diff --git a/README.md b/README.md index 5f59311..c7bbeb7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # sqlite -Package sqlite is an in-process implementation of a self-contained, serverless, zero-configuration, transactional SQL database engine. +Package sqlite is a CGo-free port of SQLite. + +SQLite is an in-process implementation of a self-contained, serverless, +zero-configuration, transactional SQL database engine. Installation diff --git a/doc.go b/doc.go index 087774a..cffd4dd 100644 --- a/doc.go +++ b/doc.go @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package sqlite is an in-process implementation of a self-contained, -// serverless, zero-configuration, transactional SQL database engine. +// Package sqlite is a CGo-free port of SQLite. +// +// SQLite is an in-process implementation of a self-contained, serverless, +// zero-configuration, transactional SQL database engine. // // Builders // diff --git a/generator.go b/generator.go index c3b08b4..eb1443b 100644 --- a/generator.go +++ b/generator.go @@ -606,7 +606,10 @@ func makeTestfixture(goos, goarch string, more []string) { "-export-fields", "F", "-trace-translation-units", volatiles, - "-lmodernc.org/tcl/lib,modernc.org/sqlite/internal/libc2,modernc.org/sqlite/libtest", + "-lmodernc.org/sqlite/internal/libc2", + "-lmodernc.org/sqlite/libtest", + "-lmodernc.org/tcl/lib", + "-lmodernc.org/z/lib", "-o", filepath.Join(dir, fmt.Sprintf("testfixture_%s_%s.go", goos, goarch)), fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/async"))), fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/fts3"))), @@ -632,6 +635,7 @@ func makeSpeedTest(goos, goarch string, more []string) { "ccgo", join( []string{ + "-export-defines", "", "-o", filepath.FromSlash(fmt.Sprintf("speedtest1/main_%s_%s.go", goos, goarch)), "-trace-translation-units", filepath.Join(sqliteSrcDir, "test", "speedtest1.c"), @@ -651,6 +655,7 @@ func makeMpTest(goos, goarch string, more []string) { "ccgo", join( []string{ + "-export-defines", "", "-o", filepath.FromSlash(fmt.Sprintf("internal/mptest/main_%s_%s.go", goos, goarch)), "-trace-translation-units", filepath.Join(sqliteSrcDir, "mptest", "mptest.c"), diff --git a/go.mod b/go.mod index b1e0681..501b6fc 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,8 @@ go 1.15 require ( github.com/mattn/go-sqlite3 v1.14.6 - modernc.org/libc v0.0.0-20210217213903-244f02c059c0 + modernc.org/libc v1.7.12 modernc.org/mathutil v1.2.2 - modernc.org/tcl v0.0.0-20210217214212-ee0aa120619d + modernc.org/tcl v0.0.0-20210221211649-a304dc2f5a60 + modernc.org/z v1.0.0 ) diff --git a/go.sum b/go.sum index be75ccd..c507879 100644 --- a/go.sum +++ b/go.sum @@ -7,15 +7,19 @@ github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qq golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201126233918-771906719818 h1:f1CIuDlJhwANEC2MM87MBEVMr3jl5bifgsfj90XAF9c= golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= modernc.org/httpfs v1.0.2 h1:4aw8F68gTwx7FWL/vEMjm/XaPwPL16MItkF/P9ziEPY= modernc.org/httpfs v1.0.2/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= -modernc.org/libc v0.0.0-20210217213903-244f02c059c0 h1:rpybsAFmoW9BAIBT5UfczUfP9Rq4kvNO+1XeI+rOlSs= -modernc.org/libc v0.0.0-20210217213903-244f02c059c0/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= +modernc.org/libc v1.7.12 h1:x4NjVrgGXghep5yT0tQr9weJc++zboRWgJqQ1cXXEug= +modernc.org/libc v1.7.12/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= modernc.org/mathutil v1.1.1 h1:FeylZSVX8S+58VsyJlkEj2bcpdytmp9MmDKZkKx8OIE= modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.2.2 h1:+yFk8hBprV+4c0U9GjFtL+dV3N8hOJ8JCituQcMShFY= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/memory v1.0.4 h1:utMBrFcpnQDdNsmM6asmyH/FM9TqLPS7XF7otpJmrwM= modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc= -modernc.org/tcl v0.0.0-20210217214212-ee0aa120619d h1:o58gI9Zp0nHaiIfjmQpNVaGPC809HhS0NniF+Ybe278= -modernc.org/tcl v0.0.0-20210217214212-ee0aa120619d/go.mod h1:elJXjEdB68/mF4pZwpWYLwv89lYlk/Yc/5lJNa7F5VM= +modernc.org/tcl v0.0.0-20210221211649-a304dc2f5a60 h1:4qgoL7Y2ztugxR1HRZBiW4eQy89tmTQDwTIz3fk+ygE= +modernc.org/tcl v0.0.0-20210221211649-a304dc2f5a60/go.mod h1:cHZNJ127VgYdlCSqFeGkGFRMb80Rii2R6z9cQTPwxzs= +modernc.org/z v1.0.0 h1:mEk+jxKT03Fz+kbVWgwJRV6V82a+xEDisa7JCSHJnBA= +modernc.org/z v1.0.0/go.mod h1:dy1pW95tOEf0gSkDFXwb2XAC+VWsFbKjZiD/qI8/9HI= diff --git a/internal/mptest/main_linux_amd64.go b/internal/mptest/main_linux_amd64.go index bb4dc64..e7df4a5 100644 --- a/internal/mptest/main_linux_amd64.go +++ b/internal/mptest/main_linux_amd64.go @@ -1,4 +1,4 @@ -// Code generated by 'ccgo -o internal/mptest/main_linux_amd64.go -trace-translation-units testdata/sqlite-src-3330000/mptest/mptest.c -Itestdata/sqlite-amalgamation-3330000 -l modernc.org/sqlite/lib -DNDEBUG -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -DSQLITE_CORE -DSQLITE_ENABLE_COLUMN_METADATA -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_UNLOCK_NOTIFY -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_MUTEX_NOOP -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_OS_UNIX=1', DO NOT EDIT. +// Code generated by 'ccgo -export-defines "" -o internal/mptest/main_linux_amd64.go -trace-translation-units testdata/sqlite-src-3330000/mptest/mptest.c -Itestdata/sqlite-amalgamation-3330000 -l modernc.org/sqlite/lib -DNDEBUG -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -DSQLITE_CORE -DSQLITE_ENABLE_COLUMN_METADATA -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_UNLOCK_NOTIFY -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_MUTEX_NOOP -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_OS_UNIX=1', DO NOT EDIT. package main @@ -9,6 +9,7 @@ import ( "unsafe" "modernc.org/libc" + "modernc.org/libc/sys/types" "modernc.org/sqlite/lib" ) @@ -16,9 +17,820 @@ var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer +var _ types.Size_t func main() { libc.Start(main1) } +const ( + BIG_ENDIAN = 4321 + BUFSIZ = 8192 + BYTE_ORDER = 1234 + DEFAULT_TIMEOUT = 10000 + E2BIG = 7 + EACCES = 13 + EADDRINUSE = 98 + EADDRNOTAVAIL = 99 + EADV = 68 + EAFNOSUPPORT = 97 + EAGAIN = 11 + EALREADY = 114 + EBADE = 52 + EBADF = 9 + EBADFD = 77 + EBADMSG = 74 + EBADR = 53 + EBADRQC = 56 + EBADSLT = 57 + EBFONT = 59 + EBUSY = 16 + ECANCELED = 125 + ECHILD = 10 + ECHRNG = 44 + ECOMM = 70 + ECONNABORTED = 103 + ECONNREFUSED = 111 + ECONNRESET = 104 + EDEADLK = 35 + EDEADLOCK = 35 + EDESTADDRREQ = 89 + EDOM = 33 + EDOTDOT = 73 + EDQUOT = 122 + EEXIST = 17 + EFAULT = 14 + EFBIG = 27 + EHOSTDOWN = 112 + EHOSTUNREACH = 113 + EHWPOISON = 133 + EIDRM = 43 + EILSEQ = 84 + EINPROGRESS = 115 + EINTR = 4 + EINVAL = 22 + EIO = 5 + EISCONN = 106 + EISDIR = 21 + EISNAM = 120 + EKEYEXPIRED = 127 + EKEYREJECTED = 129 + EKEYREVOKED = 128 + EL2HLT = 51 + EL2NSYNC = 45 + EL3HLT = 46 + EL3RST = 47 + ELIBACC = 79 + ELIBBAD = 80 + ELIBEXEC = 83 + ELIBMAX = 82 + ELIBSCN = 81 + ELNRNG = 48 + ELOOP = 40 + EMEDIUMTYPE = 124 + EMFILE = 24 + EMLINK = 31 + EMSGSIZE = 90 + EMULTIHOP = 72 + ENAMETOOLONG = 36 + ENAVAIL = 119 + ENETDOWN = 100 + ENETRESET = 102 + ENETUNREACH = 101 + ENFILE = 23 + ENOANO = 55 + ENOBUFS = 105 + ENOCSI = 50 + ENODATA = 61 + ENODEV = 19 + ENOENT = 2 + ENOEXEC = 8 + ENOKEY = 126 + ENOLCK = 37 + ENOLINK = 67 + ENOMEDIUM = 123 + ENOMEM = 12 + ENOMSG = 42 + ENONET = 64 + ENOPKG = 65 + ENOPROTOOPT = 92 + ENOSPC = 28 + ENOSR = 63 + ENOSTR = 60 + ENOSYS = 38 + ENOTBLK = 15 + ENOTCONN = 107 + ENOTDIR = 20 + ENOTEMPTY = 39 + ENOTNAM = 118 + ENOTRECOVERABLE = 131 + ENOTSOCK = 88 + ENOTSUP = 95 + ENOTTY = 25 + ENOTUNIQ = 76 + ENXIO = 6 + EOF = -1 + EOPNOTSUPP = 95 + EOVERFLOW = 75 + EOWNERDEAD = 130 + EPERM = 1 + EPFNOSUPPORT = 96 + EPIPE = 32 + EPROTO = 71 + EPROTONOSUPPORT = 93 + EPROTOTYPE = 91 + ERANGE = 34 + EREMCHG = 78 + EREMOTE = 66 + EREMOTEIO = 121 + ERESTART = 85 + ERFKILL = 132 + EROFS = 30 + ESHUTDOWN = 108 + ESOCKTNOSUPPORT = 94 + ESPIPE = 29 + ESRCH = 3 + ESRMNT = 69 + ESTALE = 116 + ESTRPIPE = 86 + ETIME = 62 + ETIMEDOUT = 110 + ETOOMANYREFS = 109 + ETXTBSY = 26 + EUCLEAN = 117 + EUNATCH = 49 + EUSERS = 87 + EWOULDBLOCK = 11 + EXDEV = 18 + EXFULL = 54 + EXIT_FAILURE = 1 + EXIT_SUCCESS = 0 + FD_SETSIZE = 1024 + FILENAME_MAX = 4096 + FOPEN_MAX = 16 + FTS5_TOKENIZE_AUX = 0x0008 + FTS5_TOKENIZE_DOCUMENT = 0x0004 + FTS5_TOKENIZE_PREFIX = 0x0002 + FTS5_TOKENIZE_QUERY = 0x0001 + FTS5_TOKEN_COLOCATED = 0x0001 + FULLY_WITHIN = 2 + F_LOCK = 1 + F_OK = 0 + F_TEST = 3 + F_TLOCK = 2 + F_ULOCK = 0 + HAVE_USLEEP = 1 + LITTLE_ENDIAN = 1234 + L_INCR = 1 + L_SET = 0 + L_XTND = 2 + L_ctermid = 9 + L_tmpnam = 20 + MX_ARG = 2 + NDEBUG = 1 + NOT_WITHIN = 0 + PARTLY_WITHIN = 1 + PDP_ENDIAN = 3412 + P_tmpdir = "/tmp" + RAND_MAX = 2147483647 + R_OK = 4 + SEEK_CUR = 1 + SEEK_END = 2 + SEEK_SET = 0 + SQLITE3_H = 0 + SQLITE3_TEXT = 3 + SQLITE_ABORT = 4 + SQLITE_ABORT_ROLLBACK = 516 + SQLITE_ACCESS_EXISTS = 0 + SQLITE_ACCESS_READ = 2 + SQLITE_ACCESS_READWRITE = 1 + SQLITE_ALTER_TABLE = 26 + SQLITE_ANALYZE = 28 + SQLITE_ANY = 5 + SQLITE_API = 0 + SQLITE_APICALL = 0 + SQLITE_ATTACH = 24 + SQLITE_AUTH = 23 + SQLITE_AUTH_USER = 279 + SQLITE_BLOB = 4 + SQLITE_BUSY = 5 + SQLITE_BUSY_RECOVERY = 261 + SQLITE_BUSY_SNAPSHOT = 517 + SQLITE_BUSY_TIMEOUT = 773 + SQLITE_CALLBACK = 0 + SQLITE_CANTOPEN = 14 + SQLITE_CANTOPEN_CONVPATH = 1038 + SQLITE_CANTOPEN_DIRTYWAL = 1294 + SQLITE_CANTOPEN_FULLPATH = 782 + SQLITE_CANTOPEN_ISDIR = 526 + SQLITE_CANTOPEN_NOTEMPDIR = 270 + SQLITE_CANTOPEN_SYMLINK = 1550 + SQLITE_CDECL = 0 + SQLITE_CHECKPOINT_FULL = 1 + SQLITE_CHECKPOINT_PASSIVE = 0 + SQLITE_CHECKPOINT_RESTART = 2 + SQLITE_CHECKPOINT_TRUNCATE = 3 + SQLITE_CONFIG_COVERING_INDEX_SCAN = 20 + SQLITE_CONFIG_GETMALLOC = 5 + SQLITE_CONFIG_GETMUTEX = 11 + SQLITE_CONFIG_GETPCACHE = 15 + SQLITE_CONFIG_GETPCACHE2 = 19 + SQLITE_CONFIG_HEAP = 8 + SQLITE_CONFIG_LOG = 16 + SQLITE_CONFIG_LOOKASIDE = 13 + SQLITE_CONFIG_MALLOC = 4 + SQLITE_CONFIG_MEMDB_MAXSIZE = 29 + SQLITE_CONFIG_MEMSTATUS = 9 + SQLITE_CONFIG_MMAP_SIZE = 22 + SQLITE_CONFIG_MULTITHREAD = 2 + SQLITE_CONFIG_MUTEX = 10 + SQLITE_CONFIG_PAGECACHE = 7 + SQLITE_CONFIG_PCACHE = 14 + SQLITE_CONFIG_PCACHE2 = 18 + SQLITE_CONFIG_PCACHE_HDRSZ = 24 + SQLITE_CONFIG_PMASZ = 25 + SQLITE_CONFIG_SCRATCH = 6 + SQLITE_CONFIG_SERIALIZED = 3 + SQLITE_CONFIG_SINGLETHREAD = 1 + SQLITE_CONFIG_SMALL_MALLOC = 27 + SQLITE_CONFIG_SORTERREF_SIZE = 28 + SQLITE_CONFIG_SQLLOG = 21 + SQLITE_CONFIG_STMTJRNL_SPILL = 26 + SQLITE_CONFIG_URI = 17 + SQLITE_CONFIG_WIN32_HEAPSIZE = 23 + SQLITE_CONSTRAINT = 19 + SQLITE_CONSTRAINT_CHECK = 275 + SQLITE_CONSTRAINT_COMMITHOOK = 531 + SQLITE_CONSTRAINT_FOREIGNKEY = 787 + SQLITE_CONSTRAINT_FUNCTION = 1043 + SQLITE_CONSTRAINT_NOTNULL = 1299 + SQLITE_CONSTRAINT_PINNED = 2835 + SQLITE_CONSTRAINT_PRIMARYKEY = 1555 + SQLITE_CONSTRAINT_ROWID = 2579 + SQLITE_CONSTRAINT_TRIGGER = 1811 + SQLITE_CONSTRAINT_UNIQUE = 2067 + SQLITE_CONSTRAINT_VTAB = 2323 + SQLITE_COPY = 0 + SQLITE_CORE = 1 + SQLITE_CORRUPT = 11 + SQLITE_CORRUPT_INDEX = 779 + SQLITE_CORRUPT_SEQUENCE = 523 + SQLITE_CORRUPT_VTAB = 267 + SQLITE_CREATE_INDEX = 1 + SQLITE_CREATE_TABLE = 2 + SQLITE_CREATE_TEMP_INDEX = 3 + SQLITE_CREATE_TEMP_TABLE = 4 + SQLITE_CREATE_TEMP_TRIGGER = 5 + SQLITE_CREATE_TEMP_VIEW = 6 + SQLITE_CREATE_TRIGGER = 7 + SQLITE_CREATE_VIEW = 8 + SQLITE_CREATE_VTABLE = 29 + SQLITE_DBCONFIG_DEFENSIVE = 1010 + SQLITE_DBCONFIG_DQS_DDL = 1014 + SQLITE_DBCONFIG_DQS_DML = 1013 + SQLITE_DBCONFIG_ENABLE_FKEY = 1002 + SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004 + SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005 + SQLITE_DBCONFIG_ENABLE_QPSG = 1007 + SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003 + SQLITE_DBCONFIG_ENABLE_VIEW = 1015 + SQLITE_DBCONFIG_LEGACY_ALTER_TABLE = 1012 + SQLITE_DBCONFIG_LEGACY_FILE_FORMAT = 1016 + SQLITE_DBCONFIG_LOOKASIDE = 1001 + SQLITE_DBCONFIG_MAINDBNAME = 1000 + SQLITE_DBCONFIG_MAX = 1017 + SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE = 1006 + SQLITE_DBCONFIG_RESET_DATABASE = 1009 + SQLITE_DBCONFIG_TRIGGER_EQP = 1008 + SQLITE_DBCONFIG_TRUSTED_SCHEMA = 1017 + SQLITE_DBCONFIG_WRITABLE_SCHEMA = 1011 + SQLITE_DBSTATUS_CACHE_HIT = 7 + SQLITE_DBSTATUS_CACHE_MISS = 8 + SQLITE_DBSTATUS_CACHE_SPILL = 12 + SQLITE_DBSTATUS_CACHE_USED = 1 + SQLITE_DBSTATUS_CACHE_USED_SHARED = 11 + SQLITE_DBSTATUS_CACHE_WRITE = 9 + SQLITE_DBSTATUS_DEFERRED_FKS = 10 + SQLITE_DBSTATUS_LOOKASIDE_HIT = 4 + SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6 + SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5 + SQLITE_DBSTATUS_LOOKASIDE_USED = 0 + SQLITE_DBSTATUS_MAX = 12 + SQLITE_DBSTATUS_SCHEMA_USED = 2 + SQLITE_DBSTATUS_STMT_USED = 3 + SQLITE_DELETE = 9 + SQLITE_DENY = 1 + SQLITE_DEPRECATED = 0 + SQLITE_DESERIALIZE_FREEONCLOSE = 1 + SQLITE_DESERIALIZE_READONLY = 4 + SQLITE_DESERIALIZE_RESIZEABLE = 2 + SQLITE_DETACH = 25 + SQLITE_DETERMINISTIC = 0x000000800 + SQLITE_DIRECTONLY = 0x000080000 + SQLITE_DONE = 101 + SQLITE_DROP_INDEX = 10 + SQLITE_DROP_TABLE = 11 + SQLITE_DROP_TEMP_INDEX = 12 + SQLITE_DROP_TEMP_TABLE = 13 + SQLITE_DROP_TEMP_TRIGGER = 14 + SQLITE_DROP_TEMP_VIEW = 15 + SQLITE_DROP_TRIGGER = 16 + SQLITE_DROP_VIEW = 17 + SQLITE_DROP_VTABLE = 30 + SQLITE_EMPTY = 16 + SQLITE_ENABLE_COLUMN_METADATA = 1 + SQLITE_ENABLE_FTS5 = 1 + SQLITE_ENABLE_GEOPOLY = 1 + SQLITE_ENABLE_JSON1 = 1 + SQLITE_ENABLE_MEMORY_MANAGEMENT = 1 + SQLITE_ENABLE_OFFSET_SQL_FUNC = 1 + SQLITE_ENABLE_PREUPDATE_HOOK = 1 + SQLITE_ENABLE_RBU = 1 + SQLITE_ENABLE_RTREE = 1 + SQLITE_ENABLE_SNAPSHOT = 1 + SQLITE_ENABLE_STAT4 = 1 + SQLITE_ENABLE_UNLOCK_NOTIFY = 1 + SQLITE_ERROR = 1 + SQLITE_ERROR_MISSING_COLLSEQ = 257 + SQLITE_ERROR_RETRY = 513 + SQLITE_ERROR_SNAPSHOT = 769 + SQLITE_EXPERIMENTAL = 0 + SQLITE_FAIL = 3 + SQLITE_FCNTL_BEGIN_ATOMIC_WRITE = 31 + SQLITE_FCNTL_BUSYHANDLER = 15 + SQLITE_FCNTL_CHUNK_SIZE = 6 + SQLITE_FCNTL_CKPT_DONE = 37 + SQLITE_FCNTL_CKPT_START = 39 + SQLITE_FCNTL_COMMIT_ATOMIC_WRITE = 32 + SQLITE_FCNTL_COMMIT_PHASETWO = 22 + SQLITE_FCNTL_DATA_VERSION = 35 + SQLITE_FCNTL_FILE_POINTER = 7 + SQLITE_FCNTL_GET_LOCKPROXYFILE = 2 + SQLITE_FCNTL_HAS_MOVED = 20 + SQLITE_FCNTL_JOURNAL_POINTER = 28 + SQLITE_FCNTL_LAST_ERRNO = 4 + SQLITE_FCNTL_LOCKSTATE = 1 + SQLITE_FCNTL_LOCK_TIMEOUT = 34 + SQLITE_FCNTL_MMAP_SIZE = 18 + SQLITE_FCNTL_OVERWRITE = 11 + SQLITE_FCNTL_PDB = 30 + SQLITE_FCNTL_PERSIST_WAL = 10 + SQLITE_FCNTL_POWERSAFE_OVERWRITE = 13 + SQLITE_FCNTL_PRAGMA = 14 + SQLITE_FCNTL_RBU = 26 + SQLITE_FCNTL_RESERVE_BYTES = 38 + SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE = 33 + SQLITE_FCNTL_SET_LOCKPROXYFILE = 3 + SQLITE_FCNTL_SIZE_HINT = 5 + SQLITE_FCNTL_SIZE_LIMIT = 36 + SQLITE_FCNTL_SYNC = 21 + SQLITE_FCNTL_SYNC_OMITTED = 8 + SQLITE_FCNTL_TEMPFILENAME = 16 + SQLITE_FCNTL_TRACE = 19 + SQLITE_FCNTL_VFSNAME = 12 + SQLITE_FCNTL_VFS_POINTER = 27 + SQLITE_FCNTL_WAL_BLOCK = 24 + SQLITE_FCNTL_WIN32_AV_RETRY = 9 + SQLITE_FCNTL_WIN32_GET_HANDLE = 29 + SQLITE_FCNTL_WIN32_SET_HANDLE = 23 + SQLITE_FCNTL_ZIPVFS = 25 + SQLITE_FLOAT = 2 + SQLITE_FORMAT = 24 + SQLITE_FULL = 13 + SQLITE_FUNCTION = 31 + SQLITE_GET_LOCKPROXYFILE = 2 + SQLITE_IGNORE = 2 + SQLITE_INDEX_CONSTRAINT_EQ = 2 + SQLITE_INDEX_CONSTRAINT_FUNCTION = 150 + SQLITE_INDEX_CONSTRAINT_GE = 32 + SQLITE_INDEX_CONSTRAINT_GLOB = 66 + SQLITE_INDEX_CONSTRAINT_GT = 4 + SQLITE_INDEX_CONSTRAINT_IS = 72 + SQLITE_INDEX_CONSTRAINT_ISNOT = 69 + SQLITE_INDEX_CONSTRAINT_ISNOTNULL = 70 + SQLITE_INDEX_CONSTRAINT_ISNULL = 71 + SQLITE_INDEX_CONSTRAINT_LE = 8 + SQLITE_INDEX_CONSTRAINT_LIKE = 65 + SQLITE_INDEX_CONSTRAINT_LT = 16 + SQLITE_INDEX_CONSTRAINT_MATCH = 64 + SQLITE_INDEX_CONSTRAINT_NE = 68 + SQLITE_INDEX_CONSTRAINT_REGEXP = 67 + SQLITE_INDEX_SCAN_UNIQUE = 1 + SQLITE_INNOCUOUS = 0x000200000 + SQLITE_INSERT = 18 + SQLITE_INTEGER = 1 + SQLITE_INTERNAL = 2 + SQLITE_INTERRUPT = 9 + SQLITE_IOCAP_ATOMIC = 0x00000001 + SQLITE_IOCAP_ATOMIC16K = 0x00000040 + SQLITE_IOCAP_ATOMIC1K = 0x00000004 + SQLITE_IOCAP_ATOMIC2K = 0x00000008 + SQLITE_IOCAP_ATOMIC32K = 0x00000080 + SQLITE_IOCAP_ATOMIC4K = 0x00000010 + SQLITE_IOCAP_ATOMIC512 = 0x00000002 + SQLITE_IOCAP_ATOMIC64K = 0x00000100 + SQLITE_IOCAP_ATOMIC8K = 0x00000020 + SQLITE_IOCAP_BATCH_ATOMIC = 0x00004000 + SQLITE_IOCAP_IMMUTABLE = 0x00002000 + SQLITE_IOCAP_POWERSAFE_OVERWRITE = 0x00001000 + SQLITE_IOCAP_SAFE_APPEND = 0x00000200 + SQLITE_IOCAP_SEQUENTIAL = 0x00000400 + SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 0x00000800 + SQLITE_IOERR = 10 + SQLITE_IOERR_ACCESS = 3338 + SQLITE_IOERR_AUTH = 7178 + SQLITE_IOERR_BEGIN_ATOMIC = 7434 + SQLITE_IOERR_BLOCKED = 2826 + SQLITE_IOERR_CHECKRESERVEDLOCK = 3594 + SQLITE_IOERR_CLOSE = 4106 + SQLITE_IOERR_COMMIT_ATOMIC = 7690 + SQLITE_IOERR_CONVPATH = 6666 + SQLITE_IOERR_DATA = 8202 + SQLITE_IOERR_DELETE = 2570 + SQLITE_IOERR_DELETE_NOENT = 5898 + SQLITE_IOERR_DIR_CLOSE = 4362 + SQLITE_IOERR_DIR_FSYNC = 1290 + SQLITE_IOERR_FSTAT = 1802 + SQLITE_IOERR_FSYNC = 1034 + SQLITE_IOERR_GETTEMPPATH = 6410 + SQLITE_IOERR_LOCK = 3850 + SQLITE_IOERR_MMAP = 6154 + SQLITE_IOERR_NOMEM = 3082 + SQLITE_IOERR_RDLOCK = 2314 + SQLITE_IOERR_READ = 266 + SQLITE_IOERR_ROLLBACK_ATOMIC = 7946 + SQLITE_IOERR_SEEK = 5642 + SQLITE_IOERR_SHMLOCK = 5130 + SQLITE_IOERR_SHMMAP = 5386 + SQLITE_IOERR_SHMOPEN = 4618 + SQLITE_IOERR_SHMSIZE = 4874 + SQLITE_IOERR_SHORT_READ = 522 + SQLITE_IOERR_TRUNCATE = 1546 + SQLITE_IOERR_UNLOCK = 2058 + SQLITE_IOERR_VNODE = 6922 + SQLITE_IOERR_WRITE = 778 + SQLITE_LAST_ERRNO = 4 + SQLITE_LIKE_DOESNT_MATCH_BLOBS = 1 + SQLITE_LIMIT_ATTACHED = 7 + SQLITE_LIMIT_COLUMN = 2 + SQLITE_LIMIT_COMPOUND_SELECT = 4 + SQLITE_LIMIT_EXPR_DEPTH = 3 + SQLITE_LIMIT_FUNCTION_ARG = 6 + SQLITE_LIMIT_LENGTH = 0 + SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8 + SQLITE_LIMIT_SQL_LENGTH = 1 + SQLITE_LIMIT_TRIGGER_DEPTH = 10 + SQLITE_LIMIT_VARIABLE_NUMBER = 9 + SQLITE_LIMIT_VDBE_OP = 5 + SQLITE_LIMIT_WORKER_THREADS = 11 + SQLITE_LOCKED = 6 + SQLITE_LOCKED_SHAREDCACHE = 262 + SQLITE_LOCKED_VTAB = 518 + SQLITE_LOCK_EXCLUSIVE = 4 + SQLITE_LOCK_NONE = 0 + SQLITE_LOCK_PENDING = 3 + SQLITE_LOCK_RESERVED = 2 + SQLITE_LOCK_SHARED = 1 + SQLITE_MISMATCH = 20 + SQLITE_MISUSE = 21 + SQLITE_MUTEX_APPDEF = 1 + SQLITE_MUTEX_FAST = 0 + SQLITE_MUTEX_NOOP = 1 + SQLITE_MUTEX_RECURSIVE = 1 + SQLITE_MUTEX_STATIC_APP1 = 8 + SQLITE_MUTEX_STATIC_APP2 = 9 + SQLITE_MUTEX_STATIC_APP3 = 10 + SQLITE_MUTEX_STATIC_LRU = 6 + SQLITE_MUTEX_STATIC_LRU2 = 7 + SQLITE_MUTEX_STATIC_MAIN = 2 + SQLITE_MUTEX_STATIC_MASTER = 2 + SQLITE_MUTEX_STATIC_MEM = 3 + SQLITE_MUTEX_STATIC_MEM2 = 4 + SQLITE_MUTEX_STATIC_OPEN = 4 + SQLITE_MUTEX_STATIC_PMEM = 7 + SQLITE_MUTEX_STATIC_PRNG = 5 + SQLITE_MUTEX_STATIC_VFS1 = 11 + SQLITE_MUTEX_STATIC_VFS2 = 12 + SQLITE_MUTEX_STATIC_VFS3 = 13 + SQLITE_NOLFS = 22 + SQLITE_NOMEM = 7 + SQLITE_NOTADB = 26 + SQLITE_NOTFOUND = 12 + SQLITE_NOTICE = 27 + SQLITE_NOTICE_RECOVER_ROLLBACK = 539 + SQLITE_NOTICE_RECOVER_WAL = 283 + SQLITE_NULL = 5 + SQLITE_OK = 0 + SQLITE_OK_LOAD_PERMANENTLY = 256 + SQLITE_OK_SYMLINK = 512 + SQLITE_OPEN_AUTOPROXY = 0x00000020 + SQLITE_OPEN_CREATE = 0x00000004 + SQLITE_OPEN_DELETEONCLOSE = 0x00000008 + SQLITE_OPEN_EXCLUSIVE = 0x00000010 + SQLITE_OPEN_FULLMUTEX = 0x00010000 + SQLITE_OPEN_MAIN_DB = 0x00000100 + SQLITE_OPEN_MAIN_JOURNAL = 0x00000800 + SQLITE_OPEN_MASTER_JOURNAL = 0x00004000 + SQLITE_OPEN_MEMORY = 0x00000080 + SQLITE_OPEN_NOFOLLOW = 0x01000000 + SQLITE_OPEN_NOMUTEX = 0x00008000 + SQLITE_OPEN_PRIVATECACHE = 0x00040000 + SQLITE_OPEN_READONLY = 0x00000001 + SQLITE_OPEN_READWRITE = 0x00000002 + SQLITE_OPEN_SHAREDCACHE = 0x00020000 + SQLITE_OPEN_SUBJOURNAL = 0x00002000 + SQLITE_OPEN_SUPER_JOURNAL = 0x00004000 + SQLITE_OPEN_TEMP_DB = 0x00000200 + SQLITE_OPEN_TEMP_JOURNAL = 0x00001000 + SQLITE_OPEN_TRANSIENT_DB = 0x00000400 + SQLITE_OPEN_URI = 0x00000040 + SQLITE_OPEN_WAL = 0x00080000 + SQLITE_OS_UNIX = 1 + SQLITE_PERM = 3 + SQLITE_PRAGMA = 19 + SQLITE_PREPARE_NORMALIZE = 0x02 + SQLITE_PREPARE_NO_VTAB = 0x04 + SQLITE_PREPARE_PERSISTENT = 0x01 + SQLITE_PROTOCOL = 15 + SQLITE_RANGE = 25 + SQLITE_READ = 20 + SQLITE_READONLY = 8 + SQLITE_READONLY_CANTINIT = 1288 + SQLITE_READONLY_CANTLOCK = 520 + SQLITE_READONLY_DBMOVED = 1032 + SQLITE_READONLY_DIRECTORY = 1544 + SQLITE_READONLY_RECOVERY = 264 + SQLITE_READONLY_ROLLBACK = 776 + SQLITE_RECURSIVE = 33 + SQLITE_REINDEX = 27 + SQLITE_REPLACE = 5 + SQLITE_ROLLBACK = 1 + SQLITE_ROW = 100 + SQLITE_SAVEPOINT = 32 + SQLITE_SCANSTAT_EST = 2 + SQLITE_SCANSTAT_EXPLAIN = 4 + SQLITE_SCANSTAT_NAME = 3 + SQLITE_SCANSTAT_NLOOP = 0 + SQLITE_SCANSTAT_NVISIT = 1 + SQLITE_SCANSTAT_SELECTID = 5 + SQLITE_SCHEMA = 17 + SQLITE_SELECT = 21 + SQLITE_SERIALIZE_NOCOPY = 0x001 + SQLITE_SET_LOCKPROXYFILE = 3 + SQLITE_SHM_EXCLUSIVE = 8 + SQLITE_SHM_LOCK = 2 + SQLITE_SHM_NLOCK = 8 + SQLITE_SHM_SHARED = 4 + SQLITE_SHM_UNLOCK = 1 + SQLITE_SOUNDEX = 1 + SQLITE_SOURCE_ID = "2020-08-14 13:23:32 fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0ff3f" + SQLITE_STATUS_MALLOC_COUNT = 9 + SQLITE_STATUS_MALLOC_SIZE = 5 + SQLITE_STATUS_MEMORY_USED = 0 + SQLITE_STATUS_PAGECACHE_OVERFLOW = 2 + SQLITE_STATUS_PAGECACHE_SIZE = 7 + SQLITE_STATUS_PAGECACHE_USED = 1 + SQLITE_STATUS_PARSER_STACK = 6 + SQLITE_STATUS_SCRATCH_OVERFLOW = 4 + SQLITE_STATUS_SCRATCH_SIZE = 8 + SQLITE_STATUS_SCRATCH_USED = 3 + SQLITE_STDCALL = 0 + SQLITE_STMTSTATUS_AUTOINDEX = 3 + SQLITE_STMTSTATUS_FULLSCAN_STEP = 1 + SQLITE_STMTSTATUS_MEMUSED = 99 + SQLITE_STMTSTATUS_REPREPARE = 5 + SQLITE_STMTSTATUS_RUN = 6 + SQLITE_STMTSTATUS_SORT = 2 + SQLITE_STMTSTATUS_VM_STEP = 4 + SQLITE_SUBTYPE = 0x000100000 + SQLITE_SYNC_DATAONLY = 0x00010 + SQLITE_SYNC_FULL = 0x00003 + SQLITE_SYNC_NORMAL = 0x00002 + SQLITE_SYSAPI = 0 + SQLITE_TESTCTRL_ALWAYS = 13 + SQLITE_TESTCTRL_ASSERT = 12 + SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10 + SQLITE_TESTCTRL_BITVEC_TEST = 8 + SQLITE_TESTCTRL_BYTEORDER = 22 + SQLITE_TESTCTRL_EXPLAIN_STMT = 19 + SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS = 29 + SQLITE_TESTCTRL_FAULT_INSTALL = 9 + SQLITE_TESTCTRL_FIRST = 5 + SQLITE_TESTCTRL_IMPOSTER = 25 + SQLITE_TESTCTRL_INTERNAL_FUNCTIONS = 17 + SQLITE_TESTCTRL_ISINIT = 23 + SQLITE_TESTCTRL_ISKEYWORD = 16 + SQLITE_TESTCTRL_LAST = 29 + SQLITE_TESTCTRL_LOCALTIME_FAULT = 18 + SQLITE_TESTCTRL_NEVER_CORRUPT = 20 + SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD = 19 + SQLITE_TESTCTRL_OPTIMIZATIONS = 15 + SQLITE_TESTCTRL_PARSER_COVERAGE = 26 + SQLITE_TESTCTRL_PENDING_BYTE = 11 + SQLITE_TESTCTRL_PRNG_RESET = 7 + SQLITE_TESTCTRL_PRNG_RESTORE = 6 + SQLITE_TESTCTRL_PRNG_SAVE = 5 + SQLITE_TESTCTRL_PRNG_SEED = 28 + SQLITE_TESTCTRL_RESERVE = 14 + SQLITE_TESTCTRL_RESULT_INTREAL = 27 + SQLITE_TESTCTRL_SCRATCHMALLOC = 17 + SQLITE_TESTCTRL_SORTER_MMAP = 24 + SQLITE_TESTCTRL_VDBE_COVERAGE = 21 + SQLITE_TEXT = 3 + SQLITE_THREADSAFE = 1 + SQLITE_TOOBIG = 18 + SQLITE_TRACE_CLOSE = 0x08 + SQLITE_TRACE_PROFILE = 0x02 + SQLITE_TRACE_ROW = 0x04 + SQLITE_TRACE_STMT = 0x01 + SQLITE_TRANSACTION = 22 + SQLITE_UPDATE = 23 + SQLITE_UTF16 = 4 + SQLITE_UTF16BE = 3 + SQLITE_UTF16LE = 2 + SQLITE_UTF16_ALIGNED = 8 + SQLITE_UTF8 = 1 + SQLITE_VERSION = "3.33.0" + SQLITE_VERSION_NUMBER = 3033000 + SQLITE_VTAB_CONSTRAINT_SUPPORT = 1 + SQLITE_VTAB_DIRECTONLY = 3 + SQLITE_VTAB_INNOCUOUS = 2 + SQLITE_WARNING = 28 + SQLITE_WARNING_AUTOINDEX = 284 + SQLITE_WIN32_DATA_DIRECTORY_TYPE = 1 + SQLITE_WIN32_TEMP_DIRECTORY_TYPE = 2 + STDERR_FILENO = 2 + STDIN_FILENO = 0 + STDOUT_FILENO = 1 + TMP_MAX = 238328 + WCONTINUED = 8 + WEXITED = 4 + WNOHANG = 1 + WNOWAIT = 0x01000000 + WSTOPPED = 2 + WUNTRACED = 2 + W_OK = 2 + X_OK = 1 + X_ALLOCA_H = 1 + X_ANSI_STDARG_H_ = 0 + X_ASM_GENERIC_ERRNO_BASE_H = 0 + X_ASM_GENERIC_ERRNO_H = 0 + X_ASSERT_H = 1 + X_ATFILE_SOURCE = 1 + X_BITS_BYTESWAP_H = 1 + X_BITS_ERRNO_H = 1 + X_BITS_FLOATN_COMMON_H = 0 + X_BITS_FLOATN_H = 0 + X_BITS_POSIX_OPT_H = 1 + X_BITS_PTHREADTYPES_ARCH_H = 1 + X_BITS_PTHREADTYPES_COMMON_H = 1 + X_BITS_STDINT_INTN_H = 1 + X_BITS_STDIO_LIM_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_TYPES_LOCALE_T_H = 1 + X_BITS_TYPES___LOCALE_T_H = 1 + X_BITS_UINTN_IDENTITY_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_CTYPE_H = 1 + X_DEFAULT_SOURCE = 1 + X_ENDIAN_H = 1 + X_ERRNO_H = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_FTS5_H = 0 + X_GCC_SIZE_T = 0 + X_GCC_WCHAR_T = 0 + X_GETOPT_CORE_H = 1 + X_GETOPT_POSIX_H = 1 + X_IOFBF = 0 + X_IOLBF = 1 + X_IONBF = 2 + X_IO_EOF_SEEN = 0x0010 + X_IO_ERR_SEEN = 0x0020 + X_IO_USER_LOCK = 0x8000 + X_LFS64_ASYNCHRONOUS_IO = 1 + X_LFS64_LARGEFILE = 1 + X_LFS64_STDIO = 1 + X_LFS_ASYNCHRONOUS_IO = 1 + X_LFS_LARGEFILE = 1 + X_LP64 = 1 + X_POSIX2_CHAR_TERM = 200809 + X_POSIX2_C_BIND = 200809 + X_POSIX2_C_DEV = 200809 + X_POSIX2_C_VERSION = 200809 + X_POSIX2_LOCALEDEF = 200809 + X_POSIX2_SW_DEV = 200809 + X_POSIX2_VERSION = 200809 + X_POSIX_ADVISORY_INFO = 200809 + X_POSIX_ASYNCHRONOUS_IO = 200809 + X_POSIX_ASYNC_IO = 1 + X_POSIX_BARRIERS = 200809 + X_POSIX_CHOWN_RESTRICTED = 0 + X_POSIX_CLOCK_SELECTION = 200809 + X_POSIX_CPUTIME = 0 + X_POSIX_C_SOURCE = 200809 + X_POSIX_FSYNC = 200809 + X_POSIX_IPV6 = 200809 + X_POSIX_JOB_CONTROL = 1 + X_POSIX_MAPPED_FILES = 200809 + X_POSIX_MEMLOCK = 200809 + X_POSIX_MEMLOCK_RANGE = 200809 + X_POSIX_MEMORY_PROTECTION = 200809 + X_POSIX_MESSAGE_PASSING = 200809 + X_POSIX_MONOTONIC_CLOCK = 0 + X_POSIX_NO_TRUNC = 1 + X_POSIX_PRIORITIZED_IO = 200809 + X_POSIX_PRIORITY_SCHEDULING = 200809 + X_POSIX_RAW_SOCKETS = 200809 + X_POSIX_READER_WRITER_LOCKS = 200809 + X_POSIX_REALTIME_SIGNALS = 200809 + X_POSIX_REENTRANT_FUNCTIONS = 1 + X_POSIX_REGEXP = 1 + X_POSIX_SAVED_IDS = 1 + X_POSIX_SEMAPHORES = 200809 + X_POSIX_SHARED_MEMORY_OBJECTS = 200809 + X_POSIX_SHELL = 1 + X_POSIX_SOURCE = 1 + X_POSIX_SPAWN = 200809 + X_POSIX_SPIN_LOCKS = 200809 + X_POSIX_SPORADIC_SERVER = -1 + X_POSIX_SYNCHRONIZED_IO = 200809 + X_POSIX_THREADS = 200809 + X_POSIX_THREAD_ATTR_STACKADDR = 200809 + X_POSIX_THREAD_ATTR_STACKSIZE = 200809 + X_POSIX_THREAD_CPUTIME = 0 + X_POSIX_THREAD_PRIORITY_SCHEDULING = 200809 + X_POSIX_THREAD_PRIO_INHERIT = 200809 + X_POSIX_THREAD_PRIO_PROTECT = 200809 + X_POSIX_THREAD_PROCESS_SHARED = 200809 + X_POSIX_THREAD_ROBUST_PRIO_INHERIT = 200809 + X_POSIX_THREAD_ROBUST_PRIO_PROTECT = -1 + X_POSIX_THREAD_SAFE_FUNCTIONS = 200809 + X_POSIX_THREAD_SPORADIC_SERVER = -1 + X_POSIX_TIMEOUTS = 200809 + X_POSIX_TIMERS = 200809 + X_POSIX_TRACE = -1 + X_POSIX_TRACE_EVENT_FILTER = -1 + X_POSIX_TRACE_INHERIT = -1 + X_POSIX_TRACE_LOG = -1 + X_POSIX_TYPED_MEMORY_OBJECTS = -1 + X_POSIX_V6_LP64_OFF64 = 1 + X_POSIX_V6_LPBIG_OFFBIG = -1 + X_POSIX_V7_LP64_OFF64 = 1 + X_POSIX_V7_LPBIG_OFFBIG = -1 + X_POSIX_VDISABLE = 0 + X_POSIX_VERSION = 200809 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_SQLITE3RTREE_H_ = 0 + X_STDARG_H = 0 + X_STDC_PREDEF_H = 1 + X_STDIO_H = 1 + X_STDLIB_H = 1 + X_STRINGS_H = 1 + X_STRING_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SELECT_H = 1 + X_SYS_SIZE_T_H = 0 + X_SYS_TYPES_H = 1 + X_THREAD_SHARED_TYPES_H = 1 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + X_T_WCHAR = 0 + X_T_WCHAR_ = 0 + X_UNISTD_H = 1 + X_VA_LIST = 0 + X_VA_LIST_ = 0 + X_VA_LIST_DEFINED = 0 + X_VA_LIST_T_H = 0 + X_WCHAR_T = 0 + X_WCHAR_T_ = 0 + X_WCHAR_T_DECLARED = 0 + X_WCHAR_T_DEFINED = 0 + X_WCHAR_T_DEFINED_ = 0 + X_WCHAR_T_H = 0 + X_XBS5_LP64_OFF64 = 1 + X_XBS5_LPBIG_OFFBIG = -1 + X_XOPEN_ENH_I18N = 1 + X_XOPEN_LEGACY = 1 + X_XOPEN_REALTIME = 1 + X_XOPEN_REALTIME_THREADS = 1 + X_XOPEN_SHM = 1 + X_XOPEN_UNIX = 1 + X_XOPEN_VERSION = 700 + X_XOPEN_XCU_VERSION = 4 + X_XOPEN_XPG2 = 1 + X_XOPEN_XPG3 = 1 + X_XOPEN_XPG4 = 1 + Linux = 1 + Unix = 1 +) + // Copyright (C) 1991-2018 Free Software Foundation, Inc. // This file is part of the GNU C Library. // @@ -4239,13 +5051,13 @@ func printWithPrefix(tls *libc.TLS, pOut uintptr, zPrefix uintptr, zMsg uintptr) bp := tls.Alloc(24) defer tls.Free(24) - for (zMsg != 0) && (*(*int8)(unsafe.Pointer(zMsg + uintptr(0))) != 0) { + for (zMsg != 0) && (*(*int8)(unsafe.Pointer(zMsg)) != 0) { var i int32 for i = 0; ((*(*int8)(unsafe.Pointer(zMsg + uintptr(i))) != 0) && (int32(*(*int8)(unsafe.Pointer(zMsg + uintptr(i)))) != '\n')) && (int32(*(*int8)(unsafe.Pointer(zMsg + uintptr(i)))) != '\r'); i++ { } libc.Xfprintf(tls, pOut, ts /* "%s%.*s\n" */, libc.VaList(bp, zPrefix, i, zMsg)) zMsg += uintptr(i) - for (int32(*(*int8)(unsafe.Pointer(zMsg + uintptr(0)))) == '\n') || (int32(*(*int8)(unsafe.Pointer(zMsg + uintptr(0)))) == '\r') { + for (int32(*(*int8)(unsafe.Pointer(zMsg))) == '\n') || (int32(*(*int8)(unsafe.Pointer(zMsg))) == '\r') { zMsg++ } } @@ -4338,7 +5150,7 @@ func strglob(tls *libc.TLS, zGlob uintptr, z uintptr) int32 { /* mptest.c:136:5: c2 = int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zGlob, 1)))) } for (c2 != 0) && (c2 != ']') { - if (((c2 == '-') && (int32(*(*int8)(unsafe.Pointer(zGlob + uintptr(0)))) != ']')) && (int32(*(*int8)(unsafe.Pointer(zGlob + uintptr(0)))) != 0)) && (prior_c > 0) { + if (((c2 == '-') && (int32(*(*int8)(unsafe.Pointer(zGlob))) != ']')) && (int32(*(*int8)(unsafe.Pointer(zGlob))) != 0)) && (prior_c > 0) { c2 = int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zGlob, 1)))) if (c >= prior_c) && (c <= c2) { seen = 1 @@ -4356,14 +5168,14 @@ func strglob(tls *libc.TLS, zGlob uintptr, z uintptr) int32 { /* mptest.c:136:5: return 0 } } else if c == '#' { - if ((int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '-') || (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '+')) && ((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(z + uintptr(1))))))*2))) & int32(_ISdigit)) != 0) { + if ((int32(*(*int8)(unsafe.Pointer(z))) == '-') || (int32(*(*int8)(unsafe.Pointer(z))) == '+')) && ((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(z + 1)))))*2))) & int32(_ISdigit)) != 0) { z++ } - if !((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(z + uintptr(0))))))*2))) & int32(_ISdigit)) != 0) { + if !((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(z)))))*2))) & int32(_ISdigit)) != 0) { return 0 } z++ - for (int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(z + uintptr(0))))))*2))) & int32(_ISdigit)) != 0 { + for (int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(z)))))*2))) & int32(_ISdigit)) != 0 { z++ } } else { @@ -4436,7 +5248,7 @@ func fatalError(tls *libc.TLS, zFormat uintptr, va uintptr) { /* mptest.c:241:13 if g.db != 0 { var nTry int32 = 0 g.iTimeout = 0 - for (trySql(tls, ts+30 /* "UPDATE client SE..." */, 0) == 5) && + for (trySql(tls, ts+30 /* "UPDATE client SE..." */, 0) == SQLITE_BUSY) && ((libc.PostIncInt32(&nTry, 1)) < 100) { sqlite3.Xsqlite3_sleep(tls, 10) } @@ -4484,7 +5296,7 @@ func vfsNameFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* *(*uintptr)(unsafe.Pointer(bp /* zVfs */)) = uintptr(0) _ = argc _ = argv - sqlite3.Xsqlite3_file_control(tls, db, ts+65 /* "main" */, 12, bp /* &zVfs */) + sqlite3.Xsqlite3_file_control(tls, db, ts+65 /* "main" */, SQLITE_FCNTL_VFSNAME, bp /* &zVfs */) if *(*uintptr)(unsafe.Pointer(bp /* zVfs */)) != 0 { sqlite3.Xsqlite3_result_text(tls, context, *(*uintptr)(unsafe.Pointer(bp /* zVfs */)), -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) } @@ -4521,16 +5333,16 @@ func sqlErrorCallback(tls *libc.TLS, pArg uintptr, iErrCode int32, zMsg uintptr) defer tls.Free(24) _ = pArg - if (iErrCode == 1) && (g.bIgnoreSqlErrors != 0) { + if (iErrCode == SQLITE_ERROR) && (g.bIgnoreSqlErrors != 0) { return } - if ((iErrCode & 0xff) == 17) && (g.iTrace < 3) { + if ((iErrCode & 0xff) == SQLITE_SCHEMA) && (g.iTrace < 3) { return } - if ((g.iTimeout == 0) && ((iErrCode & 0xff) == 5)) && (g.iTrace < 3) { + if ((g.iTimeout == 0) && ((iErrCode & 0xff) == SQLITE_BUSY)) && (g.iTrace < 3) { return } - if (iErrCode & 0xff) == 27 { + if (iErrCode & 0xff) == SQLITE_NOTICE { logMessage(tls, ts+96 /* "(info) %s" */, libc.VaList(bp, zMsg)) } else { errorMessage(tls, ts+106 /* "(errcode=%d) %s" */, libc.VaList(bp+8, iErrCode, zMsg)) @@ -4551,7 +5363,7 @@ func prepareSql(tls *libc.TLS, zFormat uintptr, va uintptr) uintptr { /* mptest. zSql = sqlite3.Xsqlite3_vmprintf(tls, zFormat, ap) _ = ap rc = sqlite3.Xsqlite3_prepare_v2(tls, g.db, zSql, -1, bp+16 /* &pStmt */, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) fatalError(tls, ts+122 /* "%s\n%s\n" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, g.db), zSql)) } @@ -4572,7 +5384,7 @@ func runSql(tls *libc.TLS, zFormat uintptr, va uintptr) { /* mptest.c:377:13: */ zSql = sqlite3.Xsqlite3_vmprintf(tls, zFormat, ap) _ = ap rc = sqlite3.Xsqlite3_exec(tls, g.db, zSql, uintptr(0), uintptr(0), uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { fatalError(tls, ts+122 /* "%s\n%s\n" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, g.db), zSql)) } sqlite3.Xsqlite3_free(tls, zSql) @@ -4635,7 +5447,7 @@ func stringReset(tls *libc.TLS, p uintptr) { /* mptest.c:437:13: */ stringAppend(tls, p, ts+143 /* " " */, 1) } (*String)(unsafe.Pointer(p)).n = 0 - *(*int8)(unsafe.Pointer((*String)(unsafe.Pointer(p)).z + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer((*String)(unsafe.Pointer(p)).z)) = int8(0) } // Append a new token onto the end of the string @@ -4655,7 +5467,7 @@ func stringAppendTerm(tls *libc.TLS, p uintptr, z uintptr) { /* mptest.c:444:13: return } stringAppend(tls, p, ts+149 /* "'" */, 1) - for *(*int8)(unsafe.Pointer(z + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(z)) != 0 { for i = 0; (*(*int8)(unsafe.Pointer(z + uintptr(i))) != 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr(i)))) != '\''); i++ { } if *(*int8)(unsafe.Pointer(z + uintptr(i))) != 0 { @@ -4719,7 +5531,7 @@ func evalFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* mpt defer tls.Free(24) var db uintptr = sqlite3.Xsqlite3_context_db_handle(tls, context) - var zSql uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zSql uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) // var res String at bp, 16 *(*uintptr)(unsafe.Pointer(bp + 16 /* zErrMsg */)) = uintptr(0) @@ -4756,12 +5568,12 @@ func startScript(tls *libc.TLS, iClient int32, pzScript uintptr, pTaskId uintptr g.iTimeout = 0 for 1 != 0 { rc = trySql(tls, ts+161 /* "BEGIN IMMEDIATE" */, 0) - if rc == 5 { + if rc == SQLITE_BUSY { sqlite3.Xsqlite3_sleep(tls, 10) totalTime = totalTime + (10) continue } - if rc != 0 { + if rc != SQLITE_OK { fatalError(tls, ts+177 /* "in startScript: ..." */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, g.db))) } if (g.nError != 0) || (g.nTest != 0) { @@ -4773,17 +5585,17 @@ func startScript(tls *libc.TLS, iClient int32, pzScript uintptr, pTaskId uintptr pStmt = prepareSql(tls, ts+249 /* "SELECT 1 FROM cl..." */, libc.VaList(bp+24, iClient)) rc = sqlite3.Xsqlite3_step(tls, pStmt) sqlite3.Xsqlite3_finalize(tls, pStmt) - if rc == 100 { + if rc == SQLITE_ROW { runSql(tls, ts+295 /* "DELETE FROM clie..." */, libc.VaList(bp+32, iClient)) - g.iTimeout = 10000 + g.iTimeout = DEFAULT_TIMEOUT runSql(tls, ts+326 /* "COMMIT TRANSACTI..." */, 0) - return 101 + return SQLITE_DONE } pStmt = prepareSql(tls, ts+346 /* "SELECT script, i..." */, libc.VaList(bp+40, iClient)) rc = sqlite3.Xsqlite3_step(tls, pStmt) - if rc == 100 { + if rc == SQLITE_ROW { var n int32 = sqlite3.Xsqlite3_column_bytes(tls, pStmt, 0) *(*uintptr)(unsafe.Pointer(pzScript)) = sqlite3.Xsqlite3_malloc(tls, (n + 1)) libc.Xstrcpy(tls, *(*uintptr)(unsafe.Pointer(pzScript)), sqlite3.Xsqlite3_column_text(tls, pStmt, 0)) @@ -4793,19 +5605,19 @@ func startScript(tls *libc.TLS, iClient int32, pzScript uintptr, pTaskId uintptr runSql(tls, ts+441 /* "UPDATE task SE..." */, libc.VaList(bp+56, taskId)) - g.iTimeout = 10000 + g.iTimeout = DEFAULT_TIMEOUT runSql(tls, ts+326 /* "COMMIT TRANSACTI..." */, 0) - return 0 + return SQLITE_OK } sqlite3.Xsqlite3_finalize(tls, pStmt) - if rc == 101 { + if rc == SQLITE_DONE { if totalTime > 30000 { errorMessage(tls, ts+524 /* "Waited over 30 s..." */, 0) runSql(tls, ts+573 /* "DELETE FROM clie..." */, libc.VaList(bp+64, iClient)) sqlite3.Xsqlite3_close(tls, g.db) libc.Xexit(tls, 1) } - for trySql(tls, ts+613 /* "COMMIT" */, 0) == 5 { + for trySql(tls, ts+613 /* "COMMIT" */, 0) == SQLITE_BUSY { sqlite3.Xsqlite3_sleep(tls, 10) totalTime = totalTime + (10) } @@ -4815,7 +5627,7 @@ func startScript(tls *libc.TLS, iClient int32, pzScript uintptr, pTaskId uintptr } fatalError(tls, ts+438 /* "%s" */, libc.VaList(bp+72, sqlite3.Xsqlite3_errmsg(tls, g.db))) } - g.iTimeout = 10000 + g.iTimeout = DEFAULT_TIMEOUT return int32(0) } @@ -4831,7 +5643,7 @@ func finishScript(tls *libc.TLS, iClient int32, taskId int32, bShutdown int32) i if bShutdown != 0 { runSql(tls, ts+295 /* "DELETE FROM clie..." */, libc.VaList(bp+8, iClient)) } - return 0 + return SQLITE_OK } // Start up a client process for iClient, if it is not already @@ -4879,7 +5691,7 @@ func readFile(tls *libc.TLS, zFilename uintptr) uintptr { /* mptest.c:684:13: */ if in == uintptr(0) { fatalError(tls, ts+867 /* "cannot open \"%s\"..." */, libc.VaList(bp, zFilename)) } - libc.Xfseek(tls, in, int64(0), 2) + libc.Xfseek(tls, in, int64(0), SEEK_END) sz = libc.Xftell(tls, in) libc.Xrewind(tls, in) z = sqlite3.Xsqlite3_malloc(tls, (int32(sz + int64(1)))) @@ -4892,10 +5704,10 @@ func readFile(tls *libc.TLS, zFilename uintptr) uintptr { /* mptest.c:684:13: */ // Return the length of the next token. func tokenLength(tls *libc.TLS, z uintptr, pnLine uintptr) int32 { /* mptest.c:704:12: */ var n int32 = 0 - if ((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(z + uintptr(0))))))*2))) & int32(_ISspace)) != 0) || ((int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '/') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == '*')) { + if ((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(z)))))*2))) & int32(_ISspace)) != 0) || ((int32(*(*int8)(unsafe.Pointer(z))) == '/') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == '*')) { var inC int32 = 0 var c int32 - if int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '/' { + if int32(*(*int8)(unsafe.Pointer(z))) == '/' { inC = 1 n = 2 } @@ -4917,15 +5729,15 @@ func tokenLength(tls *libc.TLS, z uintptr, pnLine uintptr) int32 { /* mptest.c:7 } } n-- - } else if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '-') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == '-') { + } else if (int32(*(*int8)(unsafe.Pointer(z))) == '-') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == '-') { for n = 2; (*(*int8)(unsafe.Pointer(z + uintptr(n))) != 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr(n)))) != '\n'); n++ { } if *(*int8)(unsafe.Pointer(z + uintptr(n))) != 0 { (*(*int32)(unsafe.Pointer(pnLine)))++ n++ } - } else if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '"') || (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '\'') { - var delim int32 = int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) + } else if (int32(*(*int8)(unsafe.Pointer(z))) == '"') || (int32(*(*int8)(unsafe.Pointer(z))) == '\'') { + var delim int32 = int32(*(*int8)(unsafe.Pointer(z))) for n = 1; *(*int8)(unsafe.Pointer(z + uintptr(n))) != 0; n++ { if int32(*(*int8)(unsafe.Pointer(z + uintptr(n)))) == '\n' { (*(*int32)(unsafe.Pointer(pnLine)))++ @@ -4949,7 +5761,7 @@ func tokenLength(tls *libc.TLS, z uintptr, pnLine uintptr) int32 { /* mptest.c:7 func extractToken(tls *libc.TLS, zIn uintptr, nIn int32, zOut uintptr, nOut int32) int32 { /* mptest.c:749:12: */ var i int32 if nIn <= 0 { - *(*int8)(unsafe.Pointer(zOut + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(zOut)) = int8(0) return 0 } for i = 0; ((i < nIn) && (i < (nOut - 1))) && !((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zIn + uintptr(i))))))*2))) & int32(_ISspace)) != 0); i++ { @@ -5007,15 +5819,15 @@ func waitForClient(tls *libc.TLS, iClient int32, iTimeout int32, zErrPrefix uint ts+1018 /* "SELECT 1 FROM ta..." */, 0) } g.iTimeout = 0 - for (((libc.AssignInt32(&rc, sqlite3.Xsqlite3_step(tls, pStmt))) == 5) || (rc == 100)) && + for (((libc.AssignInt32(&rc, sqlite3.Xsqlite3_step(tls, pStmt))) == SQLITE_BUSY) || (rc == SQLITE_ROW)) && (iTimeout > 0) { sqlite3.Xsqlite3_reset(tls, pStmt) sqlite3.Xsqlite3_sleep(tls, 50) iTimeout = iTimeout - (50) } sqlite3.Xsqlite3_finalize(tls, pStmt) - g.iTimeout = 10000 - if rc != 101 { + g.iTimeout = DEFAULT_TIMEOUT + if rc != SQLITE_DONE { if zErrPrefix == uintptr(0) { zErrPrefix = ts + 1099 /* "" */ } @@ -5122,7 +5934,7 @@ func runScript(tls *libc.TLS, iClient int32, taskId int32, zScript uintptr, zFil logMessage(tls, ts+1202 /* "%.*s" */, libc.VaList(bp+16, len, (zScript+uintptr(ii)))) } n = extractToken(tls, ((zScript + uintptr(ii)) + uintptr(2)), (len - 2), bp+380 /* &zCmd[0] */, int32(unsafe.Sizeof([30]int8{}))) - for nArg = 0; (n < (len - 2)) && (nArg < 2); nArg++ { + for nArg = 0; (n < (len - 2)) && (nArg < MX_ARG); nArg++ { for (n < (len - 2)) && ((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zScript + uintptr(((ii + 2) + n)))))))*2))) & int32(_ISspace)) != 0) { n++ } @@ -5132,15 +5944,15 @@ func runScript(tls *libc.TLS, iClient int32, taskId int32, zScript uintptr, zFil n = n + (extractToken(tls, (((zScript + uintptr(ii)) + uintptr(2)) + uintptr(n)), ((len - 2) - n), (bp + 410 /* &azArg[0] */ + uintptr(nArg)*100), int32(unsafe.Sizeof([100]int8{})))) } - for j = nArg; j < 2; j++ { - *(*int8)(unsafe.Pointer((bp + 410 /* &azArg[0] */ + uintptr(libc.PostIncInt32(&j, 1))*100) + uintptr(0))) = int8(0) + for j = nArg; j < MX_ARG; j++ { + *(*int8)(unsafe.Pointer((bp + 410 /* &azArg[0] */ + uintptr(libc.PostIncInt32(&j, 1))*100))) = int8(0) } // --sleep N // // Pause for N milliseconds if libc.Xstrcmp(tls, bp+380 /* &zCmd[0] */, ts+1207 /* "sleep" */) == 0 { - sqlite3.Xsqlite3_sleep(tls, libc.Xatoi(tls, (bp+410 /* &azArg[0] */ +uintptr(0)*100))) + sqlite3.Xsqlite3_sleep(tls, libc.Xatoi(tls, (bp+410 /* &azArg[0] */))) } else // --exit N @@ -5148,7 +5960,7 @@ func runScript(tls *libc.TLS, iClient int32, taskId int32, zScript uintptr, zFil // Exit this process. If N>0 then exit without shutting down // SQLite. (In other words, simulate a crash.) if libc.Xstrcmp(tls, bp+380 /* &zCmd[0] */, ts+1213 /* "exit" */) == 0 { - var rc int32 = libc.Xatoi(tls, (bp + 410 /* &azArg[0] */ + uintptr(0)*100)) + var rc int32 = libc.Xatoi(tls, (bp + 410 /* &azArg[0] */)) finishScript(tls, iClient, taskId, 1) if rc == 0 { sqlite3.Xsqlite3_close(tls, g.db) @@ -5208,7 +6020,7 @@ func runScript(tls *libc.TLS, iClient int32, taskId int32, zScript uintptr, zFil var jj int32 var zAns uintptr = (zScript + uintptr(ii)) var zCopy uintptr - var isGlob int32 = (libc.Bool32(int32(*(*int8)(unsafe.Pointer(bp + 380 /* &zCmd[0] */ + uintptr(0)))) == 'g')) + var isGlob int32 = (libc.Bool32(int32(*(*int8)(unsafe.Pointer(bp + 380 /* &zCmd[0] */))) == 'g')) for jj = (9 - (3 * isGlob)); (jj < (len - 1)) && ((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zAns + uintptr(jj))))))*2))) & int32(_ISspace)) != 0); jj++ { } zAns += uintptr(jj) @@ -5236,8 +6048,8 @@ func runScript(tls *libc.TLS, iClient int32, taskId int32, zScript uintptr, zFil var zNewFile uintptr var zNewScript uintptr var zToDel uintptr = uintptr(0) - zNewFile = (bp + 410 /* &azArg[0] */ + uintptr(0)*100) - if !((int32(*(*int8)(unsafe.Pointer(zNewFile + uintptr(0))))) == '/') { + zNewFile = (bp + 410 /* &azArg[0] */) + if !((int32(*(*int8)(unsafe.Pointer(zNewFile)))) == '/') { var k int32 for k = (int32(libc.Xstrlen(tls, zFilename)) - 1); (k >= 0) && !((int32(*(*int8)(unsafe.Pointer(zFilename + uintptr(k))))) == '/'); k-- { } @@ -5278,7 +6090,7 @@ func runScript(tls *libc.TLS, iClient int32, taskId int32, zScript uintptr, zFil } pStmt = prepareSql(tls, ts+1414 /* "SELECT %.*s" */, libc.VaList(bp+200, (len-jj), ((zScript+uintptr(ii))+uintptr(jj)))) rc = sqlite3.Xsqlite3_step(tls, pStmt) - if (rc != 100) || (sqlite3.Xsqlite3_column_int(tls, pStmt, 0) == 0) { + if (rc != SQLITE_ROW) || (sqlite3.Xsqlite3_column_int(tls, pStmt, 0) == 0) { ii = ii + (findEndif(tls, ((zScript + uintptr(ii)) + uintptr(len)), 1, bp+376 /* &lineno */)) } sqlite3.Xsqlite3_finalize(tls, pStmt) @@ -5304,7 +6116,7 @@ func runScript(tls *libc.TLS, iClient int32, taskId int32, zScript uintptr, zFil // // Start up the given client. if (libc.Xstrcmp(tls, bp+380 /* &zCmd[0] */, ts+1437 /* "start" */) == 0) && (iClient == 0) { - var iNewClient int32 = libc.Xatoi(tls, (bp + 410 /* &azArg[0] */ + uintptr(0)*100)) + var iNewClient int32 = libc.Xatoi(tls, (bp + 410 /* &azArg[0] */)) if iNewClient > 0 { startClient(tls, iNewClient) } @@ -5318,13 +6130,13 @@ func runScript(tls *libc.TLS, iClient int32, taskId int32, zScript uintptr, zFil if (libc.Xstrcmp(tls, bp+380 /* &zCmd[0] */, ts+1443 /* "wait" */) == 0) && (iClient == 0) { var iTimeout int32 if nArg >= 2 { - iTimeout = libc.Xatoi(tls, (bp + 410 /* &azArg[0] */ + uintptr(1)*100)) + iTimeout = libc.Xatoi(tls, (bp + 410 /* &azArg[0] */ + 1*100)) } else { iTimeout = 10000 } sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([1000]int8{})), bp+610 /* &zError[0] */, ts+1448, /* "line %d of %s\n" */ libc.VaList(bp+216, prevLine, zFilename)) - waitForClient(tls, libc.Xatoi(tls, (bp+410 /* &azArg[0] */ +uintptr(0)*100)), iTimeout, bp+610 /* &zError[0] */) + waitForClient(tls, libc.Xatoi(tls, (bp+410 /* &azArg[0] */)), iTimeout, bp+610 /* &zError[0] */) } else // --task CLIENT @@ -5334,7 +6146,7 @@ func runScript(tls *libc.TLS, iClient int32, taskId int32, zScript uintptr, zFil // Assign work to a client. Start the client if it is not running // already. if (libc.Xstrcmp(tls, bp+380 /* &zCmd[0] */, ts+1463 /* "task" */) == 0) && (iClient == 0) { - var iTarget int32 = libc.Xatoi(tls, (bp + 410 /* &azArg[0] */ + uintptr(0)*100)) + var iTarget int32 = libc.Xatoi(tls, (bp + 410 /* &azArg[0] */)) var iEnd int32 var zTask uintptr var zTName uintptr @@ -5345,7 +6157,7 @@ func runScript(tls *libc.TLS, iClient int32, taskId int32, zScript uintptr, zFil } else { zTask = sqlite3.Xsqlite3_mprintf(tls, ts+1202 /* "%.*s" */, libc.VaList(bp+256, iEnd, ((zScript+uintptr(ii))+uintptr(len)))) if nArg > 1 { - zTName = sqlite3.Xsqlite3_mprintf(tls, ts+438 /* "%s" */, libc.VaList(bp+272, (bp+410 /* &azArg[0] */ +uintptr(1)*100))) + zTName = sqlite3.Xsqlite3_mprintf(tls, ts+438 /* "%s" */, libc.VaList(bp+272, (bp+410 /* &azArg[0] */ +1*100))) } else { zTName = sqlite3.Xsqlite3_mprintf(tls, ts+1505 /* "%s:%d" */, libc.VaList(bp+280, filenameTail(tls, zFilename), prevLine)) } @@ -5374,7 +6186,7 @@ func runScript(tls *libc.TLS, iClient int32, taskId int32, zScript uintptr, zFil if libc.Xstrcmp(tls, bp+380 /* &zCmd[0] */, ts+1578 /* "show-sql-errors" */) == 0 { g.bIgnoreSqlErrors = func() int32 { if nArg >= 1 { - return libc.BoolInt32(!(booleanValue(tls, (bp+410 /* &azArg[0] */ +uintptr(0)*100)) != 0)) + return libc.BoolInt32(!(booleanValue(tls, (bp+410 /* &azArg[0] */)) != 0)) } return 1 }() @@ -5413,12 +6225,12 @@ func findOption(tls *libc.TLS, azArg uintptr, pnArg uintptr, zOption uintptr, ha break } z = *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)) - if int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) != '-' { + if int32(*(*int8)(unsafe.Pointer(z))) != '-' { continue } z++ - if int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '-' { - if int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(z))) == '-' { + if int32(*(*int8)(unsafe.Pointer(z + 1))) == 0 { break } z++ @@ -5485,7 +6297,7 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* mptest.c:1279:18: // var n int32 at bp+232, 4 var i int32 - var openFlags int32 = 0x00000002 + var openFlags int32 = SQLITE_OPEN_READWRITE var rc int32 // var zScript uintptr at bp+240, 8 @@ -5500,14 +6312,14 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* mptest.c:1279:18: var iTmout int32 = 0 // Default: no timeout var zTmout uintptr - g.argv0 = *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)) + g.argv0 = *(*uintptr)(unsafe.Pointer(argv)) g.iTrace = 1 if argc < 2 { - usage(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + usage(tls, *(*uintptr)(unsafe.Pointer(argv))) } - g.zDbFile = *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) + g.zDbFile = *(*uintptr)(unsafe.Pointer(argv + 1*8)) if strglob(tls, ts+2323 /* "*.test" */, g.zDbFile) != 0 { - usage(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + usage(tls, *(*uintptr)(unsafe.Pointer(argv))) } if libc.Xstrcmp(tls, sqlite3.Xsqlite3_sourceid(tls), ts+2330 /* "2020-08-14 13:23..." */) != 0 { libc.Xfprintf(tls, libc.Xstderr, @@ -5554,7 +6366,7 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* mptest.c:1279:18: g.pLog = libc.Xstdout } - sqlite3.Xsqlite3_config(tls, 16, libc.VaList(bp+24, *(*uintptr)(unsafe.Pointer(&struct { + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_LOG, libc.VaList(bp+24, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{sqlErrorCallback})), 0)) if zClient != 0 { @@ -5567,7 +6379,7 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* mptest.c:1279:18: } else { var nTry int32 = 0 if g.iTrace > 0 { - libc.Xprintf(tls, ts+2607 /* "BEGIN: %s" */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + libc.Xprintf(tls, ts+2607 /* "BEGIN: %s" */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(argv)))) for i = 1; i < argc; i++ { libc.Xprintf(tls, ts+2317 /* " %s" */, libc.VaList(bp+72, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) } @@ -5590,7 +6402,7 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* mptest.c:1279:18: }(), g.zDbFile)) } rc = libc.Xunlink(tls, g.zDbFile) - if (rc != 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 2) { + if (rc != 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == ENOENT) { rc = 0 } } @@ -5598,7 +6410,7 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* mptest.c:1279:18: fatalError(tls, ts+2771, /* "unable to unlink..." */ libc.VaList(bp+104, g.zDbFile, nTry)) } - openFlags = openFlags | (0x00000004) + openFlags = openFlags | (SQLITE_OPEN_CREATE) } rc = sqlite3.Xsqlite3_open_v2(tls, g.zDbFile, (uintptr(unsafe.Pointer(&g)) + 24 /* &.db */), openFlags, g.zVfs) if rc != 0 { @@ -5618,15 +6430,15 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* mptest.c:1279:18: sqlite3.Xsqlite3_busy_handler(tls, g.db, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32) int32 }{busyHandler})), uintptr(0)) - sqlite3.Xsqlite3_create_function(tls, g.db, ts+2876 /* "vfsname" */, 0, 1, uintptr(0), + sqlite3.Xsqlite3_create_function(tls, g.db, ts+2876 /* "vfsname" */, 0, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{vfsNameFunc})), uintptr(0), uintptr(0)) - sqlite3.Xsqlite3_create_function(tls, g.db, ts+2884 /* "eval" */, 1, 1, uintptr(0), + sqlite3.Xsqlite3_create_function(tls, g.db, ts+2884 /* "eval" */, 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{evalFunc})), uintptr(0), uintptr(0)) - g.iTimeout = 10000 + g.iTimeout = DEFAULT_TIMEOUT if g.bSqlTrace != 0 { sqlite3.Xsqlite3_trace(tls, g.db, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) @@ -5634,7 +6446,7 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* mptest.c:1279:18: } if iClient > 0 { if *(*int32)(unsafe.Pointer(bp + 232 /* n */)) > 0 { - unrecognizedArguments(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), *(*int32)(unsafe.Pointer(bp + 232 /* n */)), (argv + uintptr(2)*8)) + unrecognizedArguments(tls, *(*uintptr)(unsafe.Pointer(argv)), *(*int32)(unsafe.Pointer(bp + 232 /* n */)), (argv + uintptr(2)*8)) } if g.iTrace != 0 { logMessage(tls, ts+2889 /* "start-client" */, 0) @@ -5642,7 +6454,7 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* mptest.c:1279:18: for 1 != 0 { *(*uintptr)(unsafe.Pointer(bp + 256 /* zTaskName */)) = uintptr(0) rc = startScript(tls, iClient, bp+240 /* &zScript */, bp+248 /* &taskId */, bp+256 /* &zTaskName */) - if rc == 101 { + if rc == SQLITE_DONE { break } if g.iTrace != 0 { @@ -5666,19 +6478,19 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* mptest.c:1279:18: fatalError(tls, ts+2939 /* "missing script f..." */, 0) } if *(*int32)(unsafe.Pointer(bp + 232 /* n */)) > 1 { - unrecognizedArguments(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), *(*int32)(unsafe.Pointer(bp + 232 /* n */)), (argv + uintptr(2)*8)) + unrecognizedArguments(tls, *(*uintptr)(unsafe.Pointer(argv)), *(*int32)(unsafe.Pointer(bp + 232 /* n */)), (argv + uintptr(2)*8)) } runSql(tls, ts+2963 /* "DROP TABLE IF EX..." */, 0) - *(*uintptr)(unsafe.Pointer(bp + 240 /* zScript */)) = readFile(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + *(*uintptr)(unsafe.Pointer(bp + 240 /* zScript */)) = readFile(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) for iRep = 1; iRep <= nRep; iRep++ { if g.iTrace != 0 { - logMessage(tls, ts+3399 /* "begin script [%s..." */, libc.VaList(bp+168, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), iRep)) + logMessage(tls, ts+3399 /* "begin script [%s..." */, libc.VaList(bp+168, *(*uintptr)(unsafe.Pointer(argv + 2*8)), iRep)) } - runScript(tls, 0, 0, *(*uintptr)(unsafe.Pointer(bp + 240 /* zScript */)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + runScript(tls, 0, 0, *(*uintptr)(unsafe.Pointer(bp + 240 /* zScript */)), *(*uintptr)(unsafe.Pointer(argv + 2*8))) if g.iTrace != 0 { - logMessage(tls, ts+3427 /* "end script [%s] ..." */, libc.VaList(bp+184, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), iRep)) + logMessage(tls, ts+3427 /* "end script [%s] ..." */, libc.VaList(bp+184, *(*uintptr)(unsafe.Pointer(argv + 2*8)), iRep)) } } sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 240 /* zScript */))) @@ -5687,19 +6499,19 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* mptest.c:1279:18: sqlite3.Xsqlite3_sleep(tls, 10) g.iTimeout = 0 iTimeout = 1000 - for (((libc.AssignInt32(&rc, trySql(tls, ts+3502 /* "SELECT 1 FROM cl..." */, 0))) == 5) || - (rc == 100)) && (iTimeout > 0) { + for (((libc.AssignInt32(&rc, trySql(tls, ts+3502 /* "SELECT 1 FROM cl..." */, 0))) == SQLITE_BUSY) || + (rc == SQLITE_ROW)) && (iTimeout > 0) { sqlite3.Xsqlite3_sleep(tls, 10) iTimeout = iTimeout - (10) } sqlite3.Xsqlite3_sleep(tls, 100) pStmt = prepareSql(tls, ts+3523 /* "SELECT nError, n..." */, 0) iTimeout = 1000 - for ((libc.AssignInt32(&rc, sqlite3.Xsqlite3_step(tls, pStmt))) == 5) && (iTimeout > 0) { + for ((libc.AssignInt32(&rc, sqlite3.Xsqlite3_step(tls, pStmt))) == SQLITE_BUSY) && (iTimeout > 0) { sqlite3.Xsqlite3_sleep(tls, 10) iTimeout = iTimeout - (10) } - if rc == 100 { + if rc == SQLITE_ROW { *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&g)) + 112 /* &.nError */)) += (sqlite3.Xsqlite3_column_int(tls, pStmt, 0)) *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&g)) + 116 /* &.nTest */)) += (sqlite3.Xsqlite3_column_int(tls, pStmt, 1)) } @@ -5710,7 +6522,7 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* mptest.c:1279:18: maybeClose(tls, g.pErrLog) if iClient == 0 { libc.Xprintf(tls, ts+3558 /* "Summary: %d erro..." */, libc.VaList(bp+200, g.nError, g.nTest)) - libc.Xprintf(tls, ts+3594 /* "END: %s" */, libc.VaList(bp+216, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + libc.Xprintf(tls, ts+3594 /* "END: %s" */, libc.VaList(bp+216, *(*uintptr)(unsafe.Pointer(argv)))) for i = 1; i < argc; i++ { libc.Xprintf(tls, ts+2317 /* " %s" */, libc.VaList(bp+224, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) } diff --git a/internal/testfixture/testfixture_linux_amd64.go b/internal/testfixture/testfixture_linux_amd64.go index 45fb616..6a7d9fc 100644 --- a/internal/testfixture/testfixture_linux_amd64.go +++ b/internal/testfixture/testfixture_linux_amd64.go @@ -1,4 +1,4 @@ -// 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/tcl/lib,modernc.org/sqlite/internal/libc2,modernc.org/sqlite/libtest -o internal/testfixture/testfixture_linux_amd64.go -Itestdata/sqlite-src-3330000/ext/async -Itestdata/sqlite-src-3330000/ext/fts3 -Itestdata/sqlite-src-3330000/ext/icu -Itestdata/sqlite-src-3330000/ext/rtree -Itestdata/sqlite-src-3330000/ext/session -Itestdata/sqlite-src-3330000/ext/userauth -Itestdata/sqlite-src-3330000/src -Itestdata/sqlite-amalgamation-3330000 -Itestdata/sqlite-src-3330000 testdata/sqlite-src-3330000/ext/expert/sqlite3expert.c testdata/sqlite-src-3330000/ext/expert/test_expert.c testdata/sqlite-src-3330000/ext/fts3/fts3_term.c testdata/sqlite-src-3330000/ext/fts3/fts3_test.c testdata/sqlite-src-3330000/ext/fts5/fts5_tcl.c testdata/sqlite-src-3330000/ext/fts5/fts5_test_mi.c testdata/sqlite-src-3330000/ext/fts5/fts5_test_tok.c testdata/sqlite-src-3330000/ext/misc/amatch.c testdata/sqlite-src-3330000/ext/misc/carray.c testdata/sqlite-src-3330000/ext/misc/closure.c testdata/sqlite-src-3330000/ext/misc/csv.c testdata/sqlite-src-3330000/ext/misc/decimal.c testdata/sqlite-src-3330000/ext/misc/eval.c testdata/sqlite-src-3330000/ext/misc/explain.c testdata/sqlite-src-3330000/ext/misc/fileio.c testdata/sqlite-src-3330000/ext/misc/fuzzer.c testdata/sqlite-src-3330000/ext/misc/ieee754.c testdata/sqlite-src-3330000/ext/misc/mmapwarm.c testdata/sqlite-src-3330000/ext/misc/nextchar.c testdata/sqlite-src-3330000/ext/misc/normalize.c testdata/sqlite-src-3330000/ext/misc/percentile.c testdata/sqlite-src-3330000/ext/misc/prefixes.c testdata/sqlite-src-3330000/ext/misc/regexp.c testdata/sqlite-src-3330000/ext/misc/remember.c testdata/sqlite-src-3330000/ext/misc/series.c testdata/sqlite-src-3330000/ext/misc/spellfix.c testdata/sqlite-src-3330000/ext/misc/totype.c testdata/sqlite-src-3330000/ext/misc/unionvtab.c testdata/sqlite-src-3330000/ext/misc/wholenumber.c testdata/sqlite-src-3330000/ext/misc/zipfile.c testdata/sqlite-src-3330000/ext/rbu/test_rbu.c testdata/sqlite-src-3330000/ext/userauth/userauth.c testdata/sqlite-src-3330000/src/tclsqlite.c testdata/sqlite-src-3330000/src/test1.c testdata/sqlite-src-3330000/src/test2.c testdata/sqlite-src-3330000/src/test3.c testdata/sqlite-src-3330000/src/test4.c testdata/sqlite-src-3330000/src/test5.c testdata/sqlite-src-3330000/src/test6.c testdata/sqlite-src-3330000/src/test7.c testdata/sqlite-src-3330000/src/test8.c testdata/sqlite-src-3330000/src/test9.c testdata/sqlite-src-3330000/src/test_async.c testdata/sqlite-src-3330000/src/test_autoext.c testdata/sqlite-src-3330000/src/test_backup.c testdata/sqlite-src-3330000/src/test_bestindex.c testdata/sqlite-src-3330000/src/test_blob.c testdata/sqlite-src-3330000/src/test_btree.c testdata/sqlite-src-3330000/src/test_config.c testdata/sqlite-src-3330000/src/test_delete.c testdata/sqlite-src-3330000/src/test_demovfs.c testdata/sqlite-src-3330000/src/test_devsym.c testdata/sqlite-src-3330000/src/test_fs.c testdata/sqlite-src-3330000/src/test_func.c testdata/sqlite-src-3330000/src/test_hexio.c testdata/sqlite-src-3330000/src/test_init.c testdata/sqlite-src-3330000/src/test_intarray.c testdata/sqlite-src-3330000/src/test_journal.c testdata/sqlite-src-3330000/src/test_malloc.c testdata/sqlite-src-3330000/src/test_md5.c testdata/sqlite-src-3330000/src/test_multiplex.c testdata/sqlite-src-3330000/src/test_mutex.c testdata/sqlite-src-3330000/src/test_onefile.c testdata/sqlite-src-3330000/src/test_osinst.c testdata/sqlite-src-3330000/src/test_pcache.c testdata/sqlite-src-3330000/src/test_quota.c testdata/sqlite-src-3330000/src/test_rtree.c testdata/sqlite-src-3330000/src/test_schema.c testdata/sqlite-src-3330000/src/test_server.c testdata/sqlite-src-3330000/src/test_superlock.c testdata/sqlite-src-3330000/src/test_syscall.c testdata/sqlite-src-3330000/src/test_tclsh.c testdata/sqlite-src-3330000/src/test_tclvar.c testdata/sqlite-src-3330000/src/test_thread.c testdata/sqlite-src-3330000/src/test_vdbecov.c testdata/sqlite-src-3330000/src/test_vfs.c testdata/sqlite-src-3330000/src/test_windirent.c testdata/sqlite-src-3330000/src/test_window.c testdata/sqlite-src-3330000/src/test_wsd.c -DNDEBUG -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -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_MUTEX_NOOP -DSQLITE_SOUNDEX -DSQLITE_TEMP_STORE=1 -DSQLITE_TEST -DSQLITE_THREADSAFE=1', DO NOT EDIT. +// 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/internal/libc2 -lmodernc.org/sqlite/libtest -lmodernc.org/tcl/lib -lmodernc.org/z/lib -o internal/testfixture/testfixture_linux_amd64.go -Itestdata/sqlite-src-3330000/ext/async -Itestdata/sqlite-src-3330000/ext/fts3 -Itestdata/sqlite-src-3330000/ext/icu -Itestdata/sqlite-src-3330000/ext/rtree -Itestdata/sqlite-src-3330000/ext/session -Itestdata/sqlite-src-3330000/ext/userauth -Itestdata/sqlite-src-3330000/src -Itestdata/sqlite-amalgamation-3330000 -Itestdata/sqlite-src-3330000 testdata/sqlite-src-3330000/ext/expert/sqlite3expert.c testdata/sqlite-src-3330000/ext/expert/test_expert.c testdata/sqlite-src-3330000/ext/fts3/fts3_term.c testdata/sqlite-src-3330000/ext/fts3/fts3_test.c testdata/sqlite-src-3330000/ext/fts5/fts5_tcl.c testdata/sqlite-src-3330000/ext/fts5/fts5_test_mi.c testdata/sqlite-src-3330000/ext/fts5/fts5_test_tok.c testdata/sqlite-src-3330000/ext/misc/amatch.c testdata/sqlite-src-3330000/ext/misc/carray.c testdata/sqlite-src-3330000/ext/misc/closure.c testdata/sqlite-src-3330000/ext/misc/csv.c testdata/sqlite-src-3330000/ext/misc/decimal.c testdata/sqlite-src-3330000/ext/misc/eval.c testdata/sqlite-src-3330000/ext/misc/explain.c testdata/sqlite-src-3330000/ext/misc/fileio.c testdata/sqlite-src-3330000/ext/misc/fuzzer.c testdata/sqlite-src-3330000/ext/misc/ieee754.c testdata/sqlite-src-3330000/ext/misc/mmapwarm.c testdata/sqlite-src-3330000/ext/misc/nextchar.c testdata/sqlite-src-3330000/ext/misc/normalize.c testdata/sqlite-src-3330000/ext/misc/percentile.c testdata/sqlite-src-3330000/ext/misc/prefixes.c testdata/sqlite-src-3330000/ext/misc/regexp.c testdata/sqlite-src-3330000/ext/misc/remember.c testdata/sqlite-src-3330000/ext/misc/series.c testdata/sqlite-src-3330000/ext/misc/spellfix.c testdata/sqlite-src-3330000/ext/misc/totype.c testdata/sqlite-src-3330000/ext/misc/unionvtab.c testdata/sqlite-src-3330000/ext/misc/wholenumber.c testdata/sqlite-src-3330000/ext/misc/zipfile.c testdata/sqlite-src-3330000/ext/rbu/test_rbu.c testdata/sqlite-src-3330000/ext/userauth/userauth.c testdata/sqlite-src-3330000/src/tclsqlite.c testdata/sqlite-src-3330000/src/test1.c testdata/sqlite-src-3330000/src/test2.c testdata/sqlite-src-3330000/src/test3.c testdata/sqlite-src-3330000/src/test4.c testdata/sqlite-src-3330000/src/test5.c testdata/sqlite-src-3330000/src/test6.c testdata/sqlite-src-3330000/src/test7.c testdata/sqlite-src-3330000/src/test8.c testdata/sqlite-src-3330000/src/test9.c testdata/sqlite-src-3330000/src/test_async.c testdata/sqlite-src-3330000/src/test_autoext.c testdata/sqlite-src-3330000/src/test_backup.c testdata/sqlite-src-3330000/src/test_bestindex.c testdata/sqlite-src-3330000/src/test_blob.c testdata/sqlite-src-3330000/src/test_btree.c testdata/sqlite-src-3330000/src/test_config.c testdata/sqlite-src-3330000/src/test_delete.c testdata/sqlite-src-3330000/src/test_demovfs.c testdata/sqlite-src-3330000/src/test_devsym.c testdata/sqlite-src-3330000/src/test_fs.c testdata/sqlite-src-3330000/src/test_func.c testdata/sqlite-src-3330000/src/test_hexio.c testdata/sqlite-src-3330000/src/test_init.c testdata/sqlite-src-3330000/src/test_intarray.c testdata/sqlite-src-3330000/src/test_journal.c testdata/sqlite-src-3330000/src/test_malloc.c testdata/sqlite-src-3330000/src/test_md5.c testdata/sqlite-src-3330000/src/test_multiplex.c testdata/sqlite-src-3330000/src/test_mutex.c testdata/sqlite-src-3330000/src/test_onefile.c testdata/sqlite-src-3330000/src/test_osinst.c testdata/sqlite-src-3330000/src/test_pcache.c testdata/sqlite-src-3330000/src/test_quota.c testdata/sqlite-src-3330000/src/test_rtree.c testdata/sqlite-src-3330000/src/test_schema.c testdata/sqlite-src-3330000/src/test_server.c testdata/sqlite-src-3330000/src/test_superlock.c testdata/sqlite-src-3330000/src/test_syscall.c testdata/sqlite-src-3330000/src/test_tclsh.c testdata/sqlite-src-3330000/src/test_tclvar.c testdata/sqlite-src-3330000/src/test_thread.c testdata/sqlite-src-3330000/src/test_vdbecov.c testdata/sqlite-src-3330000/src/test_vfs.c testdata/sqlite-src-3330000/src/test_windirent.c testdata/sqlite-src-3330000/src/test_window.c testdata/sqlite-src-3330000/src/test_wsd.c -DNDEBUG -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -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_MUTEX_NOOP -DSQLITE_SOUNDEX -DSQLITE_TEMP_STORE=1 -DSQLITE_TEST -DSQLITE_THREADSAFE=1', DO NOT EDIT. package main @@ -9,15 +9,18 @@ import ( "unsafe" "modernc.org/libc" + "modernc.org/libc/sys/types" "modernc.org/sqlite/internal/libc2" "modernc.org/sqlite/libtest" "modernc.org/tcl/lib" + "modernc.org/z/lib" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer +var _ types.Size_t func main() { libc.Start(main1) } @@ -574,7 +577,6 @@ const ( Linux = 1 Unix = 1 CRTIMPORT = 0 - DLLEXPORT = 0 DLLIMPORT = 0 INLINE = 0 MP_DIGIT_DECLARED = 0 @@ -681,7 +683,6 @@ const ( TCL_MODE_BLOCKING = 0 TCL_MODE_NONBLOCKING = 1 TCL_NAMESPACE_ONLY = 2 - TCL_NORETURN = 0 TCL_NORETURN1 = 0 TCL_NO_EVAL = 0x010000 TCL_OK = 0 @@ -845,7 +846,6 @@ const ( CSVTEST_FIDX = 0x0001 CSV_INBUFSZ = 1024 CSV_MXERR = 200 - CSV_NOINLINE = 0 EXPLN_COLUMN_ADDR = 0 EXPLN_COLUMN_COMMENT = 7 EXPLN_COLUMN_OPCODE = 1 @@ -2391,7 +2391,6 @@ const ( SQLITE_MSVC_H = 0 SQLITE_MX_JUMP_OPCODE = 62 SQLITE_NEED_ERR_NAME = 0 - SQLITE_NOINLINE = 0 SQLITE_NOMEM_BKPT = 7 SQLITE_NOTNULL = 0x90 SQLITE_NULLEQ = 0x80 @@ -3085,50 +3084,8 @@ const ( TESTVFS_WRITE_MASK = 0x00001000 ) -// end block for C++ - -// Local Variables: -// mode: c -// c-basic-offset: 4 -// fill-column: 78 -// End: -// Copyright (C) 1991-2018 Free Software Foundation, Inc. -// This file is part of the GNU C Library. -// -// The GNU C Library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// The GNU C Library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with the GNU C Library; if not, see -// . - -// ISO C99 Standard: 7.20 General utilities - -// Copyright (C) 1991-2018 Free Software Foundation, Inc. -// This file is part of the GNU C Library. -// -// The GNU C Library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// The GNU C Library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with the GNU C Library; if not, see -// . - -// ISO C99 Standard: 7.21 String handling +// If we are compiling with optimizing read this file. It contains +// several optimizing inline functions and macros. // Copyright (C) 1991-2018 Free Software Foundation, Inc. // This file is part of the GNU C Library. @@ -3817,9 +3774,15 @@ const ( /* resource.h:187:1: */ PRIO_USER = 2 ) -// Convenience macros for operations on timevals. -// NOTE: `timercmp' does not work for >= or <=. +// end block for C++ +// Local Variables: +// mode: c +// c-basic-offset: 4 +// fill-column: 78 +// End: + +// Needed for the setrlimit() system call on unix // Copyright (C) 1992-2018 Free Software Foundation, Inc. // This file is part of the GNU C Library. // @@ -7385,7 +7348,7 @@ func idxMalloc(tls *libc.TLS, pRc uintptr, nByte int32) uintptr { /* sqlite3expe if pRet != 0 { libc.Xmemset(tls, pRet, 0, uint64(nByte)) } else { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } return pRet } @@ -7398,7 +7361,7 @@ func idxHashInit(tls *libc.TLS, pHash uintptr) { /* sqlite3expert.c:174:13: */ // Reset an IdxHash hash table. func idxHashClear(tls *libc.TLS, pHash uintptr) { /* sqlite3expert.c:181:13: */ var i int32 - for i = 0; i < 1023; i++ { + for i = 0; i < IDX_HASH_SIZE; i++ { var pEntry uintptr var pNext uintptr for pEntry = *(*uintptr)(unsafe.Pointer((pHash + 8 /* &.aHash */) + uintptr(i)*8)); pEntry != 0; pEntry = pNext { @@ -7418,7 +7381,7 @@ func idxHashString(tls *libc.TLS, z uintptr, n int32) int32 { /* sqlite3expert.c for i = 0; i < n; i++ { ret = ret + ((ret << 3) + uint32((uint8(*(*int8)(unsafe.Pointer(z + uintptr(i))))))) } - return (int32(ret % uint32(1023))) + return (int32(ret % IDX_HASH_SIZE)) } // If zKey is already present in the hash table, return non-zero and do @@ -7442,7 +7405,7 @@ func idxHashAdd(tls *libc.TLS, pRc uintptr, pHash uintptr, zKey uintptr, zVal ui } pEntry = idxMalloc(tls, pRc, (int32((((uint64(unsafe.Sizeof(IdxHashEntry{})) + uint64(nKey)) + uint64(1)) + uint64(nVal)) + uint64(1)))) if pEntry != 0 { - (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzKey = (pEntry + uintptr(1)*40) + (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzKey = (pEntry + 1*40) libc.Xmemcpy(tls, (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzKey, zKey, uint64(nKey)) if zVal != 0 { (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzVal = ((*IdxHashEntry)(unsafe.Pointer(pEntry)).FzKey + uintptr((nKey + 1))) @@ -7495,7 +7458,7 @@ func idxNewConstraint(tls *libc.TLS, pRc uintptr, zColl uintptr) uintptr { /* sq pNew = idxMalloc(tls, pRc, (int32((uint64(unsafe.Sizeof(IdxConstraint{})) * uint64(nColl)) + uint64(1)))) if pNew != 0 { - (*IdxConstraint)(unsafe.Pointer(pNew)).FzColl = (pNew + uintptr(1)*40) + (*IdxConstraint)(unsafe.Pointer(pNew)).FzColl = (pNew + 1*40) libc.Xmemcpy(tls, (*IdxConstraint)(unsafe.Pointer(pNew)).FzColl, zColl, (uint64(nColl + 1))) } return pNew @@ -7513,7 +7476,7 @@ func idxDatabaseError(tls *libc.TLS, db uintptr, pzErrmsg uintptr) { /* sqlite3e // Prepare an SQL statement. func idxPrepareStmt(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErrmsg uintptr, zSql uintptr) int32 { /* sqlite3expert.c:307:12: */ var rc int32 = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, ppStmt, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0) idxDatabaseError(tls, db, pzErrmsg) } @@ -7529,7 +7492,7 @@ func idxPrintfPrepareStmt(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErrmsg ui ap = va zSql = sqlite3.Xsqlite3_vmprintf(tls, zFmt, ap) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = idxPrepareStmt(tls, db, ppStmt, pzErrmsg, zSql) sqlite3.Xsqlite3_free(tls, zSql) @@ -7596,22 +7559,22 @@ func expertConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin if argc != 4 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3 /* "internal error!" */, 0) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR } else { - var zCreateTable uintptr = expertDequote(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) + var zCreateTable uintptr = expertDequote(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) if zCreateTable != 0 { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3_declare_vtab(tls, db, zCreateTable) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { p = idxMalloc(tls, bp /* &rc */, int32(unsafe.Sizeof(ExpertVtab{}))) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*ExpertVtab)(unsafe.Pointer(p)).FpExpert = pExpert (*ExpertVtab)(unsafe.Pointer(p)).FpTab = (*sqlite3expert)(unsafe.Pointer(pExpert)).FpTable } sqlite3.Xsqlite3_free(tls, zCreateTable) } else { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_NOMEM } } @@ -7622,7 +7585,7 @@ func expertConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin func expertDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3expert.c:431:12: */ var p uintptr = pVtab sqlite3.Xsqlite3_free(tls, p) - return 0 + return SQLITE_OK } func expertBestIndex(tls *libc.TLS, pVtab uintptr, pIdxInfo uintptr) int32 { /* sqlite3expert.c:437:12: */ @@ -7630,10 +7593,10 @@ func expertBestIndex(tls *libc.TLS, pVtab uintptr, pIdxInfo uintptr) int32 { /* defer tls.Free(4) var p uintptr = pVtab - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var n int32 = 0 var pScan uintptr - var opmask int32 = ((((2 | 4) | 16) | 32) | 8) + var opmask int32 = ((((SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_GT) | SQLITE_INDEX_CONSTRAINT_LT) | SQLITE_INDEX_CONSTRAINT_GE) | SQLITE_INDEX_CONSTRAINT_LE) pScan = idxMalloc(tls, bp /* &rc */, int32(unsafe.Sizeof(IdxScan{}))) if pScan != 0 { @@ -7656,7 +7619,7 @@ func expertBestIndex(tls *libc.TLS, pVtab uintptr, pIdxInfo uintptr) int32 { /* pNew = idxNewConstraint(tls, bp /* &rc */, zColl) if pNew != 0 { (*IdxConstraint)(unsafe.Pointer(pNew)).FiCol = (*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn - if int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == 2 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ { (*IdxConstraint)(unsafe.Pointer(pNew)).FpNext = (*IdxScan)(unsafe.Pointer(pScan)).FpEq (*IdxScan)(unsafe.Pointer(pScan)).FpEq = pNew } else { @@ -7696,7 +7659,7 @@ func expertUpdate(tls *libc.TLS, pVtab uintptr, nData int32, azData uintptr, pRo _ = nData _ = azData _ = pRowid - return 0 + return SQLITE_OK } // Virtual table module xOpen method. @@ -7704,7 +7667,7 @@ func expertOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* sqlit bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pCsr uintptr _ = pVTab pCsr = idxMalloc(tls, bp /* &rc */, int32(unsafe.Sizeof(ExpertCsr{}))) @@ -7717,7 +7680,7 @@ func expertClose(tls *libc.TLS, cur uintptr) int32 { /* sqlite3expert.c:532:12: var pCsr uintptr = cur sqlite3.Xsqlite3_finalize(tls, (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData) sqlite3.Xsqlite3_free(tls, pCsr) - return 0 + return SQLITE_OK } // Virtual table module xEof method. @@ -7732,14 +7695,14 @@ func expertEof(tls *libc.TLS, cur uintptr) int32 { /* sqlite3expert.c:545:12: */ // Virtual table module xNext method. func expertNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3expert.c:553:12: */ var pCsr uintptr = cur - var rc int32 = 0 + var rc int32 = SQLITE_OK rc = sqlite3.Xsqlite3_step(tls, (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData) - if rc != 100 { + if rc != SQLITE_ROW { rc = sqlite3.Xsqlite3_finalize(tls, (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData) (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData = uintptr(0) } else { - rc = 0 + rc = SQLITE_OK } return rc @@ -7749,7 +7712,7 @@ func expertNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3expert.c:553:12: * func expertRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* sqlite3expert.c:572:12: */ _ = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = int64(0) - return 0 + return SQLITE_OK } // Virtual table module xColumn method. @@ -7760,7 +7723,7 @@ func expertColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* s if pVal != 0 { sqlite3.Xsqlite3_result_value(tls, ctx, pVal) } - return 0 + return SQLITE_OK } // Virtual table module xFilter method. @@ -7779,12 +7742,12 @@ func expertFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, argc _ = argv rc = sqlite3.Xsqlite3_finalize(tls, (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData) (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData = uintptr(0) - if rc == 0 { + if rc == SQLITE_OK { rc = idxPrintfPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(pExpert)).Fdb, (pCsr + 8 /* &.pData */), (pVtab /* &.base */ + 16 /* &.zErrMsg */), ts+19 /* "SELECT * FROM ma..." */, libc.VaList(bp, (*IdxTable)(unsafe.Pointer((*ExpertVtab)(unsafe.Pointer(pVtab)).FpTab)).FzName)) } - if rc == 0 { + if rc == SQLITE_OK { rc = expertNext(tls, cur) } return rc @@ -7796,53 +7759,20 @@ func idxRegisterVtab(tls *libc.TLS, p uintptr) int32 { /* sqlite3expert.c:622:12 } var expertModule = sqlite3_module{ - FiVersion: 2, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - create a table - 0, - FxBestIndex:// xConnect - connect to an existing table - 0, - FxDisconnect:// xBestIndex - Determine search strategy - 0, - FxDestroy:// xDisconnect - Disconnect from a table - 0, - FxOpen:// xDestroy - Drop a table - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - write data - uintptr(0), - FxSync:// xBegin - begin transaction - uintptr(0), - FxCommit:// xSync - sync transaction - uintptr(0), - FxRollback:// xCommit - commit transaction - uintptr(0), - FxFindFunction:// xRollback - rollback transaction - uintptr(0), - FxRename:// xFindFunction - function overloading - uintptr(0), - FxSavepoint:// xRename - rename the table - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName + FiVersion: 2, // iVersion + FxCreate: 0, // xCreate - create a table + FxConnect: 0, // xConnect - connect to an existing table + FxBestIndex: 0, // xBestIndex - Determine search strategy + FxDisconnect: 0, // xDisconnect - Disconnect from a table + FxDestroy: 0, // xDestroy - Drop a table + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRowid - read data + FxUpdate: 0, // xShadowName } /* sqlite3expert.c:623:25 */ // @@ -7853,7 +7783,7 @@ var expertModule = sqlite3_module{ // returning. Otherwise, discard the sqlite3_finalize() return value. func idxFinalize(tls *libc.TLS, pRc uintptr, pStmt uintptr) { /* sqlite3expert.c:660:13: */ var rc int32 = sqlite3.Xsqlite3_finalize(tls, pStmt) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { *(*int32)(unsafe.Pointer(pRc)) = rc } } @@ -7881,7 +7811,7 @@ func idxGetTableInfo(tls *libc.TLS, db uintptr, zTab uintptr, ppOut uintptr, pzE var pCsr uintptr = uintptr(0) *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = idxPrintfPrepareStmt(tls, db, bp+8 /* &p1 */, pzErrmsg, ts+63 /* "PRAGMA table_inf..." */, libc.VaList(bp, zTab)) - for (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0) && (100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)))) { + for (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)))) { *(*uintptr)(unsafe.Pointer(bp + 16 /* zCol */)) = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)), 1) nByte = nByte + (1 + int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* zCol */))))) *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = sqlite3.Xsqlite3_table_column_metadata(tls, @@ -7890,22 +7820,22 @@ func idxGetTableInfo(tls *libc.TLS, db uintptr, zTab uintptr, ppOut uintptr, pzE nCol++ } rc2 = sqlite3.Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */))) - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = rc2 } nByte = int32(uint64(nByte) + (uint64(unsafe.Sizeof(IdxColumn{})) * uint64(nCol))) - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { pNew = idxMalloc(tls, bp+24 /* &rc */, nByte) } - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { - (*IdxTable)(unsafe.Pointer(pNew)).FaCol = (pNew + uintptr(1)*32) + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { + (*IdxTable)(unsafe.Pointer(pNew)).FaCol = (pNew + 1*32) (*IdxTable)(unsafe.Pointer(pNew)).FnCol = nCol pCsr = ((*IdxTable)(unsafe.Pointer(pNew)).FaCol + uintptr(nCol)*24) } nCol = 0 - for (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0) && (100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)))) { + for (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)))) { *(*uintptr)(unsafe.Pointer(bp + 32 /* zCol */)) = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)), 1) var nCopy int32 = (int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* zCol */)))) + 1) (*IdxColumn)(unsafe.Pointer((*IdxTable)(unsafe.Pointer(pNew)).FaCol + uintptr(nCol)*24)).FzName = pCsr @@ -7915,7 +7845,7 @@ func idxGetTableInfo(tls *libc.TLS, db uintptr, zTab uintptr, ppOut uintptr, pzE *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = sqlite3.Xsqlite3_table_column_metadata(tls, db, ts+84 /* "main" */, zTab, *(*uintptr)(unsafe.Pointer(bp + 32 /* zCol */)), uintptr(0), bp+32 /* &zCol */, uintptr(0), uintptr(0), uintptr(0)) - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { nCopy = (int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* zCol */)))) + 1) (*IdxColumn)(unsafe.Pointer((*IdxTable)(unsafe.Pointer(pNew)).FaCol + uintptr(nCol)*24)).FzColl = pCsr libc.Xmemcpy(tls, pCsr, *(*uintptr)(unsafe.Pointer(bp + 32 /* zCol */)), uint64(nCopy)) @@ -7926,7 +7856,7 @@ func idxGetTableInfo(tls *libc.TLS, db uintptr, zTab uintptr, ppOut uintptr, pzE } idxFinalize(tls, bp+24 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */))) - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) != SQLITE_OK { sqlite3.Xsqlite3_free(tls, pNew) pNew = uintptr(0) } else { @@ -7958,7 +7888,7 @@ func idxAppendText(tls *libc.TLS, pRc uintptr, zIn uintptr, zFmt uintptr, va uin } var nAppend int32 = 0 ap = va - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { zAppend = sqlite3.Xsqlite3_vmprintf(tls, zFmt, ap) if zAppend != 0 { nAppend = int32(libc.Xstrlen(tls, zAppend)) @@ -7972,7 +7902,7 @@ func idxAppendText(tls *libc.TLS, pRc uintptr, zIn uintptr, zFmt uintptr, va uin } else { sqlite3.Xsqlite3_free(tls, zRet) zRet = uintptr(0) - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } sqlite3.Xsqlite3_free(tls, zAppend) sqlite3.Xsqlite3_free(tls, zIn) @@ -8050,7 +7980,7 @@ func idxFindCompatible(tls *libc.TLS, pRc uintptr, dbm uintptr, pScan uintptr, p } *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = idxPrintfPrepareStmt(tls, dbm, bp+16 /* &pIdxList */, uintptr(0), ts+125 /* "PRAGMA index_lis..." */, libc.VaList(bp, zTbl)) - for (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pIdxList */))) == 100) { + for (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pIdxList */))) == SQLITE_ROW) { var bMatch int32 = 1 var pT uintptr = pTail *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */)) = uintptr(0) @@ -8062,7 +7992,7 @@ func idxFindCompatible(tls *libc.TLS, pRc uintptr, dbm uintptr, pScan uintptr, p } *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = idxPrintfPrepareStmt(tls, dbm, bp+24 /* &pInfo */, uintptr(0), ts+146 /* "PRAGMA index_xIn..." */, libc.VaList(bp+8, zIdx)) - for (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */))) == 100) { + for (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */))) == SQLITE_ROW) { var iIdx int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */)), 0) var iCol int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */)), 1) var zColl uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */)), 4) @@ -8097,7 +8027,7 @@ func idxFindCompatible(tls *libc.TLS, pRc uintptr, dbm uintptr, pScan uintptr, p } idxFinalize(tls, bp+32 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */))) - if (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0) && (bMatch != 0) { + if (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK) && (bMatch != 0) { sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pIdxList */))) return 1 } @@ -8113,7 +8043,7 @@ func idxCreateFromCons(tls *libc.TLS, p uintptr, pScan uintptr, pEq uintptr, pTa defer tls.Free(44) var dbm uintptr = (*sqlite3expert)(unsafe.Pointer(p)).Fdbm - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_OK if ((pEq != 0) || (pTail != 0)) && (0 == idxFindCompatible(tls, bp+40 /* &rc */, dbm, pScan, pEq, pTail)) { var pTab uintptr = (*IdxScan)(unsafe.Pointer(pScan)).FpTab var zCols uintptr = uintptr(0) @@ -8129,7 +8059,7 @@ func idxCreateFromCons(tls *libc.TLS, p uintptr, pScan uintptr, pEq uintptr, pTa zCols = idxAppendColDefn(tls, bp+40 /* &rc */, zCols, pTab, pCons) } - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { // Hash the list of columns to come up with a name for the index var zTable uintptr = (*IdxTable)(unsafe.Pointer((*IdxScan)(unsafe.Pointer(pScan)).FpTab)).FzName var zName uintptr // Index name @@ -8139,7 +8069,7 @@ func idxCreateFromCons(tls *libc.TLS, p uintptr, pScan uintptr, pEq uintptr, pTa } zName = sqlite3.Xsqlite3_mprintf(tls, ts+168 /* "%s_idx_%08x" */, libc.VaList(bp, zTable, h)) if zName == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_NOMEM } else { if idxIdentifierRequiresQuotes(tls, zTable) != 0 { zFmt = ts + 180 /* "CREATE INDEX '%q..." */ @@ -8148,7 +8078,7 @@ func idxCreateFromCons(tls *libc.TLS, p uintptr, pScan uintptr, pEq uintptr, pTa } zIdx = sqlite3.Xsqlite3_mprintf(tls, zFmt, libc.VaList(bp+16, zName, zTable, zCols)) if !(zIdx != 0) { - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_NOMEM } else { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = sqlite3.Xsqlite3_exec(tls, dbm, zIdx, uintptr(0), uintptr(0), (*sqlite3expert)(unsafe.Pointer(p)).FpzErrmsg) idxHashAdd(tls, bp+40 /* &rc */, (p + 88 /* &.hIdx */), zName, zIdx) @@ -8195,7 +8125,7 @@ func idxCreateFromWhere(tls *libc.TLS, p uintptr, pScan uintptr, pTail uintptr) // If no range/ORDER BY passed by the caller, create a version of the // index for each range constraint. if pTail == uintptr(0) { - for pCon = (*IdxScan)(unsafe.Pointer(pScan)).FpRange; (rc == 0) && (pCon != 0); pCon = (*IdxConstraint)(unsafe.Pointer(pCon)).FpNext { + for pCon = (*IdxScan)(unsafe.Pointer(pScan)).FpRange; (rc == SQLITE_OK) && (pCon != 0); pCon = (*IdxConstraint)(unsafe.Pointer(pCon)).FpNext { if !(idxFindConstraint(tls, p1, pCon) != 0) && !(idxFindConstraint(tls, pTail, pCon) != 0) { rc = idxCreateFromCons(tls, p, pScan, p1, pCon) @@ -8209,12 +8139,12 @@ func idxCreateFromWhere(tls *libc.TLS, p uintptr, pScan uintptr, pTail uintptr) // Create candidate indexes in database [dbm] based on the data in // linked-list pScan. func idxCreateCandidates(tls *libc.TLS, p uintptr) int32 { /* sqlite3expert.c:1019:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pIter uintptr - for pIter = (*sqlite3expert)(unsafe.Pointer(p)).FpScan; (pIter != 0) && (rc == 0); pIter = (*IdxScan)(unsafe.Pointer(pIter)).FpNextScan { + for pIter = (*sqlite3expert)(unsafe.Pointer(p)).FpScan; (pIter != 0) && (rc == SQLITE_OK); pIter = (*IdxScan)(unsafe.Pointer(pIter)).FpNextScan { rc = idxCreateFromWhere(tls, p, pIter, uintptr(0)) - if (rc == 0) && ((*IdxScan)(unsafe.Pointer(pIter)).FpOrder != 0) { + if (rc == SQLITE_OK) && ((*IdxScan)(unsafe.Pointer(pIter)).FpOrder != 0) { rc = idxCreateFromWhere(tls, p, pIter, (*IdxScan)(unsafe.Pointer(pIter)).FpOrder) } } @@ -8305,12 +8235,12 @@ func idxFindIndexes(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* sqlite3e var pEntry uintptr // var pExplain uintptr at bp+8216, 8 dbm = (*sqlite3expert)(unsafe.Pointer(p)).Fdbm - *(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) = SQLITE_OK idxHashInit(tls, bp+24 /* &hIdx */) pStmt = (*sqlite3expert)(unsafe.Pointer(p)).FpStatement __1: - if !((*(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) == 0) && (pStmt != 0)) { + if !((*(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) == SQLITE_OK) && (pStmt != 0)) { goto __3 } *(*uintptr)(unsafe.Pointer(bp + 8216 /* pExplain */)) = uintptr(0) @@ -8318,7 +8248,7 @@ __1: *(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) = idxPrintfPrepareStmt(tls, dbm, bp+8216 /* &pExplain */, pzErr, ts+234 /* "EXPLAIN QUERY PL..." */, libc.VaList(bp, (*IdxStatement)(unsafe.Pointer(pStmt)).FzSql)) __4: - if !((*(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) == 0) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8216 /* pExplain */))) == 100)) { + if !((*(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) == SQLITE_OK) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8216 /* pExplain */))) == SQLITE_ROW)) { goto __5 } // int iId = sqlite3_column_int(pExplain, 0); @@ -8391,7 +8321,7 @@ __8: __9: ; - if !(int32(*(*int8)(unsafe.Pointer(zDetail + uintptr(0)))) != '-') { + if !(int32(*(*int8)(unsafe.Pointer(zDetail))) != '-') { goto __18 } (*IdxStatement)(unsafe.Pointer(pStmt)).FzEQP = idxAppendText(tls, bp+8224 /* &rc */, (*IdxStatement)(unsafe.Pointer(pStmt)).FzEQP, ts+293 /* "%s\n" */, libc.VaList(bp+8, zDetail)) @@ -8433,10 +8363,10 @@ func idxAuthCallback(tls *libc.TLS, pCtx uintptr, eOp int32, z3 uintptr, z4 uint bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK _ = z4 _ = zTrigger - if ((eOp == 18) || (eOp == 23)) || (eOp == 9) { + if ((eOp == SQLITE_INSERT) || (eOp == SQLITE_UPDATE)) || (eOp == SQLITE_DELETE) { if sqlite3.Xsqlite3_stricmp(tls, zDb, ts+84 /* "main" */) == 0 { var p uintptr = pCtx var pTab uintptr @@ -8454,7 +8384,7 @@ func idxAuthCallback(tls *libc.TLS, pCtx uintptr, eOp int32, z3 uintptr, z4 uint } if pWrite == uintptr(0) { pWrite = idxMalloc(tls, bp /* &rc */, int32(unsafe.Sizeof(IdxWrite{}))) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*IdxWrite)(unsafe.Pointer(pWrite)).FpTab = pTab (*IdxWrite)(unsafe.Pointer(pWrite)).FeOp = eOp (*IdxWrite)(unsafe.Pointer(pWrite)).FpNext = (*sqlite3expert)(unsafe.Pointer(p)).FpWrite @@ -8475,22 +8405,22 @@ func idxProcessOneTrigger(tls *libc.TLS, p uintptr, pWrite uintptr, pzErr uintpt var zTab uintptr = (*IdxTable)(unsafe.Pointer(pTab)).FzName var zSql uintptr = ts + 302 /* "SELECT 'CREATE T..." */ *(*uintptr)(unsafe.Pointer(bp + 80 /* pSelect */)) = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = SQLITE_OK var zWrite uintptr = uintptr(0) // Create the table and its triggers in the temp schema *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = idxPrintfPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdb, bp+80 /* &pSelect */, pzErr, zSql, libc.VaList(bp, zTab, zTab)) - for (*(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == 0) && (100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pSelect */)))) { + for (*(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pSelect */)))) { var zCreate uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pSelect */)), 0) *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, zCreate, uintptr(0), uintptr(0), pzErr) } idxFinalize(tls, bp+88 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 80 /* pSelect */))) // Rename the table in the temp schema to zInt - if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == SQLITE_OK { var z uintptr = sqlite3.Xsqlite3_mprintf(tls, ts+428 /* "ALTER TABLE temp..." */, libc.VaList(bp+16, zTab, zInt)) if z == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = SQLITE_NOMEM } else { *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, z, uintptr(0), uintptr(0), pzErr) sqlite3.Xsqlite3_free(tls, z) @@ -8498,7 +8428,7 @@ func idxProcessOneTrigger(tls *libc.TLS, p uintptr, pWrite uintptr, pzErr uintpt } switch (*IdxWrite)(unsafe.Pointer(pWrite)).FeOp { - case 18: + case SQLITE_INSERT: { var i int32 zWrite = idxAppendText(tls, bp+88 /* &rc */, zWrite, ts+461 /* "INSERT INTO %Q V..." */, libc.VaList(bp+32, zInt)) @@ -8514,7 +8444,7 @@ func idxProcessOneTrigger(tls *libc.TLS, p uintptr, pWrite uintptr, pzErr uintpt break } - case 23: + case SQLITE_UPDATE: { var i int32 zWrite = idxAppendText(tls, bp+88 /* &rc */, zWrite, ts+491 /* "UPDATE %Q SET " */, libc.VaList(bp+48, zInt)) @@ -8533,27 +8463,27 @@ func idxProcessOneTrigger(tls *libc.TLS, p uintptr, pWrite uintptr, pzErr uintpt default: { - if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == SQLITE_OK { zWrite = sqlite3.Xsqlite3_mprintf(tls, ts+513 /* "DELETE FROM %Q" */, libc.VaList(bp+72, zInt)) if zWrite == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = SQLITE_NOMEM } } } } - if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == SQLITE_OK { *(*uintptr)(unsafe.Pointer(bp + 96 /* pX */)) = uintptr(0) *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = sqlite3.Xsqlite3_prepare_v2(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, zWrite, -1, bp+96 /* &pX */, uintptr(0)) idxFinalize(tls, bp+88 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 96 /* pX */))) - if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) != SQLITE_OK { idxDatabaseError(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, pzErr) } } sqlite3.Xsqlite3_free(tls, zWrite) - if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, zDrop, uintptr(0), uintptr(0), pzErr) } @@ -8564,13 +8494,13 @@ var zInt uintptr = ts + 528 /* "t592690916721053..." */ /* sqlite3expert.c:1221 var zDrop uintptr = ts + 566 /* "DROP TABLE t5926..." */ /* sqlite3expert.c:1222:21 */ func idxProcessTriggers(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* sqlite3expert.c:1298:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pEnd uintptr = uintptr(0) var pFirst uintptr = (*sqlite3expert)(unsafe.Pointer(p)).FpWrite - for (rc == 0) && (pFirst != pEnd) { + for (rc == SQLITE_OK) && (pFirst != pEnd) { var pIter uintptr - for pIter = pFirst; (rc == 0) && (pIter != pEnd); pIter = (*IdxWrite)(unsafe.Pointer(pIter)).FpNext { + for pIter = pFirst; (rc == SQLITE_OK) && (pIter != pEnd); pIter = (*IdxWrite)(unsafe.Pointer(pIter)).FpNext { rc = idxProcessOneTrigger(tls, p, pIter, pzErr) } pEnd = pFirst @@ -8594,18 +8524,18 @@ func idxCreateVtabSchema(tls *libc.TLS, p uintptr, pzErrmsg uintptr) int32 { /* *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = idxPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdb, bp+40 /* &pSchema */, pzErrmsg, ts+615 /* "SELECT type, nam..." */) - for (*(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == 0) && (100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pSchema */)))) { + for (*(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pSchema */)))) { var zType uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pSchema */)), 0) var zName uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pSchema */)), 1) var zSql uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pSchema */)), 2) - if (int32(*(*int8)(unsafe.Pointer(zType + uintptr(0)))) == 'v') || (int32(*(*int8)(unsafe.Pointer(zType + uintptr(1)))) == 'r') { + if (int32(*(*int8)(unsafe.Pointer(zType))) == 'v') || (int32(*(*int8)(unsafe.Pointer(zType + 1))) == 'r') { *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, zSql, uintptr(0), uintptr(0), pzErrmsg) } else { // var pTab uintptr at bp+48, 8 *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = idxGetTableInfo(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdb, zName, bp+48 /* &pTab */, pzErrmsg) - if *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == SQLITE_OK { var i int32 var zInner uintptr = uintptr(0) var zOuter uintptr = uintptr(0) @@ -8628,7 +8558,7 @@ func idxCreateVtabSchema(tls *libc.TLS, p uintptr, pzErrmsg uintptr) int32 { /* // The CVT statement to create the vtab zOuter = idxAppendText(tls, bp+56 /* &rc */, uintptr(0), ts+915 /* "CREATE VIRTUAL T..." */, libc.VaList(bp+24, zName, zInner)) - if *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, zOuter, uintptr(0), uintptr(0), pzErrmsg) } sqlite3.Xsqlite3_free(tls, zInner) @@ -8704,51 +8634,51 @@ func idxRemFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { /* sqli var pSlot uintptr var iSlot int32 - iSlot = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + iSlot = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) pSlot = ((p + 8 /* &.aSlot */) + uintptr(iSlot)*40) switch (*IdxRemSlot)(unsafe.Pointer(pSlot)).FeType { - case 5: + case SQLITE_NULL: // no-op break - case 1: + case SQLITE_INTEGER: sqlite3.Xsqlite3_result_int64(tls, pCtx, (*IdxRemSlot)(unsafe.Pointer(pSlot)).FiVal) break - case 2: + case SQLITE_FLOAT: sqlite3.Xsqlite3_result_double(tls, pCtx, (*IdxRemSlot)(unsafe.Pointer(pSlot)).FrVal) break - case 4: + case SQLITE_BLOB: sqlite3.Xsqlite3_result_blob(tls, pCtx, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fn, libc.UintptrFromInt32(-1)) break - case 3: + case SQLITE_TEXT: sqlite3.Xsqlite3_result_text(tls, pCtx, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fn, libc.UintptrFromInt32(-1)) break } - (*IdxRemSlot)(unsafe.Pointer(pSlot)).FeType = sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + (*IdxRemSlot)(unsafe.Pointer(pSlot)).FeType = sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) switch (*IdxRemSlot)(unsafe.Pointer(pSlot)).FeType { - case 5: + case SQLITE_NULL: // no-op break - case 1: - (*IdxRemSlot)(unsafe.Pointer(pSlot)).FiVal = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + case SQLITE_INTEGER: + (*IdxRemSlot)(unsafe.Pointer(pSlot)).FiVal = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) break - case 2: - (*IdxRemSlot)(unsafe.Pointer(pSlot)).FrVal = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + case SQLITE_FLOAT: + (*IdxRemSlot)(unsafe.Pointer(pSlot)).FrVal = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) break - case 4: + case SQLITE_BLOB: fallthrough - case 3: + case SQLITE_TEXT: { - var nByte int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + var nByte int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if nByte > (*IdxRemSlot)(unsafe.Pointer(pSlot)).FnByte { var zNew uintptr = sqlite3.Xsqlite3_realloc(tls, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz, (nByte * 2)) if zNew == uintptr(0) { @@ -8759,10 +8689,10 @@ func idxRemFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { /* sqli (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz = zNew } (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fn = nByte - if (*IdxRemSlot)(unsafe.Pointer(pSlot)).FeType == 4 { - libc.Xmemcpy(tls, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz, sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))), uint64(nByte)) + if (*IdxRemSlot)(unsafe.Pointer(pSlot)).FeType == SQLITE_BLOB { + libc.Xmemcpy(tls, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz, sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))), uint64(nByte)) } else { - libc.Xmemcpy(tls, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))), uint64(nByte)) + libc.Xmemcpy(tls, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))), uint64(nByte)) } break @@ -8774,13 +8704,13 @@ func idxLargestIndex(tls *libc.TLS, db uintptr, pnMax uintptr, pzErr uintptr) in bp := tls.Alloc(12) defer tls.Free(12) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK var zMax uintptr = ts + 956 /* "SELECT max(i.seq..." */ *(*uintptr)(unsafe.Pointer(bp /* pMax */)) = uintptr(0) *(*int32)(unsafe.Pointer(pnMax)) = 0 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = idxPrepareStmt(tls, db, bp /* &pMax */, pzErr, zMax) - if (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0) && (100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pMax */)))) { + if (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pMax */)))) { *(*int32)(unsafe.Pointer(pnMax)) = (sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp /* pMax */)), 0) + 1) } idxFinalize(tls, bp+8 /* &rc */, *(*uintptr)(unsafe.Pointer(bp /* pMax */))) @@ -8799,11 +8729,11 @@ func idxPopulateOneStat1(tls *libc.TLS, p uintptr, pIndexXInfo uintptr, pWriteSt var i int32 *(*uintptr)(unsafe.Pointer(bp + 120 /* pQuery */)) = uintptr(0) var aStat uintptr = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = SQLITE_OK // Formulate the query text sqlite3.Xsqlite3_bind_text(tls, pIndexXInfo, 1, zIdx, -1, uintptr(0)) - for (0 == *(*int32)(unsafe.Pointer(bp + 112 /* rc */))) && (100 == sqlite3.Xsqlite3_step(tls, pIndexXInfo)) { + for (SQLITE_OK == *(*int32)(unsafe.Pointer(bp + 112 /* rc */))) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, pIndexXInfo)) { var zComma uintptr if zCols == uintptr(0) { zComma = ts + 488 /* "" */ @@ -8817,7 +8747,7 @@ func idxPopulateOneStat1(tls *libc.TLS, p uintptr, pIndexXInfo uintptr, pWriteSt zOrder = idxAppendText(tls, bp+112 /* &rc */, zOrder, ts+1128 /* "%s%d" */, libc.VaList(bp+40, zComma, libc.PreIncInt32(&nCol, 1))) } sqlite3.Xsqlite3_reset(tls, pIndexXInfo) - if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK { if (*sqlite3expert)(unsafe.Pointer(p)).FiSample == 100 { zQuery = sqlite3.Xsqlite3_mprintf(tls, ts+1133 /* "SELECT %s FROM %..." */, libc.VaList(bp+56, zCols, zTab, zOrder)) @@ -8830,7 +8760,7 @@ func idxPopulateOneStat1(tls *libc.TLS, p uintptr, pIndexXInfo uintptr, pWriteSt sqlite3.Xsqlite3_free(tls, zOrder) // Formulate the query text - if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK { var dbrem uintptr = func() uintptr { if (*sqlite3expert)(unsafe.Pointer(p)).FiSample == 100 { return (*sqlite3expert)(unsafe.Pointer(p)).Fdb @@ -8841,17 +8771,17 @@ func idxPopulateOneStat1(tls *libc.TLS, p uintptr, pIndexXInfo uintptr, pWriteSt } sqlite3.Xsqlite3_free(tls, zQuery) - if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK { aStat = idxMalloc(tls, bp+112 /* &rc */, (int32(uint64(unsafe.Sizeof(int32(0))) * (uint64(nCol + 1))))) } - if (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == 0) && (100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* pQuery */)))) { + if (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* pQuery */)))) { var pEntry uintptr var zStat uintptr = uintptr(0) for i = 0; i <= nCol; i++ { *(*int32)(unsafe.Pointer(aStat + uintptr(i)*4)) = 1 } - for (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == 0) && (100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* pQuery */)))) { - *(*int32)(unsafe.Pointer(aStat + uintptr(0)*4))++ + for (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* pQuery */)))) { + *(*int32)(unsafe.Pointer(aStat))++ for i = 0; i < nCol; i++ { if sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* pQuery */)), i) == 0 { break @@ -8862,18 +8792,18 @@ func idxPopulateOneStat1(tls *libc.TLS, p uintptr, pIndexXInfo uintptr, pWriteSt } } - if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == 0 { - var s0 int32 = *(*int32)(unsafe.Pointer(aStat + uintptr(0)*4)) + if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK { + var s0 int32 = *(*int32)(unsafe.Pointer(aStat)) zStat = sqlite3.Xsqlite3_mprintf(tls, ts+1237 /* "%d" */, libc.VaList(bp+96, s0)) if zStat == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = SQLITE_NOMEM } - for i = 1; (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == 0) && (i <= nCol); i++ { + for i = 1; (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK) && (i <= nCol); i++ { zStat = idxAppendText(tls, bp+112 /* &rc */, zStat, ts+1240 /* " %d" */, libc.VaList(bp+104, ((s0+(*(*int32)(unsafe.Pointer(aStat + uintptr(i)*4))/2)) / *(*int32)(unsafe.Pointer(aStat + uintptr(i)*4))))) } } - if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK { sqlite3.Xsqlite3_bind_text(tls, pWriteStat, 1, zTab, -1, uintptr(0)) sqlite3.Xsqlite3_bind_text(tls, pWriteStat, 2, zIdx, -1, uintptr(0)) sqlite3.Xsqlite3_bind_text(tls, pWriteStat, 3, zStat, -1, uintptr(0)) @@ -8903,14 +8833,14 @@ func idxBuildSampleTable(tls *libc.TLS, p uintptr, zTab uintptr) int32 { /* sqli var zSql uintptr rc = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, ts+1244 /* "DROP TABLE IF EX..." */, uintptr(0), uintptr(0), uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { return rc } zSql = sqlite3.Xsqlite3_mprintf(tls, ts+1308 /* "CREATE TABLE tem..." */, libc.VaList(bp, zTab)) if zSql == uintptr(0) { - return 7 + return SQLITE_NOMEM } rc = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, zSql, uintptr(0), uintptr(0), uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) @@ -8927,7 +8857,7 @@ func idxPopulateStat1(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* sqlite bp := tls.Alloc(64) defer tls.Free(64) - *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = SQLITE_OK *(*int32)(unsafe.Pointer(bp /* nMax */)) = 0 var pCtx uintptr = uintptr(0) // var samplectx IdxSampleCtx at bp+8, 32 @@ -8944,22 +8874,22 @@ func idxPopulateStat1(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* sqlite // If iSample==0, no sqlite_stat1 data is required. if (*sqlite3expert)(unsafe.Pointer(p)).FiSample == 0 { - return 0 + return SQLITE_OK } *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = idxLargestIndex(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm, bp /* &nMax */, pzErr) - if (*(*int32)(unsafe.Pointer(bp /* nMax */)) <= 0) || (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) != 0) { + if (*(*int32)(unsafe.Pointer(bp /* nMax */)) <= 0) || (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) != SQLITE_OK) { return *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) } *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm, ts+1594 /* "ANALYZE; PRAGMA ..." */, uintptr(0), uintptr(0), uintptr(0)) - if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { var nByte int32 = (int32(uint64(unsafe.Sizeof(IdxRemCtx{})) + (uint64(unsafe.Sizeof(IdxRemSlot{})) * uint64(*(*int32)(unsafe.Pointer(bp /* nMax */)))))) pCtx = idxMalloc(tls, bp+4 /* &rc */, nByte) } - if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { var dbrem uintptr = func() uintptr { if (*sqlite3expert)(unsafe.Pointer(p)).FiSample == 100 { return (*sqlite3expert)(unsafe.Pointer(p)).Fdb @@ -8967,29 +8897,29 @@ func idxPopulateStat1(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* sqlite return (*sqlite3expert)(unsafe.Pointer(p)).Fdbv }() *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = sqlite3.Xsqlite3_create_function(tls, - dbrem, ts+1628 /* "rem" */, 2, 1, pCtx, *(*uintptr)(unsafe.Pointer(&struct { + dbrem, ts+1628 /* "rem" */, 2, SQLITE_UTF8, pCtx, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{idxRemFunc})), uintptr(0), uintptr(0)) } - if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = sqlite3.Xsqlite3_create_function(tls, - (*sqlite3expert)(unsafe.Pointer(p)).Fdb, ts+1632 /* "sample" */, 0, 1, bp+8 /* &samplectx */, *(*uintptr)(unsafe.Pointer(&struct { + (*sqlite3expert)(unsafe.Pointer(p)).Fdb, ts+1632 /* "sample" */, 0, SQLITE_UTF8, bp+8 /* &samplectx */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{idxSampleFunc})), uintptr(0), uintptr(0)) } - if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { (*IdxRemCtx)(unsafe.Pointer(pCtx)).FnSlot = (*(*int32)(unsafe.Pointer(bp /* nMax */)) + 1) *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = idxPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm, bp+40 /* &pAllIndex */, pzErr, zAllIndex) } - if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = idxPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm, bp+48 /* &pIndexXInfo */, pzErr, zIndexXInfo) } - if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = idxPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm, bp+56 /* &pWrite */, pzErr, zWrite) } - for (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0) && (100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pAllIndex */)))) { + for (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pAllIndex */)))) { var iRowid i64 = sqlite3.Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pAllIndex */)), 0) var zTab uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pAllIndex */)), 1) var zIdx uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pAllIndex */)), 2) @@ -8999,14 +8929,14 @@ func idxPopulateStat1(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* sqlite (*IdxSampleCtx)(unsafe.Pointer(bp + 8 /* &samplectx */)).FnRow = 0.0 (*IdxSampleCtx)(unsafe.Pointer(bp + 8 /* &samplectx */)).FnRet = 0.0 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = idxBuildSampleTable(tls, p, zTab) - if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) != SQLITE_OK { break } } *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = idxPopulateOneStat1(tls, p, *(*uintptr)(unsafe.Pointer(bp + 48 /* pIndexXInfo */)), *(*uintptr)(unsafe.Pointer(bp + 56 /* pWrite */)), zTab, zIdx, pzErr) iPrev = iRowid } - if (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0) && ((*sqlite3expert)(unsafe.Pointer(p)).FiSample < 100) { + if (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK) && ((*sqlite3expert)(unsafe.Pointer(p)).FiSample < 100) { *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, ts+1244 /* "DROP TABLE IF EX..." */, uintptr(0), uintptr(0), uintptr(0)) } @@ -9020,7 +8950,7 @@ func idxPopulateStat1(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* sqlite } sqlite3.Xsqlite3_free(tls, pCtx) - if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm, ts+1639 /* "ANALYZE sqlite_s..." */, uintptr(0), uintptr(0), uintptr(0)) } @@ -9033,7 +8963,7 @@ func sqlite3_expert_new(tls *libc.TLS, db uintptr, pzErrmsg uintptr) uintptr { / bp := tls.Alloc(32) defer tls.Free(32) - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK var pNew uintptr pNew = idxMalloc(tls, bp+16 /* &rc */, int32(unsafe.Sizeof(sqlite3expert{}))) @@ -9043,26 +8973,26 @@ func sqlite3_expert_new(tls *libc.TLS, db uintptr, pzErrmsg uintptr) uintptr { / // the user database schema, and a copy of each view. It is used to // collect information regarding the WHERE, ORDER BY and other clauses // of the user's query. - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { (*sqlite3expert)(unsafe.Pointer(pNew)).Fdb = db (*sqlite3expert)(unsafe.Pointer(pNew)).FiSample = 100 *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3.Xsqlite3_open(tls, ts+1661 /* ":memory:" */, (pNew + 24 /* &.dbv */)) } - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3.Xsqlite3_open(tls, ts+1661 /* ":memory:" */, (pNew + 16 /* &.dbm */)) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { - sqlite3.Xsqlite3_db_config(tls, (*sqlite3expert)(unsafe.Pointer(pNew)).Fdbm, 1008, libc.VaList(bp, 1, uintptr(0))) + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { + sqlite3.Xsqlite3_db_config(tls, (*sqlite3expert)(unsafe.Pointer(pNew)).Fdbm, SQLITE_DBCONFIG_TRIGGER_EQP, libc.VaList(bp, 1, uintptr(0))) } } // Copy the entire schema of database [db] into [dbm]. - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { // var pSql uintptr at bp+24, 8 *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = idxPrintfPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(pNew)).Fdb, bp+24 /* &pSql */, pzErrmsg, ts+1670 /* "SELECT sql FROM ..." */, 0) - for (*(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0) && (100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pSql */)))) { + for (*(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pSql */)))) { var zSql uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pSql */)), 0) *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(pNew)).Fdbm, zSql, uintptr(0), uintptr(0), pzErrmsg) } @@ -9070,12 +9000,12 @@ func sqlite3_expert_new(tls *libc.TLS, db uintptr, pzErrmsg uintptr) uintptr { / } // Create the vtab schema - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = idxCreateVtabSchema(tls, pNew, pzErrmsg) } // Register the auth callback with dbv - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { sqlite3.Xsqlite3_set_authorizer(tls, (*sqlite3expert)(unsafe.Pointer(pNew)).Fdbv, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32 }{idxAuthCallback})), pNew) @@ -9083,7 +9013,7 @@ func sqlite3_expert_new(tls *libc.TLS, db uintptr, pzErrmsg uintptr) uintptr { / // If an error has occurred, free the new object and reutrn NULL. Otherwise, // return the new sqlite3expert handle. - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) != SQLITE_OK { sqlite3_expert_destroy(tls, pNew) pNew = uintptr(0) } @@ -9092,12 +9022,12 @@ func sqlite3_expert_new(tls *libc.TLS, db uintptr, pzErrmsg uintptr) uintptr { / // Configure an sqlite3expert object. func sqlite3_expert_config(tls *libc.TLS, p uintptr, op int32, va uintptr) int32 { /* sqlite3expert.c:1799:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var ap va_list _ = ap ap = va switch op { - case 1: + case EXPERT_CONFIG_SAMPLE: { var iVal int32 = int32(libc.VaInt32(&ap)) if iVal < 0 { @@ -9111,7 +9041,7 @@ func sqlite3_expert_config(tls *libc.TLS, p uintptr, op int32, va uintptr) int32 } default: - rc = 12 + rc = SQLITE_NOTFOUND break } @@ -9126,24 +9056,24 @@ func sqlite3_expert_sql(tls *libc.TLS, p uintptr, zSql uintptr, pzErr uintptr) i var pScanOrig uintptr = (*sqlite3expert)(unsafe.Pointer(p)).FpScan var pStmtOrig uintptr = (*sqlite3expert)(unsafe.Pointer(p)).FpStatement - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp + 8 /* zStmt */)) = zSql if (*sqlite3expert)(unsafe.Pointer(p)).FbRun != 0 { - return 21 + return SQLITE_MISUSE } - for ((*(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* zStmt */)) != 0)) && (*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zStmt */)) + uintptr(0))) != 0) { + 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) { *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) *(*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 */) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { if *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) != 0 { var pNew uintptr var z uintptr = sqlite3.Xsqlite3_sql(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) var n int32 = int32(libc.Xstrlen(tls, z)) pNew = idxMalloc(tls, bp+16 /* &rc */, (int32((uint64(unsafe.Sizeof(IdxStatement{})) + uint64(n)) + uint64(1)))) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { - (*IdxStatement)(unsafe.Pointer(pNew)).FzSql = (pNew + uintptr(1)*40) + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { + (*IdxStatement)(unsafe.Pointer(pNew)).FzSql = (pNew + 1*40) libc.Xmemcpy(tls, (*IdxStatement)(unsafe.Pointer(pNew)).FzSql, z, (uint64(n + 1))) (*IdxStatement)(unsafe.Pointer(pNew)).FpNext = (*sqlite3expert)(unsafe.Pointer(p)).FpStatement if (*sqlite3expert)(unsafe.Pointer(p)).FpStatement != 0 { @@ -9158,7 +9088,7 @@ func sqlite3_expert_sql(tls *libc.TLS, p uintptr, zSql uintptr, pzErr uintptr) i } } - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) != SQLITE_OK { idxScanFree(tls, (*sqlite3expert)(unsafe.Pointer(p)).FpScan, pScanOrig) idxStatementFree(tls, (*sqlite3expert)(unsafe.Pointer(p)).FpStatement, pStmtOrig) (*sqlite3expert)(unsafe.Pointer(p)).FpScan = pScanOrig @@ -9180,12 +9110,12 @@ func sqlite3_expert_analyze(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = idxProcessTriggers(tls, p, pzErr) // Create candidate indexes within the in-memory database file - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = idxCreateCandidates(tls, p) } // Generate the stat1 data - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = idxPopulateStat1(tls, p, pzErr) } @@ -9203,11 +9133,11 @@ func sqlite3_expert_analyze(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* // Figure out which of the candidate indexes are preferred by the query // planner and report the results to the user. - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = idxFindIndexes(tls, p, pzErr) } - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { (*sqlite3expert)(unsafe.Pointer(p)).FbRun = 1 } return *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) @@ -9234,22 +9164,22 @@ func sqlite3_expert_report(tls *libc.TLS, p uintptr, iStmt int32, eReport int32) for pStmt = (*sqlite3expert)(unsafe.Pointer(p)).FpStatement; (pStmt != 0) && ((*IdxStatement)(unsafe.Pointer(pStmt)).FiId != iStmt); pStmt = (*IdxStatement)(unsafe.Pointer(pStmt)).FpNext { } switch eReport { - case 1: + case EXPERT_REPORT_SQL: if pStmt != 0 { zRet = (*IdxStatement)(unsafe.Pointer(pStmt)).FzSql } break - case 2: + case EXPERT_REPORT_INDEXES: if pStmt != 0 { zRet = (*IdxStatement)(unsafe.Pointer(pStmt)).FzIdx } break - case 3: + case EXPERT_REPORT_PLAN: if pStmt != 0 { zRet = (*IdxStatement)(unsafe.Pointer(pStmt)).FzEQP } break - case 4: + case EXPERT_REPORT_CANDIDATES: zRet = (*sqlite3expert)(unsafe.Pointer(p)).FzCandidates break } @@ -11224,11 +11154,11 @@ func dbHandleFromObj(tls *libc.TLS, interp uintptr, pObj uintptr, pDb uintptr) i if 0 == tcl.XTcl_GetCommandInfo(tls, interp, tcl.XTcl_GetString(tls, pObj), bp+24 /* &info */) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+1790 /* "no such handle: " */, tcl.XTcl_GetString(tls, pObj), 0)) - return 1 + return TCL_ERROR } *(*uintptr)(unsafe.Pointer(pDb)) = *(*uintptr)(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp + 24 /* &info */)).FobjClientData)) - return 0 + return TCL_OK } // Tclcmd: $expert sql SQL @@ -11242,51 +11172,36 @@ func testExpertCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 var pExpert uintptr = clientData *(*[6]Subcmd)(unsafe.Pointer(bp /* aSub */)) = [6]Subcmd{ - { - FzSub: ts + 1807, /* "sql" */ - FnArg: 1, - FzMsg: ts + 1811 /* "TABLE" */}, // 0 - { - FzSub: ts + 1817, /* "analyze" */ - FnArg: 0, - FzMsg: ts + 488 /* "" */}, // 1 - { - FzSub: ts + 1825, /* "count" */ - FnArg: 0, - FzMsg: ts + 488 /* "" */}, // 2 - { - FzSub: ts + 1831, /* "report" */ - FnArg: 2, - FzMsg: ts + 1838 /* "STMT EREPORT" */}, // 3 - { - FzSub: ts + 1851, /* "destroy" */ - FnArg: 0, - FzMsg: ts + 488 /* "" */}, // 4 + {FzSub: ts + 1807 /* "sql" */, FnArg: 1, FzMsg: ts + 1811 /* "TABLE" */}, // 0 + {FzSub: ts + 1817 /* "analyze" */, FzMsg: ts + 488 /* "" */}, // 1 + {FzSub: ts + 1825 /* "count" */, FzMsg: ts + 488 /* "" */}, // 2 + {FzSub: ts + 1831 /* "report" */, FnArg: 2, FzMsg: ts + 1838 /* "STMT EREPORT" */}, // 3 + {FzSub: ts + 1851 /* "destroy" */, FzMsg: ts + 488 /* "" */}, // 4 {}, } // var iSub int32 at bp+144, 4 - var rc int32 = 0 + var rc int32 = TCL_OK *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) = uintptr(0) if objc < 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1859 /* "SUBCOMMAND ..." */) - return 1 + return TCL_ERROR } rc = tcl.XTcl_GetIndexFromObjStruct(tls, interp, - *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &aSub[0] */, int32(unsafe.Sizeof(Subcmd{})), ts+1874 /* "sub-command" */, 0, bp+144 /* &iSub */) - if rc != 0 { + *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &aSub[0] */, int32(unsafe.Sizeof(Subcmd{})), ts+1874 /* "sub-command" */, 0, bp+144 /* &iSub */) + if rc != TCL_OK { return rc } if objc != (2 + (*Subcmd)(unsafe.Pointer(bp /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 144 /* iSub */)))*24)).FnArg) { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, (*Subcmd)(unsafe.Pointer(bp /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 144 /* iSub */)))*24)).FzMsg) - return 1 + return TCL_ERROR } switch *(*int32)(unsafe.Pointer(bp + 144 /* iSub */)) { case 0: { // sql - var zArg uintptr = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + var zArg uintptr = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) rc = sqlite3_expert_sql(tls, pExpert, zArg, bp+152 /* &zErr */) break @@ -11318,9 +11233,9 @@ func testExpertCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 var zReport uintptr - if (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+160 /* &iStmt */) != 0) || - (tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+168 /* &aEnum[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+1831 /* "report" */, 0, bp+208 /* &iEnum */) != 0) { - return 1 + if (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+160 /* &iStmt */) != 0) || + (tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+168 /* &aEnum[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+1831 /* "report" */, 0, bp+208 /* &iEnum */) != 0) { + return TCL_ERROR } zReport = sqlite3_expert_report(tls, pExpert, *(*int32)(unsafe.Pointer(bp + 160 /* iStmt */)), (1 + *(*int32)(unsafe.Pointer(bp + 208 /* iEnum */)))) @@ -11331,11 +11246,11 @@ func testExpertCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 default: // destroy - tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)))) + tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv)))) break } - if rc != 0 { + if rc != TCL_OK { if *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) != 0 { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)), -1)) } else { @@ -11368,26 +11283,26 @@ func test_sqlite3_expert_new(tls *libc.TLS, clientData uintptr, interp uintptr, var zCmd uintptr = uintptr(0) *(*uintptr)(unsafe.Pointer(bp + 48 /* zErr */)) = uintptr(0) var pExpert uintptr - var rc int32 = 0 + var rc int32 = TCL_OK if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if dbHandleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+40 /* &db */) != 0 { - return 1 + if dbHandleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+40 /* &db */) != 0 { + return TCL_ERROR } zCmd = sqlite3.Xsqlite3_mprintf(tls, ts+1913 /* "sqlite3expert%d" */, libc.VaList(bp, libc.PreIncInt32(&iCmd, 1))) if zCmd == uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+8, ts+1929 /* "out of memory" */, uintptr(0))) - return 1 + return TCL_ERROR } pExpert = sqlite3_expert_new(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* db */)), bp+48 /* &zErr */) if pExpert == uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, *(*uintptr)(unsafe.Pointer(bp + 48 /* zErr */)), uintptr(0))) - rc = 1 + rc = TCL_ERROR } else { var p uintptr = pExpert tcl.XTcl_CreateObjCommand(tls, interp, zCmd, *(*uintptr)(unsafe.Pointer(&struct { @@ -11414,11 +11329,9 @@ func TestExpert_Init(tls *libc.TLS, interp uintptr) int32 { /* test_expert.c:202 FzCmd uintptr FxProc uintptr }{ - { - FzCmd: ts + 1943, /* "sqlite3_expert_n..." */ - FxProc: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{test_sqlite3_expert_new}))}, + {FzCmd: ts + 1943 /* "sqlite3_expert_n..." */, FxProc: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{test_sqlite3_expert_new}))}, } var i int32 @@ -11438,7 +11351,7 @@ func TestExpert_Init(tls *libc.TLS, interp uintptr) int32 { /* test_expert.c:202 FxProc uintptr })(unsafe.Pointer(p)).FxProc, uintptr(0), uintptr(0)) } - return 0 + return TCL_OK } // 2011 Jan 27 @@ -11533,9 +11446,9 @@ func f5tDbPointer(tls *libc.TLS, interp uintptr, pObj uintptr, ppDb uintptr) int if tcl.XTcl_GetCommandInfo(tls, interp, z, bp /* &cmdInfo */) != 0 { p = (*Tcl_CmdInfo)(unsafe.Pointer(bp /* &cmdInfo */)).FobjClientData *(*uintptr)(unsafe.Pointer(ppDb)) = (*struct{ Fdb uintptr })(unsafe.Pointer(p)).Fdb - return 0 + return TCL_OK } - return 1 + return TCL_ERROR } // End of code that accesses the SqliteDb struct. @@ -11546,18 +11459,10 @@ func f5tResultToErrorCode(tls *libc.TLS, zRes uintptr) int32 { /* fts5_tcl.c:67: defer tls.Free(64) *(*[4]ErrorCode)(unsafe.Pointer(bp /* aErr */)) = [4]ErrorCode{ - { - Frc: 101, - FzError: ts + 1962 /* "SQLITE_DONE" */}, - { - Frc: 1, - FzError: ts + 1974 /* "SQLITE_ERROR" */}, - { - Frc: 0, - FzError: ts + 1987 /* "SQLITE_OK" */}, - { - Frc: 0, - FzError: ts + 488 /* "" */}, + {Frc: SQLITE_DONE, FzError: ts + 1962 /* "SQLITE_DONE" */}, + {Frc: SQLITE_ERROR, FzError: ts + 1974 /* "SQLITE_ERROR" */}, + {FzError: ts + 1987 /* "SQLITE_OK" */}, + {FzError: ts + 488 /* "" */}, } var i int32 @@ -11567,7 +11472,7 @@ func f5tResultToErrorCode(tls *libc.TLS, zRes uintptr) int32 { /* fts5_tcl.c:67: } } - return 1 + return SQLITE_ERROR } type ErrorCode = struct { @@ -11582,30 +11487,30 @@ func f5tDbAndApi(tls *libc.TLS, interp uintptr, pObj uintptr, ppDb uintptr, ppAp *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)) = uintptr(0) var rc int32 = f5tDbPointer(tls, interp, pObj, bp+48 /* &db */) - if rc != 0 { - return 1 + if rc != TCL_OK { + return TCL_ERROR } else { *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)) = uintptr(0) *(*uintptr)(unsafe.Pointer(bp + 64 /* pApi */)) = uintptr(0) rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), ts+1997 /* "SELECT fts5(?1)" */, -1, bp+56 /* &pStmt */, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+2013 /* "error: " */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))), 0)) - return 1 + return TCL_ERROR } sqlite3.Xsqlite3_bind_pointer(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)), 1, bp+64 /* &pApi */, ts+2021 /* "fts5_api_ptr" */, uintptr(0)) sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) - if sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) != 0 { + if sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+2013 /* "error: " */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))), 0)) - return 1 + return TCL_ERROR } *(*uintptr)(unsafe.Pointer(ppDb)) = *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)) *(*uintptr)(unsafe.Pointer(ppApi)) = *(*uintptr)(unsafe.Pointer(bp + 64 /* pApi */)) } - return 0 + return TCL_OK } type F5tFunction1 = struct { @@ -11655,7 +11560,7 @@ func xTokenizeCb(tls *libc.TLS, pCtx uintptr, tflags int32, zToken uintptr, nTok tcl.XTclFreeObj(tls, _objPtr) } } - if rc == 0 { + if rc == TCL_OK { rc = f5tResultToErrorCode(tls, tcl.XTcl_GetStringResult(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp)) } @@ -11692,7 +11597,7 @@ func xQueryPhraseCb(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr) int } tcl.XTcl_DeleteCommand(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, bp+8 /* &zCmd[0] */) - if rc == 0 { + if rc == TCL_OK { rc = f5tResultToErrorCode(tls, tcl.XTcl_GetStringResult(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp)) } @@ -11720,78 +11625,24 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv defer tls.Free(684) *(*[19]Sub)(unsafe.Pointer(bp + 32 /* aSub */)) = [19]Sub{ - { - FzName: ts + 2045, /* "xColumnCount" */ - FnArg: 0, - FzMsg: ts + 488 /* "" */}, // 0 - { - FzName: ts + 2058, /* "xRowCount" */ - FnArg: 0, - FzMsg: ts + 488 /* "" */}, // 1 - { - FzName: ts + 2068, /* "xColumnTotalSize" */ - FnArg: 1, - FzMsg: ts + 2085 /* "COL" */}, // 2 - { - FzName: ts + 2089, /* "xTokenize" */ - FnArg: 2, - FzMsg: ts + 2099 /* "TEXT SCRIPT" */}, // 3 - { - FzName: ts + 2111, /* "xPhraseCount" */ - FnArg: 0, - FzMsg: ts + 488 /* "" */}, // 4 - { - FzName: ts + 2124, /* "xPhraseSize" */ - FnArg: 1, - FzMsg: ts + 2136 /* "PHRASE" */}, // 5 - { - FzName: ts + 2143, /* "xInstCount" */ - FnArg: 0, - FzMsg: ts + 488 /* "" */}, // 6 - { - FzName: ts + 2154, /* "xInst" */ - FnArg: 1, - FzMsg: ts + 2160 /* "IDX" */}, // 7 - { - FzName: ts + 2164, /* "xRowid" */ - FnArg: 0, - FzMsg: ts + 488 /* "" */}, // 8 - { - FzName: ts + 2171, /* "xColumnText" */ - FnArg: 1, - FzMsg: ts + 2085 /* "COL" */}, // 9 - { - FzName: ts + 2183, /* "xColumnSize" */ - FnArg: 1, - FzMsg: ts + 2085 /* "COL" */}, // 10 - { - FzName: ts + 2195, /* "xQueryPhrase" */ - FnArg: 2, - FzMsg: ts + 2208 /* "PHRASE SCRIPT" */}, // 11 - { - FzName: ts + 2222, /* "xSetAuxdata" */ - FnArg: 1, - FzMsg: ts + 2234 /* "VALUE" */}, // 12 - { - FzName: ts + 2240, /* "xGetAuxdata" */ - FnArg: 1, - FzMsg: ts + 2252 /* "CLEAR" */}, // 13 - { - FzName: ts + 2258, /* "xSetAuxdataInt" */ - FnArg: 1, - FzMsg: ts + 2273 /* "INTEGER" */}, // 14 - { - FzName: ts + 2281, /* "xGetAuxdataInt" */ - FnArg: 1, - FzMsg: ts + 2252 /* "CLEAR" */}, // 15 - { - FzName: ts + 2296, /* "xPhraseForeach" */ - FnArg: 4, - FzMsg: ts + 2311 /* "IPHRASE COLVAR O..." */}, // 16 - { - FzName: ts + 2340, /* "xPhraseColumnFor..." */ - FnArg: 3, - FzMsg: ts + 2361 /* "IPHRASE COLVAR S..." */}, // 17 + {FzName: ts + 2045 /* "xColumnCount" */, FzMsg: ts + 488 /* "" */}, // 0 + {FzName: ts + 2058 /* "xRowCount" */, FzMsg: ts + 488 /* "" */}, // 1 + {FzName: ts + 2068 /* "xColumnTotalSize" */, FnArg: 1, FzMsg: ts + 2085 /* "COL" */}, // 2 + {FzName: ts + 2089 /* "xTokenize" */, FnArg: 2, FzMsg: ts + 2099 /* "TEXT SCRIPT" */}, // 3 + {FzName: ts + 2111 /* "xPhraseCount" */, FzMsg: ts + 488 /* "" */}, // 4 + {FzName: ts + 2124 /* "xPhraseSize" */, FnArg: 1, FzMsg: ts + 2136 /* "PHRASE" */}, // 5 + {FzName: ts + 2143 /* "xInstCount" */, FzMsg: ts + 488 /* "" */}, // 6 + {FzName: ts + 2154 /* "xInst" */, FnArg: 1, FzMsg: ts + 2160 /* "IDX" */}, // 7 + {FzName: ts + 2164 /* "xRowid" */, FzMsg: ts + 488 /* "" */}, // 8 + {FzName: ts + 2171 /* "xColumnText" */, FnArg: 1, FzMsg: ts + 2085 /* "COL" */}, // 9 + {FzName: ts + 2183 /* "xColumnSize" */, FnArg: 1, FzMsg: ts + 2085 /* "COL" */}, // 10 + {FzName: ts + 2195 /* "xQueryPhrase" */, FnArg: 2, FzMsg: ts + 2208 /* "PHRASE SCRIPT" */}, // 11 + {FzName: ts + 2222 /* "xSetAuxdata" */, FnArg: 1, FzMsg: ts + 2234 /* "VALUE" */}, // 12 + {FzName: ts + 2240 /* "xGetAuxdata" */, FnArg: 1, FzMsg: ts + 2252 /* "CLEAR" */}, // 13 + {FzName: ts + 2258 /* "xSetAuxdataInt" */, FnArg: 1, FzMsg: ts + 2273 /* "INTEGER" */}, // 14 + {FzName: ts + 2281 /* "xGetAuxdataInt" */, FnArg: 1, FzMsg: ts + 2252 /* "CLEAR" */}, // 15 + {FzName: ts + 2296 /* "xPhraseForeach" */, FnArg: 4, FzMsg: ts + 2311 /* "IPHRASE COLVAR O..." */}, // 16 + {FzName: ts + 2340 /* "xPhraseColumnFor..." */, FnArg: 3, FzMsg: ts + 2361 /* "IPHRASE COLVAR S..." */}, // 17 {}, } var rc int32 @@ -11800,17 +11651,17 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv if objc < 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2383 /* "SUB-COMMAND" */) - return 1 + return TCL_ERROR } rc = tcl.XTcl_GetIndexFromObjStruct(tls, - interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+32 /* &aSub[0] */, int32(unsafe.Sizeof(Sub{})), ts+2383 /* "SUB-COMMAND" */, 0, bp+488 /* &iSub */) - if rc != 0 { + interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+32 /* &aSub[0] */, int32(unsafe.Sizeof(Sub{})), ts+2383 /* "SUB-COMMAND" */, 0, bp+488 /* &iSub */) + if rc != TCL_OK { return rc } if (*Sub)(unsafe.Pointer(bp+32 /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 488 /* iSub */)))*24)).FnArg != (objc - 2) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, (*Sub)(unsafe.Pointer(bp+32 /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 488 /* iSub */)))*24)).FzMsg) - return 1 + return TCL_ERROR } switch *(*int32)(unsafe.Pointer(bp + 488 /* iSub */)) { @@ -11818,7 +11669,7 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv { var nCol int32 nCol = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 16 /* &.xColumnCount */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts) - if rc == 0 { + if rc == SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nCol)) } break @@ -11829,7 +11680,7 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv // var nRow sqlite3_int64 at bp+496, 8 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 */) - if rc == 0 { + if rc == SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, *(*sqlite3_int64)(unsafe.Pointer(bp + 496 /* nRow */)))) } break @@ -11841,11 +11692,11 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv // var nSize sqlite3_int64 at bp+512, 8 - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+504 /* &iCol */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+504 /* &iCol */) != 0 { + return TCL_ERROR } 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 */) - if rc == 0 { + if rc == SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, *(*sqlite3_int64)(unsafe.Pointer(bp + 512 /* nSize */)))) } break @@ -11855,15 +11706,15 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv { // var nText int32 at bp+520, 4 - var zText uintptr = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+520 /* &nText */) + var zText uintptr = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+520 /* &nText */) // var ctx F5tFunction at bp+528, 16 (*F5tFunction)(unsafe.Pointer(bp + 528 /* &ctx */)).Finterp = interp - (*F5tFunction)(unsafe.Pointer(bp + 528 /* &ctx */)).FpScript = *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)) + (*F5tFunction)(unsafe.Pointer(bp + 528 /* &ctx */)).FpScript = *(*uintptr)(unsafe.Pointer(objv + 3*8)) 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 { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{xTokenizeCb}))) - if rc == 0 { + if rc == SQLITE_OK { tcl.XTcl_ResetResult(tls, interp) } return rc @@ -11873,7 +11724,7 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv { var nPhrase int32 nPhrase = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 48 /* &.xPhraseCount */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts) - if rc == 0 { + if rc == SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nPhrase)) } break @@ -11884,11 +11735,11 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv // var iPhrase int32 at bp+544, 4 var sz int32 - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+544 /* &iPhrase */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+544 /* &iPhrase */) != 0 { + return TCL_ERROR } 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 */))) - if rc == 0 { + if rc == SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sz)) } break @@ -11899,7 +11750,7 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv // var nInst int32 at bp+548, 4 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 */) - if rc == 0 { + if rc == SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 548 /* nInst */)))) } break @@ -11915,11 +11766,11 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv // var io int32 at bp+564, 4 - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+552 /* &iIdx */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+552 /* &iIdx */) != 0 { + return TCL_ERROR } 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 */) - if rc == 0 { + if rc == SQLITE_OK { var pList uintptr = tcl.XTcl_NewObj(tls) tcl.XTcl_ListObjAppendElement(tls, interp, pList, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 556 /* ip */)))) tcl.XTcl_ListObjAppendElement(tls, interp, pList, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 560 /* ic */)))) @@ -11942,11 +11793,11 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv *(*int32)(unsafe.Pointer(bp + 584 /* n */)) = 0 // var iCol int32 at bp+568, 4 - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+568 /* &iCol */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+568 /* &iCol */) != 0 { + return TCL_ERROR } 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 */) - if rc == 0 { + if rc == SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 576 /* z */)), *(*int32)(unsafe.Pointer(bp + 584 /* n */)))) } break @@ -11957,11 +11808,11 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv *(*int32)(unsafe.Pointer(bp + 592 /* n */)) = 0 // var iCol int32 at bp+588, 4 - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+588 /* &iCol */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+588 /* &iCol */) != 0 { + return TCL_ERROR } 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 */) - if rc == 0 { + if rc == SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 592 /* n */)))) } break @@ -11973,15 +11824,15 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv // var ctx F5tFunction at bp+600, 16 - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+596 /* &iPhrase */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+596 /* &iPhrase */) != 0 { + return TCL_ERROR } (*F5tFunction)(unsafe.Pointer(bp + 600 /* &ctx */)).Finterp = interp - (*F5tFunction)(unsafe.Pointer(bp + 600 /* &ctx */)).FpScript = *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)) + (*F5tFunction)(unsafe.Pointer(bp + 600 /* &ctx */)).FpScript = *(*uintptr)(unsafe.Pointer(objv + 3*8)) 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 { f func(*libc.TLS, uintptr, uintptr, uintptr) int32 }{xQueryPhraseCb}))) - if rc == 0 { + if rc == SQLITE_OK { tcl.XTcl_ResetResult(tls, interp) } break @@ -11992,9 +11843,9 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv var pData uintptr = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(F5tAuxData{}))) if pData == uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+1929 /* "out of memory" */, 0)) - return 1 + return TCL_ERROR } - (*F5tAuxData)(unsafe.Pointer(pData)).FpObj = *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)) + (*F5tAuxData)(unsafe.Pointer(pData)).FpObj = *(*uintptr)(unsafe.Pointer(objv + 2*8)) (*Tcl_Obj)(unsafe.Pointer((*F5tAuxData)(unsafe.Pointer(pData)).FpObj)).FrefCount++ 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}))) break @@ -12005,8 +11856,8 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv var pData uintptr // var bClear int32 at bp+616, 4 - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+616 /* &bClear */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+616 /* &bClear */) != 0 { + return TCL_ERROR } 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 */))) if pData == uintptr(0) { @@ -12029,8 +11880,8 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv { // var iVal int32 at bp+620, 4 - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+620 /* &iVal */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+620 /* &iVal */) != 0 { + return TCL_ERROR } 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)) break @@ -12041,8 +11892,8 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv var iVal int32 // var bClear int32 at bp+624, 4 - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+624 /* &bClear */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+624 /* &bClear */) != 0 { + return TCL_ERROR } 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)) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, iVal)) @@ -12060,30 +11911,30 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv var zColvar uintptr var zOffvar uintptr - var pScript uintptr = *(*uintptr)(unsafe.Pointer(objv + uintptr(5)*8)) + var pScript uintptr = *(*uintptr)(unsafe.Pointer(objv + 5*8)) // var iter Fts5PhraseIter at bp+632, 16 - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+628 /* &iPhrase */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+628 /* &iPhrase */) != 0 { + return TCL_ERROR } - zColvar = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) - zOffvar = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8))) + zColvar = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) + zOffvar = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) 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 */) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } 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 */) { tcl.XTcl_SetVar2Ex(tls, interp, zColvar, uintptr(0), tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 648 /* iCol */))), 0) tcl.XTcl_SetVar2Ex(tls, interp, zOffvar, uintptr(0), tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 652 /* iOff */))), 0) rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, 0) - if rc == 4 { - rc = 0 + if rc == TCL_CONTINUE { + rc = TCL_OK } - if rc != 0 { - if rc == 3 { - rc = 0 + if rc != TCL_OK { + if rc == TCL_BREAK { + rc = TCL_OK } break } @@ -12100,28 +11951,28 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv // var iCol int32 at bp+680, 4 var zColvar uintptr - var pScript uintptr = *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)) + var pScript uintptr = *(*uintptr)(unsafe.Pointer(objv + 4*8)) // var iter Fts5PhraseIter at bp+664, 16 - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+656 /* &iPhrase */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+656 /* &iPhrase */) != 0 { + return TCL_ERROR } - zColvar = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + zColvar = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 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 */) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 1 + return TCL_ERROR } 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 */) { tcl.XTcl_SetVar2Ex(tls, interp, zColvar, uintptr(0), tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 680 /* iCol */))), 0) rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, 0) - if rc == 4 { - rc = 0 + if rc == TCL_CONTINUE { + rc = TCL_OK } - if rc != 0 { - if rc == 3 { - rc = 0 + if rc != TCL_OK { + if rc == TCL_BREAK { + rc = TCL_OK } break } @@ -12136,12 +11987,12 @@ func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv break } - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } type Sub = struct { @@ -12177,17 +12028,17 @@ func xF5tFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal for i = 0; i < nVal; i++ { var pObj uintptr = uintptr(0) switch sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8))) { - case 3: + case SQLITE_TEXT: pObj = tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8))), -1) break - case 4: + case SQLITE_BLOB: pObj = tcl.XTcl_NewByteArrayObj(tls, sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8))), sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8)))) break - case 1: + case SQLITE_INTEGER: pObj = tcl.XTcl_NewWideIntObj(tls, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8)))) break - case 2: + case SQLITE_FLOAT: pObj = tcl.XTcl_NewDoubleObj(tls, sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8)))) break default: @@ -12197,7 +12048,7 @@ func xF5tFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal tcl.XTcl_ListObjAppendElement(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, pEval, pObj) } - rc = tcl.XTcl_EvalObjEx(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, pEval, 1) + rc = tcl.XTcl_EvalObjEx(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, pEval, TCL_GLOBAL_ONLY) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pEval if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -12206,7 +12057,7 @@ func xF5tFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal } tcl.XTcl_DeleteCommand(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, bp+8 /* &zCmd[0] */) - if rc != 0 { + if rc != TCL_OK { sqlite3.Xsqlite3_result_error(tls, pCtx, tcl.XTcl_GetStringResult(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp), -1) } else { var pVar uintptr = tcl.XTcl_GetObjResult(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp) @@ -12218,7 +12069,7 @@ func xF5tFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal } return ts + 488 /* "" */ }() - var c int8 = *(*int8)(unsafe.Pointer(zType + uintptr(0))) + var c int8 = *(*int8)(unsafe.Pointer(zType)) if ((int32(c) == 'b') && (libc.Xstrcmp(tls, zType, ts+2404 /* "bytearray" */) == 0)) && ((*Tcl_Obj)(unsafe.Pointer(pVar)).Fbytes == uintptr(0)) { // Only return a BLOB type if the Tcl variable is a bytearray and // has no string representation. @@ -12273,14 +12124,14 @@ func f5tCreateFunction(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2441 /* "DB NAME SCRIPT" */) - return 1 + return TCL_ERROR } - if f5tDbAndApi(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+24 /* &db */, bp+32 /* &pApi */) != 0 { - return 1 + if f5tDbAndApi(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+24 /* &db */, bp+32 /* &pApi */) != 0 { + return TCL_ERROR } - zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - pScript = *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)) + zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + pScript = *(*uintptr)(unsafe.Pointer(objv + 3*8)) pCtx = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(F5tFunction{}))) (*F5tFunction)(unsafe.Pointer(pCtx)).Finterp = interp (*F5tFunction)(unsafe.Pointer(pCtx)).FpScript = pScript @@ -12290,12 +12141,12 @@ func f5tCreateFunction(tls *libc.TLS, clientData uintptr, interp uintptr, objc i *(*uintptr)(unsafe.Pointer(bp + 32 /* pApi */)), zName, pCtx, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) }{xF5tFunction})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{xF5tDestroy}))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+2013 /* "error: " */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */))), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } type F5tTokenizeCtx1 = struct { @@ -12318,7 +12169,7 @@ func xTokenizeCb2(tls *libc.TLS, pCtx uintptr, tflags int32, zToken uintptr, nTo tcl.XTcl_ListObjAppendElement(tls, uintptr(0), (*F5tTokenizeCtx)(unsafe.Pointer(p)).FpRet, tcl.XTcl_NewIntObj(tls, iStart)) tcl.XTcl_ListObjAppendElement(tls, uintptr(0), (*F5tTokenizeCtx)(unsafe.Pointer(p)).FpRet, tcl.XTcl_NewIntObj(tls, iEnd)) } - return 0 + return SQLITE_OK } // sqlite3_fts5_tokenize DB TOKENIZER TEXT @@ -12348,38 +12199,38 @@ func f5tTokenize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if (objc != 4) && (objc != 5) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2456 /* "?-subst? DB NAME..." */) - return 1 + return TCL_ERROR } if objc == 5 { - var zOpt uintptr = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + var zOpt uintptr = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) if libc.Xstrcmp(tls, ts+2478 /* "-subst" */, zOpt) != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+2485 /* "unrecognized opt..." */, zOpt, 0)) - return 1 + return TCL_ERROR } } if f5tDbAndApi(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-3))*8)), bp+96 /* &db */, bp+104 /* &pApi */) != 0 { - return 1 + return TCL_ERROR } 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 { - return 1 + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 112 /* nArg */)) == 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+2507 /* "no such tokenize..." */, 0)) tcl.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* azArg */))) - return 1 + return TCL_ERROR } zText = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)), bp+128 /* &nText */) - 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 */)) + uintptr(0)*8)), bp+136 /* &pUserdata */, bp+144 /* &tokenizer */) - if rc != 0 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, ts+2507 /* "no such tokenize..." */, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 120 /* azArg */)) + uintptr(0)*8)), 0)) - return 1 + 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 */) + if rc != SQLITE_OK { + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, ts+2507 /* "no such tokenize..." */, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 120 /* azArg */)))), 0)) + return TCL_ERROR } - 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 */)) + uintptr(1)*8), (*(*int32)(unsafe.Pointer(bp + 112 /* nArg */)) - 1), bp+168 /* &pTok */) - if rc != 0 { + 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 */) + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, ts+2527 /* "error in tokeniz..." */, 0)) - return 1 + return TCL_ERROR } pRet = tcl.XTcl_NewObj(tls) @@ -12388,11 +12239,11 @@ func f5tTokenize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, (*F5tTokenizeCtx)(unsafe.Pointer(bp + 176 /* &ctx */)).FpRet = pRet (*F5tTokenizeCtx)(unsafe.Pointer(bp + 176 /* &ctx */)).FzInput = zText rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer((bp + 144 /* &tokenizer */ + 16 /* &.xTokenize */))))(tls, - *(*uintptr)(unsafe.Pointer(bp + 168 /* pTok */)), bp+176 /* &ctx */, 0x0004, zText, *(*int32)(unsafe.Pointer(bp + 128 /* nText */)), *(*uintptr)(unsafe.Pointer(&struct { + *(*uintptr)(unsafe.Pointer(bp + 168 /* pTok */)), bp+176 /* &ctx */, FTS5_TOKENIZE_DOCUMENT, zText, *(*int32)(unsafe.Pointer(bp + 128 /* nText */)), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{xTokenizeCb2}))) (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((bp + 144 /* &tokenizer */ + 8 /* &.xDelete */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pTok */))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+80, ts+2556 /* "error in tokeniz..." */, 0)) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pRet @@ -12400,7 +12251,7 @@ func f5tTokenize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, tcl.XTclFreeObj(tls, _objPtr) } } - return 1 + return TCL_ERROR } tcl.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* azArg */))) @@ -12411,7 +12262,7 @@ func f5tTokenize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, tcl.XTclFreeObj(tls, _objPtr) } } - return 0 + return TCL_OK } // ************************************************************************ @@ -12446,18 +12297,18 @@ type F5tTokenizerInstance = F5tTokenizerInstance1 /* fts5_tcl.c:762:37 */ func f5tTokenizerCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, ppOut uintptr) int32 { /* fts5_tcl.c:781:12: */ var pMod uintptr = pCtx var pEval uintptr - var rc int32 = 0 + var rc int32 = TCL_OK var i int32 pEval = tcl.XTcl_DuplicateObj(tls, (*F5tTokenizerModule)(unsafe.Pointer(pMod)).FpScript) (*Tcl_Obj)(unsafe.Pointer(pEval)).FrefCount++ - for i = 0; (rc == 0) && (i < nArg); i++ { + for i = 0; (rc == TCL_OK) && (i < nArg); i++ { var pObj uintptr = tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), -1) rc = tcl.XTcl_ListObjAppendElement(tls, (*F5tTokenizerModule)(unsafe.Pointer(pMod)).Finterp, pEval, pObj) } - if rc == 0 { - rc = tcl.XTcl_EvalObjEx(tls, (*F5tTokenizerModule)(unsafe.Pointer(pMod)).Finterp, pEval, 1) + if rc == TCL_OK { + rc = tcl.XTcl_EvalObjEx(tls, (*F5tTokenizerModule)(unsafe.Pointer(pMod)).Finterp, pEval, TCL_GLOBAL_ONLY) } for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pEval @@ -12466,7 +12317,7 @@ func f5tTokenizerCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, } } - if rc == 0 { + if rc == TCL_OK { var pInst uintptr pInst = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(F5tTokenizerInstance{}))) libc.Xmemset(tls, pInst, 0, uint64(unsafe.Sizeof(F5tTokenizerInstance{}))) @@ -12508,16 +12359,16 @@ func f5tTokenizerTokenize(tls *libc.TLS, p uintptr, pCtx uintptr, flags int32, p pEval = tcl.XTcl_DuplicateObj(tls, (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).FpScript) (*Tcl_Obj)(unsafe.Pointer(pEval)).FrefCount++ switch flags { - case 0x0004: + case FTS5_TOKENIZE_DOCUMENT: zFlags = ts + 2587 /* "document" */ break - case 0x0008: + case FTS5_TOKENIZE_AUX: zFlags = ts + 2596 /* "aux" */ break - case 0x0001: + case FTS5_TOKENIZE_QUERY: zFlags = ts + 2600 /* "query" */ break - case (0x0002 | 0x0001): + case (FTS5_TOKENIZE_PREFIX | FTS5_TOKENIZE_QUERY): zFlags = ts + 2606 /* "prefixquery" */ break default: @@ -12528,7 +12379,7 @@ func f5tTokenizerTokenize(tls *libc.TLS, p uintptr, pCtx uintptr, flags int32, p tcl.XTcl_ListObjAppendElement(tls, (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).Finterp, pEval, tcl.XTcl_NewStringObj(tls, zFlags, -1)) tcl.XTcl_ListObjAppendElement(tls, (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).Finterp, pEval, tcl.XTcl_NewStringObj(tls, pText, nText)) - rc = tcl.XTcl_EvalObjEx(tls, (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).Finterp, pEval, 1) + rc = tcl.XTcl_EvalObjEx(tls, (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).Finterp, pEval, TCL_GLOBAL_ONLY) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pEval if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -12565,11 +12416,11 @@ func f5tTokenizerReturn(tls *libc.TLS, clientData uintptr, interp uintptr, objc if !(objc == 5) { goto __1 } - zArg = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+16 /* &nArg */) + zArg = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &nArg */) if !(((*(*int32)(unsafe.Pointer(bp + 16 /* nArg */)) <= 10) && (*(*int32)(unsafe.Pointer(bp + 16 /* nArg */)) >= 2)) && (libc.Xmemcmp(tls, ts+2626 /* "-colocated" */, zArg, uint64(*(*int32)(unsafe.Pointer(bp + 16 /* nArg */)))) == 0)) { goto __3 } - tflags = tflags | (0x0001) + tflags = tflags | (FTS5_TOKEN_COLOCATED) goto __4 __3: goto usage @@ -12591,7 +12442,7 @@ __2: (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)), bp+28 /* &iEnd */) != 0)) { goto __6 } - return 1 + return TCL_ERROR __6: ; @@ -12600,20 +12451,20 @@ __6: } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+2637 /* "sqlite3_fts5_tok..." */, 0)) - return 1 + return TCL_ERROR __7: ; 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 */))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - if rc == 0 { - return 0 + if rc == SQLITE_OK { + return TCL_OK } - return 1 + return TCL_ERROR usage: tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2695 /* "?-colocated? TEX..." */) - return 1 + return TCL_ERROR } func f5tDelTokenizer(tls *libc.TLS, pCtx uintptr) { /* fts5_tcl.c:934:13: */ @@ -12659,13 +12510,13 @@ func f5tCreateTokenizer(tls *libc.TLS, clientData ClientData, interp uintptr, ob if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2441 /* "DB NAME SCRIPT" */) - return 1 + return TCL_ERROR } - if f5tDbAndApi(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+16 /* &db */, bp+24 /* &pApi */) != 0 { - return 1 + if f5tDbAndApi(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &db */, bp+24 /* &pApi */) != 0 { + return TCL_ERROR } - zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - pScript = *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)) + zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + pScript = *(*uintptr)(unsafe.Pointer(objv + 3*8)) (*fts5_tokenizer)(unsafe.Pointer(bp + 32 /* &t */)).FxCreate = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 @@ -12681,12 +12532,12 @@ func f5tCreateTokenizer(tls *libc.TLS, clientData ClientData, interp uintptr, ob (*F5tTokenizerModule)(unsafe.Pointer(pMod)).FpContext = pContext (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ 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}))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+2723 /* "error in fts5_ap..." */, 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } func xF5tFree(tls *libc.TLS, clientData ClientData) { /* fts5_tcl.c:999:27: */ @@ -12704,19 +12555,19 @@ func f5tMayBeCorrupt(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if (objc != 2) && (objc != 1) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2760 /* "?BOOLEAN?" */) - return 1 + return TCL_ERROR } if objc == 2 { // var bNew int32 at bp, 4 - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &bNew */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &bNew */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_fts5_may_be_corrupt = *(*int32)(unsafe.Pointer(bp /* bNew */)) } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, bOld)) - return 0 + return TCL_OK } func f5t_fts5HashKey(tls *libc.TLS, nSlot int32, p uintptr, n int32) uint32 { /* fts5_tcl.c:1031:21: */ @@ -12740,16 +12591,16 @@ func f5tTokenHash(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2770 /* "NSLOT TOKEN" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &nSlot */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &nSlot */) != 0 { + return TCL_ERROR } - z = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+4 /* &n */) + z = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+4 /* &n */) iVal = f5t_fts5HashKey(tls, *(*int32)(unsafe.Pointer(bp /* nSlot */)), z, *(*int32)(unsafe.Pointer(bp + 4 /* n */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, int32(iVal))) - return 0 + return TCL_OK } func f5tRegisterMatchinfo(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* fts5_tcl.c:1065:26: */ @@ -12761,18 +12612,18 @@ func f5tRegisterMatchinfo(tls *libc.TLS, clientData uintptr, interp uintptr, obj if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if f5tDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &db */) != 0 { - return 1 + if f5tDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &db */) != 0 { + return TCL_ERROR } rc = sqlite3Fts5TestRegisterMatchinfo(tls, *(*uintptr)(unsafe.Pointer(bp /* db */))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } func f5tRegisterTok(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* fts5_tcl.c:1090:26: */ @@ -12785,18 +12636,18 @@ func f5tRegisterTok(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if f5tDbAndApi(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &db */, bp+8 /* &pApi */) != 0 { - return 1 + if f5tDbAndApi(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &db */, bp+8 /* &pApi */) != 0 { + return TCL_ERROR } rc = sqlite3Fts5TestRegisterTok(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), *(*uintptr)(unsafe.Pointer(bp + 8 /* pApi */))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Entry point. @@ -12841,7 +12692,7 @@ func Fts5tcl_Init(tls *libc.TLS, interp uintptr) int32 { /* fts5_tcl.c:1119:5: * }()) } - return 0 + return TCL_OK } var aCmd = [8]struct { @@ -12850,38 +12701,14 @@ var aCmd = [8]struct { FbTokenizeCtx int32 _ [4]byte }{ - { - FzName: ts + 2782, /* "sqlite3_fts5_cre..." */ - FxProc: 0, - FbTokenizeCtx: 1}, - { - FzName: ts + 2812, /* "sqlite3_fts5_tok..." */ - FxProc: 0, - FbTokenizeCtx: 1}, - { - FzName: ts + 2831, /* "sqlite3_fts5_tok..." */ - FxProc: 0, - FbTokenizeCtx: 0}, - { - FzName: ts + 2853, /* "sqlite3_fts5_cre..." */ - FxProc: 0, - FbTokenizeCtx: 0}, - { - FzName: ts + 2882, /* "sqlite3_fts5_may..." */ - FxProc: 0, - FbTokenizeCtx: 0}, - { - FzName: ts + 2910, /* "sqlite3_fts5_tok..." */ - FxProc: 0, - FbTokenizeCtx: 0}, - { - FzName: ts + 2934, /* "sqlite3_fts5_reg..." */ - FxProc: 0, - FbTokenizeCtx: 0}, - { - FzName: ts + 2966, /* "sqlite3_fts5_reg..." */ - FxProc: 0, - FbTokenizeCtx: 0}, + {FzName: ts + 2782 /* "sqlite3_fts5_cre..." */, FxProc: 0, FbTokenizeCtx: 1}, + {FzName: ts + 2812 /* "sqlite3_fts5_tok..." */, FxProc: 0, FbTokenizeCtx: 1}, + {FzName: ts + 2831 /* "sqlite3_fts5_tok..." */, FxProc: 0}, + {FzName: ts + 2853 /* "sqlite3_fts5_cre..." */, FxProc: 0}, + {FzName: ts + 2882 /* "sqlite3_fts5_may..." */, FxProc: 0}, + {FzName: ts + 2910 /* "sqlite3_fts5_tok..." */, FxProc: 0}, + {FzName: ts + 2934 /* "sqlite3_fts5_reg..." */, FxProc: 0}, + {FzName: ts + 2966 /* "sqlite3_fts5_reg..." */, FxProc: 0}, } /* fts5_tcl.c:1124:5 */ type Fts5MatchinfoCtx1 = struct { @@ -12909,7 +12736,7 @@ func fts5_api_from_db(tls *libc.TLS, db uintptr, ppApi uintptr) int32 { /* fts5_ *(*uintptr)(unsafe.Pointer(ppApi)) = uintptr(0) rc = sqlite3.Xsqlite3_prepare(tls, db, ts+1997 /* "SELECT fts5(?1)" */, -1, bp /* &pStmt */, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { sqlite3.Xsqlite3_bind_pointer(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 1, ppApi, ts+2021 /* "fts5_api_ptr" */, uintptr(0)) sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) @@ -12960,11 +12787,11 @@ func fts5MatchinfoFlagsize(tls *libc.TLS, nCol int32, nPhrase int32, f int8) int func fts5MatchinfoIter(tls *libc.TLS, pApi uintptr, pFts uintptr, p uintptr, x uintptr) int32 { /* fts5_test_mi.c:110:12: */ var i int32 var n int32 = 0 - var rc int32 = 0 + var rc int32 = SQLITE_OK var f int8 for i = 0; libc.AssignInt8(&f, *(*int8)(unsafe.Pointer((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FzArg + uintptr(i)))) != 0; i++ { 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)) - if rc != 0 { + if rc != SQLITE_OK { break } n = n + (fts5MatchinfoFlagsize(tls, (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol, (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase, f)) @@ -12993,27 +12820,27 @@ func fts5MatchinfoXCb(tls *libc.TLS, pApi uintptr, pFts uintptr, pUserData uintp iPrev = *(*int32)(unsafe.Pointer(bp + 16 /* iCol */)) } - return 0 + return SQLITE_OK } func fts5MatchinfoGlobalCb(tls *libc.TLS, pApi uintptr, pFts uintptr, p uintptr, f int8, aOut uintptr) int32 { /* fts5_test_mi.c:150:12: */ bp := tls.Alloc(24) defer tls.Free(24) - var rc int32 = 0 + var rc int32 = SQLITE_OK switch int32(f) { case 'p': - *(*u32)(unsafe.Pointer(aOut + uintptr(0)*4)) = u32((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase) + *(*u32)(unsafe.Pointer(aOut)) = u32((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase) break case 'c': - *(*u32)(unsafe.Pointer(aOut + uintptr(0)*4)) = u32((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol) + *(*u32)(unsafe.Pointer(aOut)) = u32((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol) break case 'x': { var i int32 - for i = 0; (i < (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase) && (rc == 0); i++ { + for i = 0; (i < (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase) && (rc == SQLITE_OK); i++ { var pPtr uintptr = (aOut + uintptr(((i*(*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol)*3))*4) rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 104 /* &.xQueryPhrase */))))(tls, pFts, i, pPtr, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr) int32 @@ -13028,7 +12855,7 @@ func fts5MatchinfoGlobalCb(tls *libc.TLS, pApi uintptr, pFts uintptr, p uintptr, // var nRow sqlite3_int64 at bp, 8 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 24 /* &.xRowCount */))))(tls, pFts, bp /* &nRow */) - *(*u32)(unsafe.Pointer(aOut + uintptr(0)*4)) = u32(*(*sqlite3_int64)(unsafe.Pointer(bp /* nRow */))) + *(*u32)(unsafe.Pointer(aOut)) = u32(*(*sqlite3_int64)(unsafe.Pointer(bp /* nRow */))) break } @@ -13041,11 +12868,11 @@ func fts5MatchinfoGlobalCb(tls *libc.TLS, pApi uintptr, pFts uintptr, p uintptr, libc.Xmemset(tls, aOut, 0, (uint64(unsafe.Sizeof(u32(0))) * uint64((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol))) } else { var i int32 - for i = 0; (rc == 0) && (i < (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol); i++ { // var nToken sqlite3_int64 at bp+16, 8 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pApi + 32 /* &.xColumnTotalSize */))))(tls, pFts, i, bp+16 /* &nToken */) - if rc == 0 { + if rc == SQLITE_OK { *(*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 */))))) } } @@ -13063,7 +12890,7 @@ func fts5MatchinfoLocalCb(tls *libc.TLS, pApi uintptr, pFts uintptr, p uintptr, defer tls.Free(80) var i int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK switch int32(f) { case 'b': @@ -13122,7 +12949,7 @@ func fts5MatchinfoLocalCb(tls *libc.TLS, pApi uintptr, pFts uintptr, p uintptr, case 'l': { - for i = 0; (rc == 0) && (i < (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol); i++ { // var nToken int32 at bp+48, 4 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pApi + 96 /* &.xColumnSize */))))(tls, pFts, i, bp+48 /* &nToken */) @@ -13139,7 +12966,7 @@ func fts5MatchinfoLocalCb(tls *libc.TLS, pApi uintptr, pFts uintptr, p uintptr, libc.Xmemset(tls, aOut, 0, (uint64(unsafe.Sizeof(u32(0))) * uint64((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol))) rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 64 /* &.xInstCount */))))(tls, pFts, bp+52 /* &nInst */) - for i = 0; (rc == 0) && (i < *(*int32)(unsafe.Pointer(bp + 52 /* nInst */))); i++ { + for i = 0; (rc == SQLITE_OK) && (i < *(*int32)(unsafe.Pointer(bp + 52 /* nInst */))); i++ { // var iPhrase int32 at bp+56, 4 // var iOff int32 at bp+64, 4 @@ -13153,7 +12980,7 @@ func fts5MatchinfoLocalCb(tls *libc.TLS, pApi uintptr, pFts uintptr, p uintptr, 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 */) iNextPhrase = (*(*int32)(unsafe.Pointer(bp + 56 /* iPhrase */)) + 1) iNextOff = (*(*int32)(unsafe.Pointer(bp + 64 /* iOff */)) + (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((pApi + 56 /* &.xPhraseSize */))))(tls, pFts, 0)) - for j = (i + 1); (rc == 0) && (j < *(*int32)(unsafe.Pointer(bp + 52 /* nInst */))); j++ { + for j = (i + 1); (rc == SQLITE_OK) && (j < *(*int32)(unsafe.Pointer(bp + 52 /* nInst */))); j++ { // var ip int32 at bp+68, 4 // var ic int32 at bp+72, 4 @@ -13222,7 +13049,7 @@ func fts5MatchinfoNew(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, z (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol = nCol (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase = nPhrase - (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FaRet = (p + uintptr(1)*32) + (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FaRet = (p + 1*32) (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnRet = nInt (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FzArg = ((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FaRet + uintptr(nInt)*4) libc.Xmemcpy(tls, (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FzArg, zArg, uint64(i)) @@ -13230,7 +13057,7 @@ func fts5MatchinfoNew(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, z rc = fts5MatchinfoIter(tls, pApi, pFts, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr, int8, uintptr) int32 }{fts5MatchinfoGlobalCb}))) - if rc != 0 { + if rc != SQLITE_OK { sqlite3.Xsqlite3_result_error_code(tls, pCtx, rc) sqlite3.Xsqlite3_free(tls, p) p = uintptr(0) @@ -13242,10 +13069,10 @@ func fts5MatchinfoNew(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, z func fts5MatchinfoFunc(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) { /* fts5_test_mi.c:357:13: */ var zArg uintptr var p uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK if nVal > 0 { - zArg = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + zArg = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))) } else { zArg = ts + 3033 /* "pcx" */ } @@ -13254,18 +13081,18 @@ func fts5MatchinfoFunc(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, if (p == uintptr(0)) || (sqlite3.Xsqlite3_stricmp(tls, zArg, (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FzArg) != 0) { p = fts5MatchinfoNew(tls, pApi, pFts, pCtx, zArg) if p == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { 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}))) } } - if rc == 0 { + if rc == SQLITE_OK { rc = fts5MatchinfoIter(tls, pApi, pFts, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr, int8, uintptr) int32 }{fts5MatchinfoLocalCb}))) } - if rc != 0 { + if rc != SQLITE_OK { sqlite3.Xsqlite3_result_error_code(tls, pCtx, rc) } else { // No errors has occured, so return a copy of the array of integers. @@ -13286,7 +13113,7 @@ func sqlite3Fts5TestRegisterMatchinfo(tls *libc.TLS, db uintptr) int32 { /* fts5 // fts5_api_from_db() function above is copied verbatim from the // FTS5 documentation. Refer there for details. rc = fts5_api_from_db(tls, db, bp /* &pApi */) - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -13296,7 +13123,7 @@ func sqlite3Fts5TestRegisterMatchinfo(tls *libc.TLS, db uintptr) int32 { /* fts5 ** Also check that the fts5_api object is version 2 or newer. */ if (*(*uintptr)(unsafe.Pointer(bp /* pApi */)) == uintptr(0)) || ((*fts5_api)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pApi */)))).FiVersion < 2) { - return 1 + return SQLITE_ERROR } // Register the implementation of matchinfo() @@ -13430,7 +13257,7 @@ type Fts5tokRow1 = struct { type Fts5tokRow = Fts5tokRow1 /* fts5_test_tok.c:49:27 */ func fts5tokDequote(tls *libc.TLS, z uintptr) { /* fts5_test_tok.c:81:13: */ - var q int8 = *(*int8)(unsafe.Pointer(z + uintptr(0))) + var q int8 = *(*int8)(unsafe.Pointer(z)) if (((int32(q) == '[') || (int32(q) == '\'')) || (int32(q) == '"')) || (int32(q) == '`') { var iIn int32 = 1 @@ -13472,7 +13299,7 @@ func fts5tokDequote(tls *libc.TLS, z uintptr) { /* fts5_test_tok.c:81:13: */ // in this case. Or, if an error occurs, an SQLite error code is returned. // The final value of *pazDequote is undefined in this case. func fts5tokDequoteArray(tls *libc.TLS, argc int32, argv uintptr, pazDequote uintptr) int32 { /* fts5_test_tok.c:123:12: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code if argc == 0 { *(*uintptr)(unsafe.Pointer(pazDequote)) = uintptr(0) } else { @@ -13486,7 +13313,7 @@ func fts5tokDequoteArray(tls *libc.TLS, argc int32, argv uintptr, pazDequote uin *(*uintptr)(unsafe.Pointer(pazDequote)) = libc.AssignUintptr(&azDequote, sqlite3.Xsqlite3_malloc64(tls, (uint64((uint64(unsafe.Sizeof(uintptr(0)))*uint64(argc))+uint64(nByte))))) if azDequote == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var pSpace uintptr = (azDequote + uintptr(argc)*8) for i = 0; i < argc; i++ { @@ -13525,30 +13352,30 @@ func fts5tokConnectMethod(tls *libc.TLS, db uintptr, pCtx uintptr, argc int32, a rc = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+3047 /* "CREATE TABLE x(i..." */) - if rc == 0 { + if rc == SQLITE_OK { nDequote = (argc - 3) - rc = fts5tokDequoteArray(tls, nDequote, (argv + uintptr(3)*8), bp /* &azDequote */) + rc = fts5tokDequoteArray(tls, nDequote, (argv + 3*8), bp /* &azDequote */) } - if rc == 0 { + if rc == SQLITE_OK { pTab = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5tokTable{}))) if pTab == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, pTab, 0, uint64(unsafe.Sizeof(Fts5tokTable{}))) } } - if rc == 0 { + if rc == SQLITE_OK { *(*uintptr)(unsafe.Pointer(bp + 8 /* pTokCtx */)) = uintptr(0) var zModule uintptr = uintptr(0) if nDequote > 0 { - zModule = *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* azDequote */)) + uintptr(0)*8)) + zModule = *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* azDequote */)))) } rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 16 /* &.xFindTokenizer */))))(tls, pApi, zModule, bp+8 /* &pTokCtx */, (pTab + 24 /* &.tok */)) - if rc == 0 { - var azArg uintptr = (*(*uintptr)(unsafe.Pointer(bp /* azDequote */)) + uintptr(1)*8) + if rc == SQLITE_OK { + var azArg uintptr = (*(*uintptr)(unsafe.Pointer(bp /* azDequote */)) + 1*8) var nArg int32 if nDequote > 0 { nArg = (nDequote - 1) @@ -13559,7 +13386,7 @@ func fts5tokConnectMethod(tls *libc.TLS, db uintptr, pCtx uintptr, argc int32, a } } - if rc != 0 { + if rc != SQLITE_OK { sqlite3.Xsqlite3_free(tls, pTab) pTab = uintptr(0) } @@ -13578,7 +13405,7 @@ func fts5tokDisconnectMethod(tls *libc.TLS, pVtab uintptr) int32 { /* fts5_test_ (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((pTab + 24 /* &.tok */ + 8 /* &.xDelete */))))(tls, (*Fts5tokTable)(unsafe.Pointer(pTab)).FpTok) } sqlite3.Xsqlite3_free(tls, pTab) - return 0 + return SQLITE_OK } // xBestIndex - Analyze a WHERE and ORDER BY clause. @@ -13588,18 +13415,18 @@ func fts5tokBestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { for i = 0; i < (*sqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint; i++ { if (((*sqlite3_index_constraint)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint+uintptr(i)*12)).Fusable != 0) && ((*sqlite3_index_constraint)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint+uintptr(i)*12)).FiColumn == 0)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint+uintptr(i)*12)).Fop) == 2) { + (int32((*sqlite3_index_constraint)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint+uintptr(i)*12)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { (*sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) (*sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(1) - return 0 + return SQLITE_OK } } (*sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = 0 - return 0 + return SQLITE_OK } // xOpen - Open a cursor. @@ -13608,12 +13435,12 @@ func fts5tokOpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 { /* f pCsr = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5tokCursor{}))) if pCsr == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCsr, 0, uint64(unsafe.Sizeof(Fts5tokCursor{}))) *(*uintptr)(unsafe.Pointer(ppCsr)) = pCsr - return 0 + return SQLITE_OK } // Reset the tokenizer cursor passed as the only argument. As if it had @@ -13636,14 +13463,14 @@ func fts5tokCloseMethod(tls *libc.TLS, pCursor uintptr) int32 { /* fts5_test_tok var pCsr uintptr = pCursor fts5tokResetCursor(tls, pCsr) sqlite3.Xsqlite3_free(tls, pCsr) - return 0 + return SQLITE_OK } // xNext - Advance the cursor to the next row, if any. func fts5tokNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* fts5_test_tok.c:318:12: */ var pCsr uintptr = pCursor (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FiRowid++ - return 0 + return SQLITE_OK } func fts5tokCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nToken int32, iStart int32, iEnd int32) int32 { /* fts5_test_tok.c:324:12: */ @@ -13660,7 +13487,7 @@ func fts5tokCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nToken var aNew uintptr aNew = sqlite3.Xsqlite3_realloc64(tls, (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FaRow, (uint64(uint64(nNew) * uint64(unsafe.Sizeof(Fts5tokRow{}))))) if aNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, (aNew + uintptr((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow)*24), 0, (uint64(unsafe.Sizeof(Fts5tokRow{})) * (uint64(nNew - (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow)))) (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FaRow = aNew @@ -13671,7 +13498,7 @@ func fts5tokCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nToken (*Fts5tokRow)(unsafe.Pointer(pRow)).FiEnd = iEnd if (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow != 0 { (*Fts5tokRow)(unsafe.Pointer(pRow)).FiPos = ((*Fts5tokRow)(unsafe.Pointer(pRow+libc.UintptrFromInt32(-1)*24)).FiPos + (func() int32 { - if (tflags & 0x0001) != 0 { + if (tflags & FTS5_TOKEN_COLOCATED) != 0 { return 0 } return 1 @@ -13679,28 +13506,28 @@ func fts5tokCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nToken } (*Fts5tokRow)(unsafe.Pointer(pRow)).FzToken = sqlite3.Xsqlite3_malloc(tls, (nToken + 1)) if (*Fts5tokRow)(unsafe.Pointer(pRow)).FzToken == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, (*Fts5tokRow)(unsafe.Pointer(pRow)).FzToken, pToken, uint64(nToken)) *(*int8)(unsafe.Pointer((*Fts5tokRow)(unsafe.Pointer(pRow)).FzToken + uintptr(nToken))) = int8(0) (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow++ - return 0 + return SQLITE_OK } // xFilter - Initialize a cursor to point at the start of its data. func fts5tokFilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, nVal int32, apVal uintptr) int32 { /* fts5_test_tok.c:362:12: */ - var rc int32 = 1 + var rc int32 = SQLITE_ERROR var pCsr uintptr = pCursor var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab fts5tokResetCursor(tls, pCsr) if idxNum == 1 { - var zByte uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) - var nByte int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + var zByte uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))) + var nByte int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal))) (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FzInput = sqlite3.Xsqlite3_malloc(tls, (nByte + 1)) if (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FzInput == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { if nByte > 0 { libc.Xmemcpy(tls, (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FzInput, zByte, uint64(nByte)) @@ -13713,7 +13540,7 @@ func fts5tokFilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr ui } } - if rc != 0 { + if rc != SQLITE_OK { return rc } return fts5tokNextMethod(tls, pCursor) @@ -13749,14 +13576,14 @@ func fts5tokColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol int3 sqlite3.Xsqlite3_result_int(tls, pCtx, (*Fts5tokRow)(unsafe.Pointer(pRow)).FiPos) break } - return 0 + return SQLITE_OK } // xRowid - Return the current rowid for the cursor. func fts5tokRowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { /* fts5_test_tok.c:437:12: */ var pCsr uintptr = pCursor *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3_int64((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FiRowid) - return 0 + return SQLITE_OK } // Register the fts5tok module with database connection db. Return SQLITE_OK @@ -13768,54 +13595,19 @@ func sqlite3Fts5TestRegisterTok(tls *libc.TLS, db uintptr, pApi uintptr) int32 { return rc } -var fts5tok_module = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - 0, - FxOpen:// xDestroy - 0, - FxClose:// xOpen - 0, - FxFilter:// xClose - 0, - FxNext:// xFilter - 0, - FxEof:// xNext - 0, - FxColumn:// xEof - 0, - FxRowid:// xColumn - 0, - FxUpdate:// xRowid - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindFunction - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var fts5tok_module = sqlite3_module{ // iVersion + FxCreate: 0, // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDisconnect + FxDestroy: 0, // xDestroy + FxOpen: 0, // xOpen + FxClose: 0, // xClose + FxFilter: 0, // xFilter + FxNext: 0, // xNext + FxEof: 0, // xEof + FxColumn: 0, // xColumn + FxRowid: 0, // xShadowName } /* fts5_test_tok.c:451:31 */ // CAPI3REF: Loadable Extension Thunk @@ -15064,7 +14856,7 @@ func amatchLoadOneRule(tls *libc.TLS, p uintptr, pStmt uintptr, ppRule uintptr, var zTo uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 2) var rCost amatch_cost = sqlite3.Xsqlite3_column_int(tls, pStmt, 3) - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var nFrom int32 // Size of string zFrom, in bytes var nTo int32 // Size of string zTo, in bytes var pRule uintptr = uintptr(0) // New rule object to return @@ -15080,27 +14872,27 @@ func amatchLoadOneRule(tls *libc.TLS, p uintptr, pStmt uintptr, ppRule uintptr, // Silently ignore null transformations if libc.Xstrcmp(tls, zFrom, zTo) == 0 { - if (int32(*(*int8)(unsafe.Pointer(zFrom + uintptr(0)))) == '?') && (int32(*(*int8)(unsafe.Pointer(zFrom + uintptr(1)))) == 0) { + if (int32(*(*int8)(unsafe.Pointer(zFrom))) == '?') && (int32(*(*int8)(unsafe.Pointer(zFrom + 1))) == 0) { if ((*amatch_vtab)(unsafe.Pointer(p)).FrSub == 0) || ((*amatch_vtab)(unsafe.Pointer(p)).FrSub > rCost) { (*amatch_vtab)(unsafe.Pointer(p)).FrSub = rCost } } *(*uintptr)(unsafe.Pointer(ppRule)) = uintptr(0) - return 0 + return SQLITE_OK } - if (rCost <= 0) || (rCost > 1000) { + if (rCost <= 0) || (rCost > AMATCH_MX_COST) { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3118, /* "%s: cost must be..." */ - libc.VaList(bp, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName, 1000)) - rc = 1 - } else if (nFrom > 50) || (nTo > 50) { + libc.VaList(bp, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName, AMATCH_MX_COST)) + rc = SQLITE_ERROR + } else if (nFrom > AMATCH_MX_LENGTH) || (nTo > AMATCH_MX_LENGTH) { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3152, /* "%s: maximum stri..." */ - libc.VaList(bp+16, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName, 50)) - rc = 1 - } else if (iLang < int64(0)) || (iLang > int64(2147483647)) { + libc.VaList(bp+16, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName, AMATCH_MX_LENGTH)) + rc = SQLITE_ERROR + } else if (iLang < int64(0)) || (iLang > AMATCH_MX_LANGID) { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3184, /* "%s: iLang must b..." */ - libc.VaList(bp+32, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName, 2147483647)) - rc = 1 + libc.VaList(bp+32, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName, AMATCH_MX_LANGID)) + rc = SQLITE_ERROR } else if (libc.Xstrcmp(tls, zFrom, ts+488 /* "" */) == 0) && (libc.Xstrcmp(tls, zTo, ts+3219 /* "?" */) == 0) { if ((*amatch_vtab)(unsafe.Pointer(p)).FrIns == 0) || ((*amatch_vtab)(unsafe.Pointer(p)).FrIns > rCost) { (*amatch_vtab)(unsafe.Pointer(p)).FrIns = rCost @@ -15112,7 +14904,7 @@ func amatchLoadOneRule(tls *libc.TLS, p uintptr, pStmt uintptr, ppRule uintptr, } else { pRule = sqlite3.Xsqlite3_malloc64(tls, (uint64((uint64(unsafe.Sizeof(amatch_rule{})) + uint64(nFrom)) + uint64(nTo)))) if pRule == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, pRule, 0, uint64(unsafe.Sizeof(amatch_rule{}))) (*amatch_rule)(unsafe.Pointer(pRule)).FzFrom = ((pRule + 26 /* &.zTo */) + uintptr((nTo + 1))) @@ -15144,25 +14936,25 @@ func amatchLoadRules(tls *libc.TLS, db uintptr, p uintptr, pzErr uintptr) int32 bp := tls.Alloc(192) defer tls.Free(192) - var rc int32 = 0 // Return code - var zSql uintptr // SELECT used to read from rules table + var rc int32 = SQLITE_OK // Return code + var zSql uintptr // SELECT used to read from rules table var pHead uintptr = uintptr(0) zSql = sqlite3.Xsqlite3_mprintf(tls, ts+3221 /* "SELECT * FROM %Q..." */, libc.VaList(bp, (*amatch_vtab)(unsafe.Pointer(p)).FzDb, (*amatch_vtab)(unsafe.Pointer(p)).FzCostTab)) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var rc2 int32 // finalize() return code *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)) = uintptr(0) rc = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+56 /* &pStmt */, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3241 /* "%s: %s" */, libc.VaList(bp+16, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName, sqlite3.Xsqlite3_errmsg(tls, db))) } else if sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) != 4 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3248, /* "%s: %s has %d co..." */ 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 */))))) - rc = 1 + rc = SQLITE_ERROR } else { - for (rc == 0) && (100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)))) { + for (rc == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)))) { *(*uintptr)(unsafe.Pointer(bp + 64 /* pRule */)) = uintptr(0) rc = amatchLoadOneRule(tls, p, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)), bp+64 /* &pRule */, pzErr) if *(*uintptr)(unsafe.Pointer(bp + 64 /* pRule */)) != 0 { @@ -15172,7 +14964,7 @@ func amatchLoadRules(tls *libc.TLS, db uintptr, p uintptr, pzErr uintptr) int32 } } rc2 = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } @@ -15181,7 +14973,7 @@ func amatchLoadRules(tls *libc.TLS, db uintptr, p uintptr, pzErr uintptr) int32 // All rules are now in a singly linked list starting at pHead. This // block sorts them by cost and then sets amatch_vtab.pRule to point to // point to the head of the sorted list. - if rc == 0 { + if rc == SQLITE_OK { var i uint32 var pX uintptr // var a [15]uintptr at bp+72, 120 @@ -15198,7 +14990,7 @@ func amatchLoadRules(tls *libc.TLS, db uintptr, p uintptr, pzErr uintptr) int32 } *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)) = amatchMergeRules(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)), pX) } - pX = *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(0)*8)) + pX = *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */)) i = uint32(1) for ; uint64(i) < (uint64(unsafe.Sizeof([15]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { pX = amatchMergeRules(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)), pX) @@ -15232,7 +15024,7 @@ func amatchDequote(tls *libc.TLS, zIn uintptr) uintptr { /* amatch.c:740:13: */ nIn = sqlite3_int64(libc.Xstrlen(tls, zIn)) zOut = sqlite3.Xsqlite3_malloc64(tls, (uint64(nIn + int64(1)))) if zOut != 0 { - var q int8 = *(*int8)(unsafe.Pointer(zIn + uintptr(0))) // Quote character (if any ) + var q int8 = *(*int8)(unsafe.Pointer(zIn)) // Quote character (if any ) if (((int32(q) != '[') && (int32(q) != '\'')) && (int32(q) != '"')) && (int32(q) != '`') { libc.Xmemcpy(tls, zOut, zIn, (size_t(nIn + int64(1)))) @@ -15285,7 +15077,7 @@ func amatchDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* amatch.c:798:12: var p uintptr = pVtab amatchFree(tls, p) - return 0 + return SQLITE_OK } // Check to see if the argument is of the form: @@ -15332,10 +15124,10 @@ func amatchConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin var zDb uintptr var zVal uintptr var i int32 - rc = 0 + rc = SQLITE_OK pNew = uintptr(0) - zModule = *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)) - zDb = *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) + zModule = *(*uintptr)(unsafe.Pointer(argv)) + zDb = *(*uintptr)(unsafe.Pointer(argv + 1*8)) _ = pAux *(*uintptr)(unsafe.Pointer(ppVtab)) = uintptr(0) @@ -15343,10 +15135,10 @@ func amatchConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin if !(pNew == uintptr(0)) { goto __1 } - return 7 + return SQLITE_NOMEM __1: ; - rc = 7 + rc = SQLITE_NOMEM libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(amatch_vtab{}))) (*amatch_vtab)(unsafe.Pointer(pNew)).Fdb = db (*amatch_vtab)(unsafe.Pointer(pNew)).FzClassName = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zModule)) @@ -15363,7 +15155,7 @@ __2: goto amatchConnectError __3: ; - (*amatch_vtab)(unsafe.Pointer(pNew)).FzSelf = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + (*amatch_vtab)(unsafe.Pointer(pNew)).FzSelf = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) if !((*amatch_vtab)(unsafe.Pointer(pNew)).FzSelf == uintptr(0)) { goto __4 } @@ -15438,7 +15230,7 @@ __14: *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3350 /* "unrecognized arg..." */, libc.VaList(bp+24, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) amatchFree(tls, pNew) *(*uintptr)(unsafe.Pointer(ppVtab)) = uintptr(0) - return 1 + return SQLITE_ERROR goto __6 __6: i++ @@ -15446,27 +15238,27 @@ __6: goto __7 __7: ; - rc = 0 + rc = SQLITE_OK if !((*amatch_vtab)(unsafe.Pointer(pNew)).FzCostTab == uintptr(0)) { goto __16 } *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3379 /* "no edit_distance..." */, 0) - rc = 1 + rc = SQLITE_ERROR goto __17 __16: rc = amatchLoadRules(tls, db, pNew, pzErr) __17: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __18 } - sqlite3.Xsqlite3_vtab_config(tls, db, 2, 0) + sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) rc = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+3413 /* "CREATE TABLE x(w..." */) __18: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __19 } amatchFree(tls, pNew) @@ -15486,13 +15278,13 @@ func amatchOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* amatc var pCur uintptr pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(amatch_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(amatch_cursor{}))) (*amatch_cursor)(unsafe.Pointer(pCur)).FpVtab = p *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) (*amatch_vtab)(unsafe.Pointer(p)).FnCursor++ - return 0 + return SQLITE_OK } // Free up all the memory allocated by a cursor. Set it rLimit to 0 @@ -15524,15 +15316,15 @@ func amatchClose(tls *libc.TLS, cur uintptr) int32 { /* amatch.c:967:12: */ amatchClearCursor(tls, pCur) (*amatch_vtab)(unsafe.Pointer((*amatch_cursor)(unsafe.Pointer(pCur)).FpVtab)).FnCursor-- sqlite3.Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } // Render a 24-bit unsigned integer as a 4-byte base-64 number. func amatchEncodeInt(tls *libc.TLS, x int32, z uintptr) { /* amatch.c:978:13: */ - *(*int8)(unsafe.Pointer(z + uintptr(0))) = a[((x >> 18) & 0x3f)] - *(*int8)(unsafe.Pointer(z + uintptr(1))) = a[((x >> 12) & 0x3f)] - *(*int8)(unsafe.Pointer(z + uintptr(2))) = a[((x >> 6) & 0x3f)] - *(*int8)(unsafe.Pointer(z + uintptr(3))) = a[(x & 0x3f)] + *(*int8)(unsafe.Pointer(z)) = a[((x >> 18) & 0x3f)] + *(*int8)(unsafe.Pointer(z + 1)) = a[((x >> 12) & 0x3f)] + *(*int8)(unsafe.Pointer(z + 2)) = a[((x >> 6) & 0x3f)] + *(*int8)(unsafe.Pointer(z + 3)) = a[(x & 0x3f)] } var a = *(*[65]int8)(unsafe.Pointer(ts + 3480 /* "0123456789ABCDEF..." */)) /* amatch.c:979:21 */ @@ -15541,7 +15333,7 @@ var a = *(*[65]int8)(unsafe.Pointer(ts + 3480 /* "0123456789ABCDEF..." */)) /* a func amatchWriteCost(tls *libc.TLS, pWord uintptr) { /* amatch.c:996:13: */ amatchEncodeInt(tls, (*amatch_word)(unsafe.Pointer(pWord)).FrCost, pWord+112 /* &.zCost */) amatchEncodeInt(tls, (*amatch_word)(unsafe.Pointer(pWord)).FiSeq, ((pWord + 112 /* &.zCost */) + uintptr(4))) - *(*int8)(unsafe.Pointer((pWord + 112 /* &.zCost */) + uintptr(8))) = int8(0) + *(*int8)(unsafe.Pointer((pWord + 112 /* &.zCost */) + 8)) = int8(0) } // Circumvent compiler warnings about the use of strcpy() by supplying @@ -15653,7 +15445,7 @@ func amatchNext(tls *libc.TLS, cur uintptr) int32 { /* amatch.c:1102:12: */ if (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck == uintptr(0) { var zSql uintptr - if ((*amatch_vtab)(unsafe.Pointer(p)).FzVocabLang != 0) && (*(*int8)(unsafe.Pointer((*amatch_vtab)(unsafe.Pointer(p)).FzVocabLang + uintptr(0))) != 0) { + if ((*amatch_vtab)(unsafe.Pointer(p)).FzVocabLang != 0) && (*(*int8)(unsafe.Pointer((*amatch_vtab)(unsafe.Pointer(p)).FzVocabLang)) != 0) { zSql = sqlite3.Xsqlite3_mprintf(tls, ts+3545, /* "SELECT \"%w\" FROM..." */ @@ -15689,13 +15481,13 @@ func amatchNext(tls *libc.TLS, cur uintptr) int32 { /* amatch.c:1102:12: */ nBuf = (int8(nWord + 100)) zBuf = sqlite3.Xsqlite3_realloc(tls, zBuf, int32(nBuf)) if zBuf == uintptr(0) { - return 7 + return SQLITE_NOMEM } } amatchStrcpy(tls, zBuf, ((pWord + 124 /* &.zWord */) + uintptr(2))) - *(*int8)(unsafe.Pointer(bp + 64 /* &zNext[0] */ + uintptr(0))) = int8(0) - *(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */ + uintptr(0))) = *(*int8)(unsafe.Pointer((*amatch_cursor)(unsafe.Pointer(pCur)).FzInput + uintptr((*amatch_word)(unsafe.Pointer(pWord)).FnMatch))) - if *(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */ + uintptr(0))) != 0 { + *(*int8)(unsafe.Pointer(bp + 64 /* &zNext[0] */)) = int8(0) + *(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */)) = *(*int8)(unsafe.Pointer((*amatch_cursor)(unsafe.Pointer(pCur)).FzInput + uintptr((*amatch_word)(unsafe.Pointer(pWord)).FnMatch))) + if *(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */)) != 0 { 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++ { *(*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)))) } @@ -15705,12 +15497,12 @@ func amatchNext(tls *libc.TLS, cur uintptr) int32 { /* amatch.c:1102:12: */ nNextIn = 0 } - if (*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */ + uintptr(0))) != 0) && (int32(*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */ + uintptr(0)))) != '*') { + if (*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */)) != 0) && (int32(*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */))) != '*') { sqlite3.Xsqlite3_reset(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck) amatchStrcat(tls, zBuf, bp+72 /* &zNextIn[0] */) sqlite3.Xsqlite3_bind_text(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck, 1, zBuf, (nWord + nNextIn), uintptr(0)) rc = sqlite3.Xsqlite3_step(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck) - if rc == 100 { + if rc == SQLITE_ROW { zW = sqlite3.Xsqlite3_column_text(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck, 0) if libc.Xstrncmp(tls, zBuf, zW, (uint64(nWord+nNextIn))) == 0 { amatchAddWord(tls, pCur, (*amatch_word)(unsafe.Pointer(pWord)).FrCost, (int32((*amatch_word)(unsafe.Pointer(pWord)).FnMatch) + nNextIn), zBuf, ts+488 /* "" */) @@ -15724,7 +15516,7 @@ func amatchNext(tls *libc.TLS, cur uintptr) int32 { /* amatch.c:1102:12: */ sqlite3.Xsqlite3_reset(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck) sqlite3.Xsqlite3_bind_text(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck, 1, zBuf, -1, libc.UintptrFromInt32(-1)) rc = sqlite3.Xsqlite3_step(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck) - if rc != 100 { + if rc != SQLITE_ROW { break } zW = sqlite3.Xsqlite3_column_text(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck, 0) @@ -15732,14 +15524,14 @@ func amatchNext(tls *libc.TLS, cur uintptr) int32 { /* amatch.c:1102:12: */ if libc.Xstrncmp(tls, zW, zBuf, uint64(nWord)) != 0 { break } - if ((int32(*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */ + uintptr(0)))) == '*') && (int32(*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */ + uintptr(1)))) == 0)) || - ((int32(*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */ + uintptr(0)))) == 0) && (int32(*(*int8)(unsafe.Pointer(zW + uintptr(nWord)))) == 0)) { + if ((int32(*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */))) == '*') && (int32(*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */ + 1))) == 0)) || + ((int32(*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */))) == 0) && (int32(*(*int8)(unsafe.Pointer(zW + uintptr(nWord)))) == 0)) { isMatch = 1 - *(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */ + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */)) = int8(0) nNextIn = 0 break } - *(*int8)(unsafe.Pointer(bp + 64 /* &zNext[0] */ + uintptr(0))) = *(*int8)(unsafe.Pointer(zW + uintptr(nWord))) + *(*int8)(unsafe.Pointer(bp + 64 /* &zNext[0] */)) = *(*int8)(unsafe.Pointer(zW + uintptr(nWord))) for i = 1; (i <= 4) && ((int32(*(*int8)(unsafe.Pointer(zW + uintptr((nWord + i))))) & 0xc0) == 0x80); i++ { *(*int8)(unsafe.Pointer(bp + 64 /* &zNext[0] */ + uintptr(i))) = *(*int8)(unsafe.Pointer(zW + uintptr((nWord + i)))) } @@ -15778,7 +15570,7 @@ func amatchNext(tls *libc.TLS, cur uintptr) int32 { /* amatch.c:1102:12: */ } (*amatch_cursor)(unsafe.Pointer(pCur)).FpCurrent = pWord sqlite3.Xsqlite3_free(tls, zBuf) - return 0 + return SQLITE_OK } // Called to "rewind" a cursor back to the beginning so that @@ -15795,7 +15587,7 @@ func amatchFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp amatchClearCursor(tls, pCur) idx = 0 if (idxNum & 1) != 0 { - zWord = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zWord = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) idx++ } if (idxNum & 2) != 0 { @@ -15808,12 +15600,12 @@ func amatchFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp } (*amatch_cursor)(unsafe.Pointer(pCur)).FzInput = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zWord)) if (*amatch_cursor)(unsafe.Pointer(pCur)).FzInput == uintptr(0) { - return 7 + return SQLITE_NOMEM } amatchAddWord(tls, pCur, 0, 0, ts+488 /* "" */, ts+488 /* "" */) amatchNext(tls, pVtabCursor) - return 0 + return SQLITE_OK } // Only the word and distance columns have values. All other columns @@ -15821,25 +15613,25 @@ func amatchFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp func amatchColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* amatch.c:1286:12: */ var pCur uintptr = cur switch i { - case 0: + case AMATCH_COL_WORD: { sqlite3.Xsqlite3_result_text(tls, ctx, (((*amatch_cursor)(unsafe.Pointer(pCur)).FpCurrent + 124 /* &.zWord */) + uintptr(2)), -1, uintptr(0)) break } - case 1: + case AMATCH_COL_DISTANCE: { sqlite3.Xsqlite3_result_int(tls, ctx, (*amatch_word)(unsafe.Pointer((*amatch_cursor)(unsafe.Pointer(pCur)).FpCurrent)).FrCost) break } - case 2: + case AMATCH_COL_LANGUAGE: { sqlite3.Xsqlite3_result_int(tls, ctx, (*amatch_cursor)(unsafe.Pointer(pCur)).FiLang) break } - case 4: + case AMATCH_COL_NWORD: { sqlite3.Xsqlite3_result_int(tls, ctx, (*amatch_cursor)(unsafe.Pointer(pCur)).FnWord) break @@ -15852,14 +15644,14 @@ func amatchColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* a } } - return 0 + return SQLITE_OK } // The rowid. func amatchRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* amatch.c:1316:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*amatch_cursor)(unsafe.Pointer(pCur)).FiRowid - return 0 + return SQLITE_OK } // EOF indicator @@ -15908,21 +15700,21 @@ __1: } if (((iPlan & 1) == 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 0)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 64) { + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) { iPlan = iPlan | (1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) } if (((iPlan & 2) == 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 1)) && - ((int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 16) || - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 8)) { + ((int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT) || + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LE)) { iPlan = iPlan | (2) iDistTerm = i } if (((iPlan & 4) == 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 2)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2) { + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { iPlan = iPlan | (4) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) iLangTerm = i @@ -15952,13 +15744,13 @@ __3: } (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = iPlan if (((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1) && - ((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).FiColumn == 1)) && - (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).Fdesc) == 0) { + ((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn == 1)) && + (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0) { (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 } (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(10000) - return 0 + return SQLITE_OK } // The xUpdate() method. @@ -15975,82 +15767,48 @@ func amatchUpdate(tls *libc.TLS, pVTab uintptr, argc int32, argv uintptr, pRowid if argc == 1 { (*sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+3656, /* "DELETE from %s i..." */ libc.VaList(bp, (*amatch_vtab)(unsafe.Pointer(p)).FzSelf)) - return 1 + return SQLITE_ERROR } - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) != 5 { + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) != SQLITE_NULL { (*sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+3686, /* "UPDATE of %s is ..." */ libc.VaList(bp+8, (*amatch_vtab)(unsafe.Pointer(p)).FzSelf)) - return 1 + return SQLITE_ERROR } - if ((sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((2+0))*8))) != 5) || - (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((2+1))*8))) != 5)) || - (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((2+2))*8))) != 5) { + if ((sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) != SQLITE_NULL) || + (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) != SQLITE_NULL)) || + (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) != SQLITE_NULL) { (*sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+3714 /* "INSERT INTO %s a..." */, libc.VaList(bp+16, (*amatch_vtab)(unsafe.Pointer(p)).FzSelf)) - return 1 + return SQLITE_ERROR } - zCmd = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((2+3))*8))) + zCmd = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) if zCmd == uintptr(0) { - return 0 + return SQLITE_OK } - return 0 + return SQLITE_OK } // A virtual table module that implements the "approximate_match". -var amatchModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - 0, - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var amatchModule = sqlite3_module{ // iVersion + FxCreate: 0, // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDisconnect + FxDestroy: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRowid - read data + FxUpdate: 0, // xShadowName } /* amatch.c:1454:23 */ // Register the amatch virtual table func sqlite3_amatch_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* amatch.c:1489:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi _ = pzErrMsg // Not used @@ -16099,10 +15857,10 @@ func carrayConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin rc = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+3799 /* "CREATE TABLE x(v..." */) - if rc == 0 { + if rc == SQLITE_OK { pNew = libc.AssignPtrUintptr(ppVtab, sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(sqlite3_vtab{})))) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(sqlite3_vtab{}))) } @@ -16112,7 +15870,7 @@ func carrayConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin // This method is the destructor for carray_cursor objects. func carrayDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* carray.c:131:12: */ sqlite3.Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // Constructor for a new carray_cursor object. @@ -16120,24 +15878,24 @@ func carrayOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* carray.c: var pCur uintptr pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(carray_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(carray_cursor{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Destructor for a carray_cursor. func carrayClose(tls *libc.TLS, cur uintptr) int32 { /* carray.c:151:12: */ sqlite3.Xsqlite3_free(tls, cur) - return 0 + return SQLITE_OK } // Advance a carray_cursor to its next row of output. func carrayNext(tls *libc.TLS, cur uintptr) int32 { /* carray.c:160:12: */ var pCur uintptr = cur (*carray_cursor)(unsafe.Pointer(pCur)).FiRowid++ - return 0 + return SQLITE_OK } // Return values of columns for the row at which the carray_cursor @@ -16146,46 +15904,46 @@ func carrayColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* c var pCur uintptr = cur var x sqlite3_int64 = int64(0) switch i { - case 1: - return 0 - case 2: + case CARRAY_COLUMN_POINTER: + return SQLITE_OK + case CARRAY_COLUMN_COUNT: x = (*carray_cursor)(unsafe.Pointer(pCur)).FiCnt break - case 3: + case CARRAY_COLUMN_CTYPE: { sqlite3.Xsqlite3_result_text(tls, ctx, azType[(*carray_cursor)(unsafe.Pointer(pCur)).FeType], -1, uintptr(0)) - return 0 + return SQLITE_OK } default: { switch int32((*carray_cursor)(unsafe.Pointer(pCur)).FeType) { - case 0: + case CARRAY_INT32: { var p uintptr = (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr sqlite3.Xsqlite3_result_int(tls, ctx, *(*int32)(unsafe.Pointer(p + uintptr(((*carray_cursor)(unsafe.Pointer(pCur)).FiRowid-int64(1)))*4))) - return 0 + return SQLITE_OK } - case 1: + case CARRAY_INT64: { var p uintptr = (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr sqlite3.Xsqlite3_result_int64(tls, ctx, *(*sqlite3_int64)(unsafe.Pointer(p + uintptr(((*carray_cursor)(unsafe.Pointer(pCur)).FiRowid-int64(1)))*8))) - return 0 + return SQLITE_OK } - case 2: + case CARRAY_DOUBLE: { var p uintptr = (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr sqlite3.Xsqlite3_result_double(tls, ctx, *(*float64)(unsafe.Pointer(p + uintptr(((*carray_cursor)(unsafe.Pointer(pCur)).FiRowid-int64(1)))*8))) - return 0 + return SQLITE_OK } - case 3: + case CARRAY_TEXT: { var p uintptr = (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr sqlite3.Xsqlite3_result_text(tls, ctx, *(*uintptr)(unsafe.Pointer(p + uintptr(((*carray_cursor)(unsafe.Pointer(pCur)).FiRowid-int64(1)))*8)), -1, libc.UintptrFromInt32(-1)) - return 0 + return SQLITE_OK } } @@ -16193,7 +15951,7 @@ func carrayColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* c } } sqlite3.Xsqlite3_result_int64(tls, ctx, x) - return 0 + return SQLITE_OK } // Return the rowid for the current row. In this implementation, the @@ -16201,7 +15959,7 @@ func carrayColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* c func carrayRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* carray.c:217:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*carray_cursor)(unsafe.Pointer(pCur)).FiRowid - return 0 + return SQLITE_OK } // Return TRUE if the cursor has been moved off of the last @@ -16219,18 +15977,18 @@ func carrayFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp var pCur uintptr = pVtabCursor if idxNum != 0 { - (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr = sqlite3.Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), ts+3862 /* "carray" */) + (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr = sqlite3.Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(argv)), ts+3862 /* "carray" */) (*carray_cursor)(unsafe.Pointer(pCur)).FiCnt = func() int64 { if (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr != 0 { - return sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + return sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) } return int64(0) }() if idxNum < 3 { - (*carray_cursor)(unsafe.Pointer(pCur)).FeType = uint8(0) + (*carray_cursor)(unsafe.Pointer(pCur)).FeType = CARRAY_INT32 } else { var i uint8 - var zType uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + var zType uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) for i = uint8(0); uint64(i) < (uint64(unsafe.Sizeof(azType)) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { if sqlite3.Xsqlite3_stricmp(tls, zType, azType[i]) == 0 { break @@ -16239,7 +15997,7 @@ func carrayFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp if uint64(i) >= (uint64(unsafe.Sizeof(azType)) / uint64(unsafe.Sizeof(uintptr(0)))) { (*sqlite3_vtab)(unsafe.Pointer((*sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+3869 /* "unknown datatype..." */, libc.VaList(bp, zType)) - return 1 + return SQLITE_ERROR } else { (*carray_cursor)(unsafe.Pointer(pCur)).FeType = i } @@ -16249,7 +16007,7 @@ func carrayFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp (*carray_cursor)(unsafe.Pointer(pCur)).FiCnt = int64(0) } (*carray_cursor)(unsafe.Pointer(pCur)).FiRowid = int64(1) - return 0 + return SQLITE_OK } // SQLite will invoke this method one or more times while planning a query @@ -16280,17 +16038,17 @@ __1: if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { goto __2 } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) != 2 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) != SQLITE_INDEX_CONSTRAINT_EQ { goto __2 } switch (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn { - case 1: + case CARRAY_COLUMN_POINTER: ptrIdx = i break - case 2: + case CARRAY_COLUMN_COUNT: cntIdx = i break - case 3: + case CARRAY_COLUMN_CTYPE: ctypeIdx = i break } @@ -16322,51 +16080,22 @@ __3: (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(2147483647) (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0 } - return 0 + return SQLITE_OK } // This following structure defines all the methods for the // carray virtual table. -var carrayModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - uintptr(0), - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - uintptr(0), - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename +var carrayModule = sqlite3_module{ // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRename } /* carray.c:333:23 */ // For testing purpose in the TCL test harness, we need a method for @@ -16384,7 +16113,7 @@ func inttoptrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* // var i64 sqlite3_int64 at bp+8, 8 - *(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* i64 */)) = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + *(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* i64 */)) = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) if uint64(unsafe.Sizeof(sqlite3_int64(0))) == uint64(unsafe.Sizeof(uintptr(0))) { libc.Xmemcpy(tls, bp /* &p */, bp+8 /* &i64 */, uint64(unsafe.Sizeof(uintptr(0)))) } else { @@ -16395,12 +16124,12 @@ func inttoptrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* } func sqlite3_carray_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* carray.c:389:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi rc = sqlite3.Xsqlite3_create_module(tls, db, ts+3862 /* "carray" */, uintptr(unsafe.Pointer(&carrayModule)), uintptr(0)) - if rc == 0 { - rc = sqlite3.Xsqlite3_create_function(tls, db, ts+3890 /* "inttoptr" */, 1, 1, uintptr(0), + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_function(tls, db, ts+3890 /* "inttoptr" */, 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{inttoptrFunc})), uintptr(0), uintptr(0)) @@ -16687,7 +16416,7 @@ func closureDequote(tls *libc.TLS, zIn uintptr) uintptr { /* closure.c:424:13: * nIn = sqlite3_int64(libc.Xstrlen(tls, zIn)) zOut = sqlite3.Xsqlite3_malloc64(tls, (uint64(nIn + int64(1)))) if zOut != 0 { - var q int8 = *(*int8)(unsafe.Pointer(zIn + uintptr(0))) // Quote character (if any ) + var q int8 = *(*int8)(unsafe.Pointer(zIn)) // Quote character (if any ) if (((int32(q) != '[') && (int32(q) != '\'')) && (int32(q) != '"')) && (int32(q) != '`') { libc.Xmemcpy(tls, zOut, zIn, (size_t(nIn + int64(1)))) @@ -16728,7 +16457,7 @@ func closureDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* closure.c:468:12 var p uintptr = pVtab closureFree(tls, p) - return 0 + return SQLITE_OK } // Check to see if the argument is of the form: @@ -16774,9 +16503,9 @@ func closureConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv ui var zDb uintptr var zVal uintptr var i int32 - rc = 0 + rc = SQLITE_OK pNew = uintptr(0) - zDb = *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) + zDb = *(*uintptr)(unsafe.Pointer(argv + 1*8)) _ = pAux *(*uintptr)(unsafe.Pointer(ppVtab)) = uintptr(0) @@ -16784,10 +16513,10 @@ func closureConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv ui if !(pNew == uintptr(0)) { goto __1 } - return 7 + return SQLITE_NOMEM __1: ; - rc = 7 + rc = SQLITE_NOMEM libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(closure_vtab{}))) (*closure_vtab)(unsafe.Pointer(pNew)).Fdb = db (*closure_vtab)(unsafe.Pointer(pNew)).FzDb = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zDb)) @@ -16797,7 +16526,7 @@ __1: goto closureConnectError __2: ; - (*closure_vtab)(unsafe.Pointer(pNew)).FzSelf = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + (*closure_vtab)(unsafe.Pointer(pNew)).FzSelf = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) if !((*closure_vtab)(unsafe.Pointer(pNew)).FzSelf == uintptr(0)) { goto __3 } @@ -16857,7 +16586,7 @@ __11: *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3350 /* "unrecognized arg..." */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) closureFree(tls, pNew) *(*uintptr)(unsafe.Pointer(ppVtab)) = uintptr(0) - return 1 + return SQLITE_ERROR goto __5 __5: i++ @@ -16868,7 +16597,7 @@ __6: rc = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+3931 /* "CREATE TABLE x(i..." */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __13 } closureFree(tls, pNew) @@ -16888,13 +16617,13 @@ func closureOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* clos var pCur uintptr pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(closure_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(closure_cursor{}))) (*closure_cursor)(unsafe.Pointer(pCur)).FpVtab = p *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) (*closure_vtab)(unsafe.Pointer(p)).FnCursor++ - return 0 + return SQLITE_OK } // Free up all the memory allocated by a cursor. Set it rLimit to 0 @@ -16917,28 +16646,28 @@ func closureClose(tls *libc.TLS, cur uintptr) int32 { /* closure.c:610:12: */ closureClearCursor(tls, pCur) (*closure_vtab)(unsafe.Pointer((*closure_cursor)(unsafe.Pointer(pCur)).FpVtab)).FnCursor-- sqlite3.Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } // Advance a cursor to its next row of output func closureNext(tls *libc.TLS, cur uintptr) int32 { /* closure.c:621:12: */ var pCur uintptr = cur (*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent = closureAvlNext(tls, (*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent) - return 0 + return SQLITE_OK } // Allocate and insert a node func closureInsertNode(tls *libc.TLS, pQueue uintptr, pCur uintptr, id sqlite3_int64, iGeneration int32) int32 { /* closure.c:630:12: */ var pNew uintptr = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(closure_avl{}))) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(closure_avl{}))) (*closure_avl)(unsafe.Pointer(pNew)).Fid = id (*closure_avl)(unsafe.Pointer(pNew)).FiGeneration = iGeneration closureAvlInsert(tls, (pCur + 48 /* &.pClosure */), pNew) queuePush(tls, pQueue, pNew) - return 0 + return SQLITE_OK } // Called to "rewind" a cursor back to the beginning so that @@ -16962,7 +16691,7 @@ func closureFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint // var pStmt uintptr at bp+88, 8 var pAvl uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK var zTableName uintptr = (*closure_vtab)(unsafe.Pointer(pVtab)).FzTableName var zIdColumn uintptr = (*closure_vtab)(unsafe.Pointer(pVtab)).FzIdColumn var zParentColumn uintptr = (*closure_vtab)(unsafe.Pointer(pVtab)).FzParentColumn @@ -16974,9 +16703,9 @@ func closureFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint libc.Xmemset(tls, bp+72 /* &sQueue */, 0, uint64(unsafe.Sizeof(closure_queue{}))) if (idxNum & 1) == 0 { // No root=$root in the WHERE clause. Return an empty set - return 0 + return SQLITE_OK } - iRoot = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + iRoot = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) if (idxNum & 0x000f0) != 0 { mxGen = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(((idxNum>>4)&0x0f))*8))) if (idxNum & 0x00002) != 0 { @@ -17000,7 +16729,7 @@ func closureFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint ts+4021, /* "SELECT \"%w\".\"%w\"..." */ libc.VaList(bp+24, zTableName, zIdColumn, zTableName, zTableName, zParentColumn)) if zSql == uintptr(0) { - return 7 + return SQLITE_NOMEM } else { rc = sqlite3.Xsqlite3_prepare_v2(tls, (*closure_vtab)(unsafe.Pointer(pVtab)).Fdb, zSql, -1, bp+88 /* &pStmt */, uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) @@ -17010,7 +16739,7 @@ func closureFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint return rc } } - if rc == 0 { + if rc == SQLITE_OK { rc = closureInsertNode(tls, bp+72 /* &sQueue */, pCur, iRoot, 0) } for (libc.AssignUintptr(&pAvl, queuePull(tls, bp+72 /* &sQueue */))) != uintptr(0) { @@ -17018,8 +16747,8 @@ func closureFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint continue } sqlite3.Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */)), 1, (*closure_avl)(unsafe.Pointer(pAvl)).Fid) - for (rc == 0) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */))) == 100) { - if sqlite3.Xsqlite3_column_type(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */)), 0) == 1 { + for (rc == SQLITE_OK) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */))) == SQLITE_ROW) { + if sqlite3.Xsqlite3_column_type(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */)), 0) == SQLITE_INTEGER { var iNew sqlite3_int64 = sqlite3.Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */)), 0) if closureAvlSearch(tls, (*closure_cursor)(unsafe.Pointer(pCur)).FpClosure, iNew) == uintptr(0) { rc = closureInsertNode(tls, bp+72 /* &sQueue */, pCur, iNew, ((*closure_avl)(unsafe.Pointer(pAvl)).FiGeneration + 1)) @@ -17029,7 +16758,7 @@ func closureFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint sqlite3.Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */))) } sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */))) - if rc == 0 { + if rc == SQLITE_OK { (*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent = closureAvlFirst(tls, (*closure_cursor)(unsafe.Pointer(pCur)).FpClosure) } @@ -17041,25 +16770,25 @@ func closureFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint func closureColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* closure.c:743:12: */ var pCur uintptr = cur switch i { - case 0: + case CLOSURE_COL_ID: { sqlite3.Xsqlite3_result_int64(tls, ctx, (*closure_avl)(unsafe.Pointer((*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent)).Fid) break } - case 1: + case CLOSURE_COL_DEPTH: { sqlite3.Xsqlite3_result_int(tls, ctx, (*closure_avl)(unsafe.Pointer((*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent)).FiGeneration) break } - case 2: + case CLOSURE_COL_ROOT: { sqlite3.Xsqlite3_result_null(tls, ctx) break } - case 3: + case CLOSURE_COL_TABLENAME: { sqlite3.Xsqlite3_result_text(tls, ctx, func() uintptr { @@ -17072,7 +16801,7 @@ func closureColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* break } - case 4: + case CLOSURE_COL_IDCOLUMN: { sqlite3.Xsqlite3_result_text(tls, ctx, func() uintptr { @@ -17085,7 +16814,7 @@ func closureColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* break } - case 5: + case CLOSURE_COL_PARENTCOLUMN: { sqlite3.Xsqlite3_result_text(tls, ctx, func() uintptr { @@ -17099,14 +16828,14 @@ func closureColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* } } - return 0 + return SQLITE_OK } // The rowid. For the closure table, this is the same as the "id" column. func closureRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* closure.c:783:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*closure_avl)(unsafe.Pointer((*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent)).Fid - return 0 + return SQLITE_OK } // EOF indicator @@ -17157,43 +16886,43 @@ __1: goto __2 } if (((iPlan & 1) == 0) && - ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 2)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2) { + ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == CLOSURE_COL_ROOT)) && + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { iPlan = iPlan | (1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) rCost = rCost / (100.0) } if (((iPlan & 0x0000f0) == 0) && - ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 1)) && - (((int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 16) || - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 8)) || - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2)) { + ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == CLOSURE_COL_DEPTH)) && + (((int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT) || + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LE)) || + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ)) { iPlan = iPlan | (idx << 4) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&idx, 1) - if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 16 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT { iPlan = iPlan | (0x000002) } rCost = rCost / (5.0) } if (((iPlan & 0x000f00) == 0) && - ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 3)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2) { + ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == CLOSURE_COL_TABLENAME)) && + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { iPlan = iPlan | (idx << 8) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&idx, 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) rCost = rCost / (5.0) } if (((iPlan & 0x00f000) == 0) && - ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 4)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2) { + ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == CLOSURE_COL_IDCOLUMN)) && + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { iPlan = iPlan | (idx << 12) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&idx, 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) } if (((iPlan & 0x0f0000) == 0) && - ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 5)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2) { + ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == CLOSURE_COL_PARENTCOLUMN)) && + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { iPlan = iPlan | (idx << 16) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&idx, 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) @@ -17244,69 +16973,34 @@ __3: } (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = iPlan if (((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1) && - ((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).FiColumn == 0)) && - (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).Fdesc) == 0) { + ((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn == CLOSURE_COL_ID)) && + (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0) { (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 } (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = rCost - return 0 + return SQLITE_OK } // A virtual table module that implements the "transitive_closure". -var closureModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - 0, - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var closureModule = sqlite3_module{ // iVersion + FxCreate: 0, // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDisconnect + FxDestroy: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xShadowName } /* closure.c:918:23 */ // Register the closure virtual table func sqlite3_closure_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* closure.c:953:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi _ = pzErrMsg @@ -17363,7 +17057,7 @@ func csv_reader_init(tls *libc.TLS, p uintptr) { /* csv.c:89:13: */ (*CsvReader)(unsafe.Pointer(p)).FbNotFirst = 0 (*CsvReader)(unsafe.Pointer(p)).FnIn = uint64(0) (*CsvReader)(unsafe.Pointer(p)).FzIn = uintptr(0) - *(*int8)(unsafe.Pointer((p + 64 /* &.zErr */) + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer((p + 64 /* &.zErr */))) = int8(0) } // Close and reset a CsvReader object @@ -17381,7 +17075,7 @@ func csv_errmsg(tls *libc.TLS, p uintptr, zFormat uintptr, va uintptr) { /* csv. var ap va_list _ = ap ap = va - sqlite3.Xsqlite3_vsnprintf(tls, 200, p+64 /* &.zErr */, zFormat, ap) + sqlite3.Xsqlite3_vsnprintf(tls, CSV_MXERR, p+64 /* &.zErr */, zFormat, ap) _ = ap } @@ -17392,7 +17086,7 @@ func csv_reader_open(tls *libc.TLS, p uintptr, zFilename uintptr, zData uintptr) defer tls.Free(8) if zFilename != 0 { - (*CsvReader)(unsafe.Pointer(p)).FzIn = sqlite3.Xsqlite3_malloc(tls, 1024) + (*CsvReader)(unsafe.Pointer(p)).FzIn = sqlite3.Xsqlite3_malloc(tls, CSV_INBUFSZ) if (*CsvReader)(unsafe.Pointer(p)).FzIn == uintptr(0) { csv_errmsg(tls, p, ts+1929 /* "out of memory" */, 0) return 1 @@ -17420,13 +17114,13 @@ func csv_getc_refill(tls *libc.TLS, p uintptr) int32 { /* csv.c:151:25: */ // Only called on an empty input buffer // Only called if reading froma file - got = libc.Xfread(tls, (*CsvReader)(unsafe.Pointer(p)).FzIn, uint64(1), uint64(1024), (*CsvReader)(unsafe.Pointer(p)).Fin) + got = libc.Xfread(tls, (*CsvReader)(unsafe.Pointer(p)).FzIn, uint64(1), CSV_INBUFSZ, (*CsvReader)(unsafe.Pointer(p)).Fin) if got == uint64(0) { return -1 } (*CsvReader)(unsafe.Pointer(p)).FnIn = got (*CsvReader)(unsafe.Pointer(p)).FiIn = uint64(1) - return int32(*(*int8)(unsafe.Pointer((*CsvReader)(unsafe.Pointer(p)).FzIn + uintptr(0)))) + return int32(*(*int8)(unsafe.Pointer((*CsvReader)(unsafe.Pointer(p)).FzIn))) } // Return the next character of input. Return EOF at end of input. @@ -17616,13 +17310,13 @@ func csvtabDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* csv.c:337:12: */ sqlite3.Xsqlite3_free(tls, (*CsvTable)(unsafe.Pointer(p)).FzFilename) sqlite3.Xsqlite3_free(tls, (*CsvTable)(unsafe.Pointer(p)).FzData) sqlite3.Xsqlite3_free(tls, p) - return 0 + return SQLITE_OK } // Skip leading whitespace. Return a pointer to the first non-whitespace // character, or to the zero terminator if the string has only whitespace func csv_skip_whitespace(tls *libc.TLS, z uintptr) uintptr { /* csv.c:347:19: */ - for (int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(z + uintptr(0))))))*2))) & int32(_ISspace)) != 0 { + 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 { z++ } return z @@ -17640,7 +17334,7 @@ func csv_trim_whitespace(tls *libc.TLS, z uintptr) { /* csv.c:353:13: */ // Dequote the string func csv_dequote(tls *libc.TLS, z uintptr) { /* csv.c:360:13: */ var j int32 - var cQuote int8 = *(*int8)(unsafe.Pointer(z + uintptr(0))) + var cQuote int8 = *(*int8)(unsafe.Pointer(z)) var i size_t var n size_t @@ -17648,7 +17342,7 @@ func csv_dequote(tls *libc.TLS, z uintptr) { /* csv.c:360:13: */ return } n = libc.Xstrlen(tls, z) - if (n < uint64(2)) || (int32(*(*int8)(unsafe.Pointer(z + uintptr((n - uint64(1)))))) != int32(*(*int8)(unsafe.Pointer(z + uintptr(0))))) { + if (n < uint64(2)) || (int32(*(*int8)(unsafe.Pointer(z + uintptr((n - uint64(1)))))) != int32(*(*int8)(unsafe.Pointer(z)))) { return } i = uint64(1) @@ -17671,7 +17365,7 @@ func csv_parameter(tls *libc.TLS, zTag uintptr, nTag int32, z uintptr) uintptr { return uintptr(0) } z = csv_skip_whitespace(tls, (z + uintptr(nTag))) - if int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) != '=' { + if int32(*(*int8)(unsafe.Pointer(z))) != '=' { return uintptr(0) } return csv_skip_whitespace(tls, (z + uintptr(1))) @@ -17691,7 +17385,7 @@ func csv_string_parameter(tls *libc.TLS, p uintptr, zParam uintptr, zArg uintptr if zValue == uintptr(0) { return 0 } - *(*int8)(unsafe.Pointer((p + 64 /* &.zErr */) + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer((p + 64 /* &.zErr */))) = int8(0) if *(*uintptr)(unsafe.Pointer(pzVal)) != 0 { csv_errmsg(tls, p, ts+4189 /* "more than one '%..." */, libc.VaList(bp, zParam)) return 1 @@ -17712,13 +17406,13 @@ func csv_boolean(tls *libc.TLS, z uintptr) int32 { /* csv.c:421:12: */ if (((sqlite3.Xsqlite3_stricmp(tls, ts+4218 /* "yes" */, z) == 0) || (sqlite3.Xsqlite3_stricmp(tls, ts+4222 /* "on" */, z) == 0)) || (sqlite3.Xsqlite3_stricmp(tls, ts+4225 /* "true" */, z) == 0)) || - ((int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '1') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == 0)) { + ((int32(*(*int8)(unsafe.Pointer(z))) == '1') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == 0)) { return 1 } if (((sqlite3.Xsqlite3_stricmp(tls, ts+4230 /* "no" */, z) == 0) || (sqlite3.Xsqlite3_stricmp(tls, ts+4233 /* "off" */, z) == 0)) || (sqlite3.Xsqlite3_stricmp(tls, ts+4237 /* "false" */, z) == 0)) || - ((int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '0') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == 0)) { + ((int32(*(*int8)(unsafe.Pointer(z))) == '0') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == 0)) { return 0 } return -1 @@ -17735,11 +17429,11 @@ func csv_boolean_parameter(tls *libc.TLS, zTag uintptr, nTag int32, z uintptr, p return 0 } z = csv_skip_whitespace(tls, (z + uintptr(nTag))) - if int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(z))) == 0 { *(*int32)(unsafe.Pointer(pValue)) = 1 return 1 } - if int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) != '=' { + if int32(*(*int8)(unsafe.Pointer(z))) != '=' { return 0 } z = csv_skip_whitespace(tls, (z + uintptr(1))) @@ -17792,7 +17486,7 @@ func csvtabConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin var iCol int32 pNew = uintptr(0) bHeader = -1 - rc = 0 + rc = SQLITE_OK tstFlags = 0 nCol = -99 // Parameter values @@ -17825,7 +17519,7 @@ __6: if !(uint64(j) < (uint64(unsafe.Sizeof(azParam)) / uint64(unsafe.Sizeof(uintptr(0))))) { goto __8 } - if !(*(*int8)(unsafe.Pointer((bp + 80 /* &sRdr */ + 64 /* &.zErr */) + uintptr(0))) != 0) { + if !(*(*int8)(unsafe.Pointer((bp + 80 /* &sRdr */ + 64 /* &.zErr */))) != 0) { goto __10 } goto csvtab_connect_error @@ -17890,7 +17584,7 @@ __2: goto __3 __3: ; - if !((libc.Bool32((*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(0)*8))) == uintptr(0))) == (libc.Bool32((*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(1)*8))) == uintptr(0)))) { + 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)))) { goto __20 } csv_errmsg(tls, bp+80 /* &sRdr */, ts+4386 /* "must specify eit..." */, 0) @@ -17899,7 +17593,7 @@ __20: ; if !(((nCol <= 0) || (bHeader == 1)) && - (csv_reader_open(tls, bp+80 /* &sRdr */, *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(0)*8)), *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(1)*8))) != 0)) { + (csv_reader_open(tls, bp+80 /* &sRdr */, *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */)), *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 1*8))) != 0)) { goto __21 } goto csvtab_connect_error @@ -17914,7 +17608,7 @@ __21: __22: ; libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(CsvTable{}))) - if !((*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(2)*8))) == uintptr(0)) { + if !((*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 2*8))) == uintptr(0)) { goto __23 } pStr = sqlite3.Xsqlite3_str_new(tls, uintptr(0)) @@ -17996,8 +17690,8 @@ __30: ; (*CsvTable)(unsafe.Pointer(pNew)).FnCol = nCol sqlite3.Xsqlite3_str_appendf(tls, pStr, ts+489 /* ")" */, 0) - (*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(2)*8))) = sqlite3.Xsqlite3_str_finish(tls, pStr) - if !((*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(2)*8))) == uintptr(0)) { + (*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 2*8))) = sqlite3.Xsqlite3_str_finish(tls, pStr) + if !((*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 2*8))) == uintptr(0)) { goto __42 } goto csvtab_connect_oom @@ -18026,10 +17720,10 @@ __44: ; __24: ; - (*CsvTable)(unsafe.Pointer(pNew)).FzFilename = *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(0)*8)) - (*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(0)*8))) = uintptr(0) - (*CsvTable)(unsafe.Pointer(pNew)).FzData = *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(1)*8)) - (*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(1)*8))) = uintptr(0) + (*CsvTable)(unsafe.Pointer(pNew)).FzFilename = *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */)) + (*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */))) = uintptr(0) + (*CsvTable)(unsafe.Pointer(pNew)).FzData = *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 1*8)) + (*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 1*8))) = uintptr(0) (*CsvTable)(unsafe.Pointer(pNew)).FtstFlags = uint32(tstFlags) if !(bHeader != 1) { goto __48 @@ -18049,11 +17743,11 @@ __51: __49: ; csv_reader_reset(tls, bp+80 /* &sRdr */) - rc = sqlite3.Xsqlite3_declare_vtab(tls, db, *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(2)*8))) + rc = sqlite3.Xsqlite3_declare_vtab(tls, db, *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 2*8))) if !(rc != 0) { goto __52 } - csv_errmsg(tls, bp+80 /* &sRdr */, ts+4463 /* "bad schema: '%s'..." */, libc.VaList(bp+56, *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(2)*8)), sqlite3.Xsqlite3_errmsg(tls, db))) + csv_errmsg(tls, bp+80 /* &sRdr */, ts+4463 /* "bad schema: '%s'..." */, libc.VaList(bp+56, *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 2*8)), sqlite3.Xsqlite3_errmsg(tls, db))) goto csvtab_connect_error __52: ; @@ -18077,11 +17771,11 @@ __55: // TEMP namespace, so they should still be usable from within TEMP // views, so there shouldn't be a serious loss of functionality by // prohibiting the use of this vtab from persistent triggers and views. - sqlite3.Xsqlite3_vtab_config(tls, db, 3, 0) - return 0 + sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_DIRECTONLY, 0) + return SQLITE_OK csvtab_connect_oom: - rc = 7 + rc = SQLITE_NOMEM csv_errmsg(tls, bp+80 /* &sRdr */, ts+1929 /* "out of memory" */, 0) csvtab_connect_error: @@ -18104,7 +17798,7 @@ __58: goto __59 __59: ; - if !(*(*int8)(unsafe.Pointer((bp + 80 /* &sRdr */ + 64 /* &.zErr */) + uintptr(0))) != 0) { + if !(*(*int8)(unsafe.Pointer((bp + 80 /* &sRdr */ + 64 /* &.zErr */))) != 0) { goto __60 } sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(pzErr))) @@ -18112,10 +17806,10 @@ __59: __60: ; csv_reader_reset(tls, bp+80 /* &sRdr */) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __61 } - rc = 1 + rc = SQLITE_ERROR __61: ; return rc @@ -18148,7 +17842,7 @@ func csvtabClose(tls *libc.TLS, cur uintptr) int32 { /* csv.c:694:12: */ csvtabCursorRowReset(tls, pCur) csv_reader_reset(tls, (pCur + 8 /* &.rdr */)) sqlite3.Xsqlite3_free(tls, cur) - return 0 + return SQLITE_OK } // Constructor for a new CsvTable cursor object. @@ -18159,17 +17853,17 @@ func csvtabOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* csv.c:705 nByte = (uint64(unsafe.Sizeof(CsvCursor{})) + ((uint64(unsafe.Sizeof(uintptr(0))) + uint64(unsafe.Sizeof(int32(0)))) * uint64((*CsvTable)(unsafe.Pointer(pTab)).FnCol))) pCur = sqlite3.Xsqlite3_malloc64(tls, uint64(nByte)) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, nByte) - (*CsvCursor)(unsafe.Pointer(pCur)).FazVal = (pCur + uintptr(1)*296) + (*CsvCursor)(unsafe.Pointer(pCur)).FazVal = (pCur + 1*296) (*CsvCursor)(unsafe.Pointer(pCur)).FaLen = ((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr((*CsvTable)(unsafe.Pointer(pTab)).FnCol)*8) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) if csv_reader_open(tls, (pCur+8 /* &.rdr */), (*CsvTable)(unsafe.Pointer(pTab)).FzFilename, (*CsvTable)(unsafe.Pointer(pTab)).FzData) != 0 { csv_xfer_error(tls, pTab, (pCur + 8 /* &.rdr */)) - return 1 + return SQLITE_ERROR } - return 0 + return SQLITE_OK } // Advance a CsvCursor to its next row of input. @@ -18210,7 +17904,7 @@ func csvtabNext(tls *libc.TLS, cur uintptr) int32 { /* csv.c:728:12: */ i++ } } - return 0 + return SQLITE_OK } // Return values of columns for the row at which the CsvCursor @@ -18221,14 +17915,14 @@ func csvtabColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* c if ((i >= 0) && (i < (*CsvTable)(unsafe.Pointer(pTab)).FnCol)) && (*(*uintptr)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr(i)*8)) != uintptr(0)) { sqlite3.Xsqlite3_result_text(tls, ctx, *(*uintptr)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr(i)*8)), -1, uintptr(0)) } - return 0 + return SQLITE_OK } // Return the rowid for the current row. func csvtabRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* csv.c:787:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*CsvCursor)(unsafe.Pointer(pCur)).FiRowid - return 0 + return SQLITE_OK } // Return TRUE if the cursor has been moved off of the last @@ -18248,7 +17942,7 @@ func csvtabFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp (*CsvCursor)(unsafe.Pointer(pCur)).Frdr.FiIn = size_t((*CsvTable)(unsafe.Pointer(pTab)).FiStart) } else { - libc.Xfseek(tls, (*CsvCursor)(unsafe.Pointer(pCur)).Frdr.Fin, (*CsvTable)(unsafe.Pointer(pTab)).FiStart, 0) + libc.Xfseek(tls, (*CsvCursor)(unsafe.Pointer(pCur)).Frdr.Fin, (*CsvTable)(unsafe.Pointer(pTab)).FiStart, SEEK_SET) (*CsvCursor)(unsafe.Pointer(pCur)).Frdr.FiIn = uint64(0) (*CsvCursor)(unsafe.Pointer(pCur)).Frdr.FnIn = uint64(0) } @@ -18261,7 +17955,7 @@ func csvtabFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp // for testing certain kinds of virtual table behavior. func csvtabBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* csv.c:833:12: */ (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1000000) - if ((*CsvTable)(unsafe.Pointer((tab))).FtstFlags & uint32(0x0001)) != uint32(0) { + if ((*CsvTable)(unsafe.Pointer((tab))).FtstFlags & CSVTEST_FIDX) != uint32(0) { // The usual (and sensible) case is to always do a full table scan. // The code in this branch only runs when testflags=1. This code // generates an artifical and unrealistic plan which is useful @@ -18280,107 +17974,54 @@ func csvtabBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* cs continue } op = (*sqlite3_index_constraint)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12)).Fop - if ((int32(op) == 2) || - (int32(op) == 65)) || - (int32(op) == 66) { + if ((int32(op) == SQLITE_INDEX_CONSTRAINT_EQ) || + (int32(op) == SQLITE_INDEX_CONSTRAINT_LIKE)) || + (int32(op) == SQLITE_INDEX_CONSTRAINT_GLOB) { (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(10) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(nConst)*8)).FargvIndex = (nConst + 1) nConst++ } } } - return 0 + return SQLITE_OK } -var CsvModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - 0, - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename +var CsvModule = sqlite3_module{ // iVersion + FxCreate: 0, // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDisconnect + FxDestroy: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRename } /* csv.c:872:23 */ // For virtual table testing, make a version of the CSV virtual table // available that has an xUpdate function. But the xUpdate always returns // SQLITE_READONLY since the CSV file is not really writable. func csvtabUpdate(tls *libc.TLS, p uintptr, n int32, v uintptr, x uintptr) int32 { /* csv.c:901:12: */ - return 8 + return SQLITE_READONLY } -var CsvModuleFauxWrite = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - 0, - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename +var CsvModuleFauxWrite = sqlite3_module{ // iVersion + FxCreate: 0, // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDisconnect + FxDestroy: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRowid - read data + FxUpdate: 0, // xRename } /* csv.c:904:23 */ // This routine is called when the extension is loaded. The new @@ -18391,7 +18032,7 @@ func sqlite3_csv_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) _ = pApi rc = sqlite3.Xsqlite3_create_module(tls, db, ts+4506 /* "csv" */, uintptr(unsafe.Pointer(&CsvModule)), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_module(tls, db, ts+4510 /* "csv_wr" */, uintptr(unsafe.Pointer(&CsvModuleFauxWrite)), uintptr(0)) } return rc @@ -18504,7 +18145,7 @@ __1: zIn = zAlt goto __3 __2: - if !(sqlite3.Xsqlite3_value_type(tls, pIn) == 5) { + if !(sqlite3.Xsqlite3_value_type(tls, pIn) == SQLITE_NULL) { goto __4 } (*Decimal)(unsafe.Pointer(p)).Fa = uintptr(0) @@ -18747,11 +18388,11 @@ func decimal_result(tls *libc.TLS, pCtx uintptr, p uintptr) { /* decimal.c:183:1 return } i = 0 - if ((*Decimal)(unsafe.Pointer(p)).FnDigit == 0) || (((*Decimal)(unsafe.Pointer(p)).FnDigit == 1) && (int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(p)).Fa + uintptr(0)))) == 0)) { + if ((*Decimal)(unsafe.Pointer(p)).FnDigit == 0) || (((*Decimal)(unsafe.Pointer(p)).FnDigit == 1) && (int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(p)).Fa))) == 0)) { (*Decimal)(unsafe.Pointer(p)).Fsign = int8(0) } if (*Decimal)(unsafe.Pointer(p)).Fsign != 0 { - *(*int8)(unsafe.Pointer(z + uintptr(0))) = int8('-') + *(*int8)(unsafe.Pointer(z)) = int8('-') i = 1 } n = ((*Decimal)(unsafe.Pointer(p)).FnDigit - (*Decimal)(unsafe.Pointer(p)).FnFrac) @@ -18783,7 +18424,7 @@ func decimal_result(tls *libc.TLS, pCtx uintptr, p uintptr) { /* decimal.c:183:1 // // Convert input X into decimal and then back into text func decimalFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* decimal.c:238:13: */ - var p uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), 0, uintptr(0)) + var p uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) _ = argc decimal_result(tls, context, p) decimal_free(tls, p) @@ -18842,14 +18483,14 @@ func decimalCmpFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { pB = uintptr(0) _ = argc - pA = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), 0, uintptr(0)) + pA = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) if !((pA == uintptr(0)) || ((*Decimal)(unsafe.Pointer(pA)).FisNull != 0)) { goto __1 } goto cmp_done __1: ; - pB = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), 0, uintptr(0)) + pB = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*8)), 0, uintptr(0)) if !((pB == uintptr(0)) || ((*Decimal)(unsafe.Pointer(pB)).FisNull != 0)) { goto __2 } @@ -18928,7 +18569,7 @@ func decimal_add(tls *libc.TLS, pA uintptr, pB uintptr) { /* decimal.c:345:13: * return } nSig = ((*Decimal)(unsafe.Pointer(pA)).FnDigit - (*Decimal)(unsafe.Pointer(pA)).FnFrac) - if (nSig != 0) && (int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(pA)).Fa + uintptr(0)))) == 0) { + if (nSig != 0) && (int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(pA)).Fa))) == 0) { nSig-- } if nSig < ((*Decimal)(unsafe.Pointer(pB)).FnDigit - (*Decimal)(unsafe.Pointer(pB)).FnFrac) { @@ -19006,8 +18647,8 @@ func decimalCollFunc(tls *libc.TLS, notUsed uintptr, nKey1 int32, pKey1 uintptr, // // Return the sum or difference of X and Y. func decimalAddFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* decimal.c:441:13: */ - var pA uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), 0, uintptr(0)) - var pB uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), 0, uintptr(0)) + var pA uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) + var pB uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*8)), 0, uintptr(0)) _ = argc decimal_add(tls, pA, pB) decimal_result(tls, context, pA) @@ -19016,8 +18657,8 @@ func decimalAddFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { } func decimalSubFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* decimal.c:454:13: */ - var pA uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), 0, uintptr(0)) - var pB uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), 0, uintptr(0)) + var pA uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) + var pB uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*8)), 0, uintptr(0)) _ = argc if pB == uintptr(0) { return @@ -19047,15 +18688,15 @@ func decimalSumStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { if (*Decimal)(unsafe.Pointer(p)).Fa == uintptr(0) { (*Decimal)(unsafe.Pointer(p)).Foom = int8(1) } else { - *(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(p)).Fa + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(p)).Fa)) = int8(0) } (*Decimal)(unsafe.Pointer(p)).FnDigit = 1 (*Decimal)(unsafe.Pointer(p)).FnFrac = 0 } - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } - pArg = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), 0, uintptr(0)) + pArg = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) decimal_add(tls, p, pArg) decimal_free(tls, pArg) } @@ -19068,10 +18709,10 @@ func decimalSumInverse(tls *libc.TLS, context uintptr, argc int32, argv uintptr) if p == uintptr(0) { return } - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } - pArg = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), 0, uintptr(0)) + pArg = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) if pArg != 0 { (*Decimal)(unsafe.Pointer(pArg)).Fsign = libc.BoolInt8(!((*Decimal)(unsafe.Pointer(pArg)).Fsign != 0)) } @@ -19115,8 +18756,8 @@ func decimalMulFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { var f int8 var carry int32 var x int32 - pA = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), 0, uintptr(0)) - pB = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), 0, uintptr(0)) + pA = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) + pB = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*8)), 0, uintptr(0)) acc = uintptr(0) _ = argc if !((((((pA == uintptr(0)) || ((*Decimal)(unsafe.Pointer(pA)).Foom != 0)) || ((*Decimal)(unsafe.Pointer(pA)).FisNull != 0)) || @@ -19200,7 +18841,7 @@ mul_end: } func sqlite3_decimal_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* decimal.c:596:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var i uint32 _ = pzErrMsg // Unused parameter @@ -19211,14 +18852,14 @@ func sqlite3_decimal_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uint FnArg int32 _ [4]byte FxFunc uintptr - }{})))) && (rc == 0); i++ { + }{})))) && (rc == SQLITE_OK); i++ { rc = sqlite3.Xsqlite3_create_function(tls, db, aFunc[i].FzFuncName, aFunc[i].FnArg, - ((1 | 0x000200000) | 0x000000800), + ((SQLITE_UTF8 | SQLITE_INNOCUOUS) | SQLITE_DETERMINISTIC), uintptr(0), aFunc[i].FxFunc, uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_window_function(tls, db, ts+4517 /* "decimal_sum" */, 1, - ((1 | 0x000200000) | 0x000000800), uintptr(0), + ((SQLITE_UTF8 | SQLITE_INNOCUOUS) | SQLITE_DETERMINISTIC), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{decimalSumStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{decimalSumFinalize})), @@ -19226,8 +18867,8 @@ func sqlite3_decimal_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uint f func(*libc.TLS, uintptr, int32, uintptr) }{decimalSumInverse})), uintptr(0)) } - if rc == 0 { - rc = sqlite3.Xsqlite3_create_collation(tls, db, ts+4529 /* "decimal" */, 1, + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_collation(tls, db, ts+4529 /* "decimal" */, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{decimalCollFunc}))) @@ -19241,26 +18882,11 @@ var aFunc = [5]struct { _ [4]byte FxFunc uintptr }{ - { - FzFuncName: ts + 4529, /* "decimal" */ - FnArg: 1, - FxFunc: 0}, - { - FzFuncName: ts + 4537, /* "decimal_cmp" */ - FnArg: 2, - FxFunc: 0}, - { - FzFuncName: ts + 4549, /* "decimal_add" */ - FnArg: 2, - FxFunc: 0}, - { - FzFuncName: ts + 4561, /* "decimal_sub" */ - FnArg: 2, - FxFunc: 0}, - { - FzFuncName: ts + 4573, /* "decimal_mul" */ - FnArg: 2, - FxFunc: 0}, + {FzFuncName: ts + 4529 /* "decimal" */, FnArg: 1, FxFunc: 0}, + {FzFuncName: ts + 4537 /* "decimal_cmp" */, FnArg: 2, FxFunc: 0}, + {FzFuncName: ts + 4549 /* "decimal_add" */, FnArg: 2, FxFunc: 0}, + {FzFuncName: ts + 4561 /* "decimal_sub" */, FnArg: 2, FxFunc: 0}, + {FzFuncName: ts + 4573 /* "decimal_mul" */, FnArg: 2, FxFunc: 0}, } /* decimal.c:606:5 */ // Structure used to accumulate the output @@ -19332,12 +18958,12 @@ func sqlEvalFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* libc.Xmemset(tls, bp /* &x */, 0, uint64(unsafe.Sizeof(EvalResult{}))) (*EvalResult)(unsafe.Pointer(bp /* &x */)).FzSep = ts + 4585 /* " " */ - zSql = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zSql = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zSql == uintptr(0) { return } if argc > 1 { - (*EvalResult)(unsafe.Pointer(bp /* &x */)).FzSep = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + (*EvalResult)(unsafe.Pointer(bp /* &x */)).FzSep = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if (*EvalResult)(unsafe.Pointer(bp /* &x */)).FzSep == uintptr(0) { return } @@ -19347,7 +18973,7 @@ func sqlEvalFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* rc = sqlite3.Xsqlite3_exec(tls, db, zSql, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 }{callback})), bp /* &x */, bp+40 /* &zErr */) - if rc != 0 { + if rc != SQLITE_OK { sqlite3.Xsqlite3_result_error(tls, context, *(*uintptr)(unsafe.Pointer(bp + 40 /* zErr */)), -1) sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* zErr */))) } else if (*EvalResult)(unsafe.Pointer(bp /* &x */)).FzSep == uintptr(0) { @@ -19359,18 +18985,18 @@ func sqlEvalFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* } func sqlite3_eval_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* eval.c:108:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi _ = pzErrMsg // Unused parameter rc = sqlite3.Xsqlite3_create_function(tls, db, ts+4587 /* "eval" */, 1, - (1 | 0x000080000), uintptr(0), + (SQLITE_UTF8 | SQLITE_DIRECTONLY), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{sqlEvalFunc})), uintptr(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_function(tls, db, ts+4587 /* "eval" */, 2, - (1 | 0x000080000), uintptr(0), + (SQLITE_UTF8 | SQLITE_DIRECTONLY), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{sqlEvalFunc})), uintptr(0), uintptr(0)) @@ -19425,11 +19051,11 @@ func explainConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv ui rc = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+4592 /* "CREATE TABLE x(a..." */) - if rc == 0 { + if rc == SQLITE_OK { pNew = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(explain_vtab{}))) *(*uintptr)(unsafe.Pointer(ppVtab)) = pNew if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(explain_vtab{}))) (*explain_vtab)(unsafe.Pointer(pNew)).Fdb = db @@ -19440,7 +19066,7 @@ func explainConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv ui // This method is the destructor for explain_cursor objects. func explainDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* explain.c:107:12: */ sqlite3.Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // Constructor for a new explain_cursor object. @@ -19448,12 +19074,12 @@ func explainOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* explain. var pCur uintptr pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(explain_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(explain_cursor{}))) (*explain_cursor)(unsafe.Pointer(pCur)).Fdb = (*explain_vtab)(unsafe.Pointer(p)).Fdb *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Destructor for a explain_cursor. @@ -19462,29 +19088,29 @@ func explainClose(tls *libc.TLS, cur uintptr) int32 { /* explain.c:128:12: */ sqlite3.Xsqlite3_finalize(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain) sqlite3.Xsqlite3_free(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FzSql) sqlite3.Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } // Advance a explain_cursor to its next row of output. func explainNext(tls *libc.TLS, cur uintptr) int32 { /* explain.c:140:12: */ var pCur uintptr = cur (*explain_cursor)(unsafe.Pointer(pCur)).Frc = sqlite3.Xsqlite3_step(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain) - if ((*explain_cursor)(unsafe.Pointer(pCur)).Frc != 101) && ((*explain_cursor)(unsafe.Pointer(pCur)).Frc != 100) { + if ((*explain_cursor)(unsafe.Pointer(pCur)).Frc != SQLITE_DONE) && ((*explain_cursor)(unsafe.Pointer(pCur)).Frc != SQLITE_ROW) { return (*explain_cursor)(unsafe.Pointer(pCur)).Frc } - return 0 + return SQLITE_OK } // Return values of columns for the row at which the explain_cursor // is currently pointing. func explainColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* explain.c:151:12: */ var pCur uintptr = cur - if i == 8 { + if i == EXPLN_COLUMN_SQL { sqlite3.Xsqlite3_result_text(tls, ctx, (*explain_cursor)(unsafe.Pointer(pCur)).FzSql, -1, libc.UintptrFromInt32(-1)) } else { sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain, i)) } - return 0 + return SQLITE_OK } // Return the rowid for the current row. In this implementation, the @@ -19492,14 +19118,14 @@ func explainColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* func explainRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* explain.c:169:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_column_int64(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain, 0) - return 0 + return SQLITE_OK } // Return TRUE if the cursor has been moved off of the last // row of output. func explainEof(tls *libc.TLS, cur uintptr) int32 { /* explain.c:179:12: */ var pCur uintptr = cur - return (libc.Bool32((*explain_cursor)(unsafe.Pointer(pCur)).Frc != 100)) + return (libc.Bool32((*explain_cursor)(unsafe.Pointer(pCur)).Frc != SQLITE_ROW)) } // This method is called to "rewind" the explain_cursor object back @@ -19517,17 +19143,17 @@ func explainFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint var rc int32 sqlite3.Xsqlite3_finalize(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain) (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain = uintptr(0) - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) != 3 { - (*explain_cursor)(unsafe.Pointer(pCur)).Frc = 101 - return 0 + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) != SQLITE_TEXT { + (*explain_cursor)(unsafe.Pointer(pCur)).Frc = SQLITE_DONE + return SQLITE_OK } sqlite3.Xsqlite3_free(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FzSql) - (*explain_cursor)(unsafe.Pointer(pCur)).FzSql = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) + (*explain_cursor)(unsafe.Pointer(pCur)).FzSql = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))))) if (*explain_cursor)(unsafe.Pointer(pCur)).FzSql != 0 { zSql = sqlite3.Xsqlite3_mprintf(tls, ts+4654 /* "EXPLAIN %s" */, libc.VaList(bp+8, (*explain_cursor)(unsafe.Pointer(pCur)).FzSql)) } if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = sqlite3.Xsqlite3_prepare_v2(tls, (*explain_cursor)(unsafe.Pointer(pCur)).Fdb, zSql, -1, (pCur + 24 /* &.pExplain */), uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) @@ -19539,8 +19165,8 @@ func explainFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint (*explain_cursor)(unsafe.Pointer(pCur)).FzSql = uintptr(0) } else { (*explain_cursor)(unsafe.Pointer(pCur)).Frc = sqlite3.Xsqlite3_step(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain) - if ((*explain_cursor)(unsafe.Pointer(pCur)).Frc == 101) || ((*explain_cursor)(unsafe.Pointer(pCur)).Frc == 100) { - rc = 0 + if ((*explain_cursor)(unsafe.Pointer(pCur)).Frc == SQLITE_DONE) || ((*explain_cursor)(unsafe.Pointer(pCur)).Frc == SQLITE_ROW) { + rc = SQLITE_OK } else { rc = (*explain_cursor)(unsafe.Pointer(pCur)).Frc } @@ -19560,12 +19186,12 @@ func explainBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* e (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(500) for i = 0; i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; i++ { var p uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12) - if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn != 8 { + if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn != EXPLN_COLUMN_SQL { continue } if !(int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) != 0) { unusable = 1 - } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2 { + } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ { idx = i } } @@ -19578,71 +19204,34 @@ func explainBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* e } else if unusable != 0 { // There are unusable constraints against the SQL column. Do not allow // this plan to continue forward. - return 19 + return SQLITE_CONSTRAINT } - return 0 + return SQLITE_OK } // This following structure defines all the methods for the // explain virtual table. -var explainModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - uintptr(0), - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - uintptr(0), - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var explainModule = sqlite3_module{ // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xShadowName } /* explain.c:271:23 */ func sqlite3ExplainVtabInit(tls *libc.TLS, db uintptr) int32 { /* explain.c:300:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK rc = sqlite3.Xsqlite3_create_module(tls, db, ts+4665 /* "explain" */, uintptr(unsafe.Pointer(&explainModule)), uintptr(0)) return rc } func sqlite3_explain_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* explain.c:311:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi rc = sqlite3ExplainVtabInit(tls, db) @@ -20684,13 +20273,13 @@ func readFileContents(tls *libc.TLS, ctx uintptr, zName uintptr) { /* fileio.c:1 // File does not exist or is unreadable. Leave the result set to NULL. return } - libc.Xfseek(tls, in, int64(0), 2) + libc.Xfseek(tls, in, int64(0), SEEK_END) nIn = sqlite3_int64(libc.Xftell(tls, in)) libc.Xrewind(tls, in) db = sqlite3.Xsqlite3_context_db_handle(tls, ctx) - mxBlob = sqlite3.Xsqlite3_limit(tls, db, 0, -1) + mxBlob = sqlite3.Xsqlite3_limit(tls, db, SQLITE_LIMIT_LENGTH, -1) if nIn > sqlite3_int64(mxBlob) { - sqlite3.Xsqlite3_result_error_code(tls, ctx, 18) + sqlite3.Xsqlite3_result_error_code(tls, ctx, SQLITE_TOOBIG) libc.Xfclose(tls, in) return } @@ -20708,7 +20297,7 @@ func readFileContents(tls *libc.TLS, ctx uintptr, zName uintptr) { /* fileio.c:1 if nIn == sqlite3_int64(libc.Xfread(tls, pBuf, uint64(1), size_t(nIn), in)) { sqlite3.Xsqlite3_result_blob64(tls, ctx, pBuf, uint64(nIn), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) } else { - sqlite3.Xsqlite3_result_error_code(tls, ctx, 10) + sqlite3.Xsqlite3_result_error_code(tls, ctx, SQLITE_IOERR) sqlite3.Xsqlite3_free(tls, pBuf) } libc.Xfclose(tls, in) @@ -20720,7 +20309,7 @@ func readFileContents(tls *libc.TLS, ctx uintptr, zName uintptr) { /* fileio.c:1 func readfileFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* fileio.c:175:13: */ var zName uintptr _ = argc // Unused parameter - zName = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zName = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zName == uintptr(0) { return } @@ -20768,15 +20357,15 @@ func makeDirectory(tls *libc.TLS, zFile uintptr) int32 { /* fileio.c:303:12: */ defer tls.Free(152) var zCopy uintptr = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zFile)) - var rc int32 = 0 + var rc int32 = SQLITE_OK if zCopy == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var nCopy int32 = int32(libc.Xstrlen(tls, zCopy)) var i int32 = 1 - for rc == 0 { + for rc == SQLITE_OK { // var sStat stat at bp+8, 144 var rc2 int32 @@ -20791,11 +20380,11 @@ func makeDirectory(tls *libc.TLS, zFile uintptr) int32 { /* fileio.c:303:12: */ rc2 = fileStat(tls, zCopy, bp+8 /* &sStat */) if rc2 != 0 { if libc.Xmkdir(tls, zCopy, uint32(0777)) != 0 { - rc = 1 + rc = SQLITE_ERROR } } else { if !((((*stat)(unsafe.Pointer(bp + 8 /* &sStat */)).Fst_mode) & uint32(0170000)) == (uint32(0040000))) { - rc = 1 + rc = SQLITE_ERROR } } *(*int8)(unsafe.Pointer(zCopy + uintptr(i))) = int8('/') @@ -20828,7 +20417,7 @@ func writeFile(tls *libc.TLS, pCtx uintptr, zFile uintptr, pData uintptr, mode m // to do so using chmod(), it is not an error. // var sStat stat at bp, 144 - if ((((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) != 17) || + if ((((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) != EEXIST) || (0 != fileStat(tls, zFile, bp /* &sStat */))) || !((((*stat)(unsafe.Pointer(bp /* &sStat */)).Fst_mode) & uint32(0170000)) == (uint32(0040000)))) || ((((*stat)(unsafe.Pointer(bp /* &sStat */)).Fst_mode & uint32(0777)) != (mode & mode_t(0777))) && (0 != libc.Xchmod(tls, zFile, (mode&mode_t(0777))))) { @@ -20866,9 +20455,9 @@ func writeFile(tls *libc.TLS, pCtx uintptr, zFile uintptr, pData uintptr, mode m // Legacy unix // var times [2]timeval at bp+144, 32 - (*timeval)(unsafe.Pointer(bp + 144 /* × */ + uintptr(0)*16)).Ftv_usec = libc.AssignPtrInt64(bp+144 /* × */ +uintptr(1)*16+8 /* &.tv_usec */, int64(0)) - (*timeval)(unsafe.Pointer(bp + 144 /* × */ + uintptr(0)*16)).Ftv_sec = libc.Xtime(tls, uintptr(0)) - (*timeval)(unsafe.Pointer(bp + 144 /* × */ + uintptr(1)*16)).Ftv_sec = int64(mtime) + (*timeval)(unsafe.Pointer(bp + 144 /* × */)).Ftv_usec = libc.AssignPtrInt64(bp+144 /* × */ +1*16+8 /* &.tv_usec */, int64(0)) + (*timeval)(unsafe.Pointer(bp + 144 /* × */)).Ftv_sec = libc.Xtime(tls, uintptr(0)) + (*timeval)(unsafe.Pointer(bp + 144 /* × */ + 1*16)).Ftv_sec = int64(mtime) if libc.Xutimes(tls, zFile, bp+144 /* ×[0] */) != 0 { return 1 } @@ -20894,21 +20483,21 @@ func writefileFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { / return } - zFile = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zFile = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zFile == uintptr(0) { return } if argc >= 3 { - mode = mode_t(sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + mode = mode_t(sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) } if argc == 4 { - mtime = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) + mtime = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) } - res = writeFile(tls, context, zFile, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), mode, mtime) - if (res == 1) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 2) { - if makeDirectory(tls, zFile) == 0 { - res = writeFile(tls, context, zFile, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), mode, mtime) + res = writeFile(tls, context, zFile, *(*uintptr)(unsafe.Pointer(argv + 1*8)), mode, mtime) + if (res == 1) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == ENOENT) { + if makeDirectory(tls, zFile) == SQLITE_OK { + res = writeFile(tls, context, zFile, *(*uintptr)(unsafe.Pointer(argv + 1*8)), mode, mtime) } } @@ -20932,42 +20521,42 @@ func lsModeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* f defer tls.Free(16) var i int32 - var iMode int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var iMode int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) // var z [16]int8 at bp, 16 _ = argc if ((iMode) & 0170000) == (0120000) { - *(*int8)(unsafe.Pointer(bp /* &z[0] */ + uintptr(0))) = int8('l') + *(*int8)(unsafe.Pointer(bp /* &z[0] */)) = int8('l') } else if ((iMode) & 0170000) == (0100000) { - *(*int8)(unsafe.Pointer(bp /* &z[0] */ + uintptr(0))) = int8('-') + *(*int8)(unsafe.Pointer(bp /* &z[0] */)) = int8('-') } else if ((iMode) & 0170000) == (0040000) { - *(*int8)(unsafe.Pointer(bp /* &z[0] */ + uintptr(0))) = int8('d') + *(*int8)(unsafe.Pointer(bp /* &z[0] */)) = int8('d') } else { - *(*int8)(unsafe.Pointer(bp /* &z[0] */ + uintptr(0))) = int8('?') + *(*int8)(unsafe.Pointer(bp /* &z[0] */)) = int8('?') } for i = 0; i < 3; i++ { var m int32 = (iMode >> ((2 - i) * 3)) var a uintptr = (bp /* &z */ + uintptr((1 + (i * 3)))) - *(*int8)(unsafe.Pointer(a + uintptr(0))) = func() int8 { + *(*int8)(unsafe.Pointer(a)) = func() int8 { if (m & 0x4) != 0 { return int8('r') } return int8('-') }() - *(*int8)(unsafe.Pointer(a + uintptr(1))) = func() int8 { + *(*int8)(unsafe.Pointer(a + 1)) = func() int8 { if (m & 0x2) != 0 { return int8('w') } return int8('-') }() - *(*int8)(unsafe.Pointer(a + uintptr(2))) = func() int8 { + *(*int8)(unsafe.Pointer(a + 2)) = func() int8 { if (m & 0x1) != 0 { return int8('x') } return int8('-') }() } - *(*int8)(unsafe.Pointer(bp /* &z[0] */ + uintptr(10))) = int8(0) + *(*int8)(unsafe.Pointer(bp /* &z[0] */ + 10)) = int8(0) sqlite3.Xsqlite3_result_text(tls, context, bp /* &z[0] */, -1, libc.UintptrFromInt32(-1)) } @@ -21032,13 +20621,13 @@ func fsdirConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uint _ = argv _ = pzErr rc = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+4811 /* "CREATE TABLE x(n..." */) - if rc == 0 { + if rc == SQLITE_OK { pNew = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(fsdir_tab{}))) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(fsdir_tab{}))) - sqlite3.Xsqlite3_vtab_config(tls, db, 3, 0) + sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_DIRECTONLY, 0) } *(*uintptr)(unsafe.Pointer(ppVtab)) = pNew return rc @@ -21047,7 +20636,7 @@ func fsdirConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uint // This method is the destructor for fsdir vtab objects. func fsdirDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* fileio.c:599:12: */ sqlite3.Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // Constructor for a new fsdir_cursor object. @@ -21056,12 +20645,12 @@ func fsdirOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* fileio.c:6 _ = p pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(fsdir_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(fsdir_cursor{}))) (*fsdir_cursor)(unsafe.Pointer(pCur)).FiLvl = -1 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Reset a cursor back to the state it was in when first returned @@ -21092,7 +20681,7 @@ func fsdirClose(tls *libc.TLS, cur uintptr) int32 { /* fileio.c:643:12: */ fsdirResetCursor(tls, pCur) sqlite3.Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } // Set the error message for the virtual table associated with cursor @@ -21123,7 +20712,7 @@ func fsdirNext(tls *libc.TLS, cur uintptr) int32 { /* fileio.c:666:12: */ var nByte sqlite3_int64 = (sqlite3_int64(uint64(nNew) * uint64(unsafe.Sizeof(FsdirLevel{})))) var aNew uintptr = sqlite3.Xsqlite3_realloc64(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FaLvl, uint64(nByte)) if aNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } 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)))) (*fsdir_cursor)(unsafe.Pointer(pCur)).FaLvl = aNew @@ -21137,7 +20726,7 @@ func fsdirNext(tls *libc.TLS, cur uintptr) int32 { /* fileio.c:666:12: */ (*FsdirLevel)(unsafe.Pointer(pLvl)).FpDir = libc.Xopendir(tls, (*FsdirLevel)(unsafe.Pointer(pLvl)).FzDir) if (*FsdirLevel)(unsafe.Pointer(pLvl)).FpDir == uintptr(0) { fsdirSetErrmsg(tls, pCur, ts+4871 /* "cannot read dire..." */, libc.VaList(bp, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath)) - return 1 + return SQLITE_ERROR } } @@ -21145,24 +20734,24 @@ func fsdirNext(tls *libc.TLS, cur uintptr) int32 { /* fileio.c:666:12: */ var pLvl uintptr = ((*fsdir_cursor)(unsafe.Pointer(pCur)).FaLvl + uintptr((*fsdir_cursor)(unsafe.Pointer(pCur)).FiLvl)*16) var pEntry uintptr = libc.Xreaddir(tls, (*FsdirLevel)(unsafe.Pointer(pLvl)).FpDir) if pEntry != 0 { - if int32(*(*int8)(unsafe.Pointer((pEntry + 19 /* &.d_name */) + uintptr(0)))) == '.' { - if (int32(*(*int8)(unsafe.Pointer((pEntry + 19 /* &.d_name */) + uintptr(1)))) == '.') && (int32(*(*int8)(unsafe.Pointer((pEntry + 19 /* &.d_name */) + uintptr(2)))) == 0) { + if int32(*(*int8)(unsafe.Pointer((pEntry + 19 /* &.d_name */)))) == '.' { + if (int32(*(*int8)(unsafe.Pointer((pEntry + 19 /* &.d_name */) + 1))) == '.') && (int32(*(*int8)(unsafe.Pointer((pEntry + 19 /* &.d_name */) + 2))) == 0) { continue } - if int32(*(*int8)(unsafe.Pointer((pEntry + 19 /* &.d_name */) + uintptr(1)))) == 0 { + if int32(*(*int8)(unsafe.Pointer((pEntry + 19 /* &.d_name */) + 1))) == 0 { continue } } sqlite3.Xsqlite3_free(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath) (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath = sqlite3.Xsqlite3_mprintf(tls, ts+4897 /* "%s/%s" */, libc.VaList(bp+8, (*FsdirLevel)(unsafe.Pointer(pLvl)).FzDir, pEntry+19 /* &.d_name */)) if (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath == uintptr(0) { - return 7 + return SQLITE_NOMEM } if fileLinkStat(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath, (pCur+40 /* &.sStat */)) != 0 { fsdirSetErrmsg(tls, pCur, ts+4903 /* "cannot stat file..." */, libc.VaList(bp+24, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath)) - return 1 + return SQLITE_ERROR } - return 0 + return SQLITE_OK } libc.Xclosedir(tls, (*FsdirLevel)(unsafe.Pointer(pLvl)).FpDir) sqlite3.Xsqlite3_free(tls, (*FsdirLevel)(unsafe.Pointer(pLvl)).FzDir) @@ -21174,7 +20763,7 @@ func fsdirNext(tls *libc.TLS, cur uintptr) int32 { /* fileio.c:666:12: */ // EOF sqlite3.Xsqlite3_free(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath) (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath = uintptr(0) - return 0 + return SQLITE_OK } // Return values of columns for the row at which the series_cursor @@ -21185,22 +20774,22 @@ func fsdirColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* fi var pCur uintptr = cur switch i { - case 0: + case FSDIR_COLUMN_NAME: { sqlite3.Xsqlite3_result_text(tls, ctx, ((*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath + uintptr((*fsdir_cursor)(unsafe.Pointer(pCur)).FnBase)), -1, libc.UintptrFromInt32(-1)) break } - case 1: + case FSDIR_COLUMN_MODE: sqlite3.Xsqlite3_result_int64(tls, ctx, int64((*fsdir_cursor)(unsafe.Pointer(pCur)).FsStat.Fst_mode)) break - case 2: + case FSDIR_COLUMN_MTIME: sqlite3.Xsqlite3_result_int64(tls, ctx, int64((*fsdir_cursor)(unsafe.Pointer(pCur)).FsStat.Fst_mtim.Ftv_sec)) break - case 3: + case FSDIR_COLUMN_DATA: { var m mode_t = (*fsdir_cursor)(unsafe.Pointer(pCur)).FsStat.Fst_mode if ((m) & mode_t(0170000)) == (mode_t(0040000)) { @@ -21224,7 +20813,7 @@ func fsdirColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* fi aBuf = sqlite3.Xsqlite3_malloc64(tls, uint64(nBuf)) if aBuf == uintptr(0) { sqlite3.Xsqlite3_result_error_nomem(tls, ctx) - return 7 + return SQLITE_NOMEM } } @@ -21238,7 +20827,7 @@ func fsdirColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* fi } fallthrough - case 4: + case FSDIR_COLUMN_PATH: fallthrough default: { @@ -21248,7 +20837,7 @@ func fsdirColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* fi } } - return 0 + return SQLITE_OK } // Return the rowid for the current row. In this implementation, the @@ -21257,7 +20846,7 @@ func fsdirColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* fi func fsdirRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* fileio.c:795:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*fsdir_cursor)(unsafe.Pointer(pCur)).FiRowid - return 0 + return SQLITE_OK } // Return TRUE if the cursor has been moved off of the last @@ -21282,16 +20871,16 @@ func fsdirFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, argc if idxNum == 0 { fsdirSetErrmsg(tls, pCur, ts+4924 /* "table function f..." */, 0) - return 1 + return SQLITE_ERROR } - zDir = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zDir = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zDir == uintptr(0) { fsdirSetErrmsg(tls, pCur, ts+4966 /* "table function f..." */, 0) - return 1 + return SQLITE_ERROR } if argc == 2 { - (*fsdir_cursor)(unsafe.Pointer(pCur)).FzBase = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + (*fsdir_cursor)(unsafe.Pointer(pCur)).FzBase = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) } if (*fsdir_cursor)(unsafe.Pointer(pCur)).FzBase != 0 { (*fsdir_cursor)(unsafe.Pointer(pCur)).FnBase = (int32(libc.Xstrlen(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzBase)) + 1) @@ -21301,14 +20890,14 @@ func fsdirFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, argc } if (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath == uintptr(0) { - return 7 + return SQLITE_NOMEM } if fileLinkStat(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath, (pCur+40 /* &.sStat */)) != 0 { fsdirSetErrmsg(tls, pCur, ts+4903 /* "cannot stat file..." */, libc.VaList(bp+24, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath)) - return 1 + return SQLITE_ERROR } - return 0 + return SQLITE_OK } // SQLite will invoke this method one or more times while planning a query @@ -21339,11 +20928,11 @@ __1: goto __3 } { - if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) != 2 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) != SQLITE_INDEX_CONSTRAINT_EQ { goto __2 } switch (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn { - case 4: + case FSDIR_COLUMN_PATH: { if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable != 0 { idxPath = i @@ -21354,7 +20943,7 @@ __1: break } - case 5: + case FSDIR_COLUMN_DIR: { if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable != 0 { idxDir = i @@ -21378,7 +20967,7 @@ __3: ; if (seenPath != 0) || (seenDir != 0) { // If input parameters are unusable, disallow this plan - return 19 + return SQLITE_CONSTRAINT } if idxPath < 0 { @@ -21400,7 +20989,7 @@ __3: } } - return 0 + return SQLITE_OK } // Register the "fsdir" virtual table. @@ -21410,80 +20999,43 @@ func fsdirRegister(tls *libc.TLS, db uintptr) int32 { /* fileio.c:938:12: */ return rc } -var fsdirModule1 = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - uintptr(0), - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - uintptr(0), - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var fsdirModule1 = sqlite3_module{ // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xShadowName } /* fileio.c:939:25 */ func sqlite3_fileio_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* fileio.c:976:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi _ = pzErrMsg // Unused parameter rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5022 /* "readfile" */, 1, - (1 | 0x000080000), uintptr(0), + (SQLITE_UTF8 | SQLITE_DIRECTONLY), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{readfileFunc})), uintptr(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5031 /* "writefile" */, -1, - (1 | 0x000080000), uintptr(0), + (SQLITE_UTF8 | SQLITE_DIRECTONLY), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{writefileFunc})), uintptr(0), uintptr(0)) } - if rc == 0 { - rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5041 /* "lsmode" */, 1, 1, uintptr(0), + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5041 /* "lsmode" */, 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{lsModeFunc})), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = fsdirRegister(tls, db) } return rc @@ -21611,7 +21163,7 @@ func fuzzerLoadOneRule(tls *libc.TLS, p uintptr, pStmt uintptr, ppRule uintptr, var zTo uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 2) var nCost int32 = sqlite3.Xsqlite3_column_int(tls, pStmt, 3) - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var nFrom int32 // Size of string zFrom, in bytes var nTo int32 // Size of string zTo, in bytes var pRule uintptr = uintptr(0) // New rule object to return @@ -21628,26 +21180,26 @@ func fuzzerLoadOneRule(tls *libc.TLS, p uintptr, pStmt uintptr, ppRule uintptr, // Silently ignore null transformations if libc.Xstrcmp(tls, zFrom, zTo) == 0 { *(*uintptr)(unsafe.Pointer(ppRule)) = uintptr(0) - return 0 + return SQLITE_OK } - if (nCost <= 0) || (nCost > 1000) { + if (nCost <= 0) || (nCost > FUZZER_MX_COST) { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3118, /* "%s: cost must be..." */ - libc.VaList(bp, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, 1000)) - rc = 1 - } else if (nFrom > 50) || (nTo > 50) { + libc.VaList(bp, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, FUZZER_MX_COST)) + rc = SQLITE_ERROR + } else if (nFrom > FUZZER_MX_LENGTH) || (nTo > FUZZER_MX_LENGTH) { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3152, /* "%s: maximum stri..." */ - libc.VaList(bp+16, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, 50)) - rc = 1 - } else if (iRuleset < int64(0)) || (iRuleset > int64(2147483647)) { + libc.VaList(bp+16, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, FUZZER_MX_LENGTH)) + rc = SQLITE_ERROR + } else if (iRuleset < int64(0)) || (iRuleset > FUZZER_MX_RULEID) { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+5048, /* "%s: ruleset must..." */ - libc.VaList(bp+32, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, 2147483647)) - rc = 1 + libc.VaList(bp+32, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, FUZZER_MX_RULEID)) + rc = SQLITE_ERROR } else { pRule = sqlite3.Xsqlite3_malloc64(tls, (uint64((uint64(unsafe.Sizeof(fuzzer_rule{})) + uint64(nFrom)) + uint64(nTo)))) if pRule == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, pRule, 0, uint64(unsafe.Sizeof(fuzzer_rule{}))) (*fuzzer_rule)(unsafe.Pointer(pRule)).FzFrom = pRule + 28 /* &.zTo */ @@ -21670,25 +21222,25 @@ func fuzzerLoadRules(tls *libc.TLS, db uintptr, p uintptr, zDb uintptr, zData ui bp := tls.Alloc(192) defer tls.Free(192) - var rc int32 = 0 // Return code - var zSql uintptr // SELECT used to read from rules table + var rc int32 = SQLITE_OK // Return code + var zSql uintptr // SELECT used to read from rules table var pHead uintptr = uintptr(0) zSql = sqlite3.Xsqlite3_mprintf(tls, ts+3221 /* "SELECT * FROM %Q..." */, libc.VaList(bp, zDb, zData)) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var rc2 int32 // finalize() return code *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)) = uintptr(0) rc = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+56 /* &pStmt */, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3241 /* "%s: %s" */, libc.VaList(bp+16, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, sqlite3.Xsqlite3_errmsg(tls, db))) } else if sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) != 4 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3248, /* "%s: %s has %d co..." */ libc.VaList(bp+32, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, zData, sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))))) - rc = 1 + rc = SQLITE_ERROR } else { - for (rc == 0) && (100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)))) { + for (rc == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)))) { *(*uintptr)(unsafe.Pointer(bp + 64 /* pRule */)) = uintptr(0) rc = fuzzerLoadOneRule(tls, p, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)), bp+64 /* &pRule */, pzErr) if *(*uintptr)(unsafe.Pointer(bp + 64 /* pRule */)) != 0 { @@ -21698,7 +21250,7 @@ func fuzzerLoadRules(tls *libc.TLS, db uintptr, p uintptr, zDb uintptr, zData ui } } rc2 = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } @@ -21707,7 +21259,7 @@ func fuzzerLoadRules(tls *libc.TLS, db uintptr, p uintptr, zDb uintptr, zData ui // All rules are now in a singly linked list starting at pHead. This // block sorts them by cost and then sets fuzzer_vtab.pRule to point to // point to the head of the sorted list. - if rc == 0 { + if rc == SQLITE_OK { var i uint32 var pX uintptr // var a [15]uintptr at bp+72, 120 @@ -21724,7 +21276,7 @@ func fuzzerLoadRules(tls *libc.TLS, db uintptr, p uintptr, zDb uintptr, zData ui } *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)) = fuzzerMergeRules(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)), pX) } - pX = *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(0)*8)) + pX = *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */)) i = uint32(1) for ; uint64(i) < (uint64(unsafe.Sizeof([15]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { pX = fuzzerMergeRules(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)), pX) @@ -21758,7 +21310,7 @@ func fuzzerDequote(tls *libc.TLS, zIn uintptr) uintptr { /* fuzzer.c:449:13: */ nIn = sqlite3_int64(libc.Xstrlen(tls, zIn)) zOut = sqlite3.Xsqlite3_malloc64(tls, (uint64(nIn + int64(1)))) if zOut != 0 { - var q int8 = *(*int8)(unsafe.Pointer(zIn + uintptr(0))) // Quote character (if any ) + var q int8 = *(*int8)(unsafe.Pointer(zIn)) // Quote character (if any ) if (((int32(q) != '[') && (int32(q) != '\'')) && (int32(q) != '"')) && (int32(q) != '`') { libc.Xmemcpy(tls, zOut, zIn, (size_t(nIn + int64(1)))) @@ -21791,7 +21343,7 @@ func fuzzerDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* fuzzer.c:478:12: sqlite3.Xsqlite3_free(tls, pRule) } sqlite3.Xsqlite3_free(tls, p) - return 0 + return SQLITE_OK } // xConnect/xCreate method for the fuzzer module. Arguments are: @@ -21804,45 +21356,45 @@ func fuzzerConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var pNew uintptr = uintptr(0) // New virtual table - var zModule uintptr = *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)) - var zDb uintptr = *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) + var zModule uintptr = *(*uintptr)(unsafe.Pointer(argv)) + var zDb uintptr = *(*uintptr)(unsafe.Pointer(argv + 1*8)) if argc != 4 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+5085 /* "%s: wrong number..." */, libc.VaList(bp, zModule)) - rc = 1 + rc = SQLITE_ERROR } else { var nModule sqlite3_int64 // Length of zModule, in bytes nModule = sqlite3_int64(libc.Xstrlen(tls, zModule)) pNew = sqlite3.Xsqlite3_malloc64(tls, ((uint64(unsafe.Sizeof(fuzzer_vtab{})) + uint64(nModule)) + uint64(1))) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var zTab uintptr // Dequoted name of fuzzer data table libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(fuzzer_vtab{}))) - (*fuzzer_vtab)(unsafe.Pointer(pNew)).FzClassName = (pNew + uintptr(1)*48) + (*fuzzer_vtab)(unsafe.Pointer(pNew)).FzClassName = (pNew + 1*48) libc.Xmemcpy(tls, (*fuzzer_vtab)(unsafe.Pointer(pNew)).FzClassName, zModule, (size_t(nModule + int64(1)))) - zTab = fuzzerDequote(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) + zTab = fuzzerDequote(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) if zTab == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = fuzzerLoadRules(tls, db, pNew, zDb, zTab, pzErr) sqlite3.Xsqlite3_free(tls, zTab) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+5136 /* "CREATE TABLE x(w..." */) } - if rc != 0 { + if rc != SQLITE_OK { fuzzerDisconnect(tls, pNew) pNew = uintptr(0) } else { - sqlite3.Xsqlite3_vtab_config(tls, db, 2, 0) + sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) } } } @@ -21857,13 +21409,13 @@ func fuzzerOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* fuzze var pCur uintptr pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(fuzzer_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(fuzzer_cursor{}))) (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpVtab = p *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) (*fuzzer_vtab)(unsafe.Pointer(p)).FnCursor++ - return 0 + return SQLITE_OK } // Free all stems in a list. @@ -21881,7 +21433,7 @@ func fuzzerClearCursor(tls *libc.TLS, pCur uintptr, clearHash int32) { /* fuzzer var i int32 fuzzerClearStemList(tls, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem) fuzzerClearStemList(tls, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpDone) - for i = 0; i < 20; i++ { + for i = 0; i < FUZZER_NQUEUE; i++ { fuzzerClearStemList(tls, *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + uintptr(i)*8))) } (*fuzzer_cursor)(unsafe.Pointer(pCur)).FrLimit = 0 @@ -21902,7 +21454,7 @@ func fuzzerClose(tls *libc.TLS, cur uintptr) int32 { /* fuzzer.c:602:12: */ sqlite3.Xsqlite3_free(tls, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FzBuf) (*fuzzer_vtab)(unsafe.Pointer((*fuzzer_cursor)(unsafe.Pointer(pCur)).FpVtab)).FnCursor-- sqlite3.Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } // Compute the current output term for a fuzzer_stem. @@ -21915,7 +21467,7 @@ func fuzzerRender(tls *libc.TLS, pStem uintptr, pzBuf uintptr, pnBuf uintptr) in if (*(*int32)(unsafe.Pointer(pnBuf))) < (n + 1) { (*(*uintptr)(unsafe.Pointer(pzBuf))) = sqlite3.Xsqlite3_realloc(tls, *(*uintptr)(unsafe.Pointer(pzBuf)), (n + 100)) if (*(*uintptr)(unsafe.Pointer(pzBuf))) == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*(*int32)(unsafe.Pointer(pnBuf))) = (n + 100) } @@ -21930,7 +21482,7 @@ func fuzzerRender(tls *libc.TLS, pStem uintptr, pzBuf uintptr, pnBuf uintptr) in (uint64(((int32((*fuzzer_stem)(unsafe.Pointer(pStem)).FnBasis) - n) - int32((*fuzzer_rule)(unsafe.Pointer(pRule)).FnFrom)) + 1))) } - return 0 + return SQLITE_OK } // Compute a hash on zBasis. @@ -21939,7 +21491,7 @@ func fuzzerHash(tls *libc.TLS, z uintptr) uint32 { /* fuzzer.c:647:21: */ for *(*int8)(unsafe.Pointer(z)) != 0 { h = (((h << 3) ^ (h >> 29)) ^ uint32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))) } - return (h % uint32(4001)) + return (h % FUZZER_HASH) } // Current cost of a stem @@ -21954,7 +21506,7 @@ func fuzzerSeen(tls *libc.TLS, pCur uintptr, pStem uintptr) int32 { /* fuzzer.c: var h uint32 var pLookup uintptr - if fuzzerRender(tls, pStem, (pCur+216 /* &.zBuf */), (pCur+224 /* &.nBuf */)) == 7 { + if fuzzerRender(tls, pStem, (pCur+216 /* &.zBuf */), (pCur+224 /* &.nBuf */)) == SQLITE_NOMEM { return -1 } h = fuzzerHash(tls, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FzBuf) @@ -21973,7 +21525,7 @@ func fuzzerSeen(tls *libc.TLS, pCur uintptr, pStem uintptr) int32 { /* fuzzer.c: // FUZZER_MX_OUTPUT_LENGTH bytes. func fuzzerSkipRule(tls *libc.TLS, pRule uintptr, pStem uintptr, iRuleset int32) int32 { /* fuzzer.c:717:12: */ return (libc.Bool32((pRule != 0) && (((*fuzzer_rule)(unsafe.Pointer(pRule)).FiRuleset != iRuleset) || - (((int32((*fuzzer_stem)(unsafe.Pointer(pStem)).FnBasis) + int32((*fuzzer_rule)(unsafe.Pointer(pRule)).FnTo)) - int32((*fuzzer_rule)(unsafe.Pointer(pRule)).FnFrom)) > 100)))) + (((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)))) } // Advance a fuzzer_stem to its next value. Return 0 if there are @@ -22100,13 +21652,13 @@ func fuzzerInsert(tls *libc.TLS, pCur uintptr, pNew uintptr) uintptr { /* fuzzer } } if i > (*fuzzer_cursor)(unsafe.Pointer(pCur)).FmxQueue { - if i < 20 { + if i < FUZZER_NQUEUE { (*fuzzer_cursor)(unsafe.Pointer(pCur)).FmxQueue = i *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + uintptr(i)*8)) = pX } else { - pX = fuzzerMergeStems(tls, pX, *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + uintptr((20-1))*8))) - *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + uintptr((20-1))*8)) = pX + pX = fuzzerMergeStems(tls, pX, *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + 19*8))) + *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + 19*8)) = pX } } @@ -22125,7 +21677,7 @@ func fuzzerNewStem(tls *libc.TLS, pCur uintptr, zWord uintptr, rBaseCost fuzzer_ return uintptr(0) } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(fuzzer_stem{}))) - (*fuzzer_stem)(unsafe.Pointer(pNew)).FzBasis = (pNew + uintptr(1)*48) + (*fuzzer_stem)(unsafe.Pointer(pNew)).FzBasis = (pNew + 1*48) (*fuzzer_stem)(unsafe.Pointer(pNew)).FnBasis = fuzzer_len(libc.Xstrlen(tls, zWord)) libc.Xmemcpy(tls, (*fuzzer_stem)(unsafe.Pointer(pNew)).FzBasis, zWord, (uint64(int32((*fuzzer_stem)(unsafe.Pointer(pNew)).FnBasis) + 1))) pRule = (*fuzzer_vtab)(unsafe.Pointer((*fuzzer_cursor)(unsafe.Pointer(pCur)).FpVtab)).FpRule @@ -22156,8 +21708,8 @@ func fuzzerNext(tls *libc.TLS, cur uintptr) int32 { /* fuzzer.c:901:12: */ pStem = (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem if (*fuzzer_stem)(unsafe.Pointer(pStem)).FrCostX > 0 { rc = fuzzerRender(tls, pStem, (pCur + 216 /* &.zBuf */), (pCur + 224 /* &.nBuf */)) - if rc == 7 { - return 7 + if rc == SQLITE_NOMEM { + return SQLITE_NOMEM } pNew = fuzzerNewStem(tls, pCur, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FzBuf, (*fuzzer_stem)(unsafe.Pointer(pStem)).FrCostX) if pNew != 0 { @@ -22166,11 +21718,11 @@ func fuzzerNext(tls *libc.TLS, cur uintptr) int32 { /* fuzzer.c:901:12: */ (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpDone = pNew } else { if fuzzerInsert(tls, pCur, pNew) == pNew { - return 0 + return SQLITE_OK } } } else { - return 7 + return SQLITE_NOMEM } } @@ -22179,17 +21731,17 @@ func fuzzerNext(tls *libc.TLS, cur uintptr) int32 { /* fuzzer.c:901:12: */ for (libc.AssignUintptr(&pStem, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem)) != uintptr(0) { var res int32 = fuzzerAdvance(tls, pCur, pStem) if res < 0 { - return 7 + return SQLITE_NOMEM } else if res > 0 { (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem = uintptr(0) pStem = fuzzerInsert(tls, pCur, pStem) if (libc.AssignInt32(&rc, fuzzerSeen(tls, pCur, pStem))) != 0 { if rc < 0 { - return 7 + return SQLITE_NOMEM } continue } - return 0 // New word found + return SQLITE_OK // New word found } (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem = uintptr(0) (*fuzzer_stem)(unsafe.Pointer(pStem)).FpNext = (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpDone @@ -22197,10 +21749,10 @@ func fuzzerNext(tls *libc.TLS, cur uintptr) int32 { /* fuzzer.c:901:12: */ if fuzzerLowestCostStem(tls, pCur) != 0 { rc = fuzzerSeen(tls, pCur, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem) if rc < 0 { - return 7 + return SQLITE_NOMEM } if rc == 0 { - return 0 + return SQLITE_OK } } } @@ -22208,7 +21760,7 @@ func fuzzerNext(tls *libc.TLS, cur uintptr) int32 { /* fuzzer.c:901:12: */ // Reach this point only if queue has been exhausted and there is // nothing left to be output. (*fuzzer_cursor)(unsafe.Pointer(pCur)).FrLimit = 0 - return 0 + return SQLITE_OK } // Called to "rewind" a cursor back to the beginning so that @@ -22224,7 +21776,7 @@ func fuzzerFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp (*fuzzer_cursor)(unsafe.Pointer(pCur)).FrLimit = 2147483647 idx = 0 if (idxNum & 1) != 0 { - zWord = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zWord = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) idx++ } if (idxNum & 2) != 0 { @@ -22244,10 +21796,10 @@ func fuzzerFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp // If the query term is longer than FUZZER_MX_OUTPUT_LENGTH bytes, this // query will return zero rows. - if int32(libc.Xstrlen(tls, zWord)) < 100 { + if int32(libc.Xstrlen(tls, zWord)) < FUZZER_MX_OUTPUT_LENGTH { (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem = libc.AssignUintptr(&pStem, fuzzerNewStem(tls, pCur, zWord, 0)) if pStem == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*fuzzer_stem)(unsafe.Pointer(pStem)).FpRule = (pCur + 240 /* &.nullRule */) (*fuzzer_stem)(unsafe.Pointer(pStem)).Fn = (*fuzzer_stem)(unsafe.Pointer(pStem)).FnBasis @@ -22255,7 +21807,7 @@ func fuzzerFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp (*fuzzer_cursor)(unsafe.Pointer(pCur)).FrLimit = 0 } - return 0 + return SQLITE_OK } // Only the word and distance columns have values. All other columns @@ -22264,8 +21816,8 @@ func fuzzerColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* f var pCur uintptr = cur if i == 0 { // the "word" column - if fuzzerRender(tls, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem, (pCur+216 /* &.zBuf */), (pCur+224 /* &.nBuf */)) == 7 { - return 7 + if fuzzerRender(tls, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem, (pCur+216 /* &.zBuf */), (pCur+224 /* &.nBuf */)) == SQLITE_NOMEM { + return SQLITE_NOMEM } sqlite3.Xsqlite3_result_text(tls, ctx, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FzBuf, -1, libc.UintptrFromInt32(-1)) } else if i == 1 { @@ -22275,14 +21827,14 @@ func fuzzerColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* f // All other columns are NULL sqlite3.Xsqlite3_result_null(tls, ctx) } - return 0 + return SQLITE_OK } // The rowid. func fuzzerRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* fuzzer.c:1041:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*fuzzer_cursor)(unsafe.Pointer(pCur)).FiRowid - return 0 + return SQLITE_OK } // When the fuzzer_cursor.rLimit value is 0 or less, that is a signal @@ -22329,7 +21881,7 @@ __1: } { if ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 0) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 64) { + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) { seenMatch = 1 } if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { @@ -22337,7 +21889,7 @@ __1: } if (((iPlan & 1) == 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 0)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 64) { + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) { iPlan = iPlan | (1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) @@ -22345,15 +21897,15 @@ __1: } if (((iPlan & 2) == 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 1)) && - ((int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 16) || - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 8)) { + ((int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT) || + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LE)) { iPlan = iPlan | (2) iDistTerm = i rCost = rCost / (10.0) } if (((iPlan & 4) == 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 2)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2) { + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { iPlan = iPlan | (4) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) iRulesetTerm = i @@ -22384,8 +21936,8 @@ __3: } (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = iPlan if (((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1) && - ((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).FiColumn == 1)) && - (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).Fdesc) == 0) { + ((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn == 1)) && + (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0) { (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 } if (seenMatch != 0) && ((iPlan & 1) == 0) { @@ -22393,49 +21945,27 @@ __3: } (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = rCost - return 0 + return SQLITE_OK } // A virtual table module that implements the "fuzzer". -var fuzzerModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, +var fuzzerModule = sqlite3_module{ // iVersion + FxCreate: 0, FxConnect: 0, FxBestIndex: 0, FxDisconnect: 0, FxDestroy: 0, - FxOpen: 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRename } /* fuzzer.c:1147:23 */ func sqlite3_fuzzer_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* fuzzer.c:1176:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi rc = sqlite3.Xsqlite3_create_module(tls, db, ts+5174 /* "fuzzer" */, uintptr(unsafe.Pointer(&fuzzerModule)), uintptr(0)) @@ -22460,9 +21990,9 @@ func ieee754func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* var isNeg int32 // var zResult [100]int8 at bp+40, 100 - if (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 4) && - (uint64(sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) == uint64(unsafe.Sizeof(float64(0)))) { - var x uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + if (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_BLOB) && + (uint64(sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) == uint64(unsafe.Sizeof(float64(0)))) { + var x uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) var i uint32 *(*sqlite3_uint64)(unsafe.Pointer(bp + 24 /* v */)) = uint64(0) for i = uint32(0); uint64(i) < uint64(unsafe.Sizeof(float64(0))); i++ { @@ -22470,7 +22000,7 @@ func ieee754func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* } libc.Xmemcpy(tls, bp+16 /* &r */, bp+24 /* &v */, uint64(unsafe.Sizeof(float64(0)))) } else { - *(*float64)(unsafe.Pointer(bp + 16 /* r */)) = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + *(*float64)(unsafe.Pointer(bp + 16 /* r */)) = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) } if *(*float64)(unsafe.Pointer(bp + 16 /* r */)) < 0.0 { isNeg = 1 @@ -22521,8 +22051,8 @@ func ieee754func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* // var r float64 at bp+144, 8 var isNeg int32 = 0 - m = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - e = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + m = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) + e = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if m < int64(0) { isNeg = 1 m = -m @@ -22565,11 +22095,11 @@ func ieee754func_from_blob(tls *libc.TLS, context uintptr, argc int32, argv uint defer tls.Free(16) _ = argc - if (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 4) && - (uint64(sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) == uint64(unsafe.Sizeof(float64(0)))) { + if (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_BLOB) && + (uint64(sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) == uint64(unsafe.Sizeof(float64(0)))) { // var r float64 at bp, 8 - var x uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var x uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) var i uint32 *(*sqlite3_uint64)(unsafe.Pointer(bp + 8 /* v */)) = uint64(0) for i = uint32(0); uint64(i) < uint64(unsafe.Sizeof(float64(0))); i++ { @@ -22585,9 +22115,9 @@ func ieee754func_to_blob(tls *libc.TLS, context uintptr, argc int32, argv uintpt defer tls.Free(24) _ = argc - if (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 2) || - (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 1) { - *(*float64)(unsafe.Pointer(bp + 8 /* r */)) = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + if (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_FLOAT) || + (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_INTEGER) { + *(*float64)(unsafe.Pointer(bp + 8 /* r */)) = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) // var v sqlite3_uint64 at bp, 8 // var a [8]uint8 at bp+16, 8 @@ -22604,7 +22134,7 @@ func ieee754func_to_blob(tls *libc.TLS, context uintptr, argc int32, argv uintpt func sqlite3_ieee_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* ieee754.c:251:5: */ var i uint32 - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi _ = pzErrMsg // Unused parameter @@ -22613,9 +22143,9 @@ func sqlite3_ieee_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr FnArg int32 FiAux int32 FxFunc uintptr - }{})))) && (rc == 0); i++ { + }{})))) && (rc == SQLITE_OK); i++ { rc = sqlite3.Xsqlite3_create_function(tls, db, aFunc1[i].FzFName, aFunc1[i].FnArg, - (1 | 0x000200000), + (SQLITE_UTF8 | SQLITE_INNOCUOUS), (uintptr(unsafe.Pointer(&aFunc1)) + uintptr(i)*24 + 12 /* &.iAux */), aFunc1[i].FxFunc, uintptr(0), uintptr(0)) } @@ -22628,36 +22158,12 @@ var aFunc1 = [6]struct { FiAux int32 FxFunc uintptr }{ - { - FzFName: ts + 5198, /* "ieee754" */ - FnArg: 1, - FiAux: 0, - FxFunc: 0}, - { - FzFName: ts + 5198, /* "ieee754" */ - FnArg: 2, - FiAux: 0, - FxFunc: 0}, - { - FzFName: ts + 5206, /* "ieee754_mantissa" */ - FnArg: 1, - FiAux: 1, - FxFunc: 0}, - { - FzFName: ts + 5223, /* "ieee754_exponent" */ - FnArg: 1, - FiAux: 2, - FxFunc: 0}, - { - FzFName: ts + 5240, /* "ieee754_to_blob" */ - FnArg: 1, - FiAux: 0, - FxFunc: 0}, - { - FzFName: ts + 5256, /* "ieee754_from_blo..." */ - FnArg: 1, - FiAux: 0, - FxFunc: 0}, + {FzFName: ts + 5198 /* "ieee754" */, FnArg: 1, FxFunc: 0}, + {FzFName: ts + 5198 /* "ieee754" */, FnArg: 2, FxFunc: 0}, + {FzFName: ts + 5206 /* "ieee754_mantissa" */, FnArg: 1, FiAux: 1, FxFunc: 0}, + {FzFName: ts + 5223 /* "ieee754_exponent" */, FnArg: 1, FiAux: 2, FxFunc: 0}, + {FzFName: ts + 5240 /* "ieee754_to_blob" */, FnArg: 1, FxFunc: 0}, + {FzFName: ts + 5256 /* "ieee754_from_blo..." */, FnArg: 1, FxFunc: 0}, } /* ieee754.c:261:5 */ // @@ -22687,13 +22193,13 @@ func sqlite3_mmap_warm(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* mmapwa bp := tls.Alloc(88) defer tls.Free(88) - var rc int32 = 0 + var rc int32 = SQLITE_OK var zSql uintptr = uintptr(0) var pgsz int32 = 0 var nTotal int32 = 0 if 0 == sqlite3.Xsqlite3_get_autocommit(tls, db) { - return 21 + return SQLITE_MISUSE } // Open a read-only transaction on the file in question @@ -22715,13 +22221,13 @@ func sqlite3_mmap_warm(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* mmapwa return ts + 488 /* "" */ }())) if zSql == uintptr(0) { - return 7 + return SQLITE_NOMEM } rc = sqlite3.Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) // Find the SQLite page size of the file - if rc == 0 { + if rc == SQLITE_OK { zSql = sqlite3.Xsqlite3_mprintf(tls, ts+5320, /* "PRAGMA %s%q%spag..." */ libc.VaList(bp+24, func() uintptr { if zDb != 0 { @@ -22740,49 +22246,49 @@ func sqlite3_mmap_warm(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* mmapwa return ts + 488 /* "" */ }())) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { *(*uintptr)(unsafe.Pointer(bp + 64 /* pPgsz */)) = uintptr(0) rc = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+64 /* &pPgsz */, uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) - if rc == 0 { - if sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pPgsz */))) == 100 { + if rc == SQLITE_OK { + if sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pPgsz */))) == SQLITE_ROW { pgsz = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pPgsz */)), 0) } rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pPgsz */))) } - if (rc == 0) && (pgsz == 0) { - rc = 1 + if (rc == SQLITE_OK) && (pgsz == 0) { + rc = SQLITE_ERROR } } } // Touch each mmap'd page of the file - if rc == 0 { + if rc == SQLITE_OK { var rc2 int32 *(*uintptr)(unsafe.Pointer(bp + 72 /* pFd */)) = uintptr(0) - rc = sqlite3.Xsqlite3_file_control(tls, db, zDb, 7, bp+72 /* &pFd */) - if (rc == 0) && ((*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 72 /* pFd */)))).FpMethods)).FiVersion >= 3) { + rc = sqlite3.Xsqlite3_file_control(tls, db, zDb, SQLITE_FCNTL_FILE_POINTER, bp+72 /* &pFd */) + if (rc == SQLITE_OK) && ((*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 72 /* pFd */)))).FpMethods)).FiVersion >= 3) { var iPg sqlite3_int64 = int64(1) var p uintptr = (*sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 72 /* pFd */)))).FpMethods for 1 != 0 { // var pMap uintptr at bp+80, 8 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 */) - if (rc != 0) || (*(*uintptr)(unsafe.Pointer(bp + 80 /* pMap */)) == uintptr(0)) { + if (rc != SQLITE_OK) || (*(*uintptr)(unsafe.Pointer(bp + 80 /* pMap */)) == uintptr(0)) { break } - nTotal = nTotal + (int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* pMap */)) + uintptr(0))))) + nTotal = nTotal + (int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* pMap */)))))) nTotal = nTotal + (int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* pMap */)) + uintptr((pgsz - 1)))))) 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 */))) - if rc != 0 { + if rc != SQLITE_OK { break } iPg++ } - sqlite3.Xsqlite3_log(tls, 0, + sqlite3.Xsqlite3_log(tls, SQLITE_OK, ts+5343 /* "sqlite3_mmap_war..." */, libc.VaList(bp+48, func() int64 { if iPg == int64(1) { return int64(0) @@ -22793,7 +22299,7 @@ func sqlite3_mmap_warm(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* mmapwa } rc2 = sqlite3.Xsqlite3_exec(tls, db, ts+5393 /* "END" */, uintptr(0), uintptr(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } @@ -22848,31 +22354,31 @@ func nextCharAppend(tls *libc.TLS, p uintptr, c uint32) { /* nextchar.c:80:13: * // to hold the character func writeUtf8(tls *libc.TLS, z uintptr, c uint32) int32 { /* nextchar.c:104:12: */ if c < uint32(0x00080) { - *(*uint8)(unsafe.Pointer(z + uintptr(0))) = (uint8(c & uint32(0xff))) + *(*uint8)(unsafe.Pointer(z)) = (uint8(c & uint32(0xff))) return 1 } if c < uint32(0x00800) { - *(*uint8)(unsafe.Pointer(z + uintptr(0))) = (uint8(0xC0 + int32((uint8((c >> 6) & uint32(0x1F)))))) - *(*uint8)(unsafe.Pointer(z + uintptr(1))) = (uint8(0x80 + int32((uint8(c & uint32(0x3F)))))) + *(*uint8)(unsafe.Pointer(z)) = (uint8(0xC0 + int32((uint8((c >> 6) & uint32(0x1F)))))) + *(*uint8)(unsafe.Pointer(z + 1)) = (uint8(0x80 + int32((uint8(c & uint32(0x3F)))))) return 2 } if c < uint32(0x10000) { - *(*uint8)(unsafe.Pointer(z + uintptr(0))) = (uint8(0xE0 + int32((uint8((c >> 12) & uint32(0x0F)))))) - *(*uint8)(unsafe.Pointer(z + uintptr(1))) = (uint8(0x80 + int32((uint8((c >> 6) & uint32(0x3F)))))) - *(*uint8)(unsafe.Pointer(z + uintptr(2))) = (uint8(0x80 + int32((uint8(c & uint32(0x3F)))))) + *(*uint8)(unsafe.Pointer(z)) = (uint8(0xE0 + int32((uint8((c >> 12) & uint32(0x0F)))))) + *(*uint8)(unsafe.Pointer(z + 1)) = (uint8(0x80 + int32((uint8((c >> 6) & uint32(0x3F)))))) + *(*uint8)(unsafe.Pointer(z + 2)) = (uint8(0x80 + int32((uint8(c & uint32(0x3F)))))) return 3 } - *(*uint8)(unsafe.Pointer(z + uintptr(0))) = (uint8(0xF0 + int32((uint8((c >> 18) & uint32(0x07)))))) - *(*uint8)(unsafe.Pointer(z + uintptr(1))) = (uint8(0x80 + int32((uint8((c >> 12) & uint32(0x3F)))))) - *(*uint8)(unsafe.Pointer(z + uintptr(2))) = (uint8(0x80 + int32((uint8((c >> 6) & uint32(0x3F)))))) - *(*uint8)(unsafe.Pointer(z + uintptr(3))) = (uint8(0x80 + int32((uint8(c & uint32(0x3F)))))) + *(*uint8)(unsafe.Pointer(z)) = (uint8(0xF0 + int32((uint8((c >> 18) & uint32(0x07)))))) + *(*uint8)(unsafe.Pointer(z + 1)) = (uint8(0x80 + int32((uint8((c >> 12) & uint32(0x3F)))))) + *(*uint8)(unsafe.Pointer(z + 2)) = (uint8(0x80 + int32((uint8((c >> 6) & uint32(0x3F)))))) + *(*uint8)(unsafe.Pointer(z + 3)) = (uint8(0x80 + int32((uint8(c & uint32(0x3F)))))) return 4 } // Read a UTF8 character out of z[] and write it into *pOut. Return // the number of bytes in z[] that were used to construct the character. func readUtf8(tls *libc.TLS, z uintptr, pOut uintptr) int32 { /* nextchar.c:131:12: */ - var c uint32 = uint32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) + var c uint32 = uint32(*(*uint8)(unsafe.Pointer(z))) if c < uint32(0xc0) { *(*uint32)(unsafe.Pointer(pOut)) = c return 1 @@ -22920,10 +22426,10 @@ func findNextChars(tls *libc.TLS, p uintptr) { /* nextchar.c:164:13: */ n = writeUtf8(tls, bp /* &zPrev[0] */, (cPrev + uint32(1))) sqlite3.Xsqlite3_bind_text(tls, (*nextCharContext)(unsafe.Pointer(p)).FpStmt, 2, bp /* zPrev */, n, uintptr(0)) rc = sqlite3.Xsqlite3_step(tls, (*nextCharContext)(unsafe.Pointer(p)).FpStmt) - if rc == 101 { + if rc == SQLITE_DONE { sqlite3.Xsqlite3_reset(tls, (*nextCharContext)(unsafe.Pointer(p)).FpStmt) return - } else if rc != 100 { + } else if rc != SQLITE_ROW { (*nextCharContext)(unsafe.Pointer(p)).FotherError = rc return } else { @@ -22952,8 +22458,8 @@ func nextCharFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* // var c nextCharContext at bp+80, 56 - var zTable uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - var zField uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + var zTable uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + var zField uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) var zWhere uintptr var zCollName uintptr var zWhereClause uintptr = uintptr(0) @@ -22963,14 +22469,14 @@ func nextCharFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* libc.Xmemset(tls, bp+80 /* &c */, 0, uint64(unsafe.Sizeof(nextCharContext{}))) (*nextCharContext)(unsafe.Pointer(bp + 80 /* &c */)).Fdb = sqlite3.Xsqlite3_context_db_handle(tls, context) - (*nextCharContext)(unsafe.Pointer(bp + 80 /* &c */)).FzPrefix = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - (*nextCharContext)(unsafe.Pointer(bp + 80 /* &c */)).FnPrefix = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + (*nextCharContext)(unsafe.Pointer(bp + 80 /* &c */)).FzPrefix = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + (*nextCharContext)(unsafe.Pointer(bp + 80 /* &c */)).FnPrefix = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) if ((zTable == uintptr(0)) || (zField == uintptr(0))) || ((*nextCharContext)(unsafe.Pointer(bp+80 /* &c */)).FzPrefix == uintptr(0)) { return } if ((argc >= 4) && - ((libc.AssignUintptr(&zWhere, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))))) != uintptr(0))) && - (int32(*(*uint8)(unsafe.Pointer(zWhere + uintptr(0)))) != 0) { + ((libc.AssignUintptr(&zWhere, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))))) != uintptr(0))) && + (int32(*(*uint8)(unsafe.Pointer(zWhere))) != 0) { zWhereClause = sqlite3.Xsqlite3_mprintf(tls, ts+5397 /* "AND (%s)" */, libc.VaList(bp, zWhere)) if zWhereClause == uintptr(0) { sqlite3.Xsqlite3_result_error_nomem(tls, context) @@ -22980,12 +22486,12 @@ func nextCharFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* zWhereClause = ts + 488 /* "" */ } if ((argc >= 5) && - ((libc.AssignUintptr(&zCollName, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8))))) != uintptr(0))) && - (int32(*(*uint8)(unsafe.Pointer(zCollName + uintptr(0)))) != 0) { + ((libc.AssignUintptr(&zCollName, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))))) != uintptr(0))) && + (int32(*(*uint8)(unsafe.Pointer(zCollName))) != 0) { zColl = sqlite3.Xsqlite3_mprintf(tls, ts+5406 /* "collate \"%w\"" */, libc.VaList(bp+8, zCollName)) if zColl == uintptr(0) { sqlite3.Xsqlite3_result_error_nomem(tls, context) - if *(*int8)(unsafe.Pointer(zWhereClause + uintptr(0))) != 0 { + if *(*int8)(unsafe.Pointer(zWhereClause)) != 0 { sqlite3.Xsqlite3_free(tls, zWhereClause) } return @@ -22999,10 +22505,10 @@ func nextCharFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* ts+5419, /* "SELECT %s FROM %..." */ libc.VaList(bp+16, zField, zTable, zField, zColl, zField, zColl, zWhereClause, zColl)) - if *(*int8)(unsafe.Pointer(zWhereClause + uintptr(0))) != 0 { + if *(*int8)(unsafe.Pointer(zWhereClause)) != 0 { sqlite3.Xsqlite3_free(tls, zWhereClause) } - if *(*int8)(unsafe.Pointer(zColl + uintptr(0))) != 0 { + if *(*int8)(unsafe.Pointer(zColl)) != 0 { sqlite3.Xsqlite3_free(tls, zColl) } if zSql == uintptr(0) { @@ -23039,25 +22545,25 @@ func nextCharFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* } func sqlite3_nextchar_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* nextchar.c:292:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi _ = pzErrMsg // Unused parameter rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5527 /* "next_char" */, 3, - (1 | 0x000200000), uintptr(0), + (SQLITE_UTF8 | SQLITE_INNOCUOUS), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{nextCharFunc})), uintptr(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5527 /* "next_char" */, 4, - (1 | 0x000200000), uintptr(0), + (SQLITE_UTF8 | SQLITE_INNOCUOUS), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{nextCharFunc})), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5527 /* "next_char" */, 5, - (1 | 0x000200000), uintptr(0), + (SQLITE_UTF8 | SQLITE_INNOCUOUS), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{nextCharFunc})), uintptr(0), uintptr(0)) @@ -23221,163 +22727,163 @@ func sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* nor switch int32(aiClass[*(*uint8)(unsafe.Pointer(z))]) { // Switch on the character-class of the first byte // of the token. See the comment on the CC_ defines // above. - case 7: + case CC_SPACE: { for i = 1; (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x01) != 0; i++ { } - *(*int32)(unsafe.Pointer(tokenType)) = 0 + *(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE return i } - case 11: + case CC_MINUS: { - if int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == '-' { + if int32(*(*uint8)(unsafe.Pointer(z + 1))) == '-' { for i = 2; ((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0) && (c != '\n'); i++ { } - *(*int32)(unsafe.Pointer(tokenType)) = 0 + *(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE return i } - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } - case 17: + case CC_LP: { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } - case 18: + case CC_RP: { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } - case 19: + case CC_SEMI: { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } - case 20: + case CC_PLUS: { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } - case 21: + case CC_STAR: { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } - case 16: + case CC_SLASH: { - if (int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) != '*') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(2)))) == 0) { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + if (int32(*(*uint8)(unsafe.Pointer(z + 1))) != '*') || (int32(*(*uint8)(unsafe.Pointer(z + 2))) == 0) { + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } i = 3 - c = int32(*(*uint8)(unsafe.Pointer(z + uintptr(2)))) + c = int32(*(*uint8)(unsafe.Pointer(z + 2))) for ; ((c != '*') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '/')) && ((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0); i++ { } if c != 0 { i++ } - *(*int32)(unsafe.Pointer(tokenType)) = 0 + *(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE return i } - case 22: + case CC_PERCENT: { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } - case 14: + case CC_EQ: { - *(*int32)(unsafe.Pointer(tokenType)) = 3 - return (1 + (libc.Bool32(int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == '='))) + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT + return (1 + (libc.Bool32(int32(*(*uint8)(unsafe.Pointer(z + 1))) == '='))) } - case 12: + case CC_LT: { - if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))))) == '=' { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + 1))))) == '=' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 2 } else if c == '>' { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 2 } else if c == '<' { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 2 } else { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } } fallthrough - case 13: + case CC_GT: { - if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))))) == '=' { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + 1))))) == '=' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 2 } else if c == '>' { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 2 } else { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } } fallthrough - case 15: + case CC_BANG: { - if int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) != '=' { - *(*int32)(unsafe.Pointer(tokenType)) = 4 + if int32(*(*uint8)(unsafe.Pointer(z + 1))) != '=' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR return 1 } else { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 2 } } fallthrough - case 10: + case CC_PIPE: { - if int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) != '|' { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + if int32(*(*uint8)(unsafe.Pointer(z + 1))) != '|' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } else { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 2 } } fallthrough - case 23: + case CC_COMMA: { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } - case 24: + case CC_AND: { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } - case 25: + case CC_TILDA: { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } - case 8: + case CC_QUOTE: { - var delim int32 = int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) + var delim int32 = int32(*(*uint8)(unsafe.Pointer(z))) for i = 1; (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0; i++ { if c == delim { @@ -23389,22 +22895,22 @@ func sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* nor } } if c == '\'' { - *(*int32)(unsafe.Pointer(tokenType)) = 2 + *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL return (i + 1) } else if c != 0 { - *(*int32)(unsafe.Pointer(tokenType)) = 1 + *(*int32)(unsafe.Pointer(tokenType)) = TK_NAME return (i + 1) } else { - *(*int32)(unsafe.Pointer(tokenType)) = 4 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR return i } } fallthrough - case 26: + case CC_DOT: { - if !((int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(1)))]) & 0x04) != 0) { - *(*int32)(unsafe.Pointer(tokenType)) = 3 + if !((int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + 1))]) & 0x04) != 0) { + *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT return 1 } // If the next character is a digit, this is a floating point @@ -23413,10 +22919,10 @@ func sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* nor } fallthrough - case 3: + case CC_DIGIT: { - *(*int32)(unsafe.Pointer(tokenType)) = 2 - if ((int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) == '0') && ((int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == 'x') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == 'X'))) && ((int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(2)))]) & 0x08) != 0) { + *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL + 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) { for i = 3; (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x08) != 0; i++ { } return i @@ -23428,7 +22934,7 @@ func sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* nor for (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0 { i++ } - *(*int32)(unsafe.Pointer(tokenType)) = 2 + *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL } 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) || (((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))) { @@ -23436,45 +22942,45 @@ func sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* nor for (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0 { i++ } - *(*int32)(unsafe.Pointer(tokenType)) = 2 + *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL } for (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x46) != 0 { - *(*int32)(unsafe.Pointer(tokenType)) = 4 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR i++ } return i } - case 9: + case CC_QUOTE2: { i = 1 - c = int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) + c = int32(*(*uint8)(unsafe.Pointer(z))) for ; (c != ']') && ((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0); i++ { } *(*int32)(unsafe.Pointer(tokenType)) = func() int32 { if c == ']' { - return 1 + return TK_NAME } - return 4 + return TK_ERROR }() return i } - case 6: + case CC_VARNUM: { - *(*int32)(unsafe.Pointer(tokenType)) = 2 + *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL for i = 1; (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0; i++ { } return i } - case 4: + case CC_DOLLAR: fallthrough - case 5: + case CC_VARALPHA: { var n int32 = 0 - *(*int32)(unsafe.Pointer(tokenType)) = 2 + *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL for i = 1; (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0; i++ { if (int32(sqlite3CtypeMap[uint8(c)]) & 0x46) != 0 { n++ @@ -23485,7 +22991,7 @@ func sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* nor if c == ')' { i++ } else { - *(*int32)(unsafe.Pointer(tokenType)) = 4 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR } break } else if (c == ':') && (int32(*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))) == ':') { @@ -23495,14 +23001,14 @@ func sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* nor } } if n == 0 { - *(*int32)(unsafe.Pointer(tokenType)) = 4 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR } return i } - case 1: + case CC_KYWD: { - for i = 1; int32(aiClass[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) <= 1; i++ { + for i = 1; int32(aiClass[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) <= CC_KYWD; i++ { } if (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x46) != 0 { // This token started out using characters that can appear in keywords, @@ -23511,19 +23017,19 @@ func sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* nor i++ break } - *(*int32)(unsafe.Pointer(tokenType)) = 1 + *(*int32)(unsafe.Pointer(tokenType)) = TK_NAME return i } - case 0: + case CC_X: { - if int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == '\'' { - *(*int32)(unsafe.Pointer(tokenType)) = 2 + if int32(*(*uint8)(unsafe.Pointer(z + 1))) == '\'' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL for i = 2; (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x08) != 0; i++ { } if (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '\'') || ((i % 2) != 0) { - *(*int32)(unsafe.Pointer(tokenType)) = 4 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR for (*(*uint8)(unsafe.Pointer(z + uintptr(i))) != 0) && (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '\'') { i++ } @@ -23539,7 +23045,7 @@ func sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* nor } fallthrough - case 2: + case CC_ID: { i = 1 break @@ -23547,7 +23053,7 @@ func sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* nor } default: { - *(*int32)(unsafe.Pointer(tokenType)) = 4 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR return 1 } @@ -23555,7 +23061,7 @@ func sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* nor for (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x46) != 0 { i++ } - *(*int32)(unsafe.Pointer(tokenType)) = 1 + *(*int32)(unsafe.Pointer(tokenType)) = TK_NAME return i } @@ -23582,26 +23088,26 @@ func sqlite3_normalize(tls *libc.TLS, zSql uintptr) uintptr { /* normalize.c:555 for i = libc.AssignInt32(&j, 0); *(*int8)(unsafe.Pointer(zSql + uintptr(i))) != 0; i = i + (n) { n = sqlite3GetToken(tls, (zSql + uintptr(i)), bp /* &tokenType */) switch *(*int32)(unsafe.Pointer(bp /* tokenType */)) { - case 0: + case TK_SPACE: { break } - case 4: + case TK_ERROR: { sqlite3.Xsqlite3_free(tls, z) return uintptr(0) } - case 2: + case TK_LITERAL: { *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&j, 1)))) = int8('?') break } - case 3: + case TK_PUNCT: fallthrough - case 1: + case TK_NAME: { if (n == 4) && (sqlite3.Xsqlite3_strnicmp(tls, (zSql+uintptr(i)), ts+5537 /* "NULL" */, 4) == 0) { if (((j >= 3) && (libc.Xstrncmp(tls, ((z+uintptr(j))-uintptr(2)), ts+5542 /* "is" */, uint64(2)) == 0)) && !((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr((j - 3)))))]) & 0x46) != 0)) || @@ -23644,10 +23150,10 @@ func sqlite3_normalize(tls *libc.TLS, zSql uintptr) uintptr { /* normalize.c:555 if (n != 0) && ((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zIn + libc.UintptrFromInt32(-1))))]) & 0x46) != 0) { continue } - if (libc.Xstrncmp(tls, zIn, ts+5553 /* "in(select" */, uint64(9)) == 0) && !((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zIn + uintptr(9))))]) & 0x46) != 0) { + if (libc.Xstrncmp(tls, zIn, ts+5553 /* "in(select" */, uint64(9)) == 0) && !((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zIn + 9)))]) & 0x46) != 0) { continue } - if (libc.Xstrncmp(tls, zIn, ts+5563 /* "in(with" */, uint64(7)) == 0) && !((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zIn + uintptr(7))))]) & 0x46) != 0) { + if (libc.Xstrncmp(tls, zIn, ts+5563 /* "in(with" */, uint64(7)) == 0) && !((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zIn + 7)))]) & 0x46) != 0) { continue } nParen = 1 @@ -23768,9 +23274,9 @@ func percentStep(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { /* per var y float64 // Requirement 3: P must be a number between 0 and 100 - eType = sqlite3.Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - rPct = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - if (((eType != 1) && (eType != 2)) || + eType = sqlite3.Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + rPct = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + if (((eType != SQLITE_INTEGER) && (eType != SQLITE_FLOAT)) || (rPct < 0.0)) || (rPct > 100.0) { sqlite3.Xsqlite3_result_error(tls, pCtx, ts+5577 /* "2nd argument to ..." */, -1) @@ -23794,21 +23300,21 @@ func percentStep(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { /* per } // Ignore rows for which Y is NULL - eType = sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - if eType == 5 { + eType = sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) + if eType == SQLITE_NULL { return } // If not NULL, then Y must be numeric. Otherwise throw an error. // Requirement 4 - if (eType != 1) && (eType != 2) { + if (eType != SQLITE_INTEGER) && (eType != SQLITE_FLOAT) { sqlite3.Xsqlite3_result_error(tls, pCtx, ts+5708 /* "1st argument to ..." */, -1) return } // Throw an error if the Y value is infinity or NaN - y = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + y = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) if isInfinity(tls, y) != 0 { sqlite3.Xsqlite3_result_error(tls, pCtx, ts+5752 /* "Inf input to per..." */, -1) return @@ -23881,12 +23387,12 @@ func percentFinal(tls *libc.TLS, pCtx uintptr) { /* percentile.c:182:13: */ } func sqlite3_percentile_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* percentile.c:208:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi _ = pzErrMsg // Unused parameter rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5778 /* "percentile" */, 2, - (1 | 0x000200000), uintptr(0), + (SQLITE_UTF8 | SQLITE_INNOCUOUS), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{percentStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{percentFinal}))) @@ -24028,14 +23534,14 @@ func prefixesConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv u rc = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+5789 /* "CREATE TABLE pre..." */) - if rc == 0 { + if rc == SQLITE_OK { pNew = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(prefixes_vtab{}))) *(*uintptr)(unsafe.Pointer(ppVtab)) = pNew if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(prefixes_vtab{}))) - sqlite3.Xsqlite3_vtab_config(tls, db, 2, 0) + sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) } return rc } @@ -24044,7 +23550,7 @@ func prefixesConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv u func prefixesDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* prefixes.c:90:12: */ var p uintptr = pVtab sqlite3.Xsqlite3_free(tls, p) - return 0 + return SQLITE_OK } // Constructor for a new prefixes_cursor object. @@ -24052,11 +23558,11 @@ func prefixesOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* prefixe var pCur uintptr pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(prefixes_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(prefixes_cursor{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Destructor for a prefixes_cursor. @@ -24064,14 +23570,14 @@ func prefixesClose(tls *libc.TLS, cur uintptr) int32 { /* prefixes.c:111:12: */ var pCur uintptr = cur sqlite3.Xsqlite3_free(tls, (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr) sqlite3.Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } // Advance a prefixes_cursor to its next row of output. func prefixesNext(tls *libc.TLS, cur uintptr) int32 { /* prefixes.c:122:12: */ var pCur uintptr = cur (*prefixes_cursor)(unsafe.Pointer(pCur)).FiRowid++ - return 0 + return SQLITE_OK } // Return values of columns for the row at which the prefixes_cursor @@ -24087,7 +23593,7 @@ func prefixesColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* sqlite3.Xsqlite3_result_text(tls, ctx, (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr, (*prefixes_cursor)(unsafe.Pointer(pCur)).FnStr, uintptr(0)) break } - return 0 + return SQLITE_OK } // Return the rowid for the current row. In this implementation, the @@ -24095,7 +23601,7 @@ func prefixesColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* func prefixesRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* prefixes.c:154:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*prefixes_cursor)(unsafe.Pointer(pCur)).FiRowid - return 0 + return SQLITE_OK } // Return TRUE if the cursor has been moved off of the last @@ -24116,7 +23622,7 @@ func prefixesFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uin var pCur uintptr = pVtabCursor sqlite3.Xsqlite3_free(tls, (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr) if argc > 0 { - (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) + (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))))) (*prefixes_cursor)(unsafe.Pointer(pCur)).FnStr = func() int32 { if (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr != 0 { return int32(libc.Xstrlen(tls, (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr)) @@ -24128,7 +23634,7 @@ func prefixesFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uin (*prefixes_cursor)(unsafe.Pointer(pCur)).FnStr = 0 } (*prefixes_cursor)(unsafe.Pointer(pCur)).FiRowid = int64(0) - return 0 + return SQLITE_OK } // SQLite will invoke this method one or more times while planning a query @@ -24151,7 +23657,7 @@ __1: if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn != 1 { goto __2 } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) != 2 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) != SQLITE_INDEX_CONSTRAINT_EQ { goto __2 } if !(int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) != 0) { @@ -24161,7 +23667,7 @@ __1: (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(10) (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(10) - return 0 + return SQLITE_OK } goto __2 @@ -24174,60 +23680,22 @@ __3: ; (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1000000000) (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1000000000) - return 0 + return SQLITE_OK } // This following structure defines all the methods for the // virtual table. var prefixesModule = sqlite3_module{ - FiVersion: - /* iVersion */ 0, - FxCreate: - /* xCreate */ uintptr(0), - FxConnect: - /* xConnect */ 0, - FxBestIndex: - /* xBestIndex */ 0, - FxDisconnect: - /* xDisconnect */ 0, - FxDestroy: - /* xDestroy */ uintptr(0), - FxOpen: - /* xOpen */ 0, - FxClose: - /* xClose */ 0, - FxFilter: - /* xFilter */ 0, - FxNext: - /* xNext */ 0, - FxEof: - /* xEof */ 0, - FxColumn: - /* xColumn */ 0, - FxRowid: - /* xRowid */ 0, - FxUpdate: - /* xUpdate */ uintptr(0), - FxBegin: - /* xBegin */ uintptr(0), - FxSync: - /* xSync */ uintptr(0), - FxCommit: - /* xCommit */ uintptr(0), - FxRollback: - /* xRollback */ uintptr(0), - FxFindFunction: - /* xFindMethod */ uintptr(0), - FxRename: - /* xRename */ uintptr(0), - FxSavepoint: - /* xSavepoint */ uintptr(0), - FxRelease: - /* xRelease */ uintptr(0), - FxRollbackTo: - /* xRollbackTo */ uintptr(0), - FxShadowName: - /* xShadowName */ uintptr(0), + /* xConnect */ FxConnect: 0, + /* xBestIndex */ FxBestIndex: 0, + /* xDisconnect */ FxDisconnect: 0, + /* xOpen */ FxOpen: 0, + /* xClose */ FxClose: 0, + /* xFilter */ FxFilter: 0, + /* xNext */ FxNext: 0, + /* xEof */ FxEof: 0, + /* xColumn */ FxColumn: 0, + /* xRowid */ FxRowid: 0, } /* prefixes.c:227:23 */ // This is a copy of the SQLITE_SKIP_UTF8(zIn) macro in sqliteInt.h. @@ -24249,10 +23717,10 @@ var prefixesModule = sqlite3_module{ func prefixLengthFunc(tls *libc.TLS, ctx uintptr, nVal int32, apVal uintptr) { /* prefixes.c:279:13: */ var nByte int32 // Number of bytes to compare var nRet int32 = 0 // Return value - var zL uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) - var zR uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - var nL int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) - var nR int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) + var zL uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))) + var zR uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + var nL int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal))) + var nR int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) var i int32 nByte = func() int32 { @@ -24277,13 +23745,13 @@ func prefixLengthFunc(tls *libc.TLS, ctx uintptr, nVal int32, apVal uintptr) { / } func sqlite3_prefixes_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* prefixes.c:305:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi rc = sqlite3.Xsqlite3_create_module(tls, db, ts+5853 /* "prefixes" */, uintptr(unsafe.Pointer(&prefixesModule)), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_function(tls, - db, ts+5862 /* "prefix_length" */, 2, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + db, ts+5862 /* "prefix_length" */, 2, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{prefixLengthFunc})), uintptr(0), uintptr(0)) } @@ -24459,7 +23927,7 @@ func sqlite3re_match(tls *libc.TLS, pRe uintptr, zIn uintptr, nIn int32) int32 { var x1 int32 i = uint32(0) iSwap = uint32(0) - c = (0 + 1) + c = (RE_EOF + 1) cPrev = 0 rc = 0 @@ -24476,7 +23944,7 @@ func sqlite3re_match(tls *libc.TLS, pRe uintptr, zIn uintptr, nIn int32) int32 { if !((*ReCompiled)(unsafe.Pointer(pRe)).FnInit != 0) { goto __1 } - x = *(*uint8)(unsafe.Pointer((pRe + 48 /* &.zInit */) + uintptr(0))) + x = *(*uint8)(unsafe.Pointer((pRe + 48 /* &.zInit */))) __2: if !((((*ReInput)(unsafe.Pointer(bp+232 /* &in */)).Fi + (*ReCompiled)(unsafe.Pointer(pRe)).FnInit) <= (*ReInput)(unsafe.Pointer(bp+232 /* &in */)).Fmx) && ((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))) { @@ -24499,7 +23967,7 @@ __1: goto __5 } pToFree = uintptr(0) - (*ReStateSet)(unsafe.Pointer(bp /* &aStateSet */ + uintptr(0)*16)).FaState = bp + 32 /* &aSpace[0] */ + (*ReStateSet)(unsafe.Pointer(bp /* &aStateSet */)).FaState = bp + 32 /* &aSpace[0] */ goto __6 __5: pToFree = sqlite3.Xsqlite3_malloc64(tls, (uint64((uint64(unsafe.Sizeof(ReStateNumber(0))) * uint64(2)) * uint64((*ReCompiled)(unsafe.Pointer(pRe)).FnState)))) @@ -24509,15 +23977,15 @@ __5: return -1 __7: ; - (*ReStateSet)(unsafe.Pointer(bp /* &aStateSet */ + uintptr(0)*16)).FaState = pToFree + (*ReStateSet)(unsafe.Pointer(bp /* &aStateSet */)).FaState = pToFree __6: ; - (*ReStateSet)(unsafe.Pointer(bp /* &aStateSet */ + uintptr(1)*16)).FaState = ((*ReStateSet)(unsafe.Pointer(bp /* &aStateSet */ +uintptr(0)*16)).FaState + uintptr((*ReCompiled)(unsafe.Pointer(pRe)).FnState)*2) - pNext = (bp /* &aStateSet */ + uintptr(1)*16) + (*ReStateSet)(unsafe.Pointer(bp /* &aStateSet */ + 1*16)).FaState = ((*ReStateSet)(unsafe.Pointer(bp /* &aStateSet */)).FaState + uintptr((*ReCompiled)(unsafe.Pointer(pRe)).FnState)*2) + pNext = (bp /* &aStateSet */ + 1*16) (*ReStateSet)(unsafe.Pointer(pNext)).FnState = uint32(0) re_add_state(tls, pNext, 0) __8: - if !((c != 0) && ((*ReStateSet)(unsafe.Pointer(pNext)).FnState > uint32(0))) { + if !((c != RE_EOF) && ((*ReStateSet)(unsafe.Pointer(pNext)).FnState > uint32(0))) { goto __9 } cPrev = c @@ -24533,35 +24001,35 @@ __10: } x1 = int32(*(*ReStateNumber)(unsafe.Pointer((*ReStateSet)(unsafe.Pointer(pThis)).FaState + uintptr(i)*2))) switch int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr(x1)))) { - case 1: + case RE_OP_MATCH: goto __14 - case 2: + case RE_OP_ANY: goto __15 - case 11: + case RE_OP_WORD: goto __16 - case 12: + case RE_OP_NOTWORD: goto __17 - case 13: + case RE_OP_DIGIT: goto __18 - case 14: + case RE_OP_NOTDIGIT: goto __19 - case 15: + case RE_OP_SPACE: goto __20 - case 16: + case RE_OP_NOTSPACE: goto __21 - case 17: + case RE_OP_BOUNDARY: goto __22 - case 3: + case RE_OP_ANYSTAR: goto __23 - case 4: + case RE_OP_FORK: goto __24 - case 5: + case RE_OP_GOTO: goto __25 - case 6: + case RE_OP_ACCEPT: goto __26 - case 7: + case RE_OP_CC_INC: goto __27 - case 8: + case RE_OP_CC_EXC: goto __28 } goto __13 @@ -24669,7 +24137,7 @@ __37: if !((j > 0) && (j < n)) { goto __39 } - if !(int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr((x1 + j))))) == 9) { + if !(int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr((x1 + j))))) == RE_OP_CC_VALUE) { goto __40 } if !(*(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaArg + uintptr((x1+j))*4)) == c) { @@ -24700,7 +24168,7 @@ __38: goto __39 __39: ; - if !(int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr(x1)))) == 8) { + if !(int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr(x1)))) == RE_OP_CC_EXC) { goto __45 } hit = libc.BoolInt32(!(hit != 0)) @@ -24731,7 +24199,7 @@ __47: if !(i < (*ReStateSet)(unsafe.Pointer(pNext)).FnState) { goto __49 } - if !(int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr(*(*ReStateNumber)(unsafe.Pointer((*ReStateSet)(unsafe.Pointer(pNext)).FaState + uintptr(i)*2)))))) == 6) { + 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) { goto __50 } rc = 1 @@ -24833,18 +24301,18 @@ func re_esc_char(tls *libc.TLS, p uintptr) uint32 { /* regexp.c:403:17: */ c = int8(*(*uint8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fz + uintptr((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi)))) if (int32(c) == 'u') && (((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi + 4) < (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fmx) { var zIn uintptr = ((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fz + uintptr((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi)) - if (((re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(1)))), bp /* &v */) != 0) && - (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(2)))), bp /* &v */) != 0)) && - (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(3)))), bp /* &v */) != 0)) && - (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(4)))), bp /* &v */) != 0) { + if (((re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + 1))), bp /* &v */) != 0) && + (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + 2))), bp /* &v */) != 0)) && + (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + 3))), bp /* &v */) != 0)) && + (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + 4))), bp /* &v */) != 0) { *(*int32)(unsafe.Pointer(p /* &.sIn */ + 8 /* &.i */)) += (5) return uint32(*(*int32)(unsafe.Pointer(bp /* v */))) } } if (int32(c) == 'x') && (((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi + 2) < (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fmx) { var zIn uintptr = ((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fz + uintptr((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi)) - if (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(1)))), bp /* &v */) != 0) && - (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(2)))), bp /* &v */) != 0) { + if (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + 1))), bp /* &v */) != 0) && + (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + 2))), bp /* &v */) != 0) { *(*int32)(unsafe.Pointer(p /* &.sIn */ + 8 /* &.i */)) += (3) return uint32(*(*int32)(unsafe.Pointer(bp /* v */))) } @@ -24888,8 +24356,8 @@ func re_subcompile_re(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:452:19: */ } for int32(rePeek(tls, p)) == '|' { iEnd = int32((*ReCompiled)(unsafe.Pointer(p)).FnState) - re_insert(tls, p, iStart, 4, ((iEnd + 2) - iStart)) - iGoto = re_append(tls, p, 5, 0) + re_insert(tls, p, iStart, RE_OP_FORK, ((iEnd + 2) - iStart)) + iGoto = re_append(tls, p, RE_OP_GOTO, 0) (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ zErr = re_subcompile_string(tls, p) if zErr != 0 { @@ -24937,10 +24405,10 @@ func re_subcompile_string(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:474:19 case uint32('.'): { if int32(rePeek(tls, p)) == '*' { - re_append(tls, p, 3, 0) + re_append(tls, p, RE_OP_ANYSTAR, 0) (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ } else { - re_append(tls, p, 2, 0) + re_append(tls, p, RE_OP_ANY, 0) } break @@ -24950,8 +24418,8 @@ func re_subcompile_string(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:474:19 if iPrev < 0 { return ts + 5935 /* "'*' without oper..." */ } - re_insert(tls, p, iPrev, 5, (int32(((*ReCompiled)(unsafe.Pointer(p)).FnState - uint32(iPrev)) + uint32(1)))) - re_append(tls, p, 4, (int32((uint32(iPrev) - (*ReCompiled)(unsafe.Pointer(p)).FnState) + uint32(1)))) + re_insert(tls, p, iPrev, RE_OP_GOTO, (int32(((*ReCompiled)(unsafe.Pointer(p)).FnState - uint32(iPrev)) + uint32(1)))) + re_append(tls, p, RE_OP_FORK, (int32((uint32(iPrev) - (*ReCompiled)(unsafe.Pointer(p)).FnState) + uint32(1)))) break } @@ -24960,7 +24428,7 @@ func re_subcompile_string(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:474:19 if iPrev < 0 { return ts + 5955 /* "'+' without oper..." */ } - re_append(tls, p, 4, (int32(uint32(iPrev) - (*ReCompiled)(unsafe.Pointer(p)).FnState))) + re_append(tls, p, RE_OP_FORK, (int32(uint32(iPrev) - (*ReCompiled)(unsafe.Pointer(p)).FnState))) break } @@ -24969,7 +24437,7 @@ func re_subcompile_string(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:474:19 if iPrev < 0 { return ts + 5975 /* "'?' without oper..." */ } - re_insert(tls, p, iPrev, 4, (int32(((*ReCompiled)(unsafe.Pointer(p)).FnState - uint32(iPrev)) + uint32(1)))) + re_insert(tls, p, iPrev, RE_OP_FORK, (int32(((*ReCompiled)(unsafe.Pointer(p)).FnState - uint32(iPrev)) + uint32(1)))) break } @@ -25007,7 +24475,7 @@ func re_subcompile_string(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:474:19 if n == 0 { return ts + 6058 /* "both m and n are..." */ } - re_insert(tls, p, iPrev, 4, (sz + 1)) + re_insert(tls, p, iPrev, RE_OP_FORK, (sz + 1)) n-- } else { for j = 1; j < m; j++ { @@ -25015,11 +24483,11 @@ func re_subcompile_string(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:474:19 } } for j = m; j < n; j++ { - re_append(tls, p, 4, (sz + 1)) + re_append(tls, p, RE_OP_FORK, (sz + 1)) re_copy(tls, p, iPrev, sz) } if (n == 0) && (m > 0) { - re_append(tls, p, 4, -sz) + re_append(tls, p, RE_OP_FORK, -sz) } break @@ -25028,10 +24496,10 @@ func re_subcompile_string(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:474:19 { var iFirst int32 = int32((*ReCompiled)(unsafe.Pointer(p)).FnState) if int32(rePeek(tls, p)) == '^' { - re_append(tls, p, 8, 0) + re_append(tls, p, RE_OP_CC_EXC, 0) (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ } else { - re_append(tls, p, 7, 0) + re_append(tls, p, RE_OP_CC_INC, 0) } for (libc.AssignUint32(&c, (*(*func(*libc.TLS, uintptr) uint32)(unsafe.Pointer((p + 40 /* &.xNextChar */))))(tls, (p /* &.sIn */)))) != uint32(0) { if (c == uint32('[')) && (int32(rePeek(tls, p)) == ':') { @@ -25041,15 +24509,15 @@ func re_subcompile_string(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:474:19 c = re_esc_char(tls, p) } if int32(rePeek(tls, p)) == '-' { - re_append(tls, p, 10, int32(c)) + re_append(tls, p, RE_OP_CC_RANGE, int32(c)) (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ c = (*(*func(*libc.TLS, uintptr) uint32)(unsafe.Pointer((p + 40 /* &.xNextChar */))))(tls, (p /* &.sIn */)) if c == uint32('\\') { c = re_esc_char(tls, p) } - re_append(tls, p, 10, int32(c)) + re_append(tls, p, RE_OP_CC_RANGE, int32(c)) } else { - re_append(tls, p, 9, int32(c)) + re_append(tls, p, RE_OP_CC_VALUE, int32(c)) } if int32(rePeek(tls, p)) == ']' { (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ @@ -25068,25 +24536,25 @@ func re_subcompile_string(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:474:19 var specialOp int32 = 0 switch int32(rePeek(tls, p)) { case 'b': - specialOp = 17 + specialOp = RE_OP_BOUNDARY break case 'd': - specialOp = 13 + specialOp = RE_OP_DIGIT break case 'D': - specialOp = 14 + specialOp = RE_OP_NOTDIGIT break case 's': - specialOp = 15 + specialOp = RE_OP_SPACE break case 'S': - specialOp = 16 + specialOp = RE_OP_NOTSPACE break case 'w': - specialOp = 11 + specialOp = RE_OP_WORD break case 'W': - specialOp = 12 + specialOp = RE_OP_NOTWORD break } if specialOp != 0 { @@ -25094,14 +24562,14 @@ func re_subcompile_string(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:474:19 re_append(tls, p, specialOp, 0) } else { c = re_esc_char(tls, p) - re_append(tls, p, 1, int32(c)) + re_append(tls, p, RE_OP_MATCH, int32(c)) } break } default: { - re_append(tls, p, 1, int32(c)) + re_append(tls, p, RE_OP_MATCH, int32(c)) break } @@ -25152,10 +24620,10 @@ func sqlite3re_compile(tls *libc.TLS, ppRe uintptr, zIn uintptr, noCase int32) u sqlite3re_free(tls, pRe) return ts + 1929 /* "out of memory" */ } - if int32(*(*int8)(unsafe.Pointer(zIn + uintptr(0)))) == '^' { + if int32(*(*int8)(unsafe.Pointer(zIn))) == '^' { zIn++ } else { - re_append(tls, pRe, 3, 0) + re_append(tls, pRe, RE_OP_ANYSTAR, 0) } (*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fz = zIn (*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fi = 0 @@ -25166,11 +24634,11 @@ func sqlite3re_compile(tls *libc.TLS, ppRe uintptr, zIn uintptr, noCase int32) u return zErr } if (int32(rePeek(tls, pRe)) == '$') && (((*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fi + 1) >= (*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fmx) { - re_append(tls, pRe, 1, 0) - re_append(tls, pRe, 6, 0) + re_append(tls, pRe, RE_OP_MATCH, RE_EOF) + re_append(tls, pRe, RE_OP_ACCEPT, 0) *(*uintptr)(unsafe.Pointer(ppRe)) = pRe } else if (*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fi >= (*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fmx { - re_append(tls, pRe, 6, 0) + re_append(tls, pRe, RE_OP_ACCEPT, 0) *(*uintptr)(unsafe.Pointer(ppRe)) = pRe } else { sqlite3re_free(tls, pRe) @@ -25185,10 +24653,10 @@ func sqlite3re_compile(tls *libc.TLS, ppRe uintptr, zIn uintptr, noCase int32) u // regex engine over the string. Do not worry able trying to match // unicode characters beyond plane 0 - those are very rare and this is // just an optimization. - if int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr(0)))) == 3 { + if int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp))) == RE_OP_ANYSTAR { j = 0 i = 1 - for ; (uint64(j) < (uint64(unsafe.Sizeof([12]uint8{})) - uint64(2))) && (int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr(i)))) == 1); i++ { + 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++ { var x uint32 = uint32(*(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaArg + uintptr(i)*4))) if x <= uint32(127) { *(*uint8)(unsafe.Pointer((pRe + 48 /* &.zInit */) + uintptr(libc.PostIncInt32(&j, 1)))) = uint8(x) @@ -25231,7 +24699,7 @@ func re_sql_func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* *(*uintptr)(unsafe.Pointer(bp /* pRe */)) = sqlite3.Xsqlite3_get_auxdata(tls, context, 0) if *(*uintptr)(unsafe.Pointer(bp /* pRe */)) == uintptr(0) { - zPattern = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zPattern = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zPattern == uintptr(0) { return } @@ -25247,7 +24715,7 @@ func re_sql_func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* } setAux = 1 } - zStr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zStr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if zStr != uintptr(0) { sqlite3.Xsqlite3_result_int(tls, context, sqlite3re_match(tls, *(*uintptr)(unsafe.Pointer(bp /* pRe */)), zStr, -1)) } @@ -25259,10 +24727,10 @@ func re_sql_func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* // Invoke this routine to register the regexp() function with the // SQLite database connection. func sqlite3_regexp_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* regexp.c:750:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi - rc = sqlite3.Xsqlite3_create_function(tls, db, ts+6165 /* "regexp" */, 2, (1 | 0x000200000), + rc = sqlite3.Xsqlite3_create_function(tls, db, ts+6165 /* "regexp" */, 2, (SQLITE_UTF8 | SQLITE_INNOCUOUS), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{re_sql_func})), uintptr(0), uintptr(0)) @@ -25722,8 +25190,8 @@ func rememberFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { /* re var v sqlite3_int64 var ptr uintptr - v = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - ptr = sqlite3.Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+3862 /* "carray" */) + v = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) + ptr = sqlite3.Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+3862 /* "carray" */) if ptr != 0 { *(*sqlite3_int64)(unsafe.Pointer(ptr)) = v } @@ -25731,10 +25199,10 @@ func rememberFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { /* re } func sqlite3_remember_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* remember.c:62:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi - rc = sqlite3.Xsqlite3_create_function(tls, db, ts+6172 /* "remember" */, 2, 1, uintptr(0), + rc = sqlite3.Xsqlite3_create_function(tls, db, ts+6172 /* "remember" */, 2, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rememberFunc})), uintptr(0), uintptr(0)) @@ -25779,13 +25247,13 @@ func seriesConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin rc = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+6181 /* "CREATE TABLE x(v..." */) - if rc == 0 { + if rc == SQLITE_OK { pNew = libc.AssignPtrUintptr(ppVtab, sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(sqlite3_vtab{})))) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(sqlite3_vtab{}))) - sqlite3.Xsqlite3_vtab_config(tls, db, 2, 0) + sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) } return rc } @@ -25793,7 +25261,7 @@ func seriesConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin // This method is the destructor for series_cursor objects. func seriesDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* series.c:137:12: */ sqlite3.Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // Constructor for a new series_cursor object. @@ -25801,17 +25269,17 @@ func seriesOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* series.c: var pCur uintptr pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(series_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(series_cursor{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Destructor for a series_cursor. func seriesClose(tls *libc.TLS, cur uintptr) int32 { /* series.c:157:12: */ sqlite3.Xsqlite3_free(tls, cur) - return 0 + return SQLITE_OK } // Advance a series_cursor to its next row of output. @@ -25823,7 +25291,7 @@ func seriesNext(tls *libc.TLS, cur uintptr) int32 { /* series.c:166:12: */ *(*sqlite3_int64)(unsafe.Pointer(pCur + 24 /* &.iValue */)) += ((*series_cursor)(unsafe.Pointer(pCur)).FiStep) } (*series_cursor)(unsafe.Pointer(pCur)).FiRowid++ - return 0 + return SQLITE_OK } // Return values of columns for the row at which the series_cursor @@ -25832,13 +25300,13 @@ func seriesColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* s var pCur uintptr = cur var x sqlite3_int64 = int64(0) switch i { - case 1: + case SERIES_COLUMN_START: x = (*series_cursor)(unsafe.Pointer(pCur)).FmnValue break - case 2: + case SERIES_COLUMN_STOP: x = (*series_cursor)(unsafe.Pointer(pCur)).FmxValue break - case 3: + case SERIES_COLUMN_STEP: x = (*series_cursor)(unsafe.Pointer(pCur)).FiStep break default: @@ -25846,7 +25314,7 @@ func seriesColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* s break } sqlite3.Xsqlite3_result_int64(tls, ctx, x) - return 0 + return SQLITE_OK } // Return the rowid for the current row. In this implementation, the @@ -25855,7 +25323,7 @@ func seriesColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* s func seriesRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* series.c:203:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*series_cursor)(unsafe.Pointer(pCur)).FiRowid - return 0 + return SQLITE_OK } // Return TRUE if the cursor has been moved off of the last @@ -25915,7 +25383,7 @@ func seriesFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp (*series_cursor)(unsafe.Pointer(pCur)).FiStep = int64(1) } for i = 0; i < argc; i++ { - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) == 5 { + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) == SQLITE_NULL { // If any of the constraints have a NULL value, then return no rows. // See ticket https://www.sqlite.org/src/info/fac496b61722daf2 (*series_cursor)(unsafe.Pointer(pCur)).FmnValue = int64(1) @@ -25934,7 +25402,7 @@ func seriesFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp (*series_cursor)(unsafe.Pointer(pCur)).FiValue = (*series_cursor)(unsafe.Pointer(pCur)).FmnValue } (*series_cursor)(unsafe.Pointer(pCur)).FiRowid = int64(1) - return 0 + return SQLITE_OK } // SQLite will invoke this method one or more times while planning a query @@ -25967,7 +25435,7 @@ func seriesBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* se // This implementation assumes that the start, stop, and step columns // are the last three columns in the virtual table. - *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(0)*4)) = libc.AssignPtrInt32(bp /* &aIdx */ +uintptr(1)*4, libc.AssignPtrInt32(bp /* &aIdx */ +uintptr(2)*4, -1)) + *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */)) = libc.AssignPtrInt32(bp /* &aIdx */ +1*4, libc.AssignPtrInt32(bp /* &aIdx */ +2*4, -1)) pConstraint = (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint i = 0 __1: @@ -25977,16 +25445,16 @@ __1: { var iCol int32 // 0 for start, 1 for stop, 2 for step var iMask int32 // bitmask for those column - if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < 1 { + if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < SERIES_COLUMN_START { goto __2 } - iCol = ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn - 1) + iCol = ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn - SERIES_COLUMN_START) iMask = (int32(1) << iCol) if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { unusableMask = unusableMask | (iMask) goto __2 - } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2 { + } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ { idxNum = idxNum | (iMask) *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(iCol)*4)) = i } @@ -26010,7 +25478,7 @@ __3: // The start, stop, and step columns are inputs. Therefore if there // are unusable constraints on any of start, stop, or step then // this plan is unusable - return 19 + return SQLITE_CONSTRAINT } if (idxNum & 3) == 3 { // Both start= and stop= boundaries are available. This is the @@ -26018,7 +25486,7 @@ __3: (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = (float64(2 - (libc.Bool32((idxNum & 4) != 0)))) (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1000) if (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1 { - if (*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).Fdesc != 0 { + if (*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc != 0 { idxNum = idxNum | (8) } (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 @@ -26030,61 +25498,32 @@ __3: (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(2147483647) } (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = idxNum - return 0 + return SQLITE_OK } // This following structure defines all the methods for the // generate_series virtual table. -var seriesModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - uintptr(0), - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - uintptr(0), - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename +var seriesModule = sqlite3_module{ // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRename } /* series.c:380:23 */ func sqlite3_series_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* series.c:408:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi if sqlite3.Xsqlite3_libversion_number(tls) < 3008012 { *(*uintptr)(unsafe.Pointer(pzErrMsg)) = sqlite3.Xsqlite3_mprintf(tls, ts+6240 /* "generate_series(..." */, 0) - return 1 + return SQLITE_ERROR } rc = sqlite3.Xsqlite3_create_module(tls, db, ts+6290 /* "generate_series" */, uintptr(unsafe.Pointer(&seriesModule)), uintptr(0)) return rc @@ -26179,97 +25618,97 @@ type u16 = uint16 /* spellfix.c:34:26 */ // The following table gives the character class for non-initial ASCII // characters. var midClass = [128]uint8{ - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(11) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(11) /* */, uint8(11) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(11), - /* ! */ uint8(12) /* " */, uint8(12) /* # */, uint8(12), - /* $ */ uint8(12) /* % */, uint8(12) /* & */, uint8(12), - /* ' */ uint8(0) /* ( */, uint8(12) /* ) */, uint8(12), - /* * */ uint8(12) /* + */, uint8(12) /* , */, uint8(12), - /* - */ uint8(12) /* . */, uint8(12) /* / */, uint8(12), - /* 0 */ uint8(10) /* 1 */, uint8(10) /* 2 */, uint8(10), - /* 3 */ uint8(10) /* 4 */, uint8(10) /* 5 */, uint8(10), - /* 6 */ uint8(10) /* 7 */, uint8(10) /* 8 */, uint8(10), - /* 9 */ uint8(10) /* : */, uint8(12) /* ; */, uint8(12), - /* < */ uint8(12) /* = */, uint8(12) /* > */, uint8(12), - /* ? */ uint8(12) /* @ */, uint8(12) /* A */, uint8(1), - /* B */ uint8(2) /* C */, uint8(3) /* D */, uint8(4), - /* E */ uint8(1) /* F */, uint8(2) /* G */, uint8(3), - /* H */ uint8(0) /* I */, uint8(1) /* J */, uint8(3), - /* K */ uint8(3) /* L */, uint8(6) /* M */, uint8(8), - /* N */ uint8(8) /* O */, uint8(1) /* P */, uint8(2), - /* Q */ uint8(3) /* R */, uint8(7) /* S */, uint8(3), - /* T */ uint8(4) /* U */, uint8(1) /* V */, uint8(2), - /* W */ uint8(2) /* X */, uint8(3) /* Y */, uint8(1), - /* Z */ uint8(3) /* [ */, uint8(12) /* \ */, uint8(12), - /* ] */ uint8(12) /* ^ */, uint8(12) /* _ */, uint8(12), - /* ` */ uint8(12) /* a */, uint8(1) /* b */, uint8(2), - /* c */ uint8(3) /* d */, uint8(4) /* e */, uint8(1), - /* f */ uint8(2) /* g */, uint8(3) /* h */, uint8(0), - /* i */ uint8(1) /* j */, uint8(3) /* k */, uint8(3), - /* l */ uint8(6) /* m */, uint8(8) /* n */, uint8(8), - /* o */ uint8(1) /* p */, uint8(2) /* q */, uint8(3), - /* r */ uint8(7) /* s */, uint8(3) /* t */, uint8(4), - /* u */ uint8(1) /* v */, uint8(2) /* w */, uint8(2), - /* x */ uint8(3) /* y */, uint8(1) /* z */, uint8(3), - /* { */ uint8(12) /* | */, uint8(12) /* } */, uint8(12), - /* ~ */ uint8(12) /* */, uint8(12), + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_SPACE /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_SPACE /* */, CCLASS_SPACE /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_SPACE, + /* ! */ CCLASS_OTHER /* " */, CCLASS_OTHER /* # */, CCLASS_OTHER, + /* $ */ CCLASS_OTHER /* % */, CCLASS_OTHER /* & */, CCLASS_OTHER, + /* ' */ CCLASS_SILENT /* ( */, CCLASS_OTHER /* ) */, CCLASS_OTHER, + /* * */ CCLASS_OTHER /* + */, CCLASS_OTHER /* , */, CCLASS_OTHER, + /* - */ CCLASS_OTHER /* . */, CCLASS_OTHER /* / */, CCLASS_OTHER, + /* 0 */ CCLASS_DIGIT /* 1 */, CCLASS_DIGIT /* 2 */, CCLASS_DIGIT, + /* 3 */ CCLASS_DIGIT /* 4 */, CCLASS_DIGIT /* 5 */, CCLASS_DIGIT, + /* 6 */ CCLASS_DIGIT /* 7 */, CCLASS_DIGIT /* 8 */, CCLASS_DIGIT, + /* 9 */ CCLASS_DIGIT /* : */, CCLASS_OTHER /* ; */, CCLASS_OTHER, + /* < */ CCLASS_OTHER /* = */, CCLASS_OTHER /* > */, CCLASS_OTHER, + /* ? */ CCLASS_OTHER /* @ */, CCLASS_OTHER /* A */, CCLASS_VOWEL, + /* B */ CCLASS_B /* C */, CCLASS_C /* D */, CCLASS_D, + /* E */ CCLASS_VOWEL /* F */, CCLASS_B /* G */, CCLASS_C, + /* H */ CCLASS_SILENT /* I */, CCLASS_VOWEL /* J */, CCLASS_C, + /* K */ CCLASS_C /* L */, CCLASS_L /* M */, CCLASS_M, + /* N */ CCLASS_M /* O */, CCLASS_VOWEL /* P */, CCLASS_B, + /* Q */ CCLASS_C /* R */, CCLASS_R /* S */, CCLASS_C, + /* T */ CCLASS_D /* U */, CCLASS_VOWEL /* V */, CCLASS_B, + /* W */ CCLASS_B /* X */, CCLASS_C /* Y */, CCLASS_VOWEL, + /* Z */ CCLASS_C /* [ */, CCLASS_OTHER /* \ */, CCLASS_OTHER, + /* ] */ CCLASS_OTHER /* ^ */, CCLASS_OTHER /* _ */, CCLASS_OTHER, + /* ` */ CCLASS_OTHER /* a */, CCLASS_VOWEL /* b */, CCLASS_B, + /* c */ CCLASS_C /* d */, CCLASS_D /* e */, CCLASS_VOWEL, + /* f */ CCLASS_B /* g */, CCLASS_C /* h */, CCLASS_SILENT, + /* i */ CCLASS_VOWEL /* j */, CCLASS_C /* k */, CCLASS_C, + /* l */ CCLASS_L /* m */, CCLASS_M /* n */, CCLASS_M, + /* o */ CCLASS_VOWEL /* p */, CCLASS_B /* q */, CCLASS_C, + /* r */ CCLASS_R /* s */, CCLASS_C /* t */, CCLASS_D, + /* u */ CCLASS_VOWEL /* v */, CCLASS_B /* w */, CCLASS_B, + /* x */ CCLASS_C /* y */, CCLASS_VOWEL /* z */, CCLASS_C, + /* { */ CCLASS_OTHER /* | */, CCLASS_OTHER /* } */, CCLASS_OTHER, + /* ~ */ CCLASS_OTHER /* */, CCLASS_OTHER, } /* spellfix.c:75:28 */ // This tables gives the character class for ASCII characters that form the // initial character of a word. The only difference from midClass is with // the letters H, W, and Y. var initClass = [128]uint8{ - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(11) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(11) /* */, uint8(11) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(12), - /* */ uint8(12) /* */, uint8(12) /* */, uint8(11), - /* ! */ uint8(12) /* " */, uint8(12) /* # */, uint8(12), - /* $ */ uint8(12) /* % */, uint8(12) /* & */, uint8(12), - /* ' */ uint8(12) /* ( */, uint8(12) /* ) */, uint8(12), - /* * */ uint8(12) /* + */, uint8(12) /* , */, uint8(12), - /* - */ uint8(12) /* . */, uint8(12) /* / */, uint8(12), - /* 0 */ uint8(10) /* 1 */, uint8(10) /* 2 */, uint8(10), - /* 3 */ uint8(10) /* 4 */, uint8(10) /* 5 */, uint8(10), - /* 6 */ uint8(10) /* 7 */, uint8(10) /* 8 */, uint8(10), - /* 9 */ uint8(10) /* : */, uint8(12) /* ; */, uint8(12), - /* < */ uint8(12) /* = */, uint8(12) /* > */, uint8(12), - /* ? */ uint8(12) /* @ */, uint8(12) /* A */, uint8(1), - /* B */ uint8(2) /* C */, uint8(3) /* D */, uint8(4), - /* E */ uint8(1) /* F */, uint8(2) /* G */, uint8(3), - /* H */ uint8(0) /* I */, uint8(1) /* J */, uint8(3), - /* K */ uint8(3) /* L */, uint8(6) /* M */, uint8(8), - /* N */ uint8(8) /* O */, uint8(1) /* P */, uint8(2), - /* Q */ uint8(3) /* R */, uint8(7) /* S */, uint8(3), - /* T */ uint8(4) /* U */, uint8(1) /* V */, uint8(2), - /* W */ uint8(2) /* X */, uint8(3) /* Y */, uint8(9), - /* Z */ uint8(3) /* [ */, uint8(12) /* \ */, uint8(12), - /* ] */ uint8(12) /* ^ */, uint8(12) /* _ */, uint8(12), - /* ` */ uint8(12) /* a */, uint8(1) /* b */, uint8(2), - /* c */ uint8(3) /* d */, uint8(4) /* e */, uint8(1), - /* f */ uint8(2) /* g */, uint8(3) /* h */, uint8(0), - /* i */ uint8(1) /* j */, uint8(3) /* k */, uint8(3), - /* l */ uint8(6) /* m */, uint8(8) /* n */, uint8(8), - /* o */ uint8(1) /* p */, uint8(2) /* q */, uint8(3), - /* r */ uint8(7) /* s */, uint8(3) /* t */, uint8(4), - /* u */ uint8(1) /* v */, uint8(2) /* w */, uint8(2), - /* x */ uint8(3) /* y */, uint8(9) /* z */, uint8(3), - /* { */ uint8(12) /* | */, uint8(12) /* } */, uint8(12), - /* ~ */ uint8(12) /* */, uint8(12), + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_SPACE /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_SPACE /* */, CCLASS_SPACE /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_OTHER, + /* */ CCLASS_OTHER /* */, CCLASS_OTHER /* */, CCLASS_SPACE, + /* ! */ CCLASS_OTHER /* " */, CCLASS_OTHER /* # */, CCLASS_OTHER, + /* $ */ CCLASS_OTHER /* % */, CCLASS_OTHER /* & */, CCLASS_OTHER, + /* ' */ CCLASS_OTHER /* ( */, CCLASS_OTHER /* ) */, CCLASS_OTHER, + /* * */ CCLASS_OTHER /* + */, CCLASS_OTHER /* , */, CCLASS_OTHER, + /* - */ CCLASS_OTHER /* . */, CCLASS_OTHER /* / */, CCLASS_OTHER, + /* 0 */ CCLASS_DIGIT /* 1 */, CCLASS_DIGIT /* 2 */, CCLASS_DIGIT, + /* 3 */ CCLASS_DIGIT /* 4 */, CCLASS_DIGIT /* 5 */, CCLASS_DIGIT, + /* 6 */ CCLASS_DIGIT /* 7 */, CCLASS_DIGIT /* 8 */, CCLASS_DIGIT, + /* 9 */ CCLASS_DIGIT /* : */, CCLASS_OTHER /* ; */, CCLASS_OTHER, + /* < */ CCLASS_OTHER /* = */, CCLASS_OTHER /* > */, CCLASS_OTHER, + /* ? */ CCLASS_OTHER /* @ */, CCLASS_OTHER /* A */, CCLASS_VOWEL, + /* B */ CCLASS_B /* C */, CCLASS_C /* D */, CCLASS_D, + /* E */ CCLASS_VOWEL /* F */, CCLASS_B /* G */, CCLASS_C, + /* H */ CCLASS_SILENT /* I */, CCLASS_VOWEL /* J */, CCLASS_C, + /* K */ CCLASS_C /* L */, CCLASS_L /* M */, CCLASS_M, + /* N */ CCLASS_M /* O */, CCLASS_VOWEL /* P */, CCLASS_B, + /* Q */ CCLASS_C /* R */, CCLASS_R /* S */, CCLASS_C, + /* T */ CCLASS_D /* U */, CCLASS_VOWEL /* V */, CCLASS_B, + /* W */ CCLASS_B /* X */, CCLASS_C /* Y */, CCLASS_Y, + /* Z */ CCLASS_C /* [ */, CCLASS_OTHER /* \ */, CCLASS_OTHER, + /* ] */ CCLASS_OTHER /* ^ */, CCLASS_OTHER /* _ */, CCLASS_OTHER, + /* ` */ CCLASS_OTHER /* a */, CCLASS_VOWEL /* b */, CCLASS_B, + /* c */ CCLASS_C /* d */, CCLASS_D /* e */, CCLASS_VOWEL, + /* f */ CCLASS_B /* g */, CCLASS_C /* h */, CCLASS_SILENT, + /* i */ CCLASS_VOWEL /* j */, CCLASS_C /* k */, CCLASS_C, + /* l */ CCLASS_L /* m */, CCLASS_M /* n */, CCLASS_M, + /* o */ CCLASS_VOWEL /* p */, CCLASS_B /* q */, CCLASS_C, + /* r */ CCLASS_R /* s */, CCLASS_C /* t */, CCLASS_D, + /* u */ CCLASS_VOWEL /* v */, CCLASS_B /* w */, CCLASS_B, + /* x */ CCLASS_C /* y */, CCLASS_Y /* z */, CCLASS_C, + /* { */ CCLASS_OTHER /* | */, CCLASS_OTHER /* } */, CCLASS_OTHER, + /* ~ */ CCLASS_OTHER /* */, CCLASS_OTHER, } /* spellfix.c:125:28 */ // Mapping from the character class number (0-13) to a symbol for each @@ -26303,12 +25742,12 @@ func phoneticHash(tls *libc.TLS, zIn uintptr, nIn int32) uintptr { /* spellfix.c return uintptr(0) } if nIn > 2 { - switch int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(0)))) { + switch int32(*(*uint8)(unsafe.Pointer(zIn))) { case 'g': fallthrough case 'k': { - if int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(1)))) == 'n' { + if int32(*(*uint8)(unsafe.Pointer(zIn + 1))) == 'n' { zIn++ nIn-- } @@ -26333,21 +25772,21 @@ func phoneticHash(tls *libc.TLS, zIn uintptr, nIn int32) uintptr { /* spellfix.c } } c = *(*uint8)(unsafe.Pointer(aClass + uintptr((int32(c) & 0x7f)))) - if int32(c) == 11 { + if int32(c) == CCLASS_SPACE { continue } - if (int32(c) == 12) && (int32(cPrev) != 10) { + if (int32(c) == CCLASS_OTHER) && (int32(cPrev) != CCLASS_DIGIT) { continue } aClass = uintptr(unsafe.Pointer(&midClass)) - if (int32(c) == 1) && ((int32(cPrevX) == 7) || (int32(cPrevX) == 6)) { + if (int32(c) == CCLASS_VOWEL) && ((int32(cPrevX) == CCLASS_R) || (int32(cPrevX) == CCLASS_L)) { continue /* No vowels beside L or R */ } - if ((int32(c) == 7) || (int32(c) == 6)) && (int32(cPrevX) == 1) { + if ((int32(c) == CCLASS_R) || (int32(c) == CCLASS_L)) && (int32(cPrevX) == CCLASS_VOWEL) { nOut-- // No vowels beside L or R } cPrev = int8(c) - if int32(c) == 0 { + if int32(c) == CCLASS_SILENT { continue } cPrevX = int8(c) @@ -26367,11 +25806,11 @@ func phoneticHashSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintpt var zIn uintptr var zOut uintptr - zIn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zIn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zIn == uintptr(0) { return } - zOut = phoneticHash(tls, zIn, sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + zOut = phoneticHash(tls, zIn, sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) if zOut == uintptr(0) { sqlite3.Xsqlite3_result_error_nomem(tls, context) } else { @@ -26395,7 +25834,7 @@ func insertOrDeleteCost(tls *libc.TLS, cPrev int8, c int8, cNext int8) int32 { / var classC int8 = characterClass(tls, cPrev, c) var classCprev int8 - if int32(classC) == 0 { + if int32(classC) == CCLASS_SILENT { // Insert or delete "silent" characters such as H or W return 1 } @@ -26403,12 +25842,12 @@ func insertOrDeleteCost(tls *libc.TLS, cPrev int8, c int8, cNext int8) int32 { / // Repeated characters, or miss a repeat return 10 } - if (int32(classC) == 1) && ((int32(cPrev) == 'r') || (int32(cNext) == 'r')) { + if (int32(classC) == CCLASS_VOWEL) && ((int32(cPrev) == 'r') || (int32(cNext) == 'r')) { return 20 // Insert a vowel before or after 'r' } classCprev = characterClass(tls, cPrev, cPrev) if int32(classC) == int32(classCprev) { - if int32(classC) == 1 { + if int32(classC) == CCLASS_VOWEL { // Remove or add a new vowel to a vowel cluster return 15 } else { @@ -26444,8 +25883,8 @@ func substituteCost(tls *libc.TLS, cPrev int8, cFrom int8, cTo int8) int32 { /* // Same character class return 40 } - if (((int32(classFrom) >= 2) && (int32(classFrom) <= 9)) && - (int32(classTo) >= 2)) && (int32(classTo) <= 9) { + if (((int32(classFrom) >= CCLASS_B) && (int32(classFrom) <= CCLASS_Y)) && + (int32(classTo) >= CCLASS_B)) && (int32(classTo) <= CCLASS_Y) { // Convert from one consonant to another, but in a different class return 75 } @@ -26500,8 +25939,8 @@ func editdist1(tls *libc.TLS, zA uintptr, zB uintptr, pnMatch uintptr) int32 { / } // Skip any common prefix - for (*(*int8)(unsafe.Pointer(zA + uintptr(0))) != 0) && (int32(*(*int8)(unsafe.Pointer(zA + uintptr(0)))) == int32(*(*int8)(unsafe.Pointer(zB + uintptr(0))))) { - dc = int32(*(*int8)(unsafe.Pointer(zA + uintptr(0)))) + for (*(*int8)(unsafe.Pointer(zA)) != 0) && (int32(*(*int8)(unsafe.Pointer(zA))) == int32(*(*int8)(unsafe.Pointer(zB)))) { + dc = int32(*(*int8)(unsafe.Pointer(zA))) zA++ zB++ nMatch++ @@ -26509,7 +25948,7 @@ func editdist1(tls *libc.TLS, zA uintptr, zB uintptr, pnMatch uintptr) int32 { / if pnMatch != 0 { *(*int32)(unsafe.Pointer(pnMatch)) = nMatch } - if (int32(*(*int8)(unsafe.Pointer(zA + uintptr(0)))) == 0) && (int32(*(*int8)(unsafe.Pointer(zB + uintptr(0)))) == 0) { + if (int32(*(*int8)(unsafe.Pointer(zA))) == 0) && (int32(*(*int8)(unsafe.Pointer(zB))) == 0) { return 0 } @@ -26529,7 +25968,7 @@ func editdist1(tls *libc.TLS, zA uintptr, zB uintptr, pnMatch uintptr) int32 { / if nA == 0 { cBprev = int8(dc) for xB = libc.AssignInt32(&res, 0); (int32(libc.AssignInt8(&cB, *(*int8)(unsafe.Pointer(zB + uintptr(xB)))))) != 0; xB++ { - res = res + (insertOrDeleteCost(tls, cBprev, cB, *(*int8)(unsafe.Pointer(zB + uintptr((xB + 1))))) / 4) + res = res + (insertOrDeleteCost(tls, cBprev, cB, *(*int8)(unsafe.Pointer(zB + uintptr((xB + 1))))) / FINAL_INS_COST_DIV) cBprev = cB } return res @@ -26544,7 +25983,7 @@ func editdist1(tls *libc.TLS, zA uintptr, zB uintptr, pnMatch uintptr) int32 { / } // A is a prefix of B - if (int32(*(*int8)(unsafe.Pointer(zA + uintptr(0)))) == '*') && (int32(*(*int8)(unsafe.Pointer(zA + uintptr(1)))) == 0) { + if (int32(*(*int8)(unsafe.Pointer(zA))) == '*') && (int32(*(*int8)(unsafe.Pointer(zA + 1))) == 0) { return 0 } @@ -26560,8 +25999,8 @@ func editdist1(tls *libc.TLS, zA uintptr, zB uintptr, pnMatch uintptr) int32 { / cx = (m + uintptr((nB+1))*4) // Compute the Wagner edit distance - *(*int32)(unsafe.Pointer(m + uintptr(0)*4)) = 0 - *(*int8)(unsafe.Pointer(cx + uintptr(0))) = int8(dc) + *(*int32)(unsafe.Pointer(m)) = 0 + *(*int8)(unsafe.Pointer(cx)) = int8(dc) cBprev = int8(dc) for xB = 1; xB <= nB; xB++ { cBnext = *(*int8)(unsafe.Pointer(zB + uintptr(xB))) @@ -26578,9 +26017,9 @@ func editdist1(tls *libc.TLS, zA uintptr, zB uintptr, pnMatch uintptr) int32 { / if (int32(cA) == '*') && (lastA != 0) { break } - d = *(*int32)(unsafe.Pointer(m + uintptr(0)*4)) - dc = int32(*(*int8)(unsafe.Pointer(cx + uintptr(0)))) - *(*int32)(unsafe.Pointer(m + uintptr(0)*4)) = (d + insertOrDeleteCost(tls, cAprev, cA, cAnext)) + d = *(*int32)(unsafe.Pointer(m)) + dc = int32(*(*int8)(unsafe.Pointer(cx))) + *(*int32)(unsafe.Pointer(m)) = (d + insertOrDeleteCost(tls, cAprev, cA, cAnext)) cBprev = int8(0) for xB = 1; xB <= nB; xB++ { var totalCost int32 @@ -26594,7 +26033,7 @@ func editdist1(tls *libc.TLS, zA uintptr, zB uintptr, pnMatch uintptr) int32 { / // Cost to insert cB insCost = insertOrDeleteCost(tls, *(*int8)(unsafe.Pointer(cx + uintptr((xB - 1)))), cB, cBnext) if lastA != 0 { - insCost = insCost / (4) + insCost = insCost / (FINAL_INS_COST_DIV) } // Cost to delete cA @@ -26626,7 +26065,7 @@ func editdist1(tls *libc.TLS, zA uintptr, zB uintptr, pnMatch uintptr) int32 { / // Free the wagner matrix and return the result if int32(cA) == '*' { - res = *(*int32)(unsafe.Pointer(m + uintptr(1)*4)) + res = *(*int32)(unsafe.Pointer(m + 1*4)) for xB = 1; xB <= nB; xB++ { if *(*int32)(unsafe.Pointer(m + uintptr(xB)*4)) < res { res = *(*int32)(unsafe.Pointer(m + uintptr(xB)*4)) @@ -26653,8 +26092,8 @@ func editdist1(tls *libc.TLS, zA uintptr, zB uintptr, pnMatch uintptr) int32 { / // cost. func editdistSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* spellfix.c:518:13: */ var res int32 = editdist1(tls, - sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))), - sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))), + sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), + sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))), uintptr(0)) if res < 0 { if res == (-3) { @@ -26739,12 +26178,7 @@ type EditDist3Lang1 = struct { type EditDist3Lang = EditDist3Lang1 /* spellfix.c:553:30 */ // The default EditDist3Lang object, with default costs. -var editDist3Lang = EditDist3Lang{ - FiLang: 0, - FiInsCost: 100, - FiDelCost: 100, - FiSubCost: 150, - FpCost: uintptr(0)} /* spellfix.c:583:28 */ +var editDist3Lang = EditDist3Lang{FiInsCost: 100, FiDelCost: 100, FiSubCost: 150} /* spellfix.c:583:28 */ // Clear or delete an instance of the object that records all edit-distance // weights. @@ -26827,8 +26261,8 @@ func editDist3CostSort(tls *libc.TLS, pList uintptr) uintptr { /* spellfix.c:707 var p uintptr var i int32 var mx int32 = 0 - *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */ + uintptr(0)*8)) = uintptr(0) - *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */ + uintptr(1)*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */ + 1*8)) = uintptr(0) for pList != 0 { p = pList pList = (*EditDist3Cost)(unsafe.Pointer(p)).FpNext @@ -26868,7 +26302,7 @@ func editDist3ConfigLoad(tls *libc.TLS, p uintptr, db uintptr, zTable uintptr) i zSql = sqlite3.Xsqlite3_mprintf(tls, ts+6375 /* "SELECT iLang, cF..." */, libc.VaList(bp, zTable)) if zSql == uintptr(0) { - return 7 + return SQLITE_NOMEM } rc = sqlite3.Xsqlite3_prepare(tls, db, zSql, -1, bp+8 /* &pStmt */, uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) @@ -26876,7 +26310,7 @@ func editDist3ConfigLoad(tls *libc.TLS, p uintptr, db uintptr, zTable uintptr) i return rc } editDist3ConfigClear(tls, p) - for sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) == 100 { + for sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) == SQLITE_ROW { var iLang int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 0) var zFrom uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) var nFrom int32 @@ -26907,7 +26341,7 @@ func editDist3ConfigLoad(tls *libc.TLS, p uintptr, db uintptr, zTable uintptr) i var pNew uintptr pNew = sqlite3.Xsqlite3_realloc64(tls, (*EditDist3Config)(unsafe.Pointer(p)).Fa, (uint64((uint64((*EditDist3Config)(unsafe.Pointer(p)).FnLang + 1)) * uint64(unsafe.Sizeof(EditDist3Lang{}))))) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM break } (*EditDist3Config)(unsafe.Pointer(p)).Fa = pNew @@ -26920,11 +26354,11 @@ func editDist3ConfigLoad(tls *libc.TLS, p uintptr, db uintptr, zTable uintptr) i (*EditDist3Lang)(unsafe.Pointer(pLang)).FpCost = uintptr(0) iLangPrev = iLang } - if ((nFrom == 1) && (int32(*(*int8)(unsafe.Pointer(zFrom + uintptr(0)))) == '?')) && (nTo == 0) { + if ((nFrom == 1) && (int32(*(*int8)(unsafe.Pointer(zFrom))) == '?')) && (nTo == 0) { (*EditDist3Lang)(unsafe.Pointer(pLang)).FiDelCost = iCost - } else if ((nFrom == 0) && (nTo == 1)) && (int32(*(*int8)(unsafe.Pointer(zTo + uintptr(0)))) == '?') { + } else if ((nFrom == 0) && (nTo == 1)) && (int32(*(*int8)(unsafe.Pointer(zTo))) == '?') { (*EditDist3Lang)(unsafe.Pointer(pLang)).FiInsCost = iCost - } else if (((nFrom == 1) && (nTo == 1)) && (int32(*(*int8)(unsafe.Pointer(zFrom + uintptr(0)))) == '?')) && (int32(*(*int8)(unsafe.Pointer(zTo + uintptr(0)))) == '?') { + } else if (((nFrom == 1) && (nTo == 1)) && (int32(*(*int8)(unsafe.Pointer(zFrom))) == '?')) && (int32(*(*int8)(unsafe.Pointer(zTo))) == '?') { (*EditDist3Lang)(unsafe.Pointer(pLang)).FiSubCost = iCost } else { var pCost uintptr @@ -26934,7 +26368,7 @@ func editDist3ConfigLoad(tls *libc.TLS, p uintptr, db uintptr, zTable uintptr) i } pCost = sqlite3.Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(EditDist3Cost{})) + uint64(nExtra)))) if pCost == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM break } (*EditDist3Cost)(unsafe.Pointer(pCost)).FnFrom = u8(nFrom) @@ -26947,10 +26381,10 @@ func editDist3ConfigLoad(tls *libc.TLS, p uintptr, db uintptr, zTable uintptr) i } } rc2 = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } - if rc == 0 { + if rc == SQLITE_OK { var iLang int32 for iLang = 0; iLang < (*EditDist3Config)(unsafe.Pointer(p)).FnLang; iLang++ { (*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) @@ -26982,7 +26416,7 @@ func utf8Len(tls *libc.TLS, c uint8, N int32) int32 { /* spellfix.c:818:12: */ // the given string. func matchTo(tls *libc.TLS, p uintptr, z uintptr, n int32) int32 { /* spellfix.c:837:12: */ - if int32(*(*int8)(unsafe.Pointer((p + 12 /* &.a */) + uintptr((*EditDist3Cost)(unsafe.Pointer(p)).FnFrom)))) != int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) { + if int32(*(*int8)(unsafe.Pointer((p + 12 /* &.a */) + uintptr((*EditDist3Cost)(unsafe.Pointer(p)).FnFrom)))) != int32(*(*int8)(unsafe.Pointer(z))) { return 0 } if int32((*EditDist3Cost)(unsafe.Pointer(p)).FnTo) > n { @@ -26999,7 +26433,7 @@ func matchTo(tls *libc.TLS, p uintptr, z uintptr, n int32) int32 { /* spellfix.c func matchFrom(tls *libc.TLS, p uintptr, z uintptr, n int32) int32 { /* spellfix.c:849:12: */ if (*EditDist3Cost)(unsafe.Pointer(p)).FnFrom != 0 { - if int32(*(*int8)(unsafe.Pointer((p + 12 /* &.a */) + uintptr(0)))) != int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) { + if int32(*(*int8)(unsafe.Pointer((p + 12 /* &.a */)))) != int32(*(*int8)(unsafe.Pointer(z))) { return 0 } if libc.Xstrncmp(tls, p+12 /* &.a */, z, uint64((*EditDist3Cost)(unsafe.Pointer(p)).FnFrom)) != 0 { @@ -27017,7 +26451,7 @@ func matchFromTo(tls *libc.TLS, pStr uintptr, n1 int32, z2 uintptr, n2 int32) in return 0 } - if int32(*(*int8)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(pStr)).Fz + uintptr(n1)))) != int32(*(*int8)(unsafe.Pointer(z2 + uintptr(0)))) { + if int32(*(*int8)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(pStr)).Fz + uintptr(n1)))) != int32(*(*int8)(unsafe.Pointer(z2))) { return 0 } if libc.Xstrncmp(tls, ((*EditDist3FromString)(unsafe.Pointer(pStr)).Fz+uintptr(n1)), z2, uint64(b1)) != 0 { @@ -27054,7 +26488,7 @@ func editDist3FromStringNew(tls *libc.TLS, pLang uintptr, z uintptr, n int32) ui if pStr == uintptr(0) { return uintptr(0) } - (*EditDist3FromString)(unsafe.Pointer(pStr)).Fa = (pStr + uintptr(1)*24) + (*EditDist3FromString)(unsafe.Pointer(pStr)).Fa = (pStr + 1*24) libc.Xmemset(tls, (*EditDist3FromString)(unsafe.Pointer(pStr)).Fa, 0, (uint64(unsafe.Sizeof(EditDist3From{})) * uint64(n))) (*EditDist3FromString)(unsafe.Pointer(pStr)).Fn = n (*EditDist3FromString)(unsafe.Pointer(pStr)).Fz = ((*EditDist3FromString)(unsafe.Pointer(pStr)).Fa + uintptr(n)*32) @@ -27168,7 +26602,7 @@ func editDist3Core(tls *libc.TLS, pFrom uintptr, z2 uintptr, n2 int32, pLang uin // allocate the Wagner matrix and the aTo[] array for the TO string n = (((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fn + 1) * (n2 + 1)) - n = ((n + 1) & ^libc.Int32(1)) + n = ((n + 1) & libc.CplInt32(1)) nByte = (sqlite3_uint64((uint64(n) * uint64(unsafe.Sizeof(uint32(0)))) + (uint64(unsafe.Sizeof(EditDist3To{})) * uint64(n2)))) if !(nByte <= sqlite3_uint64(unsafe.Sizeof([256]uint32{}))) { goto __1 @@ -27213,7 +26647,7 @@ __10: goto __8 __11: ; - if !(int32(*(*int8)(unsafe.Pointer((p + 12 /* &.a */) + uintptr(0)))) > int32(*(*int8)(unsafe.Pointer(z2 + uintptr(i2))))) { + if !(int32(*(*int8)(unsafe.Pointer((p + 12 /* &.a */)))) > int32(*(*int8)(unsafe.Pointer(z2 + uintptr(i2))))) { goto __12 } goto __9 @@ -27254,7 +26688,7 @@ __6: // Prepare to compute the minimum edit distance szRow = ((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fn + 1) libc.Xmemset(tls, m, 0x01, ((uint64((n2 + 1) * szRow)) * uint64(unsafe.Sizeof(uint32(0))))) - *(*uint32)(unsafe.Pointer(m + uintptr(0)*4)) = uint32(0) + *(*uint32)(unsafe.Pointer(m)) = uint32(0) // First fill in the top-row of the matrix with FROM deletion costs i1 = 0 @@ -27472,19 +26906,19 @@ func editDist3SqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) var db uintptr = sqlite3.Xsqlite3_context_db_handle(tls, context) var rc int32 if argc == 1 { - var zTable uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zTable uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) rc = editDist3ConfigLoad(tls, pConfig, db, zTable) if rc != 0 { sqlite3.Xsqlite3_result_error_code(tls, context, rc) } } else { - var zA uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var zB uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - var nA int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var nB int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + var zA uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + var zB uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + var nA int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + var nB int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) var iLang int32 if argc == 3 { - iLang = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + iLang = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) } else { iLang = 0 } @@ -27512,24 +26946,24 @@ func editDist3Install(tls *libc.TLS, db uintptr) int32 { /* spellfix.c:1210:12: var rc int32 var pConfig uintptr = sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(EditDist3Config{}))) if pConfig == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pConfig, 0, uint64(unsafe.Sizeof(EditDist3Config{}))) rc = sqlite3.Xsqlite3_create_function_v2(tls, db, ts+6447, /* "editdist3" */ - 2, (1 | 0x000000800), pConfig, + 2, (SQLITE_UTF8 | SQLITE_DETERMINISTIC), pConfig, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{editDist3SqlFunc})), uintptr(0), uintptr(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_function_v2(tls, db, ts+6447, /* "editdist3" */ - 3, (1 | 0x000000800), pConfig, + 3, (SQLITE_UTF8 | SQLITE_DETERMINISTIC), pConfig, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{editDist3SqlFunc})), uintptr(0), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_function_v2(tls, db, ts+6447, /* "editdist3" */ - 1, (1 | 0x000000800), pConfig, + 1, (SQLITE_UTF8 | SQLITE_DETERMINISTIC), pConfig, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{editDist3SqlFunc})), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{editDist3ConfigDelete}))) @@ -27567,7 +27001,7 @@ func utf8Read(tls *libc.TLS, z uintptr, n int32, pSize uintptr) int32 { /* spell if 0 != 0 { c = libc.AssignInt32(&i, 0) } else { - c = int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) + c = int32(*(*uint8)(unsafe.Pointer(z))) i = 1 if c >= 0xc0 { c = int32(sqlite3Utf8Trans1[(c - 0xc0)]) @@ -27609,2340 +27043,395 @@ type Transliteration = Transliteration1 /* spellfix.c:1294:32 */ // Table of translations from unicode characters into ASCII. var translit = [389]Transliteration{ - { - FcFrom: uint16(0x00A0), - FcTo0: uint8(0x20), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, //   to - { - FcFrom: uint16(0x00B5), - FcTo0: uint8(0x75), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // µ to u - { - FcFrom: uint16(0x00C0), - FcTo0: uint8(0x41), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // À to A - { - FcFrom: uint16(0x00C1), - FcTo0: uint8(0x41), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Á to A - { - FcFrom: uint16(0x00C2), - FcTo0: uint8(0x41), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, //  to A - { - FcFrom: uint16(0x00C3), - FcTo0: uint8(0x41), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // à to A - { - FcFrom: uint16(0x00C4), - FcTo0: uint8(0x41), - FcTo1: uint8(0x65), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ä to Ae - { - FcFrom: uint16(0x00C5), - FcTo0: uint8(0x41), - FcTo1: uint8(0x61), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Å to Aa - { - FcFrom: uint16(0x00C6), - FcTo0: uint8(0x41), - FcTo1: uint8(0x45), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Æ to AE - { - FcFrom: uint16(0x00C7), - FcTo0: uint8(0x43), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ç to C - { - FcFrom: uint16(0x00C8), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // È to E - { - FcFrom: uint16(0x00C9), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // É to E - { - FcFrom: uint16(0x00CA), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ê to E - { - FcFrom: uint16(0x00CB), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ë to E - { - FcFrom: uint16(0x00CC), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ì to I - { - FcFrom: uint16(0x00CD), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Í to I - { - FcFrom: uint16(0x00CE), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Î to I - { - FcFrom: uint16(0x00CF), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ï to I - { - FcFrom: uint16(0x00D0), - FcTo0: uint8(0x44), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ð to D - { - FcFrom: uint16(0x00D1), - FcTo0: uint8(0x4E), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ñ to N - { - FcFrom: uint16(0x00D2), - FcTo0: uint8(0x4F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ò to O - { - FcFrom: uint16(0x00D3), - FcTo0: uint8(0x4F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ó to O - { - FcFrom: uint16(0x00D4), - FcTo0: uint8(0x4F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ô to O - { - FcFrom: uint16(0x00D5), - FcTo0: uint8(0x4F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Õ to O - { - FcFrom: uint16(0x00D6), - FcTo0: uint8(0x4F), - FcTo1: uint8(0x65), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ö to Oe - { - FcFrom: uint16(0x00D7), - FcTo0: uint8(0x78), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // × to x - { - FcFrom: uint16(0x00D8), - FcTo0: uint8(0x4F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ø to O - { - FcFrom: uint16(0x00D9), - FcTo0: uint8(0x55), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ù to U - { - FcFrom: uint16(0x00DA), - FcTo0: uint8(0x55), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ú to U - { - FcFrom: uint16(0x00DB), - FcTo0: uint8(0x55), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Û to U - { - FcFrom: uint16(0x00DC), - FcTo0: uint8(0x55), - FcTo1: uint8(0x65), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ü to Ue - { - FcFrom: uint16(0x00DD), - FcTo0: uint8(0x59), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ý to Y - { - FcFrom: uint16(0x00DE), - FcTo0: uint8(0x54), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Þ to Th - { - FcFrom: uint16(0x00DF), - FcTo0: uint8(0x73), - FcTo1: uint8(0x73), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ß to ss - { - FcFrom: uint16(0x00E0), - FcTo0: uint8(0x61), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // à to a - { - FcFrom: uint16(0x00E1), - FcTo0: uint8(0x61), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // á to a - { - FcFrom: uint16(0x00E2), - FcTo0: uint8(0x61), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // â to a - { - FcFrom: uint16(0x00E3), - FcTo0: uint8(0x61), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ã to a - { - FcFrom: uint16(0x00E4), - FcTo0: uint8(0x61), - FcTo1: uint8(0x65), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ä to ae - { - FcFrom: uint16(0x00E5), - FcTo0: uint8(0x61), - FcTo1: uint8(0x61), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // å to aa - { - FcFrom: uint16(0x00E6), - FcTo0: uint8(0x61), - FcTo1: uint8(0x65), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // æ to ae - { - FcFrom: uint16(0x00E7), - FcTo0: uint8(0x63), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ç to c - { - FcFrom: uint16(0x00E8), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // è to e - { - FcFrom: uint16(0x00E9), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // é to e - { - FcFrom: uint16(0x00EA), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ê to e - { - FcFrom: uint16(0x00EB), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ë to e - { - FcFrom: uint16(0x00EC), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ì to i - { - FcFrom: uint16(0x00ED), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // í to i - { - FcFrom: uint16(0x00EE), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // î to i - { - FcFrom: uint16(0x00EF), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ï to i - { - FcFrom: uint16(0x00F0), - FcTo0: uint8(0x64), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ð to d - { - FcFrom: uint16(0x00F1), - FcTo0: uint8(0x6E), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ñ to n - { - FcFrom: uint16(0x00F2), - FcTo0: uint8(0x6F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ò to o - { - FcFrom: uint16(0x00F3), - FcTo0: uint8(0x6F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ó to o - { - FcFrom: uint16(0x00F4), - FcTo0: uint8(0x6F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ô to o - { - FcFrom: uint16(0x00F5), - FcTo0: uint8(0x6F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // õ to o - { - FcFrom: uint16(0x00F6), - FcTo0: uint8(0x6F), - FcTo1: uint8(0x65), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ö to oe - { - FcFrom: uint16(0x00F7), - FcTo0: uint8(0x3A), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ÷ to : - { - FcFrom: uint16(0x00F8), - FcTo0: uint8(0x6F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ø to o - { - FcFrom: uint16(0x00F9), - FcTo0: uint8(0x75), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ù to u - { - FcFrom: uint16(0x00FA), - FcTo0: uint8(0x75), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ú to u - { - FcFrom: uint16(0x00FB), - FcTo0: uint8(0x75), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // û to u - { - FcFrom: uint16(0x00FC), - FcTo0: uint8(0x75), - FcTo1: uint8(0x65), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ü to ue - { - FcFrom: uint16(0x00FD), - FcTo0: uint8(0x79), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ý to y - { - FcFrom: uint16(0x00FE), - FcTo0: uint8(0x74), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // þ to th - { - FcFrom: uint16(0x00FF), - FcTo0: uint8(0x79), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ÿ to y - { - FcFrom: uint16(0x0100), - FcTo0: uint8(0x41), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ā to A - { - FcFrom: uint16(0x0101), - FcTo0: uint8(0x61), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ā to a - { - FcFrom: uint16(0x0102), - FcTo0: uint8(0x41), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ă to A - { - FcFrom: uint16(0x0103), - FcTo0: uint8(0x61), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ă to a - { - FcFrom: uint16(0x0104), - FcTo0: uint8(0x41), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ą to A - { - FcFrom: uint16(0x0105), - FcTo0: uint8(0x61), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ą to a - { - FcFrom: uint16(0x0106), - FcTo0: uint8(0x43), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ć to C - { - FcFrom: uint16(0x0107), - FcTo0: uint8(0x63), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ć to c - { - FcFrom: uint16(0x0108), - FcTo0: uint8(0x43), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ĉ to Ch - { - FcFrom: uint16(0x0109), - FcTo0: uint8(0x63), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ĉ to ch - { - FcFrom: uint16(0x010A), - FcTo0: uint8(0x43), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ċ to C - { - FcFrom: uint16(0x010B), - FcTo0: uint8(0x63), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ċ to c - { - FcFrom: uint16(0x010C), - FcTo0: uint8(0x43), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Č to C - { - FcFrom: uint16(0x010D), - FcTo0: uint8(0x63), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // č to c - { - FcFrom: uint16(0x010E), - FcTo0: uint8(0x44), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ď to D - { - FcFrom: uint16(0x010F), - FcTo0: uint8(0x64), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ď to d - { - FcFrom: uint16(0x0110), - FcTo0: uint8(0x44), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Đ to D - { - FcFrom: uint16(0x0111), - FcTo0: uint8(0x64), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // đ to d - { - FcFrom: uint16(0x0112), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ē to E - { - FcFrom: uint16(0x0113), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ē to e - { - FcFrom: uint16(0x0114), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ĕ to E - { - FcFrom: uint16(0x0115), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ĕ to e - { - FcFrom: uint16(0x0116), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ė to E - { - FcFrom: uint16(0x0117), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ė to e - { - FcFrom: uint16(0x0118), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ę to E - { - FcFrom: uint16(0x0119), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ę to e - { - FcFrom: uint16(0x011A), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ě to E - { - FcFrom: uint16(0x011B), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ě to e - { - FcFrom: uint16(0x011C), - FcTo0: uint8(0x47), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ĝ to Gh - { - FcFrom: uint16(0x011D), - FcTo0: uint8(0x67), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ĝ to gh - { - FcFrom: uint16(0x011E), - FcTo0: uint8(0x47), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ğ to G - { - FcFrom: uint16(0x011F), - FcTo0: uint8(0x67), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ğ to g - { - FcFrom: uint16(0x0120), - FcTo0: uint8(0x47), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ġ to G - { - FcFrom: uint16(0x0121), - FcTo0: uint8(0x67), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ġ to g - { - FcFrom: uint16(0x0122), - FcTo0: uint8(0x47), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ģ to G - { - FcFrom: uint16(0x0123), - FcTo0: uint8(0x67), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ģ to g - { - FcFrom: uint16(0x0124), - FcTo0: uint8(0x48), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ĥ to Hh - { - FcFrom: uint16(0x0125), - FcTo0: uint8(0x68), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ĥ to hh - { - FcFrom: uint16(0x0126), - FcTo0: uint8(0x48), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ħ to H - { - FcFrom: uint16(0x0127), - FcTo0: uint8(0x68), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ħ to h - { - FcFrom: uint16(0x0128), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ĩ to I - { - FcFrom: uint16(0x0129), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ĩ to i - { - FcFrom: uint16(0x012A), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ī to I - { - FcFrom: uint16(0x012B), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ī to i - { - FcFrom: uint16(0x012C), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ĭ to I - { - FcFrom: uint16(0x012D), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ĭ to i - { - FcFrom: uint16(0x012E), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Į to I - { - FcFrom: uint16(0x012F), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // į to i - { - FcFrom: uint16(0x0130), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // İ to I - { - FcFrom: uint16(0x0131), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ı to i - { - FcFrom: uint16(0x0132), - FcTo0: uint8(0x49), - FcTo1: uint8(0x4A), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // IJ to IJ - { - FcFrom: uint16(0x0133), - FcTo0: uint8(0x69), - FcTo1: uint8(0x6A), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ij to ij - { - FcFrom: uint16(0x0134), - FcTo0: uint8(0x4A), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ĵ to Jh - { - FcFrom: uint16(0x0135), - FcTo0: uint8(0x6A), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ĵ to jh - { - FcFrom: uint16(0x0136), - FcTo0: uint8(0x4B), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ķ to K - { - FcFrom: uint16(0x0137), - FcTo0: uint8(0x6B), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ķ to k - { - FcFrom: uint16(0x0138), - FcTo0: uint8(0x6B), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ĸ to k - { - FcFrom: uint16(0x0139), - FcTo0: uint8(0x4C), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ĺ to L - { - FcFrom: uint16(0x013A), - FcTo0: uint8(0x6C), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ĺ to l - { - FcFrom: uint16(0x013B), - FcTo0: uint8(0x4C), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ļ to L - { - FcFrom: uint16(0x013C), - FcTo0: uint8(0x6C), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ļ to l - { - FcFrom: uint16(0x013D), - FcTo0: uint8(0x4C), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ľ to L - { - FcFrom: uint16(0x013E), - FcTo0: uint8(0x6C), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ľ to l - { - FcFrom: uint16(0x013F), - FcTo0: uint8(0x4C), - FcTo1: uint8(0x2E), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ŀ to L. - { - FcFrom: uint16(0x0140), - FcTo0: uint8(0x6C), - FcTo1: uint8(0x2E), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ŀ to l. - { - FcFrom: uint16(0x0141), - FcTo0: uint8(0x4C), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ł to L - { - FcFrom: uint16(0x0142), - FcTo0: uint8(0x6C), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ł to l - { - FcFrom: uint16(0x0143), - FcTo0: uint8(0x4E), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ń to N - { - FcFrom: uint16(0x0144), - FcTo0: uint8(0x6E), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ń to n - { - FcFrom: uint16(0x0145), - FcTo0: uint8(0x4E), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ņ to N - { - FcFrom: uint16(0x0146), - FcTo0: uint8(0x6E), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ņ to n - { - FcFrom: uint16(0x0147), - FcTo0: uint8(0x4E), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ň to N - { - FcFrom: uint16(0x0148), - FcTo0: uint8(0x6E), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ň to n - { - FcFrom: uint16(0x0149), - FcTo0: uint8(0x27), - FcTo1: uint8(0x6E), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ʼn to 'n - { - FcFrom: uint16(0x014A), - FcTo0: uint8(0x4E), - FcTo1: uint8(0x47), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ŋ to NG - { - FcFrom: uint16(0x014B), - FcTo0: uint8(0x6E), - FcTo1: uint8(0x67), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ŋ to ng - { - FcFrom: uint16(0x014C), - FcTo0: uint8(0x4F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ō to O - { - FcFrom: uint16(0x014D), - FcTo0: uint8(0x6F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ō to o - { - FcFrom: uint16(0x014E), - FcTo0: uint8(0x4F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ŏ to O - { - FcFrom: uint16(0x014F), - FcTo0: uint8(0x6F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ŏ to o - { - FcFrom: uint16(0x0150), - FcTo0: uint8(0x4F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ő to O - { - FcFrom: uint16(0x0151), - FcTo0: uint8(0x6F), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ő to o - { - FcFrom: uint16(0x0152), - FcTo0: uint8(0x4F), - FcTo1: uint8(0x45), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Œ to OE - { - FcFrom: uint16(0x0153), - FcTo0: uint8(0x6F), - FcTo1: uint8(0x65), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // œ to oe - { - FcFrom: uint16(0x0154), - FcTo0: uint8(0x52), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ŕ to R - { - FcFrom: uint16(0x0155), - FcTo0: uint8(0x72), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ŕ to r - { - FcFrom: uint16(0x0156), - FcTo0: uint8(0x52), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ŗ to R - { - FcFrom: uint16(0x0157), - FcTo0: uint8(0x72), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ŗ to r - { - FcFrom: uint16(0x0158), - FcTo0: uint8(0x52), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ř to R - { - FcFrom: uint16(0x0159), - FcTo0: uint8(0x72), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ř to r - { - FcFrom: uint16(0x015A), - FcTo0: uint8(0x53), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ś to S - { - FcFrom: uint16(0x015B), - FcTo0: uint8(0x73), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ś to s - { - FcFrom: uint16(0x015C), - FcTo0: uint8(0x53), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ŝ to Sh - { - FcFrom: uint16(0x015D), - FcTo0: uint8(0x73), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ŝ to sh - { - FcFrom: uint16(0x015E), - FcTo0: uint8(0x53), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ş to S - { - FcFrom: uint16(0x015F), - FcTo0: uint8(0x73), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ş to s - { - FcFrom: uint16(0x0160), - FcTo0: uint8(0x53), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Š to S - { - FcFrom: uint16(0x0161), - FcTo0: uint8(0x73), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // š to s - { - FcFrom: uint16(0x0162), - FcTo0: uint8(0x54), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ţ to T - { - FcFrom: uint16(0x0163), - FcTo0: uint8(0x74), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ţ to t - { - FcFrom: uint16(0x0164), - FcTo0: uint8(0x54), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ť to T - { - FcFrom: uint16(0x0165), - FcTo0: uint8(0x74), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ť to t - { - FcFrom: uint16(0x0166), - FcTo0: uint8(0x54), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ŧ to T - { - FcFrom: uint16(0x0167), - FcTo0: uint8(0x74), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ŧ to t - { - FcFrom: uint16(0x0168), - FcTo0: uint8(0x55), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ũ to U - { - FcFrom: uint16(0x0169), - FcTo0: uint8(0x75), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ũ to u - { - FcFrom: uint16(0x016A), - FcTo0: uint8(0x55), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ū to U - { - FcFrom: uint16(0x016B), - FcTo0: uint8(0x75), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ū to u - { - FcFrom: uint16(0x016C), - FcTo0: uint8(0x55), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ŭ to U - { - FcFrom: uint16(0x016D), - FcTo0: uint8(0x75), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ŭ to u - { - FcFrom: uint16(0x016E), - FcTo0: uint8(0x55), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ů to U - { - FcFrom: uint16(0x016F), - FcTo0: uint8(0x75), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ů to u - { - FcFrom: uint16(0x0170), - FcTo0: uint8(0x55), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ű to U - { - FcFrom: uint16(0x0171), - FcTo0: uint8(0x75), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ű to u - { - FcFrom: uint16(0x0172), - FcTo0: uint8(0x55), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ų to U - { - FcFrom: uint16(0x0173), - FcTo0: uint8(0x75), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ų to u - { - FcFrom: uint16(0x0174), - FcTo0: uint8(0x57), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ŵ to W - { - FcFrom: uint16(0x0175), - FcTo0: uint8(0x77), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ŵ to w - { - FcFrom: uint16(0x0176), - FcTo0: uint8(0x59), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ŷ to Y - { - FcFrom: uint16(0x0177), - FcTo0: uint8(0x79), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ŷ to y - { - FcFrom: uint16(0x0178), - FcTo0: uint8(0x59), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ÿ to Y - { - FcFrom: uint16(0x0179), - FcTo0: uint8(0x5A), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ź to Z - { - FcFrom: uint16(0x017A), - FcTo0: uint8(0x7A), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ź to z - { - FcFrom: uint16(0x017B), - FcTo0: uint8(0x5A), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ż to Z - { - FcFrom: uint16(0x017C), - FcTo0: uint8(0x7A), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ż to z - { - FcFrom: uint16(0x017D), - FcTo0: uint8(0x5A), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ž to Z - { - FcFrom: uint16(0x017E), - FcTo0: uint8(0x7A), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ž to z - { - FcFrom: uint16(0x017F), - FcTo0: uint8(0x73), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ſ to s - { - FcFrom: uint16(0x0192), - FcTo0: uint8(0x66), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ƒ to f - { - FcFrom: uint16(0x0218), - FcTo0: uint8(0x53), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ș to S - { - FcFrom: uint16(0x0219), - FcTo0: uint8(0x73), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ș to s - { - FcFrom: uint16(0x021A), - FcTo0: uint8(0x54), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ț to T - { - FcFrom: uint16(0x021B), - FcTo0: uint8(0x74), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ț to t - { - FcFrom: uint16(0x0386), - FcTo0: uint8(0x41), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ά to A - { - FcFrom: uint16(0x0388), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Έ to E - { - FcFrom: uint16(0x0389), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ή to I - { - FcFrom: uint16(0x038A), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ί to I - { - FcFrom: uint16(0x038C), - FcTo0: uint8(0x4f), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ό to O - { - FcFrom: uint16(0x038E), - FcTo0: uint8(0x59), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ύ to Y - { - FcFrom: uint16(0x038F), - FcTo0: uint8(0x4f), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ώ to O - { - FcFrom: uint16(0x0390), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ΐ to i - { - FcFrom: uint16(0x0391), - FcTo0: uint8(0x41), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Α to A - { - FcFrom: uint16(0x0392), - FcTo0: uint8(0x42), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Β to B - { - FcFrom: uint16(0x0393), - FcTo0: uint8(0x47), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Γ to G - { - FcFrom: uint16(0x0394), - FcTo0: uint8(0x44), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Δ to D - { - FcFrom: uint16(0x0395), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ε to E - { - FcFrom: uint16(0x0396), - FcTo0: uint8(0x5a), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ζ to Z - { - FcFrom: uint16(0x0397), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Η to I - { - FcFrom: uint16(0x0398), - FcTo0: uint8(0x54), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Θ to Th - { - FcFrom: uint16(0x0399), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ι to I - { - FcFrom: uint16(0x039A), - FcTo0: uint8(0x4b), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Κ to K - { - FcFrom: uint16(0x039B), - FcTo0: uint8(0x4c), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Λ to L - { - FcFrom: uint16(0x039C), - FcTo0: uint8(0x4d), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Μ to M - { - FcFrom: uint16(0x039D), - FcTo0: uint8(0x4e), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ν to N - { - FcFrom: uint16(0x039E), - FcTo0: uint8(0x58), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ξ to X - { - FcFrom: uint16(0x039F), - FcTo0: uint8(0x4f), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ο to O - { - FcFrom: uint16(0x03A0), - FcTo0: uint8(0x50), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Π to P - { - FcFrom: uint16(0x03A1), - FcTo0: uint8(0x52), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ρ to R - { - FcFrom: uint16(0x03A3), - FcTo0: uint8(0x53), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Σ to S - { - FcFrom: uint16(0x03A4), - FcTo0: uint8(0x54), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Τ to T - { - FcFrom: uint16(0x03A5), - FcTo0: uint8(0x59), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Υ to Y - { - FcFrom: uint16(0x03A6), - FcTo0: uint8(0x46), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Φ to F - { - FcFrom: uint16(0x03A7), - FcTo0: uint8(0x43), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Χ to Ch - { - FcFrom: uint16(0x03A8), - FcTo0: uint8(0x50), - FcTo1: uint8(0x73), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ψ to Ps - { - FcFrom: uint16(0x03A9), - FcTo0: uint8(0x4f), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ω to O - { - FcFrom: uint16(0x03AA), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ϊ to I - { - FcFrom: uint16(0x03AB), - FcTo0: uint8(0x59), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ϋ to Y - { - FcFrom: uint16(0x03AC), - FcTo0: uint8(0x61), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ά to a - { - FcFrom: uint16(0x03AD), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // έ to e - { - FcFrom: uint16(0x03AE), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ή to i - { - FcFrom: uint16(0x03AF), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ί to i - { - FcFrom: uint16(0x03B1), - FcTo0: uint8(0x61), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // α to a - { - FcFrom: uint16(0x03B2), - FcTo0: uint8(0x62), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // β to b - { - FcFrom: uint16(0x03B3), - FcTo0: uint8(0x67), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // γ to g - { - FcFrom: uint16(0x03B4), - FcTo0: uint8(0x64), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // δ to d - { - FcFrom: uint16(0x03B5), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ε to e - { - FcFrom: uint16(0x03B6), - FcTo0: uint8(0x7a), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ζ to z - { - FcFrom: uint16(0x03B7), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // η to i - { - FcFrom: uint16(0x03B8), - FcTo0: uint8(0x74), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // θ to th - { - FcFrom: uint16(0x03B9), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ι to i - { - FcFrom: uint16(0x03BA), - FcTo0: uint8(0x6b), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // κ to k - { - FcFrom: uint16(0x03BB), - FcTo0: uint8(0x6c), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // λ to l - { - FcFrom: uint16(0x03BC), - FcTo0: uint8(0x6d), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // μ to m - { - FcFrom: uint16(0x03BD), - FcTo0: uint8(0x6e), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ν to n - { - FcFrom: uint16(0x03BE), - FcTo0: uint8(0x78), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ξ to x - { - FcFrom: uint16(0x03BF), - FcTo0: uint8(0x6f), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ο to o - { - FcFrom: uint16(0x03C0), - FcTo0: uint8(0x70), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // π to p - { - FcFrom: uint16(0x03C1), - FcTo0: uint8(0x72), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ρ to r - { - FcFrom: uint16(0x03C3), - FcTo0: uint8(0x73), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // σ to s - { - FcFrom: uint16(0x03C4), - FcTo0: uint8(0x74), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // τ to t - { - FcFrom: uint16(0x03C5), - FcTo0: uint8(0x79), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // υ to y - { - FcFrom: uint16(0x03C6), - FcTo0: uint8(0x66), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // φ to f - { - FcFrom: uint16(0x03C7), - FcTo0: uint8(0x63), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // χ to ch - { - FcFrom: uint16(0x03C8), - FcTo0: uint8(0x70), - FcTo1: uint8(0x73), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ψ to ps - { - FcFrom: uint16(0x03C9), - FcTo0: uint8(0x6f), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ω to o - { - FcFrom: uint16(0x03CA), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ϊ to i - { - FcFrom: uint16(0x03CB), - FcTo0: uint8(0x79), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ϋ to y - { - FcFrom: uint16(0x03CC), - FcTo0: uint8(0x6f), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ό to o - { - FcFrom: uint16(0x03CD), - FcTo0: uint8(0x79), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ύ to y - { - FcFrom: uint16(0x03CE), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ώ to i - { - FcFrom: uint16(0x0400), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ѐ to E - { - FcFrom: uint16(0x0401), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ё to E - { - FcFrom: uint16(0x0402), - FcTo0: uint8(0x44), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ђ to D - { - FcFrom: uint16(0x0403), - FcTo0: uint8(0x47), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ѓ to G - { - FcFrom: uint16(0x0404), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Є to E - { - FcFrom: uint16(0x0405), - FcTo0: uint8(0x5a), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ѕ to Z - { - FcFrom: uint16(0x0406), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // І to I - { - FcFrom: uint16(0x0407), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ї to I - { - FcFrom: uint16(0x0408), - FcTo0: uint8(0x4a), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ј to J - { - FcFrom: uint16(0x0409), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Љ to I - { - FcFrom: uint16(0x040A), - FcTo0: uint8(0x4e), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Њ to N - { - FcFrom: uint16(0x040B), - FcTo0: uint8(0x44), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ћ to D - { - FcFrom: uint16(0x040C), - FcTo0: uint8(0x4b), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ќ to K - { - FcFrom: uint16(0x040D), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ѝ to I - { - FcFrom: uint16(0x040E), - FcTo0: uint8(0x55), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ў to U - { - FcFrom: uint16(0x040F), - FcTo0: uint8(0x44), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Џ to D - { - FcFrom: uint16(0x0410), - FcTo0: uint8(0x41), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // А to A - { - FcFrom: uint16(0x0411), - FcTo0: uint8(0x42), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Б to B - { - FcFrom: uint16(0x0412), - FcTo0: uint8(0x56), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // В to V - { - FcFrom: uint16(0x0413), - FcTo0: uint8(0x47), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Г to G - { - FcFrom: uint16(0x0414), - FcTo0: uint8(0x44), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Д to D - { - FcFrom: uint16(0x0415), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Е to E - { - FcFrom: uint16(0x0416), - FcTo0: uint8(0x5a), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ж to Zh - { - FcFrom: uint16(0x0417), - FcTo0: uint8(0x5a), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // З to Z - { - FcFrom: uint16(0x0418), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // И to I - { - FcFrom: uint16(0x0419), - FcTo0: uint8(0x49), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Й to I - { - FcFrom: uint16(0x041A), - FcTo0: uint8(0x4b), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // К to K - { - FcFrom: uint16(0x041B), - FcTo0: uint8(0x4c), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Л to L - { - FcFrom: uint16(0x041C), - FcTo0: uint8(0x4d), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // М to M - { - FcFrom: uint16(0x041D), - FcTo0: uint8(0x4e), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Н to N - { - FcFrom: uint16(0x041E), - FcTo0: uint8(0x4f), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // О to O - { - FcFrom: uint16(0x041F), - FcTo0: uint8(0x50), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // П to P - { - FcFrom: uint16(0x0420), - FcTo0: uint8(0x52), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Р to R - { - FcFrom: uint16(0x0421), - FcTo0: uint8(0x53), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // С to S - { - FcFrom: uint16(0x0422), - FcTo0: uint8(0x54), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Т to T - { - FcFrom: uint16(0x0423), - FcTo0: uint8(0x55), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // У to U - { - FcFrom: uint16(0x0424), - FcTo0: uint8(0x46), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ф to F - { - FcFrom: uint16(0x0425), - FcTo0: uint8(0x4b), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Х to Kh - { - FcFrom: uint16(0x0426), - FcTo0: uint8(0x54), - FcTo1: uint8(0x63), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ц to Tc - { - FcFrom: uint16(0x0427), - FcTo0: uint8(0x43), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ч to Ch - { - FcFrom: uint16(0x0428), - FcTo0: uint8(0x53), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ш to Sh - { - FcFrom: uint16(0x0429), - FcTo0: uint8(0x53), - FcTo1: uint8(0x68), - FcTo2: uint8(0x63), - FcTo3: uint8(0x68)}, // Щ to Shch - { - FcFrom: uint16(0x042A), - FcTo0: uint8(0x61), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // to A - { - FcFrom: uint16(0x042B), - FcTo0: uint8(0x59), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ы to Y - { - FcFrom: uint16(0x042C), - FcTo0: uint8(0x59), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // to Y - { - FcFrom: uint16(0x042D), - FcTo0: uint8(0x45), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Э to E - { - FcFrom: uint16(0x042E), - FcTo0: uint8(0x49), - FcTo1: uint8(0x75), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ю to Iu - { - FcFrom: uint16(0x042F), - FcTo0: uint8(0x49), - FcTo1: uint8(0x61), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Я to Ia - { - FcFrom: uint16(0x0430), - FcTo0: uint8(0x61), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // а to a - { - FcFrom: uint16(0x0431), - FcTo0: uint8(0x62), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // б to b - { - FcFrom: uint16(0x0432), - FcTo0: uint8(0x76), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // в to v - { - FcFrom: uint16(0x0433), - FcTo0: uint8(0x67), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // г to g - { - FcFrom: uint16(0x0434), - FcTo0: uint8(0x64), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // д to d - { - FcFrom: uint16(0x0435), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // е to e - { - FcFrom: uint16(0x0436), - FcTo0: uint8(0x7a), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ж to zh - { - FcFrom: uint16(0x0437), - FcTo0: uint8(0x7a), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // з to z - { - FcFrom: uint16(0x0438), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // и to i - { - FcFrom: uint16(0x0439), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // й to i - { - FcFrom: uint16(0x043A), - FcTo0: uint8(0x6b), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // к to k - { - FcFrom: uint16(0x043B), - FcTo0: uint8(0x6c), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // л to l - { - FcFrom: uint16(0x043C), - FcTo0: uint8(0x6d), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // м to m - { - FcFrom: uint16(0x043D), - FcTo0: uint8(0x6e), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // н to n - { - FcFrom: uint16(0x043E), - FcTo0: uint8(0x6f), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // о to o - { - FcFrom: uint16(0x043F), - FcTo0: uint8(0x70), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // п to p - { - FcFrom: uint16(0x0440), - FcTo0: uint8(0x72), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // р to r - { - FcFrom: uint16(0x0441), - FcTo0: uint8(0x73), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // с to s - { - FcFrom: uint16(0x0442), - FcTo0: uint8(0x74), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // т to t - { - FcFrom: uint16(0x0443), - FcTo0: uint8(0x75), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // у to u - { - FcFrom: uint16(0x0444), - FcTo0: uint8(0x66), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ф to f - { - FcFrom: uint16(0x0445), - FcTo0: uint8(0x6b), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // х to kh - { - FcFrom: uint16(0x0446), - FcTo0: uint8(0x74), - FcTo1: uint8(0x63), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ц to tc - { - FcFrom: uint16(0x0447), - FcTo0: uint8(0x63), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ч to ch - { - FcFrom: uint16(0x0448), - FcTo0: uint8(0x73), - FcTo1: uint8(0x68), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ш to sh - { - FcFrom: uint16(0x0449), - FcTo0: uint8(0x73), - FcTo1: uint8(0x68), - FcTo2: uint8(0x63), - FcTo3: uint8(0x68)}, // щ to shch - { - FcFrom: uint16(0x044A), - FcTo0: uint8(0x61), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // to a - { - FcFrom: uint16(0x044B), - FcTo0: uint8(0x79), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ы to y - { - FcFrom: uint16(0x044C), - FcTo0: uint8(0x79), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // to y - { - FcFrom: uint16(0x044D), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // э to e - { - FcFrom: uint16(0x044E), - FcTo0: uint8(0x69), - FcTo1: uint8(0x75), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ю to iu - { - FcFrom: uint16(0x044F), - FcTo0: uint8(0x69), - FcTo1: uint8(0x61), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // я to ia - { - FcFrom: uint16(0x0450), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ѐ to e - { - FcFrom: uint16(0x0451), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ё to e - { - FcFrom: uint16(0x0452), - FcTo0: uint8(0x64), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ђ to d - { - FcFrom: uint16(0x0453), - FcTo0: uint8(0x67), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ѓ to g - { - FcFrom: uint16(0x0454), - FcTo0: uint8(0x65), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // є to e - { - FcFrom: uint16(0x0455), - FcTo0: uint8(0x7a), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ѕ to z - { - FcFrom: uint16(0x0456), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // і to i - { - FcFrom: uint16(0x0457), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ї to i - { - FcFrom: uint16(0x0458), - FcTo0: uint8(0x6a), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ј to j - { - FcFrom: uint16(0x0459), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // љ to i - { - FcFrom: uint16(0x045A), - FcTo0: uint8(0x6e), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // њ to n - { - FcFrom: uint16(0x045B), - FcTo0: uint8(0x64), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ћ to d - { - FcFrom: uint16(0x045C), - FcTo0: uint8(0x6b), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ќ to k - { - FcFrom: uint16(0x045D), - FcTo0: uint8(0x69), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ѝ to i - { - FcFrom: uint16(0x045E), - FcTo0: uint8(0x75), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ў to u - { - FcFrom: uint16(0x045F), - FcTo0: uint8(0x64), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // џ to d - { - FcFrom: uint16(0x1E02), - FcTo0: uint8(0x42), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ḃ to B - { - FcFrom: uint16(0x1E03), - FcTo0: uint8(0x62), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ḃ to b - { - FcFrom: uint16(0x1E0A), - FcTo0: uint8(0x44), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ḋ to D - { - FcFrom: uint16(0x1E0B), - FcTo0: uint8(0x64), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ḋ to d - { - FcFrom: uint16(0x1E1E), - FcTo0: uint8(0x46), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ḟ to F - { - FcFrom: uint16(0x1E1F), - FcTo0: uint8(0x66), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ḟ to f - { - FcFrom: uint16(0x1E40), - FcTo0: uint8(0x4D), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ṁ to M - { - FcFrom: uint16(0x1E41), - FcTo0: uint8(0x6D), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ṁ to m - { - FcFrom: uint16(0x1E56), - FcTo0: uint8(0x50), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ṗ to P - { - FcFrom: uint16(0x1E57), - FcTo0: uint8(0x70), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ṗ to p - { - FcFrom: uint16(0x1E60), - FcTo0: uint8(0x53), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ṡ to S - { - FcFrom: uint16(0x1E61), - FcTo0: uint8(0x73), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ṡ to s - { - FcFrom: uint16(0x1E6A), - FcTo0: uint8(0x54), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ṫ to T - { - FcFrom: uint16(0x1E6B), - FcTo0: uint8(0x74), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ṫ to t - { - FcFrom: uint16(0x1E80), - FcTo0: uint8(0x57), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ẁ to W - { - FcFrom: uint16(0x1E81), - FcTo0: uint8(0x77), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ẁ to w - { - FcFrom: uint16(0x1E82), - FcTo0: uint8(0x57), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ẃ to W - { - FcFrom: uint16(0x1E83), - FcTo0: uint8(0x77), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ẃ to w - { - FcFrom: uint16(0x1E84), - FcTo0: uint8(0x57), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ẅ to W - { - FcFrom: uint16(0x1E85), - FcTo0: uint8(0x77), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ẅ to w - { - FcFrom: uint16(0x1EF2), - FcTo0: uint8(0x59), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // Ỳ to Y - { - FcFrom: uint16(0x1EF3), - FcTo0: uint8(0x79), - FcTo1: uint8(0x00), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ỳ to y - { - FcFrom: uint16(0xFB00), - FcTo0: uint8(0x66), - FcTo1: uint8(0x66), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ff to ff - { - FcFrom: uint16(0xFB01), - FcTo0: uint8(0x66), - FcTo1: uint8(0x69), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // fi to fi - { - FcFrom: uint16(0xFB02), - FcTo0: uint8(0x66), - FcTo1: uint8(0x6C), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // fl to fl - { - FcFrom: uint16(0xFB05), - FcTo0: uint8(0x73), - FcTo1: uint8(0x74), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // ſt to st - { - FcFrom: uint16(0xFB06), - FcTo0: uint8(0x73), - FcTo1: uint8(0x74), - FcTo2: uint8(0x00), - FcTo3: uint8(0x00)}, // st to st + {FcFrom: uint16(0x00A0), FcTo0: uint8(0x20)}, //   to + {FcFrom: uint16(0x00B5), FcTo0: uint8(0x75)}, // µ to u + {FcFrom: uint16(0x00C0), FcTo0: uint8(0x41)}, // À to A + {FcFrom: uint16(0x00C1), FcTo0: uint8(0x41)}, // Á to A + {FcFrom: uint16(0x00C2), FcTo0: uint8(0x41)}, //  to A + {FcFrom: uint16(0x00C3), FcTo0: uint8(0x41)}, // à to A + {FcFrom: uint16(0x00C4), FcTo0: uint8(0x41), FcTo1: uint8(0x65)}, // Ä to Ae + {FcFrom: uint16(0x00C5), FcTo0: uint8(0x41), FcTo1: uint8(0x61)}, // Å to Aa + {FcFrom: uint16(0x00C6), FcTo0: uint8(0x41), FcTo1: uint8(0x45)}, // Æ to AE + {FcFrom: uint16(0x00C7), FcTo0: uint8(0x43)}, // Ç to C + {FcFrom: uint16(0x00C8), FcTo0: uint8(0x45)}, // È to E + {FcFrom: uint16(0x00C9), FcTo0: uint8(0x45)}, // É to E + {FcFrom: uint16(0x00CA), FcTo0: uint8(0x45)}, // Ê to E + {FcFrom: uint16(0x00CB), FcTo0: uint8(0x45)}, // Ë to E + {FcFrom: uint16(0x00CC), FcTo0: uint8(0x49)}, // Ì to I + {FcFrom: uint16(0x00CD), FcTo0: uint8(0x49)}, // Í to I + {FcFrom: uint16(0x00CE), FcTo0: uint8(0x49)}, // Î to I + {FcFrom: uint16(0x00CF), FcTo0: uint8(0x49)}, // Ï to I + {FcFrom: uint16(0x00D0), FcTo0: uint8(0x44)}, // Ð to D + {FcFrom: uint16(0x00D1), FcTo0: uint8(0x4E)}, // Ñ to N + {FcFrom: uint16(0x00D2), FcTo0: uint8(0x4F)}, // Ò to O + {FcFrom: uint16(0x00D3), FcTo0: uint8(0x4F)}, // Ó to O + {FcFrom: uint16(0x00D4), FcTo0: uint8(0x4F)}, // Ô to O + {FcFrom: uint16(0x00D5), FcTo0: uint8(0x4F)}, // Õ to O + {FcFrom: uint16(0x00D6), FcTo0: uint8(0x4F), FcTo1: uint8(0x65)}, // Ö to Oe + {FcFrom: uint16(0x00D7), FcTo0: uint8(0x78)}, // × to x + {FcFrom: uint16(0x00D8), FcTo0: uint8(0x4F)}, // Ø to O + {FcFrom: uint16(0x00D9), FcTo0: uint8(0x55)}, // Ù to U + {FcFrom: uint16(0x00DA), FcTo0: uint8(0x55)}, // Ú to U + {FcFrom: uint16(0x00DB), FcTo0: uint8(0x55)}, // Û to U + {FcFrom: uint16(0x00DC), FcTo0: uint8(0x55), FcTo1: uint8(0x65)}, // Ü to Ue + {FcFrom: uint16(0x00DD), FcTo0: uint8(0x59)}, // Ý to Y + {FcFrom: uint16(0x00DE), FcTo0: uint8(0x54), FcTo1: uint8(0x68)}, // Þ to Th + {FcFrom: uint16(0x00DF), FcTo0: uint8(0x73), FcTo1: uint8(0x73)}, // ß to ss + {FcFrom: uint16(0x00E0), FcTo0: uint8(0x61)}, // à to a + {FcFrom: uint16(0x00E1), FcTo0: uint8(0x61)}, // á to a + {FcFrom: uint16(0x00E2), FcTo0: uint8(0x61)}, // â to a + {FcFrom: uint16(0x00E3), FcTo0: uint8(0x61)}, // ã to a + {FcFrom: uint16(0x00E4), FcTo0: uint8(0x61), FcTo1: uint8(0x65)}, // ä to ae + {FcFrom: uint16(0x00E5), FcTo0: uint8(0x61), FcTo1: uint8(0x61)}, // å to aa + {FcFrom: uint16(0x00E6), FcTo0: uint8(0x61), FcTo1: uint8(0x65)}, // æ to ae + {FcFrom: uint16(0x00E7), FcTo0: uint8(0x63)}, // ç to c + {FcFrom: uint16(0x00E8), FcTo0: uint8(0x65)}, // è to e + {FcFrom: uint16(0x00E9), FcTo0: uint8(0x65)}, // é to e + {FcFrom: uint16(0x00EA), FcTo0: uint8(0x65)}, // ê to e + {FcFrom: uint16(0x00EB), FcTo0: uint8(0x65)}, // ë to e + {FcFrom: uint16(0x00EC), FcTo0: uint8(0x69)}, // ì to i + {FcFrom: uint16(0x00ED), FcTo0: uint8(0x69)}, // í to i + {FcFrom: uint16(0x00EE), FcTo0: uint8(0x69)}, // î to i + {FcFrom: uint16(0x00EF), FcTo0: uint8(0x69)}, // ï to i + {FcFrom: uint16(0x00F0), FcTo0: uint8(0x64)}, // ð to d + {FcFrom: uint16(0x00F1), FcTo0: uint8(0x6E)}, // ñ to n + {FcFrom: uint16(0x00F2), FcTo0: uint8(0x6F)}, // ò to o + {FcFrom: uint16(0x00F3), FcTo0: uint8(0x6F)}, // ó to o + {FcFrom: uint16(0x00F4), FcTo0: uint8(0x6F)}, // ô to o + {FcFrom: uint16(0x00F5), FcTo0: uint8(0x6F)}, // õ to o + {FcFrom: uint16(0x00F6), FcTo0: uint8(0x6F), FcTo1: uint8(0x65)}, // ö to oe + {FcFrom: uint16(0x00F7), FcTo0: uint8(0x3A)}, // ÷ to : + {FcFrom: uint16(0x00F8), FcTo0: uint8(0x6F)}, // ø to o + {FcFrom: uint16(0x00F9), FcTo0: uint8(0x75)}, // ù to u + {FcFrom: uint16(0x00FA), FcTo0: uint8(0x75)}, // ú to u + {FcFrom: uint16(0x00FB), FcTo0: uint8(0x75)}, // û to u + {FcFrom: uint16(0x00FC), FcTo0: uint8(0x75), FcTo1: uint8(0x65)}, // ü to ue + {FcFrom: uint16(0x00FD), FcTo0: uint8(0x79)}, // ý to y + {FcFrom: uint16(0x00FE), FcTo0: uint8(0x74), FcTo1: uint8(0x68)}, // þ to th + {FcFrom: uint16(0x00FF), FcTo0: uint8(0x79)}, // ÿ to y + {FcFrom: uint16(0x0100), FcTo0: uint8(0x41)}, // Ā to A + {FcFrom: uint16(0x0101), FcTo0: uint8(0x61)}, // ā to a + {FcFrom: uint16(0x0102), FcTo0: uint8(0x41)}, // Ă to A + {FcFrom: uint16(0x0103), FcTo0: uint8(0x61)}, // ă to a + {FcFrom: uint16(0x0104), FcTo0: uint8(0x41)}, // Ą to A + {FcFrom: uint16(0x0105), FcTo0: uint8(0x61)}, // ą to a + {FcFrom: uint16(0x0106), FcTo0: uint8(0x43)}, // Ć to C + {FcFrom: uint16(0x0107), FcTo0: uint8(0x63)}, // ć to c + {FcFrom: uint16(0x0108), FcTo0: uint8(0x43), FcTo1: uint8(0x68)}, // Ĉ to Ch + {FcFrom: uint16(0x0109), FcTo0: uint8(0x63), FcTo1: uint8(0x68)}, // ĉ to ch + {FcFrom: uint16(0x010A), FcTo0: uint8(0x43)}, // Ċ to C + {FcFrom: uint16(0x010B), FcTo0: uint8(0x63)}, // ċ to c + {FcFrom: uint16(0x010C), FcTo0: uint8(0x43)}, // Č to C + {FcFrom: uint16(0x010D), FcTo0: uint8(0x63)}, // č to c + {FcFrom: uint16(0x010E), FcTo0: uint8(0x44)}, // Ď to D + {FcFrom: uint16(0x010F), FcTo0: uint8(0x64)}, // ď to d + {FcFrom: uint16(0x0110), FcTo0: uint8(0x44)}, // Đ to D + {FcFrom: uint16(0x0111), FcTo0: uint8(0x64)}, // đ to d + {FcFrom: uint16(0x0112), FcTo0: uint8(0x45)}, // Ē to E + {FcFrom: uint16(0x0113), FcTo0: uint8(0x65)}, // ē to e + {FcFrom: uint16(0x0114), FcTo0: uint8(0x45)}, // Ĕ to E + {FcFrom: uint16(0x0115), FcTo0: uint8(0x65)}, // ĕ to e + {FcFrom: uint16(0x0116), FcTo0: uint8(0x45)}, // Ė to E + {FcFrom: uint16(0x0117), FcTo0: uint8(0x65)}, // ė to e + {FcFrom: uint16(0x0118), FcTo0: uint8(0x45)}, // Ę to E + {FcFrom: uint16(0x0119), FcTo0: uint8(0x65)}, // ę to e + {FcFrom: uint16(0x011A), FcTo0: uint8(0x45)}, // Ě to E + {FcFrom: uint16(0x011B), FcTo0: uint8(0x65)}, // ě to e + {FcFrom: uint16(0x011C), FcTo0: uint8(0x47), FcTo1: uint8(0x68)}, // Ĝ to Gh + {FcFrom: uint16(0x011D), FcTo0: uint8(0x67), FcTo1: uint8(0x68)}, // ĝ to gh + {FcFrom: uint16(0x011E), FcTo0: uint8(0x47)}, // Ğ to G + {FcFrom: uint16(0x011F), FcTo0: uint8(0x67)}, // ğ to g + {FcFrom: uint16(0x0120), FcTo0: uint8(0x47)}, // Ġ to G + {FcFrom: uint16(0x0121), FcTo0: uint8(0x67)}, // ġ to g + {FcFrom: uint16(0x0122), FcTo0: uint8(0x47)}, // Ģ to G + {FcFrom: uint16(0x0123), FcTo0: uint8(0x67)}, // ģ to g + {FcFrom: uint16(0x0124), FcTo0: uint8(0x48), FcTo1: uint8(0x68)}, // Ĥ to Hh + {FcFrom: uint16(0x0125), FcTo0: uint8(0x68), FcTo1: uint8(0x68)}, // ĥ to hh + {FcFrom: uint16(0x0126), FcTo0: uint8(0x48)}, // Ħ to H + {FcFrom: uint16(0x0127), FcTo0: uint8(0x68)}, // ħ to h + {FcFrom: uint16(0x0128), FcTo0: uint8(0x49)}, // Ĩ to I + {FcFrom: uint16(0x0129), FcTo0: uint8(0x69)}, // ĩ to i + {FcFrom: uint16(0x012A), FcTo0: uint8(0x49)}, // Ī to I + {FcFrom: uint16(0x012B), FcTo0: uint8(0x69)}, // ī to i + {FcFrom: uint16(0x012C), FcTo0: uint8(0x49)}, // Ĭ to I + {FcFrom: uint16(0x012D), FcTo0: uint8(0x69)}, // ĭ to i + {FcFrom: uint16(0x012E), FcTo0: uint8(0x49)}, // Į to I + {FcFrom: uint16(0x012F), FcTo0: uint8(0x69)}, // į to i + {FcFrom: uint16(0x0130), FcTo0: uint8(0x49)}, // İ to I + {FcFrom: uint16(0x0131), FcTo0: uint8(0x69)}, // ı to i + {FcFrom: uint16(0x0132), FcTo0: uint8(0x49), FcTo1: uint8(0x4A)}, // IJ to IJ + {FcFrom: uint16(0x0133), FcTo0: uint8(0x69), FcTo1: uint8(0x6A)}, // ij to ij + {FcFrom: uint16(0x0134), FcTo0: uint8(0x4A), FcTo1: uint8(0x68)}, // Ĵ to Jh + {FcFrom: uint16(0x0135), FcTo0: uint8(0x6A), FcTo1: uint8(0x68)}, // ĵ to jh + {FcFrom: uint16(0x0136), FcTo0: uint8(0x4B)}, // Ķ to K + {FcFrom: uint16(0x0137), FcTo0: uint8(0x6B)}, // ķ to k + {FcFrom: uint16(0x0138), FcTo0: uint8(0x6B)}, // ĸ to k + {FcFrom: uint16(0x0139), FcTo0: uint8(0x4C)}, // Ĺ to L + {FcFrom: uint16(0x013A), FcTo0: uint8(0x6C)}, // ĺ to l + {FcFrom: uint16(0x013B), FcTo0: uint8(0x4C)}, // Ļ to L + {FcFrom: uint16(0x013C), FcTo0: uint8(0x6C)}, // ļ to l + {FcFrom: uint16(0x013D), FcTo0: uint8(0x4C)}, // Ľ to L + {FcFrom: uint16(0x013E), FcTo0: uint8(0x6C)}, // ľ to l + {FcFrom: uint16(0x013F), FcTo0: uint8(0x4C), FcTo1: uint8(0x2E)}, // Ŀ to L. + {FcFrom: uint16(0x0140), FcTo0: uint8(0x6C), FcTo1: uint8(0x2E)}, // ŀ to l. + {FcFrom: uint16(0x0141), FcTo0: uint8(0x4C)}, // Ł to L + {FcFrom: uint16(0x0142), FcTo0: uint8(0x6C)}, // ł to l + {FcFrom: uint16(0x0143), FcTo0: uint8(0x4E)}, // Ń to N + {FcFrom: uint16(0x0144), FcTo0: uint8(0x6E)}, // ń to n + {FcFrom: uint16(0x0145), FcTo0: uint8(0x4E)}, // Ņ to N + {FcFrom: uint16(0x0146), FcTo0: uint8(0x6E)}, // ņ to n + {FcFrom: uint16(0x0147), FcTo0: uint8(0x4E)}, // Ň to N + {FcFrom: uint16(0x0148), FcTo0: uint8(0x6E)}, // ň to n + {FcFrom: uint16(0x0149), FcTo0: uint8(0x27), FcTo1: uint8(0x6E)}, // ʼn to 'n + {FcFrom: uint16(0x014A), FcTo0: uint8(0x4E), FcTo1: uint8(0x47)}, // Ŋ to NG + {FcFrom: uint16(0x014B), FcTo0: uint8(0x6E), FcTo1: uint8(0x67)}, // ŋ to ng + {FcFrom: uint16(0x014C), FcTo0: uint8(0x4F)}, // Ō to O + {FcFrom: uint16(0x014D), FcTo0: uint8(0x6F)}, // ō to o + {FcFrom: uint16(0x014E), FcTo0: uint8(0x4F)}, // Ŏ to O + {FcFrom: uint16(0x014F), FcTo0: uint8(0x6F)}, // ŏ to o + {FcFrom: uint16(0x0150), FcTo0: uint8(0x4F)}, // Ő to O + {FcFrom: uint16(0x0151), FcTo0: uint8(0x6F)}, // ő to o + {FcFrom: uint16(0x0152), FcTo0: uint8(0x4F), FcTo1: uint8(0x45)}, // Œ to OE + {FcFrom: uint16(0x0153), FcTo0: uint8(0x6F), FcTo1: uint8(0x65)}, // œ to oe + {FcFrom: uint16(0x0154), FcTo0: uint8(0x52)}, // Ŕ to R + {FcFrom: uint16(0x0155), FcTo0: uint8(0x72)}, // ŕ to r + {FcFrom: uint16(0x0156), FcTo0: uint8(0x52)}, // Ŗ to R + {FcFrom: uint16(0x0157), FcTo0: uint8(0x72)}, // ŗ to r + {FcFrom: uint16(0x0158), FcTo0: uint8(0x52)}, // Ř to R + {FcFrom: uint16(0x0159), FcTo0: uint8(0x72)}, // ř to r + {FcFrom: uint16(0x015A), FcTo0: uint8(0x53)}, // Ś to S + {FcFrom: uint16(0x015B), FcTo0: uint8(0x73)}, // ś to s + {FcFrom: uint16(0x015C), FcTo0: uint8(0x53), FcTo1: uint8(0x68)}, // Ŝ to Sh + {FcFrom: uint16(0x015D), FcTo0: uint8(0x73), FcTo1: uint8(0x68)}, // ŝ to sh + {FcFrom: uint16(0x015E), FcTo0: uint8(0x53)}, // Ş to S + {FcFrom: uint16(0x015F), FcTo0: uint8(0x73)}, // ş to s + {FcFrom: uint16(0x0160), FcTo0: uint8(0x53)}, // Š to S + {FcFrom: uint16(0x0161), FcTo0: uint8(0x73)}, // š to s + {FcFrom: uint16(0x0162), FcTo0: uint8(0x54)}, // Ţ to T + {FcFrom: uint16(0x0163), FcTo0: uint8(0x74)}, // ţ to t + {FcFrom: uint16(0x0164), FcTo0: uint8(0x54)}, // Ť to T + {FcFrom: uint16(0x0165), FcTo0: uint8(0x74)}, // ť to t + {FcFrom: uint16(0x0166), FcTo0: uint8(0x54)}, // Ŧ to T + {FcFrom: uint16(0x0167), FcTo0: uint8(0x74)}, // ŧ to t + {FcFrom: uint16(0x0168), FcTo0: uint8(0x55)}, // Ũ to U + {FcFrom: uint16(0x0169), FcTo0: uint8(0x75)}, // ũ to u + {FcFrom: uint16(0x016A), FcTo0: uint8(0x55)}, // Ū to U + {FcFrom: uint16(0x016B), FcTo0: uint8(0x75)}, // ū to u + {FcFrom: uint16(0x016C), FcTo0: uint8(0x55)}, // Ŭ to U + {FcFrom: uint16(0x016D), FcTo0: uint8(0x75)}, // ŭ to u + {FcFrom: uint16(0x016E), FcTo0: uint8(0x55)}, // Ů to U + {FcFrom: uint16(0x016F), FcTo0: uint8(0x75)}, // ů to u + {FcFrom: uint16(0x0170), FcTo0: uint8(0x55)}, // Ű to U + {FcFrom: uint16(0x0171), FcTo0: uint8(0x75)}, // ű to u + {FcFrom: uint16(0x0172), FcTo0: uint8(0x55)}, // Ų to U + {FcFrom: uint16(0x0173), FcTo0: uint8(0x75)}, // ų to u + {FcFrom: uint16(0x0174), FcTo0: uint8(0x57)}, // Ŵ to W + {FcFrom: uint16(0x0175), FcTo0: uint8(0x77)}, // ŵ to w + {FcFrom: uint16(0x0176), FcTo0: uint8(0x59)}, // Ŷ to Y + {FcFrom: uint16(0x0177), FcTo0: uint8(0x79)}, // ŷ to y + {FcFrom: uint16(0x0178), FcTo0: uint8(0x59)}, // Ÿ to Y + {FcFrom: uint16(0x0179), FcTo0: uint8(0x5A)}, // Ź to Z + {FcFrom: uint16(0x017A), FcTo0: uint8(0x7A)}, // ź to z + {FcFrom: uint16(0x017B), FcTo0: uint8(0x5A)}, // Ż to Z + {FcFrom: uint16(0x017C), FcTo0: uint8(0x7A)}, // ż to z + {FcFrom: uint16(0x017D), FcTo0: uint8(0x5A)}, // Ž to Z + {FcFrom: uint16(0x017E), FcTo0: uint8(0x7A)}, // ž to z + {FcFrom: uint16(0x017F), FcTo0: uint8(0x73)}, // ſ to s + {FcFrom: uint16(0x0192), FcTo0: uint8(0x66)}, // ƒ to f + {FcFrom: uint16(0x0218), FcTo0: uint8(0x53)}, // Ș to S + {FcFrom: uint16(0x0219), FcTo0: uint8(0x73)}, // ș to s + {FcFrom: uint16(0x021A), FcTo0: uint8(0x54)}, // Ț to T + {FcFrom: uint16(0x021B), FcTo0: uint8(0x74)}, // ț to t + {FcFrom: uint16(0x0386), FcTo0: uint8(0x41)}, // Ά to A + {FcFrom: uint16(0x0388), FcTo0: uint8(0x45)}, // Έ to E + {FcFrom: uint16(0x0389), FcTo0: uint8(0x49)}, // Ή to I + {FcFrom: uint16(0x038A), FcTo0: uint8(0x49)}, // Ί to I + {FcFrom: uint16(0x038C), FcTo0: uint8(0x4f)}, // Ό to O + {FcFrom: uint16(0x038E), FcTo0: uint8(0x59)}, // Ύ to Y + {FcFrom: uint16(0x038F), FcTo0: uint8(0x4f)}, // Ώ to O + {FcFrom: uint16(0x0390), FcTo0: uint8(0x69)}, // ΐ to i + {FcFrom: uint16(0x0391), FcTo0: uint8(0x41)}, // Α to A + {FcFrom: uint16(0x0392), FcTo0: uint8(0x42)}, // Β to B + {FcFrom: uint16(0x0393), FcTo0: uint8(0x47)}, // Γ to G + {FcFrom: uint16(0x0394), FcTo0: uint8(0x44)}, // Δ to D + {FcFrom: uint16(0x0395), FcTo0: uint8(0x45)}, // Ε to E + {FcFrom: uint16(0x0396), FcTo0: uint8(0x5a)}, // Ζ to Z + {FcFrom: uint16(0x0397), FcTo0: uint8(0x49)}, // Η to I + {FcFrom: uint16(0x0398), FcTo0: uint8(0x54), FcTo1: uint8(0x68)}, // Θ to Th + {FcFrom: uint16(0x0399), FcTo0: uint8(0x49)}, // Ι to I + {FcFrom: uint16(0x039A), FcTo0: uint8(0x4b)}, // Κ to K + {FcFrom: uint16(0x039B), FcTo0: uint8(0x4c)}, // Λ to L + {FcFrom: uint16(0x039C), FcTo0: uint8(0x4d)}, // Μ to M + {FcFrom: uint16(0x039D), FcTo0: uint8(0x4e)}, // Ν to N + {FcFrom: uint16(0x039E), FcTo0: uint8(0x58)}, // Ξ to X + {FcFrom: uint16(0x039F), FcTo0: uint8(0x4f)}, // Ο to O + {FcFrom: uint16(0x03A0), FcTo0: uint8(0x50)}, // Π to P + {FcFrom: uint16(0x03A1), FcTo0: uint8(0x52)}, // Ρ to R + {FcFrom: uint16(0x03A3), FcTo0: uint8(0x53)}, // Σ to S + {FcFrom: uint16(0x03A4), FcTo0: uint8(0x54)}, // Τ to T + {FcFrom: uint16(0x03A5), FcTo0: uint8(0x59)}, // Υ to Y + {FcFrom: uint16(0x03A6), FcTo0: uint8(0x46)}, // Φ to F + {FcFrom: uint16(0x03A7), FcTo0: uint8(0x43), FcTo1: uint8(0x68)}, // Χ to Ch + {FcFrom: uint16(0x03A8), FcTo0: uint8(0x50), FcTo1: uint8(0x73)}, // Ψ to Ps + {FcFrom: uint16(0x03A9), FcTo0: uint8(0x4f)}, // Ω to O + {FcFrom: uint16(0x03AA), FcTo0: uint8(0x49)}, // Ϊ to I + {FcFrom: uint16(0x03AB), FcTo0: uint8(0x59)}, // Ϋ to Y + {FcFrom: uint16(0x03AC), FcTo0: uint8(0x61)}, // ά to a + {FcFrom: uint16(0x03AD), FcTo0: uint8(0x65)}, // έ to e + {FcFrom: uint16(0x03AE), FcTo0: uint8(0x69)}, // ή to i + {FcFrom: uint16(0x03AF), FcTo0: uint8(0x69)}, // ί to i + {FcFrom: uint16(0x03B1), FcTo0: uint8(0x61)}, // α to a + {FcFrom: uint16(0x03B2), FcTo0: uint8(0x62)}, // β to b + {FcFrom: uint16(0x03B3), FcTo0: uint8(0x67)}, // γ to g + {FcFrom: uint16(0x03B4), FcTo0: uint8(0x64)}, // δ to d + {FcFrom: uint16(0x03B5), FcTo0: uint8(0x65)}, // ε to e + {FcFrom: uint16(0x03B6), FcTo0: uint8(0x7a)}, // ζ to z + {FcFrom: uint16(0x03B7), FcTo0: uint8(0x69)}, // η to i + {FcFrom: uint16(0x03B8), FcTo0: uint8(0x74), FcTo1: uint8(0x68)}, // θ to th + {FcFrom: uint16(0x03B9), FcTo0: uint8(0x69)}, // ι to i + {FcFrom: uint16(0x03BA), FcTo0: uint8(0x6b)}, // κ to k + {FcFrom: uint16(0x03BB), FcTo0: uint8(0x6c)}, // λ to l + {FcFrom: uint16(0x03BC), FcTo0: uint8(0x6d)}, // μ to m + {FcFrom: uint16(0x03BD), FcTo0: uint8(0x6e)}, // ν to n + {FcFrom: uint16(0x03BE), FcTo0: uint8(0x78)}, // ξ to x + {FcFrom: uint16(0x03BF), FcTo0: uint8(0x6f)}, // ο to o + {FcFrom: uint16(0x03C0), FcTo0: uint8(0x70)}, // π to p + {FcFrom: uint16(0x03C1), FcTo0: uint8(0x72)}, // ρ to r + {FcFrom: uint16(0x03C3), FcTo0: uint8(0x73)}, // σ to s + {FcFrom: uint16(0x03C4), FcTo0: uint8(0x74)}, // τ to t + {FcFrom: uint16(0x03C5), FcTo0: uint8(0x79)}, // υ to y + {FcFrom: uint16(0x03C6), FcTo0: uint8(0x66)}, // φ to f + {FcFrom: uint16(0x03C7), FcTo0: uint8(0x63), FcTo1: uint8(0x68)}, // χ to ch + {FcFrom: uint16(0x03C8), FcTo0: uint8(0x70), FcTo1: uint8(0x73)}, // ψ to ps + {FcFrom: uint16(0x03C9), FcTo0: uint8(0x6f)}, // ω to o + {FcFrom: uint16(0x03CA), FcTo0: uint8(0x69)}, // ϊ to i + {FcFrom: uint16(0x03CB), FcTo0: uint8(0x79)}, // ϋ to y + {FcFrom: uint16(0x03CC), FcTo0: uint8(0x6f)}, // ό to o + {FcFrom: uint16(0x03CD), FcTo0: uint8(0x79)}, // ύ to y + {FcFrom: uint16(0x03CE), FcTo0: uint8(0x69)}, // ώ to i + {FcFrom: uint16(0x0400), FcTo0: uint8(0x45)}, // Ѐ to E + {FcFrom: uint16(0x0401), FcTo0: uint8(0x45)}, // Ё to E + {FcFrom: uint16(0x0402), FcTo0: uint8(0x44)}, // Ђ to D + {FcFrom: uint16(0x0403), FcTo0: uint8(0x47)}, // Ѓ to G + {FcFrom: uint16(0x0404), FcTo0: uint8(0x45)}, // Є to E + {FcFrom: uint16(0x0405), FcTo0: uint8(0x5a)}, // Ѕ to Z + {FcFrom: uint16(0x0406), FcTo0: uint8(0x49)}, // І to I + {FcFrom: uint16(0x0407), FcTo0: uint8(0x49)}, // Ї to I + {FcFrom: uint16(0x0408), FcTo0: uint8(0x4a)}, // Ј to J + {FcFrom: uint16(0x0409), FcTo0: uint8(0x49)}, // Љ to I + {FcFrom: uint16(0x040A), FcTo0: uint8(0x4e)}, // Њ to N + {FcFrom: uint16(0x040B), FcTo0: uint8(0x44)}, // Ћ to D + {FcFrom: uint16(0x040C), FcTo0: uint8(0x4b)}, // Ќ to K + {FcFrom: uint16(0x040D), FcTo0: uint8(0x49)}, // Ѝ to I + {FcFrom: uint16(0x040E), FcTo0: uint8(0x55)}, // Ў to U + {FcFrom: uint16(0x040F), FcTo0: uint8(0x44)}, // Џ to D + {FcFrom: uint16(0x0410), FcTo0: uint8(0x41)}, // А to A + {FcFrom: uint16(0x0411), FcTo0: uint8(0x42)}, // Б to B + {FcFrom: uint16(0x0412), FcTo0: uint8(0x56)}, // В to V + {FcFrom: uint16(0x0413), FcTo0: uint8(0x47)}, // Г to G + {FcFrom: uint16(0x0414), FcTo0: uint8(0x44)}, // Д to D + {FcFrom: uint16(0x0415), FcTo0: uint8(0x45)}, // Е to E + {FcFrom: uint16(0x0416), FcTo0: uint8(0x5a), FcTo1: uint8(0x68)}, // Ж to Zh + {FcFrom: uint16(0x0417), FcTo0: uint8(0x5a)}, // З to Z + {FcFrom: uint16(0x0418), FcTo0: uint8(0x49)}, // И to I + {FcFrom: uint16(0x0419), FcTo0: uint8(0x49)}, // Й to I + {FcFrom: uint16(0x041A), FcTo0: uint8(0x4b)}, // К to K + {FcFrom: uint16(0x041B), FcTo0: uint8(0x4c)}, // Л to L + {FcFrom: uint16(0x041C), FcTo0: uint8(0x4d)}, // М to M + {FcFrom: uint16(0x041D), FcTo0: uint8(0x4e)}, // Н to N + {FcFrom: uint16(0x041E), FcTo0: uint8(0x4f)}, // О to O + {FcFrom: uint16(0x041F), FcTo0: uint8(0x50)}, // П to P + {FcFrom: uint16(0x0420), FcTo0: uint8(0x52)}, // Р to R + {FcFrom: uint16(0x0421), FcTo0: uint8(0x53)}, // С to S + {FcFrom: uint16(0x0422), FcTo0: uint8(0x54)}, // Т to T + {FcFrom: uint16(0x0423), FcTo0: uint8(0x55)}, // У to U + {FcFrom: uint16(0x0424), FcTo0: uint8(0x46)}, // Ф to F + {FcFrom: uint16(0x0425), FcTo0: uint8(0x4b), FcTo1: uint8(0x68)}, // Х to Kh + {FcFrom: uint16(0x0426), FcTo0: uint8(0x54), FcTo1: uint8(0x63)}, // Ц to Tc + {FcFrom: uint16(0x0427), FcTo0: uint8(0x43), FcTo1: uint8(0x68)}, // Ч to Ch + {FcFrom: uint16(0x0428), FcTo0: uint8(0x53), FcTo1: uint8(0x68)}, // Ш to Sh + {FcFrom: uint16(0x0429), FcTo0: uint8(0x53), FcTo1: uint8(0x68), FcTo2: uint8(0x63), FcTo3: uint8(0x68)}, // Щ to Shch + {FcFrom: uint16(0x042A), FcTo0: uint8(0x61)}, // to A + {FcFrom: uint16(0x042B), FcTo0: uint8(0x59)}, // Ы to Y + {FcFrom: uint16(0x042C), FcTo0: uint8(0x59)}, // to Y + {FcFrom: uint16(0x042D), FcTo0: uint8(0x45)}, // Э to E + {FcFrom: uint16(0x042E), FcTo0: uint8(0x49), FcTo1: uint8(0x75)}, // Ю to Iu + {FcFrom: uint16(0x042F), FcTo0: uint8(0x49), FcTo1: uint8(0x61)}, // Я to Ia + {FcFrom: uint16(0x0430), FcTo0: uint8(0x61)}, // а to a + {FcFrom: uint16(0x0431), FcTo0: uint8(0x62)}, // б to b + {FcFrom: uint16(0x0432), FcTo0: uint8(0x76)}, // в to v + {FcFrom: uint16(0x0433), FcTo0: uint8(0x67)}, // г to g + {FcFrom: uint16(0x0434), FcTo0: uint8(0x64)}, // д to d + {FcFrom: uint16(0x0435), FcTo0: uint8(0x65)}, // е to e + {FcFrom: uint16(0x0436), FcTo0: uint8(0x7a), FcTo1: uint8(0x68)}, // ж to zh + {FcFrom: uint16(0x0437), FcTo0: uint8(0x7a)}, // з to z + {FcFrom: uint16(0x0438), FcTo0: uint8(0x69)}, // и to i + {FcFrom: uint16(0x0439), FcTo0: uint8(0x69)}, // й to i + {FcFrom: uint16(0x043A), FcTo0: uint8(0x6b)}, // к to k + {FcFrom: uint16(0x043B), FcTo0: uint8(0x6c)}, // л to l + {FcFrom: uint16(0x043C), FcTo0: uint8(0x6d)}, // м to m + {FcFrom: uint16(0x043D), FcTo0: uint8(0x6e)}, // н to n + {FcFrom: uint16(0x043E), FcTo0: uint8(0x6f)}, // о to o + {FcFrom: uint16(0x043F), FcTo0: uint8(0x70)}, // п to p + {FcFrom: uint16(0x0440), FcTo0: uint8(0x72)}, // р to r + {FcFrom: uint16(0x0441), FcTo0: uint8(0x73)}, // с to s + {FcFrom: uint16(0x0442), FcTo0: uint8(0x74)}, // т to t + {FcFrom: uint16(0x0443), FcTo0: uint8(0x75)}, // у to u + {FcFrom: uint16(0x0444), FcTo0: uint8(0x66)}, // ф to f + {FcFrom: uint16(0x0445), FcTo0: uint8(0x6b), FcTo1: uint8(0x68)}, // х to kh + {FcFrom: uint16(0x0446), FcTo0: uint8(0x74), FcTo1: uint8(0x63)}, // ц to tc + {FcFrom: uint16(0x0447), FcTo0: uint8(0x63), FcTo1: uint8(0x68)}, // ч to ch + {FcFrom: uint16(0x0448), FcTo0: uint8(0x73), FcTo1: uint8(0x68)}, // ш to sh + {FcFrom: uint16(0x0449), FcTo0: uint8(0x73), FcTo1: uint8(0x68), FcTo2: uint8(0x63), FcTo3: uint8(0x68)}, // щ to shch + {FcFrom: uint16(0x044A), FcTo0: uint8(0x61)}, // to a + {FcFrom: uint16(0x044B), FcTo0: uint8(0x79)}, // ы to y + {FcFrom: uint16(0x044C), FcTo0: uint8(0x79)}, // to y + {FcFrom: uint16(0x044D), FcTo0: uint8(0x65)}, // э to e + {FcFrom: uint16(0x044E), FcTo0: uint8(0x69), FcTo1: uint8(0x75)}, // ю to iu + {FcFrom: uint16(0x044F), FcTo0: uint8(0x69), FcTo1: uint8(0x61)}, // я to ia + {FcFrom: uint16(0x0450), FcTo0: uint8(0x65)}, // ѐ to e + {FcFrom: uint16(0x0451), FcTo0: uint8(0x65)}, // ё to e + {FcFrom: uint16(0x0452), FcTo0: uint8(0x64)}, // ђ to d + {FcFrom: uint16(0x0453), FcTo0: uint8(0x67)}, // ѓ to g + {FcFrom: uint16(0x0454), FcTo0: uint8(0x65)}, // є to e + {FcFrom: uint16(0x0455), FcTo0: uint8(0x7a)}, // ѕ to z + {FcFrom: uint16(0x0456), FcTo0: uint8(0x69)}, // і to i + {FcFrom: uint16(0x0457), FcTo0: uint8(0x69)}, // ї to i + {FcFrom: uint16(0x0458), FcTo0: uint8(0x6a)}, // ј to j + {FcFrom: uint16(0x0459), FcTo0: uint8(0x69)}, // љ to i + {FcFrom: uint16(0x045A), FcTo0: uint8(0x6e)}, // њ to n + {FcFrom: uint16(0x045B), FcTo0: uint8(0x64)}, // ћ to d + {FcFrom: uint16(0x045C), FcTo0: uint8(0x6b)}, // ќ to k + {FcFrom: uint16(0x045D), FcTo0: uint8(0x69)}, // ѝ to i + {FcFrom: uint16(0x045E), FcTo0: uint8(0x75)}, // ў to u + {FcFrom: uint16(0x045F), FcTo0: uint8(0x64)}, // џ to d + {FcFrom: uint16(0x1E02), FcTo0: uint8(0x42)}, // Ḃ to B + {FcFrom: uint16(0x1E03), FcTo0: uint8(0x62)}, // ḃ to b + {FcFrom: uint16(0x1E0A), FcTo0: uint8(0x44)}, // Ḋ to D + {FcFrom: uint16(0x1E0B), FcTo0: uint8(0x64)}, // ḋ to d + {FcFrom: uint16(0x1E1E), FcTo0: uint8(0x46)}, // Ḟ to F + {FcFrom: uint16(0x1E1F), FcTo0: uint8(0x66)}, // ḟ to f + {FcFrom: uint16(0x1E40), FcTo0: uint8(0x4D)}, // Ṁ to M + {FcFrom: uint16(0x1E41), FcTo0: uint8(0x6D)}, // ṁ to m + {FcFrom: uint16(0x1E56), FcTo0: uint8(0x50)}, // Ṗ to P + {FcFrom: uint16(0x1E57), FcTo0: uint8(0x70)}, // ṗ to p + {FcFrom: uint16(0x1E60), FcTo0: uint8(0x53)}, // Ṡ to S + {FcFrom: uint16(0x1E61), FcTo0: uint8(0x73)}, // ṡ to s + {FcFrom: uint16(0x1E6A), FcTo0: uint8(0x54)}, // Ṫ to T + {FcFrom: uint16(0x1E6B), FcTo0: uint8(0x74)}, // ṫ to t + {FcFrom: uint16(0x1E80), FcTo0: uint8(0x57)}, // Ẁ to W + {FcFrom: uint16(0x1E81), FcTo0: uint8(0x77)}, // ẁ to w + {FcFrom: uint16(0x1E82), FcTo0: uint8(0x57)}, // Ẃ to W + {FcFrom: uint16(0x1E83), FcTo0: uint8(0x77)}, // ẃ to w + {FcFrom: uint16(0x1E84), FcTo0: uint8(0x57)}, // Ẅ to W + {FcFrom: uint16(0x1E85), FcTo0: uint8(0x77)}, // ẅ to w + {FcFrom: uint16(0x1EF2), FcTo0: uint8(0x59)}, // Ỳ to Y + {FcFrom: uint16(0x1EF3), FcTo0: uint8(0x79)}, // ỳ to y + {FcFrom: uint16(0xFB00), FcTo0: uint8(0x66), FcTo1: uint8(0x66)}, // ff to ff + {FcFrom: uint16(0xFB01), FcTo0: uint8(0x66), FcTo1: uint8(0x69)}, // fi to fi + {FcFrom: uint16(0xFB02), FcTo0: uint8(0x66), FcTo1: uint8(0x6C)}, // fl to fl + {FcFrom: uint16(0xFB05), FcTo0: uint8(0x73), FcTo1: uint8(0x74)}, // ſt to st + {FcFrom: uint16(0xFB06), FcTo0: uint8(0x73), FcTo1: uint8(0x74)}, // st to st } /* spellfix.c:1306:30 */ func spellfixFindTranslit(tls *libc.TLS, c int32, pxTop uintptr) uintptr { /* spellfix.c:1698:30: */ @@ -30072,8 +27561,8 @@ func translen_to_charlen(tls *libc.TLS, zIn uintptr, nIn int32, nTrans int32) in // Convert a string that contains non-ASCII Roman characters into // pure ASCII. func transliterateSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* spellfix.c:1817:13: */ - var zIn uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var nIn int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zIn uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + var nIn int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) var zOut uintptr = transliterate(tls, zIn, nIn) if zOut == uintptr(0) { sqlite3.Xsqlite3_result_error_nomem(tls, context) @@ -30100,8 +27589,8 @@ func scriptCodeSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) bp := tls.Alloc(4) defer tls.Free(4) - var zIn uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var nIn int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zIn uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + var nIn int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) var c int32 // var sz int32 at bp, 4 @@ -30114,41 +27603,41 @@ func scriptCodeSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) zIn += uintptr(*(*int32)(unsafe.Pointer(bp /* sz */))) nIn = nIn - (*(*int32)(unsafe.Pointer(bp /* sz */))) if c < 0x02af { - if (c >= 0x80) || (int32(midClass[(c&0x7f)]) < 10) { - scriptMask = scriptMask | (0x0001) + if (c >= 0x80) || (int32(midClass[(c&0x7f)]) < CCLASS_DIGIT) { + scriptMask = scriptMask | (SCRIPT_LATIN) } else if (c >= '0') && (c <= '9') { seenDigit = 1 } } else if (c >= 0x0400) && (c <= 0x04ff) { - scriptMask = scriptMask | (0x0002) + scriptMask = scriptMask | (SCRIPT_CYRILLIC) } else if (c >= 0x0386) && (c <= 0x03ce) { - scriptMask = scriptMask | (0x0004) + scriptMask = scriptMask | (SCRIPT_GREEK) } else if (c >= 0x0590) && (c <= 0x05ff) { - scriptMask = scriptMask | (0x0008) + scriptMask = scriptMask | (SCRIPT_HEBREW) } else if (c >= 0x0600) && (c <= 0x06ff) { - scriptMask = scriptMask | (0x0010) + scriptMask = scriptMask | (SCRIPT_ARABIC) } } if (scriptMask == 0) && (seenDigit != 0) { - scriptMask = 0x0001 + scriptMask = SCRIPT_LATIN } switch scriptMask { case 0: res = 999 break - case 0x0001: + case SCRIPT_LATIN: res = 215 break - case 0x0002: + case SCRIPT_CYRILLIC: res = 220 break - case 0x0004: + case SCRIPT_GREEK: res = 200 break - case 0x0008: + case SCRIPT_HEBREW: res = 125 break - case 0x0010: + case SCRIPT_ARABIC: res = 160 break default: @@ -30231,7 +27720,7 @@ func spellfix1DbExec(tls *libc.TLS, pRc uintptr, db uintptr, zFormat uintptr, va zSql = sqlite3.Xsqlite3_vmprintf(tls, zFormat, ap) _ = ap if zSql == uintptr(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } else { *(*int32)(unsafe.Pointer(pRc)) = sqlite3.Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) @@ -30244,13 +27733,13 @@ func spellfix1Uninit(tls *libc.TLS, isDestroy int32, pVTab uintptr) int32 { /* s defer tls.Free(20) var p uintptr = pVTab - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK if isDestroy != 0 { var db uintptr = (*spellfix1_vtab)(unsafe.Pointer(p)).Fdb spellfix1DbExec(tls, bp+16 /* &rc */, db, ts+6457, /* "DROP TABLE IF EX..." */ libc.VaList(bp, (*spellfix1_vtab)(unsafe.Pointer(p)).FzDbName, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName)) } - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { sqlite3.Xsqlite3_free(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName) editDist3ConfigDelete(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3) sqlite3.Xsqlite3_free(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable) @@ -30277,7 +27766,7 @@ func spellfix1Dequote(tls *libc.TLS, zIn uintptr) uintptr { /* spellfix.c:2005:1 var i int32 var j int32 var c int8 - for (int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zIn + uintptr(0))))))*2))) & int32(_ISspace)) != 0 { + 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 { zIn++ } zOut = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zIn)) @@ -30286,7 +27775,7 @@ func spellfix1Dequote(tls *libc.TLS, zIn uintptr) uintptr { /* spellfix.c:2005:1 } i = int32(libc.Xstrlen(tls, zOut)) *(*int8)(unsafe.Pointer(zOut + uintptr(i))) = int8(0) - c = *(*int8)(unsafe.Pointer(zOut + uintptr(0))) + c = *(*int8)(unsafe.Pointer(zOut)) if (int32(c) == '\'') || (int32(c) == '"') { i = 1 j = 0 @@ -30317,31 +27806,31 @@ func spellfix1Init(tls *libc.TLS, isCreate int32, db uintptr, pAux uintptr, argc var pNew uintptr = uintptr(0) // const char *zModule = argv[0]; // not used - var zDbName uintptr = *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) - var zTableName uintptr = *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)) + var zDbName uintptr = *(*uintptr)(unsafe.Pointer(argv + 1*8)) + var zTableName uintptr = *(*uintptr)(unsafe.Pointer(argv + 2*8)) var nDbName int32 - *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = SQLITE_OK var i int32 nDbName = int32(libc.Xstrlen(tls, zDbName)) pNew = sqlite3.Xsqlite3_malloc64(tls, (uint64((uint64(unsafe.Sizeof(spellfix1_vtab{})) + uint64(nDbName)) + uint64(1)))) if pNew == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = SQLITE_NOMEM } else { libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(spellfix1_vtab{}))) - (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzDbName = (pNew + uintptr(1)*64) + (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzDbName = (pNew + 1*64) libc.Xmemcpy(tls, (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzDbName, zDbName, (uint64(nDbName + 1))) (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzTableName = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zTableName)) (*spellfix1_vtab)(unsafe.Pointer(pNew)).Fdb = db if (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzTableName == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = SQLITE_NOMEM } else { - sqlite3.Xsqlite3_vtab_config(tls, db, 2, 0) + sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+6494 /* "CREATE TABLE x(w..." */) } - if (*(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == 0) && (isCreate != 0) { + if (*(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == SQLITE_OK) && (isCreate != 0) { spellfix1DbExec(tls, bp+56 /* &rc */, db, ts+6648, /* "CREATE TABLE IF ..." */ @@ -30351,16 +27840,16 @@ func spellfix1Init(tls *libc.TLS, isCreate int32, db uintptr, pAux uintptr, argc ts+6782, /* "CREATE INDEX IF ..." */ libc.VaList(bp+24, zDbName, zTableName, zTableName)) } - for i = 3; (*(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == 0) && (i < argc); i++ { + for i = 3; (*(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == SQLITE_OK) && (i < argc); i++ { if (libc.Xstrncmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), ts+6867 /* "edit_cost_table=" */, uint64(16)) == 0) && ((*spellfix1_vtab)(unsafe.Pointer(pNew)).FzCostTable == uintptr(0)) { - (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzCostTable = spellfix1Dequote(tls, (*(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) + uintptr(16))) + (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzCostTable = spellfix1Dequote(tls, (*(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) + 16)) if (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzCostTable == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = SQLITE_NOMEM } continue } *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+6884 /* "bad argument to ..." */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) - *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = SQLITE_ERROR } } @@ -30420,7 +27909,7 @@ func spellfix1Close(tls *libc.TLS, cur uintptr) int32 { /* spellfix.c:2191:12: * spellfix1ResizeCursor(tls, pCur, 0) sqlite3.Xsqlite3_free(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FzPattern) sqlite3.Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } // @@ -30450,56 +27939,56 @@ __1: } // Terms of the form: word MATCH $str - if (((iPlan & 0x01) == 0) && - ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 0)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 64) { - iPlan = iPlan | (0x01) + if (((iPlan & SPELLFIX_IDXNUM_MATCH) == 0) && + ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == SPELLFIX_COL_WORD)) && + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) { + iPlan = iPlan | (SPELLFIX_IDXNUM_MATCH) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) } // Terms of the form: langid = $langid - if (((iPlan & 0x02) == 0) && - ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 3)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2) { - iPlan = iPlan | (0x02) + if (((iPlan & SPELLFIX_IDXNUM_LANGID) == 0) && + ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == SPELLFIX_COL_LANGID)) && + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { + iPlan = iPlan | (SPELLFIX_IDXNUM_LANGID) iLangTerm = i } // Terms of the form: top = $top - if (((iPlan & 0x04) == 0) && - ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 7)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2) { - iPlan = iPlan | (0x04) + if (((iPlan & SPELLFIX_IDXNUM_TOP) == 0) && + ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == SPELLFIX_COL_TOP)) && + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { + iPlan = iPlan | (SPELLFIX_IDXNUM_TOP) iTopTerm = i } // Terms of the form: scope = $scope - if (((iPlan & 0x08) == 0) && - ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 8)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2) { - iPlan = iPlan | (0x08) + if (((iPlan & SPELLFIX_IDXNUM_SCOPE) == 0) && + ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == SPELLFIX_COL_SCOPE)) && + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { + iPlan = iPlan | (SPELLFIX_IDXNUM_SCOPE) iScopeTerm = i } // Terms of the form: distance < $dist or distance <= $dist if (((iPlan & (0x10 | 0x20)) == 0) && - ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 2)) && - ((int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 16) || - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 8)) { - if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 16 { - iPlan = iPlan | (0x10) + ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == SPELLFIX_COL_DISTANCE)) && + ((int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT) || + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LE)) { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT { + iPlan = iPlan | (SPELLFIX_IDXNUM_DISTLT) } else { - iPlan = iPlan | (0x20) + iPlan = iPlan | (SPELLFIX_IDXNUM_DISTLE) } iDistTerm = i } // Terms of the form: distance < $dist or distance <= $dist - if (((iPlan & 0x40) == 0) && + if (((iPlan & SPELLFIX_IDXNUM_ROWID) == 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < 0)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2) { - iPlan = iPlan | (0x40) + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { + iPlan = iPlan | (SPELLFIX_IDXNUM_ROWID) iRowidTerm = i } @@ -30512,23 +28001,23 @@ __2: goto __3 __3: ; - if (iPlan & 0x01) != 0 { + if (iPlan & SPELLFIX_IDXNUM_MATCH) != 0 { var idx int32 = 2 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = iPlan if (((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1) && - ((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).FiColumn == 4)) && - (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).Fdesc) == 0) { + ((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn == SPELLFIX_COL_SCORE)) && + (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0) { (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 // Default order by iScore } - if (iPlan & 0x02) != 0 { + if (iPlan & SPELLFIX_IDXNUM_LANGID) != 0 { (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iLangTerm)*8)).FargvIndex = libc.PostIncInt32(&idx, 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iLangTerm)*8)).Fomit = uint8(1) } - if (iPlan & 0x04) != 0 { + if (iPlan & SPELLFIX_IDXNUM_TOP) != 0 { (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iTopTerm)*8)).FargvIndex = libc.PostIncInt32(&idx, 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iTopTerm)*8)).Fomit = uint8(1) } - if (iPlan & 0x08) != 0 { + if (iPlan & SPELLFIX_IDXNUM_SCOPE) != 0 { (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iScopeTerm)*8)).FargvIndex = libc.PostIncInt32(&idx, 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iScopeTerm)*8)).Fomit = uint8(1) } @@ -30537,8 +28026,8 @@ __3: (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iDistTerm)*8)).Fomit = uint8(1) } (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1e5 - } else if (iPlan & 0x40) != 0 { - (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0x40 + } else if (iPlan & SPELLFIX_IDXNUM_ROWID) != 0 { + (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = SPELLFIX_IDXNUM_ROWID (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8)).FargvIndex = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8)).Fomit = uint8(1) (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(5) @@ -30546,7 +28035,7 @@ __3: (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1e50 } - return 0 + return SQLITE_OK } // Open a new fuzzy-search cursor. @@ -30555,12 +28044,12 @@ func spellfix1Open(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* sp var pCur uintptr pCur = sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(spellfix1_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(spellfix1_cursor{}))) (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpVTab = p *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Adjust a distance measurement by the words rank in order to show @@ -30649,12 +28138,12 @@ func spellfix1RunQuery(tls *libc.TLS, p uintptr, zQuery uintptr, nQuery int32) { } // Prior memory allocation failure zClass = phoneticHash(tls, zQuery, nQuery) if zClass == uintptr(0) { - (*MatchQuery)(unsafe.Pointer(p)).Frc = 7 + (*MatchQuery)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM return } nClass = int32(libc.Xstrlen(tls, zClass)) - if nClass > (32 - 2) { - nClass = (32 - 2) + if nClass > (SPELLFIX_MX_HASH - 2) { + nClass = (SPELLFIX_MX_HASH - 2) *(*int8)(unsafe.Pointer(zClass + uintptr(nClass))) = int8(0) } if nClass <= iScope { @@ -30672,12 +28161,12 @@ func spellfix1RunQuery(tls *libc.TLS, p uintptr, zQuery uintptr, nQuery int32) { *(*int8)(unsafe.Pointer(bp + 40 /* &zHash2[0] */ + uintptr((iScope + 1)))) = int8(0) libc.Xmemcpy(tls, ((p + 108 /* &.azPrior */) + uintptr(libc.PostIncInt32(&(*MatchQuery)(unsafe.Pointer(p)).FnRun, 1))*32), bp+8 /* &zHash1[0] */, (uint64(iScope + 1))) - if (sqlite3.Xsqlite3_bind_text(tls, pStmt, 1, bp+8 /* &zHash1[0] */, -1, uintptr(0)) == 7) || - (sqlite3.Xsqlite3_bind_text(tls, pStmt, 2, bp+40 /* &zHash2[0] */, -1, uintptr(0)) == 7) { - (*MatchQuery)(unsafe.Pointer(p)).Frc = 7 + if (sqlite3.Xsqlite3_bind_text(tls, pStmt, 1, bp+8 /* &zHash1[0] */, -1, uintptr(0)) == SQLITE_NOMEM) || + (sqlite3.Xsqlite3_bind_text(tls, pStmt, 2, bp+40 /* &zHash2[0] */, -1, uintptr(0)) == SQLITE_NOMEM) { + (*MatchQuery)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM return } - for sqlite3.Xsqlite3_step(tls, pStmt) == 100 { + for sqlite3.Xsqlite3_step(tls, pStmt) == SQLITE_ROW { *(*int32)(unsafe.Pointer(bp + 72 /* iMatchlen */)) = -1 iRank = sqlite3.Xsqlite3_column_int(tls, pStmt, 2) if (*MatchQuery)(unsafe.Pointer(p)).FpMatchStr3 != 0 { @@ -30692,7 +28181,7 @@ func spellfix1RunQuery(tls *libc.TLS, p uintptr, zQuery uintptr, nQuery int32) { iDist = editdist1(tls, (*MatchQuery)(unsafe.Pointer(p)).FzPattern, zK1, uintptr(0)) } if iDist < 0 { - (*MatchQuery)(unsafe.Pointer(p)).Frc = 7 + (*MatchQuery)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM break } (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnSearch++ @@ -30708,7 +28197,7 @@ func spellfix1RunQuery(tls *libc.TLS, p uintptr, zQuery uintptr, nQuery int32) { if iDist > (*MatchQuery)(unsafe.Pointer(p)).FiMaxDist { continue } - if ((*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow >= (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnAlloc) && (((*spellfix1_cursor)(unsafe.Pointer(pCur)).FidxNum & 0x04) == 0) { + if ((*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow >= (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnAlloc) && (((*spellfix1_cursor)(unsafe.Pointer(pCur)).FidxNum & SPELLFIX_IDXNUM_TOP) == 0) { spellfix1ResizeCursor(tls, pCur, (((*spellfix1_cursor)(unsafe.Pointer(pCur)).FnAlloc * 2) + 10)) if (*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa == uintptr(0) { break @@ -30728,7 +28217,7 @@ func spellfix1RunQuery(tls *libc.TLS, p uintptr, zQuery uintptr, nQuery int32) { (*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))) if (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa+uintptr(idx)*64)).FzWord == uintptr(0) { - (*MatchQuery)(unsafe.Pointer(p)).Frc = 7 + (*MatchQuery)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM break } (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr(idx)*64)).FiRowid = sqlite3.Xsqlite3_column_int64(tls, pStmt, 0) @@ -30741,7 +28230,7 @@ func spellfix1RunQuery(tls *libc.TLS, p uintptr, zQuery uintptr, nQuery int32) { (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow++ } if (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow == (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnAlloc { - iWorst = (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr(0)*64)).FiScore + iWorst = (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa)).FiScore idxWorst = 0 for i = 1; i < (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow; i++ { iScore = (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr(i)*64)).FiScore @@ -30796,7 +28285,7 @@ func spellfix1FilterForMatch(tls *libc.TLS, pCur uintptr, argc int32, argv uintp if !((*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3 == uintptr(0)) { goto __2 } - return 7 + return SQLITE_NOMEM __2: ; libc.Xmemset(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3, 0, uint64(unsafe.Sizeof(EditDist3Config{}))) @@ -30841,10 +28330,10 @@ __5: (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FiScope = 1 __8: ; - if !((*MatchQuery)(unsafe.Pointer(bp+24 /* &x */)).FiScope > (32 - 2)) { + if !((*MatchQuery)(unsafe.Pointer(bp+24 /* &x */)).FiScope > (SPELLFIX_MX_HASH - 2)) { goto __9 } - (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FiScope = (32 - 2) + (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FiScope = (SPELLFIX_MX_HASH - 2) __9: ; __7: @@ -30869,11 +28358,11 @@ __10: ; spellfix1ResetCursor(tls, pCur) spellfix1ResizeCursor(tls, pCur, iLimit) - zMatchThis = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zMatchThis = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if !(zMatchThis == uintptr(0)) { goto __13 } - return 0 + return SQLITE_OK __13: ; if !((*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3 != 0) { @@ -30884,7 +28373,7 @@ __13: if !(pMatchStr3 == uintptr(0)) { goto __16 } - (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = 7 + (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = SQLITE_NOMEM goto filter_exit __16: ; @@ -30893,13 +28382,13 @@ __14: (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FpLang = uintptr(0) __15: ; - zPattern = transliterate(tls, zMatchThis, sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + zPattern = transliterate(tls, zMatchThis, sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) sqlite3.Xsqlite3_free(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FzPattern) (*spellfix1_cursor)(unsafe.Pointer(pCur)).FzPattern = zPattern if !(zPattern == uintptr(0)) { goto __17 } - (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = 7 + (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = SQLITE_NOMEM goto filter_exit __17: ; @@ -30917,7 +28406,7 @@ __18: if !(zSql == uintptr(0)) { goto __19 } - (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = 7 + (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = SQLITE_NOMEM *(*uintptr)(unsafe.Pointer(bp + 168 /* pStmt */)) = uintptr(0) goto filter_exit __19: @@ -30933,7 +28422,7 @@ __19: (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FiLang = iLang (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = rc (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FpConfig3 = (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3 - if !((*MatchQuery)(unsafe.Pointer(bp+24 /* &x */)).Frc == 0) { + if !((*MatchQuery)(unsafe.Pointer(bp+24 /* &x */)).Frc == SQLITE_OK) { goto __20 } spellfix1RunQuery(tls, bp+24 /* &x */, zPattern, nPattern) @@ -30950,7 +28439,7 @@ __20: (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiScope = iScope goto __22 __21: - (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = 7 + (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = SQLITE_NOMEM __22: ; @@ -30965,7 +28454,7 @@ func spellfix1FilterForFullScan(tls *libc.TLS, pCur uintptr, argc int32, argv ui bp := tls.Alloc(24) defer tls.Free(24) - var rc int32 = 0 + var rc int32 = SQLITE_OK var idxNum int32 = (*spellfix1_cursor)(unsafe.Pointer(pCur)).FidxNum var zSql uintptr var pVTab uintptr = (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpVTab @@ -30981,23 +28470,23 @@ func spellfix1FilterForFullScan(tls *libc.TLS, pCur uintptr, argc int32, argv ui return ts + 488 /* "" */ }())) if zSql == uintptr(0) { - return 7 + return SQLITE_NOMEM } rc = sqlite3.Xsqlite3_prepare_v2(tls, (*spellfix1_vtab)(unsafe.Pointer(pVTab)).Fdb, zSql, -1, (pCur + 56 /* &.pFullScan */), uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) - if (rc == 0) && ((idxNum & 64) != 0) { + if (rc == SQLITE_OK) && ((idxNum & 64) != 0) { - rc = sqlite3.Xsqlite3_bind_value(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan, 1, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + rc = sqlite3.Xsqlite3_bind_value(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan, 1, *(*uintptr)(unsafe.Pointer(argv))) } (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow = libc.AssignPtrInt32(pCur+36 /* &.iRow */, 0) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_step(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan) - if rc == 100 { + if rc == SQLITE_ROW { (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow = -1 - rc = 0 + rc = SQLITE_OK } - if rc == 101 { - rc = 0 + if rc == SQLITE_DONE { + rc = SQLITE_OK } } else { (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow = 0 @@ -31023,15 +28512,15 @@ func spellfix1Filter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, a // Advance a cursor to its next row of output func spellfix1Next(tls *libc.TLS, cur uintptr) int32 { /* spellfix.c:2701:12: */ var pCur uintptr = cur - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow < (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow { if (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan != 0 { rc = sqlite3.Xsqlite3_step(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan) - if rc != 100 { + if rc != SQLITE_ROW { (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow = (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow } - if (rc == 100) || (rc == 101) { - rc = 0 + if (rc == SQLITE_ROW) || (rc == SQLITE_DONE) { + rc = SQLITE_OK } } else { (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow++ @@ -31053,45 +28542,45 @@ func spellfix1Column(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { / var pCur uintptr = cur if (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan != 0 { - if i <= 3 { + if i <= SPELLFIX_COL_LANGID { sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan, i)) } else { sqlite3.Xsqlite3_result_null(tls, ctx) } - return 0 + return SQLITE_OK } switch i { - case 0: + case SPELLFIX_COL_WORD: { 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)) break } - case 1: + case SPELLFIX_COL_RANK: { 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) break } - case 2: + case SPELLFIX_COL_DISTANCE: { 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) break } - case 3: + case SPELLFIX_COL_LANGID: { sqlite3.Xsqlite3_result_int(tls, ctx, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiLang) break } - case 4: + case SPELLFIX_COL_SCORE: { 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) break } - case 5: + case SPELLFIX_COL_MATCHLEN: { *(*int32)(unsafe.Pointer(bp /* iMatchlen */)) = (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr((*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow)*64)).FiMatchlen if *(*int32)(unsafe.Pointer(bp /* iMatchlen */)) < 0 { @@ -31104,12 +28593,12 @@ func spellfix1Column(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { / var res int32 zTranslit = transliterate(tls, zWord, nWord) if !(zTranslit != 0) { - return 7 + return SQLITE_NOMEM } res = editdist1(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FzPattern, zTranslit, bp /* &iMatchlen */) sqlite3.Xsqlite3_free(tls, zTranslit) if res < 0 { - return 7 + return SQLITE_NOMEM } *(*int32)(unsafe.Pointer(bp /* iMatchlen */)) = translen_to_charlen(tls, zWord, nWord, *(*int32)(unsafe.Pointer(bp /* iMatchlen */))) } else { @@ -31121,25 +28610,25 @@ func spellfix1Column(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { / break } - case 6: + case SPELLFIX_COL_PHONEHASH: { 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)) break } - case 7: + case SPELLFIX_COL_TOP: { sqlite3.Xsqlite3_result_int(tls, ctx, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiTop) break } - case 8: + case SPELLFIX_COL_SCOPE: { sqlite3.Xsqlite3_result_int(tls, ctx, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiScope) break } - case 9: + case SPELLFIX_COL_SRCHCNT: { sqlite3.Xsqlite3_result_int(tls, ctx, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnSearch) break @@ -31152,7 +28641,7 @@ func spellfix1Column(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { / } } - return 0 + return SQLITE_OK } // The rowid. @@ -31163,7 +28652,7 @@ func spellfix1Rowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* spell } else { *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr((*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow)*64)).FiRowid } - return 0 + return SQLITE_OK } // This function is called by the xUpdate() method. It returns a string @@ -31185,7 +28674,7 @@ func spellfix1Update(tls *libc.TLS, pVTab uintptr, argc int32, argv uintptr, pRo bp := tls.Alloc(284) defer tls.Free(284) - *(*int32)(unsafe.Pointer(bp + 280 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 280 /* rc */)) = SQLITE_OK var rowid sqlite3_int64 var newRowid sqlite3_int64 var p uintptr = pVTab @@ -31193,17 +28682,17 @@ func spellfix1Update(tls *libc.TLS, pVTab uintptr, argc int32, argv uintptr, pRo if argc == 1 { // A delete operation on the rowid given by argv[0] - rowid = libc.AssignPtrInt64(pRowid, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + rowid = libc.AssignPtrInt64(pRowid, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))) spellfix1DbExec(tls, bp+280 /* &rc */, db, ts+7122, /* "DELETE FROM \"%w\"..." */ libc.VaList(bp, (*spellfix1_vtab)(unsafe.Pointer(p)).FzDbName, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName, rowid)) } else { - var zWord uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((0+2))*8))) - var nWord int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((0+2))*8))) - var iLang int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((3+2))*8))) - var iRank int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((1+2))*8))) - var zSoundslike uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((10+2))*8))) - var nSoundslike int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((10+2))*8))) + var zWord uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) + var nWord int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) + var iLang int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) + var iRank int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) + var zSoundslike uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 12*8))) + var nSoundslike int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 12*8))) var zK1 uintptr var zK2 uintptr var i int32 @@ -31214,17 +28703,17 @@ func spellfix1Update(tls *libc.TLS, pVTab uintptr, argc int32, argv uintptr, pRo // Inserts of the form: INSERT INTO table(command) VALUES('xyzzy'); // cause zWord to be NULL, so we look at the "command" column to see // what special actions to take - var zCmd uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((11+2))*8))) + var zCmd uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 13*8))) if zCmd == uintptr(0) { (*sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+7165, /* "NOT NULL constra..." */ libc.VaList(bp+24, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName)) - return (19 | (int32(5) << 8)) + return (SQLITE_CONSTRAINT | (int32(5) << 8)) } if libc.Xstrcmp(tls, zCmd, ts+7201 /* "reset" */) == 0 { // Reset the edit cost table (if there is one). editDist3ConfigDelete(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3) (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3 = uintptr(0) - return 0 + return SQLITE_OK } if libc.Xstrncmp(tls, zCmd, ts+6867 /* "edit_cost_table=" */, uint64(16)) == 0 { editDist3ConfigDelete(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3) @@ -31232,17 +28721,17 @@ func spellfix1Update(tls *libc.TLS, pVTab uintptr, argc int32, argv uintptr, pRo sqlite3.Xsqlite3_free(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable) (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable = spellfix1Dequote(tls, (zCmd + uintptr(16))) if (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable == uintptr(0) { - return 7 + return SQLITE_NOMEM } - if (int32(*(*int8)(unsafe.Pointer((*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable + uintptr(0)))) == 0) || (sqlite3.Xsqlite3_stricmp(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable, ts+7207 /* "null" */) == 0) { + if (int32(*(*int8)(unsafe.Pointer((*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable))) == 0) || (sqlite3.Xsqlite3_stricmp(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable, ts+7207 /* "null" */) == 0) { sqlite3.Xsqlite3_free(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable) (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable = uintptr(0) } - return 0 + return SQLITE_OK } (*sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+7212, /* "unknown value fo..." */ libc.VaList(bp+32, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName, zCmd)) - return 1 + return SQLITE_ERROR } if iRank < 1 { iRank = 1 @@ -31253,7 +28742,7 @@ func spellfix1Update(tls *libc.TLS, pVTab uintptr, argc int32, argv uintptr, pRo zK1 = transliterate(tls, zWord, nWord) } if zK1 == uintptr(0) { - return 7 + return SQLITE_NOMEM } for i = 0; (int32(libc.AssignInt8(&c, *(*int8)(unsafe.Pointer(zK1 + uintptr(i)))))) != 0; i++ { if (int32(c) >= 'A') && (int32(c) <= 'Z') { @@ -31263,17 +28752,17 @@ func spellfix1Update(tls *libc.TLS, pVTab uintptr, argc int32, argv uintptr, pRo zK2 = phoneticHash(tls, zK1, i) if zK2 == uintptr(0) { sqlite3.Xsqlite3_free(tls, zK1) - return 7 + return SQLITE_NOMEM } - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) == 5 { + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) == SQLITE_NULL { spellfix1DbExec(tls, bp+280 /* &rc */, db, ts+7247, /* "INSERT INTO \"%w\"..." */ libc.VaList(bp+48, (*spellfix1_vtab)(unsafe.Pointer(p)).FzDbName, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName, iRank, iLang, zWord, zK1, zWord, zK2)) } else { - newRowid = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + newRowid = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) spellfix1DbExec(tls, bp+280 /* &rc */, db, ts+7333, /* "INSERT OR %s INT..." */ @@ -31282,8 +28771,8 @@ func spellfix1Update(tls *libc.TLS, pVTab uintptr, argc int32, argv uintptr, pRo } *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_last_insert_rowid(tls, db) } else { - rowid = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - newRowid = libc.AssignPtrInt64(pRowid, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) + rowid = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) + newRowid = libc.AssignPtrInt64(pRowid, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) spellfix1DbExec(tls, bp+280 /* &rc */, db, ts+7433, /* "UPDATE OR %s \"%w..." */ @@ -31303,15 +28792,15 @@ func spellfix1Rename(tls *libc.TLS, pVTab uintptr, zNew uintptr) int32 { /* spel var p uintptr = pVTab var db uintptr = (*spellfix1_vtab)(unsafe.Pointer(p)).Fdb - *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = SQLITE_OK var zNewName uintptr = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zNew)) if zNewName == uintptr(0) { - return 7 + return SQLITE_NOMEM } spellfix1DbExec(tls, bp+32 /* &rc */, db, ts+7542, /* "ALTER TABLE \"%w\"..." */ libc.VaList(bp+8, (*spellfix1_vtab)(unsafe.Pointer(p)).FzDbName, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName, zNewName)) - if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK { sqlite3.Xsqlite3_free(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName) (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName = zNewName } else { @@ -31321,82 +28810,57 @@ func spellfix1Rename(tls *libc.TLS, pVTab uintptr, zNew uintptr) int32 { /* spel } // A virtual table module that provides fuzzy search. -var spellfix1Module = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - handle CREATE VIRTUAL TABLE - 0, - FxBestIndex:// xConnect - reconnected to an existing table - 0, - FxDisconnect:// xBestIndex - figure out how to do a query - 0, - FxDestroy:// xDisconnect - close a connection - 0, - FxOpen:// xDestroy - handle DROP TABLE - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - 0, // xRename +var spellfix1Module = sqlite3_module{ // iVersion + FxCreate: 0, // xCreate - handle CREATE VIRTUAL TABLE + FxConnect: 0, // xConnect - reconnected to an existing table + FxBestIndex: 0, // xBestIndex - figure out how to do a query + FxDisconnect: 0, // xDisconnect - close a connection + FxDestroy: 0, // xDestroy - handle DROP TABLE + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRowid - read data + FxUpdate: 0, // xFindMethod + FxRename: 0, // xRename } /* spellfix.c:2991:23 */ // Register the various functions and the virtual table. func spellfix1Register(tls *libc.TLS, db uintptr) int32 { /* spellfix.c:3017:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+7591 /* "spellfix1_transl..." */, 1, - (1 | 0x000000800), uintptr(0), + (SQLITE_UTF8 | SQLITE_DETERMINISTIC), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{transliterateSqlFunc})), uintptr(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_function(tls, db, ts+7610 /* "spellfix1_editdi..." */, 2, - (1 | 0x000000800), uintptr(0), + (SQLITE_UTF8 | SQLITE_DETERMINISTIC), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{editdistSqlFunc})), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_function(tls, db, ts+7629 /* "spellfix1_phoneh..." */, 1, - (1 | 0x000000800), uintptr(0), + (SQLITE_UTF8 | SQLITE_DETERMINISTIC), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{phoneticHashSqlFunc})), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_function(tls, db, ts+7649 /* "spellfix1_script..." */, 1, - (1 | 0x000000800), uintptr(0), + (SQLITE_UTF8 | SQLITE_DETERMINISTIC), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{scriptCodeSqlFunc})), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_module(tls, db, ts+7670 /* "spellfix1" */, uintptr(unsafe.Pointer(&spellfix1Module)), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = editDist3Install(tls, db) } @@ -31413,7 +28877,7 @@ func sqlite3_spellfix_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uin _ = pApi return spellfix1Register(tls, db) - return 0 + return SQLITE_OK } // Determine if this is running on a big-endian or little-endian @@ -31454,7 +28918,7 @@ func totypeCompare2pow63(tls *libc.TLS, zNum uintptr) int32 { /* totype.c:95:12: c = ((int32(*(*int8)(unsafe.Pointer(zNum + uintptr(i)))) - int32(*(*int8)(unsafe.Pointer(pow63 + uintptr(i))))) * 10) } if c == 0 { - c = (int32(*(*int8)(unsafe.Pointer(zNum + uintptr(18)))) - '8') + c = (int32(*(*int8)(unsafe.Pointer(zNum + 18))) - '8') } return c } @@ -31494,7 +28958,7 @@ func totypeAtoi64(tls *libc.TLS, zNum uintptr, pNum uintptr, length int32) int32 } } zStart = zNum - for (zNum < zEnd) && (int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '0') { + for (zNum < zEnd) && (int32(*(*int8)(unsafe.Pointer(zNum))) == '0') { zNum++ } // Skip leading zeros. for i = 0; (((zNum + uintptr(i)) < zEnd) && ((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(zNum + uintptr(i)))))) >= '0')) && (c <= '9'); i++ { @@ -31617,7 +29081,7 @@ __5: // skip leading zeroes __7: - if !((z < zEnd) && (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '0')) { + if !((z < zEnd) && (int32(*(*int8)(unsafe.Pointer(z))) == '0')) { goto __8 } z++ @@ -31918,10 +29382,10 @@ func tointegerFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { / defer tls.Free(24) _ = argc - switch sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) { - case 2: + switch sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) { + case SQLITE_FLOAT: { - var rVal float64 = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var rVal float64 = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) var iVal sqlite3_int64 = sqlite3_int64(rVal) if rVal == float64(iVal) { sqlite3.Xsqlite3_result_int64(tls, context, iVal) @@ -31929,17 +29393,17 @@ func tointegerFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { / break } - case 1: + case SQLITE_INTEGER: { - sqlite3.Xsqlite3_result_int64(tls, context, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + sqlite3.Xsqlite3_result_int64(tls, context, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))) break } - case 4: + case SQLITE_BLOB: { - var zBlob uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zBlob uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) if zBlob != 0 { - var nBlob int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var nBlob int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) if uint64(nBlob) == uint64(unsafe.Sizeof(sqlite3_int64(0))) { // var iVal sqlite3_int64 at bp+8, 8 @@ -31960,12 +29424,12 @@ func tointegerFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { / break } - case 3: + case SQLITE_TEXT: { - var zStr uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zStr uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zStr != 0 { - var nStr int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - if (nStr != 0) && !(totypeIsspace(tls, *(*uint8)(unsafe.Pointer(zStr + uintptr(0)))) != 0) { + var nStr int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + if (nStr != 0) && !(totypeIsspace(tls, *(*uint8)(unsafe.Pointer(zStr))) != 0) { // var iVal sqlite3_int64 at bp+16, 8 if !(totypeAtoi64(tls, zStr, bp+16 /* &iVal */, nStr) != 0) { @@ -31993,16 +29457,16 @@ func torealFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t defer tls.Free(24) _ = argc - switch sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) { - case 2: + switch sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) { + case SQLITE_FLOAT: { - sqlite3.Xsqlite3_result_double(tls, context, sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + sqlite3.Xsqlite3_result_double(tls, context, sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))) break } - case 1: + case SQLITE_INTEGER: { - var iVal sqlite3_int64 = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var iVal sqlite3_int64 = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) var rVal float64 = float64(iVal) if iVal == sqlite3_int64(rVal) { sqlite3.Xsqlite3_result_double(tls, context, rVal) @@ -32010,11 +29474,11 @@ func torealFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t break } - case 4: + case SQLITE_BLOB: { - var zBlob uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zBlob uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) if zBlob != 0 { - var nBlob int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var nBlob int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) if uint64(nBlob) == uint64(unsafe.Sizeof(float64(0))) { // var rVal float64 at bp+8, 8 @@ -32035,12 +29499,12 @@ func torealFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t break } - case 3: + case SQLITE_TEXT: { - var zStr uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zStr uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zStr != 0 { - var nStr int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - if ((nStr != 0) && !(totypeIsspace(tls, *(*uint8)(unsafe.Pointer(zStr + uintptr(0)))) != 0)) && !(totypeIsspace(tls, *(*uint8)(unsafe.Pointer(zStr + uintptr((nStr - 1))))) != 0) { + var nStr int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + if ((nStr != 0) && !(totypeIsspace(tls, *(*uint8)(unsafe.Pointer(zStr))) != 0)) && !(totypeIsspace(tls, *(*uint8)(unsafe.Pointer(zStr + uintptr((nStr - 1))))) != 0) { // var rVal float64 at bp+16, 8 if totypeAtoF(tls, zStr, bp+16 /* &rVal */, nStr) != 0 { @@ -32062,18 +29526,18 @@ func torealFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t } func sqlite3_totype_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* totype.c:497:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi _ = pzErrMsg // Unused parameter rc = sqlite3.Xsqlite3_create_function(tls, db, ts+7699 /* "tointeger" */, 1, - ((1 | 0x000000800) | 0x000200000), uintptr(0), + ((SQLITE_UTF8 | SQLITE_DETERMINISTIC) | SQLITE_INNOCUOUS), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tointegerFunc})), uintptr(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_function(tls, db, ts+7709 /* "toreal" */, 1, - ((1 | 0x000000800) | 0x000200000), uintptr(0), + ((SQLITE_UTF8 | SQLITE_DETERMINISTIC) | SQLITE_INNOCUOUS), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{torealFunc})), uintptr(0), uintptr(0)) @@ -32197,12 +29661,12 @@ type UnionSrc = UnionSrc1 /* unionvtab.c:183:25 */ func unionMalloc(tls *libc.TLS, pRc uintptr, nByte sqlite3_int64) uintptr { /* unionvtab.c:253:13: */ var pRet uintptr - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { pRet = sqlite3.Xsqlite3_malloc64(tls, uint64(nByte)) if pRet != 0 { libc.Xmemset(tls, pRet, 0, size_t(nByte)) } else { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } else { pRet = uintptr(0) @@ -32236,7 +29700,7 @@ func unionStrdup(tls *libc.TLS, pRc uintptr, zIn uintptr) uintptr { /* unionvtab // function is a no-op. func unionDequote(tls *libc.TLS, z uintptr) { /* unionvtab.c:297:13: */ if z != 0 { - var q int8 = *(*int8)(unsafe.Pointer(z + uintptr(0))) + var q int8 = *(*int8)(unsafe.Pointer(z)) // Set stack variable q to the close-quote character if (((int32(q) == '[') || (int32(q) == '\'')) || (int32(q) == '"')) || (int32(q) == '`') { @@ -32284,9 +29748,9 @@ func unionPrepare(tls *libc.TLS, pRc uintptr, db uintptr, zSql uintptr, pzErr ui *(*uintptr)(unsafe.Pointer(bp + 8 /* pRet */)) = uintptr(0) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var rc int32 = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+8 /* &pRet */, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+7716 /* "sql error: %s" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, db))) *(*int32)(unsafe.Pointer(pRc)) = rc } @@ -32304,9 +29768,9 @@ func unionPreparePrintf(tls *libc.TLS, pRc uintptr, pzErr uintptr, db uintptr, z ap = va zSql = sqlite3.Xsqlite3_vmprintf(tls, zFmt, ap) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { if zSql == uintptr(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } else { pRet = unionPrepare(tls, pRc, db, zSql, pzErr) } @@ -32332,7 +29796,7 @@ func unionFinalize(tls *libc.TLS, pRc uintptr, pStmt uintptr, pzErr uintptr) { / var db uintptr = sqlite3.Xsqlite3_db_handle(tls, pStmt) var rc int32 = sqlite3.Xsqlite3_finalize(tls, pStmt) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { *(*int32)(unsafe.Pointer(pRc)) = rc if rc != 0 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, db))) @@ -32352,7 +29816,7 @@ func unionInvokeOpenClose(tls *libc.TLS, pTab uintptr, pSrc uintptr, bClose int3 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose != 0 { sqlite3.Xsqlite3_bind_text(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose, 1, (*UnionSrc)(unsafe.Pointer(pSrc)).FzFile, -1, uintptr(0)) if (*UnionTab)(unsafe.Pointer(pTab)).FbHasContext != 0 { @@ -32360,7 +29824,7 @@ func unionInvokeOpenClose(tls *libc.TLS, pTab uintptr, pSrc uintptr, bClose int3 } sqlite3.Xsqlite3_bind_int(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose, (2 + (*UnionTab)(unsafe.Pointer(pTab)).FbHasContext), bClose) sqlite3.Xsqlite3_step(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose) - if 0 != (libc.AssignInt32(&rc, sqlite3.Xsqlite3_reset(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose))) { + if SQLITE_OK != (libc.AssignInt32(&rc, sqlite3.Xsqlite3_reset(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose))) { if pzErr != 0 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, (*UnionTab)(unsafe.Pointer(pTab)).Fdb))) } @@ -32411,7 +29875,7 @@ func unionDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* unionvtab.c:481:12 sqlite3.Xsqlite3_free(tls, (*UnionTab)(unsafe.Pointer(pTab)).FaSrc) sqlite3.Xsqlite3_free(tls, pTab) } - return 0 + return SQLITE_OK } // Check that the table identified by pSrc is a rowid table. If not, @@ -32429,9 +29893,9 @@ func unionIsIntkeyTable(tls *libc.TLS, db uintptr, pSrc uintptr, pzErr uintptr) sqlite3.Xsqlite3_table_column_metadata(tls, db, (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb, (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab, ts+7730 /* "_rowid_" */, bp+24 /* &zType */, uintptr(0), uintptr(0), bp+32 /* &bPk */, uintptr(0)) rc = sqlite3.Xsqlite3_errcode(tls, db) - if (rc == 1) || - ((rc == 0) && (!(*(*int32)(unsafe.Pointer(bp + 32 /* bPk */)) != 0) || (sqlite3.Xsqlite3_stricmp(tls, ts+7738 /* "integer" */, *(*uintptr)(unsafe.Pointer(bp + 24 /* zType */))) != 0))) { - rc = 1 + if (rc == SQLITE_ERROR) || + ((rc == SQLITE_OK) && (!(*(*int32)(unsafe.Pointer(bp + 32 /* bPk */)) != 0) || (sqlite3.Xsqlite3_stricmp(tls, ts+7738 /* "integer" */, *(*uintptr)(unsafe.Pointer(bp + 24 /* zType */))) != 0))) { + rc = SQLITE_ERROR *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+7746, /* "no such rowid ta..." */ libc.VaList(bp, func() uintptr { if (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb != 0 { @@ -32470,7 +29934,7 @@ func unionSourceToStr(tls *libc.TLS, pRc uintptr, pTab uintptr, pSrc uintptr, pz defer tls.Free(4) var zRet uintptr = uintptr(0) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var db uintptr = func() uintptr { if (*UnionTab)(unsafe.Pointer(pTab)).FbSwarm != 0 { return (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb @@ -32481,10 +29945,10 @@ func unionSourceToStr(tls *libc.TLS, pRc uintptr, pTab uintptr, pSrc uintptr, pz var pStmt uintptr = unionPrepare(tls, bp /* &rc */, db, ts+7776 /* "SELECT group_con..." */, pzErr) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { sqlite3.Xsqlite3_bind_text(tls, pStmt, 1, (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab, -1, uintptr(0)) sqlite3.Xsqlite3_bind_text(tls, pStmt, 2, (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb, -1, uintptr(0)) - if 100 == sqlite3.Xsqlite3_step(tls, pStmt) { + if SQLITE_ROW == sqlite3.Xsqlite3_step(tls, pStmt) { var z uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 0) zRet = unionStrdup(tls, bp /* &rc */, z) } @@ -32506,16 +29970,16 @@ func unionSourceCheck(tls *libc.TLS, pTab uintptr, pzErr uintptr) int32 { /* uni bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var z0 uintptr = uintptr(0) var i int32 - z0 = unionSourceToStr(tls, bp /* &rc */, pTab, ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr(0)*72), pzErr) + z0 = unionSourceToStr(tls, bp /* &rc */, pTab, ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc), pzErr) for i = 1; i < (*UnionTab)(unsafe.Pointer(pTab)).FnSrc; i++ { var z uintptr = unionSourceToStr(tls, bp /* &rc */, pTab, ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr(i)*72), pzErr) - if (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (sqlite3.Xsqlite3_stricmp(tls, z, z0) != 0) { + if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (sqlite3.Xsqlite3_stricmp(tls, z, z0) != 0) { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+7860 /* "source table sch..." */, 0) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR } sqlite3.Xsqlite3_free(tls, z) } @@ -32533,12 +29997,12 @@ func unionOpenDatabaseInner(tls *libc.TLS, pTab uintptr, pSrc uintptr, pzErr uin var rc int32 rc = unionInvokeOpenClose(tls, pTab, pSrc, 0, pzErr) - if rc != 0 { + if rc != SQLITE_OK { return rc } rc = sqlite3.Xsqlite3_open_v2(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).FzFile, (pSrc + 56 /* &.db */), openFlags, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { return rc } if (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound != 0 { @@ -32549,19 +30013,19 @@ func unionOpenDatabaseInner(tls *libc.TLS, pTab uintptr, pSrc uintptr, pzErr uin sqlite3.Xsqlite3_bind_text(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound, 2, (*UnionSrc)(unsafe.Pointer(pSrc)).FzContext, -1, uintptr(0)) } sqlite3.Xsqlite3_step(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound) - if 0 != (libc.AssignInt32(&rc, sqlite3.Xsqlite3_reset(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound))) { + if SQLITE_OK != (libc.AssignInt32(&rc, sqlite3.Xsqlite3_reset(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound))) { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, (*UnionTab)(unsafe.Pointer(pTab)).Fdb))) return rc } rc = sqlite3.Xsqlite3_open_v2(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).FzFile, (pSrc + 56 /* &.db */), openFlags, uintptr(0)) } - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, sqlite3.Xsqlite3_errmsg(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb))) } return rc } -var openFlags int32 = (0x00000001 | 0x00000040) /* unionvtab.c:617:20 */ +var openFlags int32 = (SQLITE_OPEN_READONLY | SQLITE_OPEN_URI) /* unionvtab.c:617:20 */ // This function may only be called for swarmvtab tables. The results of // calling it on a unionvtab table are undefined. @@ -32580,28 +30044,28 @@ func unionOpenDatabase(tls *libc.TLS, pTab uintptr, iSrc int32, pzErr uintptr) i bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pSrc uintptr = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr(iSrc)*72) if (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb == uintptr(0) { unionCloseSources(tls, pTab, ((*UnionTab)(unsafe.Pointer(pTab)).FnMaxOpen - 1)) *(*int32)(unsafe.Pointer(bp /* rc */)) = unionOpenDatabaseInner(tls, pTab, pSrc, pzErr) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { var z uintptr = unionSourceToStr(tls, bp /* &rc */, pTab, pSrc, pzErr) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { if (*UnionTab)(unsafe.Pointer(pTab)).FzSourceStr == uintptr(0) { (*UnionTab)(unsafe.Pointer(pTab)).FzSourceStr = z } else { if sqlite3.Xsqlite3_stricmp(tls, z, (*UnionTab)(unsafe.Pointer(pTab)).FzSourceStr) != 0 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+7860 /* "source table sch..." */, 0) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR } sqlite3.Xsqlite3_free(tls, z) } } } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*UnionSrc)(unsafe.Pointer(pSrc)).FpNextClosable = (*UnionTab)(unsafe.Pointer(pTab)).FpClosable (*UnionTab)(unsafe.Pointer(pTab)).FpClosable = pSrc (*UnionTab)(unsafe.Pointer(pTab)).FnOpen++ @@ -32641,7 +30105,7 @@ func unionIncrRefcount(tls *libc.TLS, pTab uintptr, iTab int32) { /* unionvtab.c // count on the associated source table. If this means the source tables // refcount is now zero, add it to the closable list. func unionFinalizeCsrStmt(tls *libc.TLS, pCsr uintptr) int32 { /* unionvtab.c:726:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt != 0 { var pTab uintptr = (*UnionCsr)(unsafe.Pointer(pCsr)).Fbase.FpVtab var pSrc uintptr = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr((*UnionCsr)(unsafe.Pointer(pCsr)).FiTab)*72) @@ -32691,10 +30155,10 @@ func unionConfigureVtab(tls *libc.TLS, pRc uintptr, pTab uintptr, pStmt uintptr, *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = *(*int32)(unsafe.Pointer(pRc)) var i int32 - if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK { (*UnionTab)(unsafe.Pointer(pTab)).FbHasContext = (libc.Bool32(sqlite3.Xsqlite3_column_count(tls, pStmt) > 4)) } - for i = 0; (*(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 0) && (i < nArg); i++ { + for i = 0; (*(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK) && (i < nArg); i++ { var zArg uintptr = unionStrdup(tls, bp+64 /* &rc */, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8))) if zArg != 0 { var nOpt int32 = 0 // Size of option name in bytes @@ -32727,13 +30191,13 @@ func unionConfigureVtab(tls *libc.TLS, pRc uintptr, pTab uintptr, pStmt uintptr, zVal = unionStrdup(tls, bp+64 /* &rc */, zVal) if zVal != 0 { unionDequote(tls, zVal) - if int32(*(*int8)(unsafe.Pointer(zOpt + uintptr(0)))) == ':' { + if int32(*(*int8)(unsafe.Pointer(zOpt))) == ':' { // A value to bind to the SQL statement var iParam int32 = sqlite3.Xsqlite3_bind_parameter_index(tls, pStmt, zOpt) if iParam == 0 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+7889 /* "swarmvtab: no su..." */, libc.VaList(bp, zOpt)) - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR } else { *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = sqlite3.Xsqlite3_bind_text(tls, pStmt, iParam, zVal, -1, libc.UintptrFromInt32(-1)) } @@ -32741,13 +30205,13 @@ func unionConfigureVtab(tls *libc.TLS, pRc uintptr, pTab uintptr, pStmt uintptr, (*UnionTab)(unsafe.Pointer(pTab)).FnMaxOpen = libc.Xatoi(tls, zVal) if (*UnionTab)(unsafe.Pointer(pTab)).FnMaxOpen <= 0 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+7934 /* "swarmvtab: illeg..." */, 0) - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR } } else if (nOpt == 7) && (0 == sqlite3.Xsqlite3_strnicmp(tls, zOpt, ts+7967 /* "missing" */, 7)) { if (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound != 0 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+7975 /* "swarmvtab: dupli..." */, 0) - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR } else { (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound = unionPreparePrintf(tls, bp+64 /* &rc */, pzErr, (*UnionTab)(unsafe.Pointer(pTab)).Fdb, ts+8013 /* "SELECT \"%w\"(?%s)" */, libc.VaList(bp+8, zVal, func() uintptr { @@ -32761,7 +30225,7 @@ func unionConfigureVtab(tls *libc.TLS, pRc uintptr, pTab uintptr, pStmt uintptr, if (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose != 0 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8043 /* "swarmvtab: dupli..." */, 0) - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR } else { (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose = unionPreparePrintf(tls, bp+64 /* &rc */, pzErr, (*UnionTab)(unsafe.Pointer(pTab)).Fdb, ts+8083 /* "SELECT \"%w\"(?,?%..." */, libc.VaList(bp+24, zVal, func() uintptr { @@ -32773,7 +30237,7 @@ func unionConfigureVtab(tls *libc.TLS, pRc uintptr, pTab uintptr, pStmt uintptr, } } else { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8102 /* "swarmvtab: unrec..." */, libc.VaList(bp+40, zOpt)) - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR } sqlite3.Xsqlite3_free(tls, zVal) } @@ -32783,7 +30247,7 @@ func unionConfigureVtab(tls *libc.TLS, pRc uintptr, pTab uintptr, pStmt uintptr, ts+8137 /* "SELECT \"%w\"(?)" */, libc.VaList(bp+48, zArg)) } else { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8152 /* "swarmvtab: parse..." */, libc.VaList(bp+56, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)))) - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR } } sqlite3.Xsqlite3_free(tls, zArg) @@ -32806,7 +30270,7 @@ func unionConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uint defer tls.Free(44) var pTab uintptr = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_OK var bSwarm int32 = func() int32 { if pAux == uintptr(0) { return 0 @@ -32820,17 +30284,17 @@ func unionConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uint return ts + 8189 /* "unionvtab" */ }() - if sqlite3.Xsqlite3_stricmp(tls, ts+8199 /* "temp" */, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) != 0 { + if sqlite3.Xsqlite3_stricmp(tls, ts+8199 /* "temp" */, *(*uintptr)(unsafe.Pointer(argv + 1*8))) != 0 { // unionvtab tables may only be created in the temp schema *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8204 /* "%s tables must b..." */, libc.VaList(bp, zVtab)) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else if (argc < 4) || ((argc > 4) && (bSwarm == 0)) { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8245 /* "wrong number of ..." */, libc.VaList(bp+8, zVtab)) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { - var nAlloc int32 = 0 // Allocated size of pTab->aSrc[] - var pStmt uintptr = uintptr(0) // Argument statement - var zArg uintptr = unionStrdup(tls, bp+40 /* &rc */, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) // Copy of argument to CVT + var nAlloc int32 = 0 // Allocated size of pTab->aSrc[] + var pStmt uintptr = uintptr(0) // Argument statement + var zArg uintptr = unionStrdup(tls, bp+40 /* &rc */, *(*uintptr)(unsafe.Pointer(argv + 3*8))) // Copy of argument to CVT // Prepare the SQL statement. Instead of executing it directly, sort // the results by the "minimum rowid" field. This makes it easier to @@ -32846,17 +30310,17 @@ func unionConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uint (*UnionTab)(unsafe.Pointer(pTab)).Fdb = db (*UnionTab)(unsafe.Pointer(pTab)).FbSwarm = bSwarm - (*UnionTab)(unsafe.Pointer(pTab)).FnMaxOpen = 9 + (*UnionTab)(unsafe.Pointer(pTab)).FnMaxOpen = SWARMVTAB_MAX_OPEN } // Parse other CVT arguments, if any if bSwarm != 0 { - unionConfigureVtab(tls, bp+40 /* &rc */, pTab, pStmt, (argc - 4), (argv + uintptr(4)*8), pzErr) + unionConfigureVtab(tls, bp+40 /* &rc */, pTab, pStmt, (argc - 4), (argv + 4*8), pzErr) } // Iterate through the rows returned by the SQL statement specified // as an argument to the CREATE VIRTUAL TABLE statement. - for (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && (100 == sqlite3.Xsqlite3_step(tls, pStmt)) { + for (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, pStmt)) { var zDb uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 0) var zTab uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 1) var iMin sqlite3_int64 = sqlite3.Xsqlite3_column_int64(tls, pStmt, 2) @@ -32874,7 +30338,7 @@ func unionConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uint var aNew uintptr = sqlite3.Xsqlite3_realloc64(tls, (*UnionTab)(unsafe.Pointer(pTab)).FaSrc, (uint64(uint64(nNew) * uint64(unsafe.Sizeof(UnionSrc{}))))) if aNew == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_NOMEM break } else { libc.Xmemset(tls, (aNew + uintptr((*UnionTab)(unsafe.Pointer(pTab)).FnSrc)*72), 0, ((uint64(nNew - (*UnionTab)(unsafe.Pointer(pTab)).FnSrc)) * uint64(unsafe.Sizeof(UnionSrc{})))) @@ -32886,10 +30350,10 @@ func unionConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uint // Check for problems with the specified range of rowids 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)) { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8308 /* "rowid range mism..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { pSrc = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr(libc.PostIncInt32(&(*UnionTab)(unsafe.Pointer(pTab)).FnSrc, 1))*72) (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab = unionStrdup(tls, bp+40 /* &rc */, zTab) (*UnionSrc)(unsafe.Pointer(pSrc)).FiMin = iMin @@ -32911,15 +30375,15 @@ func unionConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uint // It is an error if the SELECT statement returned zero rows. If only // because there is no way to determine the schema of the virtual // table in this case. - if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && ((*UnionTab)(unsafe.Pointer(pTab)).FnSrc == 0) { + if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && ((*UnionTab)(unsafe.Pointer(pTab)).FnSrc == 0) { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8335 /* "no source tables..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } // For unionvtab, verify that all source tables exist and have // compatible schemas. For swarmvtab, attach the first database and // check that the first table is a rowid table only. - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { if bSwarm != 0 { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = unionOpenDatabase(tls, pTab, 0, pzErr) } else { @@ -32928,8 +30392,8 @@ func unionConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uint } // Compose a CREATE TABLE statement and pass it to declare_vtab() - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { - var pSrc uintptr = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr(0)*72) + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { + var pSrc uintptr = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc) var tdb uintptr = func() uintptr { if (*UnionTab)(unsafe.Pointer(pTab)).FbSwarm != 0 { return (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb @@ -32941,7 +30405,7 @@ func unionConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uint ts+8363, /* "SELECT 'CREATE T..." */ libc.VaList(bp+24, (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab, (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb)) } - if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && (100 == sqlite3.Xsqlite3_step(tls, pStmt)) { + if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, pStmt)) { var zDecl uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 0) *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = sqlite3.Xsqlite3_declare_vtab(tls, db, zDecl) (*UnionTab)(unsafe.Pointer(pTab)).FiPK = sqlite3.Xsqlite3_column_int(tls, pStmt, 1) @@ -32950,7 +30414,7 @@ func unionConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uint unionFinalize(tls, bp+40 /* &rc */, pStmt, pzErr) } - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { unionDisconnect(tls, pTab) pTab = uintptr(0) } @@ -32965,7 +30429,7 @@ func unionOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* unionvtab. defer tls.Free(4) var pCsr uintptr - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK _ = p // Suppress harmless warning pCsr = unionMalloc(tls, bp /* &rc */, int64(unsafe.Sizeof(UnionCsr{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCsr /* &.base */) @@ -32977,7 +30441,7 @@ func unionClose(tls *libc.TLS, cur uintptr) int32 { /* unionvtab.c:1045:12: */ var pCsr uintptr = cur unionFinalizeCsrStmt(tls, pCsr) sqlite3.Xsqlite3_free(tls, pCsr) - return 0 + return SQLITE_OK } // This function does the work of the xNext() method. Except that, if it @@ -32987,12 +30451,12 @@ func doUnionNext(tls *libc.TLS, pCsr uintptr) int32 { /* unionvtab.c:1057:12: */ bp := tls.Alloc(28) defer tls.Free(28) - *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = SQLITE_OK - if sqlite3.Xsqlite3_step(tls, (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt) != 100 { + if sqlite3.Xsqlite3_step(tls, (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt) != SQLITE_ROW { var pTab uintptr = (*UnionCsr)(unsafe.Pointer(pCsr)).Fbase.FpVtab *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = unionFinalizeCsrStmt(tls, pCsr) - if (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0) && ((*UnionTab)(unsafe.Pointer(pTab)).FbSwarm != 0) { + if (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK) && ((*UnionTab)(unsafe.Pointer(pTab)).FbSwarm != 0) { (*UnionCsr)(unsafe.Pointer(pCsr)).FiTab++ if (*UnionCsr)(unsafe.Pointer(pCsr)).FiTab < (*UnionTab)(unsafe.Pointer(pTab)).FnSrc { var pSrc uintptr = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr((*UnionCsr)(unsafe.Pointer(pCsr)).FiTab)*72) @@ -33009,10 +30473,10 @@ func doUnionNext(tls *libc.TLS, pCsr uintptr) int32 { /* unionvtab.c:1057:12: */ return ts + 8590 /* "-- " */ }(), (*UnionCsr)(unsafe.Pointer(pCsr)).FiMaxRowid)) - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { unionIncrRefcount(tls, pTab, (*UnionCsr)(unsafe.Pointer(pCsr)).FiTab) - *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = 100 + *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = SQLITE_ROW } } } @@ -33025,7 +30489,7 @@ func doUnionNext(tls *libc.TLS, pCsr uintptr) int32 { /* unionvtab.c:1057:12: */ // xNext func unionNext(tls *libc.TLS, cur uintptr) int32 { /* unionvtab.c:1092:12: */ var rc int32 - for ok := true; ok; ok = (rc == 100) { + for ok := true; ok; ok = (rc == SQLITE_ROW) { rc = doUnionNext(tls, cur) } return rc @@ -33035,14 +30499,14 @@ func unionNext(tls *libc.TLS, cur uintptr) int32 { /* unionvtab.c:1092:12: */ func unionColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* unionvtab.c:1103:12: */ var pCsr uintptr = cur sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt, (i+1))) - return 0 + return SQLITE_OK } // xRowid func unionRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* unionvtab.c:1116:12: */ var pCsr uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_column_int64(tls, (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt, 0) - return 0 + return SQLITE_OK } // xEof @@ -33058,7 +30522,7 @@ func unionFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab var pCsr uintptr = pVtabCursor - *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = SQLITE_OK var i int32 var zSql uintptr = uintptr(0) var bZero int32 = 0 @@ -33068,15 +30532,15 @@ func unionFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt _ = idxStr // Suppress harmless warning - if idxNum == 2 { + if idxNum == SQLITE_INDEX_CONSTRAINT_EQ { - iMin = libc.AssignInt64(&iMax, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + iMin = libc.AssignInt64(&iMax, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))) } else { - if (idxNum & (8 | 16)) != 0 { + if (idxNum & (SQLITE_INDEX_CONSTRAINT_LE | SQLITE_INDEX_CONSTRAINT_LT)) != 0 { - iMax = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - if (idxNum & 16) != 0 { + iMax = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) + if (idxNum & SQLITE_INDEX_CONSTRAINT_LT) != 0 { if iMax == ((int64(-1)) - (int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32))) { bZero = 1 } else { @@ -33085,10 +30549,10 @@ func unionFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt } } - if (idxNum & (32 | 4)) != 0 { + if (idxNum & (SQLITE_INDEX_CONSTRAINT_GE | SQLITE_INDEX_CONSTRAINT_GT)) != 0 { iMin = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((argc-1))*8))) - if (idxNum & 4) != 0 { + if (idxNum & SQLITE_INDEX_CONSTRAINT_GT) != 0 { if iMin == (int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32)) { bZero = 1 } else { @@ -33100,7 +30564,7 @@ func unionFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt unionFinalizeCsrStmt(tls, pCsr) if bZero != 0 { - return 0 + return SQLITE_OK } for i = 0; i < (*UnionTab)(unsafe.Pointer(pTab)).FnSrc; i++ { @@ -33131,7 +30595,7 @@ func unionFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt return ts + 488 /* "" */ }(), (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab)) if zSql == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = SQLITE_NOMEM break } @@ -33171,7 +30635,7 @@ func unionFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt } sqlite3.Xsqlite3_free(tls, zSql) } - if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) } return unionNext(tls, pVtabCursor) @@ -33204,19 +30668,19 @@ func unionBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* uni var p uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12) 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)) { switch int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) { - case 2: + case SQLITE_INDEX_CONSTRAINT_EQ: iEq = i break fallthrough - case 8: + case SQLITE_INDEX_CONSTRAINT_LE: fallthrough - case 16: + case SQLITE_INDEX_CONSTRAINT_LT: iLt = i break fallthrough - case 32: + case SQLITE_INDEX_CONSTRAINT_GE: fallthrough - case 4: + case SQLITE_INDEX_CONSTRAINT_GT: iGt = i break } @@ -33225,9 +30689,9 @@ func unionBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* uni if iEq >= 0 { (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) - (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = 1 + (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = SQLITE_INDEX_SCAN_UNIQUE (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 3.0 - (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 2 + (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = SQLITE_INDEX_CONSTRAINT_EQ (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iEq)*8)).FargvIndex = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iEq)*8)).Fomit = uint8(1) } else { @@ -33251,7 +30715,7 @@ func unionBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* uni (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = idxNum } - return 0 + return SQLITE_OK } // Register the unionvtab virtual table module with database handle db. @@ -33259,60 +30723,29 @@ func createUnionVtab(tls *libc.TLS, db uintptr) int32 { /* unionvtab.c:1329:12: var rc int32 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+8189 /* "unionvtab" */, uintptr(unsafe.Pointer(&unionModule)), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_create_module(tls, db, ts+8179 /* "swarmvtab" */, uintptr(unsafe.Pointer(&unionModule)), db) } return rc } -var unionModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect: 0, - FxBestIndex: 0, - FxDisconnect:// xBestIndex - query planner - 0, - FxDestroy: 0, - FxOpen: 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var unionModule = sqlite3_module{ // iVersion + FxCreate: 0, + FxConnect: 0, + FxBestIndex: 0, // xBestIndex - query planner + FxDisconnect: 0, + FxDestroy: 0, + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xShadowName } /* unionvtab.c:1330:25 */ func sqlite3_unionvtab_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* unionvtab.c:1370:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi _ = pzErrMsg // Suppress harmless warning @@ -33335,12 +30768,12 @@ func wholenumberConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, arg var pNew uintptr pNew = libc.AssignPtrUintptr(ppVtab, sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(sqlite3_vtab{})))) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } sqlite3.Xsqlite3_declare_vtab(tls, db, ts+8709 /* "CREATE TABLE x(v..." */) - sqlite3.Xsqlite3_vtab_config(tls, db, 2, 0) + sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(sqlite3_vtab{}))) - return 0 + return SQLITE_OK } // Note that for this virtual table, the xCreate and xConnect @@ -33348,7 +30781,7 @@ func wholenumberConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, arg func wholenumberDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* wholenumber.c:60:12: */ sqlite3.Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // The xDisconnect and xDestroy methods are also the same @@ -33358,38 +30791,38 @@ func wholenumberOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* whol var pCur uintptr pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(wholenumber_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(wholenumber_cursor{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Close a wholenumber cursor. func wholenumberClose(tls *libc.TLS, cur uintptr) int32 { /* wholenumber.c:82:12: */ sqlite3.Xsqlite3_free(tls, cur) - return 0 + return SQLITE_OK } // Advance a cursor to its next row of output func wholenumberNext(tls *libc.TLS, cur uintptr) int32 { /* wholenumber.c:91:12: */ var pCur uintptr = cur (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue++ - return 0 + return SQLITE_OK } // Return the value associated with a wholenumber. func wholenumberColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* wholenumber.c:100:12: */ var pCur uintptr = cur sqlite3.Xsqlite3_result_int64(tls, ctx, (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue) - return 0 + return SQLITE_OK } // The rowid. func wholenumberRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* wholenumber.c:113:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue - return 0 + return SQLITE_OK } // When the wholenumber_cursor.rLimit value is 0 or less, that is a signal @@ -33422,7 +30855,7 @@ func wholenumberFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue = int64(1) (*wholenumber_cursor)(unsafe.Pointer(pCur)).FmxValue = int64(0xffffffff) // 4294967295 if (idxNum & 3) != 0 { - v = (sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + (sqlite3_int64(idxNum & 1))) + v = (sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) + (sqlite3_int64(idxNum & 1))) if (v > (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue) && (v <= (*wholenumber_cursor)(unsafe.Pointer(pCur)).FmxValue) { (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue = v } @@ -33434,7 +30867,7 @@ func wholenumberFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr (*wholenumber_cursor)(unsafe.Pointer(pCur)).FmxValue = v } } - return 0 + return SQLITE_OK } // Search for terms of these forms: @@ -33462,19 +30895,19 @@ __1: if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { goto __2 } - if ((idxNum & 3) == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 4) { + if ((idxNum & 3) == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_GT) { idxNum = idxNum | (1) ltIdx = i } - if ((idxNum & 3) == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 32) { + if ((idxNum & 3) == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_GE) { idxNum = idxNum | (2) ltIdx = i } - if ((idxNum & 12) == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 16) { + if ((idxNum & 12) == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT) { idxNum = idxNum | (4) gtIdx = i } - if ((idxNum & 12) == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 8) { + if ((idxNum & 12) == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LE) { idxNum = idxNum | (8) gtIdx = i } @@ -33498,7 +30931,7 @@ __3: (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(gtIdx)*8)).Fomit = uint8(1) } if ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1) && - (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).Fdesc) == 0) { + (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0) { (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 } if (idxNum & 12) == 0 { @@ -33508,50 +30941,28 @@ __3: } else { (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1) } - return 0 + return SQLITE_OK } // A virtual table module that provides read-only access to a // Tcl global variable namespace. -var wholenumberModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, +var wholenumberModule = sqlite3_module{ // iVersion + FxCreate: 0, FxConnect: 0, FxBestIndex: 0, FxDisconnect: 0, FxDestroy: 0, - FxOpen: 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRename } /* wholenumber.c:236:23 */ func sqlite3_wholenumber_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* wholenumber.c:264:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pApi rc = sqlite3.Xsqlite3_create_module(tls, db, ts+8731 /* "wholenumber" */, uintptr(unsafe.Pointer(&wholenumberModule)), uintptr(0)) @@ -34204,7 +31615,17 @@ type u321 = uint64 /* zipfile.c:42:23 */ // are also made explicit in [man stat], and (c) are part of the // file format for zip archives. -var ZIPFILE_SCHEMA = *(*[91]int8)(unsafe.Pointer(ts + 8743 /* "CREATE TABLE y(n..." */)) /* zipfile.c:77:19 */ +var ZIPFILE_SCHEMA = + +// 0: Name of file in zip archive +// 1: POSIX mode for file +// 2: Last modification time (secs since 1970) +// 3: Size of object +// 4: Raw data +// 5: Uncompressed data +// 6: Compression method (integer) +// 7: Name of zip file +*(*[91]int8)(unsafe.Pointer(ts + 8743 /* "CREATE TABLE y(n..." */)) /* zipfile.c:77:19 */ // Magic numbers used to read and write zip files. // @@ -34477,7 +31898,7 @@ func zipfileCtxErrorMsg(tls *libc.TLS, ctx uintptr, zFmt uintptr, va uintptr) { // If string zIn is quoted, dequote it in place. Otherwise, if the string // is not quoted, do nothing. func zipfileDequote(tls *libc.TLS, zIn uintptr) { /* zipfile.c:303:13: */ - var q int8 = *(*int8)(unsafe.Pointer(zIn + uintptr(0))) + var q int8 = *(*int8)(unsafe.Pointer(zIn)) if (((int32(q) == '"') || (int32(q) == '\'')) || (int32(q) == '`')) || (int32(q) == '[') { var iIn int32 = 1 var iOut int32 = 0 @@ -34517,32 +31938,32 @@ func zipfileConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv ui // // CREATE VIRTUAL TABLE zipfile USING zipfile(); - if ((0 != sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), ts+8834 /* "zipfile" */)) && (argc < 4)) || (argc > 4) { + if ((0 != sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ts+8834 /* "zipfile" */)) && (argc < 4)) || (argc > 4) { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8842 /* "zipfile construc..." */, 0) - return 1 + return SQLITE_ERROR } if argc > 3 { - zFile = *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)) + zFile = *(*uintptr)(unsafe.Pointer(argv + 3*8)) nFile = (int32(libc.Xstrlen(tls, zFile)) + 1) } rc = sqlite3.Xsqlite3_declare_vtab(tls, db, uintptr(unsafe.Pointer(&ZIPFILE_SCHEMA))) - if rc == 0 { + if rc == SQLITE_OK { pNew = sqlite3.Xsqlite3_malloc64(tls, (uint64(sqlite3_int64(nByte) + sqlite3_int64(nFile)))) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pNew, 0, (uint64(nByte + nFile))) (*ZipfileTab)(unsafe.Pointer(pNew)).Fdb = db - (*ZipfileTab)(unsafe.Pointer(pNew)).FaBuffer = (pNew + uintptr(1)*104) + (*ZipfileTab)(unsafe.Pointer(pNew)).FaBuffer = (pNew + 1*104) if zFile != 0 { - (*ZipfileTab)(unsafe.Pointer(pNew)).FzFile = ((*ZipfileTab)(unsafe.Pointer(pNew)).FaBuffer + uintptr((64 * 1024))) + (*ZipfileTab)(unsafe.Pointer(pNew)).FzFile = ((*ZipfileTab)(unsafe.Pointer(pNew)).FaBuffer + 65536) libc.Xmemcpy(tls, (*ZipfileTab)(unsafe.Pointer(pNew)).FzFile, zFile, uint64(nFile)) zipfileDequote(tls, (*ZipfileTab)(unsafe.Pointer(pNew)).FzFile) } } - sqlite3.Xsqlite3_vtab_config(tls, db, 3, 0) + sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_DIRECTONLY, 0) *(*uintptr)(unsafe.Pointer(ppVtab)) = pNew return rc } @@ -34579,7 +32000,7 @@ func zipfileCleanupTransaction(tls *libc.TLS, pTab uintptr) { /* zipfile.c:391:1 func zipfileDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* zipfile.c:412:12: */ zipfileCleanupTransaction(tls, pVtab) sqlite3.Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // Constructor for a new ZipfileCsr object. @@ -34589,13 +32010,13 @@ func zipfileOpen(tls *libc.TLS, p uintptr, ppCsr uintptr) int32 { /* zipfile.c:4 pCsr = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(ZipfileCsr{}))) *(*uintptr)(unsafe.Pointer(ppCsr)) = pCsr if pCsr == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCsr, 0, uint64(unsafe.Sizeof(ZipfileCsr{}))) (*ZipfileCsr)(unsafe.Pointer(pCsr)).FiId = libc.PreIncInt64(&(*ZipfileTab)(unsafe.Pointer(pTab)).FiNextCsrid, 1) (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCsrNext = (*ZipfileTab)(unsafe.Pointer(pTab)).FpCsrList (*ZipfileTab)(unsafe.Pointer(pTab)).FpCsrList = pCsr - return 0 + return SQLITE_OK } // Reset a cursor back to the state it was in when first returned @@ -34631,7 +32052,7 @@ func zipfileClose(tls *libc.TLS, cur uintptr) int32 { /* zipfile.c:461:12: */ *(*uintptr)(unsafe.Pointer(pp)) = (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCsrNext sqlite3.Xsqlite3_free(tls, pCsr) - return 0 + return SQLITE_OK } // Set the error message for the virtual table associated with cursor @@ -34664,52 +32085,52 @@ func zipfileCursorErr(tls *libc.TLS, pCsr uintptr, zFmt uintptr, va uintptr) { / // sqlite3_free(). func zipfileReadData(tls *libc.TLS, pFile uintptr, aRead uintptr, nRead int32, iOff i64, pzErrmsg uintptr) int32 { /* zipfile.c:504:12: */ var n size_t - libc.Xfseek(tls, pFile, int64(iOff), 0) + libc.Xfseek(tls, pFile, int64(iOff), SEEK_SET) n = libc.Xfread(tls, aRead, uint64(1), uint64(nRead), pFile) if int32(n) != nRead { *(*uintptr)(unsafe.Pointer(pzErrmsg)) = sqlite3.Xsqlite3_mprintf(tls, ts+8884 /* "error in fread()" */, 0) - return 1 + return SQLITE_ERROR } - return 0 + return SQLITE_OK } func zipfileAppendData(tls *libc.TLS, pTab uintptr, aWrite uintptr, nWrite int32) int32 { /* zipfile.c:521:12: */ var n size_t - libc.Xfseek(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd, int64((*ZipfileTab)(unsafe.Pointer(pTab)).FszCurrent), 0) + libc.Xfseek(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd, int64((*ZipfileTab)(unsafe.Pointer(pTab)).FszCurrent), SEEK_SET) n = libc.Xfwrite(tls, aWrite, uint64(1), uint64(nWrite), (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd) if int32(n) != nWrite { (*ZipfileTab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+8901 /* "error in fwrite(..." */, 0) - return 1 + return SQLITE_ERROR } *(*i64)(unsafe.Pointer(pTab + 88 /* &.szCurrent */)) += (i64(nWrite)) - return 0 + return SQLITE_OK } // Read and return a 16-bit little-endian unsigned integer from buffer aBuf. func zipfileGetU16(tls *libc.TLS, aBuf uintptr) u16 { /* zipfile.c:540:12: */ - return (u16((int32(*(*u8)(unsafe.Pointer(aBuf + uintptr(1)))) << 8) + int32(*(*u8)(unsafe.Pointer(aBuf + uintptr(0)))))) + return (u16((int32(*(*u8)(unsafe.Pointer(aBuf + 1))) << 8) + int32(*(*u8)(unsafe.Pointer(aBuf))))) } // Read and return a 32-bit little-endian unsigned integer from buffer aBuf. func zipfileGetU32(tls *libc.TLS, aBuf uintptr) u321 { /* zipfile.c:547:12: */ - return (((((u321(*(*u8)(unsafe.Pointer(aBuf + uintptr(3))))) << 24) + - ((u321(*(*u8)(unsafe.Pointer(aBuf + uintptr(2))))) << 16)) + - ((u321(*(*u8)(unsafe.Pointer(aBuf + uintptr(1))))) << 8)) + - ((u321(*(*u8)(unsafe.Pointer(aBuf + uintptr(0))))) << 0)) + return (((((u321(*(*u8)(unsafe.Pointer(aBuf + 3)))) << 24) + + ((u321(*(*u8)(unsafe.Pointer(aBuf + 2)))) << 16)) + + ((u321(*(*u8)(unsafe.Pointer(aBuf + 1)))) << 8)) + + ((u321(*(*u8)(unsafe.Pointer(aBuf)))) << 0)) } // Write a 16-bit little endiate integer into buffer aBuf. func zipfilePutU16(tls *libc.TLS, aBuf uintptr, val u16) { /* zipfile.c:557:13: */ - *(*u8)(unsafe.Pointer(aBuf + uintptr(0))) = (u8(int32(val) & 0xFF)) - *(*u8)(unsafe.Pointer(aBuf + uintptr(1))) = (u8((int32(val) >> 8) & 0xFF)) + *(*u8)(unsafe.Pointer(aBuf)) = (u8(int32(val) & 0xFF)) + *(*u8)(unsafe.Pointer(aBuf + 1)) = (u8((int32(val) >> 8) & 0xFF)) } // Write a 32-bit little endiate integer into buffer aBuf. func zipfilePutU32(tls *libc.TLS, aBuf uintptr, val u321) { /* zipfile.c:565:13: */ - *(*u8)(unsafe.Pointer(aBuf + uintptr(0))) = (u8(val & uint64(0xFF))) - *(*u8)(unsafe.Pointer(aBuf + uintptr(1))) = (u8((val >> 8) & uint64(0xFF))) - *(*u8)(unsafe.Pointer(aBuf + uintptr(2))) = (u8((val >> 16) & uint64(0xFF))) - *(*u8)(unsafe.Pointer(aBuf + uintptr(3))) = (u8((val >> 24) & uint64(0xFF))) + *(*u8)(unsafe.Pointer(aBuf)) = (u8(val & uint64(0xFF))) + *(*u8)(unsafe.Pointer(aBuf + 1)) = (u8((val >> 8) & uint64(0xFF))) + *(*u8)(unsafe.Pointer(aBuf + 2)) = (u8((val >> 16) & uint64(0xFF))) + *(*u8)(unsafe.Pointer(aBuf + 3)) = (u8((val >> 24) & uint64(0xFF))) } // Magic numbers used to read CDS records. @@ -34719,9 +32140,9 @@ func zipfilePutU32(tls *libc.TLS, aBuf uintptr, val u321) { /* zipfile.c:565:13: func zipfileReadCDS(tls *libc.TLS, aBuf uintptr, pCDS uintptr) int32 { /* zipfile.c:588:12: */ var aRead uintptr = aBuf var sig u321 = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() - var rc int32 = 0 - if sig != uint64(0x02014b50) { - rc = 1 + var rc int32 = SQLITE_OK + if sig != ZIPFILE_SIGNATURE_CDS { + rc = SQLITE_ERROR } else { (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiVersionMadeBy = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiVersionExtract = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() @@ -34750,11 +32171,11 @@ func zipfileReadCDS(tls *libc.TLS, aBuf uintptr, pCDS uintptr) int32 { /* zipfil // if the record is not well-formed, or SQLITE_OK otherwise. func zipfileReadLFH(tls *libc.TLS, aBuffer uintptr, pLFH uintptr) int32 { /* zipfile.c:622:12: */ var aRead uintptr = aBuffer - var rc int32 = 0 + var rc int32 = SQLITE_OK var sig u321 = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() - if sig != uint64(0x04034b50) { - rc = 1 + if sig != ZIPFILE_SIGNATURE_LFH { + rc = SQLITE_ERROR } else { (*ZipfileLFH)(unsafe.Pointer(pLFH)).FiVersionExtract = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() (*ZipfileLFH)(unsafe.Pointer(pLFH)).Fflags = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() @@ -34793,11 +32214,11 @@ func zipfileScanExtra(tls *libc.TLS, aExtra uintptr, nExtra int32, pmTime uintpt var nByte u16 = func() u16 { p += uintptr(2); return zipfileGetU16(tls, (p - uintptr(2))) }() switch int32(id) { - case 0x5455: + case ZIPFILE_EXTRA_TIMESTAMP: { - var b u8 = *(*u8)(unsafe.Pointer(p + uintptr(0))) + var b u8 = *(*u8)(unsafe.Pointer(p)) if (int32(b) & 0x01) != 0 { // 0x01 -> modtime is present - *(*u321)(unsafe.Pointer(pmTime)) = zipfileGetU32(tls, (p + uintptr(1))) + *(*u321)(unsafe.Pointer(pmTime)) = zipfileGetU32(tls, (p + 1)) ret = 1 } break @@ -34921,57 +32342,57 @@ func zipfileGetEntry(tls *libc.TLS, pTab uintptr, aBlob uintptr, nBlob int32, pF var aRead uintptr var pzErr uintptr = (pTab /* &.base */ + 16 /* &.zErrMsg */) - var rc int32 = 0 + var rc int32 = SQLITE_OK if aBlob == uintptr(0) { aRead = (*ZipfileTab)(unsafe.Pointer(pTab)).FaBuffer - rc = zipfileReadData(tls, pFile, aRead, 46, iOff, pzErr) + rc = zipfileReadData(tls, pFile, aRead, ZIPFILE_CDS_FIXED_SZ, iOff, pzErr) } else { aRead = (aBlob + uintptr(iOff)) } - if rc == 0 { + if rc == SQLITE_OK { var nAlloc sqlite3_int64 var pNew uintptr - var nFile int32 = int32(zipfileGetU16(tls, (aRead + uintptr(28)))) - var nExtra int32 = int32(zipfileGetU16(tls, (aRead + uintptr((28 + 2))))) - nExtra = nExtra + (int32(zipfileGetU16(tls, (aRead + uintptr((28 + 4)))))) + var nFile int32 = int32(zipfileGetU16(tls, (aRead + 28))) + var nExtra int32 = int32(zipfileGetU16(tls, (aRead + 30))) + nExtra = nExtra + (int32(zipfileGetU16(tls, (aRead + 32)))) nAlloc = (sqlite3_int64(uint64(unsafe.Sizeof(ZipfileEntry{})) + uint64(nExtra))) if aBlob != 0 { - nAlloc = sqlite3_int64(uint64(nAlloc) + (uint64(zipfileGetU32(tls, (aRead + uintptr(20)))))) + nAlloc = sqlite3_int64(uint64(nAlloc) + (uint64(zipfileGetU32(tls, (aRead + 20))))) } pNew = sqlite3.Xsqlite3_malloc64(tls, uint64(nAlloc)) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(ZipfileEntry{}))) rc = zipfileReadCDS(tls, aRead, (pNew /* &.cds */)) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8919 /* "failed to read C..." */, libc.VaList(bp, iOff)) } else if aBlob == uintptr(0) { rc = zipfileReadData(tls, - pFile, aRead, (nExtra + nFile), (iOff + int64(46)), pzErr) + pFile, aRead, (nExtra + nFile), (iOff + ZIPFILE_CDS_FIXED_SZ), pzErr) } else { - aRead = (aBlob + uintptr((iOff + int64(46)))) + aRead = (aBlob + uintptr((iOff + ZIPFILE_CDS_FIXED_SZ))) } } - if rc == 0 { + if rc == SQLITE_OK { var pt uintptr = (pNew + 80 /* &.mUnixTime */) (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FzFile = sqlite3.Xsqlite3_mprintf(tls, ts+8953 /* "%.*s" */, libc.VaList(bp+8, nFile, aRead)) - (*ZipfileEntry)(unsafe.Pointer(pNew)).FaExtra = (pNew + uintptr(1)*120) + (*ZipfileEntry)(unsafe.Pointer(pNew)).FaExtra = (pNew + 1*120) libc.Xmemcpy(tls, (*ZipfileEntry)(unsafe.Pointer(pNew)).FaExtra, (aRead + uintptr(nFile)), uint64(nExtra)) if (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FzFile == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else if 0 == zipfileScanExtra(tls, (aRead+uintptr(nFile)), int32((*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FnExtra), pt) { (*ZipfileEntry)(unsafe.Pointer(pNew)).FmUnixTime = zipfileMtime(tls, (pNew /* &.cds */)) } } - if rc == 0 { + if rc == SQLITE_OK { // var lfh ZipfileLFH at bp+32, 48 if pFile != 0 { @@ -34981,8 +32402,8 @@ func zipfileGetEntry(tls *libc.TLS, pTab uintptr, aBlob uintptr, nBlob int32, pF } rc = zipfileReadLFH(tls, aRead, bp+32 /* &lfh */) - if rc == 0 { - (*ZipfileEntry)(unsafe.Pointer(pNew)).FiDataOff = (i64((*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiOffset + uint64(30))) + if rc == SQLITE_OK { + (*ZipfileEntry)(unsafe.Pointer(pNew)).FiDataOff = (i64((*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiOffset + ZIPFILE_LFH_FIXED_SZ)) *(*i64)(unsafe.Pointer(pNew + 96 /* &.iDataOff */)) += (i64(int32((*ZipfileLFH)(unsafe.Pointer(bp+32 /* &lfh */)).FnFile) + int32((*ZipfileLFH)(unsafe.Pointer(bp+32 /* &lfh */)).FnExtra))) if (aBlob != 0) && ((*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FszCompressed != 0) { (*ZipfileEntry)(unsafe.Pointer(pNew)).FaData = ((*ZipfileEntry)(unsafe.Pointer(pNew)).FaExtra + uintptr(nExtra)) @@ -34994,7 +32415,7 @@ func zipfileGetEntry(tls *libc.TLS, pTab uintptr, aBlob uintptr, nBlob int32, pF } } - if rc != 0 { + if rc != SQLITE_OK { zipfileEntryFree(tls, pNew) } else { *(*uintptr)(unsafe.Pointer(ppEntry)) = pNew @@ -35004,7 +32425,7 @@ func zipfileGetEntry(tls *libc.TLS, pTab uintptr, aBlob uintptr, nBlob int32, pF return rc } -var szFix int32 = 30 /* zipfile.c:852:24 */ +var szFix int32 = ZIPFILE_LFH_FIXED_SZ /* zipfile.c:852:24 */ // Advance an ZipfileCsr to its next row of output. func zipfileNext(tls *libc.TLS, cur uintptr) int32 { /* zipfile.c:888:12: */ @@ -35012,7 +32433,7 @@ func zipfileNext(tls *libc.TLS, cur uintptr) int32 { /* zipfile.c:888:12: */ defer tls.Free(8) var pCsr uintptr = cur - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile != 0 { var iEof i64 = (i64((*ZipfileCsr)(unsafe.Pointer(pCsr)).Feocd.FiOffset + (*ZipfileCsr)(unsafe.Pointer(pCsr)).Feocd.FnSize)) @@ -35024,8 +32445,8 @@ func zipfileNext(tls *libc.TLS, cur uintptr) int32 { /* zipfile.c:888:12: */ *(*uintptr)(unsafe.Pointer(bp /* p */)) = uintptr(0) var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab rc = zipfileGetEntry(tls, pTab, uintptr(0), 0, (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile, (*ZipfileCsr)(unsafe.Pointer(pCsr)).FiNextOff, bp /* &p */) - if rc == 0 { - *(*i64)(unsafe.Pointer(pCsr + 32 /* &.iNextOff */)) += (int64(46)) + if rc == SQLITE_OK { + *(*i64)(unsafe.Pointer(pCsr + 32 /* &.iNextOff */)) += (ZIPFILE_CDS_FIXED_SZ) *(*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))) } (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent = *(*uintptr)(unsafe.Pointer(bp /* p */)) @@ -35070,12 +32491,12 @@ func zipfileInflate(tls *libc.TLS, pCtx uintptr, aIn uintptr, nIn int32, nOut in (*z_stream)(unsafe.Pointer(bp + 16 /* &str */)).Fnext_out = aRes (*z_stream)(unsafe.Pointer(bp + 16 /* &str */)).Favail_out = uInt(nOut) - err = tcl.XinflateInit2_(tls, bp+16 /* &str */, -15, ts+8990 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) - if err != 0 { + err = z.XinflateInit2_(tls, bp+16 /* &str */, -15, ts+8990 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) + if err != Z_OK { zipfileCtxErrorMsg(tls, pCtx, ts+8997 /* "inflateInit2() f..." */, libc.VaList(bp, err)) } else { - err = tcl.Xinflate(tls, bp+16 /* &str */, 0) - if err != 1 { + err = z.Xinflate(tls, bp+16 /* &str */, Z_NO_FLUSH) + if err != Z_STREAM_END { zipfileCtxErrorMsg(tls, pCtx, ts+9024 /* "inflate() failed..." */, libc.VaList(bp+8, err)) } else { sqlite3.Xsqlite3_result_blob(tls, pCtx, aRes, nOut, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{zipfileFree}))) @@ -35083,7 +32504,7 @@ func zipfileInflate(tls *libc.TLS, pCtx uintptr, aIn uintptr, nIn int32, nOut in } } sqlite3.Xsqlite3_free(tls, aRes) - tcl.XinflateEnd(tls, bp+16 /* &str */) + z.XinflateEnd(tls, bp+16 /* &str */) } } @@ -35101,7 +32522,7 @@ func zipfileDeflate(tls *libc.TLS, aIn uintptr, nIn int32, ppOut uintptr, pnOut bp := tls.Alloc(112) defer tls.Free(112) - var rc int32 = 0 + var rc int32 = SQLITE_OK var nAlloc sqlite3_int64 // var str z_stream at bp, 112 @@ -35110,26 +32531,26 @@ func zipfileDeflate(tls *libc.TLS, aIn uintptr, nIn int32, ppOut uintptr, pnOut libc.Xmemset(tls, bp /* &str */, 0, uint64(unsafe.Sizeof(z_stream{}))) (*z_stream)(unsafe.Pointer(bp /* &str */)).Fnext_in = aIn (*z_stream)(unsafe.Pointer(bp /* &str */)).Favail_in = uInt(nIn) - tcl.XdeflateInit2_(tls, bp /* &str */, 9, 8, -15, 8, 0, ts+8990 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) + z.XdeflateInit2_(tls, bp /* &str */, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY, ts+8990 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) - nAlloc = sqlite3_int64(tcl.XdeflateBound(tls, bp /* &str */, uint64(nIn))) + nAlloc = sqlite3_int64(z.XdeflateBound(tls, bp /* &str */, uint64(nIn))) aOut = sqlite3.Xsqlite3_malloc64(tls, uint64(nAlloc)) if aOut == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var res int32 (*z_stream)(unsafe.Pointer(bp /* &str */)).Fnext_out = aOut (*z_stream)(unsafe.Pointer(bp /* &str */)).Favail_out = uInt(nAlloc) - res = tcl.Xdeflate(tls, bp /* &str */, 4) - if res == 1 { + res = z.Xdeflate(tls, bp /* &str */, Z_FINISH) + if res == Z_STREAM_END { *(*uintptr)(unsafe.Pointer(ppOut)) = aOut *(*int32)(unsafe.Pointer(pnOut)) = int32((*z_stream)(unsafe.Pointer(bp /* &str */)).Ftotal_out) } else { sqlite3.Xsqlite3_free(tls, aOut) *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+9046 /* "zipfile: deflate..." */, 0) - rc = 1 + rc = SQLITE_ERROR } - tcl.XdeflateEnd(tls, bp /* &str */) + z.XdeflateEnd(tls, bp /* &str */) } return rc @@ -35140,7 +32561,7 @@ func zipfileDeflate(tls *libc.TLS, aIn uintptr, nIn int32, ppOut uintptr, pnOut func zipfileColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* zipfile.c:1023:12: */ var pCsr uintptr = cur var pCDS uintptr = ((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent /* &.cds */) - var rc int32 = 0 + var rc int32 = SQLITE_OK switch i { case 0: // name sqlite3.Xsqlite3_result_text(tls, ctx, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FzFile, -1, libc.UintptrFromInt32(-1)) @@ -35182,7 +32603,7 @@ func zipfileColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* } else { aBuf = libc.AssignUintptr(&aFree, sqlite3.Xsqlite3_malloc64(tls, uint64(sz))) if aBuf == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var pFile uintptr = (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile if pFile == uintptr(0) { @@ -35192,7 +32613,7 @@ func zipfileColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* ((*ZipfileCsr)(unsafe.Pointer(pCsr)).Fbase.FpVtab + 16 /* &.zErrMsg */)) } } - if rc == 0 { + if rc == SQLITE_OK { if (i == 5) && ((*ZipfileCDS)(unsafe.Pointer(pCDS)).FiCompression != 0) { zipfileInflate(tls, ctx, aBuf, sz, szFinal) } else { @@ -35205,7 +32626,7 @@ func zipfileColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* // it to be a directory either if the mode suggests so, or if // the final character in the name is '/'. var mode u321 = ((*ZipfileCDS)(unsafe.Pointer(pCDS)).FiExternalAttr >> 16) - if !((mode & uint64(0040000)) != 0) && (int32(*(*int8)(unsafe.Pointer((*ZipfileCDS)(unsafe.Pointer(pCDS)).FzFile + uintptr((int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FnFile) - 1))))) != '/') { + if !((mode & S_IFDIR) != 0) && (int32(*(*int8)(unsafe.Pointer((*ZipfileCDS)(unsafe.Pointer(pCDS)).FzFile + uintptr((int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FnFile) - 1))))) != '/') { sqlite3.Xsqlite3_result_blob(tls, ctx, ts+488 /* "" */, 0, uintptr(0)) } } @@ -35242,16 +32663,16 @@ func zipfileEof(tls *libc.TLS, cur uintptr) int32 { /* zipfile.c:1110:12: */ func zipfileReadEOCD(tls *libc.TLS, pTab uintptr, aBlob uintptr, nBlob int32, pFile uintptr, pEOCD uintptr) int32 { /* zipfile.c:1125:12: */ var aRead uintptr = (*ZipfileTab)(unsafe.Pointer(pTab)).FaBuffer // Temporary buffer var nRead int32 // Bytes to read from file - var rc int32 = 0 + var rc int32 = SQLITE_OK if aBlob == uintptr(0) { var iOff i64 // Offset to read from var szFile i64 // Total size of file in bytes - libc.Xfseek(tls, pFile, int64(0), 2) + libc.Xfseek(tls, pFile, int64(0), SEEK_END) szFile = i64(libc.Xftell(tls, pFile)) if szFile == int64(0) { libc.Xmemset(tls, pEOCD, 0, uint64(unsafe.Sizeof(ZipfileEOCD{}))) - return 0 + return SQLITE_OK } nRead = func() int32 { if (szFile) < (int64(64 * 1024)) { @@ -35271,7 +32692,7 @@ func zipfileReadEOCD(tls *libc.TLS, pTab uintptr, aBlob uintptr, nBlob int32, pF aRead = (aBlob + uintptr((nBlob - nRead))) } - if rc == 0 { + if rc == SQLITE_OK { var i int32 // Scan backwards looking for the signature bytes @@ -35284,7 +32705,7 @@ func zipfileReadEOCD(tls *libc.TLS, pTab uintptr, aBlob uintptr, nBlob int32, pF if i < 0 { (*ZipfileTab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+9071 /* "cannot find end ..." */, 0) - return 1 + return SQLITE_ERROR } aRead += (uintptr(i + 4)) @@ -35334,13 +32755,13 @@ func zipfileLoadDirectory(tls *libc.TLS, pTab uintptr, aBlob uintptr, nBlob int3 rc = zipfileReadEOCD(tls, pTab, aBlob, nBlob, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd, bp /* &eocd */) iOff = i64((*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FiOffset) - for i = 0; (rc == 0) && (i < int32((*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FnEntry)); i++ { + for i = 0; (rc == SQLITE_OK) && (i < int32((*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FnEntry)); i++ { *(*uintptr)(unsafe.Pointer(bp + 24 /* pNew */)) = uintptr(0) rc = zipfileGetEntry(tls, pTab, aBlob, nBlob, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd, iOff, bp+24 /* &pNew */) - if rc == 0 { + if rc == SQLITE_OK { zipfileAddEntry(tls, pTab, uintptr(0), *(*uintptr)(unsafe.Pointer(bp + 24 /* pNew */))) - iOff = iOff + (int64(46)) + iOff = iOff + (ZIPFILE_CDS_FIXED_SZ) 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))) } } @@ -35355,7 +32776,7 @@ func zipfileFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, arg var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab var pCsr uintptr = cur var zFile uintptr = uintptr(0) // Zip file to scan - var rc int32 = 0 // Return Code + var rc int32 = SQLITE_OK // Return Code var bInMemory int32 = 0 // True for an in-memory zipfile zipfileResetCursor(tls, pCsr) @@ -35364,30 +32785,30 @@ func zipfileFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, arg zFile = (*ZipfileTab)(unsafe.Pointer(pTab)).FzFile } else if idxNum == 0 { zipfileCursorErr(tls, pCsr, ts+9115 /* "zipfile() functi..." */, 0) - return 1 - } else if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 4 { - var aBlob uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var nBlob int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + return SQLITE_ERROR + } else if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_BLOB { + var aBlob uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) + var nBlob int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) rc = zipfileLoadDirectory(tls, pTab, aBlob, nBlob) (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFreeEntry = (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry = libc.AssignPtrUintptr(pTab+72 /* &.pLastEntry */, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { return rc } bInMemory = 1 } else { - zFile = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zFile = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) } if (uintptr(0) == (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd) && (0 == bInMemory) { (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile = libc.Xfopen(tls, zFile, ts+4086 /* "rb" */) if (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile == uintptr(0) { zipfileCursorErr(tls, pCsr, ts+9155 /* "cannot open file..." */, libc.VaList(bp, zFile)) - rc = 1 + rc = SQLITE_ERROR } else { rc = zipfileReadEOCD(tls, pTab, uintptr(0), 0, (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile, (pCsr + 40 /* &.eocd */)) - if rc == 0 { + if rc == SQLITE_OK { if int32((*ZipfileCsr)(unsafe.Pointer(pCsr)).Feocd.FnEntry) == 0 { (*ZipfileCsr)(unsafe.Pointer(pCsr)).FbEof = u8(1) } else { @@ -35418,12 +32839,12 @@ func zipfileBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* z for i = 0; i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; i++ { var pCons uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12) - if (*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn != 7 { + if (*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn != ZIPFILE_F_COLUMN_IDX { continue } if int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fusable) == 0 { unusable = 1 - } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == 2 { + } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ { idx = i } } @@ -35433,9 +32854,9 @@ func zipfileBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* z (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(idx)*8)).Fomit = uint8(1) (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1 } else if unusable != 0 { - return 19 + return SQLITE_CONSTRAINT } - return 0 + return SQLITE_OK } func zipfileNewEntry(tls *libc.TLS, zPath uintptr) uintptr { /* zipfile.c:1323:21: */ @@ -35463,7 +32884,7 @@ func zipfileSerializeLFH(tls *libc.TLS, pEntry uintptr, aBuf uintptr) int32 { /* /* Write the LFH itself */ { - zipfilePutU32(tls, a, uint64(0x04034b50)) + zipfilePutU32(tls, a, ZIPFILE_SIGNATURE_LFH) a += uintptr(4) } @@ -35523,7 +32944,7 @@ func zipfileSerializeLFH(tls *libc.TLS, pEntry uintptr, aBuf uintptr) int32 { /* /* The "extra" data */ { - zipfilePutU16(tls, a, uint16(0x5455)) + zipfilePutU16(tls, a, ZIPFILE_EXTRA_TIMESTAMP) a += uintptr(2) } @@ -35548,7 +32969,7 @@ func zipfileAppendEntry(tls *libc.TLS, pTab uintptr, pEntry uintptr, pData uintp nBuf = zipfileSerializeLFH(tls, pEntry, aBuf) rc = zipfileAppendData(tls, pTab, aBuf, nBuf) - if rc == 0 { + if rc == SQLITE_OK { (*ZipfileEntry)(unsafe.Pointer(pEntry)).FiDataOff = (*ZipfileTab)(unsafe.Pointer(pTab)).FszCurrent rc = zipfileAppendData(tls, pTab, pData, nData) } @@ -35572,13 +32993,13 @@ func zipfileGetMode(tls *libc.TLS, pVal uintptr, bIsDir int32, pMode uintptr, pz } mode = func() uint64 { if bIsDir != 0 { - return (uint64(0040000 + 0755)) + return (uint64(S_IFDIR + 0755)) } - return (uint64(0100000 + 0644)) + return (uint64(S_IFREG + 0644)) }() goto __2 __1: - if !((int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) <= '9')) { + if !((int32(*(*int8)(unsafe.Pointer(z))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z))) <= '9')) { goto __3 } mode = u321(uint32(sqlite3.Xsqlite3_value_int(tls, pVal))) @@ -35591,7 +33012,7 @@ __3: goto parse_error __5: ; - switch int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) { + switch int32(*(*int8)(unsafe.Pointer(z))) { case '-': goto __7 case 'd': @@ -35603,13 +33024,13 @@ __5: } goto __6 __7: - mode = mode | (uint64(0100000)) + mode = mode | (S_IFREG) goto __6 __8: - mode = mode | (uint64(0040000)) + mode = mode | (S_IFDIR) goto __6 __9: - mode = mode | (uint64(0120000)) + mode = mode | (S_IFLNK) goto __6 __10: goto parse_error @@ -35645,21 +33066,21 @@ __4: ; __2: ; - if !((libc.Bool32((mode & uint64(0040000)) == uint64(0))) == bIsDir) { + if !((libc.Bool32((mode & S_IFDIR) == uint64(0))) == bIsDir) { goto __17 } // The "mode" attribute is a directory, but data has been specified. // Or vice-versa - no data but "mode" is a file or symlink. *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+9187 /* "zipfile: mode do..." */, 0) - return 19 + return SQLITE_CONSTRAINT __17: ; *(*u321)(unsafe.Pointer(pMode)) = mode - return 0 + return SQLITE_OK parse_error: *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+9221 /* "zipfile: parse e..." */, libc.VaList(bp, z)) - return 1 + return SQLITE_ERROR } // @@ -35685,11 +33106,11 @@ func zipfileBegin(tls *libc.TLS, pVtab uintptr) int32 { /* zipfile.c:1443:12: */ defer tls.Free(8) var pTab uintptr = pVtab - var rc int32 = 0 + var rc int32 = SQLITE_OK - if ((*ZipfileTab)(unsafe.Pointer(pTab)).FzFile == uintptr(0)) || (int32(*(*int8)(unsafe.Pointer((*ZipfileTab)(unsafe.Pointer(pTab)).FzFile + uintptr(0)))) == 0) { + if ((*ZipfileTab)(unsafe.Pointer(pTab)).FzFile == uintptr(0)) || (int32(*(*int8)(unsafe.Pointer((*ZipfileTab)(unsafe.Pointer(pTab)).FzFile))) == 0) { (*ZipfileTab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+9254 /* "zipfile: missing..." */, 0) - return 1 + return SQLITE_ERROR } // Open a write fd on the file. Also load the entire central directory @@ -35700,14 +33121,14 @@ func zipfileBegin(tls *libc.TLS, pVtab uintptr) int32 { /* zipfile.c:1443:12: */ if (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd == uintptr(0) { (*ZipfileTab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+9284 /* "zipfile: failed ..." */, libc.VaList(bp, (*ZipfileTab)(unsafe.Pointer(pTab)).FzFile)) - rc = 1 + rc = SQLITE_ERROR } else { - libc.Xfseek(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd, int64(0), 2) + libc.Xfseek(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd, int64(0), SEEK_END) (*ZipfileTab)(unsafe.Pointer(pTab)).FszCurrent = libc.AssignPtrInt64(pTab+96 /* &.szOrig */, i64(libc.Xftell(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd))) rc = zipfileLoadDirectory(tls, pTab, uintptr(0), 0) } - if rc != 0 { + if rc != SQLITE_OK { zipfileCleanupTransaction(tls, pTab) } @@ -35742,7 +33163,7 @@ func zipfileTime(tls *libc.TLS) u321 { /* zipfile.c:1480:12: */ // return the current time. Otherwise, return the value stored in (*pVal) // cast to a 32-bit unsigned integer. func zipfileGetTime(tls *libc.TLS, pVal uintptr) u321 { /* zipfile.c:1502:12: */ - if (pVal == uintptr(0)) || (sqlite3.Xsqlite3_value_type(tls, pVal) == 5) { + if (pVal == uintptr(0)) || (sqlite3.Xsqlite3_value_type(tls, pVal) == SQLITE_NULL) { return zipfileTime(tls) } return u321(sqlite3.Xsqlite3_value_int64(tls, pVal)) @@ -35799,7 +33220,7 @@ func zipfileUpdate(tls *libc.TLS, pVtab uintptr, nVal int32, apVal uintptr, pRow var p uintptr var pCsr uintptr pTab = pVtab - rc = 0 + rc = SQLITE_OK pNew = uintptr(0) *(*u321)(unsafe.Pointer(bp + 40 /* mode */)) = uint64(0) mTime = uint64(0) @@ -35821,7 +33242,7 @@ func zipfileUpdate(tls *libc.TLS, pVtab uintptr, nVal int32, apVal uintptr, pRow goto __1 } rc = zipfileBegin(tls, pVtab) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __2 } return rc @@ -35831,15 +33252,15 @@ __1: ; // If this is a DELETE or UPDATE, find the archive entry to delete. - if !(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) != 5) { + if !(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal))) != SQLITE_NULL) { goto __3 } - zDelete = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + zDelete = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))) nDelete = int32(libc.Xstrlen(tls, zDelete)) if !(nVal > 1) { goto __4 } - zUpdate = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) + zUpdate = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) if !((zUpdate != 0) && (zipfileComparePath(tls, zUpdate, zDelete, nDelete) != 0)) { goto __5 } @@ -35874,25 +33295,25 @@ __3: goto __10 } // Check that "sz" and "rawdata" are both NULL: - if !(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(5)*8))) != 5) { + if !(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 5*8))) != SQLITE_NULL) { goto __11 } zipfileTableErr(tls, pTab, ts+9328 /* "sz must be NULL" */, 0) - rc = 19 + rc = SQLITE_CONSTRAINT __11: ; - if !(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(6)*8))) != 5) { + if !(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 6*8))) != SQLITE_NULL) { goto __12 } zipfileTableErr(tls, pTab, ts+9344 /* "rawdata must be ..." */, 0) - rc = 19 + rc = SQLITE_CONSTRAINT __12: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __13 } - if !(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(7)*8))) == 5) { + if !(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 7*8))) == SQLITE_NULL) { goto __14 } // data=NULL. A directory @@ -35901,11 +33322,11 @@ __12: __14: // Value specified for "data", and possibly "method". This must be // a regular file or a symlink. - aIn = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(7)*8))) - nIn = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(7)*8))) - bAuto = (libc.Bool32(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(8)*8))) == 5)) + aIn = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apVal + 7*8))) + nIn = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + 7*8))) + bAuto = (libc.Bool32(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 8*8))) == SQLITE_NULL)) - iMethod = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(8)*8))) + iMethod = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + 8*8))) sz = i64(nIn) pData = aIn nData = nIn @@ -35913,14 +33334,14 @@ __14: goto __16 } zipfileTableErr(tls, pTab, ts+9365 /* "unknown compress..." */, libc.VaList(bp, iMethod)) - rc = 19 + rc = SQLITE_CONSTRAINT goto __17 __16: if !((bAuto != 0) || (iMethod != 0)) { goto __18 } rc = zipfileDeflate(tls, aIn, nIn, bp+24 /* &pFree */, bp+32 /* &nCmp */, (pTab /* &.base */ + 16 /* &.zErrMsg */)) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __19 } if !((iMethod != 0) || (*(*int32)(unsafe.Pointer(bp + 32 /* nCmp */)) < nIn)) { @@ -35935,7 +33356,7 @@ __19: ; __18: ; - iCrc32 = tcl.Xcrc32(tls, uint64(0), aIn, uint32(nIn)) + iCrc32 = z.Xcrc32(tls, uint64(0), aIn, uint32(nIn)) __17: ; __15: @@ -35943,17 +33364,17 @@ __15: __13: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __21 } - rc = zipfileGetMode(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(3)*8)), bIsDir, bp+40 /* &mode */, (pTab /* &.base */ + 16 /* &.zErrMsg */)) + rc = zipfileGetMode(tls, *(*uintptr)(unsafe.Pointer(apVal + 3*8)), bIsDir, bp+40 /* &mode */, (pTab /* &.base */ + 16 /* &.zErrMsg */)) __21: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __22 } - zPath = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(2)*8))) + zPath = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 2*8))) if !(zPath == uintptr(0)) { goto __23 } @@ -35961,11 +33382,11 @@ __21: __23: ; nPath = int32(libc.Xstrlen(tls, zPath)) - mTime = zipfileGetTime(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(4)*8))) + mTime = zipfileGetTime(tls, *(*uintptr)(unsafe.Pointer(apVal + 4*8))) __22: ; - if !((rc == 0) && (bIsDir != 0)) { + if !((rc == SQLITE_OK) && (bIsDir != 0)) { goto __24 } // For a directory, check that the last character in the path is a @@ -35980,7 +33401,7 @@ __22: if !(zFree == uintptr(0)) { goto __26 } - rc = 7 + rc = SQLITE_NOMEM nPath = 0 goto __27 __26: @@ -35994,7 +33415,7 @@ __24: // Check that we're not inserting a duplicate entry -OR- updating an // entry with a path, thereby making it into a duplicate. - if !(((pOld == uintptr(0)) || (bUpdate != 0)) && (rc == 0)) { + if !(((pOld == uintptr(0)) || (bUpdate != 0)) && (rc == SQLITE_OK)) { goto __28 } p = (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry @@ -36006,9 +33427,9 @@ __29: goto __32 } switch sqlite3.Xsqlite3_vtab_on_conflict(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).Fdb) { - case 2: + case SQLITE_IGNORE: goto __34 - case 5: + case SQLITE_REPLACE: goto __35 default: goto __36 @@ -36023,7 +33444,7 @@ __35: __36: zipfileTableErr(tls, pTab, ts+9400 /* "duplicate name: ..." */, libc.VaList(bp+16, zPath)) - rc = 19 + rc = SQLITE_CONSTRAINT goto __33 __33: @@ -36041,7 +33462,7 @@ __31: __28: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __37 } // Create the new CDS record. @@ -36049,12 +33470,12 @@ __28: if !(pNew == uintptr(0)) { goto __38 } - rc = 7 + rc = SQLITE_NOMEM goto __39 __38: (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiVersionMadeBy = (u16((int32(3) << 8) + 30)) - (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiVersionExtract = u16(20) - (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.Fflags = u16(0x800) + (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiVersionExtract = ZIPFILE_NEWENTRY_REQUIRED + (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.Fflags = ZIPFILE_NEWENTRY_FLAGS (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiCompression = u16(iMethod) zipfileMtimeToDos(tls, (pNew /* &.cds */), mTime) (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.Fcrc32 = iCrc32 @@ -36073,7 +33494,7 @@ __37: __10: ; - if !((rc == 0) && ((pOld != 0) || (pOld2 != 0))) { + if !((rc == SQLITE_OK) && ((pOld != 0) || (pOld2 != 0))) { goto __40 } pCsr = (*ZipfileTab)(unsafe.Pointer(pTab)).FpCsrList @@ -36110,7 +33531,7 @@ zipfile_update_done: func zipfileSerializeEOCD(tls *libc.TLS, p uintptr, aBuf uintptr) int32 { /* zipfile.c:1716:12: */ var a uintptr = aBuf { - zipfilePutU32(tls, a, uint64(0x06054b50)) + zipfilePutU32(tls, a, ZIPFILE_SIGNATURE_EOCD) a += uintptr(4) } @@ -36170,7 +33591,7 @@ func zipfileSerializeCDS(tls *libc.TLS, pEntry uintptr, aBuf uintptr) int32 { /* } { - zipfilePutU32(tls, a, uint64(0x02014b50)) + zipfilePutU32(tls, a, ZIPFILE_SIGNATURE_CDS) a += uintptr(4) } @@ -36264,7 +33685,7 @@ func zipfileSerializeCDS(tls *libc.TLS, pEntry uintptr, aBuf uintptr) int32 { /* } else { { - zipfilePutU16(tls, a, uint16(0x5455)) + zipfilePutU16(tls, a, ZIPFILE_EXTRA_TIMESTAMP) a += uintptr(2) } @@ -36289,7 +33710,7 @@ func zipfileCommit(tls *libc.TLS, pVtab uintptr) int32 { /* zipfile.c:1785:12: * defer tls.Free(24) var pTab uintptr = pVtab - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd != 0 { var iOffset i64 = (*ZipfileTab)(unsafe.Pointer(pTab)).FszCurrent var p uintptr @@ -36298,7 +33719,7 @@ func zipfileCommit(tls *libc.TLS, pVtab uintptr) int32 { /* zipfile.c:1785:12: * var nEntry int32 = 0 // Write out all entries - for p = (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry; (rc == 0) && (p != 0); p = (*ZipfileEntry)(unsafe.Pointer(p)).FpNext { + for p = (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry; (rc == SQLITE_OK) && (p != 0); p = (*ZipfileEntry)(unsafe.Pointer(p)).FpNext { var n int32 = zipfileSerializeCDS(tls, p, (*ZipfileTab)(unsafe.Pointer(pTab)).FaBuffer) rc = zipfileAppendData(tls, pTab, (*ZipfileTab)(unsafe.Pointer(pTab)).FaBuffer, n) nEntry++ @@ -36339,7 +33760,7 @@ func zipfileFunctionCds(tls *libc.TLS, context uintptr, argc int32, argv uintptr var pCsr uintptr var pTab uintptr = sqlite3.Xsqlite3_user_data(tls, context) - pCsr = zipfileFindCursor(tls, pTab, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + pCsr = zipfileFindCursor(tls, pTab, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))) if pCsr != 0 { var p uintptr = ((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent /* &.cds */) var zRes uintptr = sqlite3.Xsqlite3_mprintf(tls, @@ -36408,12 +33829,12 @@ func zipfileBufferGrow(tls *libc.TLS, pBuf uintptr, nByte int32) int32 { /* zipf } aNew = sqlite3.Xsqlite3_realloc64(tls, (*ZipfileBuffer)(unsafe.Pointer(pBuf)).Fa, uint64(nNew)) if aNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*ZipfileBuffer)(unsafe.Pointer(pBuf)).Fa = aNew (*ZipfileBuffer)(unsafe.Pointer(pBuf)).FnAlloc = int32(nNew) } - return 0 + return SQLITE_OK } // xStep() callback for the zipfile() aggregate. This can be called in @@ -36461,7 +33882,7 @@ func zipfileStep(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) { /* zi pData = uintptr(0) pMethod = uintptr(0) bIsDir = 0 - rc = 0 + rc = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) = uintptr(0) iMethod = -1 aData = uintptr(0) @@ -36487,24 +33908,24 @@ __1: goto __2 } *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) = sqlite3.Xsqlite3_mprintf(tls, ts+9775 /* "wrong number of ..." */, 0) - rc = 1 + rc = SQLITE_ERROR goto zipfile_step_out __2: ; - pName = *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8)) + pName = *(*uintptr)(unsafe.Pointer(apVal)) if !(nVal == 2) { goto __3 } - pData = *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8)) + pData = *(*uintptr)(unsafe.Pointer(apVal + 1*8)) goto __4 __3: - pMode = *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8)) - pMtime = *(*uintptr)(unsafe.Pointer(apVal + uintptr(2)*8)) - pData = *(*uintptr)(unsafe.Pointer(apVal + uintptr(3)*8)) + pMode = *(*uintptr)(unsafe.Pointer(apVal + 1*8)) + pMtime = *(*uintptr)(unsafe.Pointer(apVal + 2*8)) + pData = *(*uintptr)(unsafe.Pointer(apVal + 3*8)) if !(nVal == 5) { goto __5 } - pMethod = *(*uintptr)(unsafe.Pointer(apVal + uintptr(4)*8)) + pMethod = *(*uintptr)(unsafe.Pointer(apVal + 4*8)) __5: ; __4: @@ -36517,14 +33938,14 @@ __4: goto __6 } *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) = sqlite3.Xsqlite3_mprintf(tls, ts+9823 /* "first argument t..." */, 0) - rc = 1 + rc = SQLITE_ERROR goto zipfile_step_out __6: ; // Inspect the 'method' parameter. This must be either 0 (store), 8 (use // deflate compression) or NULL (choose automatically). - if !((pMethod != 0) && (5 != sqlite3.Xsqlite3_value_type(tls, pMethod))) { + if !((pMethod != 0) && (SQLITE_NULL != sqlite3.Xsqlite3_value_type(tls, pMethod))) { goto __7 } iMethod = int32(sqlite3.Xsqlite3_value_int64(tls, pMethod)) @@ -36532,7 +33953,7 @@ __6: goto __8 } *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) = sqlite3.Xsqlite3_mprintf(tls, ts+9868 /* "illegal method v..." */, libc.VaList(bp, iMethod)) - rc = 1 + rc = SQLITE_ERROR goto zipfile_step_out __8: ; @@ -36542,7 +33963,7 @@ __7: // Now inspect the data. If this is NULL, then the new entry must be a // directory. Otherwise, figure out whether or not the data should // be deflated or simply stored in the zip archive. - if !(sqlite3.Xsqlite3_value_type(tls, pData) == 5) { + if !(sqlite3.Xsqlite3_value_type(tls, pData) == SQLITE_NULL) { goto __9 } bIsDir = 1 @@ -36551,13 +33972,13 @@ __7: __9: aData = sqlite3.Xsqlite3_value_blob(tls, pData) szUncompressed = libc.AssignInt32(&nData, sqlite3.Xsqlite3_value_bytes(tls, pData)) - iCrc32 = tcl.Xcrc32(tls, uint64(0), aData, uint32(nData)) + iCrc32 = z.Xcrc32(tls, uint64(0), aData, uint32(nData)) if !((iMethod < 0) || (iMethod == 8)) { goto __11 } *(*int32)(unsafe.Pointer(bp + 144 /* nOut */)) = 0 rc = zipfileDeflate(tls, aData, nData, bp+136 /* &aFree */, bp+144 /* &nOut */, bp+152 /* &zErr */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } goto zipfile_step_out @@ -36601,7 +34022,7 @@ __15: goto __18 } *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) = sqlite3.Xsqlite3_mprintf(tls, ts+9893 /* "non-directory na..." */, 0) - rc = 1 + rc = SQLITE_ERROR goto zipfile_step_out __18: ; @@ -36614,7 +34035,7 @@ __16: if !(zName == uintptr(0)) { goto __21 } - rc = 7 + rc = SQLITE_NOMEM goto zipfile_step_out __21: ; @@ -36636,8 +34057,8 @@ __17: // Assemble the ZipfileEntry object for the new zip archive entry (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FiVersionMadeBy = (u16((int32(3) << 8) + 30)) - (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FiVersionExtract = u16(20) - (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.Fflags = u16(0x800) + (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FiVersionExtract = ZIPFILE_NEWENTRY_REQUIRED + (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.Fflags = ZIPFILE_NEWENTRY_FLAGS (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FiCompression = u16(iMethod) zipfileMtimeToDos(tls, (bp + 16 /* &e */ /* &.cds */), (*ZipfileEntry)(unsafe.Pointer(bp+16 /* &e */)).FmUnixTime) (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.Fcrc32 = iCrc32 @@ -36649,7 +34070,7 @@ __17: (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FzFile = zName // Append the LFH to the body of the new archive - nByte = ((30 + int32((*ZipfileEntry)(unsafe.Pointer(bp+16 /* &e */)).Fcds.FnFile)) + 9) + nByte = ((ZIPFILE_LFH_FIXED_SZ + int32((*ZipfileEntry)(unsafe.Pointer(bp+16 /* &e */)).Fcds.FnFile)) + 9) if !(libc.AssignInt32(&rc, zipfileBufferGrow(tls, (p+8 /* &.body */), nByte)) != 0) { goto __24 } @@ -36674,7 +34095,7 @@ __25: ; // Append the CDS record to the directory of the new archive - nByte = ((46 + int32((*ZipfileEntry)(unsafe.Pointer(bp+16 /* &e */)).Fcds.FnFile)) + 9) + nByte = ((ZIPFILE_CDS_FIXED_SZ + int32((*ZipfileEntry)(unsafe.Pointer(bp+16 /* &e */)).Fcds.FnFile)) + 9) if !(libc.AssignInt32(&rc, zipfileBufferGrow(tls, (p+24 /* &.cds */), nByte)) != 0) { goto __27 } @@ -36728,7 +34149,7 @@ func zipfileFinal(tls *libc.TLS, pCtx uintptr) { /* zipfile.c:2105:6: */ (*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FnSize = u321((*ZipfileCtx)(unsafe.Pointer(p)).Fcds.Fn) (*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FiOffset = u321((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fn) - nZip = (sqlite3_int64(((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fn + (*ZipfileCtx)(unsafe.Pointer(p)).Fcds.Fn) + 22)) + nZip = (sqlite3_int64(((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fn + (*ZipfileCtx)(unsafe.Pointer(p)).Fcds.Fn) + ZIPFILE_EOCD_FIXED_SZ)) aZip = sqlite3.Xsqlite3_malloc64(tls, uint64(nZip)) if aZip == uintptr(0) { sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) @@ -36748,11 +34169,11 @@ func zipfileFinal(tls *libc.TLS, pCtx uintptr) { /* zipfile.c:2105:6: */ func zipfileRegister(tls *libc.TLS, db uintptr) int32 { /* zipfile.c:2140:12: */ var rc int32 = sqlite3.Xsqlite3_create_module(tls, db, ts+8834 /* "zipfile" */, uintptr(unsafe.Pointer(&zipfileModule)), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_overload_function(tls, db, ts+9763 /* "zipfile_cds" */, -1) } - if rc == 0 { - rc = sqlite3.Xsqlite3_create_function(tls, db, ts+8834 /* "zipfile" */, -1, 1, uintptr(0), uintptr(0), + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_function(tls, db, ts+8834 /* "zipfile" */, -1, SQLITE_UTF8, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{zipfileStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{zipfileFinal}))) @@ -36761,45 +34182,23 @@ func zipfileRegister(tls *libc.TLS, db uintptr) int32 { /* zipfile.c:2140:12: */ } var zipfileModule = sqlite3_module{ - FiVersion: 1, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - 0, - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - uintptr(0), - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - 0, - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - 0, - FxRollback:// xCommit - 0, - FxFindFunction:// xRollback - 0, - FxRename:// xFindMethod - uintptr(0), // xRename + FiVersion: 1, // iVersion + FxCreate: 0, // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDisconnect + FxDestroy: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xRowid - read data + FxUpdate: 0, // xUpdate + FxBegin: 0, // xSync + FxCommit: 0, // xCommit + FxRollback: 0, // xRollback + FxFindFunction: 0, // xRename } /* zipfile.c:2141:25 */ func sqlite3_zipfile_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* zipfile.c:2180:5: */ @@ -36823,7 +34222,7 @@ func test_rbu_delta(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) { /* tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pScript, tcl.XTcl_NewStringObj(tls, z, -1)) } - if 0 == tcl.XTcl_EvalObjEx(tls, interp, pScript, 1) { + if TCL_OK == tcl.XTcl_EvalObjEx(tls, interp, pScript, TCL_GLOBAL_ONLY) { var z uintptr = tcl.XTcl_GetStringResult(tls, interp) sqlite3.Xsqlite3_result_text(tls, pCtx, z, -1, libc.UintptrFromInt32(-1)) } else { @@ -36842,77 +34241,38 @@ func test_sqlite3rbu_cmd(tls *libc.TLS, clientData ClientData, interp uintptr, o bp := tls.Alloc(496) defer tls.Free(496) - var ret int32 = 0 + var ret int32 = TCL_OK var pRbu uintptr = clientData *(*[14]RbuCmd)(unsafe.Pointer(bp + 24 /* aCmd */)) = [14]RbuCmd{ - { - FzName: ts + 9942, /* "step" */ - FnArg: 2, - FzUsage: ts + 488 /* "" */}, // 0 - { - FzName: ts + 9947, /* "close" */ - FnArg: 2, - FzUsage: ts + 488 /* "" */}, // 1 - { - FzName: ts + 9953, /* "create_rbu_delta" */ - FnArg: 2, - FzUsage: ts + 488 /* "" */}, // 2 - { - FzName: ts + 9970, /* "savestate" */ - FnArg: 2, - FzUsage: ts + 488 /* "" */}, // 3 - { - FzName: ts + 9980, /* "dbMain_eval" */ - FnArg: 3, - FzUsage: ts + 9992 /* "SQL" */}, // 4 - { - FzName: ts + 9996, /* "bp_progress" */ - FnArg: 2, - FzUsage: ts + 488 /* "" */}, // 5 - { - FzName: ts + 10008, /* "db" */ - FnArg: 3, - FzUsage: ts + 10011 /* "RBU" */}, // 6 - { - FzName: ts + 10015, /* "state" */ - FnArg: 2, - FzUsage: ts + 488 /* "" */}, // 7 - { - FzName: ts + 10021, /* "progress" */ - FnArg: 2, - FzUsage: ts + 488 /* "" */}, // 8 - { - FzName: ts + 10030, /* "close_no_error" */ - FnArg: 2, - FzUsage: ts + 488 /* "" */}, // 9 - { - FzName: ts + 10045, /* "temp_size_limit" */ - FnArg: 3, - FzUsage: ts + 10061 /* "LIMIT" */}, // 10 - { - FzName: ts + 10067, /* "temp_size" */ - FnArg: 2, - FzUsage: ts + 488 /* "" */}, // 11 - { - FzName: ts + 10077, /* "dbRbu_eval" */ - FnArg: 3, - FzUsage: ts + 9992 /* "SQL" */}, // 12 + {FzName: ts + 9942 /* "step" */, FnArg: 2, FzUsage: ts + 488 /* "" */}, // 0 + {FzName: ts + 9947 /* "close" */, FnArg: 2, FzUsage: ts + 488 /* "" */}, // 1 + {FzName: ts + 9953 /* "create_rbu_delta" */, FnArg: 2, FzUsage: ts + 488 /* "" */}, // 2 + {FzName: ts + 9970 /* "savestate" */, FnArg: 2, FzUsage: ts + 488 /* "" */}, // 3 + {FzName: ts + 9980 /* "dbMain_eval" */, FnArg: 3, FzUsage: ts + 9992 /* "SQL" */}, // 4 + {FzName: ts + 9996 /* "bp_progress" */, FnArg: 2, FzUsage: ts + 488 /* "" */}, // 5 + {FzName: ts + 10008 /* "db" */, FnArg: 3, FzUsage: ts + 10011 /* "RBU" */}, // 6 + {FzName: ts + 10015 /* "state" */, FnArg: 2, FzUsage: ts + 488 /* "" */}, // 7 + {FzName: ts + 10021 /* "progress" */, FnArg: 2, FzUsage: ts + 488 /* "" */}, // 8 + {FzName: ts + 10030 /* "close_no_error" */, FnArg: 2, FzUsage: ts + 488 /* "" */}, // 9 + {FzName: ts + 10045 /* "temp_size_limit" */, FnArg: 3, FzUsage: ts + 10061 /* "LIMIT" */}, // 10 + {FzName: ts + 10067 /* "temp_size" */, FnArg: 2, FzUsage: ts + 488 /* "" */}, // 11 + {FzName: ts + 10077 /* "dbRbu_eval" */, FnArg: 3, FzUsage: ts + 9992 /* "SQL" */}, // 12 {}, } // var iCmd int32 at bp+360, 4 if objc < 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10088 /* "METHOD" */) - return 1 + return TCL_ERROR } ret = tcl.XTcl_GetIndexFromObjStruct(tls, - interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+24 /* &aCmd[0] */, int32(unsafe.Sizeof(RbuCmd{})), ts+10095 /* "method" */, 0, bp+360 /* &iCmd */) + interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+24 /* &aCmd[0] */, int32(unsafe.Sizeof(RbuCmd{})), ts+10095 /* "method" */, 0, bp+360 /* &iCmd */) if ret != 0 { - return 1 + return TCL_ERROR } if objc != (*RbuCmd)(unsafe.Pointer(bp+24 /* &aCmd */ +uintptr(*(*int32)(unsafe.Pointer(bp + 360 /* iCmd */)))*24)).FnArg { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, (*RbuCmd)(unsafe.Pointer(bp+24 /* &aCmd */ +uintptr(*(*int32)(unsafe.Pointer(bp + 360 /* iCmd */)))*24)).FzUsage) - return 1 + return TCL_ERROR } switch *(*int32)(unsafe.Pointer(bp + 360 /* iCmd */)) { @@ -36930,13 +34290,13 @@ func test_sqlite3rbu_cmd(tls *libc.TLS, clientData ClientData, interp uintptr, o { *(*uintptr)(unsafe.Pointer(bp + 368 /* zErrmsg */)) = uintptr(0) var rc int32 - tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)))) + tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv)))) if *(*int32)(unsafe.Pointer(bp + 360 /* iCmd */)) == 1 { rc = sqlite3.Xsqlite3rbu_close(tls, pRbu, bp+368 /* &zErrmsg */) } else { rc = sqlite3.Xsqlite3rbu_close(tls, pRbu, uintptr(0)) } - if (rc == 0) || (rc == 101) { + if (rc == SQLITE_OK) || (rc == SQLITE_DONE) { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) } else { @@ -36945,7 +34305,7 @@ func test_sqlite3rbu_cmd(tls *libc.TLS, clientData ClientData, interp uintptr, o tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+10102 /* " - " */, *(*uintptr)(unsafe.Pointer(bp + 368 /* zErrmsg */)), 0)) sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 368 /* zErrmsg */))) } - ret = 1 + ret = TCL_ERROR } break @@ -36955,15 +34315,15 @@ func test_sqlite3rbu_cmd(tls *libc.TLS, clientData ClientData, interp uintptr, o { var db uintptr = sqlite3.Xsqlite3rbu_db(tls, pRbu, 0) var rc int32 = sqlite3.Xsqlite3_create_function(tls, - db, ts+9932 /* "rbu_delta" */, -1, 1, interp, *(*uintptr)(unsafe.Pointer(&struct { + db, ts+9932 /* "rbu_delta" */, -1, SQLITE_UTF8, interp, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{test_rbu_delta})), uintptr(0), uintptr(0)) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) ret = func() int32 { - if rc == 0 { - return 0 + if rc == SQLITE_OK { + return TCL_OK } - return 1 + return TCL_ERROR }() break @@ -36974,10 +34334,10 @@ func test_sqlite3rbu_cmd(tls *libc.TLS, clientData ClientData, interp uintptr, o var rc int32 = sqlite3.Xsqlite3rbu_savestate(tls, pRbu) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) ret = func() int32 { - if rc == 0 { - return 0 + if rc == SQLITE_OK { + return TCL_OK } - return 1 + return TCL_ERROR }() break @@ -36988,10 +34348,10 @@ func test_sqlite3rbu_cmd(tls *libc.TLS, clientData ClientData, interp uintptr, o case 4: /* dbMain_eval */ { var db uintptr = sqlite3.Xsqlite3rbu_db(tls, pRbu, (libc.Bool32(*(*int32)(unsafe.Pointer(bp + 360 /* iCmd */)) == 12))) - var rc int32 = sqlite3.Xsqlite3_exec(tls, db, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), uintptr(0), uintptr(0), uintptr(0)) - if rc != 0 { + var rc int32 = sqlite3.Xsqlite3_exec(tls, db, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), uintptr(0), uintptr(0), uintptr(0)) + if rc != SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_errmsg(tls, db), -1)) - ret = 1 + ret = TCL_ERROR } break @@ -37018,14 +34378,14 @@ func test_sqlite3rbu_cmd(tls *libc.TLS, clientData ClientData, interp uintptr, o { // var bArg int32 at bp+384, 4 - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+384 /* &bArg */) != 0 { - ret = 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+384 /* &bArg */) != 0 { + ret = TCL_ERROR } else { // var zBuf [50]int8 at bp+388, 50 var db uintptr = sqlite3.Xsqlite3rbu_db(tls, pRbu, *(*int32)(unsafe.Pointer(bp + 384 /* bArg */))) if sqlite3TestMakePointerStr(tls, interp, bp+388 /* &zBuf[0] */, db) != 0 { - ret = 1 + ret = TCL_ERROR } else { tcl.XTcl_SetResult(tls, interp, bp+388 /* &zBuf[0] */, uintptr(1)) } @@ -37054,8 +34414,8 @@ func test_sqlite3rbu_cmd(tls *libc.TLS, clientData ClientData, interp uintptr, o { // var nLimit sqlite3_int64 at bp+488, 8 - if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+488 /* &nLimit */) != 0 { - ret = 1 + if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+488 /* &nLimit */) != 0 { + ret = TCL_ERROR } else { *(*sqlite3_int64)(unsafe.Pointer(bp + 488 /* nLimit */)) = sqlite3.Xsqlite3rbu_temp_size_limit(tls, pRbu, *(*sqlite3_int64)(unsafe.Pointer(bp + 488 /* nLimit */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, *(*sqlite3_int64)(unsafe.Pointer(bp + 488 /* nLimit */)))) @@ -37096,21 +34456,21 @@ func test_sqlite3rbu(tls *libc.TLS, clientData ClientData, interp uintptr, objc if (objc != 4) && (objc != 5) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10137 /* "NAME TARGET-DB R..." */) - return 1 + return TCL_ERROR } - zCmd = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - zTarget = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - zRbu = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + zCmd = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + zTarget = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + zRbu = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) if objc == 5 { - zStateDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8))) + zStateDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) } pRbu = sqlite3.Xsqlite3rbu_open(tls, zTarget, zRbu, zStateDb) tcl.XTcl_CreateObjCommand(tls, interp, zCmd, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 }{test_sqlite3rbu_cmd})), pRbu, uintptr(0)) - tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - return 0 + tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + return TCL_OK } // Tclcmd: sqlite3rbu_vacuum CMD @@ -37122,14 +34482,14 @@ func test_sqlite3rbu_vacuum(tls *libc.TLS, clientData ClientData, interp uintptr if (objc != 3) && (objc != 4) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10170 /* "NAME TARGET-DB ?..." */) - return 1 + return TCL_ERROR } - zCmd = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - zTarget = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zCmd = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + zTarget = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if objc == 4 { - zStateDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + zStateDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) } - if (zStateDb != 0) && (int32(*(*int8)(unsafe.Pointer(zStateDb + uintptr(0)))) == 0) { + if (zStateDb != 0) && (int32(*(*int8)(unsafe.Pointer(zStateDb))) == 0) { zStateDb = uintptr(0) } @@ -37137,8 +34497,8 @@ func test_sqlite3rbu_vacuum(tls *libc.TLS, clientData ClientData, interp uintptr tcl.XTcl_CreateObjCommand(tls, interp, zCmd, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 }{test_sqlite3rbu_cmd})), pRbu, uintptr(0)) - tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - return 0 + tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + return TCL_OK } // Tclcmd: sqlite3rbu_create_vfs ?-default? NAME PARENT @@ -37149,26 +34509,26 @@ func test_sqlite3rbu_create_vfs(tls *libc.TLS, clientData ClientData, interp uin if (objc != 3) && (objc != 4) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10196 /* "?-default? NAME ..." */) - return 1 + return TCL_ERROR } zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-2))*8))) zParent = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8))) - if int32(*(*int8)(unsafe.Pointer(zParent + uintptr(0)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(zParent))) == 0 { zParent = uintptr(0) } rc = sqlite3.Xsqlite3rbu_create_vfs(tls, zName, zParent) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 1 + return TCL_ERROR } else if objc == 4 { var pVfs uintptr = sqlite3.Xsqlite3_vfs_find(tls, zName) sqlite3.Xsqlite3_vfs_register(tls, pVfs, 1) } tcl.XTcl_ResetResult(tls, interp) - return 0 + return TCL_OK } // Tclcmd: sqlite3rbu_destroy_vfs NAME @@ -37177,12 +34537,12 @@ func test_sqlite3rbu_destroy_vfs(tls *libc.TLS, clientData ClientData, interp ui if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10219 /* "NAME" */) - return 1 + return TCL_ERROR } - zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) sqlite3.Xsqlite3rbu_destroy_vfs(tls, zName) - return 0 + return TCL_OK } // Tclcmd: sqlite3rbu_internal_test @@ -37194,16 +34554,16 @@ func test_sqlite3rbu_internal_test(tls *libc.TLS, clientData ClientData, interp if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } db = sqlite3.Xsqlite3rbu_db(tls, uintptr(0), 0) if db != uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+10224 /* "sqlite3rbu_db(0,..." */, 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } func SqliteRbu_Init(tls *libc.TLS, interp uintptr) int32 { /* test_rbu.c:365:5: */ @@ -37214,28 +34574,18 @@ func SqliteRbu_Init(tls *libc.TLS, interp uintptr) int32 { /* test_rbu.c:365:5: }{}))); i++ { tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd[i].FzName, aObjCmd[i].FxProc, uintptr(0), uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd = [5]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 10247, /* "sqlite3rbu" */ - FxProc: 0}, - { - FzName: ts + 10258, /* "sqlite3rbu_vacuu..." */ - FxProc: 0}, - { - FzName: ts + 10276, /* "sqlite3rbu_creat..." */ - FxProc: 0}, - { - FzName: ts + 10298, /* "sqlite3rbu_destr..." */ - FxProc: 0}, - { - FzName: ts + 10321, /* "sqlite3rbu_inter..." */ - FxProc: 0}, + {FzName: ts + 10247 /* "sqlite3rbu" */, FxProc: 0}, + {FzName: ts + 10258 /* "sqlite3rbu_vacuu..." */, FxProc: 0}, + {FzName: ts + 10276 /* "sqlite3rbu_creat..." */, FxProc: 0}, + {FzName: ts + 10298 /* "sqlite3rbu_destr..." */, FxProc: 0}, + {FzName: ts + 10321 /* "sqlite3rbu_inter..." */, FxProc: 0}, } /* test_rbu.c:369:5 */ // 2014-09-08 @@ -38255,11 +35605,11 @@ func incrblobClose(tls *libc.TLS, instanceData ClientData, interp uintptr) int32 // Free the IncrblobChannel structure tcl.XTcl_Free(tls, p) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_errmsg(tls, db), uintptr(1)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Read data from an incremental blob channel. @@ -38278,7 +35628,7 @@ func incrblobInput(tls *libc.TLS, instanceData ClientData, buf uintptr, bufSize } rc = sqlite3.Xsqlite3_blob_read(tls, (*IncrblobChannel)(unsafe.Pointer(p)).FpBlob, buf, nRead, (*IncrblobChannel)(unsafe.Pointer(p)).FiSeek) - if rc != 0 { + if rc != SQLITE_OK { *(*int32)(unsafe.Pointer(errorCodePtr)) = rc return -1 } @@ -38296,7 +35646,7 @@ func incrblobOutput(tls *libc.TLS, instanceData ClientData, buf uintptr, toWrite nBlob = sqlite3.Xsqlite3_blob_bytes(tls, (*IncrblobChannel)(unsafe.Pointer(p)).FpBlob) if ((*IncrblobChannel)(unsafe.Pointer(p)).FiSeek + nWrite) > nBlob { - *(*int32)(unsafe.Pointer(errorCodePtr)) = 22 + *(*int32)(unsafe.Pointer(errorCodePtr)) = EINVAL return -1 } if nWrite <= 0 { @@ -38304,8 +35654,8 @@ func incrblobOutput(tls *libc.TLS, instanceData ClientData, buf uintptr, toWrite } rc = sqlite3.Xsqlite3_blob_write(tls, (*IncrblobChannel)(unsafe.Pointer(p)).FpBlob, buf, nWrite, (*IncrblobChannel)(unsafe.Pointer(p)).FiSeek) - if rc != 0 { - *(*int32)(unsafe.Pointer(errorCodePtr)) = 5 + if rc != SQLITE_OK { + *(*int32)(unsafe.Pointer(errorCodePtr)) = EIO return -1 } @@ -38318,13 +35668,13 @@ func incrblobSeek(tls *libc.TLS, instanceData ClientData, offset int64, seekMode var p uintptr = instanceData switch seekMode { - case 0: + case SEEK_SET: (*IncrblobChannel)(unsafe.Pointer(p)).FiSeek = int32(offset) break - case 1: + case SEEK_CUR: *(*int32)(unsafe.Pointer(p + 16 /* &.iSeek */)) += int32((offset)) break - case 2: + case SEEK_END: (*IncrblobChannel)(unsafe.Pointer(p)).FiSeek = (int32(int64(sqlite3.Xsqlite3_blob_bytes(tls, (*IncrblobChannel)(unsafe.Pointer(p)).FpBlob)) + offset)) break @@ -38339,39 +35689,18 @@ func incrblobWatch(tls *libc.TLS, instanceData ClientData, mode int32) { /* tcls } func incrblobHandle(tls *libc.TLS, instanceData ClientData, dir int32, hPtr uintptr) int32 { /* tclsqlite.c:361:26: */ - return 1 + return TCL_ERROR } var IncrblobChannelType = Tcl_ChannelType{ - FtypeName: ts + 10346, /* "incrblob" */ - Fversion:// typeName - uintptr(0x2), - FcloseProc:// version - 0, - FinputProc:// closeProc - 0, - FoutputProc:// inputProc - 0, - FseekProc:// outputProc - 0, - FsetOptionProc:// seekProc - uintptr(0), - FgetOptionProc:// setOptionProc - uintptr(0), - FwatchProc:// getOptionProc - 0, - FgetHandleProc:// watchProc (this is a no-op) - 0, - Fclose2Proc:// getHandleProc (always returns error) - uintptr(0), - FblockModeProc:// close2Proc - uintptr(0), - FflushProc:// blockModeProc - uintptr(0), - FhandlerProc:// flushProc - uintptr(0), - FwideSeekProc:// handlerProc - uintptr(0), // wideSeekProc + FtypeName: ts + 10346, /* "incrblob" */ // typeName + Fversion: uintptr(0x2), // version + FcloseProc: 0, // closeProc + FinputProc: 0, // inputProc + FoutputProc: 0, // outputProc + FseekProc: 0, // getOptionProc + FwatchProc: 0, // watchProc (this is a no-op) + FgetHandleProc: 0, // wideSeekProc } /* tclsqlite.c:369:24 */ // Create a new incrblob channel. @@ -38393,9 +35722,9 @@ func createIncrblobChannel(tls *libc.TLS, interp uintptr, pDb uintptr, zDb uintp // var zChannel [64]int8 at bp+16, 64 rc = sqlite3.Xsqlite3_blob_open(tls, db, zDb, zTable, zColumn, iRow, libc.BoolInt32(!(isReadonly != 0)), bp+8 /* &pBlob */) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(1)) - return 1 + return TCL_ERROR } p = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(IncrblobChannel{}))) @@ -38416,7 +35745,7 @@ func createIncrblobChannel(tls *libc.TLS, interp uintptr, pDb uintptr, zDb uintp (*IncrblobChannel)(unsafe.Pointer(p)).FpDb = pDb tcl.XTcl_SetResult(tls, interp, tcl.XTcl_GetChannelName(tls, (*IncrblobChannel)(unsafe.Pointer(p)).Fchannel), uintptr(1)) - return 0 + return TCL_OK } var count int32 = 0 /* tclsqlite.c:406:14 */ @@ -38459,7 +35788,7 @@ func findSqlFunc(tls *libc.TLS, pDb uintptr, zName uintptr) uintptr { /* tclsqli var pNew uintptr var nName int32 = strlen30(tls, zName) pNew = tcl.XTcl_Alloc(tls, (uint32((uint64(unsafe.Sizeof(SqlFunc{})) + uint64(nName)) + uint64(1)))) - (*SqlFunc)(unsafe.Pointer(pNew)).FzName = (pNew + uintptr(1)*48) + (*SqlFunc)(unsafe.Pointer(pNew)).FzName = (pNew + 1*48) libc.Xmemcpy(tls, (*SqlFunc)(unsafe.Pointer(pNew)).FzName, zName, (uint64(nName + 1))) for p = (*SqliteDb)(unsafe.Pointer(pDb)).FpFunc; p != 0; p = (*SqlFunc)(unsafe.Pointer(p)).FpNext { if sqlite3.Xsqlite3_stricmp(tls, (*SqlFunc)(unsafe.Pointer(p)).FzName, (*SqlFunc)(unsafe.Pointer(pNew)).FzName) == 0 { @@ -38598,7 +35927,7 @@ func DbBusyHandler(tls *libc.TLS, cd uintptr, nTries int32) int32 { /* tclsqlite sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+40 /* &zVal[0] */, ts+1237 /* "%d" */, libc.VaList(bp, nTries)) rc = tcl.XTcl_VarEval(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, libc.VaList(bp+8, (*SqliteDb)(unsafe.Pointer(pDb)).FzBusy, ts+4585 /* " " */, bp+40 /* &zVal[0] */, uintptr(0))) - if (rc != 0) || (libc.Xatoi(tls, tcl.XTcl_GetStringResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp)) != 0) { + if (rc != TCL_OK) || (libc.Xatoi(tls, tcl.XTcl_GetStringResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp)) != 0) { return 0 } return 1 @@ -38610,7 +35939,7 @@ func DbProgressHandler(tls *libc.TLS, cd uintptr) int32 { /* tclsqlite.c:601:12: var rc int32 rc = tcl.XTcl_Eval(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*SqliteDb)(unsafe.Pointer(pDb)).FzProgress) - if (rc != 0) || (libc.Xatoi(tls, tcl.XTcl_GetStringResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp)) != 0) { + if (rc != TCL_OK) || (libc.Xatoi(tls, tcl.XTcl_GetStringResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp)) != 0) { return 1 } return 0 @@ -38642,7 +35971,7 @@ func DbTraceV2Handler(tls *libc.TLS, type1 uint32, cd uintptr, pd uintptr, xd ui var pCmd uintptr switch type1 { - case uint32(0x01): + case SQLITE_TRACE_STMT: { var pStmt uintptr = pd var zSql uintptr = xd @@ -38653,7 +35982,7 @@ func DbTraceV2Handler(tls *libc.TLS, type1 uint32, cd uintptr, pd uintptr, xd ui tcl.XTcl_NewWideIntObj(tls, int64(pStmt))) tcl.XTcl_ListObjAppendElement(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, tcl.XTcl_NewStringObj(tls, zSql, -1)) - tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, 0x040000) + tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, TCL_EVAL_DIRECT) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pCmd if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -38664,7 +35993,7 @@ func DbTraceV2Handler(tls *libc.TLS, type1 uint32, cd uintptr, pd uintptr, xd ui break } - case uint32(0x02): + case SQLITE_TRACE_PROFILE: { var pStmt uintptr = pd var ns sqlite3_int64 = *(*sqlite3_int64)(unsafe.Pointer(xd)) @@ -38675,7 +36004,7 @@ func DbTraceV2Handler(tls *libc.TLS, type1 uint32, cd uintptr, pd uintptr, xd ui tcl.XTcl_NewWideIntObj(tls, int64(pStmt))) tcl.XTcl_ListObjAppendElement(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, tcl.XTcl_NewWideIntObj(tls, ns)) - tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, 0x040000) + tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, TCL_EVAL_DIRECT) for ok1 := true; ok1; ok1 = 0 != 0 { var _objPtr uintptr = pCmd if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -38686,7 +36015,7 @@ func DbTraceV2Handler(tls *libc.TLS, type1 uint32, cd uintptr, pd uintptr, xd ui break } - case uint32(0x04): + case SQLITE_TRACE_ROW: { var pStmt uintptr = pd @@ -38694,7 +36023,7 @@ func DbTraceV2Handler(tls *libc.TLS, type1 uint32, cd uintptr, pd uintptr, xd ui (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ tcl.XTcl_ListObjAppendElement(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, tcl.XTcl_NewWideIntObj(tls, int64(pStmt))) - tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, 0x040000) + tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, TCL_EVAL_DIRECT) for ok2 := true; ok2; ok2 = 0 != 0 { var _objPtr uintptr = pCmd if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -38705,7 +36034,7 @@ func DbTraceV2Handler(tls *libc.TLS, type1 uint32, cd uintptr, pd uintptr, xd ui break } - case uint32(0x08): + case SQLITE_TRACE_CLOSE: { var db uintptr = pd @@ -38713,7 +36042,7 @@ func DbTraceV2Handler(tls *libc.TLS, type1 uint32, cd uintptr, pd uintptr, xd ui (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ tcl.XTcl_ListObjAppendElement(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, tcl.XTcl_NewWideIntObj(tls, int64(db))) - tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, 0x040000) + tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, TCL_EVAL_DIRECT) for ok3 := true; ok3; ok3 = 0 != 0 { var _objPtr uintptr = pCmd if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -38725,7 +36054,7 @@ func DbTraceV2Handler(tls *libc.TLS, type1 uint32, cd uintptr, pd uintptr, xd ui } } - return 0 + return SQLITE_OK } // This routine is called by the SQLite profile handler after a statement @@ -38758,7 +36087,7 @@ func DbCommitHandler(tls *libc.TLS, cd uintptr) int32 { /* tclsqlite.c:737:12: * var rc int32 rc = tcl.XTcl_Eval(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*SqliteDb)(unsafe.Pointer(pDb)).FzCommit) - if (rc != 0) || (libc.Xatoi(tls, tcl.XTcl_GetStringResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp)) != 0) { + if (rc != TCL_OK) || (libc.Xatoi(tls, tcl.XTcl_GetStringResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp)) != 0) { return 1 } return 0 @@ -38767,7 +36096,7 @@ func DbCommitHandler(tls *libc.TLS, cd uintptr) int32 { /* tclsqlite.c:737:12: * func DbRollbackHandler(tls *libc.TLS, clientData uintptr) { /* tclsqlite.c:748:13: */ var pDb uintptr = clientData - if 0 != tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*SqliteDb)(unsafe.Pointer(pDb)).FpRollbackHook, 0) { + if TCL_OK != tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*SqliteDb)(unsafe.Pointer(pDb)).FpRollbackHook, 0) { tcl.XTcl_BackgroundError(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) } } @@ -38777,7 +36106,7 @@ func DbWalHandler(tls *libc.TLS, clientData uintptr, db uintptr, zDb uintptr, nE bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* ret */)) = 0 + *(*int32)(unsafe.Pointer(bp /* ret */)) = SQLITE_OK var p uintptr var pDb uintptr = clientData var interp uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).Finterp @@ -38786,8 +36115,8 @@ func DbWalHandler(tls *libc.TLS, clientData uintptr, db uintptr, zDb uintptr, nE (*Tcl_Obj)(unsafe.Pointer(p)).FrefCount++ tcl.XTcl_ListObjAppendElement(tls, interp, p, tcl.XTcl_NewStringObj(tls, zDb, -1)) tcl.XTcl_ListObjAppendElement(tls, interp, p, tcl.XTcl_NewIntObj(tls, nEntry)) - if (0 != tcl.XTcl_EvalObjEx(tls, interp, p, 0)) || - (0 != tcl.XTcl_GetIntFromObj(tls, interp, tcl.XTcl_GetObjResult(tls, interp), bp /* &ret */)) { + if (TCL_OK != tcl.XTcl_EvalObjEx(tls, interp, p, 0)) || + (TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, tcl.XTcl_GetObjResult(tls, interp), bp /* &ret */)) { tcl.XTcl_BackgroundError(tls, interp) } for ok := true; ok; ok = 0 != 0 { @@ -38807,15 +36136,15 @@ func setTestUnlockNotifyVars(tls *libc.TLS, interp uintptr, iArg int32, nArg int // var zBuf [64]int8 at bp+16, 64 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([64]int8{})), bp+16 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp, iArg)) - tcl.XTcl_SetVar2(tls, interp, ts+10372 /* "sqlite_unlock_no..." */, uintptr(0), bp+16 /* &zBuf[0] */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+10372 /* "sqlite_unlock_no..." */, uintptr(0), bp+16 /* &zBuf[0] */, TCL_GLOBAL_ONLY) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([64]int8{})), bp+16 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+8, nArg)) - tcl.XTcl_SetVar2(tls, interp, ts+10397 /* "sqlite_unlock_no..." */, uintptr(0), bp+16 /* &zBuf[0] */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+10397 /* "sqlite_unlock_no..." */, uintptr(0), bp+16 /* &zBuf[0] */, TCL_GLOBAL_ONLY) } func DbUnlockNotify(tls *libc.TLS, apArg uintptr, nArg int32) { /* tclsqlite.c:799:13: */ var i int32 for i = 0; i < nArg; i++ { - var flags int32 = (0x020000 | 0x040000) + var flags int32 = (TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT) var pDb uintptr = *(*uintptr)(unsafe.Pointer(apArg + uintptr(i)*8)) setTestUnlockNotifyVars(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, i, nArg) @@ -38842,7 +36171,7 @@ func DbPreUpdateHandler(tls *libc.TLS, p uintptr, db uintptr, op int32, zDb uint tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewStringObj(tls, zTbl, -1)) tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewWideIntObj(tls, iKey1)) tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewWideIntObj(tls, iKey2)) - tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, 0x040000) + tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, TCL_EVAL_DIRECT) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pCmd if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -38863,7 +36192,7 @@ func DbUpdateHandler(tls *libc.TLS, p uintptr, op int32, zDb uintptr, zTbl uintp tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewStringObj(tls, zDb, -1)) tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewStringObj(tls, zTbl, -1)) tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewWideIntObj(tls, rowid)) - tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, 0x040000) + tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, TCL_EVAL_DIRECT) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pCmd if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -38898,7 +36227,7 @@ func tclSqlCollate(tls *libc.TLS, pCtx uintptr, nA int32, zA uintptr, nB int32, (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ tcl.XTcl_ListObjAppendElement(tls, (*SqlCollate)(unsafe.Pointer(p)).Finterp, pCmd, tcl.XTcl_NewStringObj(tls, zA, nA)) tcl.XTcl_ListObjAppendElement(tls, (*SqlCollate)(unsafe.Pointer(p)).Finterp, pCmd, tcl.XTcl_NewStringObj(tls, zB, nB)) - tcl.XTcl_EvalObjEx(tls, (*SqlCollate)(unsafe.Pointer(p)).Finterp, pCmd, 0x040000) + tcl.XTcl_EvalObjEx(tls, (*SqlCollate)(unsafe.Pointer(p)).Finterp, pCmd, TCL_EVAL_DIRECT) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pCmd if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -38958,7 +36287,7 @@ func tclSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t // Set pVal to contain the i'th column of this row. switch sqlite3.Xsqlite3_value_type(tls, pIn) { - case 4: + case SQLITE_BLOB: { var bytes int32 = sqlite3.Xsqlite3_value_bytes(tls, pIn) pVal = tcl.XTcl_NewByteArrayObj(tls, sqlite3.Xsqlite3_value_blob(tls, pIn), bytes) @@ -38966,7 +36295,7 @@ func tclSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t } fallthrough - case 1: + case SQLITE_INTEGER: { var v sqlite_int64 = sqlite3.Xsqlite3_value_int64(tls, pIn) if (v >= int64(-2147483647)) && (v <= int64(2147483647)) { @@ -38978,7 +36307,7 @@ func tclSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t } fallthrough - case 2: + case SQLITE_FLOAT: { var r float64 = sqlite3.Xsqlite3_value_double(tls, pIn) pVal = tcl.XTcl_NewDoubleObj(tls, r) @@ -38986,7 +36315,7 @@ func tclSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t } fallthrough - case 5: + case SQLITE_NULL: { pVal = tcl.XTcl_NewStringObj(tls, (*SqliteDb)(unsafe.Pointer((*SqlFunc)(unsafe.Pointer(p)).FpDb)).FzNull, -1) break @@ -39019,7 +36348,7 @@ func tclSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t // happening, make sure pCmd has a valid string representation tcl.XTcl_GetString(tls, pCmd) } - rc = tcl.XTcl_EvalObjEx(tls, (*SqlFunc)(unsafe.Pointer(p)).Finterp, pCmd, 0x040000) + rc = tcl.XTcl_EvalObjEx(tls, (*SqlFunc)(unsafe.Pointer(p)).Finterp, pCmd, TCL_EVAL_DIRECT) for ok2 := true; ok2; ok2 = 0 != 0 { var _objPtr uintptr = pCmd if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -39028,7 +36357,7 @@ func tclSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t } } - if (rc != 0) && (rc != 2) { + if (rc != 0) && (rc != TCL_RETURN) { sqlite3.Xsqlite3_result_error(tls, context, tcl.XTcl_GetStringResult(tls, (*SqlFunc)(unsafe.Pointer(p)).Finterp), -1) } else { var pVar uintptr = tcl.XTcl_GetObjResult(tls, (*SqlFunc)(unsafe.Pointer(p)).Finterp) @@ -39041,27 +36370,27 @@ func tclSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t } return ts + 488 /* "" */ }() - var c int8 = *(*int8)(unsafe.Pointer(zType + uintptr(0))) + var c int8 = *(*int8)(unsafe.Pointer(zType)) var eType int32 = (*SqlFunc)(unsafe.Pointer(p)).FeType - if eType == 5 { + if eType == SQLITE_NULL { if ((int32(c) == 'b') && (libc.Xstrcmp(tls, zType, ts+2404 /* "bytearray" */) == 0)) && ((*Tcl_Obj)(unsafe.Pointer(pVar)).Fbytes == uintptr(0)) { // Only return a BLOB type if the Tcl variable is a bytearray and // has no string representation. - eType = 4 + eType = SQLITE_BLOB } else if (((int32(c) == 'b') && (libc.Xstrcmp(tls, zType, ts+2414 /* "boolean" */) == 0)) || ((int32(c) == 'w') && (libc.Xstrcmp(tls, zType, ts+2429 /* "wideInt" */) == 0))) || ((int32(c) == 'i') && (libc.Xstrcmp(tls, zType, ts+2437 /* "int" */) == 0)) { - eType = 1 + eType = SQLITE_INTEGER } else if (int32(c) == 'd') && (libc.Xstrcmp(tls, zType, ts+2422 /* "double" */) == 0) { - eType = 2 + eType = SQLITE_FLOAT } else { - eType = 3 + eType = SQLITE_TEXT } } switch eType { - case 4: + case SQLITE_BLOB: { data = tcl.XTcl_GetByteArrayFromObj(tls, pVar, bp+16 /* &n */) sqlite3.Xsqlite3_result_blob(tls, context, data, *(*int32)(unsafe.Pointer(bp + 16 /* n */)), libc.UintptrFromInt32(-1)) @@ -39069,11 +36398,11 @@ func tclSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t } fallthrough - case 1: + case SQLITE_INTEGER: { // var v Tcl_WideInt at bp+24, 8 - if 0 == tcl.XTcl_GetWideIntFromObj(tls, uintptr(0), pVar, bp+24 /* &v */) { + if TCL_OK == tcl.XTcl_GetWideIntFromObj(tls, uintptr(0), pVar, bp+24 /* &v */) { sqlite3.Xsqlite3_result_int64(tls, context, *(*Tcl_WideInt)(unsafe.Pointer(bp + 24 /* v */))) break } @@ -39081,11 +36410,11 @@ func tclSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* t } fallthrough - case 2: + case SQLITE_FLOAT: { // var r float64 at bp+32, 8 - if 0 == tcl.XTcl_GetDoubleFromObj(tls, uintptr(0), pVar, bp+32 /* &r */) { + if TCL_OK == tcl.XTcl_GetDoubleFromObj(tls, uintptr(0), pVar, bp+32 /* &r */) { sqlite3.Xsqlite3_result_double(tls, context, *(*float64)(unsafe.Pointer(bp + 32 /* r */))) break } @@ -39123,113 +36452,113 @@ func auth_callback(tls *libc.TLS, pArg uintptr, code int32, zArg1 uintptr, zArg2 // sqlite3_set_authorizer() interface. var pDb uintptr = pArg if (*SqliteDb)(unsafe.Pointer(pDb)).FdisableAuth != 0 { - return 0 + return SQLITE_OK } // EVIDENCE-OF: R-56518-44310 The second parameter to the callback is an // integer action code that specifies the particular action to be // authorized. switch code { - case 0: + case SQLITE_COPY: zCode = ts + 10448 /* "SQLITE_COPY" */ break - case 1: + case SQLITE_CREATE_INDEX: zCode = ts + 10460 /* "SQLITE_CREATE_IN..." */ break - case 2: + case SQLITE_CREATE_TABLE: zCode = ts + 10480 /* "SQLITE_CREATE_TA..." */ break - case 3: + case SQLITE_CREATE_TEMP_INDEX: zCode = ts + 10500 /* "SQLITE_CREATE_TE..." */ break - case 4: + case SQLITE_CREATE_TEMP_TABLE: zCode = ts + 10525 /* "SQLITE_CREATE_TE..." */ break - case 5: + case SQLITE_CREATE_TEMP_TRIGGER: zCode = ts + 10550 /* "SQLITE_CREATE_TE..." */ break - case 6: + case SQLITE_CREATE_TEMP_VIEW: zCode = ts + 10577 /* "SQLITE_CREATE_TE..." */ break - case 7: + case SQLITE_CREATE_TRIGGER: zCode = ts + 10601 /* "SQLITE_CREATE_TR..." */ break - case 8: + case SQLITE_CREATE_VIEW: zCode = ts + 10623 /* "SQLITE_CREATE_VI..." */ break - case 9: + case SQLITE_DELETE: zCode = ts + 10642 /* "SQLITE_DELETE" */ break - case 10: + case SQLITE_DROP_INDEX: zCode = ts + 10656 /* "SQLITE_DROP_INDE..." */ break - case 11: + case SQLITE_DROP_TABLE: zCode = ts + 10674 /* "SQLITE_DROP_TABL..." */ break - case 12: + case SQLITE_DROP_TEMP_INDEX: zCode = ts + 10692 /* "SQLITE_DROP_TEMP..." */ break - case 13: + case SQLITE_DROP_TEMP_TABLE: zCode = ts + 10715 /* "SQLITE_DROP_TEMP..." */ break - case 14: + case SQLITE_DROP_TEMP_TRIGGER: zCode = ts + 10738 /* "SQLITE_DROP_TEMP..." */ break - case 15: + case SQLITE_DROP_TEMP_VIEW: zCode = ts + 10763 /* "SQLITE_DROP_TEMP..." */ break - case 16: + case SQLITE_DROP_TRIGGER: zCode = ts + 10785 /* "SQLITE_DROP_TRIG..." */ break - case 17: + case SQLITE_DROP_VIEW: zCode = ts + 10805 /* "SQLITE_DROP_VIEW" */ break - case 18: + case SQLITE_INSERT: zCode = ts + 10822 /* "SQLITE_INSERT" */ break - case 19: + case SQLITE_PRAGMA: zCode = ts + 10836 /* "SQLITE_PRAGMA" */ break - case 20: + case SQLITE_READ: zCode = ts + 10850 /* "SQLITE_READ" */ break - case 21: + case SQLITE_SELECT: zCode = ts + 10862 /* "SQLITE_SELECT" */ break - case 22: + case SQLITE_TRANSACTION: zCode = ts + 10876 /* "SQLITE_TRANSACTI..." */ break - case 23: + case SQLITE_UPDATE: zCode = ts + 10895 /* "SQLITE_UPDATE" */ break - case 24: + case SQLITE_ATTACH: zCode = ts + 10909 /* "SQLITE_ATTACH" */ break - case 25: + case SQLITE_DETACH: zCode = ts + 10923 /* "SQLITE_DETACH" */ break - case 26: + case SQLITE_ALTER_TABLE: zCode = ts + 10937 /* "SQLITE_ALTER_TAB..." */ break - case 27: + case SQLITE_REINDEX: zCode = ts + 10956 /* "SQLITE_REINDEX" */ break - case 28: + case SQLITE_ANALYZE: zCode = ts + 10971 /* "SQLITE_ANALYZE" */ break - case 29: + case SQLITE_CREATE_VTABLE: zCode = ts + 10986 /* "SQLITE_CREATE_VT..." */ break - case 30: + case SQLITE_DROP_VTABLE: zCode = ts + 11007 /* "SQLITE_DROP_VTAB..." */ break - case 31: + case SQLITE_FUNCTION: zCode = ts + 11026 /* "SQLITE_FUNCTION" */ break - case 32: + case SQLITE_SAVEPOINT: zCode = ts + 11042 /* "SQLITE_SAVEPOINT" */ break - case 33: + case SQLITE_RECURSIVE: zCode = ts + 11059 /* "SQLITE_RECURSIVE" */ break default: @@ -39265,17 +36594,17 @@ func auth_callback(tls *libc.TLS, pArg uintptr, code int32, zArg1 uintptr, zArg2 }()) rc = tcl.XTcl_GlobalEval(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*Tcl_DString)(unsafe.Pointer(bp /* &str */)).Fstring) tcl.XTcl_DStringFree(tls, bp /* &str */) - if rc == 0 { + if rc == TCL_OK { zReply = tcl.XTcl_GetStringResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) } else { zReply = ts + 11081 /* "SQLITE_DENY" */ } if libc.Xstrcmp(tls, zReply, ts+1987 /* "SQLITE_OK" */) == 0 { - rc = 0 + rc = SQLITE_OK } else if libc.Xstrcmp(tls, zReply, ts+11081 /* "SQLITE_DENY" */) == 0 { - rc = 1 + rc = SQLITE_DENY } else if libc.Xstrcmp(tls, zReply, ts+11093 /* "SQLITE_IGNORE" */) == 0 { - rc = 2 + rc = SQLITE_IGNORE } else { rc = 999 } @@ -39341,12 +36670,12 @@ func DbTransPostCmd(tls *libc.TLS, data uintptr, interp uintptr, result int32) i bp := tls.Alloc(16) defer tls.Free(16) - var pDb uintptr = *(*ClientData)(unsafe.Pointer(data + uintptr(0)*8)) + var pDb uintptr = *(*ClientData)(unsafe.Pointer(data)) var rc int32 = result var zEnd uintptr (*SqliteDb)(unsafe.Pointer(pDb)).FnTransaction-- - zEnd = azEnd[(((libc.Bool32(rc == 1)) * 2) + (libc.Bool32((*SqliteDb)(unsafe.Pointer(pDb)).FnTransaction == 0)))] + zEnd = azEnd[(((libc.Bool32(rc == TCL_ERROR)) * 2) + (libc.Bool32((*SqliteDb)(unsafe.Pointer(pDb)).FnTransaction == 0)))] (*SqliteDb)(unsafe.Pointer(pDb)).FdisableAuth++ if sqlite3.Xsqlite3_exec(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zEnd, uintptr(0), uintptr(0), uintptr(0)) != 0 { @@ -39359,9 +36688,9 @@ func DbTransPostCmd(tls *libc.TLS, data uintptr, interp uintptr, result int32) i // But it could also be that the user executed one or more BEGIN, // COMMIT, SAVEPOINT, RELEASE or ROLLBACK commands that are confusing // this method's logic. Not clear how this would be best handled. - if rc != 1 { + if rc != TCL_ERROR { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) - rc = 1 + rc = TCL_ERROR } sqlite3.Xsqlite3_exec(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, ts+7092 /* "ROLLBACK" */, uintptr(0), uintptr(0), uintptr(0)) } @@ -39391,7 +36720,7 @@ func dbPrepare(tls *libc.TLS, pDb uintptr, zSql uintptr, ppStmt uintptr, pzOut u // flags, which uses less lookaside memory. But if the cache is small, // omit that flag to make full use of lookaside if (*SqliteDb)(unsafe.Pointer(pDb)).FmaxStmt > 5 { - prepFlags = uint32(0x01) + prepFlags = SQLITE_PREPARE_PERSISTENT } return sqlite3.Xsqlite3_prepare_v3(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSql, -1, prepFlags, ppStmt, pzOut) @@ -39423,13 +36752,13 @@ func dbPrepareAndBind(tls *libc.TLS, pDb uintptr, zIn uintptr, pzOut uintptr, pp var c int8 var i int32 var needResultReset int32 = 0 // Need to invoke Tcl_ResetResult() - var rc int32 = 0 // Value to return + var rc int32 = SQLITE_OK // Value to return var interp uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).Finterp *(*uintptr)(unsafe.Pointer(ppPreStmt)) = uintptr(0) // Trim spaces from the start of zSql and calculate the remaining length. - for ((((int32(libc.AssignInt8(&c, *(*int8)(unsafe.Pointer(zSql + uintptr(0)))))) == ' ') || (int32(c) == '\t')) || (int32(c) == '\r')) || (int32(c) == '\n') { + for ((((int32(libc.AssignInt8(&c, *(*int8)(unsafe.Pointer(zSql))))) == ' ') || (int32(c) == '\t')) || (int32(c) == '\r')) || (int32(c) == '\n') { zSql++ } nSql = strlen30(tls, zSql) @@ -39466,19 +36795,19 @@ func dbPrepareAndBind(tls *libc.TLS, pDb uintptr, zIn uintptr, pzOut uintptr, pp if pPreStmt == uintptr(0) { var nByte int32 - if 0 != dbPrepare(tls, pDb, zSql, bp /* &pStmt */, pzOut) { + if SQLITE_OK != dbPrepare(tls, pDb, zSql, bp /* &pStmt */, pzOut) { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), -1)) - return 1 + return TCL_ERROR } if *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) == uintptr(0) { - if 0 != sqlite3.Xsqlite3_errcode(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb) { + if SQLITE_OK != sqlite3.Xsqlite3_errcode(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb) { // A compile-time error in the statement. tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), -1)) - return 1 + return TCL_ERROR } else { // The statement was a no-op. Continue to the next statement // in the SQL string. - return 0 + return TCL_OK } } @@ -39490,7 +36819,7 @@ func dbPrepareAndBind(tls *libc.TLS, pDb uintptr, zIn uintptr, pzOut uintptr, pp (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpStmt = *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnSql = (int32((int64(*(*uintptr)(unsafe.Pointer(pzOut))) - int64(zSql)) / 1)) (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FzSql = sqlite3.Xsqlite3_sql(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) - (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FapParm = (pPreStmt + uintptr(1)*56) + (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FapParm = (pPreStmt + 1*56) if (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FzSql == uintptr(0) { var zCopy uintptr = tcl.XTcl_Alloc(tls, (uint32((*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnSql + 1))) libc.Xmemcpy(tls, zCopy, zSql, uint64((*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnSql)) @@ -39502,8 +36831,8 @@ func dbPrepareAndBind(tls *libc.TLS, pDb uintptr, zIn uintptr, pzOut uintptr, pp // Bind values to parameters that begin with $ or : for i = 1; i <= nVar; i++ { var zVar uintptr = sqlite3.Xsqlite3_bind_parameter_name(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i) - if (zVar != uintptr(0)) && (((int32(*(*int8)(unsafe.Pointer(zVar + uintptr(0)))) == '$') || (int32(*(*int8)(unsafe.Pointer(zVar + uintptr(0)))) == ':')) || (int32(*(*int8)(unsafe.Pointer(zVar + uintptr(0)))) == '@')) { - var pVar uintptr = tcl.XTcl_GetVar2Ex(tls, interp, (zVar + uintptr(1)), uintptr(0), 0) + if (zVar != uintptr(0)) && (((int32(*(*int8)(unsafe.Pointer(zVar))) == '$') || (int32(*(*int8)(unsafe.Pointer(zVar))) == ':')) || (int32(*(*int8)(unsafe.Pointer(zVar))) == '@')) { + var pVar uintptr = tcl.XTcl_GetVar2Ex(tls, interp, (zVar + 1), uintptr(0), 0) if (pVar == uintptr(0)) && ((*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback != uintptr(0)) { var pCmd uintptr var rx int32 @@ -39514,17 +36843,17 @@ func dbPrepareAndBind(tls *libc.TLS, pDb uintptr, zIn uintptr, pzOut uintptr, pp tcl.XTcl_ResetResult(tls, interp) } needResultReset = 1 - rx = tcl.XTcl_EvalObjEx(tls, interp, pCmd, 0x040000) + rx = tcl.XTcl_EvalObjEx(tls, interp, pCmd, TCL_EVAL_DIRECT) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pCmd if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { tcl.XTclFreeObj(tls, _objPtr) } } - if rx == 0 { + if rx == TCL_OK { pVar = tcl.XTcl_GetObjResult(tls, interp) - } else if rx == 1 { - rc = 1 + } else if rx == TCL_ERROR { + rc = TCL_ERROR break } else { pVar = uintptr(0) @@ -39540,8 +36869,8 @@ func dbPrepareAndBind(tls *libc.TLS, pDb uintptr, zIn uintptr, pzOut uintptr, pp } return ts + 488 /* "" */ }() - c = *(*int8)(unsafe.Pointer(zType + uintptr(0))) - if (int32(*(*int8)(unsafe.Pointer(zVar + uintptr(0)))) == '@') || (((int32(c) == 'b') && (libc.Xstrcmp(tls, zType, ts+2404 /* "bytearray" */) == 0)) && ((*Tcl_Obj)(unsafe.Pointer(pVar)).Fbytes == uintptr(0))) { + c = *(*int8)(unsafe.Pointer(zType)) + if (int32(*(*int8)(unsafe.Pointer(zVar))) == '@') || (((int32(c) == 'b') && (libc.Xstrcmp(tls, zType, ts+2404 /* "bytearray" */) == 0)) && ((*Tcl_Obj)(unsafe.Pointer(pVar)).Fbytes == uintptr(0))) { // Load a BLOB type if the Tcl variable is a bytearray and // it has no string representation or the host // parameter name begins with "@". @@ -39578,7 +36907,7 @@ func dbPrepareAndBind(tls *libc.TLS, pDb uintptr, zIn uintptr, pzOut uintptr, pp } (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnParm = iParm *(*uintptr)(unsafe.Pointer(ppPreStmt)) = pPreStmt - if (needResultReset != 0) && (rc == 0) { + if (needResultReset != 0) && (rc == TCL_OK) { tcl.XTcl_ResetResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) } @@ -39767,7 +37096,7 @@ func dbEvalRowInfo(tls *libc.TLS, p uintptr, pnCol uintptr, papColName uintptr) func dbEvalStep(tls *libc.TLS, p uintptr) int32 { /* tclsqlite.c:1646:12: */ var zPrevSql uintptr = uintptr(0) // Previous value of p->zSql - for (*(*int8)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FzSql + uintptr(0))) != 0) || ((*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt != 0) { + for (*(*int8)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FzSql)) != 0) || ((*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt != 0) { var rc int32 if (*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt == uintptr(0) { zPrevSql = func() uintptr { @@ -39777,7 +37106,7 @@ func dbEvalStep(tls *libc.TLS, p uintptr) int32 { /* tclsqlite.c:1646:12: */ return (*DbEvalContext)(unsafe.Pointer(p)).FzSql }() rc = dbPrepareAndBind(tls, (*DbEvalContext)(unsafe.Pointer(p)).FpDb, (*DbEvalContext)(unsafe.Pointer(p)).FzSql, (p + 16 /* &.zSql */), (p + 24 /* &.pPreStmt */)) - if rc != 0 { + if rc != TCL_OK { return rc } } else { @@ -39787,26 +37116,26 @@ func dbEvalStep(tls *libc.TLS, p uintptr) int32 { /* tclsqlite.c:1646:12: */ var pStmt uintptr = (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpStmt rcs = sqlite3.Xsqlite3_step(tls, pStmt) - if rcs == 100 { - return 0 + if rcs == SQLITE_ROW { + return TCL_OK } if (*DbEvalContext)(unsafe.Pointer(p)).FpArray != 0 { dbEvalRowInfo(tls, p, uintptr(0), uintptr(0)) } rcs = sqlite3.Xsqlite3_reset(tls, pStmt) - (*SqliteDb)(unsafe.Pointer(pDb)).FnStep = sqlite3.Xsqlite3_stmt_status(tls, pStmt, 1, 1) - (*SqliteDb)(unsafe.Pointer(pDb)).FnSort = sqlite3.Xsqlite3_stmt_status(tls, pStmt, 2, 1) - (*SqliteDb)(unsafe.Pointer(pDb)).FnIndex = sqlite3.Xsqlite3_stmt_status(tls, pStmt, 3, 1) - (*SqliteDb)(unsafe.Pointer(pDb)).FnVMStep = sqlite3.Xsqlite3_stmt_status(tls, pStmt, 4, 1) + (*SqliteDb)(unsafe.Pointer(pDb)).FnStep = sqlite3.Xsqlite3_stmt_status(tls, pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, 1) + (*SqliteDb)(unsafe.Pointer(pDb)).FnSort = sqlite3.Xsqlite3_stmt_status(tls, pStmt, SQLITE_STMTSTATUS_SORT, 1) + (*SqliteDb)(unsafe.Pointer(pDb)).FnIndex = sqlite3.Xsqlite3_stmt_status(tls, pStmt, SQLITE_STMTSTATUS_AUTOINDEX, 1) + (*SqliteDb)(unsafe.Pointer(pDb)).FnVMStep = sqlite3.Xsqlite3_stmt_status(tls, pStmt, SQLITE_STMTSTATUS_VM_STEP, 1) dbReleaseColumnNames(tls, p) (*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt = uintptr(0) - if rcs != 0 { + if rcs != SQLITE_OK { // If a run-time error occurs, report the error and stop reading // the SQL. dbReleaseStmt(tls, pDb, pPreStmt, 1) - if (((*SqliteDb)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpDb)).FbLegacyPrepare != 0) && (rcs == 17)) && (zPrevSql != 0) { + if (((*SqliteDb)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpDb)).FbLegacyPrepare != 0) && (rcs == SQLITE_SCHEMA)) && (zPrevSql != 0) { // If the runtime error was an SQLITE_SCHEMA, and the database // handle is configured to use the legacy sqlite3_prepare() // interface, retry prepare()/step() on the same SQL statement. @@ -39817,7 +37146,7 @@ func dbEvalStep(tls *libc.TLS, p uintptr) int32 { /* tclsqlite.c:1646:12: */ } tcl.XTcl_SetObjResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), -1)) - return 1 + return TCL_ERROR } else { dbReleaseStmt(tls, pDb, pPreStmt, 0) } @@ -39825,7 +37154,7 @@ func dbEvalStep(tls *libc.TLS, p uintptr) int32 { /* tclsqlite.c:1646:12: */ } // Finished - return 3 + return TCL_BREAK } // Free all resources currently held by the DbEvalContext structure passed @@ -39861,7 +37190,7 @@ func dbEvalFinalize(tls *libc.TLS, p uintptr) { /* tclsqlite.c:1710:13: */ func dbEvalColumnValue(tls *libc.TLS, p uintptr, iCol int32) uintptr { /* tclsqlite.c:1729:16: */ var pStmt uintptr = (*SqlPreparedStmt)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt)).FpStmt switch sqlite3.Xsqlite3_column_type(tls, pStmt, iCol) { - case 4: + case SQLITE_BLOB: { var bytes int32 = sqlite3.Xsqlite3_column_bytes(tls, pStmt, iCol) var zBlob uintptr = sqlite3.Xsqlite3_column_blob(tls, pStmt, iCol) @@ -39871,7 +37200,7 @@ func dbEvalColumnValue(tls *libc.TLS, p uintptr, iCol int32) uintptr { /* tclsql return tcl.XTcl_NewByteArrayObj(tls, zBlob, bytes) } - case 1: + case SQLITE_INTEGER: { var v sqlite_int64 = sqlite3.Xsqlite3_column_int64(tls, pStmt, iCol) if (v >= int64(-2147483647)) && (v <= int64(2147483647)) { @@ -39882,12 +37211,12 @@ func dbEvalColumnValue(tls *libc.TLS, p uintptr, iCol int32) uintptr { /* tclsql } fallthrough - case 2: + case SQLITE_FLOAT: { return tcl.XTcl_NewDoubleObj(tls, sqlite3.Xsqlite3_column_double(tls, pStmt, iCol)) } - case 5: + case SQLITE_NULL: { return tcl.XTcl_NewStringObj(tls, (*SqliteDb)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpDb)).FzNull, -1) @@ -39927,11 +37256,11 @@ func DbEvalNextCmd(tls *libc.TLS, data uintptr, interp uintptr, result int32) in // structure allocated using Tcl_Alloc(). The second element of data[] // is a pointer to a Tcl_Obj containing the script to run for each row // returned by the queries encapsulated in data[0]. - var p uintptr = *(*ClientData)(unsafe.Pointer(data + uintptr(0)*8)) - var pScript uintptr = *(*ClientData)(unsafe.Pointer(data + uintptr(1)*8)) + var p uintptr = *(*ClientData)(unsafe.Pointer(data)) + var pScript uintptr = *(*ClientData)(unsafe.Pointer(data + 1*8)) var pArray uintptr = (*DbEvalContext)(unsafe.Pointer(p)).FpArray - for ((rc == 0) || (rc == 4)) && (0 == (libc.AssignInt32(&rc, dbEvalStep(tls, p)))) { + for ((rc == TCL_OK) || (rc == TCL_CONTINUE)) && (TCL_OK == (libc.AssignInt32(&rc, dbEvalStep(tls, p)))) { var i int32 // var nCol int32 at bp, 4 @@ -39941,8 +37270,8 @@ func DbEvalNextCmd(tls *libc.TLS, data uintptr, interp uintptr, result int32) in for i = 0; i < *(*int32)(unsafe.Pointer(bp /* nCol */)); i++ { if pArray == uintptr(0) { tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* apColName */)) + uintptr(i)*8)), uintptr(0), dbEvalColumnValue(tls, p, i), 0) - } else if (((*DbEvalContext)(unsafe.Pointer(p)).FevalFlags & 0x00001) != 0) && - (sqlite3.Xsqlite3_column_type(tls, (*SqlPreparedStmt)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt)).FpStmt, i) == 5) { + } else if (((*DbEvalContext)(unsafe.Pointer(p)).FevalFlags & SQLITE_EVAL_WITHOUTNULLS) != 0) && + (sqlite3.Xsqlite3_column_type(tls, (*SqlPreparedStmt)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt)).FpStmt, i) == SQLITE_NULL) { tcl.XTcl_UnsetVar2(tls, interp, tcl.XTcl_GetString(tls, pArray), tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* apColName */)) + uintptr(i)*8))), 0) } else { @@ -39978,9 +37307,9 @@ func DbEvalNextCmd(tls *libc.TLS, data uintptr, interp uintptr, result int32) in dbEvalFinalize(tls, p) tcl.XTcl_Free(tls, p) - if (rc == 0) || (rc == 3) { + if (rc == TCL_OK) || (rc == TCL_BREAK) { tcl.XTcl_ResetResult(tls, interp) - rc = 0 + rc = TCL_OK } return rc } @@ -40252,20 +37581,20 @@ func DbObjCmd(tls *libc.TLS, cd uintptr, interp uintptr, objc int32, objv uintpt var zArg uintptr var i5 int32 pDb = *(*uintptr)(unsafe.Pointer(bp + 1456 /* cd */)) - rc = 0 + rc = TCL_OK // don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler if !(objc < 2) { goto __1 } tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1859 /* "SUBCOMMAND ..." */) - return 1 + return TCL_ERROR __1: ; - if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), uintptr(unsafe.Pointer(&DB_strs)), int32(unsafe.Sizeof(uintptr(0))), ts+11195 /* "option" */, 0, bp+1016 /* &choice */) != 0) { + if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&DB_strs)), int32(unsafe.Sizeof(uintptr(0))), ts+11195 /* "option" */, 0, bp+1016 /* &choice */) != 0) { goto __2 } - return 1 + return TCL_ERROR __2: ; @@ -40621,7 +37950,7 @@ __4: goto __45 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11202 /* "?CALLBACK?" */) - return 1 + return TCL_ERROR goto __46 __45: if !(objc == 2) { @@ -40641,7 +37970,7 @@ __47: tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzAuth) __50: ; - zAuth = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+1020 /* &len */) + zAuth = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1020 /* &len */) if !((zAuth != 0) && (*(*int32)(unsafe.Pointer(bp + 1020 /* len */)) > 0)) { goto __51 } @@ -40681,31 +38010,31 @@ __5: goto __55 } zSrcDb = ts + 84 /* "main" */ - zDestFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zDestFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) goto __56 __55: if !(objc == 4) { goto __57 } - zSrcDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - zDestFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + zSrcDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + zDestFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) goto __58 __57: tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11213 /* "?DATABASE? FILEN..." */) - return 1 + return TCL_ERROR __58: ; __56: ; rc = sqlite3.Xsqlite3_open_v2(tls, zDestFile, bp+1024, /* &pDest */ - ((0x00000002 | 0x00000004) | (*SqliteDb)(unsafe.Pointer(pDb)).FopenFlags), uintptr(0)) - if !(rc != 0) { + ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | (*SqliteDb)(unsafe.Pointer(pDb)).FopenFlags), uintptr(0)) + if !(rc != SQLITE_OK) { goto __59 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+11233, /* "cannot open targ..." */ sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */))), uintptr(0))) sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */))) - return 1 + return TCL_ERROR __59: ; pBackup = sqlite3.Xsqlite3_backup_init(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */)), ts+84 /* "main" */, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSrcDb) @@ -40715,26 +38044,26 @@ __59: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, ts+11263, /* "backup failed: " */ sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */))), uintptr(0))) sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */))) - return 1 + return TCL_ERROR __60: ; __61: - if !((libc.AssignInt32(&rc, sqlite3.Xsqlite3_backup_step(tls, pBackup, 100))) == 0) { + if !((libc.AssignInt32(&rc, sqlite3.Xsqlite3_backup_step(tls, pBackup, 100))) == SQLITE_OK) { goto __62 } goto __61 __62: ; sqlite3.Xsqlite3_backup_finish(tls, pBackup) - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __63 } - rc = 0 + rc = TCL_OK goto __64 __63: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, ts+11263, /* "backup failed: " */ sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */))), uintptr(0))) - rc = 1 + rc = TCL_ERROR __64: ; sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */))) @@ -40762,7 +38091,7 @@ __6: goto __65 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11202 /* "?CALLBACK?" */) - return 1 + return TCL_ERROR goto __66 __65: if !(objc == 2) { @@ -40782,7 +38111,7 @@ __67: tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback) __70: ; - zCallback = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+1032 /* &len1 */) + zCallback = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1032 /* &len1 */) if !((zCallback != 0) && (*(*int32)(unsafe.Pointer(bp + 1032 /* len1 */)) > 0)) { goto __71 } @@ -40808,7 +38137,7 @@ __7: goto __73 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11279 /* "CALLBACK" */) - return 1 + return TCL_ERROR goto __74 __73: if !(objc == 2) { @@ -40828,7 +38157,7 @@ __75: tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzBusy) __78: ; - zBusy = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+1036 /* &len2 */) + zBusy = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1036 /* &len2 */) if !((zBusy != 0) && (*(*int32)(unsafe.Pointer(bp + 1036 /* len2 */)) > 0)) { goto __79 } @@ -40868,10 +38197,10 @@ __8: goto __83 } tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+11288 /* "cache option ?ar..." */) - return 1 + return TCL_ERROR __83: ; - subCmd = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), uintptr(0)) + subCmd = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0)) if !((int32(*(*int8)(unsafe.Pointer(subCmd))) == 'f') && (libc.Xstrcmp(tls, subCmd, ts+11307 /* "flush" */) == 0)) { goto __84 } @@ -40879,7 +38208,7 @@ __83: goto __86 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11307 /* "flush" */) - return 1 + return TCL_ERROR goto __87 __86: flushStmtCache(tls, pDb) @@ -40894,15 +38223,15 @@ __84: goto __90 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11318 /* "size n" */) - return 1 + return TCL_ERROR goto __91 __90: - if !(1 == tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+1040 /* &n */)) { + if !(TCL_ERROR == tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+1040 /* &n */)) { goto __92 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+120, ts+11325, /* "cannot convert \"" */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), uintptr(0)), ts+11342 /* "\" to integer" */, uintptr(0))) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), uintptr(0)), ts+11342 /* "\" to integer" */, uintptr(0))) + return TCL_ERROR goto __93 __92: if !(*(*int32)(unsafe.Pointer(bp + 1040 /* n */)) < 0) { @@ -40912,10 +38241,10 @@ __92: *(*int32)(unsafe.Pointer(bp + 1040 /* n */)) = 0 goto __95 __94: - if !(*(*int32)(unsafe.Pointer(bp + 1040 /* n */)) > 100) { + if !(*(*int32)(unsafe.Pointer(bp + 1040 /* n */)) > MAX_PREPARED_STMTS) { goto __96 } - *(*int32)(unsafe.Pointer(bp + 1040 /* n */)) = 100 + *(*int32)(unsafe.Pointer(bp + 1040 /* n */)) = MAX_PREPARED_STMTS __96: ; __95: @@ -40928,9 +38257,9 @@ __91: goto __89 __88: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+152, ts+11355, /* "bad option \"" */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), uintptr(0)), ts+11368, /* "\": must be flush..." */ + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0)), ts+11368, /* "\": must be flush..." */ uintptr(0))) - return 1 + return TCL_ERROR __89: ; __85: @@ -40947,7 +38276,7 @@ __9: goto __97 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR __97: ; pResult = tcl.XTcl_GetObjResult(tls, interp) @@ -40958,7 +38287,7 @@ __97: // // Shutdown the database __10: - tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0))) + tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0))) goto __3 // $db collate NAME SCRIPT @@ -40970,31 +38299,31 @@ __11: goto __98 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11393 /* "NAME SCRIPT" */) - return 1 + return TCL_ERROR __98: ; - zName = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), uintptr(0)) - zScript = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+1044 /* &nScript */) + zName = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0)) + zScript = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+1044 /* &nScript */) pCollate = tcl.XTcl_Alloc(tls, (uint32((uint64(unsafe.Sizeof(SqlCollate{})) + uint64(*(*int32)(unsafe.Pointer(bp + 1044 /* nScript */)))) + uint64(1)))) if !(pCollate == uintptr(0)) { goto __99 } - return 1 + return TCL_ERROR __99: ; (*SqlCollate)(unsafe.Pointer(pCollate)).Finterp = interp (*SqlCollate)(unsafe.Pointer(pCollate)).FpNext = (*SqliteDb)(unsafe.Pointer(pDb)).FpCollate - (*SqlCollate)(unsafe.Pointer(pCollate)).FzScript = (pCollate + uintptr(1)*24) + (*SqlCollate)(unsafe.Pointer(pCollate)).FzScript = (pCollate + 1*24) (*SqliteDb)(unsafe.Pointer(pDb)).FpCollate = pCollate libc.Xmemcpy(tls, (*SqlCollate)(unsafe.Pointer(pCollate)).FzScript, zScript, (uint64(*(*int32)(unsafe.Pointer(bp + 1044 /* nScript */)) + 1))) - if !(sqlite3.Xsqlite3_create_collation(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zName, 1, + if !(sqlite3.Xsqlite3_create_collation(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zName, SQLITE_UTF8, pCollate, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{tclSqlCollate}))) != 0) { goto __100 } tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(1)) - return 1 + return TCL_ERROR __100: ; goto __3 @@ -41008,7 +38337,7 @@ __12: goto __101 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11405 /* "SCRIPT" */) - return 1 + return TCL_ERROR __101: ; if !((*SqliteDb)(unsafe.Pointer(pDb)).FpCollateNeeded != 0) { @@ -41032,7 +38361,7 @@ __105: ; __102: ; - (*SqliteDb)(unsafe.Pointer(pDb)).FpCollateNeeded = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + (*SqliteDb)(unsafe.Pointer(pDb)).FpCollateNeeded = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) (*Tcl_Obj)(unsafe.Pointer((*SqliteDb)(unsafe.Pointer(pDb)).FpCollateNeeded)).FrefCount++ sqlite3.Xsqlite3_collation_needed(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, pDb, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, uintptr) @@ -41050,7 +38379,7 @@ __13: goto __107 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11202 /* "?CALLBACK?" */) - return 1 + return TCL_ERROR goto __108 __107: if !(objc == 2) { @@ -41070,7 +38399,7 @@ __109: tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzCommit) __112: ; - zCommit = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+1048 /* &len3 */) + zCommit = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1048 /* &len3 */) if !((zCommit != 0) && (*(*int32)(unsafe.Pointer(bp + 1048 /* len3 */)) > 0)) { goto __113 } @@ -41109,10 +38438,10 @@ __14: goto __117 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+9992 /* "SQL" */) - return 1 + return TCL_ERROR __117: ; - isComplete = sqlite3.Xsqlite3_complete(tls, tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), uintptr(0))) + isComplete = sqlite3.Xsqlite3_complete(tls, tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0))) pResult1 = tcl.XTcl_GetObjResult(tls, interp) tcl.XTcl_SetIntObj(tls, pResult1, (libc.Bool32((isComplete) != 0))) goto __3 @@ -41126,7 +38455,7 @@ __15: goto __118 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11412 /* "?OPTION? ?BOOLEA..." */) - return 1 + return TCL_ERROR __118: ; if !(objc == 2) { @@ -41155,10 +38484,10 @@ __123: ; goto __120 __119: - zOpt = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zOpt = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) *(*int32)(unsafe.Pointer(bp + 1056 /* onoff */)) = -1 *(*int32)(unsafe.Pointer(bp + 1060 /* v1 */)) = 0 - if !(int32(*(*int8)(unsafe.Pointer(zOpt + uintptr(0)))) == '-') { + if !(int32(*(*int8)(unsafe.Pointer(zOpt))) == '-') { goto __124 } zOpt++ @@ -41187,16 +38516,16 @@ __127: } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+216, ts+11431 /* "unknown config o..." */, zOpt, ts+11456 /* "\"" */, uintptr(0))) - return 1 + return TCL_ERROR __129: ; if !(objc == 4) { goto __130 } - if !(tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+1056 /* &onoff */) != 0) { + if !(tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+1056 /* &onoff */) != 0) { goto __131 } - return 1 + return TCL_ERROR __131: ; __130: @@ -41231,13 +38560,13 @@ __16: // The input file } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11458 /* "CONFLICT-ALGORIT..." */) - return 1 + return TCL_ERROR __132: ; if !(objc >= 6) { goto __133 } - zSep = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(5)*8)), uintptr(0)) + zSep = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 5*8)), uintptr(0)) goto __134 __133: zSep = ts + 11520 /* "\t" */ @@ -41246,15 +38575,15 @@ __134: if !(objc >= 7) { goto __135 } - zNull = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(6)*8)), uintptr(0)) + zNull = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 6*8)), uintptr(0)) goto __136 __135: zNull = ts + 488 /* "" */ __136: ; - zConflict = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), uintptr(0)) - zTable = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), uintptr(0)) - zFile = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), uintptr(0)) + zConflict = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0)) + zTable = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), uintptr(0)) + zFile = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8)), uintptr(0)) nSep = strlen30(tls, zSep) nNull = strlen30(tls, zNull) if !(nSep == 0) { @@ -41262,7 +38591,7 @@ __136: } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+264, ts+11522, /* "Error: non-null ..." */ uintptr(0))) - return 1 + return TCL_ERROR __137: ; if !(((((libc.Xstrcmp(tls, zConflict, ts+11566 /* "rollback" */) != 0) && (libc.Xstrcmp(tls, zConflict, ts+11575 /* "abort" */) != 0)) && (libc.Xstrcmp(tls, zConflict, ts+11581 /* "fail" */) != 0)) && (libc.Xstrcmp(tls, zConflict, ts+11586 /* "ignore" */) != 0)) && (libc.Xstrcmp(tls, zConflict, ts+11593 /* "replace" */) != 0)) { @@ -41271,7 +38600,7 @@ __137: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+280, ts+11601 /* "Error: \"" */, zConflict, ts+11610 /* "\", conflict-algo..." */, uintptr(0))) - return 1 + return TCL_ERROR __138: ; zSql = sqlite3.Xsqlite3_mprintf(tls, ts+11690 /* "SELECT * FROM '%..." */, libc.VaList(bp+312, zTable)) @@ -41279,7 +38608,7 @@ __138: goto __139 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+320, ts+11709 /* "Error: no such t..." */, zTable, uintptr(0))) - return 1 + return TCL_ERROR __139: ; nByte = strlen30(tls, zSql) @@ -41299,7 +38628,7 @@ __141: if !(nCol == 0) { goto __142 } - return 1 + return TCL_ERROR __142: ; zSql = libc.Xmalloc(tls, (uint64((nByte + 50) + (nCol * 2)))) @@ -41307,7 +38636,7 @@ __142: goto __143 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+368, ts+11740 /* "Error: can't mal..." */, uintptr(0))) - return 1 + return TCL_ERROR __143: ; sqlite3.Xsqlite3_snprintf(tls, (nByte + 50), zSql, ts+11762, /* "INSERT OR %q INT..." */ @@ -41336,7 +38665,7 @@ __146: } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+400, ts+11732 /* "Error: " */, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */))) - return 1 + return TCL_ERROR __147: ; in = libc.Xfopen(tls, zFile, ts+4086 /* "rb" */) @@ -41345,7 +38674,7 @@ __147: } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+424, ts+11794 /* "Error: cannot op..." */, zFile, uintptr(0))) sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */))) - return 1 + return TCL_ERROR __148: ; azCol = libc.Xmalloc(tls, (uint64(unsafe.Sizeof(uintptr(0))) * (uint64(nCol + 1)))) @@ -41354,7 +38683,7 @@ __148: } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+448, ts+11740 /* "Error: can't mal..." */, uintptr(0))) libc.Xfclose(tls, in) - return 1 + return TCL_ERROR __149: ; sqlite3.Xsqlite3_exec(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, ts+11820 /* "BEGIN" */, uintptr(0), uintptr(0), uintptr(0)) @@ -41364,14 +38693,14 @@ __150: goto __151 } lineno++ - *(*uintptr)(unsafe.Pointer(azCol + uintptr(0)*8)) = zLine + *(*uintptr)(unsafe.Pointer(azCol)) = zLine i = 0 z = zLine __152: if !(*(*int8)(unsafe.Pointer(z)) != 0) { goto __154 } - if !((int32(*(*int8)(unsafe.Pointer(z))) == int32(*(*int8)(unsafe.Pointer(zSep + uintptr(0))))) && (libc.Xstrncmp(tls, z, zSep, uint64(nSep)) == 0)) { + if !((int32(*(*int8)(unsafe.Pointer(z))) == int32(*(*int8)(unsafe.Pointer(zSep)))) && (libc.Xstrncmp(tls, z, zSep, uint64(nSep)) == 0)) { goto __155 } *(*int8)(unsafe.Pointer(z)) = int8(0) @@ -41437,7 +38766,7 @@ __161: sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */))) rc = sqlite3.Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */))) libc.Xfree(tls, zLine) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __164 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+512, ts+11732 /* "Error: " */, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) @@ -41453,20 +38782,20 @@ __151: sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */))) sqlite3.Xsqlite3_exec(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zCommit1, uintptr(0), uintptr(0), uintptr(0)) - if !(int32(*(*int8)(unsafe.Pointer(zCommit1 + uintptr(0)))) == 'C') { + if !(int32(*(*int8)(unsafe.Pointer(zCommit1))) == 'C') { goto __165 } // success, set result as number of lines processed pResult3 = tcl.XTcl_GetObjResult(tls, interp) tcl.XTcl_SetIntObj(tls, pResult3, lineno) - rc = 0 + rc = TCL_OK goto __166 __165: // failure, append lineno where failed sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([80]int8{})), bp+1072 /* &zLineNum[0] */, ts+1237 /* "%d" */, libc.VaList(bp+536, lineno)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+544, ts+11886 /* ", failed while p..." */, bp+1072, /* &zLineNum[0] */ uintptr(0))) - rc = 1 + rc = TCL_ERROR __166: ; goto __3 @@ -41484,7 +38813,7 @@ __17: goto __167 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11919 /* "?DATABASE? VALUE" */) - rc = 1 + rc = TCL_ERROR goto __3 __167: ; @@ -41520,7 +38849,7 @@ __174: goto __169 __173: ; - if !(((zSchema == uintptr(0)) && (i1 == (objc - 2))) && (int32(*(*int8)(unsafe.Pointer(z1 + uintptr(0)))) != '-')) { + if !(((zSchema == uintptr(0)) && (i1 == (objc - 2))) && (int32(*(*int8)(unsafe.Pointer(z1))) != '-')) { goto __175 } zSchema = z1 @@ -41528,7 +38857,7 @@ __173: __175: ; tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+568, ts+11955 /* "unknown option: " */, z1, uintptr(0))) - rc = 1 + rc = TCL_ERROR goto deserialize_error goto __169 __169: @@ -41544,7 +38873,7 @@ __170: goto __176 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+592, ts+1929 /* "out of memory" */, uintptr(0))) - rc = 1 + rc = TCL_ERROR goto __177 __176: if !(*(*int32)(unsafe.Pointer(bp + 1164 /* len4 */)) > 0) { @@ -41556,10 +38885,10 @@ __178: if !(*(*int32)(unsafe.Pointer(bp + 1160 /* isReadonly */)) != 0) { goto __179 } - flags = (1 | 4) + flags = (SQLITE_DESERIALIZE_FREEONCLOSE | SQLITE_DESERIALIZE_READONLY) goto __180 __179: - flags = (1 | 2) + flags = (SQLITE_DESERIALIZE_FREEONCLOSE | SQLITE_DESERIALIZE_RESIZEABLE) __180: ; 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)) @@ -41567,13 +38896,13 @@ __180: goto __181 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+608, ts+11972 /* "unable to set ME..." */, uintptr(0))) - rc = 1 + rc = TCL_ERROR __181: ; if !(*(*sqlite3_int64)(unsafe.Pointer(bp + 1152 /* mxSize */)) > int64(0)) { goto __182 } - sqlite3.Xsqlite3_file_control(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSchema, 36, bp+1152 /* &mxSize */) + sqlite3.Xsqlite3_file_control(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSchema, SQLITE_FCNTL_SIZE_LIMIT, bp+1152 /* &mxSize */) __182: ; __177: @@ -41588,7 +38917,7 @@ deserialize_error: __18: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+624, ts+12000, /* "extension loadin..." */ uintptr(0))) - return 1 + return TCL_ERROR // $db errorcode // @@ -41610,22 +38939,22 @@ __21: goto __183 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+9992 /* "SQL" */) - return 1 + return TCL_ERROR __183: ; - dbEvalInit(tls, bp+1168 /* &sEval */, pDb, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), uintptr(0), 0) + dbEvalInit(tls, bp+1168 /* &sEval */, pDb, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0), 0) rc = dbEvalStep(tls, bp+1168 /* &sEval */) if !(*(*int32)(unsafe.Pointer(bp + 1016 /* choice */)) == 23 /* DB_ONECOLUMN */) { goto __184 } - if !(rc == 0) { + if !(rc == TCL_OK) { goto __186 } pResult4 = dbEvalColumnValue(tls, bp+1168 /* &sEval */, 0) goto __187 __186: - if !(rc == 3) { + if !(rc == TCL_BREAK) { goto __188 } tcl.XTcl_ResetResult(tls, interp) @@ -41635,10 +38964,10 @@ __187: ; goto __185 __184: - if !((rc == 3) || (rc == 0)) { + if !((rc == TCL_BREAK) || (rc == TCL_OK)) { goto __189 } - pResult4 = tcl.XTcl_NewIntObj(tls, (libc.Bool32((libc.Bool32(rc == 0)) != 0))) + pResult4 = tcl.XTcl_NewIntObj(tls, (libc.Bool32((libc.Bool32(rc == TCL_OK)) != 0))) __189: ; __185: @@ -41651,10 +38980,10 @@ __185: __190: ; - if !(rc == 3) { + if !(rc == TCL_BREAK) { goto __191 } - rc = 0 + rc = TCL_OK __191: ; goto __3 @@ -41669,17 +38998,17 @@ __191: __22: evalFlags = 0 __192: - if !(((objc > 3) && ((libc.AssignUintptr(&zOpt1, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))))) != uintptr(0))) && (int32(*(*int8)(unsafe.Pointer(zOpt1 + uintptr(0)))) == '-')) { + if !(((objc > 3) && ((libc.AssignUintptr(&zOpt1, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))))) != uintptr(0))) && (int32(*(*int8)(unsafe.Pointer(zOpt1))) == '-')) { goto __193 } if !(libc.Xstrcmp(tls, zOpt1, ts+12048 /* "-withoutnulls" */) == 0) { goto __194 } - evalFlags = evalFlags | (0x00001) + evalFlags = evalFlags | (SQLITE_EVAL_WITHOUTNULLS) goto __195 __194: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+640, ts+12062 /* "unknown option: ..." */, zOpt1, ts+11456 /* "\"" */, uintptr(0))) - return 1 + return TCL_ERROR __195: ; objc-- @@ -41692,7 +39021,7 @@ __193: } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12080 /* "?OPTIONS? SQL ?A..." */) - return 1 + return TCL_ERROR __196: ; @@ -41701,9 +39030,9 @@ __196: } pRet = tcl.XTcl_NewObj(tls) (*Tcl_Obj)(unsafe.Pointer(pRet)).FrefCount++ - dbEvalInit(tls, bp+1224 /* &sEval1 */, pDb, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), uintptr(0), 0) + dbEvalInit(tls, bp+1224 /* &sEval1 */, pDb, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0), 0) __199: - if !(0 == (libc.AssignInt32(&rc, dbEvalStep(tls, bp+1224 /* &sEval1 */)))) { + if !(TCL_OK == (libc.AssignInt32(&rc, dbEvalStep(tls, bp+1224 /* &sEval1 */)))) { goto __200 } dbEvalRowInfo(tls, bp+1224 /* &sEval1 */, bp+1280 /* &nCol1 */, uintptr(0)) @@ -41724,11 +39053,11 @@ __203: __200: ; dbEvalFinalize(tls, bp+1224 /* &sEval1 */) - if !(rc == 3) { + if !(rc == TCL_BREAK) { goto __204 } tcl.XTcl_SetObjResult(tls, interp, pRet) - rc = 0 + rc = TCL_OK __204: ; __205: @@ -41751,21 +39080,21 @@ __207: __197: pArray = uintptr(0) - if !((objc >= 5) && (*(*int8)(unsafe.Pointer(tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))))) != 0)) { + if !((objc >= 5) && (*(*int8)(unsafe.Pointer(tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))))) != 0)) { goto __209 } - pArray = *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)) + pArray = *(*uintptr)(unsafe.Pointer(objv + 3*8)) __209: ; pScript = *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)) (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ p = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(DbEvalContext{}))) - dbEvalInit(tls, p, pDb, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), pArray, evalFlags) + dbEvalInit(tls, p, pDb, *(*uintptr)(unsafe.Pointer(objv + 2*8)), pArray, evalFlags) - *(*ClientData)(unsafe.Pointer(bp + 1288 /* &cd2[0] */ + uintptr(0)*8)) = p - *(*ClientData)(unsafe.Pointer(bp + 1288 /* &cd2[0] */ + uintptr(1)*8)) = pScript - rc = DbEvalNextCmd(tls, bp+1288 /* &cd2[0] */, interp, 0) + *(*ClientData)(unsafe.Pointer(bp + 1288 /* &cd2[0] */)) = p + *(*ClientData)(unsafe.Pointer(bp + 1288 /* &cd2[0] */ + 1*8)) = pScript + rc = DbEvalNextCmd(tls, bp+1288 /* &cd2[0] */, interp, TCL_OK) __198: ; goto __3 @@ -41782,14 +39111,14 @@ __198: // --innocuous Has no side effects or information leaks // --returntype TYPE Specify the return type of the function __23: - flags1 = 1 + flags1 = SQLITE_UTF8 *(*int32)(unsafe.Pointer(bp + 1304 /* nArg */)) = -1 - *(*int32)(unsafe.Pointer(bp + 1360 /* eType */)) = 5 + *(*int32)(unsafe.Pointer(bp + 1360 /* eType */)) = SQLITE_NULL if !(objc < 4) { goto __210 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12116 /* "NAME ?SWITCHES? ..." */) - return 1 + return TCL_ERROR __210: ; i3 = 3 @@ -41806,13 +39135,13 @@ __211: goto __216 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+672, ts+12149 /* "option requires ..." */, z2, uintptr(0))) - return 1 + return TCL_ERROR __216: ; if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i3+1))*8)), bp+1304 /* &nArg */) != 0) { goto __217 } - return 1 + return TCL_ERROR __217: ; if !(*(*int32)(unsafe.Pointer(bp + 1304 /* nArg */)) < 0) { @@ -41820,7 +39149,7 @@ __217: } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+696, ts+12179, /* "number of argume..." */ uintptr(0))) - return 1 + return TCL_ERROR __218: ; i3++ @@ -41829,19 +39158,19 @@ __214: if !((n1 > 1) && (libc.Xstrncmp(tls, z2, ts+12220 /* "-deterministic" */, uint64(n1)) == 0)) { goto __219 } - flags1 = flags1 | (0x000000800) + flags1 = flags1 | (SQLITE_DETERMINISTIC) goto __220 __219: if !((n1 > 1) && (libc.Xstrncmp(tls, z2, ts+12235 /* "-directonly" */, uint64(n1)) == 0)) { goto __221 } - flags1 = flags1 | (0x000080000) + flags1 = flags1 | (SQLITE_DIRECTONLY) goto __222 __221: if !((n1 > 1) && (libc.Xstrncmp(tls, z2, ts+12247 /* "-innocuous" */, uint64(n1)) == 0)) { goto __223 } - flags1 = flags1 | (0x000200000) + flags1 = flags1 | (SQLITE_INNOCUOUS) goto __224 __223: if !((n1 > 1) && (libc.Xstrncmp(tls, z2, ts+12258 /* "-returntype" */, uint64(n1)) == 0)) { @@ -41853,14 +39182,14 @@ __223: goto __227 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+712, ts+12149 /* "option requires ..." */, z2, uintptr(0))) - return 1 + return TCL_ERROR __227: ; i3++ if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i3)*8)), bp+1312 /* &azType[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+12289 /* "type" */, 0, bp+1360 /* &eType */) != 0) { goto __228 } - return 1 + return TCL_ERROR __228: ; *(*int32)(unsafe.Pointer(bp + 1360 /* eType */))++ @@ -41869,7 +39198,7 @@ __225: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+736, ts+11355 /* "bad option \"" */, z2, ts+12294 /* "\": must be -argc..." */, uintptr(0))) - return 1 + return TCL_ERROR __226: ; __224: @@ -41889,12 +39218,12 @@ __213: ; pScript1 = *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)) - zName1 = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), uintptr(0)) + zName1 = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0)) pFunc = findSqlFunc(tls, pDb, zName1) if !(pFunc == uintptr(0)) { goto __229 } - return 1 + return TCL_ERROR __229: ; if !((*SqlFunc)(unsafe.Pointer(pFunc)).FpScript != 0) { @@ -41926,10 +39255,10 @@ __230: pFunc, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tclSqlFunc})), uintptr(0), uintptr(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __235 } - rc = 1 + rc = TCL_ERROR tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(1)) __235: ; @@ -41941,7 +39270,7 @@ __24: zDb = ts + 84 /* "main" */ // Check for the -readonly option - if !((objc > 3) && (libc.Xstrcmp(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), ts+11945 /* "-readonly" */) == 0)) { + if !((objc > 3) && (libc.Xstrcmp(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), ts+11945 /* "-readonly" */) == 0)) { goto __236 } isReadonly1 = 1 @@ -41952,21 +39281,21 @@ __236: goto __237 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12372 /* "?-readonly? ?DB?..." */) - return 1 + return TCL_ERROR __237: ; if !(objc == (6 + isReadonly1)) { goto __238 } - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) __238: ; zTable1 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-3))*8))) zColumn = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-2))*8))) rc = tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)), bp+1368 /* &iRow */) - if !(rc == 0) { + if !(rc == TCL_OK) { goto __239 } rc = createIncrblobChannel(tls, @@ -41994,13 +39323,13 @@ __26: goto __240 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12408 /* "NULLVALUE" */) - return 1 + return TCL_ERROR __240: ; if !(objc == 3) { goto __241 } - zNull1 = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+1376 /* &len5 */) + zNull1 = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1376 /* &len5 */) if !((*SqliteDb)(unsafe.Pointer(pDb)).FzNull != 0) { goto __242 } @@ -42031,7 +39360,7 @@ __27: goto __245 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR __245: ; rowid = sqlite3.Xsqlite3_last_insert_rowid(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb) @@ -42060,10 +39389,10 @@ __246: if !(objc == 4) { goto __249 } - if !(0 != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+1380 /* &N */)) { + if !(TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1380 /* &N */)) { goto __251 } - return 1 + return TCL_ERROR __251: ; @@ -42073,7 +39402,7 @@ __251: tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzProgress) __252: ; - zProgress = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+1384 /* &len6 */) + zProgress = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+1384 /* &len6 */) if !((zProgress != 0) && (*(*int32)(unsafe.Pointer(bp + 1384 /* len6 */)) > 0)) { goto __253 } @@ -42099,7 +39428,7 @@ __256: goto __250 __249: tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12418 /* "N CALLBACK" */) - return 1 + return TCL_ERROR __250: ; __247: @@ -42116,7 +39445,7 @@ __29: goto __257 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11202 /* "?CALLBACK?" */) - return 1 + return TCL_ERROR goto __258 __257: if !(objc == 2) { @@ -42136,7 +39465,7 @@ __259: tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzProfile) __262: ; - zProfile = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+1388 /* &len7 */) + zProfile = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1388 /* &len7 */) if !((zProfile != 0) && (*(*int32)(unsafe.Pointer(bp + 1388 /* len7 */)) > 0)) { goto __263 } @@ -42173,7 +39502,7 @@ __30: goto __267 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12429 /* "KEY" */) - return 1 + return TCL_ERROR __267: ; goto __3 @@ -42189,31 +39518,31 @@ __31: goto __268 } zDestDb = ts + 84 /* "main" */ - zSrcFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zSrcFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) goto __269 __268: if !(objc == 4) { goto __270 } - zDestDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - zSrcFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + zDestDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + zSrcFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) goto __271 __270: tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11213 /* "?DATABASE? FILEN..." */) - return 1 + return TCL_ERROR __271: ; __269: ; rc = sqlite3.Xsqlite3_open_v2(tls, zSrcFile, bp+1392, /* &pSrc */ - (0x00000001 | (*SqliteDb)(unsafe.Pointer(pDb)).FopenFlags), uintptr(0)) - if !(rc != 0) { + (SQLITE_OPEN_READONLY | (*SqliteDb)(unsafe.Pointer(pDb)).FopenFlags), uintptr(0)) + if !(rc != SQLITE_OK) { goto __272 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+800, ts+12433, /* "cannot open sour..." */ sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 1392 /* pSrc */))), uintptr(0))) sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 1392 /* pSrc */))) - return 1 + return TCL_ERROR __272: ; pBackup1 = sqlite3.Xsqlite3_backup_init(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zDestDb, *(*uintptr)(unsafe.Pointer(bp + 1392 /* pSrc */)), ts+84 /* "main" */) @@ -42223,15 +39552,15 @@ __272: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+824, ts+12463, /* "restore failed: " */ sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 1392 /* pSrc */))) - return 1 + return TCL_ERROR __273: ; __274: - if !(((libc.AssignInt32(&rc, sqlite3.Xsqlite3_backup_step(tls, pBackup1, 100))) == 0) || - (rc == 5)) { + if !(((libc.AssignInt32(&rc, sqlite3.Xsqlite3_backup_step(tls, pBackup1, 100))) == SQLITE_OK) || + (rc == SQLITE_BUSY)) { goto __275 } - if !(rc == 5) { + if !(rc == SQLITE_BUSY) { goto __276 } if !(libc.PostIncInt32(&nTimeout, 1) >= 3) { @@ -42247,23 +39576,23 @@ __276: __275: ; sqlite3.Xsqlite3_backup_finish(tls, pBackup1) - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __278 } - rc = 0 + rc = TCL_OK goto __279 __278: - if !((rc == 5) || (rc == 6)) { + if !((rc == SQLITE_BUSY) || (rc == SQLITE_LOCKED)) { goto __280 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+848, ts+12480, /* "restore failed: ..." */ uintptr(0))) - rc = 1 + rc = TCL_ERROR goto __281 __280: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+864, ts+12463, /* "restore failed: " */ sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) - rc = 1 + rc = TCL_ERROR __281: ; __279: @@ -42276,7 +39605,7 @@ __279: // Return a serialization of a database. __32: if objc >= 3 { - zSchema1 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zSchema1 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) } else { zSchema1 = ts + 84 /* "main" */ } @@ -42285,10 +39614,10 @@ __32: goto __282 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12517 /* "?DATABASE?" */) - rc = 1 + rc = TCL_ERROR goto __283 __282: - pData1 = sqlite3.Xsqlite3_serialize(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSchema1, bp+1400 /* &sz */, uint32(0x001)) + pData1 = sqlite3.Xsqlite3_serialize(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSchema1, bp+1400 /* &sz */, SQLITE_SERIALIZE_NOCOPY) if !(pData1 != 0) { goto __284 } @@ -42319,10 +39648,10 @@ __33: goto __287 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12528 /* "(step|sort|autoi..." */) - return 1 + return TCL_ERROR __287: ; - zOp = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zOp = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if !(libc.Xstrcmp(tls, zOp, ts+9942 /* "step" */) == 0) { goto __288 } @@ -42350,7 +39679,7 @@ __294: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+888, ts+12572, /* "bad argument: sh..." */ uintptr(0))) - return 1 + return TCL_ERROR __295: ; __293: @@ -42370,13 +39699,13 @@ __34: goto __296 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12628 /* "MILLISECONDS" */) - return 1 + return TCL_ERROR __296: ; - if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+1408 /* &ms */) != 0) { + if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1408 /* &ms */) != 0) { goto __297 } - return 1 + return TCL_ERROR __297: ; sqlite3.Xsqlite3_busy_timeout(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, *(*int32)(unsafe.Pointer(bp + 1408 /* ms */))) @@ -42391,7 +39720,7 @@ __35: goto __298 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR __298: ; pResult6 = tcl.XTcl_GetObjResult(tls, interp) @@ -42408,7 +39737,7 @@ __36: goto __299 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11202 /* "?CALLBACK?" */) - return 1 + return TCL_ERROR goto __300 __299: if !(objc == 2) { @@ -42428,7 +39757,7 @@ __301: tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzTrace) __304: ; - zTrace = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+1412 /* &len8 */) + zTrace = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1412 /* &len8 */) if !((zTrace != 0) && (*(*int32)(unsafe.Pointer(bp + 1412 /* len8 */)) > 0)) { goto __305 } @@ -42467,7 +39796,7 @@ __37: goto __309 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12641 /* "?CALLBACK? ?MASK..." */) - return 1 + return TCL_ERROR goto __310 __309: if !(objc == 2) { @@ -42485,10 +39814,10 @@ __311: if !(objc == 4) { goto __314 } - if !(0 != tcl.XTcl_ListObjLength(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+1416 /* &len9 */)) { + if !(TCL_OK != tcl.XTcl_ListObjLength(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+1416 /* &len9 */)) { goto __316 } - return 1 + return TCL_ERROR __316: ; i4 = 0 @@ -42496,18 +39825,18 @@ __317: if !(i4 < *(*int32)(unsafe.Pointer(bp + 1416 /* len9 */))) { goto __319 } - if !(0 != tcl.XTcl_ListObjIndex(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), i4, bp+1424 /* &pObj */)) { + if !(TCL_OK != tcl.XTcl_ListObjIndex(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), i4, bp+1424 /* &pObj */)) { goto __320 } - return 1 + return TCL_ERROR __320: ; - if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 1424 /* pObj */)), uintptr(unsafe.Pointer(&TTYPE_strs)), int32(unsafe.Sizeof(uintptr(0))), ts+12659 /* "trace type" */, 0, bp+1432 /* &ttype */) != 0) { + if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 1424 /* pObj */)), uintptr(unsafe.Pointer(&TTYPE_strs)), int32(unsafe.Sizeof(uintptr(0))), ts+12659 /* "trace type" */, 0, bp+1432 /* &ttype */) != TCL_OK) { goto __321 } pError = tcl.XTcl_DuplicateObj(tls, tcl.XTcl_GetObjResult(tls, interp)) (*Tcl_Obj)(unsafe.Pointer(pError)).FrefCount++ - if !(0 == tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 1424 /* pObj */)), bp+1440 /* &wType */)) { + if !(TCL_OK == tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 1424 /* pObj */)), bp+1440 /* &wType */)) { goto __323 } __325: @@ -42546,7 +39875,7 @@ __330: goto __331 __331: ; - return 1 + return TCL_ERROR __324: ; goto __322 @@ -42563,16 +39892,16 @@ __321: } goto __333 __334: - wMask = wMask | (int64(0x01)) + wMask = wMask | (SQLITE_TRACE_STMT) goto __333 __335: - wMask = wMask | (int64(0x02)) + wMask = wMask | (SQLITE_TRACE_PROFILE) goto __333 __336: - wMask = wMask | (int64(0x04)) + wMask = wMask | (SQLITE_TRACE_ROW) goto __333 __337: - wMask = wMask | (int64(0x08)) + wMask = wMask | (SQLITE_TRACE_CLOSE) goto __333 __333: ; @@ -42587,7 +39916,7 @@ __319: ; goto __315 __314: - wMask = int64(0x01) // use the "legacy" default + wMask = SQLITE_TRACE_STMT // use the "legacy" default __315: ; if !((*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2 != 0) { @@ -42596,7 +39925,7 @@ __315: tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2) __338: ; - zTraceV2 = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+1416 /* &len9 */) + zTraceV2 = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1416 /* &len9 */) if !((zTraceV2 != 0) && (*(*int32)(unsafe.Pointer(bp + 1416 /* len9 */)) > 0)) { goto __339 } @@ -42641,17 +39970,17 @@ __38: goto __343 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12697 /* "[TYPE] SCRIPT" */) - return 1 + return TCL_ERROR __343: ; if !(((*SqliteDb)(unsafe.Pointer(pDb)).FnTransaction == 0) && (objc == 4)) { goto __344 } - if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), uintptr(unsafe.Pointer(&TTYPE_strs1)), int32(unsafe.Sizeof(uintptr(0))), ts+12711 /* "transaction type" */, 0, bp+1448 /* &ttype1 */) != 0) { + if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&TTYPE_strs1)), int32(unsafe.Sizeof(uintptr(0))), ts+12711 /* "transaction type" */, 0, bp+1448 /* &ttype1 */) != 0) { goto __345 } - return 1 + return TCL_ERROR __345: ; switch uint32(*(*int32)(unsafe.Pointer(bp + 1448 /* ttype1 */))) { @@ -42682,11 +40011,11 @@ __344: (*SqliteDb)(unsafe.Pointer(pDb)).FdisableAuth++ rc = sqlite3.Xsqlite3_exec(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zBegin, uintptr(0), uintptr(0), uintptr(0)) (*SqliteDb)(unsafe.Pointer(pDb)).FdisableAuth-- - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __350 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+936, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) - return 1 + return TCL_ERROR __350: ; (*SqliteDb)(unsafe.Pointer(pDb)).FnTransaction++ @@ -42716,7 +40045,7 @@ __39: goto __353 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12760 /* "?SCRIPT?" */) - rc = 1 + rc = TCL_ERROR goto __354 __353: xNotify = uintptr(0) @@ -42752,7 +40081,7 @@ __355: f func(*libc.TLS, uintptr, int32) }{DbUnlockNotify})) pNotifyArg = pDb - (*SqliteDb)(unsafe.Pointer(pDb)).FpUnlockNotify = *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)) + (*SqliteDb)(unsafe.Pointer(pDb)).FpUnlockNotify = *(*uintptr)(unsafe.Pointer(objv + 2*8)) (*Tcl_Obj)(unsafe.Pointer((*SqliteDb)(unsafe.Pointer(pDb)).FpUnlockNotify)).FrefCount++ __360: ; @@ -42761,7 +40090,7 @@ __360: goto __361 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+952, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) - rc = 1 + rc = TCL_ERROR __361: ; __354: @@ -42780,10 +40109,10 @@ __40: tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12769 /* "SUB-COMMAND ?ARG..." */) __362: ; - if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), uintptr(unsafe.Pointer(&azSub)), int32(unsafe.Sizeof(uintptr(0))), ts+1874 /* "sub-command" */, 0, bp+1464 /* &iSub */) != 0) { + if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&azSub)), int32(unsafe.Sizeof(uintptr(0))), ts+1874 /* "sub-command" */, 0, bp+1464 /* &iSub */) != 0) { goto __363 } - return 1 + return TCL_ERROR __363: ; @@ -42813,12 +40142,12 @@ __366: goto __370 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12788 /* "hook ?SCRIPT?" */) - return 1 + return TCL_ERROR __370: ; DbHookCmd(tls, interp, pDb, func() uintptr { if objc == 4 { - return *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)) + return *(*uintptr)(unsafe.Pointer(objv + 3*8)) } return uintptr(0) }(), (pDb + 112 /* &.pPreUpdateHook */)) @@ -42829,7 +40158,7 @@ __367: goto __371 } tcl.XTcl_WrongNumArgs(tls, interp, 3, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR __371: ; pRet1 = tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_preupdate_depth(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb)) @@ -42842,13 +40171,13 @@ __369: goto __372 } tcl.XTcl_WrongNumArgs(tls, interp, 3, objv, ts+12802 /* "INDEX" */) - return 1 + return TCL_ERROR __372: ; - if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+1468 /* &iIdx */) != 0) { + if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+1468 /* &iIdx */) != 0) { goto __373 } - return 1 + return TCL_ERROR __373: ; @@ -42863,7 +40192,7 @@ __374: __375: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __376 } pObj1 = tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(bp + 1472 /* pValue1 */))), -1) @@ -42871,7 +40200,7 @@ __375: goto __377 __376: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+968, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) - return 1 + return TCL_ERROR __377: ; @@ -42910,13 +40239,13 @@ __380: goto __381 } tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12760 /* "?SCRIPT?" */) - return 1 + return TCL_ERROR __381: ; DbHookCmd(tls, interp, pDb, func() uintptr { if objc == 3 { - return *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)) + return *(*uintptr)(unsafe.Pointer(objv + 2*8)) } return uintptr(0) }(), ppHook) @@ -42943,7 +40272,7 @@ __382: if !(tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i5)*8)), (pDb+224 /* &.bLegacyPrepare */)) != 0) { goto __387 } - return 1 + return TCL_ERROR __387: ; goto __386 @@ -42968,7 +40297,7 @@ __385: __388: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+992, ts+12846 /* "unknown argument..." */, zArg, uintptr(0))) - return 1 + return TCL_ERROR __389: ; __386: @@ -43016,54 +40345,22 @@ var DB_strs = [42]uintptr{ ts + 13220 /* "version" */, ts + 13228 /* "wal_hook" */, uintptr(0), } /* tclsqlite.c:1916:21 */ var aDbConfig = [16]DbConfigChoices{ - { - FzName: ts + 13237, /* "defensive" */ - Fop: 1010}, - { - FzName: ts + 13247, /* "dqs_ddl" */ - Fop: 1014}, - { - FzName: ts + 13255, /* "dqs_dml" */ - Fop: 1013}, - { - FzName: ts + 13263, /* "enable_fkey" */ - Fop: 1002}, - { - FzName: ts + 13275, /* "enable_qpsg" */ - Fop: 1007}, - { - FzName: ts + 13287, /* "enable_trigger" */ - Fop: 1003}, - { - FzName: ts + 13302, /* "enable_view" */ - Fop: 1015}, - { - FzName: ts + 13314, /* "fts3_tokenizer" */ - Fop: 1004}, - { - FzName: ts + 13329, /* "legacy_alter_tab..." */ - Fop: 1012}, - { - FzName: ts + 13348, /* "legacy_file_form..." */ - Fop: 1016}, - { - FzName: ts + 13367, /* "load_extension" */ - Fop: 1005}, - { - FzName: ts + 13382, /* "no_ckpt_on_close" */ - Fop: 1006}, - { - FzName: ts + 13399, /* "reset_database" */ - Fop: 1009}, - { - FzName: ts + 13414, /* "trigger_eqp" */ - Fop: 1008}, - { - FzName: ts + 13426, /* "trusted_schema" */ - Fop: 1017}, - { - FzName: ts + 13441, /* "writable_schema" */ - Fop: 1011}, + {FzName: ts + 13237 /* "defensive" */, Fop: SQLITE_DBCONFIG_DEFENSIVE}, + {FzName: ts + 13247 /* "dqs_ddl" */, Fop: SQLITE_DBCONFIG_DQS_DDL}, + {FzName: ts + 13255 /* "dqs_dml" */, Fop: SQLITE_DBCONFIG_DQS_DML}, + {FzName: ts + 13263 /* "enable_fkey" */, Fop: SQLITE_DBCONFIG_ENABLE_FKEY}, + {FzName: ts + 13275 /* "enable_qpsg" */, Fop: SQLITE_DBCONFIG_ENABLE_QPSG}, + {FzName: ts + 13287 /* "enable_trigger" */, Fop: SQLITE_DBCONFIG_ENABLE_TRIGGER}, + {FzName: ts + 13302 /* "enable_view" */, Fop: SQLITE_DBCONFIG_ENABLE_VIEW}, + {FzName: ts + 13314 /* "fts3_tokenizer" */, Fop: SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER}, + {FzName: ts + 13329 /* "legacy_alter_tab..." */, Fop: SQLITE_DBCONFIG_LEGACY_ALTER_TABLE}, + {FzName: ts + 13348 /* "legacy_file_form..." */, Fop: SQLITE_DBCONFIG_LEGACY_FILE_FORMAT}, + {FzName: ts + 13367 /* "load_extension" */, Fop: SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION}, + {FzName: ts + 13382 /* "no_ckpt_on_close" */, Fop: SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE}, + {FzName: ts + 13399 /* "reset_database" */, Fop: SQLITE_DBCONFIG_RESET_DATABASE}, + {FzName: ts + 13414 /* "trigger_eqp" */, Fop: SQLITE_DBCONFIG_TRIGGER_EQP}, + {FzName: ts + 13426 /* "trusted_schema" */, Fop: SQLITE_DBCONFIG_TRUSTED_SCHEMA}, + {FzName: ts + 13441 /* "writable_schema" */, Fop: SQLITE_DBCONFIG_WRITABLE_SCHEMA}, } /* tclsqlite.c:2343:7 */ var TTYPE_strs = [5]uintptr{ ts + 13457 /* "statement" */, ts + 13092 /* "profile" */, ts + 13467 /* "row" */, ts + 9947 /* "close" */, uintptr(0), @@ -43087,7 +40384,7 @@ func sqliteCmdUsage(tls *libc.TLS, interp uintptr, objv uintptr) int32 { /* tcls tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+13519 /* "HANDLE ?FILENAME..." */) - return 1 + return TCL_ERROR } // sqlite3 DBNAME FILENAME ?-vfs VFSNAME? ?-key KEY? ?-readonly BOOLEAN? @@ -43125,32 +40422,32 @@ func DbMain(tls *libc.TLS, cd uintptr, interp uintptr, objc int32, objv uintptr) // However, for testing purposes it is useful to have mutexes turned // on. So, by default, mutexes default off. But if compiled with // SQLITE_TCL_DEFAULT_FULLMUTEX then mutexes default on. - flags = ((0x00000002 | 0x00000004) | 0x00008000) + flags = ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_NOMUTEX) if objc == 1 { return sqliteCmdUsage(tls, interp, objv) } if objc == 2 { - zArg = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), uintptr(0)) + zArg = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(0)) if libc.Xstrcmp(tls, zArg, ts+13665 /* "-version" */) == 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3_libversion(tls), uintptr(0))) - return 0 + return TCL_OK } if libc.Xstrcmp(tls, zArg, ts+13674 /* "-sourceid" */) == 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, sqlite3.Xsqlite3_sourceid(tls), uintptr(0))) - return 0 + return TCL_OK } if libc.Xstrcmp(tls, zArg, ts+13684 /* "-has-codec" */) == 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+13695 /* "0" */, uintptr(0))) - return 0 + return TCL_OK } - if int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) == '-' { + if int32(*(*int8)(unsafe.Pointer(zArg))) == '-' { return sqliteCmdUsage(tls, interp, objv) } } for i = 2; i < objc; i++ { zArg = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8))) - if int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) != '-' { + if int32(*(*int8)(unsafe.Pointer(zArg))) != '-' { if zFile != uintptr(0) { return sqliteCmdUsage(tls, interp, objv) } @@ -43169,79 +40466,79 @@ func DbMain(tls *libc.TLS, cd uintptr, interp uintptr, objc int32, objv uintptr) // var b int32 at bp+88, 4 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+88 /* &b */) != 0 { - return 1 + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 88 /* b */)) != 0 { - flags = flags & (^libc.Int32((0x00000002 | 0x00000004))) - flags = flags | (0x00000001) + flags = flags & (libc.CplInt32((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE))) + flags = flags | (SQLITE_OPEN_READONLY) } else { - flags = flags & (^libc.Int32(0x00000001)) - flags = flags | (0x00000002) + flags = flags & (libc.CplInt32(SQLITE_OPEN_READONLY)) + flags = flags | (SQLITE_OPEN_READWRITE) } } else if libc.Xstrcmp(tls, zArg, ts+13707 /* "-create" */) == 0 { // var b int32 at bp+92, 4 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+92 /* &b */) != 0 { - return 1 + return TCL_ERROR } - if (*(*int32)(unsafe.Pointer(bp + 92 /* b */)) != 0) && ((flags & 0x00000001) == 0) { - flags = flags | (0x00000004) + if (*(*int32)(unsafe.Pointer(bp + 92 /* b */)) != 0) && ((flags & SQLITE_OPEN_READONLY) == 0) { + flags = flags | (SQLITE_OPEN_CREATE) } else { - flags = flags & (^libc.Int32(0x00000004)) + flags = flags & (libc.CplInt32(SQLITE_OPEN_CREATE)) } } else if libc.Xstrcmp(tls, zArg, ts+13715 /* "-nofollow" */) == 0 { // var b int32 at bp+96, 4 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+96 /* &b */) != 0 { - return 1 + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 96 /* b */)) != 0 { - flags = flags | (0x01000000) + flags = flags | (SQLITE_OPEN_NOFOLLOW) } else { - flags = flags & (^libc.Int32(0x01000000)) + flags = flags & (libc.CplInt32(SQLITE_OPEN_NOFOLLOW)) } } else if libc.Xstrcmp(tls, zArg, ts+13725 /* "-nomutex" */) == 0 { // var b int32 at bp+100, 4 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+100 /* &b */) != 0 { - return 1 + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 100 /* b */)) != 0 { - flags = flags | (0x00008000) - flags = flags & (^libc.Int32(0x00010000)) + flags = flags | (SQLITE_OPEN_NOMUTEX) + flags = flags & (libc.CplInt32(SQLITE_OPEN_FULLMUTEX)) } else { - flags = flags & (^libc.Int32(0x00008000)) + flags = flags & (libc.CplInt32(SQLITE_OPEN_NOMUTEX)) } } else if libc.Xstrcmp(tls, zArg, ts+13734 /* "-fullmutex" */) == 0 { // var b int32 at bp+104, 4 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+104 /* &b */) != 0 { - return 1 + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 104 /* b */)) != 0 { - flags = flags | (0x00010000) - flags = flags & (^libc.Int32(0x00008000)) + flags = flags | (SQLITE_OPEN_FULLMUTEX) + flags = flags & (libc.CplInt32(SQLITE_OPEN_NOMUTEX)) } else { - flags = flags & (^libc.Int32(0x00010000)) + flags = flags & (libc.CplInt32(SQLITE_OPEN_FULLMUTEX)) } } else if libc.Xstrcmp(tls, zArg, ts+13745 /* "-uri" */) == 0 { // var b int32 at bp+108, 4 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+108 /* &b */) != 0 { - return 1 + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 108 /* b */)) != 0 { - flags = flags | (0x00000040) + flags = flags | (SQLITE_OPEN_URI) } else { - flags = flags & (^libc.Int32(0x00000040)) + flags = flags & (libc.CplInt32(SQLITE_OPEN_URI)) } } else if libc.Xstrcmp(tls, zArg, ts+13750 /* "-translatefilena..." */) == 0 { if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+112 /* &bTranslateFileName */) != 0 { - return 1 + return TCL_ERROR } } else { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+11955 /* "unknown option: " */, zArg, uintptr(0))) - return 1 + return TCL_ERROR } } zErrMsg = uintptr(0) @@ -43258,7 +40555,7 @@ func DbMain(tls *libc.TLS, cd uintptr, interp uintptr, objc int32, objv uintptr) tcl.XTcl_DStringFree(tls, bp+120 /* &translatedFilename */) } if (*SqliteDb)(unsafe.Pointer(p)).Fdb != 0 { - if 0 != sqlite3.Xsqlite3_errcode(tls, (*SqliteDb)(unsafe.Pointer(p)).Fdb) { + if SQLITE_OK != sqlite3.Xsqlite3_errcode(tls, (*SqliteDb)(unsafe.Pointer(p)).Fdb) { zErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+72, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(p)).Fdb))) sqlite3.Xsqlite3_close(tls, (*SqliteDb)(unsafe.Pointer(p)).Fdb) (*SqliteDb)(unsafe.Pointer(p)).Fdb = uintptr(0) @@ -43270,12 +40567,12 @@ func DbMain(tls *libc.TLS, cd uintptr, interp uintptr, objc int32, objv uintptr) tcl.XTcl_SetResult(tls, interp, zErrMsg, uintptr(1)) tcl.XTcl_Free(tls, p) sqlite3.Xsqlite3_free(tls, zErrMsg) - return 1 + return TCL_ERROR } - (*SqliteDb)(unsafe.Pointer(p)).FmaxStmt = 10 - (*SqliteDb)(unsafe.Pointer(p)).FopenFlags = (flags & 0x00000040) + (*SqliteDb)(unsafe.Pointer(p)).FmaxStmt = NUM_PREPARED_STMTS + (*SqliteDb)(unsafe.Pointer(p)).FopenFlags = (flags & SQLITE_OPEN_URI) (*SqliteDb)(unsafe.Pointer(p)).Finterp = interp - zArg = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), uintptr(0)) + zArg = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(0)) if DbUseNre(tls) != 0 { tcl.XTcl_NRCreateCommand(tls, interp, zArg, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 @@ -43288,7 +40585,7 @@ func DbMain(tls *libc.TLS, cd uintptr, interp uintptr, objc int32, objv uintptr) f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 }{DbObjCmd})), p, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{DbDeleteCmd}))) } - return 0 + return TCL_OK } // Provide a dummy Tcl_InitStubs if we are using this as a static @@ -43310,11 +40607,11 @@ func DbMain(tls *libc.TLS, cd uintptr, interp uintptr, objc int32, objv uintptr) func Sqlite3_Init(tls *libc.TLS, interp uintptr) int32 { /* tclsqlite.c:3877:12: */ var rc int32 if 1 != 0 { - rc = 0 + rc = TCL_OK } else { - rc = 1 + rc = TCL_ERROR } - if rc == 0 { + if rc == TCL_OK { tcl.XTcl_CreateObjCommand(tls, interp, ts+13769 /* "sqlite3" */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 }{DbMain})), uintptr(0), uintptr(0)) @@ -43334,22 +40631,22 @@ func Tclsqlite3_Init(tls *libc.TLS, interp uintptr) int32 { /* tclsqlite.c:3891: } func Sqlite3_Unload(tls *libc.TLS, interp uintptr, flags int32) int32 { /* tclsqlite.c:3892:12: */ - return 0 + return TCL_OK } func Tclsqlite3_Unload(tls *libc.TLS, interp uintptr, flags int32) int32 { /* tclsqlite.c:3893:12: */ - return 0 + return TCL_OK } // Because it accesses the file-system and uses persistent state, SQLite // is not considered appropriate for safe interpreters. Hence, we cause // the _SafeInit() interfaces return TCL_ERROR. func Sqlite3_SafeInit(tls *libc.TLS, interp uintptr) int32 { /* tclsqlite.c:3899:12: */ - return 1 + return TCL_ERROR } func Sqlite3_SafeUnload(tls *libc.TLS, interp uintptr, flags int32) int32 { /* tclsqlite.c:3900:12: */ - return 1 + return TCL_ERROR } func Sqlite_Init(tls *libc.TLS, interp uintptr) int32 { /* tclsqlite.c:3905:5: */ @@ -43361,11 +40658,11 @@ func Tclsqlite_Init(tls *libc.TLS, interp uintptr) int32 { /* tclsqlite.c:3906:5 } func Sqlite_Unload(tls *libc.TLS, interp uintptr, flags int32) int32 { /* tclsqlite.c:3907:5: */ - return 0 + return TCL_OK } func Tclsqlite_Unload(tls *libc.TLS, interp uintptr, flags int32) int32 { /* tclsqlite.c:3908:5: */ - return 0 + return TCL_OK } // If the TCLSH macro is defined, add code to make a stand-alone program. @@ -43395,7 +40692,7 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* tclsqlite.c:3953: libc.VaList(bp, libc.Xgetpid(tls))) libc.Xfgetc(tls, libc.Xstdin) } else { - libc.Xraise(tls, 5) + libc.Xraise(tls, SIGTRAP) } } @@ -43404,24 +40701,24 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* tclsqlite.c:3953: // sqlite3_initialize() is. sqlite3.Xsqlite3_shutdown(tls) - tcl.XTcl_FindExecutable(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + tcl.XTcl_FindExecutable(tls, *(*uintptr)(unsafe.Pointer(argv))) tcl.XTcl_SetSystemEncoding(tls, uintptr(0), ts+14303 /* "utf-8" */) interp = tcl.XTcl_CreateInterp(tls) Sqlite3_Init(tls, interp) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([32]int8{})), bp+32 /* &zArgc[0] */, ts+1237 /* "%d" */, libc.VaList(bp+8, (argc-1))) - tcl.XTcl_SetVar2(tls, interp, ts+14309 /* "argc" */, uintptr(0), bp+32 /* &zArgc[0] */, 1) - tcl.XTcl_SetVar2(tls, interp, ts+14314 /* "argv0" */, uintptr(0), *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), 1) - tcl.XTcl_SetVar2(tls, interp, ts+14320 /* "argv" */, uintptr(0), ts+488 /* "" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+14309 /* "argc" */, uintptr(0), bp+32 /* &zArgc[0] */, TCL_GLOBAL_ONLY) + tcl.XTcl_SetVar2(tls, interp, ts+14314 /* "argv0" */, uintptr(0), *(*uintptr)(unsafe.Pointer(argv)), TCL_GLOBAL_ONLY) + tcl.XTcl_SetVar2(tls, interp, ts+14320 /* "argv" */, uintptr(0), ts+488 /* "" */, TCL_GLOBAL_ONLY) for i = 1; i < argc; i++ { - tcl.XTcl_SetVar2(tls, interp, ts+14320 /* "argv" */, uintptr(0), *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), ((1 | 8) | 4)) + tcl.XTcl_SetVar2(tls, interp, ts+14320 /* "argv" */, uintptr(0), *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), ((TCL_GLOBAL_ONLY | TCL_LIST_ELEMENT) | TCL_APPEND_VALUE)) } zScript = sqlite3TestInit(tls, interp) if zScript == uintptr(0) { zScript = tclsh_main_loop(tls) } - if tcl.XTcl_GlobalEval(tls, interp, zScript) != 0 { - var zInfo uintptr = tcl.XTcl_GetVar2(tls, interp, ts+14325 /* "errorInfo" */, uintptr(0), 1) + if tcl.XTcl_GlobalEval(tls, interp, zScript) != TCL_OK { + var zInfo uintptr = tcl.XTcl_GetVar2(tls, interp, ts+14325 /* "errorInfo" */, uintptr(0), TCL_GLOBAL_ONLY) if zInfo == uintptr(0) { zInfo = tcl.XTcl_GetStringResult(tls, interp) } @@ -45653,7 +42950,7 @@ func sqlite3TestTextToPtr(tls *libc.TLS, z uintptr) uintptr { /* test1.c:54:6: * // var v2 u322 at bp+16, 4 - if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '0') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == 'x') { + if (int32(*(*int8)(unsafe.Pointer(z))) == '0') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == 'x') { z += uintptr(2) } *(*u64)(unsafe.Pointer(bp + 8 /* v */)) = uint64(0) @@ -45685,17 +42982,17 @@ func get_sqlite_pointer(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+14343 /* "SQLITE-CONNECTIO..." */) - return 1 + return TCL_ERROR } - if !(tcl.XTcl_GetCommandInfo(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+48 /* &cmdInfo */) != 0) { + if !(tcl.XTcl_GetCommandInfo(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &cmdInfo */) != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14361, /* "command not foun..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), uintptr(0))) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) + return TCL_ERROR } p = (*Tcl_CmdInfo)(unsafe.Pointer(bp + 48 /* &cmdInfo */)).FobjClientData sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+112 /* &zBuf[0] */, ts+12843 /* "%p" */, libc.VaList(bp+24, (*struct{ Fdb uintptr })(unsafe.Pointer(p)).Fdb)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+112 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Decode a pointer to an sqlite3 object. @@ -45712,7 +43009,7 @@ func getDbPointer(tls *libc.TLS, interp uintptr, zA uintptr, ppDb uintptr) int32 } else { *(*uintptr)(unsafe.Pointer(ppDb)) = sqlite3TestTextToPtr(tls, zA) } - return 0 + return TCL_OK } // Convert an sqlite3_stmt* into an sqlite3*. This depends on the @@ -45724,7 +43021,7 @@ func sqlite3TestErrCode(tls *libc.TLS, interp uintptr, db uintptr, rc int32) int bp := tls.Alloc(248) defer tls.Free(248) - if (((sqlite3.Xsqlite3_threadsafe(tls) == 0) && (rc != 21)) && (rc != 0)) && + if (((sqlite3.Xsqlite3_threadsafe(tls) == 0) && (rc != SQLITE_MISUSE)) && (rc != SQLITE_OK)) && (sqlite3.Xsqlite3_errcode(tls, db) != rc) { // var zBuf [200]int8 at bp+48, 200 @@ -45742,7 +43039,7 @@ func sqlite3TestErrCode(tls *libc.TLS, interp uintptr, db uintptr, rc int32) int // Decode a pointer to an sqlite3_stmt object. func getStmtPointer(tls *libc.TLS, interp uintptr, zArg uintptr, ppStmt uintptr) int32 { /* test1.c:162:12: */ *(*uintptr)(unsafe.Pointer(ppStmt)) = sqlite3TestTextToPtr(tls, zArg) - return 0 + return TCL_OK } // Generate a text representation of a pointer that can be understood @@ -45761,7 +43058,7 @@ func sqlite3TestMakePointerStr(tls *libc.TLS, interp uintptr, zPtr uintptr, p ui defer tls.Free(8) sqlite3.Xsqlite3_snprintf(tls, 100, zPtr, ts+12843 /* "%p" */, libc.VaList(bp, p)) - return 0 + return TCL_OK } // The callback routine for sqlite3_exec_printf(). @@ -45798,7 +43095,7 @@ func exec_printf_cb(tls *libc.TLS, pArg uintptr, argc int32, argv uintptr, name // I/O tracing begins going into FILENAME. If FILENAME is an empty // string, I/O tracing is turned off. func test_io_trace(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:228:26: */ - return 0 + return TCL_OK } // Usage: clang_sanitize_address @@ -45813,7 +43110,7 @@ func clang_sanitize_address(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc res = 1 } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, res)) - return 0 + return TCL_OK } // Usage: sqlite3_exec_printf DB FORMAT STRING @@ -45835,15 +43132,15 @@ func test_exec_printf(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32 // var zBuf [30]int8 at bp+280, 30 if argc != 4 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14477 /* " DB FORMAT STRIN..." */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+48 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+48 /* &db */) != 0 { + return TCL_ERROR } tcl.XTcl_DStringInit(tls, bp+56 /* &str */) - zSql = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)))) + zSql = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + 3*8)))) rc = sqlite3.Xsqlite3_exec(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zSql, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 }{exec_printf_cb})), bp+56 /* &str */, bp+272 /* &zErr */) @@ -45851,7 +43148,7 @@ func test_exec_printf(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+280 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+40, rc)) tcl.XTcl_AppendElement(tls, interp, bp+280 /* &zBuf[0] */) tcl.XTcl_AppendElement(tls, interp, func() uintptr { - if rc == 0 { + if rc == SQLITE_OK { return (*Tcl_DString)(unsafe.Pointer(bp + 56 /* &str */)).Fstring } return *(*uintptr)(unsafe.Pointer(bp + 272 /* zErr */)) @@ -45861,9 +43158,9 @@ func test_exec_printf(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 272 /* zErr */))) } if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_exec_hex DB HEX @@ -45889,14 +43186,14 @@ func test_exec_hex(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, a // var zBuf [30]int8 at bp+776, 30 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14495 /* " DB HEX" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+40 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+40 /* &db */) != 0 { + return TCL_ERROR } - zHex = *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)) + zHex = *(*uintptr)(unsafe.Pointer(argv + 2*8)) i = libc.AssignInt32(&j, 0) __1: if !((uint64(i) < (uint64(unsafe.Sizeof([501]int8{})) - uint64(1))) && (*(*int8)(unsafe.Pointer(zHex + uintptr(j))) != 0)) { @@ -45927,7 +43224,7 @@ __3: sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+776 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+32, rc)) tcl.XTcl_AppendElement(tls, interp, bp+776 /* &zBuf[0] */) tcl.XTcl_AppendElement(tls, interp, func() uintptr { - if rc == 0 { + if rc == SQLITE_OK { return (*Tcl_DString)(unsafe.Pointer(bp + 552 /* &str */)).Fstring } return *(*uintptr)(unsafe.Pointer(bp + 768 /* zErr */)) @@ -45937,9 +43234,9 @@ __3: sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 768 /* zErr */))) } if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 40 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: db_enter DB @@ -45953,15 +43250,15 @@ func db_enter(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv u // var db uintptr at bp+32, 8 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14503 /* " DB" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmutex) - return 0 + return TCL_OK } func db_leave(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:396:26: */ @@ -45971,15 +43268,15 @@ func db_leave(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv u // var db uintptr at bp+32, 8 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14503 /* " DB" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmutex) - return 0 + return TCL_OK } // Usage: sqlite3_exec DB SQL @@ -46001,15 +43298,15 @@ func test_exec(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv // var zBuf [30]int8 at bp+280, 30 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14507 /* " DB SQL" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+48 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+48 /* &db */) != 0 { + return TCL_ERROR } tcl.XTcl_DStringInit(tls, bp+56 /* &str */) - zSql = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + zSql = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) for i = libc.AssignInt32(&j, 0); *(*int8)(unsafe.Pointer(zSql + uintptr(i))) != 0; { if int32(*(*int8)(unsafe.Pointer(zSql + uintptr(i)))) == '%' { *(*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)))))))) @@ -46026,7 +43323,7 @@ func test_exec(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+280 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+40, rc)) tcl.XTcl_AppendElement(tls, interp, bp+280 /* &zBuf[0] */) tcl.XTcl_AppendElement(tls, interp, func() uintptr { - if rc == 0 { + if rc == SQLITE_OK { return (*Tcl_DString)(unsafe.Pointer(bp + 56 /* &str */)).Fstring } return *(*uintptr)(unsafe.Pointer(bp + 272 /* zErr */)) @@ -46036,9 +43333,9 @@ func test_exec(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 272 /* zErr */))) } if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_exec_nr DB SQL @@ -46054,18 +43351,18 @@ func test_exec_nr(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, ar var rc int32 *(*uintptr)(unsafe.Pointer(bp + 40 /* zErr */)) = uintptr(0) if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14507 /* " DB SQL" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_exec(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), uintptr(0), uintptr(0), bp+40 /* &zErr */) + rc = sqlite3.Xsqlite3_exec(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), uintptr(0), uintptr(0), bp+40 /* &zErr */) if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_mprintf_z_test SEPARATOR ARG0 ARG1 ... @@ -46081,11 +43378,11 @@ func test_mprintf_z(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var i int32 for i = 2; (i < argc) && ((i == 2) || (zResult != 0)); i++ { - zResult = sqlite3.Xsqlite3_mprintf(tls, ts+14515 /* "%z%s%s" */, libc.VaList(bp, zResult, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) + zResult = sqlite3.Xsqlite3_mprintf(tls, ts+14515 /* "%z%s%s" */, libc.VaList(bp, zResult, *(*uintptr)(unsafe.Pointer(argv + 1*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, zResult, 0)) sqlite3.Xsqlite3_free(tls, zResult) - return 0 + return TCL_OK } // Usage: sqlite3_mprintf_n_test STRING @@ -46098,10 +43395,10 @@ func test_mprintf_n(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var zStr uintptr *(*int32)(unsafe.Pointer(bp + 16 /* n */)) = 0 - zStr = sqlite3.Xsqlite3_mprintf(tls, ts+14522 /* "%s%n" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+16 /* &n */)) + zStr = sqlite3.Xsqlite3_mprintf(tls, ts+14522 /* "%s%n" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+16 /* &n */)) sqlite3.Xsqlite3_free(tls, zStr) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 16 /* n */)))) - return 0 + return TCL_OK } // Usage: sqlite3_snprintf_int SIZE FORMAT INT @@ -46118,16 +43415,16 @@ func test_snprintf_int(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 // var zStr [100]int8 at bp+24, 100 - var n int32 = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - var zFormat uintptr = *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)) - var a1 int32 = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) + var n int32 = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + var zFormat uintptr = *(*uintptr)(unsafe.Pointer(argv + 2*8)) + var a1 int32 = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) if uint64(n) > uint64(unsafe.Sizeof([100]int8{})) { n = int32(unsafe.Sizeof([100]int8{})) } sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+24 /* &zStr[0] */, ts+14527 /* "abcdefghijklmnop..." */, 0) sqlite3.Xsqlite3_snprintf(tls, n, bp+24 /* &zStr[0] */, zFormat, libc.VaList(bp, a1)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+8, bp+24 /* &zStr[0] */, 0)) - return 0 + return TCL_OK } // Usage: sqlite3_get_table_printf DB FORMAT STRING ?--no-counts? @@ -46155,20 +43452,20 @@ func test_get_table_printf(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc var zSql uintptr *(*int32)(unsafe.Pointer(bp + 64 /* resCount */)) = -1 if argc == 5 { - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)), bp+64 /* &resCount */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 4*8)), bp+64 /* &resCount */) != 0 { + return TCL_ERROR } } if (argc != 4) && (argc != 5) { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14554 /* " DB FORMAT STRIN..." */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+72 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+72 /* &db */) != 0 { + return TCL_ERROR } tcl.XTcl_DStringInit(tls, bp+80 /* &str */) - zSql = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)))) + zSql = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + 3*8)))) if argc == 5 { rc = sqlite3.Xsqlite3_get_table(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* db */)), zSql, bp+296 /* &aResult */, uintptr(0), uintptr(0), bp+304 /* &zErr */) } else { @@ -46178,7 +43475,7 @@ func test_get_table_printf(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc sqlite3.Xsqlite3_free(tls, zSql) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+320 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+40, rc)) tcl.XTcl_AppendElement(tls, interp, bp+320 /* &zBuf[0] */) - if rc == 0 { + if rc == SQLITE_OK { if argc == 4 { sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+320 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+48, *(*int32)(unsafe.Pointer(bp + 312 /* nRow */)))) tcl.XTcl_AppendElement(tls, interp, bp+320 /* &zBuf[0] */) @@ -46201,9 +43498,9 @@ func test_get_table_printf(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 304 /* zErr */))) } if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 72 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_last_insert_rowid DB @@ -46218,29 +43515,29 @@ func test_last_rowid(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, // var zBuf [30]int8 at bp+64, 30 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), ts+14580 /* " DB\"" */, 0)) - return 1 + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14580 /* " DB\"" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+56 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+56 /* &db */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+64 /* &zBuf[0] */, ts+10367 /* "%lld" */, libc.VaList(bp+32, sqlite3.Xsqlite3_last_insert_rowid(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */))))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+64 /* &zBuf[0] */, 0)) - return 0 + return SQLITE_OK } // Usage: sqlite3_key DB KEY // // Set the codec key. func test_key(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:652:26: */ - return 0 + return TCL_OK } // Usage: sqlite3_rekey DB KEY // // Change the codec key. func test_rekey(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:666:26: */ - return 0 + return TCL_OK } // Usage: sqlite3_close DB @@ -46254,16 +43551,16 @@ func sqlite_test_close(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14585 /* " FILENAME\"" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // Usage: sqlite3_close_v2 DB @@ -46277,16 +43574,16 @@ func sqlite_test_close_v2(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc i var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14585 /* " FILENAME\"" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_close_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // Implementation of the x_coalesce() function. @@ -46294,7 +43591,7 @@ func sqlite_test_close_v2(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc i func t1_ifnullFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test1.c:727:13: */ var i int32 for i = 0; i < argc; i++ { - if 5 != sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) { + if SQLITE_NULL != sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) { var n int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) sqlite3.Xsqlite3_result_text(tls, context, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))), n, libc.UintptrFromInt32(-1)) @@ -46314,7 +43611,7 @@ func hex8Func(tls *libc.TLS, p uintptr, argc int32, argv uintptr) { /* test1.c:7 var i int32 // var zBuf [200]int8 at bp+8, 200 - z = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + z = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) for i = 0; (uint64(i) < ((uint64(unsafe.Sizeof([200]int8{})) / uint64(2)) - uint64(2))) && (*(*uint8)(unsafe.Pointer(z + uintptr(i))) != 0); i++ { sqlite3.Xsqlite3_snprintf(tls, (int32(uint64(unsafe.Sizeof([200]int8{})) - (uint64(i * 2)))), (bp + 8 /* &zBuf */ + uintptr((i * 2))), ts+14596 /* "%02x" */, libc.VaList(bp, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) } @@ -46330,7 +43627,7 @@ func hex16Func(tls *libc.TLS, p uintptr, argc int32, argv uintptr) { /* test1.c: var i int32 // var zBuf [400]int8 at bp+8, 400 - z = sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + z = sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv))) for i = 0; (uint64(i) < ((uint64(unsafe.Sizeof([400]int8{})) / uint64(4)) - uint64(4))) && (*(*uint16)(unsafe.Pointer(z + uintptr(i)*2)) != 0); i++ { sqlite3.Xsqlite3_snprintf(tls, (int32(uint64(unsafe.Sizeof([400]int8{})) - (uint64(i * 4)))), (bp + 8 /* &zBuf */ + uintptr((i * 4))), ts+14601 /* "%04x" */, libc.VaList(bp, (int32(*(*uint16)(unsafe.Pointer(z + uintptr(i)*2)))&0xff))) } @@ -46397,7 +43694,7 @@ func sqlite3ExecFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { libc.Xmemset(tls, bp /* &x */, 0, uint64(unsafe.Sizeof(dstr{}))) sqlite3.Xsqlite3_exec(tls, sqlite3.Xsqlite3_user_data(tls, context), - sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))), + sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 }{execFuncCallback})), bp /* &x */, uintptr(0)) @@ -46425,10 +43722,10 @@ func tkt2213Function(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { var zText2 uintptr var zText3 uintptr - nText = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zText1 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zText2 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zText3 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + nText = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + zText1 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + zText2 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + zText3 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if (zText1 != zText2) || (zText2 != zText3) { sqlite3.Xsqlite3_result_error(tls, context, ts+14606 /* "tkt2213 is not f..." */, -1) @@ -46468,42 +43765,42 @@ func ptrChngFunction(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { if argc != 4 { return } - zCmd = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zCmd = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if zCmd == uintptr(0) { return } if libc.Xstrcmp(tls, zCmd, ts+12275 /* "text" */) == 0 { - p1 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + p1 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) } else if libc.Xstrcmp(tls, zCmd, ts+14627 /* "text16" */) == 0 { - p1 = sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + p1 = sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv))) } else if libc.Xstrcmp(tls, zCmd, ts+12280 /* "blob" */) == 0 { - p1 = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + p1 = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) } else { return } - zCmd = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + zCmd = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) if zCmd == uintptr(0) { return } if libc.Xstrcmp(tls, zCmd, ts+14634 /* "bytes" */) == 0 { - sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) } else if libc.Xstrcmp(tls, zCmd, ts+14640 /* "bytes16" */) == 0 { - sqlite3.Xsqlite3_value_bytes16(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + sqlite3.Xsqlite3_value_bytes16(tls, *(*uintptr)(unsafe.Pointer(argv))) } else if libc.Xstrcmp(tls, zCmd, ts+14648 /* "noop" */) == 0 { // do nothing } else { return } - zCmd = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) + zCmd = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) if zCmd == uintptr(0) { return } if libc.Xstrcmp(tls, zCmd, ts+12275 /* "text" */) == 0 { - p2 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + p2 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) } else if libc.Xstrcmp(tls, zCmd, ts+14627 /* "text16" */) == 0 { - p2 = sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + p2 = sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv))) } else if libc.Xstrcmp(tls, zCmd, ts+12280 /* "blob" */) == 0 { - p2 = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + p2 = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) } else { return } @@ -46524,9 +43821,9 @@ func intrealFunction(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { bp := tls.Alloc(8) defer tls.Free(8) - var v sqlite3_int64 = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var v sqlite3_int64 = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) sqlite3.Xsqlite3_result_int64(tls, context, v) - sqlite3.Xsqlite3_test_control(tls, 27, libc.VaList(bp, context)) + sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_RESULT_INTREAL, libc.VaList(bp, context)) } // Usage: sqlite3_create_function DB @@ -46550,37 +43847,37 @@ func test_create_function(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc i // var db uintptr at bp+32, 8 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14580 /* " DB\"" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14653 /* "x_coalesce" */, -1, 1, uintptr(0), + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14653 /* "x_coalesce" */, -1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{t1_ifnullFunc})), uintptr(0), uintptr(0)) - if rc == 0 { - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14664 /* "hex8" */, 1, (1 | 0x000000800), + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14664 /* "hex8" */, 1, (SQLITE_UTF8 | SQLITE_DETERMINISTIC), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{hex8Func})), uintptr(0), uintptr(0)) } - if rc == 0 { - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14669 /* "hex16" */, 1, (4 | 0x000000800), + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14669 /* "hex16" */, 1, (SQLITE_UTF16 | SQLITE_DETERMINISTIC), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{hex16Func})), uintptr(0), uintptr(0)) } - if rc == 0 { - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14675 /* "tkt2213func" */, 1, 5, uintptr(0), + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14675 /* "tkt2213func" */, 1, SQLITE_ANY, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tkt2213Function})), uintptr(0), uintptr(0)) } - if rc == 0 { - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14687 /* "pointer_change" */, 4, 5, uintptr(0), + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14687 /* "pointer_change" */, 4, SQLITE_ANY, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{ptrChngFunction})), uintptr(0), uintptr(0)) @@ -46589,14 +43886,14 @@ func test_create_function(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc i // Functions counter1() and counter2() have the same implementation - they // both return an ascending integer with each call. But counter1() is marked // as non-deterministic and counter2() is marked as deterministic. - if rc == 0 { - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14702 /* "counter1" */, -1, 1, + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14702 /* "counter1" */, -1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{nondeterministicFunction})), uintptr(0), uintptr(0)) } - if rc == 0 { - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14711 /* "counter2" */, -1, (1 | 0x000000800), + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14711 /* "counter2" */, -1, (SQLITE_UTF8 | SQLITE_DETERMINISTIC), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{nondeterministicFunction})), uintptr(0), uintptr(0)) @@ -46604,8 +43901,8 @@ func test_create_function(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc i // The intreal() function converts its argument to an integer and returns // it as a MEM_IntReal. - if rc == 0 { - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14720 /* "intreal" */, 1, 1, + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14720 /* "intreal" */, 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{intrealFunction})), uintptr(0), uintptr(0)) @@ -46613,18 +43910,18 @@ func test_create_function(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc i // Use the sqlite3_create_function16() API here. Mainly for fun, but also // because it is not tested anywhere else. - if rc == 0 { + if rc == SQLITE_OK { var zUtf16 uintptr var pVal uintptr sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmutex) pVal = sqlite3.Xsqlite3ValueNew(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))) - sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, ts+14728 /* "x_sqlite_exec" */, uint8(1), uintptr(0)) - zUtf16 = sqlite3.Xsqlite3ValueText(tls, pVal, uint8(2)) + sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, ts+14728 /* "x_sqlite_exec" */, SQLITE_UTF8, uintptr(0)) + zUtf16 = sqlite3.Xsqlite3ValueText(tls, pVal, SQLITE_UTF16LE) if (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).FmallocFailed != 0 { - rc = 7 + rc = SQLITE_NOMEM } else { rc = sqlite3.Xsqlite3_create_function16(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), zUtf16, - 1, 4, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), *(*uintptr)(unsafe.Pointer(&struct { + 1, SQLITE_UTF16, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{sqlite3ExecFunc})), uintptr(0), uintptr(0)) } @@ -46633,10 +43930,10 @@ func test_create_function(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc i } if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // Usage: sqlite3_drop_modules DB ?NAME ...? @@ -46651,12 +43948,12 @@ func test_drop_modules(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 // var db uintptr at bp+32, 8 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14580 /* " DB\"" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_drop_modules(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), func() uintptr { if argc > 2 { @@ -46664,7 +43961,7 @@ func test_drop_modules(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 } return uintptr(0) }()) - return 0 + return TCL_OK } // Routines to implement the x_count() aggregate function. @@ -46695,16 +43992,16 @@ func t1CountStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* var p uintptr p = sqlite3.Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(t1CountCtx{}))) - if ((argc == 0) || (5 != sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) && (p != 0) { + if ((argc == 0) || (SQLITE_NULL != sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))))) && (p != 0) { (*t1CountCtx)(unsafe.Pointer(p)).Fn++ } if argc > 0 { - var v int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var v int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) if v == 40 { sqlite3.Xsqlite3_result_error(tls, context, ts+14742 /* "value of 40 hand..." */, -1) } else if v == 41 { *(*[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)} - sqlite3.Xsqlite3_result_error16(tls, context, (bp /* &zUtf16ErrMsg */ + uintptr((1 - 0))), -1) + sqlite3.Xsqlite3_result_error16(tls, context, (bp /* &zUtf16ErrMsg */ + 1), -1) } } } @@ -46759,34 +44056,34 @@ func test_create_aggregate(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14585 /* " FILENAME\"" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14793 /* "x_count" */, 0, 1, uintptr(0), uintptr(0), + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14793 /* "x_count" */, 0, SQLITE_UTF8, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{t1CountStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{t1CountFinalize}))) - if rc == 0 { - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14793 /* "x_count" */, 1, 1, uintptr(0), uintptr(0), + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14793 /* "x_count" */, 1, SQLITE_UTF8, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{t1CountStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{t1CountFinalize}))) } - if rc == 0 { - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14801 /* "legacy_count" */, 0, 5, uintptr(0), uintptr(0), + if rc == SQLITE_OK { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14801 /* "legacy_count" */, 0, SQLITE_ANY, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{legacyCountStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{legacyCountFinalize}))) } if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // Usage: printf TEXT @@ -46800,12 +44097,12 @@ func test_printf(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, arg defer tls.Free(40) if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14814 /* " TEXT\"" */, 0)) - return 1 + return TCL_ERROR } - libc.Xprintf(tls, ts+293 /* "%s\n" */, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) - return 0 + libc.Xprintf(tls, ts+293 /* "%s\n" */, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) + return TCL_OK } // Usage: sqlite3_mprintf_int FORMAT INTEGER INTEGER INTEGER @@ -46820,19 +44117,19 @@ func sqlite3_mprintf_int(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc in var i int32 var z uintptr if argc != 5 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14821 /* " FORMAT INT INT ..." */, 0)) - return 1 + return TCL_ERROR } for i = 2; i < 5; i++ { if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+72 /* &a */ +uintptr((i-2))*4)) != 0 { - return 1 + return TCL_ERROR } } - z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(0)*4)), *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(1)*4)), *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(2)*4)))) + 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)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, z, 0)) sqlite3.Xsqlite3_free(tls, z) - return 0 + return TCL_OK } // Usage: sqlite3_mprintf_int64 FORMAT INTEGER INTEGER INTEGER @@ -46847,20 +44144,20 @@ func sqlite3_mprintf_int64(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc var z uintptr if argc != 5 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14821 /* " FORMAT INT INT ..." */, 0)) - return 1 + return TCL_ERROR } for i = 2; i < 5; i++ { - 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(1)) != 0 { + 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))), SQLITE_UTF8) != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+14842 /* "argument is not ..." */, 0)) - return 1 + return TCL_ERROR } } - z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), libc.VaList(bp+48, *(*sqlite_int64)(unsafe.Pointer(bp + 88 /* &a[0] */ + uintptr(0)*8)), *(*sqlite_int64)(unsafe.Pointer(bp + 88 /* &a[0] */ + uintptr(1)*8)), *(*sqlite_int64)(unsafe.Pointer(bp + 88 /* &a[0] */ + uintptr(2)*8)))) + 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)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, z, 0)) sqlite3.Xsqlite3_free(tls, z) - return 0 + return TCL_OK } // Usage: sqlite3_mprintf_long FORMAT INTEGER INTEGER INTEGER @@ -46879,21 +44176,21 @@ func sqlite3_mprintf_long(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc i var z uintptr if argc != 5 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14821 /* " FORMAT INT INT ..." */, 0)) - return 1 + return TCL_ERROR } for i = 2; i < 5; i++ { if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+72 /* &b */ +uintptr((i-2))*4)) != 0 { - return 1 + return TCL_ERROR } *(*int64)(unsafe.Pointer(bp + 88 /* &a[0] */ + uintptr((i-2))*8)) = int64(*(*int32)(unsafe.Pointer(bp + 72 /* &b[0] */ + uintptr((i-2))*4))) *(*int64)(unsafe.Pointer(bp + 88 /* &a */ + uintptr((i-2))*8)) &= int64(((u64((uint64(1))) << (uint64(unsafe.Sizeof(int32(0))) * uint64(8))) - uint64(1))) } - z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), libc.VaList(bp+32, *(*int64)(unsafe.Pointer(bp + 88 /* &a[0] */ + uintptr(0)*8)), *(*int64)(unsafe.Pointer(bp + 88 /* &a[0] */ + uintptr(1)*8)), *(*int64)(unsafe.Pointer(bp + 88 /* &a[0] */ + uintptr(2)*8)))) + 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)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, z, 0)) sqlite3.Xsqlite3_free(tls, z) - return 0 + return TCL_OK } // Usage: sqlite3_mprintf_str FORMAT INTEGER INTEGER STRING @@ -46908,24 +44205,24 @@ func sqlite3_mprintf_str(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc in var i int32 var z uintptr if (argc < 4) || (argc > 5) { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14881 /* " FORMAT INT INT ..." */, 0)) - return 1 + return TCL_ERROR } for i = 2; i < 4; i++ { if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+72 /* &a */ +uintptr((i-2))*4)) != 0 { - return 1 + return TCL_ERROR } } - z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(0)*4)), *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(1)*4)), func() uintptr { + 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 { if argc > 4 { - return *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)) + return *(*uintptr)(unsafe.Pointer(argv + 4*8)) } return uintptr(0) }())) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, z, 0)) sqlite3.Xsqlite3_free(tls, z) - return 0 + return TCL_OK } // Usage: sqlite3_snprintf_str INTEGER FORMAT INTEGER INTEGER STRING @@ -46942,32 +44239,32 @@ func sqlite3_snprintf_str(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc i var z uintptr if (argc < 5) || (argc > 6) { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14907 /* " INT FORMAT INT ..." */, 0)) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+88 /* &n */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+88 /* &n */) != 0 { + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 88 /* n */)) < 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+14937 /* "N must be non-ne..." */, 0)) - return 1 + return TCL_ERROR } for i = 3; i < 5; i++ { if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+92 /* &a */ +uintptr((i-3))*4)) != 0 { - return 1 + return TCL_ERROR } } z = sqlite3.Xsqlite3_malloc(tls, (*(*int32)(unsafe.Pointer(bp + 88 /* n */)) + 1)) - sqlite3.Xsqlite3_snprintf(tls, *(*int32)(unsafe.Pointer(bp + 88 /* n */)), z, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), libc.VaList(bp+48, *(*int32)(unsafe.Pointer(bp + 92 /* &a[0] */ + uintptr(0)*4)), *(*int32)(unsafe.Pointer(bp + 92 /* &a[0] */ + uintptr(1)*4)), func() uintptr { + 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 { if argc > 4 { - return *(*uintptr)(unsafe.Pointer(argv + uintptr(5)*8)) + return *(*uintptr)(unsafe.Pointer(argv + 5*8)) } return uintptr(0) }())) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, z, 0)) sqlite3.Xsqlite3_free(tls, z) - return 0 + return TCL_OK } // Usage: sqlite3_mprintf_double FORMAT INTEGER INTEGER DOUBLE @@ -46984,22 +44281,22 @@ func sqlite3_mprintf_double(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc var z uintptr if argc != 5 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14960 /* " FORMAT INT INT ..." */, 0)) - return 1 + return TCL_ERROR } for i = 2; i < 4; i++ { if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+72 /* &a */ +uintptr((i-2))*4)) != 0 { - return 1 + return TCL_ERROR } } - if tcl.XTcl_GetDouble(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)), bp+88 /* &r */) != 0 { - return 1 + if tcl.XTcl_GetDouble(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 4*8)), bp+88 /* &r */) != 0 { + return TCL_ERROR } - z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(0)*4)), *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(1)*4)), *(*float64)(unsafe.Pointer(bp + 88 /* r */)))) + 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 */)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, z, 0)) sqlite3.Xsqlite3_free(tls, z) - return 0 + return TCL_OK } // Usage: sqlite3_mprintf_scaled FORMAT DOUBLE DOUBLE @@ -47016,19 +44313,19 @@ func sqlite3_mprintf_scaled(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc var z uintptr if argc != 4 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14984 /* " FORMAT DOUBLE D..." */, 0)) - return 1 + return TCL_ERROR } for i = 2; i < 4; i++ { if tcl.XTcl_GetDouble(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+56 /* &r */ +uintptr((i-2))*8)) != 0 { - return 1 + return TCL_ERROR } } - z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), libc.VaList(bp+32, (*(*float64)(unsafe.Pointer(bp + 56 /* &r[0] */ + uintptr(0)*8))**(*float64)(unsafe.Pointer(bp + 56 /* &r[0] */ + uintptr(1)*8))))) + 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))))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, z, 0)) sqlite3.Xsqlite3_free(tls, z) - return 0 + return TCL_OK } // Usage: sqlite3_mprintf_stronly FORMAT STRING @@ -47042,14 +44339,14 @@ func sqlite3_mprintf_stronly(tls *libc.TLS, NotUsed uintptr, interp uintptr, arg var z uintptr if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+15007 /* " FORMAT STRING\"" */, 0)) - return 1 + return TCL_ERROR } - z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, z, 0)) sqlite3.Xsqlite3_free(tls, z) - return 0 + return TCL_OK } // Usage: sqlite3_mprintf_hexdouble FORMAT HEX @@ -47070,21 +44367,21 @@ func sqlite3_mprintf_hexdouble(tls *libc.TLS, NotUsed uintptr, interp uintptr, a // var d sqlite_uint64 at bp+104, 8 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+15007 /* " FORMAT STRING\"" */, 0)) - return 1 + return TCL_ERROR } - if libc.Xsscanf(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), ts+15023 /* "%08x%08x" */, libc.VaList(bp+32, bp+88 /* &x2 */, bp+92 /* &x1 */)) != 2 { + if libc.Xsscanf(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ts+15023 /* "%08x%08x" */, libc.VaList(bp+32, bp+88 /* &x2 */, bp+92 /* &x1 */)) != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+15032 /* "2nd argument sho..." */, 0)) - return 1 + return TCL_ERROR } *(*sqlite_uint64)(unsafe.Pointer(bp + 104 /* d */)) = sqlite_uint64(*(*uint32)(unsafe.Pointer(bp + 88 /* x2 */))) *(*sqlite_uint64)(unsafe.Pointer(bp + 104 /* d */)) = ((*(*sqlite_uint64)(unsafe.Pointer(bp + 104 /* d */)) << 32) + sqlite_uint64(*(*uint32)(unsafe.Pointer(bp + 92 /* x1 */)))) libc.Xmemcpy(tls, bp+96 /* &r */, bp+104 /* &d */, uint64(unsafe.Sizeof(float64(0)))) - z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), libc.VaList(bp+64, *(*float64)(unsafe.Pointer(bp + 96 /* r */)))) + z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), libc.VaList(bp+64, *(*float64)(unsafe.Pointer(bp + 96 /* r */)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, z, 0)) sqlite3.Xsqlite3_free(tls, z) - return 0 + return TCL_OK } // Usage: sqlite3_enable_shared_cache ?BOOLEAN? @@ -47100,22 +44397,22 @@ func test_enable_shared(tls *libc.TLS, clientData ClientData, interp uintptr, ob if (objc != 2) && (objc != 1) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2760 /* "?BOOLEAN?" */) - return 1 + return TCL_ERROR } ret = sqlite3.Xsqlite3Config.FsharedCacheEnabled if objc == 2 { - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &enable */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &enable */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_enable_shared_cache(tls, *(*int32)(unsafe.Pointer(bp /* enable */))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrStr(tls, rc), uintptr(0)) - return 1 + return TCL_ERROR } } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((ret) != 0)))) - return 0 + return TCL_OK } // Usage: sqlite3_extended_result_codes DB BOOLEAN @@ -47130,23 +44427,23 @@ func test_extended_result_codes(tls *libc.TLS, clientData ClientData, interp uin if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15076 /* "DB BOOLEAN" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+8 /* &enable */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &enable */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_extended_result_codes(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), *(*int32)(unsafe.Pointer(bp + 8 /* enable */))) - return 0 + return TCL_OK } // Usage: sqlite3_libversion_number // func test_libversion_number(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:1587:26: */ tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_libversion_number(tls))) - return 0 + return TCL_OK } // Usage: sqlite3_table_column_metadata DB dbname tblname colname @@ -47174,15 +44471,15 @@ func test_table_column_metadata(tls *libc.TLS, clientData ClientData, interp uin if (objc != 5) && (objc != 4) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15087 /* "DB dbname tblnam..." */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+16 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0 { + return TCL_ERROR } - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - zTbl = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + zTbl = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) if objc == 5 { - zCol = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8))) + zCol = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) } else { zCol = uintptr(0) } @@ -47194,9 +44491,9 @@ func test_table_column_metadata(tls *libc.TLS, clientData ClientData, interp uin rc = sqlite3.Xsqlite3_table_column_metadata(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), zDb, zTbl, zCol, bp+24 /* &zDatatype */, bp+32 /* &zCollseq */, bp+40 /* ¬null */, bp+44 /* &primarykey */, bp+48 /* &autoincrement */) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */))), 0)) - return 1 + return TCL_ERROR } pRet = tcl.XTcl_NewObj(tls) @@ -47207,7 +44504,7 @@ func test_table_column_metadata(tls *libc.TLS, clientData ClientData, interp uin tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 48 /* autoincrement */)))) tcl.XTcl_SetObjResult(tls, interp, pRet) - return 0 + return TCL_OK } func blobHandleFromObj(tls *libc.TLS, interp uintptr, pObj uintptr, ppBlob uintptr) int32 { /* test1.c:1652:26: */ @@ -47228,17 +44525,17 @@ func blobHandleFromObj(tls *libc.TLS, interp uintptr, pObj uintptr, ppBlob uintp channel = tcl.XTcl_GetChannel(tls, interp, z, bp+4 /* ¬Used */) if !(channel != 0) { - return 1 + return TCL_ERROR } tcl.XTcl_Flush(tls, channel) - tcl.XTcl_Seek(tls, channel, int64(0), 0) + tcl.XTcl_Seek(tls, channel, int64(0), SEEK_SET) instanceData = tcl.XTcl_GetChannelInstanceData(tls, channel) *(*uintptr)(unsafe.Pointer(ppBlob)) = *(*uintptr)(unsafe.Pointer(instanceData)) } - return 0 + return TCL_OK } func test_blob_reopen(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:1681:26: */ @@ -47253,26 +44550,26 @@ func test_blob_reopen(tls *libc.TLS, clientData ClientData, interp uintptr, objc if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15113 /* "CHANNEL ROWID" */) - return 1 + return TCL_ERROR } - if blobHandleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &pBlob */) != 0 { - return 1 + if blobHandleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &pBlob */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+8 /* &iRowid */) != 0 { - return 1 + if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &iRowid */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_blob_reopen(tls, *(*uintptr)(unsafe.Pointer(bp /* pBlob */)), *(*Tcl_WideInt)(unsafe.Pointer(bp + 8 /* iRowid */))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) } return func() int32 { - if rc == 0 { - return 0 + if rc == SQLITE_OK { + return TCL_OK } - return 1 + return TCL_ERROR }() } @@ -47291,8 +44588,8 @@ type TestCollationX = TestCollationX1 /* test1.c:1720:31 */ func testCreateCollationDel(tls *libc.TLS, pCtx uintptr) { /* test1.c:1721:13: */ var p uintptr = pCtx - var rc int32 = tcl.XTcl_EvalObjEx(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp, (*TestCollationX)(unsafe.Pointer(p)).FpDel, (0x040000 | 0x020000)) - if rc != 0 { + var rc int32 = tcl.XTcl_EvalObjEx(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp, (*TestCollationX)(unsafe.Pointer(p)).FpDel, (TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL)) + if rc != TCL_OK { tcl.XTcl_BackgroundError(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp) } @@ -47323,8 +44620,8 @@ func testCreateCollationCmp(tls *libc.TLS, pCtx uintptr, nLeft int32, zLeft uint tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pScript, tcl.XTcl_NewStringObj(tls, zLeft, nLeft)) tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pScript, tcl.XTcl_NewStringObj(tls, zRight, nRight)) - if (0 != tcl.XTcl_EvalObjEx(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp, pScript, (0x040000|0x020000))) || - (0 != tcl.XTcl_GetIntFromObj(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp, tcl.XTcl_GetObjResult(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp), bp /* &iRes */)) { + if (TCL_OK != tcl.XTcl_EvalObjEx(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp, pScript, (TCL_EVAL_DIRECT|TCL_EVAL_GLOBAL))) || + (TCL_OK != tcl.XTcl_GetIntFromObj(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp, tcl.XTcl_GetObjResult(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp), bp /* &iRes */)) { tcl.XTcl_BackgroundError(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp) } for ok := true; ok; ok = 0 != 0 { @@ -47348,33 +44645,33 @@ func test_create_collation_v2(tls *libc.TLS, clientData ClientData, interp uintp if objc != 5 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15127 /* "DB-HANDLE NAME C..." */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+16 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0 { + return TCL_ERROR } p = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(TestCollationX{}))) - (*TestCollationX)(unsafe.Pointer(p)).FpCmp = *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)) - (*TestCollationX)(unsafe.Pointer(p)).FpDel = *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)) + (*TestCollationX)(unsafe.Pointer(p)).FpCmp = *(*uintptr)(unsafe.Pointer(objv + 3*8)) + (*TestCollationX)(unsafe.Pointer(p)).FpDel = *(*uintptr)(unsafe.Pointer(objv + 4*8)) (*TestCollationX)(unsafe.Pointer(p)).Finterp = interp (*Tcl_Obj)(unsafe.Pointer((*TestCollationX)(unsafe.Pointer(p)).FpCmp)).FrefCount++ (*Tcl_Obj)(unsafe.Pointer((*TestCollationX)(unsafe.Pointer(p)).FpDel)).FrefCount++ - rc = sqlite3.Xsqlite3_create_collation_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), 16, + rc = sqlite3.Xsqlite3_create_collation_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), 16, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{testCreateCollationCmp})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testCreateCollationDel}))) - if rc != 21 { + if rc != SQLITE_MISUSE { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+15160 /* "sqlite3_create_c..." */, uintptr(0))) - return 1 + return TCL_ERROR } - rc = sqlite3.Xsqlite3_create_collation_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), 1, + 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, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{testCreateCollationCmp})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testCreateCollationDel}))) - return 0 + return TCL_OK } // USAGE: sqlite3_create_function_v2 DB NAME NARG ENC ?SWITCHES? @@ -47417,7 +44714,7 @@ func cf2Destroy(tls *libc.TLS, pUser uintptr) { /* test1.c:1818:13: */ if ((*CreateFunctionV2)(unsafe.Pointer(p)).Finterp != 0) && ((*CreateFunctionV2)(unsafe.Pointer(p)).FpDestroy != 0) { var rc int32 = tcl.XTcl_EvalObjEx(tls, (*CreateFunctionV2)(unsafe.Pointer(p)).Finterp, (*CreateFunctionV2)(unsafe.Pointer(p)).FpDestroy, 0) - if rc != 0 { + if rc != TCL_OK { tcl.XTcl_BackgroundError(tls, (*CreateFunctionV2)(unsafe.Pointer(p)).Finterp) } } @@ -47473,41 +44770,29 @@ func test_create_function_v2(tls *libc.TLS, clientData ClientData, interp uintpt var rc int32 *(*[6]EncTable)(unsafe.Pointer(bp + 32 /* aEnc */)) = [6]EncTable{ - { - FzEnc: ts + 15225, /* "utf8" */ - Fenc: 1}, - { - FzEnc: ts + 15230, /* "utf16" */ - Fenc: 4}, - { - FzEnc: ts + 15236, /* "utf16le" */ - Fenc: 2}, - { - FzEnc: ts + 15244, /* "utf16be" */ - Fenc: 3}, - { - FzEnc: ts + 12285, /* "any" */ - Fenc: 5}, - { - FzEnc: ts + 13695, /* "0" */ - Fenc: 0}, + {FzEnc: ts + 15225 /* "utf8" */, Fenc: SQLITE_UTF8}, + {FzEnc: ts + 15230 /* "utf16" */, Fenc: SQLITE_UTF16}, + {FzEnc: ts + 15236 /* "utf16le" */, Fenc: SQLITE_UTF16LE}, + {FzEnc: ts + 15244 /* "utf16be" */, Fenc: SQLITE_UTF16BE}, + {FzEnc: ts + 12285 /* "any" */, Fenc: SQLITE_ANY}, + {FzEnc: ts + 13695 /* "0" */}, } if (objc < 5) || ((objc % 2) == 0) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15252 /* "DB NAME NARG ENC..." */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+16 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0 { + return TCL_ERROR } - zFunc = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+24 /* &nArg */) != 0 { - return 1 + zFunc = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+24 /* &nArg */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+32 /* &aEnc[0] */, int32(unsafe.Sizeof(EncTable{})), + if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+32 /* &aEnc[0] */, int32(unsafe.Sizeof(EncTable{})), ts+15281 /* "encoding" */, 0, bp+128 /* &enc */) != 0 { - return 1 + return TCL_ERROR } *(*int32)(unsafe.Pointer(bp + 128 /* enc */)) = (*EncTable)(unsafe.Pointer(bp + 32 /* &aEnc */ + uintptr(*(*int32)(unsafe.Pointer(bp + 128 /* enc */)))*16)).Fenc @@ -47522,7 +44807,7 @@ func test_create_function_v2(tls *libc.TLS, clientData ClientData, interp uintpt *(*[5]uintptr)(unsafe.Pointer(bp + 136 /* azSwitch */)) = [5]uintptr{ts + 15290 /* "-func" */, ts + 15296 /* "-step" */, ts + 15302 /* "-final" */, ts + 15309 /* "-destroy" */, uintptr(0)} if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+136 /* &azSwitch[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+15318 /* "switch" */, 0, bp+176 /* &iSwitch */) != 0 { sqlite3.Xsqlite3_free(tls, p) - return 1 + return TCL_ERROR } switch *(*int32)(unsafe.Pointer(bp + 176 /* iSwitch */)) { @@ -47590,12 +44875,12 @@ func test_create_function_v2(tls *libc.TLS, clientData ClientData, interp uintpt return uintptr(0) }(), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{cf2Destroy}))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_ResetResult(tls, interp) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } type EncTable = struct { @@ -47623,38 +44908,38 @@ func test_load_extension(tls *libc.TLS, clientData ClientData, interp uintptr, o if (objc != 4) && (objc != 3) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15325 /* "DB-HANDLE FILE ?..." */) - return 1 + return TCL_ERROR } - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if objc == 4 { - zProc = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + zProc = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) } // Extract the C database handle from the Tcl command name if !(tcl.XTcl_GetCommandInfo(tls, interp, zDb, bp+24 /* &cmdInfo */) != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14361 /* "command not foun..." */, zDb, uintptr(0))) - return 1 + return TCL_ERROR } db = (*struct{ Fdb uintptr })(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp + 24 /* &cmdInfo */)).FobjClientData)).Fdb // Call the underlying C function. If an error occurs, set rc to // TCL_ERROR and load any error string into the interpreter. If no // error occurs, set rc to TCL_OK. - rc = 1 + rc = SQLITE_ERROR zErr = sqlite3.Xsqlite3_mprintf(tls, ts+15347 /* "this build omits..." */, 0) _ = zProc _ = zFile - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetResult(tls, interp, func() uintptr { if zErr != 0 { return zErr } return ts + 488 /* "" */ }(), uintptr(1)) - rc = 1 + rc = TCL_ERROR } else { - rc = 0 + rc = TCL_OK } sqlite3.Xsqlite3_free(tls, zErr) @@ -47675,24 +44960,24 @@ func test_enable_load(tls *libc.TLS, clientData ClientData, interp uintptr, objc if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15389 /* "DB-HANDLE ONOFF" */) - return 1 + return TCL_ERROR } - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) // Extract the C database handle from the Tcl command name if !(tcl.XTcl_GetCommandInfo(tls, interp, zDb, bp+32 /* &cmdInfo */) != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14361 /* "command not foun..." */, zDb, uintptr(0))) - return 1 + return TCL_ERROR } db = (*struct{ Fdb uintptr })(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp + 32 /* &cmdInfo */)).FobjClientData)).Fdb // Get the onoff parameter - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+96 /* &onoff */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+96 /* &onoff */) != 0 { + return TCL_ERROR } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+15347 /* "this build omits..." */)) - return 1 + return TCL_ERROR } // Usage: sqlite_abort @@ -47703,7 +44988,7 @@ func test_enable_load(tls *libc.TLS, clientData ClientData, interp uintptr, objc func sqlite_abort(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:2024:26: */ libc.Xexit(tls, 255) // This will always fail - return 0 + return TCL_OK } // The following routine is a user-defined SQL function whose purpose @@ -47714,33 +44999,33 @@ __1: if !(argc >= 2) { goto __2 } - zArg0 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zArg0 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if !(zArg0 != 0) { goto __3 } if !(0 == sqlite3.Xsqlite3StrICmp(tls, zArg0, ts+2437 /* "int" */)) { goto __5 } - sqlite3.Xsqlite3_result_int(tls, context, sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) + sqlite3.Xsqlite3_result_int(tls, context, sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) goto __6 __5: if !(sqlite3.Xsqlite3StrICmp(tls, zArg0, ts+3787 /* "int64" */) == 0) { goto __7 } - sqlite3.Xsqlite3_result_int64(tls, context, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) + sqlite3.Xsqlite3_result_int64(tls, context, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) goto __8 __7: if !(sqlite3.Xsqlite3StrICmp(tls, zArg0, ts+15405 /* "string" */) == 0) { goto __9 } - sqlite3.Xsqlite3_result_text(tls, context, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))), -1, + sqlite3.Xsqlite3_result_text(tls, context, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))), -1, libc.UintptrFromInt32(-1)) goto __10 __9: if !(sqlite3.Xsqlite3StrICmp(tls, zArg0, ts+2422 /* "double" */) == 0) { goto __11 } - sqlite3.Xsqlite3_result_double(tls, context, sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) + sqlite3.Xsqlite3_result_double(tls, context, sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) goto __12 __11: if !(sqlite3.Xsqlite3StrICmp(tls, zArg0, ts+7207 /* "null" */) == 0) { @@ -47752,7 +45037,7 @@ __13: if !(sqlite3.Xsqlite3StrICmp(tls, zArg0, ts+15412 /* "value" */) == 0) { goto __15 } - sqlite3.Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))))*8))) + sqlite3.Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))))*8))) goto __16 __15: goto error_out @@ -47796,25 +45081,25 @@ func test_register_func(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int var rc int32 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+15486 /* " DB FUNCTION-NAM..." */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+48 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+48 /* &db */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), -1, 1, uintptr(0), + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), -1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{testFunc})), uintptr(0), uintptr(0)) if rc != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrStr(tls, rc), 0)) - return 1 + return TCL_ERROR } if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_finalize STMT @@ -47831,12 +45116,12 @@ func test_finalize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+15504 /* " " */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15504 /* " " */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } if *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) != 0 { @@ -47845,9 +45130,9 @@ func test_finalize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) if (db != 0) && (sqlite3TestErrCode(tls, interp, db, rc) != 0) { - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_stmt_status STMT CODE RESETFLAG @@ -47867,12 +45152,12 @@ func test_stmt_status(tls *libc.TLS, clientData uintptr, interp uintptr, objc in if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15512 /* "STMT PARAMETER R..." */) - return 1 + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { + return TCL_ERROR } - zOpName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zOpName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) for i = 0; i < (int32(uint64(unsafe.Sizeof(aOp)) / uint64(unsafe.Sizeof(struct { FzName uintptr Fop int32 @@ -47888,16 +45173,16 @@ func test_stmt_status(tls *libc.TLS, clientData uintptr, interp uintptr, objc in Fop int32 _ [4]byte }{})))) { - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+8 /* &op */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &op */) != 0 { + return TCL_ERROR } } - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+12 /* &resetFlag */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+12 /* &resetFlag */) != 0 { + return TCL_ERROR } iValue = sqlite3.Xsqlite3_stmt_status(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 8 /* op */)), *(*int32)(unsafe.Pointer(bp + 12 /* resetFlag */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, iValue)) - return 0 + return TCL_OK } var aOp = [7]struct { @@ -47905,27 +45190,13 @@ var aOp = [7]struct { Fop int32 _ [4]byte }{ - { - FzName: ts + 15537, /* "SQLITE_STMTSTATU..." */ - Fop: 1}, - { - FzName: ts + 15569, /* "SQLITE_STMTSTATU..." */ - Fop: 2}, - { - FzName: ts + 15592, /* "SQLITE_STMTSTATU..." */ - Fop: 3}, - { - FzName: ts + 15620, /* "SQLITE_STMTSTATU..." */ - Fop: 4}, - { - FzName: ts + 15646, /* "SQLITE_STMTSTATU..." */ - Fop: 5}, - { - FzName: ts + 15674, /* "SQLITE_STMTSTATU..." */ - Fop: 6}, - { - FzName: ts + 15696, /* "SQLITE_STMTSTATU..." */ - Fop: 99}, + {FzName: ts + 15537 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_FULLSCAN_STEP}, + {FzName: ts + 15569 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_SORT}, + {FzName: ts + 15592 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_AUTOINDEX}, + {FzName: ts + 15620 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_VM_STEP}, + {FzName: ts + 15646 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_REPREPARE}, + {FzName: ts + 15674 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_RUN}, + {FzName: ts + 15696 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_MEMUSED}, } /* test1.c:2158:5 */ // Usage: sqlite3_config_sorterref @@ -47939,13 +45210,13 @@ func test_config_sorterref(tls *libc.TLS, clientData uintptr, interp uintptr, ob if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15722 /* "NBYTE" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+8 /* &iVal */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8 /* &iVal */) != 0 { + return TCL_ERROR } - sqlite3.Xsqlite3_config(tls, 28, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* iVal */)))) - return 0 + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_SORTERREF_SIZE, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* iVal */)))) + return TCL_OK } // Usage: vfs_current_time_int64 @@ -47960,11 +45231,11 @@ func vfsCurrentTimeInt64(tls *libc.TLS, clientData uintptr, interp uintptr, objc var pVfs uintptr = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pVfs + 136 /* &.xCurrentTimeInt64 */))))(tls, pVfs, bp /* &t */) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, *(*i64)(unsafe.Pointer(bp /* t */)))) - return 0 + return TCL_OK } // Usage: sqlite3_snapshot_get DB DBNAME @@ -47980,26 +45251,26 @@ func test_snapshot_get(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15728 /* "DB DBNAME" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) rc = sqlite3.Xsqlite3_snapshot_get(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zName, bp+8 /* &pSnapshot */) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 1 + return TCL_ERROR } else { // var zBuf [100]int8 at bp+16, 100 if sqlite3TestMakePointerStr(tls, interp, bp+16 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 8 /* pSnapshot */))) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, bp+16 /* &zBuf[0] */, -1)) } - return 0 + return TCL_OK } // Usage: sqlite3_snapshot_recover DB DBNAME @@ -48014,21 +45285,21 @@ func test_snapshot_recover(tls *libc.TLS, clientData uintptr, interp uintptr, ob if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15728 /* "DB DBNAME" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) rc = sqlite3.Xsqlite3_snapshot_recover(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zName) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 1 + return TCL_ERROR } else { tcl.XTcl_ResetResult(tls, interp) } - return 0 + return TCL_OK } // Usage: sqlite3_snapshot_open DB DBNAME SNAPSHOT @@ -48044,22 +45315,22 @@ func test_snapshot_open(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15738 /* "DB DBNAME SNAPSH..." */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - pSnapshot = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)))) + zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + pSnapshot = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)))) rc = sqlite3.Xsqlite3_snapshot_open(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zName, pSnapshot) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 1 + return TCL_ERROR } else { tcl.XTcl_ResetResult(tls, interp) } - return 0 + return TCL_OK } // Usage: sqlite3_snapshot_free SNAPSHOT @@ -48067,11 +45338,11 @@ func test_snapshot_free(tls *libc.TLS, clientData uintptr, interp uintptr, objc var pSnapshot uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15757 /* "SNAPSHOT" */) - return 1 + return TCL_ERROR } - pSnapshot = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + pSnapshot = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) sqlite3.Xsqlite3_snapshot_free(tls, pSnapshot) - return 0 + return TCL_OK } // Usage: sqlite3_snapshot_cmp SNAPSHOT1 SNAPSHOT2 @@ -48081,13 +45352,13 @@ func test_snapshot_cmp(tls *libc.TLS, clientData uintptr, interp uintptr, objc i var p2 uintptr if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15766 /* "SNAPSHOT1 SNAPSH..." */) - return 1 + return TCL_ERROR } - p1 = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) - p2 = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)))) + p1 = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) + p2 = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)))) res = sqlite3.Xsqlite3_snapshot_cmp(tls, p1, p2) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, res)) - return 0 + return TCL_OK } // Usage: sqlite3_snapshot_get_blob DB DBNAME @@ -48103,23 +45374,23 @@ func test_snapshot_get_blob(tls *libc.TLS, clientData uintptr, interp uintptr, o if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15728 /* "DB DBNAME" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) rc = sqlite3.Xsqlite3_snapshot_get(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zName, bp+8 /* &pSnapshot */) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 1 + return TCL_ERROR } else { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pSnapshot */)), int32(unsafe.Sizeof(sqlite3_snapshot{})))) sqlite3.Xsqlite3_snapshot_free(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pSnapshot */))) } - return 0 + return TCL_OK } // Usage: sqlite3_snapshot_open_blob DB DBNAME SNAPSHOT @@ -48136,23 +45407,23 @@ func test_snapshot_open_blob(tls *libc.TLS, clientData uintptr, interp uintptr, if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15738 /* "DB DBNAME SNAPSH..." */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+16 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0 { + return TCL_ERROR } - zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - pBlob = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+24 /* &nBlob */) + zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + pBlob = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+24 /* &nBlob */) if (uint64(*(*int32)(unsafe.Pointer(bp + 24 /* nBlob */))) != uint64(unsafe.Sizeof(sqlite3_snapshot{}))) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+15786 /* "bad SNAPSHOT" */, 0)) - return 1 + return TCL_ERROR } rc = sqlite3.Xsqlite3_snapshot_open(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), zName, pBlob) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_snapshot_cmp_blob SNAPSHOT1 SNAPSHOT2 @@ -48169,20 +45440,20 @@ func test_snapshot_cmp_blob(tls *libc.TLS, clientData uintptr, interp uintptr, o if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15766 /* "SNAPSHOT1 SNAPSH..." */) - return 1 + return TCL_ERROR } - p1 = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+16 /* &n1 */) - p2 = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+20 /* &n2 */) + p1 = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &n1 */) + p2 = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+20 /* &n2 */) 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 */))) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+15786 /* "bad SNAPSHOT" */, 0)) - return 1 + return TCL_ERROR } res = sqlite3.Xsqlite3_snapshot_cmp(tls, p1, p2) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, res)) - return 0 + return TCL_OK } // in test_delete.c @@ -48191,13 +45462,13 @@ func test_delete_database(tls *libc.TLS, clientData uintptr, interp uintptr, obj var zFile uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15799 /* "FILE" */) - return 1 + return TCL_ERROR } - zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) rc = sqlite3_delete_database(tls, zFile) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 0 + return TCL_OK } // Usage: atomic_batch_write PATH @@ -48214,26 +45485,26 @@ func test_atomic_batch_write(tls *libc.TLS, clientData uintptr, interp uintptr, if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15804 /* "PATH" */) - return 1 + return TCL_ERROR } - zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) rc = sqlite3.Xsqlite3_open(tls, zFile, bp+16 /* &db */) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */))), 0)) sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */))) - return 1 + return TCL_ERROR } - rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+84 /* "main" */, 7, bp+24 /* &pFd */) + rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+84 /* "main" */, SQLITE_FCNTL_FILE_POINTER, bp+24 /* &pFd */) 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 */))) - if (dc & 0x00004000) != 0 { + if (dc & SQLITE_IOCAP_BATCH_ATOMIC) != 0 { bRes = 1 } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, bRes)) sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */))) - return 0 + return TCL_OK } // Usage: sqlite3_next_stmt DB STMT @@ -48250,24 +45521,24 @@ func test_next_stmt(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+15809 /* " DB STMT" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15809 /* " DB STMT" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+48 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), bp+56 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+56 /* &pStmt */) != 0 { + return TCL_ERROR } *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)) = sqlite3.Xsqlite3_next_stmt(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) if *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)) != 0 { if sqlite3TestMakePointerStr(tls, interp, bp+64 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+64 /* &zBuf[0] */, 0)) } - return 0 + return TCL_OK } // Usage: sqlite3_stmt_readonly STMT @@ -48284,16 +45555,16 @@ func test_stmt_readonly(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+15818 /* " STMT" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15818 /* " STMT" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_stmt_readonly(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((rc) != 0)))) - return 0 + return TCL_OK } // Usage: sqlite3_stmt_isexplain STMT @@ -48310,16 +45581,16 @@ func test_stmt_isexplain(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+15818 /* " STMT" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15818 /* " STMT" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_stmt_isexplain(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } // Usage: sqlite3_stmt_busy STMT @@ -48336,16 +45607,16 @@ func test_stmt_busy(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+15818 /* " STMT" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15818 /* " STMT" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_stmt_busy(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((rc) != 0)))) - return 0 + return TCL_OK } // Usage: uses_stmt_journal STMT @@ -48359,16 +45630,16 @@ func uses_stmt_journal(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+15818 /* " STMT" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15818 /* " STMT" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_stmt_readonly(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((int32(*(*uint16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) + 200 /* &.usesStmtJournal */))&0x40>>6)) != 0)))) - return 0 + return TCL_OK } // Usage: sqlite3_reset STMT @@ -48384,24 +45655,24 @@ func test_reset(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, o if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+15504 /* " " */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15504 /* " " */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) if (*(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) != 0) && (sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))), rc) != 0) { - return 1 + return TCL_ERROR } tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) // // if( rc ){ // return TCL_ERROR; // } - return 0 + return TCL_OK } // Usage: sqlite3_expired STMT @@ -48415,14 +45686,14 @@ func test_expired(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+15504 /* " " */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15504 /* " " */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((sqlite3.Xsqlite3_expired(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)))) != 0)))) - return 0 + return TCL_OK } // Usage: sqlite3_transfer_bindings FROMSTMT TOSTMT @@ -48438,18 +45709,18 @@ func test_transfer_bind(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+15824 /* " FROM-STMT TO-ST..." */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15824 /* " FROM-STMT TO-ST..." */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt1 */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt1 */) != 0 { + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), bp+40 /* &pStmt2 */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+40 /* &pStmt2 */) != 0 { + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_transfer_bindings(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt1 */)), *(*uintptr)(unsafe.Pointer(bp + 40 /* pStmt2 */))))) - return 0 + return TCL_OK } // Usage: sqlite3_changes DB @@ -48464,14 +45735,14 @@ func test_changes(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+14503 /* " DB" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+14503 /* " DB" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_changes(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))))) - return 0 + return TCL_OK } // This is the "static_bind_value" that variables are bound to when @@ -48498,43 +45769,43 @@ func test_bind(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv // var idx int32 at bp+88, 4 if argc != 5 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+15843 /* " VM IDX VALUE (n..." */, 0)) - return 1 + return TCL_ERROR } - if getStmtPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+80 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+80 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+88 /* &idx */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+88 /* &idx */) != 0 { + return TCL_ERROR } - if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)), ts+7207 /* "null" */) == 0 { + if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), ts+7207 /* "null" */) == 0 { rc = sqlite3.Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 88 /* idx */))) - } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)), ts+15879 /* "static" */) == 0 { + } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), ts+15879 /* "static" */) == 0 { 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)) - } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)), ts+15886 /* "static-nbytes" */) == 0 { + } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), ts+15886 /* "static-nbytes" */) == 0 { rc = sqlite3.Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 88 /* idx */)), sqlite_static_bind_value, sqlite_static_bind_nbyte, uintptr(0)) - } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)), ts+15900 /* "normal" */) == 0 { - rc = sqlite3.Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 88 /* idx */)), *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)), -1, libc.UintptrFromInt32(-1)) - } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)), ts+15907 /* "blob10" */) == 0 { + } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), ts+15900 /* "normal" */) == 0 { + 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)) + } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), ts+15907 /* "blob10" */) == 0 { rc = sqlite3.Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 88 /* idx */)), ts+15914 /* "abc\x00xyz\x00pq" */, 10, uintptr(0)) } else { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+15925 /* "4th argument sho..." */, 0)) - return 1 + return TCL_ERROR } if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */))), rc) != 0 { - return 1 + return TCL_ERROR } if rc != 0 { // var zBuf [50]int8 at bp+92, 50 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+92 /* &zBuf[0] */, ts+15979 /* "(%d) " */, libc.VaList(bp+48, rc)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+92 /* &zBuf[0] */, sqlite3.Xsqlite3ErrStr(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: add_test_collate @@ -48581,13 +45852,13 @@ func test_collate_func(tls *libc.TLS, pCtx uintptr, nA int32, zA uintptr, nB int (*Tcl_Obj)(unsafe.Pointer(pX)).FrefCount++ switch encin { - case 1: + case SQLITE_UTF8: tcl.XTcl_ListObjAppendElement(tls, i, pX, tcl.XTcl_NewStringObj(tls, ts+15998 /* "UTF-8" */, -1)) break - case 2: + case SQLITE_UTF16LE: tcl.XTcl_ListObjAppendElement(tls, i, pX, tcl.XTcl_NewStringObj(tls, ts+16004 /* "UTF-16LE" */, -1)) break - case 3: + case SQLITE_UTF16BE: tcl.XTcl_ListObjAppendElement(tls, i, pX, tcl.XTcl_NewStringObj(tls, ts+16013 /* "UTF-16BE" */, -1)) break default: @@ -48639,21 +45910,21 @@ func test_collate(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, __1: ; pTestCollateInterp = interp - if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+48 /* &db */) != 0) { + if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0) { goto __2 } - return 1 + return TCL_ERROR __2: ; - if !(0 != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+56 /* &val */)) { + if !(TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+56 /* &val */)) { goto __3 } - return 1 + return TCL_ERROR __3: ; - rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), ts+15985 /* "test_collate" */, 1, - uintptr(1), func() uintptr { + rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), ts+15985 /* "test_collate" */, SQLITE_UTF8, + SQLITE_UTF8, func() uintptr { if *(*int32)(unsafe.Pointer(bp + 56 /* val */)) != 0 { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 @@ -48661,17 +45932,17 @@ __3: } return uintptr(0) }()) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __4 } - if !(0 != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+56 /* &val */)) { + if !(TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+56 /* &val */)) { goto __5 } - return 1 + return TCL_ERROR __5: ; - rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), ts+15985 /* "test_collate" */, 2, - uintptr(2), func() uintptr { + rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), ts+15985 /* "test_collate" */, SQLITE_UTF16LE, + SQLITE_UTF16LE, func() uintptr { if *(*int32)(unsafe.Pointer(bp + 56 /* val */)) != 0 { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 @@ -48679,25 +45950,25 @@ __5: } return uintptr(0) }()) - if !(0 != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+56 /* &val */)) { + if !(TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+56 /* &val */)) { goto __6 } - return 1 + return TCL_ERROR __6: ; sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 48 /* db */)))).Fmutex) pVal = sqlite3.Xsqlite3ValueNew(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))) - sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, ts+15985 /* "test_collate" */, uint8(1), uintptr(0)) - zUtf16 = sqlite3.Xsqlite3ValueText(tls, pVal, uint8(2)) + sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, ts+15985 /* "test_collate" */, SQLITE_UTF8, uintptr(0)) + zUtf16 = sqlite3.Xsqlite3ValueText(tls, pVal, SQLITE_UTF16LE) if !((*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 48 /* db */)))).FmallocFailed != 0) { goto __7 } - rc = 7 + rc = SQLITE_NOMEM goto __8 __7: - rc = sqlite3.Xsqlite3_create_collation16(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zUtf16, 3, - uintptr(3), func() uintptr { + rc = sqlite3.Xsqlite3_create_collation16(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zUtf16, SQLITE_UTF16BE, + SQLITE_UTF16BE, func() uintptr { if *(*int32)(unsafe.Pointer(bp + 56 /* val */)) != 0 { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 @@ -48714,23 +45985,23 @@ __4: if !(sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), rc) != 0) { goto __9 } - return 1 + return TCL_ERROR __9: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __10 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR __10: ; - return 0 + return TCL_OK bad_args: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+16022 /* " @@ -48766,28 +46037,28 @@ func test_utf16bin_collate(tls *libc.TLS, clientData uintptr, interp uintptr, ob goto bad_args __1: ; - if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0) { + if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) { goto __2 } - return 1 + return TCL_ERROR __2: ; - rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+16055 /* "utf16bin" */, 4, uintptr(0), + rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+16055 /* "utf16bin" */, SQLITE_UTF16, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{test_utf16bin_collate_func}))) if !(sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp /* db */)), rc) != 0) { goto __3 } - return 1 + return TCL_ERROR __3: ; - return 0 + return TCL_OK bad_args: tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } // When the collation needed callback is invoked, record the name of @@ -48805,7 +46076,7 @@ func test_collate_needed_cb(tls *libc.TLS, pCtx uintptr, db uintptr, eTextRep in var z uintptr z = pName i = 0 - for ; (*(*int8)(unsafe.Pointer(z)) != 0) || (*(*int8)(unsafe.Pointer(z + uintptr(1))) != 0); z++ { + for ; (*(*int8)(unsafe.Pointer(z)) != 0) || (*(*int8)(unsafe.Pointer(z + 1)) != 0); z++ { if *(*int8)(unsafe.Pointer(z)) != 0 { zNeededCollation[libc.PostIncInt32(&i, 1)] = *(*int8)(unsafe.Pointer(z)) } @@ -48832,10 +46103,10 @@ func test_collate_needed(tls *libc.TLS, clientData uintptr, interp uintptr, objc goto bad_args __1: ; - if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0) { + if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) { goto __2 } - return 1 + return TCL_ERROR __2: ; rc = sqlite3.Xsqlite3_collation_needed16(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { @@ -48845,14 +46116,14 @@ __2: if !(sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp /* db */)), rc) != 0) { goto __3 } - return 1 + return TCL_ERROR __3: ; - return 0 + return TCL_OK bad_args: tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } // tclcmd: add_alignment_test_collations DB @@ -48897,19 +46168,19 @@ func add_alignment_test_collations(tls *libc.TLS, clientData uintptr, interp uin // var db uintptr at bp, 8 if objc >= 2 { - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+16064 /* "utf16_unaligned" */, 4, + sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+16064 /* "utf16_unaligned" */, SQLITE_UTF16, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{alignmentCollFunc}))) - sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+16080 /* "utf16_aligned" */, 8, + sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+16080 /* "utf16_aligned" */, SQLITE_UTF16_ALIGNED, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{alignmentCollFunc}))) } - return 0 + return SQLITE_OK } // Usage: add_test_function @@ -48944,7 +46215,7 @@ func test_function_utf8(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { (*Tcl_Obj)(unsafe.Pointer(pX)).FrefCount++ tcl.XTcl_ListObjAppendElement(tls, interp, pX, tcl.XTcl_NewStringObj(tls, ts+15998 /* "UTF-8" */, -1)) tcl.XTcl_ListObjAppendElement(tls, interp, pX, - tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))), -1)) + tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), -1)) tcl.XTcl_EvalObjEx(tls, interp, pX, 0) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pX @@ -48955,7 +46226,7 @@ func test_function_utf8(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { sqlite3.Xsqlite3_result_text(tls, pCtx, tcl.XTcl_GetStringResult(tls, interp), -1, libc.UintptrFromInt32(-1)) pVal = sqlite3.Xsqlite3ValueNew(tls, uintptr(0)) sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, tcl.XTcl_GetStringResult(tls, interp), - uint8(1), uintptr(0)) + SQLITE_UTF8, uintptr(0)) sqlite3.Xsqlite3_result_text16be(tls, pCtx, sqlite3.Xsqlite3_value_text16be(tls, pVal), -1, libc.UintptrFromInt32(-1)) sqlite3.Xsqlite3ValueFree(tls, pVal) @@ -48970,7 +46241,7 @@ func test_function_utf16le(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr (*Tcl_Obj)(unsafe.Pointer(pX)).FrefCount++ tcl.XTcl_ListObjAppendElement(tls, interp, pX, tcl.XTcl_NewStringObj(tls, ts+16004 /* "UTF-16LE" */, -1)) tcl.XTcl_ListObjAppendElement(tls, interp, pX, - tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))), -1)) + tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), -1)) tcl.XTcl_EvalObjEx(tls, interp, pX, 0) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pX @@ -48980,7 +46251,7 @@ func test_function_utf16le(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr } pVal = sqlite3.Xsqlite3ValueNew(tls, uintptr(0)) sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, tcl.XTcl_GetStringResult(tls, interp), - uint8(1), uintptr(0)) + SQLITE_UTF8, uintptr(0)) sqlite3.Xsqlite3_result_text(tls, pCtx, sqlite3.Xsqlite3_value_text(tls, pVal), -1, libc.UintptrFromInt32(-1)) sqlite3.Xsqlite3ValueFree(tls, pVal) } @@ -48994,7 +46265,7 @@ func test_function_utf16be(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr (*Tcl_Obj)(unsafe.Pointer(pX)).FrefCount++ tcl.XTcl_ListObjAppendElement(tls, interp, pX, tcl.XTcl_NewStringObj(tls, ts+16013 /* "UTF-16BE" */, -1)) tcl.XTcl_ListObjAppendElement(tls, interp, pX, - tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))), -1)) + tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), -1)) tcl.XTcl_EvalObjEx(tls, interp, pX, 0) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pX @@ -49004,7 +46275,7 @@ func test_function_utf16be(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr } pVal = sqlite3.Xsqlite3ValueNew(tls, uintptr(0)) sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, tcl.XTcl_GetStringResult(tls, interp), - uint8(1), uintptr(0)) + SQLITE_UTF8, uintptr(0)) sqlite3.Xsqlite3_result_text16(tls, pCtx, sqlite3.Xsqlite3_value_text16le(tls, pVal), -1, libc.UintptrFromInt32(-1)) sqlite3.Xsqlite3_result_text16be(tls, pCtx, sqlite3.Xsqlite3_value_text16le(tls, pVal), @@ -49028,64 +46299,64 @@ func test_function(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 goto bad_args __1: ; - if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &db */) != 0) { + if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0) { goto __2 } - return 1 + return TCL_ERROR __2: ; - if !(0 != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &val */)) { + if !(TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &val */)) { goto __3 } - return 1 + return TCL_ERROR __3: ; if !(*(*int32)(unsafe.Pointer(bp + 40 /* val */)) != 0) { goto __4 } - sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+16094 /* "test_function" */, 1, 1, + sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+16094 /* "test_function" */, 1, SQLITE_UTF8, interp, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{test_function_utf8})), uintptr(0), uintptr(0)) __4: ; - if !(0 != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+40 /* &val */)) { + if !(TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+40 /* &val */)) { goto __5 } - return 1 + return TCL_ERROR __5: ; if !(*(*int32)(unsafe.Pointer(bp + 40 /* val */)) != 0) { goto __6 } - sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+16094 /* "test_function" */, 1, 2, + sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+16094 /* "test_function" */, 1, SQLITE_UTF16LE, interp, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{test_function_utf16le})), uintptr(0), uintptr(0)) __6: ; - if !(0 != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+40 /* &val */)) { + if !(TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+40 /* &val */)) { goto __7 } - return 1 + return TCL_ERROR __7: ; if !(*(*int32)(unsafe.Pointer(bp + 40 /* val */)) != 0) { goto __8 } - sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+16094 /* "test_function" */, 1, 3, + sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+16094 /* "test_function" */, 1, SQLITE_UTF16BE, interp, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{test_function_utf16be})), uintptr(0), uintptr(0)) __8: ; - return 0 + return TCL_OK bad_args: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+16022 /* " @@ -49101,14 +46372,14 @@ func test_errstr(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16108 /* "" */) } - zCode = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zCode = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) for i = 0; i < 200; i++ { if 0 == libc.Xstrcmp(tls, sqlite3.Xsqlite3ErrName(tls, i), zCode) { break } } tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrStr(tls, i), uintptr(0)) - return 0 + return TCL_OK } // Usage: breakpoint @@ -49123,7 +46394,7 @@ func test_errstr(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, // Then run testfixture in the debugger and wait for the breakpoint to // fire. Then additional breakpoints can be set to trace down the bug. func test_breakpoint(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:3404:26: */ - return 0 // Do nothing + return TCL_OK // Do nothing } // Usage: sqlite3_bind_zeroblob STMT IDX N @@ -49145,28 +46416,28 @@ func test_bind_zeroblob(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16121 /* "STMT IDX N" */) - return 1 + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+8 /* &idx */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &idx */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+12 /* &n */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+12 /* &n */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_bind_zeroblob(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 8 /* idx */)), *(*int32)(unsafe.Pointer(bp + 12 /* n */))) if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))), rc) != 0 { - return 1 + return TCL_ERROR } - if rc != 0 { - return 1 + if rc != SQLITE_OK { + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_bind_zeroblob64 STMT IDX N @@ -49188,29 +46459,29 @@ func test_bind_zeroblob64(tls *libc.TLS, clientData uintptr, interp uintptr, obj if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16121 /* "STMT IDX N" */) - return 1 + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+16 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+24 /* &idx */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+24 /* &idx */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+32 /* &n */) != 0 { - return 1 + if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+32 /* &n */) != 0 { + return TCL_ERROR } 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 */)))) if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))), rc) != 0 { - return 1 + return TCL_ERROR } - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_bind_int STMT N VALUE @@ -49232,29 +46503,29 @@ func test_bind_int(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 if objc != 4 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+16132 /* " STMT N VALUE" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16132 /* " STMT N VALUE" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &idx */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &idx */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+44 /* &value */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+44 /* &value */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_bind_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* idx */)), *(*int32)(unsafe.Pointer(bp + 44 /* value */))) if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))), rc) != 0 { - return 1 + return TCL_ERROR } - if rc != 0 { - return 1 + if rc != SQLITE_OK { + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: intarray_addr INT ... @@ -49272,18 +46543,18 @@ func test_intarray_addr(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc > 1 { p = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(int32(0))) * (uint64(objc - 1))))) if p == uintptr(0) { - return 1 + return TCL_ERROR } for i = 0; i < (objc - 1); i++ { if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((1+i))*8)), (p+uintptr(i)*4)) != 0 { sqlite3.Xsqlite3_free(tls, p) p = uintptr(0) - return 1 + return TCL_ERROR } } } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, int64(p))) - return 0 + return TCL_OK } var p uintptr = uintptr(0) /* test1.c:3540:14 */ @@ -49306,7 +46577,7 @@ func test_int64array_addr(tls *libc.TLS, clientData uintptr, interp uintptr, obj if objc > 1 { p1 = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(sqlite3_int64(0))) * (uint64(objc - 1))))) if p1 == uintptr(0) { - return 1 + return TCL_ERROR } for i = 0; i < (objc - 1); i++ { // var v Tcl_WideInt at bp, 8 @@ -49314,13 +46585,13 @@ func test_int64array_addr(tls *libc.TLS, clientData uintptr, interp uintptr, obj if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((1+i))*8)), bp /* &v */) != 0 { sqlite3.Xsqlite3_free(tls, p1) p1 = uintptr(0) - return 1 + return TCL_ERROR } *(*sqlite3_int64)(unsafe.Pointer(p1 + uintptr(i)*8)) = *(*Tcl_WideInt)(unsafe.Pointer(bp /* v */)) } } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, int64(p1))) - return 0 + return TCL_OK } var p1 uintptr = uintptr(0) /* test1.c:3574:24 */ @@ -49340,18 +46611,18 @@ func test_doublearray_addr(tls *libc.TLS, clientData uintptr, interp uintptr, ob if objc > 1 { p2 = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(float64(0))) * (uint64(objc - 1))))) if p2 == uintptr(0) { - return 1 + return TCL_ERROR } for i = 0; i < (objc - 1); i++ { if tcl.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((1+i))*8)), (p2+uintptr(i)*8)) != 0 { sqlite3.Xsqlite3_free(tls, p2) p2 = uintptr(0) - return 1 + return TCL_ERROR } } } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, int64(p2))) - return 0 + return TCL_OK } var p2 uintptr = uintptr(0) /* test1.c:3610:17 */ @@ -49377,7 +46648,7 @@ func test_textarray_addr(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc > 1 { p3 = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(uintptr(0))) * (uint64(objc - 1))))) if p3 == uintptr(0) { - return 1 + return TCL_ERROR } for i = 0; i < (objc - 1); i++ { *(*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))))) @@ -49385,7 +46656,7 @@ func test_textarray_addr(tls *libc.TLS, clientData uintptr, interp uintptr, objc } n = (objc - 1) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, int64(p3))) - return 0 + return TCL_OK } var n int32 = 0 /* test1.c:3644:14 */ @@ -49410,29 +46681,29 @@ func test_bind_int64(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if objc != 4 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+16132 /* " STMT N VALUE" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16132 /* " STMT N VALUE" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &idx */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &idx */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+48 /* &value */) != 0 { - return 1 + if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+48 /* &value */) != 0 { + return TCL_ERROR } 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 */))) if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))), rc) != 0 { - return 1 + return TCL_ERROR } - if rc != 0 { - return 1 + if rc != SQLITE_OK { + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_bind_double STMT N VALUE @@ -49455,22 +46726,22 @@ func test_bind_double(tls *libc.TLS, clientData uintptr, interp uintptr, objc in if objc != 4 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+16132 /* " STMT N VALUE" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16132 /* " STMT N VALUE" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &idx */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &idx */) != 0 { + return TCL_ERROR } // Intercept the string "NaN" and generate a NaN value for it. // All other strings are passed through to Tcl_GetDoubleFromObj(). // Tcl_GetDoubleFromObj() should understand "NaN" but some versions // contain a bug. - zVal = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + zVal = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aSpecialFp)) / uint64(unsafe.Sizeof(struct { FzName uintptr FiUpper uint32 @@ -49491,18 +46762,18 @@ func test_bind_double(tls *libc.TLS, clientData uintptr, interp uintptr, objc in FzName uintptr FiUpper uint32 FiLower uint32 - }{})))) && (tcl.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+48 /* &value */) != 0) { - return 1 + }{})))) && (tcl.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+48 /* &value */) != 0) { + return TCL_ERROR } rc = sqlite3.Xsqlite3_bind_double(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* idx */)), *(*float64)(unsafe.Pointer(bp + 48 /* value */))) if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))), rc) != 0 { - return 1 + return TCL_ERROR } - if rc != 0 { - return 1 + if rc != SQLITE_OK { + return TCL_ERROR } - return 0 + return TCL_OK } var aSpecialFp = [10]struct { @@ -49510,46 +46781,16 @@ var aSpecialFp = [10]struct { FiUpper uint32 FiLower uint32 }{ - { - FzName: ts + 16146, /* "NaN" */ - FiUpper: uint32(0x7fffffff), - FiLower: 0xffffffff}, - { - FzName: ts + 16150, /* "SNaN" */ - FiUpper: uint32(0x7ff7ffff), - FiLower: 0xffffffff}, - { - FzName: ts + 16155, /* "-NaN" */ - FiUpper: 0xffffffff, - FiLower: 0xffffffff}, - { - FzName: ts + 16160, /* "-SNaN" */ - FiUpper: 0xfff7ffff, - FiLower: 0xffffffff}, - { - FzName: ts + 16166, /* "+Inf" */ - FiUpper: uint32(0x7ff00000), - FiLower: uint32(0x00000000)}, - { - FzName: ts + 16171, /* "-Inf" */ - FiUpper: 0xfff00000, - FiLower: uint32(0x00000000)}, - { - FzName: ts + 16176, /* "Epsilon" */ - FiUpper: uint32(0x00000000), - FiLower: uint32(0x00000001)}, - { - FzName: ts + 16184, /* "-Epsilon" */ - FiUpper: 0x80000000, - FiLower: uint32(0x00000001)}, - { - FzName: ts + 16193, /* "NaN0" */ - FiUpper: uint32(0x7ff80000), - FiLower: uint32(0x00000000)}, - { - FzName: ts + 16198, /* "-NaN0" */ - FiUpper: 0xfff80000, - FiLower: uint32(0x00000000)}, + {FzName: ts + 16146 /* "NaN" */, FiUpper: uint32(0x7fffffff), FiLower: 0xffffffff}, + {FzName: ts + 16150 /* "SNaN" */, FiUpper: uint32(0x7ff7ffff), FiLower: 0xffffffff}, + {FzName: ts + 16155 /* "-NaN" */, FiUpper: 0xffffffff, FiLower: 0xffffffff}, + {FzName: ts + 16160 /* "-SNaN" */, FiUpper: 0xfff7ffff, FiLower: 0xffffffff}, + {FzName: ts + 16166 /* "+Inf" */, FiUpper: uint32(0x7ff00000)}, + {FzName: ts + 16171 /* "-Inf" */, FiUpper: 0xfff00000}, + {FzName: ts + 16176 /* "Epsilon" */, FiLower: uint32(0x00000001)}, + {FzName: ts + 16184 /* "-Epsilon" */, FiUpper: 0x80000000, FiLower: uint32(0x00000001)}, + {FzName: ts + 16193 /* "NaN0" */, FiUpper: uint32(0x7ff80000)}, + {FzName: ts + 16198 /* "-NaN0" */, FiUpper: 0xfff80000}, } /* test1.c:3724:5 */ // Usage: sqlite3_bind_null STMT N @@ -49569,26 +46810,26 @@ func test_bind_null(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+16204 /* " STMT N" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16204 /* " STMT N" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &idx */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &idx */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* idx */))) if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))), rc) != 0 { - return 1 + return TCL_ERROR } - if rc != 0 { - return 1 + if rc != SQLITE_OK { + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_bind_text STMT N STRING BYTES @@ -49612,31 +46853,31 @@ func test_bind_text(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if objc != 5 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+16212 /* " STMT N VALUE BY..." */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16212 /* " STMT N VALUE BY..." */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+48 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+56 /* &idx */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+56 /* &idx */) != 0 { + return TCL_ERROR } - value = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+60 /* &bytes */) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+60 /* &bytes */) != 0 { - return 1 + value = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+60 /* &bytes */) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+60 /* &bytes */) != 0 { + return TCL_ERROR } 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)) if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* pStmt */))), rc) != 0 { - return 1 + return TCL_ERROR } - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_bind_text16 ?-static? STMT N STRING BYTES @@ -49671,31 +46912,31 @@ func test_bind_text16(tls *libc.TLS, clientData uintptr, interp uintptr, objc in if (objc != 5) && (objc != 6) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+16212 /* " STMT N VALUE BY..." */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16212 /* " STMT N VALUE BY..." */, 0)) + return TCL_ERROR } if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, oStmt), bp+48 /* &pStmt */) != 0 { - return 1 + return TCL_ERROR } if tcl.XTcl_GetIntFromObj(tls, interp, oN, bp+56 /* &idx */) != 0 { - return 1 + return TCL_ERROR } value = tcl.XTcl_GetByteArrayFromObj(tls, oString, uintptr(0)) if tcl.XTcl_GetIntFromObj(tls, interp, oBytes, bp+60 /* &bytes */) != 0 { - return 1 + return TCL_ERROR } 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) if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* pStmt */))), rc) != 0 { - return 1 + return TCL_ERROR } - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_bind_blob ?-static? STMT N DATA BYTES @@ -49721,8 +46962,8 @@ func test_bind_blob(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if (objc != 5) && (objc != 6) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+16232 /* " STMT N DATA BYT..." */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16232 /* " STMT N DATA BYT..." */, 0)) + return TCL_ERROR } if objc == 6 { @@ -49730,16 +46971,16 @@ func test_bind_blob(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 objv += 8 } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+64 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+64 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+72 /* &idx */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+72 /* &idx */) != 0 { + return TCL_ERROR } - value = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+76 /* &len */) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+80 /* &bytes */) != 0 { - return 1 + value = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+76 /* &len */) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+80 /* &bytes */) != 0 { + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 80 /* bytes */)) > *(*int32)(unsafe.Pointer(bp + 76 /* len */)) { @@ -49748,18 +46989,18 @@ func test_bind_blob(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([200]int8{})), bp+84, /* &zBuf[0] */ ts+16251 /* "cannot use %d bl..." */, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 80 /* bytes */)), *(*int32)(unsafe.Pointer(bp + 76 /* len */)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, bp+84 /* &zBuf[0] */, -1)) - return 1 + return TCL_ERROR } 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) if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */))), rc) != 0 { - return 1 + return TCL_ERROR } - if rc != 0 { - return 1 + if rc != SQLITE_OK { + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_bind_parameter_count STMT @@ -49773,13 +47014,13 @@ func test_bind_parameter_count(tls *libc.TLS, clientData uintptr, interp uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16285 /* "STMT" */) - return 1 + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_bind_parameter_count(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))))) - return 0 + return TCL_OK } // Usage: sqlite3_bind_parameter_name STMT N @@ -49797,17 +47038,17 @@ func test_bind_parameter_name(tls *libc.TLS, clientData uintptr, interp uintptr, if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16290 /* "STMT N" */) - return 1 + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+8 /* &i */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &i */) != 0 { + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_bind_parameter_name(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 8 /* i */))), -1)) - return 0 + return TCL_OK } // Usage: sqlite3_bind_parameter_index STMT NAME @@ -49822,15 +47063,15 @@ func test_bind_parameter_index(tls *libc.TLS, clientData uintptr, interp uintptr if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16297 /* "STMT NAME" */) - return 1 + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, - sqlite3.Xsqlite3_bind_parameter_index(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)))))) - return 0 + sqlite3.Xsqlite3_bind_parameter_index(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)))))) + return TCL_OK } // Usage: sqlite3_clear_bindings STMT @@ -49843,13 +47084,13 @@ func test_clear_bindings(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16285 /* "STMT" */) - return 1 + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_clear_bindings(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))))) - return 0 + return TCL_OK } // Usage: sqlite3_sleep MILLISECONDS @@ -49861,13 +47102,13 @@ func test_sleep(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, o if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+12628 /* "MILLISECONDS" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &ms */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &ms */) != 0 { + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_sleep(tls, *(*int32)(unsafe.Pointer(bp /* ms */))))) - return 0 + return TCL_OK } // Usage: sqlite3_extended_errcode DB @@ -49884,15 +47125,15 @@ func test_ex_errcode(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+14503 /* " DB" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+14503 /* " DB" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+48 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_extended_errcode(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 0 + return TCL_OK } // Usage: sqlite3_errcode DB @@ -49909,15 +47150,15 @@ func test_errcode(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+14503 /* " DB" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+14503 /* " DB" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+48 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_errcode(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 0 + return TCL_OK } // Usage: sqlite3_errmsg DB @@ -49934,16 +47175,16 @@ func test_errmsg(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+14503 /* " DB" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+14503 /* " DB" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { + return TCL_ERROR } zErr = sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, zErr, -1)) - return 0 + return TCL_OK } // Usage: test_errmsg16 DB @@ -49964,11 +47205,11 @@ func test_errmsg16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+14503 /* " DB" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+14503 /* " DB" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { + return TCL_ERROR } zErr = sqlite3.Xsqlite3_errmsg16(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))) @@ -49978,7 +47219,7 @@ func test_errmsg16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 } } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, zErr, bytes)) - return 0 + return TCL_OK } // Usage: sqlite3_prepare DB sql bytes ?tailvar? @@ -50004,15 +47245,15 @@ func test_prepare(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if (objc != 5) && (objc != 4) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16307 /* " DB sql bytes ?t..." */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16307 /* " DB sql bytes ?t..." */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+80 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+80 /* &db */) != 0 { + return TCL_ERROR } - zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+88 /* &bytes */) != 0 { - return 1 + zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+88 /* &bytes */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_prepare(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), zSql, *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)), bp+96 /* &pStmt */, func() uintptr { @@ -50023,7 +47264,7 @@ func test_prepare(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, }()) tcl.XTcl_ResetResult(tls, interp) if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } if (*(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)) != 0) && (objc >= 5) { if *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) >= 0 { @@ -50032,22 +47273,22 @@ func test_prepare(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)))) < *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) { *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)))) } - tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), uintptr(0), tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)), *(*int32)(unsafe.Pointer(bp + 88 /* bytes */))), 0) + 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) } - if rc != 0 { + if rc != SQLITE_OK { sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+112 /* &zBuf[0] */, ts+15979 /* "(%d) " */, libc.VaList(bp+32, rc)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+112 /* &zBuf[0] */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */))), 0)) - return 1 + return TCL_ERROR } if *(*uintptr)(unsafe.Pointer(bp + 96 /* pStmt */)) != 0 { if sqlite3TestMakePointerStr(tls, interp, bp+112 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 96 /* pStmt */))) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, bp+112 /* &zBuf[0] */, 0)) } - return 0 + return TCL_OK } // Usage: sqlite3_prepare_v2 DB sql bytes ?tailvar? @@ -50075,15 +47316,15 @@ func test_prepare_v2(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if (objc != 5) && (objc != 4) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16331 /* " DB sql bytes ta..." */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16331 /* " DB sql bytes ta..." */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+80 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+80 /* &db */) != 0 { + return TCL_ERROR } - zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+88 /* &bytes */) != 0 { - return 1 + zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+88 /* &bytes */) != 0 { + return TCL_ERROR } // Instead of using zSql directly, make a copy into a buffer obtained @@ -50110,28 +47351,28 @@ func test_prepare_v2(tls *libc.TLS, clientData uintptr, interp uintptr, objc int tcl.XTcl_ResetResult(tls, interp) if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } - if ((rc == 0) && (objc >= 5)) && (*(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)) != 0) { + if ((rc == SQLITE_OK) && (objc >= 5)) && (*(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)) != 0) { if *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) >= 0 { *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) = (*(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) - (int32((int64(*(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */))) - int64(zSql)) / 1))) } - tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), uintptr(0), tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)), *(*int32)(unsafe.Pointer(bp + 88 /* bytes */))), 0) + 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) } - if rc != 0 { + if rc != SQLITE_OK { sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+112 /* &zBuf[0] */, ts+15979 /* "(%d) " */, libc.VaList(bp+32, rc)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+112 /* &zBuf[0] */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */))), 0)) - return 1 + return TCL_ERROR } if *(*uintptr)(unsafe.Pointer(bp + 104 /* pStmt */)) != 0 { if sqlite3TestMakePointerStr(tls, interp, bp+112 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 104 /* pStmt */))) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, bp+112 /* &zBuf[0] */, 0)) } - return 0 + return TCL_OK } // Usage: sqlite3_prepare_v3 DB sql bytes flags ?tailvar? @@ -50161,18 +47402,18 @@ func test_prepare_v3(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if (objc != 6) && (objc != 5) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16353 /* " DB sql bytes fl..." */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16353 /* " DB sql bytes fl..." */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+80 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+80 /* &db */) != 0 { + return TCL_ERROR } - zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+88 /* &bytes */) != 0 { - return 1 + zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+88 /* &bytes */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+92 /* &flags */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+92 /* &flags */) != 0 { + return TCL_ERROR } // Instead of using zSql directly, make a copy into a buffer obtained @@ -50197,28 +47438,28 @@ func test_prepare_v3(tls *libc.TLS, clientData uintptr, interp uintptr, objc int tcl.XTcl_ResetResult(tls, interp) if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } - if ((rc == 0) && (*(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)) != 0)) && (objc >= 6) { + if ((rc == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)) != 0)) && (objc >= 6) { if *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) >= 0 { *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) = (*(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) - (int32((int64(*(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */))) - int64(zSql)) / 1))) } - tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(5)*8)), uintptr(0), tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)), *(*int32)(unsafe.Pointer(bp + 88 /* bytes */))), 0) + 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) } - if rc != 0 { + if rc != SQLITE_OK { sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+112 /* &zBuf[0] */, ts+15979 /* "(%d) " */, libc.VaList(bp+32, rc)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+112 /* &zBuf[0] */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */))), 0)) - return 1 + return TCL_ERROR } if *(*uintptr)(unsafe.Pointer(bp + 104 /* pStmt */)) != 0 { if sqlite3TestMakePointerStr(tls, interp, bp+112 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 104 /* pStmt */))) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, bp+112 /* &zBuf[0] */, 0)) } - return 0 + return TCL_OK } // Usage: sqlite3_prepare_tkt3134 DB @@ -50238,31 +47479,31 @@ func test_prepare_tkt3134(tls *libc.TLS, clientData uintptr, interp uintptr, obj if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16331 /* " DB sql bytes ta..." */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16331 /* " DB sql bytes ta..." */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+80 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+80 /* &db */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), (uintptr(unsafe.Pointer(&zSql)) + uintptr(1)), 0, bp+88 /* &pStmt */, uintptr(0)) + rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), (uintptr(unsafe.Pointer(&zSql)) + 1), 0, bp+88 /* &pStmt */, uintptr(0)) if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } - if rc != 0 { + if rc != SQLITE_OK { sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+96 /* &zBuf[0] */, ts+15979 /* "(%d) " */, libc.VaList(bp+32, rc)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+96 /* &zBuf[0] */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */))), 0)) - return 1 + return TCL_ERROR } if *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */)) != 0 { if sqlite3TestMakePointerStr(tls, interp, bp+96 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */))) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, bp+96 /* &zBuf[0] */, 0)) } - return 0 + return TCL_OK } var zSql = *(*[10]int8)(unsafe.Pointer(ts + 16381 /* "\x00SELECT 1" */)) /* test1.c:4410:21 */ @@ -50293,15 +47534,15 @@ func test_prepare16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if (objc != 5) && (objc != 4) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16307 /* " DB sql bytes ?t..." */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16307 /* " DB sql bytes ?t..." */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+48 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { + return TCL_ERROR } - zSql = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+56 /* &objlen */) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+60 /* &bytes */) != 0 { - return 1 + zSql = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+56 /* &objlen */) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+60 /* &bytes */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_prepare16(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zSql, *(*int32)(unsafe.Pointer(bp + 60 /* bytes */)), bp+64 /* &pStmt */, func() uintptr { @@ -50311,10 +47552,10 @@ func test_prepare16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 return uintptr(0) }()) if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } if rc != 0 { - return 1 + return TCL_ERROR } if objc >= 5 { @@ -50325,7 +47566,7 @@ func test_prepare16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 } pTail = tcl.XTcl_NewByteArrayObj(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* zTail */)), *(*int32)(unsafe.Pointer(bp + 56 /* objlen */))) (*Tcl_Obj)(unsafe.Pointer(pTail)).FrefCount++ - tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), uintptr(0), pTail, 0) + tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), uintptr(0), pTail, 0) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pTail if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -50336,11 +47577,11 @@ func test_prepare16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)) != 0 { if sqlite3TestMakePointerStr(tls, interp, bp+80 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */))) != 0 { - return 1 + return TCL_ERROR } } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+80 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: sqlite3_prepare16_v2 DB sql bytes ?tailvar? @@ -50369,15 +47610,15 @@ func test_prepare16_v2(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if (objc != 5) && (objc != 4) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16307 /* " DB sql bytes ?t..." */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16307 /* " DB sql bytes ?t..." */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+48 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { + return TCL_ERROR } - zSql = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+56 /* &objlen */) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+60 /* &bytes */) != 0 { - return 1 + zSql = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+56 /* &objlen */) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+60 /* &bytes */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_prepare16_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zSql, *(*int32)(unsafe.Pointer(bp + 60 /* bytes */)), bp+64 /* &pStmt */, func() uintptr { @@ -50387,10 +47628,10 @@ func test_prepare16_v2(tls *libc.TLS, clientData uintptr, interp uintptr, objc i return uintptr(0) }()) if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), rc) != 0 { - return 1 + return TCL_ERROR } if rc != 0 { - return 1 + return TCL_ERROR } if objc >= 5 { @@ -50401,7 +47642,7 @@ func test_prepare16_v2(tls *libc.TLS, clientData uintptr, interp uintptr, objc i } pTail = tcl.XTcl_NewByteArrayObj(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* zTail */)), *(*int32)(unsafe.Pointer(bp + 56 /* objlen */))) (*Tcl_Obj)(unsafe.Pointer(pTail)).FrefCount++ - tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), uintptr(0), pTail, 0) + tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), uintptr(0), pTail, 0) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pTail if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -50412,11 +47653,11 @@ func test_prepare16_v2(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)) != 0 { if sqlite3TestMakePointerStr(tls, interp, bp+80 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */))) != 0 { - return 1 + return TCL_ERROR } } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+80 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: sqlite3_open filename ?options-list? @@ -50431,22 +47672,22 @@ func test_open(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, ob if ((objc != 3) && (objc != 2)) && (objc != 1) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16391 /* " filename option..." */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16391 /* " filename option..." */, 0)) + return TCL_ERROR } if objc > 1 { - zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) } else { zFilename = uintptr(0) } sqlite3.Xsqlite3_open(tls, zFilename, bp+48 /* &db */) if sqlite3TestMakePointerStr(tls, interp, bp+56 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+56 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: sqlite3_open_v2 FILENAME FLAGS VFS @@ -50470,84 +47711,46 @@ func test_open_v2(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16414 /* "FILENAME FLAGS V..." */) - return 1 + return TCL_ERROR } - zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) - if int32(*(*int8)(unsafe.Pointer(zVfs + uintptr(0)))) == 0x00 { + zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) + if int32(*(*int8)(unsafe.Pointer(zVfs))) == 0x00 { zVfs = uintptr(0) } - rc = tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+16 /* &nFlag */, bp+24 /* &apFlag */) - if rc != 0 { + rc = tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+16 /* &nFlag */, bp+24 /* &apFlag */) + if rc != TCL_OK { return rc } for i = 0; i < *(*int32)(unsafe.Pointer(bp + 16 /* nFlag */)); i++ { // var iFlag int32 at bp+352, 4 *(*[20]OpenFlag)(unsafe.Pointer(bp + 32 /* aFlag */)) = [20]OpenFlag{ - { - FzFlag: ts + 16433, /* "SQLITE_OPEN_READ..." */ - Fflag: 0x00000001}, - { - FzFlag: ts + 16454, /* "SQLITE_OPEN_READ..." */ - Fflag: 0x00000002}, - { - FzFlag: ts + 16476, /* "SQLITE_OPEN_CREA..." */ - Fflag: 0x00000004}, - { - FzFlag: ts + 16495, /* "SQLITE_OPEN_DELE..." */ - Fflag: 0x00000008}, - { - FzFlag: ts + 16521, /* "SQLITE_OPEN_EXCL..." */ - Fflag: 0x00000010}, - { - FzFlag: ts + 16543, /* "SQLITE_OPEN_AUTO..." */ - Fflag: 0x00000020}, - { - FzFlag: ts + 16565, /* "SQLITE_OPEN_MAIN..." */ - Fflag: 0x00000100}, - { - FzFlag: ts + 16585, /* "SQLITE_OPEN_TEMP..." */ - Fflag: 0x00000200}, - { - FzFlag: ts + 16605, /* "SQLITE_OPEN_TRAN..." */ - Fflag: 0x00000400}, - { - FzFlag: ts + 16630, /* "SQLITE_OPEN_MAIN..." */ - Fflag: 0x00000800}, - { - FzFlag: ts + 16655, /* "SQLITE_OPEN_TEMP..." */ - Fflag: 0x00001000}, - { - FzFlag: ts + 16680, /* "SQLITE_OPEN_SUBJ..." */ - Fflag: 0x00002000}, - { - FzFlag: ts + 16703, /* "SQLITE_OPEN_SUPE..." */ - Fflag: 0x00004000}, - { - FzFlag: ts + 16729, /* "SQLITE_OPEN_NOMU..." */ - Fflag: 0x00008000}, - { - FzFlag: ts + 16749, /* "SQLITE_OPEN_FULL..." */ - Fflag: 0x00010000}, - { - FzFlag: ts + 16771, /* "SQLITE_OPEN_SHAR..." */ - Fflag: 0x00020000}, - { - FzFlag: ts + 16795, /* "SQLITE_OPEN_PRIV..." */ - Fflag: 0x00040000}, - { - FzFlag: ts + 16820, /* "SQLITE_OPEN_WAL" */ - Fflag: 0x00080000}, - { - FzFlag: ts + 16836, /* "SQLITE_OPEN_URI" */ - Fflag: 0x00000040}, + {FzFlag: ts + 16433 /* "SQLITE_OPEN_READ..." */, Fflag: SQLITE_OPEN_READONLY}, + {FzFlag: ts + 16454 /* "SQLITE_OPEN_READ..." */, Fflag: SQLITE_OPEN_READWRITE}, + {FzFlag: ts + 16476 /* "SQLITE_OPEN_CREA..." */, Fflag: SQLITE_OPEN_CREATE}, + {FzFlag: ts + 16495 /* "SQLITE_OPEN_DELE..." */, Fflag: SQLITE_OPEN_DELETEONCLOSE}, + {FzFlag: ts + 16521 /* "SQLITE_OPEN_EXCL..." */, Fflag: SQLITE_OPEN_EXCLUSIVE}, + {FzFlag: ts + 16543 /* "SQLITE_OPEN_AUTO..." */, Fflag: SQLITE_OPEN_AUTOPROXY}, + {FzFlag: ts + 16565 /* "SQLITE_OPEN_MAIN..." */, Fflag: SQLITE_OPEN_MAIN_DB}, + {FzFlag: ts + 16585 /* "SQLITE_OPEN_TEMP..." */, Fflag: SQLITE_OPEN_TEMP_DB}, + {FzFlag: ts + 16605 /* "SQLITE_OPEN_TRAN..." */, Fflag: SQLITE_OPEN_TRANSIENT_DB}, + {FzFlag: ts + 16630 /* "SQLITE_OPEN_MAIN..." */, Fflag: SQLITE_OPEN_MAIN_JOURNAL}, + {FzFlag: ts + 16655 /* "SQLITE_OPEN_TEMP..." */, Fflag: SQLITE_OPEN_TEMP_JOURNAL}, + {FzFlag: ts + 16680 /* "SQLITE_OPEN_SUBJ..." */, Fflag: SQLITE_OPEN_SUBJOURNAL}, + {FzFlag: ts + 16703 /* "SQLITE_OPEN_SUPE..." */, Fflag: SQLITE_OPEN_SUPER_JOURNAL}, + {FzFlag: ts + 16729 /* "SQLITE_OPEN_NOMU..." */, Fflag: SQLITE_OPEN_NOMUTEX}, + {FzFlag: ts + 16749 /* "SQLITE_OPEN_FULL..." */, Fflag: SQLITE_OPEN_FULLMUTEX}, + {FzFlag: ts + 16771 /* "SQLITE_OPEN_SHAR..." */, Fflag: SQLITE_OPEN_SHAREDCACHE}, + {FzFlag: ts + 16795 /* "SQLITE_OPEN_PRIV..." */, Fflag: SQLITE_OPEN_PRIVATECACHE}, + {FzFlag: ts + 16820 /* "SQLITE_OPEN_WAL" */, Fflag: SQLITE_OPEN_WAL}, + {FzFlag: ts + 16836 /* "SQLITE_OPEN_URI" */, Fflag: SQLITE_OPEN_URI}, {}, } 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{})), ts+16852 /* "flag" */, 0, bp+352 /* &iFlag */) - if rc != 0 { + if rc != TCL_OK { return rc } flags = flags | ((*OpenFlag)(unsafe.Pointer(bp + 32 /* &aFlag */ + uintptr(*(*int32)(unsafe.Pointer(bp + 352 /* iFlag */)))*16)).Fflag) @@ -50555,10 +47758,10 @@ func test_open_v2(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, rc = sqlite3.Xsqlite3_open_v2(tls, zFilename, bp+360 /* &db */, flags, zVfs) if sqlite3TestMakePointerStr(tls, interp, bp+368 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 360 /* db */))) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, bp+368 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } type OpenFlag = struct { @@ -50579,18 +47782,18 @@ func test_open16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16391 /* " filename option..." */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16391 /* " filename option..." */, 0)) + return TCL_ERROR } - zFilename = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), uintptr(0)) + zFilename = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(0)) sqlite3.Xsqlite3_open16(tls, zFilename, bp+48 /* &db */) if sqlite3TestMakePointerStr(tls, interp, bp+56 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+56 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: sqlite3_complete16 @@ -50602,12 +47805,12 @@ func test_complete16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16857 /* "" */) - return 1 + return TCL_ERROR } - zBuf = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), uintptr(0)) + zBuf = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(0)) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_complete16(tls, zBuf))) - return 0 + return TCL_OK } // Usage: sqlite3_normalize SQL @@ -50619,16 +47822,16 @@ func test_normalize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+9992 /* "SQL" */) - return 1 + return TCL_ERROR } - zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) zNorm = sqlite3_normalize(tls, zSql) if zNorm != 0 { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, zNorm, -1)) sqlite3.Xsqlite3_free(tls, zNorm) } - return 0 + return TCL_OK } // Usage: sqlite3_step STMT @@ -50644,18 +47847,18 @@ func test_step(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, ob if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+15818 /* " STMT" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+15818 /* " STMT" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) // if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR; tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } func test_sql(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4767:26: */ @@ -50666,14 +47869,14 @@ func test_sql(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, obj if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16285 /* "STMT" */) - return 1 + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { + return TCL_ERROR } tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_sql(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))), uintptr(1)) - return 0 + return TCL_OK } func test_ex_sql(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4784:26: */ @@ -50686,16 +47889,16 @@ func test_ex_sql(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16285 /* "STMT" */) - return 1 + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { + return TCL_ERROR } z = sqlite3.Xsqlite3_expanded_sql(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) tcl.XTcl_SetResult(tls, interp, z, uintptr(1)) sqlite3.Xsqlite3_free(tls, z) - return 0 + return TCL_OK } // Usage: sqlite3_column_count STMT @@ -50709,16 +47912,16 @@ func test_column_count(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16870 /* " STMT column" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16870 /* " STMT column" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))))) - return 0 + return TCL_OK } // Usage: sqlite3_column_type STMT column @@ -50736,39 +47939,39 @@ func test_column_type(tls *libc.TLS, clientData uintptr, interp uintptr, objc in if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16870 /* " STMT column" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16870 /* " STMT column" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &col */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { + return TCL_ERROR } tp = sqlite3.Xsqlite3_column_type(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) switch tp { - case 1: + case SQLITE_INTEGER: tcl.XTcl_SetResult(tls, interp, ts+2273 /* "INTEGER" */, uintptr(0)) break - case 5: + case SQLITE_NULL: tcl.XTcl_SetResult(tls, interp, ts+5537 /* "NULL" */, uintptr(0)) break - case 2: + case SQLITE_FLOAT: tcl.XTcl_SetResult(tls, interp, ts+16883 /* "FLOAT" */, uintptr(0)) break - case 3: + case SQLITE_TEXT: tcl.XTcl_SetResult(tls, interp, ts+16889 /* "TEXT" */, uintptr(0)) break - case 4: + case SQLITE_BLOB: tcl.XTcl_SetResult(tls, interp, ts+16894 /* "BLOB" */, uintptr(0)) break default: } - return 0 + return TCL_OK } // Usage: sqlite3_column_int64 STMT column @@ -50787,20 +47990,20 @@ func test_column_int64(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16870 /* " STMT column" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16870 /* " STMT column" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &col */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { + return TCL_ERROR } iVal = sqlite3.Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, iVal)) - return 0 + return TCL_OK } // Usage: sqlite3_column_blob STMT column @@ -50817,21 +48020,21 @@ func test_column_blob(tls *libc.TLS, clientData uintptr, interp uintptr, objc in if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16870 /* " STMT column" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16870 /* " STMT column" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &col */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { + return TCL_ERROR } len = sqlite3.Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) pBlob = sqlite3.Xsqlite3_column_blob(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, pBlob, len)) - return 0 + return TCL_OK } // Usage: sqlite3_column_double STMT column @@ -50849,20 +48052,20 @@ func test_column_double(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16870 /* " STMT column" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16870 /* " STMT column" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &col */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { + return TCL_ERROR } rVal = sqlite3.Xsqlite3_column_double(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewDoubleObj(tls, rVal)) - return 0 + return TCL_OK } // Usage: sqlite3_data_count STMT @@ -50876,16 +48079,16 @@ func test_data_count(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16870 /* " STMT column" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16870 /* " STMT column" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_data_count(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))))) - return 0 + return TCL_OK } // Usage: sqlite3_column_text STMT column @@ -50907,32 +48110,32 @@ func test_stmt_utf8(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 xFunc = clientData if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16870 /* " STMT column" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16870 /* " STMT column" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &col */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { + return TCL_ERROR } zRet = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(&xFunc)))(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) if zRet != 0 { tcl.XTcl_SetResult(tls, interp, zRet, uintptr(0)) } - return 0 + return TCL_OK } func test_global_recover(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5045:26: */ var rc int32 if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } rc = sqlite3.Xsqlite3_global_recover(tls) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // Usage: sqlite3_column_text STMT column @@ -50955,15 +48158,15 @@ func test_stmt_utf16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int xFunc = clientData if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16870 /* " STMT column" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16870 /* " STMT column" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &col */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { + return TCL_ERROR } zName16 = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(&xFunc)))(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) @@ -50976,7 +48179,7 @@ func test_stmt_utf16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int tcl.XTcl_SetObjResult(tls, interp, pRet) } - return 0 + return TCL_OK } // Usage: sqlite3_column_int STMT column @@ -50998,19 +48201,19 @@ func test_stmt_int(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 xFunc = clientData if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16870 /* " STMT column" */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16870 /* " STMT column" */, 0)) + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &col */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { + return TCL_ERROR } 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 */))))) - return 0 + return TCL_OK } // Usage: sqlite_set_magic DB MAGIC-NUMBER @@ -51023,25 +48226,25 @@ func sqlite_set_magic(tls *libc.TLS, clientData uintptr, interp uintptr, argc in // var db uintptr at bp+32, 8 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+16899 /* " DB MAGIC" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { + return TCL_ERROR } - if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), ts+16909 /* "SQLITE_MAGIC_OPE..." */) == 0 { - (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmagic = 0xa029a697 - } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), ts+16927 /* "SQLITE_MAGIC_CLO..." */) == 0 { - (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmagic = 0x9f3c2d33 - } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), ts+16947 /* "SQLITE_MAGIC_BUS..." */) == 0 { - (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmagic = 0xf03b7906 - } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), ts+16965 /* "SQLITE_MAGIC_ERR..." */) == 0 { - (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmagic = 0xb5357930 - } else if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), (*(*uintptr)(unsafe.Pointer(bp + 32 /* db */))+112 /* &.magic */)) != 0 { - return 1 + if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ts+16909 /* "SQLITE_MAGIC_OPE..." */) == 0 { + (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmagic = SQLITE_MAGIC_OPEN + } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ts+16927 /* "SQLITE_MAGIC_CLO..." */) == 0 { + (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmagic = SQLITE_MAGIC_CLOSED + } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ts+16947 /* "SQLITE_MAGIC_BUS..." */) == 0 { + (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmagic = SQLITE_MAGIC_BUSY + } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ts+16965 /* "SQLITE_MAGIC_ERR..." */) == 0 { + (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmagic = SQLITE_MAGIC_ERROR + } else if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), (*(*uintptr)(unsafe.Pointer(bp + 32 /* db */))+112 /* &.magic */)) != 0 { + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_interrupt DB @@ -51054,14 +48257,14 @@ func test_interrupt(tls *libc.TLS, clientData uintptr, interp uintptr, argc int3 // var db uintptr at bp+32, 8 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), ts+14503 /* " DB" */, 0)) - return 1 + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14503 /* " DB" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_interrupt(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))) - return 0 + return TCL_OK } // Usage: sqlite_delete_function DB function-name @@ -51077,16 +48280,16 @@ func delete_function(tls *libc.TLS, clientData uintptr, interp uintptr, argc int // var db uintptr at bp+32, 8 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+16984 /* " DB function-nam..." */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), -1, 1, uintptr(0), uintptr(0), uintptr(0), uintptr(0)) + 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)) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // Usage: sqlite_delete_collation DB collation-name @@ -51102,16 +48305,16 @@ func delete_collation(tls *libc.TLS, clientData uintptr, interp uintptr, argc in // var db uintptr at bp+32, 8 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+16984 /* " DB function-nam..." */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), 1, uintptr(0), uintptr(0)) + rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), SQLITE_UTF8, uintptr(0), uintptr(0)) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // Usage: sqlite3_get_autocommit DB @@ -51127,16 +48330,16 @@ func get_autocommit(tls *libc.TLS, clientData uintptr, interp uintptr, argc int3 // var db uintptr at bp+56, 8 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14503 /* " DB" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+56 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+56 /* &db */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+64 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+32, sqlite3.Xsqlite3_get_autocommit(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */))))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+64 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: sqlite3_busy_timeout DB MS @@ -51154,19 +48357,19 @@ func test_busy_timeout(tls *libc.TLS, clientData uintptr, interp uintptr, argc i // var db uintptr at bp+48, 8 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14503 /* " DB" */, 0)) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+48 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+48 /* &db */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+56 /* &ms */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+56 /* &ms */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_busy_timeout(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), *(*int32)(unsafe.Pointer(bp + 56 /* ms */))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 0 + return TCL_OK } // Usage: tcl_variable_type VARIABLENAME @@ -51177,16 +48380,16 @@ func tcl_variable_type(tls *libc.TLS, clientData uintptr, interp uintptr, objc i var pVar uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17002 /* "VARIABLE" */) - return 1 + return TCL_ERROR } - pVar = tcl.XTcl_GetVar2Ex(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), uintptr(0), 0x200) + pVar = tcl.XTcl_GetVar2Ex(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0), TCL_LEAVE_ERR_MSG) if pVar == uintptr(0) { - return 1 + return TCL_ERROR } if (*Tcl_Obj)(unsafe.Pointer(pVar)).FtypePtr != 0 { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, (*Tcl_ObjType)(unsafe.Pointer((*Tcl_Obj)(unsafe.Pointer(pVar)).FtypePtr)).Fname, -1)) } - return 0 + return TCL_OK } // Usage: sqlite3_release_memory ?N? @@ -51203,18 +48406,18 @@ func test_release_memory(tls *libc.TLS, clientData uintptr, interp uintptr, objc var amt int32 if (objc != 1) && (objc != 2) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17011 /* "?N?" */) - return 1 + return TCL_ERROR } if objc == 2 { - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &N */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &N */) != 0 { + return TCL_ERROR } } else { *(*int32)(unsafe.Pointer(bp /* N */)) = -1 } amt = sqlite3.Xsqlite3_release_memory(tls, *(*int32)(unsafe.Pointer(bp /* N */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, amt)) - return 0 + return TCL_OK } // Usage: sqlite3_db_release_memory DB @@ -51230,14 +48433,14 @@ func test_db_release_memory(tls *libc.TLS, clientData uintptr, interp uintptr, o var rc int32 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_db_release_memory(tls, *(*uintptr)(unsafe.Pointer(bp /* db */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } // Usage: sqlite3_db_cacheflush DB @@ -51252,19 +48455,19 @@ func test_db_cacheflush(tls *libc.TLS, clientData uintptr, interp uintptr, objc var rc int32 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_db_cacheflush(tls, *(*uintptr)(unsafe.Pointer(bp /* db */))) if rc != 0 { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrStr(tls, rc), uintptr(0)) - return 1 + return TCL_ERROR } tcl.XTcl_ResetResult(tls, interp) - return 0 + return TCL_OK } // Usage: sqlite3_system_errno DB @@ -51279,14 +48482,14 @@ func test_system_errno(tls *libc.TLS, clientData uintptr, interp uintptr, objc i var iErrno int32 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } iErrno = sqlite3.Xsqlite3_system_errno(tls, *(*uintptr)(unsafe.Pointer(bp /* db */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, iErrno)) - return 0 + return TCL_OK } // Usage: sqlite3_db_filename DB DBNAME @@ -51301,14 +48504,14 @@ func test_db_filename(tls *libc.TLS, clientData uintptr, interp uintptr, objc in var zDbName uintptr if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15728 /* "DB DBNAME" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+16 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0 { + return TCL_ERROR } - zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3_db_filename(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), zDbName), uintptr(0))) - return 0 + return TCL_OK } // Usage: sqlite3_db_readonly DB DBNAME @@ -51324,14 +48527,14 @@ func test_db_readonly(tls *libc.TLS, clientData uintptr, interp uintptr, objc in var zDbName uintptr if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15728 /* "DB DBNAME" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_db_readonly(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDbName))) - return 0 + return TCL_OK } // Usage: sqlite3_soft_heap_limit ?N? @@ -51347,16 +48550,16 @@ func test_soft_heap_limit(tls *libc.TLS, clientData uintptr, interp uintptr, obj *(*Tcl_WideInt)(unsafe.Pointer(bp /* N */)) = int64(-1) if (objc != 1) && (objc != 2) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17011 /* "?N?" */) - return 1 + return TCL_ERROR } if objc == 2 { - if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &N */) != 0 { - return 1 + if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &N */) != 0 { + return TCL_ERROR } } amt = sqlite3.Xsqlite3_soft_heap_limit64(tls, *(*Tcl_WideInt)(unsafe.Pointer(bp /* N */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, amt)) - return 0 + return TCL_OK } // Usage: sqlite3_hard_heap_limit ?N? @@ -51372,16 +48575,16 @@ func test_hard_heap_limit(tls *libc.TLS, clientData uintptr, interp uintptr, obj *(*Tcl_WideInt)(unsafe.Pointer(bp /* N */)) = int64(-1) if (objc != 1) && (objc != 2) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17011 /* "?N?" */) - return 1 + return TCL_ERROR } if objc == 2 { - if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &N */) != 0 { - return 1 + if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &N */) != 0 { + return TCL_ERROR } } amt = sqlite3.Xsqlite3_hard_heap_limit64(tls, *(*Tcl_WideInt)(unsafe.Pointer(bp /* N */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, amt)) - return 0 + return TCL_OK } // Usage: sqlite3_thread_cleanup @@ -51389,7 +48592,7 @@ func test_hard_heap_limit(tls *libc.TLS, clientData uintptr, interp uintptr, obj // Call the sqlite3_thread_cleanup API. func test_thread_cleanup(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5533:26: */ sqlite3.Xsqlite3_thread_cleanup(tls) - return 0 + return TCL_OK } // Usage: sqlite3_pager_refcounts DB @@ -51409,11 +48612,11 @@ func test_pager_refcounts(tls *libc.TLS, clientData uintptr, interp uintptr, obj if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+14503 /* " DB" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+14503 /* " DB" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { + return TCL_ERROR } pResult = tcl.XTcl_NewObj(tls) for i = 0; i < (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).FnDb; i++ { @@ -51422,13 +48625,13 @@ func test_pager_refcounts(tls *libc.TLS, clientData uintptr, interp uintptr, obj } else { sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmutex) a = sqlite3.Xsqlite3PagerStats(tls, sqlite3.Xsqlite3BtreePager(tls, (*Db)(unsafe.Pointer((*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).FaDb+uintptr(i)*32)).FpBt)) - v = *(*int32)(unsafe.Pointer(a + uintptr(0)*4)) + v = *(*int32)(unsafe.Pointer(a)) sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmutex) } tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pResult, tcl.XTcl_NewIntObj(tls, v)) } tcl.XTcl_SetObjResult(tls, interp, pResult) - return 0 + return TCL_OK } // tclcmd: working_64bit_int @@ -51454,7 +48657,7 @@ func working_64bit_int(tls *libc.TLS, clientData ClientData, interp uintptr, obj } } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((working) != 0)))) - return 0 + return TCL_OK } // tclcmd: vfs_unlink_test @@ -51537,7 +48740,7 @@ func vfs_unlink_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc // We should be left with the original default VFS back as the // original - return 0 + return TCL_OK } // tclcmd: vfs_initfail_test @@ -51553,17 +48756,17 @@ func vfs_initfail_test(tls *libc.TLS, clientData ClientData, interp uintptr, obj (*sqlite3_vfs)(unsafe.Pointer(bp /* &one */)).FzName = ts + 17032 /* "__one" */ if sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) != 0 { - return 1 + return TCL_ERROR } sqlite3.Xsqlite3_vfs_register(tls, bp /* &one */, 0) if sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) != 0 { - return 1 + return TCL_ERROR } sqlite3.Xsqlite3_vfs_register(tls, bp /* &one */, 1) if sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) != 0 { - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Saved VFSes @@ -51583,7 +48786,7 @@ func vfs_unregister_all(tls *libc.TLS, clientData ClientData, interp uintptr, ob sqlite3.Xsqlite3_vfs_unregister(tls, apVfs[i]) } nVfs = i - return 0 + return TCL_OK } // tclcmd: vfs_reregister_all @@ -51596,7 +48799,7 @@ func vfs_reregister_all(tls *libc.TLS, clientData ClientData, interp uintptr, ob for i = (nVfs - 1); i >= 0; i-- { sqlite3.Xsqlite3_vfs_register(tls, apVfs[i], 1) } - return 0 + return TCL_OK } // tclcmd: file_control_test DB @@ -51615,21 +48818,21 @@ func file_control_test(tls *libc.TLS, clientData ClientData, interp uintptr, obj if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+14503 /* " DB" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+14503 /* " DB" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), uintptr(0), 0, bp+40 /* &iArg */) - rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+17044 /* "notadatabase" */, 1, bp+40 /* &iArg */) + rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+17044 /* "notadatabase" */, SQLITE_FCNTL_LOCKSTATE, bp+40 /* &iArg */) rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+84 /* "main" */, -1, bp+40 /* &iArg */) rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+8199 /* "temp" */, -1, bp+40 /* &iArg */) - return 0 + return TCL_OK } // tclcmd: file_control_lasterrno_test DB @@ -51647,23 +48850,23 @@ func file_control_lasterrno_test(tls *libc.TLS, clientData ClientData, interp ui if objc != 2 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+14503 /* " DB" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+14503 /* " DB" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+64 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+64 /* &db */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), uintptr(0), 4, bp+72 /* &iArg */) + rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), uintptr(0), SQLITE_FCNTL_LAST_ERRNO, bp+72 /* &iArg */) if rc != 0 { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 1 + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 72 /* iArg */)) != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+17057, /* "Unexpected non-z..." */ tcl.XTcl_GetStringFromObj(tls, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 72 /* iArg */))), uintptr(0)), ts+4585 /* " " */, 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // tclcmd: file_control_data_version DB DBNAME @@ -51684,25 +48887,25 @@ func file_control_data_version(tls *libc.TLS, clientData ClientData, interp uint if (objc != 3) && (objc != 2) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17085 /* "DB [DBNAME]" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+8 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+8 /* &db */) != 0 { + return TCL_ERROR } if objc == 3 { - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) } else { zDb = uintptr(0) } - rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* db */)), zDb, 35, bp+16 /* &iVers */) + rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* db */)), zDb, SQLITE_FCNTL_DATA_VERSION, bp+16 /* &iVers */) if rc != 0 { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 1 + return TCL_ERROR } else { sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+20 /* &zBuf[0] */, ts+17097 /* "%u" */, libc.VaList(bp, *(*uint32)(unsafe.Pointer(bp + 16 /* iVers */)))) tcl.XTcl_SetResult(tls, interp, bp+20 /* zBuf */, uintptr(1)) - return 0 + return TCL_OK } return int32(0) } @@ -51725,23 +48928,23 @@ func file_control_chunksize_test(tls *libc.TLS, clientData ClientData, interp ui if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17100 /* "DB DBNAME SIZE" */) - return 1 + return TCL_ERROR } - if (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0) || - (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+8 /* &nSize */) != 0) { - return 1 + if (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) || + (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8 /* &nSize */) != 0) { + return TCL_ERROR } - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - if int32(*(*int8)(unsafe.Pointer(zDb + uintptr(0)))) == 0 { + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + if int32(*(*int8)(unsafe.Pointer(zDb))) == 0 { zDb = uintptr(0) } - rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDb, 6, bp+8 /* &nSize */) + rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDb, SQLITE_FCNTL_CHUNK_SIZE, bp+8 /* &nSize */) if rc != 0 { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // tclcmd: file_control_sizehint_test DB DBNAME SIZE @@ -51761,23 +48964,23 @@ func file_control_sizehint_test(tls *libc.TLS, clientData ClientData, interp uin if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17100 /* "DB DBNAME SIZE" */) - return 1 + return TCL_ERROR } - if (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0) || - (tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+8 /* &nSize */) != 0) { - return 1 + if (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) || + (tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8 /* &nSize */) != 0) { + return TCL_ERROR } - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - if int32(*(*int8)(unsafe.Pointer(zDb + uintptr(0)))) == 0 { + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + if int32(*(*int8)(unsafe.Pointer(zDb))) == 0 { zDb = uintptr(0) } - rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDb, 5, bp+8 /* &nSize */) + rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDb, SQLITE_FCNTL_SIZE_HINT, bp+8 /* &nSize */) if rc != 0 { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // tclcmd: file_control_lockproxy_test DB PWD @@ -51793,14 +48996,14 @@ func file_control_lockproxy_test(tls *libc.TLS, clientData ClientData, interp ui if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+17115 /* " DB PWD" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+17115 /* " DB PWD" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { + return TCL_ERROR } - return 0 + return TCL_OK } // tclcmd: file_control_persist_wal DB PERSIST-FLAG @@ -51820,19 +49023,19 @@ func file_control_persist_wal(tls *libc.TLS, clientData ClientData, interp uintp if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+17123 /* " DB FLAG" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+17123 /* " DB FLAG" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+64 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+64 /* &db */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+72 /* &bPersist */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+72 /* &bPersist */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), uintptr(0), 10, bp+72 /* &bPersist */) + rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), uintptr(0), SQLITE_FCNTL_PERSIST_WAL, bp+72 /* &bPersist */) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+76 /* &z[0] */, ts+17132 /* "%d %d" */, libc.VaList(bp+32, rc, *(*int32)(unsafe.Pointer(bp + 72 /* bPersist */)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, bp+76 /* &z[0] */, uintptr(0))) - return 0 + return TCL_OK } // tclcmd: file_control_powersafe_overwrite DB PSOW-FLAG @@ -51852,19 +49055,19 @@ func file_control_powersafe_overwrite(tls *libc.TLS, clientData ClientData, inte if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+17123 /* " DB FLAG" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+17123 /* " DB FLAG" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+64 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+64 /* &db */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+72 /* &b */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+72 /* &b */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), uintptr(0), 13, bp+72 /* &b */) + rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), uintptr(0), SQLITE_FCNTL_POWERSAFE_OVERWRITE, bp+72 /* &b */) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+76 /* &z[0] */, ts+17132 /* "%d %d" */, libc.VaList(bp+32, rc, *(*int32)(unsafe.Pointer(bp + 72 /* b */)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, bp+76 /* &z[0] */, uintptr(0))) - return 0 + return TCL_OK } // tclcmd: file_control_vfsname DB ?AUXDB? @@ -51881,19 +49084,19 @@ func file_control_vfsname(tls *libc.TLS, clientData ClientData, interp uintptr, if (objc != 2) && (objc != 3) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+17138 /* " DB ?AUXDB?" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+17138 /* " DB ?AUXDB?" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+48 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { + return TCL_ERROR } if objc == 3 { - zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) } - sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zDbName, 12, bp+56 /* &zVfsName */) + sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zDbName, SQLITE_FCNTL_VFSNAME, bp+56 /* &zVfsName */) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(bp + 56 /* zVfsName */)), uintptr(0))) sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* zVfsName */))) - return 0 + return TCL_OK } // tclcmd: file_control_tempfilename DB ?AUXDB? @@ -51910,19 +49113,19 @@ func file_control_tempfilename(tls *libc.TLS, clientData ClientData, interp uint if (objc != 2) && (objc != 3) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+17138 /* " DB ?AUXDB?" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+17138 /* " DB ?AUXDB?" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+48 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { + return TCL_ERROR } if objc == 3 { - zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) } - sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zDbName, 16, bp+56 /* &zTName */) + sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zDbName, SQLITE_FCNTL_TEMPFILENAME, bp+56 /* &zTName */) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(bp + 56 /* zTName */)), uintptr(0))) sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* zTName */))) - return 0 + return TCL_OK } // tclcmd: sqlite3_vfs_list @@ -51933,13 +49136,13 @@ func vfs_list(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, var pRet uintptr = tcl.XTcl_NewObj(tls) if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } for pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)); pVfs != 0; pVfs = (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext { tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewStringObj(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FzName, -1)) } tcl.XTcl_SetObjResult(tls, interp, pRet) - return 0 + return TCL_OK } // tclcmd: sqlite3_limit DB ID VALUE @@ -51961,13 +49164,13 @@ func test_limit(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32 if objc != 4 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+17150 /* " DB ID VALUE" */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+17150 /* " DB ID VALUE" */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+56 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+56 /* &db */) != 0 { + return TCL_ERROR } - zId = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zId = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aId)) / uint64(unsafe.Sizeof(struct { FzName uintptr Fid int32 @@ -51984,14 +49187,14 @@ func test_limit(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32 _ [4]byte }{}))) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+17163 /* "unknown limit ty..." */, zId, uintptr(0))) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+64 /* &val */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+64 /* &val */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_limit(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */)), id, *(*int32)(unsafe.Pointer(bp + 64 /* val */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } var aId = [14]struct { @@ -51999,50 +49202,22 @@ var aId = [14]struct { Fid int32 _ [4]byte }{ - { - FzName: ts + 17184, /* "SQLITE_LIMIT_LEN..." */ - Fid: 0}, - { - FzName: ts + 17204, /* "SQLITE_LIMIT_SQL..." */ - Fid: 1}, - { - FzName: ts + 17228, /* "SQLITE_LIMIT_COL..." */ - Fid: 2}, - { - FzName: ts + 17248, /* "SQLITE_LIMIT_EXP..." */ - Fid: 3}, - { - FzName: ts + 17272, /* "SQLITE_LIMIT_COM..." */ - Fid: 4}, - { - FzName: ts + 17301, /* "SQLITE_LIMIT_VDB..." */ - Fid: 5}, - { - FzName: ts + 17322, /* "SQLITE_LIMIT_FUN..." */ - Fid: 6}, - { - FzName: ts + 17348, /* "SQLITE_LIMIT_ATT..." */ - Fid: 7}, - { - FzName: ts + 17370, /* "SQLITE_LIMIT_LIK..." */ - Fid: 8}, - { - FzName: ts + 17403, /* "SQLITE_LIMIT_VAR..." */ - Fid: 9}, - { - FzName: ts + 17432, /* "SQLITE_LIMIT_TRI..." */ - Fid: 10}, - { - FzName: ts + 17459, /* "SQLITE_LIMIT_WOR..." */ - Fid: 11}, + {FzName: ts + 17184 /* "SQLITE_LIMIT_LEN..." */}, + {FzName: ts + 17204 /* "SQLITE_LIMIT_SQL..." */, Fid: SQLITE_LIMIT_SQL_LENGTH}, + {FzName: ts + 17228 /* "SQLITE_LIMIT_COL..." */, Fid: SQLITE_LIMIT_COLUMN}, + {FzName: ts + 17248 /* "SQLITE_LIMIT_EXP..." */, Fid: SQLITE_LIMIT_EXPR_DEPTH}, + {FzName: ts + 17272 /* "SQLITE_LIMIT_COM..." */, Fid: SQLITE_LIMIT_COMPOUND_SELECT}, + {FzName: ts + 17301 /* "SQLITE_LIMIT_VDB..." */, Fid: SQLITE_LIMIT_VDBE_OP}, + {FzName: ts + 17322 /* "SQLITE_LIMIT_FUN..." */, Fid: SQLITE_LIMIT_FUNCTION_ARG}, + {FzName: ts + 17348 /* "SQLITE_LIMIT_ATT..." */, Fid: SQLITE_LIMIT_ATTACHED}, + {FzName: ts + 17370 /* "SQLITE_LIMIT_LIK..." */, Fid: SQLITE_LIMIT_LIKE_PATTERN_LENGTH}, + {FzName: ts + 17403 /* "SQLITE_LIMIT_VAR..." */, Fid: SQLITE_LIMIT_VARIABLE_NUMBER}, + {FzName: ts + 17432 /* "SQLITE_LIMIT_TRI..." */, Fid: SQLITE_LIMIT_TRIGGER_DEPTH}, + {FzName: ts + 17459 /* "SQLITE_LIMIT_WOR..." */, Fid: SQLITE_LIMIT_WORKER_THREADS}, // Out of range test cases - { - FzName: ts + 17487, /* "SQLITE_LIMIT_TOO..." */ - Fid: -1}, - { - FzName: ts + 17509, /* "SQLITE_LIMIT_TOO..." */ - Fid: (11 + 1)}, + {FzName: ts + 17487 /* "SQLITE_LIMIT_TOO..." */, Fid: -1}, + {FzName: ts + 17509 /* "SQLITE_LIMIT_TOO..." */, Fid: (SQLITE_LIMIT_WORKER_THREADS + 1)}, } /* test1.c:6316:5 */ // tclcmd: save_prng_state @@ -52056,20 +49231,20 @@ func save_prng_state(tls *libc.TLS, clientData ClientData, interp uintptr, objc rc = sqlite3.Xsqlite3_test_control(tls, -1, 0) - sqlite3.Xsqlite3_test_control(tls, 5, 0) - return 0 + sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_PRNG_SAVE, 0) + return TCL_OK } // tclcmd: restore_prng_state func restore_prng_state(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6384:26: */ - sqlite3.Xsqlite3_test_control(tls, 6, 0) - return 0 + sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_PRNG_RESTORE, 0) + return TCL_OK } // tclcmd: reset_prng_state func reset_prng_state(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6396:26: */ sqlite3.Xsqlite3_randomness(tls, 0, uintptr(0)) - return 0 + return TCL_OK } // tclcmd: prng_seed INT ?DB? @@ -52093,16 +49268,16 @@ func prng_seed(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)) = uintptr(0) if (objc != 2) && (objc != 3) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17529 /* "SEED ?DB?" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), bp+16 /* &i */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv)), bp+16 /* &i */) != 0 { + return TCL_ERROR } - if (objc == 3) && (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), bp+24 /* &db */) != 0) { - return 1 + if (objc == 3) && (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+24 /* &db */) != 0) { + return TCL_ERROR } - sqlite3.Xsqlite3_test_control(tls, 28, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 16 /* i */)), *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)))) - return 0 + sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_PRNG_SEED, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 16 /* i */)), *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)))) + return TCL_OK } // tclcmd: extra_schema_checks BOOLEAN @@ -52118,13 +49293,13 @@ func extra_schema_checks(tls *libc.TLS, clientData ClientData, interp uintptr, o *(*int32)(unsafe.Pointer(bp + 8 /* i */)) = 0 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17539 /* "BOOLEAN" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+8 /* &i */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8 /* &i */) != 0 { + return TCL_ERROR } - sqlite3.Xsqlite3_test_control(tls, 29, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* i */)))) - return 0 + sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* i */)))) + return TCL_OK } // tclcmd: database_may_be_corrupt @@ -52135,8 +49310,8 @@ func database_may_be_corrupt(tls *libc.TLS, clientData ClientData, interp uintpt bp := tls.Alloc(8) defer tls.Free(8) - sqlite3.Xsqlite3_test_control(tls, 20, libc.VaList(bp, 0)) - return 0 + sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_NEVER_CORRUPT, libc.VaList(bp, 0)) + return TCL_OK } // tclcmd: database_never_corrupt @@ -52148,8 +49323,8 @@ func database_never_corrupt(tls *libc.TLS, clientData ClientData, interp uintptr bp := tls.Alloc(8) defer tls.Free(8) - sqlite3.Xsqlite3_test_control(tls, 20, libc.VaList(bp, 1)) - return 0 + sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_NEVER_CORRUPT, libc.VaList(bp, 1)) + return TCL_OK } // tclcmd: pcache_stats @@ -52181,13 +49356,13 @@ func test_pcache_stats(tls *libc.TLS, clientData ClientData, interp uintptr, obj tcl.XTcl_SetObjResult(tls, interp, pRet) - return 0 + return TCL_OK } func test_unlock_notify_cb(tls *libc.TLS, aArg uintptr, nArg int32) { /* test1.c:6529:13: */ var ii int32 for ii = 0; ii < nArg; ii++ { - tcl.XTcl_EvalEx(tls, *(*uintptr)(unsafe.Pointer(aArg + uintptr(ii)*8)), ts+13194 /* "unlock_notify" */, -1, 0x020000) + tcl.XTcl_EvalEx(tls, *(*uintptr)(unsafe.Pointer(aArg + uintptr(ii)*8)), ts+13194 /* "unlock_notify" */, -1, TCL_EVAL_GLOBAL) } } @@ -52202,17 +49377,17 @@ func test_unlock_notify(tls *libc.TLS, clientData ClientData, interp uintptr, ob if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_unlock_notify(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32) }{test_unlock_notify_cb})), interp) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // tclcmd: sqlite3_wal_checkpoint db ?NAME? @@ -52227,18 +49402,18 @@ func test_wal_checkpoint(tls *libc.TLS, clientData ClientData, interp uintptr, o if (objc != 3) && (objc != 2) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17574 /* "DB ?NAME?" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } if objc == 3 { - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) } rc = sqlite3.Xsqlite3_wal_checkpoint(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDb) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // tclcmd: sqlite3_wal_checkpoint_v2 db MODE ?NAME? @@ -52275,28 +49450,28 @@ func test_wal_checkpoint_v2(tls *libc.TLS, clientData ClientData, interp uintptr if (objc != 3) && (objc != 4) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17614 /* "DB MODE ?NAME?" */) - return 1 + return TCL_ERROR } if objc == 4 { - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) } - if (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &db */) != 0) || ((0 != tcl.XTcl_GetIntFromObj(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &eMode */)) && - (0 != tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+48 /* &aMode[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+17629 /* "mode" */, 0, bp+40 /* &eMode */))) { - return 1 + 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 */)) && + (TCL_OK != tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+48 /* &aMode[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+17629 /* "mode" */, 0, bp+40 /* &eMode */))) { + return TCL_ERROR } 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 */) - if (rc != 0) && (rc != 5) { + if (rc != SQLITE_OK) && (rc != SQLITE_BUSY) { var zErrCode uintptr = sqlite3.Xsqlite3ErrName(tls, rc) tcl.XTcl_ResetResult(tls, interp) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, zErrCode, ts+10102 /* " - " */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))), 0)) - return 1 + return TCL_ERROR } pRet = tcl.XTcl_NewObj(tls) tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, func() int32 { - if rc == 5 { + if rc == SQLITE_BUSY { return 1 } return 0 @@ -52305,7 +49480,7 @@ func test_wal_checkpoint_v2(tls *libc.TLS, clientData ClientData, interp uintptr tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 92 /* nCkpt */)))) tcl.XTcl_SetObjResult(tls, interp, pRet) - return 0 + return TCL_OK } // tclcmd: sqlite3_wal_autocheckpoint db VALUE @@ -52320,23 +49495,23 @@ func test_wal_autocheckpoint(tls *libc.TLS, clientData ClientData, interp uintpt if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17634 /* "DB VALUE" */) - return 1 + return TCL_ERROR } - if (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0) || - (tcl.XTcl_GetIntFromObj(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+8 /* &iVal */) != 0) { - return 1 + if (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) || + (tcl.XTcl_GetIntFromObj(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &iVal */) != 0) { + return TCL_ERROR } rc = sqlite3.Xsqlite3_wal_autocheckpoint(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), *(*int32)(unsafe.Pointer(bp + 8 /* iVal */))) tcl.XTcl_ResetResult(tls, interp) - if rc != 0 { + if rc != SQLITE_OK { var zErrCode uintptr = sqlite3.Xsqlite3ErrName(tls, rc) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, zErrCode, -1)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // tclcmd: test_sqlite3_log ?SCRIPT? @@ -52354,7 +49529,7 @@ func xLogcallback(tls *libc.TLS, unused uintptr, err int32, zMsg uintptr) { /* t tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pNew, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, err), -1)) tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pNew, tcl.XTcl_NewStringObj(tls, zMsg, -1)) - tcl.XTcl_EvalObjEx(tls, logcallback.FpInterp, pNew, (0x020000 | 0x040000)) + tcl.XTcl_EvalObjEx(tls, logcallback.FpInterp, pNew, (TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT)) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pNew if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -52369,7 +49544,7 @@ func test_sqlite3_log(tls *libc.TLS, clientData ClientData, interp uintptr, objc if objc > 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+11405 /* "SCRIPT" */) - return 1 + return TCL_ERROR } if logcallback.FpObj != 0 { for ok := true; ok; ok = 0 != 0 { @@ -52380,17 +49555,17 @@ func test_sqlite3_log(tls *libc.TLS, clientData ClientData, interp uintptr, objc } logcallback.FpObj = uintptr(0) logcallback.FpInterp = uintptr(0) - sqlite3.Xsqlite3_config(tls, 16, libc.VaList(bp, uintptr(0), uintptr(0))) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_LOG, libc.VaList(bp, uintptr(0), uintptr(0))) } if objc > 1 { - logcallback.FpObj = *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)) + logcallback.FpObj = *(*uintptr)(unsafe.Pointer(objv + 1*8)) (*Tcl_Obj)(unsafe.Pointer(logcallback.FpObj)).FrefCount++ logcallback.FpInterp = interp - sqlite3.Xsqlite3_config(tls, 16, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(&struct { + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_LOG, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{xLogcallback})), uintptr(0))) } - return 0 + return TCL_OK } // tcl_objproc COMMANDNAME ARGS... @@ -52405,17 +49580,17 @@ func runAsObjProc(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc < 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17643 /* "COMMAND ..." */) - return 1 + return TCL_ERROR } - if !(tcl.XTcl_GetCommandInfo(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+48 /* &cmdInfo */) != 0) { + if !(tcl.XTcl_GetCommandInfo(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &cmdInfo */) != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14361, /* "command not foun..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), uintptr(0))) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) + return TCL_ERROR } if (*Tcl_CmdInfo)(unsafe.Pointer(bp+48 /* &cmdInfo */)).FobjProc == uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+17655, /* "command has no o..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), uintptr(0))) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) + return TCL_ERROR } 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)) } @@ -52438,21 +49613,21 @@ func printExplainQueryPlan(tls *libc.TLS, pStmt uintptr) int32 { /* test1.c:6784 zSql = sqlite3.Xsqlite3_sql(tls, pStmt) if zSql == uintptr(0) { - return 1 + return SQLITE_ERROR } zExplain = sqlite3.Xsqlite3_mprintf(tls, ts+234 /* "EXPLAIN QUERY PL..." */, libc.VaList(bp, zSql)) if zExplain == uintptr(0) { - return 7 + return SQLITE_NOMEM } rc = sqlite3.Xsqlite3_prepare_v2(tls, sqlite3.Xsqlite3_db_handle(tls, pStmt), zExplain, -1, bp+40 /* &pExplain */, uintptr(0)) sqlite3.Xsqlite3_free(tls, zExplain) - if rc != 0 { + if rc != SQLITE_OK { return rc } - for 100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pExplain */))) { + for SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pExplain */))) { var iSelectid int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pExplain */)), 0) var iOrder int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pExplain */)), 1) var iFrom int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pExplain */)), 2) @@ -52473,10 +49648,10 @@ func test_print_eqp(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16285 /* "STMT" */) - return 1 + return TCL_ERROR } - if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &pStmt */) != 0 { - return 1 + if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { + return TCL_ERROR } rc = printExplainQueryPlan(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) // This is needed on Windows so that a test case using this @@ -52484,7 +49659,7 @@ func test_print_eqp(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 // printExplainQueryPlan() immediately. libc.Xfflush(tls, libc.Xstdout) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // sqlite3_test_control VERB ARGS... @@ -52493,18 +49668,10 @@ func test_test_control(tls *libc.TLS, clientData uintptr, interp uintptr, objc i defer tls.Free(184) *(*[4]Verb)(unsafe.Pointer(bp + 64 /* aVerb */)) = [4]Verb{ - { - FzName: ts + 17693, /* "SQLITE_TESTCTRL_..." */ - Fi: 18}, - { - FzName: ts + 17725, /* "SQLITE_TESTCTRL_..." */ - Fi: 24}, - { - FzName: ts + 17753, /* "SQLITE_TESTCTRL_..." */ - Fi: 25}, - { - FzName: ts + 17778, /* "SQLITE_TESTCTRL_..." */ - Fi: 17}, + {FzName: ts + 17693 /* "SQLITE_TESTCTRL_..." */, Fi: SQLITE_TESTCTRL_LOCALTIME_FAULT}, + {FzName: ts + 17725 /* "SQLITE_TESTCTRL_..." */, Fi: SQLITE_TESTCTRL_SORTER_MMAP}, + {FzName: ts + 17753 /* "SQLITE_TESTCTRL_..." */, Fi: SQLITE_TESTCTRL_IMPOSTER}, + {FzName: ts + 17778 /* "SQLITE_TESTCTRL_..." */, Fi: SQLITE_TESTCTRL_INTERNAL_FUNCTIONS}, } // var iVerb int32 at bp+128, 4 @@ -52513,48 +49680,48 @@ func test_test_control(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc < 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17813 /* "VERB ARGS..." */) - return 1 + return TCL_ERROR } rc = tcl.XTcl_GetIndexFromObjStruct(tls, - interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+64 /* &aVerb[0] */, int32(unsafe.Sizeof(Verb{})), ts+17826 /* "VERB" */, 0, bp+128 /* &iVerb */) - if rc != 0 { + interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+64 /* &aVerb[0] */, int32(unsafe.Sizeof(Verb{})), ts+17826 /* "VERB" */, 0, bp+128 /* &iVerb */) + if rc != TCL_OK { return rc } iFlag = (*Verb)(unsafe.Pointer(bp + 64 /* &aVerb */ + uintptr(*(*int32)(unsafe.Pointer(bp + 128 /* iVerb */)))*16)).Fi switch iFlag { - case 17: + case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS: { *(*uintptr)(unsafe.Pointer(bp + 136 /* db */)) = uintptr(0) if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), bp+136 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+136 /* &db */) != 0 { + return TCL_ERROR } - sqlite3.Xsqlite3_test_control(tls, 17, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 136 /* db */)))) + sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 136 /* db */)))) break } - case 18: + case SQLITE_TESTCTRL_LOCALTIME_FAULT: { // var val int32 at bp+144, 4 if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+17831 /* "ONOFF" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+144 /* &val */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+144 /* &val */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_test_control(tls, iFlag, libc.VaList(bp+8, *(*int32)(unsafe.Pointer(bp + 144 /* val */)))) break } - case 24: + case SQLITE_TESTCTRL_SORTER_MMAP: { // var val int32 at bp+160, 4 @@ -52562,20 +49729,20 @@ func test_test_control(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+17837 /* "DB LIMIT" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), bp+152 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+152 /* &db */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+160 /* &val */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+160 /* &val */) != 0 { + return TCL_ERROR } - sqlite3.Xsqlite3_test_control(tls, 24, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(bp + 152 /* db */)), *(*int32)(unsafe.Pointer(bp + 160 /* val */)))) + 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 */)))) break } - case 25: + case SQLITE_TESTCTRL_IMPOSTER: { // var onOff int32 at bp+176, 4 @@ -52586,26 +49753,26 @@ func test_test_control(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 6 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+17846 /* "DB dbName onOff ..." */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), bp+168 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+168 /* &db */) != 0 { + return TCL_ERROR } - zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+176 /* &onOff */) != 0 { - return 1 + zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+176 /* &onOff */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(5)*8)), bp+180 /* &tnum */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+180 /* &tnum */) != 0 { + return TCL_ERROR } - sqlite3.Xsqlite3_test_control(tls, 25, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(bp + 168 /* db */)), zDbName, *(*int32)(unsafe.Pointer(bp + 176 /* onOff */)), *(*int32)(unsafe.Pointer(bp + 180 /* tnum */)))) + 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 */)))) break } } tcl.XTcl_ResetResult(tls, interp) - return 0 + return TCL_OK } type Verb = struct { @@ -52718,7 +49885,7 @@ func test_getrusage(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 int32((*rusage)(unsafe.Pointer(bp+48 /* &r */)).Fru_stime.Ftv_sec), int32((*rusage)(unsafe.Pointer(bp+48 /* &r */)).Fru_stime.Ftv_usec), int32(*(*int64)(unsafe.Pointer(bp + 48 /* &r */ + 64 /* &.ru_minflt */))), int32(*(*int64)(unsafe.Pointer(bp + 48 /* &r */ + 72 /* &.ru_majflt */))))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, bp+192 /* &buf[0] */, -1)) - return 0 + return TCL_OK } // optimization_control DB OPT BOOLEAN @@ -52740,15 +49907,15 @@ func optimization_control(tls *libc.TLS, clientData uintptr, interp uintptr, obj if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17927 /* "DB OPT BOOLEAN" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+56 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+56 /* &db */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+64 /* &onoff */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+64 /* &onoff */) != 0 { + return TCL_ERROR } - zOpt = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zOpt = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aOpt)) / uint64(unsafe.Sizeof(struct { FzOptName uintptr Fmask int32 @@ -52776,10 +49943,10 @@ func optimization_control(tls *libc.TLS, clientData uintptr, interp uintptr, obj }{}))); i++ { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+4585 /* " " */, aOpt[i].FzOptName, uintptr(0))) } - return 1 + return TCL_ERROR } - sqlite3.Xsqlite3_test_control(tls, 15, libc.VaList(bp+40, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */)), mask)) - return 0 + sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_OPTIMIZATIONS, libc.VaList(bp+40, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */)), mask)) + return TCL_OK } var aOpt = [13]struct { @@ -52787,45 +49954,19 @@ var aOpt = [13]struct { Fmask int32 _ [4]byte }{ - { - FzOptName: ts + 17983, /* "all" */ - Fmask: 0xffff}, - { - FzOptName: ts + 17987, /* "none" */ - Fmask: 0}, - { - FzOptName: ts + 17992, /* "query-flattener" */ - Fmask: 0x0001}, - { - FzOptName: ts + 18008, /* "groupby-order" */ - Fmask: 0x0004}, - { - FzOptName: ts + 18022, /* "factor-constants" */ - Fmask: 0x0008}, - { - FzOptName: ts + 18039, /* "distinct-opt" */ - Fmask: 0x0010}, - { - FzOptName: ts + 18052, /* "cover-idx-scan" */ - Fmask: 0x0020}, - { - FzOptName: ts + 18067, /* "order-by-idx-joi..." */ - Fmask: 0x0040}, - { - FzOptName: ts + 18085, /* "transitive" */ - Fmask: 0x0080}, - { - FzOptName: ts + 18096, /* "omit-noop-join" */ - Fmask: 0x0100}, - { - FzOptName: ts + 18111, /* "stat4" */ - Fmask: 0x0800}, - { - FzOptName: ts + 18117, /* "skip-scan" */ - Fmask: 0x4000}, - { - FzOptName: ts + 18127, /* "push-down" */ - Fmask: 0x1000}, + {FzOptName: ts + 17983 /* "all" */, Fmask: SQLITE_AllOpts}, + {FzOptName: ts + 17987 /* "none" */}, + {FzOptName: ts + 17992 /* "query-flattener" */, Fmask: SQLITE_QueryFlattener}, + {FzOptName: ts + 18008 /* "groupby-order" */, Fmask: SQLITE_GroupByOrder}, + {FzOptName: ts + 18022 /* "factor-constants" */, Fmask: SQLITE_FactorOutConst}, + {FzOptName: ts + 18039 /* "distinct-opt" */, Fmask: SQLITE_DistinctOpt}, + {FzOptName: ts + 18052 /* "cover-idx-scan" */, Fmask: SQLITE_CoverIdxScan}, + {FzOptName: ts + 18067 /* "order-by-idx-joi..." */, Fmask: SQLITE_OrderByIdxJoin}, + {FzOptName: ts + 18085 /* "transitive" */, Fmask: SQLITE_Transitive}, + {FzOptName: ts + 18096 /* "omit-noop-join" */, Fmask: SQLITE_OmitNoopJoin}, + {FzOptName: ts + 18111 /* "stat4" */, Fmask: SQLITE_Stat4}, + {FzOptName: ts + 18117 /* "skip-scan" */, Fmask: SQLITE_SkipScan}, + {FzOptName: ts + 18127 /* "push-down" */, Fmask: SQLITE_PushDown}, } /* test1.c:7224:5 */ // load_static_extension DB NAME ... @@ -52844,10 +49985,10 @@ func tclLoadStaticExtensionCmd(tls *libc.TLS, clientData uintptr, interp uintptr *(*uintptr)(unsafe.Pointer(bp + 72 /* zErrMsg */)) = uintptr(0) if objc < 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18137 /* "DB NAME ..." */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+64 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+64 /* &db */) != 0 { + return TCL_ERROR } for j = 2; j < objc; j++ { zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(j)*8))) @@ -52864,90 +50005,48 @@ func tclLoadStaticExtensionCmd(tls *libc.TLS, clientData uintptr, interp uintptr FpInit uintptr }{})))) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+18149 /* "no such extensio..." */, zName, uintptr(0))) - return 1 + return TCL_ERROR } if aExtension[i].FpInit != 0 { 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)) } else { - rc = 0 + rc = SQLITE_OK } - if (rc != 0) || (*(*uintptr)(unsafe.Pointer(bp + 72 /* zErrMsg */)) != 0) { + if (rc != SQLITE_OK) || (*(*uintptr)(unsafe.Pointer(bp + 72 /* zErrMsg */)) != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+18169 /* "initialization o..." */, zName, ts+18188 /* " failed: " */, *(*uintptr)(unsafe.Pointer(bp + 72 /* zErrMsg */)), uintptr(0))) sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* zErrMsg */))) - return 1 + return TCL_ERROR } } - return 0 + return TCL_OK } var aExtension = [21]struct { FzExtName uintptr FpInit uintptr }{ - { - FzExtName: ts + 18198, /* "amatch" */ - FpInit: 0}, - { - FzExtName: ts + 3862, /* "carray" */ - FpInit: 0}, - { - FzExtName: ts + 18205, /* "closure" */ - FpInit: 0}, - { - FzExtName: ts + 4506, /* "csv" */ - FpInit: 0}, - { - FzExtName: ts + 4529, /* "decimal" */ - FpInit: 0}, - { - FzExtName: ts + 4587, /* "eval" */ - FpInit: 0}, - { - FzExtName: ts + 4665, /* "explain" */ - FpInit: 0}, - { - FzExtName: ts + 18213, /* "fileio" */ - FpInit: 0}, - { - FzExtName: ts + 5174, /* "fuzzer" */ - FpInit: 0}, - { - FzExtName: ts + 5198, /* "ieee754" */ - FpInit: 0}, - { - FzExtName: ts + 18220, /* "nextchar" */ - FpInit: 0}, - { - FzExtName: ts + 5778, /* "percentile" */ - FpInit: 0}, - { - FzExtName: ts + 5853, /* "prefixes" */ - FpInit: 0}, - { - FzExtName: ts + 6165, /* "regexp" */ - FpInit: 0}, - { - FzExtName: ts + 6172, /* "remember" */ - FpInit: 0}, - { - FzExtName: ts + 18229, /* "series" */ - FpInit: 0}, - { - FzExtName: ts + 18236, /* "spellfix" */ - FpInit: 0}, - { - FzExtName: ts + 18245, /* "totype" */ - FpInit: 0}, - { - FzExtName: ts + 8189, /* "unionvtab" */ - FpInit: 0}, - { - FzExtName: ts + 8731, /* "wholenumber" */ - FpInit: 0}, - { - FzExtName: ts + 8834, /* "zipfile" */ - FpInit: 0}, + {FzExtName: ts + 18198 /* "amatch" */, FpInit: 0}, + {FzExtName: ts + 3862 /* "carray" */, FpInit: 0}, + {FzExtName: ts + 18205 /* "closure" */, FpInit: 0}, + {FzExtName: ts + 4506 /* "csv" */, FpInit: 0}, + {FzExtName: ts + 4529 /* "decimal" */, FpInit: 0}, + {FzExtName: ts + 4587 /* "eval" */, FpInit: 0}, + {FzExtName: ts + 4665 /* "explain" */, FpInit: 0}, + {FzExtName: ts + 18213 /* "fileio" */, FpInit: 0}, + {FzExtName: ts + 5174 /* "fuzzer" */, FpInit: 0}, + {FzExtName: ts + 5198 /* "ieee754" */, FpInit: 0}, + {FzExtName: ts + 18220 /* "nextchar" */, FpInit: 0}, + {FzExtName: ts + 5778 /* "percentile" */, FpInit: 0}, + {FzExtName: ts + 5853 /* "prefixes" */, FpInit: 0}, + {FzExtName: ts + 6165 /* "regexp" */, FpInit: 0}, + {FzExtName: ts + 6172 /* "remember" */, FpInit: 0}, + {FzExtName: ts + 18229 /* "series" */, FpInit: 0}, + {FzExtName: ts + 18236 /* "spellfix" */, FpInit: 0}, + {FzExtName: ts + 18245 /* "totype" */, FpInit: 0}, + {FzExtName: ts + 8189 /* "unionvtab" */, FpInit: 0}, + {FzExtName: ts + 8731 /* "wholenumber" */, FpInit: 0}, + {FzExtName: ts + 8834 /* "zipfile" */, FpInit: 0}, } /* test1.c:7305:5 */ // sorter_test_fakeheap BOOL @@ -52960,11 +50059,11 @@ func sorter_test_fakeheap(tls *libc.TLS, clientData uintptr, interp uintptr, obj if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18252 /* "BOOL" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &bArg */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &bArg */) != 0 { + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp /* bArg */)) != 0 { @@ -52978,7 +50077,7 @@ func sorter_test_fakeheap(tls *libc.TLS, clientData uintptr, interp uintptr, obj } tcl.XTcl_ResetResult(tls, interp) - return 0 + return TCL_OK } // sorter_test_sort4_helper DB SQL1 NSTEP SQL2 @@ -53015,27 +50114,27 @@ func sorter_test_sort4_helper(tls *libc.TLS, clientData uintptr, interp uintptr, goto __1 } tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18257 /* "DB SQL1 NSTEP SQ..." */) - return 1 + return TCL_ERROR __1: ; - if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+56 /* &db */) != 0) { + if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+56 /* &db */) != 0) { goto __2 } - return 1 + return TCL_ERROR __2: ; - zSql1 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+64 /* &nStep */) != 0) { + zSql1 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+64 /* &nStep */) != 0) { goto __3 } - return 1 + return TCL_ERROR __3: ; - zSql2 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8))) + zSql2 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */)), zSql1, -1, bp+72 /* &pStmt */, uintptr(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } goto sql_error @@ -53045,7 +50144,7 @@ __4: iB = (sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) - 1) iStep = 0 __5: - if !((iStep < *(*int32)(unsafe.Pointer(bp + 64 /* nStep */))) && (100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))))) { + if !((iStep < *(*int32)(unsafe.Pointer(bp + 64 /* nStep */))) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))))) { goto __7 } a = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)), 0) @@ -53053,7 +50152,7 @@ __5: goto __8 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+18276 /* "data error: (a!=..." */, 0)) - return 1 + return TCL_ERROR __8: ; @@ -53066,7 +50165,7 @@ __6: __7: ; rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __9 } goto sql_error @@ -53074,7 +50173,7 @@ __9: ; rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */)), zSql2, -1, bp+72 /* &pStmt */, uintptr(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __10 } goto sql_error @@ -53082,7 +50181,7 @@ __10: ; iStep = 0 __11: - if !(100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)))) { + if !(SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)))) { goto __13 } a1 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)), 0) @@ -53095,7 +50194,7 @@ __12: __13: ; rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __14 } goto sql_error @@ -53106,14 +50205,14 @@ __14: goto __15 } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+18295 /* "checksum mismatc..." */, 0)) - return 1 + return TCL_ERROR __15: ; - return 0 + return TCL_OK sql_error: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+18313 /* "sql error: " */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */))), 0)) - return 1 + return TCL_ERROR } // tclcmd: bad_behavior TYPE @@ -53141,10 +50240,10 @@ func test_bad_behavior(tls *libc.TLS, clientData ClientData, interp uintptr, obj var a uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18325 /* "TYPE" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &iType */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &iType */) != 0 { + return TCL_ERROR } switch *(*int32)(unsafe.Pointer(bp /* iType */)) { case 1: @@ -53157,11 +50256,11 @@ func test_bad_behavior(tls *libc.TLS, clientData ClientData, interp uintptr, obj } case 2: { - *(*int32)(unsafe.Pointer(bp + 4 /* &w[0] */ + uintptr(1)*4)) = 5 + *(*int32)(unsafe.Pointer(bp + 4 /* &w[0] */ + 1*4)) = 5 if *(*int32)(unsafe.Pointer(bp + 4 /* &w[0] */ + uintptr(i)*4)) > 0 { - *(*int32)(unsafe.Pointer(bp + 4 /* &w[0] */ + uintptr(1)*4))++ + *(*int32)(unsafe.Pointer(bp + 4 /* &w[0] */ + 1*4))++ } - tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 4 /* &w[0] */ + uintptr(1)*4)))) + tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 4 /* &w[0] */ + 1*4)))) break } @@ -53183,7 +50282,7 @@ func test_bad_behavior(tls *libc.TLS, clientData ClientData, interp uintptr, obj } } - return 0 + return TCL_OK } // tclcmd: register_dbstat_vtab DB @@ -53198,15 +50297,15 @@ func test_register_dbstat_vtab(tls *libc.TLS, clientData uintptr, interp uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) if tcl.XTcl_GetCommandInfo(tls, interp, zDb, bp /* &cmdInfo */) != 0 { var db uintptr = (*struct{ Fdb uintptr })(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp /* &cmdInfo */)).FobjClientData)).Fdb sqlite3.Xsqlite3DbstatRegister(tls, db) } - return 0 + return TCL_OK } // tclcmd: sqlite3_db_config DB SETTING VALUE @@ -53223,12 +50322,12 @@ func test_sqlite3_db_config(tls *libc.TLS, clientData uintptr, interp uintptr, o if (objc != 4) && (objc != 3) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18347 /* "DB SETTING [VALU..." */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+16 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0 { + return TCL_ERROR } - zSetting = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zSetting = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if sqlite3.Xsqlite3_strglob(tls, ts+18366 /* "SQLITE_*" */, zSetting) == 0 { zSetting += uintptr(7) } @@ -53254,18 +50353,18 @@ func test_sqlite3_db_config(tls *libc.TLS, clientData uintptr, interp uintptr, o }{})))) { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, ts+18395 /* "unknown sqlite3_..." */, -1)) - return 1 + return TCL_ERROR } if objc == 4 { - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+24 /* &v */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+24 /* &v */) != 0 { + return TCL_ERROR } } else { *(*int32)(unsafe.Pointer(bp + 24 /* v */)) = -1 } 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 */)) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 24 /* v */)))) - return 0 + return TCL_OK } var aSetting = [14]struct { @@ -53273,48 +50372,20 @@ var aSetting = [14]struct { FeVal int32 _ [4]byte }{ - { - FzName: ts + 18429, /* "FKEY" */ - FeVal: 1002}, - { - FzName: ts + 18434, /* "TRIGGER" */ - FeVal: 1003}, - { - FzName: ts + 18442, /* "FTS3_TOKENIZER" */ - FeVal: 1004}, - { - FzName: ts + 18457, /* "LOAD_EXTENSION" */ - FeVal: 1005}, - { - FzName: ts + 18472, /* "NO_CKPT_ON_CLOSE" */ - FeVal: 1006}, - { - FzName: ts + 18489, /* "QPSG" */ - FeVal: 1007}, - { - FzName: ts + 18494, /* "TRIGGER_EQP" */ - FeVal: 1008}, - { - FzName: ts + 18506, /* "RESET_DB" */ - FeVal: 1009}, - { - FzName: ts + 18515, /* "DEFENSIVE" */ - FeVal: 1010}, - { - FzName: ts + 18525, /* "WRITABLE_SCHEMA" */ - FeVal: 1011}, - { - FzName: ts + 18541, /* "LEGACY_ALTER_TAB..." */ - FeVal: 1012}, - { - FzName: ts + 18560, /* "DQS_DML" */ - FeVal: 1013}, - { - FzName: ts + 18568, /* "DQS_DDL" */ - FeVal: 1014}, - { - FzName: ts + 18576, /* "LEGACY_FILE_FORM..." */ - FeVal: 1016}, + {FzName: ts + 18429 /* "FKEY" */, FeVal: SQLITE_DBCONFIG_ENABLE_FKEY}, + {FzName: ts + 18434 /* "TRIGGER" */, FeVal: SQLITE_DBCONFIG_ENABLE_TRIGGER}, + {FzName: ts + 18442 /* "FTS3_TOKENIZER" */, FeVal: SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER}, + {FzName: ts + 18457 /* "LOAD_EXTENSION" */, FeVal: SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION}, + {FzName: ts + 18472 /* "NO_CKPT_ON_CLOSE" */, FeVal: SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE}, + {FzName: ts + 18489 /* "QPSG" */, FeVal: SQLITE_DBCONFIG_ENABLE_QPSG}, + {FzName: ts + 18494 /* "TRIGGER_EQP" */, FeVal: SQLITE_DBCONFIG_TRIGGER_EQP}, + {FzName: ts + 18506 /* "RESET_DB" */, FeVal: SQLITE_DBCONFIG_RESET_DATABASE}, + {FzName: ts + 18515 /* "DEFENSIVE" */, FeVal: SQLITE_DBCONFIG_DEFENSIVE}, + {FzName: ts + 18525 /* "WRITABLE_SCHEMA" */, FeVal: SQLITE_DBCONFIG_WRITABLE_SCHEMA}, + {FzName: ts + 18541 /* "LEGACY_ALTER_TAB..." */, FeVal: SQLITE_DBCONFIG_LEGACY_ALTER_TABLE}, + {FzName: ts + 18560 /* "DQS_DML" */, FeVal: SQLITE_DBCONFIG_DQS_DML}, + {FzName: ts + 18568 /* "DQS_DDL" */, FeVal: SQLITE_DBCONFIG_DQS_DDL}, + {FzName: ts + 18576 /* "LEGACY_FILE_FORM..." */, FeVal: SQLITE_DBCONFIG_LEGACY_FILE_FORMAT}, } /* test1.c:7705:5 */ // Change the name of the main database schema from "main" to "icecube". @@ -53327,14 +50398,14 @@ func test_dbconfig_maindbname_icecube(tls *libc.TLS, clientData uintptr, interp if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } else { - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+8 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+8 /* &db */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_db_config(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* db */)), 1000, libc.VaList(bp, ts+18595 /* "icecube" */)) + rc = sqlite3.Xsqlite3_db_config(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* db */)), SQLITE_DBCONFIG_MAINDBNAME, libc.VaList(bp, ts+18595 /* "icecube" */)) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } return int32(0) } @@ -53346,21 +50417,21 @@ func test_mmap_warm(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if (objc != 2) && (objc != 3) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18603 /* "DB ?DBNAME?" */) - return 1 + return TCL_ERROR } else { var rc int32 // var db uintptr at bp, 8 var zDb uintptr = uintptr(0) - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } if objc == 3 { - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) } rc = sqlite3_mmap_warm(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDb) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 0 + return TCL_OK } return int32(0) } @@ -53383,21 +50454,21 @@ func test_write_db(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18615 /* "DB OFFSET DATA" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+8 /* &iOff */) != 0 { - return 1 + if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &iOff */) != 0 { + return TCL_ERROR } - aData = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+16 /* &nData */) + aData = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+16 /* &nData */) - sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+84 /* "main" */, 7, bp+24 /* &pFile */) + sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+84 /* "main" */, SQLITE_FCNTL_FILE_POINTER, bp+24 /* &pFile */) 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 */))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 0 + return TCL_OK } // Usage: decode_hexdb TEXT @@ -53427,9 +50498,9 @@ func test_decode_hexdb(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18630 /* "HEXDB" */) - return 1 + return TCL_ERROR } - zIn = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zIn = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) for i = 0; *(*int8)(unsafe.Pointer(zIn + uintptr(i))) != 0; i = iNext { lineno++ for iNext = i; (*(*int8)(unsafe.Pointer(zIn + uintptr(iNext))) != 0) && (int32(*(*int8)(unsafe.Pointer(zIn + uintptr(iNext)))) != '\n'); iNext++ { @@ -53449,17 +50520,17 @@ func test_decode_hexdb(tls *libc.TLS, clientData uintptr, interp uintptr, objc i } 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) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+18658 /* "bad 'pagesize' f..." */, uintptr(0))) - return 1 + return TCL_ERROR } *(*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 if *(*int32)(unsafe.Pointer(bp + 216 /* n */)) < 512 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+18679 /* "bad 'size' field" */, uintptr(0))) - return 1 + return TCL_ERROR } a = libc.Xmalloc(tls, uint64(*(*int32)(unsafe.Pointer(bp + 216 /* n */)))) if a == uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+1929 /* "out of memory" */, uintptr(0))) - return 1 + return TCL_ERROR } libc.Xmemset(tls, a, 0, uint64(*(*int32)(unsafe.Pointer(bp + 216 /* n */)))) continue @@ -53470,8 +50541,8 @@ func test_decode_hexdb(tls *libc.TLS, clientData uintptr, interp uintptr, objc i continue } rc = libc.Xsscanf(tls, (zIn + uintptr(i)), ts+18716, /* "| %d: %x %x %x %..." */ - libc.VaList(bp+80, bp+224 /* &j */, (bp+232 /* &x */ +uintptr(0)*4), (bp+232 /* &x */ +uintptr(1)*4), (bp+232 /* &x */ +uintptr(2)*4), (bp+232 /* &x */ +uintptr(3)*4), (bp+232 /* &x */ +uintptr(4)*4), (bp+232 /* &x */ +uintptr(5)*4), (bp+232 /* &x */ +uintptr(6)*4), (bp+232 /* &x */ +uintptr(7)*4), - (bp+232 /* &x */ +uintptr(8)*4), (bp+232 /* &x */ +uintptr(9)*4), (bp+232 /* &x */ +uintptr(10)*4), (bp+232 /* &x */ +uintptr(11)*4), (bp+232 /* &x */ +uintptr(12)*4), (bp+232 /* &x */ +uintptr(13)*4), (bp+232 /* &x */ +uintptr(14)*4), (bp+232 /* &x */ +uintptr(15)*4))) + 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), + (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))) if rc == 17 { *(*int32)(unsafe.Pointer(bp + 228 /* k */)) = (iOffset + *(*int32)(unsafe.Pointer(bp + 224 /* j */))) if (*(*int32)(unsafe.Pointer(bp + 228 /* k */)) + 16) <= *(*int32)(unsafe.Pointer(bp + 216 /* n */)) { @@ -53485,7 +50556,7 @@ func test_decode_hexdb(tls *libc.TLS, clientData uintptr, interp uintptr, objc i } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, a, *(*int32)(unsafe.Pointer(bp + 216 /* n */)))) libc.Xfree(tls, a) - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -53507,57 +50578,57 @@ func Sqlitetest1_Init(tls *libc.TLS, interp uintptr) int32 { /* test1.c:7921:5: aObjCmd1[i].FxProc, aObjCmd1[i].FclientData, uintptr(0)) } tcl.XTcl_LinkVar(tls, interp, ts+18770, /* "sqlite_search_co..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_search_count)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_search_count)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+18790, /* "sqlite_found_cou..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_found_count)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_found_count)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+18809, /* "sqlite_sort_coun..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_sort_count)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_sort_count)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+18827, /* "sqlite3_max_blob..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_max_blobsize)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_max_blobsize)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+18848, /* "sqlite_like_coun..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_like_count)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_like_count)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+18866, /* "sqlite_interrupt..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_interrupt_count)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_interrupt_count)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+18889, /* "sqlite_open_file..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_open_file_count)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_open_file_count)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+18912, /* "sqlite_current_t..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_current_time)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_current_time)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+18932, /* "sqlite3_xferopt_..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_xferopt_count)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_xferopt_count)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+18954, /* "sqlite3_pager_re..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_pager_readdb_count)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_pager_readdb_count)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+18981, /* "sqlite3_pager_wr..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_pager_writedb_count)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_pager_writedb_count)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+19009, /* "sqlite3_pager_wr..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_pager_writej_count)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_pager_writej_count)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+19036, /* "unaligned_string..." */ - uintptr(unsafe.Pointer(&unaligned_string_counter)), 1) + uintptr(unsafe.Pointer(&unaligned_string_counter)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+19061, /* "sqlite_last_need..." */ - uintptr(unsafe.Pointer(&pzNeededCollation)), (4 | 0x80)) + uintptr(unsafe.Pointer(&pzNeededCollation)), (TCL_LINK_STRING | TCL_LINK_READ_ONLY)) { tcl.XTcl_LinkVar(tls, interp, ts+19090, /* "sqlite_query_pla..." */ - uintptr(unsafe.Pointer(&query_plan)), (4 | 0x80)) + uintptr(unsafe.Pointer(&query_plan)), (TCL_LINK_STRING | TCL_LINK_READ_ONLY)) } tcl.XTcl_LinkVar(tls, interp, ts+19108, /* "sqlite_opentemp_..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_opentemp_count)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_opentemp_count)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+19130, /* "sqlite_static_bi..." */ - uintptr(unsafe.Pointer(&sqlite_static_bind_value)), 4) + uintptr(unsafe.Pointer(&sqlite_static_bind_value)), TCL_LINK_STRING) tcl.XTcl_LinkVar(tls, interp, ts+19155, /* "sqlite_static_bi..." */ - uintptr(unsafe.Pointer(&sqlite_static_bind_nbyte)), 1) + uintptr(unsafe.Pointer(&sqlite_static_bind_nbyte)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+19180, /* "sqlite_temp_dire..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_temp_directory)), 4) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_temp_directory)), TCL_LINK_STRING) tcl.XTcl_LinkVar(tls, interp, ts+19202, /* "sqlite_data_dire..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_data_directory)), 4) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_data_directory)), TCL_LINK_STRING) tcl.XTcl_LinkVar(tls, interp, ts+19224, /* "bitmask_size" */ - uintptr(unsafe.Pointer(&bitmask_size)), (1 | 0x80)) + uintptr(unsafe.Pointer(&bitmask_size)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) tcl.XTcl_LinkVar(tls, interp, ts+19237, /* "longdouble_size" */ - uintptr(unsafe.Pointer(&longdouble_size)), (1 | 0x80)) + uintptr(unsafe.Pointer(&longdouble_size)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) tcl.XTcl_LinkVar(tls, interp, ts+19253, /* "sqlite_sync_coun..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_sync_count)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_sync_count)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+19271, /* "sqlite_fullsync_..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_fullsync_count)), 1) - return 0 + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_fullsync_count)), TCL_LINK_INT) + return TCL_OK } var iZero int32 = 0 /* test1.c:7934:14 */ @@ -53565,754 +50636,217 @@ var aCmd1 = [40]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 19293, /* "db_enter" */ - FxProc: 0}, - { - FzName: ts + 19302, /* "db_leave" */ - FxProc: 0}, - { - FzName: ts + 19311, /* "sqlite3_mprintf_..." */ - FxProc: 0}, - { - FzName: ts + 19331, /* "sqlite3_mprintf_..." */ - FxProc: 0}, - { - FzName: ts + 19353, /* "sqlite3_mprintf_..." */ - FxProc: 0}, - { - FzName: ts + 19374, /* "sqlite3_mprintf_..." */ - FxProc: 0}, - { - FzName: ts + 19394, /* "sqlite3_snprintf..." */ - FxProc: 0}, - { - FzName: ts + 19415, /* "sqlite3_mprintf_..." */ - FxProc: 0}, - { - FzName: ts + 19439, /* "sqlite3_mprintf_..." */ - FxProc: 0}, - { - FzName: ts + 19462, /* "sqlite3_mprintf_..." */ - FxProc: 0}, - { - FzName: ts + 19485, /* "sqlite3_mprintf_..." */ - FxProc: 0}, - { - FzName: ts + 19511, /* "sqlite3_mprintf_..." */ - FxProc: 0}, - { - FzName: ts + 19534, /* "sqlite3_mprintf_..." */ - FxProc: 0}, - { - FzName: ts + 19557, /* "sqlite3_snprintf..." */ - FxProc: 0}, - { - FzName: ts + 19578, /* "sqlite3_last_ins..." */ - FxProc: 0}, - { - FzName: ts + 19604, /* "sqlite3_exec_pri..." */ - FxProc: 0}, - { - FzName: ts + 19624, /* "sqlite3_exec_hex" */ - FxProc: 0}, - { - FzName: ts + 19641, /* "sqlite3_exec" */ - FxProc: 0}, - { - FzName: ts + 19654, /* "sqlite3_exec_nr" */ - FxProc: 0}, - { - FzName: ts + 19670, /* "sqlite3_get_tabl..." */ - FxProc: 0}, - { - FzName: ts + 19695, /* "sqlite3_close" */ - FxProc: 0}, - { - FzName: ts + 19709, /* "sqlite3_close_v2" */ - FxProc: 0}, - { - FzName: ts + 19726, /* "sqlite3_create_f..." */ - FxProc: 0}, - { - FzName: ts + 19750, /* "sqlite3_create_a..." */ - FxProc: 0}, - { - FzName: ts + 19775, /* "sqlite3_drop_mod..." */ - FxProc: 0}, - { - FzName: ts + 19796, /* "sqlite_register_..." */ - FxProc: 0}, - { - FzName: ts + 19826, /* "sqlite_abort" */ - FxProc: 0}, - { - FzName: ts + 19839, /* "sqlite_bind" */ - FxProc: 0}, - { - FzName: ts + 19851, /* "breakpoint" */ - FxProc: 0}, - { - FzName: ts + 19862, /* "sqlite3_key" */ - FxProc: 0}, - { - FzName: ts + 19874, /* "sqlite3_rekey" */ - FxProc: 0}, - { - FzName: ts + 19888, /* "sqlite_set_magic" */ - FxProc: 0}, - { - FzName: ts + 19905, /* "sqlite3_interrup..." */ - FxProc: 0}, - { - FzName: ts + 19923, /* "sqlite_delete_fu..." */ - FxProc: 0}, - { - FzName: ts + 19946, /* "sqlite_delete_co..." */ - FxProc: 0}, - { - FzName: ts + 19970, /* "sqlite3_get_auto..." */ - FxProc: 0}, - { - FzName: ts + 19993, /* "sqlite3_busy_tim..." */ - FxProc: 0}, - { - FzName: ts + 20014, /* "printf" */ - FxProc: 0}, - { - FzName: ts + 20021, /* "sqlite3IoTrace" */ - FxProc: 0}, - { - FzName: ts + 20036, /* "clang_sanitize_a..." */ - FxProc: 0}, + {FzName: ts + 19293 /* "db_enter" */, FxProc: 0}, + {FzName: ts + 19302 /* "db_leave" */, FxProc: 0}, + {FzName: ts + 19311 /* "sqlite3_mprintf_..." */, FxProc: 0}, + {FzName: ts + 19331 /* "sqlite3_mprintf_..." */, FxProc: 0}, + {FzName: ts + 19353 /* "sqlite3_mprintf_..." */, FxProc: 0}, + {FzName: ts + 19374 /* "sqlite3_mprintf_..." */, FxProc: 0}, + {FzName: ts + 19394 /* "sqlite3_snprintf..." */, FxProc: 0}, + {FzName: ts + 19415 /* "sqlite3_mprintf_..." */, FxProc: 0}, + {FzName: ts + 19439 /* "sqlite3_mprintf_..." */, FxProc: 0}, + {FzName: ts + 19462 /* "sqlite3_mprintf_..." */, FxProc: 0}, + {FzName: ts + 19485 /* "sqlite3_mprintf_..." */, FxProc: 0}, + {FzName: ts + 19511 /* "sqlite3_mprintf_..." */, FxProc: 0}, + {FzName: ts + 19534 /* "sqlite3_mprintf_..." */, FxProc: 0}, + {FzName: ts + 19557 /* "sqlite3_snprintf..." */, FxProc: 0}, + {FzName: ts + 19578 /* "sqlite3_last_ins..." */, FxProc: 0}, + {FzName: ts + 19604 /* "sqlite3_exec_pri..." */, FxProc: 0}, + {FzName: ts + 19624 /* "sqlite3_exec_hex" */, FxProc: 0}, + {FzName: ts + 19641 /* "sqlite3_exec" */, FxProc: 0}, + {FzName: ts + 19654 /* "sqlite3_exec_nr" */, FxProc: 0}, + {FzName: ts + 19670 /* "sqlite3_get_tabl..." */, FxProc: 0}, + {FzName: ts + 19695 /* "sqlite3_close" */, FxProc: 0}, + {FzName: ts + 19709 /* "sqlite3_close_v2" */, FxProc: 0}, + {FzName: ts + 19726 /* "sqlite3_create_f..." */, FxProc: 0}, + {FzName: ts + 19750 /* "sqlite3_create_a..." */, FxProc: 0}, + {FzName: ts + 19775 /* "sqlite3_drop_mod..." */, FxProc: 0}, + {FzName: ts + 19796 /* "sqlite_register_..." */, FxProc: 0}, + {FzName: ts + 19826 /* "sqlite_abort" */, FxProc: 0}, + {FzName: ts + 19839 /* "sqlite_bind" */, FxProc: 0}, + {FzName: ts + 19851 /* "breakpoint" */, FxProc: 0}, + {FzName: ts + 19862 /* "sqlite3_key" */, FxProc: 0}, + {FzName: ts + 19874 /* "sqlite3_rekey" */, FxProc: 0}, + {FzName: ts + 19888 /* "sqlite_set_magic" */, FxProc: 0}, + {FzName: ts + 19905 /* "sqlite3_interrup..." */, FxProc: 0}, + {FzName: ts + 19923 /* "sqlite_delete_fu..." */, FxProc: 0}, + {FzName: ts + 19946 /* "sqlite_delete_co..." */, FxProc: 0}, + {FzName: ts + 19970 /* "sqlite3_get_auto..." */, FxProc: 0}, + {FzName: ts + 19993 /* "sqlite3_busy_tim..." */, FxProc: 0}, + {FzName: ts + 20014 /* "printf" */, FxProc: 0}, + {FzName: ts + 20021 /* "sqlite3IoTrace" */, FxProc: 0}, + {FzName: ts + 20036 /* "clang_sanitize_a..." */, FxProc: 0}, } /* test1.c:7938:5 */ var aObjCmd1 = [155]struct { FzName uintptr FxProc uintptr FclientData uintptr }{ - { - FzName: ts + 20059, /* "sqlite3_db_confi..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20077, /* "bad_behavior" */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 20090, /* "register_dbstat_..." */ - FxProc: 0}, - { - FzName: ts + 20111, /* "sqlite3_connecti..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20138, /* "intarray_addr" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20152, /* "int64array_addr" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20168, /* "doublearray_addr" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20185, /* "textarray_addr" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20200, /* "sqlite3_bind_int" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20217, /* "sqlite3_bind_zer..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20239, /* "sqlite3_bind_zer..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20263, /* "sqlite3_bind_int..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20282, /* "sqlite3_bind_dou..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20302, /* "sqlite3_bind_nul..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20320, /* "sqlite3_bind_tex..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20338, /* "sqlite3_bind_tex..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20358, /* "sqlite3_bind_blo..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20376, /* "sqlite3_bind_par..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20405, /* "sqlite3_bind_par..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20433, /* "sqlite3_bind_par..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20462, /* "sqlite3_clear_bi..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20485, /* "sqlite3_sleep" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20499, /* "sqlite3_errcode" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20515, /* "sqlite3_extended..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20540, /* "sqlite3_errmsg" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20555, /* "sqlite3_errmsg16" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20572, /* "sqlite3_open" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20585, /* "sqlite3_open16" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20600, /* "sqlite3_open_v2" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20616, /* "sqlite3_complete..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20635, /* "sqlite3_normaliz..." */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 20059 /* "sqlite3_db_confi..." */, FxProc: 0}, + {FzName: ts + 20077 /* "bad_behavior" */, FxProc: 0, FclientData: 0}, + {FzName: ts + 20090 /* "register_dbstat_..." */, FxProc: 0}, + {FzName: ts + 20111 /* "sqlite3_connecti..." */, FxProc: 0}, + {FzName: ts + 20138 /* "intarray_addr" */, FxProc: 0}, + {FzName: ts + 20152 /* "int64array_addr" */, FxProc: 0}, + {FzName: ts + 20168 /* "doublearray_addr" */, FxProc: 0}, + {FzName: ts + 20185 /* "textarray_addr" */, FxProc: 0}, + {FzName: ts + 20200 /* "sqlite3_bind_int" */, FxProc: 0}, + {FzName: ts + 20217 /* "sqlite3_bind_zer..." */, FxProc: 0}, + {FzName: ts + 20239 /* "sqlite3_bind_zer..." */, FxProc: 0}, + {FzName: ts + 20263 /* "sqlite3_bind_int..." */, FxProc: 0}, + {FzName: ts + 20282 /* "sqlite3_bind_dou..." */, FxProc: 0}, + {FzName: ts + 20302 /* "sqlite3_bind_nul..." */, FxProc: 0}, + {FzName: ts + 20320 /* "sqlite3_bind_tex..." */, FxProc: 0}, + {FzName: ts + 20338 /* "sqlite3_bind_tex..." */, FxProc: 0}, + {FzName: ts + 20358 /* "sqlite3_bind_blo..." */, FxProc: 0}, + {FzName: ts + 20376 /* "sqlite3_bind_par..." */, FxProc: 0}, + {FzName: ts + 20405 /* "sqlite3_bind_par..." */, FxProc: 0}, + {FzName: ts + 20433 /* "sqlite3_bind_par..." */, FxProc: 0}, + {FzName: ts + 20462 /* "sqlite3_clear_bi..." */, FxProc: 0}, + {FzName: ts + 20485 /* "sqlite3_sleep" */, FxProc: 0}, + {FzName: ts + 20499 /* "sqlite3_errcode" */, FxProc: 0}, + {FzName: ts + 20515 /* "sqlite3_extended..." */, FxProc: 0}, + {FzName: ts + 20540 /* "sqlite3_errmsg" */, FxProc: 0}, + {FzName: ts + 20555 /* "sqlite3_errmsg16" */, FxProc: 0}, + {FzName: ts + 20572 /* "sqlite3_open" */, FxProc: 0}, + {FzName: ts + 20585 /* "sqlite3_open16" */, FxProc: 0}, + {FzName: ts + 20600 /* "sqlite3_open_v2" */, FxProc: 0}, + {FzName: ts + 20616 /* "sqlite3_complete..." */, FxProc: 0}, + {FzName: ts + 20635 /* "sqlite3_normaliz..." */, FxProc: 0}, - { - FzName: ts + 20653, /* "sqlite3_prepare" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20669, /* "sqlite3_prepare1..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20687, /* "sqlite3_prepare_..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20706, /* "sqlite3_prepare_..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20725, /* "sqlite3_prepare_..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20749, /* "sqlite3_prepare1..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20770, /* "sqlite3_finalize" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20787, /* "sqlite3_stmt_sta..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20807, /* "sqlite3_reset" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20821, /* "sqlite3_expired" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20837, /* "sqlite3_transfer..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20863, /* "sqlite3_changes" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20879, /* "sqlite3_step" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20892, /* "sqlite3_sql" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20904, /* "sqlite3_expanded..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20925, /* "sqlite3_next_stm..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20943, /* "sqlite3_stmt_rea..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20965, /* "sqlite3_stmt_ise..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 20988, /* "sqlite3_stmt_bus..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21006, /* "uses_stmt_journa..." */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 20653 /* "sqlite3_prepare" */, FxProc: 0}, + {FzName: ts + 20669 /* "sqlite3_prepare1..." */, FxProc: 0}, + {FzName: ts + 20687 /* "sqlite3_prepare_..." */, FxProc: 0}, + {FzName: ts + 20706 /* "sqlite3_prepare_..." */, FxProc: 0}, + {FzName: ts + 20725 /* "sqlite3_prepare_..." */, FxProc: 0}, + {FzName: ts + 20749 /* "sqlite3_prepare1..." */, FxProc: 0}, + {FzName: ts + 20770 /* "sqlite3_finalize" */, FxProc: 0}, + {FzName: ts + 20787 /* "sqlite3_stmt_sta..." */, FxProc: 0}, + {FzName: ts + 20807 /* "sqlite3_reset" */, FxProc: 0}, + {FzName: ts + 20821 /* "sqlite3_expired" */, FxProc: 0}, + {FzName: ts + 20837 /* "sqlite3_transfer..." */, FxProc: 0}, + {FzName: ts + 20863 /* "sqlite3_changes" */, FxProc: 0}, + {FzName: ts + 20879 /* "sqlite3_step" */, FxProc: 0}, + {FzName: ts + 20892 /* "sqlite3_sql" */, FxProc: 0}, + {FzName: ts + 20904 /* "sqlite3_expanded..." */, FxProc: 0}, + {FzName: ts + 20925 /* "sqlite3_next_stm..." */, FxProc: 0}, + {FzName: ts + 20943 /* "sqlite3_stmt_rea..." */, FxProc: 0}, + {FzName: ts + 20965 /* "sqlite3_stmt_ise..." */, FxProc: 0}, + {FzName: ts + 20988 /* "sqlite3_stmt_bus..." */, FxProc: 0}, + {FzName: ts + 21006 /* "uses_stmt_journa..." */, FxProc: 0}, - { - FzName: ts + 21024, /* "sqlite3_release_..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21047, /* "sqlite3_db_relea..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21073, /* "sqlite3_db_cache..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21095, /* "sqlite3_system_e..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21116, /* "sqlite3_db_filen..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21136, /* "sqlite3_db_reado..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21156, /* "sqlite3_soft_hea..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21180, /* "sqlite3_soft_hea..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21206, /* "sqlite3_hard_hea..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21232, /* "sqlite3_thread_c..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21255, /* "sqlite3_pager_re..." */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 21024 /* "sqlite3_release_..." */, FxProc: 0}, + {FzName: ts + 21047 /* "sqlite3_db_relea..." */, FxProc: 0}, + {FzName: ts + 21073 /* "sqlite3_db_cache..." */, FxProc: 0}, + {FzName: ts + 21095 /* "sqlite3_system_e..." */, FxProc: 0}, + {FzName: ts + 21116 /* "sqlite3_db_filen..." */, FxProc: 0}, + {FzName: ts + 21136 /* "sqlite3_db_reado..." */, FxProc: 0}, + {FzName: ts + 21156 /* "sqlite3_soft_hea..." */, FxProc: 0}, + {FzName: ts + 21180 /* "sqlite3_soft_hea..." */, FxProc: 0}, + {FzName: ts + 21206 /* "sqlite3_hard_hea..." */, FxProc: 0}, + {FzName: ts + 21232 /* "sqlite3_thread_c..." */, FxProc: 0}, + {FzName: ts + 21255 /* "sqlite3_pager_re..." */, FxProc: 0}, - { - FzName: ts + 21279, /* "sqlite3_load_ext..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21302, /* "sqlite3_enable_l..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21332, /* "sqlite3_extended..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21362, /* "sqlite3_limit" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21376, /* "dbconfig_maindbn..." */ - FxProc: 0}, + {FzName: ts + 21279 /* "sqlite3_load_ext..." */, FxProc: 0}, + {FzName: ts + 21302 /* "sqlite3_enable_l..." */, FxProc: 0}, + {FzName: ts + 21332 /* "sqlite3_extended..." */, FxProc: 0}, + {FzName: ts + 21362 /* "sqlite3_limit" */, FxProc: 0}, + {FzName: ts + 21376 /* "dbconfig_maindbn..." */, FxProc: 0}, - { - FzName: ts + 21404, /* "save_prng_state" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21420, /* "restore_prng_sta..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21439, /* "reset_prng_state" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21456, /* "prng_seed" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21466, /* "extra_schema_che..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21486, /* "database_never_c..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21509, /* "database_may_be_..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21533, /* "optimization_con..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21554, /* "tcl_objproc" */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 21404 /* "save_prng_state" */, FxProc: 0}, + {FzName: ts + 21420 /* "restore_prng_sta..." */, FxProc: 0}, + {FzName: ts + 21439 /* "reset_prng_state" */, FxProc: 0}, + {FzName: ts + 21456 /* "prng_seed" */, FxProc: 0}, + {FzName: ts + 21466 /* "extra_schema_che..." */, FxProc: 0}, + {FzName: ts + 21486 /* "database_never_c..." */, FxProc: 0}, + {FzName: ts + 21509 /* "database_may_be_..." */, FxProc: 0}, + {FzName: ts + 21533 /* "optimization_con..." */, FxProc: 0}, + {FzName: ts + 21554 /* "tcl_objproc" */, FxProc: 0}, // sqlite3_column_*() API - { - FzName: ts + 21566, /* "sqlite3_column_c..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21587, /* "sqlite3_data_cou..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21606, /* "sqlite3_column_t..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21626, /* "sqlite3_column_b..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21646, /* "sqlite3_column_d..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21668, /* "sqlite3_column_i..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21689, /* "sqlite3_column_t..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 21709, /* "sqlite3_column_n..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 21729, /* "sqlite3_column_i..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 21748, /* "sqlite3_column_b..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 21769, /* "sqlite3_column_d..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 21793, /* "sqlite3_column_d..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 21822, /* "sqlite3_column_t..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 21848, /* "sqlite3_column_o..." */ - FxProc: 0, - FclientData: 0}, + {FzName: ts + 21566 /* "sqlite3_column_c..." */, FxProc: 0}, + {FzName: ts + 21587 /* "sqlite3_data_cou..." */, FxProc: 0}, + {FzName: ts + 21606 /* "sqlite3_column_t..." */, FxProc: 0}, + {FzName: ts + 21626 /* "sqlite3_column_b..." */, FxProc: 0}, + {FzName: ts + 21646 /* "sqlite3_column_d..." */, FxProc: 0}, + {FzName: ts + 21668 /* "sqlite3_column_i..." */, FxProc: 0}, + {FzName: ts + 21689 /* "sqlite3_column_t..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 21709 /* "sqlite3_column_n..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 21729 /* "sqlite3_column_i..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 21748 /* "sqlite3_column_b..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 21769 /* "sqlite3_column_d..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 21793 /* "sqlite3_column_d..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 21822 /* "sqlite3_column_t..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 21848 /* "sqlite3_column_o..." */, FxProc: 0, FclientData: 0}, - { - FzName: ts + 21875, /* "sqlite3_column_b..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 21898, /* "sqlite3_column_t..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 21920, /* "sqlite3_column_n..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 21942, /* "add_alignment_te..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 21972, /* "sqlite3_column_d..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 21998, /* "sqlite3_column_d..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 22029, /* "sqlite3_column_t..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 22057, /* "sqlite3_column_o..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 22086, /* "sqlite3_create_c..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22114, /* "sqlite3_global_r..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22137, /* "working_64bit_in..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22155, /* "vfs_unlink_test" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22171, /* "vfs_initfail_tes..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22189, /* "vfs_unregister_a..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22208, /* "vfs_reregister_a..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22227, /* "file_control_tes..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22245, /* "file_control_las..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22273, /* "file_control_loc..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22301, /* "file_control_chu..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22329, /* "file_control_siz..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22356, /* "file_control_dat..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22382, /* "file_control_per..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22407, /* "file_control_pow..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22440, /* "file_control_vfs..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22461, /* "file_control_tem..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22487, /* "sqlite3_vfs_list" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22504, /* "sqlite3_create_f..." */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 21875 /* "sqlite3_column_b..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 21898 /* "sqlite3_column_t..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 21920 /* "sqlite3_column_n..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 21942 /* "add_alignment_te..." */, FxProc: 0}, + {FzName: ts + 21972 /* "sqlite3_column_d..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 21998, /* "sqlite3_column_d..." */ + FxProc: 0, FclientData: 0}, + {FzName: ts + 22029 /* "sqlite3_column_t..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 22057 /* "sqlite3_column_o..." */, FxProc: 0, FclientData: 0}, + {FzName: ts + 22086 /* "sqlite3_create_c..." */, FxProc: 0}, + {FzName: ts + 22114 /* "sqlite3_global_r..." */, FxProc: 0}, + {FzName: ts + 22137 /* "working_64bit_in..." */, FxProc: 0}, + {FzName: ts + 22155 /* "vfs_unlink_test" */, FxProc: 0}, + {FzName: ts + 22171 /* "vfs_initfail_tes..." */, FxProc: 0}, + {FzName: ts + 22189 /* "vfs_unregister_a..." */, FxProc: 0}, + {FzName: ts + 22208 /* "vfs_reregister_a..." */, FxProc: 0}, + {FzName: ts + 22227 /* "file_control_tes..." */, FxProc: 0}, + {FzName: ts + 22245 /* "file_control_las..." */, FxProc: 0}, + {FzName: ts + 22273 /* "file_control_loc..." */, FxProc: 0}, + {FzName: ts + 22301 /* "file_control_chu..." */, FxProc: 0}, + {FzName: ts + 22329 /* "file_control_siz..." */, FxProc: 0}, + {FzName: ts + 22356 /* "file_control_dat..." */, FxProc: 0}, + {FzName: ts + 22382 /* "file_control_per..." */, FxProc: 0}, + {FzName: ts + 22407 /* "file_control_pow..." */, FxProc: 0}, + {FzName: ts + 22440 /* "file_control_vfs..." */, FxProc: 0}, + {FzName: ts + 22461 /* "file_control_tem..." */, FxProc: 0}, + {FzName: ts + 22487 /* "sqlite3_vfs_list" */, FxProc: 0}, + {FzName: ts + 22504 /* "sqlite3_create_f..." */, FxProc: 0}, // Functions from os.h - { - FzName: ts + 22531, /* "add_test_collate" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22548, /* "add_test_collate..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22572, /* "add_test_functio..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22590, /* "add_test_utf16bi..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22616, /* "sqlite3_test_err..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22636, /* "tcl_variable_typ..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22654, /* "sqlite3_enable_s..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22682, /* "sqlite3_shared_c..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22710, /* "sqlite3_libversi..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22736, /* "sqlite3_table_co..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22766, /* "sqlite3_blob_reo..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22786, /* "pcache_stats" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22799, /* "sqlite3_unlock_n..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22821, /* "sqlite3_wal_chec..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22844, /* "sqlite3_wal_chec..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22870, /* "sqlite3_wal_auto..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22897, /* "test_sqlite3_log" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22914, /* "print_explain_qu..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 22939, /* "sqlite3_test_con..." */ - FxProc: 0}, - { - FzName: ts + 22960, /* "getrusage" */ - FxProc: 0}, - { - FzName: ts + 22970, /* "load_static_exte..." */ - FxProc: 0}, - { - FzName: ts + 22992, /* "sorter_test_fake..." */ - FxProc: 0}, - { - FzName: ts + 23013, /* "sorter_test_sort..." */ - FxProc: 0}, - { - FzName: ts + 23038, /* "vfs_current_time..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23061, /* "sqlite3_snapshot..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23082, /* "sqlite3_snapshot..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23104, /* "sqlite3_snapshot..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23126, /* "sqlite3_snapshot..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23147, /* "sqlite3_snapshot..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23172, /* "sqlite3_snapshot..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23198, /* "sqlite3_snapshot..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23225, /* "sqlite3_snapshot..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23251, /* "sqlite3_delete_d..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23275, /* "atomic_batch_wri..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23294, /* "sqlite3_mmap_war..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23312, /* "sqlite3_config_s..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23337, /* "decode_hexdb" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 23350, /* "test_write_db" */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 22531 /* "add_test_collate" */, FxProc: 0}, + {FzName: ts + 22548 /* "add_test_collate..." */, FxProc: 0}, + {FzName: ts + 22572 /* "add_test_functio..." */, FxProc: 0}, + {FzName: ts + 22590 /* "add_test_utf16bi..." */, FxProc: 0}, + {FzName: ts + 22616 /* "sqlite3_test_err..." */, FxProc: 0}, + {FzName: ts + 22636 /* "tcl_variable_typ..." */, FxProc: 0}, + {FzName: ts + 22654 /* "sqlite3_enable_s..." */, FxProc: 0}, + {FzName: ts + 22682 /* "sqlite3_shared_c..." */, FxProc: 0}, + {FzName: ts + 22710 /* "sqlite3_libversi..." */, FxProc: 0}, + {FzName: ts + 22736 /* "sqlite3_table_co..." */, FxProc: 0}, + {FzName: ts + 22766 /* "sqlite3_blob_reo..." */, FxProc: 0}, + {FzName: ts + 22786 /* "pcache_stats" */, FxProc: 0}, + {FzName: ts + 22799 /* "sqlite3_unlock_n..." */, FxProc: 0}, + {FzName: ts + 22821 /* "sqlite3_wal_chec..." */, FxProc: 0}, + {FzName: ts + 22844 /* "sqlite3_wal_chec..." */, FxProc: 0}, + {FzName: ts + 22870 /* "sqlite3_wal_auto..." */, FxProc: 0}, + {FzName: ts + 22897 /* "test_sqlite3_log" */, FxProc: 0}, + {FzName: ts + 22914 /* "print_explain_qu..." */, FxProc: 0}, + {FzName: ts + 22939 /* "sqlite3_test_con..." */, FxProc: 0}, + {FzName: ts + 22960 /* "getrusage" */, FxProc: 0}, + {FzName: ts + 22970 /* "load_static_exte..." */, FxProc: 0}, + {FzName: ts + 22992 /* "sorter_test_fake..." */, FxProc: 0}, + {FzName: ts + 23013 /* "sorter_test_sort..." */, FxProc: 0}, + {FzName: ts + 23038 /* "vfs_current_time..." */, FxProc: 0}, + {FzName: ts + 23061 /* "sqlite3_snapshot..." */, FxProc: 0}, + {FzName: ts + 23082 /* "sqlite3_snapshot..." */, FxProc: 0}, + {FzName: ts + 23104 /* "sqlite3_snapshot..." */, FxProc: 0}, + {FzName: ts + 23126 /* "sqlite3_snapshot..." */, FxProc: 0}, + {FzName: ts + 23147 /* "sqlite3_snapshot..." */, FxProc: 0}, + {FzName: ts + 23172 /* "sqlite3_snapshot..." */, FxProc: 0}, + {FzName: ts + 23198 /* "sqlite3_snapshot..." */, FxProc: 0}, + {FzName: ts + 23225 /* "sqlite3_snapshot..." */, FxProc: 0}, + {FzName: ts + 23251 /* "sqlite3_delete_d..." */, FxProc: 0}, + {FzName: ts + 23275 /* "atomic_batch_wri..." */, FxProc: 0}, + {FzName: ts + 23294 /* "sqlite3_mmap_war..." */, FxProc: 0}, + {FzName: ts + 23312 /* "sqlite3_config_s..." */, FxProc: 0}, + {FzName: ts + 23337 /* "decode_hexdb" */, FxProc: 0}, + {FzName: ts + 23350 /* "test_write_db" */, FxProc: 0}, } /* test1.c:7986:5 */ var bitmask_size int32 = (int32(uint64(unsafe.Sizeof(Bitmask(0))) * uint64(8))) /* test1.c:8206:14 */ var longdouble_size int32 = int32(unsafe.Sizeof(float64(0))) /* test1.c:8207:14 */ @@ -54343,26 +50877,26 @@ func pager_open(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv // var zBuf [100]int8 at bp+92, 100 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23390 /* " FILENAME N-PAGE..." */, 0)) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+72 /* &nPage */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+72 /* &nPage */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3PagerOpen(tls, sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)), bp+80 /* &pPager */, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), 0, 0, - ((0x00000002 | 0x00000004) | 0x00000100), + rc = sqlite3.Xsqlite3PagerOpen(tls, sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)), bp+80 /* &pPager */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), 0, 0, + ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_MAIN_DB), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{pager_test_reiniter}))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } sqlite3.Xsqlite3PagerSetCachesize(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pPager */)), *(*int32)(unsafe.Pointer(bp + 72 /* nPage */))) *(*u322)(unsafe.Pointer(bp + 88 /* pageSize */)) = u322(test_pagesize) sqlite3.Xsqlite3PagerSetPagesize(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pPager */)), bp+88 /* &pageSize */, -1) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+92 /* &zBuf[0] */, ts+12843 /* "%p" */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(bp + 80 /* pPager */)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+92 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: pager_close ID @@ -54375,17 +50909,17 @@ func pager_close(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, arg var pPager uintptr var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) rc = sqlite3.Xsqlite3PagerClose(tls, pPager, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: pager_rollback ID @@ -54398,17 +50932,17 @@ func pager_rollback(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var pPager uintptr var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) rc = sqlite3.Xsqlite3PagerRollback(tls, pPager) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: pager_commit ID @@ -54421,22 +50955,22 @@ func pager_commit(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, ar var pPager uintptr var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) rc = sqlite3.Xsqlite3PagerCommitPhaseOne(tls, pPager, uintptr(0), 0) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } rc = sqlite3.Xsqlite3PagerCommitPhaseTwo(tls, pPager) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: pager_stmt_begin ID @@ -54449,17 +50983,17 @@ func pager_stmt_begin(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32 var pPager uintptr var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) rc = sqlite3.Xsqlite3PagerOpenSavepoint(tls, pPager, 1) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: pager_stmt_rollback ID @@ -54472,18 +51006,18 @@ func pager_stmt_rollback(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc in var pPager uintptr var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - rc = sqlite3.Xsqlite3PagerSavepoint(tls, pPager, 2, 0) - sqlite3.Xsqlite3PagerSavepoint(tls, pPager, 1, 0) - if rc != 0 { + pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + rc = sqlite3.Xsqlite3PagerSavepoint(tls, pPager, SAVEPOINT_ROLLBACK, 0) + sqlite3.Xsqlite3PagerSavepoint(tls, pPager, SAVEPOINT_RELEASE, 0) + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: pager_stmt_commit ID @@ -54496,17 +51030,17 @@ func pager_stmt_commit(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 var pPager uintptr var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - rc = sqlite3.Xsqlite3PagerSavepoint(tls, pPager, 1, 0) - if rc != 0 { + pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + rc = sqlite3.Xsqlite3PagerSavepoint(tls, pPager, SAVEPOINT_RELEASE, 0) + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: pager_stats ID @@ -54520,11 +51054,11 @@ func pager_stats(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, arg var i int32 var a uintptr if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) a = sqlite3.Xsqlite3PagerStats(tls, pPager) for i = 0; i < 9; i++ { // var zBuf [100]int8 at bp+40, 100 @@ -54533,7 +51067,7 @@ func pager_stats(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, arg sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+40 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(a + uintptr(i)*4)))) tcl.XTcl_AppendElement(tls, interp, bp+40 /* &zBuf[0] */) } - return 0 + return TCL_OK } var zName = [9]uintptr{ @@ -54554,15 +51088,15 @@ func pager_pagecount(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, // var nPage int32 at bp+56, 4 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) sqlite3.Xsqlite3PagerPagecount(tls, pPager, bp+56 /* &nPage */) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+60 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 56 /* nPage */)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+60 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: page_get ID PGNO @@ -54580,25 +51114,25 @@ func page_get(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv u var rc int32 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23440 /* " ID PGNO\"" */, 0)) - return 1 + return TCL_ERROR } - pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+72 /* &pgno */) != 0 { - return 1 + pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+72 /* &pgno */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3PagerSharedLock(tls, pPager) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3PagerGet(tls, pPager, uint32(*(*int32)(unsafe.Pointer(bp + 72 /* pgno */))), bp+80 /* &pPage */, 0) } - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+88 /* &zBuf[0] */, ts+12843 /* "%p" */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(bp + 80 /* pPage */)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+88 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: page_lookup ID PGNO @@ -54616,20 +51150,20 @@ func page_lookup(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, arg // var pgno int32 at bp+56, 4 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23440 /* " ID PGNO\"" */, 0)) - return 1 + return TCL_ERROR } - pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+56 /* &pgno */) != 0 { - return 1 + pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+56 /* &pgno */) != 0 { + return TCL_ERROR } pPage = sqlite3.Xsqlite3PagerLookup(tls, pPager, uint32(*(*int32)(unsafe.Pointer(bp + 56 /* pgno */)))) if pPage != 0 { sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+60 /* &zBuf[0] */, ts+12843 /* "%p" */, libc.VaList(bp+32, pPage)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+60 /* &zBuf[0] */, 0)) } - return 0 + return TCL_OK } // Usage: pager_truncate ID PGNO @@ -54641,16 +51175,16 @@ func pager_truncate(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, // var pgno int32 at bp+32, 4 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23440 /* " ID PGNO\"" */, 0)) - return 1 + return TCL_ERROR } - pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+32 /* &pgno */) != 0 { - return 1 + pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+32 /* &pgno */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3PagerTruncateImage(tls, pPager, uint32(*(*int32)(unsafe.Pointer(bp + 32 /* pgno */)))) - return 0 + return TCL_OK } // Usage: page_unref PAGE @@ -54662,13 +51196,13 @@ func page_unref(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv var pPage uintptr if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23450 /* " PAGE\"" */, 0)) - return 1 + return TCL_ERROR } - pPage = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pPage = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) sqlite3.Xsqlite3PagerUnref(tls, pPage) - return 0 + return TCL_OK } // Usage: page_read PAGE @@ -54682,14 +51216,14 @@ func page_read(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv var pPage uintptr if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23450 /* " PAGE\"" */, 0)) - return 1 + return TCL_ERROR } - pPage = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pPage = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) libc.Xmemcpy(tls, bp+48 /* &zBuf[0] */, sqlite3.Xsqlite3PagerGetData(tls, pPage), uint64(unsafe.Sizeof([100]int8{}))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+48 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: page_number PAGE @@ -54703,14 +51237,14 @@ func page_number(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, arg var pPage uintptr if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23450 /* " PAGE\"" */, 0)) - return 1 + return TCL_ERROR } - pPage = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pPage = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+56 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+32, sqlite3.Xsqlite3PagerPagenumber(tls, pPage))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+56 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: page_write PAGE DATA @@ -54724,20 +51258,20 @@ func page_write(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv var pData uintptr var rc int32 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23457 /* " PAGE DATA\"" */, 0)) - return 1 + return TCL_ERROR } - pPage = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pPage = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) rc = sqlite3.Xsqlite3PagerWrite(tls, pPage) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } pData = sqlite3.Xsqlite3PagerGetData(tls, pPage) - libc.Xstrncpy(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), (uint64(test_pagesize - 1))) + libc.Xstrncpy(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 2*8)), (uint64(test_pagesize - 1))) *(*int8)(unsafe.Pointer(pData + uintptr((test_pagesize - 1)))) = int8(0) - return 0 + return TCL_OK } // Usage: fake_big_file N FILENAME @@ -54760,28 +51294,28 @@ func fake_big_file(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, a var zFile uintptr var nFile int32 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23469 /* " N-MEGABYTES FIL..." */, 0)) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+80 /* &n */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+80 /* &n */) != 0 { + return TCL_ERROR } pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) - nFile = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + nFile = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) zFile = sqlite3.Xsqlite3_malloc(tls, (nFile + 2)) if zFile == uintptr(0) { - return 1 + return TCL_ERROR } - libc.Xmemcpy(tls, zFile, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), (uint64(nFile + 1))) + libc.Xmemcpy(tls, zFile, *(*uintptr)(unsafe.Pointer(argv + 2*8)), (uint64(nFile + 1))) *(*int8)(unsafe.Pointer(zFile + uintptr((nFile + 1)))) = int8(0) rc = sqlite3.Xsqlite3OsOpenMalloc(tls, pVfs, zFile, bp+88, /* &fd */ - ((0x00000004 | 0x00000002) | 0x00000100), uintptr(0)) + ((SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE) | SQLITE_OPEN_MAIN_DB), uintptr(0)) if rc != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+23488 /* "open failed: " */, sqlite3.Xsqlite3ErrName(tls, rc), 0)) sqlite3.Xsqlite3_free(tls, zFile) - return 1 + return TCL_ERROR } offset = i64(*(*int32)(unsafe.Pointer(bp + 80 /* n */))) offset = offset * (int64(1024 * 1024)) @@ -54790,9 +51324,9 @@ func fake_big_file(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, a sqlite3.Xsqlite3_free(tls, zFile) if rc != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, ts+23516 /* "write failed: " */, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // test_control_pending_byte PENDING_BYTE @@ -54806,16 +51340,16 @@ func testPendingByte(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23531 /* " PENDING-BYTE\"" */, uintptr(0))) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+40 /* &pbyte */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+40 /* &pbyte */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_test_control(tls, 11, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 40 /* pbyte */)))) + rc = sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_PENDING_BYTE, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 40 /* pbyte */)))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } // The sqlite3FaultSim() callback: @@ -54842,7 +51376,7 @@ func faultSimCallback(tls *libc.TLS, x int32) int32 { /* test2.c:583:12: */ } else { isNeg = 0 } - *(*int8)(unsafe.Pointer(bp + 8 /* &zInt[0] */ + uintptr((uint64(unsafe.Sizeof([30]int8{})) - uint64(1))))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 8 /* &zInt[0] */ + 29)) = int8(0) i = (int32(uint64(unsafe.Sizeof([30]int8{})) - uint64(2))) __1: if !((i > 0) && (x > 0)) { @@ -54868,7 +51402,7 @@ func faultSimCallback(tls *libc.TLS, x int32) int32 { /* test2.c:583:12: */ rc = tcl.XTcl_Eval(tls, faultSimInterp, faultSimScript) if rc != 0 { libc.Xfprintf(tls, libc.Xstderr, ts+23546 /* "fault simulator ..." */, libc.VaList(bp, faultSimScript)) - rc = 1 + rc = SQLITE_ERROR } else { rc = libc.Xatoi(tls, tcl.XTcl_GetStringResult(tls, faultSimInterp)) } @@ -54889,11 +51423,11 @@ func faultInstallCmd(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var nScript int32 var rc int32 if (argc != 1) && (argc != 2) { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23582 /* " SCRIPT\"" */, uintptr(0))) } if argc == 2 { - zScript = *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) + zScript = *(*uintptr)(unsafe.Pointer(argv + 1*8)) } else { zScript = ts + 488 /* "" */ } @@ -54903,21 +51437,21 @@ func faultInstallCmd(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, faultSimScript = uintptr(0) } if nScript == 0 { - rc = sqlite3.Xsqlite3_test_control(tls, 9, libc.VaList(bp+32, 0)) + rc = sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_FAULT_INSTALL, libc.VaList(bp+32, 0)) } else { faultSimScript = libc.Xmalloc(tls, (uint64(nScript + 100))) if faultSimScript == uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, ts+1929 /* "out of memory" */, uintptr(0))) - return 1 + return SQLITE_ERROR } libc.Xmemcpy(tls, faultSimScript, zScript, uint64(nScript)) *(*int8)(unsafe.Pointer(faultSimScript + uintptr(nScript))) = int8(' ') faultSimScriptSize = (nScript + 1) faultSimInterp = interp - rc = sqlite3.Xsqlite3_test_control(tls, 9, libc.VaList(bp+56, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, int32) int32 }{faultSimCallback})))) + 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})))) } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return SQLITE_OK } // sqlite3BitvecBuiltinTest SIZE PROGRAM @@ -54936,13 +51470,13 @@ func testBitvecBuiltinTest(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc var z uintptr if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23591 /* " SIZE PROGRAM\"" */, uintptr(0))) } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+48 /* &sz */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+48 /* &sz */) != 0 { + return TCL_ERROR } - z = *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)) + z = *(*uintptr)(unsafe.Pointer(argv + 2*8)) for (nProg < 99) && (*(*int8)(unsafe.Pointer(z)) != 0) { for (*(*int8)(unsafe.Pointer(z)) != 0) && !((int32(sqlite3.Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z)))]) & 0x04) != 0) { z++ @@ -54956,9 +51490,9 @@ func testBitvecBuiltinTest(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc } } *(*int32)(unsafe.Pointer(bp + 52 /* &aProg[0] */ + uintptr(nProg)*4)) = 0 - rc = sqlite3.Xsqlite3_test_control(tls, 8, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 48 /* sz */)), bp+52 /* &aProg[0] */)) + rc = sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_BITVEC_TEST, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 48 /* sz */)), bp+52 /* &aProg[0] */)) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -54971,86 +51505,46 @@ func Sqlitetest2_Init(tls *libc.TLS, interp uintptr) int32 { /* test2.c:697:5: * tcl.XTcl_CreateCommand(tls, interp, aCmd2[i].FzName, aCmd2[i].FxProc, uintptr(0), uintptr(0)) } tcl.XTcl_LinkVar(tls, interp, ts+23606, /* "sqlite_io_error_..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_io_error_pending)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_io_error_pending)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+23630, /* "sqlite_io_error_..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_io_error_persist)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_io_error_persist)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+23654, /* "sqlite_io_error_..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_io_error_hit)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_io_error_hit)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+23674, /* "sqlite_io_error_..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_io_error_hardhit)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_io_error_hardhit)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+23698, /* "sqlite_diskfull_..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_diskfull_pending)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_diskfull_pending)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+23722, /* "sqlite_diskfull" */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_diskfull)), 1) + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_diskfull)), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+23738, /* "sqlite_pending_b..." */ - uintptr(unsafe.Pointer(&sqlite3.Xsqlite3PendingByte)), (1 | 0x80)) - return 0 + uintptr(unsafe.Pointer(&sqlite3.Xsqlite3PendingByte)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) + return TCL_OK } var aCmd2 = [20]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 23758, /* "pager_open" */ - FxProc: 0}, - { - FzName: ts + 23769, /* "pager_close" */ - FxProc: 0}, - { - FzName: ts + 23781, /* "pager_commit" */ - FxProc: 0}, - { - FzName: ts + 23794, /* "pager_rollback" */ - FxProc: 0}, - { - FzName: ts + 23809, /* "pager_stmt_begin" */ - FxProc: 0}, - { - FzName: ts + 23826, /* "pager_stmt_commi..." */ - FxProc: 0}, - { - FzName: ts + 23844, /* "pager_stmt_rollb..." */ - FxProc: 0}, - { - FzName: ts + 23864, /* "pager_stats" */ - FxProc: 0}, - { - FzName: ts + 23876, /* "pager_pagecount" */ - FxProc: 0}, - { - FzName: ts + 23892, /* "page_get" */ - FxProc: 0}, - { - FzName: ts + 23901, /* "page_lookup" */ - FxProc: 0}, - { - FzName: ts + 23913, /* "page_unref" */ - FxProc: 0}, - { - FzName: ts + 23924, /* "page_read" */ - FxProc: 0}, - { - FzName: ts + 23934, /* "page_write" */ - FxProc: 0}, - { - FzName: ts + 23945, /* "page_number" */ - FxProc: 0}, - { - FzName: ts + 23957, /* "pager_truncate" */ - FxProc: 0}, - { - FzName: ts + 23972, /* "fake_big_file" */ - FxProc: 0}, - { - FzName: ts + 23986, /* "sqlite3BitvecBui..." */ - FxProc: 0}, - { - FzName: ts + 24011, /* "sqlite3_test_con..." */ - FxProc: 0}, - { - FzName: ts + 24045, /* "sqlite3_test_con..." */ - FxProc: 0}, + {FzName: ts + 23758 /* "pager_open" */, FxProc: 0}, + {FzName: ts + 23769 /* "pager_close" */, FxProc: 0}, + {FzName: ts + 23781 /* "pager_commit" */, FxProc: 0}, + {FzName: ts + 23794 /* "pager_rollback" */, FxProc: 0}, + {FzName: ts + 23809 /* "pager_stmt_begin" */, FxProc: 0}, + {FzName: ts + 23826 /* "pager_stmt_commi..." */, FxProc: 0}, + {FzName: ts + 23844 /* "pager_stmt_rollb..." */, FxProc: 0}, + {FzName: ts + 23864 /* "pager_stats" */, FxProc: 0}, + {FzName: ts + 23876 /* "pager_pagecount" */, FxProc: 0}, + {FzName: ts + 23892 /* "page_get" */, FxProc: 0}, + {FzName: ts + 23901 /* "page_lookup" */, FxProc: 0}, + {FzName: ts + 23913 /* "page_unref" */, FxProc: 0}, + {FzName: ts + 23924 /* "page_read" */, FxProc: 0}, + {FzName: ts + 23934 /* "page_write" */, FxProc: 0}, + {FzName: ts + 23945 /* "page_number" */, FxProc: 0}, + {FzName: ts + 23957 /* "pager_truncate" */, FxProc: 0}, + {FzName: ts + 23972 /* "fake_big_file" */, FxProc: 0}, + {FzName: ts + 23986 /* "sqlite3BitvecBui..." */, FxProc: 0}, + {FzName: ts + 24011 /* "sqlite3_test_con..." */, FxProc: 0}, + {FzName: ts + 24045 /* "sqlite3_test_con..." */, FxProc: 0}, } /* test2.c:707:5 */ // 2001 September 15 @@ -55827,37 +52321,37 @@ func btree_open(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv var n int32 var zFilename uintptr if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24080 /* " FILENAME NCACHE..." */, 0)) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+72 /* &nCache */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+72 /* &nCache */) != 0 { + return TCL_ERROR } nRefSqlite3++ if nRefSqlite3 == 1 { sDb.FpVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) - sDb.Fmutex = sqlite3.Xsqlite3MutexAlloc(tls, 1) + sDb.Fmutex = sqlite3.Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_RECURSIVE) sqlite3.Xsqlite3_mutex_enter(tls, sDb.Fmutex) } - n = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) + n = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) zFilename = sqlite3.Xsqlite3_malloc(tls, (n + 2)) if zFilename == uintptr(0) { - return 1 + return TCL_ERROR } - libc.Xmemcpy(tls, zFilename, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), (uint64(n + 1))) + libc.Xmemcpy(tls, zFilename, *(*uintptr)(unsafe.Pointer(argv + 1*8)), (uint64(n + 1))) *(*int8)(unsafe.Pointer(zFilename + uintptr((n + 1)))) = int8(0) rc = sqlite3.Xsqlite3BtreeOpen(tls, sDb.FpVfs, zFilename, uintptr(unsafe.Pointer(&sDb)), bp+80 /* &pBt */, 0, - ((0x00000002 | 0x00000004) | 0x00000100)) + ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_MAIN_DB)) sqlite3.Xsqlite3_free(tls, zFilename) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } sqlite3.Xsqlite3BtreeSetCacheSize(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pBt */)), *(*int32)(unsafe.Pointer(bp + 72 /* nCache */))) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+88 /* &zBuf[0] */, ts+12843 /* "%p" */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(bp + 80 /* pBt */)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+88 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: btree_close ID @@ -55870,15 +52364,15 @@ func btree_close(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, arg var pBt uintptr var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) rc = sqlite3.Xsqlite3BtreeClose(tls, pBt) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } nRefSqlite3-- if nRefSqlite3 == 0 { @@ -55887,7 +52381,7 @@ func btree_close(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, arg sDb.Fmutex = uintptr(0) sDb.FpVfs = uintptr(0) } - return 0 + return TCL_OK } // Usage: btree_begin_transaction ID @@ -55900,19 +52394,19 @@ func btree_begin_transaction(tls *libc.TLS, NotUsed uintptr, interp uintptr, arg var pBt uintptr var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) sqlite3.Xsqlite3BtreeEnter(tls, pBt) rc = sqlite3.Xsqlite3BtreeBeginTrans(tls, pBt, 1, uintptr(0)) sqlite3.Xsqlite3BtreeLeave(tls, pBt) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: btree_pager_stats ID @@ -55927,11 +52421,11 @@ func btree_pager_stats(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 var a uintptr if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) // Normally in this file, with a b-tree handle opened using the // [btree_open] command it is safe to call sqlite3BtreeEnter() directly. @@ -55954,7 +52448,7 @@ func btree_pager_stats(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 // Release the mutex on the SQLite handle that controls this b-tree sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) - return 0 + return TCL_OK } var zName1 = [11]uintptr{ @@ -55973,32 +52467,32 @@ func btree_cursor(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, ar // var iTable int32 at bp+72, 4 var pCur uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK // var wrFlag int32 at bp+76, 4 // var zBuf [30]int8 at bp+80, 30 if argc != 4 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24115 /* " ID TABLENUM WRI..." */, 0)) - return 1 + return TCL_ERROR } - pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+72 /* &iTable */) != 0 { - return 1 + pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+72 /* &iTable */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetBoolean(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)), bp+76 /* &wrFlag */) != 0 { - return 1 + if tcl.XTcl_GetBoolean(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 3*8)), bp+76 /* &wrFlag */) != 0 { + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 76 /* wrFlag */)) != 0 { - *(*int32)(unsafe.Pointer(bp + 76 /* wrFlag */)) = 0x00000004 + *(*int32)(unsafe.Pointer(bp + 76 /* wrFlag */)) = BTREE_WRCSR } pCur = tcl.XTcl_Alloc(tls, uint32(sqlite3.Xsqlite3BtreeCursorSize(tls))) libc.Xmemset(tls, pCur, 0, uint64(sqlite3.Xsqlite3BtreeCursorSize(tls))) sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) sqlite3.Xsqlite3BtreeEnter(tls, pBt) rc = sqlite3.Xsqlite3BtreeLockTable(tls, pBt, *(*int32)(unsafe.Pointer(bp + 72 /* iTable */)), libc.BoolUint8(!(!(*(*int32)(unsafe.Pointer(bp + 76 /* wrFlag */)) != 0)))) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3BtreeCursor(tls, pBt, uint32(*(*int32)(unsafe.Pointer(bp + 72 /* iTable */))), *(*int32)(unsafe.Pointer(bp + 76 /* wrFlag */)), uintptr(0), pCur) } sqlite3.Xsqlite3BtreeLeave(tls, pBt) @@ -56006,11 +52500,11 @@ func btree_cursor(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, ar if rc != 0 { tcl.XTcl_Free(tls, pCur) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+80 /* &zBuf[0] */, ts+12843 /* "%p" */, libc.VaList(bp+48, pCur)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+80 /* &zBuf[0] */, 0)) - return 0 + return SQLITE_OK } // Usage: btree_close_cursor ID @@ -56024,11 +52518,11 @@ func btree_close_cursor(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int var rc int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) { var pBt uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpBtree sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) @@ -56041,9 +52535,9 @@ func btree_close_cursor(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int tcl.XTcl_Free(tls, pCur) if rc != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } - return 0 + return SQLITE_OK } // Usage: btree_next ID @@ -56061,25 +52555,25 @@ func btree_next(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv // var zBuf [100]int8 at bp+72, 100 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) sqlite3.Xsqlite3BtreeEnter(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) rc = sqlite3.Xsqlite3BtreeNext(tls, pCur, 0) - if rc == 101 { + if rc == SQLITE_DONE { res = 1 - rc = 0 + rc = SQLITE_OK } sqlite3.Xsqlite3BtreeLeave(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) if rc != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+72 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+48, res)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+72 /* &zBuf[0] */, 0)) - return 0 + return SQLITE_OK } // Usage: btree_first ID @@ -56096,21 +52590,21 @@ func btree_first(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, arg // var zBuf [100]int8 at bp+76, 100 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) sqlite3.Xsqlite3BtreeEnter(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) rc = sqlite3.Xsqlite3BtreeFirst(tls, pCur, bp+72 /* &res */) sqlite3.Xsqlite3BtreeLeave(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) if rc != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) - return 1 + return TCL_ERROR } sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+76 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+48, *(*int32)(unsafe.Pointer(bp + 72 /* res */)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+76 /* &zBuf[0] */, 0)) - return 0 + return SQLITE_OK } // Usage: btree_eof ID @@ -56126,17 +52620,17 @@ func btree_eof(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv // var zBuf [50]int8 at bp+56, 50 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) sqlite3.Xsqlite3BtreeEnter(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) rc = sqlite3.Xsqlite3BtreeEof(tls, pCur) sqlite3.Xsqlite3BtreeLeave(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+56 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+32, rc)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+56 /* &zBuf[0] */, 0)) - return 0 + return SQLITE_OK } // Usage: btree_payload_size ID @@ -56151,17 +52645,17 @@ func btree_payload_size(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int // var zBuf [50]int8 at bp+56, 50 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) sqlite3.Xsqlite3BtreeEnter(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) n = sqlite3.Xsqlite3BtreePayloadSize(tls, pCur) sqlite3.Xsqlite3BtreeLeave(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+56 /* &zBuf[0] */, ts+17097 /* "%u" */, libc.VaList(bp+32, n)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+56 /* &zBuf[0] */, 0)) - return 0 + return SQLITE_OK } // usage: varint_test START MULTIPLIER COUNT INCREMENT @@ -56198,21 +52692,21 @@ func btree_varint_test(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 // var zBuf [100]uint8 at bp+200, 100 if argc != 5 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24139 /* " START MULTIPLIE..." */, 0)) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+184 /* &start */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+184 /* &start */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+188 /* &mult */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+188 /* &mult */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)), bp+192 /* &count */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 3*8)), bp+192 /* &count */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)), bp+196 /* &incr */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 4*8)), bp+196 /* &incr */) != 0 { + return TCL_ERROR } in = u64(*(*u322)(unsafe.Pointer(bp + 184 /* start */))) in = in * (u64(*(*u322)(unsafe.Pointer(bp + 188 /* mult */)))) @@ -56224,20 +52718,20 @@ func btree_varint_test(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([200]int8{})), bp+300, /* &zErr[0] */ ts+24174 /* "putVarint return..." */, libc.VaList(bp+32, n1)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+300 /* &zErr[0] */, 0)) - return 1 + return TCL_ERROR } n2 = int32(sqlite3.Xsqlite3GetVarint(tls, bp+200 /* &zBuf[0] */, bp+504 /* &out */)) if n1 != n2 { sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([200]int8{})), bp+300, /* &zErr[0] */ ts+24224 /* "putVarint return..." */, libc.VaList(bp+56, n1, n2)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, bp+300 /* &zErr[0] */, 0)) - return 1 + return TCL_ERROR } if in != *(*u64)(unsafe.Pointer(bp + 504 /* out */)) { sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([200]int8{})), bp+300, /* &zErr[0] */ ts+24272 /* "Wrote 0x%016llx ..." */, libc.VaList(bp+88, in, *(*u64)(unsafe.Pointer(bp + 504 /* out */)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+104, bp+300 /* &zErr[0] */, 0)) - return 1 + return TCL_ERROR } if (in & uint64(0xffffffff)) == in { // var out32 u322 at bp+512, 4 @@ -56257,14 +52751,14 @@ func btree_varint_test(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 ts+24311, /* "putVarint return..." */ libc.VaList(bp+120, n1, n2)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+136, bp+300 /* &zErr[0] */, 0)) - return 1 + return TCL_ERROR } if in != *(*u64)(unsafe.Pointer(bp + 504 /* out */)) { sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([200]int8{})), bp+300, /* &zErr[0] */ ts+24361, /* "Wrote 0x%016llx ..." */ libc.VaList(bp+152, in, *(*u64)(unsafe.Pointer(bp + 504 /* out */)))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+168, bp+300 /* &zErr[0] */, 0)) - return 1 + return TCL_ERROR } } @@ -56276,7 +52770,7 @@ func btree_varint_test(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 } in = in + (u64(*(*u322)(unsafe.Pointer(bp + 196 /* incr */)))) } - return 0 + return TCL_OK } // usage: btree_from_db DB-HANDLE @@ -56299,17 +52793,17 @@ func btree_from_db(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, a var iDb int32 = 0 if (argc != 2) && (argc != 3) { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24417 /* " DB-HANDLE ?N?\"" */, 0)) - return 1 + return TCL_ERROR } - if 1 != tcl.XTcl_GetCommandInfo(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), bp+72 /* &info */) { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24433 /* "No such db-handl..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+11456 /* "\"" */, 0)) - return 1 + if 1 != tcl.XTcl_GetCommandInfo(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+72 /* &info */) { + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24433 /* "No such db-handl..." */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+11456 /* "\"" */, 0)) + return TCL_ERROR } if argc == 3 { - iDb = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + iDb = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) } db = *(*uintptr)(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp + 72 /* &info */)).FobjClientData)) @@ -56317,7 +52811,7 @@ func btree_from_db(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, a pBt = (*Db)(unsafe.Pointer((*sqlite31)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpBt sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+136 /* &zBuf[0] */, ts+12843 /* "%p" */, libc.VaList(bp+64, pBt)) tcl.XTcl_SetResult(tls, interp, bp+136 /* &zBuf[0] */, uintptr(1)) - return 0 + return TCL_OK } // Usage: btree_ismemdb ID @@ -56332,11 +52826,11 @@ func btree_ismemdb(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, a var pFile uintptr if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+23408 /* " ID\"" */, 0)) - return 1 + return TCL_ERROR } - pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) sqlite3.Xsqlite3BtreeEnter(tls, pBt) pFile = sqlite3.Xsqlite3PagerFile(tls, sqlite3.Xsqlite3BtreePager(tls, pBt)) @@ -56344,7 +52838,7 @@ func btree_ismemdb(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, a sqlite3.Xsqlite3BtreeLeave(tls, pBt) sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((res) != 0)))) - return 0 + return SQLITE_OK } // usage: btree_set_cache_size ID NCACHE @@ -56360,12 +52854,12 @@ func btree_set_cache_size(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc i if argc != 3 { tcl.XTcl_AppendResult(tls, - interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), ts+24454 /* " BT NCACHE\"" */, 0)) - return 1 + interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24454 /* " BT NCACHE\"" */, 0)) + return TCL_ERROR } - pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+32 /* &nCache */) != 0 { - return 1 + pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+32 /* &nCache */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) @@ -56373,7 +52867,7 @@ func btree_set_cache_size(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc i sqlite3.Xsqlite3BtreeSetCacheSize(tls, pBt, *(*int32)(unsafe.Pointer(bp + 32 /* nCache */))) sqlite3.Xsqlite3BtreeLeave(tls, pBt) sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) - return 0 + return TCL_OK } // usage: btree_insert CSR ?KEY? VALUE @@ -56390,21 +52884,21 @@ func btree_insert(tls *libc.TLS, clientData ClientData, interp uintptr, objc int if (objc != 4) && (objc != 3) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+24466 /* "?-intkey? CSR KE..." */) - return 1 + return TCL_ERROR } libc.Xmemset(tls, bp+16 /* &x */, 0, uint64(unsafe.Sizeof(BtreePayload{}))) if objc == 4 { - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+64 /* &rc */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64 /* &rc */) != 0 { + return TCL_ERROR } (*BtreePayload)(unsafe.Pointer(bp + 16 /* &x */)).FnKey = sqlite3_int64(*(*int32)(unsafe.Pointer(bp + 64 /* rc */))) - (*BtreePayload)(unsafe.Pointer(bp + 16 /* &x */)).FpData = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), (bp + 16 /* &x */ + 36 /* &.nData */)) + (*BtreePayload)(unsafe.Pointer(bp + 16 /* &x */)).FpData = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), (bp + 16 /* &x */ + 36 /* &.nData */)) } else { - (*BtreePayload)(unsafe.Pointer(bp + 16 /* &x */)).FpKey = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+64 /* &rc */) + (*BtreePayload)(unsafe.Pointer(bp + 16 /* &x */)).FpKey = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64 /* &rc */) (*BtreePayload)(unsafe.Pointer(bp + 16 /* &x */)).FnKey = sqlite3_int64(*(*int32)(unsafe.Pointer(bp + 64 /* rc */))) } - pCur = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + pCur = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBtree)).Fdb)).Fmutex) sqlite3.Xsqlite3BtreeEnter(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) @@ -56415,9 +52909,9 @@ func btree_insert(tls *libc.TLS, clientData ClientData, interp uintptr, objc int tcl.XTcl_ResetResult(tls, interp) if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3ErrName(tls, *(*int32)(unsafe.Pointer(bp + 64 /* rc */))), 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -56435,55 +52929,27 @@ func Sqlitetest3_Init(tls *libc.TLS, interp uintptr) int32 { /* test3.c:661:5: * f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 }{btree_insert})), uintptr(0), uintptr(0)) - return 0 + return TCL_OK } var aCmd3 = [14]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 24503, /* "btree_open" */ - FxProc: 0}, - { - FzName: ts + 24514, /* "btree_close" */ - FxProc: 0}, - { - FzName: ts + 24526, /* "btree_begin_tran..." */ - FxProc: 0}, - { - FzName: ts + 24550, /* "btree_pager_stat..." */ - FxProc: 0}, - { - FzName: ts + 24568, /* "btree_cursor" */ - FxProc: 0}, - { - FzName: ts + 24581, /* "btree_close_curs..." */ - FxProc: 0}, - { - FzName: ts + 24600, /* "btree_next" */ - FxProc: 0}, - { - FzName: ts + 24611, /* "btree_eof" */ - FxProc: 0}, - { - FzName: ts + 24621, /* "btree_payload_si..." */ - FxProc: 0}, - { - FzName: ts + 24640, /* "btree_first" */ - FxProc: 0}, - { - FzName: ts + 24652, /* "btree_varint_tes..." */ - FxProc: 0}, - { - FzName: ts + 24670, /* "btree_from_db" */ - FxProc: 0}, - { - FzName: ts + 24684, /* "btree_ismemdb" */ - FxProc: 0}, - { - FzName: ts + 24698, /* "btree_set_cache_..." */ - FxProc: 0}, + {FzName: ts + 24503 /* "btree_open" */, FxProc: 0}, + {FzName: ts + 24514 /* "btree_close" */, FxProc: 0}, + {FzName: ts + 24526 /* "btree_begin_tran..." */, FxProc: 0}, + {FzName: ts + 24550 /* "btree_pager_stat..." */, FxProc: 0}, + {FzName: ts + 24568 /* "btree_cursor" */, FxProc: 0}, + {FzName: ts + 24581 /* "btree_close_curs..." */, FxProc: 0}, + {FzName: ts + 24600 /* "btree_next" */, FxProc: 0}, + {FzName: ts + 24611 /* "btree_eof" */, FxProc: 0}, + {FzName: ts + 24621 /* "btree_payload_si..." */, FxProc: 0}, + {FzName: ts + 24640 /* "btree_first" */, FxProc: 0}, + {FzName: ts + 24652 /* "btree_varint_tes..." */, FxProc: 0}, + {FzName: ts + 24670 /* "btree_from_db" */, FxProc: 0}, + {FzName: ts + 24684 /* "btree_ismemdb" */, FxProc: 0}, + {FzName: ts + 24698 /* "btree_set_cache_..." */, FxProc: 0}, } /* test3.c:665:5 */ // end block for C++ @@ -57092,7 +53558,7 @@ func test_thread_main(tls *libc.TLS, pArg uintptr) uintptr { /* test4.c:67:13: * sqlite3.Xsqlite3_close(tls, (*Thread)(unsafe.Pointer(p)).Fdb) } sqlite3.Xsqlite3_open(tls, (*Thread)(unsafe.Pointer(p)).FzFilename, (p + 40 /* &.db */)) - if 0 != sqlite3.Xsqlite3_errcode(tls, (*Thread)(unsafe.Pointer(p)).Fdb) { + if SQLITE_OK != sqlite3.Xsqlite3_errcode(tls, (*Thread)(unsafe.Pointer(p)).Fdb) { (*Thread)(unsafe.Pointer(p)).FzErr = libc.Xstrdup(tls, sqlite3.Xsqlite3_errmsg(tls, (*Thread)(unsafe.Pointer(p)).Fdb)) sqlite3.Xsqlite3_close(tls, (*Thread)(unsafe.Pointer(p)).Fdb) (*Thread)(unsafe.Pointer(p)).Fdb = uintptr(0) @@ -57137,11 +53603,11 @@ func parse_thread_id(tls *libc.TLS, interp uintptr, zArg uintptr) int32 { /* tes bp := tls.Alloc(16) defer tls.Free(16) - if (((zArg == uintptr(0)) || (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) == 0)) || (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(1)))) != 0)) || !((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zArg + uintptr(0))))))*2))) & int32(_ISupper)) != 0) { + 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) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+24719 /* "thread ID must b..." */, 0)) return -1 } - return (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) - 'A') + return (int32(*(*int8)(unsafe.Pointer(zArg))) - 'A') } // Usage: thread_create NAME FILENAME @@ -57158,21 +53624,21 @@ func tcl_thread_create(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 var rc int32 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24758 /* " ID FILENAME" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if threadset[i].Fbusy != 0 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24771 /* "thread " */, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+24779 /* " is already runn..." */, 0)) - return 1 + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24771 /* "thread " */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+24779 /* " is already runn..." */, 0)) + return TCL_ERROR } threadset[i].Fbusy = 1 sqlite3.Xsqlite3_free(tls, threadset[i].FzFilename) - threadset[i].FzFilename = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + threadset[i].FzFilename = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) threadset[i].Fopnum = 1 threadset[i].Fcompleted = 0 rc = libc2.Xpthread_create(tls, bp+88 /* &x */, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { @@ -57182,10 +53648,10 @@ func tcl_thread_create(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, ts+24799 /* "failed to create..." */, 0)) sqlite3.Xsqlite3_free(tls, threadset[i].FzFilename) threadset[i].Fbusy = 0 - return 1 + return TCL_ERROR } libc2.Xpthread_detach(tls, *(*pthread_t)(unsafe.Pointer(bp + 88 /* x */))) - return 0 + return TCL_OK } // Wait for a thread to reach its idle state. @@ -57205,20 +53671,20 @@ func tcl_thread_wait(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var i int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24827 /* " ID" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) - return 0 + return TCL_OK } // Stop a thread. @@ -57245,28 +53711,28 @@ func tcl_thread_halt(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var i int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24827 /* " ID" */, 0)) - return 1 + return TCL_ERROR } - if (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) + uintptr(0)))) == '*') && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) + uintptr(1)))) == 0) { - for i = 0; i < 26; i++ { + if (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 1*8))))) == '*') && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 1*8)) + 1))) == 0) { + for i = 0; i < N_THREAD; i++ { if threadset[i].Fbusy != 0 { test_stop_thread(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) } } } else { - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_stop_thread(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) } - return 0 + return TCL_OK } // Usage: thread_argc ID @@ -57281,22 +53747,22 @@ func tcl_thread_argc(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, // var zBuf [100]int8 at bp+72, 100 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24827 /* " ID" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+72 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+48, threadset[i].Fargc)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+72 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: thread_argv ID N @@ -57311,28 +53777,28 @@ func tcl_thread_argv(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, // var n int32 at bp+80, 4 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24846 /* " ID N" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+80 /* &n */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+80 /* &n */) != 0 { + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) if (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) < 0) || (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) >= threadset[i].Fargc) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+24852 /* "column number ou..." */, 0)) - return 1 + return TCL_ERROR } 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)) - return 0 + return TCL_OK } // Usage: thread_colname ID N @@ -57347,28 +53813,28 @@ func tcl_thread_colname(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int // var n int32 at bp+80, 4 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24846 /* " ID N" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+80 /* &n */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+80 /* &n */) != 0 { + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) if (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) < 0) || (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) >= threadset[i].Fargc) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+24852 /* "column number ou..." */, 0)) - return 1 + return TCL_ERROR } 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)) - return 0 + return TCL_OK } // Usage: thread_result ID @@ -57383,22 +53849,22 @@ func tcl_thread_result(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 var zName uintptr if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24827 /* " ID" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) zName = sqlite3.Xsqlite3ErrName(tls, threadset[i].Frc) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, zName, 0)) - return 0 + return TCL_OK } // Usage: thread_error ID @@ -57412,28 +53878,28 @@ func tcl_thread_error(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32 var i int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24827 /* " ID" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, threadset[i].FzErr, 0)) - return 0 + return TCL_OK } // This procedure runs in the thread to compile an SQL statement. func do_compile(tls *libc.TLS, p uintptr) { /* test4.c:419:13: */ if (*Thread)(unsafe.Pointer(p)).Fdb == uintptr(0) { (*Thread)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+24879 /* "no database is o..." */) - (*Thread)(unsafe.Pointer(p)).Frc = 1 + (*Thread)(unsafe.Pointer(p)).Frc = SQLITE_ERROR return } if (*Thread)(unsafe.Pointer(p)).FpStmt != 0 { @@ -57452,24 +53918,24 @@ func tcl_thread_compile(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int var i int32 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24899 /* " ID SQL" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) threadset[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_compile})) sqlite3.Xsqlite3_free(tls, threadset[i].FzArg) - threadset[i].FzArg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + threadset[i].FzArg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) threadset[i].Fopnum++ - return 0 + return TCL_OK } // This procedure runs in the thread to step the virtual machine. @@ -57477,11 +53943,11 @@ func do_step(tls *libc.TLS, p uintptr) { /* test4.c:466:13: */ var i int32 if (*Thread)(unsafe.Pointer(p)).FpStmt == uintptr(0) { (*Thread)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+24907 /* "no virtual machi..." */) - (*Thread)(unsafe.Pointer(p)).Frc = 1 + (*Thread)(unsafe.Pointer(p)).Frc = SQLITE_ERROR return } (*Thread)(unsafe.Pointer(p)).Frc = sqlite3.Xsqlite3_step(tls, (*Thread)(unsafe.Pointer(p)).FpStmt) - if (*Thread)(unsafe.Pointer(p)).Frc == 100 { + if (*Thread)(unsafe.Pointer(p)).Frc == SQLITE_ROW { (*Thread)(unsafe.Pointer(p)).Fargc = sqlite3.Xsqlite3_column_count(tls, (*Thread)(unsafe.Pointer(p)).FpStmt) for i = 0; i < sqlite3.Xsqlite3_data_count(tls, (*Thread)(unsafe.Pointer(p)).FpStmt); i++ { *(*uintptr)(unsafe.Pointer((p + 80 /* &.argv */) + uintptr(i)*8)) = sqlite3.Xsqlite3_column_text(tls, (*Thread)(unsafe.Pointer(p)).FpStmt, i) @@ -57501,29 +53967,29 @@ func tcl_thread_step(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var i int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24936 /* " IDL" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) threadset[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_step})) threadset[i].Fopnum++ - return 0 + return TCL_OK } // This procedure runs in the thread to finalize a virtual machine. func do_finalize(tls *libc.TLS, p uintptr) { /* test4.c:517:13: */ if (*Thread)(unsafe.Pointer(p)).FpStmt == uintptr(0) { (*Thread)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+24907 /* "no virtual machi..." */) - (*Thread)(unsafe.Pointer(p)).Frc = 1 + (*Thread)(unsafe.Pointer(p)).Frc = SQLITE_ERROR return } (*Thread)(unsafe.Pointer(p)).Frc = sqlite3.Xsqlite3_finalize(tls, (*Thread)(unsafe.Pointer(p)).FpStmt) @@ -57539,24 +54005,24 @@ func tcl_thread_finalize(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc in var i int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24936 /* " IDL" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) threadset[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_finalize})) sqlite3.Xsqlite3_free(tls, threadset[i].FzArg) threadset[i].FzArg = uintptr(0) threadset[i].Fopnum++ - return 0 + return TCL_OK } // Usage: thread_swap ID ID @@ -57570,32 +54036,32 @@ func tcl_thread_swap(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var j int32 var temp uintptr if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24941 /* " ID1 ID2" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) - j = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + j = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8))) if j < 0 { - return 1 + return TCL_ERROR } if !(threadset[j].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(j)*1680)) temp = threadset[i].Fdb threadset[i].Fdb = threadset[j].Fdb threadset[j].Fdb = temp - return 0 + return TCL_OK } // Usage: thread_db_get ID @@ -57611,23 +54077,23 @@ func tcl_thread_db_get(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 // var zBuf [100]int8 at bp+64, 100 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24827 /* " ID" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) sqlite3TestMakePointerStr(tls, interp, bp+64 /* &zBuf[0] */, threadset[i].Fdb) threadset[i].Fdb = uintptr(0) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, bp+64 /* &zBuf[0] */, uintptr(0))) - return 0 + return TCL_OK } // Usage: thread_db_put ID DB @@ -57638,22 +54104,22 @@ func tcl_thread_db_put(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 var i int32 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24950 /* " ID DB" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) - threadset[i].Fdb = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) - return 0 + threadset[i].Fdb = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) + return TCL_OK } // Usage: thread_stmt_get ID @@ -57668,23 +54134,23 @@ func tcl_thread_stmt_get(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc in // var zBuf [100]int8 at bp+64, 100 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24827 /* " ID" */, 0)) - return 1 + return TCL_ERROR } - i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) sqlite3TestMakePointerStr(tls, interp, bp+64 /* &zBuf[0] */, threadset[i].FpStmt) threadset[i].FpStmt = uintptr(0) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, bp+64 /* &zBuf[0] */, uintptr(0))) - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -57697,58 +54163,28 @@ func Sqlitetest4_Init(tls *libc.TLS, interp uintptr) int32 { /* test4.c:696:5: * }{}))); i++ { tcl.XTcl_CreateCommand(tls, interp, aCmd4[i].FzName, aCmd4[i].FxProc, uintptr(0), uintptr(0)) } - return 0 + return TCL_OK } var aCmd4 = [15]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 24957, /* "thread_create" */ - FxProc: 0}, - { - FzName: ts + 24971, /* "thread_wait" */ - FxProc: 0}, - { - FzName: ts + 24983, /* "thread_halt" */ - FxProc: 0}, - { - FzName: ts + 24995, /* "thread_argc" */ - FxProc: 0}, - { - FzName: ts + 25007, /* "thread_argv" */ - FxProc: 0}, - { - FzName: ts + 25019, /* "thread_colname" */ - FxProc: 0}, - { - FzName: ts + 25034, /* "thread_result" */ - FxProc: 0}, - { - FzName: ts + 25048, /* "thread_error" */ - FxProc: 0}, - { - FzName: ts + 25061, /* "thread_compile" */ - FxProc: 0}, - { - FzName: ts + 25076, /* "thread_step" */ - FxProc: 0}, - { - FzName: ts + 25088, /* "thread_finalize" */ - FxProc: 0}, - { - FzName: ts + 25104, /* "thread_swap" */ - FxProc: 0}, - { - FzName: ts + 25116, /* "thread_db_get" */ - FxProc: 0}, - { - FzName: ts + 25130, /* "thread_db_put" */ - FxProc: 0}, - { - FzName: ts + 25144, /* "thread_stmt_get" */ - FxProc: 0}, + {FzName: ts + 24957 /* "thread_create" */, FxProc: 0}, + {FzName: ts + 24971 /* "thread_wait" */, FxProc: 0}, + {FzName: ts + 24983 /* "thread_halt" */, FxProc: 0}, + {FzName: ts + 24995 /* "thread_argc" */, FxProc: 0}, + {FzName: ts + 25007 /* "thread_argv" */, FxProc: 0}, + {FzName: ts + 25019 /* "thread_colname" */, FxProc: 0}, + {FzName: ts + 25034 /* "thread_result" */, FxProc: 0}, + {FzName: ts + 25048 /* "thread_error" */, FxProc: 0}, + {FzName: ts + 25061 /* "thread_compile" */, FxProc: 0}, + {FzName: ts + 25076 /* "thread_step" */, FxProc: 0}, + {FzName: ts + 25088 /* "thread_finalize" */, FxProc: 0}, + {FzName: ts + 25104 /* "thread_swap" */, FxProc: 0}, + {FzName: ts + 25116 /* "thread_db_get" */, FxProc: 0}, + {FzName: ts + 25130 /* "thread_db_put" */, FxProc: 0}, + {FzName: ts + 25144 /* "thread_stmt_get" */, FxProc: 0}, } /* test4.c:700:5 */ // end block for C++ @@ -57808,10 +54244,10 @@ func binarize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, obj var bytes uintptr var pRet uintptr - bytes = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &len */) + bytes = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &len */) pRet = tcl.XTcl_NewByteArrayObj(tls, bytes, (*(*int32)(unsafe.Pointer(bp /* len */)) + 1)) tcl.XTcl_SetObjResult(tls, interp, pRet) - return 0 + return TCL_OK } // Usage: test_value_overhead . @@ -57836,20 +54272,20 @@ func test_value_overhead(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 3 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), ts+25160 /* " ..." */, 0)) - return 1 + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+25160 /* " ..." */, 0)) + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+32 /* &repeat_count */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+32 /* &repeat_count */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+36 /* &do_calls */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+36 /* &do_calls */) != 0 { + return TCL_ERROR } - (*Mem)(unsafe.Pointer(bp + 40 /* &val */)).Fflags = (u16((0x0002 | 0x0200) | 0x0800)) + (*Mem)(unsafe.Pointer(bp + 40 /* &val */)).Fflags = (u16((MEM_Str | MEM_Term) | MEM_Static)) (*Mem)(unsafe.Pointer(bp + 40 /* &val */)).Fz = ts + 25187 /* "hello world" */ - (*Mem)(unsafe.Pointer(bp + 40 /* &val */)).Fenc = u8(1) + (*Mem)(unsafe.Pointer(bp + 40 /* &val */)).Fenc = SQLITE_UTF8 for i = 0; i < *(*int32)(unsafe.Pointer(bp + 32 /* repeat_count */)); i++ { if *(*int32)(unsafe.Pointer(bp + 36 /* do_calls */)) != 0 { @@ -57857,7 +54293,7 @@ func test_value_overhead(tls *libc.TLS, clientData uintptr, interp uintptr, objc } } - return 0 + return TCL_OK } func name_to_enc(tls *libc.TLS, interp uintptr, pObj uintptr) u8 { /* test5.c:94:11: */ @@ -57865,23 +54301,15 @@ func name_to_enc(tls *libc.TLS, interp uintptr, pObj uintptr) u8 { /* test5.c:94 defer tls.Free(104) *(*[5]EncName)(unsafe.Pointer(bp + 24 /* encnames */)) = [5]EncName{ - { - FzName: ts + 25199, /* "UTF8" */ - Fenc: u8(1)}, - { - FzName: ts + 25204, /* "UTF16LE" */ - Fenc: u8(2)}, - { - FzName: ts + 25212, /* "UTF16BE" */ - Fenc: u8(3)}, - { - FzName: ts + 25220, /* "UTF16" */ - Fenc: u8(4)}, + {FzName: ts + 25199 /* "UTF8" */, Fenc: SQLITE_UTF8}, + {FzName: ts + 25204 /* "UTF16LE" */, Fenc: SQLITE_UTF16LE}, + {FzName: ts + 25212 /* "UTF16BE" */, Fenc: SQLITE_UTF16BE}, + {FzName: ts + 25220 /* "UTF16" */, Fenc: SQLITE_UTF16}, {}, } var pEnc uintptr var z uintptr = tcl.XTcl_GetString(tls, pObj) - for pEnc = (bp + 24 /* &encnames */ + uintptr(0)*16); (*EncName)(unsafe.Pointer(pEnc)).FzName != 0; pEnc += 16 { + for pEnc = (bp + 24 /* &encnames */); (*EncName)(unsafe.Pointer(pEnc)).FzName != 0; pEnc += 16 { if 0 == sqlite3.Xsqlite3StrICmp(tls, z, (*EncName)(unsafe.Pointer(pEnc)).FzName) { break } @@ -57889,8 +54317,8 @@ func name_to_enc(tls *libc.TLS, interp uintptr, pObj uintptr) u8 { /* test5.c:94 if !(int32((*EncName)(unsafe.Pointer(pEnc)).Fenc) != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+25226 /* "No such encoding..." */, z, 0)) } - if int32((*EncName)(unsafe.Pointer(pEnc)).Fenc) == 4 { - return u8(2) + if int32((*EncName)(unsafe.Pointer(pEnc)).Fenc) == SQLITE_UTF16 { + return SQLITE_UTF16LE } return (*EncName)(unsafe.Pointer(pEnc)).Fenc } @@ -57917,33 +54345,33 @@ func test_translate(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if (objc != 4) && (objc != 5) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)), uintptr(0)), + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+25245 /* " <..." */, 0)) - return 1 + return TCL_ERROR } if objc == 5 { xDel = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free})) } - enc_from = name_to_enc(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + enc_from = name_to_enc(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if !(enc_from != 0) { - return 1 + return TCL_ERROR } - enc_to = name_to_enc(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + enc_to = name_to_enc(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8))) if !(enc_to != 0) { - return 1 + return TCL_ERROR } pVal = sqlite3.Xsqlite3ValueNew(tls, uintptr(0)) - if int32(enc_from) == 1 { - z = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + if int32(enc_from) == SQLITE_UTF8 { + z = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) if objc == 5 { z = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+32, z)) } sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, z, enc_from, xDel) } else { - z = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+40 /* &len */) + z = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+40 /* &len */) if objc == 5 { var zTmp uintptr = z z = sqlite3.Xsqlite3_malloc(tls, *(*int32)(unsafe.Pointer(bp + 40 /* len */))) @@ -57954,7 +54382,7 @@ func test_translate(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 z = sqlite3.Xsqlite3ValueText(tls, pVal, enc_to) *(*int32)(unsafe.Pointer(bp + 40 /* len */)) = (sqlite3.Xsqlite3ValueBytes(tls, pVal, enc_to) + (func() int32 { - if int32(enc_to) == 1 { + if int32(enc_to) == SQLITE_UTF8 { return 1 } return 2 @@ -57963,12 +54391,12 @@ func test_translate(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 sqlite3.Xsqlite3ValueFree(tls, pVal) - return 0 + return TCL_OK } func test_translate_selftest(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test5.c:189:26: */ sqlite3.Xsqlite3UtfSelfTest(tls) - return 0 + return SQLITE_OK } // Register commands with the TCL interpreter. @@ -57980,25 +54408,17 @@ func Sqlitetest5_Init(tls *libc.TLS, interp uintptr) int32 { /* test5.c:205:5: * }{}))); i++ { tcl.XTcl_CreateObjCommand(tls, interp, aCmd5[i].FzName, aCmd5[i].FxProc, uintptr(0), uintptr(0)) } - return 0 + return SQLITE_OK } var aCmd5 = [4]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 25280, /* "binarize" */ - FxProc: 0}, - { - FzName: ts + 25289, /* "test_value_overh..." */ - FxProc: 0}, - { - FzName: ts + 25309, /* "test_translate" */ - FxProc: 0}, - { - FzName: ts + 25324, /* "translate_selfte..." */ - FxProc: 0}, + {FzName: ts + 25280 /* "binarize" */, FxProc: 0}, + {FzName: ts + 25289 /* "test_value_overh..." */, FxProc: 0}, + {FzName: ts + 25309 /* "test_translate" */, FxProc: 0}, + {FzName: ts + 25324 /* "translate_selfte..." */, FxProc: 0}, } /* test5.c:209:5 */ // end block for C++ @@ -58055,12 +54475,7 @@ type WriteBuffer1 = struct { type WriteBuffer = WriteBuffer1 /* test6.c:31:28 */ -var g = CrashGlobal{ - FpWriteList: uintptr(0), - FpWriteListEnd: uintptr(0), - FiSectorSize: 4096, - FiDeviceCharacteristics: 0, - FiCrash: 0} /* test6.c:156:20 */ +var g = CrashGlobal{FiSectorSize: SQLITE_DEFAULT_SECTOR_SIZE} /* test6.c:156:20 */ // Set this global variable to 1 to enable crash testing. var sqlite3CrashTestEnable int32 = 0 /* test6.c:161:12 */ @@ -58080,7 +54495,7 @@ func crash_realloc(tls *libc.TLS, p uintptr, n int32) uintptr { /* test6.c:169:1 // Wrapper around the sqlite3OsWrite() function that avoids writing to the // 512 byte block begining at offset PENDING_BYTE. func writeDbFile(tls *libc.TLS, p uintptr, z uintptr, iAmt i64, iOff i64) int32 { /* test6.c:177:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var iSkip int32 = 0 if (iAmt - i64(iSkip)) > int64(0) { rc = sqlite3.Xsqlite3OsWrite(tls, (*CrashFile)(unsafe.Pointer(p)).FpRealFile, (z + uintptr(iSkip)), (int32(iAmt - i64(iSkip))), (iOff + i64(iSkip))) @@ -58094,7 +54509,7 @@ func writeListSync(tls *libc.TLS, pFile uintptr, isCrash int32) int32 { /* test6 bp := tls.Alloc(16) defer tls.Free(16) - var rc int32 = 0 + var rc int32 = SQLITE_OK var iDc int32 = g.FiDeviceCharacteristics var pWrite uintptr var ppPtr uintptr @@ -58112,7 +54527,7 @@ func writeListSync(tls *libc.TLS, pFile uintptr, isCrash int32) int32 { /* test6 pFinal = pWrite } } - } else if (iDc & (0x00000400 | 0x00000200)) != 0 { + } else if (iDc & (SQLITE_IOCAP_SEQUENTIAL | SQLITE_IOCAP_SAFE_APPEND)) != 0 { var nWrite int32 = 0 // var iFinal int32 at bp, 4 @@ -58133,7 +54548,7 @@ func writeListSync(tls *libc.TLS, pFile uintptr, isCrash int32) int32 { /* test6 } ppPtr = (uintptr(unsafe.Pointer(&g)) /* &.pWriteList */) - for pWrite = *(*uintptr)(unsafe.Pointer(ppPtr)); (rc == 0) && (pWrite != 0); pWrite = *(*uintptr)(unsafe.Pointer(ppPtr)) { + for pWrite = *(*uintptr)(unsafe.Pointer(ppPtr)); (rc == SQLITE_OK) && (pWrite != 0); pWrite = *(*uintptr)(unsafe.Pointer(ppPtr)) { var pRealFile uintptr = (*CrashFile)(unsafe.Pointer((*WriteBuffer)(unsafe.Pointer(pWrite)).FpFile)).FpRealFile // (eAction==1) -> write block out normally, @@ -58142,7 +54557,7 @@ func writeListSync(tls *libc.TLS, pFile uintptr, isCrash int32) int32 { /* test6 var eAction int32 = 0 if !(isCrash != 0) { eAction = 2 - if ((*WriteBuffer)(unsafe.Pointer(pWrite)).FpFile == pFile) || ((iDc & 0x00000400) != 0) { + if ((*WriteBuffer)(unsafe.Pointer(pWrite)).FpFile == pFile) || ((iDc & SQLITE_IOCAP_SEQUENTIAL) != 0) { eAction = 1 } } else { @@ -58152,21 +54567,21 @@ func writeListSync(tls *libc.TLS, pFile uintptr, isCrash int32) int32 { /* test6 // Do not select option 3 (sector trashing) if the IOCAP_ATOMIC flag // is set or this is an OsTruncate(), not an Oswrite(). - if ((iDc & 0x00000001) != 0) || ((*WriteBuffer)(unsafe.Pointer(pWrite)).FzBuf == uintptr(0)) { + if ((iDc & SQLITE_IOCAP_ATOMIC) != 0) || ((*WriteBuffer)(unsafe.Pointer(pWrite)).FzBuf == uintptr(0)) { *(*int8)(unsafe.Pointer(bp + 4 /* random */)) &= int8(0x01) } // If IOCAP_SEQUENTIAL is set and this is not the final entry // in the truncated write-list, always select option 1 (write // out correctly). - if ((iDc & 0x00000400) != 0) && (pWrite != pFinal) { + if ((iDc & SQLITE_IOCAP_SEQUENTIAL) != 0) && (pWrite != pFinal) { *(*int8)(unsafe.Pointer(bp + 4 /* random */)) = int8(0) } // If IOCAP_SAFE_APPEND is set and this OsWrite() operation is // an append (first byte of the written region is 1 byte past the // current EOF), always select option 1 (write out correctly). - if ((iDc & 0x00000200) != 0) && ((*WriteBuffer)(unsafe.Pointer(pWrite)).FzBuf != 0) { + if ((iDc & SQLITE_IOCAP_SAFE_APPEND) != 0) && ((*WriteBuffer)(unsafe.Pointer(pWrite)).FzBuf != 0) { // var iSize i64 at bp+8, 8 sqlite3.Xsqlite3OsFileSize(tls, pRealFile, bp+8 /* &iSize */) @@ -58216,14 +54631,14 @@ func writeListSync(tls *libc.TLS, pFile uintptr, isCrash int32) int32 { /* test6 zGarbage = crash_malloc(tls, g.FiSectorSize) if zGarbage != 0 { var i sqlite3_int64 - for i = sqlite3_int64(iFirst); (rc == 0) && (i <= sqlite3_int64(iLast)); i++ { + for i = sqlite3_int64(iFirst); (rc == SQLITE_OK) && (i <= sqlite3_int64(iLast)); i++ { sqlite3.Xsqlite3_randomness(tls, g.FiSectorSize, zGarbage) rc = writeDbFile(tls, (*WriteBuffer)(unsafe.Pointer(pWrite)).FpFile, zGarbage, int64(g.FiSectorSize), (i * sqlite3_int64(g.FiSectorSize))) } crash_free(tls, zGarbage) } else { - rc = 7 + rc = SQLITE_NOMEM } ppPtr = (pWrite + 32 /* &.pNext */) @@ -58240,7 +54655,7 @@ func writeListSync(tls *libc.TLS, pFile uintptr, isCrash int32) int32 { /* test6 } } - if (rc == 0) && (isCrash != 0) { + if (rc == SQLITE_OK) && (isCrash != 0) { libc.Xexit(tls, -1) } @@ -58264,7 +54679,7 @@ func writeListAppend(tls *libc.TLS, pFile uintptr, iOffset sqlite3_int64, zBuf u (*WriteBuffer)(unsafe.Pointer(pNew)).FnBuf = nBuf (*WriteBuffer)(unsafe.Pointer(pNew)).FpFile = pFile if zBuf != 0 { - (*WriteBuffer)(unsafe.Pointer(pNew)).FzBuf = (pNew + uintptr(1)*40) + (*WriteBuffer)(unsafe.Pointer(pNew)).FzBuf = (pNew + 1*40) libc.Xmemcpy(tls, (*WriteBuffer)(unsafe.Pointer(pNew)).FzBuf, zBuf, uint64(nBuf)) } @@ -58276,7 +54691,7 @@ func writeListAppend(tls *libc.TLS, pFile uintptr, iOffset sqlite3_int64, zBuf u } g.FpWriteListEnd = pNew - return 0 + return SQLITE_OK } // Close a crash-file. @@ -58284,7 +54699,7 @@ func cfClose(tls *libc.TLS, pFile uintptr) int32 { /* test6.c:399:12: */ var pCrash uintptr = pFile writeListSync(tls, pCrash, 0) sqlite3.Xsqlite3OsClose(tls, (*CrashFile)(unsafe.Pointer(pCrash)).FpRealFile) - return 0 + return SQLITE_OK } // Read data from a crash-file. @@ -58303,10 +54718,10 @@ func cfRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite // Check the file-size to see if this is a short-read if nCopy < iAmt { - return (10 | (int32(2) << 8)) + return (SQLITE_IOERR | (int32(2) << 8)) } - return 0 + return SQLITE_OK } // Write data to a crash-file. @@ -58320,7 +54735,7 @@ func cfWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlit var nNew int32 = (((*CrashFile)(unsafe.Pointer(pCrash)).FnData * 2) + 4096) zNew = crash_realloc(tls, (*CrashFile)(unsafe.Pointer(pCrash)).FzData, nNew) if !(zNew != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, (zNew + uintptr((*CrashFile)(unsafe.Pointer(pCrash)).FnData)), 0, (uint64(nNew - (*CrashFile)(unsafe.Pointer(pCrash)).FnData))) (*CrashFile)(unsafe.Pointer(pCrash)).FnData = nNew @@ -58370,7 +54785,7 @@ func cfSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test6.c:473:12 func cfFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* test6.c:505:12: */ var pCrash uintptr = pFile *(*sqlite_int64)(unsafe.Pointer(pSize)) = (*CrashFile)(unsafe.Pointer(pCrash)).FiSize - return 0 + return SQLITE_OK } // Calls related to file-locks are passed on to the real file handle. @@ -58387,15 +54802,15 @@ func cfCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { } func cfFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { /* test6.c:523:12: */ - if op == 5 { + if op == SQLITE_FCNTL_SIZE_HINT { var pCrash uintptr = pFile var nByte i64 = *(*i64)(unsafe.Pointer(pArg)) if nByte > (*CrashFile)(unsafe.Pointer(pCrash)).FiSize { - if 0 == writeListAppend(tls, pFile, nByte, uintptr(0), 0) { + if SQLITE_OK == writeListAppend(tls, pFile, nByte, uintptr(0), 0) { (*CrashFile)(unsafe.Pointer(pCrash)).FiSize = i64(int32(nByte)) } } - return 0 + return SQLITE_OK } return sqlite3.Xsqlite3OsFileControl(tls, (*CrashFile)(unsafe.Pointer(pFile)).FpRealFile, op, pArg) } @@ -58429,39 +54844,23 @@ func cfShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, sz int32, w int32, pp } var CrashFileVtab = sqlite3_io_methods{ - FiVersion: 2, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - 0, - FxUnlock:// xLock - 0, - FxCheckReservedLock:// xUnlock - 0, - FxFileControl:// xCheckReservedLock - 0, - FxSectorSize:// xFileControl - 0, - FxDeviceCharacteristics:// xSectorSize - 0, - FxShmMap:// xDeviceCharacteristics - 0, - FxShmLock:// xShmMap - 0, - FxShmBarrier:// xShmLock - 0, - FxShmUnmap:// xShmBarrier - 0, // xShmUnmap + FiVersion: 2, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xFileSize + FxLock: 0, // xLock + FxUnlock: 0, // xUnlock + FxCheckReservedLock: 0, // xCheckReservedLock + FxFileControl: 0, // xFileControl + FxSectorSize: 0, // xSectorSize + FxDeviceCharacteristics: 0, // xDeviceCharacteristics + FxShmMap: 0, // xShmMap + FxShmLock: 0, // xShmLock + FxShmBarrier: 0, // xShmBarrier + FxShmUnmap: 0, // xShmUnmap } /* test6.c:571:33 */ // Application data for the crash VFS @@ -58481,12 +54880,12 @@ func cfOpen(tls *libc.TLS, pCfVfs uintptr, zName uintptr, pFile uintptr, flags i var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData var rc int32 var pWrapper uintptr = pFile - var pReal uintptr = (pWrapper + uintptr(1)*56) + var pReal uintptr = (pWrapper + 1*56) libc.Xmemset(tls, pWrapper, 0, uint64(unsafe.Sizeof(CrashFile{}))) rc = sqlite3.Xsqlite3OsOpen(tls, pVfs, zName, pReal, flags, pOutFlags) - if rc == 0 { + if rc == SQLITE_OK { // var iSize i64 at bp, 8 (*CrashFile)(unsafe.Pointer(pWrapper)).FpMethod = uintptr(unsafe.Pointer(&CrashFileVtab)) @@ -58496,7 +54895,7 @@ func cfOpen(tls *libc.TLS, pCfVfs uintptr, zName uintptr, pFile uintptr, flags i (*CrashFile)(unsafe.Pointer(pWrapper)).FiSize = i64(int32(*(*i64)(unsafe.Pointer(bp /* iSize */)))) (*CrashFile)(unsafe.Pointer(pWrapper)).Fflags = flags } - if rc == 0 { + if rc == SQLITE_OK { (*CrashFile)(unsafe.Pointer(pWrapper)).FnData = (int32(int64(4096) + (*CrashFile)(unsafe.Pointer(pWrapper)).FiSize)) (*CrashFile)(unsafe.Pointer(pWrapper)).FzData = crash_malloc(tls, (*CrashFile)(unsafe.Pointer(pWrapper)).FnData) if (*CrashFile)(unsafe.Pointer(pWrapper)).FzData != 0 { @@ -58518,10 +54917,10 @@ func cfOpen(tls *libc.TLS, pCfVfs uintptr, zName uintptr, pFile uintptr, flags i rc = sqlite3.Xsqlite3OsRead(tls, pReal, ((*CrashFile)(unsafe.Pointer(pWrapper)).FzData + uintptr(iOff)), nRead, iOff) } } else { - rc = 7 + rc = SQLITE_NOMEM } } - if (rc != 0) && ((*CrashFile)(unsafe.Pointer(pWrapper)).FpMethod != 0) { + if (rc != SQLITE_OK) && ((*CrashFile)(unsafe.Pointer(pWrapper)).FpMethod != 0) { sqlite3.Xsqlite3OsClose(tls, pFile) } return rc @@ -58587,45 +54986,19 @@ func processDevSymArgs(tls *libc.TLS, interp uintptr, objc int32, objv uintptr, defer tls.Free(316) *(*[14]DeviceFlag)(unsafe.Pointer(bp + 88 /* aFlag */)) = [14]DeviceFlag{ - { - FzName: ts + 25381, /* "atomic" */ - FiValue: 0x00000001}, - { - FzName: ts + 25388, /* "atomic512" */ - FiValue: 0x00000002}, - { - FzName: ts + 25398, /* "atomic1k" */ - FiValue: 0x00000004}, - { - FzName: ts + 25407, /* "atomic2k" */ - FiValue: 0x00000008}, - { - FzName: ts + 25416, /* "atomic4k" */ - FiValue: 0x00000010}, - { - FzName: ts + 25425, /* "atomic8k" */ - FiValue: 0x00000020}, - { - FzName: ts + 25434, /* "atomic16k" */ - FiValue: 0x00000040}, - { - FzName: ts + 25444, /* "atomic32k" */ - FiValue: 0x00000080}, - { - FzName: ts + 25454, /* "atomic64k" */ - FiValue: 0x00000100}, - { - FzName: ts + 25464, /* "sequential" */ - FiValue: 0x00000400}, - { - FzName: ts + 25475, /* "safe_append" */ - FiValue: 0x00000200}, - { - FzName: ts + 25487, /* "powersafe_overwr..." */ - FiValue: 0x00001000}, - { - FzName: ts + 25507, /* "batch-atomic" */ - FiValue: 0x00004000}, + {FzName: ts + 25381 /* "atomic" */, FiValue: SQLITE_IOCAP_ATOMIC}, + {FzName: ts + 25388 /* "atomic512" */, FiValue: SQLITE_IOCAP_ATOMIC512}, + {FzName: ts + 25398 /* "atomic1k" */, FiValue: SQLITE_IOCAP_ATOMIC1K}, + {FzName: ts + 25407 /* "atomic2k" */, FiValue: SQLITE_IOCAP_ATOMIC2K}, + {FzName: ts + 25416 /* "atomic4k" */, FiValue: SQLITE_IOCAP_ATOMIC4K}, + {FzName: ts + 25425 /* "atomic8k" */, FiValue: SQLITE_IOCAP_ATOMIC8K}, + {FzName: ts + 25434 /* "atomic16k" */, FiValue: SQLITE_IOCAP_ATOMIC16K}, + {FzName: ts + 25444 /* "atomic32k" */, FiValue: SQLITE_IOCAP_ATOMIC32K}, + {FzName: ts + 25454 /* "atomic64k" */, FiValue: SQLITE_IOCAP_ATOMIC64K}, + {FzName: ts + 25464 /* "sequential" */, FiValue: SQLITE_IOCAP_SEQUENTIAL}, + {FzName: ts + 25475 /* "safe_append" */, FiValue: SQLITE_IOCAP_SAFE_APPEND}, + {FzName: ts + 25487 /* "powersafe_overwr..." */, FiValue: SQLITE_IOCAP_POWERSAFE_OVERWRITE}, + {FzName: ts + 25507 /* "batch-atomic" */, FiValue: SQLITE_IOCAP_BATCH_ATOMIC}, {}, } var i int32 @@ -58644,16 +55017,16 @@ func processDevSymArgs(tls *libc.TLS, interp uintptr, objc int32, objv uintptr, tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+25549 /* "Bad option: \"" */, zOpt, ts+25563 /* "\" - must be \"-ch..." */, 0)) - return 1 + return TCL_ERROR } if i == (objc - 1) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25611 /* "Option requires ..." */, zOpt, ts+11456 /* "\"" */, 0)) - return 1 + return TCL_ERROR } - if int32(*(*int8)(unsafe.Pointer(zOpt + uintptr(1)))) == 's' { + if int32(*(*int8)(unsafe.Pointer(zOpt + 1))) == 's' { if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+68 /* &iSectorSize */) != 0 { - return 1 + return TCL_ERROR } setSectorsize = 1 } else { @@ -58663,7 +55036,7 @@ func processDevSymArgs(tls *libc.TLS, interp uintptr, objc int32, objv uintptr, // var nObj int32 at bp+72, 4 if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+72 /* &nObj */, bp+80 /* &apObj */) != 0 { - return 1 + return TCL_ERROR } for j = 0; j < *(*int32)(unsafe.Pointer(bp + 72 /* nObj */)); j++ { var rc int32 @@ -58682,7 +55055,7 @@ func processDevSymArgs(tls *libc.TLS, interp uintptr, objc int32, objv uintptr, } } if rc != 0 { - return 1 + return TCL_ERROR } iDc = iDc | ((*DeviceFlag)(unsafe.Pointer(bp + 88 /* &aFlag */ + uintptr(*(*int32)(unsafe.Pointer(bp + 312 /* iChoice */)))*16)).FiValue) @@ -58698,7 +55071,7 @@ func processDevSymArgs(tls *libc.TLS, interp uintptr, objc int32, objv uintptr, *(*int32)(unsafe.Pointer(piSectorSize)) = *(*int32)(unsafe.Pointer(bp + 68 /* iSectorSize */)) } - return 0 + return TCL_OK } type DeviceFlag = struct { @@ -58714,11 +55087,11 @@ type DeviceFlag = struct { func crashNowCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test6.c:816:26: */ if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } writeListSync(tls, uintptr(0), 1) - return 0 + return TCL_OK } // tclcmd: sqlite_crash_enable ENABLE ?DEFAULT? @@ -58735,18 +55108,18 @@ func crashEnableCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 if (objc != 2) && (objc != 3) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+25655 /* "ENABLE ?DEFAULT?" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &isEnable */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &isEnable */) != 0 { + return TCL_ERROR } - if (objc == 3) && (tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+4 /* &isDefault */) != 0) { - return 1 + if (objc == 3) && (tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+4 /* &isDefault */) != 0) { + return TCL_ERROR } if ((*(*int32)(unsafe.Pointer(bp /* isEnable */)) != 0) && (crashVfs.FpAppData != 0)) || (!(*(*int32)(unsafe.Pointer(bp /* isEnable */)) != 0) && !(int32(crashVfs.FpAppData) != 0)) { - return 0 + return TCL_OK } if crashVfs.FpAppData == uintptr(0) { @@ -58760,48 +55133,25 @@ func crashEnableCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 sqlite3.Xsqlite3_vfs_unregister(tls, uintptr(unsafe.Pointer(&crashVfs))) } - return 0 + return TCL_OK } var crashVfs = sqlite3_vfs{ - FiVersion: 2, - FszOsFile:// iVersion - 0, - FmxPathname:// szOsFile - 0, - FpNext:// mxPathname - uintptr(0), - FzName:// pNext - ts + 25672, /* "crash" */ - FpAppData:// zName - uintptr(0), - FxOpen:// pAppData + FiVersion: 2, // pNext + FzName: ts + 25672, /* "crash" */ // pAppData - 0, - FxDelete:// xOpen - 0, - FxAccess:// xDelete - 0, - FxFullPathname:// xAccess - 0, - FxDlOpen:// xFullPathname - 0, - FxDlError:// xDlOpen - 0, - FxDlSym:// xDlError - 0, - FxDlClose:// xDlSym - 0, - FxRandomness:// xDlClose - 0, - FxSleep:// xRandomness - 0, - FxCurrentTime:// xSleep - 0, - FxGetLastError:// xCurrentTime - 0, - FxCurrentTimeInt64:// xGetLastError - uintptr(0), // xCurrentTimeInt64 + FxOpen: 0, // xOpen + FxDelete: 0, // xDelete + FxAccess: 0, // xAccess + FxFullPathname: 0, // xFullPathname + FxDlOpen: 0, // xDlOpen + FxDlError: 0, // xDlError + FxDlSym: 0, // xDlSym + FxDlClose: 0, // xDlClose + FxRandomness: 0, // xRandomness + FxSleep: 0, // xSleep + FxCurrentTime: 0, // xCurrentTime + FxGetLastError: 0, // xCurrentTimeInt64 } /* test6.c:845:22 */ // tclcmd: sqlite_crashparams ?OPTIONS? DELAY CRASHFILE @@ -58859,10 +55209,10 @@ __2: __3: ; - if !(processDevSymArgs(tls, interp, (objc-3), (objv+uintptr(1)*8), bp+40 /* &iDc */, bp+44 /* &iSectorSize */) != 0) { + if !(processDevSymArgs(tls, interp, (objc-3), (objv+1*8), bp+40 /* &iDc */, bp+44 /* &iSectorSize */) != 0) { goto __4 } - return 1 + return TCL_ERROR __4: ; @@ -58882,10 +55232,10 @@ __6: g.FiCrash = *(*int32)(unsafe.Pointer(bp + 36 /* iDelay */)) libc.Xmemcpy(tls, uintptr(unsafe.Pointer(&g))+28 /* &.zCrashFile */, zCrashFile, (uint64(*(*int32)(unsafe.Pointer(bp + 32 /* nCrashFile */)) + 1))) sqlite3CrashTestEnable = 1 - return 0 + return TCL_OK error: - return 1 + return TCL_ERROR } func devSymObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test6.c:963:26: */ @@ -58895,12 +55245,12 @@ func devSymObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, *(*int32)(unsafe.Pointer(bp /* iDc */)) = -1 *(*int32)(unsafe.Pointer(bp + 4 /* iSectorSize */)) = -1 - if processDevSymArgs(tls, interp, (objc-1), (objv+uintptr(1)*8), bp /* &iDc */, bp+4 /* &iSectorSize */) != 0 { - return 1 + if processDevSymArgs(tls, interp, (objc-1), (objv+1*8), bp /* &iDc */, bp+4 /* &iSectorSize */) != 0 { + return TCL_ERROR } devsym_register(tls, *(*int32)(unsafe.Pointer(bp /* iDc */)), *(*int32)(unsafe.Pointer(bp + 4 /* iSectorSize */))) - return 0 + return TCL_OK } // tclcmd: sqlite3_crash_on_write N @@ -58912,14 +55262,14 @@ func writeCrashObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc in if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+25728 /* "NWRITE" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &nWrite */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &nWrite */) != 0 { + return TCL_ERROR } devsym_crash_on_write(tls, *(*int32)(unsafe.Pointer(bp /* nWrite */))) - return 0 + return TCL_OK } // tclcmd: unregister_devsim @@ -58927,11 +55277,11 @@ func dsUnregisterObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } devsym_unregister(tls) - return 0 + return TCL_OK } // tclcmd: register_jt_vfs ?-default? PARENT-VFS @@ -58943,16 +55293,16 @@ func jtObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, obj if (objc != 2) && (objc != 3) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+25735 /* "?-default? PAREN..." */) - return 1 + return TCL_ERROR } - zParent = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zParent = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) if objc == 3 { if libc.Xstrcmp(tls, zParent, ts+25757 /* "-default" */) != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+11355 /* "bad option \"" */, zParent, ts+25766 /* "\": must be -defa..." */, 0)) - return 1 + return TCL_ERROR } - zParent = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zParent = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) } if !(int32(*(*int8)(unsafe.Pointer(zParent))) != 0) { @@ -58960,10 +55310,10 @@ func jtObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, obj } if jt_register(tls, zParent, (libc.Bool32(objc == 3))) != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25786 /* "Error in jt_regi..." */, 0)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // tclcmd: unregister_jt_vfs @@ -58971,11 +55321,11 @@ func jtUnregisterObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } jt_unregister(tls) - return 0 + return TCL_OK } // This procedure registers the TCL procedures defined in this file. @@ -59004,7 +55354,7 @@ func Sqlitetest6_Init(tls *libc.TLS, interp uintptr) int32 { /* test6.c:1089:5: tcl.XTcl_CreateObjCommand(tls, interp, ts+25947 /* "unregister_jt_vf..." */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 }{jtUnregisterObjCmd})), uintptr(0), uintptr(0)) - return 0 + return TCL_OK } // Each thread is controlled by an instance of the following @@ -59040,7 +55390,7 @@ func client_main(tls *libc.TLS, pArg uintptr) uintptr { /* test7.c:95:13: */ sqlite3_client_close(tls, (*Thread1)(unsafe.Pointer(p)).Fdb) } sqlite3_client_open(tls, (*Thread1)(unsafe.Pointer(p)).FzFilename, (p + 40 /* &.db */)) - if 0 != sqlite3.Xsqlite3_errcode(tls, (*Thread1)(unsafe.Pointer(p)).Fdb) { + if SQLITE_OK != sqlite3.Xsqlite3_errcode(tls, (*Thread1)(unsafe.Pointer(p)).Fdb) { (*Thread1)(unsafe.Pointer(p)).FzErr = libc.Xstrdup(tls, sqlite3.Xsqlite3_errmsg(tls, (*Thread1)(unsafe.Pointer(p)).Fdb)) sqlite3_client_close(tls, (*Thread1)(unsafe.Pointer(p)).Fdb) (*Thread1)(unsafe.Pointer(p)).Fdb = uintptr(0) @@ -59085,11 +55435,11 @@ func parse_client_id(tls *libc.TLS, interp uintptr, zArg uintptr) int32 { /* tes bp := tls.Alloc(16) defer tls.Free(16) - if (((zArg == uintptr(0)) || (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) == 0)) || (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(1)))) != 0)) || !((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zArg + uintptr(0))))))*2))) & int32(_ISupper)) != 0) { + 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) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+24719 /* "thread ID must b..." */, 0)) return -1 } - return (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) - 'A') + return (int32(*(*int8)(unsafe.Pointer(zArg))) - 'A') } // Usage: client_create NAME FILENAME @@ -59106,21 +55456,21 @@ func tcl_client_create(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 var rc int32 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24758 /* " ID FILENAME" */, 0)) - return 1 + return TCL_ERROR } - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if threadset1[i].Fbusy != 0 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24771 /* "thread " */, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+24779 /* " is already runn..." */, 0)) - return 1 + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24771 /* "thread " */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+24779 /* " is already runn..." */, 0)) + return TCL_ERROR } threadset1[i].Fbusy = 1 sqlite3.Xsqlite3_free(tls, threadset1[i].FzFilename) - threadset1[i].FzFilename = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + threadset1[i].FzFilename = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) threadset1[i].Fopnum = 1 threadset1[i].Fcompleted = 0 rc = libc2.Xpthread_create(tls, bp+88 /* &x */, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { @@ -59130,14 +55480,14 @@ func tcl_client_create(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, ts+24799 /* "failed to create..." */, 0)) sqlite3.Xsqlite3_free(tls, threadset1[i].FzFilename) threadset1[i].Fbusy = 0 - return 1 + return TCL_ERROR } libc2.Xpthread_detach(tls, *(*pthread_t)(unsafe.Pointer(bp + 88 /* x */))) if threadset1[i].FnServer == 0 { threadset1[i].FnServer = 1 sqlite3_server_start2(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688 + 1680 /* &.nServer */)) } - return 0 + return TCL_OK } // Wait for a thread to reach its idle state. @@ -59157,20 +55507,20 @@ func tcl_client_wait(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var i int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24827 /* " ID" */, 0)) - return 1 + return TCL_ERROR } - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset1[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) - return 0 + return TCL_OK } // Stop a thread. @@ -59197,43 +55547,43 @@ func tcl_client_halt(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var i int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24827 /* " ID" */, 0)) - return 1 + return TCL_ERROR } - if (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) + uintptr(0)))) == '*') && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) + uintptr(1)))) == 0) { - for i = 0; i < 26; i++ { + if (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 1*8))))) == '*') && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 1*8)) + 1))) == 0) { + for i = 0; i < N_THREAD; i++ { if threadset1[i].Fbusy != 0 { stop_thread(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) } } } else { - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset1[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } stop_thread(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) } // If no client threads are still running, also stop the server - for i = 0; (i < 26) && (threadset1[i].Fbusy == 0); i++ { + for i = 0; (i < N_THREAD) && (threadset1[i].Fbusy == 0); i++ { } - if i >= 26 { + if i >= N_THREAD { sqlite3_server_stop(tls) for 1 != 0 { - for i = 0; (i < 26) && (threadset1[i].FnServer == 0); i++ { + for i = 0; (i < N_THREAD) && (threadset1[i].FnServer == 0); i++ { } - if i == 26 { + if i == N_THREAD { break } libc2.Xsched_yield(tls) } } - return 0 + return TCL_OK } // Usage: client_argc ID @@ -59248,22 +55598,22 @@ func tcl_client_argc(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, // var zBuf [100]int8 at bp+72, 100 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24827 /* " ID" */, 0)) - return 1 + return TCL_ERROR } - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset1[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+72 /* &zBuf[0] */, ts+1237 /* "%d" */, libc.VaList(bp+48, threadset1[i].Fargc)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+72 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // Usage: client_argv ID N @@ -59278,28 +55628,28 @@ func tcl_client_argv(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, // var n int32 at bp+80, 4 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24846 /* " ID N" */, 0)) - return 1 + return TCL_ERROR } - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset1[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+80 /* &n */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+80 /* &n */) != 0 { + return TCL_ERROR } client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) if (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) < 0) || (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) >= threadset1[i].Fargc) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+24852 /* "column number ou..." */, 0)) - return 1 + return TCL_ERROR } 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)) - return 0 + return TCL_OK } // Usage: client_colname ID N @@ -59314,28 +55664,28 @@ func tcl_client_colname(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int // var n int32 at bp+80, 4 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24846 /* " ID N" */, 0)) - return 1 + return TCL_ERROR } - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset1[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+80 /* &n */) != 0 { - return 1 + if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+80 /* &n */) != 0 { + return TCL_ERROR } client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) if (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) < 0) || (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) >= threadset1[i].Fargc) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+24852 /* "column number ou..." */, 0)) - return 1 + return TCL_ERROR } 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)) - return 0 + return TCL_OK } // Usage: client_result ID @@ -59350,22 +55700,22 @@ func tcl_client_result(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int3 var zName uintptr if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24827 /* " ID" */, 0)) - return 1 + return TCL_ERROR } - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset1[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) zName = sqlite3.Xsqlite3ErrName(tls, threadset1[i].Frc) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, zName, 0)) - return 0 + return TCL_OK } // Usage: client_error ID @@ -59379,28 +55729,28 @@ func tcl_client_error(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32 var i int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24827 /* " ID" */, 0)) - return 1 + return TCL_ERROR } - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset1[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, threadset1[i].FzErr, 0)) - return 0 + return TCL_OK } // This procedure runs in the thread to compile an SQL statement. func do_compile1(tls *libc.TLS, p uintptr) { /* test7.c:466:13: */ if (*Thread1)(unsafe.Pointer(p)).Fdb == uintptr(0) { (*Thread1)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+24879 /* "no database is o..." */) - (*Thread1)(unsafe.Pointer(p)).Frc = 1 + (*Thread1)(unsafe.Pointer(p)).Frc = SQLITE_ERROR return } if (*Thread1)(unsafe.Pointer(p)).FpStmt != 0 { @@ -59419,24 +55769,24 @@ func tcl_client_compile(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int var i int32 if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24899 /* " ID SQL" */, 0)) - return 1 + return TCL_ERROR } - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset1[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) threadset1[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_compile1})) sqlite3.Xsqlite3_free(tls, threadset1[i].FzArg) - threadset1[i].FzArg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + threadset1[i].FzArg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) threadset1[i].Fopnum++ - return 0 + return TCL_OK } // This procedure runs in the thread to step the virtual machine. @@ -59444,11 +55794,11 @@ func do_step1(tls *libc.TLS, p uintptr) { /* test7.c:513:13: */ var i int32 if (*Thread1)(unsafe.Pointer(p)).FpStmt == uintptr(0) { (*Thread1)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+24907 /* "no virtual machi..." */) - (*Thread1)(unsafe.Pointer(p)).Frc = 1 + (*Thread1)(unsafe.Pointer(p)).Frc = SQLITE_ERROR return } (*Thread1)(unsafe.Pointer(p)).Frc = sqlite3_client_step(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt) - if (*Thread1)(unsafe.Pointer(p)).Frc == 100 { + if (*Thread1)(unsafe.Pointer(p)).Frc == SQLITE_ROW { (*Thread1)(unsafe.Pointer(p)).Fargc = sqlite3.Xsqlite3_column_count(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt) for i = 0; i < sqlite3.Xsqlite3_data_count(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt); i++ { *(*uintptr)(unsafe.Pointer((p + 80 /* &.argv */) + uintptr(i)*8)) = sqlite3.Xsqlite3_column_text(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt, i) @@ -59468,29 +55818,29 @@ func tcl_client_step(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var i int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24936 /* " IDL" */, 0)) - return 1 + return TCL_ERROR } - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset1[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) threadset1[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_step1})) threadset1[i].Fopnum++ - return 0 + return TCL_OK } // This procedure runs in the thread to finalize a virtual machine. func do_finalize1(tls *libc.TLS, p uintptr) { /* test7.c:564:13: */ if (*Thread1)(unsafe.Pointer(p)).FpStmt == uintptr(0) { (*Thread1)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+24907 /* "no virtual machi..." */) - (*Thread1)(unsafe.Pointer(p)).Frc = 1 + (*Thread1)(unsafe.Pointer(p)).Frc = SQLITE_ERROR return } (*Thread1)(unsafe.Pointer(p)).Frc = sqlite3_client_finalize(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt) @@ -59506,31 +55856,31 @@ func tcl_client_finalize(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc in var i int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24936 /* " IDL" */, 0)) - return 1 + return TCL_ERROR } - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset1[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) threadset1[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_finalize1})) sqlite3.Xsqlite3_free(tls, threadset1[i].FzArg) threadset1[i].FzArg = uintptr(0) threadset1[i].Fopnum++ - return 0 + return TCL_OK } // This procedure runs in the thread to reset a virtual machine. func do_reset(tls *libc.TLS, p uintptr) { /* test7.c:608:13: */ if (*Thread1)(unsafe.Pointer(p)).FpStmt == uintptr(0) { (*Thread1)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+24907 /* "no virtual machi..." */) - (*Thread1)(unsafe.Pointer(p)).Frc = 1 + (*Thread1)(unsafe.Pointer(p)).Frc = SQLITE_ERROR return } (*Thread1)(unsafe.Pointer(p)).Frc = sqlite3_client_reset(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt) @@ -59546,24 +55896,24 @@ func tcl_client_reset(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32 var i int32 if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24936 /* " IDL" */, 0)) - return 1 + return TCL_ERROR } - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset1[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) threadset1[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_reset})) sqlite3.Xsqlite3_free(tls, threadset1[i].FzArg) threadset1[i].FzArg = uintptr(0) threadset1[i].Fopnum++ - return 0 + return TCL_OK } // Usage: client_swap ID ID @@ -59577,32 +55927,32 @@ func tcl_client_swap(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, var j int32 var temp uintptr if argc != 3 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24941 /* " ID1 ID2" */, 0)) - return 1 + return TCL_ERROR } - i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if i < 0 { - return 1 + return TCL_ERROR } if !(threadset1[i].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) - j = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + j = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8))) if j < 0 { - return 1 + return TCL_ERROR } if !(threadset1[j].Fbusy != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+24831 /* "no such thread" */, 0)) - return 1 + return TCL_ERROR } client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(j)*1688)) temp = threadset1[i].Fdb threadset1[i].Fdb = threadset1[j].Fdb threadset1[j].Fdb = temp - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -59615,52 +55965,26 @@ func Sqlitetest7_Init(tls *libc.TLS, interp uintptr) int32 { /* test7.c:690:5: * }{}))); i++ { tcl.XTcl_CreateCommand(tls, interp, aCmd6[i].FzName, aCmd6[i].FxProc, uintptr(0), uintptr(0)) } - return 0 + return TCL_OK } var aCmd6 = [13]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 25965, /* "client_create" */ - FxProc: 0}, - { - FzName: ts + 25979, /* "client_wait" */ - FxProc: 0}, - { - FzName: ts + 25991, /* "client_halt" */ - FxProc: 0}, - { - FzName: ts + 26003, /* "client_argc" */ - FxProc: 0}, - { - FzName: ts + 26015, /* "client_argv" */ - FxProc: 0}, - { - FzName: ts + 26027, /* "client_colname" */ - FxProc: 0}, - { - FzName: ts + 26042, /* "client_result" */ - FxProc: 0}, - { - FzName: ts + 26056, /* "client_error" */ - FxProc: 0}, - { - FzName: ts + 26069, /* "client_compile" */ - FxProc: 0}, - { - FzName: ts + 26084, /* "client_step" */ - FxProc: 0}, - { - FzName: ts + 26096, /* "client_reset" */ - FxProc: 0}, - { - FzName: ts + 26109, /* "client_finalize" */ - FxProc: 0}, - { - FzName: ts + 26125, /* "client_swap" */ - FxProc: 0}, + {FzName: ts + 25965 /* "client_create" */, FxProc: 0}, + {FzName: ts + 25979 /* "client_wait" */, FxProc: 0}, + {FzName: ts + 25991 /* "client_halt" */, FxProc: 0}, + {FzName: ts + 26003 /* "client_argc" */, FxProc: 0}, + {FzName: ts + 26015 /* "client_argv" */, FxProc: 0}, + {FzName: ts + 26027 /* "client_colname" */, FxProc: 0}, + {FzName: ts + 26042 /* "client_result" */, FxProc: 0}, + {FzName: ts + 26056 /* "client_error" */, FxProc: 0}, + {FzName: ts + 26069 /* "client_compile" */, FxProc: 0}, + {FzName: ts + 26084 /* "client_step" */, FxProc: 0}, + {FzName: ts + 26096 /* "client_reset" */, FxProc: 0}, + {FzName: ts + 26109 /* "client_finalize" */, FxProc: 0}, + {FzName: ts + 26125 /* "client_swap" */, FxProc: 0}, } /* test7.c:694:5 */ // end block for C++ @@ -59783,9 +56107,9 @@ func simulateVtabError(tls *libc.TLS, p uintptr, zMethod uintptr) int32 { /* tes var zErr uintptr // var zVarname [128]int8 at bp+24, 128 - *(*int8)(unsafe.Pointer(bp + 24 /* &zVarname[0] */ + uintptr(127))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 24 /* &zVarname[0] */ + 127)) = int8(0) sqlite3.Xsqlite3_snprintf(tls, 127, bp+24 /* &zVarname[0] */, ts+26137 /* "echo_module_fail..." */, libc.VaList(bp, zMethod, (*echo_vtab)(unsafe.Pointer(p)).FzTableName)) - zErr = tcl.XTcl_GetVar2(tls, (*echo_vtab)(unsafe.Pointer(p)).Finterp, bp+24 /* &zVarname[0] */, uintptr(0), 1) + zErr = tcl.XTcl_GetVar2(tls, (*echo_vtab)(unsafe.Pointer(p)).Finterp, bp+24 /* &zVarname[0] */, uintptr(0), TCL_GLOBAL_ONLY) if zErr != 0 { (*echo_vtab)(unsafe.Pointer(p)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+26161 /* "echo-vtab-error:..." */, libc.VaList(bp+16, zErr)) } @@ -59810,7 +56134,7 @@ func dequoteString(tls *libc.TLS, z uintptr) { /* test8.c:122:13: */ if z == uintptr(0) { return } - quote = int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) + quote = int32(*(*int8)(unsafe.Pointer(z))) switch quote { case '\'': break @@ -59865,7 +56189,7 @@ func getColumnNames(tls *libc.TLS, db uintptr, zTab uintptr, paCol uintptr, pnCo var zSpace uintptr aCol = uintptr(0) *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)) = uintptr(0) - rc = 0 + rc = SQLITE_OK nCol = 0 // Prepare the statement "SELECT * FROM ". The column names @@ -59875,14 +56199,14 @@ func getColumnNames(tls *libc.TLS, db uintptr, zTab uintptr, paCol uintptr, pnCo if !(!(zSql != 0)) { goto __1 } - rc = 7 + rc = SQLITE_NOMEM goto out __1: ; rc = sqlite3.Xsqlite3_prepare(tls, db, zSql, -1, bp+16 /* &pStmt */, uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __2 } nCol = sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) @@ -59899,7 +56223,7 @@ __3: if !(!(zName != 0)) { goto __6 } - rc = 7 + rc = SQLITE_NOMEM goto out __6: ; @@ -59915,7 +56239,7 @@ __5: if !(!(aCol != 0)) { goto __7 } - rc = 7 + rc = SQLITE_NOMEM goto out __7: ; @@ -59982,7 +56306,7 @@ func getIndexArray(tls *libc.TLS, db uintptr, zTab uintptr, nCol int32, paIndex if !(!(aIndex != 0)) { goto __1 } - rc = 7 + rc = SQLITE_NOMEM goto get_index_array_out __1: ; @@ -59992,7 +56316,7 @@ __1: if !(!(zSql != 0)) { goto __2 } - rc = 7 + rc = SQLITE_NOMEM goto get_index_array_out __2: ; @@ -60002,7 +56326,7 @@ __2: // For each index, figure out the left-most column and set the // corresponding entry in aIndex[] to 1. __3: - if !((*(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)) != 0) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == 100)) { + if !((*(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)) != 0) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == SQLITE_ROW)) { goto __4 } zIdx = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)), 1) @@ -60017,13 +56341,13 @@ __5: if !(!(zSql != 0)) { goto __6 } - rc = 7 + rc = SQLITE_NOMEM goto get_index_array_out __6: ; rc = sqlite3.Xsqlite3_prepare(tls, db, zSql, -1, bp+24 /* &pStmt2 */, uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) - if !((*(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt2 */)) != 0) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt2 */))) == 100)) { + if !((*(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt2 */)) != 0) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt2 */))) == SQLITE_ROW)) { goto __7 } cid = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt2 */)), 1) @@ -60037,7 +56361,7 @@ __7: rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt2 */))) __8: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __9 } goto get_index_array_out @@ -60052,7 +56376,7 @@ get_index_array_out: goto __10 } rc2 = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __11 } rc = rc2 @@ -60060,7 +56384,7 @@ __11: ; __10: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } sqlite3.Xsqlite3_free(tls, aIndex) @@ -60074,7 +56398,7 @@ __12: // Global Tcl variable $echo_module is a list. This routine appends // the string element zArg to that list in interpreter interp. func appendToEchoModule(tls *libc.TLS, interp uintptr, zArg uintptr) { /* test8.c:313:13: */ - var flags int32 = ((4 | 8) | 1) + var flags int32 = ((TCL_APPEND_VALUE | TCL_LIST_ELEMENT) | TCL_GLOBAL_ONLY) tcl.XTcl_SetVar2(tls, interp, ts+26242 /* "echo_module" */, uintptr(0), func() uintptr { if zArg != 0 { return zArg @@ -60102,33 +56426,33 @@ func echoDeclareVtab(tls *libc.TLS, pVtab uintptr, db uintptr) int32 { /* test8. bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName != 0 { *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) rc = sqlite3.Xsqlite3_prepare(tls, db, ts+26254, /* "SELECT sql FROM ..." */ -1, bp /* &pStmt */, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { sqlite3.Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 1, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName, -1, uintptr(0)) - if sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) == 100 { + if sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) == SQLITE_ROW { var rc2 int32 var zCreateTable uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 0) rc = sqlite3.Xsqlite3_declare_vtab(tls, db, zCreateTable) rc2 = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } else { rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) - if rc == 0 { - rc = 1 + if rc == SQLITE_OK { + rc = SQLITE_ERROR } } - if rc == 0 { + if rc == SQLITE_OK { rc = getColumnNames(tls, db, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName, (pVtab + 88 /* &.aCol */), (pVtab + 72 /* &.nCol */)) } - if rc == 0 { + if rc == SQLITE_OK { rc = getIndexArray(tls, db, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName, (*echo_vtab)(unsafe.Pointer(pVtab)).FnCol, (pVtab + 80 /* &.aIndex */)) } } @@ -60168,31 +56492,31 @@ func echoConstructor(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv u // Allocate the sqlite3_vtab/echo_vtab structure itself pVtab = sqlite3.Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(echo_vtab{}))) if !(pVtab != 0) { - return 7 + return SQLITE_NOMEM } (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp = (*EchoModule)(unsafe.Pointer(pAux)).Finterp (*echo_vtab)(unsafe.Pointer(pVtab)).Fdb = db // Allocate echo_vtab.zThis - (*echo_vtab)(unsafe.Pointer(pVtab)).FzThis = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + (*echo_vtab)(unsafe.Pointer(pVtab)).FzThis = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) if !(int32((*echo_vtab)(unsafe.Pointer(pVtab)).FzThis) != 0) { echoDestructor(tls, pVtab) - return 7 + return SQLITE_NOMEM } // Allocate echo_vtab.zTableName if argc > 3 { - (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)))) + (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(argv + 3*8)))) dequoteString(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName) - if ((*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName != 0) && (int32(*(*int8)(unsafe.Pointer((*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName + uintptr(0)))) == '*') { - var z uintptr = sqlite3.Xsqlite3_mprintf(tls, ts+26318 /* "%s%s" */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), ((*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName+uintptr(1)))) + if ((*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName != 0) && (int32(*(*int8)(unsafe.Pointer((*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName))) == '*') { + var z uintptr = sqlite3.Xsqlite3_mprintf(tls, ts+26318 /* "%s%s" */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ((*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName+1))) sqlite3.Xsqlite3_free(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName) (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName = z (*echo_vtab)(unsafe.Pointer(pVtab)).FisPattern = 1 } if !(int32((*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName) != 0) { echoDestructor(tls, pVtab) - return 7 + return SQLITE_NOMEM } } @@ -60205,14 +56529,14 @@ func echoConstructor(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv u // structure. If an error occurs, delete the sqlite3_vtab structure and // return an error code. rc = echoDeclareVtab(tls, pVtab, db) - if rc != 0 { + if rc != SQLITE_OK { echoDestructor(tls, pVtab) return rc } // Success. Set *ppVtab and return *(*uintptr)(unsafe.Pointer(ppVtab)) = (pVtab /* &.base */) - return 0 + return SQLITE_OK } // Echo virtual table module xCreate method. @@ -60220,7 +56544,7 @@ func echoCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintpt bp := tls.Alloc(24) defer tls.Free(24) - var rc int32 = 0 + var rc int32 = SQLITE_OK appendToEchoModule(tls, (*EchoModule)(unsafe.Pointer(pAux)).Finterp, ts+26323 /* "xCreate" */) rc = echoConstructor(tls, db, pAux, argc, argv, ppVtab, pzErr) @@ -60233,24 +56557,24 @@ func echoCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintpt // // Note: The main point of this is to test that we can drop tables // from within an xDestroy method call. - if (rc == 0) && (argc == 5) { + if (rc == SQLITE_OK) && (argc == 5) { var zSql uintptr var pVtab uintptr = *(*uintptr)(unsafe.Pointer(ppVtab)) - (*echo_vtab)(unsafe.Pointer(pVtab)).FzLogName = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)))) + (*echo_vtab)(unsafe.Pointer(pVtab)).FzLogName = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + 4*8)))) zSql = sqlite3.Xsqlite3_mprintf(tls, ts+26331 /* "CREATE TABLE %Q(..." */, libc.VaList(bp+8, (*echo_vtab)(unsafe.Pointer(pVtab)).FzLogName)) rc = sqlite3.Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+16, sqlite3.Xsqlite3_errmsg(tls, db))) } } - if (*(*uintptr)(unsafe.Pointer(ppVtab)) != 0) && (rc != 0) { + if (*(*uintptr)(unsafe.Pointer(ppVtab)) != 0) && (rc != SQLITE_OK) { echoDestructor(tls, *(*uintptr)(unsafe.Pointer(ppVtab))) *(*uintptr)(unsafe.Pointer(ppVtab)) = uintptr(0) } - if rc == 0 { + if rc == SQLITE_OK { (*echo_vtab)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppVtab)))).FinTransaction = 1 } @@ -60274,7 +56598,7 @@ func echoDestroy(tls *libc.TLS, pVtab uintptr) int32 { /* test8.c:534:12: */ bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr = pVtab appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, ts+26376 /* "xDestroy" */) @@ -60286,7 +56610,7 @@ func echoDestroy(tls *libc.TLS, pVtab uintptr) int32 { /* test8.c:534:12: */ sqlite3.Xsqlite3_free(tls, zSql) } - if rc == 0 { + if rc == SQLITE_OK { rc = echoDestructor(tls, pVtab) } return rc @@ -60296,15 +56620,15 @@ func echoDestroy(tls *libc.TLS, pVtab uintptr) int32 { /* test8.c:534:12: */ func echoOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test8.c:556:12: */ var pCur uintptr if simulateVtabError(tls, pVTab, ts+26399 /* "xOpen" */) != 0 { - return 1 + return SQLITE_ERROR } pCur = sqlite3.Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(echo_cursor{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = pCur return func() int32 { if pCur != 0 { - return 0 + return SQLITE_OK } - return 7 + return SQLITE_NOMEM }() } @@ -60332,17 +56656,17 @@ func echoEof(tls *libc.TLS, cur uintptr) int32 { /* test8.c:583:12: */ // Echo virtual table module xNext method. func echoNext(tls *libc.TLS, cur uintptr) int32 { /* test8.c:590:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pCur uintptr = cur if simulateVtabError(tls, (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab, ts+26405 /* "xNext" */) != 0 { - return 1 + return SQLITE_ERROR } if (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt != 0 { rc = sqlite3.Xsqlite3_step(tls, (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt) - if rc == 100 { - rc = 0 + if rc == SQLITE_ROW { + rc = SQLITE_OK } else { rc = sqlite3.Xsqlite3_finalize(tls, (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt) (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt = uintptr(0) @@ -60358,7 +56682,7 @@ func echoColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* tes var pStmt uintptr = (*echo_cursor)(unsafe.Pointer(cur)).FpStmt if simulateVtabError(tls, (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab, ts+26411 /* "xColumn" */) != 0 { - return 1 + return SQLITE_ERROR } if !(pStmt != 0) { @@ -60367,7 +56691,7 @@ func echoColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* tes sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, pStmt, iCol)) } - return 0 + return SQLITE_OK } // Echo virtual table module xRowid method. @@ -60375,11 +56699,11 @@ func echoRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test8.c:63 var pStmt uintptr = (*echo_cursor)(unsafe.Pointer(cur)).FpStmt if simulateVtabError(tls, (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab, ts+2164 /* "xRowid" */) != 0 { - return 1 + return SQLITE_ERROR } *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_column_int64(tls, pStmt, 0) - return 0 + return SQLITE_OK } // Compute a simple hash of the null terminated string zString. @@ -60408,7 +56732,7 @@ func echoFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr var db uintptr = (*echo_vtab)(unsafe.Pointer(pVtab)).Fdb if simulateVtabError(tls, pVtab, ts+26419 /* "xFilter" */) != 0 { - return 1 + return SQLITE_ERROR } // Check that idxNum matches idxStr @@ -60427,12 +56751,12 @@ func echoFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr // runtime parameters passed to this function to it. rc = sqlite3.Xsqlite3_prepare(tls, db, idxStr, -1, (pCur + 8 /* &.pStmt */), uintptr(0)) - for i = 0; (rc == 0) && (i < argc); i++ { + for i = 0; (rc == SQLITE_OK) && (i < argc); i++ { rc = sqlite3.Xsqlite3_bind_value(tls, (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt, (i + 1), *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) } // If everything was successful, advance to the first row of the scan - if rc == 0 { + if rc == SQLITE_OK { rc = echoNext(tls, pVtabCursor) } @@ -60455,10 +56779,10 @@ func string_concat(tls *libc.TLS, pzStr uintptr, zAppend uintptr, doFree int32, defer tls.Free(24) var zIn uintptr = *(*uintptr)(unsafe.Pointer(pzStr)) - if (!(zAppend != 0) && (doFree != 0)) && (*(*int32)(unsafe.Pointer(pRc)) == 0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + if (!(zAppend != 0) && (doFree != 0)) && (*(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK) { + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } - if *(*int32)(unsafe.Pointer(pRc)) != 0 { + if *(*int32)(unsafe.Pointer(pRc)) != SQLITE_OK { sqlite3.Xsqlite3_free(tls, zIn) zIn = uintptr(0) } else { @@ -60470,7 +56794,7 @@ func string_concat(tls *libc.TLS, pzStr uintptr, zAppend uintptr, doFree int32, zIn = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+16, zAppend)) } if !(zIn != 0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } *(*uintptr)(unsafe.Pointer(pzStr)) = zIn @@ -60551,50 +56875,50 @@ func echoBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test var nRow int32 = 0 var useIdx int32 = 0 - *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = SQLITE_OK var useCost int32 = 0 var cost float64 = float64(0) var isIgnoreUsable int32 = 0 - if tcl.XTcl_GetVar2(tls, interp, ts+26447 /* "echo_module_igno..." */, uintptr(0), 1) != 0 { + if tcl.XTcl_GetVar2(tls, interp, ts+26447 /* "echo_module_igno..." */, uintptr(0), TCL_GLOBAL_ONLY) != 0 { isIgnoreUsable = 1 } if simulateVtabError(tls, pVtab, ts+26473 /* "xBestIndex" */) != 0 { - return 1 + return SQLITE_ERROR } // Determine the number of rows in the table and store this value in local // variable nRow. The 'estimated-cost' of the scan will be the number of // rows in the table for a linear scan, or the log (base 2) of the // number of rows if the proposed scan uses an index. - if tcl.XTcl_GetVar2(tls, interp, ts+26484 /* "echo_module_cost" */, uintptr(0), 1) != 0 { - cost = libc.Xatof(tls, tcl.XTcl_GetVar2(tls, interp, ts+26484 /* "echo_module_cost" */, uintptr(0), 1)) + if tcl.XTcl_GetVar2(tls, interp, ts+26484 /* "echo_module_cost" */, uintptr(0), TCL_GLOBAL_ONLY) != 0 { + cost = libc.Xatof(tls, tcl.XTcl_GetVar2(tls, interp, ts+26484 /* "echo_module_cost" */, uintptr(0), TCL_GLOBAL_ONLY)) useCost = 1 } else { *(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */)) = sqlite3.Xsqlite3_mprintf(tls, ts+26501 /* "SELECT count(*) ..." */, libc.VaList(bp, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) if !(*(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */)) != 0) { - return 7 + return SQLITE_NOMEM } *(*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)) sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */))) - if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) } sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */))) nRow = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)), 0) *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */))) - if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) } } zCol = echoSelectList(tls, pVtab, pIdxInfo) if !(zCol != 0) { - return 7 + return SQLITE_NOMEM } *(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */)) = sqlite3.Xsqlite3_mprintf(tls, ts+26525 /* "SELECT rowid%z F..." */, libc.VaList(bp+8, zCol, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) if !(*(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */)) != 0) { - return 7 + return SQLITE_NOMEM } for ii = 0; ii < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { @@ -60620,27 +56944,27 @@ func echoBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test var zOp uintptr = uintptr(0) useIdx = 1 switch int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) { - case 2: + case SQLITE_INDEX_CONSTRAINT_EQ: zOp = ts + 26554 /* "=" */ break fallthrough - case 16: + case SQLITE_INDEX_CONSTRAINT_LT: zOp = ts + 26556 /* "<" */ break fallthrough - case 4: + case SQLITE_INDEX_CONSTRAINT_GT: zOp = ts + 26558 /* ">" */ break fallthrough - case 8: + case SQLITE_INDEX_CONSTRAINT_LE: zOp = ts + 26560 /* "<=" */ break fallthrough - case 32: + case SQLITE_INDEX_CONSTRAINT_GE: zOp = ts + 26563 /* ">=" */ break fallthrough - case 64: + case SQLITE_INDEX_CONSTRAINT_MATCH: // Purposely translate the MATCH operator into a LIKE, which // will be used by the next block of code to construct a new // query. It should also be noted here that the next block @@ -60650,20 +56974,20 @@ func echoBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test zOp = ts + 26566 /* "LIKE" */ break fallthrough - case 65: + case SQLITE_INDEX_CONSTRAINT_LIKE: zOp = ts + 26571 /* "like" */ break fallthrough - case 66: + case SQLITE_INDEX_CONSTRAINT_GLOB: zOp = ts + 26576 /* "glob" */ break fallthrough - case 67: + case SQLITE_INDEX_CONSTRAINT_REGEXP: zOp = ts + 6165 /* "regexp" */ break } if zOp != 0 { - if int32(*(*int8)(unsafe.Pointer(zOp + uintptr(0)))) == 'L' { + if int32(*(*int8)(unsafe.Pointer(zOp))) == 'L' { zNew = sqlite3.Xsqlite3_mprintf(tls, ts+26581, /* " %s %s LIKE (SEL..." */ libc.VaList(bp+24, zSep, zNewCol)) } else { @@ -60742,7 +57066,7 @@ func echoUpdate(tls *libc.TLS, tab uintptr, nData int32, apData uintptr, pRowid var pVtab uintptr = tab var db uintptr = (*echo_vtab)(unsafe.Pointer(pVtab)).Fdb - *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */)) = uintptr(0) *(*uintptr)(unsafe.Pointer(bp + 96 /* z */)) = uintptr(0) // SQL statement to execute @@ -60754,18 +57078,18 @@ func echoUpdate(tls *libc.TLS, tab uintptr, nData int32, apData uintptr, pRowid // making any changes to a virtual table if simulateVtabError(tls, pVtab, ts+26653 /* "xUpdate" */) != 0 { - return 1 + return SQLITE_ERROR } // If apData[0] is an integer and nData>1 then do an UPDATE - if (nData > 1) && (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData + uintptr(0)*8))) == 1) { + if (nData > 1) && (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData))) == SQLITE_INTEGER) { var zSep uintptr = ts + 26661 /* " SET" */ *(*uintptr)(unsafe.Pointer(bp + 96 /* z */)) = sqlite3.Xsqlite3_mprintf(tls, ts+26666 /* "UPDATE %Q" */, libc.VaList(bp, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) if !(*(*uintptr)(unsafe.Pointer(bp + 96 /* z */)) != 0) { - *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = SQLITE_NOMEM } - bindArgOne = (libc.Bool32((*(*uintptr)(unsafe.Pointer(apData + uintptr(1)*8)) != 0) && (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData + uintptr(1)*8))) == 1))) + bindArgOne = (libc.Bool32((*(*uintptr)(unsafe.Pointer(apData + 1*8)) != 0) && (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData + 1*8))) == SQLITE_INTEGER))) bindArgZero = 1 if bindArgOne != 0 { @@ -60781,22 +57105,22 @@ func echoUpdate(tls *libc.TLS, tab uintptr, nData int32, apData uintptr, pRowid zSep = ts + 4449 /* "," */ } string_concat(tls, bp+96 /* &z */, sqlite3.Xsqlite3_mprintf(tls, ts+26701 /* " WHERE rowid=?%d" */, libc.VaList(bp+32, nData)), 1, bp+104 /* &rc */) - } else if (nData == 1) && (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData + uintptr(0)*8))) == 1) { + } else if (nData == 1) && (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData))) == SQLITE_INTEGER) { *(*uintptr)(unsafe.Pointer(bp + 96 /* z */)) = sqlite3.Xsqlite3_mprintf(tls, ts+26718 /* "DELETE FROM %Q W..." */, libc.VaList(bp+40, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) if !(*(*uintptr)(unsafe.Pointer(bp + 96 /* z */)) != 0) { - *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = SQLITE_NOMEM } bindArgZero = 1 - } else if (nData > 2) && (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData + uintptr(0)*8))) == 5) { + } else if (nData > 2) && (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData))) == SQLITE_NULL) { var ii int32 *(*uintptr)(unsafe.Pointer(bp + 112 /* zInsert */)) = uintptr(0) *(*uintptr)(unsafe.Pointer(bp + 120 /* zValues */)) = uintptr(0) *(*uintptr)(unsafe.Pointer(bp + 112 /* zInsert */)) = sqlite3.Xsqlite3_mprintf(tls, ts+26750 /* "INSERT INTO %Q (" */, libc.VaList(bp+48, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) if !(*(*uintptr)(unsafe.Pointer(bp + 112 /* zInsert */)) != 0) { - *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = SQLITE_NOMEM } - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData + uintptr(1)*8))) == 1 { + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData + 1*8))) == SQLITE_INTEGER { bindArgOne = 1 *(*uintptr)(unsafe.Pointer(bp + 120 /* zValues */)) = sqlite3.Xsqlite3_mprintf(tls, ts+3219 /* "?" */, 0) string_concat(tls, bp+112 /* &zInsert */, ts+26548 /* "rowid" */, 0, bp+104 /* &rc */) @@ -60825,27 +57149,27 @@ func echoUpdate(tls *libc.TLS, tab uintptr, nData int32, apData uintptr, pRowid string_concat(tls, bp+96 /* &z */, ts+489 /* ")" */, 0, bp+104 /* &rc */) } else { - return 1 + return SQLITE_ERROR } - if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = sqlite3.Xsqlite3_prepare(tls, db, *(*uintptr)(unsafe.Pointer(bp + 96 /* z */)), -1, bp+128 /* &pStmt */, uintptr(0)) } sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 96 /* z */))) - if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == SQLITE_OK { if bindArgZero != 0 { - sqlite3.Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */)), nData, *(*uintptr)(unsafe.Pointer(apData + uintptr(0)*8))) + sqlite3.Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */)), nData, *(*uintptr)(unsafe.Pointer(apData))) } if bindArgOne != 0 { - sqlite3.Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */)), 1, *(*uintptr)(unsafe.Pointer(apData + uintptr(1)*8))) + sqlite3.Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */)), 1, *(*uintptr)(unsafe.Pointer(apData + 1*8))) } - for i = 2; (i < nData) && (*(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == 0); i++ { + for i = 2; (i < nData) && (*(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == SQLITE_OK); i++ { if *(*uintptr)(unsafe.Pointer(apData + uintptr(i)*8)) != 0 { *(*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))) } } - if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == SQLITE_OK { sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */))) *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */))) } else { @@ -60853,10 +57177,10 @@ func echoUpdate(tls *libc.TLS, tab uintptr, nData int32, apData uintptr, pRowid } } - if (pRowid != 0) && (*(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == 0) { + if (pRowid != 0) && (*(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == SQLITE_OK) { *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_last_insert_rowid(tls, db) } - if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) != SQLITE_OK { (*sqlite3_vtab)(unsafe.Pointer(tab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+26161 /* "echo-vtab-error:..." */, libc.VaList(bp+88, sqlite3.Xsqlite3_errmsg(tls, db))) } @@ -60874,12 +57198,12 @@ func echoTransactionCall(tls *libc.TLS, tab uintptr, zCall uintptr) int32 { /* t var pVtab uintptr = tab z = sqlite3.Xsqlite3_mprintf(tls, ts+26788 /* "echo(%s)" */, libc.VaList(bp, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) if z == uintptr(0) { - return 7 + return SQLITE_NOMEM } appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, zCall) appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, z) sqlite3.Xsqlite3_free(tls, z) - return 0 + return SQLITE_OK } func echoBegin(tls *libc.TLS, tab uintptr) int32 { /* test8.c:1111:12: */ @@ -60892,21 +57216,21 @@ func echoBegin(tls *libc.TLS, tab uintptr) int32 { /* test8.c:1111:12: */ // a transaction if simulateVtabError(tls, pVtab, ts+26797 /* "xBegin" */) != 0 { - return 1 + return SQLITE_ERROR } rc = echoTransactionCall(tls, tab, ts+26797 /* "xBegin" */) - if rc == 0 { + if rc == SQLITE_OK { // Check if the $::echo_module_begin_fail variable is defined. If it is, // and it is set to the name of the real table underlying this virtual // echo module table, then cause this xSync operation to fail. - zVal = tcl.XTcl_GetVar2(tls, interp, ts+26804 /* "echo_module_begi..." */, uintptr(0), 1) + zVal = tcl.XTcl_GetVar2(tls, interp, ts+26804 /* "echo_module_begi..." */, uintptr(0), TCL_GLOBAL_ONLY) if (zVal != 0) && (0 == libc.Xstrcmp(tls, zVal, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) { - rc = 1 + rc = SQLITE_ERROR } } - if rc == 0 { + if rc == SQLITE_OK { (*echo_vtab)(unsafe.Pointer(pVtab)).FinTransaction = 1 } return rc @@ -60922,16 +57246,16 @@ func echoSync(tls *libc.TLS, tab uintptr) int32 { /* test8.c:1142:12: */ // transaction if simulateVtabError(tls, pVtab, ts+26827 /* "xSync" */) != 0 { - return 1 + return SQLITE_ERROR } rc = echoTransactionCall(tls, tab, ts+26827 /* "xSync" */) - if rc == 0 { + if rc == SQLITE_OK { // Check if the $::echo_module_sync_fail variable is defined. If it is, // and it is set to the name of the real table underlying this virtual // echo module table, then cause this xSync operation to fail. - zVal = tcl.XTcl_GetVar2(tls, interp, ts+26833 /* "echo_module_sync..." */, uintptr(0), 1) + zVal = tcl.XTcl_GetVar2(tls, interp, ts+26833 /* "echo_module_sync..." */, uintptr(0), TCL_GLOBAL_ONLY) if (zVal != 0) && (0 == libc.Xstrcmp(tls, zVal, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) { rc = -1 } @@ -60947,7 +57271,7 @@ func echoCommit(tls *libc.TLS, tab uintptr) int32 { /* test8.c:1170:12: */ // a transaction if simulateVtabError(tls, pVtab, ts+26855 /* "xCommit" */) != 0 { - return 1 + return SQLITE_ERROR } sqlite3.Xsqlite3BeginBenignMalloc(tls) @@ -61028,11 +57352,11 @@ func echoRename(tls *libc.TLS, vtab uintptr, zNewName uintptr) int32 { /* test8. bp := tls.Alloc(24) defer tls.Free(24) - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr = vtab if simulateVtabError(tls, p, ts+26894 /* "xRename" */) != 0 { - return 1 + return SQLITE_ERROR } if (*echo_vtab)(unsafe.Pointer(p)).FisPattern != 0 { @@ -61048,97 +57372,68 @@ func echoRename(tls *libc.TLS, vtab uintptr, zNewName uintptr) int32 { /* test8. func echoSavepoint(tls *libc.TLS, pVTab uintptr, iSavepoint int32) int32 { /* test8.c:1280:12: */ - return 0 + return SQLITE_OK } func echoRelease(tls *libc.TLS, pVTab uintptr, iSavepoint int32) int32 { /* test8.c:1285:12: */ - return 0 + return SQLITE_OK } func echoRollbackTo(tls *libc.TLS, pVTab uintptr, iSavepoint int32) int32 { /* test8.c:1290:12: */ - return 0 + return SQLITE_OK } // A virtual table module that merely "echos" the contents of another // table (like an SQL VIEW). var echoModule = sqlite3_module{ - FiVersion: 1, - FxCreate:// iVersion - 0, - FxConnect: 0, - FxBestIndex: 0, - FxDisconnect: 0, - FxDestroy: 0, - FxOpen: 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - write data - 0, - FxSync:// xBegin - begin transaction - 0, - FxCommit:// xSync - sync transaction - 0, - FxRollback:// xCommit - commit transaction - 0, - FxFindFunction:// xRollback - rollback transaction - 0, - FxRename:// xFindFunction - function overloading - 0, // xRename - rename the table + FiVersion: 1, // iVersion + FxCreate: 0, + FxConnect: 0, + FxBestIndex: 0, + FxDisconnect: 0, + FxDestroy: 0, + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRowid - read data + FxUpdate: 0, // xUpdate - write data + FxBegin: 0, // xBegin - begin transaction + FxSync: 0, // xSync - sync transaction + FxCommit: 0, // xCommit - commit transaction + FxRollback: 0, // xRollback - rollback transaction + FxFindFunction: 0, // xFindFunction - function overloading + FxRename: 0, // xRename - rename the table } /* test8.c:1299:23 */ var echoModuleV2 = sqlite3_module{ - FiVersion: 2, - FxCreate:// iVersion - 0, - FxConnect: 0, - FxBestIndex: 0, - FxDisconnect: 0, - FxDestroy: 0, - FxOpen: 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - write data - 0, - FxSync:// xBegin - begin transaction - 0, - FxCommit:// xSync - sync transaction - 0, - FxRollback:// xCommit - commit transaction - 0, - FxFindFunction:// xRollback - rollback transaction - 0, - FxRename:// xFindFunction - function overloading - 0, - FxSavepoint:// xRename - rename the table - 0, - FxRelease: 0, - FxRollbackTo: 0, + FiVersion: 2, // iVersion + FxCreate: 0, + FxConnect: 0, + FxBestIndex: 0, + FxDisconnect: 0, + FxDestroy: 0, + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRowid - read data + FxUpdate: 0, // xUpdate - write data + FxBegin: 0, // xBegin - begin transaction + FxSync: 0, // xSync - sync transaction + FxCommit: 0, // xCommit - commit transaction + FxRollback: 0, // xRollback - rollback transaction + FxFindFunction: 0, // xFindFunction - function overloading + FxRename: 0, // xRename - rename the table + FxSavepoint: 0, + FxRelease: 0, + FxRollbackTo: 0, } /* test8.c:1322:23 */ func moduleDestroy(tls *libc.TLS, p uintptr) { /* test8.c:1354:13: */ @@ -61156,10 +57451,10 @@ func register_echo_module(tls *libc.TLS, clientData ClientData, interp uintptr, var pMod uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } // Virtual table module "echo" @@ -61169,7 +57464,7 @@ func register_echo_module(tls *libc.TLS, clientData ClientData, interp uintptr, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+26932 /* "echo" */, uintptr(unsafe.Pointer(&echoModule)), pMod, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{moduleDestroy}))) // Virtual table module "echo_v2" - if rc == 0 { + if rc == SQLITE_OK { pMod = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(EchoModule{}))) (*EchoModule)(unsafe.Pointer(pMod)).Finterp = interp rc = sqlite3.Xsqlite3_create_module_v2(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+26937, /* "echo_v2" */ @@ -61177,7 +57472,7 @@ func register_echo_module(tls *libc.TLS, clientData ClientData, interp uintptr, } tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // Tcl interface to sqlite3_declare_vtab, invoked as follows from Tcl: @@ -61192,17 +57487,17 @@ func declare_vtab(tls *libc.TLS, clientData ClientData, interp uintptr, objc int var rc int32 if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+26945 /* "DB SQL" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_declare_vtab(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)))) - if rc != 0 { + rc = sqlite3.Xsqlite3_declare_vtab(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)))) + if rc != SQLITE_OK { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp /* db */))), uintptr(1)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -61216,7 +57511,7 @@ func Sqlitetest8_Init(tls *libc.TLS, interp uintptr) int32 { /* test8.c:1427:5: tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd2[i].FzName, aObjCmd2[i].FxProc, aObjCmd2[i].FclientData, uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd2 = [2]struct { @@ -61224,14 +57519,8 @@ var aObjCmd2 = [2]struct { FxProc uintptr FclientData uintptr }{ - { - FzName: ts + 26952, /* "register_echo_mo..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 26973, /* "sqlite3_declare_..." */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 26952 /* "register_echo_mo..." */, FxProc: 0}, + {FzName: ts + 26973 /* "sqlite3_declare_..." */, FxProc: 0}, } /* test8.c:1433:5 */ // end block for C++ @@ -61293,13 +57582,13 @@ func c_collation_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc goto __1 } tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR __1: ; // Open a database. rc = sqlite3.Xsqlite3_open(tls, ts+1661 /* ":memory:" */, bp+24 /* &db */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __2 } zErrFunction = ts + 20572 /* "sqlite3_open" */ @@ -61308,7 +57597,7 @@ __2: ; rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)), ts+12916 /* "collate" */, 456, uintptr(0), uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __3 } sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */))) @@ -61318,12 +57607,12 @@ __3: ; sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */))) - return 0 + return TCL_OK error_out: tcl.XTcl_ResetResult(tls, interp) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+27023 /* "Error testing fu..." */, zErrFunction, 0)) - return 1 + return TCL_ERROR } // c_realloc_test @@ -61339,7 +57628,7 @@ func c_realloc_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc i goto __1 } tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR __1: ; @@ -61363,12 +57652,12 @@ __2: __3: ; - return 0 + return TCL_OK error_out: tcl.XTcl_ResetResult(tls, interp) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+27023 /* "Error testing fu..." */, zErrFunction, 0)) - return 1 + return TCL_ERROR } // c_misuse_test @@ -61389,14 +57678,14 @@ func c_misuse_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc in goto __1 } tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR __1: ; // Open a database. Then close it again. We need to do this so that // we have a "closed database handle" to pass to various API functions. rc = sqlite3.Xsqlite3_open(tls, ts+1661 /* ":memory:" */, bp+24 /* &db */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __2 } zErrFunction = ts + 20572 /* "sqlite3_open" */ @@ -61406,7 +57695,7 @@ __2: sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */))) rc = sqlite3.Xsqlite3_errcode(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */))) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __3 } zErrFunction = ts + 20499 /* "sqlite3_errcode" */ @@ -61416,7 +57705,7 @@ __3: *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) = uintptr(1234) rc = sqlite3.Xsqlite3_prepare(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)), uintptr(0), 0, bp+32 /* &pStmt */, uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __4 } zErrFunction = ts + 20653 /* "sqlite3_prepare" */ @@ -61427,7 +57716,7 @@ __4: *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) = uintptr(1234) rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)), uintptr(0), 0, bp+32 /* &pStmt */, uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __5 } zErrFunction = ts + 20687 /* "sqlite3_prepare_..." */ @@ -61437,7 +57726,7 @@ __5: *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) = uintptr(1234) rc = sqlite3.Xsqlite3_prepare16(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)), uintptr(0), 0, bp+32 /* &pStmt */, uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __6 } zErrFunction = ts + 20669 /* "sqlite3_prepare1..." */ @@ -61447,7 +57736,7 @@ __6: *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) = uintptr(1234) rc = sqlite3.Xsqlite3_prepare16_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)), uintptr(0), 0, bp+32 /* &pStmt */, uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __7 } zErrFunction = ts + 20749 /* "sqlite3_prepare1..." */ @@ -61455,12 +57744,12 @@ __6: __7: ; - return 0 + return TCL_OK error_out: tcl.XTcl_ResetResult(tls, interp) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+27023 /* "Error testing fu..." */, zErrFunction, 0)) - return 1 + return TCL_ERROR } // Register commands with the TCL interpreter. @@ -61474,7 +57763,7 @@ func Sqlitetest9_Init(tls *libc.TLS, interp uintptr) int32 { /* test9.c:188:5: * tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd3[i].FzName, aObjCmd3[i].FxProc, aObjCmd3[i].FclientData, uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd3 = [3]struct { @@ -61482,18 +57771,9 @@ var aObjCmd3 = [3]struct { FxProc uintptr FclientData uintptr }{ - { - FzName: ts + 27079, /* "c_misuse_test" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 27093, /* "c_realloc_test" */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 27108, /* "c_collation_test" */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 27079 /* "c_misuse_test" */, FxProc: 0}, + {FzName: ts + 27093 /* "c_realloc_test" */, FxProc: 0}, + {FzName: ts + 27108 /* "c_collation_test" */, FxProc: 0}, } /* test9.c:193:5 */ // end block for C++ @@ -61508,7 +57788,7 @@ var aObjCmd3 = [3]struct { // module. This should be the only procedure visible from outside // of this module. func Sqlitetestasync_Init(tls *libc.TLS, interp uintptr) int32 { /* test_async.c:238:5: */ - return 0 + return TCL_OK } // The following macros redefine the API routines so that they are @@ -61529,7 +57809,7 @@ func Sqlitetestasync_Init(tls *libc.TLS, interp uintptr) int32 { /* test_async.c // Reset all auto-extensions func resetAutoExtObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_autoext.c:196:26: */ sqlite3.Xsqlite3_reset_auto_extension(tls) - return 0 + return SQLITE_OK } // This procedure registers the TCL procs defined in this file. @@ -61538,7 +57818,7 @@ func Sqlitetest_autoext_Init(tls *libc.TLS, interp uintptr) int32 { /* test_auto *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 }{resetAutoExtObjCmd})), uintptr(0), uintptr(0)) - return 0 + return TCL_OK } func backupTestCmd(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_backup.c:33:26: */ @@ -61546,26 +57826,10 @@ func backupTestCmd(tls *libc.TLS, clientData ClientData, interp uintptr, objc in defer tls.Free(196) *(*[5]BackupSubCommand)(unsafe.Pointer(bp /* aSub */)) = [5]BackupSubCommand{ - { - FzCmd: ts + 9942, /* "step" */ - FeCmd: uint32(0), /* BACKUP_STEP */ - FnArg: 1, - FzArg: ts + 27154 /* "npage" */}, - { - FzCmd: ts + 27160, /* "finish" */ - FeCmd: uint32(1), /* BACKUP_FINISH */ - FnArg: 0, - FzArg: ts + 488 /* "" */}, - { - FzCmd: ts + 27167, /* "remaining" */ - FeCmd: uint32(2), /* BACKUP_REMAINING */ - FnArg: 0, - FzArg: ts + 488 /* "" */}, - { - FzCmd: ts + 27177, /* "pagecount" */ - FeCmd: uint32(3), /* BACKUP_PAGECOUNT */ - FnArg: 0, - FzArg: ts + 488 /* "" */}, + {FzCmd: ts + 9942 /* "step" */, FnArg: 1, FzArg: ts + 27154 /* "npage" */}, + {FzCmd: ts + 27160 /* "finish" */, FeCmd: uint32(1) /* BACKUP_FINISH */, FzArg: ts + 488 /* "" */}, + {FzCmd: ts + 27167 /* "remaining" */, FeCmd: uint32(2) /* BACKUP_REMAINING */, FzArg: ts + 488 /* "" */}, + {FzCmd: ts + 27177 /* "pagecount" */, FeCmd: uint32(3) /* BACKUP_PAGECOUNT */, FzArg: ts + 488 /* "" */}, {}, } @@ -61575,13 +57839,13 @@ func backupTestCmd(tls *libc.TLS, clientData ClientData, interp uintptr, objc in var rc int32 rc = tcl.XTcl_GetIndexFromObjStruct(tls, - interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &aSub[0] */, int32(unsafe.Sizeof(BackupSubCommand{})), ts+11195 /* "option" */, 0, bp+120 /* &iCmd */) - if rc != 0 { + interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &aSub[0] */, int32(unsafe.Sizeof(BackupSubCommand{})), ts+11195 /* "option" */, 0, bp+120 /* &iCmd */) + if rc != TCL_OK { return rc } if objc != (2 + (*BackupSubCommand)(unsafe.Pointer(bp /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 120 /* iCmd */)))*24)).FnArg) { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, (*BackupSubCommand)(unsafe.Pointer(bp /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 120 /* iCmd */)))*24)).FzArg) - return 1 + return TCL_ERROR } switch (*BackupSubCommand)(unsafe.Pointer(bp /* &aSub */ + uintptr(*(*int32)(unsafe.Pointer(bp + 120 /* iCmd */)))*24)).FeCmd { @@ -61591,7 +57855,7 @@ func backupTestCmd(tls *libc.TLS, clientData ClientData, interp uintptr, objc in var zCmdName uintptr // var cmdInfo Tcl_CmdInfo at bp+128, 64 - zCmdName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))) + zCmdName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))) tcl.XTcl_GetCommandInfo(tls, interp, zCmdName, bp+128 /* &cmdInfo */) (*Tcl_CmdInfo)(unsafe.Pointer(bp + 128 /* &cmdInfo */)).FdeleteProc = uintptr(0) tcl.XTcl_SetCommandInfo(tls, interp, zCmdName, bp+128 /* &cmdInfo */) @@ -61607,8 +57871,8 @@ func backupTestCmd(tls *libc.TLS, clientData ClientData, interp uintptr, objc in { // var nPage int32 at bp+192, 4 - if 0 != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+192 /* &nPage */) { - return 1 + if TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+192 /* &nPage */) { + return TCL_ERROR } rc = sqlite3.Xsqlite3_backup_step(tls, p, *(*int32)(unsafe.Pointer(bp + 192 /* nPage */))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) @@ -61625,7 +57889,7 @@ func backupTestCmd(tls *libc.TLS, clientData ClientData, interp uintptr, objc in break } - return 0 + return TCL_OK } type BackupSubCommand = struct { @@ -61658,33 +57922,33 @@ func backupTestInit(tls *libc.TLS, clientData ClientData, interp uintptr, objc i if objc != 6 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27187 /* "CMDNAME DESTHAND..." */) - return 1 + return TCL_ERROR } - zCmd = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), bp+16 /* &pDestDb */) - zDestName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) - getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8))), bp+24 /* &pSrcDb */) - zSrcName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(5)*8))) + zCmd = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+16 /* &pDestDb */) + zDestName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) + getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))), bp+24 /* &pSrcDb */) + zSrcName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 5*8))) pBackup = sqlite3.Xsqlite3_backup_init(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pDestDb */)), zDestName, *(*uintptr)(unsafe.Pointer(bp + 24 /* pSrcDb */)), zSrcName) if !(pBackup != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+27233 /* "sqlite3_backup_i..." */, 0)) - return 1 + return TCL_ERROR } tcl.XTcl_CreateObjCommand(tls, interp, zCmd, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 }{backupTestCmd})), pBackup, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, ClientData) }{backupTestFinish}))) - tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - return 0 + tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + return TCL_OK } func Sqlitetestbackup_Init(tls *libc.TLS, interp uintptr) int32 { /* test_backup.c:154:5: */ tcl.XTcl_CreateObjCommand(tls, interp, ts+27262 /* "sqlite3_backup" */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 }{backupTestInit})), uintptr(0), uintptr(0)) - return 0 + return TCL_OK } // end block for C++ @@ -61720,7 +57984,7 @@ type tcl_cursor = tcl_cursor1 /* test_bestindex.c:105:27 */ // Dequote string z in place. func tclDequote(tls *libc.TLS, z uintptr) { /* test_bestindex.c:126:13: */ - var q int8 = *(*int8)(unsafe.Pointer(z + uintptr(0))) + var q int8 = *(*int8)(unsafe.Pointer(z)) // Set stack variable q to the close-quote character if (((int32(q) == '[') || (int32(q) == '\'')) || (int32(q) == '"')) || (int32(q) == '`') { @@ -61769,17 +58033,17 @@ func tclConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintpt var pTab uintptr = uintptr(0) var zCmd uintptr = uintptr(0) var pScript uintptr = uintptr(0) - var rc int32 = 0 + var rc int32 = SQLITE_OK if argc != 4 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+27277 /* "wrong number of ..." */, 0) - return 1 + return SQLITE_ERROR } - zCmd = sqlite3.Xsqlite3_malloc64(tls, (uint64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) + uint64(1)))) + zCmd = sqlite3.Xsqlite3_malloc64(tls, (uint64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) + uint64(1)))) pTab = sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(tcl_vtab{}))) if (zCmd != 0) && (pTab != 0) { - libc.Xmemcpy(tls, zCmd, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)), (libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) + uint64(1))) + libc.Xmemcpy(tls, zCmd, *(*uintptr)(unsafe.Pointer(argv + 3*8)), (libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) + uint64(1))) tclDequote(tls, zCmd) libc.Xmemset(tls, pTab, 0, uint64(unsafe.Sizeof(tcl_vtab{}))) @@ -61792,20 +58056,20 @@ func tclConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintpt (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ tcl.XTcl_ListObjAppendElement(tls, interp, pScript, tcl.XTcl_NewStringObj(tls, ts+26355 /* "xConnect" */, -1)) - rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, 0x020000) - if rc != 0 { + rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, TCL_EVAL_GLOBAL) + if rc != TCL_OK { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, tcl.XTcl_GetStringResult(tls, interp))) - rc = 1 + rc = SQLITE_ERROR } else { rc = sqlite3.Xsqlite3_declare_vtab(tls, db, tcl.XTcl_GetStringResult(tls, interp)) } - if rc != 0 { + if rc != SQLITE_OK { sqlite3.Xsqlite3_free(tls, pTab) pTab = uintptr(0) } } else { - rc = 7 + rc = SQLITE_NOMEM } sqlite3.Xsqlite3_free(tls, zCmd) @@ -61823,7 +58087,7 @@ func tclDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* test_bestindex.c:224 } } sqlite3.Xsqlite3_free(tls, pTab) - return 0 + return SQLITE_OK } // Open a new tcl cursor. @@ -61831,11 +58095,11 @@ func tclOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_bes var pCur uintptr pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(tcl_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(tcl_cursor{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Close a tcl cursor. @@ -61845,7 +58109,7 @@ func tclClose(tls *libc.TLS, cur uintptr) int32 { /* test_bestindex.c:246:12: */ sqlite3.Xsqlite3_finalize(tls, (*tcl_cursor)(unsafe.Pointer(pCur)).FpStmt) sqlite3.Xsqlite3_free(tls, pCur) } - return 0 + return SQLITE_OK } func tclNext(tls *libc.TLS, pVtabCursor uintptr) int32 { /* test_bestindex.c:255:12: */ @@ -61856,17 +58120,17 @@ func tclNext(tls *libc.TLS, pVtabCursor uintptr) int32 { /* test_bestindex.c:255 if (*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt != 0 { var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab var rc int32 = sqlite3.Xsqlite3_step(tls, (*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt) - if rc != 100 { + if rc != SQLITE_ROW { var zErr uintptr rc = sqlite3.Xsqlite3_finalize(tls, (*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt) (*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt = uintptr(0) - if rc != 0 { + if rc != SQLITE_OK { zErr = sqlite3.Xsqlite3_errmsg(tls, (*tcl_vtab)(unsafe.Pointer(pTab)).Fdb) (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zErr)) } } } - return 0 + return SQLITE_OK } func tclFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* test_bestindex.c:273:12: */ @@ -61911,10 +58175,10 @@ func tclFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, } } - rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, 0x020000) - if rc != 0 { + rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, TCL_EVAL_GLOBAL) + if rc != TCL_OK { var zErr uintptr = tcl.XTcl_GetStringResult(tls, interp) - rc = 1 + rc = SQLITE_ERROR (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zErr)) } else { // Analyze the scripts return value. The return value should be a tcl @@ -61927,30 +58191,30 @@ func tclFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, // var nElem int32 at bp+32, 4 rc = tcl.XTcl_ListObjGetElements(tls, interp, pRes, bp+32 /* &nElem */, bp+40 /* &apElem */) - if rc != 0 { + if rc != TCL_OK { var zErr uintptr = tcl.XTcl_GetStringResult(tls, interp) - rc = 1 + rc = SQLITE_ERROR (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, zErr)) } else { - for ii = 0; (rc == 0) && (ii < *(*int32)(unsafe.Pointer(bp + 32 /* nElem */))); ii = ii + (2) { + for ii = 0; (rc == SQLITE_OK) && (ii < *(*int32)(unsafe.Pointer(bp + 32 /* nElem */))); ii = ii + (2) { var zCmd uintptr = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 40 /* apElem */)) + uintptr(ii)*8))) var p uintptr = *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 40 /* apElem */)) + uintptr((ii+1))*8)) if sqlite3.Xsqlite3_stricmp(tls, ts+1807 /* "sql" */, zCmd) == 0 { var zSql uintptr = tcl.XTcl_GetString(tls, p) rc = sqlite3.Xsqlite3_prepare_v2(tls, (*tcl_vtab)(unsafe.Pointer(pTab)).Fdb, zSql, -1, (pCsr + 8 /* &.pStmt */), uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { var zErr uintptr = sqlite3.Xsqlite3_errmsg(tls, (*tcl_vtab)(unsafe.Pointer(pTab)).Fdb) (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+27303 /* "unexpected: %s" */, libc.VaList(bp+16, zErr)) } } else { - rc = 1 + rc = SQLITE_ERROR (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+27303 /* "unexpected: %s" */, libc.VaList(bp+24, zCmd)) } } } } - if rc == 0 { + if rc == SQLITE_OK { rc = tclNext(tls, pVtabCursor) } return rc @@ -61959,13 +58223,13 @@ func tclFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, func tclColumn(tls *libc.TLS, pVtabCursor uintptr, ctx uintptr, i int32) int32 { /* test_bestindex.c:356:12: */ var pCsr uintptr = pVtabCursor sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt, (i+1))) - return 0 + return SQLITE_OK } func tclRowid(tls *libc.TLS, pVtabCursor uintptr, pRowid uintptr) int32 { /* test_bestindex.c:366:12: */ var pCsr uintptr = pVtabCursor *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_column_int64(tls, (*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt, 0) - return 0 + return SQLITE_OK } func tclEof(tls *libc.TLS, pVtabCursor uintptr) int32 { /* test_bestindex.c:372:12: */ @@ -61982,7 +58246,7 @@ func tclBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_ var pArg uintptr var pScript uintptr var ii int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK pScript = tcl.XTcl_DuplicateObj(tls, (*tcl_vtab)(unsafe.Pointer(pTab)).FpCmd) (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ @@ -61998,46 +58262,46 @@ func tclBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_ (*Tcl_Obj)(unsafe.Pointer(pElem)).FrefCount++ switch int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) { - case 2: + case SQLITE_INDEX_CONSTRAINT_EQ: zOp = ts + 27318 /* "eq" */ break - case 4: + case SQLITE_INDEX_CONSTRAINT_GT: zOp = ts + 27321 /* "gt" */ break - case 8: + case SQLITE_INDEX_CONSTRAINT_LE: zOp = ts + 27324 /* "le" */ break - case 16: + case SQLITE_INDEX_CONSTRAINT_LT: zOp = ts + 27327 /* "lt" */ break - case 32: + case SQLITE_INDEX_CONSTRAINT_GE: zOp = ts + 27330 /* "ge" */ break - case 64: + case SQLITE_INDEX_CONSTRAINT_MATCH: zOp = ts + 27333 /* "match" */ break - case 65: + case SQLITE_INDEX_CONSTRAINT_LIKE: zOp = ts + 26571 /* "like" */ break - case 66: + case SQLITE_INDEX_CONSTRAINT_GLOB: zOp = ts + 26576 /* "glob" */ break - case 67: + case SQLITE_INDEX_CONSTRAINT_REGEXP: zOp = ts + 6165 /* "regexp" */ break - case 68: + case SQLITE_INDEX_CONSTRAINT_NE: zOp = ts + 27339 /* "ne" */ break - case 69: + case SQLITE_INDEX_CONSTRAINT_ISNOT: zOp = ts + 27342 /* "isnot" */ break - case 70: + case SQLITE_INDEX_CONSTRAINT_ISNOTNULL: zOp = ts + 27348 /* "isnotnull" */ break - case 71: + case SQLITE_INDEX_CONSTRAINT_ISNULL: zOp = ts + 27358 /* "isnull" */ break - case 72: + case SQLITE_INDEX_CONSTRAINT_IS: zOp = ts + 5542 /* "is" */ break } @@ -62097,16 +58361,16 @@ func tclBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_ tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pScript, tcl.XTcl_NewWideIntObj(tls, int64((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FcolUsed))) - rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, 0x020000) + rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, TCL_EVAL_GLOBAL) for ok4 := true; ok4; ok4 = 0 != 0 { var _objPtr uintptr = pScript if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { tcl.XTclFreeObj(tls, _objPtr) } } - if rc != 0 { + if rc != TCL_OK { var zErr uintptr = tcl.XTcl_GetStringResult(tls, interp) - rc = 1 + rc = SQLITE_ERROR (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zErr)) } else { // Analyze the scripts return value. The return value should be a tcl @@ -62125,13 +58389,13 @@ func tclBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_ // var nElem int32 at bp+48, 4 rc = tcl.XTcl_ListObjGetElements(tls, interp, pRes, bp+48 /* &nElem */, bp+56 /* &apElem */) - if rc != 0 { + if rc != TCL_OK { var zErr uintptr = tcl.XTcl_GetStringResult(tls, interp) - rc = 1 + rc = SQLITE_ERROR (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, zErr)) } else { var iArgv int32 = 1 - for ii = 0; (rc == 0) && (ii < *(*int32)(unsafe.Pointer(bp + 48 /* nElem */))); ii = ii + (2) { + for ii = 0; (rc == SQLITE_OK) && (ii < *(*int32)(unsafe.Pointer(bp + 48 /* nElem */))); ii = ii + (2) { var zCmd uintptr = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 56 /* apElem */)) + uintptr(ii)*8))) var p uintptr = *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 56 /* apElem */)) + uintptr((ii+1))*8)) if sqlite3.Xsqlite3_stricmp(tls, ts+27387 /* "cost" */, zCmd) == 0 { @@ -62153,21 +58417,21 @@ func tclBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_ // var iCons int32 at bp+72, 4 rc = tcl.XTcl_GetIntFromObj(tls, interp, p, bp+72 /* &iCons */) - if rc == 0 { + if rc == SQLITE_OK { if (*(*int32)(unsafe.Pointer(bp + 72 /* iCons */)) < 0) || (*(*int32)(unsafe.Pointer(bp + 72 /* iCons */)) >= (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { - rc = 1 + rc = SQLITE_ERROR (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+27428 /* "unexpected: %d" */, libc.VaList(bp+24, *(*int32)(unsafe.Pointer(bp + 72 /* iCons */)))) } else { - var bOmit int32 = (libc.Bool32((int32(*(*int8)(unsafe.Pointer(zCmd + uintptr(0)))) == 'o') || (int32(*(*int8)(unsafe.Pointer(zCmd + uintptr(0)))) == 'O'))) + var bOmit int32 = (libc.Bool32((int32(*(*int8)(unsafe.Pointer(zCmd))) == 'o') || (int32(*(*int8)(unsafe.Pointer(zCmd))) == 'O'))) (*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) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(*(*int32)(unsafe.Pointer(bp + 72 /* iCons */)))*8)).Fomit = uint8(bOmit) } } } else { - rc = 1 + rc = SQLITE_ERROR (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+27303 /* "unexpected: %s" */, libc.VaList(bp+32, zCmd)) } - if (rc != 0) && ((*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg == uintptr(0)) { + if (rc != SQLITE_OK) && ((*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg == uintptr(0)) { var zErr uintptr = tcl.XTcl_GetStringResult(tls, interp) (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+40, zErr)) } @@ -62180,41 +58444,19 @@ func tclBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_ // A virtual table module that provides read-only access to a // Tcl global variable namespace. -var tclModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, +var tclModule = sqlite3_module{ // iVersion + FxCreate: 0, FxConnect: 0, FxBestIndex: 0, FxDisconnect: 0, FxDestroy: 0, - FxOpen: 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRename } /* test_bestindex.c:549:23 */ // Register the echo virtual table module. @@ -62226,13 +58468,13 @@ func register_tcl_module(tls *libc.TLS, clientData ClientData, interp uintptr, o if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+27443 /* "tcl" */, uintptr(unsafe.Pointer(&tclModule)), interp) - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -62246,7 +58488,7 @@ func Sqlitetesttcl_Init(tls *libc.TLS, interp uintptr) int32 { /* test_bestindex tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd4[i].FzName, aObjCmd4[i].FxProc, aObjCmd4[i].FclientData, uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd4 = [1]struct { @@ -62254,10 +58496,7 @@ var aObjCmd4 = [1]struct { FxProc uintptr FclientData uintptr }{ - { - FzName: ts + 27447, /* "register_tcl_mod..." */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 27447 /* "register_tcl_mod..." */, FxProc: 0}, } /* test_bestindex.c:610:5 */ // Return a pointer to a buffer containing a text representation of the @@ -62301,11 +58540,11 @@ func blobHandleFromObj1(tls *libc.TLS, interp uintptr, pObj uintptr, ppBlob uint channel = tcl.XTcl_GetChannel(tls, interp, z, bp+4 /* ¬Used */) if !(channel != 0) { - return 1 + return TCL_ERROR } tcl.XTcl_Flush(tls, channel) - tcl.XTcl_Seek(tls, channel, int64(0), 0) + tcl.XTcl_Seek(tls, channel, int64(0), SEEK_SET) instanceData = tcl.XTcl_GetChannelInstanceData(tls, channel) *(*uintptr)(unsafe.Pointer(ppBlob)) = *(*uintptr)(unsafe.Pointer(instanceData)) @@ -62313,7 +58552,7 @@ func blobHandleFromObj1(tls *libc.TLS, interp uintptr, pObj uintptr, ppBlob uint *(*uintptr)(unsafe.Pointer(ppBlob)) = sqlite3TestTextToPtr(tls, z) } - return 0 + return TCL_OK } // Like Tcl_GetString(), except that if the string is 0 bytes in size, a @@ -62359,21 +58598,21 @@ func test_blob_open(tls *libc.TLS, clientData ClientData, interp uintptr, objc i if objc != 8 { var zUsage uintptr = ts + 27477 /* "DB DATABASE TABL..." */ tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, zUsage) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+8 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+8 /* &db */) != 0 { + return TCL_ERROR } - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - zTable = blobStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) - zColumn = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8))) - if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(5)*8)), bp+16 /* &iRowid */) != 0 { - return 1 + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + zTable = blobStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) + zColumn = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) + if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+16 /* &iRowid */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(6)*8)), bp /* &flags */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 6*8)), bp /* &flags */) != 0 { + return TCL_ERROR } - zVarname = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(7)*8)), bp+24 /* &nVarname */) + zVarname = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 7*8)), bp+24 /* &nVarname */) if *(*int32)(unsafe.Pointer(bp + 24 /* nVarname */)) > 0 { 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 */) @@ -62382,13 +58621,13 @@ func test_blob_open(tls *libc.TLS, clientData ClientData, interp uintptr, objc i 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)) } - if rc == 0 { + if rc == SQLITE_OK { tcl.XTcl_ResetResult(tls, interp) } else { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // sqlite3_blob_close HANDLE @@ -62402,11 +58641,11 @@ func test_blob_close(tls *libc.TLS, clientData ClientData, interp uintptr, objc if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27522 /* "HANDLE" */) - return 1 + return TCL_ERROR } - if blobHandleFromObj1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &pBlob */) != 0 { - return 1 + if blobHandleFromObj1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &pBlob */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_blob_close(tls, *(*uintptr)(unsafe.Pointer(bp /* pBlob */))) @@ -62415,7 +58654,7 @@ func test_blob_close(tls *libc.TLS, clientData ClientData, interp uintptr, objc } else { tcl.XTcl_ResetResult(tls, interp) } - return 0 + return TCL_OK } // sqlite3_blob_bytes HANDLE @@ -62429,16 +58668,16 @@ func test_blob_bytes(tls *libc.TLS, clientData ClientData, interp uintptr, objc if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27522 /* "HANDLE" */) - return 1 + return TCL_ERROR } - if blobHandleFromObj1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &pBlob */) != 0 { - return 1 + if blobHandleFromObj1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &pBlob */) != 0 { + return TCL_ERROR } nByte = sqlite3.Xsqlite3_blob_bytes(tls, *(*uintptr)(unsafe.Pointer(bp /* pBlob */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nByte)) - return 0 + return TCL_OK } // sqlite3_blob_read CHANNEL OFFSET N @@ -62469,26 +58708,26 @@ func test_blob_read(tls *libc.TLS, clientData ClientData, interp uintptr, objc i if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27529 /* "CHANNEL OFFSET N" */) - return 1 + return TCL_ERROR } - if blobHandleFromObj1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+16 /* &pBlob */) != 0 { - return 1 + if blobHandleFromObj1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &pBlob */) != 0 { + return TCL_ERROR } - if (0 != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+24 /* &iOffset */)) || - (0 != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+28 /* &nByte */)) { - return 1 + if (TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+24 /* &iOffset */)) || + (TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+28 /* &nByte */)) { + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 28 /* nByte */)) > 0 { zBuf = tcl.XTcl_AttemptAlloc(tls, uint32(*(*int32)(unsafe.Pointer(bp + 28 /* nByte */)))) if zBuf == uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+27546 /* "out of memory in..." */, 0)) - return 1 + return TCL_ERROR } } 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 */))) - if rc == 0 { + if rc == SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, zBuf, *(*int32)(unsafe.Pointer(bp + 28 /* nByte */)))) } else { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) @@ -62496,10 +58735,10 @@ func test_blob_read(tls *libc.TLS, clientData ClientData, interp uintptr, objc i tcl.XTcl_Free(tls, zBuf) return func() int32 { - if rc == 0 { - return 0 + if rc == SQLITE_OK { + return TCL_OK } - return 1 + return TCL_ERROR }() } @@ -62529,30 +58768,30 @@ func test_blob_write(tls *libc.TLS, clientData ClientData, interp uintptr, objc if (objc != 4) && (objc != 5) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27607 /* "HANDLE OFFSET DA..." */) - return 1 + return TCL_ERROR } - if blobHandleFromObj1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &pBlob */) != 0 { - return 1 + if blobHandleFromObj1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &pBlob */) != 0 { + return TCL_ERROR } - if 0 != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+8 /* &iOffset */) { - return 1 + if TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &iOffset */) { + return TCL_ERROR } - zBuf = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+12 /* &nBuf */) - if (objc == 5) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+12 /* &nBuf */) != 0) { - return 1 + zBuf = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+12 /* &nBuf */) + if (objc == 5) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+12 /* &nBuf */) != 0) { + return TCL_ERROR } rc = sqlite3.Xsqlite3_blob_write(tls, *(*uintptr)(unsafe.Pointer(bp /* pBlob */)), zBuf, *(*int32)(unsafe.Pointer(bp + 12 /* nBuf */)), *(*int32)(unsafe.Pointer(bp + 8 /* iOffset */))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) } return func() int32 { - if rc == 0 { - return 0 + if rc == SQLITE_OK { + return TCL_OK } - return 1 + return TCL_ERROR }() } @@ -62565,28 +58804,18 @@ func Sqlitetest_blob_Init(tls *libc.TLS, interp uintptr) int32 { /* test_blob.c: }{}))); i++ { tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd5[i].FzName, aObjCmd5[i].FxProc, uintptr(0), uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd5 = [5]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 27634, /* "sqlite3_blob_ope..." */ - FxProc: 0}, - { - FzName: ts + 27652, /* "sqlite3_blob_clo..." */ - FxProc: 0}, - { - FzName: ts + 27671, /* "sqlite3_blob_byt..." */ - FxProc: 0}, - { - FzName: ts + 27690, /* "sqlite3_blob_rea..." */ - FxProc: 0}, - { - FzName: ts + 27708, /* "sqlite3_blob_wri..." */ - FxProc: 0}, + {FzName: ts + 27634 /* "sqlite3_blob_ope..." */, FxProc: 0}, + {FzName: ts + 27652 /* "sqlite3_blob_clo..." */, FxProc: 0}, + {FzName: ts + 27671 /* "sqlite3_blob_byt..." */, FxProc: 0}, + {FzName: ts + 27690 /* "sqlite3_blob_rea..." */, FxProc: 0}, + {FzName: ts + 27708 /* "sqlite3_blob_wri..." */, FxProc: 0}, } /* test_blob.c:317:5 */ // end block for C++ @@ -62610,7 +58839,7 @@ func sqlite3BtreeSharedCacheReport(tls *libc.TLS, clientData uintptr, interp uin tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, (*BtShared)(unsafe.Pointer(pBt)).FnRef)) } tcl.XTcl_SetObjResult(tls, interp, pRet) - return 0 + return TCL_OK } // Print debugging information about all cursors to standard output. @@ -62670,156 +58899,156 @@ func sqlite3BtreeCursorList(tls *libc.TLS, p uintptr) { /* test_btree.c:52:6: */ // procedures use this to determine when tests should be omitted. func set_options(tls *libc.TLS, interp uintptr) { /* test_config.c:47:13: */ tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27742 /* "malloc_usable_si..." */, ts+27761, /* "1" */ - 1) + TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27763 /* "rowid32" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27763 /* "rowid32" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27771 /* "casesensitivelik..." */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27771 /* "casesensitivelik..." */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27789 /* "curdir" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27789 /* "curdir" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27796 /* "win32malloc" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27796 /* "win32malloc" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27808 /* "debug" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27808 /* "debug" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27814 /* "default_ckptfull..." */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27814 /* "default_ckptfull..." */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27836 /* "direct_read" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27836 /* "direct_read" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27848 /* "dirsync" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27848 /* "dirsync" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27856 /* "lfs" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27856 /* "lfs" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27860 /* "pagecache_overfl..." */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27860 /* "pagecache_overfl..." */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27885 /* "mmap" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27885 /* "mmap" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27890, /* "worker_threads" */ - ts+27905 /* "8" */, 1) + ts+27905 /* "8" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27907 /* "memdebug" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27907 /* "memdebug" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27916 /* "8_3_names" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27916 /* "8_3_names" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27926 /* "cursorhints" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27926 /* "cursorhints" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27938 /* "hiddencolumns" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27938 /* "hiddencolumns" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+12974 /* "deserialize" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+12974 /* "deserialize" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27952 /* "mem3" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27952 /* "mem3" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27957 /* "mem5" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27957 /* "mem5" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27962 /* "offset_sql_func" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27962 /* "offset_sql_func" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+13082 /* "preupdate" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+13082 /* "preupdate" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27978 /* "snapshot" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27978 /* "snapshot" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27987 /* "mutex" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27987 /* "mutex" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27993 /* "mutex_noop" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+27993 /* "mutex_noop" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28004 /* "altertable" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28004 /* "altertable" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+1817 /* "analyze" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+1817 /* "analyze" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28015 /* "api_armor" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28015 /* "api_armor" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28025 /* "atomicwrite" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28025 /* "atomicwrite" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28037 /* "json1" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28037 /* "json1" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28043 /* "has_codec" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28043 /* "has_codec" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28053 /* "like_match_blobs" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28053 /* "like_match_blobs" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28070 /* "attach" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28070 /* "attach" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28077 /* "auth" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28077 /* "auth" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28082 /* "autoinc" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28082 /* "autoinc" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+12555 /* "autoindex" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+12555 /* "autoindex" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28090 /* "autoreset" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28090 /* "autoreset" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28100 /* "autovacuum" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28100 /* "autovacuum" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28111, /* "default_autovacu..." */ - ts+13695 /* "0" */, 1) + ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28130 /* "between_opt" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28130 /* "between_opt" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28142 /* "builtin_test" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28142 /* "builtin_test" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28155 /* "bloblit" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28155 /* "bloblit" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28163 /* "cast" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28163 /* "cast" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28168 /* "check" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28168 /* "check" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28174 /* "cte" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28174 /* "cte" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28178 /* "columnmetadata" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28178 /* "columnmetadata" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28193 /* "oversize_cell_ch..." */, ts+13695, /* "0" */ - 1) + TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28213 /* "compileoption_di..." */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28213 /* "compileoption_di..." */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+12953 /* "complete" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+12953 /* "complete" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28233 /* "compound" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28233 /* "compound" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28242 /* "conflict" */, ts+27761 /* "1" */, 1) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28251 /* "crashtest" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28242 /* "conflict" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28251 /* "crashtest" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28261 /* "datetime" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28261 /* "datetime" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28270 /* "decltype" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28270 /* "decltype" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28279 /* "deprecated" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28279 /* "deprecated" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28290 /* "diskio" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28290 /* "diskio" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+4665 /* "explain" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+4665 /* "explain" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28297 /* "floatingpoint" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28297 /* "floatingpoint" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28311 /* "foreignkey" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28311 /* "foreignkey" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28322 /* "fts1" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28322 /* "fts1" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28327 /* "fts2" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28327 /* "fts2" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28332 /* "fts3" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28332 /* "fts3" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28337 /* "fts5" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28337 /* "fts5" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28342 /* "fts3_unicode" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28342 /* "fts3_unicode" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28355 /* "fts4_deferred" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28355 /* "fts4_deferred" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28369 /* "gettable" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28369 /* "gettable" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28378 /* "icu" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28378 /* "icu" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28382 /* "icu_collations" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28382 /* "icu_collations" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+10346 /* "incrblob" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+10346 /* "incrblob" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28397 /* "integrityck" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28397 /* "integrityck" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28409 /* "legacyformat" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28409 /* "legacyformat" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28422 /* "like_opt" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28422 /* "like_opt" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28431 /* "load_ext" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28431 /* "load_ext" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28440 /* "localtime" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28440 /* "localtime" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28450 /* "lookaside" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28450 /* "lookaside" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28460, /* "long_double" */ func() uintptr { @@ -62828,51 +59057,51 @@ func set_options(tls *libc.TLS, interp uintptr) { /* test_config.c:47:13: */ } return ts + 13695 /* "0" */ }(), - 1) + TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28472 /* "memorydb" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28472 /* "memorydb" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28481 /* "memorymanage" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28481 /* "memorymanage" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28494 /* "mergesort" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28494 /* "mergesort" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28504 /* "null_trim" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28504 /* "null_trim" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28514 /* "or_opt" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28514 /* "or_opt" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28521 /* "rbu" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28521 /* "rbu" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28525 /* "pager_pragmas" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28525 /* "pager_pragmas" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28539 /* "pragma" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28539 /* "pragma" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+10021 /* "progress" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+10021 /* "progress" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28546 /* "reindex" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28546 /* "reindex" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28554 /* "rtree" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28554 /* "rtree" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28560 /* "rtree_int_only" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28560 /* "rtree_int_only" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28575 /* "schema_pragmas" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28575 /* "schema_pragmas" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28590 /* "schema_version" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28590 /* "schema_version" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28605 /* "session" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28605 /* "session" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+18111 /* "stat4" */, ts+27761 /* "1" */, 1) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28613 /* "stmtvtab" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+18111 /* "stat4" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28613 /* "stmtvtab" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28622 /* "scanstatus" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28622 /* "scanstatus" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28633 /* "lock_proxy_pragm..." */, ts+13695 /* "0" */, 1) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28652 /* "prefer_proxy_loc..." */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28633 /* "lock_proxy_pragm..." */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28652 /* "prefer_proxy_loc..." */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28673 /* "shared_cache" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28673 /* "shared_cache" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28686 /* "subquery" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28686 /* "subquery" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28695 /* "tclvar" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28695 /* "tclvar" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28702, /* "threadsafe" */ func() uintptr { @@ -62880,184 +59109,184 @@ func set_options(tls *libc.TLS, interp uintptr) { /* test_config.c:47:13: */ return ts + 27761 /* "1" */ } return ts + 13695 /* "0" */ - }(), 1) + }(), TCL_GLOBAL_ONLY) tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28713, /* "threadsafe1" */ func() uintptr { - if 1 == 1 { + if SQLITE_THREADSAFE == 1 { return ts + 27761 /* "1" */ } return ts + 13695 /* "0" */ - }(), 1) + }(), TCL_GLOBAL_ONLY) tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28725, /* "threadsafe2" */ func() uintptr { - if 1 == 2 { + if SQLITE_THREADSAFE == 2 { return ts + 27761 /* "1" */ } return ts + 13695 /* "0" */ - }(), 1) + }(), TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28737 /* "tempdb" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28737 /* "tempdb" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+13167 /* "trace" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+13167 /* "trace" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28744 /* "trigger" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28744 /* "trigger" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28752 /* "truncate_opt" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28752 /* "truncate_opt" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+15230 /* "utf16" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+15230 /* "utf16" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28765 /* "vacuum" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28765 /* "vacuum" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28772 /* "view" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28772 /* "view" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28777 /* "vtab" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28777 /* "vtab" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28782 /* "wal" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28782 /* "wal" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28786 /* "wsd" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28786 /* "wsd" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28790 /* "update_delete_li..." */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28790 /* "update_delete_li..." */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+13194 /* "unlock_notify" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+13194 /* "unlock_notify" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28810 /* "fast_secure_dele..." */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28810 /* "fast_secure_dele..." */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28829 /* "secure_delete" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28829 /* "secure_delete" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28843 /* "userauth" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28843 /* "userauth" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28852 /* "multiplex_ext_ov..." */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28852 /* "multiplex_ext_ov..." */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28876 /* "yytrackmaxstackd..." */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28876 /* "yytrackmaxstackd..." */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28897 /* "sqllog" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28897 /* "sqllog" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28904 /* "uri_00_error" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28904 /* "uri_00_error" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28917 /* "normalize" */, ts+13695 /* "0" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28917 /* "normalize" */, ts+13695 /* "0" */, TCL_GLOBAL_ONLY) - tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28927 /* "windowfunc" */, ts+27761 /* "1" */, 1) + tcl.XTcl_SetVar2(tls, interp, ts+27727 /* "sqlite_options" */, ts+28927 /* "windowfunc" */, ts+27761 /* "1" */, TCL_GLOBAL_ONLY) { - tcl.XTcl_LinkVar(tls, interp, ts+28938 /* "SQLITE_MAX_LENGT..." */, uintptr(unsafe.Pointer(&cv_MAX_LENGTH)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+28938 /* "SQLITE_MAX_LENGT..." */, uintptr(unsafe.Pointer(&cv_MAX_LENGTH)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+28956 /* "SQLITE_MAX_COLUM..." */, uintptr(unsafe.Pointer(&cv_MAX_COLUMN)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+28956 /* "SQLITE_MAX_COLUM..." */, uintptr(unsafe.Pointer(&cv_MAX_COLUMN)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+28974 /* "SQLITE_MAX_SQL_L..." */, uintptr(unsafe.Pointer(&cv_MAX_SQL_LENGTH)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+28974 /* "SQLITE_MAX_SQL_L..." */, uintptr(unsafe.Pointer(&cv_MAX_SQL_LENGTH)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+28996 /* "SQLITE_MAX_EXPR_..." */, uintptr(unsafe.Pointer(&cv_MAX_EXPR_DEPTH)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+28996 /* "SQLITE_MAX_EXPR_..." */, uintptr(unsafe.Pointer(&cv_MAX_EXPR_DEPTH)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29018 /* "SQLITE_MAX_COMPO..." */, uintptr(unsafe.Pointer(&cv_MAX_COMPOUND_SELECT)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29018 /* "SQLITE_MAX_COMPO..." */, uintptr(unsafe.Pointer(&cv_MAX_COMPOUND_SELECT)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29045 /* "SQLITE_MAX_VDBE_..." */, uintptr(unsafe.Pointer(&cv_MAX_VDBE_OP)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29045 /* "SQLITE_MAX_VDBE_..." */, uintptr(unsafe.Pointer(&cv_MAX_VDBE_OP)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29064 /* "SQLITE_MAX_FUNCT..." */, uintptr(unsafe.Pointer(&cv_MAX_FUNCTION_ARG)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29064 /* "SQLITE_MAX_FUNCT..." */, uintptr(unsafe.Pointer(&cv_MAX_FUNCTION_ARG)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29088 /* "SQLITE_MAX_VARIA..." */, uintptr(unsafe.Pointer(&cv_MAX_VARIABLE_NUMBER)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29088 /* "SQLITE_MAX_VARIA..." */, uintptr(unsafe.Pointer(&cv_MAX_VARIABLE_NUMBER)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29115 /* "SQLITE_MAX_PAGE_..." */, uintptr(unsafe.Pointer(&cv_MAX_PAGE_SIZE)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29115 /* "SQLITE_MAX_PAGE_..." */, uintptr(unsafe.Pointer(&cv_MAX_PAGE_SIZE)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29136 /* "SQLITE_MAX_PAGE_..." */, uintptr(unsafe.Pointer(&cv_MAX_PAGE_COUNT)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29136 /* "SQLITE_MAX_PAGE_..." */, uintptr(unsafe.Pointer(&cv_MAX_PAGE_COUNT)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29158 /* "SQLITE_MAX_LIKE_..." */, uintptr(unsafe.Pointer(&cv_MAX_LIKE_PATTERN_LENGTH)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29158 /* "SQLITE_MAX_LIKE_..." */, uintptr(unsafe.Pointer(&cv_MAX_LIKE_PATTERN_LENGTH)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29189 /* "SQLITE_MAX_TRIGG..." */, uintptr(unsafe.Pointer(&cv_MAX_TRIGGER_DEPTH)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29189 /* "SQLITE_MAX_TRIGG..." */, uintptr(unsafe.Pointer(&cv_MAX_TRIGGER_DEPTH)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29214 /* "SQLITE_DEFAULT_C..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_CACHE_SIZE)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29214 /* "SQLITE_DEFAULT_C..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_CACHE_SIZE)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29240 /* "SQLITE_DEFAULT_P..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_PAGE_SIZE)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29240 /* "SQLITE_DEFAULT_P..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_PAGE_SIZE)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29265 /* "SQLITE_DEFAULT_F..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_FILE_FORMAT)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29265 /* "SQLITE_DEFAULT_F..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_FILE_FORMAT)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29292 /* "SQLITE_DEFAULT_S..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_SYNCHRONOUS)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29292 /* "SQLITE_DEFAULT_S..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_SYNCHRONOUS)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29319 /* "SQLITE_DEFAULT_W..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_WAL_SYNCHRONOUS)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29319 /* "SQLITE_DEFAULT_W..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_WAL_SYNCHRONOUS)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29350 /* "SQLITE_MAX_ATTAC..." */, uintptr(unsafe.Pointer(&cv_MAX_ATTACHED)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29350 /* "SQLITE_MAX_ATTAC..." */, uintptr(unsafe.Pointer(&cv_MAX_ATTACHED)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29370 /* "SQLITE_MAX_DEFAU..." */, uintptr(unsafe.Pointer(&cv_MAX_DEFAULT_PAGE_SIZE)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29370 /* "SQLITE_MAX_DEFAU..." */, uintptr(unsafe.Pointer(&cv_MAX_DEFAULT_PAGE_SIZE)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { - tcl.XTcl_LinkVar(tls, interp, ts+29399 /* "SQLITE_MAX_WORKE..." */, uintptr(unsafe.Pointer(&cv_MAX_WORKER_THREADS)), (1 | 0x80)) + tcl.XTcl_LinkVar(tls, interp, ts+29399 /* "SQLITE_MAX_WORKE..." */, uintptr(unsafe.Pointer(&cv_MAX_WORKER_THREADS)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { tcl.XTcl_LinkVar(tls, interp, ts+29425 /* "TEMP_STORE" */, uintptr(unsafe.Pointer(&cv_TEMP_STORE)), - (1 | 0x80)) + (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } { tcl.XTcl_LinkVar(tls, interp, ts+29436 /* "__GNUC__" */, uintptr(unsafe.Pointer(&cv___GNUC__)), - (1 | 0x80)) + (TCL_LINK_INT | TCL_LINK_READ_ONLY)) } } -var cv_MAX_LENGTH int32 = 1000000000 /* test_config.c:772:3 */ -var cv_MAX_COLUMN int32 = 2000 /* test_config.c:773:3 */ -var cv_MAX_SQL_LENGTH int32 = 1000000000 /* test_config.c:774:3 */ -var cv_MAX_EXPR_DEPTH int32 = 1000 /* test_config.c:775:3 */ -var cv_MAX_COMPOUND_SELECT int32 = 500 /* test_config.c:776:3 */ -var cv_MAX_VDBE_OP int32 = 250000000 /* test_config.c:777:3 */ -var cv_MAX_FUNCTION_ARG int32 = 127 /* test_config.c:778:3 */ -var cv_MAX_VARIABLE_NUMBER int32 = 32766 /* test_config.c:779:3 */ -var cv_MAX_PAGE_SIZE int32 = 65536 /* test_config.c:780:3 */ -var cv_MAX_PAGE_COUNT int32 = 1073741823 /* test_config.c:781:3 */ -var cv_MAX_LIKE_PATTERN_LENGTH int32 = 50000 /* test_config.c:782:3 */ -var cv_MAX_TRIGGER_DEPTH int32 = 1000 /* test_config.c:783:3 */ -var cv_DEFAULT_CACHE_SIZE int32 = -2000 /* test_config.c:784:3 */ -var cv_DEFAULT_PAGE_SIZE int32 = 1024 /* test_config.c:785:3 */ -var cv_DEFAULT_FILE_FORMAT int32 = 4 /* test_config.c:786:3 */ -var cv_DEFAULT_SYNCHRONOUS int32 = 2 /* test_config.c:787:3 */ -var cv_DEFAULT_WAL_SYNCHRONOUS int32 = 2 /* test_config.c:788:3 */ -var cv_MAX_ATTACHED int32 = 10 /* test_config.c:789:3 */ -var cv_MAX_DEFAULT_PAGE_SIZE int32 = 8192 /* test_config.c:790:3 */ -var cv_MAX_WORKER_THREADS int32 = 8 /* test_config.c:791:3 */ -var cv_TEMP_STORE int32 = 1 /* test_config.c:794:22 */ -var cv___GNUC__ int32 = 1 /* test_config.c:808:22 */ +var cv_MAX_LENGTH int32 = SQLITE_MAX_LENGTH /* test_config.c:772:3 */ +var cv_MAX_COLUMN int32 = SQLITE_MAX_COLUMN /* test_config.c:773:3 */ +var cv_MAX_SQL_LENGTH int32 = SQLITE_MAX_SQL_LENGTH /* test_config.c:774:3 */ +var cv_MAX_EXPR_DEPTH int32 = SQLITE_MAX_EXPR_DEPTH /* test_config.c:775:3 */ +var cv_MAX_COMPOUND_SELECT int32 = SQLITE_MAX_COMPOUND_SELECT /* test_config.c:776:3 */ +var cv_MAX_VDBE_OP int32 = SQLITE_MAX_VDBE_OP /* test_config.c:777:3 */ +var cv_MAX_FUNCTION_ARG int32 = SQLITE_MAX_FUNCTION_ARG /* test_config.c:778:3 */ +var cv_MAX_VARIABLE_NUMBER int32 = SQLITE_MAX_VARIABLE_NUMBER /* test_config.c:779:3 */ +var cv_MAX_PAGE_SIZE int32 = SQLITE_MAX_PAGE_SIZE /* test_config.c:780:3 */ +var cv_MAX_PAGE_COUNT int32 = SQLITE_MAX_PAGE_COUNT /* test_config.c:781:3 */ +var cv_MAX_LIKE_PATTERN_LENGTH int32 = SQLITE_MAX_LIKE_PATTERN_LENGTH /* test_config.c:782:3 */ +var cv_MAX_TRIGGER_DEPTH int32 = SQLITE_MAX_TRIGGER_DEPTH /* test_config.c:783:3 */ +var cv_DEFAULT_CACHE_SIZE int32 = -2000 /* test_config.c:784:3 */ +var cv_DEFAULT_PAGE_SIZE int32 = SQLITE_DEFAULT_PAGE_SIZE /* test_config.c:785:3 */ +var cv_DEFAULT_FILE_FORMAT int32 = SQLITE_DEFAULT_FILE_FORMAT /* test_config.c:786:3 */ +var cv_DEFAULT_SYNCHRONOUS int32 = SQLITE_DEFAULT_SYNCHRONOUS /* test_config.c:787:3 */ +var cv_DEFAULT_WAL_SYNCHRONOUS int32 = SQLITE_DEFAULT_SYNCHRONOUS /* test_config.c:788:3 */ +var cv_MAX_ATTACHED int32 = SQLITE_MAX_ATTACHED /* test_config.c:789:3 */ +var cv_MAX_DEFAULT_PAGE_SIZE int32 = SQLITE_MAX_DEFAULT_PAGE_SIZE /* test_config.c:790:3 */ +var cv_MAX_WORKER_THREADS int32 = SQLITE_MAX_WORKER_THREADS /* test_config.c:791:3 */ +var cv_TEMP_STORE int32 = SQLITE_TEMP_STORE /* test_config.c:794:22 */ +var cv___GNUC__ int32 = 1 /* test_config.c:808:22 */ // Register commands with the TCL interpreter. func Sqliteconfig_Init(tls *libc.TLS, interp uintptr) int32 { /* test_config.c:819:5: */ set_options(tls, interp) - return 0 + return TCL_OK } // @@ -63088,15 +59317,15 @@ func sqlite3Delete83Name(tls *libc.TLS, z uintptr) { /* test_delete.c:46:13: */ // // If an error occurs, non-zero is returned. Or, if no error occurs, zero. func sqlite3DeleteUnlinkIfExists(tls *libc.TLS, pVfs uintptr, zFile uintptr, pbExists uintptr) int32 { /* test_delete.c:60:12: */ - var rc int32 = 1 + var rc int32 = SQLITE_ERROR - rc = libc.Xaccess(tls, zFile, 0) + rc = libc.Xaccess(tls, zFile, F_OK) if rc != 0 { - if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 2 { + if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == ENOENT { if pbExists != 0 { *(*int32)(unsafe.Pointer(pbExists)) = 0 } - rc = 0 + rc = SQLITE_OK } } else { if pbExists != 0 { @@ -63121,30 +59350,12 @@ func sqlite3_delete_database(tls *libc.TLS, zFile uintptr) int32 { /* test_delet *(*[4]uintptr)(unsafe.Pointer(bp + 24 /* azFmt */)) = [4]uintptr{ts /* "%s" */, ts + 29445 /* "%s-journal" */, ts + 29456 /* "%s-wal" */, ts + 29463 /* "%s-shm" */} *(*[6]MFile)(unsafe.Pointer(bp + 56 /* aMFile */)) = [6]MFile{ - { - FzFmt: ts + 29470, /* "%s%03d" */ - FiOffset: 0, - Fb83: 0}, - { - FzFmt: ts + 29477, /* "%s-journal%03d" */ - FiOffset: 0, - Fb83: 0}, - { - FzFmt: ts + 29492, /* "%s-wal%03d" */ - FiOffset: 0, - Fb83: 0}, - { - FzFmt: ts + 29470, /* "%s%03d" */ - FiOffset: 0, - Fb83: 1}, - { - FzFmt: ts + 29477, /* "%s-journal%03d" */ - FiOffset: 400, - Fb83: 1}, - { - FzFmt: ts + 29492, /* "%s-wal%03d" */ - FiOffset: 700, - Fb83: 1}, + {FzFmt: ts + 29470 /* "%s%03d" */}, + {FzFmt: ts + 29477 /* "%s-journal%03d" */}, + {FzFmt: ts + 29492 /* "%s-wal%03d" */}, + {FzFmt: ts + 29470 /* "%s%03d" */, Fb83: 1}, + {FzFmt: ts + 29477 /* "%s-journal%03d" */, FiOffset: SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET, Fb83: 1}, + {FzFmt: ts + 29492 /* "%s-wal%03d" */, FiOffset: SQLITE_MULTIPLEX_WAL_8_3_OFFSET, Fb83: 1}, } var pVfs uintptr = uintptr(0) @@ -63154,7 +59365,7 @@ func sqlite3_delete_database(tls *libc.TLS, zFile uintptr) int32 { /* test_delet nBuf = (int32(libc.Xstrlen(tls, zFile)) + 100) zBuf = sqlite3.Xsqlite3_malloc(tls, nBuf) if zBuf == uintptr(0) { - return 7 + return SQLITE_NOMEM } // Delete both the regular and 8.3 filenames versions of the database, @@ -63172,7 +59383,7 @@ func sqlite3_delete_database(tls *libc.TLS, zFile uintptr) int32 { /* test_delet for i = 0; (rc == 0) && (uint64(i) < (uint64(unsafe.Sizeof([6]MFile{})) / uint64(unsafe.Sizeof(MFile{})))); i++ { var p uintptr = (bp + 56 /* &aMFile */ + uintptr(i)*16) var iChunk int32 - for iChunk = 1; iChunk <= 299; iChunk++ { + for iChunk = 1; iChunk <= MX_CHUNK_NUMBER; iChunk++ { // var bExists int32 at bp+152, 4 sqlite3.Xsqlite3_snprintf(tls, nBuf, zBuf, (*MFile)(unsafe.Pointer(p)).FzFmt, libc.VaList(bp+8, zFile, (iChunk+(*MFile)(unsafe.Pointer(p)).FiOffset))) @@ -63189,9 +59400,9 @@ func sqlite3_delete_database(tls *libc.TLS, zFile uintptr) int32 { /* test_delet sqlite3.Xsqlite3_free(tls, zBuf) return func() int32 { if rc != 0 { - return 1 + return SQLITE_ERROR } - return 0 + return SQLITE_OK }() } @@ -63210,7 +59421,7 @@ type MFile = struct { // End: func Sqlitetest_demovfs_Init(tls *libc.TLS, interp uintptr) int32 { /* test_demovfs.c:686:5: */ - return 0 + return TCL_OK } // Maximum pathname length supported by the devsym backend. @@ -63236,17 +59447,13 @@ type DevsymGlobal = struct { _ [4]byte } /* test_devsym.c:76:1 */ -var g1 = DevsymGlobal{ - FpVfs: uintptr(0), - FiDeviceChar: 0, - FiSectorSize: 512, - FnWriteCrash: 0} /* test_devsym.c:82:21 */ +var g1 = DevsymGlobal{FiSectorSize: 512} /* test_devsym.c:82:21 */ // Close an devsym-file. func devsymClose(tls *libc.TLS, pFile uintptr) int32 { /* test_devsym.c:87:12: */ var p uintptr = pFile sqlite3.Xsqlite3OsClose(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal) - return 0 + return SQLITE_OK } // Read data from an devsym-file. @@ -63338,7 +59545,7 @@ func devsymShmUnmap(tls *libc.TLS, pFile uintptr, delFlag int32) int32 { /* test func devsymOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { /* test_devsym.c:220:12: */ var rc int32 var p uintptr = pFile - (*devsym_file)(unsafe.Pointer(p)).FpReal = (p + uintptr(1)*16) + (*devsym_file)(unsafe.Pointer(p)).FpReal = (p + 1*16) rc = sqlite3.Xsqlite3OsOpen(tls, g1.FpVfs, zName, (*devsym_file)(unsafe.Pointer(p)).FpReal, flags, pOutFlags) if (*sqlite3_file)(unsafe.Pointer((*devsym_file)(unsafe.Pointer(p)).FpReal)).FpMethods != 0 { (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&devsym_io_methods)) @@ -63347,39 +59554,23 @@ func devsymOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags } var devsym_io_methods = sqlite3_io_methods{ - FiVersion: 2, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - 0, - FxUnlock:// xLock - 0, - FxCheckReservedLock:// xUnlock - 0, - FxFileControl:// xCheckReservedLock - 0, - FxSectorSize:// xFileControl - 0, - FxDeviceCharacteristics:// xSectorSize - 0, - FxShmMap:// xDeviceCharacteristics - 0, - FxShmLock:// xShmMap - 0, - FxShmBarrier:// xShmLock - 0, - FxShmUnmap:// xShmBarrier - 0, // xShmUnmap + FiVersion: 2, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xFileSize + FxLock: 0, // xLock + FxUnlock: 0, // xUnlock + FxCheckReservedLock: 0, // xCheckReservedLock + FxFileControl: 0, // xFileControl + FxSectorSize: 0, // xSectorSize + FxDeviceCharacteristics: 0, // xDeviceCharacteristics + FxShmMap: 0, // xShmMap + FxShmLock: 0, // xShmLock + FxShmBarrier: 0, // xShmBarrier + FxShmUnmap: 0, // xShmUnmap } /* test_devsym.c:227:27 */ // Delete the file located at zPath. If the dirSync argument is true, @@ -63447,7 +59638,7 @@ func writecrashWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOf func writecrashOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { /* test_devsym.c:384:12: */ var rc int32 var p uintptr = pFile - (*devsym_file)(unsafe.Pointer(p)).FpReal = (p + uintptr(1)*16) + (*devsym_file)(unsafe.Pointer(p)).FpReal = (p + 1*16) rc = sqlite3.Xsqlite3OsOpen(tls, g1.FpVfs, zName, (*devsym_file)(unsafe.Pointer(p)).FpReal, flags, pOutFlags) if (*sqlite3_file)(unsafe.Pointer((*devsym_file)(unsafe.Pointer(p)).FpReal)).FpMethods != 0 { (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&writecrash_io_methods)) @@ -63456,119 +59647,51 @@ func writecrashOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, f } var writecrash_io_methods = sqlite3_io_methods{ - FiVersion: 2, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - 0, - FxUnlock:// xLock - 0, - FxCheckReservedLock:// xUnlock - 0, - FxFileControl:// xCheckReservedLock - 0, - FxSectorSize:// xFileControl - 0, - FxDeviceCharacteristics:// xSectorSize - 0, - FxShmMap:// xDeviceCharacteristics - 0, - FxShmLock:// xShmMap - 0, - FxShmBarrier:// xShmLock - 0, - FxShmUnmap:// xShmBarrier - 0, // xShmUnmap + FiVersion: 2, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xFileSize + FxLock: 0, // xLock + FxUnlock: 0, // xUnlock + FxCheckReservedLock: 0, // xCheckReservedLock + FxFileControl: 0, // xFileControl + FxSectorSize: 0, // xSectorSize + FxDeviceCharacteristics: 0, // xDeviceCharacteristics + FxShmMap: 0, // xShmMap + FxShmLock: 0, // xShmLock + FxShmBarrier: 0, // xShmBarrier + FxShmUnmap: 0, // xShmUnmap } /* test_devsym.c:391:27 */ var devsym_vfs = sqlite3_vfs{ - FiVersion: 2, - FszOsFile:// iVersion - int32(unsafe.Sizeof(devsym_file{})), - FmxPathname:// szOsFile - 512, - FpNext:// mxPathname - uintptr(0), - FzName:// pNext - ts + 29503, /* "devsym" */ - FpAppData:// zName - uintptr(0), - FxOpen:// pAppData - 0, - FxDelete:// xOpen - 0, - FxAccess:// xDelete - 0, - FxFullPathname:// xAccess - 0, - FxDlOpen:// xFullPathname - uintptr(0), - FxDlError:// xDlOpen - uintptr(0), - FxDlSym:// xDlError - uintptr(0), - FxDlClose:// xDlSym - uintptr(0), - FxRandomness:// xDlClose - 0, - FxSleep:// xRandomness - 0, - FxCurrentTime:// xSleep - 0, - FxGetLastError:// xCurrentTime - uintptr(0), - FxCurrentTimeInt64:// xGetLastError - uintptr(0), // xCurrentTimeInt64 + FiVersion: 2, // iVersion + FszOsFile: int32(unsafe.Sizeof(devsym_file{})), // szOsFile + FmxPathname: DEVSYM_MAX_PATHNAME, // pNext + FzName: ts + 29503, /* "devsym" */ // pAppData + FxOpen: 0, // xOpen + FxDelete: 0, // xDelete + FxAccess: 0, // xAccess + FxFullPathname: 0, // xDlClose + FxRandomness: 0, // xRandomness + FxSleep: 0, // xSleep + FxCurrentTime: 0, // xCurrentTimeInt64 } /* test_devsym.c:421:20 */ var writecrash_vfs = sqlite3_vfs{ - FiVersion: 2, - FszOsFile:// iVersion - int32(unsafe.Sizeof(devsym_file{})), - FmxPathname:// szOsFile - 512, - FpNext:// mxPathname - uintptr(0), - FzName:// pNext - ts + 29510, /* "writecrash" */ - FpAppData:// zName - uintptr(0), - FxOpen:// pAppData - 0, - FxDelete:// xOpen - 0, - FxAccess:// xDelete - 0, - FxFullPathname:// xAccess - 0, - FxDlOpen:// xFullPathname - uintptr(0), - FxDlError:// xDlOpen - uintptr(0), - FxDlSym:// xDlError - uintptr(0), - FxDlClose:// xDlSym - uintptr(0), - FxRandomness:// xDlClose - 0, - FxSleep:// xRandomness - 0, - FxCurrentTime:// xSleep - 0, - FxGetLastError:// xCurrentTime - uintptr(0), - FxCurrentTimeInt64:// xGetLastError - uintptr(0), // xCurrentTimeInt64 + FiVersion: 2, // iVersion + FszOsFile: int32(unsafe.Sizeof(devsym_file{})), // szOsFile + FmxPathname: DEVSYM_MAX_PATHNAME, // pNext + FzName: ts + 29510, /* "writecrash" */ // pAppData + FxOpen: 0, // xOpen + FxDelete: 0, // xDelete + FxAccess: 0, // xAccess + FxFullPathname: 0, // xDlClose + FxRandomness: 0, // xRandomness + FxSleep: 0, // xSleep + FxCurrentTime: 0, // xCurrentTimeInt64 } /* test_devsym.c:450:20 */ // This procedure registers the devsym vfs with SQLite. If the argument is @@ -64017,25 +60140,25 @@ func fsdirConnect1(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin if argc != 3 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+27277 /* "wrong number of ..." */, 0) - return 1 + return SQLITE_ERROR } pTab = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(FsdirVtab{}))) if !(pTab != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pTab, 0, uint64(unsafe.Sizeof(FsdirVtab{}))) *(*uintptr)(unsafe.Pointer(ppVtab)) = (pTab /* &.base */) sqlite3.Xsqlite3_declare_vtab(tls, db, ts+29521 /* "CREATE TABLE xyz..." */) - return 0 + return SQLITE_OK } // xDestroy/xDisconnect implementation. func fsdirDisconnect1(tls *libc.TLS, pVtab uintptr) int32 { /* test_fs.c:173:12: */ sqlite3.Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // xBestIndex implementation. The only constraint supported is: @@ -64048,7 +60171,7 @@ func fsdirBestIndex1(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* te for ii = 0; ii < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { var p uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12) - 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) == 2) { + 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) { var pUsage uintptr pUsage = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8) (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(1) @@ -64059,7 +60182,7 @@ func fsdirBestIndex1(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* te } } - return 0 + return SQLITE_OK } // xOpen implementation. @@ -64072,11 +60195,11 @@ func fsdirOpen1(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_ // Solaris only provides one byte. pCur = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(FsdirCsr{})) + uint64(256)))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(FsdirCsr{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Close a fsdir cursor. @@ -64087,7 +60210,7 @@ func fsdirClose1(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:224:12: */ } sqlite3.Xsqlite3_free(tls, (*FsdirCsr)(unsafe.Pointer(pCur)).FzDir) sqlite3.Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } // Skip the cursor to the next entry. @@ -64103,7 +60226,7 @@ func fsdirNext1(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:235:12: */ (*FsdirCsr)(unsafe.Pointer(pCsr)).FiRowid++ } - return 0 + return SQLITE_OK } // xFilter method implementation. @@ -64113,7 +60236,7 @@ func fsdirFilter1(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp var nDir int32 if (idxNum != 1) || (argc != 1) { - return 1 + return SQLITE_ERROR } (*FsdirCsr)(unsafe.Pointer(pCsr)).FiRowid = int64(0) @@ -64123,11 +60246,11 @@ func fsdirFilter1(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp (*FsdirCsr)(unsafe.Pointer(pCsr)).FpDir = uintptr(0) } - zDir = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - nDir = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zDir = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + nDir = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) (*FsdirCsr)(unsafe.Pointer(pCsr)).FzDir = sqlite3.Xsqlite3_malloc(tls, (nDir + 1)) if (*FsdirCsr)(unsafe.Pointer(pCsr)).FzDir == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, (*FsdirCsr)(unsafe.Pointer(pCsr)).FzDir, zDir, (uint64(nDir + 1))) @@ -64157,14 +60280,14 @@ func fsdirColumn1(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* t } - return 0 + return SQLITE_OK } // xRowid method implementation. func fsdirRowid1(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test_fs.c:316:12: */ var pCsr uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*FsdirCsr)(unsafe.Pointer(pCsr)).FiRowid - return 0 + return SQLITE_OK } // @@ -64210,12 +60333,12 @@ func fstreeConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin if argc != 3 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+27277 /* "wrong number of ..." */, 0) - return 1 + return SQLITE_ERROR } pTab = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(FstreeVtab{}))) if !(pTab != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pTab, 0, uint64(unsafe.Sizeof(FstreeVtab{}))) (*FstreeVtab)(unsafe.Pointer(pTab)).Fdb = db @@ -64223,13 +60346,13 @@ func fstreeConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin *(*uintptr)(unsafe.Pointer(ppVtab)) = (pTab /* &.base */) sqlite3.Xsqlite3_declare_vtab(tls, db, ts+29550 /* "CREATE TABLE xyz..." */) - return 0 + return SQLITE_OK } // xDestroy/xDisconnect implementation. func fstreeDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* test_fs.c:380:12: */ sqlite3.Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // xBestIndex implementation. The only constraint supported is: @@ -64240,20 +60363,20 @@ func fstreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* te for ii = 0; ii < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { var p uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12) - 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) == 66) || - (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 65)) || - (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2)) { + 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) || + (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_LIKE)) || + (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ)) { var pUsage uintptr pUsage = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8) (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = 1 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 100000.0 - return 0 + return SQLITE_OK } } (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1000000000.0 - return 0 + return SQLITE_OK } // xOpen implementation. @@ -64263,12 +60386,12 @@ func fstreeOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_ var pCur uintptr pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(FstreeCsr{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(FstreeCsr{}))) (*FstreeCsr)(unsafe.Pointer(pCur)).Ffd = -1 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } func fstreeCloseFd(tls *libc.TLS, pCsr uintptr) { /* test_fs.c:428:13: */ @@ -64284,7 +60407,7 @@ func fstreeClose(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:438:12: */ sqlite3.Xsqlite3_finalize(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt) fstreeCloseFd(tls, pCsr) sqlite3.Xsqlite3_free(tls, pCsr) - return 0 + return SQLITE_OK } // Skip the cursor to the next entry. @@ -64294,12 +60417,12 @@ func fstreeNext(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:449:12: */ fstreeCloseFd(tls, pCsr) rc = sqlite3.Xsqlite3_step(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt) - if rc != 100 { + if rc != SQLITE_ROW { rc = sqlite3.Xsqlite3_finalize(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt) (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt = uintptr(0) } else { - rc = 0 - (*FstreeCsr)(unsafe.Pointer(pCsr)).Ffd = libc.Xopen(tls, sqlite3.Xsqlite3_column_text(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt, 0), 00, 0) + rc = SQLITE_OK + (*FstreeCsr)(unsafe.Pointer(pCsr)).Ffd = libc.Xopen(tls, sqlite3.Xsqlite3_column_text(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt, 0), O_RDONLY, 0) } return rc @@ -64334,28 +60457,28 @@ func fstreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp sqlite3.Xsqlite3_finalize(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt) (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt = uintptr(0) rc = sqlite3.Xsqlite3_prepare_v2(tls, (*FstreeVtab)(unsafe.Pointer(pTab)).Fdb, zSql, -1, (pCsr + 8 /* &.pStmt */), uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { return rc } if idxNum != 0 { - var zQuery uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zQuery uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) switch idxNum { - case 66: - *(*int8)(unsafe.Pointer(bp /* &aWild[0] */ + uintptr(0))) = int8('*') - *(*int8)(unsafe.Pointer(bp /* &aWild[0] */ + uintptr(1))) = int8('?') + case SQLITE_INDEX_CONSTRAINT_GLOB: + *(*int8)(unsafe.Pointer(bp /* &aWild[0] */)) = int8('*') + *(*int8)(unsafe.Pointer(bp /* &aWild[0] */ + 1)) = int8('?') break fallthrough - case 65: - *(*int8)(unsafe.Pointer(bp /* &aWild[0] */ + uintptr(0))) = int8('_') - *(*int8)(unsafe.Pointer(bp /* &aWild[0] */ + uintptr(1))) = int8('%') + case SQLITE_INDEX_CONSTRAINT_LIKE: + *(*int8)(unsafe.Pointer(bp /* &aWild[0] */)) = int8('_') + *(*int8)(unsafe.Pointer(bp /* &aWild[0] */ + 1)) = int8('%') break } if sqlite3.Xsqlite3_strnicmp(tls, zQuery, zPrefix, nPrefix) == 0 { var i int32 for i = nPrefix; *(*int8)(unsafe.Pointer(zQuery + uintptr(i))) != 0; i++ { - if (int32(*(*int8)(unsafe.Pointer(zQuery + uintptr(i)))) == int32(*(*int8)(unsafe.Pointer(bp /* &aWild[0] */ + uintptr(0))))) || (int32(*(*int8)(unsafe.Pointer(zQuery + uintptr(i)))) == int32(*(*int8)(unsafe.Pointer(bp /* &aWild[0] */ + uintptr(1))))) { + 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)))) { break } if int32(*(*int8)(unsafe.Pointer(zQuery + uintptr(i)))) == '/' { @@ -64402,11 +60525,11 @@ func fstreeColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* t var nRead int32 var aBuf uintptr = sqlite3.Xsqlite3_malloc(tls, (int32((*stat)(unsafe.Pointer(bp /* &sBuf */)).Fst_mode + uint32(1)))) if !(aBuf != 0) { - return 7 + return SQLITE_NOMEM } nRead = int32(libc.Xread(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).Ffd, aBuf, uint64((*stat)(unsafe.Pointer(bp /* &sBuf */)).Fst_mode))) if uint32(nRead) != (*stat)(unsafe.Pointer(bp /* &sBuf */)).Fst_mode { - return 10 + return SQLITE_IOERR } sqlite3.Xsqlite3_result_blob(tls, ctx, aBuf, nRead, libc.UintptrFromInt32(-1)) sqlite3.Xsqlite3_free(tls, aBuf) @@ -64414,13 +60537,13 @@ func fstreeColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* t } } - return 0 + return SQLITE_OK } // xRowid method implementation. func fstreeRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test_fs.c:596:12: */ *(*sqlite_int64)(unsafe.Pointer(pRowid)) = int64(0) - return 0 + return SQLITE_OK } // @@ -64440,21 +60563,21 @@ func fsConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr var pVtab uintptr var nByte int32 var zTbl uintptr - var zDb uintptr = *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) + var zDb uintptr = *(*uintptr)(unsafe.Pointer(argv + 1*8)) if argc != 4 { *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+27277 /* "wrong number of ..." */, 0) - return 1 + return SQLITE_ERROR } - zTbl = *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)) + zTbl = *(*uintptr)(unsafe.Pointer(argv + 3*8)) nByte = (int32((((uint64(unsafe.Sizeof(fs_vtab{})) + uint64(int32(libc.Xstrlen(tls, zTbl)))) + uint64(1)) + uint64(int32(libc.Xstrlen(tls, zDb)))) + uint64(1))) pVtab = sqlite3.Xsqlite3MallocZero(tls, uint64(nByte)) if !(pVtab != 0) { - return 7 + return SQLITE_NOMEM } - (*fs_vtab)(unsafe.Pointer(pVtab)).FzTbl = (pVtab + uintptr(1)*48) + (*fs_vtab)(unsafe.Pointer(pVtab)).FzTbl = (pVtab + 1*48) (*fs_vtab)(unsafe.Pointer(pVtab)).FzDb = ((*fs_vtab)(unsafe.Pointer(pVtab)).FzTbl + uintptr((libc.Xstrlen(tls, zTbl) + uint64(1)))) (*fs_vtab)(unsafe.Pointer(pVtab)).Fdb = db libc.Xmemcpy(tls, (*fs_vtab)(unsafe.Pointer(pVtab)).FzTbl, zTbl, libc.Xstrlen(tls, zTbl)) @@ -64462,7 +60585,7 @@ func fsConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr *(*uintptr)(unsafe.Pointer(ppVtab)) = (pVtab /* &.base */) sqlite3.Xsqlite3_declare_vtab(tls, db, ts+29820 /* "CREATE TABLE x(p..." */) - return 0 + return SQLITE_OK } // Note that for this virtual table, the xCreate and xConnect @@ -64470,7 +60593,7 @@ func fsConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr func fsDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* test_fs.c:653:12: */ sqlite3.Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // The xDisconnect and xDestroy methods are also the same @@ -64480,7 +60603,7 @@ func fsOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_fs.c var pCur uintptr pCur = sqlite3.Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(fs_cursor{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Close a fs cursor. @@ -64489,7 +60612,7 @@ func fsClose(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:672:12: */ sqlite3.Xsqlite3_finalize(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FpStmt) sqlite3.Xsqlite3_free(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FzBuf) sqlite3.Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } func fsNext(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:680:12: */ @@ -64497,8 +60620,8 @@ func fsNext(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:680:12: */ var rc int32 rc = sqlite3.Xsqlite3_step(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FpStmt) - if (rc == 100) || (rc == 101) { - rc = 0 + if (rc == SQLITE_ROW) || (rc == SQLITE_DONE) { + rc = SQLITE_OK } return rc @@ -64516,23 +60639,23 @@ func fsFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, var zStmt uintptr = sqlite3.Xsqlite3_mprintf(tls, ts+29857 /* "SELECT * FROM %Q..." */, libc.VaList(bp, (*fs_vtab)(unsafe.Pointer(p)).FzDb, (*fs_vtab)(unsafe.Pointer(p)).FzTbl)) if !(zStmt != 0) { - return 7 + return SQLITE_NOMEM } rc = sqlite3.Xsqlite3_prepare_v2(tls, (*fs_vtab)(unsafe.Pointer(p)).Fdb, zStmt, -1, (pCur + 8 /* &.pStmt */), uintptr(0)) sqlite3.Xsqlite3_free(tls, zStmt) - if rc == 0 { - sqlite3.Xsqlite3_bind_value(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FpStmt, 1, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + if rc == SQLITE_OK { + sqlite3.Xsqlite3_bind_value(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FpStmt, 1, *(*uintptr)(unsafe.Pointer(argv))) } } else { var zStmt uintptr = sqlite3.Xsqlite3_mprintf(tls, ts+3221 /* "SELECT * FROM %Q..." */, libc.VaList(bp+16, (*fs_vtab)(unsafe.Pointer(p)).FzDb, (*fs_vtab)(unsafe.Pointer(p)).FzTbl)) if !(zStmt != 0) { - return 7 + return SQLITE_NOMEM } rc = sqlite3.Xsqlite3_prepare_v2(tls, (*fs_vtab)(unsafe.Pointer(p)).Fdb, zStmt, -1, (pCur + 8 /* &.pStmt */), uintptr(0)) sqlite3.Xsqlite3_free(tls, zStmt) } - if rc == 0 { + if rc == SQLITE_OK { rc = fsNext(tls, pVtabCursor) } return rc @@ -64552,9 +60675,9 @@ func fsColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* test_ var fd int32 var n int32 - fd = libc.Xopen(tls, zFile, 00, 0) + fd = libc.Xopen(tls, zFile, O_RDONLY, 0) if fd < 0 { - return 10 + return SQLITE_IOERR } libc.Xfstat(tls, fd, bp /* &sbuf */) @@ -64568,7 +60691,7 @@ func fsColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* test_ zNew = sqlite3.Xsqlite3Realloc(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FzBuf, uint64(nNew)) if zNew == uintptr(0) { libc.Xclose(tls, fd) - return 7 + return SQLITE_NOMEM } (*fs_cursor)(unsafe.Pointer(pCur)).FzBuf = zNew (*fs_cursor)(unsafe.Pointer(pCur)).FnAlloc = int32(nNew) @@ -64577,20 +60700,20 @@ func fsColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* test_ n = int32(libc.Xread(tls, fd, (*fs_cursor)(unsafe.Pointer(pCur)).FzBuf, uint64((*stat)(unsafe.Pointer(bp /* &sbuf */)).Fst_size))) libc.Xclose(tls, fd) if int64(n) != (*stat)(unsafe.Pointer(bp /* &sbuf */)).Fst_size { - return 1 + return SQLITE_ERROR } (*fs_cursor)(unsafe.Pointer(pCur)).FnBuf = int32((*stat)(unsafe.Pointer(bp /* &sbuf */)).Fst_size) *(*int8)(unsafe.Pointer((*fs_cursor)(unsafe.Pointer(pCur)).FzBuf + uintptr((*fs_cursor)(unsafe.Pointer(pCur)).FnBuf))) = int8(0) sqlite3.Xsqlite3_result_text(tls, ctx, (*fs_cursor)(unsafe.Pointer(pCur)).FzBuf, -1, libc.UintptrFromInt32(-1)) } - return 0 + return SQLITE_OK } func fsRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test_fs.c:763:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_column_int64(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FpStmt, 0) - return 0 + return SQLITE_OK } func fsEof(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:769:12: */ @@ -64604,7 +60727,7 @@ func fsBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_f for ii = 0; ii < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { var pCons uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12) if (((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn < 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fusable != 0)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == 2) { + (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { var pUsage uintptr pUsage = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8) (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(0) @@ -64615,130 +60738,54 @@ func fsBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_f } } - return 0 + return SQLITE_OK } // A virtual table module that provides read-only access to a // Tcl global variable namespace. -var fsModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, +var fsModule = sqlite3_module{ // iVersion + FxCreate: 0, FxConnect: 0, FxBestIndex: 0, FxDisconnect: 0, FxDestroy: 0, - FxOpen: 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRename } /* test_fs.c:798:23 */ -var fsdirModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - 0, - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename +var fsdirModule = sqlite3_module{ // iVersion + FxCreate: 0, // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDisconnect + FxDestroy: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRename } /* test_fs.c:821:23 */ -var fstreeModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - 0, - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename +var fstreeModule = sqlite3_module{ // iVersion + FxCreate: 0, // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDisconnect + FxDestroy: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRename } /* test_fs.c:844:23 */ // Register the echo virtual table module. @@ -64750,15 +60797,15 @@ func register_fs_module(tls *libc.TLS, clientData ClientData, interp uintptr, ob if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+29891 /* "fs" */, uintptr(unsafe.Pointer(&fsModule)), interp) sqlite3.Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+5016 /* "fsdir" */, uintptr(unsafe.Pointer(&fsdirModule)), uintptr(0)) sqlite3.Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+29894 /* "fstree" */, uintptr(unsafe.Pointer(&fstreeModule)), uintptr(0)) - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -64772,7 +60819,7 @@ func Sqlitetestfs_Init(tls *libc.TLS, interp uintptr) int32 { /* test_fs.c:901:5 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd6[i].FzName, aObjCmd6[i].FxProc, aObjCmd6[i].FclientData, uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd6 = [1]struct { @@ -64780,10 +60827,7 @@ var aObjCmd6 = [1]struct { FxProc uintptr FclientData uintptr }{ - { - FzName: ts + 29901, /* "register_fs_modu..." */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 29901 /* "register_fs_modu..." */, FxProc: 0}, } /* test_fs.c:907:5 */ // Some versions of define this macros. @@ -64820,14 +60864,14 @@ func randStr(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test // It used to be possible to call randstr() with any number of arguments, // but now it is registered with SQLite as requiring exactly 2. - iMin = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + iMin = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) if iMin < 0 { iMin = 0 } if uint64(iMin) >= uint64(unsafe.Sizeof([1000]uint8{})) { iMin = (int32(uint64(unsafe.Sizeof([1000]uint8{})) - uint64(1))) } - iMax = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + iMax = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if iMax < iMin { iMax = iMin } @@ -64876,10 +60920,10 @@ func test_destructor(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_destructor_count_var++ - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } - len = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + len = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) zVal = testContextMalloc(tls, pCtx, (len + 3)) if !(zVal != 0) { return @@ -64887,7 +60931,7 @@ func test_destructor(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* *(*int8)(unsafe.Pointer(zVal + uintptr((len + 1)))) = int8(0) *(*int8)(unsafe.Pointer(zVal + uintptr((len + 2)))) = int8(0) zVal++ - libc.Xmemcpy(tls, zVal, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))), uint64(len)) + libc.Xmemcpy(tls, zVal, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), uint64(len)) sqlite3.Xsqlite3_result_text(tls, pCtx, zVal, -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{destructor}))) } @@ -64897,10 +60941,10 @@ func test_destructor16(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { test_destructor_count_var++ - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } - len = sqlite3.Xsqlite3_value_bytes16(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + len = sqlite3.Xsqlite3_value_bytes16(tls, *(*uintptr)(unsafe.Pointer(argv))) zVal = testContextMalloc(tls, pCtx, (len + 3)) if !(zVal != 0) { return @@ -64908,7 +60952,7 @@ func test_destructor16(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { *(*int8)(unsafe.Pointer(zVal + uintptr((len + 1)))) = int8(0) *(*int8)(unsafe.Pointer(zVal + uintptr((len + 2)))) = int8(0) zVal++ - libc.Xmemcpy(tls, zVal, sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))), uint64(len)) + libc.Xmemcpy(tls, zVal, sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv))), uint64(len)) sqlite3.Xsqlite3_result_text16(tls, pCtx, zVal, -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{destructor}))) } @@ -64974,9 +61018,9 @@ func test_auxdata(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* te // returns a copy of its first argument as the error message. If the // second argument exists, it becomes the error code. func test_error(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:226:13: */ - sqlite3.Xsqlite3_result_error(tls, pCtx, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))), -1) + sqlite3.Xsqlite3_result_error(tls, pCtx, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), -1) if nArg == 2 { - sqlite3.Xsqlite3_result_error_code(tls, pCtx, sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) + sqlite3.Xsqlite3_result_error_code(tls, pCtx, sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) } } @@ -64992,7 +61036,7 @@ func counterFunc(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* tes sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) return } - *(*int32)(unsafe.Pointer(pCounter)) = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + *(*int32)(unsafe.Pointer(pCounter)) = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) sqlite3.Xsqlite3_set_auxdata(tls, pCtx, 0, pCounter, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) } else { *(*int32)(unsafe.Pointer(pCounter))++ @@ -65011,11 +61055,11 @@ func counterFunc(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* tes // We want to verify that the type conversions that occur on the // first argument do not invalidate the second argument. func test_isolation(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:276:13: */ - sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - sqlite3.Xsqlite3_result_value(tls, pCtx, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv))) + sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv))) + sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + sqlite3.Xsqlite3_result_value(tls, pCtx, *(*uintptr)(unsafe.Pointer(argv + 1*8))) } // Invoke an SQL statement recursively. The function result is the @@ -65030,11 +61074,11 @@ func test_eval(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_ var db uintptr = sqlite3.Xsqlite3_context_db_handle(tls, pCtx) var zSql uintptr - zSql = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zSql = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) rc = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+8 /* &pStmt */, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) - if rc == 100 { + if rc == SQLITE_ROW { sqlite3.Xsqlite3_result_value(tls, pCtx, sqlite3.Xsqlite3_column_value(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 0)) } rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) @@ -65062,8 +61106,8 @@ func testHexChar(tls *libc.TLS, c int8) int32 { /* test_func.c:326:12: */ // Convert hex to binary. func testHexToBin(tls *libc.TLS, zIn uintptr, zOut uintptr) { /* test_func.c:340:13: */ - for (*(*int8)(unsafe.Pointer(zIn + uintptr(0))) != 0) && (*(*int8)(unsafe.Pointer(zIn + uintptr(1))) != 0) { - *(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = (int8((testHexChar(tls, *(*int8)(unsafe.Pointer(zIn + uintptr(0)))) << 4) + testHexChar(tls, *(*int8)(unsafe.Pointer(zIn + uintptr(1)))))) + for (*(*int8)(unsafe.Pointer(zIn)) != 0) && (*(*int8)(unsafe.Pointer(zIn + 1)) != 0) { + *(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = (int8((testHexChar(tls, *(*int8)(unsafe.Pointer(zIn))) << 4) + testHexChar(tls, *(*int8)(unsafe.Pointer(zIn + 1))))) zIn += uintptr(2) } } @@ -65077,8 +61121,8 @@ func testHexToUtf16be(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { / var zIn uintptr var zOut uintptr - n = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zIn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + n = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + zIn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) zOut = sqlite3.Xsqlite3_malloc(tls, (n / 2)) if zOut == uintptr(0) { sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) @@ -65097,8 +61141,8 @@ func testHexToUtf8(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* t var zIn uintptr var zOut uintptr - n = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zIn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + n = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + zIn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) zOut = sqlite3.Xsqlite3_malloc(tls, (n / 2)) if zOut == uintptr(0) { sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) @@ -65117,8 +61161,8 @@ func testHexToUtf16le(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { / var zIn uintptr var zOut uintptr - n = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zIn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + n = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + zIn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) zOut = sqlite3.Xsqlite3_malloc(tls, (n / 2)) if zOut == uintptr(0) { sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) @@ -65144,8 +61188,8 @@ func real2hex(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* tes var i int32 var bigEndian int32 *(*sqlite3_uint64)(unsafe.Pointer(bp /* &v */)) = uint64(1) - bigEndian = (libc.Bool32(int32(*(*uint8)(unsafe.Pointer((bp /* &v */ /* &.x */) + uintptr(0)))) == 0)) - *(*float64)(unsafe.Pointer(bp /* &v */)) = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + bigEndian = (libc.Bool32(int32(*(*uint8)(unsafe.Pointer((bp /* &v */ /* &.x */)))) == 0)) + *(*float64)(unsafe.Pointer(bp /* &v */)) = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) for i = 0; i < 8; i++ { if bigEndian != 0 { *(*int8)(unsafe.Pointer(bp + 8 /* &zOut[0] */ + uintptr((i * 2)))) = *(*int8)(unsafe.Pointer(ts + 30030 /* "0123456789abcdef" */ + uintptr((int32(*(*uint8)(unsafe.Pointer((bp /* &v */ /* &.x */) + uintptr(i)))) >> 4)))) @@ -65155,7 +61199,7 @@ func real2hex(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* tes *(*int8)(unsafe.Pointer(bp + 8 /* &zOut[0] */ + uintptr(((14 - (i * 2)) + 1)))) = *(*int8)(unsafe.Pointer(ts + 30030 /* "0123456789abcdef" */ + uintptr((int32(*(*uint8)(unsafe.Pointer((bp /* &v */ /* &.x */) + uintptr(i)))) & 0xf)))) } } - *(*int8)(unsafe.Pointer(bp + 8 /* &zOut[0] */ + uintptr(16))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 8 /* &zOut[0] */ + 16)) = int8(0) sqlite3.Xsqlite3_result_text(tls, context, bp+8 /* &zOut[0] */, -1, libc.UintptrFromInt32(-1)) } @@ -65179,8 +61223,8 @@ func test_extract(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* var iIdx int32 // Required field var iCurrent int32 = 0 // Current field - pRec = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - iIdx = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pRec = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) + iIdx = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) pHdr = (pRec + uintptr(sqlite3.Xsqlite3GetVarint(tls, pRec, bp /* &nHdr */))) pBody = libc.AssignUintptr(&pEndHdr, (pRec + uintptr(*(*u64)(unsafe.Pointer(bp /* nHdr */))))) @@ -65228,7 +61272,7 @@ func test_decode(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* pRet = tcl.XTcl_NewObj(tls) (*Tcl_Obj)(unsafe.Pointer(pRet)).FrefCount++ - pRec = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + pRec = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) pHdr = (pRec + uintptr(sqlite3.Xsqlite3GetVarint(tls, pRec, bp+32 /* &nHdr */))) pBody = libc.AssignUintptr(&pEndHdr, (pRec + uintptr(*(*u64)(unsafe.Pointer(bp + 32 /* nHdr */))))) @@ -65245,11 +61289,11 @@ func test_decode(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* pBody += uintptr(sqlite3.Xsqlite3VdbeSerialGet(tls, pBody, u322(*(*u64)(unsafe.Pointer(bp + 96 /* iSerialType */))), bp+40 /* &mem */)) switch sqlite3.Xsqlite3_value_type(tls, bp+40 /* &mem */) { - case 3: + case SQLITE_TEXT: pVal = tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, bp+40 /* &mem */), -1) break - case 4: + case SQLITE_BLOB: { *(*[16]int8)(unsafe.Pointer(bp + 107 /* hexdigit */)) = [16]int8{ int8('0'), int8('1'), int8('2'), int8('3'), int8('4'), int8('5'), int8('6'), int8('7'), @@ -65262,9 +61306,9 @@ func test_decode(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* for i = 0; i < n; i++ { // var hex [3]int8 at bp+104, 3 - *(*int8)(unsafe.Pointer(bp + 104 /* &hex[0] */ + uintptr(0))) = *(*int8)(unsafe.Pointer(bp + 107 /* &hexdigit[0] */ + uintptr(((int32(*(*u8)(unsafe.Pointer(z + uintptr(i)))) >> 4) & 0x0F)))) - *(*int8)(unsafe.Pointer(bp + 104 /* &hex[0] */ + uintptr(1))) = *(*int8)(unsafe.Pointer(bp + 107 /* &hexdigit[0] */ + uintptr((int32(*(*u8)(unsafe.Pointer(z + uintptr(i)))) & 0x0F)))) - *(*int8)(unsafe.Pointer(bp + 104 /* &hex[0] */ + uintptr(2))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 104 /* &hex[0] */)) = *(*int8)(unsafe.Pointer(bp + 107 /* &hexdigit[0] */ + uintptr(((int32(*(*u8)(unsafe.Pointer(z + uintptr(i)))) >> 4) & 0x0F)))) + *(*int8)(unsafe.Pointer(bp + 104 /* &hex[0] */ + 1)) = *(*int8)(unsafe.Pointer(bp + 107 /* &hexdigit[0] */ + uintptr((int32(*(*u8)(unsafe.Pointer(z + uintptr(i)))) & 0x0F)))) + *(*int8)(unsafe.Pointer(bp + 104 /* &hex[0] */ + 2)) = int8(0) tcl.XTcl_AppendStringsToObj(tls, pVal, libc.VaList(bp, bp+104 /* &hex[0] */, 0)) } tcl.XTcl_AppendStringsToObj(tls, pVal, libc.VaList(bp+16, ts+5315 /* "'" */, 0)) @@ -65272,15 +61316,15 @@ func test_decode(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* } - case 2: + case SQLITE_FLOAT: pVal = tcl.XTcl_NewDoubleObj(tls, sqlite3.Xsqlite3_value_double(tls, bp+40 /* &mem */)) break - case 1: + case SQLITE_INTEGER: pVal = tcl.XTcl_NewWideIntObj(tls, sqlite3.Xsqlite3_value_int64(tls, bp+40 /* &mem */)) break - case 5: + case SQLITE_NULL: pVal = tcl.XTcl_NewStringObj(tls, ts+5537 /* "NULL" */, -1) break @@ -65311,7 +61355,7 @@ func test_decode(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* // check that the integer parameter is within range before passing it // to sqlite3_result_zeroblob(). func test_zeroblob(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_func.c:612:13: */ - var nZero int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var nZero int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) sqlite3.Xsqlite3_result_zeroblob(tls, context, nZero) } @@ -65319,7 +61363,7 @@ func test_zeroblob(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { / // // Return the subtype for value V. func test_getsubtype(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_func.c:625:13: */ - sqlite3.Xsqlite3_result_int(tls, context, int32(sqlite3.Xsqlite3_value_subtype(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) + sqlite3.Xsqlite3_result_int(tls, context, int32(sqlite3.Xsqlite3_value_subtype(tls, *(*uintptr)(unsafe.Pointer(argv))))) } // test_frombind(A,B,C,...) @@ -65341,8 +61385,8 @@ func test_frombind(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { / // // Return the value V with its subtype changed to T func test_setsubtype(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_func.c:655:13: */ - sqlite3.Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - sqlite3.Xsqlite3_result_subtype(tls, context, uint32(sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))))) + sqlite3.Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv))) + sqlite3.Xsqlite3_result_subtype(tls, context, uint32(sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))))) } func registerTestFunctions(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pThunk uintptr) int32 { /* test_func.c:664:12: */ @@ -65359,12 +61403,12 @@ func registerTestFunctions(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pThunk u int32(aFuncs[i].FeTextRep), uintptr(0), aFuncs[i].FxFunc, uintptr(0), uintptr(0)) } - sqlite3.Xsqlite3_create_function(tls, db, ts+30050 /* "test_agg_errmsg1..." */, 0, 5, uintptr(0), uintptr(0), + sqlite3.Xsqlite3_create_function(tls, db, ts+30050 /* "test_agg_errmsg1..." */, 0, SQLITE_ANY, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{test_agg_errmsg16_step})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{test_agg_errmsg16_final}))) - return 0 + return SQLITE_OK } var aFuncs = [20]struct { @@ -65374,106 +61418,26 @@ var aFuncs = [20]struct { FeTextRep uint32 FxFunc uintptr }{ - { - FzName: ts + 30068, /* "randstr" */ - FnArg: int8(2), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30076, /* "test_destructor" */ - FnArg: int8(1), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30092, /* "test_destructor1..." */ - FnArg: int8(1), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30110, /* "hex_to_utf16be" */ - FnArg: int8(1), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30125, /* "hex_to_utf16le" */ - FnArg: int8(1), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30140, /* "hex_to_utf8" */ - FnArg: int8(1), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30152, /* "test_destructor_..." */ - FnArg: int8(0), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30174, /* "test_auxdata" */ - FnArg: int8(-1), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30187, /* "test_error" */ - FnArg: int8(1), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30187, /* "test_error" */ - FnArg: int8(2), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30198, /* "test_eval" */ - FnArg: int8(1), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30208, /* "test_isolation" */ - FnArg: int8(2), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30223, /* "test_counter" */ - FnArg: int8(1), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30236, /* "real2hex" */ - FnArg: int8(1), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30245, /* "test_decode" */ - FnArg: int8(1), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30257, /* "test_extract" */ - FnArg: int8(2), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30270, /* "test_zeroblob" */ - FnArg: int8(1), - FeTextRep: (uint32(1 | 0x000000800)), - FxFunc: 0}, - { - FzName: ts + 30284, /* "test_getsubtype" */ - FnArg: int8(1), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30300, /* "test_setsubtype" */ - FnArg: int8(2), - FeTextRep: uint32(1), - FxFunc: 0}, - { - FzName: ts + 30316, /* "test_frombind" */ - FnArg: int8(-1), - FeTextRep: uint32(1), - FxFunc: 0}, + {FzName: ts + 30068 /* "randstr" */, FnArg: int8(2), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30076 /* "test_destructor" */, FnArg: int8(1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30092 /* "test_destructor1..." */, FnArg: int8(1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30110 /* "hex_to_utf16be" */, FnArg: int8(1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30125 /* "hex_to_utf16le" */, FnArg: int8(1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30140 /* "hex_to_utf8" */, FnArg: int8(1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30152 /* "test_destructor_..." */, FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30174 /* "test_auxdata" */, FnArg: int8(-1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30187 /* "test_error" */, FnArg: int8(1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30187 /* "test_error" */, FnArg: int8(2), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30198 /* "test_eval" */, FnArg: int8(1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30208 /* "test_isolation" */, FnArg: int8(2), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30223 /* "test_counter" */, FnArg: int8(1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30236 /* "real2hex" */, FnArg: int8(1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30245 /* "test_decode" */, FnArg: int8(1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30257 /* "test_extract" */, FnArg: int8(2), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30270 /* "test_zeroblob" */, FnArg: int8(1), FeTextRep: (uint32(SQLITE_UTF8 | SQLITE_DETERMINISTIC)), FxFunc: 0}, + {FzName: ts + 30284 /* "test_getsubtype" */, FnArg: int8(1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30300 /* "test_setsubtype" */, FnArg: int8(2), FeTextRep: SQLITE_UTF8, FxFunc: 0}, + {FzName: ts + 30316 /* "test_frombind" */, FnArg: int8(-1), FeTextRep: SQLITE_UTF8, FxFunc: 0}, } /* test_func.c:674:5 */ // TCLCMD: autoinstall_test_functions @@ -65485,13 +61449,13 @@ func autoinstall_test_funcs(tls *libc.TLS, clientData uintptr, interp uintptr, o var rc int32 = sqlite3.Xsqlite3_auto_extension(tls, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr) int32 }{registerTestFunctions}))) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_auto_extension(tls, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr) int32 }{Md5_Register}))) } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } // A bogus step function and finalizer function. @@ -65514,79 +61478,79 @@ func abuse_create_function(tls *libc.TLS, clientData uintptr, interp uintptr, ob var rc int32 var mxArg int32 - if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+16 /* &db */) != 0) { + if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0) { goto __1 } - return 1 + return TCL_ERROR __1: ; - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, 1, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tStep})), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{tFinal}))) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __2 } goto abuse_err __2: ; - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, 1, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tStep})), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tStep})), uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __3 } goto abuse_err __3: ; - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, 1, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tStep})), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{tFinal}))) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __4 } goto abuse_err __4: ; - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, 1, 1, uintptr(0), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{tFinal}))) - if !(rc != 21) { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, 1, SQLITE_UTF8, uintptr(0), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{tFinal}))) + if !(rc != SQLITE_MISUSE) { goto __5 } goto abuse_err __5: ; - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, 1, 1, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, 1, SQLITE_UTF8, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tStep})), uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __6 } goto abuse_err __6: ; - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, -2, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, -2, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tStep})), uintptr(0), uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __7 } goto abuse_err __7: ; - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, 128, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30330 /* "tx" */, 128, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tStep})), uintptr(0), uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __8 } goto abuse_err @@ -65596,10 +61560,10 @@ __8: rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30333, /* "funcxx_123456789..." */ - 1, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tStep})), uintptr(0), uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __9 } goto abuse_err @@ -65609,27 +61573,27 @@ __9: // This last function registration should actually work. Generate // a no-op function (that always returns NULL) and which has the // maximum-length function name and the maximum number of parameters. - sqlite3.Xsqlite3_limit(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), 6, 10000) - mxArg = sqlite3.Xsqlite3_limit(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), 6, -1) + sqlite3.Xsqlite3_limit(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), SQLITE_LIMIT_FUNCTION_ARG, 10000) + mxArg = sqlite3.Xsqlite3_limit(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), SQLITE_LIMIT_FUNCTION_ARG, -1) rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30590, /* "nullx_123456789_..." */ - mxArg, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + mxArg, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{tStep})), uintptr(0), uintptr(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __10 } goto abuse_err __10: ; - return 0 + return TCL_OK abuse_err: tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+30846, /* "sqlite3_create_f..." */ uintptr(0))) - return 1 + return TCL_ERROR } // SQLite user defined function to use with matchinfo() to calculate the @@ -65701,13 +61665,13 @@ func rankfunc(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) { /* test_ goto wrong_number_args __1: ; - aMatchinfo = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) - nMatchinfo = (int32(uint64(sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8)))) / uint64(unsafe.Sizeof(int32(0))))) + aMatchinfo = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apVal))) + nMatchinfo = (int32(uint64(sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal)))) / uint64(unsafe.Sizeof(int32(0))))) if !(nMatchinfo >= 2) { goto __2 } - nPhrase = *(*int32)(unsafe.Pointer(aMatchinfo + uintptr(0)*4)) - nCol = *(*int32)(unsafe.Pointer(aMatchinfo + uintptr(1)*4)) + nPhrase = *(*int32)(unsafe.Pointer(aMatchinfo)) + nCol = *(*int32)(unsafe.Pointer(aMatchinfo + 1*4)) __2: ; if !(nMatchinfo != (2 + ((3 * nCol) * nPhrase))) { @@ -65786,16 +61750,16 @@ func install_fts3_rank_function(tls *libc.TLS, clientData uintptr, interp uintpt if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+30983 /* "rank" */, -1, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+30983 /* "rank" */, -1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rankfunc})), uintptr(0), uintptr(0)) - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -65815,22 +61779,16 @@ func Sqlitetest_func_Init(tls *libc.TLS, interp uintptr) int32 { /* test_func.c: sqlite3.Xsqlite3_auto_extension(tls, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr) int32 }{Md5_Register}))) - return 0 + return TCL_OK } var aObjCmd7 = [3]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 30988, /* "autoinstall_test..." */ - FxProc: 0}, - { - FzName: ts + 31015, /* "abuse_create_fun..." */ - FxProc: 0}, - { - FzName: ts + 31037, /* "install_fts3_ran..." */ - FxProc: 0}, + {FzName: ts + 30988 /* "autoinstall_test..." */, FxProc: 0}, + {FzName: ts + 31015 /* "abuse_create_fun..." */, FxProc: 0}, + {FzName: ts + 31037 /* "install_fts3_ran..." */, FxProc: 0}, } /* test_func.c:937:5 */ // Some versions of define this macros. @@ -66019,18 +61977,18 @@ func hexio_read(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, o if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31081 /* "FILENAME OFFSET ..." */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &offset */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &offset */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+44 /* &amt */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+44 /* &amt */) != 0 { + return TCL_ERROR } - zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) zBuf = sqlite3.Xsqlite3_malloc(tls, ((*(*int32)(unsafe.Pointer(bp + 44 /* amt */)) * 2) + 1)) if zBuf == uintptr(0) { - return 1 + return TCL_ERROR } in = libc.Xfopen(tls, zFile, ts+4086 /* "rb" */) if in == uintptr(0) { @@ -66038,9 +61996,9 @@ func hexio_read(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, o } if in == uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31103 /* "cannot open inpu..." */, zFile, 0)) - return 1 + return TCL_ERROR } - libc.Xfseek(tls, in, int64(*(*int32)(unsafe.Pointer(bp + 40 /* offset */))), 0) + libc.Xfseek(tls, in, int64(*(*int32)(unsafe.Pointer(bp + 40 /* offset */))), SEEK_SET) got = int32(libc.Xfread(tls, zBuf, uint64(1), uint64(*(*int32)(unsafe.Pointer(bp + 44 /* amt */))), in)) libc.Xfclose(tls, in) if got < 0 { @@ -66049,7 +62007,7 @@ func hexio_read(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, o sqlite3TestBinToHex(tls, zBuf, got) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, zBuf, 0)) sqlite3.Xsqlite3_free(tls, zBuf) - return 0 + return TCL_OK } // Usage: hexio_write FILENAME OFFSET DATA @@ -66073,16 +62031,16 @@ func hexio_write(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31127 /* "FILENAME OFFSET ..." */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+24 /* &offset */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+24 /* &offset */) != 0 { + return TCL_ERROR } - zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - zIn = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+28 /* &nIn */) + zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + zIn = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+28 /* &nIn */) aOut = sqlite3.Xsqlite3_malloc(tls, (*(*int32)(unsafe.Pointer(bp + 28 /* nIn */)) / 2)) if aOut == uintptr(0) { - return 1 + return TCL_ERROR } nOut = sqlite3TestHexToBin(tls, zIn, *(*int32)(unsafe.Pointer(bp + 28 /* nIn */)), aOut) out = libc.Xfopen(tls, zFile, ts+31151 /* "r+b" */) @@ -66091,14 +62049,14 @@ func hexio_write(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, } if out == uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31158 /* "cannot open outp..." */, zFile, 0)) - return 1 + return TCL_ERROR } - libc.Xfseek(tls, out, int64(*(*int32)(unsafe.Pointer(bp + 24 /* offset */))), 0) + libc.Xfseek(tls, out, int64(*(*int32)(unsafe.Pointer(bp + 24 /* offset */))), SEEK_SET) written = int32(libc.Xfwrite(tls, aOut, uint64(1), uint64(nOut), out)) sqlite3.Xsqlite3_free(tls, aOut) libc.Xfclose(tls, out) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, written)) - return 0 + return TCL_OK } // USAGE: hexio_get_int HEXDATA @@ -66120,12 +62078,12 @@ func hexio_get_int(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31183 /* "HEXDATA" */) - return 1 + return TCL_ERROR } - zIn = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &nIn */) + zIn = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &nIn */) aOut = sqlite3.Xsqlite3_malloc(tls, (*(*int32)(unsafe.Pointer(bp /* nIn */)) / 2)) if aOut == uintptr(0) { - return 1 + return TCL_ERROR } nOut = sqlite3TestHexToBin(tls, zIn, *(*int32)(unsafe.Pointer(bp /* nIn */)), aOut) if nOut >= 4 { @@ -66135,9 +62093,9 @@ func hexio_get_int(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 libc.Xmemcpy(tls, (bp + 4 /* &aNum */ + uintptr((4 - nOut))), aOut, uint64(nOut)) } sqlite3.Xsqlite3_free(tls, aOut) - val = ((((int32(*(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + uintptr(0)))) << 24) | (int32(*(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + uintptr(1)))) << 16)) | (int32(*(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + uintptr(2)))) << 8)) | int32(*(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + uintptr(3))))) + 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)))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, val)) - return 0 + return TCL_OK } // USAGE: hexio_render_int16 INTEGER @@ -66153,16 +62111,16 @@ func hexio_render_int16(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2273 /* "INTEGER" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &val */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &val */) != 0 { + return TCL_ERROR } - *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + uintptr(0))) = (uint8(*(*int32)(unsafe.Pointer(bp /* val */)) >> 8)) - *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + uintptr(1))) = uint8(*(*int32)(unsafe.Pointer(bp /* val */))) + *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */)) = (uint8(*(*int32)(unsafe.Pointer(bp /* val */)) >> 8)) + *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + 1)) = uint8(*(*int32)(unsafe.Pointer(bp /* val */))) sqlite3TestBinToHex(tls, bp+4 /* &aNum[0] */, 2) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, bp+4 /* aNum */, 4)) - return 0 + return TCL_OK } // USAGE: hexio_render_int32 INTEGER @@ -66178,18 +62136,18 @@ func hexio_render_int32(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2273 /* "INTEGER" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &val */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &val */) != 0 { + return TCL_ERROR } - *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + uintptr(0))) = (uint8(*(*int32)(unsafe.Pointer(bp /* val */)) >> 24)) - *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + uintptr(1))) = (uint8(*(*int32)(unsafe.Pointer(bp /* val */)) >> 16)) - *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + uintptr(2))) = (uint8(*(*int32)(unsafe.Pointer(bp /* val */)) >> 8)) - *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + uintptr(3))) = uint8(*(*int32)(unsafe.Pointer(bp /* val */))) + *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */)) = (uint8(*(*int32)(unsafe.Pointer(bp /* val */)) >> 24)) + *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + 1)) = (uint8(*(*int32)(unsafe.Pointer(bp /* val */)) >> 16)) + *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + 2)) = (uint8(*(*int32)(unsafe.Pointer(bp /* val */)) >> 8)) + *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + 3)) = uint8(*(*int32)(unsafe.Pointer(bp /* val */))) sqlite3TestBinToHex(tls, bp+4 /* &aNum[0] */, 4) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, bp+4 /* aNum */, 8)) - return 0 + return TCL_OK } // USAGE: utf8_to_utf8 HEX @@ -66203,7 +62161,7 @@ func utf8_to_utf8(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31191 /* "[utf8_to_utf8] u..." */, 0)) - return 1 + return TCL_ERROR } func getFts3Varint(tls *libc.TLS, p uintptr, v uintptr) int32 { /* test_hexio.c:328:12: */ @@ -66248,14 +62206,14 @@ func read_fts3varint(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31245 /* "BLOB VARNAME" */) - return 1 + return TCL_ERROR } - zBlob = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &nBlob */) + zBlob = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &nBlob */) nVal = getFts3Varint(tls, zBlob, bp+8 /* &iVal */) - tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), uintptr(0), tcl.XTcl_NewWideIntObj(tls, *(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* iVal */))), 0) + 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) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nVal)) - return 0 + return TCL_OK } // USAGE: make_fts3record ARGLIST @@ -66272,16 +62230,16 @@ func make_fts3record(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31258 /* "LIST" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &nArg */, bp+8 /* &aArg */) != 0 { - return 1 + if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &nArg */, bp+8 /* &aArg */) != 0 { + return TCL_ERROR } for i = 0; i < *(*int32)(unsafe.Pointer(bp /* nArg */)); i++ { // var iVal sqlite3_int64 at bp+16, 8 - if 0 == tcl.XTcl_GetWideIntFromObj(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* aArg */)) + uintptr(i)*8)), bp+16 /* &iVal */) { + if TCL_OK == tcl.XTcl_GetWideIntFromObj(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* aArg */)) + uintptr(i)*8)), bp+16 /* &iVal */) { if (nOut + 10) > nAlloc { var nNew int32 if nAlloc != 0 { @@ -66292,7 +62250,7 @@ func make_fts3record(tls *libc.TLS, clientData uintptr, interp uintptr, objc int var aNew uintptr = sqlite3.Xsqlite3_realloc(tls, aOut, nNew) if aNew == uintptr(0) { sqlite3.Xsqlite3_free(tls, aOut) - return 1 + return TCL_ERROR } aOut = aNew nAlloc = nNew @@ -66311,7 +62269,7 @@ func make_fts3record(tls *libc.TLS, clientData uintptr, interp uintptr, objc int var aNew uintptr = sqlite3.Xsqlite3_realloc(tls, aOut, nNew) if aNew == uintptr(0) { sqlite3.Xsqlite3_free(tls, aOut) - return 1 + return TCL_ERROR } aOut = aNew nAlloc = nNew @@ -66323,7 +62281,7 @@ func make_fts3record(tls *libc.TLS, clientData uintptr, interp uintptr, objc int tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, aOut, nOut)) sqlite3.Xsqlite3_free(tls, aOut) - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -66335,37 +62293,21 @@ func Sqlitetest_hexio_Init(tls *libc.TLS, interp uintptr) int32 { /* test_hexio. }{}))); i++ { tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd8[i].FzName, aObjCmd8[i].FxProc, uintptr(0), uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd8 = [8]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 31263, /* "hexio_read" */ - FxProc: 0}, - { - FzName: ts + 31274, /* "hexio_write" */ - FxProc: 0}, - { - FzName: ts + 31286, /* "hexio_get_int" */ - FxProc: 0}, - { - FzName: ts + 31300, /* "hexio_render_int..." */ - FxProc: 0}, - { - FzName: ts + 31319, /* "hexio_render_int..." */ - FxProc: 0}, - { - FzName: ts + 31338, /* "utf8_to_utf8" */ - FxProc: 0}, - { - FzName: ts + 31351, /* "read_fts3varint" */ - FxProc: 0}, - { - FzName: ts + 31367, /* "make_fts3record" */ - FxProc: 0}, + {FzName: ts + 31263 /* "hexio_read" */, FxProc: 0}, + {FzName: ts + 31274 /* "hexio_write" */, FxProc: 0}, + {FzName: ts + 31286 /* "hexio_get_int" */, FxProc: 0}, + {FzName: ts + 31300 /* "hexio_render_int..." */, FxProc: 0}, + {FzName: ts + 31319 /* "hexio_render_int..." */, FxProc: 0}, + {FzName: ts + 31338 /* "utf8_to_utf8" */, FxProc: 0}, + {FzName: ts + 31351 /* "read_fts3varint" */, FxProc: 0}, + {FzName: ts + 31367 /* "make_fts3record" */, FxProc: 0}, } /* test_hexio.c:450:5 */ // end block for C++ @@ -66401,11 +62343,11 @@ var wrapped Wrapped /* test_init.c:47:3: */ func wrMemInit(tls *libc.TLS, pAppData uintptr) int32 { /* test_init.c:49:12: */ var rc int32 if wrapped.Fmem_fail != 0 { - rc = 1 + rc = SQLITE_ERROR } else { rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 104 /* &.mem */ + 40 /* &.xInit */))))(tls, wrapped.Fmem.FpAppData) } - if rc == 0 { + if rc == SQLITE_OK { wrapped.Fmem_init = 1 } return rc @@ -66439,11 +62381,11 @@ func wrMemRoundup(tls *libc.TLS, n int32) int32 { /* test_init.c:69:12: */ func wrMutexInit(tls *libc.TLS) int32 { /* test_init.c:72:12: */ var rc int32 if wrapped.Fmutex_fail != 0 { - rc = 1 + rc = SQLITE_ERROR } else { rc = (*(*func(*libc.TLS) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 168 /* &.mutex */ /* &.xMutexInit */))))(tls) } - if rc == 0 { + if rc == SQLITE_OK { wrapped.Fmutex_init = 1 } return rc @@ -66452,7 +62394,7 @@ func wrMutexInit(tls *libc.TLS) int32 { /* test_init.c:72:12: */ func wrMutexEnd(tls *libc.TLS) int32 { /* test_init.c:84:12: */ (*(*func(*libc.TLS) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 168 /* &.mutex */ + 8 /* &.xMutexEnd */))))(tls) wrapped.Fmutex_init = 0 - return 0 + return SQLITE_OK } func wrMutexAlloc(tls *libc.TLS, e int32) uintptr { /* test_init.c:89:22: */ @@ -66486,11 +62428,11 @@ func wrMutexNotheld(tls *libc.TLS, p uintptr) int32 { /* test_init.c:107:12: */ func wrPCacheInit(tls *libc.TLS, pArg uintptr) int32 { /* test_init.c:113:12: */ var rc int32 if wrapped.Fpcache_fail != 0 { - rc = 1 + rc = SQLITE_ERROR } else { rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */ + 16 /* &.xInit */))))(tls, wrapped.Fpcache.FpArg) } - if rc == 0 { + if rc == SQLITE_OK { wrapped.Fpcache_init = 1 } return rc @@ -66538,50 +62480,37 @@ func installInitWrappers(tls *libc.TLS) { /* test_init.c:160:13: */ defer tls.Free(288) *(*sqlite3_mutex_methods)(unsafe.Pointer(bp + 48 /* mutexmethods */)) = sqlite3_mutex_methods{ - 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 { + 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 { f func(*libc.TLS, int32) uintptr }{wrMutexAlloc})), - 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 { + 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 { f func(*libc.TLS, uintptr) int32 }{wrMutexTry})), - FxMutexLeave: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrMutexLeave})), - FxMutexHeld: *(*uintptr)(unsafe.Pointer(&struct { + FxMutexLeave: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrMutexLeave})), FxMutexHeld: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr) int32 - }{wrMutexHeld})), - FxMutexNotheld: *(*uintptr)(unsafe.Pointer(&struct { + }{wrMutexHeld})), FxMutexNotheld: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr) int32 }{wrMutexNotheld})), } *(*sqlite3_pcache_methods2)(unsafe.Pointer(bp + 184 /* pcachemethods */)) = sqlite3_pcache_methods2{ FiVersion: 1, - FpArg: uintptr(0), FxInit: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr) int32 - }{wrPCacheInit})), - FxShutdown: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrPCacheShutdown})), - FxCreate: *(*uintptr)(unsafe.Pointer(&struct { + }{wrPCacheInit})), FxShutdown: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrPCacheShutdown})), FxCreate: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, int32, int32, int32) uintptr }{wrPCacheCreate})), FxCachesize: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32) - }{wrPCacheCachesize})), - FxPagecount: *(*uintptr)(unsafe.Pointer(&struct { + }{wrPCacheCachesize})), FxPagecount: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr) int32 - }{wrPCachePagecount})), - FxFetch: *(*uintptr)(unsafe.Pointer(&struct { + }{wrPCachePagecount})), FxFetch: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uint32, int32) uintptr }{wrPCacheFetch})), FxUnpin: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32) - }{wrPCacheUnpin})), - FxRekey: *(*uintptr)(unsafe.Pointer(&struct { + }{wrPCacheUnpin})), FxRekey: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uint32, uint32) - }{wrPCacheRekey})), - FxTruncate: *(*uintptr)(unsafe.Pointer(&struct { + }{wrPCacheRekey})), FxTruncate: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uint32) }{wrPCacheTruncate})), FxDestroy: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrPCacheDestroy})), @@ -66589,31 +62518,26 @@ func installInitWrappers(tls *libc.TLS) { /* test_init.c:160:13: */ *(*sqlite3_mem_methods)(unsafe.Pointer(bp + 120 /* memmethods */)) = sqlite3_mem_methods{ FxMalloc: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, int32) uintptr - }{wrMemMalloc})), - FxFree: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrMemFree})), - FxRealloc: *(*uintptr)(unsafe.Pointer(&struct { + }{wrMemMalloc})), FxFree: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrMemFree})), FxRealloc: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32) uintptr }{wrMemRealloc})), FxSize: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr) int32 - }{wrMemSize})), - FxRoundup: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, int32) int32 }{wrMemRoundup})), - FxInit: *(*uintptr)(unsafe.Pointer(&struct { + }{wrMemSize})), FxRoundup: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, int32) int32 }{wrMemRoundup})), FxInit: *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr) int32 }{wrMemInit})), FxShutdown: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrMemShutdown})), - FpAppData: uintptr(0), } libc.Xmemset(tls, uintptr(unsafe.Pointer(&wrapped)), 0, uint64(unsafe.Sizeof(wrapped))) sqlite3.Xsqlite3_shutdown(tls) - sqlite3.Xsqlite3_config(tls, 11, libc.VaList(bp, (uintptr(unsafe.Pointer(&wrapped))+168 /* &.mutex */))) - sqlite3.Xsqlite3_config(tls, 5, libc.VaList(bp+8, (uintptr(unsafe.Pointer(&wrapped))+104 /* &.mem */))) - sqlite3.Xsqlite3_config(tls, 19, libc.VaList(bp+16, (uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */))) - sqlite3.Xsqlite3_config(tls, 10, libc.VaList(bp+24, bp+48 /* &mutexmethods */)) - sqlite3.Xsqlite3_config(tls, 4, libc.VaList(bp+32, bp+120 /* &memmethods */)) - sqlite3.Xsqlite3_config(tls, 18, libc.VaList(bp+40, bp+184 /* &pcachemethods */)) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETMUTEX, libc.VaList(bp, (uintptr(unsafe.Pointer(&wrapped))+168 /* &.mutex */))) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETMALLOC, libc.VaList(bp+8, (uintptr(unsafe.Pointer(&wrapped))+104 /* &.mem */))) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETPCACHE2, libc.VaList(bp+16, (uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */))) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MUTEX, libc.VaList(bp+24, bp+48 /* &mutexmethods */)) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp+32, bp+120 /* &memmethods */)) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PCACHE2, libc.VaList(bp+40, bp+184 /* &pcachemethods */)) } func init_wrapper_install(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_init.c:191:26: */ @@ -66632,10 +62556,10 @@ func init_wrapper_install(tls *libc.TLS, clientData ClientData, interp uintptr, wrapped.Fpcache_fail = 1 } else { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31394 /* "Unknown argument..." */, z, ts+11456 /* "\"" */)) - return 1 + return TCL_ERROR } } - return 0 + return TCL_OK } func init_wrapper_uninstall(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_init.c:215:26: */ @@ -66644,26 +62568,26 @@ func init_wrapper_uninstall(tls *libc.TLS, clientData ClientData, interp uintptr if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } sqlite3.Xsqlite3_shutdown(tls) - sqlite3.Xsqlite3_config(tls, 10, libc.VaList(bp, (uintptr(unsafe.Pointer(&wrapped))+168 /* &.mutex */))) - sqlite3.Xsqlite3_config(tls, 4, libc.VaList(bp+8, (uintptr(unsafe.Pointer(&wrapped))+104 /* &.mem */))) - sqlite3.Xsqlite3_config(tls, 18, libc.VaList(bp+16, (uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */))) - return 0 + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MUTEX, libc.VaList(bp, (uintptr(unsafe.Pointer(&wrapped))+168 /* &.mutex */))) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp+8, (uintptr(unsafe.Pointer(&wrapped))+104 /* &.mem */))) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PCACHE2, libc.VaList(bp+16, (uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */))) + return TCL_OK } func init_wrapper_clear(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_init.c:233:26: */ if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } wrapped.Fmem_fail = 0 wrapped.Fmutex_fail = 0 wrapped.Fpcache_fail = 0 - return 0 + return TCL_OK } func init_wrapper_query(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_init.c:250:26: */ @@ -66671,7 +62595,7 @@ func init_wrapper_query(tls *libc.TLS, clientData ClientData, interp uintptr, ob if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } pRet = tcl.XTcl_NewObj(tls) @@ -66686,7 +62610,7 @@ func init_wrapper_query(tls *libc.TLS, clientData ClientData, interp uintptr, ob } tcl.XTcl_SetObjResult(tls, interp, pRet) - return 0 + return TCL_OK } func Sqlitetest_init_Init(tls *libc.TLS, interp uintptr) int32 { /* test_init.c:278:5: */ @@ -66699,25 +62623,17 @@ func Sqlitetest_init_Init(tls *libc.TLS, interp uintptr) int32 { /* test_init.c: tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd9[i].FzName, aObjCmd9[i].FxProc, uintptr(0), uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd9 = [4]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 31414, /* "init_wrapper_ins..." */ - FxProc: 0}, - { - FzName: ts + 31435, /* "init_wrapper_que..." */ - FxProc: 0}, - { - FzName: ts + 31454, /* "init_wrapper_uni..." */ - FxProc: 0}, - { - FzName: ts + 31477, /* "init_wrapper_cle..." */ - FxProc: 0}, + {FzName: ts + 31414 /* "init_wrapper_ins..." */, FxProc: 0}, + {FzName: ts + 31435 /* "init_wrapper_que..." */, FxProc: 0}, + {FzName: ts + 31454 /* "init_wrapper_uni..." */, FxProc: 0}, + {FzName: ts + 31477 /* "init_wrapper_cle..." */, FxProc: 0}, } /* test_init.c:282:5 */ // @@ -66784,7 +62700,7 @@ func intarrayDestroy(tls *libc.TLS, p uintptr) int32 { /* test_intarray.c:74:12: // Table constructor for the intarray module. func intarrayCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test_intarray.c:83:12: */ - var rc int32 = 7 + var rc int32 = SQLITE_NOMEM var pVtab uintptr = sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(intarray_vtab{}))) if pVtab != 0 { @@ -66798,13 +62714,13 @@ func intarrayCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv ui // Open a new cursor on the intarray table. func intarrayOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_intarray.c:106:12: */ - var rc int32 = 7 + var rc int32 = SQLITE_NOMEM var pCur uintptr pCur = sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(intarray_cursor{}))) if pCur != 0 { libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(intarray_cursor{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = pCur - rc = 0 + rc = SQLITE_OK } return rc } @@ -66813,7 +62729,7 @@ func intarrayOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* tes func intarrayClose(tls *libc.TLS, cur uintptr) int32 { /* test_intarray.c:121:12: */ var pCur uintptr = cur sqlite3.Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } // Retrieve a column of data. @@ -66823,14 +62739,14 @@ func intarrayColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* 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) { 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))) } - return 0 + return SQLITE_OK } // Retrieve the current rowid. func intarrayRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test_intarray.c:142:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite_int64((*intarray_cursor)(unsafe.Pointer(pCur)).Fi) - return 0 + return SQLITE_OK } func intarrayEof(tls *libc.TLS, cur uintptr) int32 { /* test_intarray.c:148:12: */ @@ -66843,63 +62759,36 @@ func intarrayEof(tls *libc.TLS, cur uintptr) int32 { /* test_intarray.c:148:12: func intarrayNext(tls *libc.TLS, cur uintptr) int32 { /* test_intarray.c:157:12: */ var pCur uintptr = cur (*intarray_cursor)(unsafe.Pointer(pCur)).Fi++ - return 0 + return SQLITE_OK } // Reset a intarray table cursor. func intarrayFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* test_intarray.c:166:12: */ var pCur uintptr = pVtabCursor (*intarray_cursor)(unsafe.Pointer(pCur)).Fi = 0 - return 0 + return SQLITE_OK } // Analyse the WHERE condition. func intarrayBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_intarray.c:179:12: */ - return 0 + return SQLITE_OK } // A virtual table module that merely echos method calls into TCL // variables. -var intarrayModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - create a new virtual table - 0, - FxBestIndex:// xConnect - connect to an existing vtab - 0, - FxDisconnect:// xBestIndex - find the best query index - 0, - FxDestroy:// xDisconnect - disconnect a vtab - 0, - FxOpen:// xDestroy - destroy a vtab - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename +var intarrayModule = sqlite3_module{ // iVersion + FxCreate: 0, // xCreate - create a new virtual table + FxConnect: 0, // xConnect - connect to an existing vtab + FxBestIndex: 0, // xBestIndex - find the best query index + FxDisconnect: 0, // xDisconnect - disconnect a vtab + FxDestroy: 0, // xDestroy - destroy a vtab + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRename } /* test_intarray.c:187:23 */ // Invoke this routine to create a specific instance of an intarray object. @@ -66915,17 +62804,17 @@ func sqlite3_intarray_create(tls *libc.TLS, db uintptr, zName uintptr, ppReturn bp := tls.Alloc(16) defer tls.Free(16) - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr *(*uintptr)(unsafe.Pointer(ppReturn)) = libc.AssignUintptr(&p, sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(sqlite3_intarray{})))) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(sqlite3_intarray{}))) rc = sqlite3.Xsqlite3_create_module_v2(tls, db, zName, uintptr(unsafe.Pointer(&intarrayModule)), p, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{intarrayFree}))) - if rc == 0 { + if rc == SQLITE_OK { var zSql uintptr zSql = sqlite3.Xsqlite3_mprintf(tls, ts+31538, /* "CREATE VIRTUAL T..." */ libc.VaList(bp, zName, zName)) @@ -66947,7 +62836,7 @@ func sqlite3_intarray_bind(tls *libc.TLS, pIntArray uintptr, nElements int32, aE (*sqlite3_intarray)(unsafe.Pointer(pIntArray)).Fn = nElements (*sqlite3_intarray)(unsafe.Pointer(pIntArray)).Fa = aElements (*sqlite3_intarray)(unsafe.Pointer(pIntArray)).FxFree = xFree - return 0 + return SQLITE_OK } // sqlite3_intarray_create DB NAME @@ -66963,25 +62852,25 @@ func test_intarray_create(tls *libc.TLS, clientData ClientData, interp uintptr, var zName uintptr // var pArray uintptr at bp+40, 8 - var rc int32 = 0 + var rc int32 = SQLITE_OK // var zPtr [100]int8 at bp+48, 100 if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { + return TCL_ERROR } - zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) rc = sqlite3_intarray_create(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), zName, bp+40 /* &pArray */) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0))) - return 1 + return TCL_ERROR } sqlite3TestMakePointerStr(tls, interp, bp+48 /* &zPtr[0] */, *(*uintptr)(unsafe.Pointer(bp + 40 /* pArray */))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, bp+48 /* &zPtr[0] */, uintptr(0))) - return 0 + return TCL_OK } // sqlite3_intarray_bind INTARRAY ?VALUE ...? @@ -66992,21 +62881,21 @@ func test_intarray_bind(tls *libc.TLS, clientData ClientData, interp uintptr, ob defer tls.Free(40) var pArray uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 var n int32 var a uintptr if objc < 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31576 /* "INTARRAY" */) - return 1 + return TCL_ERROR } - pArray = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + pArray = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) n = (objc - 2) a = sqlite3.Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(sqlite3_int64(0))) * uint64(n)))) if a == uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31585 /* "SQLITE_NOMEM" */, uintptr(0))) - return 1 + return TCL_ERROR } for i = 0; i < n; i++ { *(*Tcl_WideInt)(unsafe.Pointer(bp + 32 /* x */)) = int64(0) @@ -67014,11 +62903,11 @@ func test_intarray_bind(tls *libc.TLS, clientData ClientData, interp uintptr, ob *(*sqlite3_int64)(unsafe.Pointer(a + uintptr(i)*8)) = *(*Tcl_WideInt)(unsafe.Pointer(bp + 32 /* x */)) } rc = sqlite3_intarray_bind(tls, pArray, n, a, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0))) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -67032,7 +62921,7 @@ func Sqlitetestintarray_Init(tls *libc.TLS, interp uintptr) int32 { /* test_inta tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd10[i].FzName, aObjCmd10[i].FxProc, aObjCmd10[i].FclientData, uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd10 = [2]struct { @@ -67040,14 +62929,8 @@ var aObjCmd10 = [2]struct { FxProc uintptr FclientData uintptr }{ - { - FzName: ts + 31598, /* "sqlite3_intarray..." */ - FxProc: 0, - FclientData: uintptr(0)}, - { - FzName: ts + 31622, /* "sqlite3_intarray..." */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 31598 /* "sqlite3_intarray..." */, FxProc: 0}, + {FzName: ts + 31622 /* "sqlite3_intarray..." */, FxProc: 0}, } /* test_intarray.c:380:5 */ // Maximum pathname length supported by the jt backend. @@ -67077,71 +62960,39 @@ type jt_file1 = struct { type jt_file = jt_file1 /* test_journal.c:111:24 */ var jt_vfs = sqlite3_vfs{ - FiVersion: 2, - FszOsFile:// iVersion - int32(unsafe.Sizeof(jt_file{})), - FmxPathname:// szOsFile - 512, - FpNext:// mxPathname - uintptr(0), - FzName:// pNext - ts + 31644, /* "jt" */ - FpAppData:// zName - uintptr(0), - FxOpen:// pAppData - 0, - FxDelete:// xOpen - 0, - FxAccess:// xDelete - 0, - FxFullPathname:// xAccess - 0, - FxDlOpen:// xFullPathname - 0, - FxDlError:// xDlOpen - 0, - FxDlSym:// xDlError - 0, - FxDlClose:// xDlSym - 0, - FxRandomness:// xDlClose - 0, - FxSleep:// xRandomness - 0, - FxCurrentTime:// xSleep - 0, - FxGetLastError:// xCurrentTime - 0, - FxCurrentTimeInt64:// xGetLastError - 0, // xCurrentTimeInt64 + FiVersion: 2, // iVersion + FszOsFile: int32(unsafe.Sizeof(jt_file{})), // szOsFile + FmxPathname: JT_MAX_PATHNAME, // pNext + FzName: ts + 31644, /* "jt" */ // pAppData + FxOpen: 0, // xOpen + FxDelete: 0, // xDelete + FxAccess: 0, // xAccess + FxFullPathname: 0, // xFullPathname + FxDlOpen: 0, // xDlOpen + FxDlError: 0, // xDlError + FxDlSym: 0, // xDlSym + FxDlClose: 0, // xDlClose + FxRandomness: 0, // xRandomness + FxSleep: 0, // xSleep + FxCurrentTime: 0, // xCurrentTime + FxGetLastError: 0, // xGetLastError + FxCurrentTimeInt64: 0, // xCurrentTimeInt64 } /* test_journal.c:165:20 */ var jt_io_methods = sqlite3_io_methods{ - FiVersion: 1, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - 0, - FxUnlock:// xLock - 0, - FxCheckReservedLock:// xUnlock - 0, - FxFileControl:// xCheckReservedLock - 0, - FxSectorSize:// xFileControl - 0, - FxDeviceCharacteristics:// xSectorSize - 0, // xDeviceCharacteristics + FiVersion: 1, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xFileSize + FxLock: 0, // xLock + FxUnlock: 0, // xUnlock + FxCheckReservedLock: 0, // xCheckReservedLock + FxFileControl: 0, // xFileControl + FxSectorSize: 0, // xSectorSize + FxDeviceCharacteristics: 0, // xDeviceCharacteristics } /* test_journal.c:187:27 */ type JtGlobal = struct { @@ -67154,11 +63005,11 @@ var g2 = JtGlobal{} /* test_journal.c:207:24 */ // Functions to obtain and relinquish a mutex to protect g.pList. The // STATIC_PRNG mutex is reused, purely for the sake of convenience. func enterJtMutex(tls *libc.TLS) { /* test_journal.c:213:13: */ - sqlite3.Xsqlite3_mutex_enter(tls, sqlite3.Xsqlite3_mutex_alloc(tls, 5)) + sqlite3.Xsqlite3_mutex_enter(tls, sqlite3.Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_STATIC_PRNG)) } func leaveJtMutex(tls *libc.TLS) { /* test_journal.c:216:13: */ - sqlite3.Xsqlite3_mutex_leave(tls, sqlite3.Xsqlite3_mutex_alloc(tls, 5)) + sqlite3.Xsqlite3_mutex_leave(tls, sqlite3.Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_STATIC_PRNG)) } func stop_ioerr_simulation(tls *libc.TLS, piSave uintptr, piSave2 uintptr) { /* test_journal.c:222:13: */ @@ -67198,7 +63049,7 @@ func jtClose(tls *libc.TLS, pFile uintptr) int32 { /* test_journal.c:249:12: */ } leaveJtMutex(tls) sqlite3.Xsqlite3OsClose(tls, (*jt_file)(unsafe.Pointer(p)).FpReal) - return 0 + return SQLITE_OK } // Read data from an jt-file. @@ -67227,10 +63078,10 @@ func locateDatabaseHandle(tls *libc.TLS, zJournal uintptr, noLock int32) uintptr enterJtMutex(tls) for pMain = g2.FpList; pMain != 0; pMain = (*jt_file)(unsafe.Pointer(pMain)).FpNext { var nName int32 = (int32(libc.Xstrlen(tls, zJournal) - libc.Xstrlen(tls, ts+31647 /* "-journal" */))) - if (((((*jt_file)(unsafe.Pointer(pMain)).Fflags & 0x00000100) != 0) && + if (((((*jt_file)(unsafe.Pointer(pMain)).Fflags & SQLITE_OPEN_MAIN_DB) != 0) && (int32(libc.Xstrlen(tls, (*jt_file)(unsafe.Pointer(pMain)).FzName)) == nName)) && (0 == libc.Xmemcmp(tls, (*jt_file)(unsafe.Pointer(pMain)).FzName, zJournal, uint64(nName)))) && - (((*jt_file)(unsafe.Pointer(pMain)).FeLock >= 2) || (noLock != 0)) { + (((*jt_file)(unsafe.Pointer(pMain)).FeLock >= SQLITE_LOCK_RESERVED) || (noLock != 0)) { break } } @@ -67242,7 +63093,7 @@ func locateDatabaseHandle(tls *libc.TLS, zJournal uintptr, noLock int32) uintptr // unsigned 32-bit integer stored in big-endian format. Decode the // integer and return its value. func decodeUint32(tls *libc.TLS, z uintptr) u322 { /* test_journal.c:314:12: */ - return (u322((((int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) << 24) + (int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) << 16)) + (int32(*(*uint8)(unsafe.Pointer(z + uintptr(2)))) << 8)) + int32(*(*uint8)(unsafe.Pointer(z + uintptr(3)))))) + 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))))) } // Calculate a checksum from the buffer of length n bytes pointed to @@ -67269,21 +63120,21 @@ func decodeJournalHdr(tls *libc.TLS, zBuf uintptr, pnRec uintptr, pnPage uintptr *(*[8]uint8)(unsafe.Pointer(bp /* aMagic */)) = [8]uint8{uint8(0xd9), uint8(0xd5), uint8(0x05), uint8(0xf9), uint8(0x20), uint8(0xa1), uint8(0x63), uint8(0xd7)} if libc.Xmemcmp(tls, bp /* &aMagic[0] */, zBuf, uint64(8)) != 0 { - return 1 + return SQLITE_ERROR } if pnRec != 0 { - *(*u322)(unsafe.Pointer(pnRec)) = decodeUint32(tls, (zBuf + uintptr(8))) + *(*u322)(unsafe.Pointer(pnRec)) = decodeUint32(tls, (zBuf + 8)) } if pnPage != 0 { - *(*u322)(unsafe.Pointer(pnPage)) = decodeUint32(tls, (zBuf + uintptr(16))) + *(*u322)(unsafe.Pointer(pnPage)) = decodeUint32(tls, (zBuf + 16)) } if pnSector != 0 { - *(*u322)(unsafe.Pointer(pnSector)) = decodeUint32(tls, (zBuf + uintptr(20))) + *(*u322)(unsafe.Pointer(pnSector)) = decodeUint32(tls, (zBuf + 20)) } if pnPagesize != 0 { - *(*u322)(unsafe.Pointer(pnPagesize)) = decodeUint32(tls, (zBuf + uintptr(24))) + *(*u322)(unsafe.Pointer(pnPagesize)) = decodeUint32(tls, (zBuf + 24)) } - return 0 + return SQLITE_OK } // This function is called when a new transaction is opened, just after @@ -67294,7 +63145,7 @@ func openTransaction(tls *libc.TLS, pMain uintptr, pJournal uintptr) int32 { /* var aData uintptr var p uintptr = (*jt_file)(unsafe.Pointer(pMain)).FpReal - var rc int32 = 0 + var rc int32 = SQLITE_OK closeTransaction(tls, pMain) aData = sqlite3.Xsqlite3_malloc(tls, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize)) @@ -67303,7 +63154,7 @@ func openTransaction(tls *libc.TLS, pMain uintptr, pJournal uintptr) int32 { /* (*jt_file)(unsafe.Pointer(pJournal)).FiMaxOff = int64(0) if (!(int32((*jt_file)(unsafe.Pointer(pMain)).FpWritable) != 0) || !(int32((*jt_file)(unsafe.Pointer(pMain)).FaCksum) != 0)) || !(aData != 0) { - rc = (10 | (int32(12) << 8)) + rc = (SQLITE_IOERR | (int32(12) << 8)) } else if (*jt_file)(unsafe.Pointer(pMain)).FnPage > u322(0) { var iTrunk u322 // var iSave int32 at bp, 4 @@ -67315,23 +63166,23 @@ func openTransaction(tls *libc.TLS, pMain uintptr, pJournal uintptr) int32 { /* // Read the database free-list. Add the page-number for each free-list // leaf to the jt_file.pWritable bitvec. rc = sqlite3.Xsqlite3OsRead(tls, p, aData, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize), int64(0)) - if rc == 0 { - var nDbsize u322 = decodeUint32(tls, (aData + uintptr(28))) - if (nDbsize > u322(0)) && (libc.Xmemcmp(tls, (aData+uintptr(24)), (aData+uintptr(92)), uint64(4)) == 0) { + if rc == SQLITE_OK { + var nDbsize u322 = decodeUint32(tls, (aData + 28)) + if (nDbsize > u322(0)) && (libc.Xmemcmp(tls, (aData+24), (aData+92), uint64(4)) == 0) { var iPg u322 for iPg = (nDbsize + u322(1)); iPg <= (*jt_file)(unsafe.Pointer(pMain)).FnPage; iPg++ { sqlite3.Xsqlite3BitvecSet(tls, (*jt_file)(unsafe.Pointer(pMain)).FpWritable, iPg) } } } - iTrunk = decodeUint32(tls, (aData + uintptr(32))) - for (rc == 0) && (iTrunk > u322(0)) { + iTrunk = decodeUint32(tls, (aData + 32)) + for (rc == SQLITE_OK) && (iTrunk > u322(0)) { var nLeaf u322 var iLeaf u322 var iOff sqlite3_int64 = ((i64(iTrunk - u322(1))) * i64((*jt_file)(unsafe.Pointer(pMain)).FnPagesize)) rc = sqlite3.Xsqlite3OsRead(tls, p, aData, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize), iOff) - nLeaf = decodeUint32(tls, (aData + uintptr(4))) - for iLeaf = u322(0); (rc == 0) && (iLeaf < nLeaf); iLeaf++ { + nLeaf = decodeUint32(tls, (aData + 4)) + for iLeaf = u322(0); (rc == SQLITE_OK) && (iLeaf < nLeaf); iLeaf++ { var pgno u322 = decodeUint32(tls, (aData + uintptr((u322(8) + (u322(4) * iLeaf))))) sqlite3.Xsqlite3BitvecSet(tls, (*jt_file)(unsafe.Pointer(pMain)).FpWritable, pgno) } @@ -67339,17 +63190,17 @@ func openTransaction(tls *libc.TLS, pMain uintptr, pJournal uintptr) int32 { /* } // Calculate and store a checksum for each page in the database file. - if rc == 0 { + if rc == SQLITE_OK { var ii int32 - for ii = 0; (rc == 0) && (ii < int32((*jt_file)(unsafe.Pointer(pMain)).FnPage)); ii++ { + for ii = 0; (rc == SQLITE_OK) && (ii < int32((*jt_file)(unsafe.Pointer(pMain)).FnPage)); ii++ { var iOff i64 = ((i64((*jt_file)(unsafe.Pointer(pMain)).FnPagesize)) * i64(ii)) if iOff == i64(sqlite3.Xsqlite3PendingByte) { continue } rc = sqlite3.Xsqlite3OsRead(tls, (*jt_file)(unsafe.Pointer(pMain)).FpReal, aData, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize), iOff) *(*u322)(unsafe.Pointer((*jt_file)(unsafe.Pointer(pMain)).FaCksum + uintptr(ii)*4)) = genCksum(tls, aData, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize)) - if ((ii + 1) == int32((*jt_file)(unsafe.Pointer(pMain)).FnPage)) && (rc == (10 | (int32(2) << 8))) { - rc = 0 + if ((ii + 1) == int32((*jt_file)(unsafe.Pointer(pMain)).FnPage)) && (rc == (SQLITE_IOERR | (int32(2) << 8))) { + rc = SQLITE_OK } } } @@ -67391,7 +63242,7 @@ func readJournalFile(tls *libc.TLS, p uintptr, pMain uintptr) int32 { /* test_jo // var nPagesize u322 at bp+48, 4 var ii u322 - rc = 0 + rc = SQLITE_OK pReal = (*jt_file)(unsafe.Pointer(p)).FpReal iOff = int64(0) iSize = (*jt_file)(unsafe.Pointer(p)).FiMaxOff @@ -67400,20 +63251,20 @@ func readJournalFile(tls *libc.TLS, p uintptr, pMain uintptr) int32 { /* test_jo if !(!(aPage != 0)) { goto __1 } - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) __1: ; stop_ioerr_simulation(tls, bp /* &iSave */, bp+4 /* &iSave2 */) __2: - if !((rc == 0) && (iOff < iSize)) { + if !((rc == SQLITE_OK) && (iOff < iSize)) { goto __3 } // Read and decode the next journal-header from the journal file. rc = sqlite3.Xsqlite3OsRead(tls, pReal, bp+8 /* &zBuf[0] */, 28, iOff) - if !((rc != 0) || + if !((rc != SQLITE_OK) || (decodeJournalHdr(tls, bp+8 /* &zBuf[0] */, bp+36 /* &nRec */, bp+40 /* &nPage */, bp+44 /* &nSector */, bp+48 /* &nPagesize */) != 0)) { goto __4 } @@ -67432,7 +63283,7 @@ __4: goto __6 } rc = sqlite3.Xsqlite3OsRead(tls, pReal, bp+8 /* &zBuf[0] */, 28, iOff) - if !((rc != 0) || (0 == decodeJournalHdr(tls, bp+8 /* &zBuf[0] */, uintptr(0), uintptr(0), uintptr(0), uintptr(0)))) { + if !((rc != SQLITE_OK) || (0 == decodeJournalHdr(tls, bp+8 /* &zBuf[0] */, uintptr(0), uintptr(0), uintptr(0), uintptr(0)))) { goto __7 } goto __2 @@ -67447,11 +63298,11 @@ __5: // Read all the records that follow the journal-header just read. ii = u322(0) __8: - if !(((rc == 0) && (ii < *(*u322)(unsafe.Pointer(bp + 36 /* nRec */)))) && (iOff < iSize)) { + if !(((rc == SQLITE_OK) && (ii < *(*u322)(unsafe.Pointer(bp + 36 /* nRec */)))) && (iOff < iSize)) { goto __10 } rc = sqlite3.Xsqlite3OsRead(tls, pReal, bp+8 /* &zBuf[0] */, 4, iOff) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __11 } pgno = decodeUint32(tls, bp+8 /* &zBuf[0] */) @@ -67462,7 +63313,7 @@ __8: goto __13 } rc = sqlite3.Xsqlite3OsRead(tls, pReal, aPage, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize), (iOff + int64(4))) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __14 } cksum = genCksum(tls, aPage, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize)) @@ -67493,10 +63344,10 @@ __3: finish_rjf: start_ioerr_simulation(tls, *(*int32)(unsafe.Pointer(bp /* iSave */)), *(*int32)(unsafe.Pointer(bp + 4 /* iSave2 */))) sqlite3.Xsqlite3_free(tls, aPage) - if !(rc == (10 | (int32(2) << 8))) { + if !(rc == (SQLITE_IOERR | (int32(2) << 8))) { goto __15 } - rc = 0 + rc = SQLITE_OK __15: ; return rc @@ -67506,7 +63357,7 @@ __15: func jtWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_journal.c:512:12: */ var rc int32 var p uintptr = pFile - if ((*jt_file)(unsafe.Pointer(p)).Fflags & 0x00000800) != 0 { + if ((*jt_file)(unsafe.Pointer(p)).Fflags & SQLITE_OPEN_MAIN_JOURNAL) != 0 { if iOfst == int64(0) { var pMain uintptr = locateDatabaseHandle(tls, (*jt_file)(unsafe.Pointer(p)).FzName, 0) @@ -67518,9 +63369,9 @@ func jtWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlit // Writing the first journal header to a journal file. This happens // when a transaction is first started. var z uintptr = zBuf - (*jt_file)(unsafe.Pointer(pMain)).FnPage = decodeUint32(tls, (z + uintptr(16))) - (*jt_file)(unsafe.Pointer(pMain)).FnPagesize = decodeUint32(tls, (z + uintptr(24))) - if 0 != (libc.AssignInt32(&rc, openTransaction(tls, pMain, p))) { + (*jt_file)(unsafe.Pointer(pMain)).FnPage = decodeUint32(tls, (z + 16)) + (*jt_file)(unsafe.Pointer(pMain)).FnPagesize = decodeUint32(tls, (z + 24)) + if SQLITE_OK != (libc.AssignInt32(&rc, openTransaction(tls, pMain, p))) { return rc } } @@ -67530,7 +63381,7 @@ func jtWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlit } } - if (((*jt_file)(unsafe.Pointer(p)).Fflags & 0x00000100) != 0) && ((*jt_file)(unsafe.Pointer(p)).FpWritable != 0) { + if (((*jt_file)(unsafe.Pointer(p)).Fflags & SQLITE_OPEN_MAIN_DB) != 0) && ((*jt_file)(unsafe.Pointer(p)).FpWritable != 0) { if (((iAmt < int32((*jt_file)(unsafe.Pointer(p)).FnPagesize)) && (((*jt_file)(unsafe.Pointer(p)).FnPagesize % u322(iAmt)) == u322(0))) && (iOfst >= (sqlite_int64(sqlite3.Xsqlite3PendingByte + 512)))) && @@ -67551,10 +63402,10 @@ func jtWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlit } rc = sqlite3.Xsqlite3OsWrite(tls, (*jt_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) - if (((*jt_file)(unsafe.Pointer(p)).Fflags & 0x00000800) != 0) && (iAmt == 12) { + if (((*jt_file)(unsafe.Pointer(p)).Fflags & SQLITE_OPEN_MAIN_JOURNAL) != 0) && (iAmt == 12) { var pMain uintptr = locateDatabaseHandle(tls, (*jt_file)(unsafe.Pointer(p)).FzName, 0) var rc2 int32 = readJournalFile(tls, p, pMain) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } @@ -67564,12 +63415,12 @@ func jtWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlit // Truncate an jt-file. func jtTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* test_journal.c:580:12: */ var p uintptr = pFile - if (((*jt_file)(unsafe.Pointer(p)).Fflags & 0x00000800) != 0) && (size == int64(0)) { + if (((*jt_file)(unsafe.Pointer(p)).Fflags & SQLITE_OPEN_MAIN_JOURNAL) != 0) && (size == int64(0)) { // Truncating a journal file. This is the end of a transaction. var pMain uintptr = locateDatabaseHandle(tls, (*jt_file)(unsafe.Pointer(p)).FzName, 0) closeTransaction(tls, pMain) } - if (((*jt_file)(unsafe.Pointer(p)).Fflags & 0x00000100) != 0) && ((*jt_file)(unsafe.Pointer(p)).FpWritable != 0) { + if (((*jt_file)(unsafe.Pointer(p)).Fflags & SQLITE_OPEN_MAIN_DB) != 0) && ((*jt_file)(unsafe.Pointer(p)).FpWritable != 0) { var pgno u322 var locking_page u322 = ((u322(sqlite3.Xsqlite3PendingByte) / (*jt_file)(unsafe.Pointer(p)).FnPagesize) + u322(1)) _ = locking_page @@ -67584,7 +63435,7 @@ func jtTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* test func jtSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_journal.c:600:12: */ var p uintptr = pFile - if ((*jt_file)(unsafe.Pointer(p)).Fflags & 0x00000800) != 0 { + if ((*jt_file)(unsafe.Pointer(p)).Fflags & SQLITE_OPEN_MAIN_JOURNAL) != 0 { var rc int32 var pMain uintptr // The associated database file @@ -67598,7 +63449,7 @@ func jtSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_journal.c if (pMain != 0) && ((*jt_file)(unsafe.Pointer(pMain)).FpWritable != 0) { (*jt_file)(unsafe.Pointer(pMain)).FnSync++ rc = readJournalFile(tls, p, pMain) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -67618,7 +63469,7 @@ func jtLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_journal.c var rc int32 var p uintptr = pFile rc = sqlite3.Xsqlite3OsLock(tls, (*jt_file)(unsafe.Pointer(p)).FpReal, eLock) - if (rc == 0) && (eLock > (*jt_file)(unsafe.Pointer(p)).FeLock) { + if (rc == SQLITE_OK) && (eLock > (*jt_file)(unsafe.Pointer(p)).FeLock) { (*jt_file)(unsafe.Pointer(p)).FeLock = eLock } return rc @@ -67629,7 +63480,7 @@ func jtUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_journal var rc int32 var p uintptr = pFile rc = sqlite3.Xsqlite3OsUnlock(tls, (*jt_file)(unsafe.Pointer(p)).FpReal, eLock) - if (rc == 0) && (eLock < (*jt_file)(unsafe.Pointer(p)).FeLock) { + if (rc == SQLITE_OK) && (eLock < (*jt_file)(unsafe.Pointer(p)).FeLock) { (*jt_file)(unsafe.Pointer(p)).FeLock = eLock } return rc @@ -67664,11 +63515,11 @@ func jtOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int var rc int32 var p uintptr = pFile (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(0) - (*jt_file)(unsafe.Pointer(p)).FpReal = (p + uintptr(1)*80) + (*jt_file)(unsafe.Pointer(p)).FpReal = (p + 1*80) (*sqlite3_file)(unsafe.Pointer((*jt_file)(unsafe.Pointer(p)).FpReal)).FpMethods = uintptr(0) rc = sqlite3.Xsqlite3OsOpen(tls, g2.FpVfs, zName, (*jt_file)(unsafe.Pointer(p)).FpReal, flags, pOutFlags) - if rc == 0 { + if rc == SQLITE_OK { (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&jt_io_methods)) (*jt_file)(unsafe.Pointer(p)).FeLock = 0 (*jt_file)(unsafe.Pointer(p)).FzName = zName @@ -67775,7 +63626,7 @@ func jtGetLastError(tls *libc.TLS, pVfs uintptr, n int32, z uintptr) int32 { /* func jt_register(tls *libc.TLS, zWrap uintptr, isDefault int32) int32 { /* test_journal.c:847:5: */ g2.FpVfs = sqlite3.Xsqlite3_vfs_find(tls, zWrap) if g2.FpVfs == uintptr(0) { - return 1 + return SQLITE_ERROR } jt_vfs.FszOsFile = (int32(uint64(unsafe.Sizeof(jt_file{})) + uint64((*sqlite3_vfs)(unsafe.Pointer(g2.FpVfs)).FszOsFile))) if (*sqlite3_vfs)(unsafe.Pointer(g2.FpVfs)).FiVersion == 1 { @@ -67784,7 +63635,7 @@ func jt_register(tls *libc.TLS, zWrap uintptr, isDefault int32) int32 { /* test_ jt_vfs.FxCurrentTimeInt64 = uintptr(0) } sqlite3.Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&jt_vfs)), isDefault) - return 0 + return SQLITE_OK } // Uninstall the jt VFS, if it is installed. @@ -68131,13 +63982,13 @@ func faultsimInstall(tls *libc.TLS, install int32) int32 { /* test_malloc.c:180: }() if install == memfault.FisInstalled { - return 1 + return SQLITE_ERROR } if install != 0 { - rc = sqlite3.Xsqlite3_config(tls, 5, libc.VaList(bp, (uintptr(unsafe.Pointer(&memfault))+40 /* &.m */))) + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETMALLOC, libc.VaList(bp, (uintptr(unsafe.Pointer(&memfault))+40 /* &.m */))) - if rc == 0 { + if rc == SQLITE_OK { *(*sqlite3_mem_methods)(unsafe.Pointer(bp + 72 /* m */)) = memfault.Fm (*sqlite3_mem_methods)(unsafe.Pointer(bp + 72 /* &m */)).FxMalloc = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, int32) uintptr @@ -68145,9 +63996,9 @@ func faultsimInstall(tls *libc.TLS, install int32) int32 { /* test_malloc.c:180: (*sqlite3_mem_methods)(unsafe.Pointer(bp + 72 /* &m */)).FxRealloc = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32) uintptr }{faultsimRealloc})) - rc = sqlite3.Xsqlite3_config(tls, 4, libc.VaList(bp+8, bp+72 /* &m */)) + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp+8, bp+72 /* &m */)) } - sqlite3.Xsqlite3_test_control(tls, 10, + sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) }{faultsimBeginBenign})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) }{faultsimEndBenign})))) } else { // var m2 sqlite3_mem_methods at bp+136, 64 @@ -68155,15 +64006,15 @@ func faultsimInstall(tls *libc.TLS, install int32) int32 { /* test_malloc.c:180: // One should be able to reset the default memory allocator by storing // a zeroed allocator then calling GETMALLOC. libc.Xmemset(tls, bp+136 /* &m2 */, 0, uint64(unsafe.Sizeof(sqlite3_mem_methods{}))) - sqlite3.Xsqlite3_config(tls, 4, libc.VaList(bp+32, bp+136 /* &m2 */)) - sqlite3.Xsqlite3_config(tls, 5, libc.VaList(bp+40, bp+136 /* &m2 */)) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp+32, bp+136 /* &m2 */)) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETMALLOC, libc.VaList(bp+40, bp+136 /* &m2 */)) - rc = sqlite3.Xsqlite3_config(tls, 4, libc.VaList(bp+48, (uintptr(unsafe.Pointer(&memfault))+40 /* &.m */))) - sqlite3.Xsqlite3_test_control(tls, 10, + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp+48, (uintptr(unsafe.Pointer(&memfault))+40 /* &.m */))) + sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, libc.VaList(bp+56, uintptr(0), uintptr(0))) } - if rc == 0 { + if rc == SQLITE_OK { memfault.FisInstalled = 1 } return rc @@ -68212,7 +64063,7 @@ __2: goto __3 __3: ; - *(*int8)(unsafe.Pointer(z + uintptr((uint64(unsafe.Sizeof(uintptr(0))) * uint64(2))))) = int8(0) + *(*int8)(unsafe.Pointer(z + 16)) = int8(0) } var zHex = *(*[17]int8)(unsafe.Pointer(ts + 30030 /* "0123456789abcdef" */)) /* test_malloc.c:240:21 */ @@ -68236,16 +64087,16 @@ func textToPointer(tls *libc.TLS, z uintptr, pp uintptr) int32 { /* test_malloc. var i int32 // var u uint32 at bp+8, 4 - for i = 0; (uint64(i) < (uint64(unsafe.Sizeof(uintptr(0))) * uint64(2))) && (*(*int8)(unsafe.Pointer(z + uintptr(0))) != 0); i++ { + for i = 0; (uint64(i) < (uint64(unsafe.Sizeof(uintptr(0))) * uint64(2))) && (*(*int8)(unsafe.Pointer(z)) != 0); i++ { var v int32 v = hexToInt(tls, int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))) if v < 0 { - return 1 + return TCL_ERROR } *(*sqlite3_uint64)(unsafe.Pointer(bp /* n */)) = ((*(*sqlite3_uint64)(unsafe.Pointer(bp /* n */)) * uint64(16)) + sqlite3_uint64(v)) } if int32(*(*int8)(unsafe.Pointer(z))) != 0 { - return 1 + return TCL_ERROR } if uint64(unsafe.Sizeof(sqlite3_uint64(0))) == uint64(unsafe.Sizeof(uintptr(0))) { libc.Xmemcpy(tls, pp, bp /* &n */, uint64(unsafe.Sizeof(sqlite3_uint64(0)))) @@ -68255,7 +64106,7 @@ func textToPointer(tls *libc.TLS, z uintptr, pp uintptr) int32 { /* test_malloc. } else { } - return 0 + return TCL_OK } // Usage: sqlite3_malloc NBYTES @@ -68272,15 +64123,15 @@ func test_malloc(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31656 /* "NBYTES" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+16 /* &nByte */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &nByte */) != 0 { + return TCL_ERROR } p = sqlite3.Xsqlite3_malloc(tls, int32(uint32(*(*int32)(unsafe.Pointer(bp + 16 /* nByte */))))) pointerToText(tls, p, bp+20 /* &zOut[0] */) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, bp+20 /* &zOut[0] */, uintptr(0))) - return 0 + return TCL_OK } // Usage: sqlite3_realloc PRIOR NBYTES @@ -68299,19 +64150,19 @@ func test_realloc(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31663 /* "PRIOR NBYTES" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+40 /* &nByte */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &nByte */) != 0 { + return TCL_ERROR } - if textToPointer(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+48 /* &pPrior */) != 0 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31676 /* "bad pointer: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), uintptr(0))) - return 1 + if textToPointer(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &pPrior */) != 0 { + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31676 /* "bad pointer: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) + return TCL_ERROR } p = sqlite3.Xsqlite3_realloc(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* pPrior */)), int32(uint32(*(*int32)(unsafe.Pointer(bp + 40 /* nByte */))))) pointerToText(tls, p, bp+56 /* &zOut[0] */) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, bp+56 /* &zOut[0] */, uintptr(0))) - return 0 + return TCL_OK } // Usage: sqlite3_free PRIOR @@ -68325,14 +64176,14 @@ func test_free(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, ob if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31690 /* "PRIOR" */) - return 1 + return TCL_ERROR } - if textToPointer(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+24 /* &pPrior */) != 0 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31676 /* "bad pointer: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), uintptr(0))) - return 1 + if textToPointer(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+24 /* &pPrior */) != 0 { + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31676 /* "bad pointer: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) + return TCL_ERROR } sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pPrior */))) - return 0 + return TCL_OK } // Usage: memset ADDRESS SIZE HEX @@ -68356,33 +64207,33 @@ func test_memset(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31696 /* "ADDRESS SIZE HEX" */) - return 1 + return TCL_ERROR } - if textToPointer(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+56 /* &p */) != 0 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31676 /* "bad pointer: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), uintptr(0))) - return 1 + if textToPointer(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+56 /* &p */) != 0 { + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31676 /* "bad pointer: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+64 /* &size */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64 /* &size */) != 0 { + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 64 /* size */)) <= 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+31713 /* "size must be pos..." */, uintptr(0))) - return 1 + return TCL_ERROR } - zHex = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+68 /* &n */) + zHex = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+68 /* &n */) if uint64(*(*int32)(unsafe.Pointer(bp + 68 /* n */))) > (uint64(unsafe.Sizeof([100]int8{})) * uint64(2)) { *(*int32)(unsafe.Pointer(bp + 68 /* n */)) = (int32(uint64(unsafe.Sizeof([100]int8{})) * uint64(2))) } *(*int32)(unsafe.Pointer(bp + 68 /* n */)) = sqlite3TestHexToBin(tls, zHex, *(*int32)(unsafe.Pointer(bp + 68 /* n */)), bp+72 /* &zBin[0] */) if *(*int32)(unsafe.Pointer(bp + 68 /* n */)) == 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, ts+31735 /* "no data" */, uintptr(0))) - return 1 + return TCL_ERROR } zOut = *(*uintptr)(unsafe.Pointer(bp + 56 /* p */)) for i = 0; i < *(*int32)(unsafe.Pointer(bp + 64 /* size */)); i++ { *(*int8)(unsafe.Pointer(zOut + uintptr(i))) = *(*int8)(unsafe.Pointer(bp + 72 /* &zBin[0] */ + uintptr((i % *(*int32)(unsafe.Pointer(bp + 68 /* n */)))))) } - return 0 + return TCL_OK } // Usage: memget ADDRESS SIZE @@ -68402,18 +64253,18 @@ func test_memget(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31743 /* "ADDRESS SIZE" */) - return 1 + return TCL_ERROR } - if textToPointer(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+56 /* &p */) != 0 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31676 /* "bad pointer: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), uintptr(0))) - return 1 + if textToPointer(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+56 /* &p */) != 0 { + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31676 /* "bad pointer: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+64 /* &size */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64 /* &size */) != 0 { + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 64 /* size */)) <= 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+31713 /* "size must be pos..." */, uintptr(0))) - return 1 + return TCL_ERROR } zBin = *(*uintptr)(unsafe.Pointer(bp + 56 /* p */)) for *(*int32)(unsafe.Pointer(bp + 64 /* size */)) > 0 { @@ -68428,7 +64279,7 @@ func test_memget(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, sqlite3TestBinToHex(tls, bp+68 /* &zHex[0] */, n) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+68 /* &zHex[0] */, uintptr(0))) } - return 0 + return TCL_OK } // Usage: sqlite3_memory_used @@ -68436,7 +64287,7 @@ func test_memget(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, // Raw test interface for sqlite3_memory_used(). func test_memory_used(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:476:26: */ tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, sqlite3.Xsqlite3_memory_used(tls))) - return 0 + return TCL_OK } // Usage: sqlite3_memory_highwater ?RESETFLAG? @@ -68449,16 +64300,16 @@ func test_memory_highwater(tls *libc.TLS, clientData uintptr, interp uintptr, ob *(*int32)(unsafe.Pointer(bp /* resetFlag */)) = 0 if (objc != 1) && (objc != 2) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31756 /* "?RESET?" */) - return 1 + return TCL_ERROR } if objc == 2 { - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &resetFlag */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &resetFlag */) != 0 { + return TCL_ERROR } } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, sqlite3.Xsqlite3_memory_highwater(tls, *(*int32)(unsafe.Pointer(bp /* resetFlag */))))) - return 0 + return TCL_OK } // Usage: sqlite3_memdebug_backtrace DEPTH @@ -68473,12 +64324,12 @@ func test_memdebug_backtrace(tls *libc.TLS, clientData uintptr, interp uintptr, if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31764 /* "DEPT" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &depth */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &depth */) != 0 { + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_memdebug_dump FILENAME @@ -68487,9 +64338,9 @@ func test_memdebug_backtrace(tls *libc.TLS, clientData uintptr, interp uintptr, func test_memdebug_dump(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:542:26: */ if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31769 /* "FILENAME" */) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // Usage: sqlite3_memdebug_malloc_count @@ -68499,10 +64350,10 @@ func test_memdebug_malloc_count(tls *libc.TLS, clientData uintptr, interp uintpt var nMalloc int32 = -1 if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nMalloc)) - return 0 + return TCL_OK } // Usage: sqlite3_memdebug_fail COUNTER ?OPTIONS? @@ -68535,10 +64386,10 @@ func test_memdebug_fail(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc < 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31778 /* "COUNTER ?OPTIONS..." */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+24 /* &iFail */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+24 /* &iFail */) != 0 { + return TCL_ERROR } for ii = 2; ii < objc; ii = ii + (2) { @@ -68552,7 +64403,7 @@ func test_memdebug_fail(tls *libc.TLS, clientData uintptr, interp uintptr, objc zErr = ts + 12149 /* "option requires ..." */ } else { if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((ii+1))*8)), bp+32 /* &nRepeat */) != 0 { - return 1 + return TCL_ERROR } } } else if (*(*int32)(unsafe.Pointer(bp + 28 /* nOption */)) > 1) && (libc.Xstrncmp(tls, zOption, ts+31804 /* "-benigncnt" */, uint64(*(*int32)(unsafe.Pointer(bp + 28 /* nOption */)))) == 0) { @@ -68567,7 +64418,7 @@ func test_memdebug_fail(tls *libc.TLS, clientData uintptr, interp uintptr, objc if zErr != 0 { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, zErr, zOption, 0)) - return 1 + return TCL_ERROR } } @@ -68579,7 +64430,7 @@ func test_memdebug_fail(tls *libc.TLS, clientData uintptr, interp uintptr, objc tcl.XTcl_ObjSetVar2(tls, interp, pBenignCnt, uintptr(0), tcl.XTcl_NewIntObj(tls, nBenign), 0) } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nFail)) - return 0 + return TCL_OK } // Usage: sqlite3_memdebug_pending @@ -68591,11 +64442,11 @@ func test_memdebug_pending(tls *libc.TLS, clientData uintptr, interp uintptr, ob var nPending int32 if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } nPending = faultsimPending(tls) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nPending)) - return 0 + return TCL_OK } // The following global variable keeps track of the number of tests @@ -68615,9 +64466,9 @@ func test_memdebug_settitle(tls *libc.TLS, clientData uintptr, interp uintptr, o sqlite3_memdebug_title_count++ if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31815 /* "TITLE" */) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } var aMallocLog Tcl_HashTable /* test_malloc.c:732:22: */ @@ -68669,8 +64520,8 @@ func test_memdebug_log(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc < 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31821 /* "SUB-COMMAND ..." */) } - if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), uintptr(unsafe.Pointer(&MB_strs)), int32(unsafe.Sizeof(uintptr(0))), ts+1874 /* "sub-command" */, 0, bp /* &iSub */) != 0 { - return 1 + if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&MB_strs)), int32(unsafe.Sizeof(uintptr(0))), ts+1874 /* "sub-command" */, 0, bp /* &iSub */) != 0 { + return TCL_ERROR } switch uint32(*(*int32)(unsafe.Pointer(bp /* iSub */))) { @@ -68699,14 +64550,14 @@ func test_memdebug_log(tls *libc.TLS, clientData uintptr, interp uintptr, objc i }() var ii int32 - *(*uintptr)(unsafe.Pointer(bp + 32 /* &apElem[0] */ + uintptr(0)*8)) = tcl.XTcl_NewIntObj(tls, (*MallocLog)(unsafe.Pointer(pLog)).FnCall) - *(*uintptr)(unsafe.Pointer(bp + 32 /* &apElem[0] */ + uintptr(1)*8)) = tcl.XTcl_NewIntObj(tls, (*MallocLog)(unsafe.Pointer(pLog)).FnByte) - for ii = 0; ii < 10; ii++ { + *(*uintptr)(unsafe.Pointer(bp + 32 /* &apElem[0] */)) = tcl.XTcl_NewIntObj(tls, (*MallocLog)(unsafe.Pointer(pLog)).FnCall) + *(*uintptr)(unsafe.Pointer(bp + 32 /* &apElem[0] */ + 1*8)) = tcl.XTcl_NewIntObj(tls, (*MallocLog)(unsafe.Pointer(pLog)).FnByte) + for ii = 0; ii < MALLOC_LOG_FRAMES; ii++ { *(*uintptr)(unsafe.Pointer(bp + 32 /* &apElem[0] */ + uintptr((ii+2))*8)) = tcl.XTcl_NewWideIntObj(tls, *(*Tcl_WideInt)(unsafe.Pointer(aKey + uintptr(ii)*8))) } tcl.XTcl_ListObjAppendElement(tls, interp, pRet, - tcl.XTcl_NewListObj(tls, (10+2), bp+32 /* &apElem[0] */)) + tcl.XTcl_NewListObj(tls, (MALLOC_LOG_FRAMES+2), bp+32 /* &apElem[0] */)) } tcl.XTcl_SetObjResult(tls, interp, pRet) @@ -68727,7 +64578,7 @@ func test_memdebug_log(tls *libc.TLS, clientData uintptr, interp uintptr, objc i } } - return 0 + return TCL_OK } var isInit int32 = 0 /* test_malloc.c:793:14 */ @@ -68752,13 +64603,13 @@ func test_config_pagecache(tls *libc.TLS, clientData uintptr, interp uintptr, ob var pRes uintptr if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31864 /* "SIZE N" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+48 /* &sz */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+48 /* &sz */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+52 /* &N */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+52 /* &N */) != 0 { + return TCL_ERROR } libc.Xfree(tls, buf1) buf1 = uintptr(0) @@ -68770,12 +64621,12 @@ func test_config_pagecache(tls *libc.TLS, clientData uintptr, interp uintptr, ob tcl.XTcl_SetObjResult(tls, interp, pRes) if *(*int32)(unsafe.Pointer(bp + 48 /* sz */)) < 0 { - sqlite3.Xsqlite3_config(tls, 7, libc.VaList(bp, uintptr(0), 0, 0)) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PAGECACHE, libc.VaList(bp, uintptr(0), 0, 0)) } else { buf1 = libc.Xmalloc(tls, (uint64(*(*int32)(unsafe.Pointer(bp + 48 /* sz */)) * *(*int32)(unsafe.Pointer(bp + 52 /* N */))))) - sqlite3.Xsqlite3_config(tls, 7, libc.VaList(bp+24, buf1, *(*int32)(unsafe.Pointer(bp + 48 /* sz */)), *(*int32)(unsafe.Pointer(bp + 52 /* N */)))) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PAGECACHE, libc.VaList(bp+24, buf1, *(*int32)(unsafe.Pointer(bp + 48 /* sz */)), *(*int32)(unsafe.Pointer(bp + 52 /* N */)))) } - return 0 + return TCL_OK } var buf1 uintptr = uintptr(0) /* test_malloc.c:893:15 */ @@ -68800,28 +64651,28 @@ func test_alt_pcache(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if (objc < 2) || (objc > 5) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31871 /* "INSTALLFLAG DISC..." */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+16 /* &installFlag */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &installFlag */) != 0 { + return TCL_ERROR } - if (objc >= 3) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+20 /* &discardChance */) != 0) { - return 1 + if (objc >= 3) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+20 /* &discardChance */) != 0) { + return TCL_ERROR } - if (objc >= 4) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+24 /* &prngSeed */) != 0) { - return 1 + if (objc >= 4) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+24 /* &prngSeed */) != 0) { + return TCL_ERROR } - if (objc >= 5) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+28 /* &highStress */) != 0) { - return 1 + if (objc >= 5) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+28 /* &highStress */) != 0) { + return TCL_ERROR } if (*(*int32)(unsafe.Pointer(bp + 20 /* discardChance */)) < 0) || (*(*int32)(unsafe.Pointer(bp + 20 /* discardChance */)) > 100) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31918, /* "discard-chance s..." */ uintptr(0))) - return 1 + return TCL_ERROR } installTestPCache(tls, *(*int32)(unsafe.Pointer(bp + 16 /* installFlag */)), uint32(*(*int32)(unsafe.Pointer(bp + 20 /* discardChance */))), uint32(*(*int32)(unsafe.Pointer(bp + 24 /* prngSeed */))), uint32(*(*int32)(unsafe.Pointer(bp + 28 /* highStress */)))) - return 0 + return TCL_OK } // Usage: sqlite3_config_memstatus BOOLEAN @@ -68836,14 +64687,14 @@ func test_config_memstatus(tls *libc.TLS, clientData uintptr, interp uintptr, ob var rc int32 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17539 /* "BOOLEAN" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+8 /* &enable */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8 /* &enable */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_config(tls, 9, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* enable */)))) + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MEMSTATUS, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* enable */)))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } // Usage: sqlite3_config_lookaside SIZE COUNT @@ -68859,22 +64710,22 @@ func test_config_lookaside(tls *libc.TLS, clientData uintptr, interp uintptr, ob var pRet uintptr if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31961 /* "SIZE COUNT" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+16 /* &sz */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &sz */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+20 /* &cnt */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+20 /* &cnt */) != 0 { + return TCL_ERROR } pRet = tcl.XTcl_NewObj(tls) tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3Config.FszLookaside)) tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3Config.FnLookaside)) - sqlite3.Xsqlite3_config(tls, 13, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 16 /* sz */)), *(*int32)(unsafe.Pointer(bp + 20 /* cnt */)))) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_LOOKASIDE, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 16 /* sz */)), *(*int32)(unsafe.Pointer(bp + 20 /* cnt */)))) tcl.XTcl_SetObjResult(tls, interp, pRet) - return 0 + return TCL_OK } // Usage: sqlite3_db_config_lookaside CONNECTION BUFID SIZE COUNT @@ -68897,30 +64748,30 @@ func test_db_config_lookaside(tls *libc.TLS, clientData uintptr, interp uintptr, if objc != 5 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31972 /* "BUFID SIZE COUNT" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+64 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+64 /* &db */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+72 /* &bufid */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+72 /* &bufid */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+76 /* &sz */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+76 /* &sz */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+80 /* &cnt */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+80 /* &cnt */) != 0 { + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 72 /* bufid */)) == 0 { - rc = sqlite3.Xsqlite3_db_config(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), 1001, libc.VaList(bp, uintptr(0), *(*int32)(unsafe.Pointer(bp + 76 /* sz */)), *(*int32)(unsafe.Pointer(bp + 80 /* cnt */)))) + 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 */)))) } 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{}))) { - rc = sqlite3.Xsqlite3_db_config(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), 1001, 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 */)))) + 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 */)))) } else { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+31989 /* "illegal argument..." */, uintptr(0))) - return 1 + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } var azBuf [2][10000]int8 /* test_malloc.c:1034:15: */ @@ -68936,31 +64787,31 @@ func test_config_heap(tls *libc.TLS, clientData uintptr, interp uintptr, objc in // Size of minimum allocation var rc int32 // Return code of sqlite3_config() - var aArg uintptr = (objv + uintptr(1)*8) + var aArg uintptr = (objv + 1*8) var nArg int32 = (objc - 1) if nArg != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32027 /* "NBYTE NMINALLOC" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(aArg + uintptr(0)*8)), bp+48 /* &nByte */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(aArg)), bp+48 /* &nByte */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(aArg + uintptr(1)*8)), bp+52 /* &nMinAlloc */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(aArg + 1*8)), bp+52 /* &nMinAlloc */) != 0 { + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 48 /* nByte */)) == 0 { libc.Xfree(tls, zBuf) zBuf = uintptr(0) - rc = sqlite3.Xsqlite3_config(tls, 8, libc.VaList(bp, uintptr(0), 0, 0)) + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_HEAP, libc.VaList(bp, uintptr(0), 0, 0)) } else { zBuf = libc.Xrealloc(tls, zBuf, uint64(*(*int32)(unsafe.Pointer(bp + 48 /* nByte */)))) - rc = sqlite3.Xsqlite3_config(tls, 8, libc.VaList(bp+24, zBuf, *(*int32)(unsafe.Pointer(bp + 48 /* nByte */)), *(*int32)(unsafe.Pointer(bp + 52 /* nMinAlloc */)))) + 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 */)))) } tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 0 + return TCL_OK } var zBuf uintptr /* test_malloc.c:1065:15: */ @@ -68974,21 +64825,21 @@ func test_config_heap_size(tls *libc.TLS, clientData uintptr, interp uintptr, ob // Size to pass to sqlite3_config() var rc int32 // Return code of sqlite3_config() - var aArg uintptr = (objv + uintptr(1)*8) + var aArg uintptr = (objv + 1*8) var nArg int32 = (objc - 1) if nArg != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15722 /* "NBYTE" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(aArg + uintptr(0)*8)), bp+8 /* &nByte */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(aArg)), bp+8 /* &nByte */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_config(tls, 23, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* nByte */)))) + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_WIN32_HEAPSIZE, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* nByte */)))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 0 + return TCL_OK } // Usage: sqlite3_config_error [DB] @@ -69003,27 +64854,27 @@ func test_config_error(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if (objc != 2) && (objc != 1) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32043 /* "[DB]" */) - return 1 + return TCL_ERROR } if objc == 2 { - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+32 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { + return TCL_ERROR } - if sqlite3.Xsqlite3_db_config(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), 99999, 0) != 1 { + if sqlite3.Xsqlite3_db_config(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), 99999, 0) != SQLITE_ERROR { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+32048, /* "sqlite3_db_confi..." */ uintptr(0))) - return 1 + return TCL_ERROR } } else { - if sqlite3.Xsqlite3_config(tls, 99999, 0) != 1 { + if sqlite3.Xsqlite3_config(tls, 99999, 0) != SQLITE_ERROR { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+32106, /* "sqlite3_config(9..." */ uintptr(0))) - return 1 + return TCL_ERROR } } - return 0 + return TCL_OK } // Usage: sqlite3_config_uri BOOLEAN @@ -69039,16 +64890,16 @@ func test_config_uri(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18252 /* "BOOL" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+8 /* &bOpenUri */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8 /* &bOpenUri */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_config(tls, 17, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* bOpenUri */)))) + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_URI, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* bOpenUri */)))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 0 + return TCL_OK } // Usage: sqlite3_config_cis BOOLEAN @@ -69064,16 +64915,16 @@ func test_config_cis(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18252 /* "BOOL" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+8 /* &bUseCis */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8 /* &bUseCis */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_config(tls, 20, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* bUseCis */)))) + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_COVERING_INDEX_SCAN, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* bUseCis */)))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 0 + return TCL_OK } // Usage: sqlite3_config_pmasz INTEGER @@ -69088,16 +64939,16 @@ func test_config_pmasz(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18252 /* "BOOL" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+8 /* &iPmaSz */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8 /* &iPmaSz */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_config(tls, 25, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* iPmaSz */)))) + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PMASZ, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* iPmaSz */)))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 0 + return TCL_OK } // Usage: sqlite3_dump_memsys3 FILENAME @@ -69107,7 +64958,7 @@ func test_config_pmasz(tls *libc.TLS, clientData uintptr, interp uintptr, objc i func test_dump_memsys3(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1251:26: */ if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31769 /* "FILENAME" */) - return 1 + return TCL_ERROR } switch int32(clientData) { @@ -69121,7 +64972,7 @@ func test_dump_memsys3(tls *libc.TLS, clientData uintptr, interp uintptr, objc i } } - return 0 + return TCL_OK } // Usage: sqlite3_status OPCODE RESETFLAG @@ -69145,9 +64996,9 @@ func test_status(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, var pResult uintptr if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32157 /* "PARAMETER RESETF..." */) - return 1 + return TCL_ERROR } - zOpName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zOpName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) for i = 0; i < (int32(uint64(unsafe.Sizeof(aOp1)) / uint64(unsafe.Sizeof(struct { FzName uintptr Fop int32 @@ -69163,12 +65014,12 @@ func test_status(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, Fop int32 _ [4]byte }{})))) { - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &op */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &op */) != 0 { + return TCL_ERROR } } - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+4 /* &resetFlag */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+4 /* &resetFlag */) != 0 { + return TCL_ERROR } *(*int32)(unsafe.Pointer(bp + 8 /* iValue */)) = 0 *(*int32)(unsafe.Pointer(bp + 12 /* mxValue */)) = 0 @@ -69178,7 +65029,7 @@ func test_status(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pResult, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 8 /* iValue */)))) tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pResult, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 12 /* mxValue */)))) tcl.XTcl_SetObjResult(tls, interp, pResult) - return 0 + return TCL_OK } var aOp1 = [10]struct { @@ -69186,36 +65037,16 @@ var aOp1 = [10]struct { Fop int32 _ [4]byte }{ - { - FzName: ts + 32177, /* "SQLITE_STATUS_ME..." */ - Fop: 0}, - { - FzName: ts + 32203, /* "SQLITE_STATUS_MA..." */ - Fop: 5}, - { - FzName: ts + 32229, /* "SQLITE_STATUS_PA..." */ - Fop: 1}, - { - FzName: ts + 32258, /* "SQLITE_STATUS_PA..." */ - Fop: 2}, - { - FzName: ts + 32291, /* "SQLITE_STATUS_PA..." */ - Fop: 7}, - { - FzName: ts + 32320, /* "SQLITE_STATUS_SC..." */ - Fop: 3}, - { - FzName: ts + 32347, /* "SQLITE_STATUS_SC..." */ - Fop: 4}, - { - FzName: ts + 32378, /* "SQLITE_STATUS_SC..." */ - Fop: 8}, - { - FzName: ts + 32405, /* "SQLITE_STATUS_PA..." */ - Fop: 6}, - { - FzName: ts + 32432, /* "SQLITE_STATUS_MA..." */ - Fop: 9}, + {FzName: ts + 32177 /* "SQLITE_STATUS_ME..." */}, + {FzName: ts + 32203 /* "SQLITE_STATUS_MA..." */, Fop: SQLITE_STATUS_MALLOC_SIZE}, + {FzName: ts + 32229 /* "SQLITE_STATUS_PA..." */, Fop: SQLITE_STATUS_PAGECACHE_USED}, + {FzName: ts + 32258 /* "SQLITE_STATUS_PA..." */, Fop: SQLITE_STATUS_PAGECACHE_OVERFLOW}, + {FzName: ts + 32291 /* "SQLITE_STATUS_PA..." */, Fop: SQLITE_STATUS_PAGECACHE_SIZE}, + {FzName: ts + 32320 /* "SQLITE_STATUS_SC..." */, Fop: SQLITE_STATUS_SCRATCH_USED}, + {FzName: ts + 32347 /* "SQLITE_STATUS_SC..." */, Fop: SQLITE_STATUS_SCRATCH_OVERFLOW}, + {FzName: ts + 32378 /* "SQLITE_STATUS_SC..." */, Fop: SQLITE_STATUS_SCRATCH_SIZE}, + {FzName: ts + 32405 /* "SQLITE_STATUS_PA..." */, Fop: SQLITE_STATUS_PARSER_STACK}, + {FzName: ts + 32432 /* "SQLITE_STATUS_MA..." */, Fop: SQLITE_STATUS_MALLOC_COUNT}, } /* test_malloc.c:1299:5 */ // Usage: sqlite3_db_status DATABASE OPCODE RESETFLAG @@ -69241,12 +65072,12 @@ func test_db_status(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 var pResult uintptr if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32459 /* "DB PARAMETER RES..." */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - zOpName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zOpName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if libc.Xmemcmp(tls, zOpName, ts+32482 /* "SQLITE_" */, uint64(7)) == 0 { zOpName += uintptr(7) } @@ -69268,12 +65099,12 @@ func test_db_status(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 Fop int32 _ [4]byte }{})))) { - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+8 /* &op */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &op */) != 0 { + return TCL_ERROR } } - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+12 /* &resetFlag */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+12 /* &resetFlag */) != 0 { + return TCL_ERROR } *(*int32)(unsafe.Pointer(bp + 16 /* iValue */)) = 0 *(*int32)(unsafe.Pointer(bp + 20 /* mxValue */)) = 0 @@ -69283,7 +65114,7 @@ func test_db_status(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pResult, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 16 /* iValue */)))) tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pResult, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 20 /* mxValue */)))) tcl.XTcl_SetObjResult(tls, interp, pResult) - return 0 + return TCL_OK } var aOp2 = [13]struct { @@ -69291,45 +65122,19 @@ var aOp2 = [13]struct { Fop int32 _ [4]byte }{ - { - FzName: ts + 32500, /* "LOOKASIDE_USED" */ - Fop: 0}, - { - FzName: ts + 32515, /* "CACHE_USED" */ - Fop: 1}, - { - FzName: ts + 32526, /* "SCHEMA_USED" */ - Fop: 2}, - { - FzName: ts + 32538, /* "STMT_USED" */ - Fop: 3}, - { - FzName: ts + 32548, /* "LOOKASIDE_HIT" */ - Fop: 4}, - { - FzName: ts + 32562, /* "LOOKASIDE_MISS_S..." */ - Fop: 5}, - { - FzName: ts + 32582, /* "LOOKASIDE_MISS_F..." */ - Fop: 6}, - { - FzName: ts + 32602, /* "CACHE_HIT" */ - Fop: 7}, - { - FzName: ts + 32612, /* "CACHE_MISS" */ - Fop: 8}, - { - FzName: ts + 32623, /* "CACHE_WRITE" */ - Fop: 9}, - { - FzName: ts + 32635, /* "DEFERRED_FKS" */ - Fop: 10}, - { - FzName: ts + 32648, /* "CACHE_USED_SHARE..." */ - Fop: 11}, - { - FzName: ts + 32666, /* "CACHE_SPILL" */ - Fop: 12}, + {FzName: ts + 32500 /* "LOOKASIDE_USED" */}, + {FzName: ts + 32515 /* "CACHE_USED" */, Fop: SQLITE_DBSTATUS_CACHE_USED}, + {FzName: ts + 32526 /* "SCHEMA_USED" */, Fop: SQLITE_DBSTATUS_SCHEMA_USED}, + {FzName: ts + 32538 /* "STMT_USED" */, Fop: SQLITE_DBSTATUS_STMT_USED}, + {FzName: ts + 32548 /* "LOOKASIDE_HIT" */, Fop: SQLITE_DBSTATUS_LOOKASIDE_HIT}, + {FzName: ts + 32562 /* "LOOKASIDE_MISS_S..." */, Fop: SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE}, + {FzName: ts + 32582 /* "LOOKASIDE_MISS_F..." */, Fop: SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL}, + {FzName: ts + 32602 /* "CACHE_HIT" */, Fop: SQLITE_DBSTATUS_CACHE_HIT}, + {FzName: ts + 32612 /* "CACHE_MISS" */, Fop: SQLITE_DBSTATUS_CACHE_MISS}, + {FzName: ts + 32623 /* "CACHE_WRITE" */, Fop: SQLITE_DBSTATUS_CACHE_WRITE}, + {FzName: ts + 32635 /* "DEFERRED_FKS" */, Fop: SQLITE_DBSTATUS_DEFERRED_FKS}, + {FzName: ts + 32648 /* "CACHE_USED_SHARE..." */, Fop: SQLITE_DBSTATUS_CACHE_USED_SHARED}, + {FzName: ts + 32666 /* "CACHE_SPILL" */, Fop: SQLITE_DBSTATUS_CACHE_SPILL}, } /* test_malloc.c:1358:5 */ // install_malloc_faultsim BOOLEAN @@ -69342,21 +65147,21 @@ func test_install_malloc_faultsim(tls *libc.TLS, clientData uintptr, interp uint if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17539 /* "BOOLEAN" */) - return 1 + return TCL_ERROR } - if 0 != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &isInstall */) { - return 1 + if TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &isInstall */) { + return TCL_ERROR } rc = faultsimInstall(tls, *(*int32)(unsafe.Pointer(bp /* isInstall */))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 0 + return TCL_OK } // sqlite3_install_memsys3 func test_install_memsys3(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1430:26: */ - var rc int32 = 21 + var rc int32 = SQLITE_MISUSE tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 0 + return TCL_OK } func test_vfs_oom_test(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1445:26: */ @@ -69365,17 +65170,17 @@ func test_vfs_oom_test(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc > 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32678 /* "?INTEGER?" */) - return 1 + return TCL_ERROR } else if objc == 2 { // var iNew int32 at bp, 4 - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &iNew */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &iNew */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_memdebug_vfs_oom_test = *(*int32)(unsafe.Pointer(bp /* iNew */)) } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_memdebug_vfs_oom_test)) - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -69390,7 +65195,7 @@ func Sqlitetest_malloc_Init(tls *libc.TLS, interp uintptr) int32 { /* test_mallo var c ClientData = uintptr(intptr_t(aObjCmd11[i].FclientData)) tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd11[i].FzName, aObjCmd11[i].FxProc, c, uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd11 = [32]struct { @@ -69399,134 +65204,38 @@ var aObjCmd11 = [32]struct { FclientData int32 _ [4]byte }{ - { - FzName: ts + 27048, /* "sqlite3_malloc" */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 27063, /* "sqlite3_realloc" */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32688, /* "sqlite3_free" */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32701, /* "memset" */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32708, /* "memget" */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32715, /* "sqlite3_memory_u..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32735, /* "sqlite3_memory_h..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32760, /* "sqlite3_memdebug..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32787, /* "sqlite3_memdebug..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32809, /* "sqlite3_memdebug..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32831, /* "sqlite3_memdebug..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32856, /* "sqlite3_memdebug..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32882, /* "sqlite3_memdebug..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32912, /* "sqlite3_memdebug..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32933, /* "sqlite3_config_p..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32958, /* "sqlite3_config_a..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32984, /* "sqlite3_status" */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 32999, /* "sqlite3_db_statu..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 33017, /* "install_malloc_f..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 33041, /* "sqlite3_config_h..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 33061, /* "sqlite3_config_h..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 33086, /* "sqlite3_config_m..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 33111, /* "sqlite3_config_l..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 33136, /* "sqlite3_config_e..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 33157, /* "sqlite3_config_u..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 33176, /* "sqlite3_config_c..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 33195, /* "sqlite3_config_p..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 33216, /* "sqlite3_db_confi..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 33244, /* "sqlite3_dump_mem..." */ - FxProc: 0, - FclientData: 3}, - { - FzName: ts + 33265, /* "sqlite3_dump_mem..." */ - FxProc: 0, - FclientData: 5}, - { - FzName: ts + 33286, /* "sqlite3_install_..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 33310, /* "sqlite3_memdebug..." */ - FxProc: 0, - FclientData: 0}, + {FzName: ts + 27048 /* "sqlite3_malloc" */, FxProc: 0}, + {FzName: ts + 27063 /* "sqlite3_realloc" */, FxProc: 0}, + {FzName: ts + 32688 /* "sqlite3_free" */, FxProc: 0}, + {FzName: ts + 32701 /* "memset" */, FxProc: 0}, + {FzName: ts + 32708 /* "memget" */, FxProc: 0}, + {FzName: ts + 32715 /* "sqlite3_memory_u..." */, FxProc: 0}, + {FzName: ts + 32735 /* "sqlite3_memory_h..." */, FxProc: 0}, + {FzName: ts + 32760 /* "sqlite3_memdebug..." */, FxProc: 0}, + {FzName: ts + 32787 /* "sqlite3_memdebug..." */, FxProc: 0}, + {FzName: ts + 32809 /* "sqlite3_memdebug..." */, FxProc: 0}, + {FzName: ts + 32831 /* "sqlite3_memdebug..." */, FxProc: 0}, + {FzName: ts + 32856 /* "sqlite3_memdebug..." */, FxProc: 0}, + {FzName: ts + 32882 /* "sqlite3_memdebug..." */, FxProc: 0}, + {FzName: ts + 32912 /* "sqlite3_memdebug..." */, FxProc: 0}, + {FzName: ts + 32933 /* "sqlite3_config_p..." */, FxProc: 0}, + {FzName: ts + 32958 /* "sqlite3_config_a..." */, FxProc: 0}, + {FzName: ts + 32984 /* "sqlite3_status" */, FxProc: 0}, + {FzName: ts + 32999 /* "sqlite3_db_statu..." */, FxProc: 0}, + {FzName: ts + 33017 /* "install_malloc_f..." */, FxProc: 0}, + {FzName: ts + 33041 /* "sqlite3_config_h..." */, FxProc: 0}, + {FzName: ts + 33061 /* "sqlite3_config_h..." */, FxProc: 0}, + {FzName: ts + 33086 /* "sqlite3_config_m..." */, FxProc: 0}, + {FzName: ts + 33111 /* "sqlite3_config_l..." */, FxProc: 0}, + {FzName: ts + 33136 /* "sqlite3_config_e..." */, FxProc: 0}, + {FzName: ts + 33157 /* "sqlite3_config_u..." */, FxProc: 0}, + {FzName: ts + 33176 /* "sqlite3_config_c..." */, FxProc: 0}, + {FzName: ts + 33195 /* "sqlite3_config_p..." */, FxProc: 0}, + {FzName: ts + 33216 /* "sqlite3_db_confi..." */, FxProc: 0}, + {FzName: ts + 33244 /* "sqlite3_dump_mem..." */, FxProc: 0, FclientData: 3}, + {FzName: ts + 33265 /* "sqlite3_dump_mem..." */, FxProc: 0, FclientData: 5}, + {FzName: ts + 33286 /* "sqlite3_install_..." */, FxProc: 0}, + {FzName: ts + 33310 /* "sqlite3_memdebug..." */, FxProc: 0}, } /* test_malloc.c:1472:5 */ // Some versions of define this macros. @@ -69578,7 +65287,7 @@ type MD5Context = MD5Context1 /* test_md5.c:63:27 */ func byteReverse(tls *libc.TLS, buf uintptr, longs uint32) { /* test_md5.c:68:13: */ var t uint32 for ok := true; ok; ok = libc.PreDecUint32(&longs, 1) != 0 { - t = ((((uint32(*(*uint8)(unsafe.Pointer(buf + uintptr(3)))) << 8) | uint32(*(*uint8)(unsafe.Pointer(buf + uintptr(2))))) << 16) | ((uint32(*(*uint8)(unsafe.Pointer(buf + uintptr(1)))) << 8) | uint32(*(*uint8)(unsafe.Pointer(buf + uintptr(0)))))) + 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))))) *(*uint32)(unsafe.Pointer(buf)) = t buf += uintptr(4) } @@ -69599,223 +65308,223 @@ func MD5Transform(tls *libc.TLS, buf uintptr, in uintptr) { /* test_md5.c:94:13: var c uint32 var d uint32 - a = *(*uint32)(unsafe.Pointer(buf + uintptr(0)*4)) - b = *(*uint32)(unsafe.Pointer(buf + uintptr(1)*4)) - c = *(*uint32)(unsafe.Pointer(buf + uintptr(2)*4)) - d = *(*uint32)(unsafe.Pointer(buf + uintptr(3)*4)) + a = *(*uint32)(unsafe.Pointer(buf)) + b = *(*uint32)(unsafe.Pointer(buf + 1*4)) + c = *(*uint32)(unsafe.Pointer(buf + 2*4)) + d = *(*uint32)(unsafe.Pointer(buf + 3*4)) - a = a + (((d ^ (b & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + uintptr(0)*4))) + 0xd76aa478) + a = a + (((d ^ (b & (c ^ d))) + *(*uint32)(unsafe.Pointer(in))) + 0xd76aa478) a = ((a << 7) | (a >> (32 - 7))) a = a + (b) - d = d + (((c ^ (a & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + uintptr(1)*4))) + 0xe8c7b756) + d = d + (((c ^ (a & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 1*4))) + 0xe8c7b756) d = ((d << 12) | (d >> (32 - 12))) d = d + (a) - c = c + (((b ^ (d & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + uintptr(2)*4))) + uint32(0x242070db)) + c = c + (((b ^ (d & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 2*4))) + uint32(0x242070db)) c = ((c << 17) | (c >> (32 - 17))) c = c + (d) - b = b + (((a ^ (c & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + uintptr(3)*4))) + 0xc1bdceee) + b = b + (((a ^ (c & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 3*4))) + 0xc1bdceee) b = ((b << 22) | (b >> (32 - 22))) b = b + (c) - a = a + (((d ^ (b & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + uintptr(4)*4))) + 0xf57c0faf) + a = a + (((d ^ (b & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + 4*4))) + 0xf57c0faf) a = ((a << 7) | (a >> (32 - 7))) a = a + (b) - d = d + (((c ^ (a & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + uintptr(5)*4))) + uint32(0x4787c62a)) + d = d + (((c ^ (a & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 5*4))) + uint32(0x4787c62a)) d = ((d << 12) | (d >> (32 - 12))) d = d + (a) - c = c + (((b ^ (d & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + uintptr(6)*4))) + 0xa8304613) + c = c + (((b ^ (d & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 6*4))) + 0xa8304613) c = ((c << 17) | (c >> (32 - 17))) c = c + (d) - b = b + (((a ^ (c & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + uintptr(7)*4))) + 0xfd469501) + b = b + (((a ^ (c & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 7*4))) + 0xfd469501) b = ((b << 22) | (b >> (32 - 22))) b = b + (c) - a = a + (((d ^ (b & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + uintptr(8)*4))) + uint32(0x698098d8)) + a = a + (((d ^ (b & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + 8*4))) + uint32(0x698098d8)) a = ((a << 7) | (a >> (32 - 7))) a = a + (b) - d = d + (((c ^ (a & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + uintptr(9)*4))) + 0x8b44f7af) + d = d + (((c ^ (a & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 9*4))) + 0x8b44f7af) d = ((d << 12) | (d >> (32 - 12))) d = d + (a) - c = c + (((b ^ (d & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + uintptr(10)*4))) + 0xffff5bb1) + c = c + (((b ^ (d & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 10*4))) + 0xffff5bb1) c = ((c << 17) | (c >> (32 - 17))) c = c + (d) - b = b + (((a ^ (c & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + uintptr(11)*4))) + 0x895cd7be) + b = b + (((a ^ (c & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 11*4))) + 0x895cd7be) b = ((b << 22) | (b >> (32 - 22))) b = b + (c) - a = a + (((d ^ (b & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + uintptr(12)*4))) + uint32(0x6b901122)) + a = a + (((d ^ (b & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + 12*4))) + uint32(0x6b901122)) a = ((a << 7) | (a >> (32 - 7))) a = a + (b) - d = d + (((c ^ (a & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + uintptr(13)*4))) + 0xfd987193) + d = d + (((c ^ (a & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 13*4))) + 0xfd987193) d = ((d << 12) | (d >> (32 - 12))) d = d + (a) - c = c + (((b ^ (d & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + uintptr(14)*4))) + 0xa679438e) + c = c + (((b ^ (d & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 14*4))) + 0xa679438e) c = ((c << 17) | (c >> (32 - 17))) c = c + (d) - b = b + (((a ^ (c & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + uintptr(15)*4))) + uint32(0x49b40821)) + b = b + (((a ^ (c & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 15*4))) + uint32(0x49b40821)) b = ((b << 22) | (b >> (32 - 22))) b = b + (c) - a = a + (((c ^ (d & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + uintptr(1)*4))) + 0xf61e2562) + a = a + (((c ^ (d & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 1*4))) + 0xf61e2562) a = ((a << 5) | (a >> (32 - 5))) a = a + (b) - d = d + (((b ^ (c & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + uintptr(6)*4))) + 0xc040b340) + d = d + (((b ^ (c & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 6*4))) + 0xc040b340) d = ((d << 9) | (d >> (32 - 9))) d = d + (a) - c = c + (((a ^ (b & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + uintptr(11)*4))) + uint32(0x265e5a51)) + c = c + (((a ^ (b & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 11*4))) + uint32(0x265e5a51)) c = ((c << 14) | (c >> (32 - 14))) c = c + (d) - b = b + (((d ^ (a & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + uintptr(0)*4))) + 0xe9b6c7aa) + b = b + (((d ^ (a & (c ^ d))) + *(*uint32)(unsafe.Pointer(in))) + 0xe9b6c7aa) b = ((b << 20) | (b >> (32 - 20))) b = b + (c) - a = a + (((c ^ (d & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + uintptr(5)*4))) + 0xd62f105d) + a = a + (((c ^ (d & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 5*4))) + 0xd62f105d) a = ((a << 5) | (a >> (32 - 5))) a = a + (b) - d = d + (((b ^ (c & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + uintptr(10)*4))) + uint32(0x02441453)) + d = d + (((b ^ (c & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 10*4))) + uint32(0x02441453)) d = ((d << 9) | (d >> (32 - 9))) d = d + (a) - c = c + (((a ^ (b & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + uintptr(15)*4))) + 0xd8a1e681) + c = c + (((a ^ (b & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 15*4))) + 0xd8a1e681) c = ((c << 14) | (c >> (32 - 14))) c = c + (d) - b = b + (((d ^ (a & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + uintptr(4)*4))) + 0xe7d3fbc8) + b = b + (((d ^ (a & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + 4*4))) + 0xe7d3fbc8) b = ((b << 20) | (b >> (32 - 20))) b = b + (c) - a = a + (((c ^ (d & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + uintptr(9)*4))) + uint32(0x21e1cde6)) + a = a + (((c ^ (d & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 9*4))) + uint32(0x21e1cde6)) a = ((a << 5) | (a >> (32 - 5))) a = a + (b) - d = d + (((b ^ (c & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + uintptr(14)*4))) + 0xc33707d6) + d = d + (((b ^ (c & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 14*4))) + 0xc33707d6) d = ((d << 9) | (d >> (32 - 9))) d = d + (a) - c = c + (((a ^ (b & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + uintptr(3)*4))) + 0xf4d50d87) + c = c + (((a ^ (b & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 3*4))) + 0xf4d50d87) c = ((c << 14) | (c >> (32 - 14))) c = c + (d) - b = b + (((d ^ (a & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + uintptr(8)*4))) + uint32(0x455a14ed)) + b = b + (((d ^ (a & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + 8*4))) + uint32(0x455a14ed)) b = ((b << 20) | (b >> (32 - 20))) b = b + (c) - a = a + (((c ^ (d & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + uintptr(13)*4))) + 0xa9e3e905) + a = a + (((c ^ (d & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 13*4))) + 0xa9e3e905) a = ((a << 5) | (a >> (32 - 5))) a = a + (b) - d = d + (((b ^ (c & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + uintptr(2)*4))) + 0xfcefa3f8) + d = d + (((b ^ (c & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 2*4))) + 0xfcefa3f8) d = ((d << 9) | (d >> (32 - 9))) d = d + (a) - c = c + (((a ^ (b & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + uintptr(7)*4))) + uint32(0x676f02d9)) + c = c + (((a ^ (b & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 7*4))) + uint32(0x676f02d9)) c = ((c << 14) | (c >> (32 - 14))) c = c + (d) - b = b + (((d ^ (a & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + uintptr(12)*4))) + 0x8d2a4c8a) + b = b + (((d ^ (a & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + 12*4))) + 0x8d2a4c8a) b = ((b << 20) | (b >> (32 - 20))) b = b + (c) - a = a + ((((b ^ c) ^ d) + *(*uint32)(unsafe.Pointer(in + uintptr(5)*4))) + 0xfffa3942) + a = a + ((((b ^ c) ^ d) + *(*uint32)(unsafe.Pointer(in + 5*4))) + 0xfffa3942) a = ((a << 4) | (a >> (32 - 4))) a = a + (b) - d = d + ((((a ^ b) ^ c) + *(*uint32)(unsafe.Pointer(in + uintptr(8)*4))) + 0x8771f681) + d = d + ((((a ^ b) ^ c) + *(*uint32)(unsafe.Pointer(in + 8*4))) + 0x8771f681) d = ((d << 11) | (d >> (32 - 11))) d = d + (a) - c = c + ((((d ^ a) ^ b) + *(*uint32)(unsafe.Pointer(in + uintptr(11)*4))) + uint32(0x6d9d6122)) + c = c + ((((d ^ a) ^ b) + *(*uint32)(unsafe.Pointer(in + 11*4))) + uint32(0x6d9d6122)) c = ((c << 16) | (c >> (32 - 16))) c = c + (d) - b = b + ((((c ^ d) ^ a) + *(*uint32)(unsafe.Pointer(in + uintptr(14)*4))) + 0xfde5380c) + b = b + ((((c ^ d) ^ a) + *(*uint32)(unsafe.Pointer(in + 14*4))) + 0xfde5380c) b = ((b << 23) | (b >> (32 - 23))) b = b + (c) - a = a + ((((b ^ c) ^ d) + *(*uint32)(unsafe.Pointer(in + uintptr(1)*4))) + 0xa4beea44) + a = a + ((((b ^ c) ^ d) + *(*uint32)(unsafe.Pointer(in + 1*4))) + 0xa4beea44) a = ((a << 4) | (a >> (32 - 4))) a = a + (b) - d = d + ((((a ^ b) ^ c) + *(*uint32)(unsafe.Pointer(in + uintptr(4)*4))) + uint32(0x4bdecfa9)) + d = d + ((((a ^ b) ^ c) + *(*uint32)(unsafe.Pointer(in + 4*4))) + uint32(0x4bdecfa9)) d = ((d << 11) | (d >> (32 - 11))) d = d + (a) - c = c + ((((d ^ a) ^ b) + *(*uint32)(unsafe.Pointer(in + uintptr(7)*4))) + 0xf6bb4b60) + c = c + ((((d ^ a) ^ b) + *(*uint32)(unsafe.Pointer(in + 7*4))) + 0xf6bb4b60) c = ((c << 16) | (c >> (32 - 16))) c = c + (d) - b = b + ((((c ^ d) ^ a) + *(*uint32)(unsafe.Pointer(in + uintptr(10)*4))) + 0xbebfbc70) + b = b + ((((c ^ d) ^ a) + *(*uint32)(unsafe.Pointer(in + 10*4))) + 0xbebfbc70) b = ((b << 23) | (b >> (32 - 23))) b = b + (c) - a = a + ((((b ^ c) ^ d) + *(*uint32)(unsafe.Pointer(in + uintptr(13)*4))) + uint32(0x289b7ec6)) + a = a + ((((b ^ c) ^ d) + *(*uint32)(unsafe.Pointer(in + 13*4))) + uint32(0x289b7ec6)) a = ((a << 4) | (a >> (32 - 4))) a = a + (b) - d = d + ((((a ^ b) ^ c) + *(*uint32)(unsafe.Pointer(in + uintptr(0)*4))) + 0xeaa127fa) + d = d + ((((a ^ b) ^ c) + *(*uint32)(unsafe.Pointer(in))) + 0xeaa127fa) d = ((d << 11) | (d >> (32 - 11))) d = d + (a) - c = c + ((((d ^ a) ^ b) + *(*uint32)(unsafe.Pointer(in + uintptr(3)*4))) + 0xd4ef3085) + c = c + ((((d ^ a) ^ b) + *(*uint32)(unsafe.Pointer(in + 3*4))) + 0xd4ef3085) c = ((c << 16) | (c >> (32 - 16))) c = c + (d) - b = b + ((((c ^ d) ^ a) + *(*uint32)(unsafe.Pointer(in + uintptr(6)*4))) + uint32(0x04881d05)) + b = b + ((((c ^ d) ^ a) + *(*uint32)(unsafe.Pointer(in + 6*4))) + uint32(0x04881d05)) b = ((b << 23) | (b >> (32 - 23))) b = b + (c) - a = a + ((((b ^ c) ^ d) + *(*uint32)(unsafe.Pointer(in + uintptr(9)*4))) + 0xd9d4d039) + a = a + ((((b ^ c) ^ d) + *(*uint32)(unsafe.Pointer(in + 9*4))) + 0xd9d4d039) a = ((a << 4) | (a >> (32 - 4))) a = a + (b) - d = d + ((((a ^ b) ^ c) + *(*uint32)(unsafe.Pointer(in + uintptr(12)*4))) + 0xe6db99e5) + d = d + ((((a ^ b) ^ c) + *(*uint32)(unsafe.Pointer(in + 12*4))) + 0xe6db99e5) d = ((d << 11) | (d >> (32 - 11))) d = d + (a) - c = c + ((((d ^ a) ^ b) + *(*uint32)(unsafe.Pointer(in + uintptr(15)*4))) + uint32(0x1fa27cf8)) + c = c + ((((d ^ a) ^ b) + *(*uint32)(unsafe.Pointer(in + 15*4))) + uint32(0x1fa27cf8)) c = ((c << 16) | (c >> (32 - 16))) c = c + (d) - b = b + ((((c ^ d) ^ a) + *(*uint32)(unsafe.Pointer(in + uintptr(2)*4))) + 0xc4ac5665) + b = b + ((((c ^ d) ^ a) + *(*uint32)(unsafe.Pointer(in + 2*4))) + 0xc4ac5665) b = ((b << 23) | (b >> (32 - 23))) b = b + (c) - a = a + (((c ^ (b | ^d)) + *(*uint32)(unsafe.Pointer(in + uintptr(0)*4))) + 0xf4292244) + a = a + (((c ^ (b | ^d)) + *(*uint32)(unsafe.Pointer(in))) + 0xf4292244) a = ((a << 6) | (a >> (32 - 6))) a = a + (b) - d = d + (((b ^ (a | ^c)) + *(*uint32)(unsafe.Pointer(in + uintptr(7)*4))) + uint32(0x432aff97)) + d = d + (((b ^ (a | ^c)) + *(*uint32)(unsafe.Pointer(in + 7*4))) + uint32(0x432aff97)) d = ((d << 10) | (d >> (32 - 10))) d = d + (a) - c = c + (((a ^ (d | ^b)) + *(*uint32)(unsafe.Pointer(in + uintptr(14)*4))) + 0xab9423a7) + c = c + (((a ^ (d | ^b)) + *(*uint32)(unsafe.Pointer(in + 14*4))) + 0xab9423a7) c = ((c << 15) | (c >> (32 - 15))) c = c + (d) - b = b + (((d ^ (c | ^a)) + *(*uint32)(unsafe.Pointer(in + uintptr(5)*4))) + 0xfc93a039) + b = b + (((d ^ (c | ^a)) + *(*uint32)(unsafe.Pointer(in + 5*4))) + 0xfc93a039) b = ((b << 21) | (b >> (32 - 21))) b = b + (c) - a = a + (((c ^ (b | ^d)) + *(*uint32)(unsafe.Pointer(in + uintptr(12)*4))) + uint32(0x655b59c3)) + a = a + (((c ^ (b | ^d)) + *(*uint32)(unsafe.Pointer(in + 12*4))) + uint32(0x655b59c3)) a = ((a << 6) | (a >> (32 - 6))) a = a + (b) - d = d + (((b ^ (a | ^c)) + *(*uint32)(unsafe.Pointer(in + uintptr(3)*4))) + 0x8f0ccc92) + d = d + (((b ^ (a | ^c)) + *(*uint32)(unsafe.Pointer(in + 3*4))) + 0x8f0ccc92) d = ((d << 10) | (d >> (32 - 10))) d = d + (a) - c = c + (((a ^ (d | ^b)) + *(*uint32)(unsafe.Pointer(in + uintptr(10)*4))) + 0xffeff47d) + c = c + (((a ^ (d | ^b)) + *(*uint32)(unsafe.Pointer(in + 10*4))) + 0xffeff47d) c = ((c << 15) | (c >> (32 - 15))) c = c + (d) - b = b + (((d ^ (c | ^a)) + *(*uint32)(unsafe.Pointer(in + uintptr(1)*4))) + 0x85845dd1) + b = b + (((d ^ (c | ^a)) + *(*uint32)(unsafe.Pointer(in + 1*4))) + 0x85845dd1) b = ((b << 21) | (b >> (32 - 21))) b = b + (c) - a = a + (((c ^ (b | ^d)) + *(*uint32)(unsafe.Pointer(in + uintptr(8)*4))) + uint32(0x6fa87e4f)) + a = a + (((c ^ (b | ^d)) + *(*uint32)(unsafe.Pointer(in + 8*4))) + uint32(0x6fa87e4f)) a = ((a << 6) | (a >> (32 - 6))) a = a + (b) - d = d + (((b ^ (a | ^c)) + *(*uint32)(unsafe.Pointer(in + uintptr(15)*4))) + 0xfe2ce6e0) + d = d + (((b ^ (a | ^c)) + *(*uint32)(unsafe.Pointer(in + 15*4))) + 0xfe2ce6e0) d = ((d << 10) | (d >> (32 - 10))) d = d + (a) - c = c + (((a ^ (d | ^b)) + *(*uint32)(unsafe.Pointer(in + uintptr(6)*4))) + 0xa3014314) + c = c + (((a ^ (d | ^b)) + *(*uint32)(unsafe.Pointer(in + 6*4))) + 0xa3014314) c = ((c << 15) | (c >> (32 - 15))) c = c + (d) - b = b + (((d ^ (c | ^a)) + *(*uint32)(unsafe.Pointer(in + uintptr(13)*4))) + uint32(0x4e0811a1)) + b = b + (((d ^ (c | ^a)) + *(*uint32)(unsafe.Pointer(in + 13*4))) + uint32(0x4e0811a1)) b = ((b << 21) | (b >> (32 - 21))) b = b + (c) - a = a + (((c ^ (b | ^d)) + *(*uint32)(unsafe.Pointer(in + uintptr(4)*4))) + 0xf7537e82) + a = a + (((c ^ (b | ^d)) + *(*uint32)(unsafe.Pointer(in + 4*4))) + 0xf7537e82) a = ((a << 6) | (a >> (32 - 6))) a = a + (b) - d = d + (((b ^ (a | ^c)) + *(*uint32)(unsafe.Pointer(in + uintptr(11)*4))) + 0xbd3af235) + d = d + (((b ^ (a | ^c)) + *(*uint32)(unsafe.Pointer(in + 11*4))) + 0xbd3af235) d = ((d << 10) | (d >> (32 - 10))) d = d + (a) - c = c + (((a ^ (d | ^b)) + *(*uint32)(unsafe.Pointer(in + uintptr(2)*4))) + uint32(0x2ad7d2bb)) + c = c + (((a ^ (d | ^b)) + *(*uint32)(unsafe.Pointer(in + 2*4))) + uint32(0x2ad7d2bb)) c = ((c << 15) | (c >> (32 - 15))) c = c + (d) - b = b + (((d ^ (c | ^a)) + *(*uint32)(unsafe.Pointer(in + uintptr(9)*4))) + 0xeb86d391) + b = b + (((d ^ (c | ^a)) + *(*uint32)(unsafe.Pointer(in + 9*4))) + 0xeb86d391) b = ((b << 21) | (b >> (32 - 21))) b = b + (c) - *(*uint32)(unsafe.Pointer(buf + uintptr(0)*4)) += (a) - *(*uint32)(unsafe.Pointer(buf + uintptr(1)*4)) += (b) - *(*uint32)(unsafe.Pointer(buf + uintptr(2)*4)) += (c) - *(*uint32)(unsafe.Pointer(buf + uintptr(3)*4)) += (d) + *(*uint32)(unsafe.Pointer(buf)) += (a) + *(*uint32)(unsafe.Pointer(buf + 1*4)) += (b) + *(*uint32)(unsafe.Pointer(buf + 2*4)) += (c) + *(*uint32)(unsafe.Pointer(buf + 3*4)) += (d) } // Start MD5 accumulation. Set bit count to 0 and buffer to mysterious // initialization constants. func MD5Init(tls *libc.TLS, ctx uintptr) { /* test_md5.c:180:13: */ (*MD5Context)(unsafe.Pointer(ctx)).FisInit = 1 - *(*uint32)(unsafe.Pointer((ctx + 4 /* &.buf */) + uintptr(0)*4)) = uint32(0x67452301) - *(*uint32)(unsafe.Pointer((ctx + 4 /* &.buf */) + uintptr(1)*4)) = 0xefcdab89 - *(*uint32)(unsafe.Pointer((ctx + 4 /* &.buf */) + uintptr(2)*4)) = 0x98badcfe - *(*uint32)(unsafe.Pointer((ctx + 4 /* &.buf */) + uintptr(3)*4)) = uint32(0x10325476) - *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */) + uintptr(0)*4)) = uint32(0) - *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */) + uintptr(1)*4)) = uint32(0) + *(*uint32)(unsafe.Pointer((ctx + 4 /* &.buf */))) = uint32(0x67452301) + *(*uint32)(unsafe.Pointer((ctx + 4 /* &.buf */) + 1*4)) = 0xefcdab89 + *(*uint32)(unsafe.Pointer((ctx + 4 /* &.buf */) + 2*4)) = 0x98badcfe + *(*uint32)(unsafe.Pointer((ctx + 4 /* &.buf */) + 3*4)) = uint32(0x10325476) + *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */))) = uint32(0) + *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */) + 1*4)) = uint32(0) } // Update context to reflect the concatenation of another buffer full @@ -69825,11 +65534,11 @@ func MD5Update(tls *libc.TLS, ctx uintptr, buf uintptr, len uint32) { /* test_md // Update bitcount - t = *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */) + uintptr(0)*4)) - if (libc.AssignPtrUint32((ctx+20 /* &.bits */)+uintptr(0)*4, (t + (len << 3)))) < t { - *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */) + uintptr(1)*4))++ + t = *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */))) + if (libc.AssignPtrUint32((ctx + 20 /* &.bits */), (t + (len << 3)))) < t { + *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */) + 1*4))++ } // Carry from low to high - *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */) + uintptr(1)*4)) += (len >> 29) + *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */) + 1*4)) += (len >> 29) t = ((t >> 3) & uint32(0x3f)) // Bytes already in shsInfo->data @@ -69872,7 +65581,7 @@ func MD5Final(tls *libc.TLS, digest uintptr, ctx uintptr) { /* test_md5.c:243:13 var p uintptr // Compute number of bytes mod 64 - count = ((*(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */) + uintptr(0)*4)) >> 3) & uint32(0x3F)) + count = ((*(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */))) >> 3) & uint32(0x3F)) // Set the first char of padding to 0x80. This is safe since there is // always at least one byte free @@ -69956,17 +65665,17 @@ func md5_cmd(tls *libc.TLS, cd uintptr, interp uintptr, argc int32, argv uintptr var converter uintptr if argc != 2 { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14814 /* " TEXT\"" */, uintptr(0))) - return 1 + return TCL_ERROR } MD5Init(tls, bp+48 /* &ctx */) - MD5Update(tls, bp+48 /* &ctx */, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uint32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))))) + MD5Update(tls, bp+48 /* &ctx */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uint32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))))) MD5Final(tls, bp+140 /* &digest[0] */, bp+48 /* &ctx */) converter = cd (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&converter)))(tls, bp+140 /* &digest[0] */, bp+156 /* &zBuf[0] */) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+156 /* &zBuf[0] */, uintptr(0))) - return 0 + return TCL_OK } // A TCL command to take the md5 hash of a file. The argument is the @@ -69986,24 +65695,24 @@ func md5file_cmd(tls *libc.TLS, cd uintptr, interp uintptr, argc int32, argv uin // var zBuf [10240]int8 at bp+172, 10240 if (argc != 2) && (argc != 4) { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+33345 /* " FILENAME [OFFSE..." */, uintptr(0))) - return 1 + return TCL_ERROR } if argc == 4 { - ofst = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) - amt = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) + ofst = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) + amt = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) } else { ofst = 0 amt = 2147483647 } - in = libc.Xfopen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+4086 /* "rb" */) + in = libc.Xfopen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+4086 /* "rb" */) if in == uintptr(0) { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+33369 /* "unable to open f..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+33369 /* "unable to open f..." */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+33391 /* "\" for reading" */, uintptr(0))) - return 1 + return TCL_ERROR } - libc.Xfseek(tls, in, int64(ofst), 0) + libc.Xfseek(tls, in, int64(ofst), SEEK_SET) MD5Init(tls, bp+80 /* &ctx */) for amt > 0 { var n int32 @@ -70024,7 +65733,7 @@ func md5file_cmd(tls *libc.TLS, cd uintptr, interp uintptr, argc int32, argv uin converter = cd (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&converter)))(tls, bp+10412 /* &digest[0] */, bp+172 /* &zBuf[0] */) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, bp+172 /* &zBuf[0] */, uintptr(0))) - return 0 + return TCL_OK } // Register the four new TCL commands for generating MD5 checksums @@ -70054,7 +65763,7 @@ func Md5_Init(tls *libc.TLS, interp uintptr) int32 { /* test_md5.c:400:5: */ *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) }{MD5DigestToBase10x8})), uintptr(0)) - return 0 + return TCL_OK } // During testing, the special md5sum() aggregate function is available. @@ -70096,7 +65805,7 @@ func md5finalize(tls *libc.TLS, context uintptr) { /* test_md5.c:432:13: */ } func Md5_Register(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pThunk uintptr) int32 { /* test_md5.c:441:5: */ - var rc int32 = sqlite3.Xsqlite3_create_function(tls, db, ts+33439 /* "md5sum" */, -1, 1, uintptr(0), uintptr(0), + var rc int32 = sqlite3.Xsqlite3_create_function(tls, db, ts+33439 /* "md5sum" */, -1, SQLITE_UTF8, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{md5step})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{md5finalize}))) @@ -70269,7 +65978,7 @@ func multiplexFilename(tls *libc.TLS, zBase uintptr, nBase int32, flags int32, i var n int32 = nBase libc.Xmemcpy(tls, zOut, zBase, (uint64(n + 1))) - if (iChunk != 0) && (iChunk <= 299) { + if (iChunk != 0) && (iChunk <= MX_CHUNK_NUMBER) { sqlite3.Xsqlite3_snprintf(tls, 4, (zOut + uintptr(n)), ts+33446 /* "%03d" */, libc.VaList(bp, iChunk)) n = n + (3) } @@ -70283,7 +65992,7 @@ func multiplexSubFilename(tls *libc.TLS, pGroup uintptr, iChunk int32) int32 { / var p uintptr p = sqlite3.Xsqlite3_realloc64(tls, (*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal, (uint64((uint64(iChunk + 1)) * uint64(unsafe.Sizeof(multiplexReal{}))))) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, (p + uintptr((*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal)*16), 0, (uint64(unsafe.Sizeof(multiplexReal{})) * (uint64((iChunk + 1) - (*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal)))) (*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal = p @@ -70294,16 +66003,16 @@ func multiplexSubFilename(tls *libc.TLS, pGroup uintptr, iChunk int32) int32 { / var n int32 = (*multiplexGroup)(unsafe.Pointer(pGroup)).FnName z = sqlite3.Xsqlite3_malloc64(tls, (uint64(n + 5))) if z == uintptr(0) { - return 7 + return SQLITE_NOMEM } multiplexFilename(tls, (*multiplexGroup)(unsafe.Pointer(pGroup)).FzName, (*multiplexGroup)(unsafe.Pointer(pGroup)).FnName, (*multiplexGroup)(unsafe.Pointer(pGroup)).Fflags, iChunk, z) (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal + uintptr(iChunk)*16)).Fz = sqlite3.Xsqlite3_create_filename(tls, z, ts+488 /* "" */, ts+488 /* "" */, 0, uintptr(0)) sqlite3.Xsqlite3_free(tls, z) if (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz == uintptr(0) { - return 7 + return SQLITE_NOMEM } } - return 0 + return SQLITE_OK } // Translate an sqlite3_file* that is really a multiplexGroup* into @@ -70320,20 +66029,20 @@ func multiplexSubOpen(tls *libc.TLS, pGroup uintptr, iChunk int32, rc uintptr, p var pOrigVfs uintptr = gMultiplex.FpOrigVfs // Real VFS *(*int32)(unsafe.Pointer(rc)) = multiplexSubFilename(tls, pGroup, iChunk) - if ((*(*int32)(unsafe.Pointer(rc))) == 0) && ((libc.AssignUintptr(&pSubOpen, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fp)) == uintptr(0)) { + if ((*(*int32)(unsafe.Pointer(rc))) == SQLITE_OK) && ((libc.AssignUintptr(&pSubOpen, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fp)) == uintptr(0)) { var flags int32 // var bExists int32 at bp+16, 4 flags = (*multiplexGroup)(unsafe.Pointer(pGroup)).Fflags if createFlag != 0 { - flags = flags | (0x00000004) + flags = flags | (SQLITE_OPEN_CREATE) } else if iChunk == 0 { // Fall through } else if (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz == uintptr(0) { return uintptr(0) } else { *(*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, - 0, bp+16 /* &bExists */) + SQLITE_ACCESS_EXISTS, bp+16 /* &bExists */) if (*(*int32)(unsafe.Pointer(rc)) != 0) || !(*(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) != 0) { if *(*int32)(unsafe.Pointer(rc)) != 0 { sqlite3.Xsqlite3_log(tls, *(*int32)(unsafe.Pointer(rc)), ts+33451, /* "multiplexor.xAcc..." */ @@ -70341,17 +66050,17 @@ func multiplexSubOpen(tls *libc.TLS, pGroup uintptr, iChunk int32, rc uintptr, p } return uintptr(0) } - flags = flags & (^libc.Int32(0x00000004)) + flags = flags & (libc.CplInt32(SQLITE_OPEN_CREATE)) } pSubOpen = sqlite3.Xsqlite3_malloc64(tls, uint64((*sqlite3_vfs)(unsafe.Pointer(pOrigVfs)).FszOsFile)) if pSubOpen == uintptr(0) { - *(*int32)(unsafe.Pointer(rc)) = (10 | (int32(12) << 8)) + *(*int32)(unsafe.Pointer(rc)) = (SQLITE_IOERR | (int32(12) << 8)) return uintptr(0) } (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal + uintptr(iChunk)*16)).Fp = pSubOpen *(*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, flags, pOutFlags) - if (*(*int32)(unsafe.Pointer(rc))) != 0 { + if (*(*int32)(unsafe.Pointer(rc))) != SQLITE_OK { sqlite3.Xsqlite3_log(tls, *(*int32)(unsafe.Pointer(rc)), ts+33485, /* "multiplexor.xOpe..." */ libc.VaList(bp+8, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz)) sqlite3.Xsqlite3_free(tls, pSubOpen) @@ -70388,37 +66097,37 @@ func multiplexControlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintp bp := tls.Alloc(4) defer tls.Free(4) - var rc int32 = 0 + var rc int32 = SQLITE_OK var db uintptr = sqlite3.Xsqlite3_context_db_handle(tls, context) var op int32 = 0 // var iVal int32 at bp, 4 if !(db != 0) || (argc != 2) { - rc = 1 + rc = SQLITE_ERROR } else { // extract params - op = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - *(*int32)(unsafe.Pointer(bp /* iVal */)) = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + op = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) + *(*int32)(unsafe.Pointer(bp /* iVal */)) = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) // map function op to file_control op switch op { case 1: - op = 214014 + op = MULTIPLEX_CTRL_ENABLE break fallthrough case 2: - op = 214015 + op = MULTIPLEX_CTRL_SET_CHUNK_SIZE break fallthrough case 3: - op = 214016 + op = MULTIPLEX_CTRL_SET_MAX_CHUNKS break fallthrough default: - rc = 12 + rc = SQLITE_NOTFOUND break } } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_file_control(tls, db, uintptr(0), op, bp /* &iVal */) } sqlite3.Xsqlite3_result_error_code(tls, context, rc) @@ -70428,7 +66137,7 @@ func multiplexControlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintp // multiplex_control() function. func multiplexFuncInit(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* test_multiplex.c:417:12: */ var rc int32 - rc = sqlite3.Xsqlite3_create_function(tls, db, ts+33517 /* "multiplex_contro..." */, 2, 5, + rc = sqlite3.Xsqlite3_create_function(tls, db, ts+33517 /* "multiplex_contro..." */, 2, SQLITE_ANY, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{multiplexControlFunc})), uintptr(0), uintptr(0)) @@ -70471,11 +66180,11 @@ func multiplexOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pConn uintptr, fl bp := tls.Alloc(20) defer tls.Free(20) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 // Result code - var pMultiplexOpen uintptr // The new multiplex file descriptor - var pGroup uintptr = uintptr(0) // Corresponding multiplexGroup object - var pSubOpen uintptr = uintptr(0) // Real file descriptor - var pOrigVfs uintptr = gMultiplex.FpOrigVfs // Real VFS + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK // Result code + var pMultiplexOpen uintptr // The new multiplex file descriptor + var pGroup uintptr = uintptr(0) // Corresponding multiplexGroup object + var pSubOpen uintptr = uintptr(0) // Real file descriptor + var pOrigVfs uintptr = gMultiplex.FpOrigVfs // Real VFS var nName int32 = 0 var sz int32 = 0 var zToFree uintptr = uintptr(0) @@ -70487,7 +66196,7 @@ func multiplexOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pConn uintptr, fl // access to this group of files. pMultiplexOpen = pConn - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { // allocate space for group if zName != 0 { nName = multiplexStrlen30(tls, zName) @@ -70498,13 +66207,13 @@ func multiplexOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pConn uintptr, fl uint64(nName)) + uint64(1))) // zName pGroup = sqlite3.Xsqlite3_malloc64(tls, uint64(sz)) if pGroup == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_NOMEM } } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { var zUri uintptr - if (flags & 0x00000040) != 0 { + if (flags & SQLITE_OPEN_URI) != 0 { zUri = zName } else { zUri = uintptr(0) @@ -70514,12 +66223,12 @@ func multiplexOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pConn uintptr, fl (*multiplexConn)(unsafe.Pointer(pMultiplexOpen)).FpGroup = pGroup (*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled = libc.Uint8(libc.Uint8FromInt32(-1)) (*multiplexGroup)(unsafe.Pointer(pGroup)).FbTruncate = uint8(sqlite3.Xsqlite3_uri_boolean(tls, zUri, ts+17605, /* "truncate" */ - (libc.Bool32((flags & 0x00000100) == 0)))) + (libc.Bool32((flags & SQLITE_OPEN_MAIN_DB) == 0)))) (*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk = uint32(int32(sqlite3.Xsqlite3_uri_int64(tls, zUri, ts+33535, /* "chunksize" */ - int64(2147418112)))) - (*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk = (((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk + uint32(0xffff)) & ^libc.Uint32FromInt32(0xffff)) + SQLITE_MULTIPLEX_CHUNK_SIZE))) + (*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk = (((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk + uint32(0xffff)) & libc.Uint32FromInt32(libc.CplInt32(0xffff))) if zName != 0 { - var p uintptr = (pGroup + uintptr(1)*40) + var p uintptr = (pGroup + 1*40) (*multiplexGroup)(unsafe.Pointer(pGroup)).FzName = p libc.Xmemcpy(tls, (*multiplexGroup)(unsafe.Pointer(pGroup)).FzName, zName, (uint64(nName + 1))) (*multiplexGroup)(unsafe.Pointer(pGroup)).FnName = nName @@ -70529,35 +66238,35 @@ func multiplexOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pConn uintptr, fl *(*uint32)(unsafe.Pointer(pGroup + 32 /* &.szChunk */)) += (uint32(65536)) } } - (*multiplexGroup)(unsafe.Pointer(pGroup)).Fflags = (flags & ^libc.Int32(0x00000040)) + (*multiplexGroup)(unsafe.Pointer(pGroup)).Fflags = (flags & libc.CplInt32(SQLITE_OPEN_URI)) *(*int32)(unsafe.Pointer(bp /* rc */)) = multiplexSubFilename(tls, pGroup, 1) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { pSubOpen = multiplexSubOpen(tls, pGroup, 0, bp /* &rc */, pOutFlags, 0) - if (pSubOpen == uintptr(0)) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 14 + if (pSubOpen == uintptr(0)) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) { + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_CANTOPEN } } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { // var sz64 sqlite3_int64 at bp+8, 8 *(*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 */) - if (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (zName != 0) { + if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (zName != 0) { // var bExists int32 at bp+16, 4 - if (flags & 0x00004000) != 0 { + if (flags & SQLITE_OPEN_SUPER_JOURNAL) != 0 { (*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled = uint8(0) } else if *(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* sz64 */)) == int64(0) { - if (flags & 0x00000800) != 0 { + if (flags & SQLITE_OPEN_MAIN_JOURNAL) != 0 { // If opening a main journal file and the first chunk is zero // bytes in size, delete any subsequent chunks from the // file-system. var iChunk int32 = 1 - for ok := true; ok; ok = ((*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (*(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) != 0)) { + for ok := true; ok; ok = ((*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) != 0)) { *(*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+uintptr(iChunk)*16)).Fz, 0, bp+16 /* &bExists */) - if (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (*(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) != 0) { + (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz, SQLITE_ACCESS_EXISTS, bp+16 /* &bExists */) + if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) != 0) { *(*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) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = multiplexSubFilename(tls, pGroup, libc.PreIncInt32(&iChunk, 1)) } } @@ -70572,20 +66281,20 @@ func multiplexOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pConn uintptr, fl // larger than the chunk size, that means the chunk size is too small. // But we have no way of determining the intended chunk size, so // just disable the multiplexor all togethre. - *(*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+uintptr(1)*16)).Fz, - 0, bp+16 /* &bExists */) + *(*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, + SQLITE_ACCESS_EXISTS, bp+16 /* &bExists */) *(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) = (libc.Bool32(multiplexSubSize(tls, pGroup, 1, bp /* &rc */) > int64(0))) - if ((((*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (*(*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))) && + 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))) && (*(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* sz64 */)) != sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk)) { (*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk = uint32(int32(*(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* sz64 */)))) - } else if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && !(*(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) != 0)) && (*(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* sz64 */)) > sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk)) { + } 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)) { (*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled = uint8(0) } } } } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { if (*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods)).FiVersion == 1 { (*sqlite3_file)(unsafe.Pointer(pConn)).FpMethods = (uintptr(unsafe.Pointer(&gMultiplex)) + 176 /* &.sIoMethodsV1 */) } else { @@ -70609,34 +66318,34 @@ func multiplexDelete(tls *libc.TLS, pVfs uintptr, zName uintptr, syncDir int32) var rc int32 var pOrigVfs uintptr = gMultiplex.FpOrigVfs // Real VFS rc = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pOrigVfs + 48 /* &.xDelete */))))(tls, pOrigVfs, zName, syncDir) - if rc == 0 { + if rc == SQLITE_OK { // If the main chunk was deleted successfully, also delete any subsequent // chunks - starting with the last (highest numbered). var nName int32 = int32(libc.Xstrlen(tls, zName)) var z uintptr z = sqlite3.Xsqlite3_malloc64(tls, (uint64(nName + 5))) if z == uintptr(0) { - rc = (10 | (int32(12) << 8)) + rc = (SQLITE_IOERR | (int32(12) << 8)) } else { var iChunk int32 = 0 // var bExists int32 at bp, 4 - for ok := true; ok; ok = ((rc == 0) && (*(*int32)(unsafe.Pointer(bp /* bExists */)) != 0)) { - multiplexFilename(tls, zName, nName, 0x00000800, libc.PreIncInt32(&iChunk, 1), z) - rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 56 /* &.xAccess */))))(tls, pOrigVfs, z, 0, bp /* &bExists */) + for ok := true; ok; ok = ((rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* bExists */)) != 0)) { + multiplexFilename(tls, zName, nName, SQLITE_OPEN_MAIN_JOURNAL, libc.PreIncInt32(&iChunk, 1), z) + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 56 /* &.xAccess */))))(tls, pOrigVfs, z, SQLITE_ACCESS_EXISTS, bp /* &bExists */) } - for (rc == 0) && (iChunk > 1) { - multiplexFilename(tls, zName, nName, 0x00000800, libc.PreDecInt32(&iChunk, 1), z) + for (rc == SQLITE_OK) && (iChunk > 1) { + multiplexFilename(tls, zName, nName, SQLITE_OPEN_MAIN_JOURNAL, libc.PreDecInt32(&iChunk, 1), z) rc = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pOrigVfs + 48 /* &.xDelete */))))(tls, pOrigVfs, z, syncDir) } - if rc == 0 { + if rc == SQLITE_OK { iChunk = 0 - for ok1 := true; ok1; ok1 = ((rc == 0) && (*(*int32)(unsafe.Pointer(bp /* bExists */)) != 0)) { - multiplexFilename(tls, zName, nName, 0x00080000, libc.PreIncInt32(&iChunk, 1), z) - rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 56 /* &.xAccess */))))(tls, pOrigVfs, z, 0, bp /* &bExists */) + for ok1 := true; ok1; ok1 = ((rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* bExists */)) != 0)) { + multiplexFilename(tls, zName, nName, SQLITE_OPEN_WAL, libc.PreIncInt32(&iChunk, 1), z) + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 56 /* &.xAccess */))))(tls, pOrigVfs, z, SQLITE_ACCESS_EXISTS, bp /* &bExists */) } - for (rc == 0) && (iChunk > 1) { - multiplexFilename(tls, zName, nName, 0x00080000, libc.PreDecInt32(&iChunk, 1), z) + for (rc == SQLITE_OK) && (iChunk > 1) { + multiplexFilename(tls, zName, nName, SQLITE_OPEN_WAL, libc.PreDecInt32(&iChunk, 1), z) rc = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pOrigVfs + 48 /* &.xDelete */))))(tls, pOrigVfs, z, syncDir) } } @@ -70704,7 +66413,7 @@ func multiplexCurrentTimeInt64(tls *libc.TLS, a uintptr, b uintptr) int32 { /* t func multiplexClose(tls *libc.TLS, pConn uintptr) int32 { /* test_multiplex.c:701:12: */ var p uintptr = pConn var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup - var rc int32 = 0 + var rc int32 = SQLITE_OK multiplexFreeComponents(tls, pGroup) sqlite3.Xsqlite3_free(tls, pGroup) return rc @@ -70719,11 +66428,11 @@ func multiplexRead(tls *libc.TLS, pConn uintptr, pBuf uintptr, iAmt int32, iOfst var p uintptr = pConn var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK if !(int32((*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled) != 0) { var pSubOpen uintptr = multiplexSubOpen(tls, pGroup, 0, bp /* &rc */, uintptr(0), 0) if pSubOpen == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = (10 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_IOERR | (int32(1) << 8)) } else { *(*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) } @@ -70740,14 +66449,14 @@ func multiplexRead(tls *libc.TLS, pConn uintptr, pBuf uintptr, iAmt int32, iOfst iAmt = iAmt - (extra) *(*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 % sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk))) - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { break } pBuf = (pBuf + uintptr(iAmt)) iOfst = iOfst + (sqlite3_int64(iAmt)) iAmt = extra } else { - *(*int32)(unsafe.Pointer(bp /* rc */)) = (10 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_IOERR | (int32(1) << 8)) break } } @@ -70765,16 +66474,16 @@ func multiplexWrite(tls *libc.TLS, pConn uintptr, pBuf uintptr, iAmt int32, iOfs var p uintptr = pConn var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK if !(int32((*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled) != 0) { var pSubOpen uintptr = multiplexSubOpen(tls, pGroup, 0, bp /* &rc */, uintptr(0), 0) if pSubOpen == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = (10 | (int32(3) << 8)) + *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_IOERR | (int32(3) << 8)) } else { *(*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) } } else { - for (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (iAmt > 0) { + for (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (iAmt > 0) { var i int32 = (int32(iOfst / sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk))) var pSubOpen uintptr = multiplexSubOpen(tls, pGroup, i, bp /* &rc */, uintptr(0), 1) if pSubOpen != 0 { @@ -70803,11 +66512,11 @@ func multiplexTruncate(tls *libc.TLS, pConn uintptr, size sqlite3_int64) int32 { var p uintptr = pConn var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK if !(int32((*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled) != 0) { var pSubOpen uintptr = multiplexSubOpen(tls, pGroup, 0, bp /* &rc */, uintptr(0), 0) if pSubOpen == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = (10 | (int32(6) << 8)) + *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_IOERR | (int32(6) << 8)) } else { *(*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) } @@ -70817,7 +66526,7 @@ func multiplexTruncate(tls *libc.TLS, pConn uintptr, size sqlite3_int64) int32 { var pSubOpen uintptr var pOrigVfs uintptr = gMultiplex.FpOrigVfs // Real VFS // delete the chunks above the truncate limit - for i = ((*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal - 1); (i > iBaseGroup) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0); i-- { + for i = ((*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal - 1); (i > iBaseGroup) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK); i-- { if (*multiplexGroup)(unsafe.Pointer(pGroup)).FbTruncate != 0 { multiplexSubClose(tls, pGroup, i, pOrigVfs) } else { @@ -70827,14 +66536,14 @@ func multiplexTruncate(tls *libc.TLS, pConn uintptr, size sqlite3_int64) int32 { } } } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { pSubOpen = multiplexSubOpen(tls, pGroup, iBaseGroup, bp /* &rc */, uintptr(0), 0) if pSubOpen != 0 { *(*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))) } } if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { - *(*int32)(unsafe.Pointer(bp /* rc */)) = (10 | (int32(6) << 8)) + *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_IOERR | (int32(6) << 8)) } } return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -70844,13 +66553,13 @@ func multiplexTruncate(tls *libc.TLS, pConn uintptr, size sqlite3_int64) int32 { func multiplexSync(tls *libc.TLS, pConn uintptr, flags int32) int32 { /* test_multiplex.c:839:12: */ var p uintptr = pConn var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 for i = 0; i < (*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal; i++ { var pSubOpen uintptr = (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal + uintptr(i)*16)).Fp if pSubOpen != 0 { var rc2 int32 = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 40 /* &.xSync */))))(tls, pSubOpen, flags) - if rc2 != 0 { + if rc2 != SQLITE_OK { rc = rc2 } } @@ -70866,18 +66575,18 @@ func multiplexFileSize(tls *libc.TLS, pConn uintptr, pSize uintptr) int32 { /* t var p uintptr = pConn var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var i int32 if !(int32((*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled) != 0) { var pSubOpen uintptr = multiplexSubOpen(tls, pGroup, 0, bp /* &rc */, uintptr(0), 0) if pSubOpen == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = (10 | (int32(7) << 8)) + *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_IOERR | (int32(7) << 8)) } else { *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 48 /* &.xFileSize */))))(tls, pSubOpen, pSize) } } else { *(*sqlite3_int64)(unsafe.Pointer(pSize)) = int64(0) - for i = 0; *(*int32)(unsafe.Pointer(bp /* rc */)) == 0; i++ { + for i = 0; *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK; i++ { var sz sqlite3_int64 = multiplexSubSize(tls, pGroup, i, bp /* &rc */) if sz == int64(0) { break @@ -70900,7 +66609,7 @@ func multiplexLock(tls *libc.TLS, pConn uintptr, lock int32) int32 { /* test_mul if pSubOpen != 0 { return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 56 /* &.xLock */))))(tls, pSubOpen, lock) } - return 5 + return SQLITE_BUSY } // Pass xUnlock requests through to the original VFS unchanged. @@ -70915,7 +66624,7 @@ func multiplexUnlock(tls *libc.TLS, pConn uintptr, lock int32) int32 { /* test_m if pSubOpen != 0 { return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 64 /* &.xUnlock */))))(tls, pSubOpen, lock) } - return (10 | (int32(8) << 8)) + return (SQLITE_IOERR | (int32(8) << 8)) } // Pass xCheckReservedLock requests through to the original VFS unchanged. @@ -70930,7 +66639,7 @@ func multiplexCheckReservedLock(tls *libc.TLS, pConn uintptr, pResOut uintptr) i if pSubOpen != 0 { return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 72 /* &.xCheckReservedLock */))))(tls, pSubOpen, pResOut) } - return (10 | (int32(14) << 8)) + return (SQLITE_IOERR | (int32(14) << 8)) } // Pass xFileControl requests through to the original VFS unchanged, @@ -70941,44 +66650,44 @@ func multiplexFileControl(tls *libc.TLS, pConn uintptr, op int32, pArg uintptr) var p uintptr = pConn var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_ERROR var pSubOpen uintptr if !(gMultiplex.FisInitialized != 0) { - return 21 + return SQLITE_MISUSE } switch op { - case 214014: + case MULTIPLEX_CTRL_ENABLE: if pArg != 0 { var bEnabled int32 = *(*int32)(unsafe.Pointer(pArg)) (*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled = uint8(bEnabled) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK } break - case 214015: + case MULTIPLEX_CTRL_SET_CHUNK_SIZE: if pArg != 0 { var szChunk uint32 = *(*uint32)(unsafe.Pointer(pArg)) if szChunk < uint32(1) { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 21 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_MISUSE } else { // Round up to nearest multiple of MAX_PAGE_SIZE. - szChunk = (szChunk + (uint32(0x10000 - 1))) - szChunk = szChunk & (^libc.Uint32FromInt32((0x10000 - 1))) + szChunk = (szChunk + (uint32(MAX_PAGE_SIZE - 1))) + szChunk = szChunk & (libc.Uint32FromInt32(libc.CplInt32((MAX_PAGE_SIZE - 1)))) (*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk = szChunk - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK } } break - case 214016: - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + case MULTIPLEX_CTRL_SET_MAX_CHUNKS: + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK break - case 5: + case SQLITE_FCNTL_SIZE_HINT: fallthrough - case 6: + case SQLITE_FCNTL_CHUNK_SIZE: // no-op these - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK break - case 14: + case SQLITE_FCNTL_PRAGMA: { var aFcntl uintptr = pArg // EVIDENCE-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA @@ -70986,13 +66695,13 @@ func multiplexFileControl(tls *libc.TLS, pConn uintptr, op int32, pArg uintptr) // second element of the array is the name of the pragma and the third // element is the argument to the pragma or NULL if the pragma has no // argument. - if (*(*uintptr)(unsafe.Pointer(aFcntl + uintptr(1)*8)) != 0) && (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + uintptr(1)*8)), ts+33545 /* "multiplex_trunca..." */) == 0) { - if (*(*uintptr)(unsafe.Pointer(aFcntl + uintptr(2)*8)) != 0) && (*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aFcntl + uintptr(2)*8)) + uintptr(0))) != 0) { - if (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + uintptr(2)*8)), ts+4222 /* "on" */) == 0) || - (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + uintptr(2)*8)), ts+27761 /* "1" */) == 0) { + if (*(*uintptr)(unsafe.Pointer(aFcntl + 1*8)) != 0) && (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + 1*8)), ts+33545 /* "multiplex_trunca..." */) == 0) { + if (*(*uintptr)(unsafe.Pointer(aFcntl + 2*8)) != 0) && (*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aFcntl + 2*8)))) != 0) { + if (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + 2*8)), ts+4222 /* "on" */) == 0) || + (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + 2*8)), ts+27761 /* "1" */) == 0) { (*multiplexGroup)(unsafe.Pointer(pGroup)).FbTruncate = uint8(1) - } else if (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + uintptr(2)*8)), ts+4233 /* "off" */) == 0) || - (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + uintptr(2)*8)), ts+13695 /* "0" */) == 0) { + } else if (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + 2*8)), ts+4233 /* "off" */) == 0) || + (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + 2*8)), ts+13695 /* "0" */) == 0) { (*multiplexGroup)(unsafe.Pointer(pGroup)).FbTruncate = uint8(0) } } @@ -71001,13 +66710,13 @@ func multiplexFileControl(tls *libc.TLS, pConn uintptr, op int32, pArg uintptr) // argument point to a string obtained from sqlite3_mprintf() or the // equivalent and that string will become the result of the pragma // or the error message if the pragma fails. - *(*uintptr)(unsafe.Pointer(aFcntl + uintptr(0)*8)) = sqlite3.Xsqlite3_mprintf(tls, func() uintptr { + *(*uintptr)(unsafe.Pointer(aFcntl)) = sqlite3.Xsqlite3_mprintf(tls, func() uintptr { if (*multiplexGroup)(unsafe.Pointer(pGroup)).FbTruncate != 0 { return ts + 4222 /* "on" */ } return ts + 4233 /* "off" */ }(), 0) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK break } // If the multiplexor does not handle the pragma, pass it through @@ -71019,7 +66728,7 @@ func multiplexFileControl(tls *libc.TLS, pConn uintptr, op int32, pArg uintptr) pSubOpen = multiplexSubOpen(tls, pGroup, 0, bp+8 /* &rc */, uintptr(0), 0) if pSubOpen != 0 { *(*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) - if (op == 12) && (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0) { + if (op == SQLITE_FCNTL_VFSNAME) && (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK) { *(*uintptr)(unsafe.Pointer(pArg)) = sqlite3.Xsqlite3_mprintf(tls, ts+33564 /* "multiplex/%z" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(pArg)))) } } @@ -71040,7 +66749,7 @@ func multiplexSectorSize(tls *libc.TLS, pConn uintptr) int32 { /* test_multiplex if (pSubOpen != 0) && ((*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods)).FxSectorSize != 0) { return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 88 /* &.xSectorSize */))))(tls, pSubOpen) } - return 0x1000 + return DEFAULT_SECTOR_SIZE } // Pass xDeviceCharacteristics requests through to the original VFS unchanged. @@ -71070,7 +66779,7 @@ func multiplexShmMap(tls *libc.TLS, pConn uintptr, iRegion int32, szRegion int32 if pSubOpen != 0 { 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)) } - return 10 + return SQLITE_IOERR } // Pass xShmLock requests through to the original VFS unchanged. @@ -71085,7 +66794,7 @@ func multiplexShmLock(tls *libc.TLS, pConn uintptr, ofst int32, n int32, flags i if pSubOpen != 0 { return (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 112 /* &.xShmLock */))))(tls, pSubOpen, ofst, n, flags) } - return 5 + return SQLITE_BUSY } // Pass xShmBarrier requests through to the original VFS unchanged. @@ -71114,7 +66823,7 @@ func multiplexShmUnmap(tls *libc.TLS, pConn uintptr, deleteFlag int32) int32 { / if pSubOpen != 0 { return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 128 /* &.xShmUnmap */))))(tls, pSubOpen, deleteFlag) } - return 0 + return SQLITE_OK } //************************* Public Interfaces **************************** @@ -71131,11 +66840,11 @@ func multiplexShmUnmap(tls *libc.TLS, pConn uintptr, deleteFlag int32) int32 { / func sqlite3_multiplex_initialize(tls *libc.TLS, zOrigVfsName uintptr, makeDefault int32) int32 { /* test_multiplex.c:1097:5: */ var pOrigVfs uintptr if gMultiplex.FisInitialized != 0 { - return 21 + return SQLITE_MISUSE } pOrigVfs = sqlite3.Xsqlite3_vfs_find(tls, zOrigVfsName) if pOrigVfs == uintptr(0) { - return 1 + return SQLITE_ERROR } gMultiplex.FisInitialized = 1 @@ -71238,7 +66947,7 @@ func sqlite3_multiplex_initialize(tls *libc.TLS, zOrigVfsName uintptr, makeDefau f func(*libc.TLS, uintptr, uintptr, uintptr) int32 }{multiplexFuncInit}))) - return 0 + return SQLITE_OK } // CAPI: Shutdown the multiplex system - sqlite3_multiplex_shutdown() @@ -71249,9 +66958,9 @@ func sqlite3_multiplex_initialize(tls *libc.TLS, zOrigVfsName uintptr, makeDefau // THIS ROUTINE IS NOT THREADSAFE. Call this routine exactly once while // shutting down in order to free all remaining multiplex groups. func sqlite3_multiplex_shutdown(tls *libc.TLS, eForce int32) int32 { /* test_multiplex.c:1158:5: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if gMultiplex.FisInitialized == 0 { - return 21 + return SQLITE_MISUSE } gMultiplex.FisInitialized = 0 sqlite3.Xsqlite3_vfs_unregister(tls, (uintptr(unsafe.Pointer(&gMultiplex)) + 8 /* &.sThisVfs */)) @@ -71274,13 +66983,13 @@ func test_multiplex_initialize(tls *libc.TLS, clientData uintptr, interp uintptr // Process arguments if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+33587 /* "NAME MAKEDEFAULT" */) - return 1 + return TCL_ERROR } - zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp /* &makeDefault */) != 0 { - return 1 + zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &makeDefault */) != 0 { + return TCL_ERROR } - if int32(*(*int8)(unsafe.Pointer(zName + uintptr(0)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(zName))) == 0 { zName = uintptr(0) } @@ -71288,7 +66997,7 @@ func test_multiplex_initialize(tls *libc.TLS, clientData uintptr, interp uintptr rc = sqlite3_multiplex_initialize(tls, zName, *(*int32)(unsafe.Pointer(bp /* makeDefault */))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // tclcmd: sqlite3_multiplex_shutdown @@ -71297,19 +67006,19 @@ func test_multiplex_shutdown(tls *libc.TLS, clientData uintptr, interp uintptr, _ = clientData - if (objc == 2) && (libc.Xstrcmp(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), ts+33604 /* "-force" */) != 0) { + if (objc == 2) && (libc.Xstrcmp(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), ts+33604 /* "-force" */) != 0) { objc = 3 } if (objc != 1) && (objc != 2) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+33611 /* "?-force?" */) - return 1 + return TCL_ERROR } // Call sqlite3_multiplex_shutdown() rc = sqlite3_multiplex_shutdown(tls, (libc.Bool32(objc == 2))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // Tclcmd: test_multiplex_control HANDLE DBNAME SUB-COMMAND ?INT-VALUE? @@ -71335,41 +67044,32 @@ func test_multiplex_control(tls *libc.TLS, cd ClientData, interp uintptr, objc i Fop int32 Fargtype int32 }{ - { - FzName: ts + 33620, /* "enable" */ - Fop: 214014, - Fargtype: 1}, - { - FzName: ts + 33627, /* "chunk_size" */ - Fop: 214015, - Fargtype: 1}, - { - FzName: ts + 33638, /* "max_chunks" */ - Fop: 214016, - Fargtype: 1}, + {FzName: ts + 33620 /* "enable" */, Fop: MULTIPLEX_CTRL_ENABLE, Fargtype: 1}, + {FzName: ts + 33627 /* "chunk_size" */, Fop: MULTIPLEX_CTRL_SET_CHUNK_SIZE, Fargtype: 1}, + {FzName: ts + 33638 /* "max_chunks" */, Fop: MULTIPLEX_CTRL_SET_MAX_CHUNKS, Fargtype: 1}, {}, } if objc != 5 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+33649 /* "HANDLE DBNAME SU..." */) - return 1 + return TCL_ERROR } - if 0 == tcl.XTcl_GetCommandInfo(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+40 /* &cmdInfo */) { + if 0 == tcl.XTcl_GetCommandInfo(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+40 /* &cmdInfo */) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+33685 /* "expected databas..." */, 0)) - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), ts+11456 /* "\"" */, 0)) - return 1 + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), ts+11456 /* "\"" */, 0)) + return TCL_ERROR } else { db = *(*uintptr)(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp + 40 /* &cmdInfo */)).FobjClientData)) } rc = tcl.XTcl_GetIndexFromObjStruct(tls, - interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+104 /* &aSub[0] */, int32(unsafe.Sizeof(struct { + interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+104 /* &aSub[0] */, int32(unsafe.Sizeof(struct { FzName uintptr Fop int32 Fargtype int32 }{})), ts+1874 /* "sub-command" */, 0, bp+168 /* &idx */) - if rc != 0 { + if rc != TCL_OK { return rc } @@ -71379,26 +67079,26 @@ func test_multiplex_control(tls *libc.TLS, cd ClientData, interp uintptr, objc i Fargtype int32 })(unsafe.Pointer(bp + 104 /* &aSub */ + uintptr(*(*int32)(unsafe.Pointer(bp + 168 /* idx */)))*16)).Fargtype { case 1: - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+172 /* &iValue */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+172 /* &iValue */) != 0 { + return TCL_ERROR } pArg = bp + 172 /* &iValue */ break default: tcl.XTcl_WrongNumArgs(tls, interp, 4, objv, ts+2383 /* "SUB-COMMAND" */) - return 1 + return TCL_ERROR } - rc = sqlite3.Xsqlite3_file_control(tls, db, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), (*struct { + rc = sqlite3.Xsqlite3_file_control(tls, db, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), (*struct { FzName uintptr Fop int32 Fargtype int32 })(unsafe.Pointer(bp+104 /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 168 /* idx */)))*16)).Fop, pArg) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - if rc == 0 { - return 0 + if rc == SQLITE_OK { + return TCL_OK } - return 1 + return TCL_ERROR } // This routine registers the custom TCL commands defined in this @@ -71414,22 +67114,16 @@ func Sqlitemultiplex_Init(tls *libc.TLS, interp uintptr) int32 { /* test_multipl tcl.XTcl_CreateObjCommand(tls, interp, aCmd7[i].FzName, aCmd7[i].FxProc, uintptr(0), uintptr(0)) } - return 0 + return TCL_OK } var aCmd7 = [3]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 33717, /* "sqlite3_multiple..." */ - FxProc: 0}, - { - FzName: ts + 33746, /* "sqlite3_multiple..." */ - FxProc: 0}, - { - FzName: ts + 33773, /* "sqlite3_multiple..." */ - FxProc: 0}, + {FzName: ts + 33717 /* "sqlite3_multiple..." */, FxProc: 0}, + {FzName: ts + 33746 /* "sqlite3_multiple..." */, FxProc: 0}, + {FzName: ts + 33773 /* "sqlite3_multiple..." */, FxProc: 0}, } /* test_multiplex.c:1310:5 */ // CAPI3REF: Standard File Control Opcodes @@ -71826,10 +67520,10 @@ func counterMutexAlloc(tls *libc.TLS, eType int32) uintptr { /* test_mutex.c:90: return uintptr(0) } - if (eType == 0) || (eType == 1) { + if (eType == SQLITE_MUTEX_FAST) || (eType == SQLITE_MUTEX_RECURSIVE) { pRet = libc.Xmalloc(tls, uint64(unsafe.Sizeof(sqlite3_mutex{}))) } else { - var eStaticType int32 = (eType - ((13 + 1) - ((13 + 1) - (1 + 1)))) + var eStaticType int32 = (eType - ((SQLITE_MUTEX_STATIC_VFS3 + 1) - ((SQLITE_MUTEX_STATIC_VFS3 + 1) - (SQLITE_MUTEX_RECURSIVE + 1)))) pRet = ((uintptr(unsafe.Pointer(&g3)) + 144 /* &.aStatic */) + uintptr(eStaticType)*16) } @@ -71843,7 +67537,7 @@ func counterMutexAlloc(tls *libc.TLS, eType int32) uintptr { /* test_mutex.c:90: func counterMutexFree(tls *libc.TLS, p uintptr) { /* test_mutex.c:118:13: */ (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */ + 24 /* &.xMutexFree */))))(tls, (*sqlite3_mutex)(unsafe.Pointer(p)).FpReal) - if ((*sqlite3_mutex)(unsafe.Pointer(p)).FeType == 0) || ((*sqlite3_mutex)(unsafe.Pointer(p)).FeType == 1) { + if ((*sqlite3_mutex)(unsafe.Pointer(p)).FeType == SQLITE_MUTEX_FAST) || ((*sqlite3_mutex)(unsafe.Pointer(p)).FeType == SQLITE_MUTEX_RECURSIVE) { libc.Xfree(tls, p) } } @@ -71860,7 +67554,7 @@ func counterMutexTry(tls *libc.TLS, p uintptr) int32 { /* test_mutex.c:140:12: * *(*int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 88 /* &.aCounter */) + uintptr((*sqlite3_mutex)(unsafe.Pointer(p)).FeType)*4))++ if g3.FdisableTry != 0 { - return 5 + return SQLITE_BUSY } return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */ + 40 /* &.xMutexTry */))))(tls, (*sqlite3_mutex)(unsafe.Pointer(p)).FpReal) } @@ -71877,12 +67571,12 @@ func test_shutdown(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32 if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } rc = sqlite3.Xsqlite3_shutdown(tls) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 0 + return TCL_OK } // sqlite3_initialize @@ -71891,12 +67585,12 @@ func test_initialize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } rc = sqlite3.Xsqlite3_initialize(tls) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 0 + return TCL_OK } // install_mutex_counters BOOLEAN @@ -71904,7 +67598,7 @@ func test_install_mutex_counters(tls *libc.TLS, clientData uintptr, interp uintp bp := tls.Alloc(136) defer tls.Free(136) - var rc int32 = 0 + var rc int32 = SQLITE_OK // var isInstall int32 at bp+56, 4 *(*sqlite3_mutex_methods)(unsafe.Pointer(bp + 64 /* counter_methods */)) = sqlite3_mutex_methods{ @@ -71929,10 +67623,10 @@ func test_install_mutex_counters(tls *libc.TLS, clientData uintptr, interp uintp if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17539 /* "BOOLEAN" */) - return 1 + return TCL_ERROR } - if 0 != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+56 /* &isInstall */) { - return 1 + if TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+56 /* &isInstall */) { + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 56 /* isInstall */)) == g3.FisInstalled { @@ -71943,28 +67637,28 @@ func test_install_mutex_counters(tls *libc.TLS, clientData uintptr, interp uintp } return ts + 33994 /* "not installed" */ }(), 0)) - return 1 + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 56 /* isInstall */)) != 0 { - rc = sqlite3.Xsqlite3_config(tls, 11, libc.VaList(bp+32, (uintptr(unsafe.Pointer(&g3))+16 /* &.m */))) - if rc == 0 { - sqlite3.Xsqlite3_config(tls, 10, libc.VaList(bp+40, bp+64 /* &counter_methods */)) + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETMUTEX, libc.VaList(bp+32, (uintptr(unsafe.Pointer(&g3))+16 /* &.m */))) + if rc == SQLITE_OK { + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MUTEX, libc.VaList(bp+40, bp+64 /* &counter_methods */)) } g3.FdisableTry = 0 } else { - rc = sqlite3.Xsqlite3_config(tls, 10, libc.VaList(bp+48, (uintptr(unsafe.Pointer(&g3))+16 /* &.m */))) + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MUTEX, libc.VaList(bp+48, (uintptr(unsafe.Pointer(&g3))+16 /* &.m */))) libc.Xmemset(tls, (uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */), 0, uint64(unsafe.Sizeof(sqlite3_mutex_methods{}))) } - if rc == 0 { + if rc == SQLITE_OK { g3.FisInstalled = *(*int32)(unsafe.Pointer(bp + 56 /* isInstall */)) } tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 0 + return TCL_OK } // read_mutex_counters @@ -71974,12 +67668,12 @@ func test_read_mutex_counters(tls *libc.TLS, clientData uintptr, interp uintptr, if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } pRet = tcl.XTcl_NewObj(tls) (*Tcl_Obj)(unsafe.Pointer(pRet)).FrefCount++ - for ii = 0; ii < (13 + 1); ii++ { + for ii = 0; ii < (SQLITE_MUTEX_STATIC_VFS3 + 1); ii++ { tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewStringObj(tls, aName[ii], -1)) tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 88 /* &.aCounter */) + uintptr(ii)*4)))) } @@ -71991,7 +67685,7 @@ func test_read_mutex_counters(tls *libc.TLS, clientData uintptr, interp uintptr, } } - return 0 + return TCL_OK } // clear_mutex_counters @@ -72000,13 +67694,13 @@ func test_clear_mutex_counters(tls *libc.TLS, clientData uintptr, interp uintptr if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } - for ii = 0; ii < (13 + 1); ii++ { + for ii = 0; ii < (SQLITE_MUTEX_STATIC_VFS3 + 1); ii++ { *(*int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 88 /* &.aCounter */) + uintptr(ii)*4)) = 0 } - return 0 + return TCL_OK } // Create and free a mutex. Return the mutex pointer. The pointer @@ -72016,13 +67710,13 @@ func test_alloc_mutex(tls *libc.TLS, clientData uintptr, interp uintptr, objc in bp := tls.Alloc(124) defer tls.Free(124) - var p uintptr = sqlite3.Xsqlite3_mutex_alloc(tls, 0) + var p uintptr = sqlite3.Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST) // var zBuf [100]int8 at bp+24, 100 sqlite3.Xsqlite3_mutex_free(tls, p) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+24 /* &zBuf[0] */, ts+12843 /* "%p" */, libc.VaList(bp, p)) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+8, bp+24 /* &zBuf[0] */, uintptr(0))) - return 0 + return TCL_OK } // sqlite3_config OPTION @@ -72039,15 +67733,9 @@ func test_config(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, defer tls.Free(68) *(*[4]ConfigOption)(unsafe.Pointer(bp /* aOpt */)) = [4]ConfigOption{ - { - FzName: ts + 34008, /* "singlethread" */ - FiValue: 1}, - { - FzName: ts + 34021, /* "multithread" */ - FiValue: 2}, - { - FzName: ts + 34033, /* "serialized" */ - FiValue: 3}, + {FzName: ts + 34008 /* "singlethread" */, FiValue: SQLITE_CONFIG_SINGLETHREAD}, + {FzName: ts + 34021 /* "multithread" */, FiValue: SQLITE_CONFIG_MULTITHREAD}, + {FzName: ts + 34033 /* "serialized" */, FiValue: SQLITE_CONFIG_SERIALIZED}, {}, } var s int32 = int32(unsafe.Sizeof(ConfigOption{})) @@ -72057,12 +67745,12 @@ func test_config(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &aOpt[0] */, s, ts+16852 /* "flag" */, 0, bp+64 /* &i */) != 0 { - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+64 /* &i */) != 0 { - return 1 + if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &aOpt[0] */, s, ts+16852 /* "flag" */, 0, bp+64 /* &i */) != 0 { + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+64 /* &i */) != 0 { + return TCL_ERROR } } else { *(*int32)(unsafe.Pointer(bp + 64 /* i */)) = (*ConfigOption)(unsafe.Pointer(bp /* &aOpt */ + uintptr(*(*int32)(unsafe.Pointer(bp + 64 /* i */)))*16)).FiValue @@ -72070,7 +67758,7 @@ func test_config(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, rc = sqlite3.Xsqlite3_config(tls, *(*int32)(unsafe.Pointer(bp + 64 /* i */)), 0) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) - return 0 + return TCL_OK } type ConfigOption = struct { @@ -72113,56 +67801,56 @@ func test_enter_static_mutex(tls *libc.TLS, clientData uintptr, interp uintptr, var pMutex uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10219 /* "NAME" */) - return 1 + return TCL_ERROR } - pMutex = getStaticMutexPointer(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + pMutex = getStaticMutexPointer(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) if !(pMutex != 0) { - return 1 + return TCL_ERROR } sqlite3.Xsqlite3_mutex_enter(tls, pMutex) - return 0 + return TCL_OK } func test_leave_static_mutex(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:423:26: */ var pMutex uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10219 /* "NAME" */) - return 1 + return TCL_ERROR } - pMutex = getStaticMutexPointer(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + pMutex = getStaticMutexPointer(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) if !(pMutex != 0) { - return 1 + return TCL_ERROR } sqlite3.Xsqlite3_mutex_leave(tls, pMutex) - return 0 + return TCL_OK } func test_enter_db_mutex(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:442:26: */ var db uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - db = getDbPointer1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + db = getDbPointer1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) if !(db != 0) { - return 1 + return TCL_ERROR } sqlite3.Xsqlite3_mutex_enter(tls, sqlite3.Xsqlite3_db_mutex(tls, db)) - return 0 + return TCL_OK } func test_leave_db_mutex(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:461:26: */ var db uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - db = getDbPointer1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + db = getDbPointer1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) if !(db != 0) { - return 1 + return TCL_ERROR } sqlite3.Xsqlite3_mutex_leave(tls, sqlite3.Xsqlite3_db_mutex(tls, db)) - return 0 + return TCL_OK } func Sqlitetest_mutex_Init(tls *libc.TLS, interp uintptr) int32 { /* test_mutex.c:480:5: */ @@ -72175,52 +67863,30 @@ func Sqlitetest_mutex_Init(tls *libc.TLS, interp uintptr) int32 { /* test_mutex. } tcl.XTcl_LinkVar(tls, interp, ts+34055, /* "disable_mutex_in..." */ - (uintptr(unsafe.Pointer(&g3)) + 4 /* &.disableInit */), 1) + (uintptr(unsafe.Pointer(&g3)) + 4 /* &.disableInit */), TCL_LINK_INT) tcl.XTcl_LinkVar(tls, interp, ts+34074, /* "disable_mutex_tr..." */ - (uintptr(unsafe.Pointer(&g3)) + 8 /* &.disableTry */), 1) - return 0 + (uintptr(unsafe.Pointer(&g3)) + 8 /* &.disableTry */), TCL_LINK_INT) + return SQLITE_OK } var aCmd8 = [11]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 34092, /* "sqlite3_shutdown" */ - FxProc: 0}, - { - FzName: ts + 34109, /* "sqlite3_initiali..." */ - FxProc: 0}, - { - FzName: ts + 34128, /* "sqlite3_config" */ - FxProc: 0}, + {FzName: ts + 34092 /* "sqlite3_shutdown" */, FxProc: 0}, + {FzName: ts + 34109 /* "sqlite3_initiali..." */, FxProc: 0}, + {FzName: ts + 34128 /* "sqlite3_config" */, FxProc: 0}, - { - FzName: ts + 34143, /* "enter_static_mut..." */ - FxProc: 0}, - { - FzName: ts + 34162, /* "leave_static_mut..." */ - FxProc: 0}, + {FzName: ts + 34143 /* "enter_static_mut..." */, FxProc: 0}, + {FzName: ts + 34162 /* "leave_static_mut..." */, FxProc: 0}, - { - FzName: ts + 34181, /* "enter_db_mutex" */ - FxProc: 0}, - { - FzName: ts + 34196, /* "leave_db_mutex" */ - FxProc: 0}, + {FzName: ts + 34181 /* "enter_db_mutex" */, FxProc: 0}, + {FzName: ts + 34196 /* "leave_db_mutex" */, FxProc: 0}, - { - FzName: ts + 34211, /* "alloc_dealloc_mu..." */ - FxProc: 0}, - { - FzName: ts + 34231, /* "install_mutex_co..." */ - FxProc: 0}, - { - FzName: ts + 34254, /* "read_mutex_count..." */ - FxProc: 0}, - { - FzName: ts + 34274, /* "clear_mutex_coun..." */ - FxProc: 0}, + {FzName: ts + 34211 /* "alloc_dealloc_mu..." */, FxProc: 0}, + {FzName: ts + 34231 /* "install_mutex_co..." */, FxProc: 0}, + {FzName: ts + 34254 /* "read_mutex_count..." */, FxProc: 0}, + {FzName: ts + 34274 /* "clear_mutex_coun..." */, FxProc: 0}, } /* test_mutex.c:484:5 */ // Maximum pathname length supported by the fs backend. @@ -72272,117 +67938,52 @@ type fs_vfs_t = fs_vfs_t1 /* test_onefile.c:176:25 */ var fs_vfs = fs_vfs_t{ Fbase: sqlite3_vfs{ - FiVersion: 1, - FszOsFile:// iVersion - 0, - FmxPathname:// szOsFile - 0, - FpNext:// mxPathname - uintptr(0), - FzName:// pNext - ts + 29891, /* "fs" */ - FpAppData:// zName - uintptr(0), - FxOpen:// pAppData - 0, - FxDelete:// xOpen - 0, - FxAccess:// xDelete - 0, - FxFullPathname:// xAccess - 0, - FxDlOpen:// xFullPathname - 0, - FxDlError:// xDlOpen - 0, - FxDlSym:// xDlError - 0, - FxDlClose:// xDlSym - 0, - FxRandomness:// xDlClose - 0, - FxSleep:// xRandomness - 0, - FxCurrentTime:// xSleep - 0, - FxGetLastError:// xCurrentTime - uintptr(0), // xCurrentTimeInt64 - }, - FpFileList: uintptr(0), - FpParent:// pFileList - uintptr(0), // pParent + FiVersion: 1, // pNext + FzName: ts + 29891, /* "fs" */ // pAppData + FxOpen: 0, // xOpen + FxDelete: 0, // xDelete + FxAccess: 0, // xAccess + FxFullPathname: 0, // xFullPathname + FxDlOpen: 0, // xDlOpen + FxDlError: 0, // xDlError + FxDlSym: 0, // xDlSym + FxDlClose: 0, // xDlClose + FxRandomness: 0, // xRandomness + FxSleep: 0, // xSleep + FxCurrentTime: 0, // xCurrentTimeInt64 + }, // pParent } /* test_onefile.c:183:17 */ var fs_io_methods = sqlite3_io_methods{ - FiVersion: 1, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - 0, - FxUnlock:// xLock - 0, - FxCheckReservedLock:// xUnlock - 0, - FxFileControl:// xCheckReservedLock - 0, - FxSectorSize:// xFileControl - 0, - FxDeviceCharacteristics:// xSectorSize - 0, - FxShmMap:// xDeviceCharacteristics - uintptr(0), - FxShmLock:// xShmMap - uintptr(0), - FxShmBarrier:// xShmLock - uintptr(0), - FxShmUnmap:// xShmBarrier - uintptr(0), // xShmUnmap + FiVersion: 1, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xFileSize + FxLock: 0, // xLock + FxUnlock: 0, // xUnlock + FxCheckReservedLock: 0, // xCheckReservedLock + FxFileControl: 0, // xFileControl + FxSectorSize: 0, // xSectorSize + FxDeviceCharacteristics: 0, // xShmUnmap } /* test_onefile.c:208:27 */ var tmp_io_methods = sqlite3_io_methods{ - FiVersion: 1, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - 0, - FxUnlock:// xLock - 0, - FxCheckReservedLock:// xUnlock - 0, - FxFileControl:// xCheckReservedLock - 0, - FxSectorSize:// xFileControl - 0, - FxDeviceCharacteristics:// xSectorSize - 0, - FxShmMap:// xDeviceCharacteristics - uintptr(0), - FxShmLock:// xShmMap - uintptr(0), - FxShmBarrier:// xShmLock - uintptr(0), - FxShmUnmap:// xShmBarrier - uintptr(0), // xShmUnmap + FiVersion: 1, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xFileSize + FxLock: 0, // xLock + FxUnlock: 0, // xUnlock + FxCheckReservedLock: 0, // xCheckReservedLock + FxFileControl: 0, // xFileControl + FxSectorSize: 0, // xSectorSize + FxDeviceCharacteristics: 0, // xShmUnmap } /* test_onefile.c:229:27 */ // Useful macros used in several places @@ -72391,17 +67992,17 @@ var tmp_io_methods = sqlite3_io_methods{ func tmpClose(tls *libc.TLS, pFile uintptr) int32 { /* test_onefile.c:257:12: */ var pTmp uintptr = pFile sqlite3.Xsqlite3_free(tls, (*tmp_file)(unsafe.Pointer(pTmp)).FzAlloc) - return 0 + return SQLITE_OK } // Read data from a tmp-file. func tmpRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_onefile.c:266:12: */ var pTmp uintptr = pFile if (sqlite_int64(iAmt) + iOfst) > sqlite_int64((*tmp_file)(unsafe.Pointer(pTmp)).FnSize) { - return (10 | (int32(2) << 8)) + return (SQLITE_IOERR | (int32(2) << 8)) } libc.Xmemcpy(tls, zBuf, ((*tmp_file)(unsafe.Pointer(pTmp)).FzAlloc + uintptr(iOfst)), uint64(iAmt)) - return 0 + return SQLITE_OK } // Write data to a tmp-file. @@ -72411,7 +68012,7 @@ func tmpWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqli var nNew int32 = (int32(int64(2) * ((sqlite_int64(iAmt) + iOfst) + sqlite_int64((*tmp_file)(unsafe.Pointer(pTmp)).FnAlloc)))) var zNew uintptr = sqlite3.Xsqlite3_realloc(tls, (*tmp_file)(unsafe.Pointer(pTmp)).FzAlloc, nNew) if !(zNew != 0) { - return 7 + return SQLITE_NOMEM } (*tmp_file)(unsafe.Pointer(pTmp)).FzAlloc = zNew (*tmp_file)(unsafe.Pointer(pTmp)).FnAlloc = nNew @@ -72423,7 +68024,7 @@ func tmpWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqli } return (int32(iOfst + sqlite_int64(iAmt))) }() - return 0 + return SQLITE_OK } // Truncate a tmp-file. @@ -72435,40 +68036,40 @@ func tmpTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* tes } return int32(size) }() - return 0 + return SQLITE_OK } // Sync a tmp-file. func tmpSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_onefile.c:316:12: */ - return 0 + return SQLITE_OK } // Return the current file-size of a tmp-file. func tmpFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* test_onefile.c:323:12: */ var pTmp uintptr = pFile *(*sqlite_int64)(unsafe.Pointer(pSize)) = sqlite_int64((*tmp_file)(unsafe.Pointer(pTmp)).FnSize) - return 0 + return SQLITE_OK } // Lock a tmp-file. func tmpLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_onefile.c:332:12: */ - return 0 + return SQLITE_OK } // Unlock a tmp-file. func tmpUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_onefile.c:339:12: */ - return 0 + return SQLITE_OK } // Check if another file-handle holds a RESERVED lock on a tmp-file. func tmpCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { /* test_onefile.c:346:12: */ *(*int32)(unsafe.Pointer(pResOut)) = 0 - return 0 + return SQLITE_OK } // File control method. For custom operations on a tmp-file. func tmpFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { /* test_onefile.c:354:12: */ - return 0 + return SQLITE_OK } // Return the sector-size in bytes for a tmp-file. @@ -72483,7 +68084,7 @@ func tmpDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* test_onef // Close an fs-file. func fsClose1(tls *libc.TLS, pFile uintptr) int32 { /* test_onefile.c:375:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr = pFile var pReal uintptr = (*fs_file)(unsafe.Pointer(p)).FpReal @@ -72505,28 +68106,28 @@ func fsClose1(tls *libc.TLS, pFile uintptr) int32 { /* test_onefile.c:375:12: */ // Read data from an fs-file. func fsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_onefile.c:400:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr = pFile var pReal uintptr = (*fs_file)(unsafe.Pointer(p)).FpReal var pF uintptr = (*fs_real_file)(unsafe.Pointer(pReal)).FpFile - if (((*fs_file)(unsafe.Pointer(p)).FeType == 1) && ((sqlite_int64(iAmt) + iOfst) > sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase))) || - (((*fs_file)(unsafe.Pointer(p)).FeType == 2) && ((sqlite_int64(iAmt) + iOfst) > sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnJournal))) { - rc = (10 | (int32(2) << 8)) - } else if (*fs_file)(unsafe.Pointer(p)).FeType == 1 { - 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(512))) + if (((*fs_file)(unsafe.Pointer(p)).FeType == DATABASE_FILE) && ((sqlite_int64(iAmt) + iOfst) > sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase))) || + (((*fs_file)(unsafe.Pointer(p)).FeType == JOURNAL_FILE) && ((sqlite_int64(iAmt) + iOfst) > sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnJournal))) { + rc = (SQLITE_IOERR | (int32(2) << 8)) + } else if (*fs_file)(unsafe.Pointer(p)).FeType == DATABASE_FILE { + 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 + BLOCKSIZE)) } else { // Journal file. var iRem int32 = iAmt var iBuf int32 = 0 var ii int32 = int32(iOfst) - for (iRem > 0) && (rc == 0) { - var iRealOff int32 = (((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - (512 * ((ii / 512) + 1))) + (ii % 512)) + for (iRem > 0) && (rc == SQLITE_OK) { + var iRealOff int32 = (((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - (BLOCKSIZE * ((ii / BLOCKSIZE) + 1))) + (ii % BLOCKSIZE)) var iRealAmt int32 = func() int32 { - if (iRem) < (512 - (iRealOff % 512)) { + if (iRem) < (BLOCKSIZE - (iRealOff % BLOCKSIZE)) { return iRem } - return (512 - (iRealOff % 512)) + return (BLOCKSIZE - (iRealOff % BLOCKSIZE)) }() 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)) @@ -72541,17 +68142,17 @@ func fsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite // Write data to an fs-file. func fsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_onefile.c:439:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr = pFile var pReal uintptr = (*fs_file)(unsafe.Pointer(p)).FpReal var pF uintptr = (*fs_real_file)(unsafe.Pointer(pReal)).FpFile - if (*fs_file)(unsafe.Pointer(p)).FeType == 1 { - if ((sqlite_int64(iAmt) + iOfst) + int64(512)) > (sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal)) { - rc = 13 + if (*fs_file)(unsafe.Pointer(p)).FeType == DATABASE_FILE { + if ((sqlite_int64(iAmt) + iOfst) + BLOCKSIZE) > (sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal)) { + rc = SQLITE_FULL } else { - 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(512))) - if rc == 0 { + 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 + BLOCKSIZE)) + if rc == SQLITE_OK { (*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase = func() int32 { if (sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase)) > (sqlite_int64(iAmt) + iOfst) { return (*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase @@ -72565,17 +68166,17 @@ func fsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlit var iRem int32 = iAmt var iBuf int32 = 0 var ii int32 = int32(iOfst) - for (iRem > 0) && (rc == 0) { - var iRealOff int32 = (((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - (512 * ((ii / 512) + 1))) + (ii % 512)) + for (iRem > 0) && (rc == SQLITE_OK) { + var iRealOff int32 = (((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - (BLOCKSIZE * ((ii / BLOCKSIZE) + 1))) + (ii % BLOCKSIZE)) var iRealAmt int32 = func() int32 { - if (iRem) < (512 - (iRealOff % 512)) { + if (iRem) < (BLOCKSIZE - (iRealOff % BLOCKSIZE)) { return iRem } - return (512 - (iRealOff % 512)) + return (BLOCKSIZE - (iRealOff % BLOCKSIZE)) }() - if iRealOff < ((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase + 512) { - rc = 13 + if iRealOff < ((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase + BLOCKSIZE) { + rc = SQLITE_FULL } else { 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)) ii = ii + (iRealAmt) @@ -72583,7 +68184,7 @@ func fsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlit iRem = iRem - (iRealAmt) } } - if rc == 0 { + if rc == SQLITE_OK { (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal = func() int32 { if (sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnJournal)) > (sqlite_int64(iAmt) + iOfst) { return (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal @@ -72600,7 +68201,7 @@ func fsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlit func fsTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* test_onefile.c:488:12: */ var p uintptr = pFile var pReal uintptr = (*fs_file)(unsafe.Pointer(p)).FpReal - if (*fs_file)(unsafe.Pointer(p)).FeType == 1 { + if (*fs_file)(unsafe.Pointer(p)).FeType == DATABASE_FILE { (*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase = func() int32 { if (sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase)) < (size) { return (*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase @@ -72615,7 +68216,7 @@ func fsTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* test return int32(size) }() } - return 0 + return SQLITE_OK } // Sync an fs-file. @@ -72626,19 +68227,19 @@ func fsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_onefile.c var p uintptr = pFile var pReal uintptr = (*fs_file)(unsafe.Pointer(p)).FpReal var pRealFile uintptr = (*fs_real_file)(unsafe.Pointer(pReal)).FpFile - var rc int32 = 0 + var rc int32 = SQLITE_OK - if (*fs_file)(unsafe.Pointer(p)).FeType == 1 { + if (*fs_file)(unsafe.Pointer(p)).FeType == DATABASE_FILE { // var zSize [4]uint8 at bp, 4 - *(*uint8)(unsafe.Pointer(bp /* &zSize[0] */ + uintptr(0))) = (uint8((uint32((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase) & 0xFF000000) >> 24)) - *(*uint8)(unsafe.Pointer(bp /* &zSize[0] */ + uintptr(1))) = (uint8(((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase & 0x00FF0000) >> 16)) - *(*uint8)(unsafe.Pointer(bp /* &zSize[0] */ + uintptr(2))) = (uint8(((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase & 0x0000FF00) >> 8)) - *(*uint8)(unsafe.Pointer(bp /* &zSize[0] */ + uintptr(3))) = (uint8((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase & 0x000000FF)) + *(*uint8)(unsafe.Pointer(bp /* &zSize[0] */)) = (uint8((uint32((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase) & 0xFF000000) >> 24)) + *(*uint8)(unsafe.Pointer(bp /* &zSize[0] */ + 1)) = (uint8(((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase & 0x00FF0000) >> 16)) + *(*uint8)(unsafe.Pointer(bp /* &zSize[0] */ + 2)) = (uint8(((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase & 0x0000FF00) >> 8)) + *(*uint8)(unsafe.Pointer(bp /* &zSize[0] */ + 3)) = (uint8((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase & 0x000000FF)) 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)) } - if rc == 0 { - rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pRealFile)).FpMethods + 40 /* &.xSync */))))(tls, pRealFile, (flags & (^libc.Int32(0x00010)))) + if rc == SQLITE_OK { + 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)))) } return rc @@ -72648,41 +68249,41 @@ func fsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_onefile.c func fsFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* test_onefile.c:526:12: */ var p uintptr = pFile var pReal uintptr = (*fs_file)(unsafe.Pointer(p)).FpReal - if (*fs_file)(unsafe.Pointer(p)).FeType == 1 { + if (*fs_file)(unsafe.Pointer(p)).FeType == DATABASE_FILE { *(*sqlite_int64)(unsafe.Pointer(pSize)) = sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase) } else { *(*sqlite_int64)(unsafe.Pointer(pSize)) = sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnJournal) } - return 0 + return SQLITE_OK } // Lock an fs-file. func fsLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_onefile.c:540:12: */ - return 0 + return SQLITE_OK } // Unlock an fs-file. func fsUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_onefile.c:547:12: */ - return 0 + return SQLITE_OK } // Check if another file-handle holds a RESERVED lock on an fs-file. func fsCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { /* test_onefile.c:554:12: */ *(*int32)(unsafe.Pointer(pResOut)) = 0 - return 0 + return SQLITE_OK } // File control method. For custom operations on an fs-file. func fsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { /* test_onefile.c:562:12: */ - if op == 14 { - return 12 + if op == SQLITE_FCNTL_PRAGMA { + return SQLITE_NOTFOUND } - return 0 + return SQLITE_OK } // Return the sector-size in bytes for an fs-file. func fsSectorSize(tls *libc.TLS, pFile uintptr) int32 { /* test_onefile.c:570:12: */ - return 512 + return BLOCKSIZE } // Return the device characteristic flags supported by an fs-file. @@ -72712,29 +68313,29 @@ func fsOpen1(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags in pFsVfs = pVfs p = pFile pReal = uintptr(0) - rc = 0 + rc = SQLITE_OK - if !(0 == (flags & (0x00000100 | 0x00000800))) { + if !(0 == (flags & (SQLITE_OPEN_MAIN_DB | SQLITE_OPEN_MAIN_JOURNAL))) { goto __1 } p2 = pFile libc.Xmemset(tls, p2, 0, uint64(unsafe.Sizeof(tmp_file{}))) (*tmp_file)(unsafe.Pointer(p2)).Fbase.FpMethods = uintptr(unsafe.Pointer(&tmp_io_methods)) - return 0 + return SQLITE_OK __1: ; eType = func() int32 { - if (flags & (0x00000100)) != 0 { - return 1 + if (flags & (SQLITE_OPEN_MAIN_DB)) != 0 { + return DATABASE_FILE } - return 2 + return JOURNAL_FILE }() (*fs_file)(unsafe.Pointer(p)).Fbase.FpMethods = uintptr(unsafe.Pointer(&fs_io_methods)) (*fs_file)(unsafe.Pointer(p)).FeType = eType nName = (int32(libc.Xstrlen(tls, zName)) - (func() int32 { - if eType == 2 { + if eType == JOURNAL_FILE { return 8 } return 0 @@ -72755,23 +68356,23 @@ __4: if !(!(pReal != 0)) { goto __5 } - real_flags = ((flags & ^libc.Int32(0x00000100)) | 0x00000200) + real_flags = ((flags & libc.CplInt32(SQLITE_OPEN_MAIN_DB)) | SQLITE_OPEN_TEMP_DB) pParent = (*fs_vfs_t)(unsafe.Pointer(pFsVfs)).FpParent pReal = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(fs_real_file{})) + uint64((*sqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile)))) if !(!(pReal != 0)) { goto __6 } - rc = 7 + rc = SQLITE_NOMEM goto open_out __6: ; libc.Xmemset(tls, pReal, 0, (uint64(unsafe.Sizeof(fs_real_file{})) + uint64((*sqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile))) (*fs_real_file)(unsafe.Pointer(pReal)).FzName = zName - (*fs_real_file)(unsafe.Pointer(pReal)).FpFile = (pReal + uintptr(1)*48) + (*fs_real_file)(unsafe.Pointer(pReal)).FpFile = (pReal + 1*48) 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) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __7 } goto open_out @@ -72780,7 +68381,7 @@ __7: pRealFile = (*fs_real_file)(unsafe.Pointer(pReal)).FpFile rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pRealFile)).FpMethods + 48 /* &.xFileSize */))))(tls, pRealFile, bp /* &size */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __8 } goto open_out @@ -72789,18 +68390,18 @@ __8: if !(*(*sqlite3_int64)(unsafe.Pointer(bp /* size */)) == int64(0)) { goto __9 } - rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pRealFile)).FpMethods + 24 /* &.xWrite */))))(tls, pRealFile, ts+34295 /* "\x00" */, 1, (int64(10485760 - 1))) - (*fs_real_file)(unsafe.Pointer(pReal)).FnBlob = 10485760 + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pRealFile)).FpMethods + 24 /* &.xWrite */))))(tls, pRealFile, ts+34295 /* "\x00" */, 1, (int64(BLOBSIZE - 1))) + (*fs_real_file)(unsafe.Pointer(pReal)).FnBlob = BLOBSIZE goto __10 __9: (*fs_real_file)(unsafe.Pointer(pReal)).FnBlob = int32(*(*sqlite3_int64)(unsafe.Pointer(bp /* size */))) 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)) - (*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase = ((((int32(*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + uintptr(0)))) << 24) + (int32(*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + uintptr(1)))) << 16)) + (int32(*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + uintptr(2)))) << 8)) + int32(*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + uintptr(3))))) - if !(rc == 0) { + (*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)))) + if !(rc == SQLITE_OK) { goto __11 } 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))) - if !((((*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + uintptr(0))) != 0) || (*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + uintptr(1))) != 0)) || (*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + uintptr(2))) != 0)) || (*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + uintptr(3))) != 0)) { + 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)) { goto __12 } (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal = (*fs_real_file)(unsafe.Pointer(pReal)).FnBlob @@ -72811,7 +68412,7 @@ __11: __10: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __13 } (*fs_real_file)(unsafe.Pointer(pReal)).FpNext = (*fs_vfs_t)(unsafe.Pointer(pFsVfs)).FpFileList @@ -72832,7 +68433,7 @@ open_out: if !(pReal != 0) { goto __15 } - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __16 } (*fs_file)(unsafe.Pointer(p)).FpReal = pReal @@ -72857,7 +68458,7 @@ __15: // ensure the file-system modifications are synced to disk before // returning. func fsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { /* test_onefile.c:686:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pFsVfs uintptr = pVfs var pReal uintptr var pF uintptr @@ -72868,8 +68469,8 @@ func fsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { } if pReal != 0 { pF = (*fs_real_file)(unsafe.Pointer(pReal)).FpFile - rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pF)).FpMethods + 24 /* &.xWrite */))))(tls, pF, ts+34297 /* "\x00\x00\x00\x00" */, 4, (int64((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - 512))) - if rc == 0 { + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pF)).FpMethods + 24 /* &.xWrite */))))(tls, pF, ts+34297 /* "\x00\x00\x00\x00" */, 4, (int64((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - BLOCKSIZE))) + if rc == SQLITE_OK { (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal = 0 } } @@ -72884,7 +68485,7 @@ func fsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut u var isJournal int32 = 0 var nName int32 = int32(libc.Xstrlen(tls, zPath)) - if flags != 0 { + if flags != SQLITE_ACCESS_EXISTS { var pParent uintptr = (*fs_vfs_t)(unsafe.Pointer(pVfs)).FpParent return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pParent + 56 /* &.xAccess */))))(tls, pParent, zPath, flags, pResOut) } @@ -72899,7 +68500,7 @@ func fsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut u } *(*int32)(unsafe.Pointer(pResOut)) = (libc.Bool32((pReal != 0) && (!(isJournal != 0) || ((*fs_real_file)(unsafe.Pointer(pReal)).FnJournal > 0)))) - return 0 + return SQLITE_OK } // Populate buffer zOut with the full canonical pathname corresponding @@ -72961,7 +68562,7 @@ func fsCurrentTime(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) int32 { /* tes // available function in this file. func fs_register(tls *libc.TLS) int32 { /* test_onefile.c:821:5: */ if fs_vfs.FpParent != 0 { - return 0 + return SQLITE_OK } fs_vfs.FpParent = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) fs_vfs.Fbase.FmxPathname = (*sqlite3_vfs)(unsafe.Pointer(fs_vfs.FpParent)).FmxPathname @@ -73100,79 +68701,42 @@ type VfslogFile1 = struct { type VfslogFile = VfslogFile1 /* test_osinst.c:118:27 */ var vfslog_vfs = sqlite3_vfs{ - FiVersion: 1, - FszOsFile:// iVersion - int32(unsafe.Sizeof(VfslogFile{})), - FmxPathname:// szOsFile - 512, - FpNext:// mxPathname - uintptr(0), - FzName:// pNext - uintptr(0), - FpAppData:// zName - uintptr(0), - FxOpen:// pAppData - 0, - FxDelete:// xOpen - 0, - FxAccess:// xDelete - 0, - FxFullPathname:// xAccess - 0, - FxDlOpen:// xFullPathname - 0, - FxDlError:// xDlOpen - 0, - FxDlSym:// xDlError - 0, - FxDlClose:// xDlSym - 0, - FxRandomness:// xDlClose - 0, - FxSleep:// xRandomness - 0, - FxCurrentTime:// xSleep - 0, - FxGetLastError:// xCurrentTime - 0, - FxCurrentTimeInt64:// xGetLastError - 0, // xCurrentTime + FiVersion: 1, // iVersion + FszOsFile: int32(unsafe.Sizeof(VfslogFile{})), // szOsFile + FmxPathname: INST_MAX_PATHNAME, // pAppData + FxOpen: 0, // xOpen + FxDelete: 0, // xDelete + FxAccess: 0, // xAccess + FxFullPathname: 0, // xFullPathname + FxDlOpen: 0, // xDlOpen + FxDlError: 0, // xDlError + FxDlSym: 0, // xDlSym + FxDlClose: 0, // xDlClose + FxRandomness: 0, // xRandomness + FxSleep: 0, // xSleep + FxCurrentTime: 0, // xCurrentTime + FxGetLastError: 0, // xGetLastError + FxCurrentTimeInt64: 0, // xCurrentTime } /* test_osinst.c:180:20 */ var vfslog_io_methods = sqlite3_io_methods{ - FiVersion: 2, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - 0, - FxUnlock:// xLock - 0, - FxCheckReservedLock:// xUnlock - 0, - FxFileControl:// xCheckReservedLock - 0, - FxSectorSize:// xFileControl - 0, - FxDeviceCharacteristics:// xSectorSize - 0, - FxShmMap:// xDeviceCharacteristics - 0, - FxShmLock:// xShmMap - 0, - FxShmBarrier:// xShmLock - 0, - FxShmUnmap:// xShmBarrier - 0, // xShmUnmap + FiVersion: 2, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xFileSize + FxLock: 0, // xLock + FxUnlock: 0, // xUnlock + FxCheckReservedLock: 0, // xCheckReservedLock + FxFileControl: 0, // xFileControl + FxSectorSize: 0, // xSectorSize + FxDeviceCharacteristics: 0, // xDeviceCharacteristics + FxShmMap: 0, // xShmMap + FxShmLock: 0, // xShmLock + FxShmBarrier: 0, // xShmBarrier + FxShmUnmap: 0, // xShmUnmap } /* test_osinst.c:202:27 */ // Convenience macros for operations on timevals. @@ -73191,7 +68755,7 @@ func vfslog_time(tls *libc.TLS) sqlite3_uint64 { /* test_osinst.c:224:23: */ // Close an vfslog-file. func vfslogClose(tls *libc.TLS, pFile uintptr) int32 { /* test_osinst.c:256:12: */ var t sqlite3_uint64 - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr = pFile t = vfslog_time(tls) @@ -73199,7 +68763,7 @@ func vfslogClose(tls *libc.TLS, pFile uintptr) int32 { /* test_osinst.c:256:12: 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) } t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 3, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_CLOSE, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) return rc } @@ -73211,7 +68775,7 @@ func vfslogRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sq t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 14, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, iAmt, int32(iOfst)) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_READ, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, iAmt, int32(iOfst)) return rc } @@ -73223,7 +68787,7 @@ func vfslogWrite(tls *libc.TLS, pFile uintptr, z uintptr, iAmt int32, iOfst sqli t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 20, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, iAmt, int32(iOfst)) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_WRITE, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, iAmt, int32(iOfst)) return rc } @@ -73235,7 +68799,7 @@ func vfslogTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 18, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, int32(size)) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_TRUNCATE, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, int32(size)) return rc } @@ -73247,7 +68811,7 @@ func vfslogSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_osins t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 17, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, flags, 0) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_SYNC, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, flags, 0) return rc } @@ -73259,7 +68823,7 @@ func vfslogFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* test t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 8, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, int32(*(*sqlite_int64)(unsafe.Pointer(pSize)))) + 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)))) return rc } @@ -73271,7 +68835,7 @@ func vfslogLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_osins t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 11, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, eLock, 0) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_LOCK, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, eLock, 0) return rc } @@ -73283,7 +68847,7 @@ func vfslogUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_osi t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 19, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, eLock, 0) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_UNLOCK, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, eLock, 0) return rc } @@ -73295,7 +68859,7 @@ func vfslogCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int3 t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 2, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, *(*int32)(unsafe.Pointer(pResOut)), 0) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_CHECKRESERVEDLOCK, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, *(*int32)(unsafe.Pointer(pResOut)), 0) return rc } @@ -73306,7 +68870,7 @@ func vfslogFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int var p uintptr = pFile 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) - if (op == 12) && (rc == 0) { + if (op == SQLITE_FCNTL_VFSNAME) && (rc == SQLITE_OK) { *(*uintptr)(unsafe.Pointer(pArg)) = sqlite3.Xsqlite3_mprintf(tls, ts+34302 /* "vfslog/%z" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(pArg)))) } return rc @@ -73320,7 +68884,7 @@ func vfslogSectorSize(tls *libc.TLS, pFile uintptr) int32 { /* test_osinst.c:407 t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 15, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_SECTORSIZE, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) return rc } @@ -73332,7 +68896,7 @@ func vfslogDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* test_o t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 6, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_DEVCHAR, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) return rc } @@ -73343,7 +68907,7 @@ func vfslogShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int3 t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 25, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_SHMLOCK, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) return rc } @@ -73354,7 +68918,7 @@ func vfslogShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, szRegion int32, i t = vfslog_time(tls) 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)) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 23, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_SHMMAP, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) return rc } @@ -73364,7 +68928,7 @@ func vfslogShmBarrier(tls *libc.TLS, pFile uintptr) { /* test_osinst.c:458:13: * t = vfslog_time(tls) (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 120 /* &.xShmBarrier */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 26, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), 0, 0, 0) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_SHMBARRIER, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), SQLITE_OK, 0, 0) } func vfslogShmUnmap(tls *libc.TLS, pFile uintptr, deleteFlag int32) int32 { /* test_osinst.c:466:12: */ @@ -73374,7 +68938,7 @@ func vfslogShmUnmap(tls *libc.TLS, pFile uintptr, deleteFlag int32) int32 { /* t t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, 22, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) + vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_SHMUNMAP, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) return rc } @@ -73386,7 +68950,7 @@ func vfslogOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags var pLog uintptr = pVfs (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&vfslog_io_methods)) - (*VfslogFile)(unsafe.Pointer(p)).FpReal = (p + uintptr(1)*32) + (*VfslogFile)(unsafe.Pointer(p)).FpReal = (p + 1*32) (*VfslogFile)(unsafe.Pointer(p)).FpVfslog = pVfs (*VfslogFile)(unsafe.Pointer(p)).FiFileId = libc.PreIncInt32(&(*VfslogVfs)(unsafe.Pointer(pLog)).FiNextFileId, 1) @@ -73394,7 +68958,7 @@ func vfslogOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, pVfs, 12, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) + vfslog_call(tls, pVfs, OS_OPEN, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) vfslog_string(tls, pVfs, zName) return rc } @@ -73408,7 +68972,7 @@ func vfslogDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, pVfs, 5, 0, int64(t), rc, dirSync, 0) + vfslog_call(tls, pVfs, OS_DELETE, 0, int64(t), rc, dirSync, 0) vfslog_string(tls, pVfs, zPath) return rc } @@ -73421,7 +68985,7 @@ func vfslogAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResO t = vfslog_time(tls) 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) t = (vfslog_time(tls) - t) - vfslog_call(tls, pVfs, 1, 0, int64(t), rc, flags, *(*int32)(unsafe.Pointer(pResOut))) + vfslog_call(tls, pVfs, OS_ACCESS, 0, int64(t), rc, flags, *(*int32)(unsafe.Pointer(pResOut))) vfslog_string(tls, pVfs, zPath) return rc } @@ -73502,10 +69066,10 @@ func vfslog_flush(tls *libc.TLS, p uintptr) { /* test_osinst.c:617:13: */ } func put32bits(tls *libc.TLS, p uintptr, v uint32) { /* test_osinst.c:645:13: */ - *(*uint8)(unsafe.Pointer(p + uintptr(0))) = (uint8(v >> 24)) - *(*uint8)(unsafe.Pointer(p + uintptr(1))) = (uint8(v >> 16)) - *(*uint8)(unsafe.Pointer(p + uintptr(2))) = (uint8(v >> 8)) - *(*uint8)(unsafe.Pointer(p + uintptr(3))) = uint8(v) + *(*uint8)(unsafe.Pointer(p)) = (uint8(v >> 24)) + *(*uint8)(unsafe.Pointer(p + 1)) = (uint8(v >> 16)) + *(*uint8)(unsafe.Pointer(p + 2)) = (uint8(v >> 8)) + *(*uint8)(unsafe.Pointer(p + 3)) = uint8(v) } 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: */ @@ -73515,12 +69079,12 @@ func vfslog_call(tls *libc.TLS, pVfs uintptr, eEvent int32, iFileid int32, nClic vfslog_flush(tls, p) } zRec = ((p + 204 /* &.aBuf */) + uintptr((*VfslogVfs)(unsafe.Pointer(p)).FnBuf)) - put32bits(tls, (zRec + uintptr(0)), uint32(eEvent)) - put32bits(tls, (zRec + uintptr(4)), uint32(iFileid)) - put32bits(tls, (zRec + uintptr(8)), (uint32(nClick & int64(0xffff)))) - put32bits(tls, (zRec + uintptr(12)), uint32(return_code)) - put32bits(tls, (zRec + uintptr(16)), uint32(size)) - put32bits(tls, (zRec + uintptr(20)), uint32(offset)) + put32bits(tls, (zRec), uint32(eEvent)) + put32bits(tls, (zRec + 4), uint32(iFileid)) + put32bits(tls, (zRec + 8), (uint32(nClick & int64(0xffff)))) + put32bits(tls, (zRec + 12), uint32(return_code)) + put32bits(tls, (zRec + 16), uint32(size)) + put32bits(tls, (zRec + 20), uint32(offset)) *(*int32)(unsafe.Pointer(p + 200 /* &.nBuf */)) += (24) } @@ -73537,9 +69101,9 @@ func vfslog_string(tls *libc.TLS, pVfs uintptr, zStr uintptr) { /* test_osinst.c vfslog_flush(tls, p) } zRec = ((p + 204 /* &.aBuf */) + uintptr((*VfslogVfs)(unsafe.Pointer(p)).FnBuf)) - put32bits(tls, (zRec + uintptr(0)), uint32(nStr)) + put32bits(tls, (zRec), uint32(nStr)) if zStr != 0 { - libc.Xmemcpy(tls, (zRec + uintptr(4)), zStr, uint64(nStr)) + libc.Xmemcpy(tls, (zRec + 4), zStr, uint64(nStr)) } *(*int32)(unsafe.Pointer(p + 200 /* &.nBuf */)) += (4 + nStr) } @@ -73558,11 +69122,11 @@ func sqlite3_vfslog_finalize(tls *libc.TLS, zVfs uintptr) int32 { /* test_osinst if !(pVfs != 0) || ((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FxOpen != *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32 }{vfslogOpen}))) { - return 1 + return SQLITE_ERROR } sqlite3.Xsqlite3_vfs_unregister(tls, pVfs) vfslog_finalize(tls, pVfs) - return 0 + return SQLITE_OK } func sqlite3_vfslog_new(tls *libc.TLS, zVfs uintptr, zParentVfs uintptr, zLog uintptr) int32 { /* test_osinst.c:710:5: */ @@ -73580,7 +69144,7 @@ func sqlite3_vfslog_new(tls *libc.TLS, zVfs uintptr, zParentVfs uintptr, zLog ui pParent = sqlite3.Xsqlite3_vfs_find(tls, zParentVfs) if !(pParent != 0) { - return 1 + return SQLITE_ERROR } nVfs = int32(libc.Xstrlen(tls, zVfs)) @@ -73589,7 +69153,7 @@ func sqlite3_vfslog_new(tls *libc.TLS, zVfs uintptr, zParentVfs uintptr, zLog ui libc.Xmemset(tls, p, 0, uint64(nByte)) (*VfslogVfs)(unsafe.Pointer(p)).FpVfs = pParent - (*VfslogVfs)(unsafe.Pointer(p)).FpLog = (p + uintptr(1)*8400) + (*VfslogVfs)(unsafe.Pointer(p)).FpLog = (p + 1*8400) libc.Xmemcpy(tls, (p /* &.base */), uintptr(unsafe.Pointer(&vfslog_vfs)), uint64(unsafe.Sizeof(sqlite3_vfs{}))) (*VfslogVfs)(unsafe.Pointer(p)).Fbase.FzName = (((*VfslogVfs)(unsafe.Pointer(p)).FpLog) + uintptr((*sqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile)) *(*int32)(unsafe.Pointer(p /* &.base */ + 4 /* &.szOsFile */)) += ((*sqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile) @@ -73598,10 +69162,10 @@ func sqlite3_vfslog_new(tls *libc.TLS, zVfs uintptr, zParentVfs uintptr, zLog ui zFile = ((*VfslogVfs)(unsafe.Pointer(p)).Fbase.FzName + uintptr((nVfs + 1))) (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pParent + 64 /* &.xFullPathname */))))(tls, pParent, zLog, (*sqlite3_vfs)(unsafe.Pointer(pParent)).FmxPathname, zFile) - *(*int32)(unsafe.Pointer(bp /* flags */)) = ((0x00000002 | 0x00000004) | 0x00004000) + *(*int32)(unsafe.Pointer(bp /* flags */)) = ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_SUPER_JOURNAL) (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pParent + 48 /* &.xDelete */))))(tls, pParent, zFile, 0) 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 */) - if rc == 0 { + if rc == SQLITE_OK { libc.Xmemcpy(tls, p+204 /* &.aBuf */, ts+34312 /* "sqlite_ostrace1...." */, uint64(20)) (*VfslogVfs)(unsafe.Pointer(p)).FiOffset = int64(0) (*VfslogVfs)(unsafe.Pointer(p)).FnBuf = 20 @@ -73619,89 +69183,89 @@ func sqlite3_vfslog_annotate(tls *libc.TLS, zVfs uintptr, zMsg uintptr) int32 { if !(pVfs != 0) || ((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FxOpen != *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32 }{vfslogOpen}))) { - return 1 + return SQLITE_ERROR } - vfslog_call(tls, pVfs, 28, 0, int64(0), 0, 0, 0) + vfslog_call(tls, pVfs, OS_ANNOTATE, 0, int64(0), 0, 0, 0) vfslog_string(tls, pVfs, zMsg) - return 0 + return SQLITE_OK } func vfslog_eventname(tls *libc.TLS, eEvent int32) uintptr { /* test_osinst.c:769:19: */ var zEvent uintptr = uintptr(0) switch eEvent { - case 3: + case OS_CLOSE: zEvent = ts + 34333 /* "xClose" */ break - case 14: + case OS_READ: zEvent = ts + 34340 /* "xRead" */ break - case 20: + case OS_WRITE: zEvent = ts + 34346 /* "xWrite" */ break - case 18: + case OS_TRUNCATE: zEvent = ts + 34353 /* "xTruncate" */ break - case 17: + case OS_SYNC: zEvent = ts + 26827 /* "xSync" */ break - case 8: + case OS_FILESIZE: zEvent = ts + 34363 /* "xFilesize" */ break - case 11: + case OS_LOCK: zEvent = ts + 34373 /* "xLock" */ break - case 19: + case OS_UNLOCK: zEvent = ts + 34379 /* "xUnlock" */ break - case 2: + case OS_CHECKRESERVEDLOCK: zEvent = ts + 34387 /* "xCheckResLock" */ break - case 7: + case OS_FILECONTROL: zEvent = ts + 34401 /* "xFileControl" */ break - case 15: + case OS_SECTORSIZE: zEvent = ts + 34414 /* "xSectorSize" */ break - case 6: + case OS_DEVCHAR: zEvent = ts + 34426 /* "xDeviceChar" */ break - case 12: + case OS_OPEN: zEvent = ts + 26399 /* "xOpen" */ break - case 5: + case OS_DELETE: zEvent = ts + 34438 /* "xDelete" */ break - case 1: + case OS_ACCESS: zEvent = ts + 34446 /* "xAccess" */ break - case 9: + case OS_FULLPATHNAME: zEvent = ts + 34454 /* "xFullPathname" */ break - case 13: + case OS_RANDOMNESS: zEvent = ts + 34468 /* "xRandomness" */ break - case 16: + case OS_SLEEP: zEvent = ts + 34480 /* "xSleep" */ break - case 4: + case OS_CURRENTTIME: zEvent = ts + 34487 /* "xCurrentTime" */ break - case 22: + case OS_SHMUNMAP: zEvent = ts + 34500 /* "xShmUnmap" */ break - case 25: + case OS_SHMLOCK: zEvent = ts + 34510 /* "xShmLock" */ break - case 26: + case OS_SHMBARRIER: zEvent = ts + 34519 /* "xShmBarrier" */ break - case 23: + case OS_SHMMAP: zEvent = ts + 34531 /* "xShmMap" */ break - case 28: + case OS_ANNOTATE: zEvent = ts + 34539 /* "annotation" */ break } @@ -73731,7 +69295,7 @@ type VfslogCsr1 = struct { type VfslogCsr = VfslogCsr1 /* test_osinst.c:805:26 */ func get32bits(tls *libc.TLS, p uintptr) uint32 { /* test_osinst.c:830:21: */ - return (uint32((((int32(*(*uint8)(unsafe.Pointer(p + uintptr(0)))) << 24) + (int32(*(*uint8)(unsafe.Pointer(p + uintptr(1)))) << 16)) + (int32(*(*uint8)(unsafe.Pointer(p + uintptr(2)))) << 8)) + int32(*(*uint8)(unsafe.Pointer(p + uintptr(3)))))) + 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))))) } // The argument must point to a buffer containing a nul-terminated string. @@ -73739,7 +69303,7 @@ func get32bits(tls *libc.TLS, p uintptr) uint32 { /* test_osinst.c:830:21: */ // the dequoted version. Otherwise the buffer is left unmodified. func dequote(tls *libc.TLS, z uintptr) { /* test_osinst.c:839:13: */ var quote int8 // Quote character (if any ) - quote = *(*int8)(unsafe.Pointer(z + uintptr(0))) + quote = *(*int8)(unsafe.Pointer(z)) if (((int32(quote) == '[') || (int32(quote) == '\'')) || (int32(quote) == '"')) || (int32(quote) == '`') { var iIn int32 = 1 // Index of next byte to read from input var iOut int32 = 0 // Index of next byte to write to output @@ -73779,26 +69343,26 @@ func vlogConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintp nByte = (int32((uint64(unsafe.Sizeof(VfslogVtab{})) + uint64((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)) + uint64((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname))) p = sqlite3.Xsqlite3_malloc(tls, nByte) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, p, 0, uint64(nByte)) - (*VfslogVtab)(unsafe.Pointer(p)).FpFd = (p + uintptr(1)*48) + (*VfslogVtab)(unsafe.Pointer(p)).FpFd = (p + 1*48) (*VfslogVtab)(unsafe.Pointer(p)).FzFile = (((*VfslogVtab)(unsafe.Pointer(p)).FpFd) + uintptr((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)) - zFile = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)))) + zFile = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + 3*8)))) if !(zFile != 0) { sqlite3.Xsqlite3_free(tls, p) - return 7 + return SQLITE_NOMEM } dequote(tls, zFile) (*(*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) sqlite3.Xsqlite3_free(tls, zFile) - *(*int32)(unsafe.Pointer(bp + 8 /* flags */)) = (0x00000002 | 0x00004000) + *(*int32)(unsafe.Pointer(bp + 8 /* flags */)) = (SQLITE_OPEN_READWRITE | SQLITE_OPEN_SUPER_JOURNAL) 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 */) - if rc == 0 { + if rc == SQLITE_OK { (*(*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 */)) sqlite3.Xsqlite3_declare_vtab(tls, db, ts+34550 /* "CREATE TABLE xxx..." */) @@ -73814,7 +69378,7 @@ func vlogConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintp // scan of the binary VFS log file. func vlogBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_osinst.c:916:12: */ (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 10.0 - return 0 + return SQLITE_OK } // Disconnect from or destroy a vfslog virtual table. @@ -73825,7 +69389,7 @@ func vlogDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* test_osinst.c:924:1 (*sqlite3_file)(unsafe.Pointer((*VfslogVtab)(unsafe.Pointer(p)).FpFd)).FpMethods = uintptr(0) } sqlite3.Xsqlite3_free(tls, p) - return 0 + return SQLITE_OK } // Open a new vfslog cursor. @@ -73834,11 +69398,11 @@ func vlogOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_os pCsr = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(VfslogCsr{}))) if !(pCsr != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCsr, 0, uint64(unsafe.Sizeof(VfslogCsr{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCsr /* &.base */) - return 0 + return SQLITE_OK } // Close a vfslog cursor. @@ -73851,7 +69415,7 @@ func vlogClose(tls *libc.TLS, pCursor uintptr) int32 { /* test_osinst.c:950:12: sqlite3.Xsqlite3_free(tls, (*VfslogCsr)(unsafe.Pointer(p)).FazFile) sqlite3.Xsqlite3_free(tls, (*VfslogCsr)(unsafe.Pointer(p)).FzTransient) sqlite3.Xsqlite3_free(tls, p) - return 0 + return SQLITE_OK } // Move a vfslog cursor to the next entry in the file. @@ -73861,7 +69425,7 @@ func vlogNext(tls *libc.TLS, pCursor uintptr) int32 { /* test_osinst.c:965:12: * var pCsr uintptr = pCursor var p uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab - var rc int32 = 0 + var rc int32 = SQLITE_OK var nRead int32 sqlite3.Xsqlite3_free(tls, (*VfslogCsr)(unsafe.Pointer(pCsr)).FzTransient) @@ -73873,21 +69437,21 @@ func vlogNext(tls *libc.TLS, pCursor uintptr) int32 { /* test_osinst.c:965:12: * 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) eEvent = int32(get32bits(tls, pCsr+48 /* &.aBuf */)) - if (rc == 0) && - (((eEvent == 12) || (eEvent == 5)) || (eEvent == 1)) { + if (rc == SQLITE_OK) && + (((eEvent == OS_OPEN) || (eEvent == OS_DELETE)) || (eEvent == OS_ACCESS)) { // var buf [4]int8 at bp, 4 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))) nRead = nRead + (4) - if rc == 0 { + if rc == SQLITE_OK { var nStr int32 = int32(get32bits(tls, bp /* buf */)) var zStr uintptr = sqlite3.Xsqlite3_malloc(tls, (nStr + 1)) 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))) *(*int8)(unsafe.Pointer(zStr + uintptr(nStr))) = int8(0) nRead = nRead + (nStr) - if eEvent == 12 { - var iFileid int32 = int32(get32bits(tls, ((pCsr + 48 /* &.aBuf */) + uintptr(4)))) + if eEvent == OS_OPEN { + var iFileid int32 = int32(get32bits(tls, ((pCsr + 48 /* &.aBuf */) + 4))) if iFileid >= (*VfslogCsr)(unsafe.Pointer(pCsr)).FnFile { var nNew int32 = (int32(uint64(unsafe.Sizeof(uintptr(0))) * (uint64(iFileid + 1)))) (*VfslogCsr)(unsafe.Pointer(pCsr)).FazFile = sqlite3.Xsqlite3_realloc(tls, (*VfslogCsr)(unsafe.Pointer(pCsr)).FazFile, nNew) @@ -73950,61 +69514,34 @@ func vlogColumn(tls *libc.TLS, pCursor uintptr, ctx uintptr, i int32) int32 { /* break } - return 0 + return SQLITE_OK } func vlogRowid(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { /* test_osinst.c:1065:12: */ var pCsr uintptr = pCursor *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*VfslogCsr)(unsafe.Pointer(pCsr)).FiRowid - return 0 + return SQLITE_OK } func sqlite3_vfslog_register(tls *libc.TLS, db uintptr) int32 { /* test_osinst.c:1071:5: */ sqlite3.Xsqlite3_create_module(tls, db, ts+34605 /* "vfslog" */, uintptr(unsafe.Pointer(&vfslog_module)), uintptr(0)) - return 0 + return SQLITE_OK } -var vfslog_module = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - 0, - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename +var vfslog_module = sqlite3_module{ // iVersion + FxCreate: 0, // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDisconnect + FxDestroy: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRename } /* test_osinst.c:1072:25 */ // end block for C++ @@ -74022,15 +69559,15 @@ func test_vfslog(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, var db uintptr // var cmdInfo Tcl_CmdInfo at bp+80, 64 - var rc int32 = 1 + var rc int32 = SQLITE_ERROR // var iSub int32 at bp+72, 4 if objc < 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31821 /* "SUB-COMMAND ..." */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), uintptr(unsafe.Pointer(&strs)), int32(unsafe.Sizeof(uintptr(0))), ts+1874 /* "sub-command" */, 0, bp+72 /* &iSub */) != 0 { - return 1 + if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&strs)), int32(unsafe.Sizeof(uintptr(0))), ts+1874 /* "sub-command" */, 0, bp+72 /* &iSub */) != 0 { + return TCL_ERROR } switch uint32(*(*int32)(unsafe.Pointer(bp + 72 /* iSub */))) { @@ -74040,14 +69577,14 @@ func test_vfslog(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, var zMsg uintptr if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 3, objv, ts+34612 /* "VFS" */) - return 1 + return TCL_ERROR } - zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - zMsg = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + zMsg = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) rc = sqlite3_vfslog_annotate(tls, zVfs, zMsg) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+34616 /* "failed" */, 0)) - return 1 + return TCL_ERROR } break @@ -74057,13 +69594,13 @@ func test_vfslog(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, var zVfs uintptr if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+34612 /* "VFS" */) - return 1 + return TCL_ERROR } - zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) rc = sqlite3_vfslog_finalize(tls, zVfs) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+34616 /* "failed" */, 0)) - return 1 + return TCL_ERROR } break @@ -74076,18 +69613,18 @@ func test_vfslog(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, var zLog uintptr if objc != 5 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+34623 /* "VFS PARENT LOGFI..." */) - return 1 + return TCL_ERROR } - zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - zParent = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) - zLog = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8))) + zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + zParent = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) + zLog = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) if int32(*(*int8)(unsafe.Pointer(zParent))) == 0 { zParent = uintptr(0) } rc = sqlite3_vfslog_new(tls, zVfs, zParent, zLog) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+34616 /* "failed" */, 0)) - return 1 + return TCL_ERROR } break @@ -74098,23 +69635,23 @@ func test_vfslog(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, var zDb uintptr if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if tcl.XTcl_GetCommandInfo(tls, interp, zDb, bp+80 /* &cmdInfo */) != 0 { db = (*struct{ Fdb uintptr })(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp + 80 /* &cmdInfo */)).FobjClientData)).Fdb rc = sqlite3_vfslog_register(tls, db) } - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+34642 /* "bad sqlite3 hand..." */, zDb, uintptr(0))) - return 1 + return TCL_ERROR } break } } - return 0 + return TCL_OK } var strs = [5]uintptr{ts + 34663 /* "annotate" */, ts + 34672 /* "finalize" */, ts + 13511 /* "new" */, ts + 34681 /* "register" */, uintptr(0)} /* test_osinst.c:1127:21 */ @@ -74123,7 +69660,7 @@ func SqlitetestOsinst_Init(tls *libc.TLS, interp uintptr) int32 { /* test_osinst tcl.XTcl_CreateObjCommand(tls, interp, ts+34605 /* "vfslog" */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 }{test_vfslog})), uintptr(0), uintptr(0)) - return 0 + return TCL_OK } // Copyright (C) 1991-2018 Free Software Foundation, Inc. @@ -74249,9 +69786,9 @@ func testpcacheInit(tls *libc.TLS, pArg uintptr) int32 { /* test_pcache.c:53:12: testpcacheGlobal.FpDummy = sqlite3.Xsqlite3_malloc(tls, 10) if testpcacheGlobal.FpDummy == uintptr(0) { - return 7 + return SQLITE_NOMEM } - return 0 + return SQLITE_OK } // Destructor @@ -74327,23 +69864,23 @@ func testpcacheCreate(tls *libc.TLS, szPage int32, szExtra int32, bPurgeable int var p uintptr var i int32 - szPage = ((szPage + 7) & ^libc.Int32(7)) - nMem = (int32(uint64(unsafe.Sizeof(testpcache{})) + (uint64(217 * (szPage + szExtra))))) + szPage = ((szPage + 7) & libc.CplInt32(7)) + nMem = (int32(uint64(unsafe.Sizeof(testpcache{})) + (uint64(TESTPCACHE_NPAGE * (szPage + szExtra))))) p = sqlite3.Xsqlite3_malloc(tls, nMem) if p == uintptr(0) { return uintptr(0) } - x = (p + uintptr(1)*5240) + x = (p + 1*5240) (*testpcache)(unsafe.Pointer(p)).FszPage = szPage (*testpcache)(unsafe.Pointer(p)).FszExtra = szExtra - (*testpcache)(unsafe.Pointer(p)).FnFree = 217 + (*testpcache)(unsafe.Pointer(p)).FnFree = TESTPCACHE_NPAGE (*testpcache)(unsafe.Pointer(p)).FnPinned = 0 (*testpcache)(unsafe.Pointer(p)).FiRand = testpcacheGlobal.FprngSeed (*testpcache)(unsafe.Pointer(p)).FbPurgeable = bPurgeable - (*testpcache)(unsafe.Pointer(p)).FiMagic = uint32(0x364585fd) + (*testpcache)(unsafe.Pointer(p)).FiMagic = TESTPCACHE_VALID i = 0 __1: - if !(i < 217) { + if !(i < TESTPCACHE_NPAGE) { goto __3 } { @@ -74377,7 +69914,7 @@ func testpcacheCachesize(tls *libc.TLS, pCache uintptr, newSize int32) { /* test func testpcachePagecount(tls *libc.TLS, pCache uintptr) int32 { /* test_pcache.c:179:12: */ var p uintptr = pCache - return (217 - (*testpcache)(unsafe.Pointer(p)).FnFree) + return (TESTPCACHE_NPAGE - (*testpcache)(unsafe.Pointer(p)).FnFree) } // Fetch a page. @@ -74387,7 +69924,7 @@ func testpcacheFetch(tls *libc.TLS, pCache uintptr, key uint32, createFlag int32 var j int32 // See if the page is already in cache. Return immediately if it is - for i = 0; i < 217; i++ { + for i = 0; i < TESTPCACHE_NPAGE; i++ { if (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(i)*24)).Fkey == key { if !((*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(i)*24)).FisPinned != 0) { (*testpcache)(unsafe.Pointer(p)).FnPinned++ @@ -74404,12 +69941,12 @@ func testpcacheFetch(tls *libc.TLS, pCache uintptr, key uint32, createFlag int32 } // If no pages are available, always fail - if (*testpcache)(unsafe.Pointer(p)).FnPinned == 217 { + if (*testpcache)(unsafe.Pointer(p)).FnPinned == TESTPCACHE_NPAGE { return uintptr(0) } // Do not allocate the last TESTPCACHE_RESERVE pages unless createFlag is 2 - if ((*testpcache)(unsafe.Pointer(p)).FnPinned >= (217 - 17)) && (createFlag < 2) { + if ((*testpcache)(unsafe.Pointer(p)).FnPinned >= (TESTPCACHE_NPAGE - TESTPCACHE_RESERVE)) && (createFlag < 2) { return uintptr(0) } @@ -74423,11 +69960,11 @@ func testpcacheFetch(tls *libc.TLS, pCache uintptr, key uint32, createFlag int32 // Find a free page to allocate if there are any free pages. // Withhold TESTPCACHE_RESERVE free pages until createFlag is 2. - if ((*testpcache)(unsafe.Pointer(p)).FnFree > 17) || ((createFlag == 2) && ((*testpcache)(unsafe.Pointer(p)).FnFree > 0)) { - j = (int32(testpcacheRandom(tls, p) % uint32(217))) + if ((*testpcache)(unsafe.Pointer(p)).FnFree > TESTPCACHE_RESERVE) || ((createFlag == 2) && ((*testpcache)(unsafe.Pointer(p)).FnFree > 0)) { + j = (int32(testpcacheRandom(tls, p) % TESTPCACHE_NPAGE)) i = 0 __1: - if !(i < 217) { + if !(i < TESTPCACHE_NPAGE) { goto __3 } { @@ -74446,7 +69983,7 @@ func testpcacheFetch(tls *libc.TLS, pCache uintptr, key uint32, createFlag int32 goto __2 __2: i++ - j = ((j + 1) % 217) + j = ((j + 1) % TESTPCACHE_NPAGE) goto __1 goto __3 __3: @@ -74462,10 +69999,10 @@ func testpcacheFetch(tls *libc.TLS, pCache uintptr, key uint32, createFlag int32 // If there are no free pages, recycle a page. The page to // recycle is selected at random from all unpinned pages. - j = (int32(testpcacheRandom(tls, p) % uint32(217))) + j = (int32(testpcacheRandom(tls, p) % TESTPCACHE_NPAGE)) i = 0 __4: - if !(i < 217) { + if !(i < TESTPCACHE_NPAGE) { goto __6 } { @@ -74483,7 +70020,7 @@ __4: goto __5 __5: i++ - j = ((j + 1) % 217) + j = ((j + 1) % TESTPCACHE_NPAGE) goto __4 goto __6 __6: @@ -74507,7 +70044,7 @@ func testpcacheUnpin(tls *libc.TLS, pCache uintptr, pOldPage uintptr, discard in discard = 1 } - for i = 0; i < 217; i++ { + for i = 0; i < TESTPCACHE_NPAGE; i++ { if ((p + 32 /* &.a */) + uintptr(i)*24 /* &.page */) == pOldPage { // The pOldPage pointer always points to a pinned page @@ -74534,7 +70071,7 @@ func testpcacheRekey(tls *libc.TLS, pCache uintptr, pOldPage uintptr, oldKey uin // If there already exists another page at newKey, verify that // the other page is unpinned and discard it. - for i = 0; i < 217; i++ { + for i = 0; i < TESTPCACHE_NPAGE; i++ { if (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(i)*24)).Fkey == newKey { // The new key is never a page that is already pinned @@ -74546,7 +70083,7 @@ func testpcacheRekey(tls *libc.TLS, pCache uintptr, pOldPage uintptr, oldKey uin } // Find the page to be rekeyed and rekey it. - for i = 0; i < 217; i++ { + for i = 0; i < TESTPCACHE_NPAGE; i++ { if (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(i)*24)).Fkey == oldKey { // The oldKey and pOldPage parameters match @@ -74567,7 +70104,7 @@ func testpcacheTruncate(tls *libc.TLS, pCache uintptr, iLimit uint32) { /* test_ var p uintptr = pCache var i uint32 - for i = uint32(0); i < uint32(217); i++ { + for i = uint32(0); i < TESTPCACHE_NPAGE; i++ { if (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(i)*24)).Fkey >= iLimit { (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(i)*24)).Fkey = uint32(0) if (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(i)*24)).FisPinned != 0 { @@ -74584,7 +70121,7 @@ func testpcacheTruncate(tls *libc.TLS, pCache uintptr, iLimit uint32) { /* test_ func testpcacheDestroy(tls *libc.TLS, pCache uintptr) { /* test_pcache.c:404:13: */ var p uintptr = pCache - (*testpcache)(unsafe.Pointer(p)).FiMagic = 0xd42670d4 + (*testpcache)(unsafe.Pointer(p)).FiMagic = TESTPCACHE_CLEAR sqlite3.Xsqlite3_free(tls, p) testpcacheGlobal.FnInstance-- } @@ -74608,12 +70145,12 @@ func installTestPCache(tls *libc.TLS, installFlag int32, discardChance uint32, p testpcacheGlobal.FhighStress = highStress if installFlag != isInstalled { if installFlag != 0 { - sqlite3.Xsqlite3_config(tls, 19, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultPcache)))) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETPCACHE2, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultPcache)))) - sqlite3.Xsqlite3_config(tls, 18, libc.VaList(bp+8, uintptr(unsafe.Pointer(&testPcache)))) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PCACHE2, libc.VaList(bp+8, uintptr(unsafe.Pointer(&testPcache)))) } else { - sqlite3.Xsqlite3_config(tls, 18, libc.VaList(bp+16, uintptr(unsafe.Pointer(&defaultPcache)))) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PCACHE2, libc.VaList(bp+16, uintptr(unsafe.Pointer(&defaultPcache)))) } isInstalled = installFlag } @@ -74849,7 +70386,7 @@ func quotaStrglob(tls *libc.TLS, zGlob uintptr, z uintptr) int32 { /* test_quota c2 = int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zGlob, 1)))) } for (c2 != 0) && (c2 != ']') { - if (((c2 == '-') && (int32(*(*int8)(unsafe.Pointer(zGlob + uintptr(0)))) != ']')) && (int32(*(*int8)(unsafe.Pointer(zGlob + uintptr(0)))) != 0)) && (prior_c > 0) { + if (((c2 == '-') && (int32(*(*int8)(unsafe.Pointer(zGlob))) != ']')) && (int32(*(*int8)(unsafe.Pointer(zGlob))) != 0)) && (prior_c > 0) { c2 = int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zGlob, 1)))) if (c >= prior_c) && (c <= c2) { seen = 1 @@ -74867,7 +70404,7 @@ func quotaStrglob(tls *libc.TLS, zGlob uintptr, z uintptr) int32 { /* test_quota return 0 } } else if c == '/' { - if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) != '/') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) != '\\') { + if (int32(*(*int8)(unsafe.Pointer(z))) != '/') && (int32(*(*int8)(unsafe.Pointer(z))) != '\\') { return 0 } z++ @@ -74894,7 +70431,7 @@ func quotaGroupFind(tls *libc.TLS, zFilename uintptr) uintptr { /* test_quota.c: // the sqlite3_file* for the underlying original VFS. func quotaSubOpen(tls *libc.TLS, pConn uintptr) uintptr { /* test_quota.c:339:21: */ var p uintptr = pConn - return (p + uintptr(1)*16) + return (p + 1*16) } // Find a file in a quota group and return a pointer to that file. @@ -74909,7 +70446,7 @@ func quotaFindFile(tls *libc.TLS, pGroup uintptr, zName uintptr, createFlag int3 pFile = sqlite3.Xsqlite3_malloc(tls, (int32((uint64(unsafe.Sizeof(quotaFile{})) + uint64(nName)) + uint64(1)))) if pFile != 0 { libc.Xmemset(tls, pFile, 0, uint64(unsafe.Sizeof(quotaFile{}))) - (*quotaFile)(unsafe.Pointer(pFile)).FzFilename = (pFile + uintptr(1)*48) + (*quotaFile)(unsafe.Pointer(pFile)).FzFilename = (pFile + 1*48) libc.Xmemcpy(tls, (*quotaFile)(unsafe.Pointer(pFile)).FzFilename, zName, (uint64(nName + 1))) (*quotaFile)(unsafe.Pointer(pFile)).FpNext = (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles if (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles != 0 { @@ -74951,7 +70488,7 @@ func quotaOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pConn uintptr, flags // If the file is not a main database file or a WAL, then use the // normal xOpen method. - if (flags & (0x00000100 | 0x00080000)) == 0 { + if (flags & (SQLITE_OPEN_MAIN_DB | SQLITE_OPEN_WAL)) == 0 { return (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 40 /* &.xOpen */))))(tls, pOrigVfs, zName, pConn, flags, pOutFlags) } @@ -74966,14 +70503,14 @@ func quotaOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pConn uintptr, flags pQuotaOpen = pConn pSubOpen = quotaSubOpen(tls, pConn) rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 40 /* &.xOpen */))))(tls, pOrigVfs, zName, pSubOpen, flags, pOutFlags) - if rc == 0 { + if rc == SQLITE_OK { pFile = quotaFindFile(tls, pGroup, zName, 1) if pFile == uintptr(0) { quotaLeave(tls) (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 8 /* &.xClose */))))(tls, pSubOpen) - return 7 + return SQLITE_NOMEM } - (*quotaFile)(unsafe.Pointer(pFile)).FdeleteOnClose = (libc.Bool32((flags & 0x00000008) != 0)) + (*quotaFile)(unsafe.Pointer(pFile)).FdeleteOnClose = (libc.Bool32((flags & SQLITE_OPEN_DELETEONCLOSE) != 0)) (*quotaFile)(unsafe.Pointer(pFile)).FnRef++ (*quotaConn)(unsafe.Pointer(pQuotaOpen)).FpFile = pFile if (*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods)).FiVersion == 1 { @@ -75003,7 +70540,7 @@ func quotaDelete(tls *libc.TLS, pVfs uintptr, zName uintptr, syncDir int32) int3 // If the file just deleted is a member of a quota group, then remove // it from that quota group. - if rc == 0 { + if rc == SQLITE_OK { quotaEnter(tls) pGroup = quotaGroupFind(tls, zName) if pGroup != 0 { @@ -75076,7 +70613,7 @@ func quotaWrite(tls *libc.TLS, pConn uintptr, pBuf uintptr, iAmt int32, iOfst sq } if (szNew > (*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit) && ((*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit > int64(0)) { quotaLeave(tls) - return 13 + return SQLITE_FULL } } (*quotaGroup)(unsafe.Pointer(pGroup)).FiSize = szNew @@ -75094,7 +70631,7 @@ func quotaTruncate(tls *libc.TLS, pConn uintptr, size sqlite3_int64) int32 { /* var rc int32 = (*(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 32 /* &.xTruncate */))))(tls, pSubOpen, size) var pFile uintptr = (*quotaConn)(unsafe.Pointer(p)).FpFile var pGroup uintptr - if rc == 0 { + if rc == SQLITE_OK { quotaEnter(tls) pGroup = (*quotaFile)(unsafe.Pointer(pFile)).FpGroup *(*sqlite3_int64)(unsafe.Pointer(pGroup + 16 /* &.iSize */)) -= ((*quotaFile)(unsafe.Pointer(pFile)).FiSize) @@ -75126,7 +70663,7 @@ func quotaFileSize(tls *libc.TLS, pConn uintptr, pSize uintptr) int32 { /* test_ var rc int32 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 48 /* &.xFileSize */))))(tls, pSubOpen, bp /* &sz */) - if rc == 0 { + if rc == SQLITE_OK { quotaEnter(tls) pGroup = (*quotaFile)(unsafe.Pointer(pFile)).FpGroup *(*sqlite3_int64)(unsafe.Pointer(pGroup + 16 /* &.iSize */)) -= ((*quotaFile)(unsafe.Pointer(pFile)).FiSize) @@ -75163,7 +70700,7 @@ func quotaFileControl(tls *libc.TLS, pConn uintptr, op int32, pArg uintptr) int3 var pSubOpen uintptr = quotaSubOpen(tls, pConn) var rc int32 = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 80 /* &.xFileControl */))))(tls, pSubOpen, op, pArg) - if (op == 12) && (rc == 0) { + if (op == SQLITE_FCNTL_VFSNAME) && (rc == SQLITE_OK) { *(*uintptr)(unsafe.Pointer(pArg)) = sqlite3.Xsqlite3_mprintf(tls, ts+34690 /* "quota/%z" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(pArg)))) } return rc @@ -75218,16 +70755,16 @@ func quotaShmUnmap(tls *libc.TLS, pConn uintptr, deleteFlag int32) int32 { /* te func sqlite3_quota_initialize(tls *libc.TLS, zOrigVfsName uintptr, makeDefault int32) int32 { /* test_quota.c:749:5: */ var pOrigVfs uintptr if gQuota.FisInitialized != 0 { - return 21 + return SQLITE_MISUSE } pOrigVfs = sqlite3.Xsqlite3_vfs_find(tls, zOrigVfsName) if pOrigVfs == uintptr(0) { - return 1 + return SQLITE_ERROR } - gQuota.FpMutex = sqlite3.Xsqlite3_mutex_alloc(tls, 0) + gQuota.FpMutex = sqlite3.Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST) if !(int32(gQuota.FpMutex) != 0) { - return 7 + return SQLITE_NOMEM } gQuota.FisInitialized = 1 gQuota.FpOrigVfs = pOrigVfs @@ -75290,7 +70827,7 @@ func sqlite3_quota_initialize(tls *libc.TLS, zOrigVfsName uintptr, makeDefault i f func(*libc.TLS, uintptr, int32) int32 }{quotaShmUnmap})) sqlite3.Xsqlite3_vfs_register(tls, (uintptr(unsafe.Pointer(&gQuota)) + 8 /* &.sThisVfs */), makeDefault) - return 0 + return SQLITE_OK } // Shutdown the quota system. @@ -75303,11 +70840,11 @@ func sqlite3_quota_initialize(tls *libc.TLS, zOrigVfsName uintptr, makeDefault i func sqlite3_quota_shutdown(tls *libc.TLS) int32 { /* test_quota.c:798:5: */ var pGroup uintptr if gQuota.FisInitialized == 0 { - return 21 + return SQLITE_MISUSE } for pGroup = gQuota.FpGroup; pGroup != 0; pGroup = (*quotaGroup)(unsafe.Pointer(pGroup)).FpNext { if quotaGroupOpenFileCount(tls, pGroup) > 0 { - return 21 + return SQLITE_MISUSE } } for gQuota.FpGroup != 0 { @@ -75321,7 +70858,7 @@ func sqlite3_quota_shutdown(tls *libc.TLS) int32 { /* test_quota.c:798:5: */ sqlite3.Xsqlite3_mutex_free(tls, gQuota.FpMutex) sqlite3.Xsqlite3_vfs_unregister(tls, (uintptr(unsafe.Pointer(&gQuota)) + 8 /* &.sThisVfs */)) libc.Xmemset(tls, uintptr(unsafe.Pointer(&gQuota)), 0, uint64(unsafe.Sizeof(gQuota))) - return 0 + return SQLITE_OK } // Create or destroy a quota group. @@ -75353,15 +70890,15 @@ func sqlite3_quota_set(tls *libc.TLS, zPattern uintptr, iLimit sqlite3_int64, xC var nPattern int32 = (int32(libc.Xstrlen(tls, zPattern) & uint64(0x3fffffff))) if iLimit <= int64(0) { quotaLeave(tls) - return 0 + return SQLITE_OK } pGroup = sqlite3.Xsqlite3_malloc(tls, (int32((uint64(unsafe.Sizeof(quotaGroup{})) + uint64(nPattern)) + uint64(1)))) if pGroup == uintptr(0) { quotaLeave(tls) - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pGroup, 0, uint64(unsafe.Sizeof(quotaGroup{}))) - (*quotaGroup)(unsafe.Pointer(pGroup)).FzPattern = (pGroup + uintptr(1)*72) + (*quotaGroup)(unsafe.Pointer(pGroup)).FzPattern = (pGroup + 1*72) libc.Xmemcpy(tls, (*quotaGroup)(unsafe.Pointer(pGroup)).FzPattern, zPattern, (uint64(nPattern + 1))) if gQuota.FpGroup != 0 { (*quotaGroup)(unsafe.Pointer(gQuota.FpGroup)).FppPrev = (pGroup + 48 /* &.pNext */) @@ -75379,7 +70916,7 @@ func sqlite3_quota_set(tls *libc.TLS, zPattern uintptr, iLimit sqlite3_int64, xC (*quotaGroup)(unsafe.Pointer(pGroup)).FxDestroy = xDestroy quotaGroupDeref(tls, pGroup) quotaLeave(tls) - return 0 + return SQLITE_OK } // Bring the named file under quota management. Or if it is already under @@ -75399,21 +70936,21 @@ func sqlite3_quota_file(tls *libc.TLS, zFilename uintptr) int32 { /* test_quota. // Allocate space for a file-handle and the full path for file zFilename fd = sqlite3.Xsqlite3_malloc(tls, nAlloc) if fd == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { zFull = ((fd) + uintptr(gQuota.FsThisVfs.FszOsFile)) rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((gQuota.FpOrigVfs + 64 /* &.xFullPathname */))))(tls, gQuota.FpOrigVfs, zFilename, (gQuota.FsThisVfs.FmxPathname + 1), zFull) } - if rc == 0 { + if rc == SQLITE_OK { *(*int8)(unsafe.Pointer(zFull + uintptr((libc.Xstrlen(tls, zFull) + uint64(1))))) = int8(0) rc = quotaOpen(tls, (uintptr(unsafe.Pointer(&gQuota)) + 8 /* &.sThisVfs */), zFull, fd, - (0x00000001 | 0x00000100), bp /* &outFlags */) - if rc == 0 { + (SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_DB), bp /* &outFlags */) + if rc == SQLITE_OK { (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(fd)).FpMethods + 48 /* &.xFileSize */))))(tls, fd, bp+8 /* &iSize */) (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(fd)).FpMethods + 8 /* &.xClose */))))(tls, fd) - } else if rc == 14 { + } else if rc == SQLITE_CANTOPEN { var pGroup uintptr var pFile uintptr quotaEnter(tls) @@ -75704,7 +71241,7 @@ func sqlite3_quota_file_available(tls *libc.TLS, p uintptr) int64 { /* test_quot if pos1 < int64(0) { return int64(-1) } - rc = libc.Xfseek(tls, f, int64(0), 2) + rc = libc.Xfseek(tls, f, int64(0), SEEK_END) if rc != 0 { return int64(-1) } @@ -75712,7 +71249,7 @@ func sqlite3_quota_file_available(tls *libc.TLS, p uintptr) int64 { /* test_quot if pos2 < int64(0) { return int64(-1) } - rc = libc.Xfseek(tls, f, pos1, 0) + rc = libc.Xfseek(tls, f, pos1, SEEK_SET) if rc != 0 { return int64(-1) } @@ -75732,7 +71269,7 @@ func sqlite3_quota_remove(tls *libc.TLS, zFilename uintptr) int32 { /* test_quot zFull = sqlite3.Xsqlite3_malloc(tls, (gQuota.FsThisVfs.FmxPathname + 1)) if zFull == uintptr(0) { - return 7 + return SQLITE_NOMEM } rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((gQuota.FpOrigVfs + 64 /* &.xFullPathname */))))(tls, gQuota.FpOrigVfs, zFilename, (gQuota.FsThisVfs.FmxPathname + 1), zFull) @@ -75752,7 +71289,7 @@ func sqlite3_quota_remove(tls *libc.TLS, zFilename uintptr) int32 { /* test_quot quotaEnter(tls) pGroup = quotaGroupFind(tls, zFull) if pGroup != 0 { - for pFile = (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles; (pFile != 0) && (rc == 0); pFile = pNextFile { + for pFile = (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles; (pFile != 0) && (rc == SQLITE_OK); pFile = pNextFile { pNextFile = (*quotaFile)(unsafe.Pointer(pFile)).FpNext diff = libc.Xstrncmp(tls, zFull, (*quotaFile)(unsafe.Pointer(pFile)).FzFilename, nFull) if (diff == 0) && ((((int32(libc.AssignInt8(&c, *(*int8)(unsafe.Pointer((*quotaFile)(unsafe.Pointer(pFile)).FzFilename + uintptr(nFull)))))) == 0) || (int32(c) == '/')) || (int32(c) == '\\')) { @@ -75824,9 +71361,9 @@ func tclQuotaCallback(tls *libc.TLS, zFilename uintptr, piLimit uintptr, iSize s tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pEval, tcl.XTcl_NewStringObj(tls, zFilename, -1)) tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pEval, pVarname) tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pEval, tcl.XTcl_NewWideIntObj(tls, iSize)) - rc = tcl.XTcl_EvalObjEx(tls, (*TclQuotaCallback)(unsafe.Pointer(p)).Finterp, pEval, 0x020000) + rc = tcl.XTcl_EvalObjEx(tls, (*TclQuotaCallback)(unsafe.Pointer(p)).Finterp, pEval, TCL_EVAL_GLOBAL) - if rc == 0 { + if rc == TCL_OK { // var x Tcl_WideInt at bp+8, 8 var pLimit uintptr = tcl.XTcl_ObjGetVar2(tls, (*TclQuotaCallback)(unsafe.Pointer(p)).Finterp, pVarname, uintptr(0), 0) @@ -75847,7 +71384,7 @@ func tclQuotaCallback(tls *libc.TLS, zFilename uintptr, piLimit uintptr, iSize s tcl.XTclFreeObj(tls, _objPtr) } } - if rc != 0 { + if rc != TCL_OK { tcl.XTcl_BackgroundError(tls, (*TclQuotaCallback)(unsafe.Pointer(p)).Finterp) } } @@ -75879,13 +71416,13 @@ func test_quota_initialize(tls *libc.TLS, clientData uintptr, interp uintptr, ob // Process arguments if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+33587 /* "NAME MAKEDEFAULT" */) - return 1 + return TCL_ERROR } - zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp /* &makeDefault */) != 0 { - return 1 + zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &makeDefault */) != 0 { + return TCL_ERROR } - if int32(*(*int8)(unsafe.Pointer(zName + uintptr(0)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(zName))) == 0 { zName = uintptr(0) } @@ -75893,7 +71430,7 @@ func test_quota_initialize(tls *libc.TLS, clientData uintptr, interp uintptr, ob rc = sqlite3_quota_initialize(tls, zName, *(*int32)(unsafe.Pointer(bp /* makeDefault */))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_shutdown @@ -75902,14 +71439,14 @@ func test_quota_shutdown(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } // Call sqlite3_quota_shutdown() rc = sqlite3_quota_shutdown(tls) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_set PATTERN LIMIT SCRIPT @@ -75931,13 +71468,13 @@ func test_quota_set(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 // Process arguments if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+34716 /* "PATTERN LIMIT SC..." */) - return 1 + return TCL_ERROR } - zPattern = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp /* &iLimit */) != 0 { - return 1 + zPattern = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &iLimit */) != 0 { + return TCL_ERROR } - pScript = *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)) + pScript = *(*uintptr)(unsafe.Pointer(objv + 3*8)) tcl.XTcl_GetStringFromObj(tls, pScript, bp+8 /* &nScript */) if *(*int32)(unsafe.Pointer(bp + 8 /* nScript */)) > 0 { @@ -75945,7 +71482,7 @@ func test_quota_set(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 p = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(TclQuotaCallback{}))) if !(p != 0) { tcl.XTcl_SetResult(tls, interp, ts+31585 /* "SQLITE_NOMEM" */, uintptr(0)) - return 0 + return TCL_OK } libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(TclQuotaCallback{}))) (*TclQuotaCallback)(unsafe.Pointer(p)).Finterp = interp @@ -75965,7 +71502,7 @@ func test_quota_set(tls *libc.TLS, clientData uintptr, interp uintptr, objc int3 rc = sqlite3_quota_set(tls, zPattern, *(*Tcl_WideInt)(unsafe.Pointer(bp /* iLimit */)), xCallback, p, xDestroy) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_file FILENAME @@ -75976,15 +71513,15 @@ func test_quota_file(tls *libc.TLS, clientData uintptr, interp uintptr, objc int // Process arguments if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31769 /* "FILENAME" */) - return 1 + return TCL_ERROR } - zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) // Invoke sqlite3_quota_file() rc = sqlite3_quota_file(tls, zFilename) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_dump @@ -76033,7 +71570,7 @@ func test_quota_dump(tls *libc.TLS, clientData uintptr, interp uintptr, objc int } quotaLeave(tls) tcl.XTcl_SetObjResult(tls, interp, pResult) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_fopen FILENAME MODE @@ -76050,14 +71587,14 @@ func test_quota_fopen(tls *libc.TLS, clientData uintptr, interp uintptr, objc in // Process arguments if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+34737 /* "FILENAME MODE" */) - return 1 + return TCL_ERROR } - zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - zMode = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + zMode = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) p = sqlite3_quota_fopen(tls, zFilename, zMode) sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+8 /* &zReturn[0] */, ts+12843 /* "%p" */, libc.VaList(bp, p)) tcl.XTcl_SetResult(tls, interp, bp+8 /* &zReturn[0] */, uintptr(1)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_fread HANDLE SIZE NELEM @@ -76075,25 +71612,25 @@ func test_quota_fread(tls *libc.TLS, clientData uintptr, interp uintptr, objc in if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+34751 /* "HANDLE SIZE NELE..." */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp /* &sz */) != 0 { - return 1 + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &sz */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+4 /* &nElem */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+4 /* &nElem */) != 0 { + return TCL_ERROR } zBuf = sqlite3.Xsqlite3_malloc(tls, ((*(*int32)(unsafe.Pointer(bp /* sz */)) * *(*int32)(unsafe.Pointer(bp + 4 /* nElem */))) + 1)) if zBuf == uintptr(0) { tcl.XTcl_SetResult(tls, interp, ts+1929 /* "out of memory" */, uintptr(0)) - return 1 + return TCL_ERROR } got = sqlite3_quota_fread(tls, zBuf, uint64(*(*int32)(unsafe.Pointer(bp /* sz */))), uint64(*(*int32)(unsafe.Pointer(bp + 4 /* nElem */))), p) *(*int8)(unsafe.Pointer(zBuf + uintptr((got * size_t(*(*int32)(unsafe.Pointer(bp /* sz */))))))) = int8(0) tcl.XTcl_SetResult(tls, interp, zBuf, uintptr(1)) sqlite3.Xsqlite3_free(tls, zBuf) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_fwrite HANDLE SIZE NELEM CONTENT @@ -76111,19 +71648,19 @@ func test_quota_fwrite(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 5 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+34769 /* "HANDLE SIZE NELE..." */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp /* &sz */) != 0 { - return 1 + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &sz */) != 0 { + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+4 /* &nElem */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+4 /* &nElem */) != 0 { + return TCL_ERROR } - zBuf = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8))) + zBuf = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) got = sqlite3_quota_fwrite(tls, zBuf, uint64(*(*int32)(unsafe.Pointer(bp /* sz */))), uint64(*(*int32)(unsafe.Pointer(bp + 4 /* nElem */))), p) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, int64(got))) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_fclose HANDLE @@ -76133,12 +71670,12 @@ func test_quota_fclose(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27522 /* "HANDLE" */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) rc = sqlite3_quota_fclose(tls, p) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_fflush HANDLE ?HARDSYNC? @@ -76152,17 +71689,17 @@ func test_quota_fflush(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if (objc != 2) && (objc != 3) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+34795 /* "HANDLE ?HARDSYNC..." */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) if objc == 3 { - if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp /* &doSync */) != 0 { - return 1 + if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &doSync */) != 0 { + return TCL_ERROR } } rc = sqlite3_quota_fflush(tls, p, *(*int32)(unsafe.Pointer(bp /* doSync */))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_fseek HANDLE OFFSET WHENCE @@ -76179,27 +71716,27 @@ func test_quota_fseek(tls *libc.TLS, clientData uintptr, interp uintptr, objc in if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+34813 /* "HANDLE OFFSET WH..." */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+16 /* &ofst */) != 0 { - return 1 + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+16 /* &ofst */) != 0 { + return TCL_ERROR } - zWhence = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + zWhence = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) if libc.Xstrcmp(tls, zWhence, ts+34834 /* "SEEK_SET" */) == 0 { - whence = 0 + whence = SEEK_SET } else if libc.Xstrcmp(tls, zWhence, ts+34843 /* "SEEK_CUR" */) == 0 { - whence = 1 + whence = SEEK_CUR } else if libc.Xstrcmp(tls, zWhence, ts+34852 /* "SEEK_END" */) == 0 { - whence = 2 + whence = SEEK_END } else { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+34861 /* "WHENCE should be..." */, uintptr(0))) - return 1 + return TCL_ERROR } rc = sqlite3_quota_fseek(tls, p, int64(*(*int32)(unsafe.Pointer(bp + 16 /* ofst */))), whence) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_rewind HANDLE @@ -76207,11 +71744,11 @@ func test_quota_rewind(tls *libc.TLS, clientData uintptr, interp uintptr, objc i var p uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27522 /* "HANDLE" */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) sqlite3_quota_rewind(tls, p) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_ftell HANDLE @@ -76220,12 +71757,12 @@ func test_quota_ftell(tls *libc.TLS, clientData uintptr, interp uintptr, objc in var x sqlite3_int64 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27522 /* "HANDLE" */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) x = sqlite3_int64(sqlite3_quota_ftell(tls, p)) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, x)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_ftruncate HANDLE SIZE @@ -76240,16 +71777,16 @@ func test_quota_ftruncate(tls *libc.TLS, clientData uintptr, interp uintptr, obj var rc int32 if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+34910 /* "HANDLE SIZE" */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) - if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp /* &w */) != 0 { - return 1 + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) + if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &w */) != 0 { + return TCL_ERROR } x = *(*Tcl_WideInt)(unsafe.Pointer(bp /* w */)) rc = sqlite3_quota_ftruncate(tls, p, x) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_file_size HANDLE @@ -76258,12 +71795,12 @@ func test_quota_file_size(tls *libc.TLS, clientData uintptr, interp uintptr, obj var x sqlite3_int64 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27522 /* "HANDLE" */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) x = sqlite3_quota_file_size(tls, p) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, x)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_file_truesize HANDLE @@ -76272,12 +71809,12 @@ func test_quota_file_truesize(tls *libc.TLS, clientData uintptr, interp uintptr, var x sqlite3_int64 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27522 /* "HANDLE" */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) x = sqlite3_quota_file_truesize(tls, p) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, x)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_file_mtime HANDLE @@ -76290,13 +71827,13 @@ func test_quota_file_mtime(tls *libc.TLS, clientData uintptr, interp uintptr, ob if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27522 /* "HANDLE" */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) *(*time_t)(unsafe.Pointer(bp /* t */)) = int64(0) sqlite3_quota_file_mtime(tls, p, bp /* &t */) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, int64(*(*time_t)(unsafe.Pointer(bp /* t */))))) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_remove FILENAME @@ -76305,12 +71842,12 @@ func test_quota_remove(tls *libc.TLS, clientData uintptr, interp uintptr, objc i var rc int32 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31769 /* "FILENAME" */) - return 1 + return TCL_ERROR } - zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) rc = sqlite3_quota_remove(tls, zFilename) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_glob PATTERN TEXT @@ -76323,13 +71860,13 @@ func test_quota_glob(tls *libc.TLS, clientData uintptr, interp uintptr, objc int var rc int32 if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+34922 /* "PATTERN TEXT" */) - return 1 + return TCL_ERROR } - zPattern = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - zText = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zPattern = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + zText = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) rc = quotaStrglob(tls, zPattern, zText) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_file_available HANDLE @@ -76341,12 +71878,12 @@ func test_quota_file_available(tls *libc.TLS, clientData uintptr, interp uintptr var x sqlite3_int64 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27522 /* "HANDLE" */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) x = sqlite3_int64(sqlite3_quota_file_available(tls, p)) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, x)) - return 0 + return TCL_OK } // tclcmd: sqlite3_quota_ferror HANDLE @@ -76357,12 +71894,12 @@ func test_quota_ferror(tls *libc.TLS, clientData uintptr, interp uintptr, objc i var x int32 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27522 /* "HANDLE" */) - return 1 + return TCL_ERROR } - p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) x = sqlite3_quota_ferror(tls, p) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, x)) - return 0 + return TCL_OK } // This routine registers the custom TCL commands defined in this @@ -76378,76 +71915,34 @@ func Sqlitequota_Init(tls *libc.TLS, interp uintptr) int32 { /* test_quota.c:194 tcl.XTcl_CreateObjCommand(tls, interp, aCmd9[i].FzName, aCmd9[i].FxProc, uintptr(0), uintptr(0)) } - return 0 + return TCL_OK } var aCmd9 = [21]struct { FzName uintptr FxProc uintptr }{ - { - FzName: ts + 34935, /* "sqlite3_quota_in..." */ - FxProc: 0}, - { - FzName: ts + 34960, /* "sqlite3_quota_sh..." */ - FxProc: 0}, - { - FzName: ts + 34983, /* "sqlite3_quota_se..." */ - FxProc: 0}, - { - FzName: ts + 35001, /* "sqlite3_quota_fi..." */ - FxProc: 0}, - { - FzName: ts + 35020, /* "sqlite3_quota_du..." */ - FxProc: 0}, - { - FzName: ts + 35039, /* "sqlite3_quota_fo..." */ - FxProc: 0}, - { - FzName: ts + 35059, /* "sqlite3_quota_fr..." */ - FxProc: 0}, - { - FzName: ts + 35079, /* "sqlite3_quota_fw..." */ - FxProc: 0}, - { - FzName: ts + 35100, /* "sqlite3_quota_fc..." */ - FxProc: 0}, - { - FzName: ts + 35121, /* "sqlite3_quota_ff..." */ - FxProc: 0}, - { - FzName: ts + 35142, /* "sqlite3_quota_fs..." */ - FxProc: 0}, - { - FzName: ts + 35162, /* "sqlite3_quota_re..." */ - FxProc: 0}, - { - FzName: ts + 35183, /* "sqlite3_quota_ft..." */ - FxProc: 0}, - { - FzName: ts + 35203, /* "sqlite3_quota_ft..." */ - FxProc: 0}, - { - FzName: ts + 35227, /* "sqlite3_quota_fi..." */ - FxProc: 0}, - { - FzName: ts + 35251, /* "sqlite3_quota_fi..." */ - FxProc: 0}, - { - FzName: ts + 35279, /* "sqlite3_quota_fi..." */ - FxProc: 0}, - { - FzName: ts + 35304, /* "sqlite3_quota_re..." */ - FxProc: 0}, - { - FzName: ts + 35325, /* "sqlite3_quota_gl..." */ - FxProc: 0}, - { - FzName: ts + 35344, /* "sqlite3_quota_fi..." */ - FxProc: 0}, - { - FzName: ts + 35373, /* "sqlite3_quota_fe..." */ - FxProc: 0}, + {FzName: ts + 34935 /* "sqlite3_quota_in..." */, FxProc: 0}, + {FzName: ts + 34960 /* "sqlite3_quota_sh..." */, FxProc: 0}, + {FzName: ts + 34983 /* "sqlite3_quota_se..." */, FxProc: 0}, + {FzName: ts + 35001 /* "sqlite3_quota_fi..." */, FxProc: 0}, + {FzName: ts + 35020 /* "sqlite3_quota_du..." */, FxProc: 0}, + {FzName: ts + 35039 /* "sqlite3_quota_fo..." */, FxProc: 0}, + {FzName: ts + 35059 /* "sqlite3_quota_fr..." */, FxProc: 0}, + {FzName: ts + 35079 /* "sqlite3_quota_fw..." */, FxProc: 0}, + {FzName: ts + 35100 /* "sqlite3_quota_fc..." */, FxProc: 0}, + {FzName: ts + 35121 /* "sqlite3_quota_ff..." */, FxProc: 0}, + {FzName: ts + 35142 /* "sqlite3_quota_fs..." */, FxProc: 0}, + {FzName: ts + 35162 /* "sqlite3_quota_re..." */, FxProc: 0}, + {FzName: ts + 35183 /* "sqlite3_quota_ft..." */, FxProc: 0}, + {FzName: ts + 35203 /* "sqlite3_quota_ft..." */, FxProc: 0}, + {FzName: ts + 35227 /* "sqlite3_quota_fi..." */, FxProc: 0}, + {FzName: ts + 35251 /* "sqlite3_quota_fi..." */, FxProc: 0}, + {FzName: ts + 35279 /* "sqlite3_quota_fi..." */, FxProc: 0}, + {FzName: ts + 35304 /* "sqlite3_quota_re..." */, FxProc: 0}, + {FzName: ts + 35325 /* "sqlite3_quota_gl..." */, FxProc: 0}, + {FzName: ts + 35344 /* "sqlite3_quota_fi..." */, FxProc: 0}, + {FzName: ts + 35373 /* "sqlite3_quota_fe..." */, FxProc: 0}, } /* test_quota.c:1948:5 */ // Type used to cache parameter information for the "circle" r-tree geometry @@ -76491,10 +71986,10 @@ func circle_geom(tls *libc.TLS, p uintptr, nCoord int32, aCoord uintptr, pRes ui var ymin float64 var ymax float64 // X dimensions of box being tested - xmin = *(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + uintptr(0)*8)) - xmax = *(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + uintptr(1)*8)) - ymin = *(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + uintptr(2)*8)) - ymax = *(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + uintptr(3)*8)) + xmin = *(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord)) + xmax = *(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 1*8)) + ymin = *(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 2*8)) + ymax = *(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 3*8)) pCircle = (*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FpUser if pCircle == uintptr(0) { // If pUser is still 0, then the parameter values have not been tested @@ -76503,21 +71998,21 @@ func circle_geom(tls *libc.TLS, p uintptr, nCoord int32, aCoord uintptr, pRes ui // This geometry callback is for use with a 2-dimensional r-tree table. // Return an error if the table does not have exactly 2 dimensions. if nCoord != 4 { - return 1 + return SQLITE_ERROR } // Test that the correct number of parameters (3) have been supplied, // and that the parameters are in range (that the radius of the circle // radius is greater than zero). - if ((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FnParam != 3) || (*(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(2)*8)) < 0.0) { - return 1 + 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) { + return SQLITE_ERROR } // Allocate a structure to cache parameter data in. Return SQLITE_NOMEM // if the allocation fails. pCircle = libc.AssignPtrUintptr(p+24 /* &.pUser */, sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Circle{})))) if !(pCircle != 0) { - return 7 + return SQLITE_NOMEM } (*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FxDelUser = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{circle_del})) @@ -76525,9 +72020,9 @@ func circle_geom(tls *libc.TLS, p uintptr, nCoord int32, aCoord uintptr, pRes ui // tested bounding boxes that intersect the circular region are detected // is by testing if each corner of the bounding box lies within radius // units of the center of the circle. - (*Circle)(unsafe.Pointer(pCircle)).Fcenterx = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(0)*8)) - (*Circle)(unsafe.Pointer(pCircle)).Fcentery = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(1)*8)) - (*Circle)(unsafe.Pointer(pCircle)).Fradius = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(2)*8)) + (*Circle)(unsafe.Pointer(pCircle)).Fcenterx = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam)) + (*Circle)(unsafe.Pointer(pCircle)).Fcentery = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 1*8)) + (*Circle)(unsafe.Pointer(pCircle)).Fradius = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 2*8)) // Define two bounding box regions. The first, aBox[0], extends to // infinity in the X dimension. It covers the same range of the Y dimension @@ -76539,14 +72034,14 @@ func circle_geom(tls *libc.TLS, p uintptr, nCoord int32, aCoord uintptr, pRes ui // that intersects the center of the circular region. A bounding box // being tested can be said to intersect the circular region if it contains // points from each half of either of the two infinite bounding boxes. - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(0)*32)).Fxmin = (*Circle)(unsafe.Pointer(pCircle)).Fcenterx - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(0)*32)).Fxmax = (*Circle)(unsafe.Pointer(pCircle)).Fcenterx - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(0)*32)).Fymin = ((*Circle)(unsafe.Pointer(pCircle)).Fcentery + (*Circle)(unsafe.Pointer(pCircle)).Fradius) - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(0)*32)).Fymax = ((*Circle)(unsafe.Pointer(pCircle)).Fcentery - (*Circle)(unsafe.Pointer(pCircle)).Fradius) - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(1)*32)).Fxmin = ((*Circle)(unsafe.Pointer(pCircle)).Fcenterx + (*Circle)(unsafe.Pointer(pCircle)).Fradius) - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(1)*32)).Fxmax = ((*Circle)(unsafe.Pointer(pCircle)).Fcenterx - (*Circle)(unsafe.Pointer(pCircle)).Fradius) - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(1)*32)).Fymin = (*Circle)(unsafe.Pointer(pCircle)).Fcentery - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(1)*32)).Fymax = (*Circle)(unsafe.Pointer(pCircle)).Fcentery + (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fxmin = (*Circle)(unsafe.Pointer(pCircle)).Fcenterx + (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fxmax = (*Circle)(unsafe.Pointer(pCircle)).Fcenterx + (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fymin = ((*Circle)(unsafe.Pointer(pCircle)).Fcentery + (*Circle)(unsafe.Pointer(pCircle)).Fradius) + (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fymax = ((*Circle)(unsafe.Pointer(pCircle)).Fcentery - (*Circle)(unsafe.Pointer(pCircle)).Fradius) + (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fxmin = ((*Circle)(unsafe.Pointer(pCircle)).Fcenterx + (*Circle)(unsafe.Pointer(pCircle)).Fradius) + (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fxmax = ((*Circle)(unsafe.Pointer(pCircle)).Fcenterx - (*Circle)(unsafe.Pointer(pCircle)).Fradius) + (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fymin = (*Circle)(unsafe.Pointer(pCircle)).Fcentery + (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fymax = (*Circle)(unsafe.Pointer(pCircle)).Fcentery (*Circle)(unsafe.Pointer(pCircle)).FmxArea = (((xmax - xmin) * (ymax - ymin)) + 1.0) } @@ -76573,7 +72068,7 @@ func circle_geom(tls *libc.TLS, p uintptr, nCoord int32, aCoord uintptr, pRes ui d2 = d2 + ((y - (*Circle)(unsafe.Pointer(pCircle)).Fcentery) * (y - (*Circle)(unsafe.Pointer(pCircle)).Fcentery)) if d2 < ((*Circle)(unsafe.Pointer(pCircle)).Fradius * (*Circle)(unsafe.Pointer(pCircle)).Fradius) { *(*int32)(unsafe.Pointer(pRes)) = 1 - return 0 + return SQLITE_OK } } @@ -76587,14 +72082,14 @@ func circle_geom(tls *libc.TLS, p uintptr, nCoord int32, aCoord uintptr, pRes ui (ymin <= (*Box)(unsafe.Pointer((pCircle /* &.aBox */)+uintptr(i)*32)).Fymin)) && (ymax >= (*Box)(unsafe.Pointer((pCircle /* &.aBox */)+uintptr(i)*32)).Fymax) { *(*int32)(unsafe.Pointer(pRes)) = 1 - return 0 + return SQLITE_OK } } // The specified bounding box does not intersect the circular region. Set // the output variable to zero and return SQLITE_OK. *(*int32)(unsafe.Pointer(pRes)) = 0 - return 0 + return SQLITE_OK } // Implementation of "circle" r-tree geometry callback using the @@ -76613,10 +72108,10 @@ func circle_query_func(tls *libc.TLS, p uintptr) int32 { /* test_rtree.c:168:12: var ymax float64 // X dimensions of box being tested var nWithin int32 = 0 // Number of corners inside the circle - xmin = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + uintptr(0)*8)) - xmax = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + uintptr(1)*8)) - ymin = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + uintptr(2)*8)) - ymax = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + uintptr(3)*8)) + xmin = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord)) + xmax = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + 1*8)) + ymin = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + 2*8)) + ymax = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + 3*8)) pCircle = (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FpUser if pCircle == uintptr(0) { // If pUser is still 0, then the parameter values have not been tested @@ -76625,19 +72120,19 @@ func circle_query_func(tls *libc.TLS, p uintptr) int32 { /* test_rtree.c:168:12: // This geometry callback is for use with a 2-dimensional r-tree table. // Return an error if the table does not have exactly 2 dimensions. if (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FnCoord != 4 { - return 1 + return SQLITE_ERROR } // Test that the correct number of parameters (1 or 4) have been supplied. if ((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FnParam != 4) && ((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FnParam != 1) { - return 1 + return SQLITE_ERROR } // Allocate a structure to cache parameter data in. Return SQLITE_NOMEM // if the allocation fails. pCircle = libc.AssignPtrUintptr(p+24 /* &.pUser */, sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Circle{})))) if !(pCircle != 0) { - return 7 + return SQLITE_NOMEM } (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FxDelUser = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{circle_del})) @@ -76646,40 +72141,40 @@ func circle_query_func(tls *libc.TLS, p uintptr) int32 { /* test_rtree.c:168:12: // is by testing if each corner of the bounding box lies within radius // units of the center of the circle. if (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FnParam == 4 { - (*Circle)(unsafe.Pointer(pCircle)).Fcenterx = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + uintptr(0)*8)) - (*Circle)(unsafe.Pointer(pCircle)).Fcentery = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + uintptr(1)*8)) - (*Circle)(unsafe.Pointer(pCircle)).Fradius = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + uintptr(2)*8)) - (*Circle)(unsafe.Pointer(pCircle)).FeScoreType = int32(*(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + uintptr(3)*8))) + (*Circle)(unsafe.Pointer(pCircle)).Fcenterx = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam)) + (*Circle)(unsafe.Pointer(pCircle)).Fcentery = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + 1*8)) + (*Circle)(unsafe.Pointer(pCircle)).Fradius = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + 2*8)) + (*Circle)(unsafe.Pointer(pCircle)).FeScoreType = int32(*(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + 3*8))) } else { - var z uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FapSqlParam + uintptr(0)*8))) + var z uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FapSqlParam))) (*Circle)(unsafe.Pointer(pCircle)).Fcenterx = 0.0 (*Circle)(unsafe.Pointer(pCircle)).Fcentery = 0.0 (*Circle)(unsafe.Pointer(pCircle)).Fradius = 0.0 (*Circle)(unsafe.Pointer(pCircle)).FeScoreType = 0 - for (z != 0) && (*(*int8)(unsafe.Pointer(z + uintptr(0))) != 0) { - if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == 'r') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == ':') { - (*Circle)(unsafe.Pointer(pCircle)).Fradius = libc.Xatof(tls, (z + uintptr(2))) - } else if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == 'x') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == ':') { - (*Circle)(unsafe.Pointer(pCircle)).Fcenterx = libc.Xatof(tls, (z + uintptr(2))) - } else if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == 'y') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == ':') { - (*Circle)(unsafe.Pointer(pCircle)).Fcentery = libc.Xatof(tls, (z + uintptr(2))) - } else if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == 'e') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == ':') { - (*Circle)(unsafe.Pointer(pCircle)).FeScoreType = int32(libc.Xatof(tls, (z + uintptr(2)))) - } else if int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == ' ' { + for (z != 0) && (*(*int8)(unsafe.Pointer(z)) != 0) { + if (int32(*(*int8)(unsafe.Pointer(z))) == 'r') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == ':') { + (*Circle)(unsafe.Pointer(pCircle)).Fradius = libc.Xatof(tls, (z + 2)) + } else if (int32(*(*int8)(unsafe.Pointer(z))) == 'x') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == ':') { + (*Circle)(unsafe.Pointer(pCircle)).Fcenterx = libc.Xatof(tls, (z + 2)) + } else if (int32(*(*int8)(unsafe.Pointer(z))) == 'y') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == ':') { + (*Circle)(unsafe.Pointer(pCircle)).Fcentery = libc.Xatof(tls, (z + 2)) + } else if (int32(*(*int8)(unsafe.Pointer(z))) == 'e') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == ':') { + (*Circle)(unsafe.Pointer(pCircle)).FeScoreType = int32(libc.Xatof(tls, (z + 2))) + } else if int32(*(*int8)(unsafe.Pointer(z))) == ' ' { z++ continue } - for (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) != 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) != ' ') { + for (int32(*(*int8)(unsafe.Pointer(z))) != 0) && (int32(*(*int8)(unsafe.Pointer(z))) != ' ') { z++ } - for int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == ' ' { + for int32(*(*int8)(unsafe.Pointer(z))) == ' ' { z++ } } } if (*Circle)(unsafe.Pointer(pCircle)).Fradius < 0.0 { sqlite3.Xsqlite3_free(tls, pCircle) - return 7 + return SQLITE_NOMEM } // Define two bounding box regions. The first, aBox[0], extends to @@ -76692,14 +72187,14 @@ func circle_query_func(tls *libc.TLS, p uintptr) int32 { /* test_rtree.c:168:12: // that intersects the center of the circular region. A bounding box // being tested can be said to intersect the circular region if it contains // points from each half of either of the two infinite bounding boxes. - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(0)*32)).Fxmin = (*Circle)(unsafe.Pointer(pCircle)).Fcenterx - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(0)*32)).Fxmax = (*Circle)(unsafe.Pointer(pCircle)).Fcenterx - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(0)*32)).Fymin = ((*Circle)(unsafe.Pointer(pCircle)).Fcentery + (*Circle)(unsafe.Pointer(pCircle)).Fradius) - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(0)*32)).Fymax = ((*Circle)(unsafe.Pointer(pCircle)).Fcentery - (*Circle)(unsafe.Pointer(pCircle)).Fradius) - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(1)*32)).Fxmin = ((*Circle)(unsafe.Pointer(pCircle)).Fcenterx + (*Circle)(unsafe.Pointer(pCircle)).Fradius) - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(1)*32)).Fxmax = ((*Circle)(unsafe.Pointer(pCircle)).Fcenterx - (*Circle)(unsafe.Pointer(pCircle)).Fradius) - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(1)*32)).Fymin = (*Circle)(unsafe.Pointer(pCircle)).Fcentery - (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + uintptr(1)*32)).Fymax = (*Circle)(unsafe.Pointer(pCircle)).Fcentery + (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fxmin = (*Circle)(unsafe.Pointer(pCircle)).Fcenterx + (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fxmax = (*Circle)(unsafe.Pointer(pCircle)).Fcenterx + (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fymin = ((*Circle)(unsafe.Pointer(pCircle)).Fcentery + (*Circle)(unsafe.Pointer(pCircle)).Fradius) + (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fymax = ((*Circle)(unsafe.Pointer(pCircle)).Fcentery - (*Circle)(unsafe.Pointer(pCircle)).Fradius) + (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fxmin = ((*Circle)(unsafe.Pointer(pCircle)).Fcenterx + (*Circle)(unsafe.Pointer(pCircle)).Fradius) + (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fxmax = ((*Circle)(unsafe.Pointer(pCircle)).Fcenterx - (*Circle)(unsafe.Pointer(pCircle)).Fradius) + (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fymin = (*Circle)(unsafe.Pointer(pCircle)).Fcentery + (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fymax = (*Circle)(unsafe.Pointer(pCircle)).Fcentery (*Circle)(unsafe.Pointer(pCircle)).FmxArea = (float64(200.0) * 200.0) } @@ -76776,13 +72271,13 @@ func circle_query_func(tls *libc.TLS, p uintptr) int32 { /* test_rtree.c:168:12: } } if nWithin == 0 { - (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = 0 + (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = NOT_WITHIN } else if nWithin >= 4 { - (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = 2 + (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = FULLY_WITHIN } else { - (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = 1 + (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = PARTLY_WITHIN } - return 0 + return SQLITE_OK } // Implementation of "breadthfirstsearch" r-tree geometry callback using the @@ -76802,27 +72297,27 @@ func bfs_query_func(tls *libc.TLS, p uintptr) int32 { /* test_rtree.c:329:12: */ var by1 float64 // Boundary of the query function if (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FnParam != 4 { - return 1 + return SQLITE_ERROR } - x0 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + uintptr(0)*8)) - x1 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + uintptr(1)*8)) - y0 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + uintptr(2)*8)) - y1 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + uintptr(3)*8)) - bx0 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + uintptr(0)*8)) - bx1 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + uintptr(1)*8)) - by0 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + uintptr(2)*8)) - by1 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + uintptr(3)*8)) + x0 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord)) + x1 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + 1*8)) + y0 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + 2*8)) + y1 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + 3*8)) + bx0 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam)) + bx1 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + 1*8)) + by0 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + 2*8)) + by1 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + 3*8)) (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FrScore = (sqlite3_rtree_dbl(100 - (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FiLevel)) - if (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeParentWithin == 2 { - (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = 2 + if (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeParentWithin == FULLY_WITHIN { + (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = FULLY_WITHIN } else if (((x0 >= bx0) && (x1 <= bx1)) && (y0 >= by0)) && (y1 <= by1) { - (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = 2 + (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = FULLY_WITHIN } else if (((x1 >= bx0) && (x0 <= bx1)) && (y1 >= by0)) && (y0 <= by1) { - (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = 1 + (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = PARTLY_WITHIN } else { - (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = 0 + (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = NOT_WITHIN } - return 0 + return SQLITE_OK } // END of implementation of "circle" geometry callback. @@ -76999,35 +72494,35 @@ func cube_geom(tls *libc.TLS, p uintptr, nCoord int32, aCoord uintptr, piRes uin if pCube == uintptr(0) { if (((((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FnParam != 6) || (nCoord != 6)) || - (*(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(3)*8)) <= 0.0)) || (*(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(4)*8)) <= 0.0)) || (*(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(5)*8)) <= 0.0) { - return 1 + (*(*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) { + return SQLITE_ERROR } pCube = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Cube{}))) if !(pCube != 0) { - return 7 + return SQLITE_NOMEM } - (*Cube)(unsafe.Pointer(pCube)).Fx = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(0)*8)) - (*Cube)(unsafe.Pointer(pCube)).Fy = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(1)*8)) - (*Cube)(unsafe.Pointer(pCube)).Fz = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(2)*8)) - (*Cube)(unsafe.Pointer(pCube)).Fwidth = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(3)*8)) - (*Cube)(unsafe.Pointer(pCube)).Fheight = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(4)*8)) - (*Cube)(unsafe.Pointer(pCube)).Fdepth = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + uintptr(5)*8)) + (*Cube)(unsafe.Pointer(pCube)).Fx = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam)) + (*Cube)(unsafe.Pointer(pCube)).Fy = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 1*8)) + (*Cube)(unsafe.Pointer(pCube)).Fz = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 2*8)) + (*Cube)(unsafe.Pointer(pCube)).Fwidth = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 3*8)) + (*Cube)(unsafe.Pointer(pCube)).Fheight = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 4*8)) + (*Cube)(unsafe.Pointer(pCube)).Fdepth = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 5*8)) (*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FpUser = pCube (*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FxDelUser = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{cube_context_free})) } *(*int32)(unsafe.Pointer(piRes)) = 0 - if (((((*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + uintptr(0)*8)) <= ((*Cube)(unsafe.Pointer(pCube)).Fx + (*Cube)(unsafe.Pointer(pCube)).Fwidth)) && - (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + uintptr(1)*8)) >= (*Cube)(unsafe.Pointer(pCube)).Fx)) && - (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + uintptr(2)*8)) <= ((*Cube)(unsafe.Pointer(pCube)).Fy + (*Cube)(unsafe.Pointer(pCube)).Fheight))) && - (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + uintptr(3)*8)) >= (*Cube)(unsafe.Pointer(pCube)).Fy)) && - (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + uintptr(4)*8)) <= ((*Cube)(unsafe.Pointer(pCube)).Fz + (*Cube)(unsafe.Pointer(pCube)).Fdepth))) && - (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + uintptr(5)*8)) >= (*Cube)(unsafe.Pointer(pCube)).Fz) { + if (((((*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord)) <= ((*Cube)(unsafe.Pointer(pCube)).Fx + (*Cube)(unsafe.Pointer(pCube)).Fwidth)) && + (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 1*8)) >= (*Cube)(unsafe.Pointer(pCube)).Fx)) && + (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 2*8)) <= ((*Cube)(unsafe.Pointer(pCube)).Fy + (*Cube)(unsafe.Pointer(pCube)).Fheight))) && + (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 3*8)) >= (*Cube)(unsafe.Pointer(pCube)).Fy)) && + (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 4*8)) <= ((*Cube)(unsafe.Pointer(pCube)).Fz + (*Cube)(unsafe.Pointer(pCube)).Fdepth))) && + (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 5*8)) >= (*Cube)(unsafe.Pointer(pCube)).Fz) { *(*int32)(unsafe.Pointer(piRes)) = 1 } - return 0 + return SQLITE_OK } func register_cube_geom(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_rtree.c:443:26: */ @@ -77040,16 +72535,16 @@ func register_cube_geom(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_rtree_geometry_callback(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+35394 /* "cube" */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 }{cube_geom})), uintptr(unsafe.Pointer(&gHere))) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } func register_circle_geom(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_rtree.c:471:26: */ @@ -77062,28 +72557,28 @@ func register_circle_geom(tls *libc.TLS, clientData uintptr, interp uintptr, obj if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } rc = sqlite3.Xsqlite3_rtree_geometry_callback(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+35399 /* "circle" */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 }{circle_geom})), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_rtree_query_callback(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+35406, /* "Qcircle" */ *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr) int32 }{circle_query_func})), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3.Xsqlite3_rtree_query_callback(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+35414, /* "breadthfirstsear..." */ *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr) int32 }{bfs_query_func})), uintptr(0), uintptr(0)) } tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } func Sqlitetestrtree_Init(tls *libc.TLS, interp uintptr) int32 { /* test_rtree.c:507:5: */ @@ -77093,7 +72588,7 @@ func Sqlitetestrtree_Init(tls *libc.TLS, interp uintptr) int32 { /* test_rtree.c tcl.XTcl_CreateObjCommand(tls, interp, ts+35452 /* "register_circle_..." */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 }{register_circle_geom})), uintptr(0), uintptr(0)) - return 0 + return TCL_OK } // Some versions of define this macros. @@ -77315,7 +72810,7 @@ func schemaDestroy(tls *libc.TLS, pVtab uintptr) int32 { /* test_schema.c:79:12: // Table constructor for the schema module. func schemaCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test_schema.c:87:12: */ - var rc int32 = 7 + var rc int32 = SQLITE_NOMEM var pVtab uintptr = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(schema_vtab{}))) if pVtab != 0 { libc.Xmemset(tls, pVtab, 0, uint64(unsafe.Sizeof(schema_vtab{}))) @@ -77328,13 +72823,13 @@ func schemaCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uint // Open a new cursor on the schema table. func schemaOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_schema.c:110:12: */ - var rc int32 = 7 + var rc int32 = SQLITE_NOMEM var pCur uintptr pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(schema_cursor{}))) if pCur != 0 { libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(schema_cursor{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = pCur - rc = 0 + rc = SQLITE_OK } return rc } @@ -77346,7 +72841,7 @@ func schemaClose(tls *libc.TLS, cur uintptr) int32 { /* test_schema.c:125:12: */ sqlite3.Xsqlite3_finalize(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpTableList) sqlite3.Xsqlite3_finalize(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpColumnList) sqlite3.Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } // Retrieve a column of data. @@ -77363,14 +72858,14 @@ func schemaColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* t sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpColumnList, (i-2))) break } - return 0 + return SQLITE_OK } // Retrieve the current rowid. func schemaRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test_schema.c:156:12: */ var pCur uintptr = cur *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite_int64((*schema_cursor)(unsafe.Pointer(pCur)).Frowid) - return 0 + return SQLITE_OK } func finalize(tls *libc.TLS, ppStmt uintptr) int32 { /* test_schema.c:162:12: */ @@ -77399,16 +72894,16 @@ func schemaNext(tls *libc.TLS, cur uintptr) int32 { /* test_schema.c:176:12: */ var pVtab uintptr var zSql uintptr var pDbList uintptr - rc = 0 + rc = SQLITE_OK pCur = cur pVtab = (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab zSql = uintptr(0) __1: - if !(!(int32((*schema_cursor)(unsafe.Pointer(pCur)).FpColumnList) != 0) || (100 != sqlite3.Xsqlite3_step(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpColumnList))) { + if !(!(int32((*schema_cursor)(unsafe.Pointer(pCur)).FpColumnList) != 0) || (SQLITE_ROW != sqlite3.Xsqlite3_step(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpColumnList))) { goto __2 } - if !(0 != (libc.AssignInt32(&rc, finalize(tls, (pCur+24 /* &.pColumnList */))))) { + if !(SQLITE_OK != (libc.AssignInt32(&rc, finalize(tls, (pCur+24 /* &.pColumnList */))))) { goto __3 } goto next_exit @@ -77416,10 +72911,10 @@ __3: ; __4: - if !(!(int32((*schema_cursor)(unsafe.Pointer(pCur)).FpTableList) != 0) || (100 != sqlite3.Xsqlite3_step(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpTableList))) { + if !(!(int32((*schema_cursor)(unsafe.Pointer(pCur)).FpTableList) != 0) || (SQLITE_ROW != sqlite3.Xsqlite3_step(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpTableList))) { goto __5 } - if !(0 != (libc.AssignInt32(&rc, finalize(tls, (pCur+16 /* &.pTableList */))))) { + if !(SQLITE_OK != (libc.AssignInt32(&rc, finalize(tls, (pCur+16 /* &.pTableList */))))) { goto __6 } goto next_exit @@ -77427,7 +72922,7 @@ __6: ; __7: - if !(100 != sqlite3.Xsqlite3_step(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpDbList)) { + if !(SQLITE_ROW != sqlite3.Xsqlite3_step(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpDbList)) { goto __8 } rc = finalize(tls, (pCur + 8 /* &.pDbList */)) @@ -77456,14 +72951,14 @@ __10: if !(!(zSql != 0)) { goto __11 } - rc = 7 + rc = SQLITE_NOMEM goto next_exit __11: ; rc = sqlite3.Xsqlite3_prepare(tls, (*schema_vtab)(unsafe.Pointer(pVtab)).Fdb, zSql, -1, (pCur + 16 /* &.pTableList */), uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } goto next_exit @@ -77483,13 +72978,13 @@ __5: if !(!(zSql != 0)) { goto __13 } - rc = 7 + rc = SQLITE_NOMEM goto next_exit __13: ; rc = sqlite3.Xsqlite3_prepare(tls, (*schema_vtab)(unsafe.Pointer(pVtab)).Fdb, zSql, -1, (pCur + 24 /* &.pColumnList */), uintptr(0)) sqlite3.Xsqlite3_free(tls, zSql) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __14 } goto next_exit @@ -77516,7 +73011,7 @@ func schemaFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp finalize(tls, (pCur + 8 /* &.pDbList */)) rc = sqlite3.Xsqlite3_prepare(tls, (*schema_vtab)(unsafe.Pointer(pVtab)).Fdb, ts+35678 /* "PRAGMA database_..." */, -1, (pCur + 8 /* &.pDbList */), uintptr(0)) return func() int32 { - if rc == 0 { + if rc == SQLITE_OK { return schemaNext(tls, pVtabCursor) } return rc @@ -77525,46 +73020,24 @@ func schemaFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp // Analyse the WHERE condition. func schemaBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_schema.c:266:12: */ - return 0 + return SQLITE_OK } // A virtual table module that merely echos method calls into TCL // variables. -var schemaModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, +var schemaModule = sqlite3_module{ // iVersion + FxCreate: 0, FxConnect: 0, FxBestIndex: 0, FxDisconnect: 0, FxDestroy: 0, - FxOpen: 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRename } /* test_schema.c:274:23 */ // Register the schema virtual table module. @@ -77576,13 +73049,13 @@ func register_schema_module(tls *libc.TLS, clientData ClientData, interp uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+4499 /* "schema" */, uintptr(unsafe.Pointer(&schemaModule)), uintptr(0)) - return 0 + return TCL_OK } // Register commands with the TCL interpreter. @@ -77596,7 +73069,7 @@ func Sqlitetestschema_Init(tls *libc.TLS, interp uintptr) int32 { /* test_schema tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd12[i].FzName, aObjCmd12[i].FxProc, aObjCmd12[i].FclientData, uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd12 = [1]struct { @@ -77604,10 +73077,7 @@ var aObjCmd12 = [1]struct { FxProc uintptr FclientData uintptr }{ - { - FzName: ts + 35699, /* "register_schema_..." */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 35699 /* "register_schema_..." */, FxProc: 0}, } /* test_schema.c:335:5 */ // 2001-09-15 @@ -77813,7 +73283,7 @@ func sendToServer(tls *libc.TLS, pMsg uintptr) { /* test_server.c:272:13: */ // block waiting for the server to process the message. libc2.Xpthread_mutex_lock(tls, (pMsg + 72 /* &.clientMutex */)) libc2.Xpthread_cond_signal(tls, (uintptr(unsafe.Pointer(&g4)) + 80 /* &.serverWakeup */)) - for (*SqlMessage)(unsafe.Pointer(pMsg)).Fop != 7 { + for (*SqlMessage)(unsafe.Pointer(pMsg)).Fop != MSG_Done { libc2.Xpthread_cond_wait(tls, (pMsg + 112 /* &.clientWakeup */), (pMsg + 72 /* &.clientMutex */)) } libc2.Xpthread_mutex_unlock(tls, (pMsg + 72 /* &.clientMutex */)) @@ -77852,7 +73322,7 @@ func sqlite3_client_open(tls *libc.TLS, zDatabaseName uintptr, ppDb uintptr) int // var msg SqlMessage at bp, 160 - (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = 1 + (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = MSG_Open (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FzIn = zDatabaseName sendToServer(tls, bp /* &msg */) *(*uintptr)(unsafe.Pointer(ppDb)) = (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpDb @@ -77865,7 +73335,7 @@ func sqlite3_client_prepare(tls *libc.TLS, pDb uintptr, zSql uintptr, nByte int3 // var msg SqlMessage at bp, 160 - (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = 2 + (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = MSG_Prepare (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpDb = pDb (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FzIn = zSql (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FnByte = nByte @@ -77883,7 +73353,7 @@ func sqlite3_client_step(tls *libc.TLS, pStmt uintptr) int32 { /* test_server.c: // var msg SqlMessage at bp, 160 - (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = 3 + (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = MSG_Step (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpStmt = pStmt sendToServer(tls, bp /* &msg */) return (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FerrCode @@ -77895,7 +73365,7 @@ func sqlite3_client_reset(tls *libc.TLS, pStmt uintptr) int32 { /* test_server.c // var msg SqlMessage at bp, 160 - (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = 4 + (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = MSG_Reset (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpStmt = pStmt sendToServer(tls, bp /* &msg */) return (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FerrCode @@ -77907,7 +73377,7 @@ func sqlite3_client_finalize(tls *libc.TLS, pStmt uintptr) int32 { /* test_serve // var msg SqlMessage at bp, 160 - (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = 5 + (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = MSG_Finalize (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpStmt = pStmt sendToServer(tls, bp /* &msg */) return (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FerrCode @@ -77919,7 +73389,7 @@ func sqlite3_client_close(tls *libc.TLS, pDb uintptr) int32 { /* test_server.c:3 // var msg SqlMessage at bp, 160 - (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = 6 + (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = MSG_Close (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpDb = pDb sendToServer(tls, bp /* &msg */) return (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FerrCode @@ -77960,38 +73430,38 @@ func sqlite3_server(tls *libc.TLS, NotUsed uintptr) uintptr { /* test_server.c:3 // Process the message just removed libc2.Xpthread_mutex_lock(tls, (pMsg + 72 /* &.clientMutex */)) switch (*SqlMessage)(unsafe.Pointer(pMsg)).Fop { - case 1: + case MSG_Open: { (*SqlMessage)(unsafe.Pointer(pMsg)).FerrCode = sqlite3.Xsqlite3_open(tls, (*SqlMessage)(unsafe.Pointer(pMsg)).FzIn, (pMsg + 8 /* &.pDb */)) break } - case 2: + case MSG_Prepare: { (*SqlMessage)(unsafe.Pointer(pMsg)).FerrCode = sqlite3.Xsqlite3_prepare(tls, (*SqlMessage)(unsafe.Pointer(pMsg)).FpDb, (*SqlMessage)(unsafe.Pointer(pMsg)).FzIn, (*SqlMessage)(unsafe.Pointer(pMsg)).FnByte, (pMsg + 16 /* &.pStmt */), (pMsg + 48 /* &.zOut */)) break } - case 3: + case MSG_Step: { (*SqlMessage)(unsafe.Pointer(pMsg)).FerrCode = sqlite3.Xsqlite3_step(tls, (*SqlMessage)(unsafe.Pointer(pMsg)).FpStmt) break } - case 4: + case MSG_Reset: { (*SqlMessage)(unsafe.Pointer(pMsg)).FerrCode = sqlite3.Xsqlite3_reset(tls, (*SqlMessage)(unsafe.Pointer(pMsg)).FpStmt) break } - case 5: + case MSG_Finalize: { (*SqlMessage)(unsafe.Pointer(pMsg)).FerrCode = sqlite3.Xsqlite3_finalize(tls, (*SqlMessage)(unsafe.Pointer(pMsg)).FpStmt) break } - case 6: + case MSG_Close: { (*SqlMessage)(unsafe.Pointer(pMsg)).FerrCode = sqlite3.Xsqlite3_close(tls, (*SqlMessage)(unsafe.Pointer(pMsg)).FpDb) break @@ -78000,7 +73470,7 @@ func sqlite3_server(tls *libc.TLS, NotUsed uintptr) uintptr { /* test_server.c:3 } // Signal the client that the message has been processed. - (*SqlMessage)(unsafe.Pointer(pMsg)).Fop = 7 + (*SqlMessage)(unsafe.Pointer(pMsg)).Fop = MSG_Done libc2.Xpthread_mutex_unlock(tls, (pMsg + 72 /* &.clientMutex */)) libc2.Xpthread_cond_signal(tls, (pMsg + 112 /* &.clientWakeup */)) } @@ -78163,12 +73633,12 @@ func superlockIsWal(tls *libc.TLS, pLock uintptr) int32 { /* test_superlock.c:67 // Compiled PRAGMA journal_mode statement rc = sqlite3.Xsqlite3_prepare(tls, (*Superlock)(unsafe.Pointer(pLock)).Fdb, ts+35722 /* "PRAGMA main.jour..." */, -1, bp /* &pStmt */, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { return rc } (*Superlock)(unsafe.Pointer(pLock)).FbWal = 0 - if 100 == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { + if SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { var zMode uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 0) if ((zMode != 0) && (libc.Xstrlen(tls, zMode) == uint64(3))) && (sqlite3.Xsqlite3_strnicmp(tls, ts+28782 /* "wal" */, zMode, 3) == 0) { (*Superlock)(unsafe.Pointer(pLock)).FbWal = 1 @@ -78185,8 +73655,8 @@ func superlockIsWal(tls *libc.TLS, pLock uintptr) int32 { /* test_superlock.c:67 func superlockShmLock(tls *libc.TLS, fd uintptr, idx int32, nByte int32, pBusy uintptr) int32 { /* test_superlock.c:91:12: */ var rc int32 var xShmLock uintptr = (*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(fd)).FpMethods)).FxShmLock - for ok := true; ok; ok = ((rc == 5) && (superlockBusyHandler(tls, pBusy, 0) != 0)) { - rc = (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&xShmLock)))(tls, fd, idx, nByte, (2 | 8)) + for ok := true; ok; ok = ((rc == SQLITE_BUSY) && (superlockBusyHandler(tls, pBusy, 0) != 0)) { + rc = (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&xShmLock)))(tls, fd, idx, nByte, (SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)) } return rc } @@ -78202,15 +73672,15 @@ func superlockWalLock(tls *libc.TLS, db uintptr, pBusy uintptr) int32 { /* test_ *(*uintptr)(unsafe.Pointer(bp + 8 /* p */)) = uintptr(0) // Pointer to first page of shared memory // Obtain a pointer to the sqlite3_file object open on the main db file. - rc = sqlite3.Xsqlite3_file_control(tls, db, ts+84 /* "main" */, 7, bp /* &fd */) - if rc != 0 { + rc = sqlite3.Xsqlite3_file_control(tls, db, ts+84 /* "main" */, SQLITE_FCNTL_FILE_POINTER, bp /* &fd */) + if rc != SQLITE_OK { return rc } // Obtain the "recovery" lock. Normally, this lock is only obtained by // clients running database recovery. rc = superlockShmLock(tls, *(*uintptr)(unsafe.Pointer(bp /* fd */)), 2, 1, pBusy) - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -78221,7 +73691,7 @@ func superlockWalLock(tls *libc.TLS, db uintptr, pBusy uintptr) int32 { /* test_ // transactions may now be opened. Nor can a checkpoint be run, for the // same reason. 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 */) - if rc != 0 { + if rc != SQLITE_OK { return rc } libc.Xmemset(tls, libc.AtomicLoadPUintptr(bp+8 /* p */), 0, uint64(32)) @@ -78229,7 +73699,7 @@ func superlockWalLock(tls *libc.TLS, db uintptr, pBusy uintptr) int32 { /* test_ // Obtain exclusive locks on all the "read-lock" slots. Once these locks // are held, it is guaranteed that there are no active reader, writer or // checkpointer clients. - rc = superlockShmLock(tls, *(*uintptr)(unsafe.Pointer(bp /* fd */)), 3, (8 - 3), pBusy) + rc = superlockShmLock(tls, *(*uintptr)(unsafe.Pointer(bp /* fd */)), 3, (SQLITE_SHM_NLOCK - 3), pBusy) return rc } @@ -78243,12 +73713,12 @@ func sqlite3demo_superunlock(tls *libc.TLS, pLock uintptr) { /* test_superlock.c var p uintptr = pLock if (*Superlock)(unsafe.Pointer(p)).FbWal != 0 { var rc int32 // Return code - var flags int32 = (1 | 8) + var flags int32 = (SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) *(*uintptr)(unsafe.Pointer(bp /* fd */)) = uintptr(0) - rc = sqlite3.Xsqlite3_file_control(tls, (*Superlock)(unsafe.Pointer(p)).Fdb, ts+84 /* "main" */, 7, bp /* &fd */) - if rc == 0 { + rc = sqlite3.Xsqlite3_file_control(tls, (*Superlock)(unsafe.Pointer(p)).Fdb, ts+84 /* "main" */, SQLITE_FCNTL_FILE_POINTER, bp /* &fd */) + if rc == SQLITE_OK { (*(*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) - (*(*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, (8 - 3), flags) + (*(*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) } } sqlite3.Xsqlite3_close(tls, (*Superlock)(unsafe.Pointer(p)).Fdb) @@ -78278,13 +73748,13 @@ func sqlite3demo_superlock(tls *libc.TLS, zPath uintptr, zVfs uintptr, xBusy uin pLock = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Superlock{}))) if !(pLock != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pLock, 0, uint64(unsafe.Sizeof(Superlock{}))) // Open a database handle on the file to superlock. rc = sqlite3.Xsqlite3_open_v2(tls, - zPath, (pLock /* &.db */), (0x00000002 | 0x00000004), zVfs) + zPath, (pLock /* &.db */), (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE), zVfs) // Install a busy-handler and execute a BEGIN EXCLUSIVE. If this is not // a WAL database, this is all we need to do. @@ -78298,7 +73768,7 @@ func sqlite3demo_superlock(tls *libc.TLS, zPath uintptr, zVfs uintptr, xBusy uin // represents the total number of busy-handler invocations made within // this call to sqlite3demo_superlock(), including any made during the // "BEGIN EXCLUSIVE". - if rc == 0 { + if rc == SQLITE_OK { (*SuperlockBusy)(unsafe.Pointer(bp /* &busy */)).FxBusy = xBusy (*SuperlockBusy)(unsafe.Pointer(bp /* &busy */)).FpBusyArg = pBusyArg sqlite3.Xsqlite3_busy_handler(tls, (*Superlock)(unsafe.Pointer(pLock)).Fdb, *(*uintptr)(unsafe.Pointer(&struct { @@ -78315,16 +73785,16 @@ func sqlite3demo_superlock(tls *libc.TLS, zPath uintptr, zVfs uintptr, xBusy uin // Before attempting any WAL locks, commit the transaction started above // to drop the WAL read and write locks currently held. Otherwise, the // new WAL locks may conflict with the old. - if rc == 0 { - if (0 == (libc.AssignInt32(&rc, superlockIsWal(tls, pLock)))) && ((*Superlock)(unsafe.Pointer(pLock)).FbWal != 0) { + if rc == SQLITE_OK { + if (SQLITE_OK == (libc.AssignInt32(&rc, superlockIsWal(tls, pLock)))) && ((*Superlock)(unsafe.Pointer(pLock)).FbWal != 0) { rc = sqlite3.Xsqlite3_exec(tls, (*Superlock)(unsafe.Pointer(pLock)).Fdb, ts+11132 /* "COMMIT" */, uintptr(0), uintptr(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = superlockWalLock(tls, (*Superlock)(unsafe.Pointer(pLock)).Fdb, bp /* &busy */) } } } - if rc != 0 { + if rc != SQLITE_OK { sqlite3demo_superunlock(tls, pLock) *(*uintptr)(unsafe.Pointer(ppLock)) = uintptr(0) } else { @@ -78356,10 +73826,10 @@ func superunlock_del(tls *libc.TLS, cd ClientData) { /* test_superlock.c:274:27: func superunlock_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_superlock.c:278:26: */ if objc != 1 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } - tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)))) - return 0 + tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv)))) + return TCL_OK } func superlock_busy(tls *libc.TLS, pCtx uintptr, nBusy int32) int32 { /* test_superlock.c:292:12: */ @@ -78373,7 +73843,7 @@ func superlock_busy(tls *libc.TLS, pCtx uintptr, nBusy int32) int32 { /* test_su pEval = tcl.XTcl_DuplicateObj(tls, (*InterpAndScript)(unsafe.Pointer(p)).FpScript) (*Tcl_Obj)(unsafe.Pointer(pEval)).FrefCount++ tcl.XTcl_ListObjAppendElement(tls, (*InterpAndScript)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_NewIntObj(tls, nBusy)) - tcl.XTcl_EvalObjEx(tls, (*InterpAndScript)(unsafe.Pointer(p)).Finterp, pEval, 0x020000) + tcl.XTcl_EvalObjEx(tls, (*InterpAndScript)(unsafe.Pointer(p)).Finterp, pEval, TCL_EVAL_GLOBAL) tcl.XTcl_GetIntFromObj(tls, (*InterpAndScript)(unsafe.Pointer(p)).Finterp, tcl.XTcl_GetObjResult(tls, (*InterpAndScript)(unsafe.Pointer(p)).Finterp), bp /* &iVal */) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = pEval @@ -78401,20 +73871,20 @@ func superlock_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, obj if (objc < 3) || (objc > 5) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+35747 /* "CMDNAME PATH ?VF..." */) - return 1 + return TCL_ERROR } - zPath = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zPath = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) if objc > 3 { - zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) + zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) if libc.Xstrlen(tls, zVfs) == uint64(0) { zVfs = uintptr(0) } } if objc > 4 { (*InterpAndScript)(unsafe.Pointer(bp + 16 /* &busy */)).Finterp = interp - (*InterpAndScript)(unsafe.Pointer(bp + 16 /* &busy */)).FpScript = *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)) + (*InterpAndScript)(unsafe.Pointer(bp + 16 /* &busy */)).FpScript = *(*uintptr)(unsafe.Pointer(objv + 4*8)) xBusy = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32) int32 }{superlock_busy})) @@ -78422,25 +73892,25 @@ func superlock_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, obj rc = sqlite3demo_superlock(tls, zPath, zVfs, xBusy, bp+16 /* &busy */, bp+32 /* &pLock */) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_ResetResult(tls, interp) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3ErrStr(tls, rc), 0)) - return 1 + return TCL_ERROR } tcl.XTcl_CreateObjCommand(tls, - interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), *(*uintptr)(unsafe.Pointer(&struct { + interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 }{superunlock_cmd})), *(*uintptr)(unsafe.Pointer(bp + 32 /* pLock */)), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, ClientData) }{superunlock_del}))) - tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) - return 0 + tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) + return TCL_OK } func SqliteSuperlock_Init(tls *libc.TLS, interp uintptr) int32 { /* test_superlock.c:359:5: */ tcl.XTcl_CreateObjCommand(tls, interp, ts+35788 /* "sqlite3demo_supe..." */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 }{superlock_cmd})), uintptr(0), uintptr(0)) - return 0 + return TCL_OK } // Define error_t. @@ -78482,114 +73952,24 @@ type TestSyscallArray = struct { } /* test_syscall.c:127:1 */ var aSyscall = [19]TestSyscallArray{ - /* 0 */ { - FzName: ts + 35810, /* "open" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 13, - Fcustom_errno: 0}, - /* 1 */ { - FzName: ts + 9947, /* "close" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 2 */ { - FzName: ts + 35815, /* "access" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 3 */ { - FzName: ts + 35822, /* "getcwd" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 4 */ { - FzName: ts + 35829, /* "stat" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 5 */ { - FzName: ts + 35834, /* "fstat" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 6 */ { - FzName: ts + 35840, /* "ftruncate" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 5, - Fcustom_errno: 0}, - /* 7 */ { - FzName: ts + 35850, /* "fcntl" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 13, - Fcustom_errno: 0}, - /* 8 */ { - FzName: ts + 24104, /* "read" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 9 */ { - FzName: ts + 35856, /* "pread" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 10 */ { - FzName: ts + 35862, /* "pread64" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 11 */ { - FzName: ts + 24109, /* "write" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 12 */ { - FzName: ts + 35870, /* "pwrite" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 13 */ { - FzName: ts + 35877, /* "pwrite64" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 14 */ { - FzName: ts + 35886, /* "fchmod" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 15 */ { - FzName: ts + 35893, /* "fallocate" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 16 */ { - FzName: ts + 27885, /* "mmap" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, - /* 17 */ { - FzName: ts + 35903, /* "mremap" */ - FxTest: 0, - FxOrig: uintptr(0), - Fdefault_errno: 0, - Fcustom_errno: 0}, + /* 0 */ {FzName: ts + 35810 /* "open" */, FxTest: 0, Fdefault_errno: EACCES}, + /* 1 */ {FzName: ts + 9947 /* "close" */, FxTest: 0}, + /* 2 */ {FzName: ts + 35815 /* "access" */, FxTest: 0}, + /* 3 */ {FzName: ts + 35822 /* "getcwd" */, FxTest: 0}, + /* 4 */ {FzName: ts + 35829 /* "stat" */, FxTest: 0}, + /* 5 */ {FzName: ts + 35834 /* "fstat" */, FxTest: 0}, + /* 6 */ {FzName: ts + 35840 /* "ftruncate" */, FxTest: 0, Fdefault_errno: EIO}, + /* 7 */ {FzName: ts + 35850 /* "fcntl" */, FxTest: 0, Fdefault_errno: EACCES}, + /* 8 */ {FzName: ts + 24104 /* "read" */, FxTest: 0}, + /* 9 */ {FzName: ts + 35856 /* "pread" */, FxTest: 0}, + /* 10 */ {FzName: ts + 35862 /* "pread64" */, FxTest: 0}, + /* 11 */ {FzName: ts + 24109 /* "write" */, FxTest: 0}, + /* 12 */ {FzName: ts + 35870 /* "pwrite" */, FxTest: 0}, + /* 13 */ {FzName: ts + 35877 /* "pwrite64" */, FxTest: 0}, + /* 14 */ {FzName: ts + 35886 /* "fchmod" */, FxTest: 0}, + /* 15 */ {FzName: ts + 35893 /* "fallocate" */, FxTest: 0}, + /* 16 */ {FzName: ts + 27885 /* "mmap" */, FxTest: 0}, + /* 17 */ {FzName: ts + 35903 /* "mremap" */, FxTest: 0}, {}, } /* test_syscall.c:133:3 */ @@ -78644,7 +74024,7 @@ func ts_open(tls *libc.TLS, zFile uintptr, flags int32, mode int32) int32 { /* t if tsIsFailErrno(tls, ts+35810 /* "open" */) != 0 { return -1 } - return (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(0)*32 + 16 /* &.xOrig */))))(tls, zFile, flags, mode) + return (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 16 /* &.xOrig */))))(tls, zFile, flags, mode) } // A wrapper around close(). @@ -78655,10 +74035,10 @@ func ts_close(tls *libc.TLS, fd int32) int32 { /* test_syscall.c:236:12: */ // when running a long test. If a call to close() appears to fail, SQLite // never attempts to use the file-descriptor afterwards (or even to close // it a second time). - (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(1)*32 + 16 /* &.xOrig */))))(tls, fd) + (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 1*32 + 16 /* &.xOrig */))))(tls, fd) return -1 } - return (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(1)*32 + 16 /* &.xOrig */))))(tls, fd) + return (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 1*32 + 16 /* &.xOrig */))))(tls, fd) } // A wrapper around access(). @@ -78666,7 +74046,7 @@ func ts_access(tls *libc.TLS, zPath uintptr, mode int32) int32 { /* test_syscall if tsIsFail(tls) != 0 { return -1 } - return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(2)*32 + 16 /* &.xOrig */))))(tls, zPath, mode) + return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 2*32 + 16 /* &.xOrig */))))(tls, zPath, mode) } // A wrapper around getcwd(). @@ -78674,7 +74054,7 @@ func ts_getcwd(tls *libc.TLS, zPath uintptr, nPath size_t) uintptr { /* test_sys if tsIsFail(tls) != 0 { return uintptr(0) } - return (*(*func(*libc.TLS, uintptr, size_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(3)*32 + 16 /* &.xOrig */))))(tls, zPath, nPath) + return (*(*func(*libc.TLS, uintptr, size_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 3*32 + 16 /* &.xOrig */))))(tls, zPath, nPath) } // A wrapper around stat(). @@ -78682,7 +74062,7 @@ func ts_stat(tls *libc.TLS, zPath uintptr, p uintptr) int32 { /* test_syscall.c: if tsIsFail(tls) != 0 { return -1 } - return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(4)*32 + 16 /* &.xOrig */))))(tls, zPath, p) + return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 4*32 + 16 /* &.xOrig */))))(tls, zPath, p) } // A wrapper around fstat(). @@ -78690,7 +74070,7 @@ func ts_fstat(tls *libc.TLS, fd int32, p uintptr) int32 { /* test_syscall.c:282: if tsIsFailErrno(tls, ts+35834 /* "fstat" */) != 0 { return -1 } - return (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*32 + 16 /* &.xOrig */))))(tls, fd, p) + return (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*32 + 16 /* &.xOrig */))))(tls, fd, p) } // A wrapper around ftruncate(). @@ -78698,7 +74078,7 @@ func ts_ftruncate(tls *libc.TLS, fd int32, n off_t) int32 { /* test_syscall.c:29 if tsIsFailErrno(tls, ts+35840 /* "ftruncate" */) != 0 { return -1 } - return (*(*func(*libc.TLS, int32, off_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(6)*32 + 16 /* &.xOrig */))))(tls, fd, n) + return (*(*func(*libc.TLS, int32, off_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 6*32 + 16 /* &.xOrig */))))(tls, fd, n) } // A wrapper around fcntl(). @@ -78714,7 +74094,7 @@ func ts_fcntl(tls *libc.TLS, fd int32, cmd int32, va uintptr) int32 { /* test_sy } ap = va pArg = libc.VaUintptr(&ap) - return (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(7)*32 + 16 /* &.xOrig */))))(tls, fd, cmd, libc.VaList(bp, pArg)) + 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)) } // A wrapper around read(). @@ -78722,7 +74102,7 @@ func ts_read(tls *libc.TLS, fd int32, aBuf uintptr, nBuf size_t) int32 { /* test if tsIsFailErrno(tls, ts+24104 /* "read" */) != 0 { return -1 } - return int32((*(*func(*libc.TLS, int32, uintptr, size_t) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(8)*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, nBuf)) + 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)) } // A wrapper around pread(). @@ -78730,7 +74110,7 @@ func ts_pread(tls *libc.TLS, fd int32, aBuf uintptr, nBuf size_t, off off_t) int if tsIsFailErrno(tls, ts+35856 /* "pread" */) != 0 { return -1 } - return int32((*(*func(*libc.TLS, int32, uintptr, size_t, off_t) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(9)*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, nBuf, off)) + 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)) } // A wrapper around pread64(). @@ -78738,18 +74118,18 @@ func ts_pread64(tls *libc.TLS, fd int32, aBuf uintptr, nBuf size_t, off sqlite3_ if tsIsFailErrno(tls, ts+35862 /* "pread64" */) != 0 { return -1 } - return int32((*(*func(*libc.TLS, int32, uintptr, size_t, sqlite3_uint64) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(10)*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, nBuf, off)) + 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)) } // A wrapper around write(). func ts_write(tls *libc.TLS, fd int32, aBuf uintptr, nBuf size_t) int32 { /* test_syscall.c:346:12: */ if tsIsFailErrno(tls, ts+24109 /* "write" */) != 0 { - if tsErrno(tls, ts+24109 /* "write" */) == 4 { - (*(*func(*libc.TLS, int32, uintptr, size_t) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(11)*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, (nBuf / uint64(2))) + if tsErrno(tls, ts+24109 /* "write" */) == EINTR { + (*(*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))) } return -1 } - return int32((*(*func(*libc.TLS, int32, uintptr, size_t) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(11)*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, nBuf)) + 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)) } // A wrapper around pwrite(). @@ -78757,7 +74137,7 @@ func ts_pwrite(tls *libc.TLS, fd int32, aBuf uintptr, nBuf size_t, off off_t) in if tsIsFailErrno(tls, ts+35870 /* "pwrite" */) != 0 { return -1 } - return int32((*(*func(*libc.TLS, int32, uintptr, size_t, off_t) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(12)*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, nBuf, off)) + 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)) } // A wrapper around pwrite64(). @@ -78765,7 +74145,7 @@ func ts_pwrite64(tls *libc.TLS, fd int32, aBuf uintptr, nBuf size_t, off sqlite3 if tsIsFailErrno(tls, ts+35877 /* "pwrite64" */) != 0 { return -1 } - return int32((*(*func(*libc.TLS, int32, uintptr, size_t, sqlite3_uint64) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(13)*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, nBuf, off)) + 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)) } // A wrapper around fchmod(). @@ -78773,7 +74153,7 @@ func ts_fchmod(tls *libc.TLS, fd int32, mode mode_t) int32 { /* test_syscall.c:3 if tsIsFail(tls) != 0 { return -1 } - return (*(*func(*libc.TLS, int32, mode_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(14)*32 + 16 /* &.xOrig */))))(tls, fd, mode) + return (*(*func(*libc.TLS, int32, mode_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 14*32 + 16 /* &.xOrig */))))(tls, fd, mode) } // A wrapper around fallocate(). @@ -78787,14 +74167,14 @@ func ts_fallocate(tls *libc.TLS, fd int32, off off_t, len off_t) int32 { /* test if tsIsFail(tls) != 0 { return tsErrno(tls, ts+35893 /* "fallocate" */) } - return (*(*func(*libc.TLS, int32, off_t, off_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(15)*32 + 16 /* &.xOrig */))))(tls, fd, off, len) + return (*(*func(*libc.TLS, int32, off_t, off_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 15*32 + 16 /* &.xOrig */))))(tls, fd, off, len) } 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: */ if tsIsFailErrno(tls, ts+27885 /* "mmap" */) != 0 { return libc.UintptrFromInt32(-1) } - return (*(*func(*libc.TLS, uintptr, size_t, int32, int32, int32, off_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(16)*32 + 16 /* &.xOrig */))))(tls, pAddr, nByte, prot, flags, fd, iOff) + 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) } func ts_mremap(tls *libc.TLS, a uintptr, b size_t, c size_t, d int32, va uintptr) uintptr { /* test_syscall.c:414:13: */ @@ -78809,7 +74189,7 @@ func ts_mremap(tls *libc.TLS, a uintptr, b size_t, c size_t, d int32, va uintptr } ap = va pArg = libc.VaUintptr(&ap) - return (*(*func(*libc.TLS, uintptr, size_t, size_t, int32, uintptr) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(17)*32 + 16 /* &.xOrig */))))(tls, a, b, c, d, libc.VaList(bp, pArg)) + 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)) } func test_syscall_install(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:425:26: */ @@ -78824,10 +74204,10 @@ func test_syscall_install(tls *libc.TLS, clientData uintptr, interp uintptr, obj if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+35910 /* "SYSCALL-LIST" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp /* &nElem */, bp+8 /* &apElem */) != 0 { - return 1 + if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &nElem */, bp+8 /* &apElem */) != 0 { + return TCL_ERROR } pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) @@ -78846,7 +74226,7 @@ func test_syscall_install(tls *libc.TLS, clientData uintptr, interp uintptr, obj aSyscall[*(*int32)(unsafe.Pointer(bp + 16 /* iCall */))].Fcustom_errno = aSyscall[*(*int32)(unsafe.Pointer(bp + 16 /* iCall */))].Fdefault_errno } - return 0 + return TCL_OK } func test_syscall_uninstall(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:461:26: */ @@ -78855,7 +74235,7 @@ func test_syscall_uninstall(tls *libc.TLS, clientData uintptr, interp uintptr, o if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) @@ -78865,7 +74245,7 @@ func test_syscall_uninstall(tls *libc.TLS, clientData uintptr, interp uintptr, o aSyscall[i].FxOrig = uintptr(0) } } - return 0 + return TCL_OK } func test_syscall_reset(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:485:26: */ @@ -78878,7 +74258,7 @@ func test_syscall_reset(tls *libc.TLS, clientData uintptr, interp uintptr, objc if (objc != 2) && (objc != 3) { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) @@ -78890,9 +74270,9 @@ func test_syscall_reset(tls *libc.TLS, clientData uintptr, interp uintptr, objc } else { // var nFunc int32 at bp, 4 - var zFunc uintptr = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp /* &nFunc */) - 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 + uintptr(2)*8))), uintptr(0)) - for i = 0; (rc == 0) && (aSyscall[i].FzName != 0); i++ { + var zFunc uintptr = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &nFunc */) + 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)) + for i = 0; (rc == SQLITE_OK) && (aSyscall[i].FzName != 0); i++ { if libc.Xstrlen(tls, aSyscall[i].FzName) != size_t(*(*int32)(unsafe.Pointer(bp /* nFunc */))) { continue } @@ -78902,13 +74282,13 @@ func test_syscall_reset(tls *libc.TLS, clientData uintptr, interp uintptr, objc aSyscall[i].FxOrig = uintptr(0) } } - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 1 + return TCL_ERROR } tcl.XTcl_ResetResult(tls, interp) - return 0 + return TCL_OK } func test_syscall_exists(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:523:26: */ @@ -78917,14 +74297,14 @@ func test_syscall_exists(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) - x = (*(*func(*libc.TLS, uintptr, uintptr) sqlite3_syscall_ptr)(unsafe.Pointer((pVfs + 152 /* &.xGetSystemCall */))))(tls, pVfs, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)))) + 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)))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((libc.Bool32(x != uintptr(0))) != 0)))) - return 0 + return TCL_OK } func test_syscall_fault(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:544:26: */ @@ -78936,13 +74316,13 @@ func test_syscall_fault(tls *libc.TLS, clientData uintptr, interp uintptr, objc if (objc != 2) && (objc != 4) { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+35935 /* "?COUNT PERSIST?" */) - return 1 + return TCL_ERROR } if objc == 4 { - if (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp /* &nCount */) != 0) || - (tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+4 /* &bPersist */) != 0) { - return 1 + if (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &nCount */) != 0) || + (tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+4 /* &bPersist */) != 0) { + return TCL_ERROR } } @@ -78950,7 +74330,7 @@ func test_syscall_fault(tls *libc.TLS, clientData uintptr, interp uintptr, objc gSyscall.FnCount = *(*int32)(unsafe.Pointer(bp /* nCount */)) gSyscall.FbPersist = *(*int32)(unsafe.Pointer(bp + 4 /* bPersist */)) gSyscall.FnFail = 0 - return 0 + return TCL_OK } func test_syscall_errno(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:573:26: */ @@ -78964,60 +74344,38 @@ func test_syscall_errno(tls *libc.TLS, clientData uintptr, interp uintptr, objc var rc int32 *(*[12]Errno)(unsafe.Pointer(bp + 8 /* aErrno */)) = [12]Errno{ - { - Fz: ts + 35951, /* "EACCES" */ - Fi: 13}, - { - Fz: ts + 35958, /* "EINTR" */ - Fi: 4}, - { - Fz: ts + 35964, /* "EIO" */ - Fi: 5}, - { - Fz: ts + 35968, /* "EOVERFLOW" */ - Fi: 75}, - { - Fz: ts + 35978, /* "ENOMEM" */ - Fi: 12}, - { - Fz: ts + 35985, /* "EAGAIN" */ - Fi: 11}, - { - Fz: ts + 35992, /* "ETIMEDOUT" */ - Fi: 110}, - { - Fz: ts + 36002, /* "EBUSY" */ - Fi: 16}, - { - Fz: ts + 36008, /* "EPERM" */ - Fi: 1}, - { - Fz: ts + 36014, /* "EDEADLK" */ - Fi: 35}, - { - Fz: ts + 36022, /* "ENOLCK" */ - Fi: 37}, + {Fz: ts + 35951 /* "EACCES" */, Fi: EACCES}, + {Fz: ts + 35958 /* "EINTR" */, Fi: EINTR}, + {Fz: ts + 35964 /* "EIO" */, Fi: EIO}, + {Fz: ts + 35968 /* "EOVERFLOW" */, Fi: EOVERFLOW}, + {Fz: ts + 35978 /* "ENOMEM" */, Fi: ENOMEM}, + {Fz: ts + 35985 /* "EAGAIN" */, Fi: EAGAIN}, + {Fz: ts + 35992 /* "ETIMEDOUT" */, Fi: ETIMEDOUT}, + {Fz: ts + 36002 /* "EBUSY" */, Fi: EBUSY}, + {Fz: ts + 36008 /* "EPERM" */, Fi: EPERM}, + {Fz: ts + 36014 /* "EDEADLK" */, Fi: EDEADLK}, + {Fz: ts + 36022 /* "ENOLCK" */, Fi: ENOLCK}, {}, } if objc != 4 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+36029 /* "SYSCALL ERRNO" */) - return 1 + return TCL_ERROR } rc = tcl.XTcl_GetIndexFromObjStruct(tls, interp, - *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), uintptr(unsafe.Pointer(&aSyscall)), int32(unsafe.Sizeof(TestSyscallArray{})), ts+35923 /* "system-call" */, 0, bp /* &iCall */) - if rc != 0 { + *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&aSyscall)), int32(unsafe.Sizeof(TestSyscallArray{})), ts+35923 /* "system-call" */, 0, bp /* &iCall */) + if rc != TCL_OK { return rc } rc = tcl.XTcl_GetIndexFromObjStruct(tls, interp, - *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+8 /* &aErrno[0] */, int32(unsafe.Sizeof(Errno{})), ts+36043 /* "errno" */, 0, bp+200 /* &iErrno */) - if rc != 0 { + *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8 /* &aErrno[0] */, int32(unsafe.Sizeof(Errno{})), ts+36043 /* "errno" */, 0, bp+200 /* &iErrno */) + if rc != TCL_OK { return rc } aSyscall[*(*int32)(unsafe.Pointer(bp /* iCall */))].Fcustom_errno = (*Errno)(unsafe.Pointer(bp + 8 /* &aErrno */ + uintptr(*(*int32)(unsafe.Pointer(bp + 200 /* iErrno */)))*16)).Fi - return 0 + return TCL_OK } type Errno = struct { @@ -79033,7 +74391,7 @@ func test_syscall_list(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) @@ -79050,7 +74408,7 @@ func test_syscall_list(tls *libc.TLS, clientData uintptr, interp uintptr, objc i tcl.XTclFreeObj(tls, _objPtr) } } - return 0 + return TCL_OK } func test_syscall_defaultvfs(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:649:26: */ @@ -79058,12 +74416,12 @@ func test_syscall_defaultvfs(tls *libc.TLS, clientData uintptr, interp uintptr, if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+488 /* "" */) - return 1 + return TCL_ERROR } pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FzName, -1)) - return 0 + return TCL_OK } func ts_getpagesize(tls *libc.TLS) int32 { /* test_syscall.c:667:12: */ @@ -79079,10 +74437,10 @@ func test_syscall_pagesize(tls *libc.TLS, clientData uintptr, interp uintptr, ob if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+36049 /* "PGSZ" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+16 /* &pgsz */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+16 /* &pgsz */) != 0 { + return TCL_ERROR } if *(*int32)(unsafe.Pointer(bp + 16 /* pgsz */)) < 0 { @@ -79092,7 +74450,7 @@ func test_syscall_pagesize(tls *libc.TLS, clientData uintptr, interp uintptr, ob } else { if (*(*int32)(unsafe.Pointer(bp + 16 /* pgsz */)) < 512) || ((*(*int32)(unsafe.Pointer(bp + 16 /* pgsz */)) & (*(*int32)(unsafe.Pointer(bp + 16 /* pgsz */)) - 1)) != 0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+36066 /* "pgsz out of rang..." */, 0)) - return 1 + return TCL_ERROR } gSyscall.Forig_getpagesize = (*(*func(*libc.TLS, uintptr, uintptr) sqlite3_syscall_ptr)(unsafe.Pointer((pVfs + 152 /* &.xGetSystemCall */))))(tls, pVfs, ts+36054 /* "getpagesize" */) gSyscall.Fpgsz = *(*int32)(unsafe.Pointer(bp + 16 /* pgsz */)) @@ -79100,7 +74458,7 @@ func test_syscall_pagesize(tls *libc.TLS, clientData uintptr, interp uintptr, ob pVfs, ts+36054 /* "getpagesize" */, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) int32 }{ts_getpagesize}))) } - return 0 + return TCL_OK } func test_syscall(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:706:26: */ @@ -79108,51 +74466,33 @@ func test_syscall(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, defer tls.Free(180) *(*[10]SyscallCmd)(unsafe.Pointer(bp + 16 /* aCmd */)) = [10]SyscallCmd{ - { - FzName: ts + 36084, /* "fault" */ - FxCmd: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{test_syscall_fault}))}, - { - FzName: ts + 36090, /* "install" */ - FxCmd: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{test_syscall_install}))}, - { - FzName: ts + 36098, /* "uninstall" */ - FxCmd: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{test_syscall_uninstall}))}, - { - FzName: ts + 7201, /* "reset" */ - FxCmd: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{test_syscall_reset}))}, - { - FzName: ts + 36043, /* "errno" */ - FxCmd: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{test_syscall_errno}))}, - { - FzName: ts + 13018, /* "exists" */ - FxCmd: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{test_syscall_exists}))}, - { - FzName: ts + 36108, /* "list" */ - FxCmd: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{test_syscall_list}))}, - { - FzName: ts + 36113, /* "defaultvfs" */ - FxCmd: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{test_syscall_defaultvfs}))}, - { - FzName: ts + 36124, /* "pagesize" */ - FxCmd: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{test_syscall_pagesize}))}, + {FzName: ts + 36084 /* "fault" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{test_syscall_fault}))}, + {FzName: ts + 36090 /* "install" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{test_syscall_install}))}, + {FzName: ts + 36098 /* "uninstall" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{test_syscall_uninstall}))}, + {FzName: ts + 7201 /* "reset" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{test_syscall_reset}))}, + {FzName: ts + 36043 /* "errno" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{test_syscall_errno}))}, + {FzName: ts + 13018 /* "exists" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{test_syscall_exists}))}, + {FzName: ts + 36108 /* "list" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{test_syscall_list}))}, + {FzName: ts + 36113 /* "defaultvfs" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{test_syscall_defaultvfs}))}, + {FzName: ts + 36124 /* "pagesize" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{test_syscall_pagesize}))}, {}, } // var iCmd int32 at bp+176, 4 @@ -79162,16 +74502,16 @@ func test_syscall(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, if objc < 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31821 /* "SUB-COMMAND ..." */) - return 1 + return TCL_ERROR } if ((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FiVersion < 3) || ((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FxSetSystemCall == uintptr(0)) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+36133 /* "VFS does not sup..." */, 0)) - rc = 1 + rc = TCL_ERROR } else { rc = tcl.XTcl_GetIndexFromObjStruct(tls, interp, - *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+16 /* &aCmd[0] */, int32(unsafe.Sizeof(SyscallCmd{})), ts+1874 /* "sub-command" */, 0, bp+176 /* &iCmd */) + *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &aCmd[0] */, int32(unsafe.Sizeof(SyscallCmd{})), ts+1874 /* "sub-command" */, 0, bp+176 /* &iCmd */) } - if rc != 0 { + if rc != TCL_OK { return rc } 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) @@ -79187,18 +74527,16 @@ func SqlitetestSyscall_Init(tls *libc.TLS, interp uintptr) int32 { /* test_sysca defer tls.Free(16) *(*[1]SyscallCmd)(unsafe.Pointer(bp /* aCmd */)) = [1]SyscallCmd{ - { - FzName: ts + 36169, /* "test_syscall" */ - FxCmd: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{test_syscall}))}, + {FzName: ts + 36169 /* "test_syscall" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{test_syscall}))}, } var i int32 for i = 0; uint64(i) < (uint64(unsafe.Sizeof([1]SyscallCmd{})) / uint64(unsafe.Sizeof(SyscallCmd{}))); i++ { 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)) } - return 0 + return TCL_OK } // This routine is the primary export of this file. @@ -79286,16 +74624,16 @@ func load_testfixture_extensions(tls *libc.TLS, cd ClientData, interp uintptr, o var slave uintptr if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+36210 /* "SLAVE" */) - return 1 + return TCL_ERROR } - slave = tcl.XTcl_GetSlave(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + slave = tcl.XTcl_GetSlave(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) if !(slave != 0) { - return 1 + return TCL_ERROR } sqlite3TestInit(tls, slave) - return 0 + return TCL_OK } // end block for C++ @@ -79413,22 +74751,28 @@ func tclvarConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin var pVtab uintptr pVtab = sqlite3.Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(tclvar_vtab{}))) if pVtab == uintptr(0) { - return 7 + return SQLITE_NOMEM } *(*uintptr)(unsafe.Pointer(ppVtab)) = (pVtab /* &.base */) (*tclvar_vtab)(unsafe.Pointer(pVtab)).Finterp = pAux sqlite3.Xsqlite3_declare_vtab(tls, db, uintptr(unsafe.Pointer(&zSchema))) - return 0 + return SQLITE_OK } -var zSchema = *(*[100]int8)(unsafe.Pointer(ts + 36216 /* "CREATE TABLE x( ..." */)) /* test_tclvar.c:88:21 */ +var zSchema = + +// Base name +// Array index +// Value +// base(index) name +*(*[100]int8)(unsafe.Pointer(ts + 36216 /* "CREATE TABLE x( ..." */)) /* test_tclvar.c:88:21 */ // Note that for this virtual table, the xCreate and xConnect // methods are identical. func tclvarDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* test_tclvar.c:105:12: */ sqlite3.Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // The xDisconnect and xDestroy methods are also the same @@ -79438,7 +74782,7 @@ func tclvarOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_ var pCur uintptr pCur = sqlite3.Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(tclvar_cursor{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Close a tclvar cursor. @@ -79461,7 +74805,7 @@ func tclvarClose(tls *libc.TLS, cur uintptr) int32 { /* test_tclvar.c:124:12: */ } } sqlite3.Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } // Returns 1 if data is ready, or 0 if not. @@ -79476,7 +74820,7 @@ func next2(tls *libc.TLS, interp uintptr, pCur uintptr, pObj uintptr) int32 { /* p = tcl.XTcl_NewStringObj(tls, ts+36316 /* "array names" */, -1) (*Tcl_Obj)(unsafe.Pointer(p)).FrefCount++ tcl.XTcl_ListObjAppendElement(tls, uintptr(0), p, pObj) - tcl.XTcl_EvalObjEx(tls, interp, p, 0x020000) + tcl.XTcl_EvalObjEx(tls, interp, p, TCL_EVAL_GLOBAL) for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = p if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { @@ -79572,7 +74916,7 @@ func tclvarFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintp tcl.XTcl_ListObjAppendElement(tls, uintptr(0), p, tcl.XTcl_NewStringObj(tls, zRegexp, -1)) tcl.XTcl_ListObjAppendElement(tls, uintptr(0), p, tcl.XTcl_NewStringObj(tls, zLike, -1)) - tcl.XTcl_EvalObjEx(tls, interp, p, 0x020000) + tcl.XTcl_EvalObjEx(tls, interp, p, TCL_EVAL_GLOBAL) if (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList1 != 0 { for ok := true; ok; ok = 0 != 0 { var _objPtr uintptr = (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList1 @@ -79643,7 +74987,7 @@ func tclvarColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* t return z2 } return uintptr(0) - }(), 1) + }(), TCL_GLOBAL_ONLY) sqlite3.Xsqlite3_result_text(tls, ctx, tcl.XTcl_GetString(tls, pVal), -1, libc.UintptrFromInt32(-1)) break @@ -79661,12 +75005,12 @@ func tclvarColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* t } } - return 0 + return SQLITE_OK } func tclvarRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test_tclvar.c:292:12: */ *(*sqlite_int64)(unsafe.Pointer(pRowid)) = int64(0) - return 0 + return SQLITE_OK } func tclvarEof(tls *libc.TLS, cur uintptr) int32 { /* test_tclvar.c:297:12: */ @@ -79708,11 +75052,11 @@ func tclvarSetOmit(tls *libc.TLS, interp uintptr) int32 { /* test_tclvar.c:324:1 var pRes uintptr rc = tcl.XTcl_Eval(tls, interp, ts+36353 /* "expr {[info exis..." */) - if rc == 0 { + if rc == TCL_OK { pRes = tcl.XTcl_GetObjResult(tls, interp) rc = tcl.XTcl_GetBooleanFromObj(tls, uintptr(0), pRes, bp /* &res */) } - return (libc.Bool32((rc == 0) && (*(*int32)(unsafe.Pointer(bp /* res */)) != 0))) + return (libc.Bool32((rc == TCL_OK) && (*(*int32)(unsafe.Pointer(bp /* res */)) != 0))) } // The xBestIndex() method. This virtual table supports the following @@ -79733,9 +75077,9 @@ func tclvarBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* te var iStr int32 = 0 if zStr == uintptr(0) { - return 7 + return SQLITE_NOMEM } - *(*int8)(unsafe.Pointer(zStr + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(zStr)) = int8(0) for ii = 0; ii < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { var pCons uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12) @@ -79744,7 +75088,7 @@ func tclvarBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* te pUsage = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8) if (*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fusable != 0 { // name = ? - if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == 2) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 0) { + if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 0) { if 0 == tclvarAddToIdxstr(tls, zStr, int8('e')) { (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = libc.PreIncInt32(&iStr, 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(0) @@ -79752,7 +75096,7 @@ func tclvarBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* te } // name MATCH ? - if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == 64) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 0) { + if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 0) { if 0 == tclvarAddToIdxstr(tls, zStr, int8('m')) { (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = libc.PreIncInt32(&iStr, 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(1) @@ -79760,7 +75104,7 @@ func tclvarBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* te } // value GLOB ? - if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == 66) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 2) { + if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_GLOB) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 2) { if 0 == tclvarAddToIdxstr(tls, zStr, int8('g')) { (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = libc.PreIncInt32(&iStr, 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(tclvarSetOmit(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp)) @@ -79768,7 +75112,7 @@ func tclvarBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* te } // value REGEXP ? - if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == 67) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 2) { + if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_REGEXP) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 2) { if 0 == tclvarAddToIdxstr(tls, zStr, int8('r')) { (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = libc.PreIncInt32(&iStr, 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(tclvarSetOmit(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp)) @@ -79776,7 +75120,7 @@ func tclvarBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* te } // value LIKE ? - if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == 65) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 2) { + if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_LIKE) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 2) { if 0 == tclvarAddToIdxstr(tls, zStr, int8('l')) { (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = libc.PreIncInt32(&iStr, 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(tclvarSetOmit(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp)) @@ -79787,7 +75131,7 @@ func tclvarBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* te (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = zStr (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = 1 - return 0 + return SQLITE_OK } // Invoked for any UPDATE, INSERT, or DELETE against a tclvar table @@ -79795,82 +75139,61 @@ func tclvarUpdate(tls *libc.TLS, tab uintptr, argc int32, argv uintptr, pRowid u var pTab uintptr = tab if argc == 1 { // A DELETE operation. The variable to be deleted is stored in argv[0] - var zVar uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - tcl.XTcl_UnsetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zVar, uintptr(0), 1) - return 0 + var zVar uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + tcl.XTcl_UnsetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zVar, uintptr(0), TCL_GLOBAL_ONLY) + return SQLITE_OK } - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { // An INSERT operation - var zValue uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8))) + var zValue uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) var zName uintptr - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(5)*8))) != 3 { + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) != SQLITE_TEXT { (*sqlite3_vtab)(unsafe.Pointer(tab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+36414 /* "the 'fullname' c..." */, 0) - return 1 + return SQLITE_ERROR } - zName = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(5)*8))) + zName = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) if zValue != 0 { - tcl.XTcl_SetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zName, uintptr(0), zValue, 1) + tcl.XTcl_SetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zName, uintptr(0), zValue, TCL_GLOBAL_ONLY) } else { - tcl.XTcl_UnsetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zName, uintptr(0), 1) + tcl.XTcl_UnsetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zName, uintptr(0), TCL_GLOBAL_ONLY) } - return 0 + return SQLITE_OK } - if (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 3) && - (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) == 3) { + if (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_TEXT) && + (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) == SQLITE_TEXT) { // An UPDATE operation - var zOldName uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var zNewName uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - var zValue uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8))) + var zOldName uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + var zNewName uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + var zValue uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) if (libc.Xstrcmp(tls, zOldName, zNewName) != 0) || (zValue == uintptr(0)) { - tcl.XTcl_UnsetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zOldName, uintptr(0), 1) + tcl.XTcl_UnsetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zOldName, uintptr(0), TCL_GLOBAL_ONLY) } if zValue != uintptr(0) { - tcl.XTcl_SetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zNewName, uintptr(0), zValue, 1) + tcl.XTcl_SetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zNewName, uintptr(0), zValue, TCL_GLOBAL_ONLY) } - return 0 + return SQLITE_OK } (*sqlite3_vtab)(unsafe.Pointer(tab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+36449 /* "prohibited TCL v..." */, 0) - return 1 + return SQLITE_ERROR } // A virtual table module that provides read-only access to a // Tcl global variable namespace. -var tclvarModule = sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, +var tclvarModule = sqlite3_module{ // iVersion + FxCreate: 0, FxConnect: 0, FxBestIndex: 0, FxDisconnect: 0, FxDestroy: 0, - FxOpen: 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), // xRename + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRowid - read data + FxUpdate: 0, // xRename } /* test_tclvar.c:469:23 */ // Register the echo virtual table module. @@ -79878,15 +75201,15 @@ func register_tclvar_module(tls *libc.TLS, clientData ClientData, interp uintptr bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = TCL_OK // var db uintptr at bp, 8 if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } sqlite3.Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+28695 /* "tclvar" */, uintptr(unsafe.Pointer(&tclvarModule)), interp) rc = tcl.XTcl_Eval(tls, interp, @@ -79906,7 +75229,7 @@ func Sqlitetesttclvar_Init(tls *libc.TLS, interp uintptr) int32 { /* test_tclvar tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd13[i].FzName, aObjCmd13[i].FxProc, aObjCmd13[i].FclientData, uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd13 = [1]struct { @@ -79914,10 +75237,7 @@ var aObjCmd13 = [1]struct { FxProc uintptr FclientData uintptr }{ - { - FzName: ts + 37016, /* "register_tclvar_..." */ - FxProc: 0, - FclientData: uintptr(0)}, + {FzName: ts + 37016 /* "register_tclvar_..." */, FxProc: 0}, } /* test_tclvar.c:552:5 */ // Define some macros helping to catch buffer overflows. @@ -79958,7 +75278,7 @@ func tclScriptEvent(tls *libc.TLS, evPtr uintptr, flags int32) int32 { /* test_t var rc int32 var p uintptr = evPtr rc = tcl.XTcl_Eval(tls, (*EvalEvent)(unsafe.Pointer(p)).Finterp, (*EvalEvent)(unsafe.Pointer(p)).FzScript) - if rc != 0 { + if rc != TCL_OK { tcl.XTcl_BackgroundError(tls, (*EvalEvent)(unsafe.Pointer(p)).Finterp) } _ = flags @@ -79981,7 +75301,7 @@ func postToParent(tls *libc.TLS, p uintptr, pScript uintptr) { /* test_thread.c: (*EvalEvent)(unsafe.Pointer(pEvent)).Fbase.Fproc = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32) int32 }{tclScriptEvent})) - (*EvalEvent)(unsafe.Pointer(pEvent)).FzScript = (pEvent + uintptr(1)*32) + (*EvalEvent)(unsafe.Pointer(pEvent)).FzScript = (pEvent + 1*32) libc.Xmemcpy(tls, (*EvalEvent)(unsafe.Pointer(pEvent)).FzScript, zMsg, (uint64(*(*int32)(unsafe.Pointer(bp /* nMsg */)) + 1))) (*EvalEvent)(unsafe.Pointer(pEvent)).Finterp = (*SqlThread)(unsafe.Pointer(p)).Finterp @@ -80025,7 +75345,7 @@ func tclScriptThread(tls *libc.TLS, pSqlThread ClientData) { /* test_thread.c:11 (*Tcl_Obj)(unsafe.Pointer(pList)).FrefCount++ (*Tcl_Obj)(unsafe.Pointer(pRes)).FrefCount++ - if rc != 0 { + if rc != TCL_OK { tcl.XTcl_ListObjAppendElement(tls, interp, pList, tcl.XTcl_NewStringObj(tls, ts+10131 /* "error" */, -1)) tcl.XTcl_ListObjAppendElement(tls, interp, pList, pRes) postToParent(tls, p, pList) @@ -80057,7 +75377,7 @@ func tclScriptThread(tls *libc.TLS, pSqlThread ClientData) { /* test_thread.c:11 } } tcl.XTcl_DeleteInterp(tls, interp) - for tcl.XTcl_DoOneEvent(tls, ((^libc.Int32((int32(1) << 1)))|(int32(1)<<1))) != 0 { + for tcl.XTcl_DoOneEvent(tls, ((libc.CplInt32((int32(1) << 1)))|(int32(1)<<1))) != 0 { } tcl.XTcl_ExitThread(tls, 0) @@ -80093,11 +75413,11 @@ func sqlthread_spawn(tls *libc.TLS, clientData ClientData, interp uintptr, objc _ = clientData _ = objc - zVarname = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+16 /* &nVarname */) - zScript = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+20 /* &nScript */) + zVarname = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+16 /* &nVarname */) + zScript = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+20 /* &nScript */) 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)))) - (*SqlThread)(unsafe.Pointer(pNew)).FzVarname = (pNew + uintptr(1)*32) + (*SqlThread)(unsafe.Pointer(pNew)).FzVarname = (pNew + 1*32) (*SqlThread)(unsafe.Pointer(pNew)).FzScript = ((*SqlThread)(unsafe.Pointer(pNew)).FzVarname + uintptr((*(*int32)(unsafe.Pointer(bp + 16 /* nVarname */)) + 1))) libc.Xmemcpy(tls, (*SqlThread)(unsafe.Pointer(pNew)).FzVarname, zVarname, (uint64(*(*int32)(unsafe.Pointer(bp + 16 /* nVarname */)) + 1))) libc.Xmemcpy(tls, (*SqlThread)(unsafe.Pointer(pNew)).FzScript, zScript, (uint64(*(*int32)(unsafe.Pointer(bp + 20 /* nScript */)) + 1))) @@ -80105,13 +75425,13 @@ func sqlthread_spawn(tls *libc.TLS, clientData ClientData, interp uintptr, objc (*SqlThread)(unsafe.Pointer(pNew)).Finterp = interp rc = tcl.XTcl_CreateThread(tls, bp+24 /* &x */, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, ClientData) }{tclScriptThread})), pNew, nStack, flags) - if rc != 0 { + if rc != TCL_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+37148 /* "Error in Tcl_Cre..." */, 0)) tcl.XTcl_Free(tls, pNew) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } // sqlthread parent SCRIPT @@ -80137,22 +75457,22 @@ func sqlthread_parent(tls *libc.TLS, clientData ClientData, interp uintptr, objc if p == uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+37176 /* "no parent thread" */, 0)) - return 1 + return TCL_ERROR } - zMsg = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+16 /* &nMsg */) + zMsg = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+16 /* &nMsg */) pEvent = tcl.XTcl_Alloc(tls, (uint32((uint64(unsafe.Sizeof(EvalEvent{})) + uint64(*(*int32)(unsafe.Pointer(bp + 16 /* nMsg */)))) + uint64(1)))) (*EvalEvent)(unsafe.Pointer(pEvent)).Fbase.FnextPtr = uintptr(0) (*EvalEvent)(unsafe.Pointer(pEvent)).Fbase.Fproc = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32) int32 }{tclScriptEvent})) - (*EvalEvent)(unsafe.Pointer(pEvent)).FzScript = (pEvent + uintptr(1)*32) + (*EvalEvent)(unsafe.Pointer(pEvent)).FzScript = (pEvent + 1*32) libc.Xmemcpy(tls, (*EvalEvent)(unsafe.Pointer(pEvent)).FzScript, zMsg, (uint64(*(*int32)(unsafe.Pointer(bp + 16 /* nMsg */)) + 1))) (*EvalEvent)(unsafe.Pointer(pEvent)).Finterp = (*SqlThread)(unsafe.Pointer(p)).Finterp tcl.XTcl_ThreadQueueEvent(tls, (*SqlThread)(unsafe.Pointer(p)).Fparent, pEvent, TCL_QUEUE_TAIL) tcl.XTcl_ThreadAlert(tls, (*SqlThread)(unsafe.Pointer(p)).Fparent) - return 0 + return TCL_OK } func xBusy(tls *libc.TLS, pArg uintptr, nBusy int32) int32 { /* test_thread.c:259:12: */ @@ -80178,7 +75498,7 @@ func sqlthread_open(tls *libc.TLS, clientData ClientData, interp uintptr, objc i _ = clientData _ = objc - zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) sqlite3.Xsqlite3_open(tls, zFilename, bp+16 /* &db */) Md5_Register(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), uintptr(0), uintptr(0)) sqlite3.Xsqlite3_busy_handler(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), *(*uintptr)(unsafe.Pointer(&struct { @@ -80186,11 +75506,11 @@ func sqlthread_open(tls *libc.TLS, clientData ClientData, interp uintptr, objc i }{xBusy})), uintptr(0)) if sqlite3TestMakePointerStr(tls, interp, bp+24 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */))) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, bp+24 /* &zBuf[0] */, 0)) - return 0 + return TCL_OK } // sqlthread open @@ -80203,7 +75523,7 @@ func sqlthread_id(tls *libc.TLS, clientData ClientData, interp uintptr, objc int _ = clientData _ = objc _ = objv - return 0 + return TCL_OK } // Dispatch routine for the sub-commands of [sqlthread]. @@ -80224,34 +75544,18 @@ func sqlthread_proc(tls *libc.TLS, clientData ClientData, interp uintptr, objc i _ [4]byte FzUsage uintptr }{ - { - FzName: ts + 37193, /* "parent" */ - FxProc: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 - }{sqlthread_parent})), - FnArg: 1, - FzUsage: ts + 11405 /* "SCRIPT" */}, - { - FzName: ts + 37200, /* "spawn" */ - FxProc: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 - }{sqlthread_spawn})), - FnArg: 2, - FzUsage: ts + 37206 /* "VARNAME SCRIPT" */}, - { - FzName: ts + 35810, /* "open" */ - FxProc: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 - }{sqlthread_open})), - FnArg: 1, - FzUsage: ts + 37221 /* "DBNAME" */}, - { - FzName: ts + 37228, /* "id" */ - FxProc: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 - }{sqlthread_id})), - FnArg: 0, - FzUsage: ts + 488 /* "" */}, + {FzName: ts + 37193 /* "parent" */, FxProc: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 + }{sqlthread_parent})), FnArg: 1, FzUsage: ts + 11405 /* "SCRIPT" */}, + {FzName: ts + 37200 /* "spawn" */, FxProc: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 + }{sqlthread_spawn})), FnArg: 2, FzUsage: ts + 37206 /* "VARNAME SCRIPT" */}, + {FzName: ts + 35810 /* "open" */, FxProc: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 + }{sqlthread_open})), FnArg: 1, FzUsage: ts + 37221 /* "DBNAME" */}, + {FzName: ts + 37228 /* "id" */, FxProc: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 + }{sqlthread_id})), FzUsage: ts + 488 /* "" */}, {}, } var pSub uintptr @@ -80260,18 +75564,18 @@ func sqlthread_proc(tls *libc.TLS, clientData ClientData, interp uintptr, objc i if objc < 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2383 /* "SUB-COMMAND" */) - return 1 + return TCL_ERROR } rc = tcl.XTcl_GetIndexFromObjStruct(tls, - interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp /* &aSub[0] */, int32(unsafe.Sizeof(struct { + interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &aSub[0] */, int32(unsafe.Sizeof(struct { FzName uintptr FxProc uintptr FnArg int32 _ [4]byte FzUsage uintptr }{})), ts+1874 /* "sub-command" */, 0, bp+160 /* &iIndex */) - if rc != 0 { + if rc != TCL_OK { return rc } pSub = (bp /* &aSub */ + uintptr(*(*int32)(unsafe.Pointer(bp + 160 /* iIndex */)))*32) @@ -80290,7 +75594,7 @@ func sqlthread_proc(tls *libc.TLS, clientData ClientData, interp uintptr, objc i _ [4]byte FzUsage uintptr })(unsafe.Pointer(pSub)).FzUsage) - return 1 + return TCL_ERROR } return (*(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer((pSub + 8 /* &.xProc */))))(tls, clientData, interp, objc, objv) @@ -80314,7 +75618,7 @@ func clock_seconds_proc(tls *libc.TLS, clientData ClientData, interp uintptr, ob _ = clientData _ = objc _ = objv - return 0 + return TCL_OK } // A pointer to an instance of this structure is passed as the user-context @@ -80378,7 +75682,7 @@ func wait_for_unlock_notify(tls *libc.TLS, db uintptr) int32 { /* test_thread.c: // case this function needs to return SQLITE_LOCKED to the caller so // that the current transaction can be rolled back. Otherwise, block // until the unlock-notify callback is invoked, then return SQLITE_OK. - if rc == 0 { + if rc == SQLITE_OK { libc2.Xpthread_mutex_lock(tls, (bp /* &un */ + 56 /* &.mutex */)) if !((*UnlockNotification)(unsafe.Pointer(bp /* &un */)).Ffired != 0) { libc2.Xpthread_cond_wait(tls, (bp /* &un */ + 8 /* &.cond */), (bp /* &un */ + 56 /* &.mutex */)) @@ -80404,9 +75708,9 @@ func wait_for_unlock_notify(tls *libc.TLS, db uintptr) int32 { /* test_thread.c: // system may become deadlocked. func sqlite3_blocking_step(tls *libc.TLS, pStmt uintptr) int32 { /* test_thread.c:492:5: */ var rc int32 - for 6 == (libc.AssignInt32(&rc, sqlite3.Xsqlite3_step(tls, pStmt))) { + for SQLITE_LOCKED == (libc.AssignInt32(&rc, sqlite3.Xsqlite3_step(tls, pStmt))) { rc = wait_for_unlock_notify(tls, sqlite3.Xsqlite3_db_handle(tls, pStmt)) - if rc != 0 { + if rc != SQLITE_OK { break } sqlite3.Xsqlite3_reset(tls, pStmt) @@ -80425,9 +75729,9 @@ func sqlite3_blocking_step(tls *libc.TLS, pStmt uintptr) int32 { /* test_thread. // system may become deadlocked. func sqlite3_blocking_prepare_v2(tls *libc.TLS, db uintptr, zSql uintptr, nSql int32, ppStmt uintptr, pz uintptr) int32 { /* test_thread.c:513:5: */ var rc int32 - for 6 == (libc.AssignInt32(&rc, sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, nSql, ppStmt, pz))) { + for SQLITE_LOCKED == (libc.AssignInt32(&rc, sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, nSql, ppStmt, pz))) { rc = wait_for_unlock_notify(tls, db) - if rc != 0 { + if rc != SQLITE_OK { break } } @@ -80445,14 +75749,14 @@ func blocking_step_proc(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16285 /* "STMT" */) - return 1 + return TCL_ERROR } - pStmt = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)))) + pStmt = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) rc = sqlite3_blocking_step(tls, pStmt) tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) - return 0 + return TCL_OK } // Usage: sqlite3_blocking_prepare_v2 DB sql bytes ?tailvar? @@ -80475,15 +75779,15 @@ func blocking_prepare_v2_proc(tls *libc.TLS, clientData uintptr, interp uintptr, if (objc != 5) && (objc != 4) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14451, /* "wrong # args: sh..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8))), ts+16331 /* " DB sql bytes ta..." */, 0)) - return 1 + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16331 /* " DB sql bytes ta..." */, 0)) + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+80 /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+80 /* &db */) != 0 { + return TCL_ERROR } - zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+88 /* &bytes */) != 0 { - return 1 + zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+88 /* &bytes */) != 0 { + return TCL_ERROR } if isBlocking != 0 { @@ -80496,22 +75800,22 @@ func blocking_prepare_v2_proc(tls *libc.TLS, clientData uintptr, interp uintptr, if *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) >= 0 { *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) = (int32(int64(*(*int32)(unsafe.Pointer(bp + 88 /* bytes */))) - ((int64(*(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */))) - int64(zSql)) / 1))) } - tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), uintptr(0), tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)), *(*int32)(unsafe.Pointer(bp + 88 /* bytes */))), 0) + 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) } - if rc != 0 { + if rc != SQLITE_OK { sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+112 /* &zBuf[0] */, ts+37231 /* "%s " */, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc))) tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+112 /* &zBuf[0] */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */))), 0)) - return 1 + return TCL_ERROR } if *(*uintptr)(unsafe.Pointer(bp + 96 /* pStmt */)) != 0 { if sqlite3TestMakePointerStr(tls, interp, bp+112 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 96 /* pStmt */))) != 0 { - return 1 + return TCL_ERROR } tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, bp+112 /* &zBuf[0] */, 0)) } - return 0 + return TCL_OK } // @@ -80537,7 +75841,7 @@ func SqlitetestThread_Init(tls *libc.TLS, interp uintptr) int32 { /* test_thread ts+37113 /* "sqlite3_nonblock..." */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 }{blocking_prepare_v2_proc})), uintptr(0), uintptr(0)) - return 0 + return TCL_OK } // end block for C++ @@ -80549,7 +75853,7 @@ func SqlitetestThread_Init(tls *libc.TLS, interp uintptr) int32 { /* test_thread // End: func Sqlitetestvdbecov_Init(tls *libc.TLS, interp uintptr) int32 { /* test_vdbecov.c:113:5: */ - return 0 + return TCL_OK } // end block for C++ @@ -80624,42 +75928,25 @@ type TestFaultInject1 = struct { type TestFaultInject = TestFaultInject1 /* test_vfs.c:69:32 */ var tvfs_io_methods = sqlite3_io_methods{ - FiVersion: 3, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - 0, - FxUnlock:// xLock - 0, - FxCheckReservedLock:// xUnlock - 0, - FxFileControl:// xCheckReservedLock - 0, - FxSectorSize:// xFileControl - 0, - FxDeviceCharacteristics:// xSectorSize - 0, - FxShmMap:// xDeviceCharacteristics - 0, - FxShmLock:// xShmMap - 0, - FxShmBarrier:// xShmLock - 0, - FxShmUnmap:// xShmBarrier - 0, - FxFetch:// xShmUnmap - 0, - FxUnfetch: 0, + FiVersion: 3, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xFileSize + FxLock: 0, // xLock + FxUnlock: 0, // xUnlock + FxCheckReservedLock: 0, // xCheckReservedLock + FxFileControl: 0, // xFileControl + FxSectorSize: 0, // xSectorSize + FxDeviceCharacteristics: 0, // xDeviceCharacteristics + FxShmMap: 0, // xShmMap + FxShmLock: 0, // xShmLock + FxShmBarrier: 0, // xShmBarrier + FxShmUnmap: 0, // xShmUnmap + FxFetch: 0, + FxUnfetch: 0, } /* test_vfs.c:204:27 */ func tvfsResultCode(tls *libc.TLS, p uintptr, pRc uintptr) int32 { /* test_vfs.c:226:12: */ @@ -80667,33 +75954,15 @@ func tvfsResultCode(tls *libc.TLS, p uintptr, pRc uintptr) int32 { /* test_vfs.c defer tls.Free(144) *(*[9]errcode)(unsafe.Pointer(bp /* aCode */)) = [9]errcode{ - { - FeCode: 0, - FzCode: ts + 1987 /* "SQLITE_OK" */}, - { - FeCode: 1, - FzCode: ts + 1974 /* "SQLITE_ERROR" */}, - { - FeCode: 10, - FzCode: ts + 37235 /* "SQLITE_IOERR" */}, - { - FeCode: 6, - FzCode: ts + 37248 /* "SQLITE_LOCKED" */}, - { - FeCode: 5, - FzCode: ts + 37262 /* "SQLITE_BUSY" */}, - { - FeCode: 8, - FzCode: ts + 37274 /* "SQLITE_READONLY" */}, - { - FeCode: (8 | (int32(5) << 8)), - FzCode: ts + 37290 /* "SQLITE_READONLY_..." */}, - { - FeCode: 12, - FzCode: ts + 37315 /* "SQLITE_NOTFOUND" */}, - { - FeCode: -1, - FzCode: ts + 37331 /* "SQLITE_OMIT" */}, + {FzCode: ts + 1987 /* "SQLITE_OK" */}, + {FeCode: SQLITE_ERROR, FzCode: ts + 1974 /* "SQLITE_ERROR" */}, + {FeCode: SQLITE_IOERR, FzCode: ts + 37235 /* "SQLITE_IOERR" */}, + {FeCode: SQLITE_LOCKED, FzCode: ts + 37248 /* "SQLITE_LOCKED" */}, + {FeCode: SQLITE_BUSY, FzCode: ts + 37262 /* "SQLITE_BUSY" */}, + {FeCode: SQLITE_READONLY, FzCode: ts + 37274 /* "SQLITE_READONLY" */}, + {FeCode: (SQLITE_READONLY | (int32(5) << 8)), FzCode: ts + 37290 /* "SQLITE_READONLY_..." */}, + {FeCode: SQLITE_NOTFOUND, FzCode: ts + 37315 /* "SQLITE_NOTFOUND" */}, + {FeCode: -1, FzCode: ts + 37331 /* "SQLITE_OMIT" */}, } var z uintptr var i int32 @@ -80719,7 +75988,7 @@ func tvfsInjectFault(tls *libc.TLS, p uintptr) int32 { /* test_vfs.c:256:12: */ var ret int32 = 0 if (*TestFaultInject)(unsafe.Pointer(p)).FeFault != 0 { (*TestFaultInject)(unsafe.Pointer(p)).FiCnt-- - if ((*TestFaultInject)(unsafe.Pointer(p)).FiCnt == 0) || (((*TestFaultInject)(unsafe.Pointer(p)).FiCnt < 0) && ((*TestFaultInject)(unsafe.Pointer(p)).FeFault == 2)) { + if ((*TestFaultInject)(unsafe.Pointer(p)).FiCnt == 0) || (((*TestFaultInject)(unsafe.Pointer(p)).FiCnt < 0) && ((*TestFaultInject)(unsafe.Pointer(p)).FeFault == FAULT_INJECT_PERSISTENT)) { ret = 1 (*TestFaultInject)(unsafe.Pointer(p)).FnFail++ } @@ -80759,8 +76028,8 @@ func tvfsExecTcl(tls *libc.TLS, p uintptr, zMethod uintptr, arg1 uintptr, arg2 u tcl.XTcl_ListObjAppendElement(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pEval, arg4) } - rc = tcl.XTcl_EvalObjEx(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pEval, 0x020000) - if rc != 0 { + rc = tcl.XTcl_EvalObjEx(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pEval, TCL_EVAL_GLOBAL) + if rc != TCL_OK { tcl.XTcl_BackgroundError(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp) tcl.XTcl_ResetResult(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp) } @@ -80772,7 +76041,7 @@ func tvfsClose(tls *libc.TLS, pFile uintptr) int32 { /* test_vfs.c:317:12: */ var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pTestfile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000800) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_CLOSE_MASK) != 0) { tvfsExecTcl(tls, p, ts+34333, /* "xClose" */ tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, uintptr(0), uintptr(0)) } @@ -80792,7 +76061,7 @@ func tvfsClose(tls *libc.TLS, pFile uintptr) int32 { /* test_vfs.c:317:12: */ sqlite3.Xsqlite3OsClose(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal) tcl.XTcl_Free(tls, pFd) (*TestvfsFile)(unsafe.Pointer(pTestfile)).FpFd = uintptr(0) - return 0 + return SQLITE_OK } // Read data from an tvfs-file. @@ -80800,18 +76069,18 @@ func tvfsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqli bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00010000) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_READ_MASK) != 0) { tvfsExecTcl(tls, p, ts+34340, /* "xRead" */ tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, uintptr(0), uintptr(0)) tvfsResultCode(tls, p, bp /* &rc */) } - if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00010000) != 0)) && (tvfsInjectIoerr(tls, p) != 0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 10 + if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_READ_MASK) != 0)) && (tvfsInjectIoerr(tls, p) != 0) { + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_IOERR } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3OsRead(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, zBuf, iAmt, iOfst) } return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -80822,28 +76091,28 @@ func tvfsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sql bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00001000) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_WRITE_MASK) != 0) { tvfsExecTcl(tls, p, ts+34346, /* "xWrite" */ tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, tcl.XTcl_NewWideIntObj(tls, iOfst), tcl.XTcl_NewIntObj(tls, iAmt)) tvfsResultCode(tls, p, bp /* &rc */) if *(*int32)(unsafe.Pointer(bp /* rc */)) < 0 { - return 0 + return SQLITE_OK } } - if (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (tvfsInjectFullerr(tls, p) != 0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 13 + if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (tvfsInjectFullerr(tls, p) != 0) { + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_FULL } - if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00001000) != 0)) && (tvfsInjectIoerr(tls, p) != 0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 10 + if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_WRITE_MASK) != 0)) && (tvfsInjectIoerr(tls, p) != 0) { + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_IOERR } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3OsWrite(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, zBuf, iAmt, iOfst) } return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -80854,17 +76123,17 @@ func tvfsTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* te bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00002000) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_TRUNCATE_MASK) != 0) { tvfsExecTcl(tls, p, ts+34353, /* "xTruncate" */ tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, uintptr(0), uintptr(0)) tvfsResultCode(tls, p, bp /* &rc */) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3OsTruncate(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, size) } return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -80875,27 +76144,27 @@ func tvfsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_vfs.c:4 bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000200) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SYNC_MASK) != 0) { var zFlags uintptr = uintptr(0) switch flags { - case 0x00002: + case SQLITE_SYNC_NORMAL: zFlags = ts + 15900 /* "normal" */ break fallthrough - case 0x00003: + case SQLITE_SYNC_FULL: zFlags = ts + 17592 /* "full" */ break fallthrough - case (0x00002 | 0x00010): + case (SQLITE_SYNC_NORMAL | SQLITE_SYNC_DATAONLY): zFlags = ts + 37343 /* "normal|dataonly" */ break fallthrough - case (0x00003 | 0x00010): + case (SQLITE_SYNC_FULL | SQLITE_SYNC_DATAONLY): zFlags = ts + 37359 /* "full|dataonly" */ break fallthrough @@ -80909,11 +76178,11 @@ func tvfsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_vfs.c:4 tvfsResultCode(tls, p, bp /* &rc */) } - if (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (tvfsInjectFullerr(tls, p) != 0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 13 + if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (tvfsInjectFullerr(tls, p) != 0) { + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_FULL } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3OsSync(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, flags) } @@ -80933,7 +76202,7 @@ func tvfsLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_vfs.c:4 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00040000) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_LOCK_MASK) != 0) { // var zLock [30]int8 at bp+8, 30 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+8 /* &zLock[0] */, ts+1237 /* "%d" */, libc.VaList(bp, eLock)) @@ -80950,15 +76219,15 @@ func tvfsUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_vfs.c var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00020000) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_UNLOCK_MASK) != 0) { // var zLock [30]int8 at bp+8, 30 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+8 /* &zLock[0] */, ts+1237 /* "%d" */, libc.VaList(bp, eLock)) tvfsExecTcl(tls, p, ts+34379 /* "xUnlock" */, tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), tcl.XTcl_NewStringObj(tls, bp+8 /* &zLock[0] */, -1), uintptr(0), uintptr(0)) } - if (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00001000) != 0) && (tvfsInjectIoerr(tls, p) != 0) { - return (10 | (int32(8) << 8)) + if (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_WRITE_MASK) != 0) && (tvfsInjectIoerr(tls, p) != 0) { + return (SQLITE_IOERR | (int32(8) << 8)) } return sqlite3.Xsqlite3OsUnlock(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, eLock) } @@ -80967,7 +76236,7 @@ func tvfsUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_vfs.c func tvfsCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { /* test_vfs.c:512:12: */ var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00080000) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_CKLOCK_MASK) != 0) { tvfsExecTcl(tls, p, ts+37373 /* "xCheckReservedLo..." */, tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), uintptr(0), uintptr(0), uintptr(0)) } @@ -80981,44 +76250,38 @@ func tvfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData - if op == 14 { + if op == SQLITE_FCNTL_PRAGMA { var argv uintptr = pArg - if sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+10131 /* "error" */) == 0 { - var rc int32 = 1 - if *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)) != 0 { - var z uintptr = *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)) + if sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+10131 /* "error" */) == 0 { + var rc int32 = SQLITE_ERROR + if *(*uintptr)(unsafe.Pointer(argv + 2*8)) != 0 { + var z uintptr = *(*uintptr)(unsafe.Pointer(argv + 2*8)) var x int32 = libc.Xatoi(tls, z) if x != 0 { rc = x - for (int32(sqlite3.Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr(0))))]) & 0x04) != 0 { + for (int32(sqlite3.Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z)))]) & 0x04) != 0 { z++ } - for (int32(sqlite3.Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr(0))))]) & 0x01) != 0 { + for (int32(sqlite3.Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z)))]) & 0x01) != 0 { z++ } } - if *(*int8)(unsafe.Pointer(z + uintptr(0))) != 0 { - *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, z)) + if *(*int8)(unsafe.Pointer(z)) != 0 { + *(*uintptr)(unsafe.Pointer(argv)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, z)) } } return rc } - if sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+4485 /* "filename" */) == 0 { - *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename)) - return 0 + if sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+4485 /* "filename" */) == 0 { + *(*uintptr)(unsafe.Pointer(argv)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename)) + return SQLITE_OK } } - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00100000) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_FCNTL_MASK) != 0) { *(*[3]Fcntl)(unsafe.Pointer(bp + 16 /* aF */)) = [3]Fcntl{ - { - FiFnctl: 31, - FzFnctl: ts + 37392 /* "BEGIN_ATOMIC_WRI..." */}, - { - FiFnctl: 32, - FzFnctl: ts + 37411 /* "COMMIT_ATOMIC_WR..." */}, - { - FiFnctl: 25, - FzFnctl: ts + 37431 /* "ZIPVFS" */}, + {FiFnctl: SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, FzFnctl: ts + 37392 /* "BEGIN_ATOMIC_WRI..." */}, + {FiFnctl: SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, FzFnctl: ts + 37411 /* "COMMIT_ATOMIC_WR..." */}, + {FiFnctl: SQLITE_FCNTL_ZIPVFS, FzFnctl: ts + 37431 /* "ZIPVFS" */}, } var i int32 for i = 0; uint64(i) < (uint64(unsafe.Sizeof([3]Fcntl{})) / uint64(unsafe.Sizeof(Fcntl{}))); i++ { @@ -81036,7 +76299,7 @@ func tvfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) != 0 { return func() int32 { if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) < 0 { - return 0 + return SQLITE_OK } return *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) }() @@ -81090,7 +76353,7 @@ func tvfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags i (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId = uintptr(0) (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename = zName (*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs = pVfs - (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal = (pFd + uintptr(1)*56) + (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal = (pFd + 1*56) libc.Xmemset(tls, pTestfile, 0, uint64(unsafe.Sizeof(TestvfsFile{}))) (*TestvfsFile)(unsafe.Pointer(pTestfile)).FpFd = pFd @@ -81103,10 +76366,10 @@ func tvfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags i // connection is named "anon". Otherwise, the value returned by the // script is used as the connection name. tcl.XTcl_ResetResult(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp) - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000100) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_OPEN_MASK) != 0) { var pArg uintptr = tcl.XTcl_NewObj(tls) (*Tcl_Obj)(unsafe.Pointer(pArg)).FrefCount++ - if (flags & 0x00000100) != 0 { + if (flags & SQLITE_OPEN_MAIN_DB) != 0 { var z uintptr = (zName + uintptr((libc.Xstrlen(tls, zName) + uint64(1)))) for *(*int8)(unsafe.Pointer(z)) != 0 { tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pArg, tcl.XTcl_NewStringObj(tls, z, -1)) @@ -81123,7 +76386,7 @@ func tvfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags i } } if tvfsResultCode(tls, p, bp /* &rc */) != 0 { - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } } else { @@ -81131,14 +76394,14 @@ func tvfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags i } } - if (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000100) != 0) && (tvfsInjectIoerr(tls, p) != 0) { - return 10 + if (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_OPEN_MASK) != 0) && (tvfsInjectIoerr(tls, p) != 0) { + return SQLITE_IOERR } if tvfsInjectCantopenerr(tls, p) != 0 { - return 14 + return SQLITE_CANTOPEN } if tvfsInjectFullerr(tls, p) != 0 { - return 13 + return SQLITE_FULL } if !(pId != 0) { @@ -81184,15 +76447,15 @@ func tvfsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var p uintptr = (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000400) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_DELETE_MASK) != 0) { tvfsExecTcl(tls, p, ts+34438, /* "xDelete" */ tcl.XTcl_NewStringObj(tls, zPath, -1), tcl.XTcl_NewIntObj(tls, dirSync), uintptr(0), uintptr(0)) tvfsResultCode(tls, p, bp /* &rc */) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3OsDelete(tls, (*Testvfs)(unsafe.Pointer((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FpParent, zPath, dirSync) } return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -81205,29 +76468,29 @@ func tvfsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut defer tls.Free(4) var p uintptr = (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00004000) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_ACCESS_MASK) != 0) { // var rc int32 at bp, 4 var zArg uintptr = uintptr(0) - if flags == 0 { + if flags == SQLITE_ACCESS_EXISTS { zArg = ts + 37443 /* "SQLITE_ACCESS_EX..." */ } - if flags == 1 { + if flags == SQLITE_ACCESS_READWRITE { zArg = ts + 37464 /* "SQLITE_ACCESS_RE..." */ } - if flags == 2 { + if flags == SQLITE_ACCESS_READ { zArg = ts + 37488 /* "SQLITE_ACCESS_RE..." */ } tvfsExecTcl(tls, p, ts+34446, /* "xAccess" */ tcl.XTcl_NewStringObj(tls, zPath, -1), tcl.XTcl_NewStringObj(tls, zArg, -1), uintptr(0), uintptr(0)) if tvfsResultCode(tls, p, bp /* &rc */) != 0 { - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } } else { var interp uintptr = (*Testvfs)(unsafe.Pointer(p)).Finterp - if 0 == tcl.XTcl_GetBooleanFromObj(tls, uintptr(0), tcl.XTcl_GetObjResult(tls, interp), pResOut) { - return 0 + if TCL_OK == tcl.XTcl_GetBooleanFromObj(tls, uintptr(0), tcl.XTcl_GetObjResult(tls, interp), pResOut) { + return SQLITE_OK } } } @@ -81242,12 +76505,12 @@ func tvfsFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zO defer tls.Free(4) var p uintptr = (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00008000) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_FULLPATHNAME_MASK) != 0) { // var rc int32 at bp, 4 tvfsExecTcl(tls, p, ts+34454 /* "xFullPathname" */, tcl.XTcl_NewStringObj(tls, zPath, -1), uintptr(0), uintptr(0), uintptr(0)) if tvfsResultCode(tls, p, bp /* &rc */) != 0 { - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } } @@ -81277,9 +76540,9 @@ func tvfsShmOpen(tls *libc.TLS, pFile uintptr) int32 { /* test_vfs.c:827:12: */ defer tls.Free(4) var p uintptr - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 // Return code - var pBuffer uintptr // Buffer to open connection to - var pFd uintptr // The testvfs file structure + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK // Return code + var pBuffer uintptr // Buffer to open connection to + var pFd uintptr // The testvfs file structure pFd = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd p = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData @@ -81288,17 +76551,17 @@ func tvfsShmOpen(tls *libc.TLS, pFile uintptr) int32 { /* test_vfs.c:827:12: */ // // SCRIPT xShmOpen FILENAME tcl.XTcl_ResetResult(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp) - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000001) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMOPEN_MASK) != 0) { tvfsExecTcl(tls, p, ts+37507 /* "xShmOpen" */, tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), uintptr(0), uintptr(0), uintptr(0)) if tvfsResultCode(tls, p, bp /* &rc */) != 0 { - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } } } - if (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000001) != 0) && (tvfsInjectIoerr(tls, p) != 0) { - return 10 + if (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMOPEN_MASK) != 0) && (tvfsInjectIoerr(tls, p) != 0) { + return SQLITE_IOERR } // Search for a TestvfsBuffer. Create a new one if required. @@ -81312,7 +76575,7 @@ func tvfsShmOpen(tls *libc.TLS, pFile uintptr) int32 { /* test_vfs.c:827:12: */ var nByte int32 = (int32((uint64(unsafe.Sizeof(TestvfsBuffer{})) + uint64(szName)) + uint64(1))) pBuffer = tcl.XTcl_Alloc(tls, uint32(nByte)) libc.Xmemset(tls, pBuffer, 0, uint64(nByte)) - (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FzFile = (pBuffer + uintptr(1)*8224) + (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FzFile = (pBuffer + 1*8224) libc.Xmemcpy(tls, (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FzFile, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, (uint64(szName + 1))) (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FpNext = (*Testvfs)(unsafe.Pointer(p)).FpBuffer (*Testvfs)(unsafe.Pointer(p)).FpBuffer = pBuffer @@ -81338,7 +76601,7 @@ func tvfsShmMap(tls *libc.TLS, pFile uintptr, iPage int32, pgsz int32, isWrite i bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData @@ -81348,12 +76611,12 @@ func tvfsShmMap(tls *libc.TLS, pFile uintptr, iPage int32, pgsz int32, isWrite i if uintptr(0) == (*TestvfsFd)(unsafe.Pointer(pFd)).FpShm { *(*int32)(unsafe.Pointer(bp /* rc */)) = tvfsShmOpen(tls, pFile) - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } } - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000020) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMMAP_MASK) != 0) { var pArg uintptr = tcl.XTcl_NewObj(tls) (*Tcl_Obj)(unsafe.Pointer(pArg)).FrefCount++ tcl.XTcl_ListObjAppendElement(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pArg, tcl.XTcl_NewIntObj(tls, iPage)) @@ -81369,14 +76632,14 @@ func tvfsShmMap(tls *libc.TLS, pFile uintptr, iPage int32, pgsz int32, isWrite i } } } - if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000020) != 0)) && (tvfsInjectIoerr(tls, p) != 0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 10 + if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMMAP_MASK) != 0)) && (tvfsInjectIoerr(tls, p) != 0) { + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_IOERR } - if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (isWrite != 0)) && !(int32(*(*uintptr)(unsafe.Pointer(((*TestvfsFd)(unsafe.Pointer(pFd)).FpShm + 16 /* &.aPage */) + uintptr(iPage)*8))) != 0) { + 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) { tvfsAllocPage(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpShm, iPage, pgsz) } - if (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) || (*(*int32)(unsafe.Pointer(bp /* rc */)) == 8) { + if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) || (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_READONLY) { *(*uintptr)(unsafe.Pointer(libc.AtomicLoadUintptr(&pp))) = *(*uintptr)(unsafe.Pointer(((*TestvfsFd)(unsafe.Pointer(pFd)).FpShm + 16 /* &.aPage */) + uintptr(iPage)*8)) } @@ -81387,7 +76650,7 @@ func tvfsShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int32) bp := tls.Alloc(100) defer tls.Free(100) - *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = SQLITE_OK var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData var nLock int32 @@ -81397,16 +76660,16 @@ func tvfsShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int32) return sqlite3.Xsqlite3OsShmLock(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, ofst, n, flags) } - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000010) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMLOCK_MASK) != 0) { sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([80]int8{})), bp+16 /* &zLock[0] */, ts+17132 /* "%d %d" */, libc.VaList(bp, ofst, n)) nLock = int32(libc.Xstrlen(tls, bp+16 /* &zLock[0] */)) - if (flags & 2) != 0 { + if (flags & SQLITE_SHM_LOCK) != 0 { libc.Xstrcpy(tls, (bp + 16 /* &zLock */ + uintptr(nLock)), ts+37516 /* " lock" */) } else { libc.Xstrcpy(tls, (bp + 16 /* &zLock */ + uintptr(nLock)), ts+37522 /* " unlock" */) } nLock = nLock + (int32(libc.Xstrlen(tls, (bp + 16 /* &zLock */ + uintptr(nLock))))) - if (flags & 4) != 0 { + if (flags & SQLITE_SHM_SHARED) != 0 { libc.Xstrcpy(tls, (bp + 16 /* &zLock */ + uintptr(nLock)), ts+37530 /* " shared" */) } else { libc.Xstrcpy(tls, (bp + 16 /* &zLock */ + uintptr(nLock)), ts+37538 /* " exclusive" */) @@ -81417,13 +76680,13 @@ func tvfsShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int32) tvfsResultCode(tls, p, bp+96 /* &rc */) } - if ((*(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000010) != 0)) && (tvfsInjectIoerr(tls, p) != 0) { - *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = 10 + if ((*(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == SQLITE_OK) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMLOCK_MASK) != 0)) && (tvfsInjectIoerr(tls, p) != 0) { + *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = SQLITE_IOERR } - if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == 0 { - var isLock int32 = (flags & 2) - var isExcl int32 = (flags & 8) + if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == SQLITE_OK { + var isLock int32 = (flags & SQLITE_SHM_LOCK) + var isExcl int32 = (flags & SQLITE_SHM_EXCLUSIVE) var mask u322 = (u322(((int32(1) << n) - 1) << ofst)) if isLock != 0 { var p2 uintptr @@ -81432,11 +76695,11 @@ func tvfsShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int32) continue } if (((*TestvfsFd)(unsafe.Pointer(p2)).Fexcllock & mask) != 0) || ((isExcl != 0) && (((*TestvfsFd)(unsafe.Pointer(p2)).Fsharedlock & mask) != 0)) { - *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = 5 + *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = SQLITE_BUSY break } } - if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == SQLITE_OK { if isExcl != 0 { *(*u322)(unsafe.Pointer(pFd + 40 /* &.excllock */)) |= (mask) } @@ -81461,7 +76724,7 @@ func tvfsShmBarrier(tls *libc.TLS, pFile uintptr) { /* test_vfs.c:1002:13: */ var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000040) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMBARRIER_MASK) != 0) { var z uintptr if (*TestvfsFd)(unsafe.Pointer(pFd)).FpShm != 0 { z = (*TestvfsBuffer)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpShm)).FzFile @@ -81481,7 +76744,7 @@ func tvfsShmUnmap(tls *libc.TLS, pFile uintptr, deleteFlag int32) int32 { /* tes bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData var pBuffer uintptr = (*TestvfsFd)(unsafe.Pointer(pFd)).FpShm @@ -81492,10 +76755,10 @@ func tvfsShmUnmap(tls *libc.TLS, pFile uintptr, deleteFlag int32) int32 { /* tes } if !(pBuffer != 0) { - return 0 + return SQLITE_OK } - if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & 0x00000080) != 0) { + if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMCLOSE_MASK) != 0) { tvfsExecTcl(tls, p, ts+34500, /* "xShmUnmap" */ tcl.XTcl_NewStringObj(tls, (*TestvfsBuffer)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpShm)).FzFile, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, uintptr(0), uintptr(0)) tvfsResultCode(tls, p, bp /* &rc */) @@ -81539,44 +76802,26 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o var p uintptr = cd *(*[10]TestvfsSubcmd)(unsafe.Pointer(bp + 96 /* aSubcmd */)) = [10]TestvfsSubcmd{ - { - FzName: ts + 37549, /* "shm" */ - FeCmd: uint32(0) /* CMD_SHM */}, - { - FzName: ts + 37553, /* "delete" */ - FeCmd: uint32(1) /* CMD_DELETE */}, - { - FzName: ts + 37560, /* "filter" */ - FeCmd: uint32(2) /* CMD_FILTER */}, - { - FzName: ts + 37567, /* "ioerr" */ - FeCmd: uint32(3) /* CMD_IOERR */}, - { - FzName: ts + 37573, /* "fullerr" */ - FeCmd: uint32(7) /* CMD_FULLERR */}, - { - FzName: ts + 37581, /* "cantopenerr" */ - FeCmd: uint32(8) /* CMD_CANTOPENERR */}, - { - FzName: ts + 37593, /* "script" */ - FeCmd: uint32(4) /* CMD_SCRIPT */}, - { - FzName: ts + 37600, /* "devchar" */ - FeCmd: uint32(5) /* CMD_DEVCHAR */}, - { - FzName: ts + 37608, /* "sectorsize" */ - FeCmd: uint32(6) /* CMD_SECTORSIZE */}, + {FzName: ts + 37549 /* "shm" */}, + {FzName: ts + 37553 /* "delete" */, FeCmd: uint32(1) /* CMD_DELETE */}, + {FzName: ts + 37560 /* "filter" */, FeCmd: uint32(2) /* CMD_FILTER */}, + {FzName: ts + 37567 /* "ioerr" */, FeCmd: uint32(3) /* CMD_IOERR */}, + {FzName: ts + 37573 /* "fullerr" */, FeCmd: uint32(7) /* CMD_FULLERR */}, + {FzName: ts + 37581 /* "cantopenerr" */, FeCmd: uint32(8) /* CMD_CANTOPENERR */}, + {FzName: ts + 37593 /* "script" */, FeCmd: uint32(4) /* CMD_SCRIPT */}, + {FzName: ts + 37600 /* "devchar" */, FeCmd: uint32(5) /* CMD_DEVCHAR */}, + {FzName: ts + 37608 /* "sectorsize" */, FeCmd: uint32(6) /* CMD_SECTORSIZE */}, {}, } // var i int32 at bp+256, 4 if objc < 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1859 /* "SUBCOMMAND ..." */) - return 1 + return TCL_ERROR } if tcl.XTcl_GetIndexFromObjStruct(tls, - interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8)), bp+96 /* &aSubcmd[0] */, int32(unsafe.Sizeof(TestvfsSubcmd{})), ts+37619 /* "subcommand" */, 0, bp+256 /* &i */) != 0 { - return 1 + interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+96 /* &aSubcmd[0] */, int32(unsafe.Sizeof(TestvfsSubcmd{})), ts+37619 /* "subcommand" */, 0, bp+256 /* &i */) != 0 { + return TCL_ERROR } tcl.XTcl_ResetResult(tls, interp) @@ -81589,17 +76834,17 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o var zName uintptr if (objc != 3) && (objc != 4) { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+37630 /* "FILE ?VALUE?" */) - return 1 + return TCL_ERROR } zName = tcl.XTcl_Alloc(tls, uint32((*sqlite3_vfs)(unsafe.Pointer((*Testvfs)(unsafe.Pointer(p)).FpParent)).FmxPathname)) rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*Testvfs)(unsafe.Pointer(p)).FpParent + 64 /* &.xFullPathname */))))(tls, - (*Testvfs)(unsafe.Pointer(p)).FpParent, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), + (*Testvfs)(unsafe.Pointer(p)).FpParent, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), (*sqlite3_vfs)(unsafe.Pointer((*Testvfs)(unsafe.Pointer(p)).FpParent)).FmxPathname, zName) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+37643, /* "failed to get fu..." */ - tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), 0)) + tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), 0)) tcl.XTcl_Free(tls, zName) - return 1 + return TCL_ERROR } for pBuffer = (*Testvfs)(unsafe.Pointer(p)).FpBuffer; pBuffer != 0; pBuffer = (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FpNext { if 0 == libc.Xstrcmp(tls, (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FzFile, zName) { @@ -81608,13 +76853,13 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o } tcl.XTcl_Free(tls, zName) if !(pBuffer != 0) { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+37669 /* "no such file: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), 0)) - return 1 + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+37669 /* "no such file: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), 0)) + return TCL_ERROR } if objc == 4 { // var n int32 at bp+260, 4 - var a uintptr = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+260 /* &n */) + var a uintptr = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+260 /* &n */) var pgsz int32 = (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).Fpgsz if pgsz == 0 { pgsz = 65536 @@ -81652,10 +76897,10 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o var mask int32 = 0 if objc != 3 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+31258 /* "LIST" */) - return 1 + return TCL_ERROR } - if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+264 /* &nElem */, bp+272 /* &apElem */) != 0 { - return 1 + if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+264 /* &nElem */, bp+272 /* &apElem */) != 0 { + return TCL_ERROR } tcl.XTcl_ResetResult(tls, interp) 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 */))++ { @@ -81669,7 +76914,7 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o } if iMethod == (int32(uint64(unsafe.Sizeof(vfsmethod)) / uint64(unsafe.Sizeof(VfsMethod{})))) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+37684 /* "unknown method: " */, zElem, 0)) - return 1 + return TCL_ERROR } } (*Testvfs)(unsafe.Pointer(p)).Fmask = mask @@ -81695,14 +76940,14 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o } (*Testvfs)(unsafe.Pointer(p)).FpScript = uintptr(0) } - tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+280 /* &nByte */) + tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+280 /* &nByte */) if *(*int32)(unsafe.Pointer(bp + 280 /* nByte */)) > 0 { - (*Testvfs)(unsafe.Pointer(p)).FpScript = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + (*Testvfs)(unsafe.Pointer(p)).FpScript = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) (*Tcl_Obj)(unsafe.Pointer((*Testvfs)(unsafe.Pointer(p)).FpScript)).FrefCount++ } } else if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12760 /* "?SCRIPT?" */) - return 1 + return TCL_ERROR } tcl.XTcl_ResetResult(tls, interp) @@ -81748,20 +76993,20 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o // var iPersist int32 at bp+288, 4 - if (0 != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+284 /* &iCnt */)) || - (0 != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+288 /* &iPersist */)) { - return 1 + if (TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+284 /* &iCnt */)) || + (TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+288 /* &iPersist */)) { + return TCL_ERROR } (*TestFaultInject)(unsafe.Pointer(pTest)).FeFault = func() int32 { if *(*int32)(unsafe.Pointer(bp + 288 /* iPersist */)) != 0 { - return 2 + return FAULT_INJECT_PERSISTENT } - return 1 + return FAULT_INJECT_TRANSIENT }() (*TestFaultInject)(unsafe.Pointer(pTest)).FiCnt = *(*int32)(unsafe.Pointer(bp + 284 /* iCnt */)) } else if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+37701 /* "?CNT PERSIST?" */) - return 1 + return TCL_ERROR } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, iRet)) break @@ -81770,7 +77015,7 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o case uint32(1) /* CMD_DELETE */ : { - tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(0)*8)))) + tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv)))) break } @@ -81778,51 +77023,21 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o case uint32(5) /* CMD_DEVCHAR */ : { *(*[16]DeviceFlag)(unsafe.Pointer(bp + 304 /* aFlag */)) = [16]DeviceFlag{ - { - FzName: ts + 37715, /* "default" */ - FiValue: -1}, - { - FzName: ts + 25381, /* "atomic" */ - FiValue: 0x00000001}, - { - FzName: ts + 25388, /* "atomic512" */ - FiValue: 0x00000002}, - { - FzName: ts + 25398, /* "atomic1k" */ - FiValue: 0x00000004}, - { - FzName: ts + 25407, /* "atomic2k" */ - FiValue: 0x00000008}, - { - FzName: ts + 25416, /* "atomic4k" */ - FiValue: 0x00000010}, - { - FzName: ts + 25425, /* "atomic8k" */ - FiValue: 0x00000020}, - { - FzName: ts + 25434, /* "atomic16k" */ - FiValue: 0x00000040}, - { - FzName: ts + 25444, /* "atomic32k" */ - FiValue: 0x00000080}, - { - FzName: ts + 25454, /* "atomic64k" */ - FiValue: 0x00000100}, - { - FzName: ts + 25464, /* "sequential" */ - FiValue: 0x00000400}, - { - FzName: ts + 25475, /* "safe_append" */ - FiValue: 0x00000200}, - { - FzName: ts + 37723, /* "undeletable_when..." */ - FiValue: 0x00000800}, - { - FzName: ts + 25487, /* "powersafe_overwr..." */ - FiValue: 0x00001000}, - { - FzName: ts + 37745, /* "immutable" */ - FiValue: 0x00002000}, + {FzName: ts + 37715 /* "default" */, FiValue: -1}, + {FzName: ts + 25381 /* "atomic" */, FiValue: SQLITE_IOCAP_ATOMIC}, + {FzName: ts + 25388 /* "atomic512" */, FiValue: SQLITE_IOCAP_ATOMIC512}, + {FzName: ts + 25398 /* "atomic1k" */, FiValue: SQLITE_IOCAP_ATOMIC1K}, + {FzName: ts + 25407 /* "atomic2k" */, FiValue: SQLITE_IOCAP_ATOMIC2K}, + {FzName: ts + 25416 /* "atomic4k" */, FiValue: SQLITE_IOCAP_ATOMIC4K}, + {FzName: ts + 25425 /* "atomic8k" */, FiValue: SQLITE_IOCAP_ATOMIC8K}, + {FzName: ts + 25434 /* "atomic16k" */, FiValue: SQLITE_IOCAP_ATOMIC16K}, + {FzName: ts + 25444 /* "atomic32k" */, FiValue: SQLITE_IOCAP_ATOMIC32K}, + {FzName: ts + 25454 /* "atomic64k" */, FiValue: SQLITE_IOCAP_ATOMIC64K}, + {FzName: ts + 25464 /* "sequential" */, FiValue: SQLITE_IOCAP_SEQUENTIAL}, + {FzName: ts + 25475 /* "safe_append" */, FiValue: SQLITE_IOCAP_SAFE_APPEND}, + {FzName: ts + 37723 /* "undeletable_when..." */, FiValue: SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN}, + {FzName: ts + 25487 /* "powersafe_overwr..." */, FiValue: SQLITE_IOCAP_POWERSAFE_OVERWRITE}, + {FzName: ts + 37745 /* "immutable" */, FiValue: SQLITE_IOCAP_IMMUTABLE}, {}, } var pRet uintptr @@ -81830,7 +77045,7 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o if objc > 3 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+37755 /* "?ATTR-LIST?" */) - return 1 + return TCL_ERROR } if objc == 3 { var j int32 @@ -81838,19 +77053,19 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o *(*uintptr)(unsafe.Pointer(bp + 296 /* flags */)) = uintptr(0) *(*int32)(unsafe.Pointer(bp + 292 /* nFlags */)) = 0 - if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+292 /* &nFlags */, bp+296 /* &flags */) != 0 { - return 1 + if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+292 /* &nFlags */, bp+296 /* &flags */) != 0 { + return TCL_ERROR } for j = 0; j < *(*int32)(unsafe.Pointer(bp + 292 /* nFlags */)); j++ { *(*int32)(unsafe.Pointer(bp + 560 /* idx */)) = 0 if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 296 /* flags */)) + uintptr(j)*8)), bp+304, /* &aFlag[0] */ int32(unsafe.Sizeof(DeviceFlag{})), ts+16852 /* "flag" */, 0, bp+560 /* &idx */) != 0 { - return 1 + return TCL_ERROR } if ((*DeviceFlag)(unsafe.Pointer(bp+304 /* &aFlag */ +uintptr(*(*int32)(unsafe.Pointer(bp + 560 /* idx */)))*16)).FiValue < 0) && (*(*int32)(unsafe.Pointer(bp + 292 /* nFlags */)) > 1) { - tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, ts+37767 /* "bad flags: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))), 0)) - return 1 + tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, ts+37767 /* "bad flags: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), 0)) + return TCL_ERROR } iNew = iNew | ((*DeviceFlag)(unsafe.Pointer(bp + 304 /* &aFlag */ + uintptr(*(*int32)(unsafe.Pointer(bp + 560 /* idx */)))*16)).FiValue) } @@ -81875,12 +77090,12 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o { if objc > 3 { tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+37779 /* "?VALUE?" */) - return 1 + return TCL_ERROR } if objc == 3 { *(*int32)(unsafe.Pointer(bp + 564 /* iNew */)) = 0 - if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8)), bp+564 /* &iNew */) != 0 { - return 1 + if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+564 /* &iNew */) != 0 { + return TCL_ERROR } (*Testvfs)(unsafe.Pointer(p)).FiSectorsize = *(*int32)(unsafe.Pointer(bp + 564 /* iNew */)) } @@ -81890,7 +77105,7 @@ func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, o } } - return 0 + return TCL_OK } type TestvfsSubcmd = struct { @@ -81906,60 +77121,24 @@ type VfsMethod = struct { } /* test_vfs.c:1175:14 */ var vfsmethod = [18]VfsMethod{ - { - FzName: ts + 37507, /* "xShmOpen" */ - Fmask: 0x00000001}, - { - FzName: ts + 34510, /* "xShmLock" */ - Fmask: 0x00000010}, - { - FzName: ts + 34519, /* "xShmBarrier" */ - Fmask: 0x00000040}, - { - FzName: ts + 34500, /* "xShmUnmap" */ - Fmask: 0x00000080}, - { - FzName: ts + 34531, /* "xShmMap" */ - Fmask: 0x00000020}, - { - FzName: ts + 26827, /* "xSync" */ - Fmask: 0x00000200}, - { - FzName: ts + 34438, /* "xDelete" */ - Fmask: 0x00000400}, - { - FzName: ts + 34346, /* "xWrite" */ - Fmask: 0x00001000}, - { - FzName: ts + 34340, /* "xRead" */ - Fmask: 0x00010000}, - { - FzName: ts + 34353, /* "xTruncate" */ - Fmask: 0x00002000}, - { - FzName: ts + 26399, /* "xOpen" */ - Fmask: 0x00000100}, - { - FzName: ts + 34333, /* "xClose" */ - Fmask: 0x00000800}, - { - FzName: ts + 34446, /* "xAccess" */ - Fmask: 0x00004000}, - { - FzName: ts + 34454, /* "xFullPathname" */ - Fmask: 0x00008000}, - { - FzName: ts + 34379, /* "xUnlock" */ - Fmask: 0x00020000}, - { - FzName: ts + 34373, /* "xLock" */ - Fmask: 0x00040000}, - { - FzName: ts + 37373, /* "xCheckReservedLo..." */ - Fmask: 0x00080000}, - { - FzName: ts + 34401, /* "xFileControl" */ - Fmask: 0x00100000}, + {FzName: ts + 37507 /* "xShmOpen" */, Fmask: TESTVFS_SHMOPEN_MASK}, + {FzName: ts + 34510 /* "xShmLock" */, Fmask: TESTVFS_SHMLOCK_MASK}, + {FzName: ts + 34519 /* "xShmBarrier" */, Fmask: TESTVFS_SHMBARRIER_MASK}, + {FzName: ts + 34500 /* "xShmUnmap" */, Fmask: TESTVFS_SHMCLOSE_MASK}, + {FzName: ts + 34531 /* "xShmMap" */, Fmask: TESTVFS_SHMMAP_MASK}, + {FzName: ts + 26827 /* "xSync" */, Fmask: TESTVFS_SYNC_MASK}, + {FzName: ts + 34438 /* "xDelete" */, Fmask: TESTVFS_DELETE_MASK}, + {FzName: ts + 34346 /* "xWrite" */, Fmask: TESTVFS_WRITE_MASK}, + {FzName: ts + 34340 /* "xRead" */, Fmask: TESTVFS_READ_MASK}, + {FzName: ts + 34353 /* "xTruncate" */, Fmask: TESTVFS_TRUNCATE_MASK}, + {FzName: ts + 26399 /* "xOpen" */, Fmask: TESTVFS_OPEN_MASK}, + {FzName: ts + 34333 /* "xClose" */, Fmask: TESTVFS_CLOSE_MASK}, + {FzName: ts + 34446 /* "xAccess" */, Fmask: TESTVFS_ACCESS_MASK}, + {FzName: ts + 34454 /* "xFullPathname" */, Fmask: TESTVFS_FULLPATHNAME_MASK}, + {FzName: ts + 34379 /* "xUnlock" */, Fmask: TESTVFS_UNLOCK_MASK}, + {FzName: ts + 34373 /* "xLock" */, Fmask: TESTVFS_LOCK_MASK}, + {FzName: ts + 37373 /* "xCheckReservedLo..." */, Fmask: TESTVFS_CKLOCK_MASK}, + {FzName: ts + 34401 /* "xFileControl" */, Fmask: TESTVFS_FCNTL_MASK}, } /* test_vfs.c:1178:9 */ func testvfs_obj_del(tls *libc.TLS, cd ClientData) { /* test_vfs.c:1389:27: */ @@ -82063,7 +77242,7 @@ __2: if !(tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+4 /* &isNoshm */) != 0) { goto __7 } - return 1 + return TCL_ERROR __7: ; if !(*(*int32)(unsafe.Pointer(bp + 4 /* isNoshm */)) != 0) { @@ -82080,7 +77259,7 @@ __5: if !(tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+8 /* &isDefault */) != 0) { goto __11 } - return 1 + return TCL_ERROR __11: ; goto __10 @@ -82091,7 +77270,7 @@ __9: if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+12 /* &szOsFile */) != 0) { goto __14 } - return 1 + return TCL_ERROR __14: ; goto __13 @@ -82102,7 +77281,7 @@ __12: if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+16 /* &mxPathname */) != 0) { goto __17 } - return 1 + return TCL_ERROR __17: ; goto __16 @@ -82113,7 +77292,7 @@ __15: if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+20 /* &iVersion */) != 0) { goto __20 } - return 1 + return TCL_ERROR __20: ; goto __19 @@ -82124,7 +77303,7 @@ __18: if !(tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+24 /* &isFullshm */) != 0) { goto __23 } - return 1 + return TCL_ERROR __23: ; if !(*(*int32)(unsafe.Pointer(bp + 24 /* isFullshm */)) != 0) { @@ -82163,7 +77342,7 @@ __4: __25: ; - zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))) + zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) nByte = (int32((uint64(unsafe.Sizeof(Testvfs{})) + uint64(int32(libc.Xstrlen(tls, zVfs)))) + uint64(1))) p = tcl.XTcl_Alloc(tls, uint32(nByte)) libc.Xmemset(tls, p, 0, uint64(nByte)) @@ -82181,7 +77360,7 @@ __25: (*Testvfs)(unsafe.Pointer(p)).FpParent = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) (*Testvfs)(unsafe.Pointer(p)).Finterp = interp - (*Testvfs)(unsafe.Pointer(p)).FzName = (p + uintptr(1)*104) + (*Testvfs)(unsafe.Pointer(p)).FzName = (p + 1*104) libc.Xmemcpy(tls, (*Testvfs)(unsafe.Pointer(p)).FzName, zVfs, (libc.Xstrlen(tls, zVfs) + uint64(1))) pVfs = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(sqlite3_vfs{}))) @@ -82200,61 +77379,26 @@ __26: (*Testvfs)(unsafe.Pointer(p)).FpVfs = pVfs (*Testvfs)(unsafe.Pointer(p)).FisNoshm = *(*int32)(unsafe.Pointer(bp + 4 /* isNoshm */)) (*Testvfs)(unsafe.Pointer(p)).FisFullshm = *(*int32)(unsafe.Pointer(bp + 24 /* isFullshm */)) - (*Testvfs)(unsafe.Pointer(p)).Fmask = 0x001FFFFF + (*Testvfs)(unsafe.Pointer(p)).Fmask = TESTVFS_ALL_MASK sqlite3.Xsqlite3_vfs_register(tls, pVfs, *(*int32)(unsafe.Pointer(bp + 8 /* isDefault */))) - return 0 + return TCL_OK bad_args: tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+37835 /* "VFSNAME ?-noshm ..." */) - return 1 + return TCL_ERROR } var tvfs_vfs = sqlite3_vfs{ - FiVersion: 3, - FszOsFile:// iVersion - 0, - FmxPathname:// szOsFile - 0, - FpNext:// mxPathname - uintptr(0), - FzName:// pNext - uintptr(0), - FpAppData:// zName - uintptr(0), - FxOpen:// pAppData - 0, - FxDelete:// xOpen - 0, - FxAccess:// xDelete - 0, - FxFullPathname:// xAccess - 0, - FxDlOpen:// xFullPathname - uintptr(0), - FxDlError:// xDlOpen - uintptr(0), - FxDlSym:// xDlError - uintptr(0), - FxDlClose:// xDlSym - uintptr(0), - FxRandomness:// xDlClose - 0, - FxSleep:// xRandomness - 0, - FxCurrentTime:// xSleep - 0, - FxGetLastError:// xCurrentTime - uintptr(0), - FxCurrentTimeInt64:// xGetLastError - uintptr(0), - FxSetSystemCall:// xCurrentTimeInt64 - uintptr(0), - FxGetSystemCall:// xSetSystemCall - uintptr(0), - FxNextSystemCall:// xGetSystemCall - uintptr(0), // xNextSystemCall + FiVersion: 3, // pAppData + FxOpen: 0, // xOpen + FxDelete: 0, // xDelete + FxAccess: 0, // xAccess + FxFullPathname: 0, // xDlClose + FxRandomness: 0, // xRandomness + FxSleep: 0, // xSleep + FxCurrentTime: 0, // xNextSystemCall } /* test_vfs.c:1440:22 */ // tclcmd: vfs_shmlock DB DBNAME (shared|exclusive) (lock|unlock) OFFSET N @@ -82265,7 +77409,7 @@ func test_vfs_shmlock(tls *libc.TLS, clientData uintptr, interp uintptr, objc in *(*[3]uintptr)(unsafe.Pointer(bp + 8 /* azArg1 */)) = [3]uintptr{ts + 37939 /* "shared" */, ts + 13480 /* "exclusive" */, uintptr(0)} *(*[3]uintptr)(unsafe.Pointer(bp + 40 /* azArg2 */)) = [3]uintptr{ts + 37946 /* "lock" */, ts + 37951 /* "unlock" */, uintptr(0)} *(*uintptr)(unsafe.Pointer(bp /* db */)) = uintptr(0) - var rc int32 = 0 + var rc int32 = SQLITE_OK var zDbname uintptr = uintptr(0) *(*int32)(unsafe.Pointer(bp + 32 /* iArg1 */)) = 0 *(*int32)(unsafe.Pointer(bp + 64 /* iArg2 */)) = 0 @@ -82276,37 +77420,37 @@ func test_vfs_shmlock(tls *libc.TLS, clientData uintptr, interp uintptr, objc in if objc != 7 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+37958 /* "DB DBNAME (share..." */) - return 1 + return TCL_ERROR } - zDbname = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - if ((((getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0) || - (tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+8 /* &azArg1[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+38010 /* "ARG" */, 0, bp+32 /* &iArg1 */) != 0)) || - (tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+40 /* &azArg2[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+38010 /* "ARG" */, 0, bp+64 /* &iArg2 */) != 0)) || - (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(5)*8)), bp+68 /* &iOffset */) != 0)) || - (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(6)*8)), bp+72 /* &n */) != 0) { - return 1 + zDbname = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + if ((((getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) || + (tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8 /* &azArg1[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+38010 /* "ARG" */, 0, bp+32 /* &iArg1 */) != 0)) || + (tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+40 /* &azArg2[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+38010 /* "ARG" */, 0, bp+64 /* &iArg2 */) != 0)) || + (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+68 /* &iOffset */) != 0)) || + (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 6*8)), bp+72 /* &n */) != 0) { + return TCL_ERROR } - sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDbname, 7, bp+80 /* &pFd */) + sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDbname, SQLITE_FCNTL_FILE_POINTER, bp+80 /* &pFd */) if *(*uintptr)(unsafe.Pointer(bp + 80 /* pFd */)) == uintptr(0) { - return 1 + return TCL_ERROR } 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 */)), ((func() int32 { if *(*int32)(unsafe.Pointer(bp + 32 /* iArg1 */)) == 0 { - return 4 + return SQLITE_SHM_SHARED } - return 8 + return SQLITE_SHM_EXCLUSIVE }()) | (func() int32 { if *(*int32)(unsafe.Pointer(bp + 64 /* iArg2 */)) == 0 { - return 2 + return SQLITE_SHM_LOCK } - return 1 + return SQLITE_SHM_UNLOCK }()))) tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 0 + return TCL_OK } func test_vfs_set_readmark(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_vfs.c:1628:26: */ @@ -82314,7 +77458,7 @@ func test_vfs_set_readmark(tls *libc.TLS, clientData uintptr, interp uintptr, ob defer tls.Free(48) *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)) = uintptr(0) - var rc int32 = 0 + var rc int32 = SQLITE_OK var zDbname uintptr = uintptr(0) *(*int32)(unsafe.Pointer(bp + 24 /* iSlot */)) = 0 *(*int32)(unsafe.Pointer(bp + 28 /* iVal */)) = -1 @@ -82326,28 +77470,28 @@ func test_vfs_set_readmark(tls *libc.TLS, clientData uintptr, interp uintptr, ob if (objc != 4) && (objc != 5) { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+38014 /* "DB DBNAME SLOT ?..." */) - return 1 + return TCL_ERROR } - zDbname = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) - if ((getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp+16 /* &db */) != 0) || - (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8)), bp+24 /* &iSlot */) != 0)) || - ((objc == 5) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8)), bp+28 /* &iVal */) != 0)) { - return 1 + zDbname = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) + if ((getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0) || + (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+24 /* &iSlot */) != 0)) || + ((objc == 5) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+28 /* &iVal */) != 0)) { + return TCL_ERROR } - sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), zDbname, 7, bp+32 /* &pFd */) + sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), zDbname, SQLITE_FCNTL_FILE_POINTER, bp+32 /* &pFd */) if *(*uintptr)(unsafe.Pointer(bp + 32 /* pFd */)) == uintptr(0) { - return 1 + return TCL_ERROR } 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 */) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 1 + return TCL_ERROR } if libc.AtomicLoadPUintptr(bp+40 /* pShm */) == uintptr(0) { tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+38037 /* "*-shm is not yet..." */, 0)) - return 1 + return TCL_ERROR } aShm = libc.AtomicLoadPUintptr(bp + 40 /* pShm */) iOff = (((12 * 2) + 1) + *(*int32)(unsafe.Pointer(bp + 24 /* iSlot */))) @@ -82357,7 +77501,7 @@ func test_vfs_set_readmark(tls *libc.TLS, clientData uintptr, interp uintptr, ob } tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, int32(*(*u322)(unsafe.Pointer(aShm + uintptr(iOff)*4))))) - return 0 + return TCL_OK } func Sqlitetestvfs_Init(tls *libc.TLS, interp uintptr) int32 { /* test_vfs.c:1681:5: */ @@ -82370,7 +77514,7 @@ func Sqlitetestvfs_Init(tls *libc.TLS, interp uintptr) int32 { /* test_vfs.c:168 tcl.XTcl_CreateObjCommand(tls, interp, ts+38081 /* "vfs_set_readmark" */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 }{test_vfs_set_readmark})), uintptr(0), uintptr(0)) - return 0 + return TCL_OK } // 2015 November 30 @@ -82425,8 +77569,8 @@ func doTestWindowStep(tls *libc.TLS, bInverse int32, ctx uintptr, nArg int32, ap pArg = tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(i)*8))), -1) tcl.XTcl_ListObjAppendElement(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, pArg) } - rc = tcl.XTcl_EvalObjEx(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, 0x020000) - if rc != 0 { + rc = tcl.XTcl_EvalObjEx(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, TCL_EVAL_GLOBAL) + if rc != TCL_OK { zResult = tcl.XTcl_GetStringResult(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp) sqlite3.Xsqlite3_result_error(tls, ctx, zResult, -1) } else { @@ -82470,9 +77614,9 @@ func doTestWindowFinalize(tls *libc.TLS, bValue int32, ctx uintptr) { /* test_wi tcl.XTcl_ListObjAppendElement(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_NewStringObj(tls, ts+488 /* "" */, -1)) } - rc = tcl.XTcl_EvalObjEx(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, 0x020000) + rc = tcl.XTcl_EvalObjEx(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, TCL_EVAL_GLOBAL) zResult = tcl.XTcl_GetStringResult(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp) - if rc != 0 { + if rc != TCL_OK { sqlite3.Xsqlite3_result_error(tls, ctx, zResult, -1) } else { sqlite3.Xsqlite3_result_text(tls, ctx, zResult, -1, libc.UintptrFromInt32(-1)) @@ -82531,19 +77675,19 @@ func test_create_window(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 7 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+38098 /* "DB NAME XSTEP XF..." */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(2)*8))) + zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) pNew = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(TestWindow{}))) libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(TestWindow{}))) - (*TestWindow)(unsafe.Pointer(pNew)).FxStep = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(3)*8))) - (*TestWindow)(unsafe.Pointer(pNew)).FxFinal = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(4)*8))) - (*TestWindow)(unsafe.Pointer(pNew)).FxValue = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(5)*8))) - (*TestWindow)(unsafe.Pointer(pNew)).FxInverse = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(6)*8))) + (*TestWindow)(unsafe.Pointer(pNew)).FxStep = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) + (*TestWindow)(unsafe.Pointer(pNew)).FxFinal = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) + (*TestWindow)(unsafe.Pointer(pNew)).FxValue = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 5*8))) + (*TestWindow)(unsafe.Pointer(pNew)).FxInverse = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 6*8))) (*TestWindow)(unsafe.Pointer(pNew)).Finterp = interp (*Tcl_Obj)(unsafe.Pointer((*TestWindow)(unsafe.Pointer(pNew)).FxStep)).FrefCount++ @@ -82551,19 +77695,19 @@ func test_create_window(tls *libc.TLS, clientData uintptr, interp uintptr, objc (*Tcl_Obj)(unsafe.Pointer((*TestWindow)(unsafe.Pointer(pNew)).FxValue)).FrefCount++ (*Tcl_Obj)(unsafe.Pointer((*TestWindow)(unsafe.Pointer(pNew)).FxInverse)).FrefCount++ - rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zName, -1, 1, pNew, + rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zName, -1, SQLITE_UTF8, pNew, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{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 { f func(*libc.TLS, uintptr, int32, uintptr) }{testWindowInverse})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowDestroy}))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } func test_create_window_misuse(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_window.c:179:26: */ @@ -82578,83 +77722,83 @@ func test_create_window_misuse(tls *libc.TLS, clientData uintptr, interp uintptr goto __1 } tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR __1: ; - if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0) { + if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) { goto __2 } - return 1 + return TCL_ERROR __2: ; - rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38135 /* "fff" */, -1, 1, uintptr(0), + rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38135 /* "fff" */, -1, SQLITE_UTF8, uintptr(0), 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 { f func(*libc.TLS, uintptr, int32, uintptr) }{testWindowInverse})), uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __3 } goto error __3: ; - rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38135 /* "fff" */, -1, 1, uintptr(0), + rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38135 /* "fff" */, -1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{testWindowStep})), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowValue})), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{testWindowInverse})), uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __4 } goto error __4: ; - rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38135 /* "fff" */, -1, 1, uintptr(0), + rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38135 /* "fff" */, -1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{testWindowStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowFinal})), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{testWindowInverse})), uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __5 } goto error __5: ; - rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38135 /* "fff" */, -1, 1, uintptr(0), + rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38135 /* "fff" */, -1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{testWindowStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowFinal})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowValue})), uintptr(0), uintptr(0)) - if !(rc != 21) { + if !(rc != SQLITE_MISUSE) { goto __6 } goto error __6: ; - return 0 + return TCL_OK error: tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, ts+38139 /* "misuse test erro..." */, -1)) - return 1 + return TCL_ERROR } // xStep for sumint(). func sumintStep(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* test_window.c:225:13: */ var pInt uintptr - if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) != 1 { + if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apArg))) != SQLITE_INTEGER { sqlite3.Xsqlite3_result_error(tls, ctx, ts+38157 /* "invalid argument" */, -1) return } pInt = sqlite3.Xsqlite3_aggregate_context(tls, ctx, int32(unsafe.Sizeof(sqlite3_int64(0)))) if pInt != 0 { - *(*sqlite3_int64)(unsafe.Pointer(pInt)) += (sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8)))) + *(*sqlite3_int64)(unsafe.Pointer(pInt)) += (sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg)))) } } @@ -82662,7 +77806,7 @@ func sumintStep(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* test func sumintInverse(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* test_window.c:246:13: */ var pInt uintptr pInt = sqlite3.Xsqlite3_aggregate_context(tls, ctx, int32(unsafe.Sizeof(sqlite3_int64(0)))) - *(*sqlite3_int64)(unsafe.Pointer(pInt)) -= (sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8)))) + *(*sqlite3_int64)(unsafe.Pointer(pInt)) -= (sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg)))) } // xFinal for sumint(). @@ -82697,13 +77841,13 @@ func test_create_sumint(tls *libc.TLS, clientData uintptr, interp uintptr, objc if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38174 /* "sumint" */, 1, 1, uintptr(0), + rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38174 /* "sumint" */, 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{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 { @@ -82711,11 +77855,11 @@ func test_create_sumint(tls *libc.TLS, clientData uintptr, interp uintptr, objc }{sumintInverse})), uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } func test_override_sum(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_window.c:305:26: */ @@ -82728,22 +77872,22 @@ func test_override_sum(tls *libc.TLS, clientData uintptr, interp uintptr, objc i if objc != 2 { tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1910 /* "DB" */) - return 1 + return TCL_ERROR } - if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(1)*8))), bp /* &db */) != 0 { - return 1 + if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { + return TCL_ERROR } - rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38181 /* "sum" */, -1, 1, uintptr(0), + rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38181 /* "sum" */, -1, SQLITE_UTF8, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{sumintStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sumintFinal}))) - if rc != 0 { + if rc != SQLITE_OK { tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) - return 1 + return TCL_ERROR } - return 0 + return TCL_OK } func Sqlitetest_window_Init(tls *libc.TLS, interp uintptr) int32 { /* test_window.c:331:5: */ @@ -82757,7 +77901,7 @@ func Sqlitetest_window_Init(tls *libc.TLS, interp uintptr) int32 { /* test_windo var c ClientData = uintptr(intptr_t(aObjCmd14[i].FclientData)) tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd14[i].FzName, aObjCmd14[i].FxProc, c, uintptr(0)) } - return 0 + return TCL_OK } var aObjCmd14 = [4]struct { @@ -82766,22 +77910,10 @@ var aObjCmd14 = [4]struct { FclientData int32 _ [4]byte }{ - { - FzName: ts + 38185, /* "sqlite3_create_w..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 38216, /* "test_create_wind..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 38251, /* "test_create_sumi..." */ - FxProc: 0, - FclientData: 0}, - { - FzName: ts + 38270, /* "test_override_su..." */ - FxProc: 0, - FclientData: 0}, + {FzName: ts + 38185 /* "sqlite3_create_w..." */, FxProc: 0}, + {FzName: ts + 38216 /* "test_create_wind..." */, FxProc: 0}, + {FzName: ts + 38251 /* "test_create_sumi..." */, FxProc: 0}, + {FzName: ts + 38270 /* "test_override_su..." */, FxProc: 0}, } /* test_window.c:336:5 */ // 2008 September 1 diff --git a/lib/sqlite_darwin_amd64.go b/lib/sqlite_darwin_amd64.go index d380a35..cdffc5e 100644 --- a/lib/sqlite_darwin_amd64.go +++ b/lib/sqlite_darwin_amd64.go @@ -175058,7 +175058,6 @@ __15: goto __14 goto __16 __16: - } // This is a helper function for rbuObjIterCacheTableInfo(). It populates diff --git a/lib/sqlite_linux_amd64.go b/lib/sqlite_linux_amd64.go index b8f80a0..8c77aef 100644 --- a/lib/sqlite_linux_amd64.go +++ b/lib/sqlite_linux_amd64.go @@ -9,12 +9,14 @@ import ( "unsafe" "modernc.org/libc" + "modernc.org/libc/sys/types" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer +var _ types.Size_t const ( ACCESSPERMS = 511 @@ -486,7 +488,6 @@ const ( FTS5_MAX_TOKEN_SIZE = 32768 FTS5_MINUS = 6 FTS5_MIN_DLIDX_SIZE = 4 - FTS5_NOINLINE = 0 FTS5_NOT = 3 FTS5_OPT_WORK_UNIT = 1000 FTS5_OR = 1 @@ -647,7 +648,6 @@ const ( JSON_FALSE = 2 JSON_INT = 3 JSON_MAX_DEPTH = 2000 - JSON_NOINLINE = 0 JSON_NULL = 0 JSON_OBJECT = 7 JSON_REAL = 4 @@ -1947,7 +1947,6 @@ const ( SQLITE_MUTEX_STATIC_VFS2 = 12 SQLITE_MUTEX_STATIC_VFS3 = 13 SQLITE_MX_JUMP_OPCODE = 62 - SQLITE_NOINLINE = 0 SQLITE_NOLFS = 22 SQLITE_NOMATCH = 1 SQLITE_NOMEM = 7 @@ -3609,8 +3608,8 @@ type X__uint128_t = struct { Fhi uint64 } /* :22:44 */ // must match modernc.org/mathutil.Int128 -type X__builtin_va_list = uintptr /* :47:14 */ -type X__float128 = float64 /* :48:21 */ +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ // ***************************************************************************** // @@ -11085,86 +11084,19 @@ var Xsqlite3CtypeMap = [256]uint8{ // The following singleton contains the global configuration for // the SQLite library. var Xsqlite3Config = Sqlite3Config{ - FbMemstat: 1, - FbCoreMutex:// bMemstat - U8(1), - FbFullMutex:// bCoreMutex - (U8(libc.Bool32(1 == 1))), - FbOpenUri:// bFullMutex - U8(0), - FbUseCis:// bOpenUri - U8(1), - FbSmallMalloc:// bUseCis - U8(0), - FbExtraSchemaChecks:// bSmallMalloc - U8(1), - FmxStrlen:// bExtraSchemaChecks - 0x7ffffffe, - FneverCorrupt:// mxStrlen - 0, - FszLookaside:// neverCorrupt - 1200, - FnLookaside: 40, - FnStmtSpill:// szLookaside, nLookaside - (64 * 1024), // nStmtSpill - Fm:// nStmtSpill - Sqlite3_mem_methods{}, // m - Fmutex:// m - Sqlite3_mutex_methods{}, // mutex - Fpcache2:// mutex - Sqlite3_pcache_methods2{}, - FpHeap:// pcache2 - uintptr(0), - FnHeap:// pHeap - 0, - FmnReq:// nHeap - 0, - FmxReq: 0, - FszMmap:// mnHeap, mxHeap - int64(0), - FmxMmap:// szMmap - int64(0x7fff0000), - FpPage:// mxMmap - uintptr(0), - FszPage:// pPage - 0, - FnPage:// szPage - 20, - FmxParserStack:// nPage - 0, - FsharedCacheEnabled:// mxParserStack - 0, - FszPma:// sharedCacheEnabled - U32(250), - FisInit:// szPma - // All the rest should always be initialized to zero - 0, - FinProgress:// isInit - 0, - FisMutexInit:// inProgress - 0, - FisMallocInit:// isMutexInit - 0, - FisPCacheInit:// isMallocInit - 0, - FnRefInitMutex:// isPCacheInit - 0, - FpInitMutex:// nRefInitMutex - uintptr(0), - FxLog:// pInitMutex - uintptr(0), - FpLogArg:// xLog - uintptr(0), - FxTestCallback:// pLogArg - uintptr(0), - FbLocaltimeFault:// xTestCallback - 0, - FiOnceResetThreshold:// bLocaltimeFault - 0x7ffffffe, - FszSorterRef:// iOnceResetThreshold - U32(0x7fffffff), - FiPrngSeed:// szSorterRef - uint32(0), // iPrngSeed + FbMemstat: SQLITE_DEFAULT_MEMSTATUS, // bMemstat + FbCoreMutex: U8(1), // bCoreMutex + FbFullMutex: (U8(libc.Bool32(SQLITE_THREADSAFE == 1))), // bOpenUri + FbUseCis: SQLITE_ALLOW_COVERING_INDEX_SCAN, // bSmallMalloc + FbExtraSchemaChecks: U8(1), // bExtraSchemaChecks + FmxStrlen: 0x7ffffffe, // neverCorrupt + FszLookaside: 1200, FnLookaside: 40, // szLookaside, nLookaside + FnStmtSpill: (64 * 1024), // szMmap + FmxMmap: SQLITE_MAX_MMAP_SIZE, // szPage + FnPage: SQLITE_DEFAULT_PCACHE_INITSZ, // sharedCacheEnabled + FszPma: SQLITE_SORTER_PMASZ, // bLocaltimeFault + FiOnceResetThreshold: 0x7ffffffe, // iOnceResetThreshold + FszSorterRef: SQLITE_DEFAULT_SORTERREF_SIZE, // iPrngSeed } /* sqlite3.c:20578:48 */ // Hash table for global functions - functions common to all @@ -11554,7 +11486,7 @@ func Xsqlite3_status64(tls *libc.TLS, op int32, pCurrent uintptr, pHighwater uin } Xsqlite3_mutex_leave(tls, pMutex) _ = pMutex // Prevent warning when SQLITE_THREADSAFE=0 - return 0 + return SQLITE_OK } func Xsqlite3_status(tls *libc.TLS, op int32, pCurrent uintptr, pHighwater uintptr, resetFlag int32) int32 { /* sqlite3.c:21477:16: */ @@ -11599,10 +11531,10 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p bp := tls.Alloc(12) defer tls.Free(12) - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) switch op { - case 0: + case SQLITE_DBSTATUS_LOOKASIDE_USED: { *(*int32)(unsafe.Pointer(pCurrent)) = Xsqlite3LookasideUsed(tls, db, pHighwater) if resetFlag != 0 { @@ -11629,17 +11561,17 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p } - case 4: + case SQLITE_DBSTATUS_LOOKASIDE_HIT: fallthrough - case 5: + case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: fallthrough - case 6: + case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: { *(*int32)(unsafe.Pointer(pCurrent)) = 0 - *(*int32)(unsafe.Pointer(pHighwater)) = int32(*(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr((op-4))*4))) + *(*int32)(unsafe.Pointer(pHighwater)) = int32(*(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr((op-SQLITE_DBSTATUS_LOOKASIDE_HIT))*4))) if resetFlag != 0 { - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr((op-4))*4)) = U32(0) + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr((op-SQLITE_DBSTATUS_LOOKASIDE_HIT))*4)) = U32(0) } break @@ -11648,9 +11580,9 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p // Return an approximation for the amount of memory currently used // by all pagers associated with the given database connection. The // highwater mark is meaningless and is returned as zero. - case 11: + case SQLITE_DBSTATUS_CACHE_USED_SHARED: fallthrough - case 1: + case SQLITE_DBSTATUS_CACHE_USED: { var totalUsed int32 = 0 var i int32 @@ -11660,7 +11592,7 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p if pBt != 0 { var pPager uintptr = Xsqlite3BtreePager(tls, pBt) var nByte int32 = Xsqlite3PagerMemUsed(tls, pPager) - if op == 11 { + if op == SQLITE_DBSTATUS_CACHE_USED_SHARED { nByte = (nByte / Xsqlite3BtreeConnectionCount(tls, pBt)) } totalUsed = totalUsed + (nByte) @@ -11676,7 +11608,7 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p // *pCurrent gets an accurate estimate of the amount of memory used // to store the schema for all databases (main, temp, and any ATTACHed // databases. *pHighwater is set to zero. - case 2: + case SQLITE_DBSTATUS_SCHEMA_USED: { var i int32 // Used to iterate through schemas *(*int32)(unsafe.Pointer(bp /* nByte */)) = 0 // Used to accumulate return value @@ -11717,7 +11649,7 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p // *pCurrent gets an accurate estimate of the amount of memory used // to store all prepared statements. // *pHighwater is set to zero. - case 3: + case SQLITE_DBSTATUS_STMT_USED: { var pVdbe uintptr // Used to iterate through VMs *(*int32)(unsafe.Pointer(bp + 4 /* nByte */)) = 0 // Used to accumulate return value @@ -11739,15 +11671,14 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p // Set *pCurrent to the total cache hits or misses encountered by all // pagers the database handle is connected to. *pHighwater is always set // to zero. - case 12: - op = (9 + 1) - /* no break */ + case SQLITE_DBSTATUS_CACHE_SPILL: + op = (SQLITE_DBSTATUS_CACHE_WRITE + 1) fallthrough - case 7: + case SQLITE_DBSTATUS_CACHE_HIT: fallthrough - case 8: + case SQLITE_DBSTATUS_CACHE_MISS: fallthrough - case 9: + case SQLITE_DBSTATUS_CACHE_WRITE: { var i int32 *(*int32)(unsafe.Pointer(bp + 8 /* nRet */)) = 0 @@ -11769,7 +11700,7 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p // Set *pCurrent to non-zero if there are unresolved deferred foreign // key constraints. Set *pCurrent to zero if all foreign key constraints // have been satisfied. The *pHighwater is always set to zero. - case 10: + case SQLITE_DBSTATUS_DEFERRED_FKS: { *(*int32)(unsafe.Pointer(pHighwater)) = 0 // IMP: R-11967-56545 *(*int32)(unsafe.Pointer(pCurrent)) = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons > int64(0)) || ((*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons > int64(0)))) @@ -11779,7 +11710,7 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p default: { - rc = 1 + rc = SQLITE_ERROR } } @@ -12242,12 +12173,12 @@ func getDigits(tls *libc.TLS, zDate uintptr, zFormat uintptr, va uintptr) int32 cnt = 0 ap = va __1: - N = (int8(int32(*(*int8)(unsafe.Pointer(zFormat + uintptr(0)))) - '0')) - min = (int8(int32(*(*int8)(unsafe.Pointer(zFormat + uintptr(1)))) - '0')) + N = (int8(int32(*(*int8)(unsafe.Pointer(zFormat))) - '0')) + min = (int8(int32(*(*int8)(unsafe.Pointer(zFormat + 1))) - '0')) val = 0 - max = aMx[(int32(*(*int8)(unsafe.Pointer(zFormat + uintptr(2)))) - 'a')] - nextC = *(*int8)(unsafe.Pointer(zFormat + uintptr(3))) + max = aMx[(int32(*(*int8)(unsafe.Pointer(zFormat + 2))) - 'a')] + nextC = *(*int8)(unsafe.Pointer(zFormat + 3)) val = 0 __4: if !(libc.PostDecInt8(&N, 1) != 0) { @@ -12398,7 +12329,7 @@ func parseHhMmSs(tls *libc.TLS, zDate uintptr, p uintptr) int32 { /* sqlite3.c:2 return 1 } zDate += uintptr(2) - if (int32(*(*int8)(unsafe.Pointer(zDate))) == '.') && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zDate + uintptr(1))))]) & 0x04) != 0) { + if (int32(*(*int8)(unsafe.Pointer(zDate))) == '.') && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zDate + 1)))]) & 0x04) != 0) { var rScale float64 = 1.0 zDate++ for (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zDate)))]) & 0x04) != 0 { @@ -12507,7 +12438,7 @@ func parseYyyyMmDd(tls *libc.TLS, zDate uintptr, p uintptr) int32 { /* sqlite3.c var neg int32 - if int32(*(*int8)(unsafe.Pointer(zDate + uintptr(0)))) == '-' { + if int32(*(*int8)(unsafe.Pointer(zDate))) == '-' { zDate++ neg = 1 } else { @@ -12596,7 +12527,7 @@ func parseDateOrTime(tls *libc.TLS, context uintptr, zDate uintptr, p uintptr) i return 0 } else if (Xsqlite3StrICmp(tls, zDate, ts+305 /* "now" */) == 0) && (Xsqlite3NotPureFunc(tls, context) != 0) { return setDateTimeToCurrent(tls, context, p) - } else if Xsqlite3AtoF(tls, zDate, bp /* &r */, Xsqlite3Strlen30(tls, zDate), uint8(1)) > 0 { + } else if Xsqlite3AtoF(tls, zDate, bp /* &r */, Xsqlite3Strlen30(tls, zDate), SQLITE_UTF8) > 0 { setRawDateNumber(tls, p, *(*float64)(unsafe.Pointer(bp /* r */))) return 0 } @@ -12719,7 +12650,7 @@ func clearYMD_HMS_TZ(tls *libc.TLS, p uintptr) { /* sqlite3.c:22189:13: */ func osLocaltime(tls *libc.TLS, t uintptr, pTm uintptr) int32 { /* sqlite3.c:22227:12: */ var rc int32 var pX uintptr - var mutex uintptr = Xsqlite3MutexAlloc(tls, 2) + var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutex) pX = libc.Xlocaltime(tls, t) if Xsqlite3Config.FbLocaltimeFault != 0 { @@ -12777,7 +12708,7 @@ func localtimeOffset(tls *libc.TLS, p uintptr, pCtx uintptr, pRc uintptr) Sqlite *(*Time_t)(unsafe.Pointer(bp + 104 /* t */)) = (Time_t(((*DateTime)(unsafe.Pointer(bp+56 /* &x */)).FiJD / int64(1000)) - (int64(21086676) * int64(10000)))) if osLocaltime(tls, bp+104 /* &t */, bp /* &sLocal */) != 0 { Xsqlite3_result_error(tls, pCtx, ts+309 /* "local time unava..." */, -1) - *(*int32)(unsafe.Pointer(pRc)) = 1 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_ERROR return int64(0) } (*DateTime)(unsafe.Pointer(bp + 112 /* &y */)).FY = ((*tm)(unsafe.Pointer(bp /* &sLocal */)).Ftm_year + 1900) @@ -12793,7 +12724,7 @@ func localtimeOffset(tls *libc.TLS, p uintptr, pCtx uintptr, pRc uintptr) Sqlite (*DateTime)(unsafe.Pointer(bp + 112 /* &y */)).FvalidTZ = int8(0) (*DateTime)(unsafe.Pointer(bp + 112 /* &y */)).FisError = int8(0) computeJD(tls, bp+112 /* &y */) - *(*int32)(unsafe.Pointer(pRc)) = 0 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_OK return ((*DateTime)(unsafe.Pointer(bp+112 /* &y */)).FiJD - (*DateTime)(unsafe.Pointer(bp+56 /* &x */)).FiJD) } @@ -12811,42 +12742,12 @@ var aXformType = [6]struct { FrLimit float64 FrXform float64 }{ - { - FeType: U8(0), - FnName: U8(6), - FzName: ts + 332, /* "second" */ - FrLimit: 464269060800.0, - FrXform: 1000.0}, - { - FeType: U8(0), - FnName: U8(6), - FzName: ts + 339, /* "minute" */ - FrLimit: 7737817680.0, - FrXform: 60000.0}, - { - FeType: U8(0), - FnName: U8(4), - FzName: ts + 346, /* "hour" */ - FrLimit: 128963628.0, - FrXform: 3600000.0}, - { - FeType: U8(0), - FnName: U8(3), - FzName: ts + 351, /* "day" */ - FrLimit: 5373485.0, - FrXform: 86400000.0}, - { - FeType: U8(1), - FnName: U8(5), - FzName: ts + 355, /* "month" */ - FrLimit: 176546.0, - FrXform: 2592000000.0}, - { - FeType: U8(2), - FnName: U8(4), - FzName: ts + 361, /* "year" */ - FrLimit: 14713.0, - FrXform: 31536000000.0}, + {FnName: U8(6), FzName: ts + 332 /* "second" */, FrLimit: 464269060800.0, FrXform: 1000.0}, + {FnName: U8(6), FzName: ts + 339 /* "minute" */, FrLimit: 7737817680.0, FrXform: 60000.0}, + {FnName: U8(4), FzName: ts + 346 /* "hour" */, FrLimit: 128963628.0, FrXform: 3600000.0}, + {FnName: U8(3), FzName: ts + 351 /* "day" */, FrLimit: 5373485.0, FrXform: 86400000.0}, + {FeType: U8(1), FnName: U8(5), FzName: ts + 355 /* "month" */, FrLimit: 176546.0, FrXform: 2592000000.0}, + {FeType: U8(2), FnName: U8(4), FzName: ts + 361 /* "year" */, FrLimit: 14713.0, FrXform: 31536000000.0}, } /* sqlite3.c:22337:3 */ // Process a modifier to a date-time stamp. The modifiers are @@ -12878,7 +12779,7 @@ func parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr) i *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 // var r float64 at bp+8, 8 - switch int32(Xsqlite3UpperToLower[U8(*(*int8)(unsafe.Pointer(z + uintptr(0))))]) { + switch int32(Xsqlite3UpperToLower[U8(*(*int8)(unsafe.Pointer(z)))]) { case 'l': { // localtime @@ -12913,14 +12814,14 @@ func parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr) i var c1 Sqlite3_int64 computeJD(tls, p) c1 = localtimeOffset(tls, p, pCtx, bp /* &rc */) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*Sqlite3_int64)(unsafe.Pointer(p /* &.iJD */)) -= (c1) clearYMD_HMS_TZ(tls, p) *(*Sqlite3_int64)(unsafe.Pointer(p /* &.iJD */)) += (c1 - localtimeOffset(tls, p, pCtx, bp /* &rc */)) } (*DateTime)(unsafe.Pointer(p)).FtzSet = int8(1) } else { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK } } break @@ -12934,7 +12835,7 @@ func parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr) i // weekday N where 0==Sunday, 1==Monday, and so forth. If the // date is already on the appropriate weekday, this is a no-op. if ((((Xsqlite3_strnicmp(tls, z, ts+390 /* "weekday " */, 8) == 0) && - (Xsqlite3AtoF(tls, (z+uintptr(8)), bp+8 /* &r */, Xsqlite3Strlen30(tls, (z+uintptr(8))), uint8(1)) > 0)) && + (Xsqlite3AtoF(tls, (z+8), bp+8 /* &r */, Xsqlite3Strlen30(tls, (z+8)), SQLITE_UTF8) > 0)) && ((float64(libc.AssignInt32(&n, int32(*(*float64)(unsafe.Pointer(bp + 8 /* r */)))))) == *(*float64)(unsafe.Pointer(bp + 8 /* r */)))) && (n >= 0)) && (*(*float64)(unsafe.Pointer(bp + 8 /* r */)) < float64(7)) { var Z Sqlite3_int64 computeYMD_HMS(tls, p) @@ -13013,7 +12914,7 @@ func parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr) i var i int32 for n = 1; ((*(*int8)(unsafe.Pointer(z + uintptr(n))) != 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr(n)))) != ':')) && !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr(n))))]) & 0x01) != 0); n++ { } - if Xsqlite3AtoF(tls, z, bp+8 /* &r */, n, uint8(1)) <= 0 { + if Xsqlite3AtoF(tls, z, bp+8 /* &r */, n, SQLITE_UTF8) <= 0 { *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 break } @@ -13037,7 +12938,7 @@ func parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr) i *(*Sqlite3_int64)(unsafe.Pointer(bp + 16 /* &tx */ /* &.iJD */)) -= (int64(43200000)) day = ((*DateTime)(unsafe.Pointer(bp+16 /* &tx */)).FiJD / int64(86400000)) *(*Sqlite3_int64)(unsafe.Pointer(bp + 16 /* &tx */ /* &.iJD */)) -= (day * int64(86400000)) - if int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '-' { + if int32(*(*int8)(unsafe.Pointer(z))) == '-' { (*DateTime)(unsafe.Pointer(bp + 16 /* &tx */)).FiJD = -(*DateTime)(unsafe.Pointer(bp + 16 /* &tx */)).FiJD } computeJD(tls, p) @@ -13143,11 +13044,11 @@ func isDate(tls *libc.TLS, context uintptr, argc int32, argv uintptr, p uintptr) if argc == 0 { return setDateTimeToCurrent(tls, context, p) } - if ((libc.AssignInt32(&eType, Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) == 2) || - (eType == 1) { - setRawDateNumber(tls, p, Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + if ((libc.AssignInt32(&eType, Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))))) == SQLITE_FLOAT) || + (eType == SQLITE_INTEGER) { + setRawDateNumber(tls, p, Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))) } else { - z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if !(z != 0) || (parseDateOrTime(tls, context, z, p) != 0) { return 1 } @@ -13273,7 +13174,7 @@ func strftimeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* if argc == 0 { return } - zFmt = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zFmt = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if (zFmt == uintptr(0)) || (isDate(tls, context, (argc-1), (argv+uintptr(1)*8), bp+80 /* &x */) != 0) { return } @@ -13342,7 +13243,7 @@ __3: if n < U64(unsafe.Sizeof([100]int8{})) { z = bp + 128 /* &zBuf[0] */ - } else if n > U64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) { + } else if n > U64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) { Xsqlite3_result_error_toobig(tls, context) return } else { @@ -13504,87 +13405,14 @@ func Xsqlite3RegisterDateTimeFunctions(tls *libc.TLS) { /* sqlite3.c:22945:21: * } var aDateTimeFuncs = [8]FuncDef{ - { - FnArg: int8(-1), - FfuncFlags: (U32((0x2000 | 1) | 0x0800)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 497 /* "julianday" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x2000 | 1) | 0x0800)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 507 /* "date" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x2000 | 1) | 0x0800)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 512 /* "time" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x2000 | 1) | 0x0800)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 517 /* "datetime" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x2000 | 1) | 0x0800)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 526 /* "strftime" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 535 /* "current_time" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 548 /* "current_timestam..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 566 /* "current_date" */, Fu: struct{ FpHash uintptr }{}}, -} /* sqlite3.c:22946:18 */ + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_SLOCHNG | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FpUserData: 0, FxSFunc: 0, FzName: ts + 497 /* "julianday" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_SLOCHNG | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FpUserData: 0, FxSFunc: 0, FzName: ts + 507 /* "date" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_SLOCHNG | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FpUserData: 0, FxSFunc: 0, FzName: ts + 512 /* "time" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_SLOCHNG | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FpUserData: 0, FxSFunc: 0, FzName: ts + 517 /* "datetime" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_SLOCHNG | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FpUserData: 0, FxSFunc: 0, FzName: ts + 526 /* "strftime" */}, + {FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 535 /* "current_time" */}, + {FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 548 /* "current_timestam..." */}, + {FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 566 /* "current_date" */}} /* sqlite3.c:22946:18 */ //************* End of date.c *********************************************** //************* Begin file os.c ********************************************* @@ -13662,7 +13490,7 @@ func Xsqlite3OsSync(tls *libc.TLS, id uintptr, flags int32) int32 { /* sqlite3.c if flags != 0 { return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods + 40 /* &.xSync */))))(tls, id, flags) } - return 0 + return SQLITE_OK } func Xsqlite3OsFileSize(tls *libc.TLS, id uintptr, pSize uintptr) int32 { /* sqlite3.c:23069:20: */ @@ -13692,7 +13520,7 @@ func Xsqlite3OsCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int // routine has no return value since the return value would be meaningless. func Xsqlite3OsFileControl(tls *libc.TLS, id uintptr, op int32, pArg uintptr) int32 { /* sqlite3.c:23093:20: */ if (*Sqlite3_file)(unsafe.Pointer(id)).FpMethods == uintptr(0) { - return 12 + return SQLITE_NOTFOUND } return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods + 80 /* &.xFileControl */))))(tls, id, op, pArg) } @@ -13709,7 +13537,7 @@ func Xsqlite3OsSectorSize(tls *libc.TLS, id uintptr) int32 { /* sqlite3.c:23118: if xSectorSize != 0 { return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&xSectorSize)))(tls, id) } - return 4096 + return SQLITE_DEFAULT_SECTOR_SIZE }() } @@ -13770,7 +13598,7 @@ func Xsqlite3OsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, p func Xsqlite3OsFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nPathOut int32, zPathOut uintptr) int32 { /* sqlite3.c:23202:20: */ - *(*int8)(unsafe.Pointer(zPathOut + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(zPathOut)) = int8(0) return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pVfs + 64 /* &.xFullPathname */))))(tls, pVfs, zPath, nPathOut, zPathOut) } @@ -13797,7 +13625,7 @@ func Xsqlite3OsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uint nByte = int32(unsafe.Sizeof(uint32(0))) } libc.Xmemcpy(tls, zBufOut, (uintptr(unsafe.Pointer(&Xsqlite3Config)) + 412 /* &.iPrngSeed */), uint64(nByte)) - return 0 + return SQLITE_OK } else { return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pVfs + 104 /* &.xRandomness */))))(tls, pVfs, nByte, zBufOut) } @@ -13843,13 +13671,13 @@ func Xsqlite3OsOpenMalloc(tls *libc.TLS, pVfs uintptr, zFile uintptr, ppFile uin pFile = Xsqlite3MallocZero(tls, uint64((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)) if pFile != 0 { rc = Xsqlite3OsOpen(tls, pVfs, zFile, pFile, flags, pOutFlags) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_free(tls, pFile) } else { *(*uintptr)(unsafe.Pointer(ppFile)) = pFile } } else { - rc = 7 + rc = SQLITE_NOMEM } return rc } @@ -13867,7 +13695,7 @@ func Xsqlite3OsCloseFree(tls *libc.TLS, pFile uintptr) { /* sqlite3.c:23283:21: func Xsqlite3OsInit(tls *libc.TLS) int32 { /* sqlite3.c:23295:20: */ var p uintptr = Xsqlite3_malloc(tls, 10) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } Xsqlite3_free(tls, p) return Xsqlite3_os_init(tls) @@ -13885,7 +13713,7 @@ func Xsqlite3_vfs_find(tls *libc.TLS, zVfs uintptr) uintptr { /* sqlite3.c:23312 if rc != 0 { return uintptr(0) } - mutex = Xsqlite3MutexAlloc(tls, 2) + mutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutex) for pVfs = vfsList; pVfs != 0; pVfs = (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext { if zVfs == uintptr(0) { @@ -13927,7 +13755,7 @@ func Xsqlite3_vfs_register(tls *libc.TLS, pVfs uintptr, makeDflt int32) int32 { return rc } - mutex = Xsqlite3MutexAlloc(tls, 2) + mutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutex) vfsUnlink(tls, pVfs) if (makeDflt != 0) || (vfsList == uintptr(0)) { @@ -13939,7 +13767,7 @@ func Xsqlite3_vfs_register(tls *libc.TLS, pVfs uintptr, makeDflt int32) int32 { } Xsqlite3_mutex_leave(tls, mutex) - return 0 + return SQLITE_OK } // Unregister a VFS so that it is no longer accessible. @@ -13949,11 +13777,11 @@ func Xsqlite3_vfs_unregister(tls *libc.TLS, pVfs uintptr) int32 { /* sqlite3.c:2 if rc != 0 { return rc } - mutex = Xsqlite3MutexAlloc(tls, 2) + mutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutex) vfsUnlink(tls, pVfs) Xsqlite3_mutex_leave(tls, mutex) - return 0 + return SQLITE_OK } //************* End of os.c ************************************************* @@ -14152,11 +13980,11 @@ func sqlite3MemMalloc(tls *libc.TLS, nByte int32) uintptr { /* sqlite3.c:23680:1 p = libc.Xmalloc(tls, (uint64(nByte + 8))) if p != 0 { - *(*Sqlite3_int64)(unsafe.Pointer(p + uintptr(0)*8)) = Sqlite3_int64(nByte) + *(*Sqlite3_int64)(unsafe.Pointer(p)) = Sqlite3_int64(nByte) p += 8 } else { - Xsqlite3_log(tls, 7, ts+579 /* "failed to alloca..." */, libc.VaList(bp, nByte)) + Xsqlite3_log(tls, SQLITE_NOMEM, ts+579 /* "failed to alloca..." */, libc.VaList(bp, nByte)) } return p } @@ -14181,7 +14009,7 @@ func sqlite3MemSize(tls *libc.TLS, pPrior uintptr) int32 { /* sqlite3.c:23729:12 p = pPrior p -= 8 - return int32(*(*Sqlite3_int64)(unsafe.Pointer(p + uintptr(0)*8))) + return int32(*(*Sqlite3_int64)(unsafe.Pointer(p))) } // Like realloc(). Resize an allocation previously obtained from @@ -14202,11 +14030,11 @@ func sqlite3MemRealloc(tls *libc.TLS, pPrior uintptr, nByte int32) uintptr { /* p -= 8 p = libc.Xrealloc(tls, p, (uint64(nByte + 8))) if p != 0 { - *(*Sqlite3_int64)(unsafe.Pointer(p + uintptr(0)*8)) = Sqlite3_int64(nByte) + *(*Sqlite3_int64)(unsafe.Pointer(p)) = Sqlite3_int64(nByte) p += 8 } else { - Xsqlite3_log(tls, 7, + Xsqlite3_log(tls, SQLITE_NOMEM, ts+617, /* "failed memory re..." */ libc.VaList(bp, sqlite3MemSize(tls, pPrior), nByte)) } @@ -14215,13 +14043,13 @@ func sqlite3MemRealloc(tls *libc.TLS, pPrior uintptr, nByte int32) uintptr { /* // Round up a request size to the next valid allocation size. func sqlite3MemRoundup(tls *libc.TLS, n int32) int32 { /* sqlite3.c:23784:12: */ - return (((n) + 7) & ^libc.Int32(7)) + return (((n) + 7) & libc.CplInt32(7)) } // Initialize this module. func sqlite3MemInit(tls *libc.TLS, NotUsed uintptr) int32 { /* sqlite3.c:23791:12: */ _ = NotUsed - return 0 + return SQLITE_OK } // Deinitialize this module. @@ -14238,7 +14066,7 @@ func Xsqlite3MemSetDefault(tls *libc.TLS) { /* sqlite3.c:23829:21: */ bp := tls.Alloc(8) defer tls.Free(8) - Xsqlite3_config(tls, 4, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultMethods)))) + Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultMethods)))) } var defaultMethods = Sqlite3_mem_methods{ @@ -14249,7 +14077,6 @@ var defaultMethods = Sqlite3_mem_methods{ FxRoundup: 0, FxInit: 0, FxShutdown: 0, - FpAppData: uintptr(0), } /* sqlite3.c:23830:36 */ //************* End of mem1.c *********************************************** @@ -14385,7 +14212,7 @@ var defaultMethods = Sqlite3_mem_methods{ // Initialize the mutex system. func Xsqlite3MutexInit(tls *libc.TLS) int32 { /* sqlite3.c:25865:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if !(int32(Xsqlite3Config.Fmutex.FxMutexAlloc) != 0) { // If the xMutexAlloc method has not been set, then the user did not // install a mutex implementation via sqlite3_config() prior to @@ -14419,7 +14246,7 @@ func Xsqlite3MutexInit(tls *libc.TLS) int32 { /* sqlite3.c:25865:20: */ // Shutdown the mutex system. This call frees resources allocated by // sqlite3MutexInit(). func Xsqlite3MutexEnd(tls *libc.TLS) int32 { /* sqlite3.c:25911:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if Xsqlite3Config.Fmutex.FxMutexEnd != 0 { rc = (*(*func(*libc.TLS) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 96 /* &.mutex */ + 8 /* &.xMutexEnd */))))(tls) } @@ -14429,10 +14256,10 @@ func Xsqlite3MutexEnd(tls *libc.TLS) int32 { /* sqlite3.c:25911:20: */ // Retrieve a pointer to a static mutex or allocate a new dynamic one. func Xsqlite3_mutex_alloc(tls *libc.TLS, id int32) uintptr { /* sqlite3.c:25927:26: */ - if (id <= 1) && (Xsqlite3_initialize(tls) != 0) { + if (id <= SQLITE_MUTEX_RECURSIVE) && (Xsqlite3_initialize(tls) != 0) { return uintptr(0) } - if (id > 1) && (Xsqlite3MutexInit(tls) != 0) { + if (id > SQLITE_MUTEX_RECURSIVE) && (Xsqlite3MutexInit(tls) != 0) { return uintptr(0) } @@ -14467,7 +14294,7 @@ func Xsqlite3_mutex_enter(tls *libc.TLS, p uintptr) { /* sqlite3.c:25959:17: */ // Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another // thread holds the mutex and it cannot be obtained, return SQLITE_BUSY. func Xsqlite3_mutex_try(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:25970:16: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if p != 0 { return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 96 /* &.mutex */ + 40 /* &.xMutexTry */))))(tls, p) @@ -14519,11 +14346,11 @@ func Xsqlite3_mutex_leave(tls *libc.TLS, p uintptr) { /* sqlite3.c:25985:17: */ // // This routines provide no mutual exclusion or error checking. func noopMutexInit(tls *libc.TLS) int32 { /* sqlite3.c:26048:12: */ - return 0 + return SQLITE_OK } func noopMutexEnd(tls *libc.TLS) int32 { /* sqlite3.c:26049:12: */ - return 0 + return SQLITE_OK } func noopMutexAlloc(tls *libc.TLS, id int32) uintptr { /* sqlite3.c:26050:22: */ @@ -14543,7 +14370,7 @@ func noopMutexEnter(tls *libc.TLS, p uintptr) { /* sqlite3.c:26055:13: */ func noopMutexTry(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:26056:12: */ _ = p - return 0 + return SQLITE_OK } func noopMutexLeave(tls *libc.TLS, p uintptr) { /* sqlite3.c:26060:13: */ @@ -14557,15 +14384,13 @@ func Xsqlite3NoopMutex(tls *libc.TLS) uintptr { /* sqlite3.c:26062:44: */ } var sMutex = Sqlite3_mutex_methods{ - FxMutexInit: 0, - FxMutexEnd: 0, - FxMutexAlloc: 0, - FxMutexFree: 0, - FxMutexEnter: 0, - FxMutexTry: 0, - FxMutexLeave: 0, - FxMutexHeld: uintptr(0), - FxMutexNotheld: uintptr(0), + FxMutexInit: 0, + FxMutexEnd: 0, + FxMutexAlloc: 0, + FxMutexFree: 0, + FxMutexEnter: 0, + FxMutexTry: 0, + FxMutexLeave: 0, } /* sqlite3.c:26063:38 */ // If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation @@ -14665,7 +14490,7 @@ func Xsqlite3_memory_alarm(tls *libc.TLS, xCallback uintptr, pArg uintptr, iThre _ = xCallback _ = pArg _ = iThreshold - return 0 + return SQLITE_OK } // Set the soft heap-size limit for the library. An argument of @@ -14695,7 +14520,7 @@ func Xsqlite3_soft_heap_limit64(tls *libc.TLS, n Sqlite3_int64) Sqlite3_int64 { n = mem0.FhardLimit } mem0.FalarmThreshold = n - nUsed = Xsqlite3StatusValue(tls, 0) + nUsed = Xsqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED) libc.AtomicStoreNInt32((uintptr(unsafe.Pointer(&mem0)) + 24 /* &.nearlyFull */), int32((libc.Bool32((n > int64(0)) && (n <= nUsed)))), 0) Xsqlite3_mutex_leave(tls, mem0.Fmutex) excess = (Xsqlite3_memory_used(tls) - n) @@ -14747,14 +14572,14 @@ func Xsqlite3MallocInit(tls *libc.TLS) int32 { /* sqlite3.c:27476:20: */ Xsqlite3MemSetDefault(tls) } libc.Xmemset(tls, uintptr(unsafe.Pointer(&mem0)), 0, uint64(unsafe.Sizeof(mem0))) - mem0.Fmutex = Xsqlite3MutexAlloc(tls, 3) + mem0.Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MEM) if ((Xsqlite3Config.FpPage == uintptr(0)) || (Xsqlite3Config.FszPage < 512)) || (Xsqlite3Config.FnPage <= 0) { Xsqlite3Config.FpPage = uintptr(0) Xsqlite3Config.FszPage = 0 } rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 32 /* &.m */ + 40 /* &.xInit */))))(tls, Xsqlite3Config.Fm.FpAppData) - if rc != 0 { + if rc != SQLITE_OK { libc.Xmemset(tls, uintptr(unsafe.Pointer(&mem0)), 0, uint64(unsafe.Sizeof(mem0))) } return rc @@ -14784,7 +14609,7 @@ func Xsqlite3_memory_used(tls *libc.TLS) Sqlite3_int64 { /* sqlite3.c:27515:26: // var mx Sqlite3_int64 at bp+8, 8 - Xsqlite3_status64(tls, 0, bp /* &res */, bp+8 /* &mx */, 0) + Xsqlite3_status64(tls, SQLITE_STATUS_MEMORY_USED, bp /* &res */, bp+8 /* &mx */, 0) return *(*Sqlite3_int64)(unsafe.Pointer(bp /* res */)) } @@ -14799,7 +14624,7 @@ func Xsqlite3_memory_highwater(tls *libc.TLS, resetFlag int32) Sqlite3_int64 { / // var mx Sqlite3_int64 at bp+8, 8 - Xsqlite3_status64(tls, 0, bp /* &res */, bp+8 /* &mx */, resetFlag) + Xsqlite3_status64(tls, SQLITE_STATUS_MEMORY_USED, bp /* &res */, bp+8 /* &mx */, resetFlag) return *(*Sqlite3_int64)(unsafe.Pointer(bp + 8 /* mx */)) } @@ -14826,14 +14651,14 @@ func mallocWithAlarm(tls *libc.TLS, n int32, pp uintptr) { /* sqlite3.c:27546:13 // following xRoundup() call. nFull = (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 32 /* &.m */ + 32 /* &.xRoundup */))))(tls, n) - Xsqlite3StatusHighwater(tls, 5, n) + Xsqlite3StatusHighwater(tls, SQLITE_STATUS_MALLOC_SIZE, n) if mem0.FalarmThreshold > int64(0) { - var nUsed Sqlite3_int64 = Xsqlite3StatusValue(tls, 0) + var nUsed Sqlite3_int64 = Xsqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED) if nUsed >= (mem0.FalarmThreshold - Sqlite3_int64(nFull)) { libc.AtomicStoreNInt32((uintptr(unsafe.Pointer(&mem0)) + 24 /* &.nearlyFull */), int32(1), 0) sqlite3MallocAlarm(tls, nFull) if mem0.FhardLimit != 0 { - nUsed = Xsqlite3StatusValue(tls, 0) + nUsed = Xsqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED) if nUsed >= (mem0.FhardLimit - Sqlite3_int64(nFull)) { *(*uintptr)(unsafe.Pointer(pp)) = uintptr(0) return @@ -14850,8 +14675,8 @@ func mallocWithAlarm(tls *libc.TLS, n int32, pp uintptr) { /* sqlite3.c:27546:13 } if p != 0 { nFull = Xsqlite3MallocSize(tls, p) - Xsqlite3StatusUp(tls, 0, nFull) - Xsqlite3StatusUp(tls, 9, 1) + Xsqlite3StatusUp(tls, SQLITE_STATUS_MEMORY_USED, nFull) + Xsqlite3StatusUp(tls, SQLITE_STATUS_MALLOC_COUNT, 1) } *(*uintptr)(unsafe.Pointer(pp)) = p } @@ -14918,7 +14743,7 @@ func lookasideMallocSize(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite if p < (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle { return int32((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) } - return 128 + return LOOKASIDE_SMALL } func Xsqlite3DbMallocSize(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:27659:20: */ @@ -14927,7 +14752,7 @@ func Xsqlite3DbMallocSize(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlit if (Uptr(p)) < Uptr(((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd)) { if (Uptr(p)) >= Uptr(((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle)) { - return 128 + return LOOKASIDE_SMALL } if (Uptr(p)) >= Uptr(((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart)) { @@ -14954,8 +14779,8 @@ func Xsqlite3_free(tls *libc.TLS, p uintptr) { /* sqlite3.c:27697:17: */ if Xsqlite3Config.FbMemstat != 0 { Xsqlite3_mutex_enter(tls, mem0.Fmutex) - Xsqlite3StatusDown(tls, 0, Xsqlite3MallocSize(tls, p)) - Xsqlite3StatusDown(tls, 9, 1) + Xsqlite3StatusDown(tls, SQLITE_STATUS_MEMORY_USED, Xsqlite3MallocSize(tls, p)) + Xsqlite3StatusDown(tls, SQLITE_STATUS_MALLOC_COUNT, 1) (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 32 /* &.m */ + 8 /* &.xFree */))))(tls, p) Xsqlite3_mutex_leave(tls, mem0.Fmutex) } else { @@ -15032,9 +14857,9 @@ func Xsqlite3Realloc(tls *libc.TLS, pOld uintptr, nBytes U64) uintptr { /* sqlit pNew = pOld } else if Xsqlite3Config.FbMemstat != 0 { Xsqlite3_mutex_enter(tls, mem0.Fmutex) - Xsqlite3StatusHighwater(tls, 5, int32(nBytes)) + Xsqlite3StatusHighwater(tls, SQLITE_STATUS_MALLOC_SIZE, int32(nBytes)) nDiff = (nNew - nOld) - if (nDiff > 0) && (Xsqlite3StatusValue(tls, 0) >= (mem0.FalarmThreshold - Sqlite3_int64(nDiff))) { + if (nDiff > 0) && (Xsqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED) >= (mem0.FalarmThreshold - Sqlite3_int64(nDiff))) { sqlite3MallocAlarm(tls, nDiff) } pNew = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 32 /* &.m */ + 16 /* &.xRealloc */))))(tls, pOld, nNew) @@ -15044,7 +14869,7 @@ func Xsqlite3Realloc(tls *libc.TLS, pOld uintptr, nBytes U64) uintptr { /* sqlit } if pNew != 0 { nNew = Xsqlite3MallocSize(tls, pNew) - Xsqlite3StatusUp(tls, 0, (nNew - nOld)) + Xsqlite3StatusUp(tls, SQLITE_STATUS_MEMORY_USED, (nNew - nOld)) } Xsqlite3_mutex_leave(tls, mem0.Fmutex) } else { @@ -15142,33 +14967,33 @@ func Xsqlite3DbMallocRawNN(tls *libc.TLS, db uintptr, n U64) uintptr { /* sqlite if n > U64((*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz) { if !(int32((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable) != 0) { - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr(1)*4))++ + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + 1*4))++ } else if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { return uintptr(0) } return dbMallocRawFinish(tls, db, n) } - if n <= uint64(128) { + if n <= LOOKASIDE_SMALL { if (libc.AssignUintptr(&pBuf, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree)) != uintptr(0) { (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = (*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr(0)*4))++ + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */)))++ return pBuf } else if (libc.AssignUintptr(&pBuf, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit)) != uintptr(0) { (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = (*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr(0)*4))++ + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */)))++ return pBuf } } if (libc.AssignUintptr(&pBuf, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree)) != uintptr(0) { (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree = (*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr(0)*4))++ + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */)))++ return pBuf } else if (libc.AssignUintptr(&pBuf, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpInit)) != uintptr(0) { (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpInit = (*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr(0)*4))++ + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */)))++ return pBuf } else { - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr(2)*4))++ + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + 2*4))++ } return dbMallocRawFinish(tls, db, n) } @@ -15183,7 +15008,7 @@ func Xsqlite3DbRealloc(tls *libc.TLS, db uintptr, p uintptr, n U64) uintptr { /* if (Uptr(p)) < Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd) { if (Uptr(p)) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle) { - if n <= uint64(128) { + if n <= LOOKASIDE_SMALL { return p } } else if (Uptr(p)) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) { @@ -15267,7 +15092,7 @@ func Xsqlite3DbStrNDup(tls *libc.TLS, db uintptr, z uintptr, n U64) uintptr { /* // sqlite3DbMalloc(). Omit leading and trailing whitespace. func Xsqlite3DbSpanDup(tls *libc.TLS, db uintptr, zStart uintptr, zEnd uintptr) uintptr { /* sqlite3.c:28054:21: */ var n int32 - for (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zStart + uintptr(0))))]) & 0x01) != 0 { + for (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zStart)))]) & 0x01) != 0 { zStart++ } n = (int32((int64(zEnd) - int64(zStart)) / 1)) @@ -15296,7 +15121,7 @@ func Xsqlite3OomFault(tls *libc.TLS, db uintptr) { /* sqlite3.c:28076:21: */ (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable++ (*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0) if (*Sqlite3)(unsafe.Pointer(db)).FpParse != 0 { - (*Parse)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpParse)).Frc = 7 + (*Parse)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpParse)).Frc = SQLITE_NOMEM } } } @@ -15324,8 +15149,8 @@ func Xsqlite3OomClear(tls *libc.TLS, db uintptr) { /* sqlite3.c:28096:21: */ // Take actions at the end of an API call to indicate an OOM error func apiOomError(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:28108:28: */ Xsqlite3OomClear(tls, db) - Xsqlite3Error(tls, db, 7) - return 7 + Xsqlite3Error(tls, db, SQLITE_NOMEM) + return SQLITE_NOMEM } // This function must be called before exiting any API function (i.e. @@ -15343,7 +15168,7 @@ func Xsqlite3ApiExit(tls *libc.TLS, db uintptr, rc int32) int32 { /* sqlite3.c:2 // Otherwise the read (and possible write) of db->mallocFailed // is unsafe, as is the call to sqlite3Error(). - if ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) || (rc == (10 | (int32(12) << 8))) { + if ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) || (rc == (SQLITE_IOERR | (int32(12) << 8))) { return apiOomError(tls, db) } return (rc & (*Sqlite3)(unsafe.Pointer(db)).FerrMask) @@ -15391,169 +15216,31 @@ type Et_info = et_info /* sqlite3.c:28197:3 */ var aDigits = *(*[33]int8)(unsafe.Pointer(ts + 653 /* "0123456789ABCDEF..." */)) /* sqlite3.c:28210:19 */ var aPrefix = *(*[7]int8)(unsafe.Pointer(ts + 686 /* "-x0\x00X0" */)) /* sqlite3.c:28211:19 */ var fmtinfo = [23]Et_info{ - { - Ffmttype: int8('d'), - Fbase: EtByte(10), - Fflags: EtByte(1), - Ftype: EtByte(16), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('s'), - Fbase: EtByte(0), - Fflags: EtByte(4), - Ftype: EtByte(5), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('g'), - Fbase: EtByte(0), - Fflags: EtByte(1), - Ftype: EtByte(3), - Fcharset: EtByte(30), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('z'), - Fbase: EtByte(0), - Fflags: EtByte(4), - Ftype: EtByte(6), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('q'), - Fbase: EtByte(0), - Fflags: EtByte(4), - Ftype: EtByte(9), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('Q'), - Fbase: EtByte(0), - Fflags: EtByte(4), - Ftype: EtByte(10), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('w'), - Fbase: EtByte(0), - Fflags: EtByte(4), - Ftype: EtByte(14), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('c'), - Fbase: EtByte(0), - Fflags: EtByte(0), - Ftype: EtByte(8), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('o'), - Fbase: EtByte(8), - Fflags: EtByte(0), - Ftype: EtByte(0), - Fcharset: EtByte(0), - Fprefix: EtByte(2)}, - { - Ffmttype: int8('u'), - Fbase: EtByte(10), - Fflags: EtByte(0), - Ftype: EtByte(16), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('x'), - Fbase: EtByte(16), - Fflags: EtByte(0), - Ftype: EtByte(0), - Fcharset: EtByte(16), - Fprefix: EtByte(1)}, - { - Ffmttype: int8('X'), - Fbase: EtByte(16), - Fflags: EtByte(0), - Ftype: EtByte(0), - Fcharset: EtByte(0), - Fprefix: EtByte(4)}, - { - Ffmttype: int8('f'), - Fbase: EtByte(0), - Fflags: EtByte(1), - Ftype: EtByte(1), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('e'), - Fbase: EtByte(0), - Fflags: EtByte(1), - Ftype: EtByte(2), - Fcharset: EtByte(30), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('E'), - Fbase: EtByte(0), - Fflags: EtByte(1), - Ftype: EtByte(2), - Fcharset: EtByte(14), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('G'), - Fbase: EtByte(0), - Fflags: EtByte(1), - Ftype: EtByte(3), - Fcharset: EtByte(14), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('i'), - Fbase: EtByte(10), - Fflags: EtByte(1), - Ftype: EtByte(16), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('n'), - Fbase: EtByte(0), - Fflags: EtByte(0), - Ftype: EtByte(4), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('%'), - Fbase: EtByte(0), - Fflags: EtByte(0), - Ftype: EtByte(7), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('p'), - Fbase: EtByte(16), - Fflags: EtByte(0), - Ftype: EtByte(13), - Fcharset: EtByte(0), - Fprefix: EtByte(1)}, + {Ffmttype: int8('d'), Fbase: EtByte(10), Fflags: EtByte(1), Ftype: EtDECIMAL}, + {Ffmttype: int8('s'), Fflags: EtByte(4), Ftype: EtSTRING}, + {Ffmttype: int8('g'), Fflags: EtByte(1), Ftype: EtGENERIC, Fcharset: EtByte(30)}, + {Ffmttype: int8('z'), Fflags: EtByte(4), Ftype: EtDYNSTRING}, + {Ffmttype: int8('q'), Fflags: EtByte(4), Ftype: EtSQLESCAPE}, + {Ffmttype: int8('Q'), Fflags: EtByte(4), Ftype: EtSQLESCAPE2}, + {Ffmttype: int8('w'), Fflags: EtByte(4), Ftype: EtSQLESCAPE3}, + {Ffmttype: int8('c'), Ftype: EtCHARX}, + {Ffmttype: int8('o'), Fbase: EtByte(8), Fprefix: EtByte(2)}, + {Ffmttype: int8('u'), Fbase: EtByte(10), Ftype: EtDECIMAL}, + {Ffmttype: int8('x'), Fbase: EtByte(16), Fcharset: EtByte(16), Fprefix: EtByte(1)}, + {Ffmttype: int8('X'), Fbase: EtByte(16), Fprefix: EtByte(4)}, + {Ffmttype: int8('f'), Fflags: EtByte(1), Ftype: EtFLOAT}, + {Ffmttype: int8('e'), Fflags: EtByte(1), Ftype: EtEXP, Fcharset: EtByte(30)}, + {Ffmttype: int8('E'), Fflags: EtByte(1), Ftype: EtEXP, Fcharset: EtByte(14)}, + {Ffmttype: int8('G'), Fflags: EtByte(1), Ftype: EtGENERIC, Fcharset: EtByte(14)}, + {Ffmttype: int8('i'), Fbase: EtByte(10), Fflags: EtByte(1), Ftype: EtDECIMAL}, + {Ffmttype: int8('n'), Ftype: EtSIZE}, + {Ffmttype: int8('%'), Ftype: EtPERCENT}, + {Ffmttype: int8('p'), Fbase: EtByte(16), Ftype: EtPOINTER, Fprefix: EtByte(1)}, // All the rest are undocumented and are for internal use only - { - Ffmttype: int8('T'), - Fbase: EtByte(0), - Fflags: EtByte(0), - Ftype: EtByte(11), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('S'), - Fbase: EtByte(0), - Fflags: EtByte(0), - Ftype: EtByte(12), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('r'), - Fbase: EtByte(10), - Fflags: EtByte(1), - Ftype: EtByte(15), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, + {Ffmttype: int8('T'), Ftype: EtTOKEN}, + {Ffmttype: int8('S'), Ftype: EtSRCLIST}, + {Ffmttype: int8('r'), Fbase: EtByte(10), Fflags: EtByte(1), Ftype: EtORDINAL}, } /* sqlite3.c:28212:22 */ // Floating point constants used for rounding @@ -15596,7 +15283,7 @@ func setStrAccumError(tls *libc.TLS, p uintptr, eError U8) { /* sqlite3.c:28282: if (*StrAccum)(unsafe.Pointer(p)).FmxAlloc != 0 { Xsqlite3_str_reset(tls, p) } - if int32(eError) == 18 { + if int32(eError) == SQLITE_TOOBIG { Xsqlite3ErrorToParser(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, int32(eError)) } } @@ -15636,12 +15323,12 @@ func printfTempBuf(tls *libc.TLS, pAccum uintptr, n Sqlite3_int64) uintptr { /* return uintptr(0) } if (n > Sqlite3_int64((*Sqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc)) && (n > Sqlite3_int64((*Sqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc)) { - setStrAccumError(tls, pAccum, uint8(18)) + setStrAccumError(tls, pAccum, SQLITE_TOOBIG) return uintptr(0) } z = Xsqlite3DbMallocRaw(tls, (*Sqlite3_str)(unsafe.Pointer(pAccum)).Fdb, uint64(n)) if z == uintptr(0) { - setStrAccumError(tls, pAccum, uint8(7)) + setStrAccumError(tls, pAccum, SQLITE_NOMEM) } return z } @@ -15729,7 +15416,7 @@ func Xsqlite3_str_vappendf(tls *libc.TLS, pAccum uintptr, fmt uintptr, ap Va_lis var pSrc uintptr var k1 int32 var pItem uintptr - xtype = EtByte(17) + xtype = EtINVALID zExtra = uintptr(0) pArgList = uintptr(0) // Conversion buffer @@ -15738,7 +15425,7 @@ func Xsqlite3_str_vappendf(tls *libc.TLS, pAccum uintptr, fmt uintptr, ap Va_lis // optimization. bufpt = uintptr(0) - if !((int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags) & 0x02) != 0) { + if !((int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags) & SQLITE_PRINTF_SQLFUNC) != 0) { goto __1 } pArgList = libc.VaUintptr(&ap) @@ -15921,7 +15608,7 @@ __42: } __43: ; - if !(((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(fmt + uintptr(1)))))) != '.') && (c != 'l')) { + if !(((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(fmt + 1))))) != '.') && (c != 'l')) { goto __44 } c = int32(*(*int8)(unsafe.Pointer(libc.PreIncUintptr(&fmt, 1)))) @@ -15994,8 +15681,8 @@ __14: ; // Fetch the info entry for the field - infop = (uintptr(unsafe.Pointer(&fmtinfo)) + uintptr(0)*6) - xtype = EtByte(17) + infop = (uintptr(unsafe.Pointer(&fmtinfo))) + xtype = EtINVALID idx = 0 __54: if !(idx < (int32(uint64(unsafe.Sizeof(fmtinfo)) / uint64(unsafe.Sizeof(Et_info{}))))) { @@ -16034,39 +15721,39 @@ __56: // infop Pointer to the appropriate info struct. switch int32(xtype) { - case 13: + case EtPOINTER: goto __59 - case 15: + case EtORDINAL: goto __60 - case 0: + case EtRADIX: goto __61 - case 16: + case EtDECIMAL: goto __62 - case 1: + case EtFLOAT: goto __63 - case 2: + case EtEXP: goto __64 - case 3: + case EtGENERIC: goto __65 - case 4: + case EtSIZE: goto __66 - case 7: + case EtPERCENT: goto __67 - case 8: + case EtCHARX: goto __68 - case 5: + case EtSTRING: goto __69 - case 6: + case EtDYNSTRING: goto __70 - case 9: + case EtSQLESCAPE: goto __71 // %q: Escape ' characters - case 10: + case EtSQLESCAPE2: goto __72 // %Q: Escape ' and enclose in '...' - case 14: + case EtSQLESCAPE3: goto __73 - case 11: + case EtTOKEN: goto __74 - case 12: + case EtSRCLIST: goto __75 default: goto __76 @@ -16082,13 +15769,11 @@ __59: flag_long = uint8(0) } } - /* no break */ __60: __61: cThousand = EtByte(0) - /* no break */ __62: - if !((int32((*Et_info)(unsafe.Pointer(infop)).Fflags) & 1) != 0) { + if !((int32((*Et_info)(unsafe.Pointer(infop)).Fflags) & FLAG_SIGNED) != 0) { goto __77 } if !(bArgList != 0) { @@ -16177,10 +15862,10 @@ __95: precision = (width - (libc.Bool32(int32(prefix) != 0))) __96: ; - if !(precision < ((70 - 10) - (70 / 3))) { + if !(precision < ((SQLITE_PRINT_BUF_SIZE - 10) - (SQLITE_PRINT_BUF_SIZE / 3))) { goto __97 } - nOut = 70 + nOut = SQLITE_PRINT_BUF_SIZE zOut = bp /* &buf[0] */ goto __98 __97: @@ -16202,7 +15887,7 @@ __100: __98: ; bufpt = (zOut + uintptr((nOut - 1))) - if !(int32(xtype) == 15) { + if !(int32(xtype) == EtORDINAL) { goto __101 } x = (int32(longvalue % uint64(10))) @@ -16315,10 +16000,10 @@ __119: precision = 6 __120: ; // Set default precision - if !(precision > 100000000) { + if !(precision > SQLITE_FP_PRECISION_LIMIT) { goto __121 } - precision = 100000000 + precision = SQLITE_FP_PRECISION_LIMIT __121: ; if !(*(*float64)(unsafe.Pointer(bp + 88 /* realvalue */)) < 0.0) { @@ -16331,7 +16016,7 @@ __122: prefix = int8(flag_prefix) __123: ; - if !((int32(xtype) == 3) && (precision > 0)) { + if !((int32(xtype) == EtGENERIC) && (precision > 0)) { goto __124 } precision-- @@ -16349,7 +16034,7 @@ __125: goto __125 __126: ; - if !(int32(xtype) == 1) { + if !(int32(xtype) == EtFLOAT) { goto __127 } *(*float64)(unsafe.Pointer(bp + 80 /* rx */)) = *(*float64)(unsafe.Pointer(bp + 88 /* realvalue */)) @@ -16428,7 +16113,7 @@ __140: goto __141 } bufpt = bp /* &buf[0] */ - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = prefix + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = prefix libc.Xmemcpy(tls, (bp /* &buf[0] */ + uintptr((libc.Bool32(int32(prefix) != 0)))), ts+699 /* "Inf" */, uint64(4)) length = (3 + (libc.Bool32(int32(prefix) != 0))) goto __58 @@ -16439,7 +16124,7 @@ __130: bufpt = bp /* &buf[0] */ // If the field type is etGENERIC, then convert to either etEXP // or etFLOAT, as appropriate. - if !(int32(xtype) != 1) { + if !(int32(xtype) != EtFLOAT) { goto __142 } *(*float64)(unsafe.Pointer(bp + 88 /* realvalue */)) += rounder @@ -16452,18 +16137,18 @@ __143: ; __142: ; - if !(int32(xtype) == 3) { + if !(int32(xtype) == EtGENERIC) { goto __144 } flag_rtz = libc.BoolUint8(!(flag_alternateform != 0)) if !((exp < -4) || (exp > precision)) { goto __146 } - xtype = EtByte(2) + xtype = EtEXP goto __147 __146: precision = (precision - exp) - xtype = EtByte(1) + xtype = EtFLOAT __147: ; goto __145 @@ -16471,7 +16156,7 @@ __144: flag_rtz = flag_altform2 __145: ; - if !(int32(xtype) == 2) { + if !(int32(xtype) == EtEXP) { goto __148 } e2 = 0 @@ -16487,7 +16172,7 @@ __149: } return int64(0) }()) + I64(precision)) + I64(width)) + int64(15)) - if !(szBufNeeded > int64(70)) { + if !(szBufNeeded > SQLITE_PRINT_BUF_SIZE) { goto __150 } bufpt = libc.AssignUintptr(&zExtra, printfTempBuf(tls, pAccum, szBufNeeded)) @@ -16600,7 +16285,7 @@ __167: __164: ; // Add the "eNNN" suffix - if !(int32(xtype) == 2) { + if !(int32(xtype) == EtEXP) { goto __170 } *(*int8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = aDigits[(*Et_info)(unsafe.Pointer(infop)).Fcharset] @@ -16675,7 +16360,7 @@ __180: length = libc.AssignInt32(&width, 0) goto __58 __67: - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = int8('%') + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = int8('%') bufpt = bp /* &buf[0] */ length = 1 goto __58 @@ -16688,12 +16373,12 @@ __68: if !(bufpt != 0) { goto __183 } - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = int8(libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = int8(libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1)))))) if !((c & 0xc0) == 0xc0) { goto __185 } __186: - if !((length < 4) && ((int32(*(*int8)(unsafe.Pointer(bufpt + uintptr(0)))) & 0xc0) == 0x80)) { + if !((length < 4) && ((int32(*(*int8)(unsafe.Pointer(bufpt))) & 0xc0) == 0x80)) { goto __187 } *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(libc.PostIncInt32(&length, 1)))) = *(*int8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) @@ -16704,7 +16389,7 @@ __185: ; goto __184 __183: - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = int8(0) __184: ; goto __182 @@ -16713,31 +16398,31 @@ __181: if !(ch < uint32(0x00080)) { goto __188 } - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = (int8(ch & uint32(0xff))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = (int8(ch & uint32(0xff))) length = 1 goto __189 __188: if !(ch < uint32(0x00800)) { goto __190 } - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = (int8(0xc0 + int32((U8((ch >> 6) & uint32(0x1f)))))) - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(1))) = (int8(0x80 + int32((U8(ch & uint32(0x3f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = (int8(0xc0 + int32((U8((ch >> 6) & uint32(0x1f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + 1)) = (int8(0x80 + int32((U8(ch & uint32(0x3f)))))) length = 2 goto __191 __190: if !(ch < uint32(0x10000)) { goto __192 } - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = (int8(0xe0 + int32((U8((ch >> 12) & uint32(0x0f)))))) - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(1))) = (int8(0x80 + int32((U8((ch >> 6) & uint32(0x3f)))))) - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(2))) = (int8(0x80 + int32((U8(ch & uint32(0x3f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = (int8(0xe0 + int32((U8((ch >> 12) & uint32(0x0f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + 1)) = (int8(0x80 + int32((U8((ch >> 6) & uint32(0x3f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + 2)) = (int8(0x80 + int32((U8(ch & uint32(0x3f)))))) length = 3 goto __193 __192: - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = (int8(0xf0 + int32((U8((ch >> 18) & uint32(0x07)))))) - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(1))) = (int8(0x80 + int32((U8((ch >> 12) & uint32(0x3f)))))) - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(2))) = (int8(0x80 + int32((U8((ch >> 6) & uint32(0x3f)))))) - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(3))) = (int8(0x80 + int32((U8(ch & uint32(0x3f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = (int8(0xf0 + int32((U8((ch >> 18) & uint32(0x07)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + 1)) = (int8(0x80 + int32((U8((ch >> 12) & uint32(0x3f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + 2)) = (int8(0x80 + int32((U8((ch >> 6) & uint32(0x3f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + 3)) = (int8(0x80 + int32((U8(ch & uint32(0x3f)))))) length = 4 __193: ; @@ -16777,7 +16462,7 @@ __70: goto __198 } bufpt = getTextArg(tls, pArgList) - xtype = EtByte(5) + xtype = EtSTRING goto __199 __198: bufpt = libc.VaUintptr(&ap) @@ -16789,7 +16474,7 @@ __199: bufpt = ts + 703 /* "" */ goto __201 __200: - if !(int32(xtype) == 6) { + if !(int32(xtype) == EtDYNSTRING) { goto __202 } if !((((((*Sqlite3_str)(unsafe.Pointer(pAccum)).FnChar == U32(0)) && @@ -16806,7 +16491,7 @@ __200: (*Sqlite3_str)(unsafe.Pointer(pAccum)).FzText = bufpt (*Sqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc = U32(Xsqlite3DbMallocSize(tls, (*Sqlite3_str)(unsafe.Pointer(pAccum)).Fdb, bufpt)) (*Sqlite3_str)(unsafe.Pointer(pAccum)).FnChar = (U32(0x7fffffff & int32(libc.Xstrlen(tls, bufpt)))) - *(*U8)(unsafe.Pointer(pAccum + 29 /* &.printfFlags */)) |= U8((0x04)) + *(*U8)(unsafe.Pointer(pAccum + 29 /* &.printfFlags */)) |= U8((SQLITE_PRINTF_MALLOCED)) length = 0 goto __58 __203: @@ -16826,7 +16511,7 @@ __201: // precision characters z = bufpt __208: - if !((libc.PostDecInt32(&precision, 1) > 0) && (*(*uint8)(unsafe.Pointer(z + uintptr(0))) != 0)) { + if !((libc.PostDecInt32(&precision, 1) > 0) && (*(*uint8)(unsafe.Pointer(z)) != 0)) { goto __209 } if !((int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))) >= 0xc0) { @@ -16894,7 +16579,7 @@ __71: // %q: Escape ' characters __72: // %Q: Escape ' and enclose in '...' __73: q = func() int8 { - if int32(xtype) == 14 { + if int32(xtype) == EtSQLESCAPE3 { return int8('"') } return int8('\'') @@ -16914,7 +16599,7 @@ __221: goto __222 } escarg = func() uintptr { - if int32(xtype) == 10 { + if int32(xtype) == EtSQLESCAPE2 { return ts + 704 /* "NULL" */ } return ts + 709 /* "(NULL)" */ @@ -16958,9 +16643,9 @@ __224: goto __225 __225: ; - needQuote = (libc.Bool32(!(isnull != 0) && (int32(xtype) == 10))) + needQuote = (libc.Bool32(!(isnull != 0) && (int32(xtype) == EtSQLESCAPE2))) n1 = n1 + (i1 + 3) - if !(n1 > 70) { + if !(n1 > SQLITE_PRINT_BUF_SIZE) { goto __230 } bufpt = libc.AssignUintptr(&zExtra, printfTempBuf(tls, pAccum, int64(n1))) @@ -17013,7 +16698,7 @@ __238: goto adjust_width_for_utf8 __74: - if !((int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags) & 0x01) == 0) { + if !((int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags) & SQLITE_PRINTF_INTERNAL) == 0) { goto __239 } return @@ -17031,7 +16716,7 @@ __240: goto __58 __75: - if !((int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags) & 0x01) == 0) { + if !((int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags) & SQLITE_PRINTF_INTERNAL) == 0) { goto __241 } return @@ -17104,6 +16789,7 @@ __5: } var zOrd = *(*[9]int8)(unsafe.Pointer(ts + 718 /* "thstndrd" */)) /* sqlite3.c:28611:29 */ + // End of function // Enlarge the memory allocation on a StrAccum object so that it is @@ -17119,11 +16805,11 @@ func sqlite3StrAccumEnlarge(tls *libc.TLS, p uintptr, N int32) int32 { /* sqlite return 0 } if (*StrAccum)(unsafe.Pointer(p)).FmxAlloc == U32(0) { - setStrAccumError(tls, p, uint8(18)) + setStrAccumError(tls, p, SQLITE_TOOBIG) return (int32(((*StrAccum)(unsafe.Pointer(p)).FnAlloc - (*StrAccum)(unsafe.Pointer(p)).FnChar) - U32(1))) } else { var zOld uintptr - if (int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & 0x04) != 0 { + if (int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & SQLITE_PRINTF_MALLOCED) != 0 { zOld = (*StrAccum)(unsafe.Pointer(p)).FzText } else { zOld = uintptr(0) @@ -17137,7 +16823,7 @@ func sqlite3StrAccumEnlarge(tls *libc.TLS, p uintptr, N int32) int32 { /* sqlite } if szNew > I64((*StrAccum)(unsafe.Pointer(p)).FmxAlloc) { Xsqlite3_str_reset(tls, p) - setStrAccumError(tls, p, uint8(18)) + setStrAccumError(tls, p, SQLITE_TOOBIG) return 0 } else { (*StrAccum)(unsafe.Pointer(p)).FnAlloc = U32(int32(szNew)) @@ -17149,15 +16835,15 @@ func sqlite3StrAccumEnlarge(tls *libc.TLS, p uintptr, N int32) int32 { /* sqlite } if zNew != 0 { - if !((int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & 0x04) != 0) && ((*StrAccum)(unsafe.Pointer(p)).FnChar > U32(0)) { + if !((int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & SQLITE_PRINTF_MALLOCED) != 0) && ((*StrAccum)(unsafe.Pointer(p)).FnChar > U32(0)) { libc.Xmemcpy(tls, zNew, (*StrAccum)(unsafe.Pointer(p)).FzText, uint64((*StrAccum)(unsafe.Pointer(p)).FnChar)) } (*StrAccum)(unsafe.Pointer(p)).FzText = zNew (*StrAccum)(unsafe.Pointer(p)).FnAlloc = U32(Xsqlite3DbMallocSize(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, zNew)) - *(*U8)(unsafe.Pointer(p + 29 /* &.printfFlags */)) |= U8((0x04)) + *(*U8)(unsafe.Pointer(p + 29 /* &.printfFlags */)) |= U8((SQLITE_PRINTF_MALLOCED)) } else { Xsqlite3_str_reset(tls, p) - setStrAccumError(tls, p, uint8(7)) + setStrAccumError(tls, p, SQLITE_NOMEM) return 0 } } @@ -17216,9 +16902,9 @@ func strAccumFinishRealloc(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:2915 zText = Xsqlite3DbMallocRaw(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, (uint64((*StrAccum)(unsafe.Pointer(p)).FnChar + U32(1)))) if zText != 0 { libc.Xmemcpy(tls, zText, (*StrAccum)(unsafe.Pointer(p)).FzText, (uint64((*StrAccum)(unsafe.Pointer(p)).FnChar + U32(1)))) - *(*U8)(unsafe.Pointer(p + 29 /* &.printfFlags */)) |= U8((0x04)) + *(*U8)(unsafe.Pointer(p + 29 /* &.printfFlags */)) |= U8((SQLITE_PRINTF_MALLOCED)) } else { - setStrAccumError(tls, p, uint8(7)) + setStrAccumError(tls, p, SQLITE_NOMEM) } (*StrAccum)(unsafe.Pointer(p)).FzText = zText return zText @@ -17227,7 +16913,7 @@ func strAccumFinishRealloc(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:2915 func Xsqlite3StrAccumFinish(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:29169:21: */ if (*StrAccum)(unsafe.Pointer(p)).FzText != 0 { *(*int8)(unsafe.Pointer((*StrAccum)(unsafe.Pointer(p)).FzText + uintptr((*StrAccum)(unsafe.Pointer(p)).FnChar))) = int8(0) - if ((*StrAccum)(unsafe.Pointer(p)).FmxAlloc > U32(0)) && !((int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & 0x04) != 0) { + if ((*StrAccum)(unsafe.Pointer(p)).FmxAlloc > U32(0)) && !((int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & SQLITE_PRINTF_MALLOCED) != 0) { return strAccumFinishRealloc(tls, p) } } @@ -17238,15 +16924,7 @@ func Xsqlite3StrAccumFinish(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:291 // sqlite3_malloc() fails to provide space for a real one. This // sqlite3_str object accepts no new text and always returns // an SQLITE_NOMEM error. -var sqlite3OomStr = Sqlite3_str{ - Fdb: uintptr(0), - FzText: uintptr(0), - FnAlloc: U32(0), - FmxAlloc: U32(0), - FnChar: U32(0), - FaccError: U8(7), - FprintfFlags: U8(0), -} /* sqlite3.c:29185:20 */ +var sqlite3OomStr = Sqlite3_str{FaccError: SQLITE_NOMEM} /* sqlite3.c:29185:20 */ // Finalize a string created using sqlite3_str_new(). func Xsqlite3_str_finish(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:29191:17: */ @@ -17265,7 +16943,7 @@ func Xsqlite3_str_errcode(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:29203:1 if p != 0 { return int32((*Sqlite3_str)(unsafe.Pointer(p)).FaccError) } - return 7 + return SQLITE_NOMEM } // Return the current length of p in bytes @@ -17287,9 +16965,9 @@ func Xsqlite3_str_value(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:29213:1 // Reset an StrAccum string. Reclaim all malloced memory. func Xsqlite3_str_reset(tls *libc.TLS, p uintptr) { /* sqlite3.c:29222:17: */ - if (int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & 0x04) != 0 { + if (int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & SQLITE_PRINTF_MALLOCED) != 0 { Xsqlite3DbFree(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, (*StrAccum)(unsafe.Pointer(p)).FzText) - *(*U8)(unsafe.Pointer(p + 29 /* &.printfFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x04))) + *(*U8)(unsafe.Pointer(p + 29 /* &.printfFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(SQLITE_PRINTF_MALLOCED))) } (*StrAccum)(unsafe.Pointer(p)).FnAlloc = U32(0) (*StrAccum)(unsafe.Pointer(p)).FnChar = U32(0) @@ -17325,9 +17003,9 @@ func Xsqlite3_str_new(tls *libc.TLS, db uintptr) uintptr { /* sqlite3.c:29257:24 Xsqlite3StrAccumInit(tls, p, uintptr(0), uintptr(0), 0, func() int32 { if db != 0 { - return *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4)) + return *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */))) } - return 1000000000 + return SQLITE_MAX_LENGTH }()) } else { p = uintptr(unsafe.Pointer(&sqlite3OomStr)) @@ -17347,11 +17025,11 @@ func Xsqlite3VMPrintf(tls *libc.TLS, db uintptr, zFormat uintptr, ap Va_list) ui // var acc StrAccum at bp, 32 Xsqlite3StrAccumInit(tls, bp /* &acc */, db, bp+32 /* &zBase[0] */, int32(unsafe.Sizeof([70]int8{})), - *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) - (*StrAccum)(unsafe.Pointer(bp /* &acc */)).FprintfFlags = U8(0x01) + *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) + (*StrAccum)(unsafe.Pointer(bp /* &acc */)).FprintfFlags = SQLITE_PRINTF_INTERNAL Xsqlite3_str_vappendf(tls, bp /* &acc */, zFormat, ap) z = Xsqlite3StrAccumFinish(tls, bp /* &acc */) - if int32((*StrAccum)(unsafe.Pointer(bp /* &acc */)).FaccError) == 7 { + if int32((*StrAccum)(unsafe.Pointer(bp /* &acc */)).FaccError) == SQLITE_NOMEM { Xsqlite3OomFault(tls, db) } return z @@ -17383,7 +17061,7 @@ func Xsqlite3_vmprintf(tls *libc.TLS, zFormat uintptr, ap Va_list) uintptr { /* if Xsqlite3_initialize(tls) != 0 { return uintptr(0) } - Xsqlite3StrAccumInit(tls, bp /* &acc */, uintptr(0), bp+32 /* &zBase[0] */, int32(unsafe.Sizeof([70]int8{})), 1000000000) + Xsqlite3StrAccumInit(tls, bp /* &acc */, uintptr(0), bp+32 /* &zBase[0] */, int32(unsafe.Sizeof([70]int8{})), SQLITE_MAX_LENGTH) Xsqlite3_str_vappendf(tls, bp /* &acc */, zFormat, ap) z = Xsqlite3StrAccumFinish(tls, bp /* &acc */) return z @@ -17601,7 +17279,7 @@ func Xsqlite3_randomness(tls *libc.TLS, N int32, pBuf uintptr) { /* sqlite3.c:30 return } - mutex = Xsqlite3MutexAlloc(tls, 5) + mutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_PRNG) Xsqlite3_mutex_enter(tls, mutex) if (N <= 0) || (pBuf == uintptr(0)) { @@ -17679,7 +17357,7 @@ func Xsqlite3ThreadCreate(tls *libc.TLS, ppThread uintptr, xTask uintptr, pIn ui *(*uintptr)(unsafe.Pointer(ppThread)) = uintptr(0) p = Xsqlite3Malloc(tls, uint64(unsafe.Sizeof(SQLiteThread{}))) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } if (((int32(p)) / 17) & 1) != 0 { (*SQLiteThread)(unsafe.Pointer(p)).FxTask = xTask @@ -17689,14 +17367,14 @@ func Xsqlite3ThreadCreate(tls *libc.TLS, ppThread uintptr, xTask uintptr, pIn ui (*SQLiteThread)(unsafe.Pointer(p)).FpResult = (*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(&xTask)))(tls, pIn) } *(*uintptr)(unsafe.Pointer(ppThread)) = p - return 0 + return SQLITE_OK } // Get the results of the thread func Xsqlite3ThreadJoin(tls *libc.TLS, p uintptr, ppOut uintptr) int32 { /* sqlite3.c:30621:20: */ if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } if (*SQLiteThread)(unsafe.Pointer(p)).FxTask != 0 { *(*uintptr)(unsafe.Pointer(ppOut)) = (*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer((p /* &.xTask */))))(tls, (*SQLiteThread)(unsafe.Pointer(p)).FpIn) @@ -17705,7 +17383,7 @@ func Xsqlite3ThreadJoin(tls *libc.TLS, p uintptr, ppOut uintptr) int32 { /* sqli } Xsqlite3_free(tls, p) - return 0 + return SQLITE_OK } //***************************** End Single-Threaded ************************ @@ -17829,19 +17507,19 @@ func Xsqlite3VdbeMemTranslate(tls *libc.TLS, pMem uintptr, desiredEnc U8) int32 // If the translation is between UTF-16 little and big endian, then // all that is required is to swap the byte order. This case is handled // differently from the others. - if !((int32((*Mem)(unsafe.Pointer(pMem)).Fenc) != 1) && (int32(desiredEnc) != 1)) { + if !((int32((*Mem)(unsafe.Pointer(pMem)).Fenc) != SQLITE_UTF8) && (int32(desiredEnc) != SQLITE_UTF8)) { goto __1 } rc = Xsqlite3VdbeMemMakeWriteable(tls, pMem) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __2 } - return 7 + return SQLITE_NOMEM __2: ; zIn = (*Mem)(unsafe.Pointer(pMem)).Fz - zTerm = (zIn + uintptr(((*Mem)(unsafe.Pointer(pMem)).Fn & ^libc.Int32(1)))) + zTerm = (zIn + uintptr(((*Mem)(unsafe.Pointer(pMem)).Fn & libc.CplInt32(1)))) __3: if !(zIn < zTerm) { goto __4 @@ -17859,14 +17537,14 @@ __1: ; // Set len to the maximum number of bytes required in the output buffer. - if !(int32(desiredEnc) == 1) { + if !(int32(desiredEnc) == SQLITE_UTF8) { goto __5 } // When converting from UTF-16, the maximum growth results from // translating a 2-byte character to a 4-byte UTF-8 character. // A single byte is required for the output string // nul-terminator. - *(*int32)(unsafe.Pointer(pMem + 12 /* &.n */)) &= (^libc.Int32(1)) + *(*int32)(unsafe.Pointer(pMem + 12 /* &.n */)) &= (libc.CplInt32(1)) len = ((int64(2) * Sqlite3_int64((*Mem)(unsafe.Pointer(pMem)).Fn)) + int64(1)) goto __6 __5: @@ -17889,15 +17567,15 @@ __6: if !(!(zOut != 0)) { goto __7 } - return 7 + return SQLITE_NOMEM __7: ; z = zOut - if !(int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == 1) { + if !(int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == SQLITE_UTF8) { goto __8 } - if !(int32(desiredEnc) == 2) { + if !(int32(desiredEnc) == SQLITE_UTF16LE) { goto __10 } // UTF-8 -> UTF-16 Little-endian @@ -17998,7 +17676,7 @@ __11: goto __9 __8: ; - if !(int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == 2) { + if !(int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == SQLITE_UTF16LE) { goto __28 } // UTF-16 Little-endian -> UTF-8 @@ -18120,7 +17798,7 @@ __9: ; *(*uint8)(unsafe.Pointer(z)) = uint8(0) - c = (uint32((0x0002 | 0x0200) | (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x003f | 0x8000)))) + c = (uint32((MEM_Str | MEM_Term) | (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_AffMask | MEM_Subtype)))) Xsqlite3VdbeMemRelease(tls, pMem) (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(c) (*Mem)(unsafe.Pointer(pMem)).Fenc = desiredEnc @@ -18129,7 +17807,7 @@ __9: (*Mem)(unsafe.Pointer(pMem)).FszMalloc = Xsqlite3DbMallocSize(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, (*Mem)(unsafe.Pointer(pMem)).Fz) translate_out: - return 0 + return SQLITE_OK } // This routine checks for a byte-order mark at the beginning of the @@ -18140,28 +17818,28 @@ translate_out: // The allocation (static, dynamic etc.) and encoding of the Mem may be // changed by this function. func Xsqlite3VdbeMemHandleBom(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:31025:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var bom U8 = U8(0) if (*Mem)(unsafe.Pointer(pMem)).Fn > 1 { var b1 U8 = *(*U8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz)) var b2 U8 = *(*U8)(unsafe.Pointer((((*Mem)(unsafe.Pointer(pMem)).Fz) + uintptr(1)))) if (int32(b1) == 0xFE) && (int32(b2) == 0xFF) { - bom = U8(3) + bom = SQLITE_UTF16BE } if (int32(b1) == 0xFF) && (int32(b2) == 0xFE) { - bom = U8(2) + bom = SQLITE_UTF16LE } } if bom != 0 { rc = Xsqlite3VdbeMemMakeWriteable(tls, pMem) - if rc == 0 { + if rc == SQLITE_OK { *(*int32)(unsafe.Pointer(pMem + 12 /* &.n */)) -= (2) - libc.Xmemmove(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, ((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(2)), uint64((*Mem)(unsafe.Pointer(pMem)).Fn)) + libc.Xmemmove(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, ((*Mem)(unsafe.Pointer(pMem)).Fz + 2), uint64((*Mem)(unsafe.Pointer(pMem)).Fn)) *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn))) = int8(0) *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(((*Mem)(unsafe.Pointer(pMem)).Fn + 1)))) = int8(0) - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16((0x0200)) + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16((MEM_Term)) (*Mem)(unsafe.Pointer(pMem)).Fenc = bom } } @@ -18214,7 +17892,7 @@ func Xsqlite3Utf16to8(tls *libc.TLS, db uintptr, z uintptr, nByte int32, enc U8) libc.Xmemset(tls, bp /* &m */, 0, uint64(unsafe.Sizeof(Mem{}))) (*Mem)(unsafe.Pointer(bp /* &m */)).Fdb = db Xsqlite3VdbeMemSetStr(tls, bp /* &m */, z, nByte, enc, uintptr(0)) - Xsqlite3VdbeChangeEncoding(tls, bp /* &m */, 1) + Xsqlite3VdbeChangeEncoding(tls, bp /* &m */, SQLITE_UTF8) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { Xsqlite3VdbeMemRelease(tls, bp /* &m */) (*Mem)(unsafe.Pointer(bp /* &m */)).Fz = uintptr(0) @@ -18231,19 +17909,19 @@ func Xsqlite3Utf16ByteLen(tls *libc.TLS, zIn uintptr, nChar int32) int32 { /* sq var z uintptr = zIn var n int32 = 0 - if 2 == 2 { + if SQLITE_UTF16LE == SQLITE_UTF16LE { z++ } for n < nChar { - c = int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) + c = int32(*(*uint8)(unsafe.Pointer(z))) z += uintptr(2) - if (((c >= 0xd8) && (c < 0xdc)) && (int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) >= 0xdc)) && (int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) < 0xe0) { + if (((c >= 0xd8) && (c < 0xdc)) && (int32(*(*uint8)(unsafe.Pointer(z))) >= 0xdc)) && (int32(*(*uint8)(unsafe.Pointer(z))) < 0xe0) { z += uintptr(2) } n++ } return ((int32((int64(z) - int64(zIn)) / 1)) - - (libc.Bool32(2 == 2))) + (libc.Bool32(SQLITE_UTF16LE == SQLITE_UTF16LE))) } //************* End of utf.c ************************************************ @@ -18530,7 +18208,7 @@ func Xsqlite3FaultSim(tls *libc.TLS, iTest int32) int32 { /* sqlite3.c:31240:20: if xCallback != 0 { return (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(&xCallback)))(tls, iTest) } - return 0 + return SQLITE_OK } // Return true if the floating point value is Not a Number (NaN). @@ -18564,7 +18242,7 @@ func Xsqlite3Strlen30(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:31265:20: * // The column type is an extra string stored after the zero-terminator on // the column name if and only if the COLFLAG_HASTYPE flag is set. func Xsqlite3ColumnType(tls *libc.TLS, pCol uintptr, zDflt uintptr) uintptr { /* sqlite3.c:31277:21: */ - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0004) == 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_HASTYPE) == 0 { return zDflt } return (((*Column)(unsafe.Pointer(pCol)).FzName + uintptr(libc.Xstrlen(tls, (*Column)(unsafe.Pointer(pCol)).FzName))) + uintptr(1)) @@ -18594,11 +18272,11 @@ func Xsqlite3Error(tls *libc.TLS, db uintptr, err_code int32) { /* sqlite3.c:312 // Load the sqlite3.iSysErrno field if that is an appropriate thing // to do based on the SQLite error code in rc. func Xsqlite3SystemError(tls *libc.TLS, db uintptr, rc int32) { /* sqlite3.c:31307:21: */ - if rc == (10 | (int32(12) << 8)) { + if rc == (SQLITE_IOERR | (int32(12) << 8)) { return } rc = rc & (0xff) - if (rc == 14) || (rc == 10) { + if (rc == SQLITE_CANTOPEN) || (rc == SQLITE_IOERR) { (*Sqlite3)(unsafe.Pointer(db)).FiSysErrno = Xsqlite3OsGetLastError(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs) } } @@ -18635,7 +18313,7 @@ func Xsqlite3ErrorWithMsg(tls *libc.TLS, db uintptr, err_code int32, zFormat uin ap = va z = Xsqlite3VMPrintf(tls, db, zFormat, ap) _ = ap - Xsqlite3ValueSetStr(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr, -1, z, uint8(1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) + Xsqlite3ValueSetStr(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr, -1, z, SQLITE_UTF8, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) } } @@ -18668,7 +18346,7 @@ func Xsqlite3ErrorMsg(tls *libc.TLS, pParse uintptr, zFormat uintptr, va uintptr (*Parse)(unsafe.Pointer(pParse)).FnErr++ Xsqlite3DbFree(tls, db, (*Parse)(unsafe.Pointer(pParse)).FzErrMsg) (*Parse)(unsafe.Pointer(pParse)).FzErrMsg = zMsg - (*Parse)(unsafe.Pointer(pParse)).Frc = 1 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR (*Parse)(unsafe.Pointer(pParse)).FpWith = uintptr(0) } } @@ -18708,7 +18386,7 @@ func Xsqlite3Dequote(tls *libc.TLS, z uintptr) { /* sqlite3.c:31417:21: */ if z == uintptr(0) { return } - quote = *(*int8)(unsafe.Pointer(z + uintptr(0))) + quote = *(*int8)(unsafe.Pointer(z)) if !((int32(Xsqlite3CtypeMap[uint8(quote)]) & 0x80) != 0) { return } @@ -18736,10 +18414,10 @@ func Xsqlite3Dequote(tls *libc.TLS, z uintptr) { /* sqlite3.c:31417:21: */ func Xsqlite3DequoteExpr(tls *libc.TLS, p uintptr) { /* sqlite3.c:31439:21: */ *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= (func() uint32 { - if int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) + uintptr(0)))) == '"' { - return (uint32(0x4000000 | 0x000040)) + if int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))))) == '"' { + return (uint32(EP_Quoted | EP_DblQuoted)) } - return uint32(0x4000000) + return EP_Quoted }()) Xsqlite3Dequote(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))) } @@ -18827,8 +18505,8 @@ func Xsqlite3StrIHash(tls *libc.TLS, z uintptr) U8 { /* sqlite3.c:31509:19: */ if z == uintptr(0) { return U8(0) } - for *(*int8)(unsafe.Pointer(z + uintptr(0))) != 0 { - h = U8(int32(h) + (int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(z + uintptr(0))))]))) + for *(*int8)(unsafe.Pointer(z)) != 0 { + h = U8(int32(h) + (int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(z)))]))) z++ } return h @@ -18914,7 +18592,7 @@ func Xsqlite3AtoF(tls *libc.TLS, z uintptr, pResult uintptr, length int32, enc U __1: ; - if !(int32(enc) == 1) { + if !(int32(enc) == SQLITE_UTF8) { goto __2 } incr = 1 @@ -18922,7 +18600,7 @@ __1: goto __3 __2: incr = 2 - length = length & (^libc.Int32(1)) + length = length & (libc.CplInt32(1)) i = (3 - int32(enc)) __4: @@ -19279,7 +18957,7 @@ func Xsqlite3Int64ToText(tls *libc.TLS, v I64, zOut uintptr) { /* sqlite3.c:3178 x = U64(v) } i = (int32(uint64(unsafe.Sizeof([22]int8{})) - uint64(2))) - *(*int8)(unsafe.Pointer(bp /* &zTemp[0] */ + uintptr((uint64(unsafe.Sizeof([22]int8{})) - uint64(1))))) = int8(0) + *(*int8)(unsafe.Pointer(bp /* &zTemp[0] */ + 21)) = int8(0) for ok := true; ok; ok = x != 0 { *(*int8)(unsafe.Pointer(bp /* &zTemp[0] */ + uintptr(libc.PostDecInt32(&i, 1)))) = (int8((x % uint64(10)) + uint64('0'))) x = (x / uint64(10)) @@ -19342,7 +19020,7 @@ func Xsqlite3Atoi64(tls *libc.TLS, zNum uintptr, pNum uintptr, length int32, enc var zStart uintptr var zEnd uintptr = (zNum + uintptr(length)) - if int32(enc) == 1 { + if int32(enc) == SQLITE_UTF8 { incr = 1 } else { incr = 2 @@ -19365,7 +19043,7 @@ func Xsqlite3Atoi64(tls *libc.TLS, zNum uintptr, pNum uintptr, length int32, enc } } zStart = zNum - for (zNum < zEnd) && (int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '0') { + for (zNum < zEnd) && (int32(*(*int8)(unsafe.Pointer(zNum))) == '0') { zNum += uintptr(incr) } // Skip leading zeros. for i = 0; (((zNum + uintptr(i)) < zEnd) && ((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(zNum + uintptr(i)))))) >= '0')) && (c <= '9'); i = i + (incr) { @@ -19456,8 +19134,8 @@ func Xsqlite3DecOrHexToI64(tls *libc.TLS, z uintptr, pOut uintptr) int32 { /* sq bp := tls.Alloc(8) defer tls.Free(8) - if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '0') && - ((int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == 'x') || (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == 'X')) { + if (int32(*(*int8)(unsafe.Pointer(z))) == '0') && + ((int32(*(*int8)(unsafe.Pointer(z + 1))) == 'x') || (int32(*(*int8)(unsafe.Pointer(z + 1))) == 'X')) { *(*U64)(unsafe.Pointer(bp /* u */)) = uint64(0) var i int32 var k int32 @@ -19472,7 +19150,7 @@ func Xsqlite3DecOrHexToI64(tls *libc.TLS, z uintptr, pOut uintptr) int32 { /* sq } return 2 } else { - return Xsqlite3Atoi64(tls, z, pOut, Xsqlite3Strlen30(tls, z), uint8(1)) + return Xsqlite3Atoi64(tls, z, pOut, Xsqlite3Strlen30(tls, z), SQLITE_UTF8) } return int32(0) } @@ -19493,17 +19171,17 @@ func Xsqlite3GetInt32(tls *libc.TLS, zNum uintptr, pValue uintptr) int32 { /* sq var i int32 var c int32 var neg int32 = 0 - if int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '-' { + if int32(*(*int8)(unsafe.Pointer(zNum))) == '-' { neg = 1 zNum++ - } else if int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '+' { + } else if int32(*(*int8)(unsafe.Pointer(zNum))) == '+' { zNum++ - } else if ((int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '0') && - ((int32(*(*int8)(unsafe.Pointer(zNum + uintptr(1)))) == 'x') || (int32(*(*int8)(unsafe.Pointer(zNum + uintptr(1)))) == 'X'))) && - ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zNum + uintptr(2))))]) & 0x08) != 0) { + } else if ((int32(*(*int8)(unsafe.Pointer(zNum))) == '0') && + ((int32(*(*int8)(unsafe.Pointer(zNum + 1))) == 'x') || (int32(*(*int8)(unsafe.Pointer(zNum + 1))) == 'X'))) && + ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zNum + 2)))]) & 0x08) != 0) { *(*U32)(unsafe.Pointer(bp /* u */)) = U32(0) zNum += uintptr(2) - for int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '0' { + for int32(*(*int8)(unsafe.Pointer(zNum))) == '0' { zNum++ } for i = 0; ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zNum + uintptr(i))))]) & 0x08) != 0) && (i < 8); i++ { @@ -19516,10 +19194,10 @@ func Xsqlite3GetInt32(tls *libc.TLS, zNum uintptr, pValue uintptr) int32 { /* sq return 0 } } - if !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zNum + uintptr(0))))]) & 0x04) != 0) { + if !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zNum)))]) & 0x04) != 0) { return 0 } - for int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '0' { + for int32(*(*int8)(unsafe.Pointer(zNum))) == '0' { zNum++ } for i = 0; ((i < 11) && ((libc.AssignInt32(&c, (int32(*(*int8)(unsafe.Pointer(zNum + uintptr(i)))) - '0'))) >= 0)) && (c <= 9); i++ { @@ -19613,7 +19291,7 @@ func putVarint64(tls *libc.TLS, p uintptr, v U64) int32 { /* sqlite3.c:32099:28: // var buf [10]U8 at bp, 10 if (v & (U64((uint64(0xff000000))) << 32)) != 0 { - *(*uint8)(unsafe.Pointer(p + uintptr(8))) = U8(v) + *(*uint8)(unsafe.Pointer(p + 8)) = U8(v) v >>= 8 for i = 7; i >= 0; i-- { *(*uint8)(unsafe.Pointer(p + uintptr(i))) = (U8((v & uint64(0x7f)) | uint64(0x80))) @@ -19626,7 +19304,7 @@ func putVarint64(tls *libc.TLS, p uintptr, v U64) int32 { /* sqlite3.c:32099:28: *(*U8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(libc.PostIncInt32(&n, 1)))) = (U8((v & uint64(0x7f)) | uint64(0x80))) v >>= 7 } - *(*U8)(unsafe.Pointer(bp /* &buf */ + uintptr(0))) &= U8((0x7f)) + *(*U8)(unsafe.Pointer(bp /* &buf */)) &= U8((0x7f)) i = 0 j = (n - 1) @@ -19651,12 +19329,12 @@ __3: func Xsqlite3PutVarint(tls *libc.TLS, p uintptr, v U64) int32 { /* sqlite3.c:32123:20: */ if v <= uint64(0x7f) { - *(*uint8)(unsafe.Pointer(p + uintptr(0))) = (uint8(v & uint64(0x7f))) + *(*uint8)(unsafe.Pointer(p)) = (uint8(v & uint64(0x7f))) return 1 } if v <= uint64(0x3fff) { - *(*uint8)(unsafe.Pointer(p + uintptr(0))) = (uint8(((v >> 7) & uint64(0x7f)) | uint64(0x80))) - *(*uint8)(unsafe.Pointer(p + uintptr(1))) = (uint8(v & uint64(0x7f))) + *(*uint8)(unsafe.Pointer(p)) = (uint8(((v >> 7) & uint64(0x7f)) | uint64(0x80))) + *(*uint8)(unsafe.Pointer(p + 1)) = (uint8(v & uint64(0x7f))) return 2 } return putVarint64(tls, p, v) @@ -19677,24 +19355,24 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 var b U32 var s U32 - if int32(*(*int8)(unsafe.Pointer((p) + uintptr(0)))) >= 0 { + if int32(*(*int8)(unsafe.Pointer((p)))) >= 0 { *(*U64)(unsafe.Pointer(v)) = U64(*(*uint8)(unsafe.Pointer(p))) return U8(1) } - if int32(*(*int8)(unsafe.Pointer((p) + uintptr(1)))) >= 0 { - *(*U64)(unsafe.Pointer(v)) = (U64(((U32(int32(*(*uint8)(unsafe.Pointer(p + uintptr(0)))) & 0x7f)) << 7) | U32(*(*uint8)(unsafe.Pointer(p + uintptr(1)))))) + if int32(*(*int8)(unsafe.Pointer((p) + 1))) >= 0 { + *(*U64)(unsafe.Pointer(v)) = (U64(((U32(int32(*(*uint8)(unsafe.Pointer(p))) & 0x7f)) << 7) | U32(*(*uint8)(unsafe.Pointer(p + 1))))) return U8(2) } // Verify that constants are precomputed correctly - a = ((U32(*(*uint8)(unsafe.Pointer(p + uintptr(0))))) << 14) - b = U32(*(*uint8)(unsafe.Pointer(p + uintptr(1)))) + a = ((U32(*(*uint8)(unsafe.Pointer(p)))) << 14) + b = U32(*(*uint8)(unsafe.Pointer(p + 1))) p += uintptr(2) a = a | (U32(*(*uint8)(unsafe.Pointer(p)))) // a: p0<<14 | p2 (unmasked) if !((a & U32(0x80)) != 0) { - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) b = b & (U32(0x7f)) b = (b << 7) a = a | (b) @@ -19703,13 +19381,13 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 } // CSE1 from below - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) p++ b = (b << 14) b = b | (U32(*(*uint8)(unsafe.Pointer(p)))) // b: p1<<14 | p3 (unmasked) if !((b & U32(0x80)) != 0) { - b = b & (U32(0x001fc07f)) + b = b & (SLOT_2_0) // moved CSE1 up // a &= (0x7f<<14)|(0x7f); a = (a << 7) @@ -19723,7 +19401,7 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 // 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) // moved CSE1 up // a &= (0x7f<<14)|(0x7f); - b = b & (U32(0x001fc07f)) + b = b & (SLOT_2_0) s = a // s: p0<<14 | p2 (masked) @@ -19755,7 +19433,7 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 if !((b & U32(0x80)) != 0) { // we can skip this cause it was (effectively) done above in calc'ing s // b &= (0x7f<<28)|(0x7f<<14)|(0x7f); - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) a = (a << 7) a = a | (b) s = (s >> 18) @@ -19768,8 +19446,8 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 a = a | (U32(*(*uint8)(unsafe.Pointer(p)))) // a: p2<<28 | p4<<14 | p6 (unmasked) if !((a & U32(0x80)) != 0) { - a = a & (0xf01fc07f) - b = b & (U32(0x001fc07f)) + a = a & (SLOT_4_2_0) + b = b & (SLOT_2_0) b = (b << 7) a = a | (b) s = (s >> 11) @@ -19778,13 +19456,13 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 } // CSE2 from below - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) p++ b = (b << 14) b = b | (U32(*(*uint8)(unsafe.Pointer(p)))) // b: p3<<28 | p5<<14 | p7 (unmasked) if !((b & U32(0x80)) != 0) { - b = b & (0xf01fc07f) + b = b & (SLOT_4_2_0) // moved CSE2 up // a &= (0x7f<<14)|(0x7f); a = (a << 7) @@ -19801,7 +19479,7 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 // moved CSE2 up // a &= (0x7f<<29)|(0x7f<<15)|(0xff); - b = b & (U32(0x001fc07f)) + b = b & (SLOT_2_0) b = (b << 8) a = a | (b) @@ -19954,7 +19632,7 @@ func logBadConnection(tls *libc.TLS, zType uintptr) { /* sqlite3.c:32527:13: */ bp := tls.Alloc(8) defer tls.Free(8) - Xsqlite3_log(tls, 21, + Xsqlite3_log(tls, SQLITE_MISUSE, ts+746, /* "API call with %s..." */ libc.VaList(bp, zType)) } @@ -19978,7 +19656,7 @@ func Xsqlite3SafetyCheckOk(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:32548 return 0 } magic = (*Sqlite3)(unsafe.Pointer(db)).Fmagic - if magic != 0xa029a697 { + if magic != SQLITE_MAGIC_OPEN { if Xsqlite3SafetyCheckSickOrOk(tls, db) != 0 { logBadConnection(tls, ts+791 /* "unopened" */) @@ -19993,7 +19671,7 @@ func Xsqlite3SafetyCheckOk(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:32548 func Xsqlite3SafetyCheckSickOrOk(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:32565:20: */ var magic U32 magic = (*Sqlite3)(unsafe.Pointer(db)).Fmagic - if ((magic != U32(0x4b771290)) && (magic != 0xa029a697)) && (magic != 0xf03b7906) { + if ((magic != SQLITE_MAGIC_SICK) && (magic != SQLITE_MAGIC_OPEN)) && (magic != SQLITE_MAGIC_BUSY) { logBadConnection(tls, ts+800 /* "invalid" */) return 0 @@ -20175,11 +19853,11 @@ func Xsqlite3VListAdd(tls *libc.TLS, db uintptr, pIn uintptr, zName uintptr, nNa nInt = ((nName / 4) + 3) // Verify ok to add new elements - if (pIn == uintptr(0)) || ((*(*VList)(unsafe.Pointer(pIn + uintptr(1)*4)) + nInt) > *(*VList)(unsafe.Pointer(pIn + uintptr(0)*4))) { + if (pIn == uintptr(0)) || ((*(*VList)(unsafe.Pointer(pIn + 1*4)) + nInt) > *(*VList)(unsafe.Pointer(pIn))) { // Enlarge the allocation var nAlloc Sqlite3_int64 = ((func() int64 { if pIn != 0 { - return (int64(2) * Sqlite3_int64(*(*VList)(unsafe.Pointer(pIn + uintptr(0)*4)))) + return (int64(2) * Sqlite3_int64(*(*VList)(unsafe.Pointer(pIn)))) } return int64(10) }()) + Sqlite3_int64(nInt)) @@ -20188,16 +19866,16 @@ func Xsqlite3VListAdd(tls *libc.TLS, db uintptr, pIn uintptr, zName uintptr, nNa return pIn } if pIn == uintptr(0) { - *(*VList)(unsafe.Pointer(pOut + uintptr(1)*4)) = 2 + *(*VList)(unsafe.Pointer(pOut + 1*4)) = 2 } pIn = pOut - *(*VList)(unsafe.Pointer(pIn + uintptr(0)*4)) = VList(nAlloc) + *(*VList)(unsafe.Pointer(pIn)) = VList(nAlloc) } - i = *(*VList)(unsafe.Pointer(pIn + uintptr(1)*4)) + i = *(*VList)(unsafe.Pointer(pIn + 1*4)) *(*VList)(unsafe.Pointer(pIn + uintptr(i)*4)) = iVal *(*VList)(unsafe.Pointer(pIn + uintptr((i+1))*4)) = nInt z = (pIn + uintptr((i+2))*4) - *(*VList)(unsafe.Pointer(pIn + uintptr(1)*4)) = (i + nInt) + *(*VList)(unsafe.Pointer(pIn + 1*4)) = (i + nInt) libc.Xmemcpy(tls, z, zName, uint64(nName)) *(*int8)(unsafe.Pointer(z + uintptr(nName))) = int8(0) @@ -20213,7 +19891,7 @@ func Xsqlite3VListNumToName(tls *libc.TLS, pIn uintptr, iVal int32) uintptr { /* if pIn == uintptr(0) { return uintptr(0) } - mx = *(*VList)(unsafe.Pointer(pIn + uintptr(1)*4)) + mx = *(*VList)(unsafe.Pointer(pIn + 1*4)) i = 2 for ok := true; ok; ok = (i < mx) { if *(*VList)(unsafe.Pointer(pIn + uintptr(i)*4)) == iVal { @@ -20232,7 +19910,7 @@ func Xsqlite3VListNameToNum(tls *libc.TLS, pIn uintptr, zName uintptr, nName int if pIn == uintptr(0) { return 0 } - mx = *(*VList)(unsafe.Pointer(pIn + uintptr(1)*4)) + mx = *(*VList)(unsafe.Pointer(pIn + 1*4)) i = 2 for ok := true; ok; ok = (i < mx) { var z uintptr = (pIn + uintptr((i+2))*4) @@ -20350,8 +20028,8 @@ func rehash(tls *libc.TLS, pH uintptr, new_size uint32) int32 { /* sqlite3.c:329 var elem uintptr var next_elem uintptr // For looping over existing elements - if (uint64(new_size) * uint64(unsafe.Sizeof(_ht{}))) > uint64(1024) { - new_size = (uint32(uint64(1024) / uint64(unsafe.Sizeof(_ht{})))) + if (uint64(new_size) * uint64(unsafe.Sizeof(_ht{}))) > SQLITE_MALLOC_SOFT_LIMIT { + new_size = (uint32(SQLITE_MALLOC_SOFT_LIMIT / uint64(unsafe.Sizeof(_ht{})))) } if new_size == (*Hash)(unsafe.Pointer(pH)).Fhtsize { return 0 @@ -22310,165 +21988,79 @@ type unix_syscall = struct { // testing and sandboxing. The following array holds the names and pointers // to all overrideable system calls. var aSyscall = [29]unix_syscall{ - { - FzName: ts + 2288, /* "open" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2288 /* "open" */, FpCurrent: 0}, - { - FzName: ts + 2293, /* "close" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2293 /* "close" */, FpCurrent: 0}, - { - FzName: ts + 2299, /* "access" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2299 /* "access" */, FpCurrent: 0}, - { - FzName: ts + 2306, /* "getcwd" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2306 /* "getcwd" */, FpCurrent: 0}, - { - FzName: ts + 2313, /* "stat" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2313 /* "stat" */, FpCurrent: 0}, // The DJGPP compiler environment looks mostly like Unix, but it // lacks the fcntl() system call. So redefine fcntl() to be something // that always succeeds. This means that locking does not occur under // DJGPP. But it is DOS - what did you expect? - { - FzName: ts + 2318, /* "fstat" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2318 /* "fstat" */, FpCurrent: 0}, - { - FzName: ts + 2324, /* "ftruncate" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2324 /* "ftruncate" */, FpCurrent: 0}, - { - FzName: ts + 2334, /* "fcntl" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2334 /* "fcntl" */, FpCurrent: 0}, - { - FzName: ts + 2340, /* "read" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2340 /* "read" */, FpCurrent: 0}, - { - FzName: ts + 2345, /* "pread" */ - FpCurrent: uintptr(0), - FpDefault: uintptr(0)}, + {FzName: ts + 2345 /* "pread" */}, - { - FzName: ts + 2351, /* "pread64" */ - FpCurrent: uintptr(0), - FpDefault: uintptr(0)}, + {FzName: ts + 2351 /* "pread64" */}, - { - FzName: ts + 2359, /* "write" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2359 /* "write" */, FpCurrent: 0}, - { - FzName: ts + 2365, /* "pwrite" */ - FpCurrent: uintptr(0), - FpDefault: uintptr(0)}, + {FzName: ts + 2365 /* "pwrite" */}, - { - FzName: ts + 2372, /* "pwrite64" */ - FpCurrent: uintptr(0), - FpDefault: uintptr(0)}, + {FzName: ts + 2372 /* "pwrite64" */}, - { - FzName: ts + 2381, /* "fchmod" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2381 /* "fchmod" */, FpCurrent: 0}, - { - FzName: ts + 2388, /* "fallocate" */ - FpCurrent: uintptr(0), - FpDefault: uintptr(0)}, + {FzName: ts + 2388 /* "fallocate" */}, - { - FzName: ts + 2398, /* "unlink" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2398 /* "unlink" */, FpCurrent: 0}, - { - FzName: ts + 2405, /* "openDirectory" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2405 /* "openDirectory" */, FpCurrent: 0}, - { - FzName: ts + 2419, /* "mkdir" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2419 /* "mkdir" */, FpCurrent: 0}, - { - FzName: ts + 2425, /* "rmdir" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2425 /* "rmdir" */, FpCurrent: 0}, - { - FzName: ts + 2431, /* "fchown" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2431 /* "fchown" */, FpCurrent: 0}, - { - FzName: ts + 2438, /* "geteuid" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2438 /* "geteuid" */, FpCurrent: 0}, - { - FzName: ts + 2446, /* "mmap" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2446 /* "mmap" */, FpCurrent: 0}, - { - FzName: ts + 2451, /* "munmap" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2451 /* "munmap" */, FpCurrent: 0}, - { - FzName: ts + 2458, /* "mremap" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2458 /* "mremap" */, FpCurrent: 0}, - { - FzName: ts + 2465, /* "getpagesize" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2465 /* "getpagesize" */, FpCurrent: 0}, - { - FzName: ts + 2477, /* "readlink" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2477 /* "readlink" */, FpCurrent: 0}, - { - FzName: ts + 2486, /* "lstat" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 2486 /* "lstat" */, FpCurrent: 0}, - { - FzName: ts + 2492, /* "ioctl" */ - FpCurrent: uintptr(0), - FpDefault: uintptr(0)}, + {FzName: ts + 2492 /* "ioctl" */}, } /* sqlite3.c:33935:3 */ + // End of the overrideable system calls // On some systems, calls to fchown() will trigger a message in a security // log if they come from non-root processes. So avoid calling fchown() if // we are not running as root. func robustFchown(tls *libc.TLS, fd int32, uid Uid_t, gid Gid_t) int32 { /* sqlite3.c:34105:12: */ - if (*(*func(*libc.TLS) Uid_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(21)*24 + 8 /* &.pCurrent */))))(tls) != 0 { + if (*(*func(*libc.TLS) Uid_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 21*24 + 8 /* &.pCurrent */))))(tls) != 0 { return 0 } - return (*(*func(*libc.TLS, int32, Uid_t, Gid_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(20)*24 + 8 /* &.pCurrent */))))(tls, fd, uid, gid) + return (*(*func(*libc.TLS, int32, Uid_t, Gid_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 20*24 + 8 /* &.pCurrent */))))(tls, fd, uid, gid) } // This is the xSetSystemCall() method of sqlite3_vfs for all of the @@ -22477,13 +22069,13 @@ func robustFchown(tls *libc.TLS, fd int32, uid Uid_t, gid Gid_t) int32 { /* sqli // system call named zName. func unixSetSystemCall(tls *libc.TLS, pNotUsed uintptr, zName uintptr, pNewFunc Sqlite3_syscall_ptr) int32 { /* sqlite3.c:34119:12: */ var i uint32 - var rc int32 = 12 + var rc int32 = SQLITE_NOTFOUND _ = pNotUsed if zName == uintptr(0) { // If no zName is given, restore all system calls to their default // settings and return NULL - rc = 0 + rc = SQLITE_OK for i = uint32(0); uint64(i) < (uint64(unsafe.Sizeof(aSyscall)) / uint64(unsafe.Sizeof(unix_syscall{}))); i++ { if aSyscall[i].FpDefault != 0 { aSyscall[i].FpCurrent = aSyscall[i].FpDefault @@ -22497,7 +22089,7 @@ func unixSetSystemCall(tls *libc.TLS, pNotUsed uintptr, zName uintptr, pNewFunc if aSyscall[i].FpDefault == uintptr(0) { aSyscall[i].FpDefault = aSyscall[i].FpCurrent } - rc = 0 + rc = SQLITE_OK if pNewFunc == uintptr(0) { pNewFunc = aSyscall[i].FpDefault } @@ -22575,24 +22167,24 @@ func robust_open(tls *libc.TLS, z uintptr, f int32, m Mode_t) int32 { /* sqlite3 if m != 0 { m2 = m } else { - m2 = uint32(0644) + m2 = SQLITE_DEFAULT_FILE_PERMISSIONS } for 1 != 0 { - fd = (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(0)*24 + 8 /* &.pCurrent */))))(tls, z, (f | 02000000), int32(m2)) + fd = (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 8 /* &.pCurrent */))))(tls, z, (f | 02000000), int32(m2)) if fd < 0 { - if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 4 { + if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == EINTR { continue } break } - if fd >= 3 { + if fd >= SQLITE_MINIMUM_FILE_DESCRIPTOR { break } - (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(1)*24 + 8 /* &.pCurrent */))))(tls, fd) - Xsqlite3_log(tls, 28, + (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 1*24 + 8 /* &.pCurrent */))))(tls, fd) + Xsqlite3_log(tls, SQLITE_WARNING, ts+2498 /* "attempt to open ..." */, libc.VaList(bp, z, fd)) fd = -1 - if (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(0)*24 + 8 /* &.pCurrent */))))(tls, ts+2541 /* "/dev/null" */, 00, int32(m)) < 0 { + if (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 8 /* &.pCurrent */))))(tls, ts+2541 /* "/dev/null" */, O_RDONLY, int32(m)) < 0 { break } } @@ -22600,10 +22192,10 @@ func robust_open(tls *libc.TLS, z uintptr, f int32, m Mode_t) int32 { /* sqlite3 if m != Mode_t(0) { // var statbuf stat at bp+16, 144 - if (((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, fd, bp+16 /* &statbuf */) == 0) && + if (((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, fd, bp+16 /* &statbuf */) == 0) && ((*stat)(unsafe.Pointer(bp+16 /* &statbuf */)).Fst_size == int64(0))) && (((*stat)(unsafe.Pointer(bp+16 /* &statbuf */)).Fst_mode & X__mode_t(0777)) != m) { - (*(*func(*libc.TLS, int32, Mode_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(14)*24 + 8 /* &.pCurrent */))))(tls, fd, m) + (*(*func(*libc.TLS, int32, Mode_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 14*24 + 8 /* &.pCurrent */))))(tls, fd, m) } } } @@ -22652,8 +22244,8 @@ func unixLeaveMutex(tls *libc.TLS) { /* sqlite3.c:34289:13: */ // could lead to a corrupt database. func robust_ftruncate(tls *libc.TLS, h int32, sz Sqlite3_int64) int32 { /* sqlite3.c:34385:12: */ var rc int32 - for ok := true; ok; ok = ((rc < 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 4)) { - rc = (*(*func(*libc.TLS, int32, Off_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(6)*24 + 8 /* &.pCurrent */))))(tls, h, int64(sz)) + for ok := true; ok; ok = ((rc < 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == EINTR)) { + rc = (*(*func(*libc.TLS, int32, Off_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 6*24 + 8 /* &.pCurrent */))))(tls, h, int64(sz)) } return rc } @@ -22669,23 +22261,23 @@ func robust_ftruncate(tls *libc.TLS, h int32, sz Sqlite3_int64) int32 { /* sqlit func sqliteErrorFromPosixError(tls *libc.TLS, posixError int32, sqliteIOErr int32) int32 { /* sqlite3.c:34410:12: */ switch posixError { - case 13: + case EACCES: fallthrough - case 11: + case EAGAIN: fallthrough - case 110: + case ETIMEDOUT: fallthrough - case 16: + case EBUSY: fallthrough - case 4: + case EINTR: fallthrough - case 37: + case ENOLCK: // random NFS retry error, unless during file system support // introspection, in which it actually means what it says - return 5 + return SQLITE_BUSY - case 1: - return 3 + case EPERM: + return SQLITE_PERM default: return sqliteIOErr @@ -22822,6 +22414,7 @@ type unixFileId = struct { // // Must hold unixBigLock in order to read or write this variable. var inodeList uintptr = uintptr(0) /* sqlite3.c:34734:22 */ + // All unixInodeInfo objects // @@ -22873,8 +22466,8 @@ func unixLogErrorAtLine(tls *libc.TLS, errcode int32, zFunc uintptr, zPath uintp // So we don't even try to recover from an EINTR. Just log the error // and move on. func robust_close(tls *libc.TLS, pFile uintptr, h int32, lineno int32) { /* sqlite3.c:34834:13: */ - if (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(1)*24 + 8 /* &.pCurrent */))))(tls, h) != 0 { - unixLogErrorAtLine(tls, (10 | (int32(16) << 8)), ts+2293, /* "close" */ + if (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 1*24 + 8 /* &.pCurrent */))))(tls, h) != 0 { + unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(16) << 8)), ts+2293, /* "close" */ func() uintptr { if pFile != 0 { return (*UnixFile)(unsafe.Pointer(pFile)).FzPath @@ -22957,10 +22550,10 @@ func findInodeInfo(tls *libc.TLS, pFile uintptr, ppInode uintptr) int32 { /* sql // Get low-level information about the file that we can used to // create a unique name for the file. fd = (*UnixFile)(unsafe.Pointer(pFile)).Fh - rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, fd, bp /* &statbuf */) + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, fd, bp /* &statbuf */) if rc != 0 { storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - return 10 + return SQLITE_IOERR } libc.Xmemset(tls, bp+144 /* &fileId */, 0, uint64(unsafe.Sizeof(unixFileId{}))) @@ -22974,15 +22567,15 @@ func findInodeInfo(tls *libc.TLS, pFile uintptr, ppInode uintptr) int32 { /* sql if pInode == uintptr(0) { pInode = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(UnixInodeInfo{}))) if pInode == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pInode, 0, uint64(unsafe.Sizeof(UnixInodeInfo{}))) libc.Xmemcpy(tls, (pInode /* &.fileId */), bp+144 /* &fileId */, uint64(unsafe.Sizeof(unixFileId{}))) if Xsqlite3Config.FbCoreMutex != 0 { - (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex = Xsqlite3_mutex_alloc(tls, 0) + (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST) if (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex == uintptr(0) { Xsqlite3_free(tls, pInode) - return 7 + return SQLITE_NOMEM } } (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnRef = 1 @@ -22997,7 +22590,7 @@ func findInodeInfo(tls *libc.TLS, pFile uintptr, ppInode uintptr) int32 { /* sql (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnRef++ } *(*uintptr)(unsafe.Pointer(ppInode)) = pInode - return 0 + return SQLITE_OK } // Return TRUE if pFile has been renamed or unlinked since it was first opened. @@ -23007,7 +22600,7 @@ func fileHasMoved(tls *libc.TLS, pFile uintptr) int32 { /* sqlite3.c:35000:12: * // var buf stat at bp, 144 - return (libc.Bool32(((*UnixFile)(unsafe.Pointer(pFile)).FpInode != uintptr(0)) && (((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(4)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, bp /* &buf */) != 0) || + return (libc.Bool32(((*UnixFile)(unsafe.Pointer(pFile)).FpInode != uintptr(0)) && (((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 4*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, bp /* &buf */) != 0) || (U64((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_ino) != (*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FfileId.Fino)))) } @@ -23027,25 +22620,25 @@ func verifyDbFile(tls *libc.TLS, pFile uintptr) { /* sqlite3.c:35021:13: */ var rc int32 // These verifications occurs for the main database only - if (int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags) & 0x80) != 0 { + if (int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags) & UNIXFILE_NOLOCK) != 0 { return } - rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, bp+32 /* &buf */) + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, bp+32 /* &buf */) if rc != 0 { - Xsqlite3_log(tls, 28, ts+2582 /* "cannot fstat db ..." */, libc.VaList(bp, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) + Xsqlite3_log(tls, SQLITE_WARNING, ts+2582 /* "cannot fstat db ..." */, libc.VaList(bp, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) return } if (*stat)(unsafe.Pointer(bp+32 /* &buf */)).Fst_nlink == uint64(0) { - Xsqlite3_log(tls, 28, ts+2606 /* "file unlinked wh..." */, libc.VaList(bp+8, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) + Xsqlite3_log(tls, SQLITE_WARNING, ts+2606 /* "file unlinked wh..." */, libc.VaList(bp+8, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) return } if (*stat)(unsafe.Pointer(bp+32 /* &buf */)).Fst_nlink > uint64(1) { - Xsqlite3_log(tls, 28, ts+2635 /* "multiple links t..." */, libc.VaList(bp+16, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) + Xsqlite3_log(tls, SQLITE_WARNING, ts+2635 /* "multiple links t..." */, libc.VaList(bp+16, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) return } if fileHasMoved(tls, pFile) != 0 { - Xsqlite3_log(tls, 28, ts+2662 /* "file renamed whi..." */, libc.VaList(bp+24, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) + Xsqlite3_log(tls, SQLITE_WARNING, ts+2662 /* "file renamed whi..." */, libc.VaList(bp+24, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) return } } @@ -23058,14 +22651,14 @@ func unixCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int32 { / bp := tls.Alloc(40) defer tls.Free(40) - var rc int32 = 0 + var rc int32 = SQLITE_OK var reserved int32 = 0 var pFile uintptr = id Xsqlite3_mutex_enter(tls, (*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FpLockMutex) // Check if a thread in this process holds such a lock - if int32((*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FeFileLock) > 1 { + if int32((*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FeFileLock) > SHARED_LOCK { reserved = 1 } @@ -23073,14 +22666,14 @@ func unixCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int32 { / if !(reserved != 0) && !(int32((*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FbProcessLock) != 0) { // var lock flock at bp+8, 32 - (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_whence = int16(0) + (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_whence = SEEK_SET (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_start = (X__off64_t(Xsqlite3PendingByte + 1)) (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_len = int64(1) - (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_type = int16(1) - if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(7)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, 5, libc.VaList(bp, bp+8 /* &lock */)) != 0 { - rc = (10 | (int32(14) << 8)) + (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_type = F_WRLCK + if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 7*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, F_GETLK64, libc.VaList(bp, bp+8 /* &lock */)) != 0 { + rc = (SQLITE_IOERR | (int32(14) << 8)) storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - } else if int32((*flock)(unsafe.Pointer(bp+8 /* &lock */)).Fl_type) != 2 { + } else if int32((*flock)(unsafe.Pointer(bp+8 /* &lock */)).Fl_type) != F_UNLCK { reserved = 1 } } @@ -23127,15 +22720,15 @@ func unixFileLock(tls *libc.TLS, pFile uintptr, pLock uintptr) int32 { /* sqlite var rc int32 var pInode uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FpInode - if (int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags) & (0x01 | 0x02)) == 0x01 { + if (int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags) & (UNIXFILE_EXCL | UNIXFILE_RDONLY)) == UNIXFILE_EXCL { if int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FbProcessLock) == 0 { // var lock flock at bp+16, 32 - (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_whence = int16(0) + (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_whence = SEEK_SET (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_start = (X__off64_t(Xsqlite3PendingByte + 2)) - (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_len = int64(510) - (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_type = int16(1) - rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(7)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, 6, libc.VaList(bp, bp+16 /* &lock */)) + (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_len = SHARED_SIZE + (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_type = F_WRLCK + rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 7*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, F_SETLK64, libc.VaList(bp, bp+16 /* &lock */)) if rc < 0 { return rc } @@ -23145,7 +22738,7 @@ func unixFileLock(tls *libc.TLS, pFile uintptr, pLock uintptr) int32 { /* sqlite rc = 0 } } else { - rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(7)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, 6, libc.VaList(bp+8, pLock)) + rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 7*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, F_SETLK64, libc.VaList(bp+8, pLock)) } return rc } @@ -23220,7 +22813,7 @@ func unixLock(tls *libc.TLS, id uintptr, eFileLock int32) int32 { /* sqlite3.c:3 // var lock flock at bp, 32 var tErrno int32 - rc = 0 + rc = SQLITE_OK pFile = id tErrno = 0 @@ -23231,7 +22824,7 @@ func unixLock(tls *libc.TLS, id uintptr, eFileLock int32) int32 { /* sqlite3.c:3 goto __1 } - return 0 + return SQLITE_OK __1: ; @@ -23246,10 +22839,10 @@ __1: // If some thread using this PID has a lock via a different unixFile* // handle that precludes the requested lock, return BUSY. - if !((int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) != int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock)) && ((int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) >= 3) || (eFileLock > 1))) { + if !((int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) != int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock)) && ((int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) >= PENDING_LOCK) || (eFileLock > SHARED_LOCK))) { goto __2 } - rc = 5 + rc = SQLITE_BUSY goto end_lock __2: ; @@ -23257,11 +22850,11 @@ __2: // If a SHARED lock is requested, and some thread using this PID already // has a SHARED or RESERVED lock, then increment reference counts and // return SQLITE_OK. - if !((eFileLock == 1) && ((int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == 1) || (int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == 2))) { + if !((eFileLock == SHARED_LOCK) && ((int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == SHARED_LOCK) || (int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == RESERVED_LOCK))) { goto __3 } - (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(1) + (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = SHARED_LOCK (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared++ (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnLock++ goto end_lock @@ -23272,24 +22865,24 @@ __3: // acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will // be released. (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_len = 1 - (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_whence = int16(0) - if !((eFileLock == 1) || - ((eFileLock == 4) && (int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) < 3))) { + (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_whence = SEEK_SET + if !((eFileLock == SHARED_LOCK) || + ((eFileLock == EXCLUSIVE_LOCK) && (int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) < PENDING_LOCK))) { goto __4 } (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_type = func() int16 { - if eFileLock == 1 { - return int16(0) + if eFileLock == SHARED_LOCK { + return F_RDLCK } - return int16(1) + return F_WRLCK }() (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_start = X__off64_t(Xsqlite3PendingByte) if !(unixFileLock(tls, pFile, bp /* &lock */) != 0) { goto __5 } tErrno = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) - rc = sqliteErrorFromPosixError(tls, tErrno, (10 | (int32(15) << 8))) - if !(rc != 5) { + rc = sqliteErrorFromPosixError(tls, tErrno, (SQLITE_IOERR | (int32(15) << 8))) + if !(rc != SQLITE_BUSY) { goto __6 } storeLastErrno(tls, pFile, tErrno) @@ -23303,38 +22896,38 @@ __4: // If control gets to this point, then actually go ahead and make // operating system calls for the specified lock. - if !(eFileLock == 1) { + if !(eFileLock == SHARED_LOCK) { goto __7 } // Now get the read-lock (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_start = (X__off64_t(Xsqlite3PendingByte + 2)) - (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_len = int64(510) + (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_len = SHARED_SIZE if !(unixFileLock(tls, pFile, bp /* &lock */) != 0) { goto __9 } tErrno = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) - rc = sqliteErrorFromPosixError(tls, tErrno, (10 | (int32(15) << 8))) + rc = sqliteErrorFromPosixError(tls, tErrno, (SQLITE_IOERR | (int32(15) << 8))) __9: ; // Drop the temporary PENDING lock (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_start = X__off64_t(Xsqlite3PendingByte) (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_len = 1 - (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_type = int16(2) - if !((unixFileLock(tls, pFile, bp /* &lock */) != 0) && (rc == 0)) { + (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_type = F_UNLCK + if !((unixFileLock(tls, pFile, bp /* &lock */) != 0) && (rc == SQLITE_OK)) { goto __10 } // This could happen with a network mount tErrno = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) - rc = (10 | (int32(8) << 8)) + rc = (SQLITE_IOERR | (int32(8) << 8)) __10: ; if !(rc != 0) { goto __11 } - if !(rc != 5) { + if !(rc != SQLITE_BUSY) { goto __13 } storeLastErrno(tls, pFile, tErrno) @@ -23343,28 +22936,28 @@ __13: goto end_lock goto __12 __11: - (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(1) + (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = SHARED_LOCK (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnLock++ (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared = 1 __12: ; goto __8 __7: - if !((eFileLock == 4) && ((*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared > 1)) { + if !((eFileLock == EXCLUSIVE_LOCK) && ((*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared > 1)) { goto __14 } // We are trying for an exclusive lock but another thread in this // same process is still holding a shared lock. - rc = 5 + rc = SQLITE_BUSY goto __15 __14: // The request was for a RESERVED or EXCLUSIVE lock. It is // assumed that there is a SHARED or greater lock on the file // already. ; - (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_type = int16(1) + (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_type = F_WRLCK - if !(eFileLock == 2) { + if !(eFileLock == RESERVED_LOCK) { goto __16 } (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_start = (X__off64_t(Xsqlite3PendingByte + 1)) @@ -23372,7 +22965,7 @@ __14: goto __17 __16: (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_start = (X__off64_t(Xsqlite3PendingByte + 2)) - (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_len = int64(510) + (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_len = SHARED_SIZE __17: ; @@ -23380,8 +22973,8 @@ __17: goto __18 } tErrno = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) - rc = sqliteErrorFromPosixError(tls, tErrno, (10 | (int32(15) << 8))) - if !(rc != 5) { + rc = sqliteErrorFromPosixError(tls, tErrno, (SQLITE_IOERR | (int32(15) << 8))) + if !(rc != SQLITE_BUSY) { goto __19 } storeLastErrno(tls, pFile, tErrno) @@ -23394,18 +22987,18 @@ __15: __8: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __20 } (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(eFileLock) (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(eFileLock) goto __21 __20: - if !(eFileLock == 4) { + if !(eFileLock == EXCLUSIVE_LOCK) { goto __22 } - (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(3) - (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(3) + (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = PENDING_LOCK + (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = PENDING_LOCK __22: ; __21: @@ -23450,18 +23043,18 @@ func posixUnlock(tls *libc.TLS, id uintptr, eFileLock int32, handleNFSUnlock int var rc int32 pFile = id - rc = 0 + rc = SQLITE_OK if !(int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) <= eFileLock) { goto __1 } - return 0 + return SQLITE_OK __1: ; pInode = (*UnixFile)(unsafe.Pointer(pFile)).FpInode Xsqlite3_mutex_enter(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) - if !(int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) > 1) { + if !(int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) > SHARED_LOCK) { goto __2 } @@ -23473,15 +23066,15 @@ __1: // 2: [....W] // 3: [RRRRW] // 4: [RRRR.] - if !(eFileLock == 1) { + if !(eFileLock == SHARED_LOCK) { goto __3 } _ = handleNFSUnlock - (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_type = int16(0) - (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_whence = int16(0) + (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_type = F_RDLCK + (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_whence = SEEK_SET (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_start = (X__off64_t(Xsqlite3PendingByte + 2)) - (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_len = int64(510) + (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_len = SHARED_SIZE if !(unixFileLock(tls, pFile, bp /* &lock */) != 0) { goto __4 } @@ -23491,7 +23084,7 @@ __1: // protocol. If this happens, return SQLITE_IOERR_RDLOCK. Returning // SQLITE_BUSY would confuse the upper layer (in practice it causes // an assert to fail). - rc = (10 | (int32(9) << 8)) + rc = (SQLITE_IOERR | (int32(9) << 8)) storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) goto end_unlock __4: @@ -23499,24 +23092,24 @@ __4: __3: ; - (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_type = int16(2) - (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_whence = int16(0) + (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_type = F_UNLCK + (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_whence = SEEK_SET (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_start = X__off64_t(Xsqlite3PendingByte) (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_len = 2 if !(unixFileLock(tls, pFile, bp /* &lock */) == 0) { goto __5 } - (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(1) + (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = SHARED_LOCK goto __6 __5: - rc = (10 | (int32(8) << 8)) + rc = (SQLITE_IOERR | (int32(8) << 8)) storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) goto end_unlock __6: ; __2: ; - if !(eFileLock == 0) { + if !(eFileLock == NO_LOCK) { goto __7 } // Decrement the shared lock counter. Release the lock using an @@ -23526,19 +23119,19 @@ __2: if !((*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared == 0) { goto __8 } - (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_type = int16(2) - (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_whence = int16(0) + (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_type = F_UNLCK + (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_whence = SEEK_SET (*flock)(unsafe.Pointer(bp /* &lock */)).Fl_start = libc.AssignPtrInt64(bp /* &lock */ +16 /* &.l_len */, 0) if !(unixFileLock(tls, pFile, bp /* &lock */) == 0) { goto __9 } - (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(0) + (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = NO_LOCK goto __10 __9: - rc = (10 | (int32(8) << 8)) + rc = (SQLITE_IOERR | (int32(8) << 8)) storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(0) - (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(0) + (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = NO_LOCK + (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = NO_LOCK __10: ; __8: @@ -23560,7 +23153,7 @@ __7: end_unlock: Xsqlite3_mutex_leave(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __12 } (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(eFileLock) @@ -23597,17 +23190,17 @@ func closeUnixFile(tls *libc.TLS, id uintptr) int32 { /* sqlite3.c:35634:12: */ Xsqlite3_free(tls, (*UnixFile)(unsafe.Pointer(pFile)).FpPreallocatedUnused) libc.Xmemset(tls, pFile, 0, uint64(unsafe.Sizeof(UnixFile{}))) - return 0 + return SQLITE_OK } // Close a file. func unixClose(tls *libc.TLS, id uintptr) int32 { /* sqlite3.c:35669:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pFile uintptr = id var pInode uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FpInode verifyDbFile(tls, pFile) - unixUnlock(tls, id, 0) + unixUnlock(tls, id, NO_LOCK) unixEnterMutex(tls) @@ -23653,19 +23246,19 @@ func unixClose(tls *libc.TLS, id uintptr) int32 { /* sqlite3.c:35669:12: */ func nolockCheckReservedLock(tls *libc.TLS, NotUsed uintptr, pResOut uintptr) int32 { /* sqlite3.c:35720:12: */ _ = NotUsed *(*int32)(unsafe.Pointer(pResOut)) = 0 - return 0 + return SQLITE_OK } func nolockLock(tls *libc.TLS, NotUsed uintptr, NotUsed2 int32) int32 { /* sqlite3.c:35725:12: */ _ = NotUsed _ = NotUsed2 - return 0 + return SQLITE_OK } func nolockUnlock(tls *libc.TLS, NotUsed uintptr, NotUsed2 int32) int32 { /* sqlite3.c:35729:12: */ _ = NotUsed _ = NotUsed2 - return 0 + return SQLITE_OK } // Close the file. @@ -23711,11 +23304,11 @@ func nolockClose(tls *libc.TLS, id uintptr) int32 { /* sqlite3.c:35737:12: */ // variation of CheckReservedLock(), *pResOut is set to true if any lock // is held on the file and false if the file is unlocked. func dotlockCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int32 { /* sqlite3.c:35782:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var reserved int32 = 0 var pFile uintptr = id - reserved = (libc.Bool32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(2)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FlockingContext, 0) == 0)) + reserved = (libc.Bool32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 2*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FlockingContext, 0) == 0)) *(*int32)(unsafe.Pointer(pResOut)) = reserved return rc @@ -23749,27 +23342,27 @@ func dotlockCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int32 func dotlockLock(tls *libc.TLS, id uintptr, eFileLock int32) int32 { /* sqlite3.c:35823:12: */ var pFile uintptr = id var zLockFile uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FlockingContext - var rc int32 = 0 + var rc int32 = SQLITE_OK // If we have any lock, then the lock file already exists. All we have // to do is adjust our internal record of the lock level. - if int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) > 0 { + if int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) > NO_LOCK { (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(eFileLock) // Always update the timestamp on the old file libc.Xutimes(tls, zLockFile, uintptr(0)) - return 0 + return SQLITE_OK } // grab an exclusive lock - rc = (*(*func(*libc.TLS, uintptr, Mode_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(18)*24 + 8 /* &.pCurrent */))))(tls, zLockFile, uint32(0777)) + rc = (*(*func(*libc.TLS, uintptr, Mode_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 18*24 + 8 /* &.pCurrent */))))(tls, zLockFile, uint32(0777)) if rc < 0 { // failed to open/create the lock directory var tErrno int32 = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) - if 17 == tErrno { - rc = 5 + if EEXIST == tErrno { + rc = SQLITE_BUSY } else { - rc = sqliteErrorFromPosixError(tls, tErrno, (10 | (int32(15) << 8))) - if rc != 5 { + rc = sqliteErrorFromPosixError(tls, tErrno, (SQLITE_IOERR | (int32(15) << 8))) + if rc != SQLITE_BUSY { storeLastErrno(tls, pFile, tErrno) } } @@ -23795,38 +23388,38 @@ func dotlockUnlock(tls *libc.TLS, id uintptr, eFileLock int32) int32 { /* sqlite // no-op if possible if int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) == eFileLock { - return 0 + return SQLITE_OK } // To downgrade to shared, simply update our internal notion of the // lock state. No need to mess with the file on disk. - if eFileLock == 1 { - (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(1) - return 0 + if eFileLock == SHARED_LOCK { + (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = SHARED_LOCK + return SQLITE_OK } // To fully unlock the database, delete the lock file - rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(19)*24 + 8 /* &.pCurrent */))))(tls, zLockFile) + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 19*24 + 8 /* &.pCurrent */))))(tls, zLockFile) if rc < 0 { var tErrno int32 = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) - if tErrno == 2 { - rc = 0 + if tErrno == ENOENT { + rc = SQLITE_OK } else { - rc = (10 | (int32(8) << 8)) + rc = (SQLITE_IOERR | (int32(8) << 8)) storeLastErrno(tls, pFile, tErrno) } return rc } - (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(0) - return 0 + (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = NO_LOCK + return SQLITE_OK } // Close a file. Make sure the lock has been released before closing. func dotlockClose(tls *libc.TLS, id uintptr) int32 { /* sqlite3.c:35916:12: */ var pFile uintptr = id - dotlockUnlock(tls, id, 0) + dotlockUnlock(tls, id, NO_LOCK) Xsqlite3_free(tls, (*UnixFile)(unsafe.Pointer(pFile)).FlockingContext) return closeUnixFile(tls, id) } @@ -23928,18 +23521,18 @@ func seekAndRead(tls *libc.TLS, id uintptr, offset Sqlite3_int64, pBuf uintptr, var newOffset I64 for ok := true; ok; ok = (got > 0) { - newOffset = I64(libc.Xlseek(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, int64(offset), 0)) + newOffset = I64(libc.Xlseek(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, int64(offset), SEEK_SET)) if newOffset < int64(0) { storeLastErrno(tls, id, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) return -1 } - got = int32((*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(8)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, pBuf, uint64(cnt))) + got = int32((*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 8*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, pBuf, uint64(cnt))) if got == cnt { break } if got < 0 { - if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 4 { + if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == EINTR { got = 1 continue } @@ -23972,7 +23565,7 @@ func unixRead(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Sqlite3 if offset < (*UnixFile)(unsafe.Pointer(pFile)).FmmapSize { if (offset + Sqlite3_int64(amt)) <= (*UnixFile)(unsafe.Pointer(pFile)).FmmapSize { libc.Xmemcpy(tls, pBuf, (((*UnixFile)(unsafe.Pointer(pFile)).FpMapRegion) + uintptr(offset)), uint64(amt)) - return 0 + return SQLITE_OK } else { var nCopy int32 = (int32((*UnixFile)(unsafe.Pointer(pFile)).FmmapSize - offset)) libc.Xmemcpy(tls, pBuf, (((*UnixFile)(unsafe.Pointer(pFile)).FpMapRegion) + uintptr(offset)), uint64(nCopy)) @@ -23984,15 +23577,15 @@ func unixRead(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Sqlite3 got = seekAndRead(tls, pFile, offset, pBuf, amt) if got == amt { - return 0 + return SQLITE_OK } else if got < 0 { // lastErrno set by seekAndRead - return (10 | (int32(1) << 8)) + return (SQLITE_IOERR | (int32(1) << 8)) } else { storeLastErrno(tls, pFile, 0) // not a system error // Unread parts of the buffer must be zero-filled libc.Xmemset(tls, ((pBuf) + uintptr(got)), 0, (uint64(amt - got))) - return (10 | (int32(2) << 8)) + return (SQLITE_IOERR | (int32(2) << 8)) } return int32(0) } @@ -24007,14 +23600,14 @@ func seekAndWriteFd(tls *libc.TLS, fd int32, iOff I64, pBuf uintptr, nBuf int32, nBuf = nBuf & (0x1ffff) - for ok := true; ok; ok = ((rc < 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 4)) { - var iSeek I64 = I64(libc.Xlseek(tls, fd, int64(iOff), 0)) + for ok := true; ok; ok = ((rc < 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == EINTR)) { + var iSeek I64 = I64(libc.Xlseek(tls, fd, int64(iOff), SEEK_SET)) if iSeek < int64(0) { rc = -1 break } - rc = int32((*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(11)*24 + 8 /* &.pCurrent */))))(tls, fd, pBuf, uint64(nBuf))) + rc = int32((*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 11*24 + 8 /* &.pCurrent */))))(tls, fd, pBuf, uint64(nBuf))) } if rc < 0 { @@ -24048,16 +23641,16 @@ func unixWrite(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Sqlite } if amt > wrote { - if (wrote < 0) && ((*UnixFile)(unsafe.Pointer(pFile)).FlastErrno != 28) { + if (wrote < 0) && ((*UnixFile)(unsafe.Pointer(pFile)).FlastErrno != ENOSPC) { // lastErrno set by seekAndWrite - return (10 | (int32(3) << 8)) + return (SQLITE_IOERR | (int32(3) << 8)) } else { storeLastErrno(tls, pFile, 0) // not a system error - return 13 + return SQLITE_FULL } } - return 0 + return SQLITE_OK } // We do not trust systems to provide a working fdatasync(). Some do. @@ -24145,24 +23738,24 @@ func openDirectory(tls *libc.TLS, zFilename uintptr, pFd uintptr) int32 { /* sql var fd int32 = -1 // var zDirname [513]int8 at bp+8, 513 - Xsqlite3_snprintf(tls, 512, bp+8 /* &zDirname[0] */, ts+2690 /* "%s" */, libc.VaList(bp, zFilename)) + Xsqlite3_snprintf(tls, MAX_PATHNAME, bp+8 /* &zDirname[0] */, ts+2690 /* "%s" */, libc.VaList(bp, zFilename)) for ii = int32(libc.Xstrlen(tls, bp+8 /* &zDirname[0] */)); (ii > 0) && (int32(*(*int8)(unsafe.Pointer(bp + 8 /* &zDirname[0] */ + uintptr(ii)))) != '/'); ii-- { } if ii > 0 { *(*int8)(unsafe.Pointer(bp + 8 /* &zDirname[0] */ + uintptr(ii))) = int8(0) } else { - if int32(*(*int8)(unsafe.Pointer(bp + 8 /* &zDirname[0] */ + uintptr(0)))) != '/' { - *(*int8)(unsafe.Pointer(bp + 8 /* &zDirname[0] */ + uintptr(0))) = int8('.') + if int32(*(*int8)(unsafe.Pointer(bp + 8 /* &zDirname[0] */))) != '/' { + *(*int8)(unsafe.Pointer(bp + 8 /* &zDirname[0] */)) = int8('.') } - *(*int8)(unsafe.Pointer(bp + 8 /* &zDirname[0] */ + uintptr(1))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 8 /* &zDirname[0] */ + 1)) = int8(0) } - fd = robust_open(tls, bp+8 /* &zDirname[0] */, (00 | 0), uint32(0)) + fd = robust_open(tls, bp+8 /* &zDirname[0] */, (O_RDONLY | O_BINARY), uint32(0)) if fd >= 0 { } *(*int32)(unsafe.Pointer(pFd)) = fd if fd >= 0 { - return 0 + return SQLITE_OK } return unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 37243), ts+2405 /* "openDirectory" */, bp+8 /* &zDirname[0] */, 37243) } @@ -24187,8 +23780,8 @@ func unixSync(tls *libc.TLS, id uintptr, flags int32) int32 { /* sqlite3.c:37261 var rc int32 var pFile uintptr = id - var isDataOnly int32 = (flags & 0x00010) - var isFullsync int32 = (libc.Bool32((flags & 0x0F) == 0x00003)) + var isDataOnly int32 = (flags & SQLITE_SYNC_DATAONLY) + var isFullsync int32 = (libc.Bool32((flags & 0x0F) == SQLITE_SYNC_FULL)) // Check that one of SQLITE_SYNC_NORMAL or FULL was passed @@ -24199,24 +23792,24 @@ func unixSync(tls *libc.TLS, id uintptr, flags int32) int32 { /* sqlite3.c:37261 if rc != 0 { storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - return unixLogErrorAtLine(tls, (10 | (int32(4) << 8)), ts+2693 /* "full_fsync" */, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 37284) + return unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(4) << 8)), ts+2693 /* "full_fsync" */, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 37284) } // Also fsync the directory containing the file if the DIRSYNC flag // is set. This is a one-time occurrence. Many systems (examples: AIX) // are unable to fsync a directory, so ignore errors on the fsync. - if (int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags) & 0x08) != 0 { + if (int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags) & UNIXFILE_DIRSYNC) != 0 { // var dirfd int32 at bp, 4 - rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(17)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, bp /* &dirfd */) - if rc == 0 { + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 17*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, bp /* &dirfd */) + if rc == SQLITE_OK { full_fsync(tls, *(*int32)(unsafe.Pointer(bp /* dirfd */)), 0, 0) robust_close(tls, pFile, *(*int32)(unsafe.Pointer(bp /* dirfd */)), 37298) } else { - rc = 0 + rc = SQLITE_OK } - *(*uint16)(unsafe.Pointer(pFile + 30 /* &.ctrlFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x08))) + *(*uint16)(unsafe.Pointer(pFile + 30 /* &.ctrlFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(UNIXFILE_DIRSYNC))) } return rc } @@ -24237,7 +23830,7 @@ func unixTruncate(tls *libc.TLS, id uintptr, nByte I64) int32 { /* sqlite3.c:373 rc = robust_ftruncate(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, nByte) if rc != 0 { storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - return unixLogErrorAtLine(tls, (10 | (int32(6) << 8)), ts+2324 /* "ftruncate" */, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 37329) + return unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(6) << 8)), ts+2324 /* "ftruncate" */, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 37329) } else { // If the file was just truncated to a size smaller than the currently @@ -24247,7 +23840,7 @@ func unixTruncate(tls *libc.TLS, id uintptr, nByte I64) int32 { /* sqlite3.c:373 (*UnixFile)(unsafe.Pointer(pFile)).FmmapSize = nByte } - return 0 + return SQLITE_OK } return int32(0) } @@ -24260,11 +23853,11 @@ func unixFileSize(tls *libc.TLS, id uintptr, pSize uintptr) int32 { /* sqlite3.c var rc int32 // var buf stat at bp, 144 - rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, bp /* &buf */) + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, bp /* &buf */) if rc != 0 { storeLastErrno(tls, id, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - return (10 | (int32(7) << 8)) + return (SQLITE_IOERR | (int32(7) << 8)) } *(*I64)(unsafe.Pointer(pSize)) = I64((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_size) @@ -24277,7 +23870,7 @@ func unixFileSize(tls *libc.TLS, id uintptr, pSize uintptr) int32 { /* sqlite3.c *(*I64)(unsafe.Pointer(pSize)) = int64(0) } - return 0 + return SQLITE_OK } // This function is called to handle the SQLITE_FCNTL_SIZE_HINT @@ -24293,8 +23886,8 @@ func fcntlSizeHint(tls *libc.TLS, pFile uintptr, nByte I64) int32 { /* sqlite3.c // var buf stat at bp, 144 // Used to hold return values of fstat() - if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, bp /* &buf */) != 0 { - return (10 | (int32(7) << 8)) + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, bp /* &buf */) != 0 { + return (SQLITE_IOERR | (int32(7) << 8)) } nSize = ((((nByte + I64((*UnixFile)(unsafe.Pointer(pFile)).FszChunk)) - int64(1)) / I64((*UnixFile)(unsafe.Pointer(pFile)).FszChunk)) * I64((*UnixFile)(unsafe.Pointer(pFile)).FszChunk)) @@ -24318,7 +23911,7 @@ func fcntlSizeHint(tls *libc.TLS, pFile uintptr, nByte I64) int32 { /* sqlite3.c } nWrite = seekAndWrite(tls, pFile, iWrite, ts+703 /* "" */, 1) if nWrite != 1 { - return (10 | (int32(3) << 8)) + return (SQLITE_IOERR | (int32(3) << 8)) } } } @@ -24329,7 +23922,7 @@ func fcntlSizeHint(tls *libc.TLS, pFile uintptr, nByte I64) int32 { /* sqlite3.c if (*UnixFile)(unsafe.Pointer(pFile)).FszChunk <= 0 { if robust_ftruncate(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, nByte) != 0 { storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - return unixLogErrorAtLine(tls, (10 | (int32(6) << 8)), ts+2324 /* "ftruncate" */, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 37450) + return unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(6) << 8)), ts+2324 /* "ftruncate" */, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 37450) } } @@ -24337,7 +23930,7 @@ func fcntlSizeHint(tls *libc.TLS, pFile uintptr, nByte I64) int32 { /* sqlite3.c return rc } - return 0 + return SQLITE_OK } // If *pArg is initially negative then this is a query. Set *pArg to @@ -24362,25 +23955,25 @@ func unixFileControl(tls *libc.TLS, id uintptr, op int32, pArg uintptr) int32 { var pFile uintptr = id switch op { - case 1: + case SQLITE_FCNTL_LOCKSTATE: { *(*int32)(unsafe.Pointer(pArg)) = int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) - return 0 + return SQLITE_OK } - case 4: + case SQLITE_FCNTL_LAST_ERRNO: { *(*int32)(unsafe.Pointer(pArg)) = (*UnixFile)(unsafe.Pointer(pFile)).FlastErrno - return 0 + return SQLITE_OK } - case 6: + case SQLITE_FCNTL_CHUNK_SIZE: { (*UnixFile)(unsafe.Pointer(pFile)).FszChunk = *(*int32)(unsafe.Pointer(pArg)) - return 0 + return SQLITE_OK } - case 5: + case SQLITE_FCNTL_SIZE_HINT: { var rc int32 @@ -24389,44 +23982,44 @@ func unixFileControl(tls *libc.TLS, id uintptr, op int32, pArg uintptr) int32 { return rc } - case 10: + case SQLITE_FCNTL_PERSIST_WAL: { - unixModeBit(tls, pFile, uint8(0x04), pArg) - return 0 + unixModeBit(tls, pFile, UNIXFILE_PERSIST_WAL, pArg) + return SQLITE_OK } - case 13: + case SQLITE_FCNTL_POWERSAFE_OVERWRITE: { - unixModeBit(tls, pFile, uint8(0x10), pArg) - return 0 + unixModeBit(tls, pFile, UNIXFILE_PSOW, pArg) + return SQLITE_OK } - case 12: + case SQLITE_FCNTL_VFSNAME: { *(*uintptr)(unsafe.Pointer(pArg)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp, (*Sqlite3_vfs)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpVfs)).FzName)) - return 0 + return SQLITE_OK } - case 16: + case SQLITE_FCNTL_TEMPFILENAME: { var zTFile uintptr = Xsqlite3_malloc64(tls, uint64((*Sqlite3_vfs)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpVfs)).FmxPathname)) if zTFile != 0 { unixGetTempname(tls, (*Sqlite3_vfs)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpVfs)).FmxPathname, zTFile) *(*uintptr)(unsafe.Pointer(pArg)) = zTFile } - return 0 + return SQLITE_OK } - case 20: + case SQLITE_FCNTL_HAS_MOVED: { *(*int32)(unsafe.Pointer(pArg)) = fileHasMoved(tls, pFile) - return 0 + return SQLITE_OK } - case 18: + case SQLITE_FCNTL_MMAP_SIZE: { var newLimit I64 = *(*I64)(unsafe.Pointer(pArg)) - var rc int32 = 0 + var rc int32 = SQLITE_OK if newLimit > Xsqlite3Config.FmxMmap { newLimit = Xsqlite3Config.FmxMmap } @@ -24450,7 +24043,7 @@ func unixFileControl(tls *libc.TLS, id uintptr, op int32, pArg uintptr) int32 { } } - return 12 + return SQLITE_NOTFOUND } // If pFd->sectorSize is non-zero when this function is called, it is a @@ -24465,11 +24058,11 @@ func setDeviceCharacteristics(tls *libc.TLS, pFd uintptr) { /* sqlite3.c:37610:1 if (*UnixFile)(unsafe.Pointer(pFd)).FsectorSize == 0 { // Set the POWERSAFE_OVERWRITE flag if requested. - if (int32((*UnixFile)(unsafe.Pointer(pFd)).FctrlFlags) & 0x10) != 0 { - *(*int32)(unsafe.Pointer(pFd + 116 /* &.deviceCharacteristics */)) |= (0x00001000) + if (int32((*UnixFile)(unsafe.Pointer(pFd)).FctrlFlags) & UNIXFILE_PSOW) != 0 { + *(*int32)(unsafe.Pointer(pFd + 116 /* &.deviceCharacteristics */)) |= (SQLITE_IOCAP_POWERSAFE_OVERWRITE) } - (*UnixFile)(unsafe.Pointer(pFd)).FsectorSize = 4096 + (*UnixFile)(unsafe.Pointer(pFd)).FsectorSize = SQLITE_DEFAULT_SECTOR_SIZE } } @@ -24525,7 +24118,7 @@ func unixShmSystemLock(tls *libc.TLS, pFile uintptr, lockType int32, ofst int32, var pShmNode uintptr // Apply locks to this open shared-memory segment // var f flock at bp+8, 32 // The posix advisory locking structure - var rc int32 = 0 // Result code form fcntl() + var rc int32 = SQLITE_OK // Result code form fcntl() // Access to the unixShmNode object is serialized by the caller pShmNode = (*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FpShmNode @@ -24538,12 +24131,12 @@ func unixShmSystemLock(tls *libc.TLS, pFile uintptr, lockType int32, ofst int32, var res int32 // Initialize the locking parameters (*flock)(unsafe.Pointer(bp + 8 /* &f */)).Fl_type = int16(lockType) - (*flock)(unsafe.Pointer(bp + 8 /* &f */)).Fl_whence = int16(0) + (*flock)(unsafe.Pointer(bp + 8 /* &f */)).Fl_whence = SEEK_SET (*flock)(unsafe.Pointer(bp + 8 /* &f */)).Fl_start = X__off64_t(ofst) (*flock)(unsafe.Pointer(bp + 8 /* &f */)).Fl_len = X__off64_t(n) - res = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(7)*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, 6, libc.VaList(bp, bp+8 /* &f */)) + res = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 7*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, F_SETLK64, libc.VaList(bp, bp+8 /* &f */)) if res == -1 { - rc = 5 + rc = SQLITE_BUSY } } @@ -24560,8 +24153,8 @@ func unixShmSystemLock(tls *libc.TLS, pFile uintptr, lockType int32, ofst int32, // to use 64KB pages - in this case each mapping must cover at least two // shm regions. func unixShmRegionPerMap(tls *libc.TLS) int32 { /* sqlite3.c:37931:12: */ - var shmsz int32 = (32 * 1024) // SHM region size - var pgsz int32 = (*(*func(*libc.TLS) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(25)*24 + 8 /* &.pCurrent */))))(tls) // System page size + var shmsz int32 = (32 * 1024) // SHM region size + var pgsz int32 = (*(*func(*libc.TLS) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 25*24 + 8 /* &.pCurrent */))))(tls) // System page size // Page size must be a power of 2 if pgsz < shmsz { return 1 @@ -24583,7 +24176,7 @@ func unixShmPurge(tls *libc.TLS, pFd uintptr) { /* sqlite3.c:37945:13: */ Xsqlite3_mutex_free(tls, (*UnixShmNode)(unsafe.Pointer(p)).FpShmMutex) for i = 0; i < int32((*UnixShmNode)(unsafe.Pointer(p)).FnRegion); i = i + (nShmPerMap) { if (*UnixShmNode)(unsafe.Pointer(p)).FhShm >= 0 { - (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(23)*24 + 8 /* &.pCurrent */))))(tls, *(*uintptr)(unsafe.Pointer((*UnixShmNode)(unsafe.Pointer(p)).FapRegion + uintptr(i)*8)), uint64((*UnixShmNode)(unsafe.Pointer(p)).FszRegion)) + (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 23*24 + 8 /* &.pCurrent */))))(tls, *(*uintptr)(unsafe.Pointer((*UnixShmNode)(unsafe.Pointer(p)).FapRegion + uintptr(i)*8)), uint64((*UnixShmNode)(unsafe.Pointer(p)).FszRegion)) } else { Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*UnixShmNode)(unsafe.Pointer(p)).FapRegion + uintptr(i)*8))) } @@ -24611,7 +24204,7 @@ func unixLockSharedMemory(tls *libc.TLS, pDbFd uintptr, pShmNode uintptr) int32 // var lock flock at bp+8, 32 - var rc int32 = 0 + var rc int32 = SQLITE_OK // Use F_GETLK to determine the locks other processes are holding // on the DMS byte. If it indicates that another process is holding @@ -24631,34 +24224,34 @@ func unixLockSharedMemory(tls *libc.TLS, pDbFd uintptr, pShmNode uintptr) int32 // process might open and use the *-shm file without truncating it. // And if the *-shm file has been corrupted by a power failure or // system crash, the database itself may also become corrupt. - (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_whence = int16(0) - (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_start = (int64(((22 + 8) * 4) + 8)) + (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_whence = SEEK_SET + (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_start = (int64(((22 + SQLITE_SHM_NLOCK) * 4) + SQLITE_SHM_NLOCK)) (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_len = int64(1) - (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_type = int16(1) - if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(7)*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, 5, libc.VaList(bp, bp+8 /* &lock */)) != 0 { - rc = (10 | (int32(15) << 8)) - } else if int32((*flock)(unsafe.Pointer(bp+8 /* &lock */)).Fl_type) == 2 { + (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_type = F_WRLCK + if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 7*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, F_GETLK64, libc.VaList(bp, bp+8 /* &lock */)) != 0 { + rc = (SQLITE_IOERR | (int32(15) << 8)) + } else if int32((*flock)(unsafe.Pointer(bp+8 /* &lock */)).Fl_type) == F_UNLCK { if (*UnixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 { (*UnixShmNode)(unsafe.Pointer(pShmNode)).FisUnlocked = U8(1) - rc = (8 | (int32(5) << 8)) + rc = (SQLITE_READONLY | (int32(5) << 8)) } else { - rc = unixShmSystemLock(tls, pDbFd, 1, (((22 + 8) * 4) + 8), 1) + rc = unixShmSystemLock(tls, pDbFd, F_WRLCK, (((22 + SQLITE_SHM_NLOCK) * 4) + SQLITE_SHM_NLOCK), 1) // The first connection to attach must truncate the -shm file. We // truncate to 3 bytes (an arbitrary small number, less than the // -shm header size) rather than 0 as a system debugging aid, to // help detect if a -shm file truncation is legitimate or is the work // or a rogue process. - if (rc == 0) && (robust_ftruncate(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int64(3)) != 0) { - rc = unixLogErrorAtLine(tls, (10 | (int32(18) << 8)), ts+2324 /* "ftruncate" */, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename, 38019) + if (rc == SQLITE_OK) && (robust_ftruncate(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int64(3)) != 0) { + rc = unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(18) << 8)), ts+2324 /* "ftruncate" */, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename, 38019) } } - } else if int32((*flock)(unsafe.Pointer(bp+8 /* &lock */)).Fl_type) == 1 { - rc = 5 + } else if int32((*flock)(unsafe.Pointer(bp+8 /* &lock */)).Fl_type) == F_WRLCK { + rc = SQLITE_BUSY } - if rc == 0 { + if rc == SQLITE_OK { - rc = unixShmSystemLock(tls, pDbFd, 0, (((22 + 8) * 4) + 8), 1) + rc = unixShmSystemLock(tls, pDbFd, F_RDLCK, (((22 + SQLITE_SHM_NLOCK) * 4) + SQLITE_SHM_NLOCK), 1) } return rc } @@ -24710,14 +24303,14 @@ func unixOpenSharedMemory(tls *libc.TLS, pDbFd uintptr) int32 { /* sqlite3.c:380 // fstat() info for database file var zBasePath uintptr p = uintptr(0) - rc = 0 // Size of the SHM filename in bytes + rc = SQLITE_OK // Size of the SHM filename in bytes // Allocate space for the new unixShm object. p = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(unixShm{}))) if !(p == uintptr(0)) { goto __1 } - return 7 + return SQLITE_NOMEM __1: ; libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(unixShm{}))) @@ -24736,10 +24329,10 @@ __1: // Call fstat() to figure out the permissions on the database file. If // a new *-shm file is created, an attempt will be made to create it // with the same permissions. - if !((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pDbFd)).Fh, bp+8 /* &sStat */) != 0) { + if !((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pDbFd)).Fh, bp+8 /* &sStat */) != 0) { goto __3 } - rc = (10 | (int32(7) << 8)) + rc = (SQLITE_IOERR | (int32(7) << 8)) goto shm_open_err __3: ; @@ -24749,12 +24342,12 @@ __3: if !(pShmNode == uintptr(0)) { goto __4 } - rc = 7 + rc = SQLITE_NOMEM goto shm_open_err __4: ; libc.Xmemset(tls, pShmNode, 0, (uint64(unsafe.Sizeof(unixShmNode{})) + uint64(nShmFilename))) - zShm = libc.AssignPtrUintptr(pShmNode+16 /* &.zFilename */, (pShmNode + uintptr(1)*64)) + zShm = libc.AssignPtrUintptr(pShmNode+16 /* &.zFilename */, (pShmNode + 1*64)) Xsqlite3_snprintf(tls, nShmFilename, zShm, ts+2704 /* "%s-shm" */, libc.VaList(bp, zBasePath)) (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = -1 @@ -24763,11 +24356,11 @@ __4: if !(Xsqlite3Config.FbCoreMutex != 0) { goto __5 } - (*unixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex = Xsqlite3_mutex_alloc(tls, 0) + (*unixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST) if !((*unixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex == uintptr(0)) { goto __6 } - rc = 7 + rc = SQLITE_NOMEM goto shm_open_err __6: ; @@ -24780,14 +24373,14 @@ __5: if !(0 == Xsqlite3_uri_boolean(tls, (*UnixFile)(unsafe.Pointer(pDbFd)).FzPath, ts+2711 /* "readonly_shm" */, 0)) { goto __8 } - (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = robust_open(tls, zShm, ((02 | 0100) | 0400000), + (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = robust_open(tls, zShm, ((O_RDWR | O_CREAT) | 0400000), ((*stat)(unsafe.Pointer(bp+8 /* &sStat */)).Fst_mode & X__mode_t(0777))) __8: ; if !((*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm < 0) { goto __9 } - (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = robust_open(tls, zShm, (00 | 0400000), + (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = robust_open(tls, zShm, (O_RDONLY | 0400000), ((*stat)(unsafe.Pointer(bp+8 /* &sStat */)).Fst_mode & X__mode_t(0777))) if !((*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm < 0) { goto __10 @@ -24806,7 +24399,7 @@ __9: robustFchown(tls, (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm, (*stat)(unsafe.Pointer(bp+8 /* &sStat */)).Fst_uid, (*stat)(unsafe.Pointer(bp+8 /* &sStat */)).Fst_gid) rc = unixLockSharedMemory(tls, pDbFd, pShmNode) - if !((rc != 0) && (rc != (8 | (int32(5) << 8)))) { + if !((rc != SQLITE_OK) && (rc != (SQLITE_READONLY | (int32(5) << 8)))) { goto __11 } goto shm_open_err @@ -24881,7 +24474,7 @@ func unixShmMap(tls *libc.TLS, fd uintptr, iRegion int32, szRegion int32, bExten var nByte int32 // Minimum required file size // var sStat stat at bp, 144 pDbFd = fd - rc = 0 + rc = SQLITE_OK nShmPerMap = unixShmRegionPerMap(tls) // If the shared-memory file has not yet been opened, open it now. @@ -24889,7 +24482,7 @@ func unixShmMap(tls *libc.TLS, fd uintptr, iRegion int32, szRegion int32, bExten goto __1 } rc = unixOpenSharedMemory(tls, pDbFd) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __2 } return rc @@ -24905,7 +24498,7 @@ __1: goto __3 } rc = unixLockSharedMemory(tls, pDbFd, pShmNode) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } goto shmpage_out @@ -24931,10 +24524,10 @@ __3: // The requested region is not mapped into this processes address space. // Check to see if it has been allocated (i.e. if the wal-index file is // large enough to contain the requested region). - if !((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, bp /* &sStat */) != 0) { + if !((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, bp /* &sStat */) != 0) { goto __7 } - rc = (10 | (int32(19) << 8)) + rc = (SQLITE_IOERR | (int32(19) << 8)) goto shmpage_out __7: ; @@ -24963,7 +24556,7 @@ __11: goto __14 } zFile = (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename - rc = unixLogErrorAtLine(tls, (10 | (int32(19) << 8)), ts+2359 /* "write" */, zFile, 38288) + rc = unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(19) << 8)), ts+2359 /* "write" */, zFile, 38288) goto shmpage_out __14: ; @@ -24987,7 +24580,7 @@ __6: if !(!(apNew != 0)) { goto __15 } - rc = (10 | (int32(12) << 8)) + rc = (SQLITE_IOERR | (int32(12) << 8)) goto shmpage_out __15: ; @@ -25000,18 +24593,18 @@ __16: if !((*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0) { goto __18 } - pMem = (*(*func(*libc.TLS, uintptr, Size_t, int32, int32, int32, Off_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(22)*24 + 8 /* &.pCurrent */))))(tls, uintptr(0), uint64(nMap), + pMem = (*(*func(*libc.TLS, uintptr, Size_t, int32, int32, int32, Off_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 22*24 + 8 /* &.pCurrent */))))(tls, uintptr(0), uint64(nMap), func() int32 { if (*UnixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 { - return 0x1 + return PROT_READ } - return (0x1 | 0x2) + return (PROT_READ | PROT_WRITE) }(), - 0x01, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, (int64(I64(szRegion) * I64((*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRegion)))) + MAP_SHARED, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, (int64(I64(szRegion) * I64((*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRegion)))) if !(pMem == (libc.UintptrFromInt32(-1))) { goto __20 } - rc = unixLogErrorAtLine(tls, (10 | (int32(21) << 8)), ts+2446 /* "mmap" */, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename, 38315) + rc = unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(21) << 8)), ts+2446 /* "mmap" */, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename, 38315) goto shmpage_out __20: ; @@ -25021,7 +24614,7 @@ __18: if !(pMem == uintptr(0)) { goto __21 } - rc = 7 + rc = SQLITE_NOMEM goto shmpage_out __21: ; @@ -25059,10 +24652,10 @@ __25: *(*uintptr)(unsafe.Pointer(libc.AtomicLoadUintptr(&pp))) = uintptr(0) __26: ; - if !(((*UnixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0) && (rc == 0)) { + if !(((*UnixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0) && (rc == SQLITE_OK)) { goto __27 } - rc = 8 + rc = SQLITE_READONLY __27: ; Xsqlite3_mutex_leave(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) @@ -25082,7 +24675,7 @@ func unixShmLock(tls *libc.TLS, fd uintptr, ofst int32, n int32, flags int32) in var p uintptr = (*UnixFile)(unsafe.Pointer(pDbFd)).FpShm // The shared memory being locked var pX uintptr // For looping over all siblings var pShmNode uintptr = (*UnixShm)(unsafe.Pointer(p)).FpShmNode // The underlying file iNode - var rc int32 = 0 // Result code + var rc int32 = SQLITE_OK // Result code var mask U16 // Mask of locks to take or release // Check that, if this to be a blocking lock, no locks that occur later @@ -25101,7 +24694,7 @@ func unixShmLock(tls *libc.TLS, fd uintptr, ofst int32, n int32, flags int32) in mask = (U16((int32(1) << (ofst + n)) - (int32(1) << ofst))) Xsqlite3_mutex_enter(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) - if (flags & 1) != 0 { + if (flags & SQLITE_SHM_UNLOCK) != 0 { var allMask U16 = U16(0) // Mask of locks held by siblings // See if any siblings hold this same lock @@ -25115,17 +24708,17 @@ func unixShmLock(tls *libc.TLS, fd uintptr, ofst int32, n int32, flags int32) in // Unlock the system-level locks if (int32(mask) & int32(allMask)) == 0 { - rc = unixShmSystemLock(tls, pDbFd, 2, (ofst + ((22 + 8) * 4)), n) + rc = unixShmSystemLock(tls, pDbFd, F_UNLCK, (ofst + ((22 + SQLITE_SHM_NLOCK) * 4)), n) } else { - rc = 0 + rc = SQLITE_OK } // Undo the local locks - if rc == 0 { + if rc == SQLITE_OK { *(*U16)(unsafe.Pointer(p + 20 /* &.exclMask */)) &= U16((^int32(mask))) *(*U16)(unsafe.Pointer(p + 18 /* &.sharedMask */)) &= U16((^int32(mask))) } - } else if (flags & 4) != 0 { + } else if (flags & SQLITE_SHM_SHARED) != 0 { var allShared U16 = U16(0) // Union of locks held by connections other than "p" // Find out which shared locks are already held by sibling connections. @@ -25133,23 +24726,23 @@ func unixShmLock(tls *libc.TLS, fd uintptr, ofst int32, n int32, flags int32) in // SQLITE_BUSY. for pX = (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpFirst; pX != 0; pX = (*UnixShm)(unsafe.Pointer(pX)).FpNext { if (int32((*UnixShm)(unsafe.Pointer(pX)).FexclMask) & int32(mask)) != 0 { - rc = 5 + rc = SQLITE_BUSY break } allShared = U16(int32(allShared) | (int32((*UnixShm)(unsafe.Pointer(pX)).FsharedMask))) } // Get shared locks at the system level, if necessary - if rc == 0 { + if rc == SQLITE_OK { if (int32(allShared) & int32(mask)) == 0 { - rc = unixShmSystemLock(tls, pDbFd, 0, (ofst + ((22 + 8) * 4)), n) + rc = unixShmSystemLock(tls, pDbFd, F_RDLCK, (ofst + ((22 + SQLITE_SHM_NLOCK) * 4)), n) } else { - rc = 0 + rc = SQLITE_OK } } // Get the local shared locks - if rc == 0 { + if rc == SQLITE_OK { *(*U16)(unsafe.Pointer(p + 18 /* &.sharedMask */)) |= U16((int32(mask))) } } else { @@ -25157,16 +24750,16 @@ func unixShmLock(tls *libc.TLS, fd uintptr, ofst int32, n int32, flags int32) in // lock. If any do, return SQLITE_BUSY right away. for pX = (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpFirst; pX != 0; pX = (*UnixShm)(unsafe.Pointer(pX)).FpNext { if ((int32((*UnixShm)(unsafe.Pointer(pX)).FexclMask) & int32(mask)) != 0) || ((int32((*UnixShm)(unsafe.Pointer(pX)).FsharedMask) & int32(mask)) != 0) { - rc = 5 + rc = SQLITE_BUSY break } } // Get the exclusive locks at the system level. Then if successful // also mark the local connection as being locked. - if rc == 0 { - rc = unixShmSystemLock(tls, pDbFd, 1, (ofst + ((22 + 8) * 4)), n) - if rc == 0 { + if rc == SQLITE_OK { + rc = unixShmSystemLock(tls, pDbFd, F_WRLCK, (ofst + ((22 + SQLITE_SHM_NLOCK) * 4)), n) + if rc == SQLITE_OK { *(*U16)(unsafe.Pointer(p + 20 /* &.exclMask */)) |= U16((int32(mask))) } @@ -25203,7 +24796,7 @@ func unixShmUnmap(tls *libc.TLS, fd uintptr, deleteFlag int32) int32 { /* sqlite pDbFd = fd p = (*UnixFile)(unsafe.Pointer(pDbFd)).FpShm if p == uintptr(0) { - return 0 + return SQLITE_OK } pShmNode = (*UnixShm)(unsafe.Pointer(p)).FpShmNode @@ -25227,20 +24820,20 @@ func unixShmUnmap(tls *libc.TLS, fd uintptr, deleteFlag int32) int32 { /* sqlite (*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRef-- if (*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRef == 0 { if (deleteFlag != 0) && ((*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0) { - (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(16)*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename) + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 16*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename) } unixShmPurge(tls, pDbFd) } unixLeaveMutex(tls) - return 0 + return SQLITE_OK } // If it is currently memory mapped, unmap file pFd. func unixUnmapfile(tls *libc.TLS, pFd uintptr) { /* sqlite3.c:38563:13: */ if (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion != 0 { - (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(23)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion, uint64((*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeActual)) + (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 23*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion, uint64((*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeActual)) (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion = uintptr(0) (*UnixFile)(unsafe.Pointer(pFd)).FmmapSize = int64(0) (*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeActual = int64(0) @@ -25266,7 +24859,7 @@ func unixRemapfile(tls *libc.TLS, pFd uintptr, nNew I64) { /* sqlite3.c:38588:13 var pOrig uintptr = (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion // Pointer to current file mapping var nOrig I64 = (*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeActual // Size of pOrig region in bytes var pNew uintptr = uintptr(0) // Location of new mapping - var flags int32 = 0x1 // Flags to pass to mmap() + var flags int32 = PROT_READ // Flags to pass to mmap() if pOrig != 0 { var nReuse I64 = (*UnixFile)(unsafe.Pointer(pFd)).FmmapSize @@ -25274,27 +24867,27 @@ func unixRemapfile(tls *libc.TLS, pFd uintptr, nNew I64) { /* sqlite3.c:38588:13 // Unmap any pages of the existing mapping that cannot be reused. if nReuse != nOrig { - (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(23)*24 + 8 /* &.pCurrent */))))(tls, pReq, (uint64(nOrig - nReuse))) + (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 23*24 + 8 /* &.pCurrent */))))(tls, pReq, (uint64(nOrig - nReuse))) } - pNew = (*(*func(*libc.TLS, uintptr, Size_t, Size_t, int32, uintptr) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(24)*24 + 8 /* &.pCurrent */))))(tls, pOrig, uint64(nReuse), uint64(nNew), 1, 0) + pNew = (*(*func(*libc.TLS, uintptr, Size_t, Size_t, int32, uintptr) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 24*24 + 8 /* &.pCurrent */))))(tls, pOrig, uint64(nReuse), uint64(nNew), MREMAP_MAYMOVE, 0) zErr = ts + 2458 /* "mremap" */ // The attempt to extend the existing mapping failed. Free it. if (pNew == (libc.UintptrFromInt32(-1))) || (pNew == uintptr(0)) { - (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(23)*24 + 8 /* &.pCurrent */))))(tls, pOrig, uint64(nReuse)) + (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 23*24 + 8 /* &.pCurrent */))))(tls, pOrig, uint64(nReuse)) } } // If pNew is still NULL, try to create an entirely new mapping. if pNew == uintptr(0) { - pNew = (*(*func(*libc.TLS, uintptr, Size_t, int32, int32, int32, Off_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(22)*24 + 8 /* &.pCurrent */))))(tls, uintptr(0), uint64(nNew), flags, 0x01, h, int64(0)) + pNew = (*(*func(*libc.TLS, uintptr, Size_t, int32, int32, int32, Off_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 22*24 + 8 /* &.pCurrent */))))(tls, uintptr(0), uint64(nNew), flags, MAP_SHARED, h, int64(0)) } if pNew == (libc.UintptrFromInt32(-1)) { pNew = uintptr(0) nNew = int64(0) - unixLogErrorAtLine(tls, 0, zErr, (*UnixFile)(unsafe.Pointer(pFd)).FzPath, 38653) + unixLogErrorAtLine(tls, SQLITE_OK, zErr, (*UnixFile)(unsafe.Pointer(pFd)).FzPath, 38653) // If the mmap() above failed, assume that all subsequent mmap() calls // will probably fail too. Fall back to using xRead/xWrite exclusively @@ -25324,14 +24917,14 @@ func unixMapfile(tls *libc.TLS, pFd uintptr, nMap I64) int32 { /* sqlite3.c:3868 defer tls.Free(144) if (*UnixFile)(unsafe.Pointer(pFd)).FnFetchOut > 0 { - return 0 + return SQLITE_OK } if nMap < int64(0) { // var statbuf stat at bp, 144 // Low-level file information - if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFd)).Fh, bp /* &statbuf */) != 0 { - return (10 | (int32(7) << 8)) + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFd)).Fh, bp /* &statbuf */) != 0 { + return (SQLITE_IOERR | (int32(7) << 8)) } nMap = I64((*stat)(unsafe.Pointer(bp /* &statbuf */)).Fst_size) } @@ -25343,7 +24936,7 @@ func unixMapfile(tls *libc.TLS, pFd uintptr, nMap I64) int32 { /* sqlite3.c:3868 unixRemapfile(tls, pFd, nMap) } - return 0 + return SQLITE_OK } // If possible, return a pointer to a mapping of file fd starting at offset @@ -25363,7 +24956,7 @@ func unixFetch(tls *libc.TLS, fd uintptr, iOff I64, nAmt int32, pp uintptr) int3 if (*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeMax > int64(0) { if (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion == uintptr(0) { var rc int32 = unixMapfile(tls, pFd, int64(-1)) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -25372,7 +24965,7 @@ func unixFetch(tls *libc.TLS, fd uintptr, iOff I64, nAmt int32, pp uintptr) int3 (*UnixFile)(unsafe.Pointer(pFd)).FnFetchOut++ } } - return 0 + return SQLITE_OK } // If the third argument is non-NULL, then this function releases a @@ -25399,7 +24992,7 @@ func unixUnfetch(tls *libc.TLS, fd uintptr, iOff I64, p uintptr) int32 { /* sqli unixUnmapfile(tls, pFd) } - return 0 + return SQLITE_OK } // @@ -25444,80 +25037,26 @@ func unixUnfetch(tls *libc.TLS, fd uintptr, iOff I64, p uintptr) int32 { /* sqli // Here are all of the sqlite3_io_methods objects for each of the // locking strategies. Functions that return pointers to these methods // are also created. -var posixIoMethods = Sqlite3_io_methods{ - FiVersion: 3, - FxClose:/* iVersion */ 0, - FxRead:/* xClose */ 0, - FxWrite:/* xRead */ 0, - FxTruncate:/* xWrite */ 0, - FxSync:/* xTruncate */ 0, - FxFileSize:/* xSync */ 0, - FxLock:/* xFileSize */ 0, - FxUnlock:/* xLock */ 0, - FxCheckReservedLock:/* xUnlock */ 0, - FxFileControl:/* xCheckReservedLock */ 0, - FxSectorSize:/* xFileControl */ 0, - FxDeviceCharacteristics:/* xSectorSize */ 0, - FxShmMap:/* xDeviceCapabilities */ 0, - FxShmLock:/* xShmMap */ 0, - FxShmBarrier:/* xShmLock */ 0, - FxShmUnmap:/* xShmBarrier */ 0, - FxFetch:/* xShmUnmap */ 0, - FxUnfetch:/* xFetch */ 0 /* xUnfetch */} /* sqlite3.c:38850:1 */ +var posixIoMethods = Sqlite3_io_methods{FiVersion: 3 /* iVersion */, FxClose: 0 /* xClose */, FxRead: 0 /* xRead */, FxWrite: 0 /* xWrite */, FxTruncate: 0 /* xTruncate */, FxSync: 0 /* xSync */, FxFileSize: 0 /* xFileSize */, FxLock: 0 /* xLock */, FxUnlock: 0 /* xUnlock */, FxCheckReservedLock: 0 /* xCheckReservedLock */, FxFileControl: 0 /* xFileControl */, FxSectorSize: 0 /* xSectorSize */, FxDeviceCharacteristics: 0 /* xDeviceCapabilities */, FxShmMap: 0 /* xShmMap */, FxShmLock: 0 /* xShmLock */, FxShmBarrier: 0 /* xShmBarrier */, FxShmUnmap: 0 /* xShmUnmap */, FxFetch: 0 /* xFetch */, FxUnfetch: 0 /* xUnfetch */} /* sqlite3.c:38850:1 */ + func posixIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) uintptr { /* sqlite3.c:38850:1: */ _ = z _ = p return uintptr(unsafe.Pointer(&posixIoMethods)) } -var posixIoFinder uintptr = 0 /* sqlite3.c:38850:1 */ -var nolockIoMethods = Sqlite3_io_methods{ - FiVersion: 3, - FxClose:/* iVersion */ 0, - FxRead:/* xClose */ 0, - FxWrite:/* xRead */ 0, - FxTruncate:/* xWrite */ 0, - FxSync:/* xTruncate */ 0, - FxFileSize:/* xSync */ 0, - FxLock:/* xFileSize */ 0, - FxUnlock:/* xLock */ 0, - FxCheckReservedLock:/* xUnlock */ 0, - FxFileControl:/* xCheckReservedLock */ 0, - FxSectorSize:/* xFileControl */ 0, - FxDeviceCharacteristics:/* xSectorSize */ 0, - FxShmMap:/* xDeviceCapabilities */ uintptr(0), - FxShmLock:/* xShmMap */ 0, - FxShmBarrier:/* xShmLock */ 0, - FxShmUnmap:/* xShmBarrier */ 0, - FxFetch:/* xShmUnmap */ 0, - FxUnfetch:/* xFetch */ 0 /* xUnfetch */} /* sqlite3.c:38860:1 */ +var posixIoFinder uintptr = 0 /* sqlite3.c:38850:1 */ +var nolockIoMethods = Sqlite3_io_methods{FiVersion: 3 /* iVersion */, FxClose: 0 /* xClose */, FxRead: 0 /* xRead */, FxWrite: 0 /* xWrite */, FxTruncate: 0 /* xTruncate */, FxSync: 0 /* xSync */, FxFileSize: 0 /* xFileSize */, FxLock: 0 /* xLock */, FxUnlock: 0 /* xUnlock */, FxCheckReservedLock: 0 /* xCheckReservedLock */, FxFileControl: 0 /* xFileControl */, FxSectorSize: 0 /* xSectorSize */, FxDeviceCharacteristics: 0 /* xShmMap */, FxShmLock: 0 /* xShmLock */, FxShmBarrier: 0 /* xShmBarrier */, FxShmUnmap: 0 /* xShmUnmap */, FxFetch: 0 /* xFetch */, FxUnfetch: 0 /* xUnfetch */} /* sqlite3.c:38860:1 */ + func nolockIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) uintptr { /* sqlite3.c:38860:1: */ _ = z _ = p return uintptr(unsafe.Pointer(&nolockIoMethods)) } -var nolockIoFinder uintptr = 0 /* sqlite3.c:38860:1 */ -var dotlockIoMethods = Sqlite3_io_methods{ - FiVersion: 1, - FxClose:/* iVersion */ 0, - FxRead:/* xClose */ 0, - FxWrite:/* xRead */ 0, - FxTruncate:/* xWrite */ 0, - FxSync:/* xTruncate */ 0, - FxFileSize:/* xSync */ 0, - FxLock:/* xFileSize */ 0, - FxUnlock:/* xLock */ 0, - FxCheckReservedLock:/* xUnlock */ 0, - FxFileControl:/* xCheckReservedLock */ 0, - FxSectorSize:/* xFileControl */ 0, - FxDeviceCharacteristics:/* xSectorSize */ 0, - FxShmMap:/* xDeviceCapabilities */ uintptr(0), - FxShmLock:/* xShmMap */ 0, - FxShmBarrier:/* xShmLock */ 0, - FxShmUnmap:/* xShmBarrier */ 0, - FxFetch:/* xShmUnmap */ 0, - FxUnfetch:/* xFetch */ 0 /* xUnfetch */} /* sqlite3.c:38870:1 */ +var nolockIoFinder uintptr = 0 /* sqlite3.c:38860:1 */ +var dotlockIoMethods = Sqlite3_io_methods{FiVersion: 1 /* iVersion */, FxClose: 0 /* xClose */, FxRead: 0 /* xRead */, FxWrite: 0 /* xWrite */, FxTruncate: 0 /* xTruncate */, FxSync: 0 /* xSync */, FxFileSize: 0 /* xFileSize */, FxLock: 0 /* xLock */, FxUnlock: 0 /* xUnlock */, FxCheckReservedLock: 0 /* xCheckReservedLock */, FxFileControl: 0 /* xFileControl */, FxSectorSize: 0 /* xSectorSize */, FxDeviceCharacteristics: 0 /* xShmMap */, FxShmLock: 0 /* xShmLock */, FxShmBarrier: 0 /* xShmBarrier */, FxShmUnmap: 0 /* xShmUnmap */, FxFetch: 0 /* xFetch */, FxUnfetch: 0 /* xUnfetch */} /* sqlite3.c:38870:1 */ + func dotlockIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) uintptr { /* sqlite3.c:38870:1: */ _ = z _ = p @@ -25553,7 +25092,7 @@ func fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename var pLockingStyle uintptr var pNew uintptr = pId - var rc int32 = 0 + var rc int32 = SQLITE_OK // No locking occurs in temporary files @@ -25563,19 +25102,19 @@ func fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename (*UnixFile)(unsafe.Pointer(pNew)).FctrlFlags = uint16(U8(ctrlFlags)) (*UnixFile)(unsafe.Pointer(pNew)).FmmapSizeMax = Xsqlite3Config.FszMmap if Xsqlite3_uri_boolean(tls, func() uintptr { - if (ctrlFlags & 0x40) != 0 { + if (ctrlFlags & UNIXFILE_URI) != 0 { return zFilename } return uintptr(0) }(), - ts+2724 /* "psow" */, 1) != 0 { - *(*uint16)(unsafe.Pointer(pNew + 30 /* &.ctrlFlags */)) |= uint16((0x10)) + ts+2724 /* "psow" */, SQLITE_POWERSAFE_OVERWRITE) != 0 { + *(*uint16)(unsafe.Pointer(pNew + 30 /* &.ctrlFlags */)) |= uint16((UNIXFILE_PSOW)) } if libc.Xstrcmp(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FzName, ts+2729 /* "unix-excl" */) == 0 { - *(*uint16)(unsafe.Pointer(pNew + 30 /* &.ctrlFlags */)) |= uint16((0x01)) + *(*uint16)(unsafe.Pointer(pNew + 30 /* &.ctrlFlags */)) |= uint16((UNIXFILE_EXCL)) } - if (ctrlFlags & 0x80) != 0 { + if (ctrlFlags & UNIXFILE_NOLOCK) != 0 { pLockingStyle = uintptr(unsafe.Pointer(&nolockIoMethods)) } else { pLockingStyle = (**(**func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer((pVfs + 32 /* &.pAppData */))))(tls, zFilename, pNew) @@ -25584,7 +25123,7 @@ func fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename if pLockingStyle == uintptr(unsafe.Pointer(&posixIoMethods)) { unixEnterMutex(tls) rc = findInodeInfo(tls, pNew, (pNew + 16 /* &.pInode */)) - if rc != 0 { + if rc != SQLITE_OK { // If an error occurred in findInodeInfo(), close the file descriptor // immediately, before releasing the mutex. findInodeInfo() may fail // in two scenarios: @@ -25615,7 +25154,7 @@ func fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename nFilename = (int32(libc.Xstrlen(tls, zFilename)) + 6) zLockFile = Xsqlite3_malloc64(tls, uint64(nFilename)) if zLockFile == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { Xsqlite3_snprintf(tls, nFilename, zLockFile, ts+2739 /* "%s.lock" */, libc.VaList(bp, zFilename)) } @@ -25623,7 +25162,7 @@ func fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename } storeLastErrno(tls, pNew, 0) - if rc != 0 { + if rc != SQLITE_OK { if h >= 0 { robust_close(tls, pNew, h, 39241) } @@ -25654,9 +25193,9 @@ func unixTempFileDir(tls *libc.TLS) uintptr { /* sqlite3.c:39254:19: */ } for 1 != 0 { if (((zDir != uintptr(0)) && - ((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(4)*24 + 8 /* &.pCurrent */))))(tls, zDir, bp /* &buf */) == 0)) && + ((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 4*24 + 8 /* &.pCurrent */))))(tls, zDir, bp /* &buf */) == 0)) && ((((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_mode) & X__mode_t(0170000)) == (X__mode_t(0040000)))) && - ((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(2)*24 + 8 /* &.pCurrent */))))(tls, zDir, 03) == 0) { + ((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 2*24 + 8 /* &.pCurrent */))))(tls, zDir, 03) == 0) { return zDir } if uint64(i) >= (uint64(unsafe.Sizeof(azDirs)) / uint64(unsafe.Sizeof(uintptr(0)))) { @@ -25689,13 +25228,13 @@ func unixGetTempname(tls *libc.TLS, nBuf int32, zBuf uintptr) int32 { /* sqlite3 // It's odd to simulate an io-error here, but really this is just // using the io-error infrastructure to test that SQLite handles this // function failing. - *(*int8)(unsafe.Pointer(zBuf + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(zBuf)) = int8(0) zDir = unixTempFileDir(tls) if zDir == uintptr(0) { - return (10 | (int32(25) << 8)) + return (SQLITE_IOERR | (int32(25) << 8)) } - for ok := true; ok; ok = ((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(2)*24 + 8 /* &.pCurrent */))))(tls, zBuf, 0) == 0) { + for ok := true; ok; ok = ((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 2*24 + 8 /* &.pCurrent */))))(tls, zBuf, 0) == 0) { // var r U64 at bp+24, 8 Xsqlite3_randomness(tls, int32(unsafe.Sizeof(U64(0))), bp+24 /* &r */) @@ -25704,10 +25243,10 @@ func unixGetTempname(tls *libc.TLS, nBuf int32, zBuf uintptr) int32 { /* sqlite3 Xsqlite3_snprintf(tls, nBuf, zBuf, ts+2791, /* "%s/etilqs_%llx%c" */ libc.VaList(bp, zDir, *(*U64)(unsafe.Pointer(bp + 24 /* r */)), 0)) if (int32(*(*int8)(unsafe.Pointer(zBuf + uintptr((nBuf - 2))))) != 0) || ((libc.PostIncInt32(&iLimit, 1)) > 10) { - return 1 + return SQLITE_ERROR } } - return 0 + return SQLITE_OK } // Search for an unused file descriptor that was opened on the database @@ -25748,7 +25287,7 @@ func findReusableFd(tls *libc.TLS, zPath uintptr, flags int32) uintptr { /* sqli // // Even if a subsequent open() call does succeed, the consequences of // not searching for a reusable file descriptor are not dire. - if (inodeList != uintptr(0)) && (0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(4)*24 + 8 /* &.pCurrent */))))(tls, zPath, bp /* &sStat */)) { + if (inodeList != uintptr(0)) && (0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 4*24 + 8 /* &.pCurrent */))))(tls, zPath, bp /* &sStat */)) { var pInode uintptr pInode = inodeList @@ -25760,7 +25299,7 @@ func findReusableFd(tls *libc.TLS, zPath uintptr, flags int32) uintptr { /* sqli var pp uintptr Xsqlite3_mutex_enter(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) - flags = flags & (0x00000001 | 0x00000002) + flags = flags & (SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE) for pp = (pInode + 40 /* &.pUnused */); (*(*uintptr)(unsafe.Pointer(pp)) != 0) && ((*UnixUnusedFd)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pp))))).Fflags != flags); pp = (*(*uintptr)(unsafe.Pointer(pp)) + 8 /* &.pNext */) { } pUnused = *(*uintptr)(unsafe.Pointer(pp)) @@ -25781,13 +25320,13 @@ func getFileMode(tls *libc.TLS, zFile uintptr, pMode uintptr, pUid uintptr, pGid // var sStat stat at bp, 144 // Output of stat() on database file - var rc int32 = 0 - if 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(4)*24 + 8 /* &.pCurrent */))))(tls, zFile, bp /* &sStat */) { + var rc int32 = SQLITE_OK + if 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 4*24 + 8 /* &.pCurrent */))))(tls, zFile, bp /* &sStat */) { *(*Mode_t)(unsafe.Pointer(pMode)) = ((*stat)(unsafe.Pointer(bp /* &sStat */)).Fst_mode & X__mode_t(0777)) *(*Uid_t)(unsafe.Pointer(pUid)) = (*stat)(unsafe.Pointer(bp /* &sStat */)).Fst_uid *(*Gid_t)(unsafe.Pointer(pGid)) = (*stat)(unsafe.Pointer(bp /* &sStat */)).Fst_gid } else { - rc = (10 | (int32(7) << 8)) + rc = (SQLITE_IOERR | (int32(7) << 8)) } return rc } @@ -25815,11 +25354,11 @@ func findCreateFileMode(tls *libc.TLS, zPath uintptr, flags int32, pMode uintptr bp := tls.Alloc(513) defer tls.Free(513) - var rc int32 = 0 // Return Code + var rc int32 = SQLITE_OK // Return Code *(*Mode_t)(unsafe.Pointer(pMode)) = Mode_t(0) *(*Uid_t)(unsafe.Pointer(pUid)) = Uid_t(0) *(*Gid_t)(unsafe.Pointer(pGid)) = Gid_t(0) - if (flags & (0x00080000 | 0x00000800)) != 0 { + if (flags & (SQLITE_OPEN_WAL | SQLITE_OPEN_MAIN_JOURNAL)) != 0 { // var zDb [513]int8 at bp, 513 // Database file path var nDb int32 // Number of valid bytes in zDb @@ -25842,7 +25381,7 @@ func findCreateFileMode(tls *libc.TLS, zPath uintptr, flags int32, pMode uintptr // rollback journal specifies a super-journal with a goofy name, then // the '-' might be missing. if (nDb == 0) || (int32(*(*int8)(unsafe.Pointer(zPath + uintptr(nDb)))) == '.') { - return 0 + return SQLITE_OK } nDb-- } @@ -25850,9 +25389,9 @@ func findCreateFileMode(tls *libc.TLS, zPath uintptr, flags int32, pMode uintptr *(*int8)(unsafe.Pointer(bp /* &zDb[0] */ + uintptr(nDb))) = int8(0) rc = getFileMode(tls, bp /* &zDb[0] */, pMode, pUid, pGid) - } else if (flags & 0x00000008) != 0 { + } else if (flags & SQLITE_OPEN_DELETEONCLOSE) != 0 { *(*Mode_t)(unsafe.Pointer(pMode)) = Mode_t(0600) - } else if (flags & 0x00000040) != 0 { + } else if (flags & SQLITE_OPEN_URI) != 0 { // If this is a main database file and the file was opened using a URI // filename, check for the "modeof" parameter. If present, interpret // its value as a filename and try to copy the mode, uid and gid from @@ -25924,16 +25463,16 @@ func unixOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr, pFile uintptr, flags i fd = -1 openFlags = 0 eType = (flags & 0x0FFF00) - rc = 0 + rc = SQLITE_OK ctrlFlags = 0 - isExclusive = (flags & 0x00000010) - isDelete = (flags & 0x00000008) - isCreate = (flags & 0x00000004) - isReadonly = (flags & 0x00000001) - isReadWrite = (flags & 0x00000002) - isNewJrnl = (libc.Bool32((isCreate != 0) && (((eType == 0x00004000) || - (eType == 0x00000800)) || - (eType == 0x00080000)))) + isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE) + isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE) + isCreate = (flags & SQLITE_OPEN_CREATE) + isReadonly = (flags & SQLITE_OPEN_READONLY) + isReadWrite = (flags & SQLITE_OPEN_READWRITE) + isNewJrnl = (libc.Bool32((isCreate != 0) && (((eType == SQLITE_OPEN_SUPER_JOURNAL) || + (eType == SQLITE_OPEN_MAIN_JOURNAL)) || + (eType == SQLITE_OPEN_WAL)))) zName = zPath // Check the following statements are true: @@ -25961,7 +25500,7 @@ __1: ; libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(UnixFile{}))) - if !(eType == 0x00000100) { + if !(eType == SQLITE_OPEN_MAIN_DB) { goto __2 } pUnused = findReusableFd(tls, zName, flags) @@ -25975,7 +25514,7 @@ __4: if !(!(pUnused != 0)) { goto __6 } - return 7 + return SQLITE_NOMEM __6: ; __5: @@ -25994,7 +25533,7 @@ __2: // If zName is NULL, the upper layer is requesting a temp file. rc = unixGetTempname(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname, bp /* &zTmpname[0] */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __8 } return rc @@ -26017,34 +25556,34 @@ __3: if !(isReadonly != 0) { goto __9 } - openFlags = openFlags | (00) + openFlags = openFlags | (O_RDONLY) __9: ; if !(isReadWrite != 0) { goto __10 } - openFlags = openFlags | (02) + openFlags = openFlags | (O_RDWR) __10: ; if !(isCreate != 0) { goto __11 } - openFlags = openFlags | (0100) + openFlags = openFlags | (O_CREAT) __11: ; if !(isExclusive != 0) { goto __12 } - openFlags = openFlags | (0200 | 0400000) + openFlags = openFlags | (O_EXCL | 0400000) __12: ; - openFlags = openFlags | ((0 | 0) | 0400000) + openFlags = openFlags | ((0 | O_BINARY) | 0400000) if !(fd < 0) { goto __13 } // Groupid for the file rc = findCreateFileMode(tls, zName, flags, bp+516 /* &openMode */, bp+520 /* &uid */, bp+524 /* &gid */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __14 } @@ -26056,22 +25595,22 @@ __14: if !(fd < 0) { goto __15 } - if !(((isNewJrnl != 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 13)) && ((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(2)*24 + 8 /* &.pCurrent */))))(tls, zName, 0) != 0)) { + if !(((isNewJrnl != 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == EACCES)) && ((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 2*24 + 8 /* &.pCurrent */))))(tls, zName, F_OK) != 0)) { goto __16 } // If unable to create a journal because the directory is not // writable, change the error code to indicate that. - rc = (8 | (int32(6) << 8)) + rc = (SQLITE_READONLY | (int32(6) << 8)) goto __17 __16: - if !(((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) != 21) && (isReadWrite != 0)) { + if !(((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) != EISDIR) && (isReadWrite != 0)) { goto __18 } // Failed to open the file for read/write access. Try read-only. - flags = flags & (^libc.Int32((0x00000002 | 0x00000004))) - openFlags = openFlags & (^libc.Int32((02 | 0100))) - flags = flags | (0x00000001) - openFlags = openFlags | (00) + flags = flags & (libc.CplInt32((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE))) + openFlags = openFlags & (libc.CplInt32((O_RDWR | O_CREAT))) + flags = flags | (SQLITE_OPEN_READONLY) + openFlags = openFlags | (O_RDONLY) isReadonly = 1 fd = robust_open(tls, zName, openFlags, *(*Mode_t)(unsafe.Pointer(bp + 516 /* openMode */))) __18: @@ -26084,7 +25623,7 @@ __15: goto __19 } rc2 = unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 39655), ts+2288 /* "open" */, zName, 39655) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __20 } rc = rc2 @@ -26105,7 +25644,7 @@ __19: // If openMode==0, then that means uid and gid are not set correctly // (probably because SQLite is configured to use 8+3 filename mode) and // in that case we do not want to attempt the chown(). - if !((*(*Mode_t)(unsafe.Pointer(bp + 516 /* openMode */)) != 0) && ((flags & (0x00080000 | 0x00000800)) != 0)) { + if !((*(*Mode_t)(unsafe.Pointer(bp + 516 /* openMode */)) != 0) && ((flags & (SQLITE_OPEN_WAL | SQLITE_OPEN_MAIN_JOURNAL)) != 0)) { goto __21 } robustFchown(tls, fd, *(*Uid_t)(unsafe.Pointer(bp + 520 /* uid */)), *(*Gid_t)(unsafe.Pointer(bp + 524 /* gid */))) @@ -26125,14 +25664,14 @@ __22: goto __23 } (*UnixUnusedFd)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused)).Ffd = fd - (*UnixUnusedFd)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused)).Fflags = (flags & (0x00000001 | 0x00000002)) + (*UnixUnusedFd)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused)).Fflags = (flags & (SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE)) __23: ; if !(isDelete != 0) { goto __24 } - (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(16)*24 + 8 /* &.pCurrent */))))(tls, zName) + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 16*24 + 8 /* &.pCurrent */))))(tls, zName) __24: ; @@ -26140,39 +25679,39 @@ __24: if !(isDelete != 0) { goto __25 } - ctrlFlags = ctrlFlags | (0x20) + ctrlFlags = ctrlFlags | (UNIXFILE_DELETE) __25: ; if !(isReadonly != 0) { goto __26 } - ctrlFlags = ctrlFlags | (0x02) + ctrlFlags = ctrlFlags | (UNIXFILE_RDONLY) __26: ; - noLock = (libc.Bool32(eType != 0x00000100)) + noLock = (libc.Bool32(eType != SQLITE_OPEN_MAIN_DB)) if !(noLock != 0) { goto __27 } - ctrlFlags = ctrlFlags | (0x80) + ctrlFlags = ctrlFlags | (UNIXFILE_NOLOCK) __27: ; if !(isNewJrnl != 0) { goto __28 } - ctrlFlags = ctrlFlags | (0x08) + ctrlFlags = ctrlFlags | (UNIXFILE_DIRSYNC) __28: ; - if !((flags & 0x00000040) != 0) { + if !((flags & SQLITE_OPEN_URI) != 0) { goto __29 } - ctrlFlags = ctrlFlags | (0x40) + ctrlFlags = ctrlFlags | (UNIXFILE_URI) __29: ; rc = fillInUnixFile(tls, pVfs, fd, pFile, zPath, ctrlFlags) open_finished: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __30 } Xsqlite3_free(tls, (*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused) @@ -26187,29 +25726,29 @@ func unixDelete(tls *libc.TLS, NotUsed uintptr, zPath uintptr, dirSync int32) in bp := tls.Alloc(4) defer tls.Free(4) - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = NotUsed - if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(16)*24 + 8 /* &.pCurrent */))))(tls, zPath) == (-1) { - if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 2 { - rc = (10 | (int32(23) << 8)) + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 16*24 + 8 /* &.pCurrent */))))(tls, zPath) == (-1) { + if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == ENOENT { + rc = (SQLITE_IOERR | (int32(23) << 8)) } else { - rc = unixLogErrorAtLine(tls, (10 | (int32(10) << 8)), ts+2398 /* "unlink" */, zPath, 39794) + rc = unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(10) << 8)), ts+2398 /* "unlink" */, zPath, 39794) } return rc } if (dirSync & 1) != 0 { // var fd int32 at bp, 4 - rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(17)*24 + 8 /* &.pCurrent */))))(tls, zPath, bp /* &fd */) - if rc == 0 { + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 17*24 + 8 /* &.pCurrent */))))(tls, zPath, bp /* &fd */) + if rc == SQLITE_OK { if full_fsync(tls, *(*int32)(unsafe.Pointer(bp /* fd */)), 0, 0) != 0 { - rc = unixLogErrorAtLine(tls, (10 | (int32(5) << 8)), ts+2815 /* "fsync" */, zPath, 39804) + rc = unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(5) << 8)), ts+2815 /* "fsync" */, zPath, 39804) } robust_close(tls, uintptr(0), *(*int32)(unsafe.Pointer(bp /* fd */)), 39806) } else { - rc = 0 + rc = SQLITE_OK } } return rc @@ -26232,14 +25771,14 @@ func unixAccess(tls *libc.TLS, NotUsed uintptr, zPath uintptr, flags int32, pRes // The spec says there are three possible values for flags. But only // two of them are actually used - if flags == 0 { + if flags == SQLITE_ACCESS_EXISTS { // var buf stat at bp, 144 - *(*int32)(unsafe.Pointer(pResOut)) = (libc.Bool32((0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(4)*24 + 8 /* &.pCurrent */))))(tls, zPath, bp /* &buf */)) && (!((((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_mode) & X__mode_t(0170000)) == (X__mode_t(0100000))) || ((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_size > int64(0))))) + *(*int32)(unsafe.Pointer(pResOut)) = (libc.Bool32((0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 4*24 + 8 /* &.pCurrent */))))(tls, zPath, bp /* &buf */)) && (!((((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_mode) & X__mode_t(0170000)) == (X__mode_t(0100000))) || ((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_size > int64(0))))) } else { - *(*int32)(unsafe.Pointer(pResOut)) = (libc.Bool32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(2)*24 + 8 /* &.pCurrent */))))(tls, zPath, (2|4)) == 0)) + *(*int32)(unsafe.Pointer(pResOut)) = (libc.Bool32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 2*24 + 8 /* &.pCurrent */))))(tls, zPath, (W_OK|R_OK)) == 0)) } - return 0 + return SQLITE_OK } // @@ -26249,8 +25788,8 @@ func mkFullPathname(tls *libc.TLS, zPath uintptr, zOut uintptr, nOut int32) int3 var nPath int32 = Xsqlite3Strlen30(tls, zPath) var iOff int32 = 0 - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) != '/' { - if (*(*func(*libc.TLS, uintptr, Size_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(3)*24 + 8 /* &.pCurrent */))))(tls, zOut, (uint64(nOut-2))) == uintptr(0) { + if int32(*(*int8)(unsafe.Pointer(zPath))) != '/' { + if (*(*func(*libc.TLS, uintptr, Size_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 3*24 + 8 /* &.pCurrent */))))(tls, zOut, (uint64(nOut-2))) == uintptr(0) { return unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 39862), ts+2306 /* "getcwd" */, zPath, 39862) } iOff = Xsqlite3Strlen30(tls, zOut) @@ -26263,7 +25802,7 @@ func mkFullPathname(tls *libc.TLS, zPath uintptr, zOut uintptr, nOut int32) int3 return Xsqlite3CantopenError(tls, 39871) } Xsqlite3_snprintf(tls, (nOut - iOff), (zOut + uintptr(iOff)), ts+2690 /* "%s" */, libc.VaList(bp, zPath)) - return 0 + return SQLITE_OK } // Turn a relative pathname into a full pathname. The relative path @@ -26277,7 +25816,7 @@ func unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zO bp := tls.Alloc(144) defer tls.Free(144) - var rc int32 = 0 + var rc int32 = SQLITE_OK var nByte int32 var nLink int32 = 0 // Number of symbolic links followed so far var zIn uintptr = zPath // Input path for each iteration of loop @@ -26290,15 +25829,15 @@ func unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zO // function failing. This function could fail if, for example, the // current working directory has been unlinked. - for ok := true; ok; ok = (rc == 0) { + for ok := true; ok; ok = (rc == SQLITE_OK) { // Call stat() on path zIn. Set bLink to true if the path is a symbolic // link, or false otherwise. var bLink int32 = 0 // var buf stat at bp, 144 - if (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(27)*24 + 8 /* &.pCurrent */))))(tls, zIn, bp /* &buf */) != 0 { - if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) != 2 { + if (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 27*24 + 8 /* &.pCurrent */))))(tls, zIn, bp /* &buf */) != 0 { + if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) != ENOENT { rc = unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 39919), ts+2486 /* "lstat" */, zIn, 39919) } } else { @@ -26310,18 +25849,18 @@ func unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zO if zDel == uintptr(0) { zDel = Xsqlite3_malloc(tls, nOut) if zDel == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } - } else if nLink >= 100 { + } else if nLink >= SQLITE_MAX_SYMLINKS { rc = Xsqlite3CantopenError(tls, 39931) } - if rc == 0 { - nByte = int32((*(*func(*libc.TLS, uintptr, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(26)*24 + 8 /* &.pCurrent */))))(tls, zIn, zDel, (uint64(nOut - 1)))) + if rc == SQLITE_OK { + nByte = int32((*(*func(*libc.TLS, uintptr, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 26*24 + 8 /* &.pCurrent */))))(tls, zIn, zDel, (uint64(nOut - 1)))) if nByte < 0 { rc = unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 39937), ts+2477 /* "readlink" */, zIn, 39937) } else { - if int32(*(*int8)(unsafe.Pointer(zDel + uintptr(0)))) != '/' { + if int32(*(*int8)(unsafe.Pointer(zDel))) != '/' { var n int32 for n = Xsqlite3Strlen30(tls, zIn); (n > 0) && (int32(*(*int8)(unsafe.Pointer(zIn + uintptr((n - 1))))) != '/'); n-- { } @@ -26340,7 +25879,7 @@ func unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zO zIn = zDel } - if (rc == 0) && (zIn != zOut) { + if (rc == SQLITE_OK) && (zIn != zOut) { rc = mkFullPathname(tls, zIn, zOut, nOut) } if bLink == 0 { @@ -26350,8 +25889,8 @@ func unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zO } Xsqlite3_free(tls, zDel) - if (rc == 0) && (nLink != 0) { - rc = (0 | (int32(2) << 8)) + if (rc == SQLITE_OK) && (nLink != 0) { + rc = (SQLITE_OK | (int32(2) << 8)) } return rc } @@ -26396,7 +25935,7 @@ type Dl_serinfo = struct { func unixDlOpen(tls *libc.TLS, NotUsed uintptr, zFilename uintptr) uintptr { /* sqlite3.c:39978:13: */ _ = NotUsed - return libc.Xdlopen(tls, zFilename, (0x00002 | 0x00100)) + return libc.Xdlopen(tls, zFilename, (RTLD_NOW | RTLD_GLOBAL)) } // SQLite calls this function immediately after a call to unixDlSym() or @@ -26470,18 +26009,18 @@ func unixRandomness(tls *libc.TLS, NotUsed uintptr, nBuf int32, zBuf uintptr) in { var fd int32 var got int32 - fd = robust_open(tls, ts+2821 /* "/dev/urandom" */, 00, uint32(0)) + fd = robust_open(tls, ts+2821 /* "/dev/urandom" */, O_RDONLY, uint32(0)) if fd < 0 { // var t Time_t at bp, 8 libc.Xtime(tls, bp /* &t */) libc.Xmemcpy(tls, zBuf, bp /* &t */, uint64(unsafe.Sizeof(Time_t(0)))) - libc.Xmemcpy(tls, (zBuf + uintptr(uint64(unsafe.Sizeof(Time_t(0))))), uintptr(unsafe.Pointer(&randomnessPid)), uint64(unsafe.Sizeof(randomnessPid))) + libc.Xmemcpy(tls, (zBuf + 8), uintptr(unsafe.Pointer(&randomnessPid)), uint64(unsafe.Sizeof(randomnessPid))) nBuf = (int32(uint64(unsafe.Sizeof(Time_t(0))) + uint64(unsafe.Sizeof(randomnessPid)))) } else { - for ok := true; ok; ok = ((got < 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 4)) { - got = int32((*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(8)*24 + 8 /* &.pCurrent */))))(tls, fd, zBuf, uint64(nBuf))) + for ok := true; ok; ok = ((got < 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == EINTR)) { + got = int32((*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 8*24 + 8 /* &.pCurrent */))))(tls, fd, zBuf, uint64(nBuf))) } robust_close(tls, uintptr(0), fd, 40068) } @@ -26518,7 +26057,7 @@ func unixCurrentTimeInt64(tls *libc.TLS, NotUsed uintptr, piNow uintptr) int32 { bp := tls.Alloc(16) defer tls.Free(16) - var rc int32 = 0 + var rc int32 = SQLITE_OK // var sNow timeval at bp, 16 libc.Xgettimeofday(tls, bp /* &sNow */, uintptr(0)) // Cannot fail given valid arguments @@ -26741,103 +26280,15 @@ func Xsqlite3_os_init(tls *libc.TLS) int32 { /* sqlite3.c:41379:16: */ for i = uint32(0); uint64(i) < (uint64(unsafe.Sizeof(aVfs)) / uint64(unsafe.Sizeof(Sqlite3_vfs{}))); i++ { Xsqlite3_vfs_register(tls, (uintptr(unsafe.Pointer(&aVfs)) + uintptr(i)*168), (libc.Bool32(i == uint32(0)))) } - unixBigLock = Xsqlite3MutexAlloc(tls, 11) - return 0 + unixBigLock = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_VFS1) + return SQLITE_OK } var aVfs = [4]Sqlite3_vfs{ - { - FiVersion: 3, - FszOsFile:/* iVersion */ int32(unsafe.Sizeof(UnixFile{})), - FmxPathname:/* szOsFile */ 512, - FpNext:/* mxPathname */ uintptr(0), - FzName:/* pNext */ ts + 2834, /* "unix" */ - FpAppData:/* zName */ 0, - FxOpen:/* pAppData */ 0, - FxDelete:/* xOpen */ 0, - FxAccess:/* xDelete */ 0, - FxFullPathname:/* xAccess */ 0, - FxDlOpen:/* xFullPathname */ 0, - FxDlError:/* xDlOpen */ 0, - FxDlSym:/* xDlError */ 0, - FxDlClose:/* xDlSym */ 0, - FxRandomness:/* xDlClose */ 0, - FxSleep:/* xRandomness */ 0, - FxCurrentTime:/* xSleep */ 0, - FxGetLastError:/* xCurrentTime */ 0, - FxCurrentTimeInt64:/* xGetLastError */ 0, - FxSetSystemCall:/* xCurrentTimeInt64 */ 0, - FxGetSystemCall:/* xSetSystemCall */ 0, - FxNextSystemCall:/* xGetSystemCall */ 0 /* xNextSystemCall */}, - { - FiVersion: 3, - FszOsFile:/* iVersion */ int32(unsafe.Sizeof(UnixFile{})), - FmxPathname:/* szOsFile */ 512, - FpNext:/* mxPathname */ uintptr(0), - FzName:/* pNext */ ts + 2839, /* "unix-none" */ - FpAppData:/* zName */ 0, - FxOpen:/* pAppData */ 0, - FxDelete:/* xOpen */ 0, - FxAccess:/* xDelete */ 0, - FxFullPathname:/* xAccess */ 0, - FxDlOpen:/* xFullPathname */ 0, - FxDlError:/* xDlOpen */ 0, - FxDlSym:/* xDlError */ 0, - FxDlClose:/* xDlSym */ 0, - FxRandomness:/* xDlClose */ 0, - FxSleep:/* xRandomness */ 0, - FxCurrentTime:/* xSleep */ 0, - FxGetLastError:/* xCurrentTime */ 0, - FxCurrentTimeInt64:/* xGetLastError */ 0, - FxSetSystemCall:/* xCurrentTimeInt64 */ 0, - FxGetSystemCall:/* xSetSystemCall */ 0, - FxNextSystemCall:/* xGetSystemCall */ 0 /* xNextSystemCall */}, - { - FiVersion: 3, - FszOsFile:/* iVersion */ int32(unsafe.Sizeof(UnixFile{})), - FmxPathname:/* szOsFile */ 512, - FpNext:/* mxPathname */ uintptr(0), - FzName:/* pNext */ ts + 2849, /* "unix-dotfile" */ - FpAppData:/* zName */ 0, - FxOpen:/* pAppData */ 0, - FxDelete:/* xOpen */ 0, - FxAccess:/* xDelete */ 0, - FxFullPathname:/* xAccess */ 0, - FxDlOpen:/* xFullPathname */ 0, - FxDlError:/* xDlOpen */ 0, - FxDlSym:/* xDlError */ 0, - FxDlClose:/* xDlSym */ 0, - FxRandomness:/* xDlClose */ 0, - FxSleep:/* xRandomness */ 0, - FxCurrentTime:/* xSleep */ 0, - FxGetLastError:/* xCurrentTime */ 0, - FxCurrentTimeInt64:/* xGetLastError */ 0, - FxSetSystemCall:/* xCurrentTimeInt64 */ 0, - FxGetSystemCall:/* xSetSystemCall */ 0, - FxNextSystemCall:/* xGetSystemCall */ 0 /* xNextSystemCall */}, - { - FiVersion: 3, - FszOsFile:/* iVersion */ int32(unsafe.Sizeof(UnixFile{})), - FmxPathname:/* szOsFile */ 512, - FpNext:/* mxPathname */ uintptr(0), - FzName:/* pNext */ ts + 2729, /* "unix-excl" */ - FpAppData:/* zName */ 0, - FxOpen:/* pAppData */ 0, - FxDelete:/* xOpen */ 0, - FxAccess:/* xDelete */ 0, - FxFullPathname:/* xAccess */ 0, - FxDlOpen:/* xFullPathname */ 0, - FxDlError:/* xDlOpen */ 0, - FxDlSym:/* xDlError */ 0, - FxDlClose:/* xDlSym */ 0, - FxRandomness:/* xDlClose */ 0, - FxSleep:/* xRandomness */ 0, - FxCurrentTime:/* xSleep */ 0, - FxGetLastError:/* xCurrentTime */ 0, - FxCurrentTimeInt64:/* xGetLastError */ 0, - FxSetSystemCall:/* xCurrentTimeInt64 */ 0, - FxGetSystemCall:/* xSetSystemCall */ 0, - FxNextSystemCall:/* xGetSystemCall */ 0 /* xNextSystemCall */}, + {FiVersion: 3 /* iVersion */, FszOsFile: int32(unsafe.Sizeof(UnixFile{})) /* szOsFile */, FmxPathname: MAX_PATHNAME /* pNext */, FzName: ts + 2834 /* "unix" */ /* zName */, FpAppData: 0 /* pAppData */, FxOpen: 0 /* xOpen */, FxDelete: 0 /* xDelete */, FxAccess: 0 /* xAccess */, FxFullPathname: 0 /* xFullPathname */, FxDlOpen: 0 /* xDlOpen */, FxDlError: 0 /* xDlError */, FxDlSym: 0 /* xDlSym */, FxDlClose: 0 /* xDlClose */, FxRandomness: 0 /* xRandomness */, FxSleep: 0 /* xSleep */, FxCurrentTime: 0 /* xCurrentTime */, FxGetLastError: 0 /* xGetLastError */, FxCurrentTimeInt64: 0 /* xCurrentTimeInt64 */, FxSetSystemCall: 0 /* xSetSystemCall */, FxGetSystemCall: 0 /* xGetSystemCall */, FxNextSystemCall: 0 /* xNextSystemCall */}, + {FiVersion: 3 /* iVersion */, FszOsFile: int32(unsafe.Sizeof(UnixFile{})) /* szOsFile */, FmxPathname: MAX_PATHNAME /* pNext */, FzName: ts + 2839 /* "unix-none" */ /* zName */, FpAppData: 0 /* pAppData */, FxOpen: 0 /* xOpen */, FxDelete: 0 /* xDelete */, FxAccess: 0 /* xAccess */, FxFullPathname: 0 /* xFullPathname */, FxDlOpen: 0 /* xDlOpen */, FxDlError: 0 /* xDlError */, FxDlSym: 0 /* xDlSym */, FxDlClose: 0 /* xDlClose */, FxRandomness: 0 /* xRandomness */, FxSleep: 0 /* xSleep */, FxCurrentTime: 0 /* xCurrentTime */, FxGetLastError: 0 /* xGetLastError */, FxCurrentTimeInt64: 0 /* xCurrentTimeInt64 */, FxSetSystemCall: 0 /* xSetSystemCall */, FxGetSystemCall: 0 /* xGetSystemCall */, FxNextSystemCall: 0 /* xNextSystemCall */}, + {FiVersion: 3 /* iVersion */, FszOsFile: int32(unsafe.Sizeof(UnixFile{})) /* szOsFile */, FmxPathname: MAX_PATHNAME /* pNext */, FzName: ts + 2849 /* "unix-dotfile" */ /* zName */, FpAppData: 0 /* pAppData */, FxOpen: 0 /* xOpen */, FxDelete: 0 /* xDelete */, FxAccess: 0 /* xAccess */, FxFullPathname: 0 /* xFullPathname */, FxDlOpen: 0 /* xDlOpen */, FxDlError: 0 /* xDlError */, FxDlSym: 0 /* xDlSym */, FxDlClose: 0 /* xDlClose */, FxRandomness: 0 /* xRandomness */, FxSleep: 0 /* xSleep */, FxCurrentTime: 0 /* xCurrentTime */, FxGetLastError: 0 /* xGetLastError */, FxCurrentTimeInt64: 0 /* xCurrentTimeInt64 */, FxSetSystemCall: 0 /* xSetSystemCall */, FxGetSystemCall: 0 /* xGetSystemCall */, FxNextSystemCall: 0 /* xNextSystemCall */}, + {FiVersion: 3 /* iVersion */, FszOsFile: int32(unsafe.Sizeof(UnixFile{})) /* szOsFile */, FmxPathname: MAX_PATHNAME /* pNext */, FzName: ts + 2729 /* "unix-excl" */ /* zName */, FpAppData: 0 /* pAppData */, FxOpen: 0 /* xOpen */, FxDelete: 0 /* xDelete */, FxAccess: 0 /* xAccess */, FxFullPathname: 0 /* xFullPathname */, FxDlOpen: 0 /* xDlOpen */, FxDlError: 0 /* xDlError */, FxDlSym: 0 /* xDlSym */, FxDlClose: 0 /* xDlClose */, FxRandomness: 0 /* xRandomness */, FxSleep: 0 /* xSleep */, FxCurrentTime: 0 /* xCurrentTime */, FxGetLastError: 0 /* xGetLastError */, FxCurrentTimeInt64: 0 /* xCurrentTimeInt64 */, FxSetSystemCall: 0 /* xSetSystemCall */, FxGetSystemCall: 0 /* xGetSystemCall */, FxNextSystemCall: 0 /* xNextSystemCall */}, } /* sqlite3.c:41432:22 */ // Shutdown the operating system interface. @@ -26847,7 +26298,7 @@ var aVfs = [4]Sqlite3_vfs{ // This routine is a no-op for unix. func Xsqlite3_os_end(tls *libc.TLS) int32 { /* sqlite3.c:41479:16: */ unixBigLock = uintptr(0) - return 0 + return SQLITE_OK } // Create a new bitmap object able to handle bits between 0 and iSize, @@ -26880,15 +26331,15 @@ func Xsqlite3BitvecTestNotNull(tls *libc.TLS, p uintptr, i U32) int32 { /* sqlit return 0 } } - if uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) <= (((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * uint64(8)) { - return (libc.Bool32((int32(*(*U8)(unsafe.Pointer((p + 16 /* &.u */ /* &.aBitmap */) + uintptr((i / U32(8)))))) & (int32(1) << (i & (U32(8 - 1))))) != 0)) + if uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) <= (((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * BITVEC_SZELEM) { + return (libc.Bool32((int32(*(*U8)(unsafe.Pointer((p + 16 /* &.u */ /* &.aBitmap */) + uintptr((i / BITVEC_SZELEM))))) & (int32(1) << (i & (U32(BITVEC_SZELEM - 1))))) != 0)) } else { - var h U32 = (U32((uint64((libc.PostIncUint32(&i, 1)) * U32(1))) % ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) + var h U32 = (U32((uint64((libc.PostIncUint32(&i, 1)) * U32(1))) % ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) for *(*U32)(unsafe.Pointer((p + 16 /* &.u */ /* &.aHash */) + uintptr(h)*4)) != 0 { if *(*U32)(unsafe.Pointer((p + 16 /* &.u */ /* &.aHash */) + uintptr(h)*4)) == i { return 1 } - h = (U32((uint64(h + U32(1))) % ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) + h = (U32((uint64(h + U32(1))) % ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) } return 0 } @@ -26918,13 +26369,13 @@ func Xsqlite3BitvecSet(tls *libc.TLS, p uintptr, i U32) int32 { /* sqlite3.c:486 if !(p == uintptr(0)) { goto __1 } - return 0 + return SQLITE_OK __1: ; i-- __2: - if !((uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) > (((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * uint64(8))) && ((*Bitvec)(unsafe.Pointer(p)).FiDivisor != 0)) { + if !((uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) > (((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * BITVEC_SZELEM)) && ((*Bitvec)(unsafe.Pointer(p)).FiDivisor != 0)) { goto __3 } bin = (i / (*Bitvec)(unsafe.Pointer(p)).FiDivisor) @@ -26936,7 +26387,7 @@ __2: if !(*(*uintptr)(unsafe.Pointer((p + 16 /* &.u */ /* &.apSub */) + uintptr(bin)*8)) == uintptr(0)) { goto __5 } - return 7 + return SQLITE_NOMEM __5: ; __4: @@ -26945,21 +26396,21 @@ __4: goto __2 __3: ; - if !(uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) <= (((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * uint64(8))) { + if !(uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) <= (((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * BITVEC_SZELEM)) { goto __6 } - *(*U8)(unsafe.Pointer((p + 16 /* &.u */ /* &.aBitmap */) + uintptr((i / U32(8))))) |= U8((int32(1) << (i & (U32(8 - 1))))) - return 0 + *(*U8)(unsafe.Pointer((p + 16 /* &.u */ /* &.aBitmap */) + uintptr((i / BITVEC_SZELEM)))) |= U8((int32(1) << (i & (U32(BITVEC_SZELEM - 1))))) + return SQLITE_OK __6: ; - h = (U32((uint64((libc.PostIncUint32(&i, 1)) * U32(1))) % ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) + h = (U32((uint64((libc.PostIncUint32(&i, 1)) * U32(1))) % ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) // if there wasn't a hash collision, and this doesn't // completely fill the hash, then just add it without // worring about sub-dividing and re-hashing. if !(!(int32(*(*U32)(unsafe.Pointer((p + 16 /* &.u */ /* &.aHash */) + uintptr(h)*4))) != 0)) { goto __7 } - if !(uint64((*Bitvec)(unsafe.Pointer(p)).FnSet) < (((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))) - uint64(1))) { + if !(uint64((*Bitvec)(unsafe.Pointer(p)).FnSet) < (((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))) - uint64(1))) { goto __8 } goto bitvec_set_end @@ -26976,11 +26427,11 @@ __10: if !(*(*U32)(unsafe.Pointer((p + 16 /* &.u */ /* &.aHash */) + uintptr(h)*4)) == i) { goto __13 } - return 0 + return SQLITE_OK __13: ; h++ - if !(uint64(h) >= ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0))))) { + if !(uint64(h) >= ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0))))) { goto __14 } h = U32(0) @@ -26998,23 +26449,23 @@ __12: // available free spot. check to see if this is going to // make our hash too "full". bitvec_set_rehash: - if !(uint64((*Bitvec)(unsafe.Pointer(p)).FnSet) >= (((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))) / uint64(2))) { + if !(uint64((*Bitvec)(unsafe.Pointer(p)).FnSet) >= (((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))) / uint64(2))) { goto __15 } aiValues = Xsqlite3DbMallocRaw(tls, uintptr(0), uint64(unsafe.Sizeof([124]U32{}))) if !(aiValues == uintptr(0)) { goto __16 } - return 7 + return SQLITE_NOMEM goto __17 __16: libc.Xmemcpy(tls, aiValues, p+16 /* &.u */ /* &.aHash */, uint64(unsafe.Sizeof([124]U32{}))) libc.Xmemset(tls, p+16 /* &.u */ /* &.apSub */, 0, uint64(unsafe.Sizeof([62]uintptr{}))) - (*Bitvec)(unsafe.Pointer(p)).FiDivisor = (U32(((uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) + ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(uintptr(0))))) - uint64(1)) / ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(uintptr(0)))))) + (*Bitvec)(unsafe.Pointer(p)).FiDivisor = (U32(((uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) + ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(uintptr(0))))) - uint64(1)) / ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(uintptr(0)))))) rc = Xsqlite3BitvecSet(tls, p, i) j = uint32(0) __18: - if !(uint64(j) < ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0))))) { + if !(uint64(j) < ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0))))) { goto __20 } if !(*(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) != 0) { @@ -27039,7 +26490,7 @@ __15: bitvec_set_end: (*Bitvec)(unsafe.Pointer(p)).FnSet++ *(*U32)(unsafe.Pointer((p + 16 /* &.u */ /* &.aHash */) + uintptr(h)*4)) = i - return 0 + return SQLITE_OK } // Clear the i-th bit. @@ -27060,21 +26511,21 @@ func Xsqlite3BitvecClear(tls *libc.TLS, p uintptr, i U32, pBuf uintptr) { /* sql return } } - if uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) <= (((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * uint64(8)) { - *(*U8)(unsafe.Pointer((p + 16 /* &.u */ /* &.aBitmap */) + uintptr((i / U32(8))))) &= U8((^(int32(1) << (i & (U32(8 - 1)))))) + if uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) <= (((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * BITVEC_SZELEM) { + *(*U8)(unsafe.Pointer((p + 16 /* &.u */ /* &.aBitmap */) + uintptr((i / BITVEC_SZELEM)))) &= U8((^(int32(1) << (i & (U32(BITVEC_SZELEM - 1)))))) } else { var j uint32 var aiValues uintptr = pBuf libc.Xmemcpy(tls, aiValues, p+16 /* &.u */ /* &.aHash */, uint64(unsafe.Sizeof([124]U32{}))) libc.Xmemset(tls, p+16 /* &.u */ /* &.aHash */, 0, uint64(unsafe.Sizeof([124]U32{}))) (*Bitvec)(unsafe.Pointer(p)).FnSet = U32(0) - for j = uint32(0); uint64(j) < ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))); j++ { + for j = uint32(0); uint64(j) < ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))); j++ { if (*(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) != 0) && (*(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) != (i + U32(1))) { - var h U32 = (U32((uint64((*(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) - U32(1)) * U32(1))) % ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) + var h U32 = (U32((uint64((*(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) - U32(1)) * U32(1))) % ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) (*Bitvec)(unsafe.Pointer(p)).FnSet++ for *(*U32)(unsafe.Pointer((p + 16 /* &.u */ /* &.aHash */) + uintptr(h)*4)) != 0 { h++ - if uint64(h) >= ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))) { + if uint64(h) >= ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))) { h = U32(0) } } @@ -27091,7 +26542,7 @@ func Xsqlite3BitvecDestroy(tls *libc.TLS, p uintptr) { /* sqlite3.c:48742:21: */ } if (*Bitvec)(unsafe.Pointer(p)).FiDivisor != 0 { var i uint32 - for i = uint32(0); uint64(i) < ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { + for i = uint32(0); uint64(i) < ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { Xsqlite3BitvecDestroy(tls, *(*uintptr)(unsafe.Pointer((p + 16 /* &.u */ /* &.apSub */) + uintptr(i)*8))) } } @@ -27158,7 +26609,7 @@ func Xsqlite3BitvecBuiltinTest(tls *libc.TLS, sz int32, aOp uintptr) int32 { /* // bits to act as the reference pBitvec = Xsqlite3BitvecCreate(tls, uint32(sz)) pV = Xsqlite3MallocZero(tls, (uint64(((sz + 7) / 8) + 1))) - pTmpSpace = Xsqlite3_malloc64(tls, uint64(512)) + pTmpSpace = Xsqlite3_malloc64(tls, BITVEC_SZ) if !(((pBitvec == uintptr(0)) || (pV == uintptr(0))) || (pTmpSpace == uintptr(0))) { goto __1 } @@ -27303,7 +26754,7 @@ bitvec_end: func pcacheManageDirtyList(tls *libc.TLS, pPage uintptr, addRemove U8) { /* sqlite3.c:49037:13: */ var p uintptr = (*PgHdr)(unsafe.Pointer(pPage)).FpCache - if (int32(addRemove) & 1) != 0 { + if (int32(addRemove) & PCACHE_DIRTYLIST_REMOVE) != 0 { // Update the PCache1.pSynced variable if necessary. if (*PCache)(unsafe.Pointer(p)).FpSynced == pPage { @@ -27332,7 +26783,7 @@ func pcacheManageDirtyList(tls *libc.TLS, pPage uintptr, addRemove U8) { /* sqli } } } - if (int32(addRemove) & 2) != 0 { + if (int32(addRemove) & PCACHE_DIRTYLIST_ADD) != 0 { (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev = uintptr(0) (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyNext = (*PCache)(unsafe.Pointer(p)).FpDirty if (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyNext != 0 { @@ -27353,7 +26804,7 @@ func pcacheManageDirtyList(tls *libc.TLS, pPage uintptr, addRemove U8) { /* sqli // flag set sqlite3PcacheFetchStress() searches through all newer // entries of the dirty-list for a page with NEED_SYNC clear anyway. if !(int32((*PCache)(unsafe.Pointer(p)).FpSynced) != 0) && - (0 == (int32((*PgHdr)(unsafe.Pointer(pPage)).Fflags) & 0x008)) { + (0 == (int32((*PgHdr)(unsafe.Pointer(pPage)).Fflags) & PGHDR_NEED_SYNC)) { (*PCache)(unsafe.Pointer(p)).FpSynced = pPage } } @@ -27447,10 +26898,10 @@ func Xsqlite3PcacheSetPageSize(tls *libc.TLS, pCache uintptr, szPage int32) int3 if (*PCache)(unsafe.Pointer(pCache)).FszPage != 0 { var pNew uintptr pNew = (*(*func(*libc.TLS, int32, int32, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 168 /* &.pcache2 */ + 32 /* &.xCreate */))))(tls, - szPage, (int32(uint64((*PCache)(unsafe.Pointer(pCache)).FszExtra) + (((uint64(unsafe.Sizeof(PgHdr{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))), + szPage, (int32(uint64((*PCache)(unsafe.Pointer(pCache)).FszExtra) + (((uint64(unsafe.Sizeof(PgHdr{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))))), int32((*PCache)(unsafe.Pointer(pCache)).FbPurgeable)) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 168 /* &.pcache2 */ + 40 /* &.xCachesize */))))(tls, pNew, numberOfCachePages(tls, pCache)) if (*PCache)(unsafe.Pointer(pCache)).FpCache != 0 { @@ -27460,7 +26911,7 @@ func Xsqlite3PcacheSetPageSize(tls *libc.TLS, pCache uintptr, szPage int32) int3 (*PCache)(unsafe.Pointer(pCache)).FszPage = szPage } - return 0 + return SQLITE_OK } // Try to obtain a page from the cache. @@ -27527,7 +26978,7 @@ func Xsqlite3PcacheFetchStress(tls *libc.TLS, pCache uintptr, pgno Pgno, ppPage // flag is currently referenced, then the following may leave pSynced // set incorrectly (pointing to other than the LRU page with NEED_SYNC // cleared). This is Ok, as pSynced is just an optimization. - for pPg = (*PCache)(unsafe.Pointer(pCache)).FpSynced; (pPg != 0) && (((*PgHdr)(unsafe.Pointer(pPg)).FnRef != 0) || ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & 0x008) != 0)); pPg = (*PgHdr)(unsafe.Pointer(pPg)).FpDirtyPrev { + for pPg = (*PCache)(unsafe.Pointer(pCache)).FpSynced; (pPg != 0) && (((*PgHdr)(unsafe.Pointer(pPg)).FnRef != 0) || ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & PGHDR_NEED_SYNC) != 0)); pPg = (*PgHdr)(unsafe.Pointer(pPg)).FpDirtyPrev { } (*PCache)(unsafe.Pointer(pCache)).FpSynced = pPg if !(pPg != 0) { @@ -27539,16 +26990,16 @@ func Xsqlite3PcacheFetchStress(tls *libc.TLS, pCache uintptr, pgno Pgno, ppPage rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pCache + 48 /* &.xStress */))))(tls, (*PCache)(unsafe.Pointer(pCache)).FpStress, pPg) - if (rc != 0) && (rc != 5) { + if (rc != SQLITE_OK) && (rc != SQLITE_BUSY) { return rc } } } *(*uintptr)(unsafe.Pointer(ppPage)) = (*(*func(*libc.TLS, uintptr, uint32, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 168 /* &.pcache2 */ + 56 /* &.xFetch */))))(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache, pgno, 2) if *(*uintptr)(unsafe.Pointer(ppPage)) == uintptr(0) { - return 7 + return SQLITE_NOMEM } - return 0 + return SQLITE_OK } // This is a helper routine for sqlite3PcacheFetchFinish() @@ -27566,11 +27017,11 @@ func pcacheFetchFinishWithInit(tls *libc.TLS, pCache uintptr, pgno Pgno, pPage u libc.Xmemset(tls, (pPgHdr + 32 /* &.pDirty */), 0, (uint64(unsafe.Sizeof(PgHdr{})) - (uint64((uintptr(0) + 32 /* &.pDirty */))))) (*PgHdr)(unsafe.Pointer(pPgHdr)).FpPage = pPage (*PgHdr)(unsafe.Pointer(pPgHdr)).FpData = (*Sqlite3_pcache_page)(unsafe.Pointer(pPage)).FpBuf - (*PgHdr)(unsafe.Pointer(pPgHdr)).FpExtra = (pPgHdr + uintptr(1)*72) + (*PgHdr)(unsafe.Pointer(pPgHdr)).FpExtra = (pPgHdr + 1*72) libc.Xmemset(tls, (*PgHdr)(unsafe.Pointer(pPgHdr)).FpExtra, 0, uint64(8)) (*PgHdr)(unsafe.Pointer(pPgHdr)).FpCache = pCache (*PgHdr)(unsafe.Pointer(pPgHdr)).Fpgno = pgno - (*PgHdr)(unsafe.Pointer(pPgHdr)).Fflags = U16(0x001) + (*PgHdr)(unsafe.Pointer(pPgHdr)).Fflags = PGHDR_CLEAN return Xsqlite3PcacheFetchFinish(tls, pCache, pgno, pPage) } @@ -27598,10 +27049,10 @@ func Xsqlite3PcacheRelease(tls *libc.TLS, p uintptr) { /* sqlite3.c:49388:37: */ (*PCache)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum-- if (int32(libc.PreDecInt16(&(*PgHdr)(unsafe.Pointer(p)).FnRef, 1))) == 0 { - if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & 0x001) != 0 { + if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & PGHDR_CLEAN) != 0 { pcacheUnpin(tls, p) } else { - pcacheManageDirtyList(tls, p, uint8(3)) + pcacheManageDirtyList(tls, p, PCACHE_DIRTYLIST_FRONT) } } } @@ -27618,8 +27069,8 @@ func Xsqlite3PcacheRef(tls *libc.TLS, p uintptr) { /* sqlite3.c:49403:21: */ // page pointed to by p is invalid. func Xsqlite3PcacheDrop(tls *libc.TLS, p uintptr) { /* sqlite3.c:49415:21: */ - if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & 0x002) != 0 { - pcacheManageDirtyList(tls, p, uint8(1)) + if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & PGHDR_DIRTY) != 0 { + pcacheManageDirtyList(tls, p, PCACHE_DIRTYLIST_REMOVE) } (*PCache)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum-- (*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 168 /* &.pcache2 */ + 64 /* &.xUnpin */))))(tls, (*PCache)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(p)).FpCache)).FpCache, (*PgHdr)(unsafe.Pointer(p)).FpPage, 1) @@ -27629,12 +27080,12 @@ func Xsqlite3PcacheDrop(tls *libc.TLS, p uintptr) { /* sqlite3.c:49415:21: */ // make it so. func Xsqlite3PcacheMakeDirty(tls *libc.TLS, p uintptr) { /* sqlite3.c:49429:21: */ - if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & (0x001 | 0x010)) != 0 { //OPTIMIZATION-IF-FALSE - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x010))) - if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & 0x001) != 0 { - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) ^= U16((0x002 | 0x001)) + if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & (PGHDR_CLEAN | PGHDR_DONT_WRITE)) != 0 { //OPTIMIZATION-IF-FALSE + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(PGHDR_DONT_WRITE))) + if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & PGHDR_CLEAN) != 0 { + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) ^= U16((PGHDR_DIRTY | PGHDR_CLEAN)) - pcacheManageDirtyList(tls, p, uint8(2)) + pcacheManageDirtyList(tls, p, PCACHE_DIRTYLIST_ADD) } } @@ -27644,9 +27095,9 @@ func Xsqlite3PcacheMakeDirty(tls *libc.TLS, p uintptr) { /* sqlite3.c:49429:21: // make it so. func Xsqlite3PcacheMakeClean(tls *libc.TLS, p uintptr) { /* sqlite3.c:49448:21: */ - pcacheManageDirtyList(tls, p, uint8(1)) - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((0x002 | 0x008) | 0x004)))) - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) |= U16((0x001)) + pcacheManageDirtyList(tls, p, PCACHE_DIRTYLIST_REMOVE) + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((PGHDR_DIRTY | PGHDR_NEED_SYNC) | PGHDR_WRITEABLE)))) + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) |= U16((PGHDR_CLEAN)) if int32((*PgHdr)(unsafe.Pointer(p)).FnRef) == 0 { pcacheUnpin(tls, p) @@ -27667,7 +27118,7 @@ func Xsqlite3PcacheClearWritable(tls *libc.TLS, pCache uintptr) { /* sqlite3.c:4 var p uintptr for p = (*PCache)(unsafe.Pointer(pCache)).FpDirty; p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirtyNext { - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32((0x008 | 0x004)))) + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32((PGHDR_NEED_SYNC | PGHDR_WRITEABLE)))) } (*PCache)(unsafe.Pointer(pCache)).FpSynced = (*PCache)(unsafe.Pointer(pCache)).FpDirtyTail } @@ -27676,7 +27127,7 @@ func Xsqlite3PcacheClearWritable(tls *libc.TLS, pCache uintptr) { /* sqlite3.c:4 func Xsqlite3PcacheClearSyncFlags(tls *libc.TLS, pCache uintptr) { /* sqlite3.c:49488:21: */ var p uintptr for p = (*PCache)(unsafe.Pointer(pCache)).FpDirty; p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirtyNext { - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x008))) + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(PGHDR_NEED_SYNC))) } (*PCache)(unsafe.Pointer(pCache)).FpSynced = (*PCache)(unsafe.Pointer(pCache)).FpDirtyTail } @@ -27687,8 +27138,8 @@ func Xsqlite3PcacheMove(tls *libc.TLS, p uintptr, newPgno Pgno) { /* sqlite3.c:4 (*(*func(*libc.TLS, uintptr, uintptr, uint32, uint32))(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 168 /* &.pcache2 */ + 72 /* &.xRekey */))))(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache, (*PgHdr)(unsafe.Pointer(p)).FpPage, (*PgHdr)(unsafe.Pointer(p)).Fpgno, newPgno) (*PgHdr)(unsafe.Pointer(p)).Fpgno = newPgno - if ((int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & 0x002) != 0) && ((int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & 0x008) != 0) { - pcacheManageDirtyList(tls, p, uint8(3)) + if ((int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & PGHDR_DIRTY) != 0) && ((int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & PGHDR_NEED_SYNC) != 0) { + pcacheManageDirtyList(tls, p, PCACHE_DIRTYLIST_FRONT) } } @@ -27793,7 +27244,7 @@ func pcacheSortDirtyList(tls *libc.TLS, pIn uintptr) uintptr { /* sqlite3.c:4960 p = pIn pIn = (*PgHdr)(unsafe.Pointer(p)).FpDirty (*PgHdr)(unsafe.Pointer(p)).FpDirty = uintptr(0) - for i = 0; i < (32 - 1); i++ { + for i = 0; i < (N_SORT_BUCKET - 1); i++ { if *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(i)*8)) == uintptr(0) { *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(i)*8)) = p break @@ -27802,14 +27253,14 @@ func pcacheSortDirtyList(tls *libc.TLS, pIn uintptr) uintptr { /* sqlite3.c:4960 *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(i)*8)) = uintptr(0) } } - if i == (32 - 1) { + if i == (N_SORT_BUCKET - 1) { // To get here, there need to be 2^(N_SORT_BUCKET) elements in // the input list. But that is impossible. *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(i)*8)) = pcacheMergeDirtyList(tls, *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(i)*8)), p) } } - p = *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(0)*8)) - for i = 1; i < 32; i++ { + p = *(*uintptr)(unsafe.Pointer(bp /* &a[0] */)) + for i = 1; i < N_SORT_BUCKET; i++ { if *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(i)*8)) == uintptr(0) { continue } @@ -27886,7 +27337,7 @@ func Xsqlite3PcacheShrink(tls *libc.TLS, pCache uintptr) { /* sqlite3.c:49717:21 // Return the size of the header added by this middleware layer // in the page-cache hierarchy. func Xsqlite3HeaderSizePcache(tls *libc.TLS) int32 { /* sqlite3.c:49726:20: */ - return (int32(((uint64(unsafe.Sizeof(PgHdr{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + return (int32(((uint64(unsafe.Sizeof(PgHdr{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) } // Return the number of dirty pages currently in the cache, as a percentage @@ -28164,7 +27615,7 @@ func Xsqlite3PCacheBufferSetup(tls *libc.TLS, pBuf uintptr, sz int32, n int32) { if n == 0 { sz = 0 } - sz = ((sz) & ^libc.Int32(7)) + sz = ((sz) & libc.CplInt32(7)) pcache1_g.FszSlot = sz pcache1_g.FnSlot = libc.AssignPtrInt32(uintptr(unsafe.Pointer(&pcache1_g))+136 /* &.nFreeSlot */, n) pcache1_g.FnReserve = func() int32 { @@ -28214,7 +27665,7 @@ func pcache1InitBulk(tls *libc.TLS, pCache uintptr) int32 { /* sqlite3.c:50054:1 for ok := true; ok; ok = libc.PreDecInt32(&nBulk, 1) != 0 { var pX uintptr = (zBulk + uintptr((*PCache1)(unsafe.Pointer(pCache)).FszPage)) (*PgHdr1)(unsafe.Pointer(pX)).Fpage.FpBuf = zBulk - (*PgHdr1)(unsafe.Pointer(pX)).Fpage.FpExtra = (pX + uintptr(1)*56) + (*PgHdr1)(unsafe.Pointer(pX)).Fpage.FpExtra = (pX + 1*56) (*PgHdr1)(unsafe.Pointer(pX)).FisBulkLocal = U16(1) (*PgHdr1)(unsafe.Pointer(pX)).FisAnchor = U16(0) (*PgHdr1)(unsafe.Pointer(pX)).FpNext = (*PCache1)(unsafe.Pointer(pCache)).FpFree @@ -28244,8 +27695,8 @@ func pcache1Alloc(tls *libc.TLS, nByte int32) uintptr { /* sqlite3.c:50097:13: * pcache1_g.FnFreeSlot-- pcache1_g.FbUnderPressure = (libc.Bool32(pcache1_g.FnFreeSlot < pcache1_g.FnReserve)) - Xsqlite3StatusHighwater(tls, 7, nByte) - Xsqlite3StatusUp(tls, 1, 1) + Xsqlite3StatusHighwater(tls, SQLITE_STATUS_PAGECACHE_SIZE, nByte) + Xsqlite3StatusUp(tls, SQLITE_STATUS_PAGECACHE_USED, 1) } Xsqlite3_mutex_leave(tls, pcache1_g.Fmutex) } @@ -28256,8 +27707,8 @@ func pcache1Alloc(tls *libc.TLS, nByte int32) uintptr { /* sqlite3.c:50097:13: * if p != 0 { var sz int32 = Xsqlite3MallocSize(tls, p) Xsqlite3_mutex_enter(tls, pcache1_g.Fmutex) - Xsqlite3StatusHighwater(tls, 7, nByte) - Xsqlite3StatusUp(tls, 2, sz) + Xsqlite3StatusHighwater(tls, SQLITE_STATUS_PAGECACHE_SIZE, nByte) + Xsqlite3StatusUp(tls, SQLITE_STATUS_PAGECACHE_OVERFLOW, sz) Xsqlite3_mutex_leave(tls, pcache1_g.Fmutex) } @@ -28273,7 +27724,7 @@ func pcache1Free(tls *libc.TLS, p uintptr) { /* sqlite3.c:50135:13: */ if (Uptr((p)) >= Uptr((pcache1_g.FpStart))) && (Uptr((p)) < Uptr((pcache1_g.FpEnd))) { var pSlot uintptr Xsqlite3_mutex_enter(tls, pcache1_g.Fmutex) - Xsqlite3StatusDown(tls, 1, 1) + Xsqlite3StatusDown(tls, SQLITE_STATUS_PAGECACHE_USED, 1) pSlot = p (*PgFreeslot)(unsafe.Pointer(pSlot)).FpNext = pcache1_g.FpFree pcache1_g.FpFree = pSlot @@ -28287,7 +27738,7 @@ func pcache1Free(tls *libc.TLS, p uintptr) { /* sqlite3.c:50135:13: */ var nFreed int32 = 0 nFreed = Xsqlite3MallocSize(tls, p) Xsqlite3_mutex_enter(tls, pcache1_g.Fmutex) - Xsqlite3StatusDown(tls, 2, nFreed) + Xsqlite3StatusDown(tls, SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed) Xsqlite3_mutex_leave(tls, pcache1_g.Fmutex) } @@ -28338,7 +27789,7 @@ func pcache1AllocPage(tls *libc.TLS, pCache uintptr, benignMalloc int32) uintptr } p = ((pPg) + uintptr((*PCache1)(unsafe.Pointer(pCache)).FszPage)) (*PgHdr1)(unsafe.Pointer(p)).Fpage.FpBuf = pPg - (*PgHdr1)(unsafe.Pointer(p)).Fpage.FpExtra = (p + uintptr(1)*56) + (*PgHdr1)(unsafe.Pointer(p)).Fpage.FpExtra = (p + 1*56) (*PgHdr1)(unsafe.Pointer(p)).FisBulkLocal = U16(0) (*PgHdr1)(unsafe.Pointer(p)).FisAnchor = U16(0) } @@ -28569,8 +28020,8 @@ func pcache1Init(tls *libc.TLS, NotUsed uintptr) int32 { /* sqlite3.c:50464:12: pcache1_g.FseparateCache = 0 if Xsqlite3Config.FbCoreMutex != 0 { - pcache1_g.Fgrp.Fmutex = Xsqlite3MutexAlloc(tls, 6) - pcache1_g.Fmutex = Xsqlite3MutexAlloc(tls, 7) + pcache1_g.Fgrp.Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_LRU) + pcache1_g.Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_PMEM) } if ((pcache1_g.FseparateCache != 0) && (Xsqlite3Config.FnPage != 0)) && @@ -28581,7 +28032,7 @@ func pcache1Init(tls *libc.TLS, NotUsed uintptr) int32 { /* sqlite3.c:50464:12: } pcache1_g.Fgrp.FmxPinned = uint32(10) pcache1_g.FisInit = 1 - return 0 + return SQLITE_OK } // Implementation of the sqlite3_pcache.xShutdown method. @@ -28605,7 +28056,7 @@ func pcache1Create(tls *libc.TLS, szPage int32, szExtra int32, bPurgeable int32) pCache = Xsqlite3MallocZero(tls, uint64(sz)) if pCache != 0 { if pcache1_g.FseparateCache != 0 { - pGroup = (pCache + uintptr(1)*88) + pGroup = (pCache + 1*88) (*PGroup)(unsafe.Pointer(pGroup)).FmxPinned = uint32(10) } else { pGroup = (uintptr(unsafe.Pointer(&pcache1_g)) /* &.grp */) @@ -28618,7 +28069,7 @@ func pcache1Create(tls *libc.TLS, szPage int32, szExtra int32, bPurgeable int32) (*PCache1)(unsafe.Pointer(pCache)).FpGroup = pGroup (*PCache1)(unsafe.Pointer(pCache)).FszPage = szPage (*PCache1)(unsafe.Pointer(pCache)).FszExtra = szExtra - (*PCache1)(unsafe.Pointer(pCache)).FszAlloc = (int32((uint64(szPage + szExtra)) + (((uint64(unsafe.Sizeof(PgHdr1{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + (*PCache1)(unsafe.Pointer(pCache)).FszAlloc = (int32((uint64(szPage + szExtra)) + (((uint64(unsafe.Sizeof(PgHdr1{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))))) (*PCache1)(unsafe.Pointer(pCache)).FbPurgeable = func() int32 { if bPurgeable != 0 { return 1 @@ -28961,40 +28412,27 @@ func Xsqlite3PCacheSetDefault(tls *libc.TLS) { /* sqlite3.c:50952:21: */ bp := tls.Alloc(8) defer tls.Free(8) - Xsqlite3_config(tls, 18, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultMethods1)))) + Xsqlite3_config(tls, SQLITE_CONFIG_PCACHE2, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultMethods1)))) } var defaultMethods1 = Sqlite3_pcache_methods2{ - FiVersion: 1, - FpArg:// iVersion - uintptr(0), - FxInit:// pArg - 0, - FxShutdown:// xInit - 0, - FxCreate:// xShutdown - 0, - FxCachesize:// xCreate - 0, - FxPagecount:// xCachesize - 0, - FxFetch:// xPagecount - 0, - FxUnpin:// xFetch - 0, - FxRekey:// xUnpin - 0, - FxTruncate:// xRekey - 0, - FxDestroy:// xTruncate - 0, - FxShrink:// xDestroy - 0, // xShrink + FiVersion: 1, // pArg + FxInit: 0, // xInit + FxShutdown: 0, // xShutdown + FxCreate: 0, // xCreate + FxCachesize: 0, // xCachesize + FxPagecount: 0, // xPagecount + FxFetch: 0, // xFetch + FxUnpin: 0, // xUnpin + FxRekey: 0, // xRekey + FxTruncate: 0, // xTruncate + FxDestroy: 0, // xDestroy + FxShrink: 0, // xShrink } /* sqlite3.c:50953:40 */ // Return the size of the header on each page of this PCACHE implementation. func Xsqlite3HeaderSizePcache1(tls *libc.TLS) int32 { /* sqlite3.c:50974:20: */ - return (int32(((uint64(unsafe.Sizeof(PgHdr1{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + return (int32(((uint64(unsafe.Sizeof(PgHdr1{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) } // Return the global mutex used by this PCACHE implementation. The @@ -29136,9 +28574,9 @@ func Xsqlite3RowSetInit(tls *libc.TLS, db uintptr) uintptr { /* sqlite3.c:51174: (*RowSet)(unsafe.Pointer(p)).FpEntry = uintptr(0) (*RowSet)(unsafe.Pointer(p)).FpLast = uintptr(0) (*RowSet)(unsafe.Pointer(p)).FpForest = uintptr(0) - (*RowSet)(unsafe.Pointer(p)).FpFresh = (uintptr((((uint64(unsafe.Sizeof(RowSet{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + p) - (*RowSet)(unsafe.Pointer(p)).FnFresh = (U16((uint64(N) - (((uint64(unsafe.Sizeof(RowSet{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) / uint64(unsafe.Sizeof(RowSetEntry{})))) - (*RowSet)(unsafe.Pointer(p)).FrsFlags = U16(0x01) + (*RowSet)(unsafe.Pointer(p)).FpFresh = (uintptr((((uint64(unsafe.Sizeof(RowSet{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) + p) + (*RowSet)(unsafe.Pointer(p)).FnFresh = (U16((uint64(N) - (((uint64(unsafe.Sizeof(RowSet{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) / uint64(unsafe.Sizeof(RowSetEntry{})))) + (*RowSet)(unsafe.Pointer(p)).FrsFlags = ROWSET_SORTED (*RowSet)(unsafe.Pointer(p)).FiBatch = 0 } return p @@ -29160,7 +28598,7 @@ func Xsqlite3RowSetClear(tls *libc.TLS, pArg uintptr) { /* sqlite3.c:51196:21: * (*RowSet)(unsafe.Pointer(p)).FpEntry = uintptr(0) (*RowSet)(unsafe.Pointer(p)).FpLast = uintptr(0) (*RowSet)(unsafe.Pointer(p)).FpForest = uintptr(0) - (*RowSet)(unsafe.Pointer(p)).FrsFlags = U16(0x01) + (*RowSet)(unsafe.Pointer(p)).FrsFlags = ROWSET_SORTED } // Deallocate all chunks from a RowSet. This frees all memory that @@ -29190,7 +28628,7 @@ func rowSetEntryAlloc(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:51229:27: (*RowSetChunk)(unsafe.Pointer(pNew)).FpNextChunk = (*RowSet)(unsafe.Pointer(p)).FpChunk (*RowSet)(unsafe.Pointer(p)).FpChunk = pNew (*RowSet)(unsafe.Pointer(p)).FpFresh = pNew + 8 /* &.aEntry */ - (*RowSet)(unsafe.Pointer(p)).FnFresh = (uint16((uint64(1024 - 8)) / uint64(unsafe.Sizeof(RowSetEntry{})))) + (*RowSet)(unsafe.Pointer(p)).FnFresh = (uint16((uint64(ROWSET_ALLOCATION_SIZE - 8)) / uint64(unsafe.Sizeof(RowSetEntry{})))) } (*RowSet)(unsafe.Pointer(p)).FnFresh-- return libc.PostIncUintptr(&(*RowSet)(unsafe.Pointer(p)).FpFresh, 24) @@ -29217,7 +28655,7 @@ func Xsqlite3RowSetInsert(tls *libc.TLS, p uintptr, rowid I64) { /* sqlite3.c:51 if rowid <= (*RowSetEntry)(unsafe.Pointer(pLast)).Fv { //OPTIMIZATION-IF-FALSE // Avoid unnecessary sorts by preserving the ROWSET_SORTED flags // where possible - *(*U16)(unsafe.Pointer(p + 50 /* &.rsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x01))) + *(*U16)(unsafe.Pointer(p + 50 /* &.rsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(ROWSET_SORTED))) } (*RowSetEntry)(unsafe.Pointer(pLast)).FpRight = pEntry } else { @@ -29284,7 +28722,7 @@ func rowSetEntrySort(tls *libc.TLS, pIn uintptr) uintptr { /* sqlite3.c:51320:27 *(*uintptr)(unsafe.Pointer(bp /* &aBucket[0] */ + uintptr(i)*8)) = pIn pIn = pNext } - pIn = *(*uintptr)(unsafe.Pointer(bp /* &aBucket[0] */ + uintptr(0)*8)) + pIn = *(*uintptr)(unsafe.Pointer(bp /* &aBucket[0] */)) for i = uint32(1); uint64(i) < (uint64(unsafe.Sizeof([40]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { if *(*uintptr)(unsafe.Pointer(bp /* &aBucket[0] */ + uintptr(i)*8)) == uintptr(0) { continue @@ -29401,11 +28839,11 @@ func Xsqlite3RowSetNext(tls *libc.TLS, p uintptr, pRowid uintptr) int32 { /* sql // Cannot be used with sqlite3RowSetText() // Merge the forest into a single sorted list on first call - if (int32((*RowSet)(unsafe.Pointer(p)).FrsFlags) & 0x02) == 0 { //OPTIMIZATION-IF-FALSE - if (int32((*RowSet)(unsafe.Pointer(p)).FrsFlags) & 0x01) == 0 { //OPTIMIZATION-IF-FALSE + if (int32((*RowSet)(unsafe.Pointer(p)).FrsFlags) & ROWSET_NEXT) == 0 { //OPTIMIZATION-IF-FALSE + if (int32((*RowSet)(unsafe.Pointer(p)).FrsFlags) & ROWSET_SORTED) == 0 { //OPTIMIZATION-IF-FALSE (*RowSet)(unsafe.Pointer(p)).FpEntry = rowSetEntrySort(tls, (*RowSet)(unsafe.Pointer(p)).FpEntry) } - *(*U16)(unsafe.Pointer(p + 50 /* &.rsFlags */)) |= U16((0x01 | 0x02)) + *(*U16)(unsafe.Pointer(p + 50 /* &.rsFlags */)) |= U16((ROWSET_SORTED | ROWSET_NEXT)) } // Return the next entry on the list @@ -29444,7 +28882,7 @@ func Xsqlite3RowSetTest(tls *libc.TLS, pRowSet uintptr, iBatch int32, iRowid Sql p = (*RowSet)(unsafe.Pointer(pRowSet)).FpEntry if p != 0 { var ppPrevTree uintptr = (pRowSet + 40 /* &.pForest */) - if (int32((*RowSet)(unsafe.Pointer(pRowSet)).FrsFlags) & 0x01) == 0 { //OPTIMIZATION-IF-FALSE + if (int32((*RowSet)(unsafe.Pointer(pRowSet)).FrsFlags) & ROWSET_SORTED) == 0 { //OPTIMIZATION-IF-FALSE // Only sort the current set of entries if they need it p = rowSetEntrySort(tls, p) } @@ -29473,7 +28911,7 @@ func Xsqlite3RowSetTest(tls *libc.TLS, pRowSet uintptr, iBatch int32, iRowid Sql } (*RowSet)(unsafe.Pointer(pRowSet)).FpEntry = uintptr(0) (*RowSet)(unsafe.Pointer(pRowSet)).FpLast = uintptr(0) - *(*U16)(unsafe.Pointer(pRowSet + 50 /* &.rsFlags */)) |= U16((0x01)) + *(*U16)(unsafe.Pointer(pRowSet + 50 /* &.rsFlags */)) |= U16((ROWSET_SORTED)) } (*RowSet)(unsafe.Pointer(pRowSet)).FiBatch = iBatch } @@ -30467,7 +29905,7 @@ func read32bits(tls *libc.TLS, fd uintptr, offset I64, pRes uintptr) int32 { /* // var ac [4]uint8 at bp, 4 var rc int32 = Xsqlite3OsRead(tls, fd, bp /* &ac[0] */, int32(unsafe.Sizeof([4]uint8{})), offset) - if rc == 0 { + if rc == SQLITE_OK { *(*U32)(unsafe.Pointer(pRes)) = Xsqlite3Get4byte(tls, bp /* &ac[0] */) } return rc @@ -30495,16 +29933,16 @@ func write32bits(tls *libc.TLS, fd uintptr, offset I64, val U32) int32 { /* sqli // called, do not modify it. See the comment above the #define of // UNKNOWN_LOCK for an explanation of this. func pagerUnlockDb(tls *libc.TLS, pPager uintptr, eLock int32) int32 { /* sqlite3.c:52837:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0) { if (*Pager)(unsafe.Pointer(pPager)).FnoLock != 0 { - rc = 0 + rc = SQLITE_OK } else { rc = Xsqlite3OsUnlock(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, eLock) } - if int32((*Pager)(unsafe.Pointer(pPager)).FeLock) != (4 + 1) { + if int32((*Pager)(unsafe.Pointer(pPager)).FeLock) != (EXCLUSIVE_LOCK + 1) { (*Pager)(unsafe.Pointer(pPager)).FeLock = U8(eLock) } @@ -30522,15 +29960,15 @@ func pagerUnlockDb(tls *libc.TLS, pPager uintptr, eLock int32) int32 { /* sqlite // See the comment above the #define of UNKNOWN_LOCK for an explanation // of this. func pagerLockDb(tls *libc.TLS, pPager uintptr, eLock int32) int32 { /* sqlite3.c:52865:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK - if (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) < eLock) || (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) == (4 + 1)) { + if (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) < eLock) || (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) == (EXCLUSIVE_LOCK + 1)) { if (*Pager)(unsafe.Pointer(pPager)).FnoLock != 0 { - rc = 0 + rc = SQLITE_OK } else { rc = Xsqlite3OsLock(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, eLock) } - if (rc == 0) && ((int32((*Pager)(unsafe.Pointer(pPager)).FeLock) != (4 + 1)) || (eLock == 4)) { + if (rc == SQLITE_OK) && ((int32((*Pager)(unsafe.Pointer(pPager)).FeLock) != (EXCLUSIVE_LOCK + 1)) || (eLock == EXCLUSIVE_LOCK)) { (*Pager)(unsafe.Pointer(pPager)).FeLock = U8(eLock) } @@ -30603,18 +30041,18 @@ func readSuperJournal(tls *libc.TLS, pJrnl uintptr, zSuper uintptr, nSuper U32) var u U32 // Unsigned loop counter // var aMagic [8]uint8 at bp+16, 8 // A buffer to hold the magic header - *(*int8)(unsafe.Pointer(zSuper + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(zSuper)) = int8(0) - if (((((((((0 != (libc.AssignInt32(&rc, Xsqlite3OsFileSize(tls, pJrnl, bp /* &szJ */)))) || + if (((((((((SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3OsFileSize(tls, pJrnl, bp /* &szJ */)))) || (*(*I64)(unsafe.Pointer(bp /* szJ */)) < int64(16))) || - (0 != (libc.AssignInt32(&rc, read32bits(tls, pJrnl, (*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(16)), bp+8 /* &len */))))) || + (SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, pJrnl, (*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(16)), bp+8 /* &len */))))) || (*(*U32)(unsafe.Pointer(bp + 8 /* len */)) >= nSuper)) || (I64(*(*U32)(unsafe.Pointer(bp + 8 /* len */))) > (*(*I64)(unsafe.Pointer(bp /* szJ */)) - int64(16)))) || (*(*U32)(unsafe.Pointer(bp + 8 /* len */)) == U32(0))) || - (0 != (libc.AssignInt32(&rc, read32bits(tls, pJrnl, (*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(12)), bp+12 /* &cksum */))))) || - (0 != (libc.AssignInt32(&rc, Xsqlite3OsRead(tls, pJrnl, bp+16 /* &aMagic[0] */, 8, (*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(8))))))) || + (SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, pJrnl, (*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(12)), bp+12 /* &cksum */))))) || + (SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3OsRead(tls, pJrnl, bp+16 /* &aMagic[0] */, 8, (*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(8))))))) || (libc.Xmemcmp(tls, bp+16 /* &aMagic[0] */, uintptr(unsafe.Pointer(&aJournalMagic)), uint64(8)) != 0)) || - (0 != (libc.AssignInt32(&rc, Xsqlite3OsRead(tls, pJrnl, zSuper, int32(*(*U32)(unsafe.Pointer(bp + 8 /* len */))), ((*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(16))-I64(*(*U32)(unsafe.Pointer(bp + 8 /* len */)))))))) { + (SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3OsRead(tls, pJrnl, zSuper, int32(*(*U32)(unsafe.Pointer(bp + 8 /* len */))), ((*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(16))-I64(*(*U32)(unsafe.Pointer(bp + 8 /* len */)))))))) { return rc } @@ -30632,7 +30070,7 @@ func readSuperJournal(tls *libc.TLS, pJrnl uintptr, zSuper uintptr, nSuper U32) *(*int8)(unsafe.Pointer(zSuper + uintptr(*(*U32)(unsafe.Pointer(bp + 8 /* len */))))) = int8(0) *(*int8)(unsafe.Pointer(zSuper + uintptr((*(*U32)(unsafe.Pointer(bp + 8 /* len */)) + U32(1))))) = int8(0) - return 0 + return SQLITE_OK } // Return the offset of the sector boundary at or immediately @@ -30681,7 +30119,7 @@ func zeroJournalHdr(tls *libc.TLS, pPager uintptr, doTruncate int32) int32 { /* bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code if (*Pager)(unsafe.Pointer(pPager)).FjournalOff != 0 { var iLimit I64 = (*Pager)(unsafe.Pointer(pPager)).FjournalSizeLimit // Local cache of jsl @@ -30691,8 +30129,8 @@ func zeroJournalHdr(tls *libc.TLS, pPager uintptr, doTruncate int32) int32 { /* } else { rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, uintptr(unsafe.Pointer(&zeroHdr)), int32(unsafe.Sizeof(zeroHdr)), int64(0)) } - if (rc == 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { - rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (0x00010 | int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags))) + if (rc == SQLITE_OK) && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { + rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (SQLITE_SYNC_DATAONLY | int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags))) } // At this point the transaction is committed but the write lock @@ -30700,11 +30138,11 @@ func zeroJournalHdr(tls *libc.TLS, pPager uintptr, doTruncate int32) int32 { /* // the persistent journal and the journal file currently consumes more // space than that limit allows for, truncate it now. There is no need // to sync the file following this operation. - if (rc == 0) && (iLimit > int64(0)) { + if (rc == SQLITE_OK) && (iLimit > int64(0)) { // var sz I64 at bp, 8 rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp /* &sz */) - if (rc == 0) && (*(*I64)(unsafe.Pointer(bp /* sz */)) > iLimit) { + if (rc == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp /* sz */)) > iLimit) { rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iLimit) } } @@ -30712,7 +30150,7 @@ func zeroJournalHdr(tls *libc.TLS, pPager uintptr, doTruncate int32) int32 { /* return rc } -var zeroHdr = [28]int8{int8(0)} /* sqlite3.c:53103:25 */ +var zeroHdr = [28]int8{0: int8(0)} /* sqlite3.c:53103:25 */ // The journal file must be open when this routine is called. A journal // header (JOURNAL_HDR_SZ bytes) is written into the journal file at the @@ -30728,7 +30166,7 @@ var zeroHdr = [28]int8{int8(0)} /* sqlite3.c:53103:25 */ // // Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space. func writeJournalHdr(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:53142:12: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var zHeader uintptr = (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace // Temporary space used to build header var nHeader U32 = U32((*Pager)(unsafe.Pointer(pPager)).FpageSize) // Size of buffer pointed to by zHeader var nWrite U32 // Bytes of header sector written @@ -30770,30 +30208,30 @@ func writeJournalHdr(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:53142:1 // * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees // that garbage data is never appended to the journal file. - if (((*Pager)(unsafe.Pointer(pPager)).FnoSync != 0) || (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 4)) || - ((Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd) & 0x00000200) != 0) { + if (((*Pager)(unsafe.Pointer(pPager)).FnoSync != 0) || (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_MEMORY)) || + ((Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd) & SQLITE_IOCAP_SAFE_APPEND) != 0) { libc.Xmemcpy(tls, zHeader, uintptr(unsafe.Pointer(&aJournalMagic)), uint64(unsafe.Sizeof(aJournalMagic))) - Xsqlite3Put4byte(tls, (zHeader + uintptr(uint64(unsafe.Sizeof(aJournalMagic)))), 0xffffffff) + Xsqlite3Put4byte(tls, (zHeader + 8), 0xffffffff) } else { libc.Xmemset(tls, zHeader, 0, (uint64(unsafe.Sizeof(aJournalMagic)) + uint64(4))) } // The random check-hash initializer Xsqlite3_randomness(tls, int32(unsafe.Sizeof(U32(0))), (pPager + 52 /* &.cksumInit */)) - Xsqlite3Put4byte(tls, (zHeader + uintptr((uint64(unsafe.Sizeof(aJournalMagic)) + uint64(4)))), (*Pager)(unsafe.Pointer(pPager)).FcksumInit) + Xsqlite3Put4byte(tls, (zHeader + 12), (*Pager)(unsafe.Pointer(pPager)).FcksumInit) // The initial database size - Xsqlite3Put4byte(tls, (zHeader + uintptr((uint64(unsafe.Sizeof(aJournalMagic)) + uint64(8)))), (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize) + Xsqlite3Put4byte(tls, (zHeader + 16), (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize) // The assumed sector size for this process - Xsqlite3Put4byte(tls, (zHeader + uintptr((uint64(unsafe.Sizeof(aJournalMagic)) + uint64(12)))), (*Pager)(unsafe.Pointer(pPager)).FsectorSize) + Xsqlite3Put4byte(tls, (zHeader + 20), (*Pager)(unsafe.Pointer(pPager)).FsectorSize) // The page size - Xsqlite3Put4byte(tls, (zHeader + uintptr((uint64(unsafe.Sizeof(aJournalMagic)) + uint64(16)))), uint32((*Pager)(unsafe.Pointer(pPager)).FpageSize)) + Xsqlite3Put4byte(tls, (zHeader + 24), uint32((*Pager)(unsafe.Pointer(pPager)).FpageSize)) // Initializing the tail of the buffer is not necessary. Everything // works find if the following memset() is omitted. But initializing // the memory prevents valgrind from complaining, so we are willing to // take the performance hit. - libc.Xmemset(tls, (zHeader + uintptr((uint64(unsafe.Sizeof(aJournalMagic)) + uint64(20)))), 0, + libc.Xmemset(tls, (zHeader + 28), 0, (uint64(nHeader) - (uint64(unsafe.Sizeof(aJournalMagic)) + uint64(20)))) // In theory, it is only necessary to write the 28 bytes that the @@ -30812,7 +30250,7 @@ func writeJournalHdr(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:53142:1 // database page size. Since the zHeader buffer is only Pager.pageSize // bytes in size, more than one call to sqlite3OsWrite() may be required // to populate the entire journal header sector. - for nWrite = U32(0); (rc == 0) && (nWrite < ((*Pager)(unsafe.Pointer(pPager)).FsectorSize)); nWrite = nWrite + (nHeader) { + for nWrite = U32(0); (rc == SQLITE_OK) && (nWrite < ((*Pager)(unsafe.Pointer(pPager)).FsectorSize)); nWrite = nWrite + (nHeader) { rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, zHeader, int32(nHeader), (*Pager)(unsafe.Pointer(pPager)).FjournalOff) @@ -30853,7 +30291,7 @@ func readJournalHdr(tls *libc.TLS, pPager uintptr, isHot int32, journalSize I64, // point, return SQLITE_DONE. (*Pager)(unsafe.Pointer(pPager)).FjournalOff = journalHdrOffset(tls, pPager) if ((*Pager)(unsafe.Pointer(pPager)).FjournalOff + (I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize))) > journalSize { - return 101 + return SQLITE_DONE } iHdrOff = (*Pager)(unsafe.Pointer(pPager)).FjournalOff @@ -30867,16 +30305,16 @@ func readJournalHdr(tls *libc.TLS, pPager uintptr, isHot int32, journalSize I64, return rc } if libc.Xmemcmp(tls, bp /* &aMagic[0] */, uintptr(unsafe.Pointer(&aJournalMagic)), uint64(unsafe.Sizeof([8]uint8{}))) != 0 { - return 101 + return SQLITE_DONE } } // Read the first three 32-bit fields of the journal header: The nRec // field, the checksum-initializer and the database size at the start // of the transaction. Return an error code if anything goes wrong. - if ((0 != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(8)), pNRec)))) || - (0 != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(12)), (pPager+52 /* &.cksumInit */)))))) || - (0 != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(16)), pDbSize)))) { + if ((SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(8)), pNRec)))) || + (SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(12)), (pPager+52 /* &.cksumInit */)))))) || + (SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(16)), pDbSize)))) { return rc } @@ -30887,8 +30325,8 @@ func readJournalHdr(tls *libc.TLS, pPager uintptr, isHot int32, journalSize I64, // Sector-size field of journal header // Read the page-size and sector-size journal header fields. - if (0 != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(20)), bp+8 /* &iSectorSize */)))) || - (0 != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(24)), bp+12 /* &iPageSize */)))) { + if (SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(20)), bp+8 /* &iSectorSize */)))) || + (SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(24)), bp+12 /* &iPageSize */)))) { return rc } @@ -30904,13 +30342,13 @@ func readJournalHdr(tls *libc.TLS, pPager uintptr, isHot int32, journalSize I64, // of two greater than or equal to 512 or 32, and not greater than their // respective compile time maximum limits. if (((((*(*U32)(unsafe.Pointer(bp + 12 /* iPageSize */)) < U32(512)) || (*(*U32)(unsafe.Pointer(bp + 8 /* iSectorSize */)) < U32(32))) || - (*(*U32)(unsafe.Pointer(bp + 12 /* iPageSize */)) > U32(65536))) || (*(*U32)(unsafe.Pointer(bp + 8 /* iSectorSize */)) > U32(0x10000))) || + (*(*U32)(unsafe.Pointer(bp + 12 /* iPageSize */)) > SQLITE_MAX_PAGE_SIZE)) || (*(*U32)(unsafe.Pointer(bp + 8 /* iSectorSize */)) > MAX_SECTOR_SIZE)) || (((*(*U32)(unsafe.Pointer(bp + 12 /* iPageSize */)) - U32(1)) & *(*U32)(unsafe.Pointer(bp + 12 /* iPageSize */))) != U32(0))) || (((*(*U32)(unsafe.Pointer(bp + 8 /* iSectorSize */)) - U32(1)) & *(*U32)(unsafe.Pointer(bp + 8 /* iSectorSize */))) != U32(0)) { // If the either the page-size or sector-size in the journal-header is // invalid, then the process that wrote the journal-header must have // crashed before the header was synced. In this case stop reading // the journal file here. - return 101 + return SQLITE_DONE } // Update the page-size to match the value read from the journal. @@ -30959,9 +30397,9 @@ func writeSuperJournal(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 { /* var cksum U32 = U32(0) // Checksum of string zSuper if (!(zSuper != 0) || - (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 4)) || + (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_MEMORY)) || !((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) { - return 0 + return SQLITE_OK } (*Pager)(unsafe.Pointer(pPager)).FsetSuper = U8(1) @@ -30999,7 +30437,7 @@ func writeSuperJournal(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 { /* // // Easiest thing to do in this scenario is to truncate the journal // file to the required size. - if (0 == (libc.AssignInt32(&rc, Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp /* &jrnlSize */)))) && + if (SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp /* &jrnlSize */)))) && (*(*I64)(unsafe.Pointer(bp /* jrnlSize */)) > (*Pager)(unsafe.Pointer(pPager)).FjournalOff) { rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (*Pager)(unsafe.Pointer(pPager)).FjournalOff) } @@ -31039,8 +30477,8 @@ func releaseAllSavepoints(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53471:13 // bitvecs of all open savepoints. Return SQLITE_OK if successful // or SQLITE_NOMEM if a malloc failure occurs. func addToSavepointBitvecs(tls *libc.TLS, pPager uintptr, pgno Pgno) int32 { /* sqlite3.c:53490:12: */ - var ii int32 // Loop counter - var rc int32 = 0 // Result code + var ii int32 // Loop counter + var rc int32 = SQLITE_OK // Result code for ii = 0; ii < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint; ii++ { var p uintptr = ((*Pager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(ii)*48) @@ -31076,7 +30514,7 @@ func pager_unlock(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53522:13: */ if (*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0) { Xsqlite3WalEndReadTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal) - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(0) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_OPEN } else if !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) { var rc int32 // Error code returned by pagerUnlockDb() var iDc int32 @@ -31091,7 +30529,7 @@ func pager_unlock(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53522:13: */ // another connection with journal_mode=delete might delete the file // out from under us. - if (0 == (iDc & 0x00000800)) || + if (0 == (iDc & SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN)) || (1 != (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) & 5)) { Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) } @@ -31100,16 +30538,16 @@ func pager_unlock(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53522:13: */ // file fails, set the current lock to UNKNOWN_LOCK. See the comment // above the #define for UNKNOWN_LOCK for an explanation of why this // is necessary. - rc = pagerUnlockDb(tls, pPager, 0) - if (rc != 0) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 6) { - (*Pager)(unsafe.Pointer(pPager)).FeLock = (U8(4 + 1)) + rc = pagerUnlockDb(tls, pPager, NO_LOCK) + if (rc != SQLITE_OK) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_ERROR) { + (*Pager)(unsafe.Pointer(pPager)).FeLock = (U8(EXCLUSIVE_LOCK + 1)) } // The pager state may be changed from PAGER_ERROR to PAGER_OPEN here // without clearing the error code. This is intentional - the error // code is cleared and the cache reset in the block below. - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(0) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_OPEN } // If Pager.errCode is set, the contents of the pager cache cannot be @@ -31121,19 +30559,19 @@ func pager_unlock(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53522:13: */ if int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) == 0 { pager_reset(tls, pPager) (*Pager)(unsafe.Pointer(pPager)).FchangeCountDone = U8(0) - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(0) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_OPEN } else { (*Pager)(unsafe.Pointer(pPager)).FeState = func() uint8 { if (*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0) { - return uint8(0) + return PAGER_OPEN } - return uint8(1) + return PAGER_READER }() } if (*Pager)(unsafe.Pointer(pPager)).FbUseFetch != 0 { Xsqlite3OsUnfetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, int64(0), uintptr(0)) } - (*Pager)(unsafe.Pointer(pPager)).FerrCode = 0 + (*Pager)(unsafe.Pointer(pPager)).FerrCode = SQLITE_OK setGetterMethod(tls, pPager) } @@ -31162,9 +30600,9 @@ func pager_unlock(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53522:13: */ func pager_error(tls *libc.TLS, pPager uintptr, rc int32) int32 { /* sqlite3.c:53619:12: */ var rc2 int32 = (rc & 0xff) - if (rc2 == 13) || (rc2 == 10) { + if (rc2 == SQLITE_FULL) || (rc2 == SQLITE_IOERR) { (*Pager)(unsafe.Pointer(pPager)).FerrCode = rc - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(6) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_ERROR setGetterMethod(tls, pPager) } return rc @@ -31249,8 +30687,8 @@ func pagerFlushOnCommit(tls *libc.TLS, pPager uintptr, bCommit int32) int32 { /* // to the first error encountered (the journal finalization one) is // returned. func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommit int32) int32 { /* sqlite3.c:53713:12: */ - var rc int32 = 0 // Error code from journal finalization operation - var rc2 int32 = 0 // Error code from db file unlock operation + var rc int32 = SQLITE_OK // Error code from journal finalization operation + var rc2 int32 = SQLITE_OK // Error code from db file unlock operation // Do nothing if the pager does not have an open write transaction // or at least a RESERVED lock. This function may be called when there @@ -31265,8 +30703,8 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi // read-transaction, this function is called with eState==PAGER_READER // and eLock==EXCLUSIVE_LOCK when the read-transaction is closed. - if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) < 2) && (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) < 2) { - return 0 + if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) < PAGER_WRITER_LOCKED) && (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) < RESERVED_LOCK) { + return SQLITE_OK } releaseAllSavepoints(tls, pPager) @@ -31277,12 +30715,12 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi if Xsqlite3JournalIsInMemory(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) != 0 { // assert( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ); Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) - } else if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 3 { + } else if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_TRUNCATE { if (*Pager)(unsafe.Pointer(pPager)).FjournalOff == int64(0) { - rc = 0 + rc = SQLITE_OK } else { rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, int64(0)) - if (rc == 0) && ((*Pager)(unsafe.Pointer(pPager)).FfullSync != 0) { + if (rc == SQLITE_OK) && ((*Pager)(unsafe.Pointer(pPager)).FfullSync != 0) { // Make sure the new file size is written into the inode right away. // Otherwise the journal might resurrect following a power loss and // cause the last transaction to roll back. See @@ -31291,8 +30729,8 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi } } (*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0) - } else if (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 1) || - (((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) && (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != 5)) { + } else if (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_PERSIST) || + (((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) && (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_WAL)) { rc = zeroJournalHdr(tls, pPager, (libc.Bool32((hasSuper != 0) || ((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0)))) (*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0) } else { @@ -31312,7 +30750,7 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi Xsqlite3BitvecDestroy(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal) (*Pager)(unsafe.Pointer(pPager)).FpInJournal = uintptr(0) (*Pager)(unsafe.Pointer(pPager)).FnRec = 0 - if rc == 0 { + if rc == SQLITE_OK { if ((*Pager)(unsafe.Pointer(pPager)).FmemDb != 0) || (pagerFlushOnCommit(tls, pPager, bCommit) != 0) { Xsqlite3PcacheCleanAll(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) } else { @@ -31327,7 +30765,7 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi // lock held on the database file. rc2 = Xsqlite3WalEndWriteTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal) - } else if ((rc == 0) && (bCommit != 0)) && ((*Pager)(unsafe.Pointer(pPager)).FdbFileSize > (*Pager)(unsafe.Pointer(pPager)).FdbSize) { + } else if ((rc == SQLITE_OK) && (bCommit != 0)) && ((*Pager)(unsafe.Pointer(pPager)).FdbFileSize > (*Pager)(unsafe.Pointer(pPager)).FdbSize) { // This branch is taken when committing a transaction in rollback-journal // mode if the database file on disk is larger than the database image. // At this point the journal has been finalized and the transaction @@ -31338,22 +30776,22 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi rc = pager_truncate(tls, pPager, (*Pager)(unsafe.Pointer(pPager)).FdbSize) } - if (rc == 0) && (bCommit != 0) { - rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, 22, uintptr(0)) - if rc == 12 { - rc = 0 + if (rc == SQLITE_OK) && (bCommit != 0) { + rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_COMMIT_PHASETWO, uintptr(0)) + if rc == SQLITE_NOTFOUND { + rc = SQLITE_OK } } if !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) && (!((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0)) || (Xsqlite3WalExclusiveMode(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, 0) != 0)) { - rc2 = pagerUnlockDb(tls, pPager, 1) + rc2 = pagerUnlockDb(tls, pPager, SHARED_LOCK) } - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(1) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_READER (*Pager)(unsafe.Pointer(pPager)).FsetSuper = U8(0) return func() int32 { - if rc == 0 { + if rc == SQLITE_OK { return rc2 } return rc @@ -31376,9 +30814,9 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi // the pager to enter the ERROR state. Which will be cleared by the // call to pager_unlock(), as described above. func pagerUnlockAndRollback(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53860:13: */ - if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) != 6) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) != 0) { + if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) != PAGER_ERROR) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) != PAGER_OPEN) { - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= 2 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_LOCKED { Xsqlite3BeginBenignMalloc(tls) Xsqlite3PagerRollback(tls, pPager) Xsqlite3EndBenignMalloc(tls) @@ -31489,11 +30927,11 @@ func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDo jfd = (*Pager)(unsafe.Pointer(pPager)).Fsjfd } rc = read32bits(tls, jfd, *(*I64)(unsafe.Pointer(pOffset)), bp /* &pgno */) - if rc != 0 { + if rc != SQLITE_OK { return rc } rc = Xsqlite3OsRead(tls, jfd, aData, (*Pager)(unsafe.Pointer(pPager)).FpageSize, ((*(*I64)(unsafe.Pointer(pOffset))) + int64(4))) - if rc != 0 { + if rc != SQLITE_OK { return rc } *(*I64)(unsafe.Pointer(pOffset)) += (I64(((*Pager)(unsafe.Pointer(pPager)).FpageSize + 4) + (isMainJrnl * 4))) @@ -31504,10 +30942,10 @@ func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDo // detect this invalid data (with high probability) and ignore it. if (*(*Pgno)(unsafe.Pointer(bp /* pgno */)) == Pgno(0)) || (*(*Pgno)(unsafe.Pointer(bp /* pgno */)) == (Pgno((Xsqlite3PendingByte / ((*Pager)(unsafe.Pointer(pPager)).FpageSize)) + 1))) { - return 101 + return SQLITE_DONE } if (*(*Pgno)(unsafe.Pointer(bp /* pgno */)) > (*Pager)(unsafe.Pointer(pPager)).FdbSize) || (Xsqlite3BitvecTest(tls, pDone, *(*Pgno)(unsafe.Pointer(bp /* pgno */))) != 0) { - return 0 + return SQLITE_OK } if isMainJrnl != 0 { rc = read32bits(tls, jfd, ((*(*I64)(unsafe.Pointer(pOffset))) - int64(4)), bp+4 /* &cksum */) @@ -31515,19 +30953,19 @@ func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDo return rc } if !(isSavepnt != 0) && (pager_cksum(tls, pPager, aData) != *(*U32)(unsafe.Pointer(bp + 4 /* cksum */))) { - return 101 + return SQLITE_DONE } } // If this page has already been played back before during the current // rollback, then don't bother to play it back again. - if (pDone != 0) && ((libc.AssignInt32(&rc, Xsqlite3BitvecSet(tls, pDone, *(*Pgno)(unsafe.Pointer(bp /* pgno */))))) != 0) { + if (pDone != 0) && ((libc.AssignInt32(&rc, Xsqlite3BitvecSet(tls, pDone, *(*Pgno)(unsafe.Pointer(bp /* pgno */))))) != SQLITE_OK) { return rc } // When playing back page 1, restore the nReserve setting - if (*(*Pgno)(unsafe.Pointer(bp /* pgno */)) == Pgno(1)) && (int32((*Pager)(unsafe.Pointer(pPager)).FnReserve) != int32(*(*U8)(unsafe.Pointer((aData) + uintptr(20))))) { - (*Pager)(unsafe.Pointer(pPager)).FnReserve = I16(*(*U8)(unsafe.Pointer((aData) + uintptr(20)))) + if (*(*Pgno)(unsafe.Pointer(bp /* pgno */)) == Pgno(1)) && (int32((*Pager)(unsafe.Pointer(pPager)).FnReserve) != int32(*(*U8)(unsafe.Pointer((aData) + 20)))) { + (*Pager)(unsafe.Pointer(pPager)).FnReserve = I16(*(*U8)(unsafe.Pointer((aData) + 20))) } // If the pager is in CACHEMOD state, then there must be a copy of this @@ -31573,10 +31011,10 @@ func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDo if isMainJrnl != 0 { isSynced = (libc.Bool32(((*Pager)(unsafe.Pointer(pPager)).FnoSync != 0) || (*(*I64)(unsafe.Pointer(pOffset)) <= (*Pager)(unsafe.Pointer(pPager)).FjournalHdr))) } else { - isSynced = (libc.Bool32((*(*uintptr)(unsafe.Pointer(bp + 8 /* pPg */)) == uintptr(0)) || (0 == (int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pPg */)))).Fflags) & 0x008)))) + isSynced = (libc.Bool32((*(*uintptr)(unsafe.Pointer(bp + 8 /* pPg */)) == uintptr(0)) || (0 == (int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pPg */)))).Fflags) & PGHDR_NEED_SYNC)))) } if (((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0)) && - ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= 4) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 0))) && + ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_DBMOD) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN))) && (isSynced != 0) { var ofst I64 = ((I64(*(*Pgno)(unsafe.Pointer(bp /* pgno */)) - Pgno(1))) * I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)) @@ -31611,11 +31049,11 @@ func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDo // and if the pager requires a journal-sync, then mark the page as // requiring a journal-sync before it is written. - *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) |= U8((0x02)) + *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) |= U8((SPILLFLAG_ROLLBACK)) rc = Xsqlite3PagerGet(tls, pPager, *(*Pgno)(unsafe.Pointer(bp /* pgno */)), bp+8 /* &pPg */, 1) - *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) &= libc.Uint8FromInt32((^libc.Int32(0x02))) - if rc != 0 { + *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) &= libc.Uint8FromInt32((libc.CplInt32(SPILLFLAG_ROLLBACK))) + if rc != SQLITE_OK { return rc } Xsqlite3PcacheMakeDirty(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPg */))) @@ -31638,7 +31076,7 @@ func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDo // If this was page 1, then restore the value of Pager.dbFileVers. // Do this before any decoding. if *(*Pgno)(unsafe.Pointer(bp /* pgno */)) == Pgno(1) { - libc.Xmemcpy(tls, (pPager + 136 /* &.dbFileVers */), ((pData) + uintptr(24)), uint64(unsafe.Sizeof([16]int8{}))) + libc.Xmemcpy(tls, (pPager + 136 /* &.dbFileVers */), ((pData) + 24), uint64(unsafe.Sizeof([16]int8{}))) } Xsqlite3PcacheRelease(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPg */))) } @@ -31719,16 +31157,16 @@ func pager_delsuper(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 { /* sq if !(!(pSuper != 0)) { goto __1 } - rc = 7 + rc = SQLITE_NOMEM pJournal = uintptr(0) goto __2 __1: - flags = (0x00000001 | 0x00004000) + flags = (SQLITE_OPEN_READONLY | SQLITE_OPEN_SUPER_JOURNAL) rc = Xsqlite3OsOpen(tls, pVfs, zSuper, pSuper, flags, uintptr(0)) pJournal = ((pSuper) + uintptr((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)) __2: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __3 } goto delsuper_out @@ -31740,7 +31178,7 @@ __3: // sufficient space (in zSuperPtr) to hold the names of super-journal // files extracted from regular rollback-journals. rc = Xsqlite3OsFileSize(tls, pSuper, bp /* &nSuperJournal */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } goto delsuper_out @@ -31751,13 +31189,13 @@ __4: if !(!(zSuperJournal != 0)) { goto __5 } - rc = 7 + rc = SQLITE_NOMEM goto delsuper_out __5: ; zSuperPtr = (zSuperJournal + uintptr((*(*I64)(unsafe.Pointer(bp /* nSuperJournal */)) + int64(2)))) rc = Xsqlite3OsRead(tls, pSuper, zSuperJournal, int32(*(*I64)(unsafe.Pointer(bp /* nSuperJournal */))), int64(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __6 } goto delsuper_out @@ -31771,8 +31209,8 @@ __7: if !((I64((int64(zJournal) - int64(zSuperJournal)) / 1)) < *(*I64)(unsafe.Pointer(bp /* nSuperJournal */))) { goto __8 } - rc = Xsqlite3OsAccess(tls, pVfs, zJournal, 0, bp+8 /* &exists */) - if !(rc != 0) { + rc = Xsqlite3OsAccess(tls, pVfs, zJournal, SQLITE_ACCESS_EXISTS, bp+8 /* &exists */) + if !(rc != SQLITE_OK) { goto __9 } goto delsuper_out @@ -31781,9 +31219,9 @@ __9: if !(*(*int32)(unsafe.Pointer(bp + 8 /* exists */)) != 0) { goto __10 } - flags1 = (0x00000001 | 0x00004000) + flags1 = (SQLITE_OPEN_READONLY | SQLITE_OPEN_SUPER_JOURNAL) rc = Xsqlite3OsOpen(tls, pVfs, zJournal, pJournal, flags1, uintptr(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __11 } goto delsuper_out @@ -31792,14 +31230,14 @@ __11: rc = readSuperJournal(tls, pJournal, zSuperPtr, uint32(nSuperPtr)) Xsqlite3OsClose(tls, pJournal) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } goto delsuper_out __12: ; - c = (libc.Bool32((int32(*(*int8)(unsafe.Pointer(zSuperPtr + uintptr(0)))) != 0) && (libc.Xstrcmp(tls, zSuperPtr, zSuper) == 0))) + c = (libc.Bool32((int32(*(*int8)(unsafe.Pointer(zSuperPtr))) != 0) && (libc.Xstrcmp(tls, zSuperPtr, zSuper) == 0))) if !(c != 0) { goto __13 } @@ -31852,10 +31290,10 @@ func pager_truncate(tls *libc.TLS, pPager uintptr, nPage Pgno) int32 { /* sqlite bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK if ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0)) && - ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= 4) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 0)) { + ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_DBMOD) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN)) { // var currentSize I64 at bp, 8 var newSize I64 @@ -31864,7 +31302,7 @@ func pager_truncate(tls *libc.TLS, pPager uintptr, nPage Pgno) int32 { /* sqlite // TODO: Is it safe to use Pager.dbFileSize here? rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp /* ¤tSize */) newSize = (I64(szPage) * I64(nPage)) - if (rc == 0) && (*(*I64)(unsafe.Pointer(bp /* currentSize */)) != newSize) { + if (rc == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp /* currentSize */)) != newSize) { if *(*I64)(unsafe.Pointer(bp /* currentSize */)) > newSize { rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, newSize) } else if (*(*I64)(unsafe.Pointer(bp /* currentSize */)) + I64(szPage)) <= newSize { @@ -31873,7 +31311,7 @@ func pager_truncate(tls *libc.TLS, pPager uintptr, nPage Pgno) int32 { /* sqlite rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, pTmp, szPage, (newSize - I64(szPage))) } - if rc == 0 { + if rc == SQLITE_OK { (*Pager)(unsafe.Pointer(pPager)).FdbFileSize = nPage } } @@ -31887,9 +31325,9 @@ func Xsqlite3SectorSize(tls *libc.TLS, pFile uintptr) int32 { /* sqlite3.c:54339 var iRet int32 = Xsqlite3OsSectorSize(tls, pFile) if iRet < 32 { iRet = 512 - } else if iRet > 0x10000 { + } else if iRet > MAX_SECTOR_SIZE { - iRet = 0x10000 + iRet = MAX_SECTOR_SIZE } return iRet } @@ -31918,7 +31356,7 @@ func Xsqlite3SectorSize(tls *libc.TLS, pFile uintptr) int32 { /* sqlite3.c:54339 func setSectorSize(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:54373:13: */ if ((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0) || - ((Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd) & 0x00001000) != 0) { + ((Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd) & SQLITE_IOCAP_POWERSAFE_OVERWRITE) != 0) { // Sector size doesn't matter for temporary files. Also, the file // may not have been opened yet, in which case the OsSectorSize() // call will segfault. @@ -32013,7 +31451,7 @@ func pager_playback(tls *libc.TLS, pPager uintptr, isHot int32) int32 { /* sqlit // the journal is empty. rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp+16 /* &szJ */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __1 } goto end_playback @@ -32032,14 +31470,14 @@ __1: // for pageSize. zSuper = (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace rc = readSuperJournal(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, zSuper, (uint32((*Sqlite3_vfs)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).FpVfs)).FmxPathname + 1))) - if !((rc == 0) && (*(*int8)(unsafe.Pointer(zSuper + uintptr(0))) != 0)) { + if !((rc == SQLITE_OK) && (*(*int8)(unsafe.Pointer(zSuper)) != 0)) { goto __2 } - rc = Xsqlite3OsAccess(tls, pVfs, zSuper, 0, bp+24 /* &res */) + rc = Xsqlite3OsAccess(tls, pVfs, zSuper, SQLITE_ACCESS_EXISTS, bp+24 /* &res */) __2: ; zSuper = uintptr(0) - if !((rc != 0) || !(*(*int32)(unsafe.Pointer(bp + 24 /* res */)) != 0)) { + if !((rc != SQLITE_OK) || !(*(*int32)(unsafe.Pointer(bp + 24 /* res */)) != 0)) { goto __3 } goto end_playback @@ -32060,13 +31498,13 @@ __4: // it is corrupted, then a process must have failed while writing it. // This indicates nothing more needs to be rolled back. rc = readJournalHdr(tls, pPager, isHot, *(*I64)(unsafe.Pointer(bp + 16 /* szJ */)), bp+28 /* &nRec */, bp+32 /* &mxPg */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __6 } - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __7 } - rc = 0 + rc = SQLITE_OK __7: ; goto end_playback @@ -32111,7 +31549,7 @@ __9: goto __10 } rc = pager_truncate(tls, pPager, *(*Pgno)(unsafe.Pointer(bp + 32 /* mxPg */))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __11 } goto end_playback @@ -32136,20 +31574,20 @@ __12: __15: ; rc = pager_playback_one_page(tls, pPager, (pPager + 96 /* &.journalOff */), uintptr(0), 1, 0) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __16 } nPlayback++ goto __17 __16: - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __18 } (*Pager)(unsafe.Pointer(pPager)).FjournalOff = *(*I64)(unsafe.Pointer(bp + 16 /* szJ */)) goto __14 goto __19 __18: - if !(rc == (10 | (int32(2) << 8))) { + if !(rc == (SQLITE_IOERR | (int32(2) << 8))) { goto __20 } // If the journal has been truncated, simply stop reading and @@ -32157,7 +31595,7 @@ __18: // not completely written and synced prior to a crash. In that // case, the database should have never been written in the // first place so it is OK to simply abandon the rollback. - rc = 0 + rc = SQLITE_OK goto end_playback goto __21 __20: @@ -32185,7 +31623,7 @@ __5: //NOTREACHED end_playback: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __22 } rc = Xsqlite3PagerSetPagesize(tls, pPager, bp+36 /* &savedPageSize */, -1) @@ -32206,7 +31644,7 @@ __22: // in case this has happened, clear the changeCountDone flag now. (*Pager)(unsafe.Pointer(pPager)).FchangeCountDone = (*Pager)(unsafe.Pointer(pPager)).FtempFile - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __23 } zSuper = (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace @@ -32214,21 +31652,21 @@ __22: __23: ; - if !((rc == 0) && - ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= 4) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 0))) { + if !((rc == SQLITE_OK) && + ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_DBMOD) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN))) { goto __24 } rc = Xsqlite3PagerSync(tls, pPager, uintptr(0)) __24: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __25 } - rc = pager_end_transaction(tls, pPager, (libc.Bool32(int32(*(*int8)(unsafe.Pointer(zSuper + uintptr(0)))) != 0)), 0) + rc = pager_end_transaction(tls, pPager, (libc.Bool32(int32(*(*int8)(unsafe.Pointer(zSuper))) != 0)), 0) __25: ; - if !(((rc == 0) && (*(*int8)(unsafe.Pointer(zSuper + uintptr(0))) != 0)) && (*(*int32)(unsafe.Pointer(bp + 24 /* res */)) != 0)) { + if !(((rc == SQLITE_OK) && (*(*int8)(unsafe.Pointer(zSuper)) != 0)) && (*(*int32)(unsafe.Pointer(bp + 24 /* res */)) != 0)) { goto __26 } // If there was a super-journal and this routine will return success, @@ -32240,7 +31678,7 @@ __26: if !((isHot != 0) && (nPlayback != 0)) { goto __27 } - Xsqlite3_log(tls, (27 | (int32(2) << 8)), ts+2862, /* "recovered %d pag..." */ + Xsqlite3_log(tls, (SQLITE_NOTICE | (int32(2) << 8)), ts+2862, /* "recovered %d pag..." */ libc.VaList(bp, nPlayback, (*Pager)(unsafe.Pointer(pPager)).FzJournal)) __27: ; @@ -32267,7 +31705,7 @@ func readDbPage(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:54657:12: */ defer tls.Free(4) var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager // Pager object associated with page pPg - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code *(*U32)(unsafe.Pointer(bp /* iFrame */)) = U32(0) // Frame of WAL containing pgno @@ -32282,8 +31720,8 @@ func readDbPage(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:54657:12: */ } else { var iOffset I64 = ((I64((*PgHdr)(unsafe.Pointer(pPg)).Fpgno - Pgno(1))) * I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)) rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, (*PgHdr)(unsafe.Pointer(pPg)).FpData, (*Pager)(unsafe.Pointer(pPager)).FpageSize, iOffset) - if rc == (10 | (int32(2) << 8)) { - rc = 0 + if rc == (SQLITE_IOERR | (int32(2) << 8)) { + rc = SQLITE_OK } } @@ -32302,7 +31740,7 @@ func readDbPage(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:54657:12: */ // we should still be ok. libc.Xmemset(tls, pPager+136 /* &.dbFileVers */, 0xff, uint64(unsafe.Sizeof([16]int8{}))) } else { - var dbFileVers uintptr = (((*PgHdr)(unsafe.Pointer(pPg)).FpData) + uintptr(24)) + var dbFileVers uintptr = (((*PgHdr)(unsafe.Pointer(pPg)).FpData) + 24) libc.Xmemcpy(tls, (pPager + 136 /* &.dbFileVers */), dbFileVers, uint64(unsafe.Sizeof([16]int8{}))) } } @@ -32327,7 +31765,7 @@ func pager_write_changecounter(tls *libc.TLS, pPg uintptr) { /* sqlite3.c:54720: // bytes 92..95 store the change counter for which the version number // is valid. Xsqlite3Put4byte(tls, (((*PgHdr)(unsafe.Pointer(pPg)).FpData) + uintptr(92)), change_counter) - Xsqlite3Put4byte(tls, (((*PgHdr)(unsafe.Pointer(pPg)).FpData) + uintptr(96)), uint32(3033000)) + Xsqlite3Put4byte(tls, (((*PgHdr)(unsafe.Pointer(pPg)).FpData) + uintptr(96)), SQLITE_VERSION_NUMBER) } // This function is invoked once for each page that has already been @@ -32341,7 +31779,7 @@ func pager_write_changecounter(tls *libc.TLS, pPg uintptr) { /* sqlite3.c:54720: // attempt to reload content from the database is required and fails, // return an SQLite error code. Otherwise, SQLITE_OK. func pagerUndoCallback(tls *libc.TLS, pCtx uintptr, iPg Pgno) int32 { /* sqlite3.c:54747:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pPager uintptr = pCtx var pPg uintptr @@ -32351,7 +31789,7 @@ func pagerUndoCallback(tls *libc.TLS, pCtx uintptr, iPg Pgno) int32 { /* sqlite3 Xsqlite3PcacheDrop(tls, pPg) } else { rc = readDbPage(tls, pPg) - if rc == 0 { + if rc == SQLITE_OK { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((pPager + 256 /* &.xReiniter */))))(tls, pPg) } Xsqlite3PagerUnrefNotNull(tls, pPg) @@ -32386,7 +31824,7 @@ func pagerRollbackWal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:54782: f func(*libc.TLS, uintptr, Pgno) int32 }{pagerUndoCallback})), pPager) pList = Xsqlite3PcacheDirtyList(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) - for (pList != 0) && (rc == 0) { + for (pList != 0) && (rc == SQLITE_OK) { var pNext uintptr = (*PgHdr)(unsafe.Pointer(pList)).FpDirty rc = pagerUndoCallback(tls, pPager, (*PgHdr)(unsafe.Pointer(pList)).Fpgno) pList = pNext @@ -32428,14 +31866,14 @@ func pagerWalFrames(tls *libc.TLS, pPager uintptr, pList uintptr, nTruncate Pgno } else { nList = 1 } - *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(2)*4)) += (nList) + *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + 2*4)) += (nList) if (*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pList */)))).Fpgno == Pgno(1) { pager_write_changecounter(tls, *(*uintptr)(unsafe.Pointer(bp /* pList */))) } rc = Xsqlite3WalFrames(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, (*Pager)(unsafe.Pointer(pPager)).FpageSize, *(*uintptr)(unsafe.Pointer(bp /* pList */)), nTruncate, isCommit, int32((*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags)) - if (rc == 0) && ((*Pager)(unsafe.Pointer(pPager)).FpBackup != 0) { + if (rc == SQLITE_OK) && ((*Pager)(unsafe.Pointer(pPager)).FpBackup != 0) { for p = *(*uintptr)(unsafe.Pointer(bp /* pList */)); p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirty { Xsqlite3BackupUpdate(tls, (*Pager)(unsafe.Pointer(pPager)).FpBackup, (*PgHdr)(unsafe.Pointer(p)).Fpgno, (*PgHdr)(unsafe.Pointer(p)).FpData) } @@ -32464,7 +31902,7 @@ func pagerBeginReadTransaction(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3 Xsqlite3WalEndReadTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal) rc = Xsqlite3WalBeginReadTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, bp /* &changed */) - if (rc != 0) || (*(*int32)(unsafe.Pointer(bp /* changed */)) != 0) { + if (rc != SQLITE_OK) || (*(*int32)(unsafe.Pointer(bp /* changed */)) != 0) { pager_reset(tls, pPager) if (*Pager)(unsafe.Pointer(pPager)).FbUseFetch != 0 { Xsqlite3OsUnfetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, int64(0), uintptr(0)) @@ -32502,7 +31940,7 @@ func pagerPagecount(tls *libc.TLS, pPager uintptr, pnPage uintptr) int32 { /* sq if (nPage == Pgno(0)) && ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0)) { *(*I64)(unsafe.Pointer(bp /* n */)) = int64(0) // Size of db file in bytes var rc int32 = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp /* &n */) - if rc != 0 { + if rc != SQLITE_OK { return rc } nPage = (Pgno(((*(*I64)(unsafe.Pointer(bp /* n */)) + I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)) - int64(1)) / I64((*Pager)(unsafe.Pointer(pPager)).FpageSize))) @@ -32516,7 +31954,7 @@ func pagerPagecount(tls *libc.TLS, pPager uintptr, pnPage uintptr) int32 { /* sq } *(*Pgno)(unsafe.Pointer(pnPage)) = nPage - return 0 + return SQLITE_OK } // Check if the *-wal file that corresponds to the database opened by pPager @@ -32539,14 +31977,14 @@ func pagerOpenWalIfPresent(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK if !(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) { // var isWal int32 at bp, 4 // True if WAL file exists rc = Xsqlite3OsAccess(tls, - (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzWal, 0, bp /* &isWal */) - if rc == 0 { + (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzWal, SQLITE_ACCESS_EXISTS, bp /* &isWal */) + if rc == SQLITE_OK { if *(*int32)(unsafe.Pointer(bp /* isWal */)) != 0 { // var nPage Pgno at bp+4, 4 // Size of the database file @@ -32561,8 +31999,8 @@ func pagerOpenWalIfPresent(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5 rc = Xsqlite3PagerOpenWal(tls, pPager, uintptr(0)) } - } else if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 5 { - (*Pager)(unsafe.Pointer(pPager)).FjournalMode = U8(0) + } else if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_WAL { + (*Pager)(unsafe.Pointer(pPager)).FjournalMode = PAGER_JOURNALMODE_DELETE } } } @@ -32609,14 +32047,14 @@ func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) i var szJ I64 // Effective size of the main journal var iHdrOff I64 // End of first segment of main-journal records - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var pDone uintptr = uintptr(0) // Bitvec to ensure pages played back only once // Allocate a bitvec to use to store the set of pages rolled back if pSavepoint != 0 { pDone = Xsqlite3BitvecCreate(tls, (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FnOrig) if !(pDone != 0) { - return 7 + return SQLITE_NOMEM } } @@ -32653,7 +32091,7 @@ func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) i iHdrOff = szJ } (*Pager)(unsafe.Pointer(pPager)).FjournalOff = (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FiOffset - for (rc == 0) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff < iHdrOff) { + for (rc == SQLITE_OK) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff < iHdrOff) { rc = pager_playback_one_page(tls, pPager, (pPager + 96 /* &.journalOff */), pDone, 1, 1) } @@ -32665,7 +32103,7 @@ func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) i // the first journal header seen and continuing until the effective end // of the main journal file. Continue to skip out-of-range pages and // continue adding pages rolled back to pDone. - for (rc == 0) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff < szJ) { + for (rc == SQLITE_OK) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff < szJ) { var ii U32 // Loop counter *(*U32)(unsafe.Pointer(bp /* nJRec */)) = U32(0) // Number of Journal Records // var dummy U32 at bp+4, 4 @@ -32679,7 +32117,7 @@ func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) i (((*Pager)(unsafe.Pointer(pPager)).FjournalHdr + (I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize))) == (*Pager)(unsafe.Pointer(pPager)).FjournalOff) { *(*U32)(unsafe.Pointer(bp /* nJRec */)) = (U32((szJ - (*Pager)(unsafe.Pointer(pPager)).FjournalOff) / (I64(((*Pager)(unsafe.Pointer(pPager)).FpageSize) + 8)))) } - for ii = U32(0); ((rc == 0) && (ii < *(*U32)(unsafe.Pointer(bp /* nJRec */)))) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff < szJ); ii++ { + for ii = U32(0); ((rc == SQLITE_OK) && (ii < *(*U32)(unsafe.Pointer(bp /* nJRec */)))) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff < szJ); ii++ { rc = pager_playback_one_page(tls, pPager, (pPager + 96 /* &.journalOff */), pDone, 1, 1) } @@ -32695,7 +32133,7 @@ func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) i if (*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0) { rc = Xsqlite3WalSavepointUndo(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, pSavepoint+32 /* &.aWalData */) } - for ii = (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FiSubRec; (rc == 0) && (ii < (*Pager)(unsafe.Pointer(pPager)).FnSubRec); ii++ { + for ii = (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FiSubRec; (rc == SQLITE_OK) && (ii < (*Pager)(unsafe.Pointer(pPager)).FnSubRec); ii++ { rc = pager_playback_one_page(tls, pPager, bp+8 /* &offset */, pDone, 0, 1) } @@ -32703,7 +32141,7 @@ func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) i } Xsqlite3BitvecDestroy(tls, pDone) - if rc == 0 { + if rc == SQLITE_OK { (*Pager)(unsafe.Pointer(pPager)).FjournalOff = szJ } @@ -32734,7 +32172,7 @@ func pagerFixMaplimit(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:55168:13: */ *(*Sqlite3_int64)(unsafe.Pointer(bp /* sz */)) = (*Pager)(unsafe.Pointer(pPager)).FszMmap (*Pager)(unsafe.Pointer(pPager)).FbUseFetch = (U8(libc.Bool32(*(*Sqlite3_int64)(unsafe.Pointer(bp /* sz */)) > int64(0)))) setGetterMethod(tls, pPager) - Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, 18, bp /* &sz */) + Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_MMAP_SIZE, bp /* &sz */) } } @@ -32799,26 +32237,26 @@ func Xsqlite3PagerShrink(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:55192:21: // Numeric values associated with these states are OFF==1, NORMAL=2, // and FULL=3. func Xsqlite3PagerSetFlags(tls *libc.TLS, pPager uintptr, pgFlags uint32) { /* sqlite3.c:55248:21: */ - var level uint32 = (pgFlags & uint32(0x07)) + var level uint32 = (pgFlags & PAGER_SYNCHRONOUS_MASK) if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 { (*Pager)(unsafe.Pointer(pPager)).FnoSync = U8(1) (*Pager)(unsafe.Pointer(pPager)).FfullSync = U8(0) (*Pager)(unsafe.Pointer(pPager)).FextraSync = U8(0) } else { (*Pager)(unsafe.Pointer(pPager)).FnoSync = func() uint8 { - if level == uint32(0x01) { + if level == PAGER_SYNCHRONOUS_OFF { return uint8(1) } return uint8(0) }() (*Pager)(unsafe.Pointer(pPager)).FfullSync = func() uint8 { - if level >= uint32(0x03) { + if level >= PAGER_SYNCHRONOUS_FULL { return uint8(1) } return uint8(0) }() (*Pager)(unsafe.Pointer(pPager)).FextraSync = func() uint8 { - if level == uint32(0x04) { + if level == PAGER_SYNCHRONOUS_EXTRA { return uint8(1) } return uint8(0) @@ -32826,22 +32264,22 @@ func Xsqlite3PagerSetFlags(tls *libc.TLS, pPager uintptr, pgFlags uint32) { /* s } if (*Pager)(unsafe.Pointer(pPager)).FnoSync != 0 { (*Pager)(unsafe.Pointer(pPager)).FsyncFlags = U8(0) - } else if (pgFlags & uint32(0x08)) != 0 { - (*Pager)(unsafe.Pointer(pPager)).FsyncFlags = U8(0x00003) + } else if (pgFlags & PAGER_FULLFSYNC) != 0 { + (*Pager)(unsafe.Pointer(pPager)).FsyncFlags = SQLITE_SYNC_FULL } else { - (*Pager)(unsafe.Pointer(pPager)).FsyncFlags = U8(0x00002) + (*Pager)(unsafe.Pointer(pPager)).FsyncFlags = SQLITE_SYNC_NORMAL } (*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags = (U8(int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags) << 2)) if (*Pager)(unsafe.Pointer(pPager)).FfullSync != 0 { *(*U8)(unsafe.Pointer(pPager + 15 /* &.walSyncFlags */)) |= U8((int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags))) } - if ((pgFlags & uint32(0x10)) != 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { - *(*U8)(unsafe.Pointer(pPager + 15 /* &.walSyncFlags */)) |= U8((int32(0x00003) << 2)) + if ((pgFlags & PAGER_CKPT_FULLFSYNC) != 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { + *(*U8)(unsafe.Pointer(pPager + 15 /* &.walSyncFlags */)) |= U8((int32(SQLITE_SYNC_FULL) << 2)) } - if (pgFlags & uint32(0x20)) != 0 { - *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) &= libc.Uint8FromInt32((^libc.Int32(0x01))) + if (pgFlags & PAGER_CACHESPILL) != 0 { + *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) &= libc.Uint8FromInt32((libc.CplInt32(SPILLFLAG_OFF))) } else { - *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) |= U8((0x01)) + *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) |= U8((SPILLFLAG_OFF)) } } @@ -32865,7 +32303,7 @@ func Xsqlite3PagerSetFlags(tls *libc.TLS, pPager uintptr, pgFlags uint32) { /* s func pagerOpentemp(tls *libc.TLS, pPager uintptr, pFile uintptr, vfsFlags int32) int32 { /* sqlite3.c:55308:12: */ var rc int32 // Return code - vfsFlags = vfsFlags | (((0x00000002 | 0x00000004) | 0x00000010) | 0x00000008) + vfsFlags = vfsFlags | (((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_DELETEONCLOSE) rc = Xsqlite3OsOpen(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, uintptr(0), pFile, vfsFlags, uintptr(0)) return rc @@ -32896,7 +32334,7 @@ func Xsqlite3PagerSetBusyHandler(tls *libc.TLS, pPager uintptr, xBusyHandler uin (*Pager)(unsafe.Pointer(pPager)).FpBusyHandlerArg = pBusyHandlerArg ap = (pPager + 224 /* &.xBusyHandler */) - Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, 15, ap) + Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_BUSYHANDLER, ap) } // Change the page size used by the Pager object. The new page size @@ -32931,7 +32369,7 @@ func Xsqlite3PagerSetPagesize(tls *libc.TLS, pPager uintptr, pPageSize uintptr, bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK // It is not possible to do a full assert_pager_state() here, as this // function may be called from within PagerOpen(), before the state @@ -32950,25 +32388,25 @@ func Xsqlite3PagerSetPagesize(tls *libc.TLS, pPager uintptr, pPageSize uintptr, var pNew uintptr = uintptr(0) // New temp space *(*I64)(unsafe.Pointer(bp /* nByte */)) = int64(0) - if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) > 0) && ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0)) { + if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) > PAGER_OPEN) && ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0)) { rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp /* &nByte */) } - if rc == 0 { + if rc == SQLITE_OK { // 8 bytes of zeroed overrun space is sufficient so that the b-tree // cell header parser will never run off the end of the allocation pNew = Xsqlite3PageMalloc(tls, (int32(pageSize + U32(8)))) if !(pNew != 0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, (pNew + uintptr(pageSize)), 0, uint64(8)) } } - if rc == 0 { + if rc == SQLITE_OK { pager_reset(tls, pPager) rc = Xsqlite3PcacheSetPageSize(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, int32(pageSize)) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3PageFree(tls, (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace) (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace = pNew (*Pager)(unsafe.Pointer(pPager)).FdbSize = (Pgno(((*(*I64)(unsafe.Pointer(bp /* nByte */)) + I64(pageSize)) - int64(1)) / I64(pageSize))) @@ -32979,7 +32417,7 @@ func Xsqlite3PagerSetPagesize(tls *libc.TLS, pPager uintptr, pPageSize uintptr, } *(*U32)(unsafe.Pointer(pPageSize)) = U32((*Pager)(unsafe.Pointer(pPager)).FpageSize) - if rc == 0 { + if rc == SQLITE_OK { if nReserve < 0 { nReserve = int32((*Pager)(unsafe.Pointer(pPager)).FnReserve) } @@ -33037,7 +32475,7 @@ func Xsqlite3PagerMaxPageCount(tls *libc.TLS, pPager uintptr, mxPage Pgno) Pgno // the error code is returned to the caller and the contents of the // output buffer undefined. func Xsqlite3PagerReadFileheader(tls *libc.TLS, pPager uintptr, N int32, pDest uintptr) int32 { /* sqlite3.c:55520:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK libc.Xmemset(tls, pDest, 0, uint64(N)) // This routine is only called by btree immediately after creating @@ -33047,8 +32485,8 @@ func Xsqlite3PagerReadFileheader(tls *libc.TLS, pPager uintptr, N int32, pDest u if (*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0) { rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, pDest, N, int64(0)) - if rc == (10 | (int32(2) << 8)) { - rc = 0 + if rc == (SQLITE_IOERR | (int32(2) << 8)) { + rc = SQLITE_OK } } return rc @@ -33084,7 +32522,7 @@ func pager_wait_on_lock(tls *libc.TLS, pPager uintptr, locktype int32) int32 { / // may be invoked during, according to the comment above // sqlite3PagerSetBusyhandler(). - for ok := true; ok; ok = ((rc == 5) && ((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((pPager + 224 /* &.xBusyHandler */))))(tls, (*Pager)(unsafe.Pointer(pPager)).FpBusyHandlerArg) != 0)) { + for ok := true; ok; ok = ((rc == SQLITE_BUSY) && ((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((pPager + 224 /* &.xBusyHandler */))))(tls, (*Pager)(unsafe.Pointer(pPager)).FpBusyHandlerArg) != 0)) { rc = pagerLockDb(tls, pPager, locktype) } return rc @@ -33148,11 +32586,11 @@ func Xsqlite3PagerTruncateImage(tls *libc.TLS, pPager uintptr, nPage Pgno) { /* // If everything goes as planned, SQLITE_OK is returned. Otherwise, // an SQLite error code. func pagerSyncHotJournal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:55664:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { - rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, 0x00002) + rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, SQLITE_SYNC_NORMAL) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (pPager + 104 /* &.journalHdr */)) } return rc @@ -33179,10 +32617,10 @@ func pagerAcquireMapPage(tls *libc.TLS, pPager uintptr, pgno Pgno, pData uintptr *(*uintptr)(unsafe.Pointer(ppPage)) = libc.AssignUintptr(&p, Xsqlite3MallocZero(tls, (uint64(uint64(unsafe.Sizeof(PgHdr{}))+uint64((*Pager)(unsafe.Pointer(pPager)).FnExtra))))) if p == uintptr(0) { Xsqlite3OsUnfetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, ((I64(pgno - Pgno(1))) * I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)), pData) - return 7 + return SQLITE_NOMEM } - (*PgHdr)(unsafe.Pointer(p)).FpExtra = (p + uintptr(1)*72) - (*PgHdr)(unsafe.Pointer(p)).Fflags = U16(0x020) + (*PgHdr)(unsafe.Pointer(p)).FpExtra = (p + 1*72) + (*PgHdr)(unsafe.Pointer(p)).Fflags = PGHDR_MMAP (*PgHdr)(unsafe.Pointer(p)).FnRef = int16(1) (*PgHdr)(unsafe.Pointer(p)).FpPager = pPager } @@ -33191,7 +32629,7 @@ func pagerAcquireMapPage(tls *libc.TLS, pPager uintptr, pgno Pgno, pData uintptr (*PgHdr)(unsafe.Pointer(p)).FpData = pData (*Pager)(unsafe.Pointer(pPager)).FnMmapOut++ - return 0 + return SQLITE_OK } // Release a reference to page pPg. pPg must have been returned by an @@ -33227,20 +32665,20 @@ func databaseIsUnmoved(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:55757 var rc int32 if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 { - return 0 + return SQLITE_OK } if (*Pager)(unsafe.Pointer(pPager)).FdbSize == Pgno(0) { - return 0 + return SQLITE_OK } - rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, 20, bp /* &bHasMoved */) - if rc == 12 { + rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_HAS_MOVED, bp /* &bHasMoved */) + if rc == SQLITE_NOTFOUND { // If the HAS_MOVED file-control is unimplemented, assume that the file // has not been moved. That is the historical behavior of SQLite: prior to // version 3.8.3, it never checked - rc = 0 - } else if (rc == 0) && (*(*int32)(unsafe.Pointer(bp /* bHasMoved */)) != 0) { - rc = (8 | (int32(4) << 8)) + rc = SQLITE_OK + } else if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* bHasMoved */)) != 0) { + rc = (SQLITE_READONLY | (int32(4) << 8)) } return rc } @@ -33267,8 +32705,8 @@ func Xsqlite3PagerClose(tls *libc.TLS, pPager uintptr, db uintptr) int32 { /* sq { var a uintptr = uintptr(0) - if ((db != 0) && (uint64(0) == ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000800)))) && - (0 == databaseIsUnmoved(tls, pPager)) { + if ((db != 0) && (uint64(0) == ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_NoCkptOnClose))) && + (SQLITE_OK == databaseIsUnmoved(tls, pPager)) { a = pTmp } Xsqlite3WalClose(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, db, int32((*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags), (*Pager)(unsafe.Pointer(pPager)).FpageSize, a) @@ -33302,7 +32740,7 @@ func Xsqlite3PagerClose(tls *libc.TLS, pPager uintptr, db uintptr) int32 { /* sq Xsqlite3PcacheClose(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) Xsqlite3_free(tls, pPager) - return 0 + return SQLITE_OK } // Increment the reference count for page pPg. @@ -33350,16 +32788,16 @@ func syncJournal(tls *libc.TLS, pPager uintptr, newHdr int32) int32 { /* sqlite3 var rc int32 // Return code rc = Xsqlite3PagerExclusiveLock(tls, pPager) - if rc != 0 { + if rc != SQLITE_OK { return rc } if !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { - if ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) && (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != 4) { + if ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) && (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_MEMORY) { var iDc int32 = Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd) - if 0 == (iDc & 0x00000200) { + if 0 == (iDc & SQLITE_IOCAP_SAFE_APPEND) { // This block deals with an obscure problem. If the last connection // that wrote to this database was operating in persistent-journal // mode, then the journal file may at this point actually be larger @@ -33387,14 +32825,14 @@ func syncJournal(tls *libc.TLS, pPager uintptr, newHdr int32) int32 { /* sqlite3 // var zHeader [12]U8 at bp, 12 libc.Xmemcpy(tls, bp /* &zHeader[0] */, uintptr(unsafe.Pointer(&aJournalMagic)), uint64(unsafe.Sizeof(aJournalMagic))) - Xsqlite3Put4byte(tls, (bp /* &zHeader */ + uintptr(uint64(unsafe.Sizeof(aJournalMagic)))), uint32((*Pager)(unsafe.Pointer(pPager)).FnRec)) + Xsqlite3Put4byte(tls, (bp /* &zHeader */ + 8), uint32((*Pager)(unsafe.Pointer(pPager)).FnRec)) iNextHdrOffset = journalHdrOffset(tls, pPager) rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp+12 /* &aMagic[0] */, 8, iNextHdrOffset) - if (rc == 0) && (0 == libc.Xmemcmp(tls, bp+12 /* &aMagic[0] */, uintptr(unsafe.Pointer(&aJournalMagic)), uint64(8))) { + if (rc == SQLITE_OK) && (0 == libc.Xmemcmp(tls, bp+12 /* &aMagic[0] */, uintptr(unsafe.Pointer(&aJournalMagic)), uint64(8))) { rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, uintptr(unsafe.Pointer(&zerobyte)), 1, iNextHdrOffset) } - if (rc != 0) && (rc != (10 | (int32(2) << 8))) { + if (rc != SQLITE_OK) && (rc != (SQLITE_IOERR | (int32(2) << 8))) { return rc } @@ -33408,38 +32846,38 @@ func syncJournal(tls *libc.TLS, pPager uintptr, newHdr int32) int32 { /* sqlite3 // for garbage data to be appended to the file, the nRec field // is populated with 0xFFFFFFFF when the journal header is written // and never needs to be updated. - if ((*Pager)(unsafe.Pointer(pPager)).FfullSync != 0) && (0 == (iDc & 0x00000400)) { + if ((*Pager)(unsafe.Pointer(pPager)).FfullSync != 0) && (0 == (iDc & SQLITE_IOCAP_SEQUENTIAL)) { rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags)) - if rc != 0 { + if rc != SQLITE_OK { return rc } } rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp /* &zHeader[0] */, int32(unsafe.Sizeof([12]U8{})), (*Pager)(unsafe.Pointer(pPager)).FjournalHdr) - if rc != 0 { + if rc != SQLITE_OK { return rc } } - if 0 == (iDc & 0x00000400) { + if 0 == (iDc & SQLITE_IOCAP_SEQUENTIAL) { rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags) | (func() int32 { - if int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags) == 0x00003 { - return 0x00010 + if int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags) == SQLITE_SYNC_FULL { + return SQLITE_SYNC_DATAONLY } return 0 }()))) - if rc != 0 { + if rc != SQLITE_OK { return rc } } (*Pager)(unsafe.Pointer(pPager)).FjournalHdr = (*Pager)(unsafe.Pointer(pPager)).FjournalOff - if (newHdr != 0) && (0 == (iDc & 0x00000200)) { + if (newHdr != 0) && (0 == (iDc & SQLITE_IOCAP_SAFE_APPEND)) { (*Pager)(unsafe.Pointer(pPager)).FnRec = 0 rc = writeJournalHdr(tls, pPager) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -33452,9 +32890,9 @@ func syncJournal(tls *libc.TLS, pPager uintptr, newHdr int32) int32 { /* sqlite3 // successfully synced. Either way, clear the PGHDR_NEED_SYNC flag on // all pages. Xsqlite3PcacheClearSyncFlags(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(4) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_WRITER_DBMOD - return 0 + return SQLITE_OK } var zerobyte U8 = U8(0) /* sqlite3.c:55950:27 */ @@ -33493,7 +32931,7 @@ func pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) int32 { bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code // This function is only called for rollback pagers in WRITER_DBMOD state. @@ -33508,15 +32946,15 @@ func pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) int32 { // Before the first write, give the VFS a hint of what the final // file size will be. - if ((rc == 0) && + if ((rc == SQLITE_OK) && ((*Pager)(unsafe.Pointer(pPager)).FdbHintSize < (*Pager)(unsafe.Pointer(pPager)).FdbSize)) && (((*PgHdr)(unsafe.Pointer(pList)).FpDirty != 0) || ((*PgHdr)(unsafe.Pointer(pList)).Fpgno > (*Pager)(unsafe.Pointer(pPager)).FdbHintSize)) { *(*Sqlite3_int64)(unsafe.Pointer(bp /* szFile */)) = (Sqlite3_int64((*Pager)(unsafe.Pointer(pPager)).FpageSize) * Sqlite3_int64((*Pager)(unsafe.Pointer(pPager)).FdbSize)) - Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, 5, bp /* &szFile */) + Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_SIZE_HINT, bp /* &szFile */) (*Pager)(unsafe.Pointer(pPager)).FdbHintSize = (*Pager)(unsafe.Pointer(pPager)).FdbSize } - for (rc == 0) && (pList != 0) { + for (rc == SQLITE_OK) && (pList != 0) { var pgno Pgno = (*PgHdr)(unsafe.Pointer(pList)).Fpgno // If there are dirty pages in the page cache with page numbers greater @@ -33526,7 +32964,7 @@ func pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) int32 { // // Also, do not write out any page that has the PGHDR_DONT_WRITE flag // set (set by sqlite3PagerDontWrite()). - if (pgno <= (*Pager)(unsafe.Pointer(pPager)).FdbSize) && (0 == (int32((*PgHdr)(unsafe.Pointer(pList)).Fflags) & 0x010)) { + if (pgno <= (*Pager)(unsafe.Pointer(pPager)).FdbSize) && (0 == (int32((*PgHdr)(unsafe.Pointer(pList)).Fflags) & PGHDR_DONT_WRITE)) { var offset I64 = ((I64(pgno - Pgno(1))) * I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)) // Offset to write var pData uintptr // Data to write @@ -33543,12 +32981,12 @@ func pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) int32 { // the value now stored in the database file. If writing this // page caused the database file to grow, update dbFileSize. if pgno == Pgno(1) { - libc.Xmemcpy(tls, (pPager + 136 /* &.dbFileVers */), (pData + uintptr(24)), uint64(unsafe.Sizeof([16]int8{}))) + libc.Xmemcpy(tls, (pPager + 136 /* &.dbFileVers */), (pData + 24), uint64(unsafe.Sizeof([16]int8{}))) } if pgno > (*Pager)(unsafe.Pointer(pPager)).FdbFileSize { (*Pager)(unsafe.Pointer(pPager)).FdbFileSize = pgno } - *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(2)*4))++ + *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + 2*4))++ // Update any backup objects copying the contents of this pager. Xsqlite3BackupUpdate(tls, (*Pager)(unsafe.Pointer(pPager)).FpBackup, pgno, (*PgHdr)(unsafe.Pointer(pList)).FpData) @@ -33570,13 +33008,13 @@ func pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) int32 { // SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() // fails. func openSubJournal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:56133:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if !((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fsjfd))).FpMethods != uintptr(0)) { - var flags int32 = ((((0x00002000 | 0x00000002) | - 0x00000004) | 0x00000010) | - 0x00000008) + var flags int32 = ((((SQLITE_OPEN_SUBJOURNAL | SQLITE_OPEN_READWRITE) | + SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | + SQLITE_OPEN_DELETEONCLOSE) var nStmtSpill int32 = Xsqlite3Config.FnStmtSpill - if (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 4) || ((*Pager)(unsafe.Pointer(pPager)).FsubjInMemory != 0) { + if (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_MEMORY) || ((*Pager)(unsafe.Pointer(pPager)).FsubjInMemory != 0) { nStmtSpill = -1 } rc = Xsqlite3JournalOpen(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, uintptr(0), (*Pager)(unsafe.Pointer(pPager)).Fsjfd, flags, nStmtSpill) @@ -33594,9 +33032,9 @@ func openSubJournal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:56133:12 // SQLITE_NOMEM if a malloc fails while setting a bit in a savepoint // bitvec. func subjournalPage(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:56159:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager - if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != 2 { + if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_OFF { // Open the sub-journal, if it has not already been opened @@ -33604,19 +33042,19 @@ func subjournalPage(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:56159:12: * // If the sub-journal was opened successfully (or was already open), // write the journal record into the file. - if rc == 0 { + if rc == SQLITE_OK { var pData uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpData var offset I64 = (I64((*Pager)(unsafe.Pointer(pPager)).FnSubRec) * (I64(4 + (*Pager)(unsafe.Pointer(pPager)).FpageSize))) var pData2 uintptr pData2 = pData rc = write32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fsjfd, offset, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fsjfd, pData2, (*Pager)(unsafe.Pointer(pPager)).FpageSize, (offset + int64(4))) } } } - if rc == 0 { + if rc == SQLITE_OK { (*Pager)(unsafe.Pointer(pPager)).FnSubRec++ rc = addToSavepointBitvecs(tls, pPager, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) @@ -33628,7 +33066,7 @@ func subjournalPageIfRequired(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5 if subjRequiresPage(tls, pPg) != 0 { return subjournalPage(tls, pPg) } else { - return 0 + return SQLITE_OK } return int32(0) } @@ -33652,7 +33090,7 @@ func subjournalPageIfRequired(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5 // is returned by sqlite3PcacheMakeClean() is not called. func pagerStress(tls *libc.TLS, p uintptr, pPg uintptr) int32 { /* sqlite3.c:56222:12: */ var pPager uintptr = p - var rc int32 = 0 + var rc int32 = SQLITE_OK // The doNotSpill NOSYNC bit is set during times when doing a sync of // journal (and adding a new header) is not allowed. This occurs @@ -33670,40 +33108,40 @@ func pagerStress(tls *libc.TLS, p uintptr, pPg uintptr) int32 { /* sqlite3.c:562 // be called in the error state. Nevertheless, we include a NEVER() // test for the error state as a safeguard against future changes. if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 { - return 0 + return SQLITE_OK } if ((*Pager)(unsafe.Pointer(pPager)).FdoNotSpill != 0) && - (((int32((*Pager)(unsafe.Pointer(pPager)).FdoNotSpill) & (0x02 | 0x01)) != 0) || - ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & 0x008) != 0)) { - return 0 + (((int32((*Pager)(unsafe.Pointer(pPager)).FdoNotSpill) & (SPILLFLAG_ROLLBACK | SPILLFLAG_OFF)) != 0) || + ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & PGHDR_NEED_SYNC) != 0)) { + return SQLITE_OK } - *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(3)*4))++ + *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + 3*4))++ (*PgHdr)(unsafe.Pointer(pPg)).FpDirty = uintptr(0) if (*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0) { // Write a single frame for this page to the log. rc = subjournalPageIfRequired(tls, pPg) - if rc == 0 { + if rc == SQLITE_OK { rc = pagerWalFrames(tls, pPager, pPg, uint32(0), 0) } } else { // Sync the journal file if required. - if ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & 0x008) != 0) || - (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 3) { + if ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & PGHDR_NEED_SYNC) != 0) || + (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_WRITER_CACHEMOD) { rc = syncJournal(tls, pPager, 1) } // Write the contents of the page out to the database file. - if rc == 0 { + if rc == SQLITE_OK { rc = pager_write_pagelist(tls, pPager, pPg) } } // Mark the page as clean. - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3PcacheMakeClean(tls, pPg) } @@ -33717,7 +33155,7 @@ func Xsqlite3PagerFlush(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5629 if !(int32((*Pager)(unsafe.Pointer(pPager)).FmemDb) != 0) { var pList uintptr = Xsqlite3PcacheDirtyList(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) - for (rc == 0) && (pList != 0) { + for (rc == SQLITE_OK) && (pList != 0) { var pNext uintptr = (*PgHdr)(unsafe.Pointer(pList)).FpDirty if int32((*PgHdr)(unsafe.Pointer(pList)).FnRef) == 0 { rc = pagerStress(tls, pPager, pList) @@ -33784,38 +33222,38 @@ func Xsqlite3PagerOpen(tls *libc.TLS, pVfs uintptr, ppPager uintptr, zFilename u var iDc int32 // var fout int32 at bp+8, 4 *(*uintptr)(unsafe.Pointer(bp /* pPager */)) = uintptr(0) - rc = 0 + rc = SQLITE_OK tempFile = 0 memDb = 0 readOnly = 0 zPathname = uintptr(0) nPathname = 0 - useJournal = (libc.Bool32((flags & 0x0001) == 0)) + useJournal = (libc.Bool32((flags & PAGER_OMIT_JOURNAL) == 0)) pcacheSize = Xsqlite3PcacheSize(tls) - *(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */)) = U32(4096) + *(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */)) = SQLITE_DEFAULT_PAGE_SIZE zUri = uintptr(0) nUriByte = 1 nUri = 0 // Number of URI parameters // Figure out how much space is required for each journal file-handle // (there are two of them, the main journal and the sub-journal). - journalFileSize = (((Xsqlite3JournalSize(tls, pVfs)) + 7) & ^libc.Int32(7)) + journalFileSize = (((Xsqlite3JournalSize(tls, pVfs)) + 7) & libc.CplInt32(7)) // Set the output variable to NULL in case an error occurs. *(*uintptr)(unsafe.Pointer(ppPager)) = uintptr(0) - if !((flags & 0x0002) != 0) { + if !((flags & PAGER_MEMORY) != 0) { goto __1 } memDb = 1 - if !((zFilename != 0) && (*(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0)) { + if !((zFilename != 0) && (*(*int8)(unsafe.Pointer(zFilename)) != 0)) { goto __2 } zPathname = Xsqlite3DbStrDup(tls, uintptr(0), zFilename) if !(zPathname == uintptr(0)) { goto __3 } - return 7 + return SQLITE_NOMEM __3: ; nPathname = Xsqlite3Strlen30(tls, zPathname) @@ -33828,7 +33266,7 @@ __1: // Compute and store the full pathname in an allocated buffer pointed // to by zPathname, length nPathname. Or, if this is a temporary file, // leave both nPathname and zPathname set to 0. - if !((zFilename != 0) && (*(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0)) { + if !((zFilename != 0) && (*(*int8)(unsafe.Pointer(zFilename)) != 0)) { goto __4 } nPathname = ((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname + 1) @@ -33836,24 +33274,24 @@ __1: if !(zPathname == uintptr(0)) { goto __5 } - return 7 + return SQLITE_NOMEM __5: ; - *(*int8)(unsafe.Pointer(zPathname + uintptr(0))) = int8(0) // Make sure initialized even if FullPathname() fails + *(*int8)(unsafe.Pointer(zPathname)) = int8(0) // Make sure initialized even if FullPathname() fails rc = Xsqlite3OsFullPathname(tls, pVfs, zFilename, nPathname, zPathname) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __6 } - if !(rc == (0 | (int32(2) << 8))) { + if !(rc == (SQLITE_OK | (int32(2) << 8))) { goto __7 } - if !((vfsFlags & 0x01000000) != 0) { + if !((vfsFlags & SQLITE_OPEN_NOFOLLOW) != 0) { goto __8 } - rc = (14 | (int32(6) << 8)) + rc = (SQLITE_CANTOPEN | (int32(6) << 8)) goto __9 __8: - rc = 0 + rc = SQLITE_OK __9: ; __7: @@ -33872,9 +33310,9 @@ __10: goto __10 __11: ; - nUriByte = (int32((int64((z + uintptr(1))) - int64(zUri)) / 1)) + nUriByte = (int32((int64((z + 1)) - int64(zUri)) / 1)) - if !((rc == 0) && ((nPathname + 8) > (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname)) { + if !((rc == SQLITE_OK) && ((nPathname + 8) > (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname)) { goto __12 } // This branch is taken when the journal path required by @@ -33885,7 +33323,7 @@ __11: rc = Xsqlite3CantopenError(tls, 56435) __12: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __13 } Xsqlite3DbFree(tls, uintptr(0), zPathname) @@ -33939,21 +33377,21 @@ __4: // specific formatting and order of the various filenames, so if the format // changes here, be sure to change it there as well. pPtr = Xsqlite3MallocZero(tls, - (uint64((((((((((((((((((uint64(unsafe.Sizeof(Pager{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)) + (uint64(((pcacheSize) + 7) & ^libc.Int32(7)))) + (uint64((((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile) + 7) & ^libc.Int32(7)))) + (uint64(journalFileSize * 2))) + uint64(unsafe.Sizeof(uintptr(0)))) + uint64(4)) + uint64(nPathname)) + uint64(1)) + uint64(nUriByte)) + uint64(nPathname)) + uint64(8)) + uint64(1)) + uint64(nPathname)) + uint64(4)) + uint64(1)) + uint64(3)))) + (uint64((((((((((((((((((uint64(unsafe.Sizeof(Pager{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))) + (uint64(((pcacheSize) + 7) & libc.CplInt32(7)))) + (uint64((((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile) + 7) & libc.CplInt32(7)))) + (uint64(journalFileSize * 2))) + uint64(unsafe.Sizeof(uintptr(0)))) + uint64(4)) + uint64(nPathname)) + uint64(1)) + uint64(nUriByte)) + uint64(nPathname)) + uint64(8)) + uint64(1)) + uint64(nPathname)) + uint64(4)) + uint64(1)) + uint64(3)))) if !(!(pPtr != 0)) { goto __14 } Xsqlite3DbFree(tls, uintptr(0), zPathname) - return 7 + return SQLITE_NOMEM __14: ; *(*uintptr)(unsafe.Pointer(bp /* pPager */)) = pPtr - pPtr += (uintptr(((uint64(unsafe.Sizeof(Pager{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + pPtr += (uintptr(((uint64(unsafe.Sizeof(Pager{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FpPCache = pPtr - pPtr += (uintptr(((pcacheSize) + 7) & ^libc.Int32(7))) + pPtr += (uintptr(((pcacheSize) + 7) & libc.CplInt32(7))) (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).Ffd = pPtr - pPtr += (uintptr((((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile) + 7) & ^libc.Int32(7))) + pPtr += (uintptr((((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile) + 7) & libc.CplInt32(7))) (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).Fsjfd = pPtr pPtr += uintptr(journalFileSize) (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).Fjfd = pPtr @@ -34023,13 +33461,13 @@ __22: (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FvfsFlags = U32(vfsFlags) // Open the pager file. - if !((zFilename != 0) && (*(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0)) { + if !((zFilename != 0) && (*(*int8)(unsafe.Pointer(zFilename)) != 0)) { goto __23 } *(*int32)(unsafe.Pointer(bp + 8 /* fout */)) = 0 // VFS flags returned by xOpen() rc = Xsqlite3OsOpen(tls, pVfs, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FzFilename, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).Ffd, vfsFlags, bp+8 /* &fout */) - readOnly = (libc.Bool32((*(*int32)(unsafe.Pointer(bp + 8 /* fout */)) & 0x00000001) != 0)) + readOnly = (libc.Bool32((*(*int32)(unsafe.Pointer(bp + 8 /* fout */)) & SQLITE_OPEN_READONLY) != 0)) // If the file was successfully opened for read/write access, // choose a default page size in case we have to create the @@ -34038,7 +33476,7 @@ __22: // + SQLITE_DEFAULT_PAGE_SIZE, // + The value returned by sqlite3OsSectorSize() // + The largest page size that can be written atomically. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __25 } iDc = Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).Ffd) @@ -34050,10 +33488,10 @@ __22: if !(*(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */)) < (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FsectorSize) { goto __27 } - if !((*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FsectorSize > U32(8192)) { + if !((*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FsectorSize > SQLITE_MAX_DEFAULT_PAGE_SIZE) { goto __28 } - *(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */)) = U32(8192) + *(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */)) = SQLITE_MAX_DEFAULT_PAGE_SIZE goto __29 __28: *(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */)) = (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FsectorSize @@ -34064,11 +33502,11 @@ __27: __26: ; (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FnoLock = U8(Xsqlite3_uri_boolean(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FzFilename, ts+2903 /* "nolock" */, 0)) - if !(((iDc & 0x00002000) != 0) || + if !(((iDc & SQLITE_IOCAP_IMMUTABLE) != 0) || (Xsqlite3_uri_boolean(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FzFilename, ts+2910 /* "immutable" */, 0) != 0)) { goto __30 } - vfsFlags = vfsFlags | (0x00000001) + vfsFlags = vfsFlags | (SQLITE_OPEN_READONLY) goto act_like_temp_file __30: ; @@ -34087,16 +33525,16 @@ __23: // This branch also runs for files marked as immutable. act_like_temp_file: tempFile = 1 - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FeState = U8(1) // Pretend we already have a lock - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FeLock = U8(4) // Pretend we are in EXCLUSIVE mode - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FnoLock = U8(1) // Do no locking - readOnly = (vfsFlags & 0x00000001) + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FeState = PAGER_READER // Pretend we already have a lock + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FeLock = EXCLUSIVE_LOCK // Pretend we are in EXCLUSIVE mode + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FnoLock = U8(1) // Do no locking + readOnly = (vfsFlags & SQLITE_OPEN_READONLY) __24: ; // The following call to PagerSetPagesize() serves to set the value of // Pager.pageSize and to allocate the Pager.pTmpSpace buffer. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __31 } @@ -34106,10 +33544,10 @@ __31: ; // Initialize the PCache object. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __32 } - nExtra = (((nExtra) + 7) & ^libc.Int32(7)) + nExtra = (((nExtra) + 7) & libc.CplInt32(7)) rc = Xsqlite3PcacheOpen(tls, int32(*(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */))), nExtra, libc.BoolInt32(!(memDb != 0)), func() uintptr { @@ -34124,7 +33562,7 @@ __32: ; // If an error occurred above, free the Pager structure and close the file. - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __33 } Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).Ffd) @@ -34141,7 +33579,7 @@ __33: // pPager->stmtSize = 0; // pPager->stmtJSize = 0; // pPager->nPage = 0; - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FmxPgno = Pgno(1073741823) + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FmxPgno = SQLITE_MAX_PAGE_COUNT // pPager->state = PAGER_UNLOCK; // pPager->errMask = 0; (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FtempFile = U8(tempFile) @@ -34160,8 +33598,8 @@ __33: __34: (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FfullSync = U8(1) (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FextraSync = U8(0) - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FsyncFlags = U8(0x00002) - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FwalSyncFlags = (U8(0x00002 | (int32(0x00002) << 2))) + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FsyncFlags = SQLITE_SYNC_NORMAL + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FwalSyncFlags = (U8(SQLITE_SYNC_NORMAL | (int32(SQLITE_SYNC_NORMAL) << 2))) __35: ; // pPager->pFirst = 0; @@ -34174,13 +33612,13 @@ __35: if !(!(useJournal != 0)) { goto __36 } - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FjournalMode = U8(2) + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FjournalMode = PAGER_JOURNALMODE_OFF goto __37 __36: if !((memDb != 0) || (0 != 0)) { goto __38 } - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FjournalMode = U8(4) + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FjournalMode = PAGER_JOURNALMODE_MEMORY __38: ; __37: @@ -34193,7 +33631,7 @@ __37: // pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c *(*uintptr)(unsafe.Pointer(ppPager)) = *(*uintptr)(unsafe.Pointer(bp /* pPager */)) - return 0 + return SQLITE_OK } // Return the sqlite3_file for the main database given the name @@ -34242,15 +33680,15 @@ func hasHotJournal(tls *libc.TLS, pPager uintptr, pExists uintptr) int32 { /* sq defer tls.Free(17) var pVfs uintptr = (*Pager)(unsafe.Pointer(pPager)).FpVfs - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code *(*int32)(unsafe.Pointer(bp /* exists */)) = 1 // True if a journal file is present var jrnlOpen int32 = libc.BoolInt32(!(!((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)))) *(*int32)(unsafe.Pointer(pExists)) = 0 if !(jrnlOpen != 0) { - rc = Xsqlite3OsAccess(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0, bp /* &exists */) + rc = Xsqlite3OsAccess(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, SQLITE_ACCESS_EXISTS, bp /* &exists */) } - if (rc == 0) && (*(*int32)(unsafe.Pointer(bp /* exists */)) != 0) { + if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* exists */)) != 0) { *(*int32)(unsafe.Pointer(bp + 4 /* locked */)) = 0 // True if some process holds a RESERVED lock // Race condition here: Another process might have been holding the @@ -34261,12 +33699,12 @@ func hasHotJournal(tls *libc.TLS, pPager uintptr, pExists uintptr) int32 { /* sq // in fact there is none. This results in a false-positive which will // be dealt with by the playback routine. Ticket #3883. rc = Xsqlite3OsCheckReservedLock(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp+4 /* &locked */) - if (rc == 0) && !(*(*int32)(unsafe.Pointer(bp + 4 /* locked */)) != 0) { + if (rc == SQLITE_OK) && !(*(*int32)(unsafe.Pointer(bp + 4 /* locked */)) != 0) { // var nPage Pgno at bp+8, 4 // Number of pages in database file rc = pagerPagecount(tls, pPager, bp+8 /* &nPage */) - if rc == 0 { + if rc == SQLITE_OK { // If the database is zero pages in size, that means that either (1) the // journal is a remnant from a prior database with the same name where // the database file but not the journal was deleted, or (2) the initial @@ -34276,10 +33714,10 @@ func hasHotJournal(tls *libc.TLS, pPager uintptr, pExists uintptr) int32 { /* sq // journal_mode=PERSIST. if (*(*Pgno)(unsafe.Pointer(bp + 8 /* nPage */)) == Pgno(0)) && !(jrnlOpen != 0) { Xsqlite3BeginBenignMalloc(tls) - if pagerLockDb(tls, pPager, 2) == 0 { + if pagerLockDb(tls, pPager, RESERVED_LOCK) == SQLITE_OK { Xsqlite3OsDelete(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0) if !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) { - pagerUnlockDb(tls, pPager, 1) + pagerUnlockDb(tls, pPager, SHARED_LOCK) } } Xsqlite3EndBenignMalloc(tls) @@ -34290,20 +33728,20 @@ func hasHotJournal(tls *libc.TLS, pPager uintptr, pExists uintptr) int32 { /* sq // If there is, then we consider this journal to be hot. If not, // it can be ignored. if !(jrnlOpen != 0) { - *(*int32)(unsafe.Pointer(bp + 12 /* f */)) = (0x00000001 | 0x00000800) + *(*int32)(unsafe.Pointer(bp + 12 /* f */)) = (SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_JOURNAL) rc = Xsqlite3OsOpen(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, (*Pager)(unsafe.Pointer(pPager)).Fjfd, *(*int32)(unsafe.Pointer(bp + 12 /* f */)), bp+12 /* &f */) } - if rc == 0 { + if rc == SQLITE_OK { *(*U8)(unsafe.Pointer(bp + 16 /* first */)) = U8(0) rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp+16 /* &first */, 1, int64(0)) - if rc == (10 | (int32(2) << 8)) { - rc = 0 + if rc == (SQLITE_IOERR | (int32(2) << 8)) { + rc = SQLITE_OK } if !(jrnlOpen != 0) { Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) } *(*int32)(unsafe.Pointer(pExists)) = (libc.Bool32(int32(*(*U8)(unsafe.Pointer(bp + 16 /* first */))) != 0)) - } else if rc == 14 { + } else if rc == SQLITE_CANTOPEN { // If we cannot open the rollback journal file in order to see if // it has a zero header, that might be due to an I/O error, or // it might be due to the race condition described above and in @@ -34313,7 +33751,7 @@ func hasHotJournal(tls *libc.TLS, pPager uintptr, pExists uintptr) int32 { /* sq // with it under an EXCLUSIVE lock where we do not need to // worry so much with race conditions. *(*int32)(unsafe.Pointer(pExists)) = 1 - rc = 0 + rc = SQLITE_OK } } } @@ -34377,20 +33815,20 @@ func Xsqlite3PagerSharedLock(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c // var dbFileVers [16]int8 at bp+12, 16 // var bHotJournal int32 at bp, 4 - rc = 0 // Return code + rc = SQLITE_OK // Return code // This routine is only called from b-tree and only when there are no // outstanding pages. This implies that the pager state should either // be OPEN or READER. READER is only possible if the pager is or was in // exclusive access mode. - if !(!((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0)) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 0)) { + if !(!((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0)) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN)) { goto __1 } *(*int32)(unsafe.Pointer(bp /* bHotJournal */)) = 1 // True if there exists a hot journal-file - rc = pager_wait_on_lock(tls, pPager, 1) - if !(rc != 0) { + rc = pager_wait_on_lock(tls, pPager, SHARED_LOCK) + if !(rc != SQLITE_OK) { goto __2 } @@ -34400,13 +33838,13 @@ __2: // If a journal file exists, and there is no RESERVED lock on the // database file, then it either needs to be played back or deleted. - if !(int32((*Pager)(unsafe.Pointer(pPager)).FeLock) <= 1) { + if !(int32((*Pager)(unsafe.Pointer(pPager)).FeLock) <= SHARED_LOCK) { goto __3 } rc = hasHotJournal(tls, pPager, bp /* &bHotJournal */) __3: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } goto failed @@ -34418,7 +33856,7 @@ __4: if !((*Pager)(unsafe.Pointer(pPager)).FreadOnly != 0) { goto __6 } - rc = (8 | (int32(3) << 8)) + rc = (SQLITE_READONLY | (int32(3) << 8)) goto failed __6: ; @@ -34437,8 +33875,8 @@ __6: // // Unless the pager is in locking_mode=exclusive mode, the lock is // downgraded to SHARED_LOCK before this function returns. - rc = pagerLockDb(tls, pPager, 4) - if !(rc != 0) { + rc = pagerLockDb(tls, pPager, EXCLUSIVE_LOCK) + if !(rc != SQLITE_OK) { goto __7 } goto failed @@ -34462,16 +33900,16 @@ __7: } pVfs = (*Pager)(unsafe.Pointer(pPager)).FpVfs // True if journal file exists rc = Xsqlite3OsAccess(tls, - pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0, bp+4 /* &bExists */) - if !((rc == 0) && (*(*int32)(unsafe.Pointer(bp + 4 /* bExists */)) != 0)) { + pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, SQLITE_ACCESS_EXISTS, bp+4 /* &bExists */) + if !((rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 4 /* bExists */)) != 0)) { goto __9 } *(*int32)(unsafe.Pointer(bp + 8 /* fout */)) = 0 - f = (0x00000002 | 0x00000800) + f = (SQLITE_OPEN_READWRITE | SQLITE_OPEN_MAIN_JOURNAL) rc = Xsqlite3OsOpen(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, (*Pager)(unsafe.Pointer(pPager)).Fjfd, f, bp+8 /* &fout */) - if !((rc == 0) && ((*(*int32)(unsafe.Pointer(bp + 8 /* fout */)) & 0x00000001) != 0)) { + if !((rc == SQLITE_OK) && ((*(*int32)(unsafe.Pointer(bp + 8 /* fout */)) & SQLITE_OPEN_READONLY) != 0)) { goto __10 } rc = Xsqlite3CantopenError(tls, 56964) @@ -34495,11 +33933,11 @@ __8: } rc = pagerSyncHotJournal(tls, pPager) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __13 } rc = pager_playback(tls, pPager, libc.BoolInt32(!((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0))) - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(0) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_OPEN __13: ; goto __12 @@ -34507,13 +33945,13 @@ __11: if !(!(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0)) { goto __14 } - pagerUnlockDb(tls, pPager, 1) + pagerUnlockDb(tls, pPager, SHARED_LOCK) __14: ; __12: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __15 } // This branch is taken if an error occurs while trying to open @@ -34544,10 +33982,10 @@ __5: } rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp+12 /* &dbFileVers */, int32(unsafe.Sizeof([16]int8{})), int64(24)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __17 } - if !(rc != (10 | (int32(2) << 8))) { + if !(rc != (SQLITE_IOERR | (int32(2) << 8))) { goto __18 } goto failed @@ -34594,7 +34032,7 @@ __1: __21: ; - if !(((int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) == 0) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 0)) && (rc == 0)) { + if !(((int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) == 0) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN)) && (rc == SQLITE_OK)) { goto __22 } rc = pagerPagecount(tls, pPager, (pPager + 28 /* &.dbSize */)) @@ -34602,7 +34040,7 @@ __22: ; failed: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __23 } @@ -34610,7 +34048,7 @@ failed: goto __24 __23: - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(1) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_READER (*Pager)(unsafe.Pointer(pPager)).FhasHeldSharedLock = U8(1) __24: ; @@ -34693,7 +34131,7 @@ func getPageNormal(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, fla var pPg uintptr var noContent U8 // True if PAGER_GET_NOCONTENT is set // var pBase uintptr at bp, 8 - rc = 0 + rc = SQLITE_OK if !(pgno == Pgno(0)) { goto __1 @@ -34707,7 +34145,7 @@ __1: } pPg = uintptr(0) rc = Xsqlite3PcacheFetchStress(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, pgno, bp /* &pBase */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __3 } goto pager_acquire_err @@ -34716,7 +34154,7 @@ __3: if !(*(*uintptr)(unsafe.Pointer(bp /* pBase */)) == uintptr(0)) { goto __4 } - rc = 7 + rc = SQLITE_NOMEM goto pager_acquire_err __4: ; @@ -34724,15 +34162,15 @@ __2: ; pPg = libc.AssignPtrUintptr(ppPage, Xsqlite3PcacheFetchFinish(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, pgno, *(*uintptr)(unsafe.Pointer(bp /* pBase */)))) - noContent = (U8(libc.Bool32((flags & 0x01) != 0))) + noContent = (U8(libc.Bool32((flags & PAGER_GET_NOCONTENT) != 0))) if !(((*PgHdr)(unsafe.Pointer(pPg)).FpPager != 0) && !(noContent != 0)) { goto __5 } // In this case the pcache already contains an initialized copy of // the page. Return without further ado. - *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(0)*4))++ - return 0 + *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */)))++ + return SQLITE_OK goto __6 __5: @@ -34757,7 +34195,7 @@ __7: if !(pgno > (*Pager)(unsafe.Pointer(pPager)).FmxPgno) { goto __10 } - rc = 13 + rc = SQLITE_FULL goto pager_acquire_err __10: ; @@ -34787,9 +34225,9 @@ __11: goto __9 __8: ; - *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(1)*4))++ + *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + 1*4))++ rc = readDbPage(tls, pPg) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __13 } goto pager_acquire_err @@ -34800,7 +34238,7 @@ __9: __6: ; - return 0 + return SQLITE_OK pager_acquire_err: ; @@ -34820,7 +34258,7 @@ func getPageMMap(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags bp := tls.Alloc(24) defer tls.Free(24) - var rc int32 = 0 + var rc int32 = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */)) = uintptr(0) *(*U32)(unsafe.Pointer(bp /* iFrame */)) = U32(0) // Frame to read from WAL file @@ -34829,7 +34267,7 @@ func getPageMMap(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags // flag was specified by the caller. And so long as the db is not a // temporary or in-memory database. var bMmapOk int32 = (libc.Bool32((pgno > Pgno(1)) && - ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 1) || ((flags & 0x02) != 0)))) + ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_READER) || ((flags & PAGER_GET_READONLY) != 0)))) // Optimization note: Adding the "pgno<=1" term before "pgno==0" here // allows the compiler optimizer to reuse the results of the "pgno>1" @@ -34841,7 +34279,7 @@ func getPageMMap(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags if (bMmapOk != 0) && ((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0)) { rc = Xsqlite3WalFindFrame(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, pgno, bp /* &iFrame */) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0) return rc } @@ -34850,8 +34288,8 @@ func getPageMMap(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags *(*uintptr)(unsafe.Pointer(bp + 8 /* pData */)) = uintptr(0) rc = Xsqlite3OsFetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, ((I64(pgno - Pgno(1))) * I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)), (*Pager)(unsafe.Pointer(pPager)).FpageSize, bp+8 /* &pData */) - if (rc == 0) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* pData */)) != 0) { - if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) > 1) || ((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0) { + if (rc == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* pData */)) != 0) { + if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) > PAGER_READER) || ((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0) { *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */)) = Xsqlite3PagerLookup(tls, pPager, pgno) } if *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */)) == uintptr(0) { @@ -34862,10 +34300,10 @@ func getPageMMap(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags if *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */)) != 0 { *(*uintptr)(unsafe.Pointer(ppPage)) = *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */)) - return 0 + return SQLITE_OK } } - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0) return rc } @@ -34919,7 +34357,7 @@ func Xsqlite3PagerLookup(tls *libc.TLS, pPager uintptr, pgno Pgno) uintptr { /* // pages reaches zero it drops the database lock. func Xsqlite3PagerUnrefNotNull(tls *libc.TLS, pPg uintptr) { /* sqlite3.c:57391:21: */ - if (int32((*DbPage)(unsafe.Pointer(pPg)).Fflags) & 0x020) != 0 { + if (int32((*DbPage)(unsafe.Pointer(pPg)).Fflags) & PGHDR_MMAP) != 0 { // Page1 is never memory mapped pagerReleaseMapPage(tls, pPg) } else { @@ -34965,7 +34403,7 @@ func Xsqlite3PagerUnrefPageOne(tls *libc.TLS, pPg uintptr) { /* sqlite3.c:57406: // SQLITE_NOMEM if the attempt to allocate Pager.pInJournal fails, or // an IO error code if opening or writing the journal file fails. func pager_open_journal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:57438:12: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var pVfs uintptr = (*Pager)(unsafe.Pointer(pPager)).FpVfs // Local cache of vfs pointer // If already in the error state, this function is a no-op. But on @@ -34975,32 +34413,32 @@ func pager_open_journal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5743 return (*Pager)(unsafe.Pointer(pPager)).FerrCode } - if !((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0)) && (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != 2) { + if !((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0)) && (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_OFF) { (*Pager)(unsafe.Pointer(pPager)).FpInJournal = Xsqlite3BitvecCreate(tls, (*Pager)(unsafe.Pointer(pPager)).FdbSize) if (*Pager)(unsafe.Pointer(pPager)).FpInJournal == uintptr(0) { - return 7 + return SQLITE_NOMEM } // Open the journal file if it is not already open. if !((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) { - if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 4 { + if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_MEMORY { Xsqlite3MemJournalOpen(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) } else { - var flags int32 = (0x00000002 | 0x00000004) + var flags int32 = (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) var nSpill int32 if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 { - flags = flags | (0x00000008 | 0x00001000) + flags = flags | (SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_TEMP_JOURNAL) nSpill = Xsqlite3Config.FnStmtSpill } else { - flags = flags | (0x00000800) + flags = flags | (SQLITE_OPEN_MAIN_JOURNAL) nSpill = jrnlBufferSize(tls, pPager) } // Verify that the database still has the same name as it did when // it was originally opened. rc = databaseIsUnmoved(tls, pPager) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3JournalOpen(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, (*Pager)(unsafe.Pointer(pPager)).Fjfd, flags, nSpill) } @@ -35010,7 +34448,7 @@ func pager_open_journal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5743 // Write the first journal header to the journal file and open // the sub-journal if necessary. - if rc == 0 { + if rc == SQLITE_OK { // TODO: Check if all of these are really required. (*Pager)(unsafe.Pointer(pPager)).FnRec = 0 (*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0) @@ -35020,12 +34458,12 @@ func pager_open_journal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5743 } } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3BitvecDestroy(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal) (*Pager)(unsafe.Pointer(pPager)).FpInJournal = uintptr(0) } else { - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(3) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_WRITER_CACHEMOD } return rc @@ -35047,7 +34485,7 @@ func pager_open_journal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5743 // sub-journal is implemented in-memory if pPager is an in-memory database, // or using a temporary file otherwise. func Xsqlite3PagerBegin(tls *libc.TLS, pPager uintptr, exFlag int32, subjInMemory int32) int32 { /* sqlite3.c:57527:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 { return (*Pager)(unsafe.Pointer(pPager)).FerrCode @@ -35055,14 +34493,14 @@ func Xsqlite3PagerBegin(tls *libc.TLS, pPager uintptr, exFlag int32, subjInMemor (*Pager)(unsafe.Pointer(pPager)).FsubjInMemory = U8(subjInMemory) - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 1 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_READER { if (*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0) { // If the pager is configured to use locking_mode=exclusive, and an // exclusive lock on the database is not already held, obtain it now. if ((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) && (Xsqlite3WalExclusiveMode(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, -1) != 0) { - rc = pagerLockDb(tls, pPager, 4) - if rc != 0 { + rc = pagerLockDb(tls, pPager, EXCLUSIVE_LOCK) + if rc != SQLITE_OK { return rc } Xsqlite3WalExclusiveMode(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, 1) @@ -35078,13 +34516,13 @@ func Xsqlite3PagerBegin(tls *libc.TLS, pPager uintptr, exFlag int32, subjInMemor // is true, then immediately upgrade this to an EXCLUSIVE lock. The // busy-handler callback can be used when upgrading to the EXCLUSIVE // lock, but not when obtaining the RESERVED lock. - rc = pagerLockDb(tls, pPager, 2) - if (rc == 0) && (exFlag != 0) { - rc = pager_wait_on_lock(tls, pPager, 4) + rc = pagerLockDb(tls, pPager, RESERVED_LOCK) + if (rc == SQLITE_OK) && (exFlag != 0) { + rc = pager_wait_on_lock(tls, pPager, EXCLUSIVE_LOCK) } } - if rc == 0 { + if rc == SQLITE_OK { // Change to WRITER_LOCKED state. // // WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD @@ -35093,7 +34531,7 @@ func Xsqlite3PagerBegin(tls *libc.TLS, pPager uintptr, exFlag int32, subjInMemor // transactions may copy data from the sub-journal into the database // file as well as into the page cache. Which would be incorrect in // WAL mode. - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(2) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_WRITER_LOCKED (*Pager)(unsafe.Pointer(pPager)).FdbHintSize = (*Pager)(unsafe.Pointer(pPager)).FdbSize (*Pager)(unsafe.Pointer(pPager)).FdbFileSize = (*Pager)(unsafe.Pointer(pPager)).FdbSize (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize = (*Pager)(unsafe.Pointer(pPager)).FdbSize @@ -35126,18 +34564,18 @@ func pagerAddPageToRollbackJournal(tls *libc.TLS, pPg uintptr) int32 { /* sqlite // playback_one_page() will think that the page needs to be restored // in the database file. And if an IO error occurs while doing so, // then corruption may follow. - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((0x008)) + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((PGHDR_NEED_SYNC)) rc = write32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iOff, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) - if rc != 0 { + if rc != SQLITE_OK { return rc } rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, pData2, (*Pager)(unsafe.Pointer(pPager)).FpageSize, (iOff + int64(4))) - if rc != 0 { + if rc != SQLITE_OK { return rc } rc = write32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, ((iOff + I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)) + int64(4)), cksum) - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -35158,7 +34596,7 @@ func pagerAddPageToRollbackJournal(tls *libc.TLS, pPg uintptr) int32 { /* sqlite // of any open savepoints as appropriate. func pager_write(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:57653:12: */ var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager - var rc int32 = 0 + var rc int32 = SQLITE_OK // This routine is not called unless a write-transaction has already // been started. The journal file may or may not be open at this point. @@ -35172,9 +34610,9 @@ func pager_write(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:57653:12: */ // Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then // an error might occur and the pager would end up in WRITER_LOCKED state // with pages marked as dirty in the cache. - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 2 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_WRITER_LOCKED { rc = pager_open_journal(tls, pPager) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -35191,12 +34629,12 @@ func pager_write(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:57653:12: */ if (*PgHdr)(unsafe.Pointer(pPg)).Fpgno <= (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize { rc = pagerAddPageToRollbackJournal(tls, pPg) - if rc != 0 { + if rc != SQLITE_OK { return rc } } else { - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) != 4 { - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((0x008)) + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) != PAGER_WRITER_DBMOD { + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((PGHDR_NEED_SYNC)) } } @@ -35206,7 +34644,7 @@ func pager_write(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:57653:12: */ // and before writing the page into the rollback journal. Wait until now, // after the page has been successfully journalled, before setting the // PGHDR_WRITEABLE bit that indicates that the page can be safely modified. - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((0x004)) + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((PGHDR_WRITEABLE)) // If the statement journal is open and the page is not in it, // then write the page into the statement journal. @@ -35234,7 +34672,7 @@ func pagerWriteLargeSector(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5774 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var nPageCount Pgno // Total number of pages in database file var pg1 Pgno // First page of the sector pPg is located on. var nPage int32 = 0 // Number of pages starting at pg1 to journal @@ -35247,7 +34685,7 @@ func pagerWriteLargeSector(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5774 // a journal header to be written between the pages journaled by // this function. - *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) |= U8((0x04)) + *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) |= U8((SPILLFLAG_NOSYNC)) // This trick assumes that both the page-size and sector-size are // an integer power of 2. It sets variable pg1 to the identifier @@ -35263,23 +34701,23 @@ func pagerWriteLargeSector(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5774 nPage = int32(nPagePerSector) } - for ii = 0; (ii < nPage) && (rc == 0); ii++ { + for ii = 0; (ii < nPage) && (rc == SQLITE_OK); ii++ { var pg Pgno = (pg1 + Pgno(ii)) // var pPage uintptr at bp, 8 if (pg == (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) || !(Xsqlite3BitvecTest(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal, pg) != 0) { if pg != (Pgno((Xsqlite3PendingByte / ((*Pager)(unsafe.Pointer(pPager)).FpageSize)) + 1)) { rc = Xsqlite3PagerGet(tls, pPager, pg, bp /* &pPage */, 0) - if rc == 0 { + if rc == SQLITE_OK { rc = pager_write(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */))) - if (int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).Fflags) & 0x008) != 0 { + if (int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).Fflags) & PGHDR_NEED_SYNC) != 0 { needSync = 1 } Xsqlite3PagerUnrefNotNull(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */))) } } } else if (libc.AssignPtrUintptr(bp /* pPage */, Xsqlite3PagerLookup(tls, pPager, pg))) != uintptr(0) { - if (int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).Fflags) & 0x008) != 0 { + if (int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).Fflags) & PGHDR_NEED_SYNC) != 0 { needSync = 1 } Xsqlite3PagerUnrefNotNull(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */))) @@ -35291,18 +34729,18 @@ func pagerWriteLargeSector(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5774 // writing to any of these nPage pages may damage the others, the // journal file must contain sync()ed copies of all of them // before any of them can be written out to the database file. - if (rc == 0) && (needSync != 0) { + if (rc == SQLITE_OK) && (needSync != 0) { for ii = 0; ii < nPage; ii++ { var pPage uintptr = Xsqlite3PagerLookup(tls, pPager, (pg1 + Pgno(ii))) if pPage != 0 { - *(*U16)(unsafe.Pointer(pPage + 52 /* &.flags */)) |= U16((0x008)) + *(*U16)(unsafe.Pointer(pPage + 52 /* &.flags */)) |= U16((PGHDR_NEED_SYNC)) Xsqlite3PagerUnrefNotNull(tls, pPage) } } } - *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) &= libc.Uint8FromInt32((^libc.Int32(0x04))) + *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) &= libc.Uint8FromInt32((libc.CplInt32(SPILLFLAG_NOSYNC))) return rc } @@ -35321,11 +34759,11 @@ func pagerWriteLargeSector(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5774 func Xsqlite3PagerWrite(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:57839:20: */ var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager - if ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & 0x004) != 0) && ((*Pager)(unsafe.Pointer(pPager)).FdbSize >= (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) { + if ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & PGHDR_WRITEABLE) != 0) && ((*Pager)(unsafe.Pointer(pPager)).FdbSize >= (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) { if (*Pager)(unsafe.Pointer(pPager)).FnSavepoint != 0 { return subjournalPageIfRequired(tls, pPg) } - return 0 + return SQLITE_OK } else if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 { return (*Pager)(unsafe.Pointer(pPager)).FerrCode } else if (*Pager)(unsafe.Pointer(pPager)).FsectorSize > U32((*Pager)(unsafe.Pointer(pPager)).FpageSize) { @@ -35361,10 +34799,10 @@ func Xsqlite3PagerWrite(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:57839:2 // current transaction is rolled back. func Xsqlite3PagerDontWrite(tls *libc.TLS, pPg uintptr) { /* sqlite3.c:57888:21: */ var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager - if (!(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) && ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & 0x002) != 0)) && ((*Pager)(unsafe.Pointer(pPager)).FnSavepoint == 0) { + if (!(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) && ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & PGHDR_DIRTY) != 0)) && ((*Pager)(unsafe.Pointer(pPager)).FnSavepoint == 0) { - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((0x010)) - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x004))) + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((PGHDR_DONT_WRITE)) + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(PGHDR_WRITEABLE))) } } @@ -35393,7 +34831,7 @@ func pager_incr_changecounter(tls *libc.TLS, pPager uintptr, isDirectMode int32) bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK // Declare and initialize constant integer 'isDirect'. If the // atomic-write optimization is enabled in this build, then isDirect @@ -35418,11 +34856,11 @@ func pager_incr_changecounter(tls *libc.TLS, pPager uintptr, isDirectMode int32) // operating in direct-mode, make page 1 writable. When not in // direct mode, page 1 is always held in cache and hence the PagerGet() // above is always successful - hence the ALWAYS on rc==SQLITE_OK. - if !(0 != 0) && (rc == 0) { + if !(0 != 0) && (rc == SQLITE_OK) { rc = Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp /* pPgHdr */))) } - if rc == 0 { + if rc == SQLITE_OK { // Actually do the update of the change counter pager_write_changecounter(tls, *(*uintptr)(unsafe.Pointer(bp /* pPgHdr */))) @@ -35431,15 +34869,15 @@ func pager_incr_changecounter(tls *libc.TLS, pPager uintptr, isDirectMode int32) var zBuf uintptr zBuf = (*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPgHdr */)))).FpData - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, zBuf, (*Pager)(unsafe.Pointer(pPager)).FpageSize, int64(0)) - *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(2)*4))++ + *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + 2*4))++ } - if rc == 0 { + if rc == SQLITE_OK { // Update the pager's copy of the change-counter. Otherwise, the // next time a read transaction is opened the cache will be // flushed (as the change-counter values will not match). - var pCopy uintptr = ((zBuf) + uintptr(24)) + var pCopy uintptr = ((zBuf) + 24) libc.Xmemcpy(tls, (pPager + 136 /* &.dbFileVers */), pCopy, uint64(unsafe.Sizeof([16]int8{}))) (*Pager)(unsafe.Pointer(pPager)).FchangeCountDone = U8(1) } @@ -35460,13 +34898,13 @@ func pager_incr_changecounter(tls *libc.TLS, pPager uintptr, isDirectMode int32) // If successful, or if called on a pager for which it is a no-op, this // function returns SQLITE_OK. Otherwise, an IO error code is returned. func Xsqlite3PagerSync(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 { /* sqlite3.c:58005:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pArg uintptr = zSuper - rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, 21, pArg) - if rc == 12 { - rc = 0 + rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_SYNC, pArg) + if rc == SQLITE_NOTFOUND { + rc = SQLITE_OK } - if (rc == 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { + if (rc == SQLITE_OK) && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags)) } @@ -35485,10 +34923,10 @@ func Xsqlite3PagerSync(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 { /* func Xsqlite3PagerExclusiveLock(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:58028:20: */ var rc int32 = (*Pager)(unsafe.Pointer(pPager)).FerrCode - if rc == 0 { + if rc == SQLITE_OK { if 0 == (libc.Bool32((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0))) { - rc = pager_wait_on_lock(tls, pPager, 4) + rc = pager_wait_on_lock(tls, pPager, EXCLUSIVE_LOCK) } } return rc @@ -35527,7 +34965,7 @@ func Xsqlite3PagerCommitPhaseOne(tls *libc.TLS, pPager uintptr, zSuper uintptr, var nNew Pgno var pList uintptr - rc = 0 // Return code + rc = SQLITE_OK // Return code // If a prior error occurred, report that error again. if !((*Pager)(unsafe.Pointer(pPager)).FerrCode != 0) { @@ -35541,15 +34979,15 @@ __1: if !(Xsqlite3FaultSim(tls, 400) != 0) { goto __2 } - return 10 + return SQLITE_IOERR __2: ; // If no database changes have been made, return early. - if !(int32((*Pager)(unsafe.Pointer(pPager)).FeState) < 3) { + if !(int32((*Pager)(unsafe.Pointer(pPager)).FeState) < PAGER_WRITER_CACHEMOD) { goto __3 } - return 0 + return SQLITE_OK __3: ; @@ -35585,7 +35023,7 @@ __8: __9: ; Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp /* pPageOne */))) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __10 } Xsqlite3PcacheCleanAll(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) @@ -35598,7 +35036,7 @@ __6: // is enabled. rc = pager_incr_changecounter(tls, pPager, 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __11 } goto commit_phase_one_exit @@ -35609,7 +35047,7 @@ __11: // super-journal file name has already been written to the journal file, // or if zSuper is NULL (no super-journal), then this call is a no-op. rc = writeSuperJournal(tls, pPager, zSuper) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } goto commit_phase_one_exit @@ -35627,7 +35065,7 @@ __12: // not the case. In this case it is likely enough that the redundant // xSync() call will be changed to a no-op by the OS anyhow. rc = syncJournal(tls, pPager, 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __13 } goto commit_phase_one_exit @@ -35636,13 +35074,13 @@ __13: pList = Xsqlite3PcacheDirtyList(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) - if !(0 == 0) { + if !(BBatch == 0) { goto __14 } rc = pager_write_pagelist(tls, pPager, pList) __14: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __15 } @@ -35663,7 +35101,7 @@ __15: nNew = ((*Pager)(unsafe.Pointer(pPager)).FdbSize - (Pgno(libc.Bool32((*Pager)(unsafe.Pointer(pPager)).FdbSize == (Pgno((Xsqlite3PendingByte / ((*Pager)(unsafe.Pointer(pPager)).FpageSize)) + 1)))))) rc = pager_truncate(tls, pPager, nNew) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __17 } goto commit_phase_one_exit @@ -35686,10 +35124,10 @@ __5: ; commit_phase_one_exit: - if !((rc == 0) && !((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0))) { + if !((rc == SQLITE_OK) && !((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0))) { goto __19 } - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(5) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_WRITER_FINISHED __19: ; return rc @@ -35709,7 +35147,7 @@ __19: // If an error occurs, an IO error code is returned and the pager // moves into the error state. Otherwise, SQLITE_OK is returned. func Xsqlite3PagerCommitPhaseTwo(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:58300:20: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code // This routine should not be called if a prior error has occurred. // But if (due to a coding error elsewhere in the system) it does get @@ -35729,12 +35167,12 @@ func Xsqlite3PagerCommitPhaseTwo(tls *libc.TLS, pPager uintptr) int32 { /* sqlit // to the database file. So there is no need to zero the journal // header. Since the pager is in exclusive mode, there is no need // to drop any locks either. - if ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 2) && + if ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_WRITER_LOCKED) && ((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0)) && - (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 1) { + (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_PERSIST) { - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(1) - return 0 + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_READER + return SQLITE_OK } rc = pager_end_transaction(tls, pPager, int32((*Pager)(unsafe.Pointer(pPager)).FsetSuper), 1) @@ -35766,35 +35204,35 @@ func Xsqlite3PagerCommitPhaseTwo(tls *libc.TLS, pPager uintptr) int32 { /* sqlit // their pre-transaction state by re-reading data from the database or // WAL files. The WAL transaction is then closed. func Xsqlite3PagerRollback(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:58366:20: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code // PagerRollback() is a no-op if called in READER or OPEN state. If // the pager is already in the ERROR state, the rollback is not // attempted here. Instead, the error code is returned to the caller. - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 6 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_ERROR { return (*Pager)(unsafe.Pointer(pPager)).FerrCode } - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) <= 1 { - return 0 + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) <= PAGER_READER { + return SQLITE_OK } if (*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0) { var rc2 int32 - rc = Xsqlite3PagerSavepoint(tls, pPager, 2, -1) + rc = Xsqlite3PagerSavepoint(tls, pPager, SAVEPOINT_ROLLBACK, -1) rc2 = pager_end_transaction(tls, pPager, int32((*Pager)(unsafe.Pointer(pPager)).FsetSuper), 0) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } - } else if !((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 2) { + } else if !((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_WRITER_LOCKED) { var eState int32 = int32((*Pager)(unsafe.Pointer(pPager)).FeState) rc = pager_end_transaction(tls, pPager, 0, 0) - if !(int32((*Pager)(unsafe.Pointer(pPager)).FmemDb) != 0) && (eState > 2) { + if !(int32((*Pager)(unsafe.Pointer(pPager)).FmemDb) != 0) && (eState > PAGER_WRITER_LOCKED) { // This can happen using journal_mode=off. Move the pager to the error // state to indicate that the contents of the cache may not be trusted. // Any active readers will get SQLITE_ABORT. - (*Pager)(unsafe.Pointer(pPager)).FerrCode = 4 - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(6) + (*Pager)(unsafe.Pointer(pPager)).FerrCode = SQLITE_ABORT + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_ERROR setGetterMethod(tls, pPager) return rc } @@ -35839,7 +35277,7 @@ func Xsqlite3PagerPageRefcount(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3. // returning. func Xsqlite3PagerCacheStat(tls *libc.TLS, pPager uintptr, eStat int32, reset int32, pnVal uintptr) { /* sqlite3.c:58480:21: */ - eStat = eStat - (7) + eStat = eStat - (SQLITE_DBSTATUS_CACHE_HIT) *(*int32)(unsafe.Pointer(pnVal)) += (*(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(eStat)*4))) if reset != 0 { *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(eStat)*4)) = 0 @@ -35860,7 +35298,7 @@ func Xsqlite3PagerIsMemdb(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:58 // occurs while opening the sub-journal file, then an IO error code is // returned. Otherwise, SQLITE_OK. func pagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) int32 { /* sqlite3.c:58517:28: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var nCurrent int32 = (*Pager)(unsafe.Pointer(pPager)).FnSavepoint // Current number of savepoints var ii int32 // Iterator variable var aNew uintptr // New Pager.aSavepoint array @@ -35871,7 +35309,7 @@ func pagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) int32 { aNew = Xsqlite3Realloc(tls, (*Pager)(unsafe.Pointer(pPager)).FaSavepoint, (uint64(uint64(unsafe.Sizeof(PagerSavepoint{})) * uint64(nSavepoint)))) if !(aNew != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, (aNew + uintptr(nCurrent)*48), 0, ((uint64(nSavepoint - nCurrent)) * uint64(unsafe.Sizeof(PagerSavepoint{})))) (*Pager)(unsafe.Pointer(pPager)).FaSavepoint = aNew @@ -35887,7 +35325,7 @@ func pagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) int32 { (*PagerSavepoint)(unsafe.Pointer(aNew + uintptr(ii)*48)).FiSubRec = (*Pager)(unsafe.Pointer(pPager)).FnSubRec (*PagerSavepoint)(unsafe.Pointer(aNew + uintptr(ii)*48)).FpInSavepoint = Xsqlite3BitvecCreate(tls, (*Pager)(unsafe.Pointer(pPager)).FdbSize) if !(int32((*PagerSavepoint)(unsafe.Pointer(aNew+uintptr(ii)*48)).FpInSavepoint) != 0) { - return 7 + return SQLITE_NOMEM } if (*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0) { Xsqlite3WalSavepoint(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, aNew+uintptr(ii)*48+32 /* &.aWalData */) @@ -35903,7 +35341,7 @@ func Xsqlite3PagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) if (nSavepoint > (*Pager)(unsafe.Pointer(pPager)).FnSavepoint) && ((*Pager)(unsafe.Pointer(pPager)).FuseJournal != 0) { return pagerOpenSavepoint(tls, pPager, nSavepoint) } else { - return 0 + return SQLITE_OK } return int32(0) } @@ -35939,7 +35377,7 @@ func Xsqlite3PagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) func Xsqlite3PagerSavepoint(tls *libc.TLS, pPager uintptr, op int32, iSavepoint int32) int32 { /* sqlite3.c:58604:20: */ var rc int32 = (*Pager)(unsafe.Pointer(pPager)).FerrCode - if (rc == 0) && (iSavepoint < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint) { + if (rc == SQLITE_OK) && (iSavepoint < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint) { var ii int32 // Iterator variable var nNew int32 // Number of remaining savepoints after this op. @@ -35947,7 +35385,7 @@ func Xsqlite3PagerSavepoint(tls *libc.TLS, pPager uintptr, op int32, iSavepoint // operation. Store this value in nNew. Then free resources associated // with any savepoints that are destroyed by this operation. nNew = (iSavepoint + (func() int32 { - if op == 1 { + if op == SAVEPOINT_RELEASE { return 0 } return 1 @@ -35959,7 +35397,7 @@ func Xsqlite3PagerSavepoint(tls *libc.TLS, pPager uintptr, op int32, iSavepoint // If this is a release of the outermost savepoint, truncate // the sub-journal to zero bytes in size. - if op == 1 { + if op == SAVEPOINT_RELEASE { if (nNew == 0) && ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fsjfd))).FpMethods != uintptr(0)) { // Only truncate if it is an in-memory sub-journal. if Xsqlite3JournalIsInMemory(tls, (*Pager)(unsafe.Pointer(pPager)).Fsjfd) != 0 { @@ -35997,7 +35435,7 @@ func Xsqlite3PagerSavepoint(tls *libc.TLS, pPager uintptr, op int32, iSavepoint // sqlite3_uri_parameter() and sqlite3_filename_database() and friends. func Xsqlite3PagerFilename(tls *libc.TLS, pPager uintptr, nullIfMemDb int32) uintptr { /* sqlite3.c:58683:27: */ if (nullIfMemDb != 0) && ((*Pager)(unsafe.Pointer(pPager)).FmemDb != 0) { - return (uintptr(unsafe.Pointer(&zFake)) + uintptr(4)) + return (uintptr(unsafe.Pointer(&zFake)) + 4) } return (*Pager)(unsafe.Pointer(pPager)).FzFilename } @@ -36089,8 +35527,8 @@ func Xsqlite3PagerMovepage(tls *libc.TLS, pPager uintptr, pPg uintptr, pgno Pgno // subjournalPage() may need to allocate space to store pPg->pgno into // one or more savepoint bitvecs. This is the reason this function // may return SQLITE_NOMEM. - if ((int32((*DbPage)(unsafe.Pointer(pPg)).Fflags) & 0x002) != 0) && - (0 != (libc.AssignInt32(&rc, subjournalPageIfRequired(tls, pPg)))) { + if ((int32((*DbPage)(unsafe.Pointer(pPg)).Fflags) & PGHDR_DIRTY) != 0) && + (SQLITE_OK != (libc.AssignInt32(&rc, subjournalPageIfRequired(tls, pPg)))) { return rc } @@ -36100,7 +35538,7 @@ func Xsqlite3PagerMovepage(tls *libc.TLS, pPager uintptr, pPg uintptr, pgno Pgno // If the isCommit flag is set, there is no need to remember that // the journal needs to be sync()ed before database page pPg->pgno // can be written to. The caller has already promised not to write to it. - if ((int32((*DbPage)(unsafe.Pointer(pPg)).Fflags) & 0x008) != 0) && !(isCommit != 0) { + if ((int32((*DbPage)(unsafe.Pointer(pPg)).Fflags) & PGHDR_NEED_SYNC) != 0) && !(isCommit != 0) { needSyncPgno = (*DbPage)(unsafe.Pointer(pPg)).Fpgno } @@ -36109,7 +35547,7 @@ func Xsqlite3PagerMovepage(tls *libc.TLS, pPager uintptr, pPg uintptr, pgno Pgno // from its hash chain. Also, if the PGHDR_NEED_SYNC flag was set for // page pgno before the 'move' operation, it needs to be retained // for the page moved there. - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x008))) + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(PGHDR_NEED_SYNC))) pPgOld = Xsqlite3PagerLookup(tls, pPager, pgno) if pPgOld != 0 { @@ -36117,7 +35555,7 @@ func Xsqlite3PagerMovepage(tls *libc.TLS, pPager uintptr, pPg uintptr, pgno Pgno Xsqlite3PagerUnrefNotNull(tls, pPgOld) return Xsqlite3CorruptError(tls, 58823) } - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((int32((*PgHdr)(unsafe.Pointer(pPgOld)).Fflags) & 0x008)) + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((int32((*PgHdr)(unsafe.Pointer(pPgOld)).Fflags) & PGHDR_NEED_SYNC)) if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 { // Do not discard pages from an in-memory database since we might // need to rollback later. Just move the page out of the way. @@ -36156,19 +35594,19 @@ func Xsqlite3PagerMovepage(tls *libc.TLS, pPager uintptr, pPg uintptr, pgno Pgno // var pPgHdr uintptr at bp, 8 rc = Xsqlite3PagerGet(tls, pPager, needSyncPgno, bp /* &pPgHdr */, 0) - if rc != 0 { + if rc != SQLITE_OK { if needSyncPgno <= (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize { Xsqlite3BitvecClear(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal, needSyncPgno, (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace) } return rc } - *(*U16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPgHdr */)) + 52 /* &.flags */)) |= U16((0x008)) + *(*U16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPgHdr */)) + 52 /* &.flags */)) |= U16((PGHDR_NEED_SYNC)) Xsqlite3PcacheMakeDirty(tls, *(*uintptr)(unsafe.Pointer(bp /* pPgHdr */))) Xsqlite3PagerUnrefNotNull(tls, *(*uintptr)(unsafe.Pointer(bp /* pPgHdr */))) } - return 0 + return SQLITE_OK } // The page handle passed as the first argument refers to a dirty page @@ -36240,7 +35678,7 @@ func Xsqlite3PagerSetJournalMode(tls *libc.TLS, pPager uintptr, eMode int32) int // anything other than MEMORY or OFF if (*Pager)(unsafe.Pointer(pPager)).FmemDb != 0 { - if (eMode != 4) && (eMode != 2) { + if (eMode != PAGER_JOURNALMODE_MEMORY) && (eMode != PAGER_JOURNALMODE_OFF) { eMode = int32(eOld) } } @@ -36265,30 +35703,30 @@ func Xsqlite3PagerSetJournalMode(tls *libc.TLS, pPager uintptr, eMode int32) int // database file. This ensures that the journal file is not deleted // while it is in use by some other client. Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) - if int32((*Pager)(unsafe.Pointer(pPager)).FeLock) >= 2 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeLock) >= RESERVED_LOCK { Xsqlite3OsDelete(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0) } else { - var rc int32 = 0 + var rc int32 = SQLITE_OK var state int32 = int32((*Pager)(unsafe.Pointer(pPager)).FeState) - if state == 0 { + if state == PAGER_OPEN { rc = Xsqlite3PagerSharedLock(tls, pPager) } - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 1 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_READER { - rc = pagerLockDb(tls, pPager, 2) + rc = pagerLockDb(tls, pPager, RESERVED_LOCK) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3OsDelete(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0) } - if (rc == 0) && (state == 1) { - pagerUnlockDb(tls, pPager, 1) - } else if state == 0 { + if (rc == SQLITE_OK) && (state == PAGER_READER) { + pagerUnlockDb(tls, pPager, SHARED_LOCK) + } else if state == PAGER_OPEN { pager_unlock(tls, pPager) } } - } else if eMode == 2 { + } else if eMode == PAGER_JOURNALMODE_OFF { Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) } } @@ -36307,7 +35745,7 @@ func Xsqlite3PagerGetJournalMode(tls *libc.TLS, pPager uintptr) int32 { /* sqlit // is unmodified. func Xsqlite3PagerOkToChangeJournalMode(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:59052:20: */ - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= 3 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_CACHEMOD { return 0 } if ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff > int64(0)) { @@ -36350,11 +35788,11 @@ func Xsqlite3PagerClearCache(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:59087 // // Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART. func Xsqlite3PagerCheckpoint(tls *libc.TLS, pPager uintptr, db uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) int32 { /* sqlite3.c:59102:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 { rc = Xsqlite3WalCheckpoint(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, db, eMode, func() uintptr { - if eMode == 0 { + if eMode == SQLITE_CHECKPOINT_PASSIVE { return uintptr(0) } return (*Pager)(unsafe.Pointer(pPager)).FxBusyHandler @@ -36385,11 +35823,11 @@ func Xsqlite3PagerWalSupported(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3 func pagerExclusiveLock(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:59139:12: */ var rc int32 // Return code - rc = pagerLockDb(tls, pPager, 4) - if rc != 0 { + rc = pagerLockDb(tls, pPager, EXCLUSIVE_LOCK) + if rc != SQLITE_OK { // If the attempt to grab the exclusive lock failed, release the // pending lock that may have been obtained instead. - pagerUnlockDb(tls, pPager, 1) + pagerUnlockDb(tls, pPager, SHARED_LOCK) } return rc @@ -36400,7 +35838,7 @@ func pagerExclusiveLock(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5913 // lock on the database file and use heap-memory to store the wal-index // in. Otherwise, use the normal shared-memory. func pagerOpenWal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:59159:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK // If the pager is already in exclusive-mode, the WAL module will use // heap-memory for the wal-index instead of the VFS shared-memory @@ -36412,7 +35850,7 @@ func pagerOpenWal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:59159:12: // Open the connection to the log file. If this operation fails, // (e.g. due to malloc() failure), return an error code. - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3WalOpen(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).Ffd, (*Pager)(unsafe.Pointer(pPager)).FzWal, int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode), (*Pager)(unsafe.Pointer(pPager)).FjournalSizeLimit, (pPager + 288 /* &.pWal */)) @@ -36436,20 +35874,20 @@ func pagerOpenWal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:59159:12: // the WAL file is already open, set *pbOpen to 1 and return SQLITE_OK // without doing anything. func Xsqlite3PagerOpenWal(tls *libc.TLS, pPager uintptr, pbOpen uintptr) int32 { /* sqlite3.c:59204:20: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code if !(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FpWal) != 0) { if !(Xsqlite3PagerWalSupported(tls, pPager) != 0) { - return 14 + return SQLITE_CANTOPEN } // Close any rollback journal previously open Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) rc = pagerOpenWal(tls, pPager) - if rc == 0 { - (*Pager)(unsafe.Pointer(pPager)).FjournalMode = U8(5) - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(0) + if rc == SQLITE_OK { + (*Pager)(unsafe.Pointer(pPager)).FjournalMode = PAGER_JOURNALMODE_WAL + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_OPEN } } else { *(*int32)(unsafe.Pointer(pbOpen)) = 1 @@ -36469,34 +35907,34 @@ func Xsqlite3PagerCloseWal(tls *libc.TLS, pPager uintptr, db uintptr) int32 { /* bp := tls.Alloc(4) defer tls.Free(4) - var rc int32 = 0 + var rc int32 = SQLITE_OK // If the log file is not already open, but does exist in the file-system, // it may need to be checkpointed before the connection can switch to // rollback mode. Open it now so this can happen. if !(int32((*Pager)(unsafe.Pointer(pPager)).FpWal) != 0) { *(*int32)(unsafe.Pointer(bp /* logexists */)) = 0 - rc = pagerLockDb(tls, pPager, 1) - if rc == 0 { + rc = pagerLockDb(tls, pPager, SHARED_LOCK) + if rc == SQLITE_OK { rc = Xsqlite3OsAccess(tls, - (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzWal, 0, bp /* &logexists */) + (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzWal, SQLITE_ACCESS_EXISTS, bp /* &logexists */) } - if (rc == 0) && (*(*int32)(unsafe.Pointer(bp /* logexists */)) != 0) { + if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* logexists */)) != 0) { rc = pagerOpenWal(tls, pPager) } } // Checkpoint and close the log. Because an EXCLUSIVE lock is held on // the database file, the log and log-summary files will be deleted. - if (rc == 0) && ((*Pager)(unsafe.Pointer(pPager)).FpWal != 0) { + if (rc == SQLITE_OK) && ((*Pager)(unsafe.Pointer(pPager)).FpWal != 0) { rc = pagerExclusiveLock(tls, pPager) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3WalClose(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, db, int32((*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags), (*Pager)(unsafe.Pointer(pPager)).FpageSize, (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace) (*Pager)(unsafe.Pointer(pPager)).FpWal = uintptr(0) pagerFixMaplimit(tls, pPager) if (rc != 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) { - pagerUnlockDb(tls, pPager, 1) + pagerUnlockDb(tls, pPager, SHARED_LOCK) } } } @@ -36506,7 +35944,7 @@ func Xsqlite3PagerCloseWal(tls *libc.TLS, pPager uintptr, db uintptr) int32 { /* // If this is a WAL database, obtain a snapshot handle for the snapshot // currently open. Otherwise, return an error. func Xsqlite3PagerSnapshotGet(tls *libc.TLS, pPager uintptr, ppSnapshot uintptr) int32 { /* sqlite3.c:59312:20: */ - var rc int32 = 1 + var rc int32 = SQLITE_ERROR if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 { rc = Xsqlite3WalSnapshotGet(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, ppSnapshot) } @@ -36517,11 +35955,11 @@ func Xsqlite3PagerSnapshotGet(tls *libc.TLS, pPager uintptr, ppSnapshot uintptr) // read transaction is opened, attempt to read from the snapshot it // identifies. If this is not a WAL database, return an error. func Xsqlite3PagerSnapshotOpen(tls *libc.TLS, pPager uintptr, pSnapshot uintptr) int32 { /* sqlite3.c:59325:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 { Xsqlite3WalSnapshotOpen(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, pSnapshot) } else { - rc = 1 + rc = SQLITE_ERROR } return rc } @@ -36533,7 +35971,7 @@ func Xsqlite3PagerSnapshotRecover(tls *libc.TLS, pPager uintptr) int32 { /* sqli if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 { rc = Xsqlite3WalSnapshotRecover(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal) } else { - rc = 1 + rc = SQLITE_ERROR } return rc } @@ -36553,7 +35991,7 @@ func Xsqlite3PagerSnapshotCheck(tls *libc.TLS, pPager uintptr, pSnapshot uintptr if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 { rc = Xsqlite3WalSnapshotCheck(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, pSnapshot) } else { - rc = 1 + rc = SQLITE_ERROR } return rc } @@ -37214,68 +36652,68 @@ type WalSegment = struct { // page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs, // then an SQLite error code is returned and *ppPage is set to 0. func walIndexPageRealloc(tls *libc.TLS, pWal uintptr, iPage int32, ppPage uintptr) int32 { /* sqlite3.c:59963:28: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK // Enlarge the pWal->apWiData[] array if required if (*Wal)(unsafe.Pointer(pWal)).FnWiData <= iPage { var nByte Sqlite3_int64 = (Sqlite3_int64(uint64(unsafe.Sizeof(uintptr(0))) * (uint64(iPage + 1)))) var apNew uintptr - apNew = Xsqlite3Realloc(tls, (*Wal)(unsafe.Pointer(pWal)).FapWiData, uint64(nByte)) - if !(apNew != 0) { - *(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0) - return 7 + libc.AtomicStoreUintptr(&apNew, uintptr(Xsqlite3Realloc(tls, (*Wal)(unsafe.Pointer(pWal)).FapWiData, uint64(nByte)))) + if !(libc.AtomicLoadUintptr(&apNew) != 0) { + *(*uintptr)(unsafe.Pointer(libc.AtomicLoadUintptr(&ppPage))) = uintptr(0) + return SQLITE_NOMEM } - libc.Xmemset(tls, (apNew + uintptr((*Wal)(unsafe.Pointer(pWal)).FnWiData)*8), 0, + libc.Xmemset(tls, (libc.AtomicLoadUintptr(&apNew) + uintptr((*Wal)(unsafe.Pointer(pWal)).FnWiData)*8), 0, (uint64(unsafe.Sizeof(uintptr(0))) * (uint64((iPage + 1) - (*Wal)(unsafe.Pointer(pWal)).FnWiData)))) - (*Wal)(unsafe.Pointer(pWal)).FapWiData = apNew + (*Wal)(unsafe.Pointer(pWal)).FapWiData = libc.AtomicLoadUintptr(&apNew) (*Wal)(unsafe.Pointer(pWal)).FnWiData = (iPage + 1) } // Request a pointer to the required page from the VFS - if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == 2 { - *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) = Xsqlite3MallocZero(tls, ((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(4096 * 2))) + (uint64(4096) * uint64(unsafe.Sizeof(U32(0)))))) + if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_HEAPMEMORY_MODE { + *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) = Xsqlite3MallocZero(tls, ((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(HASHTABLE_NPAGE * 2))) + (HASHTABLE_NPAGE * uint64(unsafe.Sizeof(U32(0)))))) if !(int32(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8))) != 0) { - rc = 7 + rc = SQLITE_NOMEM } } else { - rc = Xsqlite3OsShmMap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, iPage, (int32((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(4096 * 2))) + (uint64(4096) * uint64(unsafe.Sizeof(U32(0)))))), + rc = Xsqlite3OsShmMap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, iPage, (int32((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(HASHTABLE_NPAGE * 2))) + (HASHTABLE_NPAGE * uint64(unsafe.Sizeof(U32(0)))))), int32((*Wal)(unsafe.Pointer(pWal)).FwriteLock), ((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) - if rc == 0 { + if rc == SQLITE_OK { if (iPage > 0) && (Xsqlite3FaultSim(tls, 600) != 0) { - rc = 7 + rc = SQLITE_NOMEM } - } else if (rc & 0xff) == 8 { - *(*U8)(unsafe.Pointer(pWal + 66 /* &.readOnly */)) |= U8((2)) - if rc == 8 { - rc = 0 + } else if (rc & 0xff) == SQLITE_READONLY { + *(*U8)(unsafe.Pointer(pWal + 66 /* &.readOnly */)) |= U8((WAL_SHM_RDONLY)) + if rc == SQLITE_READONLY { + rc = SQLITE_OK } } } - *(*uintptr)(unsafe.Pointer(ppPage)) = *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) + *(*uintptr)(unsafe.Pointer(libc.AtomicLoadUintptr(&ppPage))) = *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) return rc } func walIndexPage(tls *libc.TLS, pWal uintptr, iPage int32, ppPage uintptr) int32 { /* sqlite3.c:60010:12: */ - if ((*Wal)(unsafe.Pointer(pWal)).FnWiData <= iPage) || ((libc.AssignPtrUintptr(ppPage, *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)))) == uintptr(0)) { - return walIndexPageRealloc(tls, pWal, iPage, ppPage) + if ((*Wal)(unsafe.Pointer(pWal)).FnWiData <= iPage) || ((libc.AssignPtrUintptr(libc.AtomicLoadUintptr(&ppPage), *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)))) == uintptr(0)) { + return walIndexPageRealloc(tls, pWal, iPage, libc.AtomicLoadUintptr(&ppPage)) } - return 0 + return SQLITE_OK } // Return a pointer to the WalCkptInfo structure in the wal-index. func walCkptInfo(tls *libc.TLS, pWal uintptr) uintptr { /* sqlite3.c:60024:29: */ - return (*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(0)*8)) + uintptr((uint64(unsafe.Sizeof(WalIndexHdr{}))/uint64(2)))*4) + return (*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData)) + 24*4) } // Return a pointer to the WalIndexHdr structure in the wal-index. func walIndexHdr(tls *libc.TLS, pWal uintptr) uintptr { /* sqlite3.c:60032:29: */ - return *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(0)*8)) + return *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData)) } // The argument to this macro must be of type u32. On a little-endian @@ -37298,8 +36736,8 @@ func walChecksumBytes(tls *libc.TLS, nativeCksum int32, a uintptr, nByte int32, var aEnd uintptr = (a + uintptr(nByte)) if aIn != 0 { - s1 = *(*U32)(unsafe.Pointer(aIn + uintptr(0)*4)) - s2 = *(*U32)(unsafe.Pointer(aIn + uintptr(1)*4)) + s1 = *(*U32)(unsafe.Pointer(aIn)) + s2 = *(*U32)(unsafe.Pointer(aIn + 1*4)) } else { s1 = libc.AssignUint32(&s2, U32(0)) } @@ -37311,20 +36749,20 @@ func walChecksumBytes(tls *libc.TLS, nativeCksum int32, a uintptr, nByte int32, } } else { for ok1 := true; ok1; ok1 = (aData < aEnd) { - s1 = s1 + (((((((*(*U32)(unsafe.Pointer(aData + uintptr(0)*4))) & U32(0x000000FF)) << 24) + (((*(*U32)(unsafe.Pointer(aData + uintptr(0)*4))) & U32(0x0000FF00)) << 8)) + (((*(*U32)(unsafe.Pointer(aData + uintptr(0)*4))) & U32(0x00FF0000)) >> 8)) + (((*(*U32)(unsafe.Pointer(aData + uintptr(0)*4))) & 0xFF000000) >> 24)) + s2) - s2 = s2 + (((((((*(*U32)(unsafe.Pointer(aData + uintptr(1)*4))) & U32(0x000000FF)) << 24) + (((*(*U32)(unsafe.Pointer(aData + uintptr(1)*4))) & U32(0x0000FF00)) << 8)) + (((*(*U32)(unsafe.Pointer(aData + uintptr(1)*4))) & U32(0x00FF0000)) >> 8)) + (((*(*U32)(unsafe.Pointer(aData + uintptr(1)*4))) & 0xFF000000) >> 24)) + s1) + s1 = s1 + (((((((*(*U32)(unsafe.Pointer(aData))) & U32(0x000000FF)) << 24) + (((*(*U32)(unsafe.Pointer(aData))) & U32(0x0000FF00)) << 8)) + (((*(*U32)(unsafe.Pointer(aData))) & U32(0x00FF0000)) >> 8)) + (((*(*U32)(unsafe.Pointer(aData))) & 0xFF000000) >> 24)) + s2) + s2 = s2 + (((((((*(*U32)(unsafe.Pointer(aData + 1*4))) & U32(0x000000FF)) << 24) + (((*(*U32)(unsafe.Pointer(aData + 1*4))) & U32(0x0000FF00)) << 8)) + (((*(*U32)(unsafe.Pointer(aData + 1*4))) & U32(0x00FF0000)) >> 8)) + (((*(*U32)(unsafe.Pointer(aData + 1*4))) & 0xFF000000) >> 24)) + s1) aData += 4 * (uintptr(2)) } } - *(*U32)(unsafe.Pointer(aOut + uintptr(0)*4)) = s1 - *(*U32)(unsafe.Pointer(aOut + uintptr(1)*4)) = s2 + *(*U32)(unsafe.Pointer(aOut)) = s1 + *(*U32)(unsafe.Pointer(aOut + 1*4)) = s2 } // If there is the possibility of concurrent access to the SHM file // from multiple threads and/or processes, then do a memory barrier. func walShmBarrier(tls *libc.TLS, pWal uintptr) { /* sqlite3.c:60101:13: */ - if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != 2 { + if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != WAL_HEAPMEMORY_MODE { Xsqlite3OsShmBarrier(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd) } } @@ -37343,12 +36781,12 @@ func walIndexWriteHdr(tls *libc.TLS, pWal uintptr) { /* sqlite3.c:60125:28: */ var nCksum int32 = int32((uintptr(0) + 40 /* &.aCksum */)) (*Wal)(unsafe.Pointer(pWal)).Fhdr.FisInit = U8(1) - (*Wal)(unsafe.Pointer(pWal)).Fhdr.FiVersion = U32(3007000) + (*Wal)(unsafe.Pointer(pWal)).Fhdr.FiVersion = WALINDEX_MAX_VERSION walChecksumBytes(tls, 1, (pWal + 72 /* &.hdr */), nCksum, uintptr(0), pWal+72 /* &.hdr */ +40 /* &.aCksum */) // Possible TSAN false-positive. See tag-20200519-1 - libc.Xmemcpy(tls, (aHdr + uintptr(1)*48), (pWal + 72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) + libc.Xmemcpy(tls, (libc.AtomicLoadUintptr(&aHdr) + 1*48), (pWal + 72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) walShmBarrier(tls, pWal) - libc.Xmemcpy(tls, (aHdr + uintptr(0)*48), (pWal + 72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) + libc.Xmemcpy(tls, (libc.AtomicLoadUintptr(&aHdr)), (pWal + 72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) } // This function encodes a single frame header and writes it to a buffer @@ -37366,19 +36804,19 @@ func walEncodeFrame(tls *libc.TLS, pWal uintptr, iPage U32, nTruncate U32, aData var nativeCksum int32 // True for native byte-order checksums var aCksum uintptr = pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */ - Xsqlite3Put4byte(tls, (aFrame + uintptr(0)), iPage) - Xsqlite3Put4byte(tls, (aFrame + uintptr(4)), nTruncate) + Xsqlite3Put4byte(tls, (aFrame), iPage) + Xsqlite3Put4byte(tls, (aFrame + 4), nTruncate) if (*Wal)(unsafe.Pointer(pWal)).FiReCksum == U32(0) { - libc.Xmemcpy(tls, (aFrame + uintptr(8)), pWal+72 /* &.hdr */ +32 /* &.aSalt */, uint64(8)) + libc.Xmemcpy(tls, (aFrame + 8), pWal+72 /* &.hdr */ +32 /* &.aSalt */, uint64(8)) - nativeCksum = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == 0)) + nativeCksum = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN)) walChecksumBytes(tls, nativeCksum, aFrame, 8, aCksum, aCksum) walChecksumBytes(tls, nativeCksum, aData, int32((*Wal)(unsafe.Pointer(pWal)).FszPage), aCksum, aCksum) - Xsqlite3Put4byte(tls, (aFrame + uintptr(16)), *(*U32)(unsafe.Pointer(aCksum + uintptr(0)*4))) - Xsqlite3Put4byte(tls, (aFrame + uintptr(20)), *(*U32)(unsafe.Pointer(aCksum + uintptr(1)*4))) + Xsqlite3Put4byte(tls, (aFrame + 16), *(*U32)(unsafe.Pointer(aCksum))) + Xsqlite3Put4byte(tls, (aFrame + 20), *(*U32)(unsafe.Pointer(aCksum + 1*4))) } else { - libc.Xmemset(tls, (aFrame + uintptr(8)), 0, uint64(16)) + libc.Xmemset(tls, (aFrame + 8), 0, uint64(16)) } } @@ -37392,12 +36830,12 @@ func walDecodeFrame(tls *libc.TLS, pWal uintptr, piPage uintptr, pnTruncate uint // A frame is only valid if the salt values in the frame-header // match the salt values in the wal-header. - if libc.Xmemcmp(tls, (pWal+72 /* &.hdr */ +32 /* &.aSalt */), (aFrame+uintptr(8)), uint64(8)) != 0 { + if libc.Xmemcmp(tls, (pWal+72 /* &.hdr */ +32 /* &.aSalt */), (aFrame+8), uint64(8)) != 0 { return 0 } // A frame is only valid if the page number is creater than zero. - pgno = Xsqlite3Get4byte(tls, (aFrame + uintptr(0))) + pgno = Xsqlite3Get4byte(tls, (aFrame)) if pgno == U32(0) { return 0 } @@ -37406,11 +36844,11 @@ func walDecodeFrame(tls *libc.TLS, pWal uintptr, piPage uintptr, pnTruncate uint // all prior frams, the first 16 bytes of this frame-header, // and the frame-data matches the checksum in the last 8 // bytes of this frame-header. - nativeCksum = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == 0)) + nativeCksum = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN)) walChecksumBytes(tls, nativeCksum, aFrame, 8, aCksum, aCksum) walChecksumBytes(tls, nativeCksum, aData, int32((*Wal)(unsafe.Pointer(pWal)).FszPage), aCksum, aCksum) - if (*(*U32)(unsafe.Pointer(aCksum + uintptr(0)*4)) != Xsqlite3Get4byte(tls, (aFrame+uintptr(16)))) || - (*(*U32)(unsafe.Pointer(aCksum + uintptr(1)*4)) != Xsqlite3Get4byte(tls, (aFrame+uintptr(20)))) { + if (*(*U32)(unsafe.Pointer(aCksum)) != Xsqlite3Get4byte(tls, (aFrame+16))) || + (*(*U32)(unsafe.Pointer(aCksum + 1*4)) != Xsqlite3Get4byte(tls, (aFrame+20))) { // Checksum failed. return 0 } @@ -37418,7 +36856,7 @@ func walDecodeFrame(tls *libc.TLS, pWal uintptr, piPage uintptr, pnTruncate uint // If we reach this point, the frame is valid. Return the page number // and the new database size. *(*U32)(unsafe.Pointer(piPage)) = pgno - *(*U32)(unsafe.Pointer(pnTruncate)) = Xsqlite3Get4byte(tls, (aFrame + uintptr(4))) + *(*U32)(unsafe.Pointer(pnTruncate)) = Xsqlite3Get4byte(tls, (aFrame + 4)) return 1 } @@ -37430,10 +36868,10 @@ func walDecodeFrame(tls *libc.TLS, pWal uintptr, piPage uintptr, pnTruncate uint func walLockShared(tls *libc.TLS, pWal uintptr, lockIdx int32) int32 { /* sqlite3.c:60262:12: */ var rc int32 if (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 { - return 0 + return SQLITE_OK } rc = Xsqlite3OsShmLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, 1, - (2 | 4)) + (SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)) return rc } @@ -37443,17 +36881,17 @@ func walUnlockShared(tls *libc.TLS, pWal uintptr, lockIdx int32) { /* sqlite3.c: return } Xsqlite3OsShmLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, 1, - (1 | 4)) + (SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)) } func walLockExclusive(tls *libc.TLS, pWal uintptr, lockIdx int32, n int32) int32 { /* sqlite3.c:60278:12: */ var rc int32 if (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 { - return 0 + return SQLITE_OK } rc = Xsqlite3OsShmLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, n, - (2 | 8)) + (SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)) return rc } @@ -37463,7 +36901,7 @@ func walUnlockExclusive(tls *libc.TLS, pWal uintptr, lockIdx int32, n int32) { / return } Xsqlite3OsShmLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, n, - (1 | 8)) + (SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE)) } @@ -37472,11 +36910,11 @@ func walUnlockExclusive(tls *libc.TLS, pWal uintptr, lockIdx int32, n int32) { / // the hash to the next value in the event of a collision. func walHash(tls *libc.TLS, iPage U32) int32 { /* sqlite3.c:60301:12: */ - return (int32((iPage * U32(383)) & (U32((4096 * 2) - 1)))) + return (int32((iPage * HASHTABLE_HASH_1) & (U32((HASHTABLE_NPAGE * 2) - 1)))) } func walNextHash(tls *libc.TLS, iPriorHash int32) int32 { /* sqlite3.c:60306:12: */ - return ((iPriorHash + 1) & ((4096 * 2) - 1)) + return ((iPriorHash + 1) & ((HASHTABLE_NPAGE * 2) - 1)) } // An instance of the WalHashLoc object is used to describe the location @@ -37511,13 +36949,13 @@ func walHashGet(tls *libc.TLS, pWal uintptr, iHash int32, pLoc uintptr) int32 { rc = walIndexPage(tls, pWal, iHash, (pLoc + 8 /* &.aPgno */)) - if rc == 0 { - (*WalHashLoc)(unsafe.Pointer(pLoc)).FaHash = ((*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + uintptr(4096)*4) + if rc == SQLITE_OK { + (*WalHashLoc)(unsafe.Pointer(pLoc)).FaHash = ((*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + 4096*4) if iHash == 0 { - (*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno = ((*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + uintptr((((uint64(unsafe.Sizeof(WalIndexHdr{}))*uint64(2))+uint64(unsafe.Sizeof(WalCkptInfo{})))/uint64(unsafe.Sizeof(U32(0)))))*4) + (*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno = ((*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + 34*4) (*WalHashLoc)(unsafe.Pointer(pLoc)).FiZero = U32(0) } else { - (*WalHashLoc)(unsafe.Pointer(pLoc)).FiZero = (U32((uint64(4096) - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64((iHash - 1) * 4096)))) + (*WalHashLoc)(unsafe.Pointer(pLoc)).FiZero = (U32((HASHTABLE_NPAGE - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64((iHash - 1) * HASHTABLE_NPAGE)))) } (*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno = ((*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + libc.UintptrFromInt32(-1)*4) } @@ -37529,7 +36967,7 @@ func walHashGet(tls *libc.TLS, pWal uintptr, iHash int32, pLoc uintptr) int32 { // iFrame. The wal-index is broken up into 32KB pages. Wal-index pages // are numbered starting from 0. func walFramePage(tls *libc.TLS, iFrame U32) int32 { /* sqlite3.c:60365:12: */ - var iHash int32 = (int32((((uint64(iFrame + U32(4096))) - (uint64(4096) - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0)))))) - uint64(1)) / uint64(4096))) + var iHash int32 = (int32((((uint64(iFrame + HASHTABLE_NPAGE)) - (HASHTABLE_NPAGE - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0)))))) - uint64(1)) / HASHTABLE_NPAGE)) return iHash } @@ -37538,9 +36976,9 @@ func walFramePage(tls *libc.TLS, iFrame U32) int32 { /* sqlite3.c:60365:12: */ func walFramePgno(tls *libc.TLS, pWal uintptr, iFrame U32) U32 { /* sqlite3.c:60380:12: */ var iHash int32 = walFramePage(tls, iFrame) if iHash == 0 { - return *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(0)*8)) + uintptr((((((uint64(unsafe.Sizeof(WalIndexHdr{}))*uint64(2))+uint64(unsafe.Sizeof(WalCkptInfo{})))/uint64(unsafe.Sizeof(U32(0))))+uint64(iFrame))-uint64(1)))*4)) + return *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData)) + uintptr((((((uint64(unsafe.Sizeof(WalIndexHdr{}))*uint64(2))+uint64(unsafe.Sizeof(WalCkptInfo{})))/uint64(unsafe.Sizeof(U32(0))))+uint64(iFrame))-uint64(1)))*4)) } - return *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iHash)*8)) + uintptr((((uint64(iFrame-U32(1)))-(uint64(4096)-(((uint64(unsafe.Sizeof(WalIndexHdr{}))*uint64(2))+uint64(unsafe.Sizeof(WalCkptInfo{})))/uint64(unsafe.Sizeof(U32(0))))))%uint64(4096)))*4)) + return *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iHash)*8)) + uintptr((((uint64(iFrame-U32(1)))-(HASHTABLE_NPAGE-(((uint64(unsafe.Sizeof(WalIndexHdr{}))*uint64(2))+uint64(unsafe.Sizeof(WalCkptInfo{})))/uint64(unsafe.Sizeof(U32(0))))))%HASHTABLE_NPAGE))*4)) } // Remove entries from the hash table that point to WAL slots greater @@ -37581,7 +37019,7 @@ func walCleanupHash(tls *libc.TLS, pWal uintptr) { /* sqlite3.c:60400:13: */ // than pWal->hdr.mxFrame. iLimit = (int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame - (*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FiZero)) - for i = 0; i < (4096 * 2); i++ { + for i = 0; i < (HASHTABLE_NPAGE * 2); i++ { if int32(*(*Ht_slot)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaHash + uintptr(i)*2))) > iLimit { *(*Ht_slot)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaHash + uintptr(i)*2)) = Ht_slot(0) } @@ -37608,7 +37046,7 @@ func walIndexAppend(tls *libc.TLS, pWal uintptr, iFrame U32, iPage U32) int32 { // Assuming the wal-index file was successfully mapped, populate the // page number array and hash table entry. - if rc == 0 { + if rc == SQLITE_OK { var iKey int32 // Hash table key var idx int32 // Value to write to hash-table slot var nCollide int32 // Number of hash collisions @@ -37618,9 +37056,9 @@ func walIndexAppend(tls *libc.TLS, pWal uintptr, iFrame U32, iPage U32) int32 { // If this is the first entry to be added to this hash-table, zero the // entire hash table and aPgno[] array before proceeding. if idx == 1 { - var nByte int32 = (int32((int64(((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaHash + uintptr((4096*2))*2)) - - int64(((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaPgno + uintptr(1)*4))) / 1)) - libc.Xmemset(tls, ((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaPgno + uintptr(1)*4), 0, uint64(nByte)) + var nByte int32 = (int32((int64(((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaHash + 8192*2)) - + int64(((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaPgno + 1*4))) / 1)) + libc.Xmemset(tls, ((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaPgno + 1*4), 0, uint64(nByte)) } // If the entry in aPgno[] is already set, then the previous writer @@ -37700,7 +37138,7 @@ func walIndexRecover(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3.c:60552:12: // If successful, the same bytes that are locked here are unlocked before // this function returns. - iLock = (1 + int32((*Wal)(unsafe.Pointer(pWal)).FckptLock)) + iLock = (WAL_ALL_BUT_WRITE + int32((*Wal)(unsafe.Pointer(pWal)).FckptLock)) rc = walLockExclusive(tls, pWal, iLock, ((3 + (0)) - iLock)) if !(rc != 0) { goto __1 @@ -37712,22 +37150,22 @@ __1: libc.Xmemset(tls, (pWal + 72 /* &.hdr */), 0, uint64(unsafe.Sizeof(WalIndexHdr{}))) rc = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+16 /* &nSize */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __2 } goto recovery_error __2: ; - if !(*(*I64)(unsafe.Pointer(bp + 16 /* nSize */)) > int64(32)) { + if !(*(*I64)(unsafe.Pointer(bp + 16 /* nSize */)) > WAL_HDRSIZE) { goto __3 } // Buffer to load WAL header into aPrivate = uintptr(0) // Heap copy of *-shm hash being populated aFrame = uintptr(0) // Last frame in wal, based on nSize alone // Read in the WAL header. - rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+24 /* &aBuf[0] */, 32, int64(0)) - if !(rc != 0) { + rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+24 /* &aBuf[0] */, WAL_HDRSIZE, int64(0)) + if !(rc != SQLITE_OK) { goto __4 } goto recovery_error @@ -37738,11 +37176,11 @@ __4: // SQLITE_MAX_PAGE_SIZE, conclude that the WAL file contains no valid // data. Similarly, if the 'magic' value is invalid, ignore the whole // WAL file. - magic = Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + uintptr(0))) - szPage = int32(Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + uintptr(8)))) - if !(((((magic & 0xFFFFFFFE) != U32(0x377f0682)) || + magic = Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */)) + szPage = int32(Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + 8))) + if !(((((magic & 0xFFFFFFFE) != WAL_MAGIC) || ((szPage & (szPage - 1)) != 0)) || - (szPage > 65536)) || + (szPage > SQLITE_MAX_PAGE_SIZE)) || (szPage < 512)) { goto __5 } @@ -37751,14 +37189,14 @@ __5: ; (*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum = (U8(magic & U32(0x00000001))) (*Wal)(unsafe.Pointer(pWal)).FszPage = U32(szPage) - (*Wal)(unsafe.Pointer(pWal)).FnCkpt = Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + uintptr(12))) - libc.Xmemcpy(tls, (pWal + 72 /* &.hdr */ + 32 /* &.aSalt */), (bp + 24 /* &aBuf */ + uintptr(16)), uint64(8)) + (*Wal)(unsafe.Pointer(pWal)).FnCkpt = Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + 12)) + libc.Xmemcpy(tls, (pWal + 72 /* &.hdr */ + 32 /* &.aSalt */), (bp + 24 /* &aBuf */ + 16), uint64(8)) // Verify that the WAL header checksum is correct - walChecksumBytes(tls, (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == 0)), - bp+24 /* &aBuf[0] */, (32 - (2 * 4)), uintptr(0), pWal+72 /* &.hdr */ +24 /* &.aFrameCksum */) - if !((*(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) != Xsqlite3Get4byte(tls, (bp+24 /* &aBuf */ +uintptr(24)))) || - (*(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) != Xsqlite3Get4byte(tls, (bp+24 /* &aBuf */ +uintptr(28))))) { + walChecksumBytes(tls, (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN)), + bp+24 /* &aBuf[0] */, (WAL_HDRSIZE - (2 * 4)), uintptr(0), pWal+72 /* &.hdr */ +24 /* &.aFrameCksum */) + if !((*(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) != Xsqlite3Get4byte(tls, (bp+24 /* &aBuf */ +24))) || + (*(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) != Xsqlite3Get4byte(tls, (bp+24 /* &aBuf */ +28)))) { goto __6 } goto finished @@ -37767,8 +37205,8 @@ __6: // Verify that the version number on the WAL format is one that // are able to understand - version = Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + uintptr(4))) - if !(version != U32(3007000)) { + version = Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + 4)) + if !(version != WAL_MAX_VERSION) { goto __7 } rc = Xsqlite3CantopenError(tls, 60635) @@ -37777,36 +37215,36 @@ __7: ; // Malloc a buffer to read frames into. - szFrame = (szPage + 24) - aFrame = Xsqlite3_malloc64(tls, (uint64(uint64(szFrame) + ((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(4096 * 2))) + (uint64(4096) * uint64(unsafe.Sizeof(U32(0)))))))) + szFrame = (szPage + WAL_FRAME_HDRSIZE) + aFrame = Xsqlite3_malloc64(tls, (uint64(uint64(szFrame) + ((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(HASHTABLE_NPAGE * 2))) + (HASHTABLE_NPAGE * uint64(unsafe.Sizeof(U32(0)))))))) if !(!(aFrame != 0)) { goto __8 } - rc = 7 + rc = SQLITE_NOMEM goto recovery_error __8: ; - aData = (aFrame + uintptr(24)) + aData = (aFrame + 24) aPrivate = (aData + uintptr(szPage)) // Read all frames from the log file. - iLastFrame = (U32((*(*I64)(unsafe.Pointer(bp + 16 /* nSize */)) - int64(32)) / I64(szFrame))) + iLastFrame = (U32((*(*I64)(unsafe.Pointer(bp + 16 /* nSize */)) - WAL_HDRSIZE) / I64(szFrame))) iPg = U32(0) __9: if !(iPg <= U32(walFramePage(tls, iLastFrame))) { goto __11 } // Index of last frame read iLast = func() uint32 { - if (uint64(iLastFrame)) < ((uint64(4096) - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64(iPg * U32(4096)))) { + if (uint64(iLastFrame)) < ((HASHTABLE_NPAGE - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64(iPg * HASHTABLE_NPAGE))) { return iLastFrame } - return (uint32((uint64(4096) - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64(iPg * U32(4096))))) + return (uint32((HASHTABLE_NPAGE - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64(iPg * HASHTABLE_NPAGE)))) }() iFirst = (U32(uint64(1) + (func() uint64 { if iPg == U32(0) { return uint64(0) } - return ((uint64(4096) - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64((iPg - U32(1)) * U32(4096)))) + return ((HASHTABLE_NPAGE - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64((iPg - U32(1)) * HASHTABLE_NPAGE))) }()))) rc = walIndexPage(tls, pWal, int32(iPg), bp+56 /* &aShare */) if !(rc != 0) { @@ -37822,11 +37260,11 @@ __13: if !(iFrame <= iLast) { goto __15 } - iOffset = (int64(32) + ((I64((iFrame) - U32(1))) * (I64((szPage) + 24)))) // dbsize field from frame header + iOffset = (WAL_HDRSIZE + ((I64((iFrame) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) // dbsize field from frame header // Read and decode the next log frame. rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aFrame, szFrame, iOffset) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __16 } goto __15 @@ -37840,7 +37278,7 @@ __16: __17: ; rc = walIndexAppend(tls, pWal, iFrame, *(*U32)(unsafe.Pointer(bp + 64 /* pgno */))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __18 } goto __15 @@ -37855,8 +37293,8 @@ __18: (*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage = *(*U32)(unsafe.Pointer(bp + 68 /* nTruncate */)) (*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage = (U16((szPage & 0xff00) | (szPage >> 16))) - *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */ + uintptr(0)*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) - *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */ + uintptr(1)*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) + *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) + *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */ + 1*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) __19: ; goto __14 @@ -37881,7 +37319,7 @@ __15: // do that, according to the spec, but no memcpy() implementation that // we know of actually does that, which is why we say that memcpy() // is safe for this. Memcpy() is certainly a lot faster. - libc.Xmemcpy(tls, (*(*uintptr)(unsafe.Pointer(bp + 56 /* aShare */)) + uintptr(nHdr32)*4), (aPrivate + uintptr(nHdr32)*4), (((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(4096 * 2))) + (uint64(4096) * uint64(unsafe.Sizeof(U32(0))))) - uint64(nHdr))) + libc.Xmemcpy(tls, (*(*uintptr)(unsafe.Pointer(bp + 56 /* aShare */)) + uintptr(nHdr32)*4), (aPrivate + uintptr(nHdr32)*4), (((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(HASHTABLE_NPAGE * 2))) + (HASHTABLE_NPAGE * uint64(unsafe.Sizeof(U32(0))))) - uint64(nHdr))) if !(iFrame <= iLast) { goto __20 } @@ -37901,42 +37339,42 @@ __3: ; finished: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __21 } - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) = *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */ + uintptr(0)*4)) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) = *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */ + uintptr(1)*4)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) = *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) = *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */ + 1*4)) walIndexWriteHdr(tls, pWal) // Reset the checkpoint-header. This is safe because this thread is // currently holding locks that exclude all other writers and // checkpointers. Then set the values of read-mark slots 1 through N. - pInfo = walCkptInfo(tls, pWal) - (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill = U32(0) - (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame - *(*U32)(unsafe.Pointer((pInfo + 4 /* &.aReadMark */) + uintptr(0)*4)) = U32(0) + libc.AtomicStoreUintptr(&pInfo, uintptr(walCkptInfo(tls, pWal))) + (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill = U32(0) + (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + *(*U32)(unsafe.Pointer((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */))) = U32(0) i = 1 __22: - if !(i < (8 - 3)) { + if !(i < (SQLITE_SHM_NLOCK - 3)) { goto __24 } rc = walLockExclusive(tls, pWal, (3 + (i)), 1) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __25 } if !((i == 1) && ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame != 0)) { goto __27 } - *(*U32)(unsafe.Pointer((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4)) = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + *(*U32)(unsafe.Pointer((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4)) = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame goto __28 __27: - *(*U32)(unsafe.Pointer((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4)) = 0xffffffff + *(*U32)(unsafe.Pointer((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4)) = READMARK_NOT_USED __28: ; walUnlockExclusive(tls, pWal, (3 + (i)), 1) goto __26 __25: - if !(rc != 5) { + if !(rc != SQLITE_BUSY) { goto __29 } goto recovery_error @@ -37959,7 +37397,7 @@ __24: if !((*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage != 0) { goto __30 } - Xsqlite3_log(tls, (27 | (int32(1) << 8)), + Xsqlite3_log(tls, (SQLITE_NOTICE | (int32(1) << 8)), ts+2920, /* "recovered %d fra..." */ libc.VaList(bp, (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame, (*Wal)(unsafe.Pointer(pWal)).FzWalName)) __30: @@ -37975,14 +37413,14 @@ recovery_error: // Close an open wal-index. func walIndexClose(tls *libc.TLS, pWal uintptr, isDelete int32) { /* sqlite3.c:60774:13: */ - if (int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == 2) || ((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable != 0) { + if (int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_HEAPMEMORY_MODE) || ((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable != 0) { var i int32 for i = 0; i < (*Wal)(unsafe.Pointer(pWal)).FnWiData; i++ { Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*8))) *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*8)) = uintptr(0) } } - if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != 2 { + if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != WAL_HEAPMEMORY_MODE { Xsqlite3OsShmUnmap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, isDelete) } } @@ -38019,11 +37457,11 @@ func Xsqlite3WalOpen(tls *libc.TLS, pVfs uintptr, pDbFd uintptr, zWalName uintpt *(*uintptr)(unsafe.Pointer(ppWal)) = uintptr(0) pRet = Xsqlite3MallocZero(tls, (uint64(uint64(unsafe.Sizeof(Wal{})) + uint64((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)))) if !(pRet != 0) { - return 7 + return SQLITE_NOMEM } (*Wal)(unsafe.Pointer(pRet)).FpVfs = pVfs - (*Wal)(unsafe.Pointer(pRet)).FpWalFd = (pRet + uintptr(1)*152) + (*Wal)(unsafe.Pointer(pRet)).FpWalFd = (pRet + 1*152) (*Wal)(unsafe.Pointer(pRet)).FpDbFd = pDbFd (*Wal)(unsafe.Pointer(pRet)).FreadLock = int16(-1) (*Wal)(unsafe.Pointer(pRet)).FmxWalSize = mxWalSize @@ -38032,28 +37470,28 @@ func Xsqlite3WalOpen(tls *libc.TLS, pVfs uintptr, pDbFd uintptr, zWalName uintpt (*Wal)(unsafe.Pointer(pRet)).FpadToSectorBoundary = U8(1) (*Wal)(unsafe.Pointer(pRet)).FexclusiveMode = func() uint8 { if bNoShm != 0 { - return uint8(2) + return WAL_HEAPMEMORY_MODE } - return uint8(0) + return WAL_NORMAL_MODE }() // Open file handle on the write-ahead log file. - *(*int32)(unsafe.Pointer(bp /* flags */)) = ((0x00000002 | 0x00000004) | 0x00080000) + *(*int32)(unsafe.Pointer(bp /* flags */)) = ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_WAL) rc = Xsqlite3OsOpen(tls, pVfs, zWalName, (*Wal)(unsafe.Pointer(pRet)).FpWalFd, *(*int32)(unsafe.Pointer(bp /* flags */)), bp /* &flags */) - if (rc == 0) && ((*(*int32)(unsafe.Pointer(bp /* flags */)) & 0x00000001) != 0) { - (*Wal)(unsafe.Pointer(pRet)).FreadOnly = U8(1) + if (rc == SQLITE_OK) && ((*(*int32)(unsafe.Pointer(bp /* flags */)) & SQLITE_OPEN_READONLY) != 0) { + (*Wal)(unsafe.Pointer(pRet)).FreadOnly = WAL_RDONLY } - if rc != 0 { + if rc != SQLITE_OK { walIndexClose(tls, pRet, 0) Xsqlite3OsClose(tls, (*Wal)(unsafe.Pointer(pRet)).FpWalFd) Xsqlite3_free(tls, pRet) } else { var iDC int32 = Xsqlite3OsDeviceCharacteristics(tls, pDbFd) - if (iDC & 0x00000400) != 0 { + if (iDC & SQLITE_IOCAP_SEQUENTIAL) != 0 { (*Wal)(unsafe.Pointer(pRet)).FsyncHeader = U8(0) } - if (iDC & 0x00001000) != 0 { + if (iDC & SQLITE_IOCAP_POWERSAFE_OVERWRITE) != 0 { (*Wal)(unsafe.Pointer(pRet)).FpadToSectorBoundary = U8(0) } *(*uintptr)(unsafe.Pointer(ppWal)) = pRet @@ -38238,13 +37676,13 @@ func walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill U32, pp uintptr) int bp := tls.Alloc(28) defer tls.Free(28) - var p uintptr // Return value - var nSegment int32 // Number of segments to merge - var iLast U32 // Last frame in log - var nByte Sqlite3_int64 // Number of bytes to allocate - var i int32 // Iterator variable - var aTmp uintptr // Temp space used by merge-sort - var rc int32 = 0 // Return Code + var p uintptr // Return value + var nSegment int32 // Number of segments to merge + var iLast U32 // Last frame in log + var nByte Sqlite3_int64 // Number of bytes to allocate + var i int32 // Iterator variable + var aTmp uintptr // Temp space used by merge-sort + var rc int32 = SQLITE_OK // Return Code // This routine only runs while holding the checkpoint lock. And // it only runs if there is actually content in the log (mxFrame>0). @@ -38258,7 +37696,7 @@ func walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill U32, pp uintptr) int (uint64(iLast) * uint64(unsafe.Sizeof(Ht_slot(0)))))) p = Xsqlite3_malloc64(tls, uint64(nByte)) if !(p != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, p, 0, uint64(nByte)) (*WalIterator)(unsafe.Pointer(p)).FnSegment = nSegment @@ -38267,20 +37705,20 @@ func walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill U32, pp uintptr) int // of memory will be freed before this function returns. aTmp = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(Ht_slot(0))) * (func() uint64 { - if iLast > U32(4096) { - return uint64(4096) + if iLast > HASHTABLE_NPAGE { + return HASHTABLE_NPAGE } return uint64(iLast) }())))) if !(aTmp != 0) { - rc = 7 + rc = SQLITE_NOMEM } - for i = walFramePage(tls, (nBackfill + U32(1))); (rc == 0) && (i < nSegment); i++ { + for i = walFramePage(tls, (nBackfill + U32(1))); (rc == SQLITE_OK) && (i < nSegment); i++ { // var sLoc WalHashLoc at bp, 24 rc = walHashGet(tls, pWal, i, bp /* &sLoc */) - if rc == 0 { + if rc == SQLITE_OK { var j int32 // Counter variable // var nEntry int32 at bp+24, 4 // Number of entries in this segment @@ -38307,7 +37745,7 @@ func walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill U32, pp uintptr) int } Xsqlite3_free(tls, aTmp) - if rc != 0 { + if rc != SQLITE_OK { walIteratorFree(tls, p) p = uintptr(0) } @@ -38321,7 +37759,7 @@ func walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill U32, pp uintptr) int // lock is successfully obtained or the busy-handler returns 0. func walBusyLock(tls *libc.TLS, pWal uintptr, xBusy uintptr, pBusyArg uintptr, lockIdx int32, n int32) int32 { /* sqlite3.c:61244:12: */ var rc int32 - for ok := true; ok; ok = (((xBusy != 0) && (rc == 5)) && ((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&xBusy)))(tls, pBusyArg) != 0)) { + for ok := true; ok; ok = (((xBusy != 0) && (rc == SQLITE_BUSY)) && ((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&xBusy)))(tls, pBusyArg) != 0)) { rc = walLockExclusive(tls, pWal, lockIdx, n) } return rc @@ -38358,14 +37796,14 @@ func walRestartHdr(tls *libc.TLS, pWal uintptr, salt1 U32) { /* sqlite3.c:61289: var aSalt uintptr = pWal + 72 /* &.hdr */ + 32 /* &.aSalt */ // Big-endian salt values (*Wal)(unsafe.Pointer(pWal)).FnCkpt++ (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = U32(0) - Xsqlite3Put4byte(tls, (aSalt + uintptr(0)*4), (U32(1) + Xsqlite3Get4byte(tls, (aSalt+uintptr(0)*4)))) - libc.Xmemcpy(tls, ((pWal + 72 /* &.hdr */ + 32 /* &.aSalt */) + uintptr(1)*4), bp /* &salt1 */, uint64(4)) + Xsqlite3Put4byte(tls, (aSalt), (U32(1) + Xsqlite3Get4byte(tls, (aSalt)))) + libc.Xmemcpy(tls, ((pWal + 72 /* &.hdr */ + 32 /* &.aSalt */) + 1*4), bp /* &salt1 */, uint64(4)) walIndexWriteHdr(tls, pWal) - libc.AtomicStoreNInt32((pInfo /* &.nBackfill */), int32(0), 0) - (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = U32(0) - *(*U32)(unsafe.Pointer((pInfo + 4 /* &.aReadMark */) + uintptr(1)*4)) = U32(0) - for i = 2; i < (8 - 3); i++ { - *(*U32)(unsafe.Pointer((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4)) = 0xffffffff + libc.AtomicStoreNInt32((libc.AtomicLoadUintptr(&pInfo) /* &.nBackfill */), int32(0), 0) + (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted = U32(0) + *(*U32)(unsafe.Pointer((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + 1*4)) = U32(0) + for i = 2; i < (SQLITE_SHM_NLOCK - 3); i++ { + *(*U32)(unsafe.Pointer((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4)) = READMARK_NOT_USED } } @@ -38425,15 +37863,15 @@ func walCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, xBusy u var szDb I64 var nBackfill U32 // var salt1 U32 at bp+32, 4 - rc = 0 + rc = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp /* pIter */)) = uintptr(0) *(*U32)(unsafe.Pointer(bp + 24 /* iDbpage */)) = U32(0) *(*U32)(unsafe.Pointer(bp + 28 /* iFrame */)) = U32(0) // The checkpoint status information szPage = walPagesize(tls, pWal) - pInfo = walCkptInfo(tls, pWal) - if !((*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) { + libc.AtomicStoreUintptr(&pInfo, uintptr(walCkptInfo(tls, pWal))) + if !((*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) { goto __1 } @@ -38448,29 +37886,29 @@ func walCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, xBusy u mxPage = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage i = 1 __2: - if !(i < (8 - 3)) { + if !(i < (SQLITE_SHM_NLOCK - 3)) { goto __4 } - y = U32(libc.AtomicLoadNUint32(((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4), 0)) + y = U32(libc.AtomicLoadNUint32(((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4), 0)) if !(mxSafeFrame > y) { goto __5 } rc = walBusyLock(tls, pWal, xBusy, pBusyArg, (3 + (i)), 1) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __6 } iMark = func() uint32 { if i == 1 { return mxSafeFrame } - return 0xffffffff + return READMARK_NOT_USED }() - libc.AtomicStoreNUint32(((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4), uint32(iMark), 0) + libc.AtomicStoreNUint32(((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4), uint32(iMark), 0) walUnlockExclusive(tls, pWal, (3 + (i)), 1) goto __7 __6: - if !(rc == 5) { + if !(rc == SQLITE_BUSY) { goto __8 } mxSafeFrame = y @@ -38493,34 +37931,34 @@ __4: ; // Allocate the iterator - if !((*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill < mxSafeFrame) { + if !((*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill < mxSafeFrame) { goto __10 } - rc = walIteratorInit(tls, pWal, (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill, bp /* &pIter */) + rc = walIteratorInit(tls, pWal, (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill, bp /* &pIter */) __10: ; if !((*(*uintptr)(unsafe.Pointer(bp /* pIter */)) != 0) && - ((libc.AssignInt32(&rc, walBusyLock(tls, pWal, xBusy, pBusyArg, (3+(0)), 1))) == 0)) { + ((libc.AssignInt32(&rc, walBusyLock(tls, pWal, xBusy, pBusyArg, (3+(0)), 1))) == SQLITE_OK)) { goto __11 } - nBackfill = (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill + nBackfill = (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill - (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = mxSafeFrame + (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted = mxSafeFrame // Sync the WAL to disk rc = Xsqlite3OsSync(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, (((sync_flags) >> 2) & 0x03)) // If the database may grow as a result of this checkpoint, hint // about the eventual size of the db file to the VFS layer. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __12 } *(*I64)(unsafe.Pointer(bp + 16 /* nReq */)) = (I64(mxPage) * I64(szPage)) // Current size of database file - Xsqlite3OsFileControl(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 39, uintptr(0)) + Xsqlite3OsFileControl(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_FCNTL_CKPT_START, uintptr(0)) rc = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, bp+8 /* &nSize */) - if !((rc == 0) && (*(*I64)(unsafe.Pointer(bp + 8 /* nSize */)) < *(*I64)(unsafe.Pointer(bp + 16 /* nReq */)))) { + if !((rc == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp + 8 /* nSize */)) < *(*I64)(unsafe.Pointer(bp + 16 /* nReq */)))) { goto __13 } if !(((*(*I64)(unsafe.Pointer(bp + 8 /* nSize */)) + int64(65536)) + (I64((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) * I64(szPage))) < *(*I64)(unsafe.Pointer(bp + 16 /* nReq */))) { @@ -38533,7 +37971,7 @@ __10: rc = Xsqlite3CorruptError(tls, 61420) goto __15 __14: - Xsqlite3OsFileControlHint(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 5, bp+16 /* &nReq */) + Xsqlite3OsFileControlHint(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_FCNTL_SIZE_HINT, bp+16 /* &nReq */) __15: ; __13: @@ -38544,7 +37982,7 @@ __12: // Iterate through the contents of the WAL, copying data to the db file __16: - if !((rc == 0) && (0 == walIteratorNext(tls, *(*uintptr)(unsafe.Pointer(bp /* pIter */)), bp+24 /* &iDbpage */, bp+28 /* &iFrame */))) { + if !((rc == SQLITE_OK) && (0 == walIteratorNext(tls, *(*uintptr)(unsafe.Pointer(bp /* pIter */)), bp+24 /* &iDbpage */, bp+28 /* &iFrame */))) { goto __17 } @@ -38552,9 +37990,9 @@ __16: goto __18 } if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - rc = 7 + rc = SQLITE_NOMEM } else { - rc = 9 + rc = SQLITE_INTERRUPT } goto __17 __18: @@ -38565,10 +38003,10 @@ __18: goto __16 __19: ; - iOffset = ((int64(32) + ((I64((*(*U32)(unsafe.Pointer(bp + 28 /* iFrame */))) - U32(1))) * (I64((szPage) + 24)))) + int64(24)) + iOffset = ((WAL_HDRSIZE + ((I64((*(*U32)(unsafe.Pointer(bp + 28 /* iFrame */))) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) + WAL_FRAME_HDRSIZE) // testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, zBuf, szPage, iOffset) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __20 } goto __17 @@ -38577,7 +38015,7 @@ __20: iOffset = ((I64(*(*U32)(unsafe.Pointer(bp + 24 /* iDbpage */)) - U32(1))) * I64(szPage)) rc = Xsqlite3OsWrite(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, zBuf, szPage, iOffset) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __21 } goto __17 @@ -38586,10 +38024,10 @@ __21: goto __16 __17: ; - Xsqlite3OsFileControl(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 37, uintptr(0)) + Xsqlite3OsFileControl(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_FCNTL_CKPT_DONE, uintptr(0)) // If work was actually accomplished... - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __22 } if !(mxSafeFrame == (*WalIndexHdr)(unsafe.Pointer(walIndexHdr(tls, pWal))).FmxFrame) { @@ -38598,7 +38036,7 @@ __17: szDb = (I64((*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage) * I64(szPage)) rc = Xsqlite3OsTruncate(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, szDb) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __24 } rc = Xsqlite3OsSync(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, (((sync_flags) >> 2) & 0x03)) @@ -38606,10 +38044,10 @@ __24: ; __23: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __25 } - libc.AtomicStoreNUint32((pInfo /* &.nBackfill */), uint32(mxSafeFrame), 0) + libc.AtomicStoreNUint32((libc.AtomicLoadUintptr(&pInfo) /* &.nBackfill */), uint32(mxSafeFrame), 0) __25: ; __22: @@ -38620,12 +38058,12 @@ __22: __11: ; - if !(rc == 5) { + if !(rc == SQLITE_BUSY) { goto __26 } // Reset the return code so as not to report a checkpoint failure // just because there are active readers. - rc = 0 + rc = SQLITE_OK __26: ; __1: @@ -38635,26 +38073,26 @@ __1: // entire wal file has been copied into the database file, then block // until all readers have finished using the wal file. This ensures that // the next process to write to the database restarts the wal file. - if !((rc == 0) && (eMode != 0)) { + if !((rc == SQLITE_OK) && (eMode != SQLITE_CHECKPOINT_PASSIVE)) { goto __27 } - if !((*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) { + if !((*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) { goto __28 } - rc = 5 + rc = SQLITE_BUSY goto __29 __28: - if !(eMode >= 2) { + if !(eMode >= SQLITE_CHECKPOINT_RESTART) { goto __30 } Xsqlite3_randomness(tls, 4, bp+32 /* &salt1 */) - rc = walBusyLock(tls, pWal, xBusy, pBusyArg, (3 + (1)), ((8 - 3) - 1)) - if !(rc == 0) { + rc = walBusyLock(tls, pWal, xBusy, pBusyArg, (3 + (1)), ((SQLITE_SHM_NLOCK - 3) - 1)) + if !(rc == SQLITE_OK) { goto __31 } - if !(eMode == 3) { + if !(eMode == SQLITE_CHECKPOINT_TRUNCATE) { goto __32 } // IMPLEMENTATION-OF: R-44699-57140 This mode works the same way as @@ -38674,7 +38112,7 @@ __28: rc = Xsqlite3OsTruncate(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, int64(0)) __32: ; - walUnlockExclusive(tls, pWal, (3 + (1)), ((8 - 3) - 1)) + walUnlockExclusive(tls, pWal, (3 + (1)), ((SQLITE_SHM_NLOCK - 3) - 1)) __31: ; __30: @@ -38700,7 +38138,7 @@ func walLimitSize(tls *libc.TLS, pWal uintptr, nMax I64) { /* sqlite3.c:61522:13 var rx int32 Xsqlite3BeginBenignMalloc(tls) rx = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+8 /* &sz */) - if (rx == 0) && (*(*I64)(unsafe.Pointer(bp + 8 /* sz */)) > nMax) { + if (rx == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp + 8 /* sz */)) > nMax) { rx = Xsqlite3OsTruncate(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, nMax) } Xsqlite3EndBenignMalloc(tls) @@ -38714,7 +38152,7 @@ func Xsqlite3WalClose(tls *libc.TLS, pWal uintptr, db uintptr, sync_flags int32, bp := tls.Alloc(4) defer tls.Free(4) - var rc int32 = 0 + var rc int32 = SQLITE_OK if pWal != 0 { var isDelete int32 = 0 // True to unlink wal and wal-index files @@ -38726,16 +38164,16 @@ func Xsqlite3WalClose(tls *libc.TLS, pWal uintptr, db uintptr, sync_flags int32, // // The EXCLUSIVE lock is not released before returning. if (zBuf != uintptr(0)) && - (0 == (libc.AssignInt32(&rc, Xsqlite3OsLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 4)))) { - if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == 0 { - (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(1) + (SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3OsLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_LOCK_EXCLUSIVE)))) { + if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_NORMAL_MODE { + (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = WAL_EXCLUSIVE_MODE } rc = Xsqlite3WalCheckpoint(tls, pWal, db, - 0, uintptr(0), uintptr(0), sync_flags, nBuf, zBuf, uintptr(0), uintptr(0)) - if rc == 0 { + SQLITE_CHECKPOINT_PASSIVE, uintptr(0), uintptr(0), sync_flags, nBuf, zBuf, uintptr(0), uintptr(0)) + if rc == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* bPersist */)) = -1 Xsqlite3OsFileControlHint(tls, - (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 10, bp /* &bPersist */) + (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_FCNTL_PERSIST_WAL, bp /* &bPersist */) if *(*int32)(unsafe.Pointer(bp /* bPersist */)) != 1 { // Try to delete the WAL file if the checkpoint completed and // fsyned (rc==SQLITE_OK) and if we are not in persistent-wal @@ -38811,10 +38249,10 @@ func walIndexTryHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* sq // here would be problematic as the memory being accessed is potentially // shared among multiple processes and not all mutex implementions work // reliably in that environment. - aHdr = walIndexHdr(tls, pWal) - libc.Xmemcpy(tls, bp /* &h1 */, (aHdr + uintptr(0)*48), uint64(unsafe.Sizeof(WalIndexHdr{}))) // Possible TSAN false-positive + libc.AtomicStoreUintptr(&aHdr, uintptr(walIndexHdr(tls, pWal))) + libc.Xmemcpy(tls, bp /* &h1 */, (libc.AtomicLoadUintptr(&aHdr)), uint64(unsafe.Sizeof(WalIndexHdr{}))) // Possible TSAN false-positive walShmBarrier(tls, pWal) - libc.Xmemcpy(tls, bp+48 /* &h2 */, (aHdr + uintptr(1)*48), uint64(unsafe.Sizeof(WalIndexHdr{}))) + libc.Xmemcpy(tls, bp+48 /* &h2 */, (libc.AtomicLoadUintptr(&aHdr) + 1*48), uint64(unsafe.Sizeof(WalIndexHdr{}))) if (libc.Xmemcmp(tls, bp /* &h1 */, bp+48 /* &h2 */, uint64(unsafe.Sizeof(WalIndexHdr{}))) != 0) { return 1 // Dirty read @@ -38823,7 +38261,7 @@ func walIndexTryHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* sq return 1 // Malformed header - probably all zeros } walChecksumBytes(tls, 1, bp /* &h1 */, (int32(uint64(unsafe.Sizeof(WalIndexHdr{})) - uint64(unsafe.Sizeof([2]U32{})))), uintptr(0), bp+96 /* &aCksum[0] */) - if (*(*U32)(unsafe.Pointer(bp + 96 /* &aCksum[0] */ + uintptr(0)*4)) != *(*U32)(unsafe.Pointer((bp /* &h1 */ + 40 /* &.aCksum */) + uintptr(0)*4))) || (*(*U32)(unsafe.Pointer(bp + 96 /* &aCksum[0] */ + uintptr(1)*4)) != *(*U32)(unsafe.Pointer((bp /* &h1 */ + 40 /* &.aCksum */) + uintptr(1)*4))) { + if (*(*U32)(unsafe.Pointer(bp + 96 /* &aCksum[0] */)) != *(*U32)(unsafe.Pointer((bp /* &h1 */ + 40 /* &.aCksum */)))) || (*(*U32)(unsafe.Pointer(bp + 96 /* &aCksum[0] */ + 1*4)) != *(*U32)(unsafe.Pointer((bp /* &h1 */ + 40 /* &.aCksum */) + 1*4))) { return 1 // Checksum does not match } @@ -38864,9 +38302,9 @@ func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* s // wal-index header) is mapped. Return early if an error occurs here. rc = walIndexPage(tls, pWal, 0, bp /* &page0 */) - if rc != 0 { + if rc != SQLITE_OK { // READONLY changed to OK in walIndexPage - if rc == (8 | (int32(5) << 8)) { + if rc == (SQLITE_READONLY | (int32(5) << 8)) { // The SQLITE_READONLY_CANTINIT return means that the shared-memory // was openable but is not writable, and this thread is unable to // confirm that another write-capable connection has the shared-memory @@ -38875,7 +38313,7 @@ func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* s // and there is no writer on hand to fix it. (*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable = U8(1) - (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(2) + (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = WAL_HEAPMEMORY_MODE *(*int32)(unsafe.Pointer(pChanged)) = 1 } else { return rc // Any other non-OK return is just an error @@ -38891,7 +38329,7 @@ func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* s // works, but may fail if the wal-index header is corrupt or currently // being modified by another thread or process. badHdr = func() int32 { - if *(*uintptr)(unsafe.Pointer(bp /* page0 */)) != 0 { + if libc.AtomicLoadPUintptr(bp /* page0 */) != 0 { return walIndexTryHdr(tls, pWal, pChanged) } return 1 @@ -38900,16 +38338,16 @@ func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* s // If the first attempt failed, it might have been due to a race // with a writer. So get a WRITE lock and try again. if badHdr != 0 { - if (int32((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0) && ((int32((*Wal)(unsafe.Pointer(pWal)).FreadOnly) & 2) != 0) { - if 0 == (libc.AssignInt32(&rc, walLockShared(tls, pWal, 0))) { - walUnlockShared(tls, pWal, 0) - rc = (8 | (int32(1) << 8)) + if (int32((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0) && ((int32((*Wal)(unsafe.Pointer(pWal)).FreadOnly) & WAL_SHM_RDONLY) != 0) { + if SQLITE_OK == (libc.AssignInt32(&rc, walLockShared(tls, pWal, WAL_WRITE_LOCK))) { + walUnlockShared(tls, pWal, WAL_WRITE_LOCK) + rc = (SQLITE_READONLY | (int32(1) << 8)) } } else { var bWriteLock int32 = int32((*Wal)(unsafe.Pointer(pWal)).FwriteLock) - if (bWriteLock != 0) || (0 == (libc.AssignInt32(&rc, walLockExclusive(tls, pWal, 0, 1)))) { + if (bWriteLock != 0) || (SQLITE_OK == (libc.AssignInt32(&rc, walLockExclusive(tls, pWal, WAL_WRITE_LOCK, 1)))) { (*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(1) - if 0 == (libc.AssignInt32(&rc, walIndexPage(tls, pWal, 0, bp /* &page0 */))) { + if SQLITE_OK == (libc.AssignInt32(&rc, walIndexPage(tls, pWal, 0, bp /* &page0 */))) { badHdr = walIndexTryHdr(tls, pWal, pChanged) if badHdr != 0 { // If the wal-index header is still malformed even while holding @@ -38921,7 +38359,7 @@ func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* s } if bWriteLock == 0 { (*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(0) - walUnlockExclusive(tls, pWal, 0, 1) + walUnlockExclusive(tls, pWal, WAL_WRITE_LOCK, 1) } } } @@ -38930,22 +38368,22 @@ func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* s // If the header is read successfully, check the version number to make // sure the wal-index was not constructed with some future format that // this version of SQLite cannot understand. - if (badHdr == 0) && ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FiVersion != U32(3007000)) { + if (badHdr == 0) && ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FiVersion != WALINDEX_MAX_VERSION) { rc = Xsqlite3CantopenError(tls, 61769) } if (*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable != 0 { - if rc != 0 { + if rc != SQLITE_OK { walIndexClose(tls, pWal, 0) (*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable = U8(0) // walIndexRecover() might have returned SHORT_READ if a concurrent // writer truncated the WAL out from under it. If that happens, it // indicates that a writer has fixed the SHM file for us, so retry - if rc == (10 | (int32(2) << 8)) { + if rc == (SQLITE_IOERR | (int32(2) << 8)) { rc = -1 } } - (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(0) + (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = WAL_NORMAL_MODE } return rc @@ -39004,10 +38442,10 @@ func walBeginShmUnreliable(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 // writers from running a checkpoint, but does not stop them // from running recovery. rc = walLockShared(tls, pWal, (3 + (0))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __1 } - if !(rc == 5) { + if !(rc == SQLITE_BUSY) { goto __2 } rc = -1 @@ -39039,13 +38477,13 @@ __1: // even if some external agent does a "chmod" to make the shared-memory // writable by us, until sqlite3OsShmUnmap() has been called. // This is a requirement on the VFS implementation. - rc = Xsqlite3OsShmMap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 0, (int32((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(4096 * 2))) + (uint64(4096) * uint64(unsafe.Sizeof(U32(0)))))), 0, bp /* &pDummy */) + rc = Xsqlite3OsShmMap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 0, (int32((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(HASHTABLE_NPAGE * 2))) + (HASHTABLE_NPAGE * uint64(unsafe.Sizeof(U32(0)))))), 0, bp /* &pDummy */) // SQLITE_OK not possible for read-only connection - if !(rc != (8 | (int32(5) << 8))) { + if !(rc != (SQLITE_READONLY | (int32(5) << 8))) { goto __3 } rc = func() int32 { - if rc == 8 { + if rc == SQLITE_READONLY { return -1 } return rc @@ -39062,13 +38500,13 @@ __3: // Make sure some writer hasn't come in and changed the WAL file out // from under us, then disconnected, while we were not looking. rc = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+8 /* &szWal */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } goto begin_unreliable_shm_out __4: ; - if !(*(*I64)(unsafe.Pointer(bp + 8 /* szWal */)) < int64(32)) { + if !(*(*I64)(unsafe.Pointer(bp + 8 /* szWal */)) < WAL_HDRSIZE) { goto __5 } // If the wal file is too small to contain a wal-header and the @@ -39080,7 +38518,7 @@ __4: *(*int32)(unsafe.Pointer(pChanged)) = 1 rc = func() int32 { if (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame == U32(0) { - return 0 + return SQLITE_OK } return -1 }() @@ -39089,14 +38527,14 @@ __5: ; // Check the salt keys at the start of the wal file still match. - rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+16 /* &aBuf[0] */, 32, int64(0)) - if !(rc != 0) { + rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+16 /* &aBuf[0] */, WAL_HDRSIZE, int64(0)) + if !(rc != SQLITE_OK) { goto __6 } goto begin_unreliable_shm_out __6: ; - if !(libc.Xmemcmp(tls, (pWal+72 /* &.hdr */ +32 /* &.aSalt */), (bp+16 /* &aBuf */ +uintptr(16)), uint64(8)) != 0) { + if !(libc.Xmemcmp(tls, (pWal+72 /* &.hdr */ +32 /* &.aSalt */), (bp+16 /* &aBuf */ +16), uint64(8)) != 0) { goto __7 } // Some writer has wrapped the WAL file while we were not looking. @@ -39108,24 +38546,24 @@ __7: ; // Allocate a buffer to read frames into - szFrame = (int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage) + 24) + szFrame = (int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage) + WAL_FRAME_HDRSIZE) aFrame = Xsqlite3_malloc64(tls, uint64(szFrame)) if !(aFrame == uintptr(0)) { goto __8 } - rc = 7 + rc = SQLITE_NOMEM goto begin_unreliable_shm_out __8: ; - aData = (aFrame + uintptr(24)) + aData = (aFrame + 24) // Check to see if a complete transaction has been appended to the // wal file since the heap-memory wal-index was created. If so, the // heap-memory wal-index is discarded and WAL_RETRY returned to // the caller. - *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */ + uintptr(0)*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) - *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */ + uintptr(1)*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) - iOffset = (int64(32) + ((I64(((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + U32(1)) - U32(1))) * (I64((int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage)) + 24)))) + *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) + *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */ + 1*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) + iOffset = (WAL_HDRSIZE + ((I64(((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + U32(1)) - U32(1))) * (I64((int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage)) + WAL_FRAME_HDRSIZE)))) __9: if !((iOffset + I64(szFrame)) <= *(*I64)(unsafe.Pointer(bp + 8 /* szWal */))) { goto __11 @@ -39133,7 +38571,7 @@ __9: // Read and decode the next log frame. rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aFrame, szFrame, iOffset) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } goto __11 @@ -39163,12 +38601,12 @@ __10: goto __11 __11: ; - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) = *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */ + uintptr(0)*4)) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) = *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */ + uintptr(1)*4)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) = *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) = *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */ + 1*4)) begin_unreliable_shm_out: Xsqlite3_free(tls, aFrame) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __15 } i = 0 @@ -39242,12 +38680,12 @@ __15: // so it takes care to hold an exclusive lock on the corresponding // WAL_READ_LOCK() while changing values. func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32, cnt int32) int32 { /* sqlite3.c:62009:12: */ - var pInfo uintptr // Checkpoint information in wal-index - var mxReadMark U32 // Largest aReadMark[] value - var mxI int32 // Index of largest aReadMark[] value - var i int32 // Loop counter - var rc int32 = 0 // Return code - var mxFrame U32 // Wal frame to lock to + var pInfo uintptr // Checkpoint information in wal-index + var mxReadMark U32 // Largest aReadMark[] value + var mxI int32 // Index of largest aReadMark[] value + var i int32 // Loop counter + var rc int32 = SQLITE_OK // Return code + var mxFrame U32 // Wal frame to lock to // Not currently locked @@ -39273,7 +38711,7 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 var nDelay int32 = 1 // Pause time in microseconds if cnt > 100 { - return 15 + return SQLITE_PROTOCOL } if cnt >= 10 { nDelay = (((cnt - 9) * (cnt - 9)) * 39) @@ -39286,7 +38724,7 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 if int32((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0 { rc = walIndexReadHdr(tls, pWal, pChanged) } - if rc == 5 { + if rc == SQLITE_BUSY { // If there is not a recovery running in another thread or process // then convert BUSY errors to WAL_RETRY. If recovery is known to // be running, convert BUSY to BUSY_RECOVERY. There is a race here @@ -39294,7 +38732,7 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 // would be technically correct. But the race is benign since with // WAL_RETRY this routine will be called again and will probably be // right on the second iteration. - if *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(0)*8)) == uintptr(0) { + if *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData)) == uintptr(0) { // This branch is taken when the xShmMap() method returns SQLITE_BUSY. // We assume this is a transient condition, so return WAL_RETRY. The // xShmMap() implementation used by the default unix and win32 VFS @@ -39302,28 +38740,28 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 // code that determines whether or not the shared-memory region // must be zeroed before the requested page is returned. rc = -1 - } else if 0 == (libc.AssignInt32(&rc, walLockShared(tls, pWal, 2))) { - walUnlockShared(tls, pWal, 2) + } else if SQLITE_OK == (libc.AssignInt32(&rc, walLockShared(tls, pWal, WAL_RECOVER_LOCK))) { + walUnlockShared(tls, pWal, WAL_RECOVER_LOCK) rc = -1 - } else if rc == 5 { - rc = (5 | (int32(1) << 8)) + } else if rc == SQLITE_BUSY { + rc = (SQLITE_BUSY | (int32(1) << 8)) } } - if rc != 0 { + if rc != SQLITE_OK { return rc } else if (*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable != 0 { return walBeginShmUnreliable(tls, pWal, pChanged) } } - pInfo = walCkptInfo(tls, pWal) - if (!(useWal != 0) && (U32(libc.AtomicLoadNUint32((pInfo /* &.nBackfill */), 0)) == (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame)) && + libc.AtomicStoreUintptr(&pInfo, uintptr(walCkptInfo(tls, pWal))) + if (!(useWal != 0) && (U32(libc.AtomicLoadNUint32((libc.AtomicLoadUintptr(&pInfo) /* &.nBackfill */), 0)) == (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame)) && (((*Wal)(unsafe.Pointer(pWal)).FpSnapshot == uintptr(0)) || ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame == U32(0))) { // The WAL has been completely backfilled (or it is empty). // and can be safely ignored. rc = walLockShared(tls, pWal, (3 + (0))) walShmBarrier(tls, pWal) - if rc == 0 { + if rc == SQLITE_OK { if libc.Xmemcmp(tls, walIndexHdr(tls, pWal), (pWal+72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) != 0 { // It is not safe to allow the reader to continue here if frames // may have been appended to the log before READ_LOCK(0) was obtained. @@ -39341,8 +38779,8 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 return -1 } (*Wal)(unsafe.Pointer(pWal)).FreadLock = int16(0) - return 0 - } else if rc != 5 { + return SQLITE_OK + } else if rc != SQLITE_BUSY { return rc } } @@ -39357,40 +38795,40 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 if ((*Wal)(unsafe.Pointer(pWal)).FpSnapshot != 0) && ((*WalIndexHdr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FpSnapshot)).FmxFrame < mxFrame) { mxFrame = (*WalIndexHdr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FpSnapshot)).FmxFrame } - for i = 1; i < (8 - 3); i++ { - var thisMark U32 = U32(libc.AtomicLoadNUint32(((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4), 0)) + for i = 1; i < (SQLITE_SHM_NLOCK - 3); i++ { + var thisMark U32 = U32(libc.AtomicLoadNUint32(((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4), 0)) if (mxReadMark <= thisMark) && (thisMark <= mxFrame) { mxReadMark = thisMark mxI = i } } - if ((int32((*Wal)(unsafe.Pointer(pWal)).FreadOnly) & 2) == 0) && + if ((int32((*Wal)(unsafe.Pointer(pWal)).FreadOnly) & WAL_SHM_RDONLY) == 0) && ((mxReadMark < mxFrame) || (mxI == 0)) { - for i = 1; i < (8 - 3); i++ { + for i = 1; i < (SQLITE_SHM_NLOCK - 3); i++ { rc = walLockExclusive(tls, pWal, (3 + (i)), 1) - if rc == 0 { - libc.AtomicStoreNUint32(((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4), uint32(mxFrame), 0) + if rc == SQLITE_OK { + libc.AtomicStoreNUint32(((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4), uint32(mxFrame), 0) mxReadMark = mxFrame mxI = i walUnlockExclusive(tls, pWal, (3 + (i)), 1) break - } else if rc != 5 { + } else if rc != SQLITE_BUSY { return rc } } } if mxI == 0 { - if rc == 5 { + if rc == SQLITE_BUSY { return -1 } - return (8 | (int32(5) << 8)) + return (SQLITE_READONLY | (int32(5) << 8)) } rc = walLockShared(tls, pWal, (3 + (mxI))) if rc != 0 { - if rc == 5 { + if rc == SQLITE_BUSY { return -1 } return rc @@ -39428,9 +38866,9 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 // that it can read version A from the database file. However, since // we can guarantee that the checkpointer that set nBackfill could not // see any pages past pWal->hdr.mxFrame, this problem does not come up. - (*Wal)(unsafe.Pointer(pWal)).FminFrame = (U32(libc.AtomicLoadNUint32((pInfo /* &.nBackfill */), 0) + 1)) + (*Wal)(unsafe.Pointer(pWal)).FminFrame = (U32(libc.AtomicLoadNUint32((libc.AtomicLoadUintptr(&pInfo) /* &.nBackfill */), 0) + 1)) walShmBarrier(tls, pWal) - if (U32(libc.AtomicLoadNUint32(((pInfo+4 /* &.aReadMark */)+uintptr(mxI)*4), 0)) != mxReadMark) || + if (U32(libc.AtomicLoadNUint32(((libc.AtomicLoadUintptr(&pInfo)+4 /* &.aReadMark */)+uintptr(mxI)*4), 0)) != mxReadMark) || (libc.Xmemcmp(tls, walIndexHdr(tls, pWal), (pWal+72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) != 0) { walUnlockShared(tls, pWal, (3 + (mxI))) return -1 @@ -39464,22 +38902,22 @@ func Xsqlite3WalSnapshotRecover(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3. var rc int32 - rc = walLockExclusive(tls, pWal, 1, 1) - if rc == 0 { + rc = walLockExclusive(tls, pWal, WAL_CKPT_LOCK, 1) + if rc == SQLITE_OK { var pInfo uintptr = walCkptInfo(tls, pWal) var szPage int32 = int32((*Wal)(unsafe.Pointer(pWal)).FszPage) // var szDb I64 at bp, 8 // Size of db file in bytes rc = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, bp /* &szDb */) - if rc == 0 { + if rc == SQLITE_OK { var pBuf1 uintptr = Xsqlite3_malloc(tls, szPage) var pBuf2 uintptr = Xsqlite3_malloc(tls, szPage) if (pBuf1 == uintptr(0)) || (pBuf2 == uintptr(0)) { - rc = 7 + rc = SQLITE_NOMEM } else { - var i U32 = (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted - for i = (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted; i > U32(libc.AtomicLoadNUint32((pInfo /* &.nBackfill */), 0)); i-- { + var i U32 = (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted + for i = (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted; i > U32(libc.AtomicLoadNUint32((libc.AtomicLoadUintptr(&pInfo) /* &.nBackfill */), 0)); i-- { // var sLoc WalHashLoc at bp+8, 24 // Hash table location var pgno U32 // Page number in db file @@ -39487,33 +38925,33 @@ func Xsqlite3WalSnapshotRecover(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3. var iWalOff I64 // Offset of wal file entry rc = walHashGet(tls, pWal, walFramePage(tls, i), bp+8 /* &sLoc */) - if rc != 0 { + if rc != SQLITE_OK { break } pgno = *(*U32)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp+8 /* &sLoc */)).FaPgno + uintptr((i-(*WalHashLoc)(unsafe.Pointer(bp+8 /* &sLoc */)).FiZero))*4)) iDbOff = ((I64(pgno - U32(1))) * I64(szPage)) if (iDbOff + I64(szPage)) <= *(*I64)(unsafe.Pointer(bp /* szDb */)) { - iWalOff = ((int64(32) + ((I64((i) - U32(1))) * (I64((szPage) + 24)))) + int64(24)) + iWalOff = ((WAL_HDRSIZE + ((I64((i) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) + WAL_FRAME_HDRSIZE) rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, pBuf1, szPage, iWalOff) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, pBuf2, szPage, iDbOff) } - if (rc != 0) || (0 == libc.Xmemcmp(tls, pBuf1, pBuf2, uint64(szPage))) { + if (rc != SQLITE_OK) || (0 == libc.Xmemcmp(tls, pBuf1, pBuf2, uint64(szPage))) { break } } - (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = (i - U32(1)) + (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted = (i - U32(1)) } } Xsqlite3_free(tls, pBuf1) Xsqlite3_free(tls, pBuf2) } - walUnlockExclusive(tls, pWal, 1, 1) + walUnlockExclusive(tls, pWal, WAL_CKPT_LOCK, 1) } return rc @@ -39551,9 +38989,9 @@ func Xsqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintp // there is no checkpointer process by taking a shared CKPT lock // before checking pInfo->nBackfillAttempted. - rc = walLockShared(tls, pWal, 1) + rc = walLockShared(tls, pWal, WAL_CKPT_LOCK) - if rc != 0 { + if rc != SQLITE_OK { return rc } (*Wal)(unsafe.Pointer(pWal)).FckptLock = U8(1) @@ -39563,7 +39001,7 @@ func Xsqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintp rc = walTryBeginRead(tls, pWal, pChanged, 0, libc.PreIncInt32(&cnt, 1)) } - if rc == 0 { + if rc == SQLITE_OK { if (pSnapshot != 0) && (libc.Xmemcmp(tls, pSnapshot, (pWal+72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) != 0) { // At this point the client has a lock on an aReadMark[] slot holding // a value equal to or smaller than pSnapshot->mxFrame, but pWal->hdr @@ -39586,12 +39024,12 @@ func Xsqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintp // with *pSnapshot and set *pChanged as appropriate for opening the // snapshot. if !(libc.Xmemcmp(tls, pSnapshot+32 /* &.aSalt */, pWal+72 /* &.hdr */ +32 /* &.aSalt */, uint64(unsafe.Sizeof([2]U32{}))) != 0) && - ((*WalIndexHdr)(unsafe.Pointer(pSnapshot)).FmxFrame >= (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted) { + ((*WalIndexHdr)(unsafe.Pointer(pSnapshot)).FmxFrame >= (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted) { libc.Xmemcpy(tls, (pWal + 72 /* &.hdr */), pSnapshot, uint64(unsafe.Sizeof(WalIndexHdr{}))) *(*int32)(unsafe.Pointer(pChanged)) = bChanged } else { - rc = (1 | (int32(3) << 8)) + rc = (SQLITE_ERROR | (int32(3) << 8)) } // A client using a non-current snapshot may not ignore any frames @@ -39602,7 +39040,7 @@ func Xsqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintp // is the same database page. (*Wal)(unsafe.Pointer(pWal)).FminFrame = U32(1) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3WalEndReadTransaction(tls, pWal) } } @@ -39611,7 +39049,7 @@ func Xsqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintp // Release the shared CKPT lock obtained above. if (*Wal)(unsafe.Pointer(pWal)).FckptLock != 0 { - walUnlockShared(tls, pWal, 1) + walUnlockShared(tls, pWal, WAL_CKPT_LOCK) (*Wal)(unsafe.Pointer(pWal)).FckptLock = U8(0) } return rc @@ -39651,7 +39089,7 @@ func Xsqlite3WalFindFrame(tls *libc.TLS, pWal uintptr, pgno Pgno, piRead uintptr // WAL were empty. if (iLast == U32(0)) || ((int32((*Wal)(unsafe.Pointer(pWal)).FreadLock) == 0) && (int32((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0)) { *(*U32)(unsafe.Pointer(piRead)) = U32(0) - return 0 + return SQLITE_OK } // Search the hash table or tables for an entry matching page number @@ -39688,10 +39126,10 @@ func Xsqlite3WalFindFrame(tls *libc.TLS, pWal uintptr, pgno Pgno, piRead uintptr var iH U32 rc = walHashGet(tls, pWal, iHash, bp /* &sLoc */) - if rc != 0 { + if rc != SQLITE_OK { return rc } - nCollide = (4096 * 2) + nCollide = (HASHTABLE_NPAGE * 2) iKey = walHash(tls, pgno) for (libc.AssignUint32(&iH, U32(libc.AtomicLoadNUint16(((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaHash+uintptr(iKey)*2), 0)))) != U32(0) { var iFrame U32 = (iH + (*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FiZero) @@ -39710,7 +39148,7 @@ func Xsqlite3WalFindFrame(tls *libc.TLS, pWal uintptr, pgno Pgno, piRead uintptr } *(*U32)(unsafe.Pointer(piRead)) = iRead - return 0 + return SQLITE_OK } // Read the contents of frame iRead from the wal file into buffer pOut @@ -39722,7 +39160,7 @@ func Xsqlite3WalReadFrame(tls *libc.TLS, pWal uintptr, iRead U32, nOut int32, pO sz = int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage) sz = ((sz & 0xfe00) + ((sz & 0x0001) << 16)) - iOffset = ((int64(32) + ((I64((iRead) - U32(1))) * (I64((sz) + 24)))) + int64(24)) + iOffset = ((WAL_HDRSIZE + ((I64((iRead) - U32(1))) * (I64((sz) + WAL_FRAME_HDRSIZE)))) + WAL_FRAME_HDRSIZE) // testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL return Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, pOut, func() int32 { if nOut > sz { @@ -39758,12 +39196,12 @@ func Xsqlite3WalBeginWriteTransaction(tls *libc.TLS, pWal uintptr) int32 { /* sq // transaction. if (*Wal)(unsafe.Pointer(pWal)).FreadOnly != 0 { - return 8 + return SQLITE_READONLY } // Only one writer allowed at a time. Get the write lock. Return // SQLITE_BUSY if unable. - rc = walLockExclusive(tls, pWal, 0, 1) + rc = walLockExclusive(tls, pWal, WAL_WRITE_LOCK, 1) if rc != 0 { return rc } @@ -39773,9 +39211,9 @@ func Xsqlite3WalBeginWriteTransaction(tls *libc.TLS, pWal uintptr) int32 { /* sq // time the read transaction on this connection was started, then // the write is disallowed. if (libc.Xmemcmp(tls, (pWal+72 /* &.hdr */), walIndexHdr(tls, pWal), uint64(unsafe.Sizeof(WalIndexHdr{}))) != 0) { - walUnlockExclusive(tls, pWal, 0, 1) + walUnlockExclusive(tls, pWal, WAL_WRITE_LOCK, 1) (*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(0) - rc = (5 | (int32(2) << 8)) + rc = (SQLITE_BUSY | (int32(2) << 8)) } return rc @@ -39785,12 +39223,12 @@ func Xsqlite3WalBeginWriteTransaction(tls *libc.TLS, pWal uintptr) int32 { /* sq // routine merely releases the lock. func Xsqlite3WalEndWriteTransaction(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3.c:62626:20: */ if (*Wal)(unsafe.Pointer(pWal)).FwriteLock != 0 { - walUnlockExclusive(tls, pWal, 0, 1) + walUnlockExclusive(tls, pWal, WAL_WRITE_LOCK, 1) (*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(0) (*Wal)(unsafe.Pointer(pWal)).FiReCksum = U32(0) (*Wal)(unsafe.Pointer(pWal)).FtruncateOnCommit = U8(0) } - return 0 + return SQLITE_OK } // If any data has been written (but not committed) to the log file, this @@ -39804,7 +39242,7 @@ func Xsqlite3WalEndWriteTransaction(tls *libc.TLS, pWal uintptr) int32 { /* sqli // Otherwise, if the callback function does not return an error, this // function returns SQLITE_OK. func Xsqlite3WalUndo(tls *libc.TLS, pWal uintptr, xUndo uintptr, pUndoCtx uintptr) int32 { /* sqlite3.c:62648:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Wal)(unsafe.Pointer(pWal)).FwriteLock != 0 { var iMax Pgno = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame var iFrame Pgno @@ -39813,7 +39251,7 @@ func Xsqlite3WalUndo(tls *libc.TLS, pWal uintptr, xUndo uintptr, pUndoCtx uintpt // was in before the client began writing to the database. libc.Xmemcpy(tls, (pWal + 72 /* &.hdr */), walIndexHdr(tls, pWal), uint64(unsafe.Sizeof(WalIndexHdr{}))) - for iFrame = ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + U32(1)); (rc == 0) && (iFrame <= iMax); iFrame++ { + for iFrame = ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + U32(1)); (rc == SQLITE_OK) && (iFrame <= iMax); iFrame++ { // This call cannot fail. Unless the page for which the page number // is passed as the second argument is (a) in the cache and // (b) has an outstanding reference, then xUndo is either a no-op @@ -39840,10 +39278,10 @@ func Xsqlite3WalUndo(tls *libc.TLS, pWal uintptr, xUndo uintptr, pUndoCtx uintpt // point in the event of a savepoint rollback (via WalSavepointUndo()). func Xsqlite3WalSavepoint(tls *libc.TLS, pWal uintptr, aWalData uintptr) { /* sqlite3.c:62688:21: */ - *(*U32)(unsafe.Pointer(aWalData + uintptr(0)*4)) = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame - *(*U32)(unsafe.Pointer(aWalData + uintptr(1)*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) - *(*U32)(unsafe.Pointer(aWalData + uintptr(2)*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) - *(*U32)(unsafe.Pointer(aWalData + uintptr(3)*4)) = (*Wal)(unsafe.Pointer(pWal)).FnCkpt + *(*U32)(unsafe.Pointer(aWalData)) = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + *(*U32)(unsafe.Pointer(aWalData + 1*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) + *(*U32)(unsafe.Pointer(aWalData + 2*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) + *(*U32)(unsafe.Pointer(aWalData + 3*4)) = (*Wal)(unsafe.Pointer(pWal)).FnCkpt } // Move the write position of the WAL back to the point identified by @@ -39851,20 +39289,20 @@ func Xsqlite3WalSavepoint(tls *libc.TLS, pWal uintptr, aWalData uintptr) { /* sq // of WAL_SAVEPOINT_NDATA u32 values that has been previously populated // by a call to WalSavepoint(). func Xsqlite3WalSavepointUndo(tls *libc.TLS, pWal uintptr, aWalData uintptr) int32 { /* sqlite3.c:62702:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK - if *(*U32)(unsafe.Pointer(aWalData + uintptr(3)*4)) != (*Wal)(unsafe.Pointer(pWal)).FnCkpt { + if *(*U32)(unsafe.Pointer(aWalData + 3*4)) != (*Wal)(unsafe.Pointer(pWal)).FnCkpt { // This savepoint was opened immediately after the write-transaction // was started. Right after that, the writer decided to wrap around // to the start of the log. Update the savepoint values to match. - *(*U32)(unsafe.Pointer(aWalData + uintptr(0)*4)) = U32(0) - *(*U32)(unsafe.Pointer(aWalData + uintptr(3)*4)) = (*Wal)(unsafe.Pointer(pWal)).FnCkpt + *(*U32)(unsafe.Pointer(aWalData)) = U32(0) + *(*U32)(unsafe.Pointer(aWalData + 3*4)) = (*Wal)(unsafe.Pointer(pWal)).FnCkpt } - if *(*U32)(unsafe.Pointer(aWalData + uintptr(0)*4)) < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame { - (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = *(*U32)(unsafe.Pointer(aWalData + uintptr(0)*4)) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) = *(*U32)(unsafe.Pointer(aWalData + uintptr(1)*4)) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) = *(*U32)(unsafe.Pointer(aWalData + uintptr(2)*4)) + if *(*U32)(unsafe.Pointer(aWalData)) < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame { + (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = *(*U32)(unsafe.Pointer(aWalData)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) = *(*U32)(unsafe.Pointer(aWalData + 1*4)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) = *(*U32)(unsafe.Pointer(aWalData + 2*4)) walCleanupHash(tls, pWal) } @@ -39885,18 +39323,18 @@ func walRestartLog(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3.c:62739:12: * bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var cnt int32 if int32((*Wal)(unsafe.Pointer(pWal)).FreadLock) == 0 { var pInfo uintptr = walCkptInfo(tls, pWal) - if (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill > U32(0) { + if (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill > U32(0) { // var salt1 U32 at bp, 4 Xsqlite3_randomness(tls, 4, bp /* &salt1 */) - rc = walLockExclusive(tls, pWal, (3 + (1)), ((8 - 3) - 1)) - if rc == 0 { + rc = walLockExclusive(tls, pWal, (3 + (1)), ((SQLITE_SHM_NLOCK - 3) - 1)) + if rc == SQLITE_OK { // If all readers are using WAL_READ_LOCK(0) (in other words if no // readers are currently using the WAL), then the transactions // frames will overwrite the start of the existing log. Update the @@ -39907,8 +39345,8 @@ func walRestartLog(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3.c:62739:12: * // safe and means there is no special case for sqlite3WalUndo() // to handle if this transaction is rolled back. walRestartHdr(tls, pWal, *(*U32)(unsafe.Pointer(bp /* salt1 */))) - walUnlockExclusive(tls, pWal, (3 + (1)), ((8 - 3) - 1)) - } else if rc != 5 { + walUnlockExclusive(tls, pWal, (3 + (1)), ((SQLITE_SHM_NLOCK - 3) - 1)) + } else if rc != SQLITE_BUSY { return rc } } @@ -40000,16 +39438,16 @@ func walRewriteChecksums(tls *libc.TLS, pWal uintptr, iLast U32) int32 { /* sqli defer tls.Free(24) var szPage int32 = int32((*Wal)(unsafe.Pointer(pWal)).FszPage) // Database page size - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var aBuf uintptr // Buffer to load data from wal file into // var aFrame [24]U8 at bp, 24 // Buffer to assemble frame-headers in var iRead U32 // Next frame to read from wal file var iCksumOff I64 - aBuf = Xsqlite3_malloc(tls, (szPage + 24)) + aBuf = Xsqlite3_malloc(tls, (szPage + WAL_FRAME_HDRSIZE)) if aBuf == uintptr(0) { - return 7 + return SQLITE_NOMEM } // Find the checksum values to use as input for the recalculating the @@ -40021,24 +39459,24 @@ func walRewriteChecksums(tls *libc.TLS, pWal uintptr, iLast U32) int32 { /* sqli if (*Wal)(unsafe.Pointer(pWal)).FiReCksum == U32(1) { iCksumOff = int64(24) } else { - iCksumOff = ((int64(32) + ((I64(((*Wal)(unsafe.Pointer(pWal)).FiReCksum - U32(1)) - U32(1))) * (I64((szPage) + 24)))) + int64(16)) + iCksumOff = ((WAL_HDRSIZE + ((I64(((*Wal)(unsafe.Pointer(pWal)).FiReCksum - U32(1)) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) + int64(16)) } rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aBuf, (int32(uint64(unsafe.Sizeof(U32(0))) * uint64(2))), iCksumOff) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) = Xsqlite3Get4byte(tls, aBuf) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) = Xsqlite3Get4byte(tls, (aBuf + uintptr(uint64(unsafe.Sizeof(U32(0)))))) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) = Xsqlite3Get4byte(tls, aBuf) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) = Xsqlite3Get4byte(tls, (aBuf + 4)) iRead = (*Wal)(unsafe.Pointer(pWal)).FiReCksum (*Wal)(unsafe.Pointer(pWal)).FiReCksum = U32(0) - for ; (rc == 0) && (iRead <= iLast); iRead++ { - var iOff I64 = (int64(32) + ((I64((iRead) - U32(1))) * (I64((szPage) + 24)))) - rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aBuf, (szPage + 24), iOff) - if rc == 0 { + for ; (rc == SQLITE_OK) && (iRead <= iLast); iRead++ { + var iOff I64 = (WAL_HDRSIZE + ((I64((iRead) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) + rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aBuf, (szPage + WAL_FRAME_HDRSIZE), iOff) + if rc == SQLITE_OK { var iPgno U32 var nDbSize U32 iPgno = Xsqlite3Get4byte(tls, aBuf) - nDbSize = Xsqlite3Get4byte(tls, (aBuf + uintptr(4))) + nDbSize = Xsqlite3Get4byte(tls, (aBuf + 4)) - walEncodeFrame(tls, pWal, iPgno, nDbSize, (aBuf + uintptr(24)), bp /* &aFrame[0] */) + walEncodeFrame(tls, pWal, iPgno, nDbSize, (aBuf + 24), bp /* &aFrame[0] */) rc = Xsqlite3OsWrite(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp /* &aFrame[0] */, int32(unsafe.Sizeof([24]U8{})), iOff) } } @@ -40075,7 +39513,7 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, // See if it is possible to write these frames into the start of the // log file, instead of appending to it at pWal->hdr.mxFrame. - if 0 != (libc.AssignInt32(&rc, walRestartLog(tls, pWal))) { + if SQLITE_OK != (libc.AssignInt32(&rc, walRestartLog(tls, pWal))) { return rc } @@ -40089,27 +39527,27 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, // var aCksum [2]U32 at bp+32, 8 // Checksum for wal-header - Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + uintptr(0)), (uint32(0x377f0682 | 0))) - Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + uintptr(4)), uint32(3007000)) - Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + uintptr(8)), uint32(szPage)) - Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + uintptr(12)), (*Wal)(unsafe.Pointer(pWal)).FnCkpt) + Xsqlite3Put4byte(tls, (bp /* &aWalHdr */), (uint32(WAL_MAGIC | SQLITE_BIGENDIAN))) + Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + 4), WAL_MAX_VERSION) + Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + 8), uint32(szPage)) + Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + 12), (*Wal)(unsafe.Pointer(pWal)).FnCkpt) if (*Wal)(unsafe.Pointer(pWal)).FnCkpt == U32(0) { Xsqlite3_randomness(tls, 8, pWal+72 /* &.hdr */ +32 /* &.aSalt */) } - libc.Xmemcpy(tls, (bp /* &aWalHdr */ + uintptr(16)), pWal+72 /* &.hdr */ +32 /* &.aSalt */, uint64(8)) - walChecksumBytes(tls, 1, bp /* &aWalHdr[0] */, (32 - (2 * 4)), uintptr(0), bp+32 /* &aCksum[0] */) - Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + uintptr(24)), *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */ + uintptr(0)*4))) - Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + uintptr(28)), *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */ + uintptr(1)*4))) + libc.Xmemcpy(tls, (bp /* &aWalHdr */ + 16), pWal+72 /* &.hdr */ +32 /* &.aSalt */, uint64(8)) + walChecksumBytes(tls, 1, bp /* &aWalHdr[0] */, (WAL_HDRSIZE - (2 * 4)), uintptr(0), bp+32 /* &aCksum[0] */) + Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + 24), *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */))) + Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + 28), *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */ + 1*4))) (*Wal)(unsafe.Pointer(pWal)).FszPage = U32(szPage) - (*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum = U8(0) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) = *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */ + uintptr(0)*4)) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) = *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */ + uintptr(1)*4)) + (*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum = SQLITE_BIGENDIAN + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) = *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) = *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */ + 1*4)) (*Wal)(unsafe.Pointer(pWal)).FtruncateOnCommit = U8(1) rc = Xsqlite3OsWrite(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp /* &aWalHdr[0] */, int32(unsafe.Sizeof([32]U8{})), int64(0)) - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -40133,8 +39571,8 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, (*WalWriter)(unsafe.Pointer(bp + 48 /* &w */)).FiSyncPoint = int64(0) (*WalWriter)(unsafe.Pointer(bp + 48 /* &w */)).FsyncFlags = sync_flags (*WalWriter)(unsafe.Pointer(bp + 48 /* &w */)).FszPage = szPage - iOffset = (int64(32) + ((I64((iFrame + U32(1)) - U32(1))) * (I64((szPage) + 24)))) - szFrame = (szPage + 24) + iOffset = (WAL_HDRSIZE + ((I64((iFrame + U32(1)) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) + szFrame = (szPage + WAL_FRAME_HDRSIZE) // Write all frames into the log file exactly once for p = pList; p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirty { @@ -40149,7 +39587,7 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, Xsqlite3WalFindFrame(tls, pWal, (*PgHdr)(unsafe.Pointer(p)).Fpgno, bp+40 /* &iWrite */) if *(*U32)(unsafe.Pointer(bp + 40 /* iWrite */)) >= iFirst { - var iOff I64 = ((int64(32) + ((I64((*(*U32)(unsafe.Pointer(bp + 40 /* iWrite */))) - U32(1))) * (I64((szPage) + 24)))) + int64(24)) + var iOff I64 = ((WAL_HDRSIZE + ((I64((*(*U32)(unsafe.Pointer(bp + 40 /* iWrite */))) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) + WAL_FRAME_HDRSIZE) var pData uintptr if ((*Wal)(unsafe.Pointer(pWal)).FiReCksum == U32(0)) || (*(*U32)(unsafe.Pointer(bp + 40 /* iWrite */)) < (*Wal)(unsafe.Pointer(pWal)).FiReCksum) { (*Wal)(unsafe.Pointer(pWal)).FiReCksum = *(*U32)(unsafe.Pointer(bp + 40 /* iWrite */)) @@ -40159,7 +39597,7 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, if rc != 0 { return rc } - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x040))) + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(PGHDR_WAL_APPEND))) continue } } @@ -40177,7 +39615,7 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, } pLast = p iOffset = iOffset + (I64(szFrame)) - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) |= U16((0x040)) + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) |= U16((PGHDR_WAL_APPEND)) } // Recalculate checksums within the wal file if required. @@ -40229,8 +39667,8 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, // journal size limit, if possible. if ((isCommit != 0) && ((*Wal)(unsafe.Pointer(pWal)).FtruncateOnCommit != 0)) && ((*Wal)(unsafe.Pointer(pWal)).FmxWalSize >= int64(0)) { var sz I64 = (*Wal)(unsafe.Pointer(pWal)).FmxWalSize - if (int64(32) + ((I64(((iFrame + U32(nExtra)) + U32(1)) - U32(1))) * (I64((szPage) + 24)))) > (*Wal)(unsafe.Pointer(pWal)).FmxWalSize { - sz = (int64(32) + ((I64(((iFrame + U32(nExtra)) + U32(1)) - U32(1))) * (I64((szPage) + 24)))) + if (WAL_HDRSIZE + ((I64(((iFrame + U32(nExtra)) + U32(1)) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) > (*Wal)(unsafe.Pointer(pWal)).FmxWalSize { + sz = (WAL_HDRSIZE + ((I64(((iFrame + U32(nExtra)) + U32(1)) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) } walLimitSize(tls, pWal, sz) (*Wal)(unsafe.Pointer(pWal)).FtruncateOnCommit = U8(0) @@ -40241,21 +39679,21 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, // guarantees that there are no other writers, and no data that may // be in use by existing readers is being overwritten. iFrame = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame - for p = pList; (p != 0) && (rc == 0); p = (*PgHdr)(unsafe.Pointer(p)).FpDirty { - if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & 0x040) == 0 { + for p = pList; (p != 0) && (rc == SQLITE_OK); p = (*PgHdr)(unsafe.Pointer(p)).FpDirty { + if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & PGHDR_WAL_APPEND) == 0 { continue } iFrame++ rc = walIndexAppend(tls, pWal, iFrame, (*PgHdr)(unsafe.Pointer(p)).Fpgno) } - for (rc == 0) && (nExtra > 0) { + for (rc == SQLITE_OK) && (nExtra > 0) { iFrame++ nExtra-- rc = walIndexAppend(tls, pWal, iFrame, (*PgHdr)(unsafe.Pointer(pLast)).Fpgno) } - if rc == 0 { + if rc == SQLITE_OK { // Update the private copy of the header. (*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage = (U16((szPage & 0xff00) | (szPage >> 16))) @@ -40295,7 +39733,7 @@ func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, // in the SQLITE_CHECKPOINT_PASSIVE mode. if (*Wal)(unsafe.Pointer(pWal)).FreadOnly != 0 { - return 8 + return SQLITE_READONLY } // Enable blocking locks, if possible. If blocking locks are successfully @@ -40308,9 +39746,9 @@ func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, // SQLITE_BUSY is returned. // EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured, // it will not be invoked in this case. - rc = walLockExclusive(tls, pWal, 1, 1) + rc = walLockExclusive(tls, pWal, WAL_CKPT_LOCK, 1) - if rc == 0 { + if rc == SQLITE_OK { (*Wal)(unsafe.Pointer(pWal)).FckptLock = U8(1) // IMPLEMENTATION-OF: R-59782-36818 The SQLITE_CHECKPOINT_FULL, RESTART and @@ -40321,20 +39759,20 @@ func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, // immediately, and a busy-handler is configured, it is invoked and the // writer lock retried until either the busy-handler returns 0 or the // lock is successfully obtained. - if eMode != 0 { - rc = walBusyLock(tls, pWal, xBusy2, pBusyArg, 0, 1) - if rc == 0 { + if eMode != SQLITE_CHECKPOINT_PASSIVE { + rc = walBusyLock(tls, pWal, xBusy2, pBusyArg, WAL_WRITE_LOCK, 1) + if rc == SQLITE_OK { (*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(1) - } else if rc == 5 { - eMode2 = 0 + } else if rc == SQLITE_BUSY { + eMode2 = SQLITE_CHECKPOINT_PASSIVE xBusy2 = uintptr(0) - rc = 0 + rc = SQLITE_OK } } } // Read the wal-index header. - if rc == 0 { + if rc == SQLITE_OK { rc = walIndexReadHdr(tls, pWal, bp /* &isChanged */) @@ -40344,7 +39782,7 @@ func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, } // Copy data from the log to the database file. - if rc == 0 { + if rc == SQLITE_OK { if ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame != 0) && (walPagesize(tls, pWal) != nBuf) { rc = Xsqlite3CorruptError(tls, 63222) @@ -40353,7 +39791,7 @@ func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, } // If no error occurred, set the output variables. - if (rc == 0) || (rc == 5) { + if (rc == SQLITE_OK) || (rc == SQLITE_BUSY) { if pnLog != 0 { *(*int32)(unsafe.Pointer(pnLog)) = int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) } @@ -40375,13 +39813,13 @@ func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, // Release the locks. Xsqlite3WalEndWriteTransaction(tls, pWal) if (*Wal)(unsafe.Pointer(pWal)).FckptLock != 0 { - walUnlockExclusive(tls, pWal, 1, 1) + walUnlockExclusive(tls, pWal, WAL_CKPT_LOCK, 1) (*Wal)(unsafe.Pointer(pWal)).FckptLock = U8(0) } return func() int32 { - if (rc == 0) && (eMode != eMode2) { - return 5 + if (rc == SQLITE_OK) && (eMode != eMode2) { + return SQLITE_BUSY } return rc }() @@ -40432,12 +39870,12 @@ func Xsqlite3WalExclusiveMode(tls *libc.TLS, pWal uintptr, op int32) int32 { /* // upgrade to exclusive-mode following such an error. if op == 0 { - if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != 0 { - (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(0) - if walLockShared(tls, pWal, (3+(int32((*Wal)(unsafe.Pointer(pWal)).FreadLock)))) != 0 { - (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(1) + if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != WAL_NORMAL_MODE { + (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = WAL_NORMAL_MODE + if walLockShared(tls, pWal, (3+(int32((*Wal)(unsafe.Pointer(pWal)).FreadLock)))) != SQLITE_OK { + (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = WAL_EXCLUSIVE_MODE } - rc = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == 0)) + rc = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_NORMAL_MODE)) } else { // Already in locking_mode=NORMAL rc = 0 @@ -40445,10 +39883,10 @@ func Xsqlite3WalExclusiveMode(tls *libc.TLS, pWal uintptr, op int32) int32 { /* } else if op > 0 { walUnlockShared(tls, pWal, (3 + (int32((*Wal)(unsafe.Pointer(pWal)).FreadLock)))) - (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(1) + (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = WAL_EXCLUSIVE_MODE rc = 1 } else { - rc = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == 0)) + rc = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_NORMAL_MODE)) } return rc } @@ -40457,23 +39895,23 @@ func Xsqlite3WalExclusiveMode(tls *libc.TLS, pWal uintptr, op int32) int32 { /* // heap-memory for the wal-index. Otherwise, if the argument is NULL or the // WAL module is using shared-memory, return false. func Xsqlite3WalHeapMemory(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3.c:63340:20: */ - return (libc.Bool32((pWal != 0) && (int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == 2))) + return (libc.Bool32((pWal != 0) && (int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_HEAPMEMORY_MODE))) } // Create a snapshot object. The content of a snapshot is opaque to // every other subsystem, so the WAL module can put whatever it needs // in the object. func Xsqlite3WalSnapshotGet(tls *libc.TLS, pWal uintptr, ppSnapshot uintptr) int32 { /* sqlite3.c:63349:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pRet uintptr - if libc.Xmemcmp(tls, ((pWal+72 /* &.hdr */ +24 /* &.aFrameCksum */)+uintptr(0)*4), uintptr(unsafe.Pointer(&aZero)), uint64(16)) == 0 { + if libc.Xmemcmp(tls, (pWal+72 /* &.hdr */ +24 /* &.aFrameCksum */), uintptr(unsafe.Pointer(&aZero)), uint64(16)) == 0 { *(*uintptr)(unsafe.Pointer(ppSnapshot)) = uintptr(0) - return 1 + return SQLITE_ERROR } pRet = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(WalIndexHdr{}))) if pRet == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemcpy(tls, pRet, (pWal + 72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) *(*uintptr)(unsafe.Pointer(ppSnapshot)) = pRet @@ -40497,10 +39935,10 @@ func Xsqlite3_snapshot_cmp(tls *libc.TLS, p1 uintptr, p2 uintptr) int32 { /* sql // aSalt[0] is a copy of the value stored in the wal file header. It // is incremented each time the wal file is restarted. - if *(*U32)(unsafe.Pointer((pHdr1 + 32 /* &.aSalt */) + uintptr(0)*4)) < *(*U32)(unsafe.Pointer((pHdr2 + 32 /* &.aSalt */) + uintptr(0)*4)) { + if *(*U32)(unsafe.Pointer((pHdr1 + 32 /* &.aSalt */))) < *(*U32)(unsafe.Pointer((pHdr2 + 32 /* &.aSalt */))) { return -1 } - if *(*U32)(unsafe.Pointer((pHdr1 + 32 /* &.aSalt */) + uintptr(0)*4)) > *(*U32)(unsafe.Pointer((pHdr2 + 32 /* &.aSalt */) + uintptr(0)*4)) { + if *(*U32)(unsafe.Pointer((pHdr1 + 32 /* &.aSalt */))) > *(*U32)(unsafe.Pointer((pHdr2 + 32 /* &.aSalt */))) { return +1 } if (*WalIndexHdr)(unsafe.Pointer(pHdr1)).FmxFrame < (*WalIndexHdr)(unsafe.Pointer(pHdr2)).FmxFrame { @@ -40523,13 +39961,13 @@ func Xsqlite3_snapshot_cmp(tls *libc.TLS, p1 uintptr, p2 uintptr) int32 { /* sql // lock is released before returning. func Xsqlite3WalSnapshotCheck(tls *libc.TLS, pWal uintptr, pSnapshot uintptr) int32 { /* sqlite3.c:63408:20: */ var rc int32 - rc = walLockShared(tls, pWal, 1) - if rc == 0 { + rc = walLockShared(tls, pWal, WAL_CKPT_LOCK) + if rc == SQLITE_OK { var pNew uintptr = pSnapshot if (libc.Xmemcmp(tls, pNew+32 /* &.aSalt */, pWal+72 /* &.hdr */ +32 /* &.aSalt */, uint64(unsafe.Sizeof([2]U32{}))) != 0) || ((*WalIndexHdr)(unsafe.Pointer(pNew)).FmxFrame < (*WalCkptInfo)(unsafe.Pointer(walCkptInfo(tls, pWal))).FnBackfillAttempted) { - rc = (1 | (int32(3) << 8)) - walUnlockShared(tls, pWal, 1) + rc = (SQLITE_ERROR | (int32(3) << 8)) + walUnlockShared(tls, pWal, WAL_CKPT_LOCK) } } return rc @@ -40539,7 +39977,7 @@ func Xsqlite3WalSnapshotCheck(tls *libc.TLS, pWal uintptr, pSnapshot uintptr) in // sqlite3WalSnapshotCheck(). func Xsqlite3WalSnapshotUnlock(tls *libc.TLS, pWal uintptr) { /* sqlite3.c:63427:21: */ - walUnlockShared(tls, pWal, 1) + walUnlockShared(tls, pWal, WAL_CKPT_LOCK) } // Return the sqlite3_file object for the WAL file @@ -41366,7 +40804,7 @@ func btreeLockCarefully(tls *libc.TLS, p uintptr) { /* sqlite3.c:64277:29: */ // In most cases, we should be able to acquire the lock we // want without having to go through the ascending lock // procedure that follows. Just be sure not to block. - if Xsqlite3_mutex_try(tls, (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).Fmutex) == 0 { + if Xsqlite3_mutex_try(tls, (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).Fmutex) == SQLITE_OK { (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).Fdb = (*Btree)(unsafe.Pointer(p)).Fdb (*Btree)(unsafe.Pointer(p)).Flocked = U8(1) return @@ -41520,7 +40958,7 @@ var sqlite3SharedCacheList uintptr = uintptr(0) /* sqlite3.c:64560:17 */ // sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2(). func Xsqlite3_enable_shared_cache(tls *libc.TLS, enable int32) int32 { /* sqlite3.c:64572:16: */ Xsqlite3Config.FsharedCacheEnabled = enable - return 0 + return SQLITE_OK } // Implementation of the SQLITE_CORRUPT_PAGE() macro. Takes a single @@ -41545,14 +40983,14 @@ func querySharedCacheTableLock(tls *libc.TLS, p uintptr, iTab Pgno, eLock U8) in // This routine is a no-op if the shared-cache is not enabled if !(int32((*Btree)(unsafe.Pointer(p)).Fsharable) != 0) { - return 0 + return SQLITE_OK } // If some other connection is holding an exclusive lock, the // requested lock may not be obtained. - if ((*BtShared)(unsafe.Pointer(pBt)).FpWriter != p) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0040) != 0) { + if ((*BtShared)(unsafe.Pointer(pBt)).FpWriter != p) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_EXCLUSIVE) != 0) { Xsqlite3ConnectionBlocked(tls, (*Btree)(unsafe.Pointer(p)).Fdb, (*Btree)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpWriter)).Fdb) - return (6 | (int32(1) << 8)) + return (SQLITE_LOCKED | (int32(1) << 8)) } for pIter = (*BtShared)(unsafe.Pointer(pBt)).FpLock; pIter != 0; pIter = (*BtLock)(unsafe.Pointer(pIter)).FpNext { @@ -41567,14 +41005,14 @@ func querySharedCacheTableLock(tls *libc.TLS, p uintptr, iTab Pgno, eLock U8) in if (((*BtLock)(unsafe.Pointer(pIter)).FpBtree != p) && ((*BtLock)(unsafe.Pointer(pIter)).FiTable == iTab)) && (int32((*BtLock)(unsafe.Pointer(pIter)).FeLock) != int32(eLock)) { Xsqlite3ConnectionBlocked(tls, (*Btree)(unsafe.Pointer(p)).Fdb, (*Btree)(unsafe.Pointer((*BtLock)(unsafe.Pointer(pIter)).FpBtree)).Fdb) - if int32(eLock) == 2 { + if int32(eLock) == WRITE_LOCK { - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0080)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_PENDING)) } - return (6 | (int32(1) << 8)) + return (SQLITE_LOCKED | (int32(1) << 8)) } } - return 0 + return SQLITE_OK } // Add a lock on the table with root-page iTable to the shared-btree used @@ -41618,7 +41056,7 @@ func setSharedCacheTableLock(tls *libc.TLS, p uintptr, iTable Pgno, eLock U8) in if !(pLock != 0) { pLock = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(BtLock{}))) if !(pLock != 0) { - return 7 + return SQLITE_NOMEM } (*BtLock)(unsafe.Pointer(pLock)).FiTable = iTable (*BtLock)(unsafe.Pointer(pLock)).FpBtree = p @@ -41634,7 +41072,7 @@ func setSharedCacheTableLock(tls *libc.TLS, p uintptr, iTable Pgno, eLock U8) in (*BtLock)(unsafe.Pointer(pLock)).FeLock = eLock } - return 0 + return SQLITE_OK } // Release all the table locks (locks obtained via calls to @@ -41663,7 +41101,7 @@ func clearAllSharedCacheTableLocks(tls *libc.TLS, p uintptr) { /* sqlite3.c:6489 if (*BtShared)(unsafe.Pointer(pBt)).FpWriter == p { (*BtShared)(unsafe.Pointer(pBt)).FpWriter = uintptr(0) - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32((0x0040 | 0x0080)))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32((BTS_EXCLUSIVE | BTS_PENDING)))) } else if (*BtShared)(unsafe.Pointer(pBt)).FnTransaction == 2 { // This function is called when Btree p is concluding its // transaction. If there currently exists a writer, and p is not @@ -41673,7 +41111,7 @@ func clearAllSharedCacheTableLocks(tls *libc.TLS, p uintptr) { /* sqlite3.c:6489 // // If there is not currently a writer, then BTS_PENDING must // be zero already. So this next line is harmless in that case. - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0080))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_PENDING))) } } @@ -41683,10 +41121,10 @@ func downgradeAllSharedCacheTableLocks(tls *libc.TLS, p uintptr) { /* sqlite3.c: if (*BtShared)(unsafe.Pointer(pBt)).FpWriter == p { var pLock uintptr (*BtShared)(unsafe.Pointer(pBt)).FpWriter = uintptr(0) - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32((0x0040 | 0x0080)))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32((BTS_EXCLUSIVE | BTS_PENDING)))) for pLock = (*BtShared)(unsafe.Pointer(pBt)).FpLock; pLock != 0; pLock = (*BtLock)(unsafe.Pointer(pLock)).FpNext { - (*BtLock)(unsafe.Pointer(pLock)).FeLock = U8(1) + (*BtLock)(unsafe.Pointer(pLock)).FeLock = READ_LOCK } } } @@ -41706,7 +41144,7 @@ func invalidateAllOverflowCache(tls *libc.TLS, pBt uintptr) { /* sqlite3.c:64993 var p uintptr for p = (*BtShared)(unsafe.Pointer(pBt)).FpCursor; p != 0; p = (*BtCursor)(unsafe.Pointer(p)).FpNext { - *(*U8)(unsafe.Pointer(p + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x04))) + *(*U8)(unsafe.Pointer(p + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_ValidOvfl))) } } @@ -41729,10 +41167,10 @@ func invalidateIncrblobCursors(tls *libc.TLS, pBtree uintptr, pgnoRoot Pgno, iRo (*Btree)(unsafe.Pointer(pBtree)).FhasIncrblobCur = U8(0) for p = (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBtree)).FpBt)).FpCursor; p != 0; p = (*BtCursor)(unsafe.Pointer(p)).FpNext { - if (int32((*BtCursor)(unsafe.Pointer(p)).FcurFlags) & 0x10) != 0 { + if (int32((*BtCursor)(unsafe.Pointer(p)).FcurFlags) & BTCF_Incrblob) != 0 { (*Btree)(unsafe.Pointer(pBtree)).FhasIncrblobCur = U8(1) if ((*BtCursor)(unsafe.Pointer(p)).FpgnoRoot == pgnoRoot) && ((isClearTable != 0) || ((*BtCursor)(unsafe.Pointer(p)).Finfo.FnKey == iRow)) { - (*BtCursor)(unsafe.Pointer(p)).FeState = U8(1) + (*BtCursor)(unsafe.Pointer(p)).FeState = CURSOR_INVALID } } } @@ -41772,15 +41210,15 @@ func invalidateIncrblobCursors(tls *libc.TLS, pBtree uintptr, pgnoRoot Pgno, iRo // set in BtShared.pHasContent. The contents of the bitvec are cleared // at the end of every transaction. func btreeSetHasContent(tls *libc.TLS, pBt uintptr, pgno Pgno) int32 { /* sqlite3.c:65075:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if !(int32((*BtShared)(unsafe.Pointer(pBt)).FpHasContent) != 0) { (*BtShared)(unsafe.Pointer(pBt)).FpHasContent = Xsqlite3BitvecCreate(tls, (*BtShared)(unsafe.Pointer(pBt)).FnPage) if !(int32((*BtShared)(unsafe.Pointer(pBt)).FpHasContent) != 0) { - rc = 7 + rc = SQLITE_NOMEM } } - if (rc == 0) && (pgno <= Xsqlite3BitvecSize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpHasContent)) { + if (rc == SQLITE_OK) && (pgno <= Xsqlite3BitvecSize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpHasContent)) { rc = Xsqlite3BitvecSet(tls, (*BtShared)(unsafe.Pointer(pBt)).FpHasContent, pgno) } return rc @@ -41827,7 +41265,7 @@ func btreeReleaseAllCursorPages(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:6511 // set to point to a malloced buffer pCur->nKey bytes in size containing // the key. func saveCursorKey(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:65138:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*BtCursor)(unsafe.Pointer(pCur)).FcurIntKey != 0 { // Only the rowid is required for a table btree @@ -41844,14 +41282,14 @@ func saveCursorKey(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:65138:12: * pKey = Xsqlite3Malloc(tls, (uint64(((*BtCursor)(unsafe.Pointer(pCur)).FnKey + int64(9)) + int64(8)))) if pKey != 0 { rc = Xsqlite3BtreePayload(tls, pCur, uint32(0), uint32(int32((*BtCursor)(unsafe.Pointer(pCur)).FnKey)), pKey) - if rc == 0 { + if rc == SQLITE_OK { libc.Xmemset(tls, ((pKey) + uintptr((*BtCursor)(unsafe.Pointer(pCur)).FnKey)), 0, (uint64(9 + 8))) (*BtCursor)(unsafe.Pointer(pCur)).FpKey = pKey } else { Xsqlite3_free(tls, pKey) } } else { - rc = 7 + rc = SQLITE_NOMEM } } @@ -41866,22 +41304,22 @@ func saveCursorKey(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:65138:12: * func saveCursorPosition(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:65180:12: */ var rc int32 - if (int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x40) != 0 { - return (19 | (int32(11) << 8)) + if (int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_Pinned) != 0 { + return (SQLITE_CONSTRAINT | (int32(11) << 8)) } - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 2 { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(0) + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_SKIPNEXT { + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_VALID } else { (*BtCursor)(unsafe.Pointer(pCur)).FskipNext = 0 } rc = saveCursorKey(tls, pCur) - if rc == 0 { + if rc == SQLITE_OK { btreeReleaseAllCursorPages(tls, pCur) - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(3) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_REQUIRESEEK } - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(((0x02 | 0x04) | 0x08)))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(((BTCF_ValidNKey | BTCF_ValidOvfl) | BTCF_AtLast)))) return rc } @@ -41916,9 +41354,9 @@ func saveAllCursors(tls *libc.TLS, pBt uintptr, iRoot Pgno, pExcept uintptr) int return saveCursorsOnList(tls, p, iRoot, pExcept) } if pExcept != 0 { - *(*U8)(unsafe.Pointer(pExcept + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x20))) + *(*U8)(unsafe.Pointer(pExcept + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_Multiple))) } - return 0 + return SQLITE_OK } // This helper routine to saveAllCursors does the actual work of saving @@ -41928,9 +41366,9 @@ func saveAllCursors(tls *libc.TLS, pBt uintptr, iRoot Pgno, pExcept uintptr) int func saveCursorsOnList(tls *libc.TLS, p uintptr, iRoot Pgno, pExcept uintptr) int32 { /* sqlite3.c:65247:28: */ for ok := true; ok; ok = p != 0 { if (p != pExcept) && ((Pgno(0) == iRoot) || ((*BtCursor)(unsafe.Pointer(p)).FpgnoRoot == iRoot)) { - if (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == 0) || (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == 2) { + if (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_VALID) || (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_SKIPNEXT) { var rc int32 = saveCursorPosition(tls, p) - if 0 != rc { + if SQLITE_OK != rc { return rc } } else { @@ -41940,7 +41378,7 @@ func saveCursorsOnList(tls *libc.TLS, p uintptr, iRoot Pgno, pExcept uintptr) in } p = (*BtCursor)(unsafe.Pointer(p)).FpNext } - return 0 + return SQLITE_OK } // Clear the current cursor position. @@ -41948,7 +41386,7 @@ func Xsqlite3BtreeClearCursor(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:65272: Xsqlite3_free(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpKey) (*BtCursor)(unsafe.Pointer(pCur)).FpKey = uintptr(0) - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID } // In this version of BtreeMoveto, pKey is a packed index record @@ -41968,7 +41406,7 @@ func btreeMoveto(tls *libc.TLS, pCur uintptr, pKey uintptr, nKey I64, bias int32 if !(pIdxKey == uintptr(0)) { goto __3 } - return 7 + return SQLITE_NOMEM __3: ; Xsqlite3VdbeRecordUnpack(tls, pKeyInfo, int32(nKey), pKey, pIdxKey) @@ -42007,24 +41445,24 @@ func btreeRestoreCursorPosition(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3. var rc int32 *(*int32)(unsafe.Pointer(bp /* skipNext */)) = 0 - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 4 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_FAULT { return (*BtCursor)(unsafe.Pointer(pCur)).FskipNext } - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID if Xsqlite3FaultSim(tls, 410) != 0 { - rc = 10 + rc = SQLITE_IOERR } else { rc = btreeMoveto(tls, pCur, (*BtCursor)(unsafe.Pointer(pCur)).FpKey, (*BtCursor)(unsafe.Pointer(pCur)).FnKey, 0, bp /* &skipNext */) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_free(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpKey) (*BtCursor)(unsafe.Pointer(pCur)).FpKey = uintptr(0) if *(*int32)(unsafe.Pointer(bp /* skipNext */)) != 0 { (*BtCursor)(unsafe.Pointer(pCur)).FskipNext = *(*int32)(unsafe.Pointer(bp /* skipNext */)) } - if ((*BtCursor)(unsafe.Pointer(pCur)).FskipNext != 0) && (int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 0) { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(2) + if ((*BtCursor)(unsafe.Pointer(pCur)).FskipNext != 0) && (int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID) { + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_SKIPNEXT } } return rc @@ -42042,7 +41480,7 @@ func btreeRestoreCursorPosition(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3. // back to where it ought to be if this routine returns true. func Xsqlite3BtreeCursorHasMoved(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:65365:20: */ - return (libc.Bool32(0 != int32(*(*U8)(unsafe.Pointer(pCur))))) + return (libc.Bool32(CURSOR_VALID != int32(*(*U8)(unsafe.Pointer(pCur))))) } // Return a pointer to a fake BtCursor object that will always answer @@ -42053,7 +41491,7 @@ func Xsqlite3BtreeFakeValidCursor(tls *libc.TLS) uintptr { /* sqlite3.c:65378:25 return uintptr(unsafe.Pointer(&fakeCursor)) } -var fakeCursor U8 = U8(0) /* sqlite3.c:65379:13 */ +var fakeCursor U8 = CURSOR_VALID /* sqlite3.c:65379:13 */ // This routine restores a cursor back to its original position after it // has been moved by some outside activity (such as a btree rebalance or @@ -42070,21 +41508,21 @@ func Xsqlite3BtreeCursorRestore(tls *libc.TLS, pCur uintptr, pDifferentRow uintp var rc int32 rc = func() int32 { - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= 3 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK { return btreeRestoreCursorPosition(tls, pCur) } - return 0 + return SQLITE_OK }() if rc != 0 { *(*int32)(unsafe.Pointer(pDifferentRow)) = 1 return rc } - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != 0 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { *(*int32)(unsafe.Pointer(pDifferentRow)) = 1 } else { *(*int32)(unsafe.Pointer(pDifferentRow)) = 0 } - return 0 + return SQLITE_OK } // Provide flag hints to the cursor. @@ -42154,14 +41592,14 @@ __2: ; iPtrmap = ptrmapPageno(tls, pBt, key) rc = Xsqlite3PagerGet(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, iPtrmap, bp /* &pDbPage */, 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __3 } *(*int32)(unsafe.Pointer(pRC)) = rc return __3: ; - if !(int32(*(*int8)(unsafe.Pointer((Xsqlite3PagerGetExtra(tls, *(*uintptr)(unsafe.Pointer(bp /* pDbPage */)))) + uintptr(0)))) != 0) { + if !(int32(*(*int8)(unsafe.Pointer((Xsqlite3PagerGetExtra(tls, *(*uintptr)(unsafe.Pointer(bp /* pDbPage */))))))) != 0) { goto __4 } // The first byte of the extra data is the MemPage.isInit byte. @@ -42187,7 +41625,7 @@ __5: } *(*int32)(unsafe.Pointer(pRC)) = libc.AssignInt32(&rc, Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp /* pDbPage */)))) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __7 } *(*U8)(unsafe.Pointer(pPtrmap + uintptr(offset))) = eType @@ -42239,7 +41677,7 @@ func ptrmapGet(tls *libc.TLS, pBt uintptr, key Pgno, pEType uintptr, pPgno uintp if (int32(*(*U8)(unsafe.Pointer(pEType))) < 1) || (int32(*(*U8)(unsafe.Pointer(pEType))) > 5) { return Xsqlite3CorruptError(tls, 65555) } - return 0 + return SQLITE_OK } // Given a btree page and a cell index (0 means the first cell on @@ -42295,7 +41733,7 @@ func btreeParseCellAdjustSizeForOverflow(tls *libc.TLS, pPage uintptr, pCell uin func btreeParseCellPtrNoPayload(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) { /* sqlite3.c:65632:13: */ _ = pPage - (*CellInfo)(unsafe.Pointer(pInfo)).FnSize = (U16(4 + int32(Xsqlite3GetVarint(tls, (pCell+uintptr(4)), (pInfo /* &.nKey */))))) + (*CellInfo)(unsafe.Pointer(pInfo)).FnSize = (U16(4 + int32(Xsqlite3GetVarint(tls, (pCell+4), (pInfo /* &.nKey */))))) (*CellInfo)(unsafe.Pointer(pInfo)).FnPayload = U32(0) (*CellInfo)(unsafe.Pointer(pInfo)).FnLocal = U16(0) (*CellInfo)(unsafe.Pointer(pInfo)).FpPayload = uintptr(0) @@ -42320,7 +41758,7 @@ func btreeParseCellPtr(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintpt // The code is inlined to avoid a function call. nPayload = U32(*(*U8)(unsafe.Pointer(pIter))) if nPayload >= U32(0x80) { - var pEnd uintptr = (pIter + uintptr(8)) + var pEnd uintptr = (pIter + 8) nPayload = nPayload & (U32(0x7f)) for ok := true; ok; ok = (((int32(*(*U8)(unsafe.Pointer(pIter)))) >= 0x80) && (pIter < pEnd)) { nPayload = ((nPayload << 7) | (U32(int32(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))) & 0x7f))) @@ -42335,7 +41773,7 @@ func btreeParseCellPtr(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintpt // The code is inlined to avoid a function call. *(*U64)(unsafe.Pointer(bp /* iKey */)) = U64(*(*U8)(unsafe.Pointer(pIter))) if *(*U64)(unsafe.Pointer(bp /* iKey */)) >= uint64(0x80) { - var pEnd uintptr = (pIter + uintptr(7)) + var pEnd uintptr = (pIter + 7) *(*U64)(unsafe.Pointer(bp /* iKey */)) &= uint64(0x7f) for 1 != 0 { *(*U64)(unsafe.Pointer(bp /* iKey */)) = ((*(*U64)(unsafe.Pointer(bp /* iKey */)) << 7) | (U64(int32(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))) & 0x7f))) @@ -42374,7 +41812,7 @@ func btreeParseCellPtrIndex(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo u pIter = (pCell + uintptr((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)) nPayload = U32(*(*U8)(unsafe.Pointer(pIter))) if nPayload >= U32(0x80) { - var pEnd uintptr = (pIter + uintptr(8)) + var pEnd uintptr = (pIter + 8) nPayload = nPayload & (U32(0x7f)) for ok := true; ok; ok = ((int32(*(*U8)(unsafe.Pointer(pIter))) >= 0x80) && (pIter < pEnd)) { nPayload = ((nPayload << 7) | (U32(int32(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))) & 0x7f))) @@ -42419,7 +41857,7 @@ func cellSizePtr(tls *libc.TLS, pPage uintptr, pCell uintptr) U16 { /* sqlite3.c nSize = U32(*(*U8)(unsafe.Pointer(pIter))) if nSize >= U32(0x80) { - pEnd = (pIter + uintptr(8)) + pEnd = (pIter + 8) nSize = nSize & (U32(0x7f)) for ok := true; ok; ok = ((int32(*(*U8)(unsafe.Pointer(pIter))) >= 0x80) && (pIter < pEnd)) { nSize = ((nSize << 7) | (U32(int32(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))) & 0x7f))) @@ -42430,7 +41868,7 @@ func cellSizePtr(tls *libc.TLS, pPage uintptr, pCell uintptr) U16 { /* sqlite3.c // pIter now points at the 64-bit integer key value, a variable length // integer. The following block moves pIter to point at the first byte // past the end of the key value. - pEnd = (pIter + uintptr(9)) + pEnd = (pIter + 9) for (((int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pIter, 1))))) & 0x80) != 0) && (pIter < pEnd) { } } @@ -42489,7 +41927,7 @@ func ptrmapPutOvflPtr(tls *libc.TLS, pPage uintptr, pSrc uintptr, pCell uintptr, return } ovfl = Xsqlite3Get4byte(tls, (pCell + uintptr((int32((*CellInfo)(unsafe.Pointer(bp /* &info */)).FnSize) - 4)))) - ptrmapPut(tls, (*MemPage)(unsafe.Pointer(pPage)).FpBt, ovfl, uint8(3), (*MemPage)(unsafe.Pointer(pPage)).Fpgno, pRC) + ptrmapPut(tls, (*MemPage)(unsafe.Pointer(pPage)).FpBt, ovfl, PTRMAP_OVERFLOW1, (*MemPage)(unsafe.Pointer(pPage)).Fpgno, pRC) } } @@ -42544,7 +41982,7 @@ func defragmentPage(tls *libc.TLS, pPage uintptr, nMaxFrag int32) int32 { /* sql if !(int32(*(*uint8)(unsafe.Pointer(data + uintptr((hdr + 7))))) <= nMaxFrag) { goto __1 } - iFree = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 1))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 1))) + uintptr(1))))) + iFree = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 1)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 1))) + 1)))) if !(iFree > (usableSize - 4)) { goto __2 } @@ -42554,7 +41992,7 @@ __2: if !(iFree != 0) { goto __3 } - iFree2 = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFree)) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFree)) + uintptr(1))))) + iFree2 = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFree))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFree)) + 1)))) if !(iFree2 > (usableSize - 4)) { goto __4 } @@ -42566,8 +42004,8 @@ __4: } pEnd = (data + uintptr((cellOffset + (nCell * 2)))) sz2 = 0 - sz = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree + 2))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree + 2))) + uintptr(1))))) - top = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))))) + sz = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree + 2)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree + 2))) + 1)))) + top = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)))) if !(top >= iFree) { goto __6 } @@ -42583,7 +42021,7 @@ __6: return Xsqlite3CorruptError(tls, 65941) __9: ; - sz2 = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree2 + 2))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree2 + 2))) + uintptr(1))))) + sz2 = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree2 + 2)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree2 + 2))) + 1)))) if !((iFree2 + sz2) > usableSize) { goto __10 } @@ -42611,19 +42049,19 @@ __12: if !(pAddr < pEnd) { goto __14 } - pc = ((int32(*(*U8)(unsafe.Pointer((pAddr) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((pAddr) + uintptr(1))))) + pc = ((int32(*(*U8)(unsafe.Pointer((pAddr)))) << 8) | int32(*(*U8)(unsafe.Pointer((pAddr) + 1)))) if !(pc < iFree) { goto __15 } - *(*U8)(unsafe.Pointer((pAddr) + uintptr(0))) = (U8((pc + sz) >> 8)) - *(*U8)(unsafe.Pointer((pAddr) + uintptr(1))) = (U8(pc + sz)) + *(*U8)(unsafe.Pointer((pAddr))) = (U8((pc + sz) >> 8)) + *(*U8)(unsafe.Pointer((pAddr) + 1)) = (U8(pc + sz)) goto __16 __15: if !(pc < iFree2) { goto __17 } - *(*U8)(unsafe.Pointer((pAddr) + uintptr(0))) = (U8((pc + sz2) >> 8)) - *(*U8)(unsafe.Pointer((pAddr) + uintptr(1))) = (U8(pc + sz2)) + *(*U8)(unsafe.Pointer((pAddr))) = (U8((pc + sz2) >> 8)) + *(*U8)(unsafe.Pointer((pAddr) + 1)) = (U8(pc + sz2)) __17: ; __16: @@ -42651,7 +42089,7 @@ __18: goto __20 } // The i-th cell pointer pAddr1 = (data + uintptr((cellOffset + (i * 2)))) - pc = ((int32(*(*U8)(unsafe.Pointer((pAddr1) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((pAddr1) + uintptr(1))))) + pc = ((int32(*(*U8)(unsafe.Pointer((pAddr1)))) << 8) | int32(*(*U8)(unsafe.Pointer((pAddr1) + 1)))) // These conditions have already been verified in btreeInitPage() // if PRAGMA cell_size_check=ON. @@ -42671,8 +42109,8 @@ __21: __22: ; - *(*U8)(unsafe.Pointer((pAddr1) + uintptr(0))) = (U8((cbrk) >> 8)) - *(*U8)(unsafe.Pointer((pAddr1) + uintptr(1))) = U8(cbrk) + *(*U8)(unsafe.Pointer((pAddr1))) = (U8((cbrk) >> 8)) + *(*U8)(unsafe.Pointer((pAddr1) + 1)) = U8(cbrk) if !(temp == uintptr(0)) { goto __23 } @@ -42683,7 +42121,7 @@ __22: __24: ; temp = Xsqlite3PagerTempSpace(tls, (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FpPager) - x = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))))) + x = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)))) libc.Xmemcpy(tls, (temp + uintptr(x)), (data + uintptr(x)), (uint64((cbrk + size) - x))) src = temp __23: @@ -42707,13 +42145,13 @@ defragment_out: __25: ; - *(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0))) = (U8((cbrk) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))) = U8(cbrk) + *(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))))) = (U8((cbrk) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)) = U8(cbrk) *(*uint8)(unsafe.Pointer(data + uintptr((hdr + 1)))) = uint8(0) *(*uint8)(unsafe.Pointer(data + uintptr((hdr + 2)))) = uint8(0) libc.Xmemset(tls, (data + uintptr(iCellFirst)), 0, (uint64(cbrk - iCellFirst))) - return 0 + return SQLITE_OK } // Search the free-list on page pPg for space to store a cell nByte bytes in @@ -42729,19 +42167,19 @@ __25: // will be ignored if adding the extra space to the fragmentation count // causes the fragmentation count to exceed 60. func pageFindSlot(tls *libc.TLS, pPg uintptr, nByte int32, pRc uintptr) uintptr { /* sqlite3.c:66027:11: */ - var hdr int32 = int32((*MemPage)(unsafe.Pointer(pPg)).FhdrOffset) // Offset to page header - var aData uintptr = (*MemPage)(unsafe.Pointer(pPg)).FaData // Page data - var iAddr int32 = (hdr + 1) // Address of ptr to pc - var pc int32 = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr(iAddr)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr(iAddr)) + uintptr(1))))) // Address of a free slot - var x int32 // Excess size of the slot - var maxPC int32 = (int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPg)).FpBt)).FusableSize - U32(nByte))) // Max address for a usable slot - var size int32 // Size of the free slot + var hdr int32 = int32((*MemPage)(unsafe.Pointer(pPg)).FhdrOffset) // Offset to page header + var aData uintptr = (*MemPage)(unsafe.Pointer(pPg)).FaData // Page data + var iAddr int32 = (hdr + 1) // Address of ptr to pc + var pc int32 = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr(iAddr))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr(iAddr)) + 1)))) // Address of a free slot + var x int32 // Excess size of the slot + var maxPC int32 = (int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPg)).FpBt)).FusableSize - U32(nByte))) // Max address for a usable slot + var size int32 // Size of the free slot for pc <= maxPC { // EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each // freeblock form a big-endian integer which is the size of the freeblock // in bytes, including the 4-byte header. - size = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))) + uintptr(1))))) + size = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr((pc + 2)))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))) + 1)))) if (libc.AssignInt32(&x, (size - nByte))) >= 0 { if x < 4 { @@ -42762,13 +42200,13 @@ func pageFindSlot(tls *libc.TLS, pPg uintptr, nByte int32, pRc uintptr) uintptr } else { // The slot remains on the free-list. Reduce its size to account // for the portion used by the new allocation. - *(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))) + uintptr(0))) = (U8((x) >> 8)) - *(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))) + uintptr(1))) = U8(x) + *(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))))) = (U8((x) >> 8)) + *(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))) + 1)) = U8(x) } return (aData + uintptr((pc + x))) } iAddr = pc - pc = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr(pc)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr(pc)) + uintptr(1))))) + pc = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr(pc))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr(pc)) + 1)))) if pc <= (iAddr + size) { if pc != 0 { // The next slot in the chain is not past the end of the current slot @@ -42802,7 +42240,7 @@ func allocateSpace(tls *libc.TLS, pPage uintptr, nByte int32, pIdx uintptr) int3 var hdr int32 = int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset) // Local cache of pPage->hdrOffset var data uintptr = (*MemPage)(unsafe.Pointer(pPage)).FaData // Local cache of pPage->aData var top int32 // First byte of cell content area - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 // Integer return code + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK // Integer return code var gap int32 // First byte of gap between cell pointers and cell content // Minimum cell size is 4 @@ -42814,7 +42252,7 @@ func allocateSpace(tls *libc.TLS, pPage uintptr, nByte int32, pIdx uintptr) int3 // then the cell content offset of an empty page wants to be 65536. // However, that integer is too large to be stored in a 2-byte unsigned // integer, so a value of 0 is used in its place. - top = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))))) + top = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)))) // by btreeComputeFreeSpace() if gap > top { if (top == 0) && ((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize == U32(65536)) { @@ -42837,7 +42275,7 @@ func allocateSpace(tls *libc.TLS, pPage uintptr, nByte int32, pIdx uintptr) int3 if g2 <= gap { return Xsqlite3CorruptError(tls, 66142) } else { - return 0 + return SQLITE_OK } } else if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -42858,7 +42296,7 @@ func allocateSpace(tls *libc.TLS, pPage uintptr, nByte int32, pIdx uintptr) int3 if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp /* rc */)) } - top = (((((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))))) - 1) & 0xffff) + 1) + top = (((((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)))) - 1) & 0xffff) + 1) } @@ -42868,11 +42306,11 @@ func allocateSpace(tls *libc.TLS, pPage uintptr, nByte int32, pIdx uintptr) int3 // is no way that the allocation can extend off the end of the page. // The assert() below verifies the previous sentence. top = top - (nByte) - *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0))) = (U8((top) >> 8)) - *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))) = U8(top) + *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))))) = (U8((top) >> 8)) + *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)) = U8(top) *(*int32)(unsafe.Pointer(pIdx)) = top - return 0 + return SQLITE_OK } // Return a section of the pPage->aData to the freelist. @@ -42905,7 +42343,7 @@ func freeSpace(tls *libc.TLS, pPage uintptr, iStart U16, iSize U16) int32 { /* s if (int32(*(*uint8)(unsafe.Pointer(data + uintptr((int32(iPtr) + 1))))) == 0) && (int32(*(*uint8)(unsafe.Pointer(data + uintptr(iPtr)))) == 0) { iFreeBlk = U16(0) // Shortcut for the case when the freelist is empty } else { - for (int32(libc.AssignUint16(&iFreeBlk, (U16((int32(*(*uint8)(unsafe.Pointer((data + uintptr(iPtr)) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr(iPtr)) + uintptr(1))))))))) < int32(iStart) { + for (int32(libc.AssignUint16(&iFreeBlk, (U16((int32(*(*uint8)(unsafe.Pointer((data + uintptr(iPtr))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr(iPtr)) + 1)))))))) < int32(iStart) { if int32(iFreeBlk) < (int32(iPtr) + 4) { if int32(iFreeBlk) == 0 { break @@ -42928,19 +42366,19 @@ func freeSpace(tls *libc.TLS, pPage uintptr, iStart U16, iSize U16) int32 { /* s if iEnd > U32(iFreeBlk) { return Xsqlite3CorruptError(tls, 66237) } - iEnd = (U32(int32(iFreeBlk) + ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iFreeBlk) + 2))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iFreeBlk) + 2))) + uintptr(1))))))) + iEnd = (U32(int32(iFreeBlk) + ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iFreeBlk) + 2)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iFreeBlk) + 2))) + 1)))))) if iEnd > (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize { return Xsqlite3CorruptError(tls, 66240) } iSize = (U16(iEnd - U32(iStart))) - iFreeBlk = (U16((int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFreeBlk)) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFreeBlk)) + uintptr(1)))))) + iFreeBlk = (U16((int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFreeBlk))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFreeBlk)) + 1))))) } // If iPtr is another freeblock (that is, if iPtr is not the freelist // pointer in the page header) then check to see if iStart should be // coalesced onto the end of iPtr. if int32(iPtr) > (int32(hdr) + 1) { - var iPtrEnd int32 = (int32(iPtr) + ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iPtr) + 2))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iPtr) + 2))) + uintptr(1)))))) + var iPtrEnd int32 = (int32(iPtr) + ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iPtr) + 2)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iPtr) + 2))) + 1))))) if (iPtrEnd + 3) >= int32(iStart) { if iPtrEnd > int32(iStart) { return Xsqlite3CorruptError(tls, 66253) @@ -42955,7 +42393,7 @@ func freeSpace(tls *libc.TLS, pPage uintptr, iStart U16, iSize U16) int32 { /* s } *(*uint8)(unsafe.Pointer(data + uintptr((int32(hdr) + 7)))) -= uint8((int32(nFrag))) } - x = (U16((int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(1)))))) + x = (U16((int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + 1))))) if int32(iStart) <= int32(x) { // The new freeblock is at the beginning of the cell content area, // so just extend the cell content area rather than create another @@ -42966,26 +42404,26 @@ func freeSpace(tls *libc.TLS, pPage uintptr, iStart U16, iSize U16) int32 { /* s if int32(iPtr) != (int32(hdr) + 1) { return Xsqlite3CorruptError(tls, 66268) } - *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))) + uintptr(0))) = (U8((int32(iFreeBlk)) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))) + uintptr(1))) = U8(iFreeBlk) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(0))) = (U8((iEnd) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(1))) = U8(iEnd) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))))) = (U8((int32(iFreeBlk)) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))) + 1)) = U8(iFreeBlk) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))))) = (U8((iEnd) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + 1)) = U8(iEnd) } else { // Insert the new freeblock into the freelist - *(*uint8)(unsafe.Pointer((data + uintptr(iPtr)) + uintptr(0))) = (U8((int32(iStart)) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr(iPtr)) + uintptr(1))) = U8(iStart) + *(*uint8)(unsafe.Pointer((data + uintptr(iPtr)))) = (U8((int32(iStart)) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr(iPtr)) + 1)) = U8(iStart) } - if (int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FbtsFlags) & 0x000c) != 0 { + if (int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FbtsFlags) & BTS_FAST_SECURE) != 0 { // Overwrite deleted information with zeros when the secure_delete // option is enabled libc.Xmemset(tls, (data + uintptr(iStart)), 0, uint64(iSize)) } - *(*uint8)(unsafe.Pointer((data + uintptr(iStart)) + uintptr(0))) = (U8((int32(iFreeBlk)) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr(iStart)) + uintptr(1))) = U8(iFreeBlk) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(iStart) + 2))) + uintptr(0))) = (U8((int32(iSize)) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(iStart) + 2))) + uintptr(1))) = U8(iSize) + *(*uint8)(unsafe.Pointer((data + uintptr(iStart)))) = (U8((int32(iFreeBlk)) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr(iStart)) + 1)) = U8(iFreeBlk) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(iStart) + 2))))) = (U8((int32(iSize)) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(iStart) + 2))) + 1)) = U8(iSize) *(*int32)(unsafe.Pointer(pPage + 20 /* &.nFree */)) += (int32(iOrigSize)) - return 0 + return SQLITE_OK } // Decode the flags byte (the first byte of the header) for a page @@ -43002,13 +42440,13 @@ func decodeFlags(tls *libc.TLS, pPage uintptr, flagByte int32) int32 { /* sqlite var pBt uintptr // A copy of pPage->pBt (*MemPage)(unsafe.Pointer(pPage)).Fleaf = (U8(flagByte >> 3)) - flagByte = flagByte & (^libc.Int32(0x08)) + flagByte = flagByte & (libc.CplInt32(PTF_LEAF)) (*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize = (U8(4 - (4 * int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf)))) (*MemPage)(unsafe.Pointer(pPage)).FxCellSize = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) U16 }{cellSizePtr})) pBt = (*MemPage)(unsafe.Pointer(pPage)).FpBt - if flagByte == (0x04 | 0x01) { + if flagByte == (PTF_LEAFDATA | PTF_INTKEY) { // EVIDENCE-OF: R-07291-35328 A value of 5 (0x05) means the page is an // interior table b-tree page. @@ -43032,7 +42470,7 @@ func decodeFlags(tls *libc.TLS, pPage uintptr, flagByte int32) int32 { /* sqlite } (*MemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*BtShared)(unsafe.Pointer(pBt)).FmaxLeaf (*MemPage)(unsafe.Pointer(pPage)).FminLocal = (*BtShared)(unsafe.Pointer(pBt)).FminLeaf - } else if flagByte == 0x02 { + } else if flagByte == PTF_ZERODATA { // EVIDENCE-OF: R-43316-37308 A value of 2 (0x02) means the page is an // interior index b-tree page. @@ -43052,7 +42490,7 @@ func decodeFlags(tls *libc.TLS, pPage uintptr, flagByte int32) int32 { /* sqlite return Xsqlite3CorruptError(tls, 66341) } (*MemPage)(unsafe.Pointer(pPage)).Fmax1bytePayload = (*BtShared)(unsafe.Pointer(pBt)).Fmax1bytePayload - return 0 + return SQLITE_OK } // Compute the amount of freespace on the page. In other words, fill @@ -43073,7 +42511,7 @@ func btreeComputeFreeSpace(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66 // EVIDENCE-OF: R-58015-48175 The two-byte integer at offset 5 designates // the start of the cell content area. A zero value for this integer is // interpreted as 65536. - top = (((((int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(1))))) - 1) & 0xffff) + 1) + top = (((((int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + 1)))) - 1) & 0xffff) + 1) iCellFirst = (((int32(hdr) + 8) + int32((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)) + (2 * int32((*MemPage)(unsafe.Pointer(pPage)).FnCell))) iCellLast = (usableSize - 4) @@ -43081,7 +42519,7 @@ func btreeComputeFreeSpace(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66 // EVIDENCE-OF: R-23588-34450 The two-byte integer at offset 1 gives the // start of the first freeblock on the page, or is zero if there are no // freeblocks. - pc = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))) + uintptr(1))))) + pc = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))) + 1)))) nFree = (int32(*(*U8)(unsafe.Pointer(data + uintptr((int32(hdr) + 7))))) + top) // Init nFree to non-freeblock free space if pc > 0 { var next U32 @@ -43096,8 +42534,8 @@ func btreeComputeFreeSpace(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66 // Freeblock off the end of the page return Xsqlite3CorruptError(tls, 66397) } - next = (U32((int32(*(*U8)(unsafe.Pointer((data + uintptr(pc)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr(pc)) + uintptr(1)))))) - size = (U32((int32(*(*U8)(unsafe.Pointer((data + uintptr((pc + 2))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((pc + 2))) + uintptr(1)))))) + next = (U32((int32(*(*U8)(unsafe.Pointer((data + uintptr(pc))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr(pc)) + 1))))) + size = (U32((int32(*(*U8)(unsafe.Pointer((data + uintptr((pc + 2)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((pc + 2))) + 1))))) nFree = (int32(U32(nFree) + size)) if next <= ((U32(pc) + size) + U32(3)) { break @@ -43124,7 +42562,7 @@ func btreeComputeFreeSpace(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66 return Xsqlite3CorruptError(tls, 66423) } (*MemPage)(unsafe.Pointer(pPage)).FnFree = int32((U16(nFree - iCellFirst))) - return 0 + return SQLITE_OK } // Do additional sanity check after btreeInitPage() if @@ -43159,7 +42597,7 @@ func btreeCellSizeCheck(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66433 return Xsqlite3CorruptError(tls, 66459) } } - return 0 + return SQLITE_OK } // Initialize the auxiliary information for a disk block. @@ -43177,7 +42615,7 @@ func btreeInitPage(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66474:12: data = ((*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)) // EVIDENCE-OF: R-28594-02890 The one-byte flag at offset 0 indicating // the b-tree page type. - if decodeFlags(tls, pPage, int32(*(*U8)(unsafe.Pointer(data + uintptr(0))))) != 0 { + if decodeFlags(tls, pPage, int32(*(*U8)(unsafe.Pointer(data)))) != 0 { return Xsqlite3CorruptError(tls, 66491) } @@ -43189,7 +42627,7 @@ func btreeInitPage(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66474:12: (*MemPage)(unsafe.Pointer(pPage)).FaDataOfst = ((*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)) // EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the // number of cells on the page. - (*MemPage)(unsafe.Pointer(pPage)).FnCell = (U16((int32(*(*U8)(unsafe.Pointer((data + uintptr(3)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr(3)) + uintptr(1)))))) + (*MemPage)(unsafe.Pointer(pPage)).FnCell = (U16((int32(*(*U8)(unsafe.Pointer((data + 3)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + 3) + 1))))) if U32((*MemPage)(unsafe.Pointer(pPage)).FnCell) > (((*BtShared)(unsafe.Pointer(pBt)).FpageSize - U32(8)) / U32(6)) { // To many cells for a single page. The page must be corrupt return Xsqlite3CorruptError(tls, 66505) @@ -43202,10 +42640,10 @@ func btreeInitPage(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66474:12: (*MemPage)(unsafe.Pointer(pPage)).FnFree = -1 // Indicate that this value is yet uncomputed (*MemPage)(unsafe.Pointer(pPage)).FisInit = U8(1) - if ((*Sqlite3)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags & uint64(0x00200000)) != 0 { + if ((*Sqlite3)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags & SQLITE_CellSizeCk) != 0 { return btreeCellSizeCheck(tls, pPage) } - return 0 + return SQLITE_OK } // Set up a raw page so that it looks like a database page holding @@ -43216,20 +42654,20 @@ func zeroPage(tls *libc.TLS, pPage uintptr, flags int32) { /* sqlite3.c:66527:13 var hdr U8 = (*MemPage)(unsafe.Pointer(pPage)).FhdrOffset var first U16 - if (int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x000c) != 0 { + if (int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_FAST_SECURE) != 0 { libc.Xmemset(tls, (data + uintptr(hdr)), 0, (uint64((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(hdr)))) } *(*uint8)(unsafe.Pointer(data + uintptr(hdr))) = uint8(int8(flags)) first = (U16(int32(hdr) + (func() int32 { - if (flags & 0x08) == 0 { + if (flags & PTF_LEAF) == 0 { return 12 } return 8 }()))) libc.Xmemset(tls, (data + uintptr((int32(hdr) + 1))), 0, uint64(4)) *(*uint8)(unsafe.Pointer(data + uintptr((int32(hdr) + 7)))) = uint8(0) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(0))) = (U8(((*BtShared)(unsafe.Pointer(pBt)).FusableSize) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(1))) = U8((*BtShared)(unsafe.Pointer(pBt)).FusableSize) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))))) = (U8(((*BtShared)(unsafe.Pointer(pBt)).FusableSize) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + 1)) = U8((*BtShared)(unsafe.Pointer(pBt)).FusableSize) (*MemPage)(unsafe.Pointer(pPage)).FnFree = int32((U16((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(first)))) decodeFlags(tls, pPage, flags) (*MemPage)(unsafe.Pointer(pPage)).FcellOffset = first @@ -43284,7 +42722,7 @@ func btreeGetPage(tls *libc.TLS, pBt uintptr, pgno Pgno, ppPage uintptr, flags i return rc } *(*uintptr)(unsafe.Pointer(ppPage)) = btreePageFromDbPage(tls, *(*uintptr)(unsafe.Pointer(bp /* pDbPage */)), pgno, pBt) - return 0 + return SQLITE_OK } // Retrieve a page from the pager cache. If the requested page is not @@ -43349,7 +42787,7 @@ __2: } btreePageFromDbPage(tls, *(*uintptr)(unsafe.Pointer(bp /* pDbPage */)), pgno, pBt) rc = btreeInitPage(tls, *(*uintptr)(unsafe.Pointer(ppPage))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } goto getAndInitPage_error2 @@ -43367,7 +42805,7 @@ __3: goto getAndInitPage_error2 __5: ; - return 0 + return SQLITE_OK getAndInitPage_error2: releasePage(tls, *(*uintptr)(unsafe.Pointer(ppPage))) @@ -43412,7 +42850,7 @@ func releasePageOne(tls *libc.TLS, pPage uintptr) { /* sqlite3.c:66716:13: */ // * Make sure the isInit flag is clear func btreeGetUnusedPage(tls *libc.TLS, pBt uintptr, pgno Pgno, ppPage uintptr, flags int32) int32 { /* sqlite3.c:66736:12: */ var rc int32 = btreeGetPage(tls, pBt, pgno, ppPage, flags) - if rc == 0 { + if rc == SQLITE_OK { if Xsqlite3PagerPageRefcount(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FpDbPage) > 1 { releasePage(tls, *(*uintptr)(unsafe.Pointer(ppPage))) *(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0) @@ -43506,11 +42944,11 @@ func Xsqlite3BtreeOpen(tls *libc.TLS, pVfs uintptr, zFilename uintptr, db uintpt var pFile uintptr pBt = uintptr(0) mutexOpen = uintptr(0) - rc = 0 - isTempDb = (libc.Bool32((zFilename == uintptr(0)) || (int32(*(*int8)(unsafe.Pointer(zFilename + uintptr(0)))) == 0))) + rc = SQLITE_OK + isTempDb = (libc.Bool32((zFilename == uintptr(0)) || (int32(*(*int8)(unsafe.Pointer(zFilename))) == 0))) isMemdb = (libc.Bool32((((zFilename != 0) && (libc.Xstrcmp(tls, zFilename, ts+2999 /* ":memory:" */) == 0)) || ((isTempDb != 0) && (Xsqlite3TempInMemory(tls, db) != 0))) || - ((vfsFlags & 0x00000080) != 0))) + ((vfsFlags & SQLITE_OPEN_MEMORY) != 0))) // flags fit in 8 bits @@ -43521,33 +42959,33 @@ func Xsqlite3BtreeOpen(tls *libc.TLS, pVfs uintptr, zFilename uintptr, db uintpt if !(isMemdb != 0) { goto __1 } - flags = flags | (2) + flags = flags | (BTREE_MEMORY) __1: ; - if !(((vfsFlags & 0x00000100) != 0) && ((isMemdb != 0) || (isTempDb != 0))) { + if !(((vfsFlags & SQLITE_OPEN_MAIN_DB) != 0) && ((isMemdb != 0) || (isTempDb != 0))) { goto __2 } - vfsFlags = ((vfsFlags & ^libc.Int32(0x00000100)) | 0x00000200) + vfsFlags = ((vfsFlags & libc.CplInt32(SQLITE_OPEN_MAIN_DB)) | SQLITE_OPEN_TEMP_DB) __2: ; p = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(Btree{}))) if !(!(p != 0)) { goto __3 } - return 7 + return SQLITE_NOMEM __3: ; - (*Btree)(unsafe.Pointer(p)).FinTrans = U8(0) + (*Btree)(unsafe.Pointer(p)).FinTrans = TRANS_NONE (*Btree)(unsafe.Pointer(p)).Fdb = db (*Btree)(unsafe.Pointer(p)).Flock.FpBtree = p (*Btree)(unsafe.Pointer(p)).Flock.FiTable = Pgno(1) // If this Btree is a candidate for shared cache, try to find an // existing BtShared object that we can share with - if !((isTempDb == 0) && ((isMemdb == 0) || ((vfsFlags & 0x00000040) != 0))) { + if !((isTempDb == 0) && ((isMemdb == 0) || ((vfsFlags & SQLITE_OPEN_URI) != 0))) { goto __4 } - if !((vfsFlags & 0x00020000) != 0) { + if !((vfsFlags & SQLITE_OPEN_SHAREDCACHE) != 0) { goto __5 } nFilename = (Xsqlite3Strlen30(tls, zFilename) + 1) @@ -43564,7 +43002,7 @@ __3: goto __6 } Xsqlite3_free(tls, p) - return 7 + return SQLITE_NOMEM __6: ; if !(isMemdb != 0) { @@ -43578,10 +43016,10 @@ __7: if !(rc != 0) { goto __9 } - if !(rc == (0 | (int32(2) << 8))) { + if !(rc == (SQLITE_OK | (int32(2) << 8))) { goto __10 } - rc = 0 + rc = SQLITE_OK goto __11 __10: Xsqlite3_free(tls, zFullPathname) @@ -43593,9 +43031,9 @@ __9: ; __8: ; - mutexOpen = Xsqlite3MutexAlloc(tls, 4) + mutexOpen = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_OPEN) Xsqlite3_mutex_enter(tls, mutexOpen) - mutexShared = Xsqlite3MutexAlloc(tls, 2) + mutexShared = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutexShared) pBt = sqlite3SharedCacheList __12: @@ -43620,7 +43058,7 @@ __16: Xsqlite3_mutex_leave(tls, mutexOpen) Xsqlite3_free(tls, zFullPathname) Xsqlite3_free(tls, p) - return 19 + return SQLITE_CONSTRAINT __19: ; goto __17 @@ -43659,20 +43097,20 @@ __4: if !(pBt == uintptr(0)) { goto __21 } - rc = 7 + rc = SQLITE_NOMEM goto btree_open_out __21: ; rc = Xsqlite3PagerOpen(tls, pVfs, (pBt /* &.pPager */), zFilename, int32(unsafe.Sizeof(MemPage{})), flags, vfsFlags, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{pageReinit}))) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __22 } Xsqlite3PagerSetMmapLimit(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, (*Sqlite3)(unsafe.Pointer(db)).FszMmap) rc = Xsqlite3PagerReadFileheader(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, int32(unsafe.Sizeof([100]uint8{})), bp /* &zDbHeader[0] */) __22: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __23 } goto btree_open_out @@ -43690,14 +43128,14 @@ __23: if !(Xsqlite3PagerIsreadonly(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) != 0) { goto __24 } - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0001)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_READ_ONLY)) __24: ; // EVIDENCE-OF: R-51873-39618 The page size for a database file is // determined by the 2-byte integer located at an offset of 16 bytes from // the beginning of the database file. - (*BtShared)(unsafe.Pointer(pBt)).FpageSize = (U32((int32(*(*uint8)(unsafe.Pointer(bp /* &zDbHeader[0] */ + uintptr(16)))) << 8) | (int32(*(*uint8)(unsafe.Pointer(bp /* &zDbHeader[0] */ + uintptr(17)))) << 16))) - if !((((*BtShared)(unsafe.Pointer(pBt)).FpageSize < U32(512)) || ((*BtShared)(unsafe.Pointer(pBt)).FpageSize > U32(65536))) || + (*BtShared)(unsafe.Pointer(pBt)).FpageSize = (U32((int32(*(*uint8)(unsafe.Pointer(bp /* &zDbHeader[0] */ + 16))) << 8) | (int32(*(*uint8)(unsafe.Pointer(bp /* &zDbHeader[0] */ + 17))) << 16))) + if !((((*BtShared)(unsafe.Pointer(pBt)).FpageSize < U32(512)) || ((*BtShared)(unsafe.Pointer(pBt)).FpageSize > SQLITE_MAX_PAGE_SIZE)) || ((((*BtShared)(unsafe.Pointer(pBt)).FpageSize - U32(1)) & (*BtShared)(unsafe.Pointer(pBt)).FpageSize) != U32(0))) { goto __25 } @@ -43717,7 +43155,7 @@ __24: return uint8(0) }() (*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = func() uint8 { - if 0 == 2 { + if SQLITE_DEFAULT_AUTOVACUUM == 2 { return uint8(1) } return uint8(0) @@ -43730,16 +43168,16 @@ __25: // EVIDENCE-OF: R-37497-42412 The size of the reserved region is // determined by the one-byte unsigned integer found at an offset of 20 // into the database file header. - nReserve = *(*uint8)(unsafe.Pointer(bp /* &zDbHeader[0] */ + uintptr(20))) - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0002)) + nReserve = *(*uint8)(unsafe.Pointer(bp /* &zDbHeader[0] */ + 20)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_PAGESIZE_FIXED)) (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum = func() uint8 { - if Xsqlite3Get4byte(tls, (bp /* &zDbHeader */ +uintptr((36+(4*4))))) != 0 { + if Xsqlite3Get4byte(tls, (bp /* &zDbHeader */ +52)) != 0 { return uint8(1) } return uint8(0) }() (*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = func() uint8 { - if Xsqlite3Get4byte(tls, (bp /* &zDbHeader */ +uintptr((36+(7*4))))) != 0 { + if Xsqlite3Get4byte(tls, (bp /* &zDbHeader */ +64)) != 0 { return uint8(1) } return uint8(0) @@ -43761,15 +43199,15 @@ __28: if !((*Btree)(unsafe.Pointer(p)).Fsharable != 0) { goto __29 } - mutexShared1 = Xsqlite3MutexAlloc(tls, 2) + mutexShared1 = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) if !((1 != 0) && (Xsqlite3Config.FbCoreMutex != 0)) { goto __30 } - (*BtShared)(unsafe.Pointer(pBt)).Fmutex = Xsqlite3MutexAlloc(tls, 0) + (*BtShared)(unsafe.Pointer(pBt)).Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_FAST) if !((*BtShared)(unsafe.Pointer(pBt)).Fmutex == uintptr(0)) { goto __31 } - rc = 7 + rc = SQLITE_NOMEM goto btree_open_out __31: ; @@ -43848,7 +43286,7 @@ __32: *(*uintptr)(unsafe.Pointer(ppBtree)) = p btree_open_out: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __44 } if !((pBt != 0) && ((*BtShared)(unsafe.Pointer(pBt)).FpPager != 0)) { @@ -43877,7 +43315,7 @@ __47: if !((*Sqlite3_file)(unsafe.Pointer(pFile)).FpMethods != 0) { goto __48 } - Xsqlite3OsFileControlHint(tls, pFile, 30, (pBt + 8 /* &.db */)) + Xsqlite3OsFileControlHint(tls, pFile, SQLITE_FCNTL_PDB, (pBt + 8 /* &.db */)) __48: ; __45: @@ -43902,7 +43340,7 @@ func removeFromSharingList(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:6711 var pList uintptr var removed int32 = 0 - pMainMtx = Xsqlite3MutexAlloc(tls, 2) + pMainMtx = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, pMainMtx) (*BtShared)(unsafe.Pointer(pBt)).FnRef-- if (*BtShared)(unsafe.Pointer(pBt)).FnRef <= 0 { @@ -43983,7 +43421,7 @@ func Xsqlite3BtreeClose(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:67192:20: // Rollback any active transaction and free the handle structure. // The call to sqlite3BtreeRollback() drops any table-locks held by // this handle. - Xsqlite3BtreeRollback(tls, p, 0, 0) + Xsqlite3BtreeRollback(tls, p, SQLITE_OK, 0) Xsqlite3BtreeLeave(tls, p) // If there are still other outstanding references to the shared-btree @@ -44013,7 +43451,7 @@ func Xsqlite3BtreeClose(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:67192:20: } Xsqlite3_free(tls, p) - return 0 + return SQLITE_OK } // Change the "soft" limit on the number of pages in the cache. @@ -44027,7 +43465,7 @@ func Xsqlite3BtreeSetCacheSize(tls *libc.TLS, p uintptr, mxPage int32) int32 { / Xsqlite3BtreeEnter(tls, p) Xsqlite3PagerSetCachesize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, mxPage) Xsqlite3BtreeLeave(tls, p) - return 0 + return SQLITE_OK } // Change the "spill" limit on the number of pages in the cache. @@ -44056,7 +43494,7 @@ func Xsqlite3BtreeSetMmapLimit(tls *libc.TLS, p uintptr, szMmap Sqlite3_int64) i Xsqlite3BtreeEnter(tls, p) Xsqlite3PagerSetMmapLimit(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, szMmap) Xsqlite3BtreeLeave(tls, p) - return 0 + return SQLITE_OK } // Change the way data is synced to disk in order to increase or decrease @@ -44071,7 +43509,7 @@ func Xsqlite3BtreeSetPagerFlags(tls *libc.TLS, p uintptr, pgFlags uint32) int32 Xsqlite3BtreeEnter(tls, p) Xsqlite3PagerSetFlags(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, pgFlags) Xsqlite3BtreeLeave(tls, p) - return 0 + return SQLITE_OK } // Change the default pages size and the number of reserved bytes per page. @@ -44093,7 +43531,7 @@ func Xsqlite3BtreeSetPagerFlags(tls *libc.TLS, p uintptr, pgFlags uint32) int32 // If the iFix!=0 then the BTS_PAGESIZE_FIXED flag is set so that the page size // and autovacuum mode can no longer be changed. func Xsqlite3BtreeSetPageSize(tls *libc.TLS, p uintptr, pageSize int32, nReserve int32, iFix int32) int32 { /* sqlite3.c:67340:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var x int32 var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt @@ -44103,12 +43541,12 @@ func Xsqlite3BtreeSetPageSize(tls *libc.TLS, p uintptr, pageSize int32, nReserve if nReserve < x { nReserve = x } - if (int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0002) != 0 { + if (int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_PAGESIZE_FIXED) != 0 { Xsqlite3BtreeLeave(tls, p) - return 8 + return SQLITE_READONLY } - if ((pageSize >= 512) && (pageSize <= 65536)) && (((pageSize - 1) & pageSize) == 0) { + if ((pageSize >= 512) && (pageSize <= SQLITE_MAX_PAGE_SIZE)) && (((pageSize - 1) & pageSize) == 0) { (*BtShared)(unsafe.Pointer(pBt)).FpageSize = U32(pageSize) freeTempSpace(tls, pBt) @@ -44116,7 +43554,7 @@ func Xsqlite3BtreeSetPageSize(tls *libc.TLS, p uintptr, pageSize int32, nReserve rc = Xsqlite3PagerSetPagesize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, (pBt + 52 /* &.pageSize */), nReserve) (*BtShared)(unsafe.Pointer(pBt)).FusableSize = ((*BtShared)(unsafe.Pointer(pBt)).FpageSize - U32(U16(nReserve))) if iFix != 0 { - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0002)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_PAGESIZE_FIXED)) } Xsqlite3BtreeLeave(tls, p) return rc @@ -44198,10 +43636,10 @@ func Xsqlite3BtreeSecureDelete(tls *libc.TLS, p uintptr, newFlag int32) int32 { Xsqlite3BtreeEnter(tls, p) if newFlag >= 0 { - *(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x000c))) - *(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt + 40 /* &.btsFlags */)) |= U16((0x0004 * newFlag)) + *(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_FAST_SECURE))) + *(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt + 40 /* &.btsFlags */)) |= U16((BTS_SECURE_DELETE * newFlag)) } - b = ((int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FbtsFlags) & 0x000c) / 0x0004) + b = ((int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FbtsFlags) & BTS_FAST_SECURE) / BTS_SECURE_DELETE) Xsqlite3BtreeLeave(tls, p) return b } @@ -44212,17 +43650,17 @@ func Xsqlite3BtreeSecureDelete(tls *libc.TLS, p uintptr, newFlag int32) int32 { // determined by the SQLITE_DEFAULT_AUTOVACUUM macro. func Xsqlite3BtreeSetAutoVacuum(tls *libc.TLS, p uintptr, autoVacuum int32) int32 { /* sqlite3.c:67464:20: */ var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt - var rc int32 = 0 + var rc int32 = SQLITE_OK var av U8 = U8(autoVacuum) Xsqlite3BtreeEnter(tls, p) - if ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0002) != 0) && ((func() int32 { + if ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_PAGESIZE_FIXED) != 0) && ((func() int32 { if av != 0 { return 1 } return 0 }()) != int32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum)) { - rc = 8 + rc = SQLITE_READONLY } else { (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum = func() uint8 { if av != 0 { @@ -44248,13 +43686,13 @@ func Xsqlite3BtreeGetAutoVacuum(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:6 Xsqlite3BtreeEnter(tls, p) rc = func() int32 { if !(int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FautoVacuum) != 0) { - return 0 + return BTREE_AUTOVACUUM_NONE } return func() int32 { if !(int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FincrVacuum) != 0) { - return 1 + return BTREE_AUTOVACUUM_FULL } - return 2 + return BTREE_AUTOVACUUM_INCR }() }() Xsqlite3BtreeLeave(tls, p) @@ -44288,14 +43726,14 @@ func lockBtree(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:67544:12: */ *(*U32)(unsafe.Pointer(bp + 8 /* nPageFile */)) = U32(0) // Number of pages in the database according to hdr rc = Xsqlite3PagerSharedLock(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __1 } return rc __1: ; rc = btreeGetPage(tls, pBt, uint32(1), bp /* &pPage1 */, 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __2 } return rc @@ -44312,7 +43750,7 @@ __2: nPage = *(*U32)(unsafe.Pointer(bp + 8 /* nPageFile */)) __3: ; - if !(((*Sqlite3)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags & uint64(0x02000000)) != uint64(0)) { + if !(((*Sqlite3)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags & SQLITE_ResetDatabase) != uint64(0)) { goto __4 } nPage = U32(0) @@ -44322,7 +43760,7 @@ __4: goto __5 } page1 = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage1 */)))).FaData - rc = 26 + rc = SQLITE_NOTADB // EVIDENCE-OF: R-43737-39999 Every valid SQLite database file begins // with the following 16 bytes (in hex): 53 51 4c 69 74 65 20 66 6f 72 6d // 61 74 20 33 00. @@ -44333,13 +43771,13 @@ __4: __6: ; - if !(int32(*(*U8)(unsafe.Pointer(page1 + uintptr(18)))) > 2) { + if !(int32(*(*U8)(unsafe.Pointer(page1 + 18))) > 2) { goto __7 } - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0001)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_READ_ONLY)) __7: ; - if !(int32(*(*U8)(unsafe.Pointer(page1 + uintptr(19)))) > 2) { + if !(int32(*(*U8)(unsafe.Pointer(page1 + 19))) > 2) { goto __8 } goto page1_init_failed @@ -44353,12 +43791,12 @@ __8: // required as the version of page 1 currently in the page1 buffer // may not be the latest version - there may be a newer one in the log // file. - if !((int32(*(*U8)(unsafe.Pointer(page1 + uintptr(19)))) == 2) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0020) == 0)) { + if !((int32(*(*U8)(unsafe.Pointer(page1 + 19))) == 2) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_NO_WAL) == 0)) { goto __9 } *(*int32)(unsafe.Pointer(bp + 12 /* isOpen */)) = 0 rc = Xsqlite3PagerOpenWal(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, bp+12 /* &isOpen */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __11 } goto page1_init_failed @@ -44369,12 +43807,12 @@ __11: goto __13 } releasePageOne(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage1 */))) - return 0 + return SQLITE_OK __13: ; __12: ; - rc = 26 + rc = SQLITE_NOTADB goto __10 __9: ; @@ -44386,7 +43824,7 @@ __10: // // The original design allowed these amounts to vary, but as of // version 3.6.0, we require them to be fixed. - if !(libc.Xmemcmp(tls, (page1+uintptr(21)), ts+3008 /* "@ " */, uint64(3)) != 0) { + if !(libc.Xmemcmp(tls, (page1+21), ts+3008 /* "@ " */, uint64(3)) != 0) { goto __14 } goto page1_init_failed @@ -44395,18 +43833,18 @@ __14: // EVIDENCE-OF: R-51873-39618 The page size for a database file is // determined by the 2-byte integer located at an offset of 16 bytes from // the beginning of the database file. - pageSize = (U32((int32(*(*U8)(unsafe.Pointer(page1 + uintptr(16)))) << 8) | (int32(*(*U8)(unsafe.Pointer(page1 + uintptr(17)))) << 16))) + pageSize = (U32((int32(*(*U8)(unsafe.Pointer(page1 + 16))) << 8) | (int32(*(*U8)(unsafe.Pointer(page1 + 17))) << 16))) // EVIDENCE-OF: R-25008-21688 The size of a page is a power of two // between 512 and 65536 inclusive. if !(((((pageSize - U32(1)) & pageSize) != U32(0)) || - (pageSize > U32(65536))) || + (pageSize > SQLITE_MAX_PAGE_SIZE)) || (pageSize <= U32(256))) { goto __15 } goto page1_init_failed __15: ; - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0002)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_PAGESIZE_FIXED)) // EVIDENCE-OF: R-59310-51205 The "reserved space" size in the 1-byte // integer at offset 20 is the number of bytes of space at the end of @@ -44415,7 +43853,7 @@ __15: // EVIDENCE-OF: R-37497-42412 The size of the reserved region is // determined by the one-byte unsigned integer found at an offset of 20 // into the database file header. - usableSize = (pageSize - U32(*(*U8)(unsafe.Pointer(page1 + uintptr(20))))) + usableSize = (pageSize - U32(*(*U8)(unsafe.Pointer(page1 + 20)))) if !(pageSize != (*BtShared)(unsafe.Pointer(pBt)).FpageSize) { goto __16 } @@ -44452,13 +43890,13 @@ __18: (*BtShared)(unsafe.Pointer(pBt)).FpageSize = pageSize (*BtShared)(unsafe.Pointer(pBt)).FusableSize = usableSize (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum = func() uint8 { - if Xsqlite3Get4byte(tls, (page1+uintptr((36+(4*4))))) != 0 { + if Xsqlite3Get4byte(tls, (page1+52)) != 0 { return uint8(1) } return uint8(0) }() (*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = func() uint8 { - if Xsqlite3Get4byte(tls, (page1+uintptr((36+(7*4))))) != 0 { + if Xsqlite3Get4byte(tls, (page1+64)) != 0 { return uint8(1) } return uint8(0) @@ -44494,7 +43932,7 @@ __20: (*BtShared)(unsafe.Pointer(pBt)).FpPage1 = *(*uintptr)(unsafe.Pointer(bp /* pPage1 */)) (*BtShared)(unsafe.Pointer(pBt)).FnPage = nPage - return 0 + return SQLITE_OK page1_init_failed: releasePageOne(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage1 */))) @@ -44510,7 +43948,7 @@ page1_init_failed: // If there is a transaction in progress, this routine is a no-op. func unlockBtreeIfUnused(tls *libc.TLS, pBt uintptr) { /* sqlite3.c:67751:13: */ - if (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == 0) && ((*BtShared)(unsafe.Pointer(pBt)).FpPage1 != uintptr(0)) { + if (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_NONE) && ((*BtShared)(unsafe.Pointer(pBt)).FpPage1 != uintptr(0)) { var pPage1 uintptr = (*BtShared)(unsafe.Pointer(pBt)).FpPage1 (*BtShared)(unsafe.Pointer(pBt)).FpPage1 = uintptr(0) @@ -44527,7 +43965,7 @@ func newDatabase(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:67768:12: */ var rc int32 if (*BtShared)(unsafe.Pointer(pBt)).FnPage > U32(0) { - return 0 + return SQLITE_OK } pP1 = (*BtShared)(unsafe.Pointer(pBt)).FpPage1 @@ -44538,24 +43976,24 @@ func newDatabase(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:67768:12: */ } libc.Xmemcpy(tls, data, uintptr(unsafe.Pointer(&zMagicHeader)), uint64(unsafe.Sizeof(zMagicHeader))) - *(*uint8)(unsafe.Pointer(data + uintptr(16))) = (U8(((*BtShared)(unsafe.Pointer(pBt)).FpageSize >> 8) & U32(0xff))) - *(*uint8)(unsafe.Pointer(data + uintptr(17))) = (U8(((*BtShared)(unsafe.Pointer(pBt)).FpageSize >> 16) & U32(0xff))) - *(*uint8)(unsafe.Pointer(data + uintptr(18))) = uint8(1) - *(*uint8)(unsafe.Pointer(data + uintptr(19))) = uint8(1) + *(*uint8)(unsafe.Pointer(data + 16)) = (U8(((*BtShared)(unsafe.Pointer(pBt)).FpageSize >> 8) & U32(0xff))) + *(*uint8)(unsafe.Pointer(data + 17)) = (U8(((*BtShared)(unsafe.Pointer(pBt)).FpageSize >> 16) & U32(0xff))) + *(*uint8)(unsafe.Pointer(data + 18)) = uint8(1) + *(*uint8)(unsafe.Pointer(data + 19)) = uint8(1) - *(*uint8)(unsafe.Pointer(data + uintptr(20))) = (U8((*BtShared)(unsafe.Pointer(pBt)).FpageSize - (*BtShared)(unsafe.Pointer(pBt)).FusableSize)) - *(*uint8)(unsafe.Pointer(data + uintptr(21))) = uint8(64) - *(*uint8)(unsafe.Pointer(data + uintptr(22))) = uint8(32) - *(*uint8)(unsafe.Pointer(data + uintptr(23))) = uint8(32) - libc.Xmemset(tls, (data + uintptr(24)), 0, (uint64(100 - 24))) - zeroPage(tls, pP1, ((0x01 | 0x08) | 0x04)) - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0002)) + *(*uint8)(unsafe.Pointer(data + 20)) = (U8((*BtShared)(unsafe.Pointer(pBt)).FpageSize - (*BtShared)(unsafe.Pointer(pBt)).FusableSize)) + *(*uint8)(unsafe.Pointer(data + 21)) = uint8(64) + *(*uint8)(unsafe.Pointer(data + 22)) = uint8(32) + *(*uint8)(unsafe.Pointer(data + 23)) = uint8(32) + libc.Xmemset(tls, (data + 24), 0, (uint64(100 - 24))) + zeroPage(tls, pP1, ((PTF_INTKEY | PTF_LEAF) | PTF_LEAFDATA)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_PAGESIZE_FIXED)) - Xsqlite3Put4byte(tls, (data + uintptr((36 + (4 * 4)))), uint32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum)) - Xsqlite3Put4byte(tls, (data + uintptr((36 + (7 * 4)))), uint32((*BtShared)(unsafe.Pointer(pBt)).FincrVacuum)) + Xsqlite3Put4byte(tls, (data + 52), uint32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum)) + Xsqlite3Put4byte(tls, (data + 64), uint32((*BtShared)(unsafe.Pointer(pBt)).FincrVacuum)) (*BtShared)(unsafe.Pointer(pBt)).FnPage = U32(1) - *(*uint8)(unsafe.Pointer(data + uintptr(31))) = uint8(1) - return 0 + *(*uint8)(unsafe.Pointer(data + 31)) = uint8(1) + return SQLITE_OK } // Initialize the first page of the database file (creating a database @@ -44612,33 +44050,33 @@ func Xsqlite3BtreeBeginTrans(tls *libc.TLS, p uintptr, wrflag int32, pSchemaVers var pPage1 uintptr pBt = (*Btree)(unsafe.Pointer(p)).FpBt pPager = (*BtShared)(unsafe.Pointer(pBt)).FpPager - rc = 0 + rc = SQLITE_OK Xsqlite3BtreeEnter(tls, p) // If the btree is already in a write-transaction, or it // is already in a read-transaction and a read-transaction // is requested, this is a no-op. - if !((int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 2) || ((int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 1) && !(wrflag != 0))) { + if !((int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE) || ((int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_READ) && !(wrflag != 0))) { goto __1 } goto trans_begun __1: ; - if !((((*Sqlite3)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).Fdb)).Fflags & uint64(0x02000000)) != 0) && + if !((((*Sqlite3)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).Fdb)).Fflags & SQLITE_ResetDatabase) != 0) && (int32(Xsqlite3PagerIsreadonly(tls, pPager)) == 0)) { goto __2 } - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0001))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_READ_ONLY))) __2: ; // Write transactions are not possible on a read-only database - if !(((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0001) != 0) && (wrflag != 0)) { + if !(((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_READ_ONLY) != 0) && (wrflag != 0)) { goto __3 } - rc = 8 + rc = SQLITE_READONLY goto trans_begun __3: ; @@ -44647,8 +44085,8 @@ __3: // If another database handle has already opened a write transaction // on this shared-btree structure and a second write transaction is // requested, return SQLITE_LOCKED. - if !(((wrflag != 0) && (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == 2)) || - ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0080) != 0)) { + if !(((wrflag != 0) && (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_WRITE)) || + ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_PENDING) != 0)) { goto __4 } pBlock = (*Btree)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpWriter)).Fdb @@ -44684,7 +44122,7 @@ __5: goto __11 } Xsqlite3ConnectionBlocked(tls, (*Btree)(unsafe.Pointer(p)).Fdb, pBlock) - rc = (6 | (int32(1) << 8)) + rc = (SQLITE_LOCKED | (int32(1) << 8)) goto trans_begun __11: ; @@ -44692,19 +44130,19 @@ __11: // Any read-only or read-write transaction implies a read-lock on // page 1. So if some other shared-cache client already has a write-lock // on page 1, the transaction cannot be opened. - rc = querySharedCacheTableLock(tls, p, uint32(1), uint8(1)) - if !(0 != rc) { + rc = querySharedCacheTableLock(tls, p, SCHEMA_ROOT, READ_LOCK) + if !(SQLITE_OK != rc) { goto __12 } goto trans_begun __12: ; - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0010))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_INITIALLY_EMPTY))) if !((*BtShared)(unsafe.Pointer(pBt)).FnPage == U32(0)) { goto __13 } - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0010)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_INITIALLY_EMPTY)) __13: ; __14: @@ -44717,36 +44155,36 @@ __14: // file is not pBt->pageSize. In this case lockBtree() will update // pBt->pageSize to the page-size of the file on disk. __17: - if !(((*BtShared)(unsafe.Pointer(pBt)).FpPage1 == uintptr(0)) && (0 == (libc.AssignInt32(&rc, lockBtree(tls, pBt))))) { + if !(((*BtShared)(unsafe.Pointer(pBt)).FpPage1 == uintptr(0)) && (SQLITE_OK == (libc.AssignInt32(&rc, lockBtree(tls, pBt))))) { goto __18 } goto __17 __18: ; - if !((rc == 0) && (wrflag != 0)) { + if !((rc == SQLITE_OK) && (wrflag != 0)) { goto __19 } - if !((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0001) != 0) { + if !((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_READ_ONLY) != 0) { goto __20 } - rc = 8 + rc = SQLITE_READONLY goto __21 __20: rc = Xsqlite3PagerBegin(tls, pPager, (libc.Bool32(wrflag > 1)), Xsqlite3TempInMemory(tls, (*Btree)(unsafe.Pointer(p)).Fdb)) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __22 } rc = newDatabase(tls, pBt) goto __23 __22: - if !((rc == (5 | (int32(2) << 8))) && (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == 0)) { + if !((rc == (SQLITE_BUSY | (int32(2) << 8))) && (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_NONE)) { goto __24 } // if there was no transaction opened when this function was // called and SQLITE_BUSY_SNAPSHOT is returned, change the error // code to SQLITE_BUSY. - rc = 5 + rc = SQLITE_BUSY __24: ; __23: @@ -44756,7 +44194,7 @@ __21: __19: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __25 } @@ -44765,17 +44203,17 @@ __25: ; goto __15 __15: - if (((rc & 0xFF) == 5) && (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == 0)) && (btreeInvokeBusyHandler(tls, pBt) != 0) { + if (((rc & 0xFF) == SQLITE_BUSY) && (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_NONE)) && (btreeInvokeBusyHandler(tls, pBt) != 0) { goto __14 } goto __16 __16: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __26 } - if !(int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 0) { + if !(int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_NONE) { goto __27 } (*BtShared)(unsafe.Pointer(pBt)).FnTransaction++ @@ -44783,7 +44221,7 @@ __16: goto __28 } - (*Btree)(unsafe.Pointer(p)).Flock.FeLock = U8(1) + (*Btree)(unsafe.Pointer(p)).Flock.FeLock = READ_LOCK (*Btree)(unsafe.Pointer(p)).Flock.FpNext = (*BtShared)(unsafe.Pointer(pBt)).FpLock (*BtShared)(unsafe.Pointer(pBt)).FpLock = (p + 48 /* &.lock */) __28: @@ -44792,9 +44230,9 @@ __27: ; (*Btree)(unsafe.Pointer(p)).FinTrans = func() uint8 { if wrflag != 0 { - return uint8(2) + return TRANS_WRITE } - return uint8(1) + return TRANS_READ }() if !(int32((*Btree)(unsafe.Pointer(p)).FinTrans) > int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction)) { goto __29 @@ -44808,11 +44246,11 @@ __29: pPage1 = (*BtShared)(unsafe.Pointer(pBt)).FpPage1 (*BtShared)(unsafe.Pointer(pBt)).FpWriter = p - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0040))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_EXCLUSIVE))) if !(wrflag > 1) { goto __31 } - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0040)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_EXCLUSIVE)) __31: ; @@ -44821,14 +44259,14 @@ __31: // this sooner rather than later means the database size can safely // re-read the database size from page 1 if a savepoint or transaction // rollback occurs within the transaction. - if !((*BtShared)(unsafe.Pointer(pBt)).FnPage != Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData+uintptr(28)))) { + if !((*BtShared)(unsafe.Pointer(pBt)).FnPage != Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData+28))) { goto __32 } rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPage1)).FpDbPage) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __33 } - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(28)), (*BtShared)(unsafe.Pointer(pBt)).FnPage) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 28), (*BtShared)(unsafe.Pointer(pBt)).FnPage) __33: ; __32: @@ -44839,13 +44277,13 @@ __26: ; trans_begun: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __34 } if !(pSchemaVersion != 0) { goto __35 } - *(*int32)(unsafe.Pointer(pSchemaVersion)) = int32(Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(40)))) + *(*int32)(unsafe.Pointer(pSchemaVersion)) = int32(Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 40))) __35: ; if !(wrflag != 0) { @@ -44879,11 +44317,11 @@ func setChildPtrmaps(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:68036:12 var pgno Pgno = (*MemPage)(unsafe.Pointer(pPage)).Fpgno if (*MemPage)(unsafe.Pointer(pPage)).FisInit != 0 { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK } else { *(*int32)(unsafe.Pointer(bp /* rc */)) = btreeInitPage(tls, pPage) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } nCell = int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) @@ -44895,13 +44333,13 @@ func setChildPtrmaps(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:68036:12 if !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) { var childPgno Pgno = Xsqlite3Get4byte(tls, pCell) - ptrmapPut(tls, pBt, childPgno, uint8(5), pgno, bp /* &rc */) + ptrmapPut(tls, pBt, childPgno, PTRMAP_BTREE, pgno, bp /* &rc */) } } if !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) { var childPgno Pgno = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr((int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset) + 8)))) - ptrmapPut(tls, pBt, childPgno, uint8(5), pgno, bp /* &rc */) + ptrmapPut(tls, pBt, childPgno, PTRMAP_BTREE, pgno, bp /* &rc */) } return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -44923,7 +44361,7 @@ func modifyPagePointer(tls *libc.TLS, pPage uintptr, iFrom Pgno, iTo Pgno, eType bp := tls.Alloc(24) defer tls.Free(24) - if int32(eType) == 4 { + if int32(eType) == PTRMAP_OVERFLOW2 { // The pointer is always the first 4 bytes of the page in this case. if Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData) != iFrom { return Xsqlite3CorruptError(tls, 68087) @@ -44935,7 +44373,7 @@ func modifyPagePointer(tls *libc.TLS, pPage uintptr, iFrom Pgno, iTo Pgno, eType var rc int32 if (*MemPage)(unsafe.Pointer(pPage)).FisInit != 0 { - rc = 0 + rc = SQLITE_OK } else { rc = btreeInitPage(tls, pPage) } @@ -44946,7 +44384,7 @@ func modifyPagePointer(tls *libc.TLS, pPage uintptr, iFrom Pgno, iTo Pgno, eType for i = 0; i < nCell; i++ { var pCell uintptr = ((*MemPage)(unsafe.Pointer((pPage))).FaData + uintptr((int32((*MemPage)(unsafe.Pointer((pPage))).FmaskPage) & int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(((*MemPage)(unsafe.Pointer((pPage))).FaCellIdx + uintptr((2 * (i))))))))))) - if int32(eType) == 3 { + if int32(eType) == PTRMAP_OVERFLOW1 { // var info CellInfo at bp, 24 (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer((pPage + 128 /* &.xParseCell */))))(tls, pPage, pCell, bp /* &info */) @@ -44968,13 +44406,13 @@ func modifyPagePointer(tls *libc.TLS, pPage uintptr, iFrom Pgno, iTo Pgno, eType } if i == nCell { - if (int32(eType) != 5) || (Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr((int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+8)))) != iFrom) { + if (int32(eType) != PTRMAP_BTREE) || (Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr((int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+8)))) != iFrom) { return Xsqlite3CorruptError(tls, 68124) } Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr((int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset) + 8))), iTo) } } - return 0 + return SQLITE_OK } // Move the open database page pDbPage to location iFreePage in the @@ -45001,7 +44439,7 @@ func relocatePage(tls *libc.TLS, pBt uintptr, pDbPage uintptr, eType U8, iPtrPag // Move page iDbPage from its current location to page number iFreePage *(*int32)(unsafe.Pointer(bp /* rc */)) = Xsqlite3PagerMovepage(tls, pPager, (*MemPage)(unsafe.Pointer(pDbPage)).FpDbPage, iFreePage, isCommit) - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } (*MemPage)(unsafe.Pointer(pDbPage)).Fpgno = iFreePage @@ -45013,16 +44451,16 @@ func relocatePage(tls *libc.TLS, pBt uintptr, pDbPage uintptr, eType U8, iPtrPag // If pDbPage is an overflow page, then the first 4 bytes may store a // pointer to a subsequent overflow page. If this is the case, then // the pointer map needs to be updated for the subsequent overflow page. - if (int32(eType) == 5) || (int32(eType) == 1) { + if (int32(eType) == PTRMAP_BTREE) || (int32(eType) == PTRMAP_ROOTPAGE) { *(*int32)(unsafe.Pointer(bp /* rc */)) = setChildPtrmaps(tls, pDbPage) - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } } else { var nextOvfl Pgno = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pDbPage)).FaData) if nextOvfl != Pgno(0) { - ptrmapPut(tls, pBt, nextOvfl, uint8(4), iFreePage, bp /* &rc */) - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + ptrmapPut(tls, pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, bp /* &rc */) + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } } @@ -45031,19 +44469,19 @@ func relocatePage(tls *libc.TLS, pBt uintptr, pDbPage uintptr, eType U8, iPtrPag // Fix the database pointer on page iPtrPage that pointed at iDbPage so // that it points at iFreePage. Also fix the pointer map entry for // iPtrPage. - if int32(eType) != 1 { + if int32(eType) != PTRMAP_ROOTPAGE { *(*int32)(unsafe.Pointer(bp /* rc */)) = btreeGetPage(tls, pBt, iPtrPage, bp+8 /* &pPtrPage */, 0) - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } *(*int32)(unsafe.Pointer(bp /* rc */)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pPtrPage */)))).FpDbPage) - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPtrPage */))) return *(*int32)(unsafe.Pointer(bp /* rc */)) } *(*int32)(unsafe.Pointer(bp /* rc */)) = modifyPagePointer(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPtrPage */)), iDbPage, iFreePage, eType) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPtrPage */))) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { ptrmapPut(tls, pBt, iFreePage, eType, iPtrPage, bp /* &rc */) } } @@ -45077,20 +44515,20 @@ func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit // var iPtrPage Pgno at bp+4, 4 - nFreeList = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(36))) + nFreeList = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 36)) if nFreeList == Pgno(0) { - return 101 + return SQLITE_DONE } rc = ptrmapGet(tls, pBt, iLastPg, bp /* &eType */, bp+4 /* &iPtrPage */) - if rc != 0 { + if rc != SQLITE_OK { return rc } - if int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == 1 { + if int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == PTRMAP_ROOTPAGE { return Xsqlite3CorruptError(tls, 68257) } - if int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == 2 { + if int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == PTRMAP_FREEPAGE { if bCommit == 0 { // Remove the page from the files free-list. This is not required // if bCommit is non-zero. In that case, the free-list will be @@ -45100,8 +44538,8 @@ func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit // var pFreePg uintptr at bp+8, 8 - rc = allocateBtreePage(tls, pBt, bp+8 /* &pFreePg */, bp+16 /* &iFreePg */, iLastPg, uint8(1)) - if rc != 0 { + rc = allocateBtreePage(tls, pBt, bp+8 /* &pFreePg */, bp+16 /* &iFreePg */, iLastPg, BTALLOC_EXACT) + if rc != SQLITE_OK { return rc } @@ -45112,11 +44550,11 @@ func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit // Index of free page to move pLastPg to // var pLastPg uintptr at bp+24, 8 - var eMode U8 = U8(0) // Mode parameter for allocateBtreePage() - var iNear Pgno = Pgno(0) // nearby parameter for allocateBtreePage() + var eMode U8 = BTALLOC_ANY // Mode parameter for allocateBtreePage() + var iNear Pgno = Pgno(0) // nearby parameter for allocateBtreePage() rc = btreeGetPage(tls, pBt, iLastPg, bp+24 /* &pLastPg */, 0) - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -45127,14 +44565,14 @@ func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit // looping until a free-page located within the first nFin pages // of the file is found. if bCommit == 0 { - eMode = U8(2) + eMode = BTALLOC_LE iNear = nFin } for ok := true; ok; ok = ((bCommit != 0) && (*(*Pgno)(unsafe.Pointer(bp + 40 /* iFreePg */)) > nFin)) { // var pFreePg uintptr at bp+32, 8 rc = allocateBtreePage(tls, pBt, bp+32 /* &pFreePg */, bp+40 /* &iFreePg */, iNear, eMode) - if rc != 0 { + if rc != SQLITE_OK { releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pLastPg */))) return rc } @@ -45143,7 +44581,7 @@ func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit rc = relocatePage(tls, pBt, *(*uintptr)(unsafe.Pointer(bp + 24 /* pLastPg */)), *(*U8)(unsafe.Pointer(bp /* eType */)), *(*Pgno)(unsafe.Pointer(bp + 4 /* iPtrPage */)), *(*Pgno)(unsafe.Pointer(bp + 40 /* iFreePg */)), bCommit) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pLastPg */))) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -45156,7 +44594,7 @@ func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit (*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate = U8(1) (*BtShared)(unsafe.Pointer(pBt)).FnPage = iLastPg } - return 0 + return SQLITE_OK } // The database opened by the first argument is an auto-vacuum database @@ -45193,26 +44631,26 @@ func Xsqlite3BtreeIncrVacuum(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:6835 Xsqlite3BtreeEnter(tls, p) if !(int32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum) != 0) { - rc = 101 + rc = SQLITE_DONE } else { var nOrig Pgno = btreePagecount(tls, pBt) - var nFree Pgno = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(36))) + var nFree Pgno = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 36)) var nFin Pgno = finalDbSize(tls, pBt, nOrig, nFree) if (nOrig < nFin) || (nFree >= nOrig) { rc = Xsqlite3CorruptError(tls, 68372) } else if nFree > Pgno(0) { rc = saveAllCursors(tls, pBt, uint32(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { invalidateAllOverflowCache(tls, pBt) rc = incrVacuumStep(tls, pBt, nFin, nOrig, 0) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(28)), (*BtShared)(unsafe.Pointer(pBt)).FnPage) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 28), (*BtShared)(unsafe.Pointer(pBt)).FnPage) } } else { - rc = 101 + rc = SQLITE_DONE } } Xsqlite3BtreeLeave(tls, p) @@ -45227,7 +44665,7 @@ func Xsqlite3BtreeIncrVacuum(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:6835 // i.e. the database has been reorganized so that only the first *pnTrunc // pages are in use. func autoVacuumCommit(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:68400:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pPager uintptr = (*BtShared)(unsafe.Pointer(pBt)).FpPager invalidateAllOverflowCache(tls, pBt) @@ -45246,7 +44684,7 @@ func autoVacuumCommit(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:68400:12: return Xsqlite3CorruptError(tls, 68420) } - nFree = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(36))) + nFree = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 36)) nFin = finalDbSize(tls, pBt, nOrig, nFree) if nFin > nOrig { return Xsqlite3CorruptError(tls, 68425) @@ -45254,18 +44692,18 @@ func autoVacuumCommit(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:68400:12: if nFin < nOrig { rc = saveAllCursors(tls, pBt, uint32(0), uintptr(0)) } - for iFree = nOrig; (iFree > nFin) && (rc == 0); iFree-- { + for iFree = nOrig; (iFree > nFin) && (rc == SQLITE_OK); iFree-- { rc = incrVacuumStep(tls, pBt, nFin, iFree, 1) } - if ((rc == 101) || (rc == 0)) && (nFree > Pgno(0)) { + if ((rc == SQLITE_DONE) || (rc == SQLITE_OK)) && (nFree > Pgno(0)) { rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(32)), uint32(0)) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(36)), uint32(0)) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(28)), nFin) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 32), uint32(0)) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 36), uint32(0)) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 28), nFin) (*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate = U8(1) (*BtShared)(unsafe.Pointer(pBt)).FnPage = nFin } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3PagerRollback(tls, pPager) } } @@ -45298,13 +44736,13 @@ func autoVacuumCommit(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:68400:12: // Once this is routine has returned, the only thing required to commit // the write-transaction for this database file is to delete the journal. func Xsqlite3BtreeCommitPhaseOne(tls *libc.TLS, p uintptr, zSuperJrnl uintptr) int32 { /* sqlite3.c:68479:20: */ - var rc int32 = 0 - if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 2 { + var rc int32 = SQLITE_OK + if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE { var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt Xsqlite3BtreeEnter(tls, p) if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { rc = autoVacuumCommit(tls, pBt) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3BtreeLeave(tls, p) return rc } @@ -45325,28 +44763,28 @@ func btreeEndTransaction(tls *libc.TLS, p uintptr) { /* sqlite3.c:68506:13: */ var db uintptr = (*Btree)(unsafe.Pointer(p)).Fdb (*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate = U8(0) - if (int32((*Btree)(unsafe.Pointer(p)).FinTrans) > 0) && ((*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead > 1) { + if (int32((*Btree)(unsafe.Pointer(p)).FinTrans) > TRANS_NONE) && ((*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead > 1) { // If there are other active statements that belong to this database // handle, downgrade to a read-only transaction. The other statements // may still be reading from the database. downgradeAllSharedCacheTableLocks(tls, p) - (*Btree)(unsafe.Pointer(p)).FinTrans = U8(1) + (*Btree)(unsafe.Pointer(p)).FinTrans = TRANS_READ } else { // If the handle had any kind of transaction open, decrement the // transaction count of the shared btree. If the transaction count // reaches 0, set the shared state to TRANS_NONE. The unlockBtreeIfUnused() // call below will unlock the pager. - if int32((*Btree)(unsafe.Pointer(p)).FinTrans) != 0 { + if int32((*Btree)(unsafe.Pointer(p)).FinTrans) != TRANS_NONE { clearAllSharedCacheTableLocks(tls, p) (*BtShared)(unsafe.Pointer(pBt)).FnTransaction-- if 0 == (*BtShared)(unsafe.Pointer(pBt)).FnTransaction { - (*BtShared)(unsafe.Pointer(pBt)).FinTransaction = U8(0) + (*BtShared)(unsafe.Pointer(pBt)).FinTransaction = TRANS_NONE } } // Set the current transaction state to TRANS_NONE and unlock the // pager if this call closed the only read or write transaction. - (*Btree)(unsafe.Pointer(p)).FinTrans = U8(0) + (*Btree)(unsafe.Pointer(p)).FinTrans = TRANS_NONE unlockBtreeIfUnused(tls, pBt) } @@ -45378,30 +44816,30 @@ func btreeEndTransaction(tls *libc.TLS, p uintptr) { /* sqlite3.c:68506:13: */ // are no active cursors, it also releases the read lock. func Xsqlite3BtreeCommitPhaseTwo(tls *libc.TLS, p uintptr, bCleanup int32) int32 { /* sqlite3.c:68568:20: */ - if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 0 { - return 0 + if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_NONE { + return SQLITE_OK } Xsqlite3BtreeEnter(tls, p) // If the handle has a write-transaction open, commit the shared-btrees // transaction and set the shared state to TRANS_READ. - if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 2 { + if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE { var rc int32 var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt rc = Xsqlite3PagerCommitPhaseTwo(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) - if (rc != 0) && (bCleanup == 0) { + if (rc != SQLITE_OK) && (bCleanup == 0) { Xsqlite3BtreeLeave(tls, p) return rc } (*Btree)(unsafe.Pointer(p)).FiDataVersion-- // Compensate for pPager->iDataVersion++; - (*BtShared)(unsafe.Pointer(pBt)).FinTransaction = U8(1) + (*BtShared)(unsafe.Pointer(pBt)).FinTransaction = TRANS_READ btreeClearHasContent(tls, pBt) } btreeEndTransaction(tls, p) Xsqlite3BtreeLeave(tls, p) - return 0 + return SQLITE_OK } // Do both phases of a commit. @@ -45409,7 +44847,7 @@ func Xsqlite3BtreeCommit(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:68600:20 var rc int32 Xsqlite3BtreeEnter(tls, p) rc = Xsqlite3BtreeCommitPhaseOne(tls, p, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3BtreeCommitPhaseTwo(tls, p, 0) } Xsqlite3BtreeLeave(tls, p) @@ -45442,22 +44880,22 @@ func Xsqlite3BtreeCommit(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:68600:20 // saving a cursor position, an SQLite error code. func Xsqlite3BtreeTripAllCursors(tls *libc.TLS, pBtree uintptr, errCode int32, writeOnly int32) int32 { /* sqlite3.c:68637:20: */ var p uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK if pBtree != 0 { Xsqlite3BtreeEnter(tls, pBtree) for p = (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBtree)).FpBt)).FpCursor; p != 0; p = (*BtCursor)(unsafe.Pointer(p)).FpNext { - if (writeOnly != 0) && ((int32((*BtCursor)(unsafe.Pointer(p)).FcurFlags) & 0x01) == 0) { - if (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == 0) || (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == 2) { + if (writeOnly != 0) && ((int32((*BtCursor)(unsafe.Pointer(p)).FcurFlags) & BTCF_WriteFlag) == 0) { + if (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_VALID) || (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_SKIPNEXT) { rc = saveCursorPosition(tls, p) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3BtreeTripAllCursors(tls, pBtree, rc, 0) break } } } else { Xsqlite3BtreeClearCursor(tls, p) - (*BtCursor)(unsafe.Pointer(p)).FeState = U8(4) + (*BtCursor)(unsafe.Pointer(p)).FeState = CURSOR_FAULT (*BtCursor)(unsafe.Pointer(p)).FskipNext = errCode } btreeReleaseAllCursorPages(tls, p) @@ -45473,7 +44911,7 @@ func btreeSetNPage(tls *libc.TLS, pBt uintptr, pPage1 uintptr) { /* sqlite3.c:68 bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* nPage */)) = int32(Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(28)))) + *(*int32)(unsafe.Pointer(bp /* nPage */)) = int32(Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 28))) if *(*int32)(unsafe.Pointer(bp /* nPage */)) == 0 { Xsqlite3PagerPagecount(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, bp /* &nPage */) @@ -45500,39 +44938,39 @@ func Xsqlite3BtreeRollback(tls *libc.TLS, p uintptr, tripCode int32, writeOnly i // var pPage1 uintptr at bp, 8 Xsqlite3BtreeEnter(tls, p) - if tripCode == 0 { + if tripCode == SQLITE_OK { rc = libc.AssignInt32(&tripCode, saveAllCursors(tls, pBt, uint32(0), uintptr(0))) if rc != 0 { writeOnly = 0 } } else { - rc = 0 + rc = SQLITE_OK } if tripCode != 0 { var rc2 int32 = Xsqlite3BtreeTripAllCursors(tls, p, tripCode, writeOnly) - if rc2 != 0 { + if rc2 != SQLITE_OK { rc = rc2 } } - if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 2 { + if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE { var rc2 int32 rc2 = Xsqlite3PagerRollback(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) - if rc2 != 0 { + if rc2 != SQLITE_OK { rc = rc2 } // The rollback may have destroyed the pPage1->aData value. So // call btreeGetPage() on page 1 again to make // sure pPage1->aData is set correctly. - if btreeGetPage(tls, pBt, uint32(1), bp /* &pPage1 */, 0) == 0 { + if btreeGetPage(tls, pBt, uint32(1), bp /* &pPage1 */, 0) == SQLITE_OK { btreeSetNPage(tls, pBt, *(*uintptr)(unsafe.Pointer(bp /* pPage1 */))) releasePageOne(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage1 */))) } - (*BtShared)(unsafe.Pointer(pBt)).FinTransaction = U8(1) + (*BtShared)(unsafe.Pointer(pBt)).FinTransaction = TRANS_READ btreeClearHasContent(tls, pBt) } @@ -45582,19 +45020,19 @@ func Xsqlite3BtreeBeginStmt(tls *libc.TLS, p uintptr, iStatement int32) int32 { // from a normal transaction rollback, as no locks are released and the // transaction remains open. func Xsqlite3BtreeSavepoint(tls *libc.TLS, p uintptr, op int32, iSavepoint int32) int32 { /* sqlite3.c:68784:20: */ - var rc int32 = 0 - if (p != 0) && (int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 2) { + var rc int32 = SQLITE_OK + if (p != 0) && (int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE) { var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt Xsqlite3BtreeEnter(tls, p) - if op == 2 { + if op == SAVEPOINT_ROLLBACK { rc = saveAllCursors(tls, pBt, uint32(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerSavepoint(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, op, iSavepoint) } - if rc == 0 { - if (iSavepoint < 0) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0010) != 0) { + if rc == SQLITE_OK { + if (iSavepoint < 0) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_INITIALLY_EMPTY) != 0) { (*BtShared)(unsafe.Pointer(pBt)).FnPage = U32(0) } rc = newDatabase(tls, pBt) @@ -45663,7 +45101,7 @@ func btreeCursor(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pKeyInfo u if wrFlag != 0 { allocateTempSpace(tls, pBt) if (*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace == uintptr(0) { - return 7 + return SQLITE_NOMEM } } if iTable <= Pgno(1) { @@ -45684,7 +45122,7 @@ func btreeCursor(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pKeyInfo u (*BtCursor)(unsafe.Pointer(pCur)).FpBt = pBt (*BtCursor)(unsafe.Pointer(pCur)).FcurFlags = func() uint8 { if wrFlag != 0 { - return uint8(0x01) + return BTCF_WriteFlag } return uint8(0) }() @@ -45692,20 +45130,20 @@ func btreeCursor(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pKeyInfo u if wrFlag != 0 { return uint8(0) } - return uint8(0x02) + return PAGER_GET_READONLY }() // If there are two or more cursors on the same btree, then all such // cursors *must* have the BTCF_Multiple flag set. for pX = (*BtShared)(unsafe.Pointer(pBt)).FpCursor; pX != 0; pX = (*BtCursor)(unsafe.Pointer(pX)).FpNext { if (*BtCursor)(unsafe.Pointer(pX)).FpgnoRoot == iTable { - *(*U8)(unsafe.Pointer(pX + 1 /* &.curFlags */)) |= U8((0x20)) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x20)) + *(*U8)(unsafe.Pointer(pX + 1 /* &.curFlags */)) |= U8((BTCF_Multiple)) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_Multiple)) } } (*BtCursor)(unsafe.Pointer(pCur)).FpNext = (*BtShared)(unsafe.Pointer(pBt)).FpCursor (*BtShared)(unsafe.Pointer(pBt)).FpCursor = pCur - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) - return 0 + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID + return SQLITE_OK } func btreeCursorWithLock(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pKeyInfo uintptr, pCur uintptr) int32 { /* sqlite3.c:68920:12: */ @@ -45732,7 +45170,7 @@ func Xsqlite3BtreeCursor(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pK // to users so they cannot do the sizeof() themselves - they must call // this routine. func Xsqlite3BtreeCursorSize(tls *libc.TLS) int32 { /* sqlite3.c:68955:20: */ - return (int32(((uint64(unsafe.Sizeof(BtCursor{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + return (int32(((uint64(unsafe.Sizeof(BtCursor{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) } // Initialize memory that will be converted into a BtCursor object. @@ -45772,7 +45210,7 @@ func Xsqlite3BtreeCloseCursor(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c: Xsqlite3BtreeLeave(tls, pBtree) (*BtCursor)(unsafe.Pointer(pCur)).FpBtree = uintptr(0) } - return 0 + return SQLITE_OK } // Make sure the BtCursor* given in the argument has a valid @@ -45783,7 +45221,7 @@ func Xsqlite3BtreeCloseCursor(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c: // Using this cache reduces the number of calls to btreeParseCell(). func getCellInfo(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:69029:29: */ if int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize) == 0 { - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x02)) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_ValidNKey)) btreeParseCell(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpPage, int32((*BtCursor)(unsafe.Pointer(pCur)).Fix), (pCur + 48 /* &.info */)) } else { @@ -45792,7 +45230,7 @@ func getCellInfo(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:69029:29: */ func Xsqlite3BtreeCursorIsValidNN(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:69048:20: */ - return (libc.Bool32(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 0)) + return (libc.Bool32(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID)) } // Return the value of the integer key or "rowid" for a table btree. @@ -45808,12 +45246,12 @@ func Xsqlite3BtreeIntegerKey(tls *libc.TLS, pCur uintptr) I64 { /* sqlite3.c:690 // Pin or unpin a cursor. func Xsqlite3BtreeCursorPin(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:69070:21: */ - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x40)) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_Pinned)) } func Xsqlite3BtreeCursorUnpin(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:69074:21: */ - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x40))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_Pinned))) } // Return the offset into the database file for the start of the @@ -45876,7 +45314,7 @@ func getOverflowPage(tls *libc.TLS, pBt uintptr, ovfl Pgno, ppPage uintptr, pPgn var next Pgno = Pgno(0) *(*uintptr)(unsafe.Pointer(bp + 8 /* pPage */)) = uintptr(0) - var rc int32 = 0 + var rc int32 = SQLITE_OK // Try to find the next page in the overflow list using the // autovacuum pointer-map pages. Guess that the next page in @@ -45895,22 +45333,22 @@ func getOverflowPage(tls *libc.TLS, pBt uintptr, ovfl Pgno, ppPage uintptr, pPgn if iGuess <= btreePagecount(tls, pBt) { rc = ptrmapGet(tls, pBt, iGuess, bp /* &eType */, bp+4 /* &pgno */) - if ((rc == 0) && (int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == 4)) && (*(*Pgno)(unsafe.Pointer(bp + 4 /* pgno */)) == ovfl) { + if ((rc == SQLITE_OK) && (int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == PTRMAP_OVERFLOW2)) && (*(*Pgno)(unsafe.Pointer(bp + 4 /* pgno */)) == ovfl) { next = iGuess - rc = 101 + rc = SQLITE_DONE } } } - if rc == 0 { + if rc == SQLITE_OK { rc = btreeGetPage(tls, pBt, ovfl, bp+8 /* &pPage */, func() int32 { if ppPage == uintptr(0) { - return 0x02 + return PAGER_GET_READONLY } return 0 }()) - if rc == 0 { + if rc == SQLITE_OK { next = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pPage */)))).FaData) } } @@ -45922,8 +45360,8 @@ func getOverflowPage(tls *libc.TLS, pBt uintptr, ovfl Pgno, ppPage uintptr, pPgn releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPage */))) } return func() int32 { - if rc == 101 { - return 0 + if rc == SQLITE_DONE { + return SQLITE_OK } return rc }() @@ -45942,7 +45380,7 @@ func copyPayload(tls *libc.TLS, pPayload uintptr, pBuf uintptr, nByte int32, eOp if eOp != 0 { // Copy data from buffer to page (a write operation) var rc int32 = Xsqlite3PagerWrite(tls, pDbPage) - if rc != 0 { + if rc != SQLITE_OK { return rc } libc.Xmemcpy(tls, pPayload, pBuf, uint64(nByte)) @@ -45950,7 +45388,7 @@ func copyPayload(tls *libc.TLS, pPayload uintptr, pBuf uintptr, nByte int32, eOp // Copy data from page to buffer (a read operation) libc.Xmemcpy(tls, pBuf, pPayload, uint64(nByte)) } - return 0 + return SQLITE_OK } // This function is used to read or overwrite payload information @@ -45985,7 +45423,7 @@ func accessPayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintpt defer tls.Free(16) var aPayload uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK var iIdx int32 = 0 var pPage uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpPage // Btree page of current entry var pBt uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpBt // Btree this cursor belongs to @@ -46015,7 +45453,7 @@ func accessPayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintpt offset = offset - (U32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)) } - if (rc == 0) && (amt > U32(0)) { + if (rc == SQLITE_OK) && (amt > U32(0)) { var ovflSize U32 = ((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(4)) // Bytes content per ovfl page // var nextPage Pgno at bp, 4 @@ -46027,20 +45465,20 @@ func accessPayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintpt // in the overflow chain. The page number of the first overflow page is // stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array // means "not yet known" (the cache is lazily populated). - if (int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x04) == 0 { + if (int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_ValidOvfl) == 0 { var nOvfl int32 = (int32(((((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnPayload - U32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)) + ovflSize) - U32(1)) / ovflSize)) if ((*BtCursor)(unsafe.Pointer(pCur)).FaOverflow == uintptr(0)) || ((nOvfl * int32(unsafe.Sizeof(Pgno(0)))) > Xsqlite3MallocSize(tls, (*BtCursor)(unsafe.Pointer(pCur)).FaOverflow)) { var aNew uintptr = Xsqlite3Realloc(tls, (*BtCursor)(unsafe.Pointer(pCur)).FaOverflow, (uint64((uint64(nOvfl * 2)) * uint64(unsafe.Sizeof(Pgno(0)))))) if aNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } else { (*BtCursor)(unsafe.Pointer(pCur)).FaOverflow = aNew } } libc.Xmemset(tls, (*BtCursor)(unsafe.Pointer(pCur)).FaOverflow, 0, (uint64(nOvfl) * uint64(unsafe.Sizeof(Pgno(0))))) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x04)) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_ValidOvfl)) } else { // If the overflow page-list cache has been allocated and the // entry for the first required overflow page is valid, skip @@ -46087,11 +45525,11 @@ func accessPayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintpt rc = Xsqlite3PagerGet(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, *(*Pgno)(unsafe.Pointer(bp /* nextPage */)), bp+8, /* &pDbPage */ func() int32 { if eOp == 0 { - return 0x02 + return PAGER_GET_READONLY } return 0 }()) - if rc == 0 { + if rc == SQLITE_OK { aPayload = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pDbPage */))) *(*Pgno)(unsafe.Pointer(bp /* nextPage */)) = Xsqlite3Get4byte(tls, aPayload) rc = copyPayload(tls, (aPayload + uintptr((offset + U32(4)))), pBuf, a, eOp, *(*uintptr)(unsafe.Pointer(bp + 8 /* pDbPage */))) @@ -46113,7 +45551,7 @@ func accessPayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintpt } } - if (rc == 0) && (amt > U32(0)) { + if (rc == SQLITE_OK) && (amt > U32(0)) { // Overflow chain ends prematurely return Xsqlite3CorruptError(tls, 69445) } @@ -46145,8 +45583,8 @@ func Xsqlite3BtreePayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf // interface. func accessPayloadChecked(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintptr) int32 { /* sqlite3.c:69481:28: */ var rc int32 - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 1 { - return 4 + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_INVALID { + return SQLITE_ABORT } rc = btreeRestoreCursorPosition(tls, pCur) @@ -46157,7 +45595,7 @@ func accessPayloadChecked(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf } func Xsqlite3BtreePayloadChecked(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintptr) int32 { /* sqlite3.c:69495:20: */ - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 0 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID { return accessPayload(tls, pCur, offset, amt, pBuf, 0) } else { @@ -46228,11 +45666,11 @@ func Xsqlite3BtreePayloadFetch(tls *libc.TLS, pCur uintptr, pAmt uintptr) uintpt func moveToChild(tls *libc.TLS, pCur uintptr, newPgno U32) int32 { /* sqlite3.c:69577:12: */ var pBt uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpBt - if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) >= (20 - 1) { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) >= (BTCURSOR_MAX_DEPTH - 1) { return Xsqlite3CorruptError(tls, 69585) } (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32((0x02 | 0x04)))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32((BTCF_ValidNKey | BTCF_ValidOvfl)))) *(*U16)(unsafe.Pointer((pCur + 88 /* &.aiIdx */) + uintptr((*BtCursor)(unsafe.Pointer(pCur)).FiPage)*2)) = (*BtCursor)(unsafe.Pointer(pCur)).Fix *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */) + uintptr((*BtCursor)(unsafe.Pointer(pCur)).FiPage)*8)) = (*BtCursor)(unsafe.Pointer(pCur)).FpPage (*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(0) @@ -46250,7 +45688,7 @@ func moveToParent(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:69626:13: */ var pLeaf uintptr (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32((0x02 | 0x04)))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32((BTCF_ValidNKey | BTCF_ValidOvfl)))) (*BtCursor)(unsafe.Pointer(pCur)).Fix = *(*U16)(unsafe.Pointer((pCur + 88 /* &.aiIdx */) + uintptr((int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage)-1))*2)) pLeaf = (*BtCursor)(unsafe.Pointer(pCur)).FpPage (*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */) + uintptr(libc.PreDecInt8(&(*BtCursor)(unsafe.Pointer(pCur)).FiPage, 1))*8)) @@ -46280,7 +45718,7 @@ func moveToRoot(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:69667:12: */ var pRoot uintptr var rc int32 var subpage Pgno - rc = 0 + rc = SQLITE_OK if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) >= 0) { goto __1 @@ -46297,7 +45735,7 @@ __4: goto __4 __5: ; - (*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */) + uintptr(0)*8)) + (*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */))) goto skip_init __3: ; @@ -46306,15 +45744,15 @@ __1: if !((*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot == Pgno(0)) { goto __6 } - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) - return 16 + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID + return SQLITE_EMPTY goto __7 __6: ; - if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= 3) { + if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK) { goto __8 } - if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 4) { + if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_FAULT) { goto __9 } @@ -46326,10 +45764,10 @@ __8: ; rc = getAndInitPage(tls, (*Btree)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBtree)).FpBt, (*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, (pCur + 136 /* &.pPage */), uintptr(0), int32((*BtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __10 } - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID return rc __10: ; @@ -46362,13 +45800,13 @@ __11: skip_init: (*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(0) (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(((0x08 | 0x02) | 0x04)))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(((BTCF_AtLast | BTCF_ValidNKey) | BTCF_ValidOvfl)))) pRoot = (*BtCursor)(unsafe.Pointer(pCur)).FpPage if !(int32((*MemPage)(unsafe.Pointer(pRoot)).FnCell) > 0) { goto __12 } - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(0) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_VALID goto __13 __12: if !(!(int32((*MemPage)(unsafe.Pointer(pRoot)).Fleaf) != 0)) { @@ -46381,12 +45819,12 @@ __12: __16: ; subpage = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pRoot)).FaData + uintptr((int32((*MemPage)(unsafe.Pointer(pRoot)).FhdrOffset) + 8)))) - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(0) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_VALID rc = moveToChild(tls, pCur, subpage) goto __15 __14: - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) - rc = 16 + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID + rc = SQLITE_EMPTY __15: ; __13: @@ -46401,10 +45839,10 @@ __13: // in ascending order. func moveToLeftmost(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:69754:12: */ var pgno Pgno - var rc int32 = 0 + var rc int32 = SQLITE_OK var pPage uintptr - for (rc == 0) && !(int32((*MemPage)(unsafe.Pointer(libc.AssignUintptr(&pPage, (*BtCursor)(unsafe.Pointer(pCur)).FpPage))).Fleaf) != 0) { + for (rc == SQLITE_OK) && !(int32((*MemPage)(unsafe.Pointer(libc.AssignUintptr(&pPage, (*BtCursor)(unsafe.Pointer(pCur)).FpPage))).Fleaf) != 0) { pgno = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((pPage))).FaData + uintptr((int32((*MemPage)(unsafe.Pointer((pPage))).FmaskPage) & int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(((*MemPage)(unsafe.Pointer((pPage))).FaCellIdx + uintptr((2 * (int32((*BtCursor)(unsafe.Pointer(pCur)).Fix))))))))))))) rc = moveToChild(tls, pCur, pgno) @@ -46422,7 +45860,7 @@ func moveToLeftmost(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:69754:12: // key in ascending order. func moveToRightmost(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:69779:12: */ var pgno Pgno - var rc int32 = 0 + var rc int32 = SQLITE_OK var pPage uintptr = uintptr(0) for !(int32((*MemPage)(unsafe.Pointer(libc.AssignUintptr(&pPage, (*BtCursor)(unsafe.Pointer(pCur)).FpPage))).Fleaf) != 0) { @@ -46435,7 +45873,7 @@ func moveToRightmost(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:69779:12: } (*BtCursor)(unsafe.Pointer(pCur)).Fix = (U16(int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - 1)) - return 0 + return SQLITE_OK } // Move the cursor to the first entry in the table. Return SQLITE_OK @@ -46445,14 +45883,14 @@ func Xsqlite3BtreeFirst(tls *libc.TLS, pCur uintptr, pRes uintptr) int32 { /* sq var rc int32 rc = moveToRoot(tls, pCur) - if rc == 0 { + if rc == SQLITE_OK { *(*int32)(unsafe.Pointer(pRes)) = 0 rc = moveToLeftmost(tls, pCur) - } else if rc == 16 { + } else if rc == SQLITE_EMPTY { *(*int32)(unsafe.Pointer(pRes)) = 1 - rc = 0 + rc = SQLITE_OK } return rc } @@ -46464,25 +45902,25 @@ func Xsqlite3BtreeLast(tls *libc.TLS, pCur uintptr, pRes uintptr) int32 { /* sql var rc int32 // If the cursor already points to the last entry, this is a no-op. - if (0 == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState)) && ((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x08) != 0) { + if (CURSOR_VALID == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState)) && ((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_AtLast) != 0) { *(*int32)(unsafe.Pointer(pRes)) = 0 - return 0 + return SQLITE_OK } rc = moveToRoot(tls, pCur) - if rc == 0 { + if rc == SQLITE_OK { *(*int32)(unsafe.Pointer(pRes)) = 0 rc = moveToRightmost(tls, pCur) - if rc == 0 { - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x08)) + if rc == SQLITE_OK { + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_AtLast)) } else { - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x08))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_AtLast))) } - } else if rc == 16 { + } else if rc == SQLITE_EMPTY { *(*int32)(unsafe.Pointer(pRes)) = 1 - rc = 0 + rc = SQLITE_OK } return rc } @@ -46548,24 +45986,24 @@ func Xsqlite3BtreeMovetoUnpacked(tls *libc.TLS, pCur uintptr, pIdxKey uintptr, i // If the cursor is already positioned at the point we are trying // to move to, then just return without doing any work if !(((pIdxKey == uintptr(0)) && - (int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 0)) && ((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x02) != 0)) { + (int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID)) && ((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_ValidNKey) != 0)) { goto __1 } if !((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey == intKey) { goto __2 } *(*int32)(unsafe.Pointer(pRes)) = 0 - return 0 + return SQLITE_OK __2: ; if !((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey < intKey) { goto __3 } - if !((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x08) != 0) { + if !((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_AtLast) != 0) { goto __4 } *(*int32)(unsafe.Pointer(pRes)) = -1 - return 0 + return SQLITE_OK __4: ; // If the requested key is one more than the previous key, then @@ -46577,22 +46015,22 @@ __4: } *(*int32)(unsafe.Pointer(pRes)) = 0 rc = Xsqlite3BtreeNext(tls, pCur, 0) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __6 } getCellInfo(tls, pCur) if !((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey == intKey) { goto __8 } - return 0 + return SQLITE_OK __8: ; goto __7 __6: - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __9 } - rc = 0 + rc = SQLITE_OK goto __10 __9: return rc @@ -46623,12 +46061,12 @@ __12: if !(rc != 0) { goto __13 } - if !(rc == 16) { + if !(rc == SQLITE_EMPTY) { goto __14 } *(*int32)(unsafe.Pointer(pRes)) = -1 - return 0 + return SQLITE_OK __14: ; return rc @@ -46709,11 +46147,11 @@ __30: goto moveto_next_layer goto __34 __33: - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x02)) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_ValidNKey)) (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey = *(*I64)(unsafe.Pointer(bp /* nCellKey */)) (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0) *(*int32)(unsafe.Pointer(pRes)) = 0 - return 0 + return SQLITE_OK __34: ; __31: @@ -46740,7 +46178,7 @@ __35: // Size of the pCell cell in bytes // the entire cell by checking for the cases where the record is // stored entirely within the b-tree page by inspecting the first // 2 bytes of the cell. - nCell = int32(*(*U8)(unsafe.Pointer(pCell + uintptr(0)))) + nCell = int32(*(*U8)(unsafe.Pointer(pCell))) if !(nCell <= int32((*MemPage)(unsafe.Pointer(pPage)).Fmax1bytePayload)) { goto __38 } @@ -46748,17 +46186,17 @@ __35: // Size of the pCell cell in bytes // single byte varint and the record fits entirely on the main // b-tree page. - c = (*(*func(*libc.TLS, int32, uintptr, uintptr) int32)(unsafe.Pointer(&xRecordCompare)))(tls, nCell, (pCell + uintptr(1)), pIdxKey) + c = (*(*func(*libc.TLS, int32, uintptr, uintptr) int32)(unsafe.Pointer(&xRecordCompare)))(tls, nCell, (pCell + 1), pIdxKey) goto __39 __38: - if !(!((int32(*(*U8)(unsafe.Pointer(pCell + uintptr(1)))) & 0x80) != 0) && - ((libc.AssignInt32(&nCell, (((nCell & 0x7f) << 7) + int32(*(*U8)(unsafe.Pointer(pCell + uintptr(1))))))) <= int32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal))) { + if !(!((int32(*(*U8)(unsafe.Pointer(pCell + 1))) & 0x80) != 0) && + ((libc.AssignInt32(&nCell, (((nCell & 0x7f) << 7) + int32(*(*U8)(unsafe.Pointer(pCell + 1)))))) <= int32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal))) { goto __40 } // The record-size field is a 2 byte varint and the record // fits entirely on the main b-tree page. - c = (*(*func(*libc.TLS, int32, uintptr, uintptr) int32)(unsafe.Pointer(&xRecordCompare)))(tls, nCell, (pCell + uintptr(2)), pIdxKey) + c = (*(*func(*libc.TLS, int32, uintptr, uintptr) int32)(unsafe.Pointer(&xRecordCompare)))(tls, nCell, (pCell + 2), pIdxKey) goto __41 __40: pCellBody = (pCell - uintptr((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)) @@ -46780,14 +46218,14 @@ __42: if !(pCellKey == uintptr(0)) { goto __43 } - rc = 7 + rc = SQLITE_NOMEM goto moveto_finish __43: ; (*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(idx) rc = accessPayload(tls, pCur, uint32(0), uint32(nCell), pCellKey, 0) libc.Xmemset(tls, ((pCellKey) + uintptr(nCell)), 0, uint64(nOverrun)) // Fix uninit warnings - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x04))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_ValidOvfl))) if !(rc != 0) { goto __44 } @@ -46816,7 +46254,7 @@ __45: __47: ; *(*int32)(unsafe.Pointer(pRes)) = 0 - rc = 0 + rc = SQLITE_OK (*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(idx) if !((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode != 0) { goto __49 @@ -46852,7 +46290,7 @@ __19: (*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(idx) *(*int32)(unsafe.Pointer(pRes)) = c - rc = 0 + rc = SQLITE_OK goto moveto_finish __51: ; @@ -46895,7 +46333,7 @@ func Xsqlite3BtreeEof(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70145:20 // TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries // have been deleted? This API will need to change to return an error code // as well as the boolean result value. - return (libc.Bool32(0 != int32((*BtCursor)(unsafe.Pointer(pCur)).FeState))) + return (libc.Bool32(CURSOR_VALID != int32((*BtCursor)(unsafe.Pointer(pCur)).FeState))) } // Return an estimate for the number of rows in the table that pCur is @@ -46908,7 +46346,7 @@ func Xsqlite3BtreeRowCountEst(tls *libc.TLS, pCur uintptr) I64 { /* sqlite3.c:70 // Currently this interface is only called by the OP_IfSmaller // opcode, and it that case the cursor will always be valid and // will always point to a leaf node. - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != 0 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { return int64(-1) } if int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).Fleaf) == 0 { @@ -46945,24 +46383,24 @@ func btreeNext(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70198:28: */ var idx int32 var pPage uintptr - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != 0 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { rc = func() int32 { - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= 3 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK { return btreeRestoreCursorPosition(tls, pCur) } - return 0 + return SQLITE_OK }() - if rc != 0 { + if rc != SQLITE_OK { return rc } - if 1 == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) { - return 101 + if CURSOR_INVALID == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) { + return SQLITE_DONE } - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 2 { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(0) + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_SKIPNEXT { + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_VALID if (*BtCursor)(unsafe.Pointer(pCur)).FskipNext > 0 { - return 0 + return SQLITE_OK } } } @@ -46999,8 +46437,8 @@ func btreeNext(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70198:28: */ } for ok := true; ok; ok = (int32((*BtCursor)(unsafe.Pointer(pCur)).Fix) >= int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)) { if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) == 0 { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) - return 101 + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID + return SQLITE_DONE } moveToParent(tls, pCur) pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage @@ -47008,11 +46446,11 @@ func btreeNext(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70198:28: */ if (*MemPage)(unsafe.Pointer(pPage)).FintKey != 0 { return Xsqlite3BtreeNext(tls, pCur, 0) } else { - return 0 + return SQLITE_OK } } if (*MemPage)(unsafe.Pointer(pPage)).Fleaf != 0 { - return 0 + return SQLITE_OK } else { return moveToLeftmost(tls, pCur) } @@ -47024,8 +46462,8 @@ func Xsqlite3BtreeNext(tls *libc.TLS, pCur uintptr, flags int32) int32 { /* sqli _ = flags // Used in COMDB2 but not native SQLite (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32((0x02 | 0x04)))) - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != 0 { + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32((BTCF_ValidNKey | BTCF_ValidOvfl)))) + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { return btreeNext(tls, pCur) } pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage @@ -47034,7 +46472,7 @@ func Xsqlite3BtreeNext(tls *libc.TLS, pCur uintptr, flags int32) int32 { /* sqli return btreeNext(tls, pCur) } if (*MemPage)(unsafe.Pointer(pPage)).Fleaf != 0 { - return 0 + return SQLITE_OK } else { return moveToLeftmost(tls, pCur) } @@ -47063,23 +46501,23 @@ func btreePrevious(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70308:28: * var rc int32 var pPage uintptr - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != 0 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { rc = func() int32 { - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= 3 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK { return btreeRestoreCursorPosition(tls, pCur) } - return 0 + return SQLITE_OK }() - if rc != 0 { + if rc != SQLITE_OK { return rc } - if 1 == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) { - return 101 + if CURSOR_INVALID == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) { + return SQLITE_DONE } - if 2 == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(0) + if CURSOR_SKIPNEXT == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) { + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_VALID if (*BtCursor)(unsafe.Pointer(pCur)).FskipNext < 0 { - return 0 + return SQLITE_OK } } } @@ -47096,8 +46534,8 @@ func btreePrevious(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70308:28: * } else { for int32((*BtCursor)(unsafe.Pointer(pCur)).Fix) == 0 { if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) == 0 { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) - return 101 + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID + return SQLITE_DONE } moveToParent(tls, pCur) } @@ -47107,7 +46545,7 @@ func btreePrevious(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70308:28: * if ((*MemPage)(unsafe.Pointer(pPage)).FintKey != 0) && !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) { rc = Xsqlite3BtreePrevious(tls, pCur, 0) } else { - rc = 0 + rc = SQLITE_OK } } return rc @@ -47116,15 +46554,15 @@ func btreePrevious(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70308:28: * func Xsqlite3BtreePrevious(tls *libc.TLS, pCur uintptr, flags int32) int32 { /* sqlite3.c:70357:20: */ _ = flags // Used in COMDB2 but not native SQLite - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(((0x08 | 0x04) | 0x02)))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(((BTCF_AtLast | BTCF_ValidOvfl) | BTCF_ValidNKey)))) (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0) - if ((int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != 0) || + if ((int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID) || (int32((*BtCursor)(unsafe.Pointer(pCur)).Fix) == 0)) || (int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).Fleaf) == 0) { return btreePrevious(tls, pCur) } (*BtCursor)(unsafe.Pointer(pCur)).Fix-- - return 0 + return SQLITE_OK } // Allocate a new page from the database file. @@ -47209,7 +46647,7 @@ func allocateBtreePage(tls *libc.TLS, pBt uintptr, ppPage uintptr, pPgno uintptr mxPage = btreePagecount(tls, pBt) // EVIDENCE-OF: R-05119-02637 The 4-byte big-endian integer at offset 36 // stores stores the total number of pages on the freelist. - n = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(36))) + n = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 36)) if !(n >= mxPage) { goto __1 @@ -47226,7 +46664,7 @@ __1: // If eMode==BTALLOC_EXACT and a query of the pointer-map // shows that the page 'nearby' is somewhere on the free-list, then // the entire-list will be searched for that page. - if !(int32(eMode) == 1) { + if !(int32(eMode) == BTALLOC_EXACT) { goto __4 } if !(nearby <= mxPage) { @@ -47240,7 +46678,7 @@ __1: return rc __7: ; - if !(int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == 2) { + if !(int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == PTRMAP_FREEPAGE) { goto __8 } searchList = U8(1) @@ -47250,7 +46688,7 @@ __6: ; goto __5 __4: - if !(int32(eMode) == 2) { + if !(int32(eMode) == BTALLOC_LE) { goto __9 } searchList = U8(1) @@ -47268,7 +46706,7 @@ __5: return rc __10: ; - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(36)), (n - U32(1))) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 36), (n - U32(1))) // The code within this loop is run only once if the 'searchList' variable // is not true. Otherwise, it runs once for each trunk-page on the @@ -47282,13 +46720,13 @@ __11: // EVIDENCE-OF: R-01506-11053 The first integer on a freelist trunk page // is the page number of the next freelist trunk page in the list or // zero if this is the last freelist trunk page. - iTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData + uintptr(0))) + iTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData)) goto __15 __14: // EVIDENCE-OF: R-59841-13798 The 4-byte big-endian integer at offset 32 // stores the page number of the first page of the freelist, or zero if // the freelist is empty. - iTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(32))) + iTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 32)) __15: ; @@ -47311,7 +46749,7 @@ __18: // EVIDENCE-OF: R-13523-04394 The second integer on a freelist trunk page // is the number of leaf page pointers to follow. - k = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(4))) + k = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + 4)) if !((k == U32(0)) && !(searchList != 0)) { goto __19 } @@ -47327,7 +46765,7 @@ __18: __21: ; *(*Pgno)(unsafe.Pointer(pPgno)) = iTrunk - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(32)), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(0)), uint64(4)) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 32), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData), uint64(4)) *(*uintptr)(unsafe.Pointer(ppPage)) = *(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)) *(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)) = uintptr(0) @@ -47342,7 +46780,7 @@ __19: goto __23 __22: if !((searchList != 0) && - ((nearby == iTrunk) || ((iTrunk < nearby) && (int32(eMode) == 2)))) { + ((nearby == iTrunk) || ((iTrunk < nearby) && (int32(eMode) == BTALLOC_LE)))) { goto __24 } // The list is being searched and this trunk page is the page @@ -47363,22 +46801,22 @@ __26: if !(!(pPrevTrunk != 0)) { goto __29 } - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(32)), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(0)), uint64(4)) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 32), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData), uint64(4)) goto __30 __29: rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPrevTrunk)).FpDbPage) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __31 } goto end_allocate_page __31: ; - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData + uintptr(0)), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(0)), uint64(4)) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData), uint64(4)) __30: ; goto __28 __27: - iNewTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(8))) + iNewTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + 8)) if !(iNewTrunk > mxPage) { goto __32 } @@ -47388,29 +46826,29 @@ __32: ; rc = btreeGetUnusedPage(tls, pBt, iNewTrunk, bp+16 /* &pNewTrunk */, 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __33 } goto end_allocate_page __33: ; rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FpDbPage) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __34 } releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */))) goto end_allocate_page __34: ; - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FaData + uintptr(0)), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(0)), uint64(4)) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FaData + uintptr(4)), (k - U32(1))) - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FaData + uintptr(8)), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(12)), (uint64((k - U32(1)) * U32(4)))) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FaData), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData), uint64(4)) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FaData + 4), (k - U32(1))) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FaData + 8), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + 12), (uint64((k - U32(1)) * U32(4)))) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */))) if !(!(pPrevTrunk != 0)) { goto __35 } - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(32)), iNewTrunk) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 32), iNewTrunk) goto __36 __35: rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPrevTrunk)).FpDbPage) @@ -47420,7 +46858,7 @@ __35: goto end_allocate_page __37: ; - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData + uintptr(0)), iNewTrunk) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData), iNewTrunk) __36: ; __28: @@ -47437,7 +46875,7 @@ __24: goto __39 } closest = U32(0) - if !(int32(eMode) == 2) { + if !(int32(eMode) == BTALLOC_LE) { goto __41 } i = U32(0) @@ -47462,7 +46900,7 @@ __45: ; goto __42 __41: - dist = Xsqlite3AbsInt32(tls, (int32(Xsqlite3Get4byte(tls, (aData+uintptr(8))) - nearby))) + dist = Xsqlite3AbsInt32(tls, (int32(Xsqlite3Get4byte(tls, (aData+8)) - nearby))) i = U32(1) __47: if !(i < k) { @@ -47502,7 +46940,7 @@ __51: ; if !(!(searchList != 0) || - ((iPage == nearby) || ((iPage < nearby) && (int32(eMode) == 2)))) { + ((iPage == nearby) || ((iPage < nearby) && (int32(eMode) == BTALLOC_LE)))) { goto __52 } *(*Pgno)(unsafe.Pointer(pPgno)) = iPage @@ -47520,18 +46958,18 @@ __53: libc.Xmemcpy(tls, (aData + uintptr((U32(8) + (closest * U32(4))))), (aData + uintptr((U32(4) + (k * U32(4))))), uint64(4)) __54: ; - Xsqlite3Put4byte(tls, (aData + uintptr(4)), (k - U32(1))) + Xsqlite3Put4byte(tls, (aData + 4), (k - U32(1))) if !(btreeGetHasContent(tls, pBt, *(*Pgno)(unsafe.Pointer(pPgno))) != 0) { - noContent = 0x01 + noContent = PAGER_GET_NOCONTENT } else { noContent = 0 } rc = btreeGetUnusedPage(tls, pBt, *(*Pgno)(unsafe.Pointer(pPgno)), ppPage, noContent) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __55 } rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FpDbPage) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __56 } releasePage(tls, *(*uintptr)(unsafe.Pointer(ppPage))) @@ -47581,7 +47019,7 @@ __2: // here are confined to those pages that lie between the end of the // database image and the end of the database file. if 0 == (int32((*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate)) { - bNoContent = 0x01 + bNoContent = PAGER_GET_NOCONTENT } else { bNoContent = 0 } @@ -47610,7 +47048,7 @@ __58: *(*uintptr)(unsafe.Pointer(bp + 24 /* pPg */)) = uintptr(0) rc = btreeGetUnusedPage(tls, pBt, (*BtShared)(unsafe.Pointer(pBt)).FnPage, bp+24 /* &pPg */, bNoContent) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __60 } rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pPg */)))).FpDbPage) @@ -47643,7 +47081,7 @@ __59: __63: ; rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FpDbPage) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __64 } releasePage(tls, *(*uintptr)(unsafe.Pointer(ppPage))) @@ -47714,10 +47152,10 @@ __3: goto freepage_out __4: ; - nFree = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(36))) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(36)), (nFree + U32(1))) + nFree = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 36)) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 36), (nFree + U32(1))) - if !((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0004) != 0) { + if !((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_SECURE_DELETE) != 0) { goto __5 } // If the secure_delete option is enabled, then @@ -47738,7 +47176,7 @@ __5: if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) { goto __7 } - ptrmapPut(tls, pBt, iPage, uint8(2), uint32(0), bp+8 /* &rc */) + ptrmapPut(tls, pBt, iPage, PTRMAP_FREEPAGE, uint32(0), bp+8 /* &rc */) if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != 0) { goto __8 } @@ -47758,7 +47196,7 @@ __7: goto __9 } // Initial number of leaf cells on trunk page - iTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(32))) + iTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 32)) if !(iTrunk > btreePagecount(tls, pBt)) { goto __10 } @@ -47767,14 +47205,14 @@ __7: __10: ; *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = btreeGetPage(tls, pBt, iTrunk, bp+16 /* &pTrunk */, 0) - if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != 0) { + if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != SQLITE_OK) { goto __11 } goto freepage_out __11: ; - nLeaf = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pTrunk */)))).FaData + uintptr(4))) + nLeaf = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pTrunk */)))).FaData + 4)) if !(nLeaf > (((*BtShared)(unsafe.Pointer(pBt)).FusableSize / U32(4)) - U32(2))) { goto __12 @@ -47805,12 +47243,12 @@ __12: // order that database files created by newer versions of SQLite can be // read by older versions of SQLite. *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pTrunk */)))).FpDbPage) - if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0) { + if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK) { goto __14 } - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pTrunk */)))).FaData + uintptr(4)), (nLeaf + U32(1))) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pTrunk */)))).FaData + 4), (nLeaf + U32(1))) Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pTrunk */)))).FaData + uintptr((U32(8) + (nLeaf * U32(4))))), iPage) - if !((*(*uintptr)(unsafe.Pointer(bp /* pPage */)) != 0) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0004) == 0)) { + if !((*(*uintptr)(unsafe.Pointer(bp /* pPage */)) != 0) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_SECURE_DELETE) == 0)) { goto __15 } Xsqlite3PagerDontWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FpDbPage) @@ -47831,22 +47269,22 @@ __9: // Possibly because the free-list is empty, or possibly because the // first trunk in the free-list is full. Either way, the page being freed // will become the new first trunk page in the free-list. - if !((*(*uintptr)(unsafe.Pointer(bp /* pPage */)) == uintptr(0)) && (0 != (libc.AssignPtrInt32(bp+8 /* rc */, btreeGetPage(tls, pBt, iPage, bp /* &pPage */, 0))))) { + if !((*(*uintptr)(unsafe.Pointer(bp /* pPage */)) == uintptr(0)) && (SQLITE_OK != (libc.AssignPtrInt32(bp+8 /* rc */, btreeGetPage(tls, pBt, iPage, bp /* &pPage */, 0))))) { goto __16 } goto freepage_out __16: ; *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FpDbPage) - if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != 0) { + if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != SQLITE_OK) { goto __17 } goto freepage_out __17: ; Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FaData, iTrunk) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FaData + uintptr(4)), uint32(0)) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(32)), iPage) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FaData + 4), uint32(0)) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 32), iPage) freepage_out: if !(*(*uintptr)(unsafe.Pointer(bp /* pPage */)) != 0) { @@ -47861,7 +47299,7 @@ __18: } func freePage(tls *libc.TLS, pPage uintptr, pRC uintptr) { /* sqlite3.c:70851:13: */ - if (*(*int32)(unsafe.Pointer(pRC))) == 0 { + if (*(*int32)(unsafe.Pointer(pRC))) == SQLITE_OK { *(*int32)(unsafe.Pointer(pRC)) = freePage2(tls, (*MemPage)(unsafe.Pointer(pPage)).FpBt, pPage, (*MemPage)(unsafe.Pointer(pPage)).Fpgno) } } @@ -47880,7 +47318,7 @@ func clearCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) int32 (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer((pPage + 128 /* &.xParseCell */))))(tls, pPage, pCell, pInfo) if U32((*CellInfo)(unsafe.Pointer(pInfo)).FnLocal) == (*CellInfo)(unsafe.Pointer(pInfo)).FnPayload { - return 0 // No overflow pages. Return without doing anything + return SQLITE_OK // No overflow pages. Return without doing anything } if (pCell + uintptr((*CellInfo)(unsafe.Pointer(pInfo)).FnSize)) > (*MemPage)(unsafe.Pointer(pPage)).FaDataEnd { @@ -47933,7 +47371,7 @@ func clearCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) int32 } ovflPgno = *(*Pgno)(unsafe.Pointer(bp + 8 /* iNext */)) } - return 0 + return SQLITE_OK } // Create the byte sequence used to represent a cell on page pPage @@ -48009,7 +47447,7 @@ func fillInCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pX uintptr, pnSize libc.Xmemcpy(tls, pPayload, pSrc, uint64(nSrc)) libc.Xmemset(tls, (pPayload + uintptr(nSrc)), 0, (uint64(nPayload - nSrc))) - return 0 + return SQLITE_OK } // If we reach this point, it means that some of the content will need @@ -48086,12 +47524,12 @@ func fillInCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pX uintptr, pnSize // then the optimistic overflow chain processing in clearCell() // may misinterpret the uninitialized values and delete the // wrong pages from the database. - if ((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) && (*(*int32)(unsafe.Pointer(bp + 12 /* rc */)) == 0) { + if ((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) && (*(*int32)(unsafe.Pointer(bp + 12 /* rc */)) == SQLITE_OK) { var eType U8 = func() uint8 { if pgnoPtrmap != 0 { - return uint8(4) + return PTRMAP_OVERFLOW2 } - return uint8(3) + return PTRMAP_OVERFLOW1 }() ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* pgnoOvfl */)), eType, pgnoPtrmap, bp+12 /* &rc */) if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != 0 { @@ -48114,12 +47552,12 @@ func fillInCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pX uintptr, pnSize pToRelease = *(*uintptr)(unsafe.Pointer(bp /* pOvfl */)) pPrior = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pOvfl */)))).FaData Xsqlite3Put4byte(tls, pPrior, uint32(0)) - pPayload = ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pOvfl */)))).FaData + uintptr(4)) + pPayload = ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pOvfl */)))).FaData + 4) spaceLeft = (int32((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(4))) } } releasePage(tls, pToRelease) - return 0 + return SQLITE_OK } // Remove the i-th cell from pPage. This routine effects pPage only. @@ -48141,7 +47579,7 @@ func dropCell(tls *libc.TLS, pPage uintptr, idx int32, sz int32, pRC uintptr) { data = (*MemPage)(unsafe.Pointer(pPage)).FaData ptr = ((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr((2 * idx))) - pc = (U32((int32(*(*U8)(unsafe.Pointer((ptr) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((ptr) + uintptr(1)))))) + pc = (U32((int32(*(*U8)(unsafe.Pointer((ptr)))) << 8) | int32(*(*U8)(unsafe.Pointer((ptr) + 1))))) hdr = int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset) if (pc + U32(sz)) > (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize { @@ -48157,14 +47595,14 @@ func dropCell(tls *libc.TLS, pPage uintptr, idx int32, sz int32, pRC uintptr) { if int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) == 0 { libc.Xmemset(tls, (data + uintptr((hdr + 1))), 0, uint64(4)) *(*U8)(unsafe.Pointer(data + uintptr((hdr + 7)))) = U8(0) - *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0))) = (U8(((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) >> 8)) - *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))) = U8((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) + *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))))) = (U8(((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) >> 8)) + *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)) = U8((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) (*MemPage)(unsafe.Pointer(pPage)).FnFree = (int32((((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize - U32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)) - U32((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)) - U32(8))) } else { libc.Xmemmove(tls, ptr, (ptr + uintptr(2)), (uint64(2 * (int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - idx)))) - *(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))) + uintptr(0))) = (U8((int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)) >> 8)) - *(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))) + uintptr(1))) = U8((*MemPage)(unsafe.Pointer(pPage)).FnCell) + *(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))))) = (U8((int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)) >> 8)) + *(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))) + 1)) = U8((*MemPage)(unsafe.Pointer(pPage)).FnCell) *(*int32)(unsafe.Pointer(pPage + 20 /* &.nFree */)) += (2) } } @@ -48214,7 +47652,7 @@ func insertCell(tls *libc.TLS, pPage uintptr, i int32, pCell uintptr, sz int32, // Overflows are sequential } else { var rc int32 = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPage)).FpDbPage) - if rc != 0 { + if rc != SQLITE_OK { *(*int32)(unsafe.Pointer(pRC)) = rc return } @@ -48243,8 +47681,8 @@ func insertCell(tls *libc.TLS, pPage uintptr, i int32, pCell uintptr, sz int32, } pIns = ((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr((i * 2))) libc.Xmemmove(tls, (pIns + uintptr(2)), pIns, (uint64(2 * (int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - i)))) - *(*U8)(unsafe.Pointer((pIns) + uintptr(0))) = (U8((*(*int32)(unsafe.Pointer(bp /* idx */))) >> 8)) - *(*U8)(unsafe.Pointer((pIns) + uintptr(1))) = U8(*(*int32)(unsafe.Pointer(bp /* idx */))) + *(*U8)(unsafe.Pointer((pIns))) = (U8((*(*int32)(unsafe.Pointer(bp /* idx */))) >> 8)) + *(*U8)(unsafe.Pointer((pIns) + 1)) = U8(*(*int32)(unsafe.Pointer(bp /* idx */))) (*MemPage)(unsafe.Pointer(pPage)).FnCell++ // increment the cell count if (int32(libc.PreIncUint8(&*(*U8)(unsafe.Pointer(data + uintptr((int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset) + 4)))), 1))) == 0 { @@ -48477,13 +47915,13 @@ func rebuildPage(tls *libc.TLS, pCArray uintptr, iFirst int32, nCell int32, pPg var k int32 // Current slot in pCArray->apEnd[] var pSrcEnd uintptr // Current pCArray->apEnd[k] value - j = (U32((int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(1)))))) + j = (U32((int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + 1))))) if j > U32(usableSize) { j = U32(0) } libc.Xmemcpy(tls, (pTmp + uintptr(j)), (aData + uintptr(j)), (uint64(U32(usableSize) - j))) - for k = 0; (*(*int32)(unsafe.Pointer((pCArray + 80 /* &.ixNx */) + uintptr(k)*4)) <= i) && (k < (3 * 2)); k++ { + for k = 0; (*(*int32)(unsafe.Pointer((pCArray + 80 /* &.ixNx */) + uintptr(k)*4)) <= i) && (k < (NB * 2)); k++ { } pSrcEnd = *(*uintptr)(unsafe.Pointer((pCArray + 32 /* &.apEnd */) + uintptr(k)*8)) @@ -48503,8 +47941,8 @@ func rebuildPage(tls *libc.TLS, pCArray uintptr, iFirst int32, nCell int32, pPg } pData -= uintptr(sz) - *(*U8)(unsafe.Pointer((pCellptr) + uintptr(0))) = (U8(((int64(pData) - int64(aData)) / 1) >> 8)) - *(*U8)(unsafe.Pointer((pCellptr) + uintptr(1))) = (U8((int64(pData) - int64(aData)) / 1)) + *(*U8)(unsafe.Pointer((pCellptr))) = (U8(((int64(pData) - int64(aData)) / 1) >> 8)) + *(*U8)(unsafe.Pointer((pCellptr) + 1)) = (U8((int64(pData) - int64(aData)) / 1)) pCellptr += uintptr(2) if pData < pCellptr { return Xsqlite3CorruptError(tls, 71466) @@ -48525,14 +47963,14 @@ func rebuildPage(tls *libc.TLS, pCArray uintptr, iFirst int32, nCell int32, pPg (*MemPage)(unsafe.Pointer(pPg)).FnCell = U16(nCell) (*MemPage)(unsafe.Pointer(pPg)).FnOverflow = U8(0) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 1))) + uintptr(0))) = (U8(int32((0)) >> 8)) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 1))) + uintptr(1))) = U8(0) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))) + uintptr(0))) = (U8((int32((*MemPage)(unsafe.Pointer(pPg)).FnCell)) >> 8)) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))) + uintptr(1))) = U8((*MemPage)(unsafe.Pointer(pPg)).FnCell) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(0))) = (U8(((int64(pData) - int64(aData)) / 1) >> 8)) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(1))) = (U8((int64(pData) - int64(aData)) / 1)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 1))))) = (U8(int32((0)) >> 8)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 1))) + 1)) = U8(0) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))))) = (U8((int32((*MemPage)(unsafe.Pointer(pPg)).FnCell)) >> 8)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))) + 1)) = U8((*MemPage)(unsafe.Pointer(pPg)).FnCell) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))))) = (U8(((int64(pData) - int64(aData)) / 1) >> 8)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + 1)) = (U8((int64(pData) - int64(aData)) / 1)) *(*U8)(unsafe.Pointer(aData + uintptr((hdr + 7)))) = U8(0x00) - return 0 + return SQLITE_OK } // The pCArray objects contains pointers to b-tree cells and the cell sizes. @@ -48571,7 +48009,7 @@ func pageInsertArray(tls *libc.TLS, pPg uintptr, pBegin uintptr, ppData uintptr, if iEnd <= iFirst { return 0 } - for k = 0; (*(*int32)(unsafe.Pointer((pCArray + 80 /* &.ixNx */) + uintptr(k)*4)) <= i) && (k < (3 * 2)); k++ { + for k = 0; (*(*int32)(unsafe.Pointer((pCArray + 80 /* &.ixNx */) + uintptr(k)*4)) <= i) && (k < (NB * 2)); k++ { } pEnd = *(*uintptr)(unsafe.Pointer((pCArray + 32 /* &.apEnd */) + uintptr(k)*8)) for 1 != 0 { @@ -48581,7 +48019,7 @@ func pageInsertArray(tls *libc.TLS, pPg uintptr, pBegin uintptr, ppData uintptr, var pSlot uintptr sz = int32(*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(pCArray)).FszCell + uintptr(i)*2))) - if ((int32(*(*U8)(unsafe.Pointer(aData + uintptr(1)))) == 0) && (int32(*(*U8)(unsafe.Pointer(aData + uintptr(2)))) == 0)) || ((libc.AssignUintptr(&pSlot, pageFindSlot(tls, pPg, sz, bp /* &rc */))) == uintptr(0)) { + if ((int32(*(*U8)(unsafe.Pointer(aData + 1))) == 0) && (int32(*(*U8)(unsafe.Pointer(aData + 2))) == 0)) || ((libc.AssignUintptr(&pSlot, pageFindSlot(tls, pPg, sz, bp /* &rc */))) == uintptr(0)) { if ((int64(pData) - int64(pBegin)) / 1) < int64(sz) { return 1 } @@ -48599,8 +48037,8 @@ func pageInsertArray(tls *libc.TLS, pPg uintptr, pBegin uintptr, ppData uintptr, return 1 } libc.Xmemmove(tls, pSlot, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*8)), uint64(sz)) - *(*U8)(unsafe.Pointer((pCellptr) + uintptr(0))) = (U8(((int64(pSlot) - int64(aData)) / 1) >> 8)) - *(*U8)(unsafe.Pointer((pCellptr) + uintptr(1))) = (U8((int64(pSlot) - int64(aData)) / 1)) + *(*U8)(unsafe.Pointer((pCellptr))) = (U8(((int64(pSlot) - int64(aData)) / 1) >> 8)) + *(*U8)(unsafe.Pointer((pCellptr) + 1)) = (U8((int64(pSlot) - int64(aData)) / 1)) pCellptr += uintptr(2) i++ if i >= iEnd { @@ -48724,7 +48162,7 @@ __1: __3: ; - *(*uintptr)(unsafe.Pointer(bp /* pData */)) = (aData + uintptr((((((int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(1))))) - 1) & 0xffff) + 1))) + *(*uintptr)(unsafe.Pointer(bp /* pData */)) = (aData + uintptr((((((int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + 1)))) - 1) & 0xffff) + 1))) if !(*(*uintptr)(unsafe.Pointer(bp /* pData */)) < pBegin) { goto __4 } @@ -48771,7 +48209,7 @@ __7: if !(nCell > iCell) { goto __11 } - libc.Xmemmove(tls, (pCellptr + uintptr(2)), pCellptr, (uint64((nCell - iCell) * 2))) + libc.Xmemmove(tls, (pCellptr + 2), pCellptr, (uint64((nCell - iCell) * 2))) __11: ; nCell++ @@ -48809,12 +48247,12 @@ __13: (*MemPage)(unsafe.Pointer(pPg)).FnCell = U16(nNew) (*MemPage)(unsafe.Pointer(pPg)).FnOverflow = U8(0) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))) + uintptr(0))) = (U8((int32((*MemPage)(unsafe.Pointer(pPg)).FnCell)) >> 8)) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))) + uintptr(1))) = U8((*MemPage)(unsafe.Pointer(pPg)).FnCell) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(0))) = (U8(((int64(*(*uintptr)(unsafe.Pointer(bp /* pData */))) - int64(aData)) / 1) >> 8)) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(1))) = (U8((int64(*(*uintptr)(unsafe.Pointer(bp /* pData */))) - int64(aData)) / 1)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))))) = (U8((int32((*MemPage)(unsafe.Pointer(pPg)).FnCell)) >> 8)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))) + 1)) = U8((*MemPage)(unsafe.Pointer(pPg)).FnCell) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))))) = (U8(((int64(*(*uintptr)(unsafe.Pointer(bp /* pData */))) - int64(aData)) / 1) >> 8)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + 1)) = (U8((int64(*(*uintptr)(unsafe.Pointer(bp /* pData */))) - int64(aData)) / 1)) - return 0 + return SQLITE_OK editpage_fail: // Unable to edit this page. Rebuild it from scratch instead. populateCellCache(tls, pCArray, iNew, nNew) @@ -48863,21 +48301,21 @@ func balance_quick(tls *libc.TLS, pParent uintptr, pPage uintptr, pSpace uintptr // may be inserted. If both these operations are successful, proceed. *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) = allocateBtreePage(tls, pBt, bp /* &pNew */, bp+8 /* &pgnoNew */, uint32(0), uint8(0)) - if *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) == SQLITE_OK { - var pOut uintptr = (pSpace + uintptr(4)) - *(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) = *(*uintptr)(unsafe.Pointer((pPage + 40 /* &.apOvfl */) + uintptr(0)*8)) + var pOut uintptr = (pSpace + 4) + *(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) = *(*uintptr)(unsafe.Pointer((pPage + 40 /* &.apOvfl */))) *(*U16)(unsafe.Pointer(bp + 24 /* szCell */)) = (*(*func(*libc.TLS, uintptr, uintptr) U16)(unsafe.Pointer((pPage + 120 /* &.xCellSize */))))(tls, pPage, *(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */))) var pStop uintptr // var b CellArray at bp+32, 104 - zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */)), ((0x01 | 0x04) | 0x08)) + zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */)), ((PTF_INTKEY | PTF_LEAFDATA) | PTF_LEAF)) (*CellArray)(unsafe.Pointer(bp + 32 /* &b */)).FnCell = 1 (*CellArray)(unsafe.Pointer(bp + 32 /* &b */)).FpRef = pPage (*CellArray)(unsafe.Pointer(bp + 32 /* &b */)).FapCell = bp + 16 /* &pCell */ (*CellArray)(unsafe.Pointer(bp + 32 /* &b */)).FszCell = bp + 24 /* &szCell */ - *(*uintptr)(unsafe.Pointer((bp + 32 /* &b */ + 32 /* &.apEnd */) + uintptr(0)*8)) = (*MemPage)(unsafe.Pointer(pPage)).FaDataEnd - *(*int32)(unsafe.Pointer((bp + 32 /* &b */ + 80 /* &.ixNx */) + uintptr(0)*4)) = 2 + *(*uintptr)(unsafe.Pointer((bp + 32 /* &b */ + 32 /* &.apEnd */))) = (*MemPage)(unsafe.Pointer(pPage)).FaDataEnd + *(*int32)(unsafe.Pointer((bp + 32 /* &b */ + 80 /* &.ixNx */))) = 2 *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) = rebuildPage(tls, bp+32 /* &b */, 0, 1, *(*uintptr)(unsafe.Pointer(bp /* pNew */))) if *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) != 0 { releasePage(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */))) @@ -48894,7 +48332,7 @@ func balance_quick(tls *libc.TLS, pParent uintptr, pPage uintptr, pSpace uintptr // be marked as dirty. Returning an error code will cause a // rollback, undoing any changes made to the parent page. if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { - ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* pgnoNew */)), uint8(5), (*MemPage)(unsafe.Pointer(pParent)).Fpgno, bp+136 /* &rc */) + ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* pgnoNew */)), PTRMAP_BTREE, (*MemPage)(unsafe.Pointer(pParent)).Fpgno, bp+136 /* &rc */) if int32(*(*U16)(unsafe.Pointer(bp + 24 /* szCell */))) > int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pNew */)))).FminLocal) { ptrmapPutOvflPtr(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */)), *(*uintptr)(unsafe.Pointer(bp /* pNew */)), *(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)), bp+136 /* &rc */) } @@ -48913,15 +48351,15 @@ func balance_quick(tls *libc.TLS, pParent uintptr, pPage uintptr, pSpace uintptr // field. The second while(...) loop copies the key value from the // cell on pPage into the pSpace buffer. *(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) = ((*MemPage)(unsafe.Pointer((pPage))).FaData + uintptr((int32((*MemPage)(unsafe.Pointer((pPage))).FmaskPage) & int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(((*MemPage)(unsafe.Pointer((pPage))).FaCellIdx + uintptr((2 * (int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - 1))))))))))) - pStop = (*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) + uintptr(9)) + pStop = (*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) + 9) for ((int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)), 1)))) & 0x80) != 0) && (*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) < pStop) { } - pStop = (*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) + uintptr(9)) + pStop = (*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) + 9) for (((int32(libc.AssignPtrUint8(libc.PostIncUintptr(&pOut, 1), *(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)), 1)))))) & 0x80) != 0) && (*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) < pStop) { } // Insert the new divider cell into pParent. - if *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) == SQLITE_OK { insertCell(tls, pParent, int32((*MemPage)(unsafe.Pointer(pParent)).FnCell), pSpace, (int32((int64(pOut) - int64(pSpace)) / 1)), uintptr(0), (*MemPage)(unsafe.Pointer(pPage)).Fpgno, bp+136 /* &rc */) } @@ -48952,7 +48390,7 @@ func balance_quick(tls *libc.TLS, pParent uintptr, pPage uintptr, pSpace uintptr // the balance_shallower() and balance_deeper() procedures, neither of // which are called often under normal circumstances. func copyNodeContent(tls *libc.TLS, pFrom uintptr, pTo uintptr, pRC uintptr) { /* sqlite3.c:71918:13: */ - if (*(*int32)(unsafe.Pointer(pRC))) == 0 { + if (*(*int32)(unsafe.Pointer(pRC))) == SQLITE_OK { var pBt uintptr = (*MemPage)(unsafe.Pointer(pFrom)).FpBt var aFrom uintptr = (*MemPage)(unsafe.Pointer(pFrom)).FaData var aTo uintptr = (*MemPage)(unsafe.Pointer(pTo)).FaData @@ -48967,7 +48405,7 @@ func copyNodeContent(tls *libc.TLS, pFrom uintptr, pTo uintptr, pRC uintptr) { / var iData int32 // Copy the b-tree node content from page pFrom to page pTo. - iData = ((int32(*(*U8)(unsafe.Pointer((aFrom + uintptr((iFromHdr + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aFrom + uintptr((iFromHdr + 5))) + uintptr(1))))) + iData = ((int32(*(*U8)(unsafe.Pointer((aFrom + uintptr((iFromHdr + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((aFrom + uintptr((iFromHdr + 5))) + 1)))) libc.Xmemcpy(tls, (aTo + uintptr(iData)), (aFrom + uintptr(iData)), (uint64((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(iData)))) libc.Xmemcpy(tls, (aTo + uintptr(iToHdr)), (aFrom + uintptr(iFromHdr)), (uint64(int32((*MemPage)(unsafe.Pointer(pFrom)).FcellOffset) + (2 * int32((*MemPage)(unsafe.Pointer(pFrom)).FnCell))))) @@ -48977,10 +48415,10 @@ func copyNodeContent(tls *libc.TLS, pFrom uintptr, pTo uintptr, pRC uintptr) { / // page pFrom. (*MemPage)(unsafe.Pointer(pTo)).FisInit = U8(0) rc = btreeInitPage(tls, pTo) - if rc == 0 { + if rc == SQLITE_OK { rc = btreeComputeFreeSpace(tls, pTo) } - if rc != 0 { + if rc != SQLITE_OK { *(*int32)(unsafe.Pointer(pRC)) = rc return } @@ -49120,7 +48558,7 @@ func balance_nonroot(tls *libc.TLS, pParent uintptr, iParentIdx int32, aOvflSpac var key U32 nMaxCells = 0 nNew = 0 - *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = SQLITE_OK iSpace1 = 0 iOvflSpace = 0 // Parsed information on cells being balanced @@ -49137,7 +48575,7 @@ func balance_nonroot(tls *libc.TLS, pParent uintptr, iParentIdx int32, aOvflSpac if !(!(aOvflSpace != 0)) { goto __1 } - return 7 + return SQLITE_NOMEM __1: ; @@ -49222,10 +48660,10 @@ __13: __15: ; - if !(((*MemPage)(unsafe.Pointer(pParent)).FnOverflow != 0) && ((i + nxDiv) == int32(*(*U16)(unsafe.Pointer((pParent + 28 /* &.aiOvfl */) + uintptr(0)*2))))) { + if !(((*MemPage)(unsafe.Pointer(pParent)).FnOverflow != 0) && ((i + nxDiv) == int32(*(*U16)(unsafe.Pointer((pParent + 28 /* &.aiOvfl */)))))) { goto __16 } - *(*uintptr)(unsafe.Pointer(bp + 32 /* &apDiv[0] */ + uintptr(i)*8)) = *(*uintptr)(unsafe.Pointer((pParent + 40 /* &.apOvfl */) + uintptr(0)*8)) + *(*uintptr)(unsafe.Pointer(bp + 32 /* &apDiv[0] */ + uintptr(i)*8)) = *(*uintptr)(unsafe.Pointer((pParent + 40 /* &.apOvfl */))) *(*Pgno)(unsafe.Pointer(bp + 272 /* pgno */)) = Xsqlite3Get4byte(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &apDiv[0] */ + uintptr(i)*8))) *(*int32)(unsafe.Pointer(bp + 48 /* &szNew[0] */ + uintptr(i)*4)) = int32((*(*func(*libc.TLS, uintptr, uintptr) U16)(unsafe.Pointer((pParent + 120 /* &.xCellSize */))))(tls, pParent, *(*uintptr)(unsafe.Pointer(bp + 32 /* &apDiv[0] */ + uintptr(i)*8)))) (*MemPage)(unsafe.Pointer(pParent)).FnOverflow = U8(0) @@ -49247,7 +48685,7 @@ __16: // In this case, temporarily copy the cell into the aOvflSpace[] // buffer. It will be copied out again as soon as the aSpace[] buffer // is allocated. - if !((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x000c) != 0) { + if !((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_FAST_SECURE) != 0) { goto __18 } @@ -49276,7 +48714,7 @@ __11: // Make nMaxCells a multiple of 4 in order to preserve 8-byte // alignment nMaxCells = (int32(U32(nOld) * ((((*BtShared)(unsafe.Pointer(pBt)).FpageSize - U32(8)) / U32(6)) + (U32((int32(uint64(unsafe.Sizeof([4]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))))))))) - nMaxCells = ((nMaxCells + 3) & ^libc.Int32(3)) + nMaxCells = ((nMaxCells + 3) & libc.CplInt32(3)) // Allocate space for memory structures szScratch = (int32(((uint64(nMaxCells) * uint64(unsafe.Sizeof(uintptr(0)))) + // b.apCell @@ -49287,7 +48725,7 @@ __11: if !((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FapCell == uintptr(0)) { goto __21 } - *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = SQLITE_NOMEM goto balance_cleanup __21: ; @@ -49308,7 +48746,7 @@ __21: // // leafCorrection: 4 if pPage is a leaf. 0 if pPage is not a leaf. // leafData: 1 if pPage holds key+data and pParent holds only keys. - (*CellArray)(unsafe.Pointer(bp + 96 /* &b */)).FpRef = *(*uintptr)(unsafe.Pointer(bp + 8 /* &apOld[0] */ + uintptr(0)*8)) + (*CellArray)(unsafe.Pointer(bp + 96 /* &b */)).FpRef = *(*uintptr)(unsafe.Pointer(bp + 8 /* &apOld[0] */)) leafCorrection = (U16(int32((*MemPage)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FpRef)).Fleaf) * 4)) leafData = int32((*MemPage)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp + 96 /* &b */)).FpRef)).FintKeyLeaf) i = 0 @@ -49324,7 +48762,7 @@ __22: // Verify that all sibling pages are of the same "type" (table-leaf, // table-interior, index-leaf, or index-interior). - if !(int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pOld)).FaData + uintptr(0)))) != int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* &apOld[0] */ + uintptr(0)*8)))).FaData + uintptr(0))))) { + if !(int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pOld)).FaData))) != int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* &apOld[0] */)))).FaData)))) { goto __25 } *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = Xsqlite3CorruptError(tls, 72197) @@ -49352,14 +48790,14 @@ __25: if !(int32((*MemPage)(unsafe.Pointer(pOld)).FnOverflow) > 0) { goto __26 } - if !(limit < int32(*(*U16)(unsafe.Pointer((pOld + 28 /* &.aiOvfl */) + uintptr(0)*2)))) { + if !(limit < int32(*(*U16)(unsafe.Pointer((pOld + 28 /* &.aiOvfl */))))) { goto __27 } *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = Xsqlite3CorruptError(tls, 72221) goto balance_cleanup __27: ; - limit = int32(*(*U16)(unsafe.Pointer((pOld + 28 /* &.aiOvfl */) + uintptr(0)*2))) + limit = int32(*(*U16)(unsafe.Pointer((pOld + 28 /* &.aiOvfl */)))) j = 0 __28: if !(j < limit) { @@ -49425,7 +48863,7 @@ __35: // The right pointer of the child page pOld becomes the left // pointer of the divider cell - libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FapCell + uintptr((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FnCell)*8)), ((*MemPage)(unsafe.Pointer(pOld)).FaData + uintptr(8)), uint64(4)) + libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FapCell + uintptr((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FnCell)*8)), ((*MemPage)(unsafe.Pointer(pOld)).FaData + 8), uint64(4)) goto __38 __37: ; @@ -49529,7 +48967,7 @@ __52: goto __54 } k = (i + 2) - if !(k > (3 + 2)) { + if !(k > (NB + 2)) { goto __55 } *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = Xsqlite3CorruptError(tls, 72322) @@ -49699,7 +49137,7 @@ __70: // that page. // Allocate k new pages. Reuse old pages where possible. - pageFlags = int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* &apOld[0] */ + uintptr(0)*8)))).FaData + uintptr(0)))) + pageFlags = int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* &apOld[0] */)))).FaData))) i = 0 __76: if !(i < k) { @@ -49742,8 +49180,8 @@ __82: if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) { goto __83 } - ptrmapPut(tls, pBt, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 264 /* pNew */)))).Fpgno, uint8(5), (*MemPage)(unsafe.Pointer(pParent)).Fpgno, bp+68 /* &rc */) - if !(*(*int32)(unsafe.Pointer(bp + 68 /* rc */)) != 0) { + ptrmapPut(tls, pBt, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 264 /* pNew */)))).Fpgno, PTRMAP_BTREE, (*MemPage)(unsafe.Pointer(pParent)).Fpgno, bp+68 /* &rc */) + if !(*(*int32)(unsafe.Pointer(bp + 68 /* rc */)) != SQLITE_OK) { goto __84 } goto balance_cleanup @@ -49863,7 +49301,7 @@ __94: // If the sibling pages are not leaves, ensure that the right-child pointer // of the right-most new sibling page is set to the value that was // originally in the same field of the right-most old sibling page. - if !(((pageFlags & 0x08) == 0) && (nOld != nNew)) { + if !(((pageFlags & PTF_LEAF) == 0) && (nOld != nNew)) { goto __101 } pOld1 = *(*uintptr)(unsafe.Pointer(func() uintptr { @@ -49872,7 +49310,7 @@ __94: } return bp + 8 /* &apOld[0] */ }() + uintptr((nOld-1))*8)) - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr((nNew-1))*8)))).FaData + uintptr(8)), ((*MemPage)(unsafe.Pointer(pOld1)).FaData + uintptr(8)), uint64(4)) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr((nNew-1))*8)))).FaData + 8), ((*MemPage)(unsafe.Pointer(pOld1)).FaData + 8), uint64(4)) __101: ; @@ -49894,7 +49332,7 @@ __101: if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) { goto __102 } - pNew1 = libc.AssignUintptr(&pOld2, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(0)*8))) + pNew1 = libc.AssignUintptr(&pOld2, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */))) cntOldNext = (int32((*MemPage)(unsafe.Pointer(pNew1)).FnCell) + int32((*MemPage)(unsafe.Pointer(pNew1)).FnOverflow)) iNew = 0 iOld = 0 @@ -49947,7 +49385,7 @@ __108: if !(!(leafCorrection != 0)) { goto __111 } - ptrmapPut(tls, pBt, Xsqlite3Get4byte(tls, pCell), uint8(5), (*MemPage)(unsafe.Pointer(pNew1)).Fpgno, bp+68 /* &rc */) + ptrmapPut(tls, pBt, Xsqlite3Get4byte(tls, pCell), PTRMAP_BTREE, (*MemPage)(unsafe.Pointer(pNew1)).Fpgno, bp+68 /* &rc */) __111: ; if !(int32(cachedCellSize(tls, bp+96 /* &b */, i)) > int32((*MemPage)(unsafe.Pointer(pNew1)).FminLocal)) { @@ -49989,7 +49427,7 @@ __114: if !(!(int32((*MemPage)(unsafe.Pointer(pNew2)).Fleaf) != 0)) { goto __117 } - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pNew2)).FaData + uintptr(8)), pCell1, uint64(4)) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pNew2)).FaData + 8), pCell1, uint64(4)) goto __118 __117: if !(leafData != 0) { @@ -49998,7 +49436,7 @@ __117: j-- (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer((pNew2 + 128 /* &.xParseCell */))))(tls, pNew2, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FapCell + uintptr(j)*8)), bp+328 /* &info */) pCell1 = pTemp1 - sz2 = (4 + Xsqlite3PutVarint(tls, (pCell1+uintptr(4)), uint64((*CellInfo)(unsafe.Pointer(bp+328 /* &info */)).FnKey))) + sz2 = (4 + Xsqlite3PutVarint(tls, (pCell1+4), uint64((*CellInfo)(unsafe.Pointer(bp+328 /* &info */)).FnKey))) pTemp1 = uintptr(0) goto __120 __119: @@ -50027,7 +49465,7 @@ __118: iOvflSpace = iOvflSpace + (sz2) insertCell(tls, pParent, (nxDiv + i), pCell1, sz2, pTemp1, (*MemPage)(unsafe.Pointer(pNew2)).Fpgno, bp+68 /* &rc */) - if !(*(*int32)(unsafe.Pointer(bp + 68 /* rc */)) != 0) { + if !(*(*int32)(unsafe.Pointer(bp + 68 /* rc */)) != SQLITE_OK) { goto __122 } goto balance_cleanup @@ -50095,7 +49533,7 @@ __126: goto __128 } iNew1 = libc.AssignInt32(&iOld1, 0) - nNewCell = *(*int32)(unsafe.Pointer(bp + 200 /* &cntNew[0] */ + uintptr(0)*4)) + nNewCell = *(*int32)(unsafe.Pointer(bp + 200 /* &cntNew[0] */)) goto __129 __128: if iPg < nOld { @@ -50130,7 +49568,7 @@ __125: // All pages have been processed exactly once - if !(((isRoot != 0) && (int32((*MemPage)(unsafe.Pointer(pParent)).FnCell) == 0)) && (int32((*MemPage)(unsafe.Pointer(pParent)).FhdrOffset) <= (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(0)*8)))).FnFree)) { + if !(((isRoot != 0) && (int32((*MemPage)(unsafe.Pointer(pParent)).FnCell) == 0)) && (int32((*MemPage)(unsafe.Pointer(pParent)).FhdrOffset) <= (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */)))).FnFree)) { goto __131 } // The root page of the b-tree now contains no cells. The only sibling @@ -50148,10 +49586,10 @@ __125: // by smaller than the child due to the database header, and so all the // free space needs to be up front. - *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = defragmentPage(tls, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(0)*8)), -1) + *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = defragmentPage(tls, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */)), -1) - copyNodeContent(tls, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(0)*8)), pParent, bp+68 /* &rc */) - freePage(tls, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(0)*8)), bp+68 /* &rc */) + copyNodeContent(tls, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */)), pParent, bp+68 /* &rc */) + freePage(tls, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */)), bp+68 /* &rc */) goto __132 __131: if !(((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) && !(leafCorrection != 0)) { @@ -50165,8 +49603,8 @@ __134: if !(i < nNew) { goto __136 } - key = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(i)*8)))).FaData + uintptr(8))) - ptrmapPut(tls, pBt, key, uint8(5), (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(i)*8)))).Fpgno, bp+68 /* &rc */) + key = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(i)*8)))).FaData + 8)) + ptrmapPut(tls, pBt, key, PTRMAP_BTREE, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(i)*8)))).Fpgno, bp+68 /* &rc */) goto __135 __135: i++ @@ -50258,11 +49696,11 @@ func balance_deeper(tls *libc.TLS, pRoot uintptr, ppChild uintptr) int32 { /* sq // page that will become the new right-child of pPage. Copy the contents // of the node stored on pRoot into the new child page. *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pRoot)).FpDbPage) - if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) = allocateBtreePage(tls, pBt, bp /* &pChild */, bp+8 /* &pgnoChild */, (*MemPage)(unsafe.Pointer(pRoot)).Fpgno, uint8(0)) copyNodeContent(tls, pRoot, *(*uintptr)(unsafe.Pointer(bp /* pChild */)), bp+12 /* &rc */) if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { - ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* pgnoChild */)), uint8(5), (*MemPage)(unsafe.Pointer(pRoot)).Fpgno, bp+12 /* &rc */) + ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* pgnoChild */)), PTRMAP_BTREE, (*MemPage)(unsafe.Pointer(pRoot)).Fpgno, bp+12 /* &rc */) } } if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != 0 { @@ -50279,11 +49717,11 @@ func balance_deeper(tls *libc.TLS, pRoot uintptr, ppChild uintptr) int32 { /* sq (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pChild */)))).FnOverflow = (*MemPage)(unsafe.Pointer(pRoot)).FnOverflow // Zero the contents of pRoot. Then install pChild as the right-child. - zeroPage(tls, pRoot, (int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pChild */)))).FaData + uintptr(0)))) & ^libc.Int32(0x08))) + zeroPage(tls, pRoot, (int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pChild */)))).FaData))) & libc.CplInt32(PTF_LEAF))) Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pRoot)).FaData + uintptr((int32((*MemPage)(unsafe.Pointer(pRoot)).FhdrOffset) + 8))), *(*Pgno)(unsafe.Pointer(bp + 8 /* pgnoChild */))) *(*uintptr)(unsafe.Pointer(ppChild)) = *(*uintptr)(unsafe.Pointer(bp /* pChild */)) - return 0 + return SQLITE_OK } // Return SQLITE_CORRUPT if any cursor other than pCur is currently valid @@ -50299,12 +49737,12 @@ func anotherValidCursor(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:72844: var pOther uintptr for pOther = (*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FpCursor; pOther != 0; pOther = (*BtCursor)(unsafe.Pointer(pOther)).FpNext { if ((pOther != pCur) && - (int32((*BtCursor)(unsafe.Pointer(pOther)).FeState) == 0)) && + (int32((*BtCursor)(unsafe.Pointer(pOther)).FeState) == CURSOR_VALID)) && ((*BtCursor)(unsafe.Pointer(pOther)).FpPage == (*BtCursor)(unsafe.Pointer(pCur)).FpPage) { return Xsqlite3CorruptError(tls, 72851) } } - return 0 + return SQLITE_OK } // The page that pCur currently points to has just been modified in @@ -50319,13 +49757,13 @@ func balance(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:72867:12: */ bp := tls.Alloc(13) defer tls.Free(13) - var rc int32 = 0 + var rc int32 = SQLITE_OK var nMin int32 = (int32(((*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FusableSize * U32(2)) / U32(3))) // var aBalanceQuickSpace [13]U8 at bp, 13 var pFree uintptr = uintptr(0) - for ok := true; ok; ok = (rc == 0) { + for ok := true; ok; ok = (rc == SQLITE_OK) { var iPage int32 var pPage uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpPage @@ -50335,19 +49773,19 @@ func balance(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:72867:12: */ if (int32((*MemPage)(unsafe.Pointer(pPage)).FnOverflow) == 0) && ((*MemPage)(unsafe.Pointer(pPage)).FnFree <= nMin) { break } else if (libc.AssignInt32(&iPage, int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage))) == 0 { - if ((*MemPage)(unsafe.Pointer(pPage)).FnOverflow != 0) && ((libc.AssignInt32(&rc, anotherValidCursor(tls, pCur))) == 0) { + if ((*MemPage)(unsafe.Pointer(pPage)).FnOverflow != 0) && ((libc.AssignInt32(&rc, anotherValidCursor(tls, pCur))) == SQLITE_OK) { // The root page of the b-tree is overfull. In this case call the // balance_deeper() function to create a new child for the root-page // and copy the current contents of the root-page to it. The // next iteration of the do-loop will balance the child page. - rc = balance_deeper(tls, pPage, ((pCur + 144 /* &.apPage */) + uintptr(1)*8)) - if rc == 0 { + rc = balance_deeper(tls, pPage, ((pCur + 144 /* &.apPage */) + 1*8)) + if rc == SQLITE_OK { (*BtCursor)(unsafe.Pointer(pCur)).FiPage = int8(1) (*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(0) - *(*U16)(unsafe.Pointer((pCur + 88 /* &.aiIdx */) + uintptr(0)*2)) = U16(0) - *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */) + uintptr(0)*8)) = pPage - (*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */) + uintptr(1)*8)) + *(*U16)(unsafe.Pointer((pCur + 88 /* &.aiIdx */))) = U16(0) + *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */))) = pPage + (*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */) + 1*8)) } } else { @@ -50358,13 +49796,13 @@ func balance(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:72867:12: */ var iIdx int32 = int32(*(*U16)(unsafe.Pointer((pCur + 88 /* &.aiIdx */) + uintptr((iPage-1))*2))) rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pParent)).FpDbPage) - if (rc == 0) && ((*MemPage)(unsafe.Pointer(pParent)).FnFree < 0) { + if (rc == SQLITE_OK) && ((*MemPage)(unsafe.Pointer(pParent)).FnFree < 0) { rc = btreeComputeFreeSpace(tls, pParent) } - if rc == 0 { + if rc == SQLITE_OK { if (((((*MemPage)(unsafe.Pointer(pPage)).FintKeyLeaf != 0) && (int32((*MemPage)(unsafe.Pointer(pPage)).FnOverflow) == 1)) && - (int32(*(*U16)(unsafe.Pointer((pPage + 28 /* &.aiOvfl */) + uintptr(0)*2))) == int32((*MemPage)(unsafe.Pointer(pPage)).FnCell))) && + (int32(*(*U16)(unsafe.Pointer((pPage + 28 /* &.aiOvfl */)))) == int32((*MemPage)(unsafe.Pointer(pPage)).FnCell))) && ((*MemPage)(unsafe.Pointer(pParent)).Fpgno != Pgno(1))) && (int32((*MemPage)(unsafe.Pointer(pParent)).FnCell) == iIdx) { // Call balance_quick() to create a new sibling of pPage on which @@ -50400,7 +49838,7 @@ func balance(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:72867:12: */ // pSpace buffer passed to the latter call to balance_nonroot(). var pSpace uintptr = Xsqlite3PageMalloc(tls, int32((*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FpageSize)) rc = balance_nonroot(tls, pParent, iIdx, pSpace, (libc.Bool32(iPage == 1)), - (int32((*BtCursor)(unsafe.Pointer(pCur)).Fhints) & 0x00000001)) + (int32((*BtCursor)(unsafe.Pointer(pCur)).Fhints) & BTREE_BULKLOAD)) if pFree != 0 { // If pFree is not NULL, it points to the pSpace buffer used // by a previous call to balance_nonroot(). Its contents are @@ -50471,7 +49909,7 @@ func btreeOverwriteContent(tls *libc.TLS, pPage uintptr, pDest uintptr, pX uintp libc.Xmemmove(tls, pDest, (((*BtreePayload)(unsafe.Pointer(pX)).FpData) + uintptr(iOffset)), uint64(iAmt)) } } - return 0 + return SQLITE_OK } // Overwrite the cell that cursor pCur is pointing to with fresh content @@ -50499,7 +49937,7 @@ func btreeOverwriteCell(tls *libc.TLS, pCur uintptr, pX uintptr) int32 { /* sqli return rc } if int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) == nTotal { - return 0 + return SQLITE_OK } // Now overwrite the overflow pages @@ -50530,7 +49968,7 @@ func btreeOverwriteCell(tls *libc.TLS, pCur uintptr, pX uintptr) int32 { /* sqli } iOffset = int32(U32(iOffset) + (ovflPageSize)) } - return 0 + return SQLITE_OK } // Insert a new record into the BTree. The content of the new record @@ -50588,7 +50026,7 @@ func Xsqlite3BtreeInsert(tls *libc.TLS, pCur uintptr, pX uintptr, flags int32, s pBt = (*Btree)(unsafe.Pointer(p)).FpBt newCell = uintptr(0) - if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 4) { + if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_FAULT) { goto __1 } @@ -50612,7 +50050,7 @@ __1: // that the cursor is already where it needs to be and returns without // doing any work. To avoid thwarting these optimizations, it is important // not to clear the cursor here. - if !((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x20) != 0) { + if !((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_Multiple) != 0) { goto __2 } *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = saveAllCursors(tls, pBt, (*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, pCur) @@ -50639,7 +50077,7 @@ __2: // On the other hand, BTREE_SAVEPOSITION==0 does not imply // that the cursor is not pointing to a row to be overwritten. // So do a complete check. - if !(((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x02) != 0) && ((*BtreePayload)(unsafe.Pointer(pX)).FnKey == (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey)) { + if !(((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_ValidNKey) != 0) && ((*BtreePayload)(unsafe.Pointer(pX)).FnKey == (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey)) { goto __6 } // The cursor is pointing to the entry that is to be @@ -50685,7 +50123,7 @@ __4: // overwritten, or if a new cell is being inserted, if the cursor is // not pointing to an immediately adjacent cell, then move the cursor // so that it does. - if !((*(*int32)(unsafe.Pointer(bp /* loc */)) == 0) && ((flags & 0x02) == 0)) { + if !((*(*int32)(unsafe.Pointer(bp /* loc */)) == 0) && ((flags & BTREE_SAVEPOSITION) == 0)) { goto __11 } if !((*BtreePayload)(unsafe.Pointer(pX)).FnMem != 0) { @@ -50741,7 +50179,7 @@ __5: if !((*MemPage)(unsafe.Pointer(pPage)).FnFree < 0) { goto __17 } - if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) > 1) { + if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) > CURSOR_INVALID) { goto __18 } *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = Xsqlite3CorruptError(tls, 73263) @@ -50790,7 +50228,7 @@ __25: ; *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = clearCell(tls, pPage, oldCell, bp+88 /* &info */) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x04))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_ValidOvfl))) if !(((int32((*CellInfo)(unsafe.Pointer(bp+88 /* &info */)).FnSize) == *(*int32)(unsafe.Pointer(bp + 80 /* szNew */))) && (U32((*CellInfo)(unsafe.Pointer(bp+88 /* &info */)).FnLocal) == (*CellInfo)(unsafe.Pointer(bp+88 /* &info */)).FnPayload)) && (!(int32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum) != 0) || (*(*int32)(unsafe.Pointer(bp + 80 /* szNew */)) < int32((*MemPage)(unsafe.Pointer(pPage)).FminLocal)))) { goto __26 @@ -50818,7 +50256,7 @@ __27: __28: ; libc.Xmemcpy(tls, oldCell, newCell, uint64(*(*int32)(unsafe.Pointer(bp + 80 /* szNew */)))) - return 0 + return SQLITE_OK __26: ; dropCell(tls, pPage, idx, int32((*CellInfo)(unsafe.Pointer(bp+88 /* &info */)).FnSize), bp+112 /* &rc */) @@ -50835,7 +50273,7 @@ __22: } idx = int32(libc.PreIncUint16(&(*BtCursor)(unsafe.Pointer(pCur)).Fix, 1)) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x02))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_ValidNKey))) goto __31 __30: ; @@ -50869,7 +50307,7 @@ __23: goto __32 } - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x02))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_ValidNKey))) *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = balance(tls, pCur) // Must make sure nOverflow is reset to zero even if the balance() @@ -50877,8 +50315,8 @@ __23: // Also, set the cursor state to invalid. This stops saveCursorPosition() // from trying to save the current position of the cursor. (*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FnOverflow = U8(0) - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) - if !(((flags & 0x02) != 0) && (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == 0)) { + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID + if !(((flags & BTREE_SAVEPOSITION) != 0) && (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK)) { goto __33 } btreeReleaseAllCursorPages(tls, pCur) @@ -50890,7 +50328,7 @@ __23: if !((*BtCursor)(unsafe.Pointer(pCur)).FpKey == uintptr(0)) { goto __35 } - *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = SQLITE_NOMEM goto __36 __35: libc.Xmemcpy(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpKey, (*BtreePayload)(unsafe.Pointer(pX)).FpKey, uint64((*BtreePayload)(unsafe.Pointer(pX)).FnKey)) @@ -50898,7 +50336,7 @@ __36: ; __34: ; - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(3) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_REQUIRESEEK (*BtCursor)(unsafe.Pointer(pCur)).FnKey = (*BtreePayload)(unsafe.Pointer(pX)).FnKey __33: ; @@ -50938,10 +50376,10 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit var iCellDepth int32 // Depth of node containing pCell // var info CellInfo at bp, 24 // Size of the cell being deleted - var bSkipnext int32 = 0 // Leaf cursor in SKIPNEXT state - var bPreserve U8 = (U8(int32(flags) & 0x02)) // Keep cursor valid + var bSkipnext int32 = 0 // Leaf cursor in SKIPNEXT state + var bPreserve U8 = (U8(int32(flags) & BTREE_SAVEPOSITION)) // Keep cursor valid - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 3 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_REQUIRESEEK { *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = btreeRestoreCursorPosition(tls, pCur) if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) @@ -50953,7 +50391,7 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage pCell = ((*MemPage)(unsafe.Pointer((pPage))).FaData + uintptr((int32((*MemPage)(unsafe.Pointer((pPage))).FmaskPage) & int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(((*MemPage)(unsafe.Pointer((pPage))).FaCellIdx + uintptr((2 * (iCellIdx))))))))))) if ((*MemPage)(unsafe.Pointer(pPage)).FnFree < 0) && (btreeComputeFreeSpace(tls, pPage) != 0) { - return 11 + return SQLITE_CORRUPT } // If the bPreserve flag is set to true, then the cursor position must @@ -50997,7 +50435,7 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit // Save the positions of any other cursors open on this table before // making any modifications. - if (int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x20) != 0 { + if (int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_Multiple) != 0 { *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = saveAllCursors(tls, pBt, (*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, pCur) if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) @@ -51046,7 +50484,7 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit n = (*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).Fpgno } pCell = ((*MemPage)(unsafe.Pointer((pLeaf))).FaData + uintptr((int32((*MemPage)(unsafe.Pointer((pLeaf))).FmaskPage) & int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(((*MemPage)(unsafe.Pointer((pLeaf))).FaCellIdx + uintptr((2 * (int32((*MemPage)(unsafe.Pointer(pLeaf)).FnCell) - 1))))))))))) - if pCell < ((*MemPage)(unsafe.Pointer(pLeaf)).FaData + uintptr(4)) { + if pCell < ((*MemPage)(unsafe.Pointer(pLeaf)).FaData + 4) { return Xsqlite3CorruptError(tls, 73510) } nCell = int32((*(*func(*libc.TLS, uintptr, uintptr) U16)(unsafe.Pointer((pLeaf + 120 /* &.xCellSize */))))(tls, pLeaf, pCell)) @@ -51054,7 +50492,7 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit pTmp = (*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pLeaf)).FpDbPage) - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { insertCell(tls, pPage, iCellIdx, (pCell - uintptr(4)), (nCell + 4), pTmp, n, bp+24 /* &rc */) } dropCell(tls, pLeaf, (int32((*MemPage)(unsafe.Pointer(pLeaf)).FnCell) - 1), nCell, bp+24 /* &rc */) @@ -51079,7 +50517,7 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit // walk the cursor up the tree to the internal node and balance it as // well. *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = balance(tls, pCur) - if (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0) && (int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) > iCellDepth) { + if (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK) && (int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) > iCellDepth) { releasePageNotNull(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpPage) (*BtCursor)(unsafe.Pointer(pCur)).FiPage-- for int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) > iCellDepth { @@ -51089,10 +50527,10 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = balance(tls, pCur) } - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { if bSkipnext != 0 { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(2) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_SKIPNEXT if iCellIdx >= int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) { (*BtCursor)(unsafe.Pointer(pCur)).FskipNext = -1 (*BtCursor)(unsafe.Pointer(pCur)).Fix = (U16(int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - 1)) @@ -51103,10 +50541,10 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = moveToRoot(tls, pCur) if bPreserve != 0 { btreeReleaseAllCursorPages(tls, pCur) - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(3) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_REQUIRESEEK } - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 16 { - *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = 0 + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_EMPTY { + *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = SQLITE_OK } } } @@ -51150,7 +50588,7 @@ func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags // Read the value of meta[3] from the database to determine where the // root page of the new table should go. meta[3] is the largest root-page // created so far, so the new root-page is (meta[3]+1). - Xsqlite3BtreeGetMeta(tls, p, 4, bp /* &pgnoRoot */) + Xsqlite3BtreeGetMeta(tls, p, BTREE_LARGEST_ROOT_PAGE, bp /* &pgnoRoot */) if *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)) > btreePagecount(tls, pBt) { return Xsqlite3CorruptError(tls, 73618) } @@ -51165,8 +50603,8 @@ func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags // Allocate a page. The page that currently resides at pgnoRoot will // be moved to the allocated page (unless the allocated page happens // to reside at pgnoRoot). - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = allocateBtreePage(tls, pBt, bp+8 /* &pPageMove */, bp+16 /* &pgnoMove */, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), uint8(1)) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = allocateBtreePage(tls, pBt, bp+8 /* &pPageMove */, bp+16 /* &pgnoMove */, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), BTALLOC_EXACT) + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } @@ -51184,20 +50622,20 @@ func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags // corresponding to page pgnoRoot. *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = saveAllCursors(tls, pBt, uint32(0), uintptr(0)) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPageMove */))) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } // Move the page currently at pgnoRoot to pgnoMove. *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = btreeGetPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), bp+24 /* &pRoot */, 0) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = ptrmapGet(tls, pBt, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), bp+32 /* &eType */, bp+36 /* &iPtrPage */) - if (int32(*(*U8)(unsafe.Pointer(bp + 32 /* eType */))) == 1) || (int32(*(*U8)(unsafe.Pointer(bp + 32 /* eType */))) == 2) { + if (int32(*(*U8)(unsafe.Pointer(bp + 32 /* eType */))) == PTRMAP_ROOTPAGE) || (int32(*(*U8)(unsafe.Pointer(bp + 32 /* eType */))) == PTRMAP_FREEPAGE) { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = Xsqlite3CorruptError(tls, 73666) } - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */))) return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } @@ -51206,15 +50644,15 @@ func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */))) // Obtain the page at pgnoRoot - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = btreeGetPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), bp+24 /* &pRoot */, 0) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)))).FpDbPage) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */))) return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } @@ -51223,7 +50661,7 @@ func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags } // Update the pointer-map and meta-data with the new root-page number. - ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), uint8(1), uint32(0), bp+40 /* &rc */) + ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), PTRMAP_ROOTPAGE, uint32(0), bp+40 /* &rc */) if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */))) return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) @@ -51246,16 +50684,16 @@ func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags } } - if (createTabFlags & 1) != 0 { - ptfFlags = ((0x01 | 0x04) | 0x08) + if (createTabFlags & BTREE_INTKEY) != 0 { + ptfFlags = ((PTF_INTKEY | PTF_LEAFDATA) | PTF_LEAF) } else { - ptfFlags = (0x02 | 0x08) + ptfFlags = (PTF_ZERODATA | PTF_LEAF) } zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)), ptfFlags) Xsqlite3PagerUnref(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)))).FpDbPage) *(*Pgno)(unsafe.Pointer(piTable)) = *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)) - return 0 + return SQLITE_OK } func Xsqlite3BtreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, flags int32) int32 { /* sqlite3.c:73729:20: */ @@ -51365,7 +50803,7 @@ __14: if !((libc.AssignPtrInt32(bp+32 /* rc */, Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FpDbPage))) == 0) { goto __16 } - zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */)), (int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FaData + uintptr(hdr)))) | 0x08)) + zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */)), (int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FaData + uintptr(hdr)))) | PTF_LEAF)) __16: ; __15: @@ -51395,7 +50833,7 @@ func Xsqlite3BtreeClearTable(tls *libc.TLS, p uintptr, iTable int32, pnChange ui rc = saveAllCursors(tls, pBt, Pgno(iTable), uintptr(0)) - if 0 == rc { + if SQLITE_OK == rc { // Invalidate all incrblob cursors open on table iTable (assuming iTable // is the root of a table b-tree - if it is not, the following call is // a no-op). @@ -51459,14 +50897,14 @@ func btreeDropTable(tls *libc.TLS, p uintptr, iTable Pgno, piMoved uintptr) int3 if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { // var maxRootPgno Pgno at bp+8, 4 - Xsqlite3BtreeGetMeta(tls, p, 4, bp+8 /* &maxRootPgno */) + Xsqlite3BtreeGetMeta(tls, p, BTREE_LARGEST_ROOT_PAGE, bp+8 /* &maxRootPgno */) if iTable == *(*Pgno)(unsafe.Pointer(bp + 8 /* maxRootPgno */)) { // If the table being dropped is the table with the largest root-page // number in the database, put the root page on the free list. freePage(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */)), bp+12 /* &rc */) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */))) - if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) } } else { @@ -51477,19 +50915,19 @@ func btreeDropTable(tls *libc.TLS, p uintptr, iTable Pgno, piMoved uintptr) int3 releasePage(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */))) *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) = btreeGetPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* maxRootPgno */)), bp+16 /* &pMove */, 0) - if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) } - *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) = relocatePage(tls, pBt, *(*uintptr)(unsafe.Pointer(bp + 16 /* pMove */)), uint8(1), uint32(0), iTable, 0) + *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) = relocatePage(tls, pBt, *(*uintptr)(unsafe.Pointer(bp + 16 /* pMove */)), PTRMAP_ROOTPAGE, uint32(0), iTable, 0) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pMove */))) - if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) } *(*uintptr)(unsafe.Pointer(bp + 16 /* pMove */)) = uintptr(0) *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) = btreeGetPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* maxRootPgno */)), bp+16 /* &pMove */, 0) freePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pMove */)), bp+12 /* &rc */) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pMove */))) - if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) } *(*int32)(unsafe.Pointer(piMoved)) = int32(*(*Pgno)(unsafe.Pointer(bp + 8 /* maxRootPgno */))) @@ -51544,7 +50982,7 @@ func Xsqlite3BtreeGetMeta(tls *libc.TLS, p uintptr, idx int32, pMeta uintptr) { Xsqlite3BtreeEnter(tls, p) - if idx == 15 { + if idx == BTREE_DATA_VERSION { *(*U32)(unsafe.Pointer(pMeta)) = (Xsqlite3PagerDataVersion(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) + (*Btree)(unsafe.Pointer(p)).FiDataVersion) } else { *(*U32)(unsafe.Pointer(pMeta)) = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr((36 + (idx * 4))))) @@ -51567,9 +51005,9 @@ func Xsqlite3BtreeUpdateMeta(tls *libc.TLS, p uintptr, idx int32, iMeta U32) int pP1 = (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3Put4byte(tls, (pP1 + uintptr((36 + (idx * 4)))), iMeta) - if idx == 7 { + if idx == BTREE_INCR_VACUUM { (*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = U8(iMeta) } @@ -51589,14 +51027,14 @@ func Xsqlite3BtreeCount(tls *libc.TLS, db uintptr, pCur uintptr, pnEntry uintptr var rc int32 // Return code rc = moveToRoot(tls, pCur) - if rc == 16 { + if rc == SQLITE_EMPTY { *(*I64)(unsafe.Pointer(pnEntry)) = int64(0) - return 0 + return SQLITE_OK } // Unless an error occurs, the following loop runs one iteration for each // page in the B-Tree structure (not including overflow pages). - for (rc == 0) && !(libc.AtomicLoadNInt32((db+392 /* &.u1 */ /* &.isInterrupted */), 0) != 0) { + for (rc == SQLITE_OK) && !(libc.AtomicLoadNInt32((db+392 /* &.u1 */ /* &.isInterrupted */), 0) != 0) { var iIdx int32 // Index of child node in parent var pPage uintptr // Current page of the b-tree @@ -51672,7 +51110,7 @@ func checkAppendMsg(tls *libc.TLS, pCheck uintptr, zFormat uintptr, va uintptr) } Xsqlite3_str_vappendf(tls, (pCheck + 56 /* &.errMsg */), zFormat, ap) _ = ap - if int32((*IntegrityCk)(unsafe.Pointer(pCheck)).FerrMsg.FaccError) == 7 { + if int32((*IntegrityCk)(unsafe.Pointer(pCheck)).FerrMsg.FaccError) == SQLITE_NOMEM { (*IntegrityCk)(unsafe.Pointer(pCheck)).FbOomFault = 1 } } @@ -51728,8 +51166,8 @@ func checkPtrmap(tls *libc.TLS, pCheck uintptr, iChild Pgno, eType U8, iParent P // var iPtrmapParent Pgno at bp+52, 4 rc = ptrmapGet(tls, (*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt, iChild, bp+48 /* &ePtrmapType */, bp+52 /* &iPtrmapParent */) - if rc != 0 { - if (rc == 7) || (rc == (10 | (int32(12) << 8))) { + if rc != SQLITE_OK { + if (rc == SQLITE_NOMEM) || (rc == (SQLITE_IOERR | (int32(12) << 8))) { (*IntegrityCk)(unsafe.Pointer(pCheck)).FbOomFault = 1 } checkAppendMsg(tls, pCheck, ts+3062 /* "Failed to read p..." */, libc.VaList(bp, iChild)) @@ -51766,9 +51204,9 @@ func checkList(tls *libc.TLS, pCheck uintptr, isFreeList int32, iPage Pgno, N U3 } pOvflData = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pOvflPage */))) if isFreeList != 0 { - var n U32 = Xsqlite3Get4byte(tls, (pOvflData + uintptr(4))) + var n U32 = Xsqlite3Get4byte(tls, (pOvflData + 4)) if (*BtShared)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 { - checkPtrmap(tls, pCheck, iPage, uint8(2), uint32(0)) + checkPtrmap(tls, pCheck, iPage, PTRMAP_FREEPAGE, uint32(0)) } if n > (((*BtShared)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FusableSize / U32(4)) - U32(2)) { checkAppendMsg(tls, pCheck, @@ -51778,7 +51216,7 @@ func checkList(tls *libc.TLS, pCheck uintptr, isFreeList int32, iPage Pgno, N U3 for i = 0; i < int32(n); i++ { var iFreePage Pgno = Xsqlite3Get4byte(tls, (pOvflData + uintptr((8 + (i * 4))))) if (*BtShared)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 { - checkPtrmap(tls, pCheck, iFreePage, uint8(2), uint32(0)) + checkPtrmap(tls, pCheck, iFreePage, PTRMAP_FREEPAGE, uint32(0)) } checkRef(tls, pCheck, iFreePage) } @@ -51790,7 +51228,7 @@ func checkList(tls *libc.TLS, pCheck uintptr, isFreeList int32, iPage Pgno, N U3 // the following page matches iPage. if ((*BtShared)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0) && (N > U32(0)) { i = int32(Xsqlite3Get4byte(tls, pOvflData)) - checkPtrmap(tls, pCheck, uint32(i), uint8(4), iPage) + checkPtrmap(tls, pCheck, uint32(i), PTRMAP_OVERFLOW2, iPage) } } iPage = Xsqlite3Get4byte(tls, pOvflData) @@ -51831,7 +51269,7 @@ func checkList(tls *libc.TLS, pCheck uintptr, isFreeList int32, iPage Pgno, N U3 // lower 16 bits are the index of the last byte of that range. func btreeHeapInsert(tls *libc.TLS, aHeap uintptr, x U32) { /* sqlite3.c:74299:13: */ var j U32 - var i U32 = libc.PreIncUint32(&*(*U32)(unsafe.Pointer(aHeap + uintptr(0)*4)), 1) + var i U32 = libc.PreIncUint32(&*(*U32)(unsafe.Pointer(aHeap)), 1) *(*U32)(unsafe.Pointer(aHeap + uintptr(i)*4)) = x for ((libc.AssignUint32(&j, (i / U32(2)))) > U32(0)) && (*(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4)) > *(*U32)(unsafe.Pointer(aHeap + uintptr(i)*4))) { x = *(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4)) @@ -51845,15 +51283,15 @@ func btreeHeapPull(tls *libc.TLS, aHeap uintptr, pOut uintptr) int32 { /* sqlite var j U32 var i U32 var x U32 - if (libc.AssignUint32(&x, *(*U32)(unsafe.Pointer(aHeap + uintptr(0)*4)))) == U32(0) { + if (libc.AssignUint32(&x, *(*U32)(unsafe.Pointer(aHeap)))) == U32(0) { return 0 } - *(*U32)(unsafe.Pointer(pOut)) = *(*U32)(unsafe.Pointer(aHeap + uintptr(1)*4)) - *(*U32)(unsafe.Pointer(aHeap + uintptr(1)*4)) = *(*U32)(unsafe.Pointer(aHeap + uintptr(x)*4)) + *(*U32)(unsafe.Pointer(pOut)) = *(*U32)(unsafe.Pointer(aHeap + 1*4)) + *(*U32)(unsafe.Pointer(aHeap + 1*4)) = *(*U32)(unsafe.Pointer(aHeap + uintptr(x)*4)) *(*U32)(unsafe.Pointer(aHeap + uintptr(x)*4)) = 0xffffffff - *(*U32)(unsafe.Pointer(aHeap + uintptr(0)*4))-- + *(*U32)(unsafe.Pointer(aHeap))-- i = U32(1) - for (libc.AssignUint32(&j, (i * U32(2)))) <= *(*U32)(unsafe.Pointer(aHeap + uintptr(0)*4)) { + for (libc.AssignUint32(&j, (i * U32(2)))) <= *(*U32)(unsafe.Pointer(aHeap)) { if *(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4)) > *(*U32)(unsafe.Pointer(aHeap + uintptr((j+U32(1)))*4)) { j++ } @@ -51984,12 +51422,12 @@ __5: // Set up for cell analysis (*IntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = ts + 3366 /* "On tree page %u ..." */ - contentOffset = (U32(((((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))))) - 1) & 0xffff) + 1)) + contentOffset = (U32(((((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)))) - 1) & 0xffff) + 1)) // Enforced by btreeInitPage() // EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the // number of cells on the page. - nCell = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))) + uintptr(1))))) + nCell = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 3)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))) + 1)))) // EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page // immediately follows the b-tree page header. @@ -52006,7 +51444,7 @@ __5: goto __8 } (*IntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = ts + 3392 /* "On page %u at ri..." */ - checkPtrmap(tls, pCheck, uint32(pgno), uint8(5), iPage) + checkPtrmap(tls, pCheck, uint32(pgno), PTRMAP_BTREE, iPage) __8: ; depth = checkTreePage(tls, pCheck, uint32(pgno), bp+104 /* &maxKey */, *(*I64)(unsafe.Pointer(bp + 104 /* maxKey */))) @@ -52016,7 +51454,7 @@ __6: // For leaf pages, the coverage check will occur in the same loop // as the other cell checks, so initialize the heap. heap = (*IntegrityCk)(unsafe.Pointer(pCheck)).Fheap - *(*U32)(unsafe.Pointer(heap + uintptr(0)*4)) = U32(0) + *(*U32)(unsafe.Pointer(heap)) = U32(0) __7: ; @@ -52083,7 +51521,7 @@ __14: if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) { goto __17 } - checkPtrmap(tls, pCheck, pgnoOvfl, uint8(3), iPage) + checkPtrmap(tls, pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage) __17: ; checkList(tls, pCheck, 0, pgnoOvfl, nPage) @@ -52098,7 +51536,7 @@ __16: if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) { goto __20 } - checkPtrmap(tls, pCheck, uint32(pgno), uint8(5), iPage) + checkPtrmap(tls, pCheck, uint32(pgno), PTRMAP_BTREE, iPage) __20: ; d2 = checkTreePage(tls, pCheck, uint32(pgno), bp+104 /* &maxKey */, *(*I64)(unsafe.Pointer(bp + 104 /* maxKey */))) @@ -52137,7 +51575,7 @@ __11: goto __23 } heap = (*IntegrityCk)(unsafe.Pointer(pCheck)).Fheap - *(*U32)(unsafe.Pointer(heap + uintptr(0)*4)) = U32(0) + *(*U32)(unsafe.Pointer(heap)) = U32(0) i = (nCell - 1) __24: if !(i >= 0) { @@ -52160,20 +51598,20 @@ __23: // EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header // is the offset of the first freeblock, or zero if there are no // freeblocks on the page. - i = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 1))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 1))) + uintptr(1))))) + i = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 1)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 1))) + 1)))) __27: if !(i > 0) { goto __28 } // Enforced by btreeComputeFreeSpace() - size1 = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((i + 2))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((i + 2))) + uintptr(1))))) + size1 = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((i + 2)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((i + 2))) + 1)))) // due to btreeComputeFreeSpace() btreeHeapInsert(tls, heap, (((U32(i)) << 16) | (U32((i + size1) - 1)))) // EVIDENCE-OF: R-58208-19414 The first 2 bytes of a freeblock are a // big-endian integer which is the offset in the b-tree page of the next // freeblock in the chain, or zero if the freeblock is the last on the // chain. - j = ((int32(*(*U8)(unsafe.Pointer((data + uintptr(i)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr(i)) + uintptr(1))))) + j = ((int32(*(*U8)(unsafe.Pointer((data + uintptr(i))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr(i)) + 1)))) // EVIDENCE-OF: R-06866-39125 Freeblocks are always connected in order of // increasing offset. // Enforced by btreeComputeFreeSpace() @@ -52220,7 +51658,7 @@ __30: // is stored in the fifth field of the b-tree page header. // EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the // number of fragmented free bytes within the cell content area. - if !((*(*U32)(unsafe.Pointer(heap + uintptr(0)*4)) == U32(0)) && (nFrag != int32(*(*U8)(unsafe.Pointer(data + uintptr((hdr + 7))))))) { + if !((*(*U32)(unsafe.Pointer(heap)) == U32(0)) && (nFrag != int32(*(*U8)(unsafe.Pointer(data + uintptr((hdr + 7))))))) { goto __33 } checkAppendMsg(tls, pCheck, @@ -52287,12 +51725,12 @@ func Xsqlite3BtreeIntegrityCheck(tls *libc.TLS, db uintptr, p uintptr, aRoot uin bCkFreelist = 1 // True to scan the freelist // aRoot[0]==0 means this is a partial check - if !(*(*Pgno)(unsafe.Pointer(aRoot + uintptr(0)*4)) == Pgno(0)) { + if !(*(*Pgno)(unsafe.Pointer(aRoot)) == Pgno(0)) { goto __1 } bPartial = 1 - if !(*(*Pgno)(unsafe.Pointer(aRoot + uintptr(1)*4)) != Pgno(1)) { + if !(*(*Pgno)(unsafe.Pointer(aRoot + 1*4)) != Pgno(1)) { goto __2 } bCkFreelist = 0 @@ -52315,8 +51753,8 @@ __1: (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).Fv2 = 0 (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).FaPgRef = uintptr(0) (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).Fheap = uintptr(0) - Xsqlite3StrAccumInit(tls, (bp + 32 /* &sCheck */ + 56 /* &.errMsg */), uintptr(0), bp+136 /* &zErr[0] */, int32(unsafe.Sizeof([100]int8{})), 1000000000) - (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).FerrMsg.FprintfFlags = U8(0x01) + Xsqlite3StrAccumInit(tls, (bp + 32 /* &sCheck */ + 56 /* &.errMsg */), uintptr(0), bp+136 /* &zErr[0] */, int32(unsafe.Sizeof([100]int8{})), SQLITE_MAX_LENGTH) + (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).FerrMsg.FprintfFlags = SQLITE_PRINTF_INTERNAL if !((*IntegrityCk)(unsafe.Pointer(bp+32 /* &sCheck */)).FnPage == Pgno(0)) { goto __3 } @@ -52354,8 +51792,8 @@ __6: goto __7 } (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).FzPfx = ts + 3612 /* "Main freelist: " */ - checkList(tls, bp+32 /* &sCheck */, 1, Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+uintptr(32))), - Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+uintptr(36)))) + checkList(tls, bp+32 /* &sCheck */, 1, Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+32)), + Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36))) (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).FzPfx = uintptr(0) __7: ; @@ -52386,7 +51824,7 @@ __12: goto __13 __13: ; - mxInHdr = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(52))) + mxInHdr = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 52)) if !(mx != mxInHdr) { goto __15 } @@ -52397,7 +51835,7 @@ __15: ; goto __10 __9: - if !(Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+uintptr(64))) != U32(0)) { + if !(Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+64)) != U32(0)) { goto __16 } checkAppendMsg(tls, bp+32, /* &sCheck */ @@ -52409,7 +51847,7 @@ __10: __8: ; - *(*U64)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x00200000))) + *(*U64)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_CellSizeCk)) i = Pgno(0) __17: if !((int32(i) < nRoot) && ((*IntegrityCk)(unsafe.Pointer(bp+32 /* &sCheck */)).FmxErr != 0)) { @@ -52424,7 +51862,7 @@ __20: if !((((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) && (*(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4)) > Pgno(1))) && !(bPartial != 0)) { goto __21 } - checkPtrmap(tls, bp+32 /* &sCheck */, *(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4)), uint8(1), uint32(0)) + checkPtrmap(tls, bp+32 /* &sCheck */, *(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4)), PTRMAP_ROOTPAGE, uint32(0)) __21: ; checkTreePage(tls, bp+32 /* &sCheck */, *(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4)), bp+240 /* ¬Used */, (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))) @@ -52518,7 +51956,7 @@ func Xsqlite3BtreeGetJournalname(tls *libc.TLS, p uintptr) uintptr { /* sqlite3. // Return non-zero if a transaction is active. func Xsqlite3BtreeIsInTrans(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:74798:20: */ - return (libc.Bool32((p != 0) && (int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 2))) + return (libc.Bool32((p != 0) && (int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE))) } // Run a checkpoint on the Btree passed as the first argument. @@ -52528,12 +51966,12 @@ func Xsqlite3BtreeIsInTrans(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:74798 // // Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART. func Xsqlite3BtreeCheckpoint(tls *libc.TLS, p uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) int32 { /* sqlite3.c:74812:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if p != 0 { var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt Xsqlite3BtreeEnter(tls, p) - if int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) != 0 { - rc = 6 + if int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) != TRANS_NONE { + rc = SQLITE_LOCKED } else { rc = Xsqlite3PagerCheckpoint(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, (*Btree)(unsafe.Pointer(p)).Fdb, eMode, pnLog, pnCkpt) } @@ -52545,7 +51983,7 @@ func Xsqlite3BtreeCheckpoint(tls *libc.TLS, p uintptr, eMode int32, pnLog uintpt // Return non-zero if a read (or write) transaction is active. func Xsqlite3BtreeIsInReadTrans(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:74831:20: */ - return (libc.Bool32(int32((*Btree)(unsafe.Pointer(p)).FinTrans) != 0)) + return (libc.Bool32(int32((*Btree)(unsafe.Pointer(p)).FinTrans) != TRANS_NONE)) } func Xsqlite3BtreeIsInBackup(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:74837:20: */ @@ -52589,7 +52027,7 @@ func Xsqlite3BtreeSchemaLocked(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:74 var rc int32 Xsqlite3BtreeEnter(tls, p) - rc = querySharedCacheTableLock(tls, p, uint32(1), uint8(1)) + rc = querySharedCacheTableLock(tls, p, SCHEMA_ROOT, READ_LOCK) Xsqlite3BtreeLeave(tls, p) return rc @@ -52599,14 +52037,14 @@ func Xsqlite3BtreeSchemaLocked(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:74 // lock is a write lock if isWritelock is true or a read lock // if it is false. func Xsqlite3BtreeLockTable(tls *libc.TLS, p uintptr, iTab int32, isWriteLock U8) int32 { /* sqlite3.c:74896:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Btree)(unsafe.Pointer(p)).Fsharable != 0 { - var lockType U8 = (U8(1 + int32(isWriteLock))) + var lockType U8 = (U8(READ_LOCK + int32(isWriteLock))) Xsqlite3BtreeEnter(tls, p) rc = querySharedCacheTableLock(tls, p, uint32(iTab), lockType) - if rc == 0 { + if rc == SQLITE_OK { rc = setSharedCacheTableLock(tls, p, uint32(iTab), lockType) } Xsqlite3BtreeLeave(tls, p) @@ -52626,17 +52064,17 @@ func Xsqlite3BtreePutData(tls *libc.TLS, pCsr uintptr, offset U32, amt U32, z ui var rc int32 rc = func() int32 { - if int32((*BtCursor)(unsafe.Pointer(pCsr)).FeState) >= 3 { + if int32((*BtCursor)(unsafe.Pointer(pCsr)).FeState) >= CURSOR_REQUIRESEEK { return btreeRestoreCursorPosition(tls, pCsr) } - return 0 + return SQLITE_OK }() - if rc != 0 { + if rc != SQLITE_OK { return rc } - if int32((*BtCursor)(unsafe.Pointer(pCsr)).FeState) != 0 { - return 4 + if int32((*BtCursor)(unsafe.Pointer(pCsr)).FeState) != CURSOR_VALID { + return SQLITE_ABORT } // Save the positions of all other cursors open on this table. This is @@ -52654,8 +52092,8 @@ func Xsqlite3BtreePutData(tls *libc.TLS, pCsr uintptr, offset U32, amt U32, z ui // (c) the connection holds a write-lock on the table (if required), // (d) there are no conflicting read-locks, and // (e) the cursor points at a valid row of an intKey table. - if (int32((*BtCursor)(unsafe.Pointer(pCsr)).FcurFlags) & 0x01) == 0 { - return 8 + if (int32((*BtCursor)(unsafe.Pointer(pCsr)).FcurFlags) & BTCF_WriteFlag) == 0 { + return SQLITE_READONLY } return accessPayload(tls, pCsr, offset, amt, z, 1) @@ -52663,7 +52101,7 @@ func Xsqlite3BtreePutData(tls *libc.TLS, pCsr uintptr, offset U32, amt U32, z ui // Mark this cursor as an incremental blob cursor. func Xsqlite3BtreeIncrblobCursor(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:74974:21: */ - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x10)) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_Incrblob)) (*Btree)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBtree)).FhasIncrblobCur = U8(1) } @@ -52676,27 +52114,27 @@ func Xsqlite3BtreeSetVersion(tls *libc.TLS, pBtree uintptr, iVersion int32) int3 // If setting the version fields to 1, do not automatically open the // WAL connection, even if the version fields are currently set to 2. - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0020))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_NO_WAL))) if iVersion == 1 { - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0020)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_NO_WAL)) } rc = Xsqlite3BtreeBeginTrans(tls, pBtree, 0, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { var aData uintptr = (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData - if (int32(*(*U8)(unsafe.Pointer(aData + uintptr(18)))) != int32(U8(iVersion))) || (int32(*(*U8)(unsafe.Pointer(aData + uintptr(19)))) != int32(U8(iVersion))) { + if (int32(*(*U8)(unsafe.Pointer(aData + 18))) != int32(U8(iVersion))) || (int32(*(*U8)(unsafe.Pointer(aData + 19))) != int32(U8(iVersion))) { rc = Xsqlite3BtreeBeginTrans(tls, pBtree, 2, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) - if rc == 0 { - *(*U8)(unsafe.Pointer(aData + uintptr(18))) = U8(iVersion) - *(*U8)(unsafe.Pointer(aData + uintptr(19))) = U8(iVersion) + if rc == SQLITE_OK { + *(*U8)(unsafe.Pointer(aData + 18)) = U8(iVersion) + *(*U8)(unsafe.Pointer(aData + 19)) = U8(iVersion) } } } } - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0020))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_NO_WAL))) return rc } @@ -52708,12 +52146,12 @@ func Xsqlite3BtreeCursorHasHint(tls *libc.TLS, pCsr uintptr, mask uint32) int32 // Return true if the given Btree is read-only. func Xsqlite3BtreeIsReadonly(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:75027:20: */ - return (libc.Bool32((int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FbtsFlags) & 0x0001) != 0)) + return (libc.Bool32((int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FbtsFlags) & BTS_READ_ONLY) != 0)) } // Return the size of the header added to each page by this module. func Xsqlite3HeaderSizeBtree(tls *libc.TLS) int32 { /* sqlite3.c:75034:20: */ - return (int32(((uint64(unsafe.Sizeof(MemPage{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + return (int32(((uint64(unsafe.Sizeof(MemPage{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) } // Return true if the Btree passed as the only argument is sharable. @@ -52778,7 +52216,7 @@ func findBtree(tls *libc.TLS, pErrorDb uintptr, pDb uintptr, zDb uintptr) uintpt (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).Fdb = pDb if Xsqlite3OpenTempDatabase(tls, bp+16 /* &sParse */) != 0 { Xsqlite3ErrorWithMsg(tls, pErrorDb, (*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).Frc, ts+2690 /* "%s" */, libc.VaList(bp, (*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).FzErrMsg)) - rc = 1 + rc = SQLITE_ERROR } Xsqlite3DbFree(tls, pErrorDb, (*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).FzErrMsg) Xsqlite3ParserReset(tls, bp+16 /* &sParse */) @@ -52788,7 +52226,7 @@ func findBtree(tls *libc.TLS, pErrorDb uintptr, pDb uintptr, zDb uintptr) uintpt } if i < 0 { - Xsqlite3ErrorWithMsg(tls, pErrorDb, 1, ts+3784 /* "unknown database..." */, libc.VaList(bp+8, zDb)) + Xsqlite3ErrorWithMsg(tls, pErrorDb, SQLITE_ERROR, ts+3784 /* "unknown database..." */, libc.VaList(bp+8, zDb)) return uintptr(0) } @@ -52809,10 +52247,10 @@ func setDestPgsz(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:75169:12: */ // message in database handle db. func checkReadTransaction(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:75181:12: */ if Xsqlite3BtreeIsInReadTrans(tls, p) != 0 { - Xsqlite3ErrorWithMsg(tls, db, 1, ts+3804 /* "destination data..." */, 0) - return 1 + Xsqlite3ErrorWithMsg(tls, db, SQLITE_ERROR, ts+3804 /* "destination data..." */, 0) + return SQLITE_ERROR } - return 0 + return SQLITE_OK } // Create an sqlite3_backup process to copy the contents of zSrcDb from @@ -52836,7 +52274,7 @@ func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcD if pSrcDb == pDestDb { Xsqlite3ErrorWithMsg(tls, - pDestDb, 1, ts+3835 /* "source and desti..." */, 0) + pDestDb, SQLITE_ERROR, ts+3835 /* "source and desti..." */, 0) p = uintptr(0) } else { // Allocate space for a new sqlite3_backup object... @@ -52845,7 +52283,7 @@ func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcD // sqlite3_backup_finish(). p = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(Sqlite3_backup{}))) if !(p != 0) { - Xsqlite3Error(tls, pDestDb, 7) + Xsqlite3Error(tls, pDestDb, SQLITE_NOMEM) } } @@ -52859,7 +52297,7 @@ func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcD (*Sqlite3_backup)(unsafe.Pointer(p)).FisAttached = 0 if ((uintptr(0) == (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc) || (uintptr(0) == (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)) || - (checkReadTransaction(tls, pDestDb, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest) != 0) { + (checkReadTransaction(tls, pDestDb, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest) != SQLITE_OK) { // One (or both) of the named databases did not exist or an OOM // error was hit. Or there is a transaction open on the destination // database. The error has already been written into the pDestDb @@ -52882,7 +52320,7 @@ func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcD // considered fatal if encountered during a backup operation. All errors // are considered fatal except for SQLITE_BUSY and SQLITE_LOCKED. func isFatalError(tls *libc.TLS, rc int32) int32 { /* sqlite3.c:75274:12: */ - return (libc.Bool32(((rc != 0) && (rc != 5)) && (rc != 6))) + return (libc.Bool32(((rc != SQLITE_OK) && (rc != SQLITE_BUSY)) && (rc != SQLITE_LOCKED))) } // Parameter zSrcData points to a buffer containing the data for @@ -52902,26 +52340,26 @@ func backupOnePage(tls *libc.TLS, p uintptr, iSrcPg Pgno, zSrcData uintptr, bUpd return nDestPgsz }() var iEnd I64 = (I64(iSrcPg) * I64(nSrcPgsz)) - var rc int32 = 0 + var rc int32 = SQLITE_OK var iOff I64 // Catch the case where the destination is an in-memory database and the // page sizes of the source and destination differ. if (nSrcPgsz != nDestPgsz) && (Xsqlite3PagerIsMemdb(tls, pDestPager) != 0) { - rc = 8 + rc = SQLITE_READONLY } // This loop runs once for each destination page spanned by the source // page. For each iteration, variable iOff is set to the byte offset // of the destination page. - for iOff = (iEnd - I64(nSrcPgsz)); (rc == 0) && (iOff < iEnd); iOff = iOff + (I64(nDestPgsz)) { + for iOff = (iEnd - I64(nSrcPgsz)); (rc == SQLITE_OK) && (iOff < iEnd); iOff = iOff + (I64(nDestPgsz)) { *(*uintptr)(unsafe.Pointer(bp /* pDestPg */)) = uintptr(0) var iDest Pgno = ((Pgno(iOff / I64(nDestPgsz))) + Pgno(1)) if iDest == ((U32(Xsqlite3PendingByte) / ((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)).FpBt)).FpageSize)) + U32(1)) { continue } - if (0 == (libc.AssignInt32(&rc, Xsqlite3PagerGet(tls, pDestPager, iDest, bp /* &pDestPg */, 0)))) && - (0 == (libc.AssignInt32(&rc, Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp /* pDestPg */)))))) { + if (SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3PagerGet(tls, pDestPager, iDest, bp /* &pDestPg */, 0)))) && + (SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp /* pDestPg */)))))) { var zIn uintptr = (zSrcData + uintptr((iOff % I64(nSrcPgsz)))) var zDestData uintptr = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp /* pDestPg */))) var zOut uintptr = (zDestData + uintptr((iOff % I64(nDestPgsz)))) @@ -52933,9 +52371,9 @@ func backupOnePage(tls *libc.TLS, p uintptr, iSrcPg Pgno, zSrcData uintptr, bUpd // cached parse of the page). MemPage.isInit is marked // "MUST BE FIRST" for this purpose. libc.Xmemcpy(tls, zOut, zIn, uint64(nCopy)) - *(*U8)(unsafe.Pointer((Xsqlite3PagerGetExtra(tls, *(*uintptr)(unsafe.Pointer(bp /* pDestPg */)))) + uintptr(0))) = U8(0) + *(*U8)(unsafe.Pointer((Xsqlite3PagerGetExtra(tls, *(*uintptr)(unsafe.Pointer(bp /* pDestPg */)))))) = U8(0) if (iOff == int64(0)) && (bUpdate == 0) { - Xsqlite3Put4byte(tls, (zOut + uintptr(28)), Xsqlite3BtreeLastPage(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)) + Xsqlite3Put4byte(tls, (zOut + 28), Xsqlite3BtreeLastPage(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)) } } Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp /* pDestPg */))) @@ -52957,7 +52395,7 @@ func backupTruncateFile(tls *libc.TLS, pFile uintptr, iSize I64) int32 { /* sqli // var iCurrent I64 at bp, 8 var rc int32 = Xsqlite3OsFileSize(tls, pFile, bp /* &iCurrent */) - if (rc == 0) && (*(*I64)(unsafe.Pointer(bp /* iCurrent */)) > iSize) { + if (rc == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp /* iCurrent */)) > iSize) { rc = Xsqlite3OsTruncate(tls, pFile, iSize) } return rc @@ -53000,16 +52438,16 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli // If the source pager is currently in a write-transaction, return // SQLITE_BUSY immediately. - if ((*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0) && (int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FpBt)).FinTransaction) == 2) { - rc = 5 + if ((*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0) && (int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FpBt)).FinTransaction) == TRANS_WRITE) { + rc = SQLITE_BUSY } else { - rc = 0 + rc = SQLITE_OK } // If there is no open read-transaction on the source database, open // one now. If a transaction is opened here, then it will be closed // before this function exits. - if (rc == 0) && (0 == Xsqlite3BtreeIsInReadTrans(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)) { + if (rc == SQLITE_OK) && (0 == Xsqlite3BtreeIsInReadTrans(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)) { rc = Xsqlite3BtreeBeginTrans(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc, 0, uintptr(0)) bCloseTrans = 1 } @@ -53020,13 +52458,13 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli // is especially important on ZipVFS systems, as in that case it is // not possible to create a database file that uses one page size by // writing to it with another. - if (((*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked == 0) && (rc == 0)) && (setDestPgsz(tls, p) == 7) { - rc = 7 + if (((*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked == 0) && (rc == SQLITE_OK)) && (setDestPgsz(tls, p) == SQLITE_NOMEM) { + rc = SQLITE_NOMEM } // Lock the destination database, if it is not locked already. - if ((0 == rc) && ((*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked == 0)) && - (0 == (libc.AssignInt32(&rc, Xsqlite3BtreeBeginTrans(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 2, + if ((SQLITE_OK == rc) && ((*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked == 0)) && + (SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3BtreeBeginTrans(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 2, (p+16 /* &.iDestSchema */))))) { (*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked = 1 } @@ -53036,8 +52474,8 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli pgszSrc = Xsqlite3BtreeGetPageSize(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc) pgszDest = Xsqlite3BtreeGetPageSize(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest) destMode = Xsqlite3PagerGetJournalMode(tls, Xsqlite3BtreePager(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)) - if ((0 == rc) && (destMode == 5)) && (pgszSrc != pgszDest) { - rc = 8 + if ((SQLITE_OK == rc) && (destMode == PAGER_JOURNALMODE_WAL)) && (pgszSrc != pgszDest) { + rc = SQLITE_READONLY } // Now that there is a read-lock on the source database, query the @@ -53049,19 +52487,19 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli if iSrcPg != ((U32(Xsqlite3PendingByte) / ((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FpBt)).FpageSize)) + U32(1)) { // var pSrcPg uintptr at bp, 8 // Source page object - rc = Xsqlite3PagerGet(tls, pSrcPager, iSrcPg, bp /* &pSrcPg */, 0x02) - if rc == 0 { + rc = Xsqlite3PagerGet(tls, pSrcPager, iSrcPg, bp /* &pSrcPg */, PAGER_GET_READONLY) + if rc == SQLITE_OK { rc = backupOnePage(tls, p, iSrcPg, Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp /* pSrcPg */))), 0) Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp /* pSrcPg */))) } } (*Sqlite3_backup)(unsafe.Pointer(p)).FiNext++ } - if rc == 0 { + if rc == SQLITE_OK { (*Sqlite3_backup)(unsafe.Pointer(p)).FnPagecount = Pgno(nSrcPage) (*Sqlite3_backup)(unsafe.Pointer(p)).FnRemaining = ((Pgno(nSrcPage + 1)) - (*Sqlite3_backup)(unsafe.Pointer(p)).FiNext) if (*Sqlite3_backup)(unsafe.Pointer(p)).FiNext > Pgno(nSrcPage) { - rc = 101 + rc = SQLITE_DONE } else if !((*Sqlite3_backup)(unsafe.Pointer(p)).FisAttached != 0) { attachBackupObject(tls, p) } @@ -53071,23 +52509,23 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli // is to make sure that the schema-version really does change in // the case where the source and destination databases have the // same schema version. - if rc == 101 { + if rc == SQLITE_DONE { if nSrcPage == 0 { rc = Xsqlite3BtreeNewDb(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest) nSrcPage = 1 } - if (rc == 0) || (rc == 101) { + if (rc == SQLITE_OK) || (rc == SQLITE_DONE) { rc = Xsqlite3BtreeUpdateMeta(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 1, ((*Sqlite3_backup)(unsafe.Pointer(p)).FiDestSchema + U32(1))) } - if rc == 0 { + if rc == SQLITE_OK { if (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 { Xsqlite3ResetAllSchemasOfConnection(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb) } - if destMode == 5 { + if destMode == PAGER_JOURNALMODE_WAL { rc = Xsqlite3BtreeSetVersion(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 2) } } - if rc == 0 { + if rc == SQLITE_OK { var nDestTruncate int32 // Set nDestTruncate to the final number of pages in the destination // database. The complication here is that the destination page @@ -53135,18 +52573,18 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli // occurs, the original database will be reconstructed from the // journal file. Xsqlite3PagerPagecount(tls, pDestPager, bp+8 /* &nDstPage */) - for iPg = Pgno(nDestTruncate); (rc == 0) && (iPg <= Pgno(*(*int32)(unsafe.Pointer(bp + 8 /* nDstPage */)))); iPg++ { + for iPg = Pgno(nDestTruncate); (rc == SQLITE_OK) && (iPg <= Pgno(*(*int32)(unsafe.Pointer(bp + 8 /* nDstPage */)))); iPg++ { if iPg != ((U32(Xsqlite3PendingByte) / ((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)).FpBt)).FpageSize)) + U32(1)) { // var pPg uintptr at bp+16, 8 rc = Xsqlite3PagerGet(tls, pDestPager, iPg, bp+16 /* &pPg */, 0) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */))) Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */))) } } } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerCommitPhaseOne(tls, pDestPager, uintptr(0), 1) } @@ -53157,22 +52595,22 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli } return iSize }() - for iOff = (I64(Xsqlite3PendingByte + pgszSrc)); (rc == 0) && (iOff < iEnd); iOff = iOff + (I64(pgszSrc)) { + for iOff = (I64(Xsqlite3PendingByte + pgszSrc)); (rc == SQLITE_OK) && (iOff < iEnd); iOff = iOff + (I64(pgszSrc)) { *(*uintptr)(unsafe.Pointer(bp + 24 /* pSrcPg */)) = uintptr(0) var iSrcPg Pgno = (Pgno((iOff / I64(pgszSrc)) + int64(1))) rc = Xsqlite3PagerGet(tls, pSrcPager, iSrcPg, bp+24 /* &pSrcPg */, 0) - if rc == 0 { + if rc == SQLITE_OK { var zData uintptr = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pSrcPg */))) rc = Xsqlite3OsWrite(tls, pFile, zData, pgszSrc, iOff) } Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pSrcPg */))) } - if rc == 0 { + if rc == SQLITE_OK { rc = backupTruncateFile(tls, pFile, iSize) } // Sync the database file to disk. - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerSync(tls, pDestPager, uintptr(0)) } } else { @@ -53181,9 +52619,9 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli } // Finish committing the transaction to the destination database. - if (0 == rc) && - (0 == (libc.AssignInt32(&rc, Xsqlite3BtreeCommitPhaseTwo(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 0)))) { - rc = 101 + if (SQLITE_OK == rc) && + (SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3BtreeCommitPhaseTwo(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 0)))) { + rc = SQLITE_DONE } } } @@ -53199,8 +52637,8 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli } - if rc == (10 | (int32(12) << 8)) { - rc = 7 + if rc == (SQLITE_IOERR | (int32(12) << 8)) { + rc = SQLITE_NOMEM } (*Sqlite3_backup)(unsafe.Pointer(p)).Frc = rc } @@ -53220,7 +52658,7 @@ func Xsqlite3_backup_finish(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:75631 // Enter the mutexes if p == uintptr(0) { - return 0 + return SQLITE_OK } pSrcDb = (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrcDb Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(pSrcDb)).Fmutex) @@ -53244,11 +52682,11 @@ func Xsqlite3_backup_finish(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:75631 } // If a transaction is still open on the Btree, roll it back. - Xsqlite3BtreeRollback(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 0, 0) + Xsqlite3BtreeRollback(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, SQLITE_OK, 0) // Set the error code of the destination database handle. - if (*Sqlite3_backup)(unsafe.Pointer(p)).Frc == 101 { - rc = 0 + if (*Sqlite3_backup)(unsafe.Pointer(p)).Frc == SQLITE_DONE { + rc = SQLITE_OK } else { rc = (*Sqlite3_backup)(unsafe.Pointer(p)).Frc } @@ -53305,7 +52743,7 @@ func backupUpdate(tls *libc.TLS, p uintptr, iPage Pgno, aData uintptr) { /* sqli rc = backupOnePage(tls, p, iPage, aData, 1) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb)).Fmutex) - if rc != 0 { + if rc != SQLITE_OK { (*Sqlite3_backup)(unsafe.Pointer(p)).Frc = rc } } @@ -53359,11 +52797,11 @@ func Xsqlite3BtreeCopyFile(tls *libc.TLS, pTo uintptr, pFrom uintptr) int32 { /* goto __1 } *(*I64)(unsafe.Pointer(bp /* nByte */)) = (I64(Xsqlite3BtreeGetPageSize(tls, pFrom)) * I64(Xsqlite3BtreeLastPage(tls, pFrom))) - rc = Xsqlite3OsFileControl(tls, pFd, 11, bp /* &nByte */) - if !(rc == 12) { + rc = Xsqlite3OsFileControl(tls, pFd, SQLITE_FCNTL_OVERWRITE, bp /* &nByte */) + if !(rc == SQLITE_NOTFOUND) { goto __2 } - rc = 0 + rc = SQLITE_OK __2: ; if !(rc != 0) { @@ -53394,10 +52832,10 @@ __1: Xsqlite3_backup_step(tls, bp+8 /* &b */, 0x7FFFFFFF) rc = Xsqlite3_backup_finish(tls, bp+8 /* &b */) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __4 } - *(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(pTo)).FpBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0002))) + *(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(pTo)).FpBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_PAGESIZE_FIXED))) goto __5 __4: Xsqlite3PagerClearCache(tls, Xsqlite3BtreePager(tls, (*Sqlite3_backup)(unsafe.Pointer(bp+8 /* &b */)).FpDest)) @@ -53441,18 +52879,18 @@ func vdbeMemRenderNum(tls *libc.TLS, sz int32, zBuf uintptr, p uintptr) { /* sql // var acc StrAccum at bp+16, 32 - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0004) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Int) != 0 { // Work-around for GCC bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96270 // var x I64 at bp+8, 8 - libc.Xmemcpy(tls, bp+8 /* &x */, (p /* &.u */), (uint64((int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0004) * 2))) + libc.Xmemcpy(tls, bp+8 /* &x */, (p /* &.u */), (uint64((int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Int) * 2))) Xsqlite3Int64ToText(tls, *(*I64)(unsafe.Pointer(bp + 8 /* x */)), zBuf) } else { Xsqlite3StrAccumInit(tls, bp+16 /* &acc */, uintptr(0), zBuf, sz, 0) Xsqlite3_str_appendf(tls, bp+16 /* &acc */, ts+3875, /* "%!.15g" */ libc.VaList(bp, func() float64 { - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0020) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_IntReal) != 0 { return float64(*(*I64)(unsafe.Pointer(p /* &.u */))) } return *(*float64)(unsafe.Pointer(p /* &.u */)) @@ -53476,8 +52914,8 @@ func vdbeMemRenderNum(tls *libc.TLS, sz int32, zBuf uintptr, p uintptr) { /* sql func Xsqlite3VdbeChangeEncoding(tls *libc.TLS, pMem uintptr, desiredEnc int32) int32 { /* sqlite3.c:76027:20: */ var rc int32 - if !((int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0002) != 0) || (int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == desiredEnc) { - return 0 + if !((int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Str) != 0) || (int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == desiredEnc) { + return SQLITE_OK } // MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned, @@ -53519,7 +52957,7 @@ func Xsqlite3VdbeMemGrow(tls *libc.TLS, pMem uintptr, n int32, bPreserve int32) Xsqlite3VdbeMemSetNull(tls, pMem) (*Mem)(unsafe.Pointer(pMem)).Fz = uintptr(0) (*Mem)(unsafe.Pointer(pMem)).FszMalloc = 0 - return 7 + return SQLITE_NOMEM } else { (*Mem)(unsafe.Pointer(pMem)).FszMalloc = Xsqlite3DbMallocSize(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, (*Mem)(unsafe.Pointer(pMem)).FzMalloc) } @@ -53528,14 +52966,14 @@ func Xsqlite3VdbeMemGrow(tls *libc.TLS, pMem uintptr, n int32, bPreserve int32) libc.Xmemcpy(tls, (*Mem)(unsafe.Pointer(pMem)).FzMalloc, (*Mem)(unsafe.Pointer(pMem)).Fz, uint64((*Mem)(unsafe.Pointer(pMem)).Fn)) } - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0400) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Dyn) != 0 { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((pMem + 48 /* &.xDel */))))(tls, (*Mem)(unsafe.Pointer(pMem)).Fz) } (*Mem)(unsafe.Pointer(pMem)).Fz = (*Mem)(unsafe.Pointer(pMem)).FzMalloc - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((0x0400 | 0x1000) | 0x0800)))) - return 0 + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((MEM_Dyn | MEM_Ephem) | MEM_Static)))) + return SQLITE_OK } // Change the pMem->zMalloc allocation to be at least szNew bytes. @@ -53556,8 +52994,8 @@ func Xsqlite3VdbeMemClearAndResize(tls *libc.TLS, pMem uintptr, szNew int32) int } (*Mem)(unsafe.Pointer(pMem)).Fz = (*Mem)(unsafe.Pointer(pMem)).FzMalloc - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= U16((((0x0001 | 0x0004) | 0x0008) | 0x0020)) - return 0 + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= U16((((MEM_Null | MEM_Int) | MEM_Real) | MEM_IntReal)) + return SQLITE_OK } // It is already known that pMem contains an unterminated string. @@ -53569,13 +53007,13 @@ func Xsqlite3VdbeMemClearAndResize(tls *libc.TLS, pMem uintptr, szNew int32) int // is an odd number of bytes. func vdbeMemAddTerminator(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:76143:28: */ if Xsqlite3VdbeMemGrow(tls, pMem, ((*Mem)(unsafe.Pointer(pMem)).Fn+3), 1) != 0 { - return 7 + return SQLITE_NOMEM } *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn))) = int8(0) *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(((*Mem)(unsafe.Pointer(pMem)).Fn + 1)))) = int8(0) *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(((*Mem)(unsafe.Pointer(pMem)).Fn + 2)))) = int8(0) - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16((0x0200)) - return 0 + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16((MEM_Term)) + return SQLITE_OK } // Change pMem so that its MEM_Str or MEM_Blob value is stored in @@ -53584,14 +53022,14 @@ func vdbeMemAddTerminator(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:7614 // Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails. func Xsqlite3VdbeMemMakeWriteable(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:76160:20: */ - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0002 | 0x0010)) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Str | MEM_Blob)) != 0 { if func() int32 { - if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pMem) } return 0 }() != 0 { - return 7 + return SQLITE_NOMEM } if ((*Mem)(unsafe.Pointer(pMem)).FszMalloc == 0) || ((*Mem)(unsafe.Pointer(pMem)).Fz != (*Mem)(unsafe.Pointer(pMem)).FzMalloc) { var rc int32 = vdbeMemAddTerminator(tls, pMem) @@ -53600,9 +53038,9 @@ func Xsqlite3VdbeMemMakeWriteable(tls *libc.TLS, pMem uintptr) int32 { /* sqlite } } } - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x1000))) + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Ephem))) - return 0 + return SQLITE_OK } // If the given Mem* has a zero-filled tail, turn it into an ordinary @@ -53613,26 +53051,26 @@ func Xsqlite3VdbeMemExpandBlob(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c // Set nByte to the number of bytes required to store the expanded blob. nByte = ((*Mem)(unsafe.Pointer(pMem)).Fn + *(*int32)(unsafe.Pointer(pMem /* &.u */))) if nByte <= 0 { - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0010) == 0 { - return 0 + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Blob) == 0 { + return SQLITE_OK } nByte = 1 } if Xsqlite3VdbeMemGrow(tls, pMem, nByte, 1) != 0 { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, ((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn)), 0, uint64(*(*int32)(unsafe.Pointer(pMem /* &.u */)))) *(*int32)(unsafe.Pointer(pMem + 12 /* &.n */)) += (*(*int32)(unsafe.Pointer(pMem /* &.u */))) - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32((0x4000 | 0x0200)))) - return 0 + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32((MEM_Zero | MEM_Term)))) + return SQLITE_OK } // Make sure the given Mem is \u0000 terminated. func Xsqlite3VdbeMemNulTerminate(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:76211:20: */ - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0200 | 0x0002)) != 0x0002 { - return 0 // Nothing to do + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Term | MEM_Str)) != MEM_Str { + return SQLITE_OK // Nothing to do } else { return vdbeMemAddTerminator(tls, pMem) } @@ -53656,19 +53094,19 @@ func Xsqlite3VdbeMemStringify(tls *libc.TLS, pMem uintptr, enc U8, bForce U8) in if Xsqlite3VdbeMemClearAndResize(tls, pMem, nByte) != 0 { (*Mem)(unsafe.Pointer(pMem)).Fenc = U8(0) - return 7 + return SQLITE_NOMEM } vdbeMemRenderNum(tls, nByte, (*Mem)(unsafe.Pointer(pMem)).Fz, pMem) (*Mem)(unsafe.Pointer(pMem)).Fn = (int32(libc.Xstrlen(tls, (*Mem)(unsafe.Pointer(pMem)).Fz) & uint64(0x3fffffff))) - (*Mem)(unsafe.Pointer(pMem)).Fenc = U8(1) - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16((0x0002 | 0x0200)) + (*Mem)(unsafe.Pointer(pMem)).Fenc = SQLITE_UTF8 + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16((MEM_Str | MEM_Term)) if bForce != 0 { - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((0x0004 | 0x0008) | 0x0020)))) + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((MEM_Int | MEM_Real) | MEM_IntReal)))) } Xsqlite3VdbeChangeEncoding(tls, pMem, int32(enc)) - return 0 + return SQLITE_OK } // Memory cell pMem contains the context of an aggregate function. @@ -53687,7 +53125,7 @@ func Xsqlite3VdbeMemFinalize(tls *libc.TLS, pMem uintptr, pFunc uintptr) int32 { libc.Xmemset(tls, bp /* &ctx */, 0, uint64(unsafe.Sizeof(Sqlite3_context{}))) libc.Xmemset(tls, bp+56 /* &t */, 0, uint64(unsafe.Sizeof(Mem{}))) - (*Mem)(unsafe.Pointer(bp + 56 /* &t */)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(bp + 56 /* &t */)).Fflags = MEM_Null (*Mem)(unsafe.Pointer(bp + 56 /* &t */)).Fdb = (*Mem)(unsafe.Pointer(pMem)).Fdb (*Sqlite3_context)(unsafe.Pointer(bp /* &ctx */)).FpOut = bp + 56 /* &t */ (*Sqlite3_context)(unsafe.Pointer(bp /* &ctx */)).FpMem = pMem @@ -53731,15 +53169,15 @@ func Xsqlite3VdbeMemAggValue(tls *libc.TLS, pAccum uintptr, pOut uintptr, pFunc // entry point for releasing Mem resources. func vdbeMemClearExternAndSetNull(tls *libc.TLS, p uintptr) { /* sqlite3.c:76325:29: */ - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x2000) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Agg) != 0 { Xsqlite3VdbeMemFinalize(tls, p, *(*uintptr)(unsafe.Pointer(p /* &.u */))) } - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0400) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Dyn) != 0 { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((p + 48 /* &.xDel */))))(tls, (*Mem)(unsafe.Pointer(p)).Fz) } - (*Mem)(unsafe.Pointer(p)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(p)).Fflags = MEM_Null } // Release memory held by the Mem p, both external memory cleared @@ -53749,7 +53187,7 @@ func vdbeMemClearExternAndSetNull(tls *libc.TLS, p uintptr) { /* sqlite3.c:76325 // the unusual case where there really is memory in p that needs // to be freed. func vdbeMemClear(tls *libc.TLS, p uintptr) { /* sqlite3.c:76348:29: */ - if (int32((*Mem)(unsafe.Pointer((p))).Fflags) & (0x2000 | 0x0400)) != 0 { + if (int32((*Mem)(unsafe.Pointer((p))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { vdbeMemClearExternAndSetNull(tls, p) } if (*Mem)(unsafe.Pointer(p)).FszMalloc != 0 { @@ -53769,7 +53207,7 @@ func vdbeMemClear(tls *libc.TLS, p uintptr) { /* sqlite3.c:76348:29: */ // prior to inserting new content into the Mem. func Xsqlite3VdbeMemRelease(tls *libc.TLS, p uintptr) { /* sqlite3.c:76369:21: */ - if ((int32((*Mem)(unsafe.Pointer((p))).Fflags) & (0x2000 | 0x0400)) != 0) || ((*Mem)(unsafe.Pointer(p)).FszMalloc != 0) { + if ((int32((*Mem)(unsafe.Pointer((p))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0) || ((*Mem)(unsafe.Pointer(p)).FszMalloc != 0) { vdbeMemClear(tls, p) } } @@ -53814,12 +53252,12 @@ func Xsqlite3VdbeIntValue(tls *libc.TLS, pMem uintptr) I64 { /* sqlite3.c:76422: var flags int32 flags = int32((*Mem)(unsafe.Pointer(pMem)).Fflags) - if (flags & (0x0004 | 0x0020)) != 0 { + if (flags & (MEM_Int | MEM_IntReal)) != 0 { return *(*I64)(unsafe.Pointer(pMem /* &.u */)) - } else if (flags & 0x0008) != 0 { + } else if (flags & MEM_Real) != 0 { return doubleToInt64(tls, *(*float64)(unsafe.Pointer(pMem /* &.u */))) - } else if ((flags & (0x0002 | 0x0010)) != 0) && ((*Mem)(unsafe.Pointer(pMem)).Fz != uintptr(0)) { + } else if ((flags & (MEM_Str | MEM_Blob)) != 0) && ((*Mem)(unsafe.Pointer(pMem)).Fz != uintptr(0)) { return memIntValue(tls, pMem) } else { return int64(0) @@ -53843,12 +53281,12 @@ func memRealValue(tls *libc.TLS, pMem uintptr) float64 { /* sqlite3.c:76445:31: func Xsqlite3VdbeRealValue(tls *libc.TLS, pMem uintptr) float64 { /* sqlite3.c:76451:23: */ - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0008) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Real) != 0 { return *(*float64)(unsafe.Pointer(pMem /* &.u */)) - } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0004 | 0x0020)) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Int | MEM_IntReal)) != 0 { return float64(*(*I64)(unsafe.Pointer(pMem /* &.u */))) - } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0002 | 0x0010)) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Str | MEM_Blob)) != 0 { return memRealValue(tls, pMem) } else { // (double)0 In case of SQLITE_OMIT_FLOATING_POINT... @@ -53861,10 +53299,10 @@ func Xsqlite3VdbeRealValue(tls *libc.TLS, pMem uintptr) float64 { /* sqlite3.c:7 // Return the value ifNull if pMem is NULL. func Xsqlite3VdbeBooleanValue(tls *libc.TLS, pMem uintptr, ifNull int32) int32 { /* sqlite3.c:76471:20: */ - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0004 | 0x0020)) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Int | MEM_IntReal)) != 0 { return (libc.Bool32(*(*I64)(unsafe.Pointer(pMem /* &.u */)) != int64(0))) } - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0001) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Null) != 0 { return ifNull } return (libc.Bool32(Xsqlite3VdbeRealValue(tls, pMem) != 0.0)) @@ -53888,7 +53326,7 @@ func Xsqlite3VdbeIntegerAffinity(tls *libc.TLS, pMem uintptr) { /* sqlite3.c:764 // values to wrap around. if ((*(*float64)(unsafe.Pointer(pMem /* &.u */)) == float64(ix)) && (ix > ((int64(-1)) - (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))))) && (ix < (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))) { *(*I64)(unsafe.Pointer(pMem /* &.u */)) = ix - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) } } @@ -53896,8 +53334,8 @@ func Xsqlite3VdbeIntegerAffinity(tls *libc.TLS, pMem uintptr) { /* sqlite3.c:764 func Xsqlite3VdbeMemIntegerify(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:76510:20: */ *(*I64)(unsafe.Pointer(pMem /* &.u */)) = Xsqlite3VdbeIntValue(tls, pMem) - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) - return 0 + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) + return SQLITE_OK } // Convert pMem so that it is of type MEM_Real. @@ -53905,8 +53343,8 @@ func Xsqlite3VdbeMemIntegerify(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c func Xsqlite3VdbeMemRealify(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:76524:20: */ *(*float64)(unsafe.Pointer(pMem /* &.u */)) = Xsqlite3VdbeRealValue(tls, pMem) - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0008)) - return 0 + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Real)) + return SQLITE_OK } // Compare a floating point value to an integer. Return true if the two @@ -53938,7 +53376,7 @@ func Xsqlite3VdbeMemNumerify(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:7 bp := tls.Alloc(8) defer tls.Free(8) - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (((0x0004 | 0x0008) | 0x0020) | 0x0001)) == 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (((MEM_Int | MEM_Real) | MEM_IntReal) | MEM_Null)) == 0 { var rc int32 // var ix Sqlite3_int64 at bp, 8 @@ -53946,14 +53384,14 @@ func Xsqlite3VdbeMemNumerify(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:7 if (((rc == 0) || (rc == 1)) && (Xsqlite3Atoi64(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, bp /* &ix */, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc) <= 1)) || (Xsqlite3RealSameAsInt(tls, *(*float64)(unsafe.Pointer(pMem /* &.u */)), libc.AssignPtrInt64(bp /* ix */, I64(*(*float64)(unsafe.Pointer(pMem /* &.u */))))) != 0) { *(*I64)(unsafe.Pointer(pMem /* &.u */)) = *(*Sqlite3_int64)(unsafe.Pointer(bp /* ix */)) - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) } else { - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0008)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Real)) } } - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((0x0002 | 0x0010) | 0x4000)))) - return 0 + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((MEM_Str | MEM_Blob) | MEM_Zero)))) + return SQLITE_OK } // Cast the datatype of the value in pMem according to the affinity @@ -53962,37 +53400,37 @@ func Xsqlite3VdbeMemNumerify(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:7 // affinity even if that results in loss of data. This routine is // used (for example) to implement the SQL "cast()" operator. func Xsqlite3VdbeMemCast(tls *libc.TLS, pMem uintptr, aff U8, encoding U8) int32 { /* sqlite3.c:76589:20: */ - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0001) != 0 { - return 0 + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Null) != 0 { + return SQLITE_OK } switch int32(aff) { - case 0x41: + case SQLITE_AFF_BLOB: { // Really a cast to BLOB - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0010) == 0 { - Xsqlite3ValueApplyAffinity(tls, pMem, uint8(0x42), encoding) + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Blob) == 0 { + Xsqlite3ValueApplyAffinity(tls, pMem, SQLITE_AFF_TEXT, encoding) - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0002) != 0 { - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0010)) + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Str) != 0 { + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Blob)) } } else { - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32((0xc1bf & ^libc.Int32(0x0010))))) + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32((MEM_TypeMask & libc.CplInt32(MEM_Blob))))) } break } - case 0x43: + case SQLITE_AFF_NUMERIC: { Xsqlite3VdbeMemNumerify(tls, pMem) break } - case 0x44: + case SQLITE_AFF_INTEGER: { Xsqlite3VdbeMemIntegerify(tls, pMem) break } - case 0x45: + case SQLITE_AFF_REAL: { Xsqlite3VdbeMemRealify(tls, pMem) break @@ -54001,15 +53439,15 @@ func Xsqlite3VdbeMemCast(tls *libc.TLS, pMem uintptr, aff U8, encoding U8) int32 default: { - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16(((int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0010) >> 3)) - Xsqlite3ValueApplyAffinity(tls, pMem, uint8(0x42), encoding) + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16(((int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Blob) >> 3)) + Xsqlite3ValueApplyAffinity(tls, pMem, SQLITE_AFF_TEXT, encoding) - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((((0x0004 | 0x0008) | 0x0020) | 0x0010) | 0x4000)))) + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((((MEM_Int | MEM_Real) | MEM_IntReal) | MEM_Blob) | MEM_Zero)))) return Xsqlite3VdbeChangeEncoding(tls, pMem, int32(encoding)) } } - return 0 + return SQLITE_OK } // Initialize bulk memory to be a consistent Mem object. @@ -54033,10 +53471,10 @@ func Xsqlite3VdbeMemInit(tls *libc.TLS, pMem uintptr, db uintptr, flags U16) { / // // Use sqlite3VdbeMemRelease() to complete erase the Mem prior to abandoning it. func Xsqlite3VdbeMemSetNull(tls *libc.TLS, pMem uintptr) { /* sqlite3.c:76652:21: */ - if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & (0x2000 | 0x0400)) != 0 { + if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { vdbeMemClearExternAndSetNull(tls, pMem) } else { - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Null } } @@ -54048,13 +53486,13 @@ func Xsqlite3ValueSetNull(tls *libc.TLS, p uintptr) { /* sqlite3.c:76659:21: */ // n containing all zeros. func Xsqlite3VdbeMemSetZeroBlob(tls *libc.TLS, pMem uintptr, n int32) { /* sqlite3.c:76667:21: */ Xsqlite3VdbeMemRelease(tls, pMem) - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(0x0010 | 0x4000)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(MEM_Blob | MEM_Zero)) (*Mem)(unsafe.Pointer(pMem)).Fn = 0 if n < 0 { n = 0 } *(*int32)(unsafe.Pointer(pMem /* &.u */)) = n - (*Mem)(unsafe.Pointer(pMem)).Fenc = U8(1) + (*Mem)(unsafe.Pointer(pMem)).Fenc = SQLITE_UTF8 (*Mem)(unsafe.Pointer(pMem)).Fz = uintptr(0) } @@ -54064,17 +53502,17 @@ func Xsqlite3VdbeMemSetZeroBlob(tls *libc.TLS, pMem uintptr, n int32) { /* sqlit func vdbeReleaseAndSetInt64(tls *libc.TLS, pMem uintptr, val I64) { /* sqlite3.c:76682:29: */ Xsqlite3VdbeMemSetNull(tls, pMem) *(*I64)(unsafe.Pointer(pMem /* &.u */)) = val - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int } // Delete any previous value and set the value stored in *pMem to val, // manifest type INTEGER. func Xsqlite3VdbeMemSetInt64(tls *libc.TLS, pMem uintptr, val I64) { /* sqlite3.c:76692:21: */ - if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & (0x2000 | 0x0400)) != 0 { + if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { vdbeReleaseAndSetInt64(tls, pMem, val) } else { *(*I64)(unsafe.Pointer(pMem /* &.u */)) = val - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int } } @@ -54094,7 +53532,7 @@ func Xsqlite3VdbeMemSetPointer(tls *libc.TLS, pMem uintptr, pPtr uintptr, zPType return ts + 703 /* "" */ }() (*Mem)(unsafe.Pointer(pMem)).Fz = pPtr - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(((0x0001 | 0x0400) | 0x8000) | 0x0200)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(((MEM_Null | MEM_Dyn) | MEM_Subtype) | MEM_Term)) (*Mem)(unsafe.Pointer(pMem)).FeSubtype = U8('p') (*Mem)(unsafe.Pointer(pMem)).FxDel = func() uintptr { if xDestructor != 0 { @@ -54110,7 +53548,7 @@ func Xsqlite3VdbeMemSetDouble(tls *libc.TLS, pMem uintptr, val float64) { /* sql Xsqlite3VdbeMemSetNull(tls, pMem) if !(Xsqlite3IsNaN(tls, val) != 0) { *(*float64)(unsafe.Pointer(pMem /* &.u */)) = val - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0008) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Real } } @@ -54126,24 +53564,24 @@ func Xsqlite3VdbeMemSetRowSet(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c: Xsqlite3VdbeMemRelease(tls, pMem) p = Xsqlite3RowSetInit(tls, db) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Mem)(unsafe.Pointer(pMem)).Fz = p - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(0x0010 | 0x0400)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(MEM_Blob | MEM_Dyn)) (*Mem)(unsafe.Pointer(pMem)).FxDel = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3RowSetDelete})) - return 0 + return SQLITE_OK } // Return true if the Mem object contains a TEXT or BLOB that is // too large - whose size exceeds SQLITE_MAX_LENGTH. func Xsqlite3VdbeMemTooBig(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:76772:20: */ - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & (0x0002 | 0x0010)) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & (MEM_Str | MEM_Blob)) != 0 { var n int32 = (*Mem)(unsafe.Pointer(p)).Fn - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Zero) != 0 { n = n + (*(*int32)(unsafe.Pointer(p /* &.u */))) } - return (libc.Bool32(n > *(*int32)(unsafe.Pointer(((*Mem)(unsafe.Pointer(p)).Fdb + 124 /* &.aLimit */) + uintptr(0)*4)))) + return (libc.Bool32(n > *(*int32)(unsafe.Pointer(((*Mem)(unsafe.Pointer(p)).Fdb + 124 /* &.aLimit */))))) } return 0 } @@ -54160,13 +53598,13 @@ func vdbeClrCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr, eType int32) { /* sq func Xsqlite3VdbeMemShallowCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr, srcType int32) { /* sqlite3.c:76833:21: */ - if (int32((*Mem)(unsafe.Pointer((pTo))).Fflags) & (0x2000 | 0x0400)) != 0 { + if (int32((*Mem)(unsafe.Pointer((pTo))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { vdbeClrCopy(tls, pTo, pFrom, srcType) return } libc.Xmemcpy(tls, pTo, pFrom, uint64((uintptr(0) + 24 /* &.zMalloc */))) - if (int32((*Mem)(unsafe.Pointer(pFrom)).Fflags) & 0x0800) == 0 { - *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((0x0400 | 0x0800) | 0x1000)))) + if (int32((*Mem)(unsafe.Pointer(pFrom)).Fflags) & MEM_Static) == 0 { + *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((MEM_Dyn | MEM_Static) | MEM_Ephem)))) *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) |= U16((srcType)) } @@ -54175,16 +53613,16 @@ func Xsqlite3VdbeMemShallowCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr, srcTy // Make a full copy of pFrom into pTo. Prior contents of pTo are // freed before the copy is made. func Xsqlite3VdbeMemCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr) int32 { /* sqlite3.c:76849:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK - if (int32((*Mem)(unsafe.Pointer((pTo))).Fflags) & (0x2000 | 0x0400)) != 0 { + if (int32((*Mem)(unsafe.Pointer((pTo))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { vdbeMemClearExternAndSetNull(tls, pTo) } libc.Xmemcpy(tls, pTo, pFrom, uint64((uintptr(0) + 24 /* &.zMalloc */))) - *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0400))) - if (int32((*Mem)(unsafe.Pointer(pTo)).Fflags) & (0x0002 | 0x0010)) != 0 { - if 0 == (int32((*Mem)(unsafe.Pointer(pFrom)).Fflags) & 0x0800) { - *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) |= U16((0x1000)) + *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Dyn))) + if (int32((*Mem)(unsafe.Pointer(pTo)).Fflags) & (MEM_Str | MEM_Blob)) != 0 { + if 0 == (int32((*Mem)(unsafe.Pointer(pFrom)).Fflags) & MEM_Static) { + *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) |= U16((MEM_Ephem)) rc = Xsqlite3VdbeMemMakeWriteable(tls, pTo) } } @@ -54200,7 +53638,7 @@ func Xsqlite3VdbeMemMove(tls *libc.TLS, pTo uintptr, pFrom uintptr) { /* sqlite3 Xsqlite3VdbeMemRelease(tls, pTo) libc.Xmemcpy(tls, pTo, pFrom, uint64(unsafe.Sizeof(Mem{}))) - (*Mem)(unsafe.Pointer(pFrom)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pFrom)).Fflags = MEM_Null (*Mem)(unsafe.Pointer(pFrom)).FszMalloc = 0 } @@ -54225,29 +53663,29 @@ func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n int32, enc // If z is a NULL pointer, set pMem to contain an SQL NULL. if !(z != 0) { Xsqlite3VdbeMemSetNull(tls, pMem) - return 0 + return SQLITE_OK } if (*Mem)(unsafe.Pointer(pMem)).Fdb != 0 { - iLimit = *(*int32)(unsafe.Pointer(((*Mem)(unsafe.Pointer(pMem)).Fdb + 124 /* &.aLimit */) + uintptr(0)*4)) + iLimit = *(*int32)(unsafe.Pointer(((*Mem)(unsafe.Pointer(pMem)).Fdb + 124 /* &.aLimit */))) } else { - iLimit = 1000000000 + iLimit = SQLITE_MAX_LENGTH } flags = func() uint16 { if int32(enc) == 0 { - return uint16(0x0010) + return MEM_Blob } - return uint16(0x0002) + return MEM_Str }() if nByte < 0 { - if int32(enc) == 1 { + if int32(enc) == SQLITE_UTF8 { nByte = (0x7fffffff & int32(libc.Xstrlen(tls, z))) } else { for nByte = 0; (nByte <= iLimit) && ((int32(*(*int8)(unsafe.Pointer(z + uintptr(nByte)))) | int32(*(*int8)(unsafe.Pointer(z + uintptr((nByte + 1)))))) != 0); nByte = nByte + (2) { } } - flags = U16(int32(flags) | (0x0200)) + flags = U16(int32(flags) | (MEM_Term)) } // The following block sets the new values of Mem.z and Mem.xDel. It @@ -54255,16 +53693,16 @@ func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n int32, enc // management (one of MEM_Dyn or MEM_Static). if xDel == (libc.UintptrFromInt32(-1)) { var nAlloc U32 = U32(nByte) - if (int32(flags) & 0x0200) != 0 { + if (int32(flags) & MEM_Term) != 0 { nAlloc = nAlloc + (func() uint32 { - if int32(enc) == 1 { + if int32(enc) == SQLITE_UTF8 { return uint32(1) } return uint32(2) }()) } if nByte > iLimit { - return Xsqlite3ErrorToParser(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, 18) + return Xsqlite3ErrorToParser(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, SQLITE_TOOBIG) } if Xsqlite3VdbeMemClearAndResize(tls, pMem, func() int32 { @@ -54273,7 +53711,7 @@ func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n int32, enc } return 32 }()) != 0 { - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, z, uint64(nAlloc)) } else { @@ -54286,9 +53724,9 @@ func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n int32, enc (*Mem)(unsafe.Pointer(pMem)).FxDel = xDel flags = U16(int32(flags) | (func() int32 { if xDel == (uintptr(0)) { - return 0x0800 + return MEM_Static } - return 0x0400 + return MEM_Dyn }())) } } @@ -54302,15 +53740,15 @@ func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n int32, enc (*Mem)(unsafe.Pointer(pMem)).Fenc = (*Sqlite3)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fdb)).Fenc } - if (int32(enc) > 1) && (Xsqlite3VdbeMemHandleBom(tls, pMem) != 0) { - return 7 + if (int32(enc) > SQLITE_UTF8) && (Xsqlite3VdbeMemHandleBom(tls, pMem) != 0) { + return SQLITE_NOMEM } if nByte > iLimit { - return 18 + return SQLITE_TOOBIG } - return 0 + return SQLITE_OK } // Move data out of a btree key or data field and into a Mem structure. @@ -54328,15 +53766,15 @@ func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n int32, enc // to read from the disk) then the pMem is left in an inconsistent state. func Xsqlite3VdbeMemFromBtree(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pMem uintptr) int32 { /* sqlite3.c:77006:20: */ var rc int32 - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Null if Xsqlite3BtreeMaxRecordSize(tls, pCur) < (Sqlite3_int64(offset + amt)) { return Xsqlite3CorruptError(tls, 77015) } - if 0 == (libc.AssignInt32(&rc, Xsqlite3VdbeMemClearAndResize(tls, pMem, (int32(amt+U32(1)))))) { + if SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3VdbeMemClearAndResize(tls, pMem, (int32(amt+U32(1)))))) { rc = Xsqlite3BtreePayload(tls, pCur, offset, amt, (*Mem)(unsafe.Pointer(pMem)).Fz) - if rc == 0 { + if rc == SQLITE_OK { *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(amt))) = int8(0) // Overrun area used when reading malformed records - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0010) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Blob (*Mem)(unsafe.Pointer(pMem)).Fn = int32(amt) } else { Xsqlite3VdbeMemRelease(tls, pMem) @@ -54350,7 +53788,7 @@ func Xsqlite3VdbeMemFromBtreeZeroOffset(tls *libc.TLS, pCur uintptr, amt U32, pM defer tls.Free(4) *(*U32)(unsafe.Pointer(bp /* available */)) = U32(0) // Number of bytes available on the local btree page - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code // Note: the calls to BtreeKeyFetch() and DataFetch() below assert() // that both the BtShared and database handle mutexes are held. @@ -54358,7 +53796,7 @@ func Xsqlite3VdbeMemFromBtreeZeroOffset(tls *libc.TLS, pCur uintptr, amt U32, pM (*Mem)(unsafe.Pointer(pMem)).Fz = Xsqlite3BtreePayloadFetch(tls, pCur, bp /* &available */) if amt <= *(*U32)(unsafe.Pointer(bp /* available */)) { - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(0x0010 | 0x1000)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(MEM_Blob | MEM_Ephem)) (*Mem)(unsafe.Pointer(pMem)).Fn = int32(amt) } else { rc = Xsqlite3VdbeMemFromBtree(tls, pCur, uint32(0), amt, pMem) @@ -54372,22 +53810,22 @@ func Xsqlite3VdbeMemFromBtreeZeroOffset(tls *libc.TLS, pCur uintptr, amt U32, pM // to a zero-terminated version of that string. func valueToText(tls *libc.TLS, pVal uintptr, enc U8) uintptr { /* sqlite3.c:77061:35: */ - if (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & (0x0010 | 0x0002)) != 0 { + if (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & (MEM_Blob | MEM_Str)) != 0 { if func() int32 { - if (int32((*Sqlite3_value)(unsafe.Pointer((pVal))).Fflags) & 0x4000) != 0 { + if (int32((*Sqlite3_value)(unsafe.Pointer((pVal))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pVal) } return 0 }() != 0 { return uintptr(0) } - *(*U16)(unsafe.Pointer(pVal + 8 /* &.flags */)) |= U16((0x0002)) - if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) != (int32(enc) & ^libc.Int32(8)) { - Xsqlite3VdbeChangeEncoding(tls, pVal, (int32(enc) & ^libc.Int32(8))) + *(*U16)(unsafe.Pointer(pVal + 8 /* &.flags */)) |= U16((MEM_Str)) + if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) != (int32(enc) & libc.CplInt32(SQLITE_UTF16_ALIGNED)) { + Xsqlite3VdbeChangeEncoding(tls, pVal, (int32(enc) & libc.CplInt32(SQLITE_UTF16_ALIGNED))) } - if ((int32(enc) & 8) != 0) && (1 == (1 & (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fz)))) { + if ((int32(enc) & SQLITE_UTF16_ALIGNED) != 0) && (1 == (1 & (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fz)))) { - if Xsqlite3VdbeMemMakeWriteable(tls, pVal) != 0 { + if Xsqlite3VdbeMemMakeWriteable(tls, pVal) != SQLITE_OK { return uintptr(0) } } @@ -54397,7 +53835,7 @@ func valueToText(tls *libc.TLS, pVal uintptr, enc U8) uintptr { /* sqlite3.c:770 } - if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == (int32(enc) & ^libc.Int32(8)) { + if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == (int32(enc) & libc.CplInt32(SQLITE_UTF16_ALIGNED)) { return (*Sqlite3_value)(unsafe.Pointer(pVal)).Fz } else { @@ -54420,11 +53858,11 @@ func Xsqlite3ValueText(tls *libc.TLS, pVal uintptr, enc U8) uintptr { /* sqlite3 return uintptr(0) } - if ((int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & (0x0002 | 0x0200)) == (0x0002 | 0x0200)) && (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == int32(enc)) { + if ((int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & (MEM_Str | MEM_Term)) == (MEM_Str | MEM_Term)) && (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == int32(enc)) { return (*Sqlite3_value)(unsafe.Pointer(pVal)).Fz } - if (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & 0x0001) != 0 { + if (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & MEM_Null) != 0 { return uintptr(0) } return valueToText(tls, pVal, enc) @@ -54434,7 +53872,7 @@ func Xsqlite3ValueText(tls *libc.TLS, pVal uintptr, enc U8) uintptr { /* sqlite3 func Xsqlite3ValueNew(tls *libc.TLS, db uintptr) uintptr { /* sqlite3.c:77122:30: */ var p uintptr = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Mem{}))) if p != 0 { - (*Mem)(unsafe.Pointer(p)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(p)).Fflags = MEM_Null (*Mem)(unsafe.Pointer(p)).Fdb = db } return p @@ -54461,7 +53899,7 @@ type ValueNewStat4Ctx = struct { // an sqlite3_value within the UnpackedRecord.a[] array. func valueNew(tls *libc.TLS, db uintptr, p uintptr) uintptr { /* sqlite3.c:77153:22: */ if p != 0 { - var pRec uintptr = *(*uintptr)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FppRec + uintptr(0)*8)) + var pRec uintptr = *(*uintptr)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FppRec)) if pRec == uintptr(0) { var pIdx uintptr = (*ValueNewStat4Ctx)(unsafe.Pointer(p)).FpIdx // Index being probed @@ -54469,15 +53907,15 @@ func valueNew(tls *libc.TLS, db uintptr, p uintptr) uintptr { /* sqlite3.c:77153 var i int32 // Counter variable var nCol int32 = int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) // Number of index columns including rowid - nByte = (int32((uint64(unsafe.Sizeof(Mem{})) * uint64(nCol)) + (((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + nByte = (int32((uint64(unsafe.Sizeof(Mem{})) * uint64(nCol)) + (((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))))) pRec = Xsqlite3DbMallocZero(tls, db, uint64(nByte)) if pRec != 0 { (*UnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo = Xsqlite3KeyInfoOfIndex(tls, (*ValueNewStat4Ctx)(unsafe.Pointer(p)).FpParse, pIdx) if (*UnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo != 0 { - (*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem = (pRec + uintptr((((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + (*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem = (pRec + uintptr((((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))))) for i = 0; i < nCol; i++ { - (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem + uintptr(i)*56)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem + uintptr(i)*56)).Fflags = MEM_Null (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem + uintptr(i)*56)).Fdb = db } } else { @@ -54488,7 +53926,7 @@ func valueNew(tls *libc.TLS, db uintptr, p uintptr) uintptr { /* sqlite3.c:77153 if pRec == uintptr(0) { return uintptr(0) } - *(*uintptr)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FppRec + uintptr(0)*8)) = pRec + *(*uintptr)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FppRec)) = pRec } (*UnpackedRecord)(unsafe.Pointer(pRec)).FnField = (U16((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FiVal + 1)) @@ -54532,7 +53970,7 @@ func valueFromFunction(tls *libc.TLS, db uintptr, p uintptr, enc U8, aff U8, ppV nVal = 0 pFunc = uintptr(0) pVal = uintptr(0) - rc = 0 + rc = SQLITE_OK pList = uintptr(0) // Iterator variable pList = *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) @@ -54544,11 +53982,11 @@ __1: ; pFunc = Xsqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)), nVal, enc, uint8(0)) - if !((((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & (U32(0x0800 | 0x2000))) == U32(0)) || - (((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & U32(0x0020)) != 0)) { + if !((((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & (U32(SQLITE_FUNC_CONSTANT | SQLITE_FUNC_SLOCHNG))) == U32(0)) || + (((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != 0)) { goto __2 } - return 0 + return SQLITE_OK __2: ; @@ -54559,7 +53997,7 @@ __2: if !(apVal == uintptr(0)) { goto __4 } - rc = 7 + rc = SQLITE_NOMEM goto value_from_function_out __4: ; @@ -54569,7 +54007,7 @@ __5: goto __7 } rc = Xsqlite3ValueFromExpr(tls, db, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FpExpr, enc, aff, (apVal + uintptr(i)*8)) - if !((*(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8)) == uintptr(0)) || (rc != 0)) { + if !((*(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8)) == uintptr(0)) || (rc != SQLITE_OK)) { goto __8 } goto value_from_function_out @@ -54589,7 +54027,7 @@ __3: if !(pVal == uintptr(0)) { goto __9 } - rc = 7 + rc = SQLITE_NOMEM goto value_from_function_out __9: ; @@ -54605,13 +54043,13 @@ __9: Xsqlite3ErrorMsg(tls, (*ValueNewStat4Ctx)(unsafe.Pointer(pCtx)).FpParse, ts+2690 /* "%s" */, libc.VaList(bp, Xsqlite3_value_text(tls, pVal))) goto __11 __10: - Xsqlite3ValueApplyAffinity(tls, pVal, aff, uint8(1)) + Xsqlite3ValueApplyAffinity(tls, pVal, aff, SQLITE_UTF8) rc = Xsqlite3VdbeChangeEncoding(tls, pVal, int32(enc)) - if !((rc == 0) && (Xsqlite3VdbeMemTooBig(tls, pVal) != 0)) { + if !((rc == SQLITE_OK) && (Xsqlite3VdbeMemTooBig(tls, pVal) != 0)) { goto __12 } - rc = 18 + rc = SQLITE_TOOBIG (*Parse)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(pCtx)).FpParse)).FnErr++ __12: ; @@ -54620,7 +54058,7 @@ __11: (*Parse)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(pCtx)).FpParse)).Frc = rc value_from_function_out: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __13 } pVal = uintptr(0) @@ -54675,17 +54113,17 @@ func valueFromExpr(tls *libc.TLS, db uintptr, pExpr uintptr, enc U8, affinity U8 *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) = uintptr(0) negInt = 1 zNeg = ts + 703 /* "" */ - rc = 0 + rc = SQLITE_OK __1: - if !(((libc.AssignInt32(&op, int32((*Expr)(unsafe.Pointer(pExpr)).Fop))) == 171) || (op == 178)) { + if !(((libc.AssignInt32(&op, int32((*Expr)(unsafe.Pointer(pExpr)).Fop))) == TK_UPLUS) || (op == TK_SPAN)) { goto __2 } pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft goto __1 __2: ; - if !(op == 173) { + if !(op == TK_REGISTER) { goto __3 } op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) @@ -54697,7 +54135,7 @@ __3: // check ensures that an EP_TokenOnly expression is never passed down // into valueFromFunction(). - if !(op == 36) { + if !(op == TK_CAST) { goto __4 } aff = U8(Xsqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), uintptr(0))) @@ -54706,8 +54144,8 @@ __3: if !(*(*uintptr)(unsafe.Pointer(ppVal)) != 0) { goto __5 } - Xsqlite3VdbeMemCast(tls, *(*uintptr)(unsafe.Pointer(ppVal)), aff, uint8(1)) - Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(ppVal)), affinity, uint8(1)) + Xsqlite3VdbeMemCast(tls, *(*uintptr)(unsafe.Pointer(ppVal)), aff, SQLITE_UTF8) + Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(ppVal)), affinity, SQLITE_UTF8) __5: ; return rc @@ -54716,8 +54154,8 @@ __4: // Handle negative integers in a single step. This is needed in the // case when the value is -9223372036854775808. - if !((op == 170) && - ((int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == 152) || (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == 150))) { + if !((op == TK_UMINUS) && + ((int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_INTEGER) || (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_FLOAT))) { goto __6 } pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft @@ -54727,7 +54165,7 @@ __4: __6: ; - if !(((op == 115) || (op == 150)) || (op == 152)) { + if !(((op == TK_STRING) || (op == TK_FLOAT)) || (op == TK_INTEGER)) { goto __7 } *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) = valueNew(tls, db, pCtx) @@ -54737,7 +54175,7 @@ __6: goto no_mem __9: ; - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000400))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_IntValue)) != U32(0)) { goto __10 } Xsqlite3VdbeMemSetInt64(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), (I64(*(*int32)(unsafe.Pointer(pExpr + 8 /* &.u */))) * I64(negInt))) @@ -54750,27 +54188,27 @@ __10: goto no_mem __12: ; - Xsqlite3ValueSetStr(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), -1, zVal, uint8(1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) + Xsqlite3ValueSetStr(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), -1, zVal, SQLITE_UTF8, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) __11: ; - if !(((op == 152) || (op == 150)) && (int32(affinity) == 0x41)) { + if !(((op == TK_INTEGER) || (op == TK_FLOAT)) && (int32(affinity) == SQLITE_AFF_BLOB)) { goto __13 } - Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), uint8(0x43), uint8(1)) + Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), SQLITE_AFF_NUMERIC, SQLITE_UTF8) goto __14 __13: - Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), affinity, uint8(1)) + Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), affinity, SQLITE_UTF8) __14: ; - if !((int32((*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags) & ((0x0004 | 0x0020) | 0x0008)) != 0) { + if !((int32((*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags) & ((MEM_Int | MEM_IntReal) | MEM_Real)) != 0) { goto __15 } - *(*U16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0002))) + *(*U16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Str))) __15: ; - if !(int32(enc) != 1) { + if !(int32(enc) != SQLITE_UTF8) { goto __16 } rc = Xsqlite3VdbeChangeEncoding(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), int32(enc)) @@ -54778,16 +54216,16 @@ __16: ; goto __8 __7: - if !(op == 170) { + if !(op == TK_UMINUS) { goto __17 } // This branch happens for multiple negative signs. Ex: -(-5) - if !((0 == valueFromExpr(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, enc, affinity, bp+16 /* &pVal */, pCtx)) && + if !((SQLITE_OK == valueFromExpr(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, enc, affinity, bp+16 /* &pVal */, pCtx)) && (*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) != uintptr(0))) { goto __19 } Xsqlite3VdbeMemNumerify(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */))) - if !((int32((*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags) & 0x0008) != 0) { + if !((int32((*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags) & MEM_Real) != 0) { goto __20 } *(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) = -*(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) @@ -54797,7 +54235,7 @@ __20: goto __22 } *(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) = -(float64((int64(-1)) - (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32)))) - (*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags = (U16((int32((*Sqlite3_value)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */))))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0008)) + (*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags = (U16((int32((*Sqlite3_value)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */))))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Real)) goto __23 __22: *(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) = -*(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) @@ -54810,7 +54248,7 @@ __19: ; goto __18 __17: - if !(op == 119) { + if !(op == TK_NULL) { goto __24 } *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) = valueNew(tls, db, pCtx) @@ -54823,7 +54261,7 @@ __26: Xsqlite3VdbeMemSetNull(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */))) goto __25 __24: - if !(op == 151) { + if !(op == TK_BLOB) { goto __27 } @@ -54834,28 +54272,28 @@ __24: goto no_mem __29: ; - zVal = (*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + uintptr(2)) + zVal = (*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + 2) nVal = (Xsqlite3Strlen30(tls, zVal) - 1) Xsqlite3VdbeMemSetStr(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), Xsqlite3HexToBlob(tls, db, zVal, nVal), (nVal / 2), uint8(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) goto __28 __27: - if !((op == 169) && (pCtx != uintptr(0))) { + if !((op == TK_FUNCTION) && (pCtx != uintptr(0))) { goto __30 } rc = valueFromFunction(tls, db, pExpr, enc, affinity, bp+16 /* &pVal */, pCtx) goto __31 __30: - if !(op == 167) { + if !(op == TK_TRUEFALSE) { goto __32 } *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) = valueNew(tls, db, pCtx) if !(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) != 0) { goto __33 } - (*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags = U16(0x0004) - *(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) = (I64(libc.Bool32(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + uintptr(4)))) == 0))) + (*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags = MEM_Int + *(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) = (I64(libc.Bool32(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + 4))) == 0))) __33: ; __32: @@ -54889,7 +54327,7 @@ __34: Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */))) __35: ; - return 7 + return SQLITE_NOMEM } // Create a new sqlite3_value object, containing the value of pExpr. @@ -54927,7 +54365,7 @@ func stat4ValueFromExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr, affinity U bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp /* pVal */)) = uintptr(0) var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb @@ -54939,7 +54377,7 @@ func stat4ValueFromExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr, affinity U if *(*uintptr)(unsafe.Pointer(bp /* pVal */)) != 0 { Xsqlite3VdbeMemSetNull(tls, *(*uintptr)(unsafe.Pointer(bp /* pVal */))) } - } else if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 153) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00800000)) == uint64(0)) { + } else if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_VARIABLE) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_EnableQPSG) == uint64(0)) { var v uintptr var iBindVar int32 = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) Xsqlite3VdbeSetVarmask(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, iBindVar) @@ -54995,10 +54433,10 @@ func Xsqlite3Stat4ProbeSetValue(tls *libc.TLS, pParse uintptr, pIdx uintptr, ppR bp := tls.Alloc(40) defer tls.Free(40) - var rc int32 = 0 + var rc int32 = SQLITE_OK var nExtract int32 = 0 - if (pExpr == uintptr(0)) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 136) { + if (pExpr == uintptr(0)) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_SELECT) { var i int32 // var alloc ValueNewStat4Ctx at bp, 32 @@ -55097,12 +54535,12 @@ func Xsqlite3Stat4Column(tls *libc.TLS, db uintptr, pRec uintptr, nRec int32, iC if pMem == uintptr(0) { pMem = libc.AssignPtrUintptr(ppVal, Xsqlite3ValueNew(tls, db)) if pMem == uintptr(0) { - return 7 + return SQLITE_NOMEM } } Xsqlite3VdbeSerialGet(tls, (a + uintptr((iField - szField))), *(*U32)(unsafe.Pointer(bp + 4 /* t */)), pMem) (*Mem)(unsafe.Pointer(pMem)).Fenc = (*Sqlite3)(unsafe.Pointer(db)).Fenc - return 0 + return SQLITE_OK } // Unless it is NULL, the argument must be an UnpackedRecord object returned @@ -55113,7 +54551,7 @@ func Xsqlite3Stat4ProbeFree(tls *libc.TLS, pRec uintptr) { /* sqlite3.c:77675:21 var i int32 var nCol int32 = int32((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo)).FnAllField) var aMem uintptr = (*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem - var db uintptr = (*Mem)(unsafe.Pointer(aMem + uintptr(0)*56)).Fdb + var db uintptr = (*Mem)(unsafe.Pointer(aMem)).Fdb for i = 0; i < nCol; i++ { Xsqlite3VdbeMemRelease(tls, (aMem + uintptr(i)*56)) } @@ -55151,17 +54589,17 @@ func valueBytes(tls *libc.TLS, pVal uintptr, enc U8) int32 { /* sqlite3.c:77717: func Xsqlite3ValueBytes(tls *libc.TLS, pVal uintptr, enc U8) int32 { /* sqlite3.c:77720:20: */ var p uintptr = pVal - if ((int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0002) != 0) && (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == int32(enc)) { + if ((int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Str) != 0) && (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == int32(enc)) { return (*Mem)(unsafe.Pointer(p)).Fn } - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0010) != 0 { - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Blob) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Zero) != 0 { return ((*Mem)(unsafe.Pointer(p)).Fn + *(*int32)(unsafe.Pointer(p /* &.u */))) } else { return (*Mem)(unsafe.Pointer(p)).Fn } } - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0001) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Null) != 0 { return 0 } return valueBytes(tls, pVal, enc) @@ -55183,11 +54621,11 @@ func Xsqlite3VdbeCreate(tls *libc.TLS, pParse uintptr) uintptr { /* sqlite3.c:77 (*Vdbe)(unsafe.Pointer(p)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).FpVdbe (*Vdbe)(unsafe.Pointer(p)).FpPrev = uintptr(0) (*Sqlite3)(unsafe.Pointer(db)).FpVdbe = p - (*Vdbe)(unsafe.Pointer(p)).Fmagic = U32(0x16bceaa5) + (*Vdbe)(unsafe.Pointer(p)).Fmagic = VDBE_MAGIC_INIT (*Vdbe)(unsafe.Pointer(p)).FpParse = pParse (*Parse)(unsafe.Pointer(pParse)).FpVdbe = p - Xsqlite3VdbeAddOp2(tls, p, 62, 0, 1) + Xsqlite3VdbeAddOp2(tls, p, OP_Init, 0, 1) return p } @@ -55212,7 +54650,7 @@ func Xsqlite3VdbeSetSql(tls *libc.TLS, p uintptr, z uintptr, n int32, prepFlags return } (*Vdbe)(unsafe.Pointer(p)).FprepFlags = prepFlags - if (int32(prepFlags) & 0x80) == 0 { + if (int32(prepFlags) & SQLITE_PREPARE_SAVESQL) == 0 { (*Vdbe)(unsafe.Pointer(p)).Fexpmask = U32(0) } @@ -55240,7 +54678,7 @@ func Xsqlite3VdbeSwap(tls *libc.TLS, pA uintptr, pB uintptr) { /* sqlite3.c:7785 (*Vdbe)(unsafe.Pointer(pB)).Fexpmask = (*Vdbe)(unsafe.Pointer(pA)).Fexpmask (*Vdbe)(unsafe.Pointer(pB)).FprepFlags = (*Vdbe)(unsafe.Pointer(pA)).FprepFlags libc.Xmemcpy(tls, pB+212 /* &.aCounter */, pA+212 /* &.aCounter */, uint64(unsafe.Sizeof([7]U32{}))) - *(*U32)(unsafe.Pointer((pB + 212 /* &.aCounter */) + uintptr(5)*4))++ + *(*U32)(unsafe.Pointer((pB + 212 /* &.aCounter */) + 5*4))++ } // Resize the Vdbe.aOp array so that it is at least nOp elements larger @@ -55271,9 +54709,9 @@ func growOpArray(tls *libc.TLS, v uintptr, nOp int32) int32 { /* sqlite3.c:77895 _ = nOp // Ensure that the size of a VDBE does not grow too large - if nNew > Sqlite3_int64(*(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(p)).Fdb + 124 /* &.aLimit */) + uintptr(5)*4))) { + if nNew > Sqlite3_int64(*(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(p)).Fdb + 124 /* &.aLimit */) + 5*4))) { Xsqlite3OomFault(tls, (*Parse)(unsafe.Pointer(p)).Fdb) - return 7 + return SQLITE_NOMEM } pNew = Xsqlite3DbRealloc(tls, (*Parse)(unsafe.Pointer(p)).Fdb, (*Vdbe)(unsafe.Pointer(v)).FaOp, (uint64(nNew) * uint64(unsafe.Sizeof(Op{})))) @@ -55284,9 +54722,9 @@ func growOpArray(tls *libc.TLS, v uintptr, nOp int32) int32 { /* sqlite3.c:77895 } return func() int32 { if pNew != 0 { - return 0 + return SQLITE_OK } - return 7 + return SQLITE_NOMEM }() } @@ -55330,7 +54768,7 @@ func Xsqlite3VdbeAddOp3(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, (*VdbeOp)(unsafe.Pointer(pOp)).Fp2 = p2 (*VdbeOp)(unsafe.Pointer(pOp)).Fp3 = p3 *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) = uintptr(0) - (*VdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(0) + (*VdbeOp)(unsafe.Pointer(pOp)).Fp4type = P4_NOTUSED return i } @@ -55348,13 +54786,13 @@ func Xsqlite3VdbeAddOp2(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32) // Generate code for an unconditional jump to instruction iDest func Xsqlite3VdbeGoto(tls *libc.TLS, p uintptr, iDest int32) int32 { /* sqlite3.c:78021:20: */ - return Xsqlite3VdbeAddOp3(tls, p, 11, 0, iDest, 0) + return Xsqlite3VdbeAddOp3(tls, p, OP_Goto, 0, iDest, 0) } // Generate code to cause the string zStr to be loaded into // register iDest func Xsqlite3VdbeLoadString(tls *libc.TLS, p uintptr, iDest int32, zStr uintptr) int32 { /* sqlite3.c:78028:20: */ - return Xsqlite3VdbeAddOp4(tls, p, 115, 0, iDest, 0, zStr, 0) + return Xsqlite3VdbeAddOp4(tls, p, OP_String8, 0, iDest, 0, zStr, 0) } // Generate code that initializes multiple registers to string or integer @@ -55384,16 +54822,16 @@ __1: z = libc.VaUintptr(&ap) Xsqlite3VdbeAddOp4(tls, p, func() int32 { if z == uintptr(0) { - return 72 + return OP_Null } - return 115 + return OP_String8 }(), 0, (iDest + i), 0, z, 0) goto __5 __4: if !(int32(c) == 'i') { goto __6 } - Xsqlite3VdbeAddOp2(tls, p, 69, int32(libc.VaInt32(&ap)), (iDest + i)) + Xsqlite3VdbeAddOp2(tls, p, OP_Integer, int32(libc.VaInt32(&ap)), (iDest + i)) goto __7 __6: goto skip_op_resultrow @@ -55408,7 +54846,7 @@ __2: goto __3 __3: ; - Xsqlite3VdbeAddOp2(tls, p, 80, iDest, i) + Xsqlite3VdbeAddOp2(tls, p, OP_ResultRow, iDest, i) skip_op_resultrow: _ = ap } @@ -55449,12 +54887,12 @@ func Xsqlite3VdbeAddFunctionCall(tls *libc.TLS, pParse uintptr, p1 int32, p2 int (*Sqlite3_context)(unsafe.Pointer(pCtx)).FiOp = Xsqlite3VdbeCurrentAddr(tls, v) addr = Xsqlite3VdbeAddOp4(tls, v, func() int32 { if eCallCtx != 0 { - return 63 + return OP_PureFunc } - return 64 + return OP_Function }(), p1, p2, p3, pCtx, -16) - Xsqlite3VdbeChangeP5(tls, v, (uint16(eCallCtx & 0x0002e))) + Xsqlite3VdbeChangeP5(tls, v, (uint16(eCallCtx & NC_SelfRef))) return addr } @@ -55500,7 +54938,7 @@ func Xsqlite3VdbeExplain(tls *libc.TLS, pParse uintptr, bPush U8, zFmt uintptr, _ = ap v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe iThis = (*Vdbe)(unsafe.Pointer(v)).FnOp - Xsqlite3VdbeAddOp4(tls, v, 174, iThis, (*Parse)(unsafe.Pointer(pParse)).FaddrExplain, 0, + Xsqlite3VdbeAddOp4(tls, v, OP_Explain, iThis, (*Parse)(unsafe.Pointer(pParse)).FaddrExplain, 0, zMsg, -7) if bPush != 0 { @@ -55523,7 +54961,7 @@ func Xsqlite3VdbeExplainPop(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:78198: // This routine will take ownership of the allocated memory. func Xsqlite3VdbeAddParseSchemaOp(tls *libc.TLS, p uintptr, iDb int32, zWhere uintptr) { /* sqlite3.c:78212:21: */ var j int32 - Xsqlite3VdbeAddOp4(tls, p, 141, iDb, 0, 0, zWhere, -7) + Xsqlite3VdbeAddOp4(tls, p, OP_ParseSchema, iDb, 0, 0, zWhere, -7) for j = 0; j < (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FnDb; j++ { Xsqlite3VdbeUsesBtree(tls, p, j) } @@ -55542,7 +54980,7 @@ func Xsqlite3VdbeAddOp4Int(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int3 // Insert the end of a co-routine func Xsqlite3VdbeEndCoroutine(tls *libc.TLS, v uintptr, regYield int32) { /* sqlite3.c:78240:21: */ - Xsqlite3VdbeAddOp1(tls, v, 66, regYield) + Xsqlite3VdbeAddOp1(tls, v, OP_EndCoroutine, regYield) // Clear the temporary register cache, thereby ensuring that each // co-routine has its own independent set of registers, because co-routines @@ -55651,33 +55089,32 @@ func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) { /* sqlite // all these opcodes together near the front of the opcode list. Skip // any opcode that does not need processing by virtual of the fact that // it is larger than SQLITE_MX_JUMP_OPCODE, as a performance optimization. - if int32((*Op)(unsafe.Pointer(pOp)).Fopcode) <= 62 { + if int32((*Op)(unsafe.Pointer(pOp)).Fopcode) <= SQLITE_MX_JUMP_OPCODE { // NOTE: Be sure to update mkopcodeh.tcl when adding or removing // cases from this switch! switch int32((*Op)(unsafe.Pointer(pOp)).Fopcode) { - case 2: + case OP_Transaction: { if (*Op)(unsafe.Pointer(pOp)).Fp2 != 0 { libc.SetBitFieldPtr16Uint32(p+200 /* &.readOnly */, Bft(0), 7, 0x80) } - /* no break */ } fallthrough - case 1: + case OP_AutoCommit: fallthrough - case 0: + case OP_Savepoint: { libc.SetBitFieldPtr16Uint32(p+200 /* &.bIsReader */, Bft(1), 8, 0x100) break } fallthrough - case 6: + case OP_Checkpoint: fallthrough - case 8: + case OP_Vacuum: fallthrough - case 7: + case OP_JournalMode: { libc.SetBitFieldPtr16Uint32(p+200 /* &.readOnly */, Bft(0), 7, 0x80) libc.SetBitFieldPtr16Uint32(p+200 /* &.bIsReader */, Bft(1), 8, 0x100) @@ -55685,9 +55122,9 @@ func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) { /* sqlite } fallthrough - case 5: + case OP_Next: fallthrough - case 3: + case OP_SorterNext: { *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32) int32 @@ -55701,7 +55138,7 @@ func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) { /* sqlite } fallthrough - case 4: + case OP_Prev: { *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32) int32 @@ -55715,7 +55152,7 @@ func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) { /* sqlite } fallthrough - case 10: + case OP_VUpdate: { if (*Op)(unsafe.Pointer(pOp)).Fp2 > nMaxArgs { nMaxArgs = (*Op)(unsafe.Pointer(pOp)).Fp2 @@ -55724,7 +55161,7 @@ func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) { /* sqlite } fallthrough - case 9: + case OP_VFilter: { var n int32 @@ -55732,8 +55169,6 @@ func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) { /* sqlite if n > nMaxArgs { nMaxArgs = n } - // Fall through into the default case - /* no break */ } fallthrough @@ -55834,11 +55269,11 @@ __1: (*VdbeOp)(unsafe.Pointer(pOut)).Fp1 = int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp1) (*VdbeOp)(unsafe.Pointer(pOut)).Fp2 = int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp2) - if ((int32(Xsqlite3OpcodeProperty[(*VdbeOpList)(unsafe.Pointer(aOp)).Fopcode]) & 0x01) != 0) && (int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp2) > 0) { + if ((int32(Xsqlite3OpcodeProperty[(*VdbeOpList)(unsafe.Pointer(aOp)).Fopcode]) & OPFLG_JUMP) != 0) && (int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp2) > 0) { *(*int32)(unsafe.Pointer(pOut + 8 /* &.p2 */)) += ((*Vdbe)(unsafe.Pointer(p)).FnOp) } (*VdbeOp)(unsafe.Pointer(pOut)).Fp3 = int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp3) - (*VdbeOp)(unsafe.Pointer(pOut)).Fp4type = int8(0) + (*VdbeOp)(unsafe.Pointer(pOut)).Fp4type = P4_NOTUSED *(*uintptr)(unsafe.Pointer(pOut + 16 /* &.p4 */)) = uintptr(0) (*VdbeOp)(unsafe.Pointer(pOut)).Fp5 = U16(0) _ = iLineno @@ -55911,7 +55346,7 @@ func Xsqlite3VdbeJumpHereOrPopInst(tls *libc.TLS, p uintptr, addr int32) { /* sq // If the input FuncDef structure is ephemeral, then free it. If // the FuncDef is not ephermal, then do nothing. func freeEphemeralFunction(tls *libc.TLS, db uintptr, pDef uintptr) { /* sqlite3.c:78840:13: */ - if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0010)) != U32(0) { + if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_EPHEM) != U32(0) { Xsqlite3DbFreeNN(tls, db, pDef) } } @@ -56024,9 +55459,9 @@ func Xsqlite3VdbeChangeToNoop(tls *libc.TLS, p uintptr, addr int32) int32 { /* s pOp = ((*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(addr)*24) freeP4(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp4type), *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */))) - (*VdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(0) + (*VdbeOp)(unsafe.Pointer(pOp)).Fp4type = P4_NOTUSED *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) = uintptr(0) - (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(173) + (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = OP_Noop return 1 } @@ -56182,7 +55617,7 @@ func Xsqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) uintptr { /* var zP4 uintptr = uintptr(0) // var x StrAccum at bp+144, 32 - Xsqlite3StrAccumInit(tls, bp+144 /* &x */, uintptr(0), uintptr(0), 0, 1000000000) + Xsqlite3StrAccumInit(tls, bp+144 /* &x */, uintptr(0), uintptr(0), 0, SQLITE_MAX_LENGTH) switch int32((*Op)(unsafe.Pointer(pOp)).Fp4type) { case -9: { @@ -56203,13 +55638,13 @@ func Xsqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) uintptr { /* } Xsqlite3_str_appendf(tls, bp+144 /* &x */, ts+3896, /* ",%s%s%s" */ libc.VaList(bp+8, func() uintptr { - if (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j)))) & 0x01) != 0 { + if (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j)))) & KEYINFO_ORDER_DESC) != 0 { return ts + 3882 /* "-" */ } return ts + 703 /* "" */ }(), func() uintptr { - if (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j)))) & 0x02) != 0 { + if (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j)))) & KEYINFO_ORDER_BIGNULL) != 0 { return ts + 3904 /* "N." */ } return ts + 703 /* "" */ @@ -56264,13 +55699,13 @@ func Xsqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) uintptr { /* case -11: { var pMem uintptr = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0002) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Str) != 0 { zP4 = (*Mem)(unsafe.Pointer(pMem)).Fz - } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0004 | 0x0020)) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Int | MEM_IntReal)) != 0 { Xsqlite3_str_appendf(tls, bp+144 /* &x */, ts+3925 /* "%lld" */, libc.VaList(bp+104, *(*I64)(unsafe.Pointer(pMem /* &.u */)))) - } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0008) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Real) != 0 { Xsqlite3_str_appendf(tls, bp+144 /* &x */, ts+486 /* "%.16g" */, libc.VaList(bp+112, *(*float64)(unsafe.Pointer(pMem /* &.u */)))) - } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0001) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Null) != 0 { zP4 = ts + 704 /* "NULL" */ } else { @@ -56290,7 +55725,7 @@ func Xsqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) uintptr { /* { var i U32 var ai uintptr = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) - var n U32 = *(*U32)(unsafe.Pointer(ai + uintptr(0)*4)) // The first element of an INTARRAY is always the + var n U32 = *(*U32)(unsafe.Pointer(ai)) // The first element of an INTARRAY is always the // count of the number of elements to follow for i = U32(1); i <= n; i++ { Xsqlite3_str_appendf(tls, bp+144 /* &x */, ts+3948 /* "%c%u" */, libc.VaList(bp+128, func() int32 { @@ -56332,7 +55767,7 @@ func Xsqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) uintptr { /* if zP4 != 0 { Xsqlite3_str_appendall(tls, bp+144 /* &x */, zP4) } - if (int32((*StrAccum)(unsafe.Pointer(bp+144 /* &x */)).FaccError) & 7) != 0 { + if (int32((*StrAccum)(unsafe.Pointer(bp+144 /* &x */)).FaccError) & SQLITE_NOMEM) != 0 { Xsqlite3OomFault(tls, db) } return Xsqlite3StrAccumFinish(tls, bp+144 /* &x */) @@ -56451,14 +55886,14 @@ func releaseMemArray(tls *libc.TLS, p uintptr, N int32) { /* sqlite3.c:79619:13: // with no indexes using a single prepared INSERT statement, bind() // and reset(). Inserts are grouped into a transaction. - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & (0x2000 | 0x0400)) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { Xsqlite3VdbeMemRelease(tls, p) } else if (*Mem)(unsafe.Pointer(p)).FszMalloc != 0 { Xsqlite3DbFreeNN(tls, db, (*Mem)(unsafe.Pointer(p)).FzMalloc) (*Mem)(unsafe.Pointer(p)).FszMalloc = 0 } - (*Mem)(unsafe.Pointer(p)).Fflags = U16(0x0080) + (*Mem)(unsafe.Pointer(p)).Fflags = MEM_Undefined } } } @@ -56485,7 +55920,7 @@ func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, var nSub int32 = 0 // Number of sub-vdbes seen so far var apSub uintptr = uintptr(0) // Array of sub-vdbes var i int32 // Next instruction address - var rc int32 = 0 // Result code + var rc int32 = SQLITE_OK // Result code var aOp uintptr = uintptr(0) // Opcode array var iPc int32 // Rowid. Copy of value in *piPc @@ -56497,7 +55932,7 @@ func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, // encountered, but p->pc will eventually catch up to nRow. nRow = (*Vdbe)(unsafe.Pointer(p)).FnOp if pSub != uintptr(0) { - if (int32((*Mem)(unsafe.Pointer(pSub)).Fflags) & 0x0010) != 0 { + if (int32((*Mem)(unsafe.Pointer(pSub)).Fflags) & MEM_Blob) != 0 { // pSub is initiallly NULL. It is initialized to a BLOB by // the P4_SUBPROGRAM processing logic below nSub = (int32(uint64((*Mem)(unsafe.Pointer(pSub)).Fn) / uint64(unsafe.Sizeof(uintptr(0))))) @@ -56511,8 +55946,8 @@ func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, for 1 != 0 { // Loop exits via break i = libc.PostIncInt32(&iPc, 1) if i >= nRow { - (*Vdbe)(unsafe.Pointer(p)).Frc = 0 - rc = 101 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK + rc = SQLITE_DONE break } if i < (*Vdbe)(unsafe.Pointer(p)).FnOp { @@ -56546,13 +55981,13 @@ func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, } if j == nSub { (*Vdbe)(unsafe.Pointer(p)).Frc = Xsqlite3VdbeMemGrow(tls, pSub, nByte, (libc.Bool32(nSub != 0))) - if (*Vdbe)(unsafe.Pointer(p)).Frc != 0 { - rc = 1 + if (*Vdbe)(unsafe.Pointer(p)).Frc != SQLITE_OK { + rc = SQLITE_ERROR break } apSub = (*Mem)(unsafe.Pointer(pSub)).Fz *(*uintptr)(unsafe.Pointer(apSub + uintptr(libc.PostIncInt32(&nSub, 1))*8)) = *(*uintptr)(unsafe.Pointer(aOp + uintptr(i)*24 + 16 /* &.p4 */)) - (*Mem)(unsafe.Pointer(pSub)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pSub))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0010)) + (*Mem)(unsafe.Pointer(pSub)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pSub))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Blob)) (*Mem)(unsafe.Pointer(pSub)).Fn = (int32(uint64(nSub) * uint64(unsafe.Sizeof(uintptr(0))))) nRow = nRow + ((*SubProgram)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aOp + uintptr(i)*24 + 16 /* &.p4 */)))).FnOp) } @@ -56562,10 +55997,10 @@ func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, } { - if int32((*Op)(unsafe.Pointer(aOp+uintptr(i)*24)).Fopcode) == 174 { + if int32((*Op)(unsafe.Pointer(aOp+uintptr(i)*24)).Fopcode) == OP_Explain { break } - if (int32((*Op)(unsafe.Pointer(aOp+uintptr(i)*24)).Fopcode) == 62) && (iPc > 1) { + if (int32((*Op)(unsafe.Pointer(aOp+uintptr(i)*24)).Fopcode) == OP_Init) && (iPc > 1) { break } @@ -56581,7 +56016,7 @@ func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, // allocated by the OP_Program opcode in sqlite3VdbeExec(). func Xsqlite3VdbeFrameDelete(tls *libc.TLS, p uintptr) { /* sqlite3.c:79808:21: */ var i int32 - var aMem uintptr = ((p) + uintptr((((uint64(unsafe.Sizeof(VdbeFrame{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + var aMem uintptr = ((p) + 112) var apCsr uintptr = (aMem + uintptr((*VdbeFrame)(unsafe.Pointer(p)).FnChildMem)*56) for i = 0; i < (*VdbeFrame)(unsafe.Pointer(p)).FnChildCsr; i++ { @@ -56616,9 +56051,9 @@ func Xsqlite3VdbeList(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:79840:20: * var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb // The database connection // var i int32 at bp, 4 // Loop counter - var rc int32 = 0 // Return code - var pMem uintptr = ((*Vdbe)(unsafe.Pointer(p)).FaMem + uintptr(1)*56) // First Mem of result set - var bListSubprogs int32 = (libc.Bool32(((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.explain */)) & 0xc >> 2)) == 1) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x01000000)) != uint64(0)))) + var rc int32 = SQLITE_OK // Return code + var pMem uintptr = ((*Vdbe)(unsafe.Pointer(p)).FaMem + 1*56) // First Mem of result set + var bListSubprogs int32 = (libc.Bool32(((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.explain */)) & 0xc >> 2)) == 1) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_TriggerEQP) != uint64(0)))) // var aOp uintptr at bp+8, 8 // Array of opcodes var pOp uintptr // Current opcode @@ -56629,11 +56064,11 @@ func Xsqlite3VdbeList(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:79840:20: * releaseMemArray(tls, pMem, 8) (*Vdbe)(unsafe.Pointer(p)).FpResultSet = uintptr(0) - if (*Vdbe)(unsafe.Pointer(p)).Frc == 7 { + if (*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_NOMEM { // This happens if a malloc() inside a call to sqlite3_column_text() or // sqlite3_column_text16() failed. Xsqlite3OomFault(tls, db) - return 1 + return SQLITE_ERROR } if bListSubprogs != 0 { @@ -56642,7 +56077,7 @@ func Xsqlite3VdbeList(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:79840:20: * // to trigger subprograms. The VDBE is guaranteed to have at least 9 // cells. - pSub = ((*Vdbe)(unsafe.Pointer(p)).FaMem + uintptr(9)*56) + pSub = ((*Vdbe)(unsafe.Pointer(p)).FaMem + 9*56) } else { pSub = uintptr(0) } @@ -56650,11 +56085,11 @@ func Xsqlite3VdbeList(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:79840:20: * // Figure out which opcode is next to display rc = Xsqlite3VdbeNextOpcode(tls, p, pSub, (libc.Bool32((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.explain */)) & 0xc >> 2)) == 2)), (p + 52 /* &.pc */), bp /* &i */, bp+8 /* &aOp */) - if rc == 0 { + if rc == SQLITE_OK { pOp = (*(*uintptr)(unsafe.Pointer(bp + 8 /* aOp */)) + uintptr(*(*int32)(unsafe.Pointer(bp /* i */)))*24) if libc.AtomicLoadNInt32((db+392 /* &.u1 */ /* &.isInterrupted */), 0) != 0 { - (*Vdbe)(unsafe.Pointer(p)).Frc = 9 - rc = 1 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_INTERRUPT + rc = SQLITE_ERROR Xsqlite3VdbeError(tls, p, Xsqlite3ErrStr(tls, (*Vdbe)(unsafe.Pointer(p)).Frc), 0) } else { var zP4 uintptr = Xsqlite3VdbeDisplayP4(tls, db, pOp) @@ -56662,28 +56097,28 @@ func Xsqlite3VdbeList(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:79840:20: * Xsqlite3VdbeMemSetInt64(tls, pMem, int64((*Op)(unsafe.Pointer(pOp)).Fp1)) Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(1)*56), int64((*Op)(unsafe.Pointer(pOp)).Fp2)) Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(2)*56), int64((*Op)(unsafe.Pointer(pOp)).Fp3)) - Xsqlite3VdbeMemSetStr(tls, (pMem + uintptr(3)*56), zP4, -1, uint8(1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) + Xsqlite3VdbeMemSetStr(tls, (pMem + uintptr(3)*56), zP4, -1, SQLITE_UTF8, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) (*Vdbe)(unsafe.Pointer(p)).FnResColumn = U16(4) } else { Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(0)*56), int64(*(*int32)(unsafe.Pointer(bp /* i */)))) Xsqlite3VdbeMemSetStr(tls, (pMem + uintptr(1)*56), Xsqlite3OpcodeName(tls, int32((*Op)(unsafe.Pointer(pOp)).Fopcode)), - -1, uint8(1), uintptr(0)) + -1, SQLITE_UTF8, uintptr(0)) Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(2)*56), int64((*Op)(unsafe.Pointer(pOp)).Fp1)) Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(3)*56), int64((*Op)(unsafe.Pointer(pOp)).Fp2)) Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(4)*56), int64((*Op)(unsafe.Pointer(pOp)).Fp3)) // pMem+5 for p4 is done last Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(6)*56), int64((*Op)(unsafe.Pointer(pOp)).Fp5)) Xsqlite3VdbeMemSetNull(tls, (pMem + uintptr(7)*56)) - Xsqlite3VdbeMemSetStr(tls, (pMem + uintptr(5)*56), zP4, -1, uint8(1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) + Xsqlite3VdbeMemSetStr(tls, (pMem + uintptr(5)*56), zP4, -1, SQLITE_UTF8, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) (*Vdbe)(unsafe.Pointer(p)).FnResColumn = U16(8) } (*Vdbe)(unsafe.Pointer(p)).FpResultSet = pMem if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - (*Vdbe)(unsafe.Pointer(p)).Frc = 7 - rc = 1 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM + rc = SQLITE_ERROR } else { - (*Vdbe)(unsafe.Pointer(p)).Frc = 0 - rc = 100 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK + rc = SQLITE_ROW } } } @@ -56715,7 +56150,7 @@ type ReusableSpace = struct { func allocSpace(tls *libc.TLS, p uintptr, pBuf uintptr, nByte Sqlite3_int64) uintptr { /* sqlite3.c:80005:13: */ if pBuf == uintptr(0) { - nByte = (((nByte) + int64(7)) & ^libc.Int64FromInt32(7)) + nByte = (((nByte) + int64(7)) & int64(libc.CplInt32(7))) if nByte <= (*ReusableSpace)(unsafe.Pointer(p)).FnFree { *(*Sqlite3_int64)(unsafe.Pointer(p + 8 /* &.nFree */)) -= (nByte) pBuf = ((*ReusableSpace)(unsafe.Pointer(p)).FpSpace + uintptr((*ReusableSpace)(unsafe.Pointer(p)).FnFree)) @@ -56734,11 +56169,11 @@ func Xsqlite3VdbeRewind(tls *libc.TLS, p uintptr) { /* sqlite3.c:80028:21: */ // There should be at least one opcode. // Set the magic to VDBE_MAGIC_RUN sooner rather than later. - (*Vdbe)(unsafe.Pointer(p)).Fmagic = U32(0x2df20da3) + (*Vdbe)(unsafe.Pointer(p)).Fmagic = VDBE_MAGIC_RUN (*Vdbe)(unsafe.Pointer(p)).Fpc = -1 - (*Vdbe)(unsafe.Pointer(p)).Frc = 0 - (*Vdbe)(unsafe.Pointer(p)).FerrorAction = U8(2) + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK + (*Vdbe)(unsafe.Pointer(p)).FerrorAction = OE_Abort (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 (*Vdbe)(unsafe.Pointer(p)).FcacheCtr = U32(1) (*Vdbe)(unsafe.Pointer(p)).FminWriteFileFormat = U8(255) @@ -56795,10 +56230,10 @@ func Xsqlite3VdbeMakeReady(tls *libc.TLS, p uintptr, pParse uintptr) { /* sqlite // Figure out how much reusable memory is available at the end of the // opcode array. This extra memory will be reallocated for other elements // of the prepared statement. - n = (int32(((uint64(unsafe.Sizeof(Op{})) * uint64((*Vdbe)(unsafe.Pointer(p)).FnOp)) + uint64(7)) & ^libc.Uint64FromInt32(7))) // Bytes of opcode memory used - (*ReusableSpace)(unsafe.Pointer(bp + 8 /* &x */)).FpSpace = (((*Vdbe)(unsafe.Pointer(p)).FaOp) + uintptr(n)) // Unused opcode memory + n = (int32(((uint64(unsafe.Sizeof(Op{})) * uint64((*Vdbe)(unsafe.Pointer(p)).FnOp)) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) // Bytes of opcode memory used + (*ReusableSpace)(unsafe.Pointer(bp + 8 /* &x */)).FpSpace = (((*Vdbe)(unsafe.Pointer(p)).FaOp) + uintptr(n)) // Unused opcode memory - (*ReusableSpace)(unsafe.Pointer(bp + 8 /* &x */)).FnFree = (Sqlite3_int64(((*Parse)(unsafe.Pointer(pParse)).FszOpAlloc - n) & ^libc.Int32(7))) // Bytes of unused memory + (*ReusableSpace)(unsafe.Pointer(bp + 8 /* &x */)).FnFree = (Sqlite3_int64(((*Parse)(unsafe.Pointer(pParse)).FszOpAlloc - n) & libc.CplInt32(7))) // Bytes of unused memory resolveP2Values(tls, p, bp /* &nArg */) libc.SetBitFieldPtr16Uint32(p+200 /* &.usesStmtJournal */, Bft((U8(libc.Bool32(((*Parse)(unsafe.Pointer(pParse)).FisMultiWrite != 0) && ((*Parse)(unsafe.Pointer(pParse)).FmayAbort != 0))))), 6, 0x40) @@ -56820,7 +56255,7 @@ func Xsqlite3VdbeMakeReady(tls *libc.TLS, p uintptr, pParse uintptr) { /* sqlite mx = 8 } for i = iFirst; i < mx; i++ { - Xsqlite3VdbeSetColName(tls, p, (i - iFirst), 0, + Xsqlite3VdbeSetColName(tls, p, (i - iFirst), COLNAME_NAME, azColName[i], uintptr(0)) } } @@ -56860,9 +56295,9 @@ func Xsqlite3VdbeMakeReady(tls *libc.TLS, p uintptr, pParse uintptr) { /* sqlite } else { (*Vdbe)(unsafe.Pointer(p)).FnCursor = nCursor (*Vdbe)(unsafe.Pointer(p)).FnVar = YnVar(nVar) - initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar, nVar, db, uint16(0x0001)) + initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar, nVar, db, MEM_Null) (*Vdbe)(unsafe.Pointer(p)).FnMem = nMem - initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaMem, nMem, db, uint16(0x0080)) + initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaMem, nMem, db, MEM_Undefined) libc.Xmemset(tls, (*Vdbe)(unsafe.Pointer(p)).FapCsr, 0, (uint64(nCursor) * uint64(unsafe.Sizeof(uintptr(0))))) } Xsqlite3VdbeRewind(tls, p) @@ -56881,13 +56316,13 @@ func Xsqlite3VdbeFreeCursor(tls *libc.TLS, p uintptr, pCx uintptr) { /* sqlite3. } switch int32((*VdbeCursor)(unsafe.Pointer(pCx)).FeCurType) { - case 1: + case CURTYPE_SORTER: { Xsqlite3VdbeSorterClose(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, pCx) break } - case 0: + case CURTYPE_BTREE: { if (Bool(int32(*(*uint8)(unsafe.Pointer(pCx + 8 /* &.isEphemeral */)) & 0x1 >> 0))) != 0 { if (*VdbeCursor)(unsafe.Pointer(pCx)).FpBtx != 0 { @@ -56902,7 +56337,7 @@ func Xsqlite3VdbeFreeCursor(tls *libc.TLS, p uintptr, pCx uintptr) { /* sqlite3. break } - case 2: + case CURTYPE_VTAB: { var pVCur uintptr = *(*uintptr)(unsafe.Pointer(pCx + 56 /* &.uc */)) var pModule uintptr = (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(pVCur)).FpVtab)).FpModule @@ -56992,16 +56427,16 @@ func Xsqlite3VdbeSetNumCols(tls *libc.TLS, p uintptr, nResColumn int32) { /* sql var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb if (*Vdbe)(unsafe.Pointer(p)).FnResColumn != 0 { - releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, (int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn) * 5)) + releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, (int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn) * COLNAME_N)) Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FaColName) } - n = (nResColumn * 5) + n = (nResColumn * COLNAME_N) (*Vdbe)(unsafe.Pointer(p)).FnResColumn = U16(nResColumn) (*Vdbe)(unsafe.Pointer(p)).FaColName = Xsqlite3DbMallocRawNN(tls, db, (uint64(uint64(unsafe.Sizeof(Mem{})) * uint64(n)))) if (*Vdbe)(unsafe.Pointer(p)).FaColName == uintptr(0) { return } - initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, n, db, uint16(0x0001)) + initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, n, db, MEM_Null) } // Set the name of the idx'th column to be returned by the SQL statement. @@ -57018,11 +56453,11 @@ func Xsqlite3VdbeSetColName(tls *libc.TLS, p uintptr, idx int32, var1 int32, zNa if (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FmallocFailed != 0 { - return 7 + return SQLITE_NOMEM } pColName = ((*Vdbe)(unsafe.Pointer(p)).FaColName + uintptr((idx+(var1*int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn))))*56) - rc = Xsqlite3VdbeMemSetStr(tls, pColName, zName, -1, uint8(1), xDel) + rc = Xsqlite3VdbeMemSetStr(tls, pColName, zName, -1, SQLITE_UTF8, xDel) return rc } @@ -57039,7 +56474,7 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 var nTrans int32 = 0 // Number of databases with an active write-transaction // that are candidates for a two-phase commit using a // super-journal - var rc int32 = 0 + var rc int32 = SQLITE_OK var needXcommit int32 = 0 // Before doing anything else, call the xSync() callback for any @@ -57054,14 +56489,14 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 // including the temp database. (b) is important because if more than // one database file has an open write transaction, a super-journal // file is required for an atomic commit. - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt if Xsqlite3BtreeIsInTrans(tls, pBt) != 0 { var pPager uintptr // Pager associated with pBt needXcommit = 1 Xsqlite3BtreeEnter(tls, pBt) pPager = Xsqlite3BtreePager(tls, pBt) - if ((int32((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).Fsafety_level) != 0x01) && + if ((int32((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).Fsafety_level) != PAGER_SYNCHRONOUS_OFF) && (aMJNeeded[Xsqlite3PagerGetJournalMode(tls, pPager)] != 0)) && (Xsqlite3PagerIsMemdb(tls, pPager) == 0) { @@ -57071,7 +56506,7 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 Xsqlite3BtreeLeave(tls, pBt) } } - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -57079,7 +56514,7 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 if (needXcommit != 0) && ((*Sqlite3)(unsafe.Pointer(db)).FxCommitCallback != 0) { rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((db + 272 /* &.xCommitCallback */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpCommitArg) if rc != 0 { - return (19 | (int32(2) << 8)) + return (SQLITE_CONSTRAINT | (int32(2) << 8)) } } @@ -57091,9 +56526,9 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 // string, it means the main database is :memory: or a temp file. In // that case we do not support atomic multi-file commits, so use the // simple case then too. - if (0 == Xsqlite3Strlen30(tls, Xsqlite3BtreeGetFilename(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt))) || + if (0 == Xsqlite3Strlen30(tls, Xsqlite3BtreeGetFilename(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt))) || (nTrans <= 1) { - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt if pBt != 0 { rc = Xsqlite3BtreeCommitPhaseOne(tls, pBt, uintptr(0)) @@ -57104,19 +56539,19 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 // If one of the BtreeCommitPhaseOne() calls fails, this indicates an // IO error while deleting or truncating a journal file. It is unlikely, // but could happen. In this case abandon processing and return the error. - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt if pBt != 0 { rc = Xsqlite3BtreeCommitPhaseTwo(tls, pBt, 0) } } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3VtabCommit(tls, db) } } else { var pVfs uintptr = (*Sqlite3)(unsafe.Pointer(db)).FpVfs var zSuper uintptr = uintptr(0) // File-name for the super-journal - var zMainFile uintptr = Xsqlite3BtreeGetFilename(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt) + var zMainFile uintptr = Xsqlite3BtreeGetFilename(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt) *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */)) = uintptr(0) var offset I64 = int64(0) // var res int32 at bp+60, 4 @@ -57128,19 +56563,19 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 nMainFile = Xsqlite3Strlen30(tls, zMainFile) zSuper = Xsqlite3MPrintf(tls, db, ts+4037 /* "%.4c%s%.16c" */, libc.VaList(bp, 0, zMainFile, 0)) if zSuper == uintptr(0) { - return 7 + return SQLITE_NOMEM } zSuper += uintptr(4) - for ok := true; ok; ok = ((rc == 0) && (*(*int32)(unsafe.Pointer(bp + 60 /* res */)) != 0)) { + for ok := true; ok; ok = ((rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 60 /* res */)) != 0)) { // var iRandom U32 at bp+56, 4 if retryCount != 0 { if retryCount > 100 { - Xsqlite3_log(tls, 13, ts+4049 /* "MJ delete: %s" */, libc.VaList(bp+24, zSuper)) + Xsqlite3_log(tls, SQLITE_FULL, ts+4049 /* "MJ delete: %s" */, libc.VaList(bp+24, zSuper)) Xsqlite3OsDelete(tls, pVfs, zSuper, 0) break } else if retryCount == 1 { - Xsqlite3_log(tls, 13, ts+4063 /* "MJ collide: %s" */, libc.VaList(bp+32, zSuper)) + Xsqlite3_log(tls, SQLITE_FULL, ts+4063 /* "MJ collide: %s" */, libc.VaList(bp+32, zSuper)) } } retryCount++ @@ -57150,14 +56585,14 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 // The antipenultimate character of the super-journal name must // be "9" to avoid name collisions when using 8+3 filenames. - rc = Xsqlite3OsAccess(tls, pVfs, zSuper, 0, bp+60 /* &res */) + rc = Xsqlite3OsAccess(tls, pVfs, zSuper, SQLITE_ACCESS_EXISTS, bp+60 /* &res */) } - if rc == 0 { + if rc == SQLITE_OK { // Open the super-journal. rc = Xsqlite3OsOpenMalloc(tls, pVfs, zSuper, bp+64, /* &pSuperJrnl */ - (((0x00000002 | 0x00000004) | 0x00000010) | 0x00004000), uintptr(0)) + (((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_SUPER_JOURNAL), uintptr(0)) } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3DbFree(tls, db, (zSuper - uintptr(4))) return rc } @@ -57177,7 +56612,7 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 rc = Xsqlite3OsWrite(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */)), zFile, (Xsqlite3Strlen30(tls, zFile) + 1), offset) offset = offset + (I64(Xsqlite3Strlen30(tls, zFile) + 1)) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3OsCloseFree(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */))) Xsqlite3OsDelete(tls, pVfs, zSuper, 0) Xsqlite3DbFree(tls, db, (zSuper - uintptr(4))) @@ -57188,8 +56623,8 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 // Sync the super-journal file. If the IOCAP_SEQUENTIAL device // flag is set this is not required. - if (0 == (Xsqlite3OsDeviceCharacteristics(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */))) & 0x00000400)) && - (0 != (libc.AssignInt32(&rc, Xsqlite3OsSync(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */)), 0x00002)))) { + if (0 == (Xsqlite3OsDeviceCharacteristics(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */))) & SQLITE_IOCAP_SEQUENTIAL)) && + (SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3OsSync(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */)), SQLITE_SYNC_NORMAL)))) { Xsqlite3OsCloseFree(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */))) Xsqlite3OsDelete(tls, pVfs, zSuper, 0) Xsqlite3DbFree(tls, db, (zSuper - uintptr(4))) @@ -57205,7 +56640,7 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 // super-journal file will be orphaned. But we cannot delete it, // in case the super-journal file name was written into the journal // file before the failure occurred. - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt if pBt != 0 { rc = Xsqlite3BtreeCommitPhaseOne(tls, pBt, zSuper) @@ -57213,7 +56648,7 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 } Xsqlite3OsCloseFree(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */))) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3DbFree(tls, db, (zSuper - uintptr(4))) return rc } @@ -57277,21 +56712,21 @@ var aMJNeeded = [6]U8{ // Otherwise SQLITE_OK. func vdbeCloseStatement(tls *libc.TLS, p uintptr, eOp int32) int32 { /* sqlite3.c:80669:28: */ var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 var iSavepoint int32 = ((*Vdbe)(unsafe.Pointer(p)).FiStatement - 1) for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { - var rc2 int32 = 0 + var rc2 int32 = SQLITE_OK var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt if pBt != 0 { - if eOp == 2 { - rc2 = Xsqlite3BtreeSavepoint(tls, pBt, 2, iSavepoint) + if eOp == SAVEPOINT_ROLLBACK { + rc2 = Xsqlite3BtreeSavepoint(tls, pBt, SAVEPOINT_ROLLBACK, iSavepoint) } - if rc2 == 0 { - rc2 = Xsqlite3BtreeSavepoint(tls, pBt, 1, iSavepoint) + if rc2 == SQLITE_OK { + rc2 = Xsqlite3BtreeSavepoint(tls, pBt, SAVEPOINT_RELEASE, iSavepoint) } - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } @@ -57299,19 +56734,19 @@ func vdbeCloseStatement(tls *libc.TLS, p uintptr, eOp int32) int32 { /* sqlite3. (*Sqlite3)(unsafe.Pointer(db)).FnStatement-- (*Vdbe)(unsafe.Pointer(p)).FiStatement = 0 - if rc == 0 { - if eOp == 2 { - rc = Xsqlite3VtabSavepoint(tls, db, 2, iSavepoint) + if rc == SQLITE_OK { + if eOp == SAVEPOINT_ROLLBACK { + rc = Xsqlite3VtabSavepoint(tls, db, SAVEPOINT_ROLLBACK, iSavepoint) } - if rc == 0 { - rc = Xsqlite3VtabSavepoint(tls, db, 1, iSavepoint) + if rc == SQLITE_OK { + rc = Xsqlite3VtabSavepoint(tls, db, SAVEPOINT_RELEASE, iSavepoint) } } // If the statement transaction is being rolled back, also restore the // database handles deferred constraint counter to the value it had when // the statement transaction was opened. - if eOp == 2 { + if eOp == SAVEPOINT_ROLLBACK { (*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons = (*Vdbe)(unsafe.Pointer(p)).FnStmtDefCons (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = (*Vdbe)(unsafe.Pointer(p)).FnStmtDefImmCons } @@ -57322,7 +56757,7 @@ func Xsqlite3VdbeCloseStatement(tls *libc.TLS, p uintptr, eOp int32) int32 { /* if ((*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FnStatement != 0) && ((*Vdbe)(unsafe.Pointer(p)).FiStatement != 0) { return vdbeCloseStatement(tls, p, eOp) } - return 0 + return SQLITE_OK } // This function is called when a transaction opened by the database @@ -57337,12 +56772,12 @@ func Xsqlite3VdbeCheckFk(tls *libc.TLS, p uintptr, deferred int32) int32 { /* sq var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb if ((deferred != 0) && (((*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons + (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons) > int64(0))) || (!(deferred != 0) && ((*Vdbe)(unsafe.Pointer(p)).FnFkConstraint > int64(0))) { - (*Vdbe)(unsafe.Pointer(p)).Frc = (19 | (int32(3) << 8)) - (*Vdbe)(unsafe.Pointer(p)).FerrorAction = U8(2) + (*Vdbe)(unsafe.Pointer(p)).Frc = (SQLITE_CONSTRAINT | (int32(3) << 8)) + (*Vdbe)(unsafe.Pointer(p)).FerrorAction = OE_Abort Xsqlite3VdbeError(tls, p, ts+4091 /* "FOREIGN KEY cons..." */, 0) - return 1 + return SQLITE_ERROR } - return 0 + return SQLITE_OK } // This routine is called the when a VDBE tries to halt. If the VDBE @@ -57375,11 +56810,11 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * // state. We need to rollback the statement transaction, if there is // one, or the complete transaction if there is no statement transaction. - if (*Vdbe)(unsafe.Pointer(p)).Fmagic != U32(0x2df20da3) { - return 0 + if (*Vdbe)(unsafe.Pointer(p)).Fmagic != VDBE_MAGIC_RUN { + return SQLITE_OK } if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - (*Vdbe)(unsafe.Pointer(p)).Frc = 7 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } closeAllCursors(tls, p) @@ -57395,8 +56830,8 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * // Check for one of the special errors mrc = ((*Vdbe)(unsafe.Pointer(p)).Frc & 0xff) - isSpecialError = (libc.Bool32((((mrc == 7) || (mrc == 10)) || - (mrc == 9)) || (mrc == 13))) + isSpecialError = (libc.Bool32((((mrc == SQLITE_NOMEM) || (mrc == SQLITE_IOERR)) || + (mrc == SQLITE_INTERRUPT)) || (mrc == SQLITE_FULL))) if isSpecialError != 0 { // If the query was read-only and the error code is SQLITE_INTERRUPT, // no rollback is necessary. Otherwise, at least a savepoint @@ -57409,13 +56844,13 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * // file as part of an effort to free up cache space (see function // pagerStress() in pager.c), the rollback is required to restore // the pager to a consistent state. - if !((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.readOnly */)) & 0x80 >> 7)) != 0) || (mrc != 9) { - if ((mrc == 7) || (mrc == 13)) && ((Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.usesStmtJournal */)) & 0x40 >> 6))) != 0) { - eStatementOp = 2 + if !((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.readOnly */)) & 0x80 >> 7)) != 0) || (mrc != SQLITE_INTERRUPT) { + if ((mrc == SQLITE_NOMEM) || (mrc == SQLITE_FULL)) && ((Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.usesStmtJournal */)) & 0x40 >> 6))) != 0) { + eStatementOp = SAVEPOINT_ROLLBACK } else { // We are forced to roll back the active transaction. Before doing // so, abort any other statements this handle currently has active. - Xsqlite3RollbackAll(tls, db, (4 | (int32(2) << 8))) + Xsqlite3RollbackAll(tls, db, (SQLITE_ABORT | (int32(2) << 8))) Xsqlite3CloseSavepoints(tls, db) (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1) (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 @@ -57424,7 +56859,7 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * } // Check for immediate foreign key violations. - if ((*Vdbe)(unsafe.Pointer(p)).Frc == 0) || ((int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == 3) && !(isSpecialError != 0)) { + if ((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK) || ((int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == OE_Fail) && !(isSpecialError != 0)) { Xsqlite3VdbeCheckFk(tls, p, 0) } @@ -57436,14 +56871,14 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * if (!(((*Sqlite3)(unsafe.Pointer((db))).FnVTrans > 0) && ((*Sqlite3)(unsafe.Pointer((db))).FaVTrans == uintptr(0))) && ((*Sqlite3)(unsafe.Pointer(db)).FautoCommit != 0)) && ((*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite == (libc.Bool32((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.readOnly */)) & 0x80 >> 7)) == 0))) { - if ((*Vdbe)(unsafe.Pointer(p)).Frc == 0) || ((int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == 3) && !(isSpecialError != 0)) { + if ((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK) || ((int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == OE_Fail) && !(isSpecialError != 0)) { rc = Xsqlite3VdbeCheckFk(tls, p, 1) - if rc != 0 { + if rc != SQLITE_OK { if (Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.readOnly */)) & 0x80 >> 7))) != 0 { Xsqlite3VdbeLeave(tls, p) - return 1 + return SQLITE_ERROR } - rc = (19 | (int32(3) << 8)) + rc = (SQLITE_CONSTRAINT | (int32(3) << 8)) } else { // The auto-commit flag is true, the vdbe program was successful // or hit an 'OR FAIL' constraint and there are no deferred foreign @@ -57451,31 +56886,31 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * // is required. rc = vdbeCommit(tls, db, p) } - if (rc == 5) && ((Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.readOnly */)) & 0x80 >> 7))) != 0) { + if (rc == SQLITE_BUSY) && ((Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.readOnly */)) & 0x80 >> 7))) != 0) { Xsqlite3VdbeLeave(tls, p) - return 5 - } else if rc != 0 { + return SQLITE_BUSY + } else if rc != SQLITE_OK { (*Vdbe)(unsafe.Pointer(p)).Frc = rc - Xsqlite3RollbackAll(tls, db, 0) + Xsqlite3RollbackAll(tls, db, SQLITE_OK) (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 } else { (*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons = int64(0) (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = int64(0) - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x00080000))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_DeferFKs)) Xsqlite3CommitInternalChanges(tls, db) } } else { - Xsqlite3RollbackAll(tls, db, 0) + Xsqlite3RollbackAll(tls, db, SQLITE_OK) (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 } (*Sqlite3)(unsafe.Pointer(db)).FnStatement = 0 } else if eStatementOp == 0 { - if ((*Vdbe)(unsafe.Pointer(p)).Frc == 0) || (int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == 3) { - eStatementOp = 1 - } else if int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == 2 { - eStatementOp = 2 + if ((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK) || (int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == OE_Fail) { + eStatementOp = SAVEPOINT_RELEASE + } else if int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == OE_Abort { + eStatementOp = SAVEPOINT_ROLLBACK } else { - Xsqlite3RollbackAll(tls, db, (4 | (int32(2) << 8))) + Xsqlite3RollbackAll(tls, db, (SQLITE_ABORT | (int32(2) << 8))) Xsqlite3CloseSavepoints(tls, db) (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1) (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 @@ -57490,12 +56925,12 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * if eStatementOp != 0 { rc = Xsqlite3VdbeCloseStatement(tls, p, eStatementOp) if rc != 0 { - if ((*Vdbe)(unsafe.Pointer(p)).Frc == 0) || (((*Vdbe)(unsafe.Pointer(p)).Frc & 0xff) == 19) { + if ((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK) || (((*Vdbe)(unsafe.Pointer(p)).Frc & 0xff) == SQLITE_CONSTRAINT) { (*Vdbe)(unsafe.Pointer(p)).Frc = rc Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg) (*Vdbe)(unsafe.Pointer(p)).FzErrMsg = uintptr(0) } - Xsqlite3RollbackAll(tls, db, (4 | (int32(2) << 8))) + Xsqlite3RollbackAll(tls, db, (SQLITE_ABORT | (int32(2) << 8))) Xsqlite3CloseSavepoints(tls, db) (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1) (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 @@ -57505,7 +56940,7 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * // If this was an INSERT, UPDATE or DELETE and no statement transaction // has been rolled back, update the database connection change-counter. if (Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.changeCntOn */)) & 0x10 >> 4))) != 0 { - if eStatementOp != 2 { + if eStatementOp != SAVEPOINT_ROLLBACK { Xsqlite3VdbeSetChanges(tls, db, (*Vdbe)(unsafe.Pointer(p)).FnChange) } else { Xsqlite3VdbeSetChanges(tls, db, 0) @@ -57528,10 +56963,10 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * } } - (*Vdbe)(unsafe.Pointer(p)).Fmagic = U32(0x319c2973) + (*Vdbe)(unsafe.Pointer(p)).Fmagic = VDBE_MAGIC_HALT if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - (*Vdbe)(unsafe.Pointer(p)).Frc = 7 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } // If the auto-commit flag is set to true, then any locks that were held @@ -57542,17 +56977,17 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * } return func() int32 { - if (*Vdbe)(unsafe.Pointer(p)).Frc == 5 { - return 5 + if (*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_BUSY { + return SQLITE_BUSY } - return 0 + return SQLITE_OK }() } // Each VDBE holds the result of the most recent sqlite3_step() call // in p->rc. This routine sets that result back to SQLITE_OK. func Xsqlite3VdbeResetStepResult(tls *libc.TLS, p uintptr) { /* sqlite3.c:80962:21: */ - (*Vdbe)(unsafe.Pointer(p)).Frc = 0 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK } // Copy the error code and error message belonging to the VDBE passed @@ -57570,7 +57005,7 @@ func Xsqlite3VdbeTransferError(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80 if (*Sqlite3)(unsafe.Pointer(db)).FpErr == uintptr(0) { (*Sqlite3)(unsafe.Pointer(db)).FpErr = Xsqlite3ValueNew(tls, db) } - Xsqlite3ValueSetStr(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr, -1, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg, uint8(1), libc.UintptrFromInt32(-1)) + Xsqlite3ValueSetStr(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr, -1, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg, SQLITE_UTF8, libc.UintptrFromInt32(-1)) Xsqlite3EndBenignMalloc(tls) (*Sqlite3)(unsafe.Pointer(db)).FbBenignMalloc-- } else if (*Sqlite3)(unsafe.Pointer(db)).FpErr != 0 { @@ -57635,15 +57070,15 @@ func Xsqlite3VdbeReset(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:81023:20: (*Vdbe)(unsafe.Pointer(p)).FpResultSet = uintptr(0) // Save profiling information from this VDBE run. - (*Vdbe)(unsafe.Pointer(p)).Fmagic = U32(0x48fa9f76) + (*Vdbe)(unsafe.Pointer(p)).Fmagic = VDBE_MAGIC_RESET return ((*Vdbe)(unsafe.Pointer(p)).Frc & (*Sqlite3)(unsafe.Pointer(db)).FerrMask) } // Clean up and delete a VDBE after execution. Return an integer which is // the result code. Write any error message text into *pzErrMsg. func Xsqlite3VdbeFinalize(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:81120:20: */ - var rc int32 = 0 - if ((*Vdbe)(unsafe.Pointer(p)).Fmagic == U32(0x2df20da3)) || ((*Vdbe)(unsafe.Pointer(p)).Fmagic == U32(0x319c2973)) { + var rc int32 = SQLITE_OK + if ((*Vdbe)(unsafe.Pointer(p)).Fmagic == VDBE_MAGIC_RUN) || ((*Vdbe)(unsafe.Pointer(p)).Fmagic == VDBE_MAGIC_HALT) { rc = Xsqlite3VdbeReset(tls, p) } @@ -57694,13 +57129,13 @@ func Xsqlite3VdbeClearObject(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3. var pSub uintptr var pNext uintptr - releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, (int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn) * 5)) + releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, (int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn) * COLNAME_N)) for pSub = (*Vdbe)(unsafe.Pointer(p)).FpProgram; pSub != 0; pSub = pNext { pNext = (*SubProgram)(unsafe.Pointer(pSub)).FpNext vdbeFreeOpArray(tls, db, (*SubProgram)(unsafe.Pointer(pSub)).FaOp, (*SubProgram)(unsafe.Pointer(pSub)).FnOp) Xsqlite3DbFree(tls, db, pSub) } - if (*Vdbe)(unsafe.Pointer(p)).Fmagic != U32(0x16bceaa5) { + if (*Vdbe)(unsafe.Pointer(p)).Fmagic != VDBE_MAGIC_INIT { releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar, int32((*Vdbe)(unsafe.Pointer(p)).FnVar)) Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FpVList) Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FpFree) @@ -57726,7 +57161,7 @@ func Xsqlite3VdbeDelete(tls *libc.TLS, p uintptr) { /* sqlite3.c:81215:21: */ if (*Vdbe)(unsafe.Pointer(p)).FpNext != 0 { (*Vdbe)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FpNext)).FpPrev = (*Vdbe)(unsafe.Pointer(p)).FpPrev } - (*Vdbe)(unsafe.Pointer(p)).Fmagic = U32(0x5606c3c8) + (*Vdbe)(unsafe.Pointer(p)).Fmagic = VDBE_MAGIC_DEAD (*Vdbe)(unsafe.Pointer(p)).Fdb = uintptr(0) Xsqlite3DbFreeNN(tls, db, p) } @@ -57750,8 +57185,8 @@ func Xsqlite3VdbeFinishMoveto(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:812 return Xsqlite3CorruptError(tls, 81251) } (*VdbeCursor)(unsafe.Pointer(p)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(p)).FcacheStatus = U32(0) - return 0 + (*VdbeCursor)(unsafe.Pointer(p)).FcacheStatus = CACHE_STALE + return SQLITE_OK } // Something has moved cursor "p" out of place. Maybe the row it was @@ -57768,7 +57203,7 @@ func handleMovedCursor(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:81267:28: var rc int32 rc = Xsqlite3BtreeCursorRestore(tls, *(*uintptr)(unsafe.Pointer(p + 56 /* &.uc */)), bp /* &isDifferentRow */) - (*VdbeCursor)(unsafe.Pointer(p)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(p)).FcacheStatus = CACHE_STALE if *(*int32)(unsafe.Pointer(bp /* isDifferentRow */)) != 0 { (*VdbeCursor)(unsafe.Pointer(p)).FnullRow = U8(1) } @@ -57782,7 +57217,7 @@ func Xsqlite3VdbeCursorRestore(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:81 if Xsqlite3BtreeCursorHasMoved(tls, *(*uintptr)(unsafe.Pointer(p + 56 /* &.uc */))) != 0 { return handleMovedCursor(tls, p) } - return 0 + return SQLITE_OK } // Make sure the cursor p is ready to read or write the row to which it @@ -57804,14 +57239,14 @@ func Xsqlite3VdbeCursorMoveto(tls *libc.TLS, pp uintptr, piCol uintptr) int32 { if (((*VdbeCursor)(unsafe.Pointer(p)).FaAltMap != 0) && ((libc.AssignUint32(&iMap, *(*U32)(unsafe.Pointer((*VdbeCursor)(unsafe.Pointer(p)).FaAltMap + uintptr((U32(1)+*(*U32)(unsafe.Pointer(piCol))))*4)))) > U32(0))) && !(int32((*VdbeCursor)(unsafe.Pointer(p)).FnullRow) != 0) { *(*uintptr)(unsafe.Pointer(pp)) = (*VdbeCursor)(unsafe.Pointer(p)).FpAltCursor *(*U32)(unsafe.Pointer(piCol)) = (iMap - U32(1)) - return 0 + return SQLITE_OK } return Xsqlite3VdbeFinishMoveto(tls, p) } if Xsqlite3BtreeCursorHasMoved(tls, *(*uintptr)(unsafe.Pointer(p + 56 /* &.uc */))) != 0 { return handleMovedCursor(tls, p) } - return 0 + return SQLITE_OK } // The following functions: @@ -57987,14 +57422,14 @@ func serialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uintptr) U32 { bp := tls.Alloc(8) defer tls.Free(8) - *(*U64)(unsafe.Pointer(bp /* x */)) = (U64((((U32(*(*uint8)(unsafe.Pointer((buf) + uintptr(0)))) << 24) | (U32(int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(1)))) << 16))) | (U32(int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(2)))) << 8))) | U32(*(*uint8)(unsafe.Pointer((buf) + uintptr(3)))))) - var y U32 = ((((U32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + uintptr(0)))) << 24) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + uintptr(1)))) << 16))) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + uintptr(2)))) << 8))) | U32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + uintptr(3))))) + *(*U64)(unsafe.Pointer(bp /* x */)) = (U64((((U32(*(*uint8)(unsafe.Pointer((buf)))) << 24) | (U32(int32(*(*uint8)(unsafe.Pointer((buf) + 1))) << 16))) | (U32(int32(*(*uint8)(unsafe.Pointer((buf) + 2))) << 8))) | U32(*(*uint8)(unsafe.Pointer((buf) + 3))))) + var y U32 = ((((U32(*(*uint8)(unsafe.Pointer((buf + uintptr(4))))) << 24) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + 1))) << 16))) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + 2))) << 8))) | U32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + 3)))) *(*U64)(unsafe.Pointer(bp /* x */)) = ((*(*U64)(unsafe.Pointer(bp /* x */)) << 32) + U64(y)) if serial_type == U32(6) { // EVIDENCE-OF: R-29851-52272 Value is a big-endian 64-bit // twos-complement integer. *(*I64)(unsafe.Pointer(pMem /* &.u */)) = *(*I64)(unsafe.Pointer(bp /* &x */)) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int } else { // EVIDENCE-OF: R-57343-49114 Value is a big-endian IEEE 754-2008 64-bit @@ -58003,9 +57438,9 @@ func serialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uintptr) U32 { libc.Xmemcpy(tls, (pMem /* &.u */ /* &.r */), bp /* &x */, uint64(unsafe.Sizeof(U64(0)))) (*Mem)(unsafe.Pointer(pMem)).Fflags = func() uint16 { if (((*(*U64)(unsafe.Pointer(bp /* x */))) & (U64((uint64(0x7ff))) << 52)) == (U64((uint64(0x7ff))) << 52)) && (((*(*U64)(unsafe.Pointer(bp /* x */))) & ((U64((uint64(1))) << 52) - uint64(1))) != uint64(0)) { - return uint16(0x0001) + return MEM_Null } - return uint16(0x0008) + return MEM_Real }() } return U32(8) @@ -58016,7 +57451,7 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin case U32(10): { // Internal use only: NULL with virtual table // UPDATE no-change flag set - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(0x0001 | 0x4000)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(MEM_Null | MEM_Zero)) (*Mem)(unsafe.Pointer(pMem)).Fn = 0 *(*int32)(unsafe.Pointer(pMem /* &.u */)) = 0 break @@ -58027,7 +57462,7 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin case U32(0): { // Null // EVIDENCE-OF: R-24078-09375 Value is a NULL. - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Null break } @@ -58035,8 +57470,8 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin { // EVIDENCE-OF: R-44885-25196 Value is an 8-bit twos-complement // integer. - *(*I64)(unsafe.Pointer(pMem /* &.u */)) = I64(I8(*(*uint8)(unsafe.Pointer((buf) + uintptr(0))))) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + *(*I64)(unsafe.Pointer(pMem /* &.u */)) = I64(I8(*(*uint8)(unsafe.Pointer((buf))))) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int return U32(1) @@ -58045,8 +57480,8 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin { // 2-byte signed integer // EVIDENCE-OF: R-49794-35026 Value is a big-endian 16-bit // twos-complement integer. - *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64((256 * int32((I8(*(*uint8)(unsafe.Pointer((buf) + uintptr(0))))))) | int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(1)))))) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64((256 * int32((I8(*(*uint8)(unsafe.Pointer((buf))))))) | int32(*(*uint8)(unsafe.Pointer((buf) + 1))))) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int return U32(2) @@ -58055,8 +57490,8 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin { // 3-byte signed integer // EVIDENCE-OF: R-37839-54301 Value is a big-endian 24-bit // twos-complement integer. - *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64(((65536 * int32((I8(*(*uint8)(unsafe.Pointer((buf) + uintptr(0))))))) | (int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(1)))) << 8)) | int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(2)))))) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64(((65536 * int32((I8(*(*uint8)(unsafe.Pointer((buf))))))) | (int32(*(*uint8)(unsafe.Pointer((buf) + 1))) << 8)) | int32(*(*uint8)(unsafe.Pointer((buf) + 2))))) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int return U32(3) @@ -58065,8 +57500,8 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin { // 4-byte signed integer // EVIDENCE-OF: R-01849-26079 Value is a big-endian 32-bit // twos-complement integer. - *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64((((16777216 * int32((I8(*(*uint8)(unsafe.Pointer((buf) + uintptr(0))))))) | (int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(1)))) << 16)) | (int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(2)))) << 8)) | int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(3)))))) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64((((16777216 * int32((I8(*(*uint8)(unsafe.Pointer((buf))))))) | (int32(*(*uint8)(unsafe.Pointer((buf) + 1))) << 16)) | (int32(*(*uint8)(unsafe.Pointer((buf) + 2))) << 8)) | int32(*(*uint8)(unsafe.Pointer((buf) + 3))))) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int return U32(4) @@ -58075,8 +57510,8 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin { // 6-byte signed integer // EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit // twos-complement integer. - *(*I64)(unsafe.Pointer(pMem /* &.u */)) = ((I64((((U32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + uintptr(0)))) << 24) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + uintptr(1)))) << 16))) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + uintptr(2)))) << 8))) | U32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + uintptr(3)))))) + ((I64((int64(1))) << 32) * (I64((256 * int32((I8(*(*uint8)(unsafe.Pointer((buf) + uintptr(0))))))) | int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(1)))))))) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + *(*I64)(unsafe.Pointer(pMem /* &.u */)) = ((I64((((U32(*(*uint8)(unsafe.Pointer((buf + uintptr(2))))) << 24) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + 1))) << 16))) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + 2))) << 8))) | U32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + 3))))) + ((I64((int64(1))) << 32) * (I64((256 * int32((I8(*(*uint8)(unsafe.Pointer((buf))))))) | int32(*(*uint8)(unsafe.Pointer((buf) + 1))))))) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int return U32(6) @@ -58097,7 +57532,7 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin // EVIDENCE-OF: R-12976-22893 Value is the integer 0. // EVIDENCE-OF: R-18143-12121 Value is the integer 1. *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64(serial_type - U32(8))) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int return U32(0) } @@ -58113,7 +57548,7 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin return U32(0) } -var aFlag = [2]U16{(U16(0x0010 | 0x1000)), (U16(0x0002 | 0x1000))} /* sqlite3.c:81711:24 */ +var aFlag = [2]U16{(U16(MEM_Blob | MEM_Ephem)), (U16(MEM_Str | MEM_Ephem))} /* sqlite3.c:81711:24 */ // This routine is used to allocate sufficient space for an UnpackedRecord // structure large enough to be used with sqlite3VdbeRecordUnpack() if @@ -58130,12 +57565,12 @@ var aFlag = [2]U16{(U16(0x0010 | 0x1000)), (U16(0x0002 | 0x1000))} /* sqlite3.c: func Xsqlite3VdbeAllocUnpackedRecord(tls *libc.TLS, pKeyInfo uintptr) uintptr { /* sqlite3.c:81734:31: */ var p uintptr // Unpacked record to return var nByte int32 // Number of bytes required for *p - nByte = (int32((((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)) + (uint64(unsafe.Sizeof(Mem{})) * (uint64(int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField) + 1))))) + nByte = (int32((((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))) + (uint64(unsafe.Sizeof(Mem{})) * (uint64(int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField) + 1))))) p = Xsqlite3DbMallocRaw(tls, (*KeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb, uint64(nByte)) if !(p != 0) { return uintptr(0) } - (*UnpackedRecord)(unsafe.Pointer(p)).FaMem = ((p) + uintptr((((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + (*UnpackedRecord)(unsafe.Pointer(p)).FaMem = ((p) + 24) (*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo = pKeyInfo (*UnpackedRecord)(unsafe.Pointer(p)).FnField = (U16(int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField) + 1)) @@ -58224,15 +57659,15 @@ func vdbeCompareMemString(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uin // var c2 Mem at bp+56, 56 - Xsqlite3VdbeMemInit(tls, bp /* &c1 */, (*Mem)(unsafe.Pointer(pMem1)).Fdb, uint16(0x0001)) - Xsqlite3VdbeMemInit(tls, bp+56 /* &c2 */, (*Mem)(unsafe.Pointer(pMem1)).Fdb, uint16(0x0001)) - Xsqlite3VdbeMemShallowCopy(tls, bp /* &c1 */, pMem1, 0x1000) - Xsqlite3VdbeMemShallowCopy(tls, bp+56 /* &c2 */, pMem2, 0x1000) + Xsqlite3VdbeMemInit(tls, bp /* &c1 */, (*Mem)(unsafe.Pointer(pMem1)).Fdb, MEM_Null) + Xsqlite3VdbeMemInit(tls, bp+56 /* &c2 */, (*Mem)(unsafe.Pointer(pMem1)).Fdb, MEM_Null) + Xsqlite3VdbeMemShallowCopy(tls, bp /* &c1 */, pMem1, MEM_Ephem) + Xsqlite3VdbeMemShallowCopy(tls, bp+56 /* &c2 */, pMem2, MEM_Ephem) v1 = Xsqlite3ValueText(tls, bp /* &c1 */, (*CollSeq)(unsafe.Pointer(pColl)).Fenc) v2 = Xsqlite3ValueText(tls, bp+56 /* &c2 */, (*CollSeq)(unsafe.Pointer(pColl)).Fenc) if (v1 == uintptr(0)) || (v2 == uintptr(0)) { if prcErr != 0 { - *(*U8)(unsafe.Pointer(prcErr)) = U8(7) + *(*U8)(unsafe.Pointer(prcErr)) = SQLITE_NOMEM } rc = 0 } else { @@ -58270,10 +57705,10 @@ func Xsqlite3BlobCompare(tls *libc.TLS, pB1 uintptr, pB2 uintptr) int32 { /* sql // by the OP_MakeRecord opcode, and such Blobs never get passed into // sqlite3MemCompare(). - if ((int32((*Mem)(unsafe.Pointer(pB1)).Fflags) | int32((*Mem)(unsafe.Pointer(pB2)).Fflags)) & 0x4000) != 0 { - if ((int32((*Mem)(unsafe.Pointer(pB1)).Fflags) & int32((*Mem)(unsafe.Pointer(pB2)).Fflags)) & 0x4000) != 0 { + if ((int32((*Mem)(unsafe.Pointer(pB1)).Fflags) | int32((*Mem)(unsafe.Pointer(pB2)).Fflags)) & MEM_Zero) != 0 { + if ((int32((*Mem)(unsafe.Pointer(pB1)).Fflags) & int32((*Mem)(unsafe.Pointer(pB2)).Fflags)) & MEM_Zero) != 0 { return (*(*int32)(unsafe.Pointer(pB1 /* &.u */)) - *(*int32)(unsafe.Pointer(pB2 /* &.u */))) - } else if (int32((*Mem)(unsafe.Pointer(pB1)).Fflags) & 0x4000) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pB1)).Fflags) & MEM_Zero) != 0 { if !(isAllZero(tls, (*Mem)(unsafe.Pointer(pB2)).Fz, (*Mem)(unsafe.Pointer(pB2)).Fn) != 0) { return -1 } @@ -58356,14 +57791,14 @@ func Xsqlite3MemCompare(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintp // If one value is NULL, it is less than the other. If both values // are NULL, return 0. - if (combined_flags & 0x0001) != 0 { - return ((f2 & 0x0001) - (f1 & 0x0001)) + if (combined_flags & MEM_Null) != 0 { + return ((f2 & MEM_Null) - (f1 & MEM_Null)) } // At least one of the two values is a number - if (combined_flags & ((0x0004 | 0x0008) | 0x0020)) != 0 { + if (combined_flags & ((MEM_Int | MEM_Real) | MEM_IntReal)) != 0 { - if ((f1 & f2) & (0x0004 | 0x0020)) != 0 { + if ((f1 & f2) & (MEM_Int | MEM_IntReal)) != 0 { if *(*I64)(unsafe.Pointer(pMem1 /* &.u */)) < *(*I64)(unsafe.Pointer(pMem2 /* &.u */)) { return -1 @@ -58373,7 +57808,7 @@ func Xsqlite3MemCompare(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintp } return 0 } - if ((f1 & f2) & 0x0008) != 0 { + if ((f1 & f2) & MEM_Real) != 0 { if *(*float64)(unsafe.Pointer(pMem1 /* &.u */)) < *(*float64)(unsafe.Pointer(pMem2 /* &.u */)) { return -1 } @@ -58382,11 +57817,11 @@ func Xsqlite3MemCompare(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintp } return 0 } - if (f1 & (0x0004 | 0x0020)) != 0 { + if (f1 & (MEM_Int | MEM_IntReal)) != 0 { - if (f2 & 0x0008) != 0 { + if (f2 & MEM_Real) != 0 { return sqlite3IntFloatCompare(tls, *(*I64)(unsafe.Pointer(pMem1 /* &.u */)), *(*float64)(unsafe.Pointer(pMem2 /* &.u */))) - } else if (f2 & (0x0004 | 0x0020)) != 0 { + } else if (f2 & (MEM_Int | MEM_IntReal)) != 0 { if *(*I64)(unsafe.Pointer(pMem1 /* &.u */)) < *(*I64)(unsafe.Pointer(pMem2 /* &.u */)) { return -1 } @@ -58398,8 +57833,8 @@ func Xsqlite3MemCompare(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintp return -1 } } - if (f1 & 0x0008) != 0 { - if (f2 & (0x0004 | 0x0020)) != 0 { + if (f1 & MEM_Real) != 0 { + if (f2 & (MEM_Int | MEM_IntReal)) != 0 { return -sqlite3IntFloatCompare(tls, *(*I64)(unsafe.Pointer(pMem2 /* &.u */)), *(*float64)(unsafe.Pointer(pMem1 /* &.u */))) } else { @@ -58411,11 +57846,11 @@ func Xsqlite3MemCompare(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintp // If one value is a string and the other is a blob, the string is less. // If both are strings, compare using the collating functions. - if (combined_flags & 0x0002) != 0 { - if (f1 & 0x0002) == 0 { + if (combined_flags & MEM_Str) != 0 { + if (f1 & MEM_Str) == 0 { return 1 } - if (f2 & 0x0002) == 0 { + if (f2 & MEM_Str) == 0 { return -1 } @@ -58450,31 +57885,31 @@ func vdbeRecordDecodeInt(tls *libc.TLS, serial_type U32, aKey uintptr) I64 { /* fallthrough case U32(1): - return I64(I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))) + return I64(I8(*(*U8)(unsafe.Pointer((aKey))))) case U32(2): - return (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))))) + return (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + 1))))) case U32(3): - return (I64(((65536 * int32((I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))))) | (int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))) << 8)) | int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(2)))))) + return (I64(((65536 * int32((I8(*(*U8)(unsafe.Pointer((aKey))))))) | (int32(*(*U8)(unsafe.Pointer((aKey) + 1))) << 8)) | int32(*(*U8)(unsafe.Pointer((aKey) + 2))))) case U32(4): { - *(*U32)(unsafe.Pointer(bp /* y */)) = ((((U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(3))))) + *(*U32)(unsafe.Pointer(bp /* y */)) = ((((U32(*(*U8)(unsafe.Pointer((aKey)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + 3)))) return I64(*(*int32)(unsafe.Pointer(bp /* &y */))) } case U32(5): { - return ((I64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(3)))))) + ((I64((int64(1))) << 32) * (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))))))) + return ((I64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2))))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + 3))))) + ((I64((int64(1))) << 32) * (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + 1))))))) } case U32(6): { - *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = (U64((((U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(3)))))) + *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = (U64((((U32(*(*U8)(unsafe.Pointer((aKey)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + 3))))) - *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = ((*(*U64)(unsafe.Pointer(bp + 8 /* x */)) << 32) | (U64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(3))))))) + *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = ((*(*U64)(unsafe.Pointer(bp + 8 /* x */)) << 32) | (U64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4))))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + 3)))))) return *(*I64)(unsafe.Pointer(bp + 8 /* &x */)) } @@ -58524,15 +57959,15 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr // var s1 U32 at bp, 4 idx1 = (U32(1 + int32((func() uint8 { - if int32(*(*uint8)(unsafe.Pointer((aKey1 + uintptr(1))))) < int32(U8(0x80)) { + if int32(*(*uint8)(unsafe.Pointer((aKey1 + 1)))) < int32(U8(0x80)) { return uint8(func() int32 { - (*(*U32)(unsafe.Pointer(bp /* s1 */))) = U32(*(*uint8)(unsafe.Pointer((aKey1 + uintptr(1))))) + (*(*U32)(unsafe.Pointer(bp /* s1 */))) = U32(*(*uint8)(unsafe.Pointer((aKey1 + 1)))) return 1 }()) } - return Xsqlite3GetVarint32(tls, (aKey1 + uintptr(1)), bp /* &s1 */) + return Xsqlite3GetVarint32(tls, (aKey1 + 1), bp /* &s1 */) }())))) - *(*U32)(unsafe.Pointer(bp + 4 /* szHdr1 */)) = U32(*(*uint8)(unsafe.Pointer(aKey1 + uintptr(0)))) + *(*U32)(unsafe.Pointer(bp + 4 /* szHdr1 */)) = U32(*(*uint8)(unsafe.Pointer(aKey1))) d1 = (*(*U32)(unsafe.Pointer(bp + 4 /* szHdr1 */)) + Xsqlite3VdbeSerialTypeLen(tls, *(*U32)(unsafe.Pointer(bp /* s1 */)))) i = 1 pRhs += 56 @@ -58558,7 +57993,7 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr // var serial_type U32 at bp+64, 4 // RHS is an integer - if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & (0x0004 | 0x0020)) != 0 { + if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & (MEM_Int | MEM_IntReal)) != 0 { *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) = U32(*(*uint8)(unsafe.Pointer(aKey1 + uintptr(idx1)))) @@ -58578,7 +58013,7 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr rc = +1 } } - } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & 0x0008) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & MEM_Real) != 0 { *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) = U32(*(*uint8)(unsafe.Pointer(aKey1 + uintptr(idx1)))) if *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) >= U32(10) { // Serial types 12 or greater are strings and blobs (greater than @@ -58600,7 +58035,7 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr rc = sqlite3IntFloatCompare(tls, *(*I64)(unsafe.Pointer(bp + 8 /* &mem1 */ /* &.u */)), *(*float64)(unsafe.Pointer(pRhs /* &.u */))) } } - } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & 0x0002) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & MEM_Str) != 0 { *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) = U32(*(*uint8)(unsafe.Pointer((aKey1 + uintptr(idx1))))) if *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) >= U32(0x80) { Xsqlite3GetVarint32(tls, (aKey1 + uintptr(idx1)), bp+64 /* &serial_type */) @@ -58620,7 +58055,7 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr } else if *(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */) + uintptr(i)*8)) != 0 { (*Mem)(unsafe.Pointer(bp + 8 /* &mem1 */)).Fenc = (*KeyInfo)(unsafe.Pointer(pKeyInfo)).Fenc (*Mem)(unsafe.Pointer(bp + 8 /* &mem1 */)).Fdb = (*KeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb - (*Mem)(unsafe.Pointer(bp + 8 /* &mem1 */)).Fflags = U16(0x0002) + (*Mem)(unsafe.Pointer(bp + 8 /* &mem1 */)).Fflags = MEM_Str (*Mem)(unsafe.Pointer(bp + 8 /* &mem1 */)).Fz = (aKey1 + uintptr(d1)) rc = vdbeCompareMemString(tls, bp+8 /* &mem1 */, pRhs, *(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */) + uintptr(i)*8)), (pPKey2 + 19 /* &.errCode */)) @@ -58637,7 +58072,7 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr } } } - } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & 0x0010) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & MEM_Blob) != 0 { *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) = U32(*(*uint8)(unsafe.Pointer((aKey1 + uintptr(idx1))))) if *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) >= U32(0x80) { @@ -58652,7 +58087,7 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr if (d1 + U32(nStr)) > uint32(nKey1) { (*UnpackedRecord)(unsafe.Pointer(pPKey2)).FerrCode = U8(Xsqlite3CorruptError(tls, 82354)) return 0 // Corruption - } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & 0x4000) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & MEM_Zero) != 0 { if !(isAllZero(tls, (aKey1+uintptr(d1)), nStr) != 0) { rc = 1 } else { @@ -58679,9 +58114,9 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr if rc != 0 { var sortFlags int32 = int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FpKeyInfo)).FaSortFlags + uintptr(i)))) if sortFlags != 0 { - if ((sortFlags & 0x02) == 0) || - ((sortFlags & 0x01) != - (libc.Bool32((*(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) == U32(0)) || ((int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & 0x0001) != 0)))) { + if ((sortFlags & KEYINFO_ORDER_BIGNULL) == 0) || + ((sortFlags & KEYINFO_ORDER_DESC) != + (libc.Bool32((*(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) == U32(0)) || ((int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & MEM_Null) != 0)))) { rc = -rc } } @@ -58727,7 +58162,7 @@ func vdbeRecordCompareInt(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uint defer tls.Free(16) var aKey uintptr = ((pKey1) + uintptr((int32(*(*U8)(unsafe.Pointer(pKey1))) & 0x3F))) - var serial_type int32 = int32(*(*U8)(unsafe.Pointer((pKey1) + uintptr(1)))) + var serial_type int32 = int32(*(*U8)(unsafe.Pointer((pKey1) + 1))) var res int32 // var y U32 at bp, 4 @@ -58739,28 +58174,28 @@ func vdbeRecordCompareInt(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uint switch serial_type { case 1: { // 1-byte signed integer - lhs = I64(I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))) + lhs = I64(I8(*(*U8)(unsafe.Pointer((aKey))))) break } case 2: { // 2-byte signed integer - lhs = (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))))) + lhs = (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + 1))))) break } case 3: { // 3-byte signed integer - lhs = (I64(((65536 * int32((I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))))) | (int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))) << 8)) | int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(2)))))) + lhs = (I64(((65536 * int32((I8(*(*U8)(unsafe.Pointer((aKey))))))) | (int32(*(*U8)(unsafe.Pointer((aKey) + 1))) << 8)) | int32(*(*U8)(unsafe.Pointer((aKey) + 2))))) break } case 4: { // 4-byte signed integer - *(*U32)(unsafe.Pointer(bp /* y */)) = ((((U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(3))))) + *(*U32)(unsafe.Pointer(bp /* y */)) = ((((U32(*(*U8)(unsafe.Pointer((aKey)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + 3)))) lhs = I64(*(*int32)(unsafe.Pointer(bp /* &y */))) break @@ -58768,15 +58203,15 @@ func vdbeRecordCompareInt(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uint } case 5: { // 6-byte signed integer - lhs = ((I64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(3)))))) + ((I64((int64(1))) << 32) * (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))))))) + lhs = ((I64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2))))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + 3))))) + ((I64((int64(1))) << 32) * (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + 1))))))) break } case 6: { // 8-byte signed integer - *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = (U64((((U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(3)))))) - *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = ((*(*U64)(unsafe.Pointer(bp + 8 /* x */)) << 32) | (U64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(3))))))) + *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = (U64((((U32(*(*U8)(unsafe.Pointer((aKey)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + 3))))) + *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = ((*(*U64)(unsafe.Pointer(bp + 8 /* x */)) << 32) | (U64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4))))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + 3)))))) lhs = *(*I64)(unsafe.Pointer(bp + 8 /* &x */)) break @@ -58804,7 +58239,7 @@ func vdbeRecordCompareInt(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uint return Xsqlite3VdbeRecordCompare(tls, nKey1, pKey1, pPKey2) } - v = *(*I64)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem + uintptr(0)*56 /* &.u */)) + v = *(*I64)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem /* &.u */)) if v > lhs { res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1) } else if v < lhs { @@ -58836,9 +58271,9 @@ func vdbeRecordCompareString(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 u var res int32 - *(*int32)(unsafe.Pointer(bp /* serial_type */)) = int32(*(*U8)(unsafe.Pointer(aKey1 + uintptr(1)))) + *(*int32)(unsafe.Pointer(bp /* serial_type */)) = int32(*(*U8)(unsafe.Pointer(aKey1 + 1))) if *(*int32)(unsafe.Pointer(bp /* serial_type */)) >= 0x80 { - Xsqlite3GetVarint32(tls, (aKey1 + uintptr(1)), bp /* &serial_type */) + Xsqlite3GetVarint32(tls, (aKey1 + 1), bp /* &serial_type */) } if *(*int32)(unsafe.Pointer(bp /* serial_type */)) < 12 { res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1) // (pKey1/nKey1) is a number or a null @@ -58847,7 +58282,7 @@ func vdbeRecordCompareString(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 u } else { var nCmp int32 var nStr int32 - var szHdr int32 = int32(*(*U8)(unsafe.Pointer(aKey1 + uintptr(0)))) + var szHdr int32 = int32(*(*U8)(unsafe.Pointer(aKey1))) nStr = ((*(*int32)(unsafe.Pointer(bp /* serial_type */)) - 12) / 2) if (szHdr + nStr) > nKey1 { @@ -58855,19 +58290,19 @@ func vdbeRecordCompareString(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 u return 0 // Corruption } nCmp = func() int32 { - if ((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem + uintptr(0)*56)).Fn) < (nStr) { - return (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem + uintptr(0)*56)).Fn + if ((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem)).Fn) < (nStr) { + return (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem)).Fn } return nStr }() - res = libc.Xmemcmp(tls, (aKey1 + uintptr(szHdr)), (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem+uintptr(0)*56)).Fz, uint64(nCmp)) + res = libc.Xmemcmp(tls, (aKey1 + uintptr(szHdr)), (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem)).Fz, uint64(nCmp)) if res > 0 { res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr2) } else if res < 0 { res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1) } else { - res = (nStr - (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem+uintptr(0)*56)).Fn) + res = (nStr - (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem)).Fn) if res == 0 { if int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FnField) > 1 { res = Xsqlite3VdbeRecordCompareWithSkip(tls, nKey1, pKey1, pPKey2, 1) @@ -58904,9 +58339,9 @@ func Xsqlite3VdbeFindCompare(tls *libc.TLS, p uintptr) RecordCompare { /* sqlite // 13 fields or less. If the first field is an integer, the maximum legal // header size is (12*5 + 1 + 1) bytes. if int32((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FnAllField) <= 13 { - var flags int32 = int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FaMem + uintptr(0)*56)).Fflags) - if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FaSortFlags + uintptr(0))) != 0 { - if (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FaSortFlags + uintptr(0)))) & 0x02) != 0 { + var flags int32 = int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FaMem)).Fflags) + if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FaSortFlags)) != 0 { + if (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FaSortFlags))) & KEYINFO_ORDER_BIGNULL) != 0 { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, int32, uintptr, uintptr) int32 }{Xsqlite3VdbeRecordCompare})) @@ -58917,14 +58352,14 @@ func Xsqlite3VdbeFindCompare(tls *libc.TLS, p uintptr) RecordCompare { /* sqlite (*UnpackedRecord)(unsafe.Pointer(p)).Fr1 = int8(-1) (*UnpackedRecord)(unsafe.Pointer(p)).Fr2 = int8(1) } - if (flags & 0x0004) != 0 { + if (flags & MEM_Int) != 0 { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, int32, uintptr, uintptr) int32 }{vdbeRecordCompareInt})) } - if ((flags & (((0x0008 | 0x0020) | 0x0001) | 0x0010)) == 0) && - (*(*uintptr)(unsafe.Pointer(((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo + 32 /* &.aColl */) + uintptr(0)*8)) == uintptr(0)) { + if ((flags & (((MEM_Real | MEM_IntReal) | MEM_Null) | MEM_Blob)) == 0) && + (*(*uintptr)(unsafe.Pointer(((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo + 32 /* &.aColl */))) == uintptr(0)) { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, int32, uintptr, uintptr) int32 @@ -59021,7 +58456,7 @@ __6: Xsqlite3VdbeSerialGet(tls, ((*Mem)(unsafe.Pointer(bp /* &m */)).Fz + uintptr((U32((*Mem)(unsafe.Pointer(bp /* &m */)).Fn) - lenRowid))), *(*U32)(unsafe.Pointer(bp + 60 /* typeRowid */)), bp+64 /* &v */) *(*I64)(unsafe.Pointer(rowid)) = *(*I64)(unsafe.Pointer(bp + 64 /* &v */ /* &.u */)) Xsqlite3VdbeMemRelease(tls, bp /* &m */) - return 0 + return SQLITE_OK // Jump here if database corruption is detected after m has been // allocated. Free the m object and return SQLITE_CORRUPT. @@ -59065,7 +58500,7 @@ func Xsqlite3VdbeIdxKeyCompare(tls *libc.TLS, db uintptr, pC uintptr, pUnpacked } *(*int32)(unsafe.Pointer(res)) = Xsqlite3VdbeRecordCompareWithSkip(tls, (*Mem)(unsafe.Pointer(bp /* &m */)).Fn, (*Mem)(unsafe.Pointer(bp /* &m */)).Fz, pUnpacked, 0) Xsqlite3VdbeMemRelease(tls, bp /* &m */) - return 0 + return SQLITE_OK } // This routine sets the value to be returned by subsequent calls to @@ -59126,11 +58561,11 @@ func Xsqlite3VdbeGetBoundValue(tls *libc.TLS, v uintptr, iVar int32, aff U8) uin if v != 0 { var pMem uintptr = ((*Vdbe)(unsafe.Pointer(v)).FaVar + uintptr((iVar-1))*56) - if 0 == (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0001) { + if 0 == (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Null) { var pRet uintptr = Xsqlite3ValueNew(tls, (*Vdbe)(unsafe.Pointer(v)).Fdb) if pRet != 0 { Xsqlite3VdbeMemCopy(tls, pRet, pMem) - Xsqlite3ValueApplyAffinity(tls, pRet, aff, uint8(1)) + Xsqlite3ValueApplyAffinity(tls, pRet, aff, SQLITE_UTF8) } return pRet } @@ -59166,12 +58601,12 @@ func Xsqlite3NotPureFunc(tls *libc.TLS, pCtx uintptr) int32 { /* sqlite3.c:82855 return 1 } pOp = ((*Vdbe)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe)).FaOp + uintptr((*Sqlite3_context)(unsafe.Pointer(pCtx)).FiOp)*24) - if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 63 { + if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_PureFunc { var zContext uintptr var zMsg uintptr - if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5) & 0x00004) != 0 { + if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5) & NC_IsCheck) != 0 { zContext = ts + 4121 /* "a CHECK constrai..." */ - } else if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5) & 0x00008) != 0 { + } else if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5) & NC_GenCol) != 0 { zContext = ts + 4140 /* "a generated colu..." */ } else { zContext = ts + 4159 /* "an index" */ @@ -59232,11 +58667,11 @@ func Xsqlite3VdbePreUpdateHook(tls *libc.TLS, v uintptr, pCsr uintptr, op int32, var zTbl uintptr = (*Table)(unsafe.Pointer(pTab)).FzName libc.Xmemset(tls, bp /* &preupdate */, 0, uint64(unsafe.Sizeof(PreUpdate{}))) - if (libc.Bool32(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) == 0 { + if (libc.Bool32(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) == 0 { iKey1 = libc.AssignInt64(&iKey2, int64(0)) (*PreUpdate)(unsafe.Pointer(bp /* &preupdate */)).FpPk = Xsqlite3PrimaryKeyIndex(tls, pTab) } else { - if op == 23 { + if op == SQLITE_UPDATE { iKey2 = *(*I64)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + uintptr(iReg)*56 /* &.u */)) } else { iKey2 = iKey1 @@ -59306,7 +58741,7 @@ func Xsqlite3_expired(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83015:1 // invalid). Return false if it is ok. func vdbeSafety(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:83026:12: */ if (*Vdbe)(unsafe.Pointer(p)).Fdb == uintptr(0) { - Xsqlite3_log(tls, 21, ts+4204 /* "API called with ..." */, 0) + Xsqlite3_log(tls, SQLITE_MISUSE, ts+4204 /* "API called with ..." */, 0) return 1 } else { return 0 @@ -59316,7 +58751,7 @@ func vdbeSafety(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:83026:12: */ func vdbeSafetyNotNull(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:83034:12: */ if p == uintptr(0) { - Xsqlite3_log(tls, 21, ts+4249 /* "API called with ..." */, 0) + Xsqlite3_log(tls, SQLITE_MISUSE, ts+4249 /* "API called with ..." */, 0) return 1 } else { return vdbeSafety(tls, p) @@ -59339,8 +58774,8 @@ func invokeProfileCallback(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3.c: if (*Sqlite3)(unsafe.Pointer(db)).FxProfile != 0 { (*(*func(*libc.TLS, uintptr, uintptr, U64))(unsafe.Pointer((db + 248 /* &.xProfile */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpProfileArg, (*Vdbe)(unsafe.Pointer(p)).FzSql, uint64(*(*Sqlite3_int64)(unsafe.Pointer(bp + 8 /* iElapse */)))) } - if (int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & 0x02) != 0 { - (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, uint32(0x02), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, bp+8 /* &iElapse */) + if (int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & SQLITE_TRACE_PROFILE) != 0 { + (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, SQLITE_TRACE_PROFILE, (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, bp+8 /* &iElapse */) } (*Vdbe)(unsafe.Pointer(p)).FstartTime = int64(0) } @@ -59360,7 +58795,7 @@ func Xsqlite3_finalize(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83086: if pStmt == uintptr(0) { // IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL // pointer is a harmless no-op. - rc = 0 + rc = SQLITE_OK } else { var v uintptr = pStmt var db uintptr = (*Vdbe)(unsafe.Pointer(v)).Fdb @@ -59388,7 +58823,7 @@ func Xsqlite3_finalize(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83086: func Xsqlite3_reset(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83113:16: */ var rc int32 if pStmt == uintptr(0) { - rc = 0 + rc = SQLITE_OK } else { var v uintptr = pStmt var db uintptr = (*Vdbe)(unsafe.Pointer(v)).Fdb @@ -59409,13 +58844,13 @@ func Xsqlite3_reset(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83113:16: // Set all the parameters in the compiled SQL statement to NULL. func Xsqlite3_clear_bindings(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83134:16: */ var i int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr = pStmt var mutex uintptr = (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(pStmt)).Fdb)).Fmutex Xsqlite3_mutex_enter(tls, mutex) for i = 0; i < int32((*Vdbe)(unsafe.Pointer(p)).FnVar); i++ { Xsqlite3VdbeMemRelease(tls, ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr(i)*56)) - (*Mem)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr(i)*56)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr(i)*56)).Fflags = MEM_Null } if (*Vdbe)(unsafe.Pointer(p)).Fexpmask != 0 { @@ -59431,17 +58866,17 @@ func Xsqlite3_clear_bindings(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c: // structure. func Xsqlite3_value_blob(tls *libc.TLS, pVal uintptr) uintptr { /* sqlite3.c:83159:23: */ var p uintptr = pVal - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & (0x0010 | 0x0002)) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & (MEM_Blob | MEM_Str)) != 0 { if (func() int32 { - if (int32((*Mem)(unsafe.Pointer((p))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((p))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, p) } return 0 - }()) != 0 { + }()) != SQLITE_OK { return uintptr(0) } - *(*U16)(unsafe.Pointer(p + 8 /* &.flags */)) |= U16((0x0010)) + *(*U16)(unsafe.Pointer(p + 8 /* &.flags */)) |= U16((MEM_Blob)) if (*Mem)(unsafe.Pointer(p)).Fn != 0 { return (*Mem)(unsafe.Pointer(p)).Fz } @@ -59453,11 +58888,11 @@ func Xsqlite3_value_blob(tls *libc.TLS, pVal uintptr) uintptr { /* sqlite3.c:831 } func Xsqlite3_value_bytes(tls *libc.TLS, pVal uintptr) int32 { /* sqlite3.c:83172:16: */ - return Xsqlite3ValueBytes(tls, pVal, uint8(1)) + return Xsqlite3ValueBytes(tls, pVal, SQLITE_UTF8) } func Xsqlite3_value_bytes16(tls *libc.TLS, pVal uintptr) int32 { /* sqlite3.c:83175:16: */ - return Xsqlite3ValueBytes(tls, pVal, uint8(2)) + return Xsqlite3ValueBytes(tls, pVal, SQLITE_UTF16LE) } func Xsqlite3_value_double(tls *libc.TLS, pVal uintptr) float64 { /* sqlite3.c:83178:19: */ @@ -59475,7 +58910,7 @@ func Xsqlite3_value_int64(tls *libc.TLS, pVal uintptr) Sqlite_int64 { /* sqlite3 func Xsqlite3_value_subtype(tls *libc.TLS, pVal uintptr) uint32 { /* sqlite3.c:83187:25: */ var pMem uintptr = pVal return func() uint32 { - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x8000) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Subtype) != 0 { return uint32((*Mem)(unsafe.Pointer(pMem)).FeSubtype) } return uint32(0) @@ -59484,7 +58919,7 @@ func Xsqlite3_value_subtype(tls *libc.TLS, pVal uintptr) uint32 { /* sqlite3.c:8 func Xsqlite3_value_pointer(tls *libc.TLS, pVal uintptr, zPType uintptr) uintptr { /* sqlite3.c:83191:17: */ var p uintptr = pVal - if ((((int32((*Mem)(unsafe.Pointer(p)).Fflags) & ((0xc1bf | 0x0200) | 0x8000)) == ((0x0001 | 0x0200) | 0x8000)) && + if ((((int32((*Mem)(unsafe.Pointer(p)).Fflags) & ((MEM_TypeMask | MEM_Term) | MEM_Subtype)) == ((MEM_Null | MEM_Term) | MEM_Subtype)) && (zPType != uintptr(0))) && (int32((*Mem)(unsafe.Pointer(p)).FeSubtype) == 'p')) && (libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(p /* &.u */)), zPType) == 0) { @@ -59496,103 +58931,103 @@ func Xsqlite3_value_pointer(tls *libc.TLS, pVal uintptr, zPType uintptr) uintptr } func Xsqlite3_value_text(tls *libc.TLS, pVal uintptr) uintptr { /* sqlite3.c:83204:32: */ - return Xsqlite3ValueText(tls, pVal, uint8(1)) + return Xsqlite3ValueText(tls, pVal, SQLITE_UTF8) } func Xsqlite3_value_text16(tls *libc.TLS, pVal uintptr) uintptr { /* sqlite3.c:83208:23: */ - return Xsqlite3ValueText(tls, pVal, uint8(2)) + return Xsqlite3ValueText(tls, pVal, SQLITE_UTF16LE) } func Xsqlite3_value_text16be(tls *libc.TLS, pVal uintptr) uintptr { /* sqlite3.c:83211:23: */ - return Xsqlite3ValueText(tls, pVal, uint8(3)) + return Xsqlite3ValueText(tls, pVal, SQLITE_UTF16BE) } func Xsqlite3_value_text16le(tls *libc.TLS, pVal uintptr) uintptr { /* sqlite3.c:83214:23: */ - return Xsqlite3ValueText(tls, pVal, uint8(2)) + return Xsqlite3ValueText(tls, pVal, SQLITE_UTF16LE) } // EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five // fundamental datatypes: 64-bit signed integer 64-bit IEEE floating // point number string BLOB NULL func Xsqlite3_value_type(tls *libc.TLS, pVal uintptr) int32 { /* sqlite3.c:83222:16: */ - return int32(aType[(int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & 0x003f)]) + return int32(aType[(int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & MEM_AffMask)]) } var aType = [64]U8{ - U8(4), // 0x00 (not possible) - U8(5), // 0x01 NULL - U8(3), // 0x02 TEXT - U8(5), // 0x03 (not possible) - U8(1), // 0x04 INTEGER - U8(5), // 0x05 (not possible) - U8(1), // 0x06 INTEGER + TEXT - U8(5), // 0x07 (not possible) - U8(2), // 0x08 FLOAT - U8(5), // 0x09 (not possible) - U8(2), // 0x0a FLOAT + TEXT - U8(5), // 0x0b (not possible) - U8(1), // 0x0c (not possible) - U8(5), // 0x0d (not possible) - U8(1), // 0x0e (not possible) - U8(5), // 0x0f (not possible) - U8(4), // 0x10 BLOB - U8(5), // 0x11 (not possible) - U8(3), // 0x12 (not possible) - U8(5), // 0x13 (not possible) - U8(1), // 0x14 INTEGER + BLOB - U8(5), // 0x15 (not possible) - U8(1), // 0x16 (not possible) - U8(5), // 0x17 (not possible) - U8(2), // 0x18 FLOAT + BLOB - U8(5), // 0x19 (not possible) - U8(2), // 0x1a (not possible) - U8(5), // 0x1b (not possible) - U8(1), // 0x1c (not possible) - U8(5), // 0x1d (not possible) - U8(1), // 0x1e (not possible) - U8(5), // 0x1f (not possible) - U8(2), // 0x20 INTREAL - U8(5), // 0x21 (not possible) - U8(3), // 0x22 INTREAL + TEXT - U8(5), // 0x23 (not possible) - U8(2), // 0x24 (not possible) - U8(5), // 0x25 (not possible) - U8(2), // 0x26 (not possible) - U8(5), // 0x27 (not possible) - U8(2), // 0x28 (not possible) - U8(5), // 0x29 (not possible) - U8(2), // 0x2a (not possible) - U8(5), // 0x2b (not possible) - U8(2), // 0x2c (not possible) - U8(5), // 0x2d (not possible) - U8(2), // 0x2e (not possible) - U8(5), // 0x2f (not possible) - U8(4), // 0x30 (not possible) - U8(5), // 0x31 (not possible) - U8(3), // 0x32 (not possible) - U8(5), // 0x33 (not possible) - U8(2), // 0x34 (not possible) - U8(5), // 0x35 (not possible) - U8(2), // 0x36 (not possible) - U8(5), // 0x37 (not possible) - U8(2), // 0x38 (not possible) - U8(5), // 0x39 (not possible) - U8(2), // 0x3a (not possible) - U8(5), // 0x3b (not possible) - U8(2), // 0x3c (not possible) - U8(5), // 0x3d (not possible) - U8(2), // 0x3e (not possible) - U8(5), // 0x3f (not possible) + SQLITE_BLOB, // 0x00 (not possible) + SQLITE_NULL, // 0x01 NULL + SQLITE_TEXT, // 0x02 TEXT + SQLITE_NULL, // 0x03 (not possible) + SQLITE_INTEGER, // 0x04 INTEGER + SQLITE_NULL, // 0x05 (not possible) + SQLITE_INTEGER, // 0x06 INTEGER + TEXT + SQLITE_NULL, // 0x07 (not possible) + SQLITE_FLOAT, // 0x08 FLOAT + SQLITE_NULL, // 0x09 (not possible) + SQLITE_FLOAT, // 0x0a FLOAT + TEXT + SQLITE_NULL, // 0x0b (not possible) + SQLITE_INTEGER, // 0x0c (not possible) + SQLITE_NULL, // 0x0d (not possible) + SQLITE_INTEGER, // 0x0e (not possible) + SQLITE_NULL, // 0x0f (not possible) + SQLITE_BLOB, // 0x10 BLOB + SQLITE_NULL, // 0x11 (not possible) + SQLITE_TEXT, // 0x12 (not possible) + SQLITE_NULL, // 0x13 (not possible) + SQLITE_INTEGER, // 0x14 INTEGER + BLOB + SQLITE_NULL, // 0x15 (not possible) + SQLITE_INTEGER, // 0x16 (not possible) + SQLITE_NULL, // 0x17 (not possible) + SQLITE_FLOAT, // 0x18 FLOAT + BLOB + SQLITE_NULL, // 0x19 (not possible) + SQLITE_FLOAT, // 0x1a (not possible) + SQLITE_NULL, // 0x1b (not possible) + SQLITE_INTEGER, // 0x1c (not possible) + SQLITE_NULL, // 0x1d (not possible) + SQLITE_INTEGER, // 0x1e (not possible) + SQLITE_NULL, // 0x1f (not possible) + SQLITE_FLOAT, // 0x20 INTREAL + SQLITE_NULL, // 0x21 (not possible) + SQLITE_TEXT, // 0x22 INTREAL + TEXT + SQLITE_NULL, // 0x23 (not possible) + SQLITE_FLOAT, // 0x24 (not possible) + SQLITE_NULL, // 0x25 (not possible) + SQLITE_FLOAT, // 0x26 (not possible) + SQLITE_NULL, // 0x27 (not possible) + SQLITE_FLOAT, // 0x28 (not possible) + SQLITE_NULL, // 0x29 (not possible) + SQLITE_FLOAT, // 0x2a (not possible) + SQLITE_NULL, // 0x2b (not possible) + SQLITE_FLOAT, // 0x2c (not possible) + SQLITE_NULL, // 0x2d (not possible) + SQLITE_FLOAT, // 0x2e (not possible) + SQLITE_NULL, // 0x2f (not possible) + SQLITE_BLOB, // 0x30 (not possible) + SQLITE_NULL, // 0x31 (not possible) + SQLITE_TEXT, // 0x32 (not possible) + SQLITE_NULL, // 0x33 (not possible) + SQLITE_FLOAT, // 0x34 (not possible) + SQLITE_NULL, // 0x35 (not possible) + SQLITE_FLOAT, // 0x36 (not possible) + SQLITE_NULL, // 0x37 (not possible) + SQLITE_FLOAT, // 0x38 (not possible) + SQLITE_NULL, // 0x39 (not possible) + SQLITE_FLOAT, // 0x3a (not possible) + SQLITE_NULL, // 0x3b (not possible) + SQLITE_FLOAT, // 0x3c (not possible) + SQLITE_NULL, // 0x3d (not possible) + SQLITE_FLOAT, // 0x3e (not possible) + SQLITE_NULL, // 0x3f (not possible) } /* sqlite3.c:83223:19 */ // Return true if a parameter to xUpdate represents an unchanged column func Xsqlite3_value_nochange(tls *libc.TLS, pVal uintptr) int32 { /* sqlite3.c:83308:16: */ - return (libc.Bool32((int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & (0x0001 | 0x4000)) == (0x0001 | 0x4000))) + return (libc.Bool32((int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & (MEM_Null | MEM_Zero)) == (MEM_Null | MEM_Zero))) } // Return true if a parameter value originated from an sqlite3_bind() func Xsqlite3_value_frombind(tls *libc.TLS, pVal uintptr) int32 { /* sqlite3.c:83313:16: */ - return (libc.Bool32((int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & 0x0040) != 0)) + return (libc.Bool32((int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & MEM_FromBind) != 0)) } // Make a copy of an sqlite3_value object @@ -59607,12 +59042,12 @@ func Xsqlite3_value_dup(tls *libc.TLS, pOrig uintptr) uintptr { /* sqlite3.c:833 } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(Sqlite3_value{}))) libc.Xmemcpy(tls, pNew, pOrig, uint64((uintptr(0) + 24 /* &.zMalloc */))) - *(*U16)(unsafe.Pointer(pNew + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0400))) + *(*U16)(unsafe.Pointer(pNew + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Dyn))) (*Sqlite3_value)(unsafe.Pointer(pNew)).Fdb = uintptr(0) - if (int32((*Sqlite3_value)(unsafe.Pointer(pNew)).Fflags) & (0x0002 | 0x0010)) != 0 { - *(*U16)(unsafe.Pointer(pNew + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32((0x0800 | 0x0400)))) - *(*U16)(unsafe.Pointer(pNew + 8 /* &.flags */)) |= U16((0x1000)) - if Xsqlite3VdbeMemMakeWriteable(tls, pNew) != 0 { + if (int32((*Sqlite3_value)(unsafe.Pointer(pNew)).Fflags) & (MEM_Str | MEM_Blob)) != 0 { + *(*U16)(unsafe.Pointer(pNew + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32((MEM_Static | MEM_Dyn)))) + *(*U16)(unsafe.Pointer(pNew + 8 /* &.flags */)) |= U16((MEM_Ephem)) + if Xsqlite3VdbeMemMakeWriteable(tls, pNew) != SQLITE_OK { Xsqlite3ValueFree(tls, pNew) pNew = uintptr(0) } @@ -59638,7 +59073,7 @@ func Xsqlite3_value_free(tls *libc.TLS, pOld uintptr) { /* sqlite3.c:83342:17: * // The invokeValueDestructor(P,X) routine invokes destructor function X() // on value P is not going to be used and need to be destroyed. func setResultStrOrError(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, enc U8, xDel uintptr) { /* sqlite3.c:83358:13: */ - if Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, n, enc, xDel) == 18 { + if Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, n, enc, xDel) == SQLITE_TOOBIG { Xsqlite3_result_error_toobig(tls, pCtx) } } @@ -59655,7 +59090,7 @@ func invokeValueDestructor(tls *libc.TLS, p uintptr, xDel uintptr, pCtx uintptr) if pCtx != 0 { Xsqlite3_result_error_toobig(tls, pCtx) } - return 18 + return SQLITE_TOOBIG } func Xsqlite3_result_blob(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) { /* sqlite3.c:83385:17: */ @@ -59679,14 +59114,14 @@ func Xsqlite3_result_double(tls *libc.TLS, pCtx uintptr, rVal float64) { /* sqli func Xsqlite3_result_error(tls *libc.TLS, pCtx uintptr, z uintptr, n int32) { /* sqlite3.c:83413:17: */ - (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = 1 - Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, n, uint8(1), libc.UintptrFromInt32(-1)) + (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = SQLITE_ERROR + Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, n, SQLITE_UTF8, libc.UintptrFromInt32(-1)) } func Xsqlite3_result_error16(tls *libc.TLS, pCtx uintptr, z uintptr, n int32) { /* sqlite3.c:83419:17: */ - (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = 1 - Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, n, uint8(2), libc.UintptrFromInt32(-1)) + (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = SQLITE_ERROR + Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, n, SQLITE_UTF16LE, libc.UintptrFromInt32(-1)) } func Xsqlite3_result_int(tls *libc.TLS, pCtx uintptr, iVal int32) { /* sqlite3.c:83425:17: */ @@ -59708,7 +59143,7 @@ func Xsqlite3_result_pointer(tls *libc.TLS, pCtx uintptr, pPtr uintptr, zPType u var pOut uintptr = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut Xsqlite3VdbeMemRelease(tls, pOut) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Null Xsqlite3VdbeMemSetPointer(tls, pOut, pPtr, zPType, xDestructor) } @@ -59716,18 +59151,18 @@ func Xsqlite3_result_subtype(tls *libc.TLS, pCtx uintptr, eSubtype uint32) { /* var pOut uintptr = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut (*Mem)(unsafe.Pointer(pOut)).FeSubtype = (U8(eSubtype & uint32(0xff))) - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((0x8000)) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((MEM_Subtype)) } func Xsqlite3_result_text(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) { /* sqlite3.c:83455:17: */ - setResultStrOrError(tls, pCtx, z, n, uint8(1), xDel) + setResultStrOrError(tls, pCtx, z, n, SQLITE_UTF8, xDel) } func Xsqlite3_result_text64(tls *libc.TLS, pCtx uintptr, z uintptr, n Sqlite3_uint64, xDel uintptr, enc uint8) { /* sqlite3.c:83464:17: */ - if int32(enc) == 4 { - enc = uint8(2) + if int32(enc) == SQLITE_UTF16 { + enc = SQLITE_UTF16LE } if n > uint64(0x7fffffff) { invokeValueDestructor(tls, z, xDel, pCtx) @@ -59738,17 +59173,17 @@ func Xsqlite3_result_text64(tls *libc.TLS, pCtx uintptr, z uintptr, n Sqlite3_ui func Xsqlite3_result_text16(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) { /* sqlite3.c:83481:17: */ - setResultStrOrError(tls, pCtx, z, n, uint8(2), xDel) + setResultStrOrError(tls, pCtx, z, n, SQLITE_UTF16LE, xDel) } func Xsqlite3_result_text16be(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) { /* sqlite3.c:83490:17: */ - setResultStrOrError(tls, pCtx, z, n, uint8(3), xDel) + setResultStrOrError(tls, pCtx, z, n, SQLITE_UTF16BE, xDel) } func Xsqlite3_result_text16le(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) { /* sqlite3.c:83499:17: */ - setResultStrOrError(tls, pCtx, z, n, uint8(2), xDel) + setResultStrOrError(tls, pCtx, z, n, SQLITE_UTF16LE, xDel) } func Xsqlite3_result_value(tls *libc.TLS, pCtx uintptr, pValue uintptr) { /* sqlite3.c:83509:17: */ @@ -59764,11 +59199,11 @@ func Xsqlite3_result_zeroblob(tls *libc.TLS, pCtx uintptr, n int32) { /* sqlite3 func Xsqlite3_result_zeroblob64(tls *libc.TLS, pCtx uintptr, n U64) int32 { /* sqlite3.c:83517:16: */ var pOut uintptr = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut - if n > U64(*(*int32)(unsafe.Pointer(((*Mem)(unsafe.Pointer(pOut)).Fdb + 124 /* &.aLimit */) + uintptr(0)*4))) { - return 18 + if n > U64(*(*int32)(unsafe.Pointer(((*Mem)(unsafe.Pointer(pOut)).Fdb + 124 /* &.aLimit */)))) { + return SQLITE_TOOBIG } Xsqlite3VdbeMemSetZeroBlob(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, int32(n)) - return 0 + return SQLITE_OK } func Xsqlite3_result_error_code(tls *libc.TLS, pCtx uintptr, errCode int32) { /* sqlite3.c:83526:17: */ @@ -59778,25 +59213,25 @@ func Xsqlite3_result_error_code(tls *libc.TLS, pCtx uintptr, errCode int32) { /* } return -1 }() - if (int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fflags) & 0x0001) != 0 { + if (int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fflags) & MEM_Null) != 0 { Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, Xsqlite3ErrStr(tls, errCode), -1, - uint8(1), uintptr(0)) + SQLITE_UTF8, uintptr(0)) } } // Force an SQLITE_TOOBIG error. func Xsqlite3_result_error_toobig(tls *libc.TLS, pCtx uintptr) { /* sqlite3.c:83538:17: */ - (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = 18 + (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = SQLITE_TOOBIG Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, ts+4289 /* "string or blob t..." */, -1, - uint8(1), uintptr(0)) + SQLITE_UTF8, uintptr(0)) } // An SQLITE_NOMEM error. func Xsqlite3_result_error_nomem(tls *libc.TLS, pCtx uintptr) { /* sqlite3.c:83546:17: */ Xsqlite3VdbeMemSetNull(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut) - (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = 7 + (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = SQLITE_NOMEM Xsqlite3OomFault(tls, (*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fdb) } @@ -59805,16 +59240,16 @@ func Xsqlite3_result_error_nomem(tls *libc.TLS, pCtx uintptr) { /* sqlite3.c:835 // test-control. func Xsqlite3ResultIntReal(tls *libc.TLS, pCtx uintptr) { /* sqlite3.c:83558:21: */ - if (int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fflags) & 0x0004) != 0 { - *(*U16)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0004))) - *(*U16)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut + 8 /* &.flags */)) |= U16((0x0020)) + if (int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fflags) & MEM_Int) != 0 { + *(*U16)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Int))) + *(*U16)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut + 8 /* &.flags */)) |= U16((MEM_IntReal)) } } // This function is called after a transaction has been committed. It // invokes callbacks registered with sqlite3_wal_hook() as required. func doWalCallbacks(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:83572:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt @@ -59823,7 +59258,7 @@ func doWalCallbacks(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:83572:12: */ Xsqlite3BtreeEnter(tls, pBt) nEntry = Xsqlite3PagerWalCallback(tls, Xsqlite3BtreePager(tls, pBt)) Xsqlite3BtreeLeave(tls, pBt) - if ((nEntry > 0) && ((*Sqlite3)(unsafe.Pointer(db)).FxWalCallback != 0)) && (rc == 0) { + if ((nEntry > 0) && ((*Sqlite3)(unsafe.Pointer(db)).FxWalCallback != 0)) && (rc == SQLITE_OK) { rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32) int32)(unsafe.Pointer((db + 344 /* &.xWalCallback */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpWalArg, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).FzDbSName, nEntry) } } @@ -59842,7 +59277,7 @@ func sqlite3Step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:83602:12: */ var db uintptr var rc int32 - if !((*Vdbe)(unsafe.Pointer(p)).Fmagic != U32(0x2df20da3)) { + if !((*Vdbe)(unsafe.Pointer(p)).Fmagic != VDBE_MAGIC_RUN) { goto __1 } // We used to require that sqlite3_reset() be called before retrying @@ -59869,17 +59304,17 @@ __1: if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __2 } - (*Vdbe)(unsafe.Pointer(p)).Frc = 7 - return 7 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM + return SQLITE_NOMEM __2: ; if !(((*Vdbe)(unsafe.Pointer(p)).Fpc < 0) && ((Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.expired */)) & 0x3 >> 0))) != 0)) { goto __3 } - (*Vdbe)(unsafe.Pointer(p)).Frc = 17 - rc = 1 - if !((int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags) & 0x80) != 0) { + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_SCHEMA + rc = SQLITE_ERROR + if !((int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags) & SQLITE_PREPARE_SAVESQL) != 0) { goto __4 } // If this statement was prepared using saved SQL and an @@ -59904,7 +59339,7 @@ __3: __6: ; - if !((((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & (0x02 | 0x80)) != 0) && + if !((((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & (SQLITE_TRACE_PROFILE | SQLITE_TRACE_XPROFILE)) != 0) && !(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0)) && ((*Vdbe)(unsafe.Pointer(p)).FzSql != 0)) { goto __7 } @@ -59944,7 +59379,7 @@ __11: __12: ; - if !(rc != 100) { + if !(rc != SQLITE_ROW) { goto __13 } // If the statement completed successfully, invoke the profile callback @@ -59955,20 +59390,20 @@ __12: __14: ; - if !((rc == 101) && ((*Sqlite3)(unsafe.Pointer(db)).FautoCommit != 0)) { + if !((rc == SQLITE_DONE) && ((*Sqlite3)(unsafe.Pointer(db)).FautoCommit != 0)) { goto __15 } (*Vdbe)(unsafe.Pointer(p)).Frc = doWalCallbacks(tls, db) - if !((*Vdbe)(unsafe.Pointer(p)).Frc != 0) { + if !((*Vdbe)(unsafe.Pointer(p)).Frc != SQLITE_OK) { goto __17 } - rc = 1 + rc = SQLITE_ERROR __17: ; goto __16 __15: - if !((rc != 101) && ((int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags) & 0x80) != 0)) { + if !((rc != SQLITE_DONE) && ((int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags) & SQLITE_PREPARE_SAVESQL) != 0)) { goto __18 } // If this statement was prepared using saved SQL and an @@ -59983,11 +59418,11 @@ __13: ; (*Sqlite3)(unsafe.Pointer(db)).FerrCode = rc - if !(7 == Xsqlite3ApiExit(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, (*Vdbe)(unsafe.Pointer(p)).Frc)) { + if !(SQLITE_NOMEM == Xsqlite3ApiExit(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, (*Vdbe)(unsafe.Pointer(p)).Frc)) { goto __19 } - (*Vdbe)(unsafe.Pointer(p)).Frc = 7 - if !((int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags) & 0x80) != 0) { + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM + if !((int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags) & SQLITE_PREPARE_SAVESQL) != 0) { goto __20 } rc = (*Vdbe)(unsafe.Pointer(p)).Frc @@ -60006,10 +59441,10 @@ end_of_step: // sqlite3Step() to do most of the work. If a schema error occurs, // call sqlite3Reprepare() and try again. func Xsqlite3_step(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83736:16: */ - var rc int32 = 0 // Result from sqlite3Step() - var v uintptr = pStmt // the prepared statement - var cnt int32 = 0 // Counter to prevent infinite loop of reprepares - var db uintptr // The database connection + var rc int32 = SQLITE_OK // Result from sqlite3Step() + var v uintptr = pStmt // the prepared statement + var cnt int32 = 0 // Counter to prevent infinite loop of reprepares + var db uintptr // The database connection if vdbeSafetyNotNull(tls, v) != 0 { return Xsqlite3MisuseError(tls, 83743) @@ -60017,11 +59452,11 @@ func Xsqlite3_step(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83736:16: db = (*Vdbe)(unsafe.Pointer(v)).Fdb Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) (*Vdbe)(unsafe.Pointer(v)).FdoingRerun = U8(0) - for ((libc.AssignInt32(&rc, sqlite3Step(tls, v))) == 17) && - (libc.PostIncInt32(&cnt, 1) < 50) { + for ((libc.AssignInt32(&rc, sqlite3Step(tls, v))) == SQLITE_SCHEMA) && + (libc.PostIncInt32(&cnt, 1) < SQLITE_MAX_SCHEMA_RETRY) { var savedPc int32 = (*Vdbe)(unsafe.Pointer(v)).Fpc rc = Xsqlite3Reprepare(tls, v) - if rc != 0 { + if rc != SQLITE_OK { // This case occurs after failing to recompile an sql statement. // The error message from the SQL compiler has already been loaded // into the database handle. This block copies the error message @@ -60036,7 +59471,7 @@ func Xsqlite3_step(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83736:16: (*Vdbe)(unsafe.Pointer(v)).Frc = libc.AssignInt32(&rc, Xsqlite3ApiExit(tls, db, rc)) } else { (*Vdbe)(unsafe.Pointer(v)).FzErrMsg = uintptr(0) - (*Vdbe)(unsafe.Pointer(v)).Frc = libc.AssignInt32(&rc, 7) + (*Vdbe)(unsafe.Pointer(v)).Frc = libc.AssignInt32(&rc, SQLITE_NOMEM) } break } @@ -60123,7 +59558,7 @@ func createAggContext(tls *libc.TLS, p uintptr, nByte int32) uintptr { /* sqlite (*Mem)(unsafe.Pointer(pMem)).Fz = uintptr(0) } else { Xsqlite3VdbeMemClearAndResize(tls, pMem, nByte) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x2000) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Agg *(*uintptr)(unsafe.Pointer(pMem /* &.u */)) = (*Sqlite3_context)(unsafe.Pointer(p)).FpFunc if (*Mem)(unsafe.Pointer(pMem)).Fz != 0 { libc.Xmemset(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, 0, uint64(nByte)) @@ -60137,7 +59572,7 @@ func createAggContext(tls *libc.TLS, p uintptr, nByte int32) uintptr { /* sqlite // same context that was returned on prior calls. func Xsqlite3_aggregate_context(tls *libc.TLS, p uintptr, nByte int32) uintptr { /* sqlite3.c:83873:17: */ - if (int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(p)).FpMem)).Fflags) & 0x2000) == 0 { + if (int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(p)).FpMem)).Fflags) & MEM_Agg) == 0 { return createAggContext(tls, p, nByte) } else { return (*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(p)).FpMem)).Fz @@ -60286,28 +59721,7 @@ func columnNullValue(tls *libc.TLS) uintptr { /* sqlite3.c:84002:18: */ } var nullMem = Mem{ - /* .u = */ Fu: - /* .u = */ MemValue{}, - Fflags: - /* .flags = */ U16(0x0001), - Fenc: - /* .enc = */ U8(0), - FeSubtype: - /* .eSubtype = */ U8(0), - Fn: - /* .n = */ 0, - Fz: - /* .z = */ uintptr(0), - FzMalloc: - /* .zMalloc = */ uintptr(0), - FszMalloc: - /* .szMalloc = */ 0, - FuTemp: - /* .uTemp = */ U32(0), - Fdb: - /* .db = */ uintptr(0), - FxDel: - /* .xDel = */ uintptr(0), + /* .flags = */ Fflags: MEM_Null, } /* sqlite3.c:84012:20 */ // Check to see if column iCol of the given statement is valid. If @@ -60327,7 +59741,7 @@ func columnMem(tls *libc.TLS, pStmt uintptr, i int32) uintptr { /* sqlite3.c:840 if (((*Vdbe)(unsafe.Pointer(pVm)).FpResultSet != uintptr(0)) && (i < int32((*Vdbe)(unsafe.Pointer(pVm)).FnResColumn))) && (i >= 0) { pOut = ((*Vdbe)(unsafe.Pointer(pVm)).FpResultSet + uintptr(i)*56) } else { - Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(pVm)).Fdb, 25) + Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(pVm)).Fdb, SQLITE_RANGE) pOut = columnNullValue(tls) } return pOut @@ -60414,9 +59828,9 @@ func Xsqlite3_column_text(tls *libc.TLS, pStmt uintptr, i int32) uintptr { /* sq func Xsqlite3_column_value(tls *libc.TLS, pStmt uintptr, i int32) uintptr { /* sqlite3.c:84137:26: */ var pOut uintptr = columnMem(tls, pStmt, i) - if (int32((*Mem)(unsafe.Pointer(pOut)).Fflags) & 0x0800) != 0 { - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0800))) - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((0x1000)) + if (int32((*Mem)(unsafe.Pointer(pOut)).Fflags) & MEM_Static) != 0 { + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Static))) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((MEM_Ephem)) } columnMallocFailure(tls, pStmt) return pOut @@ -60481,11 +59895,11 @@ func columnName(tls *libc.TLS, pStmt uintptr, N int32, useUtf16 int32, useType i // Return the name of the Nth column of the result set returned by SQL // statement pStmt. func Xsqlite3_column_name(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84224:23: */ - return columnName(tls, pStmt, N, 0, 0) + return columnName(tls, pStmt, N, 0, COLNAME_NAME) } func Xsqlite3_column_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84228:23: */ - return columnName(tls, pStmt, N, 1, 0) + return columnName(tls, pStmt, N, 1, COLNAME_NAME) } // Constraint: If you have ENABLE_COLUMN_METADATA then you must @@ -60494,44 +59908,44 @@ func Xsqlite3_column_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* // Return the column declaration type (if applicable) of the 'i'th column // of the result set of SQL statement pStmt. func Xsqlite3_column_decltype(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84247:23: */ - return columnName(tls, pStmt, N, 0, 1) + return columnName(tls, pStmt, N, 0, COLNAME_DECLTYPE) } func Xsqlite3_column_decltype16(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84251:23: */ - return columnName(tls, pStmt, N, 1, 1) + return columnName(tls, pStmt, N, 1, COLNAME_DECLTYPE) } // Return the name of the database from which a result column derives. // NULL is returned if the result column is an expression or constant or // anything else which is not an unambiguous reference to a database column. func Xsqlite3_column_database_name(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84263:23: */ - return columnName(tls, pStmt, N, 0, 2) + return columnName(tls, pStmt, N, 0, COLNAME_DATABASE) } func Xsqlite3_column_database_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84267:23: */ - return columnName(tls, pStmt, N, 1, 2) + return columnName(tls, pStmt, N, 1, COLNAME_DATABASE) } // Return the name of the table from which a result column derives. // NULL is returned if the result column is an expression or constant or // anything else which is not an unambiguous reference to a database column. func Xsqlite3_column_table_name(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84277:23: */ - return columnName(tls, pStmt, N, 0, 3) + return columnName(tls, pStmt, N, 0, COLNAME_TABLE) } func Xsqlite3_column_table_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84281:23: */ - return columnName(tls, pStmt, N, 1, 3) + return columnName(tls, pStmt, N, 1, COLNAME_TABLE) } // Return the name of the table column from which a result column derives. // NULL is returned if the result column is an expression or constant or // anything else which is not an unambiguous reference to a database column. func Xsqlite3_column_origin_name(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84291:23: */ - return columnName(tls, pStmt, N, 0, 4) + return columnName(tls, pStmt, N, 0, COLNAME_COLUMN) } func Xsqlite3_column_origin_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84295:23: */ - return columnName(tls, pStmt, N, 1, 4) + return columnName(tls, pStmt, N, 1, COLNAME_COLUMN) } // ****************************** sqlite3_bind_ *************************** @@ -60556,23 +59970,23 @@ func vdbeUnbind(tls *libc.TLS, p uintptr, i int32) int32 { /* sqlite3.c:84317:12 return Xsqlite3MisuseError(tls, 84320) } Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) - if ((*Vdbe)(unsafe.Pointer(p)).Fmagic != U32(0x2df20da3)) || ((*Vdbe)(unsafe.Pointer(p)).Fpc >= 0) { - Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, 21) + if ((*Vdbe)(unsafe.Pointer(p)).Fmagic != VDBE_MAGIC_RUN) || ((*Vdbe)(unsafe.Pointer(p)).Fpc >= 0) { + Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, SQLITE_MISUSE) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) - Xsqlite3_log(tls, 21, + Xsqlite3_log(tls, SQLITE_MISUSE, ts+4312 /* "bind on a busy p..." */, libc.VaList(bp, (*Vdbe)(unsafe.Pointer(p)).FzSql)) return Xsqlite3MisuseError(tls, 84328) } if (i < 1) || (i > int32((*Vdbe)(unsafe.Pointer(p)).FnVar)) { - Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, 25) + Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, SQLITE_RANGE) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) - return 25 + return SQLITE_RANGE } i-- pVar = ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr(i)*56) Xsqlite3VdbeMemRelease(tls, pVar) - (*Mem)(unsafe.Pointer(pVar)).Fflags = U16(0x0001) - (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FerrCode = 0 + (*Mem)(unsafe.Pointer(pVar)).Fflags = MEM_Null + (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FerrCode = SQLITE_OK // If the bit corresponding to this variable in Vdbe.expmask is set, then // binding a new value to this variable invalidates the current query plan. @@ -60591,7 +60005,7 @@ func vdbeUnbind(tls *libc.TLS, p uintptr, i int32) int32 { /* sqlite3.c:84317:12 }())) != U32(0)) { libc.SetBitFieldPtr16Uint32(p+200 /* &.expired */, Bft(1), 0, 0x3) } - return 0 + return SQLITE_OK } // Bind a text or BLOB value. @@ -60601,11 +60015,11 @@ func bindText(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData int32, var rc int32 rc = vdbeUnbind(tls, p, i) - if rc == 0 { + if rc == SQLITE_OK { if zData != uintptr(0) { pVar = ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((i-1))*56) rc = Xsqlite3VdbeMemSetStr(tls, pVar, zData, nData, encoding, xDel) - if (rc == 0) && (int32(encoding) != 0) { + if (rc == SQLITE_OK) && (int32(encoding) != 0) { rc = Xsqlite3VdbeChangeEncoding(tls, pVar, int32((*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fenc)) } if rc != 0 { @@ -60639,7 +60053,7 @@ func Xsqlite3_bind_double(tls *libc.TLS, pStmt uintptr, i int32, rValue float64) var rc int32 var p uintptr = pStmt rc = vdbeUnbind(tls, p, i) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3VdbeMemSetDouble(tls, ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((i-1))*56), rValue) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) } @@ -60654,7 +60068,7 @@ func Xsqlite3_bind_int64(tls *libc.TLS, pStmt uintptr, i int32, iValue Sqlite_in var rc int32 var p uintptr = pStmt rc = vdbeUnbind(tls, p, i) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3VdbeMemSetInt64(tls, ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((i-1))*56), iValue) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) } @@ -60665,7 +60079,7 @@ func Xsqlite3_bind_null(tls *libc.TLS, pStmt uintptr, i int32) int32 { /* sqlite var rc int32 var p uintptr = pStmt rc = vdbeUnbind(tls, p, i) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) } return rc @@ -60675,7 +60089,7 @@ func Xsqlite3_bind_pointer(tls *libc.TLS, pStmt uintptr, i int32, pPtr uintptr, var rc int32 var p uintptr = pStmt rc = vdbeUnbind(tls, p, i) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3VdbeMemSetPointer(tls, ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((i-1))*56), pPtr, zPTtype, xDestructor) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) } else if xDestructor != 0 { @@ -60685,7 +60099,7 @@ func Xsqlite3_bind_pointer(tls *libc.TLS, pStmt uintptr, i int32, pPtr uintptr, } func Xsqlite3_bind_text(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData int32, xDel uintptr) int32 { /* sqlite3.c:84472:16: */ - return bindText(tls, pStmt, i, zData, nData, xDel, uint8(1)) + return bindText(tls, pStmt, i, zData, nData, xDel, SQLITE_UTF8) } func Xsqlite3_bind_text64(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData Sqlite3_uint64, xDel uintptr, enc uint8) int32 { /* sqlite3.c:84481:16: */ @@ -60693,8 +60107,8 @@ func Xsqlite3_bind_text64(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, if nData > uint64(0x7fffffff) { return invokeValueDestructor(tls, zData, xDel, uintptr(0)) } else { - if int32(enc) == 4 { - enc = uint8(2) + if int32(enc) == SQLITE_UTF16 { + enc = SQLITE_UTF16LE } return bindText(tls, pStmt, i, zData, int32(nData), xDel, enc) } @@ -60702,27 +60116,27 @@ func Xsqlite3_bind_text64(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, } func Xsqlite3_bind_text16(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData int32, xDel uintptr) int32 { /* sqlite3.c:84498:16: */ - return bindText(tls, pStmt, i, zData, nData, xDel, uint8(2)) + return bindText(tls, pStmt, i, zData, nData, xDel, SQLITE_UTF16LE) } func Xsqlite3_bind_value(tls *libc.TLS, pStmt uintptr, i int32, pValue uintptr) int32 { /* sqlite3.c:84508:16: */ var rc int32 switch Xsqlite3_value_type(tls, pValue) { - case 1: + case SQLITE_INTEGER: { rc = Xsqlite3_bind_int64(tls, pStmt, i, *(*I64)(unsafe.Pointer(pValue /* &.u */))) break } - case 2: + case SQLITE_FLOAT: { rc = Xsqlite3_bind_double(tls, pStmt, i, *(*float64)(unsafe.Pointer(pValue /* &.u */))) break } - case 4: + case SQLITE_BLOB: { - if (int32((*Sqlite3_value)(unsafe.Pointer(pValue)).Fflags) & 0x4000) != 0 { + if (int32((*Sqlite3_value)(unsafe.Pointer(pValue)).Fflags) & MEM_Zero) != 0 { rc = Xsqlite3_bind_zeroblob(tls, pStmt, i, *(*int32)(unsafe.Pointer(pValue /* &.u */))) } else { rc = Xsqlite3_bind_blob(tls, pStmt, i, (*Sqlite3_value)(unsafe.Pointer(pValue)).Fz, (*Sqlite3_value)(unsafe.Pointer(pValue)).Fn, libc.UintptrFromInt32(-1)) @@ -60730,7 +60144,7 @@ func Xsqlite3_bind_value(tls *libc.TLS, pStmt uintptr, i int32, pValue uintptr) break } - case 3: + case SQLITE_TEXT: { rc = bindText(tls, pStmt, i, (*Sqlite3_value)(unsafe.Pointer(pValue)).Fz, (*Sqlite3_value)(unsafe.Pointer(pValue)).Fn, libc.UintptrFromInt32(-1), (*Sqlite3_value)(unsafe.Pointer(pValue)).Fenc) @@ -60751,7 +60165,7 @@ func Xsqlite3_bind_zeroblob(tls *libc.TLS, pStmt uintptr, i int32, n int32) int3 var rc int32 var p uintptr = pStmt rc = vdbeUnbind(tls, p, i) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3VdbeMemSetZeroBlob(tls, ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((i-1))*56), n) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) } @@ -60762,8 +60176,8 @@ func Xsqlite3_bind_zeroblob64(tls *libc.TLS, pStmt uintptr, i int32, n Sqlite3_u var rc int32 var p uintptr = pStmt Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) - if n > U64(*(*int32)(unsafe.Pointer(((*Vdbe)(unsafe.Pointer(p)).Fdb + 124 /* &.aLimit */) + uintptr(0)*4))) { - rc = 18 + if n > U64(*(*int32)(unsafe.Pointer(((*Vdbe)(unsafe.Pointer(p)).Fdb + 124 /* &.aLimit */)))) { + rc = SQLITE_TOOBIG } else { rc = Xsqlite3_bind_zeroblob(tls, pStmt, i, int32(n)) @@ -60820,7 +60234,7 @@ func Xsqlite3TransferBindings(tls *libc.TLS, pFromStmt uintptr, pToStmt uintptr) Xsqlite3VdbeMemMove(tls, ((*Vdbe)(unsafe.Pointer(pTo)).FaVar + uintptr(i)*56), ((*Vdbe)(unsafe.Pointer(pFrom)).FaVar + uintptr(i)*56)) } Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(pTo)).Fdb)).Fmutex) - return 0 + return SQLITE_OK } // Deprecated external interface. Internal/core SQLite code @@ -60837,7 +60251,7 @@ func Xsqlite3_transfer_bindings(tls *libc.TLS, pFromStmt uintptr, pToStmt uintpt var pFrom uintptr = pFromStmt var pTo uintptr = pToStmt if int32((*Vdbe)(unsafe.Pointer(pFrom)).FnVar) != int32((*Vdbe)(unsafe.Pointer(pTo)).FnVar) { - return 1 + return SQLITE_ERROR } if (*Vdbe)(unsafe.Pointer(pTo)).Fexpmask != 0 { @@ -60882,7 +60296,7 @@ func Xsqlite3_stmt_isexplain(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c: // Return true if the prepared statement is in need of being reset. func Xsqlite3_stmt_busy(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:84675:16: */ var v uintptr = pStmt - return (libc.Bool32(((v != uintptr(0)) && ((*Vdbe)(unsafe.Pointer(v)).Fmagic == U32(0x2df20da3))) && ((*Vdbe)(unsafe.Pointer(v)).Fpc >= 0))) + return (libc.Bool32(((v != uintptr(0)) && ((*Vdbe)(unsafe.Pointer(v)).Fmagic == VDBE_MAGIC_RUN)) && ((*Vdbe)(unsafe.Pointer(v)).Fpc >= 0))) } // Return a pointer to the next prepared statement after pStmt associated @@ -60909,7 +60323,7 @@ func Xsqlite3_stmt_status(tls *libc.TLS, pStmt uintptr, op int32, resetFlag int3 var pVdbe uintptr = pStmt // var v U32 at bp, 4 - if op == 99 { + if op == SQLITE_STMTSTATUS_MEMUSED { var db uintptr = (*Vdbe)(unsafe.Pointer(pVdbe)).Fdb Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) *(*U32)(unsafe.Pointer(bp /* v */)) = U32(0) @@ -60978,11 +60392,11 @@ func Xsqlite3_preupdate_old(tls *libc.TLS, db uintptr, iIdx int32, ppValue uintp var nRec U32 var aRec uintptr p = (*Sqlite3)(unsafe.Pointer(db)).FpPreUpdate - rc = 0 + rc = SQLITE_OK // Test that this call is being made from within an SQLITE_DELETE or // SQLITE_UPDATE pre-update callback, and that iIdx is within range. - if !(!(p != 0) || ((*PreUpdate)(unsafe.Pointer(p)).Fop == 18)) { + if !(!(p != 0) || ((*PreUpdate)(unsafe.Pointer(p)).Fop == SQLITE_INSERT)) { goto __1 } rc = Xsqlite3MisuseError(tls, 84816) @@ -60998,7 +60412,7 @@ __2: if !((iIdx >= int32((*VdbeCursor)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpCsr)).FnField)) || (iIdx < 0)) { goto __3 } - rc = 25 + rc = SQLITE_RANGE goto preupdate_old_out __3: ; @@ -61017,19 +60431,19 @@ __3: __5: ; rc = Xsqlite3BtreePayload(tls, *(*uintptr)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpCsr + 56 /* &.uc */)), uint32(0), nRec, aRec) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __6 } (*PreUpdate)(unsafe.Pointer(p)).FpUnpacked = vdbeUnpackRecord(tls, (p + 32 /* &.keyinfo */), int32(nRec), aRec) if !(!(int32((*PreUpdate)(unsafe.Pointer(p)).FpUnpacked) != 0)) { goto __7 } - rc = 7 + rc = SQLITE_NOMEM __7: ; __6: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __8 } Xsqlite3DbFree(tls, db, aRec) @@ -61053,10 +60467,10 @@ __9: *(*uintptr)(unsafe.Pointer(ppValue)) = columnNullValue(tls) goto __12 __11: - if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpTab)).FaCol+uintptr(iIdx)*32)).Faffinity) == 0x45) { + if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpTab)).FaCol+uintptr(iIdx)*32)).Faffinity) == SQLITE_AFF_REAL) { goto __13 } - if !((int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0004 | 0x0020)) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Int | MEM_IntReal)) != 0) { goto __14 } @@ -61117,16 +60531,16 @@ func Xsqlite3_preupdate_new(tls *libc.TLS, db uintptr, iIdx int32, ppValue uintp // that is being inserted. Deserialize it. var pUnpack uintptr p = (*Sqlite3)(unsafe.Pointer(db)).FpPreUpdate - rc = 0 + rc = SQLITE_OK - if !(!(p != 0) || ((*PreUpdate)(unsafe.Pointer(p)).Fop == 9)) { + if !(!(p != 0) || ((*PreUpdate)(unsafe.Pointer(p)).Fop == SQLITE_DELETE)) { goto __1 } rc = Xsqlite3MisuseError(tls, 84906) goto preupdate_new_out __1: ; - if !(((*PreUpdate)(unsafe.Pointer(p)).FpPk != 0) && ((*PreUpdate)(unsafe.Pointer(p)).Fop != 23)) { + if !(((*PreUpdate)(unsafe.Pointer(p)).FpPk != 0) && ((*PreUpdate)(unsafe.Pointer(p)).Fop != SQLITE_UPDATE)) { goto __2 } iIdx = int32(Xsqlite3TableColumnToIndex(tls, (*PreUpdate)(unsafe.Pointer(p)).FpPk, int16(iIdx))) @@ -61135,12 +60549,12 @@ __2: if !((iIdx >= int32((*VdbeCursor)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpCsr)).FnField)) || (iIdx < 0)) { goto __3 } - rc = 25 + rc = SQLITE_RANGE goto preupdate_new_out __3: ; - if !((*PreUpdate)(unsafe.Pointer(p)).Fop == 18) { + if !((*PreUpdate)(unsafe.Pointer(p)).Fop == SQLITE_INSERT) { goto __4 } // For an INSERT, memory cell p->iNewReg contains the serialized record @@ -61151,12 +60565,12 @@ __3: } pData = ((*Vdbe)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).Fv)).FaMem + uintptr((*PreUpdate)(unsafe.Pointer(p)).FiNewReg)*56) rc = func() int32 { - if (int32((*Mem)(unsafe.Pointer((pData))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pData))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pData) } return 0 }() - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __7 } goto preupdate_new_out @@ -61166,7 +60580,7 @@ __7: if !(!(pUnpack != 0)) { goto __8 } - rc = 7 + rc = SQLITE_NOMEM goto preupdate_new_out __8: ; @@ -61202,7 +60616,7 @@ __4: if !(!(int32((*PreUpdate)(unsafe.Pointer(p)).FaNew) != 0)) { goto __13 } - rc = 7 + rc = SQLITE_NOMEM goto preupdate_new_out __13: ; @@ -61220,7 +60634,7 @@ __12: goto __16 __15: rc = Xsqlite3VdbeMemCopy(tls, pMem, ((*Vdbe)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).Fv)).FaMem + uintptr((((*PreUpdate)(unsafe.Pointer(p)).FiNewReg+1)+iIdx))*56)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __17 } goto preupdate_new_out @@ -61273,10 +60687,10 @@ func findNextHostParameter(tls *libc.TLS, zSql uintptr, pnToken uintptr) int32 { var n int32 *(*int32)(unsafe.Pointer(pnToken)) = 0 - for *(*int8)(unsafe.Pointer(zSql + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(zSql)) != 0 { n = Xsqlite3GetToken(tls, zSql, bp /* &tokenType */) - if *(*int32)(unsafe.Pointer(bp /* tokenType */)) == 153 { + if *(*int32)(unsafe.Pointer(bp /* tokenType */)) == TK_VARIABLE { *(*int32)(unsafe.Pointer(pnToken)) = n break } @@ -61329,7 +60743,7 @@ func Xsqlite3VdbeExpandSql(tls *libc.TLS, p uintptr, zRawSql uintptr) uintptr { db = (*Vdbe)(unsafe.Pointer(p)).Fdb Xsqlite3StrAccumInit(tls, bp+48 /* &out */, uintptr(0), bp+80 /* &zBase[0] */, int32(unsafe.Sizeof([100]int8{})), - *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) + *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeExec > 1 { for *(*int8)(unsafe.Pointer(zRawSql)) != 0 { var zStart uintptr = zRawSql @@ -61342,7 +60756,7 @@ func Xsqlite3VdbeExpandSql(tls *libc.TLS, p uintptr, zRawSql uintptr) uintptr { } else if int32((*Vdbe)(unsafe.Pointer(p)).FnVar) == 0 { Xsqlite3_str_append(tls, bp+48 /* &out */, zRawSql, Xsqlite3Strlen30(tls, zRawSql)) } else { - for *(*int8)(unsafe.Pointer(zRawSql + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(zRawSql)) != 0 { n = findNextHostParameter(tls, zRawSql, bp+180 /* &nToken */) Xsqlite3_str_append(tls, bp+48 /* &out */, zRawSql, n) @@ -61351,10 +60765,10 @@ func Xsqlite3VdbeExpandSql(tls *libc.TLS, p uintptr, zRawSql uintptr) uintptr { if *(*int32)(unsafe.Pointer(bp + 180 /* nToken */)) == 0 { break } - if int32(*(*int8)(unsafe.Pointer(zRawSql + uintptr(0)))) == '?' { + if int32(*(*int8)(unsafe.Pointer(zRawSql))) == '?' { if *(*int32)(unsafe.Pointer(bp + 180 /* nToken */)) > 1 { - Xsqlite3GetInt32(tls, (zRawSql + uintptr(1)), bp+184 /* &idx */) + Xsqlite3GetInt32(tls, (zRawSql + 1), bp+184 /* &idx */) } else { *(*int32)(unsafe.Pointer(bp + 184 /* idx */)) = nextIndex } @@ -61367,31 +60781,31 @@ func Xsqlite3VdbeExpandSql(tls *libc.TLS, p uintptr, zRawSql uintptr) uintptr { nextIndex = (*(*int32)(unsafe.Pointer(bp + 184 /* idx */)) + 1) pVar = ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((*(*int32)(unsafe.Pointer(bp + 184 /* idx */))-1))*56) - if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & 0x0001) != 0 { + if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & MEM_Null) != 0 { Xsqlite3_str_append(tls, bp+48 /* &out */, ts+704 /* "NULL" */, 4) - } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & (0x0004 | 0x0020)) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & (MEM_Int | MEM_IntReal)) != 0 { Xsqlite3_str_appendf(tls, bp+48 /* &out */, ts+3925 /* "%lld" */, libc.VaList(bp, *(*I64)(unsafe.Pointer(pVar /* &.u */)))) - } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & 0x0008) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & MEM_Real) != 0 { Xsqlite3_str_appendf(tls, bp+48 /* &out */, ts+3875 /* "%!.15g" */, libc.VaList(bp+8, *(*float64)(unsafe.Pointer(pVar /* &.u */)))) - } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & 0x0002) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & MEM_Str) != 0 { var nOut int32 // Number of bytes of the string text to include in output var enc U8 = (*Sqlite3)(unsafe.Pointer(db)).Fenc - if int32(enc) != 1 { + if int32(enc) != SQLITE_UTF8 { libc.Xmemset(tls, bp+192 /* &utf8 */, 0, uint64(unsafe.Sizeof(Mem{}))) (*Mem)(unsafe.Pointer(bp + 192 /* &utf8 */)).Fdb = db Xsqlite3VdbeMemSetStr(tls, bp+192 /* &utf8 */, (*Mem)(unsafe.Pointer(pVar)).Fz, (*Mem)(unsafe.Pointer(pVar)).Fn, enc, uintptr(0)) - if 7 == Xsqlite3VdbeChangeEncoding(tls, bp+192 /* &utf8 */, 1) { - (*StrAccum)(unsafe.Pointer(bp + 48 /* &out */)).FaccError = U8(7) + if SQLITE_NOMEM == Xsqlite3VdbeChangeEncoding(tls, bp+192 /* &utf8 */, SQLITE_UTF8) { + (*StrAccum)(unsafe.Pointer(bp + 48 /* &out */)).FaccError = SQLITE_NOMEM (*StrAccum)(unsafe.Pointer(bp + 48 /* &out */)).FnAlloc = U32(0) } pVar = bp + 192 /* &utf8 */ } nOut = (*Mem)(unsafe.Pointer(pVar)).Fn Xsqlite3_str_appendf(tls, bp+48 /* &out */, ts+4356 /* "'%.*q'" */, libc.VaList(bp+16, nOut, (*Mem)(unsafe.Pointer(pVar)).Fz)) - if int32(enc) != 1 { + if int32(enc) != SQLITE_UTF8 { Xsqlite3VdbeMemRelease(tls, bp+192 /* &utf8 */) } - } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & 0x4000) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & MEM_Zero) != 0 { Xsqlite3_str_appendf(tls, bp+48 /* &out */, ts+4363 /* "zeroblob(%d)" */, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(pVar /* &.u */)))) } else { var nOut int32 // Number of bytes of the blob to include in output @@ -61555,8 +60969,8 @@ func allocateCursor(tls *libc.TLS, p uintptr, iCur int32, nField int32, iDb int3 } var nByte int32 var pCx uintptr = uintptr(0) - nByte = (int32(((((uint64(unsafe.Sizeof(VdbeCursor{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)) + ((uint64(2) * uint64(unsafe.Sizeof(U32(0)))) * uint64(nField))) + (func() uint64 { - if int32(eCurType) == 0 { + nByte = (int32(((((uint64(unsafe.Sizeof(VdbeCursor{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))) + ((uint64(2) * uint64(unsafe.Sizeof(U32(0)))) * uint64(nField))) + (func() uint64 { + if int32(eCurType) == CURTYPE_BTREE { return uint64(Xsqlite3BtreeCursorSize(tls)) } return uint64(0) @@ -61573,15 +60987,15 @@ func allocateCursor(tls *libc.TLS, p uintptr, iCur int32, nField int32, iDb int3 Xsqlite3VdbeFreeCursor(tls, p, *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8))) *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8)) = uintptr(0) } - if 0 == Xsqlite3VdbeMemClearAndResize(tls, pMem, nByte) { + if SQLITE_OK == Xsqlite3VdbeMemClearAndResize(tls, pMem, nByte) { *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8)) = libc.AssignUintptr(&pCx, (*Mem)(unsafe.Pointer(pMem)).Fz) libc.Xmemset(tls, pCx, 0, uint64((uintptr(0) + 48 /* &.pAltCursor */))) (*VdbeCursor)(unsafe.Pointer(pCx)).FeCurType = eCurType (*VdbeCursor)(unsafe.Pointer(pCx)).FiDb = I8(iDb) (*VdbeCursor)(unsafe.Pointer(pCx)).FnField = I16(nField) (*VdbeCursor)(unsafe.Pointer(pCx)).FaOffset = ((pCx + 120 /* &.aType */) + uintptr(nField)*4) - if int32(eCurType) == 0 { - *(*uintptr)(unsafe.Pointer(pCx + 56 /* &.uc */)) = ((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(((((uint64(unsafe.Sizeof(VdbeCursor{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)) + ((uint64(2) * uint64(unsafe.Sizeof(U32(0)))) * uint64(nField))))) + if int32(eCurType) == CURTYPE_BTREE { + *(*uintptr)(unsafe.Pointer(pCx + 56 /* &.uc */)) = ((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(((((uint64(unsafe.Sizeof(VdbeCursor{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))) + ((uint64(2) * uint64(unsafe.Sizeof(U32(0)))) * uint64(nField))))) Xsqlite3BtreeCursorZero(tls, *(*uintptr)(unsafe.Pointer(pCx + 56 /* &.uc */))) } } @@ -61628,10 +61042,10 @@ func applyNumericAffinity(tls *libc.TLS, pRec uintptr, bTryForInt int32) { /* sq return } if (rc == 1) && (alsoAnInt(tls, pRec, *(*float64)(unsafe.Pointer(bp /* rValue */)), (pRec /* &.u */ /* &.i */)) != 0) { - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((MEM_Int)) } else { *(*float64)(unsafe.Pointer(pRec /* &.u */)) = *(*float64)(unsafe.Pointer(bp /* rValue */)) - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((MEM_Real)) if bTryForInt != 0 { Xsqlite3VdbeIntegerAffinity(tls, pRec) } @@ -61640,7 +61054,7 @@ func applyNumericAffinity(tls *libc.TLS, pRec uintptr, bTryForInt int32) { /* sq // string representation after computing a numeric equivalent, because the // string representation might not be the canonical representation for the // numeric value. Ticket [343634942dd54ab57b7024] 2018-01-31. - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0002))) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Str))) } // Processing is determine by the affinity parameter: @@ -61661,30 +61075,30 @@ func applyNumericAffinity(tls *libc.TLS, pRec uintptr, bTryForInt int32) { /* sq // SQLITE_AFF_NONE: // No-op. pRec is unchanged. func applyAffinity(tls *libc.TLS, pRec uintptr, affinity int8, enc U8) { /* sqlite3.c:85607:13: */ - if int32(affinity) >= 0x43 { + if int32(affinity) >= SQLITE_AFF_NUMERIC { - if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0004) == 0 { //OPTIMIZATION-IF-FALSE - if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0008) == 0 { - if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0002) != 0 { + if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Int) == 0 { //OPTIMIZATION-IF-FALSE + if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Real) == 0 { + if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Str) != 0 { applyNumericAffinity(tls, pRec, 1) } } else { Xsqlite3VdbeIntegerAffinity(tls, pRec) } } - } else if int32(affinity) == 0x42 { + } else if int32(affinity) == SQLITE_AFF_TEXT { // Only attempt the conversion to TEXT if there is an integer or real // representation (blob and NULL do not get converted) but no string // representation. It would be harmless to repeat the conversion if // there is already a string rep, but it is pointless to waste those // CPU cycles. - if 0 == (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0002) { //OPTIMIZATION-IF-FALSE - if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & ((0x0008 | 0x0004) | 0x0020)) != 0 { + if 0 == (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Str) { //OPTIMIZATION-IF-FALSE + if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & ((MEM_Real | MEM_Int) | MEM_IntReal)) != 0 { Xsqlite3VdbeMemStringify(tls, pRec, enc, uint8(1)) } } - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((0x0008 | 0x0004) | 0x0020)))) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((MEM_Real | MEM_Int) | MEM_IntReal)))) } } @@ -61694,7 +61108,7 @@ func applyAffinity(tls *libc.TLS, pRec uintptr, affinity int8, enc U8) { /* sqli // loss of information and return the revised type of the argument. func Xsqlite3_value_numeric_type(tls *libc.TLS, pVal uintptr) int32 { /* sqlite3.c:85646:16: */ var eType int32 = Xsqlite3_value_type(tls, pVal) - if eType == 3 { + if eType == SQLITE_TEXT { var pMem uintptr = pVal applyNumericAffinity(tls, pMem, 0) eType = Xsqlite3_value_type(tls, pVal) @@ -61719,7 +61133,7 @@ func computeNumericType(tls *libc.TLS, pMem uintptr) U16 { /* sqlite3.c:85674:28 var rc int32 // var ix Sqlite3_int64 at bp, 8 - if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & MEM_Zero) != 0 { Xsqlite3VdbeMemExpandBlob(tls, pMem) } else { } @@ -61727,15 +61141,15 @@ func computeNumericType(tls *libc.TLS, pMem uintptr) U16 { /* sqlite3.c:85674:28 if rc <= 0 { if (rc == 0) && (Xsqlite3Atoi64(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, bp /* &ix */, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc) <= 1) { *(*I64)(unsafe.Pointer(pMem /* &.u */)) = *(*Sqlite3_int64)(unsafe.Pointer(bp /* ix */)) - return U16(0x0004) + return MEM_Int } else { - return U16(0x0008) + return MEM_Real } } else if (rc == 1) && (Xsqlite3Atoi64(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, bp /* &ix */, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc) == 0) { *(*I64)(unsafe.Pointer(pMem /* &.u */)) = *(*Sqlite3_int64)(unsafe.Pointer(bp /* ix */)) - return U16(0x0004) + return MEM_Int } - return U16(0x0008) + return MEM_Real } // Return the numeric type for pMem, either MEM_Int or MEM_Real or both or @@ -61744,11 +61158,11 @@ func computeNumericType(tls *libc.TLS, pMem uintptr) U16 { /* sqlite3.c:85674:28 // Unlike applyNumericAffinity(), this routine does not modify pMem->flags. // But it does set pMem->u.r and pMem->u.i appropriately. func numericType(tls *libc.TLS, pMem uintptr) U16 { /* sqlite3.c:85702:12: */ - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & ((0x0004 | 0x0008) | 0x0020)) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & ((MEM_Int | MEM_Real) | MEM_IntReal)) != 0 { - return (U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & ((0x0004 | 0x0008) | 0x0020))) + return (U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & ((MEM_Int | MEM_Real) | MEM_IntReal))) } - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0002 | 0x0010)) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Str | MEM_Blob)) != 0 { return computeNumericType(tls, pMem) } @@ -61759,7 +61173,7 @@ func numericType(tls *libc.TLS, pMem uintptr) U16 { /* sqlite3.c:85702:12: */ // overwritten with an integer value. func out2PrereleaseWithClear(tls *libc.TLS, pOut uintptr) uintptr { /* sqlite3.c:85961:28: */ Xsqlite3VdbeMemSetNull(tls, pOut) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Int return pOut } @@ -61768,10 +61182,10 @@ func out2Prerelease(tls *libc.TLS, p uintptr, pOp uintptr) uintptr { /* sqlite3. pOut = ((*Vdbe)(unsafe.Pointer(p)).FaMem + uintptr((*VdbeOp)(unsafe.Pointer(pOp)).Fp2)*56) - if (int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & (0x2000 | 0x0400)) != 0 { //OPTIMIZATION-IF-FALSE + if (int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { //OPTIMIZATION-IF-FALSE return out2PrereleaseWithClear(tls, pOut) } else { - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Int return pOut } return uintptr(0) @@ -62140,7 +61554,7 @@ func Xsqlite3VdbeExec(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:85985:20: * var zTrace uintptr aOp = (*Vdbe)(unsafe.Pointer(p)).FaOp pOp = aOp - rc = 0 + rc = SQLITE_OK db = (*Vdbe)(unsafe.Pointer(p)).Fdb resetSchemaOnFault = U8(0) encoding = (*Sqlite3)(unsafe.Pointer(db)).Fenc @@ -62158,7 +61572,7 @@ func Xsqlite3VdbeExec(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:85985:20: * if !((*Sqlite3)(unsafe.Pointer(db)).FxProgress != 0) { goto __1 } - iPrior = *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + uintptr(4)*4)) + iPrior = *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + 4*4)) nProgressLimit = (U64((*Sqlite3)(unsafe.Pointer(db)).FnProgressOps - (iPrior % (*Sqlite3)(unsafe.Pointer(db)).FnProgressOps))) goto __2 @@ -62166,7 +61580,7 @@ __1: nProgressLimit = (uint64(0xffffffff) | (U64((uint64(0xffffffff))) << 32)) __2: ; - if !((*Vdbe)(unsafe.Pointer(p)).Frc == 7) { + if !((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_NOMEM) { goto __3 } // This happens if a malloc() inside a call to sqlite3_column_text() or @@ -62175,7 +61589,7 @@ __2: __3: ; - (*Vdbe)(unsafe.Pointer(p)).Frc = 0 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK (*Vdbe)(unsafe.Pointer(p)).FiCurrentTime = int64(0) @@ -62254,21 +61668,21 @@ __5: // is sometimes set to 1 instead of 0 as a hint to the command-line shell // that this Goto is the bottom of a loop and that the lines from P2 down // to the current line should be indented for EXPLAIN output. - case 11: + case OP_Goto: goto __9 // Opcode: Gosub P1 P2 * * * // // Write the current address onto register P1 // and then jump to address P2. - case 12: + case OP_Gosub: goto __10 // Opcode: Return P1 * * * * // // Jump to the next instruction after the address in register P1. After // the jump, register P1 becomes undefined. - case 65: + case OP_Return: goto __11 // Opcode: InitCoroutine P1 P2 P3 * * @@ -62281,7 +61695,7 @@ __5: // address P2. // // See also: EndCoroutine - case 13: + case OP_InitCoroutine: goto __12 // Opcode: EndCoroutine P1 * * * * @@ -62291,7 +61705,7 @@ __5: // After the jump, register P1 becomes undefined. // // See also: InitCoroutine - case 66: + case OP_EndCoroutine: goto __13 // Opcode: Yield P1 P2 * * * @@ -62306,7 +61720,7 @@ __5: // next instruction. // // See also: InitCoroutine - case 14: + case OP_Yield: goto __14 // Opcode: HaltIfNull P1 P2 P3 P4 P5 @@ -62316,7 +61730,7 @@ __5: // parameter P1, P2, and P4 as if this were a Halt instruction. If the // value in register P3 is not NULL, then this routine is a no-op. // The P5 parameter should be 1. - case 67: + case OP_HaltIfNull: goto __15 // Opcode: Halt P1 P2 * P4 P5 @@ -62348,14 +61762,14 @@ __5: // There is an implied "Halt 0 0 0" instruction inserted at the very end of // every program. So a jump past the last instruction of the program // is the same as executing Halt. - case 68: + case OP_Halt: goto __16 // Opcode: Integer P1 P2 * * * // Synopsis: r[P2]=P1 // // The 32-bit integer value P1 is written into register P2. - case 69: + case OP_Integer: goto __17 // Opcode: Int64 * P2 * P4 * @@ -62363,7 +61777,7 @@ __5: // // P4 is a pointer to a 64-bit integer value. // Write that value into register P2. - case 70: + case OP_Int64: goto __18 // Opcode: Real * P2 * P4 * @@ -62371,7 +61785,7 @@ __5: // // P4 is a pointer to a 64-bit floating point value. // Write that value into register P2. - case 150: + case OP_Real: goto __19 // Opcode: String8 * P2 * P4 * @@ -62381,7 +61795,7 @@ __5: // into a String opcode before it is executed for the first time. During // this transformation, the length of string P4 is computed and stored // as the P1 parameter. - case 115: + case OP_String8: goto __20 // Opcode: String P1 P2 P3 P4 P5 @@ -62395,7 +61809,7 @@ __5: // of a string, as if it had been CAST. In other words: // // if( P3!=0 and reg[P3]==P5 ) reg[P2] := CAST(reg[P2] as BLOB) - case 71: + case OP_String: goto __21 // Opcode: Null P1 P2 P3 * * @@ -62409,7 +61823,7 @@ __5: // If the P1 value is non-zero, then also set the MEM_Cleared flag so that // NULL values will not compare equal even if SQLITE_NULLEQ is set on // OP_Ne or OP_Eq. - case 72: + case OP_Null: goto __22 // Opcode: SoftNull P1 * * * * @@ -62419,7 +61833,7 @@ __5: // instruction, but do not free any string or blob memory associated with // the register, so that if the value was a string or blob that was // previously copied using OP_SCopy, the copies will continue to be valid. - case 73: + case OP_SoftNull: goto __23 // Opcode: Blob P1 P2 * P4 * @@ -62427,7 +61841,7 @@ __5: // // P4 points to a blob of data P1 bytes long. Store this // blob in register P2. - case 74: + case OP_Blob: goto __24 // Opcode: Variable P1 P2 * P4 * @@ -62437,7 +61851,7 @@ __5: // // If the parameter is named, then its name appears in P4. // The P4 value is used by sqlite3_bind_parameter_name(). - case 75: + case OP_Variable: goto __25 // Opcode: Move P1 P2 P3 * * @@ -62448,7 +61862,7 @@ __5: // left holding a NULL. It is an error for register ranges // P1..P1+P3-1 and P2..P2+P3-1 to overlap. It is an error // for P3 to be less than 1. - case 76: + case OP_Move: goto __26 // Opcode: Copy P1 P2 P3 * * @@ -62458,7 +61872,7 @@ __5: // // This instruction makes a deep copy of the value. A duplicate // is made of any string or blob constant. See also OP_SCopy. - case 77: + case OP_Copy: goto __27 // Opcode: SCopy P1 P2 * * * @@ -62473,7 +61887,7 @@ __5: // Thus the program must guarantee that the original will not change // during the lifetime of the copy. Use OP_Copy to make a complete // copy. - case 78: + case OP_SCopy: goto __28 // Opcode: IntCopy P1 P2 * * * @@ -62483,7 +61897,7 @@ __5: // // This is an optimized version of SCopy that works only for integer // values. - case 79: + case OP_IntCopy: goto __29 // Opcode: ResultRow P1 P2 * * * @@ -62494,7 +61908,7 @@ __5: // with an SQLITE_ROW return code and it sets up the sqlite3_stmt // structure to provide access to the r(P1)..r(P1+P2-1) values as // the result row. - case 80: + case OP_ResultRow: goto __30 // Opcode: Concat P1 P2 P3 * * @@ -62509,7 +61923,7 @@ __5: // It is illegal for P1 and P3 to be the same register. Sometimes, // if P3 is the same register as P2, the implementation is able // to avoid a memcpy(). - case 110: + case OP_Concat: goto __31 // Opcode: Add P1 P2 P3 * * @@ -62545,15 +61959,15 @@ __5: // register P1 and store the result in register P3. // If the value in register P1 is zero the result is NULL. // If either operand is NULL, the result is NULL. - case 105: + case OP_Add: goto __32 // same as TK_PLUS, in1, in2, out3 - case 106: + case OP_Subtract: goto __33 // same as TK_MINUS, in1, in2, out3 - case 107: + case OP_Multiply: goto __34 // same as TK_STAR, in1, in2, out3 - case 108: + case OP_Divide: goto __35 // same as TK_SLASH, in1, in2, out3 - case 109: + case OP_Remainder: goto __36 // Opcode: CollSeq P1 * * P4 @@ -62570,7 +61984,7 @@ __5: // The interface used by the implementation of the aforementioned functions // to retrieve the collation sequence set by this opcode is not available // publicly. Only built-in functions have access to this feature. - case 81: + case OP_CollSeq: goto __37 // Opcode: BitAnd P1 P2 P3 * * @@ -62599,13 +62013,13 @@ __5: // number of bits specified by the integer in register P1. // Store the result in register P3. // If either input is NULL, the result is NULL. - case 101: + case OP_BitAnd: goto __38 // same as TK_BITAND, in1, in2, out3 - case 102: + case OP_BitOr: goto __39 // same as TK_BITOR, in1, in2, out3 - case 103: + case OP_ShiftLeft: goto __40 // same as TK_LSHIFT, in1, in2, out3 - case 104: + case OP_ShiftRight: goto __41 // Opcode: AddImm P1 P2 * * * @@ -62615,7 +62029,7 @@ __5: // The result is always an integer. // // To force any register to be an integer, just add 0. - case 82: + case OP_AddImm: goto __42 // Opcode: MustBeInt P1 P2 * * * @@ -62624,7 +62038,7 @@ __5: // in P1 is not an integer and cannot be converted into an integer // without data loss, then jump immediately to P2, or if P2==0 // raise an SQLITE_MISMATCH exception. - case 15: + case OP_MustBeInt: goto __43 // Opcode: RealAffinity P1 * * * * @@ -62635,7 +62049,7 @@ __5: // has REAL affinity. Such column values may still be stored as // integers, for space efficiency, but after extraction we want them // to have only a real value. - case 83: + case OP_RealAffinity: goto __44 // Opcode: Cast P1 P2 * * * @@ -62652,7 +62066,7 @@ __5: // // // A NULL value is not changed by this routine. It remains NULL. - case 84: + case OP_Cast: goto __45 // Opcode: Eq P1 P2 P3 P4 P5 @@ -62745,17 +62159,17 @@ __5: // This works just like the Lt opcode except that the jump is taken if // the content of register P3 is greater than or equal to the content of // register P1. See the Lt opcode for additional information. - case 53: + case OP_Eq: goto __46 // same as TK_EQ, jump, in1, in3 - case 52: + case OP_Ne: goto __47 // same as TK_NE, jump, in1, in3 - case 56: + case OP_Lt: goto __48 // same as TK_LT, jump, in1, in3 - case 55: + case OP_Le: goto __49 // same as TK_LE, jump, in1, in3 - case 54: + case OP_Gt: goto __50 // same as TK_GT, jump, in1, in3 - case 57: + case OP_Ge: goto __51 // Opcode: ElseNotEq * P2 * * * @@ -62770,7 +62184,7 @@ __5: // prior OP_Lt or OP_Gt would have been NULL or false (0), then then // jump to P2. If the result of an OP_Eq comparison on the two previous // operands would have been true (1), then fall through. - case 58: + case OP_ElseNotEq: goto __52 // Opcode: Permutation * * * P4 * @@ -62784,7 +62198,7 @@ __5: // // The first integer in the P4 integer array is the length of the array // and does not become part of the permutation. - case 85: + case OP_Permutation: goto __53 // Opcode: Compare P1 P2 P3 P4 P5 @@ -62806,7 +62220,7 @@ __5: // The comparison is a sort comparison, so NULLs compare equal, // NULLs are less than numbers, numbers are less than strings, // and strings are less than blobs. - case 86: + case OP_Compare: goto __54 // Opcode: Jump P1 P2 P3 * * @@ -62814,7 +62228,7 @@ __5: // Jump to the instruction at address P1, P2, or P3 depending on whether // in the most recent OP_Compare instruction the P1 vector was less than // equal to, or greater than the P2 vector, respectively. - case 16: + case OP_Jump: goto __55 // Opcode: And P1 P2 P3 * * @@ -62835,9 +62249,9 @@ __5: // If either P1 or P2 is nonzero (true) then the result is 1 (true) // even if the other input is NULL. A NULL and false or two NULLs // give a NULL output. - case 44: + case OP_And: goto __56 // same as TK_AND, in1, in2, out3 - case 43: + case OP_Or: goto __57 // Opcode: IsTrue P1 P2 P3 P4 * @@ -62859,7 +62273,7 @@ __5: //
  • If P3==0 and P4==1 then r[P2] := r[P1] IS NOT TRUE //
  • If P3==1 and P4==0 then r[P2] := r[P1] IS NOT FALSE // - case 87: + case OP_IsTrue: goto __58 // Opcode: Not P1 P2 * * * @@ -62868,7 +62282,7 @@ __5: // Interpret the value in register P1 as a boolean value. Store the // boolean complement in register P2. If the value in register P1 is // NULL, then a NULL is stored in P2. - case 19: + case OP_Not: goto __59 // Opcode: BitNot P1 P2 * * * @@ -62877,7 +62291,7 @@ __5: // Interpret the content of register P1 as an integer. Store the // ones-complement of the P1 value into register P2. If P1 holds // a NULL then store a NULL in P2. - case 112: + case OP_BitNot: goto __60 // Opcode: Once P1 P2 * * * @@ -62896,7 +62310,7 @@ __5: // whether or not the jump should be taken. The bitmask is necessary // because the self-altering code trick does not work for recursive // triggers. - case 17: + case OP_Once: goto __61 // Opcode: If P1 P2 P3 * * @@ -62904,7 +62318,7 @@ __5: // Jump to P2 if the value in register P1 is true. The value // is considered true if it is numeric and non-zero. If the value // in P1 is NULL then take the jump if and only if P3 is non-zero. - case 18: + case OP_If: goto __62 // Opcode: IfNot P1 P2 P3 * * @@ -62912,21 +62326,21 @@ __5: // Jump to P2 if the value in register P1 is False. The value // is considered false if it has a numeric value of zero. If the value // in P1 is NULL then take the jump if and only if P3 is non-zero. - case 20: + case OP_IfNot: goto __63 // Opcode: IsNull P1 P2 * * * // Synopsis: if r[P1]==NULL goto P2 // // Jump to P2 if the value in register P1 is NULL. - case 50: + case OP_IsNull: goto __64 // Opcode: NotNull P1 P2 * * * // Synopsis: if r[P1]!=NULL goto P2 // // Jump to P2 if the value in register P1 is not NULL. - case 51: + case OP_NotNull: goto __65 // Opcode: IfNullRow P1 P2 P3 * * @@ -62936,7 +62350,7 @@ __5: // If it is, then set register P3 to NULL and jump immediately to P2. // If P1 is not on a NULL row, then fall through without making any // changes. - case 21: + case OP_IfNullRow: goto __66 // Opcode: Offset P1 P2 P3 * * @@ -62953,7 +62367,7 @@ __5: // // This opcode is only available if SQLite is compiled with the // -DSQLITE_ENABLE_OFFSET_SQL_FUNC option. - case 88: + case OP_Offset: goto __67 // Opcode: Column P1 P2 P3 P4 P5 @@ -62975,7 +62389,7 @@ __5: // the result is guaranteed to only be used as the argument of a length() // or typeof() function, respectively. The loading of large blobs can be // skipped for length() and all content loading can be skipped for typeof(). - case 89: + case OP_Column: goto __68 // Opcode: Affinity P1 P2 * P4 * @@ -62986,7 +62400,7 @@ __5: // P4 is a string that is P2 characters long. The N-th character of the // string indicates the column affinity that should be used for the N-th // memory cell in the range. - case 90: + case OP_Affinity: goto __69 // Opcode: MakeRecord P1 P2 P3 P4 * @@ -63015,7 +62429,7 @@ __5: // OPFLAG_NOCHNG_MAGIC if the OP_MakeRecord opcode is allowed to // accept no-change records with serial_type 10. This value is // only used inside an assert() and does not affect the end result. - case 91: + case OP_MakeRecord: goto __70 // Opcode: Count P1 P2 p3 * * @@ -63027,7 +62441,7 @@ __5: // If P3==0, then an exact count is obtained, which involves visiting // every btree page of the table. But if P3 is non-zero, an estimate // is returned based on the current cursor position. - case 92: + case OP_Count: goto __71 // Opcode: Savepoint P1 * * P4 * @@ -63036,7 +62450,7 @@ __5: // on the value of P1. To open a new savepoint set P1==0 (SAVEPOINT_BEGIN). // To release (commit) an existing savepoint set P1==1 (SAVEPOINT_RELEASE). // To rollback an existing savepoint set P1==2 (SAVEPOINT_ROLLBACK). - case 0: + case OP_Savepoint: goto __72 // Opcode: AutoCommit P1 P2 * * * @@ -63047,7 +62461,7 @@ __5: // there are active writing VMs or active VMs that use shared cache. // // This instruction causes the VM to halt. - case 1: + case OP_AutoCommit: goto __73 // Opcode: Transaction P1 P2 P3 P4 P5 @@ -63083,7 +62497,7 @@ __5: // generation counter, then an SQLITE_SCHEMA error is raised and execution // halts. The sqlite3_step() wrapper function might then reprepare the // statement and rerun it from the beginning. - case 2: + case OP_Transaction: goto __74 // Opcode: ReadCookie P1 P2 P3 * * @@ -63097,7 +62511,7 @@ __5: // There must be a read-lock on the database (either a transaction // must be started or there must be an open cursor) before // executing this instruction. - case 93: + case OP_ReadCookie: goto __75 // Opcode: SetCookie P1 P2 P3 * P5 @@ -63114,7 +62528,7 @@ __5: // schema version is set to P3-P5. The "PRAGMA schema_version=N" statement // has P5 set to 1, so that the internal schema version will be different // from the database schema version, resulting in a schema reset. - case 94: + case OP_SetCookie: goto __76 // Opcode: OpenRead P1 P2 P3 P4 P5 @@ -63198,13 +62612,13 @@ __5: // in read/write mode. // // See also: OP_OpenRead, OP_ReopenIdx - case 95: + case OP_ReopenIdx: goto __77 // If the cursor is not currently open or is open on a different // index, then fall through into OP_OpenRead to force a reopen - case 96: + case OP_OpenRead: goto __78 - case 97: + case OP_OpenWrite: goto __79 // Opcode: OpenDup P1 P2 * * * @@ -63214,7 +62628,7 @@ __5: // opcode. Only ephemeral cursors may be duplicated. // // Duplicate ephemeral cursors are used for self-joins of materialized views. - case 98: + case OP_OpenDup: goto __80 // Opcode: OpenEphemeral P1 P2 * P4 P5 @@ -63244,9 +62658,9 @@ __5: // different name to distinguish its use. Tables created using // by this opcode will be used for automatically created transient // indices in joins. - case 99: + case OP_OpenAutoindex: goto __81 - case 100: + case OP_OpenEphemeral: goto __82 // Opcode: SorterOpen P1 P2 P3 P4 * @@ -63258,7 +62672,7 @@ __5: // If argument P3 is non-zero, then it indicates that the sorter may // assume that a stable sort considering the first P3 fields of each // key is sufficient to produce the required results. - case 111: + case OP_SorterOpen: goto __83 // Opcode: SequenceTest P1 P2 * * * @@ -63267,7 +62681,7 @@ __5: // P1 is a sorter cursor. If the sequence counter is currently zero, jump // to P2. Regardless of whether or not the jump is taken, increment the // the sequence value. - case 113: + case OP_SequenceTest: goto __84 // Opcode: OpenPseudo P1 P2 P3 * * @@ -63285,14 +62699,14 @@ __5: // // P3 is the number of fields in the records that will be stored by // the pseudo-table. - case 114: + case OP_OpenPseudo: goto __85 // Opcode: Close P1 * * * * // // Close a cursor previously opened as P1. If P1 is not // currently open, this instruction is a no-op. - case 116: + case OP_Close: goto __86 // Opcode: SeekGE P1 P2 P3 P4 * @@ -63381,13 +62795,13 @@ __5: // is an equality search. // // See also: Found, NotFound, SeekGt, SeekGe, SeekLt - case 22: + case OP_SeekLT: goto __87 // jump, in3, group - case 23: + case OP_SeekLE: goto __88 // jump, in3, group - case 24: + case OP_SeekGE: goto __89 // jump, in3, group - case 25: + case OP_SeekGT: goto __90 // Opcode: SeekHit P1 P2 * * * @@ -63398,14 +62812,14 @@ __5: // // P1 must be a valid b-tree cursor. P2 must be a boolean value, // either 0 or 1. - case 118: + case OP_SeekHit: goto __91 // Opcode: IfNotOpen P1 P2 * * * // Synopsis: if( !csr[P1] ) goto P2 // // If cursor P1 is not open, jump to instruction P2. Otherwise, fall through. - case 26: + case OP_IfNotOpen: goto __92 // Opcode: Found P1 P2 P3 P4 * @@ -63490,13 +62904,13 @@ __5: // opcodes do not work after this operation. // // See also: NotFound, Found, NotExists - case 27: + case OP_IfNoHope: goto __93 - case 28: + case OP_NoConflict: goto __94 // jump, in3 - case 29: + case OP_NotFound: goto __95 // jump, in3 - case 30: + case OP_Found: goto __96 // Opcode: SeekRowid P1 P2 P3 * * @@ -63544,9 +62958,9 @@ __5: // not work following this opcode. // // See also: Found, NotFound, NoConflict, SeekRowid - case 31: + case OP_SeekRowid: goto __97 - case 32: + case OP_NotExists: goto __98 // Opcode: Sequence P1 P2 * * * @@ -63556,7 +62970,7 @@ __5: // Write the sequence number into register P2. // The sequence number on the cursor is incremented after this // instruction. - case 119: + case OP_Sequence: goto __99 // Opcode: NewRowid P1 P2 P3 * * @@ -63573,7 +62987,7 @@ __5: // an SQLITE_FULL error is generated. The P3 register is updated with the ' // generated record number. This P3 mechanism is used to help implement the // AUTOINCREMENT feature. - case 120: + case OP_NewRowid: goto __100 // Opcode: Insert P1 P2 P3 P4 P5 @@ -63612,7 +63026,7 @@ __5: // // This instruction only works on tables. The equivalent instruction // for indices is OP_IdxInsert. - case 121: + case OP_Insert: goto __101 // Opcode: Delete P1 P2 P3 P4 P5 @@ -63649,7 +63063,7 @@ __5: // If the OPFLAG_ISUPDATE flag is set in P2, then P3 contains the address // of the memory cell that contains the value that the rowid of the row will // be set to by the update. - case 122: + case OP_Delete: goto __102 // Opcode: ResetCount * * * * * // @@ -63657,7 +63071,7 @@ __5: // change counter (returned by subsequent calls to sqlite3_changes()). // Then the VMs internal change counter resets to 0. // This is used by trigger programs. - case 123: + case OP_ResetCount: goto __103 // Opcode: SorterCompare P1 P2 P3 P4 @@ -63674,7 +63088,7 @@ __5: // // Fall through to next instruction if the two records compare equal to // each other. Jump to P2 if they are different. - case 124: + case OP_SorterCompare: goto __104 // Opcode: SorterData P1 P2 P3 * * @@ -63688,7 +63102,7 @@ __5: // OpenPseudo. That pseudo-table cursor is the one that is identified by // parameter P3. Clearing the P3 column cache as part of this opcode saves // us from having to issue a separate NullRow instruction to clear that cache. - case 125: + case OP_SorterData: goto __105 // Opcode: RowData P1 P2 P3 * * @@ -63718,7 +63132,7 @@ __5: // in OP_Result and any OP_Result will invalidate the P2 register content. // The P2 register content is invalidated by opcodes like OP_Function or // by any use of another cursor pointing to the same table. - case 126: + case OP_RowData: goto __106 // Opcode: Rowid P1 P2 * * * @@ -63730,7 +63144,7 @@ __5: // P1 can be either an ordinary table or a virtual table. There used to // be a separate OP_VRowid opcode for use with virtual tables, but this // one opcode now works for both table types. - case 127: + case OP_Rowid: goto __107 // Opcode: NullRow P1 * * * * @@ -63738,7 +63152,7 @@ __5: // Move the cursor P1 to a null row. Any OP_Column operations // that occur while the cursor is on the null row will always // write a NULL. - case 128: + case OP_NullRow: goto __108 // Opcode: SeekEnd P1 * * * * @@ -63761,16 +63175,16 @@ __5: // This opcode leaves the cursor configured to move in reverse order, // from the end toward the beginning. In other words, the cursor is // configured to use Prev, not Next. - case 129: + case OP_SeekEnd: goto __109 - case 33: + case OP_Last: goto __110 // Opcode: IfSmaller P1 P2 P3 * * // // Estimate the number of rows in the table P1. Jump to P2 if that // estimate is less than approximately 2**(0.1*P3). - case 34: + case OP_IfSmaller: goto __111 // Opcode: SorterSort P1 P2 * * * @@ -63792,9 +63206,9 @@ __5: // rewinding so that the global variable will be incremented and // regression tests can determine whether or not the optimizer is // correctly optimizing out sorts. - case 35: + case OP_SorterSort: goto __112 // jump - case 36: + case OP_Sort: goto __113 // Opcode: Rewind P1 P2 * * * // @@ -63807,7 +63221,7 @@ __5: // This opcode leaves the cursor configured to move in forward order, // from the beginning toward the end. In other words, the cursor is // configured to use Next, not Prev. - case 37: + case OP_Rewind: goto __114 // Opcode: Next P1 P2 P3 P4 P5 @@ -63867,11 +63281,11 @@ __5: // sorter object for which the OP_SorterSort opcode has been // invoked. This opcode advances the cursor to the next sorted // record, or jumps to P2 if there are no more sorted records. - case 3: + case OP_SorterNext: goto __115 - case 4: + case OP_Prev: goto __116 // jump - case 5: + case OP_Next: goto __117 // Opcode: IdxInsert P1 P2 P3 P4 P5 @@ -63901,7 +63315,7 @@ __5: // // This instruction only works for indices. The equivalent instruction // for tables is OP_Insert. - case 130: + case OP_IdxInsert: goto __118 // Opcode: SorterInsert P1 P2 * * * @@ -63910,7 +63324,7 @@ __5: // Register P2 holds an SQL index key made using the // MakeRecord instructions. This opcode writes that key // into the sorter P1. Data for the entry is nil. - case 131: + case OP_SorterInsert: goto __119 // Opcode: IdxDelete P1 P2 P3 * P5 @@ -63926,7 +63340,7 @@ __5: // or deleted is not found. For some uses of IdxDelete // (example: the EXCEPT operator) it does not matter that no matching // entry is found. For those cases, P5 is zero. - case 132: + case OP_IdxDelete: goto __120 // Opcode: DeferredSeek P1 * P3 P4 * @@ -63955,9 +63369,9 @@ __5: // the rowid of the table entry to which this index entry points. // // See also: Rowid, MakeRecord. - case 133: + case OP_DeferredSeek: goto __121 - case 134: + case OP_IdxRowid: goto __122 // Opcode: FinishSeek P1 * * * * @@ -63965,7 +63379,7 @@ __5: // If cursor P1 was previously moved via OP_DeferredSeek, complete that // seek operation now, without further delay. If the cursor seek has // already occurred, this instruction is a no-op. - case 135: + case OP_FinishSeek: goto __123 // Opcode: IdxGE P1 P2 P3 P4 P5 @@ -64008,13 +63422,13 @@ __5: // // If the P1 index entry is less than or equal to the key value then jump // to P2. Otherwise fall through to the next instruction. - case 38: + case OP_IdxLE: goto __124 // jump - case 39: + case OP_IdxGT: goto __125 // jump - case 40: + case OP_IdxLT: goto __126 // jump - case 41: + case OP_IdxGE: goto __127 // Opcode: Destroy P1 P2 P3 * * @@ -64043,7 +63457,7 @@ __5: // and non-autovacuum modes. // // See also: Clear - case 136: + case OP_Destroy: goto __128 // Opcode: Clear P1 P2 P3 @@ -64063,7 +63477,7 @@ __5: // also incremented by the number of rows in the table being cleared. // // See also: Destroy - case 137: + case OP_Clear: goto __129 // Opcode: ResetSorter P1 * * * * @@ -64073,7 +63487,7 @@ __5: // // This opcode only works for cursors used for sorting and // opened with OP_OpenEphemeral or OP_SorterOpen. - case 138: + case OP_ResetSorter: goto __130 // Opcode: CreateBtree P1 P2 P3 * * @@ -64084,13 +63498,13 @@ __5: // P1>1. The P3 argument must be 1 (BTREE_INTKEY) for a rowid table // it must be 2 (BTREE_BLOBKEY) for an index or WITHOUT ROWID table. // The root page number of the new b-tree is stored in register P2. - case 139: + case OP_CreateBtree: goto __131 // Opcode: SqlExec * * * P4 * // // Run the SQL statement or statements specified in the P4 string. - case 140: + case OP_SqlExec: goto __132 // Opcode: ParseSchema P1 * * P4 * @@ -64101,7 +63515,7 @@ __5: // // This opcode invokes the parser to create a new virtual machine, // then runs the new virtual machine. It is thus a re-entrant opcode. - case 141: + case OP_ParseSchema: goto __133 // Opcode: LoadAnalysis P1 * * * * @@ -64109,7 +63523,7 @@ __5: // Read the sqlite_stat1 table for database P1 and load the content // of that table into the internal index hash table. This will cause // the analysis to be used when preparing all subsequent queries. - case 142: + case OP_LoadAnalysis: goto __134 // Opcode: DropTable P1 * * P4 * @@ -64119,7 +63533,7 @@ __5: // is dropped from disk (using the Destroy opcode) in order to keep // the internal representation of the // schema consistent with what is on disk. - case 143: + case OP_DropTable: goto __135 // Opcode: DropIndex P1 * * P4 * @@ -64129,7 +63543,7 @@ __5: // is dropped from disk (using the Destroy opcode) // in order to keep the internal representation of the // schema consistent with what is on disk. - case 144: + case OP_DropIndex: goto __136 // Opcode: DropTrigger P1 * * P4 * @@ -64139,7 +63553,7 @@ __5: // is dropped from disk (using the Destroy opcode) in order to keep // the internal representation of the // schema consistent with what is on disk. - case 145: + case OP_DropTrigger: goto __137 // Opcode: IntegrityCk P1 P2 P3 P4 P5 @@ -64160,7 +63574,7 @@ __5: // file, not the main database file. // // This opcode is used to implement the integrity_check pragma. - case 146: + case OP_IntegrityCk: goto __138 // Opcode: RowSetAdd P1 P2 * * * @@ -64170,7 +63584,7 @@ __5: // held in register P1. // // An assertion fails if P2 is not an integer. - case 147: + case OP_RowSetAdd: goto __139 // Opcode: RowSetRead P1 P2 P3 * * @@ -64180,7 +63594,7 @@ __5: // and put that value into register P3. // Or, if RowSet object P1 is initially empty, leave P3 // unchanged and jump to instruction P2. - case 42: + case OP_RowSetRead: goto __140 // Opcode: RowSetTest P1 P2 P3 P4 @@ -64205,7 +63619,7 @@ __5: // inserted, there is no need to search to see if the same value was // previously inserted as part of set X (only if it was previously // inserted as part of some other set). - case 45: + case OP_RowSetTest: goto __141 // Opcode: Program P1 P2 P3 P4 P5 @@ -64222,7 +63636,7 @@ __5: // P4 is a pointer to the VM containing the trigger program. // // If P5 is non-zero, then recursive program invocation is enabled. - case 46: + case OP_Program: goto __142 // Opcode: Param P1 P2 * * * @@ -64236,7 +63650,7 @@ __5: // The address of the cell in the parent frame is determined by adding // the value of the P1 argument to the value of the P1 argument to the // calling OP_Program instruction. - case 148: + case OP_Param: goto __143 // Opcode: FkCounter P1 P2 * * * @@ -64246,7 +63660,7 @@ __5: // If P1 is non-zero, the database constraint counter is incremented // (deferred foreign key constraints). Otherwise, if P1 is zero, the // statement counter is incremented (immediate foreign key constraints). - case 149: + case OP_FkCounter: goto __144 // Opcode: FkIfZero P1 P2 * * * @@ -64260,7 +63674,7 @@ __5: // is zero (the one that counts deferred constraint violations). If P1 is // zero, the jump is taken if the statement constraint-counter is zero // (immediate foreign key constraint violations). - case 47: + case OP_FkIfZero: goto __145 // Opcode: MemMax P1 P2 * * * @@ -64273,7 +63687,7 @@ __5: // // This instruction throws an error if the memory cell is not initially // an integer. - case 151: + case OP_MemMax: goto __146 // Opcode: IfPos P1 P2 P3 * * @@ -64285,7 +63699,7 @@ __5: // // If the initial value of register P1 is less than 1, then the // value is unchanged and control passes through to the next instruction. - case 48: + case OP_IfPos: goto __147 // Opcode: OffsetLimit P1 P2 P3 * * @@ -64305,7 +63719,7 @@ __5: // and r[P2] is set to -1. // // Otherwise, r[P2] is set to the sum of r[P1] and r[P3]. - case 152: + case OP_OffsetLimit: goto __148 // Opcode: IfNotZero P1 P2 * * * @@ -64315,7 +63729,7 @@ __5: // initially greater than zero, then decrement the value in register P1. // If it is non-zero (negative or positive) and then also jump to P2. // If register P1 is initially zero, leave it unchanged and fall through. - case 49: + case OP_IfNotZero: goto __149 // Opcode: DecrJumpZero P1 P2 * * * @@ -64323,7 +63737,7 @@ __5: // // Register P1 must hold an integer. Decrement the value in P1 // and jump to P2 if the new value is exactly zero. - case 59: + case OP_DecrJumpZero: goto __150 // Opcode: AggStep * P2 P3 P4 P5 @@ -64362,11 +63776,11 @@ __5: // the opcode is changed. In this way, the initialization of the // sqlite3_context only happens once, instead of on each call to the // step function. - case 153: + case OP_AggInverse: goto __151 - case 154: + case OP_AggStep: goto __152 - case 155: + case OP_AggStep1: goto __153 // Opcode: AggFinal P1 P2 * P4 * @@ -64393,9 +63807,9 @@ __5: // functions that can take varying numbers of arguments. The // P4 argument is only needed for the case where // the step function was not previously called. - case 156: + case OP_AggValue: goto __154 - case 157: + case OP_AggFinal: goto __155 // Opcode: Checkpoint P1 P2 P3 * * @@ -64408,7 +63822,7 @@ __5: // in the WAL that have been checkpointed after the checkpoint // completes into mem[P3+2]. However on an error, mem[P3+1] and // mem[P3+2] are initialized to -1. - case 6: + case OP_Checkpoint: goto __156 // Opcode: JournalMode P1 P2 P3 * * @@ -64421,7 +63835,7 @@ __5: // If changing into or out of WAL mode the procedure is more complicated. // // Write a string containing the final journal-mode to register P2. - case 7: + case OP_JournalMode: goto __157 // Opcode: Vacuum P1 P2 * * * @@ -64432,7 +63846,7 @@ __5: // If P2 is not zero, then it is a register holding a string which is // the file into which the result of vacuum should be written. When // P2 is zero, the vacuum overwrites the original database. - case 8: + case OP_Vacuum: goto __158 // Opcode: IncrVacuum P1 P2 * * * @@ -64440,7 +63854,7 @@ __5: // Perform a single step of the incremental vacuum procedure on // the P1 database. If the vacuum has finished, jump to instruction // P2. Otherwise, fall through to the next instruction. - case 60: + case OP_IncrVacuum: goto __159 // Opcode: Expire P1 P2 * * * @@ -64458,21 +63872,21 @@ __5: // The P2==1 case occurs when a CREATE INDEX or similar schema change happens // that might help the statement run faster but which does not affect the // correctness of operation. - case 158: + case OP_Expire: goto __160 // Opcode: CursorLock P1 * * * * // // Lock the btree to which cursor P1 is pointing so that the btree cannot be // written by an other cursor. - case 159: + case OP_CursorLock: goto __161 // Opcode: CursorUnlock P1 * * * * // // Unlock the btree to which cursor P1 is pointing so that it can be // written by other cursors. - case 160: + case OP_CursorUnlock: goto __162 // Opcode: TableLock P1 P2 P3 P4 * @@ -64489,7 +63903,7 @@ __5: // // P4 contains a pointer to the name of the table being locked. This is only // used to generate an error message if the lock cannot be obtained. - case 161: + case OP_TableLock: goto __163 // Opcode: VBegin * * * P4 * @@ -64500,21 +63914,21 @@ __5: // Also, whether or not P4 is set, check that this is not being called from // within a callback to a virtual table xSync() method. If it is, the error // code will be set to SQLITE_LOCKED. - case 162: + case OP_VBegin: goto __164 // Opcode: VCreate P1 P2 * * * // // P2 is a register that holds the name of a virtual table in database // P1. Call the xCreate method for that table. - case 163: + case OP_VCreate: goto __165 // Opcode: VDestroy P1 * * P4 * // // P4 is the name of a virtual table in database P1. Call the xDestroy method // of that table. - case 164: + case OP_VDestroy: goto __166 // Opcode: VOpen P1 * * P4 * @@ -64522,7 +63936,7 @@ __5: // P4 is a pointer to a virtual table object, an sqlite3_vtab structure. // P1 is a cursor number. This opcode opens a cursor to the virtual // table and stores that cursor in P1. - case 165: + case OP_VOpen: goto __167 // Opcode: VFilter P1 P2 P3 P4 * @@ -64543,7 +63957,7 @@ __5: // xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter. // // A jump is made to P2 if the result set after filtering would be empty. - case 9: + case OP_VFilter: goto __168 // Opcode: VColumn P1 P2 P3 * P5 @@ -64559,7 +63973,7 @@ __5: // table implementation. The P5 column might also contain other // bits (OPFLAG_LENGTHARG or OPFLAG_TYPEOFARG) but those bits are // unused by OP_VColumn. - case 166: + case OP_VColumn: goto __169 // Opcode: VNext P1 P2 * * * @@ -64567,7 +63981,7 @@ __5: // Advance virtual table P1 to the next row in its result set and // jump to instruction P2. Or, if the virtual table has reached // the end of its result set, then fall through to the next instruction. - case 61: + case OP_VNext: goto __170 // Opcode: VRename P1 * * P4 * @@ -64575,7 +63989,7 @@ __5: // P4 is a pointer to a virtual table object, an sqlite3_vtab structure. // This opcode invokes the corresponding xRename method. The value // in register P1 is passed as the zName argument to the xRename method. - case 167: + case OP_VRename: goto __171 // Opcode: VUpdate P1 P2 P3 P4 P5 @@ -64604,13 +64018,13 @@ __5: // // P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to // apply in the case of a constraint failure on an insert or update. - case 10: + case OP_VUpdate: goto __172 // Opcode: Pagecount P1 P2 * * * // // Write the current number of pages in database P1 to memory cell P2. - case 168: + case OP_Pagecount: goto __173 // Opcode: MaxPgcnt P1 P2 P3 * * @@ -64620,7 +64034,7 @@ __5: // do not change the maximum page count value if P3==0. // // Store the maximum page count after the change in register P2. - case 169: + case OP_MaxPgcnt: goto __174 // Opcode: Function P1 P2 P3 P4 * @@ -64667,9 +64081,9 @@ __5: // if they were, they throw an error. // // See also: AggStep, AggFinal, Function - case 63: + case OP_PureFunc: goto __175 // group - case 64: + case OP_Function: goto __176 // Opcode: Trace P1 P2 * P4 * @@ -64695,9 +64109,9 @@ __5: // // If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT // error is encountered. - case 170: + case OP_Trace: goto __177 - case 62: + case OP_Init: goto __178 // Opcode: Noop * * * * * @@ -64797,7 +64211,7 @@ __181: goto __183 } nProgressLimit = (uint64(0xffffffff) | (U64((uint64(0xffffffff))) << 32)) - rc = 9 + rc = SQLITE_INTERRUPT goto abort_due_to_error __183: ; @@ -64815,7 +64229,7 @@ __10: // jump ; pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - (*Mem)(unsafe.Pointer(pIn1)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pIn1)).Fflags = MEM_Int *(*I64)(unsafe.Pointer(pIn1 /* &.u */)) = I64((int32((int64(pOp) - int64(aOp)) / 24))) // Most jump operations do a goto to this spot in order to update @@ -64832,7 +64246,7 @@ __11: // in1 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) pOp = (aOp + uintptr(*(*I64)(unsafe.Pointer(pIn1 /* &.u */)))*24) - (*Mem)(unsafe.Pointer(pIn1)).Fflags = U16(0x0080) + (*Mem)(unsafe.Pointer(pIn1)).Fflags = MEM_Undefined goto __8 // Opcode: InitCoroutine P1 P2 P3 * * @@ -64851,7 +64265,7 @@ __12: // jump pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) *(*I64)(unsafe.Pointer(pOut /* &.u */)) = (I64((*Op)(unsafe.Pointer(pOp)).Fp3 - 1)) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Int if !((*Op)(unsafe.Pointer(pOp)).Fp2 != 0) { goto __184 } @@ -64873,7 +64287,7 @@ __13: pCaller = (aOp + uintptr(*(*I64)(unsafe.Pointer(pIn1 /* &.u */)))*24) pOp = (aOp + uintptr(((*VdbeOp)(unsafe.Pointer(pCaller)).Fp2-1))*24) - (*Mem)(unsafe.Pointer(pIn1)).Fflags = U16(0x0080) + (*Mem)(unsafe.Pointer(pIn1)).Fflags = MEM_Undefined goto __8 // Opcode: Yield P1 P2 * * * @@ -64891,7 +64305,7 @@ __13: __14: pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - (*Mem)(unsafe.Pointer(pIn1)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pIn1)).Fflags = MEM_Int pcDest = int32(*(*I64)(unsafe.Pointer(pIn1 /* &.u */))) *(*I64)(unsafe.Pointer(pIn1 /* &.u */)) = I64((int32((int64(pOp) - int64(aOp)) / 24))) @@ -64907,14 +64321,12 @@ __14: // The P5 parameter should be 1. __15: // in3 pIn3 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn3)).Fflags) & 0x0001) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn3)).Fflags) & MEM_Null) == 0) { goto __185 } goto __8 __185: ; - // Fall through into OP_Halt - /* no break */ // Opcode: Halt P1 P2 * P4 P5 // @@ -64948,7 +64360,7 @@ __185: __16: pcx = (int32((int64(pOp) - int64(aOp)) / 24)) - if !(((*Op)(unsafe.Pointer(pOp)).Fp1 == 0) && ((*Vdbe)(unsafe.Pointer(p)).FpFrame != 0)) { + if !(((*Op)(unsafe.Pointer(pOp)).Fp1 == SQLITE_OK) && ((*Vdbe)(unsafe.Pointer(p)).FpFrame != 0)) { goto __186 } // Halt the sub-program. Return control to the parent frame. @@ -64957,7 +64369,7 @@ __16: (*Vdbe)(unsafe.Pointer(p)).FnFrame-- Xsqlite3VdbeSetChanges(tls, db, (*Vdbe)(unsafe.Pointer(p)).FnChange) pcx = Xsqlite3VdbeFrameRestore(tls, pFrame) - if !((*Op)(unsafe.Pointer(pOp)).Fp2 == 4) { + if !((*Op)(unsafe.Pointer(pOp)).Fp2 == OE_Ignore) { goto __187 } // Instruction pcx is the OP_Program that invoked the sub-program @@ -65002,18 +64414,18 @@ __188: ; rc = Xsqlite3VdbeHalt(tls, p) - if !(rc == 5) { + if !(rc == SQLITE_BUSY) { goto __192 } - (*Vdbe)(unsafe.Pointer(p)).Frc = 5 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_BUSY goto __193 __192: ; if (*Vdbe)(unsafe.Pointer(p)).Frc != 0 { - rc = 1 + rc = SQLITE_ERROR } else { - rc = 101 + rc = SQLITE_DONE } __193: ; @@ -65046,7 +64458,7 @@ __18: // out2 // Write that value into register P2. __19: // same as TK_FLOAT, out2 pOut = out2Prerelease(tls, p, pOp) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0008) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Real *(*float64)(unsafe.Pointer(pOut /* &.u */)) = *(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)))) goto __8 @@ -65063,10 +64475,10 @@ __20: // same as TK_STRING, out2 pOut = out2Prerelease(tls, p, pOp) (*Op)(unsafe.Pointer(pOp)).Fp1 = Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */))) - if !(int32(encoding) != 1) { + if !(int32(encoding) != SQLITE_UTF8) { goto __194 } - rc = Xsqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)), -1, uint8(1), uintptr(0)) + rc = Xsqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)), -1, SQLITE_UTF8, uintptr(0)) if !(rc != 0) { goto __195 @@ -65074,7 +64486,7 @@ __20: // same as TK_STRING, out2 goto too_big __195: ; - if !(0 != Xsqlite3VdbeChangeEncoding(tls, pOut, int32(encoding))) { + if !(SQLITE_OK != Xsqlite3VdbeChangeEncoding(tls, pOut, int32(encoding))) { goto __196 } goto no_mem @@ -65082,7 +64494,7 @@ __196: ; (*Mem)(unsafe.Pointer(pOut)).FszMalloc = 0 - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((0x0800)) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((MEM_Static)) if !(int32((*Op)(unsafe.Pointer(pOp)).Fp4type) == (-7)) { goto __197 } @@ -65094,16 +64506,13 @@ __197: (*Op)(unsafe.Pointer(pOp)).Fp1 = (*Mem)(unsafe.Pointer(pOut)).Fn __194: ; - if !((*Op)(unsafe.Pointer(pOp)).Fp1 > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) { + if !((*Op)(unsafe.Pointer(pOp)).Fp1 > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) { goto __198 } goto too_big __198: ; - (*Op)(unsafe.Pointer(pOp)).Fopcode = U8(71) - - // Fall through to the next case, OP_String - /* no break */ + (*Op)(unsafe.Pointer(pOp)).Fopcode = OP_String // Opcode: String P1 P2 P3 P4 P5 // Synopsis: r[P2]='P4' (len=P1) @@ -65119,7 +64528,7 @@ __198: __21: // out2 ; pOut = out2Prerelease(tls, p, pOp) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((0x0002 | 0x0800) | 0x0200)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((MEM_Str | MEM_Static) | MEM_Term)) (*Mem)(unsafe.Pointer(pOut)).Fz = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) (*Mem)(unsafe.Pointer(pOut)).Fn = (*Op)(unsafe.Pointer(pOp)).Fp1 (*Mem)(unsafe.Pointer(pOut)).Fenc = encoding @@ -65143,9 +64552,9 @@ __22: (*Mem)(unsafe.Pointer(pOut)).Fflags = libc.AssignUint16(&nullFlag, func() uint16 { if (*Op)(unsafe.Pointer(pOp)).Fp1 != 0 { - return (uint16(0x0001 | 0x0100)) + return (uint16(MEM_Null | MEM_Cleared)) } - return uint16(0x0001) + return MEM_Null }()) (*Mem)(unsafe.Pointer(pOut)).Fn = 0 __199: @@ -65173,7 +64582,7 @@ __200: __23: ; pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer(pOut)).Fflags) & ^libc.Int32((0x0080 | 0x003f))) | 0x0001)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer(pOut)).Fflags) & libc.CplInt32((MEM_Undefined | MEM_AffMask))) | MEM_Null)) goto __8 // Opcode: Blob P1 P2 * P4 * @@ -65208,15 +64617,15 @@ __25: // Value being transferred __201: ; pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) - if !((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & (0x2000 | 0x0400)) != 0) { + if !((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0) { goto __202 } Xsqlite3VdbeMemSetNull(tls, pOut) __202: ; libc.Xmemcpy(tls, pOut, pVar, uint64((uintptr(0) + 24 /* &.zMalloc */))) - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32((0x0400 | 0x1000)))) - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((0x0800 | 0x0040)) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32((MEM_Dyn | MEM_Ephem)))) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((MEM_Static | MEM_FromBind)) goto __8 @@ -65240,7 +64649,7 @@ __203: ; Xsqlite3VdbeMemMove(tls, pOut, pIn1) - if !(((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & 0x1000) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0)) { + if !(((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & MEM_Ephem) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0)) { goto __206 } goto no_mem @@ -65277,8 +64686,8 @@ __207: goto __208 } - Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn1, 0x1000) - if !(((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & 0x1000) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0)) { + Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn1, MEM_Ephem) + if !(((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & MEM_Ephem) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0)) { goto __209 } goto no_mem @@ -65314,7 +64723,7 @@ __28: // out2 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) - Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn1, 0x1000) + Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn1, MEM_Ephem) goto __8 // Opcode: IntCopy P1 P2 * * * @@ -65345,7 +64754,7 @@ __30: // If this statement has violated immediate foreign key constraints, do // not return the number of rows modified. And do not RELEASE the statement // transaction. It needs to be rolled back. - if !(0 != (libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 0)))) { + if !(SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 0)))) { goto __211 } @@ -65368,7 +64777,7 @@ __211: // The statement transaction is never a top-level transaction. Hence // the RELEASE call below can never fail. - rc = Xsqlite3VdbeCloseStatement(tls, p, 1) + rc = Xsqlite3VdbeCloseStatement(tls, p, SAVEPOINT_RELEASE) // Invalidate all ephemeral cursor row caches (*Vdbe)(unsafe.Pointer(p)).FcacheCtr = (((*Vdbe)(unsafe.Pointer(p)).FcacheCtr + U32(2)) | U32(1)) @@ -65383,7 +64792,7 @@ __212: goto __214 } - if !(((int32((*Mem)(unsafe.Pointer((pMem + uintptr(i)*56))).Fflags) & 0x1000) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, (pMem+uintptr(i)*56)) != 0)) { + if !(((int32((*Mem)(unsafe.Pointer((pMem + uintptr(i)*56))).Fflags) & MEM_Ephem) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, (pMem+uintptr(i)*56)) != 0)) { goto __215 } goto no_mem @@ -65406,16 +64815,16 @@ __214: __216: ; - if !((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & 0x04) != 0) { + if !((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & SQLITE_TRACE_ROW) != 0) { goto __217 } - (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, uint32(0x04), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, uintptr(0)) + (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, SQLITE_TRACE_ROW, (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, uintptr(0)) __217: ; // Return SQLITE_ROW (*Vdbe)(unsafe.Pointer(p)).Fpc = ((int32((int64(pOp) - int64(aOp)) / 24)) + 1) - rc = 100 + rc = SQLITE_ROW goto vdbe_return // Opcode: Concat P1 P2 P3 * * @@ -65438,14 +64847,14 @@ __31: // Initial flags for P2 flags1 = (*Mem)(unsafe.Pointer(pIn1)).Fflags - if !(((int32(flags1) | int32((*Mem)(unsafe.Pointer(pIn2)).Fflags)) & 0x0001) != 0) { + if !(((int32(flags1) | int32((*Mem)(unsafe.Pointer(pIn2)).Fflags)) & MEM_Null) != 0) { goto __218 } Xsqlite3VdbeMemSetNull(tls, pOut) goto __8 __218: ; - if !((int32(flags1) & (0x0002 | 0x0010)) == 0) { + if !((int32(flags1) & (MEM_Str | MEM_Blob)) == 0) { goto __219 } if !(Xsqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(0)) != 0) { @@ -65454,10 +64863,10 @@ __218: goto no_mem __221: ; - flags1 = (U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32(0x0002))) + flags1 = (U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & libc.CplInt32(MEM_Str))) goto __220 __219: - if !((int32(flags1) & 0x4000) != 0) { + if !((int32(flags1) & MEM_Zero) != 0) { goto __222 } if !(Xsqlite3VdbeMemExpandBlob(tls, pIn1) != 0) { @@ -65466,13 +64875,13 @@ __219: goto no_mem __223: ; - flags1 = (U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32(0x0002))) + flags1 = (U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & libc.CplInt32(MEM_Str))) __222: ; __220: ; flags2 = (*Mem)(unsafe.Pointer(pIn2)).Fflags - if !((int32(flags2) & (0x0002 | 0x0010)) == 0) { + if !((int32(flags2) & (MEM_Str | MEM_Blob)) == 0) { goto __224 } if !(Xsqlite3VdbeMemStringify(tls, pIn2, encoding, uint8(0)) != 0) { @@ -65481,10 +64890,10 @@ __220: goto no_mem __226: ; - flags2 = (U16(int32((*Mem)(unsafe.Pointer(pIn2)).Fflags) & ^libc.Int32(0x0002))) + flags2 = (U16(int32((*Mem)(unsafe.Pointer(pIn2)).Fflags) & libc.CplInt32(MEM_Str))) goto __225 __224: - if !((int32(flags2) & 0x4000) != 0) { + if !((int32(flags2) & MEM_Zero) != 0) { goto __227 } if !(Xsqlite3VdbeMemExpandBlob(tls, pIn2) != 0) { @@ -65493,13 +64902,13 @@ __224: goto no_mem __228: ; - flags2 = (U16(int32((*Mem)(unsafe.Pointer(pIn2)).Fflags) & ^libc.Int32(0x0002))) + flags2 = (U16(int32((*Mem)(unsafe.Pointer(pIn2)).Fflags) & libc.CplInt32(MEM_Str))) __227: ; __225: ; nByte = (I64((*Mem)(unsafe.Pointer(pIn1)).Fn + (*Mem)(unsafe.Pointer(pIn2)).Fn)) - if !(nByte > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4)))) { + if !(nByte > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */))))) { goto __229 } goto too_big @@ -65511,7 +64920,7 @@ __229: goto no_mem __230: ; - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0002)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Str)) if !(pOut != pIn2) { goto __231 } @@ -65526,7 +64935,7 @@ __231: *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pOut)).Fz + uintptr(nByte))) = int8(0) *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pOut)).Fz + uintptr((nByte + int64(1))))) = int8(0) *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pOut)).Fz + uintptr((nByte + int64(2))))) = int8(0) - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((0x0200)) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((MEM_Term)) (*Mem)(unsafe.Pointer(pOut)).Fn = int32(nByte) (*Mem)(unsafe.Pointer(pOut)).Fenc = encoding @@ -65577,19 +64986,19 @@ __36: // Real value of right operand type2 = numericType(tls, pIn2) pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) flags = (U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) | int32((*Mem)(unsafe.Pointer(pIn2)).Fflags))) - if !(((int32(type1) & int32(type2)) & 0x0004) != 0) { + if !(((int32(type1) & int32(type2)) & MEM_Int) != 0) { goto __232 } iA = *(*I64)(unsafe.Pointer(pIn1 /* &.u */)) *(*I64)(unsafe.Pointer(bp + 176 /* iB */)) = *(*I64)(unsafe.Pointer(pIn2 /* &.u */)) switch int32((*Op)(unsafe.Pointer(pOp)).Fopcode) { - case 105: + case OP_Add: goto __235 - case 106: + case OP_Subtract: goto __236 - case 107: + case OP_Multiply: goto __237 - case 108: + case OP_Divide: goto __238 default: goto __239 @@ -65654,10 +65063,10 @@ __246: __234: ; *(*I64)(unsafe.Pointer(pOut /* &.u */)) = *(*I64)(unsafe.Pointer(bp + 176 /* iB */)) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) goto __233 __232: - if !((int32(flags) & 0x0001) != 0) { + if !((int32(flags) & MEM_Null) != 0) { goto __247 } goto arithmetic_result_is_null @@ -65667,13 +65076,13 @@ fp_math: rA = Xsqlite3VdbeRealValue(tls, pIn1) rB = Xsqlite3VdbeRealValue(tls, pIn2) switch int32((*Op)(unsafe.Pointer(pOp)).Fopcode) { - case 105: + case OP_Add: goto __250 - case 106: + case OP_Subtract: goto __251 - case 107: + case OP_Multiply: goto __252 - case 108: + case OP_Divide: goto __253 default: goto __254 @@ -65726,7 +65135,7 @@ __249: __258: ; *(*float64)(unsafe.Pointer(pOut /* &.u */)) = rB - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0008)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Real)) __248: ; __233: @@ -65795,7 +65204,7 @@ __41: pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) pIn2 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) - if !(((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) | int32((*Mem)(unsafe.Pointer(pIn2)).Fflags)) & 0x0001) != 0) { + if !(((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) | int32((*Mem)(unsafe.Pointer(pIn2)).Fflags)) & MEM_Null) != 0) { goto __260 } Xsqlite3VdbeMemSetNull(tls, pOut) @@ -65805,13 +65214,13 @@ __260: *(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) = Xsqlite3VdbeIntValue(tls, pIn2) iB1 = Xsqlite3VdbeIntValue(tls, pIn1) op = (*Op)(unsafe.Pointer(pOp)).Fopcode - if !(int32(op) == 101) { + if !(int32(op) == OP_BitAnd) { goto __261 } *(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) &= iB1 goto __262 __261: - if !(int32(op) == 102) { + if !(int32(op) == OP_BitOr) { goto __263 } *(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) |= iB1 @@ -65826,7 +65235,7 @@ __263: goto __266 } - op = (U8(((2 * 103) + 1) - int32(op))) + op = (U8(((2 * OP_ShiftLeft) + 1) - int32(op))) if iB1 > (int64(-64)) { iB1 = -iB1 } else { @@ -65838,7 +65247,7 @@ __266: if !(iB1 >= int64(64)) { goto __267 } - if (*(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) >= int64(0)) || (int32(op) == 103) { + if (*(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) >= int64(0)) || (int32(op) == OP_ShiftLeft) { *(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) = int64(0) } else { *(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) = int64(-1) @@ -65846,7 +65255,7 @@ __266: goto __268 __267: libc.Xmemcpy(tls, bp+184 /* &uA */, bp+192 /* &iA1 */, uint64(unsafe.Sizeof(U64(0)))) - if !(int32(op) == 103) { + if !(int32(op) == OP_ShiftLeft) { goto __269 } *(*U64)(unsafe.Pointer(bp + 184 /* uA */)) <<= iB1 @@ -65872,7 +65281,7 @@ __264: __262: ; *(*I64)(unsafe.Pointer(pOut /* &.u */)) = *(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) goto __8 // Opcode: AddImm P1 P2 * * * @@ -65897,18 +65306,18 @@ __42: // in1 // raise an SQLITE_MISMATCH exception. __43: // jump, in1 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0004) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Int) == 0) { goto __272 } - applyAffinity(tls, pIn1, int8(0x43), encoding) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0004) == 0) { + applyAffinity(tls, pIn1, SQLITE_AFF_NUMERIC, encoding) + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Int) == 0) { goto __273 } if !((*Op)(unsafe.Pointer(pOp)).Fp2 == 0) { goto __274 } - rc = 20 + rc = SQLITE_MISMATCH goto abort_due_to_error goto __275 __274: @@ -65920,7 +65329,7 @@ __273: __272: ; - (*Mem)(unsafe.Pointer(pIn1)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pIn1))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pIn1)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pIn1))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) goto __8 // Opcode: RealAffinity P1 * * * * @@ -65933,7 +65342,7 @@ __272: // to have only a real value. __44: // in1 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & (0x0004 | 0x0020)) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & (MEM_Int | MEM_IntReal)) != 0) { goto __276 } @@ -65963,7 +65372,7 @@ __45: // in1 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) rc = func() int32 { - if (int32((*Mem)(unsafe.Pointer((pIn1))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pIn1))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pIn1) } return 0 @@ -66085,26 +65494,26 @@ __51: // Copy of initial value of pIn3->flags pIn3 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) flags11 = (*Mem)(unsafe.Pointer(pIn1)).Fflags flags3 = (*Mem)(unsafe.Pointer(pIn3)).Fflags - if !(((int32(flags11) | int32(flags3)) & 0x0001) != 0) { + if !(((int32(flags11) | int32(flags3)) & MEM_Null) != 0) { goto __279 } // One or both operands are NULL - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x80) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_NULLEQ) != 0) { goto __281 } // If SQLITE_NULLEQ is set (which will only happen if the operator is // OP_Eq or OP_Ne) then take the jump or not depending on whether // or not both operands are null. - if !((((int32(flags11) & int32(flags3)) & 0x0001) != 0) && - ((int32(flags3) & 0x0100) == 0)) { + if !((((int32(flags11) & int32(flags3)) & MEM_Null) != 0) && + ((int32(flags3) & MEM_Cleared) == 0)) { goto __283 } res = 0 // Operands are equal goto __284 __283: res = func() int32 { - if (int32(flags3) & 0x0001) != 0 { + if (int32(flags3) & MEM_Null) != 0 { return -1 } return +1 @@ -66116,18 +65525,18 @@ __281: // SQLITE_NULLEQ is clear and at least one operand is NULL, // then the result is always NULL. // The jump is taken if the SQLITE_JUMPIFNULL bit is set. - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x20) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_STOREP2) != 0) { goto __285 } pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) iCompare = 1 // Operands are not equal - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0001)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Null)) goto __286 __285: ; - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x10) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_JUMPIFNULL) != 0) { goto __287 } goto jump_to_p2 @@ -66141,14 +65550,14 @@ __282: goto __280 __279: // Neither operand is NULL. Do a comparison. - affinity = (int8(int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x47)) - if !(int32(affinity) >= 0x43) { + affinity = (int8(int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_AFF_MASK)) + if !(int32(affinity) >= SQLITE_AFF_NUMERIC) { goto __288 } - if !(((int32(flags11) | int32(flags3)) & 0x0002) != 0) { + if !(((int32(flags11) | int32(flags3)) & MEM_Str) != 0) { goto __290 } - if !((int32(flags11) & (((0x0004 | 0x0020) | 0x0008) | 0x0002)) == 0x0002) { + if !((int32(flags11) & (((MEM_Int | MEM_IntReal) | MEM_Real) | MEM_Str)) == MEM_Str) { goto __291 } applyNumericAffinity(tls, pIn1, 0) @@ -66156,7 +65565,7 @@ __279: flags3 = (*Mem)(unsafe.Pointer(pIn3)).Fflags __291: ; - if !((int32(flags3) & (((0x0004 | 0x0020) | 0x0008) | 0x0002)) == 0x0002) { + if !((int32(flags3) & (((MEM_Int | MEM_IntReal) | MEM_Real) | MEM_Str)) == MEM_Str) { goto __292 } applyNumericAffinity(tls, pIn3, 0) @@ -66166,7 +65575,7 @@ __290: ; // Handle the common case of integer comparison here, as an // optimization, to avoid a call to sqlite3MemCompare() - if !(((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & int32((*Mem)(unsafe.Pointer(pIn3)).Fflags)) & 0x0004) != 0) { + if !(((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & int32((*Mem)(unsafe.Pointer(pIn3)).Fflags)) & MEM_Int) != 0) { goto __293 } if !(*(*I64)(unsafe.Pointer(pIn3 /* &.u */)) > *(*I64)(unsafe.Pointer(pIn1 /* &.u */))) { @@ -66189,31 +65598,31 @@ __293: ; goto __289 __288: - if !(int32(affinity) == 0x42) { + if !(int32(affinity) == SQLITE_AFF_TEXT) { goto __296 } - if !(((int32(flags11) & 0x0002) == 0) && ((int32(flags11) & ((0x0004 | 0x0008) | 0x0020)) != 0)) { + if !(((int32(flags11) & MEM_Str) == 0) && ((int32(flags11) & ((MEM_Int | MEM_Real) | MEM_IntReal)) != 0)) { goto __297 } Xsqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(1)) - flags11 = (U16((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32(0xc1bf)) | (int32(flags11) & 0xc1bf))) + flags11 = (U16((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & libc.CplInt32(MEM_TypeMask)) | (int32(flags11) & MEM_TypeMask))) if !(pIn1 == pIn3) { goto __298 } - flags3 = (U16(int32(flags11) | 0x0002)) + flags3 = (U16(int32(flags11) | MEM_Str)) __298: ; __297: ; - if !(((int32(flags3) & 0x0002) == 0) && ((int32(flags3) & ((0x0004 | 0x0008) | 0x0020)) != 0)) { + if !(((int32(flags3) & MEM_Str) == 0) && ((int32(flags3) & ((MEM_Int | MEM_Real) | MEM_IntReal)) != 0)) { goto __299 } Xsqlite3VdbeMemStringify(tls, pIn3, encoding, uint8(1)) - flags3 = (U16((int32((*Mem)(unsafe.Pointer(pIn3)).Fflags) & ^libc.Int32(0xc1bf)) | (int32(flags3) & 0xc1bf))) + flags3 = (U16((int32((*Mem)(unsafe.Pointer(pIn3)).Fflags) & libc.CplInt32(MEM_TypeMask)) | (int32(flags3) & MEM_TypeMask))) __299: ; __296: @@ -66236,16 +65645,16 @@ compare_op: if !(res < 0) { goto __300 } - res2 = int32(aLTb[(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) - 52)]) + res2 = int32(aLTb[(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) - OP_Ne)]) goto __301 __300: if !(res == 0) { goto __302 } - res2 = int32(aEQb[(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) - 52)]) + res2 = int32(aEQb[(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) - OP_Ne)]) goto __303 __302: - res2 = int32(aGTb[(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) - 52)]) + res2 = int32(aGTb[(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) - OP_Ne)]) __303: ; __301: @@ -66257,12 +65666,12 @@ __301: (*Mem)(unsafe.Pointer(pIn1)).Fflags = flags11 - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x20) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_STOREP2) != 0) { goto __304 } pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) iCompare = res - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x08) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_KEEPNULL) != 0) { goto __306 } // The KEEPNULL flag prevents OP_Eq from overwriting a NULL with 1 @@ -66273,7 +65682,7 @@ __301: // Therefore it is not necessary to check the content of r[P2] for // NULL. - if !((libc.Bool32(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 53)) == res2) { + if !((libc.Bool32(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_Eq)) == res2) { goto __307 } goto __8 @@ -66282,7 +65691,7 @@ __307: __306: ; - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) *(*I64)(unsafe.Pointer(pOut /* &.u */)) = I64(res2) goto __305 @@ -66358,7 +65767,7 @@ __53: // and strings are less than blobs. __54: // The permutation - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x01) == 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_PERMUTE) == 0) { goto __310 } aPermute = uintptr(0) @@ -66387,13 +65796,13 @@ __312: } pColl = *(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */) + uintptr(i1)*8)) - bRev = (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i1)))) & 0x01) + bRev = (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i1)))) & KEYINFO_ORDER_DESC) iCompare = Xsqlite3MemCompare(tls, (aMem + uintptr((U32(p11)+idx))*56), (aMem + uintptr((U32(p21)+idx))*56), pColl) if !(iCompare != 0) { goto __315 } - if !(((int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i1)))) & 0x02) != 0) && - (((int32((*Mem)(unsafe.Pointer(aMem+uintptr((U32(p11)+idx))*56)).Fflags) & 0x0001) != 0) || ((int32((*Mem)(unsafe.Pointer(aMem+uintptr((U32(p21)+idx))*56)).Fflags) & 0x0001) != 0))) { + if !(((int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i1)))) & KEYINFO_ORDER_BIGNULL) != 0) && + (((int32((*Mem)(unsafe.Pointer(aMem+uintptr((U32(p11)+idx))*56)).Fflags) & MEM_Null) != 0) || ((int32((*Mem)(unsafe.Pointer(aMem+uintptr((U32(p21)+idx))*56)).Fflags) & MEM_Null) != 0))) { goto __316 } iCompare = -iCompare @@ -66466,7 +65875,7 @@ __57: // Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL v1 = Xsqlite3VdbeBooleanValue(tls, (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56), 2) v2 = Xsqlite3VdbeBooleanValue(tls, (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56), 2) - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 44) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_And) { goto __322 } v1 = int32(and_logic[((v1 * 3) + v2)]) @@ -66479,11 +65888,11 @@ __323: if !(v1 == 2) { goto __324 } - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0001)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Null)) goto __325 __324: *(*I64)(unsafe.Pointer(pOut /* &.u */)) = I64(v1) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) __325: ; goto __8 @@ -66523,7 +65932,7 @@ __58: // in1, out2 __59: // same as TK_NOT, in1, out2 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0001) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Null) == 0) { goto __326 } Xsqlite3VdbeMemSetInt64(tls, pOut, libc.BoolInt64(!(Xsqlite3VdbeBooleanValue(tls, pIn1, 0) != 0))) @@ -66544,10 +65953,10 @@ __60: // same as TK_BITNOT, in1, out2 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) Xsqlite3VdbeMemSetNull(tls, pOut) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0001) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Null) == 0) { goto __328 } - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Int *(*I64)(unsafe.Pointer(pOut /* &.u */)) = ^Xsqlite3VdbeIntValue(tls, pIn1) __328: ; @@ -66585,7 +65994,7 @@ __331: *(*U8)(unsafe.Pointer((*VdbeFrame)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FpFrame)).FaOnce + uintptr((iAddr / U32(8))))) |= U8((int32(1) << (iAddr & U32(7)))) goto __330 __329: - if !((*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp+uintptr(0)*24)).Fp1 == (*Op)(unsafe.Pointer(pOp)).Fp1) { + if !((*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp)).Fp1 == (*Op)(unsafe.Pointer(pOp)).Fp1) { goto __332 } @@ -66595,7 +66004,7 @@ __332: __330: ; - (*Op)(unsafe.Pointer(pOp)).Fp1 = (*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(0)*24)).Fp1 + (*Op)(unsafe.Pointer(pOp)).Fp1 = (*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp)).Fp1 goto __8 // Opcode: If P1 P2 P3 * * @@ -66637,7 +66046,7 @@ __334: __64: // same as TK_ISNULL, jump, in1 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0001) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Null) != 0) { goto __335 } goto jump_to_p2 @@ -66652,7 +66061,7 @@ __335: __65: // same as TK_NOTNULL, jump, in1 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0001) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Null) == 0) { goto __336 } goto jump_to_p2 @@ -66697,7 +66106,7 @@ __67: // The VDBE cursor ; pC = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*8)) pOut = ((*Vdbe)(unsafe.Pointer(p)).FaMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) - if !((pC == uintptr(0)) || (int32((*VdbeCursor)(unsafe.Pointer(pC)).FeCurType) != 0)) { + if !((pC == uintptr(0)) || (int32((*VdbeCursor)(unsafe.Pointer(pC)).FeCurType) != CURTYPE_BTREE)) { goto __338 } Xsqlite3VdbeMemSetNull(tls, pOut) @@ -66755,7 +66164,7 @@ __340: if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FnullRow != 0) { goto __342 } - if !(int32((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FeCurType) == 3) { + if !(int32((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FeCurType) == CURTYPE_PSEUDO) { goto __344 } // For the special case of as pseudo-cursor, the seekResult field @@ -66779,7 +66188,7 @@ __342: (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FaRow = Xsqlite3BtreePayloadFetch(tls, pCrsr, (*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)) + 116 /* &.szRow */)) // Maximum page size is 64KiB - if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FpayloadSize > U32(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4)))) { + if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FpayloadSize > U32(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */))))) { goto __346 } goto too_big @@ -66791,15 +66200,15 @@ __343: (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FiHdrOffset = U32(func() uint8 { if int32(*(*U8)(unsafe.Pointer((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FaRow))) < int32(U8(0x80)) { return uint8(func() int32 { - (*(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4))) = U32(*(*U8)(unsafe.Pointer((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FaRow))) + (*(*U32)(unsafe.Pointer(aOffset))) = U32(*(*U8)(unsafe.Pointer((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FaRow))) return 1 }()) } - return Xsqlite3GetVarint32(tls, (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FaRow, (aOffset + uintptr(0)*4)) + return Xsqlite3GetVarint32(tls, (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FaRow, (aOffset)) }()) (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FnHdrParsed = U16(0) - if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FszRow < *(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4))) { + if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FszRow < *(*U32)(unsafe.Pointer(aOffset))) { goto __347 } //OPTIMIZATION-IF-FALSE // pC->aRow does not have to hold the entire row, but it does at least @@ -66817,7 +66226,7 @@ __343: // them, respectively. So the maximum header length results from a // 3-byte type for each of the maximum of 32768 columns plus three // extra bytes for the header length itself. 32768*3 + 3 = 98307. - if !((*(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4)) > U32(98307)) || (*(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4)) > (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FpayloadSize)) { + if !((*(*U32)(unsafe.Pointer(aOffset)) > U32(98307)) || (*(*U32)(unsafe.Pointer(aOffset)) > (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FpayloadSize)) { goto __349 } goto op_column_corrupt @@ -66853,7 +66262,7 @@ __341: } // If there is more header available for parsing in the record, try // to extract additional fields up through the p2+1-th field - if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FiHdrOffset < *(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4))) { + if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FiHdrOffset < *(*U32)(unsafe.Pointer(aOffset))) { goto __352 } // Make sure zData points to enough of the record to cover the header. @@ -66861,8 +66270,8 @@ __341: goto __354 } libc.Xmemset(tls, bp+216 /* &sMem */, 0, uint64(unsafe.Sizeof(Mem{}))) - rc = Xsqlite3VdbeMemFromBtreeZeroOffset(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)) + 56 /* &.uc */)), *(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4)), bp+216 /* &sMem */) - if !(rc != 0) { + rc = Xsqlite3VdbeMemFromBtreeZeroOffset(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)) + 56 /* &.uc */)), *(*U32)(unsafe.Pointer(aOffset)), bp+216 /* &sMem */) + if !(rc != SQLITE_OK) { goto __356 } goto abort_due_to_error @@ -66880,10 +66289,10 @@ op_column_read_header: i2 = int32((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FnHdrParsed) offset64 = U64(*(*U32)(unsafe.Pointer(aOffset + uintptr(i2)*4))) zHdr = (zData + uintptr((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FiHdrOffset)) - zEndHdr = (zData + uintptr(*(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4)))) + zEndHdr = (zData + uintptr(*(*U32)(unsafe.Pointer(aOffset)))) __357: - if !((libc.AssignPtrUint32((*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */))+120 /* &.aType */)+uintptr(i2)*4, libc.AssignPtrUint32(bp+272 /* t */, U32(*(*U8)(unsafe.Pointer(zHdr + uintptr(0))))))) < U32(0x80)) { + if !((libc.AssignPtrUint32((*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */))+120 /* &.aType */)+uintptr(i2)*4, libc.AssignPtrUint32(bp+272 /* t */, U32(*(*U8)(unsafe.Pointer(zHdr)))))) < U32(0x80)) { goto __360 } zHdr++ @@ -66913,7 +66322,7 @@ __359: (offset64 > U64((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FpayloadSize))) { goto __362 } - if !(*(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4)) == U32(0)) { + if !(*(*U32)(unsafe.Pointer(aOffset)) == U32(0)) { goto __363 } i2 = 0 @@ -66955,7 +66364,7 @@ __353: if !(int32((*Op)(unsafe.Pointer(pOp)).Fp4type) == (-11)) { goto __368 } - Xsqlite3VdbeMemShallowCopy(tls, pDest, *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)), 0x0800) + Xsqlite3VdbeMemShallowCopy(tls, pDest, *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)), MEM_Static) goto __369 __368: Xsqlite3VdbeMemSetNull(tls, pDest) @@ -66974,7 +66383,7 @@ __351: // reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are // all valid. - if !((int32((*Mem)(unsafe.Pointer((pDest))).Fflags) & (0x2000 | 0x0400)) != 0) { + if !((int32((*Mem)(unsafe.Pointer((pDest))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0) { goto __370 } Xsqlite3VdbeMemSetNull(tls, pDest) @@ -66998,7 +66407,7 @@ __373: if !((*Mem)(unsafe.Pointer(pDest)).FszMalloc < (len + 2)) { goto __375 } - (*Mem)(unsafe.Pointer(pDest)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pDest)).Fflags = MEM_Null if !(Xsqlite3VdbeMemGrow(tls, pDest, (len+2), 0) != 0) { goto __377 } @@ -67020,8 +66429,8 @@ __374: __371: (*Mem)(unsafe.Pointer(pDest)).Fenc = encoding // This branch happens only when content is on overflow pages - if !((((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (0x40 | 0x80)) != 0) && - (((*(*U32)(unsafe.Pointer(bp + 272 /* t */)) >= U32(12)) && ((*(*U32)(unsafe.Pointer(bp + 272 /* t */)) & U32(1)) == U32(0))) || ((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x80) != 0))) || + if !((((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (OPFLAG_LENGTHARG | OPFLAG_TYPEOFARG)) != 0) && + (((*(*U32)(unsafe.Pointer(bp + 272 /* t */)) >= U32(12)) && ((*(*U32)(unsafe.Pointer(bp + 272 /* t */)) & U32(1)) == U32(0))) || ((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_TYPEOFARG) != 0))) || ((libc.AssignInt32(&len, int32(Xsqlite3VdbeSerialTypeLen(tls, *(*U32)(unsafe.Pointer(bp + 272 /* t */)))))) == 0)) { goto __378 } @@ -67041,14 +66450,14 @@ __371: goto __379 __378: rc = Xsqlite3VdbeMemFromBtree(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)) + 56 /* &.uc */)), *(*U32)(unsafe.Pointer(aOffset + uintptr(*(*U32)(unsafe.Pointer(bp + 208 /* p22 */)))*4)), uint32(len), pDest) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __380 } goto abort_due_to_error __380: ; Xsqlite3VdbeSerialGet(tls, (*Mem)(unsafe.Pointer(pDest)).Fz, *(*U32)(unsafe.Pointer(bp + 272 /* t */)), pDest) - *(*U16)(unsafe.Pointer(pDest + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x1000))) + *(*U16)(unsafe.Pointer(pDest + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Ephem))) __379: ; __372: @@ -67060,10 +66469,10 @@ op_column_out: goto __8 op_column_corrupt: - if !((*Op)(unsafe.Pointer(aOp+uintptr(0)*24)).Fp3 > 0) { + if !((*Op)(unsafe.Pointer(aOp)).Fp3 > 0) { goto __381 } - pOp = (aOp + uintptr(((*Op)(unsafe.Pointer(aOp+uintptr(0)*24)).Fp3-1))*24) + pOp = (aOp + uintptr(((*Op)(unsafe.Pointer(aOp)).Fp3-1))*24) goto __8 goto __382 __381: @@ -67090,8 +66499,8 @@ __383: goto __384 } - applyAffinity(tls, pIn1, *(*int8)(unsafe.Pointer(zAffinity + uintptr(0))), encoding) - if !((int32(*(*int8)(unsafe.Pointer(zAffinity + uintptr(0)))) == 0x45) && ((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0004) != 0)) { + applyAffinity(tls, pIn1, *(*int8)(unsafe.Pointer(zAffinity)), encoding) + if !((int32(*(*int8)(unsafe.Pointer(zAffinity))) == SQLITE_AFF_REAL) && ((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Int) != 0)) { goto __385 } // When applying REAL affinity, if the result is still an MEM_Int @@ -67102,20 +66511,20 @@ __383: if !((*(*I64)(unsafe.Pointer(pIn1 /* &.u */)) <= 140737488355327) && (*(*I64)(unsafe.Pointer(pIn1 /* &.u */)) >= -140737488355328)) { goto __386 } - *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) |= U16((0x0020)) - *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0004))) + *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) |= U16((MEM_IntReal)) + *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Int))) goto __387 __386: *(*float64)(unsafe.Pointer(pIn1 /* &.u */)) = float64(*(*I64)(unsafe.Pointer(pIn1 /* &.u */))) - *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) |= U16((0x0008)) - *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0004))) + *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) |= U16((MEM_Real)) + *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Int))) __387: ; __385: ; zAffinity++ - if !(int32(*(*int8)(unsafe.Pointer(zAffinity + uintptr(0)))) == 0) { + if !(int32(*(*int8)(unsafe.Pointer(zAffinity))) == 0) { goto __388 } goto __384 @@ -67191,12 +66600,12 @@ __70: // Where to write next byte of the payload } pRec = pData0 __390: - applyAffinity(tls, pRec, *(*int8)(unsafe.Pointer(zAffinity1 + uintptr(0))), encoding) - if !((int32(*(*int8)(unsafe.Pointer(zAffinity1 + uintptr(0)))) == 0x45) && ((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0004) != 0)) { + applyAffinity(tls, pRec, *(*int8)(unsafe.Pointer(zAffinity1)), encoding) + if !((int32(*(*int8)(unsafe.Pointer(zAffinity1))) == SQLITE_AFF_REAL) && ((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Int) != 0)) { goto __393 } - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((0x0020)) - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0004))) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((MEM_IntReal)) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Int))) __393: ; @@ -67205,7 +66614,7 @@ __393: goto __391 __391: - if *(*int8)(unsafe.Pointer(zAffinity1 + uintptr(0))) != 0 { + if *(*int8)(unsafe.Pointer(zAffinity1)) != 0 { goto __390 } goto __392 @@ -67242,10 +66651,10 @@ __389: pRec = pLast __394: ; - if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0001) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Null) != 0) { goto __397 } - if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x4000) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Zero) != 0) { goto __399 } // Values with MEM_Null and MEM_Zero are created by xColumn virtual @@ -67264,7 +66673,7 @@ __400: nHdr++ goto __398 __397: - if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & (0x0004 | 0x0020)) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & (MEM_Int | MEM_IntReal)) != 0) { goto __401 } // Figure out whether to use 1, 2, 4, 6 or 8 bytes. @@ -67325,15 +66734,15 @@ __413: goto __416 __415: nData = nData + (uint64(8)) - if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0020) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_IntReal) != 0) { goto __417 } // If the value is IntReal and is going to take up 8 bytes to store // as an integer, then we might as well make it an 8-byte floating // point value *(*float64)(unsafe.Pointer(pRec /* &.u */)) = float64(*(*I64)(unsafe.Pointer(pRec /* &.u */))) - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0020))) - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_IntReal))) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((MEM_Real)) (*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(7) goto __418 __417: @@ -67352,7 +66761,7 @@ __406: ; goto __402 __401: - if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0008) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Real) != 0) { goto __419 } nHdr++ @@ -67363,8 +66772,8 @@ __419: ; len1 = U32((*Mem)(unsafe.Pointer(pRec)).Fn) - serial_type = (((len1 * U32(2)) + U32(12)) + (U32(libc.Bool32((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0002) != 0)))) - if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x4000) != 0) { + serial_type = (((len1 * U32(2)) + U32(12)) + (U32(libc.Bool32((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Str) != 0)))) + if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Zero) != 0) { goto __421 } serial_type = serial_type + (U32(*(*int32)(unsafe.Pointer(pRec /* &.u */)) * 2)) @@ -67449,7 +66858,7 @@ __427: __429: // Need to make sure that the output is not too big and then enlarge // the output register to hold the full result - if !((nByte1 + nZero) > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4)))) { + if !((nByte1 + nZero) > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */))))) { goto __431 } goto too_big @@ -67464,12 +66873,12 @@ __432: __430: ; (*Mem)(unsafe.Pointer(pOut)).Fn = int32(nByte1) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0010) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Blob if !(nZero != 0) { goto __433 } *(*int32)(unsafe.Pointer(pOut /* &.u */)) = int32(nZero) - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((0x4000)) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((MEM_Zero)) __433: ; @@ -67556,7 +66965,7 @@ __72: // Assert that the p1 parameter is valid. Also that if there is no open // transaction, then there cannot be any savepoints. - if !(p12 == 0) { + if !(p12 == SAVEPOINT_BEGIN) { goto __440 } if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0) { @@ -67565,7 +66974,7 @@ __72: // A new savepoint cannot be created if there are active write // statements (i.e. open read/write incremental blob handles). Xsqlite3VdbeError(tls, p, ts+4438 /* "cannot open save..." */, 0) - rc = 5 + rc = SQLITE_BUSY goto __443 __442: nName = Xsqlite3Strlen30(tls, zName) @@ -67575,9 +66984,9 @@ __442: // If this is a transaction savepoint being opened, it is guaranteed // that the db->aVTrans[] array is empty. - rc = Xsqlite3VtabSavepoint(tls, db, 0, + rc = Xsqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, ((*Sqlite3)(unsafe.Pointer(db)).FnStatement + (*Sqlite3)(unsafe.Pointer(db)).FnSavepoint)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __444 } goto abort_due_to_error @@ -67589,7 +66998,7 @@ __444: if !(pNew != 0) { goto __445 } - (*Savepoint)(unsafe.Pointer(pNew)).FzName = (pNew + uintptr(1)*32) + (*Savepoint)(unsafe.Pointer(pNew)).FzName = (pNew + 1*32) libc.Xmemcpy(tls, (*Savepoint)(unsafe.Pointer(pNew)).FzName, zName, (uint64(nName + 1))) // If there is no open transaction, then mark this as a special @@ -67638,17 +67047,17 @@ __450: goto __451 } Xsqlite3VdbeError(tls, p, ts+4489 /* "no such savepoin..." */, libc.VaList(bp+56, zName)) - rc = 1 + rc = SQLITE_ERROR goto __452 __451: - if !(((*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0) && (p12 == 1)) { + if !(((*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0) && (p12 == SAVEPOINT_RELEASE)) { goto __453 } // It is not possible to release (commit) a savepoint if there are // active write statements. Xsqlite3VdbeError(tls, p, ts+4511 /* "cannot release s..." */, 0) - rc = 5 + rc = SQLITE_BUSY goto __454 __453: @@ -67656,22 +67065,22 @@ __453: // and this is a RELEASE command, then the current transaction // is committed. isTransaction = (libc.Bool32(((*Savepoint)(unsafe.Pointer(pSavepoint)).FpNext == uintptr(0)) && ((*Sqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint != 0))) - if !((isTransaction != 0) && (p12 == 1)) { + if !((isTransaction != 0) && (p12 == SAVEPOINT_RELEASE)) { goto __455 } - if !((libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 1))) != 0) { + if !((libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 1))) != SQLITE_OK) { goto __457 } goto vdbe_return __457: ; (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1) - if !(Xsqlite3VdbeHalt(tls, p) == 5) { + if !(Xsqlite3VdbeHalt(tls, p) == SQLITE_BUSY) { goto __458 } (*Vdbe)(unsafe.Pointer(p)).Fpc = (int32((int64(pOp) - int64(aOp)) / 24)) (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(0) - (*Vdbe)(unsafe.Pointer(p)).Frc = libc.AssignInt32(&rc, 5) + (*Vdbe)(unsafe.Pointer(p)).Frc = libc.AssignInt32(&rc, SQLITE_BUSY) goto vdbe_return __458: ; @@ -67688,19 +67097,19 @@ __460: goto __456 __455: iSavepoint = (((*Sqlite3)(unsafe.Pointer(db)).FnSavepoint - iSavepoint) - 1) - if !(p12 == 2) { + if !(p12 == SAVEPOINT_ROLLBACK) { goto __461 } - isSchemaChange = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0001)) != U32(0))) + isSchemaChange = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_SchemaChange) != U32(0))) ii = 0 __463: if !(ii < (*Sqlite3)(unsafe.Pointer(db)).FnDb) { goto __465 } rc = Xsqlite3BtreeTripAllCursors(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii)*32)).FpBt, - (4 | (int32(2) << 8)), + (SQLITE_ABORT | (int32(2) << 8)), (libc.Bool32(isSchemaChange == 0))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __466 } goto abort_due_to_error @@ -67725,7 +67134,7 @@ __467: goto __469 } rc = Xsqlite3BtreeSavepoint(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii)*32)).FpBt, p12, iSavepoint) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __470 } goto abort_due_to_error @@ -67743,7 +67152,7 @@ __469: } Xsqlite3ExpirePreparedStatements(tls, db, 0) Xsqlite3ResetAllSchemasOfConnection(tls, db) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) __471: ; __456: @@ -67773,7 +67182,7 @@ __474: // too. If it is a ROLLBACK TO, then set the number of deferred // constraint violations present in the database to the value stored // when the savepoint was created. - if !(p12 == 1) { + if !(p12 == SAVEPOINT_RELEASE) { goto __475 } @@ -67793,11 +67202,11 @@ __475: __476: ; - if !(!(isTransaction != 0) || (p12 == 2)) { + if !(!(isTransaction != 0) || (p12 == SAVEPOINT_ROLLBACK)) { goto __478 } rc = Xsqlite3VtabSavepoint(tls, db, p12, iSavepoint) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __479 } goto abort_due_to_error @@ -67842,7 +67251,7 @@ __73: goto __483 } - Xsqlite3RollbackAll(tls, db, (4 | (int32(2) << 8))) + Xsqlite3RollbackAll(tls, db, (SQLITE_ABORT | (int32(2) << 8))) (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1) goto __484 __483: @@ -67853,11 +67262,11 @@ __483: // return an error indicating that the other VMs must complete first. Xsqlite3VdbeError(tls, p, ts+4565 /* "cannot commit tr..." */, 0) - rc = 5 + rc = SQLITE_BUSY goto abort_due_to_error goto __486 __485: - if !((libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 1))) != 0) { + if !((libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 1))) != SQLITE_OK) { goto __487 } goto vdbe_return @@ -67870,23 +67279,23 @@ __486: ; __484: ; - if !(Xsqlite3VdbeHalt(tls, p) == 5) { + if !(Xsqlite3VdbeHalt(tls, p) == SQLITE_BUSY) { goto __489 } (*Vdbe)(unsafe.Pointer(p)).Fpc = (int32((int64(pOp) - int64(aOp)) / 24)) (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = (U8(1 - desiredAutoCommit)) - (*Vdbe)(unsafe.Pointer(p)).Frc = libc.AssignInt32(&rc, 5) + (*Vdbe)(unsafe.Pointer(p)).Frc = libc.AssignInt32(&rc, SQLITE_BUSY) goto vdbe_return __489: ; Xsqlite3CloseSavepoints(tls, db) - if !((*Vdbe)(unsafe.Pointer(p)).Frc == 0) { + if !((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK) { goto __490 } - rc = 101 + rc = SQLITE_DONE goto __491 __490: - rc = 1 + rc = SQLITE_ERROR __491: ; goto vdbe_return @@ -67905,7 +67314,7 @@ __481: }() }(), 0) - rc = 1 + rc = SQLITE_ERROR goto abort_due_to_error __482: ; @@ -67947,10 +67356,10 @@ __482: __74: *(*int32)(unsafe.Pointer(bp + 288 /* iMeta */)) = 0 - if !(((*Op)(unsafe.Pointer(pOp)).Fp2 != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00100000)) != uint64(0))) { + if !(((*Op)(unsafe.Pointer(pOp)).Fp2 != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_QueryOnly) != uint64(0))) { goto __492 } - rc = 8 + rc = SQLITE_READONLY goto abort_due_to_error __492: ; @@ -67961,10 +67370,10 @@ __492: } rc = Xsqlite3BtreeBeginTrans(tls, pBt, (*Op)(unsafe.Pointer(pOp)).Fp2, bp+288 /* &iMeta */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __494 } - if !((rc & 0xff) == 5) { + if !((rc & 0xff) == SQLITE_BUSY) { goto __495 } (*Vdbe)(unsafe.Pointer(p)).Fpc = (int32((int64(pOp) - int64(aOp)) / 24)) @@ -67991,8 +67400,8 @@ __494: __497: ; - rc = Xsqlite3VtabSavepoint(tls, db, 0, ((*Vdbe)(unsafe.Pointer(p)).FiStatement - 1)) - if !(rc == 0) { + rc = Xsqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, ((*Vdbe)(unsafe.Pointer(p)).FiStatement - 1)) + if !(rc == SQLITE_OK) { goto __498 } rc = Xsqlite3BtreeBeginStmt(tls, pBt, (*Vdbe)(unsafe.Pointer(p)).FiStatement) @@ -68038,7 +67447,7 @@ __493: __500: ; libc.SetBitFieldPtr16Uint32(p+200 /* &.expired */, Bft(1), 0, 0x3) - rc = 17 + rc = SQLITE_SCHEMA __499: ; if !(rc != 0) { @@ -68091,15 +67500,15 @@ __76: // See note about index shifting on OP_ReadCookie rc = Xsqlite3BtreeUpdateMeta(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, (*Op)(unsafe.Pointer(pOp)).Fp2, uint32((*Op)(unsafe.Pointer(pOp)).Fp3)) - if !((*Op)(unsafe.Pointer(pOp)).Fp2 == 1) { + if !((*Op)(unsafe.Pointer(pOp)).Fp2 == BTREE_SCHEMA_VERSION) { goto __502 } // When the schema cookie changes, record the new cookie internally (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fschema_cookie = ((*Op)(unsafe.Pointer(pOp)).Fp3 - int32((*Op)(unsafe.Pointer(pOp)).Fp5)) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) goto __503 __502: - if !((*Op)(unsafe.Pointer(pOp)).Fp2 == 2) { + if !((*Op)(unsafe.Pointer(pOp)).Fp2 == BTREE_FILE_FORMAT) { goto __504 } // Record changes in the file format @@ -68226,7 +67635,7 @@ __79: if !((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.expired */)) & 0x3 >> 0)) == 1) { goto __508 } - rc = (4 | (int32(2) << 8)) + rc = (SQLITE_ABORT | (int32(2) << 8)) goto abort_due_to_error __508: ; @@ -68239,11 +67648,11 @@ __508: pDb1 = ((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb1)*32) pX = (*Db)(unsafe.Pointer(pDb1)).FpBt - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 97) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_OpenWrite) { goto __509 } - wrFlag = (0x00000004 | (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x08)) + wrFlag = (BTREE_WRCSR | (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_FORDELETE)) if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb1)).FpSchema)).Ffile_format) < int32((*Vdbe)(unsafe.Pointer(p)).FminWriteFileFormat)) { goto __511 @@ -68256,7 +67665,7 @@ __509: wrFlag = 0 __510: ; - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x10) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_P2ISREG) != 0) { goto __512 } @@ -68289,7 +67698,7 @@ __514: ; // Table with INTEGER PRIMARY KEY and nothing else - pCur = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, nField1, iDb1, uint8(0)) + pCur = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, nField1, iDb1, CURTYPE_BTREE) if !(pCur == uintptr(0)) { goto __516 } @@ -68311,7 +67720,7 @@ open_cursor_set_hints: ; Xsqlite3BtreeCursorHintFlags(tls, *(*uintptr)(unsafe.Pointer(pCur + 56 /* &.uc */)), - (uint32(int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (0x01 | 0x02)))) + (uint32(int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (OPFLAG_BULKCSR | OPFLAG_SEEKEQ)))) if !(rc != 0) { goto __517 } @@ -68333,7 +67742,7 @@ __80: // The new cursor // Only ephemeral cursors can be duplicated - pCx = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, int32((*VdbeCursor)(unsafe.Pointer(pOrig)).FnField), -1, uint8(0)) + pCx = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, int32((*VdbeCursor)(unsafe.Pointer(pOrig)).FnField), -1, CURTYPE_BTREE) if !(pCx == uintptr(0)) { goto __518 } @@ -68346,7 +67755,7 @@ __518: (*VdbeCursor)(unsafe.Pointer(pCx)).FisTable = (*VdbeCursor)(unsafe.Pointer(pOrig)).FisTable (*VdbeCursor)(unsafe.Pointer(pCx)).FpgnoRoot = (*VdbeCursor)(unsafe.Pointer(pOrig)).FpgnoRoot libc.SetBitFieldPtr8Uint32(pCx+8 /* &.isOrdered */, (Bool(int32(*(*uint8)(unsafe.Pointer(pOrig + 8 /* &.isOrdered */)) & 0x4 >> 2))), 2, 0x4) - rc = Xsqlite3BtreeCursor(tls, (*VdbeCursor)(unsafe.Pointer(pOrig)).FpBtx, (*VdbeCursor)(unsafe.Pointer(pCx)).FpgnoRoot, 0x00000004, + rc = Xsqlite3BtreeCursor(tls, (*VdbeCursor)(unsafe.Pointer(pOrig)).FpBtx, (*VdbeCursor)(unsafe.Pointer(pCx)).FpgnoRoot, BTREE_WRCSR, (*VdbeCursor)(unsafe.Pointer(pCx)).FpKeyInfo, *(*uintptr)(unsafe.Pointer(pCx + 56 /* &.uc */))) // The sqlite3BtreeCursor() routine can only fail for the first cursor // opened for a database. Since there is already an open cursor when this @@ -68393,11 +67802,11 @@ __82: // so that the table is empty again, rather than creating a new table. (*VdbeCursor)(unsafe.Pointer(pCx1)).FseqCount = int64(0) - (*VdbeCursor)(unsafe.Pointer(pCx1)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pCx1)).FcacheStatus = CACHE_STALE rc = Xsqlite3BtreeClearTable(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, int32((*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot), uintptr(0)) goto __520 __519: - pCx1 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, -1, uint8(0)) + pCx1 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, -1, CURTYPE_BTREE) if !(pCx1 == uintptr(0)) { goto __521 } @@ -68406,15 +67815,15 @@ __521: ; libc.SetBitFieldPtr8Uint32(pCx1+8 /* &.isEphemeral */, Bool(1), 0, 0x1) rc = Xsqlite3BtreeOpen(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), db, (pCx1 + 16 /* &.pBtx */), - ((1 | 4) | int32((*Op)(unsafe.Pointer(pOp)).Fp5)), + ((BTREE_OMIT_JOURNAL | BTREE_SINGLE) | int32((*Op)(unsafe.Pointer(pOp)).Fp5)), vfsFlags) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __522 } rc = Xsqlite3BtreeBeginTrans(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, 1, uintptr(0)) __522: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __523 } // If a transient index is required, create it by calling @@ -68426,27 +67835,27 @@ __522: } rc = Xsqlite3BtreeCreateTable(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, (pCx1 + 76 /* &.pgnoRoot */), - (2 | int32((*Op)(unsafe.Pointer(pOp)).Fp5))) - if !(rc == 0) { + (BTREE_BLOBKEY | int32((*Op)(unsafe.Pointer(pOp)).Fp5))) + if !(rc == SQLITE_OK) { goto __526 } - rc = Xsqlite3BtreeCursor(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot, 0x00000004, + rc = Xsqlite3BtreeCursor(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot, BTREE_WRCSR, pKeyInfo2, *(*uintptr)(unsafe.Pointer(pCx1 + 56 /* &.uc */))) __526: ; (*VdbeCursor)(unsafe.Pointer(pCx1)).FisTable = U8(0) goto __525 __524: - (*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot = Pgno(1) - rc = Xsqlite3BtreeCursor(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, uint32(1), 0x00000004, + (*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot = SCHEMA_ROOT + rc = Xsqlite3BtreeCursor(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, SCHEMA_ROOT, BTREE_WRCSR, uintptr(0), *(*uintptr)(unsafe.Pointer(pCx1 + 56 /* &.uc */))) (*VdbeCursor)(unsafe.Pointer(pCx1)).FisTable = U8(1) __525: ; __523: ; - libc.SetBitFieldPtr8Uint32(pCx1+8 /* &.isOrdered */, (Bool(libc.Bool32(int32((*Op)(unsafe.Pointer(pOp)).Fp5) != 8))), 2, 0x4) + libc.SetBitFieldPtr8Uint32(pCx1+8 /* &.isOrdered */, (Bool(libc.Bool32(int32((*Op)(unsafe.Pointer(pOp)).Fp5) != BTREE_UNORDERED))), 2, 0x4) __520: ; if !(rc != 0) { @@ -68470,7 +67879,7 @@ __527: __83: ; - pCx2 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, -1, uint8(1)) + pCx2 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, -1, CURTYPE_SORTER) if !(pCx2 == uintptr(0)) { goto __528 } @@ -68524,7 +67933,7 @@ __530: __85: ; - pCx3 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp3, -1, uint8(3)) + pCx3 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp3, -1, CURTYPE_PSEUDO) if !(pCx3 == uintptr(0)) { goto __531 } @@ -68652,7 +68061,7 @@ __90: // Only interested in == results (*VdbeCursor)(unsafe.Pointer(pC3)).FnullRow = U8(0) (*VdbeCursor)(unsafe.Pointer(pC3)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus = CACHE_STALE if !((*VdbeCursor)(unsafe.Pointer(pC3)).FisTable != 0) { goto __532 } @@ -68663,7 +68072,7 @@ __90: // Only interested in == results // the seek, so convert it. pIn3 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) flags31 = (*Mem)(unsafe.Pointer(pIn3)).Fflags - if !((int32(flags31) & (((0x0004 | 0x0008) | 0x0020) | 0x0002)) == 0x0002) { + if !((int32(flags31) & (((MEM_Int | MEM_Real) | MEM_IntReal) | MEM_Str)) == MEM_Str) { goto __534 } applyNumericAffinity(tls, pIn3, 0) @@ -68675,13 +68084,13 @@ __534: // If the P3 value could not be converted into an integer without // loss of information, then special processing is required... - if !((int32(newType) & (0x0004 | 0x0020)) == 0) { + if !((int32(newType) & (MEM_Int | MEM_IntReal)) == 0) { goto __535 } - if !((int32(newType) & 0x0008) == 0) { + if !((int32(newType) & MEM_Real) == 0) { goto __536 } - if !(((int32(newType) & 0x0001) != 0) || (oc >= 24)) { + if !(((int32(newType) & MEM_Null) != 0) || (oc >= OP_SeekGE)) { goto __538 } @@ -68689,7 +68098,7 @@ __534: goto __539 __538: rc = Xsqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), bp+296 /* &res1 */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __540 } goto abort_due_to_error @@ -68711,7 +68120,7 @@ __536: goto __541 } - if !((oc & 0x0001) == (25 & 0x0001)) { + if !((oc & 0x0001) == (OP_SeekGT & 0x0001)) { goto __543 } oc-- @@ -68723,7 +68132,7 @@ __541: goto __544 } - if !((oc & 0x0001) == (22 & 0x0001)) { + if !((oc & 0x0001) == (OP_SeekLT & 0x0001)) { goto __545 } oc++ @@ -68739,7 +68148,7 @@ __535: ; rc = Xsqlite3BtreeMovetoUnpacked(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), uintptr(0), int64(U64(iKey)), 0, bp+296 /* &res1 */) (*VdbeCursor)(unsafe.Pointer(pC3)).FmovetoTarget = iKey // Used by OP_Delete - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __546 } goto abort_due_to_error @@ -68751,7 +68160,7 @@ __532: // OP_SeekGE and OP_SeekLE opcodes are allowed, and these must be // immediately followed by an OP_IdxGT or OP_IdxLT opcode, respectively, // with the same key. - if !(Xsqlite3BtreeCursorHasHint(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), uint32(0x00000002)) != 0) { + if !(Xsqlite3BtreeCursorHasHint(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), BTREE_SEEK_EQ) != 0) { goto __547 } eqOnly = 1 @@ -68771,7 +68180,7 @@ __547: // r.default_rc = +1; // } (*UnpackedRecord)(unsafe.Pointer(bp + 304 /* &r */)).Fdefault_rc = func() int8 { - if (1 & (oc - 22)) != 0 { + if (1 & (oc - OP_SeekLT)) != 0 { return int8(-1) } return +int8(1) @@ -68780,7 +68189,7 @@ __547: (*UnpackedRecord)(unsafe.Pointer(bp + 304 /* &r */)).FaMem = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) (*UnpackedRecord)(unsafe.Pointer(bp + 304 /* &r */)).FeqSeen = U8(0) rc = Xsqlite3BtreeMovetoUnpacked(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), bp+304 /* &r */, int64(0), 0, bp+296 /* &res1 */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __548 } goto abort_due_to_error @@ -68795,21 +68204,21 @@ __549: ; __533: ; - if !(oc >= 24) { + if !(oc >= OP_SeekGE) { goto __550 } - if !((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) < 0) || ((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) == 0) && (oc == 25))) { + if !((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) < 0) || ((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) == 0) && (oc == OP_SeekGT))) { goto __552 } *(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) = 0 rc = Xsqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __554 } - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __555 } - rc = 0 + rc = SQLITE_OK *(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) = 1 goto __556 __555: @@ -68826,18 +68235,18 @@ __553: goto __551 __550: ; - if !((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) > 0) || ((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) == 0) && (oc == 22))) { + if !((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) > 0) || ((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) == 0) && (oc == OP_SeekLT))) { goto __557 } *(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) = 0 rc = Xsqlite3BtreePrevious(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __559 } - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __560 } - rc = 0 + rc = SQLITE_OK *(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) = 1 goto __561 __560: @@ -68997,8 +68406,6 @@ __93: goto __8 __566: ; - // Fall through into OP_NotFound - /* no break */ __94: // jump, in3 __95: // jump, in3 @@ -69021,7 +68428,7 @@ __96: __567: ; rc = func() int32 { - if (int32((*Mem)(unsafe.Pointer((pIn3))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pIn3))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pIn3) } return 0 @@ -69045,7 +68452,7 @@ __568: ; (*UnpackedRecord)(unsafe.Pointer(pIdxKey)).Fdefault_rc = int8(0) takeJump = 0 - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 28) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_NoConflict) { goto __571 } // For the OP_NoConflict opcode, take the jump if any of the @@ -69056,7 +68463,7 @@ __572: if !(ii1 < int32((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FnField)) { goto __574 } - if !((int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FaMem+uintptr(ii1)*56)).Fflags) & 0x0001) != 0) { + if !((int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FaMem+uintptr(ii1)*56)).Fflags) & MEM_Null) != 0) { goto __575 } takeJump = 1 @@ -69079,7 +68486,7 @@ __571: Xsqlite3DbFreeNN(tls, db, pFree) __576: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __577 } goto abort_due_to_error @@ -69089,8 +68496,8 @@ __577: alreadyExists = (libc.Bool32(*(*int32)(unsafe.Pointer(bp + 352 /* res3 */)) == 0)) (*VdbeCursor)(unsafe.Pointer(pC6)).FnullRow = (U8(1 - alreadyExists)) (*VdbeCursor)(unsafe.Pointer(pC6)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC6)).FcacheStatus = U32(0) - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 30) { + (*VdbeCursor)(unsafe.Pointer(pC6)).FcacheStatus = CACHE_STALE + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_Found) { goto __578 } @@ -69162,7 +68569,7 @@ __97: pIn3 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn3)).Fflags) & (0x0004 | 0x0020)) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn3)).Fflags) & (MEM_Int | MEM_IntReal)) == 0) { goto __582 } // If pIn3->u.i does not contain an integer, compute iKey as the @@ -69170,9 +68577,9 @@ __97: // into an integer without loss of information. Take care to avoid // changing the datatype of pIn3, however, as it is used by other // parts of the prepared statement. - *(*Mem)(unsafe.Pointer(bp + 360 /* x */)) = *(*Mem)(unsafe.Pointer(pIn3 + uintptr(0)*56)) - applyAffinity(tls, bp+360 /* &x */, int8(0x43), encoding) - if !((int32((*Mem)(unsafe.Pointer(bp+360 /* &x */)).Fflags) & 0x0004) == 0) { + *(*Mem)(unsafe.Pointer(bp + 360 /* x */)) = *(*Mem)(unsafe.Pointer(pIn3)) + applyAffinity(tls, bp+360 /* &x */, SQLITE_AFF_NUMERIC, encoding) + if !((int32((*Mem)(unsafe.Pointer(bp+360 /* &x */)).Fflags) & MEM_Int) == 0) { goto __583 } goto jump_to_p2 @@ -69182,8 +68589,6 @@ __583: goto notExistsWithKey __582: ; - // Fall through into OP_NotExists - /* no break */ __98: // jump, in3 pIn3 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) @@ -69198,7 +68603,7 @@ notExistsWithKey: (*VdbeCursor)(unsafe.Pointer(pC7)).FmovetoTarget = I64(iKey1) // Used by OP_Delete (*VdbeCursor)(unsafe.Pointer(pC7)).FnullRow = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC7)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC7)).FcacheStatus = CACHE_STALE (*VdbeCursor)(unsafe.Pointer(pC7)).FdeferredMoveto = U8(0) (*VdbeCursor)(unsafe.Pointer(pC7)).FseekResult = *(*int32)(unsafe.Pointer(bp + 416 /* res4 */)) @@ -69282,7 +68687,7 @@ __100: // Root frame of VDBE goto __588 } rc = Xsqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC8 + 56 /* &.uc */)), bp+420 /* &res5 */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __589 } goto abort_due_to_error @@ -69347,7 +68752,7 @@ __596: if !((*(*I64)(unsafe.Pointer(pMem1 /* &.u */)) == (int64((U64((uint64(0x7fffffff))) << 32) | uint64(0xffffffff)))) || ((Bool(int32(*(*uint8)(unsafe.Pointer(pC8 + 8 /* &.useRandomRowid */)) & 0x2 >> 1))) != 0)) { goto __600 } - rc = 13 // IMP: R-17817-00630 + rc = SQLITE_FULL // IMP: R-17817-00630 goto abort_due_to_error __600: ; @@ -69377,7 +68782,7 @@ __603: goto __604 __604: if (((libc.AssignInt32(&rc, Xsqlite3BtreeMovetoUnpacked(tls, *(*uintptr)(unsafe.Pointer(pC8 + 56 /* &.uc */)), uintptr(0), int64(U64(*(*I64)(unsafe.Pointer(bp + 424 /* v */)))), - 0, bp+420 /* &res5 */))) == 0) && + 0, bp+420 /* &res5 */))) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 420 /* res5 */)) == 0)) && (libc.PreIncInt32(&cnt1, 1) < 100) { goto __603 @@ -69394,7 +68799,7 @@ __606: if !(*(*int32)(unsafe.Pointer(bp + 420 /* res5 */)) == 0) { goto __607 } - rc = 13 // IMP: R-38219-53002 + rc = SQLITE_FULL // IMP: R-38219-53002 goto abort_due_to_error __607: ; @@ -69402,7 +68807,7 @@ __607: __602: ; (*VdbeCursor)(unsafe.Pointer(pC8)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC8)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC8)).FcacheStatus = CACHE_STALE *(*I64)(unsafe.Pointer(pOut /* &.u */)) = *(*I64)(unsafe.Pointer(bp + 424 /* v */)) goto __8 @@ -69471,10 +68876,10 @@ __609: if !(pTab != 0) { goto __610 } - if !(((*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0) && !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x04) != 0)) { + if !(((*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0) && !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_ISUPDATE) != 0)) { goto __611 } - Xsqlite3VdbePreUpdateHook(tls, p, pC9, 18, zDb, pTab, (*BtreePayload)(unsafe.Pointer(bp+432 /* &x1 */)).FnKey, (*Op)(unsafe.Pointer(pOp)).Fp2) + Xsqlite3VdbePreUpdateHook(tls, p, pC9, SQLITE_INSERT, zDb, pTab, (*BtreePayload)(unsafe.Pointer(bp+432 /* &x1 */)).FnKey, (*Op)(unsafe.Pointer(pOp)).Fp2) __611: ; if !(((*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback == uintptr(0)) || ((*Table)(unsafe.Pointer(pTab)).FaCol == uintptr(0))) { @@ -69486,20 +68891,20 @@ __612: ; __610: ; - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x40) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_ISNOOP) != 0) { goto __613 } goto __8 __613: ; - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x01) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_NCHANGE) != 0) { goto __614 } (*Vdbe)(unsafe.Pointer(p)).FnChange++ __614: ; - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x20) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_LASTROWID) != 0) { goto __615 } (*Sqlite3)(unsafe.Pointer(db)).FlastRowid = (*BtreePayload)(unsafe.Pointer(bp + 432 /* &x1 */)).FnKey @@ -69509,12 +68914,12 @@ __615: (*BtreePayload)(unsafe.Pointer(bp + 432 /* &x1 */)).FpData = (*Mem)(unsafe.Pointer(pData)).Fz (*BtreePayload)(unsafe.Pointer(bp + 432 /* &x1 */)).FnData = (*Mem)(unsafe.Pointer(pData)).Fn seekResult = func() int32 { - if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x10) != 0 { + if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_USESEEKRESULT) != 0 { return (*VdbeCursor)(unsafe.Pointer(pC9)).FseekResult } return 0 }() - if !((int32((*Mem)(unsafe.Pointer(pData)).Fflags) & 0x4000) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pData)).Fflags) & MEM_Zero) != 0) { goto __616 } (*BtreePayload)(unsafe.Pointer(bp + 432 /* &x1 */)).FnZero = *(*int32)(unsafe.Pointer(pData /* &.u */)) @@ -69525,9 +68930,9 @@ __617: ; (*BtreePayload)(unsafe.Pointer(bp + 432 /* &x1 */)).FpKey = uintptr(0) rc = Xsqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC9 + 56 /* &.uc */)), bp+432, /* &x1 */ - (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (0x08 | 0x02)), seekResult) + (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (OPFLAG_APPEND | OPFLAG_SAVEPOSITION)), seekResult) (*VdbeCursor)(unsafe.Pointer(pC9)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC9)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC9)).FcacheStatus = CACHE_STALE // Invoke the update-hook if required. if !(rc != 0) { @@ -69542,10 +68947,10 @@ __618: (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Sqlite_int64))(unsafe.Pointer((db + 304 /* &.xUpdateCallback */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpUpdateArg, func() int32 { - if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x04) != 0 { - return 23 + if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_ISUPDATE) != 0 { + return SQLITE_UPDATE } - return 18 + return SQLITE_INSERT }(), zDb, (*Table)(unsafe.Pointer(pTab)).FzName, (*BtreePayload)(unsafe.Pointer(bp+432 /* &x1 */)).FnKey) __619: @@ -69603,7 +69008,7 @@ __102: zDb1 = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*VdbeCursor)(unsafe.Pointer(pC10)).FiDb)*32)).FzDbSName pTab1 = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) - if !(((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x02) != 0) && ((*VdbeCursor)(unsafe.Pointer(pC10)).FisTable != 0)) { + if !(((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_SAVEPOSITION) != 0) && ((*VdbeCursor)(unsafe.Pointer(pC10)).FisTable != 0)) { goto __622 } (*VdbeCursor)(unsafe.Pointer(pC10)).FmovetoTarget = Xsqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC10 + 56 /* &.uc */))) @@ -69623,16 +69028,16 @@ __621: Xsqlite3VdbePreUpdateHook(tls, p, pC10, func() int32 { - if (opflags & 0x04) != 0 { - return 23 + if (opflags & OPFLAG_ISUPDATE) != 0 { + return SQLITE_UPDATE } - return 9 + return SQLITE_DELETE }(), zDb1, pTab1, (*VdbeCursor)(unsafe.Pointer(pC10)).FmovetoTarget, (*Op)(unsafe.Pointer(pOp)).Fp3) __623: ; - if !((opflags & 0x40) != 0) { + if !((opflags & OPFLAG_ISNOOP) != 0) { goto __624 } goto __8 @@ -69642,7 +69047,7 @@ __624: // Only flags that can be set are SAVEPOISTION and AUXDELETE rc = Xsqlite3BtreeDelete(tls, *(*uintptr)(unsafe.Pointer(pC10 + 56 /* &.uc */)), uint8((*Op)(unsafe.Pointer(pOp)).Fp5)) - (*VdbeCursor)(unsafe.Pointer(pC10)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC10)).FcacheStatus = CACHE_STALE (*VdbeCursor)(unsafe.Pointer(pC10)).FseekResult = 0 if !(rc != 0) { goto __625 @@ -69652,14 +69057,14 @@ __625: ; // Invoke the update-hook if required. - if !((opflags & 0x01) != 0) { + if !((opflags & OPFLAG_NCHANGE) != 0) { goto __626 } (*Vdbe)(unsafe.Pointer(p)).FnChange++ - if !(((*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0) && (((*Table)(unsafe.Pointer((pTab1))).FtabFlags & U32(0x0080)) == U32(0))) { + if !(((*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0) && (((*Table)(unsafe.Pointer((pTab1))).FtabFlags & TF_WithoutRowid) == U32(0))) { goto __627 } - (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Sqlite_int64))(unsafe.Pointer((db + 304 /* &.xUpdateCallback */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpUpdateArg, 9, zDb1, (*Table)(unsafe.Pointer(pTab1)).FzName, + (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Sqlite_int64))(unsafe.Pointer((db + 304 /* &.xUpdateCallback */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpUpdateArg, SQLITE_DELETE, zDb1, (*Table)(unsafe.Pointer(pTab1)).FzName, (*VdbeCursor)(unsafe.Pointer(pC10)).FmovetoTarget) __627: @@ -69741,7 +69146,7 @@ __105: goto abort_due_to_error __630: ; - (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*8)))).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*8)))).FcacheStatus = CACHE_STALE goto __8 // Opcode: RowData P1 P2 P3 * * @@ -69788,7 +69193,7 @@ __106: // sqlite3VdbeCursorMoveto(). n3 = Xsqlite3BtreePayloadSize(tls, pCrsr3) - if !(n3 > U32(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4)))) { + if !(n3 > U32(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */))))) { goto __631 } goto too_big @@ -69805,7 +69210,7 @@ __632: if !(!((*Op)(unsafe.Pointer(pOp)).Fp3 != 0)) { goto __633 } - if !(((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & 0x1000) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0)) { + if !(((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & MEM_Ephem) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0)) { goto __634 } goto no_mem @@ -69834,7 +69239,7 @@ __107: if !((*VdbeCursor)(unsafe.Pointer(pC14)).FnullRow != 0) { goto __635 } - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Null goto __8 goto __636 __635: @@ -69844,7 +69249,7 @@ __635: *(*I64)(unsafe.Pointer(bp + 488 /* v3 */)) = (*VdbeCursor)(unsafe.Pointer(pC14)).FmovetoTarget goto __638 __637: - if !(int32((*VdbeCursor)(unsafe.Pointer(pC14)).FeCurType) == 2) { + if !(int32((*VdbeCursor)(unsafe.Pointer(pC14)).FeCurType) == CURTYPE_VTAB) { goto __639 } @@ -69873,7 +69278,7 @@ __642: if !((*VdbeCursor)(unsafe.Pointer(pC14)).FnullRow != 0) { goto __643 } - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Null goto __8 __643: ; @@ -69897,8 +69302,8 @@ __108: pC15 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*8)) (*VdbeCursor)(unsafe.Pointer(pC15)).FnullRow = U8(1) - (*VdbeCursor)(unsafe.Pointer(pC15)).FcacheStatus = U32(0) - if !(int32((*VdbeCursor)(unsafe.Pointer(pC15)).FeCurType) == 0) { + (*VdbeCursor)(unsafe.Pointer(pC15)).FcacheStatus = CACHE_STALE + if !(int32((*VdbeCursor)(unsafe.Pointer(pC15)).FeCurType) == CURTYPE_BTREE) { goto __644 } @@ -69935,7 +69340,7 @@ __110: pCrsr4 = *(*uintptr)(unsafe.Pointer(pC16 + 56 /* &.uc */)) *(*int32)(unsafe.Pointer(bp + 496 /* res7 */)) = 0 - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 129) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_SeekEnd) { goto __645 } @@ -69951,7 +69356,7 @@ __645: rc = Xsqlite3BtreeLast(tls, pCrsr4, bp+496 /* &res7 */) (*VdbeCursor)(unsafe.Pointer(pC16)).FnullRow = U8(*(*int32)(unsafe.Pointer(bp + 496 /* res7 */))) (*VdbeCursor)(unsafe.Pointer(pC16)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC16)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC16)).FcacheStatus = CACHE_STALE if !(rc != 0) { goto __647 } @@ -70031,9 +69436,7 @@ __653: // correctly optimizing out sorts. __112: // jump __113: // jump - *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + uintptr(2)*4))++ - // Fall through into OP_Rewind - /* no break */ + *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + 2*4))++ // Opcode: Rewind P1 P2 * * * // @@ -70052,7 +69455,7 @@ __114: pC18 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*8)) *(*int32)(unsafe.Pointer(bp + 504 /* res9 */)) = 1 - if !(int32((*VdbeCursor)(unsafe.Pointer((pC18))).FeCurType) == 1) { + if !(int32((*VdbeCursor)(unsafe.Pointer((pC18))).FeCurType) == CURTYPE_SORTER) { goto __654 } rc = Xsqlite3VdbeSorterRewind(tls, pC18, bp+504 /* &res9 */) @@ -70063,7 +69466,7 @@ __654: rc = Xsqlite3BtreeFirst(tls, pCrsr6, bp+504 /* &res9 */) (*VdbeCursor)(unsafe.Pointer(pC18)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC18)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC18)).FcacheStatus = CACHE_STALE __655: ; if !(rc != 0) { @@ -70156,9 +69559,9 @@ __117: // jump rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((pOp + 16 /* &.p4 */ /* &.xAdvance */))))(tls, *(*uintptr)(unsafe.Pointer(pC19 + 56 /* &.uc */)), (*Op)(unsafe.Pointer(pOp)).Fp3) next_tail: - (*VdbeCursor)(unsafe.Pointer(pC19)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC19)).FcacheStatus = CACHE_STALE - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __658 } (*VdbeCursor)(unsafe.Pointer(pC19)).FnullRow = U8(0) @@ -70166,13 +69569,13 @@ next_tail: goto jump_to_p2_and_check_for_interrupt __658: ; - if !(rc != 101) { + if !(rc != SQLITE_DONE) { goto __659 } goto abort_due_to_error __659: ; - rc = 0 + rc = SQLITE_OK (*VdbeCursor)(unsafe.Pointer(pC19)).FnullRow = U8(1) goto check_for_interrupt @@ -70209,7 +69612,7 @@ __118: pIn2 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x01) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_NCHANGE) != 0) { goto __660 } (*Vdbe)(unsafe.Pointer(p)).FnChange++ @@ -70217,7 +69620,7 @@ __660: ; rc = func() int32 { - if (int32((*Mem)(unsafe.Pointer((pIn2))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pIn2))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pIn2) } return 0 @@ -70233,15 +69636,15 @@ __661: (*BtreePayload)(unsafe.Pointer(bp + 512 /* &x2 */)).FaMem = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) (*BtreePayload)(unsafe.Pointer(bp + 512 /* &x2 */)).FnMem = U16(*(*int32)(unsafe.Pointer(pOp + 16 /* &.p4 */))) rc = Xsqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC20 + 56 /* &.uc */)), bp+512, /* &x2 */ - (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (0x08 | 0x02)), + (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (OPFLAG_APPEND | OPFLAG_SAVEPOSITION)), func() int32 { - if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x10) != 0 { + if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_USESEEKRESULT) != 0 { return (*VdbeCursor)(unsafe.Pointer(pC20)).FseekResult } return 0 }()) - (*VdbeCursor)(unsafe.Pointer(pC20)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC20)).FcacheStatus = CACHE_STALE if !(rc != 0) { goto __662 } @@ -70263,7 +69666,7 @@ __119: pIn2 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) rc = func() int32 { - if (int32((*Mem)(unsafe.Pointer((pIn2))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pIn2))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pIn2) } return 0 @@ -70317,7 +69720,7 @@ __665: if !(*(*int32)(unsafe.Pointer(bp + 584 /* res10 */)) == 0) { goto __666 } - rc = Xsqlite3BtreeDelete(tls, pCrsr7, uint8(0x04)) + rc = Xsqlite3BtreeDelete(tls, pCrsr7, BTREE_AUXDELETE) if !(rc != 0) { goto __668 } @@ -70329,14 +69732,14 @@ __666: if !((*Op)(unsafe.Pointer(pOp)).Fp5 != 0) { goto __669 } - rc = (11 | (int32(3) << 8)) + rc = (SQLITE_CORRUPT | (int32(3) << 8)) goto abort_due_to_error __669: ; __667: ; - (*VdbeCursor)(unsafe.Pointer(pC22)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC22)).FcacheStatus = CACHE_STALE (*VdbeCursor)(unsafe.Pointer(pC22)).FseekResult = 0 goto __8 @@ -70379,7 +69782,7 @@ __122: // Rowid that P1 current points to // sqlite3VbeCursorRestore() can only fail if the record has been deleted // out from under the cursor. That will never happens for an IdxRowid // or Seek opcode - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __670 } goto abort_due_to_error @@ -70391,13 +69794,13 @@ __670: } *(*I64)(unsafe.Pointer(bp + 592 /* rowid */)) = int64(0) // Not needed. Only used to silence a warning. rc = Xsqlite3VdbeIdxRowid(tls, db, *(*uintptr)(unsafe.Pointer(pC23 + 56 /* &.uc */)), bp+592 /* &rowid */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __673 } goto abort_due_to_error __673: ; - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 133) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_DeferredSeek) { goto __674 } @@ -70495,7 +69898,7 @@ __127: (*UnpackedRecord)(unsafe.Pointer(bp + 600 /* &r3 */)).FpKeyInfo = (*VdbeCursor)(unsafe.Pointer(pC25)).FpKeyInfo (*UnpackedRecord)(unsafe.Pointer(bp + 600 /* &r3 */)).FnField = U16(*(*int32)(unsafe.Pointer(pOp + 16 /* &.p4 */))) - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) < 40) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) < OP_IdxLT) { goto __678 } @@ -70510,7 +69913,7 @@ __679: *(*int32)(unsafe.Pointer(bp + 624 /* res11 */)) = 0 // Not needed. Only used to silence a warning. rc = Xsqlite3VdbeIdxKeyCompare(tls, db, pC25, bp+600 /* &r3 */, bp+624 /* &res11 */) - if !((int32((*Op)(unsafe.Pointer(pOp)).Fopcode) & 1) == (40 & 1)) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fopcode) & 1) == (OP_IdxLT & 1)) { goto __680 } @@ -70566,12 +69969,12 @@ __128: ; pOut = out2Prerelease(tls, p, pOp) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Null if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead > ((*Sqlite3)(unsafe.Pointer(db)).FnVDestroy + 1)) { goto __684 } - rc = 6 - (*Vdbe)(unsafe.Pointer(p)).FerrorAction = U8(2) + rc = SQLITE_LOCKED + (*Vdbe)(unsafe.Pointer(p)).FerrorAction = OE_Abort goto abort_due_to_error goto __685 __684: @@ -70579,7 +69982,7 @@ __684: *(*int32)(unsafe.Pointer(bp + 628 /* iMoved */)) = 0 // Not needed. Only to silence a warning. rc = Xsqlite3BtreeDropTable(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb2)*32)).FpBt, (*Op)(unsafe.Pointer(pOp)).Fp1, bp+628 /* &iMoved */) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Int *(*I64)(unsafe.Pointer(pOut /* &.u */)) = I64(*(*int32)(unsafe.Pointer(bp + 628 /* iMoved */))) if !(rc != 0) { goto __686 @@ -70660,7 +70063,7 @@ __130: ; pC26 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*8)) - if !(int32((*VdbeCursor)(unsafe.Pointer((pC26))).FeCurType) == 1) { + if !(int32((*VdbeCursor)(unsafe.Pointer((pC26))).FeCurType) == CURTYPE_SORTER) { goto __691 } Xsqlite3VdbeSorterReset(tls, db, *(*uintptr)(unsafe.Pointer(pC26 + 56 /* &.uc */))) @@ -70740,9 +70143,9 @@ __133: goto __696 } Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb3)*32)).FpSchema) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (^libc.Uint32FromInt32(0x0010)) - rc = Xsqlite3InitOne(tls, db, iDb3, (p + 168 /* &.zErrMsg */), uint32(0x0001)) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaKnownOk))) + rc = Xsqlite3InitOne(tls, db, iDb3, (p + 168 /* &.zErrMsg */), INITFLAG_AlterTable) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) libc.SetBitFieldPtr16Uint32(p+200 /* &.expired */, Bft(0), 0, 0x3) goto __697 __696: @@ -70759,24 +70162,24 @@ __696: if !(zSql == uintptr(0)) { goto __698 } - rc = 7 + rc = SQLITE_NOMEM goto __699 __698: ; (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy = U8(1) - (*InitData)(unsafe.Pointer(bp + 640 /* &initData */)).Frc = 0 + (*InitData)(unsafe.Pointer(bp + 640 /* &initData */)).Frc = SQLITE_OK (*InitData)(unsafe.Pointer(bp + 640 /* &initData */)).FnInitRow = U32(0) rc = Xsqlite3_exec(tls, db, zSql, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 }{Xsqlite3InitCallback})), bp+640 /* &initData */, uintptr(0)) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __700 } rc = (*InitData)(unsafe.Pointer(bp + 640 /* &initData */)).Frc __700: ; - if !((rc == 0) && ((*InitData)(unsafe.Pointer(bp+640 /* &initData */)).FnInitRow == U32(0))) { + if !((rc == SQLITE_OK) && ((*InitData)(unsafe.Pointer(bp+640 /* &initData */)).FnInitRow == U32(0))) { goto __701 } // The OP_ParseSchema opcode with a non-NULL P4 argument should parse @@ -70795,7 +70198,7 @@ __697: goto __702 } Xsqlite3ResetAllSchemasOfConnection(tls, db) - if !(rc == 7) { + if !(rc == SQLITE_NOMEM) { goto __703 } goto no_mem @@ -70886,7 +70289,7 @@ __138: // Register keeping track of errors remaining pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - z = Xsqlite3BtreeIntegrityCheck(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr((*Op)(unsafe.Pointer(pOp)).Fp5)*32)).FpBt, (aRoot + uintptr(1)*4), nRoot, + z = Xsqlite3BtreeIntegrityCheck(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr((*Op)(unsafe.Pointer(pOp)).Fp5)*32)).FpBt, (aRoot + 1*4), nRoot, (int32(*(*I64)(unsafe.Pointer(pnErr /* &.u */))) + 1), bp+680 /* &nErr */) Xsqlite3VdbeMemSetNull(tls, pIn1) if !(*(*int32)(unsafe.Pointer(bp + 680 /* nErr */)) == 0) { @@ -70902,7 +70305,7 @@ __705: goto __708 __707: *(*I64)(unsafe.Pointer(pnErr /* &.u */ /* &.i */)) -= (I64(*(*int32)(unsafe.Pointer(bp + 680 /* nErr */)) - 1)) - Xsqlite3VdbeMemSetStr(tls, pIn1, z, -1, uint8(1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) + Xsqlite3VdbeMemSetStr(tls, pIn1, z, -1, SQLITE_UTF8, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) __708: ; __706: @@ -70922,7 +70325,7 @@ __139: // in1, in2 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) pIn2 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0010) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Blob) == 0) { goto __709 } if !(Xsqlite3VdbeMemSetRowSet(tls, pIn1) != 0) { @@ -70948,7 +70351,7 @@ __140: pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - if !(((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0010) == 0) || + if !(((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Blob) == 0) || (Xsqlite3RowSetNext(tls, (*Mem)(unsafe.Pointer(pIn1)).Fz, bp+688 /* &val */) == 0)) { goto __711 } @@ -70995,7 +70398,7 @@ __141: // If there is anything other than a rowset object in memory cell P1, // delete it now and initialize P1 with an empty rowset - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0010) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Blob) == 0) { goto __713 } if !(Xsqlite3VdbeMemSetRowSet(tls, pIn1) != 0) { @@ -71083,10 +70486,10 @@ __722: __718: ; - if !((*Vdbe)(unsafe.Pointer(p)).FnFrame >= *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(10)*4))) { + if !((*Vdbe)(unsafe.Pointer(p)).FnFrame >= *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 10*4))) { goto __723 } - rc = 1 + rc = SQLITE_ERROR Xsqlite3VdbeError(tls, p, ts+4837 /* "too many levels ..." */, 0) goto abort_due_to_error __723: @@ -71096,7 +70499,7 @@ __723: // of the current program, and the memory required at runtime to execute // the trigger program. If this trigger has been fired before, then pRt // is already allocated. Otherwise, it must be initialized. - if !((int32((*Mem)(unsafe.Pointer(pRt)).Fflags) & 0x0010) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pRt)).Fflags) & MEM_Blob) == 0) { goto __724 } // SubProgram.nMem is set to the number of memory cells used by the @@ -71111,7 +70514,7 @@ __723: nMem++ __726: ; - nByte2 = (int32((((((uint64(unsafe.Sizeof(VdbeFrame{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)) + + nByte2 = (int32((((((uint64(unsafe.Sizeof(VdbeFrame{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))) + (uint64(nMem) * uint64(unsafe.Sizeof(Mem{})))) + (uint64((*SubProgram)(unsafe.Pointer(pProgram)).FnCsr) * uint64(unsafe.Sizeof(uintptr(0))))) + (uint64(((*SubProgram)(unsafe.Pointer(pProgram)).FnOp + 7) / 8)))) @@ -71123,7 +70526,7 @@ __726: __727: ; Xsqlite3VdbeMemRelease(tls, pRt) - (*Mem)(unsafe.Pointer(pRt)).Fflags = (U16(0x0010 | 0x0400)) + (*Mem)(unsafe.Pointer(pRt)).Fflags = (U16(MEM_Blob | MEM_Dyn)) (*Mem)(unsafe.Pointer(pRt)).Fz = pFrame2 (*Mem)(unsafe.Pointer(pRt)).Fn = nByte2 (*Mem)(unsafe.Pointer(pRt)).FxDel = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3VdbeFrameMemDel})) @@ -71140,13 +70543,13 @@ __727: (*VdbeFrame)(unsafe.Pointer(pFrame2)).FnOp = (*Vdbe)(unsafe.Pointer(p)).FnOp (*VdbeFrame)(unsafe.Pointer(pFrame2)).Ftoken = (*SubProgram)(unsafe.Pointer(pProgram)).Ftoken - pEnd = (((pFrame2) + uintptr((((uint64(unsafe.Sizeof(VdbeFrame{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + uintptr((*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem)*56) - pMem2 = ((pFrame2) + uintptr((((uint64(unsafe.Sizeof(VdbeFrame{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + pEnd = (((pFrame2) + 112) + uintptr((*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem)*56) + pMem2 = ((pFrame2) + 112) __728: if !(pMem2 != pEnd) { goto __730 } - (*Mem)(unsafe.Pointer(pMem2)).Fflags = U16(0x0080) + (*Mem)(unsafe.Pointer(pMem2)).Fflags = MEM_Undefined (*Mem)(unsafe.Pointer(pMem2)).Fdb = db goto __729 __729: @@ -71172,7 +70575,7 @@ __725: (*Vdbe)(unsafe.Pointer(p)).FpAuxData = uintptr(0) (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 (*Vdbe)(unsafe.Pointer(p)).FpFrame = pFrame2 - (*Vdbe)(unsafe.Pointer(p)).FaMem = libc.AssignUintptr(&aMem, ((pFrame2) + uintptr((((uint64(unsafe.Sizeof(VdbeFrame{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))))) + (*Vdbe)(unsafe.Pointer(p)).FaMem = libc.AssignUintptr(&aMem, ((pFrame2) + 112)) (*Vdbe)(unsafe.Pointer(p)).FnMem = (*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem (*Vdbe)(unsafe.Pointer(p)).FnCursor = int32(U16((*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildCsr)) (*Vdbe)(unsafe.Pointer(p)).FapCsr = (aMem + uintptr((*Vdbe)(unsafe.Pointer(p)).FnMem)*56) @@ -71198,7 +70601,7 @@ __143: pOut = out2Prerelease(tls, p, pOp) pFrame3 = (*Vdbe)(unsafe.Pointer(p)).FpFrame pIn = ((*VdbeFrame)(unsafe.Pointer(pFrame3)).FaMem + uintptr(((*Op)(unsafe.Pointer(pOp)).Fp1+(*Op)(unsafe.Pointer((*VdbeFrame)(unsafe.Pointer(pFrame3)).FaOp+uintptr((*VdbeFrame)(unsafe.Pointer(pFrame3)).Fpc)*24)).Fp1))*56) - Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn, 0x1000) + Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn, MEM_Ephem) goto __8 // Opcode: FkCounter P1 P2 * * * @@ -71209,7 +70612,7 @@ __143: // (deferred foreign key constraints). Otherwise, if P1 is zero, the // statement counter is incremented (immediate foreign key constraints). __144: - if !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00080000)) != 0) { + if !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DeferFKs) != 0) { goto __731 } *(*I64)(unsafe.Pointer(db + 744 /* &.nDeferredImmCons */)) += (I64((*Op)(unsafe.Pointer(pOp)).Fp2)) @@ -71471,7 +70874,7 @@ __752: ; (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpMem = uintptr(0) (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut = ((pCtx + 48 /* &.argv */) + uintptr(n4)*8) - Xsqlite3VdbeMemInit(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, db, uint16(0x0001)) + Xsqlite3VdbeMemInit(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, db, MEM_Null) (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpFunc = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) (*Sqlite3_context)(unsafe.Pointer(pCtx)).FiOp = (int32((int64(pOp) - int64(aOp)) / 24)) (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe = p @@ -71483,9 +70886,7 @@ __752: // OP_AggInverse must have P1==1 and OP_AggStep must have P1==0 - (*Op)(unsafe.Pointer(pOp)).Fopcode = U8(155) - // Fall through into OP_AggStep - /* no break */ + (*Op)(unsafe.Pointer(pOp)).Fopcode = OP_AggStep1 __153: ; @@ -71553,7 +70954,7 @@ __762: __761: ; Xsqlite3VdbeMemRelease(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpOut) - (*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpOut)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpOut)).Fflags = MEM_Null (*Sqlite3_context)(unsafe.Pointer(pCtx1)).FisError = 0 if !(rc != 0) { goto __763 @@ -71639,21 +71040,21 @@ __767: __156: // Write results here ; - *(*int32)(unsafe.Pointer(bp + 704 /* &aRes[0] */ + uintptr(0)*4)) = 0 - *(*int32)(unsafe.Pointer(bp + 704 /* &aRes[0] */ + uintptr(1)*4)) = libc.AssignPtrInt32(bp+704 /* &aRes */ +uintptr(2)*4, -1) + *(*int32)(unsafe.Pointer(bp + 704 /* &aRes[0] */)) = 0 + *(*int32)(unsafe.Pointer(bp + 704 /* &aRes[0] */ + 1*4)) = libc.AssignPtrInt32(bp+704 /* &aRes */ +2*4, -1) - rc = Xsqlite3Checkpoint(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, (bp + 704 /* &aRes */ + uintptr(1)*4), (bp + 704 /* &aRes */ + uintptr(2)*4)) + rc = Xsqlite3Checkpoint(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, (bp + 704 /* &aRes */ + 1*4), (bp + 704 /* &aRes */ + 2*4)) if !(rc != 0) { goto __768 } - if !(rc != 5) { + if !(rc != SQLITE_BUSY) { goto __769 } goto abort_due_to_error __769: ; - rc = 0 - *(*int32)(unsafe.Pointer(bp + 704 /* &aRes[0] */ + uintptr(0)*4)) = 1 + rc = SQLITE_OK + *(*int32)(unsafe.Pointer(bp + 704 /* &aRes[0] */)) = 1 __768: ; i5 = 0 @@ -71708,7 +71109,7 @@ __774: // Do not allow a transition to journal_mode=WAL for a database // in temporary storage or if the VFS does not support shared memory - if !((eNew == 5) && + if !((eNew == PAGER_JOURNALMODE_WAL) && ((Xsqlite3Strlen30(tls, zFilename) == 0) || // Temp file !(Xsqlite3PagerWalSupported(tls, pPager) != 0))) { goto __775 @@ -71718,17 +71119,17 @@ __775: ; if !((eNew != eOld) && - ((eOld == 5) || (eNew == 5))) { + ((eOld == PAGER_JOURNALMODE_WAL) || (eNew == PAGER_JOURNALMODE_WAL))) { goto __776 } if !(!(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead > 1)) { goto __777 } - rc = 1 + rc = SQLITE_ERROR Xsqlite3VdbeError(tls, p, ts+4874, /* "cannot change %s..." */ libc.VaList(bp+104, func() uintptr { - if eNew == 5 { + if eNew == PAGER_JOURNALMODE_WAL { return ts + 4926 /* "into" */ } return ts + 4931 /* "out of" */ @@ -71737,7 +71138,7 @@ __775: goto __778 __777: - if !(eOld == 5) { + if !(eOld == PAGER_JOURNALMODE_WAL) { goto __779 } // If leaving WAL mode, close the log file. If successful, the call @@ -71745,7 +71146,7 @@ __777: // file. An EXCLUSIVE lock may still be held on the database file // after a successful return. rc = Xsqlite3PagerCloseWal(tls, pPager, db) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __781 } Xsqlite3PagerSetJournalMode(tls, pPager, eNew) @@ -71753,12 +71154,12 @@ __781: ; goto __780 __779: - if !(eOld == 4) { + if !(eOld == PAGER_JOURNALMODE_MEMORY) { goto __782 } // Cannot transition directly from MEMORY to WAL. Use mode OFF // as an intermediate - Xsqlite3PagerSetJournalMode(tls, pPager, 2) + Xsqlite3PagerSetJournalMode(tls, pPager, PAGER_JOURNALMODE_OFF) __782: ; __780: @@ -71767,11 +71168,11 @@ __780: // Open a transaction on the database file. Regardless of the journal // mode, this transaction always uses a rollback journal. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __783 } rc = Xsqlite3BtreeSetVersion(tls, pBt1, func() int32 { - if eNew == 5 { + if eNew == PAGER_JOURNALMODE_WAL { return 2 } return 1 @@ -71791,10 +71192,10 @@ __784: ; eNew = Xsqlite3PagerSetJournalMode(tls, pPager, eNew) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((0x0002 | 0x0800) | 0x0200)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((MEM_Str | MEM_Static) | MEM_Term)) (*Mem)(unsafe.Pointer(pOut)).Fz = Xsqlite3JournalModename(tls, eNew) (*Mem)(unsafe.Pointer(pOut)).Fn = Xsqlite3Strlen30(tls, (*Mem)(unsafe.Pointer(pOut)).Fz) - (*Mem)(unsafe.Pointer(pOut)).Fenc = U8(1) + (*Mem)(unsafe.Pointer(pOut)).Fenc = SQLITE_UTF8 Xsqlite3VdbeChangeEncoding(tls, pOut, int32(encoding)) if !(rc != 0) { goto __785 @@ -71843,13 +71244,13 @@ __159: if !(rc != 0) { goto __787 } - if !(rc != 101) { + if !(rc != SQLITE_DONE) { goto __788 } goto abort_due_to_error __788: ; - rc = 0 + rc = SQLITE_OK goto jump_to_p2 __787: ; @@ -71921,7 +71322,7 @@ __162: // used to generate an error message if the lock cannot be obtained. __163: isWriteLock = U8((*Op)(unsafe.Pointer(pOp)).Fp3) - if !((isWriteLock != 0) || (uint64(0) == ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000400)))) { + if !((isWriteLock != 0) || (uint64(0) == ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ReadUncommit))) { goto __791 } p13 = (*Op)(unsafe.Pointer(pOp)).Fp1 @@ -71930,7 +71331,7 @@ __163: if !(rc != 0) { goto __792 } - if !((rc & 0xFF) == 6) { + if !((rc & 0xFF) == SQLITE_LOCKED) { goto __793 } z1 = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) @@ -72029,7 +71430,7 @@ __167: if !((pVtab1 == uintptr(0)) || ((*Sqlite3_vtab)(unsafe.Pointer(pVtab1)).FpModule == uintptr(0))) { goto __799 } - rc = 6 + rc = SQLITE_LOCKED goto abort_due_to_error __799: ; @@ -72047,7 +71448,7 @@ __800: (*Sqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 776 /* pVCur */)))).FpVtab = pVtab1 // Initialize vdbe cursor object - pCur1 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, 0, -1, uint8(2)) + pCur1 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, 0, -1, CURTYPE_VTAB) if !(pCur1 != 0) { goto __801 } @@ -72083,7 +71484,7 @@ __802: __168: pQuery = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) - pArgc = (pQuery + uintptr(1)*56) + pArgc = (pQuery + 1*56) pCur2 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*8)) pVCur1 = *(*uintptr)(unsafe.Pointer(pCur2 + 56 /* &.uc */)) @@ -72162,15 +71563,15 @@ __808: libc.Xmemset(tls, bp+784 /* &sContext */, 0, uint64(unsafe.Sizeof(Sqlite3_context{}))) (*Sqlite3_context)(unsafe.Pointer(bp + 784 /* &sContext */)).FpOut = pDest1 - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x01) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_NOCHNG) != 0) { goto __809 } Xsqlite3VdbeMemSetNull(tls, pDest1) - (*Mem)(unsafe.Pointer(pDest1)).Fflags = (U16(0x0001 | 0x4000)) + (*Mem)(unsafe.Pointer(pDest1)).Fflags = (U16(MEM_Null | MEM_Zero)) *(*int32)(unsafe.Pointer(pDest1 /* &.u */)) = 0 goto __810 __809: - (*Mem)(unsafe.Pointer(pDest1)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pDest1))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0001)) + (*Mem)(unsafe.Pointer(pDest1)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pDest1))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Null)) __810: ; rc = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pModule3 + 88 /* &.xColumn */))))(tls, *(*uintptr)(unsafe.Pointer(pCur3 + 56 /* &.uc */)), bp+784 /* &sContext */, (*Op)(unsafe.Pointer(pOp)).Fp2) @@ -72248,12 +71649,12 @@ __816: // in register P1 is passed as the zName argument to the xRename method. __171: - isLegacy = (int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x04000000))) - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(0x04000000)) + isLegacy = (int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_LegacyAlter)) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (SQLITE_LegacyAlter) pVtab5 = (*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)))).FpVtab pName = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - rc = Xsqlite3VdbeChangeEncoding(tls, pName, 1) + rc = Xsqlite3VdbeChangeEncoding(tls, pName, SQLITE_UTF8) if !(rc != 0) { goto __817 } @@ -72264,7 +71665,7 @@ __817: if !(isLegacy == 0) { goto __818 } - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x04000000))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_LegacyAlter)) __818: ; Xsqlite3VtabImportErrmsg(tls, p, pVtab5) @@ -72317,7 +71718,7 @@ __820: if !((pVtab6 == uintptr(0)) || ((*Sqlite3_vtab)(unsafe.Pointer(pVtab6)).FpModule == uintptr(0))) { goto __821 } - rc = 6 + rc = SQLITE_LOCKED goto abort_due_to_error __821: ; @@ -72349,25 +71750,25 @@ __825: rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pModule5 + 104 /* &.xUpdate */))))(tls, pVtab6, nArg1, apArg1, bp+840 /* &rowid1 */) (*Sqlite3)(unsafe.Pointer(db)).FvtabOnConflict = vtabOnConflict Xsqlite3VtabImportErrmsg(tls, p, pVtab6) - if !((rc == 0) && ((*Op)(unsafe.Pointer(pOp)).Fp1 != 0)) { + if !((rc == SQLITE_OK) && ((*Op)(unsafe.Pointer(pOp)).Fp1 != 0)) { goto __826 } (*Sqlite3)(unsafe.Pointer(db)).FlastRowid = *(*Sqlite_int64)(unsafe.Pointer(bp + 840 /* rowid1 */)) __826: ; - if !(((rc & 0xff) == 19) && ((*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)))).FbConstraint != 0)) { + if !(((rc & 0xff) == SQLITE_CONSTRAINT) && ((*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)))).FbConstraint != 0)) { goto __827 } - if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5) == 4) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5) == OE_Ignore) { goto __829 } - rc = 0 + rc = SQLITE_OK goto __830 __829: (*Vdbe)(unsafe.Pointer(p)).FerrorAction = func() uint8 { - if int32((*Op)(unsafe.Pointer(pOp)).Fp5) == 5 { - return uint8(2) + if int32((*Op)(unsafe.Pointer(pOp)).Fp5) == OE_Replace { + return OE_Abort } return uint8((*Op)(unsafe.Pointer(pOp)).Fp5) }() @@ -72498,7 +71899,7 @@ __837: __834: ; - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0001)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Null)) (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(((*Sqlite3_context)(unsafe.Pointer(pCtx2)).FpFunc + 24 /* &.xSFunc */))))(tls, pCtx2, int32((*Sqlite3_context)(unsafe.Pointer(pCtx2)).Fargc), pCtx2+48 /* &.argv */) // IMP: R-24505-23230 @@ -72525,7 +71926,7 @@ __838: ; // Copy the result of the function into register P3 - if !((int32((*Mem)(unsafe.Pointer(pOut)).Fflags) & (0x0002 | 0x0010)) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pOut)).Fflags) & (MEM_Str | MEM_Blob)) != 0) { goto __841 } Xsqlite3VdbeChangeEncoding(tls, pOut, int32(encoding)) @@ -72578,7 +71979,7 @@ __178: // OP_Init is always instruction 0 - if !((((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & (0x01 | 0x40)) != 0) && + if !((((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & (SQLITE_TRACE_STMT | SQLITE_TRACE_LEGACY)) != 0) && !(int32((*Vdbe)(unsafe.Pointer(p)).FdoingRerun) != 0)) && ((libc.AssignUintptr(&zTrace, func() uintptr { if *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) != 0 { @@ -72588,7 +71989,7 @@ __178: }())) != uintptr(0))) { goto __843 } - if !((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & 0x40) != 0) { + if !((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & SQLITE_TRACE_LEGACY) != 0) { goto __844 } z2 = Xsqlite3VdbeExpandSql(tls, p, zTrace) @@ -72600,11 +72001,11 @@ __844: goto __846 } z3 = Xsqlite3MPrintf(tls, db, ts+4967 /* "-- %s" */, libc.VaList(bp+136, zTrace)) - (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, uint32(0x01), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, z3) + (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, SQLITE_TRACE_STMT, (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, z3) Xsqlite3DbFree(tls, db, z3) goto __847 __846: - (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, uint32(0x01), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, zTrace) + (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, SQLITE_TRACE_STMT, (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, zTrace) __847: ; __845: @@ -72615,7 +72016,7 @@ __843: if !((*Op)(unsafe.Pointer(pOp)).Fp1 >= Xsqlite3Config.FiOnceResetThreshold) { goto __848 } - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 170) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_Trace) { goto __849 } goto __8 @@ -72626,7 +72027,7 @@ __850: if !(i9 < (*Vdbe)(unsafe.Pointer(p)).FnOp) { goto __852 } - if !(int32((*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp+uintptr(i9)*24)).Fopcode) == 17) { + if !(int32((*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp+uintptr(i9)*24)).Fopcode) == OP_Once) { goto __853 } (*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(i9)*24)).Fp1 = 0 @@ -72643,7 +72044,7 @@ __852: __848: ; (*Op)(unsafe.Pointer(pOp)).Fp1++ - *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + uintptr(6)*4))++ + *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + 6*4))++ goto jump_to_p2 // Opcode: Noop * * * * * @@ -72687,11 +72088,11 @@ abort_due_to_error: if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __854 } - rc = 7 + rc = SQLITE_NOMEM __854: ; - if !(((*Vdbe)(unsafe.Pointer(p)).FzErrMsg == uintptr(0)) && (rc != (10 | (int32(12) << 8)))) { + if !(((*Vdbe)(unsafe.Pointer(p)).FzErrMsg == uintptr(0)) && (rc != (SQLITE_IOERR | (int32(12) << 8)))) { goto __855 } Xsqlite3VdbeError(tls, p, ts+2690 /* "%s" */, libc.VaList(bp+144, Xsqlite3ErrStr(tls, rc))) @@ -72703,13 +72104,13 @@ __855: Xsqlite3_log(tls, rc, ts+4973, /* "statement aborts..." */ libc.VaList(bp+152, (int32((int64(pOp)-int64(aOp))/24)), (*Vdbe)(unsafe.Pointer(p)).FzSql, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg)) Xsqlite3VdbeHalt(tls, p) - if !(rc == (10 | (int32(12) << 8))) { + if !(rc == (SQLITE_IOERR | (int32(12) << 8))) { goto __856 } Xsqlite3OomFault(tls, db) __856: ; - rc = 1 + rc = SQLITE_ERROR if !(int32(resetSchemaOnFault) > 0) { goto __857 } @@ -72730,14 +72131,14 @@ __858: goto __860 } nProgressLimit = (uint64(0xffffffff) | (U64((uint64(0xffffffff))) << 32)) - rc = 9 + rc = SQLITE_INTERRUPT goto abort_due_to_error __860: ; goto __858 __859: ; - *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + uintptr(4)*4)) += (U32(int32(nVmStep))) + *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + 4*4)) += (U32(int32(nVmStep))) Xsqlite3VdbeLeave(tls, p) return rc @@ -72746,34 +72147,34 @@ __859: // is encountered. too_big: Xsqlite3VdbeError(tls, p, ts+4289 /* "string or blob t..." */, 0) - rc = 18 + rc = SQLITE_TOOBIG goto abort_due_to_error // Jump to here if a malloc() fails. no_mem: Xsqlite3OomFault(tls, db) Xsqlite3VdbeError(tls, p, ts+5005 /* "out of memory" */, 0) - rc = 7 + rc = SQLITE_NOMEM goto abort_due_to_error // Jump to here if the sqlite3_interrupt() API sets the interrupt // flag. abort_due_to_interrupt: ; - rc = 9 + rc = SQLITE_INTERRUPT goto abort_due_to_error return int32(0) } var azType = [4]uintptr{ts + 5019 /* "NOT NULL" */, ts + 5028 /* "UNIQUE" */, ts + 5035, /* "CHECK" */ - ts + 5041 /* "FOREIGN KEY" */} /* sqlite3.c:86430:25 */ -var aLTb = [6]uint8{uint8(1), uint8(0), uint8(0), uint8(1), uint8(1), uint8(0)} /* sqlite3.c:87455:32 */ -var aEQb = [6]uint8{uint8(0), uint8(1), uint8(0), uint8(1), uint8(0), uint8(1)} /* sqlite3.c:87458:32 */ -var aGTb = [6]uint8{uint8(1), uint8(0), uint8(1), uint8(0), uint8(0), uint8(1)} /* sqlite3.c:87461:32 */ -var and_logic = [9]uint8{uint8(0), uint8(0), uint8(0), uint8(0), uint8(1), uint8(2), uint8(0), uint8(2), uint8(2)} /* sqlite3.c:87681:32 */ -var or_logic = [9]uint8{uint8(0), uint8(1), uint8(2), uint8(1), uint8(1), uint8(1), uint8(2), uint8(1), uint8(2)} /* sqlite3.c:87684:32 */ -var aFlag1 = [2]U16{U16(0x0010), (U16(0x0002 | 0x0200))} /* sqlite3.c:88134:24 */ -var vfsFlags int32 = ((((0x00000002 | 0x00000004) | 0x00000010) | 0x00000008) | 0x00000400) /* sqlite3.c:89263:20 */ + ts + 5041 /* "FOREIGN KEY" */} /* sqlite3.c:86430:25 */ +var aLTb = [6]uint8{uint8(1), uint8(0), uint8(0), uint8(1), uint8(1), uint8(0)} /* sqlite3.c:87455:32 */ +var aEQb = [6]uint8{uint8(0), uint8(1), uint8(0), uint8(1), uint8(0), uint8(1)} /* sqlite3.c:87458:32 */ +var aGTb = [6]uint8{uint8(1), uint8(0), uint8(1), uint8(0), uint8(0), uint8(1)} /* sqlite3.c:87461:32 */ +var and_logic = [9]uint8{uint8(0), uint8(0), uint8(0), uint8(0), uint8(1), uint8(2), uint8(0), uint8(2), uint8(2)} /* sqlite3.c:87681:32 */ +var or_logic = [9]uint8{uint8(0), uint8(1), uint8(2), uint8(1), uint8(1), uint8(1), uint8(2), uint8(1), uint8(2)} /* sqlite3.c:87684:32 */ +var aFlag1 = [2]U16{MEM_Blob, (U16(MEM_Str | MEM_Term))} /* sqlite3.c:88134:24 */ +var vfsFlags int32 = ((((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_DELETEONCLOSE) | SQLITE_OPEN_TRANSIENT_DB) /* sqlite3.c:89263:20 */ //************* End of vdbe.c *********************************************** //************* Begin file vdbeblob.c *************************************** @@ -72852,8 +72253,8 @@ func blobSeekToRow(tls *libc.TLS, p uintptr, iRow Sqlite3_int64, pzErr uintptr) // Set the value of register r[1] in the SQL statement to integer iRow. // This is done directly as a performance optimization - (*Mem)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + uintptr(1)*56)).Fflags = U16(0x0004) - *(*I64)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + uintptr(1)*56 /* &.u */)) = iRow + (*Mem)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + 1*56)).Fflags = MEM_Int + *(*I64)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + 1*56 /* &.u */)) = iRow // If the statement has been run before (and is paused at the OP_ResultRow) // then back it up to the point where it does the OP_NotExists. This could @@ -72866,8 +72267,8 @@ func blobSeekToRow(tls *libc.TLS, p uintptr, iRow Sqlite3_int64, pzErr uintptr) } else { rc = Xsqlite3_step(tls, (*Incrblob)(unsafe.Pointer(p)).FpStmt) } - if rc == 100 { - var pC uintptr = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FapCsr + uintptr(0)*8)) + if rc == SQLITE_ROW { + var pC uintptr = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FapCsr)) var type1 U32 if int32((*VdbeCursor)(unsafe.Pointer(pC)).FnHdrParsed) > int32((*Incrblob)(unsafe.Pointer(p)).FiCol) { type1 = *(*U32)(unsafe.Pointer((pC + 120 /* &.aType */) + uintptr((*Incrblob)(unsafe.Pointer(p)).FiCol)*4)) @@ -72888,7 +72289,7 @@ func blobSeekToRow(tls *libc.TLS, p uintptr, iRow Sqlite3_int64, pzErr uintptr) return ts + 5092 /* "integer" */ }() }())) - rc = 1 + rc = SQLITE_ERROR Xsqlite3_finalize(tls, (*Incrblob)(unsafe.Pointer(p)).FpStmt) (*Incrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0) } else { @@ -72899,14 +72300,14 @@ func blobSeekToRow(tls *libc.TLS, p uintptr, iRow Sqlite3_int64, pzErr uintptr) } } - if rc == 100 { - rc = 0 + if rc == SQLITE_ROW { + rc = SQLITE_OK } else if (*Incrblob)(unsafe.Pointer(p)).FpStmt != 0 { rc = Xsqlite3_finalize(tls, (*Incrblob)(unsafe.Pointer(p)).FpStmt) (*Incrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0) - if rc == 0 { + if rc == SQLITE_OK { zErr = Xsqlite3MPrintf(tls, (*Incrblob)(unsafe.Pointer(p)).Fdb, ts+5100 /* "no such rowid: %..." */, libc.VaList(bp+8, iRow)) - rc = 1 + rc = SQLITE_ERROR } else { zErr = Xsqlite3MPrintf(tls, (*Incrblob)(unsafe.Pointer(p)).Fdb, ts+2690 /* "%s" */, libc.VaList(bp+16, Xsqlite3_errmsg(tls, (*Incrblob)(unsafe.Pointer(p)).Fdb))) } @@ -72943,7 +72344,7 @@ func Xsqlite3_blob_open(tls *libc.TLS, db uintptr, zDb uintptr, zTable uintptr, var iDb int32 var aOp uintptr nAttempt = 0 - rc = 0 + rc = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp + 472 /* zErr */)) = uintptr(0) pBlob = uintptr(0) @@ -72974,7 +72375,7 @@ __4: Xsqlite3ErrorMsg(tls, bp+48 /* &sParse */, ts+5120 /* "cannot open virt..." */, libc.VaList(bp, zTable)) __5: ; - if !((pTab != 0) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) { + if !((pTab != 0) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) { goto __6 } pTab = uintptr(0) @@ -72999,7 +72400,7 @@ __7: (*Parse)(unsafe.Pointer(bp + 48 /* &sParse */)).FzErrMsg = uintptr(0) __9: ; - rc = 1 + rc = SQLITE_ERROR Xsqlite3BtreeLeaveAll(tls, db) goto blob_open_out __8: @@ -73031,7 +72432,7 @@ __12: } Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 472 /* zErr */))) *(*uintptr)(unsafe.Pointer(bp + 472 /* zErr */)) = Xsqlite3MPrintf(tls, db, ts+5207 /* "no such column: ..." */, libc.VaList(bp+24, zColumn)) - rc = 1 + rc = SQLITE_ERROR Xsqlite3BtreeLeaveAll(tls, db) goto blob_open_out __14: @@ -73043,7 +72444,7 @@ __14: goto __15 } zFault = uintptr(0) - if !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00004000)) != 0) { + if !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ForeignKeys) != 0) { goto __16 } pFKey = (*Table)(unsafe.Pointer(pTab)).FpFKey @@ -73114,7 +72515,7 @@ __26: } Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 472 /* zErr */))) *(*uintptr)(unsafe.Pointer(bp + 472 /* zErr */)) = Xsqlite3MPrintf(tls, db, ts+5248 /* "cannot open %s c..." */, libc.VaList(bp+32, zFault)) - rc = 1 + rc = SQLITE_ERROR Xsqlite3BtreeLeaveAll(tls, db) goto blob_open_out __31: @@ -73130,7 +72531,7 @@ __15: v = (*Incrblob)(unsafe.Pointer(pBlob)).FpStmt iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) - Xsqlite3VdbeAddOp4Int(tls, v, 2, iDb, wrFlag, + Xsqlite3VdbeAddOp4Int(tls, v, OP_Transaction, iDb, wrFlag, (*Schema)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FpSchema)).Fschema_cookie, (*Schema)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FpSchema)).FiGeneration) Xsqlite3VdbeChangeP5(tls, v, uint16(1)) @@ -73145,10 +72546,10 @@ __15: } // Configure the OP_TableLock instruction - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*24)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*24)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).Ftnum) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*24)).Fp3 = wrFlag - Xsqlite3VdbeChangeP4(tls, v, 2, (*Table)(unsafe.Pointer(pTab)).FzName, 0) + (*VdbeOp)(unsafe.Pointer(aOp)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).Ftnum) + (*VdbeOp)(unsafe.Pointer(aOp)).Fp3 = wrFlag + Xsqlite3VdbeChangeP4(tls, v, 2, (*Table)(unsafe.Pointer(pTab)).FzName, P4_TRANSIENT) __33: ; if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0) { @@ -73160,11 +72561,11 @@ __33: if !(wrFlag != 0) { goto __35 } - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(1)*24)).Fopcode = U8(97) + (*VdbeOp)(unsafe.Pointer(aOp + 1*24)).Fopcode = OP_OpenWrite __35: ; - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(1)*24)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).Ftnum) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(1)*24)).Fp3 = iDb + (*VdbeOp)(unsafe.Pointer(aOp + 1*24)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).Ftnum) + (*VdbeOp)(unsafe.Pointer(aOp + 1*24)).Fp3 = iDb // Configure the number of columns. Configure the cursor to // think that the table has one more column than it really @@ -73172,9 +72573,9 @@ __35: // always return an SQL NULL. This is useful because it means // we can invoke OP_Column to fill in the vdbe cursors type // and offset cache without causing any IO. - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(1)*24)).Fp4type = int8(-3) - *(*int32)(unsafe.Pointer(aOp + uintptr(1)*24 + 16 /* &.p4 */)) = (int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*24)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).FnCol) + (*VdbeOp)(unsafe.Pointer(aOp + 1*24)).Fp4type = int8(-3) + *(*int32)(unsafe.Pointer(aOp + 1*24 + 16 /* &.p4 */)) = (int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 1) + (*VdbeOp)(unsafe.Pointer(aOp + 3*24)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).FnCol) (*Parse)(unsafe.Pointer(bp + 48 /* &sParse */)).FnVar = int16(0) (*Parse)(unsafe.Pointer(bp + 48 /* &sParse */)).FnMem = 1 @@ -73197,7 +72598,7 @@ __36: rc = blobSeekToRow(tls, pBlob, iRow, bp+472 /* &zErr */) goto __2 __2: - if ((libc.PreIncInt32(&nAttempt, 1)) < 50) && (rc == 17) { + if ((libc.PreIncInt32(&nAttempt, 1)) < SQLITE_MAX_SCHEMA_RETRY) && (rc == SQLITE_SCHEMA) { goto __1 } goto __3 @@ -73205,7 +72606,7 @@ __3: ; blob_open_out: - if !((rc == 0) && (int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0)) { + if !((rc == SQLITE_OK) && (int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0)) { goto __37 } *(*uintptr)(unsafe.Pointer(ppBlob)) = pBlob @@ -73235,37 +72636,13 @@ __38: var iLn int32 = 0 /* sqlite3.c:93635:24 */ var openBlob = [6]VdbeOpList{ - { - Fopcode: U8(161), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 0: Acquire a read or write lock - { - Fopcode: U8(96), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 1: Open a cursor + {Fopcode: OP_TableLock}, // 0: Acquire a read or write lock + {Fopcode: OP_OpenRead}, // 1: Open a cursor // blobSeekToRow() will initialize r[1] to the desired rowid - { - Fopcode: U8(32), - Fp1: int8(0), - Fp2: int8(5), - Fp3: int8(1)}, // 2: Seek the cursor to rowid=r[1] - { - Fopcode: U8(89), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(1)}, // 3 - { - Fopcode: U8(80), - Fp1: int8(1), - Fp2: int8(0), - Fp3: int8(0)}, // 4 - { - Fopcode: U8(68), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 5 + {Fopcode: OP_NotExists, Fp2: int8(5), Fp3: int8(1)}, // 2: Seek the cursor to rowid=r[1] + {Fopcode: OP_Column, Fp3: int8(1)}, // 3 + {Fopcode: OP_ResultRow, Fp1: int8(1)}, // 4 + {Fopcode: OP_Halt}, // 5 } /* sqlite3.c:93636:31 */ // Close a blob handle that was previously created using @@ -73283,7 +72660,7 @@ func Xsqlite3_blob_close(tls *libc.TLS, pBlob uintptr) int32 { /* sqlite3.c:9372 Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) rc = Xsqlite3_finalize(tls, pStmt) } else { - rc = 0 + rc = SQLITE_OK } return rc } @@ -73304,11 +72681,11 @@ func blobReadWrite(tls *libc.TLS, pBlob uintptr, z uintptr, n int32, iOffset int if ((n < 0) || (iOffset < 0)) || ((Sqlite3_int64(iOffset) + Sqlite3_int64(n)) > Sqlite3_int64((*Incrblob)(unsafe.Pointer(p)).FnByte)) { // Request is out of range. Return a transient error. - rc = 1 + rc = SQLITE_ERROR } else if v == uintptr(0) { // If there is no statement handle, then the blob-handle has // already been invalidated. Return SQLITE_ABORT in this case. - rc = 4 + rc = SQLITE_ABORT } else { // Call either BtreeData() or BtreePutData(). If SQLITE_ABORT is // returned, clean-up the statement handle. @@ -73333,12 +72710,12 @@ func blobReadWrite(tls *libc.TLS, pBlob uintptr, z uintptr, n int32, iOffset int var iKey Sqlite3_int64 iKey = Xsqlite3BtreeIntegerKey(tls, (*Incrblob)(unsafe.Pointer(p)).FpCsr) Xsqlite3VdbePreUpdateHook(tls, - v, *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FapCsr + uintptr(0)*8)), 9, (*Incrblob)(unsafe.Pointer(p)).FzDb, (*Incrblob)(unsafe.Pointer(p)).FpTab, iKey, -1) + v, *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FapCsr)), SQLITE_DELETE, (*Incrblob)(unsafe.Pointer(p)).FzDb, (*Incrblob)(unsafe.Pointer(p)).FpTab, iKey, -1) } rc = (*(*func(*libc.TLS, uintptr, U32, U32, uintptr) int32)(unsafe.Pointer(&xCall)))(tls, (*Incrblob)(unsafe.Pointer(p)).FpCsr, (uint32(iOffset + (*Incrblob)(unsafe.Pointer(p)).FiOffset)), uint32(n), z) Xsqlite3BtreeLeaveCursor(tls, (*Incrblob)(unsafe.Pointer(p)).FpCsr) - if rc == 4 { + if rc == SQLITE_ABORT { Xsqlite3VdbeFinalize(tls, v) (*Incrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0) } else { @@ -73402,12 +72779,12 @@ func Xsqlite3_blob_reopen(tls *libc.TLS, pBlob uintptr, iRow Sqlite3_int64) int3 if (*Incrblob)(unsafe.Pointer(p)).FpStmt == uintptr(0) { // If there is no statement handle, then the blob-handle has // already been invalidated. Return SQLITE_ABORT in this case. - rc = 4 + rc = SQLITE_ABORT } else { // var zErr uintptr at bp+8, 8 rc = blobSeekToRow(tls, p, iRow, bp+8 /* &zErr */) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3ErrorWithMsg(tls, db, rc, func() uintptr { if *(*uintptr)(unsafe.Pointer(bp + 8 /* zErr */)) != 0 { return ts + 2690 /* "%s" */ @@ -73877,7 +73254,7 @@ func vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) int32 if (*PmaReader)(unsafe.Pointer(p)).FaMap != 0 { *(*uintptr)(unsafe.Pointer(ppOut)) = ((*PmaReader)(unsafe.Pointer(p)).FaMap + uintptr((*PmaReader)(unsafe.Pointer(p)).FiReadOff)) *(*I64)(unsafe.Pointer(p /* &.iReadOff */)) += (I64(nByte)) - return 0 + return SQLITE_OK } // If there is no more data to be read from the buffer, read the next @@ -73898,7 +73275,7 @@ func vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) int32 // Readr data from the file. Return early if an error occurs. rc = Xsqlite3OsRead(tls, (*PmaReader)(unsafe.Pointer(p)).FpFd, (*PmaReader)(unsafe.Pointer(p)).FaBuffer, nRead, (*PmaReader)(unsafe.Pointer(p)).FiReadOff) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -73930,7 +73307,7 @@ func vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) int32 } aNew = Xsqlite3Realloc(tls, (*PmaReader)(unsafe.Pointer(p)).FaAlloc, uint64(nNew)) if !(aNew != 0) { - return 7 + return SQLITE_NOMEM } (*PmaReader)(unsafe.Pointer(p)).FnAlloc = int32(nNew) (*PmaReader)(unsafe.Pointer(p)).FaAlloc = aNew @@ -73955,7 +73332,7 @@ func vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) int32 nCopy = (*PmaReader)(unsafe.Pointer(p)).FnBuffer } rc = vdbePmaReadBlob(tls, p, nCopy, bp /* &aNext */) - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -73966,7 +73343,7 @@ func vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) int32 *(*uintptr)(unsafe.Pointer(ppOut)) = (*PmaReader)(unsafe.Pointer(p)).FaAlloc } - return 0 + return SQLITE_OK } // Read a varint from the stream of data accessed by p. Set *pnOut to @@ -73990,18 +73367,18 @@ func vdbePmaReadVarint(tls *libc.TLS, p uintptr, pnOut uintptr) int32 { /* sqlit var i int32 = 0 var rc int32 - for ok := true; ok; ok = ((int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* a */)) + uintptr(0)))) & 0x80) != 0) { + for ok := true; ok; ok = ((int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* a */))))) & 0x80) != 0) { rc = vdbePmaReadBlob(tls, p, 1, bp /* &a */) if rc != 0 { return rc } - *(*U8)(unsafe.Pointer(bp + 8 /* &aVarint[0] */ + uintptr(((libc.PostIncInt32(&i, 1)) & 0xf)))) = *(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* a */)) + uintptr(0))) + *(*U8)(unsafe.Pointer(bp + 8 /* &aVarint[0] */ + uintptr(((libc.PostIncInt32(&i, 1)) & 0xf)))) = *(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* a */)))) } Xsqlite3GetVarint(tls, bp+8 /* &aVarint[0] */, pnOut) } } - return 0 + return SQLITE_OK } // Attempt to memory map file pFile. If successful, set *pp to point to the @@ -74012,7 +73389,7 @@ func vdbePmaReadVarint(tls *libc.TLS, p uintptr, pnOut uintptr) int32 { /* sqlit // Or, if an error occurs, return an SQLite error code. The final value of // *pp is undefined in this case. func vdbeSorterMapFile(tls *libc.TLS, pTask uintptr, pFile uintptr, pp uintptr) int32 { /* sqlite3.c:94497:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*SorterFile)(unsafe.Pointer(pFile)).FiEof <= (I64((*Sqlite3)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb)).FnMaxSorterMmap)) { var pFd uintptr = (*SorterFile)(unsafe.Pointer(pFile)).FpFd if (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pFd)).FpMethods)).FiVersion >= 3 { @@ -74027,10 +73404,10 @@ func vdbeSorterMapFile(tls *libc.TLS, pTask uintptr, pFile uintptr, pp uintptr) // that file) and seek it to offset iOff within the file. Return SQLITE_OK // if successful, or an SQLite error code if an error occurs. func vdbePmaReaderSeek(tls *libc.TLS, pTask uintptr, pReadr uintptr, pFile uintptr, iOff I64) int32 { /* sqlite3.c:94514:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if Xsqlite3FaultSim(tls, 201) != 0 { - return (10 | (int32(1) << 8)) + return (SQLITE_IOERR | (int32(1) << 8)) } if (*PmaReader)(unsafe.Pointer(pReadr)).FaMap != 0 { Xsqlite3OsUnfetch(tls, (*PmaReader)(unsafe.Pointer(pReadr)).FpFd, int64(0), (*PmaReader)(unsafe.Pointer(pReadr)).FaMap) @@ -74041,17 +73418,17 @@ func vdbePmaReaderSeek(tls *libc.TLS, pTask uintptr, pReadr uintptr, pFile uintp (*PmaReader)(unsafe.Pointer(pReadr)).FpFd = (*SorterFile)(unsafe.Pointer(pFile)).FpFd rc = vdbeSorterMapFile(tls, pTask, pFile, (pReadr + 64 /* &.aMap */)) - if (rc == 0) && ((*PmaReader)(unsafe.Pointer(pReadr)).FaMap == uintptr(0)) { + if (rc == SQLITE_OK) && ((*PmaReader)(unsafe.Pointer(pReadr)).FaMap == uintptr(0)) { var pgsz int32 = (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fpgsz var iBuf int32 = (int32((*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff % I64(pgsz))) if (*PmaReader)(unsafe.Pointer(pReadr)).FaBuffer == uintptr(0) { (*PmaReader)(unsafe.Pointer(pReadr)).FaBuffer = Xsqlite3Malloc(tls, uint64(pgsz)) if (*PmaReader)(unsafe.Pointer(pReadr)).FaBuffer == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } (*PmaReader)(unsafe.Pointer(pReadr)).FnBuffer = pgsz } - if (rc == 0) && (iBuf != 0) { + if (rc == SQLITE_OK) && (iBuf != 0) { var nRead int32 = (pgsz - iBuf) if ((*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff + I64(nRead)) > (*PmaReader)(unsafe.Pointer(pReadr)).FiEof { nRead = (int32((*PmaReader)(unsafe.Pointer(pReadr)).FiEof - (*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff)) @@ -74071,7 +73448,7 @@ func vdbePmaReaderNext(tls *libc.TLS, pReadr uintptr) int32 { /* sqlite3.c:94561 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 // Return Code + var rc int32 = SQLITE_OK // Return Code *(*U64)(unsafe.Pointer(bp /* nRec */)) = uint64(0) // Size of record in bytes if (*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff >= (*PmaReader)(unsafe.Pointer(pReadr)).FiEof { @@ -74079,9 +73456,9 @@ func vdbePmaReaderNext(tls *libc.TLS, pReadr uintptr) int32 { /* sqlite3.c:94561 var bEof int32 = 1 if pIncr != 0 { rc = vdbeIncrSwap(tls, pIncr) - if (rc == 0) && ((*IncrMerger)(unsafe.Pointer(pIncr)).FbEof == 0) { + if (rc == SQLITE_OK) && ((*IncrMerger)(unsafe.Pointer(pIncr)).FbEof == 0) { rc = vdbePmaReaderSeek(tls, - (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask, pReadr, ((pIncr + 40 /* &.aFile */) + uintptr(0)*16), (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff) + (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask, pReadr, (pIncr + 40 /* &.aFile */), (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff) bEof = 0 } } @@ -74094,10 +73471,10 @@ func vdbePmaReaderNext(tls *libc.TLS, pReadr uintptr) int32 { /* sqlite3.c:94561 } } - if rc == 0 { + if rc == SQLITE_OK { rc = vdbePmaReadVarint(tls, pReadr, bp /* &nRec */) } - if rc == 0 { + if rc == SQLITE_OK { (*PmaReader)(unsafe.Pointer(pReadr)).FnKey = int32(*(*U64)(unsafe.Pointer(bp /* nRec */))) rc = vdbePmaReadBlob(tls, pReadr, int32(*(*U64)(unsafe.Pointer(bp /* nRec */))), (pReadr + 40 /* &.aKey */)) @@ -74120,14 +73497,14 @@ func vdbePmaReaderInit(tls *libc.TLS, pTask uintptr, pFile uintptr, iStart I64, var rc int32 rc = vdbePmaReaderSeek(tls, pTask, pReadr, pFile, iStart) - if rc == 0 { + if rc == SQLITE_OK { *(*U64)(unsafe.Pointer(bp /* nByte */)) = uint64(0) // Size of PMA in bytes rc = vdbePmaReadVarint(tls, pReadr, bp /* &nByte */) (*PmaReader)(unsafe.Pointer(pReadr)).FiEof = (I64(U64((*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff) + *(*U64)(unsafe.Pointer(bp /* nByte */)))) *(*I64)(unsafe.Pointer(pnByte)) += I64((*(*U64)(unsafe.Pointer(bp /* nByte */)))) } - if rc == 0 { + if rc == SQLITE_OK { rc = vdbePmaReaderNext(tls, pReadr) } return rc @@ -74174,8 +73551,8 @@ func vdbeSorterCompareText(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, p var p1 uintptr = pKey1 var p2 uintptr = pKey2 - var v1 uintptr = (p1 + uintptr(*(*U8)(unsafe.Pointer(p1 + uintptr(0))))) // Pointer to value 1 - var v2 uintptr = (p2 + uintptr(*(*U8)(unsafe.Pointer(p2 + uintptr(0))))) // Pointer to value 2 + var v1 uintptr = (p1 + uintptr(*(*U8)(unsafe.Pointer(p1)))) // Pointer to value 1 + var v2 uintptr = (p2 + uintptr(*(*U8)(unsafe.Pointer(p2)))) // Pointer to value 2 // var n1 int32 at bp, 4 @@ -74183,13 +73560,13 @@ func vdbeSorterCompareText(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, p var res int32 - *(*int32)(unsafe.Pointer(bp /* n1 */)) = int32(U32(*(*U8)(unsafe.Pointer((p1 + uintptr(1)))))) + *(*int32)(unsafe.Pointer(bp /* n1 */)) = int32(U32(*(*U8)(unsafe.Pointer((p1 + 1))))) if *(*int32)(unsafe.Pointer(bp /* n1 */)) >= 0x80 { - Xsqlite3GetVarint32(tls, (p1 + uintptr(1)), bp /* &n1 */) + Xsqlite3GetVarint32(tls, (p1 + 1), bp /* &n1 */) } - *(*int32)(unsafe.Pointer(bp + 4 /* n2 */)) = int32(U32(*(*U8)(unsafe.Pointer((p2 + uintptr(1)))))) + *(*int32)(unsafe.Pointer(bp + 4 /* n2 */)) = int32(U32(*(*U8)(unsafe.Pointer((p2 + 1))))) if *(*int32)(unsafe.Pointer(bp + 4 /* n2 */)) >= 0x80 { - Xsqlite3GetVarint32(tls, (p2 + uintptr(1)), bp+4 /* &n2 */) + Xsqlite3GetVarint32(tls, (p2 + 1), bp+4 /* &n2 */) } res = libc.Xmemcmp(tls, v1, v2, (uint64(((func() int32 { if (*(*int32)(unsafe.Pointer(bp /* n1 */))) < (*(*int32)(unsafe.Pointer(bp + 4 /* n2 */))) { @@ -74208,7 +73585,7 @@ func vdbeSorterCompareText(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, p } } else { - if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FaSortFlags + uintptr(0))) != 0 { + if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FaSortFlags)) != 0 { res = (res * -1) } } @@ -74221,11 +73598,11 @@ func vdbeSorterCompareText(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, p func vdbeSorterCompareInt(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pKey1 uintptr, nKey1 int32, pKey2 uintptr, nKey2 int32) int32 { /* sqlite3.c:94729:12: */ var p1 uintptr = pKey1 var p2 uintptr = pKey2 - var s1 int32 = int32(*(*U8)(unsafe.Pointer(p1 + uintptr(1)))) // Left hand serial type - var s2 int32 = int32(*(*U8)(unsafe.Pointer(p2 + uintptr(1)))) // Right hand serial type - var v1 uintptr = (p1 + uintptr(*(*U8)(unsafe.Pointer(p1 + uintptr(0))))) // Pointer to value 1 - var v2 uintptr = (p2 + uintptr(*(*U8)(unsafe.Pointer(p2 + uintptr(0))))) // Pointer to value 2 - var res int32 // Return value + var s1 int32 = int32(*(*U8)(unsafe.Pointer(p1 + 1))) // Left hand serial type + var s2 int32 = int32(*(*U8)(unsafe.Pointer(p2 + 1))) // Right hand serial type + var v1 uintptr = (p1 + uintptr(*(*U8)(unsafe.Pointer(p1)))) // Pointer to value 1 + var v2 uintptr = (p2 + uintptr(*(*U8)(unsafe.Pointer(p2)))) // Pointer to value 2 + var res int32 // Return value if s1 == s2 { var n U8 = aLen[s1] @@ -74233,8 +73610,8 @@ func vdbeSorterCompareInt(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pK res = 0 for i = 0; i < int32(n); i++ { if (libc.AssignInt32(&res, (int32(*(*U8)(unsafe.Pointer(v1 + uintptr(i)))) - int32(*(*U8)(unsafe.Pointer(v2 + uintptr(i))))))) != 0 { - if ((int32(*(*U8)(unsafe.Pointer(v1 + uintptr(0)))) ^ int32(*(*U8)(unsafe.Pointer(v2 + uintptr(0))))) & 0x80) != 0 { - if (int32(*(*U8)(unsafe.Pointer(v1 + uintptr(0)))) & 0x80) != 0 { + if ((int32(*(*U8)(unsafe.Pointer(v1))) ^ int32(*(*U8)(unsafe.Pointer(v2)))) & 0x80) != 0 { + if (int32(*(*U8)(unsafe.Pointer(v1))) & 0x80) != 0 { res = -1 } else { res = +1 @@ -74270,7 +73647,7 @@ func vdbeSorterCompareInt(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pK res = vdbeSorterCompareTail(tls, pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2) } - } else if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FaSortFlags + uintptr(0))) != 0 { + } else if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FaSortFlags)) != 0 { res = (res * -1) } @@ -74304,14 +73681,14 @@ func Xsqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintpt var pKeyInfo uintptr // Copy of pCsr->pKeyInfo with db==0 var szKeyInfo int32 // Size of pCsr->pKeyInfo in bytes var sz int32 // Size of pSorter in bytes - var rc int32 = 0 + var rc int32 = SQLITE_OK var nWorker int32 // Initialize the upper limit on the number of worker threads if (Xsqlite3TempInMemory(tls, db) != 0) || (int32(Xsqlite3Config.FbCoreMutex) == 0) { nWorker = 0 } else { - nWorker = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(11)*4)) + nWorker = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 11*4)) } // Do not allow the total number of threads (main thread + all workers) @@ -74323,7 +73700,7 @@ func Xsqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintpt pSorter = Xsqlite3DbMallocZero(tls, db, (uint64(sz + szKeyInfo))) *(*uintptr)(unsafe.Pointer(pCsr + 56 /* &.uc */)) = pSorter if pSorter == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { (*VdbeSorter)(unsafe.Pointer(pSorter)).FpKeyInfo = libc.AssignUintptr(&pKeyInfo, (pSorter + uintptr(sz))) libc.Xmemcpy(tls, pKeyInfo, (*VdbeCursor)(unsafe.Pointer(pCsr)).FpKeyInfo, uint64(szKeyInfo)) @@ -74331,7 +73708,7 @@ func Xsqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintpt if (nField != 0) && (nWorker == 0) { (*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField = U16(nField) } - (*VdbeSorter)(unsafe.Pointer(pSorter)).Fpgsz = libc.AssignInt32(&pgsz, Xsqlite3BtreeGetPageSize(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt)) + (*VdbeSorter)(unsafe.Pointer(pSorter)).Fpgsz = libc.AssignInt32(&pgsz, Xsqlite3BtreeGetPageSize(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt)) (*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask = (U8(nWorker + 1)) (*VdbeSorter)(unsafe.Pointer(pSorter)).FiPrev = (U8(nWorker - 1)) (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads = (U8(libc.Bool32(int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) > 1))) @@ -74346,7 +73723,7 @@ func Xsqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintpt var szPma U32 = Xsqlite3Config.FszPma (*VdbeSorter)(unsafe.Pointer(pSorter)).FmnPmaSize = (int32(szPma * U32(pgsz))) - mxCache = I64((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FpSchema)).Fcache_size) + mxCache = I64((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema)).Fcache_size) if mxCache < int64(0) { // A negative cache-size value C indicates that the cache is abs(C) // KiB in size. @@ -74374,15 +73751,15 @@ func Xsqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintpt (*VdbeSorter)(unsafe.Pointer(pSorter)).FnMemory = pgsz (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = Xsqlite3Malloc(tls, uint64(pgsz)) if !(int32((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory) != 0) { - rc = 7 + rc = SQLITE_NOMEM } } } if ((int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnAllField) < 13) && - ((*(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */) + uintptr(0)*8)) == uintptr(0)) || (*(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */) + uintptr(0)*8)) == (*Sqlite3)(unsafe.Pointer(db)).FpDfltColl))) && - ((int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(0)))) & 0x02) == 0) { - (*VdbeSorter)(unsafe.Pointer(pSorter)).FtypeMask = (U8(0x01 | 0x02)) + ((*(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */))) == uintptr(0)) || (*(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */))) == (*Sqlite3)(unsafe.Pointer(db)).FpDfltColl))) && + ((int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags))) & KEYINFO_ORDER_BIGNULL) == 0) { + (*VdbeSorter)(unsafe.Pointer(pSorter)).FtypeMask = (U8(SORTER_TYPE_INTEGER | SORTER_TYPE_TEXT)) } } @@ -74425,9 +73802,9 @@ func vdbeSorterJoinThread(tls *libc.TLS, pTask uintptr) int32 { /* sqlite3.c:949 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*SortSubtask)(unsafe.Pointer(pTask)).FpThread != 0 { - *(*uintptr)(unsafe.Pointer(bp /* pRet */)) = uintptr(int64(1)) + *(*uintptr)(unsafe.Pointer(bp /* pRet */)) = uintptr(SQLITE_ERROR) Xsqlite3ThreadJoin(tls, (*SortSubtask)(unsafe.Pointer(pTask)).FpThread, bp /* &pRet */) @@ -74461,7 +73838,7 @@ func vdbeSorterJoinAll(tls *libc.TLS, pSorter uintptr, rcin int32) int32 { /* sq for i = (int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) - 1); i >= 0; i-- { var pTask uintptr = ((pSorter + 96 /* &.aTask */) + uintptr(i)*104) var rc2 int32 = vdbeSorterJoinThread(tls, pTask) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } @@ -74491,7 +73868,7 @@ func vdbeMergeEngineNew(tls *libc.TLS, nReader int32) uintptr { /* sqlite3.c:950 if pNew != 0 { (*MergeEngine)(unsafe.Pointer(pNew)).FnTree = N (*MergeEngine)(unsafe.Pointer(pNew)).FpTask = uintptr(0) - (*MergeEngine)(unsafe.Pointer(pNew)).FaReadr = (pNew + uintptr(1)*32) + (*MergeEngine)(unsafe.Pointer(pNew)).FaReadr = (pNew + 1*32) (*MergeEngine)(unsafe.Pointer(pNew)).FaTree = ((*MergeEngine)(unsafe.Pointer(pNew)).FaReadr + uintptr(N)*80) } return pNew @@ -74514,11 +73891,11 @@ func vdbeIncrFree(tls *libc.TLS, pIncr uintptr) { /* sqlite3.c:95093:13: */ if pIncr != 0 { if (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { vdbeSorterJoinThread(tls, (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask) - if (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+uintptr(0)*16)).FpFd != 0 { - Xsqlite3OsCloseFree(tls, (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+uintptr(0)*16)).FpFd) + if (*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))).FpFd != 0 { + Xsqlite3OsCloseFree(tls, (*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))).FpFd) } - if (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+uintptr(1)*16)).FpFd != 0 { - Xsqlite3OsCloseFree(tls, (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+uintptr(1)*16)).FpFd) + if (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+1*16)).FpFd != 0 { + Xsqlite3OsCloseFree(tls, (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+1*16)).FpFd) } } vdbeMergeEngineFree(tls, (*IncrMerger)(unsafe.Pointer(pIncr)).FpMerger) @@ -74529,7 +73906,7 @@ func vdbeIncrFree(tls *libc.TLS, pIncr uintptr) { /* sqlite3.c:95093:13: */ // Reset a sorting cursor back to its original empty state. func Xsqlite3VdbeSorterReset(tls *libc.TLS, db uintptr, pSorter uintptr) { /* sqlite3.c:95110:21: */ var i int32 - vdbeSorterJoinAll(tls, pSorter, 0) + vdbeSorterJoinAll(tls, pSorter, SQLITE_OK) if (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader != 0 { vdbePmaReaderClear(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader) @@ -74583,8 +73960,8 @@ func vdbeSorterExtendFile(tls *libc.TLS, db uintptr, pFd uintptr, nByte I64) { / if (*(*I64)(unsafe.Pointer(bp + 8 /* nByte */)) <= (I64((*Sqlite3)(unsafe.Pointer(db)).FnMaxSorterMmap))) && ((*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pFd)).FpMethods)).FiVersion >= 3) { *(*uintptr)(unsafe.Pointer(bp + 16 /* p */)) = uintptr(0) *(*int32)(unsafe.Pointer(bp /* chunksize */)) = (4 * 1024) - Xsqlite3OsFileControlHint(tls, pFd, 6, bp /* &chunksize */) - Xsqlite3OsFileControlHint(tls, pFd, 5, bp+8 /* &nByte */) + Xsqlite3OsFileControlHint(tls, pFd, SQLITE_FCNTL_CHUNK_SIZE, bp /* &chunksize */) + Xsqlite3OsFileControlHint(tls, pFd, SQLITE_FCNTL_SIZE_HINT, bp+8 /* &nByte */) Xsqlite3OsFetch(tls, pFd, int64(0), int32(*(*I64)(unsafe.Pointer(bp + 8 /* nByte */))), bp+16 /* &p */) Xsqlite3OsUnfetch(tls, pFd, int64(0), *(*uintptr)(unsafe.Pointer(bp + 16 /* p */))) } @@ -74600,13 +73977,13 @@ func vdbeSorterOpenTempFile(tls *libc.TLS, db uintptr, nExtend I64, ppFd uintptr // var rc int32 at bp, 4 if Xsqlite3FaultSim(tls, 202) != 0 { - return (10 | (int32(13) << 8)) + return (SQLITE_IOERR | (int32(13) << 8)) } *(*int32)(unsafe.Pointer(bp /* rc */)) = Xsqlite3OsOpenMalloc(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), ppFd, - ((((0x00001000 | 0x00000002) | 0x00000004) | 0x00000010) | 0x00000008), bp /* &rc */) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { - *(*I64)(unsafe.Pointer(bp + 8 /* max */)) = int64(0x7fff0000) - Xsqlite3OsFileControlHint(tls, *(*uintptr)(unsafe.Pointer(ppFd)), 18, bp+8 /* &max */) + ((((SQLITE_OPEN_TEMP_JOURNAL | SQLITE_OPEN_READWRITE) | SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_DELETEONCLOSE), bp /* &rc */) + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { + *(*I64)(unsafe.Pointer(bp + 8 /* max */)) = SQLITE_MAX_MMAP_SIZE + Xsqlite3OsFileControlHint(tls, *(*uintptr)(unsafe.Pointer(ppFd)), SQLITE_FCNTL_MMAP_SIZE, bp+8 /* &max */) if nExtend > int64(0) { vdbeSorterExtendFile(tls, db, *(*uintptr)(unsafe.Pointer(ppFd)), nExtend) } @@ -74621,12 +73998,12 @@ func vdbeSortAllocUnpacked(tls *libc.TLS, pTask uintptr) int32 { /* sqlite3.c:95 if (*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked == uintptr(0) { (*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked = Xsqlite3VdbeAllocUnpackedRecord(tls, (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo) if (*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*UnpackedRecord)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FnField = (*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FnKeyField (*UnpackedRecord)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode = U8(0) } - return 0 + return SQLITE_OK } // Merge the two sorted lists p1 and p2 into a single list. @@ -74668,11 +74045,11 @@ func vdbeSorterMerge(tls *libc.TLS, pTask uintptr, p1 uintptr, p2 uintptr) uintp // Return the SorterCompare function to compare values collected by the // sorter object passed as the only argument. func vdbeSorterGetCompare(tls *libc.TLS, p uintptr) SorterCompare { /* sqlite3.c:95267:22: */ - if int32((*VdbeSorter)(unsafe.Pointer(p)).FtypeMask) == 0x01 { + if int32((*VdbeSorter)(unsafe.Pointer(p)).FtypeMask) == SORTER_TYPE_INTEGER { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32 }{vdbeSorterCompareInt})) - } else if int32((*VdbeSorter)(unsafe.Pointer(p)).FtypeMask) == 0x02 { + } else if int32((*VdbeSorter)(unsafe.Pointer(p)).FtypeMask) == SORTER_TYPE_TEXT { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32 }{vdbeSorterCompareText})) @@ -74695,7 +74072,7 @@ func vdbeSorterSort(tls *libc.TLS, pTask uintptr, pList uintptr) int32 { /* sqli // var aSlot [64]uintptr at bp, 512 rc = vdbeSortAllocUnpacked(tls, pTask) - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -74746,7 +74123,7 @@ func vdbePmaWriterInit(tls *libc.TLS, pFd uintptr, p uintptr, nBuf int32, iStart libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(PmaWriter{}))) (*PmaWriter)(unsafe.Pointer(p)).FaBuffer = Xsqlite3Malloc(tls, uint64(nBuf)) if !(int32((*PmaWriter)(unsafe.Pointer(p)).FaBuffer) != 0) { - (*PmaWriter)(unsafe.Pointer(p)).FeFWErr = 7 + (*PmaWriter)(unsafe.Pointer(p)).FeFWErr = SQLITE_NOMEM } else { (*PmaWriter)(unsafe.Pointer(p)).FiBufEnd = libc.AssignPtrInt32(p+20 /* &.iBufStart */, (int32(iStart % I64(nBuf)))) (*PmaWriter)(unsafe.Pointer(p)).FiWriteOff = (iStart - I64((*PmaWriter)(unsafe.Pointer(p)).FiBufStart)) @@ -74830,7 +74207,7 @@ func vdbeSorterListToPMA(tls *libc.TLS, pTask uintptr, pList uintptr) int32 { /* defer tls.Free(48) var db uintptr = (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code // var writer PmaWriter at bp, 48 // Object used to write to the file @@ -74843,16 +74220,16 @@ func vdbeSorterListToPMA(tls *libc.TLS, pTask uintptr, pList uintptr) int32 { /* } // Try to get the file to memory map - if rc == 0 { + if rc == SQLITE_OK { vdbeSorterExtendFile(tls, db, (*SortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd, (((*SortSubtask)(unsafe.Pointer(pTask)).Ffile.FiEof + I64((*SorterList)(unsafe.Pointer(pList)).FszPMA)) + int64(9))) } // Sort the list - if rc == 0 { + if rc == SQLITE_OK { rc = vdbeSorterSort(tls, pTask, pList) } - if rc == 0 { + if rc == SQLITE_OK { var p uintptr var pNext uintptr = uintptr(0) @@ -74885,14 +74262,14 @@ func vdbeMergeEngineStep(tls *libc.TLS, pMerger uintptr, pbEof uintptr) int32 { defer tls.Free(4) var rc int32 - var iPrev int32 = *(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(1)*4)) // Index of PmaReader to advance + var iPrev int32 = *(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + 1*4)) // Index of PmaReader to advance var pTask uintptr = (*MergeEngine)(unsafe.Pointer(pMerger)).FpTask // Advance the current PmaReader rc = vdbePmaReaderNext(tls, ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(iPrev)*80)) // Update contents of aTree[] - if rc == 0 { + if rc == SQLITE_OK { var i int32 // Index of aTree[] to recalculate var pReadr1 uintptr // First PmaReader to compare var pReadr2 uintptr // Second PmaReader to compare @@ -74942,11 +74319,11 @@ func vdbeMergeEngineStep(tls *libc.TLS, pMerger uintptr, pbEof uintptr) int32 { pReadr1 = ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr((i^0x0001))*4)))*80) } } - *(*int32)(unsafe.Pointer(pbEof)) = (libc.Bool32((*PmaReader)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(1)*4)))*80)).FpFd == uintptr(0))) + *(*int32)(unsafe.Pointer(pbEof)) = (libc.Bool32((*PmaReader)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + 1*4)))*80)).FpFd == uintptr(0))) } return func() int32 { - if rc == 0 { + if rc == SQLITE_OK { return int32((*UnpackedRecord)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode) } return rc @@ -74966,7 +74343,7 @@ func vdbeSorterFlushThread(tls *libc.TLS, pCtx uintptr) uintptr { /* sqlite3.c:9 // Flush the current contents of VdbeSorter.list to a new PMA, possibly // using a background thread. func vdbeSorterFlushPMA(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:95576:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 var pTask uintptr = uintptr(0) // Thread context used to create new PMA var nWorker int32 = (int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) - 1) @@ -74989,12 +74366,12 @@ func vdbeSorterFlushPMA(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:955 if (*SortSubtask)(unsafe.Pointer(pTask)).FbDone != 0 { rc = vdbeSorterJoinThread(tls, pTask) } - if (rc != 0) || ((*SortSubtask)(unsafe.Pointer(pTask)).FpThread == uintptr(0)) { + if (rc != SQLITE_OK) || ((*SortSubtask)(unsafe.Pointer(pTask)).FpThread == uintptr(0)) { break } } - if rc == 0 { + if rc == SQLITE_OK { if i == nWorker { // Use the foreground thread for this operation rc = vdbeSorterListToPMA(tls, ((pSorter + 96 /* &.aTask */) + uintptr(nWorker)*104), (pSorter + 56 /* &.list */)) @@ -75015,7 +74392,7 @@ func vdbeSorterFlushPMA(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:955 } else if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0 { (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = Xsqlite3Malloc(tls, uint64((*VdbeSorter)(unsafe.Pointer(pSorter)).FnMemory)) if !(int32((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory) != 0) { - return 7 + return SQLITE_NOMEM } } @@ -75034,23 +74411,23 @@ func Xsqlite3VdbeSorterWrite(tls *libc.TLS, pCsr uintptr, pVal uintptr) int32 { defer tls.Free(4) var pSorter uintptr - var rc int32 = 0 // Return Code - var pNew uintptr // New list element - var bFlush int32 // True to flush contents of memory to PMA - var nReq int32 // Bytes of memory required - var nPMA int32 // Bytes of PMA space required + var rc int32 = SQLITE_OK // Return Code + var pNew uintptr // New list element + var bFlush int32 // True to flush contents of memory to PMA + var nReq int32 // Bytes of memory required + var nPMA int32 // Bytes of PMA space required // var t int32 at bp, 4 // serial type of first record field pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 56 /* &.uc */)) - *(*int32)(unsafe.Pointer(bp /* t */)) = int32(U32(*(*U8)(unsafe.Pointer(((*Mem)(unsafe.Pointer(pVal)).Fz + uintptr(1)))))) + *(*int32)(unsafe.Pointer(bp /* t */)) = int32(U32(*(*U8)(unsafe.Pointer(((*Mem)(unsafe.Pointer(pVal)).Fz + 1))))) if *(*int32)(unsafe.Pointer(bp /* t */)) >= 0x80 { - Xsqlite3GetVarint32(tls, ((*Mem)(unsafe.Pointer(pVal)).Fz + uintptr(1)), bp /* &t */) + Xsqlite3GetVarint32(tls, ((*Mem)(unsafe.Pointer(pVal)).Fz + 1), bp /* &t */) } if ((*(*int32)(unsafe.Pointer(bp /* t */)) > 0) && (*(*int32)(unsafe.Pointer(bp /* t */)) < 10)) && (*(*int32)(unsafe.Pointer(bp /* t */)) != 7) { - *(*U8)(unsafe.Pointer(pSorter + 92 /* &.typeMask */)) &= U8((0x01)) + *(*U8)(unsafe.Pointer(pSorter + 92 /* &.typeMask */)) &= U8((SORTER_TYPE_INTEGER)) } else if (*(*int32)(unsafe.Pointer(bp /* t */)) > 10) && ((*(*int32)(unsafe.Pointer(bp /* t */)) & 0x01) != 0) { - *(*U8)(unsafe.Pointer(pSorter + 92 /* &.typeMask */)) &= U8((0x02)) + *(*U8)(unsafe.Pointer(pSorter + 92 /* &.typeMask */)) &= U8((SORTER_TYPE_TEXT)) } else { (*VdbeSorter)(unsafe.Pointer(pSorter)).FtypeMask = U8(0) } @@ -75113,7 +74490,7 @@ func Xsqlite3VdbeSorterWrite(tls *libc.TLS, pCsr uintptr, pVal uintptr) int32 { } aNew = Xsqlite3Realloc(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory, uint64(nNew)) if !(aNew != 0) { - return 7 + return SQLITE_NOMEM } if iListOff >= 0 { (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = (aNew + uintptr(iListOff)) @@ -75123,14 +74500,14 @@ func Xsqlite3VdbeSorterWrite(tls *libc.TLS, pCsr uintptr, pVal uintptr) int32 { } pNew = ((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory + uintptr((*VdbeSorter)(unsafe.Pointer(pSorter)).FiMemory)) - *(*int32)(unsafe.Pointer(pSorter + 80 /* &.iMemory */)) += (((nReq) + 7) & ^libc.Int32(7)) + *(*int32)(unsafe.Pointer(pSorter + 80 /* &.iMemory */)) += (((nReq) + 7) & libc.CplInt32(7)) if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 { *(*int32)(unsafe.Pointer(pNew + 8 /* &.u */)) = (int32((int64(((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList)) - int64((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory)) / 1)) } } else { pNew = Xsqlite3Malloc(tls, uint64(nReq)) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } *(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)) = (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList } @@ -75149,19 +74526,19 @@ func vdbeIncrPopulate(tls *libc.TLS, pIncr uintptr) int32 { /* sqlite3.c:95758:1 bp := tls.Alloc(52) defer tls.Free(52) - var rc int32 = 0 + var rc int32 = SQLITE_OK var rc2 int32 var iStart I64 = (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff - var pOut uintptr = ((pIncr + 40 /* &.aFile */) + uintptr(1)*16) + var pOut uintptr = ((pIncr + 40 /* &.aFile */) + 1*16) var pTask uintptr = (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask var pMerger uintptr = (*IncrMerger)(unsafe.Pointer(pIncr)).FpMerger // var writer PmaWriter at bp, 48 vdbePmaWriterInit(tls, (*SorterFile)(unsafe.Pointer(pOut)).FpFd, bp /* &writer */, (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fpgsz, iStart) - for rc == 0 { + for rc == SQLITE_OK { // var dummy int32 at bp+48, 4 - var pReader uintptr = ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(1)*4)))*80) + var pReader uintptr = ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + 1*4)))*80) var nKey int32 = (*PmaReader)(unsafe.Pointer(pReader)).FnKey var iEof I64 = ((*PmaWriter)(unsafe.Pointer(bp /* &writer */)).FiWriteOff + I64((*PmaWriter)(unsafe.Pointer(bp /* &writer */)).FiBufEnd)) @@ -75182,7 +74559,7 @@ func vdbeIncrPopulate(tls *libc.TLS, pIncr uintptr) int32 { /* sqlite3.c:95758:1 } rc2 = vdbePmaWriterFinish(tls, bp /* &writer */, (pOut + 8 /* &.iEof */)) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } @@ -75223,19 +74600,19 @@ func vdbeIncrBgPopulate(tls *libc.TLS, pIncr uintptr) int32 { /* sqlite3.c:95810 // // SQLITE_OK is returned on success, or an SQLite error code otherwise. func vdbeIncrSwap(tls *libc.TLS, pIncr uintptr) int32 { /* sqlite3.c:95834:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { rc = vdbeSorterJoinThread(tls, (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask) - if rc == 0 { - var f0 = *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(0)*16)) - *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(0)*16)) = *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(1)*16)) - *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(1)*16)) = f0 + if rc == SQLITE_OK { + var f0 = *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))) + *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))) = *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + 1*16)) + *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + 1*16)) = f0 } - if rc == 0 { - if (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+uintptr(0)*16)).FiEof == (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff { + if rc == SQLITE_OK { + if (*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))).FiEof == (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff { (*IncrMerger)(unsafe.Pointer(pIncr)).FbEof = 1 } else { rc = vdbeIncrBgPopulate(tls, pIncr) @@ -75243,8 +74620,8 @@ func vdbeIncrSwap(tls *libc.TLS, pIncr uintptr) int32 { /* sqlite3.c:95834:12: * } } else { rc = vdbeIncrPopulate(tls, pIncr) - *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(0)*16)) = *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(1)*16)) - if (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+uintptr(0)*16)).FiEof == (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff { + *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))) = *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + 1*16)) + if (*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))).FiEof == (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff { (*IncrMerger)(unsafe.Pointer(pIncr)).FbEof = 1 } } @@ -75257,7 +74634,7 @@ func vdbeIncrSwap(tls *libc.TLS, pIncr uintptr) int32 { /* sqlite3.c:95834:12: * // If an OOM condition is encountered, return NULL. In this case free the // pMerger argument before returning. func vdbeIncrMergerNew(tls *libc.TLS, pTask uintptr, pMerger uintptr, ppOut uintptr) int32 { /* sqlite3.c:95873:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pIncr uintptr = libc.AssignPtrUintptr(ppOut, func() uintptr { if Xsqlite3FaultSim(tls, 100) != 0 { return uintptr(0) @@ -75276,7 +74653,7 @@ func vdbeIncrMergerNew(tls *libc.TLS, pTask uintptr, pMerger uintptr, ppOut uint *(*I64)(unsafe.Pointer(pTask + 88 /* &.file2 */ + 8 /* &.iEof */)) += (I64((*IncrMerger)(unsafe.Pointer(pIncr)).FmxSz)) } else { vdbeMergeEngineFree(tls, pMerger) - rc = 7 + rc = SQLITE_NOMEM } return rc } @@ -75349,9 +74726,9 @@ func vdbeMergeEngineCompare(tls *libc.TLS, pMerger uintptr, iOut int32) { /* sql // // SQLITE_OK is returned if successful, or an SQLite error code otherwise. func vdbeMergeEngineInit(tls *libc.TLS, pTask uintptr, pMerger uintptr, eMode int32) int32 { /* sqlite3.c:95992:12: */ - var rc int32 = 0 // Return code - var i int32 // For looping over PmaReader objects - var nTree int32 // Number of subtrees to merge + var rc int32 = SQLITE_OK // Return code + var i int32 // For looping over PmaReader objects + var nTree int32 // Number of subtrees to merge // Failure to allocate the merge would have been detected prior to // invoking this routine @@ -75364,7 +74741,7 @@ func vdbeMergeEngineInit(tls *libc.TLS, pTask uintptr, pMerger uintptr, eMode in nTree = (*MergeEngine)(unsafe.Pointer(pMerger)).FnTree for i = 0; i < nTree; i++ { - if (8 > 0) && (eMode == 2) { + if (SQLITE_MAX_WORKER_THREADS > 0) && (eMode == INCRINIT_ROOT) { // PmaReaders should be normally initialized in order, as if they are // reading from the same temp file this makes for more linear file IO. // However, in the INCRINIT_ROOT case, if PmaReader aReadr[nTask-1] is @@ -75374,9 +74751,9 @@ func vdbeMergeEngineInit(tls *libc.TLS, pTask uintptr, pMerger uintptr, eMode in // better advantage of multi-processor hardware. rc = vdbePmaReaderNext(tls, ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(((nTree-i)-1))*80)) } else { - rc = vdbePmaReaderIncrInit(tls, ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(i)*80), 0) + rc = vdbePmaReaderIncrInit(tls, ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(i)*80), INCRINIT_NORMAL) } - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -75419,7 +74796,7 @@ func vdbeMergeEngineInit(tls *libc.TLS, pTask uintptr, pMerger uintptr, eMode in // // SQLITE_OK is returned if successful, or an SQLite error code otherwise. func vdbePmaReaderIncrMergeInit(tls *libc.TLS, pReadr uintptr, eMode int32) int32 { /* sqlite3.c:96068:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pIncr uintptr = (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr var pTask uintptr = (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask var db uintptr = (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb @@ -75431,12 +74808,12 @@ func vdbePmaReaderIncrMergeInit(tls *libc.TLS, pReadr uintptr, eMode int32) int3 // Set up the required files for pIncr. A multi-theaded IncrMerge object // requires two temp files to itself, whereas a single-threaded object // only requires a region of pTask->file2. - if rc == 0 { + if rc == SQLITE_OK { var mxSz int32 = (*IncrMerger)(unsafe.Pointer(pIncr)).FmxSz if (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { - rc = vdbeSorterOpenTempFile(tls, db, int64(mxSz), ((pIncr + 40 /* &.aFile */) + uintptr(0)*16 /* &.pFd */)) - if rc == 0 { - rc = vdbeSorterOpenTempFile(tls, db, int64(mxSz), ((pIncr + 40 /* &.aFile */) + uintptr(1)*16 /* &.pFd */)) + rc = vdbeSorterOpenTempFile(tls, db, int64(mxSz), (pIncr + 40 /* &.aFile */) /* &.pFd */) + if rc == SQLITE_OK { + rc = vdbeSorterOpenTempFile(tls, db, int64(mxSz), ((pIncr + 40 /* &.aFile */) + 1*16 /* &.pFd */)) } } else { if (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd == uintptr(0) { @@ -75444,15 +74821,15 @@ func vdbePmaReaderIncrMergeInit(tls *libc.TLS, pReadr uintptr, eMode int32) int3 rc = vdbeSorterOpenTempFile(tls, db, (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof, (pTask + 88 /* &.file2 */ /* &.pFd */)) (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof = int64(0) } - if rc == 0 { - (*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(1)*16)).FpFd = (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd + if rc == SQLITE_OK { + (*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + 1*16)).FpFd = (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff = (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof *(*I64)(unsafe.Pointer(pTask + 88 /* &.file2 */ + 8 /* &.iEof */)) += (I64(mxSz)) } } } - if (rc == 0) && ((*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0) { + if (rc == SQLITE_OK) && ((*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0) { // Use the current thread to populate aFile[1], even though this // PmaReader is multi-threaded. If this is an INCRINIT_TASK object, // then this function is already running in background thread @@ -75466,7 +74843,7 @@ func vdbePmaReaderIncrMergeInit(tls *libc.TLS, pReadr uintptr, eMode int32) int3 rc = vdbeIncrPopulate(tls, pIncr) } - if (rc == 0) && ((8 == 0) || (eMode != 1)) { + if (rc == SQLITE_OK) && ((SQLITE_MAX_WORKER_THREADS == 0) || (eMode != INCRINIT_TASK)) { rc = vdbePmaReaderNext(tls, pReadr) } @@ -75477,7 +74854,7 @@ func vdbePmaReaderIncrMergeInit(tls *libc.TLS, pReadr uintptr, eMode int32) int3 // background threads. func vdbePmaReaderBgIncrInit(tls *libc.TLS, pCtx uintptr) uintptr { /* sqlite3.c:96135:13: */ var pReader uintptr = pCtx - var pRet uintptr = uintptr(int64(vdbePmaReaderIncrMergeInit(tls, pReader, 1))) + var pRet uintptr = uintptr(int64(vdbePmaReaderIncrMergeInit(tls, pReader, INCRINIT_TASK))) (*SortSubtask)(unsafe.Pointer((*IncrMerger)(unsafe.Pointer((*PmaReader)(unsafe.Pointer(pReader)).FpIncr)).FpTask)).FbDone = 1 return pRet } @@ -75493,7 +74870,7 @@ func vdbePmaReaderBgIncrInit(tls *libc.TLS, pCtx uintptr) uintptr { /* sqlite3.c // using the current thread. func vdbePmaReaderIncrInit(tls *libc.TLS, pReadr uintptr, eMode int32) int32 { /* sqlite3.c:96156:12: */ var pIncr uintptr = (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr // Incremental merger - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code if pIncr != 0 { if (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { @@ -75525,21 +74902,21 @@ func vdbeMergeEngineLevel0(tls *libc.TLS, pTask uintptr, nPMA int32, piOffset ui var pNew uintptr // Merge engine to return var iOff I64 = *(*I64)(unsafe.Pointer(piOffset)) var i int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK *(*uintptr)(unsafe.Pointer(ppOut)) = libc.AssignUintptr(&pNew, vdbeMergeEngineNew(tls, nPMA)) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } - for i = 0; (i < nPMA) && (rc == 0); i++ { + for i = 0; (i < nPMA) && (rc == SQLITE_OK); i++ { *(*I64)(unsafe.Pointer(bp /* nDummy */)) = int64(0) var pReadr uintptr = ((*MergeEngine)(unsafe.Pointer(pNew)).FaReadr + uintptr(i)*80) rc = vdbePmaReaderInit(tls, pTask, (pTask + 72 /* &.file */), iOff, pReadr, bp /* &nDummy */) iOff = (*PmaReader)(unsafe.Pointer(pReadr)).FiEof } - if rc != 0 { + if rc != SQLITE_OK { vdbeMergeEngineFree(tls, pNew) *(*uintptr)(unsafe.Pointer(ppOut)) = uintptr(0) } @@ -75557,9 +74934,9 @@ func vdbeMergeEngineLevel0(tls *libc.TLS, pTask uintptr, nPMA int32, piOffset ui // nPMA<=65536 -> TreeDepth() == 2 func vdbeSorterTreeDepth(tls *libc.TLS, nPMA int32) int32 { /* sqlite3.c:96225:12: */ var nDepth int32 = 0 - var nDiv I64 = int64(16) + var nDiv I64 = SORTER_MAX_MERGE_COUNT for nDiv < I64(nPMA) { - nDiv = (nDiv * int64(16)) + nDiv = (nDiv * SORTER_MAX_MERGE_COUNT) nDepth++ } return nDepth @@ -75575,7 +74952,7 @@ func vdbeSorterAddToTree(tls *libc.TLS, pTask uintptr, nDepth int32, iSeq int32, bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var nDiv int32 = 1 var i int32 var p uintptr = pRoot @@ -75584,29 +74961,29 @@ func vdbeSorterAddToTree(tls *libc.TLS, pTask uintptr, nDepth int32, iSeq int32, rc = vdbeIncrMergerNew(tls, pTask, pLeaf, bp /* &pIncr */) for i = 1; i < nDepth; i++ { - nDiv = (nDiv * 16) + nDiv = (nDiv * SORTER_MAX_MERGE_COUNT) } - for i = 1; (i < nDepth) && (rc == 0); i++ { - var iIter int32 = ((iSeq / nDiv) % 16) + for i = 1; (i < nDepth) && (rc == SQLITE_OK); i++ { + var iIter int32 = ((iSeq / nDiv) % SORTER_MAX_MERGE_COUNT) var pReadr uintptr = ((*MergeEngine)(unsafe.Pointer(p)).FaReadr + uintptr(iIter)*80) if (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr == uintptr(0) { - var pNew uintptr = vdbeMergeEngineNew(tls, 16) + var pNew uintptr = vdbeMergeEngineNew(tls, SORTER_MAX_MERGE_COUNT) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = vdbeIncrMergerNew(tls, pTask, pNew, (pReadr + 72 /* &.pIncr */)) } } - if rc == 0 { + if rc == SQLITE_OK { p = (*IncrMerger)(unsafe.Pointer((*PmaReader)(unsafe.Pointer(pReadr)).FpIncr)).FpMerger - nDiv = (nDiv / 16) + nDiv = (nDiv / SORTER_MAX_MERGE_COUNT) } } - if rc == 0 { - (*PmaReader)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(p)).FaReadr + uintptr((iSeq%16))*80)).FpIncr = *(*uintptr)(unsafe.Pointer(bp /* pIncr */)) + if rc == SQLITE_OK { + (*PmaReader)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(p)).FaReadr + uintptr((iSeq%SORTER_MAX_MERGE_COUNT))*80)).FpIncr = *(*uintptr)(unsafe.Pointer(bp /* pIncr */)) } else { vdbeIncrFree(tls, *(*uintptr)(unsafe.Pointer(bp /* pIncr */))) } @@ -75627,7 +75004,7 @@ func vdbeSorterMergeTreeBuild(tls *libc.TLS, pSorter uintptr, ppOut uintptr) int defer tls.Free(24) var pMain uintptr = uintptr(0) - var rc int32 = 0 + var rc int32 = SQLITE_OK var iTask int32 // If the sorter uses more than one task, then create the top-level @@ -75637,45 +75014,45 @@ func vdbeSorterMergeTreeBuild(tls *libc.TLS, pSorter uintptr, ppOut uintptr) int if int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) > 1 { pMain = vdbeMergeEngineNew(tls, int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)) if pMain == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } } - for iTask = 0; (rc == 0) && (iTask < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)); iTask++ { + for iTask = 0; (rc == SQLITE_OK) && (iTask < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)); iTask++ { var pTask uintptr = ((pSorter + 96 /* &.aTask */) + uintptr(iTask)*104) - if (8 == 0) || ((*SortSubtask)(unsafe.Pointer(pTask)).FnPMA != 0) { + if (SQLITE_MAX_WORKER_THREADS == 0) || ((*SortSubtask)(unsafe.Pointer(pTask)).FnPMA != 0) { *(*uintptr)(unsafe.Pointer(bp + 8 /* pRoot */)) = uintptr(0) // Root node of tree for this task var nDepth int32 = vdbeSorterTreeDepth(tls, (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA) *(*I64)(unsafe.Pointer(bp /* iReadOff */)) = int64(0) - if (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA <= 16 { + if (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA <= SORTER_MAX_MERGE_COUNT { rc = vdbeMergeEngineLevel0(tls, pTask, (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA, bp /* &iReadOff */, bp+8 /* &pRoot */) } else { var i int32 var iSeq int32 = 0 - *(*uintptr)(unsafe.Pointer(bp + 8 /* pRoot */)) = vdbeMergeEngineNew(tls, 16) + *(*uintptr)(unsafe.Pointer(bp + 8 /* pRoot */)) = vdbeMergeEngineNew(tls, SORTER_MAX_MERGE_COUNT) if *(*uintptr)(unsafe.Pointer(bp + 8 /* pRoot */)) == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } - for i = 0; (i < (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA) && (rc == 0); i = i + (16) { + for i = 0; (i < (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA) && (rc == SQLITE_OK); i = i + (SORTER_MAX_MERGE_COUNT) { *(*uintptr)(unsafe.Pointer(bp + 16 /* pMerger */)) = uintptr(0) // New level-0 PMA merger var nReader int32 // Number of level-0 PMAs to merge nReader = func() int32 { - if ((*SortSubtask)(unsafe.Pointer(pTask)).FnPMA - i) < (16) { + if ((*SortSubtask)(unsafe.Pointer(pTask)).FnPMA - i) < (SORTER_MAX_MERGE_COUNT) { return ((*SortSubtask)(unsafe.Pointer(pTask)).FnPMA - i) } - return 16 + return SORTER_MAX_MERGE_COUNT }() rc = vdbeMergeEngineLevel0(tls, pTask, nReader, bp /* &iReadOff */, bp+16 /* &pMerger */) - if rc == 0 { + if rc == SQLITE_OK { rc = vdbeSorterAddToTree(tls, pTask, nDepth, libc.PostIncInt32(&iSeq, 1), *(*uintptr)(unsafe.Pointer(bp + 8 /* pRoot */)), *(*uintptr)(unsafe.Pointer(bp + 16 /* pMerger */))) } } } - if rc == 0 { + if rc == SQLITE_OK { if pMain != uintptr(0) { rc = vdbeIncrMergerNew(tls, pTask, *(*uintptr)(unsafe.Pointer(bp + 8 /* pRoot */)), ((*MergeEngine)(unsafe.Pointer(pMain)).FaReadr + uintptr(iTask)*80 + 72 /* &.pIncr */)) } else { @@ -75688,7 +75065,7 @@ func vdbeSorterMergeTreeBuild(tls *libc.TLS, pSorter uintptr, ppOut uintptr) int } } - if rc != 0 { + if rc != SQLITE_OK { vdbeMergeEngineFree(tls, pMain) pMain = uintptr(0) } @@ -75708,7 +75085,7 @@ func vdbeSorterSetupMerge(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:9 defer tls.Free(8) var rc int32 // Return code - var pTask0 uintptr = ((pSorter + 96 /* &.aTask */) + uintptr(0)*104) + var pTask0 uintptr = (pSorter + 96 /* &.aTask */) *(*uintptr)(unsafe.Pointer(bp /* pMain */)) = uintptr(0) var db uintptr = (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask0)).FpSorter)).Fdb var i int32 @@ -75718,23 +75095,23 @@ func vdbeSorterSetupMerge(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:9 } rc = vdbeSorterMergeTreeBuild(tls, pSorter, bp /* &pMain */) - if rc == 0 { + if rc == SQLITE_OK { if (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads != 0 { var iTask int32 var pReadr uintptr = uintptr(0) var pLast uintptr = ((pSorter + 96 /* &.aTask */) + uintptr((int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)-1))*104) rc = vdbeSortAllocUnpacked(tls, pLast) - if rc == 0 { + if rc == SQLITE_OK { pReadr = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(PmaReader{}))) (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader = pReadr if pReadr == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } } - if rc == 0 { + if rc == SQLITE_OK { rc = vdbeIncrMergerNew(tls, pLast, *(*uintptr)(unsafe.Pointer(bp /* pMain */)), (pReadr + 72 /* &.pIncr */)) - if rc == 0 { + if rc == SQLITE_OK { vdbeIncrMergerSetThreads(tls, (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr) for iTask = 0; iTask < (int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) - 1); iTask++ { var pIncr uintptr @@ -75743,7 +75120,7 @@ func vdbeSorterSetupMerge(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:9 } } - for iTask = 0; (rc == 0) && (iTask < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)); iTask++ { + for iTask = 0; (rc == SQLITE_OK) && (iTask < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)); iTask++ { // Check that: // // a) The incremental merge object is configured to use the @@ -75754,22 +75131,22 @@ func vdbeSorterSetupMerge(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:9 // object. var p uintptr = ((*MergeEngine)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pMain */)))).FaReadr + uintptr(iTask)*80) - rc = vdbePmaReaderIncrInit(tls, p, 1) + rc = vdbePmaReaderIncrInit(tls, p, INCRINIT_TASK) } } *(*uintptr)(unsafe.Pointer(bp /* pMain */)) = uintptr(0) } - if rc == 0 { - rc = vdbePmaReaderIncrMergeInit(tls, pReadr, 2) + if rc == SQLITE_OK { + rc = vdbePmaReaderIncrMergeInit(tls, pReadr, INCRINIT_ROOT) } } else { - rc = vdbeMergeEngineInit(tls, pTask0, *(*uintptr)(unsafe.Pointer(bp /* pMain */)), 0) + rc = vdbeMergeEngineInit(tls, pTask0, *(*uintptr)(unsafe.Pointer(bp /* pMain */)), INCRINIT_NORMAL) (*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger = *(*uintptr)(unsafe.Pointer(bp /* pMain */)) *(*uintptr)(unsafe.Pointer(bp /* pMain */)) = uintptr(0) } } - if rc != 0 { + if rc != SQLITE_OK { vdbeMergeEngineFree(tls, *(*uintptr)(unsafe.Pointer(bp /* pMain */))) } return rc @@ -75780,7 +75157,7 @@ func vdbeSorterSetupMerge(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:9 // in sorted order. func Xsqlite3VdbeSorterRewind(tls *libc.TLS, pCsr uintptr, pbEof uintptr) int32 { /* sqlite3.c:96460:20: */ var pSorter uintptr - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 56 /* &.uc */)) @@ -75790,7 +75167,7 @@ func Xsqlite3VdbeSorterRewind(tls *libc.TLS, pCsr uintptr, pbEof uintptr) int32 if int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FbUsePMA) == 0 { if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 { *(*int32)(unsafe.Pointer(pbEof)) = 0 - rc = vdbeSorterSort(tls, ((pSorter + 96 /* &.aTask */) + uintptr(0)*104), (pSorter + 56 /* &.list */)) + rc = vdbeSorterSort(tls, (pSorter + 96 /* &.aTask */), (pSorter + 56 /* &.list */)) } else { *(*int32)(unsafe.Pointer(pbEof)) = 1 } @@ -75810,7 +75187,7 @@ func Xsqlite3VdbeSorterRewind(tls *libc.TLS, pCsr uintptr, pbEof uintptr) int32 // Assuming no errors have occurred, set up a merger structure to // incrementally read and merge all remaining PMAs. - if rc == 0 { + if rc == SQLITE_OK { rc = vdbeSorterSetupMerge(tls, pSorter) *(*int32)(unsafe.Pointer(pbEof)) = 0 } @@ -75836,15 +75213,15 @@ func Xsqlite3VdbeSorterNext(tls *libc.TLS, db uintptr, pCsr uintptr) int32 { /* if (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads != 0 { rc = vdbePmaReaderNext(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader) - if (rc == 0) && ((*PmaReader)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader)).FpFd == uintptr(0)) { - rc = 101 + if (rc == SQLITE_OK) && ((*PmaReader)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader)).FpFd == uintptr(0)) { + rc = SQLITE_DONE } } else { *(*int32)(unsafe.Pointer(bp /* res */)) = 0 rc = vdbeMergeEngineStep(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger, bp /* &res */) - if (rc == 0) && (*(*int32)(unsafe.Pointer(bp /* res */)) != 0) { - rc = 101 + if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* res */)) != 0) { + rc = SQLITE_DONE } } } else { @@ -75855,9 +75232,9 @@ func Xsqlite3VdbeSorterNext(tls *libc.TLS, db uintptr, pCsr uintptr) int32 { /* vdbeSorterRecordFree(tls, db, pFree) } if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 { - rc = 0 + rc = SQLITE_OK } else { - rc = 101 + rc = SQLITE_DONE } } return rc @@ -75872,7 +75249,7 @@ func vdbeSorterRowkey(tls *libc.TLS, pSorter uintptr, pnKey uintptr) uintptr { / if (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads != 0 { pReader = (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader } else { - pReader = ((*MergeEngine)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)).FaTree + uintptr(1)*4)))*80) + pReader = ((*MergeEngine)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)).FaTree + 1*4)))*80) } *(*int32)(unsafe.Pointer(pnKey)) = (*PmaReader)(unsafe.Pointer(pReader)).FnKey pKey = (*PmaReader)(unsafe.Pointer(pReader)).FaKey @@ -75896,13 +75273,13 @@ func Xsqlite3VdbeSorterRowkey(tls *libc.TLS, pCsr uintptr, pOut uintptr) int32 { pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 56 /* &.uc */)) pKey = vdbeSorterRowkey(tls, pSorter, bp /* &nKey */) if Xsqlite3VdbeMemClearAndResize(tls, pOut, *(*int32)(unsafe.Pointer(bp /* nKey */))) != 0 { - return 7 + return SQLITE_NOMEM } (*Mem)(unsafe.Pointer(pOut)).Fn = *(*int32)(unsafe.Pointer(bp /* nKey */)) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0010)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Blob)) libc.Xmemcpy(tls, (*Mem)(unsafe.Pointer(pOut)).Fz, pKey, uint64(*(*int32)(unsafe.Pointer(bp /* nKey */)))) - return 0 + return SQLITE_OK } // Compare the key in memory cell pVal with the key that the sorter cursor @@ -75937,7 +75314,7 @@ func Xsqlite3VdbeSorterCompare(tls *libc.TLS, pCsr uintptr, pVal uintptr, nKeyCo if r2 == uintptr(0) { r2 = libc.AssignPtrUintptr(pSorter+48 /* &.pUnpacked */, Xsqlite3VdbeAllocUnpackedRecord(tls, pKeyInfo)) if r2 == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*UnpackedRecord)(unsafe.Pointer(r2)).FnField = U16(nKeyCol) } @@ -75945,14 +75322,14 @@ func Xsqlite3VdbeSorterCompare(tls *libc.TLS, pCsr uintptr, pVal uintptr, nKeyCo pKey = vdbeSorterRowkey(tls, pSorter, bp /* &nKey */) Xsqlite3VdbeRecordUnpack(tls, pKeyInfo, *(*int32)(unsafe.Pointer(bp /* nKey */)), pKey, r2) for i = 0; i < nKeyCol; i++ { - if (int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(r2)).FaMem+uintptr(i)*56)).Fflags) & 0x0001) != 0 { + if (int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(r2)).FaMem+uintptr(i)*56)).Fflags) & MEM_Null) != 0 { *(*int32)(unsafe.Pointer(pRes)) = -1 - return 0 + return SQLITE_OK } } *(*int32)(unsafe.Pointer(pRes)) = Xsqlite3VdbeRecordCompare(tls, (*Mem)(unsafe.Pointer(pVal)).Fn, (*Mem)(unsafe.Pointer(pVal)).Fz, r2) - return 0 + return SQLITE_OK } //************* End of vdbesort.c ******************************************* @@ -76084,7 +75461,7 @@ func memjrnlRead(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst Sq var pChunk uintptr if (Sqlite_int64(iAmt) + iOfst) > (*MemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset { - return (10 | (int32(2) << 8)) + return (SQLITE_IOERR | (int32(2) << 8)) } if ((*MemJournal)(unsafe.Pointer(p)).Freadpoint.FiOffset != iOfst) || (iOfst == int64(0)) { @@ -76119,7 +75496,7 @@ func memjrnlRead(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst Sq }() (*MemJournal)(unsafe.Pointer(p)).Freadpoint.FpChunk = pChunk - return 0 + return SQLITE_OK } // Free the list of FileChunk structures headed at MemJournal.pFirst. @@ -76144,7 +75521,7 @@ func memjrnlCreateFile(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:97221:12: libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(MemJournal{}))) rc = Xsqlite3OsOpen(tls, (*MemJournal)(unsafe.Pointer(bp /* © */)).FpVfs, (*MemJournal)(unsafe.Pointer(bp /* © */)).FzJournal, pReal, (*MemJournal)(unsafe.Pointer(bp /* © */)).Fflags, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { var nChunk int32 = (*MemJournal)(unsafe.Pointer(bp /* © */)).FnChunkSize var iOff I64 = int64(0) var pIter uintptr @@ -76158,12 +75535,12 @@ func memjrnlCreateFile(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:97221:12: } iOff = iOff + (I64(nChunk)) } - if rc == 0 { + if rc == SQLITE_OK { // No error has occurred. Free the in-memory buffers. memjrnlFreeChunks(tls, bp /* © */) } } - if rc != 0 { + if rc != SQLITE_OK { // If an error occurred while creating or writing to the file, restore // the original before returning. This way, SQLite uses the in-memory // journal data to roll back changes made to the internal page-cache @@ -76184,7 +75561,7 @@ func memjrnlWrite(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst S // into the file on disk. if ((*MemJournal)(unsafe.Pointer(p)).FnSpill > 0) && ((Sqlite_int64(iAmt) + iOfst) > Sqlite_int64((*MemJournal)(unsafe.Pointer(p)).FnSpill)) { var rc int32 = memjrnlCreateFile(tls, p) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3OsWrite(tls, pJfd, zBuf, iAmt, iOfst) } return rc @@ -76210,7 +75587,7 @@ func memjrnlWrite(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst S // New chunk is required to extend the file. var pNew uintptr = Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(FileChunk{})) + (uint64(((*MemJournal)(unsafe.Pointer(p)).FnChunkSize) - 8))))) if !(pNew != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } (*FileChunk)(unsafe.Pointer(pNew)).FpNext = uintptr(0) if pChunk != 0 { @@ -76233,7 +75610,7 @@ func memjrnlWrite(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst S } } - return 0 + return SQLITE_OK } // Truncate the file. @@ -76251,14 +75628,14 @@ func memjrnlTruncate(tls *libc.TLS, pJfd uintptr, size Sqlite_int64) int32 { /* (*MemJournal)(unsafe.Pointer(p)).Freadpoint.FpChunk = uintptr(0) (*MemJournal)(unsafe.Pointer(p)).Freadpoint.FiOffset = int64(0) } - return 0 + return SQLITE_OK } // Close the file. func memjrnlClose(tls *libc.TLS, pJfd uintptr) int32 { /* sqlite3.c:97355:12: */ var p uintptr = pJfd memjrnlFreeChunks(tls, p) - return 0 + return SQLITE_OK } // Sync the file. @@ -76268,55 +75645,25 @@ func memjrnlClose(tls *libc.TLS, pJfd uintptr) int32 { /* sqlite3.c:97355:12: */ func memjrnlSync(tls *libc.TLS, pJfd uintptr, flags int32) int32 { /* sqlite3.c:97367:12: */ _ = pJfd _ = flags - return 0 + return SQLITE_OK } // Query the size of the file in bytes. func memjrnlFileSize(tls *libc.TLS, pJfd uintptr, pSize uintptr) int32 { /* sqlite3.c:97375:12: */ var p uintptr = pJfd *(*Sqlite_int64)(unsafe.Pointer(pSize)) = (*MemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset - return 0 + return SQLITE_OK } // Table of methods for MemJournal sqlite3_file object. var sMemJournalMethods = sqlite3_io_methods{ - FiVersion: 1, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - uintptr(0), - FxUnlock:// xLock - uintptr(0), - FxCheckReservedLock:// xUnlock - uintptr(0), - FxFileControl:// xCheckReservedLock - uintptr(0), - FxSectorSize:// xFileControl - uintptr(0), - FxDeviceCharacteristics:// xSectorSize - uintptr(0), - FxShmMap:// xDeviceCharacteristics - uintptr(0), - FxShmLock:// xShmMap - uintptr(0), - FxShmBarrier:// xShmLock - uintptr(0), - FxShmUnmap:// xShmBarrier - uintptr(0), - FxFetch:// xShmUnmap - uintptr(0), - FxUnfetch:// xFetch - uintptr(0), // xUnfetch + FiVersion: 1, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xUnfetch } /* sqlite3.c:97384:40 */ // Open a journal file. @@ -76344,7 +75691,7 @@ func Xsqlite3JournalOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pJfd uintpt if nSpill > 0 { (*MemJournal)(unsafe.Pointer(p)).FnChunkSize = nSpill } else { - (*MemJournal)(unsafe.Pointer(p)).FnChunkSize = (int32((uint64(8 + 1024)) - uint64(unsafe.Sizeof(FileChunk{})))) + (*MemJournal)(unsafe.Pointer(p)).FnChunkSize = (int32((uint64(8 + MEMJOURNAL_DFLT_FILECHUNKSIZE)) - uint64(unsafe.Sizeof(FileChunk{})))) } @@ -76353,7 +75700,7 @@ func Xsqlite3JournalOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pJfd uintpt (*MemJournal)(unsafe.Pointer(p)).Fflags = flags (*MemJournal)(unsafe.Pointer(p)).FzJournal = zName (*MemJournal)(unsafe.Pointer(p)).FpVfs = pVfs - return 0 + return SQLITE_OK } // Open an in-memory journal file. @@ -76405,15 +75752,15 @@ func walkWindowList(tls *libc.TLS, pWalker uintptr, pList uintptr) int32 { /* sq var rc int32 rc = Xsqlite3WalkExprList(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpOrderBy) if rc != 0 { - return 2 + return WRC_Abort } rc = Xsqlite3WalkExprList(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpPartition) if rc != 0 { - return 2 + return WRC_Abort } rc = Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpFilter) if rc != 0 { - return 2 + return WRC_Abort } // The next two are purely for calls to sqlite3RenameExprUnmap() @@ -76422,14 +75769,14 @@ func walkWindowList(tls *libc.TLS, pWalker uintptr, pList uintptr) int32 { /* sq // not matter anyhow. rc = Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpStart) if rc != 0 { - return 2 + return WRC_Abort } rc = Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpEnd) if rc != 0 { - return 2 + return WRC_Abort } } - return 0 + return WRC_Continue } // Walk an expression tree. Invoke the callback once for each node @@ -76455,45 +75802,45 @@ func walkExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3. for 1 != 0 { rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pWalker + 8 /* &.xExprCallback */))))(tls, pWalker, pExpr) if rc != 0 { - return (rc & 2) + return (rc & WRC_Abort) } - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x004000 | 0x800000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_TokenOnly | EP_Leaf))) != U32(0)) { if ((*Expr)(unsafe.Pointer(pExpr)).FpLeft != 0) && (walkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) != 0) { - return 2 + return WRC_Abort } if (*Expr)(unsafe.Pointer(pExpr)).FpRight != 0 { pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpRight continue - } else if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + } else if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { if Xsqlite3WalkSelect(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) != 0 { - return 2 + return WRC_Abort } } else { if *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) != 0 { if Xsqlite3WalkExprList(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) != 0 { - return 2 + return WRC_Abort } } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { if walkWindowList(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */))) != 0 { - return 2 + return WRC_Abort } } } } break } - return 0 + return WRC_Continue } func Xsqlite3WalkExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:97606:20: */ if pExpr != 0 { return walkExpr(tls, pWalker, pExpr) } - return 0 + return WRC_Continue } // Call sqlite3WalkExpr() for every expression in list p or until @@ -76510,7 +75857,7 @@ func Xsqlite3WalkExprList(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* } { if Xsqlite3WalkExpr(tls, pWalker, (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr) != 0 { - return 2 + return WRC_Abort } } @@ -76522,7 +75869,7 @@ func Xsqlite3WalkExprList(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* goto __3 __3: } - return 0 + return WRC_Continue } // Walk all expressions associated with SELECT statement p. Do @@ -76531,26 +75878,26 @@ func Xsqlite3WalkExprList(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* // Return WRC_Abort or WRC_Continue. func Xsqlite3WalkSelectExpr(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sqlite3.c:97631:20: */ if Xsqlite3WalkExprList(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpEList) != 0 { - return 2 + return WRC_Abort } if Xsqlite3WalkExpr(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpWhere) != 0 { - return 2 + return WRC_Abort } if Xsqlite3WalkExprList(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpGroupBy) != 0 { - return 2 + return WRC_Abort } if Xsqlite3WalkExpr(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpHaving) != 0 { - return 2 + return WRC_Abort } if Xsqlite3WalkExprList(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpOrderBy) != 0 { - return 2 + return WRC_Abort } if Xsqlite3WalkExpr(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpLimit) != 0 { - return 2 + return WRC_Abort } { var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse - if (pParse != 0) && (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if (pParse != 0) && (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { // The following may return WRC_Abort if there are unresolvable // symbols (e.g. a table that does not exist) in a window definition. var rc int32 = walkWindowList(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpWinDefn) @@ -76558,7 +75905,7 @@ func Xsqlite3WalkSelectExpr(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { / } } - return 0 + return WRC_Continue } // Walk the parse trees associated with all subqueries in the @@ -76581,11 +75928,11 @@ func Xsqlite3WalkSelectFrom(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { / } { if ((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect != 0) && (Xsqlite3WalkSelect(tls, pWalker, (*SrcList_item)(unsafe.Pointer(pItem)).FpSelect) != 0) { - return 2 + return WRC_Abort } if ((uint32(int32(*(*uint8)(unsafe.Pointer((pItem + 60 /* &.fg */) + 4 /* &.isTabFunc */)) & 0x4 >> 2))) != 0) && (Xsqlite3WalkExprList(tls, pWalker, *(*uintptr)(unsafe.Pointer(pItem + 96 /* &.u1 */))) != 0) { - return 2 + return WRC_Abort } } @@ -76597,7 +75944,7 @@ func Xsqlite3WalkSelectFrom(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { / goto __3 __3: } - return 0 + return WRC_Continue } // Call sqlite3WalkExpr() for every expression in Select statement p. @@ -76618,26 +75965,26 @@ func Xsqlite3WalkSelectFrom(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { / func Xsqlite3WalkSelect(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sqlite3.c:97697:20: */ var rc int32 if p == uintptr(0) { - return 0 + return WRC_Continue } if (*Walker)(unsafe.Pointer(pWalker)).FxSelectCallback == uintptr(0) { - return 0 + return WRC_Continue } for ok := true; ok; ok = (p != uintptr(0)) { rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pWalker + 16 /* &.xSelectCallback */))))(tls, pWalker, p) if rc != 0 { - return (rc & 2) + return (rc & WRC_Abort) } if (Xsqlite3WalkSelectExpr(tls, pWalker, p) != 0) || (Xsqlite3WalkSelectFrom(tls, pWalker, p) != 0) { - return 2 + return WRC_Abort } if (*Walker)(unsafe.Pointer(pWalker)).FxSelectCallback2 != 0 { (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer((pWalker + 24 /* &.xSelectCallback2 */))))(tls, pWalker, p) } p = (*Select)(unsafe.Pointer(p)).FpPrior } - return 0 + return WRC_Continue } // Increase the walkerDepth when entering a subquery, and @@ -76645,7 +75992,7 @@ func Xsqlite3WalkSelect(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sq func Xsqlite3WalkerDepthIncrease(tls *libc.TLS, pWalker uintptr, pSelect uintptr) int32 { /* sqlite3.c:97720:20: */ _ = pSelect (*Walker)(unsafe.Pointer(pWalker)).FwalkerDepth++ - return 0 + return WRC_Continue } func Xsqlite3WalkerDepthDecrease(tls *libc.TLS, pWalker uintptr, pSelect uintptr) { /* sqlite3.c:97725:21: */ @@ -76663,7 +76010,7 @@ func Xsqlite3WalkerDepthDecrease(tls *libc.TLS, pWalker uintptr, pSelect uintptr func Xsqlite3ExprWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) int32 { /* sqlite3.c:97740:20: */ _ = NotUsed _ = NotUsed2 - return 0 + return WRC_Continue } // No-op routine for the parse-tree walker for SELECT statements. @@ -76671,7 +76018,7 @@ func Xsqlite3ExprWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) int3 func Xsqlite3SelectWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) int32 { /* sqlite3.c:97749:20: */ _ = NotUsed _ = NotUsed2 - return 0 + return WRC_Continue } //************* End of walker.c ********************************************* @@ -76704,10 +76051,10 @@ func Xsqlite3SelectWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) in // // See also the sqlite3WindowExtraAggFuncDepth() routine in window.c func incrAggDepth(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:97790:12: */ - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 165 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_FUNCTION { *(*U8)(unsafe.Pointer(pExpr + 2 /* &.op2 */)) += U8((*(*int32)(unsafe.Pointer(pWalker + 40 /* &.u */)))) } - return 0 + return WRC_Continue } func incrAggFunctionDepth(tls *libc.TLS, pExpr uintptr, N int32) { /* sqlite3.c:97794:13: */ @@ -76753,10 +76100,10 @@ func resolveAlias(tls *libc.TLS, pParse uintptr, pEList uintptr, iCol int32, pEx db = (*Parse)(unsafe.Pointer(pParse)).Fdb pDup = Xsqlite3ExprDup(tls, db, pOrig, 0) if pDup != uintptr(0) { - if int32(*(*int8)(unsafe.Pointer(zType + uintptr(0)))) != 'G' { + if int32(*(*int8)(unsafe.Pointer(zType))) != 'G' { incrAggFunctionDepth(tls, pDup, nSubquery) } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 111 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLLATE { pDup = Xsqlite3ExprAddCollateString(tls, pParse, pDup, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */))) } @@ -76766,15 +76113,15 @@ func resolveAlias(tls *libc.TLS, pParse uintptr, pEList uintptr, iCol int32, pEx // The pExpr->u.zToken might point into memory that will be freed by the // sqlite3DbFree(db, pDup) on the last line of this block, so be sure to // make a copy of the token before doing the sqlite3DbFree(). - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x8000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Static) Xsqlite3ExprDelete(tls, db, pExpr) libc.Xmemcpy(tls, pExpr, pDup, uint64(unsafe.Sizeof(Expr{}))) - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000400))) != U32(0)) && (*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) != uintptr(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_IntValue)) != U32(0)) && (*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) != uintptr(0)) { *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) = Xsqlite3DbStrDup(tls, db, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */))) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x010000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_MemToken) } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { if *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) != uintptr(0) { (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FpOwner = pExpr } else { @@ -76783,7 +76130,7 @@ func resolveAlias(tls *libc.TLS, pParse uintptr, pEList uintptr, iCol int32, pEx } Xsqlite3DbFree(tls, db, pDup) } - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x400000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Alias) } // Return TRUE if the name zCol occurs anywhere in the USING clause. @@ -76810,7 +76157,7 @@ func nameInUsingClause(tls *libc.TLS, pUsing uintptr, zCol uintptr) int32 { /* s func Xsqlite3MatchEName(tls *libc.TLS, pItem uintptr, zCol uintptr, zTab uintptr, zDb uintptr) int32 { /* sqlite3.c:97897:20: */ var n int32 var zSpan uintptr - if (int32(*(*uint8)(unsafe.Pointer(pItem + 20 /* &.eEName */)) & 0x3 >> 0)) != 2 { + if (int32(*(*uint8)(unsafe.Pointer(pItem + 20 /* &.eEName */)) & 0x3 >> 0)) != ENAME_TAB { return 0 } zSpan = (*ExprList_item)(unsafe.Pointer(pItem)).FzEName @@ -76837,15 +76184,15 @@ func areDoubleQuotedStringsEnabled(tls *libc.TLS, db uintptr, pTopNC uintptr) in if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 { return 1 } // Always support for legacy schemas - if ((*NameContext)(unsafe.Pointer(pTopNC)).FncFlags & 0x10000) != 0 { + if ((*NameContext)(unsafe.Pointer(pTopNC)).FncFlags & NC_IsDDL) != 0 { // Currently parsing a DDL statement - if (Xsqlite3WritableSchema(tls, db) != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x40000000)) != uint64(0)) { + if (Xsqlite3WritableSchema(tls, db) != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DqsDML) != uint64(0)) { return 1 } - return (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x20000000)) != uint64(0))) + return (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DqsDDL) != uint64(0))) } else { // Currently parsing a DML statement - return (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x40000000)) != uint64(0))) + return (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DqsDML) != uint64(0))) } return int32(0) } @@ -76859,8 +76206,8 @@ func Xsqlite3ExprColUsed(tls *libc.TLS, pExpr uintptr) Bitmask { /* sqlite3.c:97 n = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) pExTab = *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) - if (((*Table)(unsafe.Pointer(pExTab)).FtabFlags & U32(0x0060)) != U32(0)) && - ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pExTab)).FaCol+uintptr(n)*32)).FcolFlags) & 0x0060) != 0) { + if (((*Table)(unsafe.Pointer(pExTab)).FtabFlags & TF_HasGenerated) != U32(0)) && + ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pExTab)).FaCol+uintptr(n)*32)).FcolFlags) & COLFLAG_GENERATED) != 0) { if int32((*Table)(unsafe.Pointer(pExTab)).FnCol) >= (int32(uint64(unsafe.Sizeof(Bitmask(0))) * uint64(8))) { return libc.Uint64(libc.Uint64FromInt32(-1)) @@ -76937,7 +76284,7 @@ func lookupName(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, zCol u pMatch = uintptr(0) pTopNC = pNC pSchema = uintptr(0) - eNewExprOp = 164 + eNewExprOp = TK_COLUMN pTab = uintptr(0) // A column of pTab // the name context cannot be NULL. @@ -76953,7 +76300,7 @@ func lookupName(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, zCol u goto __1 } - if !(((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (0x00002 | 0x00004)) != 0) { + if !(((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_PartIdx | NC_IsCheck)) != 0) { goto __2 } // Silently ignore database qualifiers inside CHECK constraints and @@ -76988,8 +76335,8 @@ __6: } // This branch is taken when the main database has been renamed // using SQLITE_DBCONFIG_MAINDBNAME. - pSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FpSchema - zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FzDbSName + pSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema + zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName __8: ; __3: @@ -77013,7 +76360,7 @@ __13: } pTab = (*SrcList_item)(unsafe.Pointer(pItem)).FpTab - if !(((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect != 0) && (((*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect)).FselFlags & U32(0x0000800)) != U32(0))) { + if !(((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect != 0) && (((*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect)).FselFlags & SF_NestedFrom) != U32(0))) { goto __16 } hit = 0 @@ -77069,7 +76416,7 @@ __22: goto __14 __24: ; - if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && ((*SrcList_item)(unsafe.Pointer(pItem)).FzAlias != 0)) { + if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && ((*SrcList_item)(unsafe.Pointer(pItem)).FzAlias != 0)) { goto __25 } Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), (pExpr + 64 /* &.y */ /* &.pTab */)) @@ -77099,7 +76446,7 @@ __27: if !(cnt == 1) { goto __31 } - if !((int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & 0x0004) != 0) { + if !((int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & JT_NATURAL) != 0) { goto __32 } goto __28 @@ -77148,10 +76495,10 @@ __15: *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = (*SrcList_item)(unsafe.Pointer(pMatch)).FpTab // RIGHT JOIN not (yet) supported - if !((int32((*SrcList_item)(unsafe.Pointer(pMatch)).Ffg.Fjointype) & 0x0008) != 0) { + if !((int32((*SrcList_item)(unsafe.Pointer(pMatch)).Ffg.Fjointype) & JT_LEFT) != 0) { goto __35 } - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x100000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_CanBeNull) __35: ; pSchema = (*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FpSchema @@ -77172,14 +76519,14 @@ __12: } op = int32((*Parse)(unsafe.Pointer(pParse)).FeTriggerOp) - if !((op != 126) && (Xsqlite3StrICmp(tls, ts+5287 /* "new" */, zTab) == 0)) { + if !((op != TK_DELETE) && (Xsqlite3StrICmp(tls, ts+5287 /* "new" */, zTab) == 0)) { goto __38 } (*Expr)(unsafe.Pointer(pExpr)).FiTable = 1 pTab = (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab goto __39 __38: - if !((op != 125) && (Xsqlite3StrICmp(tls, ts+5291 /* "old" */, zTab) == 0)) { + if !((op != TK_INSERT) && (Xsqlite3StrICmp(tls, ts+5291 /* "old" */, zTab) == 0)) { goto __40 } (*Expr)(unsafe.Pointer(pExpr)).FiTable = 0 @@ -77190,15 +76537,15 @@ __39: ; __37: ; - if !(((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00200) != 0) { + if !(((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_UUpsert) != 0) { goto __41 } pUpsert = *(*uintptr)(unsafe.Pointer(pNC + 16 /* &.uNC */)) if !((pUpsert != 0) && (Xsqlite3StrICmp(tls, ts+5295 /* "excluded" */, zTab) == 0)) { goto __42 } - pTab = (*SrcList_item)(unsafe.Pointer(((*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab - (*Expr)(unsafe.Pointer(pExpr)).FiTable = 2 + pTab = (*SrcList_item)(unsafe.Pointer(((*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc + 8 /* &.a */))).FpTab + (*Expr)(unsafe.Pointer(pExpr)).FiTable = EXCLUDED_TABLE_NUMBER __42: ; __41: @@ -77236,7 +76583,7 @@ __45: goto __46 __46: ; - if !(((iCol >= int32((*Table)(unsafe.Pointer(pTab)).FnCol)) && (Xsqlite3IsRowid(tls, zCol) != 0)) && (((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0200)) == U32(0))) { + if !(((iCol >= int32((*Table)(unsafe.Pointer(pTab)).FnCol)) && (Xsqlite3IsRowid(tls, zCol) != 0)) && (((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_NoVisibleRowid) == U32(0))) { goto __49 } // IMP: R-51414-32910 @@ -77247,21 +76594,21 @@ __49: goto __50 } cnt++ - if !((*Expr)(unsafe.Pointer(pExpr)).FiTable == 2) { + if !((*Expr)(unsafe.Pointer(pExpr)).FiTable == EXCLUDED_TABLE_NUMBER) { goto __51 } - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __53 } (*Expr)(unsafe.Pointer(pExpr)).FiColumn = YnVar(iCol) *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = pTab - eNewExprOp = 164 + eNewExprOp = TK_COLUMN goto __54 __53: (*Expr)(unsafe.Pointer(pExpr)).FiTable = ((*Upsert)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNC + 16 /* &.uNC */)))).FregData + int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(iCol)))) - eNewExprOp = 173 - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x400000)) + eNewExprOp = TK_REGISTER + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Alias) __54: ; goto __52 @@ -77270,7 +76617,7 @@ __51: if !(iCol < 0) { goto __55 } - (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = int8(0x44) + (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = SQLITE_AFF_INTEGER goto __56 __55: if !((*Expr)(unsafe.Pointer(pExpr)).FiTable == 0) { @@ -77299,7 +76646,7 @@ __56: ; *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = pTab (*Expr)(unsafe.Pointer(pExpr)).FiColumn = I16(iCol) - eNewExprOp = 77 + eNewExprOp = TK_TRIGGER __52: ; __50: @@ -77313,14 +76660,14 @@ __36: if !((((((cnt == 0) && (cntTab == 1)) && (pMatch != 0)) && - (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (0x00020 | 0x00008)) == 0)) && + (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_IdxExpr | NC_GenCol)) == 0)) && (Xsqlite3IsRowid(tls, zCol) != 0)) && - (((*Table)(unsafe.Pointer(((*SrcList_item)(unsafe.Pointer(pMatch)).FpTab))).FtabFlags & U32(0x0200)) == U32(0))) { + (((*Table)(unsafe.Pointer(((*SrcList_item)(unsafe.Pointer(pMatch)).FpTab))).FtabFlags & TF_NoVisibleRowid) == U32(0))) { goto __59 } cnt = 1 (*Expr)(unsafe.Pointer(pExpr)).FiColumn = int16(-1) - (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = int8(0x44) + (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = SQLITE_AFF_INTEGER __59: ; @@ -77340,7 +76687,7 @@ __59: // clause is not standard SQL. This is a (goofy) SQLite extension, that // is supported for backwards compatibility only. Hence, we issue a warning // on sqlite3_log() whenever the capability is used. - if !(((((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00080) != 0) && + if !(((((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_UEList) != 0) && (cnt == 0)) && (zTab == uintptr(0))) { goto __60 @@ -77353,39 +76700,39 @@ __61: goto __63 } zAs = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(j)*32)).FzEName - if !(((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(j)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0) && + if !(((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(j)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME) && (Xsqlite3_stricmp(tls, zAs, zCol) == 0)) { goto __64 } pOrig = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(j)*32)).FpExpr - if !((((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00001) == 0) && (((*Expr)(unsafe.Pointer((pOrig))).Fflags & (U32(0x000010))) != U32(0))) { + if !((((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_AllowAgg) == 0) && (((*Expr)(unsafe.Pointer((pOrig))).Fflags & (EP_Agg)) != U32(0))) { goto __65 } Xsqlite3ErrorMsg(tls, pParse, ts+5304 /* "misuse of aliase..." */, libc.VaList(bp, zAs)) - return 2 + return WRC_Abort __65: ; - if !((((*Expr)(unsafe.Pointer((pOrig))).Fflags & (U32(0x008000))) != U32(0)) && - ((((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x04000) == 0) || (pNC != pTopNC))) { + if !((((*Expr)(unsafe.Pointer((pOrig))).Fflags & (EP_Win)) != U32(0)) && + ((((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_AllowWin) == 0) || (pNC != pTopNC))) { goto __66 } Xsqlite3ErrorMsg(tls, pParse, ts+5335 /* "misuse of aliase..." */, libc.VaList(bp+8, zAs)) - return 2 + return WRC_Abort __66: ; if !(Xsqlite3ExprVectorSize(tls, pOrig) != 1) { goto __67 } Xsqlite3ErrorMsg(tls, pParse, ts+5372 /* "row value misuse..." */, 0) - return 2 + return WRC_Abort __67: ; resolveAlias(tls, pParse, pEList, j, pExpr, ts+703 /* "" */, nSubquery) cnt = 1 pMatch = uintptr(0) - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __68 } Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr) @@ -77435,7 +76782,7 @@ __11: goto __70 } - if !((((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000040))) != U32(0)) && + if !((((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_DblQuoted)) != U32(0)) && (areDoubleQuotedStringsEnabled(tls, db, pTopNC) != 0)) { goto __71 } @@ -77452,17 +76799,17 @@ __11: // Someday, I hope to get rid of this hack. Unfortunately there is // a huge amount of legacy SQL that uses it. So for now, we just // issue a warning. - Xsqlite3_log(tls, 28, + Xsqlite3_log(tls, SQLITE_WARNING, ts+5390 /* "double-quoted st..." */, libc.VaList(bp+16, zCol)) - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(115) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_STRING *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = uintptr(0) - return 1 + return WRC_Prune __71: ; if !(Xsqlite3ExprIdToTrueFalse(tls, pExpr) != 0) { goto __72 } - return 1 + return WRC_Prune __72: ; __70: @@ -77526,13 +76873,13 @@ __78: Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpRight) (*Expr)(unsafe.Pointer(pExpr)).FpRight = uintptr(0) (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(eNewExprOp) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x800000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Leaf) lookupname_end: if !(cnt == 1) { goto __79 } - if !(!(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x400000))) != U32(0))) { + if !(!(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Alias)) != U32(0))) { goto __81 } Xsqlite3AuthRead(tls, pParse, pExpr, pSchema, (*NameContext)(unsafe.Pointer(pNC)).FpSrcList) @@ -77556,10 +76903,10 @@ __83: goto __84 __84: ; - return 1 + return WRC_Prune goto __80 __79: - return 2 + return WRC_Abort __80: ; return int32(0) @@ -77568,7 +76915,7 @@ __80: // Allocate and return a pointer to an expression to load the column iCol // from datasource iSrc in SrcList pSrc. func Xsqlite3CreateColumnExpr(tls *libc.TLS, db uintptr, pSrc uintptr, iSrc int32, iCol int32) uintptr { /* sqlite3.c:98406:21: */ - var p uintptr = Xsqlite3ExprAlloc(tls, db, 164, uintptr(0), 0) + var p uintptr = Xsqlite3ExprAlloc(tls, db, TK_COLUMN, uintptr(0), 0) if p != 0 { var pItem uintptr = ((pSrc + 8 /* &.a */) + uintptr(iSrc)*112) var pTab uintptr = libc.AssignPtrUintptr(p+64 /* &.y */ /* &.pTab */, (*SrcList_item)(unsafe.Pointer(pItem)).FpTab) @@ -77577,8 +76924,8 @@ func Xsqlite3CreateColumnExpr(tls *libc.TLS, db uintptr, pSrc uintptr, iSrc int3 (*Expr)(unsafe.Pointer(p)).FiColumn = int16(-1) } else { (*Expr)(unsafe.Pointer(p)).FiColumn = YnVar(iCol) - if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != U32(0)) && - ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*32)).FcolFlags) & 0x0060) != 0) { + if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != U32(0)) && + ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*32)).FcolFlags) & COLFLAG_GENERATED) != 0) { (*SrcList_item)(unsafe.Pointer(pItem)).FcolUsed = func() uint64 { if int32((*Table)(unsafe.Pointer(pTab)).FnCol) >= 64 { @@ -77619,16 +76966,16 @@ func notValidImpl(tls *libc.TLS, pParse uintptr, pNC uintptr, zMsg uintptr, pExp defer tls.Free(16) var zIn uintptr = ts + 5492 /* "partial index WH..." */ - if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00020) != 0 { + if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_IdxExpr) != 0 { zIn = ts + 5520 /* "index expression..." */ - } else if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00004) != 0 { + } else if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_IsCheck) != 0 { zIn = ts + 5538 /* "CHECK constraint..." */ - } else if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00008) != 0 { + } else if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_GenCol) != 0 { zIn = ts + 5556 /* "generated column..." */ } Xsqlite3ErrorMsg(tls, pParse, ts+5574 /* "%s prohibited in..." */, libc.VaList(bp, zMsg, zIn)) if pExpr != 0 { - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(119) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_NULL } } @@ -77640,10 +76987,10 @@ func exprProbability(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:98474:12: */ defer tls.Free(8) *(*float64)(unsafe.Pointer(bp /* r */)) = -1.0 - if int32((*Expr)(unsafe.Pointer(p)).Fop) != 150 { + if int32((*Expr)(unsafe.Pointer(p)).Fop) != TK_FLOAT { return -1 } - Xsqlite3AtoF(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)), bp /* &r */, Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))), uint8(1)) + Xsqlite3AtoF(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)), bp /* &r */, Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))), SQLITE_UTF8) if *(*float64)(unsafe.Pointer(bp /* r */)) > 1.0 { return -1 @@ -77677,17 +77024,17 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s // column in the FROM clause. This is used by the LIMIT and ORDER BY // clause processing on UPDATE and DELETE statements, and by // UPDATE ... FROM statement processing. - case 75: + case TK_ROW: { var pSrcList uintptr = (*NameContext)(unsafe.Pointer(pNC)).FpSrcList var pItem uintptr pItem = pSrcList + 8 /* &.a */ - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(164) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_COLUMN *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = (*SrcList_item)(unsafe.Pointer(pItem)).FpTab (*Expr)(unsafe.Pointer(pExpr)).FiTable = (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor (*Expr)(unsafe.Pointer(pExpr)).FiColumn-- - (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = int8(0x44) + (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = SQLITE_AFF_INTEGER break } @@ -77699,28 +77046,28 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s // The TK_ID and TK_OUT cases are combined so that there will only // be one call to lookupName(). Then the compiler will in-line // lookupName() for a size reduction and performance increase. - case 59: + case TK_ID: fallthrough - case 139: + case TK_DOT: { var zColumn uintptr var zTable uintptr var zDb uintptr var pRight uintptr - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 59 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_ID { zDb = uintptr(0) zTable = uintptr(0) zColumn = *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) } else { var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft - if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & (0x00020 | 0x00008)) != 0 { + if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & (NC_IdxExpr | NC_GenCol)) != 0 { notValidImpl(tls, pParse, pNC, ts+5594 /* "the \".\" operator" */, uintptr(0)) } pRight = (*Expr)(unsafe.Pointer(pExpr)).FpRight - if int32((*Expr)(unsafe.Pointer(pRight)).Fop) == 59 { + if int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_ID { zDb = uintptr(0) } else { @@ -77730,7 +77077,7 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } zTable = *(*uintptr)(unsafe.Pointer(pLeft + 8 /* &.u */)) zColumn = *(*uintptr)(unsafe.Pointer(pRight + 8 /* &.u */)) - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameTokenRemap(tls, pParse, pExpr, pRight) Xsqlite3RenameTokenRemap(tls, pParse, (pExpr + 64 /* &.y */ /* &.pTab */), pLeft) } @@ -77740,7 +77087,7 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } // Resolve function names - case 169: + case TK_FUNCTION: { var pList uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) // The argument list var n int32 @@ -77756,9 +77103,9 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s var zId uintptr // The function name. var pDef uintptr // Information about the function var enc U8 = (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fenc // The database encoding - var savedAllowFlags int32 = ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (0x00001 | 0x04000)) + var savedAllowFlags int32 = ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_AllowAgg | NC_AllowWin)) var pWin uintptr = func() uintptr { - if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) && (int32((*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FeFrmType) != 163) { + if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) && (int32((*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FeFrmType) != TK_FILTER) { return *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) } return uintptr(0) @@ -77776,10 +77123,10 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } } else { is_agg = (libc.Bool32((*FuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0))) - if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0400)) != 0 { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x040000)) + if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_UNLIKELY) != 0 { + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Unlikely) if n == 2 { - (*Expr)(unsafe.Pointer(pExpr)).FiTable = exprProbability(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(1)*32)).FpExpr) + (*Expr)(unsafe.Pointer(pExpr)).FiTable = exprProbability(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+1*32)).FpExpr) if (*Expr)(unsafe.Pointer(pExpr)).FiTable < 0 { Xsqlite3ErrorMsg(tls, pParse, @@ -77797,7 +77144,7 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s // to likelihood(X,0.9375). // TUNING: unlikely() probability is 0.0625. likely() is 0.9375 (*Expr)(unsafe.Pointer(pExpr)).FiTable = func() int32 { - if int32(*(*int8)(unsafe.Pointer((*FuncDef)(unsafe.Pointer(pDef)).FzName + uintptr(0)))) == 'u' { + if int32(*(*int8)(unsafe.Pointer((*FuncDef)(unsafe.Pointer(pDef)).FzName))) == 'u' { return 8388608 } return 125829120 @@ -77805,69 +77152,69 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } } { - var auth int32 = Xsqlite3AuthCheck(tls, pParse, 31, uintptr(0), (*FuncDef)(unsafe.Pointer(pDef)).FzName, uintptr(0)) - if auth != 0 { - if auth == 1 { + var auth int32 = Xsqlite3AuthCheck(tls, pParse, SQLITE_FUNCTION, uintptr(0), (*FuncDef)(unsafe.Pointer(pDef)).FzName, uintptr(0)) + if auth != SQLITE_OK { + if auth == SQLITE_DENY { Xsqlite3ErrorMsg(tls, pParse, ts+5682, /* "not authorized t..." */ libc.VaList(bp, (*FuncDef)(unsafe.Pointer(pDef)).FzName)) (*NameContext)(unsafe.Pointer(pNC)).FnErr++ } - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(119) - return 1 + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_NULL + return WRC_Prune } } - if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(0x0800 | 0x2000))) != 0 { + if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(SQLITE_FUNC_CONSTANT | SQLITE_FUNC_SLOCHNG))) != 0 { // For the purposes of the EP_ConstFunc flag, date and time // functions and other functions that change slowly are considered // constant because they are constant for the duration of one query. // This allows them to be factored out of inner loops. - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x080000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_ConstFunc) } - if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0800)) == U32(0) { + if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_CONSTANT) == U32(0) { // Clearly non-deterministic functions like random(), but also // date/time functions that use 'now', and other functions like // sqlite_version() that might change over time cannot be used // in an index or generated column. Curiously, they can be used // in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all // all this. - if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & ((0x00020 | 0x00002) | 0x00008)) != 0 { + if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & ((NC_IdxExpr | NC_PartIdx) | NC_GenCol)) != 0 { notValidImpl(tls, pParse, pNC, ts+5717 /* "non-deterministi..." */, uintptr(0)) } } else { // Must fit in 8 bits - (*Expr)(unsafe.Pointer(pExpr)).Fop2 = (U8((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x0002e)) - if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x40000) != 0 { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x40000000)) + (*Expr)(unsafe.Pointer(pExpr)).Fop2 = (U8((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_SelfRef)) + if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_FromDDL) != 0 { + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_FromDDL) } } - if ((((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x00040000)) != U32(0)) && + if ((((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_INTERNAL) != U32(0)) && (int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0)) && - (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags & U32(0x0020)) == U32(0)) { + (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags & DBFLAG_InternalFunc) == U32(0)) { // Internal-use-only functions are disallowed unless the // SQL is being compiled using sqlite3NestedParse() or // the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control has be // used to activate internal functionsn for testing purposes no_such_func = 1 pDef = uintptr(0) - } else if (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(0x00080000 | 0x00200000))) != U32(0)) && - !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + } else if (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(SQLITE_FUNC_DIRECT | SQLITE_FUNC_UNSAFE))) != U32(0)) && + !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { Xsqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef) } } - if 0 == (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) { + if 0 == (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) { if ((pDef != 0) && ((*FuncDef)(unsafe.Pointer(pDef)).FxValue == uintptr(0))) && (pWin != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+5745 /* "%.*s() may not b..." */, libc.VaList(bp+8, nId, zId)) (*NameContext)(unsafe.Pointer(pNC)).FnErr++ - } else if (((is_agg != 0) && (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00001) == 0)) || - (((is_agg != 0) && (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x00010000)) != 0)) && !(pWin != 0))) || - (((is_agg != 0) && (pWin != 0)) && (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x04000) == 0)) { + } else if (((is_agg != 0) && (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_AllowAgg) == 0)) || + (((is_agg != 0) && (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_WINDOW) != 0)) && !(pWin != 0))) || + (((is_agg != 0) && (pWin != 0)) && (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_AllowWin) == 0)) { var zType uintptr - if (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x00010000)) != 0) || (pWin != 0) { + if (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_WINDOW) != 0) || (pWin != 0) { zType = ts + 5789 /* "window" */ } else { zType = ts + 5796 /* "aggregate" */ @@ -77882,7 +77229,7 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s Xsqlite3ErrorMsg(tls, pParse, ts+5858, /* "wrong number of ..." */ libc.VaList(bp+64, nId, zId)) (*NameContext)(unsafe.Pointer(pNC)).FnErr++ - } else if (is_agg == 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + } else if (is_agg == 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) { Xsqlite3ErrorMsg(tls, pParse, ts+5903, /* "FILTER may not b..." */ libc.VaList(bp+80, nId, zId)) @@ -77892,14 +77239,14 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s // Window functions may not be arguments of aggregate functions. // Or arguments of other window functions. But aggregate functions // may be arguments for window functions. - *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (^(0x04000 | (func() int32 { + *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (^(NC_AllowWin | (func() int32 { if !(pWin != 0) { - return 0x00001 + return NC_AllowAgg } return 0 }()))) } - } else if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + } else if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { is_agg = 1 } Xsqlite3WalkExprList(tls, pWalker, pList) @@ -77907,7 +77254,7 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s if pWin != 0 { var pSel uintptr = (*NameContext)(unsafe.Pointer(pNC)).FpWinSelect - if (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) == 0 { + if (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) == 0 { Xsqlite3WindowUpdate(tls, pParse, func() uintptr { if pSel != 0 { return (*Select)(unsafe.Pointer(pSel)).FpWinDefn @@ -77919,12 +77266,12 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s Xsqlite3WalkExprList(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpOrderBy) Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpFilter) Xsqlite3WindowLink(tls, pSel, pWin) - *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) |= (0x08000) + *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) |= (NC_HasWin) } else { var pNC2 uintptr = pNC - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(165) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_AGG_FUNCTION (*Expr)(unsafe.Pointer(pExpr)).Fop2 = U8(0) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FpFilter) } for (pNC2 != 0) && !(Xsqlite3FunctionUsesThisSrc(tls, pExpr, (*NameContext)(unsafe.Pointer(pNC2)).FpSrcList) != 0) { @@ -77934,7 +77281,7 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s if (pNC2 != 0) && (pDef != 0) { - *(*int32)(unsafe.Pointer(pNC2 + 40 /* &.ncFlags */)) |= int32((U32(0x00010) | ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x1000)))) + *(*int32)(unsafe.Pointer(pNC2 + 40 /* &.ncFlags */)) |= int32((NC_HasAgg | ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_MINMAX))) } } @@ -77942,79 +77289,78 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } // FIX ME: Compute pExpr->affinity based on the expected return // type of the function - return 1 + return WRC_Prune } - case 136: + case TK_SELECT: fallthrough - case 20: + case TK_EXISTS: fallthrough - case 49: + case TK_IN: { - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { var nRef int32 = (*NameContext)(unsafe.Pointer(pNC)).FnRef - if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & (((0x00004 | 0x00002) | 0x00020) | 0x00008)) != 0 { + if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & (((NC_IsCheck | NC_PartIdx) | NC_IdxExpr) | NC_GenCol)) != 0 { notValidImpl(tls, pParse, pNC, ts+5952 /* "subqueries" */, pExpr) } Xsqlite3WalkSelect(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) if nRef != (*NameContext)(unsafe.Pointer(pNC)).FnRef { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x000020)) - *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) |= (0x00040) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_VarSelect) + *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) |= (NC_VarSelect) } } break } - case 153: + case TK_VARIABLE: { - if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & (((0x00004 | 0x00002) | 0x00020) | 0x00008)) != 0 { + if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & (((NC_IsCheck | NC_PartIdx) | NC_IdxExpr) | NC_GenCol)) != 0 { notValidImpl(tls, pParse, pNC, ts+5963 /* "parameters" */, pExpr) } break } - case 45: + case TK_IS: fallthrough - case 168: + case TK_ISNOT: { var pRight uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) // Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE", // and "x IS NOT FALSE". - if (pRight != 0) && (int32((*Expr)(unsafe.Pointer(pRight)).Fop) == 59) { + if (pRight != 0) && (int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_ID) { var rc int32 = resolveExprStep(tls, pWalker, pRight) - if rc == 2 { - return 2 + if rc == WRC_Abort { + return WRC_Abort } - if int32((*Expr)(unsafe.Pointer(pRight)).Fop) == 167 { + if int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_TRUEFALSE { (*Expr)(unsafe.Pointer(pExpr)).Fop2 = (*Expr)(unsafe.Pointer(pExpr)).Fop - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(172) - return 0 + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_TRUTH + return WRC_Continue } } - /* no break */ } fallthrough - case 48: + case TK_BETWEEN: fallthrough - case 53: + case TK_EQ: fallthrough - case 52: + case TK_NE: fallthrough - case 56: + case TK_LT: fallthrough - case 55: + case TK_LE: fallthrough - case 54: + case TK_GT: fallthrough - case 57: + case TK_GE: { var nLeft int32 var nRight int32 @@ -78023,10 +77369,10 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } nLeft = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 48 { - nRight = Xsqlite3ExprVectorSize(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))+8 /* &.a */)+uintptr(0)*32)).FpExpr) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_BETWEEN { + nRight = Xsqlite3ExprVectorSize(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */))).FpExpr) if nRight == nLeft { - nRight = Xsqlite3ExprVectorSize(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))+8 /* &.a */)+uintptr(1)*32)).FpExpr) + nRight = Xsqlite3ExprVectorSize(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))+8 /* &.a */)+1*32)).FpExpr) } } else { @@ -78041,9 +77387,9 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } } if ((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) || ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0) { - return 2 + return WRC_Abort } - return 0 + return WRC_Continue } // pEList is a list of expressions which are really the result set of the @@ -78061,10 +77407,10 @@ func resolveAsName(tls *libc.TLS, pParse uintptr, pEList uintptr, pE uintptr) in _ = pParse - if int32((*Expr)(unsafe.Pointer(pE)).Fop) == 59 { + if int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_ID { var zCol uintptr = *(*uintptr)(unsafe.Pointer(pE + 8 /* &.u */)) for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ { - if ((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0) && + if ((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME) && (Xsqlite3_stricmp(tls, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FzEName, zCol) == 0) { return (i + 1) } @@ -78108,11 +77454,11 @@ func resolveOrderByTermToExprList(tls *libc.TLS, pParse uintptr, pSelect uintptr (*NameContext)(unsafe.Pointer(bp /* &nc */)).FpParse = pParse (*NameContext)(unsafe.Pointer(bp /* &nc */)).FpSrcList = (*Select)(unsafe.Pointer(pSelect)).FpSrc *(*uintptr)(unsafe.Pointer(bp /* &nc */ + 16 /* &.uNC */)) = pEList - (*NameContext)(unsafe.Pointer(bp /* &nc */)).FncFlags = (0x00001 | 0x00080) + (*NameContext)(unsafe.Pointer(bp /* &nc */)).FncFlags = (NC_AllowAgg | NC_UEList) (*NameContext)(unsafe.Pointer(bp /* &nc */)).FnErr = 0 db = (*Parse)(unsafe.Pointer(pParse)).Fdb savedSuppErr = (*Sqlite3)(unsafe.Pointer(db)).FsuppressErr - if (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) == 0 { + if (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) == 0 { (*Sqlite3)(unsafe.Pointer(db)).FsuppressErr = U8(1) } rc = Xsqlite3ResolveExprNames(tls, bp /* &nc */, pE) @@ -78172,7 +77518,7 @@ func resolveCompoundOrderBy(tls *libc.TLS, pParse uintptr, pSelect uintptr) int3 return 0 } db = (*Parse)(unsafe.Pointer(pParse)).Fdb - if (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(2)*4)) { + if (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 2*4)) { Xsqlite3ErrorMsg(tls, pParse, ts+6030 /* "too many terms i..." */, 0) return 1 } @@ -78224,7 +77570,7 @@ func resolveCompoundOrderBy(tls *libc.TLS, pParse uintptr, pSelect uintptr) int3 // as is instead of transforming it to an integer as in the usual // case. This allows the code in alter.c to modify column // refererences within the ORDER BY expression as required. - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { pDup = pE } else { pDup = Xsqlite3ExprDup(tls, db, pE, 0) @@ -78233,7 +77579,7 @@ func resolveCompoundOrderBy(tls *libc.TLS, pParse uintptr, pSelect uintptr) int3 *(*int32)(unsafe.Pointer(bp + 8 /* iCol */)) = resolveOrderByTermToExprList(tls, pParse, pSelect, pDup) } - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { Xsqlite3ExprDelete(tls, db, pDup) } } @@ -78241,19 +77587,19 @@ func resolveCompoundOrderBy(tls *libc.TLS, pParse uintptr, pSelect uintptr) int3 if *(*int32)(unsafe.Pointer(bp + 8 /* iCol */)) > 0 { // Convert the ORDER BY term into an integer column number iCol, // taking care to preserve the COLLATE clause if it exists - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { - var pNew uintptr = Xsqlite3Expr(tls, db, 152, uintptr(0)) + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { + var pNew uintptr = Xsqlite3Expr(tls, db, TK_INTEGER, uintptr(0)) if pNew == uintptr(0) { return 1 } - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x000400)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (EP_IntValue) *(*int32)(unsafe.Pointer(pNew + 8 /* &.u */)) = *(*int32)(unsafe.Pointer(bp + 8 /* iCol */)) if (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr == pE { (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr = pNew } else { var pParent uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr - for int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pParent)).FpLeft)).Fop) == 111 { + for int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pParent)).FpLeft)).Fop) == TK_COLLATE { pParent = (*Expr)(unsafe.Pointer(pParent)).FpLeft } @@ -78305,10 +77651,10 @@ func Xsqlite3ResolveOrderGroupBy(tls *libc.TLS, pParse uintptr, pSelect uintptr, var pEList uintptr var pItem uintptr - if ((pOrderBy == uintptr(0)) || ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0)) || (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if ((pOrderBy == uintptr(0)) || ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0)) || (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { return 0 } - if (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(2)*4)) { + if (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 2*4)) { Xsqlite3ErrorMsg(tls, pParse, ts+6131 /* "too many terms i..." */, libc.VaList(bp, zType)) return 1 } @@ -78345,11 +77691,11 @@ __3: // Walker callback for windowRemoveExprFromSelect(). func resolveRemoveWindowsCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:99159:12: */ _ = pWalker - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { var pWin uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) Xsqlite3WindowUnlinkFromSelect(tls, pWin) } - return 0 + return WRC_Continue } // Remove any Window objects owned by the expression pExpr from the @@ -78412,7 +77758,7 @@ __1: { var pE uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr var pE2 uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, pE) - if int32(*(*int8)(unsafe.Pointer(zType + uintptr(0)))) != 'G' { + if int32(*(*int8)(unsafe.Pointer(zType))) != 'G' { *(*int32)(unsafe.Pointer(bp /* iCol */)) = resolveAsName(tls, pParse, (*Select)(unsafe.Pointer(pSelect)).FpEList, pE2) if *(*int32)(unsafe.Pointer(bp /* iCol */)) > 0 { // If an AS-name match is found, mark this ORDER BY column as being @@ -78478,8 +77824,8 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql var pLeftmost uintptr // Left-most of SELECT of a compound var db uintptr // Database connection - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000004)) != 0 { - return 1 + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_Resolved) != 0 { + return WRC_Prune } pOuterNC = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) pParse = (*Walker)(unsafe.Pointer(pWalker)).FpParse @@ -78492,12 +77838,12 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // sqlite3SelectPrep() do all of the processing for this SELECT. // sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and // this routine in the correct order. - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000040)) == U32(0) { + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_Expanded) == U32(0) { Xsqlite3SelectPrep(tls, pParse, p, pOuterNC) if ((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { - return 2 + return WRC_Abort } - return 1 + return WRC_Prune } isCompound = (libc.Bool32((*Select)(unsafe.Pointer(p)).FpPrior != uintptr(0))) @@ -78505,7 +77851,7 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql pLeftmost = p for p != 0 { - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0000004)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_Resolved) // Resolve the expressions in the LIMIT and OFFSET clauses. These // are not allowed to refer to any names, so pass an empty NameContext. @@ -78513,7 +77859,7 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpParse = pParse (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpWinSelect = p if Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*Select)(unsafe.Pointer(p)).FpLimit) != 0 { - return 2 + return WRC_Abort } // If the SF_Converted flags is set, then this Select object was @@ -78522,8 +77868,8 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // as if it were part of the sub-query, not the parent. This block // moves the pOrderBy down to the sub-query. It will be moved back // after the names have been resolved. - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0010000)) != 0 { - var pSub uintptr = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpSelect + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_Converted) != 0 { + var pSub uintptr = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpSelect (*Select)(unsafe.Pointer(pSub)).FpOrderBy = (*Select)(unsafe.Pointer(p)).FpOrderBy (*Select)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) @@ -78532,7 +77878,7 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // Recursively resolve names in all subqueries for i = 0; i < (*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc; i++ { var pItem uintptr = (((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(i)*112) - if ((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect != 0) && (((*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect)).FselFlags & U32(0x0000004)) == U32(0)) { + if ((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect != 0) && (((*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect)).FselFlags & SF_Resolved) == U32(0)) { var pNC uintptr // Used to iterate name contexts var nRef int32 = 0 // Refcount for pOuterNC and outer contexts var zSavedContext uintptr = (*Parse)(unsafe.Pointer(pParse)).FzAuthContext @@ -78552,7 +77898,7 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql Xsqlite3ResolveSelectNames(tls, pParse, (*SrcList_item)(unsafe.Pointer(pItem)).FpSelect, pOuterNC) (*Parse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedContext if ((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { - return 2 + return WRC_Abort } for pNC = pOuterNC; pNC != 0; pNC = (*NameContext)(unsafe.Pointer(pNC)).FpNext { @@ -78565,31 +77911,31 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // Set up the local name-context to pass to sqlite3ResolveExprNames() to // resolve the result-set expression list. - (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = (0x00001 | 0x04000) + (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = (NC_AllowAgg | NC_AllowWin) (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpSrcList = (*Select)(unsafe.Pointer(p)).FpSrc (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpNext = pOuterNC // Resolve names in the result set. if Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, (*Select)(unsafe.Pointer(p)).FpEList) != 0 { - return 2 + return WRC_Abort } - *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) &= (^libc.Int32(0x04000)) + *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) &= (libc.CplInt32(NC_AllowWin)) // If there are no aggregate functions in the result-set, and no GROUP BY // expression, do not allow aggregates in any of the other expressions. pGroupBy = (*Select)(unsafe.Pointer(p)).FpGroupBy - if (pGroupBy != 0) || (((*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags & 0x00010) != 0) { + if (pGroupBy != 0) || (((*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags & NC_HasAgg) != 0) { - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0000008 | ((*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags & 0x01000))) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(SF_Aggregate | ((*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags & NC_MinMaxAgg))) } else { - *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) &= (^libc.Int32(0x00001)) + *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) &= (libc.CplInt32(NC_AllowAgg)) } // If a HAVING clause is present, then there must be a GROUP BY clause. if ((*Select)(unsafe.Pointer(p)).FpHaving != 0) && !(pGroupBy != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+6162 /* "a GROUP BY claus..." */, 0) - return 2 + return WRC_Abort } // Add the output column list to the name-context before parsing the @@ -78601,12 +77947,12 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // re-evaluated for each reference to it. *(*uintptr)(unsafe.Pointer(bp /* &sNC */ + 16 /* &.uNC */)) = (*Select)(unsafe.Pointer(p)).FpEList - *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) |= (0x00080) + *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) |= (NC_UEList) if Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*Select)(unsafe.Pointer(p)).FpHaving) != 0 { - return 2 + return WRC_Abort } if Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*Select)(unsafe.Pointer(p)).FpWhere) != 0 { - return 2 + return WRC_Abort } // Resolve names in table-valued-function arguments @@ -78614,22 +77960,22 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql var pItem uintptr = (((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(i)*112) if ((uint32(int32(*(*uint8)(unsafe.Pointer((pItem + 60 /* &.fg */) + 4 /* &.isTabFunc */)) & 0x4 >> 2))) != 0) && (Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, *(*uintptr)(unsafe.Pointer(pItem + 96 /* &.u1 */))) != 0) { - return 2 + return WRC_Abort } } // The ORDER BY and GROUP BY clauses may not refer to terms in // outer queries (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpNext = uintptr(0) - *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) |= (0x00001 | 0x04000) + *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) |= (NC_AllowAgg | NC_AllowWin) // If this is a converted compound query, move the ORDER BY clause from // the sub-query back to the parent query. At this point each term // within the ORDER BY clause has been transformed to an integer value. // These integers will be replaced by copies of the corresponding result // set expressions by the call to resolveOrderGroupBy() below. - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0010000)) != 0 { - var pSub uintptr = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpSelect + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_Converted) != 0 { + var pSub uintptr = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpSelect (*Select)(unsafe.Pointer(p)).FpOrderBy = (*Select)(unsafe.Pointer(pSub)).FpOrderBy (*Select)(unsafe.Pointer(pSub)).FpOrderBy = uintptr(0) } @@ -78645,12 +77991,12 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // resolve those symbols on the incorrect ORDER BY for consistency. if (isCompound <= nCompound) && // Defer right-most ORDER BY of a compound (resolveOrderGroupBy(tls, bp /* &sNC */, p, (*Select)(unsafe.Pointer(p)).FpOrderBy, ts+6064 /* "ORDER" */) != 0) { - return 2 + return WRC_Abort } if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - return 2 + return WRC_Abort } - *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) &= (^libc.Int32(0x04000)) + *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) &= (libc.CplInt32(NC_AllowWin)) // Resolve the GROUP BY clause. At the same time, make sure // the GROUP BY clause does not contain aggregate functions. @@ -78658,7 +78004,7 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql var pItem uintptr if (resolveOrderGroupBy(tls, bp /* &sNC */, p, pGroupBy, ts+6206 /* "GROUP" */) != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { - return 2 + return WRC_Abort } i = 0 pItem = pGroupBy + 8 /* &.a */ @@ -78667,10 +78013,10 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql goto __3 } { - if ((*Expr)(unsafe.Pointer(((*ExprList_item)(unsafe.Pointer(pItem)).FpExpr))).Fflags & (U32(0x000010))) != U32(0) { + if ((*Expr)(unsafe.Pointer(((*ExprList_item)(unsafe.Pointer(pItem)).FpExpr))).Fflags & (EP_Agg)) != U32(0) { Xsqlite3ErrorMsg(tls, pParse, ts+6212 /* "aggregate functi..." */, 0) - return 2 + return WRC_Abort } } @@ -78683,12 +78029,12 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql __3: } - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { var pWin uintptr for pWin = (*Select)(unsafe.Pointer(p)).FpWinDefn; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { if (Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, (*Window)(unsafe.Pointer(pWin)).FpOrderBy) != 0) || (Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, (*Window)(unsafe.Pointer(pWin)).FpPartition) != 0) { - return 2 + return WRC_Abort } } } @@ -78697,7 +78043,7 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // number of expressions in the select list. if ((*Select)(unsafe.Pointer(p)).FpNext != 0) && ((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr != (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpNext)).FpEList)).FnExpr) { Xsqlite3SelectWrongNumTermsError(tls, pParse, (*Select)(unsafe.Pointer(p)).FpNext) - return 2 + return WRC_Abort } // Advance to the next term of the compound @@ -78708,10 +78054,10 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // Resolve the ORDER BY on a compound SELECT after all terms of // the compound have been resolved. if (isCompound != 0) && (resolveCompoundOrderBy(tls, pParse, pLeftmost) != 0) { - return 2 + return WRC_Abort } - return 1 + return WRC_Prune } // This routine walks an expression tree and resolves references to @@ -78768,10 +78114,10 @@ func Xsqlite3ResolveExprNames(tls *libc.TLS, pNC uintptr, pExpr uintptr) int32 { // var w Walker at bp, 48 if pExpr == uintptr(0) { - return 0 + return SQLITE_OK } - savedHasAgg = ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((0x00010 | 0x01000) | 0x08000)) - *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (^libc.Int32(((0x00010 | 0x01000) | 0x08000))) + savedHasAgg = ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin)) + *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (libc.CplInt32(((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin))) (*Walker)(unsafe.Pointer(bp /* &w */)).FpParse = (*NameContext)(unsafe.Pointer(pNC)).FpParse (*Walker)(unsafe.Pointer(bp /* &w */)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) int32 @@ -78783,12 +78129,12 @@ func Xsqlite3ResolveExprNames(tls *libc.TLS, pNC uintptr, pExpr uintptr) int32 { *(*uintptr)(unsafe.Pointer(bp /* &w */ + 40 /* &.u */)) = pNC *(*int32)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse + 292 /* &.nHeight */)) += ((*Expr)(unsafe.Pointer(pExpr)).FnHeight) if Xsqlite3ExprCheckHeight(tls, (*Walker)(unsafe.Pointer(bp /* &w */)).FpParse, (*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse)).FnHeight) != 0 { - return 1 + return SQLITE_ERROR } Xsqlite3WalkExpr(tls, bp /* &w */, pExpr) *(*int32)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse + 292 /* &.nHeight */)) -= ((*Expr)(unsafe.Pointer(pExpr)).FnHeight) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (0x00010 | 0x08000))) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_HasAgg | NC_HasWin))) *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) |= (savedHasAgg) return (libc.Bool32(((*NameContext)(unsafe.Pointer(pNC)).FnErr > 0) || ((*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse)).FnErr > 0))) } @@ -78805,7 +78151,7 @@ func Xsqlite3ResolveExprListNames(tls *libc.TLS, pNC uintptr, pList uintptr) int // var w Walker at bp, 48 if pList == uintptr(0) { - return 0 + return WRC_Continue } (*Walker)(unsafe.Pointer(bp /* &w */)).FpParse = (*NameContext)(unsafe.Pointer(pNC)).FpParse (*Walker)(unsafe.Pointer(bp /* &w */)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct { @@ -78816,8 +78162,8 @@ func Xsqlite3ResolveExprListNames(tls *libc.TLS, pNC uintptr, pList uintptr) int }{resolveSelectStep})) (*Walker)(unsafe.Pointer(bp /* &w */)).FxSelectCallback2 = uintptr(0) *(*uintptr)(unsafe.Pointer(bp /* &w */ + 40 /* &.u */)) = pNC - savedHasAgg = ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((0x00010 | 0x01000) | 0x08000)) - *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (^libc.Int32(((0x00010 | 0x01000) | 0x08000))) + savedHasAgg = ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin)) + *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (libc.CplInt32(((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin))) for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ { var pExpr uintptr = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(i)*32)).FpExpr if pExpr == uintptr(0) { @@ -78825,22 +78171,22 @@ func Xsqlite3ResolveExprListNames(tls *libc.TLS, pNC uintptr, pList uintptr) int } *(*int32)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse + 292 /* &.nHeight */)) += ((*Expr)(unsafe.Pointer(pExpr)).FnHeight) if Xsqlite3ExprCheckHeight(tls, (*Walker)(unsafe.Pointer(bp /* &w */)).FpParse, (*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse)).FnHeight) != 0 { - return 2 + return WRC_Abort } Xsqlite3WalkExpr(tls, bp /* &w */, pExpr) *(*int32)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse + 292 /* &.nHeight */)) -= ((*Expr)(unsafe.Pointer(pExpr)).FnHeight) - if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((0x00010 | 0x01000) | 0x08000)) != 0 { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (0x00010 | 0x08000))) - savedHasAgg = savedHasAgg | ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((0x00010 | 0x01000) | 0x08000)) - *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (^libc.Int32(((0x00010 | 0x01000) | 0x08000))) + if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin)) != 0 { + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_HasAgg | NC_HasWin))) + savedHasAgg = savedHasAgg | ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin)) + *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (libc.CplInt32(((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin))) } if ((*NameContext)(unsafe.Pointer(pNC)).FnErr > 0) || ((*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse)).FnErr > 0) { - return 2 + return WRC_Abort } } *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) |= (savedHasAgg) - return 0 + return WRC_Continue } // Resolve all names in all expressions of a SELECT and in all @@ -78901,19 +78247,19 @@ func Xsqlite3ResolveSelfReference(tls *libc.TLS, pParse uintptr, pTab uintptr, t libc.Xmemset(tls, bp+56 /* &sSrc */, 0, uint64(unsafe.Sizeof(SrcList{}))) if pTab != 0 { (*SrcList)(unsafe.Pointer(bp + 56 /* &sSrc */)).FnSrc = 1 - (*SrcList_item)(unsafe.Pointer((bp + 56 /* &sSrc */ + 8 /* &.a */) + uintptr(0)*112)).FzName = (*Table)(unsafe.Pointer(pTab)).FzName - (*SrcList_item)(unsafe.Pointer((bp + 56 /* &sSrc */ + 8 /* &.a */) + uintptr(0)*112)).FpTab = pTab - (*SrcList_item)(unsafe.Pointer((bp + 56 /* &sSrc */ + 8 /* &.a */) + uintptr(0)*112)).FiCursor = -1 - if (*Table)(unsafe.Pointer(pTab)).FpSchema != (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb+uintptr(1)*32)).FpSchema { + (*SrcList_item)(unsafe.Pointer((bp + 56 /* &sSrc */ + 8 /* &.a */))).FzName = (*Table)(unsafe.Pointer(pTab)).FzName + (*SrcList_item)(unsafe.Pointer((bp + 56 /* &sSrc */ + 8 /* &.a */))).FpTab = pTab + (*SrcList_item)(unsafe.Pointer((bp + 56 /* &sSrc */ + 8 /* &.a */))).FiCursor = -1 + if (*Table)(unsafe.Pointer(pTab)).FpSchema != (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb+1*32)).FpSchema { // Cause EP_FromDDL to be set on TK_FUNCTION nodes of non-TEMP // schema elements - type1 = type1 | (0x40000) + type1 = type1 | (NC_FromDDL) } } (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpParse = pParse (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpSrcList = bp + 56 /* &sSrc */ - (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = (type1 | 0x10000) - if (libc.AssignInt32(&rc, Xsqlite3ResolveExprNames(tls, bp /* &sNC */, pExpr))) != 0 { + (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = (type1 | NC_IsDDL) + if (libc.AssignInt32(&rc, Xsqlite3ResolveExprNames(tls, bp /* &sNC */, pExpr))) != SQLITE_OK { return rc } if pList != 0 { @@ -78928,7 +78274,7 @@ func Xsqlite3TableColumnAffinity(tls *libc.TLS, pTab uintptr, iCol int32) int8 { if iCol >= 0 { return (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*32)).Faffinity } - return int8(0x44) + return SQLITE_AFF_INTEGER } // Return the 'affinity' of the expression pExpr if any. @@ -78947,33 +78293,33 @@ func Xsqlite3TableColumnAffinity(tls *libc.TLS, pTab uintptr, iCol int32) int8 { // SELECT * FROM t1 WHERE (select a from t1); func Xsqlite3ExprAffinity(tls *libc.TLS, pExpr uintptr) int8 { /* sqlite3.c:99759:21: */ var op int32 - for ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x001000))) != U32(0) { + for ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Skip)) != U32(0) { pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft } op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop) - if op == 136 { + if op == TK_SELECT { - return Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList+8 /* &.a */)+uintptr(0)*32)).FpExpr) + return Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList + 8 /* &.a */))).FpExpr) } - if op == 173 { + if op == TK_REGISTER { op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) } - if op == 36 { + if op == TK_CAST { return Xsqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), uintptr(0)) } - if ((op == 166) || (op == 164)) && (*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) != 0) { + if ((op == TK_AGG_COLUMN) || (op == TK_COLUMN)) && (*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) != 0) { return Xsqlite3TableColumnAffinity(tls, *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)), int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)) } - if op == 175 { + if op == TK_SELECT_COLUMN { return Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft + 32 /* &.x */)))).FpEList+8 /* &.a */)+uintptr((*Expr)(unsafe.Pointer(pExpr)).FiColumn)*32)).FpExpr) } - if op == 174 { - return Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))+8 /* &.a */)+uintptr(0)*32)).FpExpr) + if op == TK_VECTOR { + return Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */))).FpExpr) } return (*Expr)(unsafe.Pointer(pExpr)).FaffExpr } @@ -78986,10 +78332,10 @@ func Xsqlite3ExprAffinity(tls *libc.TLS, pExpr uintptr) int8 { /* sqlite3.c:9975 // and the pExpr parameter is returned unchanged. func Xsqlite3ExprAddCollateToken(tls *libc.TLS, pParse uintptr, pExpr uintptr, pCollName uintptr, dequote int32) uintptr { /* sqlite3.c:99804:21: */ if (*Token)(unsafe.Pointer(pCollName)).Fn > uint32(0) { - var pNew uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 111, pCollName, dequote) + var pNew uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_COLLATE, pCollName, dequote) if pNew != 0 { (*Expr)(unsafe.Pointer(pNew)).FpLeft = pExpr - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x000100 | 0x001000)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(EP_Collate | EP_Skip)) pExpr = pNew } } @@ -79008,7 +78354,7 @@ func Xsqlite3ExprAddCollateString(tls *libc.TLS, pParse uintptr, pExpr uintptr, // Skip over any TK_COLLATE operators. func Xsqlite3ExprSkipCollate(tls *libc.TLS, pExpr uintptr) uintptr { /* sqlite3.c:99830:21: */ - for (pExpr != 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x001000))) != U32(0)) { + for (pExpr != 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Skip)) != U32(0)) { pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft } @@ -79019,10 +78365,10 @@ func Xsqlite3ExprSkipCollate(tls *libc.TLS, pExpr uintptr) uintptr { /* sqlite3. // or likelihood() or likely() functions at the root of an // expression. func Xsqlite3ExprSkipCollateAndLikely(tls *libc.TLS, pExpr uintptr) uintptr { /* sqlite3.c:99843:21: */ - for (pExpr != 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x001000 | 0x040000))) != U32(0)) { - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x040000))) != U32(0) { + for (pExpr != 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_Skip | EP_Unlikely))) != U32(0)) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Unlikely)) != U32(0) { - pExpr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + uintptr(0)*32)).FpExpr + pExpr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */))).FpExpr } else { pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft @@ -79049,10 +78395,10 @@ func Xsqlite3ExprCollSeq(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr { var p uintptr = pExpr for p != 0 { var op int32 = int32((*Expr)(unsafe.Pointer(p)).Fop) - if op == 173 { + if op == TK_REGISTER { op = int32((*Expr)(unsafe.Pointer(p)).Fop2) } - if (((op == 166) || (op == 164)) || (op == 77)) && + if (((op == TK_AGG_COLUMN) || (op == TK_COLUMN)) || (op == TK_TRIGGER)) && (*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) != uintptr(0)) { // op==TK_REGISTER && p->y.pTab!=0 happens when pExpr was originally // a TK_COLUMN but was previously evaluated and cached in a register @@ -79063,20 +78409,20 @@ func Xsqlite3ExprCollSeq(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr { } break } - if (op == 36) || (op == 171) { + if (op == TK_CAST) || (op == TK_UPLUS) { p = (*Expr)(unsafe.Pointer(p)).FpLeft continue } - if op == 174 { - p = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) + 8 /* &.a */) + uintptr(0)*32)).FpExpr + if op == TK_VECTOR { + p = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) + 8 /* &.a */))).FpExpr continue } - if op == 111 { + if op == TK_COLLATE { pColl = Xsqlite3GetCollSeq(tls, pParse, (*Sqlite3)(unsafe.Pointer(db)).Fenc, uintptr(0), *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))) break } - if ((*Expr)(unsafe.Pointer(p)).Fflags & U32(0x000100)) != 0 { - if ((*Expr)(unsafe.Pointer(p)).FpLeft != 0) && (((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fflags & U32(0x000100)) != U32(0)) { + if ((*Expr)(unsafe.Pointer(p)).Fflags & EP_Collate) != 0 { + if ((*Expr)(unsafe.Pointer(p)).FpLeft != 0) && (((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fflags & EP_Collate) != U32(0)) { p = (*Expr)(unsafe.Pointer(p)).FpLeft } else { var pNext uintptr = (*Expr)(unsafe.Pointer(p)).FpRight @@ -79084,10 +78430,10 @@ func Xsqlite3ExprCollSeq(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr { if ((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != uintptr(0)) && !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0)) && - (!(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000800))) != U32(0))) { + (!(((*Expr)(unsafe.Pointer((p))).Fflags & (EP_xIsSelect)) != U32(0))) { var i int32 for i = 0; i < (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))).FnExpr; i++ { - if ((*Expr)(unsafe.Pointer(((*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) + 8 /* &.a */) + uintptr(i)*32)).FpExpr))).Fflags & (U32(0x000100))) != U32(0) { + if ((*Expr)(unsafe.Pointer(((*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) + 8 /* &.a */) + uintptr(i)*32)).FpExpr))).Fflags & (EP_Collate)) != U32(0) { pNext = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) + 8 /* &.a */) + uintptr(i)*32)).FpExpr break } @@ -79134,23 +78480,23 @@ func Xsqlite3ExprCollSeqMatch(tls *libc.TLS, pParse uintptr, pE1 uintptr, pE2 ui // type affinity that should be used for the comparison operator. func Xsqlite3CompareAffinity(tls *libc.TLS, pExpr uintptr, aff2 int8) int8 { /* sqlite3.c:99965:21: */ var aff1 int8 = Xsqlite3ExprAffinity(tls, pExpr) - if (int32(aff1) > 0x40) && (int32(aff2) > 0x40) { + if (int32(aff1) > SQLITE_AFF_NONE) && (int32(aff2) > SQLITE_AFF_NONE) { // Both sides of the comparison are columns. If one has numeric // affinity, use that. Otherwise use no affinity. - if ((int32(aff1)) >= 0x43) || ((int32(aff2)) >= 0x43) { - return int8(0x43) + if ((int32(aff1)) >= SQLITE_AFF_NUMERIC) || ((int32(aff2)) >= SQLITE_AFF_NUMERIC) { + return SQLITE_AFF_NUMERIC } else { - return int8(0x41) + return SQLITE_AFF_BLOB } } else { // One side is a column, the other is not. Use the columns affinity. return (int8((func() int32 { - if int32(aff1) <= 0x40 { + if int32(aff1) <= SQLITE_AFF_NONE { return int32(aff2) } return int32(aff1) - }()) | 0x40)) + }()) | SQLITE_AFF_NONE)) } return int8(0) } @@ -79163,10 +78509,10 @@ func comparisonAffinity(tls *libc.TLS, pExpr uintptr) int8 { /* sqlite3.c:99987: aff = Xsqlite3ExprAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) if (*Expr)(unsafe.Pointer(pExpr)).FpRight != 0 { aff = Xsqlite3CompareAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight, aff) - } else if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { - aff = Xsqlite3CompareAffinity(tls, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList+8 /* &.a */)+uintptr(0)*32)).FpExpr, aff) + } else if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { + aff = Xsqlite3CompareAffinity(tls, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList + 8 /* &.a */))).FpExpr, aff) } else if int32(aff) == 0 { - aff = int8(0x41) + aff = SQLITE_AFF_BLOB } return aff } @@ -79177,13 +78523,13 @@ func comparisonAffinity(tls *libc.TLS, pExpr uintptr) int8 { /* sqlite3.c:99987: // the comparison in pExpr. func Xsqlite3IndexAffinityOk(tls *libc.TLS, pExpr uintptr, idx_affinity int8) int32 { /* sqlite3.c:100010:20: */ var aff int8 = comparisonAffinity(tls, pExpr) - if int32(aff) < 0x42 { + if int32(aff) < SQLITE_AFF_TEXT { return 1 } - if int32(aff) == 0x42 { - return (libc.Bool32(int32(idx_affinity) == 0x42)) + if int32(aff) == SQLITE_AFF_TEXT { + return (libc.Bool32(int32(idx_affinity) == SQLITE_AFF_TEXT)) } - return (libc.Bool32((int32(idx_affinity)) >= 0x43)) + return (libc.Bool32((int32(idx_affinity)) >= SQLITE_AFF_NUMERIC)) } // Return the P5 value that should be used for a binary comparison @@ -79207,9 +78553,9 @@ func binaryCompareP5(tls *libc.TLS, pExpr1 uintptr, pExpr2 uintptr, jumpIfNull i func Xsqlite3BinaryCompareCollSeq(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintptr) uintptr { /* sqlite3.c:100047:24: */ var pColl uintptr - if ((*Expr)(unsafe.Pointer(pLeft)).Fflags & U32(0x000100)) != 0 { + if ((*Expr)(unsafe.Pointer(pLeft)).Fflags & EP_Collate) != 0 { pColl = Xsqlite3ExprCollSeq(tls, pParse, pLeft) - } else if (pRight != 0) && (((*Expr)(unsafe.Pointer(pRight)).Fflags & U32(0x000100)) != U32(0)) { + } else if (pRight != 0) && (((*Expr)(unsafe.Pointer(pRight)).Fflags & EP_Collate) != U32(0)) { pColl = Xsqlite3ExprCollSeq(tls, pParse, pRight) } else { pColl = Xsqlite3ExprCollSeq(tls, pParse, pLeft) @@ -79228,7 +78574,7 @@ func Xsqlite3BinaryCompareCollSeq(tls *libc.TLS, pParse uintptr, pLeft uintptr, // is reversed in the sqlite3BinaryCompareCollSeq() call so that the // correct collating sequence is found. func Xsqlite3ExprCompareCollSeq(tls *libc.TLS, pParse uintptr, p uintptr) uintptr { /* sqlite3.c:100075:24: */ - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000200))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_Commuted)) != U32(0) { return Xsqlite3BinaryCompareCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpRight, (*Expr)(unsafe.Pointer(p)).FpLeft) } else { return Xsqlite3BinaryCompareCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, (*Expr)(unsafe.Pointer(p)).FpRight) @@ -79274,12 +78620,12 @@ func Xsqlite3ExprIsVector(tls *libc.TLS, pExpr uintptr) int32 { /* sqlite3.c:100 // any other type of expression, return 1. func Xsqlite3ExprVectorSize(tls *libc.TLS, pExpr uintptr) int32 { /* sqlite3.c:100132:20: */ var op U8 = (*Expr)(unsafe.Pointer(pExpr)).Fop - if int32(op) == 173 { + if int32(op) == TK_REGISTER { op = (*Expr)(unsafe.Pointer(pExpr)).Fop2 } - if int32(op) == 174 { + if int32(op) == TK_VECTOR { return (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FnExpr - } else if int32(op) == 136 { + } else if int32(op) == TK_SELECT { return (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList)).FnExpr } else { return 1 @@ -79304,7 +78650,7 @@ func Xsqlite3VectorFieldSubexpr(tls *libc.TLS, pVector uintptr, i int32) uintptr if Xsqlite3ExprIsVector(tls, pVector) != 0 { - if (int32((*Expr)(unsafe.Pointer(pVector)).Fop) == 136) || (int32((*Expr)(unsafe.Pointer(pVector)).Fop2) == 136) { + if (int32((*Expr)(unsafe.Pointer(pVector)).Fop) == TK_SELECT) || (int32((*Expr)(unsafe.Pointer(pVector)).Fop2) == TK_SELECT) { return (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pVector + 32 /* &.x */)))).FpEList + 8 /* &.a */) + uintptr(i)*32)).FpExpr } else { return (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pVector + 32 /* &.x */)) + 8 /* &.a */) + uintptr(i)*32)).FpExpr @@ -79334,7 +78680,7 @@ func Xsqlite3VectorFieldSubexpr(tls *libc.TLS, pVector uintptr, i int32) uintptr // of the returned TK_SELECT_COLUMN Expr object. func Xsqlite3ExprForVectorField(tls *libc.TLS, pParse uintptr, pVector uintptr, iField int32) uintptr { /* sqlite3.c:100193:21: */ var pRet uintptr - if int32((*Expr)(unsafe.Pointer(pVector)).Fop) == 136 { + if int32((*Expr)(unsafe.Pointer(pVector)).Fop) == TK_SELECT { // The TK_SELECT_COLUMN Expr node: // @@ -79351,14 +78697,14 @@ func Xsqlite3ExprForVectorField(tls *libc.TLS, pParse uintptr, pVector uintptr, // pVector. Typically there will be multiple TK_SELECT_COLUMN nodes // with the same pLeft pointer to the pVector, but only one of them // will own the pVector. - pRet = Xsqlite3PExpr(tls, pParse, 175, uintptr(0), uintptr(0)) + pRet = Xsqlite3PExpr(tls, pParse, TK_SELECT_COLUMN, uintptr(0), uintptr(0)) if pRet != 0 { (*Expr)(unsafe.Pointer(pRet)).FiColumn = YnVar(iField) (*Expr)(unsafe.Pointer(pRet)).FpLeft = pVector } } else { - if int32((*Expr)(unsafe.Pointer(pVector)).Fop) == 174 { + if int32((*Expr)(unsafe.Pointer(pVector)).Fop) == TK_VECTOR { pVector = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pVector + 32 /* &.x */)) + 8 /* &.a */) + uintptr(iField)*32)).FpExpr } pRet = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pVector, 0) @@ -79375,7 +78721,7 @@ func Xsqlite3ExprForVectorField(tls *libc.TLS, pParse uintptr, pVector uintptr, // If pExpr is not a TK_SELECT expression, return 0. func exprCodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { /* sqlite3.c:100239:12: */ var reg int32 = 0 - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 136 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_SELECT { reg = Xsqlite3CodeSubselect(tls, pParse, pExpr) } return reg @@ -79400,11 +78746,11 @@ func exprCodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { /* func exprVectorRegister(tls *libc.TLS, pParse uintptr, pVector uintptr, iField int32, regSelect int32, ppExpr uintptr, pRegFree uintptr) int32 { /* sqlite3.c:100267:12: */ var op U8 = (*Expr)(unsafe.Pointer(pVector)).Fop - if int32(op) == 173 { + if int32(op) == TK_REGISTER { *(*uintptr)(unsafe.Pointer(ppExpr)) = Xsqlite3VectorFieldSubexpr(tls, pVector, iField) return ((*Expr)(unsafe.Pointer(pVector)).FiTable + iField) } - if int32(op) == 136 { + if int32(op) == TK_SELECT { *(*uintptr)(unsafe.Pointer(ppExpr)) = (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pVector + 32 /* &.x */)))).FpEList + 8 /* &.a */) + uintptr(iField)*32)).FpExpr return (regSelect + iField) } @@ -79434,7 +78780,7 @@ func codeVectorCompare(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, var regRight int32 = 0 var opx U8 = op var addrDone int32 = Xsqlite3VdbeMakeLabel(tls, pParse) - var isCommuted int32 = (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000200))) != U32(0))) + var isCommuted int32 = (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Commuted)) != U32(0))) if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { return @@ -79444,12 +78790,12 @@ func codeVectorCompare(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, return } - p5 = U8(int32(p5) | (0x20)) - if int32(opx) == 55 { - opx = U8(56) + p5 = U8(int32(p5) | (SQLITE_STOREP2)) + if int32(opx) == TK_LE { + opx = TK_LT } - if int32(opx) == 57 { - opx = U8(54) + if int32(opx) == TK_GE { + opx = TK_GT } regLeft = exprCodeSubselect(tls, pParse, pLeft) @@ -79474,15 +78820,15 @@ func codeVectorCompare(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, if i == (nLeft - 1) { break } - if int32(opx) == 53 { - Xsqlite3VdbeAddOp2(tls, v, 20, dest, addrDone) - p5 = U8(int32(p5) | (0x08)) - } else if int32(opx) == 52 { - Xsqlite3VdbeAddOp2(tls, v, 18, dest, addrDone) - p5 = U8(int32(p5) | (0x08)) + if int32(opx) == TK_EQ { + Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, dest, addrDone) + p5 = U8(int32(p5) | (SQLITE_KEEPNULL)) + } else if int32(opx) == TK_NE { + Xsqlite3VdbeAddOp2(tls, v, OP_If, dest, addrDone) + p5 = U8(int32(p5) | (SQLITE_KEEPNULL)) } else { - Xsqlite3VdbeAddOp2(tls, v, 58, 0, addrDone) + Xsqlite3VdbeAddOp2(tls, v, OP_ElseNotEq, 0, addrDone) if i == (nLeft - 2) { opx = op @@ -79499,12 +78845,12 @@ func Xsqlite3ExprCheckHeight(tls *libc.TLS, pParse uintptr, nHeight int32) int32 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 - var mxHeight int32 = *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + uintptr(3)*4)) + var rc int32 = SQLITE_OK + var mxHeight int32 = *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + 3*4)) if nHeight > mxHeight { Xsqlite3ErrorMsg(tls, pParse, ts+6271 /* "Expression tree ..." */, libc.VaList(bp, mxHeight)) - rc = 1 + rc = SQLITE_ERROR } return rc } @@ -79561,11 +78907,11 @@ func exprSetHeight(tls *libc.TLS, p uintptr) { /* sqlite3.c:100443:13: */ *(*int32)(unsafe.Pointer(bp /* nHeight */)) = 0 heightOfExpr(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, bp /* &nHeight */) heightOfExpr(tls, (*Expr)(unsafe.Pointer(p)).FpRight, bp /* &nHeight */) - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_xIsSelect)) != U32(0) { heightOfSelect(tls, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)), bp /* &nHeight */) } else if *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0 { heightOfExprList(tls, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)), bp /* &nHeight */) - *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= ((U32((0x000100 | 0x200000) | 0x000004)) & Xsqlite3ExprListFlags(tls, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))) + *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= ((U32((EP_Collate | EP_Subquery) | EP_HasFunc)) & Xsqlite3ExprListFlags(tls, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))) } (*Expr)(unsafe.Pointer(p)).FnHeight = (*(*int32)(unsafe.Pointer(bp /* nHeight */)) + 1) } @@ -79622,7 +78968,7 @@ func Xsqlite3ExprAlloc(tls *libc.TLS, db uintptr, op int32, pToken uintptr, dequ *(*int32)(unsafe.Pointer(bp /* iValue */)) = 0 if pToken != 0 { - if ((op != 152) || ((*Token)(unsafe.Pointer(pToken)).Fz == uintptr(0))) || + if ((op != TK_INTEGER) || ((*Token)(unsafe.Pointer(pToken)).Fz == uintptr(0))) || (Xsqlite3GetInt32(tls, (*Token)(unsafe.Pointer(pToken)).Fz, bp /* &iValue */) == 0) { nExtra = (int32((*Token)(unsafe.Pointer(pToken)).Fn + uint32(1))) @@ -79635,21 +78981,21 @@ func Xsqlite3ExprAlloc(tls *libc.TLS, db uintptr, op int32, pToken uintptr, dequ (*Expr)(unsafe.Pointer(pNew)).FiAgg = int16(-1) if pToken != 0 { if nExtra == 0 { - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32((0x000400 | 0x800000) | (func() int32 { + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32((EP_IntValue | EP_Leaf) | (func() int32 { if *(*int32)(unsafe.Pointer(bp /* iValue */)) != 0 { - return 0x10000000 + return EP_IsTrue } - return 0x20000000 + return EP_IsFalse }()))) *(*int32)(unsafe.Pointer(pNew + 8 /* &.u */)) = *(*int32)(unsafe.Pointer(bp /* iValue */)) } else { - *(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)) = (pNew + uintptr(1)*72) + *(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)) = (pNew + 1*72) if (*Token)(unsafe.Pointer(pToken)).Fn != 0 { libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)), (*Token)(unsafe.Pointer(pToken)).Fz, uint64((*Token)(unsafe.Pointer(pToken)).Fn)) } *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)) + uintptr((*Token)(unsafe.Pointer(pToken)).Fn))) = int8(0) - if (dequote != 0) && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)) + uintptr(0))))]) & 0x80) != 0) { + if (dequote != 0) && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)))))]) & 0x80) != 0) { Xsqlite3DequoteExpr(tls, pNew) } } @@ -79684,11 +79030,11 @@ func Xsqlite3ExprAttachSubtrees(tls *libc.TLS, db uintptr, pRoot uintptr, pLeft } else { if pRight != 0 { (*Expr)(unsafe.Pointer(pRoot)).FpRight = pRight - *(*U32)(unsafe.Pointer(pRoot + 4 /* &.flags */)) |= ((U32((0x000100 | 0x200000) | 0x000004)) & (*Expr)(unsafe.Pointer(pRight)).Fflags) + *(*U32)(unsafe.Pointer(pRoot + 4 /* &.flags */)) |= ((U32((EP_Collate | EP_Subquery) | EP_HasFunc)) & (*Expr)(unsafe.Pointer(pRight)).Fflags) } if pLeft != 0 { (*Expr)(unsafe.Pointer(pRoot)).FpLeft = pLeft - *(*U32)(unsafe.Pointer(pRoot + 4 /* &.flags */)) |= ((U32((0x000100 | 0x200000) | 0x000004)) & (*Expr)(unsafe.Pointer(pLeft)).Fflags) + *(*U32)(unsafe.Pointer(pRoot + 4 /* &.flags */)) |= ((U32((EP_Collate | EP_Subquery) | EP_HasFunc)) & (*Expr)(unsafe.Pointer(pLeft)).Fflags) } exprSetHeight(tls, pRoot) } @@ -79720,7 +79066,7 @@ func Xsqlite3PExpr(tls *libc.TLS, pParse uintptr, op int32, pLeft uintptr, pRigh func Xsqlite3PExprAddSelect(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSelect uintptr) { /* sqlite3.c:100632:21: */ if pExpr != 0 { *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) = pSelect - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x000800 | 0x200000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(EP_xIsSelect | EP_Subquery)) Xsqlite3ExprSetHeightAndFlags(tls, pParse, pExpr) } else { @@ -79740,13 +79086,13 @@ func Xsqlite3ExprAnd(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintpt return pRight } else if pRight == uintptr(0) { return pLeft - } else if ((((*Expr)(unsafe.Pointer((pLeft))).Fflags & (U32(0x000001 | 0x20000000))) == U32(0x20000000)) || (((*Expr)(unsafe.Pointer((pRight))).Fflags & (U32(0x000001 | 0x20000000))) == U32(0x20000000))) && - !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + } else if ((((*Expr)(unsafe.Pointer((pLeft))).Fflags & (U32(EP_FromJoin | EP_IsFalse))) == EP_IsFalse) || (((*Expr)(unsafe.Pointer((pRight))).Fflags & (U32(EP_FromJoin | EP_IsFalse))) == EP_IsFalse)) && + !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { Xsqlite3ExprDelete(tls, db, pLeft) Xsqlite3ExprDelete(tls, db, pRight) - return Xsqlite3Expr(tls, db, 152, ts+6319 /* "0" */) + return Xsqlite3Expr(tls, db, TK_INTEGER, ts+6319 /* "0" */) } else { - return Xsqlite3PExpr(tls, pParse, 44, pLeft, pRight) + return Xsqlite3PExpr(tls, pParse, TK_AND, pLeft, pRight) } return uintptr(0) } @@ -79760,20 +79106,20 @@ func Xsqlite3ExprFunction(tls *libc.TLS, pParse uintptr, pList uintptr, pToken u var pNew uintptr var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - pNew = Xsqlite3ExprAlloc(tls, db, 169, pToken, 1) + pNew = Xsqlite3ExprAlloc(tls, db, TK_FUNCTION, pToken, 1) if pNew == uintptr(0) { Xsqlite3ExprListDelete(tls, db, pList) // Avoid memory leak when malloc fails return uintptr(0) } - if (pList != 0) && ((*ExprList)(unsafe.Pointer(pList)).FnExpr > *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + uintptr(6)*4))) { + if (pList != 0) && ((*ExprList)(unsafe.Pointer(pList)).FnExpr > *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + 6*4))) { Xsqlite3ErrorMsg(tls, pParse, ts+6321 /* "too many argumen..." */, libc.VaList(bp, pToken)) } *(*uintptr)(unsafe.Pointer(pNew + 32 /* &.x */)) = pList - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x000004)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (EP_HasFunc) Xsqlite3ExprSetHeightAndFlags(tls, pParse, pNew) - if eDistinct == 0x0000001 { - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x000002)) + if eDistinct == SF_Distinct { + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (EP_Distinct) } return pNew } @@ -79791,9 +79137,9 @@ func Xsqlite3ExprFunctionUsable(tls *libc.TLS, pParse uintptr, pExpr uintptr, pD bp := tls.Alloc(8) defer tls.Free(8) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x40000000))) != U32(0) { - if (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x00080000)) != U32(0)) || - (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00000080)) == uint64(0)) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromDDL)) != U32(0) { + if (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_DIRECT) != U32(0)) || + (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_TrustedSchema) == uint64(0)) { // Functions prohibited in triggers and views if: // (1) tagged with SQLITE_DIRECTONLY // (2) not tagged with SQLITE_INNOCUOUS (which means it @@ -79833,28 +79179,28 @@ func Xsqlite3ExprAssignVarNumber(tls *libc.TLS, pParse uintptr, pExpr uintptr, n z = *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) - if int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(z + 1))) == 0 { // Wildcard of the form "?". Assign the next variable number x = libc.PreIncInt16(&(*Parse)(unsafe.Pointer(pParse)).FnVar, 1) } else { var doAdd int32 = 0 - if int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '?' { + if int32(*(*int8)(unsafe.Pointer(z))) == '?' { // Wildcard of the form "?nnn". Convert "nnn" to an integer and // use it as the variable number // var i I64 at bp+8, 8 var bOk int32 if n == U32(2) { //OPTIMIZATION-IF-TRUE - *(*I64)(unsafe.Pointer(bp + 8 /* i */)) = (I64(int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) - '0')) // The common case of ?N for a single digit N + *(*I64)(unsafe.Pointer(bp + 8 /* i */)) = (I64(int32(*(*int8)(unsafe.Pointer(z + 1))) - '0')) // The common case of ?N for a single digit N bOk = 1 } else { - bOk = (libc.Bool32(0 == Xsqlite3Atoi64(tls, (z+uintptr(1)), bp+8 /* &i */, (int32(n-U32(1))), uint8(1)))) + bOk = (libc.Bool32(0 == Xsqlite3Atoi64(tls, (z+1), bp+8 /* &i */, (int32(n-U32(1))), SQLITE_UTF8))) } - if ((bOk == 0) || (*(*I64)(unsafe.Pointer(bp + 8 /* i */)) < int64(1))) || (*(*I64)(unsafe.Pointer(bp + 8 /* i */)) > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(9)*4)))) { + if ((bOk == 0) || (*(*I64)(unsafe.Pointer(bp + 8 /* i */)) < int64(1))) || (*(*I64)(unsafe.Pointer(bp + 8 /* i */)) > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 9*4)))) { Xsqlite3ErrorMsg(tls, pParse, ts+6374, /* "variable number ..." */ - libc.VaList(bp, *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(9)*4)))) + libc.VaList(bp, *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 9*4)))) return } x = YnVar(*(*I64)(unsafe.Pointer(bp + 8 /* i */))) @@ -79879,7 +79225,7 @@ func Xsqlite3ExprAssignVarNumber(tls *libc.TLS, pParse uintptr, pExpr uintptr, n } } (*Expr)(unsafe.Pointer(pExpr)).FiColumn = x - if int32(x) > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(9)*4)) { + if int32(x) > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 9*4)) { Xsqlite3ErrorMsg(tls, pParse, ts+6417 /* "too many SQL var..." */, 0) } } @@ -79889,29 +79235,29 @@ func sqlite3ExprDeleteNN(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3.c:10 // Sanity check: Assert that the IntValue is non-negative if it exists - if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x004000 | 0x800000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(EP_TokenOnly | EP_Leaf))) != U32(0)) { // The Expr.x union is never used at the same time as Expr.pRight - if ((*Expr)(unsafe.Pointer(p)).FpLeft != 0) && (int32((*Expr)(unsafe.Pointer(p)).Fop) != 175) { + if ((*Expr)(unsafe.Pointer(p)).FpLeft != 0) && (int32((*Expr)(unsafe.Pointer(p)).Fop) != TK_SELECT_COLUMN) { sqlite3ExprDeleteNN(tls, db, (*Expr)(unsafe.Pointer(p)).FpLeft) } if (*Expr)(unsafe.Pointer(p)).FpRight != 0 { sqlite3ExprDeleteNN(tls, db, (*Expr)(unsafe.Pointer(p)).FpRight) - } else if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000800))) != U32(0) { + } else if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_xIsSelect)) != U32(0) { Xsqlite3SelectDelete(tls, db, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */))) } else { Xsqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */))) - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_WinFunc)) != U32(0) { Xsqlite3WindowDelete(tls, db, *(*uintptr)(unsafe.Pointer(p + 64 /* &.y */))) } } } - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x010000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_MemToken)) != U32(0) { Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))) } - if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x8000000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((p))).Fflags & (EP_Static)) != U32(0)) { Xsqlite3DbFreeNN(tls, db, p) } } @@ -79926,7 +79272,7 @@ func Xsqlite3ExprDelete(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3.c:100 // expression. func Xsqlite3ExprUnmapAndDelete(tls *libc.TLS, pParse uintptr, p uintptr) { /* sqlite3.c:100862:21: */ if p != 0 { - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameExprUnmap(tls, pParse, p) } sqlite3ExprDeleteNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p) @@ -79937,10 +79283,10 @@ func Xsqlite3ExprUnmapAndDelete(tls *libc.TLS, pParse uintptr, p uintptr) { /* s // passed as the first argument. This is always one of EXPR_FULLSIZE, // EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. func exprStructSize(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:100876:12: */ - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x004000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_TokenOnly)) != U32(0) { return int32((uintptr(0) + 16 /* &.pLeft */)) } - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x002000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_Reduced)) != U32(0) { return int32((uintptr(0) + 44 /* &.iTable */)) } return int32(unsafe.Sizeof(Expr{})) @@ -79982,16 +79328,16 @@ func dupedExprStructSize(tls *libc.TLS, p uintptr, flags int32) int32 { /* sqlit var nSize int32 // Only one flag value allowed - if ((0 == flags) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == 175)) || - (((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x1000000))) != U32(0)) { + if ((0 == flags) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_SELECT_COLUMN)) || + (((*Expr)(unsafe.Pointer((p))).Fflags & (EP_WinFunc)) != U32(0)) { nSize = int32(unsafe.Sizeof(Expr{})) } else { if ((*Expr)(unsafe.Pointer(p)).FpLeft != 0) || (*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0) { - nSize = (int32((uint64((uintptr(0) + 44 /* &.iTable */))) | uint64(0x002000))) + nSize = (int32((uint64((uintptr(0) + 44 /* &.iTable */))) | EP_Reduced)) } else { - nSize = (int32((uint64((uintptr(0) + 16 /* &.pLeft */))) | uint64(0x004000))) + nSize = (int32((uint64((uintptr(0) + 16 /* &.pLeft */))) | EP_TokenOnly)) } } return nSize @@ -80002,10 +79348,10 @@ func dupedExprStructSize(tls *libc.TLS, p uintptr, flags int32) int32 { /* sqlit // string is defined.) func dupedExprNodeSize(tls *libc.TLS, p uintptr, flags int32) int32 { /* sqlite3.c:100947:12: */ var nByte int32 = (dupedExprStructSize(tls, p, flags) & 0xfff) - if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000400))) != U32(0)) && (*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) != 0) { + if !(((*Expr)(unsafe.Pointer((p))).Fflags & (EP_IntValue)) != U32(0)) && (*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) != 0) { nByte = int32(Size_t(nByte) + ((libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))) & uint64(0x3fffffff)) + uint64(1))) } - return (((nByte) + 7) & ^libc.Int32(7)) + return (((nByte) + 7) & libc.CplInt32(7)) } // Return the number of bytes required to create a duplicate of the @@ -80023,7 +79369,7 @@ func dupedExprSize(tls *libc.TLS, p uintptr, flags int32) int32 { /* sqlite3.c:1 var nByte int32 = 0 if p != 0 { nByte = dupedExprNodeSize(tls, p, flags) - if (flags & 0x0001) != 0 { + if (flags & EXPRDUP_REDUCE) != 0 { nByte = nByte + (dupedExprSize(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, flags) + dupedExprSize(tls, (*Expr)(unsafe.Pointer(p)).FpRight, flags)) } } @@ -80048,7 +79394,7 @@ func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uint // Figure out where to write the new Expr structure. if pzBuffer != 0 { *(*uintptr)(unsafe.Pointer(bp /* zAlloc */)) = *(*uintptr)(unsafe.Pointer(pzBuffer)) - staticFlag = U32(0x8000000) + staticFlag = EP_Static } else { *(*uintptr)(unsafe.Pointer(bp /* zAlloc */)) = Xsqlite3DbMallocRawNN(tls, db, uint64(dupedExprSize(tls, p, dupFlags))) staticFlag = U32(0) @@ -80063,7 +79409,7 @@ func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uint var nStructSize uint32 = uint32(dupedExprStructSize(tls, p, dupFlags)) var nNewSize int32 = (int32(nStructSize & uint32(0xfff))) var nToken int32 - if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000400))) != U32(0)) && (*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) != 0) { + if !(((*Expr)(unsafe.Pointer((p))).Fflags & (EP_IntValue)) != U32(0)) && (*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) != 0) { nToken = (Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))) + 1) } else { nToken = 0 @@ -80080,8 +79426,8 @@ func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uint } // Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) &= (^libc.Uint32FromInt32((((0x002000 | 0x004000) | 0x8000000) | 0x010000))) - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (nStructSize & (uint32(0x002000 | 0x004000))) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32((((EP_Reduced | EP_TokenOnly) | EP_Static) | EP_MemToken)))) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (nStructSize & (uint32(EP_Reduced | EP_TokenOnly))) *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (staticFlag) if dupFlags != 0 { @@ -80094,9 +79440,9 @@ func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uint libc.Xmemcpy(tls, zToken, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)), uint64(nToken)) } - if U32(0) == (((*Expr)(unsafe.Pointer(p)).Fflags | (*Expr)(unsafe.Pointer(pNew)).Fflags) & (U32(0x004000 | 0x800000))) { + if U32(0) == (((*Expr)(unsafe.Pointer(p)).Fflags | (*Expr)(unsafe.Pointer(pNew)).Fflags) & (U32(EP_TokenOnly | EP_Leaf))) { // Fill in the pNew->x.pSelect or pNew->x.pList member. - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_xIsSelect)) != U32(0) { *(*uintptr)(unsafe.Pointer(pNew + 32 /* &.x */)) = Xsqlite3SelectDup(tls, db, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)), dupFlags) } else { *(*uintptr)(unsafe.Pointer(pNew + 32 /* &.x */)) = Xsqlite3ExprListDup(tls, db, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)), dupFlags) @@ -80104,23 +79450,23 @@ func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uint } // Fill in pNew->pLeft and pNew->pRight. - if ((*Expr)(unsafe.Pointer((pNew))).Fflags & (U32((0x002000 | 0x004000) | 0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pNew))).Fflags & (U32((EP_Reduced | EP_TokenOnly) | EP_WinFunc))) != U32(0) { *(*uintptr)(unsafe.Pointer(bp /* zAlloc */)) += uintptr(dupedExprNodeSize(tls, p, dupFlags)) - if !(((*Expr)(unsafe.Pointer((pNew))).Fflags & (U32(0x004000 | 0x800000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pNew))).Fflags & (U32(EP_TokenOnly | EP_Leaf))) != U32(0)) { (*Expr)(unsafe.Pointer(pNew)).FpLeft = func() uintptr { if (*Expr)(unsafe.Pointer(p)).FpLeft != 0 { - return exprDup(tls, db, (*Expr)(unsafe.Pointer(p)).FpLeft, 0x0001, bp /* &zAlloc */) + return exprDup(tls, db, (*Expr)(unsafe.Pointer(p)).FpLeft, EXPRDUP_REDUCE, bp /* &zAlloc */) } return uintptr(0) }() (*Expr)(unsafe.Pointer(pNew)).FpRight = func() uintptr { if (*Expr)(unsafe.Pointer(p)).FpRight != 0 { - return exprDup(tls, db, (*Expr)(unsafe.Pointer(p)).FpRight, 0x0001, bp /* &zAlloc */) + return exprDup(tls, db, (*Expr)(unsafe.Pointer(p)).FpRight, EXPRDUP_REDUCE, bp /* &zAlloc */) } return uintptr(0) }() } - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_WinFunc)) != U32(0) { *(*uintptr)(unsafe.Pointer(pNew + 64 /* &.y */)) = Xsqlite3WindowDup(tls, db, pNew, *(*uintptr)(unsafe.Pointer(p + 64 /* &.y */))) } @@ -80128,8 +79474,8 @@ func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uint *(*uintptr)(unsafe.Pointer(pzBuffer)) = *(*uintptr)(unsafe.Pointer(bp /* zAlloc */)) } } else { - if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x004000 | 0x800000))) != U32(0)) { - if int32((*Expr)(unsafe.Pointer(pNew)).Fop) == 175 { + if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(EP_TokenOnly | EP_Leaf))) != U32(0)) { + if int32((*Expr)(unsafe.Pointer(pNew)).Fop) == TK_SELECT_COLUMN { (*Expr)(unsafe.Pointer(pNew)).FpLeft = (*Expr)(unsafe.Pointer(p)).FpLeft } else { @@ -80168,20 +79514,20 @@ func withDup(tls *libc.TLS, db uintptr, p uintptr) uintptr { /* sqlite3.c:101096 // an a newly duplicated SELECT statement and gather all of the Window // objects found there, assembling them onto the linked list at Select->pWin. func gatherSelectWindowsCallback(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:101124:12: */ - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 169) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_FUNCTION) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) { var pSelect uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) var pWin uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) Xsqlite3WindowLink(tls, pSelect, pWin) } - return 0 + return WRC_Continue } func gatherSelectWindowsSelectCallback(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sqlite3.c:101135:12: */ if p == *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) { - return 0 + return WRC_Continue } - return 1 + return WRC_Prune } func gatherSelectWindows(tls *libc.TLS, p uintptr) { /* sqlite3.c:101138:13: */ @@ -80252,7 +79598,7 @@ __1: var pNewExpr uintptr (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr = Xsqlite3ExprDup(tls, db, pOldExpr, flags) if ((pOldExpr != 0) && - (int32((*Expr)(unsafe.Pointer(pOldExpr)).Fop) == 175)) && + (int32((*Expr)(unsafe.Pointer(pOldExpr)).Fop) == TK_SELECT_COLUMN)) && ((libc.AssignUintptr(&pNewExpr, (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr)) != uintptr(0)) { if int32((*Expr)(unsafe.Pointer(pNewExpr)).FiColumn) == 0 { @@ -80393,9 +79739,9 @@ func Xsqlite3SelectDup(tls *libc.TLS, db uintptr, pDup uintptr, flags int32) uin (*Select)(unsafe.Pointer(pNew)).FpLimit = Xsqlite3ExprDup(tls, db, (*Select)(unsafe.Pointer(p)).FpLimit, flags) (*Select)(unsafe.Pointer(pNew)).FiLimit = 0 (*Select)(unsafe.Pointer(pNew)).FiOffset = 0 - (*Select)(unsafe.Pointer(pNew)).FselFlags = ((*Select)(unsafe.Pointer(p)).FselFlags & ^libc.Uint32FromInt32(0x0000020)) - *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */) + uintptr(0)*4)) = -1 - *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */) + uintptr(1)*4)) = -1 + (*Select)(unsafe.Pointer(pNew)).FselFlags = ((*Select)(unsafe.Pointer(p)).FselFlags & libc.Uint32FromInt32(libc.CplInt32(SF_UsesEphemeral))) + *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */))) = -1 + *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */) + 1*4)) = -1 (*Select)(unsafe.Pointer(pNew)).FnSelectRow = (*Select)(unsafe.Pointer(p)).FnSelectRow (*Select)(unsafe.Pointer(pNew)).FpWith = withDup(tls, db, (*Select)(unsafe.Pointer(p)).FpWith) (*Select)(unsafe.Pointer(pNew)).FpWin = uintptr(0) @@ -80517,7 +79863,7 @@ __2: // the size of the RHS and LHS match. But if the RHS is a SELECT, // wildcards ("*") in the result set of the SELECT must be expanded before // we can do the size check, so defer the size check until code generation. - if !((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 136) && ((*IdList)(unsafe.Pointer(pColumns)).FnId != (libc.AssignInt32(&n, Xsqlite3ExprVectorSize(tls, pExpr))))) { + if !((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_SELECT) && ((*IdList)(unsafe.Pointer(pColumns)).FnId != (libc.AssignInt32(&n, Xsqlite3ExprVectorSize(tls, pExpr))))) { goto __3 } Xsqlite3ErrorMsg(tls, pParse, ts+6440, /* "%d columns assig..." */ @@ -80557,7 +79903,7 @@ __5: __6: ; - if !((!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 136)) && (pList != uintptr(0))) { + if !((!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_SELECT)) && (pList != uintptr(0))) { goto __9 } pFirst = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(iFirst)*32)).FpExpr @@ -80589,14 +79935,14 @@ func Xsqlite3ExprListSetSortOrder(tls *libc.TLS, p uintptr, iSortOrder int32, eN pItem = ((p + 8 /* &.a */) + uintptr(((*ExprList)(unsafe.Pointer(p)).FnExpr-1))*32) if iSortOrder == -1 { - iSortOrder = 0 + iSortOrder = SQLITE_SO_ASC } (*ExprList_item)(unsafe.Pointer(pItem)).FsortFlags = U8(iSortOrder) if eNulls != -1 { libc.SetBitFieldPtr8Uint32(pItem+20 /* &.bNulls */, uint32(1), 5, 0x20) if iSortOrder != eNulls { - *(*U8)(unsafe.Pointer(pItem + 16 /* &.sortFlags */)) |= U8((0x02)) + *(*U8)(unsafe.Pointer(pItem + 16 /* &.sortFlags */)) |= U8((KEYINFO_ORDER_BIGNULL)) } } } @@ -80620,7 +79966,7 @@ func Xsqlite3ExprListSetName(tls *libc.TLS, pParse uintptr, pList uintptr, pName // statement handled by the parser. And so no token need be added // to the token-map. Xsqlite3Dequote(tls, (*ExprList_item)(unsafe.Pointer(pItem)).FzEName) - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameTokenMap(tls, pParse, (*ExprList_item)(unsafe.Pointer(pItem)).FzEName, pName) } } @@ -80641,7 +79987,7 @@ func Xsqlite3ExprListSetSpan(tls *libc.TLS, pParse uintptr, pList uintptr, zStar if (*ExprList_item)(unsafe.Pointer(pItem)).FzEName == uintptr(0) { (*ExprList_item)(unsafe.Pointer(pItem)).FzEName = Xsqlite3DbSpanDup(tls, db, zStart, zEnd) - libc.SetBitFieldPtr8Uint32(pItem+20 /* &.eEName */, uint32(1), 0, 0x3) + libc.SetBitFieldPtr8Uint32(pItem+20 /* &.eEName */, ENAME_SPAN, 0, 0x3) } } } @@ -80652,7 +79998,7 @@ func Xsqlite3ExprListCheckLength(tls *libc.TLS, pParse uintptr, pEList uintptr, bp := tls.Alloc(8) defer tls.Free(8) - var mx int32 = *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + uintptr(2)*4)) + var mx int32 = *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + 2*4)) if (pEList != 0) && ((*ExprList)(unsafe.Pointer(pEList)).FnExpr > mx) { Xsqlite3ErrorMsg(tls, pParse, ts+6470 /* "too many columns..." */, libc.VaList(bp, zObject)) @@ -80700,7 +80046,7 @@ func Xsqlite3ExprListFlags(tls *libc.TLS, pList uintptr) U32 { /* sqlite3.c:1015 func Xsqlite3SelectWalkFail(tls *libc.TLS, pWalker uintptr, NotUsed uintptr) int32 { /* sqlite3.c:101611:20: */ _ = NotUsed (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 + return WRC_Abort } // Check the input string to see if it is "true" or "false" (in any case). @@ -80711,10 +80057,10 @@ func Xsqlite3SelectWalkFail(tls *libc.TLS, pWalker uintptr, NotUsed uintptr) int // anything else 0 func Xsqlite3IsTrueOrFalse(tls *libc.TLS, zIn uintptr) U32 { /* sqlite3.c:101625:20: */ if Xsqlite3StrICmp(tls, zIn, ts+6493 /* "true" */) == 0 { - return U32(0x10000000) + return EP_IsTrue } if Xsqlite3StrICmp(tls, zIn, ts+6498 /* "false" */) == 0 { - return U32(0x20000000) + return EP_IsFalse } return U32(0) } @@ -80725,9 +80071,9 @@ func Xsqlite3IsTrueOrFalse(tls *libc.TLS, zIn uintptr) U32 { /* sqlite3.c:101625 func Xsqlite3ExprIdToTrueFalse(tls *libc.TLS, pExpr uintptr) int32 { /* sqlite3.c:101637:20: */ var v U32 - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x4000000))) != U32(0)) && + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Quoted)) != U32(0)) && ((libc.AssignUint32(&v, Xsqlite3IsTrueOrFalse(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */))))) != U32(0)) { - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(167) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_TRUEFALSE *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (v) return 1 } @@ -80739,7 +80085,7 @@ func Xsqlite3ExprIdToTrueFalse(tls *libc.TLS, pExpr uintptr) int32 { /* sqlite3. func Xsqlite3ExprTruthValue(tls *libc.TLS, pExpr uintptr) int32 { /* sqlite3.c:101654:20: */ pExpr = Xsqlite3ExprSkipCollate(tls, pExpr) - return (libc.Bool32(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + uintptr(4)))) == 0)) + return (libc.Bool32(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + 4))) == 0)) } // If pExpr is an AND or OR expression, try to simplify it by eliminating @@ -80755,17 +80101,17 @@ func Xsqlite3ExprTruthValue(tls *libc.TLS, pExpr uintptr) int32 { /* sqlite3.c:1 // (y=22) OR true => true func Xsqlite3ExprSimplifiedAndOr(tls *libc.TLS, pExpr uintptr) uintptr { /* sqlite3.c:101675:21: */ - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 44) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 43) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_OR) { var pRight uintptr = Xsqlite3ExprSimplifiedAndOr(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) var pLeft uintptr = Xsqlite3ExprSimplifiedAndOr(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) - if (((*Expr)(unsafe.Pointer((pLeft))).Fflags & (U32(0x000001 | 0x10000000))) == U32(0x10000000)) || (((*Expr)(unsafe.Pointer((pRight))).Fflags & (U32(0x000001 | 0x20000000))) == U32(0x20000000)) { - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 44 { + if (((*Expr)(unsafe.Pointer((pLeft))).Fflags & (U32(EP_FromJoin | EP_IsTrue))) == EP_IsTrue) || (((*Expr)(unsafe.Pointer((pRight))).Fflags & (U32(EP_FromJoin | EP_IsFalse))) == EP_IsFalse) { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND { pExpr = pRight } else { pExpr = pLeft } - } else if (((*Expr)(unsafe.Pointer((pRight))).Fflags & (U32(0x000001 | 0x10000000))) == U32(0x10000000)) || (((*Expr)(unsafe.Pointer((pLeft))).Fflags & (U32(0x000001 | 0x20000000))) == U32(0x20000000)) { - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 44 { + } else if (((*Expr)(unsafe.Pointer((pRight))).Fflags & (U32(EP_FromJoin | EP_IsTrue))) == EP_IsTrue) || (((*Expr)(unsafe.Pointer((pLeft))).Fflags & (U32(EP_FromJoin | EP_IsFalse))) == EP_IsFalse) { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND { pExpr = pLeft } else { pExpr = pRight @@ -80804,75 +80150,72 @@ func exprNodeIsConstant(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { / // If pWalker->eCode is 2 then any term of the expression that comes from // the ON or USING clauses of a left join disqualifies the expression // from being considered constant. - if (int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 2) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0)) { + if (int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 2) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0)) { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 + return WRC_Abort } switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) { // Consider functions to be constant if all their arguments are constant // and either pWalker->eCode==4 or 5 or the function has the // SQLITE_FUNC_CONST flag. - case 169: - if ((int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) >= 4) || (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x080000))) != U32(0))) && - !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + case TK_FUNCTION: + if ((int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) >= 4) || (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_ConstFunc)) != U32(0))) && + !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) { if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 5 { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x40000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_FromDDL) } - return 0 + return WRC_Continue } else { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 + return WRC_Abort } fallthrough - case 59: + case TK_ID: // Convert "true" or "false" in a DEFAULT clause into the // appropriate TK_TRUEFALSE operator if Xsqlite3ExprIdToTrueFalse(tls, pExpr) != 0 { - return 1 + return WRC_Prune } - /* no break */ fallthrough - case 164: + case TK_COLUMN: fallthrough - case 165: + case TK_AGG_FUNCTION: fallthrough - case 166: + case TK_AGG_COLUMN: - if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000008))) != U32(0)) && (int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) != 2) { - return 0 + if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FixedCol)) != U32(0)) && (int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) != 2) { + return WRC_Continue } if (int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 3) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == *(*int32)(unsafe.Pointer(pWalker + 40 /* &.u */))) { - return 0 + return WRC_Continue } - /* no break */ fallthrough - case 176: + case TK_IF_NULL_ROW: fallthrough - case 173: + case TK_REGISTER: fallthrough - case 139: + case TK_DOT: (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 - case 153: + return WRC_Abort + case TK_VARIABLE: if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 5 { // Silently convert bound parameters that appear inside of CREATE // statements into a NULL when parsing the CREATE statement text out // of the sqlite_schema table - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(119) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_NULL } else if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 4 { // A bound parameter in a CREATE statement that originates from // sqlite3_prepare() causes an error (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 + return WRC_Abort } - /* no break */ fallthrough default: // sqlite3SelectWalkFail() disallows // sqlite3SelectWalkFail() disallows - return 0 + return WRC_Continue } return int32(0) } @@ -80940,15 +80283,15 @@ func exprNodeIsConstantOrGroupBy(tls *libc.TLS, pWalker uintptr, pExpr uintptr) if Xsqlite3ExprCompare(tls, uintptr(0), pExpr, p, -1) < 2 { var pColl uintptr = Xsqlite3ExprNNCollSeq(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p) if Xsqlite3IsBinary(tls, pColl) != 0 { - return 1 + return WRC_Prune } } } // Check if pExpr is a sub-select. If so, consider it variable. - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 + return WRC_Abort } return exprNodeIsConstant(tls, pWalker, pExpr) @@ -81028,18 +80371,18 @@ func Xsqlite3ExprIsInteger(tls *libc.TLS, p uintptr, pValue uintptr) int32 { /* // If an expression is an integer literal that fits in a signed 32-bit // integer, then the EP_IntValue flag will have already been set - if ((*Expr)(unsafe.Pointer(p)).Fflags & U32(0x000400)) != 0 { + if ((*Expr)(unsafe.Pointer(p)).Fflags & EP_IntValue) != 0 { *(*int32)(unsafe.Pointer(pValue)) = *(*int32)(unsafe.Pointer(p + 8 /* &.u */)) return 1 } switch int32((*Expr)(unsafe.Pointer(p)).Fop) { - case 171: + case TK_UPLUS: { rc = Xsqlite3ExprIsInteger(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, pValue) break } - case 170: + case TK_UMINUS: { // var v int32 at bp, 4 @@ -81071,24 +80414,24 @@ func Xsqlite3ExprIsInteger(tls *libc.TLS, p uintptr, pValue uintptr) int32 { /* // TRUE. func Xsqlite3ExprCanBeNull(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:101995:20: */ var op U8 - for (int32((*Expr)(unsafe.Pointer(p)).Fop) == 171) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == 170) { + for (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UPLUS) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UMINUS) { p = (*Expr)(unsafe.Pointer(p)).FpLeft } op = (*Expr)(unsafe.Pointer(p)).Fop - if int32(op) == 173 { + if int32(op) == TK_REGISTER { op = (*Expr)(unsafe.Pointer(p)).Fop2 } switch int32(op) { - case 152: + case TK_INTEGER: fallthrough - case 115: + case TK_STRING: fallthrough - case 150: + case TK_FLOAT: fallthrough - case 151: + case TK_BLOB: return 0 - case 164: - return (libc.Bool32(((((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x100000))) != U32(0)) || (*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) == uintptr(0))) || (((int32((*Expr)(unsafe.Pointer(p)).FiColumn) >= 0) && + case TK_COLUMN: + return (libc.Bool32(((((*Expr)(unsafe.Pointer((p))).Fflags & (EP_CanBeNull)) != U32(0)) || (*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) == uintptr(0))) || (((int32((*Expr)(unsafe.Pointer(p)).FiColumn) >= 0) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)))).FaCol != uintptr(0))) && // Defense against OOM problems (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)))).FaCol+uintptr((*Expr)(unsafe.Pointer(p)).FiColumn)*32)).FnotNull) == 0)))) default: @@ -81108,44 +80451,44 @@ func Xsqlite3ExprCanBeNull(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:101995 func Xsqlite3ExprNeedsNoAffinityChange(tls *libc.TLS, p uintptr, aff int8) int32 { /* sqlite3.c:102029:20: */ var op U8 var unaryMinus int32 = 0 - if int32(aff) == 0x41 { + if int32(aff) == SQLITE_AFF_BLOB { return 1 } - for (int32((*Expr)(unsafe.Pointer(p)).Fop) == 171) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == 170) { - if int32((*Expr)(unsafe.Pointer(p)).Fop) == 170 { + for (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UPLUS) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UMINUS) { + if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UMINUS { unaryMinus = 1 } p = (*Expr)(unsafe.Pointer(p)).FpLeft } op = (*Expr)(unsafe.Pointer(p)).Fop - if int32(op) == 173 { + if int32(op) == TK_REGISTER { op = (*Expr)(unsafe.Pointer(p)).Fop2 } switch int32(op) { - case 152: + case TK_INTEGER: { - return (libc.Bool32(int32(aff) >= 0x43)) + return (libc.Bool32(int32(aff) >= SQLITE_AFF_NUMERIC)) } - case 150: + case TK_FLOAT: { - return (libc.Bool32(int32(aff) >= 0x43)) + return (libc.Bool32(int32(aff) >= SQLITE_AFF_NUMERIC)) } - case 115: + case TK_STRING: { - return (libc.Bool32(!(unaryMinus != 0) && (int32(aff) == 0x42))) + return (libc.Bool32(!(unaryMinus != 0) && (int32(aff) == SQLITE_AFF_TEXT))) } - case 151: + case TK_BLOB: { return libc.BoolInt32(!(unaryMinus != 0)) } - case 164: + case TK_COLUMN: { // p cannot be part of a CHECK constraint - return (libc.Bool32((int32(aff) >= 0x43) && (int32((*Expr)(unsafe.Pointer(p)).FiColumn) < 0))) + return (libc.Bool32((int32(aff) >= SQLITE_AFF_NUMERIC) && (int32((*Expr)(unsafe.Pointer(p)).FiColumn) < 0))) } default: @@ -81182,17 +80525,17 @@ func isCandidateForInOpt(tls *libc.TLS, pX uintptr) uintptr { /* sqlite3.c:10208 var pEList uintptr var pTab uintptr var i int32 - if !(((*Expr)(unsafe.Pointer((pX))).Fflags & (U32(0x000800))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pX))).Fflags & (EP_xIsSelect)) != U32(0)) { return uintptr(0) } // Not a subquery - if ((*Expr)(unsafe.Pointer((pX))).Fflags & (U32(0x000020))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pX))).Fflags & (EP_VarSelect)) != U32(0) { return uintptr(0) } // Correlated subq p = *(*uintptr)(unsafe.Pointer(pX + 32 /* &.x */)) if (*Select)(unsafe.Pointer(p)).FpPrior != 0 { return uintptr(0) } // Not a compound SELECT - if ((*Select)(unsafe.Pointer(p)).FselFlags & (U32(0x0000001 | 0x0000008))) != 0 { + if ((*Select)(unsafe.Pointer(p)).FselFlags & (U32(SF_Distinct | SF_Aggregate))) != 0 { return uintptr(0) // No DISTINCT keyword and no aggregate functions } @@ -81208,10 +80551,10 @@ func isCandidateForInOpt(tls *libc.TLS, pX uintptr) uintptr { /* sqlite3.c:10208 if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc != 1 { return uintptr(0) } // Single term in FROM clause - if (*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(0)*112)).FpSelect != 0 { + if (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FpSelect != 0 { return uintptr(0) } // FROM is not a subquery or view - pTab = (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab + pTab = (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FpTab // FROM clause is not a view if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { @@ -81222,7 +80565,7 @@ func isCandidateForInOpt(tls *libc.TLS, pX uintptr) uintptr { /* sqlite3.c:10208 // All SELECT results must be columns. for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ { var pRes uintptr = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(i)*32)).FpExpr - if int32((*Expr)(unsafe.Pointer(pRes)).Fop) != 164 { + if int32((*Expr)(unsafe.Pointer(pRes)).Fop) != TK_COLUMN { return uintptr(0) } // Not a correlated subquery @@ -81236,10 +80579,10 @@ func isCandidateForInOpt(tls *libc.TLS, pX uintptr) uintptr { /* sqlite3.c:10208 // to be set to NULL if iCur contains one or more NULL values. func sqlite3SetHasNullFlag(tls *libc.TLS, v uintptr, iCur int32, regHasNull int32) { /* sqlite3.c:102125:13: */ var addr1 int32 - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regHasNull) - addr1 = Xsqlite3VdbeAddOp1(tls, v, 37, iCur) - Xsqlite3VdbeAddOp3(tls, v, 89, iCur, 0, regHasNull) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x80)) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regHasNull) + addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iCur) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iCur, 0, regHasNull) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_TYPEOFARG) Xsqlite3VdbeJumpHere(tls, v, addr1) } @@ -81345,14 +80688,14 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, var mustBeUnique int32 // True if RHS must be unique var v uintptr = Xsqlite3GetVdbe(tls, pParse) // Virtual machine being coded - mustBeUnique = (libc.Bool32((inFlags & U32(0x0004)) != U32(0))) + mustBeUnique = (libc.Bool32((inFlags & IN_INDEX_LOOP) != U32(0))) // If the RHS of this IN(...) operator is a SELECT, and if it matters // whether or not the SELECT result contains NULL values, check whether // or not NULL is actually possible (it may not be, for example, due // to NOT NULL constraints in the schema). If no NULL values are possible, // set prRhsHasNull to 0 before continuing. - if (prRhsHasNull != 0) && (((*Expr)(unsafe.Pointer(pX)).Fflags & U32(0x000800)) != 0) { + if (prRhsHasNull != 0) && (((*Expr)(unsafe.Pointer(pX)).Fflags & EP_xIsSelect) != 0) { var i int32 var pEList uintptr = (*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32 /* &.x */)))).FpEList for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ { @@ -81378,7 +80721,7 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, // Because of isCandidateForInOpt(p) // Because of isCandidateForInOpt(p) // Because of isCandidateForInOpt(p) - pTab = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab + pTab = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpTab // Code an OP_Transaction and OP_TableLock for . iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) @@ -81387,12 +80730,12 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, uint8(0), (*Table)(unsafe.Pointer(pTab)).FzName) // sqlite3GetVdbe() has always been previously called - if (nExpr == 1) && (int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(0)*32)).FpExpr)).FiColumn) < 0) { + if (nExpr == 1) && (int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */))).FpExpr)).FiColumn) < 0) { // The "x IN (SELECT rowid FROM table)" case - var iAddr int32 = Xsqlite3VdbeAddOp0(tls, v, 17) + var iAddr int32 = Xsqlite3VdbeAddOp0(tls, v, OP_Once) - Xsqlite3OpenTable(tls, pParse, iTab, iDb, pTab, 96) - eType = 1 + Xsqlite3OpenTable(tls, pParse, iTab, iDb, pTab, OP_OpenRead) + eType = IN_INDEX_ROWID Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+6522 /* "USING ROWID SEAR..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName)) Xsqlite3VdbeJumpHere(tls, v, iAddr) } else { @@ -81411,10 +80754,10 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, var cmpaff int8 = Xsqlite3CompareAffinity(tls, pLhs, idxaff) switch int32(cmpaff) { - case 0x41: + case SQLITE_AFF_BLOB: break fallthrough - case 0x42: + case SQLITE_AFF_TEXT: // sqlite3CompareAffinity() only returns TEXT if one side or the // other has no affinity and the other side is TEXT. Hence, // the only way for cmpaff to be TEXT is for idxaff to be TEXT @@ -81423,7 +80766,7 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, break fallthrough default: - affinity_ok = (libc.Bool32((int32(idxaff)) >= 0x43)) + affinity_ok = (libc.Bool32((int32(idxaff)) >= SQLITE_AFF_NUMERIC)) } } @@ -81446,7 +80789,7 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, } if mustBeUnique != 0 { if (int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) > nExpr) || - ((int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) > nExpr) && !(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0)) { + ((int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) > nExpr) && !(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None)) { continue // This index is not unique over the IN RHS columns } } @@ -81483,12 +80826,12 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, if colUsed == ((Bitmask((uint64(1))) << (nExpr)) - uint64(1)) { // If we reach this point, that means the index pIdx is usable - var iAddr int32 = Xsqlite3VdbeAddOp0(tls, v, 17) + var iAddr int32 = Xsqlite3VdbeAddOp0(tls, v, OP_Once) Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+6569 /* "USING INDEX %s F..." */, libc.VaList(bp+8, (*Index)(unsafe.Pointer(pIdx)).FzName)) - Xsqlite3VdbeAddOp3(tls, v, 96, iTab, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, iTab, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx) - eType = (3 + int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(0))))) + eType = (IN_INDEX_INDEX_ASC + int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder)))) if prRhsHasNull != 0 { *(*int32)(unsafe.Pointer(prRhsHasNull)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) @@ -81510,10 +80853,10 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, // then it is not worth creating an ephemeral table to evaluate // the IN operator so return IN_INDEX_NOOP. if (((eType == 0) && - ((inFlags & U32(0x0001)) != 0)) && - !(((*Expr)(unsafe.Pointer((pX))).Fflags & (U32(0x000800))) != U32(0))) && + ((inFlags & IN_INDEX_NOOP_OK) != 0)) && + !(((*Expr)(unsafe.Pointer((pX))).Fflags & (EP_xIsSelect)) != U32(0))) && (!(sqlite3InRhsIsConstant(tls, pX) != 0) || ((*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32 /* &.x */)))).FnExpr <= 2)) { - eType = 5 + eType = IN_INDEX_NOOP } if eType == 0 { @@ -81521,8 +80864,8 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, // We will have to generate an ephemeral table to do the job. var savedNQueryLoop U32 = (*Parse)(unsafe.Pointer(pParse)).FnQueryLoop var rMayHaveNull int32 = 0 - eType = 2 - if (inFlags & U32(0x0004)) != 0 { + eType = IN_INDEX_EPH + if (inFlags & IN_INDEX_LOOP) != 0 { (*Parse)(unsafe.Pointer(pParse)).FnQueryLoop = U32(0) } else if prRhsHasNull != 0 { *(*int32)(unsafe.Pointer(prRhsHasNull)) = libc.AssignInt32(&rMayHaveNull, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)) @@ -81535,7 +80878,7 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, (*Parse)(unsafe.Pointer(pParse)).FnQueryLoop = savedNQueryLoop } - if ((aiMap != 0) && (eType != 3)) && (eType != 4) { + if ((aiMap != 0) && (eType != IN_INDEX_INDEX_ASC)) && (eType != IN_INDEX_INDEX_DESC) { var i int32 var n int32 n = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pX)).FpLeft) @@ -81557,7 +80900,7 @@ func exprINAffinity(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr { /* s var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft var nVal int32 = Xsqlite3ExprVectorSize(tls, pLeft) var pSelect uintptr - if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & U32(0x000800)) != 0 { + if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & EP_xIsSelect) != 0 { pSelect = *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) } else { pSelect = uintptr(0) @@ -81605,7 +80948,7 @@ func Xsqlite3SubselectError(tls *libc.TLS, pParse uintptr, nActual int32, nExpec // // "row value misused" func Xsqlite3VectorErrorMsg(tls *libc.TLS, pParse uintptr, pExpr uintptr) { /* sqlite3.c:102509:21: */ - if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & U32(0x000800)) != 0 { + if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & EP_xIsSelect) != 0 { Xsqlite3SubselectError(tls, pParse, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList)).FnExpr, 1) } else { Xsqlite3ErrorMsg(tls, pParse, ts+5372 /* "row value misuse..." */, 0) @@ -81654,29 +80997,29 @@ func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int3 // // If all of the above are false, then we can compute the RHS just once // and reuse it many names. - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000020))) != U32(0)) && ((*Parse)(unsafe.Pointer(pParse)).FiSelfTab == 0) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_VarSelect)) != U32(0)) && ((*Parse)(unsafe.Pointer(pParse)).FiSelfTab == 0) { // Reuse of the RHS is allowed // If this routine has already been coded, but the previous code // might not have been invoked yet, so invoke it now as a subroutine. - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x2000000))) != U32(0) { - addrOnce = Xsqlite3VdbeAddOp0(tls, v, 17) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Subrtn)) != U32(0) { + addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once) + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+6644 /* "REUSE LIST SUBQU..." */, libc.VaList(bp, (*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FselId)) } - Xsqlite3VdbeAddOp2(tls, v, 12, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */)), + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */)), *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ /* &.iAddr */))) - Xsqlite3VdbeAddOp2(tls, v, 98, iTab, (*Expr)(unsafe.Pointer(pExpr)).FiTable) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, iTab, (*Expr)(unsafe.Pointer(pExpr)).FiTable) Xsqlite3VdbeJumpHere(tls, v, addrOnce) return } // Begin coding the subroutine - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x2000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Subrtn) *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ /* &.iAddr */)) = (Xsqlite3VdbeAddOp2(tls, v, 69, 0, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) + 1) + *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ /* &.iAddr */)) = (Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) + 1) - addrOnce = Xsqlite3VdbeAddOp0(tls, v, 17) + addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once) } // Check to see if this is a vector IN operator @@ -81686,10 +81029,10 @@ func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int3 // Construct the ephemeral table that will contain the content of // RHS of the IN operator. (*Expr)(unsafe.Pointer(pExpr)).FiTable = iTab - addr = Xsqlite3VdbeAddOp2(tls, v, 100, (*Expr)(unsafe.Pointer(pExpr)).FiTable, nVal) + addr = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*Expr)(unsafe.Pointer(pExpr)).FiTable, nVal) pKeyInfo = Xsqlite3KeyInfoAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, nVal, 1) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { // Case 1: expr IN (SELECT ...) // // Generate code to write the results of the select into the temporary @@ -81709,7 +81052,7 @@ func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int3 // var dest SelectDest at bp+24, 40 var i int32 - Xsqlite3SelectDestInit(tls, bp+24 /* &dest */, 11, iTab) + Xsqlite3SelectDestInit(tls, bp+24 /* &dest */, SRT_Set, iTab) (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FzAffSdst = exprINAffinity(tls, pParse, pExpr) (*Select)(unsafe.Pointer(pSelect)).FiLimit = 0 @@ -81743,14 +81086,14 @@ func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int3 var r1 int32 var r2 int32 *(*int8)(unsafe.Pointer(bp + 64 /* affinity */)) = Xsqlite3ExprAffinity(tls, pLeft) - if int32(*(*int8)(unsafe.Pointer(bp + 64 /* affinity */))) <= 0x40 { - *(*int8)(unsafe.Pointer(bp + 64 /* affinity */)) = int8(0x41) - } else if int32(*(*int8)(unsafe.Pointer(bp + 64 /* affinity */))) == 0x45 { - *(*int8)(unsafe.Pointer(bp + 64 /* affinity */)) = int8(0x43) + if int32(*(*int8)(unsafe.Pointer(bp + 64 /* affinity */))) <= SQLITE_AFF_NONE { + *(*int8)(unsafe.Pointer(bp + 64 /* affinity */)) = SQLITE_AFF_BLOB + } else if int32(*(*int8)(unsafe.Pointer(bp + 64 /* affinity */))) == SQLITE_AFF_REAL { + *(*int8)(unsafe.Pointer(bp + 64 /* affinity */)) = SQLITE_AFF_NUMERIC } if pKeyInfo != 0 { - *(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */) + uintptr(0)*8)) = Xsqlite3ExprCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) + *(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */))) = Xsqlite3ExprCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) } // Loop through each expression in . @@ -81771,14 +81114,14 @@ func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int3 // expression we need to rerun this code each time. if (addrOnce != 0) && !(Xsqlite3ExprIsConstant(tls, pE2) != 0) { Xsqlite3VdbeChangeToNoop(tls, v, addrOnce) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(0x2000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(EP_Subrtn))) addrOnce = 0 } // Evaluate the expression and insert it into the temp table Xsqlite3ExprCode(tls, pParse, pE2, r1) - Xsqlite3VdbeAddOp4(tls, v, 91, r1, 1, r2, bp+64 /* &affinity */, 1) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iTab, r2, r1, 1) + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, r1, 1, r2, bp+64 /* &affinity */, 1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iTab, r2, r1, 1) } goto __2 @@ -81798,7 +81141,7 @@ func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int3 if addrOnce != 0 { Xsqlite3VdbeJumpHere(tls, v, addrOnce) // Subroutine return - Xsqlite3VdbeAddOp1(tls, v, 65, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) Xsqlite3VdbeChangeP1(tls, v, (*(*int32)(unsafe.Pointer((pExpr + 64 /* &.y */ /* &.sub */) /* &.iAddr */)) - 1), (Xsqlite3VdbeCurrentAddr(tls, v) - 1)) Xsqlite3ClearTempRegCache(tls, pParse) } @@ -81841,22 +81184,22 @@ func Xsqlite3CodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { // // If all of the above are false, then we can run this code just once // save the results, and reuse the same result on subsequent invocations. - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000020))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_VarSelect)) != U32(0)) { // If this routine has already been coded, then invoke it as a // subroutine. - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x2000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Subrtn)) != U32(0) { Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+6698 /* "REUSE SUBQUERY %..." */, libc.VaList(bp, (*Select)(unsafe.Pointer(pSel)).FselId)) - Xsqlite3VdbeAddOp2(tls, v, 12, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */)), + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */)), *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ /* &.iAddr */))) return (*Expr)(unsafe.Pointer(pExpr)).FiTable } // Begin coding the subroutine - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x2000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Subrtn) *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ /* &.iAddr */)) = (Xsqlite3VdbeAddOp2(tls, v, 69, 0, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) + 1) + *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ /* &.iAddr */)) = (Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) + 1) - addrOnce = Xsqlite3VdbeAddOp0(tls, v, 17) + addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once) } // For a SELECT, generate code to put the values for all columns of @@ -81874,40 +81217,40 @@ func Xsqlite3CodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { } return ts + 6686 /* "CORRELATED " */ }(), (*Select)(unsafe.Pointer(pSel)).FselId)) - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 136 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_SELECT { nReg = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpEList)).FnExpr } else { nReg = 1 } Xsqlite3SelectDestInit(tls, bp+24 /* &dest */, 0, ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1)) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (nReg) - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 136 { - (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FeDest = U8(10) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_SELECT { + (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FeDest = SRT_Mem (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FiSdst = (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FiSDParm (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FnSdst = nReg - Xsqlite3VdbeAddOp3(tls, v, 72, 0, (*SelectDest)(unsafe.Pointer(bp+24 /* &dest */)).FiSDParm, (((*SelectDest)(unsafe.Pointer(bp+24 /* &dest */)).FiSDParm + nReg) - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, (*SelectDest)(unsafe.Pointer(bp+24 /* &dest */)).FiSDParm, (((*SelectDest)(unsafe.Pointer(bp+24 /* &dest */)).FiSDParm + nReg) - 1)) } else { - (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FeDest = U8(3) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, (*SelectDest)(unsafe.Pointer(bp+24 /* &dest */)).FiSDParm) + (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FeDest = SRT_Exists + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*SelectDest)(unsafe.Pointer(bp+24 /* &dest */)).FiSDParm) } if (*Select)(unsafe.Pointer(pSel)).FpLimit != 0 { // The subquery already has a limit. If the pre-existing limit is X // then make the new limit X<>0 so that the new limit is either 1 or 0 var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - pLimit = Xsqlite3Expr(tls, db, 152, ts+6319 /* "0" */) + pLimit = Xsqlite3Expr(tls, db, TK_INTEGER, ts+6319 /* "0" */) if pLimit != 0 { - (*Expr)(unsafe.Pointer(pLimit)).FaffExpr = int8(0x43) - pLimit = Xsqlite3PExpr(tls, pParse, 52, + (*Expr)(unsafe.Pointer(pLimit)).FaffExpr = SQLITE_AFF_NUMERIC + pLimit = Xsqlite3PExpr(tls, pParse, TK_NE, Xsqlite3ExprDup(tls, db, (*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpLimit)).FpLeft, 0), pLimit) } Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpLimit)).FpLeft) (*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpLimit)).FpLeft = pLimit } else { // If there is no pre-existing limit add a limit of 1 - pLimit = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 152, ts+6737 /* "1" */) - (*Select)(unsafe.Pointer(pSel)).FpLimit = Xsqlite3PExpr(tls, pParse, 146, pLimit, uintptr(0)) + pLimit = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_INTEGER, ts+6737 /* "1" */) + (*Select)(unsafe.Pointer(pSel)).FpLimit = Xsqlite3PExpr(tls, pParse, TK_LIMIT, pLimit, uintptr(0)) } (*Select)(unsafe.Pointer(pSel)).FiLimit = 0 if Xsqlite3Select(tls, pParse, pSel, bp+24 /* &dest */) != 0 { @@ -81919,7 +81262,7 @@ func Xsqlite3CodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { Xsqlite3VdbeJumpHere(tls, v, addrOnce) // Subroutine return - Xsqlite3VdbeAddOp1(tls, v, 65, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) Xsqlite3VdbeChangeP1(tls, v, (*(*int32)(unsafe.Pointer((pExpr + 64 /* &.y */ /* &.sub */) /* &.iAddr */)) - 1), (Xsqlite3VdbeCurrentAddr(tls, v) - 1)) Xsqlite3ClearTempRegCache(tls, pParse) } @@ -81933,7 +81276,7 @@ func Xsqlite3CodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { // a sub-query, that the LHS is a vector of size 1. func Xsqlite3ExprCheckIN(tls *libc.TLS, pParse uintptr, pIn uintptr) int32 { /* sqlite3.c:102846:20: */ var nVector int32 = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pIn)).FpLeft) - if ((*Expr)(unsafe.Pointer(pIn)).Fflags & U32(0x000800)) != 0 { + if ((*Expr)(unsafe.Pointer(pIn)).Fflags & EP_xIsSelect) != 0 { if nVector != (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIn + 32 /* &.x */)))).FpEList)).FnExpr { Xsqlite3SubselectError(tls, pParse, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIn + 32 /* &.x */)))).FpEList)).FnExpr, nVector) return 1 @@ -82040,7 +81383,7 @@ __2: // OOM detected prior to this routine eType = Xsqlite3FindInIndex(tls, pParse, pExpr, - (uint32(0x0002 | 0x0001)), + (uint32(IN_INDEX_MEMBERSHIP | IN_INDEX_NOOP_OK)), func() uintptr { if destIfFalse == destIfNull { return uintptr(0) @@ -82091,7 +81434,7 @@ __8: if !(i < nVector) { goto __10 } - Xsqlite3VdbeAddOp3(tls, v, 77, (rLhsOrig + i), (rLhs + *(*int32)(unsafe.Pointer(aiMap + uintptr(i)*4))), 0) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, (rLhsOrig + i), (rLhs + *(*int32)(unsafe.Pointer(aiMap + uintptr(i)*4))), 0) goto __9 __9: i++ @@ -82107,7 +81450,7 @@ __7: // sequence of comparisons. // // This is step (1) in the in-operator.md optimized algorithm. - if !(eType == 5) { + if !(eType == IN_INDEX_NOOP) { goto __11 } pList = *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) @@ -82119,7 +81462,7 @@ __7: goto __12 } regCkNull = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 101, rLhs, rLhs, regCkNull) + Xsqlite3VdbeAddOp3(tls, v, OP_BitAnd, rLhs, rLhs, regCkNull) __12: ; ii = 0 @@ -82131,7 +81474,7 @@ __13: if !((regCkNull != 0) && (Xsqlite3ExprCanBeNull(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(ii)*32)).FpExpr) != 0)) { goto __16 } - Xsqlite3VdbeAddOp3(tls, v, 101, regCkNull, r2, regCkNull) + Xsqlite3VdbeAddOp3(tls, v, OP_BitAnd, regCkNull, r2, regCkNull) __16: ; Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 12 /* regToFree */))) @@ -82139,26 +81482,26 @@ __16: goto __17 } if rLhs != r2 { - op = 53 + op = OP_Eq } else { - op = 51 + op = OP_NotNull } Xsqlite3VdbeAddOp4(tls, v, op, rLhs, labelOk, r2, pColl, -2) - Xsqlite3VdbeChangeP5(tls, v, uint16(*(*int8)(unsafe.Pointer(zAff + uintptr(0))))) + Xsqlite3VdbeChangeP5(tls, v, uint16(*(*int8)(unsafe.Pointer(zAff)))) goto __18 __17: if rLhs != r2 { - op1 = 52 + op1 = OP_Ne } else { - op1 = 50 + op1 = OP_IsNull } Xsqlite3VdbeAddOp4(tls, v, op1, rLhs, destIfFalse, r2, pColl, -2) - Xsqlite3VdbeChangeP5(tls, v, (uint16(int32(*(*int8)(unsafe.Pointer(zAff + uintptr(0)))) | 0x10))) + Xsqlite3VdbeChangeP5(tls, v, (uint16(int32(*(*int8)(unsafe.Pointer(zAff))) | SQLITE_JUMPIFNULL))) __18: ; goto __14 @@ -82171,7 +81514,7 @@ __15: if !(regCkNull != 0) { goto __19 } - Xsqlite3VdbeAddOp2(tls, v, 50, regCkNull, destIfNull) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regCkNull, destIfNull) Xsqlite3VdbeGoto(tls, v, destIfFalse) __19: ; @@ -82208,7 +81551,7 @@ __23: if !(Xsqlite3ExprCanBeNull(tls, p) != 0) { goto __26 } - Xsqlite3VdbeAddOp2(tls, v, 50, (rLhs + i), destStep2) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (rLhs + i), destStep2) __26: ; @@ -82223,29 +81566,29 @@ __25: // Step 3. The LHS is now known to be non-NULL. Do the binary search // of the RHS using the LHS as a probe. If found, the result is // true. - if !(eType == 1) { + if !(eType == IN_INDEX_ROWID) { goto __27 } // In this case, the RHS is the ROWID of table b-tree and so we also // know that the RHS is non-NULL. Hence, we combine steps 3 and 4 // into a single opcode. - Xsqlite3VdbeAddOp3(tls, v, 31, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), destIfFalse, rLhs) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), destIfFalse, rLhs) - addrTruthOp = Xsqlite3VdbeAddOp0(tls, v, 11) // Return True + addrTruthOp = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) // Return True goto __28 __27: - Xsqlite3VdbeAddOp4(tls, v, 90, rLhs, nVector, 0, zAff, nVector) + Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, rLhs, nVector, 0, zAff, nVector) if !(destIfFalse == destIfNull) { goto __29 } // Combine Step 3 and Step 5 into a single opcode - Xsqlite3VdbeAddOp4Int(tls, v, 29, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), destIfFalse, + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), destIfFalse, rLhs, nVector) goto sqlite3ExprCodeIN_finished __29: ; // Ordinary Step 3, for the case where FALSE and NULL are distinct - addrTruthOp = Xsqlite3VdbeAddOp4Int(tls, v, 30, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), 0, + addrTruthOp = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), 0, rLhs, nVector) __28: ; @@ -82255,7 +81598,7 @@ __28: if !((*(*int32)(unsafe.Pointer(bp /* rRhsHasNull */)) != 0) && (nVector == 1)) { goto __30 } - Xsqlite3VdbeAddOp2(tls, v, 51, *(*int32)(unsafe.Pointer(bp /* rRhsHasNull */)), destIfFalse) + Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, *(*int32)(unsafe.Pointer(bp /* rRhsHasNull */)), destIfFalse) __30: ; @@ -82281,7 +81624,7 @@ __31: Xsqlite3VdbeResolveLabel(tls, v, destStep6) __32: ; - addrTop = Xsqlite3VdbeAddOp2(tls, v, 37, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), destIfFalse) + addrTop = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), destIfFalse) if !(nVector > 1) { goto __33 @@ -82302,8 +81645,8 @@ __35: r3 = Xsqlite3GetTempReg(tls, pParse) p1 = Xsqlite3VectorFieldSubexpr(tls, pLeft, i) pColl1 = Xsqlite3ExprCollSeq(tls, pParse, p1) - Xsqlite3VdbeAddOp3(tls, v, 89, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), i, r3) - Xsqlite3VdbeAddOp4(tls, v, 52, (rLhs + i), destNotNull, r3, + Xsqlite3VdbeAddOp3(tls, v, OP_Column, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), i, r3) + Xsqlite3VdbeAddOp4(tls, v, OP_Ne, (rLhs + i), destNotNull, r3, pColl1, -2) Xsqlite3ReleaseTempReg(tls, pParse, r3) @@ -82314,16 +81657,16 @@ __36: goto __37 __37: ; - Xsqlite3VdbeAddOp2(tls, v, 11, 0, destIfNull) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, destIfNull) if !(nVector > 1) { goto __38 } Xsqlite3VdbeResolveLabel(tls, v, destNotNull) - Xsqlite3VdbeAddOp2(tls, v, 5, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), (addrTop + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), (addrTop + 1)) // Step 7: If we reach this point, we know that the result must // be false. - Xsqlite3VdbeAddOp2(tls, v, 11, 0, destIfFalse) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, destIfFalse) __38: ; @@ -82356,12 +81699,12 @@ func codeReal(tls *libc.TLS, v uintptr, z uintptr, negateFlag int32, iMem int32) if z != uintptr(0) { // var value float64 at bp, 8 - Xsqlite3AtoF(tls, z, bp /* &value */, Xsqlite3Strlen30(tls, z), uint8(1)) + Xsqlite3AtoF(tls, z, bp /* &value */, Xsqlite3Strlen30(tls, z), SQLITE_UTF8) // The new AtoF never returns NaN if negateFlag != 0 { *(*float64)(unsafe.Pointer(bp /* value */)) = -*(*float64)(unsafe.Pointer(bp /* value */)) } - Xsqlite3VdbeAddOp4Dup8(tls, v, 150, 0, iMem, 0, bp /* &value */, -13) + Xsqlite3VdbeAddOp4Dup8(tls, v, OP_Real, 0, iMem, 0, bp /* &value */, -13) } } @@ -82374,13 +81717,13 @@ func codeInteger(tls *libc.TLS, pParse uintptr, pExpr uintptr, negFlag int32, iM defer tls.Free(24) var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe - if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & U32(0x000400)) != 0 { + if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & EP_IntValue) != 0 { var i int32 = *(*int32)(unsafe.Pointer(pExpr + 8 /* &.u */)) if negFlag != 0 { i = -i } - Xsqlite3VdbeAddOp2(tls, v, 69, i, iMem) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, i, iMem) } else { var c int32 // var value I64 at bp+16, 8 @@ -82407,7 +81750,7 @@ func codeInteger(tls *libc.TLS, pParse uintptr, pExpr uintptr, negFlag int32, iM *(*I64)(unsafe.Pointer(bp + 16 /* value */)) = -*(*I64)(unsafe.Pointer(bp + 16 /* value */)) } } - Xsqlite3VdbeAddOp4Dup8(tls, v, 70, 0, iMem, 0, bp+16 /* &value */, -14) + Xsqlite3VdbeAddOp4Dup8(tls, v, OP_Int64, 0, iMem, 0, bp+16 /* &value */, -14) } } } @@ -82434,13 +81777,13 @@ func Xsqlite3ExprCodeGeneratedColumn(tls *libc.TLS, pParse uintptr, pCol uintptr var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe if (*Parse)(unsafe.Pointer(pParse)).FiSelfTab > 0 { - iAddr = Xsqlite3VdbeAddOp3(tls, v, 21, ((*Parse)(unsafe.Pointer(pParse)).FiSelfTab - 1), 0, regOut) + iAddr = Xsqlite3VdbeAddOp3(tls, v, OP_IfNullRow, ((*Parse)(unsafe.Pointer(pParse)).FiSelfTab - 1), 0, regOut) } else { iAddr = 0 } Xsqlite3ExprCodeCopy(tls, pParse, (*Column)(unsafe.Pointer(pCol)).FpDflt, regOut) - if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) >= 0x42 { - Xsqlite3VdbeAddOp4(tls, v, 90, regOut, 1, 0, (pCol + 25 /* &.affinity */), 1) + if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) >= SQLITE_AFF_TEXT { + Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, regOut, 1, 0, (pCol + 25 /* &.affinity */), 1) } if iAddr != 0 { Xsqlite3VdbeJumpHere(tls, v, iAddr) @@ -82455,38 +81798,38 @@ func Xsqlite3ExprCodeGetColumnOfTable(tls *libc.TLS, v uintptr, pTab uintptr, iT var pCol uintptr if pTab == uintptr(0) { - Xsqlite3VdbeAddOp3(tls, v, 89, iTabCur, iCol, regOut) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iTabCur, iCol, regOut) return } if (iCol < 0) || (iCol == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) { - Xsqlite3VdbeAddOp2(tls, v, 127, iTabCur, regOut) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iTabCur, regOut) } else { var op int32 var x int32 if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { - op = 166 + op = OP_VColumn x = iCol - } else if (int32((*Column)(unsafe.Pointer((libc.AssignUintptr(&pCol, ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*32))))).FcolFlags) & 0x0020) != 0 { + } else if (int32((*Column)(unsafe.Pointer((libc.AssignUintptr(&pCol, ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*32))))).FcolFlags) & COLFLAG_VIRTUAL) != 0 { var pParse uintptr = Xsqlite3VdbeParser(tls, v) - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0100) != 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_BUSY) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+6768 /* "generated column..." */, libc.VaList(bp, (*Column)(unsafe.Pointer(pCol)).FzName)) } else { var savedSelfTab int32 = (*Parse)(unsafe.Pointer(pParse)).FiSelfTab - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((0x0100)) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((COLFLAG_BUSY)) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = (iTabCur + 1) Xsqlite3ExprCodeGeneratedColumn(tls, pParse, pCol, regOut) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = savedSelfTab - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0100))) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(COLFLAG_BUSY))) } return - } else if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + } else if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { x = int32(Xsqlite3TableColumnToIndex(tls, Xsqlite3PrimaryKeyIndex(tls, pTab), int16(iCol))) - op = 89 + op = OP_Column } else { x = int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(iCol))) - op = 89 + op = OP_Column } Xsqlite3VdbeAddOp3(tls, v, op, iTabCur, x, regOut) Xsqlite3ColumnDefault(tls, v, pTab, iCol, regOut) @@ -82503,7 +81846,7 @@ func Xsqlite3ExprCodeGetColumn(tls *libc.TLS, pParse uintptr, pTab uintptr, iCol Xsqlite3ExprCodeGetColumnOfTable(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, pTab, iTable, iColumn, iReg) if p5 != 0 { var pOp uintptr = Xsqlite3VdbeGetOp(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, -1) - if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 89 { + if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column { (*VdbeOp)(unsafe.Pointer(pOp)).Fp5 = U16(p5) } } @@ -82513,7 +81856,7 @@ func Xsqlite3ExprCodeGetColumn(tls *libc.TLS, pParse uintptr, pTab uintptr, iCol // Generate code to move content from registers iFrom...iFrom+nReg-1 // over to iTo..iTo+nReg-1. func Xsqlite3ExprCodeMove(tls *libc.TLS, pParse uintptr, iFrom int32, iTo int32, nReg int32) { /* sqlite3.c:103326:21: */ - Xsqlite3VdbeAddOp3(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, 76, iFrom, iTo, nReg) + Xsqlite3VdbeAddOp3(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_Move, iFrom, iTo, nReg) } // Convert a scalar expression node to a TK_REGISTER referencing @@ -82522,9 +81865,9 @@ func Xsqlite3ExprCodeMove(tls *libc.TLS, pParse uintptr, iFrom int32, iTo int32, func exprToRegister(tls *libc.TLS, pExpr uintptr, iReg int32) { /* sqlite3.c:103335:13: */ var p uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, pExpr) (*Expr)(unsafe.Pointer(p)).Fop2 = (*Expr)(unsafe.Pointer(p)).Fop - (*Expr)(unsafe.Pointer(p)).Fop = U8(173) + (*Expr)(unsafe.Pointer(p)).Fop = TK_REGISTER (*Expr)(unsafe.Pointer(p)).FiTable = iReg - *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(0x001000)) + *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(EP_Skip))) } // Evaluate an expression (either a vector or a scalar expression) and store @@ -82542,7 +81885,7 @@ func exprCodeVector(tls *libc.TLS, pParse uintptr, p uintptr, piFreeable uintptr iResult = Xsqlite3ExprCodeTemp(tls, pParse, p, piFreeable) } else { *(*int32)(unsafe.Pointer(piFreeable)) = 0 - if int32((*Expr)(unsafe.Pointer(p)).Fop) == 136 { + if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_SELECT { iResult = Xsqlite3CodeSubselect(tls, pParse, p) } else { var i int32 @@ -82559,7 +81902,7 @@ func exprCodeVector(tls *libc.TLS, pParse uintptr, p uintptr, piFreeable uintptr // If the last opcode is a OP_Copy, then set the do-not-merge flag (p5) // so that a subsequent copy will not be merged into this one. func setDoNotMergeFlagOnCopy(tls *libc.TLS, v uintptr) { /* sqlite3.c:103382:13: */ - if int32((*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, v, -1))).Fopcode) == 77 { + if int32((*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, v, -1))).Fopcode) == OP_Copy { Xsqlite3VdbeChangeP5(tls, v, uint16(1)) // Tag trailing OP_Copy as not mergable } } @@ -82576,7 +81919,7 @@ func exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncI nFarg = (*ExprList)(unsafe.Pointer(pFarg)).FnExpr // All in-line functions have at least one argument switch iFuncId { - case 0: + case INLINEFUNC_coalesce: { // Attempt a direct implementation of the built-in COALESCE() and // IFNULL() functions. This avoids unnecessary evaluation of @@ -82584,9 +81927,9 @@ func exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncI var endCoalesce int32 = Xsqlite3VdbeMakeLabel(tls, pParse) var i int32 - Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(0)*32)).FpExpr, target) + Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */))).FpExpr, target) for i = 1; i < nFarg; i++ { - Xsqlite3VdbeAddOp2(tls, v, 51, target, endCoalesce) + Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, target, endCoalesce) Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(i)*32)).FpExpr, target) } @@ -82595,12 +81938,12 @@ func exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncI break } - case 5: + case INLINEFUNC_iif: { // var caseExpr Expr at bp, 72 libc.Xmemset(tls, bp /* &caseExpr */, 0, uint64(unsafe.Sizeof(Expr{}))) - (*Expr)(unsafe.Pointer(bp /* &caseExpr */)).Fop = U8(154) + (*Expr)(unsafe.Pointer(bp /* &caseExpr */)).Fop = TK_CASE *(*uintptr)(unsafe.Pointer(bp /* &caseExpr */ + 32 /* &.x */)) = pFarg return Xsqlite3ExprCodeTarget(tls, pParse, bp /* &caseExpr */, target) @@ -82611,7 +81954,7 @@ func exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncI // The UNLIKELY() function is a no-op. The result is the value // of the first argument. - target = Xsqlite3ExprCodeTarget(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(0)*32)).FpExpr, target) + target = Xsqlite3ExprCodeTarget(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */))).FpExpr, target) break } @@ -82620,40 +81963,40 @@ func exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncI // // Test-only SQL functions that are only usable if enabled // via SQLITE_TESTCTRL_INTERNAL_FUNCTIONS - case 3: + case INLINEFUNC_expr_compare: { // Compare two expressions using sqlite3ExprCompare() - Xsqlite3VdbeAddOp2(tls, v, 69, - Xsqlite3ExprCompare(tls, uintptr(0), (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(0)*32)).FpExpr, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(1)*32)).FpExpr, -1), + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, + Xsqlite3ExprCompare(tls, uintptr(0), (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */))).FpExpr, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+1*32)).FpExpr, -1), target) break } - case 2: + case INLINEFUNC_expr_implies_expr: { // Compare two expressions using sqlite3ExprImpliesExpr() - Xsqlite3VdbeAddOp2(tls, v, 69, - Xsqlite3ExprImpliesExpr(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(0)*32)).FpExpr, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(1)*32)).FpExpr, -1), + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, + Xsqlite3ExprImpliesExpr(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */))).FpExpr, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+1*32)).FpExpr, -1), target) break } - case 1: + case INLINEFUNC_implies_nonnull_row: { // REsult of sqlite3ExprImpliesNonNullRow() var pA1 uintptr - pA1 = (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */) + uintptr(1)*32)).FpExpr - if int32((*Expr)(unsafe.Pointer(pA1)).Fop) == 164 { - Xsqlite3VdbeAddOp2(tls, v, 69, - Xsqlite3ExprImpliesNonNullRow(tls, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(0)*32)).FpExpr, (*Expr)(unsafe.Pointer(pA1)).FiTable), + pA1 = (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */) + 1*32)).FpExpr + if int32((*Expr)(unsafe.Pointer(pA1)).Fop) == TK_COLUMN { + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, + Xsqlite3ExprImpliesNonNullRow(tls, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */))).FpExpr, (*Expr)(unsafe.Pointer(pA1)).FiTable), target) } else { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target) } break @@ -82784,7 +82127,7 @@ expr_code_doover: if !(pExpr == uintptr(0)) { goto __1 } - op = 119 + op = TK_NULL goto __2 __1: ; @@ -82792,92 +82135,92 @@ __1: __2: ; switch op { - case 166: + case TK_AGG_COLUMN: goto __4 - case 164: + case TK_COLUMN: goto __5 - case 152: + case TK_INTEGER: goto __6 - case 167: + case TK_TRUEFALSE: goto __7 - case 150: + case TK_FLOAT: goto __8 - case 115: + case TK_STRING: goto __9 default: goto __10 - case 151: + case TK_BLOB: goto __11 - case 153: + case TK_VARIABLE: goto __12 - case 173: + case TK_REGISTER: goto __13 - case 36: + case TK_CAST: goto __14 - case 45: + case TK_IS: goto __15 - case 168: + case TK_ISNOT: goto __16 // fall-through - case 56: + case TK_LT: goto __17 - case 55: + case TK_LE: goto __18 - case 54: + case TK_GT: goto __19 - case 57: + case TK_GE: goto __20 - case 52: + case TK_NE: goto __21 - case 53: + case TK_EQ: goto __22 - case 44: + case TK_AND: goto __23 - case 43: + case TK_OR: goto __24 - case 105: + case TK_PLUS: goto __25 - case 107: + case TK_STAR: goto __26 - case 106: + case TK_MINUS: goto __27 - case 109: + case TK_REM: goto __28 - case 101: + case TK_BITAND: goto __29 - case 102: + case TK_BITOR: goto __30 - case 108: + case TK_SLASH: goto __31 - case 103: + case TK_LSHIFT: goto __32 - case 104: + case TK_RSHIFT: goto __33 - case 110: + case TK_CONCAT: goto __34 - case 170: + case TK_UMINUS: goto __35 - case 112: + case TK_BITNOT: goto __36 - case 19: + case TK_NOT: goto __37 - case 172: + case TK_TRUTH: goto __38 - case 50: + case TK_ISNULL: goto __39 - case 51: + case TK_NOTNULL: goto __40 - case 165: + case TK_AGG_FUNCTION: goto __41 - case 169: + case TK_FUNCTION: goto __42 - case 20: + case TK_EXISTS: goto __43 - case 136: + case TK_SELECT: goto __44 - case 175: + case TK_SELECT_COLUMN: goto __45 - case 49: + case TK_IN: goto __46 // x BETWEEN y AND z @@ -82889,19 +82232,19 @@ __2: // X is stored in pExpr->pLeft. // Y is stored in pExpr->pList->a[0].pExpr. // Z is stored in pExpr->pList->a[1].pExpr. - case 48: + case TK_BETWEEN: goto __47 - case 178: + case TK_SPAN: goto __48 - case 111: + case TK_COLLATE: goto __49 - case 171: + case TK_UPLUS: goto __50 - case 77: + case TK_TRIGGER: goto __51 - case 174: + case TK_VECTOR: goto __52 // TK_IF_NULL_ROW Expr nodes are inserted ahead of expressions @@ -82909,7 +82252,7 @@ __2: // Expr.iTable value is the table number for the right-hand table. // The expression is only evaluated if that table is not currently // on a LEFT JOIN NULL row. - case 176: + case TK_IF_NULL_ROW: goto __53 // Form A: @@ -82931,9 +82274,9 @@ __2: // The result of the expression is the Ri for the first matching Ei, // or if there is no matching Ei, the ELSE term Y, or if there is // no ELSE term, NULL. - case 154: + case TK_CASE: goto __54 - case 71: + case TK_RAISE: goto __55 } goto __3 @@ -82952,7 +82295,7 @@ __56: goto __58 } pTab = (*AggInfo_col)(unsafe.Pointer(pCol)).FpTab - Xsqlite3VdbeAddOp3(tls, v, 89, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab, + Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab, int32((*AggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn), target) if !(int32((*AggInfo_col)(unsafe.Pointer(pCol)).FiColumn) < 0) { goto __59 @@ -82961,10 +82304,10 @@ __56: goto __60 __59: ; - if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*AggInfo_col)(unsafe.Pointer(pCol)).FiColumn)*32)).Faffinity) == 0x45) { + if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*AggInfo_col)(unsafe.Pointer(pCol)).FiColumn)*32)).Faffinity) == SQLITE_AFF_REAL) { goto __61 } - Xsqlite3VdbeAddOp1(tls, v, 83, target) + Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, target) __61: ; __60: @@ -82974,12 +82317,10 @@ __58: ; __57: ; - // Otherwise, fall thru into the TK_COLUMN case - /* no break */ __5: iTab = (*Expr)(unsafe.Pointer(pExpr)).FiTable - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000008))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FixedCol)) != U32(0)) { goto __62 } iReg = Xsqlite3ExprCodeTarget(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, target) @@ -82992,11 +82333,11 @@ __63: aff = int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) __64: ; - if !(aff > 0x41) { + if !(aff > SQLITE_AFF_BLOB) { goto __65 } - Xsqlite3VdbeAddOp4(tls, v, 90, iReg, 1, 0, + Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, iReg, 1, 0, (uintptr(unsafe.Pointer(&zAff)) + uintptr(((aff - 'B') * 2))), -1) __65: ; @@ -83021,10 +82362,10 @@ __69: pCol1 = ((*Table)(unsafe.Pointer(pTab1)).FaCol + uintptr(iCol)*32) iSrc = (int32(Xsqlite3TableColumnToStorage(tls, pTab1, int16(iCol))) - (*Parse)(unsafe.Pointer(pParse)).FiSelfTab) - if !((int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags) & 0x0060) != 0) { + if !((int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags) & COLFLAG_GENERATED) != 0) { goto __70 } - if !((int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags) & 0x0100) != 0) { + if !((int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags) & COLFLAG_BUSY) != 0) { goto __72 } Xsqlite3ErrorMsg(tls, pParse, ts+6768, /* "generated column..." */ @@ -83032,22 +82373,22 @@ __69: return 0 __72: ; - *(*U16)(unsafe.Pointer(pCol1 + 28 /* &.colFlags */)) |= U16((0x0100)) - if !((int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags) & 0x0080) != 0) { + *(*U16)(unsafe.Pointer(pCol1 + 28 /* &.colFlags */)) |= U16((COLFLAG_BUSY)) + if !((int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags) & COLFLAG_NOTAVAIL) != 0) { goto __73 } Xsqlite3ExprCodeGeneratedColumn(tls, pParse, pCol1, iSrc) __73: ; - *(*U16)(unsafe.Pointer(pCol1 + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((^libc.Int32((0x0100 | 0x0080)))) + *(*U16)(unsafe.Pointer(pCol1 + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((libc.CplInt32((COLFLAG_BUSY | COLFLAG_NOTAVAIL)))) return iSrc goto __71 __70: - if !(int32((*Column)(unsafe.Pointer(pCol1)).Faffinity) == 0x45) { + if !(int32((*Column)(unsafe.Pointer(pCol1)).Faffinity) == SQLITE_AFF_REAL) { goto __74 } - Xsqlite3VdbeAddOp2(tls, v, 78, iSrc, target) - Xsqlite3VdbeAddOp1(tls, v, 83, target) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, iSrc, target) + Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, target) return target goto __75 __74: @@ -83068,10 +82409,10 @@ __66: iReg = Xsqlite3ExprCodeGetColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)), int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn), iTab, target, (*Expr)(unsafe.Pointer(pExpr)).Fop2) - if !((*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) == uintptr(0)) && (int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == 0x45)) { + if !((*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) == uintptr(0)) && (int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == SQLITE_AFF_REAL)) { goto __76 } - Xsqlite3VdbeAddOp1(tls, v, 83, iReg) + Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, iReg) __76: ; return iReg @@ -83081,7 +82422,7 @@ __6: return target __7: - Xsqlite3VdbeAddOp2(tls, v, 69, Xsqlite3ExprTruthValue(tls, pExpr), target) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, Xsqlite3ExprTruthValue(tls, pExpr), target) return target __8: @@ -83100,29 +82441,29 @@ __10: // sanely and not crash. But keep the assert() to bring the problem // to the attention of the developers. ; - Xsqlite3VdbeAddOp2(tls, v, 72, 0, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target) return target __11: ; - z = (*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + uintptr(2)) + z = (*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + 2) n = (Xsqlite3Strlen30(tls, z) - 1) zBlob = Xsqlite3HexToBlob(tls, Xsqlite3VdbeDb(tls, v), z, n) - Xsqlite3VdbeAddOp4(tls, v, 74, (n / 2), target, 0, zBlob, -7) + Xsqlite3VdbeAddOp4(tls, v, OP_Blob, (n / 2), target, 0, zBlob, -7) return target __12: ; - Xsqlite3VdbeAddOp2(tls, v, 75, int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn), target) - if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + uintptr(1)))) != 0) { + Xsqlite3VdbeAddOp2(tls, v, OP_Variable, int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn), target) + if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + 1))) != 0) { goto __77 } z1 = Xsqlite3VListNumToName(tls, (*Parse)(unsafe.Pointer(pParse)).FpVList, int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)) - *(*VList)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).FpVList + uintptr(0)*4)) = 0 // Indicate VList may no longer be enlarged + *(*VList)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).FpVList)) = 0 // Indicate VList may no longer be enlarged Xsqlite3VdbeAppendP4(tls, v, z1, -1) __77: ; @@ -83137,22 +82478,22 @@ __14: if !(inReg != target) { goto __78 } - Xsqlite3VdbeAddOp2(tls, v, 78, inReg, target) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, inReg, target) inReg = target __78: ; - Xsqlite3VdbeAddOp2(tls, v, 84, target, + Xsqlite3VdbeAddOp2(tls, v, OP_Cast, target, int32(Xsqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), uintptr(0)))) return inReg __15: __16: - if op == 45 { - op = 53 + if op == TK_IS { + op = TK_EQ } else { - op = 52 + op = TK_NE } - p5 = 0x80 + p5 = SQLITE_NULLEQ // fall-through __17: __18: @@ -83170,8 +82511,8 @@ __79: r1 = Xsqlite3ExprCodeTemp(tls, pParse, pLeft, bp+40 /* ®Free1 */) r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+44 /* ®Free2 */) codeCompare(tls, pParse, pLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight, op, - r1, r2, inReg, (0x20 | p5), - (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000200))) != U32(0)))) + r1, r2, inReg, (SQLITE_STOREP2 | p5), + (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Commuted)) != U32(0)))) __80: ; @@ -83200,14 +82541,14 @@ __34: __35: pLeft1 = (*Expr)(unsafe.Pointer(pExpr)).FpLeft - if !(int32((*Expr)(unsafe.Pointer(pLeft1)).Fop) == 152) { + if !(int32((*Expr)(unsafe.Pointer(pLeft1)).Fop) == TK_INTEGER) { goto __81 } codeInteger(tls, pParse, pLeft1, 1, target) return target goto __82 __81: - if !(int32((*Expr)(unsafe.Pointer(pLeft1)).Fop) == 150) { + if !(int32((*Expr)(unsafe.Pointer(pLeft1)).Fop) == TK_FLOAT) { goto __83 } @@ -83215,13 +82556,13 @@ __81: return target goto __84 __83: - (*Expr)(unsafe.Pointer(bp + 48 /* &tempX */)).Fop = U8(152) - (*Expr)(unsafe.Pointer(bp + 48 /* &tempX */)).Fflags = (U32(0x000400 | 0x004000)) + (*Expr)(unsafe.Pointer(bp + 48 /* &tempX */)).Fop = TK_INTEGER + (*Expr)(unsafe.Pointer(bp + 48 /* &tempX */)).Fflags = (U32(EP_IntValue | EP_TokenOnly)) *(*int32)(unsafe.Pointer(bp + 48 /* &tempX */ + 8 /* &.u */)) = 0 r1 = Xsqlite3ExprCodeTemp(tls, pParse, bp+48 /* &tempX */, bp+40 /* ®Free1 */) r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp+44 /* ®Free2 */) - Xsqlite3VdbeAddOp3(tls, v, 106, r2, r1, target) + Xsqlite3VdbeAddOp3(tls, v, OP_Subtract, r2, r1, target) __84: ; @@ -83242,21 +82583,21 @@ __38: // IS TRUE or IS FALSE r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp+40 /* ®Free1 */) isTrue = Xsqlite3ExprTruthValue(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) - bNormal = (libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == 45)) + bNormal = (libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == TK_IS)) - Xsqlite3VdbeAddOp4Int(tls, v, 87, r1, inReg, libc.BoolInt32(!(isTrue != 0)), (isTrue ^ bNormal)) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IsTrue, r1, inReg, libc.BoolInt32(!(isTrue != 0)), (isTrue ^ bNormal)) goto __3 __39: __40: ; - Xsqlite3VdbeAddOp2(tls, v, 69, 1, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, target) r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp+40 /* ®Free1 */) addr = Xsqlite3VdbeAddOp1(tls, v, op, r1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, target) Xsqlite3VdbeJumpHere(tls, v, addr) goto __3 @@ -83282,7 +82623,7 @@ __42: // The function name enc = (*Sqlite3)(unsafe.Pointer(db)).Fenc // The text encoding used by this database pColl = uintptr(0) // A collating sequence - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) { goto __87 } return (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FregResult @@ -83314,7 +82655,7 @@ __88: goto __3 __89: ; - if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x00400000)) != 0) { + if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_INLINE) != 0) { goto __90 } @@ -83322,7 +82663,7 @@ __89: int32((*FuncDef)(unsafe.Pointer(pDef)).FpUserData), target) goto __91 __90: - if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(0x00080000 | 0x00200000))) != 0) { + if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(SQLITE_FUNC_DIRECT | SQLITE_FUNC_UNSAFE))) != 0) { goto __92 } Xsqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef) @@ -83343,7 +82684,7 @@ __93: constMask = constMask | (uint32((uint32(1))) << (i)) __96: ; - if !((((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0020)) != U32(0)) && !(pColl != 0)) { + if !((((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != U32(0)) && !(pColl != 0)) { goto __97 } pColl = Xsqlite3ExprCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(i)*32)).FpExpr) @@ -83374,23 +82715,23 @@ __101: // set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG // or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data // loading. - if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(0x0040 | 0x0080))) != U32(0)) { + if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(SQLITE_FUNC_LENGTH | SQLITE_FUNC_TYPEOF))) != U32(0)) { goto __102 } - exprOp = (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */) + uintptr(0)*32)).FpExpr)).Fop - if !((int32(exprOp) == 164) || (int32(exprOp) == 166)) { + exprOp = (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */))).FpExpr)).Fop + if !((int32(exprOp) == TK_COLUMN) || (int32(exprOp) == TK_AGG_COLUMN)) { goto __103 } - (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */) + uintptr(0)*32)).FpExpr)).Fop2 = (U8((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(0x40 | 0x80)))) + (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */))).FpExpr)).Fop2 = (U8((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(OPFLAG_LENGTHARG | OPFLAG_TYPEOFARG)))) __103: ; __102: ; Xsqlite3ExprCodeExprList(tls, pParse, pFarg, r1, 0, - (uint8(0x01 | 0x02))) + (uint8(SQLITE_ECEL_DUP | SQLITE_ECEL_FACTOR))) goto __99 __98: r1 = 0 @@ -83407,21 +82748,21 @@ __99: // function. The expression "A glob B" is equivalent to // "glob(B,A). We want to use the A in "A glob B" to test // for function overloading. But we use the B term in "glob(B,A)". - if !((nFarg >= 2) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000080))) != U32(0))) { + if !((nFarg >= 2) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_InfixFunc)) != U32(0))) { goto __104 } - pDef = Xsqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(1)*32)).FpExpr) + pDef = Xsqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+1*32)).FpExpr) goto __105 __104: if !(nFarg > 0) { goto __106 } - pDef = Xsqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(0)*32)).FpExpr) + pDef = Xsqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */))).FpExpr) __106: ; __105: ; - if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0020)) != 0) { + if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != 0) { goto __107 } if !(!(pColl != 0)) { @@ -83430,20 +82771,20 @@ __105: pColl = (*Sqlite3)(unsafe.Pointer(db)).FpDfltColl __108: ; - Xsqlite3VdbeAddOp4(tls, v, 81, 0, 0, 0, pColl, -2) + Xsqlite3VdbeAddOp4(tls, v, OP_CollSeq, 0, 0, 0, pColl, -2) __107: ; - if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x8000)) != 0) { + if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_OFFSET) != 0) { goto __109 } - pArg = (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */) + uintptr(0)*32)).FpExpr - if !(int32((*Expr)(unsafe.Pointer(pArg)).Fop) == 164) { + pArg = (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */))).FpExpr + if !(int32((*Expr)(unsafe.Pointer(pArg)).Fop) == TK_COLUMN) { goto __111 } - Xsqlite3VdbeAddOp3(tls, v, 88, (*Expr)(unsafe.Pointer(pArg)).FiTable, int32((*Expr)(unsafe.Pointer(pArg)).FiColumn), target) + Xsqlite3VdbeAddOp3(tls, v, OP_Offset, (*Expr)(unsafe.Pointer(pArg)).FiTable, int32((*Expr)(unsafe.Pointer(pArg)).FiColumn), target) goto __112 __111: - Xsqlite3VdbeAddOp2(tls, v, 72, 0, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target) __112: ; goto __110 @@ -83479,7 +82820,7 @@ __44: return 0 goto __117 __116: - if !((op == 136) && ((libc.AssignInt32(&nCol, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList)).FnExpr)) != 1)) { + if !((op == TK_SELECT) && ((libc.AssignInt32(&nCol, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList)).FnExpr)) != 1)) { goto __118 } Xsqlite3SubselectError(tls, pParse, nCol, 1) @@ -83513,11 +82854,11 @@ __121: __46: destIfFalse = Xsqlite3VdbeMakeLabel(tls, pParse) destIfNull = Xsqlite3VdbeMakeLabel(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target) sqlite3ExprCodeIN(tls, pParse, pExpr, destIfFalse, destIfNull) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, target) Xsqlite3VdbeResolveLabel(tls, v, destIfFalse) - Xsqlite3VdbeAddOp2(tls, v, 82, target, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, target, 0) Xsqlite3VdbeResolveLabel(tls, v, destIfNull) return target @@ -83570,17 +82911,17 @@ __51: p1 = ((((*Expr)(unsafe.Pointer(pExpr)).FiTable * (int32((*Table)(unsafe.Pointer(pTab2)).FnCol) + 1)) + 1) + int32(Xsqlite3TableColumnToStorage(tls, pTab2, int16(iCol1)))) - Xsqlite3VdbeAddOp2(tls, v, 148, p1, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Param, p1, target) // If the column has REAL affinity, it may currently be stored as an // integer. Use OP_RealAffinity to make sure it is really real. // // EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to // floating point when extracting it from the record. - if !((iCol1 >= 0) && (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab2)).FaCol+uintptr(iCol1)*32)).Faffinity) == 0x45)) { + if !((iCol1 >= 0) && (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab2)).FaCol+uintptr(iCol1)*32)).Faffinity) == SQLITE_AFF_REAL)) { goto __122 } - Xsqlite3VdbeAddOp1(tls, v, 83, target) + Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, target) __122: ; goto __3 @@ -83596,7 +82937,7 @@ __52: // on a LEFT JOIN NULL row. __53: okConstFactor = (*Parse)(unsafe.Pointer(pParse)).FokConstFactor - addrINR = Xsqlite3VdbeAddOp1(tls, v, 21, (*Expr)(unsafe.Pointer(pExpr)).FiTable) + addrINR = Xsqlite3VdbeAddOp1(tls, v, OP_IfNullRow, (*Expr)(unsafe.Pointer(pExpr)).FiTable) // Temporarily disable factoring of constant expressions, since // even though expressions may appear to be constant, they are not // really constant because they originate from the right-hand side @@ -83651,7 +82992,7 @@ __124: exprToRegister(tls, pDel, exprCodeVector(tls, pParse, pDel, bp+40 /* ®Free1 */)) libc.Xmemset(tls, bp+120 /* &opCompare */, 0, uint64(unsafe.Sizeof(Expr{}))) - (*Expr)(unsafe.Pointer(bp + 120 /* &opCompare */)).Fop = U8(53) + (*Expr)(unsafe.Pointer(bp + 120 /* &opCompare */)).Fop = TK_EQ (*Expr)(unsafe.Pointer(bp + 120 /* &opCompare */)).FpLeft = pDel pTest = bp + 120 /* &opCompare */ // Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001: @@ -83678,7 +83019,7 @@ __129: ; nextCase = Xsqlite3VdbeMakeLabel(tls, pParse) - Xsqlite3ExprIfFalse(tls, pParse, pTest, nextCase, 0x10) + Xsqlite3ExprIfFalse(tls, pParse, pTest, nextCase, SQLITE_JUMPIFNULL) Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(aListelem+uintptr((i1+1))*32)).FpExpr, target) Xsqlite3VdbeGoto(tls, v, endLabel) @@ -83696,7 +83037,7 @@ __127: Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr((nExpr-1))*32)).FpExpr, target) goto __131 __130: - Xsqlite3VdbeAddOp2(tls, v, 72, 0, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target) __131: ; Xsqlite3ExprDelete(tls, db1, pDel) @@ -83714,27 +83055,27 @@ __55: return 0 __132: ; - if !(int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == 2) { + if !(int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == OE_Abort) { goto __133 } Xsqlite3MayAbort(tls, pParse) __133: ; - if !(int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == 4) { + if !(int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == OE_Ignore) { goto __134 } Xsqlite3VdbeAddOp4(tls, - v, 68, 0, 4, 0, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), 0) + v, OP_Halt, SQLITE_OK, OE_Ignore, 0, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), 0) goto __135 __134: Xsqlite3HaltConstraint(tls, pParse, func() int32 { if (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab != 0 { - return (19 | (int32(7) << 8)) + return (SQLITE_CONSTRAINT | (int32(7) << 8)) } - return 1 + return SQLITE_ERROR }(), int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr), *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), int8(0), uint8(0)) __135: @@ -83794,11 +83135,11 @@ func Xsqlite3ExprCodeRunJustOnce(tls *libc.TLS, pParse uintptr, pExpr uintptr, r __3: } pExpr = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0) - if (pExpr != uintptr(0)) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000004))) != U32(0)) { + if (pExpr != uintptr(0)) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_HasFunc)) != U32(0)) { var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe var addr int32 - addr = Xsqlite3VdbeAddOp0(tls, v, 17) + addr = Xsqlite3VdbeAddOp0(tls, v, OP_Once) (*Parse)(unsafe.Pointer(pParse)).FokConstFactor = U8(0) if !(int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed) != 0) { if regDest < 0 { @@ -83839,7 +83180,7 @@ func Xsqlite3ExprCodeTemp(tls *libc.TLS, pParse uintptr, pExpr uintptr, pReg uin var r2 int32 pExpr = Xsqlite3ExprSkipCollateAndLikely(tls, pExpr) if (((*Parse)(unsafe.Pointer(pParse)).FokConstFactor != 0) && - (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 173)) && + (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_REGISTER)) && (Xsqlite3ExprIsConstantNotJoin(tls, pExpr) != 0) { *(*int32)(unsafe.Pointer(pReg)) = 0 r2 = Xsqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, -1) @@ -83868,10 +83209,10 @@ func Xsqlite3ExprCode(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32 inReg = Xsqlite3ExprCodeTarget(tls, pParse, pExpr, target) if inReg != target { var op U8 - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x200000))) != U32(0) { - op = U8(77) + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Subquery)) != U32(0) { + op = OP_Copy } else { - op = U8(78) + op = OP_SCopy } Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, int32(op), inReg, target) } @@ -83925,17 +83266,17 @@ func Xsqlite3ExprCodeExprList(tls *libc.TLS, pParse uintptr, pList uintptr, targ var j int32 var n int32 var copyOp U8 - if (int32(flags) & 0x01) != 0 { - copyOp = uint8(77) + if (int32(flags) & SQLITE_ECEL_DUP) != 0 { + copyOp = OP_Copy } else { - copyOp = uint8(78) + copyOp = OP_SCopy } var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe // Never gets this far otherwise n = (*ExprList)(unsafe.Pointer(pList)).FnExpr if !(int32((*Parse)(unsafe.Pointer(pParse)).FokConstFactor) != 0) { - flags = libc.Uint8FromInt32(int32(flags) & (^libc.Int32(0x02))) + flags = libc.Uint8FromInt32(int32(flags) & (libc.CplInt32(SQLITE_ECEL_FACTOR))) } pItem = pList + 8 /* &.a */ i = 0 @@ -83945,22 +83286,22 @@ __1: } { var pExpr uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr - if ((int32(flags) & 0x04) != 0) && ((libc.AssignInt32(&j, int32(*(*U16)(unsafe.Pointer(pItem + 24 /* &.u */ /* &.x */ /* &.iOrderByCol */))))) > 0) { - if (int32(flags) & 0x08) != 0 { + if ((int32(flags) & SQLITE_ECEL_REF) != 0) && ((libc.AssignInt32(&j, int32(*(*U16)(unsafe.Pointer(pItem + 24 /* &.u */ /* &.x */ /* &.iOrderByCol */))))) > 0) { + if (int32(flags) & SQLITE_ECEL_OMITREF) != 0 { i-- n-- } else { Xsqlite3VdbeAddOp2(tls, v, int32(copyOp), ((j + srcReg) - 1), (target + i)) } - } else if ((int32(flags) & 0x02) != 0) && + } else if ((int32(flags) & SQLITE_ECEL_FACTOR) != 0) && (Xsqlite3ExprIsConstantNotJoin(tls, pExpr) != 0) { Xsqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, (target + i)) } else { var inReg int32 = Xsqlite3ExprCodeTarget(tls, pParse, pExpr, (target + i)) if inReg != (target + i) { var pOp uintptr - if ((((int32(copyOp) == 77) && - (int32((*VdbeOp)(unsafe.Pointer((libc.AssignUintptr(&pOp, Xsqlite3VdbeGetOp(tls, v, -1))))).Fopcode) == 77)) && + if ((((int32(copyOp) == OP_Copy) && + (int32((*VdbeOp)(unsafe.Pointer((libc.AssignUintptr(&pOp, Xsqlite3VdbeGetOp(tls, v, -1))))).Fopcode) == OP_Copy)) && ((((*VdbeOp)(unsafe.Pointer(pOp)).Fp1 + (*VdbeOp)(unsafe.Pointer(pOp)).Fp3) + 1) == inReg)) && ((((*VdbeOp)(unsafe.Pointer(pOp)).Fp2 + (*VdbeOp)(unsafe.Pointer(pOp)).Fp3) + 1) == (target + i))) && (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5) == 0) { @@ -84021,15 +83362,15 @@ func exprCodeBetween(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, x pDel = Xsqlite3ExprDup(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, 0) if int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { - (*Expr)(unsafe.Pointer(bp + 144 /* &exprAnd */)).Fop = U8(44) + (*Expr)(unsafe.Pointer(bp + 144 /* &exprAnd */)).Fop = TK_AND (*Expr)(unsafe.Pointer(bp + 144 /* &exprAnd */)).FpLeft = bp /* &compLeft */ (*Expr)(unsafe.Pointer(bp + 144 /* &exprAnd */)).FpRight = bp + 72 /* &compRight */ - (*Expr)(unsafe.Pointer(bp /* &compLeft */)).Fop = U8(57) + (*Expr)(unsafe.Pointer(bp /* &compLeft */)).Fop = TK_GE (*Expr)(unsafe.Pointer(bp /* &compLeft */)).FpLeft = pDel - (*Expr)(unsafe.Pointer(bp /* &compLeft */)).FpRight = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + uintptr(0)*32)).FpExpr - (*Expr)(unsafe.Pointer(bp + 72 /* &compRight */)).Fop = U8(55) + (*Expr)(unsafe.Pointer(bp /* &compLeft */)).FpRight = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */))).FpExpr + (*Expr)(unsafe.Pointer(bp + 72 /* &compRight */)).Fop = TK_LE (*Expr)(unsafe.Pointer(bp + 72 /* &compRight */)).FpLeft = pDel - (*Expr)(unsafe.Pointer(bp + 72 /* &compRight */)).FpRight = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + uintptr(1)*32)).FpExpr + (*Expr)(unsafe.Pointer(bp + 72 /* &compRight */)).FpRight = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + 1*32)).FpExpr exprToRegister(tls, pDel, exprCodeVector(tls, pParse, pDel, bp+216 /* ®Free1 */)) if xJump != 0 { (*(*func(*libc.TLS, uintptr, uintptr, int32, int32))(unsafe.Pointer(&xJump)))(tls, pParse, bp+144 /* &exprAnd */, dest, jumpIfNull) @@ -84039,7 +83380,7 @@ func exprCodeBetween(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, x // it into the Parse.pConstExpr list. We should use a new bit for this, // for clarity, but we are out of bits in the Expr.flags field so we // have to reuse the EP_FromJoin bit. Bummer. - *(*U32)(unsafe.Pointer(pDel + 4 /* &.flags */)) |= (U32(0x000001)) + *(*U32)(unsafe.Pointer(pDel + 4 /* &.flags */)) |= (EP_FromJoin) Xsqlite3ExprCodeTarget(tls, pParse, bp+144 /* &exprAnd */, dest) } Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 216 /* regFree1 */))) @@ -84100,37 +83441,37 @@ __2: op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop) switch op { - case 44: + case TK_AND: goto __4 - case 43: + case TK_OR: goto __5 - case 19: + case TK_NOT: goto __6 - case 172: + case TK_TRUTH: goto __7 - case 45: + case TK_IS: goto __8 - case 168: + case TK_ISNOT: goto __9 - case 56: + case TK_LT: goto __10 - case 55: + case TK_LE: goto __11 - case 54: + case TK_GT: goto __12 - case 57: + case TK_GE: goto __13 - case 52: + case TK_NE: goto __14 - case 53: + case TK_EQ: goto __15 - case 50: + case TK_ISNULL: goto __16 - case 51: + case TK_NOTNULL: goto __17 - case 48: + case TK_BETWEEN: goto __18 - case 49: + case TK_IN: goto __19 default: goto __20 @@ -84145,13 +83486,13 @@ __5: Xsqlite3ExprIfTrue(tls, pParse, pAlt, dest, jumpIfNull) goto __22 __21: - if !(op == 44) { + if !(op == TK_AND) { goto __23 } d2 = Xsqlite3VdbeMakeLabel(tls, pParse) Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, d2, - (jumpIfNull ^ 0x10)) + (jumpIfNull ^ SQLITE_JUMPIFNULL)) Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, dest, jumpIfNull) Xsqlite3VdbeResolveLabel(tls, v, d2) goto __24 @@ -84172,7 +83513,7 @@ __6: __7: // IS TRUE or IS NOT TRUE ; - isNot = (libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == 168)) + isNot = (libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == TK_ISNOT)) isTrue = Xsqlite3ExprTruthValue(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) if !((isTrue ^ isNot) != 0) { @@ -84181,7 +83522,7 @@ __7: // IS TRUE or IS NOT TRUE Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, dest, func() int32 { if isNot != 0 { - return 0x10 + return SQLITE_JUMPIFNULL } return 0 }()) @@ -84190,7 +83531,7 @@ __25: Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, dest, func() int32 { if isNot != 0 { - return 0x10 + return SQLITE_JUMPIFNULL } return 0 }()) @@ -84202,13 +83543,12 @@ __8: __9: ; - if op == 45 { - op = 53 + if op == TK_IS { + op = TK_EQ } else { - op = 52 + op = TK_NE } - jumpIfNull = 0x80 - /* no break */ + jumpIfNull = SQLITE_NULLEQ __10: __11: __12: @@ -84225,7 +83565,7 @@ __27: r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp /* ®Free1 */) r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+4 /* ®Free2 */) codeCompare(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight, op, - r1, r2, dest, jumpIfNull, (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000200))) != U32(0)))) + r1, r2, dest, jumpIfNull, (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Commuted)) != U32(0)))) goto __3 @@ -84259,20 +83599,20 @@ __19: __20: default_expr: - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001 | 0x10000000))) == U32(0x10000000)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_FromJoin | EP_IsTrue))) == EP_IsTrue) { goto __28 } Xsqlite3VdbeGoto(tls, v, dest) goto __29 __28: - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001 | 0x20000000))) == U32(0x20000000)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_FromJoin | EP_IsFalse))) == EP_IsFalse) { goto __30 } // No-op goto __31 __30: r1 = Xsqlite3ExprCodeTemp(tls, pParse, pExpr, bp /* ®Free1 */) - Xsqlite3VdbeAddOp3(tls, v, 18, r1, dest, (libc.Bool32(jumpIfNull != 0))) + Xsqlite3VdbeAddOp3(tls, v, OP_If, r1, dest, (libc.Bool32(jumpIfNull != 0))) __31: ; @@ -84345,42 +83685,42 @@ __2: // The value of TK_ and OP_ constants are arranged such that we // can compute the mapping above using the following expression. // Assert()s verify that the computation is correct. - op = (((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) + (50 & 1)) ^ 1) - (50 & 1)) + op = (((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) + (TK_ISNULL & 1)) ^ 1) - (TK_ISNULL & 1)) // Verify correct alignment of TK_ and OP_ constants switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) { - case 44: + case TK_AND: goto __4 - case 43: + case TK_OR: goto __5 - case 19: + case TK_NOT: goto __6 - case 172: + case TK_TRUTH: goto __7 - case 45: + case TK_IS: goto __8 - case 168: + case TK_ISNOT: goto __9 - case 56: + case TK_LT: goto __10 - case 55: + case TK_LE: goto __11 - case 54: + case TK_GT: goto __12 - case 57: + case TK_GE: goto __13 - case 52: + case TK_NE: goto __14 - case 53: + case TK_EQ: goto __15 - case 50: + case TK_ISNULL: goto __16 - case 51: + case TK_NOTNULL: goto __17 - case 48: + case TK_BETWEEN: goto __18 - case 49: + case TK_IN: goto __19 default: goto __20 @@ -84395,7 +83735,7 @@ __5: Xsqlite3ExprIfFalse(tls, pParse, pAlt, dest, jumpIfNull) goto __22 __21: - if !(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 44) { + if !(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND) { goto __23 } @@ -84406,7 +83746,7 @@ __23: d2 = Xsqlite3VdbeMakeLabel(tls, pParse) Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, d2, - (jumpIfNull ^ 0x10)) + (jumpIfNull ^ SQLITE_JUMPIFNULL)) Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, dest, jumpIfNull) Xsqlite3VdbeResolveLabel(tls, v, d2) __24: @@ -84422,7 +83762,7 @@ __6: __7: // IS TRUE or IS NOT TRUE ; - isNot = (libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == 168)) + isNot = (libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == TK_ISNOT)) isTrue = Xsqlite3ExprTruthValue(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) if !((isTrue ^ isNot) != 0) { @@ -84434,7 +83774,7 @@ __7: // IS TRUE or IS NOT TRUE if isNot != 0 { return 0 } - return 0x10 + return SQLITE_JUMPIFNULL }()) goto __26 @@ -84445,7 +83785,7 @@ __25: if isNot != 0 { return 0 } - return 0x10 + return SQLITE_JUMPIFNULL }()) __26: ; @@ -84455,13 +83795,12 @@ __8: __9: ; - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 45 { - op = 52 + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IS { + op = TK_NE } else { - op = 53 + op = TK_EQ } - jumpIfNull = 0x80 - /* no break */ + jumpIfNull = SQLITE_NULLEQ __10: __11: __12: @@ -84478,7 +83817,7 @@ __27: r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp /* ®Free1 */) r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+4 /* ®Free2 */) codeCompare(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight, op, - r1, r2, dest, jumpIfNull, (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000200))) != U32(0)))) + r1, r2, dest, jumpIfNull, (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Commuted)) != U32(0)))) goto __3 @@ -84512,20 +83851,20 @@ __29: __20: default_expr: - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001 | 0x20000000))) == U32(0x20000000)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_FromJoin | EP_IsFalse))) == EP_IsFalse) { goto __30 } Xsqlite3VdbeGoto(tls, v, dest) goto __31 __30: - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001 | 0x10000000))) == U32(0x10000000)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_FromJoin | EP_IsTrue))) == EP_IsTrue) { goto __32 } // no-op goto __33 __32: r1 = Xsqlite3ExprCodeTemp(tls, pParse, pExpr, bp /* ®Free1 */) - Xsqlite3VdbeAddOp3(tls, v, 20, r1, dest, (libc.Bool32(jumpIfNull != 0))) + Xsqlite3VdbeAddOp3(tls, v, OP_IfNot, r1, dest, (libc.Bool32(jumpIfNull != 0))) __33: ; @@ -84571,13 +83910,13 @@ func exprCompareVariable(tls *libc.TLS, pParse uintptr, pVar uintptr, pExpr uint var pL uintptr *(*uintptr)(unsafe.Pointer(bp /* pR */)) = uintptr(0) - Xsqlite3ValueFromExpr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, uint8(1), uint8(0x41), bp /* &pR */) + Xsqlite3ValueFromExpr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, bp /* &pR */) if *(*uintptr)(unsafe.Pointer(bp /* pR */)) != 0 { iVar = int32((*Expr)(unsafe.Pointer(pVar)).FiColumn) Xsqlite3VdbeSetVarmask(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, iVar) - pL = Xsqlite3VdbeGetBoundValue(tls, (*Parse)(unsafe.Pointer(pParse)).FpReprepare, iVar, uint8(0x41)) + pL = Xsqlite3VdbeGetBoundValue(tls, (*Parse)(unsafe.Pointer(pParse)).FpReprepare, iVar, SQLITE_AFF_BLOB) if pL != 0 { - if Xsqlite3_value_type(tls, pL) == 3 { + if Xsqlite3_value_type(tls, pL) == SQLITE_TEXT { Xsqlite3_value_text(tls, pL) // Make sure the encoding is UTF-8 } res = (libc.Bool32(0 == Xsqlite3MemCompare(tls, pL, *(*uintptr)(unsafe.Pointer(bp /* pR */)), uintptr(0)))) @@ -84624,42 +83963,42 @@ func Xsqlite3ExprCompare(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, } return 2 } - if ((pParse != 0) && (int32((*Expr)(unsafe.Pointer(pA)).Fop) == 153)) && (exprCompareVariable(tls, pParse, pA, pB) != 0) { + if ((pParse != 0) && (int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_VARIABLE)) && (exprCompareVariable(tls, pParse, pA, pB) != 0) { return 0 } combinedFlags = ((*Expr)(unsafe.Pointer(pA)).Fflags | (*Expr)(unsafe.Pointer(pB)).Fflags) - if (combinedFlags & U32(0x000400)) != 0 { - if ((((*Expr)(unsafe.Pointer(pA)).Fflags & (*Expr)(unsafe.Pointer(pB)).Fflags) & U32(0x000400)) != U32(0)) && (*(*int32)(unsafe.Pointer(pA + 8 /* &.u */)) == *(*int32)(unsafe.Pointer(pB + 8 /* &.u */))) { + if (combinedFlags & EP_IntValue) != 0 { + if ((((*Expr)(unsafe.Pointer(pA)).Fflags & (*Expr)(unsafe.Pointer(pB)).Fflags) & EP_IntValue) != U32(0)) && (*(*int32)(unsafe.Pointer(pA + 8 /* &.u */)) == *(*int32)(unsafe.Pointer(pB + 8 /* &.u */))) { return 0 } return 2 } - if (int32((*Expr)(unsafe.Pointer(pA)).Fop) != int32((*Expr)(unsafe.Pointer(pB)).Fop)) || (int32((*Expr)(unsafe.Pointer(pA)).Fop) == 71) { - if (int32((*Expr)(unsafe.Pointer(pA)).Fop) == 111) && (Xsqlite3ExprCompare(tls, pParse, (*Expr)(unsafe.Pointer(pA)).FpLeft, pB, iTab) < 2) { + if (int32((*Expr)(unsafe.Pointer(pA)).Fop) != int32((*Expr)(unsafe.Pointer(pB)).Fop)) || (int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_RAISE) { + if (int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_COLLATE) && (Xsqlite3ExprCompare(tls, pParse, (*Expr)(unsafe.Pointer(pA)).FpLeft, pB, iTab) < 2) { return 1 } - if (int32((*Expr)(unsafe.Pointer(pB)).Fop) == 111) && (Xsqlite3ExprCompare(tls, pParse, pA, (*Expr)(unsafe.Pointer(pB)).FpLeft, iTab) < 2) { + if (int32((*Expr)(unsafe.Pointer(pB)).Fop) == TK_COLLATE) && (Xsqlite3ExprCompare(tls, pParse, pA, (*Expr)(unsafe.Pointer(pB)).FpLeft, iTab) < 2) { return 1 } return 2 } - if ((int32((*Expr)(unsafe.Pointer(pA)).Fop) != 164) && (int32((*Expr)(unsafe.Pointer(pA)).Fop) != 166)) && (*(*uintptr)(unsafe.Pointer(pA + 8 /* &.u */)) != 0) { - if (int32((*Expr)(unsafe.Pointer(pA)).Fop) == 169) || (int32((*Expr)(unsafe.Pointer(pA)).Fop) == 165) { + if ((int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_COLUMN) && (int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_AGG_COLUMN)) && (*(*uintptr)(unsafe.Pointer(pA + 8 /* &.u */)) != 0) { + if (int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_FUNCTION) || (int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_AGG_FUNCTION) { if Xsqlite3StrICmp(tls, *(*uintptr)(unsafe.Pointer(pA + 8 /* &.u */)), *(*uintptr)(unsafe.Pointer(pB + 8 /* &.u */))) != 0 { return 2 } - if (libc.Bool32(((*Expr)(unsafe.Pointer((pA))).Fflags & (U32(0x1000000))) != U32(0))) != (libc.Bool32(((*Expr)(unsafe.Pointer((pB))).Fflags & (U32(0x1000000))) != U32(0))) { + if (libc.Bool32(((*Expr)(unsafe.Pointer((pA))).Fflags & (EP_WinFunc)) != U32(0))) != (libc.Bool32(((*Expr)(unsafe.Pointer((pB))).Fflags & (EP_WinFunc)) != U32(0))) { return 2 } - if ((*Expr)(unsafe.Pointer((pA))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pA))).Fflags & (EP_WinFunc)) != U32(0) { if Xsqlite3WindowCompare(tls, pParse, *(*uintptr)(unsafe.Pointer(pA + 64 /* &.y */)), *(*uintptr)(unsafe.Pointer(pB + 64 /* &.y */)), 1) != 0 { return 2 } } - } else if int32((*Expr)(unsafe.Pointer(pA)).Fop) == 119 { + } else if int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_NULL { return 0 - } else if int32((*Expr)(unsafe.Pointer(pA)).Fop) == 111 { + } else if int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_COLLATE { if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(pA + 8 /* &.u */)), *(*uintptr)(unsafe.Pointer(pB + 8 /* &.u */))) != 0 { return 2 } @@ -84667,15 +84006,15 @@ func Xsqlite3ExprCompare(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, return 2 } } - if ((*Expr)(unsafe.Pointer(pA)).Fflags & (U32(0x000002 | 0x000200))) != - ((*Expr)(unsafe.Pointer(pB)).Fflags & (U32(0x000002 | 0x000200))) { + if ((*Expr)(unsafe.Pointer(pA)).Fflags & (U32(EP_Distinct | EP_Commuted))) != + ((*Expr)(unsafe.Pointer(pB)).Fflags & (U32(EP_Distinct | EP_Commuted))) { return 2 } - if (combinedFlags & U32(0x004000)) == U32(0) { - if (combinedFlags & U32(0x000800)) != 0 { + if (combinedFlags & EP_TokenOnly) == U32(0) { + if (combinedFlags & EP_xIsSelect) != 0 { return 2 } - if ((combinedFlags & U32(0x000008)) == U32(0)) && + if ((combinedFlags & EP_FixedCol) == U32(0)) && (Xsqlite3ExprCompare(tls, pParse, (*Expr)(unsafe.Pointer(pA)).FpLeft, (*Expr)(unsafe.Pointer(pB)).FpLeft, iTab) != 0) { return 2 } @@ -84685,16 +84024,16 @@ func Xsqlite3ExprCompare(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, if Xsqlite3ExprListCompare(tls, *(*uintptr)(unsafe.Pointer(pA + 32 /* &.x */)), *(*uintptr)(unsafe.Pointer(pB + 32 /* &.x */)), iTab) != 0 { return 2 } - if ((int32((*Expr)(unsafe.Pointer(pA)).Fop) != 115) && - (int32((*Expr)(unsafe.Pointer(pA)).Fop) != 167)) && - ((combinedFlags & U32(0x002000)) == U32(0)) { + if ((int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_STRING) && + (int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_TRUEFALSE)) && + ((combinedFlags & EP_Reduced) == U32(0)) { if int32((*Expr)(unsafe.Pointer(pA)).FiColumn) != int32((*Expr)(unsafe.Pointer(pB)).FiColumn) { return 2 } - if (int32((*Expr)(unsafe.Pointer(pA)).Fop2) != int32((*Expr)(unsafe.Pointer(pB)).Fop2)) && (int32((*Expr)(unsafe.Pointer(pA)).Fop) == 172) { + if (int32((*Expr)(unsafe.Pointer(pA)).Fop2) != int32((*Expr)(unsafe.Pointer(pB)).Fop2)) && (int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_TRUTH) { return 2 } - if ((int32((*Expr)(unsafe.Pointer(pA)).Fop) != 49) && ((*Expr)(unsafe.Pointer(pA)).FiTable != (*Expr)(unsafe.Pointer(pB)).FiTable)) && ((*Expr)(unsafe.Pointer(pA)).FiTable != iTab) { + if ((int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_IN) && ((*Expr)(unsafe.Pointer(pA)).FiTable != (*Expr)(unsafe.Pointer(pB)).FiTable)) && ((*Expr)(unsafe.Pointer(pA)).FiTable != iTab) { return 2 } } @@ -84757,98 +84096,96 @@ func Xsqlite3ExprCompareSkip(tls *libc.TLS, pA uintptr, pB uintptr, iTab int32) func exprImpliesNotNull(tls *libc.TLS, pParse uintptr, p uintptr, pNN uintptr, iTab int32, seenNot int32) int32 { /* sqlite3.c:105063:12: */ if Xsqlite3ExprCompare(tls, pParse, p, pNN, iTab) == 0 { - return (libc.Bool32(int32((*Expr)(unsafe.Pointer(pNN)).Fop) != 119)) + return (libc.Bool32(int32((*Expr)(unsafe.Pointer(pNN)).Fop) != TK_NULL)) } switch int32((*Expr)(unsafe.Pointer(p)).Fop) { - case 49: + case TK_IN: { - if (seenNot != 0) && (((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000800))) != U32(0)) { + if (seenNot != 0) && (((*Expr)(unsafe.Pointer((p))).Fflags & (EP_xIsSelect)) != U32(0)) { return 0 } return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, 1) } - case 48: + case TK_BETWEEN: { var pList uintptr = *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) if seenNot != 0 { return 0 } - if (exprImpliesNotNull(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(0)*32)).FpExpr, pNN, iTab, 1) != 0) || - (exprImpliesNotNull(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(1)*32)).FpExpr, pNN, iTab, 1) != 0) { + if (exprImpliesNotNull(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */))).FpExpr, pNN, iTab, 1) != 0) || + (exprImpliesNotNull(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+1*32)).FpExpr, pNN, iTab, 1) != 0) { return 1 } return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, 1) } - case 53: + case TK_EQ: fallthrough - case 52: + case TK_NE: fallthrough - case 56: + case TK_LT: fallthrough - case 55: + case TK_LE: fallthrough - case 54: + case TK_GT: fallthrough - case 57: + case TK_GE: fallthrough - case 105: + case TK_PLUS: fallthrough - case 106: + case TK_MINUS: fallthrough - case 102: + case TK_BITOR: fallthrough - case 103: + case TK_LSHIFT: fallthrough - case 104: + case TK_RSHIFT: fallthrough - case 110: + case TK_CONCAT: seenNot = 1 - /* no break */ fallthrough - case 107: + case TK_STAR: fallthrough - case 109: + case TK_REM: fallthrough - case 101: + case TK_BITAND: fallthrough - case 108: + case TK_SLASH: { if exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpRight, pNN, iTab, seenNot) != 0 { return 1 } - /* no break */ } fallthrough - case 178: + case TK_SPAN: fallthrough - case 111: + case TK_COLLATE: fallthrough - case 171: + case TK_UPLUS: fallthrough - case 170: + case TK_UMINUS: { return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, seenNot) } - case 172: + case TK_TRUTH: { if seenNot != 0 { return 0 } - if int32((*Expr)(unsafe.Pointer(p)).Fop2) != 45 { + if int32((*Expr)(unsafe.Pointer(p)).Fop2) != TK_IS { return 0 } return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, 1) } - case 112: + case TK_BITNOT: fallthrough - case 19: + case TK_NOT: { return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, 1) @@ -84884,12 +84221,12 @@ func Xsqlite3ExprImpliesExpr(tls *libc.TLS, pParse uintptr, pE1 uintptr, pE2 uin if Xsqlite3ExprCompare(tls, pParse, pE1, pE2, iTab) == 0 { return 1 } - if (int32((*Expr)(unsafe.Pointer(pE2)).Fop) == 43) && + if (int32((*Expr)(unsafe.Pointer(pE2)).Fop) == TK_OR) && ((Xsqlite3ExprImpliesExpr(tls, pParse, pE1, (*Expr)(unsafe.Pointer(pE2)).FpLeft, iTab) != 0) || (Xsqlite3ExprImpliesExpr(tls, pParse, pE1, (*Expr)(unsafe.Pointer(pE2)).FpRight, iTab) != 0)) { return 1 } - if (int32((*Expr)(unsafe.Pointer(pE2)).Fop) == 51) && + if (int32((*Expr)(unsafe.Pointer(pE2)).Fop) == TK_NOTNULL) && (exprImpliesNotNull(tls, pParse, pE1, (*Expr)(unsafe.Pointer(pE2)).FpLeft, iTab, 0) != 0) { return 1 } @@ -84905,39 +84242,39 @@ func Xsqlite3ExprImpliesExpr(tls *libc.TLS, pParse uintptr, pE1 uintptr, pE2 uin // (never setting pWalker->eCode) is a harmless missed optimization. func impliesNotNullRow(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:105186:12: */ - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0) { - return 1 + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0) { + return WRC_Prune } switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) { - case 168: + case TK_ISNOT: fallthrough - case 50: + case TK_ISNULL: fallthrough - case 51: + case TK_NOTNULL: fallthrough - case 45: + case TK_IS: fallthrough - case 43: + case TK_OR: fallthrough - case 174: + case TK_VECTOR: fallthrough - case 154: + case TK_CASE: fallthrough - case 49: + case TK_IN: fallthrough - case 169: + case TK_FUNCTION: fallthrough - case 172: + case TK_TRUTH: - return 1 - case 164: + return WRC_Prune + case TK_COLUMN: if *(*int32)(unsafe.Pointer(pWalker + 40 /* &.u */)) == (*Expr)(unsafe.Pointer(pExpr)).FiTable { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(1) - return 2 + return WRC_Abort } - return 1 + return WRC_Prune - case 44: + case TK_AND: if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 0 { Xsqlite3WalkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) if (*Walker)(unsafe.Pointer(pWalker)).FeCode != 0 { @@ -84945,47 +84282,46 @@ func impliesNotNullRow(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* Xsqlite3WalkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpRight) } } - return 1 + return WRC_Prune - case 48: - if Xsqlite3WalkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) == 2 { + case TK_BETWEEN: + if Xsqlite3WalkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) == WRC_Abort { - return 2 + return WRC_Abort } - return 1 + return WRC_Prune // Virtual tables are allowed to use constraints like x=NULL. So // a term of the form x=y does not prove that y is not null if x // is the column of a virtual table - case 53: + case TK_EQ: fallthrough - case 52: + case TK_NE: fallthrough - case 56: + case TK_LT: fallthrough - case 55: + case TK_LE: fallthrough - case 54: + case TK_GT: fallthrough - case 57: + case TK_GE: { var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft var pRight uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpRight // The y.pTab=0 assignment in wherecode.c always happens after the // impliesNotNullRow() test - if (((int32((*Expr)(unsafe.Pointer(pLeft)).Fop) == 164) && (*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)) != uintptr(0))) && + if (((int32((*Expr)(unsafe.Pointer(pLeft)).Fop) == TK_COLUMN) && (*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)))).FnModuleArg != 0)) || - (((int32((*Expr)(unsafe.Pointer(pRight)).Fop) == 164) && (*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)) != uintptr(0))) && + (((int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_COLUMN) && (*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)))).FnModuleArg != 0)) { - return 1 + return WRC_Prune } - /* no break */ } fallthrough default: - return 0 + return WRC_Continue } return int32(0) } @@ -85020,10 +84356,10 @@ func Xsqlite3ExprImpliesNonNullRow(tls *libc.TLS, p uintptr, iTab int32) int32 { if p == uintptr(0) { return 0 } - if int32((*Expr)(unsafe.Pointer(p)).Fop) == 51 { + if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_NOTNULL { p = (*Expr)(unsafe.Pointer(p)).FpLeft } else { - for int32((*Expr)(unsafe.Pointer(p)).Fop) == 44 { + for int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_AND { if Xsqlite3ExprImpliesNonNullRow(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, iTab) != 0 { return 1 } @@ -85045,13 +84381,13 @@ func Xsqlite3ExprImpliesNonNullRow(tls *libc.TLS, p uintptr, iTab int32) int32 { // pWalker->u.pIdxCover->iCur can be satisfied using the index // pWalker->u.pIdxCover->pIdx. func exprIdxCover(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:105329:12: */ - if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) && + if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == (*IdxCover)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)))).FiCur)) && (int32(Xsqlite3TableColumnToIndex(tls, (*IdxCover)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)))).FpIdx, (*Expr)(unsafe.Pointer(pExpr)).FiColumn)) < 0) { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(1) - return 2 + return WRC_Abort } - return 0 + return WRC_Continue } // Determine if an index pIdx on table with cursor iCur contains will @@ -85088,9 +84424,9 @@ func Xsqlite3ExprCoveredByIndex(tls *libc.TLS, pExpr uintptr, iCur int32, pIdx u func selectSrcCount(tls *libc.TLS, pWalker uintptr, pSel uintptr) int32 { /* sqlite3.c:105386:12: */ var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) if (((*SrcCount)(unsafe.Pointer(p)).FiSrcInner == 0x7FFFFFFF) && ((*Select)(unsafe.Pointer(pSel)).FpSrc != 0)) && ((*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpSrc)).FnSrc != 0) { - (*SrcCount)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)))).FiSrcInner = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pSel)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FiCursor + (*SrcCount)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)))).FiSrcInner = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pSel)).FpSrc + 8 /* &.a */))).FiCursor } - return 0 + return WRC_Continue } // Count the number of references to columns. @@ -85101,7 +84437,7 @@ func exprSrcCount(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqli // been converted into TK_AGG_COLUMN. But this is no longer true due // to window functions - sqlite3WindowRewrite() may now indirectly call // FunctionUsesThisSrc() when creating a new sub-select. - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 166) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_COLUMN) { var i int32 var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) var pSrc uintptr = (*SrcCount)(unsafe.Pointer(p)).FpSrc @@ -85125,7 +84461,7 @@ func exprSrcCount(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqli (*SrcCount)(unsafe.Pointer(p)).FnOther++ } } - return 0 + return WRC_Continue } // Determine if any of the arguments to the pExpr Function reference @@ -85151,14 +84487,14 @@ func Xsqlite3FunctionUsesThisSrc(tls *libc.TLS, pExpr uintptr, pSrcList uintptr) (*SrcCount)(unsafe.Pointer(bp + 48 /* &cnt */)).FpSrc = pSrcList (*SrcCount)(unsafe.Pointer(bp + 48 /* &cnt */)).FiSrcInner = func() int32 { if (pSrcList != 0) && ((*SrcList)(unsafe.Pointer(pSrcList)).FnSrc != 0) { - return (*SrcList_item)(unsafe.Pointer((pSrcList + 8 /* &.a */) + uintptr(0)*112)).FiCursor + return (*SrcList_item)(unsafe.Pointer((pSrcList + 8 /* &.a */))).FiCursor } return 0x7FFFFFFF }() (*SrcCount)(unsafe.Pointer(bp + 48 /* &cnt */)).FnThis = 0 (*SrcCount)(unsafe.Pointer(bp + 48 /* &cnt */)).FnOther = 0 Xsqlite3WalkExprList(tls, bp /* &w */, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { Xsqlite3WalkExpr(tls, bp /* &w */, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FpFilter) } return (libc.Bool32(((*SrcCount)(unsafe.Pointer(bp+48 /* &cnt */)).FnThis > 0) || ((*SrcCount)(unsafe.Pointer(bp+48 /* &cnt */)).FnOther == 0))) @@ -85176,14 +84512,14 @@ func Xsqlite3FunctionUsesThisSrc(tls *libc.TLS, pExpr uintptr, pSrcList uintptr) // Parse object is destroyed, but the zero register number means that it // will not generate any code in the preamble. func agginfoPersistExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:105464:12: */ - if (!(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x004000 | 0x002000))) != U32(0))) && + if (!(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_TokenOnly | EP_Reduced))) != U32(0))) && ((*Expr)(unsafe.Pointer(pExpr)).FpAggInfo != uintptr(0)) { var pAggInfo uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo var iAgg int32 = int32((*Expr)(unsafe.Pointer(pExpr)).FiAgg) var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 166 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_COLUMN { if (*AggInfo_col)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol+uintptr(iAgg)*32)).FpCExpr == pExpr { pExpr = Xsqlite3ExprDup(tls, db, pExpr, 0) @@ -85203,7 +84539,7 @@ func agginfoPersistExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { } } } - return 0 + return WRC_Continue } // Initialize a Walker object so that will persist AggInfo entries referenced @@ -85264,9 +84600,9 @@ func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* var pAggInfo uintptr = *(*uintptr)(unsafe.Pointer(pNC + 16 /* &.uNC */)) switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) { - case 166: + case TK_AGG_COLUMN: fallthrough - case 164: + case TK_COLUMN: { // Check to see if the column is in one of the tables in the FROM @@ -85330,7 +84666,7 @@ func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* } { var pE uintptr = (*ExprList_item)(unsafe.Pointer(pTerm)).FpExpr - if ((int32((*Expr)(unsafe.Pointer(pE)).Fop) == 164) && ((*Expr)(unsafe.Pointer(pE)).FiTable == (*Expr)(unsafe.Pointer(pExpr)).FiTable)) && (int32((*Expr)(unsafe.Pointer(pE)).FiColumn) == int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)) { + if ((int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_COLUMN) && ((*Expr)(unsafe.Pointer(pE)).FiTable == (*Expr)(unsafe.Pointer(pExpr)).FiTable)) && (int32((*Expr)(unsafe.Pointer(pE)).FiColumn) == int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)) { (*AggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn = I16(j) goto __9 } @@ -85354,7 +84690,7 @@ func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* // pAggInfo->aCol[] entry. (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(166) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_AGG_COLUMN (*Expr)(unsafe.Pointer(pExpr)).FiAgg = I16(k) goto __3 } // endif pExpr->iTable==pItem->iCursor @@ -85368,12 +84704,12 @@ func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* goto __3 __3: // end loop over pSrcList } - return 1 + return WRC_Prune } - case 165: + case TK_AGG_FUNCTION: { - if (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x20000) == 0) && + if (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_InAggFunc) == 0) && ((*Walker)(unsafe.Pointer(pWalker)).FwalkerDepth == int32((*Expr)(unsafe.Pointer(pExpr)).Fop2)) { // Check to see if pExpr is a duplicate of another aggregate // function that is already in the pAggInfo structure @@ -85415,7 +84751,7 @@ func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* } return 0 }(), enc, uint8(0)) - if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & U32(0x000002)) != 0 { + if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & EP_Distinct) != 0 { (*AggInfo_func)(unsafe.Pointer(pItem)).FiDistinct = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) } else { (*AggInfo_func)(unsafe.Pointer(pItem)).FiDistinct = -1 @@ -85426,14 +84762,14 @@ func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* (*Expr)(unsafe.Pointer(pExpr)).FiAgg = I16(i) (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo - return 1 + return WRC_Prune } else { - return 0 + return WRC_Continue } } } - return 0 + return WRC_Continue } // Analyze the pExpr expression looking for aggregate functions and @@ -85588,7 +84924,7 @@ func isAlterableTable(tls *libc.TLS, pParse uintptr, pTab uintptr) int32 { /* sq defer tls.Free(8) if (0 == Xsqlite3_strnicmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName, ts+6905 /* "sqlite_" */, 7)) || - ((((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x1000)) != U32(0)) && + ((((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Shadow) != U32(0)) && (Xsqlite3ReadOnlyShadowTables(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb) != 0)) { Xsqlite3ErrorMsg(tls, pParse, ts+6913 /* "table %s may not..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName)) return 1 @@ -85661,7 +84997,7 @@ func Xsqlite3AlterRenameTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pName __1: ; - pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), ((pSrc + 8 /* &.a */) + uintptr(0)*112)) + pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), (pSrc + 8 /* &.a */)) if !(!(pTab != 0)) { goto __2 } @@ -85670,7 +85006,7 @@ __2: ; iDb = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Table)(unsafe.Pointer(pTab)).FpSchema) zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0002)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_PreferBuiltin) // Get a NULL terminated version of the new table name. zName = Xsqlite3NameFromToken(tls, db, pName) @@ -85696,13 +85032,13 @@ __4: // Make sure it is not a system table being altered, or a reserved name // that the table is being renamed to. - if !(0 != isAlterableTable(tls, pParse, pTab)) { + if !(SQLITE_OK != isAlterableTable(tls, pParse, pTab)) { goto __5 } goto exit_rename_table __5: ; - if !(0 != Xsqlite3CheckObjectName(tls, pParse, zName, ts+7333 /* "table" */, zName)) { + if !(SQLITE_OK != Xsqlite3CheckObjectName(tls, pParse, zName, ts+7333 /* "table" */, zName)) { goto __6 } goto exit_rename_table @@ -85718,7 +85054,7 @@ __7: ; // Invoke the authorization callback. - if !(Xsqlite3AuthCheck(tls, pParse, 26, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_ALTER_TABLE, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0) { goto __8 } goto exit_rename_table @@ -85808,7 +85144,7 @@ __14: } i = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) Xsqlite3VdbeLoadString(tls, v, i, zName) - Xsqlite3VdbeAddOp4(tls, v, 167, i, 0, 0, pVTab, -12) + Xsqlite3VdbeAddOp4(tls, v, OP_VRename, i, 0, 0, pVTab, -12) __15: ; @@ -85862,20 +85198,20 @@ func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pNew)).FpSchema) zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName - zTab = ((*Table)(unsafe.Pointer(pNew)).FzName + uintptr(16)) // Skip the "sqlite_altertab_" prefix on the name + zTab = ((*Table)(unsafe.Pointer(pNew)).FzName + 16) // Skip the "sqlite_altertab_" prefix on the name pCol = ((*Table)(unsafe.Pointer(pNew)).FaCol + uintptr((int32((*Table)(unsafe.Pointer(pNew)).FnCol)-1))*32) pDflt = (*Column)(unsafe.Pointer(pCol)).FpDflt pTab = Xsqlite3FindTable(tls, db, zTab, zDb) // Invoke the authorization callback. - if Xsqlite3AuthCheck(tls, pParse, 26, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { + if Xsqlite3AuthCheck(tls, pParse, SQLITE_ALTER_TABLE, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { return } // Check that the new column is not specified as PRIMARY KEY or UNIQUE. // If there is a NOT NULL constraint, then the default value for the // column must not be NULL. - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0001) != 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_PRIMKEY) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+8221 /* "Cannot add a PRI..." */, 0) return } @@ -85884,15 +85220,15 @@ func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr ts+8253 /* "Cannot add a UNI..." */, 0) return } - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0060) == 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_GENERATED) == 0 { // If the default value for the new column was specified with a // literal NULL, then set pDflt to 0. This simplifies checking // for an SQL NULL default below. - if (pDflt != 0) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pDflt)).FpLeft)).Fop) == 119) { + if (pDflt != 0) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pDflt)).FpLeft)).Fop) == TK_NULL) { pDflt = uintptr(0) } - if ((((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00004000)) != 0) && ((*Table)(unsafe.Pointer(pNew)).FpFKey != 0)) && (pDflt != 0) { + if ((((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ForeignKeys) != 0) && ((*Table)(unsafe.Pointer(pNew)).FpFKey != 0)) && (pDflt != 0) { sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, ts+8280 /* "Cannot add a REF..." */) } @@ -85906,9 +85242,9 @@ func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr if pDflt != 0 { *(*uintptr)(unsafe.Pointer(bp + 40 /* pVal */)) = uintptr(0) var rc int32 - rc = Xsqlite3ValueFromExpr(tls, db, pDflt, uint8(1), uint8(0x41), bp+40 /* &pVal */) + rc = Xsqlite3ValueFromExpr(tls, db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, bp+40 /* &pVal */) - if rc != 0 { + if rc != SQLITE_OK { return } @@ -85918,7 +85254,7 @@ func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr } Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pVal */))) } - } else if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0040) != 0 { + } else if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_STORED) != 0 { sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, ts+8438 /* "cannot add a STO..." */) } @@ -85930,7 +85266,7 @@ func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr for (zEnd > zCol) && ((int32(*(*int8)(unsafe.Pointer(zEnd))) == ';') || ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zEnd)))]) & 0x01) != 0)) { *(*int8)(unsafe.Pointer(libc.PostDecUintptr(&zEnd, 1))) = int8(0) } - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0002)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_PreferBuiltin) Xsqlite3NestedParse(tls, pParse, ts+8465, /* "UPDATE \"%w\".sqli..." */ @@ -85946,12 +85282,12 @@ func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr v = Xsqlite3GetVdbe(tls, pParse) if v != 0 { r1 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 93, iDb, r1, 2) + Xsqlite3VdbeAddOp3(tls, v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT) Xsqlite3VdbeUsesBtree(tls, v, iDb) - Xsqlite3VdbeAddOp2(tls, v, 82, r1, -2) - Xsqlite3VdbeAddOp2(tls, v, 48, r1, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, r1, -2) + Xsqlite3VdbeAddOp2(tls, v, OP_IfPos, r1, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) - Xsqlite3VdbeAddOp3(tls, v, 94, iDb, 2, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3) Xsqlite3ReleaseTempReg(tls, pParse, r1) } @@ -85993,7 +85329,7 @@ func Xsqlite3AlterBeginAddColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr) { goto exit_begin_add_column __1: ; - pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), ((pSrc + 8 /* &.a */) + uintptr(0)*112)) + pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), (pSrc + 8 /* &.a */)) if !(!(pTab != 0)) { goto __2 } @@ -86017,7 +85353,7 @@ __3: goto exit_begin_add_column __4: ; - if !(0 != isAlterableTable(tls, pParse, pTab)) { + if !(SQLITE_OK != isAlterableTable(tls, pParse, pTab)) { goto __5 } goto exit_begin_add_column @@ -86128,7 +85464,7 @@ func Xsqlite3AlterRenameColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr, pOld zNew = uintptr(0) // True to quote the new name // Locate the table to be altered - pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), ((pSrc + 8 /* &.a */) + uintptr(0)*112)) + pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), (pSrc + 8 /* &.a */)) if !(!(pTab != 0)) { goto __1 } @@ -86137,13 +85473,13 @@ __1: ; // Cannot alter a system table - if !(0 != isAlterableTable(tls, pParse, pTab)) { + if !(SQLITE_OK != isAlterableTable(tls, pParse, pTab)) { goto __2 } goto exit_rename_column __2: ; - if !(0 != isRealTable(tls, pParse, pTab)) { + if !(SQLITE_OK != isRealTable(tls, pParse, pTab)) { goto __3 } goto exit_rename_column @@ -86156,7 +85492,7 @@ __3: zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iSchema)*32)).FzDbSName // Invoke the authorization callback. - if !(Xsqlite3AuthCheck(tls, pParse, 26, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_ALTER_TABLE, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0) { goto __4 } goto exit_rename_column @@ -86210,7 +85546,7 @@ __10: __11: ; - bQuote = (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(pNew)).Fz + uintptr(0))))]) & 0x80) + bQuote = (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(pNew)).Fz)))]) & 0x80) Xsqlite3NestedParse(tls, pParse, ts+8720, /* "UPDATE \"%w\".sqli..." */ @@ -86251,7 +85587,7 @@ type RenameCtx = RenameCtx1 /* sqlite3.c:106452:26 */ func Xsqlite3RenameTokenMap(tls *libc.TLS, pParse uintptr, pPtr uintptr, pToken uintptr) uintptr { /* sqlite3.c:106513:21: */ var pNew uintptr - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != 3 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_UNMAP { pNew = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(RenameToken{}))) if pNew != 0 { (*RenameToken)(unsafe.Pointer(pNew)).Fp = pPtr @@ -86282,7 +85618,7 @@ func Xsqlite3RenameTokenRemap(tls *libc.TLS, pParse uintptr, pTo uintptr, pFrom func renameUnmapExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:106549:12: */ var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr) - return 0 + return WRC_Continue } // Iterate through the Select objects that are part of WITH clauses attached @@ -86322,15 +85658,15 @@ func renameUnmapSelectCb(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* s var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse var i int32 if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { - return 2 + return WRC_Abort } - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0200000)) != 0 { - return 1 + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_View) != 0 { + return WRC_Prune } if (*Select)(unsafe.Pointer(p)).FpEList != 0 { var pList uintptr = (*Select)(unsafe.Pointer(p)).FpEList for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ { - if ((*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FzEName != 0) && ((int32(*(*uint8)(unsafe.Pointer(((pList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0) { + if ((*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FzEName != 0) && ((int32(*(*uint8)(unsafe.Pointer(((pList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME) { Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FzEName) } } @@ -86340,14 +85676,14 @@ func renameUnmapSelectCb(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* s for i = 0; i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc; i++ { Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(i)*112)).FzName) if Xsqlite3WalkExpr(tls, pWalker, (*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(i)*112)).FpOn) != 0 { - return 2 + return WRC_Abort } unmapColumnIdlistNames(tls, pParse, (*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(i)*112)).FpUsing) } } renameWalkWith(tls, pWalker, p) - return 0 + return WRC_Continue } // Remove all nodes that are part of expression pExpr from the rename list. @@ -86366,7 +85702,7 @@ func Xsqlite3RenameExprUnmap(tls *libc.TLS, pParse uintptr, pExpr uintptr) { /* (*Walker)(unsafe.Pointer(bp /* &sWalker */)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) int32 }{renameUnmapSelectCb})) - (*Parse)(unsafe.Pointer(pParse)).FeParseMode = U8(3) + (*Parse)(unsafe.Pointer(pParse)).FeParseMode = PARSE_MODE_UNMAP Xsqlite3WalkExpr(tls, bp /* &sWalker */, pExpr) (*Parse)(unsafe.Pointer(pParse)).FeParseMode = eMode } @@ -86388,7 +85724,7 @@ func Xsqlite3RenameExprlistUnmap(tls *libc.TLS, pParse uintptr, pEList uintptr) }{renameUnmapExprCb})) Xsqlite3WalkExprList(tls, bp /* &sWalker */, pEList) for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ { - if (int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0 { + if (int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME { Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FzEName) } } @@ -86428,11 +85764,11 @@ func renameTokenFind(tls *libc.TLS, pParse uintptr, pCtx uintptr, pPtr uintptr) // because without a dummy callback, sqlite3WalkExpr() and similar do not // descend into sub-select statements. func renameColumnSelectCb(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sqlite3.c:106692:12: */ - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0200000)) != 0 { - return 1 + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_View) != 0 { + return WRC_Prune } renameWalkWith(tls, pWalker, p) - return 0 + return WRC_Continue } // This is a Walker expression callback. @@ -86444,16 +85780,16 @@ func renameColumnSelectCb(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* // constructed in RenameCtx object at pWalker->u.pRename. func renameColumnExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:106707:12: */ var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) - if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 77) && + if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_TRIGGER) && (int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) == (*RenameCtx)(unsafe.Pointer(p)).FiCol)) && ((*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(pWalker)).FpParse)).FpTriggerTab == (*RenameCtx)(unsafe.Pointer(p)).FpTab) { renameTokenFind(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p, pExpr) - } else if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) && + } else if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) && (int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) == (*RenameCtx)(unsafe.Pointer(p)).FiCol)) && ((*RenameCtx)(unsafe.Pointer(p)).FpTab == *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */))) { renameTokenFind(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p, pExpr) } - return 0 + return WRC_Continue } // The RenameCtx contains a list of tokens that reference a column that @@ -86514,7 +85850,7 @@ func renameColumnElistNames(tls *libc.TLS, pParse uintptr, pCtx uintptr, pEList var i int32 for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ { var zName uintptr = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(i)*32)).FzEName - if (((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0) && + if (((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME) && (zName != uintptr(0))) && (0 == Xsqlite3_stricmp(tls, zName, zOld)) { renameTokenFind(tls, pParse, pCtx, zName) @@ -86558,16 +85894,16 @@ func renameParseSql(tls *libc.TLS, p uintptr, zDb uintptr, db uintptr, zSql uint // occurs and the parse does not result in a new table, index or // trigger object, the database must be corrupt. libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(Parse{}))) - (*Parse)(unsafe.Pointer(p)).FeParseMode = U8(2) + (*Parse)(unsafe.Pointer(p)).FeParseMode = PARSE_MODE_RENAME (*Parse)(unsafe.Pointer(p)).Fdb = db (*Parse)(unsafe.Pointer(p)).FnQueryLoop = U32(1) rc = Xsqlite3RunParser(tls, p, zSql, bp /* &zErr */) (*Parse)(unsafe.Pointer(p)).FzErrMsg = *(*uintptr)(unsafe.Pointer(bp /* zErr */)) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - rc = 7 + rc = SQLITE_NOMEM } - if (((rc == 0) && + if (((rc == SQLITE_OK) && ((*Parse)(unsafe.Pointer(p)).FpNewTable == uintptr(0))) && ((*Parse)(unsafe.Pointer(p)).FpNewIndex == uintptr(0))) && ((*Parse)(unsafe.Pointer(p)).FpNewTrigger == uintptr(0)) { rc = Xsqlite3CorruptError(tls, 106852) } @@ -86590,7 +85926,7 @@ func renameEditSql(tls *libc.TLS, pCtx uintptr, pRename uintptr, zSql uintptr, z var nNew int32 = Xsqlite3Strlen30(tls, zNew) var nSql int32 = Xsqlite3Strlen30(tls, zSql) var db uintptr = Xsqlite3_context_db_handle(tls, pCtx) - var rc int32 = 0 + var rc int32 = SQLITE_OK var zQuot uintptr var zOut uintptr var nQuot int32 @@ -86602,7 +85938,7 @@ func renameEditSql(tls *libc.TLS, pCtx uintptr, pRename uintptr, zSql uintptr, z // quoted version of the new column name. zQuot = Xsqlite3MPrintf(tls, db, ts+9104 /* "\"%w\"" */, libc.VaList(bp, zNew)) if zQuot == uintptr(0) { - return 7 + return SQLITE_NOMEM } else { nQuot = Xsqlite3Strlen30(tls, zQuot) } @@ -86647,7 +85983,7 @@ func renameEditSql(tls *libc.TLS, pCtx uintptr, pRename uintptr, zSql uintptr, z Xsqlite3_result_text(tls, pCtx, zOut, -1, libc.UintptrFromInt32(-1)) Xsqlite3DbFree(tls, db, zOut) } else { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3_free(tls, zQuot) @@ -86667,7 +86003,7 @@ func renameResolveTrigger(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:10 var pStep uintptr // var sNC NameContext at bp, 56 - var rc int32 = 0 + var rc int32 = SQLITE_OK libc.Xmemset(tls, bp /* &sNC */, 0, uint64(unsafe.Sizeof(NameContext{}))) (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpParse = pParse @@ -86682,37 +86018,37 @@ func renameResolveTrigger(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:10 } // Resolve symbols in WHEN clause - if (rc == 0) && ((*Trigger)(unsafe.Pointer(pNew)).FpWhen != 0) { + if (rc == SQLITE_OK) && ((*Trigger)(unsafe.Pointer(pNew)).FpWhen != 0) { rc = Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*Trigger)(unsafe.Pointer(pNew)).FpWhen) } - for pStep = (*Trigger)(unsafe.Pointer(pNew)).Fstep_list; (rc == 0) && (pStep != 0); pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext { + for pStep = (*Trigger)(unsafe.Pointer(pNew)).Fstep_list; (rc == SQLITE_OK) && (pStep != 0); pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext { if (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect != 0 { Xsqlite3SelectPrep(tls, pParse, (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect, bp /* &sNC */) if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { rc = (*Parse)(unsafe.Pointer(pParse)).Frc } } - if (rc == 0) && ((*TriggerStep)(unsafe.Pointer(pStep)).FzTarget != 0) { + if (rc == SQLITE_OK) && ((*TriggerStep)(unsafe.Pointer(pStep)).FzTarget != 0) { var pSrc uintptr = Xsqlite3TriggerStepSrc(tls, pParse, pStep) if pSrc != 0 { var i int32 - for i = 0; (i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc) && (rc == 0); i++ { + for i = 0; (i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc) && (rc == SQLITE_OK); i++ { var p uintptr = ((pSrc + 8 /* &.a */) + uintptr(i)*112) (*SrcList_item)(unsafe.Pointer(p)).FpTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), p) (*SrcList_item)(unsafe.Pointer(p)).FiCursor = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) if (*SrcList_item)(unsafe.Pointer(p)).FpTab == uintptr(0) { - rc = 1 + rc = SQLITE_ERROR } else { (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(p)).FpTab)).FnTabRef++ rc = Xsqlite3ViewGetColumnNames(tls, pParse, (*SrcList_item)(unsafe.Pointer(p)).FpTab) } } (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpSrcList = pSrc - if (rc == 0) && ((*TriggerStep)(unsafe.Pointer(pStep)).FpWhere != 0) { + if (rc == SQLITE_OK) && ((*TriggerStep)(unsafe.Pointer(pStep)).FpWhere != 0) { rc = Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList) } @@ -86721,16 +86057,16 @@ func renameResolveTrigger(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:10 (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc = pSrc *(*uintptr)(unsafe.Pointer(bp /* &sNC */ + 16 /* &.uNC */)) = pUpsert - (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = 0x00200 + (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = NC_UUpsert rc = Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) - if rc == 0 { + if rc == SQLITE_OK { var pUpsertSet uintptr = (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet rc = Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, pUpsertSet) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere) } (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = 0 @@ -86738,7 +86074,7 @@ func renameResolveTrigger(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:10 (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpSrcList = uintptr(0) Xsqlite3SrcListDelete(tls, db, pSrc) } else { - rc = 7 + rc = SQLITE_NOMEM } } } @@ -86841,13 +86177,13 @@ func renameColumnFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintpt // A trigger var pStep uintptr db = Xsqlite3_context_db_handle(tls, context) - zSql = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zDb = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) - zTable = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8))) - iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(5)*8))) - zNew = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(6)*8))) - bQuote = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(7)*8))) - bTemp = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(8)*8))) + zSql = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + zDb = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) + zTable = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) + iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) + zNew = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 6*8))) + bQuote = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 7*8))) + bTemp = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 8*8))) xAuth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth _ = NotUsed @@ -86908,7 +86244,7 @@ __5: *(*uintptr)(unsafe.Pointer(bp + 456 /* &sWalker */ + 40 /* &.u */)) = bp /* &sCtx */ (*RenameCtx)(unsafe.Pointer(bp /* &sCtx */)).FpTab = pTab - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __6 } goto renameColumnFunc_done @@ -86921,22 +86257,22 @@ __6: if !(pSelect != 0) { goto __9 } - *(*U32)(unsafe.Pointer(pSelect + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0200000)) - (*Parse)(unsafe.Pointer(bp + 32 /* &sParse */)).Frc = 0 + *(*U32)(unsafe.Pointer(pSelect + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_View))) + (*Parse)(unsafe.Pointer(bp + 32 /* &sParse */)).Frc = SQLITE_OK Xsqlite3SelectPrep(tls, bp+32 /* &sParse */, pSelect, uintptr(0)) rc = func() int32 { if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - return 7 + return SQLITE_NOMEM } return (*Parse)(unsafe.Pointer(bp + 32 /* &sParse */)).Frc }() - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __11 } Xsqlite3WalkSelect(tls, bp+456 /* &sWalker */, pSelect) __11: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } goto renameColumnFunc_done @@ -87051,7 +86387,7 @@ __7: goto __33 __32: rc = renameResolveTrigger(tls, bp+32 /* &sParse */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __34 } goto renameColumnFunc_done @@ -87109,13 +86445,13 @@ __8: rc = renameEditSql(tls, context, bp /* &sCtx */, zSql, zNew, bQuote) renameColumnFunc_done: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __42 } if !((*Parse)(unsafe.Pointer(bp+32 /* &sParse */)).FzErrMsg != 0) { goto __43 } - renameColumnParseError(tls, context, 0, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+32 /* &sParse */) + renameColumnParseError(tls, context, 0, *(*uintptr)(unsafe.Pointer(argv + 1*8)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+32 /* &sParse */) goto __44 __43: Xsqlite3_result_error_code(tls, context, rc) @@ -87133,10 +86469,10 @@ __42: // Walker expression callback used by "RENAME TABLE". func renameTableExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:107274:12: */ var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) && ((*RenameCtx)(unsafe.Pointer(p)).FpTab == *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */))) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) && ((*RenameCtx)(unsafe.Pointer(p)).FpTab == *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */))) { renameTokenFind(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p, (pExpr + 64 /* &.y */ /* &.pTab */)) } - return 0 + return WRC_Continue } // Walker select callback used by "RENAME TABLE". @@ -87144,12 +86480,12 @@ func renameTableSelectCb(tls *libc.TLS, pWalker uintptr, pSelect uintptr) int32 var i int32 var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) var pSrc uintptr = (*Select)(unsafe.Pointer(pSelect)).FpSrc - if ((*Select)(unsafe.Pointer(pSelect)).FselFlags & U32(0x0200000)) != 0 { - return 1 + if ((*Select)(unsafe.Pointer(pSelect)).FselFlags & SF_View) != 0 { + return WRC_Prune } if pSrc == uintptr(0) { - return 2 + return WRC_Abort } for i = 0; i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc; i++ { var pItem uintptr = ((pSrc + 8 /* &.a */) + uintptr(i)*112) @@ -87159,7 +86495,7 @@ func renameTableSelectCb(tls *libc.TLS, pWalker uintptr, pSelect uintptr) int32 } renameWalkWith(tls, pWalker, pSelect) - return 0 + return WRC_Continue } // This C function implements an SQL user function that is used by SQL code @@ -87184,11 +86520,11 @@ func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr defer tls.Free(560) var db uintptr = Xsqlite3_context_db_handle(tls, context) - var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var zInput uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) - var zOld uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8))) - var zNew uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(5)*8))) - var bTemp int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(6)*8))) + var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + var zInput uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) + var zOld uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) + var zNew uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) + var bTemp int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 6*8))) _ = NotUsed if ((zInput != 0) && (zOld != 0)) && (zNew != 0) { @@ -87219,8 +86555,8 @@ func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr rc = renameParseSql(tls, bp+80 /* &sParse */, zDb, db, zInput, bTemp) - if rc == 0 { - var isLegacy int32 = (int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x04000000))) + if rc == SQLITE_OK { + var isLegacy int32 = (int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_LegacyAlter)) if (*Parse)(unsafe.Pointer(bp+80 /* &sParse */)).FpNewTable != 0 { var pTab uintptr = (*Parse)(unsafe.Pointer(bp + 80 /* &sParse */)).FpNewTable @@ -87232,7 +86568,7 @@ func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr libc.Xmemset(tls, bp+504 /* &sNC */, 0, uint64(unsafe.Sizeof(NameContext{}))) (*NameContext)(unsafe.Pointer(bp + 504 /* &sNC */)).FpParse = bp + 80 /* &sParse */ - *(*U32)(unsafe.Pointer(pSelect + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0200000)) + *(*U32)(unsafe.Pointer(pSelect + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_View))) Xsqlite3SelectPrep(tls, bp+80 /* &sParse */, (*Table)(unsafe.Pointer(pTab)).FpSelect, bp+504 /* &sNC */) if (*Parse)(unsafe.Pointer(bp+80 /* &sParse */)).FnErr != 0 { rc = (*Parse)(unsafe.Pointer(bp + 80 /* &sParse */)).Frc @@ -87242,7 +86578,7 @@ func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr } } else { // Modify any FK definitions to point to the new table. - if (isLegacy == 0) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00004000)) != 0) { + if (isLegacy == 0) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ForeignKeys) != 0) { var pFKey uintptr for pFKey = (*Table)(unsafe.Pointer(pTab)).FpFKey; pFKey != 0; pFKey = (*FKey)(unsafe.Pointer(pFKey)).FpNextFrom { if Xsqlite3_stricmp(tls, (*FKey)(unsafe.Pointer(pFKey)).FzTo, zOld) == 0 { @@ -87277,7 +86613,7 @@ func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr if isLegacy == 0 { rc = renameResolveTrigger(tls, bp+80 /* &sParse */) - if rc == 0 { + if rc == SQLITE_OK { renameWalkTrigger(tls, bp+32 /* &sWalker */, pTrigger) for pStep = (*Trigger)(unsafe.Pointer(pTrigger)).Fstep_list; pStep != 0; pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext { if ((*TriggerStep)(unsafe.Pointer(pStep)).FzTarget != 0) && (0 == Xsqlite3_stricmp(tls, (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget, zOld)) { @@ -87289,12 +86625,12 @@ func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr } } - if rc == 0 { + if rc == SQLITE_OK { rc = renameEditSql(tls, context, bp /* &sCtx */, zInput, zNew, bQuote) } - if rc != 0 { + if rc != SQLITE_OK { if (*Parse)(unsafe.Pointer(bp+80 /* &sParse */)).FzErrMsg != 0 { - renameColumnParseError(tls, context, 0, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+80 /* &sParse */) + renameColumnParseError(tls, context, 0, *(*uintptr)(unsafe.Pointer(argv + 1*8)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+80 /* &sParse */) } else { Xsqlite3_result_error_code(tls, context, rc) } @@ -87331,10 +86667,10 @@ func renameTableTest(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr defer tls.Free(480) var db uintptr = Xsqlite3_context_db_handle(tls, context) - var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var zInput uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - var bTemp int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8))) - var isLegacy int32 = (int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x04000000))) + var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + var zInput uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + var bTemp int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) + var isLegacy int32 = (int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_LegacyAlter)) var xAuth Sqlite3_xauth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth (*Sqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) @@ -87345,7 +86681,7 @@ func renameTableTest(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr // var sParse Parse at bp, 424 rc = renameParseSql(tls, bp /* &sParse */, zDb, db, zInput, bTemp) - if rc == 0 { + if rc == SQLITE_OK { if ((isLegacy == 0) && ((*Parse)(unsafe.Pointer(bp /* &sParse */)).FpNewTable != 0)) && ((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp /* &sParse */)).FpNewTable)).FpSelect != 0) { // var sNC NameContext at bp+424, 56 @@ -87359,7 +86695,7 @@ func renameTableTest(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr if isLegacy == 0 { rc = renameResolveTrigger(tls, bp /* &sParse */) } - if rc == 0 { + if rc == SQLITE_OK { var i1 int32 = Xsqlite3SchemaToIndex(tls, db, (*Trigger)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp /* &sParse */)).FpNewTrigger)).FpTabSchema) var i2 int32 = Xsqlite3FindDbName(tls, db, zDb) if i1 == i2 { @@ -87369,8 +86705,8 @@ func renameTableTest(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr } } - if rc != 0 { - renameColumnParseError(tls, context, 1, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)), bp /* &sParse */) + if rc != SQLITE_OK { + renameColumnParseError(tls, context, 1, *(*uintptr)(unsafe.Pointer(argv + 2*8)), *(*uintptr)(unsafe.Pointer(argv + 3*8)), bp /* &sParse */) } renameParseCleanup(tls, bp /* &sParse */) } @@ -87384,37 +86720,9 @@ func Xsqlite3AlterFunctions(tls *libc.TLS) { /* sqlite3.c:107538:21: */ } var aAlterTableFuncs = [3]FuncDef{ - { - FnArg: int8(9), - FfuncFlags: (U32((0x00040000 | 1) | 0x0800)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 9109 /* "sqlite_rename_co..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(7), - FfuncFlags: (U32((0x00040000 | 1) | 0x0800)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 9130 /* "sqlite_rename_ta..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(5), - FfuncFlags: (U32((0x00040000 | 1) | 0x0800)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 9150 /* "sqlite_rename_te..." */, Fu: struct{ FpHash uintptr }{}}, -} /* sqlite3.c:107539:18 */ + {FnArg: int8(9), FfuncFlags: (U32((SQLITE_FUNC_INTERNAL | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FxSFunc: 0, FzName: ts + 9109 /* "sqlite_rename_co..." */}, + {FnArg: int8(7), FfuncFlags: (U32((SQLITE_FUNC_INTERNAL | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FxSFunc: 0, FzName: ts + 9130 /* "sqlite_rename_ta..." */}, + {FnArg: int8(5), FfuncFlags: (U32((SQLITE_FUNC_INTERNAL | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FxSFunc: 0, FzName: ts + 9150 /* "sqlite_rename_te..." */}} /* sqlite3.c:107539:18 */ //************* End of alter.c ********************************************** //************* Begin file analyze.c **************************************** @@ -87583,7 +86891,7 @@ func openStatTable(tls *libc.TLS, pParse uintptr, iDb int32, iStatCur int32, zWh // var aCreateTbl [3]U8 at bp+72, 3 var nToOpen int32 - if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0 { + if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0 { nToOpen = 2 } else { nToOpen = 1 @@ -87613,7 +86921,7 @@ func openStatTable(tls *libc.TLS, pParse uintptr, iDb int32, iStatCur int32, zWh Xsqlite3NestedParse(tls, pParse, ts+9169 /* "CREATE TABLE %Q...." */, libc.VaList(bp, (*Db)(unsafe.Pointer(pDb)).FzDbSName, zTab, aTable[i].FzCols)) *(*U32)(unsafe.Pointer(bp + 76 /* &aRoot[0] */ + uintptr(i)*4)) = U32((*Parse)(unsafe.Pointer(pParse)).FregRoot) - *(*U8)(unsafe.Pointer(bp + 72 /* &aCreateTbl[0] */ + uintptr(i))) = U8(0x10) + *(*U8)(unsafe.Pointer(bp + 72 /* &aCreateTbl[0] */ + uintptr(i))) = OPFLAG_P2ISREG } } else { // The table already exists. If zWhere is not NULL, delete all entries @@ -87629,7 +86937,7 @@ func openStatTable(tls *libc.TLS, pParse uintptr, iDb int32, iStatCur int32, zWh Xsqlite3NestedParse(tls, pParse, ts+9222 /* "DELETE FROM %Q.%..." */, libc.VaList(bp+56, (*Db)(unsafe.Pointer(pDb)).FzDbSName, zTab)) } else { // The sqlite_stat[134] table already exists. Delete all rows. - Xsqlite3VdbeAddOp2(tls, v, 137, int32(*(*U32)(unsafe.Pointer(bp + 76 /* &aRoot[0] */ + uintptr(i)*4))), iDb) + Xsqlite3VdbeAddOp2(tls, v, OP_Clear, int32(*(*U32)(unsafe.Pointer(bp + 76 /* &aRoot[0] */ + uintptr(i)*4))), iDb) } } } @@ -87637,7 +86945,7 @@ func openStatTable(tls *libc.TLS, pParse uintptr, iDb int32, iStatCur int32, zWh // Open the sqlite_stat[134] tables for writing. for i = 0; i < nToOpen; i++ { - Xsqlite3VdbeAddOp4Int(tls, v, 97, (iStatCur + i), int32(*(*U32)(unsafe.Pointer(bp + 76 /* &aRoot[0] */ + uintptr(i)*4))), iDb, 3) + Xsqlite3VdbeAddOp4Int(tls, v, OP_OpenWrite, (iStatCur + i), int32(*(*U32)(unsafe.Pointer(bp + 76 /* &aRoot[0] */ + uintptr(i)*4))), iDb, 3) Xsqlite3VdbeChangeP5(tls, v, uint16(*(*U8)(unsafe.Pointer(bp + 72 /* &aCreateTbl[0] */ + uintptr(i))))) } @@ -87647,15 +86955,9 @@ var aTable = [3]struct { FzName uintptr FzCols uintptr }{ - { - FzName: ts + 9240, /* "sqlite_stat1" */ - FzCols: ts + 9253 /* "tbl,idx,stat" */}, - { - FzName: ts + 9266, /* "sqlite_stat4" */ - FzCols: ts + 9279 /* "tbl,idx,neq,nlt,..." */}, - { - FzName: ts + 9307, /* "sqlite_stat3" */ - FzCols: uintptr(0)}, + {FzName: ts + 9240 /* "sqlite_stat1" */, FzCols: ts + 9253 /* "tbl,idx,stat" */}, + {FzName: ts + 9266 /* "sqlite_stat4" */, FzCols: ts + 9279 /* "tbl,idx,neq,nlt,..." */}, + {FzName: ts + 9307 /* "sqlite_stat3" */}, } /* sqlite3.c:107725:5 */ // Recommended number of samples for sqlite_stat4 @@ -87799,22 +87101,22 @@ func statInit(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql var db uintptr = Xsqlite3_context_db_handle(tls, context) // Database connection // Maximum number of samples. 0 if STAT4 data is not collected var mxSample int32 - if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0 { - mxSample = 24 + if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0 { + mxSample = SQLITE_STAT4_SAMPLES } else { mxSample = 0 } // Decode the three function arguments _ = argc - nCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + nCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) if uint64(unsafe.Sizeof(TRowcnt(0))) < uint64(8) { - nColUp = ((nCol + 1) & ^libc.Int32(1)) + nColUp = ((nCol + 1) & libc.CplInt32(1)) } else { nColUp = nCol } - nKeyCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + nKeyCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) // Allocate the space required for the StatAccum object n = (int32((uint64(unsafe.Sizeof(StatAccum{})) + @@ -87833,13 +87135,13 @@ func statInit(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql } (*StatAccum)(unsafe.Pointer(p)).Fdb = db - (*StatAccum)(unsafe.Pointer(p)).FnEst = TRowcnt(Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + (*StatAccum)(unsafe.Pointer(p)).FnEst = TRowcnt(Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) (*StatAccum)(unsafe.Pointer(p)).FnRow = TRowcnt(0) - (*StatAccum)(unsafe.Pointer(p)).FnLimit = int32(Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)))) + (*StatAccum)(unsafe.Pointer(p)).FnLimit = int32(Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8)))) (*StatAccum)(unsafe.Pointer(p)).FnCol = nCol (*StatAccum)(unsafe.Pointer(p)).FnKeyCol = nKeyCol (*StatAccum)(unsafe.Pointer(p)).FnSkipAhead = U8(0) - (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt = (p + uintptr(1)*128) + (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt = (p + 1*128) (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq = ((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt + uintptr(nColUp)*4) (*StatAccum)(unsafe.Pointer(p)).FmxSample = func() int32 { @@ -87855,7 +87157,7 @@ func statInit(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql (*StatAccum)(unsafe.Pointer(p)).FiGet = -1 (*StatAccum)(unsafe.Pointer(p)).FnPSample = (((*StatAccum)(unsafe.Pointer(p)).FnEst / (TRowcnt((mxSample / 3) + 1))) + TRowcnt(1)) (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanLt = ((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(nColUp)*4) - (*StatAccum)(unsafe.Pointer(p)).FiPrn = ((U32(0x689e962d) * U32(nCol)) ^ (0xd0944565 * U32(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))))) + (*StatAccum)(unsafe.Pointer(p)).FiPrn = ((U32(0x689e962d) * U32(nCol)) ^ (0xd0944565 * U32(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))))) // Set up the StatAccum.a[] and aBest[] arrays (*StatAccum)(unsafe.Pointer(p)).Fa = ((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanLt + uintptr(nColUp)*4) @@ -87883,25 +87185,10 @@ func statInit(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql } var statInitFuncdef = FuncDef{ - FnArg: int8(4), - FfuncFlags:// nArg - U32(1), - FpUserData:// funcFlags - uintptr(0), - FpNext:// pUserData - uintptr(0), - FxSFunc:// pNext - 0, - FxFinalize:// xSFunc - uintptr(0), - FxValue:// xFinalize - uintptr(0), - FxInverse: uintptr(0), - FzName:// xValue, xInverse - ts + 9320, /* "stat_init" */ // zName - Fu:// zName - struct{ FpHash uintptr }{}, -} /* sqlite3.c:108036:22 */ + FnArg: int8(4), // nArg + FfuncFlags: SQLITE_UTF8, // pNext + FxSFunc: 0, // xValue, xInverse + FzName: ts + 9320 /* "stat_init" */} /* sqlite3.c:108036:22 */ // pNew and pOld are both candidate non-periodic samples selected for // the same column (pNew->iCol==pOld->iCol). Ignoring this column and @@ -88035,7 +87322,7 @@ __2: anLt = (*StatSample)(unsafe.Pointer(pMin)).FanLt anDLt = (*StatSample)(unsafe.Pointer(pMin)).FanDLt sampleClear(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, pMin) - libc.Xmemmove(tls, pMin, (pMin + uintptr(1)*48), (uint64(unsafe.Sizeof(StatSample{})) * (uint64(((*StatAccum)(unsafe.Pointer(p)).FnSample - (*StatAccum)(unsafe.Pointer(p)).FiMin) - 1)))) + libc.Xmemmove(tls, pMin, (pMin + 1*48), (uint64(unsafe.Sizeof(StatSample{})) * (uint64(((*StatAccum)(unsafe.Pointer(p)).FnSample - (*StatAccum)(unsafe.Pointer(p)).FiMin) - 1)))) pSample = ((*StatAccum)(unsafe.Pointer(p)).Fa + uintptr(((*StatAccum)(unsafe.Pointer(p)).FnSample-1))*48) (*StatSample)(unsafe.Pointer(pSample)).FnRowid = U32(0) (*StatSample)(unsafe.Pointer(pSample)).FanEq = anEq @@ -88151,8 +87438,8 @@ func statPush(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql var i int32 // The three function arguments - var p uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var iChng int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + var p uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) + var iChng int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) _ = argc _ = context @@ -88185,11 +87472,11 @@ func statPush(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql (*StatAccum)(unsafe.Pointer(p)).FnRow++ if (*StatAccum)(unsafe.Pointer(p)).FmxSample != 0 { var nLt TRowcnt - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) == 1 { - sampleSetRowidInt64(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, (p + 32 /* &.current */), Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) == SQLITE_INTEGER { + sampleSetRowidInt64(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, (p + 32 /* &.current */), Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) } else { - sampleSetRowid(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, (p + 32 /* &.current */), Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))), - Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + sampleSetRowid(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, (p + 32 /* &.current */), Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))), + Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) } (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FiHash = libc.AssignPtrUint32(p+88 /* &.iPrn */, (((*StatAccum)(unsafe.Pointer(p)).FiPrn * U32(1103515245)) + U32(12345))) @@ -88211,30 +87498,15 @@ func statPush(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql } } else if ((*StatAccum)(unsafe.Pointer(p)).FnLimit != 0) && ((*StatAccum)(unsafe.Pointer(p)).FnRow > (TRowcnt((*StatAccum)(unsafe.Pointer(p)).FnLimit) * (TRowcnt(int32((*StatAccum)(unsafe.Pointer(p)).FnSkipAhead) + 1)))) { (*StatAccum)(unsafe.Pointer(p)).FnSkipAhead++ - Xsqlite3_result_int(tls, context, (libc.Bool32(*(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt + uintptr(0)*4)) > TRowcnt(0)))) + Xsqlite3_result_int(tls, context, (libc.Bool32(*(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt)) > TRowcnt(0)))) } } var statPushFuncdef = FuncDef{ - FnArg: (int8(2 + 1)), - FfuncFlags:// nArg - U32(1), - FpUserData:// funcFlags - uintptr(0), - FpNext:// pUserData - uintptr(0), - FxSFunc:// pNext - 0, - FxFinalize:// xSFunc - uintptr(0), - FxValue:// xFinalize - uintptr(0), - FxInverse: uintptr(0), - FzName:// xValue, xInverse - ts + 9330, /* "stat_push" */ // zName - Fu:// zName - struct{ FpHash uintptr }{}, -} /* sqlite3.c:108326:22 */ + FnArg: (int8(2 + IsStat4)), // nArg + FfuncFlags: SQLITE_UTF8, // pNext + FxSFunc: 0, // xValue, xInverse + FzName: ts + 9330 /* "stat_push" */} /* sqlite3.c:108326:22 */ // Implementation of the stat_get(P,J) SQL function. This routine is // used to query statistical information that has been gathered into @@ -88257,11 +87529,11 @@ func statGet(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli bp := tls.Alloc(24) defer tls.Free(24) - var p uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var p uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) // STAT4 has a parameter on this routine. - var eCall int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + var eCall int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) - if eCall == 0 { + if eCall == STAT_GET_STAT1 { // Return the value to store in the "stat" column of the sqlite_stat1 // table for this index. // @@ -88308,7 +87580,7 @@ func statGet(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli } Xsqlite3_result_text(tls, context, zRet, -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) - } else if eCall == 1 { + } else if eCall == STAT_GET_ROWID { if (*StatAccum)(unsafe.Pointer(p)).FiGet < 0 { samplePushPrevious(tls, p, 0) (*StatAccum)(unsafe.Pointer(p)).FiGet = 0 @@ -88326,11 +87598,11 @@ func statGet(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli var aCnt uintptr = uintptr(0) switch eCall { - case 2: + case STAT_GET_NEQ: aCnt = (*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa + uintptr((*StatAccum)(unsafe.Pointer(p)).FiGet)*48)).FanEq break fallthrough - case 3: + case STAT_GET_NLT: aCnt = (*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa + uintptr((*StatAccum)(unsafe.Pointer(p)).FiGet)*48)).FanLt break fallthrough @@ -88365,30 +87637,15 @@ func statGet(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli } var statGetFuncdef = FuncDef{ - FnArg: (int8(1 + 1)), - FfuncFlags:// nArg - U32(1), - FpUserData:// funcFlags - uintptr(0), - FpNext:// pUserData - uintptr(0), - FxSFunc:// pNext - 0, - FxFinalize:// xSFunc - uintptr(0), - FxValue:// xFinalize - uintptr(0), - FxInverse: uintptr(0), - FzName:// xValue, xInverse - ts + 9357, /* "stat_get" */ // zName - Fu:// zName - struct{ FpHash uintptr }{}, -} /* sqlite3.c:108478:22 */ + FnArg: (int8(1 + IsStat4)), // nArg + FfuncFlags: SQLITE_UTF8, // pNext + FxSFunc: 0, // xValue, xInverse + FzName: ts + 9357 /* "stat_get" */} /* sqlite3.c:108478:22 */ func callStatGet(tls *libc.TLS, pParse uintptr, regStat int32, iParam int32, regOut int32) { /* sqlite3.c:108490:13: */ - Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, 69, iParam, (regStat + 1)) + Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_Integer, iParam, (regStat + 1)) - Xsqlite3VdbeAddFunctionCall(tls, pParse, 0, regStat, regOut, (1 + 1), + Xsqlite3VdbeAddFunctionCall(tls, pParse, 0, regStat, regOut, (1 + IsStat4), uintptr(unsafe.Pointer(&statGetFuncdef)), 0) } @@ -88437,7 +87694,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) - if Xsqlite3AuthCheck(tls, pParse, 28, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), + if Xsqlite3AuthCheck(tls, pParse, SQLITE_ANALYZE, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) != 0 { return } @@ -88447,11 +87704,11 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp if pStat1 == uintptr(0) { return } - (*Table)(unsafe.Pointer(pStat1)).FzName = (pStat1 + uintptr(1)*128) + (*Table)(unsafe.Pointer(pStat1)).FzName = (pStat1 + 1*128) libc.Xmemcpy(tls, (*Table)(unsafe.Pointer(pStat1)).FzName, ts+9240 /* "sqlite_stat1" */, uint64(13)) (*Table)(unsafe.Pointer(pStat1)).FnCol = int16(3) (*Table)(unsafe.Pointer(pStat1)).FiPKey = int16(-1) - Xsqlite3VdbeAddOp4(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, 173, 0, 0, 0, pStat1, -17) + Xsqlite3VdbeAddOp4(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_Noop, 0, 0, 0, pStat1, -17) } // Establish a read-lock on the table at the shared-cache level. @@ -88467,7 +87724,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp } return iTab }() - Xsqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab, 96) + Xsqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab, OP_OpenRead) Xsqlite3VdbeLoadString(tls, v, regTabname, (*Table)(unsafe.Pointer(pTab)).FzName) for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { @@ -88483,7 +87740,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) { needTableCnt = U8(0) } - if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2) { + if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY) { nCol = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) zIdxName = (*Table)(unsafe.Pointer(pTab)).FzName nColTest = (nCol - 1) @@ -88543,7 +87800,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp // Open a read-only cursor on the index being analyzed. - Xsqlite3VdbeAddOp3(tls, v, 96, iIdxCur, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, iIdxCur, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx) // Invoke the stat_init() function. The arguments are: @@ -88552,20 +87809,20 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp // (or for a WITHOUT ROWID table, the number of PK columns), // (2) the number of columns in the key without the rowid/pk // (3) estimated number of rows in the index, - Xsqlite3VdbeAddOp2(tls, v, 69, nCol, (regStat + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, nCol, (regStat + 1)) - Xsqlite3VdbeAddOp2(tls, v, 69, int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol), regRowid) - if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0 { - Xsqlite3VdbeAddOp2(tls, v, 92, iIdxCur, regTemp) - addrRewind = Xsqlite3VdbeAddOp1(tls, v, 37, iIdxCur) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol), regRowid) + if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0 { + Xsqlite3VdbeAddOp2(tls, v, OP_Count, iIdxCur, regTemp) + addrRewind = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iIdxCur) } else { - addrRewind = Xsqlite3VdbeAddOp1(tls, v, 37, iIdxCur) + addrRewind = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iIdxCur) - Xsqlite3VdbeAddOp3(tls, v, 92, iIdxCur, regTemp, 1) + Xsqlite3VdbeAddOp3(tls, v, OP_Count, iIdxCur, regTemp, 1) } - Xsqlite3VdbeAddOp2(tls, v, 69, (*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit, regTemp2) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, (*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit, regTemp2) Xsqlite3VdbeAddFunctionCall(tls, pParse, 0, (regStat + 1), regStat, 4, uintptr(unsafe.Pointer(&statInitFuncdef)), 0) @@ -88576,7 +87833,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp // regChng = 0 // goto next_push_0; // - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regChng) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regChng) addrNextRow = Xsqlite3VdbeCurrentAddr(tls, v) if nColTest > 0 { @@ -88595,25 +87852,25 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp // ... // regChng = N // goto endDistinctTest - Xsqlite3VdbeAddOp0(tls, v, 11) + Xsqlite3VdbeAddOp0(tls, v, OP_Goto) addrNextRow = Xsqlite3VdbeCurrentAddr(tls, v) - if ((nColTest == 1) && (int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) == 1)) && (int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0) { + if ((nColTest == 1) && (int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) == 1)) && (int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None) { // For a single-column UNIQUE index, once we have found a non-NULL // row, we know that all the rest will be distinct, so skip // subsequent distinctness tests. - Xsqlite3VdbeAddOp2(tls, v, 51, regPrev, endDistinctTest) + Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, regPrev, endDistinctTest) } for i = 0; i < nColTest; i++ { var pColl uintptr = Xsqlite3LocateCollSeq(tls, pParse, *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(i)*8))) - Xsqlite3VdbeAddOp2(tls, v, 69, i, regChng) - Xsqlite3VdbeAddOp3(tls, v, 89, iIdxCur, i, regTemp) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, i, regChng) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, i, regTemp) - *(*int32)(unsafe.Pointer(aGotoChng + uintptr(i)*4)) = Xsqlite3VdbeAddOp4(tls, v, 52, regTemp, 0, (regPrev + i), pColl, -2) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x80)) + *(*int32)(unsafe.Pointer(aGotoChng + uintptr(i)*4)) = Xsqlite3VdbeAddOp4(tls, v, OP_Ne, regTemp, 0, (regPrev + i), pColl, -2) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NULLEQ) } - Xsqlite3VdbeAddOp2(tls, v, 69, nColTest, regChng) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, nColTest, regChng) Xsqlite3VdbeGoto(tls, v, endDistinctTest) // chng_addr_0: @@ -88624,7 +87881,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp Xsqlite3VdbeJumpHere(tls, v, (addrNextRow - 1)) for i = 0; i < nColTest; i++ { Xsqlite3VdbeJumpHere(tls, v, *(*int32)(unsafe.Pointer(aGotoChng + uintptr(i)*4))) - Xsqlite3VdbeAddOp3(tls, v, 89, iIdxCur, i, (regPrev + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, i, (regPrev + i)) } Xsqlite3VdbeResolveLabel(tls, v, endDistinctTest) @@ -88636,10 +87893,10 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp // stat_push(P, regChng, regRowid) // 3rd parameter STAT4 only // Next csr // if !eof(csr) goto next_row; - if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0 { + if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0 { - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { - Xsqlite3VdbeAddOp2(tls, v, 134, iIdxCur, regRowid) + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { + Xsqlite3VdbeAddOp2(tls, v, OP_IdxRowid, iIdxCur, regRowid) } else { var pPk uintptr = Xsqlite3PrimaryKeyIndex(tls, (*Index)(unsafe.Pointer(pIdx)).FpTable) var j int32 @@ -88649,46 +87906,46 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp for j = 0; j < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); j++ { k = int32(Xsqlite3TableColumnToIndex(tls, pIdx, *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)))) - Xsqlite3VdbeAddOp3(tls, v, 89, iIdxCur, k, (regKey + j)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, k, (regKey + j)) } - Xsqlite3VdbeAddOp3(tls, v, 91, regKey, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol), regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regKey, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol), regRowid) Xsqlite3ReleaseTempRange(tls, pParse, regKey, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) } } { - Xsqlite3VdbeAddFunctionCall(tls, pParse, 1, regStat, regTemp, (2 + 1), + Xsqlite3VdbeAddFunctionCall(tls, pParse, 1, regStat, regTemp, (2 + IsStat4), uintptr(unsafe.Pointer(&statPushFuncdef)), 0) if (*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit != 0 { var j1 int32 var j2 int32 var j3 int32 - j1 = Xsqlite3VdbeAddOp1(tls, v, 50, regTemp) - j2 = Xsqlite3VdbeAddOp1(tls, v, 18, regTemp) - j3 = Xsqlite3VdbeAddOp4Int(tls, v, 25, iIdxCur, 0, regPrev, 1) + j1 = Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, regTemp) + j2 = Xsqlite3VdbeAddOp1(tls, v, OP_If, regTemp) + j3 = Xsqlite3VdbeAddOp4Int(tls, v, OP_SeekGT, iIdxCur, 0, regPrev, 1) Xsqlite3VdbeJumpHere(tls, v, j1) - Xsqlite3VdbeAddOp2(tls, v, 5, iIdxCur, addrNextRow) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iIdxCur, addrNextRow) Xsqlite3VdbeJumpHere(tls, v, j2) Xsqlite3VdbeJumpHere(tls, v, j3) } else { - Xsqlite3VdbeAddOp2(tls, v, 5, iIdxCur, addrNextRow) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iIdxCur, addrNextRow) } } // Add the entry to the stat1 table. - callStatGet(tls, pParse, regStat, 0, regStat1) + callStatGet(tls, pParse, regStat, STAT_GET_STAT1, regStat1) - Xsqlite3VdbeAddOp4(tls, v, 91, regTabname, 3, regTemp, ts+9376 /* "BBB" */, 0) - Xsqlite3VdbeAddOp2(tls, v, 120, iStatCur, regNewRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, iStatCur, regTemp, regNewRowid) + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regTabname, 3, regTemp, ts+9376 /* "BBB" */, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iStatCur, regNewRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iStatCur, regTemp, regNewRowid) Xsqlite3VdbeChangeP4(tls, v, -1, pStat1, -6) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x08)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_APPEND) // Add the entries to the stat4 table. - if ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0) && ((*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit == 0) { + if ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0) && ((*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit == 0) { var regEq int32 = regStat1 var regLt int32 = (regStat1 + 1) var regDLt int32 = (regStat1 + 2) @@ -88698,10 +87955,10 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp var addrNext int32 var addrIsNull int32 var seekOp U8 - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { - seekOp = uint8(32) + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { + seekOp = OP_NotExists } else { - seekOp = uint8(29) + seekOp = OP_NotFound } (*Parse)(unsafe.Pointer(pParse)).FnMem = func() int32 { @@ -88712,22 +87969,22 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp }() addrNext = Xsqlite3VdbeCurrentAddr(tls, v) - callStatGet(tls, pParse, regStat, 1, regSampleRowid) - addrIsNull = Xsqlite3VdbeAddOp1(tls, v, 50, regSampleRowid) + callStatGet(tls, pParse, regStat, STAT_GET_ROWID, regSampleRowid) + addrIsNull = Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, regSampleRowid) - callStatGet(tls, pParse, regStat, 2, regEq) - callStatGet(tls, pParse, regStat, 3, regLt) - callStatGet(tls, pParse, regStat, 4, regDLt) + callStatGet(tls, pParse, regStat, STAT_GET_NEQ, regEq) + callStatGet(tls, pParse, regStat, STAT_GET_NLT, regLt) + callStatGet(tls, pParse, regStat, STAT_GET_NDLT, regDLt) Xsqlite3VdbeAddOp4Int(tls, v, int32(seekOp), iTabCur, addrNext, regSampleRowid, 0) for i = 0; i < nCol; i++ { Xsqlite3ExprCodeLoadIndexColumn(tls, pParse, pIdx, iTabCur, i, (regCol + i)) } - Xsqlite3VdbeAddOp3(tls, v, 91, regCol, nCol, regSample) - Xsqlite3VdbeAddOp3(tls, v, 91, regTabname, 6, regTemp) - Xsqlite3VdbeAddOp2(tls, v, 120, (iStatCur + 1), regNewRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, (iStatCur + 1), regTemp, regNewRowid) - Xsqlite3VdbeAddOp2(tls, v, 11, 1, addrNext) // P1==1 for end-of-loop + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regCol, nCol, regSample) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regTabname, 6, regTemp) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, (iStatCur + 1), regNewRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, (iStatCur + 1), regTemp, regNewRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 1, addrNext) // P1==1 for end-of-loop Xsqlite3VdbeJumpHere(tls, v, addrIsNull) } @@ -88739,14 +87996,14 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp // name and the row count as the content. if (pOnlyIdx == uintptr(0)) && (needTableCnt != 0) { - Xsqlite3VdbeAddOp2(tls, v, 92, iTabCur, regStat1) - jZeroRows = Xsqlite3VdbeAddOp1(tls, v, 20, regStat1) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, regIdxname) + Xsqlite3VdbeAddOp2(tls, v, OP_Count, iTabCur, regStat1) + jZeroRows = Xsqlite3VdbeAddOp1(tls, v, OP_IfNot, regStat1) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regIdxname) - Xsqlite3VdbeAddOp4(tls, v, 91, regTabname, 3, regTemp, ts+9376 /* "BBB" */, 0) - Xsqlite3VdbeAddOp2(tls, v, 120, iStatCur, regNewRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, iStatCur, regTemp, regNewRowid) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x08)) + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regTabname, 3, regTemp, ts+9376 /* "BBB" */, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iStatCur, regNewRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iStatCur, regTemp, regNewRowid) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_APPEND) Xsqlite3VdbeChangeP4(tls, v, -1, pStat1, -6) Xsqlite3VdbeJumpHere(tls, v, jZeroRows) } @@ -88757,7 +88014,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp func loadAnalysis(tls *libc.TLS, pParse uintptr, iDb int32) { /* sqlite3.c:108893:13: */ var v uintptr = Xsqlite3GetVdbe(tls, pParse) if v != 0 { - Xsqlite3VdbeAddOp1(tls, v, 142, iDb) + Xsqlite3VdbeAddOp1(tls, v, OP_LoadAnalysis, iDb) } } @@ -88832,7 +88089,7 @@ func Xsqlite3Analyze(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintp // Read the database schema. If an error occurs, leave an error message // and code in pParse and return NULL. - if 0 != Xsqlite3ReadSchema(tls, pParse) { + if SQLITE_OK != Xsqlite3ReadSchema(tls, pParse) { return } @@ -88868,7 +88125,7 @@ func Xsqlite3Analyze(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintp } } if (int32((*Sqlite3)(unsafe.Pointer(db)).FnSqlExec) == 0) && ((libc.AssignUintptr(&v, Xsqlite3GetVdbe(tls, pParse))) != uintptr(0)) { - Xsqlite3VdbeAddOp0(tls, v, 158) + Xsqlite3VdbeAddOp0(tls, v, OP_Expire) } } @@ -88897,7 +88154,7 @@ func decodeIntArray(tls *libc.TLS, zIntArray uintptr, nOut int32, aOut uintptr, } for i = 0; (*(*int8)(unsafe.Pointer(z)) != 0) && (i < nOut); i++ { v = TRowcnt(0) - for ((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))))) >= '0') && (c <= '9') { + for ((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(z))))) >= '0') && (c <= '9') { v = (((v * TRowcnt(10)) + TRowcnt(c)) - TRowcnt('0')) z++ } @@ -88914,7 +88171,7 @@ func decodeIntArray(tls *libc.TLS, zIntArray uintptr, nOut int32, aOut uintptr, if pIndex != 0 { libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.bUnordered */, uint32(0), 2, 0x4) libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.noSkipScan */, uint32(0), 6, 0x40) - for *(*int8)(unsafe.Pointer(z + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(z)) != 0 { if Xsqlite3_strglob(tls, ts+9388 /* "unordered*" */, z) == 0 { libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.bUnordered */, uint32(1), 2, 0x4) } else if Xsqlite3_strglob(tls, ts+9399 /* "sz=[0-9]*" */, z) == 0 { @@ -88926,10 +88183,10 @@ func decodeIntArray(tls *libc.TLS, zIntArray uintptr, nOut int32, aOut uintptr, } else if Xsqlite3_strglob(tls, ts+9409 /* "noskipscan*" */, z) == 0 { libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.noSkipScan */, uint32(1), 6, 0x40) } - for (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) != 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) != ' ') { + for (int32(*(*int8)(unsafe.Pointer(z))) != 0) && (int32(*(*int8)(unsafe.Pointer(z))) != ' ') { z++ } - for int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == ' ' { + for int32(*(*int8)(unsafe.Pointer(z))) == ' ' { z++ } } @@ -88957,21 +88214,21 @@ func analysisLoader(tls *libc.TLS, pData uintptr, argc int32, argv uintptr, NotU _ = NotUsed _ = argc - if ((argv == uintptr(0)) || (*(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)) == uintptr(0))) || (*(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)) == uintptr(0)) { + if ((argv == uintptr(0)) || (*(*uintptr)(unsafe.Pointer(argv)) == uintptr(0))) || (*(*uintptr)(unsafe.Pointer(argv + 2*8)) == uintptr(0)) { return 0 } - pTable = Xsqlite3FindTable(tls, (*AnalysisInfo)(unsafe.Pointer(pInfo)).Fdb, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), (*AnalysisInfo)(unsafe.Pointer(pInfo)).FzDatabase) + pTable = Xsqlite3FindTable(tls, (*AnalysisInfo)(unsafe.Pointer(pInfo)).Fdb, *(*uintptr)(unsafe.Pointer(argv)), (*AnalysisInfo)(unsafe.Pointer(pInfo)).FzDatabase) if pTable == uintptr(0) { return 0 } - if *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) == uintptr(0) { + if *(*uintptr)(unsafe.Pointer(argv + 1*8)) == uintptr(0) { pIndex = uintptr(0) - } else if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) == 0 { + } else if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv)), *(*uintptr)(unsafe.Pointer(argv + 1*8))) == 0 { pIndex = Xsqlite3PrimaryKeyIndex(tls, pTable) } else { - pIndex = Xsqlite3FindIndex(tls, (*AnalysisInfo)(unsafe.Pointer(pInfo)).Fdb, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), (*AnalysisInfo)(unsafe.Pointer(pInfo)).FzDatabase) + pIndex = Xsqlite3FindIndex(tls, (*AnalysisInfo)(unsafe.Pointer(pInfo)).Fdb, *(*uintptr)(unsafe.Pointer(argv + 1*8)), (*AnalysisInfo)(unsafe.Pointer(pInfo)).FzDatabase) } - z = *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)) + z = *(*uintptr)(unsafe.Pointer(argv + 2*8)) if pIndex != 0 { var aiRowEst uintptr = uintptr(0) @@ -88990,8 +88247,8 @@ func analysisLoader(tls *libc.TLS, pData uintptr, argc int32, argv uintptr, NotU decodeIntArray(tls, z, nCol, aiRowEst, (*Index)(unsafe.Pointer(pIndex)).FaiRowLogEst, pIndex) libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.hasStat1 */, uint32(1), 7, 0x80) if (*Index)(unsafe.Pointer(pIndex)).FpPartIdxWhere == uintptr(0) { - (*Table)(unsafe.Pointer(pTable)).FnRowLogEst = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiRowLogEst + uintptr(0)*2)) - *(*U32)(unsafe.Pointer(pTable + 64 /* &.tabFlags */)) |= (U32(0x0010)) + (*Table)(unsafe.Pointer(pTable)).FnRowLogEst = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiRowLogEst)) + *(*U32)(unsafe.Pointer(pTable + 64 /* &.tabFlags */)) |= (TF_HasStat1) } } else { // var fakeIdx Index at bp, 152 @@ -88999,7 +88256,7 @@ func analysisLoader(tls *libc.TLS, pData uintptr, argc int32, argv uintptr, NotU (*Index)(unsafe.Pointer(bp /* &fakeIdx */)).FszIdxRow = (*Table)(unsafe.Pointer(pTable)).FszTabRow decodeIntArray(tls, z, 1, uintptr(0), (pTable + 74 /* &.nRowLogEst */), bp /* &fakeIdx */) (*Table)(unsafe.Pointer(pTable)).FszTabRow = (*Index)(unsafe.Pointer(bp /* &fakeIdx */)).FszIdxRow - *(*U32)(unsafe.Pointer(pTable + 64 /* &.tabFlags */)) |= (U32(0x0010)) + *(*U32)(unsafe.Pointer(pTable + 64 /* &.tabFlags */)) |= (TF_HasStat1) } return 0 @@ -89052,8 +88309,8 @@ func initAvgEq(tls *libc.TLS, pIdx uintptr) { /* sqlite3.c:109185:13: */ nDist100 = (int64(100) * I64(*(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(pFinal)).FanDLt + uintptr(iCol)*4)))) nSample-- } else { - nRow = *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst + uintptr(0)*4)) - nDist100 = ((int64(100) * I64(*(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst + uintptr(0)*4)))) / I64(*(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst + uintptr((iCol+1))*4)))) + nRow = *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst)) + nDist100 = ((int64(100) * I64(*(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst)))) / I64(*(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst + uintptr((iCol+1))*4)))) } (*Index)(unsafe.Pointer(pIdx)).FnRowEst0 = nRow @@ -89086,7 +88343,7 @@ func findIndexOrPrimaryKey(tls *libc.TLS, db uintptr, zName uintptr, zDb uintptr var pIdx uintptr = Xsqlite3FindIndex(tls, db, zName, zDb) if pIdx == uintptr(0) { var pTab uintptr = Xsqlite3FindTable(tls, db, zName, zDb) - if (pTab != 0) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if (pTab != 0) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { pIdx = Xsqlite3PrimaryKeyIndex(tls, pTab) } } @@ -89115,7 +88372,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui zSql = Xsqlite3MPrintf(tls, db, zSql1, libc.VaList(bp, zDb)) if !(zSql != 0) { - return 7 + return SQLITE_NOMEM } rc = Xsqlite3_prepare(tls, db, zSql, -1, bp+16 /* &pStmt */, uintptr(0)) Xsqlite3DbFree(tls, db, zSql) @@ -89123,7 +88380,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui return rc } - for Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == 100 { + for Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == SQLITE_ROW { var nIdxCol int32 = 1 // Number of columns in stat4 records var zIndex uintptr // Index name @@ -89144,7 +88401,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui continue } - if !(((*Table)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FpTable))).FtabFlags & U32(0x0080)) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2) { + if !(((*Table)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FpTable))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY) { nIdxCol = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) } else { nIdxCol = int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) @@ -89157,7 +88414,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui (*Index)(unsafe.Pointer(pIdx)).FaSample = Xsqlite3DbMallocZero(tls, db, uint64(nByte)) if (*Index)(unsafe.Pointer(pIdx)).FaSample == uintptr(0) { Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) - return 7 + return SQLITE_NOMEM } pSpace = ((*Index)(unsafe.Pointer(pIdx)).FaSample + uintptr(nSample)*40) (*Index)(unsafe.Pointer(pIdx)).FaAvgEq = pSpace @@ -89179,7 +88436,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui zSql = Xsqlite3MPrintf(tls, db, zSql2, libc.VaList(bp+8, zDb)) if !(zSql != 0) { - return 7 + return SQLITE_NOMEM } rc = Xsqlite3_prepare(tls, db, zSql, -1, bp+16 /* &pStmt */, uintptr(0)) Xsqlite3DbFree(tls, db, zSql) @@ -89187,7 +88444,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui return rc } - for Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == 100 { + for Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == SQLITE_ROW { var zIndex uintptr // Index name var pIdx uintptr // Pointer to the index object var nCol int32 = 1 // Number of columns in index @@ -89222,7 +88479,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui (*IndexSample)(unsafe.Pointer(pSample)).Fp = Xsqlite3DbMallocZero(tls, db, (uint64((*IndexSample)(unsafe.Pointer(pSample)).Fn + 2))) if (*IndexSample)(unsafe.Pointer(pSample)).Fp == uintptr(0) { Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) - return 7 + return SQLITE_NOMEM } if (*IndexSample)(unsafe.Pointer(pSample)).Fn != 0 { libc.Xmemcpy(tls, (*IndexSample)(unsafe.Pointer(pSample)).Fp, Xsqlite3_column_blob(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)), 4), uint64((*IndexSample)(unsafe.Pointer(pSample)).Fn)) @@ -89230,7 +88487,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui (*Index)(unsafe.Pointer(pIdx)).FnSample++ } rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) - if rc == 0 { + if rc == SQLITE_OK { initAvgEq(tls, pPrevIdx) } return rc @@ -89239,7 +88496,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui // Load content from the sqlite_stat4 table into // the Index.aSample[] arrays of all indices. func loadStat4(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* sqlite3.c:109389:12: */ - var rc int32 = 0 // Result codes from subroutines + var rc int32 = SQLITE_OK // Result codes from subroutines if Xsqlite3FindTable(tls, db, ts+9266 /* "sqlite_stat4" */, zDb) != 0 { rc = loadStatTbl(tls, db, @@ -89276,14 +88533,14 @@ func Xsqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) int32 { /* sqlit var i uintptr var zSql uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK var pSchema uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpSchema // Clear any prior statistics for i = (*Hash)(unsafe.Pointer((pSchema + 8 /* &.tblHash */))).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext { var pTab uintptr = (*HashElem)(unsafe.Pointer(i)).Fdata - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) &= (^libc.Uint32FromInt32(0x0010)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(TF_HasStat1))) } for i = (*Hash)(unsafe.Pointer((pSchema + 32 /* &.idxHash */))).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext { var pIdx uintptr = (*HashElem)(unsafe.Pointer(i)).Fdata @@ -89299,7 +88556,7 @@ func Xsqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) int32 { /* sqlit zSql = Xsqlite3MPrintf(tls, db, ts+9527 /* "SELECT tbl,idx,s..." */, libc.VaList(bp, (*AnalysisInfo)(unsafe.Pointer(bp+8 /* &sInfo */)).FzDatabase)) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_exec(tls, db, zSql, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 @@ -89318,7 +88575,7 @@ func Xsqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) int32 { /* sqlit } // Load the statistics from the sqlite_stat4 table. - if rc == 0 { + if rc == SQLITE_OK { (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable++ (*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0) rc = loadStat4(tls, db, (*AnalysisInfo)(unsafe.Pointer(bp+8 /* &sInfo */)).FzDatabase) @@ -89336,7 +88593,7 @@ func Xsqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) int32 { /* sqlit (*Index)(unsafe.Pointer(pIdx)).FaiRowEst = uintptr(0) } - if rc == 7 { + if rc == SQLITE_NOMEM { Xsqlite3OomFault(tls, db) } return rc @@ -89374,12 +88631,12 @@ func Xsqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) int32 { /* sqlit // // will fail because neither abc or def can be resolved. func resolveAttachExpr(tls *libc.TLS, pName uintptr, pExpr uintptr) int32 { /* sqlite3.c:109529:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if pExpr != 0 { - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 59 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_ID { rc = Xsqlite3ResolveExprNames(tls, pName, pExpr) } else { - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(115) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_STRING } } return rc @@ -89435,8 +88692,8 @@ func attachFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { / *(*uintptr)(unsafe.Pointer(bp + 56 /* zErrDyn */)) = uintptr(0) _ = NotUsed - zFile = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zName = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zFile = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + zName = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if !(zFile == uintptr(0)) { goto __1 } @@ -89472,7 +88729,7 @@ __6: ; (*Db)(unsafe.Pointer(pNew)).FpBt = uintptr(0) (*Db)(unsafe.Pointer(pNew)).FpSchema = uintptr(0) - rc = Xsqlite3BtreeOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pVfs */)), ts+9574 /* "x\x00" */, db, (pNew + 8 /* &.pBt */), 0, 0x00000100) + rc = Xsqlite3BtreeOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pVfs */)), ts+9574 /* "x\x00" */, db, (pNew + 8 /* &.pBt */), 0, SQLITE_OPEN_MAIN_DB) goto __4 __3: // This is a real ATTACH @@ -89482,11 +88739,11 @@ __3: // * Too many attached databases, // * Transaction currently open // * Specified database name already being used. - if !((*Sqlite3)(unsafe.Pointer(db)).FnDb >= (*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(7)*4)) + 2)) { + if !((*Sqlite3)(unsafe.Pointer(db)).FnDb >= (*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 7*4)) + 2)) { goto __7 } *(*uintptr)(unsafe.Pointer(bp + 56 /* zErrDyn */)) = Xsqlite3MPrintf(tls, db, ts+9577, /* "too many attache..." */ - libc.VaList(bp, *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(7)*4)))) + libc.VaList(bp, *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 7*4)))) goto attach_error __7: ; @@ -89544,10 +88801,10 @@ __13: // or may not be initialized. *(*uint32)(unsafe.Pointer(bp + 24 /* flags */)) = (*Sqlite3)(unsafe.Pointer(db)).FopenFlags rc = Xsqlite3ParseUri(tls, (*Sqlite3_vfs)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpVfs)).FzName, zFile, bp+24 /* &flags */, bp+32 /* &pVfs */, bp+40 /* &zPath */, bp+48 /* &zErr */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __16 } - if !(rc == 7) { + if !(rc == SQLITE_NOMEM) { goto __17 } Xsqlite3OomFault(tls, db) @@ -89559,28 +88816,28 @@ __17: __16: ; - *(*uint32)(unsafe.Pointer(bp + 24 /* flags */)) |= uint32(0x00000100) + *(*uint32)(unsafe.Pointer(bp + 24 /* flags */)) |= SQLITE_OPEN_MAIN_DB rc = Xsqlite3BtreeOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pVfs */)), *(*uintptr)(unsafe.Pointer(bp + 40 /* zPath */)), db, (pNew + 8 /* &.pBt */), 0, int32(*(*uint32)(unsafe.Pointer(bp + 24 /* flags */)))) (*Sqlite3)(unsafe.Pointer(db)).FnDb++ (*Db)(unsafe.Pointer(pNew)).FzDbSName = Xsqlite3DbStrDup(tls, db, zName) __4: ; (*Sqlite3)(unsafe.Pointer(db)).FnoSharedCache = U8(0) - if !(rc == 19) { + if !(rc == SQLITE_CONSTRAINT) { goto __18 } - rc = 1 + rc = SQLITE_ERROR *(*uintptr)(unsafe.Pointer(bp + 56 /* zErrDyn */)) = Xsqlite3MPrintf(tls, db, ts+9644 /* "database is alre..." */, 0) goto __19 __18: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __20 } (*Db)(unsafe.Pointer(pNew)).FpSchema = Xsqlite3SchemaGet(tls, db, (*Db)(unsafe.Pointer(pNew)).FpBt) if !(!(int32((*Db)(unsafe.Pointer(pNew)).FpSchema) != 0)) { goto __21 } - rc = 7 + rc = SQLITE_NOMEM goto __22 __21: if !(((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pNew)).FpSchema)).Ffile_format != 0) && (int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pNew)).FpSchema)).Fenc) != (int32((*Sqlite3)(unsafe.Pointer(db)).Fenc)))) { @@ -89588,7 +88845,7 @@ __21: } *(*uintptr)(unsafe.Pointer(bp + 56 /* zErrDyn */)) = Xsqlite3MPrintf(tls, db, ts+9673 /* "attached databas..." */, 0) - rc = 1 + rc = SQLITE_ERROR __23: ; __22: @@ -89597,19 +88854,19 @@ __22: pPager = Xsqlite3BtreePager(tls, (*Db)(unsafe.Pointer(pNew)).FpBt) Xsqlite3PagerLockingMode(tls, pPager, int32((*Sqlite3)(unsafe.Pointer(db)).FdfltLockMode)) Xsqlite3BtreeSecureDelete(tls, (*Db)(unsafe.Pointer(pNew)).FpBt, - Xsqlite3BtreeSecureDelete(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt, -1)) + Xsqlite3BtreeSecureDelete(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt, -1)) Xsqlite3BtreeSetPagerFlags(tls, (*Db)(unsafe.Pointer(pNew)).FpBt, - (uint32(uint64(0x03) | ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x38))))) + (uint32(PAGER_SYNCHRONOUS_FULL | ((*Sqlite3)(unsafe.Pointer(db)).Fflags & PAGER_FLAGS_MASK)))) Xsqlite3BtreeLeave(tls, (*Db)(unsafe.Pointer(pNew)).FpBt) __20: ; __19: ; - (*Db)(unsafe.Pointer(pNew)).Fsafety_level = (U8(2 + 1)) - if !((rc == 0) && ((*Db)(unsafe.Pointer(pNew)).FzDbSName == uintptr(0))) { + (*Db)(unsafe.Pointer(pNew)).Fsafety_level = (U8(SQLITE_DEFAULT_SYNCHRONOUS + 1)) + if !((rc == SQLITE_OK) && ((*Db)(unsafe.Pointer(pNew)).FzDbSName == uintptr(0))) { goto __24 } - rc = 7 + rc = SQLITE_NOMEM __24: ; Xsqlite3_free_filename(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* zPath */))) @@ -89618,12 +88875,12 @@ __24: // If this fails, or if opening the file failed, then close the file and // remove the entry from the db->aDb[] array. i.e. put everything back the // way we found it. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __25 } Xsqlite3BtreeEnterAll(tls, db) (*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = U8(0) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (^libc.Uint32FromInt32(0x0010)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaKnownOk))) if !(!(0 != 0)) { goto __26 } @@ -89652,7 +88909,7 @@ __29: ; Xsqlite3ResetAllSchemasOfConnection(tls, db) (*Sqlite3)(unsafe.Pointer(db)).FnDb = iDb - if !((rc == 7) || (rc == (10 | (int32(12) << 8)))) { + if !((rc == SQLITE_NOMEM) || (rc == (SQLITE_IOERR | (int32(12) << 8)))) { goto __30 } Xsqlite3OomFault(tls, db) @@ -89710,7 +88967,7 @@ func detachFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { / // var zErr [128]int8 at bp+24, 128 var pTrig uintptr - zName = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zName = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) db = Xsqlite3_context_db_handle(tls, context) pDb = uintptr(0) @@ -89773,7 +89030,7 @@ __9: // If any TEMP triggers reference the schema being detached, move those // triggers to reference the TEMP schema itself. - pEntry = (*Hash)(unsafe.Pointer(((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema + 56 /* &.trigHash */))).Ffirst + pEntry = (*Hash)(unsafe.Pointer(((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema + 56 /* &.trigHash */))).Ffirst __10: if !(pEntry != 0) { goto __11 @@ -89824,7 +89081,7 @@ __1: libc.Xmemset(tls, bp /* &sName */, 0, uint64(unsafe.Sizeof(NameContext{}))) (*NameContext)(unsafe.Pointer(bp /* &sName */)).FpParse = pParse - if !(((0 != (libc.AssignInt32(&rc, resolveAttachExpr(tls, bp /* &sName */, pFilename)))) || (0 != (libc.AssignInt32(&rc, resolveAttachExpr(tls, bp /* &sName */, pDbname))))) || (0 != (libc.AssignInt32(&rc, resolveAttachExpr(tls, bp /* &sName */, pKey))))) { + if !(((SQLITE_OK != (libc.AssignInt32(&rc, resolveAttachExpr(tls, bp /* &sName */, pFilename)))) || (SQLITE_OK != (libc.AssignInt32(&rc, resolveAttachExpr(tls, bp /* &sName */, pDbname))))) || (SQLITE_OK != (libc.AssignInt32(&rc, resolveAttachExpr(tls, bp /* &sName */, pKey))))) { goto __2 } goto attach_end @@ -89834,7 +89091,7 @@ __2: if !(pAuthArg != 0) { goto __3 } - if !(int32((*Expr)(unsafe.Pointer(pAuthArg)).Fop) == 115) { + if !(int32((*Expr)(unsafe.Pointer(pAuthArg)).Fop) == TK_STRING) { goto __4 } zAuthArg = *(*uintptr)(unsafe.Pointer(pAuthArg + 8 /* &.u */)) @@ -89844,7 +89101,7 @@ __4: __5: ; rc = Xsqlite3AuthCheck(tls, pParse, type1, zAuthArg, uintptr(0), uintptr(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __6 } goto attach_end @@ -89867,7 +89124,7 @@ __3: // Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this // statement only). For DETACH, set it to false (expire all existing // statements). - Xsqlite3VdbeAddOp1(tls, v, 158, (libc.Bool32(type1 == 24))) + Xsqlite3VdbeAddOp1(tls, v, OP_Expire, (libc.Bool32(type1 == SQLITE_ATTACH))) __7: ; @@ -89881,57 +89138,27 @@ attach_end: // // DETACH pDbname func Xsqlite3Detach(tls *libc.TLS, pParse uintptr, pDbname uintptr) { /* sqlite3.c:109892:21: */ - codeAttach(tls, pParse, 25, uintptr(unsafe.Pointer(&detach_func)), pDbname, uintptr(0), uintptr(0), pDbname) + codeAttach(tls, pParse, SQLITE_DETACH, uintptr(unsafe.Pointer(&detach_func)), pDbname, uintptr(0), uintptr(0), pDbname) } var detach_func = FuncDef{ - FnArg: int8(1), - FfuncFlags:// nArg - U32(1), - FpUserData:// funcFlags - uintptr(0), - FpNext:// pUserData - uintptr(0), - FxSFunc:// pNext - 0, - FxFinalize:// xSFunc - uintptr(0), - FxValue:// xFinalize - uintptr(0), - FxInverse: uintptr(0), - FzName:// xValue, xInverse - ts + 9838, /* "sqlite_detach" */ // zName - Fu:// zName - struct{ FpHash uintptr }{}, -} /* sqlite3.c:109893:24 */ + FnArg: int8(1), // nArg + FfuncFlags: SQLITE_UTF8, // pNext + FxSFunc: 0, // xValue, xInverse + FzName: ts + 9838 /* "sqlite_detach" */} /* sqlite3.c:109893:24 */ // Called by the parser to compile an ATTACH statement. // // ATTACH p AS pDbname KEY pKey func Xsqlite3Attach(tls *libc.TLS, pParse uintptr, p uintptr, pDbname uintptr, pKey uintptr) { /* sqlite3.c:109912:21: */ - codeAttach(tls, pParse, 24, uintptr(unsafe.Pointer(&attach_func)), p, p, pDbname, pKey) + codeAttach(tls, pParse, SQLITE_ATTACH, uintptr(unsafe.Pointer(&attach_func)), p, p, pDbname, pKey) } var attach_func = FuncDef{ - FnArg: int8(3), - FfuncFlags:// nArg - U32(1), - FpUserData:// funcFlags - uintptr(0), - FpNext:// pUserData - uintptr(0), - FxSFunc:// pNext - 0, - FxFinalize:// xSFunc - uintptr(0), - FxValue:// xFinalize - uintptr(0), - FxInverse: uintptr(0), - FzName:// xValue, xInverse - ts + 9852, /* "sqlite_attach" */ // zName - Fu:// zName - struct{ FpHash uintptr }{}, -} /* sqlite3.c:109913:24 */ + FnArg: int8(3), // nArg + FfuncFlags: SQLITE_UTF8, // pNext + FxSFunc: 0, // xValue, xInverse + FzName: ts + 9852 /* "sqlite_attach" */} /* sqlite3.c:109913:24 */ // Initialize a DbFixer structure. This routine must be called prior // to passing the structure to one of the sqliteFixAAAA() routines below. @@ -90056,20 +89283,20 @@ func Xsqlite3FixExpr(tls *libc.TLS, pFix uintptr, pExpr uintptr) int32 { /* sqli for pExpr != 0 { if !(int32((*DbFixer)(unsafe.Pointer(pFix)).FbTemp) != 0) { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x40000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_FromDDL) } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 153 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_VARIABLE { if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*DbFixer)(unsafe.Pointer(pFix)).FpParse)).Fdb)).Finit.Fbusy != 0 { - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(119) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_NULL } else { Xsqlite3ErrorMsg(tls, (*DbFixer)(unsafe.Pointer(pFix)).FpParse, ts+9912 /* "%s cannot use va..." */, libc.VaList(bp, (*DbFixer)(unsafe.Pointer(pFix)).FzType)) return 1 } } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x004000 | 0x800000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_TokenOnly | EP_Leaf))) != U32(0) { break } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { if Xsqlite3FixSelect(tls, pFix, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) != 0 { return 1 } @@ -90215,14 +89442,14 @@ func Xsqlite3_set_authorizer(tls *libc.TLS, db uintptr, xAuth uintptr, pArg uint Xsqlite3ExpirePreparedStatements(tls, db, 1) } Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // Write an error message into pParse->zErrMsg that explains that the // user-supplied authorization function returned an illegal value. func sqliteAuthBadReturnCode(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110208:13: */ Xsqlite3ErrorMsg(tls, pParse, ts+9936 /* "authorizer malfu..." */, 0) - (*Parse)(unsafe.Pointer(pParse)).Frc = 1 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR } // Invoke the authorization callback for permission to read column zCol from @@ -90241,17 +89468,17 @@ func Xsqlite3AuthReadCol(tls *libc.TLS, pParse uintptr, zTab uintptr, zCol uintp var rc int32 // Auth callback return code if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 { - return 0 + return SQLITE_OK } - rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 488 /* &.xAuth */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpAuthArg, 20, zTab, zCol, zDb, (*Parse)(unsafe.Pointer(pParse)).FzAuthContext) - if rc == 1 { + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 488 /* &.xAuth */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpAuthArg, SQLITE_READ, zTab, zCol, zDb, (*Parse)(unsafe.Pointer(pParse)).FzAuthContext) + if rc == SQLITE_DENY { var z uintptr = Xsqlite3_mprintf(tls, ts+9959 /* "%s.%s" */, libc.VaList(bp, zTab, zCol)) if ((*Sqlite3)(unsafe.Pointer(db)).FnDb > 2) || (iDb != 0) { z = Xsqlite3_mprintf(tls, ts+9965 /* "%s.%z" */, libc.VaList(bp+16, zDb, z)) } Xsqlite3ErrorMsg(tls, pParse, ts+9971 /* "access to %z is ..." */, libc.VaList(bp+32, z)) - (*Parse)(unsafe.Pointer(pParse)).Frc = 23 - } else if (rc != 2) && (rc != 0) { + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_AUTH + } else if (rc != SQLITE_IGNORE) && (rc != SQLITE_OK) { sqliteAuthBadReturnCode(tls, pParse) } return rc @@ -90282,7 +89509,7 @@ func Xsqlite3AuthRead(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSchema uint return } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 77 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_TRIGGER { pTab = (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab } else { @@ -90308,8 +89535,8 @@ func Xsqlite3AuthRead(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSchema uint zCol = ts + 6512 /* "ROWID" */ } - if 2 == Xsqlite3AuthReadCol(tls, pParse, (*Table)(unsafe.Pointer(pTab)).FzName, zCol, iDb) { - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(119) + if SQLITE_IGNORE == Xsqlite3AuthReadCol(tls, pParse, (*Table)(unsafe.Pointer(pTab)).FzName, zCol, iDb) { + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_NULL } } @@ -90324,12 +89551,12 @@ func Xsqlite3AuthCheck(tls *libc.TLS, pParse uintptr, code int32, zArg1 uintptr, // Don't do any authorization checks if the database is initialising // or if the parser is being invoked from within sqlite3_declare_vtab. - if ((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0) || (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != 0) { - return 0 + if ((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0) || (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL) { + return SQLITE_OK } if (*Sqlite3)(unsafe.Pointer(db)).FxAuth == uintptr(0) { - return 0 + return SQLITE_OK } // EVIDENCE-OF: R-43249-19882 The third through sixth parameters to the @@ -90340,11 +89567,11 @@ func Xsqlite3AuthCheck(tls *libc.TLS, pParse uintptr, code int32, zArg1 uintptr, // parameters can be either NULL or a string. rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 488 /* &.xAuth */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpAuthArg, code, zArg1, zArg2, zArg3, (*Parse)(unsafe.Pointer(pParse)).FzAuthContext) - if rc == 1 { + if rc == SQLITE_DENY { Xsqlite3ErrorMsg(tls, pParse, ts+9998 /* "not authorized" */, 0) - (*Parse)(unsafe.Pointer(pParse)).Frc = 23 - } else if (rc != 0) && (rc != 2) { - rc = 1 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_AUTH + } else if (rc != SQLITE_OK) && (rc != SQLITE_IGNORE) { + rc = SQLITE_DENY sqliteAuthBadReturnCode(tls, pParse) } return rc @@ -90428,7 +89655,7 @@ func codeTableLocks(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110485:13: */ for i = 0; i < (*Parse)(unsafe.Pointer(pParse)).FnTableLock; i++ { var p uintptr = ((*Parse)(unsafe.Pointer(pParse)).FaTableLock + uintptr(i)*24) var p1 int32 = (*TableLock)(unsafe.Pointer(p)).FiDb - Xsqlite3VdbeAddOp4(tls, pVdbe, 161, p1, int32((*TableLock)(unsafe.Pointer(p)).FiTab), int32((*TableLock)(unsafe.Pointer(p)).FisWriteLock), + Xsqlite3VdbeAddOp4(tls, pVdbe, OP_TableLock, p1, int32((*TableLock)(unsafe.Pointer(p)).FiTab), int32((*TableLock)(unsafe.Pointer(p)).FisWriteLock), (*TableLock)(unsafe.Pointer(p)).FzLockName, -1) } } @@ -90454,8 +89681,8 @@ func Xsqlite3FinishCoding(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110526:2 return } if ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) || ((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) { - if (*Parse)(unsafe.Pointer(pParse)).Frc == 0 { - (*Parse)(unsafe.Pointer(pParse)).Frc = 1 + if (*Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR } return } @@ -90465,7 +89692,7 @@ func Xsqlite3FinishCoding(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110526:2 v = Xsqlite3GetVdbe(tls, pParse) if v != 0 { - Xsqlite3VdbeAddOp0(tls, v, 68) + Xsqlite3VdbeAddOp0(tls, v, OP_Halt) // The cookie mask contains one bit for each database file open. // (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are @@ -90486,8 +89713,8 @@ func Xsqlite3FinishCoding(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110526:2 Xsqlite3VdbeUsesBtree(tls, v, iDb) pSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpSchema Xsqlite3VdbeAddOp4Int(tls, v, - 2, // Opcode - iDb, // P1 + OP_Transaction, // Opcode + iDb, // P1 (libc.Bool32((((*Parse)(unsafe.Pointer(pParse)).FwriteMask) & (YDbMask((YDbMask(1))) << (iDb))) != YDbMask(0))), // P2 (*Schema)(unsafe.Pointer(pSchema)).Fschema_cookie, // P3 (*Schema)(unsafe.Pointer(pSchema)).FiGeneration) @@ -90498,7 +89725,7 @@ func Xsqlite3FinishCoding(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110526:2 } for i = 0; i < (*Parse)(unsafe.Pointer(pParse)).FnVtabLock; i++ { var vtab uintptr = Xsqlite3GetVTable(tls, db, *(*uintptr)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).FapVtabLock + uintptr(i)*8))) - Xsqlite3VdbeAddOp4(tls, v, 162, 0, 0, 0, vtab, -12) + Xsqlite3VdbeAddOp4(tls, v, OP_VBegin, 0, 0, 0, vtab, -12) } (*Parse)(unsafe.Pointer(pParse)).FnVtabLock = 0 @@ -90538,9 +89765,9 @@ func Xsqlite3FinishCoding(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110526:2 // See ticket [a696379c1f08866] Xsqlite3VdbeMakeReady(tls, v, pParse) - (*Parse)(unsafe.Pointer(pParse)).Frc = 101 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_DONE } else { - (*Parse)(unsafe.Pointer(pParse)).Frc = 1 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR } } @@ -90577,7 +89804,7 @@ func Xsqlite3NestedParse(tls *libc.TLS, pParse uintptr, zFormat uintptr, va uint // exceeds SQLITE_LIMIT_LENGTH. In the latter case, we need to set // an error if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) { - (*Parse)(unsafe.Pointer(pParse)).Frc = 18 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_TOOBIG } (*Parse)(unsafe.Pointer(pParse)).FnErr++ return @@ -90626,14 +89853,14 @@ func Xsqlite3FindTable(tls *libc.TLS, db uintptr, zName uintptr, zDatabase uintp p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).FpSchema + 8 /* &.tblHash */), zName) if (p == uintptr(0)) && (Xsqlite3_strnicmp(tls, zName, ts+6905 /* "sqlite_" */, 7) == 0) { if i == 1 { - if ((Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+10013 /* "sqlite_temp_sche..." */ +uintptr(7))) == 0) || - (Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+10032 /* "sqlite_schema" */ +uintptr(7))) == 0)) || - (Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+4780 /* "sqlite_master" */ +uintptr(7))) == 0) { - p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema + 8 /* &.tblHash */), + if ((Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+10013 /* "sqlite_temp_sche..." */ +7)) == 0) || + (Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+10032 /* "sqlite_schema" */ +7)) == 0)) || + (Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+4780 /* "sqlite_master" */ +7)) == 0) { + p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema + 8 /* &.tblHash */), ts+10046 /* "sqlite_temp_mast..." */) } } else { - if Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+10032 /* "sqlite_schema" */ +uintptr(7))) == 0 { + if Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+10032 /* "sqlite_schema" */ +7)) == 0 { p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).FpSchema + 8 /* &.tblHash */), ts+4780 /* "sqlite_master" */) } @@ -90641,12 +89868,12 @@ func Xsqlite3FindTable(tls *libc.TLS, db uintptr, zName uintptr, zDatabase uintp } } else { // Match against TEMP first - p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema + 8 /* &.tblHash */), zName) + p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema + 8 /* &.tblHash */), zName) if p != 0 { return p } // The main database is second - p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpSchema + 8 /* &.tblHash */), zName) + p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema + 8 /* &.tblHash */), zName) if p != 0 { return p } @@ -90659,10 +89886,10 @@ func Xsqlite3FindTable(tls *libc.TLS, db uintptr, zName uintptr, zDatabase uintp } } if (p == uintptr(0)) && (Xsqlite3_strnicmp(tls, zName, ts+6905 /* "sqlite_" */, 7) == 0) { - if Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+10032 /* "sqlite_schema" */ +uintptr(7))) == 0 { - p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpSchema + 8 /* &.tblHash */), ts+4780 /* "sqlite_master" */) - } else if Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+10013 /* "sqlite_temp_sche..." */ +uintptr(7))) == 0 { - p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema + 8 /* &.tblHash */), + if Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+10032 /* "sqlite_schema" */ +7)) == 0 { + p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema + 8 /* &.tblHash */), ts+4780 /* "sqlite_master" */) + } else if Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+10013 /* "sqlite_temp_sche..." */ +7)) == 0 { + p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema + 8 /* &.tblHash */), ts+10046 /* "sqlite_temp_mast..." */) } } @@ -90687,8 +89914,8 @@ func Xsqlite3LocateTable(tls *libc.TLS, pParse uintptr, flags U32, zName uintptr // Read the database schema. If an error occurs, leave an error message // and code in pParse and return NULL. - if (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0010)) == U32(0)) && - (0 != Xsqlite3ReadSchema(tls, pParse)) { + if (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_SchemaKnownOk) == U32(0)) && + (SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) { return uintptr(0) } @@ -90706,7 +89933,7 @@ func Xsqlite3LocateTable(tls *libc.TLS, pParse uintptr, flags U32, zName uintptr return (*Module)(unsafe.Pointer(pMod)).FpEpoTab } } - if (flags & U32(0x02)) != 0 { + if (flags & LOCATE_NOERR) != 0 { return uintptr(0) } (*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1) @@ -90716,7 +89943,7 @@ func Xsqlite3LocateTable(tls *libc.TLS, pParse uintptr, flags U32, zName uintptr if p == uintptr(0) { var zMsg uintptr - if (flags & U32(0x01)) != 0 { + if (flags & LOCATE_VIEW) != 0 { zMsg = ts + 10073 /* "no such view" */ } else { zMsg = ts + 10086 /* "no such table" */ @@ -90765,7 +89992,7 @@ func Xsqlite3FindIndex(tls *libc.TLS, db uintptr, zName uintptr, zDb uintptr) ui var i int32 // All mutexes are required for schema access. Make sure we hold them. - for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { + for i = OMIT_TEMPDB; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { var j int32 if i < 2 { j = (i ^ 1) @@ -90826,7 +90053,7 @@ func Xsqlite3UnlinkAndDeleteIndex(tls *libc.TLS, db uintptr, iDb int32, zIdxName } Xsqlite3FreeIndex(tls, db, pIndex) } - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) } // Look through the list of open database files in db->aDb[] and if @@ -90866,14 +90093,14 @@ func Xsqlite3ResetOneSchema(tls *libc.TLS, db uintptr, iDb int32) { /* sqlite3.c if iDb >= 0 { - *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(iDb)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((0x0008)) - *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(1)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((0x0008)) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (^libc.Uint32FromInt32(0x0010)) + *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(iDb)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((DB_ResetWanted)) + *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+1*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((DB_ResetWanted)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaKnownOk))) } if (*Sqlite3)(unsafe.Pointer(db)).FnSchemaLock == U32(0) { for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { - if (int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(i)*32)).FpSchema)).FschemaFlags) & (0x0008)) == (0x0008) { + if (int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(i)*32)).FpSchema)).FschemaFlags) & (DB_ResetWanted)) == (DB_ResetWanted) { Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).FpSchema) } } @@ -90891,11 +90118,11 @@ func Xsqlite3ResetAllSchemasOfConnection(tls *libc.TLS, db uintptr) { /* sqlite3 if (*Sqlite3)(unsafe.Pointer(db)).FnSchemaLock == U32(0) { Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer(pDb)).FpSchema) } else { - *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(i)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(i)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((DB_ResetWanted)) } } } - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (^libc.Uint32FromInt32((0x0001 | 0x0010))) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32((DBFLAG_SchemaChange | DBFLAG_SchemaKnownOk)))) Xsqlite3VtabUnlockList(tls, db) Xsqlite3BtreeLeaveAll(tls, db) if (*Sqlite3)(unsafe.Pointer(db)).FnSchemaLock == U32(0) { @@ -90905,7 +90132,7 @@ func Xsqlite3ResetAllSchemasOfConnection(tls *libc.TLS, db uintptr) { /* sqlite3 // This routine is called when a commit occurs. func Xsqlite3CommitInternalChanges(tls *libc.TLS, db uintptr) { /* sqlite3.c:111019:21: */ - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (^libc.Uint32FromInt32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaChange))) } // Delete memory allocated for the column names of a table or view (the @@ -91006,7 +90233,7 @@ func Xsqlite3UnlinkAndDeleteTable(tls *libc.TLS, db uintptr, iDb int32, zTabName pDb = ((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32) p = Xsqlite3HashInsert(tls, ((*Db)(unsafe.Pointer(pDb)).FpSchema + 8 /* &.tblHash */), zTabName, uintptr(0)) Xsqlite3DeleteTable(tls, db, p) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) } // Given a token, return a string that consists of the text of that @@ -91035,8 +90262,8 @@ func Xsqlite3NameFromToken(tls *libc.TLS, db uintptr, pName uintptr) uintptr { / // writing. The table is opened using cursor 0. func Xsqlite3OpenSchemaTable(tls *libc.TLS, p uintptr, iDb int32) { /* sqlite3.c:111163:21: */ var v uintptr = Xsqlite3GetVdbe(tls, p) - Xsqlite3TableLock(tls, p, iDb, uint32(1), uint8(1), ts+4780 /* "sqlite_master" */) - Xsqlite3VdbeAddOp4Int(tls, v, 97, 0, 1, iDb, 5) + Xsqlite3TableLock(tls, p, iDb, SCHEMA_ROOT, uint8(1), ts+4780 /* "sqlite_master" */) + Xsqlite3VdbeAddOp4Int(tls, v, OP_OpenWrite, 0, SCHEMA_ROOT, iDb, 5) if (*Parse)(unsafe.Pointer(p)).FnTab == 0 { (*Parse)(unsafe.Pointer(p)).FnTab = 1 } @@ -91135,7 +90362,7 @@ func Xsqlite3TwoPartName(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 u // True if PRAGMA writable_schema is ON func Xsqlite3WritableSchema(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:111256:20: */ - return (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & (uint64(0x00000001 | 0x10000000))) == uint64(0x00000001))) + return (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & (uint64(SQLITE_WriteSchema | SQLITE_Defensive))) == SQLITE_WriteSchema)) } // This routine is used to check if the UTF-8 string zName is a legal @@ -91156,31 +90383,31 @@ func Xsqlite3CheckObjectName(tls *libc.TLS, pParse uintptr, zName uintptr, zType ((uint32(int32(*(*uint8)(unsafe.Pointer((db + 176 /* &.init */) + 8 /* &.imposterTable */)) & 0x2 >> 1))) != 0)) || !(int32(Xsqlite3Config.FbExtraSchemaChecks) != 0) { // Skip these error checks for writable_schema=ON - return 0 + return SQLITE_OK } if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 { - if ((Xsqlite3_stricmp(tls, zType, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit + uintptr(0)*8))) != 0) || - (Xsqlite3_stricmp(tls, zName, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit + uintptr(1)*8))) != 0)) || - (Xsqlite3_stricmp(tls, zTblName, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit + uintptr(2)*8))) != 0) { + if ((Xsqlite3_stricmp(tls, zType, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit))) != 0) || + (Xsqlite3_stricmp(tls, zName, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit + 1*8))) != 0)) || + (Xsqlite3_stricmp(tls, zTblName, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit + 2*8))) != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+703 /* "" */, 0) // corruptSchema() will supply the error - return 1 + return SQLITE_ERROR } } else { if ((int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0) && (0 == Xsqlite3_strnicmp(tls, zName, ts+6905 /* "sqlite_" */, 7))) || ((Xsqlite3ReadOnlyShadowTables(tls, db) != 0) && (Xsqlite3ShadowTableName(tls, db, zName) != 0)) { Xsqlite3ErrorMsg(tls, pParse, ts+10137, /* "object name rese..." */ libc.VaList(bp, zName)) - return 1 + return SQLITE_ERROR } } - return 0 + return SQLITE_OK } // Return the PRIMARY KEY index of a table func Xsqlite3PrimaryKeyIndex(tls *libc.TLS, pTab uintptr) uintptr { /* sqlite3.c:111316:22: */ var p uintptr - for p = (*Table)(unsafe.Pointer(pTab)).FpIndex; (p != 0) && !((int32(*(*uint16)(unsafe.Pointer((p) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2); p = (*Index)(unsafe.Pointer(p)).FpNext { + for p = (*Table)(unsafe.Pointer(pTab)).FpIndex; (p != 0) && !((int32(*(*uint16)(unsafe.Pointer((p) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY); p = (*Index)(unsafe.Pointer(p)).FpNext { } return p } @@ -91210,10 +90437,10 @@ func Xsqlite3TableColumnToIndex(tls *libc.TLS, pIdx uintptr, iCol I16) I16 { /* // // If SQLITE_OMIT_GENERATED_COLUMNS, this routine is a no-op macro. func Xsqlite3StorageColumnToTable(tls *libc.TLS, pTab uintptr, iCol I16) I16 { /* sqlite3.c:111348:20: */ - if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0020)) != 0 { + if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasVirtual) != 0 { var i int32 for i = 0; i <= int32(iCol); i++ { - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) != 0 { + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0 { iCol++ } } @@ -91260,17 +90487,17 @@ func Xsqlite3TableColumnToStorage(tls *libc.TLS, pTab uintptr, iCol I16) I16 { / var i int32 var n I16 - if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0020)) == U32(0)) || (int32(iCol) < 0) { + if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasVirtual) == U32(0)) || (int32(iCol) < 0) { return iCol } i = 0 n = int16(0) for ; i < int32(iCol); i++ { - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) == 0 { + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) == 0 { n++ } } - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) != 0 { + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0 { // iCol is a virtual column itself return (I16((int32((*Table)(unsafe.Pointer(pTab)).FnNVCol) + i) - int32(n))) } else { @@ -91353,7 +90580,7 @@ __4: __5: ; zName = Xsqlite3NameFromToken(tls, db, *(*uintptr)(unsafe.Pointer(bp + 16 /* pName */))) - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __6 } Xsqlite3RenameTokenMap(tls, pParse, zName, *(*uintptr)(unsafe.Pointer(bp + 16 /* pName */))) @@ -91387,7 +90614,7 @@ __9: ; zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName - if !(Xsqlite3AuthCheck(tls, pParse, 18, func() uintptr { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_INSERT, func() uintptr { if (!(0 != 0)) && (isTemp == 1) { return ts + 10046 /* "sqlite_temp_mast..." */ } @@ -91412,11 +90639,11 @@ __11: // to an sqlite3_declare_vtab() call. In that case only the column names // and types will be used, so there is no need to test for namespace // collisions. - if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != 0)) { + if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL)) { goto __12 } zDb1 = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName - if !(0 != Xsqlite3ReadSchema(tls, pParse)) { + if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) { goto __13 } goto begin_table_error @@ -91454,7 +90681,7 @@ __12: goto __18 } - (*Parse)(unsafe.Pointer(pParse)).Frc = 7 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM (*Parse)(unsafe.Pointer(pParse)).FnErr++ goto begin_table_error __18: @@ -91493,7 +90720,7 @@ __19: if !(isVirtual != 0) { goto __21 } - Xsqlite3VdbeAddOp0(tls, v, 162) + Xsqlite3VdbeAddOp0(tls, v, OP_VBegin) __21: ; @@ -91502,16 +90729,16 @@ __21: reg1 = libc.AssignPtrInt32(pParse+120 /* &.regRowid */, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)) reg2 = libc.AssignPtrInt32(pParse+124 /* &.regRoot */, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)) reg3 = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp3(tls, v, 93, iDb, reg3, 2) + Xsqlite3VdbeAddOp3(tls, v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT) Xsqlite3VdbeUsesBtree(tls, v, iDb) - addr1 = Xsqlite3VdbeAddOp1(tls, v, 18, reg3) - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000002)) != uint64(0) { + addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_If, reg3) + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_LegacyFileFmt) != uint64(0) { fileFormat = 1 } else { - fileFormat = 4 + fileFormat = SQLITE_MAX_FILE_FORMAT } - Xsqlite3VdbeAddOp3(tls, v, 94, iDb, 2, fileFormat) - Xsqlite3VdbeAddOp3(tls, v, 94, iDb, 5, int32((*Sqlite3)(unsafe.Pointer(db)).Fenc)) + Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, fileFormat) + Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, int32((*Sqlite3)(unsafe.Pointer(db)).Fenc)) Xsqlite3VdbeJumpHere(tls, v, addr1) // This just creates a place-holder record in the sqlite_schema table. @@ -91525,19 +90752,19 @@ __21: if !((isView != 0) || (isVirtual != 0)) { goto __22 } - Xsqlite3VdbeAddOp2(tls, v, 69, 0, reg2) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, reg2) goto __23 __22: - (*Parse)(unsafe.Pointer(pParse)).FaddrCrTab = Xsqlite3VdbeAddOp3(tls, v, 139, iDb, reg2, 1) + (*Parse)(unsafe.Pointer(pParse)).FaddrCrTab = Xsqlite3VdbeAddOp3(tls, v, OP_CreateBtree, iDb, reg2, BTREE_INTKEY) __23: ; Xsqlite3OpenSchemaTable(tls, pParse, iDb) - Xsqlite3VdbeAddOp2(tls, v, 120, 0, reg1) - Xsqlite3VdbeAddOp4(tls, v, 74, 6, reg3, 0, uintptr(unsafe.Pointer(&nullRow)), -1) - Xsqlite3VdbeAddOp3(tls, v, 121, 0, reg3, reg1) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x08)) - Xsqlite3VdbeAddOp0(tls, v, 116) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, 0, reg1) + Xsqlite3VdbeAddOp4(tls, v, OP_Blob, 6, reg3, 0, uintptr(unsafe.Pointer(&nullRow)), -1) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, 0, reg3, reg1) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_APPEND) + Xsqlite3VdbeAddOp0(tls, v, OP_Close) __20: ; @@ -91551,10 +90778,10 @@ begin_table_error: } var aCode = [4]U8{ - U8(2), - U8(4), - U8(8), - U8(6), + SQLITE_CREATE_TABLE, + SQLITE_CREATE_TEMP_TABLE, + SQLITE_CREATE_VIEW, + SQLITE_CREATE_TEMP_VIEW, } /* sqlite3.c:111477:21 */ var nullRow = [6]int8{int8(6), int8(0), int8(0), int8(0), int8(0), int8(0)} /* sqlite3.c:111565:23 */ @@ -91580,7 +90807,7 @@ func Xsqlite3AddColumn(tls *libc.TLS, pParse uintptr, pName uintptr, pType uintp if (libc.AssignUintptr(&p, (*Parse)(unsafe.Pointer(pParse)).FpNewTable)) == uintptr(0) { return } - if (int32((*Table)(unsafe.Pointer(p)).FnCol) + 1) > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(2)*4)) { + if (int32((*Table)(unsafe.Pointer(p)).FnCol) + 1) > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 2*4)) { Xsqlite3ErrorMsg(tls, pParse, ts+10279 /* "too many columns..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(p)).FzName)) return } @@ -91588,7 +90815,7 @@ func Xsqlite3AddColumn(tls *libc.TLS, pParse uintptr, pName uintptr, pType uintp if z == uintptr(0) { return } - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameTokenMap(tls, pParse, z, pName) } libc.Xmemcpy(tls, z, (*Token)(unsafe.Pointer(pName)).Fz, uint64((*Token)(unsafe.Pointer(pName)).Fn)) @@ -91618,7 +90845,7 @@ func Xsqlite3AddColumn(tls *libc.TLS, pParse uintptr, pName uintptr, pType uintp if (*Token)(unsafe.Pointer(pType)).Fn == uint32(0) { // If there is no type specified, columns have the default affinity // 'BLOB' with a default size of 4 bytes. - (*Column)(unsafe.Pointer(pCol)).Faffinity = int8(0x41) + (*Column)(unsafe.Pointer(pCol)).Faffinity = SQLITE_AFF_BLOB (*Column)(unsafe.Pointer(pCol)).FszEst = U8(1) } else { zType = ((z + uintptr(Xsqlite3Strlen30(tls, z))) + uintptr(1)) @@ -91626,7 +90853,7 @@ func Xsqlite3AddColumn(tls *libc.TLS, pParse uintptr, pName uintptr, pType uintp *(*int8)(unsafe.Pointer(zType + uintptr((*Token)(unsafe.Pointer(pType)).Fn))) = int8(0) Xsqlite3Dequote(tls, zType) (*Column)(unsafe.Pointer(pCol)).Faffinity = Xsqlite3AffinityType(tls, zType, pCol) - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((COLFLAG_HASTYPE)) } (*Table)(unsafe.Pointer(p)).FnCol++ (*Table)(unsafe.Pointer(p)).FnNVCol++ @@ -91646,15 +90873,15 @@ func Xsqlite3AddNotNull(tls *libc.TLS, pParse uintptr, onError int32) { /* sqlit } pCol = ((*Table)(unsafe.Pointer(p)).FaCol + uintptr((int32((*Table)(unsafe.Pointer(p)).FnCol)-1))*32) (*Column)(unsafe.Pointer(pCol)).FnotNull = U8(onError) - *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (U32(0x0800)) + *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (TF_HasNotNull) // Set the uniqNotNull flag on any UNIQUE or PK indexes already created // on this column. - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0008) != 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_UNIQUE) != 0 { var pIdx uintptr for pIdx = (*Table)(unsafe.Pointer(p)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { - if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(0)*2))) == (int32((*Table)(unsafe.Pointer(p)).FnCol) - 1) { + if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn))) == (int32((*Table)(unsafe.Pointer(p)).FnCol) - 1) { libc.SetBitFieldPtr16Uint32(pIdx+100 /* &.uniqNotNull */, uint32(1), 3, 0x8) } } @@ -91689,36 +90916,36 @@ func Xsqlite3AffinityType(tls *libc.TLS, zIn uintptr, pCol uintptr) int8 { /* sq defer tls.Free(4) var h U32 = U32(0) - var aff int8 = int8(0x43) + var aff int8 = SQLITE_AFF_NUMERIC var zChar uintptr = uintptr(0) - for *(*int8)(unsafe.Pointer(zIn + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(zIn)) != 0 { h = ((h << 8) + U32(Xsqlite3UpperToLower[((int32(*(*int8)(unsafe.Pointer(zIn))))&0xff)])) zIn++ if h == (U32((((int32('c') << 24) + (int32('h') << 16)) + (int32('a') << 8)) + 'r')) { // CHAR - aff = int8(0x42) + aff = SQLITE_AFF_TEXT zChar = zIn } else if h == (U32((((int32('c') << 24) + (int32('l') << 16)) + (int32('o') << 8)) + 'b')) { // CLOB - aff = int8(0x42) + aff = SQLITE_AFF_TEXT } else if h == (U32((((int32('t') << 24) + (int32('e') << 16)) + (int32('x') << 8)) + 't')) { // TEXT - aff = int8(0x42) + aff = SQLITE_AFF_TEXT } else if (h == (U32((((int32('b') << 24) + (int32('l') << 16)) + (int32('o') << 8)) + 'b'))) && // BLOB - ((int32(aff) == 0x43) || (int32(aff) == 0x45)) { - aff = int8(0x41) - if int32(*(*int8)(unsafe.Pointer(zIn + uintptr(0)))) == '(' { + ((int32(aff) == SQLITE_AFF_NUMERIC) || (int32(aff) == SQLITE_AFF_REAL)) { + aff = SQLITE_AFF_BLOB + if int32(*(*int8)(unsafe.Pointer(zIn))) == '(' { zChar = zIn } } else if (h == (U32((((int32('r') << 24) + (int32('e') << 16)) + (int32('a') << 8)) + 'l'))) && // REAL - (int32(aff) == 0x43) { - aff = int8(0x45) + (int32(aff) == SQLITE_AFF_NUMERIC) { + aff = SQLITE_AFF_REAL } else if (h == (U32((((int32('f') << 24) + (int32('l') << 16)) + (int32('o') << 8)) + 'a'))) && // FLOA - (int32(aff) == 0x43) { - aff = int8(0x45) + (int32(aff) == SQLITE_AFF_NUMERIC) { + aff = SQLITE_AFF_REAL } else if (h == (U32((((int32('d') << 24) + (int32('o') << 16)) + (int32('u') << 8)) + 'b'))) && // DOUB - (int32(aff) == 0x43) { - aff = int8(0x45) + (int32(aff) == SQLITE_AFF_NUMERIC) { + aff = SQLITE_AFF_REAL } else if (h & U32(0x00FFFFFF)) == (U32(((int32('i') << 16) + (int32('n') << 8)) + 't')) { // INT - aff = int8(0x44) + aff = SQLITE_AFF_INTEGER break } } @@ -91727,10 +90954,10 @@ func Xsqlite3AffinityType(tls *libc.TLS, zIn uintptr, pCol uintptr) int8 { /* sq // estimate is scaled so that the size of an integer is 1. if pCol != 0 { *(*int32)(unsafe.Pointer(bp /* v */)) = 0 // default size is approx 4 bytes - if int32(aff) < 0x43 { + if int32(aff) < SQLITE_AFF_NUMERIC { if zChar != 0 { - for *(*int8)(unsafe.Pointer(zChar + uintptr(0))) != 0 { - if (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zChar + uintptr(0))))]) & 0x04) != 0 { + for *(*int8)(unsafe.Pointer(zChar)) != 0 { + if (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zChar)))]) & 0x04) != 0 { // BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) Xsqlite3GetInt32(tls, zChar, bp /* &v */) break @@ -91772,7 +90999,7 @@ func Xsqlite3AddDefaultValue(tls *libc.TLS, pParse uintptr, pExpr uintptr, zStar if !(Xsqlite3ExprIsConstantOrFunction(tls, pExpr, uint8(isInit)) != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+10328, /* "default value of..." */ libc.VaList(bp, (*Column)(unsafe.Pointer(pCol)).FzName)) - } else if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0060) != 0 { + } else if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_GENERATED) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+10373 /* "cannot use DEFAU..." */, 0) } else { @@ -91782,15 +91009,15 @@ func Xsqlite3AddDefaultValue(tls *libc.TLS, pParse uintptr, pExpr uintptr, zStar Xsqlite3ExprDelete(tls, db, (*Column)(unsafe.Pointer(pCol)).FpDflt) libc.Xmemset(tls, bp+8 /* &x */, 0, uint64(unsafe.Sizeof(Expr{}))) - (*Expr)(unsafe.Pointer(bp + 8 /* &x */)).Fop = U8(178) + (*Expr)(unsafe.Pointer(bp + 8 /* &x */)).Fop = TK_SPAN *(*uintptr)(unsafe.Pointer(bp + 8 /* &x */ + 8 /* &.u */)) = Xsqlite3DbSpanDup(tls, db, zStart, zEnd) (*Expr)(unsafe.Pointer(bp + 8 /* &x */)).FpLeft = pExpr - (*Expr)(unsafe.Pointer(bp + 8 /* &x */)).Fflags = U32(0x001000) - (*Column)(unsafe.Pointer(pCol)).FpDflt = Xsqlite3ExprDup(tls, db, bp+8 /* &x */, 0x0001) + (*Expr)(unsafe.Pointer(bp + 8 /* &x */)).Fflags = EP_Skip + (*Column)(unsafe.Pointer(pCol)).FpDflt = Xsqlite3ExprDup(tls, db, bp+8 /* &x */, EXPRDUP_REDUCE) Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 8 /* &x */ + 8 /* &.u */))) } } - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameExprUnmap(tls, pParse, pExpr) } Xsqlite3ExprDelete(tls, db, pExpr) @@ -91811,17 +91038,17 @@ func Xsqlite3AddDefaultValue(tls *libc.TLS, pParse uintptr, pExpr uintptr, zStar // If the expression is anything other than TK_STRING, the expression is // unchanged. func sqlite3StringToId(tls *libc.TLS, p uintptr) { /* sqlite3.c:111898:13: */ - if int32((*Expr)(unsafe.Pointer(p)).Fop) == 115 { - (*Expr)(unsafe.Pointer(p)).Fop = U8(59) - } else if (int32((*Expr)(unsafe.Pointer(p)).Fop) == 111) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fop) == 115) { - (*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fop = U8(59) + if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_STRING { + (*Expr)(unsafe.Pointer(p)).Fop = TK_ID + } else if (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLLATE) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fop) == TK_STRING) { + (*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fop = TK_ID } } // Tag the given column as being part of the PRIMARY KEY func makeColumnPartOfPrimaryKey(tls *libc.TLS, pParse uintptr, pCol uintptr) { /* sqlite3.c:111909:13: */ - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((0x0001)) - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0060) != 0 { + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((COLFLAG_PRIMKEY)) + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_GENERATED) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+10414 /* "generated column..." */, 0) @@ -91865,7 +91092,7 @@ func Xsqlite3AddPrimaryKey(tls *libc.TLS, pParse uintptr, pList uintptr, onError goto primary_key_exit __1: ; - if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0004)) != 0) { + if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasPrimaryKey) != 0) { goto __2 } Xsqlite3ErrorMsg(tls, pParse, @@ -91873,7 +91100,7 @@ __1: goto primary_key_exit __2: ; - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0004)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (TF_HasPrimaryKey) if !(pList == uintptr(0)) { goto __3 } @@ -91892,7 +91119,7 @@ __5: pCExpr = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FpExpr) sqlite3StringToId(tls, pCExpr) - if !(int32((*Expr)(unsafe.Pointer(pCExpr)).Fop) == 59) { + if !(int32((*Expr)(unsafe.Pointer(pCExpr)).Fop) == TK_ID) { goto __8 } zCName = *(*uintptr)(unsafe.Pointer(pCExpr + 8 /* &.u */)) @@ -91930,24 +91157,24 @@ __4: if !((((nTerm == 1) && (pCol != 0)) && (Xsqlite3StrICmp(tls, Xsqlite3ColumnType(tls, pCol, ts+703 /* "" */), ts+10507 /* "INTEGER" */) == 0)) && - (sortOrder != 1)) { + (sortOrder != SQLITE_SO_DESC)) { goto __13 } - if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && (pList != 0)) { + if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && (pList != 0)) { goto __15 } - pCExpr1 = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(0)*32)).FpExpr) + pCExpr1 = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FpExpr) Xsqlite3RenameTokenRemap(tls, pParse, (pTab + 68 /* &.iPKey */), pCExpr1) __15: ; (*Table)(unsafe.Pointer(pTab)).FiPKey = I16(iCol) (*Table)(unsafe.Pointer(pTab)).FkeyConf = U8(onError) - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(autoInc * 0x0008)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(autoInc * TF_Autoincrement)) if !(pList != 0) { goto __16 } - (*Parse)(unsafe.Pointer(pParse)).FiPkSortOrder = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(0)*32)).FsortFlags + (*Parse)(unsafe.Pointer(pParse)).FiPkSortOrder = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FsortFlags __16: ; Xsqlite3HasExplicitNulls(tls, pParse, pList) @@ -91961,7 +91188,7 @@ __13: goto __18 __17: Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), pList, onError, uintptr(0), - uintptr(0), sortOrder, 0, uint8(2)) + uintptr(0), sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY) pList = uintptr(0) __18: ; @@ -91977,7 +91204,7 @@ primary_key_exit: func Xsqlite3AddCheckConstraint(tls *libc.TLS, pParse uintptr, pCheckExpr uintptr) { /* sqlite3.c:112014:21: */ var pTab uintptr = (*Parse)(unsafe.Pointer(pParse)).FpNewTable var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if ((pTab != 0) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == 1)) && + if ((pTab != 0) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == PARSE_MODE_DECLARE_VTAB)) && !(Xsqlite3BtreeIsReadonly(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr((*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb)*32)).FpBt) != 0) { (*Table)(unsafe.Pointer(pTab)).FpCheck = Xsqlite3ExprListAppend(tls, pParse, (*Table)(unsafe.Pointer(pTab)).FpCheck, pCheckExpr) if (*Parse)(unsafe.Pointer(pParse)).FconstraintName.Fn != 0 { @@ -92016,8 +91243,8 @@ func Xsqlite3AddCollateType(tls *libc.TLS, pParse uintptr, pToken uintptr) { /* // collation type was added. Correct this if it is the case. for pIdx = (*Table)(unsafe.Pointer(p)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { - if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(0)*2))) == i { - *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(0)*8)) = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(i)*32)).FzColl + if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn))) == i { + *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl)) = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(i)*32)).FzColl } } } else { @@ -92034,7 +91261,7 @@ func Xsqlite3AddGenerated(tls *libc.TLS, pParse uintptr, pExpr uintptr, pType ui var eType U8 var pTab uintptr var pCol uintptr - eType = U8(0x0020) + eType = COLFLAG_VIRTUAL pTab = (*Parse)(unsafe.Pointer(pParse)).FpNewTable if !(pTab == uintptr(0)) { goto __1 @@ -92044,7 +91271,7 @@ func Xsqlite3AddGenerated(tls *libc.TLS, pParse uintptr, pExpr uintptr, pType ui __1: ; pCol = ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr((int32((*Table)(unsafe.Pointer(pTab)).FnCol)-1))*32) - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == 1) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == PARSE_MODE_DECLARE_VTAB) { goto __2 } Xsqlite3ErrorMsg(tls, pParse, ts+10571 /* "virtual tables c..." */, 0) @@ -92069,7 +91296,7 @@ __5: if !(((*Token)(unsafe.Pointer(pType)).Fn == uint32(6)) && (Xsqlite3_strnicmp(tls, ts+10622 /* "stored" */, (*Token)(unsafe.Pointer(pType)).Fz, 6) == 0)) { goto __7 } - eType = U8(0x0040) + eType = COLFLAG_STORED goto __8 __7: goto generated_error @@ -92079,7 +91306,7 @@ __6: ; __4: ; - if !(int32(eType) == 0x0020) { + if !(int32(eType) == COLFLAG_VIRTUAL) { goto __9 } (*Table)(unsafe.Pointer(pTab)).FnNVCol-- @@ -92088,7 +91315,7 @@ __9: *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((int32(eType))) *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(eType)) - if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0001) != 0) { + if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_PRIMKEY) != 0) { goto __10 } makeColumnPartOfPrimaryKey(tls, pParse, pCol) // For the error message @@ -92126,7 +91353,7 @@ func Xsqlite3ChangeCookie(tls *libc.TLS, pParse uintptr, iDb int32) { /* sqlite3 var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe - Xsqlite3VdbeAddOp3(tls, v, 94, iDb, 1, + Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, (int32(uint32(1) + uint32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FpSchema)).Fschema_cookie)))) } @@ -92183,8 +91410,8 @@ func identPut(tls *libc.TLS, z uintptr, pIdx uintptr, zSignedIdent uintptr) { /* break } } - needQuote = (libc.Bool32(((((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zIdent + uintptr(0)))]) & 0x04) != 0) || - (Xsqlite3KeywordCode(tls, zIdent, j) != 59)) || + needQuote = (libc.Bool32(((((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zIdent))]) & 0x04) != 0) || + (Xsqlite3KeywordCode(tls, zIdent, j) != TK_ID)) || (int32(*(*uint8)(unsafe.Pointer(zIdent + uintptr(j)))) != 0)) || (j == 0))) @@ -92274,7 +91501,7 @@ __4: zSep = zSep2 identPut(tls, zStmt, bp+8 /* &k */, (*Column)(unsafe.Pointer(pCol)).FzName) - zType = azType1[(int32((*Column)(unsafe.Pointer(pCol)).Faffinity) - 0x41)] + zType = azType1[(int32((*Column)(unsafe.Pointer(pCol)).Faffinity) - SQLITE_AFF_BLOB)] len = Xsqlite3Strlen30(tls, zType) libc.Xmemcpy(tls, (zStmt + uintptr(*(*int32)(unsafe.Pointer(bp + 8 /* k */)))), zType, uint64(len)) @@ -92307,13 +91534,13 @@ func resizeIndexObject(tls *libc.TLS, db uintptr, pIdx uintptr, N int32) int32 { var zExtra uintptr var nByte int32 if int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) >= N { - return 0 + return SQLITE_OK } nByte = (int32(((uint64(unsafe.Sizeof(uintptr(0))) + uint64(unsafe.Sizeof(I16(0)))) + uint64(1)) * uint64(N))) zExtra = Xsqlite3DbMallocZero(tls, db, uint64(nByte)) if zExtra == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, zExtra, (*Index)(unsafe.Pointer(pIdx)).FazColl, (uint64(unsafe.Sizeof(uintptr(0))) * uint64((*Index)(unsafe.Pointer(pIdx)).FnColumn))) (*Index)(unsafe.Pointer(pIdx)).FazColl = zExtra @@ -92325,7 +91552,7 @@ func resizeIndexObject(tls *libc.TLS, db uintptr, pIdx uintptr, N int32) int32 { (*Index)(unsafe.Pointer(pIdx)).FaSortOrder = zExtra (*Index)(unsafe.Pointer(pIdx)).FnColumn = U16(N) libc.SetBitFieldPtr16Uint32(pIdx+100 /* &.isResized */, uint32(1), 4, 0x10) - return 0 + return SQLITE_OK } // Estimate the total row width for a table. @@ -92438,7 +91665,7 @@ func recomputeColumnsNotIndexed(tls *libc.TLS, pIdx uintptr) { /* sqlite3.c:1123 var pTab uintptr = (*Index)(unsafe.Pointer(pIdx)).FpTable for j = (int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) - 1); j >= 0; j-- { var x int32 = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) - if (x >= 0) && ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(x)*32)).FcolFlags) & 0x0020) == 0) { + if (x >= 0) && ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(x)*32)).FcolFlags) & COLFLAG_VIRTUAL) == 0) { if x < ((int32(uint64(unsafe.Sizeof(Bitmask(0))) * uint64(8))) - 1) { m = m | (Bitmask((uint64(1))) << (x)) @@ -92487,18 +91714,18 @@ func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { / // Mark every PRIMARY KEY column as NOT NULL (except for imposter tables) if !((int32(*(*uint8)(unsafe.Pointer(db + 176 /* &.init */ + 8 /* &.imposterTable */)) & 0x2 >> 1)) != 0) { for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0001) != 0 { - (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32)).FnotNull = U8(2) + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_PRIMKEY) != 0 { + (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32)).FnotNull = OE_Abort } } - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0800)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (TF_HasNotNull) } // Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY // into BTREE_BLOBKEY. if (*Parse)(unsafe.Pointer(pParse)).FaddrCrTab != 0 { - Xsqlite3VdbeChangeP3(tls, v, (*Parse)(unsafe.Pointer(pParse)).FaddrCrTab, 2) + Xsqlite3VdbeChangeP3(tls, v, (*Parse)(unsafe.Pointer(pParse)).FaddrCrTab, BTREE_BLOBKEY) } // Locate the PRIMARY KEY index. Or, if this table was originally @@ -92509,18 +91736,18 @@ func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { / Xsqlite3TokenInit(tls, bp /* &ipkToken */, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*Table)(unsafe.Pointer(pTab)).FiPKey)*32)).FzName) pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), - Xsqlite3ExprAlloc(tls, db, 59, bp /* &ipkToken */, 0)) + Xsqlite3ExprAlloc(tls, db, TK_ID, bp /* &ipkToken */, 0)) if pList == uintptr(0) { return } - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { - Xsqlite3RenameTokenRemap(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(0)*32)).FpExpr, (pTab + 68 /* &.iPKey */)) + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { + Xsqlite3RenameTokenRemap(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FpExpr, (pTab + 68 /* &.iPKey */)) } - (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(0)*32)).FsortFlags = (*Parse)(unsafe.Pointer(pParse)).FiPkSortOrder + (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FsortFlags = (*Parse)(unsafe.Pointer(pParse)).FiPkSortOrder (*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1) Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), pList, int32((*Table)(unsafe.Pointer(pTab)).FkeyConf), uintptr(0), uintptr(0), 0, 0, - uint8(2)) + SQLITE_IDXTYPE_PRIMARYKEY) if ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) || ((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) { return } @@ -92557,7 +91784,7 @@ func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { / // a database schema). if (v != 0) && ((*Index)(unsafe.Pointer(pPk)).Ftnum > Pgno(0)) { - Xsqlite3VdbeChangeOpcode(tls, v, int32((*Index)(unsafe.Pointer(pPk)).Ftnum), uint8(11)) + Xsqlite3VdbeChangeOpcode(tls, v, int32((*Index)(unsafe.Pointer(pPk)).Ftnum), OP_Goto) } // The root page of the PRIMARY KEY is the table root page @@ -92567,7 +91794,7 @@ func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { / // the final rowid column into one or more columns of the PRIMARY KEY. for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { var n int32 - if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2 { + if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY { continue } for i = libc.AssignInt32(&n, 0); i < nPk; i++ { @@ -92605,7 +91832,7 @@ func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { / nExtra = 0 for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { if !(hasColumn(tls, (*Index)(unsafe.Pointer(pPk)).FaiColumn, nPk, i) != 0) && - ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) == 0) { + ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) == 0) { nExtra++ } } @@ -92616,7 +91843,7 @@ func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { / j = nPk for ; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { if !(hasColumn(tls, (*Index)(unsafe.Pointer(pPk)).FaiColumn, j, i) != 0) && - ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) == 0) { + ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) == 0) { *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)) = I16(i) *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FazColl + uintptr(j)*8)) = uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)) @@ -92643,7 +91870,7 @@ func Xsqlite3IsShadowTableOf(tls *libc.TLS, db uintptr, pTab uintptr, zName uint if int32(*(*int8)(unsafe.Pointer(zName + uintptr(nName)))) != '_' { return 0 } - pMod = Xsqlite3HashFind(tls, (db + 528 /* &.aModule */), *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg + uintptr(0)*8))) + pMod = Xsqlite3HashFind(tls, (db + 528 /* &.aModule */), *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg))) if pMod == uintptr(0) { return 0 } @@ -92717,7 +91944,7 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr } if (pSelect == uintptr(0)) && (Xsqlite3ShadowTableName(tls, db, (*Table)(unsafe.Pointer(p)).FzName) != 0) { - *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (U32(0x1000)) + *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (TF_Shadow) } // If the db->init.busy is 1 it means we are reading the SQL off the @@ -92735,29 +91962,29 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr } (*Table)(unsafe.Pointer(p)).Ftnum = (*Sqlite3)(unsafe.Pointer(db)).Finit.FnewTnum if (*Table)(unsafe.Pointer(p)).Ftnum == Pgno(1) { - *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (TF_Readonly) } } // Special processing for WITHOUT ROWID Tables - if (int32(tabOpts) & 0x0080) != 0 { - if ((*Table)(unsafe.Pointer(p)).FtabFlags & U32(0x0008)) != 0 { + if (int32(tabOpts) & TF_WithoutRowid) != 0 { + if ((*Table)(unsafe.Pointer(p)).FtabFlags & TF_Autoincrement) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+10710 /* "AUTOINCREMENT no..." */, 0) return } - if ((*Table)(unsafe.Pointer(p)).FtabFlags & U32(0x0004)) == U32(0) { + if ((*Table)(unsafe.Pointer(p)).FtabFlags & TF_HasPrimaryKey) == U32(0) { Xsqlite3ErrorMsg(tls, pParse, ts+10760 /* "PRIMARY KEY miss..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(p)).FzName)) return } - *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (U32(0x0080 | 0x0200)) + *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (U32(TF_WithoutRowid | TF_NoVisibleRowid)) convertToWithoutRowidTable(tls, pParse, p) } iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(p)).FpSchema) // Resolve names in all CHECK constraint expressions. if (*Table)(unsafe.Pointer(p)).FpCheck != 0 { - Xsqlite3ResolveSelfReference(tls, pParse, p, 0x00004, uintptr(0), (*Table)(unsafe.Pointer(p)).FpCheck) + Xsqlite3ResolveSelfReference(tls, pParse, p, NC_IsCheck, uintptr(0), (*Table)(unsafe.Pointer(p)).FpCheck) if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { // If errors are seen, delete the CHECK constraints now, else they might // actually be used if PRAGMA writable_schema=ON is set. @@ -92767,16 +91994,16 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr } } - if ((*Table)(unsafe.Pointer(p)).FtabFlags & U32(0x0060)) != 0 { + if ((*Table)(unsafe.Pointer(p)).FtabFlags & TF_HasGenerated) != 0 { var ii int32 var nNG int32 = 0 for ii = 0; ii < int32((*Table)(unsafe.Pointer(p)).FnCol); ii++ { var colFlags U32 = U32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(ii)*32)).FcolFlags) - if (colFlags & U32(0x0060)) != U32(0) { + if (colFlags & COLFLAG_GENERATED) != U32(0) { var pX uintptr = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(ii)*32)).FpDflt - if Xsqlite3ResolveSelfReference(tls, pParse, p, 0x00008, pX, uintptr(0)) != 0 { + if Xsqlite3ResolveSelfReference(tls, pParse, p, NC_GenCol, pX, uintptr(0)) != 0 { // If there are errors in resolving the expression, change the // expression to a NULL. This prevents code generators that operate // on the expression from inserting extra parts into the expression @@ -92784,7 +92011,7 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr // illegal in a schema and will lead to errors or heap corruption // when the database connection closes. Xsqlite3ExprDelete(tls, db, pX) - (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(ii)*32)).FpDflt = Xsqlite3ExprAlloc(tls, db, 119, uintptr(0), 0) + (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(ii)*32)).FpDflt = Xsqlite3ExprAlloc(tls, db, TK_NULL, uintptr(0), 0) } } else { nNG++ @@ -92819,7 +92046,7 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr return } - Xsqlite3VdbeAddOp1(tls, v, 116, 0) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, 0) // Initialize zType for the new view or table. if (*Table)(unsafe.Pointer(p)).FpSelect == uintptr(0) { @@ -92859,15 +92086,15 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr regRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) Xsqlite3MayAbort(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 97, 1, (*Parse)(unsafe.Pointer(pParse)).FregRoot, iDb) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenWrite, 1, (*Parse)(unsafe.Pointer(pParse)).FregRoot, iDb) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_P2ISREG) (*Parse)(unsafe.Pointer(pParse)).FnTab = 2 addrTop = (Xsqlite3VdbeCurrentAddr(tls, v) + 1) - Xsqlite3VdbeAddOp3(tls, v, 13, regYield, 0, addrTop) + Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regYield, 0, addrTop) if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { return } - pSelTab = Xsqlite3ResultSetOfSelect(tls, pParse, pSelect, int8(0x41)) + pSelTab = Xsqlite3ResultSetOfSelect(tls, pParse, pSelect, SQLITE_AFF_BLOB) if pSelTab == uintptr(0) { return } @@ -92877,22 +92104,22 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr (*Table)(unsafe.Pointer(pSelTab)).FnCol = int16(0) (*Table)(unsafe.Pointer(pSelTab)).FaCol = uintptr(0) Xsqlite3DeleteTable(tls, db, pSelTab) - Xsqlite3SelectDestInit(tls, bp+104 /* &dest */, 13, regYield) + Xsqlite3SelectDestInit(tls, bp+104 /* &dest */, SRT_Coroutine, regYield) Xsqlite3Select(tls, pParse, pSelect, bp+104 /* &dest */) if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { return } Xsqlite3VdbeEndCoroutine(tls, v, regYield) Xsqlite3VdbeJumpHere(tls, v, (addrTop - 1)) - addrInsLoop = Xsqlite3VdbeAddOp1(tls, v, 14, (*SelectDest)(unsafe.Pointer(bp+104 /* &dest */)).FiSDParm) + addrInsLoop = Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(bp+104 /* &dest */)).FiSDParm) - Xsqlite3VdbeAddOp3(tls, v, 91, (*SelectDest)(unsafe.Pointer(bp+104 /* &dest */)).FiSdst, (*SelectDest)(unsafe.Pointer(bp+104 /* &dest */)).FnSdst, regRec) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (*SelectDest)(unsafe.Pointer(bp+104 /* &dest */)).FiSdst, (*SelectDest)(unsafe.Pointer(bp+104 /* &dest */)).FnSdst, regRec) Xsqlite3TableAffinity(tls, v, p, 0) - Xsqlite3VdbeAddOp2(tls, v, 120, 1, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, 1, regRec, regRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, 1, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, 1, regRec, regRowid) Xsqlite3VdbeGoto(tls, v, addrInsLoop) Xsqlite3VdbeJumpHere(tls, v, addrInsLoop) - Xsqlite3VdbeAddOp1(tls, v, 116, 1) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, 1) } // Compute the complete text of the CREATE statement @@ -92906,7 +92133,7 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr pEnd2 = pEnd } n = (int32((int64((*Token)(unsafe.Pointer(pEnd2)).Fz) - int64((*Parse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) / 1)) - if int32(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(pEnd2)).Fz + uintptr(0)))) != ';' { + if int32(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(pEnd2)).Fz))) != ';' { n = int32(uint32(n) + ((*Token)(unsafe.Pointer(pEnd2)).Fn)) } zStmt = Xsqlite3MPrintf(tls, db, @@ -92931,7 +92158,7 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr // Check to see if we need to create an sqlite_sequence table for // keeping track of autoincrement keys. - if ((*Table)(unsafe.Pointer(p)).FtabFlags & U32(0x0008)) != U32(0) { + if ((*Table)(unsafe.Pointer(p)).FtabFlags & TF_Autoincrement) != U32(0) { var pDb uintptr = ((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32) if (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab == uintptr(0) { @@ -92958,7 +92185,7 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr return } (*Parse)(unsafe.Pointer(pParse)).FpNewTable = uintptr(0) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) if !(int32((*Table)(unsafe.Pointer(p)).FpSelect) != 0) { var zName uintptr = (*Parse)(unsafe.Pointer(pParse)).FsNameToken.Fz @@ -93021,18 +92248,18 @@ __3: // This will force all the Expr.token.z values to be dynamically // allocated rather than point to the input string - which means that // they will persist after the current sqlite3_exec() call returns. - *(*U32)(unsafe.Pointer(pSelect + 4 /* &.selFlags */)) |= (U32(0x0200000)) - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + *(*U32)(unsafe.Pointer(pSelect + 4 /* &.selFlags */)) |= (SF_View) + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __4 } (*Table)(unsafe.Pointer(p)).FpSelect = pSelect pSelect = uintptr(0) goto __5 __4: - (*Table)(unsafe.Pointer(p)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, 0x0001) + (*Table)(unsafe.Pointer(p)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, EXPRDUP_REDUCE) __5: ; - (*Table)(unsafe.Pointer(p)).FpCheck = Xsqlite3ExprListDup(tls, db, pCNames, 0x0001) + (*Table)(unsafe.Pointer(p)).FpCheck = Xsqlite3ExprListDup(tls, db, pCNames, EXPRDUP_REDUCE) if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __6 } @@ -93044,7 +92271,7 @@ __6: // the end. *(*Token)(unsafe.Pointer(bp + 56 /* sEnd */)) = (*Parse)(unsafe.Pointer(pParse)).FsLastToken - if !(int32(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(bp+56 /* &sEnd */)).Fz + uintptr(0)))) != ';') { + if !(int32(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(bp + 56 /* &sEnd */)).Fz))) != ';') { goto __7 } *(*uintptr)(unsafe.Pointer(bp + 56 /* &sEnd */ /* &.z */)) += (uintptr((*Token)(unsafe.Pointer(bp + 56 /* &sEnd */)).Fn)) @@ -93070,7 +92297,7 @@ __9: create_view_fail: Xsqlite3SelectDelete(tls, db, pSelect) - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __10 } Xsqlite3RenameExprlistUnmap(tls, pParse, pCNames) @@ -93140,7 +92367,7 @@ func Xsqlite3ViewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) i pSel = Xsqlite3SelectDup(tls, db, (*Table)(unsafe.Pointer(pTable)).FpSelect, 0) if pSel != 0 { var eParseMode U8 = (*Parse)(unsafe.Pointer(pParse)).FeParseMode - (*Parse)(unsafe.Pointer(pParse)).FeParseMode = U8(0) + (*Parse)(unsafe.Pointer(pParse)).FeParseMode = PARSE_MODE_NORMAL n = (*Parse)(unsafe.Pointer(pParse)).FnTab Xsqlite3SrcListAssignCursors(tls, pParse, (*Select)(unsafe.Pointer(pSel)).FpSrc) (*Table)(unsafe.Pointer(pTable)).FnCol = int16(-1) @@ -93148,7 +92375,7 @@ func Xsqlite3ViewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) i (*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0) xAuth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth (*Sqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) - pSelTab = Xsqlite3ResultSetOfSelect(tls, pParse, pSel, int8(0x40)) + pSelTab = Xsqlite3ResultSetOfSelect(tls, pParse, pSel, SQLITE_AFF_NONE) (*Sqlite3)(unsafe.Pointer(db)).FxAuth = xAuth (*Parse)(unsafe.Pointer(pParse)).FnTab = n if pSelTab == uintptr(0) { @@ -93166,7 +92393,7 @@ func Xsqlite3ViewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) i ((*Parse)(unsafe.Pointer(pParse)).FnErr == 0)) && (int32((*Table)(unsafe.Pointer(pTable)).FnCol) == (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpEList)).FnExpr) { Xsqlite3SelectAddColumnTypeAndCollation(tls, pParse, pTable, pSel, - int8(0x40)) + SQLITE_AFF_NONE) } } else { // CREATE VIEW name AS... without an argument list. Construct @@ -93192,7 +92419,7 @@ func Xsqlite3ViewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) i } else { nErr++ } - *(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTable)).FpSchema + 114 /* &.schemaFlags */)) |= U16((0x0002)) + *(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTable)).FpSchema + 114 /* &.schemaFlags */)) |= U16((DB_UnresetViews)) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { Xsqlite3DeleteColumnNames(tls, db, pTable) (*Table)(unsafe.Pointer(pTable)).FaCol = uintptr(0) @@ -93205,7 +92432,7 @@ func Xsqlite3ViewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) i func sqliteViewResetAll(tls *libc.TLS, db uintptr, idx int32) { /* sqlite3.c:113168:13: */ var i uintptr - if !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(idx)*32)).FpSchema)).FschemaFlags) & (0x0002)) == (0x0002)) { + if !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(idx)*32)).FpSchema)).FschemaFlags) & (DB_UnresetViews)) == (DB_UnresetViews)) { return } for i = (*Hash)(unsafe.Pointer(((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(idx)*32)).FpSchema + 8 /* &.tblHash */))).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext { @@ -93216,7 +92443,7 @@ func sqliteViewResetAll(tls *libc.TLS, db uintptr, idx int32) { /* sqlite3.c:113 (*Table)(unsafe.Pointer(pTab)).FnCol = int16(0) } } - *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(idx)*32)).FpSchema + 114 /* &.schemaFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0002))) + *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(idx)*32)).FpSchema + 114 /* &.schemaFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(DB_UnresetViews))) } // This function is called by the VDBE to adjust the internal schema @@ -93269,7 +92496,7 @@ func destroyRootPage(tls *libc.TLS, pParse uintptr, iTable int32, iDb int32) { / if iTable < 2 { Xsqlite3ErrorMsg(tls, pParse, ts+11102 /* "corrupt schema" */, 0) } - Xsqlite3VdbeAddOp3(tls, v, 136, iTable, r1, iDb) + Xsqlite3VdbeAddOp3(tls, v, OP_Destroy, iTable, r1, iDb) Xsqlite3MayAbort(tls, pParse) // OP_Destroy stores an in integer r1. If this integer // is non-zero, then it is the root page number of a table moved to @@ -93369,7 +92596,7 @@ func Xsqlite3CodeDropTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iDb int3 Xsqlite3BeginWriteOperation(tls, pParse, 1, iDb) if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { - Xsqlite3VdbeAddOp0(tls, v, 162) + Xsqlite3VdbeAddOp0(tls, v, OP_VBegin) } // Drop all triggers associated with the table being dropped. Code @@ -93386,7 +92613,7 @@ func Xsqlite3CodeDropTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iDb int3 // the table being dropped. This is done before the table is dropped // at the btree level, in case the sqlite_sequence table needs to // move as a result of the drop (can happen in auto-vacuum mode). - if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0008)) != 0 { + if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Autoincrement) != 0 { Xsqlite3NestedParse(tls, pParse, ts+11198, /* "DELETE FROM %Q.s..." */ libc.VaList(bp, (*Db)(unsafe.Pointer(pDb)).FzDbSName, (*Table)(unsafe.Pointer(pTab)).FzName)) @@ -93409,10 +92636,10 @@ func Xsqlite3CodeDropTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iDb int3 // Remove the table entry from SQLite's internal schema and modify // the schema cookie. if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { - Xsqlite3VdbeAddOp4(tls, v, 164, iDb, 0, 0, (*Table)(unsafe.Pointer(pTab)).FzName, 0) + Xsqlite3VdbeAddOp4(tls, v, OP_VDestroy, iDb, 0, 0, (*Table)(unsafe.Pointer(pTab)).FzName, 0) Xsqlite3MayAbort(tls, pParse) } - Xsqlite3VdbeAddOp4(tls, v, 143, iDb, 0, 0, (*Table)(unsafe.Pointer(pTab)).FzName, 0) + Xsqlite3VdbeAddOp4(tls, v, OP_DropTable, iDb, 0, 0, (*Table)(unsafe.Pointer(pTab)).FzName, 0) Xsqlite3ChangeCookie(tls, pParse, iDb) sqliteViewResetAll(tls, db, iDb) } @@ -93420,7 +92647,7 @@ func Xsqlite3CodeDropTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iDb int3 // Return TRUE if shadow tables should be read-only in the current // context. func Xsqlite3ReadOnlyShadowTables(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:113409:20: */ - if ((((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x10000000)) != uint64(0)) && + if ((((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_Defensive) != uint64(0)) && ((*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx == uintptr(0))) && ((*Sqlite3)(unsafe.Pointer(db)).FnVdbeExec == 0) { return 1 @@ -93439,7 +92666,7 @@ func tableMayNotBeDropped(tls *libc.TLS, db uintptr, pTab uintptr) int32 { /* sq } return 1 } - if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x1000)) != U32(0)) && (Xsqlite3ReadOnlyShadowTables(tls, db) != 0) { + if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Shadow) != U32(0)) && (Xsqlite3ReadOnlyShadowTables(tls, db) != 0) { return 1 } return 0 @@ -93481,7 +92708,7 @@ __2: __3: ; - pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(isView), ((pName + 8 /* &.a */) + uintptr(0)*112)) + pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(isView), (pName + 8 /* &.a */)) if !(noErr != 0) { goto __4 } @@ -93495,7 +92722,7 @@ __4: if !(noErr != 0) { goto __6 } - Xsqlite3CodeVerifyNamedSchema(tls, pParse, (*SrcList_item)(unsafe.Pointer((pName+8 /* &.a */)+uintptr(0)*112)).FzDatabase) + Xsqlite3CodeVerifyNamedSchema(tls, pParse, (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */))).FzDatabase) __6: ; goto exit_drop_table @@ -93520,7 +92747,7 @@ __7: }() zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName zArg2 = uintptr(0) - if !(Xsqlite3AuthCheck(tls, pParse, 9, zTab, uintptr(0), zDb) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, zTab, uintptr(0), zDb) != 0) { goto __8 } goto exit_drop_table @@ -93532,10 +92759,10 @@ __8: if !(!(0 != 0) && (iDb == 1)) { goto __11 } - code = 15 + code = SQLITE_DROP_TEMP_VIEW goto __12 __11: - code = 17 + code = SQLITE_DROP_VIEW __12: ; goto __10 @@ -93543,17 +92770,17 @@ __9: if !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { goto __13 } - code = 30 + code = SQLITE_DROP_VTABLE zArg2 = (*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer(Xsqlite3GetVTable(tls, db, pTab))).FpMod)).FzName goto __14 __13: if !(!(0 != 0) && (iDb == 1)) { goto __15 } - code = 13 + code = SQLITE_DROP_TEMP_TABLE goto __16 __15: - code = 11 + code = SQLITE_DROP_TABLE __16: ; __14: @@ -93566,7 +92793,7 @@ __10: goto exit_drop_table __17: ; - if !(Xsqlite3AuthCheck(tls, pParse, 9, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), zDb) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), zDb) != 0) { goto __18 } goto exit_drop_table @@ -93653,7 +92880,7 @@ func Xsqlite3CreateForeignKey(tls *libc.TLS, pParse uintptr, pFromCol uintptr, p pFKey = uintptr(0) p = (*Parse)(unsafe.Pointer(pParse)).FpNewTable - if !((p == uintptr(0)) || (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == 1)) { + if !((p == uintptr(0)) || (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == PARSE_MODE_DECLARE_VTAB)) { goto __1 } goto fk_end @@ -93725,7 +92952,7 @@ __12: (*FKey)(unsafe.Pointer(pFKey)).FpNextFrom = (*Table)(unsafe.Pointer(p)).FpFKey z = ((pFKey + 64 /* &.aCol */) + uintptr(nCol)*16) (*FKey)(unsafe.Pointer(pFKey)).FzTo = z - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __13 } Xsqlite3RenameTokenMap(tls, pParse, z, pTo) @@ -93739,7 +92966,7 @@ __13: if !(pFromCol == uintptr(0)) { goto __14 } - (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(0)*16)).FiFrom = (int32((*Table)(unsafe.Pointer(p)).FnCol) - 1) + (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */))).FiFrom = (int32((*Table)(unsafe.Pointer(p)).FnCol) - 1) goto __15 __14: i = 0 @@ -93775,7 +93002,7 @@ __21: goto fk_end __23: ; - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __24 } Xsqlite3RenameTokenRemap(tls, pParse, ((pFKey + 64 /* &.aCol */) + uintptr(i)*16), (*ExprList_item)(unsafe.Pointer((pFromCol+8 /* &.a */)+uintptr(i)*32)).FzEName) @@ -93800,7 +93027,7 @@ __26: } n = Xsqlite3Strlen30(tls, (*ExprList_item)(unsafe.Pointer((pToCol+8 /* &.a */)+uintptr(i)*32)).FzEName) (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(i)*16)).FzCol = z - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __29 } Xsqlite3RenameTokenRemap(tls, pParse, z, (*ExprList_item)(unsafe.Pointer((pToCol+8 /* &.a */)+uintptr(i)*32)).FzEName) @@ -93819,8 +93046,8 @@ __28: __25: ; (*FKey)(unsafe.Pointer(pFKey)).FisDeferred = U8(0) - *(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + uintptr(0))) = (U8(flags & 0xff)) // ON DELETE action - *(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + uintptr(1))) = (U8((flags >> 8) & 0xff)) // ON UPDATE action + *(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */))) = (U8(flags & 0xff)) // ON DELETE action + *(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + 1)) = (U8((flags >> 8) & 0xff)) // ON UPDATE action pNextTo = Xsqlite3HashInsert(tls, ((*Table)(unsafe.Pointer(p)).FpSchema + 80 /* &.fkeyHash */), (*FKey)(unsafe.Pointer(pFKey)).FzTo, pFKey) @@ -93893,7 +93120,7 @@ func sqlite3RefillIndex(tls *libc.TLS, pParse uintptr, pIndex uintptr, memRootPa var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb // The database connection var iDb int32 = Xsqlite3SchemaToIndex(tls, db, (*Index)(unsafe.Pointer(pIndex)).FpSchema) - if Xsqlite3AuthCheck(tls, pParse, 27, (*Index)(unsafe.Pointer(pIndex)).FzName, uintptr(0), + if Xsqlite3AuthCheck(tls, pParse, SQLITE_REINDEX, (*Index)(unsafe.Pointer(pIndex)).FzName, uintptr(0), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) != 0 { return } @@ -93914,40 +93141,40 @@ func sqlite3RefillIndex(tls *libc.TLS, pParse uintptr, pIndex uintptr, memRootPa // Open the sorter cursor if we are to use one. iSorter = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - Xsqlite3VdbeAddOp4(tls, v, 111, iSorter, 0, int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol), Xsqlite3KeyInfoRef(tls, pKey), -9) + Xsqlite3VdbeAddOp4(tls, v, OP_SorterOpen, iSorter, 0, int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol), Xsqlite3KeyInfoRef(tls, pKey), -9) // Open the table. Loop through all rows of the table, inserting index // records into the sorter. - Xsqlite3OpenTable(tls, pParse, iTab, iDb, pTab, 96) - addr1 = Xsqlite3VdbeAddOp2(tls, v, 37, iTab, 0) + Xsqlite3OpenTable(tls, pParse, iTab, iDb, pTab, OP_OpenRead) + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iTab, 0) regRecord = Xsqlite3GetTempReg(tls, pParse) Xsqlite3MultiWrite(tls, pParse) Xsqlite3GenerateIndexKey(tls, pParse, pIndex, iTab, regRecord, 0, bp /* &iPartIdxLabel */, uintptr(0), 0) - Xsqlite3VdbeAddOp2(tls, v, 131, iSorter, regRecord) + Xsqlite3VdbeAddOp2(tls, v, OP_SorterInsert, iSorter, regRecord) Xsqlite3ResolvePartIdxLabel(tls, pParse, *(*int32)(unsafe.Pointer(bp /* iPartIdxLabel */))) - Xsqlite3VdbeAddOp2(tls, v, 5, iTab, (addr1 + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iTab, (addr1 + 1)) Xsqlite3VdbeJumpHere(tls, v, addr1) if memRootPage < 0 { - Xsqlite3VdbeAddOp2(tls, v, 137, int32(tnum), iDb) + Xsqlite3VdbeAddOp2(tls, v, OP_Clear, int32(tnum), iDb) } - Xsqlite3VdbeAddOp4(tls, v, 97, iIdx, int32(tnum), iDb, + Xsqlite3VdbeAddOp4(tls, v, OP_OpenWrite, iIdx, int32(tnum), iDb, pKey, -9) - Xsqlite3VdbeChangeP5(tls, v, (uint16(0x01 | (func() int32 { + Xsqlite3VdbeChangeP5(tls, v, (uint16(OPFLAG_BULKCSR | (func() int32 { if memRootPage >= 0 { - return 0x10 + return OPFLAG_P2ISREG } return 0 }())))) - addr1 = Xsqlite3VdbeAddOp2(tls, v, 35, iSorter, 0) - if int32((*Index)(unsafe.Pointer((pIndex))).FonError) != 0 { + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_SorterSort, iSorter, 0) + if int32((*Index)(unsafe.Pointer((pIndex))).FonError) != OE_None { var j2 int32 = Xsqlite3VdbeGoto(tls, v, 1) addr2 = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp4Int(tls, v, 124, iSorter, j2, regRecord, + Xsqlite3VdbeAddOp4Int(tls, v, OP_SorterCompare, iSorter, j2, regRecord, int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol)) - Xsqlite3UniqueConstraint(tls, pParse, 2, pIndex) + Xsqlite3UniqueConstraint(tls, pParse, OE_Abort, pIndex) Xsqlite3VdbeJumpHere(tls, v, j2) } else { // Most CREATE INDEX and REINDEX statements that are not UNIQUE can not @@ -93960,7 +93187,7 @@ func sqlite3RefillIndex(tls *libc.TLS, pParse uintptr, pIndex uintptr, memRootPa Xsqlite3MayAbort(tls, pParse) addr2 = Xsqlite3VdbeCurrentAddr(tls, v) } - Xsqlite3VdbeAddOp3(tls, v, 125, iSorter, regRecord, iIdx) + Xsqlite3VdbeAddOp3(tls, v, OP_SorterData, iSorter, regRecord, iIdx) if !((int32(*(*uint16)(unsafe.Pointer(pIndex + 100 /* &.bAscKeyBug */)) & 0x200 >> 9)) != 0) { // This OP_SeekEnd opcode makes index insert for a REINDEX go much // faster by avoiding unnecessary seeks. But the optimization does @@ -93968,17 +93195,17 @@ func sqlite3RefillIndex(tls *libc.TLS, pParse uintptr, pIndex uintptr, memRootPa // with DESC primary keys, since those indexes have there keys in // a different order from the main table. // See ticket: https://www.sqlite.org/src/info/bba7b69f9849b5bf - Xsqlite3VdbeAddOp1(tls, v, 129, iIdx) + Xsqlite3VdbeAddOp1(tls, v, OP_SeekEnd, iIdx) } - Xsqlite3VdbeAddOp2(tls, v, 130, iIdx, regRecord) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, iIdx, regRecord) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_USESEEKRESULT) Xsqlite3ReleaseTempReg(tls, pParse, regRecord) - Xsqlite3VdbeAddOp2(tls, v, 3, iSorter, addr2) + Xsqlite3VdbeAddOp2(tls, v, OP_SorterNext, iSorter, addr2) Xsqlite3VdbeJumpHere(tls, v, addr1) - Xsqlite3VdbeAddOp1(tls, v, 116, iTab) - Xsqlite3VdbeAddOp1(tls, v, 116, iIdx) - Xsqlite3VdbeAddOp1(tls, v, 116, iSorter) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iTab) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iIdx) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iSorter) } // Allocate heap space to hold an Index object with nCol columns. @@ -93990,12 +93217,12 @@ func Xsqlite3AllocateIndexObject(tls *libc.TLS, db uintptr, nCol I16, nExtra int var p uintptr // Allocated index object var nByte int32 // Bytes of space for Index object + arrays - nByte = (int32(((((uint64(unsafe.Sizeof(Index{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)) + (((uint64(unsafe.Sizeof(uintptr(0))) * uint64(nCol)) + uint64(7)) & ^libc.Uint64FromInt32(7))) + (((((uint64(unsafe.Sizeof(LogEst(0))) * (uint64(int32(nCol) + 1))) + (uint64(unsafe.Sizeof(I16(0))) * uint64(nCol))) + (uint64(unsafe.Sizeof(U8(0))) * uint64(nCol))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) // Index.aSortOrder + nByte = (int32(((((uint64(unsafe.Sizeof(Index{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))) + (((uint64(unsafe.Sizeof(uintptr(0))) * uint64(nCol)) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) + (((((uint64(unsafe.Sizeof(LogEst(0))) * (uint64(int32(nCol) + 1))) + (uint64(unsafe.Sizeof(I16(0))) * uint64(nCol))) + (uint64(unsafe.Sizeof(U8(0))) * uint64(nCol))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))))) // Index.aSortOrder p = Xsqlite3DbMallocZero(tls, db, (uint64(nByte + nExtra))) if p != 0 { - var pExtra uintptr = ((p) + uintptr((((uint64(unsafe.Sizeof(Index{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + var pExtra uintptr = ((p) + uintptr((((uint64(unsafe.Sizeof(Index{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))))) (*Index)(unsafe.Pointer(p)).FazColl = pExtra - pExtra += (uintptr(((uint64(unsafe.Sizeof(uintptr(0))) * uint64(nCol)) + uint64(7)) & ^libc.Uint64FromInt32(7))) + pExtra += (uintptr(((uint64(unsafe.Sizeof(uintptr(0))) * uint64(nCol)) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) (*Index)(unsafe.Pointer(p)).FaiRowLogEst = pExtra pExtra += (uintptr(uint64(unsafe.Sizeof(LogEst(0))) * (uint64(int32(nCol) + 1)))) (*Index)(unsafe.Pointer(p)).FaiColumn = pExtra @@ -94127,13 +93354,13 @@ func Xsqlite3CreateIndex(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 u goto exit_create_index __1: ; - if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == 1) && (int32(idxType) != 2)) { + if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == PARSE_MODE_DECLARE_VTAB) && (int32(idxType) != SQLITE_IDXTYPE_PRIMARYKEY)) { goto __2 } goto exit_create_index __2: ; - if !(0 != Xsqlite3ReadSchema(tls, pParse)) { + if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) { goto __3 } goto exit_create_index @@ -94170,7 +93397,7 @@ __7: goto __8 } pTab = Xsqlite3SrcListLookup(tls, pParse, pTblName) - if !((((*Token)(unsafe.Pointer(pName2)).Fn == uint32(0)) && (pTab != 0)) && ((*Table)(unsafe.Pointer(pTab)).FpSchema == (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema)) { + if !((((*Token)(unsafe.Pointer(pName2)).Fn == uint32(0)) && (pTab != 0)) && ((*Table)(unsafe.Pointer(pTab)).FpSchema == (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema)) { goto __9 } iDb = 1 @@ -94188,7 +93415,7 @@ __8: __10: ; - pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), ((pTblName + 8 /* &.a */) + uintptr(0)*112)) + pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), (pTblName + 8 /* &.a */)) if !(pTab == uintptr(0)) { goto __11 @@ -94205,7 +93432,7 @@ __11: goto exit_create_index __12: ; - if !(!(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) { + if !(!(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) { goto __13 } pPk = Xsqlite3PrimaryKeyIndex(tls, pTab) @@ -94273,13 +93500,13 @@ __17: __20: ; - if !(0 != Xsqlite3CheckObjectName(tls, pParse, zName, ts+11646 /* "index" */, (*Table)(unsafe.Pointer(pTab)).FzName)) { + if !(SQLITE_OK != Xsqlite3CheckObjectName(tls, pParse, zName, ts+11646 /* "index" */, (*Table)(unsafe.Pointer(pTab)).FzName)) { goto __21 } goto exit_create_index __21: ; - if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) { + if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) { goto __22 } if !(!(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0)) { @@ -94341,21 +93568,21 @@ __31: // The following statement converts "sqlite3_autoindex..." into // "sqlite3_butoindex..." in order to make the names distinct. // The "vtab_err.test" test demonstrates the need of this statement. - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != 0) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL) { goto __32 } - *(*int8)(unsafe.Pointer(zName + uintptr(7)))++ + *(*int8)(unsafe.Pointer(zName + 7))++ __32: ; __19: ; // Check for authorization to create an index. - if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) { + if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) { goto __33 } zDb = (*Db)(unsafe.Pointer(pDb)).FzDbSName - if !(Xsqlite3AuthCheck(tls, pParse, 18, func() uintptr { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_INSERT, func() uintptr { if (!(0 != 0)) && (iDb == 1) { return ts + 10046 /* "sqlite_temp_mast..." */ } @@ -94366,11 +93593,11 @@ __19: goto exit_create_index __34: ; - i = 1 + i = SQLITE_CREATE_INDEX if !(!(0 != 0) && (iDb == 1)) { goto __35 } - i = 3 + i = SQLITE_CREATE_TEMP_INDEX __35: ; if !(Xsqlite3AuthCheck(tls, pParse, i, zName, (*Table)(unsafe.Pointer(pTab)).FzName, zDb) != 0) { @@ -94389,10 +93616,10 @@ __33: goto __37 } pCol = ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr((int32((*Table)(unsafe.Pointer(pTab)).FnCol)-1))*32) - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((COLFLAG_UNIQUE)) Xsqlite3TokenInit(tls, bp+184 /* &prevCol */, (*Column)(unsafe.Pointer(pCol)).FzName) pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), - Xsqlite3ExprAlloc(tls, db, 59, bp+184 /* &prevCol */, 0)) + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+184 /* &prevCol */, 0)) if !(pList == uintptr(0)) { goto __39 } @@ -94422,7 +93649,7 @@ __41: } pExpr = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(i)*32)).FpExpr - if !(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 111) { + if !(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLLATE) { goto __44 } nExtra = nExtra + (1 + Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)))) @@ -94458,14 +93685,14 @@ __45: libc.Xmemcpy(tls, (*Index)(unsafe.Pointer(pIndex)).FzName, zName, (uint64(nName + 1))) (*Index)(unsafe.Pointer(pIndex)).FpTable = pTab (*Index)(unsafe.Pointer(pIndex)).FonError = U8(onError) - libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.uniqNotNull */, (uint32(libc.Bool32(onError != 0))), 3, 0x8) + libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.uniqNotNull */, (uint32(libc.Bool32(onError != OE_None))), 3, 0x8) libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.idxType */, uint32(idxType), 0, 0x3) (*Index)(unsafe.Pointer(pIndex)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpSchema (*Index)(unsafe.Pointer(pIndex)).FnKeyCol = U16((*ExprList)(unsafe.Pointer(pList)).FnExpr) if !(pPIWhere != 0) { goto __46 } - Xsqlite3ResolveSelfReference(tls, pParse, pTab, 0x00002, pPIWhere, uintptr(0)) + Xsqlite3ResolveSelfReference(tls, pParse, pTab, NC_PartIdx, pPIWhere, uintptr(0)) (*Index)(unsafe.Pointer(pIndex)).FpPartIdxWhere = pPIWhere pPIWhere = uintptr(0) __46: @@ -94491,7 +93718,7 @@ __48: // TODO: Issue a warning if the table primary key is used as part of the // index key. pListItem = pList + 8 /* &.a */ - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __49 } (*Index)(unsafe.Pointer(pIndex)).FaColExpr = pList @@ -94505,7 +93732,7 @@ __50: } // Collation sequence name sqlite3StringToId(tls, (*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr) - Xsqlite3ResolveSelfReference(tls, pParse, pTab, 0x00020, (*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr, uintptr(0)) + Xsqlite3ResolveSelfReference(tls, pParse, pTab, NC_IdxExpr, (*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr, uintptr(0)) if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) { goto __53 } @@ -94513,7 +93740,7 @@ __50: __53: ; pCExpr = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr) - if !(int32((*Expr)(unsafe.Pointer(pCExpr)).Fop) != 164) { + if !(int32((*Expr)(unsafe.Pointer(pCExpr)).Fop) != TK_COLUMN) { goto __54 } if !(pTab == (*Parse)(unsafe.Pointer(pParse)).FpNewTable) { @@ -94550,7 +93777,7 @@ __58: libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.uniqNotNull */, uint32(0), 3, 0x8) __60: ; - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & 0x0020) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0) { goto __61 } libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.bHasVCol */, uint32(1), 10, 0x400) @@ -94562,7 +93789,7 @@ __59: __55: ; zColl = uintptr(0) - if !(int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr)).Fop) == 111) { + if !(int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr)).Fop) == TK_COLLATE) { goto __62 } zColl = *(*uintptr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr + 8 /* &.u */)) @@ -94745,14 +93972,14 @@ __88: // constraint and the previous equivalent constraint have explicit // ON CONFLICT clauses this is an error. Otherwise, use the // explicitly specified behavior for the index. - if !(!((int32((*Index)(unsafe.Pointer(pIdx)).FonError) == 11) || (int32((*Index)(unsafe.Pointer(pIndex)).FonError) == 11))) { + if !(!((int32((*Index)(unsafe.Pointer(pIdx)).FonError) == OE_Default) || (int32((*Index)(unsafe.Pointer(pIndex)).FonError) == OE_Default))) { goto __93 } Xsqlite3ErrorMsg(tls, pParse, ts+11931 /* "conflicting ON C..." */, libc.VaList(bp+48, 0)) __93: ; - if !(int32((*Index)(unsafe.Pointer(pIdx)).FonError) == 11) { + if !(int32((*Index)(unsafe.Pointer(pIdx)).FonError) == OE_Default) { goto __94 } (*Index)(unsafe.Pointer(pIdx)).FonError = (*Index)(unsafe.Pointer(pIndex)).FonError @@ -94760,13 +93987,13 @@ __94: ; __92: ; - if !(int32(idxType) == 2) { + if !(int32(idxType) == SQLITE_IDXTYPE_PRIMARYKEY) { goto __95 } libc.SetBitFieldPtr16Uint32(pIdx+100 /* &.idxType */, uint32(idxType), 0, 0x3) __95: ; - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __96 } (*Index)(unsafe.Pointer(pIndex)).FpNext = (*Parse)(unsafe.Pointer(pParse)).FpNewIndex @@ -94787,7 +94014,7 @@ __84: __81: ; - if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) { + if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) { goto __97 } @@ -94822,10 +94049,10 @@ __100: goto exit_create_index __102: ; - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) goto __99 __98: - if !((((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) || (pTblName != uintptr(0))) { + if !((((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) || (pTblName != uintptr(0))) { goto __103 } iMem = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) @@ -94846,8 +94073,8 @@ __104: // PRIMARY KEY and the table is actually a WITHOUT ROWID table. In // that case the convertToWithoutRowidTable() routine will replace // the Noop with a Goto to jump over the VDBE code generated below. - (*Index)(unsafe.Pointer(pIndex)).Ftnum = Pgno(Xsqlite3VdbeAddOp0(tls, v, 173)) - Xsqlite3VdbeAddOp3(tls, v, 139, iDb, iMem, 2) + (*Index)(unsafe.Pointer(pIndex)).Ftnum = Pgno(Xsqlite3VdbeAddOp0(tls, v, OP_Noop)) + Xsqlite3VdbeAddOp3(tls, v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY) // Gather the complete text of the CREATE INDEX statement into // the zStmt variable @@ -94865,7 +94092,7 @@ __107: // A named index with an explicit CREATE INDEX statement zStmt = Xsqlite3MPrintf(tls, db, ts+11990, /* "CREATE%s INDEX %..." */ libc.VaList(bp+56, func() uintptr { - if onError == 0 { + if onError == OE_None { return ts + 703 /* "" */ } return ts + 12010 /* " UNIQUE" */ @@ -94897,7 +94124,7 @@ __106: Xsqlite3ChangeCookie(tls, pParse, iDb) Xsqlite3VdbeAddParseSchemaOp(tls, v, iDb, Xsqlite3MPrintf(tls, db, ts+12077 /* "name='%q' AND ty..." */, libc.VaList(bp+120, (*Index)(unsafe.Pointer(pIndex)).FzName))) - Xsqlite3VdbeAddOp2(tls, v, 158, 0, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_Expire, 0, 1) __108: ; @@ -94916,7 +94143,7 @@ __97: pIndex = uintptr(0) goto __110 __109: - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __111 } @@ -94944,14 +94171,14 @@ __114: if !((libc.AssignUintptr(&pThis, *(*uintptr)(unsafe.Pointer(ppFrom)))) != uintptr(0)) { goto __116 } - if !(int32((*Index)(unsafe.Pointer(pThis)).FonError) != 5) { + if !(int32((*Index)(unsafe.Pointer(pThis)).FonError) != OE_Replace) { goto __117 } goto __115 __117: ; __118: - if !(((libc.AssignUintptr(&pNext, (*Index)(unsafe.Pointer(pThis)).FpNext)) != uintptr(0)) && (int32((*Index)(unsafe.Pointer(pNext)).FonError) != 5)) { + if !(((libc.AssignUintptr(&pNext, (*Index)(unsafe.Pointer(pThis)).FpNext)) != uintptr(0)) && (int32((*Index)(unsafe.Pointer(pNext)).FonError) != OE_Replace)) { goto __119 } *(*uintptr)(unsafe.Pointer(ppFrom)) = pNext @@ -95023,16 +94250,16 @@ func Xsqlite3DefaultRowEst(tls *libc.TLS, pIdx uintptr) { /* sqlite3.c:114468:21 if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0) { x = int16(int32(x) - (10)) } - *(*LogEst)(unsafe.Pointer(a + uintptr(0)*2)) = x + *(*LogEst)(unsafe.Pointer(a)) = x // Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is // 6 and each subsequent value (if any) is 5. - libc.Xmemcpy(tls, (a + uintptr(1)*2), uintptr(unsafe.Pointer(&aVal)), (uint64(nCopy) * uint64(unsafe.Sizeof(LogEst(0))))) + libc.Xmemcpy(tls, (a + 1*2), uintptr(unsafe.Pointer(&aVal)), (uint64(nCopy) * uint64(unsafe.Sizeof(LogEst(0))))) for i = (nCopy + 1); i <= int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol); i++ { *(*LogEst)(unsafe.Pointer(a + uintptr(i)*2)) = int16(23) } - if int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0 { + if int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None { *(*LogEst)(unsafe.Pointer(a + uintptr((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)*2)) = int16(0) } } @@ -95063,13 +94290,13 @@ func Xsqlite3DropIndex(tls *libc.TLS, pParse uintptr, pName uintptr, ifExists in __1: ; - if !(0 != Xsqlite3ReadSchema(tls, pParse)) { + if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) { goto __2 } goto exit_drop_index __2: ; - pIndex = Xsqlite3FindIndex(tls, db, (*SrcList_item)(unsafe.Pointer((pName+8 /* &.a */)+uintptr(0)*112)).FzName, (*SrcList_item)(unsafe.Pointer((pName+8 /* &.a */)+uintptr(0)*112)).FzDatabase) + pIndex = Xsqlite3FindIndex(tls, db, (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */))).FzName, (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */))).FzDatabase) if !(pIndex == uintptr(0)) { goto __3 } @@ -95079,14 +94306,14 @@ __2: Xsqlite3ErrorMsg(tls, pParse, ts+12104 /* "no such index: %..." */, libc.VaList(bp, pName, 0)) goto __5 __4: - Xsqlite3CodeVerifyNamedSchema(tls, pParse, (*SrcList_item)(unsafe.Pointer((pName+8 /* &.a */)+uintptr(0)*112)).FzDatabase) + Xsqlite3CodeVerifyNamedSchema(tls, pParse, (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */))).FzDatabase) __5: ; (*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1) goto exit_drop_index __3: ; - if !((int32(*(*uint16)(unsafe.Pointer(pIndex + 100 /* &.idxType */)) & 0x3 >> 0)) != 0) { + if !((int32(*(*uint16)(unsafe.Pointer(pIndex + 100 /* &.idxType */)) & 0x3 >> 0)) != SQLITE_IDXTYPE_APPDEF) { goto __6 } Xsqlite3ErrorMsg(tls, pParse, @@ -95096,7 +94323,7 @@ __6: ; iDb = Xsqlite3SchemaToIndex(tls, db, (*Index)(unsafe.Pointer(pIndex)).FpSchema) - code = 10 + code = SQLITE_DROP_INDEX pTab = (*Index)(unsafe.Pointer(pIndex)).FpTable zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName zTab = func() uintptr { @@ -95105,7 +94332,7 @@ __6: } return ts + 4780 /* "sqlite_master" */ }() - if !(Xsqlite3AuthCheck(tls, pParse, 9, zTab, uintptr(0), zDb) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, zTab, uintptr(0), zDb) != 0) { goto __7 } goto exit_drop_index @@ -95114,7 +94341,7 @@ __7: if !(!(0 != 0) && (iDb != 0)) { goto __8 } - code = 12 + code = SQLITE_DROP_TEMP_INDEX __8: ; if !(Xsqlite3AuthCheck(tls, pParse, code, (*Index)(unsafe.Pointer(pIndex)).FzName, (*Table)(unsafe.Pointer(pTab)).FzName, zDb) != 0) { @@ -95136,7 +94363,7 @@ __9: sqlite3ClearStatTables(tls, pParse, iDb, ts+9380 /* "idx" */, (*Index)(unsafe.Pointer(pIndex)).FzName) Xsqlite3ChangeCookie(tls, pParse, iDb) destroyRootPage(tls, pParse, int32((*Index)(unsafe.Pointer(pIndex)).Ftnum), iDb) - Xsqlite3VdbeAddOp4(tls, v, 144, iDb, 0, 0, (*Index)(unsafe.Pointer(pIndex)).FzName, 0) + Xsqlite3VdbeAddOp4(tls, v, OP_DropIndex, iDb, 0, 0, (*Index)(unsafe.Pointer(pIndex)).FzName, 0) __10: ; @@ -95210,7 +94437,7 @@ func Xsqlite3IdListAppend(tls *libc.TLS, pParse uintptr, pList uintptr, pToken u return uintptr(0) } (*IdList_item)(unsafe.Pointer((*IdList)(unsafe.Pointer(pList)).Fa + uintptr(*(*int32)(unsafe.Pointer(bp /* i */)))*16)).FzName = Xsqlite3NameFromToken(tls, db, pToken) - if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && ((*IdList_item)(unsafe.Pointer((*IdList)(unsafe.Pointer(pList)).Fa+uintptr(*(*int32)(unsafe.Pointer(bp /* i */)))*16)).FzName != 0) { + if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && ((*IdList_item)(unsafe.Pointer((*IdList)(unsafe.Pointer(pList)).Fa+uintptr(*(*int32)(unsafe.Pointer(bp /* i */)))*16)).FzName != 0) { Xsqlite3RenameTokenMap(tls, pParse, (*IdList_item)(unsafe.Pointer((*IdList)(unsafe.Pointer(pList)).Fa+uintptr(*(*int32)(unsafe.Pointer(bp /* i */)))*16)).FzName, pToken) } return pList @@ -95283,13 +94510,13 @@ func Xsqlite3SrcListEnlarge(tls *libc.TLS, pParse uintptr, pSrc uintptr, nExtra var nAlloc Sqlite3_int64 = ((int64(2) * Sqlite3_int64((*SrcList)(unsafe.Pointer(pSrc)).FnSrc)) + Sqlite3_int64(nExtra)) var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if ((*SrcList)(unsafe.Pointer(pSrc)).FnSrc + nExtra) >= 200 { + if ((*SrcList)(unsafe.Pointer(pSrc)).FnSrc + nExtra) >= SQLITE_MAX_SRCLIST { Xsqlite3ErrorMsg(tls, pParse, ts+12255, /* "too many FROM cl..." */ - libc.VaList(bp, 200)) + libc.VaList(bp, SQLITE_MAX_SRCLIST)) return uintptr(0) } - if nAlloc > int64(200) { - nAlloc = int64(200) + if nAlloc > SQLITE_MAX_SRCLIST { + nAlloc = SQLITE_MAX_SRCLIST } pNew = Xsqlite3DbRealloc(tls, db, pSrc, (uint64(unsafe.Sizeof(SrcList{})) + ((uint64(nAlloc - int64(1))) * uint64(unsafe.Sizeof(SrcList_item{}))))) @@ -95364,8 +94591,8 @@ func Xsqlite3SrcListAppend(tls *libc.TLS, pParse uintptr, pList uintptr, pTable } (*SrcList)(unsafe.Pointer(pList)).FnAlloc = U32(1) (*SrcList)(unsafe.Pointer(pList)).FnSrc = 1 - libc.Xmemset(tls, ((pList + 8 /* &.a */) + uintptr(0)*112), 0, uint64(unsafe.Sizeof(SrcList_item{}))) - (*SrcList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(0)*112)).FiCursor = -1 + libc.Xmemset(tls, (pList + 8 /* &.a */), 0, uint64(unsafe.Sizeof(SrcList_item{}))) + (*SrcList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FiCursor = -1 } else { var pNew uintptr = Xsqlite3SrcListEnlarge(tls, pParse, pList, 1, (*SrcList)(unsafe.Pointer(pList)).FnSrc) if pNew == uintptr(0) { @@ -95506,7 +94733,7 @@ __2: pItem = ((p + 8 /* &.a */) + uintptr(((*SrcList)(unsafe.Pointer(p)).FnSrc-1))*112) - if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && ((*SrcList_item)(unsafe.Pointer(pItem)).FzName != 0)) { + if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && ((*SrcList_item)(unsafe.Pointer(pItem)).FzName != 0)) { goto __3 } if (pDatabase != 0) && ((*Token)(unsafe.Pointer(pDatabase)).Fz != 0) { @@ -95568,7 +94795,7 @@ func Xsqlite3SrcListAppendList(tls *libc.TLS, pParse uintptr, p1 uintptr, p2 uin Xsqlite3SrcListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p2) } else { p1 = pNew - libc.Xmemcpy(tls, ((p1 + 8 /* &.a */) + uintptr(1)*112), p2+8 /* &.a */, (uint64((*SrcList)(unsafe.Pointer(p2)).FnSrc) * uint64(unsafe.Sizeof(SrcList_item{})))) + libc.Xmemcpy(tls, ((p1 + 8 /* &.a */) + 1*112), p2+8 /* &.a */, (uint64((*SrcList)(unsafe.Pointer(p2)).FnSrc) * uint64(unsafe.Sizeof(SrcList_item{})))) Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p2) } } @@ -95607,7 +94834,7 @@ func Xsqlite3SrcListShiftJoinType(tls *libc.TLS, p uintptr) { /* sqlite3.c:11501 for i = ((*SrcList)(unsafe.Pointer(p)).FnSrc - 1); i > 0; i-- { (*SrcList_item)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(i)*112)).Ffg.Fjointype = (*SrcList_item)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((i-1))*112)).Ffg.Fjointype } - (*SrcList_item)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(0)*112)).Ffg.Fjointype = U8(0) + (*SrcList_item)(unsafe.Pointer((p + 8 /* &.a */))).Ffg.Fjointype = U8(0) } } @@ -95619,20 +94846,20 @@ func Xsqlite3BeginTransaction(tls *libc.TLS, pParse uintptr, type1 int32) { /* s db = (*Parse)(unsafe.Pointer(pParse)).Fdb - if Xsqlite3AuthCheck(tls, pParse, 22, ts+12336 /* "BEGIN" */, uintptr(0), uintptr(0)) != 0 { + if Xsqlite3AuthCheck(tls, pParse, SQLITE_TRANSACTION, ts+12336 /* "BEGIN" */, uintptr(0), uintptr(0)) != 0 { return } v = Xsqlite3GetVdbe(tls, pParse) if !(v != 0) { return } - if type1 != 7 { + if type1 != TK_DEFERRED { for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { - Xsqlite3VdbeAddOp2(tls, v, 2, i, ((libc.Bool32(type1 == 9)) + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Transaction, i, ((libc.Bool32(type1 == TK_EXCLUSIVE)) + 1)) Xsqlite3VdbeUsesBtree(tls, v, i) } } - Xsqlite3VdbeAddOp0(tls, v, 1) + Xsqlite3VdbeAddOp0(tls, v, OP_AutoCommit) } // Generate VDBE code for a COMMIT or ROLLBACK statement. @@ -95642,8 +94869,8 @@ func Xsqlite3EndTransaction(tls *libc.TLS, pParse uintptr, eType int32) { /* sql var v uintptr var isRollback int32 - isRollback = (libc.Bool32(eType == 12)) - if Xsqlite3AuthCheck(tls, pParse, 22, + isRollback = (libc.Bool32(eType == TK_ROLLBACK)) + if Xsqlite3AuthCheck(tls, pParse, SQLITE_TRANSACTION, func() uintptr { if isRollback != 0 { return ts + 12342 /* "ROLLBACK" */ @@ -95654,7 +94881,7 @@ func Xsqlite3EndTransaction(tls *libc.TLS, pParse uintptr, eType int32) { /* sql } v = Xsqlite3GetVdbe(tls, pParse) if v != 0 { - Xsqlite3VdbeAddOp2(tls, v, 1, 1, isRollback) + Xsqlite3VdbeAddOp2(tls, v, OP_AutoCommit, 1, isRollback) } } @@ -95665,11 +94892,11 @@ func Xsqlite3Savepoint(tls *libc.TLS, pParse uintptr, op int32, pName uintptr) { if zName != 0 { var v uintptr = Xsqlite3GetVdbe(tls, pParse) - if !(v != 0) || (Xsqlite3AuthCheck(tls, pParse, 32, az[op], zName, uintptr(0)) != 0) { + if !(v != 0) || (Xsqlite3AuthCheck(tls, pParse, SQLITE_SAVEPOINT, az[op], zName, uintptr(0)) != 0) { Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, zName) return } - Xsqlite3VdbeAddOp4(tls, v, 0, op, 0, 0, zName, -7) + Xsqlite3VdbeAddOp4(tls, v, OP_Savepoint, op, 0, 0, zName, -7) } } @@ -95682,20 +94909,20 @@ func Xsqlite3OpenTempDatabase(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3. defer tls.Free(8) var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpBt == uintptr(0)) && !(int32((*Parse)(unsafe.Pointer(pParse)).Fexplain) != 0) { + if ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpBt == uintptr(0)) && !(int32((*Parse)(unsafe.Pointer(pParse)).Fexplain) != 0) { var rc int32 // var pBt uintptr at bp, 8 rc = Xsqlite3BtreeOpen(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), db, bp /* &pBt */, 0, flags) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3ErrorMsg(tls, pParse, ts+12366 /* "unable to open a..." */, 0) (*Parse)(unsafe.Pointer(pParse)).Frc = rc return 1 } - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(1)*32)).FpBt = *(*uintptr)(unsafe.Pointer(bp /* pBt */)) + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*32)).FpBt = *(*uintptr)(unsafe.Pointer(bp /* pBt */)) - if 7 == Xsqlite3BtreeSetPageSize(tls, *(*uintptr)(unsafe.Pointer(bp /* pBt */)), (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0) { + if SQLITE_NOMEM == Xsqlite3BtreeSetPageSize(tls, *(*uintptr)(unsafe.Pointer(bp /* pBt */)), (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0) { Xsqlite3OomFault(tls, db) return 1 } @@ -95703,7 +94930,7 @@ func Xsqlite3OpenTempDatabase(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3. return 0 } -var flags int32 = ((((0x00000002 | 0x00000004) | 0x00000010) | 0x00000008) | 0x00000200) /* sqlite3.c:115102:22 */ +var flags int32 = ((((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_DELETEONCLOSE) | SQLITE_OPEN_TEMP_DB) /* sqlite3.c:115102:22 */ // Record the fact that the schema cookie will need to be verified // for database iDb. The code to actually verify the schema cookie @@ -95806,10 +95033,10 @@ func Xsqlite3MayAbort(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:115210:21: * func Xsqlite3HaltConstraint(tls *libc.TLS, pParse uintptr, errCode int32, onError int32, p4 uintptr, p4type I8, p5Errmsg U8) { /* sqlite3.c:115220:21: */ var v uintptr = Xsqlite3GetVdbe(tls, pParse) - if onError == 2 { + if onError == OE_Abort { Xsqlite3MayAbort(tls, pParse) } - Xsqlite3VdbeAddOp4(tls, v, 68, errCode, onError, 0, p4, int32(p4type)) + Xsqlite3VdbeAddOp4(tls, v, OP_Halt, errCode, onError, 0, p4, int32(p4type)) Xsqlite3VdbeChangeP5(tls, v, uint16(p5Errmsg)) } @@ -95825,7 +95052,7 @@ func Xsqlite3UniqueConstraint(tls *libc.TLS, pParse uintptr, onError int32, pIdx var pTab uintptr = (*Index)(unsafe.Pointer(pIdx)).FpTable Xsqlite3StrAccumInit(tls, bp+8 /* &errMsg */, (*Parse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), 0, - *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + uintptr(0)*4))) + *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */)))) if (*Index)(unsafe.Pointer(pIdx)).FaColExpr != 0 { Xsqlite3_str_appendf(tls, bp+8 /* &errMsg */, ts+12436 /* "index '%q'" */, libc.VaList(bp, (*Index)(unsafe.Pointer(pIdx)).FzName)) } else { @@ -95844,12 +95071,12 @@ func Xsqlite3UniqueConstraint(tls *libc.TLS, pParse uintptr, onError int32, pIdx zErr = Xsqlite3StrAccumFinish(tls, bp+8 /* &errMsg */) Xsqlite3HaltConstraint(tls, pParse, func() int32 { - if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2 { - return (19 | (int32(6) << 8)) + if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY { + return (SQLITE_CONSTRAINT | (int32(6) << 8)) } - return (19 | (int32(8) << 8)) + return (SQLITE_CONSTRAINT | (int32(8) << 8)) }(), - onError, zErr, int8(-7), uint8(2)) + onError, zErr, int8(-7), P5_ConstraintUnique) } // Code an OP_Halt due to non-unique rowid. @@ -95862,13 +95089,13 @@ func Xsqlite3RowidConstraint(tls *libc.TLS, pParse uintptr, onError int32, pTab if int32((*Table)(unsafe.Pointer(pTab)).FiPKey) >= 0 { zMsg = Xsqlite3MPrintf(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, ts+9959 /* "%s.%s" */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*Table)(unsafe.Pointer(pTab)).FiPKey)*32)).FzName)) - rc = (19 | (int32(6) << 8)) + rc = (SQLITE_CONSTRAINT | (int32(6) << 8)) } else { zMsg = Xsqlite3MPrintf(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, ts+12450 /* "%s.rowid" */, libc.VaList(bp+16, (*Table)(unsafe.Pointer(pTab)).FzName)) - rc = (19 | (int32(10) << 8)) + rc = (SQLITE_CONSTRAINT | (int32(10) << 8)) } Xsqlite3HaltConstraint(tls, pParse, rc, onError, zMsg, int8(-7), - uint8(2)) + P5_ConstraintUnique) } // Check to see if pIndex uses the collating sequence pColl. Return @@ -95963,7 +95190,7 @@ func Xsqlite3Reindex(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintp // Read the database schema. If an error occurs, leave an error message // and code in pParse and return NULL. - if 0 != Xsqlite3ReadSchema(tls, pParse) { + if SQLITE_OK != Xsqlite3ReadSchema(tls, pParse) { return } @@ -96050,7 +95277,7 @@ func Xsqlite3KeyInfoOfIndex(tls *libc.TLS, pParse uintptr, pIdx uintptr) uintptr // the missing index using the collation-needed callback. For // simplicity, SQLite will not give the application a second chance. libc.SetBitFieldPtr16Uint32(pIdx+100 /* &.bNoQuery */, uint32(1), 8, 0x100) - (*Parse)(unsafe.Pointer(pParse)).Frc = (1 | (int32(2) << 8)) + (*Parse)(unsafe.Pointer(pParse)).Frc = (SQLITE_ERROR | (int32(2) << 8)) } Xsqlite3KeyInfoUnref(tls, pKey) pKey = uintptr(0) @@ -96151,8 +95378,8 @@ func callCollNeeded(tls *libc.TLS, db uintptr, enc int32, zName uintptr) { /* sq if (*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded16 != 0 { var zExternal uintptr var pTmp uintptr = Xsqlite3ValueNew(tls, db) - Xsqlite3ValueSetStr(tls, pTmp, -1, zName, uint8(1), uintptr(0)) - zExternal = Xsqlite3ValueText(tls, pTmp, uint8(2)) + Xsqlite3ValueSetStr(tls, pTmp, -1, zName, SQLITE_UTF8, uintptr(0)) + zExternal = Xsqlite3ValueText(tls, pTmp, SQLITE_UTF16LE) if zExternal != 0 { (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer((db + 368 /* &.xCollNeeded16 */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpCollNeededArg, db, int32((*Sqlite3)(unsafe.Pointer(db)).Fenc), zExternal) } @@ -96174,13 +95401,13 @@ func synthCollSeq(tls *libc.TLS, db uintptr, pColl uintptr) int32 { /* sqlite3.c if (*CollSeq)(unsafe.Pointer(pColl2)).FxCmp != uintptr(0) { libc.Xmemcpy(tls, pColl, pColl2, uint64(unsafe.Sizeof(CollSeq{}))) (*CollSeq)(unsafe.Pointer(pColl)).FxDel = uintptr(0) // Do not copy the destructor - return 0 + return SQLITE_OK } } - return 1 + return SQLITE_ERROR } -var aEnc = [3]U8{U8(3), U8(2), U8(1)} /* sqlite3.c:115598:19 */ +var aEnc = [3]U8{SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8} /* sqlite3.c:115598:19 */ // This routine is called on a collation sequence before it is used to // check that it is defined. An undefined collation sequence exists when @@ -96197,11 +95424,11 @@ func Xsqlite3CheckCollSeq(tls *libc.TLS, pParse uintptr, pColl uintptr) int32 { var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var p uintptr = Xsqlite3GetCollSeq(tls, pParse, (*Sqlite3)(unsafe.Pointer(db)).Fenc, pColl, zName) if !(p != 0) { - return 1 + return SQLITE_ERROR } } - return 0 + return SQLITE_OK } // Locate and return an entry from the db.aCollSeq hash table. If the entry @@ -96224,14 +95451,14 @@ func findCollSeqEntry(tls *libc.TLS, db uintptr, zName uintptr, create int32) ui pColl = Xsqlite3DbMallocZero(tls, db, (uint64((uint64(3) * uint64(unsafe.Sizeof(CollSeq{}))) + uint64(nName)))) if pColl != 0 { var pDel uintptr = uintptr(0) - (*CollSeq)(unsafe.Pointer(pColl + uintptr(0)*40)).FzName = (pColl + uintptr(3)*40) - (*CollSeq)(unsafe.Pointer(pColl + uintptr(0)*40)).Fenc = U8(1) - (*CollSeq)(unsafe.Pointer(pColl + uintptr(1)*40)).FzName = (pColl + uintptr(3)*40) - (*CollSeq)(unsafe.Pointer(pColl + uintptr(1)*40)).Fenc = U8(2) - (*CollSeq)(unsafe.Pointer(pColl + uintptr(2)*40)).FzName = (pColl + uintptr(3)*40) - (*CollSeq)(unsafe.Pointer(pColl + uintptr(2)*40)).Fenc = U8(3) - libc.Xmemcpy(tls, (*CollSeq)(unsafe.Pointer(pColl+uintptr(0)*40)).FzName, zName, uint64(nName)) - pDel = Xsqlite3HashInsert(tls, (db + 600 /* &.aCollSeq */), (*CollSeq)(unsafe.Pointer(pColl+uintptr(0)*40)).FzName, pColl) + (*CollSeq)(unsafe.Pointer(pColl)).FzName = (pColl + 3*40) + (*CollSeq)(unsafe.Pointer(pColl)).Fenc = SQLITE_UTF8 + (*CollSeq)(unsafe.Pointer(pColl + 1*40)).FzName = (pColl + 3*40) + (*CollSeq)(unsafe.Pointer(pColl + 1*40)).Fenc = SQLITE_UTF16LE + (*CollSeq)(unsafe.Pointer(pColl + 2*40)).FzName = (pColl + 3*40) + (*CollSeq)(unsafe.Pointer(pColl + 2*40)).Fenc = SQLITE_UTF16BE + libc.Xmemcpy(tls, (*CollSeq)(unsafe.Pointer(pColl)).FzName, zName, uint64(nName)) + pDel = Xsqlite3HashInsert(tls, (db + 600 /* &.aCollSeq */), (*CollSeq)(unsafe.Pointer(pColl)).FzName, pColl) // If a malloc() failure occurred in sqlite3HashInsert(), it will // return the pColl pointer to be deleted (because it wasn't added @@ -96319,7 +95546,7 @@ func Xsqlite3GetCollSeq(tls *libc.TLS, pParse uintptr, enc U8, pColl uintptr, zN if p == uintptr(0) { Xsqlite3ErrorMsg(tls, pParse, ts+12535 /* "no such collatio..." */, libc.VaList(bp, zName)) - (*Parse)(unsafe.Pointer(pParse)).Frc = (1 | (int32(1) << 8)) + (*Parse)(unsafe.Pointer(pParse)).Frc = (SQLITE_ERROR | (int32(1) << 8)) } return p } @@ -96392,7 +95619,7 @@ func matchQuality(tls *libc.TLS, p uintptr, nArg int32, enc U8) int32 { /* sqlit if (*FuncDef)(unsafe.Pointer(p)).FxSFunc == uintptr(0) { return 0 } - return 6 + return FUNC_PERFECT_MATCH } if int32((*FuncDef)(unsafe.Pointer(p)).FnArg) >= 0 { return 0 @@ -96408,7 +95635,7 @@ func matchQuality(tls *libc.TLS, p uintptr, nArg int32, enc U8) int32 { /* sqlit } // Bonus points if the text encoding matches - if U32(enc) == ((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & U32(0x0003)) { + if U32(enc) == ((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & SQLITE_FUNC_ENCMASK) { match = match + (2) // Exact encoding match } else if ((U32(enc) & (*FuncDef)(unsafe.Pointer(p)).FfuncFlags) & U32(2)) != U32(0) { match = match + (1) // Both are UTF16, but with different byte orders @@ -96436,7 +95663,7 @@ func Xsqlite3InsertBuiltinFuncs(tls *libc.TLS, aDef uintptr, nDef int32) { /* sq var pOther uintptr var zName uintptr = (*FuncDef)(unsafe.Pointer(aDef + uintptr(i)*72)).FzName var nName int32 = Xsqlite3Strlen30(tls, zName) - var h int32 = (((int32(*(*int8)(unsafe.Pointer(zName + uintptr(0))))) + (nName)) % 23) + var h int32 = (((int32(*(*int8)(unsafe.Pointer(zName)))) + (nName)) % SQLITE_FUNC_HASH_SZ) pOther = Xsqlite3FunctionSearch(tls, h, zName) if pOther != 0 { @@ -96499,9 +95726,9 @@ func Xsqlite3FindFunction(tls *libc.TLS, db uintptr, zName uintptr, nArg int32, // have fields overwritten with new information appropriate for the // new function. But the FuncDefs for built-in functions are read-only. // So we must not search for built-ins when creating a new function. - if !(createFlag != 0) && ((pBest == uintptr(0)) || (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0002)) != U32(0))) { + if !(createFlag != 0) && ((pBest == uintptr(0)) || (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_PreferBuiltin) != U32(0))) { bestScore = 0 - h = (((int32(Xsqlite3UpperToLower[U8(*(*int8)(unsafe.Pointer(zName + uintptr(0))))])) + (nName)) % 23) + h = (((int32(Xsqlite3UpperToLower[U8(*(*int8)(unsafe.Pointer(zName)))])) + (nName)) % SQLITE_FUNC_HASH_SZ) p = Xsqlite3FunctionSearch(tls, h, zName) for p != 0 { var score int32 = matchQuality(tls, p, nArg, enc) @@ -96516,13 +95743,13 @@ func Xsqlite3FindFunction(tls *libc.TLS, db uintptr, zName uintptr, nArg int32, // If the createFlag parameter is true and the search did not reveal an // exact match for the name, number of arguments and encoding, then add a // new entry to the hash table and return it. - if ((createFlag != 0) && (bestScore < 6)) && ((libc.AssignUintptr(&pBest, Xsqlite3DbMallocZero(tls, db, (uint64((uint64(unsafe.Sizeof(FuncDef{}))+uint64(nName))+uint64(1)))))) != uintptr(0)) { + if ((createFlag != 0) && (bestScore < FUNC_PERFECT_MATCH)) && ((libc.AssignUintptr(&pBest, Xsqlite3DbMallocZero(tls, db, (uint64((uint64(unsafe.Sizeof(FuncDef{}))+uint64(nName))+uint64(1)))))) != uintptr(0)) { var pOther uintptr var z uintptr - (*FuncDef)(unsafe.Pointer(pBest)).FzName = (pBest + uintptr(1)*72) + (*FuncDef)(unsafe.Pointer(pBest)).FzName = (pBest + 1*72) (*FuncDef)(unsafe.Pointer(pBest)).FnArg = I8(U16(nArg)) (*FuncDef)(unsafe.Pointer(pBest)).FfuncFlags = U32(enc) - libc.Xmemcpy(tls, (pBest + uintptr(1)*72), zName, (uint64(nName + 1))) + libc.Xmemcpy(tls, (pBest + 1*72), zName, (uint64(nName + 1))) for z = (*FuncDef)(unsafe.Pointer(pBest)).FzName; *(*U8)(unsafe.Pointer(z)) != 0; z++ { *(*U8)(unsafe.Pointer(z)) = Xsqlite3UpperToLower[*(*U8)(unsafe.Pointer(z))] } @@ -96575,10 +95802,10 @@ func Xsqlite3SchemaClear(tls *libc.TLS, p uintptr) { /* sqlite3.c:116029:21: */ Xsqlite3HashClear(tls, bp+24 /* &temp1 */) Xsqlite3HashClear(tls, (pSchema + 80 /* &.fkeyHash */)) (*Schema)(unsafe.Pointer(pSchema)).FpSeqTab = uintptr(0) - if (int32((*Schema)(unsafe.Pointer(pSchema)).FschemaFlags) & 0x0001) != 0 { + if (int32((*Schema)(unsafe.Pointer(pSchema)).FschemaFlags) & DB_SchemaLoaded) != 0 { (*Schema)(unsafe.Pointer(pSchema)).FiGeneration++ } - *(*U16)(unsafe.Pointer(pSchema + 114 /* &.schemaFlags */)) &= libc.Uint16FromInt32((^libc.Int32((0x0001 | 0x0008)))) + *(*U16)(unsafe.Pointer(pSchema + 114 /* &.schemaFlags */)) &= libc.Uint16FromInt32((libc.CplInt32((DB_SchemaLoaded | DB_ResetWanted)))) } // Find and return the schema associated with a BTree. Create @@ -96597,7 +95824,7 @@ func Xsqlite3SchemaGet(tls *libc.TLS, db uintptr, pBt uintptr) uintptr { /* sqli Xsqlite3HashInit(tls, (p + 32 /* &.idxHash */)) Xsqlite3HashInit(tls, (p + 56 /* &.trigHash */)) Xsqlite3HashInit(tls, (p + 80 /* &.fkeyHash */)) - (*Schema)(unsafe.Pointer(p)).Fenc = U8(1) + (*Schema)(unsafe.Pointer(p)).Fenc = SQLITE_UTF8 } return p } @@ -96665,11 +95892,11 @@ func tabIsReadOnly(tls *libc.TLS, pParse uintptr, pTab uintptr) int32 { /* sqlit if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { return (libc.Bool32((*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer(Xsqlite3GetVTable(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pTab))).FpMod)).FpModule)).FxUpdate == uintptr(0))) } - if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & (U32(0x0001 | 0x1000))) == U32(0) { + if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & (U32(TF_Readonly | TF_Shadow))) == U32(0) { return 0 } db = (*Parse)(unsafe.Pointer(pParse)).Fdb - if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0001)) != U32(0) { + if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Readonly) != U32(0) { return (libc.Bool32((Xsqlite3WritableSchema(tls, db) == 0) && (int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0))) } @@ -96711,13 +95938,13 @@ func Xsqlite3MaterializeView(tls *libc.TLS, pParse uintptr, pView uintptr, pWher pFrom = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) if pFrom != 0 { - (*SrcList_item)(unsafe.Pointer((pFrom + 8 /* &.a */) + uintptr(0)*112)).FzName = Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pView)).FzName) - (*SrcList_item)(unsafe.Pointer((pFrom + 8 /* &.a */) + uintptr(0)*112)).FzDatabase = Xsqlite3DbStrDup(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) + (*SrcList_item)(unsafe.Pointer((pFrom + 8 /* &.a */))).FzName = Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pView)).FzName) + (*SrcList_item)(unsafe.Pointer((pFrom + 8 /* &.a */))).FzDatabase = Xsqlite3DbStrDup(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) } pSel = Xsqlite3SelectNew(tls, pParse, uintptr(0), pFrom, pWhere, uintptr(0), uintptr(0), pOrderBy, - uint32(0x0020000), pLimit) - Xsqlite3SelectDestInit(tls, bp /* &dest */, 12, iCur) + SF_IncludeHidden, pLimit) + Xsqlite3SelectDestInit(tls, bp /* &dest */, SRT_EphemTab, iCur) Xsqlite3Select(tls, pParse, pSel, bp /* &dest */) Xsqlite3SelectDelete(tls, db, pSel) } @@ -96810,7 +96037,7 @@ __2: // Figure out if we have any triggers and if the table being // deleted from is a view - pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, 126, uintptr(0), uintptr(0)) + pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, TK_DELETE, uintptr(0), uintptr(0)) isView = (libc.Bool32((*Table)(unsafe.Pointer(pTab)).FpSelect != uintptr(0))) bComplex = (libc.Bool32((pTrigger != 0) || (Xsqlite3FkRequired(tls, pParse, pTab, uintptr(0), 0) != 0))) @@ -96835,10 +96062,10 @@ __4: ; iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) - rcauth = Xsqlite3AuthCheck(tls, pParse, 9, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), + rcauth = Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) - if !(rcauth == 1) { + if !(rcauth == SQLITE_DENY) { goto __5 } goto delete_from_cleanup @@ -96847,7 +96074,7 @@ __5: // Assign cursor numbers to the table and all its indices. - iTabCur = libc.AssignPtrInt32((pTabList+8 /* &.a */)+uintptr(0)*112+68 /* &.iCursor */, libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)) + iTabCur = libc.AssignPtrInt32((pTabList+8 /* &.a */)+68 /* &.iCursor */, libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)) nIdx = 0 pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex __6: @@ -96920,7 +96147,7 @@ __13: goto __14 } memCnt = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, memCnt) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, memCnt) __14: ; @@ -96934,7 +96161,7 @@ __14: // the callback returns SQLITE_IGNORE then the DELETE operation proceeds but // the truncate optimization is disabled and all rows are deleted // individually. - if !(((((rcauth == 0) && + if !(((((rcauth == SQLITE_OK) && (pWhere == uintptr(0))) && !(bComplex != 0)) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0)) && @@ -96943,10 +96170,10 @@ __14: } Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, uint8(1), (*Table)(unsafe.Pointer(pTab)).FzName) - if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { goto __17 } - Xsqlite3VdbeAddOp4(tls, v, 137, int32((*Table)(unsafe.Pointer(pTab)).Ftnum), iDb, func() int32 { + Xsqlite3VdbeAddOp4(tls, v, OP_Clear, int32((*Table)(unsafe.Pointer(pTab)).Ftnum), iDb, func() int32 { if memCnt != 0 { return memCnt } @@ -96961,7 +96188,7 @@ __18: goto __20 } - Xsqlite3VdbeAddOp2(tls, v, 137, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) + Xsqlite3VdbeAddOp2(tls, v, OP_Clear, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) goto __19 __19: pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext @@ -96972,8 +96199,8 @@ __20: goto __16 __15: - wcf = (U16((0x0004 | 0x0010) | 0x0400)) - if !(((*NameContext)(unsafe.Pointer(bp+16 /* &sNC */)).FncFlags & 0x00040) != 0) { + wcf = (U16((WHERE_ONEPASS_DESIRED | WHERE_DUPLICATES_OK) | WHERE_SEEK_TABLE)) + if !(((*NameContext)(unsafe.Pointer(bp+16 /* &sNC */)).FncFlags & NC_VarSelect) != 0) { goto __21 } bComplex = 1 @@ -96983,16 +96210,16 @@ __21: if bComplex != 0 { return 0 } - return 0x0008 + return WHERE_ONEPASS_MULTIROW }())) - if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { goto __22 } // For a rowid table, initialize the RowSet to an empty set pPk = uintptr(0) nPk = int16(1) iRowSet = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, iRowSet) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, iRowSet) goto __23 __22: // For a WITHOUT ROWID table, create an ephemeral table used to @@ -97003,7 +96230,7 @@ __22: iPk = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (int32(nPk)) iEphCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - addrEphOpen = Xsqlite3VdbeAddOp2(tls, v, 100, iEphCur, int32(nPk)) + addrEphOpen = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, iEphCur, int32(nPk)) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pPk) __23: ; @@ -97024,7 +96251,7 @@ __24: ; eOnePass = Xsqlite3WhereOkOnePass(tls, pWInfo, bp+72 /* &aiCurOnePass[0] */) - if !(eOnePass != 1) { + if !(eOnePass != ONEPASS_SINGLE) { goto __25 } Xsqlite3MultiWrite(tls, pParse) @@ -97035,7 +96262,7 @@ __25: if !(memCnt != 0) { goto __26 } - Xsqlite3VdbeAddOp2(tls, v, 82, memCnt, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, memCnt, 1) __26: ; @@ -97066,7 +96293,7 @@ __27: __28: ; - if !(eOnePass != 0) { + if !(eOnePass != ONEPASS_OFF) { goto __32 } // For ONEPASS, no need to store the rowid/primary-key. There is only @@ -97083,16 +96310,16 @@ __34: ; libc.Xmemset(tls, aToOpen, 1, (uint64(nIdx + 1))) *(*U8)(unsafe.Pointer(aToOpen + uintptr((nIdx + 1)))) = U8(0) - if !(*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + uintptr(0)*4)) >= 0) { + if !(*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */)) >= 0) { goto __35 } - *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + uintptr(0)*4)) - iTabCur)))) = U8(0) + *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */)) - iTabCur)))) = U8(0) __35: ; - if !(*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + uintptr(1)*4)) >= 0) { + if !(*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + 1*4)) >= 0) { goto __36 } - *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + uintptr(1)*4)) - iTabCur)))) = U8(0) + *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + 1*4)) - iTabCur)))) = U8(0) __36: ; if !(addrEphOpen != 0) { @@ -97109,14 +96336,14 @@ __32: // Add the PK key for this row to the temporary table iKey = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) nKey = int16(0) // Zero tells OP_Found to use a composite key - Xsqlite3VdbeAddOp4(tls, v, 91, iPk, int32(nPk), iKey, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, iPk, int32(nPk), iKey, Xsqlite3IndexAffinityStr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pPk), int32(nPk)) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iEphCur, iKey, iPk, int32(nPk)) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iEphCur, iKey, iPk, int32(nPk)) goto __39 __38: // Add the rowid of the row to be deleted to the RowSet nKey = int16(1) // OP_DeferredSeek always uses a single rowid - Xsqlite3VdbeAddOp2(tls, v, 147, iRowSet, iKey) + Xsqlite3VdbeAddOp2(tls, v, OP_RowSetAdd, iRowSet, iKey) __39: ; __33: @@ -97124,7 +96351,7 @@ __33: // If this DELETE cannot use the ONEPASS strategy, this is the // end of the WHERE loop - if !(eOnePass != 0) { + if !(eOnePass != ONEPASS_OFF) { goto __40 } addrBypass = Xsqlite3VdbeMakeLabel(tls, pParse) @@ -97142,17 +96369,17 @@ __41: goto __42 } iAddrOnce = 0 - if !(eOnePass == 2) { + if !(eOnePass == ONEPASS_MULTI) { goto __43 } - iAddrOnce = Xsqlite3VdbeAddOp0(tls, v, 17) + iAddrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once) __43: ; - Xsqlite3OpenTableAndIndices(tls, pParse, pTab, 97, uint8(0x08), + Xsqlite3OpenTableAndIndices(tls, pParse, pTab, OP_OpenWrite, OPFLAG_FORDELETE, iTabCur, aToOpen, bp+80 /* &iDataCur */, bp+84 /* &iIdxCur */) - if !(eOnePass == 2) { + if !(eOnePass == ONEPASS_MULTI) { goto __44 } Xsqlite3VdbeJumpHereOrPopInst(tls, v, iAddrOnce) @@ -97163,7 +96390,7 @@ __42: // Set up a loop over the rowids/primary-keys that were found in the // where-clause loop above. - if !(eOnePass != 0) { + if !(eOnePass != ONEPASS_OFF) { goto __45 } // OP_Found will use an unpacked key @@ -97171,7 +96398,7 @@ __42: goto __47 } - Xsqlite3VdbeAddOp4Int(tls, v, 29, *(*int32)(unsafe.Pointer(bp + 80 /* iDataCur */)), addrBypass, iKey, int32(nKey)) + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, *(*int32)(unsafe.Pointer(bp + 80 /* iDataCur */)), addrBypass, iKey, int32(nKey)) __47: ; @@ -97180,20 +96407,20 @@ __45: if !(pPk != 0) { goto __48 } - addrLoop = Xsqlite3VdbeAddOp1(tls, v, 37, iEphCur) + addrLoop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iEphCur) if !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { goto __50 } - Xsqlite3VdbeAddOp3(tls, v, 89, iEphCur, 0, iKey) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEphCur, 0, iKey) goto __51 __50: - Xsqlite3VdbeAddOp2(tls, v, 126, iEphCur, iKey) + Xsqlite3VdbeAddOp2(tls, v, OP_RowData, iEphCur, iKey) __51: ; // OP_Found will use a composite key goto __49 __48: - addrLoop = Xsqlite3VdbeAddOp3(tls, v, 42, iRowSet, 0, iKey) + addrLoop = Xsqlite3VdbeAddOp3(tls, v, OP_RowSetRead, iRowSet, 0, iKey) __49: ; @@ -97208,10 +96435,10 @@ __46: Xsqlite3VtabMakeWritable(tls, pParse, pTab) Xsqlite3MayAbort(tls, pParse) - if !(eOnePass == 1) { + if !(eOnePass == ONEPASS_SINGLE) { goto __54 } - Xsqlite3VdbeAddOp1(tls, v, 116, iTabCur) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iTabCur) if !((*Parse)(unsafe.Pointer((pParse))).FpToplevel == uintptr(0)) { goto __55 } @@ -97220,19 +96447,19 @@ __55: ; __54: ; - Xsqlite3VdbeAddOp4(tls, v, 10, 0, 1, iKey, pVTab, -12) - Xsqlite3VdbeChangeP5(tls, v, uint16(2)) + Xsqlite3VdbeAddOp4(tls, v, OP_VUpdate, 0, 1, iKey, pVTab, -12) + Xsqlite3VdbeChangeP5(tls, v, OE_Abort) goto __53 __52: count = (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0)) // True to count changes Xsqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, *(*int32)(unsafe.Pointer(bp + 80 /* iDataCur */)), *(*int32)(unsafe.Pointer(bp + 84 /* iIdxCur */)), - iKey, nKey, uint8(count), uint8(11), uint8(eOnePass), *(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + uintptr(1)*4))) + iKey, nKey, uint8(count), OE_Default, uint8(eOnePass), *(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + 1*4))) __53: ; // End of the loop over all rowids/primary-keys. - if !(eOnePass != 0) { + if !(eOnePass != ONEPASS_OFF) { goto __56 } Xsqlite3VdbeResolveLabel(tls, v, addrBypass) @@ -97242,7 +96469,7 @@ __56: if !(pPk != 0) { goto __58 } - Xsqlite3VdbeAddOp2(tls, v, 5, iEphCur, (addrLoop + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iEphCur, (addrLoop + 1)) Xsqlite3VdbeJumpHere(tls, v, addrLoop) goto __59 __58: @@ -97271,9 +96498,9 @@ __60: if !(memCnt != 0) { goto __61 } - Xsqlite3VdbeAddOp2(tls, v, 80, memCnt, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, memCnt, 1) Xsqlite3VdbeSetNumCols(tls, v, 1) - Xsqlite3VdbeSetColName(tls, v, 0, 0, ts+12633 /* "rows deleted" */, uintptr(0)) + Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, ts+12633 /* "rows deleted" */, uintptr(0)) __61: ; @@ -97340,12 +96567,12 @@ func Xsqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTri // (this can happen if a trigger program has already deleted it), do // not attempt to delete it or fire any DELETE triggers. iLabel = Xsqlite3VdbeMakeLabel(tls, pParse) - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { - opSeek = uint8(32) + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { + opSeek = OP_NotExists } else { - opSeek = uint8(29) + opSeek = OP_NotFound } - if int32(eMode) == 0 { + if int32(eMode) == ONEPASS_OFF { Xsqlite3VdbeAddOp4Int(tls, v, int32(opSeek), iDataCur, iLabel, iPk, int32(nPk)) } @@ -97360,14 +96587,14 @@ func Xsqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTri // TODO: Could use temporary registers here. Also could attempt to // avoid copying the contents of the rowid register. mask = Xsqlite3TriggerColmask(tls, - pParse, pTrigger, uintptr(0), 0, (1 | 2), pTab, int32(onconf)) + pParse, pTrigger, uintptr(0), 0, (TRIGGER_BEFORE | TRIGGER_AFTER), pTab, int32(onconf)) mask = mask | (Xsqlite3FkOldmask(tls, pParse, pTab)) iOld = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (1 + int32((*Table)(unsafe.Pointer(pTab)).FnCol)) // Populate the OLD.* pseudo-table register array. These values will be // used by any BEFORE and AFTER triggers that exist. - Xsqlite3VdbeAddOp2(tls, v, 77, iPk, iOld) + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, iPk, iOld) for iCol = 0; iCol < int32((*Table)(unsafe.Pointer(pTab)).FnCol); iCol++ { if (mask == 0xffffffff) || ((iCol <= 31) && ((mask & (uint32((uint32(1))) << (iCol))) != U32(0))) { @@ -97379,7 +96606,7 @@ func Xsqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTri // Invoke BEFORE DELETE trigger programs. addrStart = Xsqlite3VdbeCurrentAddr(tls, v) Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, - 126, uintptr(0), 1, pTab, iOld, int32(onconf), iLabel) + TK_DELETE, uintptr(0), TRIGGER_BEFORE, pTab, iOld, int32(onconf), iLabel) // If any BEFORE triggers were coded, then seek the cursor to the // row to be deleted again. It may be that the BEFORE triggers moved @@ -97412,23 +96639,23 @@ func Xsqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTri if (*Table)(unsafe.Pointer(pTab)).FpSelect == uintptr(0) { var p5 U8 = U8(0) Xsqlite3GenerateRowIndexDelete(tls, pParse, pTab, iDataCur, iIdxCur, uintptr(0), iIdxNoSeek) - Xsqlite3VdbeAddOp2(tls, v, 122, iDataCur, func() int32 { + Xsqlite3VdbeAddOp2(tls, v, OP_Delete, iDataCur, func() int32 { if count != 0 { - return 0x01 + return OPFLAG_NCHANGE } return 0 }()) if (int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0) || (0 == Xsqlite3_stricmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName, ts+9240 /* "sqlite_stat1" */)) { Xsqlite3VdbeAppendP4(tls, v, pTab, -6) } - if int32(eMode) != 0 { - Xsqlite3VdbeChangeP5(tls, v, uint16(0x04)) + if int32(eMode) != ONEPASS_OFF { + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_AUXDELETE) } if (iIdxNoSeek >= 0) && (iIdxNoSeek != iDataCur) { - Xsqlite3VdbeAddOp1(tls, v, 122, iIdxNoSeek) + Xsqlite3VdbeAddOp1(tls, v, OP_Delete, iIdxNoSeek) } - if int32(eMode) == 2 { - p5 = U8(int32(p5) | (0x02)) + if int32(eMode) == ONEPASS_MULTI { + p5 = U8(int32(p5) | (OPFLAG_SAVEPOSITION)) } Xsqlite3VdbeChangeP5(tls, v, uint16(p5)) } @@ -97440,7 +96667,7 @@ func Xsqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTri // Invoke AFTER DELETE trigger programs. Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, - 126, uintptr(0), 2, pTab, iOld, int32(onconf), iLabel) + TK_DELETE, uintptr(0), TRIGGER_AFTER, pTab, iOld, int32(onconf), iLabel) // Jump here if the row had already been deleted before any BEFORE // trigger programs were invoked. Or if a trigger program throws a @@ -97479,7 +96706,7 @@ func Xsqlite3GenerateRowIndexDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, var pPk uintptr // PRIMARY KEY index, or NULL for rowid tables v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { pPk = uintptr(0) } else { pPk = Xsqlite3PrimaryKeyIndex(tls, pTab) @@ -97504,7 +96731,7 @@ __1: r1 = Xsqlite3GenerateIndexKey(tls, pParse, pIdx, iDataCur, 0, 1, bp /* &iPartIdxLabel */, pPrior, r1) - Xsqlite3VdbeAddOp3(tls, v, 132, (iIdxCur + i), r1, + Xsqlite3VdbeAddOp3(tls, v, OP_IdxDelete, (iIdxCur + i), r1, func() int32 { if (uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 100 /* &.uniqNotNull */)) & 0x8 >> 3))) != 0 { return int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) @@ -97565,7 +96792,7 @@ func Xsqlite3GenerateIndexKey(tls *libc.TLS, pParse uintptr, pIdx uintptr, iData *(*int32)(unsafe.Pointer(piPartIdxLabel)) = Xsqlite3VdbeMakeLabel(tls, pParse) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = (iDataCur + 1) Xsqlite3ExprIfFalseDup(tls, pParse, (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere, *(*int32)(unsafe.Pointer(piPartIdxLabel)), - 0x10) + SQLITE_JUMPIFNULL) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0 pPrior = uintptr(0) // Ticket a9efb42811fa41ee 2019-11-02; // pPartIdxWhere may have corrupted regPrior registers @@ -97596,13 +96823,13 @@ func Xsqlite3GenerateIndexKey(tls *libc.TLS, pParse uintptr, pIdx uintptr, iData // But we are getting ready to store this value back into an index, where // it should be converted by to INTEGER again. So omit the OP_RealAffinity // opcode if it is present - Xsqlite3VdbeDeletePriorOpcode(tls, v, uint8(83)) + Xsqlite3VdbeDeletePriorOpcode(tls, v, OP_RealAffinity) } if regOut != 0 { - Xsqlite3VdbeAddOp3(tls, v, 91, regBase, nCol, regOut) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regBase, nCol, regOut) if (*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FpSelect != 0 { var zAff uintptr = Xsqlite3IndexAffinityStr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pIdx) - Xsqlite3VdbeChangeP4(tls, v, -1, zAff, 0) + Xsqlite3VdbeChangeP4(tls, v, -1, zAff, P4_TRANSIENT) } } Xsqlite3ReleaseTempRange(tls, pParse, regBase, nCol) @@ -97671,11 +96898,11 @@ func minmaxFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s pColl = sqlite3GetFuncCollSeq(tls, context) iBest = 0 - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } for i = 1; i < argc; i++ { - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) == 5 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) == SQLITE_NULL { return } if (Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(iBest)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), pColl) ^ mask) >= 0 { @@ -97688,7 +96915,7 @@ func minmaxFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s // Return the type of the argument. func typeofFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { /* sqlite3.c:117129:13: */ - var i int32 = (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - 1) + var i int32 = (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) - 1) _ = NotUsed // EVIDENCE-OF: R-01470-60482 The sqlite3_value_type(V) interface returns @@ -97704,20 +96931,20 @@ var azType2 = [5]uintptr{ts + 5092 /* "integer" */, ts + 5087 /* "real" */, ts + func lengthFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:117154:13: */ _ = argc - switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) { - case 4: + switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) { + case SQLITE_BLOB: fallthrough - case 1: + case SQLITE_INTEGER: fallthrough - case 2: + case SQLITE_FLOAT: { - Xsqlite3_result_int(tls, context, Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + Xsqlite3_result_int(tls, context, Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) break } - case 3: + case SQLITE_TEXT: { - var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) var z0 uintptr var c uint8 if z == uintptr(0) { @@ -97753,10 +96980,10 @@ func lengthFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s func absFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:117196:13: */ _ = argc - switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) { - case 1: + switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) { + case SQLITE_INTEGER: { - var iVal I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var iVal I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) if iVal < int64(0) { if iVal == ((int64(-1)) - (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))) { // IMP: R-31676-45509 If X is the integer -9223372036854775808 @@ -97771,7 +96998,7 @@ func absFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli break } - case 5: + case SQLITE_NULL: { // IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. Xsqlite3_result_null(tls, context) @@ -97784,7 +97011,7 @@ func absFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli // something that can be converted into a number, we have: // IMP: R-01992-00519 Abs(X) returns 0.0 if X is a string or blob // that cannot be converted to a numeric value. - var rVal float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var rVal float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) if rVal < float64(0) { rVal = -rVal } @@ -97821,36 +97048,36 @@ func instrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq pC2 = uintptr(0) _ = argc - typeHaystack = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - typeNeedle = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - if !((typeHaystack == 5) || (typeNeedle == 5)) { + typeHaystack = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) + typeNeedle = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + if !((typeHaystack == SQLITE_NULL) || (typeNeedle == SQLITE_NULL)) { goto __1 } return __1: ; - nHaystack = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - nNeedle = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + nHaystack = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + nNeedle = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if !(nNeedle > 0) { goto __2 } - if !((typeHaystack == 4) && (typeNeedle == 4)) { + if !((typeHaystack == SQLITE_BLOB) && (typeNeedle == SQLITE_BLOB)) { goto __3 } - zHaystack = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zNeedle = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zHaystack = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) + zNeedle = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) isText = 0 goto __4 __3: - if !((typeHaystack != 4) && (typeNeedle != 4)) { + if !((typeHaystack != SQLITE_BLOB) && (typeNeedle != SQLITE_BLOB)) { goto __5 } - zHaystack = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zNeedle = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zHaystack = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + zNeedle = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) isText = 1 goto __6 __5: - pC1 = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + pC1 = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(argv))) zHaystack = Xsqlite3_value_text(tls, pC1) if !(zHaystack == uintptr(0)) { goto __7 @@ -97859,7 +97086,7 @@ __5: __7: ; nHaystack = Xsqlite3_value_bytes(tls, pC1) - pC2 = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pC2 = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) zNeedle = Xsqlite3_value_text(tls, pC2) if !(zNeedle == uintptr(0)) { goto __8 @@ -97879,10 +97106,10 @@ __4: goto endInstrOOM __9: ; - firstChar = *(*uint8)(unsafe.Pointer(zNeedle + uintptr(0))) + firstChar = *(*uint8)(unsafe.Pointer(zNeedle)) __10: if !((nNeedle <= nHaystack) && - ((int32(*(*uint8)(unsafe.Pointer(zHaystack + uintptr(0)))) != int32(firstChar)) || (libc.Xmemcmp(tls, zHaystack, zNeedle, uint64(nNeedle)) != 0))) { + ((int32(*(*uint8)(unsafe.Pointer(zHaystack))) != int32(firstChar)) || (libc.Xmemcmp(tls, zHaystack, zNeedle, uint64(nNeedle)) != 0))) { goto __11 } N++ @@ -97891,7 +97118,7 @@ __12: zHaystack++ goto __13 __13: - if (isText != 0) && ((int32(*(*uint8)(unsafe.Pointer(zHaystack + uintptr(0)))) & 0xc0) == 0x80) { + if (isText != 0) && ((int32(*(*uint8)(unsafe.Pointer(zHaystack))) & 0xc0) == 0x80) { goto __12 } goto __14 @@ -97931,12 +97158,12 @@ func printfFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s var n int32 var db uintptr = Xsqlite3_context_db_handle(tls, context) - if (argc >= 1) && ((libc.AssignUintptr(&zFormat, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) != uintptr(0)) { + if (argc >= 1) && ((libc.AssignUintptr(&zFormat, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))))) != uintptr(0)) { (*PrintfArguments)(unsafe.Pointer(bp + 40 /* &x */)).FnArg = (argc - 1) (*PrintfArguments)(unsafe.Pointer(bp + 40 /* &x */)).FnUsed = 0 (*PrintfArguments)(unsafe.Pointer(bp + 40 /* &x */)).FapArg = (argv + uintptr(1)*8) - Xsqlite3StrAccumInit(tls, bp+8 /* &str */, db, uintptr(0), 0, *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) - (*StrAccum)(unsafe.Pointer(bp + 8 /* &str */)).FprintfFlags = U8(0x02) + Xsqlite3StrAccumInit(tls, bp+8 /* &str */, db, uintptr(0), 0, *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) + (*StrAccum)(unsafe.Pointer(bp + 8 /* &str */)).FprintfFlags = SQLITE_PRINTF_SQLFUNC Xsqlite3_str_appendf(tls, bp+8 /* &str */, zFormat, libc.VaList(bp, bp+40 /* &x */)) n = int32((*StrAccum)(unsafe.Pointer(bp + 8 /* &str */)).FnChar) Xsqlite3_result_text(tls, context, Xsqlite3StrAccumFinish(tls, bp+8 /* &str */), n, @@ -97963,21 +97190,21 @@ func substrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s var p2 I64 var negP2 int32 = 0 - if (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) == 5) || - ((argc == 3) && (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) == 5)) { + if (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) == SQLITE_NULL) || + ((argc == 3) && (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) == SQLITE_NULL)) { return } - p0type = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - p1 = I64(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) - if p0type == 4 { - len = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - z = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + p0type = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) + p1 = I64(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) + if p0type == SQLITE_BLOB { + len = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + z = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) if z == uintptr(0) { return } } else { - z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if z == uintptr(0) { return } @@ -97996,13 +97223,13 @@ func substrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s } } if argc == 3 { - p2 = I64(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + p2 = I64(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) if p2 < int64(0) { p2 = -p2 negP2 = 1 } } else { - p2 = I64(*(*int32)(unsafe.Pointer((Xsqlite3_context_db_handle(tls, context) + 124 /* &.aLimit */) + uintptr(0)*4))) + p2 = I64(*(*int32)(unsafe.Pointer((Xsqlite3_context_db_handle(tls, context) + 124 /* &.aLimit */)))) } if p1 < int64(0) { p1 = p1 + (I64(len)) @@ -98026,7 +97253,7 @@ func substrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s } } - if p0type != 4 { + if p0type != SQLITE_BLOB { for (*(*uint8)(unsafe.Pointer(z)) != 0) && (p1 != 0) { { if (int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))) >= 0xc0 { @@ -98049,7 +97276,7 @@ func substrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s } Xsqlite3_result_text64(tls, context, z, (uint64((int64(z2) - int64(z)) / 1)), libc.UintptrFromInt32(-1), - uint8(1)) + SQLITE_UTF8) } else { if (p1 + p2) > I64(len) { p2 = (I64(len) - p1) @@ -98072,10 +97299,10 @@ func roundFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq var zBuf uintptr if argc == 2 { - if 5 == Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) { + if SQLITE_NULL == Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) { return } - n = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + n = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if n > 30 { n = 30 } @@ -98083,10 +97310,10 @@ func roundFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq n = 0 } } - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } - *(*float64)(unsafe.Pointer(bp + 16 /* r */)) = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + *(*float64)(unsafe.Pointer(bp + 16 /* r */)) = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) // If Y==0 and X will fit in a 64-bit int, // handle the rounding directly, // otherwise use printf. @@ -98105,7 +97332,7 @@ func roundFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq Xsqlite3_result_error_nomem(tls, context) return } - Xsqlite3AtoF(tls, zBuf, bp+16 /* &r */, Xsqlite3Strlen30(tls, zBuf), uint8(1)) + Xsqlite3AtoF(tls, zBuf, bp+16 /* &r */, Xsqlite3Strlen30(tls, zBuf), SQLITE_UTF8) Xsqlite3_free(tls, zBuf) } Xsqlite3_result_double(tls, context, *(*float64)(unsafe.Pointer(bp + 16 /* r */))) @@ -98120,7 +97347,7 @@ func contextMalloc(tls *libc.TLS, context uintptr, nByte I64) uintptr { /* sqlit var z uintptr var db uintptr = Xsqlite3_context_db_handle(tls, context) - if nByte > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) { + if nByte > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) { Xsqlite3_result_error_toobig(tls, context) z = uintptr(0) } else { @@ -98139,8 +97366,8 @@ func upperFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq var i int32 var n int32 _ = argc - z2 = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + z2 = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) // Verify that the call to _bytes() does not invalidate the _text() pointer if z2 != 0 { @@ -98160,8 +97387,8 @@ func lowerFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq var i int32 var n int32 _ = argc - z2 = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + z2 = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) // Verify that the call to _bytes() does not invalidate the _text() pointer if z2 != 0 { @@ -98212,7 +97439,7 @@ func randomBlob(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s var p uintptr _ = argc - n = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + n = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) if n < int64(1) { n = int64(1) } @@ -98271,25 +97498,13 @@ type compareInfo = struct { // macro for fast reading of the next character in the common case where // the next character is ASCII. -var globInfo = compareInfo{ - FmatchAll: U8('*'), - FmatchOne: U8('?'), - FmatchSet: U8('['), - FnoCase: U8(0)} /* sqlite3.c:117677:33 */ +var globInfo = compareInfo{FmatchAll: U8('*'), FmatchOne: U8('?'), FmatchSet: U8('[')} /* sqlite3.c:117677:33 */ // The correct SQL-92 behavior is for the LIKE operator to ignore // case. Thus 'a' LIKE 'A' would be true. -var likeInfoNorm = compareInfo{ - FmatchAll: U8('%'), - FmatchOne: U8('_'), - FmatchSet: U8(0), - FnoCase: U8(1)} /* sqlite3.c:117680:33 */ +var likeInfoNorm = compareInfo{FmatchAll: U8('%'), FmatchOne: U8('_'), FnoCase: U8(1)} /* sqlite3.c:117680:33 */ // If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator // is case sensitive causing 'a' LIKE 'A' to be false -var likeInfoAlt = compareInfo{ - FmatchAll: U8('%'), - FmatchOne: U8('_'), - FmatchSet: U8(0), - FnoCase: U8(0)} /* sqlite3.c:117683:33 */ +var likeInfoAlt = compareInfo{FmatchAll: U8('%'), FmatchOne: U8('_')} /* sqlite3.c:117683:33 */ // Possible error returns from patternMatch() @@ -98343,7 +97558,7 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint var zEscaped uintptr = uintptr(0) // One past the last escaped input char for (libc.AssignUint32(&c, func() uint32 { - if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */)) + uintptr(0)))) < 0x80 { + if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */))))) < 0x80 { return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp /* zPattern */)), 1)))) } return Xsqlite3Utf8Read(tls, bp /* &zPattern */) @@ -98353,22 +97568,22 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint // are also "?" characters, skip those as well, but consume a // single character of the input string for each "?" skipped for ((libc.AssignUint32(&c, func() uint32 { - if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */)) + uintptr(0)))) < 0x80 { + if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */))))) < 0x80 { return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp /* zPattern */)), 1)))) } return Xsqlite3Utf8Read(tls, bp /* &zPattern */) }())) == matchAll) || (c == matchOne) { if (c == matchOne) && (Xsqlite3Utf8Read(tls, bp+8 /* &zString */) == U32(0)) { - return 2 + return SQLITE_NOWILDCARDMATCH } } if c == U32(0) { - return 0 // "*" at the end of the pattern matches + return SQLITE_MATCH // "*" at the end of the pattern matches } else if c == matchOther { if int32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchSet) == 0 { c = Xsqlite3Utf8Read(tls, bp /* &zPattern */) if c == U32(0) { - return 2 + return SQLITE_NOWILDCARDMATCH } } else { // "[...]" immediately follows the "*". We have to do a slow @@ -98376,7 +97591,7 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint // '[' is a single-byte character for *(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)))) != 0 { var bMatch int32 = patternCompare(tls, (*(*uintptr)(unsafe.Pointer(bp /* zPattern */)) + libc.UintptrFromInt32(-1)), *(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)), pInfo, matchOther) - if bMatch != 1 { + if bMatch != SQLITE_NOMATCH { return bMatch } { @@ -98388,7 +97603,7 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint } } - return 2 + return SQLITE_NOWILDCARDMATCH } } @@ -98405,28 +97620,28 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint var bMatch int32 if noCase != 0 { - *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + uintptr(0))) = (int8((c) & U32(^(int32(Xsqlite3CtypeMap[uint8(c)]) & 0x20)))) - *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + uintptr(1))) = int8(Xsqlite3UpperToLower[uint8(c)]) - *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + uintptr(2))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */)) = (int8((c) & U32(^(int32(Xsqlite3CtypeMap[uint8(c)]) & 0x20)))) + *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + 1)) = int8(Xsqlite3UpperToLower[uint8(c)]) + *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + 2)) = int8(0) } else { - *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + uintptr(0))) = int8(c) - *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + uintptr(1))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */)) = int8(c) + *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + 1)) = int8(0) } for 1 != 0 { *(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)) += uintptr(libc.Xstrcspn(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)), bp+16 /* &zStop[0] */)) - if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)) + uintptr(0)))) == 0 { + if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */))))) == 0 { break } *(*uintptr)(unsafe.Pointer(bp + 8 /* zString */))++ bMatch = patternCompare(tls, *(*uintptr)(unsafe.Pointer(bp /* zPattern */)), *(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)), pInfo, matchOther) - if bMatch != 1 { + if bMatch != SQLITE_NOMATCH { return bMatch } } } else { var bMatch int32 for (libc.AssignUint32(&c2, func() uint32 { - if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)) + uintptr(0)))) < 0x80 { + if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */))))) < 0x80 { return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)), 1)))) } return Xsqlite3Utf8Read(tls, bp+8 /* &zString */) @@ -98435,18 +97650,18 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint continue } bMatch = patternCompare(tls, *(*uintptr)(unsafe.Pointer(bp /* zPattern */)), *(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)), pInfo, matchOther) - if bMatch != 1 { + if bMatch != SQLITE_NOMATCH { return bMatch } } } - return 2 + return SQLITE_NOWILDCARDMATCH } if c == matchOther { if int32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchSet) == 0 { c = Xsqlite3Utf8Read(tls, bp /* &zPattern */) if c == U32(0) { - return 1 + return SQLITE_NOMATCH } zEscaped = *(*uintptr)(unsafe.Pointer(bp /* zPattern */)) } else { @@ -98455,7 +97670,7 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint var invert int32 = 0 c = Xsqlite3Utf8Read(tls, bp+8 /* &zString */) if c == U32(0) { - return 1 + return SQLITE_NOMATCH } c2 = Xsqlite3Utf8Read(tls, bp /* &zPattern */) if c2 == U32('^') { @@ -98469,7 +97684,7 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint c2 = Xsqlite3Utf8Read(tls, bp /* &zPattern */) } for (c2 != 0) && (c2 != U32(']')) { - if (((c2 == U32('-')) && (int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */)) + uintptr(0)))) != ']')) && (int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */)) + uintptr(0)))) != 0)) && (prior_c > U32(0)) { + if (((c2 == U32('-')) && (int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */))))) != ']')) && (int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */))))) != 0)) && (prior_c > U32(0)) { c2 = Xsqlite3Utf8Read(tls, bp /* &zPattern */) if (c >= prior_c) && (c <= c2) { seen = 1 @@ -98484,13 +97699,13 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint c2 = Xsqlite3Utf8Read(tls, bp /* &zPattern */) } if (c2 == U32(0)) || ((seen ^ invert) == 0) { - return 1 + return SQLITE_NOMATCH } continue } } c2 = func() uint32 { - if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)) + uintptr(0)))) < 0x80 { + if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */))))) < 0x80 { return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)), 1)))) } return Xsqlite3Utf8Read(tls, bp+8 /* &zString */) @@ -98504,12 +97719,12 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint if ((c == matchOne) && (*(*uintptr)(unsafe.Pointer(bp /* zPattern */)) != zEscaped)) && (c2 != U32(0)) { continue } - return 1 + return SQLITE_NOMATCH } if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */))))) == 0 { - return 0 + return SQLITE_MATCH } - return 1 + return SQLITE_NOMATCH } // The sqlite3_strglob() interface. Return 0 on a match (like strcmp()) and @@ -98550,24 +97765,24 @@ func likeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql var pInfo uintptr = Xsqlite3_user_data(tls, context) // var backupInfo compareInfo at bp+8, 4 - if (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 4) || - (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) == 4) { + if (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_BLOB) || + (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) == SQLITE_BLOB) { Xsqlite3_result_int(tls, context, 0) return } // Limit the length of the LIKE or GLOB pattern to avoid problems // of deep recursion and N*N behavior in patternCompare(). - nPat = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + nPat = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) - if nPat > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(8)*4)) { + if nPat > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 8*4)) { Xsqlite3_result_error(tls, context, ts+12678 /* "LIKE or GLOB pat..." */, -1) return } if argc == 3 { // The escape character string must consist of a single UTF-8 character. // Otherwise, return an error. - *(*uintptr)(unsafe.Pointer(bp /* zEsc */)) = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + *(*uintptr)(unsafe.Pointer(bp /* zEsc */)) = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) if *(*uintptr)(unsafe.Pointer(bp /* zEsc */)) == uintptr(0) { return } @@ -98590,11 +97805,11 @@ func likeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql } else { escape = U32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchSet) } - zB = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zA = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zB = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + zA = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if (zA != 0) && (zB != 0) { Xsqlite3_result_int(tls, context, - (libc.Bool32(patternCompare(tls, zB, zA, pInfo, escape) == 0))) + (libc.Bool32(patternCompare(tls, zB, zA, pInfo, escape) == SQLITE_MATCH))) } } @@ -98604,8 +97819,8 @@ func likeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql func nullifFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { /* sqlite3.c:117967:13: */ var pColl uintptr = sqlite3GetFuncCollSeq(tls, context) _ = NotUsed - if Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), pColl) != 0 { - Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + if Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(argv)), *(*uintptr)(unsafe.Pointer(argv + 1*8)), pColl) != 0 { + Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv))) } } @@ -98639,7 +97854,7 @@ func errlogFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s _ = argc _ = context - Xsqlite3_log(tls, Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))), ts+2690 /* "%s" */, libc.VaList(bp, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))))) + Xsqlite3_log(tls, Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))), ts+2690 /* "%s" */, libc.VaList(bp, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))))) } // Implementation of the sqlite_compileoption_used() function. @@ -98652,7 +97867,7 @@ func compileoptionusedFunc(tls *libc.TLS, context uintptr, argc int32, argv uint // IMP: R-39564-36305 The sqlite_compileoption_used() SQL // function is a wrapper around the sqlite3_compileoption_used() C/C++ // function. - if (libc.AssignUintptr(&zOptName, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) != uintptr(0) { + if (libc.AssignUintptr(&zOptName, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))))) != uintptr(0) { Xsqlite3_result_int(tls, context, Xsqlite3_compileoption_used(tls, zOptName)) } } @@ -98666,7 +97881,7 @@ func compileoptiongetFunc(tls *libc.TLS, context uintptr, argc int32, argv uintp _ = argc // IMP: R-04922-24076 The sqlite_compileoption_get() SQL function // is a wrapper around the sqlite3_compileoption_get() C/C++ function. - n = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + n = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) Xsqlite3_result_text(tls, context, Xsqlite3_compileoption_get(tls, n), -1, uintptr(0)) } @@ -98687,17 +97902,17 @@ func quoteFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq defer tls.Free(80) _ = argc - switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) { - case 2: + switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) { + case SQLITE_FLOAT: { var r1 float64 // var r2 float64 at bp+72, 8 // var zBuf [50]int8 at bp+16, 50 - r1 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + r1 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+16 /* &zBuf[0] */, ts+3875 /* "%!.15g" */, libc.VaList(bp, r1)) - Xsqlite3AtoF(tls, bp+16 /* &zBuf[0] */, bp+72 /* &r2 */, 20, uint8(1)) + Xsqlite3AtoF(tls, bp+16 /* &zBuf[0] */, bp+72 /* &r2 */, 20, SQLITE_UTF8) if r1 != *(*float64)(unsafe.Pointer(bp + 72 /* r2 */)) { Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+16 /* &zBuf[0] */, ts+12756 /* "%!.20e" */, libc.VaList(bp+8, r1)) } @@ -98705,17 +97920,17 @@ func quoteFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq break } - case 1: + case SQLITE_INTEGER: { - Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv))) break } - case 4: + case SQLITE_BLOB: { var zText uintptr = uintptr(0) - var zBlob uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var nBlob int32 = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zBlob uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) + var nBlob int32 = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) // No encoding change zText = contextMalloc(tls, context, ((int64(2) * I64(nBlob)) + int64(4))) if zText != 0 { @@ -98726,20 +97941,20 @@ func quoteFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq } *(*int8)(unsafe.Pointer(zText + uintptr(((nBlob * 2) + 2)))) = int8('\'') *(*int8)(unsafe.Pointer(zText + uintptr(((nBlob * 2) + 3)))) = int8(0) - *(*int8)(unsafe.Pointer(zText + uintptr(0))) = int8('X') - *(*int8)(unsafe.Pointer(zText + uintptr(1))) = int8('\'') + *(*int8)(unsafe.Pointer(zText)) = int8('X') + *(*int8)(unsafe.Pointer(zText + 1)) = int8('\'') Xsqlite3_result_text(tls, context, zText, -1, libc.UintptrFromInt32(-1)) Xsqlite3_free(tls, zText) } break } - case 3: + case SQLITE_TEXT: { var i int32 var j int32 var n U64 - var zArg uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zArg uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) var z uintptr if zArg == uintptr(0) { @@ -98754,7 +97969,7 @@ func quoteFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq } z = contextMalloc(tls, context, (((I64(i)) + (I64(n))) + int64(3))) if z != 0 { - *(*int8)(unsafe.Pointer(z + uintptr(0))) = int8('\'') + *(*int8)(unsafe.Pointer(z)) = int8('\'') i = 0 j = 1 for ; *(*uint8)(unsafe.Pointer(zArg + uintptr(i))) != 0; i++ { @@ -98786,9 +98001,9 @@ func unicodeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* bp := tls.Alloc(8) defer tls.Free(8) - *(*uintptr)(unsafe.Pointer(bp /* z */)) = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + *(*uintptr)(unsafe.Pointer(bp /* z */)) = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) _ = argc - if (*(*uintptr)(unsafe.Pointer(bp /* z */)) != 0) && (*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* z */)) + uintptr(0))) != 0) { + if (*(*uintptr)(unsafe.Pointer(bp /* z */)) != 0) && (*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* z */)))) != 0) { Xsqlite3_result_int(tls, context, int32(Xsqlite3Utf8Read(tls, bp /* &z */))) } } @@ -98829,7 +98044,7 @@ func charFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql *(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = (uint8(0x80 + int32((U8(c & uint32(0x3F)))))) } } - Xsqlite3_result_text64(tls, context, z, (uint64((int64(zOut) - int64(z)) / 1)), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})), uint8(1)) + Xsqlite3_result_text64(tls, context, z, (uint64((int64(zOut) - int64(z)) / 1)), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})), SQLITE_UTF8) } // The hex() function. Interpret the argument as a blob. Return @@ -98842,8 +98057,8 @@ func hexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli var z uintptr _ = argc - pBlob = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + pBlob = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) + n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) // No encoding change z = libc.AssignUintptr(&zHex, contextMalloc(tls, context, (((I64(n))*int64(2))+int64(1)))) if zHex != 0 { @@ -98877,7 +98092,7 @@ func zeroblobFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* var rc int32 _ = argc - n = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + n = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) if n < int64(0) { n = int64(0) } @@ -98907,29 +98122,29 @@ func replaceFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* var db uintptr = Xsqlite3_context_db_handle(tls, context) _ = argc - zStr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zStr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zStr == uintptr(0) { return } - nStr = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + nStr = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) // No encoding change - zPattern = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zPattern = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if zPattern == uintptr(0) { return } - if int32(*(*uint8)(unsafe.Pointer(zPattern + uintptr(0)))) == 0 { + if int32(*(*uint8)(unsafe.Pointer(zPattern))) == 0 { - Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv))) return } - nPattern = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + nPattern = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) // No encoding change - zRep = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + zRep = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) if zRep == uintptr(0) { return } - nRep = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + nRep = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) nOut = (I64(nStr + 1)) @@ -98940,13 +98155,13 @@ func replaceFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* loopLimit = (nStr - nPattern) cntExpand = uint32(0) for i = libc.AssignInt32(&j, 0); i <= loopLimit; i++ { - if (int32(*(*uint8)(unsafe.Pointer(zStr + uintptr(i)))) != int32(*(*uint8)(unsafe.Pointer(zPattern + uintptr(0))))) || (libc.Xmemcmp(tls, (zStr+uintptr(i)), zPattern, uint64(nPattern)) != 0) { + if (int32(*(*uint8)(unsafe.Pointer(zStr + uintptr(i)))) != int32(*(*uint8)(unsafe.Pointer(zPattern)))) || (libc.Xmemcmp(tls, (zStr+uintptr(i)), zPattern, uint64(nPattern)) != 0) { *(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&j, 1)))) = *(*uint8)(unsafe.Pointer(zStr + uintptr(i))) } else { if nRep > nPattern { nOut = nOut + (I64(nRep - nPattern)) - if (nOut - int64(1)) > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) { + if (nOut - int64(1)) > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) { Xsqlite3_result_error_toobig(tls, context) Xsqlite3_free(tls, zOut) return @@ -98990,21 +98205,21 @@ func trimFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql var azChar uintptr = uintptr(0) // Individual characters in zCharSet var nChar int32 // Number of characters in zCharSet - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } - zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zIn == uintptr(0) { return } - nIn = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + nIn = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) if argc == 1 { nChar = 1 aLen = uintptr(uintptr(unsafe.Pointer(&lenOne))) azChar = uintptr(uintptr(unsafe.Pointer(&azOne))) zCharSet = uintptr(0) - } else if (libc.AssignUintptr(&zCharSet, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))))) == uintptr(0) { + } else if (libc.AssignUintptr(&zCharSet, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))))) == uintptr(0) { return } else { var z uintptr @@ -99102,7 +98317,7 @@ func soundexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* var i int32 var j int32 - zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zIn == uintptr(0) { zIn = ts + 703 /* "" */ } @@ -99110,7 +98325,7 @@ func soundexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* } if *(*U8)(unsafe.Pointer(zIn + uintptr(i))) != 0 { var prevcode U8 = iCode[(int32(*(*U8)(unsafe.Pointer(zIn + uintptr(i)))) & 0x7f)] - *(*int8)(unsafe.Pointer(bp /* &zResult[0] */ + uintptr(0))) = (int8((int32(*(*U8)(unsafe.Pointer(zIn + uintptr(i))))) & ^(int32(Xsqlite3CtypeMap[*(*U8)(unsafe.Pointer(zIn + uintptr(i)))]) & 0x20))) + *(*int8)(unsafe.Pointer(bp /* &zResult[0] */)) = (int8((int32(*(*U8)(unsafe.Pointer(zIn + uintptr(i))))) & ^(int32(Xsqlite3CtypeMap[*(*U8)(unsafe.Pointer(zIn + uintptr(i)))]) & 0x20))) for j = 1; (j < 4) && (*(*U8)(unsafe.Pointer(zIn + uintptr(i))) != 0); i++ { var code int32 = int32(iCode[(int32(*(*U8)(unsafe.Pointer(zIn + uintptr(i)))) & 0x7f)]) if code > 0 { @@ -99150,20 +98365,20 @@ func loadExt(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli bp := tls.Alloc(8) defer tls.Free(8) - var zFile uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zFile uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) var zProc uintptr var db uintptr = Xsqlite3_context_db_handle(tls, context) *(*uintptr)(unsafe.Pointer(bp /* zErrMsg */)) = uintptr(0) // Disallow the load_extension() SQL function unless the SQLITE_LoadExtFunc // flag is set. See the sqlite3_enable_load_extension() API. - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00020000)) == uint64(0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_LoadExtFunc) == uint64(0) { Xsqlite3_result_error(tls, context, ts+9998 /* "not authorized" */, -1) return } if argc == 2 { - zProc = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zProc = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) } else { zProc = uintptr(0) } @@ -99202,17 +98417,17 @@ func sumStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli _ = argc p = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(SumCtx{}))) - type1 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - if (p != 0) && (type1 != 5) { + type1 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv))) + if (p != 0) && (type1 != SQLITE_NULL) { (*SumCtx)(unsafe.Pointer(p)).Fcnt++ - if type1 == 1 { - var v I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + if type1 == SQLITE_INTEGER { + var v I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) *(*float64)(unsafe.Pointer(p /* &.rSum */)) += (float64(v)) if ((int32((*SumCtx)(unsafe.Pointer(p)).Fapprox) | int32((*SumCtx)(unsafe.Pointer(p)).Foverflow)) == 0) && (Xsqlite3AddInt64(tls, (p+8 /* &.iSum */), v) != 0) { (*SumCtx)(unsafe.Pointer(p)).Fapprox = libc.AssignPtrUint8(p+24 /* &.overflow */, U8(1)) } } else { - *(*float64)(unsafe.Pointer(p /* &.rSum */)) += (Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + *(*float64)(unsafe.Pointer(p /* &.rSum */)) += (Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))) (*SumCtx)(unsafe.Pointer(p)).Fapprox = U8(1) } } @@ -99224,19 +98439,19 @@ func sumInverse(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s _ = argc p = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(SumCtx{}))) - type1 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + type1 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv))) // p is always non-NULL because sumStep() will have been called first // to initialize it - if (p != 0) && (type1 != 5) { + if (p != 0) && (type1 != SQLITE_NULL) { (*SumCtx)(unsafe.Pointer(p)).Fcnt-- - if (type1 == 1) && (int32((*SumCtx)(unsafe.Pointer(p)).Fapprox) == 0) { - var v I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + if (type1 == SQLITE_INTEGER) && (int32((*SumCtx)(unsafe.Pointer(p)).Fapprox) == 0) { + var v I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) *(*float64)(unsafe.Pointer(p /* &.rSum */)) -= (float64(v)) *(*I64)(unsafe.Pointer(p + 8 /* &.iSum */)) -= (v) } else { - *(*float64)(unsafe.Pointer(p /* &.rSum */)) -= (Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + *(*float64)(unsafe.Pointer(p /* &.rSum */)) -= (Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))) } } } @@ -99287,7 +98502,7 @@ type CountCtx = CountCtx1 /* sqlite3.c:118654:25 */ func countStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:118665:13: */ var p uintptr p = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(CountCtx{}))) - if ((argc == 0) || (5 != Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) && (p != 0) { + if ((argc == 0) || (SQLITE_NULL != Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))))) && (p != 0) { (*CountCtx)(unsafe.Pointer(p)).Fn++ } @@ -99313,14 +98528,14 @@ func countInverse(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* sql var p uintptr p = Xsqlite3_aggregate_context(tls, ctx, int32(unsafe.Sizeof(CountCtx{}))) // p is always non-NULL since countStep() will have been called first - if ((argc == 0) || (5 != Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) && (p != 0) { + if ((argc == 0) || (SQLITE_NULL != Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))))) && (p != 0) { (*CountCtx)(unsafe.Pointer(p)).Fn-- } } // Routines to implement min() and max() aggregate functions. func minmaxStep(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { /* sqlite3.c:118705:13: */ - var pArg uintptr = *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)) + var pArg uintptr = *(*uintptr)(unsafe.Pointer(argv)) var pBest uintptr _ = NotUsed @@ -99329,7 +98544,7 @@ func minmaxStep(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { / return } - if Xsqlite3_value_type(tls, pArg) == 5 { + if Xsqlite3_value_type(tls, pArg) == SQLITE_NULL { if (*Mem)(unsafe.Pointer(pBest)).Fflags != 0 { sqlite3SkipAccumulatorLoad(tls, context) } @@ -99386,7 +98601,7 @@ func groupConcatStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { var nVal int32 var nSep int32 - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } pAccum = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(StrAccum{}))) @@ -99394,11 +98609,11 @@ func groupConcatStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { if pAccum != 0 { var db uintptr = Xsqlite3_context_db_handle(tls, context) var firstTerm int32 = (libc.Bool32((*StrAccum)(unsafe.Pointer(pAccum)).FmxAlloc == U32(0))) - (*StrAccum)(unsafe.Pointer(pAccum)).FmxAlloc = U32(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) + (*StrAccum)(unsafe.Pointer(pAccum)).FmxAlloc = U32(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) if !(firstTerm != 0) { if argc == 2 { - zSep = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - nSep = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zSep = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + nSep = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) } else { zSep = ts + 10660 /* "," */ nSep = 1 @@ -99407,8 +98622,8 @@ func groupConcatStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { Xsqlite3_str_append(tls, pAccum, zSep, nSep) } } - zVal = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - nVal = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zVal = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + nVal = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) if zVal != 0 { Xsqlite3_str_append(tls, pAccum, zVal, nVal) } @@ -99419,16 +98634,16 @@ func groupConcatInverse(tls *libc.TLS, context uintptr, argc int32, argv uintptr var n int32 var pAccum uintptr - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } pAccum = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(StrAccum{}))) // pAccum is always non-NULL since groupConcatStep() will have always // run frist to initialize it if pAccum != 0 { - n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) if argc == 2 { - n = n + (Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) + n = n + (Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) } else { n++ } @@ -99448,9 +98663,9 @@ func groupConcatFinalize(tls *libc.TLS, context uintptr) { /* sqlite3.c:118831:1 var pAccum uintptr pAccum = Xsqlite3_aggregate_context(tls, context, 0) if pAccum != 0 { - if int32((*StrAccum)(unsafe.Pointer(pAccum)).FaccError) == 18 { + if int32((*StrAccum)(unsafe.Pointer(pAccum)).FaccError) == SQLITE_TOOBIG { Xsqlite3_result_error_toobig(tls, context) - } else if int32((*StrAccum)(unsafe.Pointer(pAccum)).FaccError) == 7 { + } else if int32((*StrAccum)(unsafe.Pointer(pAccum)).FaccError) == SQLITE_NOMEM { Xsqlite3_result_error_nomem(tls, context) } else { Xsqlite3_result_text(tls, context, Xsqlite3StrAccumFinish(tls, pAccum), -1, @@ -99463,9 +98678,9 @@ func groupConcatValue(tls *libc.TLS, context uintptr) { /* sqlite3.c:118846:13: var pAccum uintptr pAccum = Xsqlite3_aggregate_context(tls, context, 0) if pAccum != 0 { - if int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 18 { + if int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == SQLITE_TOOBIG { Xsqlite3_result_error_toobig(tls, context) - } else if int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 7 { + } else if int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == SQLITE_NOMEM { Xsqlite3_result_error_nomem(tls, context) } else { var zText uintptr = Xsqlite3_str_value(tls, pAccum) @@ -99480,7 +98695,7 @@ func groupConcatValue(tls *libc.TLS, context uintptr) { /* sqlite3.c:118846:13: func Xsqlite3RegisterPerConnectionBuiltinFunctions(tls *libc.TLS, db uintptr) { /* sqlite3.c:118869:21: */ var rc int32 = Xsqlite3_overload_function(tls, db, ts+12770 /* "MATCH" */, 2) - if rc == 7 { + if rc == SQLITE_NOMEM { Xsqlite3OomFault(tls, db) } } @@ -99493,19 +98708,19 @@ func Xsqlite3RegisterLikeFunctions(tls *libc.TLS, db uintptr, caseSensitive int3 var flags int32 if caseSensitive != 0 { pInfo = uintptr(unsafe.Pointer(&likeInfoAlt)) - flags = (0x0004 | 0x0008) + flags = (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) } else { pInfo = uintptr(unsafe.Pointer(&likeInfoNorm)) - flags = 0x0004 + flags = SQLITE_FUNC_LIKE } - Xsqlite3CreateFunc(tls, db, ts+12776 /* "like" */, 2, 1, pInfo, *(*uintptr)(unsafe.Pointer(&struct { + Xsqlite3CreateFunc(tls, db, ts+12776 /* "like" */, 2, SQLITE_UTF8, pInfo, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{likeFunc})), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) - Xsqlite3CreateFunc(tls, db, ts+12776 /* "like" */, 3, 1, pInfo, *(*uintptr)(unsafe.Pointer(&struct { + Xsqlite3CreateFunc(tls, db, ts+12776 /* "like" */, 3, SQLITE_UTF8, pInfo, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{likeFunc})), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) - *(*U32)(unsafe.Pointer(Xsqlite3FindFunction(tls, db, ts+12776 /* "like" */, 2, uint8(1), uint8(0)) + 4 /* &.funcFlags */)) |= (U32(flags)) - *(*U32)(unsafe.Pointer(Xsqlite3FindFunction(tls, db, ts+12776 /* "like" */, 3, uint8(1), uint8(0)) + 4 /* &.funcFlags */)) |= (U32(flags)) + *(*U32)(unsafe.Pointer(Xsqlite3FindFunction(tls, db, ts+12776 /* "like" */, 2, SQLITE_UTF8, uint8(0)) + 4 /* &.funcFlags */)) |= (U32(flags)) + *(*U32)(unsafe.Pointer(Xsqlite3FindFunction(tls, db, ts+12776 /* "like" */, 3, SQLITE_UTF8, uint8(0)) + 4 /* &.funcFlags */)) |= (U32(flags)) } // pExpr points to an expression which implements a function. If @@ -99526,13 +98741,13 @@ func Xsqlite3RegisterLikeFunctions(tls *libc.TLS, db uintptr, caseSensitive int3 func Xsqlite3IsLikeFunction(tls *libc.TLS, db uintptr, pExpr uintptr, pIsNocase uintptr, aWc uintptr) int32 { /* sqlite3.c:118915:20: */ var pDef uintptr var nExpr int32 - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 169) || !(int32(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) != 0) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_FUNCTION) || !(int32(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) != 0) { return 0 } nExpr = (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FnExpr - pDef = Xsqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), nExpr, uint8(1), uint8(0)) - if (pDef == uintptr(0)) || (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0004)) == U32(0)) { + pDef = Xsqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), nExpr, SQLITE_UTF8, uint8(0)) + if (pDef == uintptr(0)) || (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_LIKE) == U32(0)) { return 0 } @@ -99542,27 +98757,27 @@ func Xsqlite3IsLikeFunction(tls *libc.TLS, db uintptr, pExpr uintptr, pIsNocase libc.Xmemcpy(tls, aWc, (*FuncDef)(unsafe.Pointer(pDef)).FpUserData, uint64(3)) if nExpr < 3 { - *(*int8)(unsafe.Pointer(aWc + uintptr(3))) = int8(0) + *(*int8)(unsafe.Pointer(aWc + 3)) = int8(0) } else { - var pEscape uintptr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + uintptr(2)*32)).FpExpr + var pEscape uintptr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + 2*32)).FpExpr var zEscape uintptr - if int32((*Expr)(unsafe.Pointer(pEscape)).Fop) != 115 { + if int32((*Expr)(unsafe.Pointer(pEscape)).Fop) != TK_STRING { return 0 } zEscape = *(*uintptr)(unsafe.Pointer(pEscape + 8 /* &.u */)) - if (int32(*(*int8)(unsafe.Pointer(zEscape + uintptr(0)))) == 0) || (int32(*(*int8)(unsafe.Pointer(zEscape + uintptr(1)))) != 0) { + if (int32(*(*int8)(unsafe.Pointer(zEscape))) == 0) || (int32(*(*int8)(unsafe.Pointer(zEscape + 1))) != 0) { return 0 } - if int32(*(*int8)(unsafe.Pointer(zEscape + uintptr(0)))) == int32(*(*int8)(unsafe.Pointer(aWc + uintptr(0)))) { + if int32(*(*int8)(unsafe.Pointer(zEscape))) == int32(*(*int8)(unsafe.Pointer(aWc))) { return 0 } - if int32(*(*int8)(unsafe.Pointer(zEscape + uintptr(0)))) == int32(*(*int8)(unsafe.Pointer(aWc + uintptr(1)))) { + if int32(*(*int8)(unsafe.Pointer(zEscape))) == int32(*(*int8)(unsafe.Pointer(aWc + 1))) { return 0 } - *(*int8)(unsafe.Pointer(aWc + uintptr(3))) = *(*int8)(unsafe.Pointer(zEscape + uintptr(0))) + *(*int8)(unsafe.Pointer(aWc + 3)) = *(*int8)(unsafe.Pointer(zEscape)) } - *(*int32)(unsafe.Pointer(pIsNocase)) = (libc.Bool32(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0008)) == U32(0))) + *(*int32)(unsafe.Pointer(pIsNocase)) = (libc.Bool32(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_CASE) == U32(0))) return 1 } @@ -99581,659 +98796,73 @@ func Xsqlite3RegisterBuiltinFunctions(tls *libc.TLS) { /* sqlite3.c:118964:21: * var aBuiltinFunc = [65]FuncDef{ //**** Functions only available with SQLITE_TESTCTRL_INTERNAL_FUNCTIONS **** - { - FnArg: int8(2), - FfuncFlags: (U32(((((1 | 0x00040000) | 0x4000) | 0x00400000) | 0x0800) | (0))), - FpUserData: uintptr(int64(1)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12781 /* "implies_nonnull_..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32(((((1 | 0x00040000) | 0x4000) | 0x00400000) | 0x0800) | (0))), - FpUserData: uintptr(int64(3)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12801 /* "expr_compare" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32(((((1 | 0x00040000) | 0x4000) | 0x00400000) | 0x0800) | (0))), - FpUserData: uintptr(int64(2)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12814 /* "expr_implies_exp..." */, Fu: struct{ FpHash uintptr }{}}, + {FnArg: int8(2), FfuncFlags: (U32(((((SQLITE_UTF8 | SQLITE_FUNC_INTERNAL) | SQLITE_FUNC_TEST) | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (0))), FpUserData: uintptr(INLINEFUNC_implies_nonnull_row), FxSFunc: 0, FzName: ts + 12781 /* "implies_nonnull_..." */}, + {FnArg: int8(2), FfuncFlags: (U32(((((SQLITE_UTF8 | SQLITE_FUNC_INTERNAL) | SQLITE_FUNC_TEST) | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (0))), FpUserData: uintptr(INLINEFUNC_expr_compare), FxSFunc: 0, FzName: ts + 12801 /* "expr_compare" */}, + {FnArg: int8(2), FfuncFlags: (U32(((((SQLITE_UTF8 | SQLITE_FUNC_INTERNAL) | SQLITE_FUNC_TEST) | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (0))), FpUserData: uintptr(INLINEFUNC_expr_implies_expr), FxSFunc: 0, FzName: ts + 12814 /* "expr_implies_exp..." */}, //**** Regular functions **** - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12832 /* "soundex" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | 0x000080000) | 0x00200000)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12840 /* "load_extension" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((1 | 0x000080000) | 0x00200000)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12840 /* "load_extension" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12855 /* "sqlite_compileop..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12881 /* "sqlite_compileop..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(((1 | 0x00400000) | 0x0800) | (0x0400))), - FpUserData: uintptr(int64(99)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12906 /* "unlikely" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32(((1 | 0x00400000) | 0x0800) | (0x0400))), - FpUserData: uintptr(int64(99)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12915 /* "likelihood" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(((1 | 0x00400000) | 0x0800) | (0x0400))), - FpUserData: uintptr(int64(99)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12926 /* "likely" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((((0x0800 | 1) | (0 * 0x0020)) | 0x8000) | 0x0080)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12933 /* "sqlite_offset" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(1)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12947 /* "ltrim" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(1)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12947 /* "ltrim" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(2)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12953 /* "rtrim" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(2)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12953 /* "rtrim" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(3)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12959 /* "trim" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(3)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12959 /* "trim" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x0800 | 1) | (1 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12964 /* "min" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((0x0800 | 1) | (1 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: uintptr(0), - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12964 /* "min" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (1 * 0x0020)) | 0x1000)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: uintptr(0), - FzName: ts + 12964 /* "min" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x0800 | 1) | (1 * 0x0020))), - FpUserData: uintptr(int64(1)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12968 /* "max" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((0x0800 | 1) | (1 * 0x0020))), - FpUserData: uintptr(int64(1)), - FpNext: uintptr(0), - FxSFunc: uintptr(0), - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12968 /* "max" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (1 * 0x0020)) | 0x1000)), - FpUserData: uintptr(int64(1)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: uintptr(0), - FzName: ts + 12968 /* "max" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(((0x0800 | 1) | (0 * 0x0020)) | 0x0080)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12972 /* "typeof" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(((0x0800 | 1) | (0 * 0x0020)) | 0x0040)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12979 /* "length" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12986 /* "instr" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12992 /* "printf" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12999 /* "unicode" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13007 /* "char" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13012 /* "abs" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13016 /* "round" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13016 /* "round" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13022 /* "upper" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13028 /* "lower" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13034 /* "hex" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32(((1 | 0x00400000) | 0x0800) | (0))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13038 /* "ifnull" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(1 | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13045 /* "random" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(1 | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13052 /* "randomblob" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (1 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13063 /* "nullif" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13070 /* "sqlite_version" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13085 /* "sqlite_source_id" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13102 /* "sqlite_log" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13113 /* "quote" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(1 | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13119 /* "last_insert_rowi..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(1 | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13137 /* "changes" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(1 | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13145 /* "total_changes" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(3), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13159 /* "replace" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13167 /* "zeroblob" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13176 /* "substr" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(3), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13176 /* "substr" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 13183 /* "sum" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 13187 /* "total" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 13193 /* "avg" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0x0100)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 13197 /* "count" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 13197 /* "count" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 13203 /* "group_concat" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 13203 /* "group_concat" */, Fu: struct{ FpHash uintptr }{}}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 12832 /* "soundex" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_DIRECTONLY) | SQLITE_FUNC_UNSAFE)), FxSFunc: 0, FzName: ts + 12840 /* "load_extension" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_DIRECTONLY) | SQLITE_FUNC_UNSAFE)), FxSFunc: 0, FzName: ts + 12840 /* "load_extension" */}, + {FnArg: int8(1), FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 12855 /* "sqlite_compileop..." */}, + {FnArg: int8(1), FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 12881 /* "sqlite_compileop..." */}, + {FnArg: int8(1), FfuncFlags: (U32(((SQLITE_UTF8 | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (SQLITE_FUNC_UNLIKELY))), FpUserData: uintptr(INLINEFUNC_unlikely), FxSFunc: 0, FzName: ts + 12906 /* "unlikely" */}, + {FnArg: int8(2), FfuncFlags: (U32(((SQLITE_UTF8 | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (SQLITE_FUNC_UNLIKELY))), FpUserData: uintptr(INLINEFUNC_unlikely), FxSFunc: 0, FzName: ts + 12915 /* "likelihood" */}, + {FnArg: int8(1), FfuncFlags: (U32(((SQLITE_UTF8 | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (SQLITE_FUNC_UNLIKELY))), FpUserData: uintptr(INLINEFUNC_unlikely), FxSFunc: 0, FzName: ts + 12926 /* "likely" */}, + {FnArg: int8(1), FfuncFlags: (U32((((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL)) | SQLITE_FUNC_OFFSET) | SQLITE_FUNC_TYPEOF)), FxSFunc: 0, FzName: ts + 12933 /* "sqlite_offset" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(1)), FxSFunc: 0, FzName: ts + 12947 /* "ltrim" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(1)), FxSFunc: 0, FzName: ts + 12947 /* "ltrim" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(2)), FxSFunc: 0, FzName: ts + 12953 /* "rtrim" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(2)), FxSFunc: 0, FzName: ts + 12953 /* "rtrim" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(3)), FxSFunc: 0, FzName: ts + 12959 /* "trim" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(3)), FxSFunc: 0, FzName: ts + 12959 /* "trim" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (1 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 12964 /* "min" */}, + {FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (1 * SQLITE_FUNC_NEEDCOLL))), FzName: ts + 12964 /* "min" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (1 * SQLITE_FUNC_NEEDCOLL)) | SQLITE_FUNC_MINMAX)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FzName: ts + 12964 /* "min" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (1 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(1)), FxSFunc: 0, FzName: ts + 12968 /* "max" */}, + {FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (1 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(1)), FzName: ts + 12968 /* "max" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (1 * SQLITE_FUNC_NEEDCOLL)) | SQLITE_FUNC_MINMAX)), FpUserData: uintptr(int64(1)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FzName: ts + 12968 /* "max" */}, + {FnArg: int8(1), FfuncFlags: (U32(((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL)) | SQLITE_FUNC_TYPEOF)), FxSFunc: 0, FzName: ts + 12972 /* "typeof" */}, + {FnArg: int8(1), FfuncFlags: (U32(((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL)) | SQLITE_FUNC_LENGTH)), FxSFunc: 0, FzName: ts + 12979 /* "length" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 12986 /* "instr" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 12992 /* "printf" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 12999 /* "unicode" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13007 /* "char" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13012 /* "abs" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13016 /* "round" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13016 /* "round" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13022 /* "upper" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13028 /* "lower" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13034 /* "hex" */}, + {FnArg: int8(2), FfuncFlags: (U32(((SQLITE_UTF8 | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (0))), FxSFunc: 0, FzName: ts + 13038 /* "ifnull" */}, + {FfuncFlags: (U32(SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13045 /* "random" */}, + {FnArg: int8(1), FfuncFlags: (U32(SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13052 /* "randomblob" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (1 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13063 /* "nullif" */}, + {FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 13070 /* "sqlite_version" */}, + {FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 13085 /* "sqlite_source_id" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13102 /* "sqlite_log" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13113 /* "quote" */}, + {FfuncFlags: (U32(SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13119 /* "last_insert_rowi..." */}, + {FfuncFlags: (U32(SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13137 /* "changes" */}, + {FfuncFlags: (U32(SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13145 /* "total_changes" */}, + {FnArg: int8(3), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13159 /* "replace" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13167 /* "zeroblob" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13176 /* "substr" */}, + {FnArg: int8(3), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 13176 /* "substr" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 13183 /* "sum" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 13187 /* "total" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 13193 /* "avg" */}, + {FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | SQLITE_FUNC_COUNT)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 13197 /* "count" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 13197 /* "count" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 13203 /* "group_concat" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 13203 /* "group_concat" */}, - { - FnArg: int8(2), - FfuncFlags: (U32(((0x0800 | 1) | 0x0004) | 0x0008)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13216 /* "glob" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | 0x0004)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12776 /* "like" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(3), - FfuncFlags: (U32((0x0800 | 1) | 0x0004)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12776 /* "like" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: uintptr(0), - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13221 /* "coalesce" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: uintptr(0), - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13221 /* "coalesce" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32(((1 | 0x00400000) | 0x0800) | (0))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13221 /* "coalesce" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(3), - FfuncFlags: (U32(((1 | 0x00400000) | 0x0800) | (0))), - FpUserData: uintptr(int64(5)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 13230 /* "iif" */, Fu: struct{ FpHash uintptr }{}}, -} /* sqlite3.c:118975:18 */ + {FnArg: int8(2), FfuncFlags: (U32(((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | SQLITE_FUNC_LIKE) | SQLITE_FUNC_CASE)), FpUserData: 0, FxSFunc: 0, FzName: ts + 13216 /* "glob" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | SQLITE_FUNC_LIKE)), FpUserData: 0, FxSFunc: 0, FzName: ts + 12776 /* "like" */}, + {FnArg: int8(3), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | SQLITE_FUNC_LIKE)), FpUserData: 0, FxSFunc: 0, FzName: ts + 12776 /* "like" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FzName: ts + 13221 /* "coalesce" */}, + {FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FzName: ts + 13221 /* "coalesce" */}, + {FnArg: int8(-1), FfuncFlags: (U32(((SQLITE_UTF8 | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (0))), FxSFunc: 0, FzName: ts + 13221 /* "coalesce" */}, + {FnArg: int8(3), FfuncFlags: (U32(((SQLITE_UTF8 | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (0))), FpUserData: uintptr(INLINEFUNC_iif), FxSFunc: 0, FzName: ts + 13230 /* "iif" */}} /* sqlite3.c:118975:18 */ //************* End of func.c *********************************************** //************* Begin file fkey.c ******************************************* @@ -100412,10 +99041,10 @@ func Xsqlite3FkLocateIndex(tls *libc.TLS, pParse uintptr, pParent uintptr, pFKey bp := tls.Alloc(16) defer tls.Free(16) - var pIdx uintptr = uintptr(0) // Value to return via *ppIdx - var aiCol uintptr = uintptr(0) // Value to return via *paiCol - var nCol int32 = (*FKey)(unsafe.Pointer(pFKey)).FnCol // Number of columns in parent key - var zKey uintptr = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(0)*16)).FzCol // Name of left-most parent key column + var pIdx uintptr = uintptr(0) // Value to return via *ppIdx + var aiCol uintptr = uintptr(0) // Value to return via *paiCol + var nCol int32 = (*FKey)(unsafe.Pointer(pFKey)).FnCol // Number of columns in parent key + var zKey uintptr = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */))).FzCol // Name of left-most parent key column // The caller is responsible for zeroing output parameters. @@ -100451,7 +99080,7 @@ func Xsqlite3FkLocateIndex(tls *libc.TLS, pParse uintptr, pParent uintptr, pFKey } for pIdx = (*Table)(unsafe.Pointer(pParent)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { - if ((int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) == nCol) && (int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0)) && ((*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0)) { + if ((int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) == nCol) && (int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None)) && ((*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0)) { // pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number // of columns. If each indexed column corresponds to a foreign key // column of pFKey, then this index is a winner. @@ -100460,7 +99089,7 @@ func Xsqlite3FkLocateIndex(tls *libc.TLS, pParse uintptr, pParent uintptr, pFKey // If zKey is NULL, then this foreign key is implicitly mapped to // the PRIMARY KEY of table pParent. The PRIMARY KEY index may be // identified by the test. - if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2 { + if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY { if aiCol != 0 { var i int32 for i = 0; i < nCol; i++ { @@ -100568,12 +99197,12 @@ func fkLookupParent(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr, pIdx // any are, then the constraint is considered satisfied. No need to // search for a matching row in the parent table. if nIncr < 0 { - Xsqlite3VdbeAddOp2(tls, v, 47, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), iOk) + Xsqlite3VdbeAddOp2(tls, v, OP_FkIfZero, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), iOk) } for i = 0; i < (*FKey)(unsafe.Pointer(pFKey)).FnCol; i++ { var iReg int32 = ((int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4))))) + regData) + 1) - Xsqlite3VdbeAddOp2(tls, v, 50, iReg, iOk) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, iReg, iOk) } if isIgnore == 0 { @@ -100588,21 +99217,21 @@ func fkLookupParent(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr, pIdx // is no matching parent key. Before using MustBeInt, make a copy of // the value. Otherwise, the value inserted into the child key column // will have INTEGER affinity applied to it, which may not be correct. - Xsqlite3VdbeAddOp2(tls, v, 78, - ((int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(*(*int32)(unsafe.Pointer(aiCol + uintptr(0)*4))))) + 1) + regData), regTemp) - iMustBeInt = Xsqlite3VdbeAddOp2(tls, v, 15, regTemp, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, + ((int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(*(*int32)(unsafe.Pointer(aiCol))))) + 1) + regData), regTemp) + iMustBeInt = Xsqlite3VdbeAddOp2(tls, v, OP_MustBeInt, regTemp, 0) // If the parent table is the same as the child table, and we are about // to increment the constraint-counter (i.e. this is an INSERT operation), // then check if the row being inserted matches itself. If so, do not // increment the constraint-counter. if (pTab == (*FKey)(unsafe.Pointer(pFKey)).FpFrom) && (nIncr == 1) { - Xsqlite3VdbeAddOp3(tls, v, 53, regData, iOk, regTemp) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x90)) + Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regData, iOk, regTemp) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NOTNULL) } - Xsqlite3OpenTable(tls, pParse, iCur, iDb, pTab, 96) - Xsqlite3VdbeAddOp3(tls, v, 32, iCur, 0, regTemp) + Xsqlite3OpenTable(tls, pParse, iCur, iDb, pTab, OP_OpenRead) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iCur, 0, regTemp) Xsqlite3VdbeGoto(tls, v, iOk) Xsqlite3VdbeJumpHere(tls, v, (Xsqlite3VdbeCurrentAddr(tls, v) - 2)) Xsqlite3VdbeJumpHere(tls, v, iMustBeInt) @@ -100612,10 +99241,10 @@ func fkLookupParent(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr, pIdx var regTemp int32 = Xsqlite3GetTempRange(tls, pParse, nCol) var regRec int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 96, iCur, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, iCur, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx) for i = 0; i < nCol; i++ { - Xsqlite3VdbeAddOp2(tls, v, 77, + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, ((int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4))))) + 1) + regData), (regTemp + i)) } @@ -100642,22 +99271,22 @@ func fkLookupParent(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr, pIdx // The parent key is a composite key that includes the IPK column iParent = regData } - Xsqlite3VdbeAddOp3(tls, v, 52, iChild, iJump, iParent) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeAddOp3(tls, v, OP_Ne, iChild, iJump, iParent) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_JUMPIFNULL) } Xsqlite3VdbeGoto(tls, v, iOk) } - Xsqlite3VdbeAddOp4(tls, v, 91, regTemp, nCol, regRec, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regTemp, nCol, regRec, Xsqlite3IndexAffinityStr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pIdx), nCol) - Xsqlite3VdbeAddOp4Int(tls, v, 30, iCur, iOk, regRec, 0) + Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, iCur, iOk, regRec, 0) Xsqlite3ReleaseTempReg(tls, pParse, regRec) Xsqlite3ReleaseTempRange(tls, pParse, regTemp, nCol) } } - if ((!(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && !(((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00080000)) != 0)) && + if ((!(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && !(((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_DeferFKs) != 0)) && !(int32((*Parse)(unsafe.Pointer(pParse)).FpToplevel) != 0)) && !(int32((*Parse)(unsafe.Pointer(pParse)).FisMultiWrite) != 0) { // Special case: If this is an INSERT statement that will insert exactly @@ -100665,17 +99294,17 @@ func fkLookupParent(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr, pIdx // incrementing a counter. This is necessary as the VM code is being // generated for will not open a statement transaction. - Xsqlite3HaltConstraint(tls, pParse, (19 | (int32(3) << 8)), - 2, uintptr(0), int8(-1), uint8(4)) + Xsqlite3HaltConstraint(tls, pParse, (SQLITE_CONSTRAINT | (int32(3) << 8)), + OE_Abort, uintptr(0), int8(-1), P5_ConstraintFK) } else { if (nIncr > 0) && (int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) == 0) { Xsqlite3MayAbort(tls, pParse) } - Xsqlite3VdbeAddOp2(tls, v, 149, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr) + Xsqlite3VdbeAddOp2(tls, v, OP_FkCounter, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr) } Xsqlite3VdbeResolveLabel(tls, v, iOk) - Xsqlite3VdbeAddOp1(tls, v, 116, iCur) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iCur) } // Return an Expr object that refers to a memory register corresponding @@ -100690,7 +99319,7 @@ func exprTableRegister(tls *libc.TLS, pParse uintptr, pTab uintptr, regBase int3 var zColl uintptr var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - pExpr = Xsqlite3Expr(tls, db, 173, uintptr(0)) + pExpr = Xsqlite3Expr(tls, db, TK_REGISTER, uintptr(0)) if pExpr != 0 { if (int32(iCol) >= 0) && (int32(iCol) != int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) { pCol = ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*32) @@ -100703,7 +99332,7 @@ func exprTableRegister(tls *libc.TLS, pParse uintptr, pTab uintptr, regBase int3 pExpr = Xsqlite3ExprAddCollateString(tls, pParse, pExpr, zColl) } else { (*Expr)(unsafe.Pointer(pExpr)).FiTable = regBase - (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = int8(0x44) + (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = SQLITE_AFF_INTEGER } } return pExpr @@ -100712,7 +99341,7 @@ func exprTableRegister(tls *libc.TLS, pParse uintptr, pTab uintptr, regBase int3 // Return an Expr object that refers to column iCol of table pTab which // has cursor iCur. func exprTableColumn(tls *libc.TLS, db uintptr, pTab uintptr, iCursor int32, iCol I16) uintptr { /* sqlite3.c:119604:13: */ - var pExpr uintptr = Xsqlite3Expr(tls, db, 164, uintptr(0)) + var pExpr uintptr = Xsqlite3Expr(tls, db, TK_COLUMN, uintptr(0)) if pExpr != 0 { *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = pTab (*Expr)(unsafe.Pointer(pExpr)).FiTable = iCursor @@ -100765,7 +99394,7 @@ func fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, p var v uintptr = Xsqlite3GetVdbe(tls, pParse) if nIncr < 0 { - iFkIfZero = Xsqlite3VdbeAddOp2(tls, v, 47, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), 0) + iFkIfZero = Xsqlite3VdbeAddOp2(tls, v, OP_FkIfZero, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), 0) } @@ -100792,12 +99421,12 @@ func fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, p if aiCol != 0 { iCol = int16(*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4))) } else { - iCol = int16((*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(0)*16)).FiFrom) + iCol = int16((*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */))).FiFrom) } zCol = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iCol)*32)).FzName - pRight = Xsqlite3Expr(tls, db, 59, zCol) - pEq = Xsqlite3PExpr(tls, pParse, 53, pLeft, pRight) + pRight = Xsqlite3Expr(tls, db, TK_ID, zCol) + pEq = Xsqlite3PExpr(tls, pParse, TK_EQ, pLeft, pRight) pWhere = Xsqlite3ExprAnd(tls, pParse, pWhere, pEq) } @@ -100818,10 +99447,10 @@ func fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, p var pNe uintptr // Expression (pLeft != pRight) var pLeft uintptr // Value from parent table row var pRight uintptr // Column ref to child table - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { pLeft = exprTableRegister(tls, pParse, pTab, regData, int16(-1)) - pRight = exprTableColumn(tls, db, pTab, (*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(0)*112)).FiCursor, int16(-1)) - pNe = Xsqlite3PExpr(tls, pParse, 52, pLeft, pRight) + pRight = exprTableColumn(tls, db, pTab, (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FiCursor, int16(-1)) + pNe = Xsqlite3PExpr(tls, pParse, TK_NE, pLeft, pRight) } else { var pEq uintptr var pAll uintptr = uintptr(0) @@ -100830,11 +99459,11 @@ func fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, p var iCol I16 = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2)) pLeft = exprTableRegister(tls, pParse, pTab, regData, iCol) - pRight = Xsqlite3Expr(tls, db, 59, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*32)).FzName) - pEq = Xsqlite3PExpr(tls, pParse, 45, pLeft, pRight) + pRight = Xsqlite3Expr(tls, db, TK_ID, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*32)).FzName) + pEq = Xsqlite3PExpr(tls, pParse, TK_IS, pLeft, pRight) pAll = Xsqlite3ExprAnd(tls, pParse, pAll, pEq) } - pNe = Xsqlite3PExpr(tls, pParse, 19, pAll, uintptr(0)) + pNe = Xsqlite3PExpr(tls, pParse, TK_NOT, pAll, uintptr(0)) } pWhere = Xsqlite3ExprAnd(tls, pParse, pWhere, pNe) } @@ -100850,7 +99479,7 @@ func fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, p // foreign key constraint counter. if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 { pWInfo = Xsqlite3WhereBegin(tls, pParse, pSrc, pWhere, uintptr(0), uintptr(0), uint16(0), 0) - Xsqlite3VdbeAddOp2(tls, v, 149, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr) + Xsqlite3VdbeAddOp2(tls, v, OP_FkCounter, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr) if pWInfo != 0 { Xsqlite3WhereEnd(tls, pWInfo) } @@ -100913,7 +99542,7 @@ func fkTriggerDelete(tls *libc.TLS, dbMem uintptr, p uintptr) { /* sqlite3.c:119 // DELETE, but foreign key actions are not. func Xsqlite3FkDropTable(tls *libc.TLS, pParse uintptr, pName uintptr, pTab uintptr) { /* sqlite3.c:119820:21: */ var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00004000)) != 0) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { + if (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ForeignKeys) != 0) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { var iSkip int32 = 0 var v uintptr = Xsqlite3GetVdbe(tls, pParse) @@ -100927,7 +99556,7 @@ func Xsqlite3FkDropTable(tls *libc.TLS, pParse uintptr, pName uintptr, pTab uint // when this statement is run. var p uintptr for p = (*Table)(unsafe.Pointer(pTab)).FpFKey; p != 0; p = (*FKey)(unsafe.Pointer(p)).FpNextFrom { - if ((*FKey)(unsafe.Pointer(p)).FisDeferred != 0) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00080000)) != 0) { + if ((*FKey)(unsafe.Pointer(p)).FisDeferred != 0) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DeferFKs) != 0) { break } } @@ -100935,7 +99564,7 @@ func Xsqlite3FkDropTable(tls *libc.TLS, pParse uintptr, pName uintptr, pTab uint return } iSkip = Xsqlite3VdbeMakeLabel(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 47, 1, iSkip) + Xsqlite3VdbeAddOp2(tls, v, OP_FkIfZero, 1, iSkip) } (*Parse)(unsafe.Pointer(pParse)).FdisableTriggers = U8(1) @@ -100950,12 +99579,12 @@ func Xsqlite3FkDropTable(tls *libc.TLS, pParse uintptr, pName uintptr, pTab uint // If the SQLITE_DeferFKs flag is set, then this is not required, as // the statement transaction will not be rolled back even if FK // constraints are violated. - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00080000)) == uint64(0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DeferFKs) == uint64(0) { - Xsqlite3VdbeAddOp2(tls, v, 47, 0, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_FkIfZero, 0, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) - Xsqlite3HaltConstraint(tls, pParse, (19 | (int32(3) << 8)), - 2, uintptr(0), int8(-1), uint8(4)) + Xsqlite3HaltConstraint(tls, pParse, (SQLITE_CONSTRAINT | (int32(3) << 8)), + OE_Abort, uintptr(0), int8(-1), P5_ConstraintFK) } if iSkip != 0 { @@ -101010,7 +99639,7 @@ func fkParentIsModified(tls *libc.TLS, pTab uintptr, p uintptr, aChange uintptr, if 0 == Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer(pCol)).FzName, zKey) { return 1 } - } else if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0001) != 0 { + } else if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_PRIMKEY) != 0 { return 1 } } @@ -101031,8 +99660,8 @@ func isSetNullAction(tls *libc.TLS, pParse uintptr, pFKey uintptr) int32 { /* sq }() if (*Parse)(unsafe.Pointer(pTop)).FpTriggerPrg != 0 { var p uintptr = (*TriggerPrg)(unsafe.Pointer((*Parse)(unsafe.Pointer(pTop)).FpTriggerPrg)).FpTrigger - if ((p == *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + uintptr(0)*8))) && (int32(*(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + uintptr(0)))) == 8)) || - ((p == *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + uintptr(1)*8))) && (int32(*(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + uintptr(1)))) == 8)) { + if ((p == *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */)))) && (int32(*(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */)))) == OE_SetNull)) || + ((p == *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + 1*8))) && (int32(*(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + 1))) == OE_SetNull)) { return 1 } } @@ -101070,7 +99699,7 @@ func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, // Exactly one of regOld and regNew should be non-zero. // If foreign-keys are disabled, this function is a no-op. - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00004000)) == uint64(0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ForeignKeys) == uint64(0) { return } @@ -101123,9 +99752,9 @@ func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, var iReg int32 iFromCol = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(i)*16)).FiFrom iReg = ((int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(iFromCol))) + regOld) + 1) - Xsqlite3VdbeAddOp2(tls, v, 50, iReg, iJump) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, iReg, iJump) } - Xsqlite3VdbeAddOp2(tls, v, 149, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), -1) + Xsqlite3VdbeAddOp2(tls, v, OP_FkCounter, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), -1) } continue } @@ -101133,7 +99762,7 @@ func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, if *(*uintptr)(unsafe.Pointer(bp + 8 /* aiFree */)) != 0 { aiCol = *(*uintptr)(unsafe.Pointer(bp + 8 /* aiFree */)) } else { - *(*int32)(unsafe.Pointer(bp + 16 /* iCol */)) = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(0)*16)).FiFrom + *(*int32)(unsafe.Pointer(bp + 16 /* iCol */)) = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */))).FiFrom aiCol = bp + 16 /* &iCol */ } for i = 0; i < (*FKey)(unsafe.Pointer(pFKey)).FnCol; i++ { @@ -101153,7 +99782,7 @@ func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, return int32((*Table)(unsafe.Pointer(pTo)).FiPKey) }())*32)).FzName rcauth = Xsqlite3AuthReadCol(tls, pParse, (*Table)(unsafe.Pointer(pTo)).FzName, zCol, iDb) - bIgnore = (libc.Bool32(rcauth == 2)) + bIgnore = (libc.Bool32(rcauth == SQLITE_IGNORE)) } } @@ -101195,7 +99824,7 @@ func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, continue } - if ((!(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00080000)) != 0)) && + if ((!(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DeferFKs) != 0)) && !(int32((*Parse)(unsafe.Pointer(pParse)).FpToplevel) != 0)) && !(int32((*Parse)(unsafe.Pointer(pParse)).FisMultiWrite) != 0) { // Inserting a single row into a parent table cannot cause (or fix) @@ -101243,7 +99872,7 @@ func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, // child table to fire. In these cases the fk constraint counters // might be set incorrectly if any OP_FkCounter related scans are // omitted. - if (!(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && (eAction != 10)) && (eAction != 8) { + if (!(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && (eAction != OE_Cascade)) && (eAction != OE_SetNull) { Xsqlite3MayAbort(tls, pParse) } } @@ -101261,7 +99890,7 @@ func Xsqlite3FkOldmask(tls *libc.TLS, pParse uintptr, pTab uintptr) U32 { /* sql defer tls.Free(8) var mask U32 = U32(0) - if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00004000)) != 0 { + if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_ForeignKeys) != 0 { var p uintptr var i int32 for p = (*Table)(unsafe.Pointer(pTab)).FpFKey; p != 0; p = (*FKey)(unsafe.Pointer(p)).FpNextFrom { @@ -101315,7 +99944,7 @@ func Xsqlite3FkOldmask(tls *libc.TLS, pParse uintptr, pTab uintptr) U32 { /* sql // Or, assuming some other foreign key processing is required, 1. func Xsqlite3FkRequired(tls *libc.TLS, pParse uintptr, pTab uintptr, aChange uintptr, chngRowid int32) int32 { /* sqlite3.c:120222:20: */ var eRet int32 = 0 - if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00004000)) != 0 { + if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_ForeignKeys) != 0 { if !(aChange != 0) { // A DELETE operation. Foreign key processing is required if the // table in question is either the child or parent table for any @@ -101339,7 +99968,7 @@ func Xsqlite3FkRequired(tls *libc.TLS, pParse uintptr, pTab uintptr, aChange uin // Check if any parent key columns are being modified. for p = Xsqlite3FkReferences(tls, pTab); p != 0; p = (*FKey)(unsafe.Pointer(p)).FpNextTo { if fkParentIsModified(tls, pTab, p, aChange, chngRowid) != 0 { - if int32(*(*U8)(unsafe.Pointer((p + 45 /* &.aAction */) + uintptr(1)))) != 0 { + if int32(*(*U8)(unsafe.Pointer((p + 45 /* &.aAction */) + 1))) != OE_None { return 2 } eRet = 1 @@ -101387,12 +100016,12 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, var iAction int32 = (libc.Bool32(pChanges != uintptr(0))) // 1 for UPDATE, 0 for DELETE action = int32(*(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + uintptr(iAction)))) - if (action == 7) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00080000)) != 0) { + if (action == OE_Restrict) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DeferFKs) != 0) { return uintptr(0) } pTrigger = *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + uintptr(iAction)*8)) - if (action != 0) && !(pTrigger != 0) { + if (action != OE_None) && !(pTrigger != 0) { var zFrom uintptr // Name of child table var nFrom int32 // Length in bytes of zFrom *(*uintptr)(unsafe.Pointer(bp /* pIdx */)) = uintptr(0) // Parent key index for this FK @@ -101409,12 +100038,8 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, } for i = 0; i < (*FKey)(unsafe.Pointer(pFKey)).FnCol; i++ { - *(*Token)(unsafe.Pointer(bp + 48 /* tOld */)) = Token{ - Fz: ts + 5291, /* "old" */ - Fn: uint32(3)} // Literal "old" token - *(*Token)(unsafe.Pointer(bp + 64 /* tNew */)) = Token{ - Fz: ts + 5287, /* "new" */ - Fn: uint32(3)} // Literal "new" token + *(*Token)(unsafe.Pointer(bp + 48 /* tOld */)) = Token{Fz: ts + 5291 /* "old" */, Fn: uint32(3)} // Literal "old" token + *(*Token)(unsafe.Pointer(bp + 64 /* tNew */)) = Token{Fz: ts + 5287 /* "new" */, Fn: uint32(3)} // Literal "new" token // var tFromCol Token at bp+32, 16 // Name of column in child table // var tToCol Token at bp+16, 16 @@ -101425,7 +100050,7 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, if *(*uintptr)(unsafe.Pointer(bp + 8 /* aiCol */)) != 0 { iFromCol = *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* aiCol */)) + uintptr(i)*4)) } else { - iFromCol = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(0)*16)).FiFrom + iFromCol = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */))).FiFrom } Xsqlite3TokenInit(tls, bp+16, /* &tToCol */ @@ -101441,11 +100066,11 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, // that the "OLD.zToCol" term is on the LHS of the = operator, so // that the affinity and collation sequence associated with the // parent table are used for the comparison. - pEq = Xsqlite3PExpr(tls, pParse, 53, - Xsqlite3PExpr(tls, pParse, 139, - Xsqlite3ExprAlloc(tls, db, 59, bp+48 /* &tOld */, 0), - Xsqlite3ExprAlloc(tls, db, 59, bp+16 /* &tToCol */, 0)), - Xsqlite3ExprAlloc(tls, db, 59, bp+32 /* &tFromCol */, 0)) + pEq = Xsqlite3PExpr(tls, pParse, TK_EQ, + Xsqlite3PExpr(tls, pParse, TK_DOT, + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+48 /* &tOld */, 0), + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+16 /* &tToCol */, 0)), + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+32 /* &tFromCol */, 0)) pWhere = Xsqlite3ExprAnd(tls, pParse, pWhere, pEq) // For ON UPDATE, construct the next term of the WHEN clause. @@ -101453,26 +100078,26 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, // // WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN) if pChanges != 0 { - pEq = Xsqlite3PExpr(tls, pParse, 45, - Xsqlite3PExpr(tls, pParse, 139, - Xsqlite3ExprAlloc(tls, db, 59, bp+48 /* &tOld */, 0), - Xsqlite3ExprAlloc(tls, db, 59, bp+16 /* &tToCol */, 0)), - Xsqlite3PExpr(tls, pParse, 139, - Xsqlite3ExprAlloc(tls, db, 59, bp+64 /* &tNew */, 0), - Xsqlite3ExprAlloc(tls, db, 59, bp+16 /* &tToCol */, 0))) + pEq = Xsqlite3PExpr(tls, pParse, TK_IS, + Xsqlite3PExpr(tls, pParse, TK_DOT, + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+48 /* &tOld */, 0), + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+16 /* &tToCol */, 0)), + Xsqlite3PExpr(tls, pParse, TK_DOT, + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+64 /* &tNew */, 0), + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+16 /* &tToCol */, 0))) pWhen = Xsqlite3ExprAnd(tls, pParse, pWhen, pEq) } - if (action != 7) && ((action != 10) || (pChanges != 0)) { + if (action != OE_Restrict) && ((action != OE_Cascade) || (pChanges != 0)) { var pNew uintptr - if action == 10 { - pNew = Xsqlite3PExpr(tls, pParse, 139, - Xsqlite3ExprAlloc(tls, db, 59, bp+64 /* &tNew */, 0), - Xsqlite3ExprAlloc(tls, db, 59, bp+16 /* &tToCol */, 0)) - } else if action == 9 { + if action == OE_Cascade { + pNew = Xsqlite3PExpr(tls, pParse, TK_DOT, + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+64 /* &tNew */, 0), + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+16 /* &tToCol */, 0)) + } else if action == OE_SetDflt { var pCol uintptr = ((*Table)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iFromCol)*32) var pDflt uintptr - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0060) != 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_GENERATED) != 0 { pDflt = uintptr(0) } else { @@ -101481,10 +100106,10 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, if pDflt != 0 { pNew = Xsqlite3ExprDup(tls, db, pDflt, 0) } else { - pNew = Xsqlite3ExprAlloc(tls, db, 119, uintptr(0), 0) + pNew = Xsqlite3ExprAlloc(tls, db, TK_NULL, uintptr(0), 0) } } else { - pNew = Xsqlite3ExprAlloc(tls, db, 119, uintptr(0), 0) + pNew = Xsqlite3ExprAlloc(tls, db, TK_NULL, uintptr(0), 0) } pList = Xsqlite3ExprListAppend(tls, pParse, pList, pNew) Xsqlite3ExprListSetName(tls, pParse, pList, bp+32 /* &tFromCol */, 0) @@ -101495,16 +100120,16 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, zFrom = (*Table)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpFrom)).FzName nFrom = Xsqlite3Strlen30(tls, zFrom) - if action == 7 { + if action == OE_Restrict { // var tFrom Token at bp+80, 16 var pRaise uintptr (*Token)(unsafe.Pointer(bp + 80 /* &tFrom */)).Fz = zFrom (*Token)(unsafe.Pointer(bp + 80 /* &tFrom */)).Fn = uint32(nFrom) - pRaise = Xsqlite3Expr(tls, db, 71, ts+4091 /* "FOREIGN KEY cons..." */) + pRaise = Xsqlite3Expr(tls, db, TK_RAISE, ts+4091 /* "FOREIGN KEY cons..." */) if pRaise != 0 { - (*Expr)(unsafe.Pointer(pRaise)).FaffExpr = int8(2) + (*Expr)(unsafe.Pointer(pRaise)).FaffExpr = OE_Abort } pSelect = Xsqlite3SelectNew(tls, pParse, Xsqlite3ExprListAppend(tls, pParse, uintptr(0), pRaise), @@ -101521,16 +100146,16 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, pTrigger = Xsqlite3DbMallocZero(tls, db, (uint64(((uint64(unsafe.Sizeof(Trigger{})) + uint64(unsafe.Sizeof(TriggerStep{}))) + uint64(nFrom)) + uint64(1)))) if pTrigger != 0 { - pStep = libc.AssignPtrUintptr(pTrigger+56 /* &.step_list */, (pTrigger + uintptr(1)*72)) - (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget = (pStep + uintptr(1)*96) + pStep = libc.AssignPtrUintptr(pTrigger+56 /* &.step_list */, (pTrigger + 1*72)) + (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget = (pStep + 1*96) libc.Xmemcpy(tls, (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget, zFrom, uint64(nFrom)) - (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, 0x0001) - (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList = Xsqlite3ExprListDup(tls, db, pList, 0x0001) - (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, 0x0001) + (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, EXPRDUP_REDUCE) + (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList = Xsqlite3ExprListDup(tls, db, pList, EXPRDUP_REDUCE) + (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, EXPRDUP_REDUCE) if pWhen != 0 { - pWhen = Xsqlite3PExpr(tls, pParse, 19, pWhen, uintptr(0)) - (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = Xsqlite3ExprDup(tls, db, pWhen, 0x0001) + pWhen = Xsqlite3PExpr(tls, pParse, TK_NOT, pWhen, uintptr(0)) + (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = Xsqlite3ExprDup(tls, db, pWhen, EXPRDUP_REDUCE) } } @@ -101553,19 +100178,18 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, } switch action { - case 7: - (*TriggerStep)(unsafe.Pointer(pStep)).Fop = U8(136) + case OE_Restrict: + (*TriggerStep)(unsafe.Pointer(pStep)).Fop = TK_SELECT break fallthrough - case 10: + case OE_Cascade: if !(pChanges != 0) { - (*TriggerStep)(unsafe.Pointer(pStep)).Fop = U8(126) + (*TriggerStep)(unsafe.Pointer(pStep)).Fop = TK_DELETE break } - /* no break */ fallthrough default: - (*TriggerStep)(unsafe.Pointer(pStep)).Fop = U8(127) + (*TriggerStep)(unsafe.Pointer(pStep)).Fop = TK_UPDATE } (*TriggerStep)(unsafe.Pointer(pStep)).FpTrig = pTrigger (*Trigger)(unsafe.Pointer(pTrigger)).FpSchema = (*Table)(unsafe.Pointer(pTab)).FpSchema @@ -101573,9 +100197,9 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + uintptr(iAction)*8)) = pTrigger (*Trigger)(unsafe.Pointer(pTrigger)).Fop = func() uint8 { if pChanges != 0 { - return uint8(127) + return TK_UPDATE } - return uint8(126) + return TK_DELETE }() } @@ -101589,13 +100213,13 @@ func Xsqlite3FkActions(tls *libc.TLS, pParse uintptr, pTab uintptr, pChanges uin // refer to table pTab. If there is an action associated with the FK // for this operation (either update or delete), invoke the associated // trigger sub-program. - if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00004000)) != 0 { + if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_ForeignKeys) != 0 { var pFKey uintptr // Iterator variable for pFKey = Xsqlite3FkReferences(tls, pTab); pFKey != 0; pFKey = (*FKey)(unsafe.Pointer(pFKey)).FpNextTo { if (aChange == uintptr(0)) || (fkParentIsModified(tls, pTab, pFKey, aChange, bChngRowid) != 0) { var pAct uintptr = fkActionTrigger(tls, pParse, pTab, pFKey, pChanges) if pAct != 0 { - Xsqlite3CodeRowTriggerDirect(tls, pParse, pAct, pTab, regOld, 2, 0) + Xsqlite3CodeRowTriggerDirect(tls, pParse, pAct, pTab, regOld, OE_Abort, 0) } } } @@ -101634,8 +100258,8 @@ func Xsqlite3FkDelete(tls *libc.TLS, db uintptr, pTab uintptr) { /* sqlite3.c:12 // classified as either immediate or deferred. // Delete any triggers created to implement actions for this FK. - fkTriggerDelete(tls, db, *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + uintptr(0)*8))) - fkTriggerDelete(tls, db, *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + uintptr(1)*8))) + fkTriggerDelete(tls, db, *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */)))) + fkTriggerDelete(tls, db, *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + 1*8))) pNext = (*FKey)(unsafe.Pointer(pFKey)).FpNextFrom Xsqlite3DbFree(tls, db, pFKey) @@ -101672,12 +100296,12 @@ func Xsqlite3OpenTable(tls *libc.TLS, pParse uintptr, iCur int32, iDb int32, pTa Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, func() uint8 { - if opcode == 97 { + if opcode == OP_OpenWrite { return uint8(1) } return uint8(0) }(), (*Table)(unsafe.Pointer(pTab)).FzName) - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { Xsqlite3VdbeAddOp4Int(tls, v, opcode, iCur, int32((*Table)(unsafe.Pointer(pTab)).Ftnum), iDb, int32((*Table)(unsafe.Pointer(pTab)).FnNVCol)) } else { @@ -101729,16 +100353,16 @@ func Xsqlite3IndexAffinityStr(tls *libc.TLS, db uintptr, pIdx uintptr) uintptr { if int32(x) >= 0 { aff = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(x)*32)).Faffinity } else if int32(x) == (-1) { - aff = int8(0x44) + aff = SQLITE_AFF_INTEGER } else { aff = Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FaColExpr+8 /* &.a */)+uintptr(n)*32)).FpExpr) } - if int32(aff) < 0x41 { - aff = int8(0x41) + if int32(aff) < SQLITE_AFF_BLOB { + aff = SQLITE_AFF_BLOB } - if int32(aff) > 0x43 { - aff = int8(0x43) + if int32(aff) > SQLITE_AFF_NUMERIC { + aff = SQLITE_AFF_NUMERIC } *(*int8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FzColAff + uintptr(n))) = aff } @@ -101780,11 +100404,11 @@ func Xsqlite3TableAffinity(tls *libc.TLS, v uintptr, pTab uintptr, iReg int32) { for i = libc.AssignInt32(&j, 0); i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) == 0 { + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) == 0 { *(*int8)(unsafe.Pointer(zColAff + uintptr(libc.PostIncInt32(&j, 1)))) = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32)).Faffinity } } - for ok := true; ok; ok = ((j >= 0) && (int32(*(*int8)(unsafe.Pointer(zColAff + uintptr(j)))) <= 0x41)) { + for ok := true; ok; ok = ((j >= 0) && (int32(*(*int8)(unsafe.Pointer(zColAff + uintptr(j)))) <= SQLITE_AFF_BLOB)) { *(*int8)(unsafe.Pointer(zColAff + uintptr(libc.PostDecInt32(&j, 1)))) = int8(0) } (*Table)(unsafe.Pointer(pTab)).FzColAff = zColAff @@ -101793,7 +100417,7 @@ func Xsqlite3TableAffinity(tls *libc.TLS, v uintptr, pTab uintptr, iReg int32) { i = (int32(libc.Xstrlen(tls, zColAff) & uint64(0x3fffffff))) if i != 0 { if iReg != 0 { - Xsqlite3VdbeAddOp4(tls, v, 90, iReg, i, 0, zColAff, i) + Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, iReg, i, 0, zColAff, i) } else { Xsqlite3VdbeChangeP4(tls, v, -1, zColAff, i) } @@ -101818,7 +100442,7 @@ func readsTable(tls *libc.TLS, p uintptr, iDb int32, pTab uintptr) int32 { /* sq for i = 1; i < iEnd; i++ { var pOp uintptr = Xsqlite3VdbeGetOp(tls, v, i) - if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 96) && ((*VdbeOp)(unsafe.Pointer(pOp)).Fp3 == iDb) { + if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_OpenRead) && ((*VdbeOp)(unsafe.Pointer(pOp)).Fp3 == iDb) { var pIndex uintptr var tnum Pgno = Pgno((*VdbeOp)(unsafe.Pointer(pOp)).Fp2) if tnum == (*Table)(unsafe.Pointer(pTab)).Ftnum { @@ -101830,7 +100454,7 @@ func readsTable(tls *libc.TLS, p uintptr, iDb int32, pTab uintptr) int32 { /* sq } } } - if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 165) && (*(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) == pVTab) { + if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_VOpen) && (*(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) == pVTab) { return 1 } @@ -101841,11 +100465,11 @@ func readsTable(tls *libc.TLS, p uintptr, iDb int32, pTab uintptr) int32 { /* sq // This walker callback will compute the union of colFlags flags for all // referenced columns in a CHECK constraint or generated column expression. func exprColumnFlagUnion(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:120760:12: */ - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) && (int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) >= 0) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) && (int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) >= 0) { *(*U16)(unsafe.Pointer(pWalker + 36 /* &.eCode */)) |= U16((int32((*Column)(unsafe.Pointer((*Table1)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)))).FaCol + uintptr((*Expr)(unsafe.Pointer(pExpr)).FiColumn)*32)).FcolFlags))) } - return 0 + return WRC_Continue } // All regular columns for table pTab have been puts into registers @@ -101867,8 +100491,8 @@ func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore in // Before computing generated columns, first go through and make sure // that appropriate affinity has been applied to the regular columns Xsqlite3TableAffinity(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, pTab, iRegStore) - if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0040)) != U32(0)) && - (int32((*VdbeOp)(unsafe.Pointer((libc.AssignUintptr(&pOp, Xsqlite3VdbeGetOp(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, -1))))).Fopcode) == 90) { + if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasStored) != U32(0)) && + (int32((*VdbeOp)(unsafe.Pointer((libc.AssignUintptr(&pOp, Xsqlite3VdbeGetOp(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, -1))))).Fopcode) == OP_Affinity) { // Change the OP_Affinity argument to '@' (NONE) for all stored // columns. '@' is the no-op affinity and those columns have not // yet been computed. @@ -101877,11 +100501,11 @@ func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore in var zP4 uintptr = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) for ii = libc.AssignInt32(&jj, 0); *(*int8)(unsafe.Pointer(zP4 + uintptr(jj))) != 0; ii++ { - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(ii)*32)).FcolFlags) & 0x0020) != 0 { + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(ii)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0 { continue } - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(ii)*32)).FcolFlags) & 0x0040) != 0 { - *(*int8)(unsafe.Pointer(zP4 + uintptr(jj))) = int8(0x40) + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(ii)*32)).FcolFlags) & COLFLAG_STORED) != 0 { + *(*int8)(unsafe.Pointer(zP4 + uintptr(jj))) = SQLITE_AFF_NONE } jj++ } @@ -101891,9 +100515,9 @@ func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore in // this is a two-pass algorithm. On the first pass, mark all generated // columns as "not available". for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0060) != 0 { + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_GENERATED) != 0 { - *(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32 + 28 /* &.colFlags */)) |= U16((0x0080)) + *(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32 + 28 /* &.colFlags */)) |= U16((COLFLAG_NOTAVAIL)) } } @@ -101914,13 +100538,13 @@ func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore in pRedo = uintptr(0) for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { var pCol uintptr = ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32) - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0080) != 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_NOTAVAIL) != 0 { var x int32 - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((0x0100)) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((COLFLAG_BUSY)) (*Walker)(unsafe.Pointer(bp + 8 /* &w */)).FeCode = U16(0) Xsqlite3WalkExpr(tls, bp+8 /* &w */, (*Column)(unsafe.Pointer(pCol)).FpDflt) - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0100))) - if (int32((*Walker)(unsafe.Pointer(bp+8 /* &w */)).FeCode) & 0x0080) != 0 { + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(COLFLAG_BUSY))) + if (int32((*Walker)(unsafe.Pointer(bp+8 /* &w */)).FeCode) & COLFLAG_NOTAVAIL) != 0 { pRedo = pCol continue } @@ -101928,7 +100552,7 @@ func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore in x = (int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(i))) + iRegStore) Xsqlite3ExprCodeGeneratedColumn(tls, pParse, pCol, x) - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0080))) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(COLFLAG_NOTAVAIL))) } } } @@ -101962,8 +100586,8 @@ func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore in func autoIncBegin(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr) int32 { /* sqlite3.c:120894:12: */ var memId int32 = 0 // Register holding maximum rowid - if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0008)) != U32(0)) && - (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags & U32(0x0004)) == U32(0)) { + if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Autoincrement) != U32(0)) && + (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags & DBFLAG_Vacuum) == U32(0)) { var pToplevel uintptr = func() uintptr { if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 { return (*Parse)(unsafe.Pointer(pParse)).FpToplevel @@ -101977,11 +100601,11 @@ func autoIncBegin(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr) int32 // rowid table with exactly two columns. // Ticket d8dc2b3a58cd5dc2918a1d4acb 2018-05-23 if (((pSeqTab == uintptr(0)) || - !(((*Table)(unsafe.Pointer((pSeqTab))).FtabFlags & U32(0x0080)) == U32(0))) || + !(((*Table)(unsafe.Pointer((pSeqTab))).FtabFlags & TF_WithoutRowid) == U32(0))) || ((*Table)(unsafe.Pointer(pSeqTab)).FnModuleArg != 0)) || (int32((*Table)(unsafe.Pointer(pSeqTab)).FnCol) != 2) { (*Parse)(unsafe.Pointer(pParse)).FnErr++ - (*Parse)(unsafe.Pointer(pParse)).Frc = (11 | (int32(2) << 8)) + (*Parse)(unsafe.Pointer(pParse)).Frc = (SQLITE_CORRUPT | (int32(2) << 8)) return 0 } @@ -102025,24 +100649,24 @@ func Xsqlite3AutoincrementBegin(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:12 pDb = ((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*AutoincInfo)(unsafe.Pointer(p)).FiDb)*32) memId = (*AutoincInfo)(unsafe.Pointer(p)).FregCtr - Xsqlite3OpenTable(tls, pParse, 0, (*AutoincInfo)(unsafe.Pointer(p)).FiDb, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab, 96) + Xsqlite3OpenTable(tls, pParse, 0, (*AutoincInfo)(unsafe.Pointer(p)).FiDb, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab, OP_OpenRead) Xsqlite3VdbeLoadString(tls, v, (memId - 1), (*Table)(unsafe.Pointer((*AutoincInfo)(unsafe.Pointer(p)).FpTab)).FzName) aOp = Xsqlite3VdbeAddOpList(tls, v, (int32(uint64(unsafe.Sizeof(autoInc)) / uint64(unsafe.Sizeof(VdbeOpList{})))), uintptr(unsafe.Pointer(&autoInc)), iLn1) if aOp == uintptr(0) { break } - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*24)).Fp2 = memId - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*24)).Fp3 = (memId + 2) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(2)*24)).Fp3 = memId - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*24)).Fp1 = (memId - 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*24)).Fp3 = memId - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*24)).Fp5 = U16(0x10) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(4)*24)).Fp2 = (memId + 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(5)*24)).Fp3 = memId - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(6)*24)).Fp1 = memId - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(7)*24)).Fp2 = (memId + 2) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(7)*24)).Fp1 = memId - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(10)*24)).Fp2 = memId + (*VdbeOp)(unsafe.Pointer(aOp)).Fp2 = memId + (*VdbeOp)(unsafe.Pointer(aOp)).Fp3 = (memId + 2) + (*VdbeOp)(unsafe.Pointer(aOp + 2*24)).Fp3 = memId + (*VdbeOp)(unsafe.Pointer(aOp + 3*24)).Fp1 = (memId - 1) + (*VdbeOp)(unsafe.Pointer(aOp + 3*24)).Fp3 = memId + (*VdbeOp)(unsafe.Pointer(aOp + 3*24)).Fp5 = SQLITE_JUMPIFNULL + (*VdbeOp)(unsafe.Pointer(aOp + 4*24)).Fp2 = (memId + 1) + (*VdbeOp)(unsafe.Pointer(aOp + 5*24)).Fp3 = memId + (*VdbeOp)(unsafe.Pointer(aOp + 6*24)).Fp1 = memId + (*VdbeOp)(unsafe.Pointer(aOp + 7*24)).Fp2 = (memId + 2) + (*VdbeOp)(unsafe.Pointer(aOp + 7*24)).Fp1 = memId + (*VdbeOp)(unsafe.Pointer(aOp + 10*24)).Fp2 = memId if (*Parse)(unsafe.Pointer(pParse)).FnTab == 0 { (*Parse)(unsafe.Pointer(pParse)).FnTab = 1 } @@ -102051,66 +100675,18 @@ func Xsqlite3AutoincrementBegin(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:12 var iLn1 int32 = 0 /* sqlite3.c:120957:22 */ var autoInc = [12]VdbeOpList{ - /* 0 */ { - Fopcode: U8(72), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 1 */ { - Fopcode: U8(37), - Fp1: int8(0), - Fp2: int8(10), - Fp3: int8(0)}, - /* 2 */ { - Fopcode: U8(89), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 3 */ { - Fopcode: U8(52), - Fp1: int8(0), - Fp2: int8(9), - Fp3: int8(0)}, - /* 4 */ { - Fopcode: U8(127), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 5 */ { - Fopcode: U8(89), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(0)}, - /* 6 */ { - Fopcode: U8(82), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 7 */ { - Fopcode: U8(77), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 8 */ { - Fopcode: U8(11), - Fp1: int8(0), - Fp2: int8(11), - Fp3: int8(0)}, - /* 9 */ { - Fopcode: U8(5), - Fp1: int8(0), - Fp2: int8(2), - Fp3: int8(0)}, - /* 10 */ { - Fopcode: U8(69), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 11 */ { - Fopcode: U8(116), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, + /* 0 */ {Fopcode: OP_Null}, + /* 1 */ {Fopcode: OP_Rewind, Fp2: int8(10)}, + /* 2 */ {Fopcode: OP_Column}, + /* 3 */ {Fopcode: OP_Ne, Fp2: int8(9)}, + /* 4 */ {Fopcode: OP_Rowid}, + /* 5 */ {Fopcode: OP_Column, Fp2: int8(1)}, + /* 6 */ {Fopcode: OP_AddImm}, + /* 7 */ {Fopcode: OP_Copy}, + /* 8 */ {Fopcode: OP_Goto, Fp2: int8(11)}, + /* 9 */ {Fopcode: OP_Next, Fp2: int8(2)}, + /* 10 */ {Fopcode: OP_Integer}, + /* 11 */ {Fopcode: OP_Close}, } /* sqlite3.c:120958:29 */ // Update the maximum rowid for an autoincrement calculation. @@ -102121,7 +100697,7 @@ var autoInc = [12]VdbeOpList{ // memory cell is updated. func autoIncStep(tls *libc.TLS, pParse uintptr, memId int32, regRowid int32) { /* sqlite3.c:121004:13: */ if memId > 0 { - Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, 151, memId, regRowid) + Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_MemMax, memId, regRowid) } } @@ -102143,51 +100719,31 @@ func autoIncrementEnd(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:121017:29: * iRec = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 55, (memId + 2), (Xsqlite3VdbeCurrentAddr(tls, v) + 7), memId) + Xsqlite3VdbeAddOp3(tls, v, OP_Le, (memId + 2), (Xsqlite3VdbeCurrentAddr(tls, v) + 7), memId) - Xsqlite3OpenTable(tls, pParse, 0, (*AutoincInfo)(unsafe.Pointer(p)).FiDb, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab, 97) + Xsqlite3OpenTable(tls, pParse, 0, (*AutoincInfo)(unsafe.Pointer(p)).FiDb, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab, OP_OpenWrite) aOp = Xsqlite3VdbeAddOpList(tls, v, (int32(uint64(unsafe.Sizeof(autoIncEnd)) / uint64(unsafe.Sizeof(VdbeOpList{})))), uintptr(unsafe.Pointer(&autoIncEnd)), iLn2) if aOp == uintptr(0) { break } - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*24)).Fp1 = (memId + 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(1)*24)).Fp2 = (memId + 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(2)*24)).Fp1 = (memId - 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(2)*24)).Fp3 = iRec - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*24)).Fp2 = iRec - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*24)).Fp3 = (memId + 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*24)).Fp5 = U16(0x08) + (*VdbeOp)(unsafe.Pointer(aOp)).Fp1 = (memId + 1) + (*VdbeOp)(unsafe.Pointer(aOp + 1*24)).Fp2 = (memId + 1) + (*VdbeOp)(unsafe.Pointer(aOp + 2*24)).Fp1 = (memId - 1) + (*VdbeOp)(unsafe.Pointer(aOp + 2*24)).Fp3 = iRec + (*VdbeOp)(unsafe.Pointer(aOp + 3*24)).Fp2 = iRec + (*VdbeOp)(unsafe.Pointer(aOp + 3*24)).Fp3 = (memId + 1) + (*VdbeOp)(unsafe.Pointer(aOp + 3*24)).Fp5 = OPFLAG_APPEND Xsqlite3ReleaseTempReg(tls, pParse, iRec) } } var iLn2 int32 = 0 /* sqlite3.c:121024:22 */ var autoIncEnd = [5]VdbeOpList{ - /* 0 */ { - Fopcode: U8(51), - Fp1: int8(0), - Fp2: int8(2), - Fp3: int8(0)}, - /* 1 */ { - Fopcode: U8(120), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 2 */ { - Fopcode: U8(91), - Fp1: int8(0), - Fp2: int8(2), - Fp3: int8(0)}, - /* 3 */ { - Fopcode: U8(121), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 4 */ { - Fopcode: U8(116), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, + /* 0 */ {Fopcode: OP_NotNull, Fp2: int8(2)}, + /* 1 */ {Fopcode: OP_NewRowid}, + /* 2 */ {Fopcode: OP_MakeRecord, Fp2: int8(2)}, + /* 3 */ {Fopcode: OP_Insert}, + /* 4 */ {Fopcode: OP_Close}, } /* sqlite3.c:121025:29 */ func Xsqlite3AutoincrementEnd(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:121054:21: */ @@ -102394,7 +100950,7 @@ __1: // If the Select object is really just a simple VALUES() list with a // single row (the common case) then keep that one row of values // and discard the other (unused) parts of the pSelect object - if !(((pSelect != 0) && (((*Select)(unsafe.Pointer(pSelect)).FselFlags & U32(0x0000200)) != U32(0))) && ((*Select)(unsafe.Pointer(pSelect)).FpPrior == uintptr(0))) { + if !(((pSelect != 0) && (((*Select)(unsafe.Pointer(pSelect)).FselFlags & SF_Values) != U32(0))) && ((*Select)(unsafe.Pointer(pSelect)).FpPrior == uintptr(0))) { goto __2 } pList = (*Select)(unsafe.Pointer(pSelect)).FpEList @@ -102415,18 +100971,18 @@ __3: ; iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) - if !(Xsqlite3AuthCheck(tls, pParse, 18, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_INSERT, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) != 0) { goto __4 } goto insert_cleanup __4: ; - withoutRowid = libc.BoolUint8(!(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) + withoutRowid = libc.BoolUint8(!(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) // Figure out if we have any triggers and if the table being // inserted into is a view - pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, 125, uintptr(0), bp+88 /* &tmask */) + pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, TK_INSERT, uintptr(0), bp+88 /* &tmask */) isView = (libc.Bool32((*Table)(unsafe.Pointer(pTab)).FpSelect != uintptr(0))) // If pTab is really a view, make sure it has been initialized. @@ -102513,7 +101069,7 @@ __10: // order. This enables an optimization that avoids shuffling the // columns into storage order. False negatives are harmless, // but false positives will cause database corruption. - bIdListInOrder = (U8(libc.Bool32(((*Table)(unsafe.Pointer(pTab)).FtabFlags & (U32(0x0400 | 0x0040))) == U32(0)))) + bIdListInOrder = (U8(libc.Bool32(((*Table)(unsafe.Pointer(pTab)).FtabFlags & (U32(TF_OOOHidden | TF_HasStored))) == U32(0)))) if !(pColumn != 0) { goto __11 } @@ -102556,7 +101112,7 @@ __22: ipkColumn = i __23: ; - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & (0x0040 | 0x0020)) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & (COLFLAG_STORED | COLFLAG_VIRTUAL)) != 0) { goto __24 } Xsqlite3ErrorMsg(tls, pParse, @@ -102613,8 +101169,8 @@ __11: regYield = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) addrTop = (Xsqlite3VdbeCurrentAddr(tls, v) + 1) - Xsqlite3VdbeAddOp3(tls, v, 13, regYield, 0, addrTop) - Xsqlite3SelectDestInit(tls, bp+96 /* &dest */, 13, regYield) + Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regYield, 0, addrTop) + Xsqlite3SelectDestInit(tls, bp+96 /* &dest */, SRT_Coroutine, regYield) (*SelectDest)(unsafe.Pointer(bp + 96 /* &dest */)).FiSdst = func() int32 { if bIdListInOrder != 0 { return regData @@ -102657,11 +101213,11 @@ __31: srcTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) regRec = Xsqlite3GetTempReg(tls, pParse) regTempRowid = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 100, srcTab, nColumn) - addrL = Xsqlite3VdbeAddOp1(tls, v, 14, (*SelectDest)(unsafe.Pointer(bp+96 /* &dest */)).FiSDParm) - Xsqlite3VdbeAddOp3(tls, v, 91, regFromSelect, nColumn, regRec) - Xsqlite3VdbeAddOp2(tls, v, 120, srcTab, regTempRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, srcTab, regRec, regTempRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, srcTab, nColumn) + addrL = Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(bp+96 /* &dest */)).FiSDParm) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regFromSelect, nColumn, regRec) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, srcTab, regTempRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, srcTab, regRec, regTempRowid) Xsqlite3VdbeGoto(tls, v, addrL) Xsqlite3VdbeJumpHere(tls, v, addrL) Xsqlite3ReleaseTempReg(tls, pParse, regRec) @@ -102699,7 +101255,7 @@ __29: goto __36 } ipkColumn = int32((*Table)(unsafe.Pointer(pTab)).FiPKey) - if !((ipkColumn >= 0) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != U32(0))) { + if !((ipkColumn >= 0) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != U32(0))) { goto __37 } @@ -102708,7 +101264,7 @@ __38: if !(i >= 0) { goto __40 } - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0060) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_GENERATED) != 0) { goto __41 } @@ -102734,7 +101290,7 @@ __42: if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) { goto __44 } - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0062) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_NOINSERT) != 0) { goto __45 } nHidden++ @@ -102771,7 +101327,7 @@ __47: goto __48 } regRowCount = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regRowCount) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regRowCount) __48: ; @@ -102779,7 +101335,7 @@ __48: if !(!(isView != 0)) { goto __49 } - nIdx = Xsqlite3OpenTableAndIndices(tls, pParse, pTab, 97, uint8(0), -1, uintptr(0), + nIdx = Xsqlite3OpenTableAndIndices(tls, pParse, pTab, OP_OpenWrite, uint8(0), -1, uintptr(0), bp+192 /* &iDataCur */, bp+196 /* &iIdxCur */) aRegIdx = Xsqlite3DbMallocRawNN(tls, db, (uint64(uint64(unsafe.Sizeof(int32(0))) * (uint64(nIdx + 2))))) if !(aRegIdx == uintptr(0)) { @@ -102832,7 +101388,7 @@ __56: goto insert_cleanup __57: ; - (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FiCursor = *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)) + (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FiCursor = *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)) (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc = pTabList (*Upsert)(unsafe.Pointer(pUpsert)).FregData = regData (*Upsert)(unsafe.Pointer(pUpsert)).FiDataCur = *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)) @@ -102858,7 +101414,7 @@ __54: // transfer values form intermediate table into
    // end loop // D: ... - addrInsTop = Xsqlite3VdbeAddOp1(tls, v, 37, srcTab) + addrInsTop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, srcTab) addrCont = Xsqlite3VdbeCurrentAddr(tls, v) goto __60 __59: @@ -102873,7 +101429,7 @@ __59: // goto C // D: ... - addrInsTop = libc.AssignInt32(&addrCont, Xsqlite3VdbeAddOp1(tls, v, 14, (*SelectDest)(unsafe.Pointer(bp+96 /* &dest */)).FiSDParm)) + addrInsTop = libc.AssignInt32(&addrCont, Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(bp+96 /* &dest */)).FiSDParm)) if !(ipkColumn >= 0) { goto __62 @@ -102881,7 +101437,7 @@ __59: // tag-20191021-001: If the INTEGER PRIMARY KEY is being generated by the // SELECT, go ahead and copy the value into the rowid slot now, so that // the value does not get overwritten by a NULL at tag-20191021-002. - Xsqlite3VdbeAddOp2(tls, v, 77, (regFromSelect + ipkColumn), regRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, (regFromSelect + ipkColumn), regRowid) __62: ; __61: @@ -102910,15 +101466,15 @@ __63: // using the rowid. So put a NULL in the IPK slot of the record to avoid // using excess space. The file format definition requires this extra // NULL - we cannot optimize further by skipping the column completely - Xsqlite3VdbeAddOp1(tls, v, 73, iRegStore) + Xsqlite3VdbeAddOp1(tls, v, OP_SoftNull, iRegStore) goto __64 __66: ; - if !(((libc.AssignUint32(&colFlags, U32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags))) & U32(0x0062)) != U32(0)) { + if !(((libc.AssignUint32(&colFlags, U32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags))) & COLFLAG_NOINSERT) != U32(0)) { goto __67 } nHidden++ - if !((colFlags & U32(0x0020)) != U32(0)) { + if !((colFlags & COLFLAG_VIRTUAL) != U32(0)) { goto __68 } // Virtual columns do not participate in OP_MakeRecord. So back up @@ -102928,17 +101484,17 @@ __66: goto __64 goto __69 __68: - if !((colFlags & U32(0x0040)) != U32(0)) { + if !((colFlags & COLFLAG_STORED) != U32(0)) { goto __70 } // Stored columns are computed later. But if there are BEFORE // triggers, the slots used for stored columns will be OP_Copy-ed // to a second block of registers, so the register needs to be // initialized to NULL to avoid an uninitialized register read - if !((*(*int32)(unsafe.Pointer(bp + 88 /* tmask */)) & 1) != 0) { + if !((*(*int32)(unsafe.Pointer(bp + 88 /* tmask */)) & TRIGGER_BEFORE) != 0) { goto __72 } - Xsqlite3VdbeAddOp1(tls, v, 73, iRegStore) + Xsqlite3VdbeAddOp1(tls, v, OP_SoftNull, iRegStore) __72: ; goto __64 @@ -103003,7 +101559,7 @@ __75: if !(useTempTable != 0) { goto __82 } - Xsqlite3VdbeAddOp3(tls, v, 89, srcTab, k, iRegStore) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, srcTab, k, iRegStore) goto __83 __82: if !(pSelect != 0) { @@ -103012,7 +101568,7 @@ __82: if !(regFromSelect != regData) { goto __86 } - Xsqlite3VdbeAddOp2(tls, v, 78, (regFromSelect + k), iRegStore) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, (regFromSelect + k), iRegStore) __86: ; goto __85 @@ -103033,7 +101589,7 @@ __65: // Run the BEFORE and INSTEAD OF triggers, if there are any endOfLoop = Xsqlite3VdbeMakeLabel(tls, pParse) - if !((*(*int32)(unsafe.Pointer(bp + 88 /* tmask */)) & 1) != 0) { + if !((*(*int32)(unsafe.Pointer(bp + 88 /* tmask */)) & TRIGGER_BEFORE) != 0) { goto __87 } regCols = Xsqlite3GetTempRange(tls, pParse, (int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 1)) @@ -103046,24 +101602,24 @@ __65: if !(ipkColumn < 0) { goto __88 } - Xsqlite3VdbeAddOp2(tls, v, 69, -1, regCols) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, -1, regCols) goto __89 __88: ; if !(useTempTable != 0) { goto __90 } - Xsqlite3VdbeAddOp3(tls, v, 89, srcTab, ipkColumn, regCols) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, srcTab, ipkColumn, regCols) goto __91 __90: ; // Otherwise useTempTable is true Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(ipkColumn)*32)).FpExpr, regCols) __91: ; - addr1 = Xsqlite3VdbeAddOp1(tls, v, 51, regCols) - Xsqlite3VdbeAddOp2(tls, v, 69, -1, regCols) + addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, regCols) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, -1, regCols) Xsqlite3VdbeJumpHere(tls, v, addr1) - Xsqlite3VdbeAddOp1(tls, v, 15, regCols) + Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, regCols) __89: ; @@ -103072,13 +101628,13 @@ __89: // Copy the new data already generated. - Xsqlite3VdbeAddOp3(tls, v, 77, (regRowid + 1), (regCols + 1), (int32((*Table)(unsafe.Pointer(pTab)).FnNVCol) - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, (regRowid + 1), (regCols + 1), (int32((*Table)(unsafe.Pointer(pTab)).FnNVCol) - 1)) // Compute the new value for generated columns after all other // columns have already been computed. This must be done after // computing the ROWID in case one of the generated columns // refers to the ROWID. - if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != 0) { + if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != 0) { goto __92 } @@ -103098,7 +101654,7 @@ __93: ; // Fire BEFORE or INSTEAD OF triggers - Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, 125, uintptr(0), 1, + Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, TK_INSERT, uintptr(0), TRIGGER_BEFORE, pTab, ((regCols - int32((*Table)(unsafe.Pointer(pTab)).FnCol)) - 1), onError, endOfLoop) Xsqlite3ReleaseTempRange(tls, pParse, regCols, (int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 1)) @@ -103112,7 +101668,7 @@ __87: goto __95 } // The row that the VUpdate opcode will delete: none - Xsqlite3VdbeAddOp2(tls, v, 72, 0, regIns) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regIns) __95: ; if !(ipkColumn >= 0) { @@ -103122,7 +101678,7 @@ __95: if !(useTempTable != 0) { goto __98 } - Xsqlite3VdbeAddOp3(tls, v, 89, srcTab, ipkColumn, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, srcTab, ipkColumn, regRowid) goto __99 __98: if !(pSelect != 0) { @@ -103132,10 +101688,10 @@ __98: goto __101 __100: pIpk = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(ipkColumn)*32)).FpExpr - if !((int32((*Expr)(unsafe.Pointer(pIpk)).Fop) == 119) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0)) { + if !((int32((*Expr)(unsafe.Pointer(pIpk)).Fop) == TK_NULL) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0)) { goto __102 } - Xsqlite3VdbeAddOp3(tls, v, 120, *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)), regRowid, regAutoinc) + Xsqlite3VdbeAddOp3(tls, v, OP_NewRowid, *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)), regRowid, regAutoinc) appendFlag = U8(1) goto __103 __102: @@ -103154,16 +101710,16 @@ __99: if !(!((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0)) { goto __105 } - addr11 = Xsqlite3VdbeAddOp1(tls, v, 51, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 120, *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)), regRowid, regAutoinc) + addr11 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_NewRowid, *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)), regRowid, regAutoinc) Xsqlite3VdbeJumpHere(tls, v, addr11) goto __106 __105: addr11 = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp2(tls, v, 50, regRowid, (addr11 + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regRowid, (addr11 + 2)) __106: ; - Xsqlite3VdbeAddOp1(tls, v, 15, regRowid) + Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, regRowid) __104: ; goto __97 @@ -103171,10 +101727,10 @@ __96: if !(((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) || (withoutRowid != 0)) { goto __107 } - Xsqlite3VdbeAddOp2(tls, v, 72, 0, regRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regRowid) goto __108 __107: - Xsqlite3VdbeAddOp3(tls, v, 120, *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)), regRowid, regAutoinc) + Xsqlite3VdbeAddOp3(tls, v, OP_NewRowid, *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)), regRowid, regAutoinc) appendFlag = U8(1) __108: ; @@ -103186,7 +101742,7 @@ __97: // columns have already been computed. This must be done after // computing the ROWID in case one of the generated columns // is derived from the INTEGER PRIMARY KEY. - if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != 0) { + if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != 0) { goto __109 } Xsqlite3ComputeGeneratedColumns(tls, pParse, (regRowid + 1), pTab) @@ -103200,10 +101756,10 @@ __109: } pVTab = Xsqlite3GetVTable(tls, db, pTab) Xsqlite3VtabMakeWritable(tls, pParse, pTab) - Xsqlite3VdbeAddOp4(tls, v, 10, 1, (int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 2), regIns, pVTab, -12) + Xsqlite3VdbeAddOp4(tls, v, OP_VUpdate, 1, (int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 2), regIns, pVTab, -12) Xsqlite3VdbeChangeP5(tls, v, func() uint16 { - if onError == 11 { - return uint16(2) + if onError == OE_Default { + return OE_Abort } return uint16(onError) }()) @@ -103235,7 +101791,7 @@ __94: if !(regRowCount != 0) { goto __112 } - Xsqlite3VdbeAddOp2(tls, v, 82, regRowCount, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, regRowCount, 1) __112: ; @@ -103243,7 +101799,7 @@ __112: goto __113 } // Code AFTER triggers - Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, 125, uintptr(0), 2, + Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, TK_INSERT, uintptr(0), TRIGGER_AFTER, pTab, ((regData - 2) - int32((*Table)(unsafe.Pointer(pTab)).FnCol)), onError, endOfLoop) __113: ; @@ -103254,9 +101810,9 @@ __113: if !(useTempTable != 0) { goto __114 } - Xsqlite3VdbeAddOp2(tls, v, 5, srcTab, addrCont) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, srcTab, addrCont) Xsqlite3VdbeJumpHere(tls, v, addrInsTop) - Xsqlite3VdbeAddOp1(tls, v, 116, srcTab) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, srcTab) goto __115 __114: if !(pSelect != 0) { @@ -103286,9 +101842,9 @@ __117: if !(regRowCount != 0) { goto __118 } - Xsqlite3VdbeAddOp2(tls, v, 80, regRowCount, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, regRowCount, 1) Xsqlite3VdbeSetNumCols(tls, v, 1) - Xsqlite3VdbeSetColName(tls, v, 0, 0, ts+13496 /* "rows inserted" */, uintptr(0)) + Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, ts+13496 /* "rows inserted" */, uintptr(0)) __118: ; @@ -103313,17 +101869,17 @@ insert_cleanup: // expression node references any of the // columns that are being modifed by an UPDATE statement. func checkConstraintExprNode(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:121903:12: */ - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN { if int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) >= 0 { if *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) + uintptr((*Expr)(unsafe.Pointer(pExpr)).FiColumn)*4)) >= 0 { - *(*U16)(unsafe.Pointer(pWalker + 36 /* &.eCode */)) |= U16((0x01)) + *(*U16)(unsafe.Pointer(pWalker + 36 /* &.eCode */)) |= U16((CKCNSTRNT_COLUMN)) } } else { - *(*U16)(unsafe.Pointer(pWalker + 36 /* &.eCode */)) |= U16((0x02)) + *(*U16)(unsafe.Pointer(pWalker + 36 /* &.eCode */)) |= U16((CKCNSTRNT_ROWID)) } } - return 0 + return WRC_Continue } // pExpr is a CHECK constraint on a row that is being UPDATE-ed. The @@ -103354,7 +101910,7 @@ func Xsqlite3ExprReferencesUpdatedColumn(tls *libc.TLS, pExpr uintptr, aiChng ui Xsqlite3WalkExpr(tls, bp /* &w */, pExpr) if !(chngRowid != 0) { - *(*U16)(unsafe.Pointer(bp /* &w */ + 36 /* &.eCode */)) &= libc.Uint16FromInt32((^libc.Int32(0x02))) + *(*U16)(unsafe.Pointer(bp /* &w */ + 36 /* &.eCode */)) &= libc.Uint16FromInt32((libc.CplInt32(CKCNSTRNT_ROWID))) } return (libc.Bool32(int32((*Walker)(unsafe.Pointer(bp /* &w */)).FeCode) != 0)) @@ -103489,7 +102045,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // normal rowid tables. nPkField is the number of key fields in the // pPk index or 1 for a rowid table. In other words, nPkField is the // number of fields in the true primary key of the table. - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { pPk = uintptr(0) nPkField = 1 } else { @@ -103500,7 +102056,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // Record that this module has started // Test all NOT NULL constraints. - if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0800)) != 0 { + if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasNotNull) != 0 { var b2ndPass int32 = 0 // True if currently running 2nd pass var nSeenReplace int32 = 0 // Number of ON CONFLICT REPLACE operations var nGenerated int32 = 0 // Number of generated columns with NOT NULL @@ -103510,13 +102066,13 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt var pCol uintptr = ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32) // The column to check for NOT NULL var isGenerated int32 // non-zero if column is generated onError = int32((*Column)(unsafe.Pointer(pCol)).FnotNull) - if onError == 0 { + if onError == OE_None { continue } // No NOT NULL on this column if i == int32((*Table)(unsafe.Pointer(pTab)).FiPKey) { continue // ROWID is never NULL } - isGenerated = (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0060) + isGenerated = (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_GENERATED) if (isGenerated != 0) && !(b2ndPass != 0) { nGenerated++ continue // Generated columns processed on 2nd pass @@ -103525,16 +102081,16 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // Do not check NOT NULL on columns that do not change continue } - if int32(overrideError) != 11 { + if int32(overrideError) != OE_Default { onError = int32(overrideError) - } else if onError == 11 { - onError = 2 + } else if onError == OE_Default { + onError = OE_Abort } - if onError == 5 { + if onError == OE_Replace { if (b2ndPass != 0) || // REPLACE becomes ABORT on the 2nd pass ((*Column)(unsafe.Pointer(pCol)).FpDflt == uintptr(0)) { - onError = 2 + onError = OE_Abort } else { } @@ -103544,9 +102100,9 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt iReg = ((int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(i))) + regNewData) + 1) switch onError { - case 5: + case OE_Replace: { - var addr1 int32 = Xsqlite3VdbeAddOp1(tls, v, 51, iReg) + var addr1 int32 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, iReg) nSeenReplace++ Xsqlite3ExprCodeCopy(tls, pParse, (*Column)(unsafe.Pointer(pCol)).FpDflt, iReg) @@ -103555,20 +102111,19 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt } fallthrough - case 2: + case OE_Abort: Xsqlite3MayAbort(tls, pParse) - /* no break */ fallthrough - case 1: + case OE_Rollback: fallthrough - case 3: + case OE_Fail: { var zMsg uintptr = Xsqlite3MPrintf(tls, db, ts+9959 /* "%s.%s" */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName, (*Column)(unsafe.Pointer(pCol)).FzName)) - Xsqlite3VdbeAddOp3(tls, v, 67, (19 | (int32(5) << 8)), + Xsqlite3VdbeAddOp3(tls, v, OP_HaltIfNull, (SQLITE_CONSTRAINT | (int32(5) << 8)), onError, iReg) Xsqlite3VdbeAppendP4(tls, v, zMsg, -7) - Xsqlite3VdbeChangeP5(tls, v, uint16(1)) + Xsqlite3VdbeChangeP5(tls, v, P5_ConstraintNotNull) break @@ -103577,7 +102132,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt default: { - Xsqlite3VdbeAddOp2(tls, v, 50, iReg, ignoreDest) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, iReg, ignoreDest) break @@ -103594,7 +102149,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt break } // Never need more than 2 passes b2ndPass = 1 - if (nSeenReplace > 0) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != U32(0)) { + if (nSeenReplace > 0) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != U32(0)) { // If any NOT NULL ON CONFLICT REPLACE constraints fired on the // first pass, recomputed values for all generated columns, as // those values might depend on columns affected by the REPLACE. @@ -103604,13 +102159,13 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt } // end if( has-not-null-constraints ) // Test all CHECK constraints - if ((*Table)(unsafe.Pointer(pTab)).FpCheck != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000200)) == uint64(0)) { + if ((*Table)(unsafe.Pointer(pTab)).FpCheck != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_IgnoreChecks) == uint64(0)) { var pCheck uintptr = (*Table)(unsafe.Pointer(pTab)).FpCheck (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = -(regNewData + 1) - if int32(overrideError) != 11 { + if int32(overrideError) != OE_Default { onError = int32(overrideError) } else { - onError = 2 + onError = OE_Abort } for i = 0; i < (*ExprList)(unsafe.Pointer(pCheck)).FnExpr; i++ { var allOk int32 @@ -103630,22 +102185,22 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt pCopy = Xsqlite3ExprDup(tls, db, pExpr, 0) if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) { - Xsqlite3ExprIfTrue(tls, pParse, pCopy, allOk, 0x10) + Xsqlite3ExprIfTrue(tls, pParse, pCopy, allOk, SQLITE_JUMPIFNULL) } Xsqlite3ExprDelete(tls, db, pCopy) - if onError == 4 { + if onError == OE_Ignore { Xsqlite3VdbeGoto(tls, v, ignoreDest) } else { var zName uintptr = (*ExprList_item)(unsafe.Pointer((pCheck + 8 /* &.a */) + uintptr(i)*32)).FzEName if zName == uintptr(0) { zName = (*Table)(unsafe.Pointer(pTab)).FzName } - if onError == 5 { - onError = 2 + if onError == OE_Replace { + onError = OE_Abort } // IMP: R-26383-51744 - Xsqlite3HaltConstraint(tls, pParse, (19 | (int32(1) << 8)), - onError, zName, int8(0), - uint8(3)) + Xsqlite3HaltConstraint(tls, pParse, (SQLITE_CONSTRAINT | (int32(1) << 8)), + onError, zName, P4_TRANSIENT, + P5_ConstraintCheck) } Xsqlite3VdbeResolveLabel(tls, v, allOk) } @@ -103685,12 +102240,12 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // An ON CONFLICT DO NOTHING clause, without a constraint-target. // Make all unique constraint resolution be OE_Ignore - overrideError = U8(4) + overrideError = OE_Ignore pUpsert = uintptr(0) } else if (libc.AssignUintptr(&pUpIdx, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx)) != uintptr(0) { // If the constraint-target uniqueness check must be run first. // Jump to that uniqueness check now - upsertJump = Xsqlite3VdbeAddOp0(tls, v, 11) + upsertJump = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) } } @@ -103714,14 +102269,14 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // in a second pass. The addrRecheck and lblRecheckOk variables are // used to link together these tests which are separated from each other // in the generate bytecode. - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & (uint64(0x00002000 | 0x00004000))) == uint64(0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & (uint64(SQLITE_RecTriggers | SQLITE_ForeignKeys))) == uint64(0) { // There are not DELETE triggers nor FK constraints. No constraint // rechecks are needed. pTrigger = uintptr(0) regTrigCnt = 0 } else { - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00002000)) != 0 { - pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, 126, uintptr(0), uintptr(0)) + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_RecTriggers) != 0 { + pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, TK_DELETE, uintptr(0), uintptr(0)) regTrigCnt = (libc.Bool32((pTrigger != uintptr(0)) || (Xsqlite3FkRequired(tls, pParse, pTab, uintptr(0), 0) != 0))) } else { pTrigger = uintptr(0) @@ -103731,7 +102286,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // Replace triggers might exist. Allocate the counter and // initialize it to zero. regTrigCnt = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regTrigCnt) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regTrigCnt) lblRecheckOk = Xsqlite3VdbeMakeLabel(tls, pParse) addrRecheck = lblRecheckOk @@ -103745,18 +102300,18 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // Figure out what action to take in case of a rowid collision onError = int32((*Table)(unsafe.Pointer(pTab)).FkeyConf) - if int32(overrideError) != 11 { + if int32(overrideError) != OE_Default { onError = int32(overrideError) - } else if onError == 11 { - onError = 2 + } else if onError == OE_Default { + onError = OE_Abort } // figure out whether or not upsert applies in this case if (pUpsert != 0) && ((*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx == uintptr(0)) { if (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet == uintptr(0) { - onError = 4 // DO NOTHING is the same as INSERT OR IGNORE + onError = OE_Ignore // DO NOTHING is the same as INSERT OR IGNORE } else { - onError = 6 // DO UPDATE + onError = OE_Update // DO UPDATE } } @@ -103764,10 +102319,10 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // to some other UNIQUE constraint is FAIL or IGNORE, then we need // to defer the running of the rowid conflict checking until after // the UNIQUE constraints have run. - if ((onError == 5) && // IPK rule is REPLACE + if ((onError == OE_Replace) && // IPK rule is REPLACE (onError != int32(overrideError))) && // Rules for other contraints are different ((*Table)(unsafe.Pointer(pTab)).FpIndex != 0) { - ipkTop = (Xsqlite3VdbeAddOp0(tls, v, 11) + 1) + ipkTop = (Xsqlite3VdbeAddOp0(tls, v, OP_Goto) + 1) } @@ -103775,29 +102330,28 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // pkChng!=0 does not mean that the rowid has changed, only that // it might have changed. Skip the conflict logic below if the rowid // is unchanged. - Xsqlite3VdbeAddOp3(tls, v, 53, regNewData, addrRowidOk, regOldData) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x90)) + Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regNewData, addrRowidOk, regOldData) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NOTNULL) } // Check to see if the new rowid already exists in the table. Skip // the following conflict logic if it does not. - Xsqlite3VdbeAddOp3(tls, v, 32, iDataCur, addrRowidOk, regNewData) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, addrRowidOk, regNewData) switch onError { default: { - onError = 2 - /* no break */ + onError = OE_Abort } fallthrough - case 1: + case OE_Rollback: fallthrough - case 2: + case OE_Abort: fallthrough - case 3: + case OE_Fail: { Xsqlite3RowidConstraint(tls, pParse, onError, pTab) @@ -103805,7 +102359,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt } fallthrough - case 5: + case OE_Replace: { // If there are DELETE triggers on this table and the // recursive-triggers flag is set, call GenerateRowDelete() to @@ -103831,8 +102385,8 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt if regTrigCnt != 0 { Xsqlite3MultiWrite(tls, pParse) Xsqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, iDataCur, iIdxCur, - regNewData, int16(1), uint8(0), uint8(5), uint8(1), -1) - Xsqlite3VdbeAddOp2(tls, v, 82, regTrigCnt, 1) // incr trigger cnt + regNewData, int16(1), uint8(0), OE_Replace, uint8(1), -1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, regTrigCnt, 1) // incr trigger cnt nReplaceTrig++ } else { @@ -103840,7 +102394,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // not modify the b-tree. It is more efficient to let the coming // OP_Insert replace the existing entry than it is to delete the // existing entry and then insert a new one. - Xsqlite3VdbeAddOp2(tls, v, 122, iDataCur, 0x40) + Xsqlite3VdbeAddOp2(tls, v, OP_Delete, iDataCur, OPFLAG_ISNOOP) Xsqlite3VdbeAppendP4(tls, v, pTab, -6) if (*Table)(unsafe.Pointer(pTab)).FpIndex != 0 { Xsqlite3MultiWrite(tls, pParse) @@ -103852,14 +102406,13 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt } fallthrough - case 6: + case OE_Update: { Xsqlite3UpsertDoUpdate(tls, pParse, pUpsert, pTab, uintptr(0), iDataCur) - /* no break */ } fallthrough - case 4: + case OE_Ignore: { Xsqlite3VdbeGoto(tls, v, ignoreDest) @@ -103869,7 +102422,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt } Xsqlite3VdbeResolveLabel(tls, v, addrRowidOk) if ipkTop != 0 { - ipkBottom = Xsqlite3VdbeAddOp0(tls, v, 11) + ipkBottom = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) Xsqlite3VdbeJumpHere(tls, v, (ipkTop - 1)) } } @@ -103913,10 +102466,10 @@ __1: // Skip partial indices for which the WHERE clause is not true if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(ix)*4))) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(ix)*4))) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = -(regNewData + 1) Xsqlite3ExprIfFalseDup(tls, pParse, (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere, addrUniqueOk, - 0x10) + SQLITE_JUMPIFNULL) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0 } @@ -103933,16 +102486,16 @@ __1: } else if (iField == (-1)) || (iField == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) { x = regNewData - Xsqlite3VdbeAddOp2(tls, v, 79, x, (regIdx + i)) + Xsqlite3VdbeAddOp2(tls, v, OP_IntCopy, x, (regIdx + i)) } else { x = ((int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(iField))) + regNewData) + 1) - Xsqlite3VdbeAddOp2(tls, v, 78, x, (regIdx + i)) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, x, (regIdx + i)) } } - Xsqlite3VdbeAddOp3(tls, v, 91, regIdx, int32((*Index)(unsafe.Pointer(pIdx)).FnColumn), *(*int32)(unsafe.Pointer(aRegIdx + uintptr(ix)*4))) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regIdx, int32((*Index)(unsafe.Pointer(pIdx)).FnColumn), *(*int32)(unsafe.Pointer(aRegIdx + uintptr(ix)*4))) // In an UPDATE operation, if this index is the PRIMARY KEY index // of a WITHOUT ROWID table and there has been no change the @@ -103955,22 +102508,22 @@ __1: // Find out what action to take in case there is a uniqueness conflict onError = int32((*Index)(unsafe.Pointer(pIdx)).FonError) - if onError == 0 { + if onError == OE_None { Xsqlite3VdbeResolveLabel(tls, v, addrUniqueOk) goto __2 // pIdx is not a UNIQUE index } - if int32(overrideError) != 11 { + if int32(overrideError) != OE_Default { onError = int32(overrideError) - } else if onError == 11 { - onError = 2 + } else if onError == OE_Default { + onError = OE_Abort } // Figure out if the upsert clause applies to this index if pUpIdx == pIdx { if (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet == uintptr(0) { - onError = 4 // DO NOTHING is the same as INSERT OR IGNORE + onError = OE_Ignore // DO NOTHING is the same as INSERT OR IGNORE } else { - onError = 6 // DO UPDATE + onError = OE_Update // DO UPDATE } } @@ -103987,7 +102540,7 @@ __1: // Check to see if the new index entry will be unique - addrConflictCk = Xsqlite3VdbeAddOp4Int(tls, v, 28, iThisCur, addrUniqueOk, + addrConflictCk = Xsqlite3VdbeAddOp4Int(tls, v, OP_NoConflict, iThisCur, addrUniqueOk, regIdx, int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)) // Generate code to handle collisions @@ -103996,14 +102549,14 @@ __1: } else { regR = Xsqlite3GetTempRange(tls, pParse, nPkField) } - if (isUpdate != 0) || (onError == 5) { - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { - Xsqlite3VdbeAddOp2(tls, v, 134, iThisCur, regR) + if (isUpdate != 0) || (onError == OE_Replace) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { + Xsqlite3VdbeAddOp2(tls, v, OP_IdxRowid, iThisCur, regR) // Conflict only if the rowid of the existing index entry // is different from old-rowid if isUpdate != 0 { - Xsqlite3VdbeAddOp3(tls, v, 53, regR, addrUniqueOk, regOldData) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x90)) + Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regR, addrUniqueOk, regOldData) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NOTNULL) } } else { @@ -104014,7 +102567,7 @@ __1: for i = 0; i < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); i++ { x = int32(Xsqlite3TableColumnToIndex(tls, pIdx, *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))) - Xsqlite3VdbeAddOp3(tls, v, 89, iThisCur, x, (regR + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iThisCur, x, (regR + i)) } } @@ -104027,9 +102580,9 @@ __1: // of the matched index row are different from the original PRIMARY // KEY values of this row before the update. var addrJump int32 = (Xsqlite3VdbeCurrentAddr(tls, v) + int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) - var op int32 = 52 + var op int32 = OP_Ne var regCmp int32 = func() int32 { - if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2 { + if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY { return regIdx } return regR @@ -104041,12 +102594,12 @@ __1: if i == (int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol) - 1) { addrJump = addrUniqueOk - op = 53 + op = OP_Eq } x = int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(x))) Xsqlite3VdbeAddOp4(tls, v, op, ((regOldData + 1) + x), addrJump, (regCmp + i), p4, -2) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x90)) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NOTNULL) } } @@ -104056,25 +102609,24 @@ __1: // Generate code that executes if the new index entry is not unique switch onError { - case 1: + case OE_Rollback: fallthrough - case 2: + case OE_Abort: fallthrough - case 3: + case OE_Fail: { Xsqlite3UniqueConstraint(tls, pParse, onError, pIdx) break } - case 6: + case OE_Update: { Xsqlite3UpsertDoUpdate(tls, pParse, pUpsert, pTab, pIdx, (iIdxCur + ix)) - /* no break */ } fallthrough - case 4: + case OE_Ignore: { Xsqlite3VdbeGoto(tls, v, ignoreDest) @@ -104092,24 +102644,24 @@ __1: nReplaceTrig++ } if (pTrigger != 0) && (isUpdate != 0) { - Xsqlite3VdbeAddOp1(tls, v, 159, iDataCur) + Xsqlite3VdbeAddOp1(tls, v, OP_CursorLock, iDataCur) } Xsqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, iDataCur, iIdxCur, - regR, int16(nPkField), uint8(0), uint8(5), + regR, int16(nPkField), uint8(0), OE_Replace, func() uint8 { if pIdx == pPk { - return uint8(1) + return ONEPASS_SINGLE } - return uint8(0) + return ONEPASS_OFF }(), iThisCur) if (pTrigger != 0) && (isUpdate != 0) { - Xsqlite3VdbeAddOp1(tls, v, 160, iDataCur) + Xsqlite3VdbeAddOp1(tls, v, OP_CursorUnlock, iDataCur) } if regTrigCnt != 0 { var addrBypass int32 // Jump destination to bypass recheck logic - Xsqlite3VdbeAddOp2(tls, v, 82, regTrigCnt, 1) // incr trigger cnt - addrBypass = Xsqlite3VdbeAddOp0(tls, v, 11) // Bypass recheck + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, regTrigCnt, 1) // incr trigger cnt + addrBypass = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) // Bypass recheck // Here we insert code that will be invoked after all constraint // checks have run, if and only if one or more replace triggers @@ -104119,7 +102671,7 @@ __1: if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { // Bypass the recheck if this partial index is not defined // for the current row - Xsqlite3VdbeAddOp2(tls, v, 50, (regIdx - 1), lblRecheckOk) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (regIdx - 1), lblRecheckOk) } // Copy the constraint check code from above, except change @@ -104132,10 +102684,10 @@ __1: // Hence, make a complete copy of the opcode, rather than using // a pointer to the opcode. *(*VdbeOp)(unsafe.Pointer(bp + 16 /* x */)) = *(*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, v, addrConflictCk))) - if int32((*VdbeOp)(unsafe.Pointer(bp+16 /* &x */)).Fopcode) != 134 { + if int32((*VdbeOp)(unsafe.Pointer(bp+16 /* &x */)).Fopcode) != OP_IdxRowid { var p2 int32 // New P2 value for copied conflict check opcode var zP4 uintptr - if (int32(Xsqlite3OpcodeProperty[(*VdbeOp)(unsafe.Pointer(bp+16 /* &x */)).Fopcode]) & 0x01) != 0 { + if (int32(Xsqlite3OpcodeProperty[(*VdbeOp)(unsafe.Pointer(bp+16 /* &x */)).Fopcode]) & OPFLG_JUMP) != 0 { p2 = lblRecheckOk } else { p2 = (*VdbeOp)(unsafe.Pointer(bp + 16 /* &x */)).Fp2 @@ -104153,7 +102705,7 @@ __1: addrConflictCk++ } // If the retest fails, issue an abort - Xsqlite3UniqueConstraint(tls, pParse, 2, pIdx) + Xsqlite3UniqueConstraint(tls, pParse, OE_Abort, pIdx) Xsqlite3VdbeJumpHere(tls, v, addrBypass) // Terminate the recheck bypass } @@ -104192,17 +102744,17 @@ __3: // Recheck all uniqueness constraints after replace triggers have run if nReplaceTrig != 0 { - Xsqlite3VdbeAddOp2(tls, v, 20, regTrigCnt, lblRecheckOk) + Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, regTrigCnt, lblRecheckOk) if !(pPk != 0) { if isUpdate != 0 { - Xsqlite3VdbeAddOp3(tls, v, 53, regNewData, addrRecheck, regOldData) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x90)) + Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regNewData, addrRecheck, regOldData) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NOTNULL) } - Xsqlite3VdbeAddOp3(tls, v, 32, iDataCur, addrRecheck, regNewData) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, addrRecheck, regNewData) - Xsqlite3RowidConstraint(tls, pParse, 2, pTab) + Xsqlite3RowidConstraint(tls, pParse, OE_Abort, pTab) } else { Xsqlite3VdbeGoto(tls, v, addrRecheck) } @@ -104210,9 +102762,9 @@ __3: } // Generate the table record - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { var regRec int32 = *(*int32)(unsafe.Pointer(aRegIdx + uintptr(ix)*4)) - Xsqlite3VdbeAddOp3(tls, v, 91, (regNewData + 1), int32((*Table)(unsafe.Pointer(pTab)).FnNVCol), regRec) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (regNewData + 1), int32((*Table)(unsafe.Pointer(pTab)).FnNVCol), regRec) if !(bAffinityDone != 0) { Xsqlite3TableAffinity(tls, v, pTab, 0) @@ -104252,29 +102804,29 @@ __1: goto __2 } if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { - Xsqlite3VdbeAddOp2(tls, v, 50, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) } pik_flags = func() uint8 { if useSeekResult != 0 { - return uint8(0x10) + return OPFLAG_USESEEKRESULT } return uint8(0) }() - if ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { - pik_flags = U8(int32(pik_flags) | (0x01)) - pik_flags = U8(int32(pik_flags) | (update_flags & 0x02)) + pik_flags = U8(int32(pik_flags) | (OPFLAG_NCHANGE)) + pik_flags = U8(int32(pik_flags) | (update_flags & OPFLAG_SAVEPOSITION)) if update_flags == 0 { var r int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, r) - Xsqlite3VdbeAddOp4(tls, v, 121, + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, r) + Xsqlite3VdbeAddOp4(tls, v, OP_Insert, (iIdxCur + i), *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), r, pTab, -6) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x40)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_ISNOOP) Xsqlite3ReleaseTempReg(tls, pParse, r) } } - Xsqlite3VdbeAddOp4Int(tls, v, 130, (iIdxCur + i), *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, (iIdxCur + i), *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), (*(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)) + 1), func() int32 { if (uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 100 /* &.uniqNotNull */)) & 0x8 >> 3))) != 0 { @@ -104293,27 +102845,27 @@ __2: goto __3 __3: ; - if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { return } if (*Parse)(unsafe.Pointer(pParse)).Fnested != 0 { pik_flags = U8(0) } else { - pik_flags = U8(0x01) + pik_flags = OPFLAG_NCHANGE pik_flags = U8(int32(pik_flags) | (func() int32 { if update_flags != 0 { return update_flags } - return 0x20 + return OPFLAG_LASTROWID }())) } if appendBias != 0 { - pik_flags = U8(int32(pik_flags) | (0x08)) + pik_flags = U8(int32(pik_flags) | (OPFLAG_APPEND)) } if useSeekResult != 0 { - pik_flags = U8(int32(pik_flags) | (0x10)) + pik_flags = U8(int32(pik_flags) | (OPFLAG_USESEEKRESULT)) } - Xsqlite3VdbeAddOp3(tls, v, 121, iDataCur, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), regNewData) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iDataCur, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), regNewData) if !(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0) { Xsqlite3VdbeAppendP4(tls, v, pTab, -6) } @@ -104362,10 +102914,10 @@ func Xsqlite3OpenTableAndIndices(tls *libc.TLS, pParse uintptr, pTab uintptr, op if piDataCur != 0 { *(*int32)(unsafe.Pointer(piDataCur)) = iDataCur } - if (((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) && ((aToOpen == uintptr(0)) || (*(*U8)(unsafe.Pointer(aToOpen + uintptr(0))) != 0)) { + if (((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((aToOpen == uintptr(0)) || (*(*U8)(unsafe.Pointer(aToOpen)) != 0)) { Xsqlite3OpenTable(tls, pParse, iDataCur, iDb, pTab, op) } else { - Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, (uint8(libc.Bool32(op == 97))), (*Table)(unsafe.Pointer(pTab)).FzName) + Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, (uint8(libc.Bool32(op == OP_OpenWrite))), (*Table)(unsafe.Pointer(pTab)).FzName) } if piIdxCur != 0 { *(*int32)(unsafe.Pointer(piIdxCur)) = iBase @@ -104379,7 +102931,7 @@ __1: { var iIdxCur int32 = libc.PostIncInt32(&iBase, 1) - if ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { if piDataCur != 0 { *(*int32)(unsafe.Pointer(piDataCur)) = iIdxCur } @@ -104510,19 +103062,19 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint if (*Table)(unsafe.Pointer(pDest)).FnModuleArg != 0 { return 0 // tab1 must not be a virtual table } - if onError == 11 { + if onError == OE_Default { if int32((*Table)(unsafe.Pointer(pDest)).FiPKey) >= 0 { onError = int32((*Table)(unsafe.Pointer(pDest)).FkeyConf) } - if onError == 11 { - onError = 2 + if onError == OE_Default { + onError = OE_Abort } } // allocated even if there is no FROM clause if (*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpSrc)).FnSrc != 1 { return 0 // FROM clause must have exactly one term } - if (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pSelect)).FpSrc+8 /* &.a */)+uintptr(0)*112)).FpSelect != 0 { + if (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pSelect)).FpSrc + 8 /* &.a */))).FpSelect != 0 { return 0 // FROM clause cannot contain a subquery } if (*Select)(unsafe.Pointer(pSelect)).FpWhere != 0 { @@ -104542,7 +103094,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint if (*Select)(unsafe.Pointer(pSelect)).FpPrior != 0 { return 0 // SELECT may not be a compound query } - if ((*Select)(unsafe.Pointer(pSelect)).FselFlags & U32(0x0000001)) != 0 { + if ((*Select)(unsafe.Pointer(pSelect)).FselFlags & SF_Distinct) != 0 { return 0 // SELECT may not be DISTINCT } pEList = (*Select)(unsafe.Pointer(pSelect)).FpEList @@ -104551,7 +103103,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint return 0 // The result set must have exactly one column } - if int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(0)*32)).FpExpr)).Fop) != 177 { + if int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */))).FpExpr)).Fop) != TK_ASTERISK { return 0 // The result set must be the special operator "*" } @@ -104567,7 +103119,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint // Possible due to bad sqlite_schema.rootpage return 0 // tab1 and tab2 may not be the same table } - if (libc.Bool32(((*Table)(unsafe.Pointer((pDest))).FtabFlags & U32(0x0080)) == U32(0))) != (libc.Bool32(((*Table)(unsafe.Pointer((pSrc))).FtabFlags & U32(0x0080)) == U32(0))) { + if (libc.Bool32(((*Table)(unsafe.Pointer((pDest))).FtabFlags & TF_WithoutRowid) == U32(0))) != (libc.Bool32(((*Table)(unsafe.Pointer((pSrc))).FtabFlags & TF_WithoutRowid) == U32(0))) { return 0 // source and destination must both be WITHOUT ROWID or not } if (*Table)(unsafe.Pointer(pSrc)).FnModuleArg != 0 { @@ -104600,13 +103152,13 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint // We could, in theory, disable this (except for internal use by the // VACUUM command where it is actually needed). But why do that? It // seems harmless enough, and provides a useful service. - if (int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags) & 0x0060) != (int32((*Column)(unsafe.Pointer(pSrcCol)).FcolFlags) & 0x0060) { + if (int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags) & COLFLAG_GENERATED) != (int32((*Column)(unsafe.Pointer(pSrcCol)).FcolFlags) & COLFLAG_GENERATED) { return 0 // Both columns have the same generated-column type } // But the transfer is only allowed if both the source and destination // tables have the exact same expressions for generated columns. // This requirement could be relaxed for VIRTUAL columns, I suppose. - if (int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags) & 0x0060) != 0 { + if (int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags) & COLFLAG_GENERATED) != 0 { if Xsqlite3ExprCompare(tls, uintptr(0), (*Column)(unsafe.Pointer(pSrcCol)).FpDflt, (*Column)(unsafe.Pointer(pDestCol)).FpDflt, -1) != 0 { return 0 // Different generator expressions @@ -104622,7 +103174,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint return 0 // tab2 must be NOT NULL if tab1 is } // Default values for second and subsequent columns need to match. - if ((int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags) & 0x0060) == 0) && (i > 0) { + if ((int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags) & COLFLAG_GENERATED) == 0) && (i > 0) { if ((libc.Bool32((*Column)(unsafe.Pointer(pDestCol)).FpDflt == uintptr(0))) != (libc.Bool32((*Column)(unsafe.Pointer(pSrcCol)).FpDflt == uintptr(0)))) || (((*Column)(unsafe.Pointer(pDestCol)).FpDflt != 0) && (libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer((*Column)(unsafe.Pointer(pDestCol)).FpDflt + 8 /* &.u */)), @@ -104632,7 +103184,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint } } for pDestIdx = (*Table)(unsafe.Pointer(pDest)).FpIndex; pDestIdx != 0; pDestIdx = (*Index)(unsafe.Pointer(pDestIdx)).FpNext { - if int32((*Index)(unsafe.Pointer((pDestIdx))).FonError) != 0 { + if int32((*Index)(unsafe.Pointer((pDestIdx))).FonError) != OE_None { destHasUniqueIdx = 1 } for pSrcIdx = (*Table)(unsafe.Pointer(pSrc)).FpIndex; pSrcIdx != 0; pSrcIdx = (*Index)(unsafe.Pointer(pSrcIdx)).FpNext { @@ -104644,7 +103196,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint return 0 // pDestIdx has no corresponding index in pSrc } if (((*Index)(unsafe.Pointer(pSrcIdx)).Ftnum == (*Index)(unsafe.Pointer(pDestIdx)).Ftnum) && ((*Table)(unsafe.Pointer(pSrc)).FpSchema == (*Table)(unsafe.Pointer(pDest)).FpSchema)) && - (Xsqlite3FaultSim(tls, 411) == 0) { + (Xsqlite3FaultSim(tls, 411) == SQLITE_OK) { // The sqlite3FaultSim() call allows this corruption test to be // bypassed during testing, in order to exercise other corruption tests // further downstream. @@ -104660,7 +103212,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint // command, and the VACUUM command disables foreign key constraints. So // the extra complication to make this rule less restrictive is probably // not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e] - if (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00004000)) != uint64(0)) && ((*Table)(unsafe.Pointer(pDest)).FpFKey != uintptr(0)) { + if (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ForeignKeys) != uint64(0)) && ((*Table)(unsafe.Pointer(pDest)).FpFKey != uintptr(0)) { return 0 } if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & (U64((uint64(0x00001))) << 32)) != uint64(0) { @@ -104678,11 +103230,11 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint regAutoinc = autoIncBegin(tls, pParse, iDbDest, pDest) regData = Xsqlite3GetTempReg(tls, pParse) regRowid = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3OpenTable(tls, pParse, iDest, iDbDest, pDest, 97) + Xsqlite3OpenTable(tls, pParse, iDest, iDbDest, pDest, OP_OpenWrite) - if (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0004)) == U32(0)) && ((((int32((*Table)(unsafe.Pointer(pDest)).FiPKey) < 0) && ((*Table)(unsafe.Pointer(pDest)).FpIndex != uintptr(0))) || // (1) + if (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_Vacuum) == U32(0)) && ((((int32((*Table)(unsafe.Pointer(pDest)).FiPKey) < 0) && ((*Table)(unsafe.Pointer(pDest)).FpIndex != uintptr(0))) || // (1) (destHasUniqueIdx != 0)) || // (2) - ((onError != 2) && (onError != 1))) { + ((onError != OE_Abort) && (onError != OE_Rollback))) { // In some circumstances, we are able to run the xfer optimization // only if the destination table is initially empty. Unless the // DBFLAG_Vacuum flag is set, this block generates code to make @@ -104699,41 +103251,41 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint // is unable to test uniqueness.) // // (3) onError is something other than OE_Abort and OE_Rollback. - addr1 = Xsqlite3VdbeAddOp2(tls, v, 37, iDest, 0) - emptyDestTest = Xsqlite3VdbeAddOp0(tls, v, 11) + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iDest, 0) + emptyDestTest = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) Xsqlite3VdbeJumpHere(tls, v, addr1) } - if ((*Table)(unsafe.Pointer((pSrc))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pSrc))).FtabFlags & TF_WithoutRowid) == U32(0) { var insFlags U8 - Xsqlite3OpenTable(tls, pParse, iSrc, iDbSrc, pSrc, 96) - emptySrcTest = Xsqlite3VdbeAddOp2(tls, v, 37, iSrc, 0) + Xsqlite3OpenTable(tls, pParse, iSrc, iDbSrc, pSrc, OP_OpenRead) + emptySrcTest = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iSrc, 0) if int32((*Table)(unsafe.Pointer(pDest)).FiPKey) >= 0 { - addr1 = Xsqlite3VdbeAddOp2(tls, v, 127, iSrc, regRowid) + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iSrc, regRowid) - addr2 = Xsqlite3VdbeAddOp3(tls, v, 32, iDest, 0, regRowid) + addr2 = Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDest, 0, regRowid) Xsqlite3RowidConstraint(tls, pParse, onError, pDest) Xsqlite3VdbeJumpHere(tls, v, addr2) autoIncStep(tls, pParse, regAutoinc, regRowid) - } else if ((*Table)(unsafe.Pointer(pDest)).FpIndex == uintptr(0)) && !(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0008)) != 0) { - addr1 = Xsqlite3VdbeAddOp2(tls, v, 120, iDest, regRowid) + } else if ((*Table)(unsafe.Pointer(pDest)).FpIndex == uintptr(0)) && !(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_VacuumInto) != 0) { + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iDest, regRowid) } else { - addr1 = Xsqlite3VdbeAddOp2(tls, v, 127, iSrc, regRowid) + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iSrc, regRowid) } - if ((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0004)) != 0 { - Xsqlite3VdbeAddOp1(tls, v, 129, iDest) - insFlags = (U8(0x08 | 0x10)) + if ((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_Vacuum) != 0 { + Xsqlite3VdbeAddOp1(tls, v, OP_SeekEnd, iDest) + insFlags = (U8(OPFLAG_APPEND | OPFLAG_USESEEKRESULT)) } else { - insFlags = (U8((0x01 | 0x20) | 0x08)) + insFlags = (U8((OPFLAG_NCHANGE | OPFLAG_LASTROWID) | OPFLAG_APPEND)) } - Xsqlite3VdbeAddOp3(tls, v, 126, iSrc, regData, 1) - Xsqlite3VdbeAddOp4(tls, v, 121, iDest, regData, regRowid, + Xsqlite3VdbeAddOp3(tls, v, OP_RowData, iSrc, regData, 1) + Xsqlite3VdbeAddOp4(tls, v, OP_Insert, iDest, regData, regRowid, pDest, -6) Xsqlite3VdbeChangeP5(tls, v, uint16(insFlags)) - Xsqlite3VdbeAddOp2(tls, v, 5, iSrc, addr1) - Xsqlite3VdbeAddOp2(tls, v, 116, iSrc, 0) - Xsqlite3VdbeAddOp2(tls, v, 116, iDest, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iSrc, addr1) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, iSrc, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, iDest, 0) } else { Xsqlite3TableLock(tls, pParse, iDbDest, (*Table)(unsafe.Pointer(pDest)).Ftnum, uint8(1), (*Table)(unsafe.Pointer(pDest)).FzName) Xsqlite3TableLock(tls, pParse, iDbSrc, (*Table)(unsafe.Pointer(pSrc)).Ftnum, uint8(0), (*Table)(unsafe.Pointer(pSrc)).FzName) @@ -104746,15 +103298,15 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint } } - Xsqlite3VdbeAddOp3(tls, v, 96, iSrc, int32((*Index)(unsafe.Pointer(pSrcIdx)).Ftnum), iDbSrc) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, iSrc, int32((*Index)(unsafe.Pointer(pSrcIdx)).Ftnum), iDbSrc) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pSrcIdx) - Xsqlite3VdbeAddOp3(tls, v, 97, iDest, int32((*Index)(unsafe.Pointer(pDestIdx)).Ftnum), iDbDest) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenWrite, iDest, int32((*Index)(unsafe.Pointer(pDestIdx)).Ftnum), iDbDest) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pDestIdx) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x01)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_BULKCSR) - addr1 = Xsqlite3VdbeAddOp2(tls, v, 37, iSrc, 0) - if ((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0004)) != 0 { + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iSrc, 0) + if ((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_Vacuum) != 0 { // This INSERT command is part of a VACUUM operation, which guarantees // that the destination table is empty. If all indexed columns use // collation sequence BINARY, then it can also be assumed that the @@ -104776,19 +103328,19 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint } } if i == int32((*Index)(unsafe.Pointer(pSrcIdx)).FnColumn) { - idxInsFlags = U8(0x10) - Xsqlite3VdbeAddOp1(tls, v, 129, iDest) + idxInsFlags = OPFLAG_USESEEKRESULT + Xsqlite3VdbeAddOp1(tls, v, OP_SeekEnd, iDest) } - } else if !(((*Table)(unsafe.Pointer((pSrc))).FtabFlags & U32(0x0080)) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer(pDestIdx + 100 /* &.idxType */)) & 0x3 >> 0)) == 2) { - idxInsFlags = U8(int32(idxInsFlags) | (0x01)) + } else if !(((*Table)(unsafe.Pointer((pSrc))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer(pDestIdx + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY) { + idxInsFlags = U8(int32(idxInsFlags) | (OPFLAG_NCHANGE)) } - Xsqlite3VdbeAddOp3(tls, v, 126, iSrc, regData, 1) - Xsqlite3VdbeAddOp2(tls, v, 130, iDest, regData) - Xsqlite3VdbeChangeP5(tls, v, (uint16(int32(idxInsFlags) | 0x08))) - Xsqlite3VdbeAddOp2(tls, v, 5, iSrc, (addr1 + 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_RowData, iSrc, regData, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, iDest, regData) + Xsqlite3VdbeChangeP5(tls, v, (uint16(int32(idxInsFlags) | OPFLAG_APPEND))) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iSrc, (addr1 + 1)) Xsqlite3VdbeJumpHere(tls, v, addr1) - Xsqlite3VdbeAddOp2(tls, v, 116, iSrc, 0) - Xsqlite3VdbeAddOp2(tls, v, 116, iDest, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, iSrc, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, iDest, 0) } if emptySrcTest != 0 { Xsqlite3VdbeJumpHere(tls, v, emptySrcTest) @@ -104797,9 +103349,9 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint Xsqlite3ReleaseTempReg(tls, pParse, regData) if emptyDestTest != 0 { Xsqlite3AutoincrementEnd(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 68, 0, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Halt, SQLITE_OK, 0) Xsqlite3VdbeJumpHere(tls, v, emptyDestTest) - Xsqlite3VdbeAddOp2(tls, v, 116, iDest, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, iDest, 0) return 0 } else { return 1 @@ -104848,7 +103400,7 @@ func Xsqlite3_exec(tls *libc.TLS, db uintptr, zSql uintptr, xCallback Sqlite3_ca var i int32 var nCol int32 var azVals uintptr - rc = 0 + rc = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) azCols = uintptr(0) // True if callback data is initialized @@ -104866,9 +103418,9 @@ __2: ; Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - Xsqlite3Error(tls, db, 0) + Xsqlite3Error(tls, db, SQLITE_OK) __3: - if !((rc == 0) && (*(*int8)(unsafe.Pointer(zSql + uintptr(0))) != 0)) { + if !((rc == SQLITE_OK) && (*(*int8)(unsafe.Pointer(zSql)) != 0)) { goto __4 } nCol = 0 @@ -104877,7 +103429,7 @@ __3: *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp /* &pStmt */, bp+8 /* &zLeftover */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __5 } goto __3 @@ -104900,8 +103452,8 @@ __7: rc = Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) // Invoke the callback function if required - if !((xCallback != 0) && ((100 == rc) || (((101 == rc) && !(callbackIsInit != 0)) && - (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000100)) != 0)))) { + if !((xCallback != 0) && ((SQLITE_ROW == rc) || (((SQLITE_DONE == rc) && !(callbackIsInit != 0)) && + (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_NullCallback) != 0)))) { goto __9 } if !(!(callbackIsInit != 0)) { @@ -104934,7 +103486,7 @@ __14: callbackIsInit = 1 __10: ; - if !(rc == 100) { + if !(rc == SQLITE_ROW) { goto __15 } azVals = (azCols + uintptr(nCol)*8) @@ -104944,7 +103496,7 @@ __16: goto __18 } *(*uintptr)(unsafe.Pointer(azVals + uintptr(i)*8)) = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i) - if !(!(int32(*(*uintptr)(unsafe.Pointer(azVals + uintptr(i)*8))) != 0) && (Xsqlite3_column_type(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i) != 5)) { + if !(!(int32(*(*uintptr)(unsafe.Pointer(azVals + uintptr(i)*8))) != 0) && (Xsqlite3_column_type(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i) != SQLITE_NULL)) { goto __19 } Xsqlite3OomFault(tls, db) @@ -104967,24 +103519,24 @@ __15: // EVIDENCE-OF: R-38229-40159 If the callback function to // sqlite3_exec() returns non-zero, then sqlite3_exec() will // return SQLITE_ABORT. - rc = 4 + rc = SQLITE_ABORT Xsqlite3VdbeFinalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) - Xsqlite3Error(tls, db, 4) + Xsqlite3Error(tls, db, SQLITE_ABORT) goto exec_out __20: ; __9: ; - if !(rc != 100) { + if !(rc != SQLITE_ROW) { goto __21 } rc = Xsqlite3VdbeFinalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) zSql = *(*uintptr)(unsafe.Pointer(bp + 8 /* zLeftover */)) __22: - if !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zSql + uintptr(0))))]) & 0x01) != 0) { + if !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zSql)))]) & 0x01) != 0) { goto __23 } zSql++ @@ -105014,15 +103566,15 @@ __24: Xsqlite3DbFree(tls, db, azCols) rc = Xsqlite3ApiExit(tls, db, rc) - if !((rc != 0) && (pzErrMsg != 0)) { + if !((rc != SQLITE_OK) && (pzErrMsg != 0)) { goto __25 } *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3DbStrDup(tls, uintptr(0), Xsqlite3_errmsg(tls, db)) if !(*(*uintptr)(unsafe.Pointer(pzErrMsg)) == uintptr(0)) { goto __27 } - rc = 7 - Xsqlite3Error(tls, db, 7) + rc = SQLITE_NOMEM + Xsqlite3Error(tls, db, SQLITE_NOMEM) __27: ; goto __26 @@ -105141,82 +103693,76 @@ var sqlite3Apis = Sqlite3_api_routines{ Ffree_table: 0, Fget_autocommit: 0, Fget_auxdata: 0, - Fget_table: 0, - Fglobal_recover: uintptr(0), - Finterruptx:// Was sqlite3_global_recover(), but that function is deprecated - 0, - Flast_insert_rowid: 0, - Flibversion: 0, - Flibversion_number: 0, - Fmalloc: 0, - Fmprintf: 0, - Fopen: 0, - Fopen16: 0, - Fprepare: 0, - Fprepare16: 0, - Fprofile: 0, - Fprogress_handler: 0, - Frealloc: 0, - Freset: 0, - Fresult_blob: 0, - Fresult_double: 0, - Fresult_error: 0, - Fresult_error16: 0, - Fresult_int: 0, - Fresult_int64: 0, - Fresult_null: 0, - Fresult_text: 0, - Fresult_text16: 0, - Fresult_text16be: 0, - Fresult_text16le: 0, - Fresult_value: 0, - Frollback_hook: 0, - Fset_authorizer: 0, - Fset_auxdata: 0, - Fxsnprintf: 0, - Fstep: 0, - Ftable_column_metadata: 0, - Fthread_cleanup: 0, - Ftotal_changes: 0, - Ftrace: 0, - Ftransfer_bindings: 0, - Fupdate_hook: 0, - Fuser_data: 0, - Fvalue_blob: 0, - Fvalue_bytes: 0, - Fvalue_bytes16: 0, - Fvalue_double: 0, - Fvalue_int: 0, - Fvalue_int64: 0, - Fvalue_numeric_type: 0, - Fvalue_text: 0, - Fvalue_text16: 0, - Fvalue_text16be: 0, - Fvalue_text16le: 0, - Fvalue_type: 0, - Fvmprintf: 0, - Foverload_function: + Fget_table: 0, // Was sqlite3_global_recover(), but that function is deprecated + Finterruptx: 0, + Flast_insert_rowid: 0, + Flibversion: 0, + Flibversion_number: 0, + Fmalloc: 0, + Fmprintf: 0, + Fopen: 0, + Fopen16: 0, + Fprepare: 0, + Fprepare16: 0, + Fprofile: 0, + Fprogress_handler: 0, + Frealloc: 0, + Freset: 0, + Fresult_blob: 0, + Fresult_double: 0, + Fresult_error: 0, + Fresult_error16: 0, + Fresult_int: 0, + Fresult_int64: 0, + Fresult_null: 0, + Fresult_text: 0, + Fresult_text16: 0, + Fresult_text16be: 0, + Fresult_text16le: 0, + Fresult_value: 0, + Frollback_hook: 0, + Fset_authorizer: 0, + Fset_auxdata: 0, + Fxsnprintf: 0, + Fstep: 0, + Ftable_column_metadata: 0, + Fthread_cleanup: 0, + Ftotal_changes: 0, + Ftrace: 0, + Ftransfer_bindings: 0, + Fupdate_hook: 0, + Fuser_data: 0, + Fvalue_blob: 0, + Fvalue_bytes: 0, + Fvalue_bytes16: 0, + Fvalue_double: 0, + Fvalue_int: 0, + Fvalue_int64: 0, + Fvalue_numeric_type: 0, + Fvalue_text: 0, + Fvalue_text16: 0, + Fvalue_text16be: 0, + Fvalue_text16le: 0, + Fvalue_type: 0, + Fvmprintf: 0, // The original API set ends here. All extensions can call any // of the APIs above provided that the pointer is not NULL. But // before calling APIs that follow, extension should check the // sqlite3_libversion_number() to make sure they are dealing with // a library that is new enough to support that API. // - 0, - Fprepare_v2: + Foverload_function: 0, // Added after 3.3.13 - 0, + Fprepare_v2: 0, Fprepare16_v2: 0, Fclear_bindings: 0, - Fcreate_module_v2: // Added for 3.4.1 - 0, - Fbind_zeroblob: + Fcreate_module_v2: 0, // Added for 3.5.0 - 0, + Fbind_zeroblob: 0, Fblob_bytes: 0, Fblob_close: 0, Fblob_open: 0, @@ -105240,27 +103786,24 @@ var sqlite3Apis = Sqlite3_api_routines{ Fvfs_find: 0, Fvfs_register: 0, Fvfs_unregister: 0, - Fxthreadsafe: // Added for 3.5.8 - 0, + Fxthreadsafe: 0, Fresult_zeroblob: 0, Fresult_error_code: 0, Ftest_control: 0, Frandomness: 0, Fcontext_db_handle: 0, - Fextended_result_codes: // Added for 3.6.0 - 0, - Flimit: 0, - Fnext_stmt: 0, - Fsql: 0, - Fstatus: 0, - Fbackup_finish: + Fextended_result_codes: 0, + Flimit: 0, + Fnext_stmt: 0, + Fsql: 0, + Fstatus: 0, // Added for 3.7.4 - 0, + Fbackup_finish: 0, Fbackup_init: 0, Fbackup_pagecount: 0, Fbackup_remaining: 0, @@ -105297,9 +103840,8 @@ var sqlite3Apis = Sqlite3_api_routines{ Furi_parameter: 0, Fxvsnprintf: 0, Fwal_checkpoint_v2: 0, - Fauto_extension: // Version 3.8.7 and later - 0, + Fauto_extension: 0, Fbind_blob64: 0, Fbind_text64: 0, Fcancel_auto_extension: 0, @@ -105311,46 +103853,37 @@ var sqlite3Apis = Sqlite3_api_routines{ Fresult_blob64: 0, Fresult_text64: 0, Fstrglob: 0, - Fvalue_dup: // Version 3.8.11 and later - 0, + Fvalue_dup: 0, Fvalue_free: 0, Fresult_zeroblob64: 0, Fbind_zeroblob64: 0, - Fvalue_subtype: // Version 3.9.0 and later - 0, + Fvalue_subtype: 0, Fresult_subtype: 0, - Fstatus64: // Version 3.10.0 and later - 0, + Fstatus64: 0, Fstrlike: 0, Fdb_cacheflush: 0, - Fsystem_errno: // Version 3.12.0 and later - 0, - Ftrace_v2: + Fsystem_errno: 0, // Version 3.14.0 and later - 0, + Ftrace_v2: 0, Fexpanded_sql: 0, - Fset_last_insert_rowid: // Version 3.18.0 and later - 0, - Fprepare_v3: + Fset_last_insert_rowid: 0, // Version 3.20.0 and later - 0, + Fprepare_v3: 0, Fprepare16_v3: 0, Fbind_pointer: 0, Fresult_pointer: 0, Fvalue_pointer: 0, - Fvtab_nochange: // Version 3.22.0 and later - 0, + Fvtab_nochange: 0, Fvalue_nochange: 0, Fvtab_collation: 0, - Fkeyword_count: // Version 3.24.0 and later - 0, + Fkeyword_count: 0, Fkeyword_name: 0, Fkeyword_check: 0, Fstr_new: 0, @@ -105364,29 +103897,21 @@ var sqlite3Apis = Sqlite3_api_routines{ Fstr_errcode: 0, Fstr_length: 0, Fstr_value: 0, - Fcreate_window_function: // Version 3.25.0 and later - 0, - Fnormalized_sql: - // Version 3.26.0 and later - uintptr(0), - Fstmt_isexplain: + Fcreate_window_function: 0, // Version 3.28.0 and later - 0, + Fstmt_isexplain: 0, Fvalue_frombind: 0, - Fdrop_modules: // Version 3.30.0 and later - 0, - Fhard_heap_limit64: + Fdrop_modules: 0, // Version 3.31.0 and later - 0, + Fhard_heap_limit64: 0, Furi_key: 0, Ffilename_database: 0, Ffilename_journal: 0, Ffilename_wal: 0, - Fcreate_filename: // Version 3.32.0 and later - 0, + Fcreate_filename: 0, Ffree_filename: 0, Fdatabase_file_object: 0, } /* sqlite3.c:124371:35 */ @@ -105428,11 +103953,11 @@ func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintpt // must call either sqlite3_enable_load_extension(db) or // sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, 0) // to turn on extension loading. - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00010000)) == uint64(0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_LoadExtension) == uint64(0) { if pzErrMsg != 0 { *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+9998 /* "not authorized" */, 0) } - return 1 + return SQLITE_ERROR } if zProc != 0 { @@ -105445,7 +103970,7 @@ func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintpt for ii = 0; (ii < (int32(uint64(unsafe.Sizeof(azEndings)) / uint64(unsafe.Sizeof(uintptr(0)))))) && (handle == uintptr(0)); ii++ { var zAltFile uintptr = Xsqlite3_mprintf(tls, ts+9959 /* "%s.%s" */, libc.VaList(bp, zFile, azEndings[ii])) if zAltFile == uintptr(0) { - return 7 + return SQLITE_NOMEM } handle = Xsqlite3OsDlOpen(tls, pVfs, zAltFile) Xsqlite3_free(tls, zAltFile) @@ -105459,7 +103984,7 @@ func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintpt Xsqlite3OsDlError(tls, pVfs, (int32(nMsg - uint64(1))), *(*uintptr)(unsafe.Pointer(bp + 48 /* zErrmsg */))) } } - return 1 + return SQLITE_ERROR } xInit = Xsqlite3OsDlSym(tls, pVfs, handle, zEntry) @@ -105481,7 +104006,7 @@ func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintpt zAltEntry = Xsqlite3_malloc64(tls, (uint64(ncFile + 30))) if zAltEntry == uintptr(0) { Xsqlite3OsDlClose(tls, pVfs, handle) - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, zAltEntry, ts+13568 /* "sqlite3_" */, uint64(8)) for iFile = (ncFile - 1); (iFile >= 0) && !((int32(*(*int8)(unsafe.Pointer(zFile + uintptr(iFile))))) == '/'); iFile-- { @@ -105511,26 +104036,26 @@ func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintpt } Xsqlite3OsDlClose(tls, pVfs, handle) Xsqlite3_free(tls, zAltEntry) - return 1 + return SQLITE_ERROR } Xsqlite3_free(tls, zAltEntry) rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&xInit)))(tls, db, bp+48 /* &zErrmsg */, uintptr(unsafe.Pointer(&sqlite3Apis))) if rc != 0 { - if rc == (0 | (int32(1) << 8)) { - return 0 + if rc == (SQLITE_OK | (int32(1) << 8)) { + return SQLITE_OK } if pzErrMsg != 0 { *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+13630 /* "error during ini..." */, libc.VaList(bp+40, *(*uintptr)(unsafe.Pointer(bp + 48 /* zErrmsg */)))) } Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* zErrmsg */))) Xsqlite3OsDlClose(tls, pVfs, handle) - return 1 + return SQLITE_ERROR } // Append the new shared library handle to the db->aExtension array. aHandle = Xsqlite3DbMallocZero(tls, db, (uint64(uint64(unsafe.Sizeof(handle)) * (uint64((*Sqlite3)(unsafe.Pointer(db)).FnExtension + 1))))) if aHandle == uintptr(0) { - return 7 + return SQLITE_NOMEM } if (*Sqlite3)(unsafe.Pointer(db)).FnExtension > 0 { libc.Xmemcpy(tls, aHandle, (*Sqlite3)(unsafe.Pointer(db)).FaExtension, (uint64(unsafe.Sizeof(handle)) * uint64((*Sqlite3)(unsafe.Pointer(db)).FnExtension))) @@ -105539,7 +104064,7 @@ func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintpt (*Sqlite3)(unsafe.Pointer(db)).FaExtension = aHandle *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaExtension + uintptr(libc.PostIncInt32(&(*Sqlite3)(unsafe.Pointer(db)).FnExtension, 1))*8)) = handle - return 0 + return SQLITE_OK } var azEndings = [1]uintptr{ @@ -105571,12 +104096,12 @@ func Xsqlite3CloseExtensions(tls *libc.TLS, db uintptr) { /* sqlite3.c:124900:21 func Xsqlite3_enable_load_extension(tls *libc.TLS, db uintptr, onoff int32) int32 { /* sqlite3.c:124913:16: */ Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) if onoff != 0 { - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(0x00010000 | 0x00020000)) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(SQLITE_LoadExtension | SQLITE_LoadExtFunc)) } else { - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64((uint64(0x00010000 | 0x00020000)))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64((uint64(SQLITE_LoadExtension | SQLITE_LoadExtFunc)))) } Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // The following object holds the list of automatically loaded @@ -105607,13 +104132,13 @@ var sqlite3Autoext = sqlite3AutoExtList{} /* sqlite3.c:124937:3 */ // Register a statically linked extension that is automatically // loaded by every new database connection. func Xsqlite3_auto_extension(tls *libc.TLS, xInit uintptr) int32 { /* sqlite3.c:124959:16: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK rc = Xsqlite3_initialize(tls) if rc != 0 { return rc } else { var i U32 - var mutex uintptr = Xsqlite3MutexAlloc(tls, 2) + var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutex) for i = U32(0); i < sqlite3Autoext.FnExt; i++ { @@ -105626,7 +104151,7 @@ func Xsqlite3_auto_extension(tls *libc.TLS, xInit uintptr) int32 { /* sqlite3.c: var aNew uintptr aNew = Xsqlite3_realloc64(tls, sqlite3Autoext.FaExt, nByte) if aNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { sqlite3Autoext.FaExt = aNew *(*uintptr)(unsafe.Pointer(sqlite3Autoext.FaExt + uintptr(sqlite3Autoext.FnExt)*8)) = xInit @@ -105648,7 +104173,7 @@ func Xsqlite3_auto_extension(tls *libc.TLS, xInit uintptr) int32 { /* sqlite3.c: // Return 1 if xInit was found on the list and removed. Return 0 if xInit // was not on the list. func Xsqlite3_cancel_auto_extension(tls *libc.TLS, xInit uintptr) int32 { /* sqlite3.c:125006:16: */ - var mutex uintptr = Xsqlite3MutexAlloc(tls, 2) + var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) var i int32 var n int32 = 0 @@ -105667,8 +104192,8 @@ func Xsqlite3_cancel_auto_extension(tls *libc.TLS, xInit uintptr) int32 { /* sql // Reset the automatic extension loading mechanism. func Xsqlite3_reset_auto_extension(tls *libc.TLS) { /* sqlite3.c:125031:17: */ - if Xsqlite3_initialize(tls) == 0 { - var mutex uintptr = Xsqlite3MutexAlloc(tls, 2) + if Xsqlite3_initialize(tls) == SQLITE_OK { + var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutex) Xsqlite3_free(tls, sqlite3Autoext.FaExt) @@ -105697,7 +104222,7 @@ func Xsqlite3AutoLoadExtensions(tls *libc.TLS, db uintptr) { /* sqlite3.c:125053 for i = U32(0); go1 != 0; i++ { // var zErrmsg uintptr at bp+8, 8 - var mutex uintptr = Xsqlite3MutexAlloc(tls, 2) + var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) var pThunk uintptr = uintptr(unsafe.Pointer(&sqlite3Apis)) Xsqlite3_mutex_enter(tls, mutex) if i >= sqlite3Autoext.FnExt { @@ -105826,721 +104351,237 @@ type PragmaName1 = struct { // Definitions of all built-in pragmas type PragmaName = PragmaName1 /* sqlite3.c:125259:3 */ var aPragmaName = [65]PragmaName{ - { - FzName:/* zName: */ ts + 13938, /* "analysis_limit" */ - FePragTyp: - /* ePragTyp: */ U8(1), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 13953, /* "application_id" */ - FePragTyp: - /* ePragTyp: */ U8(2), - FmPragFlg: - /* ePragFlg: */ (U8(0x04 | 0x10)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(8)}, - { - FzName:/* zName: */ ts + 13968, /* "auto_vacuum" */ - FePragTyp: - /* ePragTyp: */ U8(3), - FmPragFlg: - /* ePragFlg: */ (U8(((0x01 | 0x10) | 0x80) | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 13980, /* "automatic_index" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00008000)}, - { - FzName:/* zName: */ ts + 13996, /* "busy_timeout" */ - FePragTyp: - /* ePragTyp: */ U8(5), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(50), - FnPragCName: U8(1), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 13919, /* "cache_size" */ - FePragTyp: - /* ePragTyp: */ U8(6), - FmPragFlg: - /* ePragFlg: */ (U8(((0x01 | 0x10) | 0x80) | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14009, /* "cache_spill" */ - FePragTyp: - /* ePragTyp: */ U8(7), - FmPragFlg: - /* ePragFlg: */ (U8((0x10 | 0x80) | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14021, /* "case_sensitive_l..." */ - FePragTyp: - /* ePragTyp: */ U8(8), - FmPragFlg: - /* ePragFlg: */ U8(0x02), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14041, /* "cell_size_check" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00200000)}, - { - FzName:/* zName: */ ts + 14057, /* "checkpoint_fullf..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000010)}, - { - FzName:/* zName: */ ts + 14078, /* "collation_list" */ - FePragTyp: - /* ePragTyp: */ U8(9), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(32), - FnPragCName: U8(2), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14093, /* "compile_options" */ - FePragTyp: - /* ePragTyp: */ U8(10), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14109, /* "count_changes" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ (U64((uint64(0x00001))) << 32)}, - { - FzName:/* zName: */ ts + 14123, /* "data_version" */ - FePragTyp: - /* ePragTyp: */ U8(2), - FmPragFlg: - /* ePragFlg: */ (U8(0x08 | 0x10)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(15)}, - { - FzName:/* zName: */ ts + 14136, /* "database_list" */ - FePragTyp: - /* ePragTyp: */ U8(12), - FmPragFlg: - /* ePragFlg: */ (U8(0x01 | 0x10)), - FiPragCName: - /* ColNames: */ U8(41), - FnPragCName: U8(3), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14150, /* "default_cache_si..." */ - FePragTyp: - /* ePragTyp: */ U8(13), - FmPragFlg: - /* ePragFlg: */ (U8(((0x01 | 0x10) | 0x80) | 0x04)), - FiPragCName: - /* ColNames: */ U8(49), - FnPragCName: U8(1), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14169, /* "defer_foreign_ke..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00080000)}, - { - FzName:/* zName: */ ts + 14188, /* "empty_result_cal..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000100)}, - { - FzName:/* zName: */ ts + 14211, /* "encoding" */ - FePragTyp: - /* ePragTyp: */ U8(14), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14220, /* "foreign_key_chec..." */ - FePragTyp: - /* ePragTyp: */ U8(15), - FmPragFlg: - /* ePragFlg: */ (U8(((0x01 | 0x10) | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(37), - FnPragCName: U8(4), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14238, /* "foreign_key_list" */ - FePragTyp: - /* ePragTyp: */ U8(16), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(8), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14255, /* "foreign_keys" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00004000)}, - { - FzName:/* zName: */ ts + 14268, /* "freelist_count" */ - FePragTyp: - /* ePragTyp: */ U8(2), - FmPragFlg: - /* ePragFlg: */ (U8(0x08 | 0x10)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14283, /* "full_column_name..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000004)}, - { - FzName:/* zName: */ ts + 14301, /* "fullfsync" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000008)}, - { - FzName:/* zName: */ ts + 14311, /* "function_list" */ - FePragTyp: - /* ePragTyp: */ U8(17), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(21), - FnPragCName: U8(6), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14325, /* "hard_heap_limit" */ - FePragTyp: - /* ePragTyp: */ U8(18), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14341, /* "ignore_check_con..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000200)}, - { - FzName:/* zName: */ ts + 14366, /* "incremental_vacu..." */ - FePragTyp: - /* ePragTyp: */ U8(19), - FmPragFlg: - /* ePragFlg: */ (U8(0x01 | 0x02)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14385, /* "index_info" */ - FePragTyp: - /* ePragTyp: */ U8(20), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(15), - FnPragCName: U8(3), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14396, /* "index_list" */ - FePragTyp: - /* ePragTyp: */ U8(21), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(32), - FnPragCName: U8(5), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14407, /* "index_xinfo" */ - FePragTyp: - /* ePragTyp: */ U8(20), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(15), - FnPragCName: U8(6), - FiArg: - /* iArg: */ uint64(1)}, - { - FzName:/* zName: */ ts + 14419, /* "integrity_check" */ - FePragTyp: - /* ePragTyp: */ U8(22), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x10) | 0x20)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14435, /* "journal_mode" */ - FePragTyp: - /* ePragTyp: */ U8(23), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x10) | 0x80)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14448, /* "journal_size_lim..." */ - FePragTyp: - /* ePragTyp: */ U8(24), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x80)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14467, /* "legacy_alter_tab..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x04000000)}, - { - FzName:/* zName: */ ts + 14486, /* "locking_mode" */ - FePragTyp: - /* ePragTyp: */ U8(26), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x80)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14499, /* "max_page_count" */ - FePragTyp: - /* ePragTyp: */ U8(27), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x10) | 0x80)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14514, /* "mmap_size" */ - FePragTyp: - /* ePragTyp: */ U8(28), - FmPragFlg: - /* ePragFlg: */ U8(0), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14524, /* "module_list" */ - FePragTyp: - /* ePragTyp: */ U8(29), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(9), - FnPragCName: U8(1), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14536, /* "optimize" */ - FePragTyp: - /* ePragTyp: */ U8(30), - FmPragFlg: - /* ePragFlg: */ (U8(0x20 | 0x01)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14545, /* "page_count" */ - FePragTyp: - /* ePragTyp: */ U8(27), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x10) | 0x80)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14556, /* "page_size" */ - FePragTyp: - /* ePragTyp: */ U8(31), - FmPragFlg: - /* ePragFlg: */ (U8((0x10 | 0x80) | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14566, /* "pragma_list" */ - FePragTyp: - /* ePragTyp: */ U8(32), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(9), - FnPragCName: U8(1), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14578, /* "query_only" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00100000)}, - { - FzName:/* zName: */ ts + 14589, /* "quick_check" */ - FePragTyp: - /* ePragTyp: */ U8(22), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x10) | 0x20)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14601, /* "read_uncommitted" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000400)}, - { - FzName:/* zName: */ ts + 14618, /* "recursive_trigge..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00002000)}, - { - FzName:/* zName: */ ts + 14637, /* "reverse_unordere..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00001000)}, - { - FzName:/* zName: */ ts + 14663, /* "schema_version" */ - FePragTyp: - /* ePragTyp: */ U8(2), - FmPragFlg: - /* ePragFlg: */ (U8(0x04 | 0x10)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(1)}, - { - FzName:/* zName: */ ts + 14678, /* "secure_delete" */ - FePragTyp: - /* ePragTyp: */ U8(33), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14692, /* "short_column_nam..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000040)}, - { - FzName:/* zName: */ ts + 14711, /* "shrink_memory" */ - FePragTyp: - /* ePragTyp: */ U8(34), - FmPragFlg: - /* ePragFlg: */ U8(0x02), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14725, /* "soft_heap_limit" */ - FePragTyp: - /* ePragTyp: */ U8(35), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14741, /* "synchronous" */ - FePragTyp: - /* ePragTyp: */ U8(36), - FmPragFlg: - /* ePragFlg: */ (U8(((0x01 | 0x10) | 0x80) | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14753, /* "table_info" */ - FePragTyp: - /* ePragTyp: */ U8(37), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(8), - FnPragCName: U8(6), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14764, /* "table_xinfo" */ - FePragTyp: - /* ePragTyp: */ U8(37), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(8), - FnPragCName: U8(7), - FiArg: - /* iArg: */ uint64(1)}, - { - FzName:/* zName: */ ts + 14776, /* "temp_store" */ - FePragTyp: - /* ePragTyp: */ U8(38), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14787, /* "temp_store_direc..." */ - FePragTyp: - /* ePragTyp: */ U8(39), - FmPragFlg: - /* ePragFlg: */ U8(0x04), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14808, /* "threads" */ - FePragTyp: - /* ePragTyp: */ U8(40), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14816, /* "trusted_schema" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000080)}, - { - FzName:/* zName: */ ts + 14831, /* "user_version" */ - FePragTyp: - /* ePragTyp: */ U8(2), - FmPragFlg: - /* ePragFlg: */ (U8(0x04 | 0x10)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(6)}, - { - FzName:/* zName: */ ts + 14844, /* "wal_autocheckpoi..." */ - FePragTyp: - /* ePragTyp: */ U8(41), - FmPragFlg: - /* ePragFlg: */ U8(0), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14863, /* "wal_checkpoint" */ - FePragTyp: - /* ePragTyp: */ U8(42), - FmPragFlg: - /* ePragFlg: */ U8(0x01), - FiPragCName: - /* ColNames: */ U8(44), - FnPragCName: U8(3), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 14878, /* "writable_schema" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ (uint64(0x00000001 | 0x08000000))}, + { /* zName: */ FzName: ts + 13938, /* "analysis_limit" */ + /* ePragTyp: */ FePragTyp: PragTyp_ANALYSIS_LIMIT, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0}, + { /* zName: */ FzName: ts + 13953, /* "application_id" */ + /* ePragTyp: */ FePragTyp: PragTyp_HEADER_VALUE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_NoColumns1 | PragFlg_Result0)), + /* iArg: */ FiArg: BTREE_APPLICATION_ID}, + { /* zName: */ FzName: ts + 13968, /* "auto_vacuum" */ + /* ePragTyp: */ FePragTyp: PragTyp_AUTO_VACUUM, + /* ePragFlg: */ FmPragFlg: (U8(((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq) | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 13980, /* "automatic_index" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_AutoIndex}, + { /* zName: */ FzName: ts + 13996, /* "busy_timeout" */ + /* ePragTyp: */ FePragTyp: PragTyp_BUSY_TIMEOUT, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0, + /* ColNames: */ FiPragCName: U8(50), FnPragCName: U8(1)}, + { /* zName: */ FzName: ts + 13919, /* "cache_size" */ + /* ePragTyp: */ FePragTyp: PragTyp_CACHE_SIZE, + /* ePragFlg: */ FmPragFlg: (U8(((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq) | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 14009, /* "cache_spill" */ + /* ePragTyp: */ FePragTyp: PragTyp_CACHE_SPILL, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_Result0 | PragFlg_SchemaReq) | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 14021, /* "case_sensitive_l..." */ + /* ePragTyp: */ FePragTyp: PragTyp_CASE_SENSITIVE_LIKE, + /* ePragFlg: */ FmPragFlg: PragFlg_NoColumns}, + { /* zName: */ FzName: ts + 14041, /* "cell_size_check" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_CellSizeCk}, + { /* zName: */ FzName: ts + 14057, /* "checkpoint_fullf..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_CkptFullFSync}, + { /* zName: */ FzName: ts + 14078, /* "collation_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_COLLATION_LIST, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0, + /* ColNames: */ FiPragCName: U8(32), FnPragCName: U8(2)}, + { /* zName: */ FzName: ts + 14093, /* "compile_options" */ + /* ePragTyp: */ FePragTyp: PragTyp_COMPILE_OPTIONS, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0}, + { /* zName: */ FzName: ts + 14109, /* "count_changes" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: (U64((uint64(0x00001))) << 32)}, + { /* zName: */ FzName: ts + 14123, /* "data_version" */ + /* ePragTyp: */ FePragTyp: PragTyp_HEADER_VALUE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_ReadOnly | PragFlg_Result0)), + /* iArg: */ FiArg: BTREE_DATA_VERSION}, + { /* zName: */ FzName: ts + 14136, /* "database_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_DATABASE_LIST, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_NeedSchema | PragFlg_Result0)), + /* ColNames: */ FiPragCName: U8(41), FnPragCName: U8(3)}, + { /* zName: */ FzName: ts + 14150, /* "default_cache_si..." */ + /* ePragTyp: */ FePragTyp: PragTyp_DEFAULT_CACHE_SIZE, + /* ePragFlg: */ FmPragFlg: (U8(((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq) | PragFlg_NoColumns1)), + /* ColNames: */ FiPragCName: U8(49), FnPragCName: U8(1)}, + { /* zName: */ FzName: ts + 14169, /* "defer_foreign_ke..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_DeferFKs}, + { /* zName: */ FzName: ts + 14188, /* "empty_result_cal..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_NullCallback}, + { /* zName: */ FzName: ts + 14211, /* "encoding" */ + /* ePragTyp: */ FePragTyp: PragTyp_ENCODING, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 14220, /* "foreign_key_chec..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FOREIGN_KEY_CHECK, + /* ePragFlg: */ FmPragFlg: (U8(((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_Result1) | PragFlg_SchemaOpt)), + /* ColNames: */ FiPragCName: U8(37), FnPragCName: U8(4)}, + { /* zName: */ FzName: ts + 14238, /* "foreign_key_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_FOREIGN_KEY_LIST, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result1) | PragFlg_SchemaOpt)), FnPragCName: U8(8)}, + { /* zName: */ FzName: ts + 14255, /* "foreign_keys" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_ForeignKeys}, + { /* zName: */ FzName: ts + 14268, /* "freelist_count" */ + /* ePragTyp: */ FePragTyp: PragTyp_HEADER_VALUE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_ReadOnly | PragFlg_Result0))}, + { /* zName: */ FzName: ts + 14283, /* "full_column_name..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_FullColNames}, + { /* zName: */ FzName: ts + 14301, /* "fullfsync" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_FullFSync}, + { /* zName: */ FzName: ts + 14311, /* "function_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_FUNCTION_LIST, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0, + /* ColNames: */ FiPragCName: U8(21), FnPragCName: U8(6)}, + { /* zName: */ FzName: ts + 14325, /* "hard_heap_limit" */ + /* ePragTyp: */ FePragTyp: PragTyp_HARD_HEAP_LIMIT, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0}, + { /* zName: */ FzName: ts + 14341, /* "ignore_check_con..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_IgnoreChecks}, + { /* zName: */ FzName: ts + 14366, /* "incremental_vacu..." */ + /* ePragTyp: */ FePragTyp: PragTyp_INCREMENTAL_VACUUM, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_NeedSchema | PragFlg_NoColumns))}, + { /* zName: */ FzName: ts + 14385, /* "index_info" */ + /* ePragTyp: */ FePragTyp: PragTyp_INDEX_INFO, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result1) | PragFlg_SchemaOpt)), + /* ColNames: */ FiPragCName: U8(15), FnPragCName: U8(3)}, + { /* zName: */ FzName: ts + 14396, /* "index_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_INDEX_LIST, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result1) | PragFlg_SchemaOpt)), + /* ColNames: */ FiPragCName: U8(32), FnPragCName: U8(5)}, + { /* zName: */ FzName: ts + 14407, /* "index_xinfo" */ + /* ePragTyp: */ FePragTyp: PragTyp_INDEX_INFO, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result1) | PragFlg_SchemaOpt)), + /* ColNames: */ FiPragCName: U8(15), FnPragCName: U8(6), + /* iArg: */ FiArg: uint64(1)}, + { /* zName: */ FzName: ts + 14419, /* "integrity_check" */ + /* ePragTyp: */ FePragTyp: PragTyp_INTEGRITY_CHECK, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_Result1))}, + { /* zName: */ FzName: ts + 14435, /* "journal_mode" */ + /* ePragTyp: */ FePragTyp: PragTyp_JOURNAL_MODE, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq))}, + { /* zName: */ FzName: ts + 14448, /* "journal_size_lim..." */ + /* ePragTyp: */ FePragTyp: PragTyp_JOURNAL_SIZE_LIMIT, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_SchemaReq))}, + { /* zName: */ FzName: ts + 14467, /* "legacy_alter_tab..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_LegacyAlter}, + { /* zName: */ FzName: ts + 14486, /* "locking_mode" */ + /* ePragTyp: */ FePragTyp: PragTyp_LOCKING_MODE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_SchemaReq))}, + { /* zName: */ FzName: ts + 14499, /* "max_page_count" */ + /* ePragTyp: */ FePragTyp: PragTyp_PAGE_COUNT, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq))}, + { /* zName: */ FzName: ts + 14514, /* "mmap_size" */ + /* ePragTyp: */ FePragTyp: PragTyp_MMAP_SIZE}, + { /* zName: */ FzName: ts + 14524, /* "module_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_MODULE_LIST, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0, + /* ColNames: */ FiPragCName: U8(9), FnPragCName: U8(1)}, + { /* zName: */ FzName: ts + 14536, /* "optimize" */ + /* ePragTyp: */ FePragTyp: PragTyp_OPTIMIZE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result1 | PragFlg_NeedSchema))}, + { /* zName: */ FzName: ts + 14545, /* "page_count" */ + /* ePragTyp: */ FePragTyp: PragTyp_PAGE_COUNT, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq))}, + { /* zName: */ FzName: ts + 14556, /* "page_size" */ + /* ePragTyp: */ FePragTyp: PragTyp_PAGE_SIZE, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_Result0 | PragFlg_SchemaReq) | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 14566, /* "pragma_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_PRAGMA_LIST, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0, + /* ColNames: */ FiPragCName: U8(9), FnPragCName: U8(1)}, + { /* zName: */ FzName: ts + 14578, /* "query_only" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_QueryOnly}, + { /* zName: */ FzName: ts + 14589, /* "quick_check" */ + /* ePragTyp: */ FePragTyp: PragTyp_INTEGRITY_CHECK, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_Result1))}, + { /* zName: */ FzName: ts + 14601, /* "read_uncommitted" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_ReadUncommit}, + { /* zName: */ FzName: ts + 14618, /* "recursive_trigge..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_RecTriggers}, + { /* zName: */ FzName: ts + 14637, /* "reverse_unordere..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_ReverseOrder}, + { /* zName: */ FzName: ts + 14663, /* "schema_version" */ + /* ePragTyp: */ FePragTyp: PragTyp_HEADER_VALUE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_NoColumns1 | PragFlg_Result0)), + /* iArg: */ FiArg: BTREE_SCHEMA_VERSION}, + { /* zName: */ FzName: ts + 14678, /* "secure_delete" */ + /* ePragTyp: */ FePragTyp: PragTyp_SECURE_DELETE, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0}, + { /* zName: */ FzName: ts + 14692, /* "short_column_nam..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_ShortColNames}, + { /* zName: */ FzName: ts + 14711, /* "shrink_memory" */ + /* ePragTyp: */ FePragTyp: PragTyp_SHRINK_MEMORY, + /* ePragFlg: */ FmPragFlg: PragFlg_NoColumns}, + { /* zName: */ FzName: ts + 14725, /* "soft_heap_limit" */ + /* ePragTyp: */ FePragTyp: PragTyp_SOFT_HEAP_LIMIT, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0}, + { /* zName: */ FzName: ts + 14741, /* "synchronous" */ + /* ePragTyp: */ FePragTyp: PragTyp_SYNCHRONOUS, + /* ePragFlg: */ FmPragFlg: (U8(((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq) | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 14753, /* "table_info" */ + /* ePragTyp: */ FePragTyp: PragTyp_TABLE_INFO, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result1) | PragFlg_SchemaOpt)), + /* ColNames: */ FiPragCName: U8(8), FnPragCName: U8(6)}, + { /* zName: */ FzName: ts + 14764, /* "table_xinfo" */ + /* ePragTyp: */ FePragTyp: PragTyp_TABLE_INFO, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result1) | PragFlg_SchemaOpt)), + /* ColNames: */ FiPragCName: U8(8), FnPragCName: U8(7), + /* iArg: */ FiArg: uint64(1)}, + { /* zName: */ FzName: ts + 14776, /* "temp_store" */ + /* ePragTyp: */ FePragTyp: PragTyp_TEMP_STORE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 14787, /* "temp_store_direc..." */ + /* ePragTyp: */ FePragTyp: PragTyp_TEMP_STORE_DIRECTORY, + /* ePragFlg: */ FmPragFlg: PragFlg_NoColumns1}, + { /* zName: */ FzName: ts + 14808, /* "threads" */ + /* ePragTyp: */ FePragTyp: PragTyp_THREADS, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0}, + { /* zName: */ FzName: ts + 14816, /* "trusted_schema" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_TrustedSchema}, + { /* zName: */ FzName: ts + 14831, /* "user_version" */ + /* ePragTyp: */ FePragTyp: PragTyp_HEADER_VALUE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_NoColumns1 | PragFlg_Result0)), + /* iArg: */ FiArg: BTREE_USER_VERSION}, + { /* zName: */ FzName: ts + 14844, /* "wal_autocheckpoi..." */ + /* ePragTyp: */ FePragTyp: PragTyp_WAL_AUTOCHECKPOINT}, + { /* zName: */ FzName: ts + 14863, /* "wal_checkpoint" */ + /* ePragTyp: */ FePragTyp: PragTyp_WAL_CHECKPOINT, + /* ePragFlg: */ FmPragFlg: PragFlg_NeedSchema, + /* ColNames: */ FiPragCName: U8(44), FnPragCName: U8(3)}, + { /* zName: */ FzName: ts + 14878, /* "writable_schema" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: (uint64(SQLITE_WriteSchema | SQLITE_NoSchemaError))}, } /* sqlite3.c:125260:25 */ // Number of pragmas: 67 on by default, 77 total. @@ -106592,10 +104633,10 @@ func Xsqlite3GetBoolean(tls *libc.TLS, z uintptr, dflt U8) U8 { /* sqlite3.c:125 func getLockingMode(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:125827:12: */ if z != 0 { if 0 == Xsqlite3StrICmp(tls, z, ts+14919 /* "exclusive" */) { - return 1 + return PAGER_LOCKINGMODE_EXCLUSIVE } if 0 == Xsqlite3StrICmp(tls, z, ts+14929 /* "normal" */) { - return 0 + return PAGER_LOCKINGMODE_NORMAL } } return -1 @@ -106608,13 +104649,13 @@ func getLockingMode(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:125827:12: */ func getAutoVacuum(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:125842:12: */ var i int32 if 0 == Xsqlite3StrICmp(tls, z, ts+14936 /* "none" */) { - return 0 + return BTREE_AUTOVACUUM_NONE } if 0 == Xsqlite3StrICmp(tls, z, ts+14941 /* "full" */) { - return 1 + return BTREE_AUTOVACUUM_FULL } if 0 == Xsqlite3StrICmp(tls, z, ts+14946 /* "incremental" */) { - return 2 + return BTREE_AUTOVACUUM_INCR } i = Xsqlite3Atoi(tls, z) return int32(func() uint8 { @@ -106629,8 +104670,8 @@ func getAutoVacuum(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:125842:12: */ // backed temporary databases, 2 for the Red-Black tree in memory database // and 0 to use the compile-time default. func getTempStore(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:125858:12: */ - if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) <= '2') { - return (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) - '0') + if (int32(*(*int8)(unsafe.Pointer(z))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z))) <= '2') { + return (int32(*(*int8)(unsafe.Pointer(z))) - '0') } else if Xsqlite3StrICmp(tls, z, ts+13876 /* "file" */) == 0 { return 1 } else if Xsqlite3StrICmp(tls, z, ts+14958 /* "memory" */) == 0 { @@ -106645,17 +104686,17 @@ func getTempStore(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:125858:12: */ // from default, or when 'file' and the temp_store_directory has changed func invalidateTempStorage(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:125876:12: */ var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpBt != uintptr(0) { - if !(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0) || (Xsqlite3BtreeIsInReadTrans(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpBt) != 0) { + if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpBt != uintptr(0) { + if !(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0) || (Xsqlite3BtreeIsInReadTrans(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpBt) != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+14965 /* "temporary storag..." */, 0) - return 1 + return SQLITE_ERROR } - Xsqlite3BtreeClose(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpBt) - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(1)*32)).FpBt = uintptr(0) + Xsqlite3BtreeClose(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpBt) + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*32)).FpBt = uintptr(0) Xsqlite3ResetAllSchemasOfConnection(tls, db) } - return 0 + return SQLITE_OK } // If the TEMP database is open, close it and mark the database schema @@ -106665,13 +104706,13 @@ func changeTempStorage(tls *libc.TLS, pParse uintptr, zStorageType uintptr) int3 var ts int32 = getTempStore(tls, zStorageType) var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb if int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) == ts { - return 0 + return SQLITE_OK } - if invalidateTempStorage(tls, pParse) != 0 { - return 1 + if invalidateTempStorage(tls, pParse) != SQLITE_OK { + return SQLITE_ERROR } (*Sqlite3)(unsafe.Pointer(db)).Ftemp_store = U8(ts) - return 0 + return SQLITE_OK } // Set result column names for a pragma. @@ -106684,7 +104725,7 @@ func setPragmaResultColumnNames(tls *libc.TLS, v uintptr, pPragma uintptr) { /* return int32(n) }()) if int32(n) == 0 { - Xsqlite3VdbeSetColName(tls, v, 0, 0, (*PragmaName)(unsafe.Pointer(pPragma)).FzName, uintptr(0)) + Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, (*PragmaName)(unsafe.Pointer(pPragma)).FzName, uintptr(0)) } else { var i int32 var j int32 @@ -106695,7 +104736,7 @@ func setPragmaResultColumnNames(tls *libc.TLS, v uintptr, pPragma uintptr) { /* goto __3 } { - Xsqlite3VdbeSetColName(tls, v, i, 0, pragCName[j], uintptr(0)) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, pragCName[j], uintptr(0)) } goto __2 @@ -106714,15 +104755,15 @@ func returnSingleInt(tls *libc.TLS, v uintptr, value I64) { /* sqlite3.c:125932: defer tls.Free(8) *(*I64)(unsafe.Pointer(bp)) = value - Xsqlite3VdbeAddOp4Dup8(tls, v, 70, 0, 1, 0, bp /* &value */, -14) - Xsqlite3VdbeAddOp2(tls, v, 80, 1, 1) + Xsqlite3VdbeAddOp4Dup8(tls, v, OP_Int64, 0, 1, 0, bp /* &value */, -14) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 1) } // Generate code to return a single text value. func returnSingleText(tls *libc.TLS, v uintptr, zValue uintptr) { /* sqlite3.c:125940:13: */ if zValue != 0 { Xsqlite3VdbeLoadString(tls, v, 1, zValue) - Xsqlite3VdbeAddOp2(tls, v, 80, 1, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 1) } } @@ -106736,7 +104777,7 @@ func setAllPagerFlags(tls *libc.TLS, db uintptr) { /* sqlite3.c:125956:13: */ for (libc.PostDecInt32(&n, 1)) > 0 { if (*Db)(unsafe.Pointer(pDb)).FpBt != 0 { Xsqlite3BtreeSetPagerFlags(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, - (uint32(U64((*Db)(unsafe.Pointer(pDb)).Fsafety_level) | ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x38))))) + (uint32(U64((*Db)(unsafe.Pointer(pDb)).Fsafety_level) | ((*Sqlite3)(unsafe.Pointer(db)).Fflags & PAGER_FLAGS_MASK)))) } pDb += 32 } @@ -106747,16 +104788,16 @@ func setAllPagerFlags(tls *libc.TLS, db uintptr) { /* sqlite3.c:125956:13: */ func actionName(tls *libc.TLS, action U8) uintptr { /* sqlite3.c:125984:19: */ var zName uintptr switch int32(action) { - case 8: + case OE_SetNull: zName = ts + 15027 /* "SET NULL" */ break - case 9: + case OE_SetDflt: zName = ts + 15036 /* "SET DEFAULT" */ break - case 10: + case OE_Cascade: zName = ts + 15048 /* "CASCADE" */ break - case 7: + case OE_Restrict: zName = ts + 15056 /* "RESTRICT" */ break default: @@ -106819,7 +104860,7 @@ func pragmaFunclistLine(tls *libc.TLS, v uintptr, p uintptr, isBuiltin int32, sh if (*FuncDef)(unsafe.Pointer(p)).FxSFunc == uintptr(0) { continue } - if (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & U32(0x00040000)) != U32(0)) && + if (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & SQLITE_FUNC_INTERNAL) != U32(0)) && (showInternFuncs == 0) { continue } @@ -106832,14 +104873,14 @@ func pragmaFunclistLine(tls *libc.TLS, v uintptr, p uintptr, isBuiltin int32, sh } Xsqlite3VdbeMultiLoad(tls, v, 1, ts+15113, /* "sissii" */ libc.VaList(bp, (*FuncDef)(unsafe.Pointer(p)).FzName, isBuiltin, - zType, azEnc[((*FuncDef)(unsafe.Pointer(p)).FfuncFlags&U32(0x0003))], + zType, azEnc[((*FuncDef)(unsafe.Pointer(p)).FfuncFlags&SQLITE_FUNC_ENCMASK)], int32((*FuncDef)(unsafe.Pointer(p)).FnArg), - (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags&mask)^U32(0x000200000)))) + (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags&mask)^SQLITE_INNOCUOUS))) } } -var mask U32 = (U32((((0x000000800 | 0x000080000) | 0x000100000) | 0x000200000) | 0x00040000)) /* sqlite3.c:126055:22 */ -var azEnc = [4]uintptr{uintptr(0), ts + 15120 /* "utf8" */, ts + 15125 /* "utf16le" */, ts + 15133 /* "utf16be" */} /* sqlite3.c:126062:23 */ +var mask U32 = (U32((((SQLITE_DETERMINISTIC | SQLITE_DIRECTONLY) | SQLITE_SUBTYPE) | SQLITE_INNOCUOUS) | SQLITE_FUNC_INTERNAL)) /* sqlite3.c:126055:22 */ +var azEnc = [4]uintptr{uintptr(0), ts + 15120 /* "utf8" */, ts + 15125 /* "utf16le" */, ts + 15133 /* "utf16be" */} /* sqlite3.c:126062:23 */ // Helper subroutine for PRAGMA integrity_check: // @@ -106848,10 +104889,10 @@ var azEnc = [4]uintptr{uintptr(0), ts + 15120 /* "utf8" */, ts + 15125 /* "utf16 // and halt if the maximum number of result rows have been issued. func integrityCheckResultRow(tls *libc.TLS, v uintptr) int32 { /* sqlite3.c:126099:12: */ var addr int32 - Xsqlite3VdbeAddOp2(tls, v, 80, 3, 1) - addr = Xsqlite3VdbeAddOp3(tls, v, 48, 1, (Xsqlite3VdbeCurrentAddr(tls, v) + 2), 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 3, 1) + addr = Xsqlite3VdbeAddOp3(tls, v, OP_IfPos, 1, (Xsqlite3VdbeCurrentAddr(tls, v) + 2), 1) - Xsqlite3VdbeAddOp0(tls, v, 68) + Xsqlite3VdbeAddOp0(tls, v, OP_Halt) return addr } @@ -107113,7 +105154,7 @@ __6: } else { zDb = uintptr(0) } - if !(Xsqlite3AuthCheck(tls, pParse, 19, zLeft, zRight, zDb) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) != 0) { goto __7 } goto pragma_out @@ -107134,30 +105175,30 @@ __7: // second element of the array is the name of the pragma and the third // element is the argument to the pragma or NULL if the pragma has no // argument. - *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + uintptr(0)*8)) = uintptr(0) - *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + uintptr(1)*8)) = zLeft - *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + uintptr(2)*8)) = zRight - *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + uintptr(3)*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + 1*8)) = zLeft + *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + 2*8)) = zRight + *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + 3*8)) = uintptr(0) (*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 - rc = Xsqlite3_file_control(tls, db, zDb, 14, bp+368 /* aFcntl */) - if !(rc == 0) { + rc = Xsqlite3_file_control(tls, db, zDb, SQLITE_FCNTL_PRAGMA, bp+368 /* aFcntl */) + if !(rc == SQLITE_OK) { goto __8 } Xsqlite3VdbeSetNumCols(tls, v, 1) - Xsqlite3VdbeSetColName(tls, v, 0, 0, *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + uintptr(0)*8)), libc.UintptrFromInt32(-1)) - returnSingleText(tls, v, *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + uintptr(0)*8))) - Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + uintptr(0)*8))) + Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */)), libc.UintptrFromInt32(-1)) + returnSingleText(tls, v, *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */))) + Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */))) goto pragma_out __8: ; - if !(rc != 12) { + if !(rc != SQLITE_NOTFOUND) { goto __9 } - if !(*(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + uintptr(0)*8)) != 0) { + if !(*(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */)) != 0) { goto __10 } - Xsqlite3ErrorMsg(tls, pParse, ts+2690 /* "%s" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + uintptr(0)*8)))) - Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */ + uintptr(0)*8))) + Xsqlite3ErrorMsg(tls, pParse, ts+2690 /* "%s" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */)))) + Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 368 /* &aFcntl[0] */))) __10: ; (*Parse)(unsafe.Pointer(pParse)).FnErr++ @@ -107176,7 +105217,7 @@ __11: ; // Make sure the database schema is loaded if the pragma requires that - if !((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & 0x01) != 0) { + if !((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & PragFlg_NeedSchema) != 0) { goto __12 } if !(Xsqlite3ReadSchema(tls, pParse) != 0) { @@ -107189,8 +105230,8 @@ __12: ; // Register the result column names for pragmas that return results - if !(((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & 0x02) == 0) && - (((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & 0x04) == 0) || (zRight == uintptr(0)))) { + if !(((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & PragFlg_NoColumns) == 0) && + (((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & PragFlg_NoColumns1) == 0) || (zRight == uintptr(0)))) { goto __14 } setPragmaResultColumnNames(tls, v, pPragma) @@ -107214,7 +105255,7 @@ __14: // is always on by default regardless of the sign of the default cache // size. But continue to take the absolute value of the default cache // size of historical compatibility. - case 13: + case PragTyp_DEFAULT_CACHE_SIZE: goto __16 // PRAGMA [schema.]page_size @@ -107224,7 +105265,7 @@ __14: // database page size in bytes. The second form sets the // database page size value. The value can only be set if // the database has not yet been created. - case 31: + case PragTyp_PAGE_SIZE: goto __17 // PRAGMA [schema.]secure_delete @@ -107233,7 +105274,7 @@ __14: // The first form reports the current setting for the // secure_delete flag. The second form changes the secure_delete // flag setting and reports the new value. - case 33: + case PragTyp_SECURE_DELETE: goto __18 // PRAGMA [schema.]max_page_count @@ -107251,25 +105292,25 @@ __14: // PRAGMA [schema.]page_count // // Return the number of pages in the specified database. - case 27: + case PragTyp_PAGE_COUNT: goto __19 // PRAGMA [schema.]locking_mode // PRAGMA [schema.]locking_mode = (normal|exclusive) - case 26: + case PragTyp_LOCKING_MODE: goto __20 // PRAGMA [schema.]journal_mode // PRAGMA [schema.]journal_mode = // (delete|persist|off|truncate|memory|wal|off) - case 23: + case PragTyp_JOURNAL_MODE: goto __21 // PRAGMA [schema.]journal_size_limit // PRAGMA [schema.]journal_size_limit=N // // Get or set the size limit on rollback journal files. - case 24: + case PragTyp_JOURNAL_SIZE_LIMIT: goto __22 // PRAGMA [schema.]auto_vacuum @@ -107277,13 +105318,13 @@ __14: // // Get or set the value of the database 'auto-vacuum' parameter. // The value is one of: 0 NONE 1 FULL 2 INCREMENTAL - case 3: + case PragTyp_AUTO_VACUUM: goto __23 // PRAGMA [schema.]incremental_vacuum(N) // // Do N steps of incremental vacuuming on a database. - case 19: + case PragTyp_INCREMENTAL_VACUUM: goto __24 // PRAGMA [schema.]cache_size @@ -107295,7 +105336,7 @@ __14: // number of pages in the cache. If N is negative, then the // number of pages is adjusted so that the cache uses -N kibibytes // of memory. - case 6: + case PragTyp_CACHE_SIZE: goto __25 // PRAGMA [schema.]cache_spill @@ -107318,7 +105359,7 @@ __14: // // The cache_spill=BOOLEAN setting applies to all attached schemas, // not just the schema specified. - case 7: + case PragTyp_CACHE_SPILL: goto __26 // PRAGMA [schema.]mmap_size(N) @@ -107333,7 +105374,7 @@ __14: // This value is advisory. The underlying VFS is free to memory map // as little or as much as it wants. Except, if N is set to 0 then the // upper layers will never invoke the xFetch interfaces to the VFS. - case 28: + case PragTyp_MMAP_SIZE: goto __27 // PRAGMA temp_store @@ -107345,7 +105386,7 @@ __14: // // Note that it is possible for the library compile-time options to // override this setting - case 38: + case PragTyp_TEMP_STORE: goto __28 // PRAGMA temp_store_directory @@ -107356,7 +105397,7 @@ __14: // Setting to a null string reverts to the default temporary directory search. // If temporary directory is changed, then invalidateTempStorage. // - case 39: + case PragTyp_TEMP_STORE_DIRECTORY: goto __29 // PRAGMA [schema.]synchronous @@ -107366,10 +105407,10 @@ __14: // the local value does not make changes to the disk file and the // default value will be restored the next time the database is // opened. - case 36: + case PragTyp_SYNCHRONOUS: goto __30 - case 4: + case PragTyp_FLAG: goto __31 // PRAGMA table_info(
    ) @@ -107383,39 +105424,39 @@ __14: // notnull: True if 'NOT NULL' is part of column declaration // dflt_value: The default value for the column, if any. // pk: Non-zero for PK fields. - case 37: + case PragTyp_TABLE_INFO: goto __32 - case 20: + case PragTyp_INDEX_INFO: goto __33 - case 21: + case PragTyp_INDEX_LIST: goto __34 - case 12: + case PragTyp_DATABASE_LIST: goto __35 - case 9: + case PragTyp_COLLATION_LIST: goto __36 - case 17: + case PragTyp_FUNCTION_LIST: goto __37 - case 29: + case PragTyp_MODULE_LIST: goto __38 - case 32: + case PragTyp_PRAGMA_LIST: goto __39 - case 16: + case PragTyp_FOREIGN_KEY_LIST: goto __40 - case 15: + case PragTyp_FOREIGN_KEY_CHECK: goto __41 // Reinstall the LIKE and GLOB functions. The variant of LIKE // used will be case sensitive or not depending on the RHS. - case 8: + case PragTyp_CASE_SENSITIVE_LIKE: goto __42 // PRAGMA integrity_check @@ -107441,7 +105482,7 @@ __14: // schema, use the form: // // PRAGMA schema.integrity_check; - case 22: + case PragTyp_INTEGRITY_CHECK: goto __43 // PRAGMA encoding @@ -107464,7 +105505,7 @@ __14: // In the second form this pragma sets the text encoding to be used in // new database files created using this database handle. It is only // useful if invoked immediately after the main database i - case 14: + case PragTyp_ENCODING: goto __44 // PRAGMA [schema.]schema_version @@ -107497,20 +105538,20 @@ __14: // // The user-version is not used internally by SQLite. It may be used by // applications for any purpose. - case 2: + case PragTyp_HEADER_VALUE: goto __45 // PRAGMA compile_options // // Return the names of all compile-time options used in this build, // one option per row. - case 10: + case PragTyp_COMPILE_OPTIONS: goto __46 // PRAGMA [schema.]wal_checkpoint = passive|full|restart|truncate // // Checkpoint the database. - case 42: + case PragTyp_WAL_CHECKPOINT: goto __47 // PRAGMA wal_autocheckpoint @@ -107519,7 +105560,7 @@ __14: // Configure a database connection to automatically checkpoint a database // after accumulating N frames in the log. Or query for the current value // of N. - case 41: + case PragTyp_WAL_AUTOCHECKPOINT: goto __48 // PRAGMA shrink_memory @@ -107527,7 +105568,7 @@ __14: // IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database // connection on which it is invoked to free up as much memory as it // can, by calling sqlite3_db_release_memory(). - case 34: + case PragTyp_SHRINK_MEMORY: goto __49 // PRAGMA optimize @@ -107582,7 +105623,7 @@ __14: // // The rules for when tables are analyzed are likely to change in // future releases. - case 30: + case PragTyp_OPTIMIZE: goto __50 // PRAGMA busy_timeout @@ -107605,7 +105646,7 @@ __14: // IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always // returns the same integer that would be returned by the // sqlite3_soft_heap_limit64(-1) C-language function. - case 35: + case PragTyp_SOFT_HEAP_LIMIT: goto __52 // PRAGMA hard_heap_limit @@ -107617,7 +105658,7 @@ __14: // sqlite3_hard_heap_limit64() C-language API can raise or deactivate // the hard heap limit. This allows an application to set a heap limit // constraint that cannot be relaxed by an untrusted SQL script. - case 18: + case PragTyp_HARD_HEAP_LIMIT: goto __53 // PRAGMA threads @@ -107625,7 +105666,7 @@ __14: // // Configure the maximum number of worker threads. Return the new // maximum, which might be less than requested. - case 40: + case PragTyp_THREADS: goto __54 // PRAGMA analysis_limit @@ -107633,7 +105674,7 @@ __14: // // Configure the maximum number of rows that ANALYZE will examine // in each index that it looks at. Return the new limit. - case 1: + case PragTyp_ANALYSIS_LIMIT: goto __55 } goto __15 @@ -107666,14 +105707,14 @@ __16: goto __15 __58: ; - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*24)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(1)*24)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(6)*24)).Fp1 = -2000 + (*VdbeOp)(unsafe.Pointer(aOp)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp + 1*24)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp + 6*24)).Fp1 = -2000 goto __57 __56: size = Xsqlite3AbsInt32(tls, Xsqlite3Atoi(tls, zRight)) Xsqlite3BeginWriteOperation(tls, pParse, 0, iDb) - Xsqlite3VdbeAddOp3(tls, v, 94, iDb, 3, size) + Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, size) (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size Xsqlite3BtreeSetCacheSize(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size) @@ -107705,7 +105746,7 @@ __59: // Malloc may fail when setting the page-size, as there is an internal // buffer that the pager module resizes using sqlite3_realloc(). (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize = Xsqlite3Atoi(tls, zRight) - if !(7 == Xsqlite3BtreeSetPageSize(tls, pBt, (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0)) { + if !(SQLITE_NOMEM == Xsqlite3BtreeSetPageSize(tls, pBt, (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0)) { goto __61 } Xsqlite3OomFault(tls, db) @@ -107780,10 +105821,10 @@ __19: *(*I64)(unsafe.Pointer(bp + 400 /* x */)) = int64(0) Xsqlite3CodeVerifySchema(tls, pParse, iDb) iReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - if !((int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(zLeft + uintptr(0))))])) == 'p') { + if !((int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(zLeft)))])) == 'p') { goto __69 } - Xsqlite3VdbeAddOp2(tls, v, 168, iDb, iReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Pagecount, iDb, iReg) goto __70 __69: if !((zRight != 0) && (Xsqlite3DecOrHexToI64(tls, zRight, bp+400 /* &x */) == 0)) { @@ -107808,10 +105849,10 @@ __71: *(*I64)(unsafe.Pointer(bp + 400 /* x */)) = int64(0) __72: ; - Xsqlite3VdbeAddOp3(tls, v, 169, iDb, iReg, int32(*(*I64)(unsafe.Pointer(bp + 400 /* x */)))) + Xsqlite3VdbeAddOp3(tls, v, OP_MaxPgcnt, iDb, iReg, int32(*(*I64)(unsafe.Pointer(bp + 400 /* x */)))) __70: ; - Xsqlite3VdbeAddOp2(tls, v, 80, iReg, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, iReg, 1) goto __15 // PRAGMA [schema.]locking_mode @@ -107855,7 +105896,7 @@ __78: __77: ; - if !(eMode == 1) { + if !(eMode == PAGER_LOCKINGMODE_EXCLUSIVE) { goto __82 } zRet = ts + 14919 /* "exclusive" */ @@ -107904,7 +105945,7 @@ __87: eMode1 = -1 __89: ; - if !((eMode1 == 2) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x10000000)) != uint64(0))) { + if !((eMode1 == PAGER_JOURNALMODE_OFF) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_Defensive) != uint64(0))) { goto __90 } // Do not allow journal-mode "OFF" in defensive since the database @@ -107931,7 +105972,7 @@ __92: goto __95 } Xsqlite3VdbeUsesBtree(tls, v, ii2) - Xsqlite3VdbeAddOp3(tls, v, 7, ii2, 1, eMode1) + Xsqlite3VdbeAddOp3(tls, v, OP_JournalMode, ii2, 1, eMode1) __95: ; goto __93 @@ -107941,7 +105982,7 @@ __93: goto __94 __94: ; - Xsqlite3VdbeAddOp2(tls, v, 80, 1, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 1) goto __15 // PRAGMA [schema.]journal_size_limit @@ -107989,7 +106030,7 @@ __98: // creates the database file. It is important that it is created // as an auto-vacuum capable db. rc = Xsqlite3BtreeSetAutoVacuum(tls, pBt2, eAuto) - if !((rc == 0) && ((eAuto == 1) || (eAuto == 2))) { + if !((rc == SQLITE_OK) && ((eAuto == 1) || (eAuto == 2))) { goto __100 } iAddr = Xsqlite3VdbeCurrentAddr(tls, v) @@ -108001,11 +106042,11 @@ __98: goto __15 __101: ; - (*VdbeOp)(unsafe.Pointer(aOp1 + uintptr(0)*24)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp1 + uintptr(1)*24)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp1 + uintptr(2)*24)).Fp2 = (iAddr + 4) - (*VdbeOp)(unsafe.Pointer(aOp1 + uintptr(4)*24)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp1 + uintptr(4)*24)).Fp3 = (eAuto - 1) + (*VdbeOp)(unsafe.Pointer(aOp1)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp1 + 1*24)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp1 + 2*24)).Fp2 = (iAddr + 4) + (*VdbeOp)(unsafe.Pointer(aOp1 + 4*24)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp1 + 4*24)).Fp3 = (eAuto - 1) Xsqlite3VdbeUsesBtree(tls, v, iDb) __100: ; @@ -108024,11 +106065,11 @@ __24: __102: ; Xsqlite3BeginWriteOperation(tls, pParse, 0, iDb) - Xsqlite3VdbeAddOp2(tls, v, 69, *(*int32)(unsafe.Pointer(bp + 416 /* iLimit1 */)), 1) - addr = Xsqlite3VdbeAddOp1(tls, v, 60, iDb) - Xsqlite3VdbeAddOp1(tls, v, 80, 1) - Xsqlite3VdbeAddOp2(tls, v, 82, 1, -1) - Xsqlite3VdbeAddOp2(tls, v, 48, 1, addr) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, *(*int32)(unsafe.Pointer(bp + 416 /* iLimit1 */)), 1) + addr = Xsqlite3VdbeAddOp1(tls, v, OP_IncrVacuum, iDb) + Xsqlite3VdbeAddOp1(tls, v, OP_ResultRow, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, 1, -1) + Xsqlite3VdbeAddOp2(tls, v, OP_IfPos, 1, addr) Xsqlite3VdbeJumpHere(tls, v, addr) goto __15 @@ -108083,7 +106124,7 @@ __26: } returnSingleInt(tls, v, func() int64 { - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000020)) == uint64(0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_CacheSpill) == uint64(0) { return int64(0) } return int64(Xsqlite3BtreeSetSpillSize(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, 0)) @@ -108100,10 +106141,10 @@ __107: if !(Xsqlite3GetBoolean(tls, zRight, (uint8(libc.Bool32(*(*int32)(unsafe.Pointer(bp + 420 /* size3 */)) != 0)))) != 0) { goto __108 } - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(0x00000020)) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (SQLITE_CacheSpill) goto __109 __108: - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x00000020))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_CacheSpill)) __109: ; setAllPagerFlags(tls, db) @@ -108162,14 +106203,14 @@ __115: __110: ; *(*Sqlite3_int64)(unsafe.Pointer(bp + 424 /* sz */)) = int64(-1) - rc = Xsqlite3_file_control(tls, db, zDb, 18, bp+424 /* &sz */) - if !(rc == 0) { + rc = Xsqlite3_file_control(tls, db, zDb, SQLITE_FCNTL_MMAP_SIZE, bp+424 /* &sz */) + if !(rc == SQLITE_OK) { goto __117 } returnSingleInt(tls, v, *(*Sqlite3_int64)(unsafe.Pointer(bp + 424 /* sz */))) goto __118 __117: - if !(rc != 12) { + if !(rc != SQLITE_NOTFOUND) { goto __119 } (*Parse)(unsafe.Pointer(pParse)).FnErr++ @@ -108216,11 +106257,11 @@ __29: returnSingleText(tls, v, Xsqlite3_temp_directory) goto __123 __122: - if !(*(*int8)(unsafe.Pointer(zRight + uintptr(0))) != 0) { + if !(*(*int8)(unsafe.Pointer(zRight)) != 0) { goto __124 } - rc = Xsqlite3OsAccess(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, zRight, 1, bp+432 /* &res */) - if !((rc != 0) || (*(*int32)(unsafe.Pointer(bp + 432 /* res */)) == 0)) { + rc = Xsqlite3OsAccess(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, zRight, SQLITE_ACCESS_READWRITE, bp+432 /* &res */) + if !((rc != SQLITE_OK) || (*(*int32)(unsafe.Pointer(bp + 432 /* res */)) == 0)) { goto __125 } Xsqlite3ErrorMsg(tls, pParse, ts+15150 /* "not a writable d..." */, 0) @@ -108229,16 +106270,16 @@ __125: ; __124: ; - if !(((1 == 0) || - ((1 == 1) && (int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) <= 1))) || - ((1 == 2) && (int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) == 1))) { + if !(((SQLITE_TEMP_STORE == 0) || + ((SQLITE_TEMP_STORE == 1) && (int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) <= 1))) || + ((SQLITE_TEMP_STORE == 2) && (int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) == 1))) { goto __126 } invalidateTempStorage(tls, pParse) __126: ; Xsqlite3_free(tls, Xsqlite3_temp_directory) - if !(*(*int8)(unsafe.Pointer(zRight + uintptr(0))) != 0) { + if !(*(*int8)(unsafe.Pointer(zRight)) != 0) { goto __127 } Xsqlite3_temp_directory = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp+16, zRight)) @@ -108275,7 +106316,7 @@ __131: if !(iDb != 1) { goto __133 } - iLevel = ((int32(getSafetyLevel(tls, zRight, 0, uint8(1))) + 1) & 0x07) + iLevel = ((int32(getSafetyLevel(tls, zRight, 0, uint8(1))) + 1) & PAGER_SYNCHRONOUS_MASK) if !(iLevel == 0) { goto __134 } @@ -108307,7 +106348,7 @@ __135: } // Foreign key support may not be enabled or disabled while not // in auto-commit mode. - mask = mask & (^libc.Uint64FromInt32(0x00004000)) + mask = mask & (libc.Uint64FromInt32(libc.CplInt32(SQLITE_ForeignKeys))) __137: ; @@ -108318,7 +106359,7 @@ __137: goto __139 __138: *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^mask) - if !(mask == uint64(0x00080000)) { + if !(mask == SQLITE_DeferFKs) { goto __140 } (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = int64(0) @@ -108330,7 +106371,7 @@ __139: // Many of the flag-pragmas modify the code generated by the SQL // compiler (eg. count_changes). So add an opcode to expire all // compiled SQL statements after modifying a pragma value. - Xsqlite3VdbeAddOp0(tls, v, 158) + Xsqlite3VdbeAddOp0(tls, v, OP_Expire) setAllPagerFlags(tls, db) __136: ; @@ -108352,7 +106393,7 @@ __32: goto __141 } Xsqlite3CodeVerifyNamedSchema(tls, pParse, zDb) - pTab = Xsqlite3LocateTable(tls, pParse, uint32(0x02), zRight, zDb) + pTab = Xsqlite3LocateTable(tls, pParse, LOCATE_NOERR, zRight, zDb) if !(pTab != 0) { goto __142 } @@ -108367,7 +106408,7 @@ __143: goto __145 } isHidden = 0 - if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0062) != 0) { + if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_NOINSERT) != 0) { goto __146 } if !((*PragmaName)(unsafe.Pointer(pPragma)).FiArg == uint64(0)) { @@ -108377,13 +106418,13 @@ __143: goto __144 __147: ; - if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0020) != 0) { + if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_VIRTUAL) != 0) { goto __148 } isHidden = 2 // GENERATED ALWAYS AS ... VIRTUAL goto __149 __148: - if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0040) != 0) { + if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_STORED) != 0) { goto __150 } isHidden = 3 // GENERATED ALWAYS AS ... STORED @@ -108397,7 +106438,7 @@ __149: ; __146: ; - if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0001) == 0) { + if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_PRIMKEY) == 0) { goto __152 } k = 0 @@ -108474,8 +106515,8 @@ __33: // If there is no index named zRight, check to see if there is a // WITHOUT ROWID table named zRight, and if there is, show the // structure of the PRIMARY KEY index for that table. - pTab1 = Xsqlite3LocateTable(tls, pParse, uint32(0x02), zRight, zDb) - if !((pTab1 != 0) && !(((*Table)(unsafe.Pointer((pTab1))).FtabFlags & U32(0x0080)) == U32(0))) { + pTab1 = Xsqlite3LocateTable(tls, pParse, LOCATE_NOERR, zRight, zDb) + if !((pTab1 != 0) && !(((*Table)(unsafe.Pointer((pTab1))).FtabFlags & TF_WithoutRowid) == U32(0))) { goto __161 } pIdx = Xsqlite3PrimaryKeyIndex(tls, pTab1) @@ -108525,7 +106566,7 @@ __165: (libc.Bool32(i1 < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol))))) __168: ; - Xsqlite3VdbeAddOp2(tls, v, 80, 1, (*Parse)(unsafe.Pointer(pParse)).FnMem) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, (*Parse)(unsafe.Pointer(pParse)).FnMem) goto __166 __166: i1++ @@ -108560,7 +106601,7 @@ __171: Xsqlite3VdbeMultiLoad(tls, v, 1, ts+15257, /* "isisi" */ libc.VaList(bp+128, i2, (*Index)(unsafe.Pointer(pIdx1)).FzName, - (libc.Bool32(int32((*Index)(unsafe.Pointer((pIdx1))).FonError) != 0)), + (libc.Bool32(int32((*Index)(unsafe.Pointer((pIdx1))).FonError) != OE_None)), *(*uintptr)(unsafe.Pointer(bp + 440 /* &azOrigin[0] */ + uintptr((uint32(int32(*(*uint16)(unsafe.Pointer(pIdx1 + 100 /* &.idxType */))&0x3>>0))))*8)), (libc.Bool32((*Index)(unsafe.Pointer(pIdx1)).FpPartIdxWhere != uintptr(0))))) goto __172 @@ -108626,11 +106667,11 @@ __180: goto __15 __37: - showInternFunc = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0020)) != U32(0))) + showInternFunc = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_InternalFunc) != U32(0))) (*Parse)(unsafe.Pointer(pParse)).FnMem = 6 i5 = 0 __181: - if !(i5 < 23) { + if !(i5 < SQLITE_FUNC_HASH_SZ) { goto __183 } p1 = *(*uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3BuiltinFunctions)) /* &.a */) + uintptr(i5)*8)) @@ -108737,8 +106778,8 @@ __201: (*FKey)(unsafe.Pointer(pFK)).FzTo, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab3)).FaCol+uintptr((*sColMap)(unsafe.Pointer((pFK+64 /* &.aCol */)+uintptr(j2)*16)).FiFrom)*32)).FzName, (*sColMap)(unsafe.Pointer((pFK+64 /* &.aCol */)+uintptr(j2)*16)).FzCol, - actionName(tls, *(*U8)(unsafe.Pointer((pFK + 45 /* &.aAction */) + uintptr(1)))), // ON UPDATE - actionName(tls, *(*U8)(unsafe.Pointer((pFK + 45 /* &.aAction */) + uintptr(0)))), // ON DELETE + actionName(tls, *(*U8)(unsafe.Pointer((pFK + 45 /* &.aAction */) + 1))), // ON UPDATE + actionName(tls, *(*U8)(unsafe.Pointer((pFK + 45 /* &.aAction */)))), // ON DELETE ts+15279 /* "NONE" */)) goto __202 __202: @@ -108798,7 +106839,7 @@ __208: (*Parse)(unsafe.Pointer(pParse)).FnMem = (int32((*Table)(unsafe.Pointer(pTab4)).FnCol) + regRow) __209: ; - Xsqlite3OpenTable(tls, pParse, 0, iDb, pTab4, 96) + Xsqlite3OpenTable(tls, pParse, 0, iDb, pTab4, OP_OpenRead) Xsqlite3VdbeLoadString(tls, v, regResult, (*Table)(unsafe.Pointer(pTab4)).FzName) i8 = 1 pFK1 = (*Table)(unsafe.Pointer(pTab4)).FpFKey @@ -108822,10 +106863,10 @@ __213: if !(*(*uintptr)(unsafe.Pointer(bp + 464 /* pIdx2 */)) == uintptr(0)) { goto __216 } - Xsqlite3OpenTable(tls, pParse, i8, iDb, pParent, 96) + Xsqlite3OpenTable(tls, pParse, i8, iDb, pParent, OP_OpenRead) goto __217 __216: - Xsqlite3VdbeAddOp3(tls, v, 96, i8, int32((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 464 /* pIdx2 */)))).Ftnum), iDb) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, i8, int32((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 464 /* pIdx2 */)))).Ftnum), iDb) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 464 /* pIdx2 */))) __217: ; @@ -108856,7 +106897,7 @@ __218: (*Parse)(unsafe.Pointer(pParse)).FnTab = i8 __219: ; - addrTop = Xsqlite3VdbeAddOp1(tls, v, 37, 0) + addrTop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, 0) i8 = 1 pFK1 = (*Table)(unsafe.Pointer(pTab4)).FpFKey __220: @@ -108890,7 +106931,7 @@ __224: iCol = (*sColMap)(unsafe.Pointer((pFK1 + 64 /* &.aCol */) + uintptr(j3)*16)).FiFrom } Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab4, 0, iCol, (regRow + j3)) - Xsqlite3VdbeAddOp2(tls, v, 50, (regRow + j3), addrOk) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (regRow + j3), addrOk) goto __225 __225: j3++ @@ -108904,9 +106945,9 @@ __226: if !(*(*uintptr)(unsafe.Pointer(bp + 464 /* pIdx2 */)) != 0) { goto __227 } - Xsqlite3VdbeAddOp4(tls, v, 91, regRow, (*FKey)(unsafe.Pointer(pFK1)).FnCol, regKey, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regRow, (*FKey)(unsafe.Pointer(pFK1)).FnCol, regKey, Xsqlite3IndexAffinityStr(tls, db, *(*uintptr)(unsafe.Pointer(bp + 464 /* pIdx2 */))), (*FKey)(unsafe.Pointer(pFK1)).FnCol) - Xsqlite3VdbeAddOp4Int(tls, v, 30, i8, addrOk, regKey, 0) + Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, i8, addrOk, regKey, 0) goto __228 __227: @@ -108914,7 +106955,7 @@ __227: goto __229 } jmp = (Xsqlite3VdbeCurrentAddr(tls, v) + 2) - Xsqlite3VdbeAddOp3(tls, v, 31, i8, jmp, regRow) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, i8, jmp, regRow) Xsqlite3VdbeGoto(tls, v, addrOk) __229: @@ -108923,17 +106964,17 @@ __228: ; // Generate code to report an FK violation to the caller. - if !(((*Table)(unsafe.Pointer((pTab4))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab4))).FtabFlags & TF_WithoutRowid) == U32(0)) { goto __230 } - Xsqlite3VdbeAddOp2(tls, v, 127, 0, (regResult + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, 0, (regResult + 1)) goto __231 __230: - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (regResult + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (regResult + 1)) __231: ; Xsqlite3VdbeMultiLoad(tls, v, (regResult + 2), ts+15284 /* "siX" */, libc.VaList(bp+288, (*FKey)(unsafe.Pointer(pFK1)).FzTo, (i8-1))) - Xsqlite3VdbeAddOp2(tls, v, 80, regResult, 4) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, regResult, 4) Xsqlite3VdbeResolveLabel(tls, v, addrOk) Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 472 /* aiCols */))) goto __221 @@ -108944,7 +106985,7 @@ __221: goto __222 __222: ; - Xsqlite3VdbeAddOp2(tls, v, 5, 0, (addrTop + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, 0, (addrTop + 1)) Xsqlite3VdbeJumpHere(tls, v, addrTop) goto __204 __205: @@ -108990,7 +107031,7 @@ __232: __43: pObjTab = uintptr(0) // Check only this one table, if not NULL - isQuick = (libc.Bool32((int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(zLeft + uintptr(0))))])) == 'q')) + isQuick = (libc.Bool32((int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(zLeft)))])) == 'q')) // If the PRAGMA command was of the form "PRAGMA .integrity_check", // then iDb is set to the index of the database identified by . @@ -109013,7 +107054,7 @@ __233: (*Parse)(unsafe.Pointer(pParse)).FnMem = 6 // Set the maximum error count - *(*int32)(unsafe.Pointer(bp + 480 /* mxErr */)) = 100 + *(*int32)(unsafe.Pointer(bp + 480 /* mxErr */)) = SQLITE_INTEGRITY_CHECK_ERROR_MAX if !(zRight != 0) { goto __234 } @@ -109023,7 +107064,7 @@ __233: if !(*(*int32)(unsafe.Pointer(bp + 480 /* mxErr */)) <= 0) { goto __237 } - *(*int32)(unsafe.Pointer(bp + 480 /* mxErr */)) = 100 + *(*int32)(unsafe.Pointer(bp + 480 /* mxErr */)) = SQLITE_INTEGRITY_CHECK_ERROR_MAX __237: ; goto __236 @@ -109039,7 +107080,7 @@ __236: ; __234: ; - Xsqlite3VdbeAddOp2(tls, v, 69, (*(*int32)(unsafe.Pointer(bp + 480 /* mxErr */)) - 1), 1) // reg[1] holds errors left + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, (*(*int32)(unsafe.Pointer(bp + 480 /* mxErr */)) - 1), 1) // reg[1] holds errors left // Do an integrity check on each database file i9 = 0 @@ -109084,7 +107125,7 @@ __243: goto __244 __246: ; - if !(((*Table)(unsafe.Pointer((pTab5))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab5))).FtabFlags & TF_WithoutRowid) == U32(0)) { goto __247 } cnt++ @@ -109156,7 +107197,7 @@ __256: goto __257 __259: ; - if !(((*Table)(unsafe.Pointer((pTab6))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab6))).FtabFlags & TF_WithoutRowid) == U32(0)) { goto __260 } *(*int32)(unsafe.Pointer(aRoot + uintptr(libc.PreIncInt32(&cnt, 1))*4)) = int32((*Table)(unsafe.Pointer(pTab6)).Ftnum) @@ -109182,7 +107223,7 @@ __257: goto __258 __258: ; - *(*int32)(unsafe.Pointer(aRoot + uintptr(0)*4)) = cnt + *(*int32)(unsafe.Pointer(aRoot)) = cnt // Make sure sufficient number of registers have been allocated (*Parse)(unsafe.Pointer(pParse)).FnMem = func() int32 { @@ -109194,13 +107235,13 @@ __258: Xsqlite3ClearTempRegCache(tls, pParse) // Do the b-tree integrity checks - Xsqlite3VdbeAddOp4(tls, v, 146, 2, cnt, 1, aRoot, -15) + Xsqlite3VdbeAddOp4(tls, v, OP_IntegrityCk, 2, cnt, 1, aRoot, -15) Xsqlite3VdbeChangeP5(tls, v, uint16(U8(i9))) - addr1 = Xsqlite3VdbeAddOp1(tls, v, 50, 2) - Xsqlite3VdbeAddOp4(tls, v, 115, 0, 3, 0, + addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, 2) + Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0, Xsqlite3MPrintf(tls, db, ts+15288 /* "*** in database ..." */, libc.VaList(bp+304, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i9)*32)).FzDbSName)), -7) - Xsqlite3VdbeAddOp3(tls, v, 110, 2, 3, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 2, 3, 3) integrityCheckResultRow(tls, v) Xsqlite3VdbeJumpHere(tls, v, addr1) @@ -109226,23 +107267,23 @@ __267: goto __265 __268: ; - if ((*Table)(unsafe.Pointer((pTab7))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab7))).FtabFlags & TF_WithoutRowid) == U32(0) { pPk1 = uintptr(0) } else { pPk1 = Xsqlite3PrimaryKeyIndex(tls, pTab7) } - Xsqlite3OpenTableAndIndices(tls, pParse, pTab7, 96, uint8(0), + Xsqlite3OpenTableAndIndices(tls, pParse, pTab7, OP_OpenRead, uint8(0), 1, uintptr(0), bp+484 /* &iDataCur */, bp+488 /* &iIdxCur */) // reg[7] counts the number of entries in the table. // reg[8+i] counts the number of entries in the i-th index - Xsqlite3VdbeAddOp2(tls, v, 69, 0, 7) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, 7) j4 = 0 pIdx5 = (*Table)(unsafe.Pointer(pTab7)).FpIndex __269: if !(pIdx5 != 0) { goto __271 } - Xsqlite3VdbeAddOp2(tls, v, 69, 0, (8 + j4)) // index entries counter + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (8 + j4)) // index entries counter goto __270 __270: pIdx5 = (*Index)(unsafe.Pointer(pIdx5)).FpNext @@ -109252,14 +107293,14 @@ __270: __271: ; - Xsqlite3VdbeAddOp2(tls, v, 37, *(*int32)(unsafe.Pointer(bp + 484 /* iDataCur */)), 0) - loopTop = Xsqlite3VdbeAddOp2(tls, v, 82, 7, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, *(*int32)(unsafe.Pointer(bp + 484 /* iDataCur */)), 0) + loopTop = Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, 7, 1) if !(!(isQuick != 0)) { goto __272 } // Sanity check on record header decoding - Xsqlite3VdbeAddOp3(tls, v, 89, *(*int32)(unsafe.Pointer(bp + 484 /* iDataCur */)), (int32((*Table)(unsafe.Pointer(pTab7)).FnNVCol) - 1), 3) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x80)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, *(*int32)(unsafe.Pointer(bp + 484 /* iDataCur */)), (int32((*Table)(unsafe.Pointer(pTab7)).FnNVCol) - 1), 3) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_TYPEOFARG) __272: ; // Verify that all NOT NULL columns really are NOT NULL @@ -109281,16 +107322,16 @@ __276: __277: ; Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab7, *(*int32)(unsafe.Pointer(bp + 484 /* iDataCur */)), j4, 3) - if !(int32((*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, v, -1))).Fopcode) == 89) { + if !(int32((*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, v, -1))).Fopcode) == OP_Column) { goto __278 } - Xsqlite3VdbeChangeP5(tls, v, uint16(0x80)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_TYPEOFARG) __278: ; - jmp2 = Xsqlite3VdbeAddOp1(tls, v, 51, 3) + jmp2 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, 3) zErr = Xsqlite3MPrintf(tls, db, ts+15312 /* "NULL value in %s..." */, libc.VaList(bp+312, (*Table)(unsafe.Pointer(pTab7)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab7)).FaCol+uintptr(j4)*32)).FzName)) - Xsqlite3VdbeAddOp4(tls, v, 115, 0, 3, 0, zErr, -7) + Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0, zErr, -7) integrityCheckResultRow(tls, v) Xsqlite3VdbeJumpHere(tls, v, jmp2) goto __274 @@ -109301,7 +107342,7 @@ __274: __275: ; // Verify CHECK constraints - if !(((*Table)(unsafe.Pointer(pTab7)).FpCheck != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000200)) == uint64(0))) { + if !(((*Table)(unsafe.Pointer(pTab7)).FpCheck != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_IgnoreChecks) == uint64(0))) { goto __279 } pCheck = Xsqlite3ExprListDup(tls, db, (*Table)(unsafe.Pointer(pTab7)).FpCheck, 0) @@ -109324,13 +107365,13 @@ __282: goto __283 __283: ; - Xsqlite3ExprIfTrue(tls, pParse, (*ExprList_item)(unsafe.Pointer((pCheck+8 /* &.a */)+uintptr(0)*32)).FpExpr, addrCkOk, - 0x10) + Xsqlite3ExprIfTrue(tls, pParse, (*ExprList_item)(unsafe.Pointer((pCheck + 8 /* &.a */))).FpExpr, addrCkOk, + SQLITE_JUMPIFNULL) Xsqlite3VdbeResolveLabel(tls, v, addrCkFault) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0 zErr1 = Xsqlite3MPrintf(tls, db, ts+15332, /* "CHECK constraint..." */ libc.VaList(bp+328, (*Table)(unsafe.Pointer(pTab7)).FzName)) - Xsqlite3VdbeAddOp4(tls, v, 115, 0, 3, 0, zErr1, -7) + Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0, zErr1, -7) integrityCheckResultRow(tls, v) Xsqlite3VdbeResolveLabel(tls, v, addrCkOk) __280: @@ -109358,22 +107399,22 @@ __288: r1 = Xsqlite3GenerateIndexKey(tls, pParse, pIdx5, *(*int32)(unsafe.Pointer(bp + 484 /* iDataCur */)), 0, 0, bp+492, /* &jmp3 */ pPrior, r1) pPrior = pIdx5 - Xsqlite3VdbeAddOp2(tls, v, 82, (8 + j4), 1) // increment entry count + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (8 + j4), 1) // increment entry count // Verify that an index entry exists for the current table row - jmp21 = Xsqlite3VdbeAddOp4Int(tls, v, 30, (*(*int32)(unsafe.Pointer(bp + 488 /* iIdxCur */)) + j4), ckUniq, r1, + jmp21 = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, (*(*int32)(unsafe.Pointer(bp + 488 /* iIdxCur */)) + j4), ckUniq, r1, int32((*Index)(unsafe.Pointer(pIdx5)).FnColumn)) Xsqlite3VdbeLoadString(tls, v, 3, ts+15362 /* "row " */) - Xsqlite3VdbeAddOp3(tls, v, 110, 7, 3, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 7, 3, 3) Xsqlite3VdbeLoadString(tls, v, 4, ts+15367 /* " missing from in..." */) - Xsqlite3VdbeAddOp3(tls, v, 110, 4, 3, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 4, 3, 3) jmp5 = Xsqlite3VdbeLoadString(tls, v, 4, (*Index)(unsafe.Pointer(pIdx5)).FzName) - Xsqlite3VdbeAddOp3(tls, v, 110, 4, 3, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 4, 3, 3) jmp4 = integrityCheckResultRow(tls, v) Xsqlite3VdbeJumpHere(tls, v, jmp21) // For UNIQUE indexes, verify that only one entry exists with the // current key. The entry is unique if (1) any column is NULL // or (2) the next entry has a different key - if !(int32((*Index)(unsafe.Pointer((pIdx5))).FonError) != 0) { + if !(int32((*Index)(unsafe.Pointer((pIdx5))).FonError) != OE_None) { goto __289 } uniqOk = Xsqlite3VdbeMakeLabel(tls, pParse) @@ -109390,7 +107431,7 @@ __290: goto __291 __293: ; - Xsqlite3VdbeAddOp2(tls, v, 50, (r1 + kk), uniqOk) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (r1 + kk), uniqOk) goto __291 __291: @@ -109399,10 +107440,10 @@ __291: goto __292 __292: ; - jmp6 = Xsqlite3VdbeAddOp1(tls, v, 5, (*(*int32)(unsafe.Pointer(bp + 488 /* iIdxCur */)) + j4)) + jmp6 = Xsqlite3VdbeAddOp1(tls, v, OP_Next, (*(*int32)(unsafe.Pointer(bp + 488 /* iIdxCur */)) + j4)) Xsqlite3VdbeGoto(tls, v, uniqOk) Xsqlite3VdbeJumpHere(tls, v, jmp6) - Xsqlite3VdbeAddOp4Int(tls, v, 39, (*(*int32)(unsafe.Pointer(bp + 488 /* iIdxCur */)) + j4), uniqOk, r1, + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxGT, (*(*int32)(unsafe.Pointer(bp + 488 /* iIdxCur */)) + j4), uniqOk, r1, int32((*Index)(unsafe.Pointer(pIdx5)).FnKeyCol)) Xsqlite3VdbeLoadString(tls, v, 3, ts+15388 /* "non-unique entry..." */) Xsqlite3VdbeGoto(tls, v, jmp5) @@ -109421,7 +107462,7 @@ __287: ; __284: ; - Xsqlite3VdbeAddOp2(tls, v, 5, *(*int32)(unsafe.Pointer(bp + 484 /* iDataCur */)), loopTop) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, *(*int32)(unsafe.Pointer(bp + 484 /* iDataCur */)), loopTop) Xsqlite3VdbeJumpHere(tls, v, (loopTop - 1)) if !(!(isQuick != 0)) { goto __294 @@ -109439,11 +107480,11 @@ __295: goto __296 __298: ; - Xsqlite3VdbeAddOp2(tls, v, 92, (*(*int32)(unsafe.Pointer(bp + 488 /* iIdxCur */)) + j4), 3) - addr1 = Xsqlite3VdbeAddOp3(tls, v, 53, (8 + j4), 0, 3) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x90)) + Xsqlite3VdbeAddOp2(tls, v, OP_Count, (*(*int32)(unsafe.Pointer(bp + 488 /* iIdxCur */)) + j4), 3) + addr1 = Xsqlite3VdbeAddOp3(tls, v, OP_Eq, (8 + j4), 0, 3) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NOTNULL) Xsqlite3VdbeLoadString(tls, v, 4, (*Index)(unsafe.Pointer(pIdx5)).FzName) - Xsqlite3VdbeAddOp3(tls, v, 110, 4, 2, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 4, 2, 3) integrityCheckResultRow(tls, v) Xsqlite3VdbeJumpHere(tls, v, addr1) goto __296 @@ -109475,11 +107516,11 @@ __240: if !(aOp2 != 0) { goto __299 } - (*VdbeOp)(unsafe.Pointer(aOp2 + uintptr(0)*24)).Fp2 = (1 - *(*int32)(unsafe.Pointer(bp + 480 /* mxErr */))) - (*VdbeOp)(unsafe.Pointer(aOp2 + uintptr(2)*24)).Fp4type = int8(-1) - *(*uintptr)(unsafe.Pointer(aOp2 + uintptr(2)*24 + 16 /* &.p4 */)) = ts + 15444 /* "ok" */ - (*VdbeOp)(unsafe.Pointer(aOp2 + uintptr(5)*24)).Fp4type = int8(-1) - *(*uintptr)(unsafe.Pointer(aOp2 + uintptr(5)*24 + 16 /* &.p4 */)) = Xsqlite3ErrStr(tls, 11) + (*VdbeOp)(unsafe.Pointer(aOp2)).Fp2 = (1 - *(*int32)(unsafe.Pointer(bp + 480 /* mxErr */))) + (*VdbeOp)(unsafe.Pointer(aOp2 + 2*24)).Fp4type = int8(-1) + *(*uintptr)(unsafe.Pointer(aOp2 + 2*24 + 16 /* &.p4 */)) = ts + 15444 /* "ok" */ + (*VdbeOp)(unsafe.Pointer(aOp2 + 5*24)).Fp4type = int8(-1) + *(*uintptr)(unsafe.Pointer(aOp2 + 5*24 + 16 /* &.p4 */)) = Xsqlite3ErrStr(tls, SQLITE_CORRUPT) __299: ; Xsqlite3VdbeChangeP3(tls, v, 0, (Xsqlite3VdbeCurrentAddr(tls, v) - 2)) @@ -109524,10 +107565,10 @@ __300: // "PRAGMA encoding = XXX" // initialized. If the main database exists, the new sqlite.enc value // will be overwritten when the schema is next loaded. If it does not // already exists, it will be created to use the new encoding value. - if !(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0040)) == U32(0)) { + if !(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_EncodingFixed) == U32(0)) { goto __303 } - pEnc = (uintptr(unsafe.Pointer(&encnames1)) + uintptr(0)*16) + pEnc = (uintptr(unsafe.Pointer(&encnames1))) __304: if !((*EncName)(unsafe.Pointer(pEnc)).FzName != 0) { goto __306 @@ -109538,9 +107579,9 @@ __304: if (*EncName)(unsafe.Pointer(pEnc)).Fenc != 0 { enc = (*EncName)(unsafe.Pointer(pEnc)).Fenc } else { - enc = uint8(2) + enc = SQLITE_UTF16LE } - ((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb + uintptr(0)*32)).FpSchema)).Fenc) = enc + ((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb)).FpSchema)).Fenc) = enc Xsqlite3SetTextEncoding(tls, db, enc) goto __306 __307: @@ -109598,7 +107639,7 @@ __301: __45: iCookie = int32((*PragmaName)(unsafe.Pointer(pPragma)).FiArg) // Which cookie to read or write Xsqlite3VdbeUsesBtree(tls, v, iDb) - if !((zRight != 0) && ((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & 0x08) == 0)) { + if !((zRight != 0) && ((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & PragFlg_ReadOnly) == 0)) { goto __309 } @@ -109609,11 +107650,11 @@ __45: goto __15 __311: ; - (*VdbeOp)(unsafe.Pointer(aOp3 + uintptr(0)*24)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp3 + uintptr(1)*24)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp3 + uintptr(1)*24)).Fp2 = iCookie - (*VdbeOp)(unsafe.Pointer(aOp3 + uintptr(1)*24)).Fp3 = Xsqlite3Atoi(tls, zRight) - (*VdbeOp)(unsafe.Pointer(aOp3 + uintptr(1)*24)).Fp5 = U16(1) + (*VdbeOp)(unsafe.Pointer(aOp3)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp3 + 1*24)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp3 + 1*24)).Fp2 = iCookie + (*VdbeOp)(unsafe.Pointer(aOp3 + 1*24)).Fp3 = Xsqlite3Atoi(tls, zRight) + (*VdbeOp)(unsafe.Pointer(aOp3 + 1*24)).Fp5 = U16(1) goto __310 __309: ; @@ -109624,9 +107665,9 @@ __309: goto __15 __312: ; - (*VdbeOp)(unsafe.Pointer(aOp4 + uintptr(0)*24)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp4 + uintptr(1)*24)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp4 + uintptr(1)*24)).Fp3 = iCookie + (*VdbeOp)(unsafe.Pointer(aOp4)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp4 + 1*24)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp4 + 1*24)).Fp3 = iCookie Xsqlite3VdbeReusable(tls, v) __310: ; @@ -109645,7 +107686,7 @@ __313: goto __314 } Xsqlite3VdbeLoadString(tls, v, 1, zOpt) - Xsqlite3VdbeAddOp2(tls, v, 80, 1, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 1) goto __313 __314: ; @@ -109661,28 +107702,28 @@ __47: if (*Token)(unsafe.Pointer(pId2)).Fz != 0 { return iDb } - return 10 + return SQLITE_MAX_ATTACHED }() - eMode2 = 0 + eMode2 = SQLITE_CHECKPOINT_PASSIVE if !(zRight != 0) { goto __315 } if !(Xsqlite3StrICmp(tls, zRight, ts+14941 /* "full" */) == 0) { goto __316 } - eMode2 = 1 + eMode2 = SQLITE_CHECKPOINT_FULL goto __317 __316: if !(Xsqlite3StrICmp(tls, zRight, ts+15472 /* "restart" */) == 0) { goto __318 } - eMode2 = 2 + eMode2 = SQLITE_CHECKPOINT_RESTART goto __319 __318: if !(Xsqlite3StrICmp(tls, zRight, ts+15094 /* "truncate" */) == 0) { goto __320 } - eMode2 = 3 + eMode2 = SQLITE_CHECKPOINT_TRUNCATE __320: ; __319: @@ -109692,8 +107733,8 @@ __317: __315: ; (*Parse)(unsafe.Pointer(pParse)).FnMem = 3 - Xsqlite3VdbeAddOp3(tls, v, 6, iBt, eMode2, 1) - Xsqlite3VdbeAddOp2(tls, v, 80, 1, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_Checkpoint, iBt, eMode2, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 3) goto __15 @@ -109829,7 +107870,7 @@ __329: // If table pTab has not been used in a way that would benefit from // having analysis statistics during the current session, then skip it. // This also has the effect of skipping virtual tables and views - if !(((*Table)(unsafe.Pointer(pTab8)).FtabFlags & U32(0x0100)) == U32(0)) { + if !(((*Table)(unsafe.Pointer(pTab8)).FtabFlags & TF_StatsUsed) == U32(0)) { goto __332 } goto __330 @@ -109860,8 +107901,8 @@ __335: if !(szThreshold != 0) { goto __337 } - Xsqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab8, 96) - Xsqlite3VdbeAddOp3(tls, v, 34, iTabCur, + Xsqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab8, OP_OpenRead) + Xsqlite3VdbeAddOp3(tls, v, OP_IfSmaller, iTabCur, (int32((U32(Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + (opMask & U32(1)))), int32(szThreshold)) __337: @@ -109872,11 +107913,11 @@ __337: goto __338 } r11 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp4(tls, v, 115, 0, r11, 0, zSubSql, -7) - Xsqlite3VdbeAddOp2(tls, v, 80, r11, 1) + Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, r11, 0, zSubSql, -7) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, r11, 1) goto __339 __338: - Xsqlite3VdbeAddOp4(tls, v, 140, 0, 0, 0, zSubSql, -7) + Xsqlite3VdbeAddOp4(tls, v, OP_SqlExec, 0, 0, 0, zSubSql, -7) __339: ; goto __330 @@ -109893,7 +107934,7 @@ __326: goto __327 __327: ; - Xsqlite3VdbeAddOp0(tls, v, 158) + Xsqlite3VdbeAddOp0(tls, v, OP_Expire) goto __15 // PRAGMA busy_timeout @@ -109925,7 +107966,7 @@ __340: // returns the same integer that would be returned by the // sqlite3_soft_heap_limit64(-1) C-language function. __52: - if !((zRight != 0) && (Xsqlite3DecOrHexToI64(tls, zRight, bp+496 /* &N */) == 0)) { + if !((zRight != 0) && (Xsqlite3DecOrHexToI64(tls, zRight, bp+496 /* &N */) == SQLITE_OK)) { goto __341 } Xsqlite3_soft_heap_limit64(tls, *(*Sqlite3_int64)(unsafe.Pointer(bp + 496 /* N */))) @@ -109944,7 +107985,7 @@ __341: // the hard heap limit. This allows an application to set a heap limit // constraint that cannot be relaxed by an untrusted SQL script. __53: - if !((zRight != 0) && (Xsqlite3DecOrHexToI64(tls, zRight, bp+504 /* &N1 */) == 0)) { + if !((zRight != 0) && (Xsqlite3DecOrHexToI64(tls, zRight, bp+504 /* &N1 */) == SQLITE_OK)) { goto __342 } iPrior = Xsqlite3_hard_heap_limit64(tls, int64(-1)) @@ -109966,14 +108007,14 @@ __342: // maximum, which might be less than requested. __54: if !(((zRight != 0) && - (Xsqlite3DecOrHexToI64(tls, zRight, bp+512 /* &N2 */) == 0)) && + (Xsqlite3DecOrHexToI64(tls, zRight, bp+512 /* &N2 */) == SQLITE_OK)) && (*(*Sqlite3_int64)(unsafe.Pointer(bp + 512 /* N2 */)) >= int64(0))) { goto __344 } - Xsqlite3_limit(tls, db, 11, (int32(*(*Sqlite3_int64)(unsafe.Pointer(bp + 512 /* N2 */)) & int64(0x7fffffff)))) + Xsqlite3_limit(tls, db, SQLITE_LIMIT_WORKER_THREADS, (int32(*(*Sqlite3_int64)(unsafe.Pointer(bp + 512 /* N2 */)) & int64(0x7fffffff)))) __344: ; - returnSingleInt(tls, v, int64(Xsqlite3_limit(tls, db, 11, -1))) + returnSingleInt(tls, v, int64(Xsqlite3_limit(tls, db, SQLITE_LIMIT_WORKER_THREADS, -1))) goto __15 // PRAGMA analysis_limit @@ -109983,7 +108024,7 @@ __344: // in each index that it looks at. Return the new limit. __55: if !(((zRight != 0) && - (Xsqlite3DecOrHexToI64(tls, zRight, bp+520 /* &N3 */) == 0)) && + (Xsqlite3DecOrHexToI64(tls, zRight, bp+520 /* &N3 */) == SQLITE_OK)) && (*(*Sqlite3_int64)(unsafe.Pointer(bp + 520 /* N3 */)) >= int64(0))) { goto __345 } @@ -110001,7 +108042,7 @@ __15: // PragFlg_NoColumns1 flag is set and the caller specified an argument // to the PRAGMA, the implementation has not added any OP_ResultRow // instructions to the VM. - if !(((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & 0x04) != 0) && (zRight != 0)) { + if !(((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & PragFlg_NoColumns1) != 0) && (zRight != 0)) { goto __346 } @@ -110021,173 +108062,53 @@ type EncName = struct { var iLn3 int32 = 0 /* sqlite3.c:126248:22 */ var getCacheSize = [9]VdbeOpList{ - { - Fopcode: U8(2), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 0 - { - Fopcode: U8(93), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(3)}, // 1 - { - Fopcode: U8(48), - Fp1: int8(1), - Fp2: int8(8), - Fp3: int8(0)}, - { - Fopcode: U8(69), - Fp1: int8(0), - Fp2: int8(2), - Fp3: int8(0)}, - { - Fopcode: U8(106), - Fp1: int8(1), - Fp2: int8(2), - Fp3: int8(1)}, - { - Fopcode: U8(48), - Fp1: int8(1), - Fp2: int8(8), - Fp3: int8(0)}, - { - Fopcode: U8(69), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(0)}, // 6 - { - Fopcode: U8(173), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - { - Fopcode: U8(80), - Fp1: int8(1), - Fp2: int8(1), - Fp3: int8(0)}, + {Fopcode: OP_Transaction}, // 0 + {Fopcode: OP_ReadCookie, Fp2: int8(1), Fp3: BTREE_DEFAULT_CACHE_SIZE}, // 1 + {Fopcode: OP_IfPos, Fp1: int8(1), Fp2: int8(8)}, + {Fopcode: OP_Integer, Fp2: int8(2)}, + {Fopcode: OP_Subtract, Fp1: int8(1), Fp2: int8(2), Fp3: int8(1)}, + {Fopcode: OP_IfPos, Fp1: int8(1), Fp2: int8(8)}, + {Fopcode: OP_Integer, Fp2: int8(1)}, // 6 + {Fopcode: OP_Noop}, + {Fopcode: OP_ResultRow, Fp1: int8(1), Fp2: int8(1)}, } /* sqlite3.c:126249:29 */ var iLn4 int32 = 0 /* sqlite3.c:126517:26 */ var setMeta6 = [5]VdbeOpList{ - { - Fopcode: U8(2), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(0)}, // 0 - { - Fopcode: U8(93), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(4)}, - { - Fopcode: U8(18), - Fp1: int8(1), - Fp2: int8(0), - Fp3: int8(0)}, // 2 - { - Fopcode: U8(68), - Fp1: int8(0), - Fp2: int8(2), - Fp3: int8(0)}, // 3 - { - Fopcode: U8(94), - Fp1: int8(0), - Fp2: int8(7), - Fp3: int8(0)}, // 4 + {Fopcode: OP_Transaction, Fp2: int8(1)}, // 0 + {Fopcode: OP_ReadCookie, Fp2: int8(1), Fp3: BTREE_LARGEST_ROOT_PAGE}, + {Fopcode: OP_If, Fp1: int8(1)}, // 2 + {Fopcode: OP_Halt, Fp2: OE_Abort}, // 3 + {Fopcode: OP_SetCookie, Fp2: BTREE_INCR_VACUUM}, // 4 } /* sqlite3.c:126518:33 */ var iLn5 int32 = 0 /* sqlite3.c:127522:24 */ var endCode = [7]VdbeOpList{ - { - Fopcode: U8(82), - Fp1: int8(1), - Fp2: int8(0), - Fp3: int8(0)}, // 0 - { - Fopcode: U8(49), - Fp1: int8(1), - Fp2: int8(4), - Fp3: int8(0)}, // 1 - { - Fopcode: U8(115), - Fp1: int8(0), - Fp2: int8(3), - Fp3: int8(0)}, // 2 - { - Fopcode: U8(80), - Fp1: int8(3), - Fp2: int8(1), - Fp3: int8(0)}, // 3 - { - Fopcode: U8(68), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 4 - { - Fopcode: U8(115), - Fp1: int8(0), - Fp2: int8(3), - Fp3: int8(0)}, // 5 - { - Fopcode: U8(11), - Fp1: int8(0), - Fp2: int8(3), - Fp3: int8(0)}, // 6 + {Fopcode: OP_AddImm, Fp1: int8(1)}, // 0 + {Fopcode: OP_IfNotZero, Fp1: int8(1), Fp2: int8(4)}, // 1 + {Fopcode: OP_String8, Fp2: int8(3)}, // 2 + {Fopcode: OP_ResultRow, Fp1: int8(3), Fp2: int8(1)}, // 3 + {Fopcode: OP_Halt}, // 4 + {Fopcode: OP_String8, Fp2: int8(3)}, // 5 + {Fopcode: OP_Goto, Fp2: int8(3)}, // 6 } /* sqlite3.c:127523:31 */ var encnames1 = [9]EncName{ - { - FzName: ts + 15498, /* "UTF8" */ - Fenc: U8(1)}, - { - FzName: ts + 15503, /* "UTF-8" */ - Fenc: U8(1)}, // Must be element [1] - { - FzName: ts + 15509, /* "UTF-16le" */ - Fenc: U8(2)}, // Must be element [2] - { - FzName: ts + 15518, /* "UTF-16be" */ - Fenc: U8(3)}, // Must be element [3] - { - FzName: ts + 15527, /* "UTF16le" */ - Fenc: U8(2)}, - { - FzName: ts + 15535, /* "UTF16be" */ - Fenc: U8(3)}, - { - FzName: ts + 15543, /* "UTF-16" */ - Fenc: U8(0)}, // SQLITE_UTF16NATIVE - { - FzName: ts + 15550, /* "UTF16" */ - Fenc: U8(0)}, // SQLITE_UTF16NATIVE + {FzName: ts + 15498 /* "UTF8" */, Fenc: SQLITE_UTF8}, + {FzName: ts + 15503 /* "UTF-8" */, Fenc: SQLITE_UTF8}, // Must be element [1] + {FzName: ts + 15509 /* "UTF-16le" */, Fenc: SQLITE_UTF16LE}, // Must be element [2] + {FzName: ts + 15518 /* "UTF-16be" */, Fenc: SQLITE_UTF16BE}, // Must be element [3] + {FzName: ts + 15527 /* "UTF16le" */, Fenc: SQLITE_UTF16LE}, + {FzName: ts + 15535 /* "UTF16be" */, Fenc: SQLITE_UTF16BE}, + {FzName: ts + 15543 /* "UTF-16" */}, // SQLITE_UTF16NATIVE + {FzName: ts + 15550 /* "UTF16" */}, // SQLITE_UTF16NATIVE {}, } /* sqlite3.c:127575:7 */ var setCookie = [2]VdbeOpList{ - { - Fopcode: U8(2), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(0)}, // 0 - { - Fopcode: U8(94), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 1 + {Fopcode: OP_Transaction, Fp2: int8(1)}, // 0 + {Fopcode: OP_SetCookie}, // 1 } /* sqlite3.c:127655:31 */ var readCookie = [3]VdbeOpList{ - { - Fopcode: U8(2), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 0 - { - Fopcode: U8(93), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(0)}, // 1 - { - Fopcode: U8(80), - Fp1: int8(1), - Fp2: int8(1), - Fp3: int8(0)}, + {Fopcode: OP_Transaction}, // 0 + {Fopcode: OP_ReadCookie, Fp2: int8(1)}, // 1 + {Fopcode: OP_ResultRow, Fp1: int8(1), Fp2: int8(1)}, } /* sqlite3.c:127670:31 */ // **************************************************************************** // @@ -110259,11 +108180,11 @@ __3: i++ } j = 0 - if (int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & 0x20) != 0 { + if (int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & PragFlg_Result1) != 0 { Xsqlite3_str_appendall(tls, bp+32 /* &acc */, ts+15584 /* ",arg HIDDEN" */) j++ } - if (int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & (0x40 | 0x80)) != 0 { + if (int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & (PragFlg_SchemaOpt | PragFlg_SchemaReq)) != 0 { Xsqlite3_str_appendall(tls, bp+32 /* &acc */, ts+15596 /* ",schema HIDDEN" */) j++ } @@ -110271,10 +108192,10 @@ __3: Xsqlite3StrAccumFinish(tls, bp+32 /* &acc */) rc = Xsqlite3_declare_vtab(tls, db, bp+64 /* &zBuf[0] */) - if rc == 0 { + if rc == SQLITE_OK { pTab = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(PragmaVtab{}))) if pTab == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, pTab, 0, uint64(unsafe.Sizeof(PragmaVtab{}))) (*PragmaVtab)(unsafe.Pointer(pTab)).FpName = pPragma @@ -110294,7 +108215,7 @@ __3: func pragmaVtabDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:128111:12: */ var pTab uintptr = pVtab Xsqlite3_free(tls, pTab) - return 0 + return SQLITE_OK } // Figure out the best index to use to search a pragma virtual table. @@ -110315,11 +108236,11 @@ func pragmaVtabBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { / (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1) if int32((*PragmaVtab)(unsafe.Pointer(pTab)).FnHidden) == 0 { - return 0 + return SQLITE_OK } pConstraint = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint - *(*int32)(unsafe.Pointer(bp /* &seen[0] */ + uintptr(0)*4)) = 0 - *(*int32)(unsafe.Pointer(bp /* &seen[0] */ + uintptr(1)*4)) = 0 + *(*int32)(unsafe.Pointer(bp /* &seen[0] */)) = 0 + *(*int32)(unsafe.Pointer(bp /* &seen[0] */ + 1*4)) = 0 i = 0 __1: if !(i < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { @@ -110329,7 +108250,7 @@ __1: if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { goto __2 } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) != 2 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) != SQLITE_INDEX_CONSTRAINT_EQ { goto __2 } if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < int32((*PragmaVtab)(unsafe.Pointer(pTab)).FiHidden) { @@ -110348,23 +108269,23 @@ __2: goto __3 __3: ; - if *(*int32)(unsafe.Pointer(bp /* &seen[0] */ + uintptr(0)*4)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* &seen[0] */)) == 0 { (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(2147483647) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(2147483647) - return 0 + return SQLITE_OK } - j = (*(*int32)(unsafe.Pointer(bp /* &seen[0] */ + uintptr(0)*4)) - 1) + j = (*(*int32)(unsafe.Pointer(bp /* &seen[0] */)) - 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).FargvIndex = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).Fomit = uint8(1) - if *(*int32)(unsafe.Pointer(bp /* &seen[0] */ + uintptr(1)*4)) == 0 { - return 0 + if *(*int32)(unsafe.Pointer(bp /* &seen[0] */ + 1*4)) == 0 { + return SQLITE_OK } (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(20) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(20) - j = (*(*int32)(unsafe.Pointer(bp /* &seen[0] */ + uintptr(1)*4)) - 1) + j = (*(*int32)(unsafe.Pointer(bp /* &seen[0] */ + 1*4)) - 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).FargvIndex = 2 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).Fomit = uint8(1) - return 0 + return SQLITE_OK } // Create a new cursor for the pragma virtual table @@ -110372,12 +108293,12 @@ func pragmaVtabOpen(tls *libc.TLS, pVtab uintptr, ppCursor uintptr) int32 { /* s var pCsr uintptr pCsr = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(PragmaVtabCursor{}))) if pCsr == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCsr, 0, uint64(unsafe.Sizeof(PragmaVtabCursor{}))) (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVtab *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCsr /* &.base */) - return 0 + return SQLITE_OK } // Clear all content from pragma virtual table cursor. @@ -110396,18 +108317,18 @@ func pragmaVtabClose(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:128183:12: var pCsr uintptr = cur pragmaVtabCursorClear(tls, pCsr) Xsqlite3_free(tls, pCsr) - return 0 + return SQLITE_OK } // Advance the pragma virtual table cursor to the next row func pragmaVtabNext(tls *libc.TLS, pVtabCursor uintptr) int32 { /* sqlite3.c:128191:12: */ var pCsr uintptr = pVtabCursor - var rc int32 = 0 + var rc int32 = SQLITE_OK // Increment the xRowid value (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FiRowid++ - if 100 != Xsqlite3_step(tls, (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma) { + if SQLITE_ROW != Xsqlite3_step(tls, (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma) { rc = Xsqlite3_finalize(tls, (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma) (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma = uintptr(0) pragmaVtabCursorClear(tls, pCsr) @@ -110432,7 +108353,7 @@ func pragmaVtabFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr u _ = idxNum _ = idxStr pragmaVtabCursorClear(tls, pCsr) - if (int32((*PragmaName)(unsafe.Pointer((*PragmaVtab)(unsafe.Pointer(pTab)).FpName)).FmPragFlg) & 0x20) != 0 { + if (int32((*PragmaName)(unsafe.Pointer((*PragmaVtab)(unsafe.Pointer(pTab)).FpName)).FmPragFlg) & PragFlg_Result1) != 0 { j = 0 } else { j = 1 @@ -110448,7 +108369,7 @@ __1: if zText != 0 { *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr(j)*8)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp, zText)) if *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr(j)*8)) == uintptr(0) { - return 7 + return SQLITE_NOMEM } } @@ -110461,22 +108382,22 @@ __2: goto __3 __3: ; - Xsqlite3StrAccumInit(tls, bp+32 /* &acc */, uintptr(0), uintptr(0), 0, *(*int32)(unsafe.Pointer(((*PragmaVtab)(unsafe.Pointer(pTab)).Fdb + 124 /* &.aLimit */) + uintptr(1)*4))) + Xsqlite3StrAccumInit(tls, bp+32 /* &acc */, uintptr(0), uintptr(0), 0, *(*int32)(unsafe.Pointer(((*PragmaVtab)(unsafe.Pointer(pTab)).Fdb + 124 /* &.aLimit */) + 1*4))) Xsqlite3_str_appendall(tls, bp+32 /* &acc */, ts+15611 /* "PRAGMA " */) - if *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr(1)*8)) != 0 { - Xsqlite3_str_appendf(tls, bp+32 /* &acc */, ts+15619 /* "%Q." */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr(1)*8)))) + if *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + 1*8)) != 0 { + Xsqlite3_str_appendf(tls, bp+32 /* &acc */, ts+15619 /* "%Q." */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + 1*8)))) } Xsqlite3_str_appendall(tls, bp+32 /* &acc */, (*PragmaName)(unsafe.Pointer((*PragmaVtab)(unsafe.Pointer(pTab)).FpName)).FzName) - if *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr(0)*8)) != 0 { - Xsqlite3_str_appendf(tls, bp+32 /* &acc */, ts+15623 /* "=%Q" */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr(0)*8)))) + if *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */))) != 0 { + Xsqlite3_str_appendf(tls, bp+32 /* &acc */, ts+15623 /* "=%Q" */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */))))) } zSql = Xsqlite3StrAccumFinish(tls, bp+32 /* &acc */) if zSql == uintptr(0) { - return 7 + return SQLITE_NOMEM } rc = Xsqlite3_prepare_v2(tls, (*PragmaVtab)(unsafe.Pointer(pTab)).Fdb, zSql, -1, (pCsr + 8 /* &.pPragma */), uintptr(0)) Xsqlite3_free(tls, zSql) - if rc != 0 { + if rc != SQLITE_OK { (*PragmaVtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp+24, Xsqlite3_errmsg(tls, (*PragmaVtab)(unsafe.Pointer(pTab)).Fdb))) return rc } @@ -110499,65 +108420,28 @@ func pragmaVtabColumn(tls *libc.TLS, pVtabCursor uintptr, ctx uintptr, i int32) } else { Xsqlite3_result_text(tls, ctx, *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr((i-int32((*PragmaVtab)(unsafe.Pointer(pTab)).FiHidden)))*8)), -1, libc.UintptrFromInt32(-1)) } - return 0 + return SQLITE_OK } // Pragma virtual table module xRowid method. func pragmaVtabRowid(tls *libc.TLS, pVtabCursor uintptr, p uintptr) int32 { /* sqlite3.c:128285:12: */ var pCsr uintptr = pVtabCursor *(*Sqlite_int64)(unsafe.Pointer(p)) = (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FiRowid - return 0 + return SQLITE_OK } // The pragma virtual table object -var pragmaVtabModule = Sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - uintptr(0), - FxConnect:// xCreate - create a table - 0, - FxBestIndex:// xConnect - connect to an existing table - 0, - FxDisconnect:// xBestIndex - Determine search strategy - 0, - FxDestroy:// xDisconnect - Disconnect from a table - uintptr(0), - FxOpen:// xDestroy - Drop a table - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - write data - uintptr(0), - FxSync:// xBegin - begin transaction - uintptr(0), - FxCommit:// xSync - sync transaction - uintptr(0), - FxRollback:// xCommit - commit transaction - uintptr(0), - FxFindFunction:// xRollback - rollback transaction - uintptr(0), - FxRename:// xFindFunction - function overloading - uintptr(0), - FxSavepoint:// xRename - rename the table - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var pragmaVtabModule = Sqlite3_module{ // xCreate - create a table + FxConnect: 0, // xConnect - connect to an existing table + FxBestIndex: 0, // xBestIndex - Determine search strategy + FxDisconnect: 0, // xDestroy - Drop a table + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xShadowName } /* sqlite3.c:128292:29 */ // Check to see if zTabName is really the name of a pragma. If it is, @@ -110570,7 +108454,7 @@ func Xsqlite3PragmaVtabRegister(tls *libc.TLS, db uintptr, zName uintptr) uintpt if pName == uintptr(0) { return uintptr(0) } - if (int32((*PragmaName)(unsafe.Pointer(pName)).FmPragFlg) & (0x10 | 0x20)) == 0 { + if (int32((*PragmaName)(unsafe.Pointer(pName)).FmPragFlg) & (PragFlg_Result0 | PragFlg_Result1)) == 0 { return uintptr(0) } @@ -110602,13 +108486,13 @@ func corruptSchema(tls *libc.TLS, pData uintptr, zObj uintptr, zExtra uintptr) { var db uintptr = (*InitData)(unsafe.Pointer(pData)).Fdb if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - (*InitData)(unsafe.Pointer(pData)).Frc = 7 - } else if *(*uintptr)(unsafe.Pointer((*InitData)(unsafe.Pointer(pData)).FpzErrMsg + uintptr(0)*8)) != uintptr(0) { + (*InitData)(unsafe.Pointer(pData)).Frc = SQLITE_NOMEM + } else if *(*uintptr)(unsafe.Pointer((*InitData)(unsafe.Pointer(pData)).FpzErrMsg)) != uintptr(0) { // A error message has already been generated. Do not overwrite it - } else if ((*InitData)(unsafe.Pointer(pData)).FmInitFlags & U32(0x0001)) != 0 { + } else if ((*InitData)(unsafe.Pointer(pData)).FmInitFlags & INITFLAG_AlterTable) != 0 { *(*uintptr)(unsafe.Pointer((*InitData)(unsafe.Pointer(pData)).FpzErrMsg)) = Xsqlite3DbStrDup(tls, db, zExtra) - (*InitData)(unsafe.Pointer(pData)).Frc = 1 - } else if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000001)) != 0 { + (*InitData)(unsafe.Pointer(pData)).Frc = SQLITE_ERROR + } else if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_WriteSchema) != 0 { (*InitData)(unsafe.Pointer(pData)).Frc = Xsqlite3CorruptError(tls, 128375) } else { var z uintptr @@ -110616,7 +108500,7 @@ func corruptSchema(tls *libc.TLS, pData uintptr, zObj uintptr, zExtra uintptr) { zObj = ts + 3963 /* "?" */ } z = Xsqlite3MPrintf(tls, db, ts+15627 /* "malformed databa..." */, libc.VaList(bp, zObj)) - if (zExtra != 0) && (*(*int8)(unsafe.Pointer(zExtra + uintptr(0))) != 0) { + if (zExtra != 0) && (*(*int8)(unsafe.Pointer(zExtra)) != 0) { z = Xsqlite3MPrintf(tls, db, ts+15658 /* "%z - %s" */, libc.VaList(bp+8, z, zExtra)) } *(*uintptr)(unsafe.Pointer((*InitData)(unsafe.Pointer(pData)).FpzErrMsg)) = z @@ -110660,19 +108544,19 @@ func Xsqlite3InitCallback(tls *libc.TLS, pInit uintptr, argc int32, argv uintptr _ = NotUsed _ = argc - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0040)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_EncodingFixed) (*InitData)(unsafe.Pointer(pData)).FnInitRow++ if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uintptr(0)) + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uintptr(0)) return 1 } if argv == uintptr(0) { return 0 } // Might happen if EMPTY_RESULT_CALLBACKS are on - if *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)) == uintptr(0) { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uintptr(0)) - } else if Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)), ts+15666 /* "create " */, 7) == 0 { + if *(*uintptr)(unsafe.Pointer(argv + 3*8)) == uintptr(0) { + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uintptr(0)) + } else if Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), ts+15666 /* "create " */, 7) == 0 { // Call the parser to process a CREATE TABLE, INDEX or VIEW. // But because db->init.busy is set to 1, no VDBE code is generated // or executed. All the parser does is build the internal data @@ -110684,37 +108568,37 @@ func Xsqlite3InitCallback(tls *libc.TLS, pInit uintptr, argc int32, argv uintptr // Return code from sqlite3_prepare() (*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = U8(iDb) - if (Xsqlite3GetUInt32(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)), (db+176 /* &.init */ /* &.newTnum */)) == 0) || + if (Xsqlite3GetUInt32(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8)), (db+176 /* &.init */ /* &.newTnum */)) == 0) || (((*Sqlite3)(unsafe.Pointer(db)).Finit.FnewTnum > (*InitData)(unsafe.Pointer(pData)).FmxPage) && ((*InitData)(unsafe.Pointer(pData)).FmxPage > Pgno(0))) { if Xsqlite3Config.FbExtraSchemaChecks != 0 { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+11973 /* "invalid rootpage" */) + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+11973 /* "invalid rootpage" */) } } libc.SetBitFieldPtr8Uint32(db+176 /* &.init */ +8 /* &.orphanTrigger */, uint32(0), 0, 0x1) (*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit = argv *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) - sqlite3Prepare(tls, db, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)), -1, uint32(0), uintptr(0), bp /* &pStmt */, uintptr(0)) + sqlite3Prepare(tls, db, *(*uintptr)(unsafe.Pointer(argv + 4*8)), -1, uint32(0), uintptr(0), bp /* &pStmt */, uintptr(0)) rc = (*Sqlite3)(unsafe.Pointer(db)).FerrCode (*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = saved_iDb // assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); - if 0 != rc { + if SQLITE_OK != rc { if (uint32(int32(*(*uint8)(unsafe.Pointer(db + 176 /* &.init */ + 8 /* &.orphanTrigger */)) & 0x1 >> 0))) != 0 { } else { if rc > (*InitData)(unsafe.Pointer(pData)).Frc { (*InitData)(unsafe.Pointer(pData)).Frc = rc } - if rc == 7 { + if rc == SQLITE_NOMEM { Xsqlite3OomFault(tls, db) - } else if (rc != 9) && ((rc & 0xFF) != 6) { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), Xsqlite3_errmsg(tls, db)) + } else if (rc != SQLITE_INTERRUPT) && ((rc & 0xFF) != SQLITE_LOCKED) { + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), Xsqlite3_errmsg(tls, db)) } } } Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) - } else if (*(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) == uintptr(0)) || ((*(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)) != uintptr(0)) && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)) + uintptr(0)))) != 0)) { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uintptr(0)) + } else if (*(*uintptr)(unsafe.Pointer(argv + 1*8)) == uintptr(0)) || ((*(*uintptr)(unsafe.Pointer(argv + 4*8)) != uintptr(0)) && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 4*8))))) != 0)) { + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uintptr(0)) } else { // If the SQL column is blank it means this is an index that // was created to be the PRIMARY KEY or to fulfill a UNIQUE @@ -110722,15 +108606,15 @@ func Xsqlite3InitCallback(tls *libc.TLS, pInit uintptr, argc int32, argv uintptr // been created when we processed the CREATE TABLE. All we have // to do here is record the root page number for that index. var pIndex uintptr - pIndex = Xsqlite3FindIndex(tls, db, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) + pIndex = Xsqlite3FindIndex(tls, db, *(*uintptr)(unsafe.Pointer(argv + 1*8)), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) if pIndex == uintptr(0) { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+15674 /* "orphan index" */) - } else if (((Xsqlite3GetUInt32(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)), (pIndex+88 /* &.tnum */)) == 0) || + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+15674 /* "orphan index" */) + } else if (((Xsqlite3GetUInt32(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8)), (pIndex+88 /* &.tnum */)) == 0) || ((*Index)(unsafe.Pointer(pIndex)).Ftnum < Pgno(2))) || ((*Index)(unsafe.Pointer(pIndex)).Ftnum > (*InitData)(unsafe.Pointer(pData)).FmxPage)) || (Xsqlite3IndexHasDuplicateRootPage(tls, pIndex) != 0) { if Xsqlite3Config.FbExtraSchemaChecks != 0 { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+11973 /* "invalid rootpage" */) + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+11973 /* "invalid rootpage" */) } } } @@ -110764,7 +108648,7 @@ func Xsqlite3InitOne(tls *libc.TLS, db uintptr, iDb int32, pzErrMsg uintptr, mFl var xAuth Sqlite3_xauth var zSql uintptr openedTransaction = 0 - mask = (int32(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0040)) | ^libc.Uint32FromInt32(0x0040))) + mask = (int32(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_EncodingFixed) | libc.Uint32FromInt32(libc.CplInt32(DBFLAG_EncodingFixed)))) (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy = U8(1) @@ -110773,20 +108657,20 @@ func Xsqlite3InitOne(tls *libc.TLS, db uintptr, iDb int32, pzErrMsg uintptr, mFl // table name will be inserted automatically by the parser so we can just // use the abbreviation "x" here. The parser will also automatically tag // the schema table as read-only. - *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(0)*8)) = ts + 7333 /* "table" */ - *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(1)*8)) = libc.AssignUintptr(&zSchemaTabName, func() uintptr { + *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */)) = ts + 7333 /* "table" */ + *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + 1*8)) = libc.AssignUintptr(&zSchemaTabName, func() uintptr { if (!(0 != 0)) && (iDb == 1) { return ts + 10046 /* "sqlite_temp_mast..." */ } return ts + 4780 /* "sqlite_master" */ }()) - *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(2)*8)) = *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(1)*8)) - *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(3)*8)) = ts + 6737 /* "1" */ - *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(4)*8)) = ts + 15687 /* "CREATE TABLE x(t..." */ - *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(5)*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + 2*8)) = *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + 1*8)) + *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + 3*8)) = ts + 6737 /* "1" */ + *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + 4*8)) = ts + 15687 /* "CREATE TABLE x(t..." */ + *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + 5*8)) = uintptr(0) (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).Fdb = db (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).FiDb = iDb - (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).Frc = 0 + (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).Frc = SQLITE_OK (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).FpzErrMsg = pzErrMsg (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).FmInitFlags = mFlags (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).FnInitRow = U32(0) @@ -110807,8 +108691,8 @@ __1: goto __2 } - *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(1)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((0x0001)) - rc = 0 + *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+1*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((DB_SchemaLoaded)) + rc = SQLITE_OK goto error_out __2: ; @@ -110821,7 +108705,7 @@ __2: goto __3 } rc = Xsqlite3BtreeBeginTrans(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, 0, uintptr(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } Xsqlite3SetString(tls, pzErrMsg, db, Xsqlite3ErrStr(tls, rc)) @@ -110861,42 +108745,42 @@ __6: goto __7 __7: ; - if !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x02000000)) != uint64(0)) { + if !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ResetDatabase) != uint64(0)) { goto __8 } libc.Xmemset(tls, bp+104 /* &meta[0] */, 0, uint64(unsafe.Sizeof([5]int32{}))) __8: ; - (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fschema_cookie = *(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((1-1))*4)) + (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fschema_cookie = *(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */)) // If opening a non-empty database, check the text encoding. For the // main database, set sqlite3.enc to the encoding of the main database. // For an attached db, it is an error if the encoding is not the same // as sqlite3.enc. - if !(*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((5-1))*4)) != 0) { + if !(*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + 4*4)) != 0) { goto __9 } // text encoding - if !((iDb == 0) && (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0040)) == U32(0))) { + if !((iDb == 0) && (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_EncodingFixed) == U32(0))) { goto __10 } // If opening the main database, set ENC(db). - encoding = (U8(int32(U8(*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((5-1))*4)))) & 3)) + encoding = (U8(int32(U8(*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + 4*4)))) & 3)) if !(int32(encoding) == 0) { goto __12 } - encoding = U8(1) + encoding = SQLITE_UTF8 __12: ; Xsqlite3SetTextEncoding(tls, db, encoding) goto __11 __10: // If opening an attached database, the encoding much match ENC(db) - if !((*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((5-1))*4)) & 3) != (int32((*Sqlite3)(unsafe.Pointer(db)).Fenc))) { + if !((*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + 4*4)) & 3) != (int32((*Sqlite3)(unsafe.Pointer(db)).Fenc))) { goto __13 } Xsqlite3SetString(tls, pzErrMsg, db, ts+9673 /* "attached databas..." */) - rc = 1 + rc = SQLITE_ERROR goto initone_error_out __13: ; @@ -110909,7 +108793,7 @@ __9: if !((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size == 0) { goto __14 } - size = Xsqlite3AbsInt32(tls, *(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((3-1))*4))) + size = Xsqlite3AbsInt32(tls, *(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + 2*4))) if !(size == 0) { goto __15 } @@ -110925,18 +108809,18 @@ __14: // file_format==2 Version 3.1.3. // ALTER TABLE ADD COLUMN // file_format==3 Version 3.1.4. // ditto but with non-NULL defaults // file_format==4 Version 3.3.0. // DESC indices. Boolean constants - (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format = U8(*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((2-1))*4))) + (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format = U8(*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + 1*4))) if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) == 0) { goto __16 } (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format = U8(1) __16: ; - if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) > 4) { + if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) > SQLITE_MAX_FILE_FORMAT) { goto __17 } Xsqlite3SetString(tls, pzErrMsg, db, ts+15759 /* "unsupported file..." */) - rc = 1 + rc = SQLITE_ERROR goto initone_error_out __17: ; @@ -110945,10 +108829,10 @@ __17: // clear the legacy_file_format pragma flag so that a VACUUM will // not downgrade the database and thus invalidate any descending // indices that the user might have created. - if !((iDb == 0) && (*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((2-1))*4)) >= 4)) { + if !((iDb == 0) && (*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + 1*4)) >= 4)) { goto __18 } - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x00000002))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_LegacyFileFmt)) __18: ; @@ -110967,14 +108851,14 @@ __18: }{Xsqlite3InitCallback})), bp+64 /* &initData */, uintptr(0)) (*Sqlite3)(unsafe.Pointer(db)).FxAuth = xAuth - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __19 } rc = (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).Frc __19: ; Xsqlite3DbFree(tls, db, zSql) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __20 } Xsqlite3AnalysisLoad(tls, db, iDb) @@ -110984,11 +108868,11 @@ __20: if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __21 } - rc = 7 + rc = SQLITE_NOMEM Xsqlite3ResetAllSchemasOfConnection(tls, db) __21: ; - if !((rc == 0) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x08000000)) != 0)) { + if !((rc == SQLITE_OK) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_NoSchemaError) != 0)) { goto __22 } // Black magic: If the SQLITE_NoSchemaError flag is set, then consider @@ -110998,8 +108882,8 @@ __21: // of the schema was loaded before the error occurred. The primary // purpose of this is to allow access to the sqlite_schema table // even when its contents have been corrupted. - *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(iDb)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((0x0001)) - rc = 0 + *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(iDb)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((DB_SchemaLoaded)) + rc = SQLITE_OK __22: ; @@ -111019,7 +108903,7 @@ error_out: if !(rc != 0) { goto __24 } - if !((rc == 7) || (rc == (10 | (int32(12) << 8)))) { + if !((rc == SQLITE_NOMEM) || (rc == (SQLITE_IOERR | (int32(12) << 8)))) { goto __25 } Xsqlite3OomFault(tls, db) @@ -111042,12 +108926,12 @@ __24: func Xsqlite3Init(tls *libc.TLS, db uintptr, pzErrMsg uintptr) int32 { /* sqlite3.c:128755:20: */ var i int32 var rc int32 - var commit_internal int32 = libc.BoolInt32(!(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0001)) != 0)) + var commit_internal int32 = libc.BoolInt32(!(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_SchemaChange) != 0)) - ((*Sqlite3)(unsafe.Pointer(db)).Fenc) = (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb + uintptr(0)*32)).FpSchema)).Fenc + ((*Sqlite3)(unsafe.Pointer(db)).Fenc) = (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb)).FpSchema)).Fenc // Do the main schema first - if !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(0)*32)).FpSchema)).FschemaFlags) & (0x0001)) == (0x0001)) { + if !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb)).FpSchema)).FschemaFlags) & (DB_SchemaLoaded)) == (DB_SchemaLoaded)) { rc = Xsqlite3InitOne(tls, db, 0, pzErrMsg, uint32(0)) if rc != 0 { return rc @@ -111056,7 +108940,7 @@ func Xsqlite3Init(tls *libc.TLS, db uintptr, pzErrMsg uintptr) int32 { /* sqlite // All other schemas after the main schema. The "temp" schema must be last for i = ((*Sqlite3)(unsafe.Pointer(db)).FnDb - 1); i > 0; i-- { - if !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(i)*32)).FpSchema)).FschemaFlags) & (0x0001)) == (0x0001)) { + if !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(i)*32)).FpSchema)).FschemaFlags) & (DB_SchemaLoaded)) == (DB_SchemaLoaded)) { rc = Xsqlite3InitOne(tls, db, i, pzErrMsg, uint32(0)) if rc != 0 { return rc @@ -111066,22 +108950,22 @@ func Xsqlite3Init(tls *libc.TLS, db uintptr, pzErrMsg uintptr) int32 { /* sqlite if commit_internal != 0 { Xsqlite3CommitInternalChanges(tls, db) } - return 0 + return SQLITE_OK } // This routine is a no-op if the database schema is already initialized. // Otherwise, the schema is loaded. An error code is returned. func Xsqlite3ReadSchema(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:128787:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb if !(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0) { rc = Xsqlite3Init(tls, db, (pParse + 8 /* &.zErrMsg */)) - if rc != 0 { + if rc != SQLITE_OK { (*Parse)(unsafe.Pointer(pParse)).Frc = rc (*Parse)(unsafe.Pointer(pParse)).FnErr++ } else if (*Sqlite3)(unsafe.Pointer(db)).FnoSharedCache != 0 { - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0010)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaKnownOk) } } return rc @@ -111111,10 +108995,10 @@ func schemaIsValid(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:128809:13: */ // will be closed immediately after reading the meta-value. if !(Xsqlite3BtreeIsInReadTrans(tls, pBt) != 0) { rc = Xsqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0)) - if (rc == 7) || (rc == (10 | (int32(12) << 8))) { + if (rc == SQLITE_NOMEM) || (rc == (SQLITE_IOERR | (int32(12) << 8))) { Xsqlite3OomFault(tls, db) } - if rc != 0 { + if rc != SQLITE_OK { return } openedTransaction = 1 @@ -111123,11 +109007,11 @@ func schemaIsValid(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:128809:13: */ // Read the schema cookie from the database. If it does not match the // value stored as part of the in-memory schema representation, // set Parse.rc to SQLITE_SCHEMA. - Xsqlite3BtreeGetMeta(tls, pBt, 1, bp /* &cookie */) + Xsqlite3BtreeGetMeta(tls, pBt, BTREE_SCHEMA_VERSION, bp /* &cookie */) if *(*int32)(unsafe.Pointer(bp /* cookie */)) != (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FpSchema)).Fschema_cookie { Xsqlite3ResetOneSchema(tls, db, iDb) - (*Parse)(unsafe.Pointer(pParse)).Frc = 17 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_SCHEMA } // Close the transaction, if one was opened. @@ -111216,7 +109100,7 @@ func sqlite3Prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepF var mxLen int32 var pT uintptr *(*uintptr)(unsafe.Pointer(bp + 440 /* zErrMsg */)) = uintptr(0) - rc = 0 // Parsing context + rc = SQLITE_OK // Parsing context libc.Xmemset(tls, bp+16 /* &sParse */, 0, uint64((uintptr(0) + 212 /* &.aTempReg */))) libc.Xmemset(tls, ((bp + 16 /* &sParse */) + uintptr((uint64((uintptr(0) + 264 /* &.sLastToken */))))), 0, (uint64(unsafe.Sizeof(Parse{})) - (uint64((uintptr(0) + 264 /* &.sLastToken */))))) @@ -111226,7 +109110,7 @@ func sqlite3Prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepF // For a long-term use prepared statement avoid the use of // lookaside memory. - if !((prepFlags & U32(0x01)) != 0) { + if !((prepFlags & SQLITE_PREPARE_PERSISTENT) != 0) { goto __1 } (*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).FdisableLookaside++ @@ -111234,7 +109118,7 @@ func sqlite3Prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepF (*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0) __1: ; - (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).FdisableVtab = (U8(libc.Bool32((prepFlags & U32(0x04)) != U32(0)))) + (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).FdisableVtab = (U8(libc.Bool32((prepFlags & SQLITE_PREPARE_NO_VTAB) != U32(0)))) // Check to verify that it is possible to get a read lock on all // database schemas. The inability to get a read lock indicates that @@ -111299,13 +109183,13 @@ __2: if !((nBytes >= 0) && ((nBytes == 0) || (int32(*(*int8)(unsafe.Pointer(zSql + uintptr((nBytes - 1))))) != 0))) { goto __8 } - mxLen = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(1)*4)) + mxLen = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 1*4)) if !(nBytes > mxLen) { goto __10 } - Xsqlite3ErrorWithMsg(tls, db, 18, ts+15847 /* "statement too lo..." */, 0) - rc = Xsqlite3ApiExit(tls, db, 18) + Xsqlite3ErrorWithMsg(tls, db, SQLITE_TOOBIG, ts+15847 /* "statement too lo..." */, 0) + rc = Xsqlite3ApiExit(tls, db, SQLITE_TOOBIG) goto end_prepare __10: ; @@ -111327,10 +109211,10 @@ __8: __9: ; - if !((*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).Frc == 101) { + if !((*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).Frc == SQLITE_DONE) { goto __13 } - (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).Frc = 0 + (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).Frc = SQLITE_OK __13: ; if !((*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).FcheckSchema != 0) { @@ -111355,11 +109239,11 @@ __16: if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __17 } - (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).Frc = 7 + (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).Frc = SQLITE_NOMEM __17: ; rc = (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).Frc - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __18 } if !((*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).FpVdbe != 0) { @@ -111414,8 +109298,8 @@ func sqlite3LockAndPrepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32 } Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) Xsqlite3BtreeEnterAll(tls, db) - for ok := true; ok; ok = ((rc == (1 | (int32(2) << 8))) || - ((rc == 17) && ((func() int32 { Xsqlite3ResetOneSchema(tls, db, -1); return libc.PostIncInt32(&cnt, 1) }()) == 0))) { + for ok := true; ok; ok = ((rc == (SQLITE_ERROR | (int32(2) << 8))) || + ((rc == SQLITE_SCHEMA) && ((func() int32 { Xsqlite3ResetOneSchema(tls, db, -1); return libc.PostIncInt32(&cnt, 1) }()) == 0))) { // Make multiple attempts to compile the SQL, until it either succeeds // or encounters a permanent error. A schema problem after one schema // reset is considered a permanent error. @@ -111453,7 +109337,7 @@ func Xsqlite3Reprepare(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:129101:20: prepFlags = Xsqlite3VdbePrepareFlags(tls, p) rc = sqlite3LockAndPrepare(tls, db, zSql, -1, uint32(prepFlags), p, bp /* &pNew */, uintptr(0)) if rc != 0 { - if rc == 7 { + if rc == SQLITE_NOMEM { Xsqlite3OomFault(tls, db) } @@ -111465,7 +109349,7 @@ func Xsqlite3Reprepare(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:129101:20: Xsqlite3TransferBindings(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */)), p) Xsqlite3VdbeResetStepResult(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */))) Xsqlite3VdbeFinalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */))) - return 0 + return SQLITE_OK } // Two versions of the official API. Legacy and new use. In the legacy @@ -111488,7 +109372,7 @@ func Xsqlite3_prepare_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, // parameter. // // Proof in that the 5th parameter to sqlite3LockAndPrepare is 0 - rc = sqlite3LockAndPrepare(tls, db, zSql, nBytes, uint32(0x80), uintptr(0), + rc = sqlite3LockAndPrepare(tls, db, zSql, nBytes, SQLITE_PREPARE_SAVESQL, uintptr(0), ppStmt, pzTail) return rc @@ -111504,7 +109388,7 @@ func Xsqlite3_prepare_v3(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, // Proof by comparison to the implementation of sqlite3_prepare_v2() // directly above. rc = sqlite3LockAndPrepare(tls, db, zSql, nBytes, - (uint32(0x80) | (prepFlags & uint32(0x0f))), + (SQLITE_PREPARE_SAVESQL | (prepFlags & SQLITE_PREPARE_MASK)), uintptr(0), ppStmt, pzTail) return rc @@ -111520,7 +109404,7 @@ func sqlite3Prepare16(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, pre // tricky bit is figuring out the pointer to return in *pzTail. var zSql8 uintptr *(*uintptr)(unsafe.Pointer(bp /* zTail8 */)) = uintptr(0) - var rc int32 = 0 + var rc int32 = SQLITE_OK *(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0) if !(Xsqlite3SafetyCheckOk(tls, db) != 0) || (zSql == uintptr(0)) { @@ -111534,7 +109418,7 @@ func sqlite3Prepare16(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, pre nBytes = sz } Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - zSql8 = Xsqlite3Utf16to8(tls, db, zSql, nBytes, uint8(2)) + zSql8 = Xsqlite3Utf16to8(tls, db, zSql, nBytes, SQLITE_UTF16LE) if zSql8 != 0 { rc = sqlite3LockAndPrepare(tls, db, zSql8, -1, prepFlags, uintptr(0), ppStmt, bp /* &zTail8 */) } @@ -111568,7 +109452,7 @@ func Xsqlite3_prepare16(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, p func Xsqlite3_prepare16_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) int32 { /* sqlite3.c:129268:16: */ var rc int32 - rc = sqlite3Prepare16(tls, db, zSql, nBytes, uint32(0x80), ppStmt, pzTail) + rc = sqlite3Prepare16(tls, db, zSql, nBytes, SQLITE_PREPARE_SAVESQL, ppStmt, pzTail) // VERIFY: F13021 return rc } @@ -111576,7 +109460,7 @@ func Xsqlite3_prepare16_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32 func Xsqlite3_prepare16_v3(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags uint32, ppStmt uintptr, pzTail uintptr) int32 { /* sqlite3.c:129280:16: */ var rc int32 rc = sqlite3Prepare16(tls, db, zSql, nBytes, - (uint32(0x80) | (prepFlags & uint32(0x0f))), + (SQLITE_PREPARE_SAVESQL | (prepFlags & SQLITE_PREPARE_MASK)), ppStmt, pzTail) // VERIFY: F13021 return rc @@ -111739,16 +109623,16 @@ func Xsqlite3SelectNew(tls *libc.TLS, pParse uintptr, pEList uintptr, pSrc uintp } if pEList == uintptr(0) { pEList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), - Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 177, uintptr(0))) + Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ASTERISK, uintptr(0))) } (*Select)(unsafe.Pointer(pNew)).FpEList = pEList - (*Select)(unsafe.Pointer(pNew)).Fop = U8(136) + (*Select)(unsafe.Pointer(pNew)).Fop = TK_SELECT (*Select)(unsafe.Pointer(pNew)).FselFlags = selFlags (*Select)(unsafe.Pointer(pNew)).FiLimit = 0 (*Select)(unsafe.Pointer(pNew)).FiOffset = 0 (*Select)(unsafe.Pointer(pNew)).FselId = U32(libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnSelect, 1)) - *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */) + uintptr(0)*4)) = -1 - *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */) + uintptr(1)*4)) = -1 + *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */))) = -1 + *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */) + 1*4)) = -1 (*Select)(unsafe.Pointer(pNew)).FnSelectRow = int16(0) if pSrc == uintptr(0) { pSrc = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(SrcList{}))) @@ -111813,9 +109697,9 @@ func Xsqlite3JoinType(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, pC var p uintptr var i int32 var j int32 - *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + uintptr(0)*8)) = pA - *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + uintptr(1)*8)) = pB - *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + uintptr(2)*8)) = pC + *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */)) = pA + *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + 1*8)) = pB + *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + 2*8)) = pC for i = 0; (i < 3) && (*(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + uintptr(i)*8)) != 0); i++ { p = *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + uintptr(i)*8)) for j = 0; j < (int32(uint64(unsafe.Sizeof(aKeyword)) / uint64(unsafe.Sizeof(struct { @@ -111835,11 +109719,11 @@ func Xsqlite3JoinType(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, pC FnChar U8 Fcode U8 }{})))) { - jointype = jointype | (0x0040) + jointype = jointype | (JT_ERROR) break } } - if ((jointype & (0x0001 | 0x0020)) == (0x0001 | 0x0020)) || ((jointype & 0x0040) != 0) { + if ((jointype & (JT_INNER | JT_OUTER)) == (JT_INNER | JT_OUTER)) || ((jointype & JT_ERROR) != 0) { var zSp uintptr = ts + 12763 /* " " */ if pC == uintptr(0) { @@ -111847,12 +109731,12 @@ func Xsqlite3JoinType(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, pC } Xsqlite3ErrorMsg(tls, pParse, ts+15866 /* "unknown or unsup..." */, libc.VaList(bp, pA, pB, zSp, pC)) - jointype = 0x0001 - } else if ((jointype & 0x0020) != 0) && - ((jointype & (0x0008 | 0x0010)) != 0x0008) { + jointype = JT_INNER + } else if ((jointype & JT_OUTER) != 0) && + ((jointype & (JT_LEFT | JT_RIGHT)) != JT_LEFT) { Xsqlite3ErrorMsg(tls, pParse, ts+15910 /* "RIGHT and FULL O..." */, 0) - jointype = 0x0001 + jointype = JT_INNER } return jointype } @@ -111863,34 +109747,13 @@ var aKeyword = [7]struct { FnChar U8 Fcode U8 }{ - /* natural */ { - Fi: U8(0), - FnChar: U8(7), - Fcode: U8(0x0004)}, - /* left */ { - Fi: U8(6), - FnChar: U8(4), - Fcode: (U8(0x0008 | 0x0020))}, - /* outer */ { - Fi: U8(10), - FnChar: U8(5), - Fcode: U8(0x0020)}, - /* right */ { - Fi: U8(14), - FnChar: U8(5), - Fcode: (U8(0x0010 | 0x0020))}, - /* full */ { - Fi: U8(19), - FnChar: U8(4), - Fcode: (U8((0x0008 | 0x0010) | 0x0020))}, - /* inner */ { - Fi: U8(23), - FnChar: U8(5), - Fcode: U8(0x0001)}, - /* cross */ { - Fi: U8(28), - FnChar: U8(5), - Fcode: (U8(0x0001 | 0x0002))}, + /* natural */ {FnChar: U8(7), Fcode: JT_NATURAL}, + /* left */ {Fi: U8(6), FnChar: U8(4), Fcode: (U8(JT_LEFT | JT_OUTER))}, + /* outer */ {Fi: U8(10), FnChar: U8(5), Fcode: JT_OUTER}, + /* right */ {Fi: U8(14), FnChar: U8(5), Fcode: (U8(JT_RIGHT | JT_OUTER))}, + /* full */ {Fi: U8(19), FnChar: U8(4), Fcode: (U8((JT_LEFT | JT_RIGHT) | JT_OUTER))}, + /* inner */ {Fi: U8(23), FnChar: U8(5), Fcode: JT_INNER}, + /* cross */ {Fi: U8(28), FnChar: U8(5), Fcode: (U8(JT_INNER | JT_CROSS))}, } /* sqlite3.c:129513:5 */ // Return the index of a column in a table. Return -1 if the column @@ -111937,7 +109800,7 @@ func tableAndColumnIndex(tls *libc.TLS, pSrc uintptr, N int32, zCol uintptr, piT for i = 0; i < N; i++ { iCol = columnIndex(tls, (*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(i)*112)).FpTab, zCol) if (iCol >= 0) && - ((bIgnoreHidden == 0) || ((libc.Bool32((int32((*Column)(unsafe.Pointer(((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(i)*112)).FpTab)).FaCol + uintptr(iCol)*32))).FcolFlags) & 0x0002) != 0)) == 0)) { + ((bIgnoreHidden == 0) || ((libc.Bool32((int32((*Column)(unsafe.Pointer(((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(i)*112)).FpTab)).FaCol + uintptr(iCol)*32))).FcolFlags) & COLFLAG_HIDDEN) != 0)) == 0)) { if piTab != 0 { *(*int32)(unsafe.Pointer(piTab)) = i *(*int32)(unsafe.Pointer(piCol)) = iCol @@ -111966,9 +109829,9 @@ func addWhereTerm(tls *libc.TLS, pParse uintptr, pSrc uintptr, iLeft int32, iCol pE1 = Xsqlite3CreateColumnExpr(tls, db, pSrc, iLeft, iColLeft) pE2 = Xsqlite3CreateColumnExpr(tls, db, pSrc, iRight, iColRight) - pEq = Xsqlite3PExpr(tls, pParse, 53, pE1, pE2) + pEq = Xsqlite3PExpr(tls, pParse, TK_EQ, pE1, pE2) if (pEq != 0) && (isOuterJoin != 0) { - *(*U32)(unsafe.Pointer(pEq + 4 /* &.flags */)) |= (U32(0x000001)) + *(*U32)(unsafe.Pointer(pEq + 4 /* &.flags */)) |= (EP_FromJoin) (*Expr)(unsafe.Pointer(pEq)).FiRightJoinTable = I16((*Expr)(unsafe.Pointer(pE2)).FiTable) } @@ -112001,10 +109864,10 @@ func addWhereTerm(tls *libc.TLS, pParse uintptr, pSrc uintptr, iLeft int32, iCol // the output, which is incorrect. func Xsqlite3SetJoinExpr(tls *libc.TLS, p uintptr, iTable int32) { /* sqlite3.c:129680:21: */ for p != 0 { - *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= (U32(0x000001)) + *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= (EP_FromJoin) (*Expr)(unsafe.Pointer(p)).FiRightJoinTable = I16(iTable) - if (int32((*Expr)(unsafe.Pointer(p)).Fop) == 169) && (*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0) { + if (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_FUNCTION) && (*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0) { var i int32 for i = 0; i < (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))).FnExpr; i++ { Xsqlite3SetJoinExpr(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */))+8 /* &.a */)+uintptr(i)*32)).FpExpr, iTable) @@ -112022,11 +109885,11 @@ func Xsqlite3SetJoinExpr(tls *libc.TLS, p uintptr, iTable int32) { /* sqlite3.c: // This happens when a LEFT JOIN is simplified into an ordinary JOIN. func unsetJoinExpr(tls *libc.TLS, p uintptr, iTable int32) { /* sqlite3.c:129703:13: */ for p != 0 { - if (((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000001))) != U32(0)) && + if (((*Expr)(unsafe.Pointer((p))).Fflags & (EP_FromJoin)) != U32(0)) && ((iTable < 0) || (int32((*Expr)(unsafe.Pointer(p)).FiRightJoinTable) == iTable)) { - *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(0x000001)) + *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(EP_FromJoin))) } - if (int32((*Expr)(unsafe.Pointer(p)).Fop) == 169) && (*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0) { + if (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_FUNCTION) && (*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0) { var i int32 for i = 0; i < (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))).FnExpr; i++ { unsetJoinExpr(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */))+8 /* &.a */)+uintptr(i)*32)).FpExpr, iTable) @@ -112060,8 +109923,8 @@ func sqliteProcessJoin(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* sqli var pRight uintptr // Right table being joined pSrc = (*Select)(unsafe.Pointer(p)).FpSrc - pLeft = ((pSrc + 8 /* &.a */) + uintptr(0)*112) - pRight = (pLeft + uintptr(1)*112) + pLeft = (pSrc + 8 /* &.a */) + pRight = (pLeft + 1*112) i = 0 __1: if !(i < ((*SrcList)(unsafe.Pointer(pSrc)).FnSrc - 1)) { @@ -112074,11 +109937,11 @@ __1: if ((*SrcList_item)(unsafe.Pointer(pLeft)).FpTab == uintptr(0)) || (pRightTab == uintptr(0)) { goto __2 } - isOuter = (libc.Bool32((int32((*SrcList_item)(unsafe.Pointer(pRight)).Ffg.Fjointype) & 0x0020) != 0)) + isOuter = (libc.Bool32((int32((*SrcList_item)(unsafe.Pointer(pRight)).Ffg.Fjointype) & JT_OUTER) != 0)) // When the NATURAL keyword is present, add WHERE clause terms for // every column that the two tables have in common. - if (int32((*SrcList_item)(unsafe.Pointer(pRight)).Ffg.Fjointype) & 0x0004) != 0 { + if (int32((*SrcList_item)(unsafe.Pointer(pRight)).Ffg.Fjointype) & JT_NATURAL) != 0 { if ((*SrcList_item)(unsafe.Pointer(pRight)).FpOn != 0) || ((*SrcList_item)(unsafe.Pointer(pRight)).FpUsing != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+15999 /* "a NATURAL join m..." */, libc.VaList(bp, 0)) @@ -112091,7 +109954,7 @@ __1: // var iLeftCol int32 at bp+20, 4 // Matching column in the left table - if (int32((*Column)(unsafe.Pointer(((*Table)(unsafe.Pointer(pRightTab)).FaCol + uintptr(j)*32))).FcolFlags) & 0x0002) != 0 { + if (int32((*Column)(unsafe.Pointer(((*Table)(unsafe.Pointer(pRightTab)).FaCol + uintptr(j)*32))).FcolFlags) & COLFLAG_HIDDEN) != 0 { continue } zName = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pRightTab)).FaCol + uintptr(j)*32)).FzName @@ -112183,7 +110046,7 @@ func makeSorterRecord(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uint if (*SortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad != 0 { innerLoopLoadRow(tls, pParse, pSelect, (*SortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad) } - Xsqlite3VdbeAddOp3(tls, v, 91, (regBase + nOBSat), (nBase - nOBSat), regOut) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (regBase + nOBSat), (nBase - nOBSat), regOut) return regOut } @@ -112191,7 +110054,7 @@ func makeSorterRecord(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uint // through regData+nData-1 onto the sorter. func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintptr, regData int32, regOrigData int32, nData int32, nPrefixReg int32) { /* sqlite3.c:129882:13: */ var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe // Stmt under construction - var bSeq int32 = (libc.Bool32((int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & 0x01) == 0)) + var bSeq int32 = (libc.Bool32((int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & SORTFLAG_UseSorter) == 0)) var nExpr int32 = (*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr // No. of ORDER BY terms var nBase int32 = ((nExpr + bSeq) + nData) // Fields in sorter record var regBase int32 // Regs for sorter record @@ -112229,14 +110092,14 @@ func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintpt } (*SortCtx)(unsafe.Pointer(pSort)).FlabelDone = Xsqlite3VdbeMakeLabel(tls, pParse) Xsqlite3ExprCodeExprList(tls, pParse, (*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy, regBase, regOrigData, - (uint8(0x01 | (func() int32 { + (uint8(SQLITE_ECEL_DUP | (func() int32 { if regOrigData != 0 { - return 0x04 + return SQLITE_ECEL_REF } return 0 }())))) if bSeq != 0 { - Xsqlite3VdbeAddOp2(tls, v, 119, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor, (regBase + nExpr)) + Xsqlite3VdbeAddOp2(tls, v, OP_Sequence, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor, (regBase + nExpr)) } if (nPrefixReg == 0) && (nData > 0) { Xsqlite3ExprCodeMove(tls, pParse, regData, ((regBase + nExpr) + bSeq), nData) @@ -112254,12 +110117,12 @@ func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintpt *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += ((*SortCtx)(unsafe.Pointer(pSort)).FnOBSat) nKey = ((nExpr - (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat) + bSeq) if bSeq != 0 { - addrFirst = Xsqlite3VdbeAddOp1(tls, v, 20, (regBase + nExpr)) + addrFirst = Xsqlite3VdbeAddOp1(tls, v, OP_IfNot, (regBase + nExpr)) } else { - addrFirst = Xsqlite3VdbeAddOp1(tls, v, 113, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor) + addrFirst = Xsqlite3VdbeAddOp1(tls, v, OP_SequenceTest, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor) } - Xsqlite3VdbeAddOp3(tls, v, 86, regPrevKey, regBase, (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat) + Xsqlite3VdbeAddOp3(tls, v, OP_Compare, regPrevKey, regBase, (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat) pOp = Xsqlite3VdbeGetOp(tls, v, (*SortCtx)(unsafe.Pointer(pSort)).FaddrSortIndex) if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { return @@ -112273,13 +110136,13 @@ func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintpt ((int32((*KeyInfo)(unsafe.Pointer(pKI)).FnAllField) - int32((*KeyInfo)(unsafe.Pointer(pKI)).FnKeyField)) - 1)) pOp = uintptr(0) // Ensure pOp not used after sqltie3VdbeAddOp3() addrJmp = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp3(tls, v, 16, (addrJmp + 1), 0, (addrJmp + 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, (addrJmp + 1), 0, (addrJmp + 1)) (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut = Xsqlite3VdbeMakeLabel(tls, pParse) (*SortCtx)(unsafe.Pointer(pSort)).FregReturn = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 12, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) - Xsqlite3VdbeAddOp1(tls, v, 138, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) + Xsqlite3VdbeAddOp1(tls, v, OP_ResetSorter, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor) if iLimit != 0 { - Xsqlite3VdbeAddOp2(tls, v, 20, iLimit, (*SortCtx)(unsafe.Pointer(pSort)).FlabelDone) + Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, iLimit, (*SortCtx)(unsafe.Pointer(pSort)).FlabelDone) } Xsqlite3VdbeJumpHere(tls, v, addrFirst) @@ -112302,21 +110165,21 @@ func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintpt // just bypass the row insert logic. See the header comment on the // sqlite3WhereOrderByLimitOptLabel() function for additional info. var iCsr int32 = (*SortCtx)(unsafe.Pointer(pSort)).FiECursor - Xsqlite3VdbeAddOp2(tls, v, 49, iLimit, (Xsqlite3VdbeCurrentAddr(tls, v) + 4)) + Xsqlite3VdbeAddOp2(tls, v, OP_IfNotZero, iLimit, (Xsqlite3VdbeCurrentAddr(tls, v) + 4)) - Xsqlite3VdbeAddOp2(tls, v, 33, iCsr, 0) - iSkip = Xsqlite3VdbeAddOp4Int(tls, v, 38, + Xsqlite3VdbeAddOp2(tls, v, OP_Last, iCsr, 0) + iSkip = Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxLE, iCsr, 0, (regBase + nOBSat), (nExpr - nOBSat)) - Xsqlite3VdbeAddOp1(tls, v, 122, iCsr) + Xsqlite3VdbeAddOp1(tls, v, OP_Delete, iCsr) } if regRecord == 0 { regRecord = makeSorterRecord(tls, pParse, pSort, pSelect, regBase, nBase) } - if (int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & 0x01) != 0 { - op = 131 + if (int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & SORTFLAG_UseSorter) != 0 { + op = OP_SorterInsert } else { - op = 130 + op = OP_IdxInsert } Xsqlite3VdbeAddOp4Int(tls, v, op, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor, regRecord, (regBase + nOBSat), (nBase - nOBSat)) @@ -112334,7 +110197,7 @@ func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintpt // Add code to implement the OFFSET func codeOffset(tls *libc.TLS, v uintptr, iOffset int32, iContinue int32) { /* sqlite3.c:130024:13: */ if iOffset > 0 { - Xsqlite3VdbeAddOp3(tls, v, 48, iOffset, iContinue, 1) + Xsqlite3VdbeAddOp3(tls, v, OP_IfPos, iOffset, iContinue, 1) } } @@ -112352,10 +110215,10 @@ func codeDistinct(tls *libc.TLS, pParse uintptr, iTab int32, addrRepeat int32, N v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe r1 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp4Int(tls, v, 30, iTab, addrRepeat, iMem, N) - Xsqlite3VdbeAddOp3(tls, v, 91, iMem, N, r1) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iTab, r1, iMem, N) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, iTab, addrRepeat, iMem, N) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, iMem, N, r1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iTab, r1, iMem, N) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_USESEEKRESULT) Xsqlite3ReleaseTempReg(tls, pParse, r1) } @@ -112391,7 +110254,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo if pDistinct != 0 { hasDistinct = int32((*DistinctCtx)(unsafe.Pointer(pDistinct)).FeTnctType) } else { - hasDistinct = 0 + hasDistinct = WHERE_DISTINCT_NOOP } if (pSort != 0) && ((*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy == uintptr(0)) { pSort = uintptr(0) @@ -112407,7 +110270,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo if (*SelectDest)(unsafe.Pointer(pDest)).FiSdst == 0 { if pSort != 0 { nPrefixReg = (*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr - if !((int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & 0x01) != 0) { + if !((int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & SORTFLAG_UseSorter) != 0) { nPrefixReg++ } *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (nPrefixReg) @@ -112426,27 +110289,27 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo regOrig = libc.AssignInt32(®Result, (*SelectDest)(unsafe.Pointer(pDest)).FiSdst) if srcTab >= 0 { for i = 0; i < nResultCol; i++ { - Xsqlite3VdbeAddOp3(tls, v, 89, srcTab, i, (regResult + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, srcTab, i, (regResult + i)) } - } else if eDest != 3 { + } else if eDest != SRT_Exists { // If the destination is an EXISTS(...) expression, the actual // values returned by the SELECT are not required. var ecelFlags U8 // "ecel" is an abbreviation of "ExprCodeExprList" var pEList uintptr - if ((eDest == 10) || (eDest == 9)) || (eDest == 13) { - ecelFlags = U8(0x01) + if ((eDest == SRT_Mem) || (eDest == SRT_Output)) || (eDest == SRT_Coroutine) { + ecelFlags = SQLITE_ECEL_DUP } else { ecelFlags = U8(0) } - if (((pSort != 0) && (hasDistinct == 0)) && (eDest != 12)) && (eDest != 14) { + if (((pSort != 0) && (hasDistinct == 0)) && (eDest != SRT_EphemTab)) && (eDest != SRT_Table) { // For each expression in p->pEList that is a copy of an expression in // the ORDER BY clause (pSort->pOrderBy), set the associated // iOrderByCol value to one more than the index of the ORDER BY // expression within the sort-key that pushOntoSorter() will generate. // This allows the p->pEList field to be omitted from the sorted record, // saving space and CPU cycles. - ecelFlags = U8(int32(ecelFlags) | (0x08 | 0x04)) + ecelFlags = U8(int32(ecelFlags) | (SQLITE_ECEL_OMITREF | SQLITE_ECEL_REF)) for i = (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat; i < (*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr; i++ { var j int32 @@ -112469,7 +110332,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo (*RowLoadInfo)(unsafe.Pointer(bp /* &sRowLoadInfo */)).FregResult = regResult (*RowLoadInfo)(unsafe.Pointer(bp /* &sRowLoadInfo */)).FecelFlags = ecelFlags if (((*Select)(unsafe.Pointer(p)).FiLimit != 0) && - ((int32(ecelFlags) & 0x08) != 0)) && + ((int32(ecelFlags) & SQLITE_ECEL_OMITREF) != 0)) && (nPrefixReg > 0) { (*SortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad = bp /* &sRowLoadInfo */ @@ -112484,7 +110347,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // part of the result. if hasDistinct != 0 { switch int32((*DistinctCtx)(unsafe.Pointer(pDistinct)).FeTnctType) { - case 2: + case WHERE_DISTINCT_ORDERED: { var pOp uintptr // No longer required OpenEphemeral instr. var iJump int32 // Jump destination @@ -112501,7 +110364,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // row is all NULLs. Xsqlite3VdbeChangeToNoop(tls, v, (*DistinctCtx)(unsafe.Pointer(pDistinct)).FaddrTnct) pOp = Xsqlite3VdbeGetOp(tls, v, (*DistinctCtx)(unsafe.Pointer(pDistinct)).FaddrTnct) - (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(72) + (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = OP_Null (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = 1 (*VdbeOp)(unsafe.Pointer(pOp)).Fp2 = regPrev pOp = uintptr(0) // Ensure pOp is not used after sqlite3VdbeAddOp() @@ -112510,23 +110373,23 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo for i = 0; i < nResultCol; i++ { var pColl uintptr = Xsqlite3ExprCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpEList+8 /* &.a */)+uintptr(i)*32)).FpExpr) if i < (nResultCol - 1) { - Xsqlite3VdbeAddOp3(tls, v, 52, (regResult + i), iJump, (regPrev + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Ne, (regResult + i), iJump, (regPrev + i)) } else { - Xsqlite3VdbeAddOp3(tls, v, 53, (regResult + i), iContinue, (regPrev + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Eq, (regResult + i), iContinue, (regPrev + i)) } Xsqlite3VdbeChangeP4(tls, v, -1, pColl, -2) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x80)) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NULLEQ) } - Xsqlite3VdbeAddOp3(tls, v, 77, regResult, regPrev, (nResultCol - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regResult, regPrev, (nResultCol - 1)) break } fallthrough - case 1: + case WHERE_DISTINCT_UNIQUE: { Xsqlite3VdbeChangeToNoop(tls, v, (*DistinctCtx)(unsafe.Pointer(pDistinct)).FaddrTnct) break @@ -112551,12 +110414,12 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo switch eDest { // In this mode, write each query result to the key of the temporary // table iParm. - case 1: + case SRT_Union: { var r1 int32 r1 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 91, regResult, nResultCol, r1) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iParm, r1, regResult, nResultCol) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regResult, nResultCol, r1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, regResult, nResultCol) Xsqlite3ReleaseTempReg(tls, pParse, r1) break @@ -112565,35 +110428,35 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // Construct a record from the query result, but instead of // saving that record, use it as a key to delete elements from // the temporary table iParm. - case 2: + case SRT_Except: { - Xsqlite3VdbeAddOp3(tls, v, 132, iParm, regResult, nResultCol) + Xsqlite3VdbeAddOp3(tls, v, OP_IdxDelete, iParm, regResult, nResultCol) break } // Store the result as data using a unique key. - case 5: + case SRT_Fifo: fallthrough - case 6: + case SRT_DistFifo: fallthrough - case 14: + case SRT_Table: fallthrough - case 12: + case SRT_EphemTab: { var r1 int32 = Xsqlite3GetTempRange(tls, pParse, (nPrefixReg + 1)) - Xsqlite3VdbeAddOp3(tls, v, 91, regResult, nResultCol, (r1 + nPrefixReg)) - if eDest == 6 { + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regResult, nResultCol, (r1 + nPrefixReg)) + if eDest == SRT_DistFifo { // If the destination is DistFifo, then cursor (iParm+1) is open // on an ephemeral index. If the current row is already present // in the index, do not write it to the output. If not, add the // current row to the index and proceed with writing it to the // output table as well. var addr int32 = (Xsqlite3VdbeCurrentAddr(tls, v) + 4) - Xsqlite3VdbeAddOp4Int(tls, v, 30, (iParm + 1), addr, r1, 0) + Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, (iParm + 1), addr, r1, 0) - Xsqlite3VdbeAddOp4Int(tls, v, 130, (iParm + 1), r1, regResult, nResultCol) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, (iParm + 1), r1, regResult, nResultCol) } if pSort != 0 { @@ -112601,9 +110464,9 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo pushOntoSorter(tls, pParse, pSort, p, (r1 + nPrefixReg), regOrig, 1, nPrefixReg) } else { var r2 int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 120, iParm, r2) - Xsqlite3VdbeAddOp3(tls, v, 121, iParm, r1, r2) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x08)) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iParm, r2) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iParm, r1, r2) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_APPEND) Xsqlite3ReleaseTempReg(tls, pParse, r2) } Xsqlite3ReleaseTempRange(tls, pParse, r1, (nPrefixReg + 1)) @@ -112611,7 +110474,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo } - case 15: + case SRT_Upfrom: { if pSort != 0 { pushOntoSorter(tls, @@ -112623,14 +110486,14 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // If the UPDATE FROM join is an aggregate that matches no rows, it // might still be trying to return one row, because that is what // aggregates do. Don't record that empty row in the output table. - Xsqlite3VdbeAddOp2(tls, v, 50, regResult, iBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regResult, iBreak) - Xsqlite3VdbeAddOp3(tls, v, 91, + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (regResult + (libc.Bool32(i2 < 0))), (nResultCol - (libc.Bool32(i2 < 0))), r1) if i2 < 0 { - Xsqlite3VdbeAddOp3(tls, v, 121, iParm, r1, regResult) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iParm, r1, regResult) } else { - Xsqlite3VdbeAddOp4Int(tls, v, 130, iParm, r1, regResult, i2) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, regResult, i2) } } break @@ -112640,7 +110503,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // If we are creating a set for an "expr IN (SELECT ...)" construct, // then there should be a single item on the stack. Write this // item into the set table with bogus data. - case 11: + case SRT_Set: { if pSort != 0 { // At first glance you would think we could optimize out the @@ -112652,9 +110515,9 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo } else { var r1 int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp4(tls, v, 91, regResult, nResultCol, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regResult, nResultCol, r1, (*SelectDest)(unsafe.Pointer(pDest)).FzAffSdst, nResultCol) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iParm, r1, regResult, nResultCol) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, regResult, nResultCol) Xsqlite3ReleaseTempReg(tls, pParse, r1) } break @@ -112662,9 +110525,9 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo } // If any row exist in the result set, record that fact and abort. - case 3: + case SRT_Exists: { - Xsqlite3VdbeAddOp2(tls, v, 69, 1, iParm) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, iParm) // The LIMIT clause will terminate the loop for us break @@ -112673,7 +110536,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // If this is a scalar select that is part of an expression, then // store the results in the appropriate memory cell or array of // memory cells and break out of the scan loop. - case 10: + case SRT_Mem: { if pSort != 0 { @@ -112687,18 +110550,18 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo } - case 13: + case SRT_Coroutine: fallthrough // Send data to a co-routine - case 9: + case SRT_Output: { // Return the results if pSort != 0 { pushOntoSorter(tls, pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg) - } else if eDest == 13 { - Xsqlite3VdbeAddOp1(tls, v, 14, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm) + } else if eDest == SRT_Coroutine { + Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm) } else { - Xsqlite3VdbeAddOp2(tls, v, 80, regResult, nResultCol) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, regResult, nResultCol) } break @@ -112709,9 +110572,9 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // index with pSO->nExpr+2 columns. Build a key using pSO for the first // pSO->nExpr columns, then make sure all keys are unique by adding a // final OP_Sequence column. The last column is the record as a blob. - case 8: + case SRT_DistQueue: fallthrough - case 7: + case SRT_Queue: { var nKey int32 var r1 int32 @@ -112725,27 +110588,27 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo r1 = Xsqlite3GetTempReg(tls, pParse) r2 = Xsqlite3GetTempRange(tls, pParse, (nKey + 2)) r3 = ((r2 + nKey) + 1) - if eDest == 8 { + if eDest == SRT_DistQueue { // If the destination is DistQueue, then cursor (iParm+1) is open // on a second ephemeral index that holds all values every previously // added to the queue. - addrTest = Xsqlite3VdbeAddOp4Int(tls, v, 30, (iParm + 1), 0, + addrTest = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, (iParm + 1), 0, regResult, nResultCol) } - Xsqlite3VdbeAddOp3(tls, v, 91, regResult, nResultCol, r3) - if eDest == 8 { - Xsqlite3VdbeAddOp2(tls, v, 130, (iParm + 1), r3) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regResult, nResultCol, r3) + if eDest == SRT_DistQueue { + Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, (iParm + 1), r3) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_USESEEKRESULT) } for i = 0; i < nKey; i++ { - Xsqlite3VdbeAddOp2(tls, v, 78, + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, ((regResult + int32(*(*U16)(unsafe.Pointer(((pSO + 8 /* &.a */) + uintptr(i)*32 + 24 /* &.u */ /* &.x */) /* &.iOrderByCol */)))) - 1), (r2 + i)) } - Xsqlite3VdbeAddOp2(tls, v, 119, iParm, (r2 + nKey)) - Xsqlite3VdbeAddOp3(tls, v, 91, r2, (nKey + 2), r1) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iParm, r1, r2, (nKey + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_Sequence, iParm, (r2 + nKey)) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, r2, (nKey + 2), r1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, r2, (nKey + 2)) if addrTest != 0 { Xsqlite3VdbeJumpHere(tls, v, addrTest) } @@ -112771,7 +110634,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // there is a sorter, in which case the sorter has already limited // the output for us. if (pSort == uintptr(0)) && ((*Select)(unsafe.Pointer(p)).FiLimit != 0) { - Xsqlite3VdbeAddOp2(tls, v, 59, (*Select)(unsafe.Pointer(p)).FiLimit, iBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_DecrJumpZero, (*Select)(unsafe.Pointer(p)).FiLimit, iBreak) } } @@ -112787,7 +110650,7 @@ func Xsqlite3KeyInfoAlloc(tls *libc.TLS, db uintptr, N int32, X int32) uintptr { (*KeyInfo)(unsafe.Pointer(p)).Fenc = (*Sqlite3)(unsafe.Pointer(db)).Fenc (*KeyInfo)(unsafe.Pointer(p)).Fdb = db (*KeyInfo)(unsafe.Pointer(p)).FnRef = U32(1) - libc.Xmemset(tls, (p + uintptr(1)*40), 0, uint64(nExtra)) + libc.Xmemset(tls, (p + 1*40), 0, uint64(nExtra)) } else { Xsqlite3OomFault(tls, db) } @@ -112863,13 +110726,13 @@ func Xsqlite3KeyInfoFromExprList(tls *libc.TLS, pParse uintptr, pList uintptr, i func selectOpName(tls *libc.TLS, id int32) uintptr { /* sqlite3.c:130685:19: */ var z uintptr switch id { - case 133: + case TK_ALL: z = ts + 16168 /* "UNION ALL" */ break - case 135: + case TK_INTERSECT: z = ts + 16178 /* "INTERSECT" */ break - case 134: + case TK_EXCEPT: z = ts + 16188 /* "EXCEPT" */ break default: @@ -112925,18 +110788,18 @@ func generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, n var aOutEx uintptr = (*Select)(unsafe.Pointer(p)).FpEList + 8 /* &.a */ if (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut != 0 { - Xsqlite3VdbeAddOp2(tls, v, 12, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) Xsqlite3VdbeGoto(tls, v, addrBreak) Xsqlite3VdbeResolveLabel(tls, v, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) } iTab = (*SortCtx)(unsafe.Pointer(pSort)).FiECursor - if ((eDest == 9) || (eDest == 13)) || (eDest == 10) { + if ((eDest == SRT_Output) || (eDest == SRT_Coroutine)) || (eDest == SRT_Mem) { regRowid = 0 regRow = (*SelectDest)(unsafe.Pointer(pDest)).FiSdst } else { regRowid = Xsqlite3GetTempReg(tls, pParse) - if (eDest == 12) || (eDest == 14) { + if (eDest == SRT_EphemTab) || (eDest == SRT_Table) { regRow = Xsqlite3GetTempReg(tls, pParse) nColumn = 0 } else { @@ -112944,24 +110807,24 @@ func generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, n } } nKey = ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat) - if (int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & 0x01) != 0 { + if (int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & SORTFLAG_UseSorter) != 0 { var regSortOut int32 = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) iSortTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) if (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut != 0 { - addrOnce = Xsqlite3VdbeAddOp0(tls, v, 17) + addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once) } - Xsqlite3VdbeAddOp3(tls, v, 114, iSortTab, regSortOut, + Xsqlite3VdbeAddOp3(tls, v, OP_OpenPseudo, iSortTab, regSortOut, (((nKey + 1) + nColumn) + nRefKey)) if addrOnce != 0 { Xsqlite3VdbeJumpHere(tls, v, addrOnce) } - addr = (1 + Xsqlite3VdbeAddOp2(tls, v, 35, iTab, addrBreak)) + addr = (1 + Xsqlite3VdbeAddOp2(tls, v, OP_SorterSort, iTab, addrBreak)) codeOffset(tls, v, (*Select)(unsafe.Pointer(p)).FiOffset, addrContinue) - Xsqlite3VdbeAddOp3(tls, v, 125, iTab, regSortOut, iSortTab) + Xsqlite3VdbeAddOp3(tls, v, OP_SorterData, iTab, regSortOut, iSortTab) bSeq = 0 } else { - addr = (1 + Xsqlite3VdbeAddOp2(tls, v, 36, iTab, addrBreak)) + addr = (1 + Xsqlite3VdbeAddOp2(tls, v, OP_Sort, iTab, addrBreak)) codeOffset(tls, v, (*Select)(unsafe.Pointer(p)).FiOffset, addrContinue) iSortTab = iTab bSeq = 1 @@ -112981,46 +110844,46 @@ func generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, n } else { iRead = libc.PostDecInt32(&iCol, 1) } - Xsqlite3VdbeAddOp3(tls, v, 89, iSortTab, iRead, (regRow + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iSortTab, iRead, (regRow + i)) } } switch eDest { - case 14: + case SRT_Table: fallthrough - case 12: + case SRT_EphemTab: { - Xsqlite3VdbeAddOp3(tls, v, 89, iSortTab, (nKey + bSeq), regRow) - Xsqlite3VdbeAddOp2(tls, v, 120, iParm, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, iParm, regRow, regRowid) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x08)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iSortTab, (nKey + bSeq), regRow) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iParm, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iParm, regRow, regRowid) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_APPEND) break } - case 11: + case SRT_Set: { - Xsqlite3VdbeAddOp4(tls, v, 91, regRow, nColumn, regRowid, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regRow, nColumn, regRowid, (*SelectDest)(unsafe.Pointer(pDest)).FzAffSdst, nColumn) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iParm, regRowid, regRow, nColumn) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, regRowid, regRow, nColumn) break } - case 10: + case SRT_Mem: { // The LIMIT clause will terminate the loop for us break } - case 15: + case SRT_Upfrom: { var i2 int32 = (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm2 var r1 int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 91, (regRow + (libc.Bool32(i2 < 0))), (nColumn - (libc.Bool32(i2 < 0))), r1) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (regRow + (libc.Bool32(i2 < 0))), (nColumn - (libc.Bool32(i2 < 0))), r1) if i2 < 0 { - Xsqlite3VdbeAddOp3(tls, v, 121, iParm, r1, regRow) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iParm, r1, regRow) } else { - Xsqlite3VdbeAddOp4Int(tls, v, 130, iParm, r1, regRow, i2) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, regRow, i2) } break @@ -113028,17 +110891,17 @@ func generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, n default: { - if eDest == 9 { - Xsqlite3VdbeAddOp2(tls, v, 80, (*SelectDest)(unsafe.Pointer(pDest)).FiSdst, nColumn) + if eDest == SRT_Output { + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, (*SelectDest)(unsafe.Pointer(pDest)).FiSdst, nColumn) } else { - Xsqlite3VdbeAddOp1(tls, v, 14, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm) + Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm) } break } } if regRowid != 0 { - if eDest == 11 { + if eDest == SRT_Set { Xsqlite3ReleaseTempRange(tls, pParse, regRow, nColumn) } else { Xsqlite3ReleaseTempReg(tls, pParse, regRow) @@ -113047,13 +110910,13 @@ func generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, n } // The bottom of the loop Xsqlite3VdbeResolveLabel(tls, v, addrContinue) - if (int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & 0x01) != 0 { - Xsqlite3VdbeAddOp2(tls, v, 3, iTab, addr) + if (int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & SORTFLAG_UseSorter) != 0 { + Xsqlite3VdbeAddOp2(tls, v, OP_SorterNext, iTab, addr) } else { - Xsqlite3VdbeAddOp2(tls, v, 5, iTab, addr) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iTab, addr) } if (*SortCtx)(unsafe.Pointer(pSort)).FregReturn != 0 { - Xsqlite3VdbeAddOp1(tls, v, 65, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn) } Xsqlite3VdbeResolveLabel(tls, v, addrBreak) } @@ -113091,7 +110954,7 @@ func columnTypeImpl(tls *libc.TLS, pNC uintptr, pExpr uintptr, pzOrigDb uintptr, *(*uintptr)(unsafe.Pointer(bp + 72 /* zOrigCol */)) = uintptr(0) switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) { - case 164: + case TK_COLUMN: { // The expression is a column. Locate the table the column is being // extracted from in NameContext.pSrcList. This table may be real @@ -113171,7 +111034,7 @@ func columnTypeImpl(tls *libc.TLS, pNC uintptr, pExpr uintptr, pzOrigDb uintptr, break } - case 136: + case TK_SELECT: { // The expression is a sub-select. Return the declaration type and // origin info for the single column in the result set of the SELECT @@ -113179,7 +111042,7 @@ func columnTypeImpl(tls *libc.TLS, pNC uintptr, pExpr uintptr, pzOrigDb uintptr, // var sNC NameContext at bp+80, 56 var pS uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) - var p uintptr = (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pS)).FpEList + 8 /* &.a */) + uintptr(0)*32)).FpExpr + var p uintptr = (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pS)).FpEList + 8 /* &.a */))).FpExpr (*NameContext)(unsafe.Pointer(bp + 80 /* &sNC */)).FpSrcList = (*Select)(unsafe.Pointer(pS)).FpSrc (*NameContext)(unsafe.Pointer(bp + 80 /* &sNC */)).FpNext = pNC @@ -113223,10 +111086,10 @@ func generateColumnTypes(tls *libc.TLS, pParse uintptr, pTabList uintptr, pEList // The vdbe must make its own copy of the column-type and other // column specific strings, in case the schema is reset before this // virtual machine is deleted. - Xsqlite3VdbeSetColName(tls, v, i, 2, *(*uintptr)(unsafe.Pointer(bp + 56 /* zOrigDb */)), libc.UintptrFromInt32(-1)) - Xsqlite3VdbeSetColName(tls, v, i, 3, *(*uintptr)(unsafe.Pointer(bp + 64 /* zOrigTab */)), libc.UintptrFromInt32(-1)) - Xsqlite3VdbeSetColName(tls, v, i, 4, *(*uintptr)(unsafe.Pointer(bp + 72 /* zOrigCol */)), libc.UintptrFromInt32(-1)) - Xsqlite3VdbeSetColName(tls, v, i, 1, zType, libc.UintptrFromInt32(-1)) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_DATABASE, *(*uintptr)(unsafe.Pointer(bp + 56 /* zOrigDb */)), libc.UintptrFromInt32(-1)) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_TABLE, *(*uintptr)(unsafe.Pointer(bp + 64 /* zOrigTab */)), libc.UintptrFromInt32(-1)) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_COLUMN, *(*uintptr)(unsafe.Pointer(bp + 72 /* zOrigCol */)), libc.UintptrFromInt32(-1)) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_DECLTYPE, zType, libc.UintptrFromInt32(-1)) } } @@ -113288,19 +111151,19 @@ func generateColumnNames(tls *libc.TLS, pParse uintptr, pSelect uintptr) { /* sq pEList = (*Select)(unsafe.Pointer(pSelect)).FpEList (*Parse)(unsafe.Pointer(pParse)).FcolNamesSet = U8(1) - fullName = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000004)) != uint64(0))) - srcName = (libc.Bool32((((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000040)) != uint64(0)) || (fullName != 0))) + fullName = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_FullColNames) != uint64(0))) + srcName = (libc.Bool32((((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ShortColNames) != uint64(0)) || (fullName != 0))) Xsqlite3VdbeSetNumCols(tls, v, (*ExprList)(unsafe.Pointer(pEList)).FnExpr) for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ { var p uintptr = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(i)*32)).FpExpr // Agg processing has not run yet // Covering idx not yet coded - if ((*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FzEName != 0) && ((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0) { + if ((*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FzEName != 0) && ((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME) { // An AS clause always takes first priority var zName uintptr = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(i)*32)).FzEName - Xsqlite3VdbeSetColName(tls, v, i, 0, zName, libc.UintptrFromInt32(-1)) - } else if (srcName != 0) && (int32((*Expr)(unsafe.Pointer(p)).Fop) == 164) { + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zName, libc.UintptrFromInt32(-1)) + } else if (srcName != 0) && (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN) { var zCol uintptr var iCol int32 = int32((*Expr)(unsafe.Pointer(p)).FiColumn) pTab = *(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) @@ -113317,9 +111180,9 @@ func generateColumnNames(tls *libc.TLS, pParse uintptr, pSelect uintptr) { /* sq if fullName != 0 { var zName uintptr = uintptr(0) zName = Xsqlite3MPrintf(tls, db, ts+9959 /* "%s.%s" */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName, zCol)) - Xsqlite3VdbeSetColName(tls, v, i, 0, zName, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zName, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) } else { - Xsqlite3VdbeSetColName(tls, v, i, 0, zCol, libc.UintptrFromInt32(-1)) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zCol, libc.UintptrFromInt32(-1)) } } else { var z uintptr = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(i)*32)).FzEName @@ -113328,7 +111191,7 @@ func generateColumnNames(tls *libc.TLS, pParse uintptr, pSelect uintptr) { /* sq } else { z = Xsqlite3DbStrDup(tls, db, z) } - Xsqlite3VdbeSetColName(tls, v, i, 0, z, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, z, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) } } generateColumnTypes(tls, pParse, pTabList, pEList) @@ -113395,15 +111258,15 @@ __1: } { // Get an appropriate name for the column - if ((libc.AssignUintptr(&zName, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FzEName)) != uintptr(0)) && ((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0) { + if ((libc.AssignUintptr(&zName, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FzEName)) != uintptr(0)) && ((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME) { // If the column contains an "AS " phrase, use as the name } else { var pColExpr uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FpExpr) - for int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == 139 { + for int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == TK_DOT { pColExpr = (*Expr)(unsafe.Pointer(pColExpr)).FpRight } - if int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == 164 { + if int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == TK_COLUMN { // For columns use the column name name var iCol int32 = int32((*Expr)(unsafe.Pointer(pColExpr)).FiColumn) var pTab uintptr = *(*uintptr)(unsafe.Pointer(pColExpr + 64 /* &.y */)) @@ -113416,7 +111279,7 @@ __1: } else { zName = ts + 13865 /* "rowid" */ } - } else if int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == 59 { + } else if int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == TK_ID { zName = *(*uintptr)(unsafe.Pointer(pColExpr + 8 /* &.u */)) } else { @@ -113471,9 +111334,9 @@ __3: Xsqlite3DbFree(tls, db, aCol) *(*uintptr)(unsafe.Pointer(paCol)) = uintptr(0) *(*I16)(unsafe.Pointer(pnCol)) = int16(0) - return 7 + return SQLITE_NOMEM } - return 0 + return SQLITE_OK } // Add type and collation information to a column list based on @@ -113524,10 +111387,10 @@ __1: (*Column)(unsafe.Pointer(pCol)).FzName = Xsqlite3DbReallocOrFree(tls, db, (*Column)(unsafe.Pointer(pCol)).FzName, (uint64((n + m) + 2))) if (*Column)(unsafe.Pointer(pCol)).FzName != 0 { libc.Xmemcpy(tls, ((*Column)(unsafe.Pointer(pCol)).FzName + uintptr((n + 1))), zType, (uint64(m + 1))) - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((COLFLAG_HASTYPE)) } } - if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) <= 0x40 { + if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) <= SQLITE_AFF_NONE { (*Column)(unsafe.Pointer(pCol)).Faffinity = aff } pColl = Xsqlite3ExprCollSeq(tls, pParse, p) @@ -113555,8 +111418,8 @@ func Xsqlite3ResultSetOfSelect(tls *libc.TLS, pParse uintptr, pSelect uintptr, a var savedFlags U64 savedFlags = (*Sqlite3)(unsafe.Pointer(db)).Fflags - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x00000004))) - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(0x00000040)) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_FullColNames)) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (SQLITE_ShortColNames) Xsqlite3SelectPrep(tls, pParse, pSelect, uintptr(0)) (*Sqlite3)(unsafe.Pointer(db)).Fflags = savedFlags if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { @@ -113589,7 +111452,7 @@ func Xsqlite3GetVdbe(tls *libc.TLS, pParse uintptr) uintptr { /* sqlite3.c:13144 return (*Parse)(unsafe.Pointer(pParse)).FpVdbe } if ((*Parse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0)) && - ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (0x0008)) == 0) { + ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (SQLITE_FactorOutConst)) == 0) { (*Parse)(unsafe.Pointer(pParse)).FokConstFactor = U8(1) } return Xsqlite3VdbeCreate(tls, pParse) @@ -113641,27 +111504,27 @@ func computeLimitRegisters(tls *libc.TLS, pParse uintptr, p uintptr, iBreak int3 v = Xsqlite3GetVdbe(tls, pParse) if Xsqlite3ExprIsInteger(tls, (*Expr)(unsafe.Pointer(pLimit)).FpLeft, bp /* &n */) != 0 { - Xsqlite3VdbeAddOp2(tls, v, 69, *(*int32)(unsafe.Pointer(bp /* n */)), iLimit) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, *(*int32)(unsafe.Pointer(bp /* n */)), iLimit) if *(*int32)(unsafe.Pointer(bp /* n */)) == 0 { Xsqlite3VdbeGoto(tls, v, iBreak) } else if (*(*int32)(unsafe.Pointer(bp /* n */)) >= 0) && (int32((*Select)(unsafe.Pointer(p)).FnSelectRow) > int32(Xsqlite3LogEst(tls, U64(*(*int32)(unsafe.Pointer(bp /* n */)))))) { (*Select)(unsafe.Pointer(p)).FnSelectRow = Xsqlite3LogEst(tls, U64(*(*int32)(unsafe.Pointer(bp /* n */)))) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0004000)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_FixedLimit) } } else { Xsqlite3ExprCode(tls, pParse, (*Expr)(unsafe.Pointer(pLimit)).FpLeft, iLimit) - Xsqlite3VdbeAddOp1(tls, v, 15, iLimit) + Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, iLimit) - Xsqlite3VdbeAddOp2(tls, v, 20, iLimit, iBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, iLimit, iBreak) } if (*Expr)(unsafe.Pointer(pLimit)).FpRight != 0 { (*Select)(unsafe.Pointer(p)).FiOffset = libc.AssignInt32(&iOffset, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)) (*Parse)(unsafe.Pointer(pParse)).FnMem++ // Allocate an extra register for limit+offset Xsqlite3ExprCode(tls, pParse, (*Expr)(unsafe.Pointer(pLimit)).FpRight, iOffset) - Xsqlite3VdbeAddOp1(tls, v, 15, iOffset) + Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, iOffset) - Xsqlite3VdbeAddOp3(tls, v, 152, iLimit, (iOffset + 1), iOffset) + Xsqlite3VdbeAddOp3(tls, v, OP_OffsetLimit, iLimit, (iOffset + 1), iOffset) } } @@ -113709,7 +111572,7 @@ func multiSelectOrderByKeyInfo(tls *libc.TLS, pParse uintptr, p uintptr, nExtra var pTerm uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr var pColl uintptr - if ((*Expr)(unsafe.Pointer(pTerm)).Fflags & U32(0x000100)) != 0 { + if ((*Expr)(unsafe.Pointer(pTerm)).Fflags & EP_Collate) != 0 { pColl = Xsqlite3ExprCollSeq(tls, pParse, pTerm) } else { pColl = multiSelectCollSeq(tls, pParse, p, (int32(*(*U16)(unsafe.Pointer((pItem + 24 /* &.u */ /* &.x */) /* &.iOrderByCol */))) - 1)) @@ -113792,7 +111655,7 @@ func generateWithRecursiveQuery(tls *libc.TLS, pParse uintptr, p uintptr, pDest pSetup = (*Select)(unsafe.Pointer(p)).FpPrior iCurrent = 0 iDistinct = 0 - eDest = 5 // Registers used by LIMIT and OFFSET + eDest = SRT_Fifo // Registers used by LIMIT and OFFSET if !((*Select)(unsafe.Pointer(p)).FpWin != 0) { goto __1 @@ -113803,7 +111666,7 @@ __1: ; // Obtain authorization to do a recursive query - if !(Xsqlite3AuthCheck(tls, pParse, 33, uintptr(0), uintptr(0), uintptr(0)) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_RECURSIVE, uintptr(0), uintptr(0), uintptr(0)) != 0) { goto __2 } return @@ -113846,21 +111709,21 @@ __5: // the Distinct table must be exactly one greater than Queue in order // for the SRT_DistFifo and SRT_DistQueue destinations to work. iQueue = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - if !(int32((*Select)(unsafe.Pointer(p)).Fop) == 132) { + if !(int32((*Select)(unsafe.Pointer(p)).Fop) == TK_UNION) { goto __7 } if pOrderBy != 0 { - eDest = 8 + eDest = SRT_DistQueue } else { - eDest = 6 + eDest = SRT_DistFifo } iDistinct = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) goto __8 __7: if pOrderBy != 0 { - eDest = 7 + eDest = SRT_Queue } else { - eDest = 5 + eDest = SRT_Fifo } __8: ; @@ -113868,25 +111731,25 @@ __8: // Allocate cursors for Current, Queue, and Distinct. regCurrent = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp3(tls, v, 114, iCurrent, regCurrent, nCol) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenPseudo, iCurrent, regCurrent, nCol) if !(pOrderBy != 0) { goto __9 } pKeyInfo = multiSelectOrderByKeyInfo(tls, pParse, p, 1) - Xsqlite3VdbeAddOp4(tls, v, 100, iQueue, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr + 2), 0, + Xsqlite3VdbeAddOp4(tls, v, OP_OpenEphemeral, iQueue, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr + 2), 0, pKeyInfo, -9) (*SelectDest)(unsafe.Pointer(bp /* &destQueue */)).FpOrderBy = pOrderBy goto __10 __9: - Xsqlite3VdbeAddOp2(tls, v, 100, iQueue, nCol) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, iQueue, nCol) __10: ; if !(iDistinct != 0) { goto __11 } - *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */) + uintptr(0)*4)) = Xsqlite3VdbeAddOp2(tls, v, 100, iDistinct, 0) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0000020)) + *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */))) = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, iDistinct, 0) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_UsesEphemeral) __11: ; @@ -113906,20 +111769,20 @@ __12: ; // Find the next row in the Queue and output that row - addrTop = Xsqlite3VdbeAddOp2(tls, v, 37, iQueue, addrBreak) + addrTop = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iQueue, addrBreak) // Transfer the next row in Queue over to Current - Xsqlite3VdbeAddOp1(tls, v, 128, iCurrent) // To reset column cache + Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, iCurrent) // To reset column cache if !(pOrderBy != 0) { goto __13 } - Xsqlite3VdbeAddOp3(tls, v, 89, iQueue, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr + 1), regCurrent) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iQueue, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr + 1), regCurrent) goto __14 __13: - Xsqlite3VdbeAddOp2(tls, v, 126, iQueue, regCurrent) + Xsqlite3VdbeAddOp2(tls, v, OP_RowData, iQueue, regCurrent) __14: ; - Xsqlite3VdbeAddOp1(tls, v, 122, iQueue) + Xsqlite3VdbeAddOp1(tls, v, OP_Delete, iQueue) // Output the single row in Current addrCont = Xsqlite3VdbeMakeLabel(tls, pParse) @@ -113929,7 +111792,7 @@ __14: if !(regLimit != 0) { goto __15 } - Xsqlite3VdbeAddOp2(tls, v, 59, regLimit, addrBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_DecrJumpZero, regLimit, addrBreak) __15: ; @@ -113937,7 +111800,7 @@ __15: // Execute the recursive SELECT taking the single row in Current as // the value for the recursive-table. Store the results in the Queue. - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000008)) != 0) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_Aggregate) != 0) { goto __16 } Xsqlite3ErrorMsg(tls, pParse, ts+16296 /* "recursive aggreg..." */, 0) @@ -114082,7 +111945,7 @@ func multiSelect(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) int32 var pLoop uintptr // For looping through SELECT statements var apColl uintptr // For looping through pKeyInfo->aColl[] var nCol int32 - rc = 0 + rc = SQLITE_OK pDelete = uintptr(0) // Database connection // Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only @@ -114111,17 +111974,17 @@ __1: // The VDBE already created by calling function // Create the destination temporary table if necessary - if !(int32((*SelectDest)(unsafe.Pointer(bp+32 /* &dest */)).FeDest) == 12) { + if !(int32((*SelectDest)(unsafe.Pointer(bp+32 /* &dest */)).FeDest) == SRT_EphemTab) { goto __2 } - Xsqlite3VdbeAddOp2(tls, v, 100, (*SelectDest)(unsafe.Pointer(bp+32 /* &dest */)).FiSDParm, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr) - (*SelectDest)(unsafe.Pointer(bp + 32 /* &dest */)).FeDest = U8(14) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*SelectDest)(unsafe.Pointer(bp+32 /* &dest */)).FiSDParm, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr) + (*SelectDest)(unsafe.Pointer(bp + 32 /* &dest */)).FeDest = SRT_Table __2: ; // Special handling for a compound-select that originates as a VALUES clause. - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000400)) != 0) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_MultiValue) != 0) { goto __3 } rc = multiSelectValues(tls, pParse, p, bp+32 /* &dest */) @@ -114131,14 +111994,14 @@ __2: goto multi_select_end __4: ; - rc = 0 + rc = SQLITE_OK __3: ; // Make sure all SELECTs in the statement have the same number of elements // in their result sets. - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0002000)) != 0) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_Recursive) != 0) { goto __5 } generateWithRecursiveQuery(tls, pParse, p, bp+32 /* &dest */) @@ -114163,11 +112026,11 @@ __9: // Generate code for the left and right SELECT statements. switch int32((*Select)(unsafe.Pointer(p)).Fop) { - case 133: + case TK_ALL: goto __11 - case 134: + case TK_EXCEPT: goto __12 - case 132: + case TK_UNION: goto __13 default: goto __14 @@ -114193,12 +112056,12 @@ __15: if !((*Select)(unsafe.Pointer(p)).FiLimit != 0) { goto __16 } - addr = Xsqlite3VdbeAddOp1(tls, v, 20, (*Select)(unsafe.Pointer(p)).FiLimit) + addr = Xsqlite3VdbeAddOp1(tls, v, OP_IfNot, (*Select)(unsafe.Pointer(p)).FiLimit) if !((*Select)(unsafe.Pointer(p)).FiOffset != 0) { goto __17 } - Xsqlite3VdbeAddOp3(tls, v, 152, + Xsqlite3VdbeAddOp3(tls, v, OP_OffsetLimit, (*Select)(unsafe.Pointer(p)).FiLimit, ((*Select)(unsafe.Pointer(p)).FiOffset + 1), (*Select)(unsafe.Pointer(p)).FiOffset) __17: ; @@ -114230,7 +112093,7 @@ __12: __13: // Cursor number of the temp table holding result op = U8(0) - priorOp = 1 + priorOp = SRT_Union if !(int32((*SelectDest)(unsafe.Pointer(bp+32 /* &dest */)).FeDest) == priorOp) { goto __20 } @@ -114244,10 +112107,10 @@ __20: // intermediate results. unionTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - addr1 = Xsqlite3VdbeAddOp2(tls, v, 100, unionTab, 0) + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, unionTab, 0) - *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */) + uintptr(0)*4)) = addr1 - *(*U32)(unsafe.Pointer(findRightmost(tls, p) + 4 /* &.selFlags */)) |= (U32(0x0000020)) + *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */))) = addr1 + *(*U32)(unsafe.Pointer(findRightmost(tls, p) + 4 /* &.selFlags */)) |= (SF_UsesEphemeral) __21: ; @@ -114264,14 +112127,14 @@ __22: ; // Code the current SELECT statement - if !(int32((*Select)(unsafe.Pointer(p)).Fop) == 134) { + if !(int32((*Select)(unsafe.Pointer(p)).Fop) == TK_EXCEPT) { goto __23 } - op = U8(2) + op = SRT_Except goto __24 __23: ; - op = U8(1) + op = SRT_Union __24: ; (*Select)(unsafe.Pointer(p)).FpPrior = uintptr(0) @@ -114284,7 +112147,7 @@ __24: pDelete = (*Select)(unsafe.Pointer(p)).FpPrior (*Select)(unsafe.Pointer(p)).FpPrior = pPrior (*Select)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) - if !(int32((*Select)(unsafe.Pointer(p)).Fop) == 132) { + if !(int32((*Select)(unsafe.Pointer(p)).Fop) == TK_UNION) { goto __25 } (*Select)(unsafe.Pointer(p)).FnSelectRow = Xsqlite3LogEstAdd(tls, (*Select)(unsafe.Pointer(p)).FnSelectRow, (*Select)(unsafe.Pointer(pPrior)).FnSelectRow) @@ -114304,14 +112167,14 @@ __25: iBreak = Xsqlite3VdbeMakeLabel(tls, pParse) iCont = Xsqlite3VdbeMakeLabel(tls, pParse) computeLimitRegisters(tls, pParse, p, iBreak) - Xsqlite3VdbeAddOp2(tls, v, 37, unionTab, iBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, unionTab, iBreak) iStart = Xsqlite3VdbeCurrentAddr(tls, v) selectInnerLoop(tls, pParse, p, unionTab, uintptr(0), uintptr(0), bp+32 /* &dest */, iCont, iBreak) Xsqlite3VdbeResolveLabel(tls, v, iCont) - Xsqlite3VdbeAddOp2(tls, v, 5, unionTab, iStart) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, unionTab, iStart) Xsqlite3VdbeResolveLabel(tls, v, iBreak) - Xsqlite3VdbeAddOp2(tls, v, 116, unionTab, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, unionTab, 0) __26: ; goto __10 @@ -114325,13 +112188,13 @@ __14: tab1 = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) tab2 = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - addr2 = Xsqlite3VdbeAddOp2(tls, v, 100, tab1, 0) + addr2 = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, tab1, 0) - *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */) + uintptr(0)*4)) = addr2 - *(*U32)(unsafe.Pointer(findRightmost(tls, p) + 4 /* &.selFlags */)) |= (U32(0x0000020)) + *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */))) = addr2 + *(*U32)(unsafe.Pointer(findRightmost(tls, p) + 4 /* &.selFlags */)) |= (SF_UsesEphemeral) // Code the SELECTs to our left into temporary table "tab1". - Xsqlite3SelectDestInit(tls, bp+120 /* &intersectdest */, 1, tab1) + Xsqlite3SelectDestInit(tls, bp+120 /* &intersectdest */, SRT_Union, tab1) rc = Xsqlite3Select(tls, pParse, pPrior, bp+120 /* &intersectdest */) if !(rc != 0) { goto __27 @@ -114341,9 +112204,9 @@ __27: ; // Code the current SELECT into temporary table "tab2" - addr2 = Xsqlite3VdbeAddOp2(tls, v, 100, tab2, 0) + addr2 = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, tab2, 0) - *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */) + uintptr(1)*4)) = addr2 + *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */) + 1*4)) = addr2 (*Select)(unsafe.Pointer(p)).FpPrior = uintptr(0) pLimit1 = (*Select)(unsafe.Pointer(p)).FpLimit (*Select)(unsafe.Pointer(p)).FpLimit = uintptr(0) @@ -114374,19 +112237,19 @@ __29: iBreak1 = Xsqlite3VdbeMakeLabel(tls, pParse) iCont1 = Xsqlite3VdbeMakeLabel(tls, pParse) computeLimitRegisters(tls, pParse, p, iBreak1) - Xsqlite3VdbeAddOp2(tls, v, 37, tab1, iBreak1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, tab1, iBreak1) r1 = Xsqlite3GetTempReg(tls, pParse) - iStart1 = Xsqlite3VdbeAddOp2(tls, v, 126, tab1, r1) - Xsqlite3VdbeAddOp4Int(tls, v, 29, tab2, iCont1, r1, 0) + iStart1 = Xsqlite3VdbeAddOp2(tls, v, OP_RowData, tab1, r1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, tab2, iCont1, r1, 0) Xsqlite3ReleaseTempReg(tls, pParse, r1) selectInnerLoop(tls, pParse, p, tab1, uintptr(0), uintptr(0), bp+32 /* &dest */, iCont1, iBreak1) Xsqlite3VdbeResolveLabel(tls, v, iCont1) - Xsqlite3VdbeAddOp2(tls, v, 5, tab1, iStart1) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, tab1, iStart1) Xsqlite3VdbeResolveLabel(tls, v, iBreak1) - Xsqlite3VdbeAddOp2(tls, v, 116, tab2, 0) - Xsqlite3VdbeAddOp2(tls, v, 116, tab1, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, tab2, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, tab1, 0) goto __10 __10: @@ -114417,7 +112280,7 @@ __31: // SELECT statements to the left always skip this part. The right-most // SELECT might also skip this part if it has no ORDER BY clause and // no temp tables are required. - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000020)) != 0) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_UsesEphemeral) != 0) { goto __32 } // Number of columns in result set @@ -114426,7 +112289,7 @@ __31: if !(!(pKeyInfo != 0)) { goto __33 } - rc = 7 + rc = SQLITE_NOMEM goto multi_select_end __33: ; @@ -114507,7 +112370,7 @@ func Xsqlite3SelectWrongNumTermsError(tls *libc.TLS, pParse uintptr, p uintptr) bp := tls.Alloc(8) defer tls.Free(8) - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000200)) != 0 { + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_Values) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+16490 /* "all VALUES must ..." */, 0) } else { Xsqlite3ErrorMsg(tls, pParse, @@ -114545,13 +112408,13 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint if regPrev != 0 { var addr1 int32 var addr2 int32 - addr1 = Xsqlite3VdbeAddOp1(tls, v, 20, regPrev) - addr2 = Xsqlite3VdbeAddOp4(tls, v, 86, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (regPrev + 1), (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, + addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_IfNot, regPrev) + addr2 = Xsqlite3VdbeAddOp4(tls, v, OP_Compare, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (regPrev + 1), (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, Xsqlite3KeyInfoRef(tls, pKeyInfo), -9) - Xsqlite3VdbeAddOp3(tls, v, 16, (addr2 + 2), iContinue, (addr2 + 2)) + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, (addr2 + 2), iContinue, (addr2 + 2)) Xsqlite3VdbeJumpHere(tls, v, addr1) - Xsqlite3VdbeAddOp3(tls, v, 77, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (regPrev + 1), ((*SelectDest)(unsafe.Pointer(pIn)).FnSdst - 1)) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, regPrev) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (regPrev + 1), ((*SelectDest)(unsafe.Pointer(pIn)).FnSdst - 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, regPrev) } if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { return 0 @@ -114562,14 +112425,14 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint switch int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) { // Store the result as data using a unique key. - case 12: + case SRT_EphemTab: { var r1 int32 = Xsqlite3GetTempReg(tls, pParse) var r2 int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 91, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, r1) - Xsqlite3VdbeAddOp2(tls, v, 120, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r2) - Xsqlite3VdbeAddOp3(tls, v, 121, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r1, r2) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x08)) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, r1) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r2) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r1, r2) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_APPEND) Xsqlite3ReleaseTempReg(tls, pParse, r2) Xsqlite3ReleaseTempReg(tls, pParse, r1) break @@ -114577,14 +112440,14 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint } // If we are creating a set for an "expr IN (SELECT ...)". - case 11: + case SRT_Set: { var r1 int32 r1 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp4(tls, v, 91, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, r1, (*SelectDest)(unsafe.Pointer(pDest)).FzAffSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst) - Xsqlite3VdbeAddOp4Int(tls, v, 130, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r1, + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r1, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst) Xsqlite3ReleaseTempReg(tls, pParse, r1) break @@ -114595,7 +112458,7 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint // store the results in the appropriate memory cell and break out // of the scan loop. Note that the select might return multiple columns // if it is the RHS of a row-value IN operator. - case 10: + case SRT_Mem: { if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 { @@ -114608,14 +112471,14 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint // The results are stored in a sequence of registers // starting at pDest->iSdst. Then the co-routine yields. - case 13: + case SRT_Coroutine: { if (*SelectDest)(unsafe.Pointer(pDest)).FiSdst == 0 { (*SelectDest)(unsafe.Pointer(pDest)).FiSdst = Xsqlite3GetTempRange(tls, pParse, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst) (*SelectDest)(unsafe.Pointer(pDest)).FnSdst = (*SelectDest)(unsafe.Pointer(pIn)).FnSdst } Xsqlite3ExprCodeMove(tls, pParse, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pDest)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst) - Xsqlite3VdbeAddOp1(tls, v, 14, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm) + Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm) break } @@ -114630,7 +112493,7 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint default: { - Xsqlite3VdbeAddOp2(tls, v, 80, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst) break } @@ -114638,12 +112501,12 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint // Jump to the end of the loop if the LIMIT is reached. if (*Select)(unsafe.Pointer(p)).FiLimit != 0 { - Xsqlite3VdbeAddOp2(tls, v, 59, (*Select)(unsafe.Pointer(p)).FiLimit, iBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_DecrJumpZero, (*Select)(unsafe.Pointer(p)).FiLimit, iBreak) } // Generate the subroutine return Xsqlite3VdbeResolveLabel(tls, v, iContinue) - Xsqlite3VdbeAddOp1(tls, v, 65, regReturn) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regReturn) return addr } @@ -114791,7 +112654,7 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // For operators other than UNION ALL we have to make sure that // the ORDER BY clause covers every term of the result set. Add // terms to the ORDER BY clause as necessary. - if op != 133 { + if op != TK_ALL { for i = 1; (int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0) && (i <= (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr); i++ { var pItem uintptr j = 0 @@ -114816,11 +112679,11 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) __3: ; if j == nOrderBy { - var pNew uintptr = Xsqlite3Expr(tls, db, 152, uintptr(0)) + var pNew uintptr = Xsqlite3Expr(tls, db, TK_INTEGER, uintptr(0)) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x000400)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (EP_IntValue) *(*int32)(unsafe.Pointer(pNew + 8 /* &.u */)) = i (*Select)(unsafe.Pointer(p)).FpOrderBy = libc.AssignUintptr(&pOrderBy, Xsqlite3ExprListAppend(tls, pParse, pOrderBy, pNew)) if pOrderBy != 0 { @@ -114839,7 +112702,7 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) aPermute = Xsqlite3DbMallocRawNN(tls, db, (uint64(uint64(unsafe.Sizeof(U32(0))) * (uint64(nOrderBy + 1))))) if aPermute != 0 { var pItem uintptr - *(*U32)(unsafe.Pointer(aPermute + uintptr(0)*4)) = U32(nOrderBy) + *(*U32)(unsafe.Pointer(aPermute)) = U32(nOrderBy) i = 1 pItem = pOrderBy + 8 /* &.a */ __4: @@ -114871,14 +112734,14 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // Allocate a range of temporary registers and the KeyInfo needed // for the logic that removes duplicate result rows when the // operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL). - if op == 133 { + if op == TK_ALL { regPrev = 0 } else { var nExpr int32 = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr regPrev = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (nExpr + 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regPrev) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regPrev) pKeyDup = Xsqlite3KeyInfoAlloc(tls, db, nExpr, 1) if pKeyDup != 0 { @@ -114899,17 +112762,17 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // Compute the limit registers computeLimitRegisters(tls, pParse, p, labelEnd) - if ((*Select)(unsafe.Pointer(p)).FiLimit != 0) && (op == 133) { + if ((*Select)(unsafe.Pointer(p)).FiLimit != 0) && (op == TK_ALL) { regLimitA = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) regLimitB = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 77, func() int32 { + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, func() int32 { if (*Select)(unsafe.Pointer(p)).FiOffset != 0 { return ((*Select)(unsafe.Pointer(p)).FiOffset + 1) } return (*Select)(unsafe.Pointer(p)).FiLimit }(), regLimitA) - Xsqlite3VdbeAddOp2(tls, v, 77, regLimitA, regLimitB) + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, regLimitA, regLimitB) } else { regLimitA = libc.AssignInt32(®LimitB, 0) } @@ -114920,15 +112783,15 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) regAddrB = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) regOutA = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) regOutB = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3SelectDestInit(tls, bp+8 /* &destA */, 13, regAddrA) - Xsqlite3SelectDestInit(tls, bp+48 /* &destB */, 13, regAddrB) + Xsqlite3SelectDestInit(tls, bp+8 /* &destA */, SRT_Coroutine, regAddrA) + Xsqlite3SelectDestInit(tls, bp+48 /* &destB */, SRT_Coroutine, regAddrB) Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+16618 /* "MERGE (%s)" */, libc.VaList(bp, selectOpName(tls, int32((*Select)(unsafe.Pointer(p)).Fop)))) // Generate a coroutine to evaluate the SELECT statement to the // left of the compound operator - the "A" select. addrSelectA = (Xsqlite3VdbeCurrentAddr(tls, v) + 1) - addr1 = Xsqlite3VdbeAddOp3(tls, v, 13, regAddrA, 0, addrSelectA) + addr1 = Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regAddrA, 0, addrSelectA) (*Select)(unsafe.Pointer(pPrior)).FiLimit = regLimitA Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+16629 /* "LEFT" */, 0) @@ -114939,7 +112802,7 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // Generate a coroutine to evaluate the SELECT statement on // the right - the "B" select addrSelectB = (Xsqlite3VdbeCurrentAddr(tls, v) + 1) - addr1 = Xsqlite3VdbeAddOp3(tls, v, 13, regAddrB, 0, addrSelectB) + addr1 = Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regAddrB, 0, addrSelectB) savedLimit = (*Select)(unsafe.Pointer(p)).FiLimit savedOffset = (*Select)(unsafe.Pointer(p)).FiOffset @@ -114960,7 +112823,7 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // Generate a subroutine that outputs the current row of the B // select as the next output row of the compound select. - if (op == 133) || (op == 132) { + if (op == TK_ALL) || (op == TK_UNION) { addrOutB = generateOutputSubroutine(tls, pParse, p, bp+48 /* &destB */, pDest, regOutB, @@ -114970,12 +112833,12 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // Generate a subroutine to run when the results from select A // are exhausted and only data in select B remains. - if (op == 134) || (op == 135) { + if (op == TK_EXCEPT) || (op == TK_INTERSECT) { addrEofA_noB = libc.AssignInt32(&addrEofA, labelEnd) } else { - addrEofA = Xsqlite3VdbeAddOp2(tls, v, 12, regOutB, addrOutB) - addrEofA_noB = Xsqlite3VdbeAddOp2(tls, v, 14, regAddrB, labelEnd) + addrEofA = Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutB, addrOutB) + addrEofA_noB = Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrB, labelEnd) Xsqlite3VdbeGoto(tls, v, addrEofA) (*Select)(unsafe.Pointer(p)).FnSelectRow = Xsqlite3LogEstAdd(tls, (*Select)(unsafe.Pointer(p)).FnSelectRow, (*Select)(unsafe.Pointer(pPrior)).FnSelectRow) @@ -114983,57 +112846,57 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // Generate a subroutine to run when the results from select B // are exhausted and only data in select A remains. - if op == 135 { + if op == TK_INTERSECT { addrEofB = addrEofA if int32((*Select)(unsafe.Pointer(p)).FnSelectRow) > int32((*Select)(unsafe.Pointer(pPrior)).FnSelectRow) { (*Select)(unsafe.Pointer(p)).FnSelectRow = (*Select)(unsafe.Pointer(pPrior)).FnSelectRow } } else { - addrEofB = Xsqlite3VdbeAddOp2(tls, v, 12, regOutA, addrOutA) - Xsqlite3VdbeAddOp2(tls, v, 14, regAddrA, labelEnd) + addrEofB = Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutA, addrOutA) + Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrA, labelEnd) Xsqlite3VdbeGoto(tls, v, addrEofB) } // Generate code to handle the case of AB addrAgtB = Xsqlite3VdbeCurrentAddr(tls, v) - if (op == 133) || (op == 132) { - Xsqlite3VdbeAddOp2(tls, v, 12, regOutB, addrOutB) + if (op == TK_ALL) || (op == TK_UNION) { + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutB, addrOutB) } - Xsqlite3VdbeAddOp2(tls, v, 14, regAddrB, addrEofB) + Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrB, addrEofB) Xsqlite3VdbeGoto(tls, v, labelCmpr) // This code runs once to initialize everything. Xsqlite3VdbeJumpHere(tls, v, addr1) - Xsqlite3VdbeAddOp2(tls, v, 14, regAddrA, addrEofA_noB) - Xsqlite3VdbeAddOp2(tls, v, 14, regAddrB, addrEofB) + Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrA, addrEofA_noB) + Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrB, addrEofB) // Implement the main merge loop Xsqlite3VdbeResolveLabel(tls, v, labelCmpr) - Xsqlite3VdbeAddOp4(tls, v, 85, 0, 0, 0, aPermute, -15) - Xsqlite3VdbeAddOp4(tls, v, 86, (*SelectDest)(unsafe.Pointer(bp+8 /* &destA */)).FiSdst, (*SelectDest)(unsafe.Pointer(bp+48 /* &destB */)).FiSdst, nOrderBy, + Xsqlite3VdbeAddOp4(tls, v, OP_Permutation, 0, 0, 0, aPermute, -15) + Xsqlite3VdbeAddOp4(tls, v, OP_Compare, (*SelectDest)(unsafe.Pointer(bp+8 /* &destA */)).FiSdst, (*SelectDest)(unsafe.Pointer(bp+48 /* &destB */)).FiSdst, nOrderBy, pKeyMerge, -9) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x01)) - Xsqlite3VdbeAddOp3(tls, v, 16, addrAltB, addrAeqB, addrAgtB) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_PERMUTE) + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, addrAltB, addrAeqB, addrAgtB) // Jump to the this point in order to terminate the query. Xsqlite3VdbeResolveLabel(tls, v, labelEnd) @@ -115091,15 +112954,15 @@ func substExpr(tls *libc.TLS, pSubst uintptr, pExpr uintptr) uintptr { /* sqlite if pExpr == uintptr(0) { return uintptr(0) } - if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0)) && + if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0)) && (int32((*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable) == (*SubstContext)(unsafe.Pointer(pSubst)).FiTable) { (*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable = I16((*SubstContext)(unsafe.Pointer(pSubst)).FiNewTable) } - if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) && + if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SubstContext)(unsafe.Pointer(pSubst)).FiTable)) && - !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000008))) != U32(0)) { + !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FixedCol)) != U32(0)) { if int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) < 0 { - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(119) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_NULL } else { var pNew uintptr var pCopy uintptr = (*ExprList_item)(unsafe.Pointer(((*SubstContext)(unsafe.Pointer(pSubst)).FpEList + 8 /* &.a */) + uintptr((*Expr)(unsafe.Pointer(pExpr)).FiColumn)*32)).FpExpr @@ -115109,22 +112972,22 @@ func substExpr(tls *libc.TLS, pSubst uintptr, pExpr uintptr) uintptr { /* sqlite Xsqlite3VectorErrorMsg(tls, (*SubstContext)(unsafe.Pointer(pSubst)).FpParse, pCopy) } else { var db uintptr = (*Parse)(unsafe.Pointer((*SubstContext)(unsafe.Pointer(pSubst)).FpParse)).Fdb - if ((*SubstContext)(unsafe.Pointer(pSubst)).FisLeftJoin != 0) && (int32((*Expr)(unsafe.Pointer(pCopy)).Fop) != 164) { + if ((*SubstContext)(unsafe.Pointer(pSubst)).FisLeftJoin != 0) && (int32((*Expr)(unsafe.Pointer(pCopy)).Fop) != TK_COLUMN) { libc.Xmemset(tls, bp /* &ifNullRow */, 0, uint64(unsafe.Sizeof(Expr{}))) - (*Expr)(unsafe.Pointer(bp /* &ifNullRow */)).Fop = U8(176) + (*Expr)(unsafe.Pointer(bp /* &ifNullRow */)).Fop = TK_IF_NULL_ROW (*Expr)(unsafe.Pointer(bp /* &ifNullRow */)).FpLeft = pCopy (*Expr)(unsafe.Pointer(bp /* &ifNullRow */)).FiTable = (*SubstContext)(unsafe.Pointer(pSubst)).FiNewTable - (*Expr)(unsafe.Pointer(bp /* &ifNullRow */)).Fflags = U32(0x001000) + (*Expr)(unsafe.Pointer(bp /* &ifNullRow */)).Fflags = EP_Skip pCopy = bp /* &ifNullRow */ } pNew = Xsqlite3ExprDup(tls, db, pCopy, 0) if (pNew != 0) && ((*SubstContext)(unsafe.Pointer(pSubst)).FisLeftJoin != 0) { - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x100000)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (EP_CanBeNull) } - if (pNew != 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0)) { + if (pNew != 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0)) { (*Expr)(unsafe.Pointer(pNew)).FiRightJoinTable = (*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x000001)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (EP_FromJoin) } Xsqlite3ExprDelete(tls, db, pExpr) pExpr = pNew @@ -115132,7 +112995,7 @@ func substExpr(tls *libc.TLS, pSubst uintptr, pExpr uintptr) uintptr { /* sqlite // Ensure that the expression now has an implicit collation sequence, // just as it did when it was a column of a view or sub-query. if pExpr != 0 { - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 164) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 111) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLLATE) { var pColl uintptr = Xsqlite3ExprCollSeq(tls, (*SubstContext)(unsafe.Pointer(pSubst)).FpParse, pExpr) pExpr = Xsqlite3ExprAddCollateString(tls, (*SubstContext)(unsafe.Pointer(pSubst)).FpParse, pExpr, func() uintptr { @@ -115142,22 +113005,22 @@ func substExpr(tls *libc.TLS, pSubst uintptr, pExpr uintptr) uintptr { /* sqlite return ts + 266 /* "BINARY" */ }()) } - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(0x000100)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(EP_Collate))) } } } } else { - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 176) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SubstContext)(unsafe.Pointer(pSubst)).FiTable) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IF_NULL_ROW) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SubstContext)(unsafe.Pointer(pSubst)).FiTable) { (*Expr)(unsafe.Pointer(pExpr)).FiTable = (*SubstContext)(unsafe.Pointer(pSubst)).FiNewTable } (*Expr)(unsafe.Pointer(pExpr)).FpLeft = substExpr(tls, pSubst, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) (*Expr)(unsafe.Pointer(pExpr)).FpRight = substExpr(tls, pSubst, (*Expr)(unsafe.Pointer(pExpr)).FpRight) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { substSelect(tls, pSubst, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)), 1) } else { substExprList(tls, pSubst, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { var pWin uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) (*Window)(unsafe.Pointer(pWin)).FpFilter = substExpr(tls, pSubst, (*Window)(unsafe.Pointer(pWin)).FpFilter) substExprList(tls, pSubst, (*Window)(unsafe.Pointer(pWin)).FpPartition) @@ -115222,18 +113085,18 @@ func substSelect(tls *libc.TLS, pSubst uintptr, p uintptr, doPrior int32) { /* s // pSrcItem->colUsed mask. func recomputeColumnsUsedExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:132903:12: */ var pItem uintptr - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 164 { - return 0 + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN { + return WRC_Continue } pItem = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) if (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor != (*Expr)(unsafe.Pointer(pExpr)).FiTable { - return 0 + return WRC_Continue } if int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) < 0 { - return 0 + return WRC_Continue } *(*Bitmask)(unsafe.Pointer(pItem + 88 /* &.colUsed */)) |= (Xsqlite3ExprColUsed(tls, pExpr)) - return 0 + return WRC_Continue } func recomputeColumnsUsed(tls *libc.TLS, pSelect uintptr, pSrcItem uintptr) { /* sqlite3.c:132912:13: */ @@ -115432,7 +113295,7 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg // Check to see if flattening is permitted. Return 0 if not. - if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0001)) != 0 { + if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_QueryFlattener)) != 0 { return 0 } pSrc = (*Select)(unsafe.Pointer(p)).FpSrc @@ -115458,13 +113321,13 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg if ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) && ((*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(pSub)).FpLimit)).FpRight != 0) { return 0 } // Restriction (14) - if (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000100)) != U32(0)) && ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) { + if (((*Select)(unsafe.Pointer(p)).FselFlags & SF_Compound) != U32(0)) && ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) { return 0 // Restriction (15) } if (*SrcList)(unsafe.Pointer(pSubSrc)).FnSrc == 0 { return 0 } // Restriction (7) - if ((*Select)(unsafe.Pointer(pSub)).FselFlags & U32(0x0000001)) != 0 { + if ((*Select)(unsafe.Pointer(pSub)).FselFlags & SF_Distinct) != 0 { return 0 } // Restriction (4) if ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) && (((*SrcList)(unsafe.Pointer(pSrc)).FnSrc > 1) || (isAgg != 0)) { @@ -115479,10 +113342,10 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg if ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) && ((*Select)(unsafe.Pointer(p)).FpWhere != 0) { return 0 } // Restriction (19) - if ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) && (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000001)) != U32(0)) { + if ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) && (((*Select)(unsafe.Pointer(p)).FselFlags & SF_Distinct) != U32(0)) { return 0 // Restriction (21) } - if ((*Select)(unsafe.Pointer(pSub)).FselFlags & (U32(0x0002000))) != 0 { + if ((*Select)(unsafe.Pointer(pSub)).FselFlags & (SF_Recursive)) != 0 { return 0 // Restrictions (22) } @@ -115504,12 +113367,12 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg // the LEFT JOIN table should be all-NULL. // // See also tickets #306, #350, and #3300. - if (int32((*SrcList_item)(unsafe.Pointer(pSubitem)).Ffg.Fjointype) & 0x0020) != 0 { + if (int32((*SrcList_item)(unsafe.Pointer(pSubitem)).Ffg.Fjointype) & JT_OUTER) != 0 { isLeftJoin = 1 if ((((*SrcList)(unsafe.Pointer(pSubSrc)).FnSrc > 1) || // (3a) (isAgg != 0)) || // (3b) - ((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pSubSrc+8 /* &.a */)+uintptr(0)*112)).FpTab)).FnModuleArg != 0)) || // (3c) - (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000001)) != U32(0)) { + ((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pSubSrc + 8 /* &.a */))).FpTab)).FnModuleArg != 0)) || // (3c) + (((*Select)(unsafe.Pointer(p)).FselFlags & SF_Distinct) != U32(0)) { return 0 } } @@ -115522,13 +113385,13 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg if (*Select)(unsafe.Pointer(pSub)).FpOrderBy != 0 { return 0 // Restriction (20) } - if ((isAgg != 0) || (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000001)) != U32(0))) || ((*SrcList)(unsafe.Pointer(pSrc)).FnSrc != 1) { + if ((isAgg != 0) || (((*Select)(unsafe.Pointer(p)).FselFlags & SF_Distinct) != U32(0))) || ((*SrcList)(unsafe.Pointer(pSrc)).FnSrc != 1) { return 0 // (17d1), (17d2), or (17d3) } for pSub1 = pSub; pSub1 != 0; pSub1 = (*Select)(unsafe.Pointer(pSub1)).FpPrior { - if (((((*Select)(unsafe.Pointer(pSub1)).FselFlags & (U32(0x0000001 | 0x0000008))) != U32(0)) || // (17b) - (((*Select)(unsafe.Pointer(pSub1)).FpPrior != 0) && (int32((*Select)(unsafe.Pointer(pSub1)).Fop) != 133))) || // (17a) + if (((((*Select)(unsafe.Pointer(pSub1)).FselFlags & (U32(SF_Distinct | SF_Aggregate))) != U32(0)) || // (17b) + (((*Select)(unsafe.Pointer(pSub1)).FpPrior != 0) && (int32((*Select)(unsafe.Pointer(pSub1)).Fop) != TK_ALL))) || // (17a) ((*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSub1)).FpSrc)).FnSrc < 1)) || // (17c) ((*Select)(unsafe.Pointer(pSub1)).FpWin != 0) { return 0 @@ -115557,7 +113420,7 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg // Authorize the subquery (*Parse)(unsafe.Pointer(pParse)).FzAuthContext = (*SrcList_item)(unsafe.Pointer(pSubitem)).FzName - Xsqlite3AuthCheck(tls, pParse, 21, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3AuthCheck(tls, pParse, SQLITE_SELECT, uintptr(0), uintptr(0), uintptr(0)) (*Parse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedAuthContext @@ -115606,7 +113469,7 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg (*Select)(unsafe.Pointer(p)).FpLimit = pLimit (*Select)(unsafe.Pointer(p)).FpOrderBy = pOrderBy (*Select)(unsafe.Pointer(p)).FpSrc = pSrc - (*Select)(unsafe.Pointer(p)).Fop = U8(133) + (*Select)(unsafe.Pointer(p)).Fop = TK_ALL if pNew == uintptr(0) { (*Select)(unsafe.Pointer(p)).FpPrior = pPrior } else { @@ -115741,7 +113604,7 @@ __1: // // We look at every expression in the outer query and every place we see // "a" we substitute "x*3" and every place we see "b" we substitute "y+10". - if ((*Select)(unsafe.Pointer(pSub)).FpOrderBy != 0) && (((*Select)(unsafe.Pointer(pParent)).FselFlags & U32(0x0400000)) == U32(0)) { + if ((*Select)(unsafe.Pointer(pSub)).FpOrderBy != 0) && (((*Select)(unsafe.Pointer(pParent)).FselFlags & SF_NoopOrderBy) == U32(0)) { // At this point, any non-zero iOrderByCol values indicate that the // ORDER BY column expression is identical to the iOrderByCol'th // expression returned by SELECT statement pSub. Since these values @@ -115767,7 +113630,7 @@ __1: } if pWhere != 0 { if (*Select)(unsafe.Pointer(pParent)).FpWhere != 0 { - (*Select)(unsafe.Pointer(pParent)).FpWhere = Xsqlite3PExpr(tls, pParse, 44, pWhere, (*Select)(unsafe.Pointer(pParent)).FpWhere) + (*Select)(unsafe.Pointer(pParent)).FpWhere = Xsqlite3PExpr(tls, pParse, TK_AND, pWhere, (*Select)(unsafe.Pointer(pParent)).FpWhere) } else { (*Select)(unsafe.Pointer(pParent)).FpWhere = pWhere } @@ -115785,7 +113648,7 @@ __1: // The flattened query is a compound if either the inner or the // outer query is a compound. - *(*U32)(unsafe.Pointer(pParent + 4 /* &.selFlags */)) |= ((*Select)(unsafe.Pointer(pSub)).FselFlags & U32(0x0000100)) + *(*U32)(unsafe.Pointer(pParent + 4 /* &.selFlags */)) |= ((*Select)(unsafe.Pointer(pSub)).FselFlags & SF_Compound) // restriction (17b) // SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y; @@ -115835,7 +113698,7 @@ type WhereConst = WhereConst1 /* sqlite3.c:133502:27 */ func constInsert(tls *libc.TLS, pConst uintptr, pColumn uintptr, pValue uintptr, pExpr uintptr) { /* sqlite3.c:133518:13: */ var i int32 - if ((*Expr)(unsafe.Pointer((pColumn))).Fflags & (U32(0x000008))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pColumn))).Fflags & (EP_FixedCol)) != U32(0) { return } if int32(Xsqlite3ExprAffinity(tls, pValue)) != 0 { @@ -115877,24 +113740,24 @@ func findConstInWhere(tls *libc.TLS, pConst uintptr, pExpr uintptr) { /* sqlite3 if pExpr == uintptr(0) { return } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0) { return } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 44 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND { findConstInWhere(tls, pConst, (*Expr)(unsafe.Pointer(pExpr)).FpRight) findConstInWhere(tls, pConst, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) return } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 53 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_EQ { return } pRight = (*Expr)(unsafe.Pointer(pExpr)).FpRight pLeft = (*Expr)(unsafe.Pointer(pExpr)).FpLeft - if (int32((*Expr)(unsafe.Pointer(pRight)).Fop) == 164) && (Xsqlite3ExprIsConstant(tls, pLeft) != 0) { + if (int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_COLUMN) && (Xsqlite3ExprIsConstant(tls, pLeft) != 0) { constInsert(tls, pConst, pRight, pLeft, pExpr) } - if (int32((*Expr)(unsafe.Pointer(pLeft)).Fop) == 164) && (Xsqlite3ExprIsConstant(tls, pRight) != 0) { + if (int32((*Expr)(unsafe.Pointer(pLeft)).Fop) == TK_COLUMN) && (Xsqlite3ExprIsConstant(tls, pRight) != 0) { constInsert(tls, pConst, pLeft, pRight, pExpr) } } @@ -115906,12 +113769,12 @@ func findConstInWhere(tls *libc.TLS, pConst uintptr, pExpr uintptr) { /* sqlite3 func propagateConstantExprRewrite(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:133591:12: */ var i int32 var pConst uintptr - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 164 { - return 0 + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN { + return WRC_Continue } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000008 | 0x000001))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_FixedCol | EP_FromJoin))) != U32(0) { - return 0 + return WRC_Continue } pConst = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) for i = 0; i < (*WhereConst)(unsafe.Pointer(pConst)).FnConst; i++ { @@ -115927,13 +113790,13 @@ func propagateConstantExprRewrite(tls *libc.TLS, pWalker uintptr, pExpr uintptr) } // A match is found. Add the EP_FixedCol property (*WhereConst)(unsafe.Pointer(pConst)).FnChng++ - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(0x800000)) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x000008)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(EP_Leaf))) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_FixedCol) (*Expr)(unsafe.Pointer(pExpr)).FpLeft = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FpParse)).Fdb, *(*uintptr)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr(((i*2)+1))*8)), 0) break } - return 1 + return WRC_Prune } // The WHERE-clause constant propagation optimization. @@ -116066,7 +113929,7 @@ func pushDownWhereTerms(tls *libc.TLS, pParse uintptr, pSubq uintptr, pWhere uin if pWhere == uintptr(0) { return 0 } - if ((*Select)(unsafe.Pointer(pSubq)).FselFlags & U32(0x0002000)) != 0 { + if ((*Select)(unsafe.Pointer(pSubq)).FselFlags & SF_Recursive) != 0 { return 0 } // restriction (2) @@ -116079,17 +113942,17 @@ func pushDownWhereTerms(tls *libc.TLS, pParse uintptr, pSubq uintptr, pWhere uin if (*Select)(unsafe.Pointer(pSubq)).FpLimit != uintptr(0) { return 0 // restriction (3) } - for int32((*Expr)(unsafe.Pointer(pWhere)).Fop) == 44 { + for int32((*Expr)(unsafe.Pointer(pWhere)).Fop) == TK_AND { nChng = nChng + (pushDownWhereTerms(tls, pParse, pSubq, (*Expr)(unsafe.Pointer(pWhere)).FpRight, iCursor, isLeftJoin)) pWhere = (*Expr)(unsafe.Pointer(pWhere)).FpLeft } if (isLeftJoin != 0) && - (((libc.Bool32(((*Expr)(unsafe.Pointer((pWhere))).Fflags & (U32(0x000001))) != U32(0))) == 0) || + (((libc.Bool32(((*Expr)(unsafe.Pointer((pWhere))).Fflags & (EP_FromJoin)) != U32(0))) == 0) || (int32((*Expr)(unsafe.Pointer(pWhere)).FiRightJoinTable) != iCursor)) { return 0 // restriction (4) } - if (((*Expr)(unsafe.Pointer((pWhere))).Fflags & (U32(0x000001))) != U32(0)) && (int32((*Expr)(unsafe.Pointer(pWhere)).FiRightJoinTable) != iCursor) { + if (((*Expr)(unsafe.Pointer((pWhere))).Fflags & (EP_FromJoin)) != U32(0)) && (int32((*Expr)(unsafe.Pointer(pWhere)).FiRightJoinTable) != iCursor) { return 0 // restriction (5) } if Xsqlite3ExprIsTableConstant(tls, pWhere, iCursor) != 0 { @@ -116105,7 +113968,7 @@ func pushDownWhereTerms(tls *libc.TLS, pParse uintptr, pSubq uintptr, pWhere uin (*SubstContext)(unsafe.Pointer(bp /* &x */)).FisLeftJoin = 0 (*SubstContext)(unsafe.Pointer(bp /* &x */)).FpEList = (*Select)(unsafe.Pointer(pSubq)).FpEList pNew = substExpr(tls, bp /* &x */, pNew) - if ((*Select)(unsafe.Pointer(pSubq)).FselFlags & U32(0x0000008)) != 0 { + if ((*Select)(unsafe.Pointer(pSubq)).FselFlags & SF_Aggregate) != 0 { (*Select)(unsafe.Pointer(pSubq)).FpHaving = Xsqlite3ExprAnd(tls, pParse, (*Select)(unsafe.Pointer(pSubq)).FpHaving, pNew) } else { (*Select)(unsafe.Pointer(pSubq)).FpWhere = Xsqlite3ExprAnd(tls, pParse, (*Select)(unsafe.Pointer(pSubq)).FpWhere, pNew) @@ -116131,31 +113994,31 @@ func pushDownWhereTerms(tls *libc.TLS, pParse uintptr, pSubq uintptr, pWhere uin // located but before their arguments have been subjected to aggregate // analysis. func minMaxQuery(tls *libc.TLS, db uintptr, pFunc uintptr, ppMinMax uintptr) U8 { /* sqlite3.c:133825:11: */ - var eRet int32 = 0x0000 // Return value + var eRet int32 = WHERE_ORDERBY_NORMAL // Return value var pEList uintptr = *(*uintptr)(unsafe.Pointer(pFunc + 32 /* &.x */)) // Arguments to agg function var zFunc uintptr // Name of aggregate function pFunc var pOrderBy uintptr var sortFlags U8 = U8(0) - if ((pEList == uintptr(0)) || ((*ExprList)(unsafe.Pointer(pEList)).FnExpr != 1)) || (((*Expr)(unsafe.Pointer((pFunc))).Fflags & (U32(0x1000000))) != U32(0)) { + if ((pEList == uintptr(0)) || ((*ExprList)(unsafe.Pointer(pEList)).FnExpr != 1)) || (((*Expr)(unsafe.Pointer((pFunc))).Fflags & (EP_WinFunc)) != U32(0)) { return U8(eRet) } zFunc = *(*uintptr)(unsafe.Pointer(pFunc + 8 /* &.u */)) if Xsqlite3StrICmp(tls, zFunc, ts+12964 /* "min" */) == 0 { - eRet = 0x0001 - if Xsqlite3ExprCanBeNull(tls, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(0)*32)).FpExpr) != 0 { - sortFlags = U8(0x02) + eRet = WHERE_ORDERBY_MIN + if Xsqlite3ExprCanBeNull(tls, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */))).FpExpr) != 0 { + sortFlags = KEYINFO_ORDER_BIGNULL } } else if Xsqlite3StrICmp(tls, zFunc, ts+12968 /* "max" */) == 0 { - eRet = 0x0002 - sortFlags = U8(0x01) + eRet = WHERE_ORDERBY_MAX + sortFlags = KEYINFO_ORDER_DESC } else { return U8(eRet) } *(*uintptr)(unsafe.Pointer(ppMinMax)) = libc.AssignUintptr(&pOrderBy, Xsqlite3ExprListDup(tls, db, pEList, 0)) if pOrderBy != 0 { - (*ExprList_item)(unsafe.Pointer((pOrderBy + 8 /* &.a */) + uintptr(0)*32)).FsortFlags = sortFlags + (*ExprList_item)(unsafe.Pointer((pOrderBy + 8 /* &.a */))).FsortFlags = sortFlags } return U8(eRet) } @@ -116174,25 +114037,25 @@ func isSimpleCount(tls *libc.TLS, p uintptr, pAggInfo uintptr) uintptr { /* sqli var pExpr uintptr if ((((*Select)(unsafe.Pointer(p)).FpWhere != 0) || ((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr != 1)) || - ((*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc != 1)) || ((*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc+8 /* &.a */)+uintptr(0)*112)).FpSelect != 0) { + ((*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc != 1)) || ((*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpSelect != 0) { return uintptr(0) } - pTab = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab - pExpr = (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpEList + 8 /* &.a */) + uintptr(0)*32)).FpExpr + pTab = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpTab + pExpr = (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpEList + 8 /* &.a */))).FpExpr if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { return uintptr(0) } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 165 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_AGG_FUNCTION { return uintptr(0) } if (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == 0 { return uintptr(0) } - if ((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(0)*24)).FpFunc)).FfuncFlags & U32(0x0100)) == U32(0) { + if ((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FpFunc)).FfuncFlags & SQLITE_FUNC_COUNT) == U32(0) { return uintptr(0) } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000002 | 0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_Distinct | EP_WinFunc))) != U32(0) { return uintptr(0) } @@ -116217,11 +114080,11 @@ func Xsqlite3IndexedByLookup(tls *libc.TLS, pParse uintptr, pFrom uintptr) int32 if !(pIdx != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+16640 /* "no such index: %..." */, libc.VaList(bp, zIndexedBy, 0)) (*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1) - return 1 + return SQLITE_ERROR } (*SrcList_item)(unsafe.Pointer(pFrom)).FpIBIndex = pIdx } - return 0 + return SQLITE_OK } // Detect compound SELECT statements that use an ORDER BY clause with @@ -116257,15 +114120,15 @@ func convertCompoundSelectToSubquery(tls *libc.TLS, pWalker uintptr, p uintptr) // var dummy Token at bp, 16 if (*Select)(unsafe.Pointer(p)).FpPrior == uintptr(0) { - return 0 + return WRC_Continue } if (*Select)(unsafe.Pointer(p)).FpOrderBy == uintptr(0) { - return 0 + return WRC_Continue } - for pX = p; (pX != 0) && ((int32((*Select)(unsafe.Pointer(pX)).Fop) == 133) || (int32((*Select)(unsafe.Pointer(pX)).Fop) == 136)); pX = (*Select)(unsafe.Pointer(pX)).FpPrior { + for pX = p; (pX != 0) && ((int32((*Select)(unsafe.Pointer(pX)).Fop) == TK_ALL) || (int32((*Select)(unsafe.Pointer(pX)).Fop) == TK_SELECT)); pX = (*Select)(unsafe.Pointer(pX)).FpPrior { } if pX == uintptr(0) { - return 0 + return WRC_Continue } a = (*Select)(unsafe.Pointer(p)).FpOrderBy + 8 /* &.a */ // If iOrderByCol is already non-zero, then it has already been matched @@ -116273,16 +114136,16 @@ func convertCompoundSelectToSubquery(tls *libc.TLS, pWalker uintptr, p uintptr) // SELECT is rewritten for window-functions processing and then passed // to sqlite3SelectPrep() and similar a second time. The rewriting done // by this function is not required in this case. - if *(*U16)(unsafe.Pointer(a + uintptr(0)*32 + 24 /* &.u */ /* &.x */ /* &.iOrderByCol */)) != 0 { - return 0 + if *(*U16)(unsafe.Pointer(a + 24 /* &.u */ /* &.x */ /* &.iOrderByCol */)) != 0 { + return WRC_Continue } for i = ((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpOrderBy)).FnExpr - 1); i >= 0; i-- { - if ((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(a+uintptr(i)*32)).FpExpr)).Fflags & U32(0x000100)) != 0 { + if ((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(a+uintptr(i)*32)).FpExpr)).Fflags & EP_Collate) != 0 { break } } if i < 0 { - return 0 + return WRC_Continue } // If we reach this point, that means the transformation is required. @@ -116291,17 +114154,17 @@ func convertCompoundSelectToSubquery(tls *libc.TLS, pWalker uintptr, p uintptr) db = (*Parse)(unsafe.Pointer(pParse)).Fdb pNew = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Select{}))) if pNew == uintptr(0) { - return 2 + return WRC_Abort } libc.Xmemset(tls, bp /* &dummy */, 0, uint64(unsafe.Sizeof(Token{}))) pNewSrc = Xsqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp /* &dummy */, pNew, uintptr(0), uintptr(0)) if pNewSrc == uintptr(0) { - return 2 + return WRC_Abort } *(*Select)(unsafe.Pointer(pNew)) = *(*Select)(unsafe.Pointer(p)) (*Select)(unsafe.Pointer(p)).FpSrc = pNewSrc - (*Select)(unsafe.Pointer(p)).FpEList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), Xsqlite3Expr(tls, db, 177, uintptr(0))) - (*Select)(unsafe.Pointer(p)).Fop = U8(136) + (*Select)(unsafe.Pointer(p)).FpEList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), Xsqlite3Expr(tls, db, TK_ASTERISK, uintptr(0))) + (*Select)(unsafe.Pointer(p)).Fop = TK_SELECT (*Select)(unsafe.Pointer(p)).FpWhere = uintptr(0) (*Select)(unsafe.Pointer(pNew)).FpGroupBy = uintptr(0) (*Select)(unsafe.Pointer(pNew)).FpHaving = uintptr(0) @@ -116310,13 +114173,13 @@ func convertCompoundSelectToSubquery(tls *libc.TLS, pWalker uintptr, p uintptr) (*Select)(unsafe.Pointer(p)).FpNext = uintptr(0) (*Select)(unsafe.Pointer(p)).FpWith = uintptr(0) (*Select)(unsafe.Pointer(p)).FpWinDefn = uintptr(0) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000100)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_Compound))) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0010000)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_Converted) (*Select)(unsafe.Pointer((*Select)(unsafe.Pointer(pNew)).FpPrior)).FpNext = pNew (*Select)(unsafe.Pointer(pNew)).FpLimit = uintptr(0) - return 0 + return WRC_Continue } // Check to see if the FROM clause term pFrom has table-valued function @@ -116403,7 +114266,7 @@ func withExpand(tls *libc.TLS, pWalker uintptr, pFrom uintptr) int32 { /* sqlite // WITH clause that pCte belongs to if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { - return 1 + return SQLITE_ERROR } pCte = searchWith(tls, (*Parse)(unsafe.Pointer(pParse)).FpWith, pFrom, bp+40 /* &pWith */) @@ -116421,29 +114284,29 @@ func withExpand(tls *libc.TLS, pWalker uintptr, pFrom uintptr) int32 { /* sqlite // In this case, proceed. if (*Cte)(unsafe.Pointer(pCte)).FzCteErr != 0 { Xsqlite3ErrorMsg(tls, pParse, (*Cte)(unsafe.Pointer(pCte)).FzCteErr, libc.VaList(bp, (*Cte)(unsafe.Pointer(pCte)).FzName)) - return 1 + return SQLITE_ERROR } if cannotBeFunction(tls, pParse, pFrom) != 0 { - return 1 + return SQLITE_ERROR } (*SrcList_item)(unsafe.Pointer(pFrom)).FpTab = libc.AssignUintptr(&pTab, Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Table{})))) if pTab == uintptr(0) { - return 2 + return WRC_Abort } (*Table)(unsafe.Pointer(pTab)).FnTabRef = U32(1) (*Table)(unsafe.Pointer(pTab)).FzName = Xsqlite3DbStrDup(tls, db, (*Cte)(unsafe.Pointer(pCte)).FzName) (*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1) (*Table)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200) - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0002 | 0x0200)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(TF_Ephemeral | TF_NoVisibleRowid)) (*SrcList_item)(unsafe.Pointer(pFrom)).FpSelect = Xsqlite3SelectDup(tls, db, (*Cte)(unsafe.Pointer(pCte)).FpSelect, 0) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - return 7 + return SQLITE_NOMEM } // Check if this is a recursive CTE. pSel = (*SrcList_item)(unsafe.Pointer(pFrom)).FpSelect - bMayRecursive = (libc.Bool32((int32((*Select)(unsafe.Pointer(pSel)).Fop) == 133) || (int32((*Select)(unsafe.Pointer(pSel)).Fop) == 132))) + bMayRecursive = (libc.Bool32((int32((*Select)(unsafe.Pointer(pSel)).Fop) == TK_ALL) || (int32((*Select)(unsafe.Pointer(pSel)).Fop) == TK_UNION))) if bMayRecursive != 0 { var i int32 var pSrc uintptr = (*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pFrom)).FpSelect)).FpSrc @@ -116455,7 +114318,7 @@ func withExpand(tls *libc.TLS, pWalker uintptr, pFrom uintptr) int32 { /* sqlite (*SrcList_item)(unsafe.Pointer(pItem)).FpTab = pTab libc.SetBitFieldPtr8Uint32(pItem+60 /* &.fg */ +4 /* &.isRecursive */, uint32(1), 5, 0x20) (*Table)(unsafe.Pointer(pTab)).FnTabRef++ - *(*U32)(unsafe.Pointer(pSel + 4 /* &.selFlags */)) |= (U32(0x0002000)) + *(*U32)(unsafe.Pointer(pSel + 4 /* &.selFlags */)) |= (SF_Recursive) } } } @@ -116464,7 +114327,7 @@ func withExpand(tls *libc.TLS, pWalker uintptr, pFrom uintptr) int32 { /* sqlite if (*Table)(unsafe.Pointer(pTab)).FnTabRef > U32(2) { Xsqlite3ErrorMsg(tls, pParse, ts+16681 /* "multiple referen..." */, libc.VaList(bp+8, (*Cte)(unsafe.Pointer(pCte)).FzName)) - return 1 + return SQLITE_ERROR } (*Cte)(unsafe.Pointer(pCte)).FzCteErr = ts + 16724 /* "circular referen..." */ @@ -116489,14 +114352,14 @@ func withExpand(tls *libc.TLS, pWalker uintptr, pFrom uintptr) int32 { /* sqlite Xsqlite3ErrorMsg(tls, pParse, ts+16747, /* "table %s has %d ..." */ libc.VaList(bp+16, (*Cte)(unsafe.Pointer(pCte)).FzName, (*ExprList)(unsafe.Pointer(pEList)).FnExpr, (*ExprList)(unsafe.Pointer((*Cte)(unsafe.Pointer(pCte)).FpCols)).FnExpr)) (*Parse)(unsafe.Pointer(pParse)).FpWith = pSavedWith - return 1 + return SQLITE_ERROR } pEList = (*Cte)(unsafe.Pointer(pCte)).FpCols } Xsqlite3ColumnsFromExprList(tls, pParse, pEList, (pTab + 70 /* &.nCol */), (pTab + 8 /* &.aCol */)) if bMayRecursive != 0 { - if ((*Select)(unsafe.Pointer(pSel)).FselFlags & U32(0x0002000)) != 0 { + if ((*Select)(unsafe.Pointer(pSel)).FselFlags & SF_Recursive) != 0 { (*Cte)(unsafe.Pointer(pCte)).FzCteErr = ts + 16785 /* "multiple recursi..." */ } else { (*Cte)(unsafe.Pointer(pCte)).FzCteErr = ts + 16819 /* "recursive refere..." */ @@ -116507,7 +114370,7 @@ func withExpand(tls *libc.TLS, pWalker uintptr, pFrom uintptr) int32 { /* sqlite (*Parse)(unsafe.Pointer(pParse)).FpWith = pSavedWith } - return 0 + return SQLITE_OK } // If the SELECT passed as the second argument has an associated WITH @@ -116541,7 +114404,7 @@ func Xsqlite3ExpandSubquery(tls *libc.TLS, pParse uintptr, pFrom uintptr) int32 (*SrcList_item)(unsafe.Pointer(pFrom)).FpTab = libc.AssignUintptr(&pTab, Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(Table{})))) if pTab == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Table)(unsafe.Pointer(pTab)).FnTabRef = U32(1) if (*SrcList_item)(unsafe.Pointer(pFrom)).FzAlias != 0 { @@ -116555,12 +114418,12 @@ func Xsqlite3ExpandSubquery(tls *libc.TLS, pParse uintptr, pFrom uintptr) int32 Xsqlite3ColumnsFromExprList(tls, pParse, (*Select)(unsafe.Pointer(pSel)).FpEList, (pTab + 70 /* &.nCol */), (pTab + 8 /* &.aCol */)) (*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1) (*Table)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200) - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0002)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (TF_Ephemeral) if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { - return 1 + return SQLITE_ERROR } - return 0 + return SQLITE_OK } // This routine is a Walker callback for "expanding" a SELECT statement. @@ -116603,13 +114466,13 @@ func selectExpander(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sqlite var selFlags U16 = U16((*Select)(unsafe.Pointer(p)).FselFlags) var elistFlags U32 = U32(0) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0000040)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_Expanded) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - return 2 + return WRC_Abort } - if (int32(selFlags) & 0x0000040) != 0 { - return 1 + if (int32(selFlags) & SF_Expanded) != 0 { + return WRC_Prune } if (*Walker)(unsafe.Pointer(pWalker)).FeCode != 0 { // Renumber selId because it has been copied from a view @@ -116640,7 +114503,7 @@ __1: } if withExpand(tls, pWalker, pFrom) != 0 { - return 2 + return WRC_Abort } if (*SrcList_item)(unsafe.Pointer(pFrom)).FpTab != 0 { } else if (*SrcList_item)(unsafe.Pointer(pFrom)).FzName == uintptr(0) { @@ -116648,43 +114511,43 @@ __1: // A sub-query in the FROM clause of a SELECT if Xsqlite3WalkSelect(tls, pWalker, pSel) != 0 { - return 2 + return WRC_Abort } if Xsqlite3ExpandSubquery(tls, pParse, pFrom) != 0 { - return 2 + return WRC_Abort } } else { // An ordinary table or view name in the FROM clause (*SrcList_item)(unsafe.Pointer(pFrom)).FpTab = libc.AssignUintptr(&pTab, Xsqlite3LocateTableItem(tls, pParse, uint32(0), pFrom)) if pTab == uintptr(0) { - return 2 + return WRC_Abort } if (*Table)(unsafe.Pointer(pTab)).FnTabRef >= U32(0xffff) { Xsqlite3ErrorMsg(tls, pParse, ts+16869, /* "too many referen..." */ libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName)) (*SrcList_item)(unsafe.Pointer(pFrom)).FpTab = uintptr(0) - return 2 + return WRC_Abort } (*Table)(unsafe.Pointer(pTab)).FnTabRef++ if !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) && (cannotBeFunction(tls, pParse, pFrom) != 0) { - return 2 + return WRC_Abort } if ((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) || ((*Table)(unsafe.Pointer(pTab)).FpSelect != 0) { var nCol I16 var eCodeOrig U8 = U8((*Walker)(unsafe.Pointer(pWalker)).FeCode) if Xsqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { - return 2 + return WRC_Abort } - if ((*Table)(unsafe.Pointer(pTab)).FpSelect != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x80000000)) == uint64(0)) { + if ((*Table)(unsafe.Pointer(pTab)).FpSelect != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_EnableView) == uint64(0)) { Xsqlite3ErrorMsg(tls, pParse, ts+16908, /* "access to view \"..." */ libc.VaList(bp+8, (*Table)(unsafe.Pointer(pTab)).FzName)) } if ((((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) && ((uint32(int32(*(*uint8)(unsafe.Pointer((pFrom + 60 /* &.fg */) + 4 /* &.fromDDL */)) & 0x40 >> 6))) != 0)) && ((*Table)(unsafe.Pointer(pTab)).FpVTable != uintptr(0))) && - (int32((*VTable)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FpVTable)).FeVtabRisk) > (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000080)) != uint64(0)))) { + (int32((*VTable)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FpVTable)).FeVtabRisk) > (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_TrustedSchema) != uint64(0)))) { Xsqlite3ErrorMsg(tls, pParse, ts+16939, /* "unsafe use of vi..." */ libc.VaList(bp+16, (*Table)(unsafe.Pointer(pTab)).FzName)) } @@ -116700,7 +114563,7 @@ __1: // Locate the index named by the INDEXED BY clause, if any. if Xsqlite3IndexedByLookup(tls, pParse, pFrom) != 0 { - return 2 + return WRC_Abort } } @@ -116715,7 +114578,7 @@ __3: // Process NATURAL keywords, and ON and USING clauses of joins. if (((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0)) || (sqliteProcessJoin(tls, pParse, p) != 0) { - return 2 + return WRC_Abort } // For every "*" that occurs in the column list, insert the names of @@ -116730,11 +114593,11 @@ __3: // that need expanding. for k = 0; k < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; k++ { pE = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(k)*32)).FpExpr - if int32((*Expr)(unsafe.Pointer(pE)).Fop) == 177 { + if int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_ASTERISK { break } - if (int32((*Expr)(unsafe.Pointer(pE)).Fop) == 139) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pE)).FpRight)).Fop) == 177) { + if (int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_DOT) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pE)).FpRight)).Fop) == TK_ASTERISK) { break } elistFlags = elistFlags | ((*Expr)(unsafe.Pointer(pE)).Fflags) @@ -116746,16 +114609,16 @@ __3: var a uintptr = pEList + 8 /* &.a */ var pNew uintptr = uintptr(0) var flags int32 = int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags) - var longNames int32 = (libc.Bool32(((flags & 0x00000004) != 0) && - ((flags & 0x00000040) == 0))) + var longNames int32 = (libc.Bool32(((flags & SQLITE_FullColNames) != 0) && + ((flags & SQLITE_ShortColNames) == 0))) for k = 0; k < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; k++ { pE = (*ExprList_item)(unsafe.Pointer(a + uintptr(k)*32)).FpExpr elistFlags = elistFlags | ((*Expr)(unsafe.Pointer(pE)).Fflags) pRight = (*Expr)(unsafe.Pointer(pE)).FpRight - if (int32((*Expr)(unsafe.Pointer(pE)).Fop) != 177) && - ((int32((*Expr)(unsafe.Pointer(pE)).Fop) != 139) || (int32((*Expr)(unsafe.Pointer(pRight)).Fop) != 177)) { + if (int32((*Expr)(unsafe.Pointer(pE)).Fop) != TK_ASTERISK) && + ((int32((*Expr)(unsafe.Pointer(pE)).Fop) != TK_DOT) || (int32((*Expr)(unsafe.Pointer(pRight)).Fop) != TK_ASTERISK)) { // This particular expression does not need to be expanded. pNew = Xsqlite3ExprListAppend(tls, pParse, pNew, (*ExprList_item)(unsafe.Pointer(a+uintptr(k)*32)).FpExpr) if pNew != 0 { @@ -116769,7 +114632,7 @@ __3: // expanded. var tableSeen int32 = 0 // Set to 1 when TABLE matches var zTName uintptr = uintptr(0) // text of name of TABLE - if int32((*Expr)(unsafe.Pointer(pE)).Fop) == 139 { + if int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_DOT { zTName = *(*uintptr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pE)).FpLeft + 8 /* &.u */)) } @@ -116791,7 +114654,7 @@ __3: if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { goto __6 } - if (pSub == uintptr(0)) || (((*Select)(unsafe.Pointer(pSub)).FselFlags & U32(0x0000800)) == U32(0)) { + if (pSub == uintptr(0)) || (((*Select)(unsafe.Pointer(pSub)).FselFlags & SF_NestedFrom) == U32(0)) { pSub = uintptr(0) if (zTName != 0) && (Xsqlite3StrICmp(tls, zTName, zTabName) != 0) { goto __5 @@ -116818,14 +114681,14 @@ __3: // If a column is marked as 'hidden', omit it from the expanded // result-set list unless the SELECT has the SF_IncludeHidden // bit set. - if (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0020000)) == U32(0)) && - ((int32((*Column)(unsafe.Pointer(((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*32))).FcolFlags) & 0x0002) != 0) { + if (((*Select)(unsafe.Pointer(p)).FselFlags & SF_IncludeHidden) == U32(0)) && + ((int32((*Column)(unsafe.Pointer(((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*32))).FcolFlags) & COLFLAG_HIDDEN) != 0) { continue } tableSeen = 1 if (i > 0) && (zTName == uintptr(0)) { - if ((int32((*SrcList_item)(unsafe.Pointer(pFrom)).Ffg.Fjointype) & 0x0004) != 0) && + if ((int32((*SrcList_item)(unsafe.Pointer(pFrom)).Ffg.Fjointype) & JT_NATURAL) != 0) && (tableAndColumnIndex(tls, pTabList, i, zName, uintptr(0), uintptr(0), 1) != 0) { // In a NATURAL join, omit the join columns from the // table to the right of the join @@ -116837,16 +114700,16 @@ __3: continue } } - pRight = Xsqlite3Expr(tls, db, 59, zName) + pRight = Xsqlite3Expr(tls, db, TK_ID, zName) zColname = zName zToFree = uintptr(0) if (longNames != 0) || ((*SrcList)(unsafe.Pointer(pTabList)).FnSrc > 1) { var pLeft uintptr - pLeft = Xsqlite3Expr(tls, db, 59, zTabName) - pExpr = Xsqlite3PExpr(tls, pParse, 139, pLeft, pRight) + pLeft = Xsqlite3Expr(tls, db, TK_ID, zTabName) + pExpr = Xsqlite3PExpr(tls, pParse, TK_DOT, pLeft, pRight) if zSchemaName != 0 { - pLeft = Xsqlite3Expr(tls, db, 59, zSchemaName) - pExpr = Xsqlite3PExpr(tls, pParse, 139, pLeft, pExpr) + pLeft = Xsqlite3Expr(tls, db, TK_ID, zSchemaName) + pExpr = Xsqlite3PExpr(tls, pParse, TK_DOT, pLeft, pExpr) } if longNames != 0 { zColname = Xsqlite3MPrintf(tls, db, ts+9959 /* "%s.%s" */, libc.VaList(bp+24, zTabName, zName)) @@ -116858,7 +114721,7 @@ __3: pNew = Xsqlite3ExprListAppend(tls, pParse, pNew, pExpr) Xsqlite3TokenInit(tls, bp+72 /* &sColname */, zColname) Xsqlite3ExprListSetName(tls, pParse, pNew, bp+72 /* &sColname */, 0) - if ((pNew != 0) && (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000800)) != U32(0))) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if ((pNew != 0) && (((*Select)(unsafe.Pointer(p)).FselFlags & SF_NestedFrom) != U32(0))) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { var pX uintptr = ((pNew + 8 /* &.a */) + uintptr(((*ExprList)(unsafe.Pointer(pNew)).FnExpr-1))*32) Xsqlite3DbFree(tls, db, (*ExprList_item)(unsafe.Pointer(pX)).FzEName) if pSub != 0 { @@ -116869,7 +114732,7 @@ __3: libc.VaList(bp+40, zSchemaName, zTabName, zColname)) } - libc.SetBitFieldPtr8Uint32(pX+20 /* &.eEName */, uint32(2), 0, 0x3) + libc.SetBitFieldPtr8Uint32(pX+20 /* &.eEName */, ENAME_TAB, 0, 0x3) } Xsqlite3DbFree(tls, db, zToFree) } @@ -116896,15 +114759,15 @@ __3: (*Select)(unsafe.Pointer(p)).FpEList = pNew } if (*Select)(unsafe.Pointer(p)).FpEList != 0 { - if (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(2)*4)) { + if (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 2*4)) { Xsqlite3ErrorMsg(tls, pParse, ts+17021 /* "too many columns..." */, 0) - return 2 + return WRC_Abort } - if (elistFlags & (U32(0x000004 | 0x200000))) != U32(0) { - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0040000)) + if (elistFlags & (U32(EP_HasFunc | EP_Subquery))) != U32(0) { + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_ComplexResult) } } - return 0 + return WRC_Continue } // This routine "expands" a SELECT statement and all of its subqueries. @@ -116962,10 +114825,10 @@ func selectAddSubqueryTypeInfo(tls *libc.TLS, pWalker uintptr, p uintptr) { /* s var pTabList uintptr var pFrom uintptr - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000080)) != 0 { + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_HasTypeInfo) != 0 { return } - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0000080)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_HasTypeInfo) pParse = (*Walker)(unsafe.Pointer(pWalker)).FpParse pTabList = (*Select)(unsafe.Pointer(p)).FpSrc i = 0 @@ -116977,7 +114840,7 @@ __1: { var pTab uintptr = (*SrcList_item)(unsafe.Pointer(pFrom)).FpTab - if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0002)) != U32(0) { + if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Ephemeral) != U32(0) { // A sub-query in the FROM clause of a SELECT var pSel uintptr = (*SrcList_item)(unsafe.Pointer(pFrom)).FpSelect if pSel != 0 { @@ -116985,7 +114848,7 @@ __1: pSel = (*Select)(unsafe.Pointer(pSel)).FpPrior } Xsqlite3SelectAddColumnTypeAndCollation(tls, pParse, pTab, pSel, - int8(0x40)) + SQLITE_AFF_NONE) } } @@ -117038,7 +114901,7 @@ func Xsqlite3SelectPrep(tls *libc.TLS, pParse uintptr, p uintptr, pOuterNC uintp if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { return } - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000080)) != 0 { + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_HasTypeInfo) != 0 { return } sqlite3SelectExpand(tls, pParse, p) @@ -117069,7 +114932,7 @@ func resetAccumulator(tls *libc.TLS, pParse uintptr, pAggInfo uintptr) { /* sqli if ((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) || ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0) { return } - Xsqlite3VdbeAddOp3(tls, v, 72, 0, (*AggInfo)(unsafe.Pointer(pAggInfo)).FmnReg, (*AggInfo)(unsafe.Pointer(pAggInfo)).FmxReg) + Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, (*AggInfo)(unsafe.Pointer(pAggInfo)).FmnReg, (*AggInfo)(unsafe.Pointer(pAggInfo)).FmxReg) pFunc = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc i = 0 __1: @@ -117086,7 +114949,7 @@ __1: (*AggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct = -1 } else { var pKeyInfo uintptr = Xsqlite3KeyInfoFromExprList(tls, pParse, *(*uintptr)(unsafe.Pointer(pE + 32 /* &.x */)), 0, 0) - Xsqlite3VdbeAddOp4(tls, v, 100, (*AggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct, 0, 0, + Xsqlite3VdbeAddOp4(tls, v, OP_OpenEphemeral, (*AggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct, 0, 0, pKeyInfo, -9) } } @@ -117116,7 +114979,7 @@ __1: { var pList uintptr = *(*uintptr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr + 32 /* &.x */)) - Xsqlite3VdbeAddOp2(tls, v, 157, (*AggInfo_func)(unsafe.Pointer(pF)).FiMem, func() int32 { + Xsqlite3VdbeAddOp2(tls, v, OP_AggFinal, (*AggInfo_func)(unsafe.Pointer(pF)).FiMem, func() int32 { if pList != 0 { return (*ExprList)(unsafe.Pointer(pList)).FnExpr } @@ -117162,10 +115025,10 @@ __1: var regAgg int32 var pList uintptr = *(*uintptr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr + 32 /* &.x */)) - if ((*Expr)(unsafe.Pointer(((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer(((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr))).Fflags & (EP_WinFunc)) != U32(0) { var pFilter uintptr = (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr + 64 /* &.y */)))).FpFilter if (((*AggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0) && - (((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFunc)).FfuncFlags & U32(0x0020)) != 0)) && + (((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFunc)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != 0)) && (regAcc != 0) { // If regAcc==0, there there exists some min() or max() function // without a FILTER clause that will ensure the magnet registers @@ -117180,15 +115043,15 @@ __1: // the first row (regAcc contains 1), set the magnet register so that // the accumulators are not populated unless the min()/max() is invoked // and indicates that they should be. - Xsqlite3VdbeAddOp2(tls, v, 77, regAcc, regHit) + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, regAcc, regHit) } addrNext = Xsqlite3VdbeMakeLabel(tls, pParse) - Xsqlite3ExprIfFalse(tls, pParse, pFilter, addrNext, 0x10) + Xsqlite3ExprIfFalse(tls, pParse, pFilter, addrNext, SQLITE_JUMPIFNULL) } if pList != 0 { nArg = (*ExprList)(unsafe.Pointer(pList)).FnExpr regAgg = Xsqlite3GetTempRange(tls, pParse, nArg) - Xsqlite3ExprCodeExprList(tls, pParse, pList, regAgg, 0, uint8(0x01)) + Xsqlite3ExprCodeExprList(tls, pParse, pList, regAgg, 0, SQLITE_ECEL_DUP) } else { nArg = 0 regAgg = 0 @@ -117201,7 +115064,7 @@ __1: // Also an error codeDistinct(tls, pParse, (*AggInfo_func)(unsafe.Pointer(pF)).FiDistinct, addrNext, 1, regAgg) } - if ((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFunc)).FfuncFlags & U32(0x0020)) != 0 { + if ((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFunc)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != 0 { var pColl uintptr = uintptr(0) var pItem uintptr var j int32 @@ -117230,9 +115093,9 @@ __1: if (regHit == 0) && ((*AggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0) { regHit = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) } - Xsqlite3VdbeAddOp4(tls, v, 81, regHit, 0, 0, pColl, -2) + Xsqlite3VdbeAddOp4(tls, v, OP_CollSeq, regHit, 0, 0, pColl, -2) } - Xsqlite3VdbeAddOp3(tls, v, 154, 0, regAgg, (*AggInfo_func)(unsafe.Pointer(pF)).FiMem) + Xsqlite3VdbeAddOp3(tls, v, OP_AggStep, 0, regAgg, (*AggInfo_func)(unsafe.Pointer(pF)).FiMem) Xsqlite3VdbeAppendP4(tls, v, (*AggInfo_func)(unsafe.Pointer(pF)).FpFunc, -8) Xsqlite3VdbeChangeP5(tls, v, uint16(U8(nArg))) Xsqlite3ReleaseTempRange(tls, pParse, regAgg, nArg) @@ -117253,7 +115116,7 @@ __3: regHit = regAcc } if regHit != 0 { - addrHitTest = Xsqlite3VdbeAddOp1(tls, v, 18, regHit) + addrHitTest = Xsqlite3VdbeAddOp1(tls, v, OP_If, regHit) } i = 0 pC = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol @@ -117287,7 +115150,7 @@ func explainSimpleCount(tls *libc.TLS, pParse uintptr, pTab uintptr, pIdx uintpt defer tls.Free(24) if int32((*Parse)(unsafe.Pointer(pParse)).Fexplain) == 2 { - var bCover int32 = (libc.Bool32((pIdx != uintptr(0)) && ((((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) || !((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2)))) + var bCover int32 = (libc.Bool32((pIdx != uintptr(0)) && ((((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) || !((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY)))) Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+17103, /* "SCAN TABLE %s%s%..." */ libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName, func() uintptr { @@ -117315,11 +115178,11 @@ func explainSimpleCount(tls *libc.TLS, pParse uintptr, pTab uintptr, pIdx uintpt // clause. If so, add it to the WHERE clause and replace the sub-expression // within the HAVING expression with a constant "1". func havingToWhereExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:134884:12: */ - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 44 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_AND { var pS uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) if Xsqlite3ExprIsConstantOrGroupBy(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, pExpr, (*Select)(unsafe.Pointer(pS)).FpGroupBy) != 0 { var db uintptr = (*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(pWalker)).FpParse)).Fdb - var pNew uintptr = Xsqlite3Expr(tls, db, 152, ts+6737 /* "1" */) + var pNew uintptr = Xsqlite3Expr(tls, db, TK_INTEGER, ts+6737 /* "1" */) if pNew != 0 { var pWhere uintptr = (*Select)(unsafe.Pointer(pS)).FpWhere { @@ -117333,9 +115196,9 @@ func havingToWhereExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(1) } } - return 1 + return WRC_Prune } - return 0 + return WRC_Continue } // Transfer eligible terms from the HAVING clause of a query, which is @@ -117544,14 +115407,14 @@ func Xsqlite3Select(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) int return 1 __1: ; - if !(Xsqlite3AuthCheck(tls, pParse, 21, uintptr(0), uintptr(0), uintptr(0)) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_SELECT, uintptr(0), uintptr(0), uintptr(0)) != 0) { goto __2 } return 1 __2: ; - if !((int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest)) <= 8) { + if !((int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest)) <= SRT_DistQueue) { goto __3 } @@ -117559,8 +115422,8 @@ __2: // DISTINCT so it can be removed too. Xsqlite3ExprListDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpOrderBy) (*Select)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000001)) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0400000)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_Distinct))) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_NoopOrderBy) __3: ; Xsqlite3SelectPrep(tls, pParse, p, uintptr(0)) @@ -117575,10 +115438,10 @@ __4: // as part of populating the temp table for an UPDATE...FROM statement. // In this case, it is an error if the target object (pSrc->a[0]) name // or alias is duplicated within FROM clause (pSrc->a[1..n]). - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0800000)) != 0) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_UpdateFrom) != 0) { goto __5 } - p0 = (((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112) + p0 = ((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) i = 1 __6: if !(i < (*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc) { @@ -117609,7 +115472,7 @@ __8: __5: ; - if !(int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) == 9) { + if !(int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) == SRT_Output) { goto __10 } generateColumnNames(tls, pParse, p) @@ -117625,7 +115488,7 @@ __10: __11: ; pTabList = (*Select)(unsafe.Pointer(p)).FpSrc - isAgg = (libc.Bool32(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000008)) != U32(0))) + isAgg = (libc.Bool32(((*Select)(unsafe.Pointer(p)).FselFlags & SF_Aggregate) != U32(0))) libc.Xmemset(tls, bp+48 /* &sSort */, 0, uint64(unsafe.Sizeof(SortCtx{}))) (*SortCtx)(unsafe.Pointer(bp + 48 /* &sSort */)).FpOrderBy = (*Select)(unsafe.Pointer(p)).FpOrderBy @@ -117646,13 +115509,13 @@ __12: // Convert LEFT JOIN into JOIN if there are terms of the right table // of the LEFT JOIN used in the WHERE clause. - if !((((int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & 0x0008) != 0) && + if !((((int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & JT_LEFT) != 0) && (Xsqlite3ExprImpliesNonNullRow(tls, (*Select)(unsafe.Pointer(p)).FpWhere, (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor) != 0)) && - ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x2000)) == 0)) { + ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_SimplifyJoin)) == 0)) { goto __15 } - *(*U8)(unsafe.Pointer(pItem + 60 /* &.fg */ /* &.jointype */)) &= libc.Uint8FromInt32((^libc.Int32((0x0008 | 0x0020)))) + *(*U8)(unsafe.Pointer(pItem + 60 /* &.fg */ /* &.jointype */)) &= libc.Uint8FromInt32((libc.CplInt32((JT_LEFT | JT_OUTER)))) unsetJoinExpr(tls, (*Select)(unsafe.Pointer(p)).FpWhere, (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor) __15: ; @@ -117682,7 +115545,7 @@ __17: // is not a join. But if the outer query is not a join, then the subquery // will be implemented as a co-routine and there is no advantage to // flattening in that case. - if !(((*Select)(unsafe.Pointer(pSub)).FselFlags & U32(0x0000008)) != U32(0)) { + if !(((*Select)(unsafe.Pointer(pSub)).FselFlags & SF_Aggregate) != U32(0)) { goto __18 } goto __13 @@ -117708,9 +115571,9 @@ __18: // SELECT x FROM (SELECT x FROM tab ORDER BY y LIMIT 10); if !(((((*Select)(unsafe.Pointer(pSub)).FpOrderBy != uintptr(0)) && (i == 0)) && - (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0040000)) != U32(0))) && + (((*Select)(unsafe.Pointer(p)).FselFlags & SF_ComplexResult) != U32(0))) && (((*SrcList)(unsafe.Pointer(pTabList)).FnSrc == 1) || - ((int32((*SrcList_item)(unsafe.Pointer((pTabList+8 /* &.a */)+uintptr(1)*112)).Ffg.Fjointype) & (0x0008 | 0x0002)) != 0))) { + ((int32((*SrcList_item)(unsafe.Pointer((pTabList+8 /* &.a */)+1*112)).Ffg.Fjointype) & (JT_LEFT | JT_CROSS)) != 0))) { goto __19 } goto __13 @@ -117737,7 +115600,7 @@ __20: goto select_end __22: ; - if !(!((int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest)) <= 8)) { + if !(!((int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest)) <= SRT_DistQueue)) { goto __23 } (*SortCtx)(unsafe.Pointer(bp + 48 /* &sSort */)).FpOrderBy = (*Select)(unsafe.Pointer(p)).FpOrderBy @@ -117772,7 +115635,7 @@ __24: // as the equivalent optimization will be handled by query planner in // sqlite3WhereBegin(). if !((((*SrcList)(unsafe.Pointer(pTabList)).FnSrc > 1) && - ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x8000)) == 0)) && + ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_PropagateConst)) == 0)) && (propagateConstants(tls, pParse, p) != 0)) { goto __26 } @@ -117810,7 +115673,7 @@ __28: if !(((*SrcList_item)(unsafe.Pointer(pItem1)).FcolUsed == uint64(0)) && ((*SrcList_item)(unsafe.Pointer(pItem1)).FzName != uintptr(0))) { goto __31 } - Xsqlite3AuthCheck(tls, pParse, 20, (*SrcList_item)(unsafe.Pointer(pItem1)).FzName, ts+703 /* "" */, (*SrcList_item)(unsafe.Pointer(pItem1)).FzDatabase) + Xsqlite3AuthCheck(tls, pParse, SQLITE_READ, (*SrcList_item)(unsafe.Pointer(pItem1)).FzName, ts+703 /* "" */, (*SrcList_item)(unsafe.Pointer(pItem1)).FzDatabase) __31: ; @@ -117845,9 +115708,9 @@ __32: // Make copies of constant WHERE-clause terms in the outer query down // inside the subquery. This can help the subquery to run more efficiently. - if !(((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x1000)) == 0) && + if !(((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_PushDown)) == 0) && (pushDownWhereTerms(tls, pParse, pSub1, (*Select)(unsafe.Pointer(p)).FpWhere, (*SrcList_item)(unsafe.Pointer(pItem1)).FiCursor, - (libc.Bool32((int32((*SrcList_item)(unsafe.Pointer(pItem1)).Ffg.Fjointype)&0x0020) != 0))) != 0)) { + (libc.Bool32((int32((*SrcList_item)(unsafe.Pointer(pItem1)).Ffg.Fjointype)&JT_OUTER) != 0))) != 0)) { goto __33 } goto __34 @@ -117869,7 +115732,7 @@ __34: // implementation? if !((i == 0) && (((*SrcList)(unsafe.Pointer(pTabList)).FnSrc == 1) || - ((int32((*SrcList_item)(unsafe.Pointer((pTabList+8 /* &.a */)+uintptr(1)*112)).Ffg.Fjointype) & (0x0008 | 0x0002)) != 0))) { + ((int32((*SrcList_item)(unsafe.Pointer((pTabList+8 /* &.a */)+1*112)).Ffg.Fjointype) & (JT_LEFT | JT_CROSS)) != 0))) { goto __35 } // Implement a co-routine that will return a single row of the result @@ -117877,10 +115740,10 @@ __34: addrTop = (Xsqlite3VdbeCurrentAddr(tls, v) + 1) (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp3(tls, v, 13, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn, 0, addrTop) + Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn, 0, addrTop) (*SrcList_item)(unsafe.Pointer(pItem1)).FaddrFillSub = addrTop - Xsqlite3SelectDestInit(tls, bp+96 /* &dest */, 13, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn) + Xsqlite3SelectDestInit(tls, bp+96 /* &dest */, SRT_Coroutine, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn) Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+17238 /* "CO-ROUTINE %u" */, libc.VaList(bp+32, (*Select)(unsafe.Pointer(pSub1)).FselId)) Xsqlite3Select(tls, pParse, pSub1, bp+96 /* &dest */) (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem1)).FpTab)).FnRowLogEst = (*Select)(unsafe.Pointer(pSub1)).FnSelectRow @@ -117895,7 +115758,7 @@ __35: // Ticket c52b09c7f38903b1311 (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - topAddr = Xsqlite3VdbeAddOp2(tls, v, 69, 0, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn) + topAddr = Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn) (*SrcList_item)(unsafe.Pointer(pItem1)).FaddrFillSub = (topAddr + 1) if !((int32(*(*uint8)(unsafe.Pointer((pItem1 + 60 /* &.fg */) + 4 /* &.isCorrelated */)) & 0x8 >> 3)) == 0) { goto __37 @@ -117903,7 +115766,7 @@ __35: // If the subquery is not correlated and if we are not inside of // a trigger, then we only need to compute the value of the subquery // once. - onceAddr = Xsqlite3VdbeAddOp0(tls, v, 17) + onceAddr = Xsqlite3VdbeAddOp0(tls, v, OP_Once) goto __38 __37: @@ -117914,12 +115777,12 @@ __38: if !(pPrior != 0) { goto __39 } - Xsqlite3VdbeAddOp2(tls, v, 98, (*SrcList_item)(unsafe.Pointer(pItem1)).FiCursor, (*SrcList_item)(unsafe.Pointer(pPrior)).FiCursor) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*SrcList_item)(unsafe.Pointer(pItem1)).FiCursor, (*SrcList_item)(unsafe.Pointer(pPrior)).FiCursor) (*Select)(unsafe.Pointer(pSub1)).FnSelectRow = (*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pPrior)).FpSelect)).FnSelectRow goto __40 __39: - Xsqlite3SelectDestInit(tls, bp+96 /* &dest */, 12, (*SrcList_item)(unsafe.Pointer(pItem1)).FiCursor) + Xsqlite3SelectDestInit(tls, bp+96 /* &dest */, SRT_EphemTab, (*SrcList_item)(unsafe.Pointer(pItem1)).FiCursor) Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+17252 /* "MATERIALIZE %u" */, libc.VaList(bp+40, (*Select)(unsafe.Pointer(pSub1)).FselId)) Xsqlite3Select(tls, pParse, pSub1, bp+96 /* &dest */) __40: @@ -117931,7 +115794,7 @@ __40: Xsqlite3VdbeJumpHere(tls, v, onceAddr) __41: ; - retAddr = Xsqlite3VdbeAddOp1(tls, v, 65, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn) + retAddr = Xsqlite3VdbeAddOp1(tls, v, OP_Return, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn) Xsqlite3VdbeChangeP1(tls, v, topAddr, retAddr) Xsqlite3ClearTempRegCache(tls, pParse) @@ -117959,7 +115822,7 @@ __30: pWhere = (*Select)(unsafe.Pointer(p)).FpWhere pGroupBy = (*Select)(unsafe.Pointer(p)).FpGroupBy pHaving = (*Select)(unsafe.Pointer(p)).FpHaving - (*DistinctCtx)(unsafe.Pointer(bp + 136 /* &sDistinct */)).FisTnct = (U8(libc.Bool32(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000001)) != U32(0)))) + (*DistinctCtx)(unsafe.Pointer(bp + 136 /* &sDistinct */)).FisTnct = (U8(libc.Bool32(((*Select)(unsafe.Pointer(p)).FselFlags & SF_Distinct) != U32(0)))) // If the query is DISTINCT with an ORDER BY but is not an aggregate, and // if the select-list is the same as the ORDER BY list, then this query @@ -117975,14 +115838,14 @@ __30: // used for both the ORDER BY and DISTINCT processing. As originally // written the query must use a temp-table for at least one of the ORDER // BY and DISTINCT, and an index or separate temp-table for the other. - if !(((((*Select)(unsafe.Pointer(p)).FselFlags & (U32(0x0000001 | 0x0000008))) == U32(0x0000001)) && + if !(((((*Select)(unsafe.Pointer(p)).FselFlags & (U32(SF_Distinct | SF_Aggregate))) == SF_Distinct) && (Xsqlite3ExprListCompare(tls, (*SortCtx)(unsafe.Pointer(bp+48 /* &sSort */)).FpOrderBy, pEList, -1) == 0)) && ((*Select)(unsafe.Pointer(p)).FpWin == uintptr(0))) { goto __43 } - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000001)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_Distinct))) pGroupBy = libc.AssignPtrUintptr(p+56 /* &.pGroupBy */, Xsqlite3ExprListDup(tls, db, pEList, 0)) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0000008)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_Aggregate) // Notice that even thought SF_Distinct has been cleared from p->selFlags, // the sDistinct.isTnct is still set. Hence, isTnct represents the // original setting of the SF_Distinct flag, not the current setting @@ -118003,7 +115866,7 @@ __43: pKeyInfo = Xsqlite3KeyInfoFromExprList(tls, pParse, (*SortCtx)(unsafe.Pointer(bp+48 /* &sSort */)).FpOrderBy, 0, (*ExprList)(unsafe.Pointer(pEList)).FnExpr) (*SortCtx)(unsafe.Pointer(bp + 48 /* &sSort */)).FiECursor = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - (*SortCtx)(unsafe.Pointer(bp + 48 /* &sSort */)).FaddrSortIndex = Xsqlite3VdbeAddOp4(tls, v, 100, + (*SortCtx)(unsafe.Pointer(bp + 48 /* &sSort */)).FaddrSortIndex = Xsqlite3VdbeAddOp4(tls, v, OP_OpenEphemeral, (*SortCtx)(unsafe.Pointer(bp+48 /* &sSort */)).FiECursor, (((*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(bp+48 /* &sSort */)).FpOrderBy)).FnExpr + 1) + (*ExprList)(unsafe.Pointer(pEList)).FnExpr), 0, pKeyInfo, -9) goto __45 @@ -118013,16 +115876,16 @@ __45: ; // If the output is destined for a temporary table, open that table. - if !(int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) == 12) { + if !(int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) == SRT_EphemTab) { goto __46 } - Xsqlite3VdbeAddOp2(tls, v, 100, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, (*ExprList)(unsafe.Pointer(pEList)).FnExpr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, (*ExprList)(unsafe.Pointer(pEList)).FnExpr) __46: ; // Set the limiter. iEnd = Xsqlite3VdbeMakeLabel(tls, pParse) - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0004000)) == U32(0)) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_FixedLimit) == U32(0)) { goto __47 } (*Select)(unsafe.Pointer(p)).FnSelectRow = int16(320) // 4 billion rows @@ -118032,25 +115895,25 @@ __47: if !(((*Select)(unsafe.Pointer(p)).FiLimit == 0) && ((*SortCtx)(unsafe.Pointer(bp+48 /* &sSort */)).FaddrSortIndex >= 0)) { goto __48 } - Xsqlite3VdbeChangeOpcode(tls, v, (*SortCtx)(unsafe.Pointer(bp+48 /* &sSort */)).FaddrSortIndex, uint8(111)) - *(*U8)(unsafe.Pointer(bp + 48 /* &sSort */ + 36 /* &.sortFlags */)) |= U8((0x01)) + Xsqlite3VdbeChangeOpcode(tls, v, (*SortCtx)(unsafe.Pointer(bp+48 /* &sSort */)).FaddrSortIndex, OP_SorterOpen) + *(*U8)(unsafe.Pointer(bp + 48 /* &sSort */ + 36 /* &.sortFlags */)) |= U8((SORTFLAG_UseSorter)) __48: ; // Open an ephemeral index to use for the distinct set. - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000001)) != 0) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_Distinct) != 0) { goto __49 } (*DistinctCtx)(unsafe.Pointer(bp + 136 /* &sDistinct */)).FtabTnct = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - (*DistinctCtx)(unsafe.Pointer(bp + 136 /* &sDistinct */)).FaddrTnct = Xsqlite3VdbeAddOp4(tls, v, 100, + (*DistinctCtx)(unsafe.Pointer(bp + 136 /* &sDistinct */)).FaddrTnct = Xsqlite3VdbeAddOp4(tls, v, OP_OpenEphemeral, (*DistinctCtx)(unsafe.Pointer(bp+136 /* &sDistinct */)).FtabTnct, 0, 0, Xsqlite3KeyInfoFromExprList(tls, pParse, (*Select)(unsafe.Pointer(p)).FpEList, 0, 0), -9) - Xsqlite3VdbeChangeP5(tls, v, uint16(8)) - (*DistinctCtx)(unsafe.Pointer(bp + 136 /* &sDistinct */)).FeTnctType = U8(3) + Xsqlite3VdbeChangeP5(tls, v, BTREE_UNORDERED) + (*DistinctCtx)(unsafe.Pointer(bp + 136 /* &sDistinct */)).FeTnctType = WHERE_DISTINCT_UNORDERED goto __50 __49: - (*DistinctCtx)(unsafe.Pointer(bp + 136 /* &sDistinct */)).FeTnctType = U8(0) + (*DistinctCtx)(unsafe.Pointer(bp + 136 /* &sDistinct */)).FeTnctType = WHERE_DISTINCT_NOOP __50: ; @@ -118060,11 +115923,11 @@ __50: // No aggregate functions and no GROUP BY clause wctrlFlags = (U16((func() uint32 { if (*DistinctCtx)(unsafe.Pointer(bp+136 /* &sDistinct */)).FisTnct != 0 { - return uint32(0x0100) + return WHERE_WANT_DISTINCT } return uint32(0) }()) | - ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0004000)))) + ((*Select)(unsafe.Pointer(p)).FselFlags & SF_FixedLimit))) pWin = (*Select)(unsafe.Pointer(p)).FpWin // Main window object (or NULL) if !(pWin != 0) { goto __53 @@ -118129,13 +115992,13 @@ __59: Xsqlite3WindowCodeStep(tls, pParse, p, pWInfo, regGosub, addrGosub) - Xsqlite3VdbeAddOp2(tls, v, 11, 0, iBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, iBreak) Xsqlite3VdbeResolveLabel(tls, v, addrGosub) (*SortCtx)(unsafe.Pointer(bp + 48 /* &sSort */)).FlabelOBLopt = 0 selectInnerLoop(tls, pParse, p, -1, bp+48 /* &sSort */, bp+136 /* &sDistinct */, pDest, iCont, iBreak) Xsqlite3VdbeResolveLabel(tls, v, iCont) - Xsqlite3VdbeAddOp1(tls, v, 65, regGosub) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regGosub) Xsqlite3VdbeResolveLabel(tls, v, iBreak) goto __61 @@ -118221,7 +116084,7 @@ __72: if !(ii < (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) { goto __74 } - sortFlags = (U8(int32((*ExprList_item)(unsafe.Pointer(((*SortCtx)(unsafe.Pointer(bp+48 /* &sSort */)).FpOrderBy+8 /* &.a */)+uintptr(ii)*32)).FsortFlags) & 0x01)) + sortFlags = (U8(int32((*ExprList_item)(unsafe.Pointer(((*SortCtx)(unsafe.Pointer(bp+48 /* &sSort */)).FpOrderBy+8 /* &.a */)+uintptr(ii)*32)).FsortFlags) & KEYINFO_ORDER_DESC)) (*ExprList_item)(unsafe.Pointer((pGroupBy + 8 /* &.a */) + uintptr(ii)*32)).FsortFlags = sortFlags goto __73 __73: @@ -118294,10 +116157,10 @@ __77: if !((((*Select)(unsafe.Pointer(p)).FpGroupBy == uintptr(0)) && ((*Select)(unsafe.Pointer(p)).FpHaving == uintptr(0))) && ((*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == 1)) { goto __79 } - minMaxFlag = minMaxQuery(tls, db, (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(0)*24)).FpFExpr, bp+208 /* &pMinMaxOrderBy */) + minMaxFlag = minMaxQuery(tls, db, (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FpFExpr, bp+208 /* &pMinMaxOrderBy */) goto __80 __79: - minMaxFlag = U8(0x0000) + minMaxFlag = WHERE_ORDERBY_NORMAL __80: ; i = 0 @@ -118307,16 +116170,16 @@ __81: } pExpr = (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*24)).FpFExpr - *(*int32)(unsafe.Pointer(bp + 152 /* &sNC */ + 40 /* &.ncFlags */)) |= (0x20000) + *(*int32)(unsafe.Pointer(bp + 152 /* &sNC */ + 40 /* &.ncFlags */)) |= (NC_InAggFunc) Xsqlite3ExprAnalyzeAggList(tls, bp+152 /* &sNC */, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) { goto __84 } Xsqlite3ExprAnalyzeAggregates(tls, bp+152 /* &sNC */, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FpFilter) __84: ; - *(*int32)(unsafe.Pointer(bp + 152 /* &sNC */ + 40 /* &.ncFlags */)) &= (^libc.Int32(0x20000)) + *(*int32)(unsafe.Pointer(bp + 152 /* &sNC */ + 40 /* &.ncFlags */)) &= (libc.CplInt32(NC_InAggFunc)) goto __82 __82: i++ @@ -118345,7 +116208,7 @@ __85: (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) pKeyInfo1 = Xsqlite3KeyInfoFromExprList(tls, pParse, pGroupBy, 0, (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) - addrSortingIdx = Xsqlite3VdbeAddOp4(tls, v, 111, + addrSortingIdx = Xsqlite3VdbeAddOp4(tls, v, OP_SorterOpen, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, (*AggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn, 0, pKeyInfo1, -9) @@ -118360,20 +116223,20 @@ __85: *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += ((*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) iBMem = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += ((*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, iAbortFlag) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, iAbortFlag) - Xsqlite3VdbeAddOp3(tls, v, 72, 0, iAMem, ((iAMem + (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, iAMem, ((iAMem + (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) - 1)) // Begin a loop that will extract all source rows in GROUP BY order. // This might involve two separate loops with an OP_Sort in between, or // it might be a single loop that uses an index to extract information // in the right order to begin with. - Xsqlite3VdbeAddOp2(tls, v, 12, regReset, addrReset) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regReset, addrReset) pWInfo = Xsqlite3WhereBegin(tls, pParse, pTabList, pWhere, pGroupBy, uintptr(0), - (uint16(0x0040 | (func() int32 { + (uint16(WHERE_GROUPBY | (func() int32 { if orderByGrp != 0 { - return 0x0200 + return WHERE_SORTBYGROUP } return 0 }()))), 0) @@ -118395,7 +116258,7 @@ __89: explainTempTable(tls, pParse, func() uintptr { - if ((*DistinctCtx)(unsafe.Pointer(bp+136 /* &sDistinct */)).FisTnct != 0) && (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000001)) == U32(0)) { + if ((*DistinctCtx)(unsafe.Pointer(bp+136 /* &sDistinct */)).FisTnct != 0) && (((*Select)(unsafe.Pointer(p)).FselFlags & SF_Distinct) == U32(0)) { return ts + 17267 /* "DISTINCT" */ } return ts + 17276 /* "GROUP BY" */ @@ -118450,15 +116313,15 @@ __96: __97: ; regRecord = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 91, regBase, nCol, regRecord) - Xsqlite3VdbeAddOp2(tls, v, 131, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, regRecord) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regBase, nCol, regRecord) + Xsqlite3VdbeAddOp2(tls, v, OP_SorterInsert, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, regRecord) Xsqlite3ReleaseTempReg(tls, pParse, regRecord) Xsqlite3ReleaseTempRange(tls, pParse, regBase, nCol) Xsqlite3WhereEnd(tls, pWInfo) (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab = libc.AssignInt32(&sortPTab, libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)) sortOut = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 114, sortPTab, sortOut, nCol) - Xsqlite3VdbeAddOp2(tls, v, 35, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrEnd) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenPseudo, sortPTab, sortOut, nCol) + Xsqlite3VdbeAddOp2(tls, v, OP_SorterSort, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrEnd) (*AggInfo)(unsafe.Pointer(pAggInfo)).FuseSortingIdx = U8(1) __90: @@ -118471,7 +116334,7 @@ __90: // This is an optimization - the correct answer should result regardless. // Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER to // disable this optimization for testing purposes. - if !(((orderByGrp != 0) && ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0004)) == 0)) && + if !(((orderByGrp != 0) && ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_GroupByOrder)) == 0)) && ((groupBySort != 0) || (Xsqlite3WhereIsSorted(tls, pWInfo) != 0))) { goto __99 } @@ -118488,7 +116351,7 @@ __99: if !(groupBySort != 0) { goto __100 } - Xsqlite3VdbeAddOp3(tls, v, 125, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, + Xsqlite3VdbeAddOp3(tls, v, OP_SorterData, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, sortOut, sortPTab) __100: ; @@ -118500,7 +116363,7 @@ __101: if !(groupBySort != 0) { goto __104 } - Xsqlite3VdbeAddOp3(tls, v, 89, sortPTab, j, (iBMem + j)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, sortPTab, j, (iBMem + j)) goto __105 __104: (*AggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = U8(1) @@ -118514,10 +116377,10 @@ __102: goto __103 __103: ; - Xsqlite3VdbeAddOp4(tls, v, 86, iAMem, iBMem, (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr, + Xsqlite3VdbeAddOp4(tls, v, OP_Compare, iAMem, iBMem, (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr, Xsqlite3KeyInfoRef(tls, pKeyInfo1), -9) addr1 = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp3(tls, v, 16, (addr1 + 1), 0, (addr1 + 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, (addr1 + 1), 0, (addr1 + 1)) // Generate code that runs whenever the GROUP BY changes. // Changes in the GROUP BY are detected by the previous code @@ -118528,23 +116391,23 @@ __103: // and resets the aggregate accumulator registers in preparation // for the next GROUP BY batch. Xsqlite3ExprCodeMove(tls, pParse, iBMem, iAMem, (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) - Xsqlite3VdbeAddOp2(tls, v, 12, regOutputRow, addrOutputRow) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutputRow, addrOutputRow) - Xsqlite3VdbeAddOp2(tls, v, 48, iAbortFlag, addrEnd) + Xsqlite3VdbeAddOp2(tls, v, OP_IfPos, iAbortFlag, addrEnd) - Xsqlite3VdbeAddOp2(tls, v, 12, regReset, addrReset) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regReset, addrReset) // Update the aggregate accumulators based on the content of // the current row Xsqlite3VdbeJumpHere(tls, v, addr1) updateAccumulator(tls, pParse, iUseFlag, pAggInfo) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, iUseFlag) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, iUseFlag) // End of the loop if !(groupBySort != 0) { goto __106 } - Xsqlite3VdbeAddOp2(tls, v, 3, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrTopOfLoop) + Xsqlite3VdbeAddOp2(tls, v, OP_SorterNext, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrTopOfLoop) goto __107 __106: @@ -118554,7 +116417,7 @@ __107: ; // Output the final row of result - Xsqlite3VdbeAddOp2(tls, v, 12, regOutputRow, addrOutputRow) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutputRow, addrOutputRow) // Jump over the subroutines Xsqlite3VdbeGoto(tls, v, addrEnd) @@ -118566,27 +116429,27 @@ __107: // increments the iAbortFlag memory location before returning in // order to signal the caller to abort. addrSetAbort = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, iAbortFlag) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, iAbortFlag) - Xsqlite3VdbeAddOp1(tls, v, 65, regOutputRow) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regOutputRow) Xsqlite3VdbeResolveLabel(tls, v, addrOutputRow) addrOutputRow = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp2(tls, v, 48, iUseFlag, (addrOutputRow + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_IfPos, iUseFlag, (addrOutputRow + 2)) - Xsqlite3VdbeAddOp1(tls, v, 65, regOutputRow) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regOutputRow) finalizeAggFunctions(tls, pParse, pAggInfo) - Xsqlite3ExprIfFalse(tls, pParse, pHaving, (addrOutputRow + 1), 0x10) + Xsqlite3ExprIfFalse(tls, pParse, pHaving, (addrOutputRow + 1), SQLITE_JUMPIFNULL) selectInnerLoop(tls, pParse, p, -1, bp+48, /* &sSort */ bp+136 /* &sDistinct */, pDest, (addrOutputRow + 1), addrSetAbort) - Xsqlite3VdbeAddOp1(tls, v, 65, regOutputRow) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regOutputRow) // Generate a subroutine that will reset the group-by accumulator Xsqlite3VdbeResolveLabel(tls, v, addrReset) resetAccumulator(tls, pParse, pAggInfo) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, iUseFlag) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, iUseFlag) - Xsqlite3VdbeAddOp1(tls, v, 65, regReset) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regReset) goto __87 __86: @@ -118622,13 +116485,13 @@ __86: // // In practice the KeyInfo structure will not be used. It is only // passed to keep OP_OpenRead happy. - if !(!(((*Table)(unsafe.Pointer((pTab1))).FtabFlags & U32(0x0080)) == U32(0))) { + if !(!(((*Table)(unsafe.Pointer((pTab1))).FtabFlags & TF_WithoutRowid) == U32(0))) { goto __110 } pBest = Xsqlite3PrimaryKeyIndex(tls, pTab1) __110: ; - if !(!((int32(*(*uint8)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112 + 60 /* &.fg */ + 4 /* &.notIndexed */)) & 0x1 >> 0)) != 0)) { + if !(!((int32(*(*uint8)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + 60 /* &.fg */ + 4 /* &.notIndexed */)) & 0x1 >> 0)) != 0)) { goto __111 } pIdx = (*Table)(unsafe.Pointer(pTab1)).FpIndex @@ -118663,15 +116526,15 @@ __116: ; // Open a read-only cursor, execute the OP_Count, close the cursor. - Xsqlite3VdbeAddOp4Int(tls, v, 96, iCsr, int32(iRoot), iDb, 1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_OpenRead, iCsr, int32(iRoot), iDb, 1) if !(pKeyInfo2 != 0) { goto __117 } Xsqlite3VdbeChangeP4(tls, v, -1, pKeyInfo2, -9) __117: ; - Xsqlite3VdbeAddOp2(tls, v, 92, iCsr, (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(0)*24)).FiMem) - Xsqlite3VdbeAddOp1(tls, v, 116, iCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_Count, iCsr, (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FiMem) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iCsr) explainSimpleCount(tls, pParse, pTab1, pBest) goto __109 __108: @@ -118694,13 +116557,13 @@ __119: if !(i < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { goto __121 } - if !(((*Expr)(unsafe.Pointer(((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*24)).FpFExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer(((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*24)).FpFExpr))).Fflags & (EP_WinFunc)) != U32(0)) { goto __122 } goto __120 __122: ; - if !(((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(i)*24)).FpFunc)).FfuncFlags & U32(0x0020)) != 0) { + if !(((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(i)*24)).FpFunc)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != 0) { goto __123 } goto __121 @@ -118717,7 +116580,7 @@ __121: goto __124 } regAcc = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regAcc) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regAcc) __124: ; __118: @@ -118746,7 +116609,7 @@ __125: if !(regAcc != 0) { goto __126 } - Xsqlite3VdbeAddOp2(tls, v, 69, 1, regAcc) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, regAcc) __126: ; addrSkip = Xsqlite3WhereOrderByLimitOptLabel(tls, pWInfo) @@ -118762,7 +116625,7 @@ __109: ; (*SortCtx)(unsafe.Pointer(bp + 48 /* &sSort */)).FpOrderBy = uintptr(0) - Xsqlite3ExprIfFalse(tls, pParse, pHaving, addrEnd, 0x10) + Xsqlite3ExprIfFalse(tls, pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL) selectInnerLoop(tls, pParse, p, -1, uintptr(0), uintptr(0), pDest, addrEnd, addrEnd) __87: @@ -118772,7 +116635,7 @@ __87: __52: ; // endif aggregate query - if !(int32((*DistinctCtx)(unsafe.Pointer(bp+136 /* &sDistinct */)).FeTnctType) == 3) { + if !(int32((*DistinctCtx)(unsafe.Pointer(bp+136 /* &sDistinct */)).FeTnctType) == WHERE_DISTINCT_UNORDERED) { goto __128 } explainTempTable(tls, pParse, ts+17267 /* "DISTINCT" */) @@ -118944,7 +116807,7 @@ __5: Xsqlite3_free(tls, (*TabResult)(unsafe.Pointer(p)).FzErrMsg) (*TabResult)(unsafe.Pointer(p)).FzErrMsg = Xsqlite3_mprintf(tls, ts+17308 /* "sqlite3_get_tabl..." */, 0) - (*TabResult)(unsafe.Pointer(p)).Frc = 1 + (*TabResult)(unsafe.Pointer(p)).Frc = SQLITE_ERROR return 1 __11: ; @@ -118991,7 +116854,7 @@ __12: return 0 malloc_failed: - (*TabResult)(unsafe.Pointer(p)).Frc = 7 + (*TabResult)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM return 1 } @@ -119025,20 +116888,20 @@ func Xsqlite3_get_table(tls *libc.TLS, db uintptr, zSql uintptr, pazResult uintp (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FnColumn = U32(0) (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FnData = U32(1) (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FnAlloc = U32(20) - (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).Frc = 0 + (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).Frc = SQLITE_OK (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FazResult = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(uintptr(0))) * uint64((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FnAlloc)))) if (*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult == uintptr(0) { - (*Sqlite3)(unsafe.Pointer(db)).FerrCode = 7 - return 7 + (*Sqlite3)(unsafe.Pointer(db)).FerrCode = SQLITE_NOMEM + return SQLITE_NOMEM } - *(*uintptr)(unsafe.Pointer((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + uintptr(0)*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer((*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FazResult)) = uintptr(0) rc = Xsqlite3_exec(tls, db, zSql, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 }{sqlite3_get_table_cb})), bp+8 /* &res */, pzErrMsg) - *(*uintptr)(unsafe.Pointer((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + uintptr(0)*8)) = uintptr(int64((*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FnData)) - if (rc & 0xff) == 4 { - Xsqlite3_free_table(tls, ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + uintptr(1)*8)) + *(*uintptr)(unsafe.Pointer((*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FazResult)) = uintptr(int64((*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FnData)) + if (rc & 0xff) == SQLITE_ABORT { + Xsqlite3_free_table(tls, ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + 1*8)) if (*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FzErrMsg != 0 { if pzErrMsg != 0 { Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(pzErrMsg))) @@ -119050,21 +116913,21 @@ func Xsqlite3_get_table(tls *libc.TLS, db uintptr, zSql uintptr, pazResult uintp return (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).Frc } Xsqlite3_free(tls, (*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FzErrMsg) - if rc != 0 { - Xsqlite3_free_table(tls, ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + uintptr(1)*8)) + if rc != SQLITE_OK { + Xsqlite3_free_table(tls, ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + 1*8)) return rc } if (*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FnAlloc > (*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FnData { var azNew uintptr azNew = Xsqlite3Realloc(tls, (*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult, (uint64(uint64(unsafe.Sizeof(uintptr(0))) * uint64((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FnData)))) if azNew == uintptr(0) { - Xsqlite3_free_table(tls, ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + uintptr(1)*8)) - (*Sqlite3)(unsafe.Pointer(db)).FerrCode = 7 - return 7 + Xsqlite3_free_table(tls, ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + 1*8)) + (*Sqlite3)(unsafe.Pointer(db)).FerrCode = SQLITE_NOMEM + return SQLITE_NOMEM } (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FazResult = azNew } - *(*uintptr)(unsafe.Pointer(pazResult)) = ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + uintptr(1)*8) + *(*uintptr)(unsafe.Pointer(pazResult)) = ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + 1*8) if pnColumn != 0 { *(*int32)(unsafe.Pointer(pnColumn)) = int32((*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FnColumn) } @@ -119081,7 +116944,7 @@ func Xsqlite3_free_table(tls *libc.TLS, azResult uintptr) { /* sqlite3.c:136374: var n int32 azResult -= 8 - n = int32(*(*uintptr)(unsafe.Pointer(azResult + uintptr(0)*8))) + n = int32(*(*uintptr)(unsafe.Pointer(azResult))) for i = 1; i < n; i++ { if *(*uintptr)(unsafe.Pointer(azResult + uintptr(i)*8)) != 0 { Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(azResult + uintptr(i)*8))) @@ -119136,7 +116999,7 @@ func Xsqlite3DeleteTriggerStep(tls *libc.TLS, db uintptr, pTriggerStep uintptr) // that fire off of pTab. The list will include any TEMP triggers on // pTab as well as the triggers lised in pTab->pTrigger. func Xsqlite3TriggerList(tls *libc.TLS, pParse uintptr, pTab uintptr) uintptr { /* sqlite3.c:136440:24: */ - var pTmpSchema uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(1)*32)).FpSchema + var pTmpSchema uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb + 1*32)).FpSchema var pList uintptr = uintptr(0) // List of triggers to return if (*Parse)(unsafe.Pointer(pParse)).FdisableTriggers != 0 { @@ -119240,8 +117103,8 @@ __5: if !(((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0) && (iDb != 1)) { goto __6 } - Xsqlite3DbFree(tls, db, (*SrcList_item)(unsafe.Pointer((pTableName+8 /* &.a */)+uintptr(0)*112)).FzDatabase) - (*SrcList_item)(unsafe.Pointer((pTableName + 8 /* &.a */) + uintptr(0)*112)).FzDatabase = uintptr(0) + Xsqlite3DbFree(tls, db, (*SrcList_item)(unsafe.Pointer((pTableName + 8 /* &.a */))).FzDatabase) + (*SrcList_item)(unsafe.Pointer((pTableName + 8 /* &.a */))).FzDatabase = uintptr(0) __6: ; @@ -119251,7 +117114,7 @@ __6: // exist, the error is caught by the block below. pTab = Xsqlite3SrcListLookup(tls, pParse, pTableName) if !((((int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0) && ((*Token)(unsafe.Pointer(pName2)).Fn == uint32(0))) && (pTab != 0)) && - ((*Table)(unsafe.Pointer(pTab)).FpSchema == (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema)) { + ((*Table)(unsafe.Pointer(pTab)).FpSchema == (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema)) { goto __7 } iDb = 1 @@ -119319,7 +117182,7 @@ __13: __14: ; - if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) { + if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) { goto __15 } if !(Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FpSchema+56 /* &.trigHash */), zName) != 0) { @@ -119352,12 +117215,12 @@ __19: // INSTEAD of triggers are only for views and views only support INSTEAD // of triggers. - if !(((*Table)(unsafe.Pointer(pTab)).FpSelect != 0) && (tr_tm != 65)) { + if !(((*Table)(unsafe.Pointer(pTab)).FpSelect != 0) && (tr_tm != TK_INSTEAD)) { goto __20 } Xsqlite3ErrorMsg(tls, pParse, ts+17532, /* "cannot create %s..." */ libc.VaList(bp+8, func() uintptr { - if tr_tm == 33 { + if tr_tm == TK_BEFORE { return ts + 17569 /* "BEFORE" */ } return ts + 17576 /* "AFTER" */ @@ -119365,7 +117228,7 @@ __19: goto trigger_cleanup __20: ; - if !(!(int32((*Table)(unsafe.Pointer(pTab)).FpSelect) != 0) && (tr_tm == 65)) { + if !(!(int32((*Table)(unsafe.Pointer(pTab)).FpSelect) != 0) && (tr_tm == TK_INSTEAD)) { goto __21 } Xsqlite3ErrorMsg(tls, pParse, @@ -119374,21 +117237,21 @@ __20: __21: ; - if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) { + if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) { goto __22 } iTabDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) - code = 7 + code = SQLITE_CREATE_TRIGGER zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iTabDb)*32)).FzDbSName if isTemp != 0 { - zDbTrig = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(1)*32)).FzDbSName + zDbTrig = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*32)).FzDbSName } else { zDbTrig = zDb } if !((iTabDb == 1) || (isTemp != 0)) { goto __23 } - code = 5 + code = SQLITE_CREATE_TEMP_TRIGGER __23: ; if !(Xsqlite3AuthCheck(tls, pParse, code, zName, (*Table)(unsafe.Pointer(pTab)).FzName, zDbTrig) != 0) { @@ -119397,7 +117260,7 @@ __23: goto trigger_cleanup __24: ; - if !(Xsqlite3AuthCheck(tls, pParse, 18, func() uintptr { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_INSERT, func() uintptr { if (!(0 != 0)) && (iTabDb == 1) { return ts + 10046 /* "sqlite_temp_mast..." */ } @@ -119415,10 +117278,10 @@ __22: // cannot appear on views. So we might as well translate every // INSTEAD OF trigger into a BEFORE trigger. It simplifies code // elsewhere. - if !(tr_tm == 65) { + if !(tr_tm == TK_INSTEAD) { goto __26 } - tr_tm = 33 + tr_tm = TK_BEFORE __26: ; @@ -119432,25 +117295,25 @@ __27: ; (*Trigger)(unsafe.Pointer(pTrigger)).FzName = zName zName = uintptr(0) - (*Trigger)(unsafe.Pointer(pTrigger)).Ftable = Xsqlite3DbStrDup(tls, db, (*SrcList_item)(unsafe.Pointer((pTableName+8 /* &.a */)+uintptr(0)*112)).FzName) + (*Trigger)(unsafe.Pointer(pTrigger)).Ftable = Xsqlite3DbStrDup(tls, db, (*SrcList_item)(unsafe.Pointer((pTableName + 8 /* &.a */))).FzName) (*Trigger)(unsafe.Pointer(pTrigger)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpSchema (*Trigger)(unsafe.Pointer(pTrigger)).FpTabSchema = (*Table)(unsafe.Pointer(pTab)).FpSchema (*Trigger)(unsafe.Pointer(pTrigger)).Fop = U8(op) (*Trigger)(unsafe.Pointer(pTrigger)).Ftr_tm = func() uint8 { - if tr_tm == 33 { - return uint8(1) + if tr_tm == TK_BEFORE { + return TRIGGER_BEFORE } - return uint8(2) + return TRIGGER_AFTER }() - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __28 } - Xsqlite3RenameTokenRemap(tls, pParse, (*Trigger)(unsafe.Pointer(pTrigger)).Ftable, (*SrcList_item)(unsafe.Pointer((pTableName+8 /* &.a */)+uintptr(0)*112)).FzName) + Xsqlite3RenameTokenRemap(tls, pParse, (*Trigger)(unsafe.Pointer(pTrigger)).Ftable, (*SrcList_item)(unsafe.Pointer((pTableName + 8 /* &.a */))).FzName) (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = pWhen pWhen = uintptr(0) goto __29 __28: - (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = Xsqlite3ExprDup(tls, db, pWhen, 0x0001) + (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = Xsqlite3ExprDup(tls, db, pWhen, EXPRDUP_REDUCE) __29: ; (*Trigger)(unsafe.Pointer(pTrigger)).FpColumns = pColumns @@ -119524,7 +117387,7 @@ __3: __4: ; - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __5 } @@ -119623,9 +117486,9 @@ func Xsqlite3TriggerSelectStep(tls *libc.TLS, db uintptr, pSelect uintptr, zStar Xsqlite3SelectDelete(tls, db, pSelect) return uintptr(0) } - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Fop = U8(136) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Fop = TK_SELECT (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = pSelect - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = U8(11) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = OE_Default (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FzSpan = triggerSpanDup(tls, db, zStart, zEnd) return pTriggerStep } @@ -119640,13 +117503,13 @@ func triggerStepAllocate(tls *libc.TLS, pParse uintptr, op U8, pName uintptr, zS pTriggerStep = Xsqlite3DbMallocZero(tls, db, (uint64((uint64(unsafe.Sizeof(TriggerStep{})) + uint64((*Token)(unsafe.Pointer(pName)).Fn)) + uint64(1)))) if pTriggerStep != 0 { - var z uintptr = (pTriggerStep + uintptr(1)*96) + var z uintptr = (pTriggerStep + 1*96) libc.Xmemcpy(tls, z, (*Token)(unsafe.Pointer(pName)).Fz, uint64((*Token)(unsafe.Pointer(pName)).Fn)) Xsqlite3Dequote(tls, z) (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FzTarget = z (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Fop = op (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FzSpan = triggerSpanDup(tls, db, zStart, zEnd) - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameTokenMap(tls, pParse, (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FzTarget, pName) } } @@ -119662,13 +117525,13 @@ func Xsqlite3TriggerInsertStep(tls *libc.TLS, pParse uintptr, pTableName uintptr var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var pTriggerStep uintptr - pTriggerStep = triggerStepAllocate(tls, pParse, uint8(125), pTableName, zStart, zEnd) + pTriggerStep = triggerStepAllocate(tls, pParse, TK_INSERT, pTableName, zStart, zEnd) if pTriggerStep != 0 { - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = pSelect pSelect = uintptr(0) } else { - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, 0x0001) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, EXPRDUP_REDUCE) } (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpIdList = pColumn (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpUpsert = pUpsert @@ -119694,9 +117557,9 @@ func Xsqlite3TriggerUpdateStep(tls *libc.TLS, pParse uintptr, pTableName uintptr var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var pTriggerStep uintptr - pTriggerStep = triggerStepAllocate(tls, pParse, uint8(127), pTableName, zStart, zEnd) + pTriggerStep = triggerStepAllocate(tls, pParse, TK_UPDATE, pTableName, zStart, zEnd) if pTriggerStep != 0 { - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpExprList = pEList (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = pWhere (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpFrom = pFrom @@ -119704,9 +117567,9 @@ func Xsqlite3TriggerUpdateStep(tls *libc.TLS, pParse uintptr, pTableName uintptr pWhere = uintptr(0) pFrom = uintptr(0) } else { - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpExprList = Xsqlite3ExprListDup(tls, db, pEList, 0x0001) - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, 0x0001) - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpFrom = Xsqlite3SrcListDup(tls, db, pFrom, 0x0001) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpExprList = Xsqlite3ExprListDup(tls, db, pEList, EXPRDUP_REDUCE) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, EXPRDUP_REDUCE) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpFrom = Xsqlite3SrcListDup(tls, db, pFrom, EXPRDUP_REDUCE) } (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = orconf } @@ -119723,15 +117586,15 @@ func Xsqlite3TriggerDeleteStep(tls *libc.TLS, pParse uintptr, pTableName uintptr var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var pTriggerStep uintptr - pTriggerStep = triggerStepAllocate(tls, pParse, uint8(126), pTableName, zStart, zEnd) + pTriggerStep = triggerStepAllocate(tls, pParse, TK_DELETE, pTableName, zStart, zEnd) if pTriggerStep != 0 { - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = pWhere pWhere = uintptr(0) } else { - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, 0x0001) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, EXPRDUP_REDUCE) } - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = U8(11) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = OE_Default } Xsqlite3ExprDelete(tls, db, pWhere) return pTriggerStep @@ -119777,17 +117640,17 @@ func Xsqlite3DropTrigger(tls *libc.TLS, pParse uintptr, pName uintptr, noErr int goto drop_trigger_cleanup __1: ; - if !(0 != Xsqlite3ReadSchema(tls, pParse)) { + if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) { goto __2 } goto drop_trigger_cleanup __2: ; - zDb = (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */) + uintptr(0)*112)).FzDatabase - zName = (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */) + uintptr(0)*112)).FzName + zDb = (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */))).FzDatabase + zName = (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */))).FzName - i = 0 + i = OMIT_TEMPDB __3: if !(i < (*Sqlite3)(unsafe.Pointer(db)).FnDb) { goto __5 @@ -119861,7 +117724,7 @@ func Xsqlite3DropTriggerPtr(tls *libc.TLS, pParse uintptr, pTrigger uintptr) { / pTable = tableOfTrigger(tls, pTrigger) if pTable != 0 { - var code int32 = 16 + var code int32 = SQLITE_DROP_TRIGGER var zDb uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName var zTab uintptr = func() uintptr { if (!(0 != 0)) && (iDb == 1) { @@ -119870,9 +117733,9 @@ func Xsqlite3DropTriggerPtr(tls *libc.TLS, pParse uintptr, pTrigger uintptr) { / return ts + 4780 /* "sqlite_master" */ }() if iDb == 1 { - code = 14 + code = SQLITE_DROP_TEMP_TRIGGER } - if (Xsqlite3AuthCheck(tls, pParse, code, (*Trigger)(unsafe.Pointer(pTrigger)).FzName, (*Table)(unsafe.Pointer(pTable)).FzName, zDb) != 0) || (Xsqlite3AuthCheck(tls, pParse, 9, zTab, uintptr(0), zDb) != 0) { + if (Xsqlite3AuthCheck(tls, pParse, code, (*Trigger)(unsafe.Pointer(pTrigger)).FzName, (*Table)(unsafe.Pointer(pTable)).FzName, zDb) != 0) || (Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, zTab, uintptr(0), zDb) != 0) { return } } @@ -119883,7 +117746,7 @@ func Xsqlite3DropTriggerPtr(tls *libc.TLS, pParse uintptr, pTrigger uintptr) { / ts+17752, /* "DELETE FROM %Q.s..." */ libc.VaList(bp, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName, (*Trigger)(unsafe.Pointer(pTrigger)).FzName)) Xsqlite3ChangeCookie(tls, pParse, iDb) - Xsqlite3VdbeAddOp4(tls, v, 145, iDb, 0, 0, (*Trigger)(unsafe.Pointer(pTrigger)).FzName, 0) + Xsqlite3VdbeAddOp4(tls, v, OP_DropTrigger, iDb, 0, 0, (*Trigger)(unsafe.Pointer(pTrigger)).FzName, 0) } } @@ -119908,7 +117771,7 @@ func Xsqlite3UnlinkAndDeleteTrigger(tls *libc.TLS, db uintptr, iDb int32, zName } } Xsqlite3DeleteTrigger(tls, db, pTrigger) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) } } @@ -119941,7 +117804,7 @@ func Xsqlite3TriggersExist(tls *libc.TLS, pParse uintptr, pTab uintptr, op int32 var pList uintptr = uintptr(0) var p uintptr - if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00040000)) != uint64(0) { + if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_EnableTrigger) != uint64(0) { pList = Xsqlite3TriggerList(tls, pParse, pTab) } @@ -119977,9 +117840,9 @@ func Xsqlite3TriggerStepSrc(tls *libc.TLS, pParse uintptr, pStep uintptr) uintpt if pSrc != 0 { var pSchema uintptr = (*Trigger)(unsafe.Pointer((*TriggerStep)(unsafe.Pointer(pStep)).FpTrig)).FpSchema - (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */) + uintptr(0)*112)).FzName = zName - if pSchema != (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema { - (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */) + uintptr(0)*112)).FpSchema = pSchema + (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FzName = zName + if pSchema != (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema { + (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FpSchema = pSchema } if (*TriggerStep)(unsafe.Pointer(pStep)).FpFrom != 0 { var pDup uintptr = Xsqlite3SrcListDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FpFrom, 0) @@ -120015,20 +117878,20 @@ func codeTriggerProgram(tls *libc.TLS, pParse uintptr, pStepList uintptr, orconf // INSERT INTO t1 ... ; -- insert into t2 uses REPLACE policy // INSERT OR IGNORE INTO t1 ... ; -- insert into t2 uses IGNORE policy (*Parse)(unsafe.Pointer(pParse)).FeOrconf = func() uint8 { - if orconf == 11 { + if orconf == OE_Default { return (*TriggerStep)(unsafe.Pointer(pStep)).Forconf } return U8(orconf) }() if (*TriggerStep)(unsafe.Pointer(pStep)).FzSpan != 0 { - Xsqlite3VdbeAddOp4(tls, v, 170, 0x7fffffff, 1, 0, + Xsqlite3VdbeAddOp4(tls, v, OP_Trace, 0x7fffffff, 1, 0, Xsqlite3MPrintf(tls, db, ts+4967 /* "-- %s" */, libc.VaList(bp, (*TriggerStep)(unsafe.Pointer(pStep)).FzSpan)), -7) } switch int32((*TriggerStep)(unsafe.Pointer(pStep)).Fop) { - case 127: + case TK_UPDATE: { Xsqlite3Update(tls, pParse, Xsqlite3TriggerStepSrc(tls, pParse, pStep), @@ -120038,7 +117901,7 @@ func codeTriggerProgram(tls *libc.TLS, pParse uintptr, pStepList uintptr, orconf break } - case 125: + case TK_INSERT: { Xsqlite3Insert(tls, pParse, Xsqlite3TriggerStepSrc(tls, pParse, pStep), @@ -120049,7 +117912,7 @@ func codeTriggerProgram(tls *libc.TLS, pParse uintptr, pStepList uintptr, orconf break } - case 126: + case TK_DELETE: { Xsqlite3DeleteFrom(tls, pParse, Xsqlite3TriggerStepSrc(tls, pParse, pStep), @@ -120062,15 +117925,15 @@ func codeTriggerProgram(tls *libc.TLS, pParse uintptr, pStepList uintptr, orconf // var sDest SelectDest at bp+8, 40 var pSelect uintptr = Xsqlite3SelectDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect, 0) - Xsqlite3SelectDestInit(tls, bp+8 /* &sDest */, 4, 0) + Xsqlite3SelectDestInit(tls, bp+8 /* &sDest */, SRT_Discard, 0) Xsqlite3Select(tls, pParse, pSelect, bp+8 /* &sDest */) Xsqlite3SelectDelete(tls, db, pSelect) break } } - if int32((*TriggerStep)(unsafe.Pointer(pStep)).Fop) != 136 { - Xsqlite3VdbeAddOp0(tls, v, 123) + if int32((*TriggerStep)(unsafe.Pointer(pStep)).Fop) != TK_SELECT { + Xsqlite3VdbeAddOp0(tls, v, OP_ResetCount) } } @@ -120129,8 +117992,8 @@ func codeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintpt Xsqlite3VdbeLinkSubProgram(tls, (*Parse)(unsafe.Pointer(pTop)).FpVdbe, pProgram) (*TriggerPrg)(unsafe.Pointer(pPrg)).FpTrigger = pTrigger (*TriggerPrg)(unsafe.Pointer(pPrg)).Forconf = orconf - *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */) + uintptr(0)*4)) = 0xffffffff - *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */) + uintptr(1)*4)) = 0xffffffff + *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */))) = 0xffffffff + *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */) + 1*4)) = 0xffffffff // Allocate and populate a new Parse context to use for coding the // trigger sub-program. @@ -120161,10 +118024,10 @@ func codeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintpt // OP_Halt inserted at the end of the program. if (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen != 0 { pWhen = Xsqlite3ExprDup(tls, db, (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen, 0) - if (0 == Xsqlite3ResolveExprNames(tls, bp+8 /* &sNC */, pWhen)) && + if (SQLITE_OK == Xsqlite3ResolveExprNames(tls, bp+8 /* &sNC */, pWhen)) && (int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0) { iEndTrigger = Xsqlite3VdbeMakeLabel(tls, pSubParse) - Xsqlite3ExprIfFalse(tls, pSubParse, pWhen, iEndTrigger, 0x10) + Xsqlite3ExprIfFalse(tls, pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL) } Xsqlite3ExprDelete(tls, db, pWhen) } @@ -120176,7 +118039,7 @@ func codeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintpt if iEndTrigger != 0 { Xsqlite3VdbeResolveLabel(tls, v, iEndTrigger) } - Xsqlite3VdbeAddOp0(tls, v, 68) + Xsqlite3VdbeAddOp0(tls, v, OP_Halt) transferParseError(tls, pParse, pSubParse) if (int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0) && ((*Parse)(unsafe.Pointer(pParse)).FnErr == 0) { @@ -120185,8 +118048,8 @@ func codeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintpt (*SubProgram)(unsafe.Pointer(pProgram)).FnMem = (*Parse)(unsafe.Pointer(pSubParse)).FnMem (*SubProgram)(unsafe.Pointer(pProgram)).FnCsr = (*Parse)(unsafe.Pointer(pSubParse)).FnTab (*SubProgram)(unsafe.Pointer(pProgram)).Ftoken = pTrigger - *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */) + uintptr(0)*4)) = (*Parse)(unsafe.Pointer(pSubParse)).Foldmask - *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */) + uintptr(1)*4)) = (*Parse)(unsafe.Pointer(pSubParse)).Fnewmask + *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */))) = (*Parse)(unsafe.Pointer(pSubParse)).Foldmask + *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */) + 1*4)) = (*Parse)(unsafe.Pointer(pSubParse)).Fnewmask Xsqlite3VdbeDelete(tls, v) } @@ -120236,9 +118099,9 @@ func Xsqlite3CodeRowTriggerDirect(tls *libc.TLS, pParse uintptr, p uintptr, pTab // Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program // is a pointer to the sub-vdbe containing the trigger program. if pPrg != 0 { - var bRecursive int32 = (libc.Bool32(((*Trigger)(unsafe.Pointer(p)).FzName != 0) && (uint64(0) == ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00002000))))) + var bRecursive int32 = (libc.Bool32(((*Trigger)(unsafe.Pointer(p)).FzName != 0) && (uint64(0) == ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_RecTriggers)))) - Xsqlite3VdbeAddOp4(tls, v, 46, reg, ignoreJump, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1), + Xsqlite3VdbeAddOp4(tls, v, OP_Program, reg, ignoreJump, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1), (*TriggerPrg)(unsafe.Pointer(pPrg)).FpProgram, -4) // Set the P5 operand of the OP_Program instruction to non-zero if @@ -120332,9 +118195,9 @@ func Xsqlite3CodeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, op func Xsqlite3TriggerColmask(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pChanges uintptr, isNew int32, tr_tm int32, pTab uintptr, orconf int32) U32 { /* sqlite3.c:137569:20: */ var op int32 if pChanges != 0 { - op = 127 + op = TK_UPDATE } else { - op = 126 + op = TK_DELETE } var mask U32 = U32(0) var p uintptr @@ -120396,8 +118259,8 @@ func Xsqlite3ColumnDefault(tls *libc.TLS, v uintptr, pTab uintptr, i int32, iReg Xsqlite3VdbeAppendP4(tls, v, *(*uintptr)(unsafe.Pointer(bp /* pValue */)), -11) } } - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).Faffinity) == 0x45) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { - Xsqlite3VdbeAddOp1(tls, v, 83, iReg) + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).Faffinity) == SQLITE_AFF_REAL) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { + Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, iReg) } } @@ -120444,7 +118307,7 @@ func indexWhereClauseMightChange(tls *libc.TLS, pIdx uintptr, aXRef uintptr, chn // expression to be a TK_COLUMN reading column iCol of the first // table in the source-list (pSrc->a[0]). func exprRowColumn(tls *libc.TLS, pParse uintptr, iCol int32) uintptr { /* sqlite3.c:137740:13: */ - var pRet uintptr = Xsqlite3PExpr(tls, pParse, 75, uintptr(0), uintptr(0)) + var pRet uintptr = Xsqlite3PExpr(tls, pParse, TK_ROW, uintptr(0), uintptr(0)) if pRet != 0 { (*Expr)(unsafe.Pointer(pRet)).FiColumn = (YnVar(iCol + 1)) } @@ -120500,7 +118363,7 @@ func updateFromSelect(tls *libc.TLS, pParse uintptr, iEph int32, pPk uintptr, pC var pLimit2 uintptr = uintptr(0) var pOrderBy2 uintptr = uintptr(0) var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - var pTab uintptr = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FpTab + var pTab uintptr = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FpTab var pSrc uintptr var pWhere2 uintptr var eDest int32 @@ -120512,28 +118375,28 @@ func updateFromSelect(tls *libc.TLS, pParse uintptr, iEph int32, pPk uintptr, pC pWhere2 = Xsqlite3ExprDup(tls, db, pWhere, 0) if pSrc != 0 { - (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */) + uintptr(0)*112)).FiCursor = -1 - (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(0)*112)).FpTab)).FnTabRef-- - (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab = uintptr(0) + (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FiCursor = -1 + (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FpTab)).FnTabRef-- + (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FpTab = uintptr(0) } if pPk != 0 { for i = 0; i < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); i++ { var pNew uintptr = exprRowColumn(tls, pParse, int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))) pList = Xsqlite3ExprListAppend(tls, pParse, pList, pNew) } - eDest = 15 + eDest = SRT_Upfrom } else if (*Table)(unsafe.Pointer(pTab)).FpSelect != 0 { for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { pList = Xsqlite3ExprListAppend(tls, pParse, pList, exprRowColumn(tls, pParse, i)) } - eDest = 14 + eDest = SRT_Table } else { if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { - eDest = 14 + eDest = SRT_Table } else { - eDest = 15 + eDest = SRT_Upfrom } - pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), Xsqlite3PExpr(tls, pParse, 75, uintptr(0), uintptr(0))) + pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), Xsqlite3PExpr(tls, pParse, TK_ROW, uintptr(0), uintptr(0))) } if pChanges != 0 { for i = 0; i < (*ExprList)(unsafe.Pointer(pChanges)).FnExpr; i++ { @@ -120542,7 +118405,7 @@ func updateFromSelect(tls *libc.TLS, pParse uintptr, iEph int32, pPk uintptr, pC } } pSelect = Xsqlite3SelectNew(tls, pParse, pList, - pSrc, pWhere2, pGrp, uintptr(0), pOrderBy2, (uint32(0x0800000 | 0x0020000)), pLimit2) + pSrc, pWhere2, pGrp, uintptr(0), pOrderBy2, (uint32(SF_UpdateFrom | SF_IncludeHidden)), pLimit2) Xsqlite3SelectDestInit(tls, bp /* &dest */, eDest, iEph) (*SelectDest)(unsafe.Pointer(bp /* &dest */)).FiSDParm2 = func() int32 { if pPk != 0 { @@ -120679,7 +118542,7 @@ __2: // Figure out if we have any triggers and if the table being // updated is a view. - pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, 127, pChanges, bp+32 /* &tmask */) + pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, TK_UPDATE, pChanges, bp+32 /* &tmask */) isView = (libc.Bool32((*Table)(unsafe.Pointer(pTab)).FpSelect != uintptr(0))) // If there was a FROM clause, set nChangeFrom to the number of expressions @@ -120711,7 +118574,7 @@ __4: // allocate enough space, just in case. iBaseCur = libc.AssignInt32(&iDataCur, libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)) iIdxCur = (iDataCur + 1) - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { pPk = uintptr(0) } else { pPk = Xsqlite3PrimaryKeyIndex(tls, pTab) @@ -120747,7 +118610,7 @@ __7: (*Parse)(unsafe.Pointer(pParse)).FnTab = iBaseCur __9: ; - (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FiCursor = iDataCur + (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FiCursor = iDataCur // Allocate space for aXRef[], aRegIdx[], and aToOpen[]. // Initialize aXRef[] and aToOpen[] to their default values. @@ -120781,7 +118644,7 @@ __13: (*NameContext)(unsafe.Pointer(bp + 40 /* &sNC */)).FpParse = pParse (*NameContext)(unsafe.Pointer(bp + 40 /* &sNC */)).FpSrcList = pTabList *(*uintptr)(unsafe.Pointer(bp + 40 /* &sNC */ + 16 /* &.uNC */)) = pUpsert - (*NameContext)(unsafe.Pointer(bp + 40 /* &sNC */)).FncFlags = 0x00200 + (*NameContext)(unsafe.Pointer(bp + 40 /* &sNC */)).FncFlags = NC_UUpsert // Begin generating code. v = Xsqlite3GetVdbe(tls, pParse) @@ -120827,13 +118690,13 @@ __19: iRowidExpr = i goto __24 __23: - if !((pPk != 0) && ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & 0x0001) != 0)) { + if !((pPk != 0) && ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & COLFLAG_PRIMKEY) != 0)) { goto __25 } chngPk = U8(1) goto __26 __25: - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & 0x0060) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & COLFLAG_GENERATED) != 0) { goto __27 } @@ -120878,7 +118741,7 @@ __30: __28: ; - rc = Xsqlite3AuthCheck(tls, pParse, 23, (*Table)(unsafe.Pointer(pTab)).FzName, + rc = Xsqlite3AuthCheck(tls, pParse, SQLITE_UPDATE, (*Table)(unsafe.Pointer(pTab)).FzName, func() uintptr { if j < 0 { return ts + 6512 /* "ROWID" */ @@ -120886,13 +118749,13 @@ __28: return (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*32)).FzName }(), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) - if !(rc == 1) { + if !(rc == SQLITE_DENY) { goto __31 } goto update_cleanup goto __32 __31: - if !(rc == 2) { + if !(rc == SQLITE_IGNORE) { goto __33 } *(*int32)(unsafe.Pointer(aXRef + uintptr(j)*4)) = -1 @@ -120917,7 +118780,7 @@ __17: // is non-negative, so the value of aXRef[] for generated columns can be // set to any non-negative number. We use 99999 so that the value is // obvious when looking at aXRef[] in a symbolic debugger. - if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != 0) { + if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != 0) { goto __34 } @@ -120934,7 +118797,7 @@ __38: goto __39 __41: ; - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0060) == 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_GENERATED) == 0) { goto __42 } goto __39 @@ -120970,7 +118833,7 @@ __34: // So reset the colUsed mask. Unless this is a virtual table. In that // case, set all bits of the colUsed mask (to ensure that the virtual // table implementation makes all columns available). - (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FcolUsed = func() uint64 { + (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FcolUsed = func() uint64 { if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { return libc.Uint64(libc.Uint64FromInt32(-1)) } @@ -120982,7 +118845,7 @@ __34: // There is one entry in the aRegIdx[] array for each index on the table // being updated. Fill in aRegIdx[] with a register number that will hold // the key for accessing each index. - if !(onError == 5) { + if !(onError == OE_Replace) { goto __44 } *(*int32)(unsafe.Pointer(bp + 104 /* bReplace */)) = 1 @@ -121013,7 +118876,7 @@ __50: } reg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)) - if !((onError == 11) && (int32((*Index)(unsafe.Pointer(pIdx)).FonError) == 5)) { + if !((onError == OE_Default) && (int32((*Index)(unsafe.Pointer(pIdx)).FonError) == OE_Replace)) { goto __54 } *(*int32)(unsafe.Pointer(bp + 104 /* bReplace */)) = 1 @@ -121145,14 +119008,14 @@ __64: goto __65 } regRowCount = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regRowCount) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regRowCount) __65: ; - if !((nChangeFrom == 0) && (((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) { + if !((nChangeFrom == 0) && (((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) { goto __66 } - Xsqlite3VdbeAddOp3(tls, v, 72, 0, regRowSet, regOldRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, regRowSet, regOldRowid) goto __67 __66: ; @@ -121178,10 +119041,10 @@ __66: if !(pPk != 0) { goto __69 } - Xsqlite3VdbeAddOp3(tls, v, 72, 0, iPk, ((iPk + int32(nPk)) - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, iPk, ((iPk + int32(nPk)) - 1)) __69: ; - addrOpen = Xsqlite3VdbeAddOp2(tls, v, 100, iEph, nEphCol) + addrOpen = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, iEph, nEphCol) if !(pPk != 0) { goto __70 } @@ -121217,7 +119080,7 @@ __67: goto __74 } Xsqlite3MultiWrite(tls, pParse) - eOnePass = 0 + eOnePass = ONEPASS_OFF nKey = int32(nPk) regKey = iPk goto __75 @@ -121230,8 +119093,8 @@ __74: // that is to be updated. So bypass the code that searches for the // row(s) to be updated. pWInfo = uintptr(0) - eOnePass = 1 - Xsqlite3ExprIfFalse(tls, pParse, pWhere, labelBreak, 0x10) + eOnePass = ONEPASS_SINGLE + Xsqlite3ExprIfFalse(tls, pParse, pWhere, labelBreak, SQLITE_JUMPIFNULL) bFinishSeek = 0 goto __77 __76: @@ -121242,11 +119105,11 @@ __76: // be deleted as a result of REPLACE conflict handling. Any of these // things might disturb a cursor being used to scan through the table // or index, causing a single-pass approach to malfunction. - flags = (0x0004 | 0x1000) + flags = (WHERE_ONEPASS_DESIRED | WHERE_SEEK_UNIQ_TABLE) if !((((!(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0) && !(pTrigger != 0)) && !(hasFK != 0)) && !(chngKey != 0)) && !(*(*int32)(unsafe.Pointer(bp + 104 /* bReplace */)) != 0)) { goto __78 } - flags = flags | (0x0008) + flags = flags | (WHERE_ONEPASS_MULTIROW) __78: ; pWInfo = Xsqlite3WhereBegin(tls, pParse, pTabList, pWhere, uintptr(0), uintptr(0), uint16(flags), iIdxCur) @@ -121269,18 +119132,18 @@ __79: // updated. eOnePass = Xsqlite3WhereOkOnePass(tls, pWInfo, bp+96 /* &aiCurOnePass[0] */) bFinishSeek = Xsqlite3WhereUsesDeferredSeek(tls, pWInfo) - if !(eOnePass != 1) { + if !(eOnePass != ONEPASS_SINGLE) { goto __80 } Xsqlite3MultiWrite(tls, pParse) - if !(eOnePass == 2) { + if !(eOnePass == ONEPASS_MULTI) { goto __81 } - iCur = *(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(1)*4)) + iCur = *(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + 1*4)) if !(((iCur >= 0) && (iCur != iDataCur)) && (*(*U8)(unsafe.Pointer(aToOpen + uintptr((iCur - iBaseCur)))) != 0)) { goto __82 } - eOnePass = 0 + eOnePass = ONEPASS_OFF __82: ; @@ -121291,19 +119154,19 @@ __80: __77: ; - if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { goto __83 } // Read the rowid of the current row of the WHERE scan. In ONEPASS_OFF // mode, write the rowid into the FIFO. In either of the one-pass modes, // leave it in register regOldRowid. - Xsqlite3VdbeAddOp2(tls, v, 127, iDataCur, regOldRowid) - if !(eOnePass == 0) { + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iDataCur, regOldRowid) + if !(eOnePass == ONEPASS_OFF) { goto __85 } // We need to use regRowSet, so reallocate aRegIdx[nAllIdx] *(*int32)(unsafe.Pointer(aRegIdx + uintptr(nAllIdx)*4)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 147, regRowSet, regOldRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_RowSetAdd, regRowSet, regOldRowid) __85: ; goto __84 @@ -121341,9 +119204,9 @@ __91: regKey = iPk goto __90 __89: - Xsqlite3VdbeAddOp4(tls, v, 91, iPk, int32(nPk), regKey, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, iPk, int32(nPk), regKey, Xsqlite3IndexAffinityStr(tls, db, pPk), int32(nPk)) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iEph, regKey, iPk, int32(nPk)) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iEph, regKey, iPk, int32(nPk)) __90: ; __84: @@ -121354,7 +119217,7 @@ __75: if !(pUpsert == uintptr(0)) { goto __92 } - if !((nChangeFrom == 0) && (eOnePass != 2)) { + if !((nChangeFrom == 0) && (eOnePass != ONEPASS_MULTI)) { goto __93 } Xsqlite3WhereEnd(tls, pWInfo) @@ -121367,31 +119230,31 @@ __93: addrOnce = 0 // Open every index that needs updating. - if !(eOnePass != 0) { + if !(eOnePass != ONEPASS_OFF) { goto __95 } - if !(*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(0)*4)) >= 0) { + if !(*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */)) >= 0) { goto __96 } - *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(0)*4)) - iBaseCur)))) = U8(0) + *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */)) - iBaseCur)))) = U8(0) __96: ; - if !(*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(1)*4)) >= 0) { + if !(*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + 1*4)) >= 0) { goto __97 } - *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(1)*4)) - iBaseCur)))) = U8(0) + *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + 1*4)) - iBaseCur)))) = U8(0) __97: ; __95: ; - if !((eOnePass == 2) && ((nIdx - (libc.Bool32(*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(1)*4)) >= 0))) > 0)) { + if !((eOnePass == ONEPASS_MULTI) && ((nIdx - (libc.Bool32(*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + 1*4)) >= 0))) > 0)) { goto __98 } - addrOnce = Xsqlite3VdbeAddOp0(tls, v, 17) + addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once) __98: ; - Xsqlite3OpenTableAndIndices(tls, pParse, pTab, 97, uint8(0), iBaseCur, + Xsqlite3OpenTableAndIndices(tls, pParse, pTab, OP_OpenWrite, uint8(0), iBaseCur, aToOpen, uintptr(0), uintptr(0)) if !(addrOnce != 0) { goto __99 @@ -121403,24 +119266,24 @@ __94: ; // Top of the update loop - if !(eOnePass != 0) { + if !(eOnePass != ONEPASS_OFF) { goto __100 } - if !((!(isView != 0) && (*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(0)*4)) != iDataCur)) && (*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(1)*4)) != iDataCur)) { + if !((!(isView != 0) && (*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */)) != iDataCur)) && (*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + 1*4)) != iDataCur)) { goto __102 } - Xsqlite3VdbeAddOp4Int(tls, v, 29, iDataCur, labelBreak, regKey, nKey) + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iDataCur, labelBreak, regKey, nKey) __102: ; - if !(eOnePass != 1) { + if !(eOnePass != ONEPASS_SINGLE) { goto __103 } labelContinue = Xsqlite3VdbeMakeLabel(tls, pParse) __103: ; - Xsqlite3VdbeAddOp2(tls, v, 50, func() int32 { + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, func() int32 { if pPk != 0 { return regKey } @@ -121433,7 +119296,7 @@ __100: goto __104 } labelContinue = Xsqlite3VdbeMakeLabel(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 37, iEph, labelBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iEph, labelBreak) addrTop = Xsqlite3VdbeCurrentAddr(tls, v) if !(nChangeFrom != 0) { goto __106 @@ -121449,7 +119312,7 @@ __111: if !(i < int32(nPk)) { goto __113 } - Xsqlite3VdbeAddOp3(tls, v, 89, iEph, i, (iPk + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, i, (iPk + i)) goto __112 __112: i++ @@ -121458,29 +119321,29 @@ __112: __113: ; Xsqlite3VdbeAddOp4Int(tls, - v, 29, iDataCur, labelContinue, iPk, int32(nPk)) + v, OP_NotFound, iDataCur, labelContinue, iPk, int32(nPk)) goto __110 __109: - Xsqlite3VdbeAddOp2(tls, v, 127, iEph, regOldRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iEph, regOldRowid) Xsqlite3VdbeAddOp3(tls, - v, 32, iDataCur, labelContinue, regOldRowid) + v, OP_NotExists, iDataCur, labelContinue, regOldRowid) __110: ; __108: ; goto __107 __106: - Xsqlite3VdbeAddOp2(tls, v, 126, iEph, regKey) - Xsqlite3VdbeAddOp4Int(tls, v, 29, iDataCur, labelContinue, regKey, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_RowData, iEph, regKey) + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iDataCur, labelContinue, regKey, 0) __107: ; goto __105 __104: - labelContinue = Xsqlite3VdbeAddOp3(tls, v, 42, regRowSet, labelBreak, + labelContinue = Xsqlite3VdbeAddOp3(tls, v, OP_RowSetRead, regRowSet, labelBreak, regOldRowid) - Xsqlite3VdbeAddOp3(tls, v, 32, iDataCur, labelContinue, regOldRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, labelContinue, regOldRowid) __105: ; @@ -121504,10 +119367,10 @@ __92: Xsqlite3ExprCode(tls, pParse, pRowidExpr, regNewRowid) goto __116 __115: - Xsqlite3VdbeAddOp3(tls, v, 89, iEph, iRowidExpr, regNewRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, iRowidExpr, regNewRowid) __116: ; - Xsqlite3VdbeAddOp1(tls, v, 15, regNewRowid) + Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, regNewRowid) __114: ; @@ -121523,7 +119386,7 @@ __114: return uint32(0) }() oldmask = oldmask | (Xsqlite3TriggerColmask(tls, pParse, - pTrigger, pChanges, 0, (1 | 2), pTab, onError)) + pTrigger, pChanges, 0, (TRIGGER_BEFORE | TRIGGER_AFTER), pTab, onError)) i = 0 __118: if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) { @@ -121533,14 +119396,14 @@ __118: k = (int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(i))) + regOld) if !(((oldmask == 0xffffffff) || ((i < 32) && ((oldmask & (uint32((uint32(1))) << (i))) != U32(0)))) || - ((colFlags & U32(0x0001)) != U32(0))) { + ((colFlags & COLFLAG_PRIMKEY) != U32(0))) { goto __121 } Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iDataCur, i, k) goto __122 __121: - Xsqlite3VdbeAddOp2(tls, v, 72, 0, k) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, k) __122: ; goto __119 @@ -121553,7 +119416,7 @@ __120: if !((int32(chngRowid) == 0) && (pPk == uintptr(0))) { goto __123 } - Xsqlite3VdbeAddOp2(tls, v, 77, regOldRowid, regNewRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, regOldRowid, regNewRowid) __123: ; __117: @@ -121572,7 +119435,7 @@ __117: // may have modified them). So not loading those that are not going to // be used eliminates some redundant opcodes. newmask = int32(Xsqlite3TriggerColmask(tls, - pParse, pTrigger, pChanges, 1, 1, pTab, onError)) + pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError)) i = 0 k = regNew __124: @@ -121582,13 +119445,13 @@ __124: if !(i == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) { goto __127 } - Xsqlite3VdbeAddOp2(tls, v, 72, 0, k) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, k) goto __128 __127: - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0060) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_GENERATED) != 0) { goto __129 } - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0) { goto __131 } k-- @@ -121610,7 +119473,7 @@ __129: return int32(nPk) }() - Xsqlite3VdbeAddOp3(tls, v, 89, iEph, (nOff + j), k) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, (nOff + j), k) goto __135 __134: Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pChanges+8 /* &.a */)+uintptr(j)*32)).FpExpr, k) @@ -121618,7 +119481,7 @@ __135: ; goto __133 __132: - if !(((0 == (*(*int32)(unsafe.Pointer(bp + 32 /* tmask */)) & 1)) || (i > 31)) || ((uint32(newmask) & (uint32((uint32(1))) << (i))) != 0)) { + if !(((0 == (*(*int32)(unsafe.Pointer(bp + 32 /* tmask */)) & TRIGGER_BEFORE)) || (i > 31)) || ((uint32(newmask) & (uint32((uint32(1))) << (i))) != 0)) { goto __136 } // This branch loads the value of a column that will not be changed @@ -121630,7 +119493,7 @@ __132: bFinishSeek = 0 goto __137 __136: - Xsqlite3VdbeAddOp2(tls, v, 72, 0, k) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, k) __137: ; __133: @@ -121647,7 +119510,7 @@ __125: goto __126 __126: ; - if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != 0) { + if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != 0) { goto __138 } @@ -121657,12 +119520,12 @@ __138: // Fire any BEFORE UPDATE triggers. This happens before constraints are // verified. One could argue that this is wrong. - if !((*(*int32)(unsafe.Pointer(bp + 32 /* tmask */)) & 1) != 0) { + if !((*(*int32)(unsafe.Pointer(bp + 32 /* tmask */)) & TRIGGER_BEFORE) != 0) { goto __139 } Xsqlite3TableAffinity(tls, v, pTab, regNew) - Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, 127, pChanges, - 1, pTab, regOldRowid, onError, labelContinue) + Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, TK_UPDATE, pChanges, + TRIGGER_BEFORE, pTab, regOldRowid, onError, labelContinue) if !(!(isView != 0)) { goto __140 @@ -121675,11 +119538,11 @@ __138: if !(pPk != 0) { goto __141 } - Xsqlite3VdbeAddOp4Int(tls, v, 29, iDataCur, labelContinue, regKey, nKey) + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iDataCur, labelContinue, regKey, nKey) goto __142 __141: - Xsqlite3VdbeAddOp3(tls, v, 32, iDataCur, labelContinue, regOldRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, labelContinue, regOldRowid) __142: ; @@ -121698,10 +119561,10 @@ __143: if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) { goto __145 } - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0060) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_GENERATED) != 0) { goto __146 } - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0) { goto __148 } k-- @@ -121725,7 +119588,7 @@ __144: goto __145 __145: ; - if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != 0) { + if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != 0) { goto __150 } @@ -121755,10 +119618,10 @@ __139: if !(pPk != 0) { goto __153 } - Xsqlite3VdbeAddOp4Int(tls, v, 29, iDataCur, labelContinue, regKey, nKey) + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iDataCur, labelContinue, regKey, nKey) goto __154 __153: - Xsqlite3VdbeAddOp3(tls, v, 32, iDataCur, labelContinue, regOldRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, labelContinue, regOldRowid) __154: ; @@ -121784,7 +119647,7 @@ __155: if !(bFinishSeek != 0) { goto __156 } - Xsqlite3VdbeAddOp1(tls, v, 135, iDataCur) + Xsqlite3VdbeAddOp1(tls, v, OP_FinishSeek, iDataCur) __156: ; @@ -121797,19 +119660,19 @@ __156: // value is copied from memory cell (regNewRowid+1+iCol), where iCol // is the column index supplied by the user. - Xsqlite3VdbeAddOp3(tls, v, 122, iDataCur, - (0x04 | (func() int32 { + Xsqlite3VdbeAddOp3(tls, v, OP_Delete, iDataCur, + (OPFLAG_ISUPDATE | (func() int32 { if (hasFK > 1) || (chngKey != 0) { return 0 } - return 0x40 + return OPFLAG_ISNOOP }())), regNewRowid) - if !(eOnePass == 2) { + if !(eOnePass == ONEPASS_MULTI) { goto __157 } - Xsqlite3VdbeChangeP5(tls, v, uint16(0x02)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_SAVEPOSITION) __157: ; if !(!(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0)) { @@ -121829,9 +119692,9 @@ __159: // Insert the new index entries and the new record. Xsqlite3CompleteInsertion(tls, pParse, pTab, iDataCur, iIdxCur, regNewRowid, aRegIdx, - (0x04 | (func() int32 { - if eOnePass == 2 { - return 0x02 + (OPFLAG_ISUPDATE | (func() int32 { + if eOnePass == ONEPASS_MULTI { + return OPFLAG_SAVEPOSITION } return 0 }())), @@ -121853,22 +119716,22 @@ __151: if !(regRowCount != 0) { goto __161 } - Xsqlite3VdbeAddOp2(tls, v, 82, regRowCount, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, regRowCount, 1) __161: ; - Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, 127, pChanges, - 2, pTab, regOldRowid, onError, labelContinue) + Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, TK_UPDATE, pChanges, + TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue) // Repeat the above with the next record to be updated, until // all record selected by the WHERE clause have been updated. - if !(eOnePass == 1) { + if !(eOnePass == ONEPASS_SINGLE) { goto __162 } // Nothing to do at end-of-loop for a single-pass goto __163 __162: - if !(eOnePass == 2) { + if !(eOnePass == ONEPASS_MULTI) { goto __164 } Xsqlite3VdbeResolveLabel(tls, v, labelContinue) @@ -121879,7 +119742,7 @@ __164: goto __166 } Xsqlite3VdbeResolveLabel(tls, v, labelContinue) - Xsqlite3VdbeAddOp2(tls, v, 5, iEph, addrTop) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iEph, addrTop) goto __167 __166: Xsqlite3VdbeGoto(tls, v, labelContinue) @@ -121906,9 +119769,9 @@ __168: if !(regRowCount != 0) { goto __169 } - Xsqlite3VdbeAddOp2(tls, v, 80, regRowCount, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, regRowCount, 1) Xsqlite3VdbeSetNumCols(tls, v, 1) - Xsqlite3VdbeSetColName(tls, v, 0, 0, ts+17883 /* "rows updated" */, uintptr(0)) + Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, ts+17883 /* "rows updated" */, uintptr(0)) __169: ; @@ -121954,11 +119817,11 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb // Database connection var pVTab uintptr = Xsqlite3GetVTable(tls, db, pTab) var pWInfo uintptr = uintptr(0) - var nArg int32 = (2 + int32((*Table)(unsafe.Pointer(pTab)).FnCol)) // Number of arguments to VUpdate - var regArg int32 // First register in VUpdate arg array - var regRec int32 // Register in which to assemble record - var regRowid int32 // Register for ephem table rowid - var iCsr int32 = (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */) + uintptr(0)*112)).FiCursor // Cursor used for virtual table scan + var nArg int32 = (2 + int32((*Table)(unsafe.Pointer(pTab)).FnCol)) // Number of arguments to VUpdate + var regArg int32 // First register in VUpdate arg array + var regRec int32 // Register in which to assemble record + var regRowid int32 // Register for ephem table rowid + var iCsr int32 = (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FiCursor // Cursor used for virtual table scan // var aDummy [2]int32 at bp, 8 // Unused arg for sqlite3WhereOkOnePass() var eOnePass int32 // True to use onepass strategy @@ -121969,7 +119832,7 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt // these arguments will be temporarily stored. ephemTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - addr = Xsqlite3VdbeAddOp2(tls, v, 100, ephemTab, nArg) + addr = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, ephemTab, nArg) regArg = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (nArg) if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc > 1 { @@ -121978,7 +119841,7 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt if pRowid != 0 { pRow = Xsqlite3ExprDup(tls, db, pRowid, 0) } else { - pRow = Xsqlite3PExpr(tls, pParse, 75, uintptr(0), uintptr(0)) + pRow = Xsqlite3PExpr(tls, pParse, TK_ROW, uintptr(0), uintptr(0)) } pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), pRow) @@ -121993,13 +119856,13 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt updateFromSelect(tls, pParse, ephemTab, uintptr(0), pList, pSrc, pWhere, uintptr(0), uintptr(0)) Xsqlite3ExprListDelete(tls, db, pList) - eOnePass = 0 + eOnePass = ONEPASS_OFF } else { regRec = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) regRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) // Start scanning the virtual table - pWInfo = Xsqlite3WhereBegin(tls, pParse, pSrc, pWhere, uintptr(0), uintptr(0), uint16(0x0004), 0) + pWInfo = Xsqlite3WhereBegin(tls, pParse, pSrc, pWhere, uintptr(0), uintptr(0), WHERE_ONEPASS_DESIRED, 0) if pWInfo == uintptr(0) { return } @@ -122010,25 +119873,25 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt if *(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4)) >= 0 { Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pChanges+8 /* &.a */)+uintptr(*(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4)))*32)).FpExpr, ((regArg + 2) + i)) } else { - Xsqlite3VdbeAddOp3(tls, v, 166, iCsr, i, ((regArg + 2) + i)) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x01)) // For sqlite3_vtab_nochange() + Xsqlite3VdbeAddOp3(tls, v, OP_VColumn, iCsr, i, ((regArg + 2) + i)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_NOCHNG) // For sqlite3_vtab_nochange() } } - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { - Xsqlite3VdbeAddOp2(tls, v, 127, iCsr, regArg) + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iCsr, regArg) if pRowid != 0 { Xsqlite3ExprCode(tls, pParse, pRowid, (regArg + 1)) } else { - Xsqlite3VdbeAddOp2(tls, v, 127, iCsr, (regArg + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iCsr, (regArg + 1)) } } else { var pPk uintptr // PRIMARY KEY index var iPk I16 // PRIMARY KEY column pPk = Xsqlite3PrimaryKeyIndex(tls, pTab) - iPk = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(0)*2)) - Xsqlite3VdbeAddOp3(tls, v, 166, iCsr, int32(iPk), regArg) - Xsqlite3VdbeAddOp2(tls, v, 78, ((regArg + 2) + int32(iPk)), (regArg + 1)) + iPk = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn)) + Xsqlite3VdbeAddOp3(tls, v, OP_VColumn, iCsr, int32(iPk), regArg) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, ((regArg + 2) + int32(iPk)), (regArg + 1)) } eOnePass = Xsqlite3WhereOkOnePass(tls, pWInfo, bp /* &aDummy[0] */) @@ -122039,37 +119902,37 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt // If using the onepass strategy, no-op out the OP_OpenEphemeral coded // above. Xsqlite3VdbeChangeToNoop(tls, v, addr) - Xsqlite3VdbeAddOp1(tls, v, 116, iCsr) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iCsr) } else { // Create a record from the argument register contents and insert it into // the ephemeral table. Xsqlite3MultiWrite(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 91, regArg, nArg, regRec) - Xsqlite3VdbeAddOp2(tls, v, 120, ephemTab, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, ephemTab, regRec, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regArg, nArg, regRec) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, ephemTab, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, ephemTab, regRec, regRowid) } } - if eOnePass == 0 { + if eOnePass == ONEPASS_OFF { // End the virtual table scan if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc == 1 { Xsqlite3WhereEnd(tls, pWInfo) } // Begin scannning through the ephemeral table. - addr = Xsqlite3VdbeAddOp1(tls, v, 37, ephemTab) + addr = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, ephemTab) // Extract arguments from the current row of the ephemeral table and // invoke the VUpdate method. for i = 0; i < nArg; i++ { - Xsqlite3VdbeAddOp3(tls, v, 89, ephemTab, i, (regArg + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, ephemTab, i, (regArg + i)) } } Xsqlite3VtabMakeWritable(tls, pParse, pTab) - Xsqlite3VdbeAddOp4(tls, v, 10, 0, nArg, regArg, pVTab, -12) + Xsqlite3VdbeAddOp4(tls, v, OP_VUpdate, 0, nArg, regArg, pVTab, -12) Xsqlite3VdbeChangeP5(tls, v, func() uint16 { - if onError == 11 { - return uint16(2) + if onError == OE_Default { + return OE_Abort } return uint16(onError) }()) @@ -122077,10 +119940,10 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt // End of the ephemeral table scan. Or, if using the onepass strategy, // jump to here if the scan visited zero rows. - if eOnePass == 0 { - Xsqlite3VdbeAddOp2(tls, v, 5, ephemTab, (addr + 1)) + if eOnePass == ONEPASS_OFF { + Xsqlite3VdbeAddOp2(tls, v, OP_Next, ephemTab, (addr + 1)) Xsqlite3VdbeJumpHere(tls, v, addr) - Xsqlite3VdbeAddOp2(tls, v, 116, ephemTab, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, ephemTab, 0) } else { Xsqlite3WhereEnd(tls, pWInfo) } @@ -122181,16 +120044,16 @@ func Xsqlite3UpsertAnalyzeTarget(tls *libc.TLS, pParse uintptr, pTabList uintptr } // Check to see if the conflict target matches the rowid. - pTab = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FpTab + pTab = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FpTab pTarget = (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget - iCursor = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FiCursor - if (((((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) && + iCursor = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FiCursor + if (((((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((*ExprList)(unsafe.Pointer(pTarget)).FnExpr == 1)) && - (int32((*Expr)(unsafe.Pointer((libc.AssignUintptr(&pTerm, (*ExprList_item)(unsafe.Pointer((pTarget+8 /* &.a */)+uintptr(0)*32)).FpExpr)))).Fop) == 164)) && + (int32((*Expr)(unsafe.Pointer((libc.AssignUintptr(&pTerm, (*ExprList_item)(unsafe.Pointer((pTarget + 8 /* &.a */))).FpExpr)))).Fop) == TK_COLUMN)) && (int32((*Expr)(unsafe.Pointer(pTerm)).FiColumn) == (-1)) { // The conflict-target is the rowid of the primary table - return 0 + return SQLITE_OK } // Initialize sCol[0..1] to be an expression parse tree for a @@ -122199,17 +120062,17 @@ func Xsqlite3UpsertAnalyzeTarget(tls *libc.TLS, pParse uintptr, pTabList uintptr // will populate the specific collation and column number values // prior to comparing against the conflict-target expression. libc.Xmemset(tls, bp+56 /* &sCol[0] */, 0, uint64(unsafe.Sizeof([2]Expr{}))) - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(0)*72)).Fop = U8(111) - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(0)*72)).FpLeft = (bp + 56 /* &sCol */ + uintptr(1)*72) - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(1)*72)).Fop = U8(164) - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(1)*72)).FiTable = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FiCursor + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */)).Fop = TK_COLLATE + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */)).FpLeft = (bp + 56 /* &sCol */ + 1*72) + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + 1*72)).Fop = TK_COLUMN + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + 1*72)).FiTable = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FiCursor // Check for matches against other indexes for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { var ii int32 var jj int32 var nn int32 - if !(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0) { + if !(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None) { continue } if (*ExprList)(unsafe.Pointer(pTarget)).FnExpr != int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) { @@ -122227,18 +120090,18 @@ func Xsqlite3UpsertAnalyzeTarget(tls *libc.TLS, pParse uintptr, pTabList uintptr nn = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) for ii = 0; ii < nn; ii++ { var pExpr uintptr - *(*uintptr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(0)*72 + 8 /* &.u */)) = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(ii)*8)) + *(*uintptr)(unsafe.Pointer(bp + 56 /* &sCol */ + 8 /* &.u */)) = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(ii)*8)) if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2))) == (-2) { pExpr = (*ExprList_item)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FaColExpr + 8 /* &.a */) + uintptr(ii)*32)).FpExpr - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 111 { - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(0)*72)).FpLeft = pExpr - pExpr = (bp + 56 /* &sCol */ + uintptr(0)*72) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLLATE { + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */)).FpLeft = pExpr + pExpr = (bp + 56 /* &sCol */) } } else { - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(0)*72)).FpLeft = (bp + 56 /* &sCol */ + uintptr(1)*72) - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(1)*72)).FiColumn = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2)) - pExpr = (bp + 56 /* &sCol */ + uintptr(0)*72) + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */)).FpLeft = (bp + 56 /* &sCol */ + 1*72) + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + 1*72)).FiColumn = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2)) + pExpr = (bp + 56 /* &sCol */) } for jj = 0; jj < nn; jj++ { if Xsqlite3ExprCompare(tls, pParse, (*ExprList_item)(unsafe.Pointer((pTarget+8 /* &.a */)+uintptr(jj)*32)).FpExpr, pExpr, iCursor) < 2 { @@ -122256,11 +120119,11 @@ func Xsqlite3UpsertAnalyzeTarget(tls *libc.TLS, pParse uintptr, pTabList uintptr continue } (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx = pIdx - return 0 + return SQLITE_OK } Xsqlite3ErrorMsg(tls, pParse, ts+17896 /* "ON CONFLICT clau..." */, 0) - return 1 + return SQLITE_ERROR } // Generate bytecode that does an UPDATE as part of an upsert. @@ -122279,10 +120142,10 @@ func Xsqlite3UpsertDoUpdate(tls *libc.TLS, pParse uintptr, pUpsert uintptr, pTab iDataCur = (*Upsert)(unsafe.Pointer(pUpsert)).FiDataCur if (pIdx != 0) && (iCur != iDataCur) { - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { var regRowid int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 134, iCur, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 31, iDataCur, 0, regRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_IdxRowid, iCur, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, iDataCur, 0, regRowid) Xsqlite3ReleaseTempReg(tls, pParse, regRowid) } else { @@ -122294,13 +120157,13 @@ func Xsqlite3UpsertDoUpdate(tls *libc.TLS, pParse uintptr, pUpsert uintptr, pTab var k int32 k = int32(Xsqlite3TableColumnToIndex(tls, pIdx, *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))) - Xsqlite3VdbeAddOp3(tls, v, 89, iCur, k, (iPk + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iCur, k, (iPk + i)) } - i = Xsqlite3VdbeAddOp4Int(tls, v, 30, iDataCur, 0, iPk, nPk) + i = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, iDataCur, 0, iPk, nPk) - Xsqlite3VdbeAddOp4(tls, v, 68, 11, 2, 0, + Xsqlite3VdbeAddOp4(tls, v, OP_Halt, SQLITE_CORRUPT, OE_Abort, 0, ts+10100 /* "corrupt database" */, -1) Xsqlite3MayAbort(tls, pParse) Xsqlite3VdbeJumpHere(tls, v, i) @@ -122311,12 +120174,12 @@ func Xsqlite3UpsertDoUpdate(tls *libc.TLS, pParse uintptr, pUpsert uintptr, pTab pSrc = Xsqlite3SrcListDup(tls, db, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc, 0) // excluded.* columns of type REAL need to be converted to a hard real for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { - if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).Faffinity) == 0x45 { - Xsqlite3VdbeAddOp1(tls, v, 83, ((*Upsert)(unsafe.Pointer(pUpsert)).FregData + i)) + if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).Faffinity) == SQLITE_AFF_REAL { + Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, ((*Upsert)(unsafe.Pointer(pUpsert)).FregData + i)) } } Xsqlite3Update(tls, pParse, pSrc, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet, - (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere, 2, uintptr(0), uintptr(0), pUpsert) + (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere, OE_Abort, uintptr(0), uintptr(0), pUpsert) (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet = uintptr(0) // Will have been deleted by sqlite3Update() (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere = uintptr(0) // Will have been deleted by sqlite3Update() @@ -122359,10 +120222,10 @@ func execSql(tls *libc.TLS, db uintptr, pzErrMsg uintptr, zSql uintptr) int32 { // printf("SQL: [%s]\n", zSql); fflush(stdout); rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp /* &pStmt */, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { return rc } - for 100 == (libc.AssignInt32(&rc, Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))))) { + for SQLITE_ROW == (libc.AssignInt32(&rc, Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))))) { var zSubSql uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 0) // The secondary SQL must be one of CREATE TABLE, CREATE INDEX, @@ -122373,14 +120236,14 @@ func execSql(tls *libc.TLS, db uintptr, pzErrMsg uintptr, zSql uintptr) int32 { if (zSubSql != 0) && ((libc.Xstrncmp(tls, zSubSql, ts+17967 /* "CRE" */, uint64(3)) == 0) || (libc.Xstrncmp(tls, zSubSql, ts+17971 /* "INS" */, uint64(3)) == 0)) { rc = execSql(tls, db, pzErrMsg, zSubSql) - if rc != 0 { + if rc != SQLITE_OK { break } } } - if rc == 101 { - rc = 0 + if rc == SQLITE_DONE { + rc = SQLITE_OK } if rc != 0 { Xsqlite3SetString(tls, pzErrMsg, db, Xsqlite3_errmsg(tls, db)) @@ -122398,7 +120261,7 @@ func execSqlF(tls *libc.TLS, db uintptr, pzErrMsg uintptr, zSql uintptr, va uint z = Xsqlite3VMPrintf(tls, db, zSql, ap) _ = ap if z == uintptr(0) { - return 7 + return SQLITE_NOMEM } rc = execSql(tls, db, pzErrMsg, z) Xsqlite3DbFree(tls, db, z) @@ -122480,7 +120343,7 @@ __3: Xsqlite3ExprCode(tls, pParse, pInto, iIntoReg) __6: ; - Xsqlite3VdbeAddOp2(tls, v, 8, iDb, iIntoReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Vacuum, iDb, iIntoReg) Xsqlite3VdbeUsesBtree(tls, v, iDb) __5: ; @@ -122515,37 +120378,37 @@ func Xsqlite3RunVacuum(tls *libc.TLS, pzErrMsg uintptr, db uintptr, iDb int32, p // var meta U32 at bp+48, 4 var i int32 - rc = 0 + rc = SQLITE_OK pDb = uintptr(0) // Name of output file if !(!(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0)) { goto __1 } Xsqlite3SetString(tls, pzErrMsg, db, ts+17975 /* "cannot VACUUM fr..." */) - return 1 // IMP: R-12218-18073 + return SQLITE_ERROR // IMP: R-12218-18073 __1: ; if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive > 1) { goto __2 } Xsqlite3SetString(tls, pzErrMsg, db, ts+18015 /* "cannot VACUUM - ..." */) - return 1 // IMP: R-15610-35227 + return SQLITE_ERROR // IMP: R-15610-35227 __2: ; saved_openFlags = (*Sqlite3)(unsafe.Pointer(db)).FopenFlags if !(pOut != 0) { goto __3 } - if !(Xsqlite3_value_type(tls, pOut) != 3) { + if !(Xsqlite3_value_type(tls, pOut) != SQLITE_TEXT) { goto __5 } Xsqlite3SetString(tls, pzErrMsg, db, ts+18058 /* "non-text filenam..." */) - return 1 + return SQLITE_ERROR __5: ; zOut = Xsqlite3_value_text(tls, pOut) - *(*uint32)(unsafe.Pointer(db + 76 /* &.openFlags */)) &= (^libc.Uint32FromInt32(0x00000001)) - *(*uint32)(unsafe.Pointer(db + 76 /* &.openFlags */)) |= (uint32(0x00000004 | 0x00000002)) + *(*uint32)(unsafe.Pointer(db + 76 /* &.openFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SQLITE_OPEN_READONLY))) + *(*uint32)(unsafe.Pointer(db + 76 /* &.openFlags */)) |= (uint32(SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)) goto __4 __3: zOut = ts + 703 /* "" */ @@ -122560,10 +120423,10 @@ __4: saved_nChange = (*Sqlite3)(unsafe.Pointer(db)).FnChange saved_nTotalChange = (*Sqlite3)(unsafe.Pointer(db)).FnTotalChange saved_mTrace = (*Sqlite3)(unsafe.Pointer(db)).FmTrace - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(0x00000001 | 0x00000200)) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0002 | 0x0004)) - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(((uint64((0x00004000 | 0x00001000) | - 0x10000000)) | (U64((uint64(0x00001))) << 32)))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(SQLITE_WriteSchema | SQLITE_IgnoreChecks)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(DBFLAG_PreferBuiltin | DBFLAG_Vacuum)) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(((uint64((SQLITE_ForeignKeys | SQLITE_ReverseOrder) | + SQLITE_Defensive)) | (U64((uint64(0x00001))) << 32)))) (*Sqlite3)(unsafe.Pointer(db)).FmTrace = U8(0) zDbMain = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName @@ -122586,7 +120449,7 @@ __4: nDb = (*Sqlite3)(unsafe.Pointer(db)).FnDb rc = execSqlF(tls, db, pzErrMsg, ts+18076 /* "ATTACH %Q AS vac..." */, libc.VaList(bp, zOut)) (*Sqlite3)(unsafe.Pointer(db)).FopenFlags = saved_openFlags - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __6 } goto end_of_vacuum @@ -122601,28 +120464,28 @@ __6: } id = Xsqlite3PagerFile(tls, Xsqlite3BtreePager(tls, pTemp)) *(*I64)(unsafe.Pointer(bp + 40 /* sz */)) = int64(0) - if !(((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods != uintptr(0)) && ((Xsqlite3OsFileSize(tls, id, bp+40 /* &sz */) != 0) || (*(*I64)(unsafe.Pointer(bp + 40 /* sz */)) > int64(0)))) { + if !(((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods != uintptr(0)) && ((Xsqlite3OsFileSize(tls, id, bp+40 /* &sz */) != SQLITE_OK) || (*(*I64)(unsafe.Pointer(bp + 40 /* sz */)) > int64(0)))) { goto __8 } - rc = 1 + rc = SQLITE_ERROR Xsqlite3SetString(tls, pzErrMsg, db, ts+18099 /* "output file alre..." */) goto end_of_vacuum __8: ; - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0008)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_VacuumInto) __7: ; nRes = Xsqlite3BtreeGetRequestedReserve(tls, pMain) Xsqlite3BtreeSetCacheSize(tls, pTemp, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FpSchema)).Fcache_size) Xsqlite3BtreeSetSpillSize(tls, pTemp, Xsqlite3BtreeSetSpillSize(tls, pMain, 0)) - Xsqlite3BtreeSetPagerFlags(tls, pTemp, (uint32(0x01 | 0x20))) + Xsqlite3BtreeSetPagerFlags(tls, pTemp, (uint32(PAGER_SYNCHRONOUS_OFF | PAGER_CACHESPILL))) // Begin a transaction and take an exclusive lock on the main database // file. This is done before the sqlite3BtreeGetPageSize(pMain) call below, // to ensure that we do not try to change the page-size on a WAL database. rc = execSql(tls, db, pzErrMsg, ts+12336 /* "BEGIN" */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __9 } goto end_of_vacuum @@ -122634,7 +120497,7 @@ __9: } return 0 }(), uintptr(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __10 } goto end_of_vacuum @@ -122643,7 +120506,7 @@ __10: // Do not attempt to change the page size for a WAL database if !(Xsqlite3PagerGetJournalMode(tls, Xsqlite3BtreePager(tls, pMain)) == - 5) { + PAGER_JOURNALMODE_WAL) { goto __11 } (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize = 0 @@ -122655,7 +120518,7 @@ __11: ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0)) { goto __12 } - rc = 7 + rc = SQLITE_NOMEM goto end_of_vacuum __12: ; @@ -122674,7 +120537,7 @@ __12: ts+18126, /* "SELECT sql FROM ..." */ libc.VaList(bp+8, zDbMain)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __13 } goto end_of_vacuum @@ -122684,7 +120547,7 @@ __13: ts+18234, /* "SELECT sql FROM ..." */ libc.VaList(bp+16, zDbMain)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __14 } goto end_of_vacuum @@ -122700,8 +120563,8 @@ __14: ts+18288, /* "SELECT'INSERT IN..." */ libc.VaList(bp+24, zDbMain)) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (^libc.Uint32FromInt32(0x0004)) - if !(rc != 0) { + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(DBFLAG_Vacuum))) + if !(rc != SQLITE_OK) { goto __15 } goto end_of_vacuum @@ -122740,7 +120603,7 @@ __17: // we already have page 1 loaded into cache and marked dirty. Xsqlite3BtreeGetMeta(tls, pMain, int32(aCopy[i]), bp+48 /* &meta */) rc = Xsqlite3BtreeUpdateMeta(tls, pTemp, int32(aCopy[i]), (*(*U32)(unsafe.Pointer(bp + 48 /* meta */)) + U32(aCopy[(i+1)]))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __20 } goto end_of_vacuum @@ -122760,14 +120623,14 @@ __19: rc = Xsqlite3BtreeCopyFile(tls, pMain, pTemp) __21: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __22 } goto end_of_vacuum __22: ; rc = Xsqlite3BtreeCommit(tls, pTemp) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __23 } goto end_of_vacuum @@ -122822,11 +120685,11 @@ __26: } var aCopy = [10]uint8{ - uint8(1), uint8(1), // Add one to the old schema cookie - uint8(3), uint8(0), // Preserve the default page cache size - uint8(5), uint8(0), // Preserve the text encoding - uint8(6), uint8(0), // Preserve the user version - uint8(8), uint8(0), // Preserve the application id + BTREE_SCHEMA_VERSION, uint8(1), // Add one to the old schema cookie + BTREE_DEFAULT_CACHE_SIZE, uint8(0), // Preserve the default page cache size + BTREE_TEXT_ENCODING, uint8(0), // Preserve the text encoding + BTREE_USER_VERSION, uint8(0), // Preserve the user version + BTREE_APPLICATION_ID, uint8(0), // Preserve the application id } /* sqlite3.c:139504:32 */ // Construct and install a Module object for a virtual table. When this @@ -122849,7 +120712,7 @@ func Xsqlite3VtabCreateModule(tls *libc.TLS, db uintptr, zName uintptr, pModule Xsqlite3OomFault(tls, db) return uintptr(0) } - zCopy = (pMod + uintptr(1)*48) + zCopy = (pMod + 1*48) libc.Xmemcpy(tls, zCopy, zName, (uint64(nName + 1))) (*Module)(unsafe.Pointer(pMod)).FzName = zCopy (*Module)(unsafe.Pointer(pMod)).FpModule = pModule @@ -122876,12 +120739,12 @@ func Xsqlite3VtabCreateModule(tls *libc.TLS, db uintptr, zName uintptr, pModule // This function implements the sqlite3_create_module() and // sqlite3_create_module_v2() interfaces. func createModule(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr, xDestroy uintptr) int32 { /* sqlite3.c:139664:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) Xsqlite3VtabCreateModule(tls, db, zName, pModule, pAux, xDestroy) rc = Xsqlite3ApiExit(tls, db, rc) - if (rc != 0) && (xDestroy != 0) { + if (rc != SQLITE_OK) && (xDestroy != 0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&xDestroy)))(tls, pAux) } Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -122916,7 +120779,7 @@ func Xsqlite3_drop_modules(tls *libc.TLS, db uintptr, azNames uintptr) int32 { / } createModule(tls, db, (*Module)(unsafe.Pointer(pMod)).FzName, uintptr(0), uintptr(0), uintptr(0)) } - return 0 + return SQLITE_OK } // Decrement the reference count on a Module object. Destroy the @@ -123093,7 +120956,7 @@ func addModuleArgument(tls *libc.TLS, pParse uintptr, pTable uintptr, zArg uintp var nBytes Sqlite3_int64 = (Sqlite3_int64(uint64(unsafe.Sizeof(uintptr(0))) * (uint64(2 + (*Table)(unsafe.Pointer(pTable)).FnModuleArg)))) var azModuleArg uintptr var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if ((*Table)(unsafe.Pointer(pTable)).FnModuleArg + 3) >= *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(2)*4)) { + if ((*Table)(unsafe.Pointer(pTable)).FnModuleArg + 3) >= *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 2*4)) { Xsqlite3ErrorMsg(tls, pParse, ts+10279 /* "too many columns..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTable)).FzName)) } azModuleArg = Xsqlite3DbRealloc(tls, db, (*Table)(unsafe.Pointer(pTable)).FazModuleArg, uint64(nBytes)) @@ -123135,8 +120998,8 @@ func Xsqlite3VtabBeginParse(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName if (*Table)(unsafe.Pointer(pTable)).FazModuleArg != 0 { var iDb int32 = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTable)).FpSchema) // The database the table is being created in - Xsqlite3AuthCheck(tls, pParse, 29, (*Table)(unsafe.Pointer(pTable)).FzName, - *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTable)).FazModuleArg + uintptr(0)*8)), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb+uintptr(iDb)*32)).FzDbSName) + Xsqlite3AuthCheck(tls, pParse, SQLITE_CREATE_VTABLE, (*Table)(unsafe.Pointer(pTable)).FzName, + *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTable)).FazModuleArg)), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb+uintptr(iDb)*32)).FzDbSName) } } @@ -123209,14 +121072,14 @@ func Xsqlite3VtabFinishParse(tls *libc.TLS, pParse uintptr, pEnd uintptr) { /* s v = Xsqlite3GetVdbe(tls, pParse) Xsqlite3ChangeCookie(tls, pParse, iDb) - Xsqlite3VdbeAddOp0(tls, v, 158) + Xsqlite3VdbeAddOp0(tls, v, OP_Expire) zWhere = Xsqlite3MPrintf(tls, db, ts+18692 /* "name=%Q AND sql=..." */, libc.VaList(bp+48, (*Table)(unsafe.Pointer(pTab)).FzName, zStmt)) Xsqlite3VdbeAddParseSchemaOp(tls, v, iDb, zWhere) Xsqlite3DbFree(tls, db, zStmt) iReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) Xsqlite3VdbeLoadString(tls, v, iReg, (*Table)(unsafe.Pointer(pTab)).FzName) - Xsqlite3VdbeAddOp2(tls, v, 163, iDb, iReg) + Xsqlite3VdbeAddOp2(tls, v, OP_VCreate, iDb, iReg) } else { var pOld uintptr var pSchema uintptr = (*Table)(unsafe.Pointer(pTab)).FpSchema @@ -123276,27 +121139,27 @@ func vtabCallConstructor(tls *libc.TLS, db uintptr, pTab uintptr, pMod uintptr, if (*VtabCtx)(unsafe.Pointer(pCtx)).FpTab == pTab { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db, ts+18711 /* "vtable construct..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName)) - return 6 + return SQLITE_LOCKED } } zModuleName = Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pTab)).FzName) if !(zModuleName != 0) { - return 7 + return SQLITE_NOMEM } pVTable = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(VTable{}))) if !(pVTable != 0) { Xsqlite3OomFault(tls, db) Xsqlite3DbFree(tls, db, zModuleName) - return 7 + return SQLITE_NOMEM } (*VTable)(unsafe.Pointer(pVTable)).Fdb = db (*VTable)(unsafe.Pointer(pVTable)).FpMod = pMod - (*VTable)(unsafe.Pointer(pVTable)).FeVtabRisk = U8(1) + (*VTable)(unsafe.Pointer(pVTable)).FeVtabRisk = SQLITE_VTABRISK_Normal iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) - *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg + uintptr(1)*8)) = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName + *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg + 1*8)) = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName // Invoke the virtual table constructor @@ -123307,11 +121170,11 @@ func vtabCallConstructor(tls *libc.TLS, db uintptr, pTab uintptr, pMod uintptr, (*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx = bp + 32 /* &sCtx */ rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&xConstruct)))(tls, db, (*Module)(unsafe.Pointer(pMod)).FpAux, nArg, azArg, (pVTable + 16 /* &.pVtab */), bp+64 /* &zErr */) (*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx = (*VtabCtx)(unsafe.Pointer(bp + 32 /* &sCtx */)).FpPrior - if rc == 7 { + if rc == SQLITE_NOMEM { Xsqlite3OomFault(tls, db) } - if 0 != rc { + if SQLITE_OK != rc { if *(*uintptr)(unsafe.Pointer(bp + 64 /* zErr */)) == uintptr(0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db, ts+18753 /* "vtable construct..." */, libc.VaList(bp+8, zModuleName)) } else { @@ -123330,7 +121193,7 @@ func vtabCallConstructor(tls *libc.TLS, db uintptr, pTab uintptr, pMod uintptr, var zFormat uintptr = ts + 18783 /* "vtable construct..." */ *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db, zFormat, libc.VaList(bp+24, (*Table)(unsafe.Pointer(pTab)).FzName)) Xsqlite3VtabUnlock(tls, pVTable) - rc = 1 + rc = SQLITE_ERROR } else { var iCol int32 var oooHidden U16 = U16(0) @@ -123369,8 +121232,8 @@ func vtabCallConstructor(tls *libc.TLS, db uintptr, pTab uintptr, pMod uintptr, *(*int8)(unsafe.Pointer(zType + uintptr((i - 1)))) = int8(0) } - *(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*32 + 28 /* &.colFlags */)) |= U16((0x0002)) - oooHidden = U16(0x0400) + *(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*32 + 28 /* &.colFlags */)) |= U16((COLFLAG_HIDDEN)) + oooHidden = TF_OOOHidden } else { *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(oooHidden)) } @@ -123397,21 +121260,21 @@ func Xsqlite3VtabCallConnect(tls *libc.TLS, pParse uintptr, pTab uintptr) int32 var rc int32 if !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) || (Xsqlite3GetVTable(tls, db, pTab) != 0) { - return 0 + return SQLITE_OK } // Locate the required virtual table module - zMod = *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg + uintptr(0)*8)) + zMod = *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg)) pMod = Xsqlite3HashFind(tls, (db + 528 /* &.aModule */), zMod) if !(pMod != 0) { - var zModule uintptr = *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg + uintptr(0)*8)) + var zModule uintptr = *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg)) Xsqlite3ErrorMsg(tls, pParse, ts+18829 /* "no such module: ..." */, libc.VaList(bp, zModule)) - rc = 1 + rc = SQLITE_ERROR } else { *(*uintptr)(unsafe.Pointer(bp + 16 /* zErr */)) = uintptr(0) rc = vtabCallConstructor(tls, db, pTab, pMod, (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxConnect, bp+16 /* &zErr */) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3ErrorMsg(tls, pParse, ts+2690 /* "%s" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(bp + 16 /* zErr */)))) (*Parse)(unsafe.Pointer(pParse)).Frc = rc } @@ -123432,13 +121295,13 @@ func growVTrans(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:140294:12: */ var nBytes Sqlite3_int64 = (Sqlite3_int64(uint64(unsafe.Sizeof(uintptr(0))) * (uint64(Sqlite3_int64((*Sqlite3)(unsafe.Pointer(db)).FnVTrans) + Sqlite3_int64(ARRAY_INCR))))) aVTrans = Xsqlite3DbRealloc(tls, db, (*Sqlite3)(unsafe.Pointer(db)).FaVTrans, uint64(nBytes)) if !(aVTrans != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, (aVTrans + uintptr((*Sqlite3)(unsafe.Pointer(db)).FnVTrans)*8), 0, (uint64(unsafe.Sizeof(uintptr(0))) * uint64(ARRAY_INCR))) (*Sqlite3)(unsafe.Pointer(db)).FaVTrans = aVTrans } - return 0 + return SQLITE_OK } // Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should @@ -123459,7 +121322,7 @@ func Xsqlite3VtabCallCreate(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr, bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var pTab uintptr var pMod uintptr var zMod uintptr @@ -123467,7 +121330,7 @@ func Xsqlite3VtabCallCreate(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr, pTab = Xsqlite3FindTable(tls, db, zTab, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) // Locate the required virtual table module - zMod = *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg + uintptr(0)*8)) + zMod = *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg)) pMod = Xsqlite3HashFind(tls, (db + 528 /* &.aModule */), zMod) // If the module has been registered and includes a Create method, @@ -123475,16 +121338,16 @@ func Xsqlite3VtabCallCreate(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr, // error. Otherwise, do nothing. if ((pMod == uintptr(0)) || ((*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxCreate == uintptr(0))) || ((*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxDestroy == uintptr(0)) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db, ts+18829 /* "no such module: ..." */, libc.VaList(bp, zMod)) - rc = 1 + rc = SQLITE_ERROR } else { rc = vtabCallConstructor(tls, db, pTab, pMod, (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxCreate, pzErr) } // Justification of ALWAYS(): The xConstructor method is required to // create a valid sqlite3_vtab if it returns SQLITE_OK. - if (rc == 0) && (Xsqlite3GetVTable(tls, db, pTab) != 0) { + if (rc == SQLITE_OK) && (Xsqlite3GetVTable(tls, db, pTab) != 0) { rc = growVTrans(tls, db) - if rc == 0 { + if rc == SQLITE_OK { addToVTrans(tls, db, Xsqlite3GetVTable(tls, db, pTab)) } } @@ -123500,7 +121363,7 @@ func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) int3 defer tls.Free(440) var pCtx uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK var pTab uintptr *(*uintptr)(unsafe.Pointer(bp + 432 /* zErr */)) = uintptr(0) // var sParse Parse at bp+8, 424 @@ -123508,17 +121371,17 @@ func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) int3 Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) pCtx = (*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx if !(pCtx != 0) || ((*VtabCtx)(unsafe.Pointer(pCtx)).FbDeclared != 0) { - Xsqlite3Error(tls, db, 21) + Xsqlite3Error(tls, db, SQLITE_MISUSE) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) return Xsqlite3MisuseError(tls, 140389) } pTab = (*VtabCtx)(unsafe.Pointer(pCtx)).FpTab libc.Xmemset(tls, bp+8 /* &sParse */, 0, uint64(unsafe.Sizeof(Parse{}))) - (*Parse)(unsafe.Pointer(bp + 8 /* &sParse */)).FeParseMode = U8(1) + (*Parse)(unsafe.Pointer(bp + 8 /* &sParse */)).FeParseMode = PARSE_MODE_DECLARE_VTAB (*Parse)(unsafe.Pointer(bp + 8 /* &sParse */)).Fdb = db (*Parse)(unsafe.Pointer(bp + 8 /* &sParse */)).FnQueryLoop = U32(1) - if ((((0 == Xsqlite3RunParser(tls, bp+8 /* &sParse */, zCreateTable, bp+432 /* &zErr */)) && + if ((((SQLITE_OK == Xsqlite3RunParser(tls, bp+8 /* &sParse */, zCreateTable, bp+432 /* &zErr */)) && ((*Parse)(unsafe.Pointer(bp+8 /* &sParse */)).FpNewTable != 0)) && !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0)) && !(int32((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+8 /* &sParse */)).FpNewTable)).FpSelect) != 0)) && @@ -123528,16 +121391,16 @@ func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) int3 var pIdx uintptr (*Table)(unsafe.Pointer(pTab)).FaCol = (*Table)(unsafe.Pointer(pNew)).FaCol (*Table)(unsafe.Pointer(pTab)).FnCol = (*Table)(unsafe.Pointer(pNew)).FnCol - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= ((*Table)(unsafe.Pointer(pNew)).FtabFlags & (U32(0x0080 | 0x0200))) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= ((*Table)(unsafe.Pointer(pNew)).FtabFlags & (U32(TF_WithoutRowid | TF_NoVisibleRowid))) (*Table)(unsafe.Pointer(pNew)).FnCol = int16(0) (*Table)(unsafe.Pointer(pNew)).FaCol = uintptr(0) - if (!(((*Table)(unsafe.Pointer((pNew))).FtabFlags & U32(0x0080)) == U32(0)) && + if (!(((*Table)(unsafe.Pointer((pNew))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(pCtx)).FpVTable)).FpMod)).FpModule)).FxUpdate != uintptr(0))) && (int32((*Index)(unsafe.Pointer(Xsqlite3PrimaryKeyIndex(tls, pNew))).FnKeyCol) != 1) { // WITHOUT ROWID virtual tables must either be read-only (xUpdate==0) // or else must have a single-column PRIMARY KEY - rc = 1 + rc = SQLITE_ERROR } pIdx = (*Table)(unsafe.Pointer(pNew)).FpIndex if pIdx != 0 { @@ -123549,16 +121412,16 @@ func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) int3 } (*VtabCtx)(unsafe.Pointer(pCtx)).FbDeclared = 1 } else { - Xsqlite3ErrorWithMsg(tls, db, 1, func() uintptr { + Xsqlite3ErrorWithMsg(tls, db, SQLITE_ERROR, func() uintptr { if *(*uintptr)(unsafe.Pointer(bp + 432 /* zErr */)) != 0 { return ts + 2690 /* "%s" */ } return uintptr(0) }(), libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 432 /* zErr */)))) Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 432 /* zErr */))) - rc = 1 + rc = SQLITE_ERROR } - (*Parse)(unsafe.Pointer(bp + 8 /* &sParse */)).FeParseMode = U8(0) + (*Parse)(unsafe.Pointer(bp + 8 /* &sParse */)).FeParseMode = PARSE_MODE_NORMAL if (*Parse)(unsafe.Pointer(bp+8 /* &sParse */)).FpVdbe != 0 { Xsqlite3VdbeFinalize(tls, (*Parse)(unsafe.Pointer(bp+8 /* &sParse */)).FpVdbe) @@ -123577,7 +121440,7 @@ func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) int3 // // This call is a no-op if zTab is not a virtual table. func Xsqlite3VtabCallDestroy(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr) int32 { /* sqlite3.c:140457:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pTab uintptr pTab = Xsqlite3FindTable(tls, db, zTab, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) @@ -123587,7 +121450,7 @@ func Xsqlite3VtabCallDestroy(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr) for p = (*Table)(unsafe.Pointer(pTab)).FpVTable; p != 0; p = (*VTable)(unsafe.Pointer(p)).FpNext { if (*Sqlite3_vtab)(unsafe.Pointer((*VTable)(unsafe.Pointer(p)).FpVtab)).FnRef > 0 { - return 6 + return SQLITE_LOCKED } } p = vtabDisconnectAll(tls, db, pTab) @@ -123599,7 +121462,7 @@ func Xsqlite3VtabCallDestroy(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr) (*Table)(unsafe.Pointer(pTab)).FnTabRef++ rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&xDestroy)))(tls, (*VTable)(unsafe.Pointer(p)).FpVtab) // Remove the sqlite3_vtab* from the aVTrans[] array, if applicable - if rc == 0 { + if rc == SQLITE_OK { (*VTable)(unsafe.Pointer(p)).FpVtab = uintptr(0) (*Table)(unsafe.Pointer(pTab)).FpVTable = uintptr(0) @@ -123647,11 +121510,11 @@ func callFinaliser(tls *libc.TLS, db uintptr, offset int32) { /* sqlite3.c:14049 // If an error message is available, leave it in p->zErrMsg. func Xsqlite3VtabSync(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:140526:20: */ var i int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var aVTrans uintptr = (*Sqlite3)(unsafe.Pointer(db)).FaVTrans (*Sqlite3)(unsafe.Pointer(db)).FaVTrans = uintptr(0) - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans); i++ { var x uintptr var pVtab uintptr = (*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aVTrans + uintptr(i)*8)))).FpVtab if (pVtab != 0) && ((libc.AssignUintptr(&x, (*Sqlite3_module)(unsafe.Pointer((*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule)).FxSync)) != uintptr(0)) { @@ -123667,14 +121530,14 @@ func Xsqlite3VtabSync(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c // sqlite3.aVTrans array. Then clear the array itself. func Xsqlite3VtabRollback(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:140548:20: */ callFinaliser(tls, db, int32((uintptr(0) + 136 /* &.xRollback */))) - return 0 + return SQLITE_OK } // Invoke the xCommit method of all virtual tables in the // sqlite3.aVTrans array. Then clear the array itself. func Xsqlite3VtabCommit(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:140557:20: */ callFinaliser(tls, db, int32((uintptr(0) + 128 /* &.xCommit */))) - return 0 + return SQLITE_OK } // If the virtual table pVtab supports the transaction interface @@ -123684,7 +121547,7 @@ func Xsqlite3VtabCommit(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:140557:2 // If the xBegin call is successful, place the sqlite3_vtab pointer // in the sqlite3.aVTrans array. func Xsqlite3VtabBegin(tls *libc.TLS, db uintptr, pVTab uintptr) int32 { /* sqlite3.c:140570:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pModule uintptr // Special case: If db->aVTrans is NULL and db->nVTrans is greater @@ -123692,10 +121555,10 @@ func Xsqlite3VtabBegin(tls *libc.TLS, db uintptr, pVTab uintptr) int32 { /* sqli // virtual module xSync() callback. It is illegal to write to // virtual module tables in this case, so return SQLITE_LOCKED. if ((*Sqlite3)(unsafe.Pointer((db))).FnVTrans > 0) && ((*Sqlite3)(unsafe.Pointer((db))).FaVTrans == uintptr(0)) { - return 6 + return SQLITE_LOCKED } if !(pVTab != 0) { - return 0 + return SQLITE_OK } pModule = (*Sqlite3_vtab)(unsafe.Pointer((*VTable)(unsafe.Pointer(pVTab)).FpVtab)).FpModule @@ -123705,16 +121568,16 @@ func Xsqlite3VtabBegin(tls *libc.TLS, db uintptr, pVTab uintptr) int32 { /* sqli // If pVtab is already in the aVTrans array, return early for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans; i++ { if *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaVTrans + uintptr(i)*8)) == pVTab { - return 0 + return SQLITE_OK } } // Invoke the xBegin method. If successful, add the vtab to the // sqlite3.aVTrans[] array. rc = growVTrans(tls, db) - if rc == 0 { + if rc == SQLITE_OK { rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((pModule + 112 /* &.xBegin */))))(tls, (*VTable)(unsafe.Pointer(pVTab)).FpVtab) - if rc == 0 { + if rc == SQLITE_OK { var iSvpt int32 = ((*Sqlite3)(unsafe.Pointer(db)).FnStatement + (*Sqlite3)(unsafe.Pointer(db)).FnSavepoint) addToVTrans(tls, db, pVTab) if (iSvpt != 0) && ((*Sqlite3_module)(unsafe.Pointer(pModule)).FxSavepoint != 0) { @@ -123741,23 +121604,23 @@ func Xsqlite3VtabBegin(tls *libc.TLS, db uintptr, pVTab uintptr) int32 { /* sqli // function immediately. If all calls to virtual table methods are successful, // SQLITE_OK is returned. func Xsqlite3VtabSavepoint(tls *libc.TLS, db uintptr, op int32, iSavepoint int32) int32 { /* sqlite3.c:140630:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Sqlite3)(unsafe.Pointer(db)).FaVTrans != 0 { var i int32 - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans); i++ { var pVTab uintptr = *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaVTrans + uintptr(i)*8)) var pMod uintptr = (*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer(pVTab)).FpMod)).FpModule if ((*VTable)(unsafe.Pointer(pVTab)).FpVtab != 0) && ((*Sqlite3_module)(unsafe.Pointer(pMod)).FiVersion >= 2) { var xMethod uintptr Xsqlite3VtabLock(tls, pVTab) switch op { - case 0: + case SAVEPOINT_BEGIN: xMethod = (*Sqlite3_module)(unsafe.Pointer(pMod)).FxSavepoint (*VTable)(unsafe.Pointer(pVTab)).FiSavepoint = (iSavepoint + 1) break fallthrough - case 2: + case SAVEPOINT_ROLLBACK: xMethod = (*Sqlite3_module)(unsafe.Pointer(pMod)).FxRollbackTo break fallthrough @@ -123802,7 +121665,7 @@ func Xsqlite3VtabOverloadFunction(tls *libc.TLS, db uintptr, pDef uintptr, nArg if pExpr == uintptr(0) { return pDef } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 164 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN { return pDef } pTab = *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) @@ -123838,11 +121701,11 @@ func Xsqlite3VtabOverloadFunction(tls *libc.TLS, db uintptr, pDef uintptr, nArg return pDef } *(*FuncDef)(unsafe.Pointer(pNew)) = *(*FuncDef)(unsafe.Pointer(pDef)) - (*FuncDef)(unsafe.Pointer(pNew)).FzName = (pNew + uintptr(1)*72) - libc.Xmemcpy(tls, (pNew + uintptr(1)*72), (*FuncDef)(unsafe.Pointer(pDef)).FzName, (uint64(Xsqlite3Strlen30(tls, (*FuncDef)(unsafe.Pointer(pDef)).FzName) + 1))) + (*FuncDef)(unsafe.Pointer(pNew)).FzName = (pNew + 1*72) + libc.Xmemcpy(tls, (pNew + 1*72), (*FuncDef)(unsafe.Pointer(pDef)).FzName, (uint64(Xsqlite3Strlen30(tls, (*FuncDef)(unsafe.Pointer(pDef)).FzName) + 1))) (*FuncDef)(unsafe.Pointer(pNew)).FxSFunc = *(*uintptr)(unsafe.Pointer(bp /* xSFunc */)) (*FuncDef)(unsafe.Pointer(pNew)).FpUserData = *(*uintptr)(unsafe.Pointer(bp + 8 /* pArg */)) - *(*U32)(unsafe.Pointer(pNew + 4 /* &.funcFlags */)) |= (U32(0x0010)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.funcFlags */)) |= (SQLITE_FUNC_EPHEM) return pNew } @@ -123914,7 +121777,7 @@ func Xsqlite3VtabEponymousTableInit(tls *libc.TLS, pParse uintptr, pMod uintptr) } (*Module)(unsafe.Pointer(pMod)).FpEpoTab = pTab (*Table)(unsafe.Pointer(pTab)).FnTabRef = U32(1) - (*Table)(unsafe.Pointer(pTab)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FpSchema + (*Table)(unsafe.Pointer(pTab)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema (*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1) addModuleArgument(tls, pParse, pTab, Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pTab)).FzName)) @@ -123938,7 +121801,7 @@ func Xsqlite3VtabEponymousTableClear(tls *libc.TLS, db uintptr, pMod uintptr) { // Mark the table as Ephemeral prior to deleting it, so that the // sqlite3DeleteTable() routine will know that it is not stored in // the schema. - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0002)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (TF_Ephemeral) Xsqlite3DeleteTable(tls, db, pTab) (*Module)(unsafe.Pointer(pMod)).FpEpoTab = uintptr(0) } @@ -123955,7 +121818,7 @@ func Xsqlite3_vtab_on_conflict(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:1 } var aMap = [5]uint8{ - uint8(1), uint8(4), uint8(3), uint8(2), uint8(5), + SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE, } /* sqlite3.c:140837:30 */ // Call from within the xCreate() or xConnect() methods to provide @@ -123964,7 +121827,7 @@ var aMap = [5]uint8{ func Xsqlite3_vtab_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 { /* sqlite3.c:140854:16: */ var ap Va_list _ = ap - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -123975,23 +121838,23 @@ func Xsqlite3_vtab_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 ap = va switch op { - case 1: + case SQLITE_VTAB_CONSTRAINT_SUPPORT: { (*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FbConstraint = U8(libc.VaInt32(&ap)) break } fallthrough - case 2: + case SQLITE_VTAB_INNOCUOUS: { - (*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FeVtabRisk = U8(0) + (*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FeVtabRisk = SQLITE_VTABRISK_Low break } fallthrough - case 3: + case SQLITE_VTAB_DIRECTONLY: { - (*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FeVtabRisk = U8(2) + (*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FeVtabRisk = SQLITE_VTABRISK_High break } @@ -124006,7 +121869,7 @@ func Xsqlite3_vtab_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 _ = ap } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3Error(tls, db, rc) } Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -124429,7 +122292,7 @@ func explainIndexRange(tls *libc.TLS, pStr uintptr, pLoop uintptr) { /* sqlite3. var i int32 var j int32 - if (int32(nEq) == 0) && (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(0x00000020 | 0x00000010))) == U32(0)) { + if (int32(nEq) == 0) && (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(WHERE_BTM_LIMIT | WHERE_TOP_LIMIT))) == U32(0)) { return } Xsqlite3_str_append(tls, pStr, ts+18863 /* " (" */, 2) @@ -124447,11 +122310,11 @@ func explainIndexRange(tls *libc.TLS, pStr uintptr, pLoop uintptr) { /* sqlite3. } j = i - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000020)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_BTM_LIMIT) != 0 { explainAppendTerm(tls, pStr, pIndex, int32(*(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 2 /* &.nBtm */))), j, i, ts+18879 /* ">" */) i = 1 } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000010)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_TOP_LIMIT) != 0 { explainAppendTerm(tls, pStr, pIndex, int32(*(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 4 /* &.nTop */))), j, i, ts+18881 /* "<" */) } Xsqlite3_str_append(tls, pStr, ts+3907 /* ")" */, 1) @@ -124489,15 +122352,15 @@ func Xsqlite3WhereExplainOneScan(tls *libc.TLS, pParse uintptr, pTabList uintptr pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop flags = (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags - if ((flags & U32(0x00002000)) != 0) || ((int32(wctrlFlags) & 0x0020) != 0) { + if ((flags & WHERE_MULTI_OR) != 0) || ((int32(wctrlFlags) & WHERE_OR_SUBCLAUSE) != 0) { return 0 } - isSearch = (libc.Bool32((((flags & (U32(0x00000020 | 0x00000010))) != U32(0)) || - (((flags & U32(0x00000400)) == U32(0)) && (int32(*(*U16)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.btree */) /* &.nEq */))) > 0))) || - ((int32(wctrlFlags) & (0x0001 | 0x0002)) != 0))) + isSearch = (libc.Bool32((((flags & (U32(WHERE_BTM_LIMIT | WHERE_TOP_LIMIT))) != U32(0)) || + (((flags & WHERE_VIRTUALTABLE) == U32(0)) && (int32(*(*U16)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.btree */) /* &.nEq */))) > 0))) || + ((int32(wctrlFlags) & (WHERE_ORDERBY_MIN | WHERE_ORDERBY_MAX)) != 0))) - Xsqlite3StrAccumInit(tls, bp+56 /* &str */, db, bp+88 /* &zBuf[0] */, int32(unsafe.Sizeof([100]int8{})), 1000000000) + Xsqlite3StrAccumInit(tls, bp+56 /* &str */, db, bp+88 /* &zBuf[0] */, int32(unsafe.Sizeof([100]int8{})), SQLITE_MAX_LENGTH) Xsqlite3_str_appendall(tls, bp+56 /* &str */, func() uintptr { if isSearch != 0 { return ts + 18883 /* "SEARCH" */ @@ -124513,21 +122376,21 @@ func Xsqlite3WhereExplainOneScan(tls *libc.TLS, pParse uintptr, pTabList uintptr if (*SrcList_item)(unsafe.Pointer(pItem)).FzAlias != 0 { Xsqlite3_str_appendf(tls, bp+56 /* &str */, ts+18918 /* " AS %s" */, libc.VaList(bp+16, (*SrcList_item)(unsafe.Pointer(pItem)).FzAlias)) } - if (flags & (U32(0x00000100 | 0x00000400))) == U32(0) { + if (flags & (U32(WHERE_IPK | WHERE_VIRTUALTABLE))) == U32(0) { var zFmt uintptr = uintptr(0) var pIdx uintptr pIdx = *(*uintptr)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) - if !(((*Table)(unsafe.Pointer(((*SrcList_item)(unsafe.Pointer(pItem)).FpTab))).FtabFlags & U32(0x0080)) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2) { + if !(((*Table)(unsafe.Pointer(((*SrcList_item)(unsafe.Pointer(pItem)).FpTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY) { if isSearch != 0 { zFmt = ts + 18925 /* "PRIMARY KEY" */ } - } else if (flags & U32(0x00020000)) != 0 { + } else if (flags & WHERE_PARTIALIDX) != 0 { zFmt = ts + 18937 /* "AUTOMATIC PARTIA..." */ - } else if (flags & U32(0x00004000)) != 0 { + } else if (flags & WHERE_AUTO_INDEX) != 0 { zFmt = ts + 18970 /* "AUTOMATIC COVERI..." */ - } else if (flags & U32(0x00000040)) != 0 { + } else if (flags & WHERE_IDX_ONLY) != 0 { zFmt = ts + 18995 /* "COVERING INDEX %..." */ } else { zFmt = ts + 19013 /* "INDEX %s" */ @@ -124537,13 +122400,13 @@ func Xsqlite3WhereExplainOneScan(tls *libc.TLS, pParse uintptr, pTabList uintptr Xsqlite3_str_appendf(tls, bp+56 /* &str */, zFmt, libc.VaList(bp+24, (*Index)(unsafe.Pointer(pIdx)).FzName)) explainIndexRange(tls, bp+56 /* &str */, pLoop) } - } else if ((flags & U32(0x00000100)) != U32(0)) && ((flags & U32(0x0000000f)) != U32(0)) { + } else if ((flags & WHERE_IPK) != U32(0)) && ((flags & WHERE_CONSTRAINT) != U32(0)) { var zRangeOp uintptr - if (flags & (U32(0x00000001 | 0x00000004))) != 0 { + if (flags & (U32(WHERE_COLUMN_EQ | WHERE_COLUMN_IN))) != 0 { zRangeOp = ts + 19030 /* "=" */ - } else if (flags & U32(0x00000030)) == U32(0x00000030) { + } else if (flags & WHERE_BOTH_LIMIT) == WHERE_BOTH_LIMIT { zRangeOp = ts + 19032 /* ">? AND rowid<" */ - } else if (flags & U32(0x00000020)) != 0 { + } else if (flags & WHERE_BTM_LIMIT) != 0 { zRangeOp = ts + 18879 /* ">" */ } else { @@ -124551,13 +122414,13 @@ func Xsqlite3WhereExplainOneScan(tls *libc.TLS, pParse uintptr, pTabList uintptr } Xsqlite3_str_appendf(tls, bp+56, /* &str */ ts+19046 /* " USING INTEGER P..." */, libc.VaList(bp+32, zRangeOp)) - } else if (flags & U32(0x00000400)) != U32(0) { + } else if (flags & WHERE_VIRTUALTABLE) != U32(0) { Xsqlite3_str_appendf(tls, bp+56 /* &str */, ts+19084, /* " VIRTUAL TABLE I..." */ libc.VaList(bp+40, *(*int32)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.vtab */ /* &.idxNum */)), *(*uintptr)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.vtab */ + 8 /* &.idxStr */)))) } zMsg = Xsqlite3StrAccumFinish(tls, bp+56 /* &str */) - ret = Xsqlite3VdbeAddOp4(tls, v, 174, Xsqlite3VdbeCurrentAddr(tls, v), + ret = Xsqlite3VdbeAddOp4(tls, v, OP_Explain, Xsqlite3VdbeCurrentAddr(tls, v), (*Parse)(unsafe.Pointer(pParse)).FaddrExplain, 0, zMsg, -7) } return ret @@ -124606,13 +122469,13 @@ func Xsqlite3WhereExplainOneScan(tls *libc.TLS, pParse uintptr, pTabList uintptr func disableTerm(tls *libc.TLS, pLevel uintptr, pTerm uintptr) { /* sqlite3.c:141818:13: */ var nLoop int32 = 0 - for (((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0004) == 0) && - (((*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin == 0) || (((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000001))) != U32(0)))) && + for (((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_CODED) == 0) && + (((*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin == 0) || (((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_FromJoin)) != U32(0)))) && (((*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady & (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll) == uint64(0)) { - if (nLoop != 0) && ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0400) != 0) { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0200)) + if (nLoop != 0) && ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_LIKE) != 0) { + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_LIKECOND)) } else { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) } if (*WhereTerm)(unsafe.Pointer(pTerm)).FiParent < 0 { break @@ -124646,18 +122509,18 @@ func codeApplyAffinity(tls *libc.TLS, pParse uintptr, base int32, n int32, zAff // Adjust base and n to skip over SQLITE_AFF_BLOB and SQLITE_AFF_NONE // entries at the beginning and end of the affinity string. - for (n > 0) && (int32(*(*int8)(unsafe.Pointer(zAff + uintptr(0)))) <= 0x41) { + for (n > 0) && (int32(*(*int8)(unsafe.Pointer(zAff))) <= SQLITE_AFF_BLOB) { n-- base++ zAff++ } - for (n > 1) && (int32(*(*int8)(unsafe.Pointer(zAff + uintptr((n - 1))))) <= 0x41) { + for (n > 1) && (int32(*(*int8)(unsafe.Pointer(zAff + uintptr((n - 1))))) <= SQLITE_AFF_BLOB) { n-- } // Code the OP_Affinity opcode if there is anything left to do. if n > 0 { - Xsqlite3VdbeAddOp4(tls, v, 90, base, n, 0, zAff, n) + Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, base, n, 0, zAff, n) } } @@ -124673,9 +122536,9 @@ func updateRangeAffinityStr(tls *libc.TLS, pRight uintptr, n int32, zAff uintptr var i int32 for i = 0; i < n; i++ { var p uintptr = Xsqlite3VectorFieldSubexpr(tls, pRight, i) - if (int32(Xsqlite3CompareAffinity(tls, p, *(*int8)(unsafe.Pointer(zAff + uintptr(i))))) == 0x41) || + if (int32(Xsqlite3CompareAffinity(tls, p, *(*int8)(unsafe.Pointer(zAff + uintptr(i))))) == SQLITE_AFF_BLOB) || (Xsqlite3ExprNeedsNoAffinityChange(tls, p, *(*int8)(unsafe.Pointer(zAff + uintptr(i)))) != 0) { - *(*int8)(unsafe.Pointer(zAff + uintptr(i))) = int8(0x41) + *(*int8)(unsafe.Pointer(zAff + uintptr(i))) = SQLITE_AFF_BLOB } } } @@ -124740,8 +122603,8 @@ func removeUnindexableInClauseTerms(tls *libc.TLS, pParse uintptr, iEq int32, pL // Take care here not to generate a TK_VECTOR containing only a // single value. Since the parser never creates such a vector, some // of the subroutines do not handle this case. - var p uintptr = (*ExprList_item)(unsafe.Pointer((pLhs + 8 /* &.a */) + uintptr(0)*32)).FpExpr - (*ExprList_item)(unsafe.Pointer((pLhs + 8 /* &.a */) + uintptr(0)*32)).FpExpr = uintptr(0) + var p uintptr = (*ExprList_item)(unsafe.Pointer((pLhs + 8 /* &.a */))).FpExpr + (*ExprList_item)(unsafe.Pointer((pLhs + 8 /* &.a */))).FpExpr = uintptr(0) Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer(pNew)).FpLeft) (*Expr)(unsafe.Pointer(pNew)).FpLeft = p } @@ -124785,13 +122648,13 @@ func codeEqualityTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintp var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe var iReg int32 // Register holding results - if (int32((*Expr)(unsafe.Pointer(pX)).Fop) == 53) || (int32((*Expr)(unsafe.Pointer(pX)).Fop) == 45) { + if (int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_EQ) || (int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_IS) { iReg = Xsqlite3ExprCodeTarget(tls, pParse, (*Expr)(unsafe.Pointer(pX)).FpRight, iTarget) - } else if int32((*Expr)(unsafe.Pointer(pX)).Fop) == 50 { + } else if int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_ISNULL { iReg = iTarget - Xsqlite3VdbeAddOp2(tls, v, 72, 0, iReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, iReg) } else { - var eType int32 = 5 + var eType int32 = IN_INDEX_NOOP // var iTab int32 at bp, 4 var pIn uintptr @@ -124800,7 +122663,7 @@ func codeEqualityTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintp var nEq int32 = 0 var aiMap uintptr = uintptr(0) - if ((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000400)) == U32(0)) && + if ((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_VIRTUALTABLE) == U32(0)) && (*(*uintptr)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.btree */) + 8 /* &.pIndex */)) != uintptr(0))) && (*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.btree */) + 8 /* &.pIndex */)))).FaSortOrder + uintptr(iEq))) != 0) { @@ -124823,33 +122686,33 @@ func codeEqualityTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintp } *(*int32)(unsafe.Pointer(bp /* iTab */)) = 0 - if (((*Expr)(unsafe.Pointer(pX)).Fflags & U32(0x000800)) == U32(0)) || ((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32 /* &.x */)))).FpEList)).FnExpr == 1) { - eType = Xsqlite3FindInIndex(tls, pParse, pX, uint32(0x0004), uintptr(0), uintptr(0), bp /* &iTab */) + if (((*Expr)(unsafe.Pointer(pX)).Fflags & EP_xIsSelect) == U32(0)) || ((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32 /* &.x */)))).FpEList)).FnExpr == 1) { + eType = Xsqlite3FindInIndex(tls, pParse, pX, IN_INDEX_LOOP, uintptr(0), uintptr(0), bp /* &iTab */) } else { var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb pX = removeUnindexableInClauseTerms(tls, pParse, iEq, pLoop, pX) if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) { aiMap = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (uint64(uint64(unsafe.Sizeof(int32(0))) * uint64(nEq)))) - eType = Xsqlite3FindInIndex(tls, pParse, pX, uint32(0x0004), uintptr(0), aiMap, bp /* &iTab */) + eType = Xsqlite3FindInIndex(tls, pParse, pX, IN_INDEX_LOOP, uintptr(0), aiMap, bp /* &iTab */) (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FiTable = *(*int32)(unsafe.Pointer(bp /* iTab */)) } Xsqlite3ExprDelete(tls, db, pX) pX = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr } - if eType == 4 { + if eType == IN_INDEX_INDEX_DESC { bRev = libc.BoolInt32(!(bRev != 0)) } Xsqlite3VdbeAddOp2(tls, v, func() int32 { if bRev != 0 { - return 33 + return OP_Last } - return 37 + return OP_Rewind }(), *(*int32)(unsafe.Pointer(bp /* iTab */)), 0) - *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (U32(0x00000800)) + *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (WHERE_IN_ABLE) if *(*int32)(unsafe.Pointer((pLevel + 56 /* &.u */ /* &.in */) /* &.nIn */)) == 0 { (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt = Xsqlite3VdbeMakeLabel(tls, pParse) } @@ -124865,8 +122728,8 @@ func codeEqualityTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintp for i = iEq; i < int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm); i++ { if (*WhereTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*8)))).FpExpr == pX { var iOut int32 = ((iReg + i) - iEq) - if eType == 1 { - *(*int32)(unsafe.Pointer(pIn + 4 /* &.addrInTop */)) = Xsqlite3VdbeAddOp2(tls, v, 127, *(*int32)(unsafe.Pointer(bp /* iTab */)), iOut) + if eType == IN_INDEX_ROWID { + *(*int32)(unsafe.Pointer(pIn + 4 /* &.addrInTop */)) = Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, *(*int32)(unsafe.Pointer(bp /* iTab */)), iOut) } else { var iCol int32 if aiMap != 0 { @@ -124874,26 +122737,26 @@ func codeEqualityTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintp } else { iCol = 0 } - *(*int32)(unsafe.Pointer(pIn + 4 /* &.addrInTop */)) = Xsqlite3VdbeAddOp3(tls, v, 89, *(*int32)(unsafe.Pointer(bp /* iTab */)), iCol, iOut) + *(*int32)(unsafe.Pointer(pIn + 4 /* &.addrInTop */)) = Xsqlite3VdbeAddOp3(tls, v, OP_Column, *(*int32)(unsafe.Pointer(bp /* iTab */)), iCol, iOut) } - Xsqlite3VdbeAddOp1(tls, v, 50, iOut) + Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, iOut) if i == iEq { *(*int32)(unsafe.Pointer(pIn /* &.iCur */)) = *(*int32)(unsafe.Pointer(bp /* iTab */)) *(*U8)(unsafe.Pointer(pIn + 16 /* &.eEndLoopOp */)) = func() uint8 { if bRev != 0 { - return uint8(4) + return OP_Prev } - return uint8(5) + return OP_Next }() if iEq > 0 { *(*int32)(unsafe.Pointer(pIn + 8 /* &.iBase */)) = (iReg - i) *(*int32)(unsafe.Pointer(pIn + 12 /* &.nPrefix */)) = i - *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (U32(0x00040000)) + *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (WHERE_IN_EARLYOUT) } else { *(*int32)(unsafe.Pointer(pIn + 12 /* &.nPrefix */)) = 0 } } else { - *(*U8)(unsafe.Pointer(pIn + 16 /* &.eEndLoopOp */)) = U8(173) + *(*U8)(unsafe.Pointer(pIn + 16 /* &.eEndLoopOp */)) = OP_Noop } pIn += 20 } @@ -124980,23 +122843,23 @@ func codeAllEqualityTerms(tls *libc.TLS, pParse uintptr, pLevel uintptr, bRev in var iIdxCur int32 = (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur Xsqlite3VdbeAddOp1(tls, v, func() int32 { if bRev != 0 { - return 33 + return OP_Last } - return 37 + return OP_Rewind }(), iIdxCur) - j = Xsqlite3VdbeAddOp0(tls, v, 11) + j = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip = Xsqlite3VdbeAddOp4Int(tls, v, func() int32 { if bRev != 0 { - return 22 + return OP_SeekLT } - return 25 + return OP_SeekGT }(), iIdxCur, 0, regBase, int32(nSkip)) Xsqlite3VdbeJumpHere(tls, v, j) for j = 0; j < int32(nSkip); j++ { - Xsqlite3VdbeAddOp3(tls, v, 89, iIdxCur, j, (regBase + j)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, j, (regBase + j)) } } @@ -125016,31 +122879,31 @@ func codeAllEqualityTerms(tls *libc.TLS, pParse uintptr, pLevel uintptr, bRev in Xsqlite3ReleaseTempReg(tls, pParse, regBase) regBase = r1 } else { - Xsqlite3VdbeAddOp2(tls, v, 78, r1, (regBase + j)) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, r1, (regBase + j)) } } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0001) != 0 { - if ((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags & U32(0x000800)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_IN) != 0 { + if ((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags & EP_xIsSelect) != 0 { // No affinity ever needs to be (or should be) applied to a value // from the RHS of an "? IN (SELECT ...)" expression. The // sqlite3FindInIndex() routine has already ensured that the // affinity of the comparison has been applied to the value. if zAff != 0 { - *(*int8)(unsafe.Pointer(zAff + uintptr(j))) = int8(0x41) + *(*int8)(unsafe.Pointer(zAff + uintptr(j))) = SQLITE_AFF_BLOB } } - } else if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0100) == 0 { + } else if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_ISNULL) == 0 { var pRight uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight - if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0800) == 0) && (Xsqlite3ExprCanBeNull(tls, pRight) != 0) { - Xsqlite3VdbeAddOp2(tls, v, 50, (regBase + j), (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk) + if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_IS) == 0) && (Xsqlite3ExprCanBeNull(tls, pRight) != 0) { + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (regBase + j), (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk) } if zAff != 0 { - if int32(Xsqlite3CompareAffinity(tls, pRight, *(*int8)(unsafe.Pointer(zAff + uintptr(j))))) == 0x41 { - *(*int8)(unsafe.Pointer(zAff + uintptr(j))) = int8(0x41) + if int32(Xsqlite3CompareAffinity(tls, pRight, *(*int8)(unsafe.Pointer(zAff + uintptr(j))))) == SQLITE_AFF_BLOB { + *(*int8)(unsafe.Pointer(zAff + uintptr(j))) = SQLITE_AFF_BLOB } if Xsqlite3ExprNeedsNoAffinityChange(tls, pRight, *(*int8)(unsafe.Pointer(zAff + uintptr(j)))) != 0 { - *(*int8)(unsafe.Pointer(zAff + uintptr(j))) = int8(0x41) + *(*int8)(unsafe.Pointer(zAff + uintptr(j))) = SQLITE_AFF_BLOB } } } @@ -125070,8 +122933,8 @@ func codeDeferredSeek(tls *libc.TLS, pWInfo uintptr, pIdx uintptr, iCur int32, i var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe // Vdbe to generate code within libc.SetBitFieldPtr8Uint32(pWInfo+68 /* &.bDeferredSeek */, uint32(1), 0, 0x1) - Xsqlite3VdbeAddOp3(tls, v, 133, iIdxCur, 0, iCur) - if ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0020) != 0) && + Xsqlite3VdbeAddOp3(tls, v, OP_DeferredSeek, iIdxCur, 0, iCur) + if ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_OR_SUBCLAUSE) != 0) && (((*Parse)(unsafe.Pointer(func() uintptr { if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 { return (*Parse)(unsafe.Pointer(pParse)).FpToplevel @@ -125082,7 +122945,7 @@ func codeDeferredSeek(tls *libc.TLS, pWInfo uintptr, pIdx uintptr, iCur int32, i var pTab uintptr = (*Index)(unsafe.Pointer(pIdx)).FpTable var ai uintptr = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (uint64(uint64(unsafe.Sizeof(U32(0))) * (uint64(int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 1))))) if ai != 0 { - *(*U32)(unsafe.Pointer(ai + uintptr(0)*4)) = U32((*Table)(unsafe.Pointer(pTab)).FnCol) + *(*U32)(unsafe.Pointer(ai)) = U32((*Table)(unsafe.Pointer(pTab)).FnCol) for i = 0; i < (int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) - 1); i++ { var x1 int32 var x2 int32 @@ -125109,12 +122972,12 @@ func codeDeferredSeek(tls *libc.TLS, pWInfo uintptr, pIdx uintptr, iCur int32, i func codeExprOrVector(tls *libc.TLS, pParse uintptr, p uintptr, iReg int32, nReg int32) { /* sqlite3.c:142602:13: */ if (p != 0) && (Xsqlite3ExprIsVector(tls, p) != 0) { - if ((*Expr)(unsafe.Pointer(p)).Fflags & U32(0x000800)) != 0 { + if ((*Expr)(unsafe.Pointer(p)).Fflags & EP_xIsSelect) != 0 { var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe var iSelect int32 iSelect = Xsqlite3CodeSubselect(tls, pParse, p) - Xsqlite3VdbeAddOp3(tls, v, 77, iSelect, iReg, (nReg - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, iSelect, iReg, (nReg - 1)) } else { var i int32 var pList uintptr = *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) @@ -125157,15 +123020,15 @@ func whereIndexExprTransNode(tls *libc.TLS, p uintptr, pExpr uintptr) int32 { /* if Xsqlite3ExprCompare(tls, uintptr(0), pExpr, (*IdxExprTrans)(unsafe.Pointer(pX)).FpIdxExpr, (*IdxExprTrans)(unsafe.Pointer(pX)).FiTabCur) == 0 { preserveExpr(tls, pX, pExpr) (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = Xsqlite3ExprAffinity(tls, pExpr) - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(164) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_COLUMN (*Expr)(unsafe.Pointer(pExpr)).FiTable = (*IdxExprTrans)(unsafe.Pointer(pX)).FiIdxCur (*Expr)(unsafe.Pointer(pExpr)).FiColumn = YnVar((*IdxExprTrans)(unsafe.Pointer(pX)).FiIdxCol) *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = uintptr(0) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (^libc.Uint32FromInt32((0x001000 | 0x040000))) - return 1 + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32((EP_Skip | EP_Unlikely)))) + return WRC_Prune } else { - return 0 + return WRC_Continue } return int32(0) } @@ -125173,7 +123036,7 @@ func whereIndexExprTransNode(tls *libc.TLS, p uintptr, pExpr uintptr) int32 { /* // A walker node callback that translates a column reference to a table // into a corresponding column reference of an index. func whereIndexExprTransColumn(tls *libc.TLS, p uintptr, pExpr uintptr) int32 { /* sqlite3.c:142683:12: */ - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN { var pX uintptr = *(*uintptr)(unsafe.Pointer(p + 40 /* &.u */)) if ((*Expr)(unsafe.Pointer(pExpr)).FiTable == (*IdxExprTrans)(unsafe.Pointer(pX)).FiTabCur) && (int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) == (*IdxExprTrans)(unsafe.Pointer(pX)).FiTabCol) { @@ -125184,7 +123047,7 @@ func whereIndexExprTransColumn(tls *libc.TLS, p uintptr, pExpr uintptr) int32 { *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = uintptr(0) } } - return 0 + return WRC_Continue } // For an indexes on expression X, locate every instance of expression X @@ -125230,7 +123093,7 @@ func whereIndexExprTrans(tls *libc.TLS, pIdx uintptr, iTabCur int32, iIdxCur int f func(*libc.TLS, uintptr, uintptr) int32 }{whereIndexExprTransNode})) } else if ((int32(iRef) >= 0) && - ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iRef)*32)).FcolFlags) & 0x0020) != 0)) && + ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iRef)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0)) && (((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iRef)*32)).FzColl == uintptr(0)) || (Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iRef)*32)).FzColl, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))) == 0)) { // Check to see if there are direct references to generated columns @@ -125261,7 +123124,7 @@ func whereIndexExprTrans(tls *libc.TLS, pIdx uintptr, iTabCur int32, iIdxCur int func whereApplyPartialIndexConstraints(tls *libc.TLS, pTruth uintptr, iTabCur int32, pWC uintptr) { /* sqlite3.c:142771:13: */ var i int32 var pTerm uintptr - for int32((*Expr)(unsafe.Pointer(pTruth)).Fop) == 44 { + for int32((*Expr)(unsafe.Pointer(pTruth)).Fop) == TK_AND { whereApplyPartialIndexConstraints(tls, (*Expr)(unsafe.Pointer(pTruth)).FpLeft, iTabCur, pWC) pTruth = (*Expr)(unsafe.Pointer(pTruth)).FpRight } @@ -125273,12 +123136,12 @@ __1: } { var pExpr uintptr - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0004) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_CODED) != 0 { goto __2 } pExpr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr if Xsqlite3ExprCompare(tls, uintptr(0), pExpr, pTruth, iTabCur) == 0 { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) } } @@ -125339,9 +123202,9 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // initialize a memory cell that records if this table matches any // row of the left table of the join. - if (int32((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom) > 0) && ((int32((*SrcList_item)(unsafe.Pointer(pTabItem+uintptr(0)*112)).Ffg.Fjointype) & 0x0008) != 0) { + if (int32((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom) > 0) && ((int32((*SrcList_item)(unsafe.Pointer(pTabItem)).Ffg.Fjointype) & JT_LEFT) != 0) { (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) } @@ -125354,11 +123217,11 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // Special case of a FROM clause subquery implemented as a co-routine if (uint32(int32(*(*uint8)(unsafe.Pointer(pTabItem + 60 /* &.fg */ + 4 /* &.viaCoroutine */)) & 0x10 >> 4))) != 0 { var regYield int32 = (*SrcList_item)(unsafe.Pointer(pTabItem)).FregReturn - Xsqlite3VdbeAddOp3(tls, v, 13, regYield, 0, (*SrcList_item)(unsafe.Pointer(pTabItem)).FaddrFillSub) - (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = Xsqlite3VdbeAddOp2(tls, v, 14, regYield, addrBrk) + Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regYield, 0, (*SrcList_item)(unsafe.Pointer(pTabItem)).FaddrFillSub) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regYield, addrBrk) - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(11) - } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000400)) != U32(0) { + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Goto + } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_VIRTUALTABLE) != U32(0) { // Case 1: The table is a virtual-table. Use the VFilter and VNext // to access the data. var iReg int32 // P3 Value for OP_VFilter @@ -125374,7 +123237,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI if pTerm == uintptr(0) { continue } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0001) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_IN) != 0 { codeEqualityTerm(tls, pParse, pTerm, pLevel, j, bRev, iTarget) addrNotFound = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt } else { @@ -125382,9 +123245,9 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI codeExprOrVector(tls, pParse, pRight, iTarget, 1) } } - Xsqlite3VdbeAddOp2(tls, v, 69, *(*int32)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.vtab */ /* &.idxNum */)), iReg) - Xsqlite3VdbeAddOp2(tls, v, 69, nConstraint, (iReg + 1)) - Xsqlite3VdbeAddOp4(tls, v, 9, iCur, addrNotFound, iReg, + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, *(*int32)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.vtab */ /* &.idxNum */)), iReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, nConstraint, (iReg + 1)) + Xsqlite3VdbeAddOp4(tls, v, OP_VFilter, iCur, addrNotFound, iReg, *(*uintptr)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.vtab */ + 8 /* &.idxStr */)), func() int32 { if *(*U8)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.vtab */ + 4 /* &.needFree */)) != 0 { @@ -125397,20 +123260,20 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = func() uint8 { if (*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass != 0 { - return uint8(173) + return OP_Noop } - return uint8(61) + return OP_VNext }() (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = Xsqlite3VdbeCurrentAddr(tls, v) iIn = *(*int32)(unsafe.Pointer(pLevel + 56 /* &.u */ /* &.in */ /* &.nIn */)) for j = (nConstraint - 1); j >= 0; j-- { pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*8)) - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0001) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_IN) != 0 { iIn-- } if (j < 16) && (((int32(*(*U16)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.vtab */) + 6 /* &.omitMask */))) >> j) & 1) != 0) { disableTerm(tls, pLevel, pTerm) - } else if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0001) != 0) && + } else if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_IN) != 0) && (Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft) == 1) { var pCompare uintptr // The comparison operator var pRight uintptr // RHS of the comparison @@ -125430,15 +123293,15 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // Generate code that will continue to the next row if // the IN constraint is not satisfied - pCompare = Xsqlite3PExpr(tls, pParse, 53, uintptr(0), uintptr(0)) + pCompare = Xsqlite3PExpr(tls, pParse, TK_EQ, uintptr(0), uintptr(0)) if pCompare != 0 { (*Expr)(unsafe.Pointer(pCompare)).FpLeft = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft - (*Expr)(unsafe.Pointer(pCompare)).FpRight = libc.AssignUintptr(&pRight, Xsqlite3Expr(tls, db, 173, uintptr(0))) + (*Expr)(unsafe.Pointer(pCompare)).FpRight = libc.AssignUintptr(&pRight, Xsqlite3Expr(tls, db, TK_REGISTER, uintptr(0))) if pRight != 0 { (*Expr)(unsafe.Pointer(pRight)).FiTable = ((iReg + j) + 2) Xsqlite3ExprIfFalse(tls, - pParse, pCompare, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont, 0x10) + pParse, pCompare, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont, SQLITE_JUMPIFNULL) } (*Expr)(unsafe.Pointer(pCompare)).FpLeft = uintptr(0) Xsqlite3ExprDelete(tls, db, pCompare) @@ -125452,14 +123315,14 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // simpler and safer to simply not reuse the registers. // // sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2); - } else if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000100)) != U32(0)) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(0x00000004 | 0x00000001))) != U32(0)) { + } else if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IPK) != U32(0)) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(WHERE_COLUMN_IN | WHERE_COLUMN_EQ))) != U32(0)) { // Case 2: We can directly reference a single row using an // equality comparison against the ROWID field. Or // we reference multiple rows using a "rowid IN (...)" // construct. - pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(0)*8)) + pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) iReleaseReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) iRowidReg = codeEqualityTerm(tls, pParse, pTerm, pLevel, 0, bRev, iReleaseReg) @@ -125467,16 +123330,16 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI Xsqlite3ReleaseTempReg(tls, pParse, iReleaseReg) } addrNxt = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt - Xsqlite3VdbeAddOp3(tls, v, 31, iCur, addrNxt, iRowidReg) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, iCur, addrNxt, iRowidReg) - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(173) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Noop if ((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & (*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady) == uint64(0) { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) } - } else if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000100)) != U32(0)) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000002)) != U32(0)) { + } else if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IPK) != U32(0)) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_COLUMN_RANGE) != U32(0)) { // Case 3: We have an inequality comparison against the ROWID field. - var testOp int32 = 173 + var testOp int32 = OP_Noop var start int32 var memEndValue int32 = 0 var pStart uintptr @@ -125484,10 +123347,10 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI j = 0 pStart = libc.AssignUintptr(&pEnd, uintptr(0)) - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000020)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_BTM_LIMIT) != 0 { pStart = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&j, 1))*8)) } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000010)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_TOP_LIMIT) != 0 { pEnd = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&j, 1))*8)) } @@ -125507,10 +123370,10 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // The following constant maps TK_xx codes into corresponding // seek opcodes. It depends on a particular ordering of TK_xx *(*[4]U8)(unsafe.Pointer(bp + 8 /* aMoveOp */)) = [4]U8{ - /* TK_GT */ U8(25), - /* TK_LE */ U8(23), - /* TK_LT */ U8(22), - /* TK_GE */ U8(24), + /* TK_GT */ OP_SeekGT, + /* TK_LE */ OP_SeekLE, + /* TK_LT */ OP_SeekLT, + /* TK_GE */ OP_SeekGE, } // Make sure the ordering.. // ... of the TK_xx values... @@ -125523,12 +123386,12 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI r1 = libc.AssignPtrInt32(bp+12 /* rTemp */, Xsqlite3GetTempReg(tls, pParse)) codeExprOrVector(tls, pParse, (*Expr)(unsafe.Pointer(pX)).FpRight, r1, 1) - op = int32(*(*U8)(unsafe.Pointer(bp + 8 /* &aMoveOp[0] */ + uintptr(((((int32((*Expr)(unsafe.Pointer(pX)).Fop) - 54) - 1) & 0x3) | 0x1))))) + op = int32(*(*U8)(unsafe.Pointer(bp + 8 /* &aMoveOp[0] */ + uintptr(((((int32((*Expr)(unsafe.Pointer(pX)).Fop) - TK_GT) - 1) & 0x3) | 0x1))))) } else { r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pX)).FpRight, bp+12 /* &rTemp */) disableTerm(tls, pLevel, pStart) - op = int32(*(*U8)(unsafe.Pointer(bp + 8 /* &aMoveOp[0] */ + uintptr((int32((*Expr)(unsafe.Pointer(pX)).Fop) - 54))))) + op = int32(*(*U8)(unsafe.Pointer(bp + 8 /* &aMoveOp[0] */ + uintptr((int32((*Expr)(unsafe.Pointer(pX)).Fop) - TK_GT))))) } Xsqlite3VdbeAddOp3(tls, v, op, iCur, addrBrk, r1) @@ -125536,9 +123399,9 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI } else { Xsqlite3VdbeAddOp2(tls, v, func() int32 { if bRev != 0 { - return 33 + return OP_Last } - return 37 + return OP_Rewind }(), iCur, addrHalt) } @@ -125551,17 +123414,17 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI memEndValue = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) codeExprOrVector(tls, pParse, (*Expr)(unsafe.Pointer(pX)).FpRight, memEndValue, 1) if (0 == Xsqlite3ExprIsVector(tls, (*Expr)(unsafe.Pointer(pX)).FpRight)) && - ((int32((*Expr)(unsafe.Pointer(pX)).Fop) == 56) || (int32((*Expr)(unsafe.Pointer(pX)).Fop) == 54)) { + ((int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_LT) || (int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_GT)) { if bRev != 0 { - testOp = 55 + testOp = OP_Le } else { - testOp = 57 + testOp = OP_Ge } } else { if bRev != 0 { - testOp = 56 + testOp = OP_Lt } else { - testOp = 54 + testOp = OP_Gt } } if 0 == Xsqlite3ExprIsVector(tls, (*Expr)(unsafe.Pointer(pX)).FpRight) { @@ -125571,21 +123434,21 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI start = Xsqlite3VdbeCurrentAddr(tls, v) (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = func() uint8 { if bRev != 0 { - return uint8(4) + return OP_Prev } - return uint8(5) + return OP_Next }() (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = start - if testOp != 173 { + if testOp != OP_Noop { iRowidReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 127, iCur, iRowidReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iCur, iRowidReg) Xsqlite3VdbeAddOp3(tls, v, testOp, memEndValue, addrBrk, iRowidReg) - Xsqlite3VdbeChangeP5(tls, v, (uint16(0x43 | 0x10))) + Xsqlite3VdbeChangeP5(tls, v, (uint16(SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL))) } - } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000200)) != 0 { + } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_INDEXED) != 0 { var nEq U16 = *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ /* &.nEq */)) // Number of == or IN terms var nBtm U16 = *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 2 /* &.nBtm */)) // Length of BTM vector var nTop U16 = *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 4 /* &.nTop */)) // Length of TOP vector @@ -125613,7 +123476,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // Find any inequality constraint terms for the start and end // of the range. j = int32(nEq) - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000020)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_BTM_LIMIT) != 0 { pRangeStart = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&j, 1))*8)) nExtraReg = func() int32 { if (nExtraReg) > (int32(*(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 2 /* &.nBtm */)))) { @@ -125624,7 +123487,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // Like optimization range constraints always occur in pairs } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000010)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_TOP_LIMIT) != 0 { pRangeEnd = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&j, 1))*8)) nExtraReg = func() int32 { if (nExtraReg) > (int32(*(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 4 /* &.nTop */)))) { @@ -125646,14 +123509,14 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // index entries for which the column is null and for those for which // it is not. For an ASC sort, the non-NULL entries are scanned first. // For DESC, NULL entries are scanned first. - if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(0x00000010 | 0x00000020))) == U32(0)) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00080000)) != U32(0)) { + if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(WHERE_TOP_LIMIT | WHERE_BTM_LIMIT))) == U32(0)) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_BIGNULL_SORT) != U32(0)) { nExtraReg = 1 bSeekPastNull = U8(1) (*WhereLevel)(unsafe.Pointer(pLevel)).FregBignull = libc.AssignInt32(®Bignull, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)) if (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regBignull) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regBignull) } (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull = Xsqlite3VdbeMakeLabel(tls, pParse) } @@ -125661,7 +123524,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // If we are doing a reverse order scan on an ascending index, or // a forward order scan on a descending index, interchange the // start and end terms (pRangeStart and pRangeEnd). - if ((int32(nEq) < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)) && (bRev == (libc.Bool32(int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(nEq)))) == 0)))) || + if ((int32(nEq) < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)) && (bRev == (libc.Bool32(int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(nEq)))) == SQLITE_SO_ASC)))) || ((bRev != 0) && (int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) == int32(nEq))) { { var t uintptr = pRangeEnd @@ -125699,8 +123562,8 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI return (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt }() - startEq = (libc.Bool32(!(pRangeStart != 0) || ((int32((*WhereTerm)(unsafe.Pointer(pRangeStart)).FeOperator) & ((int32(0x0002) << (55 - 53)) | (int32(0x0002) << (57 - 53)))) != 0))) - endEq = (libc.Bool32(!(pRangeEnd != 0) || ((int32((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FeOperator) & ((int32(0x0002) << (55 - 53)) | (int32(0x0002) << (57 - 53)))) != 0))) + startEq = (libc.Bool32(!(pRangeStart != 0) || ((int32((*WhereTerm)(unsafe.Pointer(pRangeStart)).FeOperator) & ((int32(WO_EQ) << (TK_LE - TK_EQ)) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) != 0))) + endEq = (libc.Bool32(!(pRangeEnd != 0) || ((int32((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FeOperator) & ((int32(WO_EQ) << (TK_LE - TK_EQ)) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) != 0))) start_constraints = (libc.Bool32((pRangeStart != 0) || (int32(nEq) > 0))) // Seek the index cursor to the start of the range. @@ -125709,9 +123572,9 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI var pRight uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pRangeStart)).FpExpr)).FpRight codeExprOrVector(tls, pParse, pRight, (regBase + int32(nEq)), int32(nBtm)) - if ((int32((*WhereTerm)(unsafe.Pointer(pRangeStart)).FwtFlags) & 0x0080) == 0) && + if ((int32((*WhereTerm)(unsafe.Pointer(pRangeStart)).FwtFlags) & TERM_VNULL) == 0) && (Xsqlite3ExprCanBeNull(tls, pRight) != 0) { - Xsqlite3VdbeAddOp2(tls, v, 50, (regBase + int32(nEq)), addrNxt) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (regBase + int32(nEq)), addrNxt) } if *(*uintptr)(unsafe.Pointer(bp + 16 /* zStartAff */)) != 0 { @@ -125727,11 +123590,11 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI bSeekPastNull = U8(0) } else if bSeekPastNull != 0 { startEq = 0 - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (regBase + int32(nEq))) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (regBase + int32(nEq))) start_constraints = 1 nConstraint++ } else if regBignull != 0 { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (regBase + int32(nEq))) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (regBase + int32(nEq))) start_constraints = 1 nConstraint++ } @@ -125741,11 +123604,11 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // above has already left the cursor sitting on the correct row, // so no further seeking is needed } else { - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00040000)) != 0 { - Xsqlite3VdbeAddOp1(tls, v, 118, iIdxCur) + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IN_EARLYOUT) != 0 { + Xsqlite3VdbeAddOp1(tls, v, OP_SeekHit, iIdxCur) } if regBignull != 0 { - Xsqlite3VdbeAddOp2(tls, v, 69, 1, regBignull) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, regBignull) } @@ -125755,7 +123618,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI if regBignull != 0 { - Xsqlite3VdbeAddOp2(tls, v, 11, 0, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) op = int32(aStartOp[((((libc.Bool32(nConstraint > 1)) * 4) + 2) + bRev)]) Xsqlite3VdbeAddOp4Int(tls, v, op, iIdxCur, addrNxt, regBase, (nConstraint - startEq)) @@ -125770,9 +123633,9 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI var pRight uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FpExpr)).FpRight codeExprOrVector(tls, pParse, pRight, (regBase + int32(nEq)), int32(nTop)) - if ((int32((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FwtFlags) & 0x0080) == 0) && + if ((int32((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FwtFlags) & TERM_VNULL) == 0) && (Xsqlite3ExprCanBeNull(tls, pRight) != 0) { - Xsqlite3VdbeAddOp2(tls, v, 50, (regBase + int32(nEq)), addrNxt) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (regBase + int32(nEq)), addrNxt) } if zEndAff != 0 { @@ -125790,7 +123653,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI } } else if bStopAtNull != 0 { if regBignull == 0 { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (regBase + int32(nEq))) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (regBase + int32(nEq))) endEq = 0 } nConstraint++ @@ -125805,7 +123668,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI if nConstraint != 0 { if regBignull != 0 { // Except, skip the end-of-range check while doing the NULL-scan - Xsqlite3VdbeAddOp2(tls, v, 20, regBignull, (Xsqlite3VdbeCurrentAddr(tls, v) + 3)) + Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, regBignull, (Xsqlite3VdbeCurrentAddr(tls, v) + 3)) } op = int32(aEndOp[((bRev * 2) + endEq)]) @@ -125816,7 +123679,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // During a NULL-scan, check to see if we have reached the end of // the NULLs - Xsqlite3VdbeAddOp2(tls, v, 18, regBignull, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_If, regBignull, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) op = int32(aEndOp[((bRev * 2) + int32(bSeekPastNull))]) Xsqlite3VdbeAddOp4Int(tls, v, op, iIdxCur, addrNxt, regBase, @@ -125824,22 +123687,22 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00040000)) != 0 { - Xsqlite3VdbeAddOp2(tls, v, 118, iIdxCur, 1) + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IN_EARLYOUT) != 0 { + Xsqlite3VdbeAddOp2(tls, v, OP_SeekHit, iIdxCur, 1) } // Seek the table cursor, if required - omitTable = (libc.Bool32((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000040)) != U32(0)) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0020) == 0))) + omitTable = (libc.Bool32((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IDX_ONLY) != U32(0)) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_OR_SUBCLAUSE) == 0))) if omitTable != 0 { // pIdx is a covering index. No need to access the main table. - } else if ((*Table)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FpTable))).FtabFlags & U32(0x0080)) == U32(0) { - if ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0400) != 0) || - (((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x1000) != 0) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == 1) || (int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm) == 0))) { + } else if ((*Table)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FpTable))).FtabFlags & TF_WithoutRowid) == U32(0) { + if ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_SEEK_TABLE) != 0) || + (((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_SEEK_UNIQ_TABLE) != 0) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == ONEPASS_SINGLE) || (int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm) == 0))) { iRowidReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 134, iIdxCur, iRowidReg) - Xsqlite3VdbeAddOp3(tls, v, 32, iCur, 0, iRowidReg) + Xsqlite3VdbeAddOp2(tls, v, OP_IdxRowid, iIdxCur, iRowidReg) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iCur, 0, iRowidReg) } else { codeDeferredSeek(tls, pWInfo, pIdx, iCur, iIdxCur) @@ -125849,9 +123712,9 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI iRowidReg = Xsqlite3GetTempRange(tls, pParse, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) for j = 0; j < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); j++ { k = int32(Xsqlite3TableColumnToIndex(tls, pIdx, *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)))) - Xsqlite3VdbeAddOp3(tls, v, 89, iIdxCur, k, (iRowidReg + j)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, k, (iRowidReg + j)) } - Xsqlite3VdbeAddOp4Int(tls, v, 29, iCur, addrCont, + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iCur, addrCont, iRowidReg, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) } @@ -125872,7 +123735,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // OR clause, since the transformation will become invalid once we // move forward to the next index. // https://sqlite.org/src/info/4e8e4857d32d401f - if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0020) == 0 { + if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_OR_SUBCLAUSE) == 0 { whereIndexExprTrans(tls, pIdx, iCur, iIdxCur, pWInfo) } @@ -125894,29 +123757,29 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI } // Record the instruction used to terminate the loop. - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00001000)) != 0 { - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(173) + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_ONEROW) != 0 { + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Noop } else if bRev != 0 { - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(4) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Prev } else { - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(5) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Next } (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iIdxCur (*WhereLevel)(unsafe.Pointer(pLevel)).Fp3 = func() uint8 { - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00010000)) != U32(0) { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_UNQ_WANTED) != U32(0) { return uint8(1) } return uint8(0) }() - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x0000000f)) == U32(0) { - (*WhereLevel)(unsafe.Pointer(pLevel)).Fp5 = U8(1) + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_CONSTRAINT) == U32(0) { + (*WhereLevel)(unsafe.Pointer(pLevel)).Fp5 = SQLITE_STMTSTATUS_FULLSCAN_STEP } else { } if omitTable != 0 { pIdx = uintptr(0) } - } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00002000)) != 0 { + } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_MULTI_OR) != 0 { // Case 5: Two or more separately indexed terms connected by OR // // Example: @@ -125975,10 +123838,10 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI var pAndExpr uintptr = uintptr(0) // An ".. AND (...)" expression var pTab uintptr = (*SrcList_item)(unsafe.Pointer(pTabItem)).FpTab - pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(0)*8)) + pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) pOrWc = (*(*uintptr)(unsafe.Pointer(pTerm + 40 /* &.u */)) /* &.wc */) - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(65) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Return (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = regReturn // Set up a new SrcList in pOrTab containing the table being scanned @@ -126014,19 +123877,19 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // correct response for the end-of-loop code (the OP_Return) is to // fall through to the next instruction, just as an OP_Next does if // called on an uninitialized cursor. - if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0010) == 0 { - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_DUPLICATES_OK) == 0 { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { regRowset = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, regRowset) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regRowset) } else { var pPk uintptr = Xsqlite3PrimaryKeyIndex(tls, pTab) regRowset = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - Xsqlite3VdbeAddOp2(tls, v, 100, regRowset, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, regRowset, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pPk) } regRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) } - iRetInit = Xsqlite3VdbeAddOp2(tls, v, 69, 0, regReturn) + iRetInit = Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regReturn) // If the original WHERE clause is z of the form: (x1 OR x2 OR ...) AND y // Then for every term xN, evaluate as the subexpression: xN AND z @@ -126049,10 +123912,10 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI continue } - if (int32((*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*64)).FwtFlags) & (0x0002 | 0x0004)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*64)).FwtFlags) & (TERM_VIRTUAL | TERM_CODED)) != 0 { continue } - if (int32((*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*64)).FeOperator) & 0x1fff) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*64)).FeOperator) & WO_ALL) == 0 { continue } @@ -126065,18 +123928,18 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // op==TK_AND comparison inside of sqlite3PExpr() false, and this // prevents sqlite3PExpr() from implementing AND short-circuit // optimization, which we do not want here. - pAndExpr = Xsqlite3PExpr(tls, pParse, (44 | 0x10000), uintptr(0), pAndExpr) + pAndExpr = Xsqlite3PExpr(tls, pParse, (TK_AND | 0x10000), uintptr(0), pAndExpr) } } // Run a separate WHERE clause for each term of the OR clause. After // eliminating duplicates from other WHERE clauses, the action for each // sub-WHERE clause is to to invoke the main loop body as a subroutine. - wctrlFlags = (U16(0x0020 | (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0400))) + wctrlFlags = (U16(WHERE_OR_SUBCLAUSE | (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_SEEK_TABLE))) Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+19111 /* "MULTI-INDEX OR" */, 0) for ii = 0; ii < (*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm; ii++ { var pOrTerm uintptr = ((*WhereClause)(unsafe.Pointer(pOrWc)).Fa + uintptr(ii)*64) - if ((*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCur) || ((int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & 0x0400) != 0) { + if ((*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCur) || ((int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & WO_AND) != 0) { var pSubWInfo uintptr // Info for single OR-term scan var pOrExpr uintptr = (*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr // Current OR clause term var jmp1 int32 = 0 // Address of jump operation @@ -126094,7 +123957,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI if pSubWInfo != 0 { var pSubLoop uintptr var addrExplain int32 = Xsqlite3WhereExplainOneScan(tls, - pParse, pOrTab, ((pSubWInfo + 920 /* &.a */) + uintptr(0)*88), uint16(0)) + pParse, pOrTab, (pSubWInfo + 920 /* &.a */), uint16(0)) _ = addrExplain _ = addrExplain @@ -126102,16 +123965,16 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // duplicate rows from prior sub-WHERE clauses, and record the // rowid (or PRIMARY KEY) for the current row so that the same // row will be skipped in subsequent sub-WHERE clauses. - if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0010) == 0 { + if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_DUPLICATES_OK) == 0 { var iSet int32 = func() int32 { if ii == ((*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm - 1) { return -1 } return ii }() - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, -1, regRowid) - jmp1 = Xsqlite3VdbeAddOp4Int(tls, v, 45, regRowset, 0, + jmp1 = Xsqlite3VdbeAddOp4Int(tls, v, OP_RowSetTest, regRowset, 0, regRowid, iSet) } else { @@ -126139,15 +124002,15 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // need to insert the key into the temp table, as it will never // be tested for. if iSet != 0 { - jmp1 = Xsqlite3VdbeAddOp4Int(tls, v, 30, regRowset, 0, r, nPk) + jmp1 = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, regRowset, 0, r, nPk) } if iSet >= 0 { - Xsqlite3VdbeAddOp3(tls, v, 91, r, nPk, regRowid) - Xsqlite3VdbeAddOp4Int(tls, v, 130, regRowset, regRowid, + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, r, nPk, regRowid) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, regRowset, regRowid, r, nPk) if iSet != 0 { - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_USESEEKRESULT) } } @@ -126157,7 +124020,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI } // Invoke the main loop body as a subroutine - Xsqlite3VdbeAddOp2(tls, v, 12, regReturn, iLoopBody) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regReturn, iLoopBody) // Jump here (skipping the main loop body subroutine) if the // current sub-WHERE row is a duplicate from prior sub-WHEREs. @@ -126184,11 +124047,11 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // terms, set pCov to the candidate covering index. Otherwise, set // pCov to NULL to indicate that no candidate covering index will // be available. - pSubLoop = (*WhereLevel)(unsafe.Pointer((pSubWInfo + 920 /* &.a */) + uintptr(0)*88)).FpWLoop + pSubLoop = (*WhereLevel)(unsafe.Pointer((pSubWInfo + 920 /* &.a */))).FpWLoop - if ((((*WhereLoop)(unsafe.Pointer(pSubLoop)).FwsFlags & U32(0x00000200)) != U32(0)) && + if ((((*WhereLoop)(unsafe.Pointer(pSubLoop)).FwsFlags & WHERE_INDEXED) != U32(0)) && ((ii == 0) || (*(*uintptr)(unsafe.Pointer((pSubLoop + 24 /* &.u */ /* &.btree */) + 8 /* &.pIndex */)) == pCov))) && - ((((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) || !((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pSubLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */))) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2)) { + ((((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) || !((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pSubLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */))) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY)) { pCov = *(*uintptr)(unsafe.Pointer(pSubLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) } else { @@ -126225,14 +124088,14 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI if (uint32(int32(*(*uint8)(unsafe.Pointer(pTabItem + 60 /* &.fg */ + 4 /* &.isRecursive */)) & 0x20 >> 5))) != 0 { // Tables marked isRecursive have only a single row that is stored in // a pseudo-cursor. No need to Rewind or Next such cursors. - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(173) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Noop } else { (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = aStep[bRev] (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = (1 + Xsqlite3VdbeAddOp2(tls, v, int32(aStart[bRev]), iCur, addrHalt)) - (*WhereLevel)(unsafe.Pointer(pLevel)).Fp5 = U8(1) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fp5 = SQLITE_STMTSTATUS_FULLSCAN_STEP } } @@ -126267,7 +124130,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI var pE uintptr var skipLikeAddr int32 = 0 - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & (0x0002 | 0x0004)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & (TERM_VIRTUAL | TERM_CODED)) != 0 { goto __2 } if ((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & (*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady) != uint64(0) { @@ -126277,7 +124140,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI } pE = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr - if ((int32((*SrcList_item)(unsafe.Pointer(pTabItem)).Ffg.Fjointype) & 0x0008) != 0) && !(((*Expr)(unsafe.Pointer((pE))).Fflags & (U32(0x000001))) != U32(0)) { + if ((int32((*SrcList_item)(unsafe.Pointer(pTabItem)).Ffg.Fjointype) & JT_LEFT) != 0) && !(((*Expr)(unsafe.Pointer((pE))).Fflags & (EP_FromJoin)) != U32(0)) { goto __2 } @@ -126285,14 +124148,14 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI iNext = 2 goto __2 } - if (iLoop < 3) && ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x1000) != 0) { + if (iLoop < 3) && ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VARSELECT) != 0) { if iNext == 0 { iNext = 3 } goto __2 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0200) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_LIKECOND) != 0 { // If the TERM_LIKECOND flag is set, that means that the range search // is sufficient to guarantee that the LIKE operator is true, so we // can skip the call to the like(A,B) function. But this only works @@ -126300,11 +124163,11 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // that compares BLOBs. goto __2 } - Xsqlite3ExprIfFalse(tls, pParse, pE, addrCont, 0x10) + Xsqlite3ExprIfFalse(tls, pParse, pE, addrCont, SQLITE_JUMPIFNULL) if skipLikeAddr != 0 { Xsqlite3VdbeJumpHere(tls, v, skipLikeAddr) } - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) } goto __2 @@ -126336,40 +124199,40 @@ __4: // var sEAlt Expr at bp+24, 72 var pAlt uintptr - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & (0x0002 | 0x0004)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & (TERM_VIRTUAL | TERM_CODED)) != 0 { goto __5 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (0x0002 | 0x0080)) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (WO_EQ | WO_IS)) == 0 { goto __5 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0800) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_EQUIV) == 0 { goto __5 } if (*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != iCur { goto __5 } - if (int32((*SrcList_item)(unsafe.Pointer(pTabItem)).Ffg.Fjointype) & 0x0008) != 0 { + if (int32((*SrcList_item)(unsafe.Pointer(pTabItem)).Ffg.Fjointype) & JT_LEFT) != 0 { goto __5 } pE = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr pAlt = Xsqlite3WhereFindTerm(tls, pWC, iCur, *(*int32)(unsafe.Pointer(pTerm + 40 /* &.u */)), notReady, - (uint32((0x0002 | 0x0001) | 0x0080)), uintptr(0)) + (uint32((WO_EQ | WO_IN) | WO_IS)), uintptr(0)) if pAlt == uintptr(0) { goto __5 } - if (int32((*WhereTerm)(unsafe.Pointer(pAlt)).FwtFlags) & (0x0004)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pAlt)).FwtFlags) & (TERM_CODED)) != 0 { goto __5 } - if (((int32((*WhereTerm)(unsafe.Pointer(pAlt)).FeOperator) & 0x0001) != 0) && - (((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAlt)).FpExpr)).Fflags & U32(0x000800)) != 0)) && + if (((int32((*WhereTerm)(unsafe.Pointer(pAlt)).FeOperator) & WO_IN) != 0) && + (((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAlt)).FpExpr)).Fflags & EP_xIsSelect) != 0)) && ((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAlt)).FpExpr + 32 /* &.x */)))).FpEList)).FnExpr > 1) { goto __5 } *(*Expr)(unsafe.Pointer(bp + 24 /* sEAlt */)) = *(*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAlt)).FpExpr)) (*Expr)(unsafe.Pointer(bp + 24 /* &sEAlt */)).FpLeft = (*Expr)(unsafe.Pointer(pE)).FpLeft - Xsqlite3ExprIfFalse(tls, pParse, bp+24 /* &sEAlt */, addrCont, 0x10) + Xsqlite3ExprIfFalse(tls, pParse, bp+24 /* &sEAlt */, addrCont, SQLITE_JUMPIFNULL) } goto __5 @@ -126385,7 +124248,7 @@ __6: // at least one row of the right table has matched the left table. if (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa j = 0 @@ -126395,7 +124258,7 @@ __6: } { - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & (0x0002 | 0x0004)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & (TERM_VIRTUAL | TERM_CODED)) != 0 { goto __8 } if ((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & (*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady) != uint64(0) { @@ -126403,8 +124266,8 @@ __6: goto __8 } - Xsqlite3ExprIfFalse(tls, pParse, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr, addrCont, 0x10) - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004)) + Xsqlite3ExprIfFalse(tls, pParse, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr, addrCont, SQLITE_JUMPIFNULL) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) } goto __8 @@ -126422,21 +124285,21 @@ __6: var aStartOp = [8]U8{ U8(0), U8(0), - U8(37), // 2: (!start_constraints && startEq && !bRev) - U8(33), // 3: (!start_constraints && startEq && bRev) - U8(25), // 4: (start_constraints && !startEq && !bRev) - U8(22), // 5: (start_constraints && !startEq && bRev) - U8(24), // 6: (start_constraints && startEq && !bRev) - U8(23), // 7: (start_constraints && startEq && bRev) + OP_Rewind, // 2: (!start_constraints && startEq && !bRev) + OP_Last, // 3: (!start_constraints && startEq && bRev) + OP_SeekGT, // 4: (start_constraints && !startEq && !bRev) + OP_SeekLT, // 5: (start_constraints && !startEq && bRev) + OP_SeekGE, // 6: (start_constraints && startEq && !bRev) + OP_SeekLE, // 7: (start_constraints && startEq && bRev) } /* sqlite3.c:143140:21 */ var aEndOp = [4]U8{ - U8(41), // 0: (end_constraints && !bRev && !endEq) - U8(39), // 1: (end_constraints && !bRev && endEq) - U8(38), // 2: (end_constraints && bRev && !endEq) - U8(40), // 3: (end_constraints && bRev && endEq) -} /* sqlite3.c:143150:21 */ -var aStep = [2]U8{U8(5), U8(4)} /* sqlite3.c:143816:21 */ -var aStart = [2]U8{U8(37), U8(33)} /* sqlite3.c:143817:21 */ + OP_IdxGE, // 0: (end_constraints && !bRev && !endEq) + OP_IdxGT, // 1: (end_constraints && !bRev && endEq) + OP_IdxLE, // 2: (end_constraints && bRev && !endEq) + OP_IdxLT, // 3: (end_constraints && bRev && endEq) +} /* sqlite3.c:143150:21 */ +var aStep = [2]U8{OP_Next, OP_Prev} /* sqlite3.c:143816:21 */ +var aStart = [2]U8{OP_Rewind, OP_Last} /* sqlite3.c:143817:21 */ // Deallocate all memory associated with a WhereOrInfo object. func whereOrInfoDelete(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3.c:144024:13: */ @@ -126476,7 +124339,7 @@ func whereClauseInsert(tls *libc.TLS, pWC uintptr, p uintptr, wtFlags U16) int32 var db uintptr = (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse)).Fdb (*WhereClause)(unsafe.Pointer(pWC)).Fa = Xsqlite3DbMallocRawNN(tls, db, (uint64((uint64(unsafe.Sizeof(WhereTerm{})) * uint64((*WhereClause)(unsafe.Pointer(pWC)).FnSlot)) * uint64(2)))) if (*WhereClause)(unsafe.Pointer(pWC)).Fa == uintptr(0) { - if (int32(wtFlags) & 0x0001) != 0 { + if (int32(wtFlags) & TERM_DYNAMIC) != 0 { Xsqlite3ExprDelete(tls, db, p) } (*WhereClause)(unsafe.Pointer(pWC)).Fa = pOld @@ -126489,7 +124352,7 @@ func whereClauseInsert(tls *libc.TLS, pWC uintptr, p uintptr, wtFlags U16) int32 (*WhereClause)(unsafe.Pointer(pWC)).FnSlot = (int32(uint64(Xsqlite3DbMallocSize(tls, db, (*WhereClause)(unsafe.Pointer(pWC)).Fa)) / uint64(unsafe.Sizeof(WhereTerm{})))) } pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(libc.AssignInt32(&idx, libc.PostIncInt32(&(*WhereClause)(unsafe.Pointer(pWC)).FnTerm, 1)))*64) - if (p != 0) && (((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x040000))) != U32(0)) { + if (p != 0) && (((*Expr)(unsafe.Pointer((p))).Fflags & (EP_Unlikely)) != U32(0)) { (*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb = (LogEst(int32(Xsqlite3LogEst(tls, uint64((*Expr)(unsafe.Pointer(p)).FiTable))) - 270)) } else { (*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb = int16(1) @@ -126508,16 +124371,16 @@ func whereClauseInsert(tls *libc.TLS, pWC uintptr, p uintptr, wtFlags U16) int32 // "=", "<", ">", "<=", ">=", "IN", "IS", and "IS NULL" func allowedOp(tls *libc.TLS, op int32) int32 { /* sqlite3.c:144097:12: */ - return (libc.Bool32((((op == 49) || ((op >= 53) && (op <= 57))) || (op == 50)) || (op == 45))) + return (libc.Bool32((((op == TK_IN) || ((op >= TK_EQ) && (op <= TK_GE))) || (op == TK_ISNULL)) || (op == TK_IS))) } // Commute a comparison operator. Expressions of the form "X op Y" // are converted into "Y op X". func exprCommute(tls *libc.TLS, pParse uintptr, pExpr uintptr) U16 { /* sqlite3.c:144109:12: */ - if ((int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == 174) || - (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpRight)).Fop) == 174)) || + if ((int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_VECTOR) || + (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpRight)).Fop) == TK_VECTOR)) || (Xsqlite3BinaryCompareCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight) != Xsqlite3BinaryCompareCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)) { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) ^= (U32(0x000200)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) ^= (EP_Commuted) } { var t uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpRight @@ -126525,9 +124388,9 @@ func exprCommute(tls *libc.TLS, pParse uintptr, pExpr uintptr) U16 { /* sqlite3. (*Expr)(unsafe.Pointer(pExpr)).FpLeft = t } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) >= 54 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) >= TK_GT { - (*Expr)(unsafe.Pointer(pExpr)).Fop = (U8(((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) - 54) ^ 2) + 54)) + (*Expr)(unsafe.Pointer(pExpr)).Fop = (U8(((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) - TK_GT) ^ 2) + TK_GT)) } return U16(0) } @@ -126536,15 +124399,15 @@ func exprCommute(tls *libc.TLS, pParse uintptr, pExpr uintptr) U16 { /* sqlite3. func operatorMask(tls *libc.TLS, op int32) U16 { /* sqlite3.c:144132:12: */ var c U16 - if op == 49 { - c = U16(0x0001) - } else if op == 50 { - c = U16(0x0100) - } else if op == 45 { - c = U16(0x0080) + if op == TK_IN { + c = WO_IN + } else if op == TK_ISNULL { + c = WO_ISNULL + } else if op == TK_IS { + c = WO_IS } else { - c = (U16(int32(0x0002) << (op - 53))) + c = (U16(int32(WO_EQ) << (op - TK_EQ))) } return c @@ -126581,29 +124444,29 @@ func isLikeOrGlob(tls *libc.TLS, pParse uintptr, pExpr uintptr, ppPrefix uintptr return 0 } pList = *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) - pLeft = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(1)*32)).FpExpr + pLeft = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + 1*32)).FpExpr - pRight = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(0)*32)).FpExpr) + pRight = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FpExpr) op = int32((*Expr)(unsafe.Pointer(pRight)).Fop) - if (op == 153) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00800000)) == uint64(0)) { + if (op == TK_VARIABLE) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_EnableQPSG) == uint64(0)) { var pReprepare uintptr = (*Parse)(unsafe.Pointer(pParse)).FpReprepare var iCol int32 = int32((*Expr)(unsafe.Pointer(pRight)).FiColumn) - pVal = Xsqlite3VdbeGetBoundValue(tls, pReprepare, iCol, uint8(0x41)) - if (pVal != 0) && (Xsqlite3_value_type(tls, pVal) == 3) { + pVal = Xsqlite3VdbeGetBoundValue(tls, pReprepare, iCol, SQLITE_AFF_BLOB) + if (pVal != 0) && (Xsqlite3_value_type(tls, pVal) == SQLITE_TEXT) { z = Xsqlite3_value_text(tls, pVal) } Xsqlite3VdbeSetVarmask(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, iCol) - } else if op == 115 { + } else if op == TK_STRING { z = *(*uintptr)(unsafe.Pointer(pRight + 8 /* &.u */)) } if z != 0 { // Count the number of prefix characters prior to the first wildcard cnt = 0 - for ((((int32(libc.AssignUint8(&c, *(*U8)(unsafe.Pointer(z + uintptr(cnt)))))) != 0) && (int32(c) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(0)))))) && (int32(c) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(1)))))) && (int32(c) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(2))))) { + for ((((int32(libc.AssignUint8(&c, *(*U8)(unsafe.Pointer(z + uintptr(cnt)))))) != 0) && (int32(c) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */))))) && (int32(c) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + 1))))) && (int32(c) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + 2)))) { cnt++ - if (int32(c) == int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(3))))) && (int32(*(*U8)(unsafe.Pointer(z + uintptr(cnt)))) != 0) { + if (int32(c) == int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + 3)))) && (int32(*(*U8)(unsafe.Pointer(z + uintptr(cnt)))) != 0) { cnt++ } } @@ -126616,21 +124479,21 @@ func isLikeOrGlob(tls *libc.TLS, pParse uintptr, pExpr uintptr, ppPrefix uintptr // range search. The third is because the caller assumes that the pattern // consists of at least one character after all escapes have been // removed. - if ((cnt != 0) && (255 != int32(*(*U8)(unsafe.Pointer(z + uintptr((cnt - 1))))))) && ((cnt > 1) || (int32(*(*U8)(unsafe.Pointer(z + uintptr(0)))) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(3)))))) { + if ((cnt != 0) && (255 != int32(*(*U8)(unsafe.Pointer(z + uintptr((cnt - 1))))))) && ((cnt > 1) || (int32(*(*U8)(unsafe.Pointer(z))) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + 3))))) { var pPrefix uintptr // A "complete" match if the pattern ends with "*" or "%" - *(*int32)(unsafe.Pointer(pisComplete)) = (libc.Bool32((int32(c) == int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(0))))) && (int32(*(*U8)(unsafe.Pointer(z + uintptr((cnt + 1))))) == 0))) + *(*int32)(unsafe.Pointer(pisComplete)) = (libc.Bool32((int32(c) == int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */)))) && (int32(*(*U8)(unsafe.Pointer(z + uintptr((cnt + 1))))) == 0))) // Get the pattern prefix. Remove all escapes from the prefix. - pPrefix = Xsqlite3Expr(tls, db, 115, z) + pPrefix = Xsqlite3Expr(tls, db, TK_STRING, z) if pPrefix != 0 { var iFrom int32 var iTo int32 var zNew uintptr = *(*uintptr)(unsafe.Pointer(pPrefix + 8 /* &.u */)) *(*int8)(unsafe.Pointer(zNew + uintptr(cnt))) = int8(0) for iFrom = libc.AssignInt32(&iTo, 0); iFrom < cnt; iFrom++ { - if int32(*(*int8)(unsafe.Pointer(zNew + uintptr(iFrom)))) == int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(3)))) { + if int32(*(*int8)(unsafe.Pointer(zNew + uintptr(iFrom)))) == int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + 3))) { iFrom++ } *(*int8)(unsafe.Pointer(zNew + uintptr(libc.PostIncInt32(&iTo, 1)))) = *(*int8)(unsafe.Pointer(zNew + uintptr(iFrom))) @@ -126649,19 +124512,19 @@ func isLikeOrGlob(tls *libc.TLS, pParse uintptr, pExpr uintptr, ppPrefix uintptr // 2019-06-10 https://sqlite.org/src/info/fd76310a5e843e07 // 2019-06-14 https://sqlite.org/src/info/ce8717f0885af975 // 2019-09-03 https://sqlite.org/src/info/0f0428096f17252a - if ((int32((*Expr)(unsafe.Pointer(pLeft)).Fop) != 164) || - (int32(Xsqlite3ExprAffinity(tls, pLeft)) != 0x42)) || + if ((int32((*Expr)(unsafe.Pointer(pLeft)).Fop) != TK_COLUMN) || + (int32(Xsqlite3ExprAffinity(tls, pLeft)) != SQLITE_AFF_TEXT)) || ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)))).FnModuleArg != 0) { var isNum int32 // var rDummy float64 at bp+8, 8 - isNum = Xsqlite3AtoF(tls, zNew, bp+8 /* &rDummy */, iTo, uint8(1)) + isNum = Xsqlite3AtoF(tls, zNew, bp+8 /* &rDummy */, iTo, SQLITE_UTF8) if isNum <= 0 { - if (iTo == 1) && (int32(*(*int8)(unsafe.Pointer(zNew + uintptr(0)))) == '-') { + if (iTo == 1) && (int32(*(*int8)(unsafe.Pointer(zNew))) == '-') { isNum = +1 } else { *(*int8)(unsafe.Pointer(zNew + uintptr((iTo - 1))))++ - isNum = Xsqlite3AtoF(tls, zNew, bp+8 /* &rDummy */, iTo, uint8(1)) + isNum = Xsqlite3AtoF(tls, zNew, bp+8 /* &rDummy */, iTo, SQLITE_UTF8) *(*int8)(unsafe.Pointer(zNew + uintptr((iTo - 1))))-- } } @@ -126676,10 +124539,10 @@ func isLikeOrGlob(tls *libc.TLS, pParse uintptr, pExpr uintptr, ppPrefix uintptr // If the RHS pattern is a bound parameter, make arrangements to // reprepare the statement when that parameter is rebound - if op == 153 { + if op == TK_VARIABLE { var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe Xsqlite3VdbeSetVarmask(tls, v, int32((*Expr)(unsafe.Pointer(pRight)).FiColumn)) - if (*(*int32)(unsafe.Pointer(pisComplete)) != 0) && (*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 8 /* &.u */)) + uintptr(1))) != 0) { + if (*(*int32)(unsafe.Pointer(pisComplete)) != 0) && (*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 8 /* &.u */)) + 1)) != 0) { // If the rhs of the LIKE expression is a variable, and the current // value of the variable means there is no need to invoke the LIKE // function, then no OP_Variable will be added to the program. @@ -126729,7 +124592,7 @@ func isAuxiliaryVtabOperator(tls *libc.TLS, db uintptr, pExpr uintptr, peOp2 uin bp := tls.Alloc(16) defer tls.Free(16) - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 169 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_FUNCTION { var pList uintptr var pCol uintptr // Column reference var i int32 @@ -126745,13 +124608,13 @@ func isAuxiliaryVtabOperator(tls *libc.TLS, db uintptr, pExpr uintptr, peOp2 uin // // vtab_column MATCH expression // MATCH(expression,vtab_column) - pCol = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(1)*32)).FpExpr + pCol = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + 1*32)).FpExpr - if ((int32((*Expr)(unsafe.Pointer((pCol))).Fop) == 164) && (*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)))).FnModuleArg != 0) { + if ((int32((*Expr)(unsafe.Pointer((pCol))).Fop) == TK_COLUMN) && (*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)))).FnModuleArg != 0) { for i = 0; i < (int32(uint64(unsafe.Sizeof(aOp)) / uint64(unsafe.Sizeof(Op2{})))); i++ { if Xsqlite3StrICmp(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), aOp[i].FzOp) == 0 { *(*uint8)(unsafe.Pointer(peOp2)) = aOp[i].FeOp2 - *(*uintptr)(unsafe.Pointer(ppRight)) = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(0)*32)).FpExpr + *(*uintptr)(unsafe.Pointer(ppRight)) = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FpExpr *(*uintptr)(unsafe.Pointer(ppLeft)) = pCol return 1 } @@ -126767,9 +124630,9 @@ func isAuxiliaryVtabOperator(tls *libc.TLS, db uintptr, pExpr uintptr, peOp2 uin // Historically, xFindFunction expected to see lower-case function // names. But for this use case, xFindFunction is expected to deal // with function names in an arbitrary case. - pCol = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(0)*32)).FpExpr + pCol = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FpExpr - if ((int32((*Expr)(unsafe.Pointer((pCol))).Fop) == 164) && (*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)))).FnModuleArg != 0) { + if ((int32((*Expr)(unsafe.Pointer((pCol))).Fop) == TK_COLUMN) && (*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)))).FnModuleArg != 0) { var pVtab uintptr var pMod uintptr // var xNotUsed uintptr at bp, 8 @@ -126781,24 +124644,24 @@ func isAuxiliaryVtabOperator(tls *libc.TLS, db uintptr, pExpr uintptr, peOp2 uin pMod = (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule if (*Sqlite3_module)(unsafe.Pointer(pMod)).FxFindFunction != uintptr(0) { i = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pMod + 144 /* &.xFindFunction */))))(tls, pVtab, 2, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), bp /* &xNotUsed */, bp+8 /* &pNotUsed */) - if i >= 150 { + if i >= SQLITE_INDEX_CONSTRAINT_FUNCTION { *(*uint8)(unsafe.Pointer(peOp2)) = uint8(i) - *(*uintptr)(unsafe.Pointer(ppRight)) = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(1)*32)).FpExpr + *(*uintptr)(unsafe.Pointer(ppRight)) = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + 1*32)).FpExpr *(*uintptr)(unsafe.Pointer(ppLeft)) = pCol return 1 } } } - } else if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 52) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 168)) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 51) { + } else if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NE) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_ISNOT)) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NOTNULL) { var res int32 = 0 var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft var pRight uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpRight - if ((int32((*Expr)(unsafe.Pointer((pLeft))).Fop) == 164) && (*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)))).FnModuleArg != 0) { + if ((int32((*Expr)(unsafe.Pointer((pLeft))).Fop) == TK_COLUMN) && (*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)))).FnModuleArg != 0) { res++ } - if (pRight != 0) && (((int32((*Expr)(unsafe.Pointer((pRight))).Fop) == 164) && (*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)))).FnModuleArg != 0)) { + if (pRight != 0) && (((int32((*Expr)(unsafe.Pointer((pRight))).Fop) == TK_COLUMN) && (*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)))).FnModuleArg != 0)) { res++ { var t uintptr = pLeft @@ -126809,14 +124672,14 @@ func isAuxiliaryVtabOperator(tls *libc.TLS, db uintptr, pExpr uintptr, peOp2 uin } *(*uintptr)(unsafe.Pointer(ppLeft)) = pLeft *(*uintptr)(unsafe.Pointer(ppRight)) = pRight - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 52 { - *(*uint8)(unsafe.Pointer(peOp2)) = uint8(68) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NE { + *(*uint8)(unsafe.Pointer(peOp2)) = SQLITE_INDEX_CONSTRAINT_NE } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 168 { - *(*uint8)(unsafe.Pointer(peOp2)) = uint8(69) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_ISNOT { + *(*uint8)(unsafe.Pointer(peOp2)) = SQLITE_INDEX_CONSTRAINT_ISNOT } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 51 { - *(*uint8)(unsafe.Pointer(peOp2)) = uint8(70) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NOTNULL { + *(*uint8)(unsafe.Pointer(peOp2)) = SQLITE_INDEX_CONSTRAINT_ISNOTNULL } return res } @@ -126830,25 +124693,17 @@ type Op2 = struct { } /* sqlite3.c:144350:18 */ var aOp = [4]Op2{ - { - FzOp: ts + 13736, /* "match" */ - FeOp2: uint8(64)}, - { - FzOp: ts + 13216, /* "glob" */ - FeOp2: uint8(66)}, - { - FzOp: ts + 12776, /* "like" */ - FeOp2: uint8(65)}, - { - FzOp: ts + 19135, /* "regexp" */ - FeOp2: uint8(67)}, + {FzOp: ts + 13736 /* "match" */, FeOp2: SQLITE_INDEX_CONSTRAINT_MATCH}, + {FzOp: ts + 13216 /* "glob" */, FeOp2: SQLITE_INDEX_CONSTRAINT_GLOB}, + {FzOp: ts + 12776 /* "like" */, FeOp2: SQLITE_INDEX_CONSTRAINT_LIKE}, + {FzOp: ts + 19135 /* "regexp" */, FeOp2: SQLITE_INDEX_CONSTRAINT_REGEXP}, } /* sqlite3.c:144353:7 */ // If the pBase expression originated in the ON or USING clause of // a join, then transfer the appropriate markings over to derived. func transferJoinMarkings(tls *libc.TLS, pDerived uintptr, pBase uintptr) { /* sqlite3.c:144447:13: */ if pDerived != 0 { - *(*U32)(unsafe.Pointer(pDerived + 4 /* &.flags */)) |= ((*Expr)(unsafe.Pointer(pBase)).Fflags & U32(0x000001)) + *(*U32)(unsafe.Pointer(pDerived + 4 /* &.flags */)) |= ((*Expr)(unsafe.Pointer(pBase)).Fflags & EP_FromJoin) (*Expr)(unsafe.Pointer(pDerived)).FiRightJoinTable = (*Expr)(unsafe.Pointer(pBase)).FiRightJoinTable } } @@ -126864,7 +124719,7 @@ func markTermAsChild(tls *libc.TLS, pWC uintptr, iChild int32, iParent int32) { // a conjunction, then return just pTerm when N==0. If N is exceeds // the number of available subterms, return NULL. func whereNthSubterm(tls *libc.TLS, pTerm uintptr, N int32) uintptr { /* sqlite3.c:144468:18: */ - if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) != 0x0400 { + if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) != WO_AND { if N == 0 { return pTerm } @@ -126901,14 +124756,14 @@ func whereCombineDisjuncts(tls *libc.TLS, pSrc uintptr, pWC uintptr, pOne uintpt var op int32 // Operator for the combined expression var idxNew int32 // Index in pWC of the next virtual term - if (int32((*WhereTerm)(unsafe.Pointer(pOne)).FeOperator) & ((((0x0002 | (int32(0x0002) << (56 - 53))) | (int32(0x0002) << (55 - 53))) | (int32(0x0002) << (54 - 53))) | (int32(0x0002) << (57 - 53)))) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pOne)).FeOperator) & ((((WO_EQ | (int32(WO_EQ) << (TK_LT - TK_EQ))) | (int32(WO_EQ) << (TK_LE - TK_EQ))) | (int32(WO_EQ) << (TK_GT - TK_EQ))) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) == 0 { return } - if (int32((*WhereTerm)(unsafe.Pointer(pTwo)).FeOperator) & ((((0x0002 | (int32(0x0002) << (56 - 53))) | (int32(0x0002) << (55 - 53))) | (int32(0x0002) << (54 - 53))) | (int32(0x0002) << (57 - 53)))) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTwo)).FeOperator) & ((((WO_EQ | (int32(WO_EQ) << (TK_LT - TK_EQ))) | (int32(WO_EQ) << (TK_LE - TK_EQ))) | (int32(WO_EQ) << (TK_GT - TK_EQ))) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) == 0 { return } - if ((int32(eOp) & ((0x0002 | (int32(0x0002) << (56 - 53))) | (int32(0x0002) << (55 - 53)))) != int32(eOp)) && - ((int32(eOp) & ((0x0002 | (int32(0x0002) << (54 - 53))) | (int32(0x0002) << (57 - 53)))) != int32(eOp)) { + if ((int32(eOp) & ((WO_EQ | (int32(WO_EQ) << (TK_LT - TK_EQ))) | (int32(WO_EQ) << (TK_LE - TK_EQ)))) != int32(eOp)) && + ((int32(eOp) & ((WO_EQ | (int32(WO_EQ) << (TK_GT - TK_EQ))) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) != int32(eOp)) { return } @@ -126920,11 +124775,11 @@ func whereCombineDisjuncts(tls *libc.TLS, pSrc uintptr, pWC uintptr, pOne uintpt } // If we reach this point, it means the two subterms can be combined if (int32(eOp) & (int32(eOp) - 1)) != 0 { - if (int32(eOp) & ((int32(0x0002) << (56 - 53)) | (int32(0x0002) << (55 - 53)))) != 0 { - eOp = (U16(int32(0x0002) << (55 - 53))) + if (int32(eOp) & ((int32(WO_EQ) << (TK_LT - TK_EQ)) | (int32(WO_EQ) << (TK_LE - TK_EQ)))) != 0 { + eOp = (U16(int32(WO_EQ) << (TK_LE - TK_EQ))) } else { - eOp = (U16(int32(0x0002) << (57 - 53))) + eOp = (U16(int32(WO_EQ) << (TK_GE - TK_EQ))) } } db = (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse)).Fdb @@ -126932,10 +124787,10 @@ func whereCombineDisjuncts(tls *libc.TLS, pSrc uintptr, pWC uintptr, pOne uintpt if pNew == uintptr(0) { return } - for op = 53; int32(eOp) != (int32(0x0002) << (op - 53)); op++ { + for op = TK_EQ; int32(eOp) != (int32(WO_EQ) << (op - TK_EQ)); op++ { } (*Expr)(unsafe.Pointer(pNew)).Fop = U8(op) - idxNew = whereClauseInsert(tls, pWC, pNew, (uint16(0x0002 | 0x0001))) + idxNew = whereClauseInsert(tls, pWC, pNew, (uint16(TERM_VIRTUAL | TERM_DYNAMIC))) exprAnalyze(tls, pSrc, pWC, idxNew) } @@ -127045,19 +124900,19 @@ func exprAnalyzeOrTerm(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) if pOrInfo == uintptr(0) { return } - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0010)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_ORINFO)) pOrWc = (pOrInfo /* &.wc */) libc.Xmemset(tls, pOrWc+40 /* &.aStatic */, 0, uint64(unsafe.Sizeof([8]WhereTerm{}))) Xsqlite3WhereClauseInit(tls, pOrWc, pWInfo) - Xsqlite3WhereSplit(tls, pOrWc, pExpr, uint8(43)) + Xsqlite3WhereSplit(tls, pOrWc, pExpr, TK_OR) Xsqlite3WhereExprAnalyze(tls, pSrc, pOrWc) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { return } // Compute the set of tables that might satisfy cases 1 or 3. - indexable = ^Bitmask(0) - chngToIN = ^Bitmask(0) + indexable = libc.CplUint64(uint64(0)) + chngToIN = libc.CplUint64(uint64(0)) i = ((*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm - 1) pOrTerm = (*WhereClause)(unsafe.Pointer(pOrWc)).Fa __1: @@ -127065,7 +124920,7 @@ __1: goto __3 } { - if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & 0x01ff) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & WO_SINGLE) == 0 { var pAndInfo uintptr chngToIN = uint64(0) @@ -127076,12 +124931,12 @@ __1: var j int32 var b Bitmask = uint64(0) *(*uintptr)(unsafe.Pointer(pOrTerm + 40 /* &.u */)) = pAndInfo - *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) |= U16((0x0020)) - (*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator = U16(0x0400) + *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) |= U16((TERM_ANDINFO)) + (*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator = WO_AND pAndWC = (pAndInfo /* &.wc */) libc.Xmemset(tls, pAndWC+40 /* &.aStatic */, 0, uint64(unsafe.Sizeof([8]WhereTerm{}))) Xsqlite3WhereClauseInit(tls, pAndWC, (*WhereClause)(unsafe.Pointer(pWC)).FpWInfo) - Xsqlite3WhereSplit(tls, pAndWC, (*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr, uint8(44)) + Xsqlite3WhereSplit(tls, pAndWC, (*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr, TK_AND) Xsqlite3WhereExprAnalyze(tls, pSrc, pAndWC) (*WhereClause)(unsafe.Pointer(pAndWC)).FpOuter = pWC if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) { @@ -127094,7 +124949,7 @@ __1: { if (allowedOp(tls, int32((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAndTerm)).FpExpr)).Fop)) != 0) || - (int32((*WhereTerm)(unsafe.Pointer(pAndTerm)).FeOperator) == 0x0040) { + (int32((*WhereTerm)(unsafe.Pointer(pAndTerm)).FeOperator) == WO_AUX) { b = b | (Xsqlite3WhereGetMask(tls, (pWInfo + 656 /* &.sMaskSet */), (*WhereTerm)(unsafe.Pointer(pAndTerm)).FleftCursor)) } @@ -127109,18 +124964,18 @@ __1: } indexable = indexable & (b) } - } else if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags) & 0x0008) != 0 { + } else if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags) & TERM_COPIED) != 0 { // Skip this term for now. We revisit it when we process the // corresponding TERM_VIRTUAL term } else { var b Bitmask b = Xsqlite3WhereGetMask(tls, (pWInfo + 656 /* &.sMaskSet */), (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor) - if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags) & 0x0002) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags) & TERM_VIRTUAL) != 0 { var pOther uintptr = ((*WhereClause)(unsafe.Pointer(pOrWc)).Fa + uintptr((*WhereTerm)(unsafe.Pointer(pOrTerm)).FiParent)*64) b = b | (Xsqlite3WhereGetMask(tls, (pWInfo + 656 /* &.sMaskSet */), (*WhereTerm)(unsafe.Pointer(pOther)).FleftCursor)) } indexable = indexable & (b) - if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & 0x0002) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & WO_EQ) == 0 { chngToIN = uint64(0) } else { chngToIN = chngToIN & (b) @@ -127141,20 +124996,20 @@ __3: // empty. (*WhereOrInfo)(unsafe.Pointer(pOrInfo)).Findexable = indexable if indexable != 0 { - (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = U16(0x0200) + (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = WO_OR (*WhereClause)(unsafe.Pointer(pWC)).FhasOr = U8(1) } else { - (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = U16(0x0200) + (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = WO_OR } // For a two-way OR, attempt to implementation case 2. if (indexable != 0) && ((*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm == 2) { var iOne int32 = 0 var pOne uintptr - for (libc.AssignUintptr(&pOne, whereNthSubterm(tls, ((*WhereClause)(unsafe.Pointer(pOrWc)).Fa+uintptr(0)*64), libc.PostIncInt32(&iOne, 1)))) != uintptr(0) { + for (libc.AssignUintptr(&pOne, whereNthSubterm(tls, ((*WhereClause)(unsafe.Pointer(pOrWc)).Fa), libc.PostIncInt32(&iOne, 1)))) != uintptr(0) { var iTwo int32 = 0 var pTwo uintptr - for (libc.AssignUintptr(&pTwo, whereNthSubterm(tls, ((*WhereClause)(unsafe.Pointer(pOrWc)).Fa+uintptr(1)*64), libc.PostIncInt32(&iTwo, 1)))) != uintptr(0) { + for (libc.AssignUintptr(&pTwo, whereNthSubterm(tls, ((*WhereClause)(unsafe.Pointer(pOrWc)).Fa+1*64), libc.PostIncInt32(&iTwo, 1)))) != uintptr(0) { whereCombineDisjuncts(tls, pSrc, pWC, pOne, pTwo) } } @@ -127200,7 +125055,7 @@ __3: } { - *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0040))) + *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(TERM_OR_OK))) if (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCursor { // This is the 2-bit case and we are on the second iteration and // current term is from the first iteration. So skip this term. @@ -127247,7 +125102,7 @@ __3: { if (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor != iCursor { - *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0040))) + *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(TERM_OR_OK))) } else if (*(*int32)(unsafe.Pointer(pOrTerm + 40 /* &.u */)) != iColumn) || ((iColumn == (-2)) && (Xsqlite3ExprCompare(tls, pParse, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft, pLeft, -1) != 0)) { okToChngToIN = 0 @@ -127262,7 +125117,7 @@ __3: if (affRight != 0) && (affRight != affLeft) { okToChngToIN = 0 } else { - *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) |= U16((0x0040)) + *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) |= U16((TERM_OR_OK)) } } @@ -127292,7 +125147,7 @@ __3: goto __15 } { - if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags) & 0x0040) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags) & TERM_OR_OK) == 0 { goto __14 } @@ -127311,13 +125166,13 @@ __3: ; pDup = Xsqlite3ExprDup(tls, db, pLeft, 0) - pNew = Xsqlite3PExpr(tls, pParse, 49, pDup, uintptr(0)) + pNew = Xsqlite3PExpr(tls, pParse, TK_IN, pDup, uintptr(0)) if pNew != 0 { var idxNew int32 transferJoinMarkings(tls, pNew, pExpr) *(*uintptr)(unsafe.Pointer(pNew + 32 /* &.x */)) = pList - idxNew = whereClauseInsert(tls, pWC, pNew, (uint16(0x0002 | 0x0001))) + idxNew = whereClauseInsert(tls, pWC, pNew, (uint16(TERM_VIRTUAL | TERM_DYNAMIC))) exprAnalyze(tls, pSrc, pWC, idxNew) // pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where used again @@ -127346,19 +125201,19 @@ func termIsEquivalence(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { /* var aff1 int8 var aff2 int8 var pColl uintptr - if !((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (0x0080)) == 0) { + if !((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (SQLITE_Transitive)) == 0) { return 0 } - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 53) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 45) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_EQ) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_IS) { return 0 } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0) { return 0 } aff1 = Xsqlite3ExprAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) aff2 = Xsqlite3ExprAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) if (int32(aff1) != int32(aff2)) && - (!((int32(aff1)) >= 0x43) || !((int32(aff2)) >= 0x43)) { + (!((int32(aff1)) >= SQLITE_AFF_NUMERIC) || !((int32(aff2)) >= SQLITE_AFF_NUMERIC)) { return 0 } pColl = Xsqlite3ExprCompareCollSeq(tls, pParse, pExpr) @@ -127435,8 +125290,8 @@ __3: continue } if Xsqlite3ExprCompareSkip(tls, pExpr, (*ExprList_item)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FaColExpr+8 /* &.a */)+uintptr(i)*32)).FpExpr, iCur) == 0 { - *(*int32)(unsafe.Pointer(aiCurCol + uintptr(0)*4)) = iCur - *(*int32)(unsafe.Pointer(aiCurCol + uintptr(1)*4)) = -2 + *(*int32)(unsafe.Pointer(aiCurCol)) = iCur + *(*int32)(unsafe.Pointer(aiCurCol + 1*4)) = -2 return 1 } } @@ -127449,13 +125304,13 @@ func exprMightBeIndexed(tls *libc.TLS, pFrom uintptr, mPrereq Bitmask, aiCurCol // inequality constraint (>, <, >= or <=), perform the processing // on the first element of the vector. - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 174) && ((op >= 54) && (op <= 57)) { - pExpr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + uintptr(0)*32)).FpExpr + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_VECTOR) && ((op >= TK_GT) && (op <= TK_GE)) { + pExpr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */))).FpExpr } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164 { - *(*int32)(unsafe.Pointer(aiCurCol + uintptr(0)*4)) = (*Expr)(unsafe.Pointer(pExpr)).FiTable - *(*int32)(unsafe.Pointer(aiCurCol + uintptr(1)*4)) = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN { + *(*int32)(unsafe.Pointer(aiCurCol)) = (*Expr)(unsafe.Pointer(pExpr)).FiTable + *(*int32)(unsafe.Pointer(aiCurCol + 1*4)) = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) return 1 } if mPrereq == uint64(0) { @@ -127512,17 +125367,17 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s prereqLeft = Xsqlite3WhereExprUsage(tls, pMaskSet, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop) - if op == 49 { + if op == TK_IN { if Xsqlite3ExprCheckIN(tls, pParse, pExpr) != 0 { return } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = exprSelectUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) } else { (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = Xsqlite3WhereExprListUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) } - } else if op == 50 { + } else if op == TK_ISNULL { (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = uint64(0) } else { (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = Xsqlite3WhereExprUsage(tls, pMaskSet, (*Expr)(unsafe.Pointer(pExpr)).FpRight) @@ -127530,9 +125385,9 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s (*WhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect = 0 prereqAll = Xsqlite3WhereExprUsageNN(tls, pMaskSet, pExpr) if (*WhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect != 0 { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x1000)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_VARSELECT)) } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0) { var x Bitmask = Xsqlite3WhereGetMask(tls, pMaskSet, int32((*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable)) prereqAll = prereqAll | (x) extraRight = (x - uint64(1)) // ON clause terms may not be used with an index @@ -127553,9 +125408,9 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s var pRight uintptr = Xsqlite3ExprSkipCollate(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) var opMask U16 if ((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight & prereqLeft) == uint64(0) { - opMask = uint16(0x1fff) + opMask = WO_ALL } else { - opMask = uint16(0x0800) + opMask = WO_EQUIV } if (*WhereTerm)(unsafe.Pointer(pTerm)).FiField > 0 { @@ -127564,12 +125419,12 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s } if exprMightBeIndexed(tls, pSrc, prereqLeft, bp /* &aiCurCol[0] */, pLeft, op) != 0 { - (*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */ + uintptr(0)*4)) - *(*int32)(unsafe.Pointer(pTerm + 40 /* &.u */)) = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */ + uintptr(1)*4)) + (*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */)) + *(*int32)(unsafe.Pointer(pTerm + 40 /* &.u */)) = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */ + 1*4)) (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = (U16(int32(operatorMask(tls, op)) & int32(opMask))) } - if op == 45 { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0800)) + if op == TK_IS { + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_IS)) } if (pRight != 0) && (exprMightBeIndexed(tls, pSrc, (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight, bp /* &aiCurCol[0] */, pRight, op) != 0) { @@ -127584,35 +125439,35 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s Xsqlite3ExprDelete(tls, db, pDup) return } - idxNew = whereClauseInsert(tls, pWC, pDup, (uint16(0x0002 | 0x0001))) + idxNew = whereClauseInsert(tls, pWC, pDup, (uint16(TERM_VIRTUAL | TERM_DYNAMIC))) if idxNew == 0 { return } pNew = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*64) markTermAsChild(tls, pWC, idxNew, idxTerm) - if op == 45 { - *(*U16)(unsafe.Pointer(pNew + 18 /* &.wtFlags */)) |= U16((0x0800)) + if op == TK_IS { + *(*U16)(unsafe.Pointer(pNew + 18 /* &.wtFlags */)) |= U16((TERM_IS)) } pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*64) - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_COPIED)) if termIsEquivalence(tls, pParse, pDup) != 0 { - *(*U16)(unsafe.Pointer(pTerm + 20 /* &.eOperator */)) |= U16((0x0800)) - eExtraOp = U16(0x0800) + *(*U16)(unsafe.Pointer(pTerm + 20 /* &.eOperator */)) |= U16((WO_EQUIV)) + eExtraOp = WO_EQUIV } } else { pDup = pExpr pNew = pTerm } *(*U16)(unsafe.Pointer(pNew + 18 /* &.wtFlags */)) |= U16((int32(exprCommute(tls, pParse, pDup)))) - (*WhereTerm)(unsafe.Pointer(pNew)).FleftCursor = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */ + uintptr(0)*4)) - *(*int32)(unsafe.Pointer(pNew + 40 /* &.u */)) = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */ + uintptr(1)*4)) + (*WhereTerm)(unsafe.Pointer(pNew)).FleftCursor = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */)) + *(*int32)(unsafe.Pointer(pNew + 40 /* &.u */)) = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */ + 1*4)) (*WhereTerm)(unsafe.Pointer(pNew)).FprereqRight = (prereqLeft | extraRight) (*WhereTerm)(unsafe.Pointer(pNew)).FprereqAll = prereqAll (*WhereTerm)(unsafe.Pointer(pNew)).FeOperator = (U16((int32(operatorMask(tls, int32((*Expr)(unsafe.Pointer(pDup)).Fop))) + int32(eExtraOp)) & int32(opMask))) } - } else if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 48) && (int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == 44) { + } else if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_BETWEEN) && (int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND) { var pList uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) var i int32 @@ -127623,13 +125478,13 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s Xsqlite3ExprDup(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, 0), Xsqlite3ExprDup(tls, db, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FpExpr, 0)) transferJoinMarkings(tls, pNewExpr, pExpr) - idxNew = whereClauseInsert(tls, pWC, pNewExpr, (uint16(0x0002 | 0x0001))) + idxNew = whereClauseInsert(tls, pWC, pNewExpr, (uint16(TERM_VIRTUAL | TERM_DYNAMIC))) exprAnalyze(tls, pSrc, pWC, idxNew) pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*64) markTermAsChild(tls, pWC, idxNew, idxTerm) } - } else if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 43 { + } else if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_OR { exprAnalyzeOrTerm(tls, pSrc, pWC, idxTerm) pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*64) @@ -127647,7 +125502,7 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s // for LIKE) then the lower-bound is made all uppercase and the upper- // bound is made all lowercase so that the bounds also work when comparing // BLOBs. - if (int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == 44) && + if (int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND) && (isLikeOrGlob(tls, pParse, pExpr, bp+8 /* &pStr1 */, bp+16 /* &isComplete */, bp+20 /* &noCase */) != 0) { var pLeft uintptr // LHS of LIKE/GLOB operator var pStr2 uintptr // Copy of pStr1 - RHS of LIKE/GLOB operator @@ -127656,9 +125511,9 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s var idxNew1 int32 var idxNew2 int32 var zCollSeqName uintptr // Name of collating sequence - var wtFlags U16 = (U16((0x0100 | 0x0002) | 0x0001)) + var wtFlags U16 = (U16((TERM_LIKEOPT | TERM_VIRTUAL) | TERM_DYNAMIC)) - pLeft = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + uintptr(1)*32)).FpExpr + pLeft = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + 1*32)).FpExpr pStr2 = Xsqlite3ExprDup(tls, db, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStr1 */)), 0) // Convert the lower bound to upper-case and the upper bound to @@ -127667,7 +125522,7 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s if (*(*int32)(unsafe.Pointer(bp + 20 /* noCase */)) != 0) && !(int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed) != 0) { var i int32 var c int8 - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0400)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_LIKE)) for i = 0; (int32(libc.AssignInt8(&c, *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pStr1 */)) + 8 /* &.u */)) + uintptr(i)))))) != 0; i++ { *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pStr1 */)) + 8 /* &.u */)) + uintptr(i))) = (int8((int32(c)) & ^(int32(Xsqlite3CtypeMap[uint8(c)]) & 0x20))) *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pStr2 + 8 /* &.u */)) + uintptr(i))) = int8(Xsqlite3UpperToLower[uint8(c)]) @@ -127699,7 +125554,7 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s return uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)) }() pNewExpr1 = Xsqlite3ExprDup(tls, db, pLeft, 0) - pNewExpr1 = Xsqlite3PExpr(tls, pParse, 57, + pNewExpr1 = Xsqlite3PExpr(tls, pParse, TK_GE, Xsqlite3ExprAddCollateString(tls, pParse, pNewExpr1, zCollSeqName), *(*uintptr)(unsafe.Pointer(bp + 8 /* pStr1 */))) transferJoinMarkings(tls, pNewExpr1, pExpr) @@ -127707,7 +125562,7 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s exprAnalyze(tls, pSrc, pWC, idxNew1) pNewExpr2 = Xsqlite3ExprDup(tls, db, pLeft, 0) - pNewExpr2 = Xsqlite3PExpr(tls, pParse, 56, + pNewExpr2 = Xsqlite3PExpr(tls, pParse, TK_LT, Xsqlite3ExprAddCollateString(tls, pParse, pNewExpr2, zCollSeqName), pStr2) transferJoinMarkings(tls, pNewExpr2, pExpr) @@ -127729,7 +125584,7 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s // This information is used by the xBestIndex methods of // virtual tables. The native query optimizer does not attempt // to do anything with MATCH functions. - if int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == 44 { + if int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND { *(*uintptr)(unsafe.Pointer(bp + 40 /* pRight */)) = uintptr(0) *(*uintptr)(unsafe.Pointer(bp + 32 /* pLeft */)) = uintptr(0) var res int32 = isAuxiliaryVtabOperator(tls, db, pExpr, bp+24 /* &eOp2 */, bp+32 /* &pLeft */, bp+40 /* &pRight */) @@ -127743,23 +125598,23 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s prereqColumn = Xsqlite3WhereExprUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(bp + 32 /* pLeft */))) if (prereqExpr & prereqColumn) == uint64(0) { var pNewExpr uintptr - pNewExpr = Xsqlite3PExpr(tls, pParse, 46, + pNewExpr = Xsqlite3PExpr(tls, pParse, TK_MATCH, uintptr(0), Xsqlite3ExprDup(tls, db, *(*uintptr)(unsafe.Pointer(bp + 40 /* pRight */)), 0)) - if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0)) && (pNewExpr != 0) { - *(*U32)(unsafe.Pointer(pNewExpr + 4 /* &.flags */)) |= (U32(0x000001)) + if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0)) && (pNewExpr != 0) { + *(*U32)(unsafe.Pointer(pNewExpr + 4 /* &.flags */)) |= (EP_FromJoin) (*Expr)(unsafe.Pointer(pNewExpr)).FiRightJoinTable = (*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable } - idxNew = whereClauseInsert(tls, pWC, pNewExpr, (uint16(0x0002 | 0x0001))) + idxNew = whereClauseInsert(tls, pWC, pNewExpr, (uint16(TERM_VIRTUAL | TERM_DYNAMIC))) pNewTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*64) (*WhereTerm)(unsafe.Pointer(pNewTerm)).FprereqRight = prereqExpr (*WhereTerm)(unsafe.Pointer(pNewTerm)).FleftCursor = (*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* pLeft */)))).FiTable *(*int32)(unsafe.Pointer(pNewTerm + 40 /* &.u */)) = int32((*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* pLeft */)))).FiColumn) - (*WhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = U16(0x0040) + (*WhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = WO_AUX (*WhereTerm)(unsafe.Pointer(pNewTerm)).FeMatchOp = *(*uint8)(unsafe.Pointer(bp + 24 /* eOp2 */)) markTermAsChild(tls, pWC, idxNew, idxTerm) pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*64) - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_COPIED)) (*WhereTerm)(unsafe.Pointer(pNewTerm)).FprereqAll = (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll } { @@ -127778,12 +125633,12 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s // // This is only required if at least one side of the comparison operation // is not a sub-select. - if ((((int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == 44) && - ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 53) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 45))) && + if ((((int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND) && + ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_EQ) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IS))) && ((libc.AssignInt32(&nLeft, Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft))) > 1)) && (Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) == nLeft)) && - ((((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fflags & U32(0x000800)) == U32(0)) || - (((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpRight)).Fflags & U32(0x000800)) == U32(0))) { + ((((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fflags & EP_xIsSelect) == U32(0)) || + (((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpRight)).Fflags & EP_xIsSelect) == U32(0))) { var i int32 for i = 0; i < nLeft; i++ { var idxNew int32 @@ -127793,11 +125648,11 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s pNew = Xsqlite3PExpr(tls, pParse, int32((*Expr)(unsafe.Pointer(pExpr)).Fop), pLeft, pRight) transferJoinMarkings(tls, pNew, pExpr) - idxNew = whereClauseInsert(tls, pWC, pNew, uint16(0x0001)) + idxNew = whereClauseInsert(tls, pWC, pNew, TERM_DYNAMIC) exprAnalyze(tls, pSrc, pWC, idxNew) } pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*64) - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004 | 0x0002)) // Disable the original + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED | TERM_VIRTUAL)) // Disable the original (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = U16(0) } @@ -127809,14 +125664,14 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s // // This only works if the RHS is a simple SELECT (not a compound) that does // not use window functions. - if (((((int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == 44) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 49)) && ((*WhereTerm)(unsafe.Pointer(pTerm)).FiField == 0)) && - (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == 174)) && + if (((((int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IN)) && ((*WhereTerm)(unsafe.Pointer(pTerm)).FiField == 0)) && + (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_VECTOR)) && ((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpPrior == uintptr(0))) && ((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpWin == uintptr(0)) { var i int32 for i = 0; i < Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft); i++ { var idxNew int32 - idxNew = whereClauseInsert(tls, pWC, pExpr, uint16(0x0002)) + idxNew = whereClauseInsert(tls, pWC, pExpr, TERM_VIRTUAL) (*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*64)).FiField = (i + 1) exprAnalyze(tls, pSrc, pWC, idxNew) markTermAsChild(tls, pWC, idxNew, idxTerm) @@ -127829,31 +125684,31 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s // virtual term of that form. // // Note that the virtual term must be tagged with TERM_VNULL. - if ((((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 51) && - (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == 164)) && + if ((((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NOTNULL) && + (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_COLUMN)) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).FiColumn) >= 0)) && - !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0))) && - ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0) { + !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0))) && + ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0) { var pNewExpr uintptr var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft var idxNew int32 var pNewTerm uintptr - pNewExpr = Xsqlite3PExpr(tls, pParse, 54, + pNewExpr = Xsqlite3PExpr(tls, pParse, TK_GT, Xsqlite3ExprDup(tls, db, pLeft, 0), - Xsqlite3ExprAlloc(tls, db, 119, uintptr(0), 0)) + Xsqlite3ExprAlloc(tls, db, TK_NULL, uintptr(0), 0)) idxNew = whereClauseInsert(tls, pWC, pNewExpr, - (uint16((0x0002 | 0x0001) | 0x0080))) + (uint16((TERM_VIRTUAL | TERM_DYNAMIC) | TERM_VNULL))) if idxNew != 0 { pNewTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*64) (*WhereTerm)(unsafe.Pointer(pNewTerm)).FprereqRight = uint64(0) (*WhereTerm)(unsafe.Pointer(pNewTerm)).FleftCursor = (*Expr)(unsafe.Pointer(pLeft)).FiTable *(*int32)(unsafe.Pointer(pNewTerm + 40 /* &.u */)) = int32((*Expr)(unsafe.Pointer(pLeft)).FiColumn) - (*WhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = (U16(int32(0x0002) << (54 - 53))) + (*WhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = (U16(int32(WO_EQ) << (TK_GT - TK_EQ))) markTermAsChild(tls, pWC, idxNew, idxTerm) pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*64) - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_COPIED)) (*WhereTerm)(unsafe.Pointer(pNewTerm)).FprereqAll = (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll } } @@ -127865,7 +125720,7 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s *(*Bitmask)(unsafe.Pointer(pTerm + 48 /* &.prereqRight */)) |= (extraRight) } -var ops = [2]U8{U8(57), U8(55)} /* sqlite3.c:145161:21 */ +var ops = [2]U8{TK_GE, TK_LE} /* sqlite3.c:145161:21 */ // ************************************************************************** // @@ -127926,12 +125781,12 @@ __1: goto __3 } { - if (int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags) & 0x0001) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags) & TERM_DYNAMIC) != 0 { Xsqlite3ExprDelete(tls, db, (*WhereTerm)(unsafe.Pointer(a)).FpExpr) } - if (int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags) & 0x0010) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags) & TERM_ORINFO) != 0 { whereOrInfoDelete(tls, db, *(*uintptr)(unsafe.Pointer(a + 40 /* &.u */))) - } else if (int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags) & 0x0020) != 0 { + } else if (int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags) & TERM_ANDINFO) != 0 { whereAndInfoDelete(tls, db, *(*uintptr)(unsafe.Pointer(a + 40 /* &.u */))) } @@ -127954,13 +125809,13 @@ __3: // tree. func Xsqlite3WhereExprUsageNN(tls *libc.TLS, pMaskSet uintptr, p uintptr) Bitmask { /* sqlite3.c:145504:24: */ var mask Bitmask - if (int32((*Expr)(unsafe.Pointer(p)).Fop) == 164) && !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000008))) != U32(0)) { + if (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN) && !(((*Expr)(unsafe.Pointer((p))).Fflags & (EP_FixedCol)) != U32(0)) { return Xsqlite3WhereGetMask(tls, pMaskSet, (*Expr)(unsafe.Pointer(p)).FiTable) - } else if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x004000 | 0x800000))) != U32(0) { + } else if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(EP_TokenOnly | EP_Leaf))) != U32(0) { return uint64(0) } - if int32((*Expr)(unsafe.Pointer(p)).Fop) == 176 { + if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_IF_NULL_ROW { mask = Xsqlite3WhereGetMask(tls, pMaskSet, (*Expr)(unsafe.Pointer(p)).FiTable) } else { mask = uint64(0) @@ -127971,15 +125826,15 @@ func Xsqlite3WhereExprUsageNN(tls *libc.TLS, pMaskSet uintptr, p uintptr) Bitmas if (*Expr)(unsafe.Pointer(p)).FpRight != 0 { mask = mask | (Xsqlite3WhereExprUsageNN(tls, pMaskSet, (*Expr)(unsafe.Pointer(p)).FpRight)) - } else if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000800))) != U32(0) { - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000020))) != U32(0) { + } else if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_xIsSelect)) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_VarSelect)) != U32(0) { (*WhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect = 1 } mask = mask | (exprSelectUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))) } else if *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0 { mask = mask | (Xsqlite3WhereExprListUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))) } - if ((int32((*Expr)(unsafe.Pointer(p)).Fop) == 169) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == 165)) && (*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) != 0) { + if ((int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_FUNCTION) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_AGG_FUNCTION)) && (*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) != 0) { mask = mask | (Xsqlite3WhereExprListUsage(tls, pMaskSet, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)))).FpPartition)) mask = mask | (Xsqlite3WhereExprListUsage(tls, pMaskSet, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)))).FpOrderBy)) mask = mask | (Xsqlite3WhereExprUsage(tls, pMaskSet, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)))).FpFilter)) @@ -128044,7 +125899,7 @@ func Xsqlite3WhereTabFuncArgs(tls *libc.TLS, pParse uintptr, pItem uintptr, pWC } for j = libc.AssignInt32(&k, 0); j < (*ExprList)(unsafe.Pointer(pArgs)).FnExpr; j++ { var pRhs uintptr - for (k < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) && ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(k)*32)).FcolFlags) & 0x0002) == 0) { + for (k < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) && ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(k)*32)).FcolFlags) & COLFLAG_HIDDEN) == 0) { k++ } if k >= int32((*Table)(unsafe.Pointer(pTab)).FnCol) { @@ -128052,20 +125907,20 @@ func Xsqlite3WhereTabFuncArgs(tls *libc.TLS, pParse uintptr, pItem uintptr, pWC libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName, j)) return } - pColRef = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 164, uintptr(0), 0) + pColRef = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_COLUMN, uintptr(0), 0) if pColRef == uintptr(0) { return } (*Expr)(unsafe.Pointer(pColRef)).FiTable = (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor (*Expr)(unsafe.Pointer(pColRef)).FiColumn = YnVar(libc.PostIncInt32(&k, 1)) *(*uintptr)(unsafe.Pointer(pColRef + 64 /* &.y */)) = pTab - pRhs = Xsqlite3PExpr(tls, pParse, 171, + pRhs = Xsqlite3PExpr(tls, pParse, TK_UPLUS, Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*ExprList_item)(unsafe.Pointer((pArgs+8 /* &.a */)+uintptr(j)*32)).FpExpr, 0), uintptr(0)) - pTerm = Xsqlite3PExpr(tls, pParse, 53, pColRef, pRhs) - if (int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & 0x0008) != 0 { + pTerm = Xsqlite3PExpr(tls, pParse, TK_EQ, pColRef, pRhs) + if (int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & JT_LEFT) != 0 { Xsqlite3SetJoinExpr(tls, pTerm, (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor) } - whereClauseInsert(tls, pWC, pTerm, uint16(0x0001)) + whereClauseInsert(tls, pWC, pTerm, TERM_DYNAMIC) } } @@ -128267,7 +126122,7 @@ __2: goto __3 __3: ; - if !(int32((*WhereOrSet)(unsafe.Pointer(pSet)).Fn) < 3) { + if !(int32((*WhereOrSet)(unsafe.Pointer(pSet)).Fn) < N_OR_COST) { goto __6 } p = ((pSet + 8 /* &.a */) + uintptr(libc.PostIncUint16(&(*WhereOrSet)(unsafe.Pointer(pSet)).Fn, 1))*16) @@ -128365,11 +126220,11 @@ func whereScanNext(tls *libc.TLS, pScan uintptr) uintptr { /* sqlite3.c:145854:1 ((int32(iColumn) != (-2)) || (Xsqlite3ExprCompareSkip(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft, (*WhereScan)(unsafe.Pointer(pScan)).FpIdxExpr, iCur) == 0))) && - ((int32((*WhereScan)(unsafe.Pointer(pScan)).FiEquiv) <= 1) || !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000001))) != U32(0))) { - if (((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0800) != 0) && + ((int32((*WhereScan)(unsafe.Pointer(pScan)).FiEquiv) <= 1) || !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_FromJoin)) != U32(0))) { + if (((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_EQUIV) != 0) && (int32((*WhereScan)(unsafe.Pointer(pScan)).FnEquiv) < (int32(uint64(unsafe.Sizeof([11]int32{})) / uint64(unsafe.Sizeof(int32(0))))))) && (int32((*Expr)(unsafe.Pointer((libc.AssignUintptr(&pX, Xsqlite3ExprSkipCollateAndLikely(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight))))).Fop) == - 164) { + TK_COLUMN) { var j int32 for j = 0; j < int32((*WhereScan)(unsafe.Pointer(pScan)).FnEquiv); j++ { if (*(*int32)(unsafe.Pointer((pScan + 44 /* &.aiCur */) + uintptr(j)*4)) == (*Expr)(unsafe.Pointer(pX)).FiTable) && @@ -128385,7 +126240,7 @@ func whereScanNext(tls *libc.TLS, pScan uintptr) uintptr { /* sqlite3.c:145854:1 } if (U32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (*WhereScan)(unsafe.Pointer(pScan)).FopMask) != U32(0) { // Verify the affinity and collating sequence match - if ((*WhereScan)(unsafe.Pointer(pScan)).FzCollName != 0) && ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0100) == 0) { + if ((*WhereScan)(unsafe.Pointer(pScan)).FzCollName != 0) && ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_ISNULL) == 0) { var pColl uintptr var pParse uintptr = (*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse pX = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr @@ -128401,10 +126256,10 @@ func whereScanNext(tls *libc.TLS, pScan uintptr) uintptr { /* sqlite3.c:145854:1 goto __2 } } - if ((((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (0x0002 | 0x0080)) != 0) && - (int32((*Expr)(unsafe.Pointer((libc.AssignUintptr(&pX, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight)))).Fop) == 164)) && - ((*Expr)(unsafe.Pointer(pX)).FiTable == *(*int32)(unsafe.Pointer((pScan + 44 /* &.aiCur */) + uintptr(0)*4)))) && - (int32((*Expr)(unsafe.Pointer(pX)).FiColumn) == int32(*(*I16)(unsafe.Pointer((pScan + 88 /* &.aiColumn */) + uintptr(0)*2)))) { + if ((((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (WO_EQ | WO_IS)) != 0) && + (int32((*Expr)(unsafe.Pointer((libc.AssignUintptr(&pX, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight)))).Fop) == TK_COLUMN)) && + ((*Expr)(unsafe.Pointer(pX)).FiTable == *(*int32)(unsafe.Pointer((pScan + 44 /* &.aiCur */))))) && + (int32((*Expr)(unsafe.Pointer(pX)).FiColumn) == int32(*(*I16)(unsafe.Pointer((pScan + 88 /* &.aiColumn */))))) { goto __2 } @@ -128470,7 +126325,7 @@ func whereScanInit(tls *libc.TLS, pScan uintptr, pWC uintptr, iCur int32, iColum (*WhereScan)(unsafe.Pointer(pScan)).FzCollName = uintptr(0) (*WhereScan)(unsafe.Pointer(pScan)).FopMask = opMask (*WhereScan)(unsafe.Pointer(pScan)).Fk = 0 - *(*int32)(unsafe.Pointer((pScan + 44 /* &.aiCur */) + uintptr(0)*4)) = iCur + *(*int32)(unsafe.Pointer((pScan + 44 /* &.aiCur */))) = iCur (*WhereScan)(unsafe.Pointer(pScan)).FnEquiv = uint8(1) (*WhereScan)(unsafe.Pointer(pScan)).FiEquiv = uint8(1) if pIdx != 0 { @@ -128479,7 +126334,7 @@ func whereScanInit(tls *libc.TLS, pScan uintptr, pWC uintptr, iCur int32, iColum if iColumn == (-2) { (*WhereScan)(unsafe.Pointer(pScan)).FpIdxExpr = (*ExprList_item)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FaColExpr + 8 /* &.a */) + uintptr(j)*32)).FpExpr (*WhereScan)(unsafe.Pointer(pScan)).FzCollName = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*8)) - *(*I16)(unsafe.Pointer((pScan + 88 /* &.aiColumn */) + uintptr(0)*2)) = int16(-2) + *(*I16)(unsafe.Pointer((pScan + 88 /* &.aiColumn */))) = int16(-2) return whereScanInitIndexExpr(tls, pScan) } else if iColumn == int32((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FiPKey) { iColumn = -1 @@ -128490,7 +126345,7 @@ func whereScanInit(tls *libc.TLS, pScan uintptr, pWC uintptr, iCur int32, iColum } else if iColumn == (-2) { return uintptr(0) } - *(*I16)(unsafe.Pointer((pScan + 88 /* &.aiColumn */) + uintptr(0)*2)) = I16(iColumn) + *(*I16)(unsafe.Pointer((pScan + 88 /* &.aiColumn */))) = I16(iColumn) return whereScanNext(tls, pScan) } @@ -128526,7 +126381,7 @@ func Xsqlite3WhereFindTerm(tls *libc.TLS, pWC uintptr, iCur int32, iColumn int32 // var scan WhereScan at bp, 112 p = whereScanInit(tls, bp /* &scan */, pWC, iCur, iColumn, op, pIdx) - op = op & (U32(0x0002 | 0x0080)) + op = op & (U32(WO_EQ | WO_IS)) for p != 0 { if ((*WhereTerm)(unsafe.Pointer(p)).FprereqRight & notReady) == uint64(0) { if ((*WhereTerm)(unsafe.Pointer(p)).FprereqRight == uint64(0)) && ((U32((*WhereTerm)(unsafe.Pointer(p)).FeOperator) & op) != U32(0)) { @@ -128553,7 +126408,7 @@ func findIndexCol(tls *libc.TLS, pParse uintptr, pList uintptr, iBase int32, pId for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ { var p uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FpExpr) - if ((int32((*Expr)(unsafe.Pointer(p)).Fop) == 164) && + if ((int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN) && (int32((*Expr)(unsafe.Pointer(p)).FiColumn) == int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(iCol)*2))))) && ((*Expr)(unsafe.Pointer(p)).FiTable == iBase) { var pColl uintptr = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FpExpr) @@ -128600,15 +126455,15 @@ func isDistinctRedundant(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWC ui if (*SrcList)(unsafe.Pointer(pTabList)).FnSrc != 1 { return 0 } - iBase = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FiCursor - pTab = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FpTab + iBase = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FiCursor + pTab = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FpTab // If any of the expressions is an IPK column on table iBase, then return // true. Note: The (p->iTable==iBase) part of this test may be false if the // current SELECT is a correlated sub-query. for i = 0; i < (*ExprList)(unsafe.Pointer(pDistinct)).FnExpr; i++ { var p uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer((pDistinct+8 /* &.a */)+uintptr(i)*32)).FpExpr) - if ((int32((*Expr)(unsafe.Pointer(p)).Fop) == 164) && ((*Expr)(unsafe.Pointer(p)).FiTable == iBase)) && (int32((*Expr)(unsafe.Pointer(p)).FiColumn) < 0) { + if ((int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN) && ((*Expr)(unsafe.Pointer(p)).FiTable == iBase)) && (int32((*Expr)(unsafe.Pointer(p)).FiColumn) < 0) { return 1 } } @@ -128626,11 +126481,11 @@ func isDistinctRedundant(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWC ui // 3. All of those index columns for which the WHERE clause does not // contain a "col=X" term are subject to a NOT NULL constraint. for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { - if !(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0) { + if !(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None) { continue } for i = 0; i < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol); i++ { - if uintptr(0) == Xsqlite3WhereFindTerm(tls, pWC, iBase, i, ^uint64(0), uint32(0x0002), pIdx) { + if uintptr(0) == Xsqlite3WhereFindTerm(tls, pWC, iBase, i, libc.CplUint64(uint64(0)), WO_EQ, pIdx) { if findIndexCol(tls, pParse, pDistinct, iBase, pIdx, i) < 0 { break } @@ -128681,17 +126536,17 @@ __1: if (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 != iTabCur { goto __2 } - if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 89 { - (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(77) + if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column { + (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = OP_Copy (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = ((*VdbeOp)(unsafe.Pointer(pOp)).Fp2 + iRegister) (*VdbeOp)(unsafe.Pointer(pOp)).Fp2 = (*VdbeOp)(unsafe.Pointer(pOp)).Fp3 (*VdbeOp)(unsafe.Pointer(pOp)).Fp3 = 0 - } else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 127 { + } else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Rowid { if iAutoidxCur != 0 { - (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(119) + (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = OP_Sequence (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = iAutoidxCur } else { - (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(72) + (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = OP_Null (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = 0 (*VdbeOp)(unsafe.Pointer(pOp)).Fp3 = 0 } @@ -128720,12 +126575,12 @@ func termCanDriveIndex(tls *libc.TLS, pTerm uintptr, pSrc uintptr, notReady Bitm if (*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor { return 0 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (0x0002 | 0x0080)) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (WO_EQ | WO_IS)) == 0 { return 0 } - if (((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & 0x0008) != 0) && - !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000001))) != U32(0))) && - ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0080) != 0) { + if (((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & JT_LEFT) != 0) && + !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_FromJoin)) != U32(0))) && + ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_IS) != 0) { // Cannot use an IS term from the WHERE clause as an index driver for // the RHS of a LEFT JOIN. Such a term can only be used if it is from // the ON clause. @@ -128792,7 +126647,7 @@ func constructAutomaticIndex(tls *libc.TLS, pParse uintptr, pWC uintptr, pSrc ui // transient index on 2nd and subsequent iterations of the loop. v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe - addrInit = Xsqlite3VdbeAddOp0(tls, v, 17) + addrInit = Xsqlite3VdbeAddOp0(tls, v, OP_Once) // Count the number of columns that will be added to the index // and used to match WHERE clause constraints @@ -128809,8 +126664,8 @@ __1: pExpr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr // table of a LEFT JOIN if !(((((*WhereLoop)(unsafe.Pointer(pLoop)).Fprereq == uint64(0)) && - ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0002) == 0)) && - !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0))) && + ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VIRTUAL) == 0)) && + !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0))) && (Xsqlite3ExprIsTableConstant(tls, pExpr, (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor) != 0)) { goto __4 } @@ -128831,7 +126686,7 @@ __4: if !(!(sentWarning != 0)) { goto __6 } - Xsqlite3_log(tls, (28 | (int32(1) << 8)), + Xsqlite3_log(tls, (SQLITE_WARNING | (int32(1) << 8)), ts+19226 /* "automatic index ..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTable)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTable)).FaCol+uintptr(iCol)*32)).FzName)) sentWarning = U8(1) @@ -128861,8 +126716,8 @@ __3: ; *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ /* &.nEq */)) = libc.AssignPtrUint16(pLoop+44 /* &.nLTerm */, U16(nKeyCol)) - (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = (U32(((0x00000001 | 0x00000040) | 0x00000200) | - 0x00004000)) + (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = (U32(((WHERE_COLUMN_EQ | WHERE_IDX_ONLY) | WHERE_INDEXED) | + WHERE_AUTO_INDEX)) // Count the number of additional columns needed to create a // covering index. A "covering index" is an index that contains all @@ -129008,7 +126863,7 @@ __24: // Create the automatic index (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - Xsqlite3VdbeAddOp2(tls, v, 99, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, (nKeyCol + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenAutoindex, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, (nKeyCol + 1)) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx) // Fill the automatic index with content @@ -129017,28 +126872,28 @@ __24: goto __28 } regYield = (*SrcList_item)(unsafe.Pointer(pTabItem)).FregReturn - addrCounter = Xsqlite3VdbeAddOp2(tls, v, 69, 0, 0) - Xsqlite3VdbeAddOp3(tls, v, 13, regYield, 0, (*SrcList_item)(unsafe.Pointer(pTabItem)).FaddrFillSub) - addrTop = Xsqlite3VdbeAddOp1(tls, v, 14, regYield) + addrCounter = Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, 0) + Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regYield, 0, (*SrcList_item)(unsafe.Pointer(pTabItem)).FaddrFillSub) + addrTop = Xsqlite3VdbeAddOp1(tls, v, OP_Yield, regYield) goto __29 __28: - addrTop = Xsqlite3VdbeAddOp1(tls, v, 37, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur) + addrTop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur) __29: ; if !(pPartial != 0) { goto __30 } iContinue = Xsqlite3VdbeMakeLabel(tls, pParse) - Xsqlite3ExprIfFalse(tls, pParse, pPartial, iContinue, 0x10) - *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (U32(0x00020000)) + Xsqlite3ExprIfFalse(tls, pParse, pPartial, iContinue, SQLITE_JUMPIFNULL) + *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (WHERE_PARTIALIDX) __30: ; regRecord = Xsqlite3GetTempReg(tls, pParse) regBase = Xsqlite3GenerateIndexKey(tls, pParse, pIdx, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, regRecord, 0, uintptr(0), uintptr(0), 0) - Xsqlite3VdbeAddOp2(tls, v, 130, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, regRecord) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, regRecord) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_USESEEKRESULT) if !(pPartial != 0) { goto __31 } @@ -129056,8 +126911,8 @@ __31: libc.SetBitFieldPtr8Uint32(pTabItem+60 /* &.fg */ +4 /* &.viaCoroutine */, uint32(0), 4, 0x10) goto __33 __32: - Xsqlite3VdbeAddOp2(tls, v, 5, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (addrTop + 1)) - Xsqlite3VdbeChangeP5(tls, v, uint16(3)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (addrTop + 1)) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_STMTSTATUS_AUTOINDEX) __33: ; Xsqlite3VdbeJumpHere(tls, v, addrTop) @@ -129102,10 +126957,10 @@ __1: goto __2 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & ^libc.Int32(0x0800)) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & libc.CplInt32(WO_EQUIV)) == 0 { goto __2 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0080) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VNULL) != 0 { goto __2 } @@ -129129,10 +126984,10 @@ __3: var n int32 = (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr for i = 0; i < n; i++ { var pExpr uintptr = (*ExprList_item)(unsafe.Pointer((pOrderBy + 8 /* &.a */) + uintptr(i)*32)).FpExpr - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 164) || ((*Expr)(unsafe.Pointer(pExpr)).FiTable != (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN) || ((*Expr)(unsafe.Pointer(pExpr)).FiTable != (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor) { break } - if (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & 0x02) != 0 { + if (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & KEYINFO_ORDER_BIGNULL) != 0 { break } } @@ -129149,8 +127004,8 @@ __3: Xsqlite3ErrorMsg(tls, pParse, ts+5005 /* "out of memory" */, 0) return uintptr(0) } - pHidden = (pIdxInfo + uintptr(1)*96) - pIdxCons = (pHidden + uintptr(1)*16) + pHidden = (pIdxInfo + 1*96) + pIdxCons = (pHidden + 1*16) pIdxOrderBy = (pIdxCons + uintptr(nTerm)*12) pUsage = (pIdxOrderBy + uintptr(nOrderBy)*8) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy = nOrderBy @@ -129174,34 +127029,34 @@ __4: goto __5 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & ^libc.Int32(0x0800)) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & libc.CplInt32(WO_EQUIV)) == 0 { goto __5 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0080) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VNULL) != 0 { goto __5 } // tag-20191211-002: WHERE-clause constraints are not useful to the // right-hand table of a LEFT JOIN. See tag-20191211-001 for the // equivalent restriction for ordinary tables. - if ((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & 0x0008) != 0) && - !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000001))) != U32(0)) { + if ((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & JT_LEFT) != 0) && + !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_FromJoin)) != U32(0)) { goto __5 } (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).FiColumn = *(*int32)(unsafe.Pointer(pTerm + 40 /* &.u */)) (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).FiTermOffset = i - op = (U16(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x1fff)) - if int32(op) == 0x0001 { - op = U16(0x0002) + op = (U16(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_ALL)) + if int32(op) == WO_IN { + op = WO_EQ } - if int32(op) == 0x0040 { + if int32(op) == WO_AUX { (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = (*WhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp - } else if (int32(op) & (0x0100 | 0x0080)) != 0 { - if int32(op) == 0x0100 { - (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = uint8(71) + } else if (int32(op) & (WO_ISNULL | WO_IS)) != 0 { + if int32(op) == WO_ISNULL { + (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = SQLITE_INDEX_CONSTRAINT_ISNULL } else { - (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = uint8(72) + (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = SQLITE_INDEX_CONSTRAINT_IS } } else { (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = U8(op) @@ -129209,17 +127064,17 @@ __4: // the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The // following asserts verify this fact. - if ((int32(op) & ((((int32(0x0002) << (56 - 53)) | (int32(0x0002) << (55 - 53))) | (int32(0x0002) << (54 - 53))) | (int32(0x0002) << (57 - 53)))) != 0) && + if ((int32(op) & ((((int32(WO_EQ) << (TK_LT - TK_EQ)) | (int32(WO_EQ) << (TK_LE - TK_EQ))) | (int32(WO_EQ) << (TK_GT - TK_EQ))) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) != 0) && (Xsqlite3ExprIsVector(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight) != 0) { if j < 16 { mNoOmit = U16(int32(mNoOmit) | (int32(1) << j)) } - if int32(op) == (int32(0x0002) << (56 - 53)) { - (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = (uint8(int32(0x0002) << (55 - 53))) + if int32(op) == (int32(WO_EQ) << (TK_LT - TK_EQ)) { + (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = (uint8(int32(WO_EQ) << (TK_LE - TK_EQ))) } - if int32(op) == (int32(0x0002) << (54 - 53)) { - (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = (uint8(int32(0x0002) << (57 - 53))) + if int32(op) == (int32(WO_EQ) << (TK_GT - TK_EQ)) { + (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = (uint8(int32(WO_EQ) << (TK_GE - TK_EQ))) } } } @@ -129239,7 +127094,7 @@ __6: for i = 0; i < nOrderBy; i++ { var pExpr uintptr = (*ExprList_item)(unsafe.Pointer((pOrderBy + 8 /* &.a */) + uintptr(i)*32)).FpExpr (*sqlite3_index_orderby)(unsafe.Pointer(pIdxOrderBy + uintptr(i)*8)).FiColumn = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) - (*sqlite3_index_orderby)(unsafe.Pointer(pIdxOrderBy + uintptr(i)*8)).Fdesc = (uint8(int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & 0x01)) + (*sqlite3_index_orderby)(unsafe.Pointer(pIdxOrderBy + uintptr(i)*8)).Fdesc = (uint8(int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & KEYINFO_ORDER_DESC)) } *(*U16)(unsafe.Pointer(pmNoOmit)) = mNoOmit @@ -129269,8 +127124,8 @@ func vtabBestIndex(tls *libc.TLS, pParse uintptr, pTab uintptr, p uintptr) int32 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule + 24 /* &.xBestIndex */))))(tls, pVtab, p) - if (rc != 0) && (rc != 19) { - if rc == 7 { + if (rc != SQLITE_OK) && (rc != SQLITE_CONSTRAINT) { + if rc == SQLITE_NOMEM { Xsqlite3OomFault(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb) } else if !(int32((*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg) != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+2690 /* "%s" */, libc.VaList(bp, Xsqlite3ErrStr(tls, rc))) @@ -129391,8 +127246,8 @@ func whereKeyStats(tls *libc.TLS, pParse uintptr, pIdx uintptr, pRec uintptr, ro if res == 0 { // Record pRec is equal to sample i - *(*TRowcnt)(unsafe.Pointer(aStat + uintptr(0)*4)) = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*40)).FanLt + uintptr(iCol)*4)) - *(*TRowcnt)(unsafe.Pointer(aStat + uintptr(1)*4)) = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*40)).FanEq + uintptr(iCol)*4)) + *(*TRowcnt)(unsafe.Pointer(aStat)) = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*40)).FanLt + uintptr(iCol)*4)) + *(*TRowcnt)(unsafe.Pointer(aStat + 1*4)) = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*40)).FanEq + uintptr(iCol)*4)) } else { // At this point, the (iCol+1) field prefix of aSample[i] is the first // sample that is greater than pRec. Or, if i==pIdx->nSample then pRec @@ -129400,7 +127255,7 @@ func whereKeyStats(tls *libc.TLS, pParse uintptr, pIdx uintptr, pRec uintptr, ro var iUpper TRowcnt var iGap TRowcnt if i >= (*Index)(unsafe.Pointer(pIdx)).FnSample { - iUpper = TRowcnt(Xsqlite3LogEstToInt(tls, *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowLogEst + uintptr(0)*2)))) + iUpper = TRowcnt(Xsqlite3LogEstToInt(tls, *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowLogEst)))) } else { iUpper = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*40)).FanLt + uintptr(iCol)*4)) } @@ -129415,8 +127270,8 @@ func whereKeyStats(tls *libc.TLS, pParse uintptr, pIdx uintptr, pRec uintptr, ro } else { iGap = (iGap / TRowcnt(3)) } - *(*TRowcnt)(unsafe.Pointer(aStat + uintptr(0)*4)) = (iLower + iGap) - *(*TRowcnt)(unsafe.Pointer(aStat + uintptr(1)*4)) = *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaAvgEq + uintptr((nField-1))*4)) + *(*TRowcnt)(unsafe.Pointer(aStat)) = (iLower + iGap) + *(*TRowcnt)(unsafe.Pointer(aStat + 1*4)) = *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaAvgEq + uintptr((nField-1))*4)) } // Restore the pRec->nField value before returning. @@ -129438,7 +127293,7 @@ func whereRangeAdjust(tls *libc.TLS, pTerm uintptr, nNew LogEst) LogEst { /* sql if pTerm != 0 { if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb) <= 0 { nRet = LogEst(int32(nRet) + (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb))) - } else if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0080) == 0 { + } else if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VNULL) == 0 { nRet = int16(int32(nRet) - (20)) } } @@ -129450,7 +127305,7 @@ func Xsqlite3IndexColumnAffinity(tls *libc.TLS, db uintptr, pIdx uintptr, iCol i if !(int32((*Index)(unsafe.Pointer(pIdx)).FzColAff) != 0) { if Xsqlite3IndexAffinityStr(tls, db, pIdx) == uintptr(0) { - return int8(0x41) + return SQLITE_AFF_BLOB } } @@ -129499,7 +127354,7 @@ func whereRangeSkipScanEst(tls *libc.TLS, pParse uintptr, pLower uintptr, pUpper var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var nLower int32 = -1 var nUpper int32 = ((*Index)(unsafe.Pointer(p)).FnSample + 1) - var rc int32 = 0 + var rc int32 = SQLITE_OK var aff U8 = U8(Xsqlite3IndexColumnAffinity(tls, db, p, nEq)) var pColl uintptr @@ -129512,7 +127367,7 @@ func whereRangeSkipScanEst(tls *libc.TLS, pParse uintptr, pLower uintptr, pUpper rc = Xsqlite3Stat4ValueFromExpr(tls, pParse, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pLower)).FpExpr)).FpRight, aff, bp /* &p1 */) nLower = 0 } - if (pUpper != 0) && (rc == 0) { + if (pUpper != 0) && (rc == SQLITE_OK) { rc = Xsqlite3Stat4ValueFromExpr(tls, pParse, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pUpper)).FpExpr)).FpRight, aff, bp+8 /* &p2 */) if *(*uintptr)(unsafe.Pointer(bp + 8 /* p2 */)) != 0 { nUpper = 0 @@ -129524,15 +127379,15 @@ func whereRangeSkipScanEst(tls *libc.TLS, pParse uintptr, pLower uintptr, pUpper if (*(*uintptr)(unsafe.Pointer(bp /* p1 */)) != 0) || (*(*uintptr)(unsafe.Pointer(bp + 8 /* p2 */)) != 0) { var i int32 var nDiff int32 - for i = 0; (rc == 0) && (i < (*Index)(unsafe.Pointer(p)).FnSample); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Index)(unsafe.Pointer(p)).FnSample); i++ { rc = Xsqlite3Stat4Column(tls, db, (*IndexSample)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaSample+uintptr(i)*40)).Fp, (*IndexSample)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaSample+uintptr(i)*40)).Fn, nEq, bp+16 /* &pVal */) - if (rc == 0) && (*(*uintptr)(unsafe.Pointer(bp /* p1 */)) != 0) { + if (rc == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp /* p1 */)) != 0) { var res int32 = Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(bp /* p1 */)), *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), pColl) if res >= 0 { nLower++ } } - if (rc == 0) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* p2 */)) != 0) { + if (rc == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* p2 */)) != 0) { var res int32 = Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p2 */)), *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), pColl) if res >= 0 { nUpper++ @@ -129609,7 +127464,7 @@ func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower u bp := tls.Alloc(28) defer tls.Free(28) - var rc int32 = 0 + var rc int32 = SQLITE_OK var nOut int32 = int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnOut) var nNew LogEst @@ -129617,7 +127472,7 @@ func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower u var nEq int32 = int32(*(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ /* &.nEq */))) if (((*Index)(unsafe.Pointer(p)).FnSample > 0) && (nEq < (*Index)(unsafe.Pointer(p)).FnSampleCol)) && - ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (0x0800)) == 0) { + ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (SQLITE_Stat4)) == 0) { if nEq == (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid { *(*uintptr)(unsafe.Pointer(bp + 8 /* pRec */)) = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec // var a [2]TRowcnt at bp, 8 @@ -129660,8 +127515,8 @@ func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower u // Note: this call could be optimized away - since the same values must // have been requested when testing key $P in whereEqualScanEst(). whereKeyStats(tls, pParse, p, *(*uintptr)(unsafe.Pointer(bp + 8 /* pRec */)), 0, bp /* &a[0] */) - iLower = *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(0)*4)) - iUpper = (*(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(0)*4)) + *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(1)*4))) + iLower = *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */)) + iUpper = (*(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */)) + *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + 1*4))) } if *(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaSortOrder + uintptr(nEq))) != 0 { @@ -129686,16 +127541,16 @@ func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower u // Values extracted from pExpr var pExpr uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pLower)).FpExpr)).FpRight rc = Xsqlite3Stat4ProbeSetValue(tls, pParse, p, bp+8 /* &pRec */, pExpr, nBtm, nEq, bp+16 /* &n */) - if (rc == 0) && (*(*int32)(unsafe.Pointer(bp + 16 /* n */)) != 0) { + if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 16 /* n */)) != 0) { var iNew TRowcnt - var mask U16 = (U16((int32(0x0002) << (54 - 53)) | (int32(0x0002) << (55 - 53)))) + var mask U16 = (U16((int32(WO_EQ) << (TK_GT - TK_EQ)) | (int32(WO_EQ) << (TK_LE - TK_EQ)))) if Xsqlite3ExprVectorSize(tls, pExpr) > *(*int32)(unsafe.Pointer(bp + 16 /* n */)) { - mask = (U16((int32(0x0002) << (55 - 53)) | (int32(0x0002) << (56 - 53)))) + mask = (U16((int32(WO_EQ) << (TK_LE - TK_EQ)) | (int32(WO_EQ) << (TK_LT - TK_EQ)))) } iLwrIdx = whereKeyStats(tls, pParse, p, *(*uintptr)(unsafe.Pointer(bp + 8 /* pRec */)), 0, bp /* &a[0] */) - iNew = (*(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(0)*4)) + (func() uint32 { + iNew = (*(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */)) + (func() uint32 { if (int32((*WhereTerm)(unsafe.Pointer(pLower)).FeOperator) & int32(mask)) != 0 { - return *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(1)*4)) + return *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + 1*4)) } return uint32(0) }())) @@ -129713,16 +127568,16 @@ func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower u // Values extracted from pExpr var pExpr uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pUpper)).FpExpr)).FpRight rc = Xsqlite3Stat4ProbeSetValue(tls, pParse, p, bp+8 /* &pRec */, pExpr, nTop, nEq, bp+20 /* &n */) - if (rc == 0) && (*(*int32)(unsafe.Pointer(bp + 20 /* n */)) != 0) { + if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 20 /* n */)) != 0) { var iNew TRowcnt - var mask U16 = (U16((int32(0x0002) << (54 - 53)) | (int32(0x0002) << (55 - 53)))) + var mask U16 = (U16((int32(WO_EQ) << (TK_GT - TK_EQ)) | (int32(WO_EQ) << (TK_LE - TK_EQ)))) if Xsqlite3ExprVectorSize(tls, pExpr) > *(*int32)(unsafe.Pointer(bp + 20 /* n */)) { - mask = (U16((int32(0x0002) << (55 - 53)) | (int32(0x0002) << (56 - 53)))) + mask = (U16((int32(WO_EQ) << (TK_LE - TK_EQ)) | (int32(WO_EQ) << (TK_LT - TK_EQ)))) } iUprIdx = whereKeyStats(tls, pParse, p, *(*uintptr)(unsafe.Pointer(bp + 8 /* pRec */)), 1, bp /* &a[0] */) - iNew = (*(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(0)*4)) + (func() uint32 { + iNew = (*(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */)) + (func() uint32 { if (int32((*WhereTerm)(unsafe.Pointer(pUpper)).FeOperator) & int32(mask)) != 0 { - return *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(1)*4)) + return *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + 1*4)) } return uint32(0) }())) @@ -129735,7 +127590,7 @@ func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower u } (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec = *(*uintptr)(unsafe.Pointer(bp + 8 /* pRec */)) - if rc == 0 { + if rc == SQLITE_OK { if iUpper > iLower { nNew = Xsqlite3LogEst(tls, (uint64(iUpper - iLower))) // TUNING: If both iUpper and iLower are derived from the same @@ -129816,29 +127671,29 @@ func whereEqualScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pExpr ui // If values are not available for all fields of the index to the left // of this one, no estimate can be made. Return SQLITE_NOTFOUND. if (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid < (nEq - 1) { - return 12 + return SQLITE_NOTFOUND } // This is an optimization only. The call to sqlite3Stat4ProbeSetValue() // below would return the same value. if nEq >= int32((*Index)(unsafe.Pointer(p)).FnColumn) { *(*TRowcnt)(unsafe.Pointer(pnRow)) = TRowcnt(1) - return 0 + return SQLITE_OK } rc = Xsqlite3Stat4ProbeSetValue(tls, pParse, p, bp /* &pRec */, pExpr, 1, (nEq - 1), bp+8 /* &bOk */) (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec = *(*uintptr)(unsafe.Pointer(bp /* pRec */)) - if rc != 0 { + if rc != SQLITE_OK { return rc } if *(*int32)(unsafe.Pointer(bp + 8 /* bOk */)) == 0 { - return 12 + return SQLITE_NOTFOUND } (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = nEq whereKeyStats(tls, pParse, p, *(*uintptr)(unsafe.Pointer(bp /* pRec */)), 0, bp+12 /* &a[0] */) - *(*TRowcnt)(unsafe.Pointer(pnRow)) = *(*TRowcnt)(unsafe.Pointer(bp + 12 /* &a[0] */ + uintptr(1)*4)) + *(*TRowcnt)(unsafe.Pointer(pnRow)) = *(*TRowcnt)(unsafe.Pointer(bp + 12 /* &a[0] */ + 1*4)) return rc } @@ -129862,22 +127717,22 @@ func whereInScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pList uintp defer tls.Free(4) var p uintptr = *(*uintptr)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) - var nRow0 I64 = I64(Xsqlite3LogEstToInt(tls, *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaiRowLogEst + uintptr(0)*2)))) + var nRow0 I64 = I64(Xsqlite3LogEstToInt(tls, *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaiRowLogEst)))) var nRecValid int32 = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid - var rc int32 = 0 // Subfunction return code + var rc int32 = SQLITE_OK // Subfunction return code // var nEst TRowcnt at bp, 4 // Number of rows for a single term var nRowEst TRowcnt = TRowcnt(0) // New estimate of the number of rows var i int32 // Loop counter - for i = 0; (rc == 0) && (i < (*ExprList)(unsafe.Pointer(pList)).FnExpr); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*ExprList)(unsafe.Pointer(pList)).FnExpr); i++ { *(*TRowcnt)(unsafe.Pointer(bp /* nEst */)) = TRowcnt(nRow0) rc = whereEqualScanEst(tls, pParse, pBuilder, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FpExpr, bp /* &nEst */) nRowEst = nRowEst + (*(*TRowcnt)(unsafe.Pointer(bp /* nEst */))) (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = nRecValid } - if rc == 0 { + if rc == SQLITE_OK { if I64(nRowEst) > nRow0 { nRowEst = TRowcnt(nRow0) } @@ -129899,12 +127754,12 @@ func whereLoopInit(tls *libc.TLS, p uintptr) { /* sqlite3.c:147466:13: */ // Clear the WhereLoop.u union. Leave WhereLoop.pLTerm intact. func whereLoopClearUnion(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3.c:147476:13: */ - if ((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & (U32(0x00000400 | 0x00004000))) != 0 { - if (((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & U32(0x00000400)) != U32(0)) && (*(*U8)(unsafe.Pointer((p + 24 /* &.u */ /* &.vtab */) + 4 /* &.needFree */)) != 0) { + if ((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & (U32(WHERE_VIRTUALTABLE | WHERE_AUTO_INDEX))) != 0 { + if (((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & WHERE_VIRTUALTABLE) != U32(0)) && (*(*U8)(unsafe.Pointer((p + 24 /* &.u */ /* &.vtab */) + 4 /* &.needFree */)) != 0) { Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.vtab */ + 8 /* &.idxStr */))) *(*U8)(unsafe.Pointer(p + 24 /* &.u */ /* &.vtab */ + 4 /* &.needFree */)) = U8(0) *(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.vtab */ + 8 /* &.idxStr */)) = uintptr(0) - } else if (((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & U32(0x00004000)) != U32(0)) && (*(*uintptr)(unsafe.Pointer((p + 24 /* &.u */ /* &.btree */) + 8 /* &.pIndex */)) != uintptr(0)) { + } else if (((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & WHERE_AUTO_INDEX) != U32(0)) && (*(*uintptr)(unsafe.Pointer((p + 24 /* &.u */ /* &.btree */) + 8 /* &.pIndex */)) != uintptr(0)) { Xsqlite3DbFree(tls, db, (*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)))).FzColAff) Xsqlite3DbFreeNN(tls, db, *(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */))) *(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) = uintptr(0) @@ -129925,12 +127780,12 @@ func whereLoopClear(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3.c:147493: func whereLoopResize(tls *libc.TLS, db uintptr, p uintptr, n int32) int32 { /* sqlite3.c:147502:12: */ var paNew uintptr if int32((*WhereLoop)(unsafe.Pointer(p)).FnLSlot) >= n { - return 0 + return SQLITE_OK } - n = ((n + 7) & ^libc.Int32(7)) + n = ((n + 7) & libc.CplInt32(7)) paNew = Xsqlite3DbMallocRawNN(tls, db, (uint64(uint64(unsafe.Sizeof(uintptr(0))) * uint64(n)))) if paNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, paNew, (*WhereLoop)(unsafe.Pointer(p)).FaLTerm, (uint64(unsafe.Sizeof(uintptr(0))) * uint64((*WhereLoop)(unsafe.Pointer(p)).FnLSlot))) if (*WhereLoop)(unsafe.Pointer(p)).FaLTerm != p+72 /* &.aLTermSpace */ { @@ -129938,7 +127793,7 @@ func whereLoopResize(tls *libc.TLS, db uintptr, p uintptr, n int32) int32 { /* s } (*WhereLoop)(unsafe.Pointer(p)).FaLTerm = paNew (*WhereLoop)(unsafe.Pointer(p)).FnLSlot = U16(n) - return 0 + return SQLITE_OK } // Transfer content from the second pLoop into the first. @@ -129954,16 +127809,16 @@ func whereLoopXfer(tls *libc.TLS, db uintptr, pTo uintptr, pFrom uintptr) int32 FpIndex uintptr } }{}))) - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, pTo, pFrom, uint64((uintptr(0) + 48 /* &.nLSlot */))) libc.Xmemcpy(tls, (*WhereLoop)(unsafe.Pointer(pTo)).FaLTerm, (*WhereLoop)(unsafe.Pointer(pFrom)).FaLTerm, (uint64((*WhereLoop)(unsafe.Pointer(pTo)).FnLTerm) * uint64(unsafe.Sizeof(uintptr(0))))) - if ((*WhereLoop)(unsafe.Pointer(pFrom)).FwsFlags & U32(0x00000400)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pFrom)).FwsFlags & WHERE_VIRTUALTABLE) != 0 { *(*U8)(unsafe.Pointer(pFrom + 24 /* &.u */ /* &.vtab */ + 4 /* &.needFree */)) = U8(0) - } else if ((*WhereLoop)(unsafe.Pointer(pFrom)).FwsFlags & U32(0x00004000)) != U32(0) { + } else if ((*WhereLoop)(unsafe.Pointer(pFrom)).FwsFlags & WHERE_AUTO_INDEX) != U32(0) { *(*uintptr)(unsafe.Pointer(pFrom + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) = uintptr(0) } - return 0 + return SQLITE_OK } // Delete a WhereLoop object @@ -129978,7 +127833,7 @@ func whereInfoFree(tls *libc.TLS, db uintptr, pWInfo uintptr) { /* sqlite3.c:147 for i = 0; i < int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel); i++ { var pLevel uintptr = ((pWInfo + 920 /* &.a */) + uintptr(i)*88) - if ((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop != 0) && (((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags & U32(0x00000800)) != 0) { + if ((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop != 0) && (((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags & WHERE_IN_ABLE) != 0) { Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pLevel + 56 /* &.u */ /* &.in */ + 8 /* &.aInLoop */))) } } @@ -130038,8 +127893,8 @@ func whereLoopCheaperProperSubset(tls *libc.TLS, pX uintptr, pY uintptr) int32 { return 0 } // X not a subset of Y since term X[i] not used by Y } - if (((*WhereLoop)(unsafe.Pointer(pX)).FwsFlags & U32(0x00000040)) != U32(0)) && - (((*WhereLoop)(unsafe.Pointer(pY)).FwsFlags & U32(0x00000040)) == U32(0)) { + if (((*WhereLoop)(unsafe.Pointer(pX)).FwsFlags & WHERE_IDX_ONLY) != U32(0)) && + (((*WhereLoop)(unsafe.Pointer(pY)).FwsFlags & WHERE_IDX_ONLY) == U32(0)) { return 0 // Constraint (5) } return 1 // All conditions meet @@ -130058,14 +127913,14 @@ func whereLoopCheaperProperSubset(tls *libc.TLS, pX uintptr, pY uintptr) int32 { // WHERE clause terms than Y and that every WHERE clause term used by X is // also used by Y. func whereLoopAdjustCost(tls *libc.TLS, p uintptr, pTemplate uintptr) { /* sqlite3.c:147623:13: */ - if ((*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags & U32(0x00000200)) == U32(0) { + if ((*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags & WHERE_INDEXED) == U32(0) { return } for ; p != 0; p = (*WhereLoop)(unsafe.Pointer(p)).FpNextLoop { if int32((*WhereLoop)(unsafe.Pointer(p)).FiTab) != int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FiTab) { continue } - if ((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & U32(0x00000200)) == U32(0) { + if ((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & WHERE_INDEXED) == U32(0) { continue } if whereLoopCheaperProperSubset(tls, p, pTemplate) != 0 { @@ -130121,10 +127976,10 @@ __1: // Any loop using an appliation-defined index (or PRIMARY KEY or // UNIQUE constraint) with one or more == constraints is better // than an automatic index. Unless it is a skip-scan. - if ((((((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & U32(0x00004000)) != U32(0)) && + if ((((((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & WHERE_AUTO_INDEX) != U32(0)) && ((int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FnSkip)) == 0)) && - (((*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags & U32(0x00000200)) != U32(0))) && - (((*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags & U32(0x00000001)) != U32(0))) && + (((*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags & WHERE_INDEXED) != U32(0))) && + (((*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags & WHERE_COLUMN_EQ) != U32(0))) && (((*WhereLoop)(unsafe.Pointer(p)).Fprereq & (*WhereLoop)(unsafe.Pointer(pTemplate)).Fprereq) == (*WhereLoop)(unsafe.Pointer(pTemplate)).Fprereq) { goto __3 } @@ -130198,7 +128053,7 @@ func whereLoopInsert(tls *libc.TLS, pBuilder uintptr, pTemplate uintptr) int32 { if (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet != 0 { (*WhereOrSet)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet)).Fn = U16(0) } - return 101 + return SQLITE_DONE } (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit-- @@ -130211,7 +128066,7 @@ func whereLoopInsert(tls *libc.TLS, pBuilder uintptr, pTemplate uintptr) int32 { whereOrInsert(tls, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet, (*WhereLoop)(unsafe.Pointer(pTemplate)).Fprereq, (*WhereLoop)(unsafe.Pointer(pTemplate)).FrRun, (*WhereLoop)(unsafe.Pointer(pTemplate)).FnOut) } - return 0 + return SQLITE_OK } // Look for an existing WhereLoop to replace with pTemplate @@ -130220,7 +128075,7 @@ func whereLoopInsert(tls *libc.TLS, pBuilder uintptr, pTemplate uintptr) int32 { if ppPrev == uintptr(0) { // There already exists a WhereLoop on the list that is better // than pTemplate, so just ignore pTemplate - return 0 + return SQLITE_OK } else { p = *(*uintptr)(unsafe.Pointer(ppPrev)) } @@ -130232,7 +128087,7 @@ func whereLoopInsert(tls *libc.TLS, pBuilder uintptr, pTemplate uintptr) int32 { // Allocate a new WhereLoop to add to the end of the list *(*uintptr)(unsafe.Pointer(ppPrev)) = libc.AssignUintptr(&p, Xsqlite3DbMallocRawNN(tls, db, uint64(unsafe.Sizeof(WhereLoop{})))) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } whereLoopInit(tls, p) (*WhereLoop)(unsafe.Pointer(p)).FpNextLoop = uintptr(0) @@ -130256,9 +128111,9 @@ func whereLoopInsert(tls *libc.TLS, pBuilder uintptr, pTemplate uintptr) int32 { } } rc = whereLoopXfer(tls, db, p, pTemplate) - if ((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & U32(0x00000400)) == U32(0) { + if ((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & WHERE_VIRTUALTABLE) == U32(0) { var pIndex uintptr = *(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) - if (pIndex != 0) && ((int32(*(*uint16)(unsafe.Pointer(pIndex + 100 /* &.idxType */)) & 0x3 >> 0)) == 3) { + if (pIndex != 0) && ((int32(*(*uint16)(unsafe.Pointer(pIndex + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_IPK) { *(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) = uintptr(0) } } @@ -130311,7 +128166,7 @@ __1: } { - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0002) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VIRTUAL) != 0 { goto __3 } if ((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf) == uint64(0) { @@ -130341,8 +128196,8 @@ __1: // In the absence of explicit truth probabilities, use heuristics to // guess a reasonable truth probability. (*WhereLoop)(unsafe.Pointer(pLoop)).FnOut-- - if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (0x0002 | 0x0080)) != 0) && - ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x4000) == 0) { + if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (WO_EQ | WO_IS)) != 0) && + ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_HIGHTRUTH) == 0) { var pRight uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight *(*int32)(unsafe.Pointer(bp /* k */)) = 0 @@ -130352,7 +128207,7 @@ __1: *(*int32)(unsafe.Pointer(bp /* k */)) = 20 } if int32(iReduce) < *(*int32)(unsafe.Pointer(bp /* k */)) { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x2000)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_HEURTRUTH)) iReduce = LogEst(*(*int32)(unsafe.Pointer(bp /* k */))) } } @@ -130406,7 +128261,7 @@ func whereRangeVectorLen(tls *libc.TLS, pParse uintptr, iCur int32, pIdx uintptr var pColl uintptr // Comparison collation sequence var pLhs uintptr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft + 32 /* &.x */)) + 8 /* &.a */) + uintptr(i)*32)).FpExpr var pRhs uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight - if ((*Expr)(unsafe.Pointer(pRhs)).Fflags & U32(0x000800)) != 0 { + if ((*Expr)(unsafe.Pointer(pRhs)).Fflags & EP_xIsSelect) != 0 { pRhs = (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRhs + 32 /* &.x */)))).FpEList + 8 /* &.a */) + uintptr(i)*32)).FpExpr } else { pRhs = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pRhs + 32 /* &.x */)) + 8 /* &.a */) + uintptr(i)*32)).FpExpr @@ -130416,7 +128271,7 @@ func whereRangeVectorLen(tls *libc.TLS, pParse uintptr, iCur int32, pIdx uintptr // the right column of the right source table. And that the sort // order of the index column is the same as the sort order of the // leftmost index column. - if (((int32((*Expr)(unsafe.Pointer(pLhs)).Fop) != 164) || + if (((int32((*Expr)(unsafe.Pointer(pLhs)).Fop) != TK_COLUMN) || ((*Expr)(unsafe.Pointer(pLhs)).FiTable != iCur)) || (int32((*Expr)(unsafe.Pointer(pLhs)).FiColumn) != int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr((i+nEq))*2))))) || (int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr((i + nEq))))) != int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(nEq))))) { @@ -130473,7 +128328,7 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb var saved_nSkip U16 // Original value of pNew->nSkip var saved_wsFlags U32 // Original value of pNew->wsFlags var saved_nOut LogEst // Original value of pNew->nOut - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var rSize LogEst // Number of rows in the table var rLogSize LogEst // Logarithm of table size var pTop uintptr = uintptr(0) @@ -130481,17 +128336,17 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb pNew = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - return 7 + return SQLITE_NOMEM } - if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & U32(0x00000020)) != 0 { - opMask = ((int32(0x0002) << (56 - 53)) | (int32(0x0002) << (55 - 53))) + if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & WHERE_BTM_LIMIT) != 0 { + opMask = ((int32(WO_EQ) << (TK_LT - TK_EQ)) | (int32(WO_EQ) << (TK_LE - TK_EQ))) } else { - opMask = (((((((0x0002 | 0x0001) | (int32(0x0002) << (54 - 53))) | (int32(0x0002) << (57 - 53))) | (int32(0x0002) << (56 - 53))) | (int32(0x0002) << (55 - 53))) | 0x0100) | 0x0080) + opMask = (((((((WO_EQ | WO_IN) | (int32(WO_EQ) << (TK_GT - TK_EQ))) | (int32(WO_EQ) << (TK_GE - TK_EQ))) | (int32(WO_EQ) << (TK_LT - TK_EQ))) | (int32(WO_EQ) << (TK_LE - TK_EQ))) | WO_ISNULL) | WO_IS) } if (uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.bUnordered */)) & 0x4 >> 2))) != 0 { - opMask = opMask & (^libc.Int32(((((int32(0x0002) << (54 - 53)) | (int32(0x0002) << (57 - 53))) | (int32(0x0002) << (56 - 53))) | (int32(0x0002) << (55 - 53))))) + opMask = opMask & (libc.CplInt32(((((int32(WO_EQ) << (TK_GT - TK_EQ)) | (int32(WO_EQ) << (TK_GE - TK_EQ))) | (int32(WO_EQ) << (TK_LT - TK_EQ))) | (int32(WO_EQ) << (TK_LE - TK_EQ))))) } saved_nEq = *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ /* &.nEq */)) @@ -130505,15 +128360,15 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb pTerm = whereScanInit(tls, bp /* &scan */, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC, (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor, int32(saved_nEq), uint32(opMask), pProbe) (*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(0) - rSize = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(0)*2)) + rSize = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst)) rLogSize = estLog(tls, rSize) - for ; (rc == 0) && (pTerm != uintptr(0)); pTerm = whereScanNext(tls, bp /* &scan */) { + for ; (rc == SQLITE_OK) && (pTerm != uintptr(0)); pTerm = whereScanNext(tls, bp /* &scan */) { var eOp U16 = (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator // Shorthand for pTerm->eOperator var rCostIdx LogEst var nOutUnadjusted LogEst // nOut before IN() and WHERE adjustments var nIn int32 = 0 var nRecValid int32 = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid - if ((int32(eOp) == 0x0100) || ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0080) != 0)) && + if ((int32(eOp) == WO_ISNULL) || ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VNULL) != 0)) && (indexColumnNotNull(tls, pProbe, int32(saved_nEq)) != 0) { continue // ignore IS [NOT] NULL constraints on NOT NULL columns } @@ -130523,22 +128378,22 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb // Do not allow the upper bound of a LIKE optimization range constraint // to mix with a lower range bound from some other source - if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0100) != 0) && (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) == (int32(0x0002) << (56 - 53))) { + if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_LIKEOPT) != 0) && (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) == (int32(WO_EQ) << (TK_LT - TK_EQ))) { continue } // tag-20191211-001: Do not allow constraints from the WHERE clause to // be used by the right table of a LEFT JOIN. Only constraints in the // ON clause are allowed. See tag-20191211-002 for the vtab equivalent. - if ((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & 0x0008) != 0) && - !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000001))) != U32(0)) { + if ((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & JT_LEFT) != 0) && + !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_FromJoin)) != U32(0)) { continue } - if (int32((*Index)(unsafe.Pointer((pProbe))).FonError) != 0) && (int32(saved_nEq) == (int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) - 1)) { - *(*uint8)(unsafe.Pointer(pBuilder + 52 /* &.bldFlags1 */)) |= uint8((0x0002)) + if (int32((*Index)(unsafe.Pointer((pProbe))).FonError) != OE_None) && (int32(saved_nEq) == (int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) - 1)) { + *(*uint8)(unsafe.Pointer(pBuilder + 52 /* &.bldFlags1 */)) |= uint8((SQLITE_BLDF1_UNIQUE)) } else { - *(*uint8)(unsafe.Pointer(pBuilder + 52 /* &.bldFlags1 */)) |= uint8((0x0001)) + *(*uint8)(unsafe.Pointer(pBuilder + 52 /* &.bldFlags1 */)) |= uint8((SQLITE_BLDF1_INDEXED)) } (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = saved_wsFlags *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ /* &.nEq */)) = saved_nEq @@ -130551,9 +128406,9 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(libc.PostIncUint16(&(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm, 1))*8)) = pTerm (*WhereLoop)(unsafe.Pointer(pNew)).Fprereq = ((saved_prereq | (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight) & ^(*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf) - if (int32(eOp) & 0x0001) != 0 { + if (int32(eOp) & WO_IN) != 0 { var pExpr uintptr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { // "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows var i int32 nIn = 46 @@ -130604,48 +128459,48 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb } } - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00000004)) - } else if (int32(eOp) & (0x0002 | 0x0080)) != 0 { + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_COLUMN_IN) + } else if (int32(eOp) & (WO_EQ | WO_IS)) != 0 { var iCol int32 = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiColumn + uintptr(saved_nEq)*2))) - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00000001)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_COLUMN_EQ) if (iCol == (-1)) || (((iCol >= 0) && (int32(nInMul) == 0)) && (int32(saved_nEq) == (int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) - 1))) { if ((iCol == (-1)) || ((uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.uniqNotNull */)) & 0x8 >> 3))) != 0)) || - (((int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) == 1) && ((*Index)(unsafe.Pointer(pProbe)).FonError != 0)) && (int32(eOp) == 0x0002)) { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00001000)) + (((int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) == 1) && ((*Index)(unsafe.Pointer(pProbe)).FonError != 0)) && (int32(eOp) == WO_EQ)) { + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_ONEROW) } else { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00010000)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_UNQ_WANTED) } } - } else if (int32(eOp) & 0x0100) != 0 { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00000008)) - } else if (int32(eOp) & ((int32(0x0002) << (54 - 53)) | (int32(0x0002) << (57 - 53)))) != 0 { + } else if (int32(eOp) & WO_ISNULL) != 0 { + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_COLUMN_NULL) + } else if (int32(eOp) & ((int32(WO_EQ) << (TK_GT - TK_EQ)) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) != 0 { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00000002 | 0x00000020)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(WHERE_COLUMN_RANGE | WHERE_BTM_LIMIT)) *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ + 2 /* &.nBtm */)) = U16(whereRangeVectorLen(tls, pParse, (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor, pProbe, int32(saved_nEq), pTerm)) pBtm = pTerm pTop = uintptr(0) - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0100) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_LIKEOPT) != 0 { // Range contraints that come from the LIKE optimization are // always used in pairs. - pTop = (pTerm + uintptr(1)*64) + pTop = (pTerm + 1*64) if whereLoopResize(tls, db, pNew, (int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)+1)) != 0 { break } // OOM *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(libc.PostIncUint16(&(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm, 1))*8)) = pTop - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00000010)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_TOP_LIMIT) *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ + 4 /* &.nTop */)) = U16(1) } } else { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00000002 | 0x00000010)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(WHERE_COLUMN_RANGE | WHERE_TOP_LIMIT)) *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ + 4 /* &.nTop */)) = U16(whereRangeVectorLen(tls, pParse, (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor, pProbe, int32(saved_nEq), pTerm)) pTop = pTerm - if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & U32(0x00000020)) != U32(0) { + if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & WHERE_BTM_LIMIT) != U32(0) { pBtm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr((int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)-2))*8)) } else { pBtm = uintptr(0) @@ -130658,7 +128513,7 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb // "x IN(...)" terms are replaced with "x = ?". This block updates // the value of pNew->nOut to account for pTerm (but not nIn/nInMul). - if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & U32(0x00000002)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & WHERE_COLUMN_RANGE) != 0 { // Adjust nOut using stat4 data. Or, if there is no stat4 // data, using some other estimate. whereRangeScanEst(tls, pParse, pBuilder, pBtm, pTop, pNew) @@ -130674,19 +128529,19 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb if ((((int32(nInMul) == 0) && ((*Index)(unsafe.Pointer(pProbe)).FnSample != 0)) && (int32(*(*U16)(unsafe.Pointer((pNew + 24 /* &.u */ /* &.btree */) /* &.nEq */))) <= (*Index)(unsafe.Pointer(pProbe)).FnSampleCol)) && - (((int32(eOp) & 0x0001) == 0) || !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000800))) != U32(0)))) && - ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0) { + (((int32(eOp) & WO_IN) == 0) || !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_xIsSelect)) != U32(0)))) && + ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0) { var pExpr uintptr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr - if (int32(eOp) & ((0x0002 | 0x0100) | 0x0080)) != 0 { + if (int32(eOp) & ((WO_EQ | WO_ISNULL) | WO_IS)) != 0 { rc = whereEqualScanEst(tls, pParse, pBuilder, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+112 /* &nOut */) } else { rc = whereInScanEst(tls, pParse, pBuilder, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)), bp+112 /* &nOut */) } - if rc == 12 { - rc = 0 + if rc == SQLITE_NOTFOUND { + rc = SQLITE_OK } - if rc != 0 { + if rc != SQLITE_OK { break } // Jump out of the pTerm loop if *(*TRowcnt)(unsafe.Pointer(bp + 112 /* nOut */)) != 0 { @@ -130695,13 +128550,13 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb // TUNING: Mark terms as "low selectivity" if they seem likely // to be true for half or more of the rows in the table. // See tag-202002240-1 - ((int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) + 10) > int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(0)*2)))) { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x4000)) - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x2000) != 0 { + ((int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) + 10) > int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst)))) { + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_HIGHTRUTH)) + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_HEURTRUTH) != 0 { // If the term has previously been used with an assumption of // higher selectivity, then set the flag to rerun the // loop computations. - *(*uint8)(unsafe.Pointer(pBuilder + 53 /* &.bldFlags2 */)) |= uint8((0x0004)) + *(*uint8)(unsafe.Pointer(pBuilder + 53 /* &.bldFlags2 */)) |= uint8((SQLITE_BLDF2_2NDPASS)) } } if int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) > int32(saved_nOut) { @@ -130712,7 +128567,7 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb } if *(*TRowcnt)(unsafe.Pointer(bp + 112 /* nOut */)) == TRowcnt(0) { *(*LogEst)(unsafe.Pointer(pNew + 22 /* &.nOut */)) += LogEst((int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(nEq)*2))) - int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr((nEq-1))*2))))) - if (int32(eOp) & 0x0100) != 0 { + if (int32(eOp) & WO_ISNULL) != 0 { // TUNING: If there is no likelihood() value, assume that a // "col IS NULL" expression matches twice as many rows // as (col=?). @@ -130729,7 +128584,7 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb rCostIdx = (LogEst((int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) + 1) + ((15 * int32((*Index)(unsafe.Pointer(pProbe)).FszIdxRow)) / int32((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pSrc)).FpTab)).FszTabRow)))) (*WhereLoop)(unsafe.Pointer(pNew)).FrRun = Xsqlite3LogEstAdd(tls, rLogSize, rCostIdx) - if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & (U32(0x00000040 | 0x00000100))) == U32(0) { + if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & (U32(WHERE_IDX_ONLY | WHERE_IPK))) == U32(0) { (*WhereLoop)(unsafe.Pointer(pNew)).FrRun = Xsqlite3LogEstAdd(tls, (*WhereLoop)(unsafe.Pointer(pNew)).FrRun, (int16(int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) + 16))) } @@ -130739,13 +128594,13 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb whereLoopOutputAdjust(tls, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC, pNew, rSize) rc = whereLoopInsert(tls, pBuilder, pNew) - if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & U32(0x00000002)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & WHERE_COLUMN_RANGE) != 0 { (*WhereLoop)(unsafe.Pointer(pNew)).FnOut = saved_nOut } else { (*WhereLoop)(unsafe.Pointer(pNew)).FnOut = nOutUnadjusted } - if (((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & U32(0x00000010)) == U32(0)) && + if (((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & WHERE_TOP_LIMIT) == U32(0)) && (int32(*(*U16)(unsafe.Pointer((pNew + 24 /* &.u */ /* &.btree */) /* &.nEq */))) < int32((*Index)(unsafe.Pointer(pProbe)).FnColumn)) { whereLoopAddBtreeIndex(tls, pBuilder, pSrc, pProbe, (int16(int32(nInMul) + nIn))) } @@ -130777,14 +128632,14 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb (int32(saved_nEq) == int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm))) && ((int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.noSkipScan */)) & 0x40 >> 6)) == 0)) && ((int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.hasStat1 */)) & 0x80 >> 7)) != 0)) && - ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x4000)) == 0)) && + ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_SkipScan)) == 0)) && (int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr((int32(saved_nEq)+1))*2))) >= 42)) && // TUNING: Minimum for skip-scan - ((libc.AssignInt32(&rc, whereLoopResize(tls, db, pNew, (int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)+1)))) == 0) { + ((libc.AssignInt32(&rc, whereLoopResize(tls, db, pNew, (int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)+1)))) == SQLITE_OK) { var nIter LogEst *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ /* &.nEq */))++ (*WhereLoop)(unsafe.Pointer(pNew)).FnSkip++ *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(libc.PostIncUint16(&(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm, 1))*8)) = uintptr(0) - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00008000)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_SKIPSCAN) nIter = (LogEst(int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(saved_nEq)*2))) - int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr((int32(saved_nEq)+1))*2))))) *(*LogEst)(unsafe.Pointer(pNew + 22 /* &.nOut */)) -= LogEst((int32(nIter))) // TUNING: Because uncertainties in the estimates for skip-scan queries, @@ -130820,7 +128675,7 @@ func indexMightHelpWithOrderBy(tls *libc.TLS, pBuilder uintptr, pIndex uintptr, } for ii = 0; ii < (*ExprList)(unsafe.Pointer(pOB)).FnExpr; ii++ { var pExpr uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer((pOB+8 /* &.a */)+uintptr(ii)*32)).FpExpr) - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == iCursor) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == iCursor) { if int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) < 0 { return 1 } @@ -130849,13 +128704,13 @@ func whereUsablePartialIndex(tls *libc.TLS, iTab int32, isLeft int32, pWC uintpt var i int32 var pTerm uintptr var pParse uintptr = (*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse - for int32((*Expr)(unsafe.Pointer(pWhere)).Fop) == 44 { + for int32((*Expr)(unsafe.Pointer(pWhere)).Fop) == TK_AND { if !(whereUsablePartialIndex(tls, iTab, isLeft, pWC, (*Expr)(unsafe.Pointer(pWhere)).FpLeft) != 0) { return 0 } pWhere = (*Expr)(unsafe.Pointer(pWhere)).FpRight } - if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00800000)) != 0 { + if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_EnableQPSG) != 0 { pParse = uintptr(0) } i = 0 @@ -130867,8 +128722,8 @@ __1: { var pExpr uintptr pExpr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr - if ((!(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0)) || (int32((*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable) == iTab)) && - ((isLeft == 0) || (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0)))) && + if ((!(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0)) || (int32((*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable) == iTab)) && + ((isLeft == 0) || (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0)))) && (Xsqlite3ExprImpliesExpr(tls, pParse, pExpr, pWhere, iTab) != 0) { return 1 } @@ -130933,7 +128788,7 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { var pTabList uintptr // The FROM clause var pSrc uintptr // The FROM clause btree term to add var pNew uintptr // Template WhereLoop object - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var iSortIdx int32 = 1 // Index number var b int32 // A boolean value var rSize LogEst // number of rows in the table @@ -130951,7 +128806,7 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { if (*SrcList_item)(unsafe.Pointer(pSrc)).FpIBIndex != 0 { // An INDEXED BY clause specifies a particular index to use pProbe = (*SrcList_item)(unsafe.Pointer(pSrc)).FpIBIndex - } else if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + } else if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { pProbe = (*Table)(unsafe.Pointer(pTab)).FpIndex } else { // There is no INDEXED BY clause. Create a fake Index object in local @@ -130964,12 +128819,12 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { (*Index)(unsafe.Pointer(bp /* &sPk */)).FnColumn = U16(1) (*Index)(unsafe.Pointer(bp /* &sPk */)).FaiColumn = bp + 152 /* &aiColumnPk */ (*Index)(unsafe.Pointer(bp /* &sPk */)).FaiRowLogEst = bp + 154 /* &aiRowEstPk[0] */ - (*Index)(unsafe.Pointer(bp /* &sPk */)).FonError = U8(5) + (*Index)(unsafe.Pointer(bp /* &sPk */)).FonError = OE_Replace (*Index)(unsafe.Pointer(bp /* &sPk */)).FpTable = pTab (*Index)(unsafe.Pointer(bp /* &sPk */)).FszIdxRow = (*Table)(unsafe.Pointer(pTab)).FszTabRow - libc.SetBitFieldPtr16Uint32(bp /* &sPk */ +100 /* &.idxType */, uint32(3), 0, 0x3) - *(*LogEst)(unsafe.Pointer(bp + 154 /* &aiRowEstPk[0] */ + uintptr(0)*2)) = (*Table)(unsafe.Pointer(pTab)).FnRowLogEst - *(*LogEst)(unsafe.Pointer(bp + 154 /* &aiRowEstPk[0] */ + uintptr(1)*2)) = int16(0) + libc.SetBitFieldPtr16Uint32(bp /* &sPk */ +100 /* &.idxType */, SQLITE_IDXTYPE_IPK, 0, 0x3) + *(*LogEst)(unsafe.Pointer(bp + 154 /* &aiRowEstPk[0] */)) = (*Table)(unsafe.Pointer(pTab)).FnRowLogEst + *(*LogEst)(unsafe.Pointer(bp + 154 /* &aiRowEstPk[0] */ + 1*2)) = int16(0) pFirst = (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pSrc)).FpTab)).FpIndex if (int32(*(*uint8)(unsafe.Pointer((pSrc + 60 /* &.fg */) + 4 /* &.notIndexed */)) & 0x1 >> 0)) == 0 { // The real indices of the table are only considered if the @@ -130983,17 +128838,17 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { // Automatic indexes if ((((((!(int32((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet) != 0) && // Not part of an OR optimization - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0020) == 0)) && - (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb)).Fflags & uint64(0x00008000)) != uint64(0))) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_OR_SUBCLAUSE) == 0)) && + (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb)).Fflags & SQLITE_AutoIndex) != uint64(0))) && ((*SrcList_item)(unsafe.Pointer(pSrc)).FpIBIndex == uintptr(0))) && // Has no INDEXED BY clause !((int32(*(*uint8)(unsafe.Pointer(pSrc + 60 /* &.fg */ + 4 /* &.notIndexed */)) & 0x1 >> 0)) != 0)) && // Has no NOT INDEXED clause - (((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) && // Not WITHOUT ROWID table. (FIXME: Why not?) + (((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) && // Not WITHOUT ROWID table. (FIXME: Why not?) !((int32(*(*uint8)(unsafe.Pointer(pSrc + 60 /* &.fg */ + 4 /* &.isCorrelated */)) & 0x8 >> 3)) != 0)) && // Not a correlated subquery !((int32(*(*uint8)(unsafe.Pointer(pSrc + 60 /* &.fg */ + 4 /* &.isRecursive */)) & 0x20 >> 5)) != 0) { // Generate auto-index WhereLoops var pTerm uintptr var pWCEnd uintptr = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*WhereClause)(unsafe.Pointer(pWC)).FnTerm)*64) - for pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa; (rc == 0) && (pTerm < pWCEnd); pTerm += 64 { + for pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa; (rc == SQLITE_OK) && (pTerm < pWCEnd); pTerm += 64 { if ((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight & (*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf) != 0 { continue } @@ -131002,7 +128857,7 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { (*WhereLoop)(unsafe.Pointer(pNew)).FnSkip = U16(0) *(*uintptr)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) = uintptr(0) (*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = U16(1) - *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(0)*8)) = pTerm + *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm)) = pTerm // TUNING: One-time cost for computing the automatic index is // estimated to be X*N*log2(N) where N is the number of rows in // the table being indexed and where X is 7 (LogEst=28) for normal @@ -131012,7 +128867,7 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { // those objects, since there is no opportunity to add schema // indexes on subqueries and views. (*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = (LogEst(int32(rLogSize) + int32(rSize))) - if ((*Table)(unsafe.Pointer(pTab)).FpSelect == uintptr(0)) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0002)) == U32(0)) { + if ((*Table)(unsafe.Pointer(pTab)).FpSelect == uintptr(0)) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Ephemeral) == U32(0)) { *(*LogEst)(unsafe.Pointer(pNew + 18 /* &.rSetup */)) += int16((28)) } else { *(*LogEst)(unsafe.Pointer(pNew + 18 /* &.rSetup */)) -= int16((10)) @@ -131027,7 +128882,7 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { // not be unreasonable to make this value much larger. (*WhereLoop)(unsafe.Pointer(pNew)).FnOut = int16(43) (*WhereLoop)(unsafe.Pointer(pNew)).FrRun = Xsqlite3LogEstAdd(tls, rLogSize, (*WhereLoop)(unsafe.Pointer(pNew)).FnOut) - (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(0x00004000) + (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = WHERE_AUTO_INDEX (*WhereLoop)(unsafe.Pointer(pNew)).Fprereq = (mPrereq | (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight) rc = whereLoopInsert(tls, pBuilder, pNew) } @@ -131037,11 +128892,11 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { // Loop over all indices. If there was an INDEXED BY clause, then only // consider index pProbe. __1: - if !((rc == 0) && (pProbe != 0)) { + if !((rc == SQLITE_OK) && (pProbe != 0)) { goto __3 } { - var isLeft int32 = (libc.Bool32((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & 0x0020) != 0)) + var isLeft int32 = (libc.Bool32((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & JT_OUTER) != 0)) if ((*Index)(unsafe.Pointer(pProbe)).FpPartIdxWhere != uintptr(0)) && !(whereUsablePartialIndex(tls, (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor, isLeft, pWC, (*Index)(unsafe.Pointer(pProbe)).FpPartIdxWhere) != 0) { @@ -131051,7 +128906,7 @@ __1: if (uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.bNoQuery */)) & 0x100 >> 8))) != 0 { goto __2 } - rSize = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(0)*2)) + rSize = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst)) *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ /* &.nEq */)) = U16(0) *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ + 2 /* &.nBtm */)) = U16(0) *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ + 4 /* &.nTop */)) = U16(0) @@ -131066,9 +128921,9 @@ __1: // The ONEPASS_DESIRED flags never occurs together with ORDER BY - if (int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.idxType */)) & 0x3 >> 0)) == 3 { + if (int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_IPK { // Integer primary key index - (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(0x00000100) + (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = WHERE_IPK // Full table scan (*WhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = func() uint8 { @@ -131089,29 +128944,29 @@ __1: } else { var m Bitmask if (uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.isCovering */)) & 0x20 >> 5))) != 0 { - (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = (U32(0x00000040 | 0x00000200)) + (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = (U32(WHERE_IDX_ONLY | WHERE_INDEXED)) m = uint64(0) } else { m = ((*SrcList_item)(unsafe.Pointer(pSrc)).FcolUsed & (*Index)(unsafe.Pointer(pProbe)).FcolNotIdxed) (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = func() uint32 { if m == uint64(0) { - return (uint32(0x00000040 | 0x00000200)) + return (uint32(WHERE_IDX_ONLY | WHERE_INDEXED)) } - return uint32(0x00000200) + return WHERE_INDEXED }() } // Full scan via index if ((((b != 0) || - !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) || + !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) || ((*Index)(unsafe.Pointer(pProbe)).FpPartIdxWhere != uintptr(0))) || ((uint32(int32(*(*uint8)(unsafe.Pointer((pSrc + 60 /* &.fg */) + 4 /* &.isIndexedBy */)) & 0x2 >> 1))) != 0)) || ((((((m == uint64(0)) && ((int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.bUnordered */)) & 0x4 >> 2)) == 0)) && (int32((*Index)(unsafe.Pointer(pProbe)).FszIdxRow) < int32((*Table)(unsafe.Pointer(pTab)).FszTabRow))) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0004) == 0)) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_ONEPASS_DESIRED) == 0)) && (Xsqlite3Config.FbUseCis != 0)) && - ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb))).FdbOptFlags) & (0x0020)) == 0)) { + ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb))).FdbOptFlags) & (SQLITE_CoverIdxScan)) == 0)) { (*WhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = func() uint8 { if b != 0 { return uint8(iSortIdx) @@ -131144,7 +128999,7 @@ __1: nLookup = LogEst(int32(nLookup) + (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb))) } else { nLookup-- - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (0x0002 | 0x0080)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (WO_EQ | WO_IS)) != 0 { nLookup = int16(int32(nLookup) - (19)) } } @@ -131164,12 +129019,12 @@ __1: (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FbldFlags1 = uint8(0) rc = whereLoopAddBtreeIndex(tls, pBuilder, pSrc, pProbe, int16(0)) - if int32((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FbldFlags1) == 0x0001 { + if int32((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FbldFlags1) == SQLITE_BLDF1_INDEXED { // If a non-unique index is used, or if a prefix of the key for // unique index is used (making the index functionally non-unique) // then the sqlite_stat1 data becomes important for scoring the // plan - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0100)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (TF_StatsUsed) } Xsqlite3Stat4ProbeFree(tls, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec) (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = 0 @@ -131219,7 +129074,7 @@ func whereLoopAddVirtualOne(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mU var pUsage uintptr = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage var i int32 var mxTerm int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var pNew uintptr = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew var pParse uintptr = (*WhereInfo)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo)).FpParse var pSrc uintptr = (((*WhereInfo)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo)).FpTabList + 8 /* &.a */) + uintptr((*WhereLoop)(unsafe.Pointer(pNew)).FiTab)*112) @@ -131268,12 +129123,12 @@ __3: // Invoke the virtual table xBestIndex() method rc = vtabBestIndex(tls, pParse, (*SrcList_item)(unsafe.Pointer(pSrc)).FpTab, pIdxInfo) if rc != 0 { - if rc == 19 { + if rc == SQLITE_CONSTRAINT { // If the xBestIndex method returns SQLITE_CONSTRAINT, that means // that the particular combination of parameters provided is unusable. // Make no entries in the loop table. - return 0 + return SQLITE_OK } return rc } @@ -131302,7 +129157,7 @@ __4: (int32((*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).Fusable) == 0) { Xsqlite3ErrorMsg(tls, pParse, ts+19263 /* "%s.xBestIndex ma..." */, libc.VaList(bp, (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pSrc)).FpTab)).FzName)) - return 1 + return SQLITE_ERROR } pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(j)*64) @@ -131321,14 +129176,14 @@ __4: } } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0001) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_IN) != 0 { // A virtual table that is constrained by an IN clause may not // consume the ORDER BY clause because (1) the order of IN terms // is not necessarily related to the order of output terms and // (2) Multiple outputs from a single IN value will not merge // together. (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 0 - *(*int32)(unsafe.Pointer(pIdxInfo + 80 /* &.idxFlags */)) &= (^libc.Int32(1)) + *(*int32)(unsafe.Pointer(pIdxInfo + 80 /* &.idxFlags */)) &= (libc.CplInt32(SQLITE_INDEX_SCAN_UNIQUE)) *(*int32)(unsafe.Pointer(pbIn)) = 1 } } @@ -131350,7 +129205,7 @@ __6: // error if they are not Xsqlite3ErrorMsg(tls, pParse, ts+19263 /* "%s.xBestIndex ma..." */, libc.VaList(bp+8, (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pSrc)).FpTab)).FzName)) - return 1 + return SQLITE_ERROR } } @@ -131370,10 +129225,10 @@ __6: // Set the WHERE_ONEROW flag if the xBestIndex() method indicated // that the scan will visit at most one row. Clear it otherwise. - if ((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags & 1) != 0 { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00001000)) + if ((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags & SQLITE_INDEX_SCAN_UNIQUE) != 0 { + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_ONEROW) } else { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) &= (^libc.Uint32FromInt32(0x00001000)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(WHERE_ONEROW))) } rc = whereLoopInsert(tls, pBuilder, pNew) if *(*U8)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.vtab */ + 4 /* &.needFree */)) != 0 { @@ -131390,7 +129245,7 @@ __6: // array. Or, if iCons is out of range or there is no active xBestIndex // call, return NULL. func Xsqlite3_vtab_collation(tls *libc.TLS, pIdxInfo uintptr, iCons int32) uintptr { /* sqlite3.c:148926:23: */ - var pHidden uintptr = (pIdxInfo + uintptr(1)*96) + var pHidden uintptr = (pIdxInfo + 1*96) var zRet uintptr = uintptr(0) if (iCons >= 0) && (iCons < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { var pC uintptr = uintptr(0) @@ -131436,13 +129291,13 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 // Return code - var pWInfo uintptr // WHERE analysis context - var pParse uintptr // The parsing context - var pWC uintptr // The WHERE clause - var pSrc uintptr // The FROM clause term to search - var p uintptr // Object to pass to xBestIndex() - var nConstraint int32 // Number of constraints in p + var rc int32 = SQLITE_OK // Return code + var pWInfo uintptr // WHERE analysis context + var pParse uintptr // The parsing context + var pWC uintptr // The WHERE clause + var pSrc uintptr // The FROM clause term to search + var p uintptr // Object to pass to xBestIndex() + var nConstraint int32 // Number of constraints in p // var bIn int32 at bp+4, 4 // True if plan uses IN(...) operator var pNew uintptr @@ -131458,16 +129313,16 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus p = allocateIndexInfo(tls, pParse, pWC, mUnusable, pSrc, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrderBy, bp /* &mNoOmit */) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(0) - (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(0x00000400) + (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = WHERE_VIRTUALTABLE (*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = U16(0) *(*U8)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.vtab */ + 4 /* &.needFree */)) = U8(0) nConstraint = (*Sqlite3_index_info)(unsafe.Pointer(p)).FnConstraint if whereLoopResize(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pNew, nConstraint) != 0 { Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p) - return 7 + return SQLITE_NOMEM } // First call xBestIndex() with all constraints usable. @@ -131479,7 +129334,7 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus // and does not use an IN(...) operator, then there is no point in making // any further calls to xBestIndex() since they will all return the same // result (if the xBestIndex() implementation is sane). - if (rc == 0) && (((libc.AssignUint64(&mBest, ((*WhereLoop)(unsafe.Pointer(pNew)).Fprereq & ^mPrereq))) != uint64(0)) || (*(*int32)(unsafe.Pointer(bp + 4 /* bIn */)) != 0)) { + if (rc == SQLITE_OK) && (((libc.AssignUint64(&mBest, ((*WhereLoop)(unsafe.Pointer(pNew)).Fprereq & ^mPrereq))) != uint64(0)) || (*(*int32)(unsafe.Pointer(bp + 4 /* bIn */)) != 0)) { var seenZero int32 = 0 // True if a plan with no prereqs seen var seenZeroNoIN int32 = 0 // Plan with no prereqs and no IN(...) seen var mPrev Bitmask = uint64(0) @@ -131490,7 +129345,7 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus if *(*int32)(unsafe.Pointer(bp + 4 /* bIn */)) != 0 { rc = whereLoopAddVirtualOne(tls, - pBuilder, mPrereq, libc.Uint64(libc.Uint64FromInt32(-1)), uint16(0x0001), p, *(*U16)(unsafe.Pointer(bp /* mNoOmit */)), bp+4 /* &bIn */) + pBuilder, mPrereq, libc.Uint64(libc.Uint64FromInt32(-1)), WO_IN, p, *(*U16)(unsafe.Pointer(bp /* mNoOmit */)), bp+4 /* &bIn */) mBestNoIn = ((*WhereLoop)(unsafe.Pointer(pNew)).Fprereq & ^mPrereq) if mBestNoIn == uint64(0) { @@ -131501,7 +129356,7 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus // Call xBestIndex once for each distinct value of (prereqRight & ~mPrereq) // in the set of terms that apply to the current virtual table. - for rc == 0 { + for rc == SQLITE_OK { var i int32 var mNext Bitmask = libc.Uint64(libc.Uint64FromInt32(-1)) @@ -131532,7 +129387,7 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus // If the calls to xBestIndex() in the above loop did not find a plan // that requires no source tables at all (i.e. one guaranteed to be // usable), make a call here with all source tables disabled - if (rc == 0) && (seenZero == 0) { + if (rc == SQLITE_OK) && (seenZero == 0) { rc = whereLoopAddVirtualOne(tls, pBuilder, mPrereq, mPrereq, uint16(0), p, *(*U16)(unsafe.Pointer(bp /* mNoOmit */)), bp+4 /* &bIn */) @@ -131544,10 +129399,10 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus // If the calls to xBestIndex() have so far failed to find a plan // that requires no source tables at all and does not use an IN(...) // operator, make a final call to obtain one here. - if (rc == 0) && (seenZeroNoIN == 0) { + if (rc == SQLITE_OK) && (seenZeroNoIN == 0) { rc = whereLoopAddVirtualOne(tls, - pBuilder, mPrereq, mPrereq, uint16(0x0001), p, *(*U16)(unsafe.Pointer(bp /* mNoOmit */)), bp+4 /* &bIn */) + pBuilder, mPrereq, mPrereq, WO_IN, p, *(*U16)(unsafe.Pointer(bp /* mNoOmit */)), bp+4 /* &bIn */) } } @@ -131570,7 +129425,7 @@ func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable var pNew uintptr var pTerm uintptr var pWCEnd uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK var iCur int32 // var tempWC WhereClause at bp+112, 552 @@ -131589,8 +129444,8 @@ func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable pItem = (((*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 /* &.a */) + uintptr((*WhereLoop)(unsafe.Pointer(pNew)).FiTab)*112) iCur = (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor - for pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa; (pTerm < pWCEnd) && (rc == 0); pTerm += 64 { - if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0200) != 0) && + for pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa; (pTerm < pWCEnd) && (rc == SQLITE_OK); pTerm += 64 { + if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_OR) != 0) && (((*WhereOrInfo)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTerm + 40 /* &.u */)))).Findexable & (*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf) != uint64(0)) { var pOrWC uintptr = (*(*uintptr)(unsafe.Pointer(pTerm + 40 /* &.u */)) /* &.wc */) var pOrWCEnd uintptr = ((*WhereClause)(unsafe.Pointer(pOrWC)).Fa + uintptr((*WhereClause)(unsafe.Pointer(pOrWC)).FnTerm)*64) @@ -131604,12 +129459,12 @@ func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable (*WhereLoopBuilder)(unsafe.Pointer(bp + 664 /* &sSubBuild */)).FpOrSet = bp + 56 /* &sCur */ for pOrTerm = (*WhereClause)(unsafe.Pointer(pOrWC)).Fa; pOrTerm < pOrWCEnd; pOrTerm += 64 { - if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & 0x0400) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & WO_AND) != 0 { (*WhereLoopBuilder)(unsafe.Pointer(bp + 664 /* &sSubBuild */)).FpWC = (*(*uintptr)(unsafe.Pointer(pOrTerm + 40 /* &.u */)) /* &.wc */) } else if (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCur { (*WhereClause)(unsafe.Pointer(bp + 112 /* &tempWC */)).FpWInfo = (*WhereClause)(unsafe.Pointer(pWC)).FpWInfo (*WhereClause)(unsafe.Pointer(bp + 112 /* &tempWC */)).FpOuter = pWC - (*WhereClause)(unsafe.Pointer(bp + 112 /* &tempWC */)).Fop = U8(44) + (*WhereClause)(unsafe.Pointer(bp + 112 /* &tempWC */)).Fop = TK_AND (*WhereClause)(unsafe.Pointer(bp + 112 /* &tempWC */)).FnTerm = 1 (*WhereClause)(unsafe.Pointer(bp + 112 /* &tempWC */)).Fa = pOrTerm (*WhereLoopBuilder)(unsafe.Pointer(bp + 664 /* &sSubBuild */)).FpWC = bp + 112 /* &tempWC */ @@ -131622,7 +129477,7 @@ func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable } else { rc = whereLoopAddBtree(tls, bp+664 /* &sSubBuild */, mPrereq) } - if rc == 0 { + if rc == SQLITE_OK { rc = whereLoopAddOr(tls, bp+664 /* &sSubBuild */, mPrereq, mUnusable) } @@ -131647,8 +129502,8 @@ func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable } } (*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = U16(1) - *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(0)*8)) = pTerm - (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(0x00002000) + *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm)) = pTerm + (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = WHERE_MULTI_OR (*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(0) (*WhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = U8(0) libc.Xmemset(tls, (pNew + 24 /* &.u */), 0, uint64(unsafe.Sizeof(struct { @@ -131660,7 +129515,7 @@ func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable FpIndex uintptr } }{}))) - for i = 0; (rc == 0) && (i < int32((*WhereOrSet)(unsafe.Pointer(bp /* &sSum */)).Fn)); i++ { + for i = 0; (rc == SQLITE_OK) && (i < int32((*WhereOrSet)(unsafe.Pointer(bp /* &sSum */)).Fn)); i++ { // TUNING: Currently sSum.a[i].rRun is set to the sum of the costs // of all sub-scans required by the OR-scan. However, due to rounding // errors, it may be that the cost of the OR-scan is equal to its @@ -131694,13 +129549,13 @@ func whereLoopAddAll(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:14921 var pItem uintptr var pEnd uintptr = ((pTabList + 8 /* &.a */) + uintptr((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)*112) var db uintptr = (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb - var rc int32 = 0 + var rc int32 = SQLITE_OK var pNew uintptr // Loop over the tables in the join, from left to right pNew = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew whereLoopInit(tls, pNew) - (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit = uint32(20000) + (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit = SQLITE_QUERY_PLANNER_LIMIT iTab = 0 pItem = pTabList + 8 /* &.a */ __1: @@ -131710,9 +129565,9 @@ __1: { var mUnusable Bitmask = uint64(0) (*WhereLoop)(unsafe.Pointer(pNew)).FiTab = U8(iTab) - *(*uint32)(unsafe.Pointer(pBuilder + 56 /* &.iPlanLimit */)) += (uint32(1000)) + *(*uint32)(unsafe.Pointer(pBuilder + 56 /* &.iPlanLimit */)) += (SQLITE_QUERY_PLANNER_LIMIT_INCR) (*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf = Xsqlite3WhereGetMask(tls, (pWInfo + 656 /* &.sMaskSet */), (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor) - if (int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & (0x0008 | 0x0002)) != 0 { + if (int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & (JT_LEFT | JT_CROSS)) != 0 { // This condition is true when pItem is the FROM clause term on the // right-hand-side of a LEFT or CROSS JOIN. mPrereq = mPrior @@ -131721,8 +129576,8 @@ __1: } if (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem)).FpTab)).FnModuleArg != 0 { var p uintptr - for p = (pItem + uintptr(1)*112); p < pEnd; p += 112 { - if (mUnusable != 0) || ((int32((*SrcList_item)(unsafe.Pointer(p)).Ffg.Fjointype) & (0x0008 | 0x0002)) != 0) { + for p = (pItem + 1*112); p < pEnd; p += 112 { + if (mUnusable != 0) || ((int32((*SrcList_item)(unsafe.Pointer(p)).Ffg.Fjointype) & (JT_LEFT | JT_CROSS)) != 0) { mUnusable = mUnusable | (Xsqlite3WhereGetMask(tls, (pWInfo + 656 /* &.sMaskSet */), (*SrcList_item)(unsafe.Pointer(p)).FiCursor)) } } @@ -131730,15 +129585,15 @@ __1: } else { rc = whereLoopAddBtree(tls, pBuilder, mPrereq) } - if (rc == 0) && ((*WhereClause)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC)).FhasOr != 0) { + if (rc == SQLITE_OK) && ((*WhereClause)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC)).FhasOr != 0) { rc = whereLoopAddOr(tls, pBuilder, mPrereq, mUnusable) } mPrior = mPrior | ((*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf) if (rc != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { - if rc == 101 { + if rc == SQLITE_DONE { // We hit the query planner search limit set by iPlanLimit - Xsqlite3_log(tls, 28, ts+19289 /* "abbreviated quer..." */, 0) - rc = 0 + Xsqlite3_log(tls, SQLITE_WARNING, ts+19289 /* "abbreviated quer..." */, 0) + rc = SQLITE_OK } else { goto __3 } @@ -131820,7 +129675,7 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, // rowid appears in the ORDER BY clause, the corresponding WhereLoop is // automatically order-distinct. - if (nLoop != 0) && ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0040)) != 0) { + if (nLoop != 0) && ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_OrderByIdxJoin)) != 0) { return int8(0) } @@ -131833,9 +129688,9 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, obDone = ((Bitmask((uint64(1))) << (int32(nOrderBy))) - uint64(1)) orderDistinctMask = uint64(0) ready = uint64(0) - eqOpMask = (U16((0x0002 | 0x0080) | 0x0100)) - if (int32(wctrlFlags) & ((0x0800 | 0x0002) | 0x0001)) != 0 { - eqOpMask = U16(int32(eqOpMask) | (0x0001)) + eqOpMask = (U16((WO_EQ | WO_IS) | WO_ISNULL)) + if (int32(wctrlFlags) & ((WHERE_ORDERBY_LIMIT | WHERE_ORDERBY_MAX) | WHERE_ORDERBY_MIN)) != 0 { + eqOpMask = U16(int32(eqOpMask) | (WO_IN)) } for iLoop = 0; ((isOrderDistinct != 0) && (obSat < obDone)) && (iLoop <= int32(nLoop)); iLoop++ { if iLoop > 0 { @@ -131843,18 +129698,18 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, } if iLoop < int32(nLoop) { pLoop = *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pPath)).FaLoop + uintptr(iLoop)*8)) - if (int32(wctrlFlags) & 0x0800) != 0 { + if (int32(wctrlFlags) & WHERE_ORDERBY_LIMIT) != 0 { continue } } else { pLoop = pLast } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000400)) != 0 { - if (*(*I8)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.vtab */) + 5 /* &.isOrdered */)) != 0) && ((int32(wctrlFlags) & 0x0080) == 0) { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_VIRTUALTABLE) != 0 { + if (*(*I8)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.vtab */) + 5 /* &.isOrdered */)) != 0) && ((int32(wctrlFlags) & WHERE_DISTINCTBY) == 0) { obSat = obDone } break - } else if (int32(wctrlFlags) & 0x0080) != 0 { + } else if (int32(wctrlFlags) & WHERE_DISTINCTBY) != 0 { *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 6 /* &.nDistinctCol */)) = U16(0) } iCur = (*SrcList_item)(unsafe.Pointer(((*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 /* &.a */) + uintptr((*WhereLoop)(unsafe.Pointer(pLoop)).FiTab)*112)).FiCursor @@ -131868,7 +129723,7 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, continue } pOBExpr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FpExpr) - if int32((*Expr)(unsafe.Pointer(pOBExpr)).Fop) != 164 { + if int32((*Expr)(unsafe.Pointer(pOBExpr)).Fop) != TK_COLUMN { continue } if (*Expr)(unsafe.Pointer(pOBExpr)).FiTable != iCur { @@ -131879,7 +129734,7 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, if pTerm == uintptr(0) { continue } - if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) == 0x0001 { + if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) == WO_IN { // IN terms are only valid for sorting in the ORDER BY LIMIT // optimization, and then only if they are actually used // by the query plan @@ -131890,7 +129745,7 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, continue } } - if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (0x0002 | 0x0080)) != 0) && (int32((*Expr)(unsafe.Pointer(pOBExpr)).FiColumn) >= 0) { + if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (WO_EQ | WO_IS)) != 0) && (int32((*Expr)(unsafe.Pointer(pOBExpr)).FiColumn) >= 0) { var pParse uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse var pColl1 uintptr = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FpExpr) var pColl2 uintptr = Xsqlite3ExprCompareCollSeq(tls, pParse, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr) @@ -131903,8 +129758,8 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, obSat = obSat | (Bitmask((uint64(1))) << (i)) } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00001000)) == U32(0) { - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000100)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_ONEROW) == U32(0) { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IPK) != 0 { pIndex = uintptr(0) nKeyCol = U16(0) nColumn = U16(1) @@ -131914,8 +129769,8 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, nKeyCol = (*Index)(unsafe.Pointer(pIndex)).FnKeyCol nColumn = (*Index)(unsafe.Pointer(pIndex)).FnColumn - isOrderDistinct = (U8(libc.Bool32((int32((*Index)(unsafe.Pointer((pIndex))).FonError) != 0) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00008000)) == U32(0))))) + isOrderDistinct = (U8(libc.Bool32((int32((*Index)(unsafe.Pointer((pIndex))).FonError) != OE_None) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_SKIPSCAN) == U32(0))))) } // Loop through all columns of the index and deal with the ones @@ -131940,12 +129795,12 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, // if it is one of two or more, none of the columns can be // considered to match an ORDER BY term. if (int32(eOp) & int32(eqOpMask)) != 0 { - if (int32(eOp) & (0x0100 | 0x0080)) != 0 { + if (int32(eOp) & (WO_ISNULL | WO_IS)) != 0 { isOrderDistinct = U8(0) } continue - } else if (int32(eOp) & 0x0001) != 0 { + } else if (int32(eOp) & WO_IN) != 0 { // ALWAYS() justification: eOp is an equality operator due to the // ju.btree.nEq constraint above. Any equality other // than WO_IN is captured by the previous "if". So this one @@ -131965,7 +129820,7 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, // (revIdx) for the j-th column of the index. if pIndex != 0 { iColumn = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(j)*2))) - revIdx = (U8(int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(j)))) & 0x01)) + revIdx = (U8(int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(j)))) & KEYINFO_ORDER_DESC)) if iColumn == int32((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FpTable)).FiPKey) { iColumn = -1 } @@ -131992,11 +129847,11 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, } pOBExpr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FpExpr) - if (int32(wctrlFlags) & (0x0040 | 0x0080)) == 0 { + if (int32(wctrlFlags) & (WHERE_GROUPBY | WHERE_DISTINCTBY)) == 0 { bOnce = U8(0) } if iColumn >= (-1) { - if int32((*Expr)(unsafe.Pointer(pOBExpr)).Fop) != 164 { + if int32((*Expr)(unsafe.Pointer(pOBExpr)).Fop) != TK_COLUMN { continue } if (*Expr)(unsafe.Pointer(pOBExpr)).FiTable != iCur { @@ -132017,30 +129872,30 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, continue } } - if (int32(wctrlFlags) & 0x0080) != 0 { + if (int32(wctrlFlags) & WHERE_DISTINCTBY) != 0 { *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 6 /* &.nDistinctCol */)) = (U16(j + 1)) } isMatch = U8(1) break } - if (isMatch != 0) && ((int32(wctrlFlags) & 0x0040) == 0) { + if (isMatch != 0) && ((int32(wctrlFlags) & WHERE_GROUPBY) == 0) { // Make sure the sort order is compatible in an ORDER BY clause. // Sort order is irrelevant for a GROUP BY clause. if revSet != 0 { - if (int32(rev) ^ int32(revIdx)) != (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & 0x01) { + if (int32(rev) ^ int32(revIdx)) != (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & KEYINFO_ORDER_DESC) { isMatch = U8(0) } } else { - rev = (U8(int32(revIdx) ^ (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & 0x01))) + rev = (U8(int32(revIdx) ^ (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & KEYINFO_ORDER_DESC))) if rev != 0 { *(*Bitmask)(unsafe.Pointer(pRevMask)) |= (Bitmask((uint64(1))) << (iLoop)) } revSet = U8(1) } } - if (isMatch != 0) && ((int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & 0x02) != 0) { + if (isMatch != 0) && ((int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & KEYINFO_ORDER_BIGNULL) != 0) { if j == int32(*(*U16)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.btree */) /* &.nEq */))) { - *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (U32(0x00080000)) + *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (WHERE_BIGNULL_SORT) } else { isMatch = U8(0) } @@ -132152,7 +130007,7 @@ func whereSortingCost(tls *libc.TLS, pWInfo uintptr, nRow LogEst, nOrderBy int32 // Multiple by log(M) where M is the number of output rows. // Use the LIMIT for M if it is smaller - if ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x4000) != 0) && (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FiLimit) < int32(nRow)) { + if ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_USE_LIMIT) != 0) && (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FiLimit) < int32(nRow)) { nRow = (*WhereInfo)(unsafe.Pointer(pWInfo)).FiLimit } rSortCost = LogEst(int32(rSortCost) + (int32(estLog(tls, nRow)))) @@ -132229,7 +130084,7 @@ func wherePathSolver(tls *libc.TLS, pWInfo uintptr, nRowEst LogEst) int32 { /* s nSpace = int32(uint64(nSpace) + (uint64(unsafe.Sizeof(LogEst(0))) * uint64(nOrderBy))) pSpace = Xsqlite3DbMallocRawNN(tls, db, uint64(nSpace)) if pSpace == uintptr(0) { - return 7 + return SQLITE_NOMEM } aTo = pSpace aFrom = (aTo + uintptr(mxChoice)*32) @@ -132270,7 +130125,7 @@ __3: // TUNING: Do not let the number of iterations go above 28. If the cost // of computing an automatic index is not paid back within the first 28 // rows, then do not use the automatic index. - (*WherePath)(unsafe.Pointer(aFrom + uintptr(0)*32)).FnRow = func() int16 { + (*WherePath)(unsafe.Pointer(aFrom)).FnRow = func() int16 { if ((*Parse)(unsafe.Pointer(pParse)).FnQueryLoop) < (U32(48)) { return int16((*Parse)(unsafe.Pointer(pParse)).FnQueryLoop) } @@ -132285,7 +130140,7 @@ __3: // indicate this. Or, if nLoop is greater than zero, set isOrdered to // -1, indicating that the result set may or may not be ordered, // depending on the loops added to the current plan. - (*WherePath)(unsafe.Pointer(aFrom + uintptr(0)*32)).FisOrdered = func() int8 { + (*WherePath)(unsafe.Pointer(aFrom)).FisOrdered = func() int8 { if nLoop > 0 { return int8(-1) } @@ -132319,7 +130174,7 @@ __3: if ((*WhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf & (*WherePath)(unsafe.Pointer(pFrom)).FmaskLoop) != uint64(0) { continue } - if (((*WhereLoop)(unsafe.Pointer(pWLoop)).FwsFlags & U32(0x00004000)) != U32(0)) && (int32((*WherePath)(unsafe.Pointer(pFrom)).FnRow) < 3) { + if (((*WhereLoop)(unsafe.Pointer(pWLoop)).FwsFlags & WHERE_AUTO_INDEX) != U32(0)) && (int32((*WherePath)(unsafe.Pointer(pFrom)).FnRow) < 3) { // Do not use an automatic index if the this loop is expected // to run less than 1.25 times. It is tempting to also exclude // automatic index usage on an outer loop, but sometimes an automatic @@ -132439,10 +130294,10 @@ __3: *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pTo)).FaLoop + uintptr(iLoop)*8)) = pWLoop if nTo >= mxChoice { mxI = 0 - mxCost = (*WherePath)(unsafe.Pointer(aTo + uintptr(0)*32)).FrCost - mxUnsorted = (*WherePath)(unsafe.Pointer(aTo + uintptr(0)*32)).FnRow + mxCost = (*WherePath)(unsafe.Pointer(aTo)).FrCost + mxUnsorted = (*WherePath)(unsafe.Pointer(aTo)).FnRow jj = 1 - pTo = (aTo + uintptr(1)*32) + pTo = (aTo + 1*32) __10: if !(jj < mxChoice) { goto __12 @@ -132486,7 +130341,7 @@ __3: if nFrom == 0 { Xsqlite3ErrorMsg(tls, pParse, ts+19324 /* "no query solutio..." */, 0) Xsqlite3DbFreeNN(tls, db, pSpace) - return 1 + return SQLITE_ERROR } // Find the lowest cost path. pFrom will be left pointing to that path @@ -132504,23 +130359,23 @@ __3: (*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom = (*WhereLoop)(unsafe.Pointer(pWLoop)).FiTab (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur = (*SrcList_item)(unsafe.Pointer(((*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 /* &.a */) + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*112)).FiCursor } - if ((((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0100) != 0) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0080) == 0)) && - (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == 0)) && + if ((((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_WANT_DISTINCT) != 0) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_DISTINCTBY) == 0)) && + (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == WHERE_DISTINCT_NOOP)) && (nRowEst != 0) { // var notUsed Bitmask at bp+8, 8 var rc int32 = int32(wherePathSatisfiesOrderBy(tls, pWInfo, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet, pFrom, - uint16(0x0080), (uint16(nLoop - 1)), *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr((nLoop-1))*8)), bp+8 /* ¬Used */)) + WHERE_DISTINCTBY, (uint16(nLoop - 1)), *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr((nLoop-1))*8)), bp+8 /* ¬Used */)) if rc == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet)).FnExpr { - (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(2) + (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = WHERE_DISTINCT_ORDERED } } libc.SetBitFieldPtr8Uint32(pWInfo+68 /* &.bOrderedInnerLoop */, uint32(0), 2, 0x4) if (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 { - if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0080) != 0 { + if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_DISTINCTBY) != 0 { if int32((*WherePath)(unsafe.Pointer(pFrom)).FisOrdered) == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr { - (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(2) + (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = WHERE_DISTINCT_ORDERED } } else { (*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = (*WherePath)(unsafe.Pointer(pFrom)).FisOrdered @@ -132529,11 +130384,11 @@ __3: (*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = int8(0) if nLoop > 0 { var wsFlags U32 = (*WhereLoop)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr((nLoop-1))*8)))).FwsFlags - if ((wsFlags & U32(0x00001000)) == U32(0)) && - ((wsFlags & (U32(0x00000100 | 0x00000004))) != (U32(0x00000100 | 0x00000004))) { + if ((wsFlags & WHERE_ONEROW) == U32(0)) && + ((wsFlags & (U32(WHERE_IPK | WHERE_COLUMN_IN))) != (U32(WHERE_IPK | WHERE_COLUMN_IN))) { *(*Bitmask)(unsafe.Pointer(bp + 16 /* m */)) = uint64(0) var rc int32 = int32(wherePathSatisfiesOrderBy(tls, pWInfo, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy, pFrom, - uint16(0x0800), (uint16(nLoop - 1)), *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr((nLoop-1))*8)), bp+16 /* &m */)) + WHERE_ORDERBY_LIMIT, (uint16(nLoop - 1)), *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr((nLoop-1))*8)), bp+16 /* &m */)) if rc == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr { libc.SetBitFieldPtr8Uint32(pWInfo+68 /* &.bOrderedInnerLoop */, uint32(1), 2, 0x4) @@ -132543,11 +130398,11 @@ __3: } } else if ((nLoop != 0) && (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) == 1)) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & (0x0001 | 0x0002)) != 0) { + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & (WHERE_ORDERBY_MIN | WHERE_ORDERBY_MAX)) != 0) { libc.SetBitFieldPtr8Uint32(pWInfo+68 /* &.bOrderedInnerLoop */, uint32(1), 2, 0x4) } } - if (((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0200) != 0) && + if (((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_SORTBYGROUP) != 0) && (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr)) && (nLoop > 0) { *(*Bitmask)(unsafe.Pointer(bp + 24 /* revMask */)) = uint64(0) var nOrder int32 = int32(wherePathSatisfiesOrderBy(tls, pWInfo, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy, @@ -132564,7 +130419,7 @@ __3: // Free temporary memory and return success Xsqlite3DbFreeNN(tls, db, pSpace) - return 0 + return SQLITE_OK } // Most queries use only a single table (they are not joins) and have @@ -132588,7 +130443,7 @@ func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:150086: var pIdx uintptr pWInfo = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo - if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0020) != 0 { + if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_OR_SUBCLAUSE) != 0 { return 0 } @@ -132605,11 +130460,11 @@ func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:150086: pLoop = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = U32(0) (*WhereLoop)(unsafe.Pointer(pLoop)).FnSkip = U16(0) - pTerm = Xsqlite3WhereFindTerm(tls, pWC, iCur, -1, uint64(0), (uint32(0x0002 | 0x0080)), uintptr(0)) + pTerm = Xsqlite3WhereFindTerm(tls, pWC, iCur, -1, uint64(0), (uint32(WO_EQ | WO_IS)), uintptr(0)) if pTerm != 0 { - (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = (U32((0x00000001 | 0x00000100) | 0x00001000)) - *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(0)*8)) = pTerm + (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = (U32((WHERE_COLUMN_EQ | WHERE_IPK) | WHERE_ONEROW)) + *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) = pTerm (*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm = U16(1) *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ /* &.nEq */)) = U16(1) // TUNING: Cost of a rowid lookup is 10 @@ -132618,15 +130473,15 @@ func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:150086: for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { var opMask int32 - if (!(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0) || + if (!(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None) || ((*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0))) || (int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) > (int32(uint64(unsafe.Sizeof([3]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))))) { continue } if (uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 100 /* &.uniqNotNull */)) & 0x8 >> 3))) != 0 { - opMask = (0x0002 | 0x0080) + opMask = (WO_EQ | WO_IS) } else { - opMask = 0x0002 + opMask = WO_EQ } for j = 0; j < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol); j++ { pTerm = Xsqlite3WhereFindTerm(tls, pWC, iCur, j, uint64(0), uint32(opMask), pIdx) @@ -132639,9 +130494,9 @@ func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:150086: if j != int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) { continue } - (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = (U32((0x00000001 | 0x00001000) | 0x00000200)) + (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = (U32((WHERE_COLUMN_EQ | WHERE_ONEROW) | WHERE_INDEXED)) if ((uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 100 /* &.isCovering */)) & 0x20 >> 5))) != 0) || (((*SrcList_item)(unsafe.Pointer(pItem)).FcolUsed & (*Index)(unsafe.Pointer(pIdx)).FcolNotIdxed) == uint64(0)) { - *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (U32(0x00000040)) + *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (WHERE_IDX_ONLY) } (*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm = U16(j) *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ /* &.nEq */)) = U16(j) @@ -132653,16 +130508,16 @@ func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:150086: } if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags != 0 { (*WhereLoop)(unsafe.Pointer(pLoop)).FnOut = int16(1) - (*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */) + uintptr(0)*88)).FpWLoop = pLoop + (*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */))).FpWLoop = pLoop (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf = uint64(1) // sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); - (*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */) + uintptr(0)*88)).FiTabCur = iCur + (*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */))).FiTabCur = iCur (*WhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut = int16(1) if (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 { (*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = I8((*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr) } - if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0100) != 0 { - (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(1) + if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_WANT_DISTINCT) != 0 { + (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = WHERE_DISTINCT_UNIQUE } return 1 } @@ -132671,11 +130526,11 @@ func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:150086: // Helper function for exprIsDeterministic(). func exprNodeIsDeterministic(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:150168:12: */ - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 169) && ((libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x080000))) != U32(0))) == 0) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_FUNCTION) && ((libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_ConstFunc)) != U32(0))) == 0) { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 + return WRC_Abort } - return 0 + return WRC_Continue } // Return true if the expression contains no non-deterministic SQL @@ -132852,10 +130707,10 @@ __1: // Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via // sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) - if !((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0010)) != 0) { + if !((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_DistinctOpt)) != 0) { goto __2 } - wctrlFlags = libc.Uint16FromInt32(int32(wctrlFlags) & (^libc.Int32(0x0100))) + wctrlFlags = libc.Uint16FromInt32(int32(wctrlFlags) & (libc.CplInt32(WHERE_WANT_DISTINCT))) __2: ; @@ -132874,7 +130729,7 @@ __3: // pTabList. But if the WHERE_OR_SUBCLAUSE flag is set, then we should // only generate code for the first table in pTabList and assume that // any cursors associated with subsequent tables are uninitialized. - if (int32(wctrlFlags) & 0x0020) != 0 { + if (int32(wctrlFlags) & WHERE_OR_SUBCLAUSE) != 0 { nTabList = 1 } else { nTabList = (*SrcList)(unsafe.Pointer(pTabList)).FnSrc @@ -132886,7 +130741,7 @@ __3: // and the WhereMaskSet structure. Since WhereClause contains an 8-byte // field (type Bitmask) it must be aligned on an 8-byte boundary on // some architectures. Hence the ROUND8() below. - nByteWInfo = (int32(((uint64(unsafe.Sizeof(WhereInfo{})) + ((uint64(nTabList - 1)) * uint64(unsafe.Sizeof(WhereLevel{})))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + nByteWInfo = (int32(((uint64(unsafe.Sizeof(WhereInfo{})) + ((uint64(nTabList - 1)) * uint64(unsafe.Sizeof(WhereLevel{})))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) pWInfo = Xsqlite3DbMallocRawNN(tls, db, (uint64(uint64(nByteWInfo) + uint64(unsafe.Sizeof(WhereLoop{}))))) if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __4 @@ -132901,7 +130756,7 @@ __4: (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy = pOrderBy (*WhereInfo)(unsafe.Pointer(pWInfo)).FpWhere = pWhere (*WhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet = pResultSet - *(*int32)(unsafe.Pointer((pWInfo + 40 /* &.aiCurOnePass */) + uintptr(0)*4)) = libc.AssignPtrInt32((pWInfo+40 /* &.aiCurOnePass */)+uintptr(1)*4, -1) + *(*int32)(unsafe.Pointer((pWInfo + 40 /* &.aiCurOnePass */))) = libc.AssignPtrInt32((pWInfo+40 /* &.aiCurOnePass */)+1*4, -1) (*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel = U8(nTabList) (*WhereInfo)(unsafe.Pointer(pWInfo)).FiBreak = libc.AssignPtrInt32(pWInfo+48 /* &.iContinue */, Xsqlite3VdbeMakeLabel(tls, pParse)) (*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags = wctrlFlags @@ -132909,7 +130764,7 @@ __4: (*WhereInfo)(unsafe.Pointer(pWInfo)).FsavedNQueryLoop = int32((*Parse)(unsafe.Pointer(pParse)).FnQueryLoop) libc.Xmemset(tls, (pWInfo + 65 /* &.nOBSat */), 0, ((uint64((uintptr(0) + 104 /* &.sWC */))) - (uint64((uintptr(0) + 65 /* &.nOBSat */))))) - libc.Xmemset(tls, ((pWInfo + 920 /* &.a */) + uintptr(0)*88), 0, (uint64(unsafe.Sizeof(WhereLoop{})) + (uint64(nTabList) * uint64(unsafe.Sizeof(WhereLevel{}))))) + libc.Xmemset(tls, (pWInfo + 920 /* &.a */), 0, (uint64(unsafe.Sizeof(WhereLoop{})) + (uint64(nTabList) * uint64(unsafe.Sizeof(WhereLevel{}))))) // ONEPASS defaults to OFF pMaskSet = (pWInfo + 656 /* &.sMaskSet */) (*WhereLoopBuilder)(unsafe.Pointer(bp + 8 /* &sWLB */)).FpWInfo = pWInfo @@ -132922,7 +130777,7 @@ __4: // subexpression is separated by an AND operator. (*WhereMaskSet)(unsafe.Pointer(pMaskSet)).Fn = 0 Xsqlite3WhereClauseInit(tls, (pWInfo + 104 /* &.sWC */), pWInfo) - Xsqlite3WhereSplit(tls, (pWInfo + 104 /* &.sWC */), pWhere, uint8(44)) + Xsqlite3WhereSplit(tls, (pWInfo + 104 /* &.sWC */), pWhere, TK_AND) // Special case: No FROM clause if !(nTabList == 0) { @@ -132934,10 +130789,10 @@ __4: (*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = I8((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr) __7: ; - if !((int32(wctrlFlags) & 0x0100) != 0) { + if !((int32(wctrlFlags) & WHERE_WANT_DISTINCT) != 0) { goto __8 } - (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(1) + (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = WHERE_DISTINCT_UNIQUE __8: ; Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+19370 /* "SCAN CONSTANT RO..." */, 0) @@ -132996,7 +130851,7 @@ __13: goto __15 } pT = ((*WhereClause)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(bp+8 /* &sWLB */)).FpWC)).Fa + uintptr(ii)*64) - if !((int32((*WhereTerm)(unsafe.Pointer(pT)).FwtFlags) & 0x0002) != 0) { + if !((int32((*WhereTerm)(unsafe.Pointer(pT)).FwtFlags) & TERM_VIRTUAL) != 0) { goto __16 } goto __14 @@ -133005,8 +130860,8 @@ __16: if !(((*WhereTerm)(unsafe.Pointer(pT)).FprereqAll == uint64(0)) && ((nTabList == 0) || (exprIsDeterministic(tls, (*WhereTerm)(unsafe.Pointer(pT)).FpExpr) != 0))) { goto __17 } - Xsqlite3ExprIfFalse(tls, pParse, (*WhereTerm)(unsafe.Pointer(pT)).FpExpr, (*WhereInfo)(unsafe.Pointer(pWInfo)).FiBreak, 0x10) - *(*U16)(unsafe.Pointer(pT + 18 /* &.wtFlags */)) |= U16((0x0004)) + Xsqlite3ExprIfFalse(tls, pParse, (*WhereTerm)(unsafe.Pointer(pT)).FpExpr, (*WhereInfo)(unsafe.Pointer(pWInfo)).FiBreak, SQLITE_JUMPIFNULL) + *(*U16)(unsafe.Pointer(pT + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) __17: ; goto __14 @@ -133017,21 +130872,21 @@ __14: __15: ; - if !((int32(wctrlFlags) & 0x0100) != 0) { + if !((int32(wctrlFlags) & WHERE_WANT_DISTINCT) != 0) { goto __18 } if !(isDistinctRedundant(tls, pParse, pTabList, (pWInfo+104 /* &.sWC */), pResultSet) != 0) { goto __19 } // The DISTINCT marking is pointless. Ignore it. - (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(1) + (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = WHERE_DISTINCT_UNIQUE goto __20 __19: if !(pOrderBy == uintptr(0)) { goto __21 } // Try to ORDER BY the result set to make distinct processing easier - *(*U16)(unsafe.Pointer(pWInfo + 60 /* &.wctrlFlags */)) |= U16((0x0080)) + *(*U16)(unsafe.Pointer(pWInfo + 60 /* &.wctrlFlags */)) |= U16((WHERE_DISTINCTBY)) (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy = pResultSet __21: ; @@ -133058,7 +130913,7 @@ __23: // changed based on STAT4 information while computing subsequent loops, // then we need to rerun the whole loop building process so that all // loops will be built using the revised truthProb values. - if !((int32((*WhereLoopBuilder)(unsafe.Pointer(bp+8 /* &sWLB */)).FbldFlags2) & 0x0004) != 0) { + if !((int32((*WhereLoopBuilder)(unsafe.Pointer(bp+8 /* &sWLB */)).FbldFlags2) & SQLITE_BLDF2_2NDPASS) != 0) { goto __24 } @@ -133103,7 +130958,7 @@ __29: ; __22: ; - if !(((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy == uintptr(0)) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00001000)) != uint64(0))) { + if !(((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy == uintptr(0)) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ReverseOrder) != uint64(0))) { goto __31 } (*WhereInfo)(unsafe.Pointer(pWInfo)).FrevMask = libc.Uint64(libc.Uint64FromInt32(-1)) @@ -133144,10 +130999,10 @@ __32: // SELECT DISTINCT v1, v3 FROM t1 // LEFT JOIN t2 // LEFT JOIN t3 ON (t1.ipk=t3.ipk) - notReady = ^Bitmask(0) + notReady = libc.CplUint64(uint64(0)) if !(((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) >= 2) && (pResultSet != uintptr(0))) && // guarantees condition (1) above - ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0100)) == 0)) { + ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_OmitNoopJoin)) == 0)) { goto __33 } tabUsed = Xsqlite3WhereExprListUsage(tls, pMaskSet, pResultSet) @@ -133164,14 +131019,14 @@ __35: } pLoop = (*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */) + uintptr(i)*88)).FpWLoop pItem = (((*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 /* &.a */) + uintptr((*WhereLoop)(unsafe.Pointer(pLoop)).FiTab)*112) - if !((int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & 0x0008) == 0) { + if !((int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & JT_LEFT) == 0) { goto __38 } goto __36 __38: ; - if !(((int32(wctrlFlags) & 0x0100) == 0) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00001000)) == U32(0))) { + if !(((int32(wctrlFlags) & WHERE_WANT_DISTINCT) == 0) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_ONEROW) == U32(0))) { goto __39 } goto __36 @@ -133192,7 +131047,7 @@ __41: if !(((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf) != uint64(0)) { goto __44 } - if !(!(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000001))) != U32(0)) || + if !(!(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_FromJoin)) != U32(0)) || (int32((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FiRightJoinTable) != (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor)) { goto __45 } @@ -133224,7 +131079,7 @@ __47: if !(((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf) != uint64(0)) { goto __50 } - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) __50: ; goto __48 @@ -133273,33 +131128,33 @@ __33: // use a one-pass approach, and this is not set accurately for scans // that use the OR optimization. - if !((int32(wctrlFlags) & 0x0004) != 0) { + if !((int32(wctrlFlags) & WHERE_ONEPASS_DESIRED) != 0) { goto __52 } - wsFlags = int32((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */) + uintptr(0)*88)).FpWLoop)).FwsFlags) - bOnerow = (libc.Bool32((wsFlags & 0x00001000) != 0)) + wsFlags = int32((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */))).FpWLoop)).FwsFlags) + bOnerow = (libc.Bool32((wsFlags & WHERE_ONEROW) != 0)) - if !((bOnerow != 0) || (((0 != (int32(wctrlFlags) & 0x0008)) && - !((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pTabList+8 /* &.a */)+uintptr(0)*112)).FpTab)).FnModuleArg != 0)) && - ((0 == (wsFlags & 0x00002000)) || ((int32(wctrlFlags) & 0x0010) != 0)))) { + if !((bOnerow != 0) || (((0 != (int32(wctrlFlags) & WHERE_ONEPASS_MULTIROW)) && + !((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FpTab)).FnModuleArg != 0)) && + ((0 == (wsFlags & WHERE_MULTI_OR)) || ((int32(wctrlFlags) & WHERE_DUPLICATES_OK) != 0)))) { goto __53 } (*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass = func() uint8 { if bOnerow != 0 { - return uint8(1) + return ONEPASS_SINGLE } - return uint8(2) + return ONEPASS_MULTI }() - if !((((*Table)(unsafe.Pointer(((*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FpTab))).FtabFlags & U32(0x0080)) == U32(0)) && ((wsFlags & 0x00000040) != 0)) { + if !((((*Table)(unsafe.Pointer(((*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FpTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((wsFlags & WHERE_IDX_ONLY) != 0)) { goto __54 } - if !((int32(wctrlFlags) & 0x0008) != 0) { + if !((int32(wctrlFlags) & WHERE_ONEPASS_MULTIROW) != 0) { goto __55 } - bFordelete = U8(0x08) + bFordelete = OPFLAG_FORDELETE __55: ; - (*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */) + uintptr(0)*88)).FpWLoop)).FwsFlags = (U32(wsFlags & ^libc.Int32(0x00000040))) + (*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */))).FpWLoop)).FwsFlags = (U32(wsFlags & libc.CplInt32(WHERE_IDX_ONLY))) __54: ; __53: @@ -133320,18 +131175,18 @@ __56: pTab = (*SrcList_item)(unsafe.Pointer(pTabItem)).FpTab iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop - if !((((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0002)) != U32(0)) || ((*Table)(unsafe.Pointer(pTab)).FpSelect != 0)) { + if !((((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Ephemeral) != U32(0)) || ((*Table)(unsafe.Pointer(pTab)).FpSelect != 0)) { goto __59 } // Do nothing goto __60 __59: - if !(((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000400)) != U32(0)) { + if !(((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_VIRTUALTABLE) != U32(0)) { goto __61 } pVTab = Xsqlite3GetVTable(tls, db, pTab) iCur = (*SrcList_item)(unsafe.Pointer(pTabItem)).FiCursor - Xsqlite3VdbeAddOp4(tls, v, 165, iCur, 0, 0, pVTab, -12) + Xsqlite3VdbeAddOp4(tls, v, OP_VOpen, iCur, 0, 0, pVTab, -12) goto __62 __61: if !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { @@ -133340,24 +131195,24 @@ __61: // noop goto __64 __63: - if !((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000040)) == U32(0)) && - ((int32(wctrlFlags) & 0x0020) == 0)) { + if !((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IDX_ONLY) == U32(0)) && + ((int32(wctrlFlags) & WHERE_OR_SUBCLAUSE) == 0)) { goto __65 } - op = 96 - if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != 0) { + op = OP_OpenRead + if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != ONEPASS_OFF) { goto __67 } - op = 97 - *(*int32)(unsafe.Pointer((pWInfo + 40 /* &.aiCurOnePass */) + uintptr(0)*4)) = (*SrcList_item)(unsafe.Pointer(pTabItem)).FiCursor + op = OP_OpenWrite + *(*int32)(unsafe.Pointer((pWInfo + 40 /* &.aiCurOnePass */))) = (*SrcList_item)(unsafe.Pointer(pTabItem)).FiCursor __67: ; Xsqlite3OpenTable(tls, pParse, (*SrcList_item)(unsafe.Pointer(pTabItem)).FiCursor, iDb, pTab, op) - if !(((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == 0) && + if !(((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == ONEPASS_OFF) && (int32((*Table)(unsafe.Pointer(pTab)).FnCol) < (int32(uint64(unsafe.Sizeof(Bitmask(0))) * uint64(8))))) && - (((*Table)(unsafe.Pointer(pTab)).FtabFlags & (U32(0x0060 | 0x0080))) == U32(0))) { + (((*Table)(unsafe.Pointer(pTab)).FtabFlags & (U32(TF_HasGenerated | TF_WithoutRowid))) == U32(0))) { goto __68 } // If we know that only a prefix of the record will be used, @@ -133395,15 +131250,15 @@ __62: ; __60: ; - if !(((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000200)) != 0) { + if !(((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_INDEXED) != 0) { goto __72 } pIx = *(*uintptr)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) - op1 = 96 + op1 = OP_OpenRead // iAuxArg is always set to a positive value if ONEPASS is possible - if !((!(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2)) && - ((int32(wctrlFlags) & 0x0020) != 0)) { + if !((!(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY)) && + ((int32(wctrlFlags) & WHERE_OR_SUBCLAUSE) != 0)) { goto __73 } // This is one term of an OR-optimization using the PRIMARY KEY of a @@ -133412,7 +131267,7 @@ __60: op1 = 0 goto __74 __73: - if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != 0) { + if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != ONEPASS_OFF) { goto __75 } pJ = (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pTabItem)).FpTab)).FpIndex @@ -133427,15 +131282,15 @@ __77: goto __77 __78: ; - op1 = 97 - *(*int32)(unsafe.Pointer((pWInfo + 40 /* &.aiCurOnePass */) + uintptr(1)*4)) = iIndexCur + op1 = OP_OpenWrite + *(*int32)(unsafe.Pointer((pWInfo + 40 /* &.aiCurOnePass */) + 1*4)) = iIndexCur goto __76 __75: - if !((iAuxArg != 0) && ((int32(wctrlFlags) & 0x0020) != 0)) { + if !((iAuxArg != 0) && ((int32(wctrlFlags) & WHERE_OR_SUBCLAUSE) != 0)) { goto __79 } iIndexCur = iAuxArg - op1 = 95 + op1 = OP_ReopenIdx goto __80 __79: iIndexCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) @@ -133452,14 +131307,14 @@ __74: } Xsqlite3VdbeAddOp3(tls, v, op1, iIndexCur, int32((*Index)(unsafe.Pointer(pIx)).Ftnum), iDb) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIx) - if !(((((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x0000000f)) != U32(0)) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(0x00000002 | 0x00008000))) == U32(0))) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00080000)) == U32(0))) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0001) == 0)) && - (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) != 2)) { + if !(((((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_CONSTRAINT) != U32(0)) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(WHERE_COLUMN_RANGE | WHERE_SKIPSCAN))) == U32(0))) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_BIGNULL_SORT) == U32(0))) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_ORDERBY_MIN) == 0)) && + (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) != WHERE_DISTINCT_ORDERED)) { goto __82 } - Xsqlite3VdbeChangeP5(tls, v, uint16(0x02)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_SEEKEQ) __82: ; @@ -133499,7 +131354,7 @@ __85: } pLevel = ((pWInfo + 920 /* &.a */) + uintptr(ii)*88) wsFlags1 = int32((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags) - if !(((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags & U32(0x00004000)) != U32(0)) { + if !(((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags & WHERE_AUTO_INDEX) != U32(0)) { goto __88 } constructAutomaticIndex(tls, pParse, (pWInfo + 104 /* &.sWC */), @@ -133517,7 +131372,7 @@ __88: (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBody = Xsqlite3VdbeCurrentAddr(tls, v) notReady = Xsqlite3WhereCodeOneLoopStart(tls, pParse, v, pWInfo, ii, pLevel, notReady) (*WhereInfo)(unsafe.Pointer(pWInfo)).FiContinue = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont - if !(((wsFlags1 & 0x00002000) == 0) && ((int32(wctrlFlags) & 0x0020) == 0)) { + if !(((wsFlags1 & WHERE_MULTI_OR) == 0) && ((int32(wctrlFlags) & WHERE_OR_SUBCLAUSE) == 0)) { goto __90 } _ = addrExplain @@ -133569,13 +131424,13 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * var addr int32 pLevel = ((pWInfo + 920 /* &.a */) + uintptr(i)*88) pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop - if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) != 173 { + if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) != OP_Noop { var addrSeek int32 = 0 var pIdx uintptr var n int32 - if (((((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == 2) && + if (((((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == WHERE_DISTINCT_ORDERED) && (i == (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - 1))) && // Ticket [ef9318757b152e3] 2017-10-21 - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000200)) != U32(0))) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_INDEXED) != U32(0))) && ((uint32(int32(*(*uint16)(unsafe.Pointer((libc.AssignUintptr(&pIdx, *(*uintptr)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)))) + 100 /* &.hasStat1 */)) & 0x80 >> 7))) != 0)) && ((libc.AssignInt32(&n, int32(*(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 6 /* &.nDistinctCol */))))) > 0)) && (int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowLogEst + uintptr(n)*2))) >= 36) { @@ -133583,17 +131438,17 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * var j int32 var op int32 for j = 0; j < n; j++ { - Xsqlite3VdbeAddOp3(tls, v, 89, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, j, (r1 + j)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, j, (r1 + j)) } *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (n + 1) - if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) == 4 { - op = 22 + if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) == OP_Prev { + op = OP_SeekLT } else { - op = 25 + op = OP_SeekGT } addrSeek = Xsqlite3VdbeAddOp4Int(tls, v, op, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, 0, r1, n) - Xsqlite3VdbeAddOp2(tls, v, 11, 1, (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 1, (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2) } // The common case: Advance to the next row Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont) @@ -133602,7 +131457,7 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * if (*WhereLevel)(unsafe.Pointer(pLevel)).FregBignull != 0 { Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull) - Xsqlite3VdbeAddOp2(tls, v, 59, (*WhereLevel)(unsafe.Pointer(pLevel)).FregBignull, ((*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 - 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_DecrJumpZero, (*WhereLevel)(unsafe.Pointer(pLevel)).FregBignull, ((*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 - 1)) } if addrSeek != 0 { @@ -133611,7 +131466,7 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * } else { Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont) } - if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000800)) != 0) && (*(*int32)(unsafe.Pointer((pLevel + 56 /* &.u */ /* &.in */) /* &.nIn */)) > 0) { + if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IN_ABLE) != 0) && (*(*int32)(unsafe.Pointer((pLevel + 56 /* &.u */ /* &.in */) /* &.nIn */)) > 0) { var pIn uintptr var j int32 Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt) @@ -133623,7 +131478,7 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * } { Xsqlite3VdbeJumpHere(tls, v, ((*InLoop)(unsafe.Pointer(pIn)).FaddrInTop + 1)) - if int32((*InLoop)(unsafe.Pointer(pIn)).FeEndLoopOp) != 173 { + if int32((*InLoop)(unsafe.Pointer(pIn)).FeEndLoopOp) != OP_Noop { if (*InLoop)(unsafe.Pointer(pIn)).FnPrefix != 0 { if (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { @@ -133635,12 +131490,12 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * // return the null-row. So, if the cursor is not open yet, // jump over the OP_Next or OP_Prev instruction about to // be coded. - Xsqlite3VdbeAddOp2(tls, v, 26, (*InLoop)(unsafe.Pointer(pIn)).FiCur, - ((Xsqlite3VdbeCurrentAddr(tls, v) + 2) + (libc.Bool32(((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000400)) == U32(0))))) + Xsqlite3VdbeAddOp2(tls, v, OP_IfNotOpen, (*InLoop)(unsafe.Pointer(pIn)).FiCur, + ((Xsqlite3VdbeCurrentAddr(tls, v) + 2) + (libc.Bool32(((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_VIRTUALTABLE) == U32(0))))) } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000400)) == U32(0) { - Xsqlite3VdbeAddOp4Int(tls, v, 27, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_VIRTUALTABLE) == U32(0) { + Xsqlite3VdbeAddOp4Int(tls, v, OP_IfNoHope, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, (Xsqlite3VdbeCurrentAddr(tls, v) + 2), (*InLoop)(unsafe.Pointer(pIn)).FiBase, (*InLoop)(unsafe.Pointer(pIn)).FnPrefix) @@ -133669,18 +131524,18 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * } if (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { var ws int32 = int32((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags) - addr = Xsqlite3VdbeAddOp1(tls, v, 48, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) + addr = Xsqlite3VdbeAddOp1(tls, v, OP_IfPos, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) - if (ws & 0x00000040) == 0 { + if (ws & WHERE_IDX_ONLY) == 0 { - Xsqlite3VdbeAddOp1(tls, v, 128, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur) + Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur) } - if ((ws & 0x00000200) != 0) || - (((ws & 0x00002000) != 0) && (*(*uintptr)(unsafe.Pointer(pLevel + 56 /* &.u */)) != 0)) { - Xsqlite3VdbeAddOp1(tls, v, 128, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur) + if ((ws & WHERE_INDEXED) != 0) || + (((ws & WHERE_MULTI_OR) != 0) && (*(*uintptr)(unsafe.Pointer(pLevel + 56 /* &.u */)) != 0)) { + Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur) } - if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) == 65 { - Xsqlite3VdbeAddOp2(tls, v, 12, (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst) + if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) == OP_Return { + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst) } else { Xsqlite3VdbeGoto(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst) } @@ -133729,13 +131584,13 @@ __4: // directly. This loop scans all that code looking for opcodes // that reference the table and converts them into opcodes that // reference the index. - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(0x00000200 | 0x00000040))) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(WHERE_INDEXED | WHERE_IDX_ONLY))) != 0 { pIdx = *(*uintptr)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) - } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00002000)) != 0 { + } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_MULTI_OR) != 0 { pIdx = *(*uintptr)(unsafe.Pointer(pLevel + 56 /* &.u */)) } if ((pIdx != 0) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == 0) || !(((*Table)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FpTable))).FtabFlags & U32(0x0080)) == U32(0)))) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == ONEPASS_OFF) || !(((*Table)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FpTable))).FtabFlags & TF_WithoutRowid) == U32(0)))) && !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) { last = Xsqlite3VdbeCurrentAddr(tls, v) k = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBody @@ -133748,11 +131603,11 @@ __4: if (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 != (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur { goto __8 } - if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 89) || - (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 88) { + if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column) || + (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Offset) { var x int32 = (*VdbeOp)(unsafe.Pointer(pOp)).Fp2 - if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { var pPk uintptr = Xsqlite3PrimaryKeyIndex(tls, pTab) x = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(x)*2))) @@ -133767,11 +131622,11 @@ __4: } - } else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 127 { + } else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Rowid { (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur - (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(134) + (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = OP_IdxRowid - } else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 21 { + } else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_IfNullRow { (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur } @@ -134019,20 +131874,20 @@ func nth_valueStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { if !(p != 0) { goto __1 } - switch Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(1)*8))) { - case 1: + switch Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*8))) { + case SQLITE_INTEGER: goto __3 - case 2: + case SQLITE_FLOAT: goto __4 default: goto __5 } goto __2 __3: - iVal = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(1)*8))) + iVal = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*8))) goto __2 __4: - fVal = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(1)*8))) + fVal = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*8))) if !((float64(I64(fVal))) != fVal) { goto __6 } @@ -134057,7 +131912,7 @@ __7: if !(iVal == (*NthValueCtx)(unsafe.Pointer(p)).FnStep) { goto __8 } - (*NthValueCtx)(unsafe.Pointer(p)).FpValue = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) + (*NthValueCtx)(unsafe.Pointer(p)).FpValue = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg))) if !(!(int32((*NthValueCtx)(unsafe.Pointer(p)).FpValue) != 0)) { goto __9 } @@ -134091,7 +131946,7 @@ func first_valueStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) var p uintptr p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(NthValueCtx{}))) if (p != 0) && ((*NthValueCtx)(unsafe.Pointer(p)).FpValue == uintptr(0)) { - (*NthValueCtx)(unsafe.Pointer(p)).FpValue = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) + (*NthValueCtx)(unsafe.Pointer(p)).FpValue = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg))) if !(int32((*NthValueCtx)(unsafe.Pointer(p)).FpValue) != 0) { Xsqlite3_result_error_nomem(tls, pCtx) } @@ -134220,7 +132075,7 @@ func ntileStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { /* p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(NtileCtx{}))) if p != 0 { if (*NtileCtx)(unsafe.Pointer(p)).FnTotal == int64(0) { - (*NtileCtx)(unsafe.Pointer(p)).FnParam = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) + (*NtileCtx)(unsafe.Pointer(p)).FnParam = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg))) if (*NtileCtx)(unsafe.Pointer(p)).FnParam <= int64(0) { Xsqlite3_result_error(tls, pCtx, ts+19444 /* "argument of ntil..." */, -1) @@ -134273,7 +132128,7 @@ func last_valueStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(LastValueCtx{}))) if p != 0 { Xsqlite3_value_free(tls, (*LastValueCtx)(unsafe.Pointer(p)).FpVal) - (*LastValueCtx)(unsafe.Pointer(p)).FpVal = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) + (*LastValueCtx)(unsafe.Pointer(p)).FpVal = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg))) if (*LastValueCtx)(unsafe.Pointer(p)).FpVal == uintptr(0) { Xsqlite3_result_error_nomem(tls, pCtx) } else { @@ -134367,157 +132222,21 @@ func Xsqlite3WindowFunctions(tls *libc.TLS) { /* sqlite3.c:151775:21: */ } var aWindowFuncs = [15]FuncDef{ - { - FnArg: int8(0), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(3), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(3), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, -} /* sqlite3.c:151776:18 */ + {FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(3), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(3), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}} /* sqlite3.c:151776:18 */ func windowFind(tls *libc.TLS, pParse uintptr, pList uintptr, zName uintptr) uintptr { /* sqlite3.c:151796:15: */ bp := tls.Alloc(8) @@ -134570,58 +132289,26 @@ func Xsqlite3WindowUpdate(tls *libc.TLS, pParse uintptr, pList uintptr, pWin uin } else { Xsqlite3WindowChain(tls, pParse, pWin, pList) } - if ((int32((*Window)(unsafe.Pointer(pWin)).FeFrmType) == 89) && + if ((int32((*Window)(unsafe.Pointer(pWin)).FeFrmType) == TK_RANGE) && (((*Window)(unsafe.Pointer(pWin)).FpStart != 0) || ((*Window)(unsafe.Pointer(pWin)).FpEnd != 0))) && (((*Window)(unsafe.Pointer(pWin)).FpOrderBy == uintptr(0)) || ((*ExprList)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOrderBy)).FnExpr != 1)) { Xsqlite3ErrorMsg(tls, pParse, ts+19606 /* "RANGE with offse..." */, 0) - } else if ((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & U32(0x00010000)) != 0 { + } else if ((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & SQLITE_FUNC_WINDOW) != 0 { var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb if (*Window)(unsafe.Pointer(pWin)).FpFilter != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+19677 /* "FILTER clause ma..." */, 0) } else { *(*[8]WindowUpdate)(unsafe.Pointer(bp /* aUp */)) = [8]WindowUpdate{ - { - FzFunc: uintptr(unsafe.Pointer(&row_numberName)), - FeFrmType: 76, - FeStart: 90, - FeEnd: 85}, - { - FzFunc: uintptr(unsafe.Pointer(&dense_rankName)), - FeFrmType: 89, - FeStart: 90, - FeEnd: 85}, - { - FzFunc: uintptr(unsafe.Pointer(&rankName)), - FeFrmType: 89, - FeStart: 90, - FeEnd: 85}, - { - FzFunc: uintptr(unsafe.Pointer(&percent_rankName)), - FeFrmType: 92, - FeStart: 85, - FeEnd: 90}, - { - FzFunc: uintptr(unsafe.Pointer(&cume_distName)), - FeFrmType: 92, - FeStart: 86, - FeEnd: 90}, - { - FzFunc: uintptr(unsafe.Pointer(&ntileName)), - FeFrmType: 76, - FeStart: 85, - FeEnd: 90}, - { - FzFunc: uintptr(unsafe.Pointer(&leadName)), - FeFrmType: 76, - FeStart: 90, - FeEnd: 90}, - { - FzFunc: uintptr(unsafe.Pointer(&lagName)), - FeFrmType: 76, - FeStart: 90, - FeEnd: 85}, + {FzFunc: uintptr(unsafe.Pointer(&row_numberName)), FeFrmType: TK_ROWS, FeStart: TK_UNBOUNDED, FeEnd: TK_CURRENT}, + {FzFunc: uintptr(unsafe.Pointer(&dense_rankName)), FeFrmType: TK_RANGE, FeStart: TK_UNBOUNDED, FeEnd: TK_CURRENT}, + {FzFunc: uintptr(unsafe.Pointer(&rankName)), FeFrmType: TK_RANGE, FeStart: TK_UNBOUNDED, FeEnd: TK_CURRENT}, + {FzFunc: uintptr(unsafe.Pointer(&percent_rankName)), FeFrmType: TK_GROUPS, FeStart: TK_CURRENT, FeEnd: TK_UNBOUNDED}, + {FzFunc: uintptr(unsafe.Pointer(&cume_distName)), FeFrmType: TK_GROUPS, FeStart: TK_FOLLOWING, FeEnd: TK_UNBOUNDED}, + {FzFunc: uintptr(unsafe.Pointer(&ntileName)), FeFrmType: TK_ROWS, FeStart: TK_CURRENT, FeEnd: TK_UNBOUNDED}, + {FzFunc: uintptr(unsafe.Pointer(&leadName)), FeFrmType: TK_ROWS, FeStart: TK_UNBOUNDED, FeEnd: TK_UNBOUNDED}, + {FzFunc: uintptr(unsafe.Pointer(&lagName)), FeFrmType: TK_ROWS, FeStart: TK_UNBOUNDED, FeEnd: TK_CURRENT}, } var i int32 for i = 0; i < (int32(uint64(unsafe.Sizeof([8]WindowUpdate{})) / uint64(unsafe.Sizeof(WindowUpdate{})))); i++ { @@ -134633,8 +132320,8 @@ func Xsqlite3WindowUpdate(tls *libc.TLS, pParse uintptr, pList uintptr, pWin uin (*Window)(unsafe.Pointer(pWin)).FeStart = U8((*WindowUpdate)(unsafe.Pointer(bp /* &aUp */ + uintptr(i)*24)).FeStart) (*Window)(unsafe.Pointer(pWin)).FeEnd = U8((*WindowUpdate)(unsafe.Pointer(bp /* &aUp */ + uintptr(i)*24)).FeEnd) (*Window)(unsafe.Pointer(pWin)).FeExclude = U8(0) - if int32((*Window)(unsafe.Pointer(pWin)).FeStart) == 86 { - (*Window)(unsafe.Pointer(pWin)).FpStart = Xsqlite3Expr(tls, db, 152, ts+6737 /* "1" */) + if int32((*Window)(unsafe.Pointer(pWin)).FeStart) == TK_FOLLOWING { + (*Window)(unsafe.Pointer(pWin)).FpStart = Xsqlite3Expr(tls, db, TK_INTEGER, ts+6737 /* "1" */) } break } @@ -134669,8 +132356,8 @@ func selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) in // not process aggregates or window functions at all, as they belong // to the scalar sub-select. if (*WindowRewrite1)(unsafe.Pointer(p)).FpSubSelect != 0 { - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 164 { - return 0 + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN { + return WRC_Continue } else { var nSrc int32 = (*SrcList)(unsafe.Pointer((*WindowRewrite1)(unsafe.Pointer(p)).FpSrc)).FnSrc var i int32 @@ -134680,31 +132367,30 @@ func selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) in } } if i == nSrc { - return 0 + return WRC_Continue } } } switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) { - case 169: - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + case TK_FUNCTION: + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) { break } else { var pWin uintptr for pWin = (*WindowRewrite1)(unsafe.Pointer(p)).FpWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { if *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) == pWin { - return 1 + return WRC_Prune } } } - /* no break */ fallthrough - case 165: + case TK_AGG_FUNCTION: fallthrough - case 164: + case TK_COLUMN: { var iCol int32 = -1 if (*WindowRewrite1)(unsafe.Pointer(p)).FpSub != 0 { @@ -134718,20 +132404,20 @@ func selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) in } if iCol < 0 { var pDup uintptr = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0) - if (pDup != 0) && (int32((*Expr)(unsafe.Pointer(pDup)).Fop) == 165) { - (*Expr)(unsafe.Pointer(pDup)).Fop = U8(169) + if (pDup != 0) && (int32((*Expr)(unsafe.Pointer(pDup)).Fop) == TK_AGG_FUNCTION) { + (*Expr)(unsafe.Pointer(pDup)).Fop = TK_FUNCTION } (*WindowRewrite1)(unsafe.Pointer(p)).FpSub = Xsqlite3ExprListAppend(tls, pParse, (*WindowRewrite1)(unsafe.Pointer(p)).FpSub, pDup) } if (*WindowRewrite1)(unsafe.Pointer(p)).FpSub != 0 { - var f int32 = (int32((*Expr)(unsafe.Pointer(pExpr)).Fflags & U32(0x000100))) + var f int32 = (int32((*Expr)(unsafe.Pointer(pExpr)).Fflags & EP_Collate)) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x8000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Static) Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(0x8000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(EP_Static))) libc.Xmemset(tls, pExpr, 0, uint64(unsafe.Sizeof(Expr{}))) - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(164) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_COLUMN (*Expr)(unsafe.Pointer(pExpr)).FiColumn = func() int16 { if iCol < 0 { return (int16((*ExprList)(unsafe.Pointer((*WindowRewrite1)(unsafe.Pointer(p)).FpSub)).FnExpr - 1)) @@ -134743,7 +132429,7 @@ func selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) in (*Expr)(unsafe.Pointer(pExpr)).Fflags = U32(f) } if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { - return 2 + return WRC_Abort } break @@ -134753,20 +132439,20 @@ func selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) in break } - return 0 + return WRC_Continue } func selectWindowRewriteSelectCb(tls *libc.TLS, pWalker uintptr, pSelect uintptr) int32 { /* sqlite3.c:151994:12: */ var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) var pSave uintptr = (*WindowRewrite1)(unsafe.Pointer(p)).FpSubSelect if pSave == pSelect { - return 0 + return WRC_Continue } else { (*WindowRewrite1)(unsafe.Pointer(p)).FpSubSelect = pSelect Xsqlite3WalkSelect(tls, pWalker, pSelect) (*WindowRewrite1)(unsafe.Pointer(p)).FpSubSelect = pSave } - return 1 + return WRC_Prune } // Iterate through each expression in expression-list pEList. For each: @@ -134831,12 +132517,12 @@ func exprListAppendList(tls *libc.TLS, pParse uintptr, pList uintptr, pAppend ui // var iDummy int32 at bp, 4 var pSub uintptr - for pSub = pDup; ((*Expr)(unsafe.Pointer((pSub))).Fflags & (U32(0x001000))) != U32(0); pSub = (*Expr)(unsafe.Pointer(pSub)).FpLeft { + for pSub = pDup; ((*Expr)(unsafe.Pointer((pSub))).Fflags & (EP_Skip)) != U32(0); pSub = (*Expr)(unsafe.Pointer(pSub)).FpLeft { } if Xsqlite3ExprIsInteger(tls, pSub, bp /* &iDummy */) != 0 { - (*Expr)(unsafe.Pointer(pSub)).Fop = U8(119) - *(*U32)(unsafe.Pointer(pSub + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(((0x000400 | 0x10000000) | 0x20000000))) + (*Expr)(unsafe.Pointer(pSub)).Fop = TK_NULL + *(*U32)(unsafe.Pointer(pSub + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(((EP_IntValue | EP_IsTrue) | EP_IsFalse)))) *(*uintptr)(unsafe.Pointer(pSub + 8 /* &.u */)) = uintptr(0) } } @@ -134856,11 +132542,11 @@ func exprListAppendList(tls *libc.TLS, pParse uintptr, pList uintptr, pAppend ui // // See also the incrAggDepth() routine in resolve.c func sqlite3WindowExtraAggFuncDepth(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:152094:12: */ - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 165) && + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_FUNCTION) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) >= (*Walker)(unsafe.Pointer(pWalker)).FwalkerDepth) { (*Expr)(unsafe.Pointer(pExpr)).Fop2++ } - return 0 + return WRC_Continue } // If the SELECT statement passed as the second argument does not invoke @@ -134872,8 +132558,8 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* bp := tls.Alloc(56) defer tls.Free(56) - var rc int32 = 0 - if (((*Select)(unsafe.Pointer(p)).FpWin != 0) && ((*Select)(unsafe.Pointer(p)).FpPrior == uintptr(0))) && (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0100000)) == U32(0)) { + var rc int32 = SQLITE_OK + if (((*Select)(unsafe.Pointer(p)).FpWin != 0) && ((*Select)(unsafe.Pointer(p)).FpPrior == uintptr(0))) && (((*Select)(unsafe.Pointer(p)).FselFlags & SF_WinRewrite) == U32(0)) { var v uintptr = Xsqlite3GetVdbe(tls, pParse) var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var pSub uintptr = uintptr(0) // The subquery @@ -134893,7 +132579,7 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* pTab = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Table{}))) if pTab == uintptr(0) { - return Xsqlite3ErrorToParser(tls, db, 7) + return Xsqlite3ErrorToParser(tls, db, SQLITE_NOMEM) } Xsqlite3AggInfoPersistWalkerInit(tls, bp /* &w */, pParse) Xsqlite3WalkSelect(tls, bp /* &w */, p) @@ -134902,8 +132588,8 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* (*Select)(unsafe.Pointer(p)).FpWhere = uintptr(0) (*Select)(unsafe.Pointer(p)).FpGroupBy = uintptr(0) (*Select)(unsafe.Pointer(p)).FpHaving = uintptr(0) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000008)) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0100000)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_Aggregate))) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_WinRewrite) // Create the ORDER BY clause for the sub-select. This is the concatenation // of the window PARTITION and ORDER BY clauses. Then, if this makes it @@ -134947,7 +132633,7 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* // results. for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { var pArgs uintptr = *(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 32 /* &.x */)) - if ((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpFunc)).FfuncFlags & U32(0x00100000)) != 0 { + if ((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpFunc)).FfuncFlags & SQLITE_FUNC_SUBTYPE) != 0 { selectWindowRewriteEList(tls, pParse, pMWin, pSrc, pArgs, pTab, bp+48 /* &pSublist */) (*Window)(unsafe.Pointer(pWin)).FiArgCol = func() int32 { if *(*uintptr)(unsafe.Pointer(bp + 48 /* pSublist */)) != 0 { @@ -134971,7 +132657,7 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* } (*Window)(unsafe.Pointer(pWin)).FregAccum = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) (*Window)(unsafe.Pointer(pWin)).FregResult = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) } // If there is no ORDER BY or PARTITION BY clause, and the window @@ -134981,7 +132667,7 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* // keep everything legal in this case. if *(*uintptr)(unsafe.Pointer(bp + 48 /* pSublist */)) == uintptr(0) { *(*uintptr)(unsafe.Pointer(bp + 48 /* pSublist */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), - Xsqlite3Expr(tls, db, 152, ts+6319 /* "0" */)) + Xsqlite3Expr(tls, db, TK_INTEGER, ts+6319 /* "0" */)) } pSub = Xsqlite3SelectNew(tls, @@ -134990,20 +132676,20 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* (*Select)(unsafe.Pointer(p)).FpSrc = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) if (*Select)(unsafe.Pointer(p)).FpSrc != 0 { var pTab2 uintptr - (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpSelect = pSub + (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpSelect = pSub Xsqlite3SrcListAssignCursors(tls, pParse, (*Select)(unsafe.Pointer(p)).FpSrc) - *(*U32)(unsafe.Pointer(pSub + 4 /* &.selFlags */)) |= (U32(0x0000040)) - pTab2 = Xsqlite3ResultSetOfSelect(tls, pParse, pSub, int8(0x40)) - *(*U32)(unsafe.Pointer(pSub + 4 /* &.selFlags */)) |= (selFlags & U32(0x0000008)) + *(*U32)(unsafe.Pointer(pSub + 4 /* &.selFlags */)) |= (SF_Expanded) + pTab2 = Xsqlite3ResultSetOfSelect(tls, pParse, pSub, SQLITE_AFF_NONE) + *(*U32)(unsafe.Pointer(pSub + 4 /* &.selFlags */)) |= (selFlags & SF_Aggregate) if pTab2 == uintptr(0) { // Might actually be some other kind of error, but in that case // pParse->nErr will be set, so if SQLITE_NOMEM is set, we will get // the correct error message regardless. - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemcpy(tls, pTab, pTab2, uint64(unsafe.Sizeof(Table{}))) - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0002)) - (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab = pTab + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (TF_Ephemeral) + (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpTab = pTab pTab = pTab2 libc.Xmemset(tls, bp /* &w */, 0, uint64(unsafe.Sizeof(Walker{}))) (*Walker)(unsafe.Pointer(bp /* &w */)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct { @@ -135021,7 +132707,7 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* Xsqlite3SelectDelete(tls, db, pSub) } if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3DbFree(tls, db, pTab) } @@ -135029,7 +132715,7 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* if rc != 0 { if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 { - Xsqlite3ErrorToParser(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 7) + Xsqlite3ErrorToParser(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, SQLITE_NOMEM) } } return rc @@ -135078,11 +132764,11 @@ func Xsqlite3WindowListDelete(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3 // variable values in the expression tree. func sqlite3WindowOffsetExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr { /* sqlite3.c:152303:13: */ if 0 == Xsqlite3ExprIsConstant(tls, pExpr) { - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameExprUnmap(tls, pParse, pExpr) } Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr) - pExpr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 119, uintptr(0), 0) + pExpr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_NULL, uintptr(0), 0) } return pExpr } @@ -135100,7 +132786,7 @@ func Xsqlite3WindowAlloc(tls *libc.TLS, pParse uintptr, eType int32, eStart int3 goto __1 } bImplicitFrame = 1 - eType = 89 + eType = TK_RANGE __1: ; @@ -135117,8 +132803,8 @@ __1: // The parser ensures that "UNBOUNDED PRECEDING" cannot be used as an ending // boundary, and than "UNBOUNDED FOLLOWING" cannot be used as a starting // frame boundary. - if !(((eStart == 85) && (eEnd == 88)) || - ((eStart == 86) && ((eEnd == 88) || (eEnd == 85)))) { + if !(((eStart == TK_CURRENT) && (eEnd == TK_PRECEDING)) || + ((eStart == TK_FOLLOWING) && ((eEnd == TK_PRECEDING) || (eEnd == TK_CURRENT)))) { goto __2 } Xsqlite3ErrorMsg(tls, pParse, ts+19740 /* "unsupported fram..." */, 0) @@ -135136,10 +132822,10 @@ __3: (*Window)(unsafe.Pointer(pWin)).FeFrmType = U8(eType) (*Window)(unsafe.Pointer(pWin)).FeStart = U8(eStart) (*Window)(unsafe.Pointer(pWin)).FeEnd = U8(eEnd) - if !((int32(eExclude) == 0) && ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (0x0002)) != 0)) { + if !((int32(eExclude) == 0) && ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (SQLITE_WindowFunc)) != 0)) { goto __4 } - eExclude = U8(66) + eExclude = TK_NO __4: ; (*Window)(unsafe.Pointer(pWin)).FeExclude = eExclude @@ -135214,9 +132900,9 @@ func Xsqlite3WindowAttach(tls *libc.TLS, pParse uintptr, p uintptr, pWin uintptr if p != 0 { *(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) = pWin - *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= (U32(0x1000000)) + *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= (EP_WinFunc) (*Window)(unsafe.Pointer(pWin)).FpOwner = p - if (((*Expr)(unsafe.Pointer(p)).Fflags & U32(0x000002)) != 0) && (int32((*Window)(unsafe.Pointer(pWin)).FeFrmType) != 163) { + if (((*Expr)(unsafe.Pointer(p)).Fflags & EP_Distinct) != 0) && (int32((*Window)(unsafe.Pointer(pWin)).FeFrmType) != TK_FILTER) { Xsqlite3ErrorMsg(tls, pParse, ts+19858 /* "DISTINCT is not ..." */, 0) } @@ -135285,15 +132971,15 @@ func Xsqlite3WindowCompare(tls *libc.TLS, pParse uintptr, p1 uintptr, p2 uintptr // to begin iterating through the sub-query results. It is used to allocate // and initialize registers and cursors used by sqlite3WindowCodeStep(). func Xsqlite3WindowCodeInit(tls *libc.TLS, pParse uintptr, pSelect uintptr) { /* sqlite3.c:152518:21: */ - var nEphExpr int32 = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pSelect)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpSelect)).FpEList)).FnExpr + var nEphExpr int32 = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pSelect)).FpSrc + 8 /* &.a */))).FpSelect)).FpEList)).FnExpr var pMWin uintptr = (*Select)(unsafe.Pointer(pSelect)).FpWin var pWin uintptr var v uintptr = Xsqlite3GetVdbe(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 100, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, nEphExpr) - Xsqlite3VdbeAddOp2(tls, v, 98, ((*Window)(unsafe.Pointer(pMWin)).FiEphCsr + 1), (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) - Xsqlite3VdbeAddOp2(tls, v, 98, ((*Window)(unsafe.Pointer(pMWin)).FiEphCsr + 2), (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) - Xsqlite3VdbeAddOp2(tls, v, 98, ((*Window)(unsafe.Pointer(pMWin)).FiEphCsr + 3), (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, nEphExpr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, ((*Window)(unsafe.Pointer(pMWin)).FiEphCsr + 1), (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, ((*Window)(unsafe.Pointer(pMWin)).FiEphCsr + 2), (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, ((*Window)(unsafe.Pointer(pMWin)).FiEphCsr + 3), (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) // Allocate registers to use for PARTITION BY values, if any. Initialize // said registers to NULL. @@ -135301,25 +132987,25 @@ func Xsqlite3WindowCodeInit(tls *libc.TLS, pParse uintptr, pSelect uintptr) { /* var nExpr int32 = (*ExprList)(unsafe.Pointer((*Window)(unsafe.Pointer(pMWin)).FpPartition)).FnExpr (*Window)(unsafe.Pointer(pMWin)).FregPart = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (nExpr) - Xsqlite3VdbeAddOp3(tls, v, 72, 0, (*Window)(unsafe.Pointer(pMWin)).FregPart, (((*Window)(unsafe.Pointer(pMWin)).FregPart + nExpr) - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pMWin)).FregPart, (((*Window)(unsafe.Pointer(pMWin)).FregPart + nExpr) - 1)) } (*Window)(unsafe.Pointer(pMWin)).FregOne = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, (*Window)(unsafe.Pointer(pMWin)).FregOne) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, (*Window)(unsafe.Pointer(pMWin)).FregOne) if (*Window)(unsafe.Pointer(pMWin)).FeExclude != 0 { (*Window)(unsafe.Pointer(pMWin)).FregStartRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) (*Window)(unsafe.Pointer(pMWin)).FregEndRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) (*Window)(unsafe.Pointer(pMWin)).FcsrApp = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid) - Xsqlite3VdbeAddOp2(tls, v, 98, (*Window)(unsafe.Pointer(pMWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*Window)(unsafe.Pointer(pMWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) return } for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { var p uintptr = (*Window)(unsafe.Pointer(pWin)).FpFunc - if (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & U32(0x1000)) != 0) && (int32((*Window)(unsafe.Pointer(pWin)).FeStart) != 90) { + if (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & SQLITE_FUNC_MINMAX) != 0) && (int32((*Window)(unsafe.Pointer(pWin)).FeStart) != TK_UNBOUNDED) { // The inline versions of min() and max() require a single ephemeral // table and 3 registers. The registers are used as follows: // @@ -135331,23 +133017,23 @@ func Xsqlite3WindowCodeInit(tls *libc.TLS, pParse uintptr, pSelect uintptr) { /* (*Window)(unsafe.Pointer(pWin)).FcsrApp = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) (*Window)(unsafe.Pointer(pWin)).FregApp = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (3) - if (pKeyInfo != 0) && (int32(*(*int8)(unsafe.Pointer((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpFunc)).FzName + uintptr(1)))) == 'i') { + if (pKeyInfo != 0) && (int32(*(*int8)(unsafe.Pointer((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpFunc)).FzName + 1))) == 'i') { - *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(0))) = U8(0x01) + *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags)) = KEYINFO_ORDER_DESC } - Xsqlite3VdbeAddOp2(tls, v, 100, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 2) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 2) Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -9) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1)) } else if ((*FuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&nth_valueName))) || ((*FuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&first_valueName))) { // Allocate two registers at pWin->regApp. These will be used to // store the start and end index of the current frame. (*Window)(unsafe.Pointer(pWin)).FregApp = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) (*Window)(unsafe.Pointer(pWin)).FcsrApp = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (2) - Xsqlite3VdbeAddOp2(tls, v, 98, (*Window)(unsafe.Pointer(pWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*Window)(unsafe.Pointer(pWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) } else if ((*FuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&leadName))) || ((*FuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&lagName))) { (*Window)(unsafe.Pointer(pWin)).FcsrApp = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - Xsqlite3VdbeAddOp2(tls, v, 98, (*Window)(unsafe.Pointer(pWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*Window)(unsafe.Pointer(pWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) } } } @@ -135361,15 +133047,15 @@ func windowCheckValue(tls *libc.TLS, pParse uintptr, reg int32, eCond int32) { / var v uintptr = Xsqlite3GetVdbe(tls, pParse) var regZero int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regZero) - if eCond >= 3 { + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regZero) + if eCond >= WINDOW_STARTING_NUM { var regString int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp4(tls, v, 115, 0, regString, 0, ts+703 /* "" */, -1) - Xsqlite3VdbeAddOp3(tls, v, 57, regString, (Xsqlite3VdbeCurrentAddr(tls, v) + 2), reg) - Xsqlite3VdbeChangeP5(tls, v, (uint16(0x43 | 0x10))) + Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, regString, 0, ts+703 /* "" */, -1) + Xsqlite3VdbeAddOp3(tls, v, OP_Ge, regString, (Xsqlite3VdbeCurrentAddr(tls, v) + 2), reg) + Xsqlite3VdbeChangeP5(tls, v, (uint16(SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL))) } else { - Xsqlite3VdbeAddOp2(tls, v, 15, reg, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_MustBeInt, reg, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) } Xsqlite3VdbeAddOp3(tls, v, aOp1[eCond], regZero, (Xsqlite3VdbeCurrentAddr(tls, v) + 2), reg) @@ -135379,7 +133065,7 @@ func windowCheckValue(tls *libc.TLS, pParse uintptr, reg int32, eCond int32) { / // NULL case caught by // the OP_Ge Xsqlite3MayAbort(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 68, 1, 2) + Xsqlite3VdbeAddOp2(tls, v, OP_Halt, SQLITE_ERROR, OE_Abort) Xsqlite3VdbeAppendP4(tls, v, azErr[eCond], -1) Xsqlite3ReleaseTempReg(tls, pParse, regZero) } @@ -135390,8 +133076,8 @@ var azErr = [5]uintptr{ ts + 19388, /* "second argument ..." */ ts + 20009, /* "frame starting o..." */ ts + 20061, /* "frame ending off..." */ -} /* sqlite3.c:152603:21 */ -var aOp1 = [5]int32{57, 57, 54, 57, 57} /* sqlite3.c:152610:14 */ +} /* sqlite3.c:152603:21 */ +var aOp1 = [5]int32{OP_Ge, OP_Ge, OP_Gt, OP_Ge, OP_Ge} /* sqlite3.c:152610:14 */ // Return the number of arguments passed to the window-function associated // with the object passed as the only argument to this function. @@ -135442,7 +133128,7 @@ func windowReadPeerValues(tls *libc.TLS, p uintptr, csr int32, reg int32) { /* s }())) var i int32 for i = 0; i < (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr; i++ { - Xsqlite3VdbeAddOp3(tls, v, 89, csr, (iColOff + i), (reg + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, (iColOff + i), (reg + i)) } } } @@ -135484,33 +133170,33 @@ func windowAggStep(tls *libc.TLS, p uintptr, pMWin uintptr, csr int32, bInverse for i = 0; i < nArg; i++ { if (i != 1) || ((*FuncDef)(unsafe.Pointer(pFunc)).FzName != uintptr(unsafe.Pointer(&nth_valueName))) { - Xsqlite3VdbeAddOp3(tls, v, 89, csr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + i), (reg + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + i), (reg + i)) } else { - Xsqlite3VdbeAddOp3(tls, v, 89, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + i), (reg + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + i), (reg + i)) } } regArg = reg if (((*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0) && - (((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & U32(0x1000)) != 0)) && - (int32((*Window)(unsafe.Pointer(pWin)).FeStart) != 90) { - var addrIsNull int32 = Xsqlite3VdbeAddOp1(tls, v, 50, regArg) + (((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & SQLITE_FUNC_MINMAX) != 0)) && + (int32((*Window)(unsafe.Pointer(pWin)).FeStart) != TK_UNBOUNDED) { + var addrIsNull int32 = Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, regArg) if bInverse == 0 { - Xsqlite3VdbeAddOp2(tls, v, 82, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1), 1) - Xsqlite3VdbeAddOp2(tls, v, 78, regArg, (*Window)(unsafe.Pointer(pWin)).FregApp) - Xsqlite3VdbeAddOp3(tls, v, 91, (*Window)(unsafe.Pointer(pWin)).FregApp, 2, ((*Window)(unsafe.Pointer(pWin)).FregApp + 2)) - Xsqlite3VdbeAddOp2(tls, v, 130, (*Window)(unsafe.Pointer(pWin)).FcsrApp, ((*Window)(unsafe.Pointer(pWin)).FregApp + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1), 1) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, regArg, (*Window)(unsafe.Pointer(pWin)).FregApp) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (*Window)(unsafe.Pointer(pWin)).FregApp, 2, ((*Window)(unsafe.Pointer(pWin)).FregApp + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, (*Window)(unsafe.Pointer(pWin)).FcsrApp, ((*Window)(unsafe.Pointer(pWin)).FregApp + 2)) } else { - Xsqlite3VdbeAddOp4Int(tls, v, 24, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 0, regArg, 1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_SeekGE, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 0, regArg, 1) - Xsqlite3VdbeAddOp1(tls, v, 122, (*Window)(unsafe.Pointer(pWin)).FcsrApp) + Xsqlite3VdbeAddOp1(tls, v, OP_Delete, (*Window)(unsafe.Pointer(pWin)).FcsrApp) Xsqlite3VdbeJumpHere(tls, v, (Xsqlite3VdbeCurrentAddr(tls, v) - 2)) } Xsqlite3VdbeJumpHere(tls, v, addrIsNull) } else if (*Window)(unsafe.Pointer(pWin)).FregApp != 0 { - Xsqlite3VdbeAddOp2(tls, v, 82, (((*Window)(unsafe.Pointer(pWin)).FregApp + 1) - bInverse), 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (((*Window)(unsafe.Pointer(pWin)).FregApp + 1) - bInverse), 1) } else if (*FuncDef)(unsafe.Pointer(pFunc)).FxSFunc != *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{noopStepFunc})) { @@ -135519,8 +133205,8 @@ func windowAggStep(tls *libc.TLS, p uintptr, pMWin uintptr, csr int32, bInverse var regTmp int32 regTmp = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 89, csr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + nArg), regTmp) - addrIf = Xsqlite3VdbeAddOp3(tls, v, 20, regTmp, 0, 1) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + nArg), regTmp) + addrIf = Xsqlite3VdbeAddOp3(tls, v, OP_IfNot, regTmp, 0, 1) Xsqlite3ReleaseTempReg(tls, pParse, regTmp) } @@ -135536,22 +133222,22 @@ func windowAggStep(tls *libc.TLS, p uintptr, pMWin uintptr, csr int32, bInverse pEnd = Xsqlite3VdbeGetOp(tls, v, -1) for pOp = Xsqlite3VdbeGetOp(tls, v, iStart); pOp <= pEnd; pOp += 24 { - if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 89) && ((*VdbeOp)(unsafe.Pointer(pOp)).Fp1 == (*Window)(unsafe.Pointer(pWin)).FiEphCsr) { + if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column) && ((*VdbeOp)(unsafe.Pointer(pOp)).Fp1 == (*Window)(unsafe.Pointer(pWin)).FiEphCsr) { (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = csr } } } - if ((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & U32(0x0020)) != 0 { + if ((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != 0 { var pColl uintptr - pColl = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 32 /* &.x */))+8 /* &.a */)+uintptr(0)*32)).FpExpr) - Xsqlite3VdbeAddOp4(tls, v, 81, 0, 0, 0, pColl, -2) + pColl = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 32 /* &.x */)) + 8 /* &.a */))).FpExpr) + Xsqlite3VdbeAddOp4(tls, v, OP_CollSeq, 0, 0, 0, pColl, -2) } Xsqlite3VdbeAddOp3(tls, v, func() int32 { if bInverse != 0 { - return 153 + return OP_AggInverse } - return 154 + return OP_AggStep }(), bInverse, regArg, (*Window)(unsafe.Pointer(pWin)).FregAccum) Xsqlite3VdbeAppendP4(tls, v, pFunc, -8) @@ -135580,24 +133266,24 @@ func windowAggFinal(tls *libc.TLS, p uintptr, bFin int32) { /* sqlite3.c:152888: for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { if (((*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0) && - (((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpFunc)).FfuncFlags & U32(0x1000)) != 0)) && - (int32((*Window)(unsafe.Pointer(pWin)).FeStart) != 90) { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) - Xsqlite3VdbeAddOp1(tls, v, 33, (*Window)(unsafe.Pointer(pWin)).FcsrApp) + (((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpFunc)).FfuncFlags & SQLITE_FUNC_MINMAX) != 0)) && + (int32((*Window)(unsafe.Pointer(pWin)).FeStart) != TK_UNBOUNDED) { + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp1(tls, v, OP_Last, (*Window)(unsafe.Pointer(pWin)).FcsrApp) - Xsqlite3VdbeAddOp3(tls, v, 89, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) Xsqlite3VdbeJumpHere(tls, v, (Xsqlite3VdbeCurrentAddr(tls, v) - 2)) } else if (*Window)(unsafe.Pointer(pWin)).FregApp != 0 { } else { var nArg int32 = windowArgCount(tls, pWin) if bFin != 0 { - Xsqlite3VdbeAddOp2(tls, v, 157, (*Window)(unsafe.Pointer(pWin)).FregAccum, nArg) + Xsqlite3VdbeAddOp2(tls, v, OP_AggFinal, (*Window)(unsafe.Pointer(pWin)).FregAccum, nArg) Xsqlite3VdbeAppendP4(tls, v, (*Window)(unsafe.Pointer(pWin)).FpFunc, -8) - Xsqlite3VdbeAddOp2(tls, v, 77, (*Window)(unsafe.Pointer(pWin)).FregAccum, (*Window)(unsafe.Pointer(pWin)).FregResult) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, (*Window)(unsafe.Pointer(pWin)).FregAccum, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) } else { - Xsqlite3VdbeAddOp3(tls, v, 156, (*Window)(unsafe.Pointer(pWin)).FregAccum, nArg, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp3(tls, v, OP_AggValue, (*Window)(unsafe.Pointer(pWin)).FregAccum, nArg, (*Window)(unsafe.Pointer(pWin)).FregResult) Xsqlite3VdbeAppendP4(tls, v, (*Window)(unsafe.Pointer(pWin)).FpFunc, -8) } } @@ -135643,23 +133329,23 @@ func windowFullScan(tls *libc.TLS, p uintptr) { /* sqlite3.c:152927:13: */ regPeer = Xsqlite3GetTempRange(tls, pParse, nPeer) } - Xsqlite3VdbeAddOp2(tls, v, 127, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, regCRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, regCRowid) windowReadPeerValues(tls, p, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, regCPeer) for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) } - Xsqlite3VdbeAddOp3(tls, v, 24, csr, lblBrk, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekGE, csr, lblBrk, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid) addrNext = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp2(tls, v, 127, csr, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 54, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid, lblBrk, regRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, csr, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Gt, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid, lblBrk, regRowid) - if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) == 85 { - Xsqlite3VdbeAddOp3(tls, v, 53, regCRowid, lblNext, regRowid) + if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) == TK_CURRENT { + Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regCRowid, lblNext, regRowid) - } else if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) != 66 { + } else if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) != TK_NO { var addr int32 var addrEq int32 = 0 var pKeyInfo uintptr = uintptr(0) @@ -135667,19 +133353,19 @@ func windowFullScan(tls *libc.TLS, p uintptr) { /* sqlite3.c:152927:13: */ if (*Window)(unsafe.Pointer(pMWin)).FpOrderBy != 0 { pKeyInfo = Xsqlite3KeyInfoFromExprList(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpOrderBy, 0, 0) } - if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) == 94 { - addrEq = Xsqlite3VdbeAddOp3(tls, v, 53, regCRowid, 0, regRowid) + if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) == TK_TIES { + addrEq = Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regCRowid, 0, regRowid) } if pKeyInfo != 0 { windowReadPeerValues(tls, p, csr, regPeer) - Xsqlite3VdbeAddOp3(tls, v, 86, regPeer, regCPeer, nPeer) + Xsqlite3VdbeAddOp3(tls, v, OP_Compare, regPeer, regCPeer, nPeer) Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -9) addr = (Xsqlite3VdbeCurrentAddr(tls, v) + 1) - Xsqlite3VdbeAddOp3(tls, v, 16, addr, lblNext, addr) + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, addr, lblNext, addr) } else { - Xsqlite3VdbeAddOp2(tls, v, 11, 0, lblNext) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lblNext) } if addrEq != 0 { Xsqlite3VdbeJumpHere(tls, v, addrEq) @@ -135689,7 +133375,7 @@ func windowFullScan(tls *libc.TLS, p uintptr) { /* sqlite3.c:152927:13: */ windowAggStep(tls, p, pMWin, csr, 0, (*WindowCodeArg)(unsafe.Pointer(p)).FregArg) Xsqlite3VdbeResolveLabel(tls, v, lblNext) - Xsqlite3VdbeAddOp2(tls, v, 5, csr, addrNext) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, csr, addrNext) Xsqlite3VdbeJumpHere(tls, v, (addrNext - 1)) Xsqlite3VdbeJumpHere(tls, v, (addrNext + 1)) @@ -135732,20 +133418,20 @@ func windowReturnOneRow(tls *libc.TLS, p uintptr) { /* sqlite3.c:153033:13: */ var csr int32 = (*Window)(unsafe.Pointer(pWin)).FcsrApp var lbl int32 = Xsqlite3VdbeMakeLabel(tls, pParse) var tmpReg int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&nth_valueName)) { - Xsqlite3VdbeAddOp3(tls, v, 89, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + 1), tmpReg) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + 1), tmpReg) windowCheckValue(tls, pParse, tmpReg, 2) } else { - Xsqlite3VdbeAddOp2(tls, v, 69, 1, tmpReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, tmpReg) } - Xsqlite3VdbeAddOp3(tls, v, 105, tmpReg, (*Window)(unsafe.Pointer(pWin)).FregApp, tmpReg) - Xsqlite3VdbeAddOp3(tls, v, 54, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1), lbl, tmpReg) + Xsqlite3VdbeAddOp3(tls, v, OP_Add, tmpReg, (*Window)(unsafe.Pointer(pWin)).FregApp, tmpReg) + Xsqlite3VdbeAddOp3(tls, v, OP_Gt, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1), lbl, tmpReg) - Xsqlite3VdbeAddOp3(tls, v, 31, csr, 0, tmpReg) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, csr, 0, tmpReg) - Xsqlite3VdbeAddOp3(tls, v, 89, csr, (*Window)(unsafe.Pointer(pWin)).FiArgCol, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, (*Window)(unsafe.Pointer(pWin)).FiArgCol, (*Window)(unsafe.Pointer(pWin)).FregResult) Xsqlite3VdbeResolveLabel(tls, v, lbl) Xsqlite3ReleaseTempReg(tls, pParse, tmpReg) } else if ((*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&leadName))) || ((*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&lagName))) { @@ -135756,11 +133442,11 @@ func windowReturnOneRow(tls *libc.TLS, p uintptr) { /* sqlite3.c:153033:13: */ var iEph int32 = (*Window)(unsafe.Pointer(pMWin)).FiEphCsr if nArg < 3 { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) } else { - Xsqlite3VdbeAddOp3(tls, v, 89, iEph, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + 2), (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + 2), (*Window)(unsafe.Pointer(pWin)).FregResult) } - Xsqlite3VdbeAddOp2(tls, v, 127, iEph, tmpReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iEph, tmpReg) if nArg < 2 { var val int32 = func() int32 { if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&leadName)) { @@ -135768,29 +133454,29 @@ func windowReturnOneRow(tls *libc.TLS, p uintptr) { /* sqlite3.c:153033:13: */ } return -1 }() - Xsqlite3VdbeAddOp2(tls, v, 82, tmpReg, val) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, tmpReg, val) } else { var op int32 = func() int32 { if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&leadName)) { - return 105 + return OP_Add } - return 106 + return OP_Subtract }() var tmpReg2 int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 89, iEph, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + 1), tmpReg2) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + 1), tmpReg2) Xsqlite3VdbeAddOp3(tls, v, op, tmpReg2, tmpReg, tmpReg) Xsqlite3ReleaseTempReg(tls, pParse, tmpReg2) } - Xsqlite3VdbeAddOp3(tls, v, 31, csr, lbl, tmpReg) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, csr, lbl, tmpReg) - Xsqlite3VdbeAddOp3(tls, v, 89, csr, (*Window)(unsafe.Pointer(pWin)).FiArgCol, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, (*Window)(unsafe.Pointer(pWin)).FiArgCol, (*Window)(unsafe.Pointer(pWin)).FregResult) Xsqlite3VdbeResolveLabel(tls, v, lbl) Xsqlite3ReleaseTempReg(tls, pParse, tmpReg) } } } - Xsqlite3VdbeAddOp2(tls, v, 12, (*WindowCodeArg)(unsafe.Pointer(p)).FregGosub, (*WindowCodeArg)(unsafe.Pointer(p)).FaddrGosub) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*WindowCodeArg)(unsafe.Pointer(p)).FregGosub, (*WindowCodeArg)(unsafe.Pointer(p)).FaddrGosub) } // Generate code to set the accumulator register for each window function @@ -135805,7 +133491,7 @@ func windowInitAccum(tls *libc.TLS, pParse uintptr, pMWin uintptr) int32 { /* sq for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { var pFunc uintptr = (*Window)(unsafe.Pointer(pWin)).FpFunc - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) nArg = func() int32 { if (nArg) > (windowArgCount(tls, pWin)) { return nArg @@ -135814,14 +133500,14 @@ func windowInitAccum(tls *libc.TLS, pParse uintptr, pMWin uintptr) int32 { /* sq }() if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0 { if ((*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&nth_valueName))) || ((*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&first_valueName))) { - Xsqlite3VdbeAddOp2(tls, v, 69, 0, (*Window)(unsafe.Pointer(pWin)).FregApp) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Window)(unsafe.Pointer(pWin)).FregApp) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1)) } - if (((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & U32(0x1000)) != 0) && ((*Window)(unsafe.Pointer(pWin)).FcsrApp != 0) { + if (((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & SQLITE_FUNC_MINMAX) != 0) && ((*Window)(unsafe.Pointer(pWin)).FcsrApp != 0) { - Xsqlite3VdbeAddOp1(tls, v, 138, (*Window)(unsafe.Pointer(pWin)).FcsrApp) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1)) + Xsqlite3VdbeAddOp1(tls, v, OP_ResetSorter, (*Window)(unsafe.Pointer(pWin)).FcsrApp) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1)) } } } @@ -135862,14 +133548,14 @@ func windowIfNewPeer(tls *libc.TLS, pParse uintptr, pOrderBy uintptr, regNew int if pOrderBy != 0 { var nVal int32 = (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr var pKeyInfo uintptr = Xsqlite3KeyInfoFromExprList(tls, pParse, pOrderBy, 0, 0) - Xsqlite3VdbeAddOp3(tls, v, 86, regOld, regNew, nVal) + Xsqlite3VdbeAddOp3(tls, v, OP_Compare, regOld, regNew, nVal) Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -9) - Xsqlite3VdbeAddOp3(tls, v, 16, + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, (Xsqlite3VdbeCurrentAddr(tls, v) + 1), addr, (Xsqlite3VdbeCurrentAddr(tls, v) + 1)) - Xsqlite3VdbeAddOp3(tls, v, 77, regNew, regOld, (nVal - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regNew, regOld, (nVal - 1)) } else { - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addr) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addr) } } @@ -135901,24 +133587,24 @@ func windowCodeRangeTest(tls *libc.TLS, p uintptr, op int32, csr1 int32, regVal var reg1 int32 = Xsqlite3GetTempReg(tls, pParse) // Reg. for csr1.peerVal+regVal var reg2 int32 = Xsqlite3GetTempReg(tls, pParse) // Reg. for csr2.peerVal var regString int32 = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) // Reg. for constant value '' - var arith int32 = 105 // OP_Add or OP_Subtract + var arith int32 = OP_Add // OP_Add or OP_Subtract var addrGe int32 // Jump destination - if (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(0)*32)).FsortFlags) & 0x01) != 0 { + if (int32((*ExprList_item)(unsafe.Pointer((pOrderBy + 8 /* &.a */))).FsortFlags) & KEYINFO_ORDER_DESC) != 0 { switch op { - case 57: - op = 55 + case OP_Ge: + op = OP_Le break fallthrough - case 54: - op = 56 + case OP_Gt: + op = OP_Lt break fallthrough default: - op = 57 + op = OP_Ge break } - arith = 106 + arith = OP_Subtract } // Read the peer-value from each cursor into a register @@ -135938,8 +133624,8 @@ func windowCodeRangeTest(tls *libc.TLS, p uintptr, op int32, csr1 int32, regVal // the add/subtract is skipped for these, as required. If reg1 is a NULL, // then the arithmetic is performed, but since adding or subtracting from // NULL is always NULL anyway, this case is handled as required too. - Xsqlite3VdbeAddOp4(tls, v, 115, 0, regString, 0, ts+703 /* "" */, -1) - addrGe = Xsqlite3VdbeAddOp3(tls, v, 57, regString, 0, reg1) + Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, regString, 0, ts+703 /* "" */, -1) + addrGe = Xsqlite3VdbeAddOp3(tls, v, OP_Ge, regString, 0, reg1) Xsqlite3VdbeAddOp3(tls, v, arith, regVal, reg1, reg1) Xsqlite3VdbeJumpHere(tls, v, addrGe) @@ -135963,33 +133649,33 @@ func windowCodeRangeTest(tls *libc.TLS, p uintptr, op int32, csr1 int32, regVal // Additionally, if either reg1 or reg2 are NULL but the jump to lbl is // not taken, control jumps over the comparison operator coded below this // block. - if (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(0)*32)).FsortFlags) & 0x02) != 0 { + if (int32((*ExprList_item)(unsafe.Pointer((pOrderBy + 8 /* &.a */))).FsortFlags) & KEYINFO_ORDER_BIGNULL) != 0 { // This block runs if reg1 contains a NULL. - var addr int32 = Xsqlite3VdbeAddOp1(tls, v, 51, reg1) + var addr int32 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, reg1) switch op { - case 57: - Xsqlite3VdbeAddOp2(tls, v, 11, 0, lbl) + case OP_Ge: + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lbl) break fallthrough - case 54: - Xsqlite3VdbeAddOp2(tls, v, 51, reg2, lbl) + case OP_Gt: + Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, reg2, lbl) break fallthrough - case 55: - Xsqlite3VdbeAddOp2(tls, v, 50, reg2, lbl) + case OP_Le: + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, reg2, lbl) break fallthrough default: /* no-op */ break } - Xsqlite3VdbeAddOp2(tls, v, 11, 0, (Xsqlite3VdbeCurrentAddr(tls, v) + 3)) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, (Xsqlite3VdbeCurrentAddr(tls, v) + 3)) // This block runs if reg1 is not NULL, but reg2 is. Xsqlite3VdbeJumpHere(tls, v, addr) - Xsqlite3VdbeAddOp2(tls, v, 50, reg2, lbl) - if (op == 54) || (op == 57) { + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, reg2, lbl) + if (op == OP_Gt) || (op == OP_Ge) { Xsqlite3VdbeChangeP2(tls, v, -1, (Xsqlite3VdbeCurrentAddr(tls, v) + 1)) } } @@ -135998,7 +133684,7 @@ func windowCodeRangeTest(tls *libc.TLS, p uintptr, op int32, csr1 int32, regVal // control skips over this test if the BIGNULL flag is set and either // reg1 or reg2 contain a NULL value. Xsqlite3VdbeAddOp3(tls, v, op, reg2, lbl, reg1) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x80)) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NULLEQ) Xsqlite3ReleaseTempReg(tls, pParse, reg1) Xsqlite3ReleaseTempReg(tls, pParse, reg2) @@ -136017,41 +133703,41 @@ func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOn var ret int32 = 0 var v uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpVdbe var addrContinue int32 = 0 - var bPeer int32 = (libc.Bool32(int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != 76)) + var bPeer int32 = (libc.Bool32(int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_ROWS)) var lblDone int32 = Xsqlite3VdbeMakeLabel(tls, pParse) var addrNextRange int32 = 0 // Special case - WINDOW_AGGINVERSE is always a no-op if the frame // starts with UNBOUNDED PRECEDING. - if (op == 2) && (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 90) { + if (op == WINDOW_AGGINVERSE) && (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_UNBOUNDED) { return 0 } if regCountdown > 0 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89 { + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE { addrNextRange = Xsqlite3VdbeCurrentAddr(tls, v) - if op == 2 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 86 { + if op == WINDOW_AGGINVERSE { + if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING { windowCodeRangeTest(tls, - p, 55, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, lblDone) + p, OP_Le, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, lblDone) } else { windowCodeRangeTest(tls, - p, 57, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, lblDone) + p, OP_Ge, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, lblDone) } } else { windowCodeRangeTest(tls, - p, 54, (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, lblDone) + p, OP_Gt, (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, lblDone) } } else { - Xsqlite3VdbeAddOp3(tls, v, 48, regCountdown, lblDone, 1) + Xsqlite3VdbeAddOp3(tls, v, OP_IfPos, regCountdown, lblDone, 1) } } - if (op == 1) && ((*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0) { + if (op == WINDOW_RETURN_ROW) && ((*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0) { windowAggFinal(tls, p, 0) } addrContinue = Xsqlite3VdbeCurrentAddr(tls, v) @@ -136061,12 +133747,12 @@ func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOn // start cursor does not advance past the end cursor within the // temporary table. It otherwise might, if (a>b). if (((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == int32((*Window)(unsafe.Pointer(pMWin)).FeEnd)) && (regCountdown != 0)) && - (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89)) && (op == 2) { + (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE)) && (op == WINDOW_AGGINVERSE) { var regRowid1 int32 = Xsqlite3GetTempReg(tls, pParse) var regRowid2 int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 127, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, regRowid1) - Xsqlite3VdbeAddOp2(tls, v, 127, (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regRowid2) - Xsqlite3VdbeAddOp3(tls, v, 57, regRowid2, lblDone, regRowid1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, regRowid1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regRowid2) + Xsqlite3VdbeAddOp3(tls, v, OP_Ge, regRowid2, lblDone, regRowid1) Xsqlite3ReleaseTempReg(tls, pParse, regRowid1) Xsqlite3ReleaseTempReg(tls, pParse, regRowid2) @@ -136074,18 +133760,18 @@ func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOn } switch op { - case 1: + case WINDOW_RETURN_ROW: csr = (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr reg = (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Freg windowReturnOneRow(tls, p) break - case 2: + case WINDOW_AGGINVERSE: csr = (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr reg = (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Freg if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid != 0 { - Xsqlite3VdbeAddOp2(tls, v, 82, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid, 1) } else { windowAggStep(tls, p, pMWin, csr, 1, (*WindowCodeArg)(unsafe.Pointer(p)).FregArg) } @@ -136097,7 +133783,7 @@ func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOn reg = (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Freg if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid != 0 { - Xsqlite3VdbeAddOp2(tls, v, 82, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid, 1) } else { windowAggStep(tls, p, pMWin, csr, 0, (*WindowCodeArg)(unsafe.Pointer(p)).FregArg) } @@ -136105,19 +133791,19 @@ func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOn } if op == (*WindowCodeArg)(unsafe.Pointer(p)).FeDelete { - Xsqlite3VdbeAddOp1(tls, v, 122, csr) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x02)) + Xsqlite3VdbeAddOp1(tls, v, OP_Delete, csr) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_SAVEPOSITION) } if jumpOnEof != 0 { - Xsqlite3VdbeAddOp2(tls, v, 5, csr, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, csr, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) - ret = Xsqlite3VdbeAddOp0(tls, v, 11) + ret = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) } else { - Xsqlite3VdbeAddOp2(tls, v, 5, csr, ((Xsqlite3VdbeCurrentAddr(tls, v) + 1) + bPeer)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, csr, ((Xsqlite3VdbeCurrentAddr(tls, v) + 1) + bPeer)) if bPeer != 0 { - Xsqlite3VdbeAddOp2(tls, v, 11, 0, lblDone) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lblDone) } } @@ -136140,7 +133826,7 @@ func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOn } if addrNextRange != 0 { - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addrNextRange) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrNextRange) } Xsqlite3VdbeResolveLabel(tls, v, lblDone) return ret @@ -136212,7 +133898,7 @@ func windowExprGtZero(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { /* s var ret int32 = 0 var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb *(*uintptr)(unsafe.Pointer(bp /* pVal */)) = uintptr(0) - Xsqlite3ValueFromExpr(tls, db, pExpr, (*Sqlite3)(unsafe.Pointer(db)).Fenc, uint8(0x43), bp /* &pVal */) + Xsqlite3ValueFromExpr(tls, db, pExpr, (*Sqlite3)(unsafe.Pointer(db)).Fenc, SQLITE_AFF_NUMERIC, bp /* &pVal */) if (*(*uintptr)(unsafe.Pointer(bp /* pVal */)) != 0) && (Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(bp /* pVal */))) > 0) { ret = 1 } @@ -136560,20 +134246,20 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin var pMWin uintptr = (*Select)(unsafe.Pointer(p)).FpWin var pOrderBy uintptr = (*Window)(unsafe.Pointer(pMWin)).FpOrderBy var v uintptr = Xsqlite3GetVdbe(tls, pParse) - var csrWrite int32 // Cursor used to write to eph. table - var csrInput int32 = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FiCursor // Cursor of sub-select - var nInput int32 = int32((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab)).FnCol) // Number of cols returned by sub - var iInput int32 // To iterate through sub cols - var addrNe int32 // Address of OP_Ne - var addrGosubFlush int32 = 0 // Address of OP_Gosub to flush: - var addrInteger int32 = 0 // Address of OP_Integer - var addrEmpty int32 // Address of OP_Rewind in flush: - var regNew int32 // Array of registers holding new input row - var regRecord int32 // regNew array in record form - var regRowid int32 // Rowid for regRecord in eph table - var regNewPeer int32 = 0 // Peer values for new row (part of regNew) - var regPeer int32 = 0 // Peer values for current row - var regFlushPart int32 = 0 // Register for "Gosub flush_partition" + var csrWrite int32 // Cursor used to write to eph. table + var csrInput int32 = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FiCursor // Cursor of sub-select + var nInput int32 = int32((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpTab)).FnCol) // Number of cols returned by sub + var iInput int32 // To iterate through sub cols + var addrNe int32 // Address of OP_Ne + var addrGosubFlush int32 = 0 // Address of OP_Gosub to flush: + var addrInteger int32 = 0 // Address of OP_Integer + var addrEmpty int32 // Address of OP_Rewind in flush: + var regNew int32 // Array of registers holding new input row + var regRecord int32 // regNew array in record form + var regRowid int32 // Rowid for regRecord in eph table + var regNewPeer int32 = 0 // Peer values for new row (part of regNew) + var regPeer int32 = 0 // Peer values for current row + var regFlushPart int32 = 0 // Register for "Gosub flush_partition" // var s WindowCodeArg at bp, 64 // Context object for sub-routines var lblWhereEnd int32 // Label just before sqlite3WhereEnd() code @@ -136601,26 +134287,26 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin // has been returned to the caller (WINDOW_RETURN_ROW), or they may // be deleted after they enter the frame (WINDOW_AGGSTEP). switch int32((*Window)(unsafe.Pointer(pMWin)).FeStart) { - case 86: - if (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != 89) && + case TK_FOLLOWING: + if (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_RANGE) && (windowExprGtZero(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpStart) != 0) { - (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = 1 + (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = WINDOW_RETURN_ROW } break - case 90: + case TK_UNBOUNDED: if windowCacheFrame(tls, pMWin) == 0 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == 88 { - if (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != 89) && + if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_PRECEDING { + if (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_RANGE) && (windowExprGtZero(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpEnd) != 0) { - (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = 3 + (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = WINDOW_AGGSTEP } } else { - (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = 1 + (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = WINDOW_RETURN_ROW } } break default: - (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = 2 + (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = WINDOW_AGGINVERSE break } @@ -136635,17 +134321,17 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin // If the window frame contains an " PRECEDING" or " FOLLOWING" // clause, allocate registers to store the results of evaluating each // . - if (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 88) || (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 86) { + if (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_PRECEDING) || (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING) { regStart = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) } - if (int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == 88) || (int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == 86) { + if (int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_PRECEDING) || (int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_FOLLOWING) { regEnd = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) } // If this is not a "ROWS BETWEEN ..." frame, then allocate arrays of // registers to store copies of the ORDER BY expressions (peer values) // for the main loop, and for each cursor (start, current and end). - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != 76 { + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_ROWS { var nPeer int32 = func() int32 { if pOrderBy != 0 { return (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr @@ -136670,9 +134356,9 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin // into an array of registers starting at regNew. Assemble them into // a record in register regRecord. for iInput = 0; iInput < nInput; iInput++ { - Xsqlite3VdbeAddOp3(tls, v, 89, csrInput, iInput, (regNew + iInput)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, csrInput, iInput, (regNew + iInput)) } - Xsqlite3VdbeAddOp3(tls, v, 91, regNew, nInput, regRecord) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regNew, nInput, regRecord) // An input row has just been read into an array of registers starting // at regNew. If the window has a PARTITION clause, this block generates @@ -136687,19 +134373,19 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin var pKeyInfo uintptr = Xsqlite3KeyInfoFromExprList(tls, pParse, pPart, 0, 0) regFlushPart = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - addr = Xsqlite3VdbeAddOp3(tls, v, 86, regNewPart, (*Window)(unsafe.Pointer(pMWin)).FregPart, nPart) + addr = Xsqlite3VdbeAddOp3(tls, v, OP_Compare, regNewPart, (*Window)(unsafe.Pointer(pMWin)).FregPart, nPart) Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -9) - Xsqlite3VdbeAddOp3(tls, v, 16, (addr + 2), (addr + 4), (addr + 2)) + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, (addr + 2), (addr + 4), (addr + 2)) - addrGosubFlush = Xsqlite3VdbeAddOp1(tls, v, 12, regFlushPart) + addrGosubFlush = Xsqlite3VdbeAddOp1(tls, v, OP_Gosub, regFlushPart) - Xsqlite3VdbeAddOp3(tls, v, 77, regNewPart, (*Window)(unsafe.Pointer(pMWin)).FregPart, (nPart - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regNewPart, (*Window)(unsafe.Pointer(pMWin)).FregPart, (nPart - 1)) } // Insert the new row into the ephemeral table - Xsqlite3VdbeAddOp2(tls, v, 120, csrWrite, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, csrWrite, regRecord, regRowid) - addrNe = Xsqlite3VdbeAddOp3(tls, v, 52, (*Window)(unsafe.Pointer(pMWin)).FregOne, 0, regRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, csrWrite, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, csrWrite, regRecord, regRowid) + addrNe = Xsqlite3VdbeAddOp3(tls, v, OP_Ne, (*Window)(unsafe.Pointer(pMWin)).FregOne, 0, regRowid) // This block is run for the first row of each partition (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FregArg = windowInitAccum(tls, pParse, pMWin) @@ -136707,7 +134393,7 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin if regStart != 0 { Xsqlite3ExprCode(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpStart, regStart) windowCheckValue(tls, pParse, regStart, (0 + (func() int32 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89 { + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE { return 3 } return 0 @@ -136716,52 +134402,52 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin if regEnd != 0 { Xsqlite3ExprCode(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpEnd, regEnd) windowCheckValue(tls, pParse, regEnd, (1 + (func() int32 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89 { + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE { return 3 } return 0 }()))) } - if ((int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != 89) && (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == int32((*Window)(unsafe.Pointer(pMWin)).FeEnd))) && (regStart != 0) { + if ((int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_RANGE) && (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == int32((*Window)(unsafe.Pointer(pMWin)).FeEnd))) && (regStart != 0) { var op int32 = func() int32 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 86 { - return 57 + if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING { + return OP_Ge } - return 55 + return OP_Le }() var addrGe int32 = Xsqlite3VdbeAddOp3(tls, v, op, regStart, 0, regEnd) // NeverNull because bound // values previously checked windowAggFinal(tls, bp /* &s */, 0) - Xsqlite3VdbeAddOp2(tls, v, 37, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, 1) windowReturnOneRow(tls, bp /* &s */) - Xsqlite3VdbeAddOp1(tls, v, 138, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr) - Xsqlite3VdbeAddOp2(tls, v, 11, 0, lblWhereEnd) + Xsqlite3VdbeAddOp1(tls, v, OP_ResetSorter, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lblWhereEnd) Xsqlite3VdbeJumpHere(tls, v, addrGe) } - if ((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 86) && (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != 89)) && (regEnd != 0) { + if ((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING) && (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_RANGE)) && (regEnd != 0) { - Xsqlite3VdbeAddOp3(tls, v, 106, regStart, regEnd, regStart) + Xsqlite3VdbeAddOp3(tls, v, OP_Subtract, regStart, regEnd, regStart) } - if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) != 90 { - Xsqlite3VdbeAddOp2(tls, v, 37, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fstart.Fcsr, 1) + if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) != TK_UNBOUNDED { + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fstart.Fcsr, 1) } - Xsqlite3VdbeAddOp2(tls, v, 37, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, 1) - Xsqlite3VdbeAddOp2(tls, v, 37, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Fcsr, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Fcsr, 1) if (regPeer != 0) && (pOrderBy != 0) { - Xsqlite3VdbeAddOp3(tls, v, 77, regNewPeer, regPeer, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) - Xsqlite3VdbeAddOp3(tls, v, 77, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fstart.Freg, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) - Xsqlite3VdbeAddOp3(tls, v, 77, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Freg, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) - Xsqlite3VdbeAddOp3(tls, v, 77, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Freg, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regNewPeer, regPeer, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fstart.Freg, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Freg, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Freg, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) } - Xsqlite3VdbeAddOp2(tls, v, 11, 0, lblWhereEnd) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lblWhereEnd) Xsqlite3VdbeJumpHere(tls, v, addrNe) @@ -136769,56 +134455,56 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin if regPeer != 0 { windowIfNewPeer(tls, pParse, pOrderBy, regNewPeer, regPeer, lblWhereEnd) } - if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 86 { - windowCodeOp(tls, bp /* &s */, 3, 0, 0) - if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) != 90 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89 { + if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING { + windowCodeOp(tls, bp /* &s */, WINDOW_AGGSTEP, 0, 0) + if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) != TK_UNBOUNDED { + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE { var lbl int32 = Xsqlite3VdbeMakeLabel(tls, pParse) var addrNext int32 = Xsqlite3VdbeCurrentAddr(tls, v) - windowCodeRangeTest(tls, bp /* &s */, 57, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, regEnd, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Fcsr, lbl) - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) - windowCodeOp(tls, bp /* &s */, 1, 0, 0) - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addrNext) + windowCodeRangeTest(tls, bp /* &s */, OP_Ge, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, regEnd, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Fcsr, lbl) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrNext) Xsqlite3VdbeResolveLabel(tls, v, lbl) } else { - windowCodeOp(tls, bp /* &s */, 1, regEnd, 0) - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, regEnd, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) } } - } else if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == 88 { - var bRPS int32 = (libc.Bool32((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 88) && (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89))) - windowCodeOp(tls, bp /* &s */, 3, regEnd, 0) + } else if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_PRECEDING { + var bRPS int32 = (libc.Bool32((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_PRECEDING) && (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE))) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGSTEP, regEnd, 0) if bRPS != 0 { - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) } - windowCodeOp(tls, bp /* &s */, 1, 0, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 0) if !(bRPS != 0) { - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) } } else { var addr int32 = 0 - windowCodeOp(tls, bp /* &s */, 3, 0, 0) - if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) != 90 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89 { + windowCodeOp(tls, bp /* &s */, WINDOW_AGGSTEP, 0, 0) + if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) != TK_UNBOUNDED { + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE { var lbl int32 = 0 addr = Xsqlite3VdbeCurrentAddr(tls, v) if regEnd != 0 { lbl = Xsqlite3VdbeMakeLabel(tls, pParse) - windowCodeRangeTest(tls, bp /* &s */, 57, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, regEnd, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Fcsr, lbl) + windowCodeRangeTest(tls, bp /* &s */, OP_Ge, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, regEnd, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Fcsr, lbl) } - windowCodeOp(tls, bp /* &s */, 1, 0, 0) - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) if regEnd != 0 { - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addr) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addr) Xsqlite3VdbeResolveLabel(tls, v, lbl) } } else { if regEnd != 0 { - addr = Xsqlite3VdbeAddOp3(tls, v, 48, regEnd, 0, 1) + addr = Xsqlite3VdbeAddOp3(tls, v, OP_IfPos, regEnd, 0, 1) } - windowCodeOp(tls, bp /* &s */, 1, 0, 0) - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) if regEnd != 0 { Xsqlite3VdbeJumpHere(tls, v, addr) } @@ -136832,66 +134518,66 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin // Fall through if (*Window)(unsafe.Pointer(pMWin)).FpPartition != 0 { - addrInteger = Xsqlite3VdbeAddOp2(tls, v, 69, 0, regFlushPart) + addrInteger = Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regFlushPart) Xsqlite3VdbeJumpHere(tls, v, addrGosubFlush) } - addrEmpty = Xsqlite3VdbeAddOp1(tls, v, 37, csrWrite) + addrEmpty = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, csrWrite) - if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == 88 { - var bRPS int32 = (libc.Bool32((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 88) && (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89))) - windowCodeOp(tls, bp /* &s */, 3, regEnd, 0) + if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_PRECEDING { + var bRPS int32 = (libc.Bool32((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_PRECEDING) && (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE))) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGSTEP, regEnd, 0) if bRPS != 0 { - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) } - windowCodeOp(tls, bp /* &s */, 1, 0, 0) - } else if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 86 { + windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 0) + } else if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING { var addrStart int32 var addrBreak1 int32 var addrBreak2 int32 var addrBreak3 int32 - windowCodeOp(tls, bp /* &s */, 3, 0, 0) - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89 { + windowCodeOp(tls, bp /* &s */, WINDOW_AGGSTEP, 0, 0) + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE { addrStart = Xsqlite3VdbeCurrentAddr(tls, v) - addrBreak2 = windowCodeOp(tls, bp /* &s */, 2, regStart, 1) - addrBreak1 = windowCodeOp(tls, bp /* &s */, 1, 0, 1) - } else if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == 90 { + addrBreak2 = windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 1) + addrBreak1 = windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 1) + } else if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_UNBOUNDED { addrStart = Xsqlite3VdbeCurrentAddr(tls, v) - addrBreak1 = windowCodeOp(tls, bp /* &s */, 1, regStart, 1) - addrBreak2 = windowCodeOp(tls, bp /* &s */, 2, 0, 1) + addrBreak1 = windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, regStart, 1) + addrBreak2 = windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, 0, 1) } else { addrStart = Xsqlite3VdbeCurrentAddr(tls, v) - addrBreak1 = windowCodeOp(tls, bp /* &s */, 1, regEnd, 1) - addrBreak2 = windowCodeOp(tls, bp /* &s */, 2, regStart, 1) + addrBreak1 = windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, regEnd, 1) + addrBreak2 = windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 1) } - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addrStart) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrStart) Xsqlite3VdbeJumpHere(tls, v, addrBreak2) addrStart = Xsqlite3VdbeCurrentAddr(tls, v) - addrBreak3 = windowCodeOp(tls, bp /* &s */, 1, 0, 1) - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addrStart) + addrBreak3 = windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrStart) Xsqlite3VdbeJumpHere(tls, v, addrBreak1) Xsqlite3VdbeJumpHere(tls, v, addrBreak3) } else { var addrBreak int32 var addrStart int32 - windowCodeOp(tls, bp /* &s */, 3, 0, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGSTEP, 0, 0) addrStart = Xsqlite3VdbeCurrentAddr(tls, v) - addrBreak = windowCodeOp(tls, bp /* &s */, 1, 0, 1) - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addrStart) + addrBreak = windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 1) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrStart) Xsqlite3VdbeJumpHere(tls, v, addrBreak) } Xsqlite3VdbeJumpHere(tls, v, addrEmpty) - Xsqlite3VdbeAddOp1(tls, v, 138, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr) + Xsqlite3VdbeAddOp1(tls, v, OP_ResetSorter, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr) if (*Window)(unsafe.Pointer(pMWin)).FpPartition != 0 { if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid != 0 { - Xsqlite3VdbeAddOp2(tls, v, 69, 1, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid) } Xsqlite3VdbeChangeP1(tls, v, addrInteger, Xsqlite3VdbeCurrentAddr(tls, v)) - Xsqlite3VdbeAddOp1(tls, v, 65, regFlushPart) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regFlushPart) } } @@ -136989,7 +134675,7 @@ func parserDoubleLinkSelect(tls *libc.TLS, pParse uintptr, p uintptr) { /* sqlit } { (*Select)(unsafe.Pointer(pLoop)).FpNext = pNext - *(*U32)(unsafe.Pointer(pLoop + 4 /* &.selFlags */)) |= (U32(0x0000100)) + *(*U32)(unsafe.Pointer(pLoop + 4 /* &.selFlags */)) |= (SF_Compound) } goto __2 @@ -137001,7 +134687,7 @@ func parserDoubleLinkSelect(tls *libc.TLS, pParse uintptr, p uintptr) { /* sqlit goto __3 __3: ; - if ((((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000400)) == U32(0)) && ((libc.AssignInt32(&mxSelect, *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + uintptr(4)*4)))) > 0)) && (cnt > mxSelect) { + if ((((*Select)(unsafe.Pointer(p)).FselFlags & SF_MultiValue) == U32(0)) && ((libc.AssignInt32(&mxSelect, *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + 4*4)))) > 0)) && (cnt > mxSelect) { Xsqlite3ErrorMsg(tls, pParse, ts+20111 /* "too many terms i..." */, 0) } } @@ -137021,7 +134707,7 @@ func tokenExpr(tls *libc.TLS, pParse uintptr, op int32, t Token) uintptr { /* sq // memset(p, 0, sizeof(Expr)); (*Expr)(unsafe.Pointer(p)).Fop = U8(op) (*Expr)(unsafe.Pointer(p)).FaffExpr = int8(0) - (*Expr)(unsafe.Pointer(p)).Fflags = U32(0x800000) + (*Expr)(unsafe.Pointer(p)).Fflags = EP_Leaf (*Expr)(unsafe.Pointer(p)).FiAgg = int16(-1) (*Expr)(unsafe.Pointer(p)).FpLeft = libc.AssignPtrUintptr(p+24 /* &.pRight */, uintptr(0)) @@ -137031,14 +134717,14 @@ func tokenExpr(tls *libc.TLS, pParse uintptr, op int32, t Token) uintptr { /* sq (*Expr)(unsafe.Pointer(p)).Fop2 = U8(0) (*Expr)(unsafe.Pointer(p)).FiTable = 0 (*Expr)(unsafe.Pointer(p)).FiColumn = int16(0) - *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) = (p + uintptr(1)*72) + *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) = (p + 1*72) libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)), (*Token)(unsafe.Pointer(bp /* &t */)).Fz, uint64((*Token)(unsafe.Pointer(bp /* &t */)).Fn)) *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) + uintptr((*Token)(unsafe.Pointer(bp /* &t */)).Fn))) = int8(0) - if (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) + uintptr(0))))]) & 0x80) != 0 { + if (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)))))]) & 0x80) != 0 { Xsqlite3DequoteExpr(tls, p) } (*Expr)(unsafe.Pointer(p)).FnHeight = 1 - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { return Xsqlite3RenameTokenMap(tls, pParse, p, bp /* &t */) } } @@ -137050,7 +134736,7 @@ func tokenExpr(tls *libc.TLS, pParse uintptr, op int32, t Token) uintptr { /* sq // unary TK_ISNULL or TK_NOTNULL expression. func binaryToUnaryIfNull(tls *libc.TLS, pParse uintptr, pY uintptr, pA uintptr, op int32) { /* sqlite3.c:154385:15: */ var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if (((pA != 0) && (pY != 0)) && (int32((*Expr)(unsafe.Pointer(pY)).Fop) == 119)) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if (((pA != 0) && (pY != 0)) && (int32((*Expr)(unsafe.Pointer(pY)).Fop) == TK_NULL)) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { (*Expr)(unsafe.Pointer(pA)).Fop = U8(op) Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer(pA)).FpRight) (*Expr)(unsafe.Pointer(pA)).FpRight = uintptr(0) @@ -138018,9 +135704,9 @@ func Xsqlite3ParserInit(tls *libc.TLS, yypRawParser uintptr, pParse uintptr) { / var yypParser uintptr = yypRawParser (*YyParser)(unsafe.Pointer(yypParser)).FpParse = pParse (*YyParser)(unsafe.Pointer(yypParser)).Fyytos = yypParser + 16 /* &.yystack */ - (*YyStackEntry)(unsafe.Pointer((yypParser + 16 /* &.yystack */) + uintptr(0)*24)).Fstateno = uint16(0) - (*YyStackEntry)(unsafe.Pointer((yypParser + 16 /* &.yystack */) + uintptr(0)*24)).Fmajor = uint16(0) - (*YyParser)(unsafe.Pointer(yypParser)).FyystackEnd = ((yypParser + 16 /* &.yystack */) + uintptr((100-1))*24) + (*YyStackEntry)(unsafe.Pointer((yypParser + 16 /* &.yystack */))).Fstateno = uint16(0) + (*YyStackEntry)(unsafe.Pointer((yypParser + 16 /* &.yystack */))).Fmajor = uint16(0) + (*YyParser)(unsafe.Pointer(yypParser)).FyystackEnd = ((yypParser + 16 /* &.yystack */) + 99*24) } // The following function deletes the "minor type" or semantic value @@ -138220,7 +135906,7 @@ func Xsqlite3ParserFinalize(tls *libc.TLS, p uintptr) { /* sqlite3.c:156415:21: func yy_find_shift_action(tls *libc.TLS, iLookAhead uint16, stateno uint16) uint16 { /* sqlite3.c:156495:21: */ var i int32 - if int32(stateno) > 552 { + if int32(stateno) > YY_MAX_SHIFT { return stateno } @@ -138239,9 +135925,9 @@ func yy_find_shift_action(tls *libc.TLS, iLookAhead uint16, stateno uint16) uint continue } { - var j int32 = ((i - int32(iLookAhead)) + 100) + var j int32 = ((i - int32(iLookAhead)) + YYWILDCARD) - if (int32(yy_lookahead[j]) == 100) && (int32(iLookAhead) > 0) { + if (int32(yy_lookahead[j]) == YYWILDCARD) && (int32(iLookAhead) > 0) { return yy_action[j] } @@ -138295,8 +135981,8 @@ func yy_shift(tls *libc.TLS, yypParser uintptr, yyNewState uint16, yyMajor uint1 yyStackOverflow(tls, yypParser) return } - if int32(yyNewState) > 552 { - yyNewState = uint16(int32(yyNewState) + (1191 - 803)) + if int32(yyNewState) > YY_MAX_SHIFT { + yyNewState = uint16(int32(yyNewState) + (YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE)) } yytos = (*YyParser)(unsafe.Pointer(yypParser)).Fyytos (*YyStackEntry)(unsafe.Pointer(yytos)).Fstateno = yyNewState @@ -139084,6 +136770,7 @@ var yyRuleInfoNRhs = [385]int8{ int8(-2), // (383) anylist ::= anylist ANY int8(0), // (384) with ::= } /* sqlite3.c:157063:26 */ + // Forward Declaration // Perform a reduce action and the shift that must immediately @@ -139153,7 +136840,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(4): /* transtype ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = 7 + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = TK_DEFERRED } break case uint32(5): @@ -139164,7 +136851,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(306): /* range_or_rows ::= RANGE|ROWS|GROUPS */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp + uintptr(0)*24)).Fmajor) /*A-overwrites-X*/ + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor) /*A-overwrites-X*/ } break case uint32(8): @@ -139176,22 +136863,22 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(10): /* cmd ::= SAVEPOINT nm */ { - Xsqlite3Savepoint(tls, pParse, 0, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3Savepoint(tls, pParse, SAVEPOINT_BEGIN, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(11): /* cmd ::= RELEASE savepoint_opt nm */ { - Xsqlite3Savepoint(tls, pParse, 1, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3Savepoint(tls, pParse, SAVEPOINT_RELEASE, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(12): /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ { - Xsqlite3Savepoint(tls, pParse, 2, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3Savepoint(tls, pParse, SAVEPOINT_ROLLBACK, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(13): /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ { - Xsqlite3StartTable(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), 0, 0, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) + Xsqlite3StartTable(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), 0, 0, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) } break case uint32(14): /* createkw ::= CREATE */ @@ -139217,7 +136904,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(232): /* collate ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = 0 + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = 0 } break case uint32(16): /* ifnotexists ::= IF NOT EXISTS */ @@ -139229,33 +136916,33 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // temp ::= TEMP case uint32(46): /* autoinc ::= AUTOINCR */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 1 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = 1 } break case uint32(19): /* create_table_args ::= LP columnlist conslist_opt RP table_options */ { - Xsqlite3EndTable(tls, pParse, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), uint8(*(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))), uintptr(0)) + Xsqlite3EndTable(tls, pParse, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), uint8(*(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))), uintptr(0)) } break case uint32(20): /* create_table_args ::= AS select */ { - Xsqlite3EndTable(tls, pParse, uintptr(0), uintptr(0), uint8(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) - Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3EndTable(tls, pParse, uintptr(0), uintptr(0), uint8(0), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) + Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(22): /* table_options ::= WITHOUT nm */ { - if ((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn == uint32(5)) && (Xsqlite3_strnicmp(tls, (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz, ts+13865 /* "rowid" */, 5) == 0) { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = (0x0080 | 0x0200) + if ((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn == uint32(5)) && (Xsqlite3_strnicmp(tls, (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz, ts+13865 /* "rowid" */, 5) == 0) { + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = (TF_WithoutRowid | TF_NoVisibleRowid) } else { *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 0 - Xsqlite3ErrorMsg(tls, pParse, ts+20205 /* "unknown table op..." */, libc.VaList(bp, (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn, (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz)) + Xsqlite3ErrorMsg(tls, pParse, ts+20205 /* "unknown table op..." */, libc.VaList(bp, (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn, (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz)) } } break case uint32(23): /* columnname ::= nm typetoken */ { - Xsqlite3AddColumn(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3AddColumn(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(24): @@ -139264,89 +136951,89 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(102): /* as ::= */ { - (*Token)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)).Fn = uint32(0) - (*Token)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)).Fz = uintptr(0) + (*Token)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)).Fn = uint32(0) + (*Token)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)).Fz = uintptr(0) } break case uint32(25): /* typetoken ::= typename LP signed RP */ { - (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)).Fn = uint32((int32((int64(((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn))) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).Fz)) / 1))) + (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)).Fn = uint32((int32((int64(((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn))) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).Fz)) / 1))) } break case uint32(26): /* typetoken ::= typename LP signed COMMA signed RP */ { - (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)).Fn = uint32((int32((int64(((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn))) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-5)*24+8 /* &.minor */)).Fz)) / 1))) + (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)).Fn = uint32((int32((int64(((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn))) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-5)*24+8 /* &.minor */)).Fz)) / 1))) } break case uint32(27): /* typename ::= typename ID|STRING */ { - (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)).Fn = ((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn + uint32((int32((int64((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz)) / 1)))) + (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)).Fn = ((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn + uint32((int32((int64((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz)) / 1)))) } break case uint32(28): /* scanpt ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = yyLookaheadToken.Fz + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = yyLookaheadToken.Fz } break case uint32(29): /* scantok ::= */ { - *(*Token)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = yyLookaheadToken + *(*Token)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = yyLookaheadToken } break case uint32(30): fallthrough // ccons ::= CONSTRAINT nm case uint32(65): /* tcons ::= CONSTRAINT nm */ { - (*Parse)(unsafe.Pointer(pParse)).FconstraintName = *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + (*Parse)(unsafe.Pointer(pParse)).FconstraintName = *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(31): /* ccons ::= DEFAULT scantok term */ { - Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fn))) + Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fn))) } break case uint32(32): /* ccons ::= DEFAULT LP expr RP */ { - Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fz + uintptr(1)), (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz) + Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fz + uintptr(1)), (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz) } break case uint32(33): /* ccons ::= DEFAULT PLUS scantok term */ { - Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fn))) + Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fn))) } break case uint32(34): /* ccons ::= DEFAULT MINUS scantok term */ { - var p uintptr = Xsqlite3PExpr(tls, pParse, 170, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) + var p uintptr = Xsqlite3PExpr(tls, pParse, TK_UMINUS, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0)) Xsqlite3AddDefaultValue(tls, pParse, p, (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fn))) } break case uint32(35): /* ccons ::= DEFAULT scantok ID|INDEXED */ { - var p uintptr = tokenExpr(tls, pParse, 115, *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + var p uintptr = tokenExpr(tls, pParse, TK_STRING, *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */))) if p != 0 { Xsqlite3ExprIdToTrueFalse(tls, p) } - Xsqlite3AddDefaultValue(tls, pParse, p, (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn))) + Xsqlite3AddDefaultValue(tls, pParse, p, (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn))) } break case uint32(36): /* ccons ::= NOT NULL onconf */ { - Xsqlite3AddNotNull(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3AddNotNull(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(37): /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ { - Xsqlite3AddPrimaryKey(tls, pParse, uintptr(0), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) + Xsqlite3AddPrimaryKey(tls, pParse, uintptr(0), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) } break case uint32(38): /* ccons ::= UNIQUE onconf */ { - Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), uintptr(0), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), 0, 0, - uint8(1)) + Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), uintptr(0), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0), uintptr(0), 0, 0, + SQLITE_IDXTYPE_UNIQUE) } break case uint32(39): /* ccons ::= CHECK LP expr RP */ @@ -139356,17 +137043,17 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(40): /* ccons ::= REFERENCES nm eidlist_opt refargs */ { - Xsqlite3CreateForeignKey(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3CreateForeignKey(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(41): /* ccons ::= defer_subclause */ { - Xsqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(42): /* ccons ::= COLLATE ID|STRING */ { - Xsqlite3AddCollateType(tls, pParse, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3AddCollateType(tls, pParse, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(43): /* generated ::= LP expr RP */ @@ -139376,17 +137063,17 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(44): /* generated ::= LP expr RP ID */ { - Xsqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(47): /* refargs ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = (0 * 0x0101) /* EV: R-19803-45884 */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = (OE_None * 0x0101) /* EV: R-19803-45884 */ } break case uint32(48): /* refargs ::= refargs refarg */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = ((*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) & ^*(*int32)(unsafe.Pointer((yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy207 */) + 4 /* &.mask */))) | *(*int32)(unsafe.Pointer((yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy207 */) /* &.value */))) + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = ((*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) & ^*(*int32)(unsafe.Pointer((yymsp + 8 /* &.minor */ /* &.yy207 */) + 4 /* &.mask */))) | *(*int32)(unsafe.Pointer((yymsp + 8 /* &.minor */ /* &.yy207 */) /* &.value */))) } break case uint32(49): /* refarg ::= MATCH nm */ @@ -139403,39 +137090,39 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(51): /* refarg ::= ON DELETE refact */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy207 */ /* &.value */)) = *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy207 */ /* &.value */)) = *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy207 */ + 4 /* &.mask */)) = 0x0000ff } break case uint32(52): /* refarg ::= ON UPDATE refact */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy207 */ /* &.value */)) = (*(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) << 8) + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy207 */ /* &.value */)) = (*(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) << 8) *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy207 */ + 4 /* &.mask */)) = 0x00ff00 } break case uint32(53): /* refact ::= SET NULL */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 8 /* EV: R-33326-45252 */ + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = OE_SetNull /* EV: R-33326-45252 */ } break case uint32(54): /* refact ::= SET DEFAULT */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 9 /* EV: R-33326-45252 */ + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = OE_SetDflt /* EV: R-33326-45252 */ } break case uint32(55): /* refact ::= CASCADE */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 10 /* EV: R-33326-45252 */ + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Cascade /* EV: R-33326-45252 */ } break case uint32(56): /* refact ::= RESTRICT */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 7 /* EV: R-33326-45252 */ + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Restrict /* EV: R-33326-45252 */ } break case uint32(57): /* refact ::= NO ACTION */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 0 /* EV: R-33326-45252 */ + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = OE_None /* EV: R-33326-45252 */ } break case uint32(58): /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ @@ -139449,7 +137136,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(162): /* insert_cmd ::= INSERT orconf */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(61): @@ -139477,13 +137164,13 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(66): /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ { - Xsqlite3AddPrimaryKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), 0) + Xsqlite3AddPrimaryKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), 0) } break case uint32(67): /* tcons ::= UNIQUE LP sortlist RP onconf */ { - Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), 0, 0, - uint8(1)) + Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0), uintptr(0), 0, 0, + SQLITE_IDXTYPE_UNIQUE) } break case uint32(68): /* tcons ::= CHECK LP expr RP onconf */ @@ -139494,65 +137181,58 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in case uint32(69): /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ { Xsqlite3CreateForeignKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) - Xsqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(71): fallthrough // onconf ::= case uint32(73): /* orconf ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = 11 + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = OE_Default } break case uint32(72): /* onconf ::= ON CONFLICT resolvetype */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(75): /* resolvetype ::= IGNORE */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 4 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Ignore } break case uint32(76): fallthrough // resolvetype ::= REPLACE case uint32(163): /* insert_cmd ::= REPLACE */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 5 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Replace } break case uint32(77): /* cmd ::= DROP TABLE ifexists fullname */ { - Xsqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), 0, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) + Xsqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), 0, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(80): /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ { - Xsqlite3CreateView(tls, pParse, (yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */))) + Xsqlite3CreateView(tls, pParse, (yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */))) } break case uint32(81): /* cmd ::= DROP VIEW ifexists fullname */ { - Xsqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), 1, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) + Xsqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), 1, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(82): /* cmd ::= select */ { - *(*SelectDest)(unsafe.Pointer(bp + 24 /* dest */)) = SelectDest{ - FeDest: U8(9), - FiSDParm: 0, - FiSDParm2: 0, - FiSdst: 0, - FnSdst: 0, - FzAffSdst: uintptr(0), - FpOrderBy: uintptr(0)} - Xsqlite3Select(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), bp+24 /* &dest */) - Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*SelectDest)(unsafe.Pointer(bp + 24 /* dest */)) = SelectDest{FeDest: SRT_Output} + Xsqlite3Select(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), bp+24 /* &dest */) + Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(83): /* select ::= WITH wqlist selectnowith */ { - var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) if p != 0 { (*Select)(unsafe.Pointer(p)).FpWith = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) parserDoubleLinkSelect(tls, pParse, p) @@ -139564,7 +137244,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(84): /* select ::= WITH RECURSIVE wqlist selectnowith */ { - var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) if p != 0 { (*Select)(unsafe.Pointer(p)).FpWith = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) parserDoubleLinkSelect(tls, pParse, p) @@ -139576,16 +137256,16 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(85): /* select ::= selectnowith */ { - var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) if p != 0 { parserDoubleLinkSelect(tls, pParse, p) } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = p //A-overwrites-X + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = p //A-overwrites-X } break case uint32(86): /* selectnowith ::= selectnowith multiselect_op oneselect */ { - var pRhs uintptr = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + var pRhs uintptr = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) var pLhs uintptr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) if (pRhs != 0) && ((*Select)(unsafe.Pointer(pRhs)).FpPrior != 0) { var pFrom uintptr @@ -139600,10 +137280,10 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in (*Select)(unsafe.Pointer(pRhs)).Fop = U8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) (*Select)(unsafe.Pointer(pRhs)).FpPrior = pLhs if pLhs != 0 { - *(*U32)(unsafe.Pointer(pLhs + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000400)) + *(*U32)(unsafe.Pointer(pLhs + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_MultiValue))) } - *(*U32)(unsafe.Pointer(pRhs + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000400)) - if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) != 133 { + *(*U32)(unsafe.Pointer(pRhs + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_MultiValue))) + if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) != TK_ALL { (*Parse)(unsafe.Pointer(pParse)).FhasCompound = U8(1) } } else { @@ -139616,22 +137296,22 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // multiselect_op ::= UNION case uint32(89): /* multiselect_op ::= EXCEPT|INTERSECT */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp + uintptr(0)*24)).Fmajor) /*A-overwrites-OP*/ + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor) /*A-overwrites-OP*/ } break case uint32(88): /* multiselect_op ::= UNION ALL */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 133 + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = TK_ALL } break case uint32(90): /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uint32(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uint32(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */))), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(91): /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-9)*24 + 8 /* &.minor */)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uint32(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-9)*24 + 8 /* &.minor */)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uint32(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */))), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-9)*24 + 8 /* &.minor */)) != 0 { (*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-9)*24 + 8 /* &.minor */)))).FpWinDefn = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) } else { @@ -139641,19 +137321,19 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(92): /* values ::= VALUES LP nexprlist RP */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0x0000200), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), SF_Values, uintptr(0)) } break case uint32(93): /* values ::= values COMMA LP nexprlist RP */ { var pRight uintptr var pLeft uintptr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) - pRight = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), (uint32(0x0000200 | 0x0000400)), uintptr(0)) + pRight = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), (uint32(SF_Values | SF_MultiValue)), uintptr(0)) if pLeft != 0 { - *(*U32)(unsafe.Pointer(pLeft + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000400)) + *(*U32)(unsafe.Pointer(pLeft + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_MultiValue))) } if pRight != 0 { - (*Select)(unsafe.Pointer(pRight)).Fop = U8(133) + (*Select)(unsafe.Pointer(pRight)).Fop = TK_ALL (*Select)(unsafe.Pointer(pRight)).FpPrior = pLeft *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = pRight } else { @@ -139663,12 +137343,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(94): /* distinct ::= DISTINCT */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 0x0000001 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = SF_Distinct } break case uint32(95): /* distinct ::= ALL */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 0x0000002 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = SF_All } break case uint32(97): @@ -139683,29 +137363,29 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(228): /* eidlist_opt ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = uintptr(0) } break case uint32(98): /* selcollist ::= sclp scanpt expr scanpt as */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) - if (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn > uint32(0) { - Xsqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + if (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn > uint32(0) { + Xsqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), (yymsp + 8 /* &.minor */ /* &.yy0 */), 1) } Xsqlite3ExprListSetSpan(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(99): /* selcollist ::= sclp scanpt STAR */ { - var p uintptr = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 177, uintptr(0)) + var p uintptr = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ASTERISK, uintptr(0)) *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), p) } break case uint32(100): /* selcollist ::= sclp scanpt nm DOT STAR */ { - var pRight uintptr = Xsqlite3PExpr(tls, pParse, 177, uintptr(0), uintptr(0)) - var pLeft uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 59, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) - var pDot uintptr = Xsqlite3PExpr(tls, pParse, 139, pLeft, pRight) + var pRight uintptr = Xsqlite3PExpr(tls, pParse, TK_ASTERISK, uintptr(0), uintptr(0)) + var pLeft uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ID, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + var pDot uintptr = Xsqlite3PExpr(tls, pParse, TK_DOT, pLeft, pRight) *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), pDot) } break @@ -139717,53 +137397,53 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(245): /* minus_num ::= MINUS INTEGER|FLOAT */ { - *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(103): fallthrough // from ::= case uint32(106): /* stl_prefix ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = uintptr(0) } break case uint32(104): /* from ::= FROM seltablist */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) Xsqlite3SrcListShiftJoinType(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(105): /* stl_prefix ::= seltablist joinop */ { if (*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) != 0) && ((*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FnSrc > 0) { - (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(((*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FnSrc-1))*112)).Ffg.Fjointype = U8(*(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(((*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FnSrc-1))*112)).Ffg.Fjointype = U8(*(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } } break case uint32(107): /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) Xsqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(108): /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) Xsqlite3SrcListFuncArgs(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) } break case uint32(109): /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(110): /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ { - if (((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) == uintptr(0)) && ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fn == uint32(0))) && (*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) == uintptr(0))) && (*(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) == uintptr(0)) { + if (((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) == uintptr(0)) && ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fn == uint32(0))) && (*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) == uintptr(0))) && (*(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) == uintptr(0)) { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) } else if (*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)))).FnSrc == 1 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) != 0 { var pNew uintptr = ((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(((*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)))).FnSrc-1))*112) var pOld uintptr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 8 /* &.a */ @@ -139783,8 +137463,8 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in } else { var pSubquery uintptr Xsqlite3SrcListShiftJoinType(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) - pSubquery = Xsqlite3SelectNew(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0x0000800), uintptr(0)) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), pSubquery, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + pSubquery = Xsqlite3SelectNew(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), SF_NestedFrom, uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), pSubquery, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } } @@ -139793,43 +137473,43 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // dbnm ::= case uint32(125): /* indexed_opt ::= */ { - (*Token)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)).Fz = uintptr(0) - (*Token)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)).Fn = uint32(0) + (*Token)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)).Fz = uintptr(0) + (*Token)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)).Fn = uint32(0) } break case uint32(113): /* fullname ::= nm */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0)) - if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && (*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) != 0) { - Xsqlite3RenameTokenMap(tls, pParse, (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */))+8 /* &.a */)+uintptr(0)*112)).FzName, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + 8 /* &.minor */ /* &.yy0 */), uintptr(0)) + if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && (*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) != 0) { + Xsqlite3RenameTokenMap(tls, pParse, (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + 8 /* &.a */))).FzName, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(114): /* fullname ::= nm DOT nm */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) - if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && (*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) != 0) { - Xsqlite3RenameTokenMap(tls, pParse, (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */))+8 /* &.a */)+uintptr(0)*112)).FzName, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */)) + if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && (*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) != 0) { + Xsqlite3RenameTokenMap(tls, pParse, (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + 8 /* &.a */))).FzName, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(115): /* xfullname ::= nm */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0)) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + 8 /* &.minor */ /* &.yy0 */), uintptr(0)) /*A-overwrites-X*/ } break case uint32(116): /* xfullname ::= nm DOT nm */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */)) /*A-overwrites-X*/ } break case uint32(117): /* xfullname ::= nm DOT nm AS nm */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */)) //A-overwrites-X if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) != 0 { - (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(0)*112)).FzAlias = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 8 /* &.a */))).FzAlias = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } } break @@ -139837,13 +137517,13 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0)) //A-overwrites-X if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) != 0 { - (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(0)*112)).FzAlias = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) + 8 /* &.a */))).FzAlias = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } } break case uint32(119): /* joinop ::= COMMA|JOIN */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 0x0001 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = JT_INNER } break case uint32(120): /* joinop ::= JOIN_KW JOIN */ @@ -139871,7 +137551,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(237): /* vinto ::= INTO expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(124): @@ -139888,12 +137568,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(238): /* vinto ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = uintptr(0) } break case uint32(126): /* indexed_opt ::= INDEXED BY nm */ { - *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(127): /* indexed_opt ::= NOT INDEXED */ @@ -139911,74 +137591,74 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // using_opt ::= case uint32(164): /* idlist_opt ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = uintptr(0) } break case uint32(131): fallthrough // orderby_opt ::= ORDER BY sortlist case uint32(141): /* groupby_opt ::= GROUP BY nexprlist */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(132): /* sortlist ::= sortlist COMMA expr sortorder nulls */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) - Xsqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(133): /* sortlist ::= expr sortorder nulls */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) //A-overwrites-Y - Xsqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(134): /* sortorder ::= ASC */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 0 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = SQLITE_SO_ASC } break case uint32(135): /* sortorder ::= DESC */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 1 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = SQLITE_SO_DESC } break case uint32(136): fallthrough // sortorder ::= case uint32(139): /* nulls ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = -1 + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = -1 } break case uint32(137): /* nulls ::= NULLS FIRST */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 0 + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = SQLITE_SO_ASC } break case uint32(138): /* nulls ::= NULLS LAST */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 1 + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = SQLITE_SO_DESC } break case uint32(145): /* limit_opt ::= LIMIT expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 146, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_LIMIT, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0)) } break case uint32(146): /* limit_opt ::= LIMIT expr OFFSET expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 146, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_LIMIT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(147): /* limit_opt ::= LIMIT expr COMMA expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 146, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_LIMIT, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) } break case uint32(148): /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ { Xsqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */)) - Xsqlite3DeleteFrom(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0)) + Xsqlite3DeleteFrom(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0), uintptr(0)) } break case uint32(151): /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt */ @@ -139986,35 +137666,35 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in Xsqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */)) Xsqlite3ExprListCheckLength(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), ts+20232 /* "set list" */) *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendList(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) - Xsqlite3Update(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3Update(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0)) } break case uint32(152): /* setlist ::= setlist COMMA nm EQ expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) Xsqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) } break case uint32(153): /* setlist ::= setlist COMMA LP idlist RP EQ expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppendVector(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppendVector(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(154): /* setlist ::= nm EQ expr */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) Xsqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(155): /* setlist ::= LP idlist RP EQ expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppendVector(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppendVector(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(156): /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ { - Xsqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(157): /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ @@ -140024,12 +137704,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(158): /* upsert ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = uintptr(0) } break case uint32(159): /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*24 + 8 /* &.minor */)) = Xsqlite3UpsertNew(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*24 + 8 /* &.minor */)) = Xsqlite3UpsertNew(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(160): /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ @@ -140049,12 +137729,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(166): /* idlist ::= idlist COMMA nm */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3IdListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3IdListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(167): /* idlist ::= nm */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = Xsqlite3IdListAppend(tls, pParse, uintptr(0), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) /*A-overwrites-Y*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = Xsqlite3IdListAppend(tls, pParse, uintptr(0), (yymsp + 8 /* &.minor */ /* &.yy0 */)) /*A-overwrites-Y*/ } break case uint32(168): /* expr ::= LP expr RP */ @@ -140066,32 +137746,32 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // expr ::= ID|INDEXED case uint32(170): /* expr ::= JOIN_KW */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = tokenExpr(tls, pParse, 59, *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = tokenExpr(tls, pParse, TK_ID, *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */))) /*A-overwrites-X*/ } break case uint32(171): /* expr ::= nm DOT nm */ { - var temp1 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 59, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) - var temp2 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 59, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 1) - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { - Xsqlite3RenameTokenMap(tls, pParse, temp2, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + var temp1 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ID, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + var temp2 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ID, (yymsp + 8 /* &.minor */ /* &.yy0 */), 1) + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { + Xsqlite3RenameTokenMap(tls, pParse, temp2, (yymsp + 8 /* &.minor */ /* &.yy0 */)) Xsqlite3RenameTokenMap(tls, pParse, temp1, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */)) } - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3PExpr(tls, pParse, 139, temp1, temp2) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3PExpr(tls, pParse, TK_DOT, temp1, temp2) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(172): /* expr ::= nm DOT nm DOT nm */ { - var temp1 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 59, (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), 1) - var temp2 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 59, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) - var temp3 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 59, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 1) - var temp4 uintptr = Xsqlite3PExpr(tls, pParse, 139, temp2, temp3) - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { - Xsqlite3RenameTokenMap(tls, pParse, temp3, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + var temp1 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ID, (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + var temp2 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ID, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + var temp3 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ID, (yymsp + 8 /* &.minor */ /* &.yy0 */), 1) + var temp4 uintptr = Xsqlite3PExpr(tls, pParse, TK_DOT, temp2, temp3) + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { + Xsqlite3RenameTokenMap(tls, pParse, temp3, (yymsp + 8 /* &.minor */ /* &.yy0 */)) Xsqlite3RenameTokenMap(tls, pParse, temp2, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */)) } - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3PExpr(tls, pParse, 139, temp1, temp4) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3PExpr(tls, pParse, TK_DOT, temp1, temp4) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break @@ -140099,34 +137779,34 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // term ::= NULL|FLOAT|BLOB case uint32(174): /* term ::= STRING */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = tokenExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+uintptr(0)*24)).Fmajor), *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = tokenExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor), *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */))) /*A-overwrites-X*/ } break case uint32(175): /* term ::= INTEGER */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 152, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_INTEGER, (yymsp + 8 /* &.minor */ /* &.yy0 */), 1) } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(176): /* expr ::= VARIABLE */ { - if !((int32(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz + uintptr(0)))) == '#') && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz + uintptr(1))))]) & 0x04) != 0)) { - var n U32 = (*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)).Fn - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = tokenExpr(tls, pParse, 153, *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) - Xsqlite3ExprAssignVarNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), n) + if !((int32(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)).Fz))) == '#') && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz + 1)))]) & 0x04) != 0)) { + var n U32 = (*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)).Fn + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = tokenExpr(tls, pParse, TK_VARIABLE, *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */))) + Xsqlite3ExprAssignVarNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), n) } else { // When doing a nested parse, one can include terms in an expression // that look like this: #1 #2 ... These terms refer to registers // in the virtual machine. #N is the N-th register. - *(*Token)(unsafe.Pointer(bp + 96 /* t */)) = *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) //A-overwrites-X + *(*Token)(unsafe.Pointer(bp + 96 /* t */)) = *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)) //A-overwrites-X if int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0 { Xsqlite3ErrorMsg(tls, pParse, ts+20241 /* "near \"%T\": synta..." */, libc.VaList(bp+16, bp+96 /* &t */)) - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = uintptr(0) } else { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 173, uintptr(0), uintptr(0)) - if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) != 0 { - Xsqlite3GetInt32(tls, ((*Token)(unsafe.Pointer(bp+96 /* &t */)).Fz + uintptr(1)), (*(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + 44 /* &.iTable */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_REGISTER, uintptr(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) != 0 { + Xsqlite3GetInt32(tls, ((*Token)(unsafe.Pointer(bp+96 /* &t */)).Fz + 1), (*(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) + 44 /* &.iTable */)) } } } @@ -140134,12 +137814,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(177): /* expr ::= expr COLLATE ID|STRING */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprAddCollateToken(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprAddCollateToken(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + 8 /* &.minor */ /* &.yy0 */), 1) } break case uint32(178): /* expr ::= CAST LP expr AS typetoken RP */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 36, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_CAST, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), 1) Xsqlite3ExprAttachSubtrees(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), uintptr(0)) } break @@ -140158,31 +137838,31 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in case uint32(181): /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ { *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */))) - Xsqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(182): /* expr ::= ID|INDEXED LP STAR RP filter_over */ { *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprFunction(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), 0) - Xsqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(183): /* term ::= CTIME_KW */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprFunction(tls, pParse, uintptr(0), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 0) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprFunction(tls, pParse, uintptr(0), (yymsp + 8 /* &.minor */ /* &.yy0 */), 0) } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(184): /* expr ::= LP nexprlist COMMA expr RP */ { var pList uintptr = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 174, uintptr(0), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_VECTOR, uintptr(0), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) != 0 { *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 32 /* &.x */)) = pList if (*ExprList)(unsafe.Pointer(pList)).FnExpr != 0 { - *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 4 /* &.flags */)) |= ((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(0)*32)).FpExpr)).Fflags & (U32((0x000100 | 0x200000) | 0x000004))) + *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 4 /* &.flags */)) |= ((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FpExpr)).Fflags & (U32((EP_Collate | EP_Subquery) | EP_HasFunc))) } } else { Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pList) @@ -140191,7 +137871,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(185): /* expr ::= expr AND expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(186): @@ -140208,12 +137888,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(192): /* expr ::= expr CONCAT expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(193): /* likeop ::= NOT LIKE_KW|MATCH */ { - *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)) *(*uint32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */ + 8 /* &.n */)) |= (0x80000000) /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/ } break @@ -140222,14 +137902,14 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in var pList uintptr var bNot int32 = (int32((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fn & 0x80000000)) *(*uint32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */ + 8 /* &.n */)) &= (uint32(0x7fffffff)) - pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprFunction(tls, pParse, pList, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), 0) if bNot != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), uintptr(0)) } if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) != 0 { - *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) + 4 /* &.flags */)) |= (U32(0x000080)) + *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) + 4 /* &.flags */)) |= (EP_InfixFunc) } } break @@ -140240,53 +137920,53 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in *(*uint32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */ + 8 /* &.n */)) &= (uint32(0x7fffffff)) pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) - pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprFunction(tls, pParse, pList, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), 0) if bNot != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) } if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) != 0 { - *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 4 /* &.flags */)) |= (U32(0x000080)) + *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 4 /* &.flags */)) |= (EP_InfixFunc) } } break case uint32(196): /* expr ::= expr ISNULL|NOTNULL */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+uintptr(0)*24)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0)) } break case uint32(197): /* expr ::= expr NOT NULL */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 51, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOTNULL, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), uintptr(0)) } break case uint32(198): /* expr ::= expr IS expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 45, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) - binaryToUnaryIfNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), 50) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_IS, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) + binaryToUnaryIfNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), TK_ISNULL) } break case uint32(199): /* expr ::= expr IS NOT expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 168, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) - binaryToUnaryIfNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), 51) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_ISNOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) + binaryToUnaryIfNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), TK_NOTNULL) } break case uint32(200): fallthrough // expr ::= NOT expr case uint32(201): /* expr ::= BITNOT expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) /*A-overwrites-B*/ + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0)) /*A-overwrites-B*/ } break case uint32(202): /* expr ::= PLUS|MINUS expr */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, func() int32 { - if int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24)).Fmajor) == 105 { - return 171 + if int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24)).Fmajor) == TK_PLUS { + return TK_UPLUS } - return 170 - }(), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) + return TK_UMINUS + }(), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0)) //A-overwrites-B } break @@ -140294,21 +137974,21 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // between_op ::= BETWEEN case uint32(206): /* in_op ::= IN */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 0 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = 0 } break case uint32(205): /* expr ::= expr between_op expr AND expr */ { var pList uintptr = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) - pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 48, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_BETWEEN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) != 0 { *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 32 /* &.x */)) = pList } else { Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pList) } if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) } } break @@ -140323,23 +138003,23 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in // simplify to constants 0 (false) and 1 (true), respectively, // regardless of the value of expr1. Xsqlite3ExprUnmapAndDelete(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 152, func() uintptr { + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_INTEGER, func() uintptr { if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { return ts + 6737 /* "1" */ } return ts + 6319 /* "0" */ }()) - } else if ((*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FnExpr == 1) && (Xsqlite3ExprIsConstant(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))+8 /* &.a */)+uintptr(0)*32)).FpExpr) != 0) { - var pRHS uintptr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(0)*32)).FpExpr - (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(0)*32)).FpExpr = uintptr(0) + } else if ((*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FnExpr == 1) && (Xsqlite3ExprIsConstant(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))+8 /* &.a */))).FpExpr) != 0) { + var pRHS uintptr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + 8 /* &.a */))).FpExpr + (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + 8 /* &.a */))).FpExpr = uintptr(0) Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) - pRHS = Xsqlite3PExpr(tls, pParse, 171, pRHS, uintptr(0)) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 53, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), pRHS) + pRHS = Xsqlite3PExpr(tls, pParse, TK_UPLUS, pRHS, uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_EQ, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), pRHS) if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) } } else { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 49, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_IN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) != 0 { *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 32 /* &.x */)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) Xsqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) @@ -140347,7 +138027,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) } } @@ -140355,17 +138035,17 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(209): /* expr ::= LP select RP */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 136, uintptr(0), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_SELECT, uintptr(0), uintptr(0)) Xsqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(210): /* expr ::= expr in_op LP select RP */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 49, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_IN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) Xsqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) } } @@ -140374,18 +138054,18 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in { var pSrc uintptr = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */)) var pSelect uintptr = Xsqlite3SelectNew(tls, pParse, uintptr(0), pSrc, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) - if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) != 0 { + if *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) != 0 { Xsqlite3SrcListFuncArgs(tls, pParse, func() uintptr { if pSelect != 0 { return pSrc } return uintptr(0) - }(), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + }(), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 49, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_IN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) Xsqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), pSelect) if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) } } @@ -140393,14 +138073,14 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in case uint32(212): /* expr ::= EXISTS LP select RP */ { var p uintptr - p = libc.AssignPtrUintptr(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */ /* &.yy202 */, Xsqlite3PExpr(tls, pParse, 20, uintptr(0), uintptr(0))) + p = libc.AssignPtrUintptr(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */ /* &.yy202 */, Xsqlite3PExpr(tls, pParse, TK_EXISTS, uintptr(0), uintptr(0))) Xsqlite3PExprAddSelect(tls, pParse, p, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(213): /* expr ::= CASE case_operand case_exprlist case_else END */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 154, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_CASE, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) != 0 { *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 32 /* &.x */)) = func() uintptr { if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) != 0 { @@ -140418,28 +138098,28 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in case uint32(214): /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(215): /* case_exprlist ::= WHEN expr THEN expr */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(218): /* case_operand ::= expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) /*A-overwrites-X*/ } break case uint32(221): /* nexprlist ::= nexprlist COMMA expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(222): /* nexprlist ::= expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) /*A-overwrites-Y*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) /*A-overwrites-Y*/ } break case uint32(224): @@ -140453,8 +138133,8 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in { Xsqlite3CreateIndex(tls, pParse, (yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp+libc.UintptrFromInt32(-4)*24+8 /* &.minor */ /* &.yy0 */), uintptr(0)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*24 + 8 /* &.minor */)), - (yymsp + libc.UintptrFromInt32(-11)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), 0, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)), uint8(0)) - if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && ((*Parse)(unsafe.Pointer(pParse)).FpNewIndex != 0) { + (yymsp + libc.UintptrFromInt32(-11)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), SQLITE_SO_ASC, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)), SQLITE_IDXTYPE_APPDEF) + if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && ((*Parse)(unsafe.Pointer(pParse)).FpNewIndex != 0) { Xsqlite3RenameTokenMap(tls, pParse, (*Index)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).FpNewIndex)).FzName, (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */)) } } @@ -140463,47 +138143,47 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // uniqueflag ::= UNIQUE case uint32(268): /* raisetype ::= ABORT */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 2 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Abort } break case uint32(227): /* uniqueflag ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = 0 + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = OE_None } break case uint32(230): /* eidlist ::= eidlist COMMA nm collate sortorder */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = parserAddExprIdListTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = parserAddExprIdListTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(231): /* eidlist ::= nm collate sortorder */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = parserAddExprIdListTerm(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) //A-overwrites-Y + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = parserAddExprIdListTerm(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) //A-overwrites-Y } break case uint32(234): /* cmd ::= DROP INDEX ifexists fullname */ { - Xsqlite3DropIndex(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) + Xsqlite3DropIndex(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(235): /* cmd ::= VACUUM vinto */ { - Xsqlite3Vacuum(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3Vacuum(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(236): /* cmd ::= VACUUM nm vinto */ { - Xsqlite3Vacuum(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3Vacuum(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(239): /* cmd ::= PRAGMA nm dbnm */ { - Xsqlite3Pragma(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), 0) + Xsqlite3Pragma(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */), uintptr(0), 0) } break case uint32(240): /* cmd ::= PRAGMA nm dbnm EQ nmnum */ { - Xsqlite3Pragma(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 0) + Xsqlite3Pragma(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */), 0) } break case uint32(241): /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ @@ -140513,7 +138193,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(242): /* cmd ::= PRAGMA nm dbnm EQ minus_num */ { - Xsqlite3Pragma(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + Xsqlite3Pragma(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */), 1) } break case uint32(243): /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ @@ -140526,13 +138206,13 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in // var all Token at bp+112, 16 (*Token)(unsafe.Pointer(bp + 112 /* &all */)).Fz = (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)).Fz - (*Token)(unsafe.Pointer(bp + 112 /* &all */)).Fn = (uint32((int32((int64((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).Fz)) / 1))) + (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn) + (*Token)(unsafe.Pointer(bp + 112 /* &all */)).Fn = (uint32((int32((int64((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).Fz)) / 1))) + (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn) Xsqlite3FinishTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), bp+112 /* &all */) } break case uint32(247): /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ { - Xsqlite3BeginTrigger(tls, pParse, (yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (*TrigEvent)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-4)*24+8 /* &.minor */)).Fa, (*TrigEvent)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-4)*24+8 /* &.minor */)).Fb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */))) + Xsqlite3BeginTrigger(tls, pParse, (yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (*TrigEvent)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-4)*24+8 /* &.minor */)).Fa, (*TrigEvent)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-4)*24+8 /* &.minor */)).Fb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */))) *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*24 + 8 /* &.minor */)) = func() Token1 { if (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-6)*24+8 /* &.minor */)).Fn == uint32(0) { return *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)) @@ -140543,45 +138223,45 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(248): /* trigger_time ::= BEFORE|AFTER */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp + uintptr(0)*24)).Fmajor) /*A-overwrites-X*/ + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor) /*A-overwrites-X*/ } break case uint32(249): /* trigger_time ::= INSTEAD OF */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 65 + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = TK_INSTEAD } break case uint32(250): /* trigger_time ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = 33 + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = TK_BEFORE } break case uint32(251): fallthrough // trigger_event ::= DELETE|INSERT case uint32(252): /* trigger_event ::= UPDATE */ { - (*TrigEvent)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)).Fa = int32((*YyStackEntry)(unsafe.Pointer(yymsp + uintptr(0)*24)).Fmajor) /*A-overwrites-X*/ - (*TrigEvent)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)).Fb = uintptr(0) + (*TrigEvent)(unsafe.Pointer(yymsp + 8 /* &.minor */)).Fa = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor) /*A-overwrites-X*/ + (*TrigEvent)(unsafe.Pointer(yymsp + 8 /* &.minor */)).Fb = uintptr(0) } break case uint32(253): /* trigger_event ::= UPDATE OF idlist */ { - (*TrigEvent)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)).Fa = 127 - (*TrigEvent)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)).Fb = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + (*TrigEvent)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)).Fa = TK_UPDATE + (*TrigEvent)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)).Fb = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(254): fallthrough // when_clause ::= case uint32(273): /* key_opt ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = uintptr(0) } break case uint32(255): fallthrough // when_clause ::= WHEN expr case uint32(274): /* key_opt ::= KEY expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(256): /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ @@ -140599,7 +138279,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(258): /* trnm ::= nm DOT nm */ { - *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)) Xsqlite3ErrorMsg(tls, pParse, ts+20265 /* "qualified table ..." */, 0) @@ -140621,39 +138301,39 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(261): /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerUpdateStep(tls, pParse, (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uint8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */))), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-8)*24+8 /* &.minor */)).Fz, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerUpdateStep(tls, pParse, (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uint8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */))), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-8)*24+8 /* &.minor */)).Fz, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(262): /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerInsertStep(tls, pParse, (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), uint8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */))), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) //yylhsminor.yy447-overwrites-yymsp[-6].minor.yy192 + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerInsertStep(tls, pParse, (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), uint8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */))), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) //yylhsminor.yy447-overwrites-yymsp[-6].minor.yy192 } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(263): /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerDeleteStep(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-5)*24+8 /* &.minor */)).Fz, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerDeleteStep(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-5)*24+8 /* &.minor */)).Fz, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(264): /* trigger_cmd ::= scanpt select scanpt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerSelectStep(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) /*yylhsminor.yy447-overwrites-yymsp[-1].minor.yy539*/ + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerSelectStep(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) /*yylhsminor.yy447-overwrites-yymsp[-1].minor.yy539*/ } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(265): /* expr ::= RAISE LP IGNORE RP */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 71, uintptr(0), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_RAISE, uintptr(0), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { - (*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)))).FaffExpr = int8(4) + (*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)))).FaffExpr = OE_Ignore } } break case uint32(266): /* expr ::= RAISE LP raisetype COMMA nm RP */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 71, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_RAISE, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), 1) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) != 0 { (*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)))).FaffExpr = int8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */))) } @@ -140661,27 +138341,27 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(267): /* raisetype ::= ROLLBACK */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 1 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Rollback } break case uint32(269): /* raisetype ::= FAIL */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 3 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Fail } break case uint32(270): /* cmd ::= DROP TRIGGER ifexists fullname */ { - Xsqlite3DropTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) + Xsqlite3DropTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(271): /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ { - Xsqlite3Attach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3Attach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(272): /* cmd ::= DETACH database_kw_opt expr */ { - Xsqlite3Detach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3Detach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(275): /* cmd ::= REINDEX */ @@ -140691,7 +138371,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(276): /* cmd ::= REINDEX nm dbnm */ { - Xsqlite3Reindex(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3Reindex(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(277): /* cmd ::= ANALYZE */ @@ -140701,12 +138381,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(278): /* cmd ::= ANALYZE nm dbnm */ { - Xsqlite3Analyze(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3Analyze(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(279): /* cmd ::= ALTER TABLE fullname RENAME TO nm */ { - Xsqlite3AlterRenameTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3AlterRenameTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(280): /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ @@ -140718,12 +138398,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in case uint32(281): /* add_column_fullname ::= fullname */ { disableLookaside(tls, pParse) - Xsqlite3AlterBeginAddColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3AlterBeginAddColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(282): /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ { - Xsqlite3AlterRenameColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3AlterRenameColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(283): /* cmd ::= create_vtab */ @@ -140733,12 +138413,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(284): /* cmd ::= create_vtab LP vtabarglist RP */ { - Xsqlite3VtabFinishParse(tls, pParse, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3VtabFinishParse(tls, pParse, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(285): /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ { - Xsqlite3VtabBeginParse(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) + Xsqlite3VtabBeginParse(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) } break case uint32(286): /* vtabarg ::= */ @@ -140752,14 +138432,14 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(289): /* lp ::= LP */ { - Xsqlite3VtabArgExtend(tls, pParse, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3VtabArgExtend(tls, pParse, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(290): fallthrough // with ::= WITH wqlist case uint32(291): /* with ::= WITH RECURSIVE wqlist */ { - Xsqlite3WithPush(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uint8(1)) + Xsqlite3WithPush(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uint8(1)) } break case uint32(292): /* wqlist ::= nm eidlist_opt AS LP select RP */ @@ -140774,16 +138454,16 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(294): /* windowdefn_list ::= windowdefn */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(295): /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ { - Xsqlite3WindowChain(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) - (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)))).FpNextWin = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + Xsqlite3WindowChain(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) + (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)))).FpNextWin = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break @@ -140798,23 +138478,23 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(297): /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0)) } break case uint32(298): /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */ /* &.yy0 */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */ /* &.yy0 */)) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(299): /* window ::= ORDER BY sortlist frame_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0)) } break case uint32(300): /* window ::= nm ORDER BY sortlist frame_opt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */)) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break @@ -140822,30 +138502,30 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // window ::= frame_opt case uint32(320): /* filter_over ::= over_clause */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(302): /* window ::= nm frame_opt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */)) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(303): /* frame_opt ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = Xsqlite3WindowAlloc(tls, pParse, 0, 90, uintptr(0), 85, uintptr(0), uint8(0)) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = Xsqlite3WindowAlloc(tls, pParse, 0, TK_UNBOUNDED, uintptr(0), TK_CURRENT, uintptr(0), uint8(0)) } break case uint32(304): /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FpExpr, 85, uintptr(0), *(*U8)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FpExpr, TK_CURRENT, uintptr(0), *(*U8)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(305): /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).FpExpr, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FpExpr, *(*U8)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).FpExpr, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FpExpr, *(*U8)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break @@ -140853,9 +138533,9 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // frame_bound_s ::= frame_bound case uint32(309): /* frame_bound_e ::= frame_bound */ { - *(*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*FrameBound)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*FrameBound)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } - *(*FrameBound)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*FrameBound)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(308): fallthrough // frame_bound_s ::= UNBOUNDED PRECEDING @@ -140870,19 +138550,19 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(311): /* frame_bound ::= expr PRECEDING|FOLLOWING */ { - (*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)).FeType = int32((*YyStackEntry)(unsafe.Pointer(yymsp + uintptr(0)*24)).Fmajor) + (*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)).FeType = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor) (*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)).FpExpr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) } *(*FrameBound)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(313): /* frame_exclude_opt ::= */ { - *(*U8)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = U8(0) + *(*U8)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = U8(0) } break case uint32(314): /* frame_exclude_opt ::= EXCLUDE frame_exclude */ { - *(*U8)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*U8)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*U8)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*U8)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(315): @@ -140894,18 +138574,18 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(317): /* frame_exclude ::= GROUP|TIES */ { - *(*U8)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = U8((*YyStackEntry)(unsafe.Pointer(yymsp + uintptr(0)*24)).Fmajor) /*A-overwrites-X*/ + *(*U8)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = U8((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor) /*A-overwrites-X*/ } break case uint32(318): /* window_clause ::= WINDOW windowdefn_list */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(319): /* filter_over ::= filter_clause over_clause */ { - (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break @@ -140913,13 +138593,13 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in { *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(Window{}))) if *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) != 0 { - (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)))).FeFrmType = U8(163) - (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)))).FeFrmType = TK_FILTER + (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } else { - Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(322): /* over_clause ::= OVER LP window RP */ { @@ -140931,7 +138611,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(Window{}))) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) != 0 { - (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FzName = Xsqlite3DbStrNDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz, uint64((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn)) + (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FzName = Xsqlite3DbStrNDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz, uint64((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn)) } } break @@ -141034,7 +138714,7 @@ func yy_syntax_error(tls *libc.TLS, yypParser uintptr, yymajor int32, yyminor To //*********** Begin %syntax_error code *************************************** _ = yymajor // Silence some compiler warnings - if *(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(bp+8 /* &yyminor */)).Fz + uintptr(0))) != 0 { + if *(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(bp + 8 /* &yyminor */)).Fz)) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+20241 /* "near \"%T\": synta..." */, libc.VaList(bp, bp+8 /* &yyminor */)) } else { Xsqlite3ErrorMsg(tls, pParse, ts+20529 /* "incomplete input" */, 0) @@ -141090,13 +138770,13 @@ func Xsqlite3Parser(tls *libc.TLS, yyp uintptr, yymajor int32, yyminor Token) { for ok := true; ok; ok = ((*YyParser)(unsafe.Pointer(yypParser)).Fyytos > yypParser+16 /* &.yystack */) { yyact = yy_find_shift_action(tls, uint16(yymajor), yyact) - if int32(yyact) >= 1191 { - yyact = yy_reduce(tls, yypParser, (uint32(int32(yyact) - 1191)), yymajor, + if int32(yyact) >= YY_MIN_REDUCE { + yyact = yy_reduce(tls, yypParser, (uint32(int32(yyact) - YY_MIN_REDUCE)), yymajor, yyminor, pParse) - } else if int32(yyact) <= 1187 { + } else if int32(yyact) <= YY_MAX_SHIFTREDUCE { yy_shift(tls, yypParser, yyact, uint16(yymajor), yyminor) break - } else if int32(yyact) == 1189 { + } else if int32(yyact) == YY_ACCEPT_ACTION { (*YyParser)(unsafe.Pointer(yypParser)).Fyytos -= 24 yy_accept(tls, yypParser) return @@ -141318,35 +138998,35 @@ var aKWOffset = [145]uint16{ } /* sqlite3.c:159521:33 */ // aKWCode[i] is the parser symbol code for the i-th keyword var aKWCode = [145]uint8{ - uint8(97), uint8(114), uint8(158), uint8(39), uint8(58), - uint8(41), uint8(122), uint8(67), uint8(33), uint8(130), - uint8(62), uint8(63), uint8(47), uint8(2), uint8(65), - uint8(160), uint8(38), uint8(24), uint8(136), uint8(16), - uint8(116), uint8(156), uint8(11), uint8(129), uint8(157), - uint8(91), uint8(126), uint8(21), uint8(21), uint8(43), - uint8(50), uint8(82), uint8(13), uint8(135), uint8(94), - uint8(51), uint8(19), uint8(66), uint8(119), uint8(47), - uint8(134), uint8(6), uint8(28), uint8(113), uint8(116), - uint8(159), uint8(71), uint8(9), uint8(20), uint8(117), - uint8(148), uint8(69), uint8(68), uint8(128), uint8(77), - uint8(89), uint8(95), uint8(40), uint8(145), uint8(47), - uint8(5), uint8(116), uint8(123), uint8(121), uint8(3), - uint8(25), uint8(81), uint8(116), uint8(14), uint8(32), - uint8(48), uint8(149), uint8(92), uint8(144), uint8(35), - uint8(31), uint8(118), uint8(154), uint8(111), uint8(17), - uint8(99), uint8(8), uint8(141), uint8(125), uint8(46), - uint8(4), uint8(30), uint8(70), uint8(27), uint8(127), - uint8(137), uint8(80), uint8(96), uint8(155), uint8(147), - uint8(72), uint8(29), uint8(98), uint8(44), uint8(7), - uint8(138), uint8(45), uint8(124), uint8(15), uint8(49), - uint8(36), uint8(60), uint8(10), uint8(37), uint8(116), - uint8(99), uint8(99), uint8(85), uint8(87), uint8(131), - uint8(88), uint8(42), uint8(84), uint8(163), uint8(73), - uint8(83), uint8(86), uint8(140), uint8(116), uint8(146), - uint8(18), uint8(143), uint8(74), uint8(93), uint8(162), - uint8(116), uint8(12), uint8(76), uint8(75), uint8(90), - uint8(132), uint8(142), uint8(78), uint8(79), uint8(161), - uint8(61), uint8(34), uint8(64), uint8(133), uint8(120), + TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE, + TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN, + TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD, + TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE, + TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE, + TK_EXCLUDE, TK_DELETE, TK_TEMP, TK_TEMP, TK_OR, + TK_ISNULL, TK_NULLS, TK_SAVEPOINT, TK_INTERSECT, TK_TIES, + TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW, + TK_EXCEPT, TK_TRANSACTION, TK_ACTION, TK_ON, TK_JOIN_KW, + TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_CONSTRAINT, + TK_INTO, TK_OFFSET, TK_OF, TK_SET, TK_TRIGGER, + TK_RANGE, TK_GENERATED, TK_DETACH, TK_HAVING, TK_LIKE_KW, + TK_BEGIN, TK_JOIN_KW, TK_REFERENCES, TK_UNIQUE, TK_QUERY, + TK_WITHOUT, TK_WITH, TK_JOIN_KW, TK_RELEASE, TK_ATTACH, + TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP, TK_CASCADE, + TK_ASC, TK_DEFAULT, TK_CASE, TK_COLLATE, TK_CREATE, + TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_MATCH, + TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT, TK_UPDATE, + TK_VALUES, TK_VIRTUAL, TK_ALWAYS, TK_WHEN, TK_WHERE, + TK_RECURSIVE, TK_AFTER, TK_RENAME, TK_AND, TK_DEFERRED, + TK_DISTINCT, TK_IS, TK_AUTOINCR, TK_TO, TK_IN, + TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, + TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT, TK_PARTITION, TK_DROP, + TK_PRECEDING, TK_FAIL, TK_LAST, TK_FILTER, TK_REPLACE, + TK_FIRST, TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_LIMIT, + TK_IF, TK_ORDER, TK_RESTRICT, TK_OTHERS, TK_OVER, + TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNBOUNDED, + TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_WINDOW, + TK_DO, TK_BY, TK_INITIALLY, TK_ALL, TK_PRIMARY, } /* sqlite3.c:159536:28 */ // Hash table decoded: @@ -141485,20 +139165,20 @@ func keywordCode(tls *libc.TLS, z uintptr, n int32, pType uintptr) int32 { /* sq var j int32 var zKW uintptr if n >= 2 { - i = ((((int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(z + uintptr(0))))]) * 4) ^ (int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(z + uintptr((n - 1)))))]) * 3)) ^ n) % 127) + i = ((((int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(z)))]) * 4) ^ (int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(z + uintptr((n - 1)))))]) * 3)) ^ n) % 127) for i = ((int32(aKWHash[i])) - 1); i >= 0; i = ((int32(aKWNext[i])) - 1) { if int32(aKWLen[i]) != n { continue } zKW = (uintptr(unsafe.Pointer(&zKWText)) + uintptr(aKWOffset[i])) - if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) & ^libc.Int32(0x20)) != int32(*(*int8)(unsafe.Pointer(zKW + uintptr(0)))) { + if (int32(*(*int8)(unsafe.Pointer(z))) & libc.CplInt32(0x20)) != int32(*(*int8)(unsafe.Pointer(zKW))) { continue } - if (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) & ^libc.Int32(0x20)) != int32(*(*int8)(unsafe.Pointer(zKW + uintptr(1)))) { + if (int32(*(*int8)(unsafe.Pointer(z + 1))) & libc.CplInt32(0x20)) != int32(*(*int8)(unsafe.Pointer(zKW + 1))) { continue } j = 2 - for (j < n) && ((int32(*(*int8)(unsafe.Pointer(z + uintptr(j)))) & ^libc.Int32(0x20)) == int32(*(*int8)(unsafe.Pointer(zKW + uintptr(j))))) { + for (j < n) && ((int32(*(*int8)(unsafe.Pointer(z + uintptr(j)))) & libc.CplInt32(0x20)) == int32(*(*int8)(unsafe.Pointer(zKW + uintptr(j))))) { j++ } if j < n { @@ -141660,26 +139340,26 @@ func Xsqlite3KeywordCode(tls *libc.TLS, z uintptr, n int32) int32 { /* sqlite3.c bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* id */)) = 59 + *(*int32)(unsafe.Pointer(bp /* id */)) = TK_ID keywordCode(tls, z, n, bp /* &id */) return *(*int32)(unsafe.Pointer(bp /* id */)) } func Xsqlite3_keyword_name(tls *libc.TLS, i int32, pzName uintptr, pnName uintptr) int32 { /* sqlite3.c:159877:16: */ - if (i < 0) || (i >= 145) { - return 1 + if (i < 0) || (i >= SQLITE_N_KEYWORD) { + return SQLITE_ERROR } *(*uintptr)(unsafe.Pointer(pzName)) = (uintptr(unsafe.Pointer(&zKWText)) + uintptr(aKWOffset[i])) *(*int32)(unsafe.Pointer(pnName)) = int32(aKWLen[i]) - return 0 + return SQLITE_OK } func Xsqlite3_keyword_count(tls *libc.TLS) int32 { /* sqlite3.c:159883:16: */ - return 145 + return SQLITE_N_KEYWORD } func Xsqlite3_keyword_check(tls *libc.TLS, zName uintptr, nName int32) int32 { /* sqlite3.c:159884:16: */ - return (libc.Bool32(59 != Xsqlite3KeywordCode(tls, zName, nName))) + return (libc.Bool32(TK_ID != Xsqlite3KeywordCode(tls, zName, nName))) } //************* End of keywordhash.h **************************************** @@ -141714,16 +139394,16 @@ func getToken(tls *libc.TLS, pz uintptr) int32 { /* sqlite3.c:159938:12: */ var z uintptr = *(*uintptr)(unsafe.Pointer(pz)) // var t int32 at bp, 4 // Token type to return - for ok := true; ok; ok = (*(*int32)(unsafe.Pointer(bp /* t */)) == 179) { + for ok := true; ok; ok = (*(*int32)(unsafe.Pointer(bp /* t */)) == TK_SPACE) { z += uintptr(Xsqlite3GetToken(tls, z, bp /* &t */)) } - if (((((*(*int32)(unsafe.Pointer(bp /* t */)) == 59) || - (*(*int32)(unsafe.Pointer(bp /* t */)) == 115)) || - (*(*int32)(unsafe.Pointer(bp /* t */)) == 116)) || - (*(*int32)(unsafe.Pointer(bp /* t */)) == 161)) || - (*(*int32)(unsafe.Pointer(bp /* t */)) == 162)) || - (Xsqlite3ParserFallback(tls, *(*int32)(unsafe.Pointer(bp /* t */))) == 59) { - *(*int32)(unsafe.Pointer(bp /* t */)) = 59 + if (((((*(*int32)(unsafe.Pointer(bp /* t */)) == TK_ID) || + (*(*int32)(unsafe.Pointer(bp /* t */)) == TK_STRING)) || + (*(*int32)(unsafe.Pointer(bp /* t */)) == TK_JOIN_KW)) || + (*(*int32)(unsafe.Pointer(bp /* t */)) == TK_WINDOW)) || + (*(*int32)(unsafe.Pointer(bp /* t */)) == TK_OVER)) || + (Xsqlite3ParserFallback(tls, *(*int32)(unsafe.Pointer(bp /* t */))) == TK_ID) { + *(*int32)(unsafe.Pointer(bp /* t */)) = TK_ID } *(*uintptr)(unsafe.Pointer(pz)) = z return *(*int32)(unsafe.Pointer(bp /* t */)) @@ -141764,14 +139444,14 @@ func analyzeWindowKeyword(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:159987: var t int32 t = getToken(tls, bp /* &z */) - if t != 59 { - return 59 + if t != TK_ID { + return TK_ID } t = getToken(tls, bp /* &z */) - if t != 24 { - return 59 + if t != TK_AS { + return TK_ID } - return 161 + return TK_WINDOW } func analyzeOverKeyword(tls *libc.TLS, z uintptr, lastToken int32) int32 { /* sqlite3.c:159995:12: */ @@ -141779,13 +139459,13 @@ func analyzeOverKeyword(tls *libc.TLS, z uintptr, lastToken int32) int32 { /* sq defer tls.Free(8) *(*uintptr)(unsafe.Pointer(bp)) = z - if lastToken == 23 { + if lastToken == TK_RP { var t int32 = getToken(tls, bp /* &z */) - if (t == 22) || (t == 59) { - return 162 + if (t == TK_LP) || (t == TK_ID) { + return TK_OVER } } - return 59 + return TK_ID } func analyzeFilterKeyword(tls *libc.TLS, z uintptr, lastToken int32) int32 { /* sqlite3.c:160002:12: */ @@ -141793,10 +139473,10 @@ func analyzeFilterKeyword(tls *libc.TLS, z uintptr, lastToken int32) int32 { /* defer tls.Free(8) *(*uintptr)(unsafe.Pointer(bp)) = z - if (lastToken == 23) && (getToken(tls, bp /* &z */) == 22) { - return 163 + if (lastToken == TK_RP) && (getToken(tls, bp /* &z */) == TK_LP) { + return TK_FILTER } - return 59 + return TK_ID } // Return the length (in bytes) of the token that begins at z[0]. @@ -141807,164 +139487,164 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq switch int32(aiClass[*(*uint8)(unsafe.Pointer(z))]) { // Switch on the character-class of the first byte // of the token. See the comment on the CC_ defines // above. - case 7: + case CC_SPACE: { for i = 1; (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x01) != 0; i++ { } - *(*int32)(unsafe.Pointer(tokenType)) = 179 + *(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE return i } - case 11: + case CC_MINUS: { - if int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == '-' { + if int32(*(*uint8)(unsafe.Pointer(z + 1))) == '-' { for i = 2; ((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0) && (c != '\n'); i++ { } - *(*int32)(unsafe.Pointer(tokenType)) = 179 // IMP: R-22934-25134 + *(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE // IMP: R-22934-25134 return i } - *(*int32)(unsafe.Pointer(tokenType)) = 106 + *(*int32)(unsafe.Pointer(tokenType)) = TK_MINUS return 1 } - case 17: + case CC_LP: { - *(*int32)(unsafe.Pointer(tokenType)) = 22 + *(*int32)(unsafe.Pointer(tokenType)) = TK_LP return 1 } - case 18: + case CC_RP: { - *(*int32)(unsafe.Pointer(tokenType)) = 23 + *(*int32)(unsafe.Pointer(tokenType)) = TK_RP return 1 } - case 19: + case CC_SEMI: { - *(*int32)(unsafe.Pointer(tokenType)) = 1 + *(*int32)(unsafe.Pointer(tokenType)) = TK_SEMI return 1 } - case 20: + case CC_PLUS: { - *(*int32)(unsafe.Pointer(tokenType)) = 105 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PLUS return 1 } - case 21: + case CC_STAR: { - *(*int32)(unsafe.Pointer(tokenType)) = 107 + *(*int32)(unsafe.Pointer(tokenType)) = TK_STAR return 1 } - case 16: + case CC_SLASH: { - if (int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) != '*') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(2)))) == 0) { - *(*int32)(unsafe.Pointer(tokenType)) = 108 + if (int32(*(*uint8)(unsafe.Pointer(z + 1))) != '*') || (int32(*(*uint8)(unsafe.Pointer(z + 2))) == 0) { + *(*int32)(unsafe.Pointer(tokenType)) = TK_SLASH return 1 } i = 3 - c = int32(*(*uint8)(unsafe.Pointer(z + uintptr(2)))) + c = int32(*(*uint8)(unsafe.Pointer(z + 2))) for ; ((c != '*') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '/')) && ((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0); i++ { } if c != 0 { i++ } - *(*int32)(unsafe.Pointer(tokenType)) = 179 // IMP: R-22934-25134 + *(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE // IMP: R-22934-25134 return i } - case 22: + case CC_PERCENT: { - *(*int32)(unsafe.Pointer(tokenType)) = 109 + *(*int32)(unsafe.Pointer(tokenType)) = TK_REM return 1 } - case 14: + case CC_EQ: { - *(*int32)(unsafe.Pointer(tokenType)) = 53 - return (1 + (libc.Bool32(int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == '='))) + *(*int32)(unsafe.Pointer(tokenType)) = TK_EQ + return (1 + (libc.Bool32(int32(*(*uint8)(unsafe.Pointer(z + 1))) == '='))) } - case 12: + case CC_LT: { - if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))))) == '=' { - *(*int32)(unsafe.Pointer(tokenType)) = 55 + if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + 1))))) == '=' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_LE return 2 } else if c == '>' { - *(*int32)(unsafe.Pointer(tokenType)) = 52 + *(*int32)(unsafe.Pointer(tokenType)) = TK_NE return 2 } else if c == '<' { - *(*int32)(unsafe.Pointer(tokenType)) = 103 + *(*int32)(unsafe.Pointer(tokenType)) = TK_LSHIFT return 2 } else { - *(*int32)(unsafe.Pointer(tokenType)) = 56 + *(*int32)(unsafe.Pointer(tokenType)) = TK_LT return 1 } } fallthrough - case 13: + case CC_GT: { - if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))))) == '=' { - *(*int32)(unsafe.Pointer(tokenType)) = 57 + if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + 1))))) == '=' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_GE return 2 } else if c == '>' { - *(*int32)(unsafe.Pointer(tokenType)) = 104 + *(*int32)(unsafe.Pointer(tokenType)) = TK_RSHIFT return 2 } else { - *(*int32)(unsafe.Pointer(tokenType)) = 54 + *(*int32)(unsafe.Pointer(tokenType)) = TK_GT return 1 } } fallthrough - case 15: + case CC_BANG: { - if int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) != '=' { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + if int32(*(*uint8)(unsafe.Pointer(z + 1))) != '=' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL return 1 } else { - *(*int32)(unsafe.Pointer(tokenType)) = 52 + *(*int32)(unsafe.Pointer(tokenType)) = TK_NE return 2 } } fallthrough - case 10: + case CC_PIPE: { - if int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) != '|' { - *(*int32)(unsafe.Pointer(tokenType)) = 102 + if int32(*(*uint8)(unsafe.Pointer(z + 1))) != '|' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_BITOR return 1 } else { - *(*int32)(unsafe.Pointer(tokenType)) = 110 + *(*int32)(unsafe.Pointer(tokenType)) = TK_CONCAT return 2 } } fallthrough - case 23: + case CC_COMMA: { - *(*int32)(unsafe.Pointer(tokenType)) = 26 + *(*int32)(unsafe.Pointer(tokenType)) = TK_COMMA return 1 } - case 24: + case CC_AND: { - *(*int32)(unsafe.Pointer(tokenType)) = 101 + *(*int32)(unsafe.Pointer(tokenType)) = TK_BITAND return 1 } - case 25: + case CC_TILDA: { - *(*int32)(unsafe.Pointer(tokenType)) = 112 + *(*int32)(unsafe.Pointer(tokenType)) = TK_BITNOT return 1 } - case 8: + case CC_QUOTE: { - var delim int32 = int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) + var delim int32 = int32(*(*uint8)(unsafe.Pointer(z))) for i = 1; (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0; i++ { if c == delim { @@ -141976,35 +139656,32 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq } } if c == '\'' { - *(*int32)(unsafe.Pointer(tokenType)) = 115 + *(*int32)(unsafe.Pointer(tokenType)) = TK_STRING return (i + 1) } else if c != 0 { - *(*int32)(unsafe.Pointer(tokenType)) = 59 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ID return (i + 1) } else { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL return i } } fallthrough - case 26: + case CC_DOT: { - if !((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(1)))]) & 0x04) != 0) { - *(*int32)(unsafe.Pointer(tokenType)) = 139 + if !((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + 1))]) & 0x04) != 0) { + *(*int32)(unsafe.Pointer(tokenType)) = TK_DOT return 1 } - // If the next character is a digit, this is a floating point - // number that begins with ".". Fall thru into the next case - /* no break */ } fallthrough - case 3: + case CC_DIGIT: { - *(*int32)(unsafe.Pointer(tokenType)) = 152 - if ((int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) == '0') && ((int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == 'x') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == 'X'))) && ((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(2)))]) & 0x08) != 0) { + *(*int32)(unsafe.Pointer(tokenType)) = TK_INTEGER + if ((int32(*(*uint8)(unsafe.Pointer(z))) == '0') && ((int32(*(*uint8)(unsafe.Pointer(z + 1))) == 'x') || (int32(*(*uint8)(unsafe.Pointer(z + 1))) == 'X'))) && ((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + 2))]) & 0x08) != 0) { for i = 3; (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x08) != 0; i++ { } return i @@ -142016,7 +139693,7 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq for (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0 { i++ } - *(*int32)(unsafe.Pointer(tokenType)) = 150 + *(*int32)(unsafe.Pointer(tokenType)) = TK_FLOAT } if ((int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == 'e') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == 'E')) && (((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))]) & 0x04) != 0) || (((int32(*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))) == '+') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))) == '-')) && ((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr((i + 2))))]) & 0x04) != 0))) { @@ -142024,45 +139701,45 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq for (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0 { i++ } - *(*int32)(unsafe.Pointer(tokenType)) = 150 + *(*int32)(unsafe.Pointer(tokenType)) = TK_FLOAT } for (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x46) != 0 { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL i++ } return i } - case 9: + case CC_QUOTE2: { i = 1 - c = int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) + c = int32(*(*uint8)(unsafe.Pointer(z))) for ; (c != ']') && ((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0); i++ { } *(*int32)(unsafe.Pointer(tokenType)) = func() int32 { if c == ']' { - return 59 + return TK_ID } - return 180 + return TK_ILLEGAL }() return i } - case 6: + case CC_VARNUM: { - *(*int32)(unsafe.Pointer(tokenType)) = 153 + *(*int32)(unsafe.Pointer(tokenType)) = TK_VARIABLE for i = 1; (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0; i++ { } return i } - case 4: + case CC_DOLLAR: fallthrough - case 5: + case CC_VARALPHA: { var n int32 = 0 - *(*int32)(unsafe.Pointer(tokenType)) = 153 + *(*int32)(unsafe.Pointer(tokenType)) = TK_VARIABLE for i = 1; (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0; i++ { if (int32(Xsqlite3CtypeMap[uint8(c)]) & 0x46) != 0 { n++ @@ -142073,7 +139750,7 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq if c == ')' { i++ } else { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL } break } else if (c == ':') && (int32(*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))) == ':') { @@ -142083,14 +139760,14 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq } } if n == 0 { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL } return i } - case 1: + case CC_KYWD: { - for i = 1; int32(aiClass[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) <= 1; i++ { + for i = 1; int32(aiClass[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) <= CC_KYWD; i++ { } if (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x46) != 0 { // This token started out using characters that can appear in keywords, @@ -142099,19 +139776,19 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq i++ break } - *(*int32)(unsafe.Pointer(tokenType)) = 59 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ID return keywordCode(tls, z, i, tokenType) } - case 0: + case CC_X: { - if int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == '\'' { - *(*int32)(unsafe.Pointer(tokenType)) = 151 + if int32(*(*uint8)(unsafe.Pointer(z + 1))) == '\'' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_BLOB for i = 2; (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x08) != 0; i++ { } if (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '\'') || ((i % 2) != 0) { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL for (*(*uint8)(unsafe.Pointer(z + uintptr(i))) != 0) && (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '\'') { i++ } @@ -142121,27 +139798,24 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq } return i } - // If it is not a BLOB literal, then it must be an ID, since no - // SQL keywords start with the letter 'x'. Fall through - /* no break */ } fallthrough - case 2: + case CC_ID: { i = 1 break } - case 28: + case CC_NUL: { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL return 0 } default: { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL return 1 } @@ -142149,7 +139823,7 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq for (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x46) != 0 { i++ } - *(*int32)(unsafe.Pointer(tokenType)) = 59 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ID return i } @@ -142173,11 +139847,11 @@ func Xsqlite3RunParser(tls *libc.TLS, pParse uintptr, zSql uintptr, pzErrMsg uin // var sEngine YyParser at bp+40, 2424 // Space to hold the Lemon-generated Parser object - mxSqlLen = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(1)*4)) + mxSqlLen = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 1*4)) if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 { libc.AtomicStoreNInt32((db + 392 /* &.u1 */ /* &.isInterrupted */), int32(0), 0) } - (*Parse)(unsafe.Pointer(pParse)).Frc = 0 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_OK (*Parse)(unsafe.Pointer(pParse)).FzTail = zSql pEngine = bp + 40 /* &sEngine */ @@ -142189,39 +139863,39 @@ func Xsqlite3RunParser(tls *libc.TLS, pParse uintptr, zSql uintptr, pzErrMsg uin n = Xsqlite3GetToken(tls, zSql, bp+2464 /* &tokenType */) mxSqlLen = mxSqlLen - (n) if mxSqlLen < 0 { - (*Parse)(unsafe.Pointer(pParse)).Frc = 18 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_TOOBIG break } - if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) >= 161 { + if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) >= TK_WINDOW { if libc.AtomicLoadNInt32((db+392 /* &.u1 */ /* &.isInterrupted */), 0) != 0 { - (*Parse)(unsafe.Pointer(pParse)).Frc = 9 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_INTERRUPT break } - if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == 179 { + if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == TK_SPACE { zSql += uintptr(n) continue } - if int32(*(*int8)(unsafe.Pointer(zSql + uintptr(0)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(zSql))) == 0 { // Upon reaching the end of input, call the parser two more times // with tokens TK_SEMI and 0, in that order. - if lastTokenParsed == 1 { + if lastTokenParsed == TK_SEMI { *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = 0 } else if lastTokenParsed == 0 { break } else { - *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = 1 + *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = TK_SEMI } n = 0 - } else if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == 161 { + } else if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == TK_WINDOW { - *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = analyzeWindowKeyword(tls, (zSql + uintptr(6))) - } else if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == 162 { + *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = analyzeWindowKeyword(tls, (zSql + 6)) + } else if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == TK_OVER { - *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = analyzeOverKeyword(tls, (zSql + uintptr(4)), lastTokenParsed) - } else if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == 163 { + *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = analyzeOverKeyword(tls, (zSql + 4), lastTokenParsed) + } else if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == TK_FILTER { - *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = analyzeFilterKeyword(tls, (zSql + uintptr(6)), lastTokenParsed) + *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = analyzeFilterKeyword(tls, (zSql + 6), lastTokenParsed) } else { Xsqlite3ErrorMsg(tls, pParse, ts+20546 /* "unrecognized tok..." */, libc.VaList(bp, n, zSql)) break @@ -142233,16 +139907,16 @@ func Xsqlite3RunParser(tls *libc.TLS, pParse uintptr, zSql uintptr, pzErrMsg uin lastTokenParsed = *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) zSql += uintptr(n) - if (*Parse)(unsafe.Pointer(pParse)).Frc != 0 { + if (*Parse)(unsafe.Pointer(pParse)).Frc != SQLITE_OK { break } } Xsqlite3ParserFinalize(tls, pEngine) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - (*Parse)(unsafe.Pointer(pParse)).Frc = 7 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM } - if (((*Parse)(unsafe.Pointer(pParse)).Frc != 0) && ((*Parse)(unsafe.Pointer(pParse)).Frc != 101)) && ((*Parse)(unsafe.Pointer(pParse)).FzErrMsg == uintptr(0)) { + if (((*Parse)(unsafe.Pointer(pParse)).Frc != SQLITE_OK) && ((*Parse)(unsafe.Pointer(pParse)).Frc != SQLITE_DONE)) && ((*Parse)(unsafe.Pointer(pParse)).FzErrMsg == uintptr(0)) { (*Parse)(unsafe.Pointer(pParse)).FzErrMsg = Xsqlite3MPrintf(tls, db, ts+2690 /* "%s" */, libc.VaList(bp+16, Xsqlite3ErrStr(tls, (*Parse)(unsafe.Pointer(pParse)).Frc))) } @@ -142265,13 +139939,13 @@ func Xsqlite3RunParser(tls *libc.TLS, pParse uintptr, zSql uintptr, pzErrMsg uin } Xsqlite3_free(tls, (*Parse)(unsafe.Pointer(pParse)).FapVtabLock) - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != 0) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL) { // If the pParse->declareVtab flag is set, do not delete any table // structure built up in pParse->pNewTable. The calling code (see vtab.c) // will take responsibility for freeing the Table structure. Xsqlite3DeleteTable(tls, db, (*Parse)(unsafe.Pointer(pParse)).FpNewTable) } - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { Xsqlite3DeleteTrigger(tls, db, (*Parse)(unsafe.Pointer(pParse)).FpNewTrigger) } @@ -142379,7 +140053,7 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: switch int32(*(*int8)(unsafe.Pointer(zSql))) { case ';': { // A semicolon - token = U8(0) + token = TkSEMI break } @@ -142393,32 +140067,32 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: fallthrough case '\f': { // White space is ignored - token = U8(1) + token = TkWS break } case '/': { // C-style comments - if int32(*(*int8)(unsafe.Pointer(zSql + uintptr(1)))) != '*' { - token = U8(2) + if int32(*(*int8)(unsafe.Pointer(zSql + 1))) != '*' { + token = TkOTHER break } zSql += uintptr(2) - for (*(*int8)(unsafe.Pointer(zSql + uintptr(0))) != 0) && ((int32(*(*int8)(unsafe.Pointer(zSql + uintptr(0)))) != '*') || (int32(*(*int8)(unsafe.Pointer(zSql + uintptr(1)))) != '/')) { + for (*(*int8)(unsafe.Pointer(zSql)) != 0) && ((int32(*(*int8)(unsafe.Pointer(zSql))) != '*') || (int32(*(*int8)(unsafe.Pointer(zSql + 1))) != '/')) { zSql++ } - if int32(*(*int8)(unsafe.Pointer(zSql + uintptr(0)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(zSql))) == 0 { return 0 } zSql++ - token = U8(1) + token = TkWS break } case '-': { // SQL-style comments from "--" to end of line - if int32(*(*int8)(unsafe.Pointer(zSql + uintptr(1)))) != '-' { - token = U8(2) + if int32(*(*int8)(unsafe.Pointer(zSql + 1))) != '-' { + token = TkOTHER break } for (*(*int8)(unsafe.Pointer(zSql)) != 0) && (int32(*(*int8)(unsafe.Pointer(zSql))) != '\n') { @@ -142427,7 +140101,7 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: if int32(*(*int8)(unsafe.Pointer(zSql))) == 0 { return (libc.Bool32(int32(state) == 1)) } - token = U8(1) + token = TkWS break } @@ -142440,7 +140114,7 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: if int32(*(*int8)(unsafe.Pointer(zSql))) == 0 { return 0 } - token = U8(2) + token = TkOTHER break } @@ -142458,7 +140132,7 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: if int32(*(*int8)(unsafe.Pointer(zSql))) == 0 { return 0 } - token = U8(2) + token = TkOTHER break } @@ -142475,9 +140149,9 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: case 'C': { if (nId == 6) && (Xsqlite3_strnicmp(tls, zSql, ts+20584 /* "create" */, 6) == 0) { - token = U8(4) + token = TkCREATE } else { - token = U8(2) + token = TkOTHER } break @@ -142488,13 +140162,13 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: case 'T': { if (nId == 7) && (Xsqlite3_strnicmp(tls, zSql, ts+17419 /* "trigger" */, 7) == 0) { - token = U8(6) + token = TkTRIGGER } else if (nId == 4) && (Xsqlite3_strnicmp(tls, zSql, ts+20591 /* "temp" */, 4) == 0) { - token = U8(5) + token = TkTEMP } else if (nId == 9) && (Xsqlite3_strnicmp(tls, zSql, ts+20596 /* "temporary" */, 9) == 0) { - token = U8(5) + token = TkTEMP } else { - token = U8(2) + token = TkOTHER } break @@ -142505,11 +140179,11 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: case 'E': { if (nId == 3) && (Xsqlite3_strnicmp(tls, zSql, ts+20606 /* "end" */, 3) == 0) { - token = U8(7) + token = TkEND } else if (nId == 7) && (Xsqlite3_strnicmp(tls, zSql, ts+20610 /* "explain" */, 7) == 0) { - token = U8(3) + token = TkEXPLAIN } else { - token = U8(2) + token = TkOTHER } break @@ -142517,7 +140191,7 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: fallthrough default: { - token = U8(2) + token = TkOTHER break } @@ -142525,7 +140199,7 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: zSql += (uintptr(nId - 1)) } else { // Operators and special symbols - token = U8(2) + token = TkOTHER } break @@ -142563,12 +140237,12 @@ func Xsqlite3_complete16(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:16088 return rc } pVal = Xsqlite3ValueNew(tls, uintptr(0)) - Xsqlite3ValueSetStr(tls, pVal, -1, zSql, uint8(2), uintptr(0)) - zSql8 = Xsqlite3ValueText(tls, pVal, uint8(1)) + Xsqlite3ValueSetStr(tls, pVal, -1, zSql, SQLITE_UTF16LE, uintptr(0)) + zSql8 = Xsqlite3ValueText(tls, pVal, SQLITE_UTF8) if zSql8 != 0 { rc = Xsqlite3_complete(tls, zSql8) } else { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3ValueFree(tls, pVal) return (rc & 0xff) @@ -142610,14 +140284,14 @@ func Xsqlite3_libversion(tls *libc.TLS) uintptr { /* sqlite3.c:161110:23: */ // IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function // returns an integer equal to SQLITE_VERSION_NUMBER. func Xsqlite3_libversion_number(tls *libc.TLS) int32 { /* sqlite3.c:161123:16: */ - return 3033000 + return SQLITE_VERSION_NUMBER } // IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns // zero if and only if SQLite was compiled with mutexing code omitted due to // the SQLITE_THREADSAFE compile-time option being set to 0. func Xsqlite3_threadsafe(tls *libc.TLS) int32 { /* sqlite3.c:161129:16: */ - return 1 + return SQLITE_THREADSAFE } // When compiling the test fixture or with debugging enabled (on Win32), @@ -142681,7 +140355,7 @@ func Xsqlite3_initialize(tls *libc.TLS) int32 { /* sqlite3.c:161202:16: */ // of this routine. if Xsqlite3Config.FisInit != 0 { - return 0 + return SQLITE_OK } // Make sure the mutex subsystem is initialized. If unable to @@ -142701,22 +140375,22 @@ func Xsqlite3_initialize(tls *libc.TLS) int32 { /* sqlite3.c:161202:16: */ // MutexAlloc() is called for a static mutex prior to initializing the // malloc subsystem - this implies that the allocation of a static // mutex must not require support from the malloc subsystem. - pMainMtx = Xsqlite3MutexAlloc(tls, 2) + pMainMtx = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, pMainMtx) Xsqlite3Config.FisMutexInit = 1 if !(Xsqlite3Config.FisMallocInit != 0) { rc = Xsqlite3MallocInit(tls) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3Config.FisMallocInit = 1 if !(int32(Xsqlite3Config.FpInitMutex) != 0) { - Xsqlite3Config.FpInitMutex = Xsqlite3MutexAlloc(tls, 1) + Xsqlite3Config.FpInitMutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_RECURSIVE) if (Xsqlite3Config.FbCoreMutex != 0) && !(int32(Xsqlite3Config.FpInitMutex) != 0) { - rc = 7 + rc = SQLITE_NOMEM } } } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3Config.FnRefInitMutex++ } Xsqlite3_mutex_leave(tls, pMainMtx) @@ -142724,7 +140398,7 @@ func Xsqlite3_initialize(tls *libc.TLS) int32 { /* sqlite3.c:161202:16: */ // If rc is not SQLITE_OK at this point, then either the malloc // subsystem could not be initialized or the system failed to allocate // the pInitMutex mutex. Return an error in either case. - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -142748,11 +140422,11 @@ func Xsqlite3_initialize(tls *libc.TLS) int32 { /* sqlite3.c:161202:16: */ if Xsqlite3Config.FisPCacheInit == 0 { rc = Xsqlite3PcacheInitialize(tls) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3Config.FisPCacheInit = 1 rc = Xsqlite3OsInit(tls) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3PCacheBufferSetup(tls, Xsqlite3Config.FpPage, Xsqlite3Config.FszPage, Xsqlite3Config.FnPage) @@ -142819,7 +140493,7 @@ func Xsqlite3_shutdown(tls *libc.TLS) int32 { /* sqlite3.c:161377:16: */ Xsqlite3Config.FisMutexInit = 0 } - return 0 + return SQLITE_OK } // This API allows applications to modify the global configuration of @@ -142832,7 +140506,7 @@ func Xsqlite3_shutdown(tls *libc.TLS) int32 { /* sqlite3.c:161377:16: */ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:161431:16: */ var ap Va_list _ = ap - var rc int32 = 0 + var rc int32 = SQLITE_OK // sqlite3_config() shall return SQLITE_MISUSE if it is invoked while // the SQLite library is in use. @@ -142845,7 +140519,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 // Mutex configuration options are only available in a threadsafe // compile. - case 1: + case SQLITE_CONFIG_SINGLETHREAD: { // EVIDENCE-OF: R-02748-19096 This option sets the threading mode to // Single-thread. @@ -142854,7 +140528,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 2: + case SQLITE_CONFIG_MULTITHREAD: { // EVIDENCE-OF: R-14374-42468 This option sets the threading mode to // Multi-thread. @@ -142863,7 +140537,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 3: + case SQLITE_CONFIG_SERIALIZED: { // EVIDENCE-OF: R-41220-51800 This option sets the threading mode to // Serialized. @@ -142872,14 +140546,14 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 10: + case SQLITE_CONFIG_MUTEX: { // Specify an alternative mutex implementation Xsqlite3Config.Fmutex = *(*Sqlite3_mutex_methods)(unsafe.Pointer(libc.VaUintptr(&ap))) break } - case 11: + case SQLITE_CONFIG_GETMUTEX: { // Retrieve the current mutex implementation *(*Sqlite3_mutex_methods)(unsafe.Pointer(libc.VaUintptr(&ap))) = Xsqlite3Config.Fmutex @@ -142887,7 +140561,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 } - case 4: + case SQLITE_CONFIG_MALLOC: { // EVIDENCE-OF: R-55594-21030 The SQLITE_CONFIG_MALLOC option takes a // single argument which is a pointer to an instance of the @@ -142898,7 +140572,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 5: + case SQLITE_CONFIG_GETMALLOC: { // EVIDENCE-OF: R-51213-46414 The SQLITE_CONFIG_GETMALLOC option takes a // single argument which is a pointer to an instance of the @@ -142911,7 +140585,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 9: + case SQLITE_CONFIG_MEMSTATUS: { // EVIDENCE-OF: R-61275-35157 The SQLITE_CONFIG_MEMSTATUS option takes // single argument of type int, interpreted as a boolean, which enables @@ -142920,13 +140594,13 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 27: + case SQLITE_CONFIG_SMALL_MALLOC: { Xsqlite3Config.FbSmallMalloc = U8(libc.VaInt32(&ap)) break } - case 7: + case SQLITE_CONFIG_PAGECACHE: { // EVIDENCE-OF: R-18761-36601 There are three arguments to // SQLITE_CONFIG_PAGECACHE: A pointer to 8-byte aligned memory (pMem), @@ -142938,7 +140612,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 24: + case SQLITE_CONFIG_PCACHE_HDRSZ: { // EVIDENCE-OF: R-39100-27317 The SQLITE_CONFIG_PCACHE_HDRSZ option takes // a single parameter which is a pointer to an integer and writes into @@ -142949,21 +140623,21 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 } - case 14: + case SQLITE_CONFIG_PCACHE: { // no-op break } - case 15: + case SQLITE_CONFIG_GETPCACHE: { // now an error - rc = 1 + rc = SQLITE_ERROR break } - case 18: + case SQLITE_CONFIG_PCACHE2: { // EVIDENCE-OF: R-63325-48378 The SQLITE_CONFIG_PCACHE2 option takes a // single argument which is a pointer to an sqlite3_pcache_methods2 @@ -142973,7 +140647,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 19: + case SQLITE_CONFIG_GETPCACHE2: { // EVIDENCE-OF: R-22035-46182 The SQLITE_CONFIG_GETPCACHE2 option takes a // single argument which is a pointer to an sqlite3_pcache_methods2 @@ -142991,7 +140665,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 // available if SQLite is compiled with either SQLITE_ENABLE_MEMSYS3 or // SQLITE_ENABLE_MEMSYS5 and returns SQLITE_ERROR if invoked otherwise. - case 13: + case SQLITE_CONFIG_LOOKASIDE: { Xsqlite3Config.FszLookaside = int32(libc.VaInt32(&ap)) Xsqlite3Config.FnLookaside = int32(libc.VaInt32(&ap)) @@ -143002,7 +140676,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 // Record a pointer to the logger function and its first argument. // The default is NULL. Logging is disabled if the function pointer is // NULL. - case 16: + case SQLITE_CONFIG_LOG: { Xsqlite3Config.FxLog = libc.VaUintptr(&ap) Xsqlite3Config.FpLogArg = libc.VaUintptr(&ap) @@ -143014,7 +140688,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 // can be changed at start-time using the // sqlite3_config(SQLITE_CONFIG_URI,1) or // sqlite3_config(SQLITE_CONFIG_URI,0) configuration calls. - case 17: + case SQLITE_CONFIG_URI: { // EVIDENCE-OF: R-25451-61125 The SQLITE_CONFIG_URI option takes a single // argument of type int. If non-zero, then URI handling is globally @@ -143025,7 +140699,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 } - case 20: + case SQLITE_CONFIG_COVERING_INDEX_SCAN: { // EVIDENCE-OF: R-36592-02772 The SQLITE_CONFIG_COVERING_INDEX_SCAN // option takes a single integer argument which is interpreted as a @@ -143036,7 +140710,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 } - case 22: + case SQLITE_CONFIG_MMAP_SIZE: { // EVIDENCE-OF: R-58063-38258 SQLITE_CONFIG_MMAP_SIZE takes two 64-bit // integer (sqlite3_int64) values that are the default mmap size limit @@ -143051,11 +140725,11 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 // silently truncated if necessary so that it does not exceed the // compile-time maximum mmap size set by the SQLITE_MAX_MMAP_SIZE // compile-time option. - if (mxMmap < int64(0)) || (mxMmap > int64(0x7fff0000)) { - mxMmap = int64(0x7fff0000) + if (mxMmap < int64(0)) || (mxMmap > SQLITE_MAX_MMAP_SIZE) { + mxMmap = SQLITE_MAX_MMAP_SIZE } if szMmap < int64(0) { - szMmap = int64(0) + szMmap = SQLITE_DEFAULT_MMAP_SIZE } if szMmap > mxMmap { szMmap = mxMmap @@ -143066,14 +140740,14 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 } - case 25: + case SQLITE_CONFIG_PMASZ: { Xsqlite3Config.FszPma = U32(libc.VaUint32(&ap)) break } - case 26: + case SQLITE_CONFIG_STMTJRNL_SPILL: { Xsqlite3Config.FnStmtSpill = int32(libc.VaInt32(&ap)) break @@ -143082,7 +140756,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 default: { - rc = 1 + rc = SQLITE_ERROR break } @@ -143107,7 +140781,7 @@ func setupLookaside(tls *libc.TLS, db uintptr, pBuf uintptr, sz int32, cnt int32 var nSm int32 // Number smaller LOOKASIDE_SMALL-byte slots if Xsqlite3LookasideUsed(tls, db, uintptr(0)) > 0 { - return 5 + return SQLITE_BUSY } // Free any existing lookaside buffer for this handle before // allocating a new one so we don't have to have space for @@ -143117,7 +140791,7 @@ func setupLookaside(tls *libc.TLS, db uintptr, pBuf uintptr, sz int32, cnt int32 } // The size of a lookaside slot after ROUNDDOWN8 needs to be larger // than a pointer to be useful. - sz = ((sz) & ^libc.Int32(7)) // IMP: R-33038-09382 + sz = ((sz) & libc.CplInt32(7)) // IMP: R-33038-09382 if sz <= int32(unsafe.Sizeof(uintptr(0))) { sz = 0 } @@ -143137,12 +140811,12 @@ func setupLookaside(tls *libc.TLS, db uintptr, pBuf uintptr, sz int32, cnt int32 } else { pStart = pBuf } - if sz >= (128 * 3) { - nBig = (int32(szAlloc / (Sqlite3_int64((3 * 128) + sz)))) - nSm = (int32((szAlloc - (Sqlite3_int64(sz * nBig))) / int64(128))) - } else if sz >= (128 * 2) { - nBig = (int32(szAlloc / (Sqlite3_int64(128 + sz)))) - nSm = (int32((szAlloc - (Sqlite3_int64(sz * nBig))) / int64(128))) + if sz >= (LOOKASIDE_SMALL * 3) { + nBig = (int32(szAlloc / (Sqlite3_int64((3 * LOOKASIDE_SMALL) + sz)))) + nSm = (int32((szAlloc - (Sqlite3_int64(sz * nBig))) / LOOKASIDE_SMALL)) + } else if sz >= (LOOKASIDE_SMALL * 2) { + nBig = (int32(szAlloc / (Sqlite3_int64(LOOKASIDE_SMALL + sz)))) + nSm = (int32((szAlloc - (Sqlite3_int64(sz * nBig))) / LOOKASIDE_SMALL)) } else if sz > 0 { nBig = (int32(szAlloc / Sqlite3_int64(sz))) nSm = 0 @@ -143170,7 +140844,7 @@ func setupLookaside(tls *libc.TLS, db uintptr, pBuf uintptr, sz int32, cnt int32 for i = 0; i < nSm; i++ { (*LookasideSlot)(unsafe.Pointer(p)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = p - p = ((p) + uintptr(128)) + p = ((p) + 128) } (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = p @@ -143194,7 +140868,7 @@ func setupLookaside(tls *libc.TLS, db uintptr, pBuf uintptr, sz int32, cnt int32 (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FnSlot = U32(0) } - return 0 + return SQLITE_OK } // Return the mutex associated with a database connection. @@ -143218,34 +140892,34 @@ func Xsqlite3_db_release_memory(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c: } Xsqlite3BtreeLeaveAll(tls, db) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // Flush any dirty pages in the pager-cache for any attached database // to disk. func Xsqlite3_db_cacheflush(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:161887:16: */ var i int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var bSeenBusy int32 = 0 Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) Xsqlite3BtreeEnterAll(tls, db) - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt if (pBt != 0) && (Xsqlite3BtreeIsInTrans(tls, pBt) != 0) { var pPager uintptr = Xsqlite3BtreePager(tls, pBt) rc = Xsqlite3PagerFlush(tls, pPager) - if rc == 5 { + if rc == SQLITE_BUSY { bSeenBusy = 1 - rc = 0 + rc = SQLITE_OK } } } Xsqlite3BtreeLeaveAll(tls, db) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) return func() int32 { - if (rc == 0) && (bSeenBusy != 0) { - return 5 + if (rc == SQLITE_OK) && (bSeenBusy != 0) { + return SQLITE_BUSY } return rc }() @@ -143258,16 +140932,16 @@ func Xsqlite3_db_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 { var rc int32 ap = va switch op { - case 1000: + case SQLITE_DBCONFIG_MAINDBNAME: { // IMP: R-06824-28531 // IMP: R-36257-52125 - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FzDbSName = libc.VaUintptr(&ap) - rc = 0 + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName = libc.VaUintptr(&ap) + rc = SQLITE_OK break } - case 1001: + case SQLITE_DBCONFIG_LOOKASIDE: { var pBuf uintptr = libc.VaUintptr(&ap) // IMP: R-26835-10964 var sz int32 = int32(libc.VaInt32(&ap)) // IMP: R-47871-25994 @@ -143279,7 +140953,7 @@ func Xsqlite3_db_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 { default: { var i uint32 - rc = 1 // IMP: R-42790-23372 + rc = SQLITE_ERROR // IMP: R-42790-23372 for i = uint32(0); i < (uint32((int32(uint64(unsafe.Sizeof(aFlagOp)) / uint64(unsafe.Sizeof(struct { Fop int32 Fmask U32 @@ -143299,7 +140973,7 @@ func Xsqlite3_db_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 { if pRes != 0 { *(*int32)(unsafe.Pointer(pRes)) = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & U64(aFlagOp[i].Fmask)) != uint64(0))) } - rc = 0 + rc = SQLITE_OK break } } @@ -143315,54 +140989,22 @@ var aFlagOp = [16]struct { Fop int32 Fmask U32 }{ - { - Fop: 1002, - Fmask: U32(0x00004000)}, - { - Fop: 1003, - Fmask: U32(0x00040000)}, - { - Fop: 1015, - Fmask: 0x80000000}, - { - Fop: 1004, - Fmask: U32(0x00400000)}, - { - Fop: 1005, - Fmask: U32(0x00010000)}, - { - Fop: 1006, - Fmask: U32(0x00000800)}, - { - Fop: 1007, - Fmask: U32(0x00800000)}, - { - Fop: 1008, - Fmask: U32(0x01000000)}, - { - Fop: 1009, - Fmask: U32(0x02000000)}, - { - Fop: 1010, - Fmask: U32(0x10000000)}, - { - Fop: 1011, - Fmask: (U32(0x00000001 | 0x08000000))}, - { - Fop: 1012, - Fmask: U32(0x04000000)}, - { - Fop: 1014, - Fmask: U32(0x20000000)}, - { - Fop: 1013, - Fmask: U32(0x40000000)}, - { - Fop: 1016, - Fmask: U32(0x00000002)}, - { - Fop: 1017, - Fmask: U32(0x00000080)}, + {Fop: SQLITE_DBCONFIG_ENABLE_FKEY, Fmask: SQLITE_ForeignKeys}, + {Fop: SQLITE_DBCONFIG_ENABLE_TRIGGER, Fmask: SQLITE_EnableTrigger}, + {Fop: SQLITE_DBCONFIG_ENABLE_VIEW, Fmask: SQLITE_EnableView}, + {Fop: SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, Fmask: SQLITE_Fts3Tokenizer}, + {Fop: SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, Fmask: SQLITE_LoadExtension}, + {Fop: SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, Fmask: SQLITE_NoCkptOnClose}, + {Fop: SQLITE_DBCONFIG_ENABLE_QPSG, Fmask: SQLITE_EnableQPSG}, + {Fop: SQLITE_DBCONFIG_TRIGGER_EQP, Fmask: SQLITE_TriggerEQP}, + {Fop: SQLITE_DBCONFIG_RESET_DATABASE, Fmask: SQLITE_ResetDatabase}, + {Fop: SQLITE_DBCONFIG_DEFENSIVE, Fmask: SQLITE_Defensive}, + {Fop: SQLITE_DBCONFIG_WRITABLE_SCHEMA, Fmask: (U32(SQLITE_WriteSchema | SQLITE_NoSchemaError))}, + {Fop: SQLITE_DBCONFIG_LEGACY_ALTER_TABLE, Fmask: SQLITE_LegacyAlter}, + {Fop: SQLITE_DBCONFIG_DQS_DDL, Fmask: SQLITE_DqsDDL}, + {Fop: SQLITE_DBCONFIG_DQS_DML, Fmask: SQLITE_DqsDML}, + {Fop: SQLITE_DBCONFIG_LEGACY_FILE_FORMAT, Fmask: SQLITE_LegacyFileFmt}, + {Fop: SQLITE_DBCONFIG_TRUSTED_SCHEMA, Fmask: SQLITE_TrustedSchema}, } /* sqlite3.c:161939:9 */ // This is the default collating function named "BINARY" which is always @@ -143531,14 +141173,14 @@ func sqlite3Close(tls *libc.TLS, db uintptr, forceZombie int32) int32 { /* sqlit if !(db != 0) { // EVIDENCE-OF: R-63257-11740 Calling sqlite3_close() or // sqlite3_close_v2() with a NULL pointer argument is a harmless no-op. - return 0 + return SQLITE_OK } if !(Xsqlite3SafetyCheckSickOrOk(tls, db) != 0) { return Xsqlite3MisuseError(tls, 162200) } Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - if (int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & 0x08) != 0 { - (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, uint32(0x08), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, db, uintptr(0)) + if (int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & SQLITE_TRACE_CLOSE) != 0 { + (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, SQLITE_TRACE_CLOSE, (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, db, uintptr(0)) } // Force xDisconnect calls on all virtual tables @@ -143555,16 +141197,16 @@ func sqlite3Close(tls *libc.TLS, db uintptr, forceZombie int32) int32 { /* sqlit // Legacy behavior (sqlite3_close() behavior) is to return // SQLITE_BUSY if the connection can not be closed immediately. if !(forceZombie != 0) && (connectionIsBusy(tls, db) != 0) { - Xsqlite3ErrorWithMsg(tls, db, 5, + Xsqlite3ErrorWithMsg(tls, db, SQLITE_BUSY, ts+20618 /* "unable to close ..." */, 0) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 5 + return SQLITE_BUSY } // Convert the connection into a zombie and then close it. - (*Sqlite3)(unsafe.Pointer(db)).Fmagic = U32(0x64cffc7f) + (*Sqlite3)(unsafe.Pointer(db)).Fmagic = SQLITE_MAGIC_ZOMBIE Xsqlite3LeaveMutexAndCloseZombie(tls, db) - return 0 + return SQLITE_OK } // Two variations on the public interface for closing a database @@ -143595,7 +141237,7 @@ func Xsqlite3LeaveMutexAndCloseZombie(tls *libc.TLS, db uintptr) { /* sqlite3.c: // If there are outstanding sqlite3_stmt or sqlite3_backup objects // or if the connection has not yet been closed by sqlite3_close_v2(), // then just leave the mutex and return. - if ((*Sqlite3)(unsafe.Pointer(db)).Fmagic != U32(0x64cffc7f)) || (connectionIsBusy(tls, db) != 0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fmagic != SQLITE_MAGIC_ZOMBIE) || (connectionIsBusy(tls, db) != 0) { Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) return } @@ -143609,7 +141251,7 @@ func Xsqlite3LeaveMutexAndCloseZombie(tls *libc.TLS, db uintptr) { /* sqlite3.c: // any database schemas have been modified by an uncommitted transaction // they are reset. And that the required b-tree mutex is held to make // the pager rollback and schema reset an atomic operation. - Xsqlite3RollbackAll(tls, db, 0) + Xsqlite3RollbackAll(tls, db, SQLITE_OK) // Free any outstanding Savepoint structures. Xsqlite3CloseSavepoints(tls, db) @@ -143626,8 +141268,8 @@ func Xsqlite3LeaveMutexAndCloseZombie(tls *libc.TLS, db uintptr) { /* sqlite3.c: } } // Clear the TEMP schema separately and last - if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema != 0 { - Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema) + if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema != 0 { + Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema) } Xsqlite3VtabUnlockList(tls, db) @@ -143668,20 +141310,20 @@ func Xsqlite3LeaveMutexAndCloseZombie(tls *libc.TLS, db uintptr) { /* sqlite3.c: } Xsqlite3HashClear(tls, (db + 528 /* &.aModule */)) - Xsqlite3Error(tls, db, 0) // Deallocates any cached error strings. + Xsqlite3Error(tls, db, SQLITE_OK) // Deallocates any cached error strings. Xsqlite3ValueFree(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr) Xsqlite3CloseExtensions(tls, db) - (*Sqlite3)(unsafe.Pointer(db)).Fmagic = 0xb5357930 + (*Sqlite3)(unsafe.Pointer(db)).Fmagic = SQLITE_MAGIC_ERROR // The temp-database schema is allocated differently from the other schema // objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()). // So it needs to be freed here. Todo: Why not roll the temp schema into // the same sqliteMalloc() as the one that allocates the database // structure? - Xsqlite3DbFree(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema) + Xsqlite3DbFree(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - (*Sqlite3)(unsafe.Pointer(db)).Fmagic = 0x9f3c2d33 + (*Sqlite3)(unsafe.Pointer(db)).Fmagic = SQLITE_MAGIC_CLOSED Xsqlite3_mutex_free(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) if (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbMalloced != 0 { @@ -143709,7 +141351,7 @@ func Xsqlite3RollbackAll(tls *libc.TLS, db uintptr, tripCode int32) { /* sqlite3 // the database rollback and schema reset, which can cause false // corruption reports in some cases. Xsqlite3BtreeEnterAll(tls, db) - schemaChange = (libc.Bool32((((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0001)) != U32(0)) && (int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0))) + schemaChange = (libc.Bool32((((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_SchemaChange) != U32(0)) && (int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0))) for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { var p uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt @@ -143732,7 +141374,7 @@ func Xsqlite3RollbackAll(tls *libc.TLS, db uintptr, tripCode int32) { /* sqlite3 // Any deferred constraint violations have now been resolved. (*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons = int64(0) (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = int64(0) - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x00080000))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_DeferFKs)) // If one has been configured, invoke the rollback-hook callback if ((*Sqlite3)(unsafe.Pointer(db)).FxRollbackCallback != 0) && ((inTrans != 0) || !(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0)) { @@ -143748,19 +141390,19 @@ func Xsqlite3RollbackAll(tls *libc.TLS, db uintptr, tripCode int32) { /* sqlite3 func Xsqlite3ErrStr(tls *libc.TLS, rc int32) uintptr { /* sqlite3.c:162545:27: */ var zErr uintptr = ts + 20686 /* "unknown error" */ switch rc { - case (4 | (int32(2) << 8)): + case (SQLITE_ABORT | (int32(2) << 8)): { zErr = ts + 20700 /* "abort due to ROL..." */ break } - case 100: + case SQLITE_ROW: { zErr = ts + 20722 /* "another row avai..." */ break } - case 101: + case SQLITE_DONE: { zErr = ts + 20744 /* "no more rows ava..." */ break @@ -143874,7 +141516,7 @@ func Xsqlite3_busy_handler(tls *libc.TLS, db uintptr, xBusy uintptr, pArg uintpt (*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 (*Sqlite3)(unsafe.Pointer(db)).FbusyTimeout = 0 Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // This routine sets the progress callback for an Sqlite database to the @@ -143906,7 +141548,7 @@ func Xsqlite3_busy_timeout(tls *libc.TLS, db uintptr, ms int32) int32 { /* sqlit } else { Xsqlite3_busy_handler(tls, db, uintptr(0), uintptr(0)) } - return 0 + return SQLITE_OK } // Cause any pending operation to stop at its earliest opportunity. @@ -143928,18 +141570,18 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i ((xSFunc != uintptr(0)) && (xFinal != uintptr(0)))) || // Not both xSFunc and xFinal ((libc.Bool32(xFinal == uintptr(0))) != (libc.Bool32(xStep == uintptr(0))))) || // Both or neither of xFinal and xStep ((libc.Bool32(xValue == uintptr(0))) != (libc.Bool32(xInverse == uintptr(0))))) || // Both or neither of xValue, xInverse - ((nArg < -1) || (nArg > 127))) || + ((nArg < -1) || (nArg > SQLITE_MAX_FUNCTION_ARG))) || (255 < (libc.AssignInt32(&nName, Xsqlite3Strlen30(tls, zFunctionName)))) { return Xsqlite3MisuseError(tls, 162797) } - extraFlags = (enc & (((0x000000800 | 0x000080000) | 0x000100000) | 0x000200000)) - enc = enc & (0x0003 | 5) + extraFlags = (enc & (((SQLITE_DETERMINISTIC | SQLITE_DIRECTONLY) | SQLITE_SUBTYPE) | SQLITE_INNOCUOUS)) + enc = enc & (SQLITE_FUNC_ENCMASK | SQLITE_ANY) // The SQLITE_INNOCUOUS flag is the same bit as SQLITE_FUNC_UNSAFE. But // the meaning is inverted. So flip the bit. - extraFlags = extraFlags ^ (0x00200000) + extraFlags = extraFlags ^ (SQLITE_FUNC_UNSAFE) // If SQLITE_UTF16 is specified as the encoding type, transform this // to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the @@ -143947,22 +141589,22 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i // // If SQLITE_ANY is specified, add three versions of the function // to the hash table. - if enc == 4 { - enc = 2 - } else if enc == 5 { + if enc == SQLITE_UTF16 { + enc = SQLITE_UTF16LE + } else if enc == SQLITE_ANY { var rc int32 rc = Xsqlite3CreateFunc(tls, db, zFunctionName, nArg, - ((1 | extraFlags) ^ 0x00200000), + ((SQLITE_UTF8 | extraFlags) ^ SQLITE_FUNC_UNSAFE), pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3CreateFunc(tls, db, zFunctionName, nArg, - ((2 | extraFlags) ^ 0x00200000), + ((SQLITE_UTF16LE | extraFlags) ^ SQLITE_FUNC_UNSAFE), pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor) } - if rc != 0 { + if rc != SQLITE_OK { return rc } - enc = 3 + enc = SQLITE_UTF16BE } // Check if an existing function is being overridden or deleted. If so, @@ -143970,12 +141612,12 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i // is being overridden/deleted but there are no active VMs, allow the // operation to continue but invalidate all precompiled statements. p = Xsqlite3FindFunction(tls, db, zFunctionName, nArg, U8(enc), uint8(0)) - if ((p != 0) && (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & U32(0x0003)) == U32(enc))) && (int32((*FuncDef)(unsafe.Pointer(p)).FnArg) == nArg) { + if ((p != 0) && (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & SQLITE_FUNC_ENCMASK) == U32(enc))) && (int32((*FuncDef)(unsafe.Pointer(p)).FnArg) == nArg) { if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive != 0 { - Xsqlite3ErrorWithMsg(tls, db, 5, + Xsqlite3ErrorWithMsg(tls, db, SQLITE_BUSY, ts+21242 /* "unable to delete..." */, 0) - return 5 + return SQLITE_BUSY } else { Xsqlite3ExpirePreparedStatements(tls, db, 0) } @@ -143984,7 +141626,7 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i p = Xsqlite3FindFunction(tls, db, zFunctionName, nArg, U8(enc), uint8(1)) if !(p != 0) { - return 7 + return SQLITE_NOMEM } // If an older version of the function with a configured destructor is @@ -143995,7 +141637,7 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i (*FuncDestructor)(unsafe.Pointer(pDestructor)).FnRef++ } *(*uintptr)(unsafe.Pointer(p + 64 /* &.u */)) = pDestructor - (*FuncDef)(unsafe.Pointer(p)).FfuncFlags = (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & U32(0x0003)) | U32(extraFlags)) + (*FuncDef)(unsafe.Pointer(p)).FfuncFlags = (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & SQLITE_FUNC_ENCMASK) | U32(extraFlags)) (*FuncDef)(unsafe.Pointer(p)).FxSFunc = func() uintptr { if xSFunc != 0 { @@ -144008,7 +141650,7 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i (*FuncDef)(unsafe.Pointer(p)).FxInverse = xInverse (*FuncDef)(unsafe.Pointer(p)).FpUserData = pUserData (*FuncDef)(unsafe.Pointer(p)).FnArg = I8(U16(nArg)) - return 0 + return SQLITE_OK } // Worker function used by utf-8 APIs that create new functions: @@ -144019,7 +141661,7 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i func createFunctionApi(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, xSFunc uintptr, xStep uintptr, xFinal uintptr, xValue uintptr, xInverse uintptr, xDestroy uintptr) int32 { /* sqlite3.c:162891:12: */ var rc int32 var pArg uintptr - rc = 1 + rc = SQLITE_ERROR pArg = uintptr(0) Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -144079,7 +141721,7 @@ func Xsqlite3_create_function16(tls *libc.TLS, db uintptr, zFunctionName uintptr Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - zFunc8 = Xsqlite3Utf16to8(tls, db, zFunctionName, -1, uint8(2)) + zFunc8 = Xsqlite3Utf16to8(tls, db, zFunctionName, -1, SQLITE_UTF16LE) rc = Xsqlite3CreateFunc(tls, db, zFunc8, nArg, eTextRep, p, xSFunc, xStep, xFinal, uintptr(0), uintptr(0), uintptr(0)) Xsqlite3DbFree(tls, db, zFunc8) rc = Xsqlite3ApiExit(tls, db, rc) @@ -144122,16 +141764,16 @@ func Xsqlite3_overload_function(tls *libc.TLS, db uintptr, zName uintptr, nArg i var zCopy uintptr Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - rc = (libc.Bool32(Xsqlite3FindFunction(tls, db, zName, nArg, uint8(1), uint8(0)) != uintptr(0))) + rc = (libc.Bool32(Xsqlite3FindFunction(tls, db, zName, nArg, SQLITE_UTF8, uint8(0)) != uintptr(0))) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) if rc != 0 { - return 0 + return SQLITE_OK } zCopy = Xsqlite3_mprintf(tls, zName, 0) if zCopy == uintptr(0) { - return 7 + return SQLITE_NOMEM } - return Xsqlite3_create_function_v2(tls, db, zName, nArg, 1, + return Xsqlite3_create_function_v2(tls, db, zName, nArg, SQLITE_UTF8, zCopy, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{sqlite3InvalidFunction})), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) @@ -144150,7 +141792,7 @@ func Xsqlite3_trace(tls *libc.TLS, db uintptr, xTrace uintptr, pArg uintptr) uin pOld = (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg (*Sqlite3)(unsafe.Pointer(db)).FmTrace = func() uint8 { if xTrace != 0 { - return uint8(0x40) + return SQLITE_TRACE_LEGACY } return uint8(0) }() @@ -144173,7 +141815,7 @@ func Xsqlite3_trace_v2(tls *libc.TLS, db uintptr, mTrace uint32, xTrace uintptr, *(*uintptr)(unsafe.Pointer(db + 232 /* &.trace */)) = xTrace (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg = pArg Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // Register a profile function. The pArg from the previously registered @@ -144189,9 +141831,9 @@ func Xsqlite3_profile(tls *libc.TLS, db uintptr, xProfile uintptr, pArg uintptr) pOld = (*Sqlite3)(unsafe.Pointer(db)).FpProfileArg (*Sqlite3)(unsafe.Pointer(db)).FxProfile = xProfile (*Sqlite3)(unsafe.Pointer(db)).FpProfileArg = pArg - *(*U8)(unsafe.Pointer(db + 104 /* &.mTrace */)) &= U8((0x0f)) + *(*U8)(unsafe.Pointer(db + 104 /* &.mTrace */)) &= U8((SQLITE_TRACE_NONLEGACY_MASK)) if (*Sqlite3)(unsafe.Pointer(db)).FxProfile != 0 { - *(*U8)(unsafe.Pointer(db + 104 /* &.mTrace */)) |= U8((0x80)) + *(*U8)(unsafe.Pointer(db + 104 /* &.mTrace */)) |= U8((SQLITE_TRACE_XPROFILE)) } Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) return pOld @@ -144259,7 +141901,7 @@ func Xsqlite3WalDefaultHook(tls *libc.TLS, pClientData uintptr, db uintptr, zDb Xsqlite3_wal_checkpoint(tls, db, zDb) Xsqlite3EndBenignMalloc(tls) } - return 0 + return SQLITE_OK } // Configure an sqlite3_wal_hook() callback to automatically checkpoint @@ -144279,7 +141921,7 @@ func Xsqlite3_wal_autocheckpoint(tls *libc.TLS, db uintptr, nFrame int32) int32 } else { Xsqlite3_wal_hook(tls, db, uintptr(0), uintptr(0)) } - return 0 + return SQLITE_OK } // Register a callback to be invoked each time a transaction is written @@ -144299,8 +141941,8 @@ func Xsqlite3_wal_checkpoint_v2(tls *libc.TLS, db uintptr, zDb uintptr, eMode in bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 // Return code - var iDb int32 = 10 // sqlite3.aDb[] index of db to checkpoint + var rc int32 // Return code + var iDb int32 = SQLITE_MAX_ATTACHED // sqlite3.aDb[] index of db to checkpoint // Initialize the output variables to -1 in case an error occurs. if pnLog != 0 { @@ -144310,19 +141952,19 @@ func Xsqlite3_wal_checkpoint_v2(tls *libc.TLS, db uintptr, zDb uintptr, eMode in *(*int32)(unsafe.Pointer(pnCkpt)) = -1 } - if (eMode < 0) || (eMode > 3) { + if (eMode < SQLITE_CHECKPOINT_PASSIVE) || (eMode > SQLITE_CHECKPOINT_TRUNCATE) { // EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint // mode: - return 21 + return SQLITE_MISUSE } Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - if (zDb != 0) && (*(*int8)(unsafe.Pointer(zDb + uintptr(0))) != 0) { + if (zDb != 0) && (*(*int8)(unsafe.Pointer(zDb)) != 0) { iDb = Xsqlite3FindDbName(tls, db, zDb) } if iDb < 0 { - rc = 1 - Xsqlite3ErrorWithMsg(tls, db, 1, ts+21356 /* "unknown database..." */, libc.VaList(bp, zDb)) + rc = SQLITE_ERROR + Xsqlite3ErrorWithMsg(tls, db, SQLITE_ERROR, ts+21356 /* "unknown database..." */, libc.VaList(bp, zDb)) } else { (*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 rc = Xsqlite3Checkpoint(tls, db, iDb, eMode, pnLog, pnCkpt) @@ -144346,7 +141988,7 @@ func Xsqlite3_wal_checkpoint_v2(tls *libc.TLS, db uintptr, zDb uintptr, eMode in func Xsqlite3_wal_checkpoint(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* sqlite3.c:163397:16: */ // EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to // sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). - return Xsqlite3_wal_checkpoint_v2(tls, db, zDb, 0, uintptr(0), uintptr(0)) + return Xsqlite3_wal_checkpoint_v2(tls, db, zDb, SQLITE_CHECKPOINT_PASSIVE, uintptr(0), uintptr(0)) } // Run a checkpoint on database iDb. This is a no-op if database iDb is @@ -144368,24 +142010,24 @@ func Xsqlite3_wal_checkpoint(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* // Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL, RESTART // or TRUNCATE. func Xsqlite3Checkpoint(tls *libc.TLS, db uintptr, iDb int32, eMode int32, pnLog uintptr, pnCkpt uintptr) int32 { /* sqlite3.c:163424:20: */ - var rc int32 = 0 // Return code - var i int32 // Used to iterate through attached dbs - var bBusy int32 = 0 // True if SQLITE_BUSY has been encountered + var rc int32 = SQLITE_OK // Return code + var i int32 // Used to iterate through attached dbs + var bBusy int32 = 0 // True if SQLITE_BUSY has been encountered - for i = 0; (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb) && (rc == 0); i++ { - if (i == iDb) || (iDb == 10) { + for i = 0; (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb) && (rc == SQLITE_OK); i++ { + if (i == iDb) || (iDb == SQLITE_MAX_ATTACHED) { rc = Xsqlite3BtreeCheckpoint(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).FpBt, eMode, pnLog, pnCkpt) pnLog = uintptr(0) pnCkpt = uintptr(0) - if rc == 5 { + if rc == SQLITE_BUSY { bBusy = 1 - rc = 0 + rc = SQLITE_OK } } } - if (rc == 0) && (bBusy != 0) { - return 5 + if (rc == SQLITE_OK) && (bBusy != 0) { + return SQLITE_BUSY } return rc } @@ -144416,14 +142058,14 @@ func Xsqlite3TempInMemory(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:163468 func Xsqlite3_errmsg(tls *libc.TLS, db uintptr) uintptr { /* sqlite3.c:163489:23: */ var z uintptr if !(db != 0) { - return Xsqlite3ErrStr(tls, 7) + return Xsqlite3ErrStr(tls, SQLITE_NOMEM) } if !(Xsqlite3SafetyCheckSickOrOk(tls, db) != 0) { return Xsqlite3ErrStr(tls, Xsqlite3MisuseError(tls, 163495)) } Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - z = Xsqlite3ErrStr(tls, 7) + z = Xsqlite3ErrStr(tls, SQLITE_NOMEM) } else { if (*Sqlite3)(unsafe.Pointer(db)).FerrCode != 0 { @@ -144485,7 +142127,7 @@ func Xsqlite3_errcode(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:163559:16: return Xsqlite3MisuseError(tls, 163561) } if !(db != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { - return 7 + return SQLITE_NOMEM } return ((*Sqlite3)(unsafe.Pointer(db)).FerrCode & (*Sqlite3)(unsafe.Pointer(db)).FerrMask) } @@ -144495,7 +142137,7 @@ func Xsqlite3_extended_errcode(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:1 return Xsqlite3MisuseError(tls, 163570) } if !(db != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { - return 7 + return SQLITE_NOMEM } return (*Sqlite3)(unsafe.Pointer(db)).FerrCode } @@ -144525,10 +142167,10 @@ func createCollation(tls *libc.TLS, db uintptr, zName uintptr, enc U8, pCtx uint // SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. enc2 = int32(enc) - if (enc2 == 4) || (enc2 == 8) { - enc2 = 2 + if (enc2 == SQLITE_UTF16) || (enc2 == SQLITE_UTF16_ALIGNED) { + enc2 = SQLITE_UTF16LE } - if (enc2 < 1) || (enc2 > 3) { + if (enc2 < SQLITE_UTF8) || (enc2 > SQLITE_UTF16BE) { return Xsqlite3MisuseError(tls, 163618) } @@ -144538,9 +142180,9 @@ func createCollation(tls *libc.TLS, db uintptr, zName uintptr, enc U8, pCtx uint pColl = Xsqlite3FindCollSeq(tls, db, U8(enc2), zName, 0) if (pColl != 0) && ((*CollSeq)(unsafe.Pointer(pColl)).FxCmp != 0) { if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive != 0 { - Xsqlite3ErrorWithMsg(tls, db, 5, + Xsqlite3ErrorWithMsg(tls, db, SQLITE_BUSY, ts+21377 /* "unable to delete..." */, 0) - return 5 + return SQLITE_BUSY } Xsqlite3ExpirePreparedStatements(tls, db, 0) @@ -144549,7 +142191,7 @@ func createCollation(tls *libc.TLS, db uintptr, zName uintptr, enc U8, pCtx uint // then any copies made by synthCollSeq() need to be invalidated. // Also, collation destructor - CollSeq.xDel() - function may need // to be called. - if (int32((*CollSeq)(unsafe.Pointer(pColl)).Fenc) & ^libc.Int32(8)) == enc2 { + if (int32((*CollSeq)(unsafe.Pointer(pColl)).Fenc) & libc.CplInt32(SQLITE_UTF16_ALIGNED)) == enc2 { var aColl uintptr = Xsqlite3HashFind(tls, (db + 600 /* &.aCollSeq */), zName) var j int32 for j = 0; j < 3; j++ { @@ -144566,32 +142208,32 @@ func createCollation(tls *libc.TLS, db uintptr, zName uintptr, enc U8, pCtx uint pColl = Xsqlite3FindCollSeq(tls, db, U8(enc2), zName, 1) if pColl == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*CollSeq)(unsafe.Pointer(pColl)).FxCmp = xCompare (*CollSeq)(unsafe.Pointer(pColl)).FpUser = pCtx (*CollSeq)(unsafe.Pointer(pColl)).FxDel = xDel - (*CollSeq)(unsafe.Pointer(pColl)).Fenc = (U8(enc2 | (int32(enc) & 8))) - Xsqlite3Error(tls, db, 0) - return 0 + (*CollSeq)(unsafe.Pointer(pColl)).Fenc = (U8(enc2 | (int32(enc) & SQLITE_UTF16_ALIGNED))) + Xsqlite3Error(tls, db, SQLITE_OK) + return SQLITE_OK } // This array defines hard upper bounds on limit values. The // initializer must be kept in sync with the SQLITE_LIMIT_* // #defines in sqlite3.h. var aHardLimit = [12]int32{ - 1000000000, - 1000000000, - 2000, - 1000, - 500, - 250000000, - 127, - 10, - 50000, - 32766, // IMP: R-38091-32352 - 1000, - 8, + SQLITE_MAX_LENGTH, + SQLITE_MAX_SQL_LENGTH, + SQLITE_MAX_COLUMN, + SQLITE_MAX_EXPR_DEPTH, + SQLITE_MAX_COMPOUND_SELECT, + SQLITE_MAX_VDBE_OP, + SQLITE_MAX_FUNCTION_ARG, + SQLITE_MAX_ATTACHED, + SQLITE_MAX_LIKE_PATTERN_LENGTH, + SQLITE_MAX_VARIABLE_NUMBER, // IMP: R-38091-32352 + SQLITE_MAX_TRIGGER_DEPTH, + SQLITE_MAX_WORKER_THREADS, } /* sqlite3.c:163671:18 */ // Make sure the hard limits are set to reasonable values @@ -144612,7 +142254,7 @@ func Xsqlite3_limit(tls *libc.TLS, db uintptr, limitId int32, newLimit int32) in // macro called SQLITE_MAX_NAME. (The "_LIMIT_" in the name is changed to // "_MAX_".) - if (limitId < 0) || (limitId >= (11 + 1)) { + if (limitId < 0) || (limitId >= (SQLITE_LIMIT_WORKER_THREADS + 1)) { return -1 } oldLimit = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(limitId)*4)) @@ -144675,12 +142317,12 @@ func Xsqlite3ParseUri(tls *libc.TLS, zDefaultVfs uintptr, zUri uintptr, pFlags u var iIn int32 // Input character index var iOut int32 // Output character index var nByte U64 - rc = 0 + rc = SQLITE_OK flags = *(*uint32)(unsafe.Pointer(pFlags)) zVfs = zDefaultVfs nUri = Xsqlite3Strlen30(tls, zUri) - if !(((((flags & uint32(0x00000040)) != 0) || // IMP: R-48725-32206 + if !(((((flags & SQLITE_OPEN_URI) != 0) || // IMP: R-48725-32206 (Xsqlite3Config.FbOpenUri != 0)) && // IMP: R-51689-46548 (nUri >= 5)) && (libc.Xmemcmp(tls, zUri, ts+21445 /* "file:" */, uint64(5)) == 0)) { goto __1 @@ -144690,7 +142332,7 @@ func Xsqlite3ParseUri(tls *libc.TLS, zDefaultVfs uintptr, zUri uintptr, pFlags u // Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen // method that there may be extra parameters following the file-name. - flags = flags | (uint32(0x00000040)) + flags = flags | (SQLITE_OPEN_URI) iIn = 0 __3: @@ -144709,7 +142351,7 @@ __5: if !(!(zFile != 0)) { goto __6 } - return 7 + return SQLITE_NOMEM __6: ; @@ -144718,7 +142360,7 @@ __6: iIn = 5 // Discard the scheme and authority segments of the URI. - if !((int32(*(*int8)(unsafe.Pointer(zUri + uintptr(5)))) == '/') && (int32(*(*int8)(unsafe.Pointer(zUri + uintptr(6)))) == '/')) { + if !((int32(*(*int8)(unsafe.Pointer(zUri + 5))) == '/') && (int32(*(*int8)(unsafe.Pointer(zUri + 6))) == '/')) { goto __7 } iIn = 7 @@ -144730,12 +142372,12 @@ __8: goto __8 __9: ; - if !((iIn != 7) && ((iIn != 16) || (libc.Xmemcmp(tls, ts+21451 /* "localhost" */, (zUri+uintptr(7)), uint64(9)) != 0))) { + if !((iIn != 7) && ((iIn != 16) || (libc.Xmemcmp(tls, ts+21451 /* "localhost" */, (zUri+7), uint64(9)) != 0))) { goto __10 } *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+21461, /* "invalid uri auth..." */ - libc.VaList(bp, (iIn-7), (zUri+uintptr(7)))) - rc = 1 + libc.VaList(bp, (iIn-7), (zUri+7))) + rc = SQLITE_ERROR goto parse_uri_out __10: ; @@ -144848,7 +142490,7 @@ __26: // method. zOpt = (zFile + uintptr((Xsqlite3Strlen30(tls, zFile) + 1))) __27: - if !(*(*int8)(unsafe.Pointer(zOpt + uintptr(0))) != 0) { + if !(*(*int8)(unsafe.Pointer(zOpt)) != 0) { goto __28 } nOpt = Xsqlite3Strlen30(tls, zOpt) @@ -144870,7 +142512,7 @@ __29: goto __31 } - mask = (0x00020000 | 0x00040000) + mask = (SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_PRIVATECACHE) aMode = uintptr(unsafe.Pointer(&aCacheMode)) limit = mask zModeType = ts + 21493 /* "cache" */ @@ -144880,8 +142522,8 @@ __31: goto __32 } - mask = (((0x00000001 | 0x00000002) | - 0x00000004) | 0x00000080) + mask = (((SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE) | + SQLITE_OPEN_CREATE) | SQLITE_OPEN_MEMORY) aMode = uintptr(unsafe.Pointer(&aOpenMode)) limit = (int32(uint32(mask) & flags)) zModeType = ts + 2299 /* "access" */ @@ -144916,16 +142558,16 @@ __36: goto __38 } *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+21504 /* "no such %s mode:..." */, libc.VaList(bp+16, zModeType, zVal)) - rc = 1 + rc = SQLITE_ERROR goto parse_uri_out __38: ; - if !((mode & ^libc.Int32(0x00000080)) > limit) { + if !((mode & libc.CplInt32(SQLITE_OPEN_MEMORY)) > limit) { goto __39 } *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+21524, /* "%s mode not allo..." */ libc.VaList(bp+32, zModeType, zVal)) - rc = 3 + rc = SQLITE_PERM goto parse_uri_out __39: ; @@ -144946,7 +142588,7 @@ __1: if !(!(zFile != 0)) { goto __40 } - return 7 + return SQLITE_NOMEM __40: ; libc.Xmemset(tls, zFile, 0, uint64(4)) @@ -144958,7 +142600,7 @@ __40: __41: ; libc.Xmemset(tls, (zFile + uintptr(nUri)), 0, uint64(4)) - flags = flags & (^libc.Uint32FromInt32(0x00000040)) + flags = flags & (libc.Uint32FromInt32(libc.CplInt32(SQLITE_OPEN_URI))) __2: ; @@ -144967,11 +142609,11 @@ __2: goto __42 } *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+21548 /* "no such vfs: %s" */, libc.VaList(bp+48, zVfs)) - rc = 1 + rc = SQLITE_ERROR __42: ; parse_uri_out: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __43 } Xsqlite3_free_filename(tls, zFile) @@ -144990,27 +142632,15 @@ type OpenMode = struct { } /* sqlite3.c:163946:9 */ var aCacheMode = [3]OpenMode{ - { - Fz: ts + 21564, /* "shared" */ - Fmode: 0x00020000}, - { - Fz: ts + 21571, /* "private" */ - Fmode: 0x00040000}, + {Fz: ts + 21564 /* "shared" */, Fmode: SQLITE_OPEN_SHAREDCACHE}, + {Fz: ts + 21571 /* "private" */, Fmode: SQLITE_OPEN_PRIVATECACHE}, {}, } /* sqlite3.c:163955:34 */ var aOpenMode = [5]OpenMode{ - { - Fz: ts + 21579, /* "ro" */ - Fmode: 0x00000001}, - { - Fz: ts + 21582, /* "rw" */ - Fmode: 0x00000002}, - { - Fz: ts + 21585, /* "rwc" */ - Fmode: (0x00000002 | 0x00000004)}, - { - Fz: ts + 14958, /* "memory" */ - Fmode: 0x00000080}, + {Fz: ts + 21579 /* "ro" */, Fmode: SQLITE_OPEN_READONLY}, + {Fz: ts + 21582 /* "rw" */, Fmode: SQLITE_OPEN_READWRITE}, + {Fz: ts + 21585 /* "rwc" */, Fmode: (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)}, + {Fz: ts + 14958 /* "memory" */, Fmode: SQLITE_OPEN_MEMORY}, {}, } /* sqlite3.c:163967:34 */ @@ -145018,7 +142648,7 @@ var aOpenMode = [5]OpenMode{ // database filename for the sqlite3_uri_parameter() interface. func uriParameter(tls *libc.TLS, zFilename uintptr, zParam uintptr) uintptr { /* sqlite3.c:164041:19: */ zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) - for *(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(zFilename)) != 0 { var x int32 = libc.Xstrcmp(tls, zFilename, zParam) zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) if x == 0 { @@ -145063,13 +142693,13 @@ __1: isThreadsafe = 0 goto __3 __2: - if !((*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) & uint32(0x00008000)) != 0) { + if !((*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) & SQLITE_OPEN_NOMUTEX) != 0) { goto __4 } isThreadsafe = 0 goto __5 __4: - if !((*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) & uint32(0x00010000)) != 0) { + if !((*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) & SQLITE_OPEN_FULLMUTEX) != 0) { goto __6 } isThreadsafe = 1 @@ -145083,16 +142713,16 @@ __5: __3: ; - if !((*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) & uint32(0x00040000)) != 0) { + if !((*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) & SQLITE_OPEN_PRIVATECACHE) != 0) { goto __8 } - *(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) &= ^libc.Uint32FromInt32(0x00020000) + *(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) &= libc.Uint32FromInt32(libc.CplInt32(SQLITE_OPEN_SHAREDCACHE)) goto __9 __8: if !(Xsqlite3Config.FsharedCacheEnabled != 0) { goto __10 } - *(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) |= uint32(0x00020000) + *(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) |= SQLITE_OPEN_SHAREDCACHE __10: ; __9: @@ -145106,7 +142736,7 @@ __9: // SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE, // SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask // off all other flags. - *(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) &= ^libc.Uint32FromInt32((((((((((((0x00000008 | 0x00000010) | 0x00000100) | 0x00000200) | 0x00000400) | 0x00000800) | 0x00001000) | 0x00002000) | 0x00004000) | 0x00008000) | 0x00010000) | 0x00080000)) + *(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) &= libc.Uint32FromInt32(libc.CplInt32((((((((((((SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_MAIN_DB) | SQLITE_OPEN_TEMP_DB) | SQLITE_OPEN_TRANSIENT_DB) | SQLITE_OPEN_MAIN_JOURNAL) | SQLITE_OPEN_TEMP_JOURNAL) | SQLITE_OPEN_SUBJOURNAL) | SQLITE_OPEN_SUPER_JOURNAL) | SQLITE_OPEN_NOMUTEX) | SQLITE_OPEN_FULLMUTEX) | SQLITE_OPEN_WAL))) // Allocate the sqlite data structure db = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(Sqlite3{}))) @@ -145119,7 +142749,7 @@ __11: if !(isThreadsafe != 0) { goto __12 } - (*Sqlite3)(unsafe.Pointer(db)).Fmutex = Xsqlite3MutexAlloc(tls, 1) + (*Sqlite3)(unsafe.Pointer(db)).Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_RECURSIVE) if !((*Sqlite3)(unsafe.Pointer(db)).Fmutex == uintptr(0)) { goto __13 } @@ -145139,23 +142769,23 @@ __12: Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) (*Sqlite3)(unsafe.Pointer(db)).FerrMask = 0xff (*Sqlite3)(unsafe.Pointer(db)).FnDb = 2 - (*Sqlite3)(unsafe.Pointer(db)).Fmagic = 0xf03b7906 + (*Sqlite3)(unsafe.Pointer(db)).Fmagic = SQLITE_MAGIC_BUSY (*Sqlite3)(unsafe.Pointer(db)).FaDb = db + 648 /* &.aDbStatic */ (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = U32(1) (*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0) libc.Xmemcpy(tls, db+124 /* &.aLimit */, uintptr(unsafe.Pointer(&aHardLimit)), uint64(unsafe.Sizeof([12]int32{}))) - *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(11)*4)) = 0 + *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 11*4)) = SQLITE_DEFAULT_WORKER_THREADS (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1) (*Sqlite3)(unsafe.Pointer(db)).FnextAutovac = int8(-1) (*Sqlite3)(unsafe.Pointer(db)).FszMmap = Xsqlite3Config.FszMmap (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize = 0 (*Sqlite3)(unsafe.Pointer(db)).FnMaxSorterMmap = 0x7FFFFFFF - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(((((((uint32(0x00000040 | - 0x00040000)) | - 0x80000000) | - uint32(0x00000020)) | - uint32(0x00000080)) | + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(((((((uint32(SQLITE_ShortColNames | + SQLITE_EnableTrigger)) | + SQLITE_EnableView) | + SQLITE_CacheSpill) | + SQLITE_TrustedSchema) | // The SQLITE_DQS compile-time option determines the default settings // for SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML. // @@ -145170,10 +142800,10 @@ __12: // Legacy behavior is 3 (double-quoted string literals are allowed anywhere) // and so that is the default. But developers are encouranged to use // -DSQLITE_DQS=0 (best) or -DSQLITE_DQS=1 (second choice) if possible. - uint32(0x40000000)) | - uint32(0x20000000)) | + SQLITE_DqsDML) | + SQLITE_DqsDDL) | - uint32(0x00008000))) + SQLITE_AutoIndex)) Xsqlite3HashInit(tls, (db + 600 /* &.aCollSeq */)) Xsqlite3HashInit(tls, (db + 528 /* &.aModule */)) @@ -145183,19 +142813,19 @@ __12: // // EVIDENCE-OF: R-52786-44878 SQLite defines three built-in collating // functions: - createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), uint8(1), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{binCollFunc})), uintptr(0)) - createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), uint8(3), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), SQLITE_UTF16BE, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{binCollFunc})), uintptr(0)) - createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), uint8(2), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), SQLITE_UTF16LE, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{binCollFunc})), uintptr(0)) - createCollation(tls, db, ts+19183 /* "NOCASE" */, uint8(1), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + createCollation(tls, db, ts+19183 /* "NOCASE" */, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{nocaseCollatingFunc})), uintptr(0)) - createCollation(tls, db, ts+21589 /* "RTRIM" */, uint8(1), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + createCollation(tls, db, ts+21589 /* "RTRIM" */, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{rtrimCollFunc})), uintptr(0)) if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { @@ -145230,10 +142860,10 @@ __16: rc = Xsqlite3ParseUri(tls, zVfs, zFilename, bp+8 /* &flags */, (db /* &.pVfs */), bp+16 /* &zOpen */, bp+24 /* &zErrMsg */) __17: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __18 } - if !(rc == 7) { + if !(rc == SQLITE_NOMEM) { goto __19 } Xsqlite3OomFault(tls, db) @@ -145251,40 +142881,40 @@ __18: ; // Open the backend database driver - rc = Xsqlite3BtreeOpen(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, *(*uintptr)(unsafe.Pointer(bp + 16 /* zOpen */)), db, ((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32 + 8 /* &.pBt */), 0, - (int32(*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) | uint32(0x00000100)))) - if !(rc != 0) { + rc = Xsqlite3BtreeOpen(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, *(*uintptr)(unsafe.Pointer(bp + 16 /* zOpen */)), db, ((*Sqlite3)(unsafe.Pointer(db)).FaDb + 8 /* &.pBt */), 0, + (int32(*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) | SQLITE_OPEN_MAIN_DB))) + if !(rc != SQLITE_OK) { goto __20 } - if !(rc == (10 | (int32(12) << 8))) { + if !(rc == (SQLITE_IOERR | (int32(12) << 8))) { goto __21 } - rc = 7 + rc = SQLITE_NOMEM __21: ; Xsqlite3Error(tls, db, rc) goto opendb_out __20: ; - Xsqlite3BtreeEnter(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt) - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FpSchema = Xsqlite3SchemaGet(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt) + Xsqlite3BtreeEnter(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt) + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema = Xsqlite3SchemaGet(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt) if !(!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0)) { goto __22 } - Xsqlite3SetTextEncoding(tls, db, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(0)*32)).FpSchema)).Fenc) + Xsqlite3SetTextEncoding(tls, db, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb)).FpSchema)).Fenc) __22: ; - Xsqlite3BtreeLeave(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt) - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(1)*32)).FpSchema = Xsqlite3SchemaGet(tls, db, uintptr(0)) + Xsqlite3BtreeLeave(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt) + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*32)).FpSchema = Xsqlite3SchemaGet(tls, db, uintptr(0)) // The default safety_level for the main database is FULL; for the temp // database it is OFF. This matches the pager layer defaults. - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FzDbSName = ts + 5282 /* "main" */ - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).Fsafety_level = (U8(2 + 1)) - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(1)*32)).FzDbSName = ts + 20591 /* "temp" */ - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(1)*32)).Fsafety_level = U8(0x01) + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName = ts + 5282 /* "main" */ + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).Fsafety_level = (U8(SQLITE_DEFAULT_SYNCHRONOUS + 1)) + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*32)).FzDbSName = ts + 20591 /* "temp" */ + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*32)).Fsafety_level = PAGER_SYNCHRONOUS_OFF - (*Sqlite3)(unsafe.Pointer(db)).Fmagic = 0xa029a697 + (*Sqlite3)(unsafe.Pointer(db)).Fmagic = SQLITE_MAGIC_OPEN if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __23 } @@ -145295,14 +142925,14 @@ __23: // Register all built-in functions, but do not attempt to read the // database schema yet. This is delayed until the first time the database // is accessed. - Xsqlite3Error(tls, db, 0) + Xsqlite3Error(tls, db, SQLITE_OK) Xsqlite3RegisterPerConnectionBuiltinFunctions(tls, db) rc = Xsqlite3_errcode(tls, db) // Load compiled-in extensions i = 0 __24: - if !((rc == 0) && (i < (int32(uint64(unsafe.Sizeof(sqlite3BuiltinExtensions)) / uint64(unsafe.Sizeof(uintptr(0))))))) { + if !((rc == SQLITE_OK) && (i < (int32(uint64(unsafe.Sizeof(sqlite3BuiltinExtensions)) / uint64(unsafe.Sizeof(uintptr(0))))))) { goto __26 } rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&sqlite3BuiltinExtensions)) + uintptr(i)*8))))(tls, db) @@ -145316,12 +142946,12 @@ __26: // Load automatic extensions - extensions that have been registered // using the sqlite3_automatic_extension() API. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __27 } Xsqlite3AutoLoadExtensions(tls, db) rc = Xsqlite3_errcode(tls, db) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __28 } goto opendb_out @@ -145345,7 +142975,7 @@ __29: setupLookaside(tls, db, uintptr(0), Xsqlite3Config.FszLookaside, Xsqlite3Config.FnLookaside) - Xsqlite3_wal_autocheckpoint(tls, db, 1000) + Xsqlite3_wal_autocheckpoint(tls, db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT) opendb_out: if !(db != 0) { @@ -145357,17 +142987,17 @@ __30: ; rc = Xsqlite3_errcode(tls, db) - if !(rc == 7) { + if !(rc == SQLITE_NOMEM) { goto __31 } Xsqlite3_close(tls, db) db = uintptr(0) goto __32 __31: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __33 } - (*Sqlite3)(unsafe.Pointer(db)).Fmagic = U32(0x4b771290) + (*Sqlite3)(unsafe.Pointer(db)).Fmagic = SQLITE_MAGIC_SICK __33: ; __32: @@ -145380,7 +143010,7 @@ __32: // Open a new database handle. func Xsqlite3_open(tls *libc.TLS, zFilename uintptr, ppDb uintptr) int32 { /* sqlite3.c:164386:16: */ return openDatabase(tls, zFilename, ppDb, - (uint32(0x00000002 | 0x00000004)), uintptr(0)) + (uint32(SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)), uintptr(0)) } func Xsqlite3_open_v2(tls *libc.TLS, filename uintptr, ppDb uintptr, flags int32, zVfs uintptr) int32 { /* sqlite3.c:164393:16: */ @@ -145402,17 +143032,17 @@ func Xsqlite3_open16(tls *libc.TLS, zFilename uintptr, ppDb uintptr) int32 { /* zFilename = ts + 21595 /* "\x00\x00" */ } pVal = Xsqlite3ValueNew(tls, uintptr(0)) - Xsqlite3ValueSetStr(tls, pVal, -1, zFilename, uint8(2), uintptr(0)) - zFilename8 = Xsqlite3ValueText(tls, pVal, uint8(1)) + Xsqlite3ValueSetStr(tls, pVal, -1, zFilename, SQLITE_UTF16LE, uintptr(0)) + zFilename8 = Xsqlite3ValueText(tls, pVal, SQLITE_UTF8) if zFilename8 != 0 { rc = openDatabase(tls, zFilename8, ppDb, - (uint32(0x00000002 | 0x00000004)), uintptr(0)) + (uint32(SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)), uintptr(0)) - if (rc == 0) && !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(ppDb))))).FaDb+uintptr(0)*32)).FpSchema)).FschemaFlags) & (0x0001)) == (0x0001)) { - ((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(ppDb))))).FaDb + uintptr(0)*32)).FpSchema)).Fenc) = libc.AssignPtrUint8(*(*uintptr)(unsafe.Pointer(ppDb))+94 /* &.enc */, U8(2)) + if (rc == SQLITE_OK) && !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(ppDb))))).FaDb)).FpSchema)).FschemaFlags) & (DB_SchemaLoaded)) == (DB_SchemaLoaded)) { + ((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(ppDb))))).FaDb)).FpSchema)).Fenc) = libc.AssignPtrUint8(*(*uintptr)(unsafe.Pointer(ppDb))+94 /* &.enc */, SQLITE_UTF16LE) } } else { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3ValueFree(tls, pVal) @@ -145438,12 +143068,12 @@ func Xsqlite3_create_collation_v2(tls *libc.TLS, db uintptr, zName uintptr, enc // Register a new collation sequence with the database handle db. func Xsqlite3_create_collation16(tls *libc.TLS, db uintptr, zName uintptr, enc int32, pCtx uintptr, xCompare uintptr) int32 { /* sqlite3.c:164483:16: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var zName8 uintptr Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - zName8 = Xsqlite3Utf16to8(tls, db, zName, -1, uint8(2)) + zName8 = Xsqlite3Utf16to8(tls, db, zName, -1, SQLITE_UTF16LE) if zName8 != 0 { rc = createCollation(tls, db, zName8, U8(enc), pCtx, xCompare, uintptr(0)) Xsqlite3DbFree(tls, db, zName8) @@ -145461,7 +143091,7 @@ func Xsqlite3_collation_needed(tls *libc.TLS, db uintptr, pCollNeededArg uintptr (*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded16 = uintptr(0) (*Sqlite3)(unsafe.Pointer(db)).FpCollNeededArg = pCollNeededArg Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // Register a collation sequence factory callback with the database handle @@ -145472,13 +143102,13 @@ func Xsqlite3_collation_needed16(tls *libc.TLS, db uintptr, pCollNeededArg uintp (*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded16 = xCollNeeded16 (*Sqlite3)(unsafe.Pointer(db)).FpCollNeededArg = pCollNeededArg Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // This function is now an anachronism. It used to be used to recover from a // malloc() failure, but SQLite now does this automatically. func Xsqlite3_global_recover(tls *libc.TLS) int32 { /* sqlite3.c:164556:16: */ - return 0 + return SQLITE_OK } // Test to see whether or not the database connection is in autocommit @@ -145509,17 +143139,17 @@ func Xsqlite3ReportError(tls *libc.TLS, iErr int32, lineno int32, zType uintptr) func Xsqlite3CorruptError(tls *libc.TLS, lineno int32) int32 { /* sqlite3.c:164593:20: */ - return Xsqlite3ReportError(tls, 11, lineno, ts+21623 /* "database corrupt..." */) + return Xsqlite3ReportError(tls, SQLITE_CORRUPT, lineno, ts+21623 /* "database corrupt..." */) } func Xsqlite3MisuseError(tls *libc.TLS, lineno int32) int32 { /* sqlite3.c:164597:20: */ - return Xsqlite3ReportError(tls, 21, lineno, ts+21643 /* "misuse" */) + return Xsqlite3ReportError(tls, SQLITE_MISUSE, lineno, ts+21643 /* "misuse" */) } func Xsqlite3CantopenError(tls *libc.TLS, lineno int32) int32 { /* sqlite3.c:164601:20: */ - return Xsqlite3ReportError(tls, 14, lineno, ts+21650 /* "cannot open file" */) + return Xsqlite3ReportError(tls, SQLITE_CANTOPEN, lineno, ts+21650 /* "cannot open file" */) } // This is a convenience routine that makes sure that all thread-specific @@ -145561,7 +143191,7 @@ func Xsqlite3_table_column_metadata(tls *libc.TLS, db uintptr, zDbName uintptr, Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) Xsqlite3BtreeEnterAll(tls, db) rc = Xsqlite3Init(tls, db, bp+24 /* &zErrMsg */) - if !(0 != rc) { + if !(SQLITE_OK != rc) { goto __1 } goto error_out @@ -145607,7 +143237,7 @@ __7: if !(iCol == int32((*Table)(unsafe.Pointer(pTab)).FnCol)) { goto __9 } - if !((((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) && (Xsqlite3IsRowid(tls, zColumnName) != 0)) { + if !((((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && (Xsqlite3IsRowid(tls, zColumnName) != 0)) { goto __10 } iCol = int32((*Table)(unsafe.Pointer(pTab)).FiPKey) @@ -145642,8 +143272,8 @@ __4: zDataType = Xsqlite3ColumnType(tls, pCol, uintptr(0)) zCollSeq = (*Column)(unsafe.Pointer(pCol)).FzColl notnull = (libc.Bool32(int32((*Column)(unsafe.Pointer(pCol)).FnotNull) != 0)) - primarykey = (libc.Bool32((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0001) != 0)) - autoinc = (libc.Bool32((int32((*Table)(unsafe.Pointer(pTab)).FiPKey) == iCol) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0008)) != U32(0)))) + primarykey = (libc.Bool32((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_PRIMKEY) != 0)) + autoinc = (libc.Bool32((int32((*Table)(unsafe.Pointer(pTab)).FiPKey) == iCol) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Autoincrement) != U32(0)))) goto __13 __12: zDataType = ts + 10507 /* "INTEGER" */ @@ -145694,13 +143324,13 @@ __18: __19: ; - if !((0 == rc) && !(pTab != 0)) { + if !((SQLITE_OK == rc) && !(pTab != 0)) { goto __20 } Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 24 /* zErrMsg */))) *(*uintptr)(unsafe.Pointer(bp + 24 /* zErrMsg */)) = Xsqlite3MPrintf(tls, db, ts+21667 /* "no such table co..." */, libc.VaList(bp, zTableName, zColumnName)) - rc = 1 + rc = SQLITE_ERROR __20: ; Xsqlite3ErrorWithMsg(tls, db, rc, func() uintptr { @@ -145740,12 +143370,12 @@ func Xsqlite3_extended_result_codes(tls *libc.TLS, db uintptr, onoff int32) int3 return 0xff }() Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // Invoke the xFileControl method on a particular database. func Xsqlite3_file_control(tls *libc.TLS, db uintptr, zDbName uintptr, op int32, pArg uintptr) int32 { /* sqlite3.c:164787:16: */ - var rc int32 = 1 + var rc int32 = SQLITE_ERROR var pBtree uintptr Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -145758,25 +143388,25 @@ func Xsqlite3_file_control(tls *libc.TLS, db uintptr, zDbName uintptr, op int32, fd = Xsqlite3PagerFile(tls, pPager) - if op == 7 { + if op == SQLITE_FCNTL_FILE_POINTER { *(*uintptr)(unsafe.Pointer(pArg)) = fd - rc = 0 - } else if op == 27 { + rc = SQLITE_OK + } else if op == SQLITE_FCNTL_VFS_POINTER { *(*uintptr)(unsafe.Pointer(pArg)) = Xsqlite3PagerVfs(tls, pPager) - rc = 0 - } else if op == 28 { + rc = SQLITE_OK + } else if op == SQLITE_FCNTL_JOURNAL_POINTER { *(*uintptr)(unsafe.Pointer(pArg)) = Xsqlite3PagerJrnlFile(tls, pPager) - rc = 0 - } else if op == 35 { + rc = SQLITE_OK + } else if op == SQLITE_FCNTL_DATA_VERSION { *(*uint32)(unsafe.Pointer(pArg)) = Xsqlite3PagerDataVersion(tls, pPager) - rc = 0 - } else if op == 38 { + rc = SQLITE_OK + } else if op == SQLITE_FCNTL_RESERVE_BYTES { var iNew int32 = *(*int32)(unsafe.Pointer(pArg)) *(*int32)(unsafe.Pointer(pArg)) = Xsqlite3BtreeGetRequestedReserve(tls, pBtree) if (iNew >= 0) && (iNew <= 255) { Xsqlite3BtreeSetPageSize(tls, pBtree, 0, iNew, 0) } - rc = 0 + rc = SQLITE_OK } else { rc = Xsqlite3OsFileControl(tls, fd, op, pArg) } @@ -145795,7 +143425,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit switch op { // Save the current state of the PRNG. - case 5: + case SQLITE_TESTCTRL_PRNG_SAVE: { Xsqlite3PrngSaveState(tls) break @@ -145805,7 +143435,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // Restore the state of the PRNG to the last state saved using // PRNG_SAVE. If PRNG_SAVE has never before been called, then // this verb acts like PRNG_RESET. - case 6: + case SQLITE_TESTCTRL_PRNG_RESTORE: { Xsqlite3PrngRestoreState(tls) break @@ -145831,13 +143461,13 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // // This test-control also resets the PRNG so that the new seed will // be used for the next call to sqlite3_randomness(). - case 28: + case SQLITE_TESTCTRL_PRNG_SEED: { var x int32 = int32(libc.VaInt32(&ap)) var y int32 var db uintptr = libc.VaUintptr(&ap) - if (db != 0) && ((libc.AssignInt32(&y, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpSchema)).Fschema_cookie)) != 0) { + if (db != 0) && ((libc.AssignInt32(&y, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema)).Fschema_cookie)) != 0) { x = y } Xsqlite3Config.FiPrngSeed = uint32(x) @@ -145852,7 +143482,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // is an array of integers that defines the test. Return -1 on a // memory allocation error, 0 on success, or non-zero for an error. // See the sqlite3BitvecBuiltinTest() for additional information. - case 8: + case SQLITE_TESTCTRL_BITVEC_TEST: { var sz int32 = int32(libc.VaInt32(&ap)) var aProg uintptr = libc.VaUintptr(&ap) @@ -145870,7 +143500,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // is called immediately after installing the new callback and the return // value from sqlite3FaultSim(0) becomes the return from // sqlite3_test_control(). - case 9: + case SQLITE_TESTCTRL_FAULT_INSTALL: { Xsqlite3Config.FxTestCallback = libc.VaUintptr(&ap) rc = Xsqlite3FaultSim(tls, 0) @@ -145882,7 +143512,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // // Register hooks to call to indicate which malloc() failures // are benign. - case 10: + case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: { var xBenignBegin uintptr var xBenignEnd uintptr @@ -145903,7 +143533,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // an incompatible database file format. Changing the PENDING byte // while any database connection is open results in undefined and // deleterious behavior. - case 11: + case SQLITE_TESTCTRL_PENDING_BYTE: { rc = Xsqlite3PendingByte { @@ -145926,7 +143556,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // false and assert() is enabled, then the assertion fires and the // process aborts. If X is false and assert() is disabled, then the // return value is zero. - case 12: + case SQLITE_TESTCTRL_ASSERT: { var x int32 = 0 @@ -145960,7 +143590,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // }else{ // // ALWAYS(x) is a constant 1. NEVER(x) is a constant 0. // } - case 13: + case SQLITE_TESTCTRL_ALWAYS: { var x int32 = int32(libc.VaInt32(&ap)) if x != 0 { @@ -145981,9 +143611,9 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // 10 little-endian, determined at run-time // 432101 big-endian, determined at compile-time // 123410 little-endian, determined at compile-time - case 22: + case SQLITE_TESTCTRL_BYTEORDER: { - rc = (((1234 * 100) + (1 * 10)) + 0) + rc = (((SQLITE_BYTEORDER * 100) + (SQLITE_LITTLEENDIAN * 10)) + SQLITE_BIGENDIAN) break } @@ -145996,10 +143626,10 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // SQL Logic Test or SLT test module) can run the same SQL multiple times // with various optimizations disabled to verify that the same answer // is obtained in every case. - case 15: + case SQLITE_TESTCTRL_OPTIMIZATIONS: { var db uintptr = libc.VaUintptr(&ap) - (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags = (U16(int32(libc.VaInt32(&ap)) & 0xffff)) + (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags = (U16((int32(libc.VaInt32(&ap))) & 0xffff)) break } @@ -146008,7 +143638,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // // If parameter onoff is non-zero, subsequent calls to localtime() // and its variants fail. If onoff is zero, undo this setting. - case 18: + case SQLITE_TESTCTRL_LOCALTIME_FAULT: { Xsqlite3Config.FbLocaltimeFault = int32(libc.VaInt32(&ap)) break @@ -146019,10 +143649,10 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // // Toggle the ability to use internal functions on or off for // the database connection given in the argument. - case 17: + case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS: { var db uintptr = libc.VaUintptr(&ap) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) ^= (U32(0x0020)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) ^= (DBFLAG_InternalFunc) break } @@ -146034,7 +143664,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // database files might have arbitrary corruption. Setting the flag during // testing causes certain assert() statements in the code to be activated // that demonstrat invariants on well-formed database files. - case 20: + case SQLITE_TESTCTRL_NEVER_CORRUPT: { Xsqlite3Config.FneverCorrupt = int32(libc.VaInt32(&ap)) break @@ -146052,7 +143682,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // is useful to make it easier to reach strange internal error states // during testing. The EXTRA_SCHEMA_CHECKS setting is always enabled // in production. - case 29: + case SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS: { Xsqlite3Config.FbExtraSchemaChecks = U8(libc.VaInt32(&ap)) break @@ -146063,7 +143693,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // By default this is 0x7ffffffe (over 2 billion), but that value is // too big to test in a reasonable amount of time, so this control is // provided to set a small and easily reachable reset value. - case 19: + case SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD: { Xsqlite3Config.FiOnceResetThreshold = int32(libc.VaInt32(&ap)) break @@ -146074,14 +143704,14 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // // Set the VDBE coverage callback function to xCallback with context // pointer ptr. - case 21: + case SQLITE_TESTCTRL_VDBE_COVERAGE: { break } // sqlite3_test_control(SQLITE_TESTCTRL_SORTER_MMAP, db, nMax); - case 24: + case SQLITE_TESTCTRL_SORTER_MMAP: { var db uintptr = libc.VaUintptr(&ap) (*Sqlite3)(unsafe.Pointer(db)).FnMaxSorterMmap = int32(libc.VaInt32(&ap)) @@ -146093,10 +143723,10 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // // Return SQLITE_OK if SQLite has been initialized and SQLITE_ERROR if // not. - case 23: + case SQLITE_TESTCTRL_ISINIT: { if Xsqlite3Config.FisInit == 0 { - rc = 1 + rc = SQLITE_ERROR } break @@ -146117,7 +143747,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // If onOff==0 and tnum>0 then reset the schema for all databases, causing // the schema to be reparsed the next time it is needed. This has the // effect of erasing all imposter tables. - case 25: + case SQLITE_TESTCTRL_IMPOSTER: { var db uintptr = libc.VaUintptr(&ap) Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -146141,7 +143771,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // test-control enables us to write an intreal() SQL function that can // inject an intreal() value at arbitrary places in an SQL statement, // for testing purposes. - case 27: + case SQLITE_TESTCTRL_RESULT_INTREAL: { var pCtx uintptr = libc.VaUintptr(&ap) Xsqlite3ResultIntReal(tls, pCtx) @@ -146244,11 +143874,11 @@ func Xsqlite3_uri_key(tls *libc.TLS, zFilename uintptr, N int32) uintptr { /* sq } zFilename = databaseName(tls, zFilename) zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) - for (*(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0) && ((libc.PostDecInt32(&N, 1)) > 0) { + for (*(*int8)(unsafe.Pointer(zFilename)) != 0) && ((libc.PostDecInt32(&N, 1)) > 0) { zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) } - if *(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0 { + if *(*int8)(unsafe.Pointer(zFilename)) != 0 { return zFilename } return uintptr(0) @@ -146293,7 +143923,7 @@ func Xsqlite3_filename_database(tls *libc.TLS, zFilename uintptr) uintptr { /* s func Xsqlite3_filename_journal(tls *libc.TLS, zFilename uintptr) uintptr { /* sqlite3.c:165359:23: */ zFilename = databaseName(tls, zFilename) zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) - for *(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(zFilename)) != 0 { zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) } @@ -146345,7 +143975,7 @@ func Xsqlite3_db_readonly(tls *libc.TLS, db uintptr, zDbName uintptr) int32 { /* // Obtain a snapshot handle for the snapshot of database zDb currently // being read by handle db. func Xsqlite3_snapshot_get(tls *libc.TLS, db uintptr, zDb uintptr, ppSnapshot uintptr) int32 { /* sqlite3.c:165423:16: */ - var rc int32 = 1 + var rc int32 = SQLITE_ERROR Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -146355,7 +143985,7 @@ func Xsqlite3_snapshot_get(tls *libc.TLS, db uintptr, zDb uintptr, ppSnapshot ui var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpBt if 0 == Xsqlite3BtreeIsInTrans(tls, pBt) { rc = Xsqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerSnapshotGet(tls, Xsqlite3BtreePager(tls, pBt), ppSnapshot) } } @@ -146368,7 +143998,7 @@ func Xsqlite3_snapshot_get(tls *libc.TLS, db uintptr, zDb uintptr, ppSnapshot ui // Open a read-transaction on the snapshot idendified by pSnapshot. func Xsqlite3_snapshot_open(tls *libc.TLS, db uintptr, zDb uintptr, pSnapshot uintptr) int32 { /* sqlite3.c:165459:16: */ - var rc int32 = 1 + var rc int32 = SQLITE_ERROR Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) if int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 { @@ -146382,18 +144012,18 @@ func Xsqlite3_snapshot_open(tls *libc.TLS, db uintptr, zDb uintptr, pSnapshot ui if Xsqlite3BtreeIsInReadTrans(tls, pBt) != 0 { if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 { rc = Xsqlite3PagerSnapshotCheck(tls, pPager, pSnapshot) - if rc == 0 { + if rc == SQLITE_OK { bUnlock = 1 rc = Xsqlite3BtreeCommit(tls, pBt) } } } else { - rc = 0 + rc = SQLITE_OK } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerSnapshotOpen(tls, pPager, pSnapshot) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0)) Xsqlite3PagerSnapshotOpen(tls, pPager, uintptr(0)) } @@ -146411,7 +144041,7 @@ func Xsqlite3_snapshot_open(tls *libc.TLS, db uintptr, zDb uintptr, pSnapshot ui // Recover as many snapshots as possible from the wal file associated with // schema zDb of database db. func Xsqlite3_snapshot_recover(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* sqlite3.c:165515:16: */ - var rc int32 = 1 + var rc int32 = SQLITE_ERROR var iDb int32 Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -146420,7 +144050,7 @@ func Xsqlite3_snapshot_recover(tls *libc.TLS, db uintptr, zDb uintptr) int32 { / var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpBt if 0 == Xsqlite3BtreeIsInReadTrans(tls, pBt) { rc = Xsqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerSnapshotRecover(tls, Xsqlite3BtreePager(tls, pBt)) Xsqlite3BtreeCommit(tls, pBt) } @@ -146543,14 +144173,14 @@ func addToBlockedList(tls *libc.TLS, db uintptr) { /* sqlite3.c:165702:13: */ // Obtain the STATIC_MAIN mutex. func enterMutex(tls *libc.TLS) { /* sqlite3.c:165717:13: */ - Xsqlite3_mutex_enter(tls, Xsqlite3MutexAlloc(tls, 2)) + Xsqlite3_mutex_enter(tls, Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)) } // Release the STATIC_MAIN mutex. func leaveMutex(tls *libc.TLS) { /* sqlite3.c:165725:13: */ - Xsqlite3_mutex_leave(tls, Xsqlite3MutexAlloc(tls, 2)) + Xsqlite3_mutex_leave(tls, Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)) } // Register an unlock-notify callback. @@ -146577,7 +144207,7 @@ func Xsqlite3_unlock_notify(tls *libc.TLS, db uintptr, xNotify uintptr, pArg uin defer tls.Free(8) *(*uintptr)(unsafe.Pointer(bp)) = pArg - var rc int32 = 0 + var rc int32 = SQLITE_OK Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) enterMutex(tls) @@ -146599,7 +144229,7 @@ func Xsqlite3_unlock_notify(tls *libc.TLS, db uintptr, xNotify uintptr, pArg uin for p = (*Sqlite3)(unsafe.Pointer(db)).FpBlockingConnection; (p != 0) && (p != db); p = (*Sqlite3)(unsafe.Pointer(p)).FpUnlockConnection { } if p != 0 { - rc = 6 // Deadlock detected. + rc = SQLITE_LOCKED // Deadlock detected. } else { (*Sqlite3)(unsafe.Pointer(db)).FpUnlockConnection = (*Sqlite3)(unsafe.Pointer(db)).FpBlockingConnection (*Sqlite3)(unsafe.Pointer(db)).FxUnlockNotify = xNotify @@ -147475,7 +145105,7 @@ func jsonGrow(tls *libc.TLS, p uintptr, N U32) int32 { /* sqlite3.c:185658:12: * zNew = Xsqlite3_malloc64(tls, nTotal) if zNew == uintptr(0) { jsonOom(tls, p) - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, zNew, (*JsonString)(unsafe.Pointer(p)).FzBuf, Size_t((*JsonString)(unsafe.Pointer(p)).FnUsed)) (*JsonString)(unsafe.Pointer(p)).FzBuf = zNew @@ -147484,12 +145114,12 @@ func jsonGrow(tls *libc.TLS, p uintptr, N U32) int32 { /* sqlite3.c:185658:12: * zNew = Xsqlite3_realloc64(tls, (*JsonString)(unsafe.Pointer(p)).FzBuf, nTotal) if zNew == uintptr(0) { jsonOom(tls, p) - return 7 + return SQLITE_NOMEM } (*JsonString)(unsafe.Pointer(p)).FzBuf = zNew } (*JsonString)(unsafe.Pointer(p)).FnAlloc = nTotal - return 0 + return SQLITE_OK } // Append N bytes from zIn onto the end of the JsonString string. @@ -147619,15 +145249,15 @@ var aSpecial = [32]int8{ // construction. func jsonAppendValue(tls *libc.TLS, p uintptr, pValue uintptr) { /* sqlite3.c:185768:13: */ switch Xsqlite3_value_type(tls, pValue) { - case 5: + case SQLITE_NULL: { jsonAppendRaw(tls, p, ts+5082 /* "null" */, uint32(4)) break } - case 1: + case SQLITE_INTEGER: fallthrough - case 2: + case SQLITE_FLOAT: { var z uintptr = Xsqlite3_value_text(tls, pValue) var n U32 = U32(Xsqlite3_value_bytes(tls, pValue)) @@ -147635,11 +145265,11 @@ func jsonAppendValue(tls *libc.TLS, p uintptr, pValue uintptr) { /* sqlite3.c:18 break } - case 3: + case SQLITE_TEXT: { var z uintptr = Xsqlite3_value_text(tls, pValue) var n U32 = U32(Xsqlite3_value_bytes(tls, pValue)) - if Xsqlite3_value_subtype(tls, pValue) == uint32(74) { + if Xsqlite3_value_subtype(tls, pValue) == JSON_SUBTYPE { jsonAppendRaw(tls, p, z, n) } else { jsonAppendString(tls, p, z, n) @@ -147670,7 +145300,7 @@ func jsonResult(tls *libc.TLS, p uintptr) { /* sqlite3.c:185808:13: */ } return *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})) }(), - uint8(1)) + SQLITE_UTF8) jsonZero(tls, p) } @@ -147689,7 +145319,7 @@ func jsonResult(tls *libc.TLS, p uintptr) { /* sqlite3.c:185808:13: */ // by which the JsonNode counter should increment in order to go to the // next peer value. func jsonNodeSize(tls *libc.TLS, pNode uintptr) U32 { /* sqlite3.c:185831:12: */ - if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) >= 6 { + if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) >= JSON_ARRAY { return ((*JsonNode)(unsafe.Pointer(pNode)).Fn + U32(1)) } return uint32(1) @@ -147716,8 +145346,8 @@ func jsonParseFree(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:185851:13: */ // append to pOut. Subsubstructure is also included. Return // the number of JsonNode objects that are encoded. func jsonRenderNode(tls *libc.TLS, pNode uintptr, pOut uintptr, aReplace uintptr) { /* sqlite3.c:185861:13: */ - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & (0x08 | 0x10)) != 0 { - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x08) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & (JNODE_REPLACE | JNODE_PATCH)) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_REPLACE) != 0 { jsonAppendValue(tls, pOut, *(*uintptr)(unsafe.Pointer(aReplace + uintptr(*(*U32)(unsafe.Pointer(pNode + 8 /* &.u */)))*8))) return } @@ -147731,49 +145361,48 @@ func jsonRenderNode(tls *libc.TLS, pNode uintptr, pOut uintptr, aReplace uintptr break } - case 1: + case JSON_TRUE: { jsonAppendRaw(tls, pOut, ts+6493 /* "true" */, uint32(4)) break } - case 2: + case JSON_FALSE: { jsonAppendRaw(tls, pOut, ts+6498 /* "false" */, uint32(5)) break } - case 5: + case JSON_STRING: { - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x01) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_RAW) != 0 { jsonAppendString(tls, pOut, *(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */)), (*JsonNode)(unsafe.Pointer(pNode)).Fn) break } - /* no break */ } fallthrough - case 4: + case JSON_REAL: fallthrough - case 3: + case JSON_INT: { jsonAppendRaw(tls, pOut, *(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */)), (*JsonNode)(unsafe.Pointer(pNode)).Fn) break } - case 6: + case JSON_ARRAY: { var j U32 = U32(1) jsonAppendChar(tls, pOut, int8('[')) for { for j <= (*JsonNode)(unsafe.Pointer(pNode)).Fn { - if (int32((*JsonNode)(unsafe.Pointer(pNode+uintptr(j)*16)).FjnFlags) & 0x04) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode+uintptr(j)*16)).FjnFlags) & JNODE_REMOVE) == 0 { jsonAppendSeparator(tls, pOut) jsonRenderNode(tls, (pNode + uintptr(j)*16), pOut, aReplace) } j = j + (jsonNodeSize(tls, (pNode + uintptr(j)*16))) } - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x20) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_APPEND) == 0 { break } pNode = (pNode + uintptr(*(*U32)(unsafe.Pointer(pNode + 8 /* &.u */)))*16) @@ -147783,13 +145412,13 @@ func jsonRenderNode(tls *libc.TLS, pNode uintptr, pOut uintptr, aReplace uintptr break } - case 7: + case JSON_OBJECT: { var j U32 = U32(1) jsonAppendChar(tls, pOut, int8('{')) for { for j <= (*JsonNode)(unsafe.Pointer(pNode)).Fn { - if (int32((*JsonNode)(unsafe.Pointer(pNode+uintptr((j+U32(1)))*16)).FjnFlags) & 0x04) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode+uintptr((j+U32(1)))*16)).FjnFlags) & JNODE_REMOVE) == 0 { jsonAppendSeparator(tls, pOut) jsonRenderNode(tls, (pNode + uintptr(j)*16), pOut, aReplace) jsonAppendChar(tls, pOut, int8(':')) @@ -147797,7 +145426,7 @@ func jsonRenderNode(tls *libc.TLS, pNode uintptr, pOut uintptr, aReplace uintptr } j = j + (U32(1) + jsonNodeSize(tls, (pNode+uintptr((j+U32(1)))*16))) } - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x20) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_APPEND) == 0 { break } pNode = (pNode + uintptr(*(*U32)(unsafe.Pointer(pNode + 8 /* &.u */)))*16) @@ -147820,7 +145449,7 @@ func jsonReturnJson(tls *libc.TLS, pNode uintptr, pCtx uintptr, aReplace uintptr jsonInit(tls, bp /* &s */, pCtx) jsonRenderNode(tls, pNode, bp /* &s */, aReplace) jsonResult(tls, bp /* &s */) - Xsqlite3_result_subtype(tls, pCtx, uint32(74)) + Xsqlite3_result_subtype(tls, pCtx, JSON_SUBTYPE) } // Translate a single byte of Hex into an integer. @@ -147836,10 +145465,10 @@ func jsonHexToInt(tls *libc.TLS, h int32) U8 { /* sqlite3.c:185960:11: */ func jsonHexToInt4(tls *libc.TLS, z uintptr) U32 { /* sqlite3.c:185973:12: */ var v U32 - v = (U32((((int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))))) << 12) + - (int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))))) << 8)) + - (int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + uintptr(2)))))) << 4)) + - int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + uintptr(3)))))))) + v = (U32((((int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z))))) << 12) + + (int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + 1))))) << 8)) + + (int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + 2))))) << 4)) + + int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + 3))))))) return v } @@ -147866,19 +145495,19 @@ func jsonReturn(tls *libc.TLS, pNode uintptr, pCtx uintptr, aReplace uintptr) { switch int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) { default: goto __2 - case 1: + case JSON_TRUE: goto __3 - case 2: + case JSON_FALSE: goto __4 - case 3: + case JSON_INT: goto __5 - case 4: + case JSON_REAL: goto __6 - case 5: + case JSON_STRING: goto __7 - case 6: + case JSON_ARRAY: goto __8 - case 7: + case JSON_OBJECT: goto __9 } goto __1 @@ -147898,14 +145527,14 @@ __4: __5: i = int64(0) z = *(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */)) - if !(int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '-') { + if !(int32(*(*int8)(unsafe.Pointer(z))) == '-') { goto __10 } z++ __10: ; __11: - if !((int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) <= '9')) { + if !((int32(*(*int8)(unsafe.Pointer(z))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z))) <= '9')) { goto __12 } v = (uint32(int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1)))) - '0')) @@ -147918,7 +145547,7 @@ __11: goto int_as_real __14: ; - if !((int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) <= '9')) { + if !((int32(*(*int8)(unsafe.Pointer(z))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z))) <= '9')) { goto __15 } goto int_as_real @@ -147933,7 +145562,7 @@ __16: if !(v == uint32(8)) { goto __17 } - if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */)) + uintptr(0)))) == '-') { + if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */))))) == '-') { goto __18 } Xsqlite3_result_int64(tls, pCtx, ((int64(-1)) - (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32)))) @@ -147951,7 +145580,7 @@ __13: goto __11 __12: ; - if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */)) + uintptr(0)))) == '-') { + if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */))))) == '-') { goto __20 } i = -i @@ -147961,17 +145590,17 @@ __20: int_done: goto __1 int_as_real: - i = int64(0) /* no break */ + i = int64(0) __6: z1 = *(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */)) - Xsqlite3AtoF(tls, z1, bp /* &r */, Xsqlite3Strlen30(tls, z1), uint8(1)) + Xsqlite3AtoF(tls, z1, bp /* &r */, Xsqlite3Strlen30(tls, z1), SQLITE_UTF8) Xsqlite3_result_double(tls, pCtx, *(*float64)(unsafe.Pointer(bp /* r */))) goto __1 __7: ; - if !((int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x02) == 0) { + if !((int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_ESCAPE) == 0) { goto __21 } // JSON formatted without any backslash-escapes @@ -148185,7 +145814,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 } if (int32(libc.AssignInt8(&c, *(*int8)(unsafe.Pointer(z + uintptr(i)))))) == '{' { // Parse object - iThis = jsonParseAddNode(tls, pParse, uint32(7), uint32(0), uintptr(0)) + iThis = jsonParseAddNode(tls, pParse, JSON_OBJECT, uint32(0), uintptr(0)) if iThis < 0 { return -1 } @@ -148193,7 +145822,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 for jsonIsSpace[uint8(*(*int8)(unsafe.Pointer(z + uintptr(j))))] != 0 { j++ } - if int32(libc.PreIncUint16(&(*JsonParse)(unsafe.Pointer(pParse)).FiDepth, 1)) > 2000 { + if int32(libc.PreIncUint16(&(*JsonParse)(unsafe.Pointer(pParse)).FiDepth, 1)) > JSON_MAX_DEPTH { return -1 } x = jsonParseValue(tls, pParse, j) @@ -148208,10 +145837,10 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 return -1 } pNode = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(((*JsonParse)(unsafe.Pointer(pParse)).FnNode-U32(1)))*16) - if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) != 5 { + if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) != JSON_STRING { return -1 } - *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((0x40)) + *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((JNODE_LABEL)) j = U32(x) for jsonIsSpace[uint8(*(*int8)(unsafe.Pointer(z + uintptr(j))))] != 0 { j++ @@ -148242,7 +145871,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 return (int32(j + U32(1))) } else if int32(c) == '[' { // Parse array - iThis = jsonParseAddNode(tls, pParse, uint32(6), uint32(0), uintptr(0)) + iThis = jsonParseAddNode(tls, pParse, JSON_ARRAY, uint32(0), uintptr(0)) if iThis < 0 { return -1 } @@ -148250,7 +145879,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 for jsonIsSpace[uint8(*(*int8)(unsafe.Pointer(z + uintptr(j))))] != 0 { j++ } - if int32(libc.PreIncUint16(&(*JsonParse)(unsafe.Pointer(pParse)).FiDepth, 1)) > 2000 { + if int32(libc.PreIncUint16(&(*JsonParse)(unsafe.Pointer(pParse)).FiDepth, 1)) > JSON_MAX_DEPTH { return -1 } x = jsonParseValue(tls, pParse, j) @@ -148282,7 +145911,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 j = (i + U32(1)) for { c = *(*int8)(unsafe.Pointer(z + uintptr(j))) - if (int32(c) & ^libc.Int32(0x1f)) == 0 { + if (int32(c) & libc.CplInt32(0x1f)) == 0 { // Control characters are not allowed in strings return -1 } @@ -148291,7 +145920,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 if ((((((((int32(c) == '"') || (int32(c) == '\\')) || (int32(c) == '/')) || (int32(c) == 'b')) || (int32(c) == 'f')) || (int32(c) == 'n')) || (int32(c) == 'r')) || (int32(c) == 't')) || ((int32(c) == 'u') && (jsonIs4Hex(tls, ((z+uintptr(j))+uintptr(1))) != 0)) { - jnFlags = U8(0x02) + jnFlags = JNODE_ESCAPE } else { return -1 } @@ -148300,7 +145929,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 } j++ } - jsonParseAddNode(tls, pParse, uint32(5), ((j + U32(1)) - i), (z + uintptr(i))) + jsonParseAddNode(tls, pParse, JSON_STRING, ((j + U32(1)) - i), (z + uintptr(i))) if !(int32((*JsonParse)(unsafe.Pointer(pParse)).Foom) != 0) { (*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(((*JsonParse)(unsafe.Pointer(pParse)).FnNode-U32(1)))*16)).FjnFlags = jnFlags } @@ -148308,17 +145937,17 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 } else if ((int32(c) == 'n') && (libc.Xstrncmp(tls, (z+uintptr(i)), ts+5082 /* "null" */, uint64(4)) == 0)) && !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr((i + U32(4))))))]) & 0x06) != 0) { - jsonParseAddNode(tls, pParse, uint32(0), uint32(0), uintptr(0)) + jsonParseAddNode(tls, pParse, JSON_NULL, uint32(0), uintptr(0)) return (int32(i + U32(4))) } else if ((int32(c) == 't') && (libc.Xstrncmp(tls, (z+uintptr(i)), ts+6493 /* "true" */, uint64(4)) == 0)) && !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr((i + U32(4))))))]) & 0x06) != 0) { - jsonParseAddNode(tls, pParse, uint32(1), uint32(0), uintptr(0)) + jsonParseAddNode(tls, pParse, JSON_TRUE, uint32(0), uintptr(0)) return (int32(i + U32(4))) } else if ((int32(c) == 'f') && (libc.Xstrncmp(tls, (z+uintptr(i)), ts+6498 /* "false" */, uint64(5)) == 0)) && !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr((i + U32(5))))))]) & 0x06) != 0) { - jsonParseAddNode(tls, pParse, uint32(2), uint32(0), uintptr(0)) + jsonParseAddNode(tls, pParse, JSON_FALSE, uint32(0), uintptr(0)) return (int32(i + U32(5))) } else if (int32(c) == '-') || ((int32(c) >= '0') && (int32(c) <= '9')) { // Parse number @@ -148376,9 +146005,9 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 } jsonParseAddNode(tls, pParse, func() uint32 { if seenDP != 0 { - return uint32(4) + return JSON_REAL } - return uint32(3) + return JSON_INT }(), (j - i), (z + uintptr(i))) return int32(j) @@ -148440,7 +146069,7 @@ func jsonParseFillInParentage(tls *libc.TLS, pParse uintptr, i U32, iParent U32) var j U32 *(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaUp + uintptr(i)*4)) = iParent switch int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) { - case 6: + case JSON_ARRAY: { for j = U32(1); j <= (*JsonNode)(unsafe.Pointer(pNode)).Fn; j = j + (jsonNodeSize(tls, (pNode + uintptr(j)*16))) { jsonParseFillInParentage(tls, pParse, (i + j), i) @@ -148448,7 +146077,7 @@ func jsonParseFillInParentage(tls *libc.TLS, pParse uintptr, i U32, iParent U32) break } - case 7: + case JSON_OBJECT: { for j = U32(1); j <= (*JsonNode)(unsafe.Pointer(pNode)).Fn; j = j + (jsonNodeSize(tls, ((pNode+uintptr(j)*16)+uintptr(1)*16)) + U32(1)) { *(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaUp + uintptr((i+j))*4)) = i @@ -148472,10 +146101,10 @@ func jsonParseFindParents(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:18 aUp = libc.AssignPtrUintptr(pParse+24 /* &.aUp */, Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(U32(0)))*uint64((*JsonParse)(unsafe.Pointer(pParse)).FnNode))))) if aUp == uintptr(0) { (*JsonParse)(unsafe.Pointer(pParse)).Foom = U8(1) - return 7 + return SQLITE_NOMEM } jsonParseFillInParentage(tls, pParse, uint32(0), uint32(0)) - return 0 + return SQLITE_OK } // Magic number used for the JSON parse cache in sqlite3_get_auxdata() @@ -148487,8 +146116,8 @@ func jsonParseFindParents(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:18 // and also register the new parse so that it will be available for // future sqlite3_get_auxdata() calls. func jsonParseCached(tls *libc.TLS, pCtx uintptr, argv uintptr, pErrCtx uintptr) uintptr { /* sqlite3.c:186461:18: */ - var zJson uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var nJson int32 = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zJson uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + var nJson int32 = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) var p uintptr var pMatch uintptr = uintptr(0) var iKey int32 @@ -148498,7 +146127,7 @@ func jsonParseCached(tls *libc.TLS, pCtx uintptr, argv uintptr, pErrCtx uintptr) if zJson == uintptr(0) { return uintptr(0) } - for iKey = 0; iKey < 4; iKey++ { + for iKey = 0; iKey < JSON_CACHE_SZ; iKey++ { p = Xsqlite3_get_auxdata(tls, pCtx, ((-429938) + iKey)) if p == uintptr(0) { iMinKey = iKey @@ -148528,7 +146157,7 @@ func jsonParseCached(tls *libc.TLS, pCtx uintptr, argv uintptr, pErrCtx uintptr) return uintptr(0) } libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(JsonParse{}))) - (*JsonParse)(unsafe.Pointer(p)).FzJson = (p + uintptr(1)*48) + (*JsonParse)(unsafe.Pointer(p)).FzJson = (p + 1*48) libc.Xmemcpy(tls, (*JsonParse)(unsafe.Pointer(p)).FzJson, zJson, (uint64(nJson + 1))) if jsonParse(tls, p, pErrCtx, (*JsonParse)(unsafe.Pointer(p)).FzJson) != 0 { Xsqlite3_free(tls, p) @@ -148544,7 +146173,7 @@ func jsonParseCached(tls *libc.TLS, pCtx uintptr, argv uintptr, pErrCtx uintptr) // Compare the OBJECT label at pNode against zKey,nKey. Return true on // a match. func jsonLabelCompare(tls *libc.TLS, pNode uintptr, zKey uintptr, nKey U32) int32 { /* sqlite3.c:186523:12: */ - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x01) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_RAW) != 0 { if (*JsonNode)(unsafe.Pointer(pNode)).Fn != nKey { return 0 } @@ -148571,18 +146200,18 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp var nKey U32 var zKey uintptr var pRoot uintptr = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*16) - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(zPath))) == 0 { return pRoot } - if (int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags) & 0x08) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags) & JNODE_REPLACE) != 0 { return uintptr(0) } - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) == '.' { - if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != 7 { + if int32(*(*int8)(unsafe.Pointer(zPath))) == '.' { + if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != JSON_OBJECT { return uintptr(0) } zPath++ - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) == '"' { + if int32(*(*int8)(unsafe.Pointer(zPath))) == '"' { zKey = (zPath + uintptr(1)) for i = U32(1); (*(*int8)(unsafe.Pointer(zPath + uintptr(i))) != 0) && (int32(*(*int8)(unsafe.Pointer(zPath + uintptr(i)))) != '"'); i++ { } @@ -148612,7 +146241,7 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp j++ j = j + (jsonNodeSize(tls, (pRoot + uintptr(j)*16))) } - if (int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags) & 0x20) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags) & JNODE_APPEND) == 0 { break } iRoot = iRoot + (*(*U32)(unsafe.Pointer(pRoot + 8 /* &.u */))) @@ -148623,8 +146252,8 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp var iStart U32 var iLabel U32 var pNode uintptr - iStart = U32(jsonParseAddNode(tls, pParse, uint32(7), uint32(2), uintptr(0))) - iLabel = U32(jsonParseAddNode(tls, pParse, uint32(5), nKey, zKey)) + iStart = U32(jsonParseAddNode(tls, pParse, JSON_OBJECT, uint32(2), uintptr(0))) + iLabel = U32(jsonParseAddNode(tls, pParse, JSON_STRING, nKey, zKey)) zPath += uintptr(i) pNode = jsonLookupAppend(tls, pParse, zPath, pApnd, pzErr) if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 { @@ -148633,12 +146262,12 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp if pNode != 0 { pRoot = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*16) *(*U32)(unsafe.Pointer(pRoot + 8 /* &.u */)) = (iStart - iRoot) - *(*U8)(unsafe.Pointer(pRoot + 1 /* &.jnFlags */)) |= U8((0x20)) - *(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iLabel)*16 + 1 /* &.jnFlags */)) |= U8((0x01)) + *(*U8)(unsafe.Pointer(pRoot + 1 /* &.jnFlags */)) |= U8((JNODE_APPEND)) + *(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iLabel)*16 + 1 /* &.jnFlags */)) |= U8((JNODE_RAW)) } return pNode } - } else if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) == '[' { + } else if int32(*(*int8)(unsafe.Pointer(zPath))) == '[' { i = U32(0) j = U32(1) for (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zPath + uintptr(j))))]) & 0x04) != 0 { @@ -148646,20 +146275,20 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp j++ } if (j < U32(2)) || (int32(*(*int8)(unsafe.Pointer(zPath + uintptr(j)))) != ']') { - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(1)))) == '#' { + if int32(*(*int8)(unsafe.Pointer(zPath + 1))) == '#' { var pBase uintptr = pRoot var iBase int32 = int32(iRoot) - if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != 6 { + if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != JSON_ARRAY { return uintptr(0) } for { for j <= (*JsonNode)(unsafe.Pointer(pBase)).Fn { - if (int32((*JsonNode)(unsafe.Pointer(pBase+uintptr(j)*16)).FjnFlags) & 0x04) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pBase+uintptr(j)*16)).FjnFlags) & JNODE_REMOVE) == 0 { i++ } j = j + (jsonNodeSize(tls, (pBase + uintptr(j)*16))) } - if (int32((*JsonNode)(unsafe.Pointer(pBase)).FjnFlags) & 0x20) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pBase)).FjnFlags) & JNODE_APPEND) == 0 { break } iBase = int32(U32(iBase) + (*(*U32)(unsafe.Pointer(pBase + 8 /* &.u */)))) @@ -148667,7 +146296,7 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp j = U32(1) } j = U32(2) - if (int32(*(*int8)(unsafe.Pointer(zPath + uintptr(2)))) == '-') && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zPath + uintptr(3))))]) & 0x04) != 0) { + if (int32(*(*int8)(unsafe.Pointer(zPath + 2))) == '-') && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zPath + 3)))]) & 0x04) != 0) { var x uint32 = uint32(0) j = U32(3) for ok := true; ok; ok = ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zPath + uintptr(j))))]) & 0x04) != 0) { @@ -148688,19 +146317,19 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp return uintptr(0) } } - if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != 6 { + if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != JSON_ARRAY { return uintptr(0) } zPath += (uintptr(j + U32(1))) j = U32(1) for { - for (j <= (*JsonNode)(unsafe.Pointer(pRoot)).Fn) && ((i > U32(0)) || ((int32((*JsonNode)(unsafe.Pointer(pRoot+uintptr(j)*16)).FjnFlags) & 0x04) != 0)) { - if (int32((*JsonNode)(unsafe.Pointer(pRoot+uintptr(j)*16)).FjnFlags) & 0x04) == 0 { + for (j <= (*JsonNode)(unsafe.Pointer(pRoot)).Fn) && ((i > U32(0)) || ((int32((*JsonNode)(unsafe.Pointer(pRoot+uintptr(j)*16)).FjnFlags) & JNODE_REMOVE) != 0)) { + if (int32((*JsonNode)(unsafe.Pointer(pRoot+uintptr(j)*16)).FjnFlags) & JNODE_REMOVE) == 0 { i-- } j = j + (jsonNodeSize(tls, (pRoot + uintptr(j)*16))) } - if (int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags) & 0x20) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags) & JNODE_APPEND) == 0 { break } iRoot = iRoot + (*(*U32)(unsafe.Pointer(pRoot + 8 /* &.u */))) @@ -148713,7 +146342,7 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp if (i == U32(0)) && (pApnd != 0) { var iStart U32 var pNode uintptr - iStart = U32(jsonParseAddNode(tls, pParse, uint32(6), uint32(1), uintptr(0))) + iStart = U32(jsonParseAddNode(tls, pParse, JSON_ARRAY, uint32(1), uintptr(0))) pNode = jsonLookupAppend(tls, pParse, zPath, pApnd, pzErr) if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 { return uintptr(0) @@ -148721,7 +146350,7 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp if pNode != 0 { pRoot = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*16) *(*U32)(unsafe.Pointer(pRoot + 8 /* &.u */)) = (iStart - iRoot) - *(*U8)(unsafe.Pointer(pRoot + 1 /* &.jnFlags */)) |= U8((0x20)) + *(*U8)(unsafe.Pointer(pRoot + 1 /* &.jnFlags */)) |= U8((JNODE_APPEND)) } return pNode } @@ -148735,17 +146364,17 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp // to the inserted node, or return NULL if the append fails. func jsonLookupAppend(tls *libc.TLS, pParse uintptr, zPath uintptr, pApnd uintptr, pzErr uintptr) uintptr { /* sqlite3.c:186690:17: */ *(*int32)(unsafe.Pointer(pApnd)) = 1 - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) == 0 { - jsonParseAddNode(tls, pParse, uint32(0), uint32(0), uintptr(0)) + if int32(*(*int8)(unsafe.Pointer(zPath))) == 0 { + jsonParseAddNode(tls, pParse, JSON_NULL, uint32(0), uintptr(0)) if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 { return uintptr(0) } return ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(((*JsonParse)(unsafe.Pointer(pParse)).FnNode-U32(1)))*16) } - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) == '.' { - jsonParseAddNode(tls, pParse, uint32(7), uint32(0), uintptr(0)) + if int32(*(*int8)(unsafe.Pointer(zPath))) == '.' { + jsonParseAddNode(tls, pParse, JSON_OBJECT, uint32(0), uintptr(0)) } else if libc.Xstrncmp(tls, zPath, ts+21800 /* "[0]" */, uint64(3)) == 0 { - jsonParseAddNode(tls, pParse, uint32(6), uint32(0), uintptr(0)) + jsonParseAddNode(tls, pParse, JSON_ARRAY, uint32(0), uintptr(0)) } else { return uintptr(0) } @@ -148789,7 +146418,7 @@ func jsonLookup(tls *libc.TLS, pParse uintptr, zPath uintptr, pApnd uintptr, pCt return uintptr(0) __1: ; - if !(int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) != '$') { + if !(int32(*(*int8)(unsafe.Pointer(zPath))) != '$') { goto __2 } *(*uintptr)(unsafe.Pointer(bp /* zErr */)) = zPath @@ -148842,10 +146471,10 @@ func jsonRemoveAllNulls(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:186780:13: n = int32((*JsonNode)(unsafe.Pointer(pNode)).Fn) for i = 2; i <= n; i = int32(U32(i) + (jsonNodeSize(tls, (pNode+uintptr(i)*16)) + U32(1))) { switch int32((*JsonNode)(unsafe.Pointer(pNode + uintptr(i)*16)).FeType) { - case 0: - *(*U8)(unsafe.Pointer(pNode + uintptr(i)*16 + 1 /* &.jnFlags */)) |= U8((0x04)) + case JSON_NULL: + *(*U8)(unsafe.Pointer(pNode + uintptr(i)*16 + 1 /* &.jnFlags */)) |= U8((JNODE_REMOVE)) break - case 7: + case JSON_OBJECT: jsonRemoveAllNulls(tls, (pNode + uintptr(i)*16)) break } @@ -148875,9 +146504,9 @@ func jsonQuoteFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* sq _ = argc jsonInit(tls, bp /* &jx */, ctx) - jsonAppendValue(tls, bp /* &jx */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + jsonAppendValue(tls, bp /* &jx */, *(*uintptr)(unsafe.Pointer(argv))) jsonResult(tls, bp /* &jx */) - Xsqlite3_result_subtype(tls, ctx, uint32(74)) + Xsqlite3_result_subtype(tls, ctx, JSON_SUBTYPE) } // Implementation of the json_array(VALUE,...) function. Return a JSON @@ -148898,7 +146527,7 @@ func jsonArrayFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* sq } jsonAppendChar(tls, bp /* &jx */, int8(']')) jsonResult(tls, bp /* &jx */) - Xsqlite3_result_subtype(tls, ctx, uint32(74)) + Xsqlite3_result_subtype(tls, ctx, JSON_SUBTYPE) } // json_array_length(JSON) @@ -148918,7 +146547,7 @@ func jsonArrayLengthFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { } if argc == 2 { - var zPath uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + var zPath uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) pNode = jsonLookup(tls, p, zPath, uintptr(0), ctx) } else { pNode = (*JsonParse)(unsafe.Pointer(p)).FaNode @@ -148926,7 +146555,7 @@ func jsonArrayLengthFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { if pNode == uintptr(0) { return } - if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) == 6 { + if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) == JSON_ARRAY { for i = U32(1); i <= (*JsonNode)(unsafe.Pointer(pNode)).Fn; n++ { i = i + (jsonNodeSize(tls, (pNode + uintptr(i)*16))) @@ -148981,7 +146610,7 @@ func jsonExtractFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* if (argc > 2) && (i == argc) { jsonAppendChar(tls, bp /* &jx */, int8(']')) jsonResult(tls, bp /* &jx */) - Xsqlite3_result_subtype(tls, ctx, uint32(74)) + Xsqlite3_result_subtype(tls, ctx, JSON_SUBTYPE) } jsonReset(tls, bp /* &jx */) } @@ -148992,13 +146621,13 @@ func jsonMergePatch(tls *libc.TLS, pParse uintptr, iTarget U32, pPatch uintptr) var j U32 var iRoot U32 var pTarget uintptr - if int32((*JsonNode)(unsafe.Pointer(pPatch)).FeType) != 7 { + if int32((*JsonNode)(unsafe.Pointer(pPatch)).FeType) != JSON_OBJECT { return pPatch } pTarget = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iTarget)*16) - if int32((*JsonNode)(unsafe.Pointer(pTarget)).FeType) != 7 { + if int32((*JsonNode)(unsafe.Pointer(pTarget)).FeType) != JSON_OBJECT { jsonRemoveAllNulls(tls, pPatch) return pPatch } @@ -149013,11 +146642,11 @@ func jsonMergePatch(tls *libc.TLS, pParse uintptr, iTarget U32, pPatch uintptr) for j = U32(1); j < (*JsonNode)(unsafe.Pointer(pTarget)).Fn; j = j + (jsonNodeSize(tls, (pTarget+uintptr((j+U32(1)))*16)) + U32(1)) { if ((*JsonNode)(unsafe.Pointer(pTarget+uintptr(j)*16)).Fn == nKey) && (libc.Xstrncmp(tls, *(*uintptr)(unsafe.Pointer(pTarget + uintptr(j)*16 + 8 /* &.u */)), zKey, uint64(nKey)) == 0) { - if (int32((*JsonNode)(unsafe.Pointer(pTarget+uintptr((j+U32(1)))*16)).FjnFlags) & (0x04 | 0x10)) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pTarget+uintptr((j+U32(1)))*16)).FjnFlags) & (JNODE_REMOVE | JNODE_PATCH)) != 0 { break } - if int32((*JsonNode)(unsafe.Pointer(pPatch+uintptr((i+U32(1)))*16)).FeType) == 0 { - *(*U8)(unsafe.Pointer(pTarget + uintptr((j+U32(1)))*16 + 1 /* &.jnFlags */)) |= U8((0x04)) + if int32((*JsonNode)(unsafe.Pointer(pPatch+uintptr((i+U32(1)))*16)).FeType) == JSON_NULL { + *(*U8)(unsafe.Pointer(pTarget + uintptr((j+U32(1)))*16 + 1 /* &.jnFlags */)) |= U8((JNODE_REMOVE)) } else { var pNew uintptr = jsonMergePatch(tls, pParse, ((iTarget + j) + U32(1)), (pPatch + uintptr((i+U32(1)))*16)) if pNew == uintptr(0) { @@ -149026,27 +146655,27 @@ func jsonMergePatch(tls *libc.TLS, pParse uintptr, iTarget U32, pPatch uintptr) pTarget = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iTarget)*16) if pNew != (pTarget + uintptr((j+U32(1)))*16) { *(*uintptr)(unsafe.Pointer(pTarget + uintptr((j+U32(1)))*16 + 8 /* &.u */)) = pNew - *(*U8)(unsafe.Pointer(pTarget + uintptr((j+U32(1)))*16 + 1 /* &.jnFlags */)) |= U8((0x10)) + *(*U8)(unsafe.Pointer(pTarget + uintptr((j+U32(1)))*16 + 1 /* &.jnFlags */)) |= U8((JNODE_PATCH)) } } break } } - if (j >= (*JsonNode)(unsafe.Pointer(pTarget)).Fn) && (int32((*JsonNode)(unsafe.Pointer(pPatch+uintptr((i+U32(1)))*16)).FeType) != 0) { + if (j >= (*JsonNode)(unsafe.Pointer(pTarget)).Fn) && (int32((*JsonNode)(unsafe.Pointer(pPatch+uintptr((i+U32(1)))*16)).FeType) != JSON_NULL) { var iStart int32 var iPatch int32 - iStart = jsonParseAddNode(tls, pParse, uint32(7), uint32(2), uintptr(0)) - jsonParseAddNode(tls, pParse, uint32(5), nKey, zKey) - iPatch = jsonParseAddNode(tls, pParse, uint32(1), uint32(0), uintptr(0)) + iStart = jsonParseAddNode(tls, pParse, JSON_OBJECT, uint32(2), uintptr(0)) + jsonParseAddNode(tls, pParse, JSON_STRING, nKey, zKey) + iPatch = jsonParseAddNode(tls, pParse, JSON_TRUE, uint32(0), uintptr(0)) if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 { return uintptr(0) } jsonRemoveAllNulls(tls, pPatch) pTarget = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iTarget)*16) - *(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*16 + 1 /* &.jnFlags */)) |= U8((0x20)) + *(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*16 + 1 /* &.jnFlags */)) |= U8((JNODE_APPEND)) *(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*16 + 8 /* &.u */)) = (U32(iStart) - iRoot) iRoot = U32(iStart) - *(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iPatch)*16 + 1 /* &.jnFlags */)) |= U8((0x10)) + *(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iPatch)*16 + 1 /* &.jnFlags */)) |= U8((JNODE_PATCH)) *(*uintptr)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iPatch)*16 + 8 /* &.u */)) = (pPatch + uintptr((i+U32(1)))*16) } } @@ -149067,10 +146696,10 @@ func jsonPatchFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* sq var pResult uintptr // The result of the merge _ = argc - if jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) != 0 { + if jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != 0 { return } - if jsonParse(tls, bp+48 /* &y */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) != 0 { + if jsonParse(tls, bp+48 /* &y */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) != 0 { jsonParseReset(tls, bp /* &x */) return } @@ -149106,7 +146735,7 @@ func jsonObjectFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* s jsonInit(tls, bp /* &jx */, ctx) jsonAppendChar(tls, bp /* &jx */, int8('{')) for i = 0; i < argc; i = i + (2) { - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) != 3 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) != SQLITE_TEXT { Xsqlite3_result_error(tls, ctx, ts+21924 /* "json_object() la..." */, -1) jsonReset(tls, bp /* &jx */) return @@ -149120,7 +146749,7 @@ func jsonObjectFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* s } jsonAppendChar(tls, bp /* &jx */, int8('}')) jsonResult(tls, bp /* &jx */) - Xsqlite3_result_subtype(tls, ctx, uint32(74)) + Xsqlite3_result_subtype(tls, ctx, JSON_SUBTYPE) } // json_remove(JSON, PATH, ...) @@ -149143,7 +146772,7 @@ func jsonRemoveFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* s return __1: ; - if !(jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) != 0) { + if !(jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != 0) { goto __2 } return @@ -149172,7 +146801,7 @@ __7: if !(pNode != 0) { goto __8 } - *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((0x04)) + *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((JNODE_REMOVE)) __8: ; goto __4 @@ -149182,7 +146811,7 @@ __4: goto __5 __5: ; - if !((int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode+uintptr(0)*16)).FjnFlags) & 0x04) == 0) { + if !((int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode)).FjnFlags) & JNODE_REMOVE) == 0) { goto __9 } jsonReturnJson(tls, (*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode, ctx, uintptr(0)) @@ -149219,7 +146848,7 @@ __1: return __2: ; - if !(jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) != 0) { + if !(jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != 0) { goto __3 } return @@ -149242,7 +146871,7 @@ __7: if !(pNode != 0) { goto __8 } - *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((int32(U8(0x08)))) + *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((int32(JNODE_REPLACE))) *(*U32)(unsafe.Pointer(pNode + 8 /* &.u */)) = (i + U32(1)) __8: ; @@ -149253,10 +146882,10 @@ __5: goto __6 __6: ; - if !((int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode+uintptr(0)*16)).FjnFlags) & 0x08) != 0) { + if !((int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode)).FjnFlags) & JNODE_REPLACE) != 0) { goto __9 } - Xsqlite3_result_value(tls, ctx, *(*uintptr)(unsafe.Pointer(argv + uintptr(*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode + uintptr(0)*16 + 8 /* &.u */)))*8))) + Xsqlite3_result_value(tls, ctx, *(*uintptr)(unsafe.Pointer(argv + uintptr(*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode + 8 /* &.u */)))*8))) goto __10 __9: jsonReturnJson(tls, (*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode, ctx, argv) @@ -149308,7 +146937,7 @@ __1: return __2: ; - if !(jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) != 0) { + if !(jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != 0) { goto __3 } return @@ -149339,7 +146968,7 @@ __9: if !((pNode != 0) && ((*(*int32)(unsafe.Pointer(bp + 48 /* bApnd */)) != 0) || (bIsSet != 0))) { goto __11 } - *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((int32(U8(0x08)))) + *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((int32(JNODE_REPLACE))) *(*U32)(unsafe.Pointer(pNode + 8 /* &.u */)) = (i + U32(1)) __11: ; @@ -149354,10 +146983,10 @@ __5: goto __6 __6: ; - if !((int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode+uintptr(0)*16)).FjnFlags) & 0x08) != 0) { + if !((int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode)).FjnFlags) & JNODE_REPLACE) != 0) { goto __12 } - Xsqlite3_result_value(tls, ctx, *(*uintptr)(unsafe.Pointer(argv + uintptr(*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode + uintptr(0)*16 + 8 /* &.u */)))*8))) + Xsqlite3_result_value(tls, ctx, *(*uintptr)(unsafe.Pointer(argv + uintptr(*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode + 8 /* &.u */)))*8))) goto __13 __12: jsonReturnJson(tls, (*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode, ctx, argv) @@ -149382,7 +147011,7 @@ func jsonTypeFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* sql return } if argc == 2 { - zPath = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zPath = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) pNode = jsonLookup(tls, p, zPath, uintptr(0), ctx) } else { pNode = (*JsonParse)(unsafe.Pointer(p)).FaNode @@ -149422,7 +147051,7 @@ func jsonArrayStep(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* sq jsonAppendChar(tls, pStr, int8(',')) (*JsonString)(unsafe.Pointer(pStr)).FpCtx = ctx } - jsonAppendValue(tls, pStr, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + jsonAppendValue(tls, pStr, *(*uintptr)(unsafe.Pointer(argv))) } } @@ -149453,7 +147082,7 @@ func jsonArrayCompute(tls *libc.TLS, ctx uintptr, isFinal int32) { /* sqlite3.c: } else { Xsqlite3_result_text(tls, ctx, ts+21969 /* "[]" */, 2, uintptr(0)) } - Xsqlite3_result_subtype(tls, ctx, uint32(74)) + Xsqlite3_result_subtype(tls, ctx, JSON_SUBTYPE) } func jsonArrayValue(tls *libc.TLS, ctx uintptr) { /* sqlite3.c:187353:13: */ @@ -149503,7 +147132,7 @@ func jsonGroupInverse(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* } } *(*U64)(unsafe.Pointer(pStr + 24 /* &.nUsed */)) -= (U64(i)) - libc.Xmemmove(tls, (z + uintptr(1)), (z + uintptr((i + uint32(1)))), (Size_t((*JsonString)(unsafe.Pointer(pStr)).FnUsed) - uint64(1))) + libc.Xmemmove(tls, (z + 1), (z + uintptr((i + uint32(1)))), (Size_t((*JsonString)(unsafe.Pointer(pStr)).FnUsed) - uint64(1))) } // json_group_obj(NAME,VALUE) @@ -149523,11 +147152,11 @@ func jsonObjectStep(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* s jsonAppendChar(tls, pStr, int8(',')) (*JsonString)(unsafe.Pointer(pStr)).FpCtx = ctx } - z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - n = U32(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + n = U32(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) jsonAppendString(tls, pStr, z, n) jsonAppendChar(tls, pStr, int8(':')) - jsonAppendValue(tls, pStr, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + jsonAppendValue(tls, pStr, *(*uintptr)(unsafe.Pointer(argv + 1*8))) } } @@ -149557,7 +147186,7 @@ func jsonObjectCompute(tls *libc.TLS, ctx uintptr, isFinal int32) { /* sqlite3.c } else { Xsqlite3_result_text(tls, ctx, ts+21972 /* "{}" */, 2, uintptr(0)) } - Xsqlite3_result_subtype(tls, ctx, uint32(74)) + Xsqlite3_result_subtype(tls, ctx, JSON_SUBTYPE) } func jsonObjectValue(tls *libc.TLS, ctx uintptr) { /* sqlite3.c:187460:13: */ @@ -149609,13 +147238,13 @@ func jsonEachConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv u rc = Xsqlite3_declare_vtab(tls, db, ts+21975 /* "CREATE TABLE x(k..." */) - if rc == 0 { + if rc == SQLITE_OK { pNew = libc.AssignPtrUintptr(ppVtab, Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Sqlite3_vtab{})))) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(Sqlite3_vtab{}))) - Xsqlite3_vtab_config(tls, db, 2, 0) + Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) } return rc } @@ -149623,7 +147252,7 @@ func jsonEachConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv u // destructor for json_each virtual table func jsonEachDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:187530:12: */ Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // constructor for a JsonEachCursor object for json_each(). @@ -149633,17 +147262,17 @@ func jsonEachOpenEach(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* sql _ = p pCur = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(JsonEachCursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(JsonEachCursor{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // constructor for a JsonEachCursor object for json_tree(). func jsonEachOpenTree(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* sqlite3.c:187548:12: */ var rc int32 = jsonEachOpenEach(tls, p, ppCursor) - if rc == 0 { + if rc == SQLITE_OK { var pCur uintptr = *(*uintptr)(unsafe.Pointer(ppCursor)) (*JsonEachCursor)(unsafe.Pointer(pCur)).FbRecursive = U8(1) } @@ -149669,7 +147298,7 @@ func jsonEachClose(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187572:12: * var p uintptr = cur jsonEachCursorReset(tls, p) Xsqlite3_free(tls, cur) - return 0 + return SQLITE_OK } // Return TRUE if the jsonEachCursor object has been advanced off the end @@ -149683,7 +147312,7 @@ func jsonEachEof(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187581:12: */ func jsonEachNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187587:12: */ var p uintptr = cur if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 { - if (int32((*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*16)).FjnFlags) & 0x40) != 0 { + if (int32((*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*16)).FjnFlags) & JNODE_LABEL) != 0 { (*JsonEachCursor)(unsafe.Pointer(p)).Fi++ } (*JsonEachCursor)(unsafe.Pointer(p)).Fi++ @@ -149692,7 +147321,7 @@ func jsonEachNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187587:12: */ var iUp U32 = *(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaUp + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*4)) var pUp uintptr = ((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(iUp)*16) (*JsonEachCursor)(unsafe.Pointer(p)).FeType = (*JsonNode)(unsafe.Pointer(pUp)).FeType - if int32((*JsonNode)(unsafe.Pointer(pUp)).FeType) == 6 { + if int32((*JsonNode)(unsafe.Pointer(pUp)).FeType) == JSON_ARRAY { if iUp == ((*JsonEachCursor)(unsafe.Pointer(p)).Fi - U32(1)) { *(*U32)(unsafe.Pointer(pUp + 8 /* &.u */)) = U32(0) } else { @@ -149702,7 +147331,7 @@ func jsonEachNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187587:12: */ } } else { switch int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) { - case 6: + case JSON_ARRAY: { *(*U32)(unsafe.Pointer(p + 16 /* &.i */)) += (jsonNodeSize(tls, ((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*16))) (*JsonEachCursor)(unsafe.Pointer(p)).FiRowid++ @@ -149710,7 +147339,7 @@ func jsonEachNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187587:12: */ } fallthrough - case 7: + case JSON_OBJECT: { *(*U32)(unsafe.Pointer(p + 16 /* &.i */)) += (U32(1) + jsonNodeSize(tls, ((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr(((*JsonEachCursor)(unsafe.Pointer(p)).Fi+U32(1)))*16))) (*JsonEachCursor)(unsafe.Pointer(p)).FiRowid++ @@ -149726,7 +147355,7 @@ func jsonEachNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187587:12: */ } } } - return 0 + return SQLITE_OK } // Append the name of the path for element i to pStr @@ -149745,11 +147374,11 @@ func jsonEachComputePath(tls *libc.TLS, p uintptr, pStr uintptr, i U32) { /* sql jsonEachComputePath(tls, p, pStr, iUp) pNode = ((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(i)*16) pUp = ((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(iUp)*16) - if int32((*JsonNode)(unsafe.Pointer(pUp)).FeType) == 6 { + if int32((*JsonNode)(unsafe.Pointer(pUp)).FeType) == JSON_ARRAY { jsonPrintf(tls, 30, pStr, ts+22058 /* "[%d]" */, libc.VaList(bp, *(*U32)(unsafe.Pointer(pUp + 8 /* &.u */)))) } else { - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x40) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_LABEL) == 0 { pNode -= 16 } @@ -149765,14 +147394,14 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* var p uintptr = cur var pThis uintptr = ((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*16) switch i { - case 0: + case JEACH_KEY: { if (*JsonEachCursor)(unsafe.Pointer(p)).Fi == U32(0) { break } - if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == 7 { + if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == JSON_OBJECT { jsonReturn(tls, pThis, ctx, uintptr(0)) - } else if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == 6 { + } else if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == JSON_ARRAY { var iKey U32 if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 { if (*JsonEachCursor)(unsafe.Pointer(p)).FiRowid == U32(0) { @@ -149787,44 +147416,44 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* break } - case 1: + case JEACH_VALUE: { - if (int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & 0x40) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & JNODE_LABEL) != 0 { pThis += 16 } jsonReturn(tls, pThis, ctx, uintptr(0)) break } - case 2: + case JEACH_TYPE: { - if (int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & 0x40) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & JNODE_LABEL) != 0 { pThis += 16 } Xsqlite3_result_text(tls, ctx, jsonType[(*JsonNode)(unsafe.Pointer(pThis)).FeType], -1, uintptr(0)) break } - case 3: + case JEACH_ATOM: { - if (int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & 0x40) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & JNODE_LABEL) != 0 { pThis += 16 } - if int32((*JsonNode)(unsafe.Pointer(pThis)).FeType) >= 6 { + if int32((*JsonNode)(unsafe.Pointer(pThis)).FeType) >= JSON_ARRAY { break } jsonReturn(tls, pThis, ctx, uintptr(0)) break } - case 4: + case JEACH_ID: { Xsqlite3_result_int64(tls, ctx, - (Sqlite3_int64((*JsonEachCursor)(unsafe.Pointer(p)).Fi) + (Sqlite3_int64(libc.Bool32((int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & 0x40) != 0))))) + (Sqlite3_int64((*JsonEachCursor)(unsafe.Pointer(p)).Fi) + (Sqlite3_int64(libc.Bool32((int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & JNODE_LABEL) != 0))))) break } - case 5: + case JEACH_PARENT: { if ((*JsonEachCursor)(unsafe.Pointer(p)).Fi > (*JsonEachCursor)(unsafe.Pointer(p)).FiBegin) && ((*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0) { Xsqlite3_result_int64(tls, ctx, Sqlite3_int64(*(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaUp + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*4)))) @@ -149832,7 +147461,7 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* break } - case 6: + case JEACH_FULLKEY: { // var x JsonString at bp+24, 136 @@ -149845,9 +147474,9 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* } else { jsonAppendChar(tls, bp+24 /* &x */, int8('$')) } - if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == 6 { + if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == JSON_ARRAY { jsonPrintf(tls, 30, bp+24 /* &x */, ts+22058 /* "[%d]" */, libc.VaList(bp, (*JsonEachCursor)(unsafe.Pointer(p)).FiRowid)) - } else if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == 7 { + } else if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == JSON_OBJECT { jsonPrintf(tls, int32((*JsonNode)(unsafe.Pointer(pThis)).Fn), bp+24 /* &x */, ts+22063 /* ".%.*s" */, libc.VaList(bp+8, ((*JsonNode)(unsafe.Pointer(pThis)).Fn-U32(2)), (*(*uintptr)(unsafe.Pointer(pThis + 8 /* &.u */))+uintptr(1)))) } } @@ -149855,7 +147484,7 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* break } - case 7: + case JEACH_PATH: { if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 { // var x JsonString at bp+160, 136 @@ -149865,9 +147494,6 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* jsonResult(tls, bp+160 /* &x */) break } - // For json_each() path and root are the same so fall through - // into the root case - /* no break */ } fallthrough @@ -149881,7 +147507,7 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* break } - case 8: + case JEACH_JSON: { Xsqlite3_result_text(tls, ctx, (*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson, -1, uintptr(0)) @@ -149889,14 +147515,14 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* } } - return 0 + return SQLITE_OK } // Return the current rowid value func jsonEachRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* sqlite3.c:187754:12: */ var p uintptr = cur *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = Sqlite_int64((*JsonEachCursor)(unsafe.Pointer(p)).FiRowid) - return 0 + return SQLITE_OK } // The query strategy is to look for an equality constraint on the json @@ -149918,7 +147544,7 @@ func jsonEachBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* // columns in the table _ = tab - *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(0)*4)) = libc.AssignPtrInt32(bp /* &aIdx */ +uintptr(1)*4, -1) + *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */)) = libc.AssignPtrInt32(bp /* &aIdx */ +1*4, -1) pConstraint = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint i = 0 __1: @@ -149928,15 +147554,15 @@ __1: { var iCol int32 var iMask int32 - if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < 8 { + if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < JEACH_JSON { goto __2 } - iCol = ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn - 8) + iCol = ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn - JEACH_JSON) iMask = (int32(1) << iCol) if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { unusableMask = unusableMask | (iMask) - } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2 { + } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ { *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(iCol)*4)) = i idxMask = idxMask | (iMask) } @@ -149953,28 +147579,28 @@ __3: if (unusableMask & ^idxMask) != 0 { // If there are any unusable constraints on JSON or ROOT, then reject // this entire plan - return 19 + return SQLITE_CONSTRAINT } - if *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(0)*4)) < 0 { + if *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */)) < 0 { // No JSON input. Leave estimatedCost at the huge value that it was // initialized to to discourage the query planner from selecting this // plan. (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0 } else { (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1.0 - i = *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(0)*4)) + i = *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */)) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) - if *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(1)*4)) < 0 { + if *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + 1*4)) < 0 { (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1 // Only JSON supplied. Plan 1 } else { - i = *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(1)*4)) + i = *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + 1*4)) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 2 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 3 // Both JSON and ROOT are supplied. Plan 3 } } - return 0 + return SQLITE_OK } // Start a search on a new JSON string @@ -149991,47 +147617,47 @@ func jsonEachFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, ar _ = argc jsonEachCursorReset(tls, p) if idxNum == 0 { - return 0 + return SQLITE_OK } - z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if z == uintptr(0) { - return 0 + return SQLITE_OK } - n = Sqlite3_int64(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + n = Sqlite3_int64(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) (*JsonEachCursor)(unsafe.Pointer(p)).FzJson = Xsqlite3_malloc64(tls, (uint64(n + int64(1)))) if (*JsonEachCursor)(unsafe.Pointer(p)).FzJson == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, (*JsonEachCursor)(unsafe.Pointer(p)).FzJson, z, (Size_t(n) + uint64(1))) if jsonParse(tls, (p+48 /* &.sParse */), uintptr(0), (*JsonEachCursor)(unsafe.Pointer(p)).FzJson) != 0 { - var rc int32 = 7 + var rc int32 = SQLITE_NOMEM if int32((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.Foom) == 0 { Xsqlite3_free(tls, (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg) (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+21785 /* "malformed JSON" */, 0) if (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { - rc = 1 + rc = SQLITE_ERROR } } jsonEachCursorReset(tls, p) return rc } else if ((*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0) && (jsonParseFindParents(tls, (p+48 /* &.sParse */)) != 0) { jsonEachCursorReset(tls, p) - return 7 + return SQLITE_NOMEM } else { var pNode uintptr = uintptr(0) if idxNum == 3 { *(*uintptr)(unsafe.Pointer(bp /* zErr */)) = uintptr(0) - zRoot = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zRoot = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if zRoot == uintptr(0) { - return 0 + return SQLITE_OK } - n = Sqlite3_int64(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) + n = Sqlite3_int64(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot = Xsqlite3_malloc64(tls, (uint64(n + int64(1)))) if (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot, zRoot, (Size_t(n) + uint64(1))) - if int32(*(*int8)(unsafe.Pointer(zRoot + uintptr(0)))) != '$' { + if int32(*(*int8)(unsafe.Pointer(zRoot))) != '$' { *(*uintptr)(unsafe.Pointer(bp /* zErr */)) = zRoot } else { pNode = jsonLookupStep(tls, (p + 48 /* &.sParse */), uint32(0), ((*JsonEachCursor)(unsafe.Pointer(p)).FzRoot + uintptr(1)), uintptr(0), bp /* &zErr */) @@ -150041,23 +147667,23 @@ func jsonEachFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, ar (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = jsonPathSyntaxError(tls, *(*uintptr)(unsafe.Pointer(bp /* zErr */))) jsonEachCursorReset(tls, p) if (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { - return 1 + return SQLITE_ERROR } - return 7 + return SQLITE_NOMEM } else if pNode == uintptr(0) { - return 0 + return SQLITE_OK } } else { pNode = (*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode } (*JsonEachCursor)(unsafe.Pointer(p)).FiBegin = libc.AssignPtrUint32(p+16 /* &.i */, U32((int32((int64(pNode) - int64((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode)) / 16)))) (*JsonEachCursor)(unsafe.Pointer(p)).FeType = (*JsonNode)(unsafe.Pointer(pNode)).FeType - if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) >= 6 { + if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) >= JSON_ARRAY { *(*U32)(unsafe.Pointer(pNode + 8 /* &.u */)) = U32(0) (*JsonEachCursor)(unsafe.Pointer(p)).FiEnd = (((*JsonEachCursor)(unsafe.Pointer(p)).Fi + (*JsonNode)(unsafe.Pointer(pNode)).Fn) + U32(1)) if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 { (*JsonEachCursor)(unsafe.Pointer(p)).FeType = (*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(*(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaUp + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*4)))*16)).FeType - if ((*JsonEachCursor)(unsafe.Pointer(p)).Fi > U32(0)) && ((int32((*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr(((*JsonEachCursor)(unsafe.Pointer(p)).Fi-U32(1)))*16)).FjnFlags) & 0x40) != 0) { + if ((*JsonEachCursor)(unsafe.Pointer(p)).Fi > U32(0)) && ((int32((*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr(((*JsonEachCursor)(unsafe.Pointer(p)).Fi-U32(1)))*16)).FjnFlags) & JNODE_LABEL) != 0) { (*JsonEachCursor)(unsafe.Pointer(p)).Fi-- } } else { @@ -150067,109 +147693,35 @@ func jsonEachFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, ar (*JsonEachCursor)(unsafe.Pointer(p)).FiEnd = ((*JsonEachCursor)(unsafe.Pointer(p)).Fi + U32(1)) } } - return 0 + return SQLITE_OK } // The methods of the json_each virtual table -var jsonEachModule = Sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - uintptr(0), - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - uintptr(0), - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var jsonEachModule = Sqlite3_module{ // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xShadowName } /* sqlite3.c:187902:23 */ // The methods of the json_tree virtual table. -var jsonTreeModule = Sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - uintptr(0), - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - uintptr(0), - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var jsonTreeModule = Sqlite3_module{ // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xShadowName } /* sqlite3.c:187930:23 */ // *************************************************************************** @@ -150180,14 +147732,14 @@ var jsonTreeModule = Sqlite3_module{ // func Xsqlite3Json1Init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:187964:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var i uint32 for i = uint32(0); (uint64(i) < (uint64(unsafe.Sizeof(aFunc)) / uint64(unsafe.Sizeof(struct { FzName uintptr FnArg int32 Fflag int32 FxFunc uintptr - }{})))) && (rc == 0); i++ { + }{})))) && (rc == SQLITE_OK); i++ { rc = Xsqlite3_create_function(tls, db, aFunc[i].FzName, aFunc[i].FnArg, enc, (uintptr(unsafe.Pointer(&aFunc)) + uintptr(i)*24 + 12 /* &.flag */), aFunc[i].FxFunc, uintptr(0), uintptr(0)) @@ -150199,9 +147751,9 @@ func Xsqlite3Json1Init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:187964:20 FxStep uintptr FxFinal uintptr FxValue uintptr - }{})))) && (rc == 0); i++ { + }{})))) && (rc == SQLITE_OK); i++ { rc = Xsqlite3_create_window_function(tls, db, aAgg[i].FzName, aAgg[i].FnArg, - (0x000100000 | enc), uintptr(0), + (SQLITE_SUBTYPE | enc), uintptr(0), aAgg[i].FxStep, aAgg[i].FxFinal, aAgg[i].FxValue, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) @@ -150210,7 +147762,7 @@ func Xsqlite3Json1Init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:187964:20 for i = uint32(0); (uint64(i) < (uint64(unsafe.Sizeof(aMod)) / uint64(unsafe.Sizeof(struct { FzName uintptr FpModule uintptr - }{})))) && (rc == 0); i++ { + }{})))) && (rc == SQLITE_OK); i++ { rc = Xsqlite3_create_module(tls, db, aMod[i].FzName, aMod[i].FpModule, uintptr(0)) } return rc @@ -150222,81 +147774,21 @@ var aFunc = [15]struct { Fflag int32 FxFunc uintptr }{ - { - FzName: ts + 22071, /* "json" */ - FnArg: 1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22076, /* "json_array" */ - FnArg: -1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22087, /* "json_array_lengt..." */ - FnArg: 1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22087, /* "json_array_lengt..." */ - FnArg: 2, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22105, /* "json_extract" */ - FnArg: -1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22118, /* "json_insert" */ - FnArg: -1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22130, /* "json_object" */ - FnArg: -1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22142, /* "json_patch" */ - FnArg: 2, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22153, /* "json_quote" */ - FnArg: 1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22164, /* "json_remove" */ - FnArg: -1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22176, /* "json_replace" */ - FnArg: -1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22189, /* "json_set" */ - FnArg: -1, - Fflag: 1, - FxFunc: 0}, - { - FzName: ts + 22198, /* "json_type" */ - FnArg: 1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22198, /* "json_type" */ - FnArg: 2, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 22208, /* "json_valid" */ - FnArg: 1, - Fflag: 0, - FxFunc: 0}, + {FzName: ts + 22071 /* "json" */, FnArg: 1, FxFunc: 0}, + {FzName: ts + 22076 /* "json_array" */, FnArg: -1, FxFunc: 0}, + {FzName: ts + 22087 /* "json_array_lengt..." */, FnArg: 1, FxFunc: 0}, + {FzName: ts + 22087 /* "json_array_lengt..." */, FnArg: 2, FxFunc: 0}, + {FzName: ts + 22105 /* "json_extract" */, FnArg: -1, FxFunc: 0}, + {FzName: ts + 22118 /* "json_insert" */, FnArg: -1, FxFunc: 0}, + {FzName: ts + 22130 /* "json_object" */, FnArg: -1, FxFunc: 0}, + {FzName: ts + 22142 /* "json_patch" */, FnArg: 2, FxFunc: 0}, + {FzName: ts + 22153 /* "json_quote" */, FnArg: 1, FxFunc: 0}, + {FzName: ts + 22164 /* "json_remove" */, FnArg: -1, FxFunc: 0}, + {FzName: ts + 22176 /* "json_replace" */, FnArg: -1, FxFunc: 0}, + {FzName: ts + 22189 /* "json_set" */, FnArg: -1, Fflag: 1, FxFunc: 0}, + {FzName: ts + 22198 /* "json_type" */, FnArg: 1, FxFunc: 0}, + {FzName: ts + 22198 /* "json_type" */, FnArg: 2, FxFunc: 0}, + {FzName: ts + 22208 /* "json_valid" */, FnArg: 1, FxFunc: 0}, } /* sqlite3.c:187972:5 */ var aAgg = [2]struct { FzName uintptr @@ -150306,31 +147798,19 @@ var aAgg = [2]struct { FxFinal uintptr FxValue uintptr }{ - { - FzName: ts + 22219, /* "json_group_array" */ - FnArg: 1, - FxStep: 0, - FxFinal: 0, - FxValue: 0}, - { - FzName: ts + 22236, /* "json_group_objec..." */ - FnArg: 2, - FxStep: 0, - FxFinal: 0, - FxValue: 0}, + {FzName: ts + 22219 /* "json_group_array" */, FnArg: 1, + FxStep: 0, FxFinal: 0, FxValue: 0}, + {FzName: ts + 22236 /* "json_group_objec..." */, FnArg: 2, + FxStep: 0, FxFinal: 0, FxValue: 0}, } /* sqlite3.c:188001:5 */ var aMod = [2]struct { FzName uintptr FpModule uintptr }{ - { - FzName: ts + 22254, /* "json_each" */ - FpModule: 0}, - { - FzName: ts + 22264, /* "json_tree" */ - FpModule: 0}, -} /* sqlite3.c:188011:5 */ -var enc int32 = ((1 | 0x000000800) | 0x000200000) /* sqlite3.c:188016:20 */ // In the SQLite core + {FzName: ts + 22254 /* "json_each" */, FpModule: 0}, + {FzName: ts + 22264 /* "json_tree" */, FpModule: 0}, +} /* sqlite3.c:188011:5 */ +var enc int32 = ((SQLITE_UTF8 | SQLITE_DETERMINISTIC) | SQLITE_INNOCUOUS) /* sqlite3.c:188016:20 */ // In the SQLite core // #include // #include @@ -150499,7 +147979,7 @@ type RtreeValue = float32 /* sqlite3.c:188256:17 */ // Functions to deserialize a 16 bit integer, 32 bit real number and // 64 bit integer. The deserialized value is returned. func readInt16(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:188535:12: */ - return ((int32(*(*U8)(unsafe.Pointer(p + uintptr(0)))) << 8) + int32(*(*U8)(unsafe.Pointer(p + uintptr(1))))) + return ((int32(*(*U8)(unsafe.Pointer(p))) << 8) + int32(*(*U8)(unsafe.Pointer(p + 1)))) } func readCoord(tls *libc.TLS, p uintptr, pCoord uintptr) { /* sqlite3.c:188538:13: */ @@ -150521,8 +148001,8 @@ func readInt64(tls *libc.TLS, p uintptr) I64 { /* sqlite3.c:188555:12: */ // 64 bit integer. The value returned is the number of bytes written // to the argument buffer (always 2, 4 and 8 respectively). func writeInt16(tls *libc.TLS, p uintptr, i int32) { /* sqlite3.c:188587:13: */ - *(*U8)(unsafe.Pointer(p + uintptr(0))) = (U8((i >> 8) & 0xFF)) - *(*U8)(unsafe.Pointer(p + uintptr(1))) = (U8((i >> 0) & 0xFF)) + *(*U8)(unsafe.Pointer(p)) = (U8((i >> 8) & 0xFF)) + *(*U8)(unsafe.Pointer(p + 1)) = (U8((i >> 0) & 0xFF)) } func writeCoord(tls *libc.TLS, p uintptr, pCoord uintptr) int32 { /* sqlite3.c:188591:12: */ @@ -150558,14 +148038,14 @@ func nodeReference(tls *libc.TLS, p uintptr) { /* sqlite3.c:188639:13: */ // Clear the content of node p (set all bytes to 0x00). func nodeZero(tls *libc.TLS, pRtree uintptr, p uintptr) { /* sqlite3.c:188649:13: */ - libc.Xmemset(tls, ((*RtreeNode)(unsafe.Pointer(p)).FzData + uintptr(2)), 0, (uint64((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize - 2))) + libc.Xmemset(tls, ((*RtreeNode)(unsafe.Pointer(p)).FzData + 2), 0, (uint64((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize - 2))) (*RtreeNode)(unsafe.Pointer(p)).FisDirty = 1 } // Given a node number iNode, return the corresponding key to use // in the Rtree.aHash table. func nodeHash(tls *libc.TLS, iNode I64) uint32 { /* sqlite3.c:188658:21: */ - return ((uint32(iNode)) % uint32(97)) + return ((uint32(iNode)) % HASHSIZE) } // Search the node hash table for node iNode. If found, return a pointer @@ -150607,7 +148087,7 @@ func nodeNew(tls *libc.TLS, pRtree uintptr, pParent uintptr) uintptr { /* sqlite pNode = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(RtreeNode{})) + uint64((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize)))) if pNode != 0 { libc.Xmemset(tls, pNode, 0, (uint64(unsafe.Sizeof(RtreeNode{})) + uint64((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize))) - (*RtreeNode)(unsafe.Pointer(pNode)).FzData = (pNode + uintptr(1)*40) + (*RtreeNode)(unsafe.Pointer(pNode)).FzData = (pNode + 1*40) (*RtreeNode)(unsafe.Pointer(pNode)).FnRef = 1 (*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef++ (*RtreeNode)(unsafe.Pointer(pNode)).FpParent = pParent @@ -150643,7 +148123,7 @@ func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNo bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var pNode uintptr = uintptr(0) // Check if the requested node is already in the hash table. If so, @@ -150652,17 +148132,17 @@ func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNo if (pParent != 0) && !(int32((*RtreeNode)(unsafe.Pointer(pNode)).FpParent) != 0) { if nodeInParentChain(tls, pNode, pParent) != 0 { - return (11 | (int32(1) << 8)) + return (SQLITE_CORRUPT | (int32(1) << 8)) } (*RtreeNode)(unsafe.Pointer(pParent)).FnRef++ (*RtreeNode)(unsafe.Pointer(pNode)).FpParent = pParent } else if ((pParent != 0) && ((*RtreeNode)(unsafe.Pointer(pNode)).FpParent != 0)) && (pParent != (*RtreeNode)(unsafe.Pointer(pNode)).FpParent) { - return (11 | (int32(1) << 8)) + return (SQLITE_CORRUPT | (int32(1) << 8)) } (*RtreeNode)(unsafe.Pointer(pNode)).FnRef++ *(*uintptr)(unsafe.Pointer(ppNode)) = pNode - return 0 + return SQLITE_OK } if (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob != 0 { @@ -150672,15 +148152,15 @@ func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNo (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob = pBlob if rc != 0 { nodeBlobReset(tls, pRtree) - if rc == 7 { - return 7 + if rc == SQLITE_NOMEM { + return SQLITE_NOMEM } } } if (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob == uintptr(0) { var zTab uintptr = Xsqlite3_mprintf(tls, ts+22274 /* "%s_node" */, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzName)) if zTab == uintptr(0) { - return 7 + return SQLITE_NOMEM } rc = Xsqlite3_blob_open(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, zTab, ts+22282 /* "data" */, iNode, 0, (pRtree + 112 /* &.pNodeBlob */)) @@ -150691,17 +148171,17 @@ func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNo *(*uintptr)(unsafe.Pointer(ppNode)) = uintptr(0) // If unable to open an sqlite3_blob on the desired row, that can only // be because the shadow tables hold erroneous data. - if rc == 1 { - rc = (11 | (int32(1) << 8)) + if rc == SQLITE_ERROR { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } else if (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize == Xsqlite3_blob_bytes(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob) { pNode = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(RtreeNode{})) + uint64((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize)))) if !(pNode != 0) { - rc = 7 + rc = SQLITE_NOMEM } else { (*RtreeNode)(unsafe.Pointer(pNode)).FpParent = pParent - (*RtreeNode)(unsafe.Pointer(pNode)).FzData = (pNode + uintptr(1)*40) + (*RtreeNode)(unsafe.Pointer(pNode)).FzData = (pNode + 1*40) (*RtreeNode)(unsafe.Pointer(pNode)).FnRef = 1 (*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef++ (*RtreeNode)(unsafe.Pointer(pNode)).FiNode = iNode @@ -150719,8 +148199,8 @@ func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNo // is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt. if (pNode != 0) && (iNode == int64(1)) { (*Rtree)(unsafe.Pointer(pRtree)).FiDepth = readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData) - if (*Rtree)(unsafe.Pointer(pRtree)).FiDepth > 40 { - rc = (11 | (int32(1) << 8)) + if (*Rtree)(unsafe.Pointer(pRtree)).FiDepth > RTREE_MAX_DEPTH { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } @@ -150728,19 +148208,19 @@ func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNo // If no error has occurred so far, check if the "number of entries" // field on the node is too large. If so, set the return code to // SQLITE_CORRUPT_VTAB. - if (pNode != 0) && (rc == 0) { - if readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+uintptr(2))) > (((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)) { - rc = (11 | (int32(1) << 8)) + if (pNode != 0) && (rc == SQLITE_OK) { + if readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+2)) > (((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)) { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } - if rc == 0 { + if rc == SQLITE_OK { if pNode != uintptr(0) { nodeReference(tls, pParent) nodeHashInsert(tls, pRtree, pNode) } else { - rc = (11 | (int32(1) << 8)) + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } *(*uintptr)(unsafe.Pointer(ppNode)) = pNode @@ -150770,9 +148250,9 @@ func nodeOverwriteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintp func nodeDeleteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32) { /* sqlite3.c:188881:13: */ var pDst uintptr = ((*RtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr((4 + (int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) * iCell)))) var pSrc uintptr = (pDst + uintptr((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)) - var nByte int32 = (((readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+uintptr(2))) - iCell) - 1) * int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)) + var nByte int32 = (((readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+2)) - iCell) - 1) * int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)) libc.Xmemmove(tls, pDst, pSrc, uint64(nByte)) - writeInt16(tls, ((*RtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr(2)), (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+uintptr(2))) - 1)) + writeInt16(tls, ((*RtreeNode)(unsafe.Pointer(pNode)).FzData + 2), (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+2)) - 1)) (*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 1 } @@ -150785,11 +148265,11 @@ func nodeInsertCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr) var nMaxCell int32 // Maximum number of cells for pNode nMaxCell = (((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)) - nCell = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + uintptr(2))) + nCell = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + 2)) if nCell < nMaxCell { nodeOverwriteCell(tls, pRtree, pNode, pCell, nCell) - writeInt16(tls, ((*RtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr(2)), (nCell + 1)) + writeInt16(tls, ((*RtreeNode)(unsafe.Pointer(pNode)).FzData + 2), (nCell + 1)) (*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 1 } @@ -150798,7 +148278,7 @@ func nodeInsertCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr) // If the node is dirty, write it out to the database. func nodeWrite(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sqlite3.c:188920:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*RtreeNode)(unsafe.Pointer(pNode)).FisDirty != 0 { var p uintptr = (*Rtree)(unsafe.Pointer(pRtree)).FpWriteNode if (*RtreeNode)(unsafe.Pointer(pNode)).FiNode != 0 { @@ -150811,7 +148291,7 @@ func nodeWrite(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sqlite3. (*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 0 rc = Xsqlite3_reset(tls, p) Xsqlite3_bind_null(tls, p, 2) - if ((*RtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(0)) && (rc == 0) { + if ((*RtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(0)) && (rc == SQLITE_OK) { (*RtreeNode)(unsafe.Pointer(pNode)).FiNode = Xsqlite3_last_insert_rowid(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb) nodeHashInsert(tls, pRtree, pNode) } @@ -150822,7 +148302,7 @@ func nodeWrite(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sqlite3. // Release a reference to a node. If the node is dirty and the reference // count drops to zero, the node data is written to the database. func nodeRelease(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sqlite3.c:188946:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if pNode != 0 { (*RtreeNode)(unsafe.Pointer(pNode)).FnRef-- @@ -150834,7 +148314,7 @@ func nodeRelease(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sqlite if (*RtreeNode)(unsafe.Pointer(pNode)).FpParent != 0 { rc = nodeRelease(tls, pRtree, (*RtreeNode)(unsafe.Pointer(pNode)).FpParent) } - if rc == 0 { + if rc == SQLITE_OK { rc = nodeWrite(tls, pRtree, pNode) } nodeHashDelete(tls, pRtree, pNode) @@ -150915,7 +148395,7 @@ func rtreeRelease(tls *libc.TLS, pRtree uintptr) { /* sqlite3.c:189066:13: */ // Rtree virtual table module xDisconnect method. func rtreeDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:189090:12: */ rtreeRelease(tls, pVtab) - return 0 + return SQLITE_OK } // Rtree virtual table module xDestroy method. @@ -150932,13 +148412,13 @@ func rtreeDestroy(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:189098:12: (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName)) if !(zCreate != 0) { - rc = 7 + rc = SQLITE_NOMEM } else { nodeBlobReset(tls, pRtree) rc = Xsqlite3_exec(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb, zCreate, uintptr(0), uintptr(0), uintptr(0)) Xsqlite3_free(tls, zCreate) } - if rc == 0 { + if rc == SQLITE_OK { rtreeRelease(tls, pRtree) } @@ -150947,7 +148427,7 @@ func rtreeDestroy(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:189098:12: // Rtree virtual table module xOpen method. func rtreeOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* sqlite3.c:189126:12: */ - var rc int32 = 7 + var rc int32 = SQLITE_NOMEM var pRtree uintptr = pVTab var pCsr uintptr @@ -150955,7 +148435,7 @@ func rtreeOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* sqlite if pCsr != 0 { libc.Xmemset(tls, pCsr, 0, uint64(unsafe.Sizeof(RtreeCursor{}))) (*RtreeCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVTab - rc = 0 + rc = SQLITE_OK (*Rtree)(unsafe.Pointer(pRtree)).FnCursor++ } *(*uintptr)(unsafe.Pointer(ppCursor)) = pCsr @@ -150982,7 +148462,7 @@ func resetCursor(tls *libc.TLS, pCsr uintptr) { /* sqlite3.c:189147:13: */ Xsqlite3_free(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint) (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = uintptr(0) } - for ii = 0; ii < 5; ii++ { + for ii = 0; ii < RTREE_CACHE_SZ; ii++ { nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */) + uintptr(ii)*8))) } Xsqlite3_free(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FaPoint) @@ -151003,7 +148483,7 @@ func rtreeClose(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:189175:12: */ Xsqlite3_free(tls, pCsr) (*Rtree)(unsafe.Pointer(pRtree)).FnCursor-- nodeBlobReset(tls, pRtree) - return 0 + return SQLITE_OK } // Rtree virtual table module xEof method. @@ -151039,7 +148519,7 @@ func rtreeCallbackConstraint(tls *libc.TLS, pConstraint uintptr, eInt int32, pCe // var aCoord [10]Sqlite3_rtree_dbl at bp+8, 80 // Decoded coordinates - if ((*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop == 0x47) && (int32((*RtreeSearchPoint)(unsafe.Pointer(pSearch)).FiLevel) == 1) { + if ((*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop == RTREE_QUERY) && (int32((*RtreeSearchPoint)(unsafe.Pointer(pSearch)).FiLevel) == 1) { (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FiRowid = readInt64(tls, pCellData) } pCellData += uintptr(8) @@ -151047,73 +148527,73 @@ func rtreeCallbackConstraint(tls *libc.TLS, pConstraint uintptr, eInt int32, pCe switch nCoord { case 10: readCoord(tls, (pCellData + uintptr(36)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(9)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 9*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(32)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(8)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 8*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) fallthrough case 8: readCoord(tls, (pCellData + uintptr(28)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(7)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 7*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(24)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(6)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 6*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) fallthrough case 6: readCoord(tls, (pCellData + uintptr(20)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(5)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 5*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(16)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(4)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 4*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) fallthrough case 4: readCoord(tls, (pCellData + uintptr(12)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(3)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 3*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(8)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(2)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 2*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) fallthrough default: readCoord(tls, (pCellData + uintptr(4)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(1)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 1*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) readCoord(tls, pCellData, bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(0)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) } } else { switch nCoord { case 10: readCoord(tls, (pCellData + uintptr(36)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(9)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 9*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(32)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(8)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 8*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) fallthrough case 8: readCoord(tls, (pCellData + uintptr(28)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(7)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 7*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(24)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(6)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 6*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) fallthrough case 6: readCoord(tls, (pCellData + uintptr(20)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(5)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 5*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(16)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(4)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 4*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) fallthrough case 4: readCoord(tls, (pCellData + uintptr(12)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(3)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 3*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(8)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(2)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 2*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) fallthrough default: readCoord(tls, (pCellData + uintptr(4)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(1)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 1*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) readCoord(tls, pCellData, bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(0)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) } } - if (*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop == 0x46 { + if (*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop == RTREE_MATCH { *(*int32)(unsafe.Pointer(bp + 88 /* eWithin */)) = 0 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pConstraint + 8 /* &.u */ /* &.xGeom */))))(tls, pInfo, nCoord, bp+8 /* &aCoord[0] */, bp+88 /* &eWithin */) if *(*int32)(unsafe.Pointer(bp + 88 /* eWithin */)) == 0 { - *(*int32)(unsafe.Pointer(peWithin)) = 0 + *(*int32)(unsafe.Pointer(peWithin)) = NOT_WITHIN } *(*Sqlite3_rtree_dbl)(unsafe.Pointer(prScore)) = 0.0 } else { @@ -151147,15 +148627,15 @@ func rtreeNonleafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uint // 4-byte aligned switch (*RtreeConstraint)(unsafe.Pointer(p)).Fop { - case 0x3f: + case RTREE_TRUE: return // Always satisfied - case 0x40: + case RTREE_FALSE: break // Never satisfied - case 0x42: + case RTREE_LE: fallthrough - case 0x43: + case RTREE_LT: fallthrough - case 0x41: + case RTREE_EQ: { // var c RtreeCoord at bp, 4 /* Coordinate decoded */ @@ -151171,7 +148651,7 @@ func rtreeNonleafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uint if *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) >= val { return } - if (*RtreeConstraint)(unsafe.Pointer(p)).Fop != 0x41 { + if (*RtreeConstraint)(unsafe.Pointer(p)).Fop != RTREE_EQ { break } fallthrough // RTREE_LE and RTREE_LT end here @@ -151195,7 +148675,7 @@ func rtreeNonleafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uint return } } - *(*int32)(unsafe.Pointer(peWithin)) = 0 + *(*int32)(unsafe.Pointer(peWithin)) = NOT_WITHIN } // Check the leaf RTree cell given by pCellData against constraint p. @@ -151226,26 +148706,26 @@ func rtreeLeafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uintptr } switch (*RtreeConstraint)(unsafe.Pointer(p)).Fop { - case 0x3f: + case RTREE_TRUE: return // Always satisfied - case 0x40: + case RTREE_FALSE: break // Never satisfied - case 0x42: + case RTREE_LE: if xN <= *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) { return } break - case 0x43: + case RTREE_LT: if xN < *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) { return } break - case 0x44: + case RTREE_GE: if xN >= *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) { return } break - case 0x45: + case RTREE_GT: if xN > *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) { return } @@ -151256,23 +148736,23 @@ func rtreeLeafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uintptr } break } - *(*int32)(unsafe.Pointer(peWithin)) = 0 + *(*int32)(unsafe.Pointer(peWithin)) = NOT_WITHIN } // One of the cells in node pNode is guaranteed to have a 64-bit // integer value equal to iRowid. Return the index of this cell. func nodeRowidIndex(tls *libc.TLS, pRtree uintptr, pNode uintptr, iRowid I64, piIndex uintptr) int32 { /* sqlite3.c:189402:12: */ var ii int32 - var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + uintptr(2))) + var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + 2)) for ii = 0; ii < nCell; ii++ { if nodeGetRowid(tls, pRtree, pNode, ii) == iRowid { *(*int32)(unsafe.Pointer(piIndex)) = ii - return 0 + return SQLITE_OK } } - return (11 | (int32(1) << 8)) + return (SQLITE_CORRUPT | (int32(1) << 8)) } // Return the index of the cell containing a pointer to node pNode @@ -151283,7 +148763,7 @@ func nodeParentIndex(tls *libc.TLS, pRtree uintptr, pNode uintptr, piIndex uintp return nodeRowidIndex(tls, pRtree, pParent, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode, piIndex) } *(*int32)(unsafe.Pointer(piIndex)) = -1 - return 0 + return SQLITE_OK } // Compare two search points. Return negative, zero, or positive if the first @@ -151318,8 +148798,8 @@ func rtreeSearchPointSwap(tls *libc.TLS, p uintptr, i int32, j int32) { /* sqlit *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(j)*24)) = t i++ j++ - if i < 5 { - if j >= 5 { + if i < RTREE_CACHE_SZ { + if j >= RTREE_CACHE_SZ { nodeRelease(tls, (*RtreeCursor)(unsafe.Pointer((p))).Fbase.FpVtab, *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + uintptr(i)*8))) *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + uintptr(i)*8)) = uintptr(0) } else { @@ -151349,7 +148829,7 @@ func rtreeNodeOfFirstSearchPoint(tls *libc.TLS, pCur uintptr, pRC uintptr) uintp if *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */) + uintptr(ii)*8)) == uintptr(0) { if ii != 0 { - id = (*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint + uintptr(0)*24)).Fid + id = (*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint)).Fid } else { id = (*RtreeCursor)(unsafe.Pointer(pCur)).FsPoint.Fid } @@ -151408,13 +148888,13 @@ func rtreeSearchPointNew(tls *libc.TLS, pCur uintptr, rScore RtreeDValue, iLevel return uintptr(0) } ii = ((int32((int64(pNew) - int64((*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint)) / 24)) + 1) - if ii < 5 { + if ii < RTREE_CACHE_SZ { - *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */) + uintptr(ii)*8)) = *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */) + uintptr(0)*8)) + *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */) + uintptr(ii)*8)) = *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */))) } else { - nodeRelease(tls, (*RtreeCursor)(unsafe.Pointer((pCur))).Fbase.FpVtab, *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */) + uintptr(0)*8))) + nodeRelease(tls, (*RtreeCursor)(unsafe.Pointer((pCur))).Fbase.FpVtab, *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */)))) } - *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */) + uintptr(0)*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */))) = uintptr(0) *(*RtreeSearchPoint)(unsafe.Pointer(pNew)) = (*RtreeCursor)(unsafe.Pointer(pCur)).FsPoint } (*RtreeCursor)(unsafe.Pointer(pCur)).FsPoint.FrScore = rScore @@ -151443,11 +148923,11 @@ func rtreeSearchPointPop(tls *libc.TLS, p uintptr) { /* sqlite3.c:189604:13: */ *(*U32)(unsafe.Pointer((p + 128 /* &.anQueue */) + uintptr((*RtreeCursor)(unsafe.Pointer(p)).FsPoint.FiLevel)*4))-- (*RtreeCursor)(unsafe.Pointer(p)).FbPoint = U8(0) } else if (*RtreeCursor)(unsafe.Pointer(p)).FnPoint != 0 { - *(*U32)(unsafe.Pointer((p + 128 /* &.anQueue */) + uintptr((*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(0)*24)).FiLevel)*4))-- + *(*U32)(unsafe.Pointer((p + 128 /* &.anQueue */) + uintptr((*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint)).FiLevel)*4))-- n = libc.PreDecInt32(&(*RtreeCursor)(unsafe.Pointer(p)).FnPoint, 1) - *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(0)*24)) = *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(n)*24)) - if n < (5 - 1) { - *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + uintptr(1)*8)) = *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + uintptr((n+1))*8)) + *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint)) = *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(n)*24)) + if n < (RTREE_CACHE_SZ - 1) { + *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + 1*8)) = *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + uintptr((n+1))*8)) *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + uintptr((n+1))*8)) = uintptr(0) } i = 0 @@ -151485,29 +148965,29 @@ func rtreeStepToLeaf(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:189652:12 var pNode uintptr // var eWithin int32 at bp+16, 4 - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var nCell int32 var nConstraint int32 = (*RtreeCursor)(unsafe.Pointer(pCur)).FnConstraint var ii int32 var eInt int32 var x RtreeSearchPoint - eInt = (libc.Bool32(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 1)) + eInt = (libc.Bool32(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_INT32)) for ((libc.AssignUintptr(&p, rtreeSearchPointFirst(tls, pCur))) != uintptr(0)) && (int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiLevel) > 0) { var pCellData uintptr pNode = rtreeNodeOfFirstSearchPoint(tls, pCur, bp /* &rc */) if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp /* rc */)) } - nCell = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + uintptr(2))) + nCell = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + 2)) pCellData = ((*RtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr((4 + (int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) * int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell))))) for int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell) < nCell { *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* rScore */)) = Sqlite3_rtree_dbl(-1) - *(*int32)(unsafe.Pointer(bp + 16 /* eWithin */)) = 2 + *(*int32)(unsafe.Pointer(bp + 16 /* eWithin */)) = FULLY_WITHIN for ii = 0; ii < nConstraint; ii++ { var pConstraint uintptr = ((*RtreeCursor)(unsafe.Pointer(pCur)).FaConstraint + uintptr(ii)*24) - if (*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop >= 0x46 { + if (*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop >= RTREE_MATCH { *(*int32)(unsafe.Pointer(bp /* rc */)) = rtreeCallbackConstraint(tls, pConstraint, eInt, pCellData, p, bp+8 /* &rScore */, bp+16 /* &eWithin */) if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { @@ -151518,13 +148998,13 @@ func rtreeStepToLeaf(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:189652:12 } else { rtreeNonleafConstraint(tls, pConstraint, eInt, pCellData, bp+16 /* &eWithin */) } - if *(*int32)(unsafe.Pointer(bp + 16 /* eWithin */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* eWithin */)) == NOT_WITHIN { (*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell++ pCellData += uintptr((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) break } } - if *(*int32)(unsafe.Pointer(bp + 16 /* eWithin */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* eWithin */)) == NOT_WITHIN { continue } (*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell++ @@ -151534,7 +149014,7 @@ func rtreeStepToLeaf(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:189652:12 for ii = 0; ii < (*RtreeCursor)(unsafe.Pointer(pCur)).FnPoint; ii++ { if (*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint+uintptr(ii)*24)).Fid == x.Fid { - return (11 | (int32(1) << 8)) + return (SQLITE_CORRUPT | (int32(1) << 8)) } } x.FiCell = U8(0) @@ -151551,7 +149031,7 @@ func rtreeStepToLeaf(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:189652:12 } p = rtreeSearchPointNew(tls, pCur, *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* rScore */)), x.FiLevel) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = U8(*(*int32)(unsafe.Pointer(bp + 16 /* eWithin */))) (*RtreeSearchPoint)(unsafe.Pointer(p)).Fid = x.Fid @@ -151565,13 +149045,13 @@ func rtreeStepToLeaf(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:189652:12 } } (*RtreeCursor)(unsafe.Pointer(pCur)).FatEOF = (U8(libc.Bool32(p == uintptr(0)))) - return 0 + return SQLITE_OK } // Rtree virtual table module xNext method. func rtreeNext(tls *libc.TLS, pVtabCursor uintptr) int32 { /* sqlite3.c:189733:12: */ var pCsr uintptr = pVtabCursor - var rc int32 = 0 + var rc int32 = SQLITE_OK // Move to the next entry that matches the configured constraints. @@ -151591,9 +149071,9 @@ func rtreeRowid(tls *libc.TLS, pVtabCursor uintptr, pRowid uintptr) int32 { /* s var pCsr uintptr = pVtabCursor var p uintptr = rtreeSearchPointFirst(tls, pCsr) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pNode uintptr = rtreeNodeOfFirstSearchPoint(tls, pCsr, bp /* &rc */) - if (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (p != 0) { + if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (p != 0) { *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = nodeGetRowid(tls, (*RtreeCursor)(unsafe.Pointer((pCsr))).Fbase.FpVtab, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell)) } return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -151609,20 +149089,20 @@ func rtreeColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* sq var p uintptr = rtreeSearchPointFirst(tls, pCsr) // var c RtreeCoord at bp+4, 4 - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pNode uintptr = rtreeNodeOfFirstSearchPoint(tls, pCsr, bp /* &rc */) if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp /* rc */)) } if p == uintptr(0) { - return 0 + return SQLITE_OK } if i == 0 { Xsqlite3_result_int64(tls, ctx, nodeGetRowid(tls, pRtree, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell))) } else if i <= int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) { nodeGetCoord(tls, pRtree, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell), (i - 1), bp+4 /* &c */) - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { Xsqlite3_result_double(tls, ctx, float64(*(*RtreeValue)(unsafe.Pointer(bp + 4 /* &c */)))) } else { @@ -151640,12 +149120,12 @@ func rtreeColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* sq Xsqlite3_bind_int64(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, 1, nodeGetRowid(tls, pRtree, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell))) *(*int32)(unsafe.Pointer(bp /* rc */)) = Xsqlite3_step(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 100 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_ROW { (*RtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid = U8(1) } else { Xsqlite3_reset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 101 { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_DONE { + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK } return *(*int32)(unsafe.Pointer(bp /* rc */)) } @@ -151653,7 +149133,7 @@ func rtreeColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* sq Xsqlite3_result_value(tls, ctx, Xsqlite3_column_value(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, ((i-int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2))+1))) } - return 0 + return SQLITE_OK } // Use nodeAcquire() to obtain the leaf node containing the record with @@ -151665,7 +149145,7 @@ func findLeafNode(tls *libc.TLS, pRtree uintptr, iRowid I64, ppLeaf uintptr, piN var rc int32 *(*uintptr)(unsafe.Pointer(ppLeaf)) = uintptr(0) Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid, 1, iRowid) - if Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) == 100 { + if Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) == SQLITE_ROW { var iNode I64 = Xsqlite3_column_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid, 0) if piNode != 0 { *(*Sqlite3_int64)(unsafe.Pointer(piNode)) = iNode @@ -151689,14 +149169,14 @@ func deserializeGeometry(tls *libc.TLS, pValue uintptr, pCons uintptr) int32 { / pSrc = Xsqlite3_value_pointer(tls, pValue, ts+22369 /* "RtreeMatchArg" */) if pSrc == uintptr(0) { - return 1 + return SQLITE_ERROR } pInfo = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(Sqlite3_rtree_query_info{})) + uint64((*RtreeMatchArg)(unsafe.Pointer(pSrc)).FiSize)))) if !(pInfo != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pInfo, 0, uint64(unsafe.Sizeof(Sqlite3_rtree_query_info{}))) - pBlob = (pInfo + uintptr(1)*112) + pBlob = (pInfo + 1*112) libc.Xmemcpy(tls, pBlob, pSrc, uint64((*RtreeMatchArg)(unsafe.Pointer(pSrc)).FiSize)) (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FpContext = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FpContext (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FnParam = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).FnParam @@ -151706,11 +149186,11 @@ func deserializeGeometry(tls *libc.TLS, pValue uintptr, pCons uintptr) int32 { / if (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxGeom != 0 { *(*uintptr)(unsafe.Pointer(pCons + 8 /* &.u */)) = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxGeom } else { - (*RtreeConstraint)(unsafe.Pointer(pCons)).Fop = 0x47 + (*RtreeConstraint)(unsafe.Pointer(pCons)).Fop = RTREE_QUERY *(*uintptr)(unsafe.Pointer(pCons + 8 /* &.u */)) = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxQueryFunc } (*RtreeConstraint)(unsafe.Pointer(pCons)).FpInfo = pInfo - return 0 + return SQLITE_OK } // Rtree virtual table module xFilter method. @@ -151722,7 +149202,7 @@ func rtreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt var pCsr uintptr = pVtabCursor *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) = uintptr(0) var ii int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK *(*int32)(unsafe.Pointer(bp + 16 /* iCell */)) = 0 rtreeReference(tls, pRtree) @@ -151736,22 +149216,22 @@ func rtreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt // var pLeaf uintptr at bp, 8 // Leaf on which the required cell resides var p uintptr // Search point for the leaf - var iRowid I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var iRowid I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) *(*I64)(unsafe.Pointer(bp + 8 /* iNode */)) = int64(0) - var eType int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - if (eType == 1) || - ((eType == 2) && (Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == float64(iRowid))) { + var eType int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv))) + if (eType == SQLITE_INTEGER) || + ((eType == SQLITE_FLOAT) && (Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) == float64(iRowid))) { rc = findLeafNode(tls, pRtree, iRowid, bp /* &pLeaf */, bp+8 /* &iNode */) } else { - rc = 0 + rc = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) = uintptr(0) } - if (rc == 0) && (*(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) != uintptr(0)) { + if (rc == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) != uintptr(0)) { p = rtreeSearchPointNew(tls, pCsr, 0.0, uint8(0)) // Always returns pCsr->sPoint - *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */) + uintptr(0)*8)) = *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) + *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */))) = *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) (*RtreeSearchPoint)(unsafe.Pointer(p)).Fid = *(*I64)(unsafe.Pointer(bp + 8 /* iNode */)) - (*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = U8(1) + (*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = PARTLY_WITHIN rc = nodeRowidIndex(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)), iRowid, bp+16 /* &iCell */) (*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell = U8(*(*int32)(unsafe.Pointer(bp + 16 /* iCell */))) @@ -151762,11 +149242,11 @@ func rtreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt // Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array // with the configured constraints. rc = nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp+24 /* &pRoot */) - if (rc == 0) && (argc > 0) { + if (rc == SQLITE_OK) && (argc > 0) { (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(RtreeConstraint{})) * uint64(argc)))) (*RtreeCursor)(unsafe.Pointer(pCsr)).FnConstraint = argc if !(int32((*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint) != 0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint, 0, (uint64(unsafe.Sizeof(RtreeConstraint{})) * uint64(argc))) libc.Xmemset(tls, pCsr+128 /* &.anQueue */, 0, (uint64(unsafe.Sizeof(U32(0))) * (uint64((*Rtree)(unsafe.Pointer(pRtree)).FiDepth + 1)))) @@ -151776,43 +149256,43 @@ func rtreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt var eType int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*8))) (*RtreeConstraint)(unsafe.Pointer(p)).Fop = int32(*(*int8)(unsafe.Pointer(idxStr + uintptr((ii * 2))))) (*RtreeConstraint)(unsafe.Pointer(p)).FiCoord = (int32(*(*int8)(unsafe.Pointer(idxStr + uintptr(((ii * 2) + 1))))) - '0') - if (*RtreeConstraint)(unsafe.Pointer(p)).Fop >= 0x46 { + if (*RtreeConstraint)(unsafe.Pointer(p)).Fop >= RTREE_MATCH { // A MATCH operator. The right-hand-side must be a blob that // can be cast into an RtreeMatchArg object. One created using // an sqlite3_rtree_geometry_callback() SQL user function. rc = deserializeGeometry(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*8)), p) - if rc != 0 { + if rc != SQLITE_OK { break } (*Sqlite3_rtree_query_info)(unsafe.Pointer((*RtreeConstraint)(unsafe.Pointer(p)).FpInfo)).FnCoord = int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) (*Sqlite3_rtree_query_info)(unsafe.Pointer((*RtreeConstraint)(unsafe.Pointer(p)).FpInfo)).FanQueue = pCsr + 128 /* &.anQueue */ (*Sqlite3_rtree_query_info)(unsafe.Pointer((*RtreeConstraint)(unsafe.Pointer(p)).FpInfo)).FmxLevel = ((*Rtree)(unsafe.Pointer(pRtree)).FiDepth + 1) - } else if (eType == 1) || (eType == 2) { + } else if (eType == SQLITE_INTEGER) || (eType == SQLITE_FLOAT) { *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*8))) } else { *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) = 0.0 - if eType == 5 { - (*RtreeConstraint)(unsafe.Pointer(p)).Fop = 0x40 - } else if ((*RtreeConstraint)(unsafe.Pointer(p)).Fop == 0x43) || ((*RtreeConstraint)(unsafe.Pointer(p)).Fop == 0x42) { - (*RtreeConstraint)(unsafe.Pointer(p)).Fop = 0x3f + if eType == SQLITE_NULL { + (*RtreeConstraint)(unsafe.Pointer(p)).Fop = RTREE_FALSE + } else if ((*RtreeConstraint)(unsafe.Pointer(p)).Fop == RTREE_LT) || ((*RtreeConstraint)(unsafe.Pointer(p)).Fop == RTREE_LE) { + (*RtreeConstraint)(unsafe.Pointer(p)).Fop = RTREE_TRUE } else { - (*RtreeConstraint)(unsafe.Pointer(p)).Fop = 0x40 + (*RtreeConstraint)(unsafe.Pointer(p)).Fop = RTREE_FALSE } } } } } - if rc == 0 { + if rc == SQLITE_OK { var pNew uintptr pNew = rtreeSearchPointNew(tls, pCsr, 0.0, (U8((*Rtree)(unsafe.Pointer(pRtree)).FiDepth + 1))) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*RtreeSearchPoint)(unsafe.Pointer(pNew)).Fid = int64(1) (*RtreeSearchPoint)(unsafe.Pointer(pNew)).FiCell = U8(0) - (*RtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = U8(1) + (*RtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = PARTLY_WITHIN - *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */) + uintptr(0)*8)) = *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) + *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */))) = *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) = uintptr(0) rc = rtreeStepToLeaf(tls, pCsr) @@ -151861,7 +149341,7 @@ func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sql defer tls.Free(49) var pRtree uintptr = tab - var rc int32 = 0 + var rc int32 = SQLITE_OK var ii int32 var bMatch int32 = 0 // True if there exists a MATCH constraint var nRow I64 // Estimated rows returned by this scan @@ -151876,7 +149356,7 @@ func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sql // require the VDBE to evaluate the MATCH constraint, which is not currently // possible. for ii = 0; ii < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { - if int32((*sqlite3_index_constraint)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint+uintptr(ii)*12)).Fop) == 64 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint+uintptr(ii)*12)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH { bMatch = 1 } } @@ -151885,7 +149365,7 @@ func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sql var p uintptr = ((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12) if (((bMatch == 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0)) && - ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0)) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2) { + ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0)) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { // We have an equality constraint on the rowid. Use strategy 1. var jj int32 for jj = 0; jj < ii; jj++ { @@ -151903,37 +149383,37 @@ func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sql // a single row. (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 30.0 (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) - (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = 1 - return 0 + (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = SQLITE_INDEX_SCAN_UNIQUE + return SQLITE_OK } if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) && ((((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn > 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn <= int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2))) || - (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 64)) { + (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH)) { var op U8 switch int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) { - case 2: - op = U8(0x41) + case SQLITE_INDEX_CONSTRAINT_EQ: + op = RTREE_EQ break fallthrough - case 4: - op = U8(0x45) + case SQLITE_INDEX_CONSTRAINT_GT: + op = RTREE_GT break fallthrough - case 8: - op = U8(0x42) + case SQLITE_INDEX_CONSTRAINT_LE: + op = RTREE_LE break fallthrough - case 16: - op = U8(0x43) + case SQLITE_INDEX_CONSTRAINT_LT: + op = RTREE_LT break fallthrough - case 32: - op = U8(0x44) + case SQLITE_INDEX_CONSTRAINT_GE: + op = RTREE_GE break fallthrough - case 64: - op = U8(0x46) + case SQLITE_INDEX_CONSTRAINT_MATCH: + op = RTREE_MATCH break fallthrough default: @@ -151952,7 +149432,7 @@ func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sql (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 2 (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = 1 if (iIdx > 0) && (uintptr(0) == (libc.AssignPtrUintptr(pIdxInfo+48 /* &.idxStr */, Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp, bp+8 /* &zIdxStr[0] */))))) { - return 7 + return SQLITE_NOMEM } nRow = ((*Rtree)(unsafe.Pointer(pRtree)).FnRowEst >> (iIdx / 2)) @@ -151966,39 +149446,39 @@ func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sql func cellArea(tls *libc.TLS, pRtree uintptr, p uintptr) RtreeDValue { /* sqlite3.c:190114:20: */ var area RtreeDValue = RtreeDValue(1) - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { switch int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim) { case 5: - area = (RtreeDValue(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(9)*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(8)*4)))) + area = (RtreeDValue(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 9*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 8*4)))) fallthrough case 4: - area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(7)*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(6)*4)))) + area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 7*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 6*4)))) fallthrough case 3: - area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(5)*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(4)*4)))) + area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 5*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 4*4)))) fallthrough case 2: - area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(3)*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(2)*4)))) + area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 3*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 2*4)))) fallthrough default: - area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(1)*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(0)*4)))) + area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 1*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */))))) } } else { switch int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim) { case 5: - area = (RtreeDValue(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(9)*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(8)*4))))) + area = (RtreeDValue(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 9*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 8*4))))) fallthrough case 4: - area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(7)*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(6)*4))))) + area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 7*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 6*4))))) fallthrough case 3: - area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(5)*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(4)*4))))) + area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 5*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 4*4))))) fallthrough case 2: - area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(3)*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(2)*4))))) + area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 3*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 2*4))))) fallthrough default: - area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(1)*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(0)*4))))) + area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 1*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */)))))) } } return area @@ -152011,12 +149491,12 @@ func cellMargin(tls *libc.TLS, pRtree uintptr, p uintptr) RtreeDValue { /* sqlit var ii int32 = (int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) - 2) for ok := true; ok; ok = (ii >= 0) { margin = margin + ((func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr((ii+1))*4))) } return float64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr((ii+1))*4))) }()) - (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(ii)*4))) } return float64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(ii)*4))) @@ -152029,7 +149509,7 @@ func cellMargin(tls *libc.TLS, pRtree uintptr, p uintptr) RtreeDValue { /* sqlit // Store the union of cells p1 and p2 in p1. func cellUnion(tls *libc.TLS, pRtree uintptr, p1 uintptr, p2 uintptr) { /* sqlite3.c:190157:13: */ var ii int32 = 0 - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { for ok := true; ok; ok = (ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2)) { *(*RtreeValue)(unsafe.Pointer((p1 + 8 /* &.aCoord */) + uintptr(ii)*4)) = func() float32 { if (*(*RtreeValue)(unsafe.Pointer((p1 + 8 /* &.aCoord */) + uintptr(ii)*4))) < (*(*RtreeValue)(unsafe.Pointer((p2 + 8 /* &.aCoord */) + uintptr(ii)*4))) { @@ -152068,12 +149548,12 @@ func cellUnion(tls *libc.TLS, pRtree uintptr, p1 uintptr, p2 uintptr) { /* sqlit // by p1. False otherwise. func cellContains(tls *libc.TLS, pRtree uintptr, p1 uintptr, p2 uintptr) int32 { /* sqlite3.c:190178:12: */ var ii int32 - var isInt int32 = (libc.Bool32(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 1)) + var isInt int32 = (libc.Bool32(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_INT32)) for ii = 0; ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2); ii = ii + (2) { var a1 uintptr = ((p1 + 8 /* &.aCoord */) + uintptr(ii)*4) var a2 uintptr = ((p2 + 8 /* &.aCoord */) + uintptr(ii)*4) - if (!(isInt != 0) && ((*(*RtreeValue)(unsafe.Pointer(a2 + uintptr(0)*4)) < *(*RtreeValue)(unsafe.Pointer(a1 + uintptr(0)*4))) || (*(*RtreeValue)(unsafe.Pointer(a2 + uintptr(1)*4)) > *(*RtreeValue)(unsafe.Pointer(a1 + uintptr(1)*4))))) || - ((isInt != 0) && ((*(*int32)(unsafe.Pointer(a2 + uintptr(0)*4)) < *(*int32)(unsafe.Pointer(a1 + uintptr(0)*4))) || (*(*int32)(unsafe.Pointer(a2 + uintptr(1)*4)) > *(*int32)(unsafe.Pointer(a1 + uintptr(1)*4))))) { + if (!(isInt != 0) && ((*(*RtreeValue)(unsafe.Pointer(a2)) < *(*RtreeValue)(unsafe.Pointer(a1))) || (*(*RtreeValue)(unsafe.Pointer(a2 + 1*4)) > *(*RtreeValue)(unsafe.Pointer(a1 + 1*4))))) || + ((isInt != 0) && ((*(*int32)(unsafe.Pointer(a2)) < *(*int32)(unsafe.Pointer(a1))) || (*(*int32)(unsafe.Pointer(a2 + 1*4)) > *(*int32)(unsafe.Pointer(a1 + 1*4))))) { return 0 } } @@ -152105,25 +149585,25 @@ func cellOverlap(tls *libc.TLS, pRtree uintptr, p uintptr, aCell uintptr, nCell var x2 RtreeDValue x1 = func() float64 { if (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(jj)*4))) } return float64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(jj)*4))) }()) > (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(jj)*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(jj)*4))) }()) { return func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(jj)*4))) } return float64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(jj)*4))) }() } return func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(jj)*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(jj)*4))) @@ -152131,25 +149611,25 @@ func cellOverlap(tls *libc.TLS, pRtree uintptr, p uintptr, aCell uintptr, nCell }() x2 = func() float64 { if (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr((jj+1))*4))) } return float64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr((jj+1))*4))) }()) < (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((jj+1))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((jj+1))*4))) }()) { return func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr((jj+1))*4))) } return float64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr((jj+1))*4))) }() } return func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((jj+1))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((jj+1))*4))) @@ -152178,14 +149658,14 @@ func sChooseLeaf(tls *libc.TLS, pRtree uintptr, pCell uintptr, iHeight int32, pp *(*uintptr)(unsafe.Pointer(bp /* pNode */)) = uintptr(0) rc = nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp /* &pNode */) - for ii = 0; (rc == 0) && (ii < ((*Rtree)(unsafe.Pointer(pRtree)).FiDepth - iHeight)); ii++ { + for ii = 0; (rc == SQLITE_OK) && (ii < ((*Rtree)(unsafe.Pointer(pRtree)).FiDepth - iHeight)); ii++ { var iCell int32 var iBest Sqlite3_int64 = int64(0) var fMinGrowth RtreeDValue = 0.0 var fMinArea RtreeDValue = 0.0 - var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNode */))))).FzData + uintptr(2))) + var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNode */))))).FzData + 2)) // var cell RtreeCell at bp+8, 48 // var pChild uintptr at bp+56, 8 @@ -152239,7 +149719,7 @@ func sAdjustTree(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr) in if ((libc.PreIncInt32(&cnt, 1)) > 1000) || (nodeParentIndex(tls, pRtree, p, bp /* &iCell */) != 0) { - return (11 | (int32(1) << 8)) + return (SQLITE_CORRUPT | (int32(1) << 8)) } nodeGetCell(tls, pRtree, pParent, *(*int32)(unsafe.Pointer(bp /* iCell */)), bp+8 /* &cell */) @@ -152250,7 +149730,7 @@ func sAdjustTree(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr) in p = pParent } - return 0 + return SQLITE_OK } // Write mapping (iRowid->iNode) to the _rowid table. @@ -152350,25 +149830,25 @@ func sSortByDimension(tls *libc.TLS, pRtree uintptr, aIdx uintptr, nIdx int32, i aLeft = aSpare for (iLeft < nLeft) || (iRight < nRight) { var xleft1 RtreeDValue = func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) }() var xleft2 RtreeDValue = func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) }() var xright1 RtreeDValue = func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) }() var xright2 RtreeDValue = func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) @@ -152404,7 +149884,7 @@ func splitNodeStartree(tls *libc.TLS, pRtree uintptr, aCell uintptr, nCell int32 aaSorted = Xsqlite3_malloc64(tls, uint64(nByte)) if !(aaSorted != 0) { - return 7 + return SQLITE_NOMEM } aSpare = ((aaSorted + uintptr((*Rtree)(unsafe.Pointer(pRtree)).FnDim)*8) + uintptr((int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim)*nCell))*4) @@ -152434,7 +149914,7 @@ func splitNodeStartree(tls *libc.TLS, pRtree uintptr, aCell uintptr, nCell int32 var overlap RtreeDValue var area RtreeDValue - libc.Xmemcpy(tls, bp /* &left */, (aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*8)) + uintptr(0)*4)))*48), uint64(unsafe.Sizeof(RtreeCell{}))) + libc.Xmemcpy(tls, bp /* &left */, (aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*8)))))*48), uint64(unsafe.Sizeof(RtreeCell{}))) libc.Xmemcpy(tls, bp+48 /* &right */, (aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*8)) + uintptr((nCell-1))*4)))*48), uint64(unsafe.Sizeof(RtreeCell{}))) for kk = 1; kk < (nCell - 1); kk++ { if kk < nLeft { @@ -152463,7 +149943,7 @@ func splitNodeStartree(tls *libc.TLS, pRtree uintptr, aCell uintptr, nCell int32 } } - libc.Xmemcpy(tls, pBboxLeft, (aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(iBestDim)*8)) + uintptr(0)*4)))*48), uint64(unsafe.Sizeof(RtreeCell{}))) + libc.Xmemcpy(tls, pBboxLeft, (aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(iBestDim)*8)))))*48), uint64(unsafe.Sizeof(RtreeCell{}))) libc.Xmemcpy(tls, pBboxRight, (aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(iBestDim)*8)) + uintptr(iBestSplit)*4)))*48), uint64(unsafe.Sizeof(RtreeCell{}))) for ii = 0; ii < nCell; ii++ { var pTarget uintptr @@ -152484,7 +149964,7 @@ func splitNodeStartree(tls *libc.TLS, pRtree uintptr, aCell uintptr, nCell int32 } Xsqlite3_free(tls, aaSorted) - return 0 + return SQLITE_OK } func updateMapping(tls *libc.TLS, pRtree uintptr, iRowid I64, pNode uintptr, iHeight int32) int32 { /* sqlite3.c:190588:12: */ @@ -152532,8 +150012,8 @@ func sSplitNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHe var iRowid I64 var iRowid1 I64 newCellIsRight = 0 - rc = 0 - nCell = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + uintptr(2))) + rc = SQLITE_OK + nCell = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + 2)) pLeft = uintptr(0) pRight = uintptr(0) @@ -152543,7 +150023,7 @@ func sSplitNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHe if !(!(aCell != 0)) { goto __1 } - rc = 7 + rc = SQLITE_NOMEM goto splitnode_out __1: ; @@ -152585,7 +150065,7 @@ __6: if !(!(pLeft != 0) || !(pRight != 0)) { goto __7 } - rc = 7 + rc = SQLITE_NOMEM goto splitnode_out __7: ; @@ -152595,7 +150075,7 @@ __7: rc = splitNodeStartree(tls, pRtree, aCell, nCell, pLeft, pRight, bp /* &leftbbox */, bp+48 /* &rightbbox */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __8 } goto splitnode_out @@ -152606,8 +150086,8 @@ __8: // nodeWrite(). Node pRight always needs a node number, as it was created // by nodeNew() above. But node pLeft sometimes already has a node number. // In this case avoid the all to nodeWrite(). - if !((0 != (libc.AssignInt32(&rc, nodeWrite(tls, pRtree, pRight)))) || - ((int64(0) == (*RtreeNode)(unsafe.Pointer(pLeft)).FiNode) && (0 != (libc.AssignInt32(&rc, nodeWrite(tls, pRtree, pLeft)))))) { + if !((SQLITE_OK != (libc.AssignInt32(&rc, nodeWrite(tls, pRtree, pRight)))) || + ((int64(0) == (*RtreeNode)(unsafe.Pointer(pLeft)).FiNode) && (SQLITE_OK != (libc.AssignInt32(&rc, nodeWrite(tls, pRtree, pLeft)))))) { goto __9 } goto splitnode_out @@ -152621,7 +150101,7 @@ __9: goto __10 } rc = rtreeInsertCell(tls, pRtree, (*RtreeNode)(unsafe.Pointer(pLeft)).FpParent, bp /* &leftbbox */, (iHeight + 1)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } goto splitnode_out @@ -152631,14 +150111,14 @@ __12: __10: pParent = (*RtreeNode)(unsafe.Pointer(pLeft)).FpParent rc = nodeParentIndex(tls, pRtree, pLeft, bp+96 /* &iCell */) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __13 } nodeOverwriteCell(tls, pRtree, pParent, bp /* &leftbbox */, *(*int32)(unsafe.Pointer(bp + 96 /* iCell */))) rc = sAdjustTree(tls, pRtree, pParent, bp /* &leftbbox */) __13: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __14 } goto splitnode_out @@ -152655,7 +150135,7 @@ __15: i = 0 __16: - if !(i < readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pRight))).FzData+uintptr(2)))) { + if !(i < readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pRight))).FzData+2))) { goto __18 } iRowid = nodeGetRowid(tls, pRtree, pRight, i) @@ -152666,7 +150146,7 @@ __16: newCellIsRight = 1 __19: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __20 } goto splitnode_out @@ -152684,12 +150164,12 @@ __18: } i = 0 __23: - if !(i < readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pLeft))).FzData+uintptr(2)))) { + if !(i < readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pLeft))).FzData+2))) { goto __25 } iRowid1 = nodeGetRowid(tls, pRtree, pLeft, i) rc = updateMapping(tls, pRtree, iRowid1, pLeft, iHeight) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __26 } goto splitnode_out @@ -152713,14 +150193,14 @@ __27: __22: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __28 } rc = nodeRelease(tls, pRtree, pRight) pRight = uintptr(0) __28: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __29 } rc = nodeRelease(tls, pRtree, pLeft) @@ -152745,13 +150225,13 @@ splitnode_out: // the entry resides (argument pLeaf). Once the leaf is located, this // function is called to determine its ancestry. func fixLeafParent(tls *libc.TLS, pRtree uintptr, pLeaf uintptr) int32 { /* sqlite3.c:190754:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pChild uintptr = pLeaf - for ((rc == 0) && ((*RtreeNode)(unsafe.Pointer(pChild)).FiNode != int64(1))) && ((*RtreeNode)(unsafe.Pointer(pChild)).FpParent == uintptr(0)) { - var rc2 int32 = 0 // sqlite3_reset() return code + for ((rc == SQLITE_OK) && ((*RtreeNode)(unsafe.Pointer(pChild)).FiNode != int64(1))) && ((*RtreeNode)(unsafe.Pointer(pChild)).FpParent == uintptr(0)) { + var rc2 int32 = SQLITE_OK // sqlite3_reset() return code Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadParent, 1, (*RtreeNode)(unsafe.Pointer(pChild)).FiNode) rc = Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadParent) - if rc == 100 { + if rc == SQLITE_ROW { var pTest uintptr // Used to test for reference loops var iNode I64 // Node number of parent node @@ -152767,12 +150247,12 @@ func fixLeafParent(tls *libc.TLS, pRtree uintptr, pLeaf uintptr) int32 { /* sqli } } rc = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadParent) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } - if (rc == 0) && !(int32((*RtreeNode)(unsafe.Pointer(pChild)).FpParent) != 0) { + if (rc == SQLITE_OK) && !(int32((*RtreeNode)(unsafe.Pointer(pChild)).FpParent) != 0) { - rc = (11 | (int32(1) << 8)) + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } pChild = (*RtreeNode)(unsafe.Pointer(pChild)).FpParent } @@ -152790,30 +150270,30 @@ func removeNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, iHeight int32) int // Remove the entry in the parent cell. rc = nodeParentIndex(tls, pRtree, pNode, bp /* &iCell */) - if rc == 0 { + if rc == SQLITE_OK { pParent = (*RtreeNode)(unsafe.Pointer(pNode)).FpParent (*RtreeNode)(unsafe.Pointer(pNode)).FpParent = uintptr(0) rc = deleteCell(tls, pRtree, pParent, *(*int32)(unsafe.Pointer(bp /* iCell */)), (iHeight + 1)) } rc2 = nodeRelease(tls, pRtree, pParent) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } - if rc != 0 { + if rc != SQLITE_OK { return rc } // Remove the xxx_node entry. Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteNode, 1, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode) Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteNode) - if 0 != (libc.AssignInt32(&rc, Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteNode))) { + if SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteNode))) { return rc } // Remove the xxx_parent entry. Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteParent, 1, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode) Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteParent) - if 0 != (libc.AssignInt32(&rc, Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteParent))) { + if SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteParent))) { return rc } @@ -152825,7 +150305,7 @@ func removeNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, iHeight int32) int (*RtreeNode)(unsafe.Pointer(pNode)).FnRef++ (*Rtree)(unsafe.Pointer(pRtree)).FpDeleted = pNode - return 0 + return SQLITE_OK } func fixBoundingBox(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sqlite3.c:190838:12: */ @@ -152833,11 +150313,11 @@ func fixBoundingBox(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sql defer tls.Free(100) var pParent uintptr = (*RtreeNode)(unsafe.Pointer(pNode)).FpParent - var rc int32 = 0 + var rc int32 = SQLITE_OK if pParent != 0 { // var ii int32 at bp+96, 4 - var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + uintptr(2))) + var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + 2)) // var box RtreeCell at bp, 48 // Bounding box for pNode nodeGetCell(tls, pRtree, pNode, 0, bp /* &box */) @@ -152849,7 +150329,7 @@ func fixBoundingBox(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sql } (*RtreeCell)(unsafe.Pointer(bp /* &box */)).FiRowid = (*RtreeNode)(unsafe.Pointer(pNode)).FiNode rc = nodeParentIndex(tls, pRtree, pNode, bp+96 /* &ii */) - if rc == 0 { + if rc == SQLITE_OK { nodeOverwriteCell(tls, pRtree, pParent, bp /* &box */, *(*int32)(unsafe.Pointer(bp + 96 /* ii */))) rc = fixBoundingBox(tls, pRtree, pParent) } @@ -152863,7 +150343,7 @@ func deleteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32, iHeig var pParent uintptr var rc int32 - if 0 != (libc.AssignInt32(&rc, fixLeafParent(tls, pRtree, pNode))) { + if SQLITE_OK != (libc.AssignInt32(&rc, fixLeafParent(tls, pRtree, pNode))) { return rc } @@ -152878,7 +150358,7 @@ func deleteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32, iHeig pParent = (*RtreeNode)(unsafe.Pointer(pNode)).FpParent if pParent != 0 { - if readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+uintptr(2))) < ((((*Rtree)(unsafe.Pointer((pRtree))).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer((pRtree))).FnBytesPerCell)) / 3) { + if readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+2)) < ((((*Rtree)(unsafe.Pointer((pRtree))).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer((pRtree))).FnBytesPerCell)) / 3) { rc = removeNode(tls, pRtree, pNode, iHeight) } else { rc = fixBoundingBox(tls, pRtree, pNode) @@ -152901,19 +150381,19 @@ func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHei var iDim int32 var ii int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var n int32 - libc.Xmemset(tls, bp /* &aCenterCoord[0] */, 0, (uint64(unsafe.Sizeof(RtreeDValue(0))) * uint64(5))) + libc.Xmemset(tls, bp /* &aCenterCoord[0] */, 0, (uint64(unsafe.Sizeof(RtreeDValue(0))) * RTREE_MAX_DIMENSIONS)) - nCell = (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+uintptr(2))) + 1) - n = ((nCell + 1) & (^libc.Int32(1))) + nCell = (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+2)) + 1) + n = ((nCell + 1) & (libc.CplInt32(1))) // Allocate the buffers used by this operation. The allocation is // relinquished before this function returns. aCell = Xsqlite3_malloc64(tls, (uint64(uint64(n) * (((uint64(unsafe.Sizeof(RtreeCell{})) + uint64(unsafe.Sizeof(int32(0)))) + uint64(unsafe.Sizeof(int32(0)))) + uint64(unsafe.Sizeof(RtreeDValue(0))))))) if !(aCell != 0) { - return 7 + return SQLITE_NOMEM } aOrder = (aCell + uintptr(n)*48) aSpare = (aOrder + uintptr(n)*4) @@ -152928,13 +150408,13 @@ func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHei *(*int32)(unsafe.Pointer(aOrder + uintptr(ii)*4)) = ii for iDim = 0; iDim < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim); iDim++ { *(*RtreeDValue)(unsafe.Pointer(bp /* &aCenterCoord */ + uintptr(iDim)*8)) += (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) }()) *(*RtreeDValue)(unsafe.Pointer(bp /* &aCenterCoord */ + uintptr(iDim)*8)) += (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) @@ -152949,12 +150429,12 @@ func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHei *(*RtreeDValue)(unsafe.Pointer(aDistance + uintptr(ii)*8)) = 0.0 for iDim = 0; iDim < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim); iDim++ { var coord RtreeDValue = ((func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) }()) - (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) @@ -152966,7 +150446,7 @@ func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHei sSortByDistance(tls, aOrder, nCell, aDistance, aSpare) nodeZero(tls, pRtree, pNode) - for ii = 0; (rc == 0) && (ii < (nCell - (((((*Rtree)(unsafe.Pointer((pRtree))).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer((pRtree))).FnBytesPerCell)) / 3) + 1))); ii++ { + for ii = 0; (rc == SQLITE_OK) && (ii < (nCell - (((((*Rtree)(unsafe.Pointer((pRtree))).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer((pRtree))).FnBytesPerCell)) / 3) + 1))); ii++ { var p uintptr = (aCell + uintptr(*(*int32)(unsafe.Pointer(aOrder + uintptr(ii)*4)))*48) nodeInsertCell(tls, pRtree, pNode, p) if (*RtreeCell)(unsafe.Pointer(p)).FiRowid == (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid { @@ -152977,21 +150457,21 @@ func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHei } } } - if rc == 0 { + if rc == SQLITE_OK { rc = fixBoundingBox(tls, pRtree, pNode) } - for ; (rc == 0) && (ii < nCell); ii++ { + for ; (rc == SQLITE_OK) && (ii < nCell); ii++ { // Find a node to store this cell in. pNode->iNode currently contains // the height of the sub-tree headed by the cell. // var pInsert uintptr at bp+40, 8 var p uintptr = (aCell + uintptr(*(*int32)(unsafe.Pointer(aOrder + uintptr(ii)*4)))*48) rc = sChooseLeaf(tls, pRtree, p, iHeight, bp+40 /* &pInsert */) - if rc == 0 { + if rc == SQLITE_OK { var rc2 int32 rc = rtreeInsertCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 40 /* pInsert */)), p, iHeight) rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 40 /* pInsert */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } @@ -153004,7 +150484,7 @@ func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHei // Insert cell pCell into node pNode. Node pNode is the head of a // subtree iHeight high (leaf nodes have iHeight==0). func rtreeInsertCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHeight int32) int32 { /* sqlite3.c:191001:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if iHeight > 0 { var pChild uintptr = nodeHashLookup(tls, pRtree, (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid) if pChild != 0 { @@ -153022,7 +150502,7 @@ func rtreeInsertCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr } } else { rc = sAdjustTree(tls, pRtree, pNode, pCell) - if rc == 0 { + if rc == SQLITE_OK { if iHeight == 0 { rc = rowidWrite(tls, pRtree, (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode) } else { @@ -153038,10 +150518,10 @@ func reinsertNodeContent(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { / defer tls.Free(56) var ii int32 - var rc int32 = 0 - var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + uintptr(2))) + var rc int32 = SQLITE_OK + var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + 2)) - for ii = 0; (rc == 0) && (ii < nCell); ii++ { + for ii = 0; (rc == SQLITE_OK) && (ii < nCell); ii++ { // var pInsert uintptr at bp+48, 8 // var cell RtreeCell at bp, 48 @@ -153051,11 +150531,11 @@ func reinsertNodeContent(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { / // Find a node to store this cell in. pNode->iNode currently contains // the height of the sub-tree headed by the cell. rc = sChooseLeaf(tls, pRtree, bp /* &cell */, int32((*RtreeNode)(unsafe.Pointer(pNode)).FiNode), bp+48 /* &pInsert */) - if rc == 0 { + if rc == SQLITE_OK { var rc2 int32 rc = rtreeInsertCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 48 /* pInsert */)), bp /* &cell */, int32((*RtreeNode)(unsafe.Pointer(pNode)).FiNode)) rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 48 /* pInsert */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } @@ -153090,25 +150570,25 @@ func rtreeDeleteRowid(tls *libc.TLS, pRtree uintptr, iDelete Sqlite3_int64) int3 // Obtain a reference to the leaf node that contains the entry // about to be deleted. - if rc == 0 { + if rc == SQLITE_OK { rc = findLeafNode(tls, pRtree, iDelete, bp+8 /* &pLeaf */, uintptr(0)) } // Delete the cell in question from the leaf node. - if (rc == 0) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)) != 0) { + if (rc == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)) != 0) { var rc2 int32 rc = nodeRowidIndex(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)), iDelete, bp+16 /* &iCell */) - if rc == 0 { + if rc == SQLITE_OK { rc = deleteCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)), *(*int32)(unsafe.Pointer(bp + 16 /* iCell */)), 0) } rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } // Delete the corresponding entry in the _rowid table. - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteRowid, 1, iDelete) Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteRowid) rc = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteRowid) @@ -153121,19 +150601,19 @@ func rtreeDeleteRowid(tls *libc.TLS, pRtree uintptr, iDelete Sqlite3_int64) int3 // This is equivalent to copying the contents of the child into // the root node (the operation that Gutman's paper says to perform // in this scenario). - if ((rc == 0) && ((*Rtree)(unsafe.Pointer(pRtree)).FiDepth > 0)) && (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pRoot */))))).FzData+uintptr(2))) == 1) { + if ((rc == SQLITE_OK) && ((*Rtree)(unsafe.Pointer(pRtree)).FiDepth > 0)) && (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pRoot */))))).FzData+2)) == 1) { var rc2 int32 *(*uintptr)(unsafe.Pointer(bp + 24 /* pChild */)) = uintptr(0) var iChild I64 = nodeGetRowid(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp /* pRoot */)), 0) rc = nodeAcquire(tls, pRtree, iChild, *(*uintptr)(unsafe.Pointer(bp /* pRoot */)), bp+24 /* &pChild */) - if rc == 0 { + if rc == SQLITE_OK { rc = removeNode(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 24 /* pChild */)), ((*Rtree)(unsafe.Pointer(pRtree)).FiDepth - 1)) } rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 24 /* pChild */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } - if rc == 0 { + if rc == SQLITE_OK { (*Rtree)(unsafe.Pointer(pRtree)).FiDepth-- writeInt16(tls, (*RtreeNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pRoot */)))).FzData, (*Rtree)(unsafe.Pointer(pRtree)).FiDepth) (*RtreeNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pRoot */)))).FisDirty = 1 @@ -153142,7 +150622,7 @@ func rtreeDeleteRowid(tls *libc.TLS, pRtree uintptr, iDelete Sqlite3_int64) int3 // Re-insert the contents of any underfull nodes removed from the tree. for *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)) = (*Rtree)(unsafe.Pointer(pRtree)).FpDeleted; *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)) != 0; *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)) = (*Rtree)(unsafe.Pointer(pRtree)).FpDeleted { - if rc == 0 { + if rc == SQLITE_OK { rc = reinsertNodeContent(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */))) } (*Rtree)(unsafe.Pointer(pRtree)).FpDeleted = (*RtreeNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)))).FpNext @@ -153151,7 +150631,7 @@ func rtreeDeleteRowid(tls *libc.TLS, pRtree uintptr, iDelete Sqlite3_int64) int3 } // Release the reference to the root node. - if rc == 0 { + if rc == SQLITE_OK { rc = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp /* pRoot */))) } else { nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp /* pRoot */))) @@ -153215,11 +150695,11 @@ func rtreeConstraintError(tls *libc.TLS, pRtree uintptr, iCol int32) int32 { /* if zSql != 0 { rc = Xsqlite3_prepare_v2(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb, zSql, -1, bp+56 /* &pStmt */, uintptr(0)) } else { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3_free(tls, zSql) - if rc == 0 { + if rc == SQLITE_OK { if iCol == 0 { var zCol uintptr = Xsqlite3_column_name(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)), 0) (*Rtree)(unsafe.Pointer(pRtree)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, @@ -153234,8 +150714,8 @@ func rtreeConstraintError(tls *libc.TLS, pRtree uintptr, iCol int32) int32 { /* Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) return func() int32 { - if rc == 0 { - return 19 + if rc == SQLITE_OK { + return SQLITE_CONSTRAINT } return rc }() @@ -153260,7 +150740,7 @@ func rtreeUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRowi // Insert the new record into the r-tree // var pLeaf uintptr at bp+48, 8 pRtree = pVtab - rc = 0 + rc = SQLITE_OK bHaveRowid = 0 // Set to 1 after new rowid is determined if !((*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef != 0) { @@ -153269,7 +150749,7 @@ func rtreeUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRowi // Unable to write to the btree while another cursor is reading from it, // since the write might do a rebalance which would disrupt the read // cursor. - return (6 | (int32(2) << 8)) + return (SQLITE_LOCKED | (int32(2) << 8)) __1: ; rtreeReference(tls, pRtree) @@ -153305,7 +150785,7 @@ __3: // This problem was discovered after years of use, so we silently ignore // these kinds of misdeclared tables to avoid breaking any legacy. - if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0) { + if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32) { goto __4 } ii = 0 @@ -153358,21 +150838,21 @@ __5: // If a rowid value was supplied, check if it is already present in // the table. If so, the constraint has failed. - if !(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8))) != 5) { + if !(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + 2*8))) != SQLITE_NULL) { goto __14 } - (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8))) - if !((Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(0)*8))) == 5) || - (Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(0)*8))) != (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid)) { + (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + 2*8))) + if !((Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData))) == SQLITE_NULL) || + (Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData))) != (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid)) { goto __15 } Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid, 1, (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid) steprc = Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) rc = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) - if !(100 == steprc) { + if !(SQLITE_ROW == steprc) { goto __16 } - if !(Xsqlite3_vtab_on_conflict(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb) == 5) { + if !(Xsqlite3_vtab_on_conflict(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb) == SQLITE_REPLACE) { goto __17 } rc = rtreeDeleteRowid(tls, pRtree, (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid) @@ -153395,17 +150875,17 @@ __2: // If aData[0] is not an SQL NULL value, it is the rowid of a // record to delete from the r-tree table. The following block does // just that. - if !(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(0)*8))) != 5) { + if !(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData))) != SQLITE_NULL) { goto __19 } - rc = rtreeDeleteRowid(tls, pRtree, Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(0)*8)))) + rc = rtreeDeleteRowid(tls, pRtree, Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData)))) __19: ; // If the aData[] array contains more than one element, elements // (aData[2]..aData[argc-1]) contain a new record to insert into // the r-tree structure. - if !((rc == 0) && (nData > 1)) { + if !((rc == SQLITE_OK) && (nData > 1)) { goto __20 } // Insert the new record into the r-tree @@ -153420,19 +150900,19 @@ __21: ; *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __22 } rc = sChooseLeaf(tls, pRtree, bp /* &cell */, 0, bp+48 /* &pLeaf */) __22: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __23 } (*Rtree)(unsafe.Pointer(pRtree)).FiReinsertHeight = -1 rc = rtreeInsertCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 48 /* pLeaf */)), bp /* &cell */, 0) rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 48 /* pLeaf */))) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __24 } rc = rc2 @@ -153440,7 +150920,7 @@ __24: ; __23: ; - if !((rc == 0) && ((*Rtree)(unsafe.Pointer(pRtree)).FnAux != 0)) { + if !((rc == SQLITE_OK) && ((*Rtree)(unsafe.Pointer(pRtree)).FnAux != 0)) { goto __25 } pUp = (*Rtree)(unsafe.Pointer(pRtree)).FpWriteAux @@ -153475,7 +150955,7 @@ func rtreeBeginTransaction(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:19 var pRtree uintptr = pVtab (*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans++ - return 0 + return SQLITE_OK } // Called when a transaction completes (either by COMMIT or ROLLBACK). @@ -153484,7 +150964,7 @@ func rtreeEndTransaction(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:1914 var pRtree uintptr = pVtab (*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans = U8(0) nodeBlobReset(tls, pRtree) - return 0 + return SQLITE_OK } // The xRename method for rtree module virtual tables. @@ -153493,7 +150973,7 @@ func rtreeRename(tls *libc.TLS, pVtab uintptr, zNewName uintptr) int32 { /* sqli defer tls.Free(72) var pRtree uintptr = pVtab - var rc int32 = 7 + var rc int32 = SQLITE_NOMEM var zSql uintptr = Xsqlite3_mprintf(tls, ts+22472 /* "ALTER TABLE %Q.'..." */, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName, zNewName, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName, zNewName, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName, zNewName)) @@ -153524,7 +151004,7 @@ func rtreeSavepoint(tls *libc.TLS, pVtab uintptr, iSavepoint int32) int32 { /* s (*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans = U8(0) nodeBlobReset(tls, pRtree) (*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans = iwt - return 0 + return SQLITE_OK } // This function populates the pRtree->nRowEst variable with an estimate @@ -153543,36 +151023,36 @@ func rtreeQueryStat1(tls *libc.TLS, db uintptr, pRtree uintptr) int32 { /* sqlit rc = Xsqlite3_table_column_metadata(tls, db, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, ts+9240 /* "sqlite_stat1" */, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) - if rc != 0 { - (*Rtree)(unsafe.Pointer(pRtree)).FnRowEst = int64(1048576) - if rc == 1 { - return 0 + if rc != SQLITE_OK { + (*Rtree)(unsafe.Pointer(pRtree)).FnRowEst = RTREE_DEFAULT_ROWEST + if rc == SQLITE_ERROR { + return SQLITE_OK } return rc } zSql = Xsqlite3_mprintf(tls, zFmt, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName)) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+16 /* &p */, uintptr(0)) - if rc == 0 { - if Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p */))) == 100 { + if rc == SQLITE_OK { + if Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p */))) == SQLITE_ROW { nRow = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p */)), 0) } rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p */))) - } else if rc != 7 { - rc = 0 + } else if rc != SQLITE_NOMEM { + rc = SQLITE_OK } - if rc == 0 { + if rc == SQLITE_OK { if nRow == int64(0) { - (*Rtree)(unsafe.Pointer(pRtree)).FnRowEst = int64(1048576) + (*Rtree)(unsafe.Pointer(pRtree)).FnRowEst = RTREE_DEFAULT_ROWEST } else { (*Rtree)(unsafe.Pointer(pRtree)).FnRowEst = func() int64 { - if (nRow) > (int64(100)) { + if (nRow) > (RTREE_MIN_ROWEST) { return nRow } - return int64(100) + return RTREE_MIN_ROWEST }() } } @@ -153599,64 +151079,38 @@ var azName1 = [3]uintptr{ } /* sqlite3.c:191506:21 */ var rtreeModule = Sqlite3_module{ - FiVersion: 3, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - create a table - 0, - FxBestIndex:// xConnect - connect to an existing table - 0, - FxDisconnect:// xBestIndex - Determine search strategy - 0, - FxDestroy:// xDisconnect - Disconnect from a table - 0, - FxOpen:// xDestroy - Drop a table - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - write data - 0, - FxSync:// xBegin - begin transaction - 0, - FxCommit:// xSync - sync transaction - 0, - FxRollback:// xCommit - commit transaction - 0, - FxFindFunction:// xRollback - rollback transaction - uintptr(0), - FxRename:// xFindFunction - function overloading - 0, - FxSavepoint:// xRename - rename the table - 0, - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - 0, // xShadowName + FiVersion: 3, // iVersion + FxCreate: 0, // xCreate - create a table + FxConnect: 0, // xConnect - connect to an existing table + FxBestIndex: 0, // xBestIndex - Determine search strategy + FxDisconnect: 0, // xDisconnect - Disconnect from a table + FxDestroy: 0, // xDestroy - Drop a table + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRowid - read data + FxUpdate: 0, // xUpdate - write data + FxBegin: 0, // xBegin - begin transaction + FxSync: 0, // xSync - sync transaction + FxCommit: 0, // xCommit - commit transaction + FxRollback: 0, // xFindFunction - function overloading + FxRename: 0, // xRename - rename the table + FxSavepoint: 0, // xRollbackTo + FxShadowName: 0, // xShadowName } /* sqlite3.c:191516:23 */ func rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefix uintptr, isCreate int32) int32 { /* sqlite3.c:191543:12: */ bp := tls.Alloc(232) defer tls.Free(232) - var rc int32 = 0 + var rc int32 = SQLITE_OK // var appStmt [8]uintptr at bp+168, 64 var i int32 - var f int32 = (0x01 | 0x04) + var f int32 = (SQLITE_PREPARE_PERSISTENT | SQLITE_PREPARE_NO_VTAB) (*Rtree)(unsafe.Pointer(pRtree)).Fdb = db @@ -153681,26 +151135,26 @@ func rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefi libc.VaList(bp+56, zDb, zPrefix, (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize)) zCreate = Xsqlite3_str_finish(tls, p) if !(zCreate != 0) { - return 7 + return SQLITE_NOMEM } rc = Xsqlite3_exec(tls, db, zCreate, uintptr(0), uintptr(0), uintptr(0)) Xsqlite3_free(tls, zCreate) - if rc != 0 { + if rc != SQLITE_OK { return rc } } - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(0)*8)) = (pRtree + 120 /* &.pWriteNode */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(1)*8)) = (pRtree + 128 /* &.pDeleteNode */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(2)*8)) = (pRtree + 136 /* &.pReadRowid */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(3)*8)) = (pRtree + 144 /* &.pWriteRowid */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(4)*8)) = (pRtree + 152 /* &.pDeleteRowid */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(5)*8)) = (pRtree + 160 /* &.pReadParent */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(6)*8)) = (pRtree + 168 /* &.pWriteParent */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(7)*8)) = (pRtree + 176 /* &.pDeleteParent */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */)) = (pRtree + 120 /* &.pWriteNode */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 1*8)) = (pRtree + 128 /* &.pDeleteNode */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 2*8)) = (pRtree + 136 /* &.pReadRowid */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 3*8)) = (pRtree + 144 /* &.pWriteRowid */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 4*8)) = (pRtree + 152 /* &.pDeleteRowid */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 5*8)) = (pRtree + 160 /* &.pReadParent */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 6*8)) = (pRtree + 168 /* &.pWriteParent */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 7*8)) = (pRtree + 176 /* &.pDeleteParent */) rc = rtreeQueryStat1(tls, db, pRtree) - for i = 0; (i < 8) && (rc == 0); i++ { + for i = 0; (i < N_STATEMENT) && (rc == SQLITE_OK); i++ { var zSql uintptr var zFormat uintptr if (i != 3) || (int32((*Rtree)(unsafe.Pointer(pRtree)).FnAux) == 0) { @@ -153714,7 +151168,7 @@ func rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefi if zSql != 0 { rc = Xsqlite3_prepare_v3(tls, db, zSql, -1, uint32(f), *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(i)*8)), uintptr(0)) } else { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3_free(tls, zSql) } @@ -153723,7 +151177,7 @@ func rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefi ts+23036, /* "SELECT * FROM \"%..." */ libc.VaList(bp+96, zDb, zPrefix)) if (*Rtree)(unsafe.Pointer(pRtree)).FzReadAuxSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var p uintptr = Xsqlite3_str_new(tls, db) var ii int32 @@ -153742,7 +151196,7 @@ func rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefi Xsqlite3_str_appendf(tls, p, ts+23138 /* " WHERE rowid=?1" */, 0) zSql = Xsqlite3_str_finish(tls, p) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_prepare_v3(tls, db, zSql, -1, uint32(f), (pRtree + 184 /* &.pWriteAux */), uintptr(0)) Xsqlite3_free(tls, zSql) @@ -153778,12 +151232,12 @@ func getIntFromStmt(tls *libc.TLS, db uintptr, zSql uintptr, piVal uintptr) int3 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 7 + var rc int32 = SQLITE_NOMEM if zSql != 0 { *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp /* &pStmt */, uintptr(0)) - if rc == 0 { - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { + if rc == SQLITE_OK { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { *(*int32)(unsafe.Pointer(piVal)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 0) } rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) @@ -153815,10 +151269,10 @@ func getNodeSize(tls *libc.TLS, db uintptr, pRtree uintptr, isCreate int32, pzEr *(*int32)(unsafe.Pointer(bp + 48 /* iPageSize */)) = 0 zSql = Xsqlite3_mprintf(tls, ts+23563 /* "PRAGMA %Q.page_s..." */, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzDb)) rc = getIntFromStmt(tls, db, zSql, bp+48 /* &iPageSize */) - if rc == 0 { + if rc == SQLITE_OK { (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize = (*(*int32)(unsafe.Pointer(bp + 48 /* iPageSize */)) - 64) - if (4 + (int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) * 51)) < (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize { - (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize = (4 + (int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) * 51)) + if (4 + (int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) * RTREE_MAXCELLS)) < (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize { + (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize = (4 + (int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) * RTREE_MAXCELLS)) } } else { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) @@ -153828,10 +151282,10 @@ func getNodeSize(tls *libc.TLS, db uintptr, pRtree uintptr, isCreate int32, pzEr ts+23583, /* "SELECT length(da..." */ libc.VaList(bp+16, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName)) rc = getIntFromStmt(tls, db, zSql, (pRtree + 32 /* &.iNodeSize */)) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp+32, Xsqlite3_errmsg(tls, db))) } else if (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize < (512 - 64) { - rc = (11 | (int32(1) << 8)) + rc = (SQLITE_CORRUPT | (int32(1) << 8)) *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+23640, /* "undersize RTree ..." */ libc.VaList(bp+40, (*Rtree)(unsafe.Pointer(pRtree)).FzName)) @@ -153874,12 +151328,12 @@ func rtreeInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr // var aErrMsg [5]uintptr at bp+96, 40 var zArg uintptr - rc = 0 + rc = SQLITE_OK eCoordType = func() int32 { if pAux != 0 { - return 1 + return RTREE_COORD_INT32 } - return 0 + return RTREE_COORD_REAL32 }() ii = 4 *(*[5]uintptr)(unsafe.Pointer(bp + 96 /* aErrMsg */)) = [5]uintptr{ @@ -153891,48 +151345,48 @@ func rtreeInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr } // Aux columns counted by a u8 - if !((argc < 6) || (argc > (100 + 3))) { + if !((argc < 6) || (argc > (RTREE_MAX_AUX_COLUMN + 3))) { goto __1 } *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 96 /* &aErrMsg[0] */ + uintptr((2+(libc.Bool32(argc >= 6))))*8)))) - return 1 + return SQLITE_ERROR __1: ; - Xsqlite3_vtab_config(tls, db, 1, libc.VaList(bp+8, 1)) + Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_CONSTRAINT_SUPPORT, libc.VaList(bp+8, 1)) // Allocate the sqlite3_vtab structure - nDb = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) - nName = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + nDb = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) + nName = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) pRtree = Xsqlite3_malloc64(tls, (uint64(((uint64(unsafe.Sizeof(Rtree{})) + uint64(nDb)) + uint64(nName)) + uint64(2)))) if !(!(pRtree != 0)) { goto __2 } - return 7 + return SQLITE_NOMEM __2: ; libc.Xmemset(tls, pRtree, 0, (((uint64(unsafe.Sizeof(Rtree{})) + uint64(nDb)) + uint64(nName)) + uint64(2))) (*Rtree)(unsafe.Pointer(pRtree)).FnBusy = U32(1) (*Rtree)(unsafe.Pointer(pRtree)).Fbase.FpModule = uintptr(unsafe.Pointer(&rtreeModule)) - (*Rtree)(unsafe.Pointer(pRtree)).FzDb = (pRtree + uintptr(1)*968) + (*Rtree)(unsafe.Pointer(pRtree)).FzDb = (pRtree + 1*968) (*Rtree)(unsafe.Pointer(pRtree)).FzName = ((*Rtree)(unsafe.Pointer(pRtree)).FzDb + uintptr((nDb + 1))) (*Rtree)(unsafe.Pointer(pRtree)).FeCoordType = U8(eCoordType) - libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uint64(nDb)) - libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzName, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), uint64(nName)) + libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uint64(nDb)) + libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzName, *(*uintptr)(unsafe.Pointer(argv + 2*8)), uint64(nName)) // Create/Connect to the underlying relational database schema. If // that is successful, call sqlite3_declare_vtab() to configure // the r-tree table schema. pSql = Xsqlite3_str_new(tls, db) Xsqlite3_str_appendf(tls, pSql, ts+23826, /* "CREATE TABLE x(%..." */ - libc.VaList(bp+16, rtreeTokenLength(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))), *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)))) + libc.VaList(bp+16, rtreeTokenLength(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))), *(*uintptr)(unsafe.Pointer(argv + 3*8)))) ii = 4 __3: if !(ii < argc) { goto __5 } zArg = *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*8)) - if !(int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) == '+') { + if !(int32(*(*int8)(unsafe.Pointer(zArg))) == '+') { goto __6 } (*Rtree)(unsafe.Pointer(pRtree)).FnAux++ @@ -153964,17 +151418,17 @@ __5: if !(!(zSql != 0)) { goto __10 } - rc = 7 + rc = SQLITE_NOMEM goto __11 __10: if !(ii < argc) { goto __12 } - *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(bp + 96 /* &aErrMsg[0] */ + uintptr(4)*8)))) - rc = 1 + *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(bp + 96 /* &aErrMsg[0] */ + 4*8)))) + rc = SQLITE_ERROR goto __13 __12: - if !(0 != (libc.AssignInt32(&rc, Xsqlite3_declare_vtab(tls, db, zSql)))) { + if !(SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3_declare_vtab(tls, db, zSql)))) { goto __14 } *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp+72, Xsqlite3_errmsg(tls, db))) @@ -153998,7 +151452,7 @@ __15: iErr = 2 goto __17 __16: - if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) > (5 * 2)) { + if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) > (RTREE_MAX_DIMENSIONS * 2)) { goto __18 } iErr = 3 @@ -154034,7 +151488,7 @@ __22: goto rtreeInit_fail __23: ; - rc = rtreeSqlInit(tls, pRtree, db, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), isCreate) + rc = rtreeSqlInit(tls, pRtree, db, *(*uintptr)(unsafe.Pointer(argv + 1*8)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), isCreate) if !(rc != 0) { goto __24 } @@ -154044,13 +151498,13 @@ __24: ; *(*uintptr)(unsafe.Pointer(ppVtab)) = pRtree - return 0 + return SQLITE_OK rtreeInit_fail: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __25 } - rc = 1 + rc = SQLITE_ERROR __25: ; @@ -154090,23 +151544,23 @@ func rtreenode(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* sqlit _ = nArg libc.Xmemset(tls, bp+16 /* &node */, 0, uint64(unsafe.Sizeof(RtreeNode{}))) libc.Xmemset(tls, bp+56 /* &tree */, 0, uint64(unsafe.Sizeof(Rtree{}))) - (*Rtree)(unsafe.Pointer(bp + 56 /* &tree */)).FnDim = U8(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8)))) + (*Rtree)(unsafe.Pointer(bp + 56 /* &tree */)).FnDim = U8(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apArg)))) if (int32((*Rtree)(unsafe.Pointer(bp+56 /* &tree */)).FnDim) < 1) || (int32((*Rtree)(unsafe.Pointer(bp+56 /* &tree */)).FnDim) > 5) { return } (*Rtree)(unsafe.Pointer(bp + 56 /* &tree */)).FnDim2 = (U8(int32((*Rtree)(unsafe.Pointer(bp+56 /* &tree */)).FnDim) * 2)) (*Rtree)(unsafe.Pointer(bp + 56 /* &tree */)).FnBytesPerCell = (U8(8 + (8 * int32((*Rtree)(unsafe.Pointer(bp+56 /* &tree */)).FnDim)))) - (*RtreeNode)(unsafe.Pointer(bp + 16 /* &node */)).FzData = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(1)*8))) - nData = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(1)*8))) + (*RtreeNode)(unsafe.Pointer(bp + 16 /* &node */)).FzData = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*8))) + nData = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*8))) if nData < 4 { return } - if nData < (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((bp+16 /* &node */))).FzData+uintptr(2))) * int32((*Rtree)(unsafe.Pointer(bp+56 /* &tree */)).FnBytesPerCell)) { + if nData < (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((bp+16 /* &node */))).FzData+2)) * int32((*Rtree)(unsafe.Pointer(bp+56 /* &tree */)).FnBytesPerCell)) { return } pOut = Xsqlite3_str_new(tls, uintptr(0)) - for ii = 0; ii < readInt16(tls, ((*RtreeNode)(unsafe.Pointer((bp+16 /* &node */))).FzData+uintptr(2))); ii++ { + for ii = 0; ii < readInt16(tls, ((*RtreeNode)(unsafe.Pointer((bp+16 /* &node */))).FzData+2)); ii++ { // var cell RtreeCell at bp+1024, 48 var jj int32 @@ -154136,11 +151590,11 @@ func rtreenode(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* sqlit // routine. This routine is intended for testing and analysis only. func rtreedepth(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* sqlite3.c:191948:13: */ _ = nArg - if (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) != 4) || - (Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) < 2) { + if (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apArg))) != SQLITE_BLOB) || + (Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apArg))) < 2) { Xsqlite3_result_error(tls, ctx, ts+23892 /* "Invalid argument..." */, -1) } else { - var zBlob uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) + var zBlob uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apArg))) Xsqlite3_result_int(tls, ctx, readInt16(tls, zBlob)) } } @@ -154172,7 +151626,7 @@ type RtreeCheck = RtreeCheck1 /* sqlite3.c:191964:27 */ // and RtreeCheck.rc==SQLITE_OK, set RtreeCheck.rc to the error code. func rtreeCheckReset(tls *libc.TLS, pCheck uintptr, pStmt uintptr) { /* sqlite3.c:191986:13: */ var rc int32 = Xsqlite3_reset(tls, pStmt) - if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = rc } } @@ -154195,9 +151649,9 @@ func rtreeCheckPrepare(tls *libc.TLS, pCheck uintptr, zFmt uintptr, va uintptr) ap = va z = Xsqlite3_vmprintf(tls, zFmt, ap) - if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { if z == uintptr(0) { - (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = 7 + (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM } else { (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = Xsqlite3_prepare_v2(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).Fdb, z, -1, bp /* &pRet */, uintptr(0)) } @@ -154218,10 +151672,10 @@ func rtreeCheckAppendMsg(tls *libc.TLS, pCheck uintptr, zFmt uintptr, va uintptr var ap Va_list _ = ap ap = va - if ((*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0) && ((*RtreeCheck)(unsafe.Pointer(pCheck)).FnErr < 100) { + if ((*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK) && ((*RtreeCheck)(unsafe.Pointer(pCheck)).FnErr < RTREE_CHECK_MAX_ERROR) { var z uintptr = Xsqlite3_vmprintf(tls, zFmt, ap) if z == uintptr(0) { - (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = 7 + (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM } else { (*RtreeCheck)(unsafe.Pointer(pCheck)).FzReport = Xsqlite3_mprintf(tls, ts+23925, /* "%z%s%z" */ libc.VaList(bp, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzReport, func() uintptr { @@ -154231,7 +151685,7 @@ func rtreeCheckAppendMsg(tls *libc.TLS, pCheck uintptr, zFmt uintptr, va uintptr return ts + 703 /* "" */ }(), z)) if (*RtreeCheck)(unsafe.Pointer(pCheck)).FzReport == uintptr(0) { - (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = 7 + (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM } } (*RtreeCheck)(unsafe.Pointer(pCheck)).FnErr++ @@ -154257,27 +151711,27 @@ func rtreeCheckGetNode(tls *libc.TLS, pCheck uintptr, iNode I64, pnNode uintptr) var pRet uintptr = uintptr(0) // Return value - if ((*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0) && ((*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode == uintptr(0)) { + if ((*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK) && ((*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode == uintptr(0)) { (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode = rtreeCheckPrepare(tls, pCheck, ts+23932, /* "SELECT data FROM..." */ libc.VaList(bp, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzTab)) } - if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { Xsqlite3_bind_int64(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 1, iNode) - if Xsqlite3_step(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode) == 100 { + if Xsqlite3_step(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode) == SQLITE_ROW { var nNode int32 = Xsqlite3_column_bytes(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 0) var pNode uintptr = Xsqlite3_column_blob(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 0) pRet = Xsqlite3_malloc64(tls, uint64(nNode)) if pRet == uintptr(0) { - (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = 7 + (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM } else { libc.Xmemcpy(tls, pRet, pNode, uint64(nNode)) *(*int32)(unsafe.Pointer(pnNode)) = nNode } } rtreeCheckReset(tls, pCheck, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode) - if ((*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0) && (pRet == uintptr(0)) { + if ((*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK) && (pRet == uintptr(0)) { rtreeCheckAppendMsg(tls, pCheck, ts+23977 /* "Node %lld missin..." */, libc.VaList(bp+16, iNode)) } } @@ -154310,14 +151764,14 @@ func rtreeCheckMapping(tls *libc.TLS, pCheck uintptr, bLeaf int32, iKey I64, iVa *(*uintptr)(unsafe.Pointer((pCheck + 40 /* &.aCheckMapping */) + uintptr(bLeaf)*8)) = rtreeCheckPrepare(tls, pCheck, *(*uintptr)(unsafe.Pointer(bp + 80 /* &azSql[0] */ + uintptr(bLeaf)*8)), libc.VaList(bp, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzTab)) } - if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc != 0 { + if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc != SQLITE_OK { return } pStmt = *(*uintptr)(unsafe.Pointer((pCheck + 40 /* &.aCheckMapping */) + uintptr(bLeaf)*8)) Xsqlite3_bind_int64(tls, pStmt, 1, iKey) rc = Xsqlite3_step(tls, pStmt) - if rc == 101 { + if rc == SQLITE_DONE { rtreeCheckAppendMsg(tls, pCheck, ts+24111, /* "Mapping (%lld ->..." */ libc.VaList(bp+16, iKey, iVal, func() uintptr { if bLeaf != 0 { @@ -154325,7 +151779,7 @@ func rtreeCheckMapping(tls *libc.TLS, pCheck uintptr, bLeaf int32, iKey I64, iVa } return ts + 24164 /* "%_parent" */ }())) - } else if rc == 100 { + } else if rc == SQLITE_ROW { var ii I64 = Xsqlite3_column_int64(tls, pStmt, 0) if ii != iVal { rtreeCheckAppendMsg(tls, pCheck, @@ -154426,13 +151880,13 @@ func rtreeCheckNode(tls *libc.TLS, pCheck uintptr, iDepth int32, aParent uintptr var i int32 // Used to iterate through cells if aParent == uintptr(0) { iDepth = readInt16(tls, aNode) - if iDepth > 40 { + if iDepth > RTREE_MAX_DEPTH { rtreeCheckAppendMsg(tls, pCheck, ts+24380 /* "Rtree depth out ..." */, libc.VaList(bp+16, iDepth)) Xsqlite3_free(tls, aNode) return } } - nCell = readInt16(tls, (aNode + uintptr(2))) + nCell = readInt16(tls, (aNode + 2)) if (4 + (nCell * (8 + (((*RtreeCheck)(unsafe.Pointer(pCheck)).FnDim * 2) * 4)))) > *(*int32)(unsafe.Pointer(bp + 48 /* nNode */)) { rtreeCheckAppendMsg(tls, pCheck, ts+24410, /* "Node %lld is too..." */ @@ -154441,11 +151895,11 @@ func rtreeCheckNode(tls *libc.TLS, pCheck uintptr, iDepth int32, aParent uintptr for i = 0; i < nCell; i++ { var pCell uintptr = (aNode + uintptr((4 + (i * (8 + (((*RtreeCheck)(unsafe.Pointer(pCheck)).FnDim * 2) * 4)))))) var iVal I64 = readInt64(tls, pCell) - rtreeCheckCellCoord(tls, pCheck, iNode, i, (pCell + uintptr(8)), aParent) + rtreeCheckCellCoord(tls, pCheck, iNode, i, (pCell + 8), aParent) if iDepth > 0 { rtreeCheckMapping(tls, pCheck, 0, iVal, iNode) - rtreeCheckNode(tls, pCheck, (iDepth - 1), (pCell + uintptr(8)), iVal) + rtreeCheckNode(tls, pCheck, (iDepth - 1), (pCell + 8), iVal) (*RtreeCheck)(unsafe.Pointer(pCheck)).FnNonLeaf++ } else { rtreeCheckMapping(tls, pCheck, 1, iVal, iNode) @@ -154467,12 +151921,12 @@ func rtreeCheckCount(tls *libc.TLS, pCheck uintptr, zTbl uintptr, nExpect I64) { bp := tls.Alloc(48) defer tls.Free(48) - if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { var pCount uintptr pCount = rtreeCheckPrepare(tls, pCheck, ts+24465, /* "SELECT count(*) ..." */ libc.VaList(bp, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzTab, zTbl)) if pCount != 0 { - if Xsqlite3_step(tls, pCount) == 100 { + if Xsqlite3_step(tls, pCount) == SQLITE_ROW { var nActual I64 = Xsqlite3_column_int64(tls, pCount, 0) if nActual != nExpect { rtreeCheckAppendMsg(tls, pCheck, @@ -154511,13 +151965,13 @@ func rtreeCheckTable(tls *libc.TLS, db uintptr, zDb uintptr, zTab uintptr, pzRep } // Find the number of auxiliary columns - if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).Frc == SQLITE_OK { pStmt = rtreeCheckPrepare(tls, bp+32 /* &check */, ts+24563 /* "SELECT * FROM %Q..." */, libc.VaList(bp, zDb, zTab)) if pStmt != 0 { nAux = (Xsqlite3_column_count(tls, pStmt) - 2) Xsqlite3_finalize(tls, pStmt) } - (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).Frc = 0 + (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).Frc = SQLITE_OK } // Find number of dimensions in the rtree table. @@ -154527,18 +151981,18 @@ func rtreeCheckTable(tls *libc.TLS, db uintptr, zDb uintptr, zTab uintptr, pzRep (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).FnDim = (((Xsqlite3_column_count(tls, pStmt) - 1) - nAux) / 2) if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).FnDim < 1 { rtreeCheckAppendMsg(tls, bp+32 /* &check */, ts+24591 /* "Schema corrupt o..." */, 0) - } else if 100 == Xsqlite3_step(tls, pStmt) { - (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).FbInt = (libc.Bool32(Xsqlite3_column_type(tls, pStmt, 1) == 1)) + } else if SQLITE_ROW == Xsqlite3_step(tls, pStmt) { + (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).FbInt = (libc.Bool32(Xsqlite3_column_type(tls, pStmt, 1) == SQLITE_INTEGER)) } rc = Xsqlite3_finalize(tls, pStmt) - if rc != 11 { + if rc != SQLITE_CORRUPT { (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).Frc = rc } } // Do the actual integrity-check if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).FnDim >= 1 { - if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).Frc == SQLITE_OK { rtreeCheckNode(tls, bp+32 /* &check */, 0, uintptr(0), int64(1)) } rtreeCheckCount(tls, bp+32 /* &check */, ts+24622 /* "_rowid" */, int64((*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).FnLeaf)) @@ -154547,13 +152001,13 @@ func rtreeCheckTable(tls *libc.TLS, db uintptr, zDb uintptr, zTab uintptr, pzRep // Finalize SQL statements used by the integrity-check Xsqlite3_finalize(tls, (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).FpGetNode) - Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer((bp + 32 /* &check */ + 40 /* &.aCheckMapping */) + uintptr(0)*8))) - Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer((bp + 32 /* &check */ + 40 /* &.aCheckMapping */) + uintptr(1)*8))) + Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer((bp + 32 /* &check */ + 40 /* &.aCheckMapping */)))) + Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer((bp + 32 /* &check */ + 40 /* &.aCheckMapping */) + 1*8))) // If one was opened, close the transaction if bEnd != 0 { var rc int32 = Xsqlite3_exec(tls, db, ts+24637 /* "END" */, uintptr(0), uintptr(0), uintptr(0)) - if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).Frc == SQLITE_OK { (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).Frc = rc } } @@ -154602,16 +152056,16 @@ func rtreecheck(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* sqli } else { var rc int32 *(*uintptr)(unsafe.Pointer(bp /* zReport */)) = uintptr(0) - var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) + var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg))) var zTab uintptr if nArg == 1 { zTab = zDb zDb = ts + 5282 /* "main" */ } else { - zTab = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(1)*8))) + zTab = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*8))) } rc = rtreeCheckTable(tls, Xsqlite3_context_db_handle(tls, ctx), zDb, zTab, bp /* &zReport */) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_result_text(tls, ctx, func() uintptr { if *(*uintptr)(unsafe.Pointer(bp /* zReport */)) != 0 { return *(*uintptr)(unsafe.Pointer(bp /* zReport */)) @@ -154730,20 +152184,20 @@ type GeoParse = GeoParse1 /* sqlite3.c:192567:25 */ // Do a 4-byte byte swap func geopolySwab32(tls *libc.TLS, a uintptr) { /* sqlite3.c:192577:13: */ - var t uint8 = *(*uint8)(unsafe.Pointer(a + uintptr(0))) - *(*uint8)(unsafe.Pointer(a + uintptr(0))) = *(*uint8)(unsafe.Pointer(a + uintptr(3))) - *(*uint8)(unsafe.Pointer(a + uintptr(3))) = t - t = *(*uint8)(unsafe.Pointer(a + uintptr(1))) - *(*uint8)(unsafe.Pointer(a + uintptr(1))) = *(*uint8)(unsafe.Pointer(a + uintptr(2))) - *(*uint8)(unsafe.Pointer(a + uintptr(2))) = t + var t uint8 = *(*uint8)(unsafe.Pointer(a)) + *(*uint8)(unsafe.Pointer(a)) = *(*uint8)(unsafe.Pointer(a + 3)) + *(*uint8)(unsafe.Pointer(a + 3)) = t + t = *(*uint8)(unsafe.Pointer(a + 1)) + *(*uint8)(unsafe.Pointer(a + 1)) = *(*uint8)(unsafe.Pointer(a + 2)) + *(*uint8)(unsafe.Pointer(a + 2)) = t } // Skip whitespace. Return the next non-whitespace character. func geopolySkipSpace(tls *libc.TLS, p uintptr) int8 { /* sqlite3.c:192587:13: */ - for jsonIsSpace[*(*uint8)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(p)).Fz + uintptr(0)))] != 0 { + for jsonIsSpace[*(*uint8)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(p)).Fz))] != 0 { (*GeoParse)(unsafe.Pointer(p)).Fz++ } - return int8(*(*uint8)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(p)).Fz + uintptr(0)))) + return int8(*(*uint8)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(p)).Fz))) } // Parse out a number. Write the value into *pVal if pVal!=0. @@ -154807,7 +152261,7 @@ func geopolyParseNumber(tls *libc.TLS, p uintptr, pVal uintptr) int32 { /* sqlit // is available // var r float64 at bp, 8 - Xsqlite3AtoF(tls, (*GeoParse)(unsafe.Pointer(p)).Fz, bp /* &r */, j, uint8(1)) + Xsqlite3AtoF(tls, (*GeoParse)(unsafe.Pointer(p)).Fz, bp /* &r */, j, SQLITE_UTF8) *(*GeoCoord)(unsafe.Pointer(pVal)) = GeoCoord(*(*float64)(unsafe.Pointer(bp /* r */))) } *(*uintptr)(unsafe.Pointer(p /* &.z */)) += (uintptr(j)) @@ -154832,7 +152286,7 @@ func geopolyParseJson(tls *libc.TLS, z uintptr, pRc uintptr) uintptr { /* sqlite var c int8 var pOut uintptr // var x int32 at bp+32, 4 - rc = 0 + rc = SQLITE_OK libc.Xmemset(tls, bp /* &s */, 0, uint64(unsafe.Sizeof(GeoParse{}))) (*GeoParse)(unsafe.Pointer(bp /* &s */)).Fz = z if !(int32(geopolySkipSpace(tls, bp /* &s */)) == '[') { @@ -154853,7 +152307,7 @@ __2: if !(aNew == uintptr(0)) { goto __5 } - rc = 7 + rc = SQLITE_NOMEM (*GeoParse)(unsafe.Pointer(bp /* &s */)).FnErr++ goto __3 __5: @@ -154892,7 +152346,7 @@ __9: __10: ; (*GeoParse)(unsafe.Pointer(bp /* &s */)).FnErr++ - rc = 1 + rc = SQLITE_ERROR goto parse_json_err goto __6 __7: @@ -154910,8 +152364,8 @@ __3: ; if !(((((int32(geopolySkipSpace(tls, bp /* &s */)) == ']') && ((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex >= 4)) && - (*(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + uintptr(0)*4)) == *(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + uintptr((((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex*2)-2))*4)))) && - (*(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + uintptr(1)*4)) == *(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + uintptr((((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex*2)-1))*4)))) && + (*(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa)) == *(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + uintptr((((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex*2)-2))*4)))) && + (*(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + 1*4)) == *(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + uintptr((((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex*2)-1))*4)))) && (func() bool { (*GeoParse)(unsafe.Pointer(bp /* &s */)).Fz++ return (int32(geopolySkipSpace(tls, bp /* &s */)) == 0) @@ -154930,22 +152384,22 @@ __14: ; (*GeoPoly)(unsafe.Pointer(pOut)).FnVertex = (*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex libc.Xmemcpy(tls, pOut+8 /* &.a */, (*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa, ((uint64((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex * 2)) * uint64(unsafe.Sizeof(GeoCoord(0))))) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(0))) = *(*uint8)(unsafe.Pointer(bp + 32 /* &x */)) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(1))) = (uint8(((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex >> 16) & 0xff)) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(2))) = (uint8(((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex >> 8) & 0xff)) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(3))) = (uint8((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex & 0xff)) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */))) = *(*uint8)(unsafe.Pointer(bp + 32 /* &x */)) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + 1)) = (uint8(((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex >> 16) & 0xff)) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + 2)) = (uint8(((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex >> 8) & 0xff)) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + 3)) = (uint8((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex & 0xff)) Xsqlite3_free(tls, (*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa) if !(pRc != 0) { goto __15 } - *(*int32)(unsafe.Pointer(pRc)) = 0 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_OK __15: ; return pOut goto __13 __12: (*GeoParse)(unsafe.Pointer(bp /* &s */)).FnErr++ - rc = 1 + rc = SQLITE_ERROR __13: ; __1: @@ -154971,17 +152425,17 @@ func geopolyFuncParam(tls *libc.TLS, pCtx uintptr, pVal uintptr, pRc uintptr) ui var p uintptr = uintptr(0) var nByte int32 - if (Xsqlite3_value_type(tls, pVal) == 4) && + if (Xsqlite3_value_type(tls, pVal) == SQLITE_BLOB) && ((uint64(libc.AssignInt32(&nByte, Xsqlite3_value_bytes(tls, pVal)))) >= (uint64(4) + (uint64(6) * uint64(unsafe.Sizeof(GeoCoord(0)))))) { var a uintptr = Xsqlite3_value_blob(tls, pVal) var nVertex int32 - nVertex = (((int32(*(*uint8)(unsafe.Pointer(a + uintptr(1)))) << 16) + (int32(*(*uint8)(unsafe.Pointer(a + uintptr(2)))) << 8)) + int32(*(*uint8)(unsafe.Pointer(a + uintptr(3))))) - if ((int32(*(*uint8)(unsafe.Pointer(a + uintptr(0)))) == 0) || (int32(*(*uint8)(unsafe.Pointer(a + uintptr(0)))) == 1)) && + nVertex = (((int32(*(*uint8)(unsafe.Pointer(a + 1))) << 16) + (int32(*(*uint8)(unsafe.Pointer(a + 2))) << 8)) + int32(*(*uint8)(unsafe.Pointer(a + 3)))) + if ((int32(*(*uint8)(unsafe.Pointer(a))) == 0) || (int32(*(*uint8)(unsafe.Pointer(a))) == 1)) && ((((uint64(nVertex * 2)) * uint64(unsafe.Sizeof(GeoCoord(0)))) + uint64(4)) == uint64(uint32(nByte))) { p = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(GeoPoly{})) + ((uint64((nVertex - 1) * 2)) * uint64(unsafe.Sizeof(GeoCoord(0))))))) if p == uintptr(0) { if pRc != 0 { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } if pCtx != 0 { Xsqlite3_result_error_nomem(tls, pCtx) @@ -154990,32 +152444,32 @@ func geopolyFuncParam(tls *libc.TLS, pCtx uintptr, pVal uintptr, pRc uintptr) ui *(*int32)(unsafe.Pointer(bp /* x */)) = 1 (*GeoPoly)(unsafe.Pointer(p)).FnVertex = nVertex libc.Xmemcpy(tls, p+4 /* &.hdr */, a, uint64(nByte)) - if int32(*(*uint8)(unsafe.Pointer(a + uintptr(0)))) != int32(*(*uint8)(unsafe.Pointer(bp /* &x */))) { + if int32(*(*uint8)(unsafe.Pointer(a))) != int32(*(*uint8)(unsafe.Pointer(bp /* &x */))) { var ii int32 for ii = 0; ii < nVertex; ii++ { geopolySwab32(tls, ((p + 8 /* &.a */) + uintptr(((ii)*2))*4)) geopolySwab32(tls, ((p + 8 /* &.a */) + uintptr((((ii)*2)+1))*4)) } - *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + uintptr(0))) ^= uint8((1)) + *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */))) ^= uint8((1)) } } } if pRc != 0 { - *(*int32)(unsafe.Pointer(pRc)) = 0 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_OK } return p - } else if Xsqlite3_value_type(tls, pVal) == 3 { + } else if Xsqlite3_value_type(tls, pVal) == SQLITE_TEXT { var zJson uintptr = Xsqlite3_value_text(tls, pVal) if zJson == uintptr(0) { if pRc != 0 { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } return uintptr(0) } return geopolyParseJson(tls, zJson, pRc) } else { if pRc != 0 { - *(*int32)(unsafe.Pointer(pRc)) = 1 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_ERROR } return uintptr(0) } @@ -155028,7 +152482,7 @@ func geopolyFuncParam(tls *libc.TLS, pCtx uintptr, pVal uintptr, pRc uintptr) ui // then return the BLOB representation of the polygon. Otherwise // return NULL. func geopolyBlobFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:192786:13: */ - var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) + var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) if p != 0 { Xsqlite3_result_blob(tls, context, p+4, /* &.hdr */ (4 + (8 * (*GeoPoly)(unsafe.Pointer(p)).FnVertex)), libc.UintptrFromInt32(-1)) @@ -155044,7 +152498,7 @@ func geopolyJsonFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { bp := tls.Alloc(32) defer tls.Free(32) - var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) + var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) if p != 0 { var db uintptr = Xsqlite3_context_db_handle(tls, context) var x uintptr = Xsqlite3_str_new(tls, db) @@ -155053,7 +152507,7 @@ func geopolyJsonFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { for i = 0; i < (*GeoPoly)(unsafe.Pointer(p)).FnVertex; i++ { Xsqlite3_str_appendf(tls, x, ts+24694 /* "[%!g,%!g]," */, libc.VaList(bp, float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((i)*2))*4))), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((i)*2)+1))*4))))) } - Xsqlite3_str_appendf(tls, x, ts+24705 /* "[%!g,%!g]]" */, libc.VaList(bp+16, float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((0)*2))*4))), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((0)*2)+1))*4))))) + Xsqlite3_str_appendf(tls, x, ts+24705 /* "[%!g,%!g]]" */, libc.VaList(bp+16, float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */)))), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + 1*4))))) Xsqlite3_result_text(tls, context, Xsqlite3_str_finish(tls, x), -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) Xsqlite3_free(tls, p) } @@ -155071,7 +152525,7 @@ func geopolySvgFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { if argc < 1 { return } - p = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) + p = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) if p != 0 { var db uintptr = Xsqlite3_context_db_handle(tls, context) var x uintptr = Xsqlite3_str_new(tls, db) @@ -155082,10 +152536,10 @@ func geopolySvgFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { Xsqlite3_str_appendf(tls, x, ts+24734 /* "%c%g,%g" */, libc.VaList(bp, int32(cSep), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((i)*2))*4))), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((i)*2)+1))*4))))) cSep = int8(' ') } - Xsqlite3_str_appendf(tls, x, ts+24742 /* " %g,%g'" */, libc.VaList(bp+24, float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((0)*2))*4))), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((0)*2)+1))*4))))) + Xsqlite3_str_appendf(tls, x, ts+24742 /* " %g,%g'" */, libc.VaList(bp+24, float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */)))), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + 1*4))))) for i = 1; i < argc; i++ { var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) - if (z != 0) && (*(*int8)(unsafe.Pointer(z + uintptr(0))) != 0) { + if (z != 0) && (*(*int8)(unsafe.Pointer(z)) != 0) { Xsqlite3_str_appendf(tls, x, ts+24750 /* " %s" */, libc.VaList(bp+40, z)) } } @@ -155110,13 +152564,13 @@ func geopolySvgFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { // // geopoly_xform(poly, cos(R), sin(R), -sin(R), cos(R), 0, 0) func geopolyXformFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:192878:13: */ - var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) - var A float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - var B float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) - var C float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) - var D float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8))) - var E float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(5)*8))) - var F float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(6)*8))) + var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) + var A float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + var B float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) + var C float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) + var D float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) + var E float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) + var F float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 6*8))) var x1 GeoCoord var y1 GeoCoord var x0 GeoCoord @@ -155150,8 +152604,8 @@ func geopolyArea(tls *libc.TLS, p uintptr) float64 { /* sqlite3.c:192914:15: */ ((*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((ii)*2)+1))*4))) + (*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((ii+1)*2)+1))*4)))))) * // (y0 + y1) 0.5) } - rArea = rArea + ((float64(((*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((ii)*2))*4))) - (*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((0)*2))*4)))) * // (xN - x0) - ((*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((ii)*2)+1))*4))) + (*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((0)*2)+1))*4)))))) * // (yN + y0) + rArea = rArea + ((float64(((*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((ii)*2))*4))) - (*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */))))) * // (xN - x0) + ((*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((ii)*2)+1))*4))) + (*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + 1*4)))))) * // (yN + y0) 0.5) return rArea } @@ -155163,7 +152617,7 @@ func geopolyArea(tls *libc.TLS, p uintptr) float64 { /* sqlite3.c:192914:15: */ // of counterclockwise (as it should) then return the negative of the // enclosed area. Otherwise return NULL. func geopolyAreaFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:192936:13: */ - var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) + var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) if p != 0 { Xsqlite3_result_double(tls, context, geopolyArea(tls, p)) Xsqlite3_free(tls, p) @@ -155182,7 +152636,7 @@ func geopolyAreaFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { // Use this routine to sanitize historical inputs that that sometimes // contain polygons that wind in the wrong direction. func geopolyCcwFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:192961:13: */ - var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) + var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) if p != 0 { if geopolyArea(tls, p) < 0.0 { var ii int32 @@ -155241,10 +152695,10 @@ func geopolyRegularFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr bp := tls.Alloc(4) defer tls.Free(4) - var x float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var y float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - var r float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) - var n int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) + var x float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) + var y float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + var r float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) + var n int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) // var i int32 at bp, 4 var p uintptr @@ -155261,10 +152715,10 @@ func geopolyRegularFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr return } *(*int32)(unsafe.Pointer(bp /* i */)) = 1 - *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + uintptr(0))) = *(*uint8)(unsafe.Pointer(bp /* &i */)) - *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + uintptr(1))) = uint8(0) - *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + uintptr(2))) = (uint8((n >> 8) & 0xff)) - *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + uintptr(3))) = (uint8(n & 0xff)) + *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */))) = *(*uint8)(unsafe.Pointer(bp /* &i */)) + *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + 1)) = uint8(0) + *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + 2)) = (uint8((n >> 8) & 0xff)) + *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + 3)) = (uint8(n & 0xff)) for *(*int32)(unsafe.Pointer(bp /* i */)) = 0; *(*int32)(unsafe.Pointer(bp /* i */)) < n; *(*int32)(unsafe.Pointer(bp /* i */))++ { var rAngle float64 = (((float64(2.0) * 3.1415926535897932385) * float64(*(*int32)(unsafe.Pointer(bp /* i */)))) / float64(n)) (*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((*(*int32)(unsafe.Pointer(bp /* i */)))*2))*4))) = (GeoCoord(x - (r * geopolySine(tls, (rAngle-(float64(0.5)*3.1415926535897932385)))))) @@ -155299,10 +152753,10 @@ func geopolyBBox(tls *libc.TLS, context uintptr, pPoly uintptr, aCoord uintptr, goto __1 } p = uintptr(0) - mnX = *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(0)*4)) - mxX = *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(1)*4)) - mnY = *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(2)*4)) - mxY = *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(3)*4)) + mnX = *(*RtreeValue)(unsafe.Pointer(aCoord)) + mxX = *(*RtreeValue)(unsafe.Pointer(aCoord + 1*4)) + mnY = *(*RtreeValue)(unsafe.Pointer(aCoord + 2*4)) + mxY = *(*RtreeValue)(unsafe.Pointer(aCoord + 3*4)) goto geopolyBboxFill goto __2 __1: @@ -155312,8 +152766,8 @@ __2: if !(p != 0) { goto __3 } - mnX = libc.AssignFloat32(&mxX, *(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((0)*2))*4))) - mnY = libc.AssignFloat32(&mxY, *(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((0)*2)+1))*4))) + mnX = libc.AssignFloat32(&mxX, *(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */)))) + mnY = libc.AssignFloat32(&mxY, *(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + 1*4))) *(*int32)(unsafe.Pointer(bp /* ii */)) = 1 __5: if !(*(*int32)(unsafe.Pointer(bp /* ii */)) < (*GeoPoly)(unsafe.Pointer(p)).FnVertex) { @@ -155359,7 +152813,7 @@ __7: if !(pRc != 0) { goto __14 } - *(*int32)(unsafe.Pointer(pRc)) = 0 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_OK __14: ; if !(aCoord == uintptr(0)) { @@ -155380,7 +152834,7 @@ __18: if !(pRc != 0) { goto __19 } - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM __19: ; return uintptr(0) @@ -155388,25 +152842,25 @@ __17: ; (*GeoPoly)(unsafe.Pointer(pOut)).FnVertex = 4 *(*int32)(unsafe.Pointer(bp /* ii */)) = 1 - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(0))) = *(*uint8)(unsafe.Pointer(bp /* &ii */)) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(1))) = uint8(0) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(2))) = uint8(0) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(3))) = uint8(4) - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr(((0)*2))*4))) = mnX - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr((((0)*2)+1))*4))) = mnY - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr(((1)*2))*4))) = mxX - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr((((1)*2)+1))*4))) = mnY - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr(((2)*2))*4))) = mxX - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr((((2)*2)+1))*4))) = mxY - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr(((3)*2))*4))) = mnX - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr((((3)*2)+1))*4))) = mxY + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */))) = *(*uint8)(unsafe.Pointer(bp /* &ii */)) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + 1)) = uint8(0) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + 2)) = uint8(0) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + 3)) = uint8(4) + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */)))) = mnX + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 1*4))) = mnY + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 2*4))) = mxX + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 3*4))) = mnY + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 4*4))) = mxX + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 5*4))) = mxY + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 6*4))) = mnX + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 7*4))) = mxY goto __16 __15: Xsqlite3_free(tls, p) - *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(0)*4)) = mnX - *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(1)*4)) = mxX - *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(2)*4)) = mnY - *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(3)*4)) = mxY + *(*RtreeValue)(unsafe.Pointer(aCoord)) = mnX + *(*RtreeValue)(unsafe.Pointer(aCoord + 1*4)) = mxX + *(*RtreeValue)(unsafe.Pointer(aCoord + 2*4)) = mnY + *(*RtreeValue)(unsafe.Pointer(aCoord + 3*4)) = mxY __16: ; goto __4 @@ -155419,7 +152873,7 @@ __4: // Implementation of the geopoly_bbox(X) SQL function. func geopolyBBoxFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:193124:13: */ - var p uintptr = geopolyBBox(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0), uintptr(0)) + var p uintptr = geopolyBBox(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0), uintptr(0)) if p != 0 { Xsqlite3_result_blob(tls, context, p+4, /* &.hdr */ (4 + (8 * (*GeoPoly)(unsafe.Pointer(p)).FnVertex)), libc.UintptrFromInt32(-1)) @@ -155443,9 +152897,9 @@ func geopolyBBoxStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { // var a [4]RtreeCoord at bp, 16 - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 0 - geopolyBBox(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), bp /* &a[0] */, bp+16 /* &rc */) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK + geopolyBBox(tls, context, *(*uintptr)(unsafe.Pointer(argv)), bp /* &a[0] */, bp+16 /* &rc */) + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { var pBBox uintptr pBBox = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(GeoBBox{}))) if pBBox == uintptr(0) { @@ -155455,17 +152909,17 @@ func geopolyBBoxStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { (*GeoBBox)(unsafe.Pointer(pBBox)).FisInit = 1 libc.Xmemcpy(tls, pBBox+4 /* &.a */, bp /* &a[0] */, (uint64(unsafe.Sizeof(RtreeCoord{})) * uint64(4))) } else { - if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + uintptr(0)*4)) < *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(0)*4)) { - *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(0)*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + uintptr(0)*4)) + if *(*RtreeValue)(unsafe.Pointer(bp /* &a */)) < *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */))) { + *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */))) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */)) } - if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + uintptr(1)*4)) > *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(1)*4)) { - *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(1)*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + uintptr(1)*4)) + if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + 1*4)) > *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + 1*4)) { + *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + 1*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + 1*4)) } - if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + uintptr(2)*4)) < *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(2)*4)) { - *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(2)*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + uintptr(2)*4)) + if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + 2*4)) < *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + 2*4)) { + *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + 2*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + 2*4)) } - if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + uintptr(3)*4)) > *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(3)*4)) { - *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(3)*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + uintptr(3)*4)) + if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + 3*4)) > *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + 3*4)) { + *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + 3*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + 3*4)) } } } @@ -155540,9 +152994,9 @@ func pointBeneathLine(tls *libc.TLS, x0 float64, y0 float64, x1 float64, y1 floa // Return +1 if point X,Y is on the polygon boundary. // Return 0 if point X,Y is outside the polygon func geopolyContainsPointFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:193234:13: */ - var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) - var x0 float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - var y0 float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) + var x0 float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + var y0 float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) var v int32 = 0 var cnt int32 = 0 var ii int32 @@ -155559,7 +153013,7 @@ func geopolyContainsPointFunc(tls *libc.TLS, context uintptr, argc int32, argv u } if v != 2 { v = pointBeneathLine(tls, x0, y0, float64(*(*GeoCoord)(unsafe.Pointer((p1 + 8 /* &.a */) + uintptr(((ii)*2))*4))), float64(*(*GeoCoord)(unsafe.Pointer((p1 + 8 /* &.a */) + uintptr((((ii)*2)+1))*4))), - float64(*(*GeoCoord)(unsafe.Pointer((p1 + 8 /* &.a */) + uintptr(((0)*2))*4))), float64(*(*GeoCoord)(unsafe.Pointer((p1 + 8 /* &.a */) + uintptr((((0)*2)+1))*4)))) + float64(*(*GeoCoord)(unsafe.Pointer((p1 + 8 /* &.a */)))), float64(*(*GeoCoord)(unsafe.Pointer((p1 + 8 /* &.a */) + 1*4)))) } if v == 2 { Xsqlite3_result_int(tls, context, 1) @@ -155578,8 +153032,8 @@ func geopolyContainsPointFunc(tls *libc.TLS, context uintptr, argc int32, argv u // Return 0 if any part of P2 is on the outside of P1 // func geopolyWithinFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:193277:13: */ - var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) - var p2 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uintptr(0)) + var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) + var p2 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uintptr(0)) if (p1 != 0) && (p2 != 0) { var x int32 = geopolyOverlap(tls, p1, p2) if x < 0 { @@ -155675,10 +153129,10 @@ func geopolyAddSegments(tls *libc.TLS, p uintptr, pPoly uintptr, side uint8) { / var x uintptr for i = uint32(0); i < (uint32((*GeoPoly)(unsafe.Pointer(pPoly)).FnVertex) - uint32(1)); i++ { x = ((pPoly + 8 /* &.a */) + uintptr(((i)*uint32(2)))*4) - geopolyAddOneSegment(tls, p, *(*GeoCoord)(unsafe.Pointer(x + uintptr(0)*4)), *(*GeoCoord)(unsafe.Pointer(x + uintptr(1)*4)), *(*GeoCoord)(unsafe.Pointer(x + uintptr(2)*4)), *(*GeoCoord)(unsafe.Pointer(x + uintptr(3)*4)), side, i) + geopolyAddOneSegment(tls, p, *(*GeoCoord)(unsafe.Pointer(x)), *(*GeoCoord)(unsafe.Pointer(x + 1*4)), *(*GeoCoord)(unsafe.Pointer(x + 2*4)), *(*GeoCoord)(unsafe.Pointer(x + 3*4)), side, i) } x = ((pPoly + 8 /* &.a */) + uintptr(((i)*uint32(2)))*4) - geopolyAddOneSegment(tls, p, *(*GeoCoord)(unsafe.Pointer(x + uintptr(0)*4)), *(*GeoCoord)(unsafe.Pointer(x + uintptr(1)*4)), *(*GeoCoord)(unsafe.Pointer((pPoly + 8 /* &.a */) + uintptr(0)*4)), *(*GeoCoord)(unsafe.Pointer((pPoly + 8 /* &.a */) + uintptr(1)*4)), side, i) + geopolyAddOneSegment(tls, p, *(*GeoCoord)(unsafe.Pointer(x)), *(*GeoCoord)(unsafe.Pointer(x + 1*4)), *(*GeoCoord)(unsafe.Pointer((pPoly + 8 /* &.a */))), *(*GeoCoord)(unsafe.Pointer((pPoly + 8 /* &.a */) + 1*4)), side, i) } // Merge two lists of sorted events by X coordinate @@ -155840,7 +153294,7 @@ func geopolyOverlap(tls *libc.TLS, p1 uintptr, p2 uintptr) int32 { /* sqlite3.c: return -1 __1: ; - (*GeoOverlap)(unsafe.Pointer(p)).FaEvent = (p + uintptr(1)*24) + (*GeoOverlap)(unsafe.Pointer(p)).FaEvent = (p + 1*24) (*GeoOverlap)(unsafe.Pointer(p)).FaSegment = ((*GeoOverlap)(unsafe.Pointer(p)).FaEvent + uintptr((nVertex*int64(2)))*32) (*GeoOverlap)(unsafe.Pointer(p)).FnEvent = libc.AssignPtrInt32(p+20 /* &.nSegment */, 0) geopolyAddSegments(tls, p, p1, uint8(1)) @@ -155985,25 +153439,25 @@ __19: goto __2 __3: ; - if !(int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(3)))) == 0) { + if !(int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 3))) == 0) { goto __26 } rc = 0 goto __27 __26: - if !((int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(1)))) != 0) && (int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(2)))) == 0)) { + if !((int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 1))) != 0) && (int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 2))) == 0)) { goto __28 } rc = 3 goto __29 __28: - if !((int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(1)))) == 0) && (int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(2)))) != 0)) { + if !((int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 1))) == 0) && (int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 2))) != 0)) { goto __30 } rc = 2 goto __31 __30: - if !((int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(1)))) == 0) && (int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(2)))) == 0)) { + if !((int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 1))) == 0) && (int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 2))) == 0)) { goto __32 } rc = 4 @@ -156035,8 +153489,8 @@ geopolyOverlapDone: // 4 P1 and P2 are the same polygon // NULL Either P1 or P2 or both are not valid polygons func geopolyOverlapFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:193607:13: */ - var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) - var p2 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uintptr(0)) + var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) + var p2 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uintptr(0)) if (p1 != 0) && (p2 != 0) { var x int32 = geopolyOverlap(tls, p1, p2) if x < 0 { @@ -156071,30 +153525,30 @@ func geopolyInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintp var pSql uintptr var zSql uintptr var ii int32 - rc = 0 + rc = SQLITE_OK - Xsqlite3_vtab_config(tls, db, 1, libc.VaList(bp, 1)) + Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_CONSTRAINT_SUPPORT, libc.VaList(bp, 1)) // Allocate the sqlite3_vtab structure - nDb = Sqlite3_int64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) - nName = Sqlite3_int64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + nDb = Sqlite3_int64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) + nName = Sqlite3_int64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) pRtree = Xsqlite3_malloc64(tls, (((uint64(unsafe.Sizeof(Rtree{})) + uint64(nDb)) + uint64(nName)) + uint64(2))) if !(!(pRtree != 0)) { goto __1 } - return 7 + return SQLITE_NOMEM __1: ; libc.Xmemset(tls, pRtree, 0, (uint64(((uint64(unsafe.Sizeof(Rtree{})) + uint64(nDb)) + uint64(nName)) + uint64(2)))) (*Rtree)(unsafe.Pointer(pRtree)).FnBusy = U32(1) (*Rtree)(unsafe.Pointer(pRtree)).Fbase.FpModule = uintptr(unsafe.Pointer(&rtreeModule)) - (*Rtree)(unsafe.Pointer(pRtree)).FzDb = (pRtree + uintptr(1)*968) + (*Rtree)(unsafe.Pointer(pRtree)).FzDb = (pRtree + 1*968) (*Rtree)(unsafe.Pointer(pRtree)).FzName = ((*Rtree)(unsafe.Pointer(pRtree)).FzDb + uintptr((nDb + int64(1)))) - (*Rtree)(unsafe.Pointer(pRtree)).FeCoordType = U8(0) + (*Rtree)(unsafe.Pointer(pRtree)).FeCoordType = RTREE_COORD_REAL32 (*Rtree)(unsafe.Pointer(pRtree)).FnDim = U8(2) (*Rtree)(unsafe.Pointer(pRtree)).FnDim2 = U8(4) - libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uint64(nDb)) - libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzName, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), uint64(nName)) + libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uint64(nDb)) + libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzName, *(*uintptr)(unsafe.Pointer(argv + 2*8)), uint64(nName)) // Create/Connect to the underlying relational database schema. If // that is successful, call sqlite3_declare_vtab() to configure @@ -156122,10 +153576,10 @@ __4: if !(!(zSql != 0)) { goto __5 } - rc = 7 + rc = SQLITE_NOMEM goto __6 __5: - if !(0 != (libc.AssignInt32(&rc, Xsqlite3_declare_vtab(tls, db, zSql)))) { + if !(SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3_declare_vtab(tls, db, zSql)))) { goto __7 } *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp+16, Xsqlite3_errmsg(tls, db))) @@ -156150,7 +153604,7 @@ __8: goto geopolyInit_fail __9: ; - rc = rtreeSqlInit(tls, pRtree, db, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), isCreate) + rc = rtreeSqlInit(tls, pRtree, db, *(*uintptr)(unsafe.Pointer(argv + 1*8)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), isCreate) if !(rc != 0) { goto __10 } @@ -156160,13 +153614,13 @@ __10: ; *(*uintptr)(unsafe.Pointer(ppVtab)) = pRtree - return 0 + return SQLITE_OK geopolyInit_fail: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __11 } - rc = 1 + rc = SQLITE_ERROR __11: ; @@ -156220,7 +153674,7 @@ func geopolyFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint pRtree = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab pCsr = pVtabCursor *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = SQLITE_OK *(*int32)(unsafe.Pointer(bp + 16 /* iCell */)) = 0 rtreeReference(tls, pRtree) @@ -156232,17 +153686,17 @@ func geopolyFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint if !(idxNum == 1) { goto __1 } // Search point for the leaf - iRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + iRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) *(*I64)(unsafe.Pointer(bp + 8 /* iNode */)) = int64(0) *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = findLeafNode(tls, pRtree, iRowid, bp /* &pLeaf */, bp+8 /* &iNode */) - if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) && (*(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) != uintptr(0))) { + if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) != uintptr(0))) { goto __3 } p = rtreeSearchPointNew(tls, pCsr, 0.0, uint8(0)) // Always returns pCsr->sPoint - *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */) + uintptr(0)*8)) = *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) + *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */))) = *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) (*RtreeSearchPoint)(unsafe.Pointer(p)).Fid = *(*I64)(unsafe.Pointer(bp + 8 /* iNode */)) - (*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = U8(1) + (*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = PARTLY_WITHIN *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = nodeRowidIndex(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)), iRowid, bp+16 /* &iCell */) (*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell = U8(*(*int32)(unsafe.Pointer(bp + 16 /* iCell */))) @@ -156256,11 +153710,11 @@ __1: // Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array // with the configured constraints. *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp+24 /* &pRoot */) - if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) && (idxNum <= 3)) { + if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) && (idxNum <= 3)) { goto __5 } - geopolyBBox(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), bp+32 /* &bbox[0] */, bp+48 /* &rc */) + geopolyBBox(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(argv)), bp+32 /* &bbox[0] */, bp+48 /* &rc */) if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) != 0) { goto __6 } @@ -156272,7 +153726,7 @@ __6: if !(p1 == uintptr(0)) { goto __7 } - *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = SQLITE_NOMEM goto __8 __7: libc.Xmemset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint, 0, (uint64(unsafe.Sizeof(RtreeConstraint{})) * uint64(4))) @@ -156283,59 +153737,59 @@ __7: // Overlap query (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'B' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 0 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(1)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + 1*4))) p1 += 24 (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'D' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 1 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(0)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */))) p1 += 24 (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'B' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 2 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(3)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + 3*4))) p1 += 24 (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'D' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 3 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(2)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + 2*4))) goto __10 __9: // Within query (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'D' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 0 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(0)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */))) p1 += 24 (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'B' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 1 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(1)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + 1*4))) p1 += 24 (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'D' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 2 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(2)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + 2*4))) p1 += 24 (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'B' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 3 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(3)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + 3*4))) __10: ; __8: ; __5: ; - if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) { + if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) { goto __11 } pNew = rtreeSearchPointNew(tls, pCsr, 0.0, (U8((*Rtree)(unsafe.Pointer(pRtree)).FiDepth + 1))) if !(pNew == uintptr(0)) { goto __12 } - *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = SQLITE_NOMEM goto geopoly_filter_end __12: ; (*RtreeSearchPoint)(unsafe.Pointer(pNew)).Fid = int64(1) (*RtreeSearchPoint)(unsafe.Pointer(pNew)).FiCell = U8(0) - (*RtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = U8(1) + (*RtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = PARTLY_WITHIN - *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */) + uintptr(0)*8)) = *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) + *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */))) = *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) = uintptr(0) *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = rtreeStepToLeaf(tls, pCsr) @@ -156372,16 +153826,16 @@ func geopolyBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* s if !(int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) != 0) { continue } - if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn < 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2) { + if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn < 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { iRowidTerm = ii break } - if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) >= 150) { + if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) >= SQLITE_INDEX_CONSTRAINT_FUNCTION) { // p->op==SQLITE_INDEX_CONSTRAINT_FUNCTION for geopoly_overlap() // p->op==(SQLITE_INDEX_CONTRAINT_FUNCTION+1) for geopoly_within(). // See geopolyFindFunction() iFuncTerm = ii - idxNum = ((int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) - 150) + 2) + idxNum = ((int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) - SQLITE_INDEX_CONSTRAINT_FUNCTION) + 2) } } @@ -156392,8 +153846,8 @@ func geopolyBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* s (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8)).Fomit = uint8(1) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 30.0 (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) - (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = 1 - return 0 + (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = SQLITE_INDEX_SCAN_UNIQUE + return SQLITE_OK } if iFuncTerm >= 0 { (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = idxNum @@ -156402,13 +153856,13 @@ func geopolyBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* s (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iFuncTerm)*8)).Fomit = uint8(0) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 300.0 (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(10) - return 0 + return SQLITE_OK } (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 4 (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = ts + 24799 /* "fullscan" */ (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 3000000.0 (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(100000) - return 0 + return SQLITE_OK } // GEOPOLY virtual table module xColumn method. @@ -156419,17 +153873,17 @@ func geopolyColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* var pRtree uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab var pCsr uintptr = cur var p uintptr = rtreeSearchPointFirst(tls, pCsr) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pNode uintptr = rtreeNodeOfFirstSearchPoint(tls, pCsr, bp /* &rc */) if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp /* rc */)) } if p == uintptr(0) { - return 0 + return SQLITE_OK } if (i == 0) && (Xsqlite3_vtab_nochange(tls, ctx) != 0) { - return 0 + return SQLITE_OK } if i <= int32((*Rtree)(unsafe.Pointer(pRtree)).FnAux) { if !(int32((*RtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid) != 0) { @@ -156443,19 +153897,19 @@ func geopolyColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* Xsqlite3_bind_int64(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, 1, nodeGetRowid(tls, pRtree, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell))) *(*int32)(unsafe.Pointer(bp /* rc */)) = Xsqlite3_step(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 100 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_ROW { (*RtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid = U8(1) } else { Xsqlite3_reset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 101 { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_DONE { + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK } return *(*int32)(unsafe.Pointer(bp /* rc */)) } } Xsqlite3_result_value(tls, ctx, Xsqlite3_column_value(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, (i+2))) } - return 0 + return SQLITE_OK } // The xUpdate method for GEOPOLY module virtual tables. @@ -156501,7 +153955,7 @@ func geopolyUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRo var jj int32 var nChange int32 pRtree = pVtab - *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = SQLITE_OK coordChange = 0 // Change in coordinates if !((*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef != 0) { @@ -156510,21 +153964,21 @@ func geopolyUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRo // Unable to write to the btree while another cursor is reading from it, // since the write might do a rebalance which would disrupt the read // cursor. - return (6 | (int32(2) << 8)) + return (SQLITE_LOCKED | (int32(2) << 8)) __1: ; rtreeReference(tls, pRtree) - oldRowidValid = (libc.Bool32(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(0)*8))) != 5)) + oldRowidValid = (libc.Bool32(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData))) != SQLITE_NULL)) if oldRowidValid != 0 { - oldRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(0)*8))) + oldRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData))) } else { oldRowid = int64(0) } - newRowidValid = (libc.Bool32((nData > 1) && (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(1)*8))) != 5))) + newRowidValid = (libc.Bool32((nData > 1) && (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + 1*8))) != SQLITE_NULL))) if newRowidValid != 0 { - newRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(1)*8))) + newRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + 1*8))) } else { newRowid = int64(0) } @@ -156532,15 +153986,15 @@ __1: if !((nData > 1) && // not a DELETE ((!(oldRowidValid != 0) || // INSERT - !(Xsqlite3_value_nochange(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8))) != 0)) || // UPDATE _shape + !(Xsqlite3_value_nochange(tls, *(*uintptr)(unsafe.Pointer(aData + 2*8))) != 0)) || // UPDATE _shape (oldRowid != newRowid))) { goto __2 } - geopolyBBox(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8)), bp /* &cell */ +8 /* &.aCoord */, bp+48 /* &rc */) + geopolyBBox(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(aData + 2*8)), bp /* &cell */ +8 /* &.aCoord */, bp+48 /* &rc */) if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) != 0) { goto __3 } - if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 1) { + if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_ERROR) { goto __4 } (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+24808 /* "_shape does not ..." */, 0) @@ -156559,10 +154013,10 @@ __3: Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid, 1, (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid) steprc = Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) - if !(100 == steprc) { + if !(SQLITE_ROW == steprc) { goto __6 } - if !(Xsqlite3_vtab_on_conflict(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb) == 5) { + if !(Xsqlite3_vtab_on_conflict(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb) == SQLITE_REPLACE) { goto __7 } *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = rtreeDeleteRowid(tls, pRtree, (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid) @@ -156581,7 +154035,7 @@ __2: // If aData[0] is not an SQL NULL value, it is the rowid of a // record to delete from the r-tree table. The following block does // just that. - if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) && ((nData == 1) || ((coordChange != 0) && (oldRowidValid != 0)))) { + if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) && ((nData == 1) || ((coordChange != 0) && (oldRowidValid != 0)))) { goto __9 } *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = rtreeDeleteRowid(tls, pRtree, oldRowid) @@ -156591,7 +154045,7 @@ __9: // If the aData[] array contains more than one element, elements // (aData[2]..aData[argc-1]) contain a new record to insert into // the r-tree structure. - if !(((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) && (nData > 1)) && (coordChange != 0)) { + if !(((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) && (nData > 1)) && (coordChange != 0)) { goto __10 } // Insert the new record into the r-tree @@ -156603,19 +154057,19 @@ __9: __11: ; *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid - if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) { + if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) { goto __12 } *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = sChooseLeaf(tls, pRtree, bp /* &cell */, 0, bp+56 /* &pLeaf */) __12: ; - if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) { + if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) { goto __13 } (*Rtree)(unsafe.Pointer(pRtree)).FiReinsertHeight = -1 *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = rtreeInsertCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 56 /* pLeaf */)), bp /* &cell */, 0) rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 56 /* pLeaf */))) - if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) { + if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) { goto __14 } *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = rc2 @@ -156627,29 +154081,29 @@ __10: ; // Change the data - if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) && (nData > 1)) { + if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) && (nData > 1)) { goto __15 } pUp = (*Rtree)(unsafe.Pointer(pRtree)).FpWriteAux nChange = 0 Xsqlite3_bind_int64(tls, pUp, 1, (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid) - if !(Xsqlite3_value_nochange(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8))) != 0) { + if !(Xsqlite3_value_nochange(tls, *(*uintptr)(unsafe.Pointer(aData + 2*8))) != 0) { goto __16 } Xsqlite3_bind_null(tls, pUp, 2) goto __17 __16: p = uintptr(0) - if !(((Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8))) == 3) && - ((libc.AssignUintptr(&p, geopolyFuncParam(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8)), bp+48 /* &rc */))) != uintptr(0))) && - (*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0)) { + if !(((Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + 2*8))) == SQLITE_TEXT) && + ((libc.AssignUintptr(&p, geopolyFuncParam(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(aData + 2*8)), bp+48 /* &rc */))) != uintptr(0))) && + (*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK)) { goto __18 } Xsqlite3_bind_blob(tls, pUp, 2, p+4 /* &.hdr */, (4 + (8 * (*GeoPoly)(unsafe.Pointer(p)).FnVertex)), libc.UintptrFromInt32(-1)) goto __19 __18: - Xsqlite3_bind_value(tls, pUp, 2, *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8))) + Xsqlite3_bind_value(tls, pUp, 2, *(*uintptr)(unsafe.Pointer(aData + 2*8))) __19: ; Xsqlite3_free(tls, p) @@ -156693,70 +154147,45 @@ func geopolyFindFunction(tls *libc.TLS, pVtab uintptr, nArg int32, zName uintptr f func(*libc.TLS, uintptr, int32, uintptr) }{geopolyOverlapFunc})) *(*uintptr)(unsafe.Pointer(ppArg)) = uintptr(0) - return 150 + return SQLITE_INDEX_CONSTRAINT_FUNCTION } if Xsqlite3_stricmp(tls, zName, ts+24864 /* "geopoly_within" */) == 0 { *(*uintptr)(unsafe.Pointer(pxFunc)) = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{geopolyWithinFunc})) *(*uintptr)(unsafe.Pointer(ppArg)) = uintptr(0) - return (150 + 1) + return (SQLITE_INDEX_CONSTRAINT_FUNCTION + 1) } return 0 } var geopolyModule = Sqlite3_module{ - FiVersion: 3, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - create a table - 0, - FxBestIndex:// xConnect - connect to an existing table - 0, - FxDisconnect:// xBestIndex - Determine search strategy - 0, - FxDestroy:// xDisconnect - Disconnect from a table - 0, - FxOpen:// xDestroy - Drop a table - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - write data - 0, - FxSync:// xBegin - begin transaction - 0, - FxCommit:// xSync - sync transaction - 0, - FxRollback:// xCommit - commit transaction - 0, - FxFindFunction:// xRollback - rollback transaction - 0, - FxRename:// xFindFunction - function overloading - 0, - FxSavepoint:// xRename - rename the table - 0, - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - 0, // xShadowName + FiVersion: 3, // iVersion + FxCreate: 0, // xCreate - create a table + FxConnect: 0, // xConnect - connect to an existing table + FxBestIndex: 0, // xBestIndex - Determine search strategy + FxDisconnect: 0, // xDisconnect - Disconnect from a table + FxDestroy: 0, // xDestroy - Drop a table + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRowid - read data + FxUpdate: 0, // xUpdate - write data + FxBegin: 0, // xBegin - begin transaction + FxSync: 0, // xSync - sync transaction + FxCommit: 0, // xCommit - commit transaction + FxRollback: 0, // xRollback - rollback transaction + FxFindFunction: 0, // xFindFunction - function overloading + FxRename: 0, // xRename - rename the table + FxSavepoint: 0, // xRollbackTo + FxShadowName: 0, // xShadowName } /* sqlite3.c:194163:23 */ func sqlite3_geopoly_init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:194190:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 for i = 0; (uint64(i) < (uint64(unsafe.Sizeof(aFunc1)) / uint64(unsafe.Sizeof(struct { FxFunc uintptr @@ -156764,12 +154193,12 @@ func sqlite3_geopoly_init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:194190 FbPure uint8 _ [6]byte FzName uintptr - }{})))) && (rc == 0); i++ { + }{})))) && (rc == SQLITE_OK); i++ { var enc int32 if aFunc1[i].FbPure != 0 { - enc = ((1 | 0x000000800) | 0x000200000) + enc = ((SQLITE_UTF8 | SQLITE_DETERMINISTIC) | SQLITE_INNOCUOUS) } else { - enc = (1 | 0x000080000) + enc = (SQLITE_UTF8 | SQLITE_DIRECTONLY) } rc = Xsqlite3_create_function(tls, db, aFunc1[i].FzName, int32(aFunc1[i].FnArg), enc, uintptr(0), @@ -156779,12 +154208,12 @@ func sqlite3_geopoly_init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:194190 FxStep uintptr FxFinal uintptr FzName uintptr - }{})))) && (rc == 0); i++ { + }{})))) && (rc == SQLITE_OK); i++ { rc = Xsqlite3_create_function(tls, db, aAgg1[i].FzName, 1, - ((1 | 0x000000800) | 0x000200000), uintptr(0), + ((SQLITE_UTF8 | SQLITE_DETERMINISTIC) | SQLITE_INNOCUOUS), uintptr(0), uintptr(0), aAgg1[i].FxStep, aAgg1[i].FxFinal) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_module_v2(tls, db, ts+24879 /* "geopoly" */, uintptr(unsafe.Pointer(&geopolyModule)), uintptr(0), uintptr(0)) } return rc @@ -156797,76 +154226,25 @@ var aFunc1 = [12]struct { _ [6]byte FzName uintptr }{ - { - FxFunc: 0, - FnArg: int8(1), - FbPure: uint8(1), - FzName: ts + 24887 /* "geopoly_area" */}, - { - FxFunc: 0, - FnArg: int8(1), - FbPure: uint8(1), - FzName: ts + 24900 /* "geopoly_blob" */}, - { - FxFunc: 0, - FnArg: int8(1), - FbPure: uint8(1), - FzName: ts + 24913 /* "geopoly_json" */}, - { - FxFunc: 0, - FnArg: int8(-1), - FbPure: uint8(1), - FzName: ts + 24926 /* "geopoly_svg" */}, - { - FxFunc: 0, - FnArg: int8(2), - FbPure: uint8(1), - FzName: ts + 24864 /* "geopoly_within" */}, - { - FxFunc: 0, - FnArg: int8(3), - FbPure: uint8(1), - FzName: ts + 24938 /* "geopoly_contains..." */}, - { - FxFunc: 0, - FnArg: int8(2), - FbPure: uint8(1), - FzName: ts + 24848 /* "geopoly_overlap" */}, - { - FxFunc: 0, - FnArg: int8(1), - FbPure: uint8(0), - FzName: ts + 24961 /* "geopoly_debug" */}, - { - FxFunc: 0, - FnArg: int8(1), - FbPure: uint8(1), - FzName: ts + 24975 /* "geopoly_bbox" */}, - { - FxFunc: 0, - FnArg: int8(7), - FbPure: uint8(1), - FzName: ts + 24988 /* "geopoly_xform" */}, - { - FxFunc: 0, - FnArg: int8(4), - FbPure: uint8(1), - FzName: ts + 25002 /* "geopoly_regular" */}, - { - FxFunc: 0, - FnArg: int8(1), - FbPure: uint8(1), - FzName: ts + 25018 /* "geopoly_ccw" */}, + {FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 24887 /* "geopoly_area" */}, + {FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 24900 /* "geopoly_blob" */}, + {FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 24913 /* "geopoly_json" */}, + {FxFunc: 0, FnArg: int8(-1), FbPure: uint8(1), FzName: ts + 24926 /* "geopoly_svg" */}, + {FxFunc: 0, FnArg: int8(2), FbPure: uint8(1), FzName: ts + 24864 /* "geopoly_within" */}, + {FxFunc: 0, FnArg: int8(3), FbPure: uint8(1), FzName: ts + 24938 /* "geopoly_contains..." */}, + {FxFunc: 0, FnArg: int8(2), FbPure: uint8(1), FzName: ts + 24848 /* "geopoly_overlap" */}, + {FxFunc: 0, FnArg: int8(1), FzName: ts + 24961 /* "geopoly_debug" */}, + {FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 24975 /* "geopoly_bbox" */}, + {FxFunc: 0, FnArg: int8(7), FbPure: uint8(1), FzName: ts + 24988 /* "geopoly_xform" */}, + {FxFunc: 0, FnArg: int8(4), FbPure: uint8(1), FzName: ts + 25002 /* "geopoly_regular" */}, + {FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 25018 /* "geopoly_ccw" */}, } /* sqlite3.c:194197:5 */ var aAgg1 = [1]struct { FxStep uintptr FxFinal uintptr FzName uintptr }{ - { - FxStep: 0, - FxFinal: 0, - FzName: ts + 25030 /* "geopoly_group_bb..." */}, + {FxStep: 0, FxFinal: 0, FzName: ts + 25030 /* "geopoly_group_bb..." */}, } /* sqlite3.c:194215:5 */ //************* End of geopoly.c ******************************************** @@ -156876,31 +154254,31 @@ var aAgg1 = [1]struct { // virtual table module "rtree" and the debugging/analysis scalar // function "rtreenode". func Xsqlite3RtreeInit(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:194250:20: */ - var utf8 int32 = 1 + var utf8 int32 = SQLITE_UTF8 var rc int32 rc = Xsqlite3_create_function(tls, db, ts+25049 /* "rtreenode" */, 2, utf8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rtreenode})), uintptr(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_function(tls, db, ts+25059 /* "rtreedepth" */, 1, utf8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rtreedepth})), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_function(tls, db, ts+25070 /* "rtreecheck" */, -1, utf8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rtreecheck})), uintptr(0), uintptr(0)) } - if rc == 0 { - var c uintptr = uintptr(0) + if rc == SQLITE_OK { + var c uintptr = RTREE_COORD_REAL32 rc = Xsqlite3_create_module_v2(tls, db, ts+24793 /* "rtree" */, uintptr(unsafe.Pointer(&rtreeModule)), c, uintptr(0)) } - if rc == 0 { - var c uintptr = uintptr(1) + if rc == SQLITE_OK { + var c uintptr = RTREE_COORD_INT32 rc = Xsqlite3_create_module_v2(tls, db, ts+25081 /* "rtree_i32" */, uintptr(unsafe.Pointer(&rtreeModule)), c, uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3_geopoly_init(tls, db) } @@ -156956,7 +154334,7 @@ func geomCallback(tls *libc.TLS, ctx uintptr, nArg int32, aArg uintptr) { /* sql } else { var i int32 (*RtreeMatchArg)(unsafe.Pointer(pBlob)).FiSize = U32(nBlob) - (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb = *(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx + uintptr(0)*32)) + (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb = *(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)) (*RtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam = ((pBlob + 56 /* &.aParam */) + uintptr(nArg)*8) (*RtreeMatchArg)(unsafe.Pointer(pBlob)).FnParam = nArg for i = 0; i < nArg; i++ { @@ -156982,13 +154360,13 @@ func Xsqlite3_rtree_geometry_callback(tls *libc.TLS, db uintptr, zGeom uintptr, // Allocate and populate the context object. pGeomCtx = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(RtreeGeomCallback{}))) if !(pGeomCtx != 0) { - return 7 + return SQLITE_NOMEM } (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxGeom = xGeom (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxQueryFunc = uintptr(0) (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxDestructor = uintptr(0) (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FpContext = pContext - return Xsqlite3_create_function_v2(tls, db, zGeom, -1, 5, + return Xsqlite3_create_function_v2(tls, db, zGeom, -1, SQLITE_ANY, pGeomCtx, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{geomCallback})), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{rtreeFreeCallback}))) @@ -157002,13 +154380,13 @@ func Xsqlite3_rtree_query_callback(tls *libc.TLS, db uintptr, zQueryFunc uintptr // Allocate and populate the context object. pGeomCtx = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(RtreeGeomCallback{}))) if !(pGeomCtx != 0) { - return 7 + return SQLITE_NOMEM } (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxGeom = uintptr(0) (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxQueryFunc = xQueryFunc (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxDestructor = xDestructor (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FpContext = pContext - return Xsqlite3_create_function_v2(tls, db, zQueryFunc, -1, 5, + return Xsqlite3_create_function_v2(tls, db, zQueryFunc, -1, SQLITE_ANY, pGeomCtx, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{geomCallback})), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{rtreeFreeCallback}))) @@ -158149,13 +155527,13 @@ func rbuDeltaApply(tls *libc.TLS, zSrc uintptr, lenSrc int32, zDelta uintptr, le var cnt uint32 var ofst uint32 cnt = rbuDeltaGetInt(tls, bp /* &zDelta */, bp+8 /* &lenDelta */) - switch int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zDelta */)) + uintptr(0)))) { + switch int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zDelta */))))) { case '@': { *(*uintptr)(unsafe.Pointer(bp /* zDelta */))++ *(*int32)(unsafe.Pointer(bp + 8 /* lenDelta */))-- ofst = rbuDeltaGetInt(tls, bp /* &zDelta */, bp+8 /* &lenDelta */) - if (*(*int32)(unsafe.Pointer(bp + 8 /* lenDelta */)) > 0) && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zDelta */)) + uintptr(0)))) != ',') { + if (*(*int32)(unsafe.Pointer(bp + 8 /* lenDelta */)) > 0) && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zDelta */))))) != ',') { // ERROR: copy command not terminated by ',' return -1 } @@ -158199,7 +155577,7 @@ func rbuDeltaApply(tls *libc.TLS, zSrc uintptr, lenSrc int32, zDelta uintptr, le { *(*uintptr)(unsafe.Pointer(bp /* zDelta */))++ *(*int32)(unsafe.Pointer(bp + 8 /* lenDelta */))-- - *(*int8)(unsafe.Pointer(zOut + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(zOut)) = int8(0) if total != limit { // ERROR: generated size does not match predicted size return -1 @@ -158253,10 +155631,10 @@ func rbuFossilDeltaFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr var nOut2 int32 var aOut uintptr - nOrig = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - aOrig = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - nDelta = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - aDelta = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + nOrig = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + aOrig = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) + nDelta = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + aDelta = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) // Figure out the size of the output nOut = rbuDeltaOutputSize(tls, aDelta, nDelta) @@ -158292,7 +155670,7 @@ func prepareAndCollectError(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErrmsg defer tls.Free(8) var rc int32 = Xsqlite3_prepare_v2(tls, db, zSql, -1, ppStmt, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(pzErrmsg)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp, Xsqlite3_errmsg(tls, db))) *(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0) } @@ -158310,7 +155688,7 @@ func resetAndCollectError(tls *libc.TLS, pStmt uintptr, pzErrmsg uintptr) int32 defer tls.Free(8) var rc int32 = Xsqlite3_reset(tls, pStmt) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(pzErrmsg)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp, Xsqlite3_errmsg(tls, Xsqlite3_db_handle(tls, pStmt)))) } return rc @@ -158333,7 +155711,7 @@ func prepareFreeAndCollectError(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErr var rc int32 if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM *(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0) } else { rc = prepareAndCollectError(tls, db, ppStmt, pzErrmsg, zSql) @@ -158408,7 +155786,7 @@ func rbuObjIterFinalize(tls *libc.TLS, pIter uintptr) { /* sqlite3.c:196691:13: // error code is returned. func rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3.c:196707:12: */ var rc int32 = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc - if rc == 0 { + if rc == SQLITE_OK { // Free any SQLite statements used while processing the previous object rbuObjIterClearStatements(tls, pIter) @@ -158418,21 +155796,21 @@ func rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3. ts+25112 /* "DROP TRIGGER IF ..." */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } - if rc == 0 { + if rc == SQLITE_OK { if (*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 { rbuObjIterFreeCols(tls, pIter) (*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = 0 rc = Xsqlite3_step(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter) - if rc != 100 { + if rc != SQLITE_ROW { rc = resetAndCollectError(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, (p + 64 /* &.zErrmsg */)) (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl = uintptr(0) } else { (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl = Xsqlite3_column_text(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, 0) (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl = Xsqlite3_column_text(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, 1) if ((*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl != 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0) { - rc = 0 + rc = SQLITE_OK } else { - rc = 7 + rc = SQLITE_NOMEM } } } else { @@ -158440,9 +155818,9 @@ func rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3. var pIdx uintptr = (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter rc = Xsqlite3_bind_text(tls, pIdx, 1, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, -1, uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_step(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter) - if rc != 100 { + if rc != SQLITE_ROW { rc = resetAndCollectError(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, (p + 64 /* &.zErrmsg */)) (*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = 1 (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx = uintptr(0) @@ -158451,9 +155829,9 @@ func rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3. (*RbuObjIter)(unsafe.Pointer(pIter)).FiTnum = Xsqlite3_column_int(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, 1) (*RbuObjIter)(unsafe.Pointer(pIter)).FbUnique = Xsqlite3_column_int(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, 2) if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx != 0 { - rc = 0 + rc = SQLITE_OK } else { - rc = 7 + rc = SQLITE_NOMEM } } } @@ -158461,7 +155839,7 @@ func rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3. } } - if rc != 0 { + if rc != SQLITE_OK { rbuObjIterFinalize(tls, pIter) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc } @@ -158491,11 +155869,11 @@ func rbuTargetNameFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { var p uintptr = Xsqlite3_user_data(tls, pCtx) var zIn uintptr - zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zIn != 0 { if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { - if (argc == 1) || (0 == Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) { + if (argc == 1) || (0 == Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) { Xsqlite3_result_text(tls, pCtx, zIn, -1, uintptr(0)) } } else { @@ -158534,7 +155912,7 @@ func rbuObjIterFirst(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3 return ts + 703 /* "" */ }()))) - if rc == 0 { + if rc == SQLITE_OK { rc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (pIter + 8 /* &.pIdxIter */), (p + 64 /* &.zErrmsg */), ts+25474 /* "SELECT name, roo..." */) @@ -158558,9 +155936,9 @@ func rbuMPrintf(tls *libc.TLS, p uintptr, zFmt uintptr, va uintptr) uintptr { /* _ = ap ap = va zSql = Xsqlite3_vmprintf(tls, zFmt, ap) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { if zSql == uintptr(0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } } else { Xsqlite3_free(tls, zSql) @@ -158584,9 +155962,9 @@ func rbuMPrintfExec(tls *libc.TLS, p uintptr, db uintptr, zFmt uintptr, va uintp var zSql uintptr ap = va zSql = Xsqlite3_vmprintf(tls, zFmt, ap) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { if zSql == uintptr(0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } else { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } @@ -158606,11 +155984,11 @@ func rbuMPrintfExec(tls *libc.TLS, p uintptr, db uintptr, zFmt uintptr, va uintp // error code. func rbuMalloc(tls *libc.TLS, p uintptr, nByte Sqlite3_int64) uintptr { /* sqlite3.c:196910:13: */ var pRet uintptr = uintptr(0) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { pRet = Xsqlite3_malloc64(tls, uint64(nByte)) if pRet == uintptr(0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } else { libc.Xmemset(tls, pRet, 0, uint64(nByte)) } @@ -158647,14 +156025,14 @@ func rbuAllocateIterArrays(tls *libc.TLS, p uintptr, pIter uintptr, nCol int32) func rbuStrndup(tls *libc.TLS, zStr uintptr, pRc uintptr) uintptr { /* sqlite3.c:196955:13: */ var zRet uintptr = uintptr(0) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { if zStr != 0 { var nCopy Size_t = (libc.Xstrlen(tls, zStr) + uint64(1)) zRet = Xsqlite3_malloc64(tls, uint64(nCopy)) if zRet != 0 { libc.Xmemcpy(tls, zRet, zStr, nCopy) } else { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } } @@ -158673,7 +156051,7 @@ func rbuFinalize(tls *libc.TLS, p uintptr, pStmt uintptr) { /* sqlite3.c:196980: var db uintptr = Xsqlite3_db_handle(tls, pStmt) var rc int32 = Xsqlite3_finalize(tls, pStmt) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (rc != 0) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (rc != SQLITE_OK) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp, Xsqlite3_errmsg(tls, db))) } @@ -158732,30 +156110,30 @@ func rbuTableType(tls *libc.TLS, p uintptr, zTab uintptr, peType uintptr, piTnum var i uint32 *(*[4]uintptr)(unsafe.Pointer(bp + 32 /* aStmt */)) = [4]uintptr{uintptr(0), uintptr(0), uintptr(0), uintptr(0)} - *(*int32)(unsafe.Pointer(peType)) = 0 + *(*int32)(unsafe.Pointer(peType)) = RBU_PK_NOTABLE *(*int32)(unsafe.Pointer(piPk)) = 0 - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + uintptr(0)*8), (p + 64 /* &.zErrmsg */), + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */), (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+25599 /* "SELECT (sql LIKE..." */, libc.VaList(bp, zTab))) - if !(((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0) || (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(0)*8))) != 100)) { + if !(((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK) || (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */))) != SQLITE_ROW)) { goto __1 } // Either an error, or no such table. goto rbuTableType_end __1: ; - if !(Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(0)*8)), 0) != 0) { + if !(Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */)), 0) != 0) { goto __2 } - *(*int32)(unsafe.Pointer(peType)) = 5 // virtual table + *(*int32)(unsafe.Pointer(peType)) = RBU_PK_VTAB // virtual table goto rbuTableType_end __2: ; - *(*int32)(unsafe.Pointer(piTnum)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(0)*8)), 1) + *(*int32)(unsafe.Pointer(piTnum)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */)), 1) - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + uintptr(1)*8), (p + 64 /* &.zErrmsg */), + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + 1*8), (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+25680 /* "PRAGMA index_lis..." */, libc.VaList(bp+8, zTab))) if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0) { goto __3 @@ -158764,28 +156142,28 @@ __2: __3: ; __4: - if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(1)*8))) == 100) { + if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 1*8))) == SQLITE_ROW) { goto __5 } - zOrig = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(1)*8)), 3) - zIdx = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(1)*8)), 1) - if !(((zOrig != 0) && (zIdx != 0)) && (int32(*(*U8)(unsafe.Pointer(zOrig + uintptr(0)))) == 'p')) { + zOrig = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 1*8)), 3) + zIdx = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 1*8)), 1) + if !(((zOrig != 0) && (zIdx != 0)) && (int32(*(*U8)(unsafe.Pointer(zOrig))) == 'p')) { goto __6 } - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + uintptr(2)*8), (p + 64 /* &.zErrmsg */), + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + 2*8), (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+25701 /* "SELECT rootpage ..." */, libc.VaList(bp+16, zIdx))) - if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) { + if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) { goto __7 } - if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(2)*8))) == 100) { + if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 2*8))) == SQLITE_ROW) { goto __8 } - *(*int32)(unsafe.Pointer(piPk)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(2)*8)), 0) - *(*int32)(unsafe.Pointer(peType)) = 3 + *(*int32)(unsafe.Pointer(piPk)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 2*8)), 0) + *(*int32)(unsafe.Pointer(peType)) = RBU_PK_EXTERNAL goto __9 __8: - *(*int32)(unsafe.Pointer(peType)) = 4 + *(*int32)(unsafe.Pointer(peType)) = RBU_PK_WITHOUT_ROWID __9: ; __7: @@ -158797,26 +156175,26 @@ __6: __5: ; - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + uintptr(3)*8), (p + 64 /* &.zErrmsg */), + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + 3*8), (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+25752 /* "PRAGMA table_inf..." */, libc.VaList(bp+24, zTab))) - if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) { + if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) { goto __10 } __11: - if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(3)*8))) == 100) { + if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 3*8))) == SQLITE_ROW) { goto __12 } - if !(Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(3)*8)), 5) > 0) { + if !(Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 3*8)), 5) > 0) { goto __13 } - *(*int32)(unsafe.Pointer(peType)) = 2 // explicit IPK column + *(*int32)(unsafe.Pointer(peType)) = RBU_PK_IPK // explicit IPK column goto rbuTableType_end __13: ; goto __11 __12: ; - *(*int32)(unsafe.Pointer(peType)) = 1 + *(*int32)(unsafe.Pointer(peType)) = RBU_PK_NONE __10: ; @@ -158833,6 +156211,7 @@ __15: goto __14 goto __16 __16: + } // This is a helper function for rbuObjIterCacheTableInfo(). It populates @@ -158844,14 +156223,14 @@ func rbuObjIterCacheIndexedCols(tls *libc.TLS, p uintptr, pIter uintptr) { /* sq *(*uintptr)(unsafe.Pointer(bp + 16 /* pList */)) = uintptr(0) var bIndex int32 = 0 - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { libc.Xmemcpy(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed, (*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk, (uint64(unsafe.Sizeof(U8(0))) * uint64((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol))) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+16 /* &pList */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+25773 /* "PRAGMA main.inde..." */, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) } (*RbuObjIter)(unsafe.Pointer(pIter)).FnIndex = 0 - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pList */)))) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pList */)))) { var zIdx uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pList */)), 1) var bPartial int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pList */)), 4) *(*uintptr)(unsafe.Pointer(bp + 24 /* pXInfo */)) = uintptr(0) @@ -158863,7 +156242,7 @@ func rbuObjIterCacheIndexedCols(tls *libc.TLS, p uintptr, pIter uintptr) { /* sq } (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+24 /* &pXInfo */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+25801 /* "PRAGMA main.inde..." */, libc.VaList(bp+8, zIdx))) - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pXInfo */)))) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pXInfo */)))) { var iCid int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pXInfo */)), 1) if iCid >= 0 { *(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed + uintptr(iCid))) = U8(1) @@ -158877,7 +156256,7 @@ func rbuObjIterCacheIndexedCols(tls *libc.TLS, p uintptr, pIter uintptr) { /* sq (*RbuObjIter)(unsafe.Pointer(pIter)).FnIndex++ } - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 4 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_WITHOUT_ROWID { // "PRAGMA index_list" includes the main PK b-tree (*RbuObjIter)(unsafe.Pointer(pIter)).FnIndex-- } @@ -158910,8 +156289,8 @@ func rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) int32 { / // Figure out the type of table this step will deal with. rbuTableType(tls, p, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, (pIter + 72 /* &.eType */), bp+56 /* &iTnum */, (pIter + 108 /* &.iPkTnum */)) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NOTABLE) { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+16983 /* "no such table: %..." */, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl)) } if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0 { @@ -158926,11 +156305,11 @@ func rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) int32 { / // "rbu_". (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp+64 /* &pStmt */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+25830 /* "SELECT * FROM '%..." */, libc.VaList(bp+8, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl))) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { nCol = Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */))) rbuAllocateIterArrays(tls, p, pIter, nCol) } - for i = 0; ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (i < nCol); i++ { + for i = 0; ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (i < nCol); i++ { var zName uintptr = Xsqlite3_column_name(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)), i) if Xsqlite3_strnicmp(tls, ts+25849 /* "rbu_" */, zName, 4) != 0 { var zCopy uintptr = rbuStrndup(tls, zName, (p + 56 /* &.rc */)) @@ -158943,10 +156322,10 @@ func rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) int32 { / Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */))) *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)) = uintptr(0) - if (((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && + if (((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((libc.Bool32((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) == 0)) && - (bRbuRowid != (libc.Bool32(((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 5) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1)))) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + (bRbuRowid != (libc.Bool32(((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE)))) { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+25864 /* "table %q %s rbu_..." */, libc.VaList(bp+16, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, func() uintptr { @@ -158960,11 +156339,11 @@ func rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) int32 { / // Check that all non-HIDDEN columns in the destination table are also // present in the input table. Populate the abTblPk[], azTblType[] and // aiTblOrder[] arrays at the same time. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+64 /* &pStmt */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+25915 /* "PRAGMA table_inf..." */, libc.VaList(bp+32, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) } - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)))) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)))) { var zName uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)), 1) if zName == uintptr(0) { break @@ -158975,7 +156354,7 @@ func rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) int32 { / } } if i == (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+25937, /* "column missing f..." */ libc.VaList(bp+40, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zName)) } else { @@ -159088,7 +156467,7 @@ func rbuVacuumTableStart(tls *libc.TLS, p uintptr, pIter uintptr, bRowid int32, (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+72 /* &pMax */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+25986 /* "SELECT max(_rowi..." */, libc.VaList(bp, zWrite, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pMax */)))) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pMax */)))) { var iMax Sqlite3_int64 = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pMax */)), 0) zRet = rbuMPrintf(tls, p, ts+26018 /* " WHERE _rowid_ >..." */, libc.VaList(bp+16, iMax)) } @@ -159098,12 +156477,12 @@ func rbuVacuumTableStart(tls *libc.TLS, p uintptr, pIter uintptr, bRowid int32, var zSelect uintptr = rbuObjIterGetPkList(tls, p, pIter, ts+26047 /* "quote(" */, ts+26054 /* "||','||" */, ts+3907 /* ")" */) var zList uintptr = rbuObjIterGetPkList(tls, p, pIter, ts+703 /* "" */, ts+12447 /* ", " */, ts+703 /* "" */) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+72 /* &pMax */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+26062, /* "SELECT %s FROM \"..." */ libc.VaList(bp+24, zSelect, zWrite, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zOrder))) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pMax */)))) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pMax */)))) { var zVal uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pMax */)), 0) zRet = rbuMPrintf(tls, p, ts+26104 /* " WHERE (%s) > (%..." */, libc.VaList(bp+56, zList, zVal)) } @@ -159170,7 +156549,7 @@ func XrbuVacuumIndexStart(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { /* (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+176 /* &pXInfo */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+25801 /* "PRAGMA main.inde..." */, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx))) __1: - if !(((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */))))) { + if !(((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */))))) { goto __2 } iCid = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */)), 1) @@ -159186,7 +156565,7 @@ __3: if !(iCid < 0) { goto __4 } - if !((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 2) { + if !((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_IPK) { goto __6 } i = 0 @@ -159233,7 +156612,7 @@ __2: __11: ; - if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) { + if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) { goto __12 } *(*uintptr)(unsafe.Pointer(bp + 184 /* pSel */)) = uintptr(0) @@ -159241,7 +156620,7 @@ __11: (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+184 /* &pSel */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+26216, /* "SELECT %s FROM \"..." */ libc.VaList(bp+112, zSelect, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zOrder))) - if !(((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 184 /* pSel */))))) { + if !(((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 184 /* pSel */))))) { goto __13 } zSep = ts + 703 /* "" */ @@ -159251,7 +156630,7 @@ __14: goto __16 } zQuoted = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 184 /* pSel */)), iCol) - if !(int32(*(*int8)(unsafe.Pointer(zQuoted + uintptr(0)))) == 'N') { + if !(int32(*(*int8)(unsafe.Pointer(zQuoted))) == 'N') { goto __17 } bFailed = 1 @@ -159325,13 +156704,13 @@ func rbuObjIterGetIndexCols(tls *libc.TLS, p uintptr, pIter uintptr, pzImposterC var zAnd uintptr = ts + 703 /* "" */ // Set to " AND " later on *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */)) = uintptr(0) // PRAGMA index_xinfo = ? - if rc == 0 { + if rc == SQLITE_OK { rc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+200 /* &pXInfo */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+25801 /* "PRAGMA main.inde..." */, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx))) } - for (rc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */)))) { + for (rc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */)))) { var iCid int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */)), 1) var bDesc int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */)), 3) var zCollate uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */)), 4) @@ -159347,7 +156726,7 @@ func rbuObjIterGetIndexCols(tls *libc.TLS, p uintptr, pIter uintptr, pzImposterC if iCid < 0 { // An integer primary key. If the table has an explicit IPK, use // its name. Otherwise, use "rbu_rowid". - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 2 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_IPK { var i int32 for i = 0; int32(*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0; i++ { } @@ -159381,7 +156760,7 @@ func rbuObjIterGetIndexCols(tls *libc.TLS, p uintptr, pIter uintptr, pzImposterC zWhere = Xsqlite3_mprintf(tls, ts+26379 /* "%z%s\"rbu_imp_%d%..." */, libc.VaList(bp+168, zWhere, zAnd, nBind, zCol)) if (((zRet == uintptr(0)) || (zImpPK == uintptr(0))) || (zImpCols == uintptr(0))) || (zWhere == uintptr(0)) { - rc = 7 + rc = SQLITE_NOMEM } zCom = ts + 12447 /* ", " */ zAnd = ts + 18855 /* " AND " */ @@ -159389,11 +156768,11 @@ func rbuObjIterGetIndexCols(tls *libc.TLS, p uintptr, pIter uintptr, pzImposterC } rc2 = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_free(tls, zRet) Xsqlite3_free(tls, zImpCols) Xsqlite3_free(tls, zImpPK) @@ -159426,7 +156805,7 @@ func rbuObjIterGetOldlist(tls *libc.TLS, p uintptr, pIter uintptr, zObj uintptr) defer tls.Free(64) var zList uintptr = uintptr(0) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0) { var zS uintptr = ts + 703 /* "" */ var i int32 for i = 0; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; i++ { @@ -159438,13 +156817,13 @@ func rbuObjIterGetOldlist(tls *libc.TLS, p uintptr, pIter uintptr, zObj uintptr) } zS = ts + 12447 /* ", " */ if zList == uintptr(0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM break } } // For a table with implicit rowids, append "old._rowid_" to the list. - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE) { zList = rbuMPrintf(tls, p, ts+26424 /* "%z, %s._rowid_" */, libc.VaList(bp+48, zList, zObj)) } } @@ -159464,9 +156843,9 @@ func rbuObjIterGetWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { /* sq defer tls.Free(80) var zList uintptr = uintptr(0) - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 5) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE) { zList = rbuMPrintf(tls, p, ts+26439 /* "_rowid_ = ?%d" */, libc.VaList(bp, ((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol+1))) - } else if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3 { + } else if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL { var zSep uintptr = ts + 703 /* "" */ var i int32 for i = 0; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; i++ { @@ -159498,7 +156877,7 @@ func rbuObjIterGetWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { /* sq // stored in the (p->nCol+1)'th column. Set the error code and error message // of the RBU handle to something reflecting this. func rbuBadControlError(tls *libc.TLS, p uintptr) { /* sqlite3.c:197716:13: */ - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+26528 /* "invalid rbu_cont..." */, 0) } @@ -159522,7 +156901,7 @@ func rbuObjIterGetSetlist(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr defer tls.Free(112) var zList uintptr = uintptr(0) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var i int32 if int32(libc.Xstrlen(tls, zMask)) != (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol { @@ -159599,14 +156978,14 @@ func rbuWithoutRowidPK(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { /* sql var z uintptr = uintptr(0) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var zSep uintptr = ts + 26621 /* "PRIMARY KEY(" */ *(*uintptr)(unsafe.Pointer(bp + 56 /* pXList */)) = uintptr(0) // PRAGMA index_list = (pIter->zTbl) *(*uintptr)(unsafe.Pointer(bp + 64 /* pXInfo */)) = uintptr(0) // PRAGMA index_xinfo = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+56 /* &pXList */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+25773 /* "PRAGMA main.inde..." */, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pXList */)))) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pXList */)))) { var zOrig uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pXList */)), 3) if (zOrig != 0) && (libc.Xstrcmp(tls, zOrig, ts+13775 /* "pk" */) == 0) { var zIdx uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pXList */)), 1) @@ -159619,7 +156998,7 @@ func rbuWithoutRowidPK(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { /* sql } rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 56 /* pXList */))) - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pXInfo */)))) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pXInfo */)))) { if Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pXInfo */)), 5) != 0 { // int iCid = sqlite3_column_int(pXInfo, 0); var zCol uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pXInfo */)), 2) @@ -159660,7 +157039,7 @@ func rbuCreateImposterTable2(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlit bp := tls.Alloc(184) defer tls.Free(184) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) { var tnum int32 = (*RbuObjIter)(unsafe.Pointer(pIter)).FiPkTnum // Root page of PK index *(*uintptr)(unsafe.Pointer(bp + 168 /* pQuery */)) = uintptr(0) // SELECT name ... WHERE rootpage = $tnum var zIdx uintptr = uintptr(0) // Name of PK index @@ -159674,9 +157053,9 @@ func rbuCreateImposterTable2(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlit // zIdx to point to a nul-terminated string containing this name. (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+168 /* &pQuery */, (p + 64 /* &.zErrmsg */), ts+26649 /* "SELECT name FROM..." */) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { Xsqlite3_bind_int(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pQuery */)), 1, tnum) - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pQuery */))) { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pQuery */))) { zIdx = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pQuery */)), 0) } } @@ -159686,7 +157065,7 @@ func rbuCreateImposterTable2(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlit } rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 168 /* pQuery */))) - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */)))) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */)))) { var bKey int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */)), 5) if bKey != 0 { var iCid int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */)), 1) @@ -159706,11 +157085,11 @@ func rbuCreateImposterTable2(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlit zCols = rbuMPrintf(tls, p, ts+26731 /* "%z, id INTEGER" */, libc.VaList(bp+80, zCols)) rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */))) - Xsqlite3_test_control(tls, 25, libc.VaList(bp+88, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 1, tnum)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+88, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 1, tnum)) rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+26746, /* "CREATE TABLE rbu..." */ libc.VaList(bp+120, zCols, zPk)) - Xsqlite3_test_control(tls, 25, libc.VaList(bp+136, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 0, 0)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+136, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 0, 0)) } } @@ -159736,14 +157115,14 @@ func rbuCreateImposterTable(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite bp := tls.Alloc(200) defer tls.Free(200) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType != 5) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType != RBU_PK_VTAB) { var tnum int32 = (*RbuObjIter)(unsafe.Pointer(pIter)).FiTnum var zComma uintptr = ts + 703 /* "" */ var zSql uintptr = uintptr(0) var iCol int32 - Xsqlite3_test_control(tls, 25, libc.VaList(bp, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 0, 1)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 0, 1)) - for iCol = 0; ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (iCol < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol); iCol++ { + for iCol = 0; ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (iCol < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol); iCol++ { var zPk uintptr = ts + 703 /* "" */ var zCol uintptr = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iCol)*8)) *(*uintptr)(unsafe.Pointer(bp + 192 /* zColl */)) = uintptr(0) @@ -159751,7 +157130,7 @@ func rbuCreateImposterTable(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_table_column_metadata(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zCol, uintptr(0), bp+192 /* &zColl */, uintptr(0), uintptr(0), uintptr(0)) - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 2) && (*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(iCol))) != 0) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_IPK) && (*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(iCol))) != 0) { // If the target table column is an "INTEGER PRIMARY KEY", add // "PRIMARY KEY" to the imposter table column declaration. zPk = ts + 26808 /* "PRIMARY KEY " */ @@ -159767,23 +157146,23 @@ func rbuCreateImposterTable(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite zComma = ts + 12447 /* ", " */ } - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 4 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_WITHOUT_ROWID { var zPk uintptr = rbuWithoutRowidPK(tls, p, pIter) if zPk != 0 { zSql = rbuMPrintf(tls, p, ts+26858 /* "%z, %z" */, libc.VaList(bp+88, zSql, zPk)) } } - Xsqlite3_test_control(tls, 25, libc.VaList(bp+104, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 1, tnum)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+104, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 1, tnum)) rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+26865, /* "CREATE TABLE \"rb..." */ libc.VaList(bp+136, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zSql, func() uintptr { - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 4 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_WITHOUT_ROWID { return ts + 26897 /* " WITHOUT ROWID" */ } return ts + 703 /* "" */ }())) - Xsqlite3_test_control(tls, 25, libc.VaList(bp+160, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 0, 0)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+160, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 0, 0)) } } @@ -159800,7 +157179,7 @@ func rbuObjIterPrepareTmpInsert(tls *libc.TLS, p uintptr, pIter uintptr, zCollis bp := tls.Alloc(40) defer tls.Free(40) - var bRbuRowid int32 = (libc.Bool32(((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1))) + var bRbuRowid int32 = (libc.Bool32(((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE))) var zBind uintptr = rbuObjIterGetBindlist(tls, p, (((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol + 1) + bRbuRowid)) if zBind != 0 { @@ -159813,22 +157192,22 @@ func rbuObjIterPrepareTmpInsert(tls *libc.TLS, p uintptr, pIter uintptr, zCollis func rbuTmpInsertFunc(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) { /* sqlite3.c:198027:13: */ var p uintptr = Xsqlite3_user_data(tls, pCtx) - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 - if Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) != 0 { + if Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal))) != 0 { *(*I64)(unsafe.Pointer(p + 304 /* &.nPhaseOneStep */)) += (I64((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex)) } - for i = 0; (rc == 0) && (i < nVal); i++ { + for i = 0; (rc == SQLITE_OK) && (i < nVal); i++ { rc = Xsqlite3_bind_value(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpTmpInsert, (i + 1), *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8))) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_step(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpTmpInsert) rc = Xsqlite3_reset(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpTmpInsert) } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_result_error_code(tls, pCtx, rc) } } @@ -159841,14 +157220,14 @@ func rbuObjIterGetIndexWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc var zRet uintptr = uintptr(0) - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp /* &pStmt */, (p + 64 /* &.zErrmsg */), ts+26969 /* "SELECT trim(sql)..." */) } - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { var rc2 int32 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 1, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx, -1, uintptr(0)) - if (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)))) { + if (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)))) { var zSql uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 0) if zSql != 0 { (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdxSql = libc.AssignUintptr(&zSql, rbuStrndup(tls, zSql, bp+8 /* &rc */)) @@ -159866,7 +157245,7 @@ func rbuObjIterGetIndexWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { var aIdxCol uintptr = Xsqlite3_realloc(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol, (int32((uint64(nIdxAlloc + 16)) * uint64(unsafe.Sizeof(RbuSpan{}))))) if aIdxCol == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_NOMEM break } (*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol = aIdxCol @@ -159876,7 +157255,7 @@ func rbuObjIterGetIndexWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { if int32(c) == '(' { if nParen == 0 { - (*RbuSpan)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(0)*16)).FzSpan = (zSql + uintptr((i + 1))) + (*RbuSpan)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol)).FzSpan = (zSql + uintptr((i + 1))) } nParen++ } else if int32(c) == ')' { @@ -159929,7 +157308,7 @@ func rbuObjIterGetIndexWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { } rc2 = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = rc2 } } @@ -159945,7 +157324,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 bp := tls.Alloc(628) defer tls.Free(628) - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect == uintptr(0)) && (rbuObjIterCacheTableInfo(tls, p, pIter) == 0) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect == uintptr(0)) && (rbuObjIterCacheTableInfo(tls, p, pIter) == SQLITE_OK) { var tnum int32 = (*RbuObjIter)(unsafe.Pointer(pIter)).FiTnum var zCollist uintptr = uintptr(0) // List of indexed columns var pz uintptr = (p + 64 /* &.zErrmsg */) @@ -159955,7 +157334,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 if nOffset != 0 { zLimit = Xsqlite3_mprintf(tls, ts+27035 /* " LIMIT -1 OFFSET..." */, libc.VaList(bp, nOffset)) if !(zLimit != 0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } } @@ -159974,30 +157353,30 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 zBind = rbuObjIterGetBindlist(tls, p, *(*int32)(unsafe.Pointer(bp + 624 /* nBind */))) // Create the imposter table used to write to this index. - Xsqlite3_test_control(tls, 25, libc.VaList(bp+8, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 0, 1)) - Xsqlite3_test_control(tls, 25, libc.VaList(bp+40, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 1, tnum)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+8, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 0, 1)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+40, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 1, tnum)) rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+27055, /* "CREATE TABLE \"rb..." */ libc.VaList(bp+72, zTbl, *(*uintptr)(unsafe.Pointer(bp + 600 /* zImposterCols */)), *(*uintptr)(unsafe.Pointer(bp + 608 /* zImposterPK */)))) - Xsqlite3_test_control(tls, 25, libc.VaList(bp+96, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 0, 0)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+96, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 0, 0)) // Create the statement to insert index entries (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol = *(*int32)(unsafe.Pointer(bp + 624 /* nBind */)) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (pIter + 136 /* &.pInsert */), (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+27120 /* "INSERT INTO \"rbu..." */, libc.VaList(bp+128, zTbl, zBind))) } // And to delete index entries - if ((libc.Bool32((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) { + if ((libc.Bool32((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (pIter + 144 /* &.pDelete */), (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+27156 /* "DELETE FROM \"rbu..." */, libc.VaList(bp+144, zTbl, *(*uintptr)(unsafe.Pointer(bp + 616 /* zWhere */))))) } // Create the SELECT statement to read keys in sorted order - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var zSql uintptr if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { var zStart uintptr = uintptr(0) @@ -160027,7 +157406,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 }(), zStart, zCollist, zLimit)) Xsqlite3_free(tls, zStart) - } else if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1) { + } else if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE) { zSql = Xsqlite3_mprintf(tls, ts+27261, /* "SELECT %s, rbu_c..." */ libc.VaList(bp+216, zCollist, p+48 /* &.zStateDb */, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, @@ -160047,7 +157426,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 }(), zCollist, zLimit)) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, (pIter + 128 /* &.pSelect */), pz, zSql) } else { Xsqlite3_free(tls, zSql) @@ -160060,9 +157439,9 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 Xsqlite3_free(tls, zBind) Xsqlite3_free(tls, zPart) } else { - var bRbuRowid int32 = (libc.Bool32((((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 5) || - ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1)) || - (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))))) + var bRbuRowid int32 = (libc.Bool32((((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB) || + ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE)) || + (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))))) var zTbl uintptr = (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl // Table this step applies to var zWrite uintptr // Imposter table name @@ -160078,14 +157457,14 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 rbuCreateImposterTable(tls, p, pIter) rbuCreateImposterTable2(tls, p, pIter) zWrite = func() uintptr { - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 5 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB { return ts + 703 /* "" */ } return ts + 27481 /* "rbu_imp_" */ }() // Create the INSERT statement to write to the target PK b-tree - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (pIter + 136 /* &.pInsert */), pz, Xsqlite3_mprintf(tls, ts+27490, /* "INSERT INTO \"%s%..." */ @@ -160100,7 +157479,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 // Create the DELETE statement to write to the target PK b-tree. // Because it only performs INSERT operations, this is not required for // an rbu vacuum handle. - if ((libc.Bool32((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) { + if ((libc.Bool32((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (pIter + 144 /* &.pDelete */), pz, Xsqlite3_mprintf(tls, ts+27536 /* "DELETE FROM \"%s%..." */, libc.VaList(bp+384, zWrite, zTbl, zWhere))) @@ -160108,7 +157487,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 if ((libc.Bool32((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0) { var zRbuRowid uintptr = ts + 703 /* "" */ - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE) { zRbuRowid = ts + 27564 /* ", rbu_rowid" */ } @@ -160116,7 +157495,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+27576 /* "CREATE TABLE IF ..." */, libc.VaList(bp+408, p+48 /* &.zStateDb */, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, func() uintptr { - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL { return ts + 27652 /* ", 0 AS rbu_rowid" */ } return ts + 703 /* "" */ @@ -160129,7 +157508,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 zWrite, zTbl, zOldlist, zWrite, zTbl, zNewlist)) - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE) { rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+27968, /* "CREATE TEMP TRIG..." */ @@ -160140,7 +157519,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 } // Create the SELECT statement to read keys from data_xxx - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var zRbuRowid uintptr = ts + 703 /* "" */ var zStart uintptr = uintptr(0) var zOrder uintptr = uintptr(0) @@ -160167,7 +157546,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, (pIter + 128 /* &.pSelect */), pz, Xsqlite3_mprintf(tls, ts+28088, /* "SELECT %s,%s rbu..." */ @@ -160238,12 +157617,12 @@ func rbuGetUpdateStmt(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr, pp (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext = (*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate (*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = pUp *(*uintptr)(unsafe.Pointer(ppStmt)) = (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate - return 0 + return SQLITE_OK } nUp++ } - if nUp >= 16 { + if nUp >= SQLITE_RBU_UPDATE_CACHESIZE { for pp = (pIter + 184 /* &.pRbuUpdate */); *(*uintptr)(unsafe.Pointer(pp)) != pUp; pp = (*(*uintptr)(unsafe.Pointer(pp)) + 16 /* &.pNext */) { } *(*uintptr)(unsafe.Pointer(pp)) = uintptr(0) @@ -160258,7 +157637,7 @@ func rbuGetUpdateStmt(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr, pp var zSet uintptr = rbuObjIterGetSetlist(tls, p, pIter, zMask) var zUpdate uintptr = uintptr(0) - (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask = (pUp + uintptr(1)*24) + (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask = (pUp + 1*24) libc.Xmemcpy(tls, (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask, zMask, uint64((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol)) (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext = (*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate (*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = pUp @@ -160266,7 +157645,7 @@ func rbuGetUpdateStmt(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr, pp if zSet != 0 { var zPrefix uintptr = ts + 703 /* "" */ - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType != 5 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType != RBU_PK_VTAB { zPrefix = ts + 27481 /* "rbu_imp_" */ } zUpdate = Xsqlite3_mprintf(tls, ts+28142, /* "UPDATE \"%s%w\" SE..." */ @@ -160287,8 +157666,8 @@ func rbuOpenDbhandle(tls *libc.TLS, p uintptr, zName uintptr, bUseVfs int32) uin defer tls.Free(16) *(*uintptr)(unsafe.Pointer(bp + 8 /* db */)) = uintptr(0) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - var flags int32 = ((0x00000002 | 0x00000004) | 0x00000040) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var flags int32 = ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_URI) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_open_v2(tls, zName, bp+8 /* &db */, flags, func() uintptr { if bUseVfs != 0 { return (*Sqlite3rbu)(unsafe.Pointer(p)).FzVfsName @@ -160338,60 +157717,60 @@ func rbuLoadState(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:198531:17: */ *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp+8 /* &pStmt */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+28172 /* "SELECT k, v FROM..." */, libc.VaList(bp, p+48 /* &.zStateDb */))) - for (*(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)))) { + for (*(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)))) { switch Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 0) { - case 1: + case RBU_STATE_STAGE: (*RbuState)(unsafe.Pointer(pRet)).FeStage = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) - if (((*RbuState)(unsafe.Pointer(pRet)).FeStage != 1) && - ((*RbuState)(unsafe.Pointer(pRet)).FeStage != 2)) && - ((*RbuState)(unsafe.Pointer(pRet)).FeStage != 4) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 11 + if (((*RbuState)(unsafe.Pointer(pRet)).FeStage != RBU_STAGE_OAL) && + ((*RbuState)(unsafe.Pointer(pRet)).FeStage != RBU_STAGE_MOVE)) && + ((*RbuState)(unsafe.Pointer(pRet)).FeStage != RBU_STAGE_CKPT) { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT } break - case 2: + case RBU_STATE_TBL: (*RbuState)(unsafe.Pointer(pRet)).FzTbl = rbuStrndup(tls, Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1), bp+16 /* &rc */) break - case 3: + case RBU_STATE_IDX: (*RbuState)(unsafe.Pointer(pRet)).FzIdx = rbuStrndup(tls, Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1), bp+16 /* &rc */) break - case 4: + case RBU_STATE_ROW: (*RbuState)(unsafe.Pointer(pRet)).FnRow = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) break - case 5: + case RBU_STATE_PROGRESS: (*RbuState)(unsafe.Pointer(pRet)).FnProgress = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) break - case 6: + case RBU_STATE_CKPT: (*RbuState)(unsafe.Pointer(pRet)).FiWalCksum = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) break - case 7: + case RBU_STATE_COOKIE: (*RbuState)(unsafe.Pointer(pRet)).FiCookie = U32(Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1)) break - case 8: + case RBU_STATE_OALSZ: (*RbuState)(unsafe.Pointer(pRet)).FiOalSz = I64(U32(Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1))) break - case 9: + case RBU_STATE_PHASEONESTEP: (*RbuState)(unsafe.Pointer(pRet)).FnPhaseOneStep = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) break - case 10: + case RBU_STATE_DATATBL: (*RbuState)(unsafe.Pointer(pRet)).FzDataTbl = rbuStrndup(tls, Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1), bp+16 /* &rc */) break default: - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 11 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_CORRUPT break } } rc2 = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = rc2 } @@ -160408,8 +157787,8 @@ func rbuOpenDatabase(tls *libc.TLS, p uintptr, pbRetry uintptr) { /* sqlite3.c:1 // Open the RBU database (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu = rbuOpenDbhandle(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu, 1) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { - Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+5282 /* "main" */, 5149216, p) + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { + Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+5282 /* "main" */, SQLITE_FCNTL_RBUCNT, p) if (*Sqlite3rbu)(unsafe.Pointer(p)).FzState == uintptr(0) { var zFile uintptr = Xsqlite3_db_filename(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+5282 /* "main" */) (*Sqlite3rbu)(unsafe.Pointer(p)).FzState = rbuMPrintf(tls, p, ts+28202 /* "file://%s-vacuum..." */, libc.VaList(bp, zFile, zFile)) @@ -160428,21 +157807,21 @@ func rbuOpenDatabase(tls *libc.TLS, p uintptr, pbRetry uintptr) { /* sqlite3.c:1 // If it has not already been created, create the rbu_state table rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+28247 /* "CREATE TABLE IF ..." */, libc.VaList(bp+24, p+48 /* &.zStateDb */)) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { var bOpen int32 = 0 var rc int32 (*Sqlite3rbu)(unsafe.Pointer(p)).FnRbu = 0 (*Sqlite3rbu)(unsafe.Pointer(p)).FpRbuFd = uintptr(0) - rc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+5282 /* "main" */, 5149216, p) - if rc != 12 { + rc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+5282 /* "main" */, SQLITE_FCNTL_RBUCNT, p) + if rc != SQLITE_NOTFOUND { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc } - if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage >= 2 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage >= RBU_STAGE_MOVE { bOpen = 1 } else { var pState uintptr = rbuLoadState(tls, p) if pState != 0 { - bOpen = (libc.Bool32((*RbuState)(unsafe.Pointer(pState)).FeStage >= 2)) + bOpen = (libc.Bool32((*RbuState)(unsafe.Pointer(pState)).FeStage >= RBU_STAGE_MOVE)) rbuFreeState(tls, pState) } } @@ -160452,7 +157831,7 @@ func rbuOpenDatabase(tls *libc.TLS, p uintptr, pbRetry uintptr) { /* sqlite3.c:1 } (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 0 - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain == uintptr(0)) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain == uintptr(0)) { if !((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain = rbuOpenDbhandle(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget, 1) } else if (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpRbuFd)).FpWalFd != 0 { @@ -160465,13 +157844,13 @@ func rbuOpenDatabase(tls *libc.TLS, p uintptr, pbRetry uintptr) { /* sqlite3.c:1 *(*int32)(unsafe.Pointer(pbRetry)) = 1 return } - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+28313 /* "cannot vacuum wa..." */, 0) } else { var zTarget uintptr var zExtra uintptr = uintptr(0) if (libc.Xstrlen(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu) >= uint64(5)) && (0 == libc.Xmemcmp(tls, ts+21445 /* "file:" */, (*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu, uint64(5))) { - zExtra = ((*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu + uintptr(5)) + zExtra = ((*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu + 5) for *(*int8)(unsafe.Pointer(zExtra)) != 0 { if int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zExtra, 1)))) == '?' { break @@ -160497,7 +157876,7 @@ func rbuOpenDatabase(tls *libc.TLS, p uintptr, pbRetry uintptr) { /* sqlite3.c:1 }())) if zTarget == uintptr(0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM return } (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain = rbuOpenDbhandle(tls, p, zTarget, (libc.Bool32((*Sqlite3rbu)(unsafe.Pointer(p)).FnRbu <= 1))) @@ -160505,41 +157884,41 @@ func rbuOpenDatabase(tls *libc.TLS, p uintptr, pbRetry uintptr) { /* sqlite3.c:1 } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, - ts+28379 /* "rbu_tmp_insert" */, -1, 1, p, *(*uintptr)(unsafe.Pointer(&struct { + ts+28379 /* "rbu_tmp_insert" */, -1, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rbuTmpInsertFunc})), uintptr(0), uintptr(0)) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, - ts+28394 /* "rbu_fossil_delta" */, 2, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + ts+28394 /* "rbu_fossil_delta" */, 2, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rbuFossilDeltaFunc})), uintptr(0), uintptr(0)) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, - ts+28411 /* "rbu_target_name" */, -1, 1, p, *(*uintptr)(unsafe.Pointer(&struct { + ts+28411 /* "rbu_target_name" */, -1, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rbuTargetNameFunc})), uintptr(0), uintptr(0)) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 26, p) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, SQLITE_FCNTL_RBU, p) } rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+28427 /* "SELECT * FROM sq..." */, 0) // Mark the database file just opened as an RBU target database. If // this call returns SQLITE_NOTFOUND, then the RBU vfs is not in use. // This is an error. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, 26, p) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+5282 /* "main" */, SQLITE_FCNTL_RBU, p) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 12 { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_NOTFOUND { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+28455 /* "rbu vfs not foun..." */, 0) } } @@ -160575,13 +157954,13 @@ func rbuShmChecksum(tls *libc.TLS, p uintptr) I64 { /* sqlite3.c:198808:12: */ defer tls.Free(8) var iRet I64 = int64(0) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal // var ptr uintptr at bp, 8 (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 104 /* &.xShmMap */))))(tls, pDb, 0, (32 * 1024), 0, bp /* &ptr */) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - iRet = ((I64(*(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* ptr */)) + uintptr(10)*4))) << 32) + I64(*(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* ptr */)) + uintptr(11)*4)))) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + iRet = ((I64(*(*U32)(unsafe.Pointer(libc.AtomicLoadPUintptr(bp /* ptr */) + 10*4))) << 32) + I64(*(*U32)(unsafe.Pointer(libc.AtomicLoadPUintptr(bp /* ptr */) + 11*4)))) } } return iRet @@ -160608,7 +157987,7 @@ func rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) { /* sqlite3.c // does not interfere with the "capture" process below. if pState == uintptr(0) { (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 0 - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+28427 /* "SELECT * FROM sq..." */, uintptr(0), uintptr(0), uintptr(0)) } } @@ -160640,17 +158019,17 @@ func rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) { /* sqlite3.c // WRITER, CHECKPOINT and READ0 locks are still held, it is safe to copy // data from the wal file into the database file according to the // contents of aFrame[]. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var rc2 int32 - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 3 + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_CAPTURE rc2 = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+28473 /* "PRAGMA main.wal_..." */, uintptr(0), uintptr(0), uintptr(0)) - if rc2 != 2 { + if rc2 != SQLITE_INTERNAL { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc2 } } - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame > 0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 4 + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame > 0) { + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_CKPT (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep = func() int32 { if pState != 0 { return (*RbuState)(unsafe.Pointer(pState)).FnRow @@ -160661,10 +158040,10 @@ func rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) { /* sqlite3.c (*Sqlite3rbu)(unsafe.Pointer(p)).FiWalCksum = rbuShmChecksum(tls, p) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { if ((*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame == 0) || ((pState != 0) && ((*RbuState)(unsafe.Pointer(pState)).FiWalCksum != (*Sqlite3rbu)(unsafe.Pointer(p)).FiWalCksum)) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 101 - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 5 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_DONE + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_DONE } else { var nSectorSize int32 var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal @@ -160681,7 +158060,7 @@ func rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) { /* sqlite3.c // directory in which the target database and the wal file reside, in // case it has not been synced since the rename() call in // rbuMoveOalFile(). - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pWal)).FpMethods + 40 /* &.xSync */))))(tls, pWal, 0x00002) + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pWal)).FpMethods + 40 /* &.xSync */))))(tls, pWal, SQLITE_SYNC_NORMAL) } } } @@ -160690,12 +158069,12 @@ func rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) { /* sqlite3.c // the rbu object is in capture mode. Record the frame number of the frame // being read in the aFrame[] array. func rbuCaptureWalRead(tls *libc.TLS, pRbu uintptr, iOff I64, iAmt int32) int32 { /* sqlite3.c:198921:12: */ - var mReq U32 = (U32(((int32(1) << 0) | (int32(1) << 1)) | (int32(1) << 3))) + var mReq U32 = (U32(((int32(1) << WAL_LOCK_WRITE) | (int32(1) << WAL_LOCK_CKPT)) | (int32(1) << WAL_LOCK_READ0))) var iFrame U32 if (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FmLock != mReq { - (*Sqlite3rbu)(unsafe.Pointer(pRbu)).Frc = 5 - return 2 + (*Sqlite3rbu)(unsafe.Pointer(pRbu)).Frc = SQLITE_BUSY + return SQLITE_INTERNAL } (*Sqlite3rbu)(unsafe.Pointer(pRbu)).Fpgsz = iAmt @@ -160709,7 +158088,7 @@ func rbuCaptureWalRead(tls *libc.TLS, pRbu uintptr, iOff I64, iAmt int32) int32 var aNew uintptr aNew = Xsqlite3_realloc64(tls, (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame, (uint64(uint64(nNew) * uint64(unsafe.Sizeof(RbuFrame{}))))) if aNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame = aNew (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrameAlloc = nNew @@ -160722,7 +158101,7 @@ func rbuCaptureWalRead(tls *libc.TLS, pRbu uintptr, iOff I64, iAmt int32) int32 (*RbuFrame)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame + uintptr((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame)*8)).FiWalFrame = iFrame (*RbuFrame)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame + uintptr((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame)*8)).FiDbPage = U32(0) (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame++ - return 0 + return SQLITE_OK } // Called when a page of data is written to offset iOff of the database @@ -160730,7 +158109,7 @@ func rbuCaptureWalRead(tls *libc.TLS, pRbu uintptr, iOff I64, iAmt int32) int32 // of the page being written in the aFrame[] array. func rbuCaptureDbWrite(tls *libc.TLS, pRbu uintptr, iOff I64) int32 { /* sqlite3.c:198953:12: */ (*RbuFrame)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame + uintptr(((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame-1))*8)).FiDbPage = ((U32(iOff / I64((*Sqlite3rbu)(unsafe.Pointer(pRbu)).Fpgsz))) + U32(1)) - return 0 + return SQLITE_OK } // This is called as part of an incremental checkpoint operation. Copy @@ -160755,9 +158134,9 @@ func rbuCheckpointFrame(tls *libc.TLS, p uintptr, pFrame uintptr) { /* sqlite3.c func rbuLockDatabase(tls *libc.TLS, p uintptr) { /* sqlite3.c:198981:13: */ var pReal uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 56 /* &.xLock */))))(tls, pReal, 1) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 56 /* &.xLock */))))(tls, pReal, 4) + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 56 /* &.xLock */))))(tls, pReal, SQLITE_LOCK_SHARED) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 56 /* &.xLock */))))(tls, pReal, SQLITE_LOCK_EXCLUSIVE) } } @@ -160782,7 +158161,7 @@ func rbuMoveOalFile(tls *libc.TLS, p uintptr) { /* sqlite3.c:199021:13: */ zWal = Xsqlite3_mprintf(tls, ts+28515 /* "%s-wal" */, libc.VaList(bp+8, zMove)) if (zWal == uintptr(0)) || (zOal == uintptr(0)) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } else { // Move the *-oal file to *-wal. At this point connection p->db is // holding a SHARED lock on the target database file (because it is @@ -160791,7 +158170,7 @@ func rbuMoveOalFile(tls *libc.TLS, p uintptr) { /* sqlite3.c:199021:13: */ // In order to ensure that there are no database readers, an EXCLUSIVE // lock is obtained here before the *-oal is moved to *-wal. rbuLockDatabase(tls, p) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { rbuFileSuffix3(tls, zBase, zWal) rbuFileSuffix3(tls, zBase, zOal) @@ -160804,12 +158183,12 @@ func rbuMoveOalFile(tls *libc.TLS, p uintptr) { /* sqlite3.c:199021:13: */ (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = func() int32 { if libc.Xrename(tls, zOal, zWal) != 0 { - return 10 + return SQLITE_IOERR } - return 0 + return SQLITE_OK }() - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { rbuOpenDatabase(tls, p, uintptr(0)) rbuSetupCheckpoint(tls, p, uintptr(0)) } @@ -160840,39 +158219,39 @@ func rbuStepType(tls *libc.TLS, p uintptr, pzMask uintptr) int32 { /* sqlite3.c: var res int32 = 0 // Return value switch Xsqlite3_column_type(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol) { - case 1: + case SQLITE_INTEGER: { var iVal int32 = Xsqlite3_column_int(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol) switch iVal { case 0: - res = 1 + res = RBU_INSERT break case 1: - res = 2 + res = RBU_DELETE break case 2: - res = 3 + res = RBU_REPLACE break case 3: - res = 4 + res = RBU_IDX_DELETE break case 4: - res = 5 + res = RBU_IDX_INSERT break } break } - case 3: + case SQLITE_TEXT: { var z uintptr = Xsqlite3_column_text(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol) if z == uintptr(0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } else { *(*uintptr)(unsafe.Pointer(pzMask)) = z } - res = 6 + res = RBU_UPDATE break @@ -160901,11 +158280,11 @@ func rbuStepOneOp(tls *libc.TLS, p uintptr, eType int32) { /* sqlite3.c:199168:1 // statement below does actually delete a row, nPhaseOneStep will be // incremented by the same amount when SQL function rbu_tmp_insert() // is invoked by the trigger. - if eType == 2 { + if eType == RBU_DELETE { *(*I64)(unsafe.Pointer(p + 304 /* &.nPhaseOneStep */)) -= (I64((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex)) } - if (eType == 4) || (eType == 2) { + if (eType == RBU_IDX_DELETE) || (eType == RBU_DELETE) { pWriter = (*RbuObjIter)(unsafe.Pointer(pIter)).FpDelete } else { pWriter = (*RbuObjIter)(unsafe.Pointer(pIter)).FpInsert @@ -160915,15 +158294,15 @@ func rbuStepOneOp(tls *libc.TLS, p uintptr, eType int32) { /* sqlite3.c:199168:1 // If this is an INSERT into a table b-tree and the table has an // explicit INTEGER PRIMARY KEY, check that this is not an attempt // to write a NULL into the IPK column. That is not permitted. - if ((((eType == 1) && - ((*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0))) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 2)) && (*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0)) && - (Xsqlite3_column_type(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) == 5) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 20 + if ((((eType == RBU_INSERT) && + ((*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0))) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_IPK)) && (*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0)) && + (Xsqlite3_column_type(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) == SQLITE_NULL) { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_MISMATCH (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+21083 /* "datatype mismatc..." */, 0) return } - if (eType == 2) && (int32(*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0) { + if (eType == RBU_DELETE) && (int32(*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0) { continue } @@ -160934,9 +158313,9 @@ func rbuStepOneOp(tls *libc.TLS, p uintptr, eType int32) { /* sqlite3.c:199168:1 } } if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { - if (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 5) || - ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1)) || - (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) { + if (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB) || + ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE)) || + (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) { // For a virtual table, or a table with no primary key, the // SELECT statement is: // @@ -160948,7 +158327,7 @@ func rbuStepOneOp(tls *libc.TLS, p uintptr, eType int32) { /* sqlite3.c:199168:1 (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, pWriter, ((*RbuObjIter)(unsafe.Pointer(pIter)).FnCol + 1), pVal) } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { Xsqlite3_step(tls, pWriter) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = resetAndCollectError(tls, pWriter, (p + 64 /* &.zErrmsg */)) } @@ -160973,17 +158352,17 @@ func rbuStep(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199251:12: */ if eType != 0 { - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0)) && ((eType == 4) || (eType == 5)) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0)) && ((eType == RBU_IDX_DELETE) || (eType == RBU_IDX_INSERT)) { rbuBadControlError(tls, p) - } else if eType == 3 { + } else if eType == RBU_REPLACE { if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { *(*I64)(unsafe.Pointer(p + 304 /* &.nPhaseOneStep */)) += (I64((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex)) - rbuStepOneOp(tls, p, 2) + rbuStepOneOp(tls, p, RBU_DELETE) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - rbuStepOneOp(tls, p, 1) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + rbuStepOneOp(tls, p, RBU_INSERT) } - } else if eType != 6 { + } else if eType != RBU_UPDATE { rbuStepOneOp(tls, p, eType) } else { var pVal uintptr @@ -160993,21 +158372,21 @@ func rbuStep(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199251:12: */ rbuGetUpdateStmt(tls, p, pIter, *(*uintptr)(unsafe.Pointer(bp /* zMask */)), bp+8 /* &pUpdate */) if *(*uintptr)(unsafe.Pointer(bp + 8 /* pUpdate */)) != 0 { var i int32 - for i = 0; ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol); i++ { + for i = 0; ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol); i++ { var c int8 = *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zMask */)) + uintptr(*(*int32)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4))))) pVal = Xsqlite3_column_value(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) if (*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0) || (int32(c) != '.') { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pUpdate */)), (i + 1), pVal) } } - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && - (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 5) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1)) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && + (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE)) { // Bind the rbu_rowid value to column _rowid_ pVal = Xsqlite3_column_value(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, ((*RbuObjIter)(unsafe.Pointer(pIter)).FnCol + 1)) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pUpdate */)), ((*RbuObjIter)(unsafe.Pointer(pIter)).FnCol + 1), pVal) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pUpdate */))) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = resetAndCollectError(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pUpdate */)), (p + 64 /* &.zErrmsg */)) } @@ -161026,7 +158405,7 @@ func rbuIncrSchemaCookie(tls *libc.TLS, p uintptr) { /* sqlite3.c:199316:13: */ bp := tls.Alloc(16) defer tls.Free(16) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var dbread uintptr = func() uintptr { if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { return (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu @@ -161038,18 +158417,18 @@ func rbuIncrSchemaCookie(tls *libc.TLS, p uintptr) { /* sqlite3.c:199316:13: */ (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, dbread, bp+8 /* &pStmt */, (p + 64 /* &.zErrmsg */), ts+28522 /* "PRAGMA schema_ve..." */) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { // Coverage: it may be that this sqlite3_step() cannot fail. There // is already a transaction open, so the prepared statement cannot // throw an SQLITE_SCHEMA exception. The only database page the // statement reads is page 1, which is guaranteed to be in the cache. // And no memory allocations are required. - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) { iCookie = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 0) } rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+28544 /* "PRAGMA schema_ve..." */, libc.VaList(bp, (iCookie+1))) } } @@ -161062,7 +158441,7 @@ func rbuSaveState(tls *libc.TLS, p uintptr, eStage int32) { /* sqlite3.c:199347: bp := tls.Alloc(176) defer tls.Free(176) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) || ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 101) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) || ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_DONE) { *(*uintptr)(unsafe.Pointer(bp + 168 /* pInsert */)) = uintptr(0) var pFd uintptr = func() uintptr { if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { @@ -161077,22 +158456,22 @@ func rbuSaveState(tls *libc.TLS, p uintptr, eStage int32) { /* sqlite3.c:199347: ts+28571, /* "INSERT OR REPLAC..." */ libc.VaList(bp, p+48, /* &.zStateDb */ - 1, eStage, - 2, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl, - 3, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzIdx, - 4, (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep, - 5, (*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress, - 6, (*Sqlite3rbu)(unsafe.Pointer(p)).FiWalCksum, - 7, I64((*Rbu_file)(unsafe.Pointer(pFd)).FiCookie), - 8, (*Sqlite3rbu)(unsafe.Pointer(p)).FiOalSz, - 9, (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep, - 10, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzDataTbl))) + RBU_STATE_STAGE, eStage, + RBU_STATE_TBL, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl, + RBU_STATE_IDX, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzIdx, + RBU_STATE_ROW, (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep, + RBU_STATE_PROGRESS, (*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress, + RBU_STATE_CKPT, (*Sqlite3rbu)(unsafe.Pointer(p)).FiWalCksum, + RBU_STATE_COOKIE, I64((*Rbu_file)(unsafe.Pointer(pFd)).FiCookie), + RBU_STATE_OALSZ, (*Sqlite3rbu)(unsafe.Pointer(p)).FiOalSz, + RBU_STATE_PHASEONESTEP, (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep, + RBU_STATE_DATATBL, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzDataTbl))) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pInsert */))) rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pInsert */))) } - if rc != 0 { + if rc != SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc } } @@ -161117,11 +158496,11 @@ func rbuCopyPragma(tls *libc.TLS, p uintptr, zPragma uintptr) { /* sqlite3.c:199 bp := tls.Alloc(32) defer tls.Free(32) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { *(*uintptr)(unsafe.Pointer(bp + 24 /* pPragma */)) = uintptr(0) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp+24 /* &pPragma */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+28729 /* "PRAGMA main.%s" */, libc.VaList(bp, zPragma))) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pPragma */)))) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pPragma */)))) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+28744, /* "PRAGMA main.%s =..." */ libc.VaList(bp+8, zPragma, Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pPragma */)), 0))) } @@ -161140,32 +158519,32 @@ func rbuCreateTargetSchema(tls *libc.TLS, p uintptr) { /* sqlite3.c:199428:13: * *(*uintptr)(unsafe.Pointer(bp + 8 /* pInsert */)) = uintptr(0) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+28764 /* "PRAGMA writable_..." */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp /* &pSql */, (p + 64 /* &.zErrmsg */), ts+28789 /* "SELECT sql FROM ..." */) } - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pSql */))) == 100) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pSql */))) == SQLITE_ROW) { var zSql uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pSql */)), 0) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, zSql, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp /* pSql */))) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK { return } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp /* &pSql */, (p + 64 /* &.zErrmsg */), ts+28897 /* "SELECT * FROM sq..." */) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8 /* &pInsert */, (p + 64 /* &.zErrmsg */), ts+28962 /* "INSERT INTO sqli..." */) } - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pSql */))) == 100) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pSql */))) == SQLITE_ROW) { var i int32 for i = 0; i < 5; i++ { Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pInsert */)), (i + 1), Xsqlite3_column_value(tls, *(*uintptr)(unsafe.Pointer(bp /* pSql */)), i)) @@ -161173,7 +158552,7 @@ func rbuCreateTargetSchema(tls *libc.TLS, p uintptr) { /* sqlite3.c:199428:13: * Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pInsert */))) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pInsert */))) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+29006 /* "PRAGMA writable_..." */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } @@ -161188,19 +158567,19 @@ func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199480:16: if p != 0 { switch (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage { - case 1: + case RBU_STAGE_OAL: { var pIter uintptr = (p + 80 /* &.objiter */) // If this is an RBU vacuum operation and the state table was empty // when this handle was opened, create the target database schema. - if (((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress == 0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) { + if (((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress == 0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) { rbuCreateTargetSchema(tls, p) rbuCopyPragma(tls, p, ts+14831 /* "user_version" */) rbuCopyPragma(tls, p, ts+13953 /* "application_id" */) } - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0) { if (*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 { // Clean up the rbu_tmp_xxx table for the previous table. It @@ -161214,9 +158593,9 @@ func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199480:16: rbuObjIterPrepareAll(tls, p, pIter, 0) // Advance to the next row to process. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var rc int32 = Xsqlite3_step(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect) - if rc == 100 { + if rc == SQLITE_ROW { (*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress++ (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep++ return rbuStep(tls, p) @@ -161229,26 +158608,26 @@ func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199480:16: rbuObjIterNext(tls, p, pIter) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { - rbuSaveState(tls, p, 2) + rbuSaveState(tls, p, RBU_STAGE_MOVE) rbuIncrSchemaCookie(tls, p) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+12351 /* "COMMIT" */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+12351 /* "COMMIT" */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 2 + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_MOVE } break } fallthrough - case 2: + case RBU_STAGE_MOVE: { - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { rbuMoveOalFile(tls, p) (*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress++ } @@ -161257,28 +158636,28 @@ func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199480:16: } fallthrough - case 4: + case RBU_STAGE_CKPT: { - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { if (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep >= (*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame { var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal // Sync the db file - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 40 /* &.xSync */))))(tls, pDb, 0x00002) + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 40 /* &.xSync */))))(tls, pDb, SQLITE_SYNC_NORMAL) // Update nBackfill - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { // var ptr uintptr at bp+16, 8 (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 104 /* &.xShmMap */))))(tls, pDb, 0, (32 * 1024), 0, bp+16 /* &ptr */) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - *(*U32)(unsafe.Pointer((libc.AtomicLoadPUintptr(bp + 16 /* ptr */)) + uintptr(24)*4)) = (*Sqlite3rbu)(unsafe.Pointer(p)).FiMaxFrame + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + *(*U32)(unsafe.Pointer((libc.AtomicLoadPUintptr(bp + 16 /* ptr */)) + 24*4)) = (*Sqlite3rbu)(unsafe.Pointer(p)).FiMaxFrame } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 5 - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 101 + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_DONE + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_DONE } } else { // At one point the following block copied a single frame from the @@ -161294,7 +158673,7 @@ func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199480:16: var iSector U32 for ok := true; ok; ok = ((((*Sqlite3rbu)(unsafe.Pointer(p)).FnStep < (*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame) && (iSector == (((*RbuFrame)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FaFrame+uintptr((*Sqlite3rbu)(unsafe.Pointer(p)).FnStep)*8)).FiDbPage - U32(1)) / U32((*Sqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector)))) && - ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0)) { + ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK)) { var pFrame uintptr = ((*Sqlite3rbu)(unsafe.Pointer(p)).FaFrame + uintptr((*Sqlite3rbu)(unsafe.Pointer(p)).FnStep)*8) iSector = (((*RbuFrame)(unsafe.Pointer(pFrame)).FiDbPage - U32(1)) / U32((*Sqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector)) rbuCheckpointFrame(tls, p, pFrame) @@ -161313,7 +158692,7 @@ func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199480:16: } return (*Sqlite3rbu)(unsafe.Pointer(p)).Frc } else { - return 7 + return SQLITE_NOMEM } return int32(0) } @@ -161343,21 +158722,21 @@ func rbuSetupOal(tls *libc.TLS, p uintptr, pState uintptr) { /* sqlite3.c:199625 if (*RbuState)(unsafe.Pointer(pState)).FzTbl != 0 { var pIter uintptr = (p + 80 /* &.objiter */) - var rc int32 = 0 + var rc int32 = SQLITE_OK - for ((rc == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0)) && (((((*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0) || + for ((rc == SQLITE_OK) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0)) && (((((*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0) || (rbuStrCompare(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx, (*RbuState)(unsafe.Pointer(pState)).FzIdx) != 0)) || (((*RbuState)(unsafe.Pointer(pState)).FzDataTbl == uintptr(0)) && (rbuStrCompare(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, (*RbuState)(unsafe.Pointer(pState)).FzTbl) != 0))) || (((*RbuState)(unsafe.Pointer(pState)).FzDataTbl != 0) && (rbuStrCompare(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, (*RbuState)(unsafe.Pointer(pState)).FzDataTbl) != 0))) { rc = rbuObjIterNext(tls, p, pIter) } - if (rc == 0) && !(int32((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl) != 0) { - rc = 1 + if (rc == SQLITE_OK) && !(int32((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl) != 0) { + rc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+29059 /* "rbu_state mismat..." */, 0) } - if rc == 0 { + if rc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep = (*RbuState)(unsafe.Pointer(pState)).FnRow rc = rbuObjIterPrepareAll(tls, p, (p + 80 /* &.objiter */), (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep) } @@ -161397,7 +158776,7 @@ func rbuCreateVfs(tls *libc.TLS, p uintptr) { /* sqlite3.c:199674:13: */ Xsqlite3_randomness(tls, int32(unsafe.Sizeof(int32(0))), bp+8 /* &rnd */) Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([64]int8{})), bp+12 /* &zRnd[0] */, ts+29084 /* "rbu_vfs_%d" */, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* rnd */)))) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3rbu_create_vfs(tls, bp+12 /* &zRnd[0] */, uintptr(0)) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var pVfs uintptr = Xsqlite3_vfs_find(tls, bp+12 /* &zRnd[0] */) (*Sqlite3rbu)(unsafe.Pointer(p)).FzVfsName = (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FzName @@ -161434,16 +158813,16 @@ func rbuIndexCntFunc(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) { / rc = prepareFreeAndCollectError(tls, db, bp+8 /* &pStmt */, bp+16, /* &zErrmsg */ Xsqlite3_mprintf(tls, - ts+29095 /* "SELECT count(*) ..." */, libc.VaList(bp, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8)))))) - if rc != 0 { + ts+29095 /* "SELECT count(*) ..." */, libc.VaList(bp, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal)))))) + if rc != SQLITE_OK { Xsqlite3_result_error(tls, pCtx, *(*uintptr)(unsafe.Pointer(bp + 16 /* zErrmsg */)), -1) } else { var nIndex int32 = 0 - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) { nIndex = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 0) } rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_result_int(tls, pCtx, nIndex) } else { Xsqlite3_result_error(tls, pCtx, Xsqlite3_errmsg(tls, db), -1) @@ -161470,36 +158849,36 @@ func rbuInitPhaseOneSteps(tls *libc.TLS, p uintptr) { /* sqlite3.c:199756:13: */ bp := tls.Alloc(8) defer tls.Free(8) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) var bExists int32 = 0 // True if rbu_count exists (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = int64(-1) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, - ts+29167 /* "rbu_index_cnt" */, 1, 1, p, *(*uintptr)(unsafe.Pointer(&struct { + ts+29167 /* "rbu_index_cnt" */, 1, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rbuIndexCntFunc})), uintptr(0), uintptr(0)) // Check for the rbu_count table. If it does not exist, or if an error // occurs, nPhaseOneStep will be left set to -1. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp /* &pStmt */, (p + 64 /* &.zErrmsg */), ts+29181 /* "SELECT 1 FROM sq..." */) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { bExists = 1 } (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) } - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (bExists != 0) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (bExists != 0) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp /* &pStmt */, (p + 64 /* &.zErrmsg */), ts+29238 /* "SELECT sum(cnt *..." */) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 0) } (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) @@ -161531,8 +158910,8 @@ func openRbuHandle(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) rbuCreateVfs(tls, p) // Open the target, RBU and state databases - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - var pCsr uintptr = (p + uintptr(1)*392) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var pCsr uintptr = (p + 1*392) *(*int32)(unsafe.Pointer(bp + 16 /* bRetry */)) = 0 if zTarget != 0 { (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget = pCsr @@ -161559,15 +158938,15 @@ func openRbuHandle(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { pState = rbuLoadState(tls, p) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { if (*RbuState)(unsafe.Pointer(pState)).FeStage == 0 { rbuDeleteOalFile(tls, p) rbuInitPhaseOneSteps(tls, p) - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 1 + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_OAL } else { (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = (*RbuState)(unsafe.Pointer(pState)).FeStage (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = (*RbuState)(unsafe.Pointer(pState)).FnPhaseOneStep @@ -161577,18 +158956,18 @@ func openRbuHandle(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) } } - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpWalFd != 0) { - if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1 { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpWalFd != 0) { + if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+29312 /* "cannot update wa..." */, 0) - } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 2 { - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 4 + } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_MOVE { + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_CKPT (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep = 0 } } - if (((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && - (((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1) || ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 2))) && + if (((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && + (((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL) || ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_MOVE))) && ((*RbuState)(unsafe.Pointer(pState)).FeStage != 0) { var pFd uintptr = func() uintptr { if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { @@ -161601,7 +158980,7 @@ func openRbuHandle(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) // change-counter cookie (the thing that gets incremented when a // transaction is committed in rollback mode) currently stored on // page 1 of the database file. - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 5 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_BUSY (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+29344, /* "database modifie..." */ libc.VaList(bp+8, func() uintptr { if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { @@ -161612,56 +158991,56 @@ func openRbuHandle(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL { var db uintptr = (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+12336 /* "BEGIN" */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) // Point the object iterator at the first object - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rbuObjIterFirst(tls, p, (p + 80 /* &.objiter */)) } // If the RBU database contains no data_xxx tables, declare the RBU // update finished. - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl == uintptr(0)) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 101 - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 5 + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl == uintptr(0)) { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_DONE + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_DONE } else { - if (((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*RbuState)(unsafe.Pointer(pState)).FeStage == 0)) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { + if (((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*RbuState)(unsafe.Pointer(pState)).FeStage == 0)) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { rbuCopyPragma(tls, p, ts+14556 /* "page_size" */) rbuCopyPragma(tls, p, ts+13968 /* "auto_vacuum" */) } // Open transactions both databases. The *-oal file is opened or // created at this point. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, ts+29390 /* "BEGIN IMMEDIATE" */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } // Check if the main database is a zipvfs db. If it is, set the upper // level pager to use "journal_mode=off". This prevents it from // generating a large journal using a temp file. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - var frc int32 = Xsqlite3_file_control(tls, db, ts+5282 /* "main" */, 25, uintptr(0)) - if frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var frc int32 = Xsqlite3_file_control(tls, db, ts+5282 /* "main" */, SQLITE_FCNTL_ZIPVFS, uintptr(0)) + if frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, ts+29406 /* "PRAGMA journal_m..." */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { rbuSetupOal(tls, p, pState) } } - } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 2 { + } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_MOVE { // no-op - } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 4 { + } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_CKPT { rbuSetupCheckpoint(tls, p, pState) - } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 5 { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 101 + } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_DONE { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_DONE } else { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 11 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT } } @@ -161678,7 +159057,7 @@ func rbuMisuseError(tls *libc.TLS) uintptr { /* sqlite3.c:199953:19: */ pRet = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(Sqlite3rbu{}))) if pRet != 0 { libc.Xmemset(tls, pRet, 0, uint64(unsafe.Sizeof(Sqlite3rbu{}))) - (*Sqlite3rbu)(unsafe.Pointer(pRet)).Frc = 21 + (*Sqlite3rbu)(unsafe.Pointer(pRet)).Frc = SQLITE_MISUSE } return pRet } @@ -161725,7 +159104,7 @@ func Xsqlite3rbu_db(tls *libc.TLS, pRbu uintptr, bRbu int32) uintptr { /* sqlite // then edit any error message string so as to remove all occurrences of // the pattern "rbu_imp_[0-9]*". func rbuEditErrmsg(tls *libc.TLS, p uintptr) { /* sqlite3.c:200011:13: */ - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 19) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg != 0) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_CONSTRAINT) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg != 0) { var i uint32 var nErrmsg Size_t = libc.Xstrlen(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg) for i = uint32(0); Size_t(i) < (nErrmsg - uint64(8)); i++ { @@ -161747,19 +159126,19 @@ func Xsqlite3rbu_close(tls *libc.TLS, p uintptr, pzErrmsg uintptr) int32 { /* sq if p != 0 { // Commit the transaction to the *-oal file. - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+12351 /* "COMMIT" */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } // Sync the db file if currently doing an incremental checkpoint - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 4) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_CKPT) { var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 40 /* &.xSync */))))(tls, pDb, 0x00002) + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 40 /* &.xSync */))))(tls, pDb, SQLITE_SYNC_NORMAL) } rbuSaveState(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+12351 /* "COMMIT" */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } @@ -161771,9 +159150,9 @@ func Xsqlite3rbu_close(tls *libc.TLS, p uintptr, pzErrmsg uintptr) int32 { /* sq // state table. This causes the next call to sqlite3rbu_vacuum() // specifying the current target and state databases to start a new // vacuum from scratch. - if (((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu != 0) { + if (((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu != 0) { var rc2 int32 = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+29438 /* "DELETE FROM stat..." */, uintptr(0), uintptr(0), uintptr(0)) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 101) && (rc2 != 0) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_DONE) && (rc2 != SQLITE_OK) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc2 } } @@ -161796,7 +159175,7 @@ func Xsqlite3rbu_close(tls *libc.TLS, p uintptr, pzErrmsg uintptr) int32 { /* sq Xsqlite3_free(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzState) Xsqlite3_free(tls, p) } else { - rc = 7 + rc = SQLITE_NOMEM *(*uintptr)(unsafe.Pointer(pzErrmsg)) = uintptr(0) } return rc @@ -161814,7 +159193,7 @@ func Xsqlite3rbu_progress(tls *libc.TLS, pRbu uintptr) Sqlite3_int64 { /* sqlite func Xsqlite3rbu_bp_progress(tls *libc.TLS, p uintptr, pnOne uintptr, pnTwo uintptr) { /* sqlite3.c:200100:17: */ var MAX_PROGRESS int32 = 10000 switch (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage { - case 1: + case RBU_STAGE_OAL: if (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep > int64(0) { *(*int32)(unsafe.Pointer(pnOne)) = (int32((I64(MAX_PROGRESS) * I64((*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress)) / (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep)) } else { @@ -161823,17 +159202,17 @@ func Xsqlite3rbu_bp_progress(tls *libc.TLS, p uintptr, pnOne uintptr, pnTwo uint *(*int32)(unsafe.Pointer(pnTwo)) = 0 break - case 2: + case RBU_STAGE_MOVE: *(*int32)(unsafe.Pointer(pnOne)) = MAX_PROGRESS *(*int32)(unsafe.Pointer(pnTwo)) = 0 break - case 4: + case RBU_STAGE_CKPT: *(*int32)(unsafe.Pointer(pnOne)) = MAX_PROGRESS *(*int32)(unsafe.Pointer(pnTwo)) = (int32((I64(MAX_PROGRESS) * I64((*Sqlite3rbu)(unsafe.Pointer(p)).FnStep)) / I64((*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame))) break - case 5: + case RBU_STAGE_DONE: *(*int32)(unsafe.Pointer(pnOne)) = MAX_PROGRESS *(*int32)(unsafe.Pointer(pnTwo)) = MAX_PROGRESS break @@ -161849,12 +159228,12 @@ func Xsqlite3rbu_state(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:200135:16: defer tls.Free(24) *(*[6]int32)(unsafe.Pointer(bp /* aRes */)) = [6]int32{ - 0, 1, 2, - 0, 3, 4, + 0, SQLITE_RBU_STATE_OAL, SQLITE_RBU_STATE_MOVE, + 0, SQLITE_RBU_STATE_CHECKPOINT, SQLITE_RBU_STATE_DONE, } - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 101) { - return 5 + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_DONE) { + return SQLITE_RBU_STATE_ERROR } else { return *(*int32)(unsafe.Pointer(bp /* &aRes[0] */ + uintptr((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage)*4)) @@ -161864,33 +159243,33 @@ func Xsqlite3rbu_state(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:200135:16: func Xsqlite3rbu_savestate(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:200163:16: */ var rc int32 = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc - if rc == 101 { - return 0 + if rc == SQLITE_DONE { + return SQLITE_OK } - if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL { - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+12351 /* "COMMIT" */, uintptr(0), uintptr(0), uintptr(0)) } } // Sync the db file - if (rc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 4) { + if (rc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_CKPT) { var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal - rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 40 /* &.xSync */))))(tls, pDb, 0x00002) + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 40 /* &.xSync */))))(tls, pDb, SQLITE_SYNC_NORMAL) } (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc rbuSaveState(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage) rc = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc - if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL { - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+12351 /* "COMMIT" */, uintptr(0), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { var zBegin uintptr if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { zBegin = ts + 12336 /* "BEGIN" */ @@ -161899,7 +159278,7 @@ func Xsqlite3rbu_savestate(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:200163 } rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, zBegin, uintptr(0), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+29390 /* "BEGIN IMMEDIATE" */, uintptr(0), uintptr(0), uintptr(0)) } } @@ -161972,9 +159351,9 @@ func rbuUnlockShm(tls *libc.TLS, p uintptr) { /* sqlite3.c:200256:13: */ if (*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 { var xShmLock uintptr = (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmLock var i int32 - for i = 0; i < 8; i++ { + for i = 0; i < SQLITE_SHM_NLOCK; i++ { if ((U32(int32(1) << i)) & (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FmLock) != 0 { - (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&xShmLock)))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, i, 1, (1 | 8)) + (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&xShmLock)))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, i, 1, (SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE)) } } (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FmLock = U32(0) @@ -161989,9 +159368,9 @@ func rbuUpdateTempSize(tls *libc.TLS, pFd uintptr, nNew Sqlite3_int64) int32 { / (*Rbu_file)(unsafe.Pointer(pFd)).Fsz = nNew if ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FszTemp > (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit) { - return 13 + return SQLITE_FULL } - return 0 + return SQLITE_OK } // Add an item to the main-db lists, if it is not already present. @@ -162075,11 +159454,11 @@ func rbuVfsClose(tls *libc.TLS, pFile uintptr) int32 { /* sqlite3.c:200348:12: * (*Rbu_file)(unsafe.Pointer(p)).FapShm = uintptr(0) Xsqlite3_free(tls, (*Rbu_file)(unsafe.Pointer(p)).FzDel) - if ((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000100) != 0 { + if ((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_MAIN_DB) != 0 { rbuMainlistRemove(tls, p) rbuUnlockShm(tls, p) (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 128 /* &.xShmUnmap */))))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, 0) - } else if (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000008) != 0) && ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0) { + } else if (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_DELETEONCLOSE) != 0) && ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0) { rbuUpdateTempSize(tls, p, int64(0)) } @@ -162091,24 +159470,24 @@ func rbuVfsClose(tls *libc.TLS, pFile uintptr) int32 { /* sqlite3.c:200348:12: * // Read and return an unsigned 32-bit big-endian integer from the buffer // passed as the only argument. func rbuGetU32(tls *libc.TLS, aBuf uintptr) U32 { /* sqlite3.c:200381:12: */ - return ((((U32(*(*U8)(unsafe.Pointer(aBuf + uintptr(0)))) << 24) + - (U32(*(*U8)(unsafe.Pointer(aBuf + uintptr(1)))) << 16)) + - (U32(*(*U8)(unsafe.Pointer(aBuf + uintptr(2)))) << 8)) + - (U32(*(*U8)(unsafe.Pointer(aBuf + uintptr(3)))))) + return ((((U32(*(*U8)(unsafe.Pointer(aBuf))) << 24) + + (U32(*(*U8)(unsafe.Pointer(aBuf + 1))) << 16)) + + (U32(*(*U8)(unsafe.Pointer(aBuf + 2))) << 8)) + + (U32(*(*U8)(unsafe.Pointer(aBuf + 3))))) } // Write an unsigned 32-bit value in big-endian format to the supplied // buffer. func rbuPutU32(tls *libc.TLS, aBuf uintptr, iVal U32) { /* sqlite3.c:200392:13: */ - *(*U8)(unsafe.Pointer(aBuf + uintptr(0))) = (U8((iVal >> 24) & U32(0xFF))) - *(*U8)(unsafe.Pointer(aBuf + uintptr(1))) = (U8((iVal >> 16) & U32(0xFF))) - *(*U8)(unsafe.Pointer(aBuf + uintptr(2))) = (U8((iVal >> 8) & U32(0xFF))) - *(*U8)(unsafe.Pointer(aBuf + uintptr(3))) = (U8((iVal >> 0) & U32(0xFF))) + *(*U8)(unsafe.Pointer(aBuf)) = (U8((iVal >> 24) & U32(0xFF))) + *(*U8)(unsafe.Pointer(aBuf + 1)) = (U8((iVal >> 16) & U32(0xFF))) + *(*U8)(unsafe.Pointer(aBuf + 2)) = (U8((iVal >> 8) & U32(0xFF))) + *(*U8)(unsafe.Pointer(aBuf + 3)) = (U8((iVal >> 0) & U32(0xFF))) } func rbuPutU16(tls *libc.TLS, aBuf uintptr, iVal U16) { /* sqlite3.c:200399:13: */ - *(*U8)(unsafe.Pointer(aBuf + uintptr(0))) = (U8((int32(iVal) >> 8) & 0xFF)) - *(*U8)(unsafe.Pointer(aBuf + uintptr(1))) = (U8((int32(iVal) >> 0) & 0xFF)) + *(*U8)(unsafe.Pointer(aBuf)) = (U8((int32(iVal) >> 8) & 0xFF)) + *(*U8)(unsafe.Pointer(aBuf + 1)) = (U8((int32(iVal) >> 0) & 0xFF)) } // Read data from an rbuVfs-file. @@ -162117,14 +159496,14 @@ func rbuVfsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Sq var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbu var rc int32 - if (pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 3) { + if (pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_CAPTURE) { rc = rbuCaptureWalRead(tls, (*Rbu_file)(unsafe.Pointer(p)).FpRbu, iOfst, iAmt) } else { - if (((pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 1)) && - (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00080000) != 0)) && + if (((pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_OAL)) && + (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_WAL) != 0)) && (iOfst >= (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz) { - rc = 0 + rc = SQLITE_OK libc.Xmemset(tls, zBuf, 0, uint64(iAmt)) } else { rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 16 /* &.xRead */))))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) @@ -162133,39 +159512,39 @@ func rbuVfsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Sq // contents of the first page if it does not yet exist. Otherwise, // SQLite will not check for a *-wal file. if (((((pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer((pRbu))).FzTarget == uintptr(0))) && - (rc == (10 | (int32(2) << 8)))) && (iOfst == int64(0))) && - (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000100) != 0)) && - ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).Frc == 0) { + (rc == (SQLITE_IOERR | (int32(2) << 8)))) && (iOfst == int64(0))) && + (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_MAIN_DB) != 0)) && + ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).Frc == SQLITE_OK) { var pFd uintptr = (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRbuFd rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pFd)).FpMethods + 16 /* &.xRead */))))(tls, pFd, zBuf, iAmt, iOfst) - if rc == 0 { + if rc == SQLITE_OK { var aBuf uintptr = zBuf var iRoot U32 - if rbuGetU32(tls, (aBuf+uintptr(52))) != 0 { + if rbuGetU32(tls, (aBuf+52)) != 0 { iRoot = uint32(1) } else { iRoot = uint32(0) } - rbuPutU32(tls, (aBuf + uintptr(52)), iRoot) // largest root page number - rbuPutU32(tls, (aBuf + uintptr(36)), uint32(0)) // number of free pages - rbuPutU32(tls, (aBuf + uintptr(32)), uint32(0)) // first page on free list trunk - rbuPutU32(tls, (aBuf + uintptr(28)), uint32(1)) // size of db file in pages - rbuPutU32(tls, (aBuf + uintptr(24)), ((*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRbuFd)).FiCookie + U32(1))) // Change counter + rbuPutU32(tls, (aBuf + 52), iRoot) // largest root page number + rbuPutU32(tls, (aBuf + 36), uint32(0)) // number of free pages + rbuPutU32(tls, (aBuf + 32), uint32(0)) // first page on free list trunk + rbuPutU32(tls, (aBuf + 28), uint32(1)) // size of db file in pages + rbuPutU32(tls, (aBuf + 24), ((*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRbuFd)).FiCookie + U32(1))) // Change counter if iAmt > 100 { - libc.Xmemset(tls, (aBuf + uintptr(100)), 0, (uint64(iAmt - 100))) - rbuPutU16(tls, (aBuf + uintptr(105)), (uint16(iAmt & 0xFFFF))) - *(*U8)(unsafe.Pointer(aBuf + uintptr(100))) = U8(0x0D) + libc.Xmemset(tls, (aBuf + 100), 0, (uint64(iAmt - 100))) + rbuPutU16(tls, (aBuf + 105), (uint16(iAmt & 0xFFFF))) + *(*U8)(unsafe.Pointer(aBuf + 100)) = U8(0x0D) } } } } - if ((rc == 0) && (iOfst == int64(0))) && (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000100) != 0) { + if ((rc == SQLITE_OK) && (iOfst == int64(0))) && (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_MAIN_DB) != 0) { // These look like magic numbers. But they are stable, as they are part // of the definition of the SQLite file format, which may not change. var pBuf uintptr = zBuf - (*Rbu_file)(unsafe.Pointer(p)).FiCookie = rbuGetU32(tls, (pBuf + uintptr(24))) - (*Rbu_file)(unsafe.Pointer(p)).FiWriteVer = *(*U8)(unsafe.Pointer(pBuf + uintptr(19))) + (*Rbu_file)(unsafe.Pointer(p)).FiCookie = rbuGetU32(tls, (pBuf + 24)) + (*Rbu_file)(unsafe.Pointer(p)).FiWriteVer = *(*U8)(unsafe.Pointer(pBuf + 19)) } } return rc @@ -162177,32 +159556,32 @@ func rbuVfsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst S var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbu var rc int32 - if (pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 3) { + if (pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_CAPTURE) { rc = rbuCaptureDbWrite(tls, (*Rbu_file)(unsafe.Pointer(p)).FpRbu, iOfst) } else { if pRbu != 0 { - if (((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 1) && - (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00080000) != 0)) && + if (((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_OAL) && + (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_WAL) != 0)) && (iOfst >= (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz) { (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz = (Sqlite_int64(iAmt) + iOfst) - } else if ((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000008) != 0 { + } else if ((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_DELETEONCLOSE) != 0 { var szNew I64 = (Sqlite_int64(iAmt) + iOfst) if szNew > (*Rbu_file)(unsafe.Pointer(p)).Fsz { rc = rbuUpdateTempSize(tls, p, szNew) - if rc != 0 { + if rc != SQLITE_OK { return rc } } } } rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 24 /* &.xWrite */))))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) - if ((rc == 0) && (iOfst == int64(0))) && (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000100) != 0) { + if ((rc == SQLITE_OK) && (iOfst == int64(0))) && (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_MAIN_DB) != 0) { // These look like magic numbers. But they are stable, as they are part // of the definition of the SQLite file format, which may not change. var pBuf uintptr = zBuf - (*Rbu_file)(unsafe.Pointer(p)).FiCookie = rbuGetU32(tls, (pBuf + uintptr(24))) - (*Rbu_file)(unsafe.Pointer(p)).FiWriteVer = *(*U8)(unsafe.Pointer(pBuf + uintptr(19))) + (*Rbu_file)(unsafe.Pointer(p)).FiCookie = rbuGetU32(tls, (pBuf + 24)) + (*Rbu_file)(unsafe.Pointer(p)).FiWriteVer = *(*U8)(unsafe.Pointer(pBuf + 19)) } } return rc @@ -162211,9 +159590,9 @@ func rbuVfsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst S // Truncate an rbuVfs-file. func rbuVfsTruncate(tls *libc.TLS, pFile uintptr, size Sqlite_int64) int32 { /* sqlite3.c:200516:12: */ var p uintptr = pFile - if (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000008) != 0) && ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0) { + if (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_DELETEONCLOSE) != 0) && ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0) { var rc int32 = rbuUpdateTempSize(tls, p, size) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -162223,11 +159602,11 @@ func rbuVfsTruncate(tls *libc.TLS, pFile uintptr, size Sqlite_int64) int32 { /* // Sync an rbuVfs-file. func rbuVfsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* sqlite3.c:200528:12: */ var p uintptr = pFile - if ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage == 3) { - if ((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000100) != 0 { - return 2 + if ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage == RBU_STAGE_CAPTURE) { + if ((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_MAIN_DB) != 0 { + return SQLITE_INTERNAL } - return 0 + return SQLITE_OK } return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 40 /* &.xSync */))))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, flags) } @@ -162242,9 +159621,9 @@ func rbuVfsFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* sqli // pretend that it has at least one page. Otherwise, SQLite will not // check for the existance of a *-wal file. rbuVfsRead() contains // similar logic. - if ((((rc == 0) && (*(*Sqlite_int64)(unsafe.Pointer(pSize)) == int64(0))) && + if ((((rc == SQLITE_OK) && (*(*Sqlite_int64)(unsafe.Pointer(pSize)) == int64(0))) && ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0)) && ((*Sqlite3rbu)(unsafe.Pointer(((*Rbu_file)(unsafe.Pointer(p)).FpRbu))).FzTarget == uintptr(0))) && - (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000100) != 0) { + (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_MAIN_DB) != 0) { *(*Sqlite_int64)(unsafe.Pointer(pSize)) = int64(1024) } return rc @@ -162254,13 +159633,13 @@ func rbuVfsFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* sqli func rbuVfsLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* sqlite3.c:200563:12: */ var p uintptr = pFile var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbu - var rc int32 = 0 + var rc int32 = SQLITE_OK - if (eLock == 4) && - (((*Rbu_file)(unsafe.Pointer(p)).FbNolock != 0) || ((pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage != 5))) { + if (eLock == SQLITE_LOCK_EXCLUSIVE) && + (((*Rbu_file)(unsafe.Pointer(p)).FbNolock != 0) || ((pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage != RBU_STAGE_DONE))) { // Do not allow EXCLUSIVE locks. Preventing SQLite from taking this // prevents it from checkpointing the database from sqlite3_close(). - rc = 5 + rc = SQLITE_BUSY } else { rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 56 /* &.xLock */))))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, eLock) } @@ -162289,7 +159668,7 @@ func rbuVfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int var xControl uintptr = (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxFileControl var rc int32 - if op == 26 { + if op == SQLITE_FCNTL_RBU { var pRbu uintptr = pArg // First try to find another RBU vfs lower down in the vfs stack. If @@ -162297,26 +159676,26 @@ func rbuVfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int // level vfs will do the special RBU handling. rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&xControl)))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, op, pArg) - if rc == 12 { + if rc == SQLITE_NOTFOUND { // Now search for a zipvfs instance lower down in the VFS stack. If // one is found, this is an error. *(*uintptr)(unsafe.Pointer(bp + 16 /* dummy */)) = uintptr(0) - rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&xControl)))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, 25, bp+16 /* &dummy */) - if rc == 0 { - rc = 1 + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&xControl)))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, SQLITE_FCNTL_ZIPVFS, bp+16 /* &dummy */) + if rc == SQLITE_OK { + rc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FzErrmsg = Xsqlite3_mprintf(tls, ts+29465 /* "rbu/zipvfs setup..." */, 0) - } else if rc == 12 { + } else if rc == SQLITE_NOTFOUND { (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpTargetFd = p (*Rbu_file)(unsafe.Pointer(p)).FpRbu = pRbu rbuMainlistAdd(tls, p) if (*Rbu_file)(unsafe.Pointer(p)).FpWalFd != 0 { (*Rbu_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpWalFd)).FpRbu = pRbu } - rc = 0 + rc = SQLITE_OK } } return rc - } else if op == 5149216 { + } else if op == SQLITE_FCNTL_RBUCNT { var pRbu uintptr = pArg (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnRbu++ (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRbuFd = p @@ -162324,13 +159703,13 @@ func rbuVfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int } rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&xControl)))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, op, pArg) - if (rc == 0) && (op == 12) { + if (rc == SQLITE_OK) && (op == SQLITE_FCNTL_VFSNAME) { var pRbuVfs uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbuVfs var zIn uintptr = *(*uintptr)(unsafe.Pointer(pArg)) var zOut uintptr = Xsqlite3_mprintf(tls, ts+29488 /* "rbu(%s)/%z" */, libc.VaList(bp, (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).Fbase.FzName, zIn)) *(*uintptr)(unsafe.Pointer(pArg)) = zOut if zOut == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } } @@ -162353,25 +159732,25 @@ func rbuVfsDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* sqlite func rbuVfsShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int32) int32 { /* sqlite3.c:200673:12: */ var p uintptr = pFile var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbu - var rc int32 = 0 + var rc int32 = SQLITE_OK - if (pRbu != 0) && (((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 1) || ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 2)) { + if (pRbu != 0) && (((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_OAL) || ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_MOVE)) { // Magic number 1 is the WAL_CKPT_LOCK lock. Preventing SQLite from // taking this lock also prevents any checkpoints from occurring. // todo: really, it's not clear why this might occur, as // wal_autocheckpoint ought to be turned off. - if (ofst == 1) && (n == 1) { - rc = 5 + if (ofst == WAL_LOCK_CKPT) && (n == 1) { + rc = SQLITE_BUSY } } else { var bCapture int32 = 0 - if (pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 3) { + if (pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_CAPTURE) { bCapture = 1 } - if (bCapture == 0) || (0 == (flags & 1)) { + if (bCapture == 0) || (0 == (flags & SQLITE_SHM_UNLOCK)) { rc = (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 112 /* &.xShmLock */))))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, ofst, n, flags) - if (bCapture != 0) && (rc == 0) { + if (bCapture != 0) && (rc == SQLITE_OK) { *(*U32)(unsafe.Pointer(pRbu + 316 /* &.mLock */)) |= (U32(int32(1) << ofst)) } } @@ -162383,7 +159762,7 @@ func rbuVfsShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int3 // Obtain a pointer to a mapping of a single 32KiB page of the *-shm file. func rbuVfsShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, szRegion int32, isWrite int32, pp uintptr) int32 { /* sqlite3.c:200709:12: */ var p uintptr = pFile - var rc int32 = 0 + var rc int32 = SQLITE_OK var eStage int32 = func() int32 { if (*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 { return (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage @@ -162395,7 +159774,7 @@ func rbuVfsShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, szRegion int32, i // rbu is in the RBU_STAGE_OAL state, use heap memory for *-shm space // instead of a file on disk. - if eStage == 1 { + if eStage == RBU_STAGE_OAL { var nByte Sqlite3_int64 = (Sqlite3_int64((uint64(iRegion + 1)) * uint64(unsafe.Sizeof(uintptr(0))))) var apNew uintptr = Xsqlite3_realloc64(tls, (*Rbu_file)(unsafe.Pointer(p)).FapShm, uint64(nByte)) @@ -162405,24 +159784,24 @@ func rbuVfsShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, szRegion int32, i // from start to finish. if apNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, (apNew + uintptr((*Rbu_file)(unsafe.Pointer(p)).FnShm)*8), 0, (uint64(unsafe.Sizeof(uintptr(0))) * (uint64((1 + iRegion) - (*Rbu_file)(unsafe.Pointer(p)).FnShm)))) (*Rbu_file)(unsafe.Pointer(p)).FapShm = apNew (*Rbu_file)(unsafe.Pointer(p)).FnShm = (iRegion + 1) } - if rc == 0 { + if rc == SQLITE_OK { var pNew uintptr = Xsqlite3_malloc64(tls, uint64(szRegion)) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, pNew, 0, uint64(szRegion)) *(*uintptr)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FapShm + uintptr(iRegion)*8)) = pNew } } - if rc == 0 { + if rc == SQLITE_OK { *(*uintptr)(unsafe.Pointer(libc.AtomicLoadUintptr(&pp))) = *(*uintptr)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FapShm + uintptr(iRegion)*8)) } else { *(*uintptr)(unsafe.Pointer(libc.AtomicLoadUintptr(&pp))) = uintptr(0) @@ -162444,7 +159823,7 @@ func rbuVfsShmBarrier(tls *libc.TLS, pFile uintptr) { /* sqlite3.c:200767:13: */ // The xShmUnmap method. func rbuVfsShmUnmap(tls *libc.TLS, pFile uintptr, delFlag int32) int32 { /* sqlite3.c:200775:12: */ var p uintptr = pFile - var rc int32 = 0 + var rc int32 = SQLITE_OK var eStage int32 = func() int32 { if (*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 { return (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage @@ -162452,7 +159831,7 @@ func rbuVfsShmUnmap(tls *libc.TLS, pFile uintptr, delFlag int32) int32 { /* sqli return 0 }() - if (eStage == 1) || (eStage == 2) { + if (eStage == RBU_STAGE_OAL) || (eStage == RBU_STAGE_MOVE) { // no-op } else { // Release the checkpointer and writer locks @@ -162467,26 +159846,26 @@ func rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags var pRbuVfs uintptr = pVfs var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRealVfs var pFd uintptr = pFile - var rc int32 = 0 + var rc int32 = SQLITE_OK var zOpen uintptr = zName var oflags int32 = flags libc.Xmemset(tls, pFd, 0, uint64(unsafe.Sizeof(Rbu_file{}))) - (*Rbu_file)(unsafe.Pointer(pFd)).FpReal = (pFd + uintptr(1)*104) + (*Rbu_file)(unsafe.Pointer(pFd)).FpReal = (pFd + 1*104) (*Rbu_file)(unsafe.Pointer(pFd)).FpRbuVfs = pRbuVfs (*Rbu_file)(unsafe.Pointer(pFd)).FopenFlags = flags if zName != 0 { - if (flags & 0x00000100) != 0 { + if (flags & SQLITE_OPEN_MAIN_DB) != 0 { // A main database has just been opened. The following block sets // (pFd->zWal) to point to a buffer owned by SQLite that contains // the name of the *-wal file this db connection will use. SQLite // happens to pass a pointer to this buffer when using xAccess() // or xOpen() to operate on the *-wal file. (*Rbu_file)(unsafe.Pointer(pFd)).FzWal = Xsqlite3_filename_wal(tls, zName) - } else if (flags & 0x00080000) != 0 { + } else if (flags & SQLITE_OPEN_WAL) != 0 { var pDb uintptr = rbuFindMaindb(tls, pRbuVfs, zName, 0) if pDb != 0 { - if ((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == 1) { + if ((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == RBU_STAGE_OAL) { // This call is to open a *-wal file. Intead, open the *-oal. This // code ensures that the string passed to xOpen() is terminated by a // pair of '\0' bytes in case the VFS attempts to extract a URI @@ -162507,7 +159886,7 @@ func rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags *(*int8)(unsafe.Pointer(zCopy + uintptr((nCopy + uint64(1))))) = int8(0) zOpen = libc.AssignPtrUintptr(pFd+64 /* &.zDel */, zCopy) } else { - rc = 7 + rc = SQLITE_NOMEM } (*Rbu_file)(unsafe.Pointer(pFd)).FpRbu = (*Rbu_file)(unsafe.Pointer(pDb)).FpRbu } @@ -162518,14 +159897,14 @@ func rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags (*Rbu_file)(unsafe.Pointer(pFd)).FpRbu = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRbu } - if ((oflags & 0x00000100) != 0) && + if ((oflags & SQLITE_OPEN_MAIN_DB) != 0) && (Xsqlite3_uri_boolean(tls, zName, ts+29499 /* "rbu_memory" */, 0) != 0) { - oflags = ((((0x00000200 | 0x00000002) | 0x00000004) | 0x00000010) | 0x00000008) + oflags = ((((SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_READWRITE) | SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_DELETEONCLOSE) zOpen = uintptr(0) } - if rc == 0 { + if rc == SQLITE_OK { rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pRealVfs + 40 /* &.xOpen */))))(tls, pRealVfs, zOpen, (*Rbu_file)(unsafe.Pointer(pFd)).FpReal, oflags, pOutFlags) } if (*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pFd)).FpReal)).FpMethods != 0 { @@ -162533,7 +159912,7 @@ func rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags // pointer and, if the file is a main database file, link it into the // mutex protected linked list of all such files. (*Sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&rbuvfs_io_methods)) - if (flags & 0x00000100) != 0 { + if (flags & SQLITE_OPEN_MAIN_DB) != 0 { rbuMainlistAdd(tls, pFd) } } else { @@ -162544,42 +159923,23 @@ func rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags } var rbuvfs_io_methods = Sqlite3_io_methods{ - FiVersion: 2, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - 0, - FxUnlock:// xLock - 0, - FxCheckReservedLock:// xUnlock - 0, - FxFileControl:// xCheckReservedLock - 0, - FxSectorSize:// xFileControl - 0, - FxDeviceCharacteristics:// xSectorSize - 0, - FxShmMap:// xDeviceCharacteristics - 0, - FxShmLock:// xShmMap - 0, - FxShmBarrier:// xShmLock - 0, - FxShmUnmap:// xShmBarrier - 0, - FxFetch:// xShmUnmap - uintptr(0), - FxUnfetch: uintptr(0), // xFetch, xUnfetch + FiVersion: 2, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xFileSize + FxLock: 0, // xLock + FxUnlock: 0, // xUnlock + FxCheckReservedLock: 0, // xCheckReservedLock + FxFileControl: 0, // xFileControl + FxSectorSize: 0, // xSectorSize + FxDeviceCharacteristics: 0, // xDeviceCharacteristics + FxShmMap: 0, // xShmMap + FxShmLock: 0, // xShmLock + FxShmBarrier: 0, // xShmBarrier + FxShmUnmap: 0, // xFetch, xUnfetch } /* sqlite3.c:200801:29 */ // Delete the file located at zPath. @@ -162613,12 +159973,12 @@ func rbuVfsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResO // causing SQLite to call xOpen() to open it. This call will also // be intercepted (see the rbuVfsOpen() function) and the *-oal // file opened instead. - if (rc == 0) && (flags == 0) { + if (rc == SQLITE_OK) && (flags == SQLITE_ACCESS_EXISTS) { var pDb uintptr = rbuFindMaindb(tls, pRbuVfs, zPath, 1) - if (pDb != 0) && ((*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == 1) { + if (pDb != 0) && ((*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == RBU_STAGE_OAL) { if *(*int32)(unsafe.Pointer(pResOut)) != 0 { - rc = 14 + rc = SQLITE_CANTOPEN } else { *(*Sqlite3_int64)(unsafe.Pointer(bp /* sz */)) = int64(0) rc = rbuVfsFileSize(tls, (pDb /* &.base */), bp /* &sz */) @@ -162708,7 +160068,7 @@ func Xsqlite3rbu_destroy_vfs(tls *libc.TLS, zName uintptr) { /* sqlite3.c:201050 func Xsqlite3rbu_create_vfs(tls *libc.TLS, zName uintptr, zParent uintptr) int32 { /* sqlite3.c:201064:16: */ var pNew uintptr = uintptr(0) // Newly allocated VFS - var rc int32 = 0 + var rc int32 = SQLITE_OK var nName Size_t var nByte Size_t @@ -162716,32 +160076,32 @@ func Xsqlite3rbu_create_vfs(tls *libc.TLS, zName uintptr, zParent uintptr) int32 nByte = ((uint64(unsafe.Sizeof(Rbu_vfs{})) + nName) + uint64(1)) pNew = Xsqlite3_malloc64(tls, uint64(nByte)) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var pParent uintptr // Parent VFS libc.Xmemset(tls, pNew, 0, nByte) pParent = Xsqlite3_vfs_find(tls, zParent) if pParent == uintptr(0) { - rc = 12 + rc = SQLITE_NOTFOUND } else { var zSpace uintptr libc.Xmemcpy(tls, (pNew /* &.base */), uintptr(unsafe.Pointer(&vfs_template)), uint64(unsafe.Sizeof(Sqlite3_vfs{}))) (*Rbu_vfs)(unsafe.Pointer(pNew)).Fbase.FmxPathname = (*Sqlite3_vfs)(unsafe.Pointer(pParent)).FmxPathname (*Rbu_vfs)(unsafe.Pointer(pNew)).Fbase.FszOsFile = (int32(uint64(unsafe.Sizeof(Rbu_file{})) + uint64((*Sqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile))) (*Rbu_vfs)(unsafe.Pointer(pNew)).FpRealVfs = pParent - (*Rbu_vfs)(unsafe.Pointer(pNew)).Fbase.FzName = libc.AssignUintptr(&zSpace, (pNew + uintptr(1)*208)) + (*Rbu_vfs)(unsafe.Pointer(pNew)).Fbase.FzName = libc.AssignUintptr(&zSpace, (pNew + 1*208)) libc.Xmemcpy(tls, zSpace, zName, nName) // Allocate the mutex and register the new VFS (not as the default) - (*Rbu_vfs)(unsafe.Pointer(pNew)).Fmutex = Xsqlite3_mutex_alloc(tls, 1) + (*Rbu_vfs)(unsafe.Pointer(pNew)).Fmutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_RECURSIVE) if (*Rbu_vfs)(unsafe.Pointer(pNew)).Fmutex == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_vfs_register(tls, (pNew /* &.base */), 0) } } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_mutex_free(tls, (*Rbu_vfs)(unsafe.Pointer(pNew)).Fmutex) Xsqlite3_free(tls, pNew) } @@ -162751,49 +160111,21 @@ func Xsqlite3rbu_create_vfs(tls *libc.TLS, zName uintptr, zParent uintptr) int32 } var vfs_template = Sqlite3_vfs{ - FiVersion: 1, - FszOsFile:// iVersion - 0, - FmxPathname:// szOsFile - 0, - FpNext:// mxPathname - uintptr(0), - FzName:// pNext - uintptr(0), - FpAppData:// zName - uintptr(0), - FxOpen:// pAppData - 0, - FxDelete:// xOpen - 0, - FxAccess:// xDelete - 0, - FxFullPathname:// xAccess - 0, - FxDlOpen:// xFullPathname + FiVersion: 1, // pAppData + FxOpen: 0, // xOpen + FxDelete: 0, // xDelete + FxAccess: 0, // xAccess + FxFullPathname: 0, // xFullPathname - 0, - FxDlError:// xDlOpen - 0, - FxDlSym:// xDlError - 0, - FxDlClose:// xDlSym - 0, - FxRandomness:// xDlClose + FxDlOpen: 0, // xDlOpen + FxDlError: 0, // xDlError + FxDlSym: 0, // xDlSym + FxDlClose: 0, // xDlClose - 0, - FxSleep:// xRandomness - 0, - FxCurrentTime:// xSleep - 0, - FxGetLastError:// xCurrentTime - 0, - FxCurrentTimeInt64:// xGetLastError - uintptr(0), - FxSetSystemCall:// xCurrentTimeInt64 (version 2) - uintptr(0), - FxGetSystemCall: uintptr(0), - FxNextSystemCall: uintptr(0), // Unimplemented version 3 methods + FxRandomness: 0, // xRandomness + FxSleep: 0, // xSleep + FxCurrentTime: 0, // xCurrentTime + FxGetLastError: 0, // Unimplemented version 3 methods } /* sqlite3.c:201067:22 */ // Configure the aggregate temp file size limit for this RBU handle. @@ -163658,9 +160990,9 @@ func sqlite3Fts5ParserInit(tls *libc.TLS, fts5yypRawParser uintptr) { /* sqlite3 var fts5yypParser uintptr = fts5yypRawParser (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos = fts5yypParser + 16 /* &.fts5yystack */ - (*Fts5yyStackEntry)(unsafe.Pointer((fts5yypParser + 16 /* &.fts5yystack */) + uintptr(0)*24)).Fstateno = uint8(0) - (*Fts5yyStackEntry)(unsafe.Pointer((fts5yypParser + 16 /* &.fts5yystack */) + uintptr(0)*24)).Fmajor = uint8(0) - (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystackEnd = ((fts5yypParser + 16 /* &.fts5yystack */) + uintptr((100-1))*24) + (*Fts5yyStackEntry)(unsafe.Pointer((fts5yypParser + 16 /* &.fts5yystack */))).Fstateno = uint8(0) + (*Fts5yyStackEntry)(unsafe.Pointer((fts5yypParser + 16 /* &.fts5yystack */))).Fmajor = uint8(0) + (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystackEnd = ((fts5yypParser + 16 /* &.fts5yystack */) + 99*24) } // This function allocates a new parser. @@ -163795,7 +161127,7 @@ func sqlite3Fts5ParserFree(tls *libc.TLS, p uintptr, freeProc uintptr) { /* sqli func fts5yy_find_shift_action(tls *libc.TLS, iLookAhead uint8, stateno uint8) uint8 { /* sqlite3.c:210050:25: */ var i int32 - if int32(stateno) > 34 { + if int32(stateno) > Fts5YY_MAX_SHIFT { return stateno } @@ -163854,8 +161186,8 @@ func fts5yy_shift(tls *libc.TLS, fts5yypParser uintptr, fts5yyNewState uint8, ft fts5yyStackOverflow(tls, fts5yypParser) return } - if int32(fts5yyNewState) > 34 { - fts5yyNewState = uint8(int32(fts5yyNewState) + (83 - 52)) + if int32(fts5yyNewState) > Fts5YY_MAX_SHIFT { + fts5yyNewState = uint8(int32(fts5yyNewState) + (Fts5YY_MIN_REDUCE - Fts5YY_MIN_SHIFTREDUCE)) } fts5yytos = (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos (*Fts5yyStackEntry)(unsafe.Pointer(fts5yytos)).Fstateno = fts5yyNewState @@ -163929,6 +161261,7 @@ var fts5yyRuleInfoNRhs = [28]int8{ int8(-1), // (26) star_opt ::= STAR int8(0), // (27) star_opt ::= } /* sqlite3.c:210261:26 */ + // Forward Declaration // Perform a reduce action and the shift that must immediately @@ -163978,7 +161311,7 @@ func fts5yy_reduce(tls *libc.TLS, fts5yypParser uintptr, fts5yyruleno uint32, ft case uint32(0): /* input ::= expr */ { - sqlite3Fts5ParseFinished(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + sqlite3Fts5ParseFinished(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } break case uint32(1): /* colset ::= MINUS LCP colsetlist RCP */ @@ -163993,43 +161326,43 @@ func fts5yy_reduce(tls *libc.TLS, fts5yypParser uintptr, fts5yyruleno uint32, ft break case uint32(3): /* colset ::= STRING */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), (fts5yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.fts5yy0 */)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), (fts5yymsp + 8 /* &.minor */ /* &.fts5yy0 */)) } - *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(4): /* colset ::= MINUS STRING */ { - *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), (fts5yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.fts5yy0 */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), (fts5yymsp + 8 /* &.minor */ /* &.fts5yy0 */)) *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = sqlite3Fts5ParseColsetInvert(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(5): /* colsetlist ::= colsetlist STRING */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseColset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (fts5yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.fts5yy0 */)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseColset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (fts5yymsp + 8 /* &.minor */ /* &.fts5yy0 */)) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(6): /* colsetlist ::= STRING */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), (fts5yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.fts5yy0 */)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), (fts5yymsp + 8 /* &.minor */ /* &.fts5yy0 */)) } - *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(7): /* expr ::= expr AND expr */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, 2, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_AND, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)), uintptr(0)) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(8): /* expr ::= expr OR expr */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, 1, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_OR, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)), uintptr(0)) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(9): /* expr ::= expr NOT expr */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, 3, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_NOT, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)), uintptr(0)) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break @@ -164049,39 +161382,39 @@ func fts5yy_reduce(tls *libc.TLS, fts5yypParser uintptr, fts5yyruleno uint32, ft fallthrough // expr ::= exprlist case uint32(13): /* exprlist ::= cnearset */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) } - *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(14): /* exprlist ::= exprlist cnearset */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseImplicitAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseImplicitAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(15): /* cnearset ::= nearset */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, 9, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_STRING, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } - *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(16): /* cnearset ::= colset COLON nearset */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, 9, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_STRING, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) sqlite3Fts5ParseSetColset(tls, pParse, *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(17): /* nearset ::= phrase */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } - *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(18): /* nearset ::= CARET phrase */ { - sqlite3Fts5ParseSetCaret(tls, *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) - *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + sqlite3Fts5ParseSetCaret(tls, *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } break case uint32(19): /* nearset ::= STRING LP nearphrases neardist_opt RP */ @@ -164094,47 +161427,47 @@ func fts5yy_reduce(tls *libc.TLS, fts5yypParser uintptr, fts5yyruleno uint32, ft break case uint32(20): /* nearphrases ::= phrase */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } - *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(21): /* nearphrases ::= nearphrases phrase */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNearset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNearset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(22): /* neardist_opt ::= */ { - (*Fts5Token)(unsafe.Pointer(fts5yymsp + uintptr(1)*24 + 8 /* &.minor */)).Fp = uintptr(0) - (*Fts5Token)(unsafe.Pointer(fts5yymsp + uintptr(1)*24 + 8 /* &.minor */)).Fn = 0 + (*Fts5Token)(unsafe.Pointer(fts5yymsp + 1*24 + 8 /* &.minor */)).Fp = uintptr(0) + (*Fts5Token)(unsafe.Pointer(fts5yymsp + 1*24 + 8 /* &.minor */)).Fn = 0 } break case uint32(23): /* neardist_opt ::= COMMA STRING */ { - *(*Fts5Token)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*Fts5Token)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*Fts5Token)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*Fts5Token)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) } break case uint32(24): /* phrase ::= phrase PLUS STRING star_opt */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), (fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.fts5yy0 */), *(*int32)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), (fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.fts5yy0 */), *(*int32)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(25): /* phrase ::= STRING star_opt */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseTerm(tls, pParse, uintptr(0), (fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.fts5yy0 */), *(*int32)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseTerm(tls, pParse, uintptr(0), (fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.fts5yy0 */), *(*int32)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(26): /* star_opt ::= STAR */ { - *(*int32)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 1 + *(*int32)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = 1 } break case uint32(27): /* star_opt ::= */ { - *(*int32)(unsafe.Pointer(fts5yymsp + uintptr(1)*24 + 8 /* &.minor */)) = 0 + *(*int32)(unsafe.Pointer(fts5yymsp + 1*24 + 8 /* &.minor */)) = 0 } break default: @@ -164224,13 +161557,13 @@ func sqlite3Fts5Parser(tls *libc.TLS, fts5yyp uintptr, fts5yymajor int32, fts5yy for ok := true; ok; ok = ((*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos > fts5yypParser+16 /* &.fts5yystack */) { fts5yyact = fts5yy_find_shift_action(tls, uint8(fts5yymajor), fts5yyact) - if int32(fts5yyact) >= 83 { - fts5yyact = fts5yy_reduce(tls, fts5yypParser, (uint32(int32(fts5yyact) - 83)), fts5yymajor, + if int32(fts5yyact) >= Fts5YY_MIN_REDUCE { + fts5yyact = fts5yy_reduce(tls, fts5yypParser, (uint32(int32(fts5yyact) - Fts5YY_MIN_REDUCE)), fts5yymajor, fts5yyminor) - } else if int32(fts5yyact) <= 79 { + } else if int32(fts5yyact) <= Fts5YY_MAX_SHIFTREDUCE { fts5yy_shift(tls, fts5yypParser, fts5yyact, uint8(fts5yymajor), fts5yyminor) break - } else if int32(fts5yyact) == 81 { + } else if int32(fts5yyact) == Fts5YY_ACCEPT_ACTION { (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos -= 24 fts5yy_accept(tls, fts5yypParser) return @@ -164375,11 +161708,11 @@ func fts5CInstIterNext(tls *libc.TLS, pIter uintptr) int32 { /* sqlite3.c:210870 bp := tls.Alloc(12) defer tls.Free(12) - var rc int32 = 0 + var rc int32 = SQLITE_OK (*CInstIter)(unsafe.Pointer(pIter)).FiStart = -1 (*CInstIter)(unsafe.Pointer(pIter)).FiEnd = -1 - for (rc == 0) && ((*CInstIter)(unsafe.Pointer(pIter)).FiInst < (*CInstIter)(unsafe.Pointer(pIter)).FnInst) { + for (rc == SQLITE_OK) && ((*CInstIter)(unsafe.Pointer(pIter)).FiInst < (*CInstIter)(unsafe.Pointer(pIter)).FnInst) { // var ip int32 at bp, 4 // var ic int32 at bp+4, 4 @@ -164387,7 +161720,7 @@ func fts5CInstIterNext(tls *libc.TLS, pIter uintptr) int32 { /* sqlite3.c:210870 // var io int32 at bp+8, 4 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(((*CInstIter)(unsafe.Pointer(pIter)).FpApi + 72 /* &.xInst */))))(tls, (*CInstIter)(unsafe.Pointer(pIter)).FpFts, (*CInstIter)(unsafe.Pointer(pIter)).FiInst, bp /* &ip */, bp+4 /* &ic */, bp+8 /* &io */) - if rc == 0 { + if rc == SQLITE_OK { if *(*int32)(unsafe.Pointer(bp + 4 /* ic */)) == (*CInstIter)(unsafe.Pointer(pIter)).FiCol { var iEnd int32 = ((*(*int32)(unsafe.Pointer(bp + 8 /* io */)) - 1) + (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*CInstIter)(unsafe.Pointer(pIter)).FpApi + 56 /* &.xPhraseSize */))))(tls, (*CInstIter)(unsafe.Pointer(pIter)).FpFts, *(*int32)(unsafe.Pointer(bp /* ip */)))) if (*CInstIter)(unsafe.Pointer(pIter)).FiStart < 0 { @@ -164419,7 +161752,7 @@ func fts5CInstIterInit(tls *libc.TLS, pApi uintptr, pFts uintptr, iCol int32, pI (*CInstIter)(unsafe.Pointer(pIter)).FiCol = iCol rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 64 /* &.xInstCount */))))(tls, pFts, (pIter + 24 /* &.nInst */)) - if rc == 0 { + if rc == SQLITE_OK { rc = fts5CInstIterNext(tls, pIter) } @@ -164459,13 +161792,13 @@ func fts5HighlightAppend(tls *libc.TLS, pRc uintptr, p uintptr, z uintptr, n int bp := tls.Alloc(24) defer tls.Free(24) - if (*(*int32)(unsafe.Pointer(pRc)) == 0) && (z != 0) { + if (*(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK) && (z != 0) { if n < 0 { n = int32(libc.Xstrlen(tls, z)) } (*HighlightContext)(unsafe.Pointer(p)).FzOut = Xsqlite3_mprintf(tls, ts+29569 /* "%z%.*s" */, libc.VaList(bp, (*HighlightContext)(unsafe.Pointer(p)).FzOut, n, z)) if (*HighlightContext)(unsafe.Pointer(p)).FzOut == uintptr(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } } @@ -164476,20 +161809,20 @@ func fts5HighlightCb(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintp defer tls.Free(4) var p uintptr = pContext - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var iPos int32 _ = pToken _ = nToken - if (tflags & 0x0001) != 0 { - return 0 + if (tflags & FTS5_TOKEN_COLOCATED) != 0 { + return SQLITE_OK } iPos = libc.PostIncInt32(&(*HighlightContext)(unsafe.Pointer(p)).FiPos, 1) if (*HighlightContext)(unsafe.Pointer(p)).FiRangeEnd > 0 { if (iPos < (*HighlightContext)(unsafe.Pointer(p)).FiRangeStart) || (iPos > (*HighlightContext)(unsafe.Pointer(p)).FiRangeEnd) { - return 0 + return SQLITE_OK } if ((*HighlightContext)(unsafe.Pointer(p)).FiRangeStart != 0) && (iPos == (*HighlightContext)(unsafe.Pointer(p)).FiRangeStart) { (*HighlightContext)(unsafe.Pointer(p)).FiOff = iStartOff @@ -164509,7 +161842,7 @@ func fts5HighlightCb(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintp fts5HighlightAppend(tls, bp /* &rc */, p, ((*HighlightContext)(unsafe.Pointer(p)).FzIn + uintptr((*HighlightContext)(unsafe.Pointer(p)).FiOff)), (iEndOff - (*HighlightContext)(unsafe.Pointer(p)).FiOff)) fts5HighlightAppend(tls, bp /* &rc */, p, (*HighlightContext)(unsafe.Pointer(p)).FzClose, -1) (*HighlightContext)(unsafe.Pointer(p)).FiOff = iEndOff - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = fts5CInstIterNext(tls, (p /* &.iter */)) } } @@ -164542,30 +161875,30 @@ func fts5HighlightFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintp return } - iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal))) libc.Xmemset(tls, bp /* &ctx */, 0, uint64(unsafe.Sizeof(HighlightContext{}))) - (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOpen = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzClose = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(2)*8))) + (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOpen = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzClose = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 2*8))) *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 88 /* &.xColumnText */))))(tls, pFts, iCol, (bp /* &ctx */ + 72 /* &.zIn */), (bp /* &ctx */ + 80 /* &.nIn */)) if (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzIn != 0 { - if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = fts5CInstIterInit(tls, pApi, pFts, iCol, (bp /* &ctx */ /* &.iter */)) } - if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 40 /* &.xTokenize */))))(tls, pFts, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzIn, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FnIn, bp /* &ctx */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5HighlightCb}))) } fts5HighlightAppend(tls, bp+96 /* &rc */, bp /* &ctx */, ((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzIn + uintptr((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FiOff)), ((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FnIn - (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FiOff)) - if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == SQLITE_OK { Xsqlite3_result_text(tls, pCtx, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOut, -1, libc.UintptrFromInt32(-1)) } Xsqlite3_free(tls, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOut) } - if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) != SQLITE_OK { Xsqlite3_result_error_code(tls, pCtx, *(*int32)(unsafe.Pointer(bp + 96 /* rc */))) } } @@ -164606,26 +161939,26 @@ func fts5SentenceFinderAdd(tls *libc.TLS, p uintptr, iAdd int32) int32 { /* sqli aNew = Xsqlite3_realloc64(tls, (*Fts5SFinder)(unsafe.Pointer(p)).FaFirst, (uint64(uint64(nNew) * uint64(unsafe.Sizeof(int32(0)))))) if aNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Fts5SFinder)(unsafe.Pointer(p)).FaFirst = aNew (*Fts5SFinder)(unsafe.Pointer(p)).FnFirstAlloc = nNew } *(*int32)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(p)).FaFirst + uintptr(libc.PostIncInt32(&(*Fts5SFinder)(unsafe.Pointer(p)).FnFirst, 1))*4)) = iAdd - return 0 + return SQLITE_OK } // This function is an xTokenize() callback used by the auxiliary snippet() // function. Its job is to identify tokens that are the first in a sentence. // For each such token, an entry is added to the SFinder.aFirst[] array. func fts5SentenceFinderCb(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iStartOff int32, iEndOff int32) int32 { /* sqlite3.c:211101:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pToken _ = nToken _ = iEndOff - if (tflags & 0x0001) == 0 { + if (tflags & FTS5_TOKEN_COLOCATED) == 0 { var p uintptr = pContext if (*Fts5SFinder)(unsafe.Pointer(p)).FiPos > 0 { var i int32 @@ -164664,9 +161997,9 @@ func fts5SnippetScore(tls *libc.TLS, pApi uintptr, pFts uintptr, nDocsize int32, var iEnd Sqlite3_int64 = (Sqlite3_int64(iPos) + Sqlite3_int64(nToken)) rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 64 /* &.xInstCount */))))(tls, pFts, bp /* &nInst */) - for i = 0; (i < *(*int32)(unsafe.Pointer(bp /* nInst */))) && (rc == 0); i++ { + for i = 0; (i < *(*int32)(unsafe.Pointer(bp /* nInst */))) && (rc == SQLITE_OK); i++ { rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 72 /* &.xInst */))))(tls, pFts, i, bp+4 /* &ip */, bp+8 /* &ic */, bp+12 /* &iOff */) - if (((rc == 0) && (*(*int32)(unsafe.Pointer(bp + 8 /* ic */)) == iCol)) && (*(*int32)(unsafe.Pointer(bp + 12 /* iOff */)) >= iPos)) && (Sqlite3_int64(*(*int32)(unsafe.Pointer(bp + 12 /* iOff */))) < iEnd) { + if (((rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 8 /* ic */)) == iCol)) && (*(*int32)(unsafe.Pointer(bp + 12 /* iOff */)) >= iPos)) && (Sqlite3_int64(*(*int32)(unsafe.Pointer(bp + 12 /* iOff */))) < iEnd) { nScore = nScore + (func() int32 { if *(*uint8)(unsafe.Pointer(aSeen + uintptr(*(*int32)(unsafe.Pointer(bp + 4 /* ip */))))) != 0 { return 1 @@ -164714,18 +162047,18 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr // var ctx HighlightContext at bp, 96 - *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = 0 // Return code - var iCol int32 // 1st argument to snippet() - var zEllips uintptr // 4th argument to snippet() - var nToken int32 // 5th argument to snippet() - *(*int32)(unsafe.Pointer(bp + 96 /* nInst */)) = 0 // Number of instance matches this row - var i int32 // Used to iterate through instances - var nPhrase int32 // Number of phrases in query - var aSeen uintptr // Array of "seen instance" flags - var iBestCol int32 // Column containing best snippet - var iBestStart int32 = 0 // First token of best snippet - var nBestScore int32 = 0 // Score of best snippet - *(*int32)(unsafe.Pointer(bp + 164 /* nColSize */)) = 0 // Total size of iBestCol in tokens + *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = SQLITE_OK // Return code + var iCol int32 // 1st argument to snippet() + var zEllips uintptr // 4th argument to snippet() + var nToken int32 // 5th argument to snippet() + *(*int32)(unsafe.Pointer(bp + 96 /* nInst */)) = 0 // Number of instance matches this row + var i int32 // Used to iterate through instances + var nPhrase int32 // Number of phrases in query + var aSeen uintptr // Array of "seen instance" flags + var iBestCol int32 // Column containing best snippet + var iBestStart int32 = 0 // First token of best snippet + var nBestScore int32 = 0 // Score of best snippet + *(*int32)(unsafe.Pointer(bp + 164 /* nColSize */)) = 0 // Total size of iBestCol in tokens // var sFinder Fts5SFinder at bp+104, 32 // Used to find the beginnings of sentences var nCol int32 @@ -164738,11 +162071,11 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr nCol = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((pApi + 16 /* &.xColumnCount */))))(tls, pFts) libc.Xmemset(tls, bp /* &ctx */, 0, uint64(unsafe.Sizeof(HighlightContext{}))) - iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) - (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOpen = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzClose = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(2)*8))) - zEllips = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(3)*8))) - nToken = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(4)*8))) + iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal))) + (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOpen = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzClose = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + 2*8))) + zEllips = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + 3*8))) + nToken = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + 4*8))) iBestCol = func() int32 { if iCol >= 0 { @@ -164753,9 +162086,9 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr nPhrase = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((pApi + 48 /* &.xPhraseCount */))))(tls, pFts) aSeen = Xsqlite3_malloc(tls, nPhrase) if aSeen == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = SQLITE_NOMEM } - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 64 /* &.xInstCount */))))(tls, pFts, bp+96 /* &nInst */) } @@ -164770,22 +162103,22 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr (*Fts5SFinder)(unsafe.Pointer(bp + 104 /* &sFinder */)).FiPos = 0 (*Fts5SFinder)(unsafe.Pointer(bp + 104 /* &sFinder */)).FnFirst = 0 *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 88 /* &.xColumnText */))))(tls, pFts, i, (bp + 104 /* &sFinder */ + 24 /* &.zDoc */), bp+136 /* &nDoc */) - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != SQLITE_OK { break } *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 40 /* &.xTokenize */))))(tls, pFts, (*Fts5SFinder)(unsafe.Pointer(bp+104 /* &sFinder */)).FzDoc, *(*int32)(unsafe.Pointer(bp + 136 /* nDoc */)), bp+104 /* &sFinder */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5SentenceFinderCb}))) - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != SQLITE_OK { break } *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pApi + 96 /* &.xColumnSize */))))(tls, pFts, i, bp+140 /* &nDocsize */) - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != SQLITE_OK { break } - for ii = 0; (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0) && (ii < *(*int32)(unsafe.Pointer(bp + 96 /* nInst */))); ii++ { + for ii = 0; (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK) && (ii < *(*int32)(unsafe.Pointer(bp + 96 /* nInst */))); ii++ { // var ip int32 at bp+144, 4 // var ic int32 at bp+148, 4 @@ -164803,22 +162136,22 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr continue } if *(*int32)(unsafe.Pointer(bp + 152 /* io */)) > *(*int32)(unsafe.Pointer(bp + 140 /* nDocsize */)) { - *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != SQLITE_OK { continue } libc.Xmemset(tls, aSeen, 0, uint64(nPhrase)) *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = fts5SnippetScore(tls, pApi, pFts, *(*int32)(unsafe.Pointer(bp + 140 /* nDocsize */)), aSeen, i, *(*int32)(unsafe.Pointer(bp + 152 /* io */)), nToken, bp+156 /* &nScore */, bp+160 /* &iAdj */) - if (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0) && (*(*int32)(unsafe.Pointer(bp + 156 /* nScore */)) > nBestScore) { + if (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 156 /* nScore */)) > nBestScore) { nBestScore = *(*int32)(unsafe.Pointer(bp + 156 /* nScore */)) iBestCol = i iBestStart = *(*int32)(unsafe.Pointer(bp + 160 /* iAdj */)) *(*int32)(unsafe.Pointer(bp + 164 /* nColSize */)) = *(*int32)(unsafe.Pointer(bp + 140 /* nDocsize */)) } - if ((*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0) && ((*Fts5SFinder)(unsafe.Pointer(bp+104 /* &sFinder */)).FnFirst != 0)) && (*(*int32)(unsafe.Pointer(bp + 140 /* nDocsize */)) > nToken) { + if ((*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK) && ((*Fts5SFinder)(unsafe.Pointer(bp+104 /* &sFinder */)).FnFirst != 0)) && (*(*int32)(unsafe.Pointer(bp + 140 /* nDocsize */)) > nToken) { for jj = 0; jj < ((*Fts5SFinder)(unsafe.Pointer(bp+104 /* &sFinder */)).FnFirst - 1); jj++ { if *(*int32)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(bp+104 /* &sFinder */)).FaFirst + uintptr((jj+1))*4)) > *(*int32)(unsafe.Pointer(bp + 152 /* io */)) { break @@ -164836,7 +162169,7 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr } return 100 }() - if (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0) && (*(*int32)(unsafe.Pointer(bp + 156 /* nScore */)) > nBestScore) { + if (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 156 /* nScore */)) > nBestScore) { nBestScore = *(*int32)(unsafe.Pointer(bp + 156 /* nScore */)) iBestCol = i iBestStart = *(*int32)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(bp+104 /* &sFinder */)).FaFirst + uintptr(jj)*4)) @@ -164848,14 +162181,14 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr } } - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 88 /* &.xColumnText */))))(tls, pFts, iBestCol, (bp /* &ctx */ + 72 /* &.zIn */), (bp /* &ctx */ + 80 /* &.nIn */)) } - if (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0) && (*(*int32)(unsafe.Pointer(bp + 164 /* nColSize */)) == 0) { + if (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 164 /* nColSize */)) == 0) { *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pApi + 96 /* &.xColumnSize */))))(tls, pFts, iBestCol, bp+164 /* &nColSize */) } if (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzIn != 0 { - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = fts5CInstIterInit(tls, pApi, pFts, iBestCol, (bp /* &ctx */ /* &.iter */)) } @@ -164868,11 +162201,11 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr // Advance iterator ctx.iter so that it points to the first coalesced // phrase instance at or following position iBestStart. - for (((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).Fiter.FiStart >= 0) && ((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).Fiter.FiStart < iBestStart)) && (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0) { + for (((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).Fiter.FiStart >= 0) && ((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).Fiter.FiStart < iBestStart)) && (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK) { *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = fts5CInstIterNext(tls, (bp /* &ctx */ /* &.iter */)) } - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 40 /* &.xTokenize */))))(tls, pFts, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzIn, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FnIn, bp /* &ctx */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5HighlightCb}))) @@ -164883,7 +162216,7 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr fts5HighlightAppend(tls, bp+168 /* &rc */, bp /* &ctx */, zEllips, -1) } } - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK { Xsqlite3_result_text(tls, pCtx, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOut, -1, libc.UintptrFromInt32(-1)) } else { Xsqlite3_result_error_code(tls, pCtx, *(*int32)(unsafe.Pointer(bp + 168 /* rc */))) @@ -164918,7 +162251,7 @@ func fts5CountCb(tls *libc.TLS, pApi uintptr, pFts uintptr, pUserData uintptr) i _ = pApi _ = pFts (*(*Sqlite3_int64)(unsafe.Pointer(pn)))++ - return 0 + return SQLITE_OK } // Set *ppData to point to the Fts5Bm25Data object for the current query. @@ -164928,8 +162261,8 @@ func fts5Bm25GetData(tls *libc.TLS, pApi uintptr, pFts uintptr, ppData uintptr) bp := tls.Alloc(24) defer tls.Free(24) - var rc int32 = 0 // Return code - var p uintptr // Object to return + var rc int32 = SQLITE_OK // Return code + var p uintptr // Object to return p = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer((pApi + 120 /* &.xGetAuxdata */))))(tls, pFts, 0) if p == uintptr(0) { @@ -164944,33 +162277,33 @@ func fts5Bm25GetData(tls *libc.TLS, pApi uintptr, pFts uintptr, ppData uintptr) nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5Bm25Data{})) + ((uint64(nPhrase * 2)) * uint64(unsafe.Sizeof(float64(0)))))) p = Xsqlite3_malloc64(tls, uint64(nByte)) if p == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, p, 0, Size_t(nByte)) (*Fts5Bm25Data)(unsafe.Pointer(p)).FnPhrase = nPhrase - (*Fts5Bm25Data)(unsafe.Pointer(p)).FaIDF = (p + uintptr(1)*32) + (*Fts5Bm25Data)(unsafe.Pointer(p)).FaIDF = (p + 1*32) (*Fts5Bm25Data)(unsafe.Pointer(p)).FaFreq = ((*Fts5Bm25Data)(unsafe.Pointer(p)).FaIDF + uintptr(nPhrase)*8) } // Calculate the average document length for this FTS5 table - if rc == 0 { + if rc == SQLITE_OK { rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 24 /* &.xRowCount */))))(tls, pFts, bp /* &nRow */) } - if rc == 0 { + if rc == SQLITE_OK { rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pApi + 32 /* &.xColumnTotalSize */))))(tls, pFts, -1, bp+8 /* &nToken */) } - if rc == 0 { + if rc == SQLITE_OK { (*Fts5Bm25Data)(unsafe.Pointer(p)).Favgdl = (float64(*(*Sqlite3_int64)(unsafe.Pointer(bp + 8 /* nToken */))) / float64(*(*Sqlite3_int64)(unsafe.Pointer(bp /* nRow */)))) } // Calculate an IDF for each phrase in the query - for i = 0; (rc == 0) && (i < nPhrase); i++ { + for i = 0; (rc == SQLITE_OK) && (i < nPhrase); i++ { *(*Sqlite3_int64)(unsafe.Pointer(bp + 16 /* nHit */)) = int64(0) rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 104 /* &.xQueryPhrase */))))(tls, pFts, i, bp+16 /* &nHit */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr) int32 }{fts5CountCb}))) - if rc == 0 { + if rc == SQLITE_OK { // Calculate the IDF (Inverse Document Frequency) for phrase i. // This is done using the standard BM25 formula as found on wikipedia: // @@ -164992,12 +162325,12 @@ func fts5Bm25GetData(tls *libc.TLS, pApi uintptr, pFts uintptr, ppData uintptr) } } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_free(tls, p) } else { 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) }{Xsqlite3_free}))) } - if rc != 0 { + if rc != SQLITE_OK { p = uintptr(0) } } @@ -165010,10 +162343,10 @@ func fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, n bp := tls.Alloc(28) defer tls.Free(28) - var k1 float64 = 1.2 // Constant "k1" from BM25 formula - var b float64 = 0.75 // Constant "b" from BM25 formula - var rc int32 = 0 // Error code - var score float64 = 0.0 // SQL function return value + var k1 float64 = 1.2 // Constant "k1" from BM25 formula + var b float64 = 0.75 // Constant "b" from BM25 formula + var rc int32 = SQLITE_OK // Error code + var score float64 = 0.0 // SQL function return value // var pData uintptr at bp, 8 // Values allocated/calculated once only var i int32 // Iterator variable @@ -165024,12 +162357,12 @@ func fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, n // Calculate the phrase frequency (symbol "f(qi,D)" in the documentation) // for each phrase in the query for the current row. rc = fts5Bm25GetData(tls, pApi, pFts, bp /* &pData */) - if rc == 0 { + if rc == SQLITE_OK { aFreq = (*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pData */)))).FaFreq libc.Xmemset(tls, aFreq, 0, (uint64(unsafe.Sizeof(float64(0))) * uint64((*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pData */)))).FnPhrase))) rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 64 /* &.xInstCount */))))(tls, pFts, bp+8 /* &nInst */) } - for i = 0; (rc == 0) && (i < *(*int32)(unsafe.Pointer(bp + 8 /* nInst */))); i++ { + for i = 0; (rc == SQLITE_OK) && (i < *(*int32)(unsafe.Pointer(bp + 8 /* nInst */))); i++ { // var ip int32 at bp+12, 4 // var ic int32 at bp+16, 4 @@ -165037,7 +162370,7 @@ func fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, n // var io int32 at bp+20, 4 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 72 /* &.xInst */))))(tls, pFts, i, bp+12 /* &ip */, bp+16 /* &ic */, bp+20 /* &io */) - if rc == 0 { + if rc == SQLITE_OK { var w float64 if nVal > *(*int32)(unsafe.Pointer(bp + 16 /* ic */)) { w = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(*(*int32)(unsafe.Pointer(bp + 16 /* ic */)))*8))) @@ -165049,7 +162382,7 @@ func fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, n } // Figure out the total size of the current row in tokens. - if rc == 0 { + if rc == SQLITE_OK { // var nTok int32 at bp+24, 4 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pApi + 96 /* &.xColumnSize */))))(tls, pFts, -1, bp+24 /* &nTok */) @@ -165057,13 +162390,13 @@ func fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, n } // Determine the BM25 score for the current row. - for i = 0; (rc == 0) && (i < (*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pData */)))).FnPhrase); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pData */)))).FnPhrase); i++ { score = score + (*(*float64)(unsafe.Pointer((*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pData */)))).FaIDF + uintptr(i)*8)) * ((*(*float64)(unsafe.Pointer(aFreq + uintptr(i)*8)) * (k1 + 1.0)) / (*(*float64)(unsafe.Pointer(aFreq + uintptr(i)*8)) + (k1 * ((float64(1) - b) + ((b * D) / (*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pData */)))).Favgdl)))))) } // If no error has occurred, return the calculated score. Otherwise, // throw an SQL exception. - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_result_double(tls, pCtx, (-1.0 * score)) } else { Xsqlite3_result_error_code(tls, pCtx, rc) @@ -165075,32 +162408,20 @@ func sqlite3Fts5AuxInit(tls *libc.TLS, pApi uintptr) int32 { /* sqlite3.c:211508 defer tls.Free(96) *(*[3]Builtin)(unsafe.Pointer(bp /* aBuiltin */)) = [3]Builtin{ - { - FzFunc: ts + 29674, /* "snippet" */ - FpUserData: uintptr(0), - FxFunc: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) - }{fts5SnippetFunction})), - FxDestroy: uintptr(0)}, - { - FzFunc: ts + 29682, /* "highlight" */ - FpUserData: uintptr(0), - FxFunc: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) - }{fts5HighlightFunction})), - FxDestroy: uintptr(0)}, - { - FzFunc: ts + 29692, /* "bm25" */ - FpUserData: uintptr(0), - FxFunc: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) - }{fts5Bm25Function})), - FxDestroy: uintptr(0)}, + {FzFunc: ts + 29674 /* "snippet" */, FxFunc: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) + }{fts5SnippetFunction}))}, + {FzFunc: ts + 29682 /* "highlight" */, FxFunc: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) + }{fts5HighlightFunction}))}, + {FzFunc: ts + 29692 /* "bm25" */, FxFunc: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) + }{fts5Bm25Function}))}, } - var rc int32 = 0 // Return code - var i int32 // To iterate through builtin functions + var rc int32 = SQLITE_OK // Return code + var i int32 // To iterate through builtin functions - for i = 0; (rc == 0) && (i < (int32(uint64(unsafe.Sizeof([3]Builtin{})) / uint64(unsafe.Sizeof(Builtin{}))))); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (int32(uint64(unsafe.Sizeof([3]Builtin{})) / uint64(unsafe.Sizeof(Builtin{}))))); i++ { rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, Fts5_extension_function, uintptr) int32)(unsafe.Pointer((pApi + 24 /* &.xCreateFunction */))))(tls, pApi, (*Builtin)(unsafe.Pointer(bp /* &aBuiltin */ +uintptr(i)*32)).FzFunc, (*Builtin)(unsafe.Pointer(bp /* &aBuiltin */ +uintptr(i)*32)).FpUserData, @@ -165145,7 +162466,7 @@ func sqlite3Fts5BufferSize(tls *libc.TLS, pRc uintptr, pBuf uintptr, nByte U32) } pNew = Xsqlite3_realloc64(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp, nNew) if pNew == uintptr(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM return 1 } else { (*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace = int32(nNew) @@ -165170,14 +162491,14 @@ func sqlite3Fts5BufferAppendVarint(tls *libc.TLS, pRc uintptr, pBuf uintptr, iVa } func sqlite3Fts5Put32(tls *libc.TLS, aBuf uintptr, iVal int32) { /* sqlite3.c:211580:13: */ - *(*U8)(unsafe.Pointer(aBuf + uintptr(0))) = (U8((iVal >> 24) & 0x00FF)) - *(*U8)(unsafe.Pointer(aBuf + uintptr(1))) = (U8((iVal >> 16) & 0x00FF)) - *(*U8)(unsafe.Pointer(aBuf + uintptr(2))) = (U8((iVal >> 8) & 0x00FF)) - *(*U8)(unsafe.Pointer(aBuf + uintptr(3))) = (U8((iVal >> 0) & 0x00FF)) + *(*U8)(unsafe.Pointer(aBuf)) = (U8((iVal >> 24) & 0x00FF)) + *(*U8)(unsafe.Pointer(aBuf + 1)) = (U8((iVal >> 16) & 0x00FF)) + *(*U8)(unsafe.Pointer(aBuf + 2)) = (U8((iVal >> 8) & 0x00FF)) + *(*U8)(unsafe.Pointer(aBuf + 3)) = (U8((iVal >> 0) & 0x00FF)) } func sqlite3Fts5Get32(tls *libc.TLS, aBuf uintptr) int32 { /* sqlite3.c:211587:12: */ - return (int32(((((U32(*(*U8)(unsafe.Pointer(aBuf + uintptr(0))))) << 24) + (U32(int32(*(*U8)(unsafe.Pointer(aBuf + uintptr(1)))) << 16))) + (U32(int32(*(*U8)(unsafe.Pointer(aBuf + uintptr(2)))) << 8))) + U32(*(*U8)(unsafe.Pointer(aBuf + uintptr(3)))))) + return (int32(((((U32(*(*U8)(unsafe.Pointer(aBuf)))) << 24) + (U32(int32(*(*U8)(unsafe.Pointer(aBuf + 1))) << 16))) + (U32(int32(*(*U8)(unsafe.Pointer(aBuf + 2))) << 8))) + U32(*(*U8)(unsafe.Pointer(aBuf + 3))))) } // Append buffer nData/pData to buffer pBuf. If an OOM error occurs, set @@ -165215,7 +162536,7 @@ func sqlite3Fts5BufferAppendString(tls *libc.TLS, pRc uintptr, pBuf uintptr, zSt // following the buffer data is set to 0x00, even though this byte is not // included in the pBuf->n count. func sqlite3Fts5BufferAppendPrintf(tls *libc.TLS, pRc uintptr, pBuf uintptr, zFmt uintptr, va uintptr) { /* sqlite3.c:211633:13: */ - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var zTmp uintptr var ap Va_list _ = ap @@ -165224,7 +162545,7 @@ func sqlite3Fts5BufferAppendPrintf(tls *libc.TLS, pRc uintptr, pBuf uintptr, zFm _ = ap if zTmp == uintptr(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } else { sqlite3Fts5BufferAppendString(tls, pRc, pBuf, zTmp) Xsqlite3_free(tls, zTmp) @@ -165234,14 +162555,14 @@ func sqlite3Fts5BufferAppendPrintf(tls *libc.TLS, pRc uintptr, pBuf uintptr, zFm func sqlite3Fts5Mprintf(tls *libc.TLS, pRc uintptr, zFmt uintptr, va uintptr) uintptr { /* sqlite3.c:211654:13: */ var zRet uintptr = uintptr(0) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var ap Va_list _ = ap ap = va zRet = Xsqlite3_vmprintf(tls, zFmt, ap) _ = ap if zRet == uintptr(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } return zRet @@ -165370,16 +162691,16 @@ func sqlite3Fts5PoslistWriterAppend(tls *libc.TLS, pBuf uintptr, pWriter uintptr return *(*int32)(unsafe.Pointer(bp /* rc */)) } sqlite3Fts5PoslistSafeAppend(tls, pBuf, (pWriter /* &.iPrev */), iPos) - return 0 + return SQLITE_OK } func sqlite3Fts5MallocZero(tls *libc.TLS, pRc uintptr, nByte Sqlite3_int64) uintptr { /* sqlite3.c:211789:13: */ var pRet uintptr = uintptr(0) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { pRet = Xsqlite3_malloc64(tls, uint64(nByte)) if pRet == uintptr(0) { if nByte > int64(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } else { libc.Xmemset(tls, pRet, 0, Size_t(nByte)) @@ -165396,7 +162717,7 @@ func sqlite3Fts5MallocZero(tls *libc.TLS, pRc uintptr, nByte Sqlite3_int64) uint // buffer using sqlite3_free(). If an OOM error occurs, NULL is returned. func sqlite3Fts5Strndup(tls *libc.TLS, pRc uintptr, pIn uintptr, nIn int32) uintptr { /* sqlite3.c:211810:13: */ var zRet uintptr = uintptr(0) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { if nIn < 0 { nIn = int32(libc.Xstrlen(tls, pIn)) } @@ -165405,7 +162726,7 @@ func sqlite3Fts5Strndup(tls *libc.TLS, pRc uintptr, pIn uintptr, nIn int32) uint libc.Xmemcpy(tls, zRet, pIn, uint64(nIn)) *(*int8)(unsafe.Pointer(zRet + uintptr(nIn))) = int8(0) } else { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } return zRet @@ -165454,7 +162775,7 @@ func sqlite3Fts5TermsetNew(tls *libc.TLS, pp uintptr) int32 { /* sqlite3.c:21186 bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK *(*uintptr)(unsafe.Pointer(pp)) = sqlite3Fts5MallocZero(tls, bp /* &rc */, int64(unsafe.Sizeof(Fts5Termset{}))) return *(*int32)(unsafe.Pointer(bp /* rc */)) } @@ -165463,7 +162784,7 @@ func sqlite3Fts5TermsetAdd(tls *libc.TLS, p uintptr, iIdx int32, pTerm uintptr, bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK *(*int32)(unsafe.Pointer(pbPresent)) = 0 if p != 0 { var i int32 @@ -165492,7 +162813,7 @@ func sqlite3Fts5TermsetAdd(tls *libc.TLS, p uintptr, iIdx int32, pTerm uintptr, if pEntry == uintptr(0) { pEntry = sqlite3Fts5MallocZero(tls, bp /* &rc */, (int64(uint64(unsafe.Sizeof(Fts5TermsetEntry{})) + uint64(nTerm)))) if pEntry != 0 { - (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FpTerm = (pEntry + uintptr(1)*24) + (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FpTerm = (pEntry + 1*24) (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FnTerm = nTerm (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FiIdx = iIdx libc.Xmemcpy(tls, (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FpTerm, pTerm, uint64(nTerm)) @@ -165583,7 +162904,7 @@ func fts5ConfigSkipLiteral(tls *libc.TLS, pIn uintptr) uintptr { /* sqlite3.c:21 fallthrough case 'N': if Xsqlite3_strnicmp(tls, ts+5082 /* "null" */, p, 4) == 0 { - p = (p + uintptr(4)) + p = (p + 4) } else { p = uintptr(0) } @@ -165638,7 +162959,7 @@ func fts5ConfigSkipLiteral(tls *libc.TLS, pIn uintptr) uintptr { /* sqlite3.c:21 // At this point, if the literal was an integer, the parse is // finished. Or, if it is a floating point value, it may continue // with either a decimal point or an 'E' character. - if (int32(*(*int8)(unsafe.Pointer(p))) == '.') && (fts5_isdigit(tls, *(*int8)(unsafe.Pointer(p + uintptr(1)))) != 0) { + if (int32(*(*int8)(unsafe.Pointer(p))) == '.') && (fts5_isdigit(tls, *(*int8)(unsafe.Pointer(p + 1))) != 0) { p += uintptr(2) for fts5_isdigit(tls, *(*int8)(unsafe.Pointer(p))) != 0 { p++ @@ -165669,7 +162990,7 @@ func fts5Dequote(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:212080:12: */ var q int8 var iIn int32 = 1 var iOut int32 = 0 - q = *(*int8)(unsafe.Pointer(z + uintptr(0))) + q = *(*int8)(unsafe.Pointer(z)) // Set stack variable q to the close-quote character @@ -165713,7 +163034,7 @@ func fts5Dequote(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:212080:12: */ func sqlite3Fts5Dequote(tls *libc.TLS, z uintptr) { /* sqlite3.c:212125:13: */ var quote int8 // Quote character (if any ) - quote = *(*int8)(unsafe.Pointer(z + uintptr(0))) + quote = *(*int8)(unsafe.Pointer(z)) if (((int32(quote) == '[') || (int32(quote) == '\'')) || (int32(quote) == '"')) || (int32(quote) == '`') { fts5Dequote(tls, z) } @@ -165735,7 +163056,7 @@ func fts5ConfigSetEnum(tls *libc.TLS, aEnum uintptr, zEnum uintptr, peVal uintpt for i = 0; (*Fts5Enum)(unsafe.Pointer(aEnum+uintptr(i)*16)).FzName != 0; i++ { if Xsqlite3_strnicmp(tls, (*Fts5Enum)(unsafe.Pointer(aEnum+uintptr(i)*16)).FzName, zEnum, nEnum) == 0 { if iVal >= 0 { - return 1 + return SQLITE_ERROR } iVal = (*Fts5Enum)(unsafe.Pointer(aEnum + uintptr(i)*16)).FeVal } @@ -165743,9 +163064,9 @@ func fts5ConfigSetEnum(tls *libc.TLS, aEnum uintptr, zEnum uintptr, peVal uintpt *(*int32)(unsafe.Pointer(peVal)) = iVal if iVal < 0 { - return 1 + return SQLITE_ERROR } - return 0 + return SQLITE_OK } // Parse a "special" CREATE VIRTUAL TABLE directive and update @@ -165759,10 +163080,10 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm bp := tls.Alloc(112) defer tls.Free(112) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_OK var nCmd int32 = int32(libc.Xstrlen(tls, zCmd)) if Xsqlite3_strnicmp(tls, ts+29697 /* "prefix" */, zCmd, nCmd) == 0 { - var nByte int32 = (int32(uint64(unsafe.Sizeof(int32(0))) * uint64(31))) + var nByte int32 = (int32(uint64(unsafe.Sizeof(int32(0))) * FTS5_MAX_PREFIX_INDEXES)) var p uintptr var bFirst int32 = 1 if (*Fts5Config)(unsafe.Pointer(pConfig)).FaPrefix == uintptr(0) { @@ -165776,38 +163097,38 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm for 1 != 0 { var nPre int32 = 0 - for int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) == ' ' { + for int32(*(*int8)(unsafe.Pointer(p))) == ' ' { p++ } - if (bFirst == 0) && (int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) == ',') { + if (bFirst == 0) && (int32(*(*int8)(unsafe.Pointer(p))) == ',') { p++ - for int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) == ' ' { + for int32(*(*int8)(unsafe.Pointer(p))) == ' ' { p++ } - } else if int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) == 0 { + } else if int32(*(*int8)(unsafe.Pointer(p))) == 0 { break } - if (int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) < '0') || (int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) > '9') { + if (int32(*(*int8)(unsafe.Pointer(p))) < '0') || (int32(*(*int8)(unsafe.Pointer(p))) > '9') { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+29704 /* "malformed prefix..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR break } - if (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix == 31 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix == FTS5_MAX_PREFIX_INDEXES { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, - ts+29735 /* "too many prefix ..." */, libc.VaList(bp, 31)) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + ts+29735 /* "too many prefix ..." */, libc.VaList(bp, FTS5_MAX_PREFIX_INDEXES)) + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR break } - for ((int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) >= '0') && (int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) <= '9')) && (nPre < 1000) { - nPre = ((nPre * 10) + (int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) - '0')) + for ((int32(*(*int8)(unsafe.Pointer(p))) >= '0') && (int32(*(*int8)(unsafe.Pointer(p))) <= '9')) && (nPre < 1000) { + nPre = ((nPre * 10) + (int32(*(*int8)(unsafe.Pointer(p))) - '0')) p++ } if (nPre <= 0) || (nPre >= 1000) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+29768 /* "prefix length ou..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR break } @@ -165829,7 +163150,7 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm if (azArg != 0) && (pSpace != 0) { if (*Fts5Config)(unsafe.Pointer(pConfig)).FpTok != 0 { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+29814 /* "multiple tokeniz..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { for nArg = int64(0); (p != 0) && (*(*int8)(unsafe.Pointer(p)) != 0); nArg++ { var p2 uintptr = fts5ConfigSkipWhitespace(tls, p) @@ -165848,7 +163169,7 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm } if p == uintptr(0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+29847 /* "parse error in t..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = sqlite3Fts5GetTokenizer(tls, pGlobal, azArg, int32(nArg), (pConfig + 104 /* &.pTok */), (pConfig + 112 /* &.pTokApi */), @@ -165863,15 +163184,15 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm } if Xsqlite3_strnicmp(tls, ts+29881 /* "content" */, zCmd, nCmd) == 0 { - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != 0 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+29889 /* "multiple content..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { - if *(*int8)(unsafe.Pointer(zArg + uintptr(0))) != 0 { - (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent = 2 + if *(*int8)(unsafe.Pointer(zArg)) != 0 { + (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent = FTS5_CONTENT_EXTERNAL (*Fts5Config)(unsafe.Pointer(pConfig)).FzContent = sqlite3Fts5Mprintf(tls, bp+40 /* &rc */, ts+29921 /* "%Q.%Q" */, libc.VaList(bp+8, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, zArg)) } else { - (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent = 1 + (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent = FTS5_CONTENT_NONE } } return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) @@ -165880,7 +163201,7 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm if Xsqlite3_strnicmp(tls, ts+29927 /* "content_rowid" */, zCmd, nCmd) == 0 { if (*Fts5Config)(unsafe.Pointer(pConfig)).FzContentRowid != 0 { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+29941 /* "multiple content..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { (*Fts5Config)(unsafe.Pointer(pConfig)).FzContentRowid = sqlite3Fts5Strndup(tls, bp+40 /* &rc */, zArg, -1) } @@ -165888,26 +163209,20 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm } if Xsqlite3_strnicmp(tls, ts+29979 /* "columnsize" */, zCmd, nCmd) == 0 { - if ((int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) != '0') && (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) != '1')) || (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(1)))) != 0) { + if ((int32(*(*int8)(unsafe.Pointer(zArg))) != '0') && (int32(*(*int8)(unsafe.Pointer(zArg))) != '1')) || (int32(*(*int8)(unsafe.Pointer(zArg + 1))) != 0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+29990 /* "malformed column..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { - (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize = (libc.Bool32(int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) == '1')) + (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize = (libc.Bool32(int32(*(*int8)(unsafe.Pointer(zArg))) == '1')) } return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } if Xsqlite3_strnicmp(tls, ts+4030 /* "detail" */, zCmd, nCmd) == 0 { *(*[4]Fts5Enum)(unsafe.Pointer(bp + 48 /* aDetail */)) = [4]Fts5Enum{ - { - FzName: ts + 14936, /* "none" */ - FeVal: 1}, - { - FzName: ts + 14941, /* "full" */ - FeVal: 0}, - { - FzName: ts + 30025, /* "columns" */ - FeVal: 2}, + {FzName: ts + 14936 /* "none" */, FeVal: FTS5_DETAIL_NONE}, + {FzName: ts + 14941 /* "full" */}, + {FzName: ts + 30025 /* "columns" */, FeVal: FTS5_DETAIL_COLUMNS}, {}, } @@ -165918,7 +163233,7 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm } *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+30064 /* "unrecognized opt..." */, libc.VaList(bp+24, nCmd, zCmd)) - return 1 + return SQLITE_ERROR } // Allocate an instance of the default tokenizer ("simple") at @@ -165953,10 +163268,10 @@ func fts5ConfigGobbleWord(tls *libc.TLS, pRc uintptr, zIn uintptr, pzOut uintptr *(*uintptr)(unsafe.Pointer(pzOut)) = uintptr(0) if zOut == uintptr(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } else { libc.Xmemcpy(tls, zOut, zIn, (Size_t(nIn + int64(1)))) - if fts5_isopenquote(tls, *(*int8)(unsafe.Pointer(zOut + uintptr(0)))) != 0 { + if fts5_isopenquote(tls, *(*int8)(unsafe.Pointer(zOut))) != 0 { var ii int32 = fts5Dequote(tls, zOut) zRet = (zIn + uintptr(ii)) *(*int32)(unsafe.Pointer(pbQuoted)) = 1 @@ -165981,17 +163296,17 @@ func fts5ConfigParseColumn(tls *libc.TLS, p uintptr, zCol uintptr, zArg uintptr, bp := tls.Alloc(16) defer tls.Free(16) - var rc int32 = 0 + var rc int32 = SQLITE_OK if (0 == Xsqlite3_stricmp(tls, zCol, ts+19511 /* "rank" */)) || (0 == Xsqlite3_stricmp(tls, zCol, ts+13865 /* "rowid" */)) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+30092 /* "reserved fts5 co..." */, libc.VaList(bp, zCol)) - rc = 1 + rc = SQLITE_ERROR } else if zArg != 0 { if 0 == Xsqlite3_stricmp(tls, zArg, ts+30122 /* "unindexed" */) { *(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(p)).FabUnindexed + uintptr((*Fts5Config)(unsafe.Pointer(p)).FnCol))) = U8(1) } else { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+30132 /* "unrecognized col..." */, libc.VaList(bp+8, zArg)) - rc = 1 + rc = SQLITE_ERROR } } @@ -166005,13 +163320,13 @@ func fts5ConfigMakeExprlist(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:21242 defer tls.Free(48) var i int32 - *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = SQLITE_OK *(*Fts5Buffer)(unsafe.Pointer(bp + 32 /* buf */)) = Fts5Buffer{} sqlite3Fts5BufferAppendPrintf(tls, bp+24 /* &rc */, bp+32 /* &buf */, ts+30163 /* "T.%Q" */, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(p)).FzContentRowid)) - if (*Fts5Config)(unsafe.Pointer(p)).FeContent != 1 { + if (*Fts5Config)(unsafe.Pointer(p)).FeContent != FTS5_CONTENT_NONE { for i = 0; i < (*Fts5Config)(unsafe.Pointer(p)).FnCol; i++ { - if (*Fts5Config)(unsafe.Pointer(p)).FeContent == 2 { + if (*Fts5Config)(unsafe.Pointer(p)).FeContent == FTS5_CONTENT_EXTERNAL { sqlite3Fts5BufferAppendPrintf(tls, bp+24 /* &rc */, bp+32 /* &buf */, ts+30168 /* ", T.%Q" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(p)).FazCol + uintptr(i)*8)))) } else { sqlite3Fts5BufferAppendPrintf(tls, bp+24 /* &rc */, bp+32 /* &buf */, ts+30175 /* ", T.c%d" */, libc.VaList(bp+16, i)) @@ -166037,14 +163352,14 @@ func sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int bp := tls.Alloc(76) defer tls.Free(76) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 0 // Return code - var pRet uintptr // New object to return + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_OK // Return code + var pRet uintptr // New object to return var i int32 var nByte Sqlite3_int64 *(*uintptr)(unsafe.Pointer(ppOut)) = libc.AssignUintptr(&pRet, Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5Config{})))) if pRet == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pRet, 0, uint64(unsafe.Sizeof(Fts5Config{}))) (*Fts5Config)(unsafe.Pointer(pRet)).Fdb = db @@ -166053,16 +163368,16 @@ func sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int nByte = (Sqlite3_int64(uint64(nArg) * (uint64(unsafe.Sizeof(uintptr(0))) + uint64(unsafe.Sizeof(U8(0)))))) (*Fts5Config)(unsafe.Pointer(pRet)).FazCol = sqlite3Fts5MallocZero(tls, bp+40 /* &rc */, nByte) (*Fts5Config)(unsafe.Pointer(pRet)).FabUnindexed = ((*Fts5Config)(unsafe.Pointer(pRet)).FazCol + uintptr(nArg)*8) - (*Fts5Config)(unsafe.Pointer(pRet)).FzDb = sqlite3Fts5Strndup(tls, bp+40 /* &rc */, *(*uintptr)(unsafe.Pointer(azArg + uintptr(1)*8)), -1) - (*Fts5Config)(unsafe.Pointer(pRet)).FzName = sqlite3Fts5Strndup(tls, bp+40 /* &rc */, *(*uintptr)(unsafe.Pointer(azArg + uintptr(2)*8)), -1) + (*Fts5Config)(unsafe.Pointer(pRet)).FzDb = sqlite3Fts5Strndup(tls, bp+40 /* &rc */, *(*uintptr)(unsafe.Pointer(azArg + 1*8)), -1) + (*Fts5Config)(unsafe.Pointer(pRet)).FzName = sqlite3Fts5Strndup(tls, bp+40 /* &rc */, *(*uintptr)(unsafe.Pointer(azArg + 2*8)), -1) (*Fts5Config)(unsafe.Pointer(pRet)).FbColumnsize = 1 - (*Fts5Config)(unsafe.Pointer(pRet)).FeDetail = 0 - if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && (Xsqlite3_stricmp(tls, (*Fts5Config)(unsafe.Pointer(pRet)).FzName, ts+19511 /* "rank" */) == 0) { + (*Fts5Config)(unsafe.Pointer(pRet)).FeDetail = FTS5_DETAIL_FULL + if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && (Xsqlite3_stricmp(tls, (*Fts5Config)(unsafe.Pointer(pRet)).FzName, ts+19511 /* "rank" */) == 0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+30183 /* "reserved fts5 ta..." */, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pRet)).FzName)) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } - for i = 3; (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && (i < nArg); i++ { + for i = 3; (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && (i < nArg); i++ { var zOrig uintptr = *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)) var z uintptr *(*uintptr)(unsafe.Pointer(bp + 48 /* zOne */)) = uintptr(0) @@ -166080,19 +163395,19 @@ func sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int } } z = fts5ConfigSkipWhitespace(tls, z) - if (z != 0) && (*(*int8)(unsafe.Pointer(z + uintptr(0))) != 0) { + if (z != 0) && (*(*int8)(unsafe.Pointer(z)) != 0) { // var bDummy int32 at bp+72, 4 z = fts5ConfigGobbleWord(tls, bp+40 /* &rc */, z, bp+64 /* &zTwo */, bp+72 /* &bDummy */) - if (z != 0) && (*(*int8)(unsafe.Pointer(z + uintptr(0))) != 0) { + if (z != 0) && (*(*int8)(unsafe.Pointer(z)) != 0) { z = uintptr(0) } } - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { if z == uintptr(0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+30212 /* "parse error in \"..." */, libc.VaList(bp+8, zOrig)) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { if bOption != 0 { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5ConfigParseSpecial(tls, pGlobal, pRet, *(*uintptr)(unsafe.Pointer(bp + 48 /* zOne */)), func() uintptr { @@ -166115,15 +163430,15 @@ func sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int // If a tokenizer= option was successfully parsed, the tokenizer has // already been allocated. Otherwise, allocate an instance of the default // tokenizer (unicode61) now. - if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && ((*Fts5Config)(unsafe.Pointer(pRet)).FpTok == uintptr(0)) { + if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pRet)).FpTok == uintptr(0)) { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5ConfigDefaultTokenizer(tls, pGlobal, pRet) } // If no zContent option was specified, fill in the default values. - if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && ((*Fts5Config)(unsafe.Pointer(pRet)).FzContent == uintptr(0)) { + if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pRet)).FzContent == uintptr(0)) { var zTail uintptr = uintptr(0) - if (*Fts5Config)(unsafe.Pointer(pRet)).FeContent == 0 { + if (*Fts5Config)(unsafe.Pointer(pRet)).FeContent == FTS5_CONTENT_NORMAL { zTail = ts + 29881 /* "content" */ } else if (*Fts5Config)(unsafe.Pointer(pRet)).FbColumnsize != 0 { zTail = ts + 30232 /* "docsize" */ @@ -166135,16 +163450,16 @@ func sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int } } - if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && ((*Fts5Config)(unsafe.Pointer(pRet)).FzContentRowid == uintptr(0)) { + if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pRet)).FzContentRowid == uintptr(0)) { (*Fts5Config)(unsafe.Pointer(pRet)).FzContentRowid = sqlite3Fts5Strndup(tls, bp+40 /* &rc */, ts+13865 /* "rowid" */, -1) } // Formulate the zContentExprlist text - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5ConfigMakeExprlist(tls, pRet) } - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { sqlite3Fts5ConfigFree(tls, pRet) *(*uintptr)(unsafe.Pointer(ppOut)) = uintptr(0) } @@ -166182,7 +163497,7 @@ func sqlite3Fts5ConfigDeclareVtab(tls *libc.TLS, pConfig uintptr) int32 { /* sql defer tls.Free(52) var i int32 - *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = SQLITE_OK var zSql uintptr zSql = sqlite3Fts5Mprintf(tls, bp+48 /* &rc */, ts+30251 /* "CREATE TABLE x(" */, 0) @@ -166229,7 +163544,7 @@ func sqlite3Fts5ConfigDeclareVtab(tls *libc.TLS, pConfig uintptr) int32 { /* sql // to be an SQLite error code and returned to the caller. func sqlite3Fts5Tokenize(tls *libc.TLS, pConfig uintptr, flags int32, pText uintptr, nText int32, pCtx uintptr, xToken uintptr) int32 { /* sqlite3.c:212650:12: */ if pText == uintptr(0) { - return 0 + return SQLITE_OK } return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*Fts5Config)(unsafe.Pointer(pConfig)).FpTokApi + 16 /* &.xTokenize */))))(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FpTok, pCtx, flags, pText, nText, xToken) @@ -166274,13 +163589,13 @@ func sqlite3Fts5ConfigParseRank(tls *libc.TLS, zIn uintptr, pzRank uintptr, pzRa var pRank uintptr var zRank uintptr = uintptr(0) var zRankArgs uintptr = uintptr(0) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK *(*uintptr)(unsafe.Pointer(pzRank)) = uintptr(0) *(*uintptr)(unsafe.Pointer(pzRankArgs)) = uintptr(0) if p == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR } else { p = fts5ConfigSkipWhitespace(tls, p) pRank = p @@ -166292,24 +163607,24 @@ func sqlite3Fts5ConfigParseRank(tls *libc.TLS, zIn uintptr, pzRank uintptr, pzRa libc.Xmemcpy(tls, zRank, pRank, (uint64((int64(p) - int64(pRank)) / 1))) } } else { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { p = fts5ConfigSkipWhitespace(tls, p) if int32(*(*int8)(unsafe.Pointer(p))) != '(' { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR } p++ } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { var pArgs uintptr p = fts5ConfigSkipWhitespace(tls, p) pArgs = p if int32(*(*int8)(unsafe.Pointer(p))) != ')' { p = fts5ConfigSkipArgs(tls, p) if p == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR } else { zRankArgs = sqlite3Fts5MallocZero(tls, bp /* &rc */, (int64(((int64(uintptr(1) + p)) - int64(pArgs)) / 1))) if zRankArgs != 0 { @@ -166320,7 +163635,7 @@ func sqlite3Fts5ConfigParseRank(tls *libc.TLS, zIn uintptr, pzRank uintptr, pzRa } } - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { Xsqlite3_free(tls, zRank) } else { @@ -166334,11 +163649,11 @@ func sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVa bp := tls.Alloc(16) defer tls.Free(16) - var rc int32 = 0 + var rc int32 = SQLITE_OK if 0 == Xsqlite3_stricmp(tls, zKey, ts+30300 /* "pgsz" */) { var pgsz int32 = 0 - if 1 == Xsqlite3_value_numeric_type(tls, pVal) { + if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) { pgsz = Xsqlite3_value_int(tls, pVal) } if (pgsz < 32) || (pgsz > (64 * 1024)) { @@ -166348,7 +163663,7 @@ func sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVa } } else if 0 == Xsqlite3_stricmp(tls, zKey, ts+30305 /* "hashsize" */) { var nHashSize int32 = -1 - if 1 == Xsqlite3_value_numeric_type(tls, pVal) { + if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) { nHashSize = Xsqlite3_value_int(tls, pVal) } if nHashSize <= 0 { @@ -166358,20 +163673,20 @@ func sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVa } } else if 0 == Xsqlite3_stricmp(tls, zKey, ts+30314 /* "automerge" */) { var nAutomerge int32 = -1 - if 1 == Xsqlite3_value_numeric_type(tls, pVal) { + if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) { nAutomerge = Xsqlite3_value_int(tls, pVal) } if (nAutomerge < 0) || (nAutomerge > 64) { *(*int32)(unsafe.Pointer(pbBadkey)) = 1 } else { if nAutomerge == 1 { - nAutomerge = 4 + nAutomerge = FTS5_DEFAULT_AUTOMERGE } (*Fts5Config)(unsafe.Pointer(pConfig)).FnAutomerge = nAutomerge } } else if 0 == Xsqlite3_stricmp(tls, zKey, ts+30324 /* "usermerge" */) { var nUsermerge int32 = -1 - if 1 == Xsqlite3_value_numeric_type(tls, pVal) { + if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) { nUsermerge = Xsqlite3_value_int(tls, pVal) } if (nUsermerge < 2) || (nUsermerge > 16) { @@ -166381,17 +163696,17 @@ func sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVa } } else if 0 == Xsqlite3_stricmp(tls, zKey, ts+30334 /* "crisismerge" */) { var nCrisisMerge int32 = -1 - if 1 == Xsqlite3_value_numeric_type(tls, pVal) { + if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) { nCrisisMerge = Xsqlite3_value_int(tls, pVal) } if nCrisisMerge < 0 { *(*int32)(unsafe.Pointer(pbBadkey)) = 1 } else { if nCrisisMerge <= 1 { - nCrisisMerge = 16 + nCrisisMerge = FTS5_DEFAULT_CRISISMERGE } - if nCrisisMerge >= 2000 { - nCrisisMerge = (2000 - 1) + if nCrisisMerge >= FTS5_MAX_SEGMENT { + nCrisisMerge = (FTS5_MAX_SEGMENT - 1) } (*Fts5Config)(unsafe.Pointer(pConfig)).FnCrisisMerge = nCrisisMerge } @@ -166402,13 +163717,13 @@ func sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVa // var zRankArgs uintptr at bp+8, 8 rc = sqlite3Fts5ConfigParseRank(tls, zIn, bp /* &zRank */, bp+8 /* &zRankArgs */) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzRank) Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzRankArgs) (*Fts5Config)(unsafe.Pointer(pConfig)).FzRank = *(*uintptr)(unsafe.Pointer(bp /* zRank */)) (*Fts5Config)(unsafe.Pointer(pConfig)).FzRankArgs = *(*uintptr)(unsafe.Pointer(bp + 8 /* zRankArgs */)) - } else if rc == 1 { - rc = 0 + } else if rc == SQLITE_ERROR { + rc = SQLITE_OK *(*int32)(unsafe.Pointer(pbBadkey)) = 1 } } else { @@ -166425,14 +163740,14 @@ func sqlite3Fts5ConfigLoad(tls *libc.TLS, pConfig uintptr, iCookie int32) int32 var zSelect uintptr = ts + 30346 /* "SELECT k, v FROM..." */ var zSql uintptr *(*uintptr)(unsafe.Pointer(bp + 40 /* p */)) = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = SQLITE_OK var iVersion int32 = 0 // Set default values - (*Fts5Config)(unsafe.Pointer(pConfig)).Fpgsz = 4050 - (*Fts5Config)(unsafe.Pointer(pConfig)).FnAutomerge = 4 - (*Fts5Config)(unsafe.Pointer(pConfig)).FnUsermerge = 4 - (*Fts5Config)(unsafe.Pointer(pConfig)).FnCrisisMerge = 16 + (*Fts5Config)(unsafe.Pointer(pConfig)).Fpgsz = FTS5_DEFAULT_PAGE_SIZE + (*Fts5Config)(unsafe.Pointer(pConfig)).FnAutomerge = FTS5_DEFAULT_AUTOMERGE + (*Fts5Config)(unsafe.Pointer(pConfig)).FnUsermerge = FTS5_DEFAULT_USERMERGE + (*Fts5Config)(unsafe.Pointer(pConfig)).FnCrisisMerge = FTS5_DEFAULT_CRISISMERGE (*Fts5Config)(unsafe.Pointer(pConfig)).FnHashSize = (1024 * 1024) zSql = sqlite3Fts5Mprintf(tls, bp+32 /* &rc */, zSelect, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) @@ -166441,8 +163756,8 @@ func sqlite3Fts5ConfigLoad(tls *libc.TLS, pConfig uintptr, iCookie int32) int32 Xsqlite3_free(tls, zSql) } - if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0 { - for 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* p */))) { + if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK { + for SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* p */))) { var zK uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* p */)), 0) var pVal uintptr = Xsqlite3_column_value(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* p */)), 1) if 0 == Xsqlite3_stricmp(tls, zK, ts+30378 /* "version" */) { @@ -166455,17 +163770,17 @@ func sqlite3Fts5ConfigLoad(tls *libc.TLS, pConfig uintptr, iCookie int32) int32 *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* p */))) } - if (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0) && (iVersion != 4) { - *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = 1 + if (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK) && (iVersion != FTS5_CURRENT_VERSION) { + *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = SQLITE_ERROR if (*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg != 0 { *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg)) = Xsqlite3_mprintf(tls, ts+30386, /* "invalid fts5 fil..." */ - libc.VaList(bp+16, iVersion, 4)) + libc.VaList(bp+16, iVersion, FTS5_CURRENT_VERSION)) } } - if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK { (*Fts5Config)(unsafe.Pointer(pConfig)).FiCookie = iCookie } return *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) @@ -166520,9 +163835,9 @@ func sqlite3Fts5ParseError(tls *libc.TLS, pParse uintptr, zFmt uintptr, va uintp var ap Va_list _ = ap ap = va - if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { (*Fts5Parse)(unsafe.Pointer(pParse)).FzErr = Xsqlite3_vmprintf(tls, zFmt, ap) - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 1 + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR } _ = ap } @@ -166548,54 +163863,54 @@ func fts5ExprGetToken(tls *libc.TLS, pParse uintptr, pz uintptr, pToken uintptr) (*Fts5Token)(unsafe.Pointer(pToken)).Fn = 1 switch int32(*(*int8)(unsafe.Pointer(z))) { case '(': - tok = 10 + tok = FTS5_LP break case ')': - tok = 11 + tok = FTS5_RP break case '{': - tok = 7 + tok = FTS5_LCP break case '}': - tok = 8 + tok = FTS5_RCP break case ':': - tok = 5 + tok = FTS5_COLON break case ',': - tok = 13 + tok = FTS5_COMMA break case '+': - tok = 14 + tok = FTS5_PLUS break case '*': - tok = 15 + tok = FTS5_STAR break case '-': - tok = 6 + tok = FTS5_MINUS break case '^': - tok = 12 + tok = FTS5_CARET break case 0: - tok = 0 + tok = FTS5_EOF break case '"': { var z2 uintptr - tok = 9 + tok = FTS5_STRING - for z2 = (z + uintptr(1)); 1 != 0; z2++ { - if int32(*(*int8)(unsafe.Pointer(z2 + uintptr(0)))) == '"' { + for z2 = (z + 1); 1 != 0; z2++ { + if int32(*(*int8)(unsafe.Pointer(z2))) == '"' { z2++ - if int32(*(*int8)(unsafe.Pointer(z2 + uintptr(0)))) != '"' { + if int32(*(*int8)(unsafe.Pointer(z2))) != '"' { break } } - if int32(*(*int8)(unsafe.Pointer(z2 + uintptr(0)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(z2))) == 0 { sqlite3Fts5ParseError(tls, pParse, ts+30451 /* "unterminated str..." */, 0) - return 0 + return FTS5_EOF } } (*Fts5Token)(unsafe.Pointer(pToken)).Fn = (int32((int64(z2) - int64(z)) / 1)) @@ -166606,22 +163921,22 @@ func fts5ExprGetToken(tls *libc.TLS, pParse uintptr, pz uintptr, pToken uintptr) default: { var z2 uintptr - if sqlite3Fts5IsBareword(tls, *(*int8)(unsafe.Pointer(z + uintptr(0)))) == 0 { + if sqlite3Fts5IsBareword(tls, *(*int8)(unsafe.Pointer(z))) == 0 { sqlite3Fts5ParseError(tls, pParse, ts+30471 /* "fts5: syntax err..." */, libc.VaList(bp, z)) - return 0 + return FTS5_EOF } - tok = 9 - for z2 = (z + uintptr(1)); sqlite3Fts5IsBareword(tls, *(*int8)(unsafe.Pointer(z2))) != 0; z2++ { + tok = FTS5_STRING + for z2 = (z + 1); sqlite3Fts5IsBareword(tls, *(*int8)(unsafe.Pointer(z2))) != 0; z2++ { } (*Fts5Token)(unsafe.Pointer(pToken)).Fn = (int32((int64(z2) - int64(z)) / 1)) if ((*Fts5Token)(unsafe.Pointer(pToken)).Fn == 2) && (libc.Xmemcmp(tls, (*Fts5Token)(unsafe.Pointer(pToken)).Fp, ts+30502 /* "OR" */, uint64(2)) == 0) { - tok = 1 + tok = FTS5_OR } if ((*Fts5Token)(unsafe.Pointer(pToken)).Fn == 3) && (libc.Xmemcmp(tls, (*Fts5Token)(unsafe.Pointer(pToken)).Fp, ts+30505 /* "NOT" */, uint64(3)) == 0) { - tok = 3 + tok = FTS5_NOT } if ((*Fts5Token)(unsafe.Pointer(pToken)).Fn == 3) && (libc.Xmemcmp(tls, (*Fts5Token)(unsafe.Pointer(pToken)).Fp, ts+27251 /* "AND" */, uint64(3)) == 0) { - tok = 2 + tok = FTS5_AND } break @@ -166658,11 +163973,11 @@ func sqlite3Fts5ExprNew(tls *libc.TLS, pConfig uintptr, iCol int32, zExpr uintpt libc.Xmemset(tls, bp /* &sParse */, 0, uint64(unsafe.Sizeof(Fts5Parse{}))) pEngine = sqlite3Fts5ParserAlloc(tls, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, U64) uintptr }{fts5ParseAlloc}))) if pEngine == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).FpConfig = pConfig - for ok := true; ok; ok = (((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == 0) && (t != 0)) { + for ok := true; ok; ok = (((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == SQLITE_OK) && (t != FTS5_EOF)) { t = fts5ExprGetToken(tls, bp /* &sParse */, bp+40 /* &z */, bp+48 /* &token */) sqlite3Fts5Parser(tls, pEngine, t, *(*Fts5Token)(unsafe.Pointer(bp + 48 /* token */)), bp /* &sParse */) } @@ -166670,20 +163985,20 @@ func sqlite3Fts5ExprNew(tls *libc.TLS, pConfig uintptr, iCol int32, zExpr uintpt // If the LHS of the MATCH expression was a user column, apply the // implicit column-filter. - if ((iCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) && ((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).FpExpr != 0)) && ((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == 0) { + if ((iCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) && ((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).FpExpr != 0)) && ((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == SQLITE_OK) { var n int32 = int32(unsafe.Sizeof(Fts5Colset{})) var pColset uintptr = sqlite3Fts5MallocZero(tls, (bp /* &sParse */ + 16 /* &.rc */), int64(n)) if pColset != 0 { (*Fts5Colset)(unsafe.Pointer(pColset)).FnCol = 1 - *(*int32)(unsafe.Pointer((pColset + 4 /* &.aiCol */) + uintptr(0)*4)) = iCol + *(*int32)(unsafe.Pointer((pColset + 4 /* &.aiCol */))) = iCol sqlite3Fts5ParseSetColset(tls, bp /* &sParse */, (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).FpExpr, pColset) } } - if (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == SQLITE_OK { *(*uintptr)(unsafe.Pointer(ppNew)) = libc.AssignUintptr(&pNew, Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5Expr{})))) if pNew == uintptr(0) { - (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc = 7 + (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc = SQLITE_NOMEM sqlite3Fts5ParseNodeFree(tls, (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).FpExpr) } else { if !(int32((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).FpExpr) != 0) { @@ -166743,14 +164058,14 @@ func sqlite3Fts5ExprAnd(tls *libc.TLS, pp1 uintptr, p2 uintptr) int32 { /* sqlit var p1 uintptr = *(*uintptr)(unsafe.Pointer(pp1)) var nPhrase int32 = ((*Fts5Expr)(unsafe.Pointer(p1)).FnPhrase + (*Fts5Expr)(unsafe.Pointer(p2)).FnPhrase) - (*Fts5Expr)(unsafe.Pointer(p1)).FpRoot = sqlite3Fts5ParseNode(tls, bp /* &sParse */, 2, (*Fts5Expr)(unsafe.Pointer(p1)).FpRoot, (*Fts5Expr)(unsafe.Pointer(p2)).FpRoot, uintptr(0)) + (*Fts5Expr)(unsafe.Pointer(p1)).FpRoot = sqlite3Fts5ParseNode(tls, bp /* &sParse */, FTS5_AND, (*Fts5Expr)(unsafe.Pointer(p1)).FpRoot, (*Fts5Expr)(unsafe.Pointer(p2)).FpRoot, uintptr(0)) (*Fts5Expr)(unsafe.Pointer(p2)).FpRoot = uintptr(0) - if (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == SQLITE_OK { var ap uintptr = Xsqlite3_realloc(tls, (*Fts5Expr)(unsafe.Pointer(p1)).FapExprPhrase, (int32(uint64(nPhrase) * uint64(unsafe.Sizeof(uintptr(0)))))) if ap == uintptr(0) { - (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc = 7 + (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc = SQLITE_NOMEM } else { var i int32 libc.Xmemmove(tls, (ap + uintptr((*Fts5Expr)(unsafe.Pointer(p2)).FnPhrase)*8), ap, (uint64((*Fts5Expr)(unsafe.Pointer(p1)).FnPhrase) * uint64(unsafe.Sizeof(uintptr(0))))) @@ -166816,7 +164131,7 @@ func fts5ExprSynonymList(tls *libc.TLS, pTerm uintptr, iRowid I64, pBuf uintptr, aIter = bp /* aStatic */ nIter = 0 nAlloc = 4 - rc = 0 + rc = SQLITE_OK p = pTerm __1: @@ -166841,7 +164156,7 @@ __5: if !(aNew == uintptr(0)) { goto __7 } - rc = 7 + rc = SQLITE_NOMEM goto synonym_poslist_out __7: ; @@ -166872,8 +164187,8 @@ __3: if !(nIter == 1) { goto __9 } - *(*uintptr)(unsafe.Pointer(pa)) = (*Fts5PoslistReader)(unsafe.Pointer(aIter + uintptr(0)*32)).Fa - *(*int32)(unsafe.Pointer(pn)) = (*Fts5PoslistReader)(unsafe.Pointer(aIter + uintptr(0)*32)).Fn + *(*uintptr)(unsafe.Pointer(pa)) = (*Fts5PoslistReader)(unsafe.Pointer(aIter)).Fa + *(*int32)(unsafe.Pointer(pn)) = (*Fts5PoslistReader)(unsafe.Pointer(aIter)).Fn goto __10 __9: *(*Fts5PoslistWriter)(unsafe.Pointer(bp + 128 /* writer */)) = Fts5PoslistWriter{} @@ -166918,7 +164233,7 @@ __14: goto __15 __15: ; - if !((iMin == (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))) || (rc != 0)) { + if !((iMin == (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))) || (rc != SQLITE_OK)) { goto __20 } goto __12 @@ -166929,7 +164244,7 @@ __20: goto __11 __12: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __21 } *(*uintptr)(unsafe.Pointer(pa)) = (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp @@ -166985,8 +164300,8 @@ func fts5ExprPhraseIsMatch(tls *libc.TLS, pNode uintptr, pPhrase uintptr, pbMatc var iPos I64 *(*Fts5PoslistWriter)(unsafe.Pointer(bp + 160 /* writer */)) = Fts5PoslistWriter{} aIter = bp /* aStatic */ - rc = 0 - bFirst = int32((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32)).FbFirst) + rc = SQLITE_OK + bFirst = int32((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FbFirst) sqlite3Fts5BufferZero(tls, (pPhrase + 8 /* &.poslist */)) @@ -167000,7 +164315,7 @@ func fts5ExprPhraseIsMatch(tls *libc.TLS, pNode uintptr, pPhrase uintptr, pbMatc if !(!(aIter != 0)) { goto __2 } - return 7 + return SQLITE_NOMEM __2: ; __1: @@ -167061,7 +164376,7 @@ __11: if !(1 != 0) { goto __12 } - iPos = (*Fts5PoslistReader)(unsafe.Pointer(aIter + uintptr(0)*32)).FiPos + iPos = (*Fts5PoslistReader)(unsafe.Pointer(aIter)).FiPos __13: bMatch = 1 i = 0 @@ -167117,7 +164432,7 @@ __15: goto __24 } rc = sqlite3Fts5PoslistWriterAppend(tls, (pPhrase + 8 /* &.poslist */), bp+160 /* &writer */, iPos) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __25 } goto ismatch_out @@ -167263,7 +164578,7 @@ __1: libc.Xmemset(tls, bp /* &aStatic[0] */, 0, uint64(unsafe.Sizeof([4]Fts5NearTrimmer{}))) __2: ; - if !(*(*int32)(unsafe.Pointer(bp + 192 /* rc */)) != 0) { + if !(*(*int32)(unsafe.Pointer(bp + 192 /* rc */)) != SQLITE_OK) { goto __3 } *(*int32)(unsafe.Pointer(pRc)) = *(*int32)(unsafe.Pointer(bp + 192 /* rc */)) @@ -167303,7 +164618,7 @@ __7: // This block advances the phrase iterators until they point to a set of // entries that together comprise a match. - iMax = (*Fts5NearTrimmer)(unsafe.Pointer(a + uintptr(0)*48)).Freader.FiPos + iMax = (*Fts5NearTrimmer)(unsafe.Pointer(a)).Freader.FiPos __9: bMatch = 1 i = 0 @@ -167377,7 +164692,7 @@ __22: ; iAdv = 0 - iMin = (*Fts5NearTrimmer)(unsafe.Pointer(a + uintptr(0)*48)).Freader.FiLookahead + iMin = (*Fts5NearTrimmer)(unsafe.Pointer(a)).Freader.FiLookahead i = 0 __24: if !(i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { @@ -167408,7 +164723,7 @@ __8: ; ismatch_out: - bRet = (libc.Bool32((*Fts5Buffer)(unsafe.Pointer((*Fts5NearTrimmer)(unsafe.Pointer(a+uintptr(0)*48)).FpOut)).Fn > 0)) + bRet = (libc.Bool32((*Fts5Buffer)(unsafe.Pointer((*Fts5NearTrimmer)(unsafe.Pointer(a)).FpOut)).Fn > 0)) *(*int32)(unsafe.Pointer(pRc)) = *(*int32)(unsafe.Pointer(bp + 192 /* rc */)) if !(a != bp /* aStatic */) { goto __29 @@ -167452,12 +164767,12 @@ func fts5ExprSynonymAdvanceto(tls *libc.TLS, pTerm uintptr, bDesc int32, piLast bp := tls.Alloc(4) defer tls.Free(4) - var rc int32 = 0 + var rc int32 = SQLITE_OK var iLast I64 = *(*I64)(unsafe.Pointer(piLast)) var p uintptr *(*int32)(unsafe.Pointer(bp /* bEof */)) = 0 - for p = pTerm; (rc == 0) && (p != 0); p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym { + for p = pTerm; (rc == SQLITE_OK) && (p != 0); p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym { if (int32((*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof)) == 0 { var iRowid I64 = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FiRowid if ((bDesc == 0) && (iLast > iRowid)) || ((bDesc != 0) && (iLast < iRowid)) { @@ -167466,7 +164781,7 @@ func fts5ExprSynonymAdvanceto(tls *libc.TLS, pTerm uintptr, bDesc int32, piLast } } - if rc != 0 { + if rc != SQLITE_OK { *(*int32)(unsafe.Pointer(pRc)) = rc *(*int32)(unsafe.Pointer(bp /* bEof */)) = 1 } else { @@ -167482,11 +164797,11 @@ func fts5ExprNearTest(tls *libc.TLS, pRc uintptr, pExpr uintptr, pNode uintptr) var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = *(*int32)(unsafe.Pointer(pRc)) - if (*Fts5Config)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FeDetail != 0 { + if (*Fts5Config)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FeDetail != FTS5_DETAIL_FULL { var pTerm uintptr - var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(0)*8)) + var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */))) (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn = 0 - for pTerm = ((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32); pTerm != 0; pTerm = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym { + for pTerm = (pPhrase + 32 /* &.aTerm */); pTerm != 0; pTerm = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym { var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter if (int32((*Fts5IndexIter)(unsafe.Pointer(pIter)).FbEof)) == 0 { if ((*Fts5IndexIter)(unsafe.Pointer(pIter)).FiRowid == (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid) && ((*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData > 0) { @@ -167501,17 +164816,17 @@ func fts5ExprNearTest(tls *libc.TLS, pRc uintptr, pExpr uintptr, pNode uintptr) // Check that each phrase in the nearset matches the current row. // Populate the pPhrase->poslist buffers at the same time. If any // phrase is not a match, break out of the loop early. - for i = 0; (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0) && (i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase); i++ { + for i = 0; (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK) && (i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase); i++ { var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(i)*8)) - if ((((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 1) || ((*Fts5ExprTerm)(unsafe.Pointer((pPhrase+32 /* &.aTerm */)+uintptr(0)*32)).FpSynonym != 0)) || - ((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset != 0)) || ((*Fts5ExprTerm)(unsafe.Pointer((pPhrase+32 /* &.aTerm */)+uintptr(0)*32)).FbFirst != 0) { + if ((((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 1) || ((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FpSynonym != 0)) || + ((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset != 0)) || ((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FbFirst != 0) { *(*int32)(unsafe.Pointer(bp /* bMatch */)) = 0 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = fts5ExprPhraseIsMatch(tls, pNode, pPhrase, bp /* &bMatch */) if *(*int32)(unsafe.Pointer(bp /* bMatch */)) == 0 { break } } else { - var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32)).FpIter + var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FpIter sqlite3Fts5BufferSet(tls, bp+4 /* &rc */, (pPhrase + 8 /* &.poslist */), (*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData, (*Fts5IndexIter)(unsafe.Pointer(pIter)).FpData) } } @@ -167540,7 +164855,7 @@ func fts5ExprNearInitAll(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(i)*8)) if (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm == 0 { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 1 - return 0 + return SQLITE_OK } else { var j int32 for j = 0; j < (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm; j++ { @@ -167558,19 +164873,19 @@ func fts5ExprNearInitAll(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* (*Fts5Expr)(unsafe.Pointer(pExpr)).FpIndex, (*Fts5ExprTerm)(unsafe.Pointer(p)).FzTerm, int32(libc.Xstrlen(tls, (*Fts5ExprTerm)(unsafe.Pointer(p)).FzTerm)), ((func() int32 { if (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FbPrefix != 0 { - return 0x0001 + return FTS5INDEX_QUERY_PREFIX } return 0 }()) | (func() int32 { if (*Fts5Expr)(unsafe.Pointer(pExpr)).FbDesc != 0 { - return 0x0002 + return FTS5INDEX_QUERY_DESC } return 0 }())), (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset, (p + 16 /* &.pIter */)) - if rc != 0 { + if rc != SQLITE_OK { return rc } if 0 == (int32((*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof)) { @@ -167580,14 +164895,14 @@ func fts5ExprNearInitAll(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* if bHit == 0 { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 1 - return 0 + return SQLITE_OK } } } } (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 0 - return 0 + return SQLITE_OK } // If pExpr is an ASC iterator, this function returns a value with the @@ -167624,7 +164939,7 @@ func fts5ExprSetEof(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:213788:13: */ } func fts5ExprNodeZeroPoslist(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:213797:13: */ - if ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == 9) || ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == 4) { + if ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_STRING) || ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_TERM) { var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear var i int32 for i = 0; i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase; i++ { @@ -167673,8 +164988,8 @@ func fts5ExprNodeTest_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 defer tls.Free(12) var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear - var pLeft uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(0)*8)) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + var pLeft uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */))) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK // var iLast I64 at bp, 8 // Lastest rowid any iterator points to var i int32 @@ -167688,10 +165003,10 @@ func fts5ExprNodeTest_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 // iterator skips through rowids in the default ascending order, this means // the maximum rowid. Or, if the iterator is "ORDER BY rowid DESC", then it // means the minimum rowid. - if (*Fts5ExprTerm)(unsafe.Pointer((pLeft+32 /* &.aTerm */)+uintptr(0)*32)).FpSynonym != 0 { - *(*I64)(unsafe.Pointer(bp /* iLast */)) = fts5ExprSynonymRowid(tls, ((pLeft + 32 /* &.aTerm */) + uintptr(0)*32), bDesc, uintptr(0)) + if (*Fts5ExprTerm)(unsafe.Pointer((pLeft + 32 /* &.aTerm */))).FpSynonym != 0 { + *(*I64)(unsafe.Pointer(bp /* iLast */)) = fts5ExprSynonymRowid(tls, (pLeft + 32 /* &.aTerm */), bDesc, uintptr(0)) } else { - *(*I64)(unsafe.Pointer(bp /* iLast */)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer((pLeft + 32 /* &.aTerm */) + uintptr(0)*32)).FpIter)).FiRowid + *(*I64)(unsafe.Pointer(bp /* iLast */)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer((pLeft + 32 /* &.aTerm */))).FpIter)).FiRowid } for ok := true; ok; ok = (bMatch == 0) { @@ -167726,7 +165041,7 @@ func fts5ExprNodeTest_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 } (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = *(*I64)(unsafe.Pointer(bp /* iLast */)) - (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = (libc.Bool32((0 == fts5ExprNearTest(tls, bp+8 /* &rc */, pExpr, pNode)) && (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0))) + (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = (libc.Bool32((0 == fts5ExprNearTest(tls, bp+8 /* &rc */, pExpr, pNode)) && (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK))) return *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) } @@ -167737,8 +165052,8 @@ func fts5ExprNodeTest_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 // Return SQLITE_OK if successful, or an SQLite error code if an error // occurs. func fts5ExprNodeNext_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 { /* sqlite3.c:213918:12: */ - var pTerm uintptr = ((*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */) + uintptr(0)*8)) + 32 /* &.aTerm */) + uintptr(0)*32) - var rc int32 = 0 + var pTerm uintptr = (*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */))) + 32 /* &.aTerm */) + var rc int32 = SQLITE_OK (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 if (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0 { @@ -167760,7 +165075,7 @@ func fts5ExprNodeNext_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromV } else { rc = sqlite3Fts5IterNext(tls, (*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter) } - if rc != 0 { + if rc != SQLITE_OK { break } if (int32((*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof)) == 0 { @@ -167801,29 +165116,29 @@ func fts5ExprNodeTest_TERM(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { // fts5_index.c iterator object. This is much faster than synthesizing // a new poslist the way we have to for more complicated phrase or NEAR // expressions. - var pPhrase uintptr = *(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */) + uintptr(0)*8)) - var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32)).FpIter + var pPhrase uintptr = *(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */))) + var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FpIter (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn = (*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData - if (*Fts5Config)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FeDetail == 0 { + if (*Fts5Config)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FeDetail == FTS5_DETAIL_FULL { (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fp = (*Fts5IndexIter)(unsafe.Pointer(pIter)).FpData } (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*Fts5IndexIter)(unsafe.Pointer(pIter)).FiRowid (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = (libc.Bool32((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn == 0)) - return 0 + return SQLITE_OK } // xNext() method for a node of type FTS5_TERM. func fts5ExprNodeNext_TERM(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 { /* sqlite3.c:214011:12: */ var rc int32 - var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */) + uintptr(0)*8)) + 32 /* &.aTerm */) + uintptr(0)*32)).FpIter + var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */))) + 32 /* &.aTerm */))).FpIter if bFromValid != 0 { rc = sqlite3Fts5IterNextFrom(tls, pIter, iFrom) } else { rc = sqlite3Fts5IterNext(tls, pIter) } - if (rc == 0) && ((int32((*Fts5IndexIter)(unsafe.Pointer(pIter)).FbEof)) == 0) { + if (rc == SQLITE_OK) && ((int32((*Fts5IndexIter)(unsafe.Pointer(pIter)).FbEof)) == 0) { rc = fts5ExprNodeTest_TERM(tls, pExpr, pNode) } else { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 1 @@ -167833,7 +165148,7 @@ func fts5ExprNodeNext_TERM(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromVal } func fts5ExprNodeTest_OR(tls *libc.TLS, pExpr uintptr, pNode uintptr) { /* sqlite3.c:214035:13: */ - var pNext uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)) + var pNext uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))) var i int32 for i = 1; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ { @@ -167859,7 +165174,7 @@ func fts5ExprNodeNext_OR(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid if ((*Fts5ExprNode)(unsafe.Pointer(p1)).FiRowid == iLast) || ((bFromValid != 0) && (fts5RowidCmp(tls, pExpr, (*Fts5ExprNode)(unsafe.Pointer(p1)).FiRowid, iFrom) < 0)) { var rc int32 = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((p1 + 16 /* &.xNext */))))(tls, pExpr, p1, bFromValid, iFrom) - if rc != 0 { + if rc != SQLITE_OK { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 return rc } @@ -167868,14 +165183,14 @@ func fts5ExprNodeNext_OR(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid } fts5ExprNodeTest_OR(tls, pExpr, pNode) - return 0 + return SQLITE_OK } // Argument pNode is an FTS5_AND node. func fts5ExprNodeTest_AND(tls *libc.TLS, pExpr uintptr, pAnd uintptr) int32 { /* sqlite3.c:214086:12: */ var iChild int32 var iLast I64 = (*Fts5ExprNode)(unsafe.Pointer(pAnd)).FiRowid - var rc int32 = 0 + var rc int32 = SQLITE_OK var bMatch int32 for ok := true; ok; ok = (bMatch == 0) { @@ -167887,7 +165202,7 @@ func fts5ExprNodeTest_AND(tls *libc.TLS, pExpr uintptr, pAnd uintptr) int32 { /* if cmp > 0 { // Advance pChild until it points to iLast or laster rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((pChild + 16 /* &.xNext */))))(tls, pExpr, pChild, 1, iLast) - if rc != 0 { + if rc != SQLITE_OK { (*Fts5ExprNode)(unsafe.Pointer(pAnd)).FbNomatch = 0 return rc } @@ -167917,12 +165232,12 @@ func fts5ExprNodeTest_AND(tls *libc.TLS, pExpr uintptr, pAnd uintptr) int32 { /* fts5ExprNodeZeroPoslist(tls, pAnd) } (*Fts5ExprNode)(unsafe.Pointer(pAnd)).FiRowid = iLast - return 0 + return SQLITE_OK } func fts5ExprNodeNext_AND(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 { /* sqlite3.c:214138:12: */ - var rc int32 = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)) + 16 /* &.xNext */))))(tls, pExpr, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)), bFromValid, iFrom) - if rc == 0 { + var rc int32 = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))) + 16 /* &.xNext */))))(tls, pExpr, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))), bFromValid, iFrom) + if rc == SQLITE_OK { rc = fts5ExprNodeTest_AND(tls, pExpr, pNode) } else { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 @@ -167931,11 +165246,11 @@ func fts5ExprNodeNext_AND(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromVali } func fts5ExprNodeTest_NOT(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sqlite3.c:214153:12: */ - var rc int32 = 0 - var p1 uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)) - var p2 uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(1)*8)) + var rc int32 = SQLITE_OK + var p1 uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))) + var p2 uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + 1*8)) - for (rc == 0) && ((*Fts5ExprNode)(unsafe.Pointer(p1)).FbEof == 0) { + for (rc == SQLITE_OK) && ((*Fts5ExprNode)(unsafe.Pointer(p1)).FbEof == 0) { var cmp int32 = fts5NodeCompare(tls, pExpr, p1, p2) if cmp > 0 { rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((p2 + 16 /* &.xNext */))))(tls, pExpr, p2, 1, (*Fts5ExprNode)(unsafe.Pointer(p1)).FiRowid) @@ -167957,11 +165272,11 @@ func fts5ExprNodeTest_NOT(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { / } func fts5ExprNodeNext_NOT(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 { /* sqlite3.c:214181:12: */ - var rc int32 = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)) + 16 /* &.xNext */))))(tls, pExpr, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)), bFromValid, iFrom) - if rc == 0 { + var rc int32 = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))) + 16 /* &.xNext */))))(tls, pExpr, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))), bFromValid, iFrom) + if rc == SQLITE_OK { rc = fts5ExprNodeTest_NOT(tls, pExpr, pNode) } - if rc != 0 { + if rc != SQLITE_OK { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 } return rc @@ -167971,11 +165286,11 @@ func fts5ExprNodeNext_NOT(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromVali // without modifying it. Otherwise, pNode is advanced until it does point // to a match or EOF is reached. func fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sqlite3.c:214202:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof == 0 { switch (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType { - case 9: + case FTS5_STRING: { rc = fts5ExprNodeTest_STRING(tls, pExpr, pNode) break @@ -167983,7 +165298,7 @@ func fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sq } fallthrough - case 4: + case FTS5_TERM: { rc = fts5ExprNodeTest_TERM(tls, pExpr, pNode) break @@ -167991,7 +165306,7 @@ func fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sq } fallthrough - case 2: + case FTS5_AND: { rc = fts5ExprNodeTest_AND(tls, pExpr, pNode) break @@ -167999,7 +165314,7 @@ func fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sq } fallthrough - case 1: + case FTS5_OR: { fts5ExprNodeTest_OR(tls, pExpr, pNode) break @@ -168024,11 +165339,11 @@ func fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sq // Return an SQLite error code if an error occurs, or SQLITE_OK otherwise. // It is not an error if there are no matches. func fts5ExprNodeFirst(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sqlite3.c:214247:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 0 (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 - if ((*Fts5ExprNode)(unsafe.Pointer((pNode))).FeType == 4) || ((*Fts5ExprNode)(unsafe.Pointer((pNode))).FeType == 9) { + if ((*Fts5ExprNode)(unsafe.Pointer((pNode))).FeType == FTS5_TERM) || ((*Fts5ExprNode)(unsafe.Pointer((pNode))).FeType == FTS5_STRING) { // Initialize all term iterators in the NEAR object. rc = fts5ExprNearInitAll(tls, pExpr, pNode) } else if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext == uintptr(0) { @@ -168036,23 +165351,23 @@ func fts5ExprNodeFirst(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* s } else { var i int32 var nEof int32 = 0 - for i = 0; (i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild) && (rc == 0); i++ { + for i = 0; (i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild) && (rc == SQLITE_OK); i++ { var pChild uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(i)*8)) rc = fts5ExprNodeFirst(tls, pExpr, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(i)*8))) nEof = nEof + ((*Fts5ExprNode)(unsafe.Pointer(pChild)).FbEof) } - (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)))).FiRowid + (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))))).FiRowid switch (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType { - case 2: + case FTS5_AND: if nEof > 0 { fts5ExprSetEof(tls, pNode) } break fallthrough - case 1: + case FTS5_OR: if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild == nEof { fts5ExprSetEof(tls, pNode) } @@ -168061,12 +165376,12 @@ func fts5ExprNodeFirst(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* s default: - (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = (*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)))).FbEof + (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = (*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))))).FbEof break } } - if rc == 0 { + if rc == SQLITE_OK { rc = fts5ExprNodeTest(tls, pExpr, pNode) } return rc @@ -168095,7 +165410,7 @@ func sqlite3Fts5ExprFirst(tls *libc.TLS, p uintptr, pIdx uintptr, iFirst I64, bD // If not at EOF but the current rowid occurs earlier than iFirst in // the iteration order, move to document iFirst or later. - if ((rc == 0) && + if ((rc == SQLITE_OK) && (0 == (*Fts5ExprNode)(unsafe.Pointer(pRoot)).FbEof)) && (fts5RowidCmp(tls, p, (*Fts5ExprNode)(unsafe.Pointer(pRoot)).FiRowid, iFirst) < 0) { rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((pRoot + 16 /* &.xNext */))))(tls, p, pRoot, 1, iFirst) @@ -168139,7 +165454,7 @@ func fts5ParseStringFromToken(tls *libc.TLS, pToken uintptr, pz uintptr) int32 { bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK *(*uintptr)(unsafe.Pointer(pz)) = sqlite3Fts5Strndup(tls, bp /* &rc */, (*Fts5Token)(unsafe.Pointer(pToken)).Fp, (*Fts5Token)(unsafe.Pointer(pToken)).Fn) return *(*int32)(unsafe.Pointer(bp /* rc */)) } @@ -168157,7 +165472,7 @@ func fts5ExprPhraseFree(tls *libc.TLS, pPhrase uintptr) { /* sqlite3.c:214368:13 for pSyn = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym; pSyn != 0; pSyn = pNext { pNext = (*Fts5ExprTerm)(unsafe.Pointer(pSyn)).FpSynonym sqlite3Fts5IterClose(tls, (*Fts5ExprTerm)(unsafe.Pointer(pSyn)).FpIter) - sqlite3Fts5BufferFree(tls, (pSyn + uintptr(1)*32)) + sqlite3Fts5BufferFree(tls, (pSyn + 1*32)) Xsqlite3_free(tls, pSyn) } } @@ -168172,7 +165487,7 @@ func fts5ExprPhraseFree(tls *libc.TLS, pPhrase uintptr) { /* sqlite3.c:214368:13 // only argument. func sqlite3Fts5ParseSetCaret(tls *libc.TLS, pPhrase uintptr) { /* sqlite3.c:214393:13: */ if (pPhrase != 0) && ((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm != 0) { - (*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32)).FbFirst = U8(1) + (*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FbFirst = U8(1) } } @@ -168186,7 +165501,7 @@ func sqlite3Fts5ParseNearset(tls *libc.TLS, pParse uintptr, pNear uintptr, pPhra var SZALLOC int32 = 8 var pRet uintptr = uintptr(0) - if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { if pPhrase == uintptr(0) { return pNear } @@ -168195,7 +165510,7 @@ func sqlite3Fts5ParseNearset(tls *libc.TLS, pParse uintptr, pNear uintptr, pPhra nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5ExprNearset{})) + (uint64(SZALLOC) * uint64(unsafe.Sizeof(uintptr(0)))))) pRet = Xsqlite3_malloc64(tls, uint64(nByte)) if pRet == uintptr(0) { - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 7 + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM } else { libc.Xmemset(tls, pRet, 0, Size_t(nByte)) } @@ -168206,7 +165521,7 @@ func sqlite3Fts5ParseNearset(tls *libc.TLS, pParse uintptr, pNear uintptr, pPhra nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5ExprNearset{})) + (uint64(nNew) * uint64(unsafe.Sizeof(uintptr(0)))))) pRet = Xsqlite3_realloc64(tls, pNear, uint64(nByte)) if pRet == uintptr(0) { - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 7 + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM } } else { pRet = pNear @@ -168251,7 +165566,7 @@ func fts5ParseTokenize(tls *libc.TLS, pContext uintptr, tflags int32, pToken uin bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var SZALLOC int32 = 8 var pCtx uintptr = pContext var pPhrase uintptr = (*TokenCtx)(unsafe.Pointer(pCtx)).FpPhrase @@ -168260,19 +165575,19 @@ func fts5ParseTokenize(tls *libc.TLS, pContext uintptr, tflags int32, pToken uin _ = iUnused2 // If an error has already occurred, this is a no-op - if (*TokenCtx)(unsafe.Pointer(pCtx)).Frc != 0 { + if (*TokenCtx)(unsafe.Pointer(pCtx)).Frc != SQLITE_OK { return (*TokenCtx)(unsafe.Pointer(pCtx)).Frc } - if nToken > 32768 { - nToken = 32768 + if nToken > FTS5_MAX_TOKEN_SIZE { + nToken = FTS5_MAX_TOKEN_SIZE } - if ((pPhrase != 0) && ((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0)) && ((tflags & 0x0001) != 0) { + if ((pPhrase != 0) && ((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0)) && ((tflags & FTS5_TOKEN_COLOCATED) != 0) { var pSyn uintptr var nByte Sqlite3_int64 = (Sqlite3_int64(((uint64(unsafe.Sizeof(Fts5ExprTerm{})) + uint64(unsafe.Sizeof(Fts5Buffer{}))) + uint64(nToken)) + uint64(1))) pSyn = Xsqlite3_malloc64(tls, uint64(nByte)) if pSyn == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_NOMEM } else { libc.Xmemset(tls, pSyn, 0, Size_t(nByte)) (*Fts5ExprTerm)(unsafe.Pointer(pSyn)).FzTerm = (((pSyn) + uintptr(uint64(unsafe.Sizeof(Fts5ExprTerm{})))) + uintptr(uint64(unsafe.Sizeof(Fts5Buffer{})))) @@ -168294,7 +165609,7 @@ func fts5ParseTokenize(tls *libc.TLS, pContext uintptr, tflags int32, pToken uin pNew = Xsqlite3_realloc64(tls, pPhrase, (uint64(uint64(unsafe.Sizeof(Fts5ExprPhrase{})) + (uint64(unsafe.Sizeof(Fts5ExprTerm{})) * uint64(nNew))))) if pNew == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_NOMEM } else { if pPhrase == uintptr(0) { libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(Fts5ExprPhrase{}))) @@ -168304,7 +165619,7 @@ func fts5ParseTokenize(tls *libc.TLS, pContext uintptr, tflags int32, pToken uin } } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { pTerm = ((pPhrase + 32 /* &.aTerm */) + uintptr(libc.PostIncInt32(&(*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm, 1))*32) libc.Xmemset(tls, pTerm, 0, uint64(unsafe.Sizeof(Fts5ExprTerm{}))) (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FzTerm = sqlite3Fts5Strndup(tls, bp /* &rc */, pToken, nToken) @@ -168354,10 +165669,10 @@ func sqlite3Fts5ParseTerm(tls *libc.TLS, pParse uintptr, pAppend uintptr, pToken (*TokenCtx)(unsafe.Pointer(bp /* &sCtx */)).FpPhrase = pAppend rc = fts5ParseStringFromToken(tls, pToken, bp+16 /* &z */) - if rc == 0 { - var flags int32 = (0x0001 | (func() int32 { + if rc == SQLITE_OK { + var flags int32 = (FTS5_TOKENIZE_QUERY | (func() int32 { if bPrefix != 0 { - return 0x0002 + return FTS5_TOKENIZE_PREFIX } return 0 }())) @@ -168381,7 +165696,7 @@ func sqlite3Fts5ParseTerm(tls *libc.TLS, pParse uintptr, pAppend uintptr, pToken var apNew uintptr apNew = Xsqlite3_realloc64(tls, (*Fts5Parse)(unsafe.Pointer(pParse)).FapPhrase, uint64(nByte)) if apNew == uintptr(0) { - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 7 + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM fts5ExprPhraseFree(tls, (*TokenCtx)(unsafe.Pointer(bp /* &sCtx */)).FpPhrase) return uintptr(0) } @@ -168409,26 +165724,26 @@ func sqlite3Fts5ExprClonePhrase(tls *libc.TLS, pExpr uintptr, iPhrase int32, ppN bp := tls.Alloc(24) defer tls.Free(24) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 // Return code + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK // Return code var pOrig uintptr // The phrase extracted from pExpr var pNew uintptr = uintptr(0) // Expression to return via *ppNew *(*TokenCtx)(unsafe.Pointer(bp + 8 /* sCtx */)) = TokenCtx{} // Context object for fts5ParseTokenize pOrig = *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*8)) pNew = sqlite3Fts5MallocZero(tls, bp /* &rc */, int64(unsafe.Sizeof(Fts5Expr{}))) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*Fts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase = sqlite3Fts5MallocZero(tls, bp, /* &rc */ int64(unsafe.Sizeof(uintptr(0)))) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot = sqlite3Fts5MallocZero(tls, bp, /* &rc */ int64(unsafe.Sizeof(Fts5ExprNode{}))) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear = sqlite3Fts5MallocZero(tls, bp, /* &rc */ (int64(uint64(unsafe.Sizeof(Fts5ExprNearset{})) + uint64(unsafe.Sizeof(uintptr(0)))))) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { var pColsetOrig uintptr = (*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer((*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FpNode)).FpNear)).FpColset if pColsetOrig != 0 { var nByte Sqlite3_int64 @@ -168444,16 +165759,16 @@ func sqlite3Fts5ExprClonePhrase(tls *libc.TLS, pExpr uintptr, iPhrase int32, ppN if (*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm != 0 { var i int32 // Used to iterate through phrase terms - for i = 0; (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (i < (*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm); i++ { + for i = 0; (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (i < (*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm); i++ { var tflags int32 = 0 var p uintptr - for p = ((pOrig + 32 /* &.aTerm */) + uintptr(i)*32); (p != 0) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0); p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym { + for p = ((pOrig + 32 /* &.aTerm */) + uintptr(i)*32); (p != 0) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK); p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym { var zTerm uintptr = (*Fts5ExprTerm)(unsafe.Pointer(p)).FzTerm *(*int32)(unsafe.Pointer(bp /* rc */)) = fts5ParseTokenize(tls, bp+8 /* &sCtx */, tflags, zTerm, int32(libc.Xstrlen(tls, zTerm)), 0, 0) - tflags = 0x0001 + tflags = FTS5_TOKEN_COLOCATED } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*Fts5ExprTerm)(unsafe.Pointer(((*TokenCtx)(unsafe.Pointer(bp+8 /* &sCtx */)).FpPhrase + 32 /* &.aTerm */) + uintptr(i)*32)).FbPrefix = (*Fts5ExprTerm)(unsafe.Pointer((pOrig + 32 /* &.aTerm */) + uintptr(i)*32)).FbPrefix (*Fts5ExprTerm)(unsafe.Pointer(((*TokenCtx)(unsafe.Pointer(bp+8 /* &sCtx */)).FpPhrase + 32 /* &.aTerm */) + uintptr(i)*32)).FbFirst = (*Fts5ExprTerm)(unsafe.Pointer((pOrig + 32 /* &.aTerm */) + uintptr(i)*32)).FbFirst } @@ -168464,25 +165779,25 @@ func sqlite3Fts5ExprClonePhrase(tls *libc.TLS, pExpr uintptr, iPhrase int32, ppN (*TokenCtx)(unsafe.Pointer(bp + 8 /* &sCtx */)).FpPhrase = sqlite3Fts5MallocZero(tls, bp /* &rc */, int64(unsafe.Sizeof(Fts5ExprPhrase{}))) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { // All the allocations succeeded. Put the expression object together. (*Fts5Expr)(unsafe.Pointer(pNew)).FpIndex = (*Fts5Expr)(unsafe.Pointer(pExpr)).FpIndex (*Fts5Expr)(unsafe.Pointer(pNew)).FpConfig = (*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig (*Fts5Expr)(unsafe.Pointer(pNew)).FnPhrase = 1 - *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase + uintptr(0)*8)) = (*TokenCtx)(unsafe.Pointer(bp + 8 /* &sCtx */)).FpPhrase - *(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear + 24 /* &.apPhrase */) + uintptr(0)*8)) = (*TokenCtx)(unsafe.Pointer(bp + 8 /* &sCtx */)).FpPhrase + *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase)) = (*TokenCtx)(unsafe.Pointer(bp + 8 /* &sCtx */)).FpPhrase + *(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear + 24 /* &.apPhrase */))) = (*TokenCtx)(unsafe.Pointer(bp + 8 /* &sCtx */)).FpPhrase (*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear)).FnPhrase = 1 (*Fts5ExprPhrase)(unsafe.Pointer((*TokenCtx)(unsafe.Pointer(bp + 8 /* &sCtx */)).FpPhrase)).FpNode = (*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot if (((*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm == 1) && - ((*Fts5ExprTerm)(unsafe.Pointer((pOrig+32 /* &.aTerm */)+uintptr(0)*32)).FpSynonym == uintptr(0))) && - (int32((*Fts5ExprTerm)(unsafe.Pointer((pOrig+32 /* &.aTerm */)+uintptr(0)*32)).FbFirst) == 0) { - (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = 4 + ((*Fts5ExprTerm)(unsafe.Pointer((pOrig + 32 /* &.aTerm */))).FpSynonym == uintptr(0))) && + (int32((*Fts5ExprTerm)(unsafe.Pointer((pOrig + 32 /* &.aTerm */))).FbFirst) == 0) { + (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = FTS5_TERM (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, I64) int32 }{fts5ExprNodeNext_TERM})) } else { - (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = 9 + (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = FTS5_STRING (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, I64) int32 }{fts5ExprNodeNext_STRING})) @@ -168528,7 +165843,7 @@ func sqlite3Fts5ParseSetDistance(tls *libc.TLS, pParse uintptr, pNear uintptr, p nNear = ((nNear * 10) + (int32(*(*int8)(unsafe.Pointer((*Fts5Token)(unsafe.Pointer(p)).Fp + uintptr(i)))) - '0')) } } else { - nNear = 10 + nNear = FTS5_DEFAULT_NEARDIST } (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnNear = nNear } @@ -168552,7 +165867,7 @@ func fts5ParseColset(tls *libc.TLS, pParse uintptr, p uintptr, iCol int32) uintp pNew = Xsqlite3_realloc64(tls, p, (uint64(uint64(unsafe.Sizeof(Fts5Colset{})) + (uint64(unsafe.Sizeof(int32(0))) * uint64(nCol))))) if pNew == uintptr(0) { - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 7 + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM } else { var aiCol uintptr = pNew + 4 /* &.aiCol */ var i int32 @@ -168610,7 +165925,7 @@ func sqlite3Fts5ParseColset(tls *libc.TLS, pParse uintptr, pColset uintptr, p ui var z uintptr // Dequoted copy of token p z = sqlite3Fts5Strndup(tls, (pParse + 16 /* &.rc */), (*Fts5Token)(unsafe.Pointer(p)).Fp, (*Fts5Token)(unsafe.Pointer(p)).Fn) - if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { var pConfig uintptr = (*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig sqlite3Fts5Dequote(tls, z) for iCol = 0; iCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; iCol++ { @@ -168680,14 +165995,14 @@ func fts5MergeColset(tls *libc.TLS, pColset uintptr, pMerge uintptr) { /* sqlite // of pColset. This function may use the spare copy and set (*ppFree) to // zero, or it may create copies of pColset using fts5CloneColset(). func fts5ParseSetColset(tls *libc.TLS, pParse uintptr, pNode uintptr, pColset uintptr, ppFree uintptr) { /* sqlite3.c:214916:13: */ - if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { - if ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == 9) || ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == 4) { + if ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_STRING) || ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_TERM) { var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear if (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset != 0 { fts5MergeColset(tls, (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset, pColset) if (*Fts5Colset)(unsafe.Pointer((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset)).FnCol == 0 { - (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType = 0 + (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType = FTS5_EOF (*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = uintptr(0) } } else if *(*uintptr)(unsafe.Pointer(ppFree)) != 0 { @@ -168712,8 +166027,8 @@ func sqlite3Fts5ParseSetColset(tls *libc.TLS, pParse uintptr, pExpr uintptr, pCo defer tls.Free(8) *(*uintptr)(unsafe.Pointer(bp /* pFree */)) = pColset - if (*Fts5Config)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail == 1 { - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 1 + if (*Fts5Config)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail == FTS5_DETAIL_NONE { + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR (*Fts5Parse)(unsafe.Pointer(pParse)).FzErr = Xsqlite3_mprintf(tls, ts+30543 /* "fts5: column que..." */, 0) } else { @@ -168724,13 +166039,13 @@ func sqlite3Fts5ParseSetColset(tls *libc.TLS, pParse uintptr, pExpr uintptr, pCo func fts5ExprAssignXNext(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:214971:13: */ switch (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType { - case 9: + case FTS5_STRING: { var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear - if ((((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase == 1) && ((*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(0)*8)))).FnTerm == 1)) && - ((*Fts5ExprTerm)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(0)*8))+32 /* &.aTerm */)+uintptr(0)*32)).FpSynonym == uintptr(0))) && - (int32((*Fts5ExprTerm)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(0)*8))+32 /* &.aTerm */)+uintptr(0)*32)).FbFirst) == 0) { - (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType = 4 + if ((((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase == 1) && ((*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */))))).FnTerm == 1)) && + ((*Fts5ExprTerm)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */))) + 32 /* &.aTerm */))).FpSynonym == uintptr(0))) && + (int32((*Fts5ExprTerm)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */))) + 32 /* &.aTerm */))).FbFirst) == 0) { + (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType = FTS5_TERM (*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, I64) int32 }{fts5ExprNodeNext_TERM})) @@ -168743,7 +166058,7 @@ func fts5ExprAssignXNext(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:214971:13: } - case 1: + case FTS5_OR: { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, I64) int32 @@ -168752,7 +166067,7 @@ func fts5ExprAssignXNext(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:214971:13: } - case 2: + case FTS5_AND: { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, I64) int32 @@ -168774,7 +166089,7 @@ func fts5ExprAssignXNext(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:214971:13: } func fts5ExprAddChildren(tls *libc.TLS, p uintptr, pSub uintptr) { /* sqlite3.c:215004:13: */ - if ((*Fts5ExprNode)(unsafe.Pointer(p)).FeType != 3) && ((*Fts5ExprNode)(unsafe.Pointer(pSub)).FeType == (*Fts5ExprNode)(unsafe.Pointer(p)).FeType) { + if ((*Fts5ExprNode)(unsafe.Pointer(p)).FeType != FTS5_NOT) && ((*Fts5ExprNode)(unsafe.Pointer(pSub)).FeType == (*Fts5ExprNode)(unsafe.Pointer(p)).FeType) { var nByte int32 = (int32(uint64(unsafe.Sizeof(uintptr(0))) * uint64((*Fts5ExprNode)(unsafe.Pointer(pSub)).FnChild))) libc.Xmemcpy(tls, ((p + 48 /* &.apChild */) + uintptr((*Fts5ExprNode)(unsafe.Pointer(p)).FnChild)*8), pSub+48 /* &.apChild */, uint64(nByte)) *(*int32)(unsafe.Pointer(p + 40 /* &.nChild */)) += ((*Fts5ExprNode)(unsafe.Pointer(pSub)).FnChild) @@ -168792,23 +166107,23 @@ func sqlite3Fts5ParseNode(tls *libc.TLS, pParse uintptr, eType int32, pLeft uint var pRet uintptr = uintptr(0) - if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { var nChild int32 = 0 // Number of children of returned node var nByte Sqlite3_int64 // Bytes of space to allocate for this node - if (eType == 9) && (pNear == uintptr(0)) { + if (eType == FTS5_STRING) && (pNear == uintptr(0)) { return uintptr(0) } - if (eType != 9) && (pLeft == uintptr(0)) { + if (eType != FTS5_STRING) && (pLeft == uintptr(0)) { return pRight } - if (eType != 9) && (pRight == uintptr(0)) { + if (eType != FTS5_STRING) && (pRight == uintptr(0)) { return pLeft } - if eType == 3 { + if eType == FTS5_NOT { nChild = 2 - } else if (eType == 2) || (eType == 1) { + } else if (eType == FTS5_AND) || (eType == FTS5_OR) { nChild = 2 if (*Fts5ExprNode)(unsafe.Pointer(pLeft)).FeType == eType { nChild = nChild + ((*Fts5ExprNode)(unsafe.Pointer(pLeft)).FnChild - 1) @@ -168825,23 +166140,23 @@ func sqlite3Fts5ParseNode(tls *libc.TLS, pParse uintptr, eType int32, pLeft uint (*Fts5ExprNode)(unsafe.Pointer(pRet)).FeType = eType (*Fts5ExprNode)(unsafe.Pointer(pRet)).FpNear = pNear fts5ExprAssignXNext(tls, pRet) - if eType == 9 { + if eType == FTS5_STRING { var iPhrase int32 for iPhrase = 0; iPhrase < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase; iPhrase++ { (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(iPhrase)*8)))).FpNode = pRet if (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(iPhrase)*8)))).FnTerm == 0 { (*Fts5ExprNode)(unsafe.Pointer(pRet)).FxNext = uintptr(0) - (*Fts5ExprNode)(unsafe.Pointer(pRet)).FeType = 0 + (*Fts5ExprNode)(unsafe.Pointer(pRet)).FeType = FTS5_EOF } } - if (*Fts5Config)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail != 0 { - var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(0)*8)) + if (*Fts5Config)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail != FTS5_DETAIL_FULL { + var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */))) if (((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase != 1) || ((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 1)) || - (((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0) && ((*Fts5ExprTerm)(unsafe.Pointer((pPhrase+32 /* &.aTerm */)+uintptr(0)*32)).FbFirst != 0)) { + (((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0) && ((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FbFirst != 0)) { - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 1 + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR (*Fts5Parse)(unsafe.Pointer(pParse)).FzErr = Xsqlite3_mprintf(tls, ts+30596, /* "fts5: %s queries..." */ @@ -168880,18 +166195,18 @@ func sqlite3Fts5ParseImplicitAnd(tls *libc.TLS, pParse uintptr, pLeft uintptr, p sqlite3Fts5ParseNodeFree(tls, pRight) } else { - if (*Fts5ExprNode)(unsafe.Pointer(pLeft)).FeType == 2 { + if (*Fts5ExprNode)(unsafe.Pointer(pLeft)).FeType == FTS5_AND { pPrev = *(*uintptr)(unsafe.Pointer((pLeft + 48 /* &.apChild */) + uintptr(((*Fts5ExprNode)(unsafe.Pointer(pLeft)).FnChild-1))*8)) } else { pPrev = pLeft } - if (*Fts5ExprNode)(unsafe.Pointer(pRight)).FeType == 0 { + if (*Fts5ExprNode)(unsafe.Pointer(pRight)).FeType == FTS5_EOF { sqlite3Fts5ParseNodeFree(tls, pRight) pRet = pLeft (*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase-- - } else if (*Fts5ExprNode)(unsafe.Pointer(pPrev)).FeType == 0 { + } else if (*Fts5ExprNode)(unsafe.Pointer(pPrev)).FeType == FTS5_EOF { var ap uintptr if pPrev == pLeft { @@ -168903,12 +166218,12 @@ func sqlite3Fts5ParseImplicitAnd(tls *libc.TLS, pParse uintptr, pLeft uintptr, p ap = ((*Fts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr((((*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase-1)-(*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pRight)).FpNear)).FnPhrase))*8) - libc.Xmemmove(tls, ap, (ap + uintptr(1)*8), (uint64(unsafe.Sizeof(uintptr(0))) * uint64((*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pRight)).FpNear)).FnPhrase))) + libc.Xmemmove(tls, ap, (ap + 1*8), (uint64(unsafe.Sizeof(uintptr(0))) * uint64((*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pRight)).FpNear)).FnPhrase))) (*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase-- sqlite3Fts5ParseNodeFree(tls, pPrev) } else { - pRet = sqlite3Fts5ParseNode(tls, pParse, 2, pLeft, pRight, uintptr(0)) + pRet = sqlite3Fts5ParseNode(tls, pParse, FTS5_AND, pLeft, pRight, uintptr(0)) } } @@ -168979,7 +166294,7 @@ func fts5ExprPrintTcl(tls *libc.TLS, pConfig uintptr, zNearsetCmd uintptr, pExpr defer tls.Free(72) var zRet uintptr = uintptr(0) - if ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == 9) || ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == 4) { + if ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == FTS5_STRING) || ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == FTS5_TERM) { var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pExpr)).FpNear var i int32 var iTerm int32 @@ -168992,9 +166307,9 @@ func fts5ExprPrintTcl(tls *libc.TLS, pConfig uintptr, zNearsetCmd uintptr, pExpr var aiCol uintptr = (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset + 4 /* &.aiCol */ var nCol int32 = (*Fts5Colset)(unsafe.Pointer((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset)).FnCol if nCol == 1 { - zRet = fts5PrintfAppend(tls, zRet, ts+30657 /* "-col %d " */, libc.VaList(bp+8, *(*int32)(unsafe.Pointer(aiCol + uintptr(0)*4)))) + zRet = fts5PrintfAppend(tls, zRet, ts+30657 /* "-col %d " */, libc.VaList(bp+8, *(*int32)(unsafe.Pointer(aiCol)))) } else { - zRet = fts5PrintfAppend(tls, zRet, ts+30666 /* "-col {%d" */, libc.VaList(bp+16, *(*int32)(unsafe.Pointer(aiCol + uintptr(0)*4)))) + zRet = fts5PrintfAppend(tls, zRet, ts+30666 /* "-col {%d" */, libc.VaList(bp+16, *(*int32)(unsafe.Pointer(aiCol)))) for i = 1; i < (*Fts5Colset)(unsafe.Pointer((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset)).FnCol; i++ { zRet = fts5PrintfAppend(tls, zRet, ts+30675 /* " %d" */, libc.VaList(bp+24, *(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4)))) } @@ -169046,11 +166361,11 @@ func fts5ExprPrintTcl(tls *libc.TLS, pConfig uintptr, zNearsetCmd uintptr, pExpr var zOp uintptr = uintptr(0) var i int32 switch (*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType { - case 2: + case FTS5_AND: zOp = ts + 27251 /* "AND" */ break fallthrough - case 3: + case FTS5_NOT: zOp = ts + 30505 /* "NOT" */ break fallthrough @@ -169082,13 +166397,13 @@ func fts5ExprPrint(tls *libc.TLS, pConfig uintptr, pExpr uintptr) uintptr { /* s var zRet uintptr = uintptr(0) if (*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == 0 { return Xsqlite3_mprintf(tls, ts+30704 /* "\"\"" */, 0) - } else if ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == 9) || ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == 4) { + } else if ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == FTS5_STRING) || ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == FTS5_TERM) { var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pExpr)).FpNear var i int32 var iTerm int32 if (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset != 0 { - var iCol int32 = *(*int32)(unsafe.Pointer(((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset + 4 /* &.aiCol */) + uintptr(0)*4)) + var iCol int32 = *(*int32)(unsafe.Pointer(((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset + 4 /* &.aiCol */))) zRet = fts5PrintfAppend(tls, zRet, ts+30707 /* "%s : " */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FazCol + uintptr(iCol)*8)))) if zRet == uintptr(0) { return uintptr(0) @@ -169140,11 +166455,11 @@ func fts5ExprPrint(tls *libc.TLS, pConfig uintptr, pExpr uintptr) uintptr { /* s var i int32 switch (*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType { - case 2: + case FTS5_AND: zOp = ts + 18855 /* " AND " */ break fallthrough - case 3: + case FTS5_NOT: zOp = ts + 30729 /* " NOT " */ break fallthrough @@ -169161,7 +166476,7 @@ func fts5ExprPrint(tls *libc.TLS, pConfig uintptr, pExpr uintptr) uintptr { /* s zRet = uintptr(0) } else { var e int32 = (*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pExpr + 48 /* &.apChild */) + uintptr(i)*8)))).FeType - var b int32 = (libc.Bool32(((e != 9) && (e != 4)) && (e != 0))) + var b int32 = (libc.Bool32(((e != FTS5_STRING) && (e != FTS5_TERM)) && (e != FTS5_EOF))) zRet = fts5PrintfAppend(tls, zRet, ts+30740, /* "%s%s%z%s" */ libc.VaList(bp+32, func() uintptr { if i == 0 { @@ -169223,7 +166538,7 @@ func fts5ExprFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr, bT } if (bTcl != 0) && (nArg > 1) { - zNearsetCmd = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) + zNearsetCmd = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) iArg = 2 } @@ -169233,9 +166548,9 @@ func fts5ExprFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr, bT Xsqlite3_result_error_nomem(tls, pCtx) return } - *(*uintptr)(unsafe.Pointer(azConfig + uintptr(0)*8)) = uintptr(0) - *(*uintptr)(unsafe.Pointer(azConfig + uintptr(1)*8)) = ts + 5282 /* "main" */ - *(*uintptr)(unsafe.Pointer(azConfig + uintptr(2)*8)) = ts + 9384 /* "tbl" */ + *(*uintptr)(unsafe.Pointer(azConfig)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(azConfig + 1*8)) = ts + 5282 /* "main" */ + *(*uintptr)(unsafe.Pointer(azConfig + 2*8)) = ts + 9384 /* "tbl" */ for i = 3; iArg < nArg; iArg++ { var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(iArg)*8))) *(*uintptr)(unsafe.Pointer(azConfig + uintptr(libc.PostIncInt32(&i, 1))*8)) = func() uintptr { @@ -169246,16 +166561,16 @@ func fts5ExprFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr, bT }() } - zExpr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + zExpr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))) if zExpr == uintptr(0) { zExpr = ts + 703 /* "" */ } rc = sqlite3Fts5ConfigParse(tls, pGlobal, db, nConfig, azConfig, bp+8 /* &pConfig */, bp+16 /* &zErr */) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5ExprNew(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)), (*Fts5Config)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)))).FnCol, zExpr, bp+24 /* &pExpr */, bp+16 /* &zErr */) } - if rc == 0 { + if rc == SQLITE_OK { var zText uintptr if (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pExpr */)))).FpRoot)).FxNext == uintptr(0) { zText = Xsqlite3_mprintf(tls, ts+703 /* "" */, 0) @@ -169265,14 +166580,14 @@ func fts5ExprFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr, bT zText = fts5ExprPrint(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)), (*Fts5Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pExpr */)))).FpRoot) } if zText == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { Xsqlite3_result_text(tls, pCtx, zText, -1, libc.UintptrFromInt32(-1)) Xsqlite3_free(tls, zText) } } - if rc != 0 { + if rc != SQLITE_OK { if *(*uintptr)(unsafe.Pointer(bp + 16 /* zErr */)) != 0 { Xsqlite3_result_error(tls, pCtx, *(*uintptr)(unsafe.Pointer(bp + 16 /* zErr */)), -1) Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* zErr */))) @@ -169312,7 +166627,7 @@ func fts5ExprIsAlnum(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) { / sqlite3Fts5UnicodeCatParse(tls, ts+30873 /* "L*" */, bp /* &aArr[0] */) sqlite3Fts5UnicodeCatParse(tls, ts+30876 /* "N*" */, bp /* &aArr[0] */) sqlite3Fts5UnicodeCatParse(tls, ts+30879 /* "Co" */, bp /* &aArr[0] */) - iCode = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + iCode = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal))) Xsqlite3_result_int(tls, pCtx, int32(*(*U8)(unsafe.Pointer(bp /* &aArr[0] */ + uintptr(sqlite3Fts5UnicodeCategory(tls, U32(iCode))))))) } @@ -169323,9 +166638,9 @@ func fts5ExprFold(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) { /* s } else { var iCode int32 var bRemoveDiacritics int32 = 0 - iCode = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + iCode = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal))) if nArg == 2 { - bRemoveDiacritics = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) + bRemoveDiacritics = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) } Xsqlite3_result_int(tls, pCtx, sqlite3Fts5UnicodeFold(tls, iCode, bRemoveDiacritics)) } @@ -169338,34 +166653,26 @@ func sqlite3Fts5ExprInit(tls *libc.TLS, pGlobal uintptr, db uintptr) int32 { /* defer tls.Free(64) *(*[4]Fts5ExprFunc)(unsafe.Pointer(bp /* aFunc */)) = [4]Fts5ExprFunc{ - { - Fz: ts + 30812, /* "fts5_expr" */ - Fx: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, int32, uintptr) - }{fts5ExprFunctionHr}))}, - { - Fz: ts + 30798, /* "fts5_expr_tcl" */ - Fx: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, int32, uintptr) - }{fts5ExprFunctionTcl}))}, - { - Fz: ts + 30930, /* "fts5_isalnum" */ - Fx: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, int32, uintptr) - }{fts5ExprIsAlnum}))}, - { - Fz: ts + 30943, /* "fts5_fold" */ - Fx: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, int32, uintptr) - }{fts5ExprFold}))}, + {Fz: ts + 30812 /* "fts5_expr" */, Fx: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{fts5ExprFunctionHr}))}, + {Fz: ts + 30798 /* "fts5_expr_tcl" */, Fx: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{fts5ExprFunctionTcl}))}, + {Fz: ts + 30930 /* "fts5_isalnum" */, Fx: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{fts5ExprIsAlnum}))}, + {Fz: ts + 30943 /* "fts5_fold" */, Fx: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{fts5ExprFold}))}, } var i int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var pCtx uintptr = pGlobal - for i = 0; (rc == 0) && (i < (int32(uint64(unsafe.Sizeof([4]Fts5ExprFunc{})) / uint64(unsafe.Sizeof(Fts5ExprFunc{}))))); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (int32(uint64(unsafe.Sizeof([4]Fts5ExprFunc{})) / uint64(unsafe.Sizeof(Fts5ExprFunc{}))))); i++ { var p uintptr = (bp /* &aFunc */ + uintptr(i)*16) - rc = Xsqlite3_create_function(tls, db, (*Fts5ExprFunc)(unsafe.Pointer(p)).Fz, -1, 1, pCtx, (*Fts5ExprFunc)(unsafe.Pointer(p)).Fx, uintptr(0), uintptr(0)) + rc = Xsqlite3_create_function(tls, db, (*Fts5ExprFunc)(unsafe.Pointer(p)).Fz, -1, SQLITE_UTF8, pCtx, (*Fts5ExprFunc)(unsafe.Pointer(p)).Fx, uintptr(0), uintptr(0)) } // Avoid warnings indicating that sqlite3Fts5ParserTrace() and @@ -169461,10 +166768,10 @@ func fts5ExprPopulatePoslistsCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToke _ = iUnused1 _ = iUnused2 - if nToken > 32768 { - nToken = 32768 + if nToken > FTS5_MAX_TOKEN_SIZE { + nToken = FTS5_MAX_TOKEN_SIZE } - if (tflags & 0x0001) == 0 { + if (tflags & FTS5_TOKEN_COLOCATED) == 0 { (*Fts5ExprCtx)(unsafe.Pointer(p)).FiOff++ } for i = 0; i < (*Fts5Expr)(unsafe.Pointer(pExpr)).FnPhrase; i++ { @@ -169472,7 +166779,7 @@ func fts5ExprPopulatePoslistsCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToke if (*Fts5PoslistPopulator)(unsafe.Pointer((*Fts5ExprCtx)(unsafe.Pointer(p)).FaPopulator+uintptr(i)*16)).FbOk == 0 { continue } - for pTerm = ((*(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*8)) + 32 /* &.aTerm */) + uintptr(0)*32); pTerm != 0; pTerm = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym { + for pTerm = (*(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*8)) + 32 /* &.aTerm */); pTerm != 0; pTerm = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym { var nTerm int32 = int32(libc.Xstrlen(tls, (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FzTerm)) if ((nTerm == nToken) || ((nTerm < nToken) && ((*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FbPrefix != 0))) && (libc.Xmemcmp(tls, (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FzTerm, pToken, uint64(nTerm)) == 0) { @@ -169485,7 +166792,7 @@ func fts5ExprPopulatePoslistsCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToke } } } - return 0 + return SQLITE_OK } func sqlite3Fts5ExprPopulatePoslists(tls *libc.TLS, pConfig uintptr, pExpr uintptr, aPopulator uintptr, iCol int32, z uintptr, n int32) int32 { /* sqlite3.c:215666:12: */ @@ -169511,14 +166818,14 @@ func sqlite3Fts5ExprPopulatePoslists(tls *libc.TLS, pConfig uintptr, pExpr uintp } return sqlite3Fts5Tokenize(tls, pConfig, - 0x0004, z, n, bp /* &sCtx */, *(*uintptr)(unsafe.Pointer(&struct { + FTS5_TOKENIZE_DOCUMENT, z, n, bp /* &sCtx */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5ExprPopulatePoslistsCb}))) } func fts5ExprClearPoslists(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:215696:13: */ - if ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == 4) || ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == 9) { - (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */) + uintptr(0)*8)))).Fposlist.Fn = 0 + if ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_TERM) || ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_STRING) { + (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */))))).Fposlist.Fn = 0 } else { var i int32 for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ { @@ -169531,12 +166838,12 @@ func fts5ExprCheckPoslists(tls *libc.TLS, pNode uintptr, iRowid I64) int32 { /* (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = iRowid (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 0 switch (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType { - case 4: + case FTS5_TERM: fallthrough - case 9: - return (libc.Bool32((*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */) + uintptr(0)*8)))).Fposlist.Fn > 0)) + case FTS5_STRING: + return (libc.Bool32((*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */))))).Fposlist.Fn > 0)) - case 2: + case FTS5_AND: { var i int32 for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ { @@ -169549,7 +166856,7 @@ func fts5ExprCheckPoslists(tls *libc.TLS, pNode uintptr, iRowid I64) int32 { /* } - case 1: + case FTS5_OR: { var i int32 var bRet int32 = 0 @@ -169565,8 +166872,8 @@ func fts5ExprCheckPoslists(tls *libc.TLS, pNode uintptr, iRowid I64) int32 { /* default: { - if (0 == fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)), iRowid)) || - (0 != fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(1)*8)), iRowid)) { + if (0 == fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))), iRowid)) || + (0 != fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + 1*8)), iRowid)) { fts5ExprClearPoslists(tls, pNode) return 0 } @@ -169585,19 +166892,19 @@ func sqlite3Fts5ExprCheckPoslists(tls *libc.TLS, pExpr uintptr, iRowid I64) { /* func sqlite3Fts5ExprPhraseCollist(tls *libc.TLS, pExpr uintptr, iPhrase int32, ppCollist uintptr, pnCollist uintptr) int32 { /* sqlite3.c:215758:12: */ var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*8)) var pNode uintptr = (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FpNode - var rc int32 = 0 + var rc int32 = SQLITE_OK if (((*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof == 0) && ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid == (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpRoot)).FiRowid)) && ((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn > 0) { - var pTerm uintptr = ((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32) + var pTerm uintptr = (pPhrase + 32 /* &.aTerm */) if (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0 { - var pBuf uintptr = ((*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym + uintptr(1)*32) + var pBuf uintptr = ((*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym + 1*32) rc = fts5ExprSynonymList(tls, pTerm, (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid, pBuf, ppCollist, pnCollist) } else { - *(*uintptr)(unsafe.Pointer(ppCollist)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32)).FpIter)).FpData - *(*int32)(unsafe.Pointer(pnCollist)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32)).FpIter)).FnData + *(*uintptr)(unsafe.Pointer(ppCollist)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FpIter)).FpData + *(*int32)(unsafe.Pointer(pnCollist)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FpIter)).FnData } } else { *(*uintptr)(unsafe.Pointer(ppCollist)) = uintptr(0) @@ -169657,12 +166964,12 @@ type Fts5HashEntry = Fts5HashEntry1 /* sqlite3.c:215811:30 */ // Allocate a new hash table. func sqlite3Fts5HashNew(tls *libc.TLS, pConfig uintptr, ppNew uintptr, pnByte uintptr) int32 { /* sqlite3.c:215877:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pNew uintptr *(*uintptr)(unsafe.Pointer(ppNew)) = libc.AssignUintptr(&pNew, Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5Hash{})))) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var nByte Sqlite3_int64 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(Fts5Hash{}))) @@ -169675,7 +166982,7 @@ func sqlite3Fts5HashNew(tls *libc.TLS, pConfig uintptr, ppNew uintptr, pnByte ui if (*Fts5Hash)(unsafe.Pointer(pNew)).FaSlot == uintptr(0) { Xsqlite3_free(tls, pNew) *(*uintptr)(unsafe.Pointer(ppNew)) = uintptr(0) - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, (*Fts5Hash)(unsafe.Pointer(pNew)).FaSlot, 0, Size_t(nByte)) } @@ -169735,7 +167042,7 @@ func fts5HashResize(tls *libc.TLS, pHash uintptr) int32 { /* sqlite3.c:215954:12 apNew = Xsqlite3_malloc64(tls, (uint64(uint64(nNew) * uint64(unsafe.Sizeof(uintptr(0)))))) if !(apNew != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, apNew, 0, (uint64(nNew) * uint64(unsafe.Sizeof(uintptr(0))))) @@ -169744,8 +167051,8 @@ func fts5HashResize(tls *libc.TLS, pHash uintptr) int32 { /* sqlite3.c:215954:12 var iHash uint32 var p uintptr = *(*uintptr)(unsafe.Pointer(apOld + uintptr(i)*8)) *(*uintptr)(unsafe.Pointer(apOld + uintptr(i)*8)) = (*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext - iHash = fts5HashKey(tls, nNew, ((p) + uintptr(1)*48), - int32(libc.Xstrlen(tls, ((p)+uintptr(1)*48)))) + iHash = fts5HashKey(tls, nNew, ((p) + 1*48), + int32(libc.Xstrlen(tls, ((p)+1*48)))) (*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext = *(*uintptr)(unsafe.Pointer(apNew + uintptr(iHash)*8)) *(*uintptr)(unsafe.Pointer(apNew + uintptr(iHash)*8)) = p } @@ -169754,7 +167061,7 @@ func fts5HashResize(tls *libc.TLS, pHash uintptr) int32 { /* sqlite3.c:215954:12 Xsqlite3_free(tls, apOld) (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot = nNew (*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot = apNew - return 0 + return SQLITE_OK } func fts5HashAddPoslistSize(tls *libc.TLS, pHash uintptr, p uintptr, p2 uintptr) int32 { /* sqlite3.c:215982:12: */ @@ -169767,7 +167074,7 @@ func fts5HashAddPoslistSize(tls *libc.TLS, pHash uintptr, p uintptr, p2 uintptr) pPtr = p } var nData int32 = (*Fts5HashEntry)(unsafe.Pointer(p)).FnData - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == 1 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_NONE { if (*Fts5HashEntry)(unsafe.Pointer(p)).FbDel != 0 { *(*U8)(unsafe.Pointer(pPtr + uintptr(libc.PostIncInt32(&nData, 1)))) = U8(0x00) @@ -169813,15 +167120,15 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, var nIncr int32 = 0 // Amount to increment (*pHash->pnByte) by var bNew int32 // If non-delete entry should be written - bNew = (libc.Bool32((*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == 0)) + bNew = (libc.Bool32((*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL)) // Attempt to locate an existing hash entry iHash = fts5HashKey2(tls, (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot, U8(bByte), pToken, nToken) for p = *(*uintptr)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)); p != 0; p = (*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext { - var zKey uintptr = ((p) + uintptr(1)*48) - if ((int32(*(*int8)(unsafe.Pointer(zKey + uintptr(0)))) == int32(bByte)) && + var zKey uintptr = ((p) + 1*48) + if ((int32(*(*int8)(unsafe.Pointer(zKey))) == int32(bByte)) && ((*Fts5HashEntry)(unsafe.Pointer(p)).FnKey == nToken)) && - (libc.Xmemcmp(tls, (zKey+uintptr(1)), pToken, uint64(nToken)) == 0) { + (libc.Xmemcmp(tls, (zKey+1), pToken, uint64(nToken)) == 0) { break } } @@ -169838,7 +167145,7 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, // Grow the Fts5Hash.aSlot[] array if necessary. if ((*Fts5Hash)(unsafe.Pointer(pHash)).FnEntry * 2) >= (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot { var rc int32 = fts5HashResize(tls, pHash) - if rc != 0 { + if rc != SQLITE_OK { return rc } iHash = fts5HashKey2(tls, (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot, U8(bByte), pToken, nToken) @@ -169847,13 +167154,13 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, // Allocate new Fts5HashEntry and add it to the hash table. p = Xsqlite3_malloc64(tls, uint64(nByte)) if !(p != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(Fts5HashEntry{}))) (*Fts5HashEntry)(unsafe.Pointer(p)).FnAlloc = int32(nByte) - zKey = ((p) + uintptr(1)*48) - *(*int8)(unsafe.Pointer(zKey + uintptr(0))) = bByte - libc.Xmemcpy(tls, (zKey + uintptr(1)), pToken, uint64(nToken)) + zKey = ((p) + 1*48) + *(*int8)(unsafe.Pointer(zKey)) = bByte + libc.Xmemcpy(tls, (zKey + 1), pToken, uint64(nToken)) (*Fts5HashEntry)(unsafe.Pointer(p)).FnKey = nToken *(*int8)(unsafe.Pointer(zKey + uintptr((nToken + 1)))) = int8(0) @@ -169867,10 +167174,10 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, (*Fts5HashEntry)(unsafe.Pointer(p)).FiRowid = iRowid (*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = (*Fts5HashEntry)(unsafe.Pointer(p)).FnData - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail != 1 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail != FTS5_DETAIL_NONE { *(*int32)(unsafe.Pointer(p + 24 /* &.nData */)) += (1) (*Fts5HashEntry)(unsafe.Pointer(p)).FiCol = func() int16 { - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == 0 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { return int16(0) } return int16(-1) @@ -169895,7 +167202,7 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, var pp uintptr pNew = Xsqlite3_realloc64(tls, p, uint64(nNew)) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Fts5HashEntry)(unsafe.Pointer(pNew)).FnAlloc = int32(nNew) for pp = ((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8); *(*uintptr)(unsafe.Pointer(pp)) != p; pp = (*(*uintptr)(unsafe.Pointer(pp)) /* &.pHashNext */) { @@ -169916,10 +167223,10 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, (*Fts5HashEntry)(unsafe.Pointer(p)).FiRowid = iRowid bNew = 1 (*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = (*Fts5HashEntry)(unsafe.Pointer(p)).FnData - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail != 1 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail != FTS5_DETAIL_NONE { *(*int32)(unsafe.Pointer(p + 24 /* &.nData */)) += (1) (*Fts5HashEntry)(unsafe.Pointer(p)).FiCol = func() int16 { - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == 0 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { return int16(0) } return int16(-1) @@ -169929,13 +167236,13 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, } if iCol >= 0 { - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == 1 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_NONE { (*Fts5HashEntry)(unsafe.Pointer(p)).FbContent = U8(1) } else { // Append a new column value, if necessary if iCol != int32((*Fts5HashEntry)(unsafe.Pointer(p)).FiCol) { - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == 0 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { *(*U8)(unsafe.Pointer(pPtr + uintptr(libc.PostIncInt32(&(*Fts5HashEntry)(unsafe.Pointer(p)).FnData, 1)))) = U8(0x01) *(*int32)(unsafe.Pointer(p + 24 /* &.nData */)) += (sqlite3Fts5PutVarint(tls, (pPtr + uintptr((*Fts5HashEntry)(unsafe.Pointer(p)).FnData)), uint64(iCol))) (*Fts5HashEntry)(unsafe.Pointer(p)).FiCol = I16(iCol) @@ -169959,7 +167266,7 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, nIncr = nIncr + ((*Fts5HashEntry)(unsafe.Pointer(p)).FnData) *(*int32)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FpnByte)) += (nIncr) - return 0 + return SQLITE_OK } // Arguments pLeft and pRight point to linked-lists of hash-entry objects, @@ -169983,8 +167290,8 @@ func fts5HashEntryMerge(tls *libc.TLS, pLeft uintptr, pRight uintptr) uintptr { p1 = uintptr(0) } else { var i int32 = 0 - var zKey1 uintptr = ((p1) + uintptr(1)*48) - var zKey2 uintptr = ((p2) + uintptr(1)*48) + var zKey1 uintptr = ((p1) + 1*48) + var zKey2 uintptr = ((p2) + 1*48) for int32(*(*int8)(unsafe.Pointer(zKey1 + uintptr(i)))) == int32(*(*int8)(unsafe.Pointer(zKey2 + uintptr(i)))) { i++ } @@ -170021,7 +167328,7 @@ func fts5HashEntrySort(tls *libc.TLS, pHash uintptr, pTerm uintptr, nTerm int32, *(*uintptr)(unsafe.Pointer(ppSorted)) = uintptr(0) ap = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(uintptr(0))) * uint64(nMergeSlot)))) if !(ap != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, ap, 0, (uint64(unsafe.Sizeof(uintptr(0))) * uint64(nMergeSlot))) @@ -170029,7 +167336,7 @@ func fts5HashEntrySort(tls *libc.TLS, pHash uintptr, pTerm uintptr, nTerm int32, var pIter uintptr for pIter = *(*uintptr)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iSlot)*8)); pIter != 0; pIter = (*Fts5HashEntry)(unsafe.Pointer(pIter)).FpHashNext { if (pTerm == uintptr(0)) || - ((((*Fts5HashEntry)(unsafe.Pointer(pIter)).FnKey + 1) >= nTerm) && (0 == libc.Xmemcmp(tls, ((pIter)+uintptr(1)*48), pTerm, uint64(nTerm)))) { + ((((*Fts5HashEntry)(unsafe.Pointer(pIter)).FnKey + 1) >= nTerm) && (0 == libc.Xmemcmp(tls, ((pIter)+1*48), pTerm, uint64(nTerm)))) { var pEntry uintptr = pIter (*Fts5HashEntry)(unsafe.Pointer(pEntry)).FpScanNext = uintptr(0) for i = 0; *(*uintptr)(unsafe.Pointer(ap + uintptr(i)*8)) != 0; i++ { @@ -170049,7 +167356,7 @@ func fts5HashEntrySort(tls *libc.TLS, pHash uintptr, pTerm uintptr, nTerm int32, (*Fts5Hash)(unsafe.Pointer(pHash)).FnEntry = 0 Xsqlite3_free(tls, ap) *(*uintptr)(unsafe.Pointer(ppSorted)) = pList - return 0 + return SQLITE_OK } // Query the hash table for a doclist associated with term pTerm/nTerm. @@ -170059,7 +167366,7 @@ func sqlite3Fts5HashQuery(tls *libc.TLS, pHash uintptr, nPre int32, pTerm uintpt var p uintptr for p = *(*uintptr)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)); p != 0; p = (*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext { - zKey = ((p) + uintptr(1)*48) + zKey = ((p) + 1*48) if (nTerm == ((*Fts5HashEntry)(unsafe.Pointer(p)).FnKey + 1)) && (libc.Xmemcmp(tls, zKey, pTerm, uint64(nTerm)) == 0) { break @@ -170077,14 +167384,14 @@ func sqlite3Fts5HashQuery(tls *libc.TLS, pHash uintptr, nPre int32, pTerm uintpt *(*int32)(unsafe.Pointer(pnDoclist)) = nList } else { *(*int32)(unsafe.Pointer(pnDoclist)) = 0 - return 7 + return SQLITE_NOMEM } } else { *(*uintptr)(unsafe.Pointer(ppOut)) = uintptr(0) *(*int32)(unsafe.Pointer(pnDoclist)) = 0 } - return 0 + return SQLITE_OK } func sqlite3Fts5HashScanInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32) int32 { /* sqlite3.c:216317:12: */ @@ -170103,7 +167410,7 @@ func sqlite3Fts5HashScanEof(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:21632 func sqlite3Fts5HashScanEntry(tls *libc.TLS, pHash uintptr, pzTerm uintptr, ppDoclist uintptr, pnDoclist uintptr) { /* sqlite3.c:216333:13: */ var p uintptr if libc.AssignUintptr(&p, (*Fts5Hash)(unsafe.Pointer(pHash)).FpScan) != 0 { - var zKey uintptr = ((p) + uintptr(1)*48) + var zKey uintptr = ((p) + 1*48) var nTerm int32 = int32(libc.Xstrlen(tls, zKey)) fts5HashAddPoslistSize(tls, pHash, p, uintptr(0)) *(*uintptr)(unsafe.Pointer(pzTerm)) = zKey @@ -170672,12 +167979,12 @@ type Fts5CResult1 = struct { type Fts5CResult = Fts5CResult1 /* sqlite3.c:216729:28 */ func fts5PutU16(tls *libc.TLS, aOut uintptr, iVal U16) { /* sqlite3.c:216908:13: */ - *(*U8)(unsafe.Pointer(aOut + uintptr(0))) = (U8(int32(iVal) >> 8)) - *(*U8)(unsafe.Pointer(aOut + uintptr(1))) = (U8(int32(iVal) & 0xFF)) + *(*U8)(unsafe.Pointer(aOut)) = (U8(int32(iVal) >> 8)) + *(*U8)(unsafe.Pointer(aOut + 1)) = (U8(int32(iVal) & 0xFF)) } func fts5GetU16(tls *libc.TLS, aIn uintptr) U16 { /* sqlite3.c:216913:12: */ - return (U16((int32(U16(*(*U8)(unsafe.Pointer(aIn + uintptr(0))))) << 8) + int32(*(*U8)(unsafe.Pointer(aIn + uintptr(1)))))) + return (U16((int32(U16(*(*U8)(unsafe.Pointer(aIn)))) << 8) + int32(*(*U8)(unsafe.Pointer(aIn + 1))))) } // Allocate and return a buffer at least nByte bytes in size. @@ -170748,8 +168055,8 @@ func sqlite3Fts5IndexCloseReader(tls *libc.TLS, p uintptr) { /* sqlite3.c:216970 // Fts5Index object. func fts5DataRead(tls *libc.TLS, p uintptr, iRowid I64) uintptr { /* sqlite3.c:216984:17: */ var pRet uintptr = uintptr(0) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - var rc int32 = 0 + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var rc int32 = SQLITE_OK if (*Fts5Index)(unsafe.Pointer(p)).FpReader != 0 { // This call may return SQLITE_ABORT if there has been a savepoint @@ -170760,17 +168067,17 @@ func fts5DataRead(tls *libc.TLS, p uintptr, iRowid I64) uintptr { /* sqlite3.c:2 rc = Xsqlite3_blob_reopen(tls, pBlob, iRowid) (*Fts5Index)(unsafe.Pointer(p)).FpReader = pBlob - if rc != 0 { + if rc != SQLITE_OK { sqlite3Fts5IndexCloseReader(tls, p) } - if rc == 4 { - rc = 0 + if rc == SQLITE_ABORT { + rc = SQLITE_OK } } // If the blob handle is not open at this point, open it and seek // to the requested entry. - if ((*Fts5Index)(unsafe.Pointer(p)).FpReader == uintptr(0)) && (rc == 0) { + if ((*Fts5Index)(unsafe.Pointer(p)).FpReader == uintptr(0)) && (rc == SQLITE_OK) { var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig rc = Xsqlite3_blob_open(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Index)(unsafe.Pointer(p)).FzDataTbl, ts+30953 /* "block" */, iRowid, 0, (p + 56 /* &.pReader */)) @@ -170781,33 +168088,33 @@ func fts5DataRead(tls *libc.TLS, p uintptr, iRowid I64) uintptr { /* sqlite3.c:2 // All the reasons those functions might return SQLITE_ERROR - missing // table, missing row, non-blob/text in block column - indicate // backing store corruption. - if rc == 1 { - rc = (11 | (int32(1) << 8)) + if rc == SQLITE_ERROR { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } - if rc == 0 { + if rc == SQLITE_OK { var aOut uintptr = uintptr(0) // Read blob data into this buffer var nByte int32 = Xsqlite3_blob_bytes(tls, (*Fts5Index)(unsafe.Pointer(p)).FpReader) - var nAlloc Sqlite3_int64 = (Sqlite3_int64((uint64(unsafe.Sizeof(Fts5Data{})) + uint64(nByte)) + uint64(20))) + var nAlloc Sqlite3_int64 = (Sqlite3_int64((uint64(unsafe.Sizeof(Fts5Data{})) + uint64(nByte)) + FTS5_DATA_PADDING)) pRet = Xsqlite3_malloc64(tls, uint64(nAlloc)) if pRet != 0 { (*Fts5Data)(unsafe.Pointer(pRet)).Fnn = nByte - aOut = libc.AssignPtrUintptr(pRet /* &.p */, (pRet + uintptr(1)*16)) + aOut = libc.AssignPtrUintptr(pRet /* &.p */, (pRet + 1*16)) } else { - rc = 7 + rc = SQLITE_NOMEM } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_blob_read(tls, (*Fts5Index)(unsafe.Pointer(p)).FpReader, aOut, nByte, 0) } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_free(tls, pRet) pRet = uintptr(0) } else { // TODO1: Fix this *(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer(pRet)).Fp + uintptr(nByte))) = U8(0x00) *(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer(pRet)).Fp + uintptr((nByte + 1)))) = U8(0x00) - (*Fts5Data)(unsafe.Pointer(pRet)).FszLeaf = int32(fts5GetU16(tls, ((*Fts5Data)(unsafe.Pointer(pRet)).Fp + uintptr(2)))) + (*Fts5Data)(unsafe.Pointer(pRet)).FszLeaf = int32(fts5GetU16(tls, ((*Fts5Data)(unsafe.Pointer(pRet)).Fp + 2))) } } (*Fts5Index)(unsafe.Pointer(p)).Frc = rc @@ -170827,7 +168134,7 @@ func fts5LeafRead(tls *libc.TLS, p uintptr, iRowid I64) uintptr { /* sqlite3.c:2 var pRet uintptr = fts5DataRead(tls, p, iRowid) if pRet != 0 { if ((*Fts5Data)(unsafe.Pointer(pRet)).Fnn < 4) || ((*Fts5Data)(unsafe.Pointer(pRet)).FszLeaf > (*Fts5Data)(unsafe.Pointer(pRet)).Fnn) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) fts5DataRelease(tls, pRet) pRet = uintptr(0) } @@ -170836,13 +168143,13 @@ func fts5LeafRead(tls *libc.TLS, p uintptr, iRowid I64) uintptr { /* sqlite3.c:2 } func fts5IndexPrepareStmt(tls *libc.TLS, p uintptr, ppStmt uintptr, zSql uintptr) int32 { /* sqlite3.c:217073:12: */ - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { if zSql != 0 { (*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_prepare_v3(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fdb, zSql, -1, - (uint32(0x01 | 0x04)), + (uint32(SQLITE_PREPARE_PERSISTENT | SQLITE_PREPARE_NO_VTAB)), ppStmt, uintptr(0)) } else { - (*Fts5Index)(unsafe.Pointer(p)).Frc = 7 + (*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } } Xsqlite3_free(tls, zSql) @@ -170854,7 +168161,7 @@ func fts5DataWrite(tls *libc.TLS, p uintptr, iRowid I64, pData uintptr, nData in bp := tls.Alloc(16) defer tls.Free(16) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { return } @@ -170882,7 +168189,7 @@ func fts5DataDelete(tls *libc.TLS, p uintptr, iFirst I64, iLast I64) { /* sqlite bp := tls.Alloc(16) defer tls.Free(16) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { return } @@ -170907,8 +168214,8 @@ func fts5DataRemoveSegment(tls *libc.TLS, p uintptr, iSegid int32) { /* sqlite3. bp := tls.Alloc(16) defer tls.Free(16) - var iFirst I64 = (((((I64(iSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (int64(0))) - var iLast I64 = ((((((I64(iSegid + 1)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (int64(0))) - int64(1)) + var iFirst I64 = (((((I64(iSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (int64(0))) + var iLast I64 = ((((((I64(iSegid + 1)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (int64(0))) - int64(1)) fts5DataDelete(tls, p, iFirst, iLast) if (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter == uintptr(0) { var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig @@ -170916,7 +168223,7 @@ func fts5DataRemoveSegment(tls *libc.TLS, p uintptr, iSegid int32) { /* sqlite3. ts+31059, /* "DELETE FROM '%q'..." */ libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))) } - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { Xsqlite3_bind_int(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter, 1, iSegid) Xsqlite3_step(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter) (*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter) @@ -170954,7 +168261,7 @@ func fts5StructureDecode(tls *libc.TLS, pData uintptr, nData int32, piCookie uin bp := tls.Alloc(16) defer tls.Free(16) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK var i int32 = 0 var iLvl int32 *(*int32)(unsafe.Pointer(bp /* nLevel */)) = 0 @@ -170972,9 +168279,9 @@ func fts5StructureDecode(tls *libc.TLS, pData uintptr, nData int32, piCookie uin // structure record. i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), bp /* &nLevel */)) i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), bp+4 /* &nSegment */)) - if (((*(*int32)(unsafe.Pointer(bp /* nLevel */)) > 2000) || (*(*int32)(unsafe.Pointer(bp /* nLevel */)) < 0)) || - (*(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) > 2000)) || (*(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) < 0) { - return (11 | (int32(1) << 8)) + if (((*(*int32)(unsafe.Pointer(bp /* nLevel */)) > FTS5_MAX_SEGMENT) || (*(*int32)(unsafe.Pointer(bp /* nLevel */)) < 0)) || + (*(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) > FTS5_MAX_SEGMENT)) || (*(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) < 0) { + return (SQLITE_CORRUPT | (int32(1) << 8)) } nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5Structure{})) + (uint64(unsafe.Sizeof(Fts5StructureLevel{})) * (uint64(*(*int32)(unsafe.Pointer(bp /* nLevel */)) - 1))))) pRet = sqlite3Fts5MallocZero(tls, bp+8 /* &rc */, nByte) @@ -170985,53 +168292,53 @@ func fts5StructureDecode(tls *libc.TLS, pData uintptr, nData int32, piCookie uin (*Fts5Structure)(unsafe.Pointer(pRet)).FnSegment = *(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) i = i + (int32(sqlite3Fts5GetVarint(tls, (pData + uintptr(i)), (pRet + 8 /* &.nWriteCounter */)))) - for iLvl = 0; (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0) && (iLvl < *(*int32)(unsafe.Pointer(bp /* nLevel */))); iLvl++ { + for iLvl = 0; (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK) && (iLvl < *(*int32)(unsafe.Pointer(bp /* nLevel */))); iLvl++ { var pLvl uintptr = ((pRet + 24 /* &.aLevel */) + uintptr(iLvl)*16) *(*int32)(unsafe.Pointer(bp + 12 /* nTotal */)) = 0 var iSeg int32 if i >= nData { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } else { i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), (pLvl /* &.nMerge */))) i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), bp+12 /* &nTotal */)) if *(*int32)(unsafe.Pointer(bp + 12 /* nTotal */)) < (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg = sqlite3Fts5MallocZero(tls, bp+8, /* &rc */ (int64(uint64(*(*int32)(unsafe.Pointer(bp + 12 /* nTotal */))) * uint64(unsafe.Sizeof(Fts5StructureSegment{}))))) *(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) -= *(*int32)(unsafe.Pointer(bp + 12 /* nTotal */)) } - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg = *(*int32)(unsafe.Pointer(bp + 12 /* nTotal */)) for iSeg = 0; iSeg < *(*int32)(unsafe.Pointer(bp + 12 /* nTotal */)); iSeg++ { var pSeg uintptr = ((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSeg)*12) if i >= nData { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) break } i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), (pSeg /* &.iSegid */))) i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), (pSeg + 4 /* &.pgnoFirst */))) i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), (pSeg + 8 /* &.pgnoLast */))) if (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast < (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) break } } if ((iLvl > 0) && ((*Fts5StructureLevel)(unsafe.Pointer(pLvl+libc.UintptrFromInt32(-1)*16)).FnMerge != 0)) && (*(*int32)(unsafe.Pointer(bp + 12 /* nTotal */)) == 0) { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } if (iLvl == (*(*int32)(unsafe.Pointer(bp /* nLevel */)) - 1)) && ((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge != 0) { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } } } - if (*(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) != 0) && (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0) { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + if (*(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) != 0) && (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK) { + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != SQLITE_OK { fts5StructureRelease(tls, pRet) pRet = uintptr(0) } @@ -171043,7 +168350,7 @@ func fts5StructureDecode(tls *libc.TLS, pData uintptr, nData int32, piCookie uin // func fts5StructureAddLevel(tls *libc.TLS, pRc uintptr, ppStruct uintptr) { /* sqlite3.c:217280:13: */ - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var pStruct uintptr = *(*uintptr)(unsafe.Pointer(ppStruct)) var nLevel int32 = (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel var nByte Sqlite3_int64 = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5Structure{})) + (uint64(unsafe.Sizeof(Fts5StructureLevel{})) * (uint64(nLevel + 1))))) @@ -171054,7 +168361,7 @@ func fts5StructureAddLevel(tls *libc.TLS, pRc uintptr, ppStruct uintptr) { /* sq (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel++ *(*uintptr)(unsafe.Pointer(ppStruct)) = pStruct } else { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } } @@ -171062,7 +168369,7 @@ func fts5StructureAddLevel(tls *libc.TLS, pRc uintptr, ppStruct uintptr) { /* sq // Extend level iLvl so that there is room for at least nExtra more // segments. func fts5StructureExtendLevel(tls *libc.TLS, pRc uintptr, pStruct uintptr, iLvl int32, nExtra int32, bInsert int32) { /* sqlite3.c:217304:13: */ - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var pLvl uintptr = ((pStruct + 24 /* &.aLevel */) + uintptr(iLvl)*16) var aNew uintptr var nByte Sqlite3_int64 @@ -171079,7 +168386,7 @@ func fts5StructureExtendLevel(tls *libc.TLS, pRc uintptr, pStruct uintptr, iLvl } (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg = aNew } else { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } } @@ -171094,16 +168401,16 @@ func fts5StructureReadUncached(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c: // Configuration cookie var pData uintptr - pData = fts5DataRead(tls, p, int64(10)) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + pData = fts5DataRead(tls, p, FTS5_STRUCTURE_ROWID) + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { // TODO: Do we need this if the leaf-index is appended? Probably... - libc.Xmemset(tls, ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr((*Fts5Data)(unsafe.Pointer(pData)).Fnn)), 0, uint64(20)) + libc.Xmemset(tls, ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr((*Fts5Data)(unsafe.Pointer(pData)).Fnn)), 0, FTS5_DATA_PADDING) (*Fts5Index)(unsafe.Pointer(p)).Frc = fts5StructureDecode(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp, (*Fts5Data)(unsafe.Pointer(pData)).Fnn, bp /* &iCookie */, bp+8 /* &pRet */) - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (((*Fts5Config)(unsafe.Pointer(pConfig)).Fpgsz == 0) || ((*Fts5Config)(unsafe.Pointer(pConfig)).FiCookie != *(*int32)(unsafe.Pointer(bp /* iCookie */)))) { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (((*Fts5Config)(unsafe.Pointer(pConfig)).Fpgsz == 0) || ((*Fts5Config)(unsafe.Pointer(pConfig)).FiCookie != *(*int32)(unsafe.Pointer(bp /* iCookie */)))) { (*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5ConfigLoad(tls, pConfig, *(*int32)(unsafe.Pointer(bp /* iCookie */))) } fts5DataRelease(tls, pData) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { fts5StructureRelease(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pRet */))) *(*uintptr)(unsafe.Pointer(bp + 8 /* pRet */)) = uintptr(0) } @@ -171118,7 +168425,7 @@ func fts5IndexDataVersion(tls *libc.TLS, p uintptr) I64 { /* sqlite3.c:217357:12 var iVersion I64 = int64(0) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { if (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion == uintptr(0) { (*Fts5Index)(unsafe.Pointer(p)).Frc = fts5IndexPrepareStmt(tls, p, (p + 112 /* &.pDataVersion */), Xsqlite3_mprintf(tls, ts+31099 /* "PRAGMA %Q.data_v..." */, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FzDb))) @@ -171127,7 +168434,7 @@ func fts5IndexDataVersion(tls *libc.TLS, p uintptr) I64 { /* sqlite3.c:217357:12 } } - if 100 == Xsqlite3_step(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion) { + if SQLITE_ROW == Xsqlite3_step(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion) { iVersion = Xsqlite3_column_int64(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion, 0) } (*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion) @@ -171149,12 +168456,12 @@ func fts5StructureRead(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:217388:2 if (*Fts5Index)(unsafe.Pointer(p)).FpStruct == uintptr(0) { (*Fts5Index)(unsafe.Pointer(p)).FiStructVersion = fts5IndexDataVersion(tls, p) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Fts5Index)(unsafe.Pointer(p)).FpStruct = fts5StructureReadUncached(tls, p) } } - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { return uintptr(0) } @@ -171180,7 +168487,7 @@ func fts5StructureWrite(tls *libc.TLS, p uintptr, pStruct uintptr) { /* sqlite3. bp := tls.Alloc(16) defer tls.Free(16) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { // var buf Fts5Buffer at bp, 16 // Buffer to serialize record into var iLvl int32 // Used to iterate through levels @@ -171224,7 +168531,7 @@ func fts5StructureWrite(tls *libc.TLS, p uintptr, pStruct uintptr) { /* sqlite3. } } - fts5DataWrite(tls, p, int64(10), (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn) + fts5DataWrite(tls, p, FTS5_STRUCTURE_ROWID, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn) sqlite3Fts5BufferFree(tls, bp /* &buf */) } } @@ -171280,7 +168587,7 @@ func fts5StructurePromoteTo(tls *libc.TLS, p uintptr, iPromote int32, szPromote // If one or more segments are promoted, the structure object is updated // to reflect this. func fts5StructurePromote(tls *libc.TLS, p uintptr, iLvl int32, pStruct uintptr) { /* sqlite3.c:217577:13: */ - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { var iTst int32 var iPromote int32 = -1 var szPromote int32 = 0 // Promote anything this size or smaller @@ -171337,7 +168644,7 @@ func fts5DlidxLvlNext(tls *libc.TLS, pLvl uintptr) int32 { /* sqlite3.c:217628:1 if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff == 0 { (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff = 1 - *(*int32)(unsafe.Pointer(pLvl + 8 /* &.iOff */)) += (sqlite3Fts5GetVarint32(tls, ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr(1)), (pLvl + 20 /* &.iLeafPgno */))) + *(*int32)(unsafe.Pointer(pLvl + 8 /* &.iOff */)) += (sqlite3Fts5GetVarint32(tls, ((*Fts5Data)(unsafe.Pointer(pData)).Fp + 1), (pLvl + 20 /* &.iLeafPgno */))) *(*int32)(unsafe.Pointer(pLvl + 8 /* &.iOff */)) += (int32(sqlite3Fts5GetVarint(tls, ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff)), (pLvl + 24 /* &.iRowid */)))) (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiFirstOff = (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff } else { @@ -171370,11 +168677,11 @@ func fts5DlidxIterNextR(tls *libc.TLS, p uintptr, pIter uintptr, iLvl int32) int if fts5DlidxLvlNext(tls, pLvl) != 0 { if (iLvl + 1) < (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl { fts5DlidxIterNextR(tls, p, pIter, (iLvl + 1)) - if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl+uintptr(1)*32)).FbEof == 0 { + if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl+1*32)).FbEof == 0 { fts5DataRelease(tls, (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData) libc.Xmemset(tls, pLvl, 0, uint64(unsafe.Sizeof(Fts5DlidxLvl{}))) (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData = fts5DataRead(tls, p, - (((((I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(1))) << (31 + 5))) + ((I64(iLvl)) << (31))) + (I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl + uintptr(1)*32)).FiLeafPgno)))) + (((((I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(1))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + ((I64(iLvl)) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl + 1*32)).FiLeafPgno)))) if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData != 0 { fts5DlidxLvlNext(tls, pLvl) } @@ -171382,7 +168689,7 @@ func fts5DlidxIterNextR(tls *libc.TLS, p uintptr, pIter uintptr, iLvl int32) int } } - return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */) + uintptr(0)*32)).FbEof + return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */))).FbEof } func fts5DlidxIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3.c:217680:12: */ @@ -171403,18 +168710,18 @@ func fts5DlidxIterFirst(tls *libc.TLS, pIter uintptr) int32 { /* sqlite3.c:21769 for i = 0; i < (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl; i++ { fts5DlidxLvlNext(tls, ((pIter + 8 /* &.aLvl */) + uintptr(i)*32)) } - return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */) + uintptr(0)*32)).FbEof + return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */))).FbEof } func fts5DlidxIterEof(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3.c:217704:12: */ - return (libc.Bool32(((*Fts5Index)(unsafe.Pointer(p)).Frc != 0) || ((*Fts5DlidxLvl)(unsafe.Pointer((pIter+8 /* &.aLvl */)+uintptr(0)*32)).FbEof != 0))) + return (libc.Bool32(((*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK) || ((*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */))).FbEof != 0))) } func fts5DlidxIterLast(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:217708:13: */ var i int32 // Advance each level to the last entry on the last page - for i = ((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl - 1); ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (i >= 0); i-- { + for i = ((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl - 1); ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (i >= 0); i-- { var pLvl uintptr = ((pIter + 8 /* &.aLvl */) + uintptr(i)*32) for fts5DlidxLvlNext(tls, pLvl) == 0 { } @@ -171425,7 +168732,7 @@ func fts5DlidxIterLast(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:2 fts5DataRelease(tls, (*Fts5DlidxLvl)(unsafe.Pointer(pChild)).FpData) libc.Xmemset(tls, pChild, 0, uint64(unsafe.Sizeof(Fts5DlidxLvl{}))) (*Fts5DlidxLvl)(unsafe.Pointer(pChild)).FpData = fts5DataRead(tls, p, - (((((I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(1))) << (31 + 5))) + ((I64(i - 1)) << (31))) + (I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiLeafPgno)))) + (((((I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(1))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + ((I64(i - 1)) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiLeafPgno)))) } } } @@ -171499,11 +168806,11 @@ func fts5DlidxIterPrevR(tls *libc.TLS, p uintptr, pIter uintptr, iLvl int32) int if fts5DlidxLvlPrev(tls, pLvl) != 0 { if (iLvl + 1) < (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl { fts5DlidxIterPrevR(tls, p, pIter, (iLvl + 1)) - if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl+uintptr(1)*32)).FbEof == 0 { + if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl+1*32)).FbEof == 0 { fts5DataRelease(tls, (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData) libc.Xmemset(tls, pLvl, 0, uint64(unsafe.Sizeof(Fts5DlidxLvl{}))) (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData = fts5DataRead(tls, p, - (((((I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(1))) << (31 + 5))) + ((I64(iLvl)) << (31))) + (I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl + uintptr(1)*32)).FiLeafPgno)))) + (((((I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(1))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + ((I64(iLvl)) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl + 1*32)).FiLeafPgno)))) if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData != 0 { for fts5DlidxLvlNext(tls, pLvl) == 0 { } @@ -171513,7 +168820,7 @@ func fts5DlidxIterPrevR(tls *libc.TLS, p uintptr, pIter uintptr, iLvl int32) int } } - return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */) + uintptr(0)*32)).FbEof + return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */))).FbEof } func fts5DlidxIterPrev(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3.c:217803:12: */ @@ -171536,27 +168843,27 @@ func fts5DlidxIterInit(tls *libc.TLS, p uintptr, bRev int32, iSegid int32, iLeaf var i int32 var bDone int32 = 0 - for i = 0; ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (bDone == 0); i++ { + for i = 0; ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (bDone == 0); i++ { var nByte Sqlite3_int64 = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5DlidxIter{})) + (uint64(i) * uint64(unsafe.Sizeof(Fts5DlidxLvl{}))))) var pNew uintptr pNew = Xsqlite3_realloc64(tls, pIter, uint64(nByte)) if pNew == uintptr(0) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = 7 + (*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } else { - var iRowid I64 = (((((I64(iSegid)) << ((31 + 5) + 1)) + (I64((int64(1))) << (31 + 5))) + ((I64(i)) << (31))) + (I64(iLeafPg))) + var iRowid I64 = (((((I64(iSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(1))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + ((I64(i)) << (FTS5_DATA_PAGE_B))) + (I64(iLeafPg))) var pLvl uintptr = ((pNew + 8 /* &.aLvl */) + uintptr(i)*32) pIter = pNew libc.Xmemset(tls, pLvl, 0, uint64(unsafe.Sizeof(Fts5DlidxLvl{}))) (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData = fts5DataRead(tls, p, iRowid) - if ((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData != 0) && ((int32(*(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData)).Fp + uintptr(0)))) & 0x0001) == 0) { + if ((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData != 0) && ((int32(*(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData)).Fp))) & 0x0001) == 0) { bDone = 1 } (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl = (i + 1) } } - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid = iSegid if bRev == 0 { fts5DlidxIterFirst(tls, pIter) @@ -171565,7 +168872,7 @@ func fts5DlidxIterInit(tls *libc.TLS, p uintptr, bRev int32, iSegid int32, iLeaf } } - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { fts5DlidxIterFree(tls, pIter) pIter = uintptr(0) } @@ -171574,11 +168881,11 @@ func fts5DlidxIterInit(tls *libc.TLS, p uintptr, bRev int32, iSegid int32, iLeaf } func fts5DlidxIterRowid(tls *libc.TLS, pIter uintptr) I64 { /* sqlite3.c:217867:12: */ - return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */) + uintptr(0)*32)).FiRowid + return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */))).FiRowid } func fts5DlidxIterPgno(tls *libc.TLS, pIter uintptr) int32 { /* sqlite3.c:217870:12: */ - return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */) + uintptr(0)*32)).FiLeafPgno + return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */))).FiLeafPgno } // Load the next leaf page into the segment iterator. @@ -171592,7 +168899,7 @@ func fts5SegIterNextPage(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c (*Fts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf = uintptr(0) } else if (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno <= (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast { (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = fts5LeafRead(tls, p, - (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno)))) + (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno)))) } else { (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0) } @@ -171645,10 +168952,10 @@ func fts5SegIterLoadNPos(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c bp := tls.Alloc(4) defer tls.Free(4) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { var iOff int32 = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset // Offset to read at - if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == 1 { + if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_NONE { var iEod int32 = func() int32 { if ((*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist) < ((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf) { return (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist @@ -171693,8 +169000,8 @@ func fts5SegIterLoadRowid(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3. if iOff >= (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf { fts5SegIterNextPage(tls, p, pIter) if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0) { - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } return } @@ -171729,7 +169036,7 @@ func fts5SegIterLoadTerm(tls *libc.TLS, p uintptr, pIter uintptr, nKeep int32) { iOff = iOff + (sqlite3Fts5GetVarint32(tls, (a + uintptr(iOff)), bp /* &nNew */)) if (((iOff + *(*int32)(unsafe.Pointer(bp /* nNew */))) > (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf) || (nKeep > (*Fts5SegIter)(unsafe.Pointer(pIter)).Fterm.Fn)) || (*(*int32)(unsafe.Pointer(bp /* nNew */)) == 0) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) return } (*Fts5SegIter)(unsafe.Pointer(pIter)).Fterm.Fn = nKeep @@ -171753,11 +169060,11 @@ func fts5SegIterLoadTerm(tls *libc.TLS, p uintptr, pIter uintptr, nKeep int32) { } func fts5SegIterSetNext(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:218031:13: */ - if ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & 0x02) != 0 { + if ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_REVERSE) != 0 { (*Fts5SegIter)(unsafe.Pointer(pIter)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr) }{fts5SegIterNext_Reverse})) - } else if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == 1 { + } else if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_NONE { (*Fts5SegIter)(unsafe.Pointer(pIter)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr) }{fts5SegIterNext_None})) @@ -171785,7 +169092,7 @@ func fts5SegIterInit(tls *libc.TLS, p uintptr, pSeg uintptr, pIter uintptr) { /* return } - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { libc.Xmemset(tls, pIter, 0, uint64(unsafe.Sizeof(Fts5SegIter{}))) fts5SegIterSetNext(tls, p, pIter) (*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg = pSeg @@ -171793,7 +169100,7 @@ func fts5SegIterInit(tls *libc.TLS, p uintptr, pSeg uintptr, pIter uintptr) { /* fts5SegIterNextPage(tls, p, pIter) } - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = 4 (*Fts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = ((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf + 1) @@ -171832,7 +169139,7 @@ func fts5SegIterReverseInitPage(tls *libc.TLS, p uintptr, pIter uintptr) { /* sq for 1 != 0 { *(*I64)(unsafe.Pointer(bp + 8 /* iDelta */)) = int64(0) - if eDetail == 1 { + if eDetail == FTS5_DETAIL_NONE { // todo if (i < n) && (int32(*(*U8)(unsafe.Pointer(a + uintptr(i)))) == 0) { i++ @@ -171859,7 +169166,7 @@ func fts5SegIterReverseInitPage(tls *libc.TLS, p uintptr, pIter uintptr) { /* sq var nNew int32 = ((*Fts5SegIter)(unsafe.Pointer(pIter)).FnRowidOffset + 8) var aNew uintptr = Xsqlite3_realloc64(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset, (uint64(uint64(nNew) * uint64(unsafe.Sizeof(int32(0)))))) if aNew == uintptr(0) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = 7 + (*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM break } (*Fts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset = aNew @@ -171878,10 +169185,10 @@ func fts5SegIterReverseNewPage(tls *libc.TLS, p uintptr, pIter uintptr) { /* sql fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0) - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno > (*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno) { + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno > (*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno) { var pNew uintptr (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno-- - pNew = fts5DataRead(tls, p, (((((I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno)))) + pNew = fts5DataRead(tls, p, (((((I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno)))) if pNew != 0 { // iTermLeafOffset may be equal to szLeaf if the term is the last // thing on the page - i.e. the first rowid is on the following page. @@ -171921,8 +169228,8 @@ func fts5SegIterReverseNewPage(tls *libc.TLS, p uintptr, pIter uintptr) { /* sql // points to a delete marker. A delete marker is an entry with a 0 byte // position-list. func fts5MultiIterIsEmpty(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3.c:218202:12: */ - var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(1)*4)).FiFirst)*120) - return (libc.Bool32((((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0)) && ((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos == 0))) + var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*120) + return (libc.Bool32((((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0)) && ((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos == 0))) } // Advance iterator pIter to the next entry. @@ -171943,7 +169250,7 @@ func fts5SegIterNext_Reverse(tls *libc.TLS, p uintptr, pIter uintptr, pbUnused u (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = *(*int32)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset + uintptr((*Fts5SegIter)(unsafe.Pointer(pIter)).FiRowidOffset)*4)) fts5SegIterLoadNPos(tls, p, pIter) iOff = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset - if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail != 1 { + if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail != FTS5_DETAIL_NONE { iOff = iOff + ((*Fts5SegIter)(unsafe.Pointer(pIter)).FnPos) } sqlite3Fts5GetVarint(tls, (a + uintptr(iOff)), bp /* &iDelta */) @@ -171999,7 +169306,7 @@ __1: *(*I64)(unsafe.Pointer(pIter + 104 /* &.iRowid */)) += (*(*I64)(unsafe.Pointer(bp /* iDelta */))) goto __4 __3: - if !(((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & 0x01) == 0) { + if !(((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_ONETERM) == 0) { goto __5 } if !((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg != 0) { @@ -172102,7 +169409,7 @@ func fts5SegIterNext(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintptr) *(*uintptr)(unsafe.Pointer(bp + 16 /* zTerm */)) = uintptr(0) *(*int32)(unsafe.Pointer(bp + 32 /* nList */)) = 0 - if 0 == ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & 0x01) { + if 0 == ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_ONETERM) { sqlite3Fts5HashScanNext(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash) sqlite3Fts5HashScanEntry(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, bp+16 /* &zTerm */, bp+24 /* &pList */, bp+32 /* &nList */) } @@ -172144,7 +169451,7 @@ func fts5SegIterNext(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintptr) } if *(*int32)(unsafe.Pointer(bp + 36 /* iOff */)) > (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) return } } @@ -172153,7 +169460,7 @@ func fts5SegIterNext(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintptr) // Check if the iterator is now at EOF. If so, return early. if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { if bNewTerm != 0 { - if ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & 0x01) != 0 { + if ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_ONETERM) != 0 { fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0) } else { @@ -172198,7 +169505,7 @@ func fts5SegIterReverse(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c: if pDlidx != 0 { var iSegid int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid pgnoLast = fts5DlidxIterPgno(tls, pDlidx) - pLast = fts5DataRead(tls, p, (((((I64(iSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(pgnoLast)))) + pLast = fts5DataRead(tls, p, (((((I64(iSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(pgnoLast)))) } else { var pLeaf uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf // Current leaf data @@ -172229,7 +169536,7 @@ func fts5SegIterReverse(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c: // The last rowid in the doclist may not be on the current page. Search // forward to find the page containing the last rowid. for pgno = ((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno + 1); !((*Fts5Index)(unsafe.Pointer(p)).Frc != 0) && (pgno <= (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast); pgno++ { - var iAbs I64 = (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(pgno))) + var iAbs I64 = (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(pgno))) var pNew uintptr = fts5DataRead(tls, p, iAbs) if pNew != 0 { var iRowid int32 @@ -172289,7 +169596,7 @@ func fts5SegIterReverse(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c: // doclist-index from disk and initialize an iterator at (pIter->pDlidx). func fts5SegIterLoadDlidx(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:218540:13: */ var iSeg int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid - var bRev int32 = ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & 0x02) + var bRev int32 = ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_REVERSE) var pLeaf uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf // Current leaf data // Check if the current doclist ends on this page. If it does, return @@ -172350,7 +169657,7 @@ func fts5LeafSeek(tls *libc.TLS, p uintptr, bGe int32, pIter uintptr, pTerm uint if !(*(*int32)(unsafe.Pointer(bp + 12 /* iOff */)) > n) { goto __1 } - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) return __1: ; @@ -172446,7 +169753,7 @@ __16: if !(*(*int32)(unsafe.Pointer(bp + 12 /* iOff */)) >= n) { goto __17 } - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) return __17: ; @@ -172494,7 +169801,7 @@ __25: if !((*(*int32)(unsafe.Pointer(bp + 12 /* iOff */)) < 4) || (*(*int32)(unsafe.Pointer(bp + 12 /* iOff */)) >= (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf)) { goto __27 } - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) return goto __28 __27: @@ -172524,7 +169831,7 @@ search_success: if !(((I64(*(*int32)(unsafe.Pointer(bp + 12 /* iOff */))) + I64(*(*U32)(unsafe.Pointer(bp + 4 /* nNew */)))) > I64(n)) || (*(*U32)(unsafe.Pointer(bp + 4 /* nNew */)) < U32(1))) { goto __29 } - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) return __29: ; @@ -172572,7 +169879,7 @@ func fts5IdxSelectStmt(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:218701:2 // an error has already occurred when this function is called, it is a no-op. func fts5SegIterSeekInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, flags int32, pSeg uintptr, pIter uintptr) { /* sqlite3.c:218720:13: */ var iPg int32 = 1 - var bGe int32 = (flags & 0x0008) + var bGe int32 = (flags & FTS5INDEX_QUERY_SCAN) var bDlidx int32 = 0 // True if there is a doclist-index var pIdxSelect uintptr = uintptr(0) @@ -172587,7 +169894,7 @@ func fts5SegIterSeekInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, f } Xsqlite3_bind_int(tls, pIdxSelect, 1, (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid) Xsqlite3_bind_blob(tls, pIdxSelect, 2, pTerm, nTerm, uintptr(0)) - if 100 == Xsqlite3_step(tls, pIdxSelect) { + if SQLITE_ROW == Xsqlite3_step(tls, pIdxSelect) { var val I64 = I64(Xsqlite3_column_int(tls, pIdxSelect, 0)) iPg = (int32(val >> 1)) bDlidx = (int32(val & int64(0x0001))) @@ -172607,16 +169914,16 @@ func fts5SegIterSeekInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, f fts5LeafSeek(tls, p, bGe, pIter, pTerm, nTerm) } - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (bGe == 0) { - *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (0x01) + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (bGe == 0) { + *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (FTS5_SEGITER_ONETERM) if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { - if (flags & 0x0002) != 0 { - *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (0x02) + if (flags & FTS5INDEX_QUERY_DESC) != 0 { + *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (FTS5_SEGITER_REVERSE) } if bDlidx != 0 { fts5SegIterLoadDlidx(tls, p, pIter) } - if (flags & 0x0002) != 0 { + if (flags & FTS5INDEX_QUERY_DESC) != 0 { fts5SegIterReverse(tls, p, pIter) } } @@ -172649,7 +169956,7 @@ func fts5SegIterHashInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, f var n int32 = 0 *(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)) = uintptr(0) - if (pTerm == uintptr(0)) || ((flags & 0x0008) != 0) { + if (pTerm == uintptr(0)) || ((flags & FTS5INDEX_QUERY_SCAN) != 0) { *(*uintptr)(unsafe.Pointer(bp + 8 /* pList */)) = uintptr(0) (*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5HashScanInit(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, pTerm, nTerm) @@ -172670,11 +169977,11 @@ func fts5SegIterHashInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, f (*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5HashQuery(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, int32(unsafe.Sizeof(Fts5Data{})), pTerm, nTerm, bp+24 /* &pLeaf */, bp+16 /* &nList */) if *(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)) != 0 { - (*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)))).Fp = (*(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)) + uintptr(1)*16) + (*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)))).Fp = (*(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)) + 1*16) } *(*uintptr)(unsafe.Pointer(bp /* z */)) = pTerm n = nTerm - *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (0x01) + *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (FTS5_SEGITER_ONETERM) } if *(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)) != 0 { @@ -172684,8 +169991,8 @@ func fts5SegIterHashInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, f (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int32(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)))).Fp, (pIter + 104 /* &.iRowid */))) (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)))).Fnn - if (flags & 0x0002) != 0 { - *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (0x02) + if (flags & FTS5INDEX_QUERY_DESC) != 0 { + *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (FTS5_SEGITER_REVERSE) fts5SegIterReverseInitPage(tls, p, pIter) } else { fts5SegIterLoadNPos(tls, p, pIter) @@ -172766,21 +170073,21 @@ func fts5MultiIterDoCompare(tls *libc.TLS, pIter uintptr, iOut int32) int32 { /* func fts5SegIterGotoPage(tls *libc.TLS, p uintptr, pIter uintptr, iLeafPgno int32) { /* sqlite3.c:219020:13: */ if iLeafPgno > (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FpgnoLast { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf) (*Fts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf = uintptr(0) (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = (iLeafPgno - 1) fts5SegIterNextPage(tls, p, pIter) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { var iOff int32 var a uintptr = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp var n int32 = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf iOff = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp)) if (iOff < 4) || (iOff >= n) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { iOff = iOff + (int32(sqlite3Fts5GetVarint(tls, (a + uintptr(iOff)), (pIter + 104 /* &.iRowid */)))) (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = iOff @@ -172794,7 +170101,7 @@ func fts5SegIterGotoPage(tls *libc.TLS, p uintptr, pIter uintptr, iLeafPgno int3 // past rowid iFrom. Regardless of the value of iFrom, the iterator is // always advanced at least once. func fts5SegIterNextFrom(tls *libc.TLS, p uintptr, pIter uintptr, iMatch I64) { /* sqlite3.c:219058:13: */ - var bRev int32 = ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & 0x02) + var bRev int32 = ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_REVERSE) var pDlidx uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpDlidx var iLeafPgno int32 = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno var bMove int32 = 1 @@ -172823,8 +170130,8 @@ func fts5SegIterNextFrom(tls *libc.TLS, p uintptr, pIter uintptr, iMatch I64) { } } - for ok := true; ok; ok = ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) { - if (bMove != 0) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) { + for ok := true; ok; ok = ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) { + if (bMove != 0) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) { (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer((pIter + 40 /* &.xNext */))))(tls, p, pIter, uintptr(0)) } if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0) { @@ -172854,7 +170161,7 @@ func fts5MultiIterFree(tls *libc.TLS, pIter uintptr) { /* sqlite3.c:219112:13: * func fts5MultiIterAdvanced(tls *libc.TLS, p uintptr, pIter uintptr, iChanged int32, iMinset int32) { /* sqlite3.c:219123:13: */ var i int32 - for i = (((*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg + iChanged) / 2); (i >= iMinset) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0); i = (i / 2) { + for i = (((*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg + iChanged) / 2); (i >= iMinset) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK); i = (i / 2) { var iEq int32 if libc.AssignInt32(&iEq, fts5MultiIterDoCompare(tls, pIter, i)) != 0 { var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr(iEq)*120) @@ -172914,7 +170221,7 @@ func fts5MultiIterAdvanceRowid(tls *libc.TLS, pIter uintptr, iChanged int32, ppF // Set the pIter->bEof variable based on the state of the sub-iterators. func fts5MultiIterSetEof(tls *libc.TLS, pIter uintptr) { /* sqlite3.c:219194:13: */ - var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(1)*4)).FiFirst)*120) + var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*120) (*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FbEof = (U8(libc.Bool32((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf == uintptr(0)))) (*Fts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiRowid } @@ -172930,8 +170237,8 @@ func fts5MultiIterNext(tls *libc.TLS, p uintptr, pIter uintptr, bFrom int32, iFr var bUseFrom int32 = bFrom - for (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - var iFirst int32 = int32((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + uintptr(1)*4)).FiFirst) + for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var iFirst int32 = int32((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4)).FiFirst) *(*int32)(unsafe.Pointer(bp /* bNewTerm */)) = 0 *(*uintptr)(unsafe.Pointer(bp + 8 /* pSeg */)) = ((pIter + 96 /* &.aSeg */) + uintptr(iFirst)*120) @@ -172945,7 +170252,7 @@ func fts5MultiIterNext(tls *libc.TLS, p uintptr, pIter uintptr, bFrom int32, iFr (fts5MultiIterAdvanceRowid(tls, pIter, iFirst, bp+8 /* &pSeg */) != 0) { fts5MultiIterAdvanced(tls, p, pIter, iFirst, 1) fts5MultiIterSetEof(tls, pIter) - *(*uintptr)(unsafe.Pointer(bp + 8 /* pSeg */)) = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(1)*4)).FiFirst)*120) + *(*uintptr)(unsafe.Pointer(bp + 8 /* pSeg */)) = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*120) if (*Fts5SegIter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pSeg */)))).FpLeaf == uintptr(0) { return } @@ -172963,10 +170270,10 @@ func fts5MultiIterNext2(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintp bp := tls.Alloc(16) defer tls.Free(16) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { *(*int32)(unsafe.Pointer(pbNewTerm)) = 0 for ok := true; ok; ok = fts5MultiIterIsEmpty(tls, p, pIter) != 0 { - var iFirst int32 = int32((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + uintptr(1)*4)).FiFirst) + var iFirst int32 = int32((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4)).FiFirst) *(*uintptr)(unsafe.Pointer(bp + 8 /* pSeg */)) = ((pIter + 96 /* &.aSeg */) + uintptr(iFirst)*120) *(*int32)(unsafe.Pointer(bp /* bNewTerm */)) = 0 @@ -173168,7 +170475,7 @@ func fts5ChunkIterate(tls *libc.TLS, p uintptr, pSeg uintptr, pCtx uintptr, xChu // This function does notmwork with detail=none databases. - if ((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fflags & 0x02) == 0 { + if ((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fflags & FTS5_SEGITER_REVERSE) == 0 { pgnoSave = (pgno + 1) } @@ -173180,11 +170487,11 @@ func fts5ChunkIterate(tls *libc.TLS, p uintptr, pSeg uintptr, pCtx uintptr, xChu break } else { pgno++ - pData = fts5LeafRead(tls, p, (((((I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(pgno)))) + pData = fts5LeafRead(tls, p, (((((I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(pgno)))) if pData == uintptr(0) { break } - pChunk = ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr(4)) + pChunk = ((*Fts5Data)(unsafe.Pointer(pData)).Fp + 4) nChunk = func() int32 { if (nRem) < ((*Fts5Data)(unsafe.Pointer(pData)).FszLeaf - 4) { return nRem @@ -173209,18 +170516,18 @@ func fts5SegiterPoslist(tls *libc.TLS, p uintptr, pSeg uintptr, pColset uintptr, defer tls.Free(48) if 0 == (func() int32 { - if ((U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)) + (U32((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos + 8))) <= (U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace)) { + if ((U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)) + (U32((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos + FTS5_DATA_ZERO_PADDING))) <= (U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace)) { return 0 } - return sqlite3Fts5BufferSize(tls, (p + 52 /* &.rc */), pBuf, (uint32(((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos + 8) + (*Fts5Buffer)(unsafe.Pointer((pBuf))).Fn))) + return sqlite3Fts5BufferSize(tls, (p + 52 /* &.rc */), pBuf, (uint32(((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos + FTS5_DATA_ZERO_PADDING) + (*Fts5Buffer)(unsafe.Pointer((pBuf))).Fn))) }()) { - libc.Xmemset(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn + (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos))), 0, uint64(8)) + libc.Xmemset(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn + (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos))), 0, FTS5_DATA_ZERO_PADDING) if pColset == uintptr(0) { fts5ChunkIterate(tls, p, pSeg, pBuf, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr, int32) }{fts5PoslistCallback}))) } else { - if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == 0 { + if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_FULL { // var sCtx PoslistCallbackCtx at bp, 24 (*PoslistCallbackCtx)(unsafe.Pointer(bp /* &sCtx */)).FpBuf = pBuf @@ -173295,7 +170602,7 @@ func fts5IndexExtractColset(tls *libc.TLS, pRc uintptr, pColset uintptr, pPos ui bp := tls.Alloc(8) defer tls.Free(8) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var i int32 sqlite3Fts5BufferZero(tls, pBuf) for i = 0; i < (*Fts5Colset)(unsafe.Pointer(pColset)).FnCol; i++ { @@ -173390,7 +170697,7 @@ __3: if !(a < pEnd) { goto __4 } - iPrev = iPrev + (int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&a, 1) + uintptr(0)))) - 2) + iPrev = iPrev + (int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&a, 1)))) - 2) __5: if !(*(*int32)(unsafe.Pointer(aiCol)) < iPrev) { goto __6 @@ -173435,7 +170742,7 @@ func fts5IterSetOutputs_Full(tls *libc.TLS, pIter uintptr, pSeg uintptr) { /* sq // variables to point into the body of the page object. *(*uintptr)(unsafe.Pointer(bp /* a */)) = ((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).Fp + uintptr((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset)) if (*Fts5Colset)(unsafe.Pointer(pColset)).FnCol == 1 { - (*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = fts5IndexExtractCol(tls, bp /* &a */, (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos, *(*int32)(unsafe.Pointer((pColset + 4 /* &.aiCol */) + uintptr(0)*4))) + (*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = fts5IndexExtractCol(tls, bp /* &a */, (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos, *(*int32)(unsafe.Pointer((pColset + 4 /* &.aiCol */)))) (*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = *(*uintptr)(unsafe.Pointer(bp /* a */)) } else { var pRc uintptr = ((*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex + 52 /* &.rc */) @@ -173456,9 +170763,9 @@ func fts5IterSetOutputs_Full(tls *libc.TLS, pIter uintptr, pSeg uintptr) { /* sq } func fts5IterSetOutputCb(tls *libc.TLS, pRc uintptr, pIter uintptr) { /* sqlite3.c:219689:13: */ - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var pConfig uintptr = (*Fts5Index)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex)).FpConfig - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 1 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_NONE { (*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) }{fts5IterSetOutputs_None})) @@ -173470,7 +170777,7 @@ func fts5IterSetOutputCb(tls *libc.TLS, pRc uintptr, pIter uintptr) { /* sqlite3 (*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) }{fts5IterSetOutputs_ZeroColset})) - } else if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 0 { + } else if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_FULL { (*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) }{fts5IterSetOutputs_Full})) @@ -173507,7 +170814,7 @@ func fts5MultiIterNew(tls *libc.TLS, p uintptr, pStruct uintptr, flags int32, pC var pNew uintptr // Allocate space for the new multi-seg-iterator. - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { if iLevel < 0 { nSeg = (*Fts5Structure)(unsafe.Pointer(pStruct)).FnSegment @@ -173530,15 +170837,15 @@ func fts5MultiIterNew(tls *libc.TLS, p uintptr, pStruct uintptr, flags int32, pC if pNew == uintptr(0) { return } - (*Fts5Iter)(unsafe.Pointer(pNew)).FbRev = (libc.Bool32(0 != (flags & 0x0002))) - (*Fts5Iter)(unsafe.Pointer(pNew)).FbSkipEmpty = (U8(libc.Bool32(0 != (flags & 0x0010)))) + (*Fts5Iter)(unsafe.Pointer(pNew)).FbRev = (libc.Bool32(0 != (flags & FTS5INDEX_QUERY_DESC))) + (*Fts5Iter)(unsafe.Pointer(pNew)).FbSkipEmpty = (U8(libc.Bool32(0 != (flags & FTS5INDEX_QUERY_SKIPEMPTY)))) (*Fts5Iter)(unsafe.Pointer(pNew)).FpColset = pColset - if (flags & 0x0020) == 0 { + if (flags & FTS5INDEX_QUERY_NOOUTPUT) == 0 { fts5IterSetOutputCb(tls, (p + 52 /* &.rc */), pNew) } // Initialize each of the component segment iterators. - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { if iLevel < 0 { var pEnd uintptr = ((pStruct + 24 /* &.aLevel */) + uintptr((*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel)*16) if (*Fts5Index)(unsafe.Pointer(p)).FpHash != 0 { @@ -173546,7 +170853,7 @@ func fts5MultiIterNew(tls *libc.TLS, p uintptr, pStruct uintptr, flags int32, pC var pIter uintptr = ((pNew + 96 /* &.aSeg */) + uintptr(libc.PostIncInt32(&iIter, 1))*120) fts5SegIterHashInit(tls, p, pTerm, nTerm, flags, pIter) } - for pLvl = ((pStruct + 24 /* &.aLevel */) + uintptr(0)*16); pLvl < pEnd; pLvl += 16 { + for pLvl = (pStruct + 24 /* &.aLevel */); pLvl < pEnd; pLvl += 16 { for iSeg = ((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg - 1); iSeg >= 0; iSeg-- { var pSeg uintptr = ((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSeg)*12) var pIter uintptr = ((pNew + 96 /* &.aSeg */) + uintptr(libc.PostIncInt32(&iIter, 1))*120) @@ -173570,12 +170877,12 @@ func fts5MultiIterNew(tls *libc.TLS, p uintptr, pStruct uintptr, flags int32, pC // to the first entry in its segment. In this case initialize the // aFirst[] array. Or, if an error has occurred, free the iterator // object and set the output variable to NULL. - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { for iIter = ((*Fts5Iter)(unsafe.Pointer(pNew)).FnSeg - 1); iIter > 0; iIter-- { var iEq int32 if libc.AssignInt32(&iEq, fts5MultiIterDoCompare(tls, pNew, iIter)) != 0 { var pSeg uintptr = ((pNew + 96 /* &.aSeg */) + uintptr(iEq)*120) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer((pSeg + 40 /* &.xNext */))))(tls, p, pSeg, uintptr(0)) } fts5MultiIterAdvanced(tls, p, pNew, iEq, iIter) @@ -173586,7 +170893,7 @@ func fts5MultiIterNew(tls *libc.TLS, p uintptr, pStruct uintptr, flags int32, pC if ((*Fts5Iter)(unsafe.Pointer(pNew)).FbSkipEmpty != 0) && (fts5MultiIterIsEmpty(tls, p, pNew) != 0) { fts5MultiIterNext(tls, p, pNew, 0, int64(0)) } else if int32((*Fts5Iter)(unsafe.Pointer(pNew)).Fbase.FbEof) == 0 { - var pSeg uintptr = ((pNew + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pNew)).FaFirst+uintptr(1)*4)).FiFirst)*120) + var pSeg uintptr = ((pNew + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pNew)).FaFirst+1*4)).FiFirst)*120) (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer((pNew + 56 /* &.xSetOutputs */))))(tls, pNew, pSeg) } @@ -173602,17 +170909,17 @@ func fts5MultiIterNew2(tls *libc.TLS, p uintptr, pData uintptr, bDesc int32, ppO var pNew uintptr pNew = fts5MultiIterAlloc(tls, p, 2) if pNew != 0 { - var pIter uintptr = ((pNew + 96 /* &.aSeg */) + uintptr(1)*120) + var pIter uintptr = ((pNew + 96 /* &.aSeg */) + 1*120) - (*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags = 0x01 + (*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags = FTS5_SEGITER_ONETERM if (*Fts5Data)(unsafe.Pointer(pData)).FszLeaf > 0 { (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = pData (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int32(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp, (pIter + 104 /* &.iRowid */))) (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*Fts5Data)(unsafe.Pointer(pData)).Fnn - (*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pNew)).FaFirst + uintptr(1)*4)).FiFirst = U16(1) + (*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pNew)).FaFirst + 1*4)).FiFirst = U16(1) if bDesc != 0 { (*Fts5Iter)(unsafe.Pointer(pNew)).FbRev = 1 - *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (0x02) + *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (FTS5_SEGITER_REVERSE) fts5SegIterReverseInitPage(tls, p, pIter) } else { fts5SegIterLoadNPos(tls, p, pIter) @@ -173641,7 +170948,7 @@ func fts5MultiIterEof(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite // results are undefined. func fts5MultiIterRowid(tls *libc.TLS, pIter uintptr) I64 { /* sqlite3.c:219883:12: */ - return (*Fts5SegIter)(unsafe.Pointer((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(1)*4)).FiFirst)*120)).FiRowid + return (*Fts5SegIter)(unsafe.Pointer((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*120)).FiRowid } // Move the iterator to the next entry at or following iMatch. @@ -173665,7 +170972,7 @@ func fts5MultiIterNextFrom(tls *libc.TLS, p uintptr, pIter uintptr, iMatch I64) // Return a pointer to a buffer containing the term associated with the // entry that the iterator currently points to. func fts5MultiIterTerm(tls *libc.TLS, pIter uintptr, pn uintptr) uintptr { /* sqlite3.c:219910:17: */ - var p uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(1)*4)).FiFirst)*120) + var p uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*120) *(*int32)(unsafe.Pointer(pn)) = (*Fts5SegIter)(unsafe.Pointer(p)).Fterm.Fn return (*Fts5SegIter)(unsafe.Pointer(p)).Fterm.Fp } @@ -173683,9 +170990,9 @@ func fts5AllocateSegid(tls *libc.TLS, p uintptr, pStruct uintptr) int32 { /* sql var iSegid int32 = 0 - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - if (*Fts5Structure)(unsafe.Pointer(pStruct)).FnSegment >= 2000 { - (*Fts5Index)(unsafe.Pointer(p)).Frc = 13 + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Fts5Structure)(unsafe.Pointer(pStruct)).FnSegment >= FTS5_MAX_SEGMENT { + (*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_FULL } else { // FTS5_MAX_SEGMENT is currently defined as 2000. So the following // array is 63 elements, or 252 bytes, in size. @@ -173699,7 +171006,7 @@ func fts5AllocateSegid(tls *libc.TLS, p uintptr, pStruct uintptr) int32 { /* sql for iLvl = 0; iLvl < (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel; iLvl++ { for iSeg = 0; iSeg < (*Fts5StructureLevel)(unsafe.Pointer((pStruct+24 /* &.aLevel */)+uintptr(iLvl)*16)).FnSeg; iSeg++ { var iId int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5StructureLevel)(unsafe.Pointer((pStruct+24 /* &.aLevel */)+uintptr(iLvl)*16)).FaSeg + uintptr(iSeg)*12)).FiSegid - if (iId <= 2000) && (iId > 0) { + if (iId <= FTS5_MAX_SEGMENT) && (iId > 0) { *(*U32)(unsafe.Pointer(bp /* &aUsed */ + uintptr(((iId-1)/32))*4)) |= (U32(U32(1)) << ((iId - 1) % 32)) } } @@ -173753,7 +171060,7 @@ func fts5WriteDlidxClear(tls *libc.TLS, p uintptr, pWriter uintptr, bFlush int32 if bFlush != 0 { fts5DataWrite(tls, p, - (((((I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(1))) << (31 + 5))) + ((I64(i)) << (31))) + (I64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno))), + (((((I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(1))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + ((I64(i)) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno))), (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fp, (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fn) } sqlite3Fts5BufferZero(tls, (pDlidx + 16 /* &.buf */)) @@ -173764,11 +171071,11 @@ func fts5WriteDlidxClear(tls *libc.TLS, p uintptr, pWriter uintptr, bFlush int32 // Grow the pWriter->aDlidx[] array to at least nLvl elements in size. // Any new array elements are zeroed before returning. func fts5WriteDlidxGrow(tls *libc.TLS, p uintptr, pWriter uintptr, nLvl int32) int32 { /* sqlite3.c:220031:12: */ - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (nLvl >= (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx) { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (nLvl >= (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx) { var aDlidx uintptr = Xsqlite3_realloc64(tls, (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx, (uint64(uint64(unsafe.Sizeof(Fts5DlidxWriter{})) * uint64(nLvl)))) if aDlidx == uintptr(0) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = 7 + (*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } else { var nByte Size_t = (uint64(unsafe.Sizeof(Fts5DlidxWriter{})) * (uint64(nLvl - (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx))) libc.Xmemset(tls, (aDlidx + uintptr((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx)*32), 0, nByte) @@ -173787,7 +171094,7 @@ func fts5WriteFlushDlidx(tls *libc.TLS, p uintptr, pWriter uintptr) int32 { /* s // If there were FTS5_MIN_DLIDX_SIZE or more empty leaf pages written // to the database, also write the doclist-index to disk. - if ((*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx+uintptr(0)*32)).Fbuf.Fn > 0) && ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty >= 4) { + if ((*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx)).Fbuf.Fn > 0) && ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty >= FTS5_MIN_DLIDX_SIZE) { bFlag = 1 } fts5WriteDlidxClear(tls, p, pWriter, bFlag) @@ -173812,7 +171119,7 @@ func fts5WriteFlushBtree(tls *libc.TLS, p uintptr, pWriter uintptr) { /* sqlite3 } bFlag = fts5WriteFlushDlidx(tls, p, pWriter) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { var z uintptr = func() uintptr { if (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fn > 0 { return (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fp @@ -173839,7 +171146,7 @@ func fts5WriteFlushBtree(tls *libc.TLS, p uintptr, pWriter uintptr) { /* sqlite3 // has already occurred when this function is called, it is a no-op. func fts5WriteBtreeTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, pTerm uintptr) { /* sqlite3.c:220110:13: */ fts5WriteFlushBtree(tls, p, pWriter) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { sqlite3Fts5BufferSet(tls, (p + 52 /* &.rc */), (pWriter + 96 /* &.btterm */), nTerm, pTerm) (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage = (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fpgno } @@ -173850,8 +171157,8 @@ func fts5WriteBtreeTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, func fts5WriteBtreeNoTerm(tls *libc.TLS, p uintptr, pWriter uintptr) { /* sqlite3.c:220126:13: */ // If there were no rowids on the leaf page either and the doclist-index // has already been started, append an 0x00 byte to it. - if ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage != 0) && ((*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx+uintptr(0)*32)).Fbuf.Fn > 0) { - var pDlidx uintptr = ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(0)*32) + if ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage != 0) && ((*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx)).Fbuf.Fn > 0) { + var pDlidx uintptr = ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx) sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + 16 /* &.buf */), int64(0)) } @@ -173868,7 +171175,7 @@ func fts5DlidxExtractFirstRowid(tls *libc.TLS, pBuf uintptr) I64 { /* sqlite3.c: var iOff int32 - iOff = (1 + int32(sqlite3Fts5GetVarint(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr(1)), bp /* &iRowid */))) + iOff = (1 + int32(sqlite3Fts5GetVarint(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+1), bp /* &iRowid */))) sqlite3Fts5GetVarint(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(iOff)), bp /* &iRowid */) return *(*I64)(unsafe.Pointer(bp /* iRowid */)) } @@ -173880,7 +171187,7 @@ func fts5WriteDlidxAppend(tls *libc.TLS, p uintptr, pWriter uintptr, iRowid I64) var i int32 var bDone int32 = 0 - for i = 0; ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (bDone == 0); i++ { + for i = 0; ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (bDone == 0); i++ { var iVal I64 var pDlidx uintptr = ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(i)*32) @@ -173890,22 +171197,22 @@ func fts5WriteDlidxAppend(tls *libc.TLS, p uintptr, pWriter uintptr, iRowid I64) // doclist-index leaf page) up into the next level of the b-tree // hierarchy. If the node being flushed is currently the root node, // also push its first rowid upwards. - *(*U8)(unsafe.Pointer((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fp + uintptr(0))) = U8(0x01) // Not the root node + *(*U8)(unsafe.Pointer((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fp)) = U8(0x01) // Not the root node fts5DataWrite(tls, p, - (((((I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(1))) << (31 + 5))) + ((I64(i)) << (31))) + (I64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno))), + (((((I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(1))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + ((I64(i)) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno))), (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fp, (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fn) fts5WriteDlidxGrow(tls, p, pWriter, (i + 2)) pDlidx = ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(i)*32) - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx+uintptr(1)*32)).Fbuf.Fn == 0) { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx+1*32)).Fbuf.Fn == 0) { var iFirst I64 = fts5DlidxExtractFirstRowid(tls, (pDlidx + 16 /* &.buf */)) // This was the root node. Push its first rowid up to the new root. - (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + uintptr(1)*32)).Fpgno = (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno - sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + uintptr(1)*32 + 16 /* &.buf */), int64(0)) - sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + uintptr(1)*32 + 16 /* &.buf */), int64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno)) - sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + uintptr(1)*32 + 16 /* &.buf */), iFirst) - (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + uintptr(1)*32)).FbPrevValid = 1 - (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + uintptr(1)*32)).FiPrev = iFirst + (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + 1*32)).Fpgno = (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno + sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + 1*32 + 16 /* &.buf */), int64(0)) + sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + 1*32 + 16 /* &.buf */), int64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno)) + sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + 1*32 + 16 /* &.buf */), iFirst) + (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + 1*32)).FbPrevValid = 1 + (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + 1*32)).FiPrev = iFirst } sqlite3Fts5BufferZero(tls, (pDlidx + 16 /* &.buf */)) @@ -173942,7 +171249,7 @@ func fts5WriteFlushLeaf(tls *libc.TLS, p uintptr, pWriter uintptr) { /* sqlite3. // Set the szLeaf header field. - fts5PutU16(tls, ((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fp + uintptr(2)), U16((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn)) + fts5PutU16(tls, ((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fp + 2), U16((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn)) if (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstTermInPage != 0 { // No term was written to this page. @@ -173954,7 +171261,7 @@ func fts5WriteFlushLeaf(tls *libc.TLS, p uintptr, pWriter uintptr) { /* sqlite3. } // Write the page out to disk - iRowid = (((((I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgno))) + iRowid = (((((I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgno))) fts5DataWrite(tls, p, iRowid, (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fp, (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn) // Initialize the next page. @@ -173994,12 +171301,12 @@ func fts5WriteAppendTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, if ((((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn + (*Fts5Buffer)(unsafe.Pointer(pPgidx)).Fn) + nTerm) + 2) >= (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz { if (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn > 4 { fts5WriteFlushLeaf(tls, p, pWriter) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { return } } - if !(((U32((*Fts5Buffer)(unsafe.Pointer((pPage + 8 /* &.buf */))).Fn)) + (U32(nTerm + 20))) <= (U32((*Fts5Buffer)(unsafe.Pointer((pPage + 8 /* &.buf */))).FnSpace))) { - sqlite3Fts5BufferSize(tls, (p + 52 /* &.rc */), (pPage + 8 /* &.buf */), (uint32((nTerm + 20) + (*Fts5Buffer)(unsafe.Pointer((pPage + 8 /* &.buf */))).Fn))) + if !(((U32((*Fts5Buffer)(unsafe.Pointer((pPage + 8 /* &.buf */))).Fn)) + (U32(nTerm + FTS5_DATA_PADDING))) <= (U32((*Fts5Buffer)(unsafe.Pointer((pPage + 8 /* &.buf */))).FnSpace))) { + sqlite3Fts5BufferSize(tls, (p + 52 /* &.rc */), (pPage + 8 /* &.buf */), (uint32((nTerm + FTS5_DATA_PADDING) + (*Fts5Buffer)(unsafe.Pointer((pPage + 8 /* &.buf */))).Fn))) } } @@ -174029,7 +171336,7 @@ func fts5WriteAppendTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, n = (1 + fts5PrefixCompress(tls, nMin, (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fterm.Fp, pTerm)) } fts5WriteBtreeTerm(tls, p, pWriter, n, pTerm) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { return } pPage = (pWriter + 8 /* &.writer */) @@ -174051,12 +171358,12 @@ func fts5WriteAppendTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage = U8(0) (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInDoclist = U8(1) - (*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(0)*32)).Fpgno = (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgno + (*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx)).Fpgno = (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgno } // Append a rowid and position-list size field to the writers output. func fts5WriteAppendRowid(tls *libc.TLS, p uintptr, pWriter uintptr, iRowid I64) { /* sqlite3.c:220343:13: */ - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { var pPage uintptr = (pWriter + 8 /* &.writer */) if ((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn + (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn) >= (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz { @@ -174092,7 +171399,7 @@ func fts5WriteAppendPoslistData(tls *libc.TLS, p uintptr, pWriter uintptr, aData var a uintptr = aData var n int32 = nData - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn + (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn) + n) >= (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz) { var nReq int32 = (((*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz - (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn) - (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn) var nCopy int32 = 0 @@ -174116,7 +171423,7 @@ func fts5WriteAppendPoslistData(tls *libc.TLS, p uintptr, pWriter uintptr, aData func fts5WriteFinish(tls *libc.TLS, p uintptr, pWriter uintptr, pnLeaf uintptr) { /* sqlite3.c:220410:13: */ var i int32 var pLeaf uintptr = (pWriter + 8 /* &.writer */) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { if (*Fts5PageWriter)(unsafe.Pointer(pLeaf)).Fbuf.Fn > 4 { fts5WriteFlushLeaf(tls, p, pWriter) @@ -174141,7 +171448,7 @@ func fts5WriteInit(tls *libc.TLS, p uintptr, pWriter uintptr, iSegid int32) { /* bp := tls.Alloc(16) defer tls.Free(16) - var nBuffer int32 = ((*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz + 20) + var nBuffer int32 = ((*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz + FTS5_DATA_PADDING) libc.Xmemset(tls, pWriter, 0, uint64(unsafe.Sizeof(Fts5SegWriter{}))) (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid = iSegid @@ -174162,7 +171469,7 @@ func fts5WriteInit(tls *libc.TLS, p uintptr, pWriter uintptr, iSegid int32) { /* libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))) } - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { // Initialize the 4-byte leaf-page header to 0x00. libc.Xmemset(tls, (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fbuf.Fp, 0, uint64(4)) (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fbuf.Fn = 4 @@ -174185,7 +171492,7 @@ func fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:22 // var buf Fts5Buffer at bp, 16 libc.Xmemset(tls, bp /* &buf */, 0, uint64(unsafe.Sizeof(Fts5Buffer{}))) - for i = 0; (i < (*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0); i++ { + for i = 0; (i < (*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK); i++ { var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr(i)*120) if (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg == uintptr(0) { // no-op @@ -174202,7 +171509,7 @@ func fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:22 var iId int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid *(*[4]U8)(unsafe.Pointer(bp + 16 /* aHdr */)) = [4]U8{U8(0x00), U8(0x00), U8(0x00), U8(0x00)} - iLeafRowid = (((((I64(iId)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno))) + iLeafRowid = (((((I64(iId)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno))) pData = fts5LeafRead(tls, p, iLeafRowid) if pData != 0 { if iOff > (*Fts5Data)(unsafe.Pointer(pData)).FszLeaf { @@ -174210,7 +171517,7 @@ func fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:22 // a single page has been assigned to more than one segment. In // this case a prior iteration of this loop may have corrupted the // segment currently being trimmed. - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { sqlite3Fts5BufferZero(tls, bp /* &buf */) if !(((U32((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn)) + (U32((*Fts5Data)(unsafe.Pointer(pData)).Fnn))) <= (U32((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).FnSpace))) { @@ -174220,9 +171527,9 @@ func fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:22 sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), bp /* &buf */, int64((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn)) sqlite3Fts5BufferAppendBlob(tls, (p + 52 /* &.rc */), bp /* &buf */, uint32((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn), (*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp) sqlite3Fts5BufferAppendBlob(tls, (p + 52 /* &.rc */), bp /* &buf */, (uint32((*Fts5Data)(unsafe.Pointer(pData)).FszLeaf - iOff)), ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr(iOff))) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { // Set the szLeaf field - fts5PutU16(tls, ((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp + uintptr(2)), U16((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn)) + fts5PutU16(tls, ((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp + 2), U16((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn)) } // Set up the new page-index array @@ -174236,7 +171543,7 @@ func fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:22 } (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FpgnoFirst = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno - fts5DataDelete(tls, p, (((((I64(iId)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (int64(1))), iLeafRowid) + fts5DataDelete(tls, p, (((((I64(iId)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (int64(1))), iLeafRowid) fts5DataWrite(tls, p, iLeafRowid, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn) } fts5DataRelease(tls, pData) @@ -174274,7 +171581,7 @@ func fts5IndexMergeLevel(tls *libc.TLS, p uintptr, ppStruct uintptr, iLvl int32, var bOldest int32 // True if the output segment is the oldest var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail - var flags int32 = 0x0020 + var flags int32 = FTS5INDEX_QUERY_NOOUTPUT var bTermWritten int32 = 0 // True if current term already output libc.Xmemset(tls, bp /* &writer */, 0, uint64(unsafe.Sizeof(Fts5SegWriter{}))) @@ -174319,7 +171626,7 @@ func fts5IndexMergeLevel(tls *libc.TLS, p uintptr, ppStruct uintptr, iLvl int32, bOldest = (libc.Bool32(((*Fts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg == 1) && ((*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel == (iLvl + 2)))) for fts5MultiIterNew(tls, p, pStruct, flags, uintptr(0), uintptr(0), 0, iLvl, nInput, bp+136 /* &pIter */); fts5MultiIterEof(tls, p, *(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */))) == 0; fts5MultiIterNext(tls, p, *(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */)), 0, int64(0)) { - var pSegIter uintptr = ((*(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */)))).FaFirst+uintptr(1)*4)).FiFirst)*120) + var pSegIter uintptr = ((*(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */)))).FaFirst+1*4)).FiFirst)*120) var nPos int32 // position-list size field value // var nTerm int32 at bp+144, 4 @@ -174344,7 +171651,7 @@ func fts5IndexMergeLevel(tls *libc.TLS, p uintptr, ppStruct uintptr, iLvl int32, continue } - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (bTermWritten == 0) { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (bTermWritten == 0) { // This is a new term. Append a term to the output segment. fts5WriteAppendTerm(tls, p, bp /* &writer */, *(*int32)(unsafe.Pointer(bp + 144 /* nTerm */)), pTerm) bTermWritten = 1 @@ -174354,7 +171661,7 @@ func fts5IndexMergeLevel(tls *libc.TLS, p uintptr, ppStruct uintptr, iLvl int32, // WRITEPOSLISTSIZE fts5WriteAppendRowid(tls, p, bp /* &writer */, fts5MultiIterRowid(tls, *(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */)))) - if eDetail == 1 { + if eDetail == FTS5_DETAIL_NONE { if (*Fts5SegIter)(unsafe.Pointer(pSegIter)).FbDel != 0 { sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (bp /* &writer */ + 8 /* &.writer */ + 8 /* &.buf */), int64(0)) if (*Fts5SegIter)(unsafe.Pointer(pSegIter)).FnPos > 0 { @@ -174418,7 +171725,7 @@ func fts5IndexMerge(tls *libc.TLS, p uintptr, ppStruct uintptr, nPg int32, nMin *(*int32)(unsafe.Pointer(bp + 8 /* nRem */)) = nPg var bRet int32 = 0 *(*uintptr)(unsafe.Pointer(bp /* pStruct */)) = *(*uintptr)(unsafe.Pointer(ppStruct)) - for (*(*int32)(unsafe.Pointer(bp + 8 /* nRem */)) > 0) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) { + for (*(*int32)(unsafe.Pointer(bp + 8 /* nRem */)) > 0) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) { var iLvl int32 // To iterate through levels var iBestLvl int32 = 0 // Level offering the most input segments var nBest int32 = 0 // Number of input segments on best level @@ -174447,7 +171754,7 @@ func fts5IndexMerge(tls *libc.TLS, p uintptr, ppStruct uintptr, nPg int32, nMin } bRet = 1 fts5IndexMergeLevel(tls, p, bp /* &pStruct */, iBestLvl, bp+8 /* &nRem */) - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pStruct */))+24 /* &.aLevel */)+uintptr(iBestLvl)*16)).FnMerge == 0) { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pStruct */))+24 /* &.aLevel */)+uintptr(iBestLvl)*16)).FnMerge == 0) { fts5StructurePromote(tls, p, (iBestLvl + 1), *(*uintptr)(unsafe.Pointer(bp /* pStruct */))) } } @@ -174462,7 +171769,7 @@ func fts5IndexMerge(tls *libc.TLS, p uintptr, ppStruct uintptr, nPg int32, nMin // If an error occurs, set the Fts5Index.rc error code. If an error has // already occurred, this function is a no-op. func fts5IndexAutomerge(tls *libc.TLS, p uintptr, ppStruct uintptr, nLeaf int32) { /* sqlite3.c:220771:13: */ - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FnAutomerge > 0) { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FnAutomerge > 0) { var pStruct uintptr = *(*uintptr)(unsafe.Pointer(ppStruct)) var nWrite U64 // Initial value of write-counter var nWork int32 // Number of work-quanta to perform @@ -174486,7 +171793,7 @@ func fts5IndexCrisismerge(tls *libc.TLS, p uintptr, ppStruct uintptr) { /* sqlit *(*uintptr)(unsafe.Pointer(bp /* pStruct */)) = *(*uintptr)(unsafe.Pointer(ppStruct)) var iLvl int32 = 0 - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pStruct */))+24 /* &.aLevel */)+uintptr(iLvl)*16)).FnSeg >= nCrisis) { + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pStruct */))+24 /* &.aLevel */)+uintptr(iLvl)*16)).FnSeg >= nCrisis) { fts5IndexMergeLevel(tls, p, bp /* &pStruct */, iLvl, uintptr(0)) fts5StructurePromote(tls, p, (iLvl + 1), *(*uintptr)(unsafe.Pointer(bp /* pStruct */))) @@ -174497,7 +171804,7 @@ func fts5IndexCrisismerge(tls *libc.TLS, p uintptr, ppStruct uintptr) { /* sqlit func fts5IndexReturn(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:220810:12: */ var rc int32 = (*Fts5Index)(unsafe.Pointer(p)).Frc - (*Fts5Index)(unsafe.Pointer(p)).Frc = 0 + (*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_OK return rc } @@ -174571,10 +171878,10 @@ func fts5FlushOneHash(tls *libc.TLS, p uintptr) { /* sqlite3.c:220848:13: */ // Begin scanning through hash table entries. This loop runs once for each // term/doclist currently stored within the hash table. - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5HashScanInit(tls, pHash, uintptr(0), 0) } - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (0 == sqlite3Fts5HashScanEof(tls, pHash)) { + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (0 == sqlite3Fts5HashScanEof(tls, pHash)) { // var zTerm uintptr at bp+120, 8 // Buffer containing term // var pDoclist uintptr at bp+128, 8 @@ -174585,7 +171892,7 @@ func fts5FlushOneHash(tls *libc.TLS, p uintptr) { /* sqlite3.c:220848:13: */ // Write the term for this entry to disk. sqlite3Fts5HashScanEntry(tls, pHash, bp+120 /* &zTerm */, bp+128 /* &pDoclist */, bp+136 /* &nDoclist */) fts5WriteAppendTerm(tls, p, bp /* &writer */, int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* zTerm */)))), *(*uintptr)(unsafe.Pointer(bp + 120 /* zTerm */))) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { break } @@ -174604,23 +171911,23 @@ func fts5FlushOneHash(tls *libc.TLS, p uintptr) { /* sqlite3.c:220848:13: */ // The entire doclist will not fit on this leaf. The following // loop iterates through the poslists that make up the current // doclist. - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (iOff < *(*int32)(unsafe.Pointer(bp + 136 /* nDoclist */))) { + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (iOff < *(*int32)(unsafe.Pointer(bp + 136 /* nDoclist */))) { iOff = iOff + (int32(sqlite3Fts5GetVarint(tls, (*(*uintptr)(unsafe.Pointer(bp + 128 /* pDoclist */)) + uintptr(iOff)), bp+144 /* &iDelta */))) iRowid = iRowid + (*(*I64)(unsafe.Pointer(bp + 144 /* iDelta */))) if (*Fts5SegWriter)(unsafe.Pointer(bp /* &writer */)).FbFirstRowidInPage != 0 { - fts5PutU16(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(0)), U16((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)) // first rowid on page + fts5PutU16(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp), U16((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)) // first rowid on page *(*int32)(unsafe.Pointer(pBuf + 8 /* &.n */)) += (sqlite3Fts5PutVarint(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)), uint64(iRowid))) (*Fts5SegWriter)(unsafe.Pointer(bp /* &writer */)).FbFirstRowidInPage = U8(0) fts5WriteDlidxAppend(tls, p, bp /* &writer */, iRowid) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { break } } else { *(*int32)(unsafe.Pointer(pBuf + 8 /* &.n */)) += (sqlite3Fts5PutVarint(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)), uint64(*(*I64)(unsafe.Pointer(bp + 144 /* iDelta */))))) } - if eDetail == 1 { + if eDetail == FTS5_DETAIL_NONE { if (iOff < *(*int32)(unsafe.Pointer(bp + 136 /* nDoclist */))) && (int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 128 /* pDoclist */)) + uintptr(iOff)))) == 0) { *(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(libc.PostIncInt32(&(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn, 1)))) = U8(0) iOff++ @@ -174653,7 +171960,7 @@ func fts5FlushOneHash(tls *libc.TLS, p uintptr) { /* sqlite3.c:220848:13: */ // that each varint must be stored contiguously. var pPoslist uintptr = (*(*uintptr)(unsafe.Pointer(bp + 128 /* pDoclist */)) + uintptr(iOff)) var iPos int32 = 0 - for (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { var nSpace int32 = ((pgsz - (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn) - (*Fts5Buffer)(unsafe.Pointer(pPgidx)).Fn) var n int32 = 0 if (nCopy - iPos) <= nSpace { @@ -174684,7 +171991,7 @@ func fts5FlushOneHash(tls *libc.TLS, p uintptr) { /* sqlite3.c:220848:13: */ // TODO2: Doclist terminator written here. // pBuf->p[pBuf->n++] = '\0'; - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { sqlite3Fts5HashScanNext(tls, pHash) } } @@ -174697,8 +172004,8 @@ func fts5FlushOneHash(tls *libc.TLS, p uintptr) { /* sqlite3.c:220848:13: */ fts5StructureAddLevel(tls, (p + 52 /* &.rc */), bp+168 /* &pStruct */) } fts5StructureExtendLevel(tls, (p + 52 /* &.rc */), *(*uintptr)(unsafe.Pointer(bp + 168 /* pStruct */)), 0, 1, 0) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - pSeg = ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 168 /* pStruct */))+24 /* &.aLevel */)+uintptr(0)*16)).FaSeg + uintptr(libc.PostIncInt32(&(*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 168 /* pStruct */))+24 /* &.aLevel */)+uintptr(0)*16)).FnSeg, 1))*12) + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pSeg = ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 168 /* pStruct */)) + 24 /* &.aLevel */))).FaSeg + uintptr(libc.PostIncInt32(&(*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 168 /* pStruct */))+24 /* &.aLevel */))).FnSeg, 1))*12) (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid = iSegid (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst = 1 (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast = *(*int32)(unsafe.Pointer(bp + 160 /* pgnoLast */)) @@ -174804,8 +172111,8 @@ func sqlite3Fts5IndexOptimize(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:221 var iLvl int32 for iLvl = 0; (*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNew */))+24 /* &.aLevel */)+uintptr(iLvl)*16)).FnSeg == 0; iLvl++ { } - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNew */))+24 /* &.aLevel */)+uintptr(iLvl)*16)).FnSeg > 0) { - *(*int32)(unsafe.Pointer(bp + 8 /* nRem */)) = 1000 + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNew */))+24 /* &.aLevel */)+uintptr(iLvl)*16)).FnSeg > 0) { + *(*int32)(unsafe.Pointer(bp + 8 /* nRem */)) = FTS5_OPT_WORK_UNIT fts5IndexMergeLevel(tls, p, bp /* &pNew */, iLvl, bp+8 /* &nRem */) } @@ -174850,9 +172157,9 @@ func fts5AppendRowid(tls *libc.TLS, p uintptr, iDelta I64, pUnused uintptr, pBuf func fts5AppendPoslist(tls *libc.TLS, p uintptr, iDelta I64, pMulti uintptr, pBuf uintptr) { /* sqlite3.c:221139:13: */ var nData int32 = (*Fts5Iter)(unsafe.Pointer(pMulti)).Fbase.FnData - var nByte int32 = (((nData + 9) + 9) + 8) + var nByte int32 = (((nData + 9) + 9) + FTS5_DATA_ZERO_PADDING) - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (0 == (func() int32 { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (0 == (func() int32 { if ((U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)) + (U32(nByte))) <= (U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace)) { return 0 } @@ -174871,7 +172178,7 @@ func fts5AppendPoslist(tls *libc.TLS, p uintptr, iDelta I64, pMulti uintptr, pBu *(*int32)(unsafe.Pointer(pBuf + 8 /* &.n */)) += (nData) } - libc.Xmemset(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)), 0, uint64(8)) + libc.Xmemset(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)), 0, FTS5_DATA_ZERO_PADDING) } } @@ -174890,13 +172197,13 @@ func fts5DoclistIterNext(tls *libc.TLS, pIter uintptr) { /* sqlite3.c:221157:13: *(*I64)(unsafe.Pointer(pIter + 8 /* &.iRowid */)) += (*(*I64)(unsafe.Pointer(bp /* iDelta */))) // Read position list size - if (int32(*(*U8)(unsafe.Pointer(p + uintptr(0)))) & 0x80) != 0 { + if (int32(*(*U8)(unsafe.Pointer(p))) & 0x80) != 0 { // var nPos int32 at bp+8, 4 (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnSize = sqlite3Fts5GetVarint32(tls, p, bp+8 /* &nPos */) (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist = (*(*int32)(unsafe.Pointer(bp + 8 /* nPos */)) >> 1) } else { - (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist = ((int32(*(*U8)(unsafe.Pointer(p + uintptr(0))))) >> 1) + (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist = ((int32(*(*U8)(unsafe.Pointer(p)))) >> 1) (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnSize = 1 } @@ -175143,8 +172450,8 @@ func fts5MergePrefixLists(tls *libc.TLS, p uintptr, p1 uintptr, p2 uintptr) { /* // WRITEPOSLISTSIZE if (*Fts5Buffer)(unsafe.Pointer(bp+88 /* &tmp */)).Fn > ((*Fts5DoclistIter)(unsafe.Pointer(bp+16 /* &i1 */)).FnPoslist + (*Fts5DoclistIter)(unsafe.Pointer(bp+48 /* &i2 */)).FnPoslist) { - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } break } @@ -175210,7 +172517,7 @@ func fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, pToken uintptr, var nBuf int32 = 32 var xMerge uintptr var xAppend uintptr - if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == 1 { + if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_NONE { xMerge = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr) }{fts5MergeRowidLists})) @@ -175230,9 +172537,9 @@ func fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, pToken uintptr, pStruct = fts5StructureRead(tls, p) if (aBuf != 0) && (pStruct != 0) { - var flags int32 = ((0x0008 | - 0x0010) | - 0x0020) + var flags int32 = ((FTS5INDEX_QUERY_SCAN | + FTS5INDEX_QUERY_SKIPEMPTY) | + FTS5INDEX_QUERY_NOOUTPUT) var i int32 var iLastRowid I64 = int64(0) *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)) = uintptr(0) // Iterator used to gather data from index @@ -175245,7 +172552,7 @@ func fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, pToken uintptr, fts5MultiIterNew(tls, p, pStruct, flags, pColset, pToken, nToken, -1, 0, bp+16 /* &p1 */) fts5IterSetOutputCb(tls, (p + 52 /* &.rc */), *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */))) for ; fts5MultiIterEof(tls, p, *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */))) == 0; fts5MultiIterNext2(tls, p, *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)), bp+24 /* &bNewTerm */) { - var pSeg uintptr = ((*(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)))).FaFirst+uintptr(1)*4)).FiFirst)*120) + var pSeg uintptr = ((*(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)))).FaFirst+1*4)).FiFirst)*120) var nTerm int32 = (*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn var pTerm uintptr = (*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)) + 56 /* &.xSetOutputs */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)), pSeg) @@ -175261,7 +172568,7 @@ func fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, pToken uintptr, } if ((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)))).Fbase.FiRowid <= iLastRowid) && ((*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn > 0) { - for i = 0; ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn != 0); i++ { + for i = 0; ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn != 0); i++ { if (*Fts5Buffer)(unsafe.Pointer(aBuf+uintptr(i)*16)).Fn == 0 { fts5BufferSwap(tls, bp /* &doclist */, (aBuf + uintptr(i)*16)) @@ -175279,16 +172586,16 @@ func fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, pToken uintptr, } for i = 0; i < nBuf; i++ { - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&xMerge)))(tls, p, bp /* &doclist */, (aBuf + uintptr(i)*16)) } sqlite3Fts5BufferFree(tls, (aBuf + uintptr(i)*16)) } fts5MultiIterFree(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */))) - pData = fts5IdxMalloc(tls, p, (int64((uint64(unsafe.Sizeof(Fts5Data{})) + uint64((*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn)) + uint64(8)))) + pData = fts5IdxMalloc(tls, p, (int64((uint64(unsafe.Sizeof(Fts5Data{})) + uint64((*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn)) + FTS5_DATA_ZERO_PADDING))) if pData != 0 { - (*Fts5Data)(unsafe.Pointer(pData)).Fp = (pData + uintptr(1)*16) + (*Fts5Data)(unsafe.Pointer(pData)).Fp = (pData + 1*16) (*Fts5Data)(unsafe.Pointer(pData)).Fnn = libc.AssignPtrInt32(pData+12 /* &.szLeaf */, (*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn) if (*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn != 0 { libc.Xmemcpy(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fp, uint64((*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn)) @@ -175340,7 +172647,7 @@ func sqlite3Fts5IndexRollback(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:221 fts5IndexDiscardData(tls, p) fts5StructureInvalidate(tls, p) // assert( p->rc==SQLITE_OK ); - return 0 + return SQLITE_OK } // The %_data table is completely empty when this function is called. This @@ -175355,7 +172662,7 @@ func sqlite3Fts5IndexReinit(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:22158 fts5StructureInvalidate(tls, p) fts5IndexDiscardData(tls, p) libc.Xmemset(tls, bp /* &s */, 0, uint64(unsafe.Sizeof(Fts5Structure{}))) - fts5DataWrite(tls, p, int64(1), ts+703 /* "" */, 0) + fts5DataWrite(tls, p, FTS5_AVERAGES_ROWID, ts+703 /* "" */, 0) fts5StructureWrite(tls, p, bp /* &s */) return fts5IndexReturn(tls, p) } @@ -175369,23 +172676,23 @@ func sqlite3Fts5IndexOpen(tls *libc.TLS, pConfig uintptr, bCreate int32, pp uint bp := tls.Alloc(12) defer tls.Free(12) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK var p uintptr // New object *(*uintptr)(unsafe.Pointer(pp)) = libc.AssignUintptr(&p, sqlite3Fts5MallocZero(tls, bp+8 /* &rc */, int64(unsafe.Sizeof(Fts5Index{})))) - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { (*Fts5Index)(unsafe.Pointer(p)).FpConfig = pConfig - (*Fts5Index)(unsafe.Pointer(p)).FnWorkUnit = 64 + (*Fts5Index)(unsafe.Pointer(p)).FnWorkUnit = FTS5_WORK_UNIT (*Fts5Index)(unsafe.Pointer(p)).FzDataTbl = sqlite3Fts5Mprintf(tls, bp+8 /* &rc */, ts+31263 /* "%s_data" */, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) if ((*Fts5Index)(unsafe.Pointer(p)).FzDataTbl != 0) && (bCreate != 0) { *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = sqlite3Fts5CreateTable(tls, pConfig, ts+22282 /* "data" */, ts+31271 /* "id INTEGER PRIMA..." */, 0, pzErr) - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = sqlite3Fts5CreateTable(tls, pConfig, ts+9380, /* "idx" */ ts+31306, /* "segid, term, pgn..." */ 1, pzErr) } - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = sqlite3Fts5IndexReinit(tls, p) } } @@ -175400,7 +172707,7 @@ func sqlite3Fts5IndexOpen(tls *libc.TLS, pConfig uintptr, bCreate int32, pp uint // Close a handle opened by an earlier call to sqlite3Fts5IndexOpen(). func sqlite3Fts5IndexClose(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:221641:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if p != 0 { fts5StructureInvalidate(tls, p) @@ -175470,15 +172777,15 @@ func fts5IndexCharlen(tls *libc.TLS, pIn uintptr, nIn int32) int32 { /* sqlite3. // unique token in the document with an iCol value less than zero. The iPos // argument is ignored for a delete. func sqlite3Fts5IndexWrite(tls *libc.TLS, p uintptr, iCol int32, iPos int32, pToken uintptr, nToken int32) int32 { /* sqlite3.c:221713:12: */ - var i int32 // Used to iterate through indexes - var rc int32 = 0 // Return code + var i int32 // Used to iterate through indexes + var rc int32 = SQLITE_OK // Return code var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig // Add the entry to the main terms index. rc = sqlite3Fts5HashWrite(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, (*Fts5Index)(unsafe.Pointer(p)).FiWriteRowid, iCol, iPos, int8('0'), pToken, nToken) - for i = 0; (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix) && (rc == 0); i++ { + for i = 0; (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix) && (rc == SQLITE_OK); i++ { var nChar int32 = *(*int32)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr(i)*4)) var nByte int32 = sqlite3Fts5IndexCharlenToBytelen(tls, pToken, nToken, nChar) if nByte != 0 { @@ -175506,7 +172813,7 @@ func sqlite3Fts5IndexQuery(tls *libc.TLS, p uintptr, pToken uintptr, nToken int3 if sqlite3Fts5BufferSize(tls, (p+52 /* &.rc */), bp /* &buf */, (uint32(nToken+1))) == 0 { var iIdx int32 = 0 // Index to search if nToken != 0 { - libc.Xmemcpy(tls, ((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp + uintptr(1)), pToken, uint64(nToken)) + libc.Xmemcpy(tls, ((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp + 1), pToken, uint64(nToken)) } // Figure out which index to search and set iIdx accordingly. If this @@ -175519,7 +172826,7 @@ func sqlite3Fts5IndexQuery(tls *libc.TLS, p uintptr, pToken uintptr, nToken int3 // evaluate the prefix query using the main FTS index. This is used // for internal sanity checking by the integrity-check in debug // mode only. - if (flags & 0x0001) != 0 { + if (flags & FTS5INDEX_QUERY_PREFIX) != 0 { var nChar int32 = fts5IndexCharlen(tls, pToken, nToken) for iIdx = 1; iIdx <= (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix; iIdx++ { if *(*int32)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr((iIdx-1))*4)) == nChar { @@ -175531,21 +172838,21 @@ func sqlite3Fts5IndexQuery(tls *libc.TLS, p uintptr, pToken uintptr, nToken int3 if iIdx <= (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix { // Straight index lookup var pStruct uintptr = fts5StructureRead(tls, p) - *(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp + uintptr(0))) = (U8('0' + iIdx)) + *(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp)) = (U8('0' + iIdx)) if pStruct != 0 { - fts5MultiIterNew(tls, p, pStruct, (flags | 0x0010), + fts5MultiIterNew(tls, p, pStruct, (flags | FTS5INDEX_QUERY_SKIPEMPTY), pColset, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp, (nToken + 1), -1, 0, bp+16 /* &pRet */) fts5StructureRelease(tls, pStruct) } } else { // Scan multiple terms in the main index - var bDesc int32 = (libc.Bool32((flags & 0x0002) != 0)) - *(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp + uintptr(0))) = U8('0') + var bDesc int32 = (libc.Bool32((flags & FTS5INDEX_QUERY_DESC) != 0)) + *(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp)) = U8('0') fts5SetupPrefixIter(tls, p, bDesc, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp, (nToken + 1), pColset, bp+16 /* &pRet */) fts5IterSetOutputCb(tls, (p + 52 /* &.rc */), *(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */))) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - var pSeg uintptr = ((*(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */)))).FaFirst+uintptr(1)*4)).FiFirst)*120) + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var pSeg uintptr = ((*(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */)))).FaFirst+1*4)).FiFirst)*120) if (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0 { (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */)) + 56 /* &.xSetOutputs */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */)), pSeg) } @@ -175579,9 +172886,9 @@ func sqlite3Fts5IterNextScan(tls *libc.TLS, pIndexIter uintptr) int32 { /* sqlit var p uintptr = (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex fts5MultiIterNext(tls, p, pIter, 0, int64(0)) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(1)*4)).FiFirst)*120) - if ((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0) && (int32(*(*U8)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp + uintptr(0)))) != '0') { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*120) + if ((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0) && (int32(*(*U8)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp))) != '0') { fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf) (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf = uintptr(0) (*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FbEof = U8(1) @@ -175609,7 +172916,7 @@ func sqlite3Fts5IterTerm(tls *libc.TLS, pIndexIter uintptr, pn uintptr) uintptr var z uintptr = fts5MultiIterTerm(tls, pIndexIter, bp /* &n */) *(*int32)(unsafe.Pointer(pn)) = (*(*int32)(unsafe.Pointer(bp /* n */)) - 1) - return (z + uintptr(1)) + return (z + 1) } // Close an iterator opened by an earlier call to sqlite3Fts5IndexQuery(). @@ -175632,8 +172939,8 @@ func sqlite3Fts5IndexGetAverages(tls *libc.TLS, p uintptr, pnRow uintptr, anSize *(*I64)(unsafe.Pointer(pnRow)) = int64(0) libc.Xmemset(tls, anSize, 0, (uint64(unsafe.Sizeof(I64(0))) * uint64(nCol))) - pData = fts5DataRead(tls, p, int64(1)) - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5Data)(unsafe.Pointer(pData)).Fnn != 0) { + pData = fts5DataRead(tls, p, FTS5_AVERAGES_ROWID) + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5Data)(unsafe.Pointer(pData)).Fnn != 0) { var i int32 = 0 var iCol int32 i = i + (int32(sqlite3Fts5GetVarint(tls, ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr(i)), pnRow))) @@ -175650,7 +172957,7 @@ func sqlite3Fts5IndexGetAverages(tls *libc.TLS, p uintptr, pnRow uintptr, anSize // supplied as the second argument. func sqlite3Fts5IndexSetAverages(tls *libc.TLS, p uintptr, pData uintptr, nData int32) int32 { /* sqlite3.c:221923:12: */ - fts5DataWrite(tls, p, int64(1), pData, nData) + fts5DataWrite(tls, p, FTS5_AVERAGES_ROWID, pData, nData) return fts5IndexReturn(tls, p) } @@ -175678,8 +172985,8 @@ func sqlite3Fts5IndexSetCookie(tls *libc.TLS, p uintptr, iNew int32) int32 { /* sqlite3Fts5Put32(tls, bp /* &aCookie[0] */, iNew) rc = Xsqlite3_blob_open(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Index)(unsafe.Pointer(p)).FzDataTbl, - ts+30953 /* "block" */, int64(10), 1, bp+8 /* &pBlob */) - if rc == 0 { + ts+30953 /* "block" */, FTS5_STRUCTURE_ROWID, 1, bp+8 /* &pBlob */) + if rc == SQLITE_OK { Xsqlite3_blob_write(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pBlob */)), bp /* &aCookie[0] */, 4, 0) rc = Xsqlite3_blob_close(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pBlob */))) } @@ -175726,14 +173033,14 @@ func fts5IndexIntegrityCheckEmpty(tls *libc.TLS, p uintptr, pSeg uintptr, iFirst // Now check that the iter.nEmpty leaves following the current leaf // (a) exist and (b) contain no terms. - for i = iFirst; ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (i <= iLast); i++ { - var pLeaf uintptr = fts5DataRead(tls, p, (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(i)))) + for i = iFirst; ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (i <= iLast); i++ { + var pLeaf uintptr = fts5DataRead(tls, p, (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(i)))) if pLeaf != 0 { if !((*Fts5Data)(unsafe.Pointer((pLeaf))).FszLeaf >= (*Fts5Data)(unsafe.Pointer((pLeaf))).Fnn) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } if (i >= iNoRowid) && (0 != (int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp)))) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } } fts5DataRelease(tls, pLeaf) @@ -175751,7 +173058,7 @@ func fts5IntegrityCheckPgidx(tls *libc.TLS, p uintptr, pLeaf uintptr) { /* sqlit *(*Fts5Buffer)(unsafe.Pointer(bp + 32 /* buf2 */)) = Fts5Buffer{} ii = (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf - for (ii < (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) { + for (ii < (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) { var res int32 var iOff int32 // var nIncr int32 at bp, 4 @@ -175761,13 +173068,13 @@ func fts5IntegrityCheckPgidx(tls *libc.TLS, p uintptr, pLeaf uintptr) { /* sqlit iOff = iTermOff if iOff >= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else if iTermOff == *(*int32)(unsafe.Pointer(bp /* nIncr */)) { // var nByte int32 at bp+4, 4 iOff = iOff + (sqlite3Fts5GetVarint32(tls, ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iOff)), bp+4 /* &nByte */)) if (iOff + *(*int32)(unsafe.Pointer(bp + 4 /* nByte */))) > (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { sqlite3Fts5BufferSet(tls, (p + 52 /* &.rc */), bp+8 /* &buf1 */, *(*int32)(unsafe.Pointer(bp + 4 /* nByte */)), ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iOff))) } @@ -175779,16 +173086,16 @@ func fts5IntegrityCheckPgidx(tls *libc.TLS, p uintptr, pLeaf uintptr) { /* sqlit iOff = iOff + (sqlite3Fts5GetVarint32(tls, ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iOff)), bp+24 /* &nKeep */)) iOff = iOff + (sqlite3Fts5GetVarint32(tls, ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iOff)), bp+28 /* &nByte */)) if (*(*int32)(unsafe.Pointer(bp + 24 /* nKeep */)) > (*Fts5Buffer)(unsafe.Pointer(bp+8 /* &buf1 */)).Fn) || ((iOff + *(*int32)(unsafe.Pointer(bp + 28 /* nByte */))) > (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { (*Fts5Buffer)(unsafe.Pointer(bp + 8 /* &buf1 */)).Fn = *(*int32)(unsafe.Pointer(bp + 24 /* nKeep */)) sqlite3Fts5BufferAppendBlob(tls, (p + 52 /* &.rc */), bp+8 /* &buf1 */, uint32(*(*int32)(unsafe.Pointer(bp + 28 /* nByte */))), ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iOff))) } - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { res = fts5BufferCompare(tls, bp+8 /* &buf1 */, bp+32 /* &buf2 */) if res <= 0 { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } } } @@ -175819,7 +173126,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid))) // Iterate through the b-tree hierarchy. - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */)))) { + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */)))) { var iRow I64 // Rowid for this leaf var pLeaf uintptr // Data for this leaf @@ -175833,7 +173140,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* if iIdxLeaf < (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst { continue } - iRow = (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(iIdxLeaf))) + iRow = (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(iIdxLeaf))) pLeaf = fts5LeafRead(tls, p, iRow) if pLeaf == uintptr(0) { break @@ -175844,7 +173151,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* // is also a rowid pointer within the leaf page header, it points to a // location before the term. if (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn <= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { var iOff int32 // Offset of first term on leaf var iRowidOff int32 // Offset of first rowid on leaf @@ -175855,7 +173162,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* iOff = fts5LeafFirstTermOff(tls, pLeaf) iRowidOff = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp)) if (iRowidOff >= iOff) || (iOff >= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { iOff = iOff + (sqlite3Fts5GetVarint32(tls, ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iOff)), bp+32 /* &nTerm */)) res = func() int32 { @@ -175878,7 +173185,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* res = (*(*int32)(unsafe.Pointer(bp + 32 /* nTerm */)) - nIdxTerm) } if res < 0 { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } } @@ -175909,11 +173216,11 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* // Check any rowid-less pages that occur before the current leaf. for iPg = (iPrevLeaf + 1); iPg < fts5DlidxIterPgno(tls, pDlidx); iPg++ { - iKey = (((((I64(iSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(iPg))) + iKey = (((((I64(iSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(iPg))) pLeaf = fts5DataRead(tls, p, iKey) if pLeaf != 0 { if (int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp))) != 0 { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } fts5DataRelease(tls, pLeaf) } @@ -175922,7 +173229,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* // Check that the leaf page indicated by the iterator really does // contain the rowid suggested by the same. - iKey = (((((I64(iSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(iPrevLeaf))) + iKey = (((((I64(iSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(iPrevLeaf))) pLeaf = fts5DataRead(tls, p, iKey) if pLeaf != 0 { // var iRowid I64 at bp+40, 8 @@ -175930,11 +173237,11 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* var iRowidOff int32 = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp)) if iRowidOff >= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { sqlite3Fts5GetVarint(tls, ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iRowidOff)), bp+40 /* &iRowid */) if *(*I64)(unsafe.Pointer(bp + 40 /* iRowid */)) != fts5DlidxIterRowid(tls, pDlidx) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } } fts5DataRelease(tls, pLeaf) @@ -175953,7 +173260,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* } rc2 = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */))) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Fts5Index)(unsafe.Pointer(p)).Frc = rc2 } @@ -175979,7 +173286,7 @@ func sqlite3Fts5IndexIntegrityCheck(tls *libc.TLS, p uintptr, cksum U64) int32 { // Used to iterate through entire index var pStruct uintptr // Index structure - var flags int32 = 0x0020 + var flags int32 = FTS5INDEX_QUERY_NOOUTPUT // Load the FTS index structure pStruct = fts5StructureRead(tls, p) @@ -176018,13 +173325,13 @@ func sqlite3Fts5IndexIntegrityCheck(tls *libc.TLS, p uintptr, cksum U64) int32 { // If this is a new term, query for it. Update cksum3 with the results. - if eDetail == 1 { + if eDetail == FTS5_DETAIL_NONE { if 0 == fts5MultiIterIsEmpty(tls, p, *(*uintptr)(unsafe.Pointer(bp /* pIter */))) { cksum2 = cksum2 ^ (sqlite3Fts5IndexEntryCksum(tls, iRowid, 0, 0, -1, z, *(*int32)(unsafe.Pointer(bp + 8 /* n */)))) } } else { (*Fts5Buffer)(unsafe.Pointer(bp + 16 /* &poslist */)).Fn = 0 - fts5SegiterPoslist(tls, p, ((*(*uintptr)(unsafe.Pointer(bp /* pIter */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pIter */)))).FaFirst+uintptr(1)*4)).FiFirst)*120), uintptr(0), bp+16 /* &poslist */) + fts5SegiterPoslist(tls, p, ((*(*uintptr)(unsafe.Pointer(bp /* pIter */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pIter */)))).FaFirst+1*4)).FiFirst)*120), uintptr(0), bp+16 /* &poslist */) for 0 == sqlite3Fts5PoslistNext64(tls, (*Fts5Buffer)(unsafe.Pointer(bp+16 /* &poslist */)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp+16 /* &poslist */)).Fn, bp+32 /* &iOff */, bp+40 /* &iPos */) { var iCol int32 = (int32(*(*I64)(unsafe.Pointer(bp + 40 /* iPos */)) >> 32)) var iTokOff int32 = (int32(*(*I64)(unsafe.Pointer(bp + 40 /* iPos */)) & int64(0x7FFFFFFF))) @@ -176034,8 +173341,8 @@ func sqlite3Fts5IndexIntegrityCheck(tls *libc.TLS, p uintptr, cksum U64) int32 { } fts5MultiIterFree(tls, *(*uintptr)(unsafe.Pointer(bp /* pIter */))) - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (cksum != cksum2) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (cksum != cksum2) { + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } fts5StructureRelease(tls, pStruct) @@ -176052,16 +173359,16 @@ func sqlite3Fts5IndexIntegrityCheck(tls *libc.TLS, p uintptr, cksum U64) int32 { // Decode a segment-data rowid from the %_data table. This function is // the opposite of macro FTS5_SEGMENT_ROWID(). func fts5DecodeRowid(tls *libc.TLS, iRowid I64, piSegid uintptr, pbDlidx uintptr, piHeight uintptr, piPgno uintptr) { /* sqlite3.c:222506:13: */ - *(*int32)(unsafe.Pointer(piPgno)) = (int32(iRowid & ((I64(int64(1)) << 31) - int64(1)))) - iRowid >>= 31 + *(*int32)(unsafe.Pointer(piPgno)) = (int32(iRowid & ((I64(int64(1)) << FTS5_DATA_PAGE_B) - int64(1)))) + iRowid >>= FTS5_DATA_PAGE_B - *(*int32)(unsafe.Pointer(piHeight)) = (int32(iRowid & ((I64(int64(1)) << 5) - int64(1)))) - iRowid >>= 5 + *(*int32)(unsafe.Pointer(piHeight)) = (int32(iRowid & ((I64(int64(1)) << FTS5_DATA_HEIGHT_B) - int64(1)))) + iRowid >>= FTS5_DATA_HEIGHT_B *(*int32)(unsafe.Pointer(pbDlidx)) = (int32(iRowid & int64(0x0001))) - iRowid >>= 1 + iRowid >>= FTS5_DATA_DLI_B - *(*int32)(unsafe.Pointer(piSegid)) = (int32(iRowid & ((I64(int64(1)) << 16) - int64(1)))) + *(*int32)(unsafe.Pointer(piSegid)) = (int32(iRowid & ((I64(int64(1)) << FTS5_DATA_ID_B) - int64(1)))) } func fts5DebugRowid(tls *libc.TLS, pRc uintptr, pBuf uintptr, iKey I64) { /* sqlite3.c:222525:13: */ @@ -176079,7 +173386,7 @@ func fts5DebugRowid(tls *libc.TLS, pRc uintptr, pBuf uintptr, iKey I64) { /* sql fts5DecodeRowid(tls, iKey, bp+32 /* &iSegid */, bp+36 /* &bDlidx */, bp+40 /* &iHeight */, bp+44 /* &iPgno */) if *(*int32)(unsafe.Pointer(bp + 32 /* iSegid */)) == 0 { - if iKey == int64(1) { + if iKey == FTS5_AVERAGES_ROWID { sqlite3Fts5BufferAppendPrintf(tls, pRc, pBuf, ts+31436 /* "{averages} " */, 0) } else { sqlite3Fts5BufferAppendPrintf(tls, pRc, pBuf, ts+31448 /* "{structure}" */, 0) @@ -176128,7 +173435,7 @@ func fts5DecodeStructure(tls *libc.TLS, pRc uintptr, pBuf uintptr, pBlob uintptr *(*uintptr)(unsafe.Pointer(bp /* p */)) = uintptr(0) // Decoded structure object rc = fts5StructureDecode(tls, pBlob, nBlob, uintptr(0), bp /* &p */) - if rc != 0 { + if rc != SQLITE_OK { *(*int32)(unsafe.Pointer(pRc)) = rc return } @@ -176318,20 +173625,20 @@ func fts5DecodeFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) var iOff1 int32 var nDoclist int32 a = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_OK nSpace = int64(0) eDetailNone = (libc.Bool32(Xsqlite3_user_data(tls, pCtx) != uintptr(0))) _ = nArg libc.Xmemset(tls, bp+48 /* &s */, 0, uint64(unsafe.Sizeof(Fts5Buffer{}))) - iRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + iRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal))) // Make a copy of the second argument (a blob) in aBlob[]. The aBlob[] // copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents // buffer overreads even if the record is corrupt. - n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - aBlob = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - nSpace = (Sqlite3_int64(n + 8)) + n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + aBlob = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + nSpace = (Sqlite3_int64(n + FTS5_DATA_ZERO_PADDING)) a = sqlite3Fts5MallocZero(tls, bp+64 /* &rc */, nSpace) if !(a == uintptr(0)) { goto __1 @@ -176379,7 +173686,7 @@ __3: if !(*(*int32)(unsafe.Pointer(bp + 68 /* iSegid */)) == 0) { goto __8 } - if !(iRowid == int64(1)) { + if !(iRowid == FTS5_AVERAGES_ROWID) { goto __10 } fts5DecodeAverages(tls, bp+64 /* &rc */, bp+48 /* &s */, a, n) @@ -176393,7 +173700,7 @@ __8: if !(eDetailNone != 0) { goto __12 } - iPgidxOff = libc.AssignInt32(&szLeaf, int32(fts5GetU16(tls, (a+uintptr(2))))) + iPgidxOff = libc.AssignInt32(&szLeaf, int32(fts5GetU16(tls, (a+2)))) *(*int32)(unsafe.Pointer(bp + 164 /* nKeep */)) = 0 libc.Xmemset(tls, bp+136 /* &term */, 0, uint64(unsafe.Sizeof(Fts5Buffer{}))) @@ -176408,7 +173715,7 @@ __14: *(*int32)(unsafe.Pointer(bp + 152 /* iTermOff */)) = szLeaf __15: ; - fts5DecodeRowidList(tls, bp+64 /* &rc */, bp+48 /* &s */, (a + uintptr(4)), (*(*int32)(unsafe.Pointer(bp + 152 /* iTermOff */)) - 4)) + fts5DecodeRowidList(tls, bp+64 /* &rc */, bp+48 /* &s */, (a + 4), (*(*int32)(unsafe.Pointer(bp + 152 /* iTermOff */)) - 4)) iOff = *(*int32)(unsafe.Pointer(bp + 152 /* iTermOff */)) __16: @@ -176464,8 +173771,8 @@ __12: goto decode_out goto __22 __21: - iRowidOff = int32(fts5GetU16(tls, (a + uintptr(0)))) - iPgidxOff1 = libc.AssignInt32(&szLeaf1, int32(fts5GetU16(tls, (a+uintptr(2))))) + iRowidOff = int32(fts5GetU16(tls, (a))) + iPgidxOff1 = libc.AssignInt32(&szLeaf1, int32(fts5GetU16(tls, (a+2)))) if !(iPgidxOff1 < n) { goto __23 } @@ -176475,7 +173782,7 @@ __23: if !(iPgidxOff1 > n) { goto __25 } - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) goto decode_out __25: ; @@ -176505,11 +173812,11 @@ __27: if !(iOff1 > n) { goto __30 } - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) goto decode_out __30: ; - fts5DecodePoslist(tls, bp+64 /* &rc */, bp+48 /* &s */, (a + uintptr(4)), (iOff1 - 4)) + fts5DecodePoslist(tls, bp+64 /* &rc */, bp+48 /* &s */, (a + 4), (iOff1 - 4)) // Decode any more doclist data that appears on the page before the // first term. @@ -176522,14 +173829,14 @@ __30: if !((nDoclist + iOff1) > n) { goto __31 } - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) goto decode_out __31: ; fts5DecodeDoclist(tls, bp+64 /* &rc */, bp+48 /* &s */, (a + uintptr(iOff1)), nDoclist) __32: - if !((iPgidxOff1 < n) && (*(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 0)) { + if !((iPgidxOff1 < n) && (*(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK)) { goto __33 } bFirst = (libc.Bool32(iPgidxOff1 == szLeaf1)) @@ -176551,7 +173858,7 @@ __35: if !(iEnd > szLeaf1) { goto __36 } - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) goto __33 __36: ; @@ -176563,7 +173870,7 @@ __36: if !(*(*int32)(unsafe.Pointer(bp + 188 /* nByte */)) > (*Fts5Buffer)(unsafe.Pointer(bp+168 /* &term1 */)).Fn) { goto __38 } - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) goto __33 __38: ; @@ -176574,7 +173881,7 @@ __37: if !((iOff1 + *(*int32)(unsafe.Pointer(bp + 188 /* nByte */))) > n) { goto __39 } - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) goto __33 __39: ; @@ -176598,7 +173905,7 @@ __4: decode_out: Xsqlite3_free(tls, a) - if !(*(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 0) { + if !(*(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK) { goto __40 } Xsqlite3_result_text(tls, pCtx, (*Fts5Buffer)(unsafe.Pointer(bp+48 /* &s */)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp+48 /* &s */)).Fn, libc.UintptrFromInt32(-1)) @@ -176616,7 +173923,7 @@ func fts5RowidFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) { if nArg == 0 { Xsqlite3_result_error(tls, pCtx, ts+31607 /* "should be: fts5_..." */, -1) } else { - zArg = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + zArg = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))) if 0 == Xsqlite3_stricmp(tls, zArg, ts+31644 /* "segment" */) { var iRowid I64 var segid int32 @@ -176625,9 +173932,9 @@ func fts5RowidFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) { Xsqlite3_result_error(tls, pCtx, ts+31652 /* "should be: fts5_..." */, -1) } else { - segid = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - pgno = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(2)*8))) - iRowid = (((((I64(segid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(pgno))) + segid = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + pgno = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + 2*8))) + iRowid = (((((I64(segid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(pgno))) Xsqlite3_result_int64(tls, pCtx, iRowid) } } else { @@ -176645,21 +173952,21 @@ func fts5RowidFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) { // SQLite error code is returned instead. func sqlite3Fts5IndexInit(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:222955:12: */ var rc int32 = Xsqlite3_create_function(tls, - db, ts+31743 /* "fts5_decode" */, 2, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + db, ts+31743 /* "fts5_decode" */, 2, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{fts5DecodeFunction})), uintptr(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_function(tls, db, ts+31755 /* "fts5_decode_none" */, 2, - 1, db, *(*uintptr)(unsafe.Pointer(&struct { + SQLITE_UTF8, db, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{fts5DecodeFunction})), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_function(tls, - db, ts+31772 /* "fts5_rowid" */, -1, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + db, ts+31772 /* "fts5_rowid" */, -1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{fts5RowidFunction})), uintptr(0), uintptr(0)) } @@ -176813,7 +174120,7 @@ type Fts5MatchPhrase = struct { // Return true if pTab is a contentless table. func fts5IsContentless(tls *libc.TLS, pTab uintptr) int32 { /* sqlite3.c:223290:12: */ - return (libc.Bool32((*Fts5Config)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FeContent == 1)) + return (libc.Bool32((*Fts5Config)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FeContent == FTS5_CONTENT_NONE)) } // Delete a virtual table handle allocated by fts5InitVtab(). @@ -176829,14 +174136,14 @@ func fts5FreeVtab(tls *libc.TLS, pTab uintptr) { /* sqlite3.c:223297:13: */ // The xDisconnect() virtual table method. func fts5DisconnectMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:223309:12: */ fts5FreeVtab(tls, pVtab) - return 0 + return SQLITE_OK } // The xDestroy() virtual table method. func fts5DestroyMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:223317:12: */ var pTab uintptr = pVtab var rc int32 = sqlite3Fts5DropAll(tls, (*Fts5Table)(unsafe.Pointer(pTab)).FpConfig) - if rc == 0 { + if rc == SQLITE_OK { fts5FreeVtab(tls, pVtab) } return rc @@ -176857,39 +174164,39 @@ func fts5InitVtab(tls *libc.TLS, bCreate int32, db uintptr, pAux uintptr, argc i var pGlobal uintptr = pAux var azConfig uintptr = argv - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 // Return code + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK // Return code *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)) = uintptr(0) // Results of parsing argc/argv var pTab uintptr = uintptr(0) // New virtual table object // Allocate the new vtab object and parse the configuration pTab = sqlite3Fts5MallocZero(tls, bp /* &rc */, int64(unsafe.Sizeof(Fts5FullTable{}))) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3Fts5ConfigParse(tls, pGlobal, db, argc, azConfig, bp+8 /* &pConfig */, pzErr) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig = *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)) (*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal = pGlobal } // Open the index sub-system - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3Fts5IndexOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)), bCreate, (pTab /* &.p */ + 32 /* &.pIndex */), pzErr) } // Open the storage sub-system - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3Fts5StorageOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)), (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex, bCreate, (pTab + 40 /* &.pStorage */), pzErr) } // Call sqlite3_declare_vtab() - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3Fts5ConfigDeclareVtab(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */))) } // Load the initial configuration - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*Fts5Config)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)))).FpzErrmsg = pzErr *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3Fts5IndexLoadConfig(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex) @@ -176897,7 +174204,7 @@ func fts5InitVtab(tls *libc.TLS, bCreate int32, db uintptr, pAux uintptr, argc i (*Fts5Config)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)))).FpzErrmsg = uintptr(0) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { fts5FreeVtab(tls, pTab) pTab = uintptr(0) } else if bCreate != 0 { @@ -176924,7 +174231,7 @@ func fts5CreateMethod(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv // support index-info flags. In that case this function is a no-op. func fts5SetUniqueFlag(tls *libc.TLS, pIdxInfo uintptr) { /* sqlite3.c:223439:13: */ { - *(*int32)(unsafe.Pointer(pIdxInfo + 80 /* &.idxFlags */)) |= (1) + *(*int32)(unsafe.Pointer(pIdxInfo + 80 /* &.idxFlags */)) |= (SQLITE_INDEX_SCAN_UNIQUE) } } @@ -177008,12 +174315,12 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* if (*Fts5Config)(unsafe.Pointer(pConfig)).FbLock != 0 { (*Fts5Table)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+31783 /* "recursively defi..." */, 0) - return 1 + return SQLITE_ERROR } idxStr = Xsqlite3_malloc(tls, (((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint * 6) + 1)) if idxStr == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxStr = idxStr (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FneedToFreeIdxStr = 1 @@ -177021,8 +174328,8 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* for i = 0; i < (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint; i++ { var p uintptr = ((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12) var iCol int32 = (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn - if (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 64) || - ((int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2) && (iCol >= nCol)) { + if (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) || + ((int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) && (iCol >= nCol)) { // A MATCH operator or equivalent if (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) == 0) || (iCol < 0) { // As there exists an unusable MATCH constraint this is an @@ -177030,7 +174337,7 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = 1e50 *(*int8)(unsafe.Pointer(idxStr + uintptr(iIdxStr))) = int8(0) - return 0 + return SQLITE_OK } else { if iCol == (nCol + 1) { if bSeenRank != 0 { @@ -177051,7 +174358,7 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) } } else if ((((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) && (bSeenEq == 0)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2)) && (iCol < 0) { + (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ)) && (iCol < 0) { *(*int8)(unsafe.Pointer(idxStr + uintptr(libc.PostIncInt32(&iIdxStr, 1)))) = int8('=') bSeenEq = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&iCons, 1) @@ -177063,14 +174370,14 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* var p uintptr = ((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12) if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn < 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) { var op int32 = int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) - if (op == 16) || (op == 8) { + if (op == SQLITE_INDEX_CONSTRAINT_LT) || (op == SQLITE_INDEX_CONSTRAINT_LE) { if bSeenLt != 0 { continue } *(*int8)(unsafe.Pointer(idxStr + uintptr(libc.PostIncInt32(&iIdxStr, 1)))) = int8('<') (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&iCons, 1) bSeenLt = 1 - } else if (op == 4) || (op == 32) { + } else if (op == SQLITE_INDEX_CONSTRAINT_GT) || (op == SQLITE_INDEX_CONSTRAINT_GE) { if bSeenGt != 0 { continue } @@ -177085,16 +174392,16 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* // Set idxFlags flags for the ORDER BY clause if (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnOrderBy == 1 { - var iSort int32 = (*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy + uintptr(0)*8)).FiColumn + var iSort int32 = (*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy)).FiColumn if (iSort == ((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol + 1)) && (bSeenMatch != 0) { - idxFlags = idxFlags | (0x0020) + idxFlags = idxFlags | (FTS5_BI_ORDER_RANK) } else if iSort == -1 { - idxFlags = idxFlags | (0x0040) + idxFlags = idxFlags | (FTS5_BI_ORDER_ROWID) } - if ((idxFlags) & (0x0020 | 0x0040)) != 0 { + if ((idxFlags) & (FTS5_BI_ORDER_RANK | FTS5_BI_ORDER_ROWID)) != 0 { (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).ForderByConsumed = 1 - if (*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy+uintptr(0)*8)).Fdesc != 0 { - idxFlags = idxFlags | (0x0080) + if (*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy)).Fdesc != 0 { + idxFlags = idxFlags | (FTS5_BI_ORDER_DESC) } } } @@ -177134,14 +174441,14 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* } (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = idxFlags - return 0 + return SQLITE_OK } func fts5NewTransaction(tls *libc.TLS, pTab uintptr) int32 { /* sqlite3.c:223640:12: */ var pCsr uintptr for pCsr = (*Fts5Global)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal)).FpCsr; pCsr != 0; pCsr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpNext { if (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab == pTab { - return 0 + return SQLITE_OK } } return sqlite3Fts5StorageReset(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage) @@ -177156,18 +174463,18 @@ func fts5OpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 { /* sqli var rc int32 // Return code rc = fts5NewTransaction(tls, pTab) - if rc == 0 { + if rc == SQLITE_OK { nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5Cursor{})) + (uint64((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) * uint64(unsafe.Sizeof(int32(0)))))) pCsr = Xsqlite3_malloc64(tls, uint64(nByte)) if pCsr != 0 { var pGlobal uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal libc.Xmemset(tls, pCsr, 0, Size_t(nByte)) - (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize = (pCsr + uintptr(1)*184) + (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize = (pCsr + 1*184) (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpNext = (*Fts5Global)(unsafe.Pointer(pGlobal)).FpCsr (*Fts5Global)(unsafe.Pointer(pGlobal)).FpCsr = pCsr (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId = libc.PreIncInt64(&(*Fts5Global)(unsafe.Pointer(pGlobal)).FiNextId, 1) } else { - rc = 7 + rc = SQLITE_NOMEM } } *(*uintptr)(unsafe.Pointer(ppCsr)) = pCsr @@ -177175,20 +174482,20 @@ func fts5OpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 { /* sqli } func fts5StmtType(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:223677:12: */ - if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 5 { + if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SCAN { if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FbDesc != 0 { - return 1 + return FTS5_STMT_SCAN_DESC } - return 0 + return FTS5_STMT_SCAN_ASC } - return 2 + return FTS5_STMT_LOOKUP } // This function is called after the cursor passed as the only argument // is moved to point at a different row. It clears all cached data // specific to the previous row stored by the cursor object. func fts5CsrNewrow(tls *libc.TLS, pCsr uintptr) { /* sqlite3.c:223689:13: */ - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (((0x02 | 0x04) | 0x08) | 0x40) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (((FTS5CSR_REQUIRE_CONTENT | FTS5CSR_REQUIRE_DOCSIZE) | FTS5CSR_REQUIRE_INST) | FTS5CSR_REQUIRE_POSLIST) } func fts5FreeCursorComponents(tls *libc.TLS, pCsr uintptr) { /* sqlite3.c:223698:13: */ @@ -177208,7 +174515,7 @@ func fts5FreeCursorComponents(tls *libc.TLS, pCsr uintptr) { /* sqlite3.c:223698 Xsqlite3_free(tls, pSorter) } - if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan != 2 { + if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan != FTS5_PLAN_SOURCE { sqlite3Fts5ExprFree(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) } @@ -177223,7 +174530,7 @@ func fts5FreeCursorComponents(tls *libc.TLS, pCsr uintptr) { /* sqlite3.c:223698 Xsqlite3_finalize(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRankArgStmt) Xsqlite3_free(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg) - if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x10)) != 0 { + if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_FREE_ZRANK)) != 0 { Xsqlite3_free(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRank) Xsqlite3_free(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs) } @@ -177248,7 +174555,7 @@ func fts5CloseMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:223742 Xsqlite3_free(tls, pCsr) } - return 0 + return SQLITE_OK } func fts5SorterNext(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:223758:12: */ @@ -177259,16 +174566,16 @@ func fts5SorterNext(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:223758:12: var rc int32 rc = Xsqlite3_step(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt) - if rc == 101 { - rc = 0 - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x01) - } else if rc == 100 { + if rc == SQLITE_DONE { + rc = SQLITE_OK + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_EOF) + } else if rc == SQLITE_ROW { var a uintptr var aBlob uintptr var nBlob int32 var i int32 var iOff int32 = 0 - rc = 0 + rc = SQLITE_OK (*Fts5Sorter)(unsafe.Pointer(pSorter)).FiRowid = Xsqlite3_column_int64(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt, 0) nBlob = Xsqlite3_column_bytes(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt, 1) @@ -177298,9 +174605,9 @@ func fts5SorterNext(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:223758:12: func fts5TripCursors(tls *libc.TLS, pTab uintptr) { /* sqlite3.c:223801:13: */ var pCsr uintptr for pCsr = (*Fts5Global)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal)).FpCsr; pCsr != 0; pCsr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpNext { - if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 1) && + if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_MATCH) && ((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab == pTab) { - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x20) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_REQUIRE_RESEEK) } } } @@ -177316,22 +174623,22 @@ func fts5TripCursors(tls *libc.TLS, pTab uintptr) { /* sqlite3.c:223801:13: */ // Return SQLITE_OK if successful or if no reseek was required, or an // error code if an error occurred. func fts5CursorReseek(tls *libc.TLS, pCsr uintptr, pbSkip uintptr) int32 { /* sqlite3.c:223824:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK - if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x20)) != 0 { + if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_REQUIRE_RESEEK)) != 0 { var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab var bDesc int32 = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FbDesc var iRowid I64 = sqlite3Fts5ExprRowid(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) rc = sqlite3Fts5ExprFirst(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex, iRowid, bDesc) - if (rc == 0) && (iRowid != sqlite3Fts5ExprRowid(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)) { + if (rc == SQLITE_OK) && (iRowid != sqlite3Fts5ExprRowid(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)) { *(*int32)(unsafe.Pointer(pbSkip)) = 1 } - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (^libc.Int32(0x20)) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (libc.CplInt32(FTS5CSR_REQUIRE_RESEEK)) fts5CsrNewrow(tls, pCsr) if sqlite3Fts5ExprEof(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) != 0 { - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x01) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_EOF) *(*int32)(unsafe.Pointer(pbSkip)) = 1 } } @@ -177361,16 +174668,16 @@ func fts5NextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:223856: fts5CsrNewrow(tls, pCsr) } else { switch (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan { - case 3: + case FTS5_PLAN_SPECIAL: { - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x01) - rc = 0 + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_EOF) + rc = SQLITE_OK break } fallthrough - case 4: + case FTS5_PLAN_SORTED_MATCH: { rc = fts5SorterNext(tls, pCsr) break @@ -177384,15 +174691,15 @@ func fts5NextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:223856: (*Fts5Config)(unsafe.Pointer(pConfig)).FbLock++ rc = Xsqlite3_step(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) (*Fts5Config)(unsafe.Pointer(pConfig)).FbLock-- - if rc != 100 { - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x01) + if rc != SQLITE_ROW { + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_EOF) rc = Xsqlite3_reset(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) - if rc != 0 { + if rc != SQLITE_OK { (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp, Xsqlite3_errmsg(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb))) } } else { - rc = 0 + rc = SQLITE_OK } break @@ -177416,11 +174723,11 @@ func fts5PrepareStatement(tls *libc.TLS, ppStmt uintptr, pConfig uintptr, zFmt u ap = va zSql = Xsqlite3_vmprintf(tls, zFmt, ap) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_prepare_v3(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -1, - uint32(0x01), bp+8 /* &pRet */, uintptr(0)) - if rc != 0 { + SQLITE_PREPARE_PERSISTENT, bp+8 /* &pRet */, uintptr(0)) + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp, Xsqlite3_errmsg(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb))) } Xsqlite3_free(tls, zSql) @@ -177447,7 +174754,7 @@ func fts5CursorFirstSorted(tls *libc.TLS, pTab uintptr, pCsr uintptr, bDesc int3 nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5Sorter{})) + (uint64(unsafe.Sizeof(int32(0))) * (uint64(nPhrase - 1))))) pSorter = Xsqlite3_malloc64(tls, uint64(nByte)) if pSorter == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pSorter, 0, Size_t(nByte)) (*Fts5Sorter)(unsafe.Pointer(pSorter)).FnIdx = nPhrase @@ -177482,14 +174789,14 @@ func fts5CursorFirstSorted(tls *libc.TLS, pTab uintptr, pCsr uintptr, bDesc int3 }())) (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter = pSorter - if rc == 0 { + if rc == SQLITE_OK { (*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr = pCsr rc = fts5SorterNext(tls, pCsr) (*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr = uintptr(0) } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_finalize(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt) Xsqlite3_free(tls, pSorter) (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter = uintptr(0) @@ -177503,7 +174810,7 @@ func fts5CursorFirst(tls *libc.TLS, pTab uintptr, pCsr uintptr, bDesc int32) int var pExpr uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr rc = sqlite3Fts5ExprFirst(tls, pExpr, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid, bDesc) if sqlite3Fts5ExprEof(tls, pExpr) != 0 { - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x01) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_EOF) } fts5CsrNewrow(tls, pCsr) return rc @@ -177517,17 +174824,17 @@ func fts5SpecialMatch(tls *libc.TLS, pTab uintptr, pCsr uintptr, zQuery uintptr) bp := tls.Alloc(16) defer tls.Free(16) - var rc int32 = 0 // Return code - var z uintptr = zQuery // Special query text - var n int32 // Number of bytes in text at z + var rc int32 = SQLITE_OK // Return code + var z uintptr = zQuery // Special query text + var n int32 // Number of bytes in text at z - for int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == ' ' { + for int32(*(*int8)(unsafe.Pointer(z))) == ' ' { z++ } for n = 0; (*(*int8)(unsafe.Pointer(z + uintptr(n))) != 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr(n)))) != ' '); n++ { } - (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = 3 + (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = FTS5_PLAN_SPECIAL if (n == 5) && (0 == Xsqlite3_strnicmp(tls, ts+31886 /* "reads" */, z, n)) { (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial = I64(sqlite3Fts5IndexReads(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)) @@ -177536,7 +174843,7 @@ func fts5SpecialMatch(tls *libc.TLS, pTab uintptr, pCsr uintptr, zQuery uintptr) } else { // An unrecognized directive. Return an error message. (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+31892 /* "unknown special ..." */, libc.VaList(bp, n, z)) - rc = 1 + rc = SQLITE_ERROR } return rc @@ -177564,7 +174871,7 @@ func fts5FindRankFunction(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:2240 var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK var pAux uintptr = uintptr(0) var zRank uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRank var zRankArgs uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs @@ -177574,16 +174881,16 @@ func fts5FindRankFunction(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:2240 if zSql != 0 { *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */)) = uintptr(0) *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = Xsqlite3_prepare_v3(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -1, - uint32(0x01), bp+24 /* &pStmt */, uintptr(0)) + SQLITE_PREPARE_PERSISTENT, bp+24 /* &pStmt */, uintptr(0)) Xsqlite3_free(tls, zSql) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */))) { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */))) { var nByte Sqlite3_int64 (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg = Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */))) nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(uintptr(0))) * uint64((*Fts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg))) (*Fts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg = sqlite3Fts5MallocZero(tls, bp+16 /* &rc */, nByte) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { var i int32 for i = 0; i < (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg; i++ { *(*uintptr)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg + uintptr(i)*8)) = Xsqlite3_column_value(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */)), i) @@ -177598,12 +174905,12 @@ func fts5FindRankFunction(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:2240 } } - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { pAux = fts5FindAuxiliary(tls, pTab, zRank) if pAux == uintptr(0) { (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+31930 /* "no such function..." */, libc.VaList(bp+8, zRank)) - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_ERROR } } @@ -177615,24 +174922,24 @@ func fts5CursorParseRank(tls *libc.TLS, pConfig uintptr, pCsr uintptr, pRank uin bp := tls.Alloc(24) defer tls.Free(24) - var rc int32 = 0 + var rc int32 = SQLITE_OK if pRank != 0 { var z uintptr = Xsqlite3_value_text(tls, pRank) *(*uintptr)(unsafe.Pointer(bp + 8 /* zRank */)) = uintptr(0) *(*uintptr)(unsafe.Pointer(bp + 16 /* zRankArgs */)) = uintptr(0) if z == uintptr(0) { - if Xsqlite3_value_type(tls, pRank) == 5 { - rc = 1 + if Xsqlite3_value_type(tls, pRank) == SQLITE_NULL { + rc = SQLITE_ERROR } } else { rc = sqlite3Fts5ConfigParseRank(tls, z, bp+8 /* &zRank */, bp+16 /* &zRankArgs */) } - if rc == 0 { + if rc == SQLITE_OK { (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRank = *(*uintptr)(unsafe.Pointer(bp + 8 /* zRank */)) (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs = *(*uintptr)(unsafe.Pointer(bp + 16 /* zRankArgs */)) - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x10) - } else if rc == 1 { + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_FREE_ZRANK) + } else if rc == SQLITE_ERROR { (*Sqlite3_vtab)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+31951 /* "parse error in r..." */, libc.VaList(bp, z)) } @@ -177651,7 +174958,7 @@ func fts5CursorParseRank(tls *libc.TLS, pConfig uintptr, pCsr uintptr, pRank uin func fts5GetRowidLimit(tls *libc.TLS, pVal uintptr, iDefault I64) I64 { /* sqlite3.c:224142:12: */ if pVal != 0 { var eType int32 = Xsqlite3_value_numeric_type(tls, pVal) - if eType == 1 { + if eType == SQLITE_INTEGER { return Xsqlite3_value_int64(tls, pVal) } } @@ -177692,7 +174999,7 @@ func fts5FilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintp pTab = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab pConfig = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig pCsr = pCursor - rc = 0 + rc = SQLITE_OK pRank = uintptr(0) pRowidEq = uintptr(0) pRowidLe = uintptr(0) @@ -177706,7 +175013,7 @@ func fts5FilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintp } (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+31783 /* "recursively defi..." */, 0) - return 1 + return SQLITE_ERROR __1: ; @@ -177772,26 +175079,26 @@ __13: __14: ; - if !(int32(*(*int8)(unsafe.Pointer(zText + uintptr(0)))) == '*') { + if !(int32(*(*int8)(unsafe.Pointer(zText))) == '*') { goto __18 } // The user has issued a query of the form "MATCH '*...'". This // indicates that the MATCH expression is not a full text query, // but a request for an internal parameter. - rc = fts5SpecialMatch(tls, pTab, pCsr, (zText + uintptr(1))) + rc = fts5SpecialMatch(tls, pTab, pCsr, (zText + 1)) goto filter_out goto __19 __18: pzErr = (pTab /* &.p */ /* &.base */ + 16 /* &.zErrMsg */) rc = sqlite3Fts5ExprNew(tls, pConfig, iCol, zText, bp+8 /* &pExpr */, pzErr) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __20 } rc = sqlite3Fts5ExprAnd(tls, (pCsr + 64 /* &.pExpr */), *(*uintptr)(unsafe.Pointer(bp + 8 /* pExpr */))) *(*uintptr)(unsafe.Pointer(bp + 8 /* pExpr */)) = uintptr(0) __20: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __21 } goto filter_out @@ -177822,13 +175129,13 @@ __4: __5: ; bOrderByRank = func() int32 { - if (idxNum & 0x0020) != 0 { + if (idxNum & FTS5_BI_ORDER_RANK) != 0 { return 1 } return 0 }() (*Fts5Cursor)(unsafe.Pointer(pCsr)).FbDesc = libc.AssignInt32(&bDesc, func() int32 { - if (idxNum & 0x0080) != 0 { + if (idxNum & FTS5_BI_ORDER_DESC) != 0 { return 1 } return 0 @@ -177877,7 +175184,7 @@ __27: (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = (*Fts5Cursor)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiFirstRowid __28: ; - (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = 2 + (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = FTS5_PLAN_SOURCE (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr = (*Fts5Cursor)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FpExpr rc = fts5CursorFirst(tls, pTab, pCsr, bDesc) goto __26 @@ -177886,17 +175193,17 @@ __25: goto __29 } rc = fts5CursorParseRank(tls, pConfig, pCsr, pRank) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __31 } if !(bOrderByRank != 0) { goto __32 } - (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = 4 + (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = FTS5_PLAN_SORTED_MATCH rc = fts5CursorFirstSorted(tls, pTab, pCsr, bDesc) goto __33 __32: - (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = 1 + (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = FTS5_PLAN_MATCH rc = fts5CursorFirst(tls, pTab, pCsr, bDesc) __33: ; @@ -177909,23 +175216,23 @@ __29: } *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg)) = Xsqlite3_mprintf(tls, ts+31984 /* "%s: table does n..." */, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) - rc = 1 + rc = SQLITE_ERROR goto __35 __34: // This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup // by rowid (ePlan==FTS5_PLAN_ROWID). (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = func() int32 { if pRowidEq != 0 { - return 6 + return FTS5_PLAN_ROWID } - return 5 + return FTS5_PLAN_SCAN }() rc = sqlite3Fts5StorageStmt(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, fts5StmtType(tls, pCsr), (pCsr + 56 /* &.pStmt */), (pTab /* &.p */ /* &.base */ + 16 /* &.zErrMsg */)) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __36 } - if !((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 6) { + if !((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_ROWID) { goto __37 } Xsqlite3_bind_value(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, 1, pRowidEq) @@ -177956,7 +175263,7 @@ filter_out: func fts5EofMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:224341:12: */ var pCsr uintptr = pCursor return func() int32 { - if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x01)) != 0 { + if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_EOF)) != 0 { return 1 } return 0 @@ -177983,15 +175290,15 @@ func fts5RowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { /* var ePlan int32 = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan switch ePlan { - case 3: + case FTS5_PLAN_SPECIAL: *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = int64(0) break - case 2: + case FTS5_PLAN_SOURCE: fallthrough - case 1: + case FTS5_PLAN_MATCH: fallthrough - case 4: + case FTS5_PLAN_SORTED_MATCH: *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = fts5CursorRowid(tls, pCsr) break @@ -178000,7 +175307,7 @@ func fts5RowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { /* break } - return 0 + return SQLITE_OK } // If the cursor requires seeking (bSeekRequired flag is set), seek it. @@ -178012,7 +175319,7 @@ func fts5SeekCursor(tls *libc.TLS, pCsr uintptr, bErrormsg int32) int32 { /* sql bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK // If the cursor does not yet have a statement handle, obtain one now. if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt == uintptr(0) { @@ -178028,7 +175335,7 @@ func fts5SeekCursor(tls *libc.TLS, pCsr uintptr, bErrormsg int32) int32 { /* sql } - if (rc == 0) && (((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x02)) != 0) { + if (rc == SQLITE_OK) && (((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_REQUIRE_CONTENT)) != 0) { var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab Xsqlite3_reset(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) @@ -178036,13 +175343,13 @@ func fts5SeekCursor(tls *libc.TLS, pCsr uintptr, bErrormsg int32) int32 { /* sql (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).FbLock++ rc = Xsqlite3_step(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).FbLock-- - if rc == 100 { - rc = 0 - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (^libc.Int32(0x02)) + if rc == SQLITE_ROW { + rc = SQLITE_OK + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (libc.CplInt32(FTS5CSR_REQUIRE_CONTENT)) } else { rc = Xsqlite3_reset(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) - if rc == 0 { - rc = (11 | (int32(1) << 8)) + if rc == SQLITE_OK { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } else if (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).FpzErrmsg != 0 { *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).FpzErrmsg)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp, Xsqlite3_errmsg(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).Fdb))) @@ -178079,23 +175386,23 @@ func fts5SpecialInsert(tls *libc.TLS, pTab uintptr, zCmd uintptr, pVal uintptr) defer tls.Free(4) var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig - var rc int32 = 0 + var rc int32 = SQLITE_OK *(*int32)(unsafe.Pointer(bp /* bError */)) = 0 if 0 == Xsqlite3_stricmp(tls, ts+32020 /* "delete-all" */, zCmd) { - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { fts5SetVtabError(tls, pTab, ts+32031 /* "'delete-all' may..." */, 0) - rc = 1 + rc = SQLITE_ERROR } else { rc = sqlite3Fts5StorageDeleteAll(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage) } } else if 0 == Xsqlite3_stricmp(tls, ts+32111 /* "rebuild" */, zCmd) { - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 1 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NONE { fts5SetVtabError(tls, pTab, ts+32119 /* "'rebuild' may no..." */, 0) - rc = 1 + rc = SQLITE_ERROR } else { rc = sqlite3Fts5StorageRebuild(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage) } @@ -178108,12 +175415,12 @@ func fts5SpecialInsert(tls *libc.TLS, pTab uintptr, zCmd uintptr, pVal uintptr) rc = sqlite3Fts5StorageIntegrity(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage) } else { rc = sqlite3Fts5IndexLoadConfig(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5ConfigSetValue(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig, zCmd, pVal, bp /* &bError */) } - if rc == 0 { + if rc == SQLITE_OK { if *(*int32)(unsafe.Pointer(bp /* bError */)) != 0 { - rc = 1 + rc = SQLITE_ERROR } else { rc = sqlite3Fts5StorageConfigValue(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, zCmd, pVal, 0) } @@ -178123,21 +175430,21 @@ func fts5SpecialInsert(tls *libc.TLS, pTab uintptr, zCmd uintptr, pVal uintptr) } func fts5SpecialDelete(tls *libc.TLS, pTab uintptr, apVal uintptr) int32 { /* sqlite3.c:224515:12: */ - var rc int32 = 0 - var eType1 int32 = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - if eType1 == 1 { - var iDel Sqlite3_int64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - rc = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iDel, (apVal + uintptr(2)*8)) + var rc int32 = SQLITE_OK + var eType1 int32 = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + if eType1 == SQLITE_INTEGER { + var iDel Sqlite3_int64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + rc = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iDel, (apVal + 2*8)) } return rc } func fts5StorageInsert(tls *libc.TLS, pRc uintptr, pTab uintptr, apVal uintptr, piRowid uintptr) { /* sqlite3.c:224528:13: */ var rc int32 = *(*int32)(unsafe.Pointer(pRc)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5StorageContentInsert(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, piRowid) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5StorageIndexInsert(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, *(*I64)(unsafe.Pointer(piRowid))) } *(*int32)(unsafe.Pointer(pRc)) = rc @@ -178161,8 +175468,8 @@ func fts5UpdateMethod(tls *libc.TLS, pVtab uintptr, nArg int32, apVal uintptr, p var pTab uintptr = pVtab var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig - var eType0 int32 // value_type() of apVal[0] - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 0 // Return code + var eType0 int32 // value_type() of apVal[0] + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK // Return code // A transaction must be open when this is called. @@ -178171,12 +175478,12 @@ func fts5UpdateMethod(tls *libc.TLS, pVtab uintptr, nArg int32, apVal uintptr, p // Put any active cursors into REQUIRE_SEEK state. fts5TripCursors(tls, pTab) - eType0 = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) - if (eType0 == 5) && - (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr((2+(*Fts5Config)(unsafe.Pointer(pConfig)).FnCol))*8))) != 5) { + eType0 = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal))) + if (eType0 == SQLITE_NULL) && + (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr((2+(*Fts5Config)(unsafe.Pointer(pConfig)).FnCol))*8))) != SQLITE_NULL) { // A "special" INSERT op. These are handled separately. var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr((2+(*Fts5Config)(unsafe.Pointer(pConfig)).FnCol))*8))) - if ((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != 0) && + if ((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL) && (0 == Xsqlite3_stricmp(tls, ts+15075 /* "delete" */, z)) { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = fts5SpecialDelete(tls, pTab, apVal) } else { @@ -178193,14 +175500,14 @@ func fts5UpdateMethod(tls *libc.TLS, pVtab uintptr, nArg int32, apVal uintptr, p // 4) INSERT // // Cases 3 and 4 may violate the rowid constraint. - var eConflict int32 = 4 - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0 { + var eConflict int32 = SQLITE_ABORT + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { eConflict = Xsqlite3_vtab_on_conflict(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb) } // Filter out attempts to run UPDATE or DELETE on contentless tables. // This is not suported. - if (eType0 == 1) && (fts5IsContentless(tls, pTab) != 0) { + if (eType0 == SQLITE_INTEGER) && (fts5IsContentless(tls, pTab) != 0) { (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+32197, /* "cannot %s conten..." */ libc.VaList(bp, func() uintptr { @@ -178209,38 +175516,38 @@ func fts5UpdateMethod(tls *libc.TLS, pVtab uintptr, nArg int32, apVal uintptr, p } return ts + 32241 /* "DELETE from" */ }(), (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_ERROR } else if nArg == 1 { - var iDel I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) // Rowid to delete + var iDel I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal))) // Rowid to delete *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iDel, uintptr(0)) } else { - var eType1 int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) + var eType1 int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) - if (eType1 != 1) && (eType1 != 5) { - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 20 - } else if eType0 != 1 { + if (eType1 != SQLITE_INTEGER) && (eType1 != SQLITE_NULL) { + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_MISMATCH + } else if eType0 != SQLITE_INTEGER { // If this is a REPLACE, first remove the current entry (if any) - if (eConflict == 5) && (eType1 == 1) { - var iNew I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) // Rowid to delete + if (eConflict == SQLITE_REPLACE) && (eType1 == SQLITE_INTEGER) { + var iNew I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) // Rowid to delete *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iNew, uintptr(0)) } fts5StorageInsert(tls, bp+16 /* &rc */, pTab, apVal, pRowid) } else { - var iOld I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) // Old rowid - var iNew I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) // New rowid - if (eType1 == 1) && (iOld != iNew) { - if eConflict == 5 { + var iOld I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal))) // Old rowid + var iNew I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) // New rowid + if (eType1 == SQLITE_INTEGER) && (iOld != iNew) { + if eConflict == SQLITE_REPLACE { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iOld, uintptr(0)) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iNew, uintptr(0)) } fts5StorageInsert(tls, bp+16 /* &rc */, pTab, apVal, pRowid) } else { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageContentInsert(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, pRowid) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iOld, uintptr(0)) } - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageIndexInsert(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, *(*Sqlite_int64)(unsafe.Pointer(pRowid))) } } @@ -178272,7 +175579,7 @@ func fts5SyncMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:224684:12 func fts5BeginMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:224698:12: */ fts5NewTransaction(tls, pVtab) - return 0 + return SQLITE_OK } // Implementation of xCommit() method. This is a no-op. The contents of @@ -178281,7 +175588,7 @@ func fts5BeginMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:224698:1 func fts5CommitMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:224709:12: */ _ = pVtab // Call below is a no-op for NDEBUG builds - return 0 + return SQLITE_OK } // Implementation of xRollback(). Discard the contents of the pending-terms @@ -178320,7 +175627,7 @@ func fts5ApiTokenize(tls *libc.TLS, pCtx uintptr, pText uintptr, nText int32, pU var pCsr uintptr = pCtx var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab return sqlite3Fts5Tokenize(tls, - (*Fts5Table)(unsafe.Pointer(pTab)).FpConfig, 0x0008, pText, nText, pUserData, xToken) + (*Fts5Table)(unsafe.Pointer(pTab)).FpConfig, FTS5_TOKENIZE_AUX, pText, nText, pUserData, xToken) } func fts5ApiPhraseCount(tls *libc.TLS, pCtx uintptr) int32 { /* sqlite3.c:224768:12: */ @@ -178334,15 +175641,15 @@ func fts5ApiPhraseSize(tls *libc.TLS, pCtx uintptr, iPhrase int32) int32 { /* sq } func fts5ApiColumnText(tls *libc.TLS, pCtx uintptr, iCol int32, pz uintptr, pn uintptr) int32 { /* sqlite3.c:224778:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pCsr uintptr = pCtx if (fts5IsContentless(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab) != 0) || - ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 3) { + ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SPECIAL) { *(*uintptr)(unsafe.Pointer(pz)) = uintptr(0) *(*int32)(unsafe.Pointer(pn)) = 0 } else { rc = fts5SeekCursor(tls, pCsr, 0) - if rc == 0 { + if rc == SQLITE_OK { *(*uintptr)(unsafe.Pointer(pz)) = Xsqlite3_column_text(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, (iCol + 1)) *(*int32)(unsafe.Pointer(pn)) = Xsqlite3_column_bytes(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, (iCol + 1)) } @@ -178355,25 +175662,25 @@ func fts5CsrPoslist(tls *libc.TLS, pCsr uintptr, iPhrase int32, pa uintptr, pn u defer tls.Free(12) var pConfig uintptr = (*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig - var rc int32 = 0 + var rc int32 = SQLITE_OK var bLive int32 = (libc.Bool32((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter == uintptr(0))) - if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x40)) != 0 { + if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_REQUIRE_POSLIST)) != 0 { - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail != 0 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail != FTS5_DETAIL_FULL { var aPopulator uintptr var i int32 aPopulator = sqlite3Fts5ExprClearPoslists(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, bLive) if aPopulator == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } - for i = 0; (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) && (rc == 0); i++ { + for i = 0; (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) && (rc == SQLITE_OK); i++ { // var n int32 at bp+8, 4 // var z uintptr at bp, 8 rc = fts5ApiColumnText(tls, pCsr, i, bp /* &z */, bp+8 /* &n */) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5ExprPopulatePoslists(tls, pConfig, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, aPopulator, i, *(*uintptr)(unsafe.Pointer(bp /* z */)), *(*int32)(unsafe.Pointer(bp + 8 /* n */))) } @@ -178384,10 +175691,10 @@ func fts5CsrPoslist(tls *libc.TLS, pCsr uintptr, iPhrase int32, pa uintptr, pn u sqlite3Fts5ExprCheckPoslists(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, (*Fts5Sorter)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter)).FiRowid) } } - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (^libc.Int32(0x40)) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (libc.CplInt32(FTS5CSR_REQUIRE_POSLIST)) } - if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 0) { + if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_FULL) { var pSorter uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter var i1 int32 = func() int32 { if iPhrase == 0 { @@ -178411,7 +175718,7 @@ func fts5CacheInstArray(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:224853 bp := tls.Alloc(20) defer tls.Free(20) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var aIter uintptr // One iterator for each phrase var nIter int32 // Number of iterators/phrases var nCol int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig)).FnCol @@ -178428,18 +175735,18 @@ func fts5CacheInstArray(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:224853 var i int32 // Initialize all iterators - for i = 0; (i < nIter) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0); i++ { + for i = 0; (i < nIter) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK); i++ { // var a uintptr at bp+8, 8 // var n int32 at bp+16, 4 *(*int32)(unsafe.Pointer(bp /* rc */)) = fts5CsrPoslist(tls, pCsr, i, bp+8 /* &a */, bp+16 /* &n */) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { sqlite3Fts5PoslistReaderInit(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* a */)), *(*int32)(unsafe.Pointer(bp + 16 /* n */)), (aIter + uintptr(i)*32)) } } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { for 1 != 0 { var aInst uintptr var iBest int32 = -1 @@ -178466,17 +175773,17 @@ func fts5CacheInstArray(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:224853 if aInst != 0 { (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst = aInst } else { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_NOMEM break } } aInst = ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr((3*(nInst-1)))*4) - *(*int32)(unsafe.Pointer(aInst + uintptr(0)*4)) = iBest - *(*int32)(unsafe.Pointer(aInst + uintptr(1)*4)) = (int32((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(iBest)*32)).FiPos >> 32)) - *(*int32)(unsafe.Pointer(aInst + uintptr(2)*4)) = (int32((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(iBest)*32)).FiPos & int64(0x7FFFFFFF))) - if (*(*int32)(unsafe.Pointer(aInst + uintptr(1)*4)) < 0) || (*(*int32)(unsafe.Pointer(aInst + uintptr(1)*4)) >= nCol) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(aInst)) = iBest + *(*int32)(unsafe.Pointer(aInst + 1*4)) = (int32((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(iBest)*32)).FiPos >> 32)) + *(*int32)(unsafe.Pointer(aInst + 2*4)) = (int32((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(iBest)*32)).FiPos & int64(0x7FFFFFFF))) + if (*(*int32)(unsafe.Pointer(aInst + 1*4)) < 0) || (*(*int32)(unsafe.Pointer(aInst + 1*4)) >= nCol) { + *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) break } sqlite3Fts5PoslistReaderNext(tls, (aIter + uintptr(iBest)*32)) @@ -178484,16 +175791,16 @@ func fts5CacheInstArray(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:224853 } (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount = nInst - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (^libc.Int32(0x08)) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (libc.CplInt32(FTS5CSR_REQUIRE_INST)) } return *(*int32)(unsafe.Pointer(bp /* rc */)) } func fts5ApiInstCount(tls *libc.TLS, pCtx uintptr, pnInst uintptr) int32 { /* sqlite3.c:224925:12: */ var pCsr uintptr = pCtx - var rc int32 = 0 - if (((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x08)) == 0) || - (0 == (libc.AssignInt32(&rc, fts5CacheInstArray(tls, pCsr)))) { + var rc int32 = SQLITE_OK + if (((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_REQUIRE_INST)) == 0) || + (SQLITE_OK == (libc.AssignInt32(&rc, fts5CacheInstArray(tls, pCsr)))) { *(*int32)(unsafe.Pointer(pnInst)) = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount } return rc @@ -178501,11 +175808,11 @@ func fts5ApiInstCount(tls *libc.TLS, pCtx uintptr, pnInst uintptr) int32 { /* sq func fts5ApiInst(tls *libc.TLS, pCtx uintptr, iIdx int32, piPhrase uintptr, piCol uintptr, piOff uintptr) int32 { /* sqlite3.c:224935:12: */ var pCsr uintptr = pCtx - var rc int32 = 0 - if (((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x08)) == 0) || - (0 == (libc.AssignInt32(&rc, fts5CacheInstArray(tls, pCsr)))) { + var rc int32 = SQLITE_OK + if (((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_REQUIRE_INST)) == 0) || + (SQLITE_OK == (libc.AssignInt32(&rc, fts5CacheInstArray(tls, pCsr)))) { if (iIdx < 0) || (iIdx >= (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount) { - rc = 25 + rc = SQLITE_RANGE } else { *(*int32)(unsafe.Pointer(piPhrase)) = *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr((iIdx*3))*4)) *(*int32)(unsafe.Pointer(piCol)) = *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(((iIdx*3)+1))*4)) @@ -178525,10 +175832,10 @@ func fts5ColumnSizeCb(tls *libc.TLS, pContext uintptr, tflags int32, pUnused uin _ = nUnused _ = iUnused1 _ = iUnused2 - if (tflags & 0x0001) == 0 { + if (tflags & FTS5_TOKEN_COLOCATED) == 0 { (*(*int32)(unsafe.Pointer(pCnt)))++ } - return 0 + return SQLITE_OK } func fts5ApiColumnSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) int32 { /* sqlite3.c:224985:12: */ @@ -178538,9 +175845,9 @@ func fts5ApiColumnSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) var pCsr uintptr = pCtx var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig - var rc int32 = 0 + var rc int32 = SQLITE_OK - if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x04)) != 0 { + if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_REQUIRE_DOCSIZE)) != 0 { if (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { var iRowid I64 = fts5CursorRowid(tls, pCsr) rc = sqlite3Fts5StorageDocsize(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iRowid, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize) @@ -178553,7 +175860,7 @@ func fts5ApiColumnSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) } } else { var i int32 - for i = 0; (rc == 0) && (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); i++ { if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(i)))) == 0 { // var z uintptr at bp, 8 @@ -178562,16 +175869,16 @@ func fts5ApiColumnSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) var p uintptr = ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(i)*4) *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(i)*4)) = 0 rc = fts5ApiColumnText(tls, pCtx, i, bp /* &z */, bp+8 /* &n */) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5Tokenize(tls, - pConfig, 0x0008, *(*uintptr)(unsafe.Pointer(bp /* z */)), *(*int32)(unsafe.Pointer(bp + 8 /* n */)), p, *(*uintptr)(unsafe.Pointer(&struct { + pConfig, FTS5_TOKENIZE_AUX, *(*uintptr)(unsafe.Pointer(bp /* z */)), *(*int32)(unsafe.Pointer(bp + 8 /* n */)), p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5ColumnSizeCb}))) } } } } - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (^libc.Int32(0x04)) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (libc.CplInt32(FTS5CSR_REQUIRE_DOCSIZE)) } if iCol < 0 { var i int32 @@ -178583,7 +175890,7 @@ func fts5ApiColumnSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) *(*int32)(unsafe.Pointer(pnToken)) = *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(iCol)*4)) } else { *(*int32)(unsafe.Pointer(pnToken)) = 0 - rc = 25 + rc = SQLITE_RANGE } return rc } @@ -178609,7 +175916,7 @@ func fts5ApiSetAuxdata(tls *libc.TLS, pCtx uintptr, pPtr uintptr, xDelete uintpt (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((pData + 16 /* &.xDelete */))))(tls, (*Fts5Auxdata)(unsafe.Pointer(pData)).FpPtr) } } else { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK pData = sqlite3Fts5MallocZero(tls, bp /* &rc */, int64(unsafe.Sizeof(Fts5Auxdata{}))) if pData == uintptr(0) { if xDelete != 0 { @@ -178624,7 +175931,7 @@ func fts5ApiSetAuxdata(tls *libc.TLS, pCtx uintptr, pPtr uintptr, xDelete uintpt (*Fts5Auxdata)(unsafe.Pointer(pData)).FxDelete = xDelete (*Fts5Auxdata)(unsafe.Pointer(pData)).FpPtr = pPtr - return 0 + return SQLITE_OK } func fts5ApiGetAuxdata(tls *libc.TLS, pCtx uintptr, bClear int32) uintptr { /* sqlite3.c:225073:13: */ @@ -178679,7 +175986,7 @@ func fts5ApiPhraseFirst(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter uintpt // var n int32 at bp, 4 var rc int32 = fts5CsrPoslist(tls, pCsr, iPhrase, (pIter /* &.a */), bp /* &n */) - if rc == 0 { + if rc == SQLITE_OK { (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb = ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(*(*int32)(unsafe.Pointer(bp /* n */)))) *(*int32)(unsafe.Pointer(piCol)) = 0 *(*int32)(unsafe.Pointer(piOff)) = 0 @@ -178695,13 +176002,13 @@ func fts5ApiPhraseNextColumn(tls *libc.TLS, pCtx uintptr, pIter uintptr, piCol u var pCsr uintptr = pCtx var pConfig uintptr = (*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 2 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_COLUMNS { if (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa >= (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb { *(*int32)(unsafe.Pointer(piCol)) = -1 } else { // var iIncr int32 at bp, 4 - *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(sqlite3Fts5GetVarint32(tls, ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(0)), bp /* &iIncr */))) + *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(sqlite3Fts5GetVarint32(tls, ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa), bp /* &iIncr */))) *(*int32)(unsafe.Pointer(piCol)) += (*(*int32)(unsafe.Pointer(bp /* iIncr */)) - 2) } } else { @@ -178712,12 +176019,12 @@ func fts5ApiPhraseNextColumn(tls *libc.TLS, pCtx uintptr, pIter uintptr, piCol u *(*int32)(unsafe.Pointer(piCol)) = -1 return } - if int32(*(*uint8)(unsafe.Pointer((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(0)))) == 0x01 { + if int32(*(*uint8)(unsafe.Pointer((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa))) == 0x01 { break } *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(sqlite3Fts5GetVarint32(tls, (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp+4 /* &dummy */))) } - *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(1 + sqlite3Fts5GetVarint32(tls, ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa+uintptr(1)), piCol))) + *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(1 + sqlite3Fts5GetVarint32(tls, ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa+1), piCol))) } } @@ -178725,11 +176032,11 @@ func fts5ApiPhraseFirstColumn(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var pCsr uintptr = pCtx var pConfig uintptr = (*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 2 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_COLUMNS { var pSorter uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter // var n int32 at bp, 4 @@ -178745,7 +176052,7 @@ func fts5ApiPhraseFirstColumn(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter } else { rc = sqlite3Fts5ExprPhraseCollist(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase, (pIter /* &.a */), bp /* &n */) } - if rc == 0 { + if rc == SQLITE_OK { (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb = ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(*(*int32)(unsafe.Pointer(bp /* n */)))) *(*int32)(unsafe.Pointer(piCol)) = 0 fts5ApiPhraseNextColumn(tls, pCtx, pIter, piCol) @@ -178754,12 +176061,12 @@ func fts5ApiPhraseFirstColumn(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter // var n int32 at bp+4, 4 rc = fts5CsrPoslist(tls, pCsr, iPhrase, (pIter /* &.a */), bp+4 /* &n */) - if rc == 0 { + if rc == SQLITE_OK { (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb = ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(*(*int32)(unsafe.Pointer(bp + 4 /* n */)))) if *(*int32)(unsafe.Pointer(bp + 4 /* n */)) <= 0 { *(*int32)(unsafe.Pointer(piCol)) = -1 - } else if int32(*(*uint8)(unsafe.Pointer((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(0)))) == 0x01 { - *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(1 + sqlite3Fts5GetVarint32(tls, ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa+uintptr(1)), piCol))) + } else if int32(*(*uint8)(unsafe.Pointer((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa))) == 0x01 { + *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(1 + sqlite3Fts5GetVarint32(tls, ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa+1), piCol))) } else { *(*int32)(unsafe.Pointer(piCol)) = 0 } @@ -178770,9 +176077,8 @@ func fts5ApiPhraseFirstColumn(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter } var sFts5Api = Fts5ExtensionApi{ - FiVersion: 2, - FxUserData:// iVersion - 0, + FiVersion: 2, // iVersion + FxUserData: 0, FxColumnCount: 0, FxRowCount: 0, FxColumnTotalSize: 0, @@ -178804,20 +176110,20 @@ func fts5ApiQueryPhrase(tls *libc.TLS, pCtx uintptr, iPhrase int32, pUserData ui *(*uintptr)(unsafe.Pointer(bp /* pNew */)) = uintptr(0) rc = fts5OpenMethod(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab, bp /* &pNew */) - if rc == 0 { - (*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pNew */)))).FePlan = 1 + if rc == SQLITE_OK { + (*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pNew */)))).FePlan = FTS5_PLAN_MATCH (*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pNew */)))).FiFirstRowid = ((int64(-1)) - (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))) (*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pNew */)))).FiLastRowid = (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32)) (*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pNew */)))).Fbase.FpVtab = pTab rc = sqlite3Fts5ExprClonePhrase(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase, (*(*uintptr)(unsafe.Pointer(bp /* pNew */)) + 64 /* &.pExpr */)) } - if rc == 0 { - for rc = fts5CursorFirst(tls, pTab, *(*uintptr)(unsafe.Pointer(bp /* pNew */)), 0); (rc == 0) && (((*Fts5Cursor)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNew */))))).Fcsrflags & (0x01)) == 0); rc = fts5NextMethod(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */))) { + if rc == SQLITE_OK { + for rc = fts5CursorFirst(tls, pTab, *(*uintptr)(unsafe.Pointer(bp /* pNew */)), 0); (rc == SQLITE_OK) && (((*Fts5Cursor)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNew */))))).Fcsrflags & (FTS5CSR_EOF)) == 0); rc = fts5NextMethod(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */))) { rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&xCallback)))(tls, uintptr(unsafe.Pointer(&sFts5Api)), *(*uintptr)(unsafe.Pointer(bp /* pNew */)), pUserData) - if rc != 0 { - if rc == 101 { - rc = 0 + if rc != SQLITE_OK { + if rc == SQLITE_DONE { + rc = SQLITE_OK } break } @@ -178854,7 +176160,7 @@ func fts5ApiCallback(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { var iCsrId I64 pAux = Xsqlite3_user_data(tls, context) - iCsrId = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + iCsrId = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) pCsr = fts5CursorFromCsrid(tls, (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpGlobal, iCsrId) if (pCsr == uintptr(0)) || ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 0) { @@ -178862,7 +176168,7 @@ func fts5ApiCallback(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { Xsqlite3_result_error(tls, context, zErr, -1) Xsqlite3_free(tls, zErr) } else { - fts5ApiInvoke(tls, pAux, pCsr, context, (argc - 1), (argv + uintptr(1)*8)) + fts5ApiInvoke(tls, pAux, pCsr, context, (argc - 1), (argv + 1*8)) } } @@ -178895,13 +176201,13 @@ func fts5PoslistBlob(tls *libc.TLS, pCtx uintptr, pCsr uintptr) int32 { /* sqlit defer tls.Free(68) var i int32 - *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = SQLITE_OK var nPhrase int32 = sqlite3Fts5ExprPhraseCount(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) // var val Fts5Buffer at bp, 16 libc.Xmemset(tls, bp /* &val */, 0, uint64(unsafe.Sizeof(Fts5Buffer{}))) switch (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig)).FeDetail { - case 0: + case FTS5_DETAIL_FULL: // Append the varints for i = 0; i < (nPhrase - 1); i++ { @@ -178921,10 +176227,10 @@ func fts5PoslistBlob(tls *libc.TLS, pCtx uintptr, pCsr uintptr) int32 { /* sqlit } break - case 2: + case FTS5_DETAIL_COLUMNS: // Append the varints - for i = 0; (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0) && (i < (nPhrase - 1)); i++ { + for i = 0; (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK) && (i < (nPhrase - 1)); i++ { // var dummy uintptr at bp+40, 8 // var nByte int32 at bp+48, 4 @@ -178934,7 +176240,7 @@ func fts5PoslistBlob(tls *libc.TLS, pCtx uintptr, pCsr uintptr) int32 { /* sqlit } // Append the position lists - for i = 0; (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0) && (i < nPhrase); i++ { + for i = 0; (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK) && (i < nPhrase); i++ { // var pPoslist uintptr at bp+56, 8 // var nPoslist int32 at bp+64, 4 @@ -178958,9 +176264,9 @@ func fts5ColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol int32) var pTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig var pCsr uintptr = pCursor - var rc int32 = 0 + var rc int32 = SQLITE_OK - if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 3 { + if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SPECIAL { if iCol == (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol { Xsqlite3_result_int64(tls, pCtx, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial) } @@ -178973,18 +176279,18 @@ func fts5ColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol int32) } else if iCol == ((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol + 1) { // The value of the "rank" column. - if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 2 { + if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SOURCE { fts5PoslistBlob(tls, pCtx, pCsr) - } else if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 1) || - ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 4) { - if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRank != 0) || (0 == (libc.AssignInt32(&rc, fts5FindRankFunction(tls, pCsr)))) { + } else if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_MATCH) || + ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SORTED_MATCH) { + if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRank != 0) || (SQLITE_OK == (libc.AssignInt32(&rc, fts5FindRankFunction(tls, pCsr)))) { fts5ApiInvoke(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRank, pCsr, pCtx, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg) } } } else if !(fts5IsContentless(tls, pTab) != 0) { (*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = (pTab /* &.p */ /* &.base */ + 16 /* &.zErrMsg */) rc = fts5SeekCursor(tls, pCsr, 1) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_result_value(tls, pCtx, Xsqlite3_column_value(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, (iCol+1))) } (*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = uintptr(0) @@ -179056,7 +176362,7 @@ func fts5RollbackToMethod(tls *libc.TLS, pVtab uintptr, iSavepoint int32) int32 func fts5CreateAux(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData uintptr, xFunc Fts5_extension_function, xDestroy uintptr) int32 { /* sqlite3.c:225537:12: */ var pGlobal uintptr = pApi var rc int32 = Xsqlite3_overload_function(tls, (*Fts5Global)(unsafe.Pointer(pGlobal)).Fdb, zName, -1) - if rc == 0 { + if rc == SQLITE_OK { var pAux uintptr var nName Sqlite3_int64 // Size of zName in bytes, including \0 var nByte Sqlite3_int64 // Bytes of space to allocate @@ -179066,7 +176372,7 @@ func fts5CreateAux(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData uintptr pAux = Xsqlite3_malloc64(tls, uint64(nByte)) if pAux != 0 { libc.Xmemset(tls, pAux, 0, Size_t(nByte)) - (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc = (pAux + uintptr(1)*48) + (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc = (pAux + 1*48) libc.Xmemcpy(tls, (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc, zName, uint64(nName)) (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpGlobal = pGlobal (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpUserData = pUserData @@ -179075,7 +176381,7 @@ func fts5CreateAux(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData uintptr (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpNext = (*Fts5Global)(unsafe.Pointer(pGlobal)).FpAux (*Fts5Global)(unsafe.Pointer(pGlobal)).FpAux = pAux } else { - rc = 7 + rc = SQLITE_NOMEM } } @@ -179089,14 +176395,14 @@ func fts5CreateTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData u var pNew uintptr var nName Sqlite3_int64 // Size of zName and its \0 terminator var nByte Sqlite3_int64 // Bytes of space to allocate - var rc int32 = 0 + var rc int32 = SQLITE_OK nName = (Sqlite3_int64(libc.Xstrlen(tls, zName) + uint64(1))) nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5TokenizerModule{})) + uint64(nName))) pNew = Xsqlite3_malloc64(tls, uint64(nByte)) if pNew != 0 { libc.Xmemset(tls, pNew, 0, Size_t(nByte)) - (*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FzName = (pNew + uintptr(1)*56) + (*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FzName = (pNew + 1*56) libc.Xmemcpy(tls, (*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FzName, zName, uint64(nName)) (*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FpUserData = pUserData (*Fts5TokenizerModule)(unsafe.Pointer(pNew)).Fx = *(*Fts5_tokenizer)(unsafe.Pointer(pTokenizer)) @@ -179107,7 +176413,7 @@ func fts5CreateTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData u (*Fts5Global)(unsafe.Pointer(pGlobal)).FpDfltTok = pNew } } else { - rc = 7 + rc = SQLITE_NOMEM } return rc @@ -179132,7 +176438,7 @@ func fts5LocateTokenizer(tls *libc.TLS, pGlobal uintptr, zName uintptr) uintptr // Find a tokenizer. This is the implementation of the // fts5_api.xFindTokenizer() method. func fts5FindTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, ppUserData uintptr, pTokenizer uintptr) int32 { /* sqlite3.c:225632:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pMod uintptr pMod = fts5LocateTokenizer(tls, pApi, zName) @@ -179141,7 +176447,7 @@ func fts5FindTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, ppUserData ui *(*uintptr)(unsafe.Pointer(ppUserData)) = (*Fts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData } else { libc.Xmemset(tls, pTokenizer, 0, uint64(unsafe.Sizeof(Fts5_tokenizer{}))) - rc = 1 + rc = SQLITE_ERROR } return rc @@ -179152,32 +176458,32 @@ func sqlite3Fts5GetTokenizer(tls *libc.TLS, pGlobal uintptr, azArg uintptr, nArg defer tls.Free(8) var pMod uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK pMod = fts5LocateTokenizer(tls, pGlobal, func() uintptr { if nArg == 0 { return uintptr(0) } - return *(*uintptr)(unsafe.Pointer(azArg + uintptr(0)*8)) + return *(*uintptr)(unsafe.Pointer(azArg)) }()) if pMod == uintptr(0) { - rc = 1 - *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+32274 /* "no such tokenize..." */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(azArg + uintptr(0)*8)))) + rc = SQLITE_ERROR + *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+32274 /* "no such tokenize..." */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(azArg)))) } else { - rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pMod + 16 /* &.x */ /* &.xCreate */))))(tls, (*Fts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData, (azArg + uintptr(1)*8), func() int32 { + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pMod + 16 /* &.x */ /* &.xCreate */))))(tls, (*Fts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData, (azArg + 1*8), func() int32 { if nArg != 0 { return (nArg - 1) } return 0 }(), ppTok) *(*uintptr)(unsafe.Pointer(ppTokApi)) = (pMod + 16 /* &.x */) - if (rc != 0) && (pzErr != 0) { + if (rc != SQLITE_OK) && (pzErr != 0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+32296 /* "error in tokeniz..." */, 0) } } - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(ppTokApi)) = uintptr(0) *(*uintptr)(unsafe.Pointer(ppTok)) = uintptr(0) } @@ -179216,7 +176522,7 @@ func fts5Fts5Func(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { /* s var ppApi uintptr _ = nArg - ppApi = Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8)), ts+32327 /* "fts5_api_ptr" */) + ppApi = Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(apArg)), ts+32327 /* "fts5_api_ptr" */) if ppApi != 0 { *(*uintptr)(unsafe.Pointer(ppApi)) = (pGlobal /* &.api */) } @@ -179252,7 +176558,7 @@ func fts5Init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:225746:12: */ pGlobal = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5Global{}))) if pGlobal == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var p uintptr = pGlobal libc.Xmemset(tls, pGlobal, 0, uint64(unsafe.Sizeof(Fts5Global{}))) @@ -179268,30 +176574,30 @@ func fts5Init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:225746:12: */ f func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32 }{fts5FindTokenizer})) rc = Xsqlite3_create_module_v2(tls, db, ts+32438 /* "fts5" */, uintptr(unsafe.Pointer(&fts5Mod)), p, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5ModuleDestroy}))) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5IndexInit(tls, db) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5ExprInit(tls, pGlobal, db) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5AuxInit(tls, (pGlobal /* &.api */)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5TokenizerInit(tls, (pGlobal /* &.api */)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5VocabInit(tls, pGlobal, db) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_function(tls, - db, ts+32438 /* "fts5" */, 1, 1, p, *(*uintptr)(unsafe.Pointer(&struct { + db, ts+32438 /* "fts5" */, 1, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{fts5Fts5Func})), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_function(tls, - db, ts+32443 /* "fts5_source_id" */, 0, 1, p, *(*uintptr)(unsafe.Pointer(&struct { + db, ts+32443 /* "fts5_source_id" */, 0, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{fts5SourceIdFunc})), uintptr(0), uintptr(0)) } @@ -179305,54 +176611,30 @@ func fts5Init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:225746:12: */ } var fts5Mod = Sqlite3_module{ - FiVersion: - /* iVersion */ 3, - FxCreate: - /* xCreate */ 0, - FxConnect: - /* xConnect */ 0, - FxBestIndex: - /* xBestIndex */ 0, - FxDisconnect: - /* xDisconnect */ 0, - FxDestroy: - /* xDestroy */ 0, - FxOpen: - /* xOpen */ 0, - FxClose: - /* xClose */ 0, - FxFilter: - /* xFilter */ 0, - FxNext: - /* xNext */ 0, - FxEof: - /* xEof */ 0, - FxColumn: - /* xColumn */ 0, - FxRowid: - /* xRowid */ 0, - FxUpdate: - /* xUpdate */ 0, - FxBegin: - /* xBegin */ 0, - FxSync: - /* xSync */ 0, - FxCommit: - /* xCommit */ 0, - FxRollback: - /* xRollback */ 0, - FxFindFunction: - /* xFindFunction */ 0, - FxRename: - /* xRename */ 0, - FxSavepoint: - /* xSavepoint */ 0, - FxRelease: - /* xRelease */ 0, - FxRollbackTo: - /* xRollbackTo */ 0, - FxShadowName: - /* xShadowName */ 0, + /* iVersion */ FiVersion: 3, + /* xCreate */ FxCreate: 0, + /* xConnect */ FxConnect: 0, + /* xBestIndex */ FxBestIndex: 0, + /* xDisconnect */ FxDisconnect: 0, + /* xDestroy */ FxDestroy: 0, + /* xOpen */ FxOpen: 0, + /* xClose */ FxClose: 0, + /* xFilter */ FxFilter: 0, + /* xNext */ FxNext: 0, + /* xEof */ FxEof: 0, + /* xColumn */ FxColumn: 0, + /* xRowid */ FxRowid: 0, + /* xUpdate */ FxUpdate: 0, + /* xBegin */ FxBegin: 0, + /* xSync */ FxSync: 0, + /* xCommit */ FxCommit: 0, + /* xRollback */ FxRollback: 0, + /* xFindFunction */ FxFindFunction: 0, + /* xRename */ FxRename: 0, + /* xSavepoint */ FxSavepoint: 0, + /* xRelease */ FxRelease: 0, + /* xRollbackTo */ FxRollbackTo: 0, + /* xShadowName */ FxShadowName: 0, } /* sqlite3.c:225747:31 */ // The following functions are used to register the module with SQLite. If @@ -179374,7 +176656,7 @@ func fts5StorageGetStmt(tls *libc.TLS, p uintptr, eStmt int32, ppStmt uintptr, p bp := tls.Alloc(216) defer tls.Free(216) - var rc int32 = 0 + var rc int32 = SQLITE_OK // If there is no %_docsize table, there should be no requests for // statements to operate on it. @@ -179400,30 +176682,30 @@ func fts5StorageGetStmt(tls *libc.TLS, p uintptr, eStmt int32, ppStmt uintptr, p var zSql uintptr = uintptr(0) switch eStmt { - case 10: + case FTS5_STMT_SCAN: zSql = Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* &azStmt[0] */ + uintptr(eStmt)*8)), libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*Fts5Config)(unsafe.Pointer(pC)).FzContent)) break fallthrough - case 0: + case FTS5_STMT_SCAN_ASC: fallthrough - case 1: + case FTS5_STMT_SCAN_DESC: zSql = Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* &azStmt[0] */ + uintptr(eStmt)*8)), libc.VaList(bp+16, (*Fts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*Fts5Config)(unsafe.Pointer(pC)).FzContent, (*Fts5Config)(unsafe.Pointer(pC)).FzContentRowid, (*Fts5Config)(unsafe.Pointer(pC)).FzContentRowid, (*Fts5Config)(unsafe.Pointer(pC)).FzContentRowid)) break fallthrough - case 2: + case FTS5_STMT_LOOKUP: zSql = Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* &azStmt[0] */ + uintptr(eStmt)*8)), libc.VaList(bp+56, (*Fts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*Fts5Config)(unsafe.Pointer(pC)).FzContent, (*Fts5Config)(unsafe.Pointer(pC)).FzContentRowid)) break fallthrough - case 3: + case FTS5_STMT_INSERT_CONTENT: fallthrough - case 4: + case FTS5_STMT_REPLACE_CONTENT: { var nCol int32 = ((*Fts5Config)(unsafe.Pointer(pC)).FnCol + 1) var zBind uintptr @@ -179450,17 +176732,17 @@ func fts5StorageGetStmt(tls *libc.TLS, p uintptr, eStmt int32, ppStmt uintptr, p } if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { - var f int32 = 0x01 - if eStmt > 2 { - f = f | (0x04) + var f int32 = SQLITE_PREPARE_PERSISTENT + if eStmt > FTS5_STMT_LOOKUP { + f = f | (SQLITE_PREPARE_NO_VTAB) } (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock++ rc = Xsqlite3_prepare_v3(tls, (*Fts5Config)(unsafe.Pointer(pC)).Fdb, zSql, -1, uint32(f), ((p + 40 /* &.aStmt */) + uintptr(eStmt)*8), uintptr(0)) (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock-- Xsqlite3_free(tls, zSql) - if (rc != 0) && (pzErrMsg != 0) { + if (rc != SQLITE_OK) && (pzErrMsg != 0) { *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+2690 /* "%s" */, libc.VaList(bp+120, Xsqlite3_errmsg(tls, (*Fts5Config)(unsafe.Pointer(pC)).Fdb))) } } @@ -179481,7 +176763,7 @@ func fts5ExecPrintf(tls *libc.TLS, db uintptr, pzErr uintptr, zFormat uintptr, v zSql = Xsqlite3_vmprintf(tls, zFormat, ap) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), pzErr) Xsqlite3_free(tls, zSql) @@ -179503,12 +176785,12 @@ func sqlite3Fts5DropAll(tls *libc.TLS, pConfig uintptr) int32 { /* sqlite3.c:226 libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { rc = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), ts+33035, /* "DROP TABLE IF EX..." */ libc.VaList(bp+48, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) } - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL) { rc = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), ts+33073, /* "DROP TABLE IF EX..." */ libc.VaList(bp+64, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) @@ -179520,7 +176802,7 @@ func fts5StorageRenameOne(tls *libc.TLS, pConfig uintptr, pRc uintptr, zTail uin bp := tls.Alloc(40) defer tls.Free(40) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { *(*int32)(unsafe.Pointer(pRc)) = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), ts+33111, /* "ALTER TABLE %Q.'..." */ libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, zTail, zName, zTail)) @@ -179540,7 +176822,7 @@ func sqlite3Fts5StorageRename(tls *libc.TLS, pStorage uintptr, zName uintptr) in if (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { fts5StorageRenameOne(tls, pConfig, bp /* &rc */, ts+30232 /* "docsize" */, zName) } - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { fts5StorageRenameOne(tls, pConfig, bp /* &rc */, ts+29881 /* "content" */, zName) } return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -179582,7 +176864,7 @@ func sqlite3Fts5StorageOpen(tls *libc.TLS, pConfig uintptr, pIndex uintptr, bCre bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr // New object var nByte Sqlite3_int64 // Bytes of space to allocate @@ -179590,20 +176872,20 @@ func sqlite3Fts5StorageOpen(tls *libc.TLS, pConfig uintptr, pIndex uintptr, bCre (uint64((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) * uint64(unsafe.Sizeof(I64(0)))))) // Fts5Storage.aTotalSize[] *(*uintptr)(unsafe.Pointer(pp)) = libc.AssignUintptr(&p, Xsqlite3_malloc64(tls, uint64(nByte))) if !(p != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, p, 0, Size_t(nByte)) - (*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize = (p + uintptr(1)*128) + (*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize = (p + 1*128) (*Fts5Storage)(unsafe.Pointer(p)).FpConfig = pConfig (*Fts5Storage)(unsafe.Pointer(p)).FpIndex = pIndex if bCreate != 0 { - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { var nDefn int32 = (32 + ((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol * 10)) var zDefn uintptr = Xsqlite3_malloc64(tls, (uint64(int64(32) + (Sqlite3_int64((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) * int64(10))))) if zDefn == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var i int32 var iOff int32 @@ -179618,16 +176900,16 @@ func sqlite3Fts5StorageOpen(tls *libc.TLS, pConfig uintptr, pIndex uintptr, bCre Xsqlite3_free(tls, zDefn) } - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { rc = sqlite3Fts5CreateTable(tls, pConfig, ts+30232 /* "docsize" */, ts+33256 /* "id INTEGER PRIMA..." */, 0, pzErr) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5CreateTable(tls, pConfig, ts+32431 /* "config" */, ts+33288 /* "k PRIMARY KEY, v" */, 1, pzErr) } - if rc == 0 { - rc = sqlite3Fts5StorageConfigValue(tls, p, ts+30378 /* "version" */, uintptr(0), 4) + if rc == SQLITE_OK { + rc = sqlite3Fts5StorageConfigValue(tls, p, ts+30378 /* "version" */, uintptr(0), FTS5_CURRENT_VERSION) } } @@ -179640,7 +176922,7 @@ func sqlite3Fts5StorageOpen(tls *libc.TLS, pConfig uintptr, pIndex uintptr, bCre // Close a handle opened by an earlier call to sqlite3Fts5StorageOpen(). func sqlite3Fts5StorageClose(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:226203:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if p != 0 { var i int32 @@ -179668,10 +176950,10 @@ func fts5StorageInsertCallback(tls *libc.TLS, pContext uintptr, tflags int32, pT var pIdx uintptr = (*Fts5Storage)(unsafe.Pointer((*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FpStorage)).FpIndex _ = iUnused1 _ = iUnused2 - if nToken > 32768 { - nToken = 32768 + if nToken > FTS5_MAX_TOKEN_SIZE { + nToken = FTS5_MAX_TOKEN_SIZE } - if ((tflags & 0x0001) == 0) || ((*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol == 0) { + if ((tflags & FTS5_TOKEN_COLOCATED) == 0) || ((*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol == 0) { (*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol++ } return sqlite3Fts5IndexWrite(tls, pIdx, (*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FiCol, ((*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol - 1), pToken, nToken) @@ -179692,12 +176974,12 @@ func fts5StorageDeleteFromIndex(tls *libc.TLS, p uintptr, iDel I64, apVal uintpt // var ctx Fts5InsertCtx at bp+8, 16 if apVal == uintptr(0) { - rc = fts5StorageGetStmt(tls, p, 2, bp /* &pSeek */, uintptr(0)) - if rc != 0 { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_LOOKUP, bp /* &pSeek */, uintptr(0)) + if rc != SQLITE_OK { return rc } Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pSeek */)), 1, iDel) - if Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pSeek */))) != 100 { + if Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pSeek */))) != SQLITE_ROW { return Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pSeek */))) } } @@ -179705,7 +176987,7 @@ func fts5StorageDeleteFromIndex(tls *libc.TLS, p uintptr, iDel I64, apVal uintpt (*Fts5InsertCtx)(unsafe.Pointer(bp + 8 /* &ctx */)).FpStorage = p (*Fts5InsertCtx)(unsafe.Pointer(bp + 8 /* &ctx */)).FiCol = -1 rc = sqlite3Fts5IndexBeginWrite(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, 1, iDel) - for iCol = 1; (rc == 0) && (iCol <= (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); iCol++ { + for iCol = 1; (rc == SQLITE_OK) && (iCol <= (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); iCol++ { if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr((iCol - 1))))) == 0 { var zText uintptr var nText int32 @@ -179717,7 +176999,7 @@ func fts5StorageDeleteFromIndex(tls *libc.TLS, p uintptr, iDel I64, apVal uintpt nText = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr((iCol-1))*8))) } (*Fts5InsertCtx)(unsafe.Pointer(bp + 8 /* &ctx */)).FszCol = 0 - rc = sqlite3Fts5Tokenize(tls, pConfig, 0x0004, + rc = sqlite3Fts5Tokenize(tls, pConfig, FTS5_TOKENIZE_DOCUMENT, zText, nText, bp+8 /* &ctx */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5StorageInsertCallback}))) @@ -179727,7 +177009,7 @@ func fts5StorageDeleteFromIndex(tls *libc.TLS, p uintptr, iDel I64, apVal uintpt (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow-- rc2 = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pSeek */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } return rc @@ -179743,11 +177025,11 @@ func fts5StorageInsertDocsize(tls *libc.TLS, p uintptr, iRowid I64, pBuf uintptr bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FbColumnsize != 0 { *(*uintptr)(unsafe.Pointer(bp /* pReplace */)) = uintptr(0) - rc = fts5StorageGetStmt(tls, p, 6, bp /* &pReplace */, uintptr(0)) - if rc == 0 { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_REPLACE_DOCSIZE, bp /* &pReplace */, uintptr(0)) + if rc == SQLITE_OK { Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 1, iRowid) Xsqlite3_bind_blob(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 2, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn, uintptr(0)) Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */))) @@ -179767,7 +177049,7 @@ func fts5StorageInsertDocsize(tls *libc.TLS, p uintptr, iRowid I64, pBuf uintptr // Return SQLITE_OK if successful, or an SQLite error code if an error // occurs. func fts5StorageLoadTotals(tls *libc.TLS, p uintptr, bCache int32) int32 { /* sqlite3.c:226339:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid == 0 { rc = sqlite3Fts5IndexGetAverages(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, (p + 24 /* &.nTotalRow */), (*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize) (*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid = bCache @@ -179788,14 +177070,14 @@ func fts5StorageSaveTotals(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:226355 var i int32 // var buf Fts5Buffer at bp, 16 - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK libc.Xmemset(tls, bp /* &buf */, 0, uint64(unsafe.Sizeof(Fts5Buffer{}))) sqlite3Fts5BufferAppendVarint(tls, bp+16 /* &rc */, bp /* &buf */, (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow) for i = 0; i < nCol; i++ { sqlite3Fts5BufferAppendVarint(tls, bp+16 /* &rc */, bp /* &buf */, *(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(i)*8))) } - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5IndexSetAverages(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn) } Xsqlite3_free(tls, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp) @@ -179815,14 +177097,14 @@ func sqlite3Fts5StorageDelete(tls *libc.TLS, p uintptr, iDel I64, apVal uintptr) rc = fts5StorageLoadTotals(tls, p, 1) // Delete the index records - if rc == 0 { + if rc == SQLITE_OK { rc = fts5StorageDeleteFromIndex(tls, p, iDel, apVal) } // Delete the %_docsize record - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { - rc = fts5StorageGetStmt(tls, p, 7, bp /* &pDel */, uintptr(0)) - if rc == 0 { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_DELETE_DOCSIZE, bp /* &pDel */, uintptr(0)) + if rc == SQLITE_OK { Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pDel */)), 1, iDel) Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pDel */))) rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pDel */))) @@ -179830,11 +177112,11 @@ func sqlite3Fts5StorageDelete(tls *libc.TLS, p uintptr, iDel I64, apVal uintptr) } // Delete the %_content record - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0 { - if rc == 0 { - rc = fts5StorageGetStmt(tls, p, 5, bp /* &pDel */, uintptr(0)) + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { + if rc == SQLITE_OK { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_DELETE_CONTENT, bp /* &pDel */, uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pDel */)), 1, iDel) Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pDel */))) rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pDel */))) @@ -179860,7 +177142,7 @@ func sqlite3Fts5StorageDeleteAll(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c: ts+33305, /* "DELETE FROM %Q.'..." */ libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { rc = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), ts+33355, /* "DELETE FROM %Q.'..." */ libc.VaList(bp+32, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) @@ -179868,11 +177150,11 @@ func sqlite3Fts5StorageDeleteAll(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c: // Reinitialize the %_data table. This call creates the initial structure // and averages records. - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5IndexReinit(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex) } - if rc == 0 { - rc = sqlite3Fts5StorageConfigValue(tls, p, ts+30378 /* "version" */, uintptr(0), 4) + if rc == SQLITE_OK { + rc = sqlite3Fts5StorageConfigValue(tls, p, ts+30378 /* "version" */, uintptr(0), FTS5_CURRENT_VERSION) } return rc } @@ -179893,26 +177175,26 @@ func sqlite3Fts5StorageRebuild(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:22 libc.Xmemset(tls, bp /* &ctx */, 0, uint64(unsafe.Sizeof(Fts5InsertCtx{}))) (*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FpStorage = p *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = sqlite3Fts5StorageDeleteAll(tls, p) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5StorageLoadTotals(tls, p, 1) } - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5StorageGetStmt(tls, p, 10, bp+16 /* &pScan */, uintptr(0)) + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5StorageGetStmt(tls, p, FTS5_STMT_SCAN, bp+16 /* &pScan */, uintptr(0)) } - for (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pScan */)))) { + for (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pScan */)))) { var iRowid I64 = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pScan */)), 0) sqlite3Fts5BufferZero(tls, bp+24 /* &buf */) *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = sqlite3Fts5IndexBeginWrite(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, 0, iRowid) - for (*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol = 0; (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && ((*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); (*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol++ { + for (*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol = 0; (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && ((*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); (*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol++ { (*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FszCol = 0 if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr((*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol)))) == 0 { var zText uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pScan */)), ((*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol + 1)) var nText int32 = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pScan */)), ((*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol + 1)) *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = sqlite3Fts5Tokenize(tls, pConfig, - 0x0004, + FTS5_TOKENIZE_DOCUMENT, zText, nText, bp, /* &ctx */ *(*uintptr)(unsafe.Pointer(&struct { @@ -179924,18 +177206,18 @@ func sqlite3Fts5StorageRebuild(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:22 } (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow++ - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5StorageInsertDocsize(tls, p, iRowid, bp+24 /* &buf */) } } Xsqlite3_free(tls, (*Fts5Buffer)(unsafe.Pointer(bp+24 /* &buf */)).Fp) rc2 = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pScan */))) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = rc2 } // Write the averages record - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5StorageSaveTotals(tls, p) } return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) @@ -179964,17 +177246,17 @@ func fts5StorageNewRowid(tls *libc.TLS, p uintptr, piRowid uintptr) int32 { /* s bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 20 + var rc int32 = SQLITE_MISMATCH if (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FbColumnsize != 0 { *(*uintptr)(unsafe.Pointer(bp /* pReplace */)) = uintptr(0) - rc = fts5StorageGetStmt(tls, p, 6, bp /* &pReplace */, uintptr(0)) - if rc == 0 { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_REPLACE_DOCSIZE, bp /* &pReplace */, uintptr(0)) + if rc == SQLITE_OK { Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 1) Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 2) Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */))) rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */))) } - if rc == 0 { + if rc == SQLITE_OK { *(*I64)(unsafe.Pointer(piRowid)) = Xsqlite3_last_insert_rowid(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb) } } @@ -179987,23 +177269,23 @@ func sqlite3Fts5StorageContentInsert(tls *libc.TLS, p uintptr, apVal uintptr, pi defer tls.Free(8) var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig - var rc int32 = 0 + var rc int32 = SQLITE_OK // Insert the new row into the %_content table. - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != 0 { - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) == 1 { - *(*I64)(unsafe.Pointer(piRowid)) = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) == SQLITE_INTEGER { + *(*I64)(unsafe.Pointer(piRowid)) = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) } else { rc = fts5StorageNewRowid(tls, p, piRowid) } } else { *(*uintptr)(unsafe.Pointer(bp /* pInsert */)) = uintptr(0) // Statement to write %_content table var i int32 // Counter variable - rc = fts5StorageGetStmt(tls, p, 3, bp /* &pInsert */, uintptr(0)) - for i = 1; (rc == 0) && (i <= ((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol + 1)); i++ { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_INSERT_CONTENT, bp /* &pInsert */, uintptr(0)) + for i = 1; (rc == SQLITE_OK) && (i <= ((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol + 1)); i++ { rc = Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp /* pInsert */)), i, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8))) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pInsert */))) rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pInsert */))) } @@ -180019,7 +177301,7 @@ func sqlite3Fts5StorageIndexInsert(tls *libc.TLS, p uintptr, apVal uintptr, iRow defer tls.Free(36) var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig - *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = 0 // Return code + *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = SQLITE_OK // Return code // var ctx Fts5InsertCtx at bp+16, 16 // Tokenization callback context object // var buf Fts5Buffer at bp, 16 @@ -180029,16 +177311,16 @@ func sqlite3Fts5StorageIndexInsert(tls *libc.TLS, p uintptr, apVal uintptr, iRow (*Fts5InsertCtx)(unsafe.Pointer(bp + 16 /* &ctx */)).FpStorage = p *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = fts5StorageLoadTotals(tls, p, 1) - if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = sqlite3Fts5IndexBeginWrite(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, 0, iRowid) } - for (*Fts5InsertCtx)(unsafe.Pointer(bp + 16 /* &ctx */)).FiCol = 0; (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0) && ((*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); (*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol++ { + for (*Fts5InsertCtx)(unsafe.Pointer(bp + 16 /* &ctx */)).FiCol = 0; (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK) && ((*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); (*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol++ { (*Fts5InsertCtx)(unsafe.Pointer(bp + 16 /* &ctx */)).FszCol = 0 if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr((*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol)))) == 0 { var zText uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(((*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol+2))*8))) var nText int32 = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(((*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol+2))*8))) *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = sqlite3Fts5Tokenize(tls, pConfig, - 0x0004, + FTS5_TOKENIZE_DOCUMENT, zText, nText, bp+16, /* &ctx */ *(*uintptr)(unsafe.Pointer(&struct { @@ -180051,7 +177333,7 @@ func sqlite3Fts5StorageIndexInsert(tls *libc.TLS, p uintptr, apVal uintptr, iRow (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow++ // Write the %_docsize record - if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = fts5StorageInsertDocsize(tls, p, iRowid, bp /* &buf */) } Xsqlite3_free(tls, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp) @@ -180070,12 +177352,12 @@ func fts5StorageCount(tls *libc.TLS, p uintptr, zSuffix uintptr, pnRow uintptr) zSql = Xsqlite3_mprintf(tls, ts+33384, /* "SELECT count(*) ..." */ libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, zSuffix)) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { *(*uintptr)(unsafe.Pointer(bp + 24 /* pCnt */)) = uintptr(0) rc = Xsqlite3_prepare_v2(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -1, bp+24 /* &pCnt */, uintptr(0)) - if rc == 0 { - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pCnt */))) { + if rc == SQLITE_OK { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pCnt */))) { *(*I64)(unsafe.Pointer(pnRow)) = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pCnt */)), 0) } rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pCnt */))) @@ -180109,27 +177391,27 @@ func fts5StorageIntegrityCallback(tls *libc.TLS, pContext uintptr, tflags int32, // var bPresent int32 at bp, 4 var ii int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var iPos int32 var iCol int32 _ = iUnused1 _ = iUnused2 - if nToken > 32768 { - nToken = 32768 + if nToken > FTS5_MAX_TOKEN_SIZE { + nToken = FTS5_MAX_TOKEN_SIZE } - if ((tflags & 0x0001) == 0) || ((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol == 0) { + if ((tflags & FTS5_TOKEN_COLOCATED) == 0) || ((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol == 0) { (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol++ } switch (*Fts5Config)(unsafe.Pointer((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FeDetail { - case 0: + case FTS5_DETAIL_FULL: iPos = ((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol - 1) iCol = (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiCol break - case 2: + case FTS5_DETAIL_COLUMNS: iPos = (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiCol iCol = 0 break @@ -180142,12 +177424,12 @@ func fts5StorageIntegrityCallback(tls *libc.TLS, pContext uintptr, tflags int32, } rc = sqlite3Fts5TermsetAdd(tls, pTermset, 0, pToken, nToken, bp /* &bPresent */) - if (rc == 0) && (*(*int32)(unsafe.Pointer(bp /* bPresent */)) == 0) { + if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* bPresent */)) == 0) { *(*U64)(unsafe.Pointer(pCtx + 16 /* &.cksum */)) ^= (sqlite3Fts5IndexEntryCksum(tls, (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiRowid, iCol, iPos, 0, pToken, nToken)) } - for ii = 0; (rc == 0) && (ii < (*Fts5Config)(unsafe.Pointer((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FnPrefix); ii++ { + for ii = 0; (rc == SQLITE_OK) && (ii < (*Fts5Config)(unsafe.Pointer((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FnPrefix); ii++ { var nChar int32 = *(*int32)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FaPrefix + uintptr(ii)*4)) var nByte int32 = sqlite3Fts5IndexCharlenToBytelen(tls, pToken, nToken, nChar) if nByte != 0 { @@ -180182,51 +177464,51 @@ func sqlite3Fts5StorageIntegrity(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c: (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FpConfig = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig aTotalSize = Xsqlite3_malloc64(tls, (uint64(uint64((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) * (uint64(unsafe.Sizeof(int32(0))) + uint64(unsafe.Sizeof(I64(0))))))) if !(aTotalSize != 0) { - return 7 + return SQLITE_NOMEM } aColSize = (aTotalSize + uintptr((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol)*8) libc.Xmemset(tls, aTotalSize, 0, (uint64(unsafe.Sizeof(I64(0))) * uint64((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol))) // Generate the expected index checksum based on the contents of the // %_content table. This block stores the checksum in ctx.cksum. - rc = fts5StorageGetStmt(tls, p, 10, bp+40 /* &pScan */, uintptr(0)) - if rc == 0 { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_SCAN, bp+40 /* &pScan */, uintptr(0)) + if rc == SQLITE_OK { var rc2 int32 - for 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pScan */))) { + for SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pScan */))) { var i int32 (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FiRowid = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pScan */)), 0) (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FszCol = 0 if (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { rc = sqlite3Fts5StorageDocsize(tls, p, (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FiRowid, aColSize) } - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 1) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_NONE) { rc = sqlite3Fts5TermsetNew(tls, (bp /* &ctx */ + 24 /* &.pTermset */)) } - for i = 0; (rc == 0) && (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); i++ { if *(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(i))) != 0 { continue } (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol = i (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FszCol = 0 - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 2 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_COLUMNS { rc = sqlite3Fts5TermsetNew(tls, (bp /* &ctx */ + 24 /* &.pTermset */)) } - if rc == 0 { + if rc == SQLITE_OK { var zText uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pScan */)), (i + 1)) var nText int32 = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pScan */)), (i + 1)) rc = sqlite3Fts5Tokenize(tls, pConfig, - 0x0004, + FTS5_TOKENIZE_DOCUMENT, zText, nText, bp, /* &ctx */ *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5StorageIntegrityCallback}))) } - if ((rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0)) && ((*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FszCol != *(*int32)(unsafe.Pointer(aColSize + uintptr(i)*4))) { - rc = (11 | (int32(1) << 8)) + if ((rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0)) && ((*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FszCol != *(*int32)(unsafe.Pointer(aColSize + uintptr(i)*4))) { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } *(*I64)(unsafe.Pointer(aTotalSize + uintptr(i)*8)) += (I64((*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FszCol)) - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 2 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_COLUMNS { sqlite3Fts5TermsetFree(tls, (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FpTermset) (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FpTermset = uintptr(0) } @@ -180234,48 +177516,48 @@ func sqlite3Fts5StorageIntegrity(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c: sqlite3Fts5TermsetFree(tls, (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FpTermset) (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FpTermset = uintptr(0) - if rc != 0 { + if rc != SQLITE_OK { break } } rc2 = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pScan */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } // Test that the "totals" (sometimes called "averages") record looks Ok - if rc == 0 { + if rc == SQLITE_OK { var i int32 rc = fts5StorageLoadTotals(tls, p, 0) - for i = 0; (rc == 0) && (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); i++ { if *(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(i)*8)) != *(*I64)(unsafe.Pointer(aTotalSize + uintptr(i)*8)) { - rc = (11 | (int32(1) << 8)) + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } } // Check that the %_docsize and %_content tables contain the expected // number of rows. - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL) { *(*I64)(unsafe.Pointer(bp + 48 /* nRow */)) = int64(0) rc = fts5StorageCount(tls, p, ts+29881 /* "content" */, bp+48 /* &nRow */) - if (rc == 0) && (*(*I64)(unsafe.Pointer(bp + 48 /* nRow */)) != (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow) { - rc = (11 | (int32(1) << 8)) + if (rc == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp + 48 /* nRow */)) != (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow) { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { *(*I64)(unsafe.Pointer(bp + 56 /* nRow */)) = int64(0) rc = fts5StorageCount(tls, p, ts+30232 /* "docsize" */, bp+56 /* &nRow */) - if (rc == 0) && (*(*I64)(unsafe.Pointer(bp + 56 /* nRow */)) != (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow) { - rc = (11 | (int32(1) << 8)) + if (rc == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp + 56 /* nRow */)) != (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow) { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } // Pass the expected checksum down to the FTS index module. It will // verify, amongst other things, that it matches the checksum generated by // inspecting the index itself. - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5IndexIntegrityCheck(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).Fcksum) } @@ -180289,7 +177571,7 @@ func sqlite3Fts5StorageStmt(tls *libc.TLS, p uintptr, eStmt int32, pp uintptr, p var rc int32 rc = fts5StorageGetStmt(tls, p, eStmt, pp, pzErrMsg) - if rc == 0 { + if rc == SQLITE_OK { *(*uintptr)(unsafe.Pointer((p + 40 /* &.aStmt */) + uintptr(eStmt)*8)) = uintptr(0) } @@ -180335,11 +177617,11 @@ func sqlite3Fts5StorageDocsize(tls *libc.TLS, p uintptr, iRowid I64, aCol uintpt *(*uintptr)(unsafe.Pointer(bp /* pLookup */)) = uintptr(0) // Statement to query %_docsize var rc int32 // Return Code - rc = fts5StorageGetStmt(tls, p, 8, bp /* &pLookup */, uintptr(0)) - if rc == 0 { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_LOOKUP_DOCSIZE, bp /* &pLookup */, uintptr(0)) + if rc == SQLITE_OK { var bCorrupt int32 = 1 Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pLookup */)), 1, iRowid) - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pLookup */))) { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pLookup */))) { var aBlob uintptr = Xsqlite3_column_blob(tls, *(*uintptr)(unsafe.Pointer(bp /* pLookup */)), 0) var nBlob int32 = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp /* pLookup */)), 0) if 0 == fts5StorageDecodeSizeArray(tls, aCol, nCol, aBlob, nBlob) { @@ -180347,8 +177629,8 @@ func sqlite3Fts5StorageDocsize(tls *libc.TLS, p uintptr, iRowid I64, aCol uintpt } } rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pLookup */))) - if (bCorrupt != 0) && (rc == 0) { - rc = (11 | (int32(1) << 8)) + if (bCorrupt != 0) && (rc == SQLITE_OK) { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } @@ -180357,7 +177639,7 @@ func sqlite3Fts5StorageDocsize(tls *libc.TLS, p uintptr, iRowid I64, aCol uintpt func sqlite3Fts5StorageSize(tls *libc.TLS, p uintptr, iCol int32, pnToken uintptr) int32 { /* sqlite3.c:226926:12: */ var rc int32 = fts5StorageLoadTotals(tls, p, 0) - if rc == 0 { + if rc == SQLITE_OK { *(*I64)(unsafe.Pointer(pnToken)) = int64(0) if iCol < 0 { var i int32 @@ -180367,7 +177649,7 @@ func sqlite3Fts5StorageSize(tls *libc.TLS, p uintptr, iCol int32, pnToken uintpt } else if iCol < (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FnCol { *(*I64)(unsafe.Pointer(pnToken)) = *(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(iCol)*8)) } else { - rc = 25 + rc = SQLITE_RANGE } } return rc @@ -180375,7 +177657,7 @@ func sqlite3Fts5StorageSize(tls *libc.TLS, p uintptr, iCol int32, pnToken uintpt func sqlite3Fts5StorageRowCount(tls *libc.TLS, p uintptr, pnRow uintptr) int32 { /* sqlite3.c:226944:12: */ var rc int32 = fts5StorageLoadTotals(tls, p, 0) - if rc == 0 { + if rc == SQLITE_OK { // nTotalRow being zero does not necessarily indicate a corrupt // database - it might be that the FTS5 table really does contain zero // rows. However this function is only called from the xRowCount() API, @@ -180383,7 +177665,7 @@ func sqlite3Fts5StorageRowCount(tls *libc.TLS, p uintptr, pnRow uintptr) int32 { // no rows. Hence the FTS5_CORRUPT return. *(*I64)(unsafe.Pointer(pnRow)) = (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow if (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow <= int64(0) { - rc = (11 | (int32(1) << 8)) + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } return rc @@ -180391,13 +177673,13 @@ func sqlite3Fts5StorageRowCount(tls *libc.TLS, p uintptr, pnRow uintptr) int32 { // Flush any data currently held in-memory to disk. func sqlite3Fts5StorageSync(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:226961:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var iLastRowid I64 = Xsqlite3_last_insert_rowid(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb) if (*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid != 0 { rc = fts5StorageSaveTotals(tls, p) (*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid = 0 } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5IndexSync(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex) } Xsqlite3_set_last_insert_rowid(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb, iLastRowid) @@ -180414,8 +177696,8 @@ func sqlite3Fts5StorageConfigValue(tls *libc.TLS, p uintptr, z uintptr, pVal uin defer tls.Free(8) *(*uintptr)(unsafe.Pointer(bp /* pReplace */)) = uintptr(0) - var rc int32 = fts5StorageGetStmt(tls, p, 9, bp /* &pReplace */, uintptr(0)) - if rc == 0 { + var rc int32 = fts5StorageGetStmt(tls, p, FTS5_STMT_REPLACE_CONFIG, bp /* &pReplace */, uintptr(0)) + if rc == SQLITE_OK { Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 1, z, -1, uintptr(0)) if pVal != 0 { Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 2, pVal) @@ -180426,10 +177708,10 @@ func sqlite3Fts5StorageConfigValue(tls *libc.TLS, p uintptr, z uintptr, pVal uin rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */))) Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 1) } - if (rc == 0) && (pVal != 0) { + if (rc == SQLITE_OK) && (pVal != 0) { var iNew int32 = ((*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FiCookie + 1) rc = sqlite3Fts5IndexSetCookie(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, iNew) - if rc == 0 { + if rc == SQLITE_OK { (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FiCookie = iNew } } @@ -180486,30 +177768,30 @@ func fts5AsciiDelete(tls *libc.TLS, p uintptr) { /* sqlite3.c:227065:13: */ // Create an "ascii" tokenizer. func fts5AsciiCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) int32 { /* sqlite3.c:227072:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr = uintptr(0) _ = pUnused if (nArg % 2) != 0 { - rc = 1 + rc = SQLITE_ERROR } else { p = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(AsciiTokenizer{}))) if p == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var i int32 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(AsciiTokenizer{}))) libc.Xmemcpy(tls, p /* &.aTokenChar */, uintptr(unsafe.Pointer(&aAsciiTokenChar)), uint64(unsafe.Sizeof(aAsciiTokenChar))) - for i = 0; (rc == 0) && (i < nArg); i = i + (2) { + for i = 0; (rc == SQLITE_OK) && (i < nArg); i = i + (2) { var zArg uintptr = *(*uintptr)(unsafe.Pointer(azArg + uintptr((i+1))*8)) if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), ts+33416 /* "tokenchars" */) { fts5AsciiAddExceptions(tls, p, zArg, 1) } else if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), ts+33427 /* "separators" */) { fts5AsciiAddExceptions(tls, p, zArg, 0) } else { - rc = 1 + rc = SQLITE_ERROR } } - if rc != 0 { + if rc != SQLITE_OK { fts5AsciiDelete(tls, p) p = uintptr(0) } @@ -180537,7 +177819,7 @@ func fts5AsciiTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused defer tls.Free(64) var p uintptr = pTokenizer - var rc int32 = 0 + var rc int32 = SQLITE_OK var ie int32 var is int32 = 0 // var aFold [64]int8 at bp, 64 @@ -180548,7 +177830,7 @@ func fts5AsciiTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused _ = iUnused - for (is < nText) && (rc == 0) { + for (is < nText) && (rc == SQLITE_OK) { var nByte int32 // Skip any leading divider characters. @@ -180573,7 +177855,7 @@ func fts5AsciiTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused } pFold = Xsqlite3_malloc64(tls, (uint64(Sqlite3_int64(nByte) * int64(2)))) if pFold == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM break } nFold = (nByte * 2) @@ -180588,8 +177870,8 @@ func fts5AsciiTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused if pFold != bp /* aFold */ { Xsqlite3_free(tls, pFold) } - if rc == 101 { - rc = 0 + if rc == SQLITE_DONE { + rc = SQLITE_OK } return rc } @@ -180626,7 +177908,7 @@ type Unicode61Tokenizer = Unicode61Tokenizer1 /* sqlite3.c:227240:35 */ // Values for eRemoveDiacritic (must match internals of fts5_unicode2.c) func fts5UnicodeAddExceptions(tls *libc.TLS, p uintptr, z uintptr, bTokenChars int32) int32 { /* sqlite3.c:227257:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var n int32 = int32(libc.Xstrlen(tls, z)) var aNew uintptr @@ -180672,7 +177954,7 @@ func fts5UnicodeAddExceptions(tls *libc.TLS, p uintptr, z uintptr, bTokenChars i (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaiException = aNew (*Unicode61Tokenizer)(unsafe.Pointer(p)).FnException = nNew } else { - rc = 7 + rc = SQLITE_NOMEM } } @@ -180720,7 +178002,7 @@ func unicodeSetCategories(tls *libc.TLS, p uintptr, zCat uintptr) int32 { /* sql z++ } if (*(*int8)(unsafe.Pointer(z)) != 0) && (sqlite3Fts5UnicodeCatParse(tls, z, p+160 /* &.aCategory */) != 0) { - return 1 + return SQLITE_ERROR } for ((int32(*(*int8)(unsafe.Pointer(z))) != ' ') && (int32(*(*int8)(unsafe.Pointer(z))) != '\t')) && (int32(*(*int8)(unsafe.Pointer(z))) != 0) { z++ @@ -180728,18 +178010,18 @@ func unicodeSetCategories(tls *libc.TLS, p uintptr, zCat uintptr) int32 { /* sql } sqlite3Fts5UnicodeAscii(tls, p+160 /* &.aCategory */, p /* &.aTokenChar */) - return 0 + return SQLITE_OK } // Create a "unicode61" tokenizer. func fts5UnicodeCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) int32 { /* sqlite3.c:227359:12: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var p uintptr = uintptr(0) // New tokenizer object _ = pUnused if (nArg % 2) != 0 { - rc = 1 + rc = SQLITE_ERROR } else { p = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Unicode61Tokenizer{}))) if p != 0 { @@ -180747,31 +178029,31 @@ func fts5UnicodeCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32 var i int32 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(Unicode61Tokenizer{}))) - (*Unicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = 1 + (*Unicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = FTS5_REMOVE_DIACRITICS_SIMPLE (*Unicode61Tokenizer)(unsafe.Pointer(p)).FnFold = 64 (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaFold = Xsqlite3_malloc64(tls, (uint64(uint64((*Unicode61Tokenizer)(unsafe.Pointer(p)).FnFold) * uint64(unsafe.Sizeof(int8(0)))))) if (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaFold == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } // Search for a "categories" argument - for i = 0; (rc == 0) && (i < nArg); i = i + (2) { + for i = 0; (rc == SQLITE_OK) && (i < nArg); i = i + (2) { if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), ts+33447 /* "categories" */) { zCat = *(*uintptr)(unsafe.Pointer(azArg + uintptr((i+1))*8)) } } - if rc == 0 { + if rc == SQLITE_OK { rc = unicodeSetCategories(tls, p, zCat) } - for i = 0; (rc == 0) && (i < nArg); i = i + (2) { + for i = 0; (rc == SQLITE_OK) && (i < nArg); i = i + (2) { var zArg uintptr = *(*uintptr)(unsafe.Pointer(azArg + uintptr((i+1))*8)) if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), ts+33458 /* "remove_diacritic..." */) { - if (((int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) != '0') && (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) != '1')) && (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) != '2')) || (*(*int8)(unsafe.Pointer(zArg + uintptr(1))) != 0) { - rc = 1 + if (((int32(*(*int8)(unsafe.Pointer(zArg))) != '0') && (int32(*(*int8)(unsafe.Pointer(zArg))) != '1')) && (int32(*(*int8)(unsafe.Pointer(zArg))) != '2')) || (*(*int8)(unsafe.Pointer(zArg + 1)) != 0) { + rc = SQLITE_ERROR } else { - (*Unicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) - '0') + (*Unicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = (int32(*(*int8)(unsafe.Pointer(zArg))) - '0') } } else if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), ts+33416 /* "tokenchars" */) { @@ -180781,14 +178063,14 @@ func fts5UnicodeCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32 } else if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), ts+33447 /* "categories" */) { // no-op } else { - rc = 1 + rc = SQLITE_ERROR } } } else { - rc = 7 + rc = SQLITE_NOMEM } - if rc != 0 { + if rc != SQLITE_OK { fts5UnicodeDelete(tls, p) p = uintptr(0) } @@ -180821,7 +178103,7 @@ func fts5UnicodeTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnuse var is int32 var ie int32 p = pTokenizer - rc = 0 + rc = SQLITE_OK a = p /* &.aTokenChar */ zTerm = (pText + uintptr(nText)) zCsr = pText @@ -180834,7 +178116,7 @@ func fts5UnicodeTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnuse // Each iteration of this loop gobbles up a contiguous run of separators, // then the next token. __1: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __2 } zOut = aFold @@ -180916,7 +178198,7 @@ __14: if !(aFold == uintptr(0)) { goto __17 } - rc = 7 + rc = SQLITE_NOMEM goto tokenize_done __17: ; @@ -181039,10 +178321,10 @@ __2: ; tokenize_done: - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __37 } - rc = 0 + rc = SQLITE_OK __37: ; return rc @@ -181087,13 +178369,13 @@ func fts5PorterCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, pp defer tls.Free(8) var pApi uintptr = pCtx - var rc int32 = 0 + var rc int32 = SQLITE_OK var pRet uintptr *(*uintptr)(unsafe.Pointer(bp /* pUserdata */)) = uintptr(0) var zBase uintptr = ts + 33476 /* "unicode61" */ if nArg > 0 { - zBase = *(*uintptr)(unsafe.Pointer(azArg + uintptr(0)*8)) + zBase = *(*uintptr)(unsafe.Pointer(azArg)) } pRet = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(PorterTokenizer{}))) @@ -181101,9 +178383,9 @@ func fts5PorterCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, pp libc.Xmemset(tls, pRet, 0, uint64(unsafe.Sizeof(PorterTokenizer{}))) rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 16 /* &.xFindTokenizer */))))(tls, pApi, zBase, bp /* &pUserdata */, (pRet /* &.tokenizer */)) } else { - rc = 7 + rc = SQLITE_NOMEM } - if rc == 0 { + if rc == SQLITE_OK { var nArg2 int32 = func() int32 { if nArg > 0 { return (nArg - 1) @@ -181112,14 +178394,14 @@ func fts5PorterCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, pp }() var azArg2 uintptr = func() uintptr { if nArg2 != 0 { - return (azArg + uintptr(1)*8) + return (azArg + 1*8) } return uintptr(0) }() rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pRet /* &.tokenizer */ /* &.xCreate */))))(tls, *(*uintptr)(unsafe.Pointer(bp /* pUserdata */)), azArg2, nArg2, (pRet + 24 /* &.pTokenizer */)) } - if rc != 0 { + if rc != SQLITE_OK { fts5PorterDelete(tls, pRet) pRet = uintptr(0) } @@ -181678,7 +178960,7 @@ func fts5PorterCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nTo var c int8 p = pCtx - if !((nToken > 64) || (nToken < 3)) { + if !((nToken > FTS5_PORTER_MAX_TOKEN) || (nToken < 3)) { goto __1 } goto pass_through @@ -181783,39 +179065,27 @@ func sqlite3Fts5TokenizerInit(tls *libc.TLS, pApi uintptr) int32 { /* sqlite3.c: defer tls.Free(96) *(*[3]BuiltinTokenizer)(unsafe.Pointer(bp /* aBuiltin */)) = [3]BuiltinTokenizer{ - { - FzName: ts + 33476 /* "unicode61" */, Fx: Fts5_tokenizer{ - FxCreate: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{fts5UnicodeCreate})), - FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5UnicodeDelete})), - FxTokenize: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 - }{fts5UnicodeTokenize}))}}, - { - FzName: ts + 33765 /* "ascii" */, Fx: Fts5_tokenizer{ - FxCreate: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{fts5AsciiCreate})), - FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5AsciiDelete})), - FxTokenize: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 - }{fts5AsciiTokenize}))}}, - { - FzName: ts + 33771 /* "porter" */, Fx: Fts5_tokenizer{ - FxCreate: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{fts5PorterCreate})), - FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5PorterDelete})), - FxTokenize: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 - }{fts5PorterTokenize}))}}, + {FzName: ts + 33476 /* "unicode61" */, Fx: Fts5_tokenizer{FxCreate: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{fts5UnicodeCreate})), FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5UnicodeDelete})), FxTokenize: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 + }{fts5UnicodeTokenize}))}}, + {FzName: ts + 33765 /* "ascii" */, Fx: Fts5_tokenizer{FxCreate: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{fts5AsciiCreate})), FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5AsciiDelete})), FxTokenize: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 + }{fts5AsciiTokenize}))}}, + {FzName: ts + 33771 /* "porter" */, Fx: Fts5_tokenizer{FxCreate: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{fts5PorterCreate})), FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5PorterDelete})), FxTokenize: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 + }{fts5PorterTokenize}))}}, } - var rc int32 = 0 // Return code - var i int32 // To iterate through builtin functions + var rc int32 = SQLITE_OK // Return code + var i int32 // To iterate through builtin functions - for i = 0; (rc == 0) && (i < (int32(uint64(unsafe.Sizeof([3]BuiltinTokenizer{})) / uint64(unsafe.Sizeof(BuiltinTokenizer{}))))); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (int32(uint64(unsafe.Sizeof([3]BuiltinTokenizer{})) / uint64(unsafe.Sizeof(BuiltinTokenizer{}))))); i++ { rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 8 /* &.xCreateTokenizer */))))(tls, pApi, (*BuiltinTokenizer)(unsafe.Pointer(bp /* &aBuiltin */ +uintptr(i)*32)).FzName, pApi, @@ -182006,550 +179276,61 @@ type TableEntry = struct { } /* sqlite3.c:228431:16 */ var aEntry = [163]TableEntry{ - { - FiCode: uint16(65), - Fflags: uint8(14), - FnRange: uint8(26)}, { - FiCode: uint16(181), - Fflags: uint8(64), - FnRange: uint8(1)}, { - FiCode: uint16(192), - Fflags: uint8(14), - FnRange: uint8(23)}, - { - FiCode: uint16(216), - Fflags: uint8(14), - FnRange: uint8(7)}, { - FiCode: uint16(256), - Fflags: uint8(1), - FnRange: uint8(48)}, { - FiCode: uint16(306), - Fflags: uint8(1), - FnRange: uint8(6)}, - { - FiCode: uint16(313), - Fflags: uint8(1), - FnRange: uint8(16)}, { - FiCode: uint16(330), - Fflags: uint8(1), - FnRange: uint8(46)}, { - FiCode: uint16(376), - Fflags: uint8(116), - FnRange: uint8(1)}, - { - FiCode: uint16(377), - Fflags: uint8(1), - FnRange: uint8(6)}, { - FiCode: uint16(383), - Fflags: uint8(104), - FnRange: uint8(1)}, { - FiCode: uint16(385), - Fflags: uint8(50), - FnRange: uint8(1)}, - { - FiCode: uint16(386), - Fflags: uint8(1), - FnRange: uint8(4)}, { - FiCode: uint16(390), - Fflags: uint8(44), - FnRange: uint8(1)}, { - FiCode: uint16(391), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(393), - Fflags: uint8(42), - FnRange: uint8(2)}, { - FiCode: uint16(395), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(398), - Fflags: uint8(32), - FnRange: uint8(1)}, - { - FiCode: uint16(399), - Fflags: uint8(38), - FnRange: uint8(1)}, { - FiCode: uint16(400), - Fflags: uint8(40), - FnRange: uint8(1)}, { - FiCode: uint16(401), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(403), - Fflags: uint8(42), - FnRange: uint8(1)}, { - FiCode: uint16(404), - Fflags: uint8(46), - FnRange: uint8(1)}, { - FiCode: uint16(406), - Fflags: uint8(52), - FnRange: uint8(1)}, - { - FiCode: uint16(407), - Fflags: uint8(48), - FnRange: uint8(1)}, { - FiCode: uint16(408), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(412), - Fflags: uint8(52), - FnRange: uint8(1)}, - { - FiCode: uint16(413), - Fflags: uint8(54), - FnRange: uint8(1)}, { - FiCode: uint16(415), - Fflags: uint8(56), - FnRange: uint8(1)}, { - FiCode: uint16(416), - Fflags: uint8(1), - FnRange: uint8(6)}, - { - FiCode: uint16(422), - Fflags: uint8(60), - FnRange: uint8(1)}, { - FiCode: uint16(423), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(425), - Fflags: uint8(60), - FnRange: uint8(1)}, - { - FiCode: uint16(428), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(430), - Fflags: uint8(60), - FnRange: uint8(1)}, { - FiCode: uint16(431), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(433), - Fflags: uint8(58), - FnRange: uint8(2)}, { - FiCode: uint16(435), - Fflags: uint8(1), - FnRange: uint8(4)}, { - FiCode: uint16(439), - Fflags: uint8(62), - FnRange: uint8(1)}, - { - FiCode: uint16(440), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(444), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(452), - Fflags: uint8(2), - FnRange: uint8(1)}, - { - FiCode: uint16(453), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(455), - Fflags: uint8(2), - FnRange: uint8(1)}, { - FiCode: uint16(456), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(458), - Fflags: uint8(2), - FnRange: uint8(1)}, { - FiCode: uint16(459), - Fflags: uint8(1), - FnRange: uint8(18)}, { - FiCode: uint16(478), - Fflags: uint8(1), - FnRange: uint8(18)}, - { - FiCode: uint16(497), - Fflags: uint8(2), - FnRange: uint8(1)}, { - FiCode: uint16(498), - Fflags: uint8(1), - FnRange: uint8(4)}, { - FiCode: uint16(502), - Fflags: uint8(122), - FnRange: uint8(1)}, - { - FiCode: uint16(503), - Fflags: uint8(134), - FnRange: uint8(1)}, { - FiCode: uint16(504), - Fflags: uint8(1), - FnRange: uint8(40)}, { - FiCode: uint16(544), - Fflags: uint8(110), - FnRange: uint8(1)}, - { - FiCode: uint16(546), - Fflags: uint8(1), - FnRange: uint8(18)}, { - FiCode: uint16(570), - Fflags: uint8(70), - FnRange: uint8(1)}, { - FiCode: uint16(571), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(573), - Fflags: uint8(108), - FnRange: uint8(1)}, { - FiCode: uint16(574), - Fflags: uint8(68), - FnRange: uint8(1)}, { - FiCode: uint16(577), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(579), - Fflags: uint8(106), - FnRange: uint8(1)}, { - FiCode: uint16(580), - Fflags: uint8(28), - FnRange: uint8(1)}, { - FiCode: uint16(581), - Fflags: uint8(30), - FnRange: uint8(1)}, - { - FiCode: uint16(582), - Fflags: uint8(1), - FnRange: uint8(10)}, { - FiCode: uint16(837), - Fflags: uint8(36), - FnRange: uint8(1)}, { - FiCode: uint16(880), - Fflags: uint8(1), - FnRange: uint8(4)}, - { - FiCode: uint16(886), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(902), - Fflags: uint8(18), - FnRange: uint8(1)}, { - FiCode: uint16(904), - Fflags: uint8(16), - FnRange: uint8(3)}, - { - FiCode: uint16(908), - Fflags: uint8(26), - FnRange: uint8(1)}, { - FiCode: uint16(910), - Fflags: uint8(24), - FnRange: uint8(2)}, { - FiCode: uint16(913), - Fflags: uint8(14), - FnRange: uint8(17)}, - { - FiCode: uint16(931), - Fflags: uint8(14), - FnRange: uint8(9)}, { - FiCode: uint16(962), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(975), - Fflags: uint8(4), - FnRange: uint8(1)}, - { - FiCode: uint16(976), - Fflags: uint8(140), - FnRange: uint8(1)}, { - FiCode: uint16(977), - Fflags: uint8(142), - FnRange: uint8(1)}, { - FiCode: uint16(981), - Fflags: uint8(146), - FnRange: uint8(1)}, - { - FiCode: uint16(982), - Fflags: uint8(144), - FnRange: uint8(1)}, { - FiCode: uint16(984), - Fflags: uint8(1), - FnRange: uint8(24)}, { - FiCode: uint16(1008), - Fflags: uint8(136), - FnRange: uint8(1)}, - { - FiCode: uint16(1009), - Fflags: uint8(138), - FnRange: uint8(1)}, { - FiCode: uint16(1012), - Fflags: uint8(130), - FnRange: uint8(1)}, { - FiCode: uint16(1013), - Fflags: uint8(128), - FnRange: uint8(1)}, - { - FiCode: uint16(1015), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(1017), - Fflags: uint8(152), - FnRange: uint8(1)}, { - FiCode: uint16(1018), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(1021), - Fflags: uint8(110), - FnRange: uint8(3)}, { - FiCode: uint16(1024), - Fflags: uint8(34), - FnRange: uint8(16)}, { - FiCode: uint16(1040), - Fflags: uint8(14), - FnRange: uint8(32)}, - { - FiCode: uint16(1120), - Fflags: uint8(1), - FnRange: uint8(34)}, { - FiCode: uint16(1162), - Fflags: uint8(1), - FnRange: uint8(54)}, { - FiCode: uint16(1216), - Fflags: uint8(6), - FnRange: uint8(1)}, - { - FiCode: uint16(1217), - Fflags: uint8(1), - FnRange: uint8(14)}, { - FiCode: uint16(1232), - Fflags: uint8(1), - FnRange: uint8(88)}, { - FiCode: uint16(1329), - Fflags: uint8(22), - FnRange: uint8(38)}, - { - FiCode: uint16(4256), - Fflags: uint8(66), - FnRange: uint8(38)}, { - FiCode: uint16(4295), - Fflags: uint8(66), - FnRange: uint8(1)}, { - FiCode: uint16(4301), - Fflags: uint8(66), - FnRange: uint8(1)}, - { - FiCode: uint16(7680), - Fflags: uint8(1), - FnRange: uint8(150)}, { - FiCode: uint16(7835), - Fflags: uint8(132), - FnRange: uint8(1)}, { - FiCode: uint16(7838), - Fflags: uint8(96), - FnRange: uint8(1)}, - { - FiCode: uint16(7840), - Fflags: uint8(1), - FnRange: uint8(96)}, { - FiCode: uint16(7944), - Fflags: uint8(150), - FnRange: uint8(8)}, { - FiCode: uint16(7960), - Fflags: uint8(150), - FnRange: uint8(6)}, - { - FiCode: uint16(7976), - Fflags: uint8(150), - FnRange: uint8(8)}, { - FiCode: uint16(7992), - Fflags: uint8(150), - FnRange: uint8(8)}, { - FiCode: uint16(8008), - Fflags: uint8(150), - FnRange: uint8(6)}, - { - FiCode: uint16(8025), - Fflags: uint8(151), - FnRange: uint8(8)}, { - FiCode: uint16(8040), - Fflags: uint8(150), - FnRange: uint8(8)}, { - FiCode: uint16(8072), - Fflags: uint8(150), - FnRange: uint8(8)}, - { - FiCode: uint16(8088), - Fflags: uint8(150), - FnRange: uint8(8)}, { - FiCode: uint16(8104), - Fflags: uint8(150), - FnRange: uint8(8)}, { - FiCode: uint16(8120), - Fflags: uint8(150), - FnRange: uint8(2)}, - { - FiCode: uint16(8122), - Fflags: uint8(126), - FnRange: uint8(2)}, { - FiCode: uint16(8124), - Fflags: uint8(148), - FnRange: uint8(1)}, { - FiCode: uint16(8126), - Fflags: uint8(100), - FnRange: uint8(1)}, - { - FiCode: uint16(8136), - Fflags: uint8(124), - FnRange: uint8(4)}, { - FiCode: uint16(8140), - Fflags: uint8(148), - FnRange: uint8(1)}, { - FiCode: uint16(8152), - Fflags: uint8(150), - FnRange: uint8(2)}, - { - FiCode: uint16(8154), - Fflags: uint8(120), - FnRange: uint8(2)}, { - FiCode: uint16(8168), - Fflags: uint8(150), - FnRange: uint8(2)}, { - FiCode: uint16(8170), - Fflags: uint8(118), - FnRange: uint8(2)}, - { - FiCode: uint16(8172), - Fflags: uint8(152), - FnRange: uint8(1)}, { - FiCode: uint16(8184), - Fflags: uint8(112), - FnRange: uint8(2)}, { - FiCode: uint16(8186), - Fflags: uint8(114), - FnRange: uint8(2)}, - { - FiCode: uint16(8188), - Fflags: uint8(148), - FnRange: uint8(1)}, { - FiCode: uint16(8486), - Fflags: uint8(98), - FnRange: uint8(1)}, { - FiCode: uint16(8490), - Fflags: uint8(92), - FnRange: uint8(1)}, - { - FiCode: uint16(8491), - Fflags: uint8(94), - FnRange: uint8(1)}, { - FiCode: uint16(8498), - Fflags: uint8(12), - FnRange: uint8(1)}, { - FiCode: uint16(8544), - Fflags: uint8(8), - FnRange: uint8(16)}, - { - FiCode: uint16(8579), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(9398), - Fflags: uint8(10), - FnRange: uint8(26)}, { - FiCode: uint16(11264), - Fflags: uint8(22), - FnRange: uint8(47)}, - { - FiCode: uint16(11360), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(11362), - Fflags: uint8(88), - FnRange: uint8(1)}, { - FiCode: uint16(11363), - Fflags: uint8(102), - FnRange: uint8(1)}, - { - FiCode: uint16(11364), - Fflags: uint8(90), - FnRange: uint8(1)}, { - FiCode: uint16(11367), - Fflags: uint8(1), - FnRange: uint8(6)}, { - FiCode: uint16(11373), - Fflags: uint8(84), - FnRange: uint8(1)}, - { - FiCode: uint16(11374), - Fflags: uint8(86), - FnRange: uint8(1)}, { - FiCode: uint16(11375), - Fflags: uint8(80), - FnRange: uint8(1)}, { - FiCode: uint16(11376), - Fflags: uint8(82), - FnRange: uint8(1)}, - { - FiCode: uint16(11378), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(11381), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(11390), - Fflags: uint8(78), - FnRange: uint8(2)}, - { - FiCode: uint16(11392), - Fflags: uint8(1), - FnRange: uint8(100)}, { - FiCode: uint16(11499), - Fflags: uint8(1), - FnRange: uint8(4)}, { - FiCode: uint16(11506), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(42560), - Fflags: uint8(1), - FnRange: uint8(46)}, { - FiCode: uint16(42624), - Fflags: uint8(1), - FnRange: uint8(24)}, { - FiCode: uint16(42786), - Fflags: uint8(1), - FnRange: uint8(14)}, - { - FiCode: uint16(42802), - Fflags: uint8(1), - FnRange: uint8(62)}, { - FiCode: uint16(42873), - Fflags: uint8(1), - FnRange: uint8(4)}, { - FiCode: uint16(42877), - Fflags: uint8(76), - FnRange: uint8(1)}, - { - FiCode: uint16(42878), - Fflags: uint8(1), - FnRange: uint8(10)}, { - FiCode: uint16(42891), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(42893), - Fflags: uint8(74), - FnRange: uint8(1)}, - { - FiCode: uint16(42896), - Fflags: uint8(1), - FnRange: uint8(4)}, { - FiCode: uint16(42912), - Fflags: uint8(1), - FnRange: uint8(10)}, { - FiCode: uint16(42922), - Fflags: uint8(72), - FnRange: uint8(1)}, - { - FiCode: uint16(65313), - Fflags: uint8(14), - FnRange: uint8(26)}, + {FiCode: uint16(65), Fflags: uint8(14), FnRange: uint8(26)}, {FiCode: uint16(181), Fflags: uint8(64), FnRange: uint8(1)}, {FiCode: uint16(192), Fflags: uint8(14), FnRange: uint8(23)}, + {FiCode: uint16(216), Fflags: uint8(14), FnRange: uint8(7)}, {FiCode: uint16(256), Fflags: uint8(1), FnRange: uint8(48)}, {FiCode: uint16(306), Fflags: uint8(1), FnRange: uint8(6)}, + {FiCode: uint16(313), Fflags: uint8(1), FnRange: uint8(16)}, {FiCode: uint16(330), Fflags: uint8(1), FnRange: uint8(46)}, {FiCode: uint16(376), Fflags: uint8(116), FnRange: uint8(1)}, + {FiCode: uint16(377), Fflags: uint8(1), FnRange: uint8(6)}, {FiCode: uint16(383), Fflags: uint8(104), FnRange: uint8(1)}, {FiCode: uint16(385), Fflags: uint8(50), FnRange: uint8(1)}, + {FiCode: uint16(386), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(390), Fflags: uint8(44), FnRange: uint8(1)}, {FiCode: uint16(391), FnRange: uint8(1)}, + {FiCode: uint16(393), Fflags: uint8(42), FnRange: uint8(2)}, {FiCode: uint16(395), FnRange: uint8(1)}, {FiCode: uint16(398), Fflags: uint8(32), FnRange: uint8(1)}, + {FiCode: uint16(399), Fflags: uint8(38), FnRange: uint8(1)}, {FiCode: uint16(400), Fflags: uint8(40), FnRange: uint8(1)}, {FiCode: uint16(401), FnRange: uint8(1)}, + {FiCode: uint16(403), Fflags: uint8(42), FnRange: uint8(1)}, {FiCode: uint16(404), Fflags: uint8(46), FnRange: uint8(1)}, {FiCode: uint16(406), Fflags: uint8(52), FnRange: uint8(1)}, + {FiCode: uint16(407), Fflags: uint8(48), FnRange: uint8(1)}, {FiCode: uint16(408), FnRange: uint8(1)}, {FiCode: uint16(412), Fflags: uint8(52), FnRange: uint8(1)}, + {FiCode: uint16(413), Fflags: uint8(54), FnRange: uint8(1)}, {FiCode: uint16(415), Fflags: uint8(56), FnRange: uint8(1)}, {FiCode: uint16(416), Fflags: uint8(1), FnRange: uint8(6)}, + {FiCode: uint16(422), Fflags: uint8(60), FnRange: uint8(1)}, {FiCode: uint16(423), FnRange: uint8(1)}, {FiCode: uint16(425), Fflags: uint8(60), FnRange: uint8(1)}, + {FiCode: uint16(428), FnRange: uint8(1)}, {FiCode: uint16(430), Fflags: uint8(60), FnRange: uint8(1)}, {FiCode: uint16(431), FnRange: uint8(1)}, + {FiCode: uint16(433), Fflags: uint8(58), FnRange: uint8(2)}, {FiCode: uint16(435), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(439), Fflags: uint8(62), FnRange: uint8(1)}, + {FiCode: uint16(440), FnRange: uint8(1)}, {FiCode: uint16(444), FnRange: uint8(1)}, {FiCode: uint16(452), Fflags: uint8(2), FnRange: uint8(1)}, + {FiCode: uint16(453), FnRange: uint8(1)}, {FiCode: uint16(455), Fflags: uint8(2), FnRange: uint8(1)}, {FiCode: uint16(456), FnRange: uint8(1)}, + {FiCode: uint16(458), Fflags: uint8(2), FnRange: uint8(1)}, {FiCode: uint16(459), Fflags: uint8(1), FnRange: uint8(18)}, {FiCode: uint16(478), Fflags: uint8(1), FnRange: uint8(18)}, + {FiCode: uint16(497), Fflags: uint8(2), FnRange: uint8(1)}, {FiCode: uint16(498), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(502), Fflags: uint8(122), FnRange: uint8(1)}, + {FiCode: uint16(503), Fflags: uint8(134), FnRange: uint8(1)}, {FiCode: uint16(504), Fflags: uint8(1), FnRange: uint8(40)}, {FiCode: uint16(544), Fflags: uint8(110), FnRange: uint8(1)}, + {FiCode: uint16(546), Fflags: uint8(1), FnRange: uint8(18)}, {FiCode: uint16(570), Fflags: uint8(70), FnRange: uint8(1)}, {FiCode: uint16(571), FnRange: uint8(1)}, + {FiCode: uint16(573), Fflags: uint8(108), FnRange: uint8(1)}, {FiCode: uint16(574), Fflags: uint8(68), FnRange: uint8(1)}, {FiCode: uint16(577), FnRange: uint8(1)}, + {FiCode: uint16(579), Fflags: uint8(106), FnRange: uint8(1)}, {FiCode: uint16(580), Fflags: uint8(28), FnRange: uint8(1)}, {FiCode: uint16(581), Fflags: uint8(30), FnRange: uint8(1)}, + {FiCode: uint16(582), Fflags: uint8(1), FnRange: uint8(10)}, {FiCode: uint16(837), Fflags: uint8(36), FnRange: uint8(1)}, {FiCode: uint16(880), Fflags: uint8(1), FnRange: uint8(4)}, + {FiCode: uint16(886), FnRange: uint8(1)}, {FiCode: uint16(902), Fflags: uint8(18), FnRange: uint8(1)}, {FiCode: uint16(904), Fflags: uint8(16), FnRange: uint8(3)}, + {FiCode: uint16(908), Fflags: uint8(26), FnRange: uint8(1)}, {FiCode: uint16(910), Fflags: uint8(24), FnRange: uint8(2)}, {FiCode: uint16(913), Fflags: uint8(14), FnRange: uint8(17)}, + {FiCode: uint16(931), Fflags: uint8(14), FnRange: uint8(9)}, {FiCode: uint16(962), FnRange: uint8(1)}, {FiCode: uint16(975), Fflags: uint8(4), FnRange: uint8(1)}, + {FiCode: uint16(976), Fflags: uint8(140), FnRange: uint8(1)}, {FiCode: uint16(977), Fflags: uint8(142), FnRange: uint8(1)}, {FiCode: uint16(981), Fflags: uint8(146), FnRange: uint8(1)}, + {FiCode: uint16(982), Fflags: uint8(144), FnRange: uint8(1)}, {FiCode: uint16(984), Fflags: uint8(1), FnRange: uint8(24)}, {FiCode: uint16(1008), Fflags: uint8(136), FnRange: uint8(1)}, + {FiCode: uint16(1009), Fflags: uint8(138), FnRange: uint8(1)}, {FiCode: uint16(1012), Fflags: uint8(130), FnRange: uint8(1)}, {FiCode: uint16(1013), Fflags: uint8(128), FnRange: uint8(1)}, + {FiCode: uint16(1015), FnRange: uint8(1)}, {FiCode: uint16(1017), Fflags: uint8(152), FnRange: uint8(1)}, {FiCode: uint16(1018), FnRange: uint8(1)}, + {FiCode: uint16(1021), Fflags: uint8(110), FnRange: uint8(3)}, {FiCode: uint16(1024), Fflags: uint8(34), FnRange: uint8(16)}, {FiCode: uint16(1040), Fflags: uint8(14), FnRange: uint8(32)}, + {FiCode: uint16(1120), Fflags: uint8(1), FnRange: uint8(34)}, {FiCode: uint16(1162), Fflags: uint8(1), FnRange: uint8(54)}, {FiCode: uint16(1216), Fflags: uint8(6), FnRange: uint8(1)}, + {FiCode: uint16(1217), Fflags: uint8(1), FnRange: uint8(14)}, {FiCode: uint16(1232), Fflags: uint8(1), FnRange: uint8(88)}, {FiCode: uint16(1329), Fflags: uint8(22), FnRange: uint8(38)}, + {FiCode: uint16(4256), Fflags: uint8(66), FnRange: uint8(38)}, {FiCode: uint16(4295), Fflags: uint8(66), FnRange: uint8(1)}, {FiCode: uint16(4301), Fflags: uint8(66), FnRange: uint8(1)}, + {FiCode: uint16(7680), Fflags: uint8(1), FnRange: uint8(150)}, {FiCode: uint16(7835), Fflags: uint8(132), FnRange: uint8(1)}, {FiCode: uint16(7838), Fflags: uint8(96), FnRange: uint8(1)}, + {FiCode: uint16(7840), Fflags: uint8(1), FnRange: uint8(96)}, {FiCode: uint16(7944), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(7960), Fflags: uint8(150), FnRange: uint8(6)}, + {FiCode: uint16(7976), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(7992), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(8008), Fflags: uint8(150), FnRange: uint8(6)}, + {FiCode: uint16(8025), Fflags: uint8(151), FnRange: uint8(8)}, {FiCode: uint16(8040), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(8072), Fflags: uint8(150), FnRange: uint8(8)}, + {FiCode: uint16(8088), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(8104), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(8120), Fflags: uint8(150), FnRange: uint8(2)}, + {FiCode: uint16(8122), Fflags: uint8(126), FnRange: uint8(2)}, {FiCode: uint16(8124), Fflags: uint8(148), FnRange: uint8(1)}, {FiCode: uint16(8126), Fflags: uint8(100), FnRange: uint8(1)}, + {FiCode: uint16(8136), Fflags: uint8(124), FnRange: uint8(4)}, {FiCode: uint16(8140), Fflags: uint8(148), FnRange: uint8(1)}, {FiCode: uint16(8152), Fflags: uint8(150), FnRange: uint8(2)}, + {FiCode: uint16(8154), Fflags: uint8(120), FnRange: uint8(2)}, {FiCode: uint16(8168), Fflags: uint8(150), FnRange: uint8(2)}, {FiCode: uint16(8170), Fflags: uint8(118), FnRange: uint8(2)}, + {FiCode: uint16(8172), Fflags: uint8(152), FnRange: uint8(1)}, {FiCode: uint16(8184), Fflags: uint8(112), FnRange: uint8(2)}, {FiCode: uint16(8186), Fflags: uint8(114), FnRange: uint8(2)}, + {FiCode: uint16(8188), Fflags: uint8(148), FnRange: uint8(1)}, {FiCode: uint16(8486), Fflags: uint8(98), FnRange: uint8(1)}, {FiCode: uint16(8490), Fflags: uint8(92), FnRange: uint8(1)}, + {FiCode: uint16(8491), Fflags: uint8(94), FnRange: uint8(1)}, {FiCode: uint16(8498), Fflags: uint8(12), FnRange: uint8(1)}, {FiCode: uint16(8544), Fflags: uint8(8), FnRange: uint8(16)}, + {FiCode: uint16(8579), FnRange: uint8(1)}, {FiCode: uint16(9398), Fflags: uint8(10), FnRange: uint8(26)}, {FiCode: uint16(11264), Fflags: uint8(22), FnRange: uint8(47)}, + {FiCode: uint16(11360), FnRange: uint8(1)}, {FiCode: uint16(11362), Fflags: uint8(88), FnRange: uint8(1)}, {FiCode: uint16(11363), Fflags: uint8(102), FnRange: uint8(1)}, + {FiCode: uint16(11364), Fflags: uint8(90), FnRange: uint8(1)}, {FiCode: uint16(11367), Fflags: uint8(1), FnRange: uint8(6)}, {FiCode: uint16(11373), Fflags: uint8(84), FnRange: uint8(1)}, + {FiCode: uint16(11374), Fflags: uint8(86), FnRange: uint8(1)}, {FiCode: uint16(11375), Fflags: uint8(80), FnRange: uint8(1)}, {FiCode: uint16(11376), Fflags: uint8(82), FnRange: uint8(1)}, + {FiCode: uint16(11378), FnRange: uint8(1)}, {FiCode: uint16(11381), FnRange: uint8(1)}, {FiCode: uint16(11390), Fflags: uint8(78), FnRange: uint8(2)}, + {FiCode: uint16(11392), Fflags: uint8(1), FnRange: uint8(100)}, {FiCode: uint16(11499), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(11506), FnRange: uint8(1)}, + {FiCode: uint16(42560), Fflags: uint8(1), FnRange: uint8(46)}, {FiCode: uint16(42624), Fflags: uint8(1), FnRange: uint8(24)}, {FiCode: uint16(42786), Fflags: uint8(1), FnRange: uint8(14)}, + {FiCode: uint16(42802), Fflags: uint8(1), FnRange: uint8(62)}, {FiCode: uint16(42873), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(42877), Fflags: uint8(76), FnRange: uint8(1)}, + {FiCode: uint16(42878), Fflags: uint8(1), FnRange: uint8(10)}, {FiCode: uint16(42891), FnRange: uint8(1)}, {FiCode: uint16(42893), Fflags: uint8(74), FnRange: uint8(1)}, + {FiCode: uint16(42896), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(42912), Fflags: uint8(1), FnRange: uint8(10)}, {FiCode: uint16(42922), Fflags: uint8(72), FnRange: uint8(1)}, + {FiCode: uint16(65313), Fflags: uint8(14), FnRange: uint8(26)}, } /* sqlite3.c:228435:5 */ var aiOff = [77]uint16{ uint16(1), uint16(2), uint16(8), uint16(15), uint16(16), uint16(26), uint16(28), uint16(32), @@ -182565,31 +179346,31 @@ var aiOff = [77]uint16{ } /* sqlite3.c:228492:31 */ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int32 { /* sqlite3.c:228549:12: */ - *(*U8)(unsafe.Pointer(aArray + uintptr(0))) = U8(1) - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(0)))) { + *(*U8)(unsafe.Pointer(aArray)) = U8(1) + switch int32(*(*int8)(unsafe.Pointer(zCat))) { case 'C': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'c': - *(*U8)(unsafe.Pointer(aArray + uintptr(1))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 1)) = U8(1) break case 'f': - *(*U8)(unsafe.Pointer(aArray + uintptr(2))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 2)) = U8(1) break case 'n': - *(*U8)(unsafe.Pointer(aArray + uintptr(3))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 3)) = U8(1) break case 's': - *(*U8)(unsafe.Pointer(aArray + uintptr(4))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 4)) = U8(1) break case 'o': - *(*U8)(unsafe.Pointer(aArray + uintptr(31))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 31)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(1))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(2))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(3))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(4))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(31))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 1)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 2)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 3)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 4)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 31)) = U8(1) break default: return 1 @@ -182597,32 +179378,32 @@ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int break case 'L': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'l': - *(*U8)(unsafe.Pointer(aArray + uintptr(5))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 5)) = U8(1) break case 'm': - *(*U8)(unsafe.Pointer(aArray + uintptr(6))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 6)) = U8(1) break case 'o': - *(*U8)(unsafe.Pointer(aArray + uintptr(7))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 7)) = U8(1) break case 't': - *(*U8)(unsafe.Pointer(aArray + uintptr(8))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 8)) = U8(1) break case 'u': - *(*U8)(unsafe.Pointer(aArray + uintptr(9))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 9)) = U8(1) break case 'C': - *(*U8)(unsafe.Pointer(aArray + uintptr(30))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 30)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(5))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(6))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(7))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(8))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(9))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(30))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 5)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 6)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 7)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 8)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 9)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 30)) = U8(1) break default: return 1 @@ -182630,20 +179411,20 @@ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int break case 'M': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'c': - *(*U8)(unsafe.Pointer(aArray + uintptr(10))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 10)) = U8(1) break case 'e': - *(*U8)(unsafe.Pointer(aArray + uintptr(11))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 11)) = U8(1) break case 'n': - *(*U8)(unsafe.Pointer(aArray + uintptr(12))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 12)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(10))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(11))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(12))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 10)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 11)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 12)) = U8(1) break default: return 1 @@ -182651,20 +179432,20 @@ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int break case 'N': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'd': - *(*U8)(unsafe.Pointer(aArray + uintptr(13))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 13)) = U8(1) break case 'l': - *(*U8)(unsafe.Pointer(aArray + uintptr(14))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 14)) = U8(1) break case 'o': - *(*U8)(unsafe.Pointer(aArray + uintptr(15))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 15)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(13))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(14))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(15))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 13)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 14)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 15)) = U8(1) break default: return 1 @@ -182672,36 +179453,36 @@ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int break case 'P': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'c': - *(*U8)(unsafe.Pointer(aArray + uintptr(16))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 16)) = U8(1) break case 'd': - *(*U8)(unsafe.Pointer(aArray + uintptr(17))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 17)) = U8(1) break case 'e': - *(*U8)(unsafe.Pointer(aArray + uintptr(18))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 18)) = U8(1) break case 'f': - *(*U8)(unsafe.Pointer(aArray + uintptr(19))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 19)) = U8(1) break case 'i': - *(*U8)(unsafe.Pointer(aArray + uintptr(20))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 20)) = U8(1) break case 'o': - *(*U8)(unsafe.Pointer(aArray + uintptr(21))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 21)) = U8(1) break case 's': - *(*U8)(unsafe.Pointer(aArray + uintptr(22))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 22)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(16))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(17))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(18))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(19))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(20))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(21))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(22))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 16)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 17)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 18)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 19)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 20)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 21)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 22)) = U8(1) break default: return 1 @@ -182709,24 +179490,24 @@ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int break case 'S': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'c': - *(*U8)(unsafe.Pointer(aArray + uintptr(23))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 23)) = U8(1) break case 'k': - *(*U8)(unsafe.Pointer(aArray + uintptr(24))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 24)) = U8(1) break case 'm': - *(*U8)(unsafe.Pointer(aArray + uintptr(25))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 25)) = U8(1) break case 'o': - *(*U8)(unsafe.Pointer(aArray + uintptr(26))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 26)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(23))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(24))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(25))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(26))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 23)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 24)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 25)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 26)) = U8(1) break default: return 1 @@ -182734,20 +179515,20 @@ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int break case 'Z': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'l': - *(*U8)(unsafe.Pointer(aArray + uintptr(27))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 27)) = U8(1) break case 'p': - *(*U8)(unsafe.Pointer(aArray + uintptr(28))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 28)) = U8(1) break case 's': - *(*U8)(unsafe.Pointer(aArray + uintptr(29))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 29)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(27))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(28))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(29))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 27)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 28)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 29)) = U8(1) break default: return 1 @@ -183297,7 +180078,7 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c a = a | (U32(*(*uint8)(unsafe.Pointer(p)))) // a: p0<<14 | p2 (unmasked) if !((a & U32(0x80)) != 0) { - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) b = b & (U32(0x7f)) b = (b << 7) a = a | (b) @@ -183306,13 +180087,13 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c } // CSE1 from below - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) p++ b = (b << 14) b = b | (U32(*(*uint8)(unsafe.Pointer(p)))) // b: p1<<14 | p3 (unmasked) if !((b & U32(0x80)) != 0) { - b = b & (U32(0x001fc07f)) + b = b & (SLOT_2_0) // moved CSE1 up // a &= (0x7f<<14)|(0x7f); a = (a << 7) @@ -183326,7 +180107,7 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c // 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) // moved CSE1 up // a &= (0x7f<<14)|(0x7f); - b = b & (U32(0x001fc07f)) + b = b & (SLOT_2_0) s = a // s: p0<<14 | p2 (masked) @@ -183357,7 +180138,7 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c if !((b & U32(0x80)) != 0) { // we can skip this cause it was (effectively) done above in calc'ing s // b &= (0x7f<<28)|(0x7f<<14)|(0x7f); - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) a = (a << 7) a = a | (b) s = (s >> 18) @@ -183370,8 +180151,8 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c a = a | (U32(*(*uint8)(unsafe.Pointer(p)))) // a: p2<<28 | p4<<14 | p6 (unmasked) if !((a & U32(0x80)) != 0) { - a = a & (0xf01fc07f) - b = b & (U32(0x001fc07f)) + a = a & (SLOT_4_2_0) + b = b & (SLOT_2_0) b = (b << 7) a = a | (b) s = (s >> 11) @@ -183380,13 +180161,13 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c } // CSE2 from below - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) p++ b = (b << 14) b = b | (U32(*(*uint8)(unsafe.Pointer(p)))) // b: p3<<28 | p5<<14 | p7 (unmasked) if !((b & U32(0x80)) != 0) { - b = b & (0xf01fc07f) + b = b & (SLOT_4_2_0) // moved CSE2 up // a &= (0x7f<<14)|(0x7f); a = (a << 7) @@ -183403,7 +180184,7 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c // moved CSE2 up // a &= (0x7f<<29)|(0x7f<<15)|(0xff); - b = b & (U32(0x001fc07f)) + b = b & (SLOT_2_0) b = (b << 8) a = a | (b) @@ -183453,7 +180234,7 @@ func fts5PutVarint64(tls *libc.TLS, p uintptr, v U64) int32 { /* sqlite3.c:22936 // var buf [10]U8 at bp, 10 if (v & (U64((uint64(0xff000000))) << 32)) != 0 { - *(*uint8)(unsafe.Pointer(p + uintptr(8))) = U8(v) + *(*uint8)(unsafe.Pointer(p + 8)) = U8(v) v >>= 8 for i = 7; i >= 0; i-- { *(*uint8)(unsafe.Pointer(p + uintptr(i))) = (U8((v & uint64(0x7f)) | uint64(0x80))) @@ -183466,7 +180247,7 @@ func fts5PutVarint64(tls *libc.TLS, p uintptr, v U64) int32 { /* sqlite3.c:22936 *(*U8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(libc.PostIncInt32(&n, 1)))) = (U8((v & uint64(0x7f)) | uint64(0x80))) v >>= 7 } - *(*U8)(unsafe.Pointer(bp /* &buf */ + uintptr(0))) &= U8((0x7f)) + *(*U8)(unsafe.Pointer(bp /* &buf */)) &= U8((0x7f)) i = 0 j = (n - 1) @@ -183491,12 +180272,12 @@ __3: func sqlite3Fts5PutVarint(tls *libc.TLS, p uintptr, v U64) int32 { /* sqlite3.c:229394:12: */ if v <= uint64(0x7f) { - *(*uint8)(unsafe.Pointer(p + uintptr(0))) = (uint8(v & uint64(0x7f))) + *(*uint8)(unsafe.Pointer(p)) = (uint8(v & uint64(0x7f))) return 1 } if v <= uint64(0x3fff) { - *(*uint8)(unsafe.Pointer(p + uintptr(0))) = (uint8(((v >> 7) & uint64(0x7f)) | uint64(0x80))) - *(*uint8)(unsafe.Pointer(p + uintptr(1))) = (uint8(v & uint64(0x7f))) + *(*uint8)(unsafe.Pointer(p)) = (uint8(((v >> 7) & uint64(0x7f)) | uint64(0x80))) + *(*uint8)(unsafe.Pointer(p + 1)) = (uint8(v & uint64(0x7f))) return 2 } return fts5PutVarint64(tls, p, v) @@ -183636,19 +180417,19 @@ func fts5VocabTableType(tls *libc.TLS, zType uintptr, pzErr uintptr, peType uint bp := tls.Alloc(12) defer tls.Free(12) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK var zCopy uintptr = sqlite3Fts5Strndup(tls, bp+8 /* &rc */, zType, -1) - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { sqlite3Fts5Dequote(tls, zCopy) if Xsqlite3_stricmp(tls, zCopy, ts+33778 /* "col" */) == 0 { - *(*int32)(unsafe.Pointer(peType)) = 0 + *(*int32)(unsafe.Pointer(peType)) = FTS5_VOCAB_COL } else if Xsqlite3_stricmp(tls, zCopy, ts+33782 /* "row" */) == 0 { - *(*int32)(unsafe.Pointer(peType)) = 1 + *(*int32)(unsafe.Pointer(peType)) = FTS5_VOCAB_ROW } else if Xsqlite3_stricmp(tls, zCopy, ts+33786 /* "instance" */) == 0 { - *(*int32)(unsafe.Pointer(peType)) = 2 + *(*int32)(unsafe.Pointer(peType)) = FTS5_VOCAB_INSTANCE } else { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+33795 /* "fts5vocab: unkno..." */, libc.VaList(bp, zCopy)) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_ERROR } Xsqlite3_free(tls, zCopy) } @@ -183660,14 +180441,14 @@ func fts5VocabTableType(tls *libc.TLS, zType uintptr, pzErr uintptr, peType uint func fts5VocabDisconnectMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:229550:12: */ var pTab uintptr = pVtab Xsqlite3_free(tls, pTab) - return 0 + return SQLITE_OK } // The xDestroy() virtual table method. func fts5VocabDestroyMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:229559:12: */ var pTab uintptr = pVtab Xsqlite3_free(tls, pTab) - return 0 + return SQLITE_OK } // This function is the implementation of both the xConnect and xCreate @@ -183700,40 +180481,40 @@ func fts5VocabInitVtab(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv } var pRet uintptr = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = 0 // Return code + *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = SQLITE_OK // Return code var bDb int32 - bDb = (libc.Bool32(((argc == 6) && (libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) == uint64(4))) && (libc.Xmemcmp(tls, ts+20591 /* "temp" */, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uint64(4)) == 0))) + bDb = (libc.Bool32(((argc == 6) && (libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) == uint64(4))) && (libc.Xmemcmp(tls, ts+20591 /* "temp" */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uint64(4)) == 0))) if (argc != 5) && (bDb == 0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+33947 /* "wrong number of ..." */, 0) - *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = SQLITE_ERROR } else { var nByte int32 // Bytes of space to allocate var zDb uintptr if bDb != 0 { - zDb = *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)) + zDb = *(*uintptr)(unsafe.Pointer(argv + 3*8)) } else { - zDb = *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) + zDb = *(*uintptr)(unsafe.Pointer(argv + 1*8)) } var zTab uintptr if bDb != 0 { - zTab = *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)) + zTab = *(*uintptr)(unsafe.Pointer(argv + 4*8)) } else { - zTab = *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)) + zTab = *(*uintptr)(unsafe.Pointer(argv + 3*8)) } var zType uintptr if bDb != 0 { - zType = *(*uintptr)(unsafe.Pointer(argv + uintptr(5)*8)) + zType = *(*uintptr)(unsafe.Pointer(argv + 5*8)) } else { - zType = *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)) + zType = *(*uintptr)(unsafe.Pointer(argv + 4*8)) } var nDb int32 = (int32(libc.Xstrlen(tls, zDb)) + 1) var nTab int32 = (int32(libc.Xstrlen(tls, zTab)) + 1) *(*int32)(unsafe.Pointer(bp /* eType */)) = 0 *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = fts5VocabTableType(tls, zType, pzErr, bp /* &eType */) - if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = Xsqlite3_declare_vtab(tls, db, *(*uintptr)(unsafe.Pointer(bp + 8 /* &azSchema[0] */ + uintptr(*(*int32)(unsafe.Pointer(bp /* eType */)))*8))) } @@ -183744,7 +180525,7 @@ func fts5VocabInitVtab(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv (*Fts5VocabTable)(unsafe.Pointer(pRet)).FpGlobal = pAux (*Fts5VocabTable)(unsafe.Pointer(pRet)).FeType = *(*int32)(unsafe.Pointer(bp /* eType */)) (*Fts5VocabTable)(unsafe.Pointer(pRet)).Fdb = db - (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl = (pRet + uintptr(1)*64) + (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl = (pRet + 1*64) (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db = ((*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl + uintptr(nTab)) libc.Xmemcpy(tls, (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl, zTab, uint64(nTab)) libc.Xmemcpy(tls, (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db, zDb, uint64(nDb)) @@ -183793,37 +180574,37 @@ func fts5VocabBestIndexMethod(tls *libc.TLS, pUnused uintptr, pInfo uintptr) int continue } if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0 { // term column - if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ { iTermEq = i } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 8 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_LE { iTermLe = i } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 16 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_LT { iTermLe = i } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 32 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_GE { iTermGe = i } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 4 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_GT { iTermGe = i } } } if iTermEq >= 0 { - idxNum = idxNum | (0x01) + idxNum = idxNum | (FTS5_VOCAB_TERM_EQ) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(iTermEq)*8)).FargvIndex = libc.PreIncInt32(&nArg, 1) (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(100) } else { (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(1000000) if iTermGe >= 0 { - idxNum = idxNum | (0x02) + idxNum = idxNum | (FTS5_VOCAB_TERM_GE) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(iTermGe)*8)).FargvIndex = libc.PreIncInt32(&nArg, 1) (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = ((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / float64(2)) } if iTermLe >= 0 { - idxNum = idxNum | (0x04) + idxNum = idxNum | (FTS5_VOCAB_TERM_LE) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(iTermLe)*8)).FargvIndex = libc.PreIncInt32(&nArg, 1) (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = ((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / float64(2)) } @@ -183835,13 +180616,13 @@ func fts5VocabBestIndexMethod(tls *libc.TLS, pUnused uintptr, pInfo uintptr) int // sqlite3_index_info.orderByConsumed flag to tell the core the results // are already in sorted order. if (((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnOrderBy == 1) && - ((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy+uintptr(0)*8)).FiColumn == 0)) && - (int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy+uintptr(0)*8)).Fdesc) == 0) { + ((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy)).FiColumn == 0)) && + (int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy)).Fdesc) == 0) { (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).ForderByConsumed = 1 } (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = idxNum - return 0 + return SQLITE_OK } // Implementation of xOpen method. @@ -183852,14 +180633,14 @@ func fts5VocabOpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 { /* var pTab uintptr = pVTab var pFts5 uintptr = uintptr(0) var pCsr uintptr = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)) = uintptr(0) var zSql uintptr = uintptr(0) if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FbBusy != 0 { (*Sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+33980 /* "recursive defini..." */, libc.VaList(bp, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Db, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl)) - return 1 + return SQLITE_ERROR } zSql = sqlite3Fts5Mprintf(tls, bp+64, /* &rc */ ts+34011, /* "SELECT t.%Q FROM..." */ @@ -183869,32 +180650,32 @@ func fts5VocabOpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 { /* } Xsqlite3_free(tls, zSql) - if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 1 { - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 0 + if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_ERROR { + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_OK } (*Fts5VocabTable)(unsafe.Pointer(pTab)).FbBusy = uint32(1) - if (*(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)) != 0) && (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) == 100) { + if (*(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)) != 0) && (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) == SQLITE_ROW) { var iId I64 = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)), 0) pFts5 = sqlite3Fts5TableFromCsrid(tls, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FpGlobal, iId) } (*Fts5VocabTable)(unsafe.Pointer(pTab)).FbBusy = uint32(0) - if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK { if pFts5 == uintptr(0) { *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)) = uintptr(0) - if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK { (*Sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+34062 /* "no such fts5 tab..." */, libc.VaList(bp+48, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Db, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl)) - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR } } else { *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = sqlite3Fts5FlushToDisk(tls, pFts5) } } - if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK { var nByte int32 = (int32(((uint64((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pFts5)).FpConfig)).FnCol) * uint64(unsafe.Sizeof(I64(0)))) * uint64(2)) + uint64(unsafe.Sizeof(Fts5VocabCursor{})))) pCsr = sqlite3Fts5MallocZero(tls, bp+64 /* &rc */, int64(nByte)) } @@ -183902,7 +180683,7 @@ func fts5VocabOpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 { /* if pCsr != 0 { (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5 = pFts5 (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpStmt = *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)) - (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt = (pCsr + uintptr(1)*120) + (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt = (pCsr + 1*120) (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc = ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pFts5)).FpConfig)).FnCol)*8) } else { Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) @@ -183930,14 +180711,14 @@ func fts5VocabCloseMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:2 sqlite3Fts5BufferFree(tls, (pCsr + 88 /* &.term */)) Xsqlite3_finalize(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpStmt) Xsqlite3_free(tls, pCsr) - return 0 + return SQLITE_OK } func fts5VocabInstanceNewTerm(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:229834:12: */ bp := tls.Alloc(8) defer tls.Free(8) - *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = SQLITE_OK if (*Fts5IndexIter)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FbEof != 0 { (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = 1 @@ -183966,20 +180747,20 @@ func fts5VocabInstanceNewTerm(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c: func fts5VocabInstanceNext(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:229856:12: */ var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail - var rc int32 = 0 + var rc int32 = SQLITE_OK var pIter uintptr = (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter var pp uintptr = (pCsr + 104 /* &.iInstPos */) var po uintptr = (pCsr + 112 /* &.iInstOff */) - for (eDetail == 1) || + for (eDetail == FTS5_DETAIL_NONE) || (sqlite3Fts5PoslistNext64(tls, (*Fts5IndexIter)(unsafe.Pointer(pIter)).FpData, (*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData, po, pp) != 0) { (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos = int64(0) (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstOff = 0 rc = sqlite3Fts5IterNextScan(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter) - if rc == 0 { + if rc == SQLITE_OK { rc = fts5VocabInstanceNewTerm(tls, pCsr) - if ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0) || (eDetail == 1) { + if ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0) || (eDetail == FTS5_DETAIL_NONE) { break } } @@ -183999,16 +180780,16 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 var pCsr uintptr = pCursor var pTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab - *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = SQLITE_OK var nCol int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FnCol (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid++ - if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == 2 { + if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_INSTANCE { return fts5VocabInstanceNext(tls, pCsr) } - if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == 0 { + if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_COL { for (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol++; (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol < nCol; (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol++ { if *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) != 0 { break @@ -184016,7 +180797,7 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 } } - if ((*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType != 0) || ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol >= nCol) { + if ((*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType != FTS5_VOCAB_COL) || ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol >= nCol) { if (*Fts5IndexIter)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FbEof != 0 { (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = 1 } else { @@ -184035,7 +180816,7 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 var bCmp int32 = libc.Xmemcmp(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm, zTerm, uint64(nCmp)) if (bCmp < 0) || ((bCmp == 0) && ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm < *(*int32)(unsafe.Pointer(bp /* nTerm */)))) { (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = 1 - return 0 + return SQLITE_OK } } @@ -184044,7 +180825,7 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 libc.Xmemset(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc, 0, (uint64(nCol) * uint64(unsafe.Sizeof(I64(0))))) (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol = 0 - for *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + for *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail var pPos uintptr var nPos int32 // Position list @@ -184055,24 +180836,24 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 nPos = (*Fts5IndexIter)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FnData switch (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType { - case 1: - if eDetail == 0 { + case FTS5_VOCAB_ROW: + if eDetail == FTS5_DETAIL_FULL { for 0 == sqlite3Fts5PoslistNext64(tls, pPos, nPos, bp+8 /* &iOff */, bp+16 /* &iPos */) { - *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr(0)*8))++ + *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt))++ } } - *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr(0)*8))++ + *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc))++ break fallthrough - case 0: - if eDetail == 0 { + case FTS5_VOCAB_COL: + if eDetail == FTS5_DETAIL_FULL { var iCol int32 = -1 for 0 == sqlite3Fts5PoslistNext64(tls, pPos, nPos, bp+8 /* &iOff */, bp+16 /* &iPos */) { var ii int32 = (int32(*(*I64)(unsafe.Pointer(bp + 16 /* iPos */)) >> 32)) if iCol != ii { if ii >= nCol { - *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) break } *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr(ii)*8))++ @@ -184080,18 +180861,18 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 } *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr(ii)*8))++ } - } else if eDetail == 2 { + } else if eDetail == FTS5_DETAIL_COLUMNS { for 0 == sqlite3Fts5PoslistNext64(tls, pPos, nPos, bp+8 /* &iOff */, bp+16 /* &iPos */) { if *(*I64)(unsafe.Pointer(bp + 16 /* iPos */)) >= I64(nCol) { - *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) break } *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr(*(*I64)(unsafe.Pointer(bp + 16 /* iPos */)))*8))++ } } else { - *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr(0)*8))++ + *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc))++ } break fallthrough @@ -184101,14 +180882,14 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 break } - if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = sqlite3Fts5IterNextScan(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter) } - if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == 2 { + if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_INSTANCE { break } - if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { zTerm = sqlite3Fts5IterTerm(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter, bp /* &nTerm */) if (*(*int32)(unsafe.Pointer(bp /* nTerm */)) != (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fn) || ((*(*int32)(unsafe.Pointer(bp /* nTerm */)) > 0) && (libc.Xmemcmp(tls, zTerm, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fp, uint64(*(*int32)(unsafe.Pointer(bp /* nTerm */)))) != 0)) { @@ -184122,11 +180903,11 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 } } - if ((*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0) && ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof == 0)) && ((*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == 0) { + if ((*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK) && ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof == 0)) && ((*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_COL) { for ; ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol < nCol) && (*(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) == int64(0)); (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol++ { } if (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol == nCol { - *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } } return *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) @@ -184137,10 +180918,10 @@ func fts5VocabFilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, zUnused var pTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab var pCsr uintptr = pCursor var eType int32 = (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType - var rc int32 = 0 + var rc int32 = SQLITE_OK var iVal int32 = 0 - var f int32 = 0x0008 + var f int32 = FTS5INDEX_QUERY_SCAN var zTerm uintptr = uintptr(0) var nTerm int32 = 0 @@ -184152,13 +180933,13 @@ func fts5VocabFilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, zUnused _ = nUnused fts5VocabResetCursor(tls, pCsr) - if (idxNum & 0x01) != 0 { + if (idxNum & FTS5_VOCAB_TERM_EQ) != 0 { pEq = *(*uintptr)(unsafe.Pointer(apVal + uintptr(libc.PostIncInt32(&iVal, 1))*8)) } - if (idxNum & 0x02) != 0 { + if (idxNum & FTS5_VOCAB_TERM_GE) != 0 { pGe = *(*uintptr)(unsafe.Pointer(apVal + uintptr(libc.PostIncInt32(&iVal, 1))*8)) } - if (idxNum & 0x04) != 0 { + if (idxNum & FTS5_VOCAB_TERM_LE) != 0 { pLe = *(*uintptr)(unsafe.Pointer(apVal + uintptr(libc.PostIncInt32(&iVal, 1))*8)) } @@ -184179,23 +180960,23 @@ func fts5VocabFilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, zUnused (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm = Xsqlite3_value_bytes(tls, pLe) (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm = Xsqlite3_malloc(tls, ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm + 1)) if (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemcpy(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm, zCopy, (uint64((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm + 1))) } } } - if rc == 0 { + if rc == SQLITE_OK { var pIndex uintptr = (*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpIndex rc = sqlite3Fts5IndexQuery(tls, pIndex, zTerm, nTerm, f, uintptr(0), (pCsr + 32 /* &.pIter */)) } - if (rc == 0) && (eType == 2) { + if (rc == SQLITE_OK) && (eType == FTS5_VOCAB_INSTANCE) { rc = fts5VocabInstanceNewTerm(tls, pCsr) } - if ((rc == 0) && !((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0)) && - ((eType != 2) || - ((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail != 1)) { + if ((rc == SQLITE_OK) && !((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0)) && + ((eType != FTS5_VOCAB_INSTANCE) || + ((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail != FTS5_DETAIL_NONE)) { rc = fts5VocabNextMethod(tls, pCursor) } @@ -184218,10 +180999,10 @@ func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol in if iCol == 0 { Xsqlite3_result_text(tls, pCtx, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fp, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fn, libc.UintptrFromInt32(-1)) - } else if eType == 0 { + } else if eType == FTS5_VOCAB_COL { if iCol == 1 { - if eDetail != 1 { + if eDetail != FTS5_DETAIL_NONE { var z uintptr = *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FazCol + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) Xsqlite3_result_text(tls, pCtx, z, -1, uintptr(0)) } @@ -184230,12 +181011,12 @@ func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol in } else { iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) } - } else if eType == 1 { + } else if eType == FTS5_VOCAB_ROW { if iCol == 1 { - iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr(0)*8)) + iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc)) } else { - iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr(0)*8)) + iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt)) } } else { @@ -184247,9 +181028,9 @@ func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol in case 2: { var ii int32 = -1 - if eDetail == 0 { + if eDetail == FTS5_DETAIL_FULL { ii = (int32((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos >> 32)) - } else if eDetail == 2 { + } else if eDetail == FTS5_DETAIL_COLUMNS { ii = int32((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos) } if (ii >= 0) && (ii < (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FnCol) { @@ -184263,7 +181044,7 @@ func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol in default: { - if eDetail == 0 { + if eDetail == FTS5_DETAIL_FULL { var ii int32 = (int32((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos & int64(0x7FFFFFFF))) Xsqlite3_result_int(tls, pCtx, ii) } @@ -184276,7 +181057,7 @@ func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol in if iVal > int64(0) { Xsqlite3_result_int64(tls, pCtx, iVal) } - return 0 + return SQLITE_OK } // This is the xRowid method. The SQLite core calls this routine to @@ -184285,7 +181066,7 @@ func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol in func fts5VocabRowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { /* sqlite3.c:230162:12: */ var pCsr uintptr = pCursor *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid - return 0 + return SQLITE_OK } func sqlite3Fts5VocabInit(tls *libc.TLS, pGlobal uintptr, db uintptr) int32 { /* sqlite3.c:230171:12: */ @@ -184295,54 +181076,19 @@ func sqlite3Fts5VocabInit(tls *libc.TLS, pGlobal uintptr, db uintptr) int32 { /* } var fts5Vocab = Sqlite3_module{ - FiVersion: - /* iVersion */ 2, - FxCreate: - /* xCreate */ 0, - FxConnect: - /* xConnect */ 0, - FxBestIndex: - /* xBestIndex */ 0, - FxDisconnect: - /* xDisconnect */ 0, - FxDestroy: - /* xDestroy */ 0, - FxOpen: - /* xOpen */ 0, - FxClose: - /* xClose */ 0, - FxFilter: - /* xFilter */ 0, - FxNext: - /* xNext */ 0, - FxEof: - /* xEof */ 0, - FxColumn: - /* xColumn */ 0, - FxRowid: - /* xRowid */ 0, - FxUpdate: - /* xUpdate */ uintptr(0), - FxBegin: - /* xBegin */ uintptr(0), - FxSync: - /* xSync */ uintptr(0), - FxCommit: - /* xCommit */ uintptr(0), - FxRollback: - /* xRollback */ uintptr(0), - FxFindFunction: - /* xFindFunction */ uintptr(0), - FxRename: - /* xRename */ uintptr(0), - FxSavepoint: - /* xSavepoint */ uintptr(0), - FxRelease: - /* xRelease */ uintptr(0), - FxRollbackTo: - /* xRollbackTo */ uintptr(0), - FxShadowName: - /* xShadowName */ uintptr(0), + /* iVersion */ FiVersion: 2, + /* xCreate */ FxCreate: 0, + /* xConnect */ FxConnect: 0, + /* xBestIndex */ FxBestIndex: 0, + /* xDisconnect */ FxDisconnect: 0, + /* xDestroy */ FxDestroy: 0, + /* xOpen */ FxOpen: 0, + /* xClose */ FxClose: 0, + /* xFilter */ FxFilter: 0, + /* xNext */ FxNext: 0, + /* xEof */ FxEof: 0, + /* xColumn */ FxColumn: 0, + /* xRowid */ FxRowid: 0, } /* sqlite3.c:230172:31 */ //************* End of fts5.c *********************************************** diff --git a/libtest/sqlite_darwin_amd64.go b/libtest/sqlite_darwin_amd64.go index 363e7d7..e46eb93 100644 --- a/libtest/sqlite_darwin_amd64.go +++ b/libtest/sqlite_darwin_amd64.go @@ -176734,7 +176734,6 @@ __15: goto __14 goto __16 __16: - } // This is a helper function for rbuObjIterCacheTableInfo(). It populates diff --git a/libtest/sqlite_linux_amd64.go b/libtest/sqlite_linux_amd64.go index 9116f39..40ecea7 100644 --- a/libtest/sqlite_linux_amd64.go +++ b/libtest/sqlite_linux_amd64.go @@ -9,12 +9,14 @@ import ( "unsafe" "modernc.org/libc" + "modernc.org/libc/sys/types" ) var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer +var _ types.Size_t const ( ACCESSPERMS = 511 @@ -489,7 +491,6 @@ const ( FTS5_MAX_TOKEN_SIZE = 32768 FTS5_MINUS = 6 FTS5_MIN_DLIDX_SIZE = 4 - FTS5_NOINLINE = 0 FTS5_NOT = 3 FTS5_OPT_WORK_UNIT = 1000 FTS5_OR = 1 @@ -650,7 +651,6 @@ const ( JSON_FALSE = 2 JSON_INT = 3 JSON_MAX_DEPTH = 2000 - JSON_NOINLINE = 0 JSON_NULL = 0 JSON_OBJECT = 7 JSON_REAL = 4 @@ -1960,7 +1960,6 @@ const ( SQLITE_MUTEX_STATIC_VFS3 = 13 SQLITE_MX_JUMP_OPCODE = 62 SQLITE_NEED_ERR_NAME = 0 - SQLITE_NOINLINE = 0 SQLITE_NOLFS = 22 SQLITE_NOMATCH = 1 SQLITE_NOMEM = 7 @@ -3634,8 +3633,8 @@ type X__uint128_t = struct { Fhi uint64 } /* :22:44 */ // must match modernc.org/mathutil.Int128 -type X__builtin_va_list = uintptr /* :47:14 */ -type X__float128 = float64 /* :48:21 */ +type X__builtin_va_list = uintptr /* :46:14 */ +type X__float128 = float64 /* :47:21 */ // ***************************************************************************** // @@ -10536,89 +10535,20 @@ var Xsqlite3CtypeMap = [256]uint8{ // The following singleton contains the global configuration for // the SQLite library. -var Xsqlite3Config = Sqlite3Config{ - FbMemstat: 0, - FbCoreMutex:// bMemstat - U8(1), - FbFullMutex:// bCoreMutex - (U8(libc.Bool32(1 == 1))), - FbOpenUri:// bFullMutex - U8(0), - FbUseCis:// bOpenUri - U8(1), - FbSmallMalloc:// bUseCis - U8(0), - FbExtraSchemaChecks:// bSmallMalloc - U8(1), - FmxStrlen:// bExtraSchemaChecks - 0x7ffffffe, - FneverCorrupt:// mxStrlen - 0, - FszLookaside:// neverCorrupt - 1200, - FnLookaside: 40, - FnStmtSpill:// szLookaside, nLookaside - (64 * 1024), // nStmtSpill - Fm:// nStmtSpill - Sqlite3_mem_methods{}, // m - Fmutex:// m - Sqlite3_mutex_methods{}, // mutex - Fpcache2:// mutex - Sqlite3_pcache_methods2{}, - FpHeap:// pcache2 - uintptr(0), - FnHeap:// pHeap - 0, - FmnReq:// nHeap - 0, - FmxReq: 0, - FszMmap:// mnHeap, mxHeap - int64(0), - FmxMmap:// szMmap - int64(0x7fff0000), - FpPage:// mxMmap - uintptr(0), - FszPage:// pPage - 0, - FnPage:// szPage - 20, - FmxParserStack:// nPage - 0, - FsharedCacheEnabled:// mxParserStack - 0, - FszPma:// sharedCacheEnabled - U32(250), - FisInit:// szPma - // All the rest should always be initialized to zero - 0, - FinProgress:// isInit - 0, - FisMutexInit:// inProgress - 0, - FisMallocInit:// isMutexInit - 0, - FisPCacheInit:// isMallocInit - 0, - FnRefInitMutex:// isPCacheInit - 0, - FpInitMutex:// nRefInitMutex - uintptr(0), - FxLog:// pInitMutex - uintptr(0), - FpLogArg:// xLog - uintptr(0), - FmxMemdbSize:// pLogArg - int64(1073741824), - FxTestCallback:// mxMemdbSize - uintptr(0), - FbLocaltimeFault:// xTestCallback - 0, - FiOnceResetThreshold:// bLocaltimeFault - 0x7ffffffe, - FszSorterRef:// iOnceResetThreshold - U32(0x7fffffff), - FiPrngSeed:// szSorterRef - uint32(0), // iPrngSeed +var Xsqlite3Config = Sqlite3Config{ // bMemstat + FbCoreMutex: U8(1), // bCoreMutex + FbFullMutex: (U8(libc.Bool32(SQLITE_THREADSAFE == 1))), // bOpenUri + FbUseCis: SQLITE_ALLOW_COVERING_INDEX_SCAN, // bSmallMalloc + FbExtraSchemaChecks: U8(1), // bExtraSchemaChecks + FmxStrlen: 0x7ffffffe, // neverCorrupt + FszLookaside: 1200, FnLookaside: 40, // szLookaside, nLookaside + FnStmtSpill: (64 * 1024), // szMmap + FmxMmap: SQLITE_MAX_MMAP_SIZE, // szPage + FnPage: SQLITE_DEFAULT_PCACHE_INITSZ, // sharedCacheEnabled + FszPma: SQLITE_SORTER_PMASZ, // pLogArg + FmxMemdbSize: SQLITE_MEMDB_DEFAULT_MAXSIZE, // bLocaltimeFault + FiOnceResetThreshold: 0x7ffffffe, // iOnceResetThreshold + FszSorterRef: SQLITE_DEFAULT_SORTERREF_SIZE, // iPrngSeed } /* sqlite3.c:20578:48 */ // Hash table for global functions - functions common to all @@ -11008,7 +10938,7 @@ func Xsqlite3_status64(tls *libc.TLS, op int32, pCurrent uintptr, pHighwater uin } Xsqlite3_mutex_leave(tls, pMutex) _ = pMutex // Prevent warning when SQLITE_THREADSAFE=0 - return 0 + return SQLITE_OK } func Xsqlite3_status(tls *libc.TLS, op int32, pCurrent uintptr, pHighwater uintptr, resetFlag int32) int32 { /* sqlite3.c:21477:16: */ @@ -11053,10 +10983,10 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p bp := tls.Alloc(12) defer tls.Free(12) - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) switch op { - case 0: + case SQLITE_DBSTATUS_LOOKASIDE_USED: { *(*int32)(unsafe.Pointer(pCurrent)) = Xsqlite3LookasideUsed(tls, db, pHighwater) if resetFlag != 0 { @@ -11083,17 +11013,17 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p } - case 4: + case SQLITE_DBSTATUS_LOOKASIDE_HIT: fallthrough - case 5: + case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: fallthrough - case 6: + case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: { *(*int32)(unsafe.Pointer(pCurrent)) = 0 - *(*int32)(unsafe.Pointer(pHighwater)) = int32(*(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr((op-4))*4))) + *(*int32)(unsafe.Pointer(pHighwater)) = int32(*(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr((op-SQLITE_DBSTATUS_LOOKASIDE_HIT))*4))) if resetFlag != 0 { - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr((op-4))*4)) = U32(0) + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr((op-SQLITE_DBSTATUS_LOOKASIDE_HIT))*4)) = U32(0) } break @@ -11102,9 +11032,9 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p // Return an approximation for the amount of memory currently used // by all pagers associated with the given database connection. The // highwater mark is meaningless and is returned as zero. - case 11: + case SQLITE_DBSTATUS_CACHE_USED_SHARED: fallthrough - case 1: + case SQLITE_DBSTATUS_CACHE_USED: { var totalUsed int32 = 0 var i int32 @@ -11114,7 +11044,7 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p if pBt != 0 { var pPager uintptr = Xsqlite3BtreePager(tls, pBt) var nByte int32 = Xsqlite3PagerMemUsed(tls, pPager) - if op == 11 { + if op == SQLITE_DBSTATUS_CACHE_USED_SHARED { nByte = (nByte / Xsqlite3BtreeConnectionCount(tls, pBt)) } totalUsed = totalUsed + (nByte) @@ -11130,7 +11060,7 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p // *pCurrent gets an accurate estimate of the amount of memory used // to store the schema for all databases (main, temp, and any ATTACHed // databases. *pHighwater is set to zero. - case 2: + case SQLITE_DBSTATUS_SCHEMA_USED: { var i int32 // Used to iterate through schemas *(*int32)(unsafe.Pointer(bp /* nByte */)) = 0 // Used to accumulate return value @@ -11171,7 +11101,7 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p // *pCurrent gets an accurate estimate of the amount of memory used // to store all prepared statements. // *pHighwater is set to zero. - case 3: + case SQLITE_DBSTATUS_STMT_USED: { var pVdbe uintptr // Used to iterate through VMs *(*int32)(unsafe.Pointer(bp + 4 /* nByte */)) = 0 // Used to accumulate return value @@ -11193,15 +11123,14 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p // Set *pCurrent to the total cache hits or misses encountered by all // pagers the database handle is connected to. *pHighwater is always set // to zero. - case 12: - op = (9 + 1) - /* no break */ + case SQLITE_DBSTATUS_CACHE_SPILL: + op = (SQLITE_DBSTATUS_CACHE_WRITE + 1) fallthrough - case 7: + case SQLITE_DBSTATUS_CACHE_HIT: fallthrough - case 8: + case SQLITE_DBSTATUS_CACHE_MISS: fallthrough - case 9: + case SQLITE_DBSTATUS_CACHE_WRITE: { var i int32 *(*int32)(unsafe.Pointer(bp + 8 /* nRet */)) = 0 @@ -11223,7 +11152,7 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p // Set *pCurrent to non-zero if there are unresolved deferred foreign // key constraints. Set *pCurrent to zero if all foreign key constraints // have been satisfied. The *pHighwater is always set to zero. - case 10: + case SQLITE_DBSTATUS_DEFERRED_FKS: { *(*int32)(unsafe.Pointer(pHighwater)) = 0 // IMP: R-11967-56545 *(*int32)(unsafe.Pointer(pCurrent)) = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons > int64(0)) || ((*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons > int64(0)))) @@ -11233,7 +11162,7 @@ func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, p default: { - rc = 1 + rc = SQLITE_ERROR } } @@ -11696,12 +11625,12 @@ func getDigits(tls *libc.TLS, zDate uintptr, zFormat uintptr, va uintptr) int32 cnt = 0 ap = va __1: - N = (int8(int32(*(*int8)(unsafe.Pointer(zFormat + uintptr(0)))) - '0')) - min = (int8(int32(*(*int8)(unsafe.Pointer(zFormat + uintptr(1)))) - '0')) + N = (int8(int32(*(*int8)(unsafe.Pointer(zFormat))) - '0')) + min = (int8(int32(*(*int8)(unsafe.Pointer(zFormat + 1))) - '0')) val = 0 - max = aMx[(int32(*(*int8)(unsafe.Pointer(zFormat + uintptr(2)))) - 'a')] - nextC = *(*int8)(unsafe.Pointer(zFormat + uintptr(3))) + max = aMx[(int32(*(*int8)(unsafe.Pointer(zFormat + 2))) - 'a')] + nextC = *(*int8)(unsafe.Pointer(zFormat + 3)) val = 0 __4: if !(libc.PostDecInt8(&N, 1) != 0) { @@ -11852,7 +11781,7 @@ func parseHhMmSs(tls *libc.TLS, zDate uintptr, p uintptr) int32 { /* sqlite3.c:2 return 1 } zDate += uintptr(2) - if (int32(*(*int8)(unsafe.Pointer(zDate))) == '.') && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zDate + uintptr(1))))]) & 0x04) != 0) { + if (int32(*(*int8)(unsafe.Pointer(zDate))) == '.') && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zDate + 1)))]) & 0x04) != 0) { var rScale float64 = 1.0 zDate++ for (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zDate)))]) & 0x04) != 0 { @@ -11961,7 +11890,7 @@ func parseYyyyMmDd(tls *libc.TLS, zDate uintptr, p uintptr) int32 { /* sqlite3.c var neg int32 - if int32(*(*int8)(unsafe.Pointer(zDate + uintptr(0)))) == '-' { + if int32(*(*int8)(unsafe.Pointer(zDate))) == '-' { zDate++ neg = 1 } else { @@ -12050,7 +11979,7 @@ func parseDateOrTime(tls *libc.TLS, context uintptr, zDate uintptr, p uintptr) i return 0 } else if (Xsqlite3StrICmp(tls, zDate, ts+402 /* "now" */) == 0) && (Xsqlite3NotPureFunc(tls, context) != 0) { return setDateTimeToCurrent(tls, context, p) - } else if Xsqlite3AtoF(tls, zDate, bp /* &r */, Xsqlite3Strlen30(tls, zDate), uint8(1)) > 0 { + } else if Xsqlite3AtoF(tls, zDate, bp /* &r */, Xsqlite3Strlen30(tls, zDate), SQLITE_UTF8) > 0 { setRawDateNumber(tls, p, *(*float64)(unsafe.Pointer(bp /* r */))) return 0 } @@ -12173,7 +12102,7 @@ func clearYMD_HMS_TZ(tls *libc.TLS, p uintptr) { /* sqlite3.c:22189:13: */ func osLocaltime(tls *libc.TLS, t uintptr, pTm uintptr) int32 { /* sqlite3.c:22227:12: */ var rc int32 var pX uintptr - var mutex uintptr = Xsqlite3MutexAlloc(tls, 2) + var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutex) pX = libc.Xlocaltime(tls, t) if Xsqlite3Config.FbLocaltimeFault != 0 { @@ -12231,7 +12160,7 @@ func localtimeOffset(tls *libc.TLS, p uintptr, pCtx uintptr, pRc uintptr) Sqlite *(*Time_t)(unsafe.Pointer(bp + 104 /* t */)) = (Time_t(((*DateTime)(unsafe.Pointer(bp+56 /* &x */)).FiJD / int64(1000)) - (int64(21086676) * int64(10000)))) if osLocaltime(tls, bp+104 /* &t */, bp /* &sLocal */) != 0 { Xsqlite3_result_error(tls, pCtx, ts+406 /* "local time unava..." */, -1) - *(*int32)(unsafe.Pointer(pRc)) = 1 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_ERROR return int64(0) } (*DateTime)(unsafe.Pointer(bp + 112 /* &y */)).FY = ((*tm)(unsafe.Pointer(bp /* &sLocal */)).Ftm_year + 1900) @@ -12247,7 +12176,7 @@ func localtimeOffset(tls *libc.TLS, p uintptr, pCtx uintptr, pRc uintptr) Sqlite (*DateTime)(unsafe.Pointer(bp + 112 /* &y */)).FvalidTZ = int8(0) (*DateTime)(unsafe.Pointer(bp + 112 /* &y */)).FisError = int8(0) computeJD(tls, bp+112 /* &y */) - *(*int32)(unsafe.Pointer(pRc)) = 0 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_OK return ((*DateTime)(unsafe.Pointer(bp+112 /* &y */)).FiJD - (*DateTime)(unsafe.Pointer(bp+56 /* &x */)).FiJD) } @@ -12265,42 +12194,12 @@ var aXformType = [6]struct { FrLimit float64 FrXform float64 }{ - { - FeType: U8(0), - FnName: U8(6), - FzName: ts + 429, /* "second" */ - FrLimit: 464269060800.0, - FrXform: 1000.0}, - { - FeType: U8(0), - FnName: U8(6), - FzName: ts + 436, /* "minute" */ - FrLimit: 7737817680.0, - FrXform: 60000.0}, - { - FeType: U8(0), - FnName: U8(4), - FzName: ts + 443, /* "hour" */ - FrLimit: 128963628.0, - FrXform: 3600000.0}, - { - FeType: U8(0), - FnName: U8(3), - FzName: ts + 448, /* "day" */ - FrLimit: 5373485.0, - FrXform: 86400000.0}, - { - FeType: U8(1), - FnName: U8(5), - FzName: ts + 452, /* "month" */ - FrLimit: 176546.0, - FrXform: 2592000000.0}, - { - FeType: U8(2), - FnName: U8(4), - FzName: ts + 458, /* "year" */ - FrLimit: 14713.0, - FrXform: 31536000000.0}, + {FnName: U8(6), FzName: ts + 429 /* "second" */, FrLimit: 464269060800.0, FrXform: 1000.0}, + {FnName: U8(6), FzName: ts + 436 /* "minute" */, FrLimit: 7737817680.0, FrXform: 60000.0}, + {FnName: U8(4), FzName: ts + 443 /* "hour" */, FrLimit: 128963628.0, FrXform: 3600000.0}, + {FnName: U8(3), FzName: ts + 448 /* "day" */, FrLimit: 5373485.0, FrXform: 86400000.0}, + {FeType: U8(1), FnName: U8(5), FzName: ts + 452 /* "month" */, FrLimit: 176546.0, FrXform: 2592000000.0}, + {FeType: U8(2), FnName: U8(4), FzName: ts + 458 /* "year" */, FrLimit: 14713.0, FrXform: 31536000000.0}, } /* sqlite3.c:22337:3 */ // Process a modifier to a date-time stamp. The modifiers are @@ -12332,7 +12231,7 @@ func parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr) i *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 // var r float64 at bp+8, 8 - switch int32(Xsqlite3UpperToLower[U8(*(*int8)(unsafe.Pointer(z + uintptr(0))))]) { + switch int32(Xsqlite3UpperToLower[U8(*(*int8)(unsafe.Pointer(z)))]) { case 'l': { // localtime @@ -12367,14 +12266,14 @@ func parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr) i var c1 Sqlite3_int64 computeJD(tls, p) c1 = localtimeOffset(tls, p, pCtx, bp /* &rc */) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*Sqlite3_int64)(unsafe.Pointer(p /* &.iJD */)) -= (c1) clearYMD_HMS_TZ(tls, p) *(*Sqlite3_int64)(unsafe.Pointer(p /* &.iJD */)) += (c1 - localtimeOffset(tls, p, pCtx, bp /* &rc */)) } (*DateTime)(unsafe.Pointer(p)).FtzSet = int8(1) } else { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK } } break @@ -12388,7 +12287,7 @@ func parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr) i // weekday N where 0==Sunday, 1==Monday, and so forth. If the // date is already on the appropriate weekday, this is a no-op. if ((((Xsqlite3_strnicmp(tls, z, ts+487 /* "weekday " */, 8) == 0) && - (Xsqlite3AtoF(tls, (z+uintptr(8)), bp+8 /* &r */, Xsqlite3Strlen30(tls, (z+uintptr(8))), uint8(1)) > 0)) && + (Xsqlite3AtoF(tls, (z+8), bp+8 /* &r */, Xsqlite3Strlen30(tls, (z+8)), SQLITE_UTF8) > 0)) && ((float64(libc.AssignInt32(&n, int32(*(*float64)(unsafe.Pointer(bp + 8 /* r */)))))) == *(*float64)(unsafe.Pointer(bp + 8 /* r */)))) && (n >= 0)) && (*(*float64)(unsafe.Pointer(bp + 8 /* r */)) < float64(7)) { var Z Sqlite3_int64 computeYMD_HMS(tls, p) @@ -12467,7 +12366,7 @@ func parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr) i var i int32 for n = 1; ((*(*int8)(unsafe.Pointer(z + uintptr(n))) != 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr(n)))) != ':')) && !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr(n))))]) & 0x01) != 0); n++ { } - if Xsqlite3AtoF(tls, z, bp+8 /* &r */, n, uint8(1)) <= 0 { + if Xsqlite3AtoF(tls, z, bp+8 /* &r */, n, SQLITE_UTF8) <= 0 { *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 break } @@ -12491,7 +12390,7 @@ func parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr) i *(*Sqlite3_int64)(unsafe.Pointer(bp + 16 /* &tx */ /* &.iJD */)) -= (int64(43200000)) day = ((*DateTime)(unsafe.Pointer(bp+16 /* &tx */)).FiJD / int64(86400000)) *(*Sqlite3_int64)(unsafe.Pointer(bp + 16 /* &tx */ /* &.iJD */)) -= (day * int64(86400000)) - if int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '-' { + if int32(*(*int8)(unsafe.Pointer(z))) == '-' { (*DateTime)(unsafe.Pointer(bp + 16 /* &tx */)).FiJD = -(*DateTime)(unsafe.Pointer(bp + 16 /* &tx */)).FiJD } computeJD(tls, p) @@ -12597,11 +12496,11 @@ func isDate(tls *libc.TLS, context uintptr, argc int32, argv uintptr, p uintptr) if argc == 0 { return setDateTimeToCurrent(tls, context, p) } - if ((libc.AssignInt32(&eType, Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) == 2) || - (eType == 1) { - setRawDateNumber(tls, p, Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + if ((libc.AssignInt32(&eType, Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))))) == SQLITE_FLOAT) || + (eType == SQLITE_INTEGER) { + setRawDateNumber(tls, p, Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))) } else { - z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if !(z != 0) || (parseDateOrTime(tls, context, z, p) != 0) { return 1 } @@ -12727,7 +12626,7 @@ func strftimeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* if argc == 0 { return } - zFmt = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zFmt = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if (zFmt == uintptr(0)) || (isDate(tls, context, (argc-1), (argv+uintptr(1)*8), bp+80 /* &x */) != 0) { return } @@ -12796,7 +12695,7 @@ __3: if n < U64(unsafe.Sizeof([100]int8{})) { z = bp + 128 /* &zBuf[0] */ - } else if n > U64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) { + } else if n > U64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) { Xsqlite3_result_error_toobig(tls, context) return } else { @@ -12958,87 +12857,14 @@ func Xsqlite3RegisterDateTimeFunctions(tls *libc.TLS) { /* sqlite3.c:22945:21: * } var aDateTimeFuncs = [8]FuncDef{ - { - FnArg: int8(-1), - FfuncFlags: (U32((0x2000 | 1) | 0x0800)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 594 /* "julianday" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x2000 | 1) | 0x0800)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 604 /* "date" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x2000 | 1) | 0x0800)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 609 /* "time" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x2000 | 1) | 0x0800)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 614 /* "datetime" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x2000 | 1) | 0x0800)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 623 /* "strftime" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 632 /* "current_time" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 645 /* "current_timestam..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 663 /* "current_date" */, Fu: struct{ FpHash uintptr }{}}, -} /* sqlite3.c:22946:18 */ + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_SLOCHNG | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FpUserData: 0, FxSFunc: 0, FzName: ts + 594 /* "julianday" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_SLOCHNG | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FpUserData: 0, FxSFunc: 0, FzName: ts + 604 /* "date" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_SLOCHNG | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FpUserData: 0, FxSFunc: 0, FzName: ts + 609 /* "time" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_SLOCHNG | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FpUserData: 0, FxSFunc: 0, FzName: ts + 614 /* "datetime" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_SLOCHNG | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FpUserData: 0, FxSFunc: 0, FzName: ts + 623 /* "strftime" */}, + {FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 632 /* "current_time" */}, + {FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 645 /* "current_timestam..." */}, + {FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 663 /* "current_date" */}} /* sqlite3.c:22946:18 */ //************* End of date.c *********************************************** //************* Begin file os.c ********************************************* @@ -13110,7 +12936,7 @@ func Xsqlite3OsRead(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset I if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(id != 0) || !(Xsqlite3JournalIsInMemory(tls, id) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } @@ -13122,7 +12948,7 @@ func Xsqlite3OsWrite(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(id != 0) || !(Xsqlite3JournalIsInMemory(tls, id) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } @@ -13138,7 +12964,7 @@ func Xsqlite3OsSync(tls *libc.TLS, id uintptr, flags int32) int32 { /* sqlite3.c if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(id != 0) || !(Xsqlite3JournalIsInMemory(tls, id) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } @@ -13146,14 +12972,14 @@ func Xsqlite3OsSync(tls *libc.TLS, id uintptr, flags int32) int32 { /* sqlite3.c if flags != 0 { return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods + 40 /* &.xSync */))))(tls, id, flags) } - return 0 + return SQLITE_OK } func Xsqlite3OsFileSize(tls *libc.TLS, id uintptr, pSize uintptr) int32 { /* sqlite3.c:23069:20: */ if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(id != 0) || !(Xsqlite3JournalIsInMemory(tls, id) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } @@ -13165,7 +12991,7 @@ func Xsqlite3OsLock(tls *libc.TLS, id uintptr, lockType int32) int32 { /* sqlite if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(id != 0) || !(Xsqlite3JournalIsInMemory(tls, id) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } @@ -13181,7 +13007,7 @@ func Xsqlite3OsCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(id != 0) || !(Xsqlite3JournalIsInMemory(tls, id) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } @@ -13197,10 +13023,10 @@ func Xsqlite3OsCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int // routine has no return value since the return value would be meaningless. func Xsqlite3OsFileControl(tls *libc.TLS, id uintptr, op int32, pArg uintptr) int32 { /* sqlite3.c:23093:20: */ if (*Sqlite3_file)(unsafe.Pointer(id)).FpMethods == uintptr(0) { - return 12 + return SQLITE_NOTFOUND } - if (op != 22) && - (op != 34) { + if (op != SQLITE_FCNTL_COMMIT_PHASETWO) && + (op != SQLITE_FCNTL_LOCK_TIMEOUT) { // Faults are not injected into COMMIT_PHASETWO because, assuming SQLite // is using a regular VFS, it is called after the corresponding // transaction has been committed. Injecting a fault at this point @@ -13214,7 +13040,7 @@ func Xsqlite3OsFileControl(tls *libc.TLS, id uintptr, op int32, pArg uintptr) in if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(id != 0) || !(Xsqlite3JournalIsInMemory(tls, id) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } @@ -13235,7 +13061,7 @@ func Xsqlite3OsSectorSize(tls *libc.TLS, id uintptr) int32 { /* sqlite3.c:23118: if xSectorSize != 0 { return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&xSectorSize)))(tls, id) } - return 4096 + return SQLITE_DEFAULT_SECTOR_SIZE }() } @@ -13259,7 +13085,7 @@ func Xsqlite3OsShmMap(tls *libc.TLS, id uintptr, iPage int32, pgsz int32, bExten if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(id != 0) || !(Xsqlite3JournalIsInMemory(tls, id) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } @@ -13272,7 +13098,7 @@ func Xsqlite3OsFetch(tls *libc.TLS, id uintptr, iOff I64, iAmt int32, pp uintptr if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(id != 0) || !(Xsqlite3JournalIsInMemory(tls, id) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } @@ -13291,7 +13117,7 @@ func Xsqlite3OsOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr, pFile uintptr, f if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(0 != 0) || !(Xsqlite3JournalIsInMemory(tls, uintptr(0)) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } @@ -13309,7 +13135,7 @@ func Xsqlite3OsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(0 != 0) || !(Xsqlite3JournalIsInMemory(tls, uintptr(0)) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } @@ -13321,7 +13147,7 @@ func Xsqlite3OsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, p if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(0 != 0) || !(Xsqlite3JournalIsInMemory(tls, uintptr(0)) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } @@ -13333,12 +13159,12 @@ func Xsqlite3OsFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nPathOut if (Xsqlite3_memdebug_vfs_oom_test != 0) && (!(0 != 0) || !(Xsqlite3JournalIsInMemory(tls, uintptr(0)) != 0)) { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } Xsqlite3_free(tls, pTstAlloc) } - *(*int8)(unsafe.Pointer(zPathOut + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(zPathOut)) = int8(0) return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pVfs + 64 /* &.xFullPathname */))))(tls, pVfs, zPath, nPathOut, zPathOut) } @@ -13365,7 +13191,7 @@ func Xsqlite3OsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uint nByte = int32(unsafe.Sizeof(uint32(0))) } libc.Xmemcpy(tls, zBufOut, (uintptr(unsafe.Pointer(&Xsqlite3Config)) + 420 /* &.iPrngSeed */), uint64(nByte)) - return 0 + return SQLITE_OK } else { return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pVfs + 104 /* &.xRandomness */))))(tls, pVfs, nByte, zBufOut) } @@ -13411,13 +13237,13 @@ func Xsqlite3OsOpenMalloc(tls *libc.TLS, pVfs uintptr, zFile uintptr, ppFile uin pFile = Xsqlite3MallocZero(tls, uint64((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)) if pFile != 0 { rc = Xsqlite3OsOpen(tls, pVfs, zFile, pFile, flags, pOutFlags) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_free(tls, pFile) } else { *(*uintptr)(unsafe.Pointer(ppFile)) = pFile } } else { - rc = 7 + rc = SQLITE_NOMEM } return rc } @@ -13435,7 +13261,7 @@ func Xsqlite3OsCloseFree(tls *libc.TLS, pFile uintptr) { /* sqlite3.c:23283:21: func Xsqlite3OsInit(tls *libc.TLS) int32 { /* sqlite3.c:23295:20: */ var p uintptr = Xsqlite3_malloc(tls, 10) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } Xsqlite3_free(tls, p) return Xsqlite3_os_init(tls) @@ -13453,7 +13279,7 @@ func Xsqlite3_vfs_find(tls *libc.TLS, zVfs uintptr) uintptr { /* sqlite3.c:23312 if rc != 0 { return uintptr(0) } - mutex = Xsqlite3MutexAlloc(tls, 2) + mutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutex) for pVfs = vfsList; pVfs != 0; pVfs = (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext { if zVfs == uintptr(0) { @@ -13495,7 +13321,7 @@ func Xsqlite3_vfs_register(tls *libc.TLS, pVfs uintptr, makeDflt int32) int32 { return rc } - mutex = Xsqlite3MutexAlloc(tls, 2) + mutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutex) vfsUnlink(tls, pVfs) if (makeDflt != 0) || (vfsList == uintptr(0)) { @@ -13507,7 +13333,7 @@ func Xsqlite3_vfs_register(tls *libc.TLS, pVfs uintptr, makeDflt int32) int32 { } Xsqlite3_mutex_leave(tls, mutex) - return 0 + return SQLITE_OK } // Unregister a VFS so that it is no longer accessible. @@ -13517,11 +13343,11 @@ func Xsqlite3_vfs_unregister(tls *libc.TLS, pVfs uintptr) int32 { /* sqlite3.c:2 if rc != 0 { return rc } - mutex = Xsqlite3MutexAlloc(tls, 2) + mutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutex) vfsUnlink(tls, pVfs) Xsqlite3_mutex_leave(tls, mutex) - return 0 + return SQLITE_OK } //************* End of os.c ************************************************* @@ -13720,11 +13546,11 @@ func sqlite3MemMalloc(tls *libc.TLS, nByte int32) uintptr { /* sqlite3.c:23680:1 p = libc.Xmalloc(tls, (uint64(nByte + 8))) if p != 0 { - *(*Sqlite3_int64)(unsafe.Pointer(p + uintptr(0)*8)) = Sqlite3_int64(nByte) + *(*Sqlite3_int64)(unsafe.Pointer(p)) = Sqlite3_int64(nByte) p += 8 } else { - Xsqlite3_log(tls, 7, ts+676 /* "failed to alloca..." */, libc.VaList(bp, nByte)) + Xsqlite3_log(tls, SQLITE_NOMEM, ts+676 /* "failed to alloca..." */, libc.VaList(bp, nByte)) } return p } @@ -13749,7 +13575,7 @@ func sqlite3MemSize(tls *libc.TLS, pPrior uintptr) int32 { /* sqlite3.c:23729:12 p = pPrior p -= 8 - return int32(*(*Sqlite3_int64)(unsafe.Pointer(p + uintptr(0)*8))) + return int32(*(*Sqlite3_int64)(unsafe.Pointer(p))) } // Like realloc(). Resize an allocation previously obtained from @@ -13770,11 +13596,11 @@ func sqlite3MemRealloc(tls *libc.TLS, pPrior uintptr, nByte int32) uintptr { /* p -= 8 p = libc.Xrealloc(tls, p, (uint64(nByte + 8))) if p != 0 { - *(*Sqlite3_int64)(unsafe.Pointer(p + uintptr(0)*8)) = Sqlite3_int64(nByte) + *(*Sqlite3_int64)(unsafe.Pointer(p)) = Sqlite3_int64(nByte) p += 8 } else { - Xsqlite3_log(tls, 7, + Xsqlite3_log(tls, SQLITE_NOMEM, ts+714, /* "failed memory re..." */ libc.VaList(bp, sqlite3MemSize(tls, pPrior), nByte)) } @@ -13783,13 +13609,13 @@ func sqlite3MemRealloc(tls *libc.TLS, pPrior uintptr, nByte int32) uintptr { /* // Round up a request size to the next valid allocation size. func sqlite3MemRoundup(tls *libc.TLS, n int32) int32 { /* sqlite3.c:23784:12: */ - return (((n) + 7) & ^libc.Int32(7)) + return (((n) + 7) & libc.CplInt32(7)) } // Initialize this module. func sqlite3MemInit(tls *libc.TLS, NotUsed uintptr) int32 { /* sqlite3.c:23791:12: */ _ = NotUsed - return 0 + return SQLITE_OK } // Deinitialize this module. @@ -13806,7 +13632,7 @@ func Xsqlite3MemSetDefault(tls *libc.TLS) { /* sqlite3.c:23829:21: */ bp := tls.Alloc(8) defer tls.Free(8) - Xsqlite3_config(tls, 4, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultMethods)))) + Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultMethods)))) } var defaultMethods = Sqlite3_mem_methods{ @@ -13817,7 +13643,6 @@ var defaultMethods = Sqlite3_mem_methods{ FxRoundup: 0, FxInit: 0, FxShutdown: 0, - FpAppData: uintptr(0), } /* sqlite3.c:23830:36 */ //************* End of mem1.c *********************************************** @@ -13953,7 +13778,7 @@ var defaultMethods = Sqlite3_mem_methods{ // Initialize the mutex system. func Xsqlite3MutexInit(tls *libc.TLS) int32 { /* sqlite3.c:25865:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if !(int32(Xsqlite3Config.Fmutex.FxMutexAlloc) != 0) { // If the xMutexAlloc method has not been set, then the user did not // install a mutex implementation via sqlite3_config() prior to @@ -13987,7 +13812,7 @@ func Xsqlite3MutexInit(tls *libc.TLS) int32 { /* sqlite3.c:25865:20: */ // Shutdown the mutex system. This call frees resources allocated by // sqlite3MutexInit(). func Xsqlite3MutexEnd(tls *libc.TLS) int32 { /* sqlite3.c:25911:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if Xsqlite3Config.Fmutex.FxMutexEnd != 0 { rc = (*(*func(*libc.TLS) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 96 /* &.mutex */ + 8 /* &.xMutexEnd */))))(tls) } @@ -13997,10 +13822,10 @@ func Xsqlite3MutexEnd(tls *libc.TLS) int32 { /* sqlite3.c:25911:20: */ // Retrieve a pointer to a static mutex or allocate a new dynamic one. func Xsqlite3_mutex_alloc(tls *libc.TLS, id int32) uintptr { /* sqlite3.c:25927:26: */ - if (id <= 1) && (Xsqlite3_initialize(tls) != 0) { + if (id <= SQLITE_MUTEX_RECURSIVE) && (Xsqlite3_initialize(tls) != 0) { return uintptr(0) } - if (id > 1) && (Xsqlite3MutexInit(tls) != 0) { + if (id > SQLITE_MUTEX_RECURSIVE) && (Xsqlite3MutexInit(tls) != 0) { return uintptr(0) } @@ -14035,7 +13860,7 @@ func Xsqlite3_mutex_enter(tls *libc.TLS, p uintptr) { /* sqlite3.c:25959:17: */ // Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another // thread holds the mutex and it cannot be obtained, return SQLITE_BUSY. func Xsqlite3_mutex_try(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:25970:16: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if p != 0 { return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 96 /* &.mutex */ + 40 /* &.xMutexTry */))))(tls, p) @@ -14087,11 +13912,11 @@ func Xsqlite3_mutex_leave(tls *libc.TLS, p uintptr) { /* sqlite3.c:25985:17: */ // // This routines provide no mutual exclusion or error checking. func noopMutexInit(tls *libc.TLS) int32 { /* sqlite3.c:26048:12: */ - return 0 + return SQLITE_OK } func noopMutexEnd(tls *libc.TLS) int32 { /* sqlite3.c:26049:12: */ - return 0 + return SQLITE_OK } func noopMutexAlloc(tls *libc.TLS, id int32) uintptr { /* sqlite3.c:26050:22: */ @@ -14111,7 +13936,7 @@ func noopMutexEnter(tls *libc.TLS, p uintptr) { /* sqlite3.c:26055:13: */ func noopMutexTry(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:26056:12: */ _ = p - return 0 + return SQLITE_OK } func noopMutexLeave(tls *libc.TLS, p uintptr) { /* sqlite3.c:26060:13: */ @@ -14125,15 +13950,13 @@ func Xsqlite3NoopMutex(tls *libc.TLS) uintptr { /* sqlite3.c:26062:44: */ } var sMutex = Sqlite3_mutex_methods{ - FxMutexInit: 0, - FxMutexEnd: 0, - FxMutexAlloc: 0, - FxMutexFree: 0, - FxMutexEnter: 0, - FxMutexTry: 0, - FxMutexLeave: 0, - FxMutexHeld: uintptr(0), - FxMutexNotheld: uintptr(0), + FxMutexInit: 0, + FxMutexEnd: 0, + FxMutexAlloc: 0, + FxMutexFree: 0, + FxMutexEnter: 0, + FxMutexTry: 0, + FxMutexLeave: 0, } /* sqlite3.c:26063:38 */ // If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation @@ -14233,7 +14056,7 @@ func Xsqlite3_memory_alarm(tls *libc.TLS, xCallback uintptr, pArg uintptr, iThre _ = xCallback _ = pArg _ = iThreshold - return 0 + return SQLITE_OK } // Set the soft heap-size limit for the library. An argument of @@ -14263,7 +14086,7 @@ func Xsqlite3_soft_heap_limit64(tls *libc.TLS, n Sqlite3_int64) Sqlite3_int64 { n = mem0.FhardLimit } mem0.FalarmThreshold = n - nUsed = Xsqlite3StatusValue(tls, 0) + nUsed = Xsqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED) libc.AtomicStoreNInt32((uintptr(unsafe.Pointer(&mem0)) + 24 /* &.nearlyFull */), int32((libc.Bool32((n > int64(0)) && (n <= nUsed)))), 0) Xsqlite3_mutex_leave(tls, mem0.Fmutex) excess = (Xsqlite3_memory_used(tls) - n) @@ -14315,14 +14138,14 @@ func Xsqlite3MallocInit(tls *libc.TLS) int32 { /* sqlite3.c:27476:20: */ Xsqlite3MemSetDefault(tls) } libc.Xmemset(tls, uintptr(unsafe.Pointer(&mem0)), 0, uint64(unsafe.Sizeof(mem0))) - mem0.Fmutex = Xsqlite3MutexAlloc(tls, 3) + mem0.Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MEM) if ((Xsqlite3Config.FpPage == uintptr(0)) || (Xsqlite3Config.FszPage < 512)) || (Xsqlite3Config.FnPage <= 0) { Xsqlite3Config.FpPage = uintptr(0) Xsqlite3Config.FszPage = 0 } rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 32 /* &.m */ + 40 /* &.xInit */))))(tls, Xsqlite3Config.Fm.FpAppData) - if rc != 0 { + if rc != SQLITE_OK { libc.Xmemset(tls, uintptr(unsafe.Pointer(&mem0)), 0, uint64(unsafe.Sizeof(mem0))) } return rc @@ -14352,7 +14175,7 @@ func Xsqlite3_memory_used(tls *libc.TLS) Sqlite3_int64 { /* sqlite3.c:27515:26: // var mx Sqlite3_int64 at bp+8, 8 - Xsqlite3_status64(tls, 0, bp /* &res */, bp+8 /* &mx */, 0) + Xsqlite3_status64(tls, SQLITE_STATUS_MEMORY_USED, bp /* &res */, bp+8 /* &mx */, 0) return *(*Sqlite3_int64)(unsafe.Pointer(bp /* res */)) } @@ -14367,7 +14190,7 @@ func Xsqlite3_memory_highwater(tls *libc.TLS, resetFlag int32) Sqlite3_int64 { / // var mx Sqlite3_int64 at bp+8, 8 - Xsqlite3_status64(tls, 0, bp /* &res */, bp+8 /* &mx */, resetFlag) + Xsqlite3_status64(tls, SQLITE_STATUS_MEMORY_USED, bp /* &res */, bp+8 /* &mx */, resetFlag) return *(*Sqlite3_int64)(unsafe.Pointer(bp + 8 /* mx */)) } @@ -14394,14 +14217,14 @@ func mallocWithAlarm(tls *libc.TLS, n int32, pp uintptr) { /* sqlite3.c:27546:13 // following xRoundup() call. nFull = (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 32 /* &.m */ + 32 /* &.xRoundup */))))(tls, n) - Xsqlite3StatusHighwater(tls, 5, n) + Xsqlite3StatusHighwater(tls, SQLITE_STATUS_MALLOC_SIZE, n) if mem0.FalarmThreshold > int64(0) { - var nUsed Sqlite3_int64 = Xsqlite3StatusValue(tls, 0) + var nUsed Sqlite3_int64 = Xsqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED) if nUsed >= (mem0.FalarmThreshold - Sqlite3_int64(nFull)) { libc.AtomicStoreNInt32((uintptr(unsafe.Pointer(&mem0)) + 24 /* &.nearlyFull */), int32(1), 0) sqlite3MallocAlarm(tls, nFull) if mem0.FhardLimit != 0 { - nUsed = Xsqlite3StatusValue(tls, 0) + nUsed = Xsqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED) if nUsed >= (mem0.FhardLimit - Sqlite3_int64(nFull)) { *(*uintptr)(unsafe.Pointer(pp)) = uintptr(0) return @@ -14418,8 +14241,8 @@ func mallocWithAlarm(tls *libc.TLS, n int32, pp uintptr) { /* sqlite3.c:27546:13 } if p != 0 { nFull = Xsqlite3MallocSize(tls, p) - Xsqlite3StatusUp(tls, 0, nFull) - Xsqlite3StatusUp(tls, 9, 1) + Xsqlite3StatusUp(tls, SQLITE_STATUS_MEMORY_USED, nFull) + Xsqlite3StatusUp(tls, SQLITE_STATUS_MALLOC_COUNT, 1) } *(*uintptr)(unsafe.Pointer(pp)) = p } @@ -14486,7 +14309,7 @@ func lookasideMallocSize(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite if p < (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle { return int32((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) } - return 128 + return LOOKASIDE_SMALL } func Xsqlite3DbMallocSize(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:27659:20: */ @@ -14495,7 +14318,7 @@ func Xsqlite3DbMallocSize(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlit if (Uptr(p)) < Uptr(((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd)) { if (Uptr(p)) >= Uptr(((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle)) { - return 128 + return LOOKASIDE_SMALL } if (Uptr(p)) >= Uptr(((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart)) { @@ -14522,8 +14345,8 @@ func Xsqlite3_free(tls *libc.TLS, p uintptr) { /* sqlite3.c:27697:17: */ if Xsqlite3Config.FbMemstat != 0 { Xsqlite3_mutex_enter(tls, mem0.Fmutex) - Xsqlite3StatusDown(tls, 0, Xsqlite3MallocSize(tls, p)) - Xsqlite3StatusDown(tls, 9, 1) + Xsqlite3StatusDown(tls, SQLITE_STATUS_MEMORY_USED, Xsqlite3MallocSize(tls, p)) + Xsqlite3StatusDown(tls, SQLITE_STATUS_MALLOC_COUNT, 1) (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 32 /* &.m */ + 8 /* &.xFree */))))(tls, p) Xsqlite3_mutex_leave(tls, mem0.Fmutex) } else { @@ -14600,9 +14423,9 @@ func Xsqlite3Realloc(tls *libc.TLS, pOld uintptr, nBytes U64) uintptr { /* sqlit pNew = pOld } else if Xsqlite3Config.FbMemstat != 0 { Xsqlite3_mutex_enter(tls, mem0.Fmutex) - Xsqlite3StatusHighwater(tls, 5, int32(nBytes)) + Xsqlite3StatusHighwater(tls, SQLITE_STATUS_MALLOC_SIZE, int32(nBytes)) nDiff = (nNew - nOld) - if (nDiff > 0) && (Xsqlite3StatusValue(tls, 0) >= (mem0.FalarmThreshold - Sqlite3_int64(nDiff))) { + if (nDiff > 0) && (Xsqlite3StatusValue(tls, SQLITE_STATUS_MEMORY_USED) >= (mem0.FalarmThreshold - Sqlite3_int64(nDiff))) { sqlite3MallocAlarm(tls, nDiff) } pNew = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 32 /* &.m */ + 16 /* &.xRealloc */))))(tls, pOld, nNew) @@ -14612,7 +14435,7 @@ func Xsqlite3Realloc(tls *libc.TLS, pOld uintptr, nBytes U64) uintptr { /* sqlit } if pNew != 0 { nNew = Xsqlite3MallocSize(tls, pNew) - Xsqlite3StatusUp(tls, 0, (nNew - nOld)) + Xsqlite3StatusUp(tls, SQLITE_STATUS_MEMORY_USED, (nNew - nOld)) } Xsqlite3_mutex_leave(tls, mem0.Fmutex) } else { @@ -14710,33 +14533,33 @@ func Xsqlite3DbMallocRawNN(tls *libc.TLS, db uintptr, n U64) uintptr { /* sqlite if n > U64((*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz) { if !(int32((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable) != 0) { - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr(1)*4))++ + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + 1*4))++ } else if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { return uintptr(0) } return dbMallocRawFinish(tls, db, n) } - if n <= uint64(128) { + if n <= LOOKASIDE_SMALL { if (libc.AssignUintptr(&pBuf, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree)) != uintptr(0) { (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallFree = (*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr(0)*4))++ + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */)))++ return pBuf } else if (libc.AssignUintptr(&pBuf, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit)) != uintptr(0) { (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = (*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr(0)*4))++ + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */)))++ return pBuf } } if (libc.AssignUintptr(&pBuf, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree)) != uintptr(0) { (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpFree = (*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr(0)*4))++ + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */)))++ return pBuf } else if (libc.AssignUintptr(&pBuf, (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpInit)) != uintptr(0) { (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpInit = (*LookasideSlot)(unsafe.Pointer(pBuf)).FpNext - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr(0)*4))++ + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */)))++ return pBuf } else { - *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + uintptr(2)*4))++ + *(*U32)(unsafe.Pointer((db + 400 /* &.lookaside */ + 16 /* &.anStat */) + 2*4))++ } return dbMallocRawFinish(tls, db, n) } @@ -14751,7 +14574,7 @@ func Xsqlite3DbRealloc(tls *libc.TLS, db uintptr, p uintptr, n U64) uintptr { /* if (Uptr(p)) < Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd) { if (Uptr(p)) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpMiddle) { - if n <= uint64(128) { + if n <= LOOKASIDE_SMALL { return p } } else if (Uptr(p)) >= Uptr((*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpStart) { @@ -14835,7 +14658,7 @@ func Xsqlite3DbStrNDup(tls *libc.TLS, db uintptr, z uintptr, n U64) uintptr { /* // sqlite3DbMalloc(). Omit leading and trailing whitespace. func Xsqlite3DbSpanDup(tls *libc.TLS, db uintptr, zStart uintptr, zEnd uintptr) uintptr { /* sqlite3.c:28054:21: */ var n int32 - for (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zStart + uintptr(0))))]) & 0x01) != 0 { + for (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zStart)))]) & 0x01) != 0 { zStart++ } n = (int32((int64(zEnd) - int64(zStart)) / 1)) @@ -14864,7 +14687,7 @@ func Xsqlite3OomFault(tls *libc.TLS, db uintptr) { /* sqlite3.c:28076:21: */ (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable++ (*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0) if (*Sqlite3)(unsafe.Pointer(db)).FpParse != 0 { - (*Parse)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpParse)).Frc = 7 + (*Parse)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpParse)).Frc = SQLITE_NOMEM } } } @@ -14892,8 +14715,8 @@ func Xsqlite3OomClear(tls *libc.TLS, db uintptr) { /* sqlite3.c:28096:21: */ // Take actions at the end of an API call to indicate an OOM error func apiOomError(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:28108:28: */ Xsqlite3OomClear(tls, db) - Xsqlite3Error(tls, db, 7) - return 7 + Xsqlite3Error(tls, db, SQLITE_NOMEM) + return SQLITE_NOMEM } // This function must be called before exiting any API function (i.e. @@ -14911,7 +14734,7 @@ func Xsqlite3ApiExit(tls *libc.TLS, db uintptr, rc int32) int32 { /* sqlite3.c:2 // Otherwise the read (and possible write) of db->mallocFailed // is unsafe, as is the call to sqlite3Error(). - if ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) || (rc == (10 | (int32(12) << 8))) { + if ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) || (rc == (SQLITE_IOERR | (int32(12) << 8))) { return apiOomError(tls, db) } return (rc & (*Sqlite3)(unsafe.Pointer(db)).FerrMask) @@ -14959,169 +14782,31 @@ type Et_info = et_info /* sqlite3.c:28197:3 */ var aDigits = *(*[33]int8)(unsafe.Pointer(ts + 750 /* "0123456789ABCDEF..." */)) /* sqlite3.c:28210:19 */ var aPrefix = *(*[7]int8)(unsafe.Pointer(ts + 783 /* "-x0\x00X0" */)) /* sqlite3.c:28211:19 */ var fmtinfo = [23]Et_info{ - { - Ffmttype: int8('d'), - Fbase: EtByte(10), - Fflags: EtByte(1), - Ftype: EtByte(16), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('s'), - Fbase: EtByte(0), - Fflags: EtByte(4), - Ftype: EtByte(5), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('g'), - Fbase: EtByte(0), - Fflags: EtByte(1), - Ftype: EtByte(3), - Fcharset: EtByte(30), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('z'), - Fbase: EtByte(0), - Fflags: EtByte(4), - Ftype: EtByte(6), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('q'), - Fbase: EtByte(0), - Fflags: EtByte(4), - Ftype: EtByte(9), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('Q'), - Fbase: EtByte(0), - Fflags: EtByte(4), - Ftype: EtByte(10), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('w'), - Fbase: EtByte(0), - Fflags: EtByte(4), - Ftype: EtByte(14), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('c'), - Fbase: EtByte(0), - Fflags: EtByte(0), - Ftype: EtByte(8), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('o'), - Fbase: EtByte(8), - Fflags: EtByte(0), - Ftype: EtByte(0), - Fcharset: EtByte(0), - Fprefix: EtByte(2)}, - { - Ffmttype: int8('u'), - Fbase: EtByte(10), - Fflags: EtByte(0), - Ftype: EtByte(16), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('x'), - Fbase: EtByte(16), - Fflags: EtByte(0), - Ftype: EtByte(0), - Fcharset: EtByte(16), - Fprefix: EtByte(1)}, - { - Ffmttype: int8('X'), - Fbase: EtByte(16), - Fflags: EtByte(0), - Ftype: EtByte(0), - Fcharset: EtByte(0), - Fprefix: EtByte(4)}, - { - Ffmttype: int8('f'), - Fbase: EtByte(0), - Fflags: EtByte(1), - Ftype: EtByte(1), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('e'), - Fbase: EtByte(0), - Fflags: EtByte(1), - Ftype: EtByte(2), - Fcharset: EtByte(30), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('E'), - Fbase: EtByte(0), - Fflags: EtByte(1), - Ftype: EtByte(2), - Fcharset: EtByte(14), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('G'), - Fbase: EtByte(0), - Fflags: EtByte(1), - Ftype: EtByte(3), - Fcharset: EtByte(14), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('i'), - Fbase: EtByte(10), - Fflags: EtByte(1), - Ftype: EtByte(16), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('n'), - Fbase: EtByte(0), - Fflags: EtByte(0), - Ftype: EtByte(4), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('%'), - Fbase: EtByte(0), - Fflags: EtByte(0), - Ftype: EtByte(7), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('p'), - Fbase: EtByte(16), - Fflags: EtByte(0), - Ftype: EtByte(13), - Fcharset: EtByte(0), - Fprefix: EtByte(1)}, + {Ffmttype: int8('d'), Fbase: EtByte(10), Fflags: EtByte(1), Ftype: EtDECIMAL}, + {Ffmttype: int8('s'), Fflags: EtByte(4), Ftype: EtSTRING}, + {Ffmttype: int8('g'), Fflags: EtByte(1), Ftype: EtGENERIC, Fcharset: EtByte(30)}, + {Ffmttype: int8('z'), Fflags: EtByte(4), Ftype: EtDYNSTRING}, + {Ffmttype: int8('q'), Fflags: EtByte(4), Ftype: EtSQLESCAPE}, + {Ffmttype: int8('Q'), Fflags: EtByte(4), Ftype: EtSQLESCAPE2}, + {Ffmttype: int8('w'), Fflags: EtByte(4), Ftype: EtSQLESCAPE3}, + {Ffmttype: int8('c'), Ftype: EtCHARX}, + {Ffmttype: int8('o'), Fbase: EtByte(8), Fprefix: EtByte(2)}, + {Ffmttype: int8('u'), Fbase: EtByte(10), Ftype: EtDECIMAL}, + {Ffmttype: int8('x'), Fbase: EtByte(16), Fcharset: EtByte(16), Fprefix: EtByte(1)}, + {Ffmttype: int8('X'), Fbase: EtByte(16), Fprefix: EtByte(4)}, + {Ffmttype: int8('f'), Fflags: EtByte(1), Ftype: EtFLOAT}, + {Ffmttype: int8('e'), Fflags: EtByte(1), Ftype: EtEXP, Fcharset: EtByte(30)}, + {Ffmttype: int8('E'), Fflags: EtByte(1), Ftype: EtEXP, Fcharset: EtByte(14)}, + {Ffmttype: int8('G'), Fflags: EtByte(1), Ftype: EtGENERIC, Fcharset: EtByte(14)}, + {Ffmttype: int8('i'), Fbase: EtByte(10), Fflags: EtByte(1), Ftype: EtDECIMAL}, + {Ffmttype: int8('n'), Ftype: EtSIZE}, + {Ffmttype: int8('%'), Ftype: EtPERCENT}, + {Ffmttype: int8('p'), Fbase: EtByte(16), Ftype: EtPOINTER, Fprefix: EtByte(1)}, // All the rest are undocumented and are for internal use only - { - Ffmttype: int8('T'), - Fbase: EtByte(0), - Fflags: EtByte(0), - Ftype: EtByte(11), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('S'), - Fbase: EtByte(0), - Fflags: EtByte(0), - Ftype: EtByte(12), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, - { - Ffmttype: int8('r'), - Fbase: EtByte(10), - Fflags: EtByte(1), - Ftype: EtByte(15), - Fcharset: EtByte(0), - Fprefix: EtByte(0)}, + {Ffmttype: int8('T'), Ftype: EtTOKEN}, + {Ffmttype: int8('S'), Ftype: EtSRCLIST}, + {Ffmttype: int8('r'), Fbase: EtByte(10), Fflags: EtByte(1), Ftype: EtORDINAL}, } /* sqlite3.c:28212:22 */ // Floating point constants used for rounding @@ -15164,7 +14849,7 @@ func setStrAccumError(tls *libc.TLS, p uintptr, eError U8) { /* sqlite3.c:28282: if (*StrAccum)(unsafe.Pointer(p)).FmxAlloc != 0 { Xsqlite3_str_reset(tls, p) } - if int32(eError) == 18 { + if int32(eError) == SQLITE_TOOBIG { Xsqlite3ErrorToParser(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, int32(eError)) } } @@ -15204,12 +14889,12 @@ func printfTempBuf(tls *libc.TLS, pAccum uintptr, n Sqlite3_int64) uintptr { /* return uintptr(0) } if (n > Sqlite3_int64((*Sqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc)) && (n > Sqlite3_int64((*Sqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc)) { - setStrAccumError(tls, pAccum, uint8(18)) + setStrAccumError(tls, pAccum, SQLITE_TOOBIG) return uintptr(0) } z = Xsqlite3DbMallocRaw(tls, (*Sqlite3_str)(unsafe.Pointer(pAccum)).Fdb, uint64(n)) if z == uintptr(0) { - setStrAccumError(tls, pAccum, uint8(7)) + setStrAccumError(tls, pAccum, SQLITE_NOMEM) } return z } @@ -15297,7 +14982,7 @@ func Xsqlite3_str_vappendf(tls *libc.TLS, pAccum uintptr, fmt uintptr, ap Va_lis var pSrc uintptr var k1 int32 var pItem uintptr - xtype = EtByte(17) + xtype = EtINVALID zExtra = uintptr(0) pArgList = uintptr(0) // Conversion buffer @@ -15306,7 +14991,7 @@ func Xsqlite3_str_vappendf(tls *libc.TLS, pAccum uintptr, fmt uintptr, ap Va_lis // optimization. bufpt = uintptr(0) - if !((int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags) & 0x02) != 0) { + if !((int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags) & SQLITE_PRINTF_SQLFUNC) != 0) { goto __1 } pArgList = libc.VaUintptr(&ap) @@ -15489,7 +15174,7 @@ __42: } __43: ; - if !(((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(fmt + uintptr(1)))))) != '.') && (c != 'l')) { + if !(((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(fmt + 1))))) != '.') && (c != 'l')) { goto __44 } c = int32(*(*int8)(unsafe.Pointer(libc.PreIncUintptr(&fmt, 1)))) @@ -15562,8 +15247,8 @@ __14: ; // Fetch the info entry for the field - infop = (uintptr(unsafe.Pointer(&fmtinfo)) + uintptr(0)*6) - xtype = EtByte(17) + infop = (uintptr(unsafe.Pointer(&fmtinfo))) + xtype = EtINVALID idx = 0 __54: if !(idx < (int32(uint64(unsafe.Sizeof(fmtinfo)) / uint64(unsafe.Sizeof(Et_info{}))))) { @@ -15602,39 +15287,39 @@ __56: // infop Pointer to the appropriate info struct. switch int32(xtype) { - case 13: + case EtPOINTER: goto __59 - case 15: + case EtORDINAL: goto __60 - case 0: + case EtRADIX: goto __61 - case 16: + case EtDECIMAL: goto __62 - case 1: + case EtFLOAT: goto __63 - case 2: + case EtEXP: goto __64 - case 3: + case EtGENERIC: goto __65 - case 4: + case EtSIZE: goto __66 - case 7: + case EtPERCENT: goto __67 - case 8: + case EtCHARX: goto __68 - case 5: + case EtSTRING: goto __69 - case 6: + case EtDYNSTRING: goto __70 - case 9: + case EtSQLESCAPE: goto __71 // %q: Escape ' characters - case 10: + case EtSQLESCAPE2: goto __72 // %Q: Escape ' and enclose in '...' - case 14: + case EtSQLESCAPE3: goto __73 - case 11: + case EtTOKEN: goto __74 - case 12: + case EtSRCLIST: goto __75 default: goto __76 @@ -15650,13 +15335,11 @@ __59: flag_long = uint8(0) } } - /* no break */ __60: __61: cThousand = EtByte(0) - /* no break */ __62: - if !((int32((*Et_info)(unsafe.Pointer(infop)).Fflags) & 1) != 0) { + if !((int32((*Et_info)(unsafe.Pointer(infop)).Fflags) & FLAG_SIGNED) != 0) { goto __77 } if !(bArgList != 0) { @@ -15745,10 +15428,10 @@ __95: precision = (width - (libc.Bool32(int32(prefix) != 0))) __96: ; - if !(precision < ((70 - 10) - (70 / 3))) { + if !(precision < ((SQLITE_PRINT_BUF_SIZE - 10) - (SQLITE_PRINT_BUF_SIZE / 3))) { goto __97 } - nOut = 70 + nOut = SQLITE_PRINT_BUF_SIZE zOut = bp /* &buf[0] */ goto __98 __97: @@ -15770,7 +15453,7 @@ __100: __98: ; bufpt = (zOut + uintptr((nOut - 1))) - if !(int32(xtype) == 15) { + if !(int32(xtype) == EtORDINAL) { goto __101 } x = (int32(longvalue % uint64(10))) @@ -15883,10 +15566,10 @@ __119: precision = 6 __120: ; // Set default precision - if !(precision > 100000000) { + if !(precision > SQLITE_FP_PRECISION_LIMIT) { goto __121 } - precision = 100000000 + precision = SQLITE_FP_PRECISION_LIMIT __121: ; if !(*(*float64)(unsafe.Pointer(bp + 88 /* realvalue */)) < 0.0) { @@ -15899,7 +15582,7 @@ __122: prefix = int8(flag_prefix) __123: ; - if !((int32(xtype) == 3) && (precision > 0)) { + if !((int32(xtype) == EtGENERIC) && (precision > 0)) { goto __124 } precision-- @@ -15917,7 +15600,7 @@ __125: goto __125 __126: ; - if !(int32(xtype) == 1) { + if !(int32(xtype) == EtFLOAT) { goto __127 } *(*float64)(unsafe.Pointer(bp + 80 /* rx */)) = *(*float64)(unsafe.Pointer(bp + 88 /* realvalue */)) @@ -15996,7 +15679,7 @@ __140: goto __141 } bufpt = bp /* &buf[0] */ - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = prefix + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = prefix libc.Xmemcpy(tls, (bp /* &buf[0] */ + uintptr((libc.Bool32(int32(prefix) != 0)))), ts+796 /* "Inf" */, uint64(4)) length = (3 + (libc.Bool32(int32(prefix) != 0))) goto __58 @@ -16007,7 +15690,7 @@ __130: bufpt = bp /* &buf[0] */ // If the field type is etGENERIC, then convert to either etEXP // or etFLOAT, as appropriate. - if !(int32(xtype) != 1) { + if !(int32(xtype) != EtFLOAT) { goto __142 } *(*float64)(unsafe.Pointer(bp + 88 /* realvalue */)) += rounder @@ -16020,18 +15703,18 @@ __143: ; __142: ; - if !(int32(xtype) == 3) { + if !(int32(xtype) == EtGENERIC) { goto __144 } flag_rtz = libc.BoolUint8(!(flag_alternateform != 0)) if !((exp < -4) || (exp > precision)) { goto __146 } - xtype = EtByte(2) + xtype = EtEXP goto __147 __146: precision = (precision - exp) - xtype = EtByte(1) + xtype = EtFLOAT __147: ; goto __145 @@ -16039,7 +15722,7 @@ __144: flag_rtz = flag_altform2 __145: ; - if !(int32(xtype) == 2) { + if !(int32(xtype) == EtEXP) { goto __148 } e2 = 0 @@ -16055,7 +15738,7 @@ __149: } return int64(0) }()) + I64(precision)) + I64(width)) + int64(15)) - if !(szBufNeeded > int64(70)) { + if !(szBufNeeded > SQLITE_PRINT_BUF_SIZE) { goto __150 } bufpt = libc.AssignUintptr(&zExtra, printfTempBuf(tls, pAccum, szBufNeeded)) @@ -16168,7 +15851,7 @@ __167: __164: ; // Add the "eNNN" suffix - if !(int32(xtype) == 2) { + if !(int32(xtype) == EtEXP) { goto __170 } *(*int8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) = aDigits[(*Et_info)(unsafe.Pointer(infop)).Fcharset] @@ -16243,7 +15926,7 @@ __180: length = libc.AssignInt32(&width, 0) goto __58 __67: - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = int8('%') + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = int8('%') bufpt = bp /* &buf[0] */ length = 1 goto __58 @@ -16256,12 +15939,12 @@ __68: if !(bufpt != 0) { goto __183 } - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = int8(libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = int8(libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1)))))) if !((c & 0xc0) == 0xc0) { goto __185 } __186: - if !((length < 4) && ((int32(*(*int8)(unsafe.Pointer(bufpt + uintptr(0)))) & 0xc0) == 0x80)) { + if !((length < 4) && ((int32(*(*int8)(unsafe.Pointer(bufpt))) & 0xc0) == 0x80)) { goto __187 } *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(libc.PostIncInt32(&length, 1)))) = *(*int8)(unsafe.Pointer(libc.PostIncUintptr(&bufpt, 1))) @@ -16272,7 +15955,7 @@ __185: ; goto __184 __183: - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = int8(0) __184: ; goto __182 @@ -16281,31 +15964,31 @@ __181: if !(ch < uint32(0x00080)) { goto __188 } - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = (int8(ch & uint32(0xff))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = (int8(ch & uint32(0xff))) length = 1 goto __189 __188: if !(ch < uint32(0x00800)) { goto __190 } - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = (int8(0xc0 + int32((U8((ch >> 6) & uint32(0x1f)))))) - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(1))) = (int8(0x80 + int32((U8(ch & uint32(0x3f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = (int8(0xc0 + int32((U8((ch >> 6) & uint32(0x1f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + 1)) = (int8(0x80 + int32((U8(ch & uint32(0x3f)))))) length = 2 goto __191 __190: if !(ch < uint32(0x10000)) { goto __192 } - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = (int8(0xe0 + int32((U8((ch >> 12) & uint32(0x0f)))))) - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(1))) = (int8(0x80 + int32((U8((ch >> 6) & uint32(0x3f)))))) - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(2))) = (int8(0x80 + int32((U8(ch & uint32(0x3f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = (int8(0xe0 + int32((U8((ch >> 12) & uint32(0x0f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + 1)) = (int8(0x80 + int32((U8((ch >> 6) & uint32(0x3f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + 2)) = (int8(0x80 + int32((U8(ch & uint32(0x3f)))))) length = 3 goto __193 __192: - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(0))) = (int8(0xf0 + int32((U8((ch >> 18) & uint32(0x07)))))) - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(1))) = (int8(0x80 + int32((U8((ch >> 12) & uint32(0x3f)))))) - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(2))) = (int8(0x80 + int32((U8((ch >> 6) & uint32(0x3f)))))) - *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(3))) = (int8(0x80 + int32((U8(ch & uint32(0x3f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */)) = (int8(0xf0 + int32((U8((ch >> 18) & uint32(0x07)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + 1)) = (int8(0x80 + int32((U8((ch >> 12) & uint32(0x3f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + 2)) = (int8(0x80 + int32((U8((ch >> 6) & uint32(0x3f)))))) + *(*int8)(unsafe.Pointer(bp /* &buf[0] */ + 3)) = (int8(0x80 + int32((U8(ch & uint32(0x3f)))))) length = 4 __193: ; @@ -16345,7 +16028,7 @@ __70: goto __198 } bufpt = getTextArg(tls, pArgList) - xtype = EtByte(5) + xtype = EtSTRING goto __199 __198: bufpt = libc.VaUintptr(&ap) @@ -16357,7 +16040,7 @@ __199: bufpt = ts + 800 /* "" */ goto __201 __200: - if !(int32(xtype) == 6) { + if !(int32(xtype) == EtDYNSTRING) { goto __202 } if !((((((*Sqlite3_str)(unsafe.Pointer(pAccum)).FnChar == U32(0)) && @@ -16374,7 +16057,7 @@ __200: (*Sqlite3_str)(unsafe.Pointer(pAccum)).FzText = bufpt (*Sqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc = U32(Xsqlite3DbMallocSize(tls, (*Sqlite3_str)(unsafe.Pointer(pAccum)).Fdb, bufpt)) (*Sqlite3_str)(unsafe.Pointer(pAccum)).FnChar = (U32(0x7fffffff & int32(libc.Xstrlen(tls, bufpt)))) - *(*U8)(unsafe.Pointer(pAccum + 29 /* &.printfFlags */)) |= U8((0x04)) + *(*U8)(unsafe.Pointer(pAccum + 29 /* &.printfFlags */)) |= U8((SQLITE_PRINTF_MALLOCED)) length = 0 goto __58 __203: @@ -16394,7 +16077,7 @@ __201: // precision characters z = bufpt __208: - if !((libc.PostDecInt32(&precision, 1) > 0) && (*(*uint8)(unsafe.Pointer(z + uintptr(0))) != 0)) { + if !((libc.PostDecInt32(&precision, 1) > 0) && (*(*uint8)(unsafe.Pointer(z)) != 0)) { goto __209 } if !((int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))) >= 0xc0) { @@ -16462,7 +16145,7 @@ __71: // %q: Escape ' characters __72: // %Q: Escape ' and enclose in '...' __73: q = func() int8 { - if int32(xtype) == 14 { + if int32(xtype) == EtSQLESCAPE3 { return int8('"') } return int8('\'') @@ -16482,7 +16165,7 @@ __221: goto __222 } escarg = func() uintptr { - if int32(xtype) == 10 { + if int32(xtype) == EtSQLESCAPE2 { return ts + 801 /* "NULL" */ } return ts + 806 /* "(NULL)" */ @@ -16526,9 +16209,9 @@ __224: goto __225 __225: ; - needQuote = (libc.Bool32(!(isnull != 0) && (int32(xtype) == 10))) + needQuote = (libc.Bool32(!(isnull != 0) && (int32(xtype) == EtSQLESCAPE2))) n1 = n1 + (i1 + 3) - if !(n1 > 70) { + if !(n1 > SQLITE_PRINT_BUF_SIZE) { goto __230 } bufpt = libc.AssignUintptr(&zExtra, printfTempBuf(tls, pAccum, int64(n1))) @@ -16581,7 +16264,7 @@ __238: goto adjust_width_for_utf8 __74: - if !((int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags) & 0x01) == 0) { + if !((int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags) & SQLITE_PRINTF_INTERNAL) == 0) { goto __239 } return @@ -16599,7 +16282,7 @@ __240: goto __58 __75: - if !((int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags) & 0x01) == 0) { + if !((int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags) & SQLITE_PRINTF_INTERNAL) == 0) { goto __241 } return @@ -16672,6 +16355,7 @@ __5: } var zOrd = *(*[9]int8)(unsafe.Pointer(ts + 815 /* "thstndrd" */)) /* sqlite3.c:28611:29 */ + // End of function // Enlarge the memory allocation on a StrAccum object so that it is @@ -16687,11 +16371,11 @@ func sqlite3StrAccumEnlarge(tls *libc.TLS, p uintptr, N int32) int32 { /* sqlite return 0 } if (*StrAccum)(unsafe.Pointer(p)).FmxAlloc == U32(0) { - setStrAccumError(tls, p, uint8(18)) + setStrAccumError(tls, p, SQLITE_TOOBIG) return (int32(((*StrAccum)(unsafe.Pointer(p)).FnAlloc - (*StrAccum)(unsafe.Pointer(p)).FnChar) - U32(1))) } else { var zOld uintptr - if (int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & 0x04) != 0 { + if (int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & SQLITE_PRINTF_MALLOCED) != 0 { zOld = (*StrAccum)(unsafe.Pointer(p)).FzText } else { zOld = uintptr(0) @@ -16705,7 +16389,7 @@ func sqlite3StrAccumEnlarge(tls *libc.TLS, p uintptr, N int32) int32 { /* sqlite } if szNew > I64((*StrAccum)(unsafe.Pointer(p)).FmxAlloc) { Xsqlite3_str_reset(tls, p) - setStrAccumError(tls, p, uint8(18)) + setStrAccumError(tls, p, SQLITE_TOOBIG) return 0 } else { (*StrAccum)(unsafe.Pointer(p)).FnAlloc = U32(int32(szNew)) @@ -16717,15 +16401,15 @@ func sqlite3StrAccumEnlarge(tls *libc.TLS, p uintptr, N int32) int32 { /* sqlite } if zNew != 0 { - if !((int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & 0x04) != 0) && ((*StrAccum)(unsafe.Pointer(p)).FnChar > U32(0)) { + if !((int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & SQLITE_PRINTF_MALLOCED) != 0) && ((*StrAccum)(unsafe.Pointer(p)).FnChar > U32(0)) { libc.Xmemcpy(tls, zNew, (*StrAccum)(unsafe.Pointer(p)).FzText, uint64((*StrAccum)(unsafe.Pointer(p)).FnChar)) } (*StrAccum)(unsafe.Pointer(p)).FzText = zNew (*StrAccum)(unsafe.Pointer(p)).FnAlloc = U32(Xsqlite3DbMallocSize(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, zNew)) - *(*U8)(unsafe.Pointer(p + 29 /* &.printfFlags */)) |= U8((0x04)) + *(*U8)(unsafe.Pointer(p + 29 /* &.printfFlags */)) |= U8((SQLITE_PRINTF_MALLOCED)) } else { Xsqlite3_str_reset(tls, p) - setStrAccumError(tls, p, uint8(7)) + setStrAccumError(tls, p, SQLITE_NOMEM) return 0 } } @@ -16784,9 +16468,9 @@ func strAccumFinishRealloc(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:2915 zText = Xsqlite3DbMallocRaw(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, (uint64((*StrAccum)(unsafe.Pointer(p)).FnChar + U32(1)))) if zText != 0 { libc.Xmemcpy(tls, zText, (*StrAccum)(unsafe.Pointer(p)).FzText, (uint64((*StrAccum)(unsafe.Pointer(p)).FnChar + U32(1)))) - *(*U8)(unsafe.Pointer(p + 29 /* &.printfFlags */)) |= U8((0x04)) + *(*U8)(unsafe.Pointer(p + 29 /* &.printfFlags */)) |= U8((SQLITE_PRINTF_MALLOCED)) } else { - setStrAccumError(tls, p, uint8(7)) + setStrAccumError(tls, p, SQLITE_NOMEM) } (*StrAccum)(unsafe.Pointer(p)).FzText = zText return zText @@ -16795,7 +16479,7 @@ func strAccumFinishRealloc(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:2915 func Xsqlite3StrAccumFinish(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:29169:21: */ if (*StrAccum)(unsafe.Pointer(p)).FzText != 0 { *(*int8)(unsafe.Pointer((*StrAccum)(unsafe.Pointer(p)).FzText + uintptr((*StrAccum)(unsafe.Pointer(p)).FnChar))) = int8(0) - if ((*StrAccum)(unsafe.Pointer(p)).FmxAlloc > U32(0)) && !((int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & 0x04) != 0) { + if ((*StrAccum)(unsafe.Pointer(p)).FmxAlloc > U32(0)) && !((int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & SQLITE_PRINTF_MALLOCED) != 0) { return strAccumFinishRealloc(tls, p) } } @@ -16806,15 +16490,7 @@ func Xsqlite3StrAccumFinish(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:291 // sqlite3_malloc() fails to provide space for a real one. This // sqlite3_str object accepts no new text and always returns // an SQLITE_NOMEM error. -var sqlite3OomStr = Sqlite3_str{ - Fdb: uintptr(0), - FzText: uintptr(0), - FnAlloc: U32(0), - FmxAlloc: U32(0), - FnChar: U32(0), - FaccError: U8(7), - FprintfFlags: U8(0), -} /* sqlite3.c:29185:20 */ +var sqlite3OomStr = Sqlite3_str{FaccError: SQLITE_NOMEM} /* sqlite3.c:29185:20 */ // Finalize a string created using sqlite3_str_new(). func Xsqlite3_str_finish(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:29191:17: */ @@ -16833,7 +16509,7 @@ func Xsqlite3_str_errcode(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:29203:1 if p != 0 { return int32((*Sqlite3_str)(unsafe.Pointer(p)).FaccError) } - return 7 + return SQLITE_NOMEM } // Return the current length of p in bytes @@ -16855,9 +16531,9 @@ func Xsqlite3_str_value(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:29213:1 // Reset an StrAccum string. Reclaim all malloced memory. func Xsqlite3_str_reset(tls *libc.TLS, p uintptr) { /* sqlite3.c:29222:17: */ - if (int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & 0x04) != 0 { + if (int32((*StrAccum)(unsafe.Pointer((p))).FprintfFlags) & SQLITE_PRINTF_MALLOCED) != 0 { Xsqlite3DbFree(tls, (*StrAccum)(unsafe.Pointer(p)).Fdb, (*StrAccum)(unsafe.Pointer(p)).FzText) - *(*U8)(unsafe.Pointer(p + 29 /* &.printfFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x04))) + *(*U8)(unsafe.Pointer(p + 29 /* &.printfFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(SQLITE_PRINTF_MALLOCED))) } (*StrAccum)(unsafe.Pointer(p)).FnAlloc = U32(0) (*StrAccum)(unsafe.Pointer(p)).FnChar = U32(0) @@ -16893,9 +16569,9 @@ func Xsqlite3_str_new(tls *libc.TLS, db uintptr) uintptr { /* sqlite3.c:29257:24 Xsqlite3StrAccumInit(tls, p, uintptr(0), uintptr(0), 0, func() int32 { if db != 0 { - return *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4)) + return *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */))) } - return 1000000000 + return SQLITE_MAX_LENGTH }()) } else { p = uintptr(unsafe.Pointer(&sqlite3OomStr)) @@ -16915,11 +16591,11 @@ func Xsqlite3VMPrintf(tls *libc.TLS, db uintptr, zFormat uintptr, ap Va_list) ui // var acc StrAccum at bp, 32 Xsqlite3StrAccumInit(tls, bp /* &acc */, db, bp+32 /* &zBase[0] */, int32(unsafe.Sizeof([70]int8{})), - *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) - (*StrAccum)(unsafe.Pointer(bp /* &acc */)).FprintfFlags = U8(0x01) + *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) + (*StrAccum)(unsafe.Pointer(bp /* &acc */)).FprintfFlags = SQLITE_PRINTF_INTERNAL Xsqlite3_str_vappendf(tls, bp /* &acc */, zFormat, ap) z = Xsqlite3StrAccumFinish(tls, bp /* &acc */) - if int32((*StrAccum)(unsafe.Pointer(bp /* &acc */)).FaccError) == 7 { + if int32((*StrAccum)(unsafe.Pointer(bp /* &acc */)).FaccError) == SQLITE_NOMEM { Xsqlite3OomFault(tls, db) } return z @@ -16951,7 +16627,7 @@ func Xsqlite3_vmprintf(tls *libc.TLS, zFormat uintptr, ap Va_list) uintptr { /* if Xsqlite3_initialize(tls) != 0 { return uintptr(0) } - Xsqlite3StrAccumInit(tls, bp /* &acc */, uintptr(0), bp+32 /* &zBase[0] */, int32(unsafe.Sizeof([70]int8{})), 1000000000) + Xsqlite3StrAccumInit(tls, bp /* &acc */, uintptr(0), bp+32 /* &zBase[0] */, int32(unsafe.Sizeof([70]int8{})), SQLITE_MAX_LENGTH) Xsqlite3_str_vappendf(tls, bp /* &acc */, zFormat, ap) z = Xsqlite3StrAccumFinish(tls, bp /* &acc */) return z @@ -17191,7 +16867,7 @@ func Xsqlite3_randomness(tls *libc.TLS, N int32, pBuf uintptr) { /* sqlite3.c:30 return } - mutex = Xsqlite3MutexAlloc(tls, 5) + mutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_PRNG) Xsqlite3_mutex_enter(tls, mutex) if (N <= 0) || (pBuf == uintptr(0)) { @@ -17269,7 +16945,7 @@ func Xsqlite3ThreadCreate(tls *libc.TLS, ppThread uintptr, xTask uintptr, pIn ui *(*uintptr)(unsafe.Pointer(ppThread)) = uintptr(0) p = Xsqlite3Malloc(tls, uint64(unsafe.Sizeof(SQLiteThread{}))) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } if (((int32(p)) / 17) & 1) != 0 { (*SQLiteThread)(unsafe.Pointer(p)).FxTask = xTask @@ -17279,14 +16955,14 @@ func Xsqlite3ThreadCreate(tls *libc.TLS, ppThread uintptr, xTask uintptr, pIn ui (*SQLiteThread)(unsafe.Pointer(p)).FpResult = (*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer(&xTask)))(tls, pIn) } *(*uintptr)(unsafe.Pointer(ppThread)) = p - return 0 + return SQLITE_OK } // Get the results of the thread func Xsqlite3ThreadJoin(tls *libc.TLS, p uintptr, ppOut uintptr) int32 { /* sqlite3.c:30621:20: */ if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } if (*SQLiteThread)(unsafe.Pointer(p)).FxTask != 0 { *(*uintptr)(unsafe.Pointer(ppOut)) = (*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer((p /* &.xTask */))))(tls, (*SQLiteThread)(unsafe.Pointer(p)).FpIn) @@ -17298,13 +16974,13 @@ func Xsqlite3ThreadJoin(tls *libc.TLS, p uintptr, ppOut uintptr) int32 { /* sqli { var pTstAlloc uintptr = Xsqlite3Malloc(tls, uint64(10)) if !(pTstAlloc != 0) { - return 7 + return SQLITE_NOMEM } Xsqlite3_free(tls, pTstAlloc) } - return 0 + return SQLITE_OK } //***************************** End Single-Threaded ************************ @@ -17428,19 +17104,19 @@ func Xsqlite3VdbeMemTranslate(tls *libc.TLS, pMem uintptr, desiredEnc U8) int32 // If the translation is between UTF-16 little and big endian, then // all that is required is to swap the byte order. This case is handled // differently from the others. - if !((int32((*Mem)(unsafe.Pointer(pMem)).Fenc) != 1) && (int32(desiredEnc) != 1)) { + if !((int32((*Mem)(unsafe.Pointer(pMem)).Fenc) != SQLITE_UTF8) && (int32(desiredEnc) != SQLITE_UTF8)) { goto __1 } rc = Xsqlite3VdbeMemMakeWriteable(tls, pMem) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __2 } - return 7 + return SQLITE_NOMEM __2: ; zIn = (*Mem)(unsafe.Pointer(pMem)).Fz - zTerm = (zIn + uintptr(((*Mem)(unsafe.Pointer(pMem)).Fn & ^libc.Int32(1)))) + zTerm = (zIn + uintptr(((*Mem)(unsafe.Pointer(pMem)).Fn & libc.CplInt32(1)))) __3: if !(zIn < zTerm) { goto __4 @@ -17458,14 +17134,14 @@ __1: ; // Set len to the maximum number of bytes required in the output buffer. - if !(int32(desiredEnc) == 1) { + if !(int32(desiredEnc) == SQLITE_UTF8) { goto __5 } // When converting from UTF-16, the maximum growth results from // translating a 2-byte character to a 4-byte UTF-8 character. // A single byte is required for the output string // nul-terminator. - *(*int32)(unsafe.Pointer(pMem + 12 /* &.n */)) &= (^libc.Int32(1)) + *(*int32)(unsafe.Pointer(pMem + 12 /* &.n */)) &= (libc.CplInt32(1)) len = ((int64(2) * Sqlite3_int64((*Mem)(unsafe.Pointer(pMem)).Fn)) + int64(1)) goto __6 __5: @@ -17488,15 +17164,15 @@ __6: if !(!(zOut != 0)) { goto __7 } - return 7 + return SQLITE_NOMEM __7: ; z = zOut - if !(int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == 1) { + if !(int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == SQLITE_UTF8) { goto __8 } - if !(int32(desiredEnc) == 2) { + if !(int32(desiredEnc) == SQLITE_UTF16LE) { goto __10 } // UTF-8 -> UTF-16 Little-endian @@ -17597,7 +17273,7 @@ __11: goto __9 __8: ; - if !(int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == 2) { + if !(int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == SQLITE_UTF16LE) { goto __28 } // UTF-16 Little-endian -> UTF-8 @@ -17719,7 +17395,7 @@ __9: ; *(*uint8)(unsafe.Pointer(z)) = uint8(0) - c = (uint32((0x0002 | 0x0200) | (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x003f | 0x8000)))) + c = (uint32((MEM_Str | MEM_Term) | (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_AffMask | MEM_Subtype)))) Xsqlite3VdbeMemRelease(tls, pMem) (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(c) (*Mem)(unsafe.Pointer(pMem)).Fenc = desiredEnc @@ -17728,7 +17404,7 @@ __9: (*Mem)(unsafe.Pointer(pMem)).FszMalloc = Xsqlite3DbMallocSize(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, (*Mem)(unsafe.Pointer(pMem)).Fz) translate_out: - return 0 + return SQLITE_OK } // This routine checks for a byte-order mark at the beginning of the @@ -17739,28 +17415,28 @@ translate_out: // The allocation (static, dynamic etc.) and encoding of the Mem may be // changed by this function. func Xsqlite3VdbeMemHandleBom(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:31025:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var bom U8 = U8(0) if (*Mem)(unsafe.Pointer(pMem)).Fn > 1 { var b1 U8 = *(*U8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz)) var b2 U8 = *(*U8)(unsafe.Pointer((((*Mem)(unsafe.Pointer(pMem)).Fz) + uintptr(1)))) if (int32(b1) == 0xFE) && (int32(b2) == 0xFF) { - bom = U8(3) + bom = SQLITE_UTF16BE } if (int32(b1) == 0xFF) && (int32(b2) == 0xFE) { - bom = U8(2) + bom = SQLITE_UTF16LE } } if bom != 0 { rc = Xsqlite3VdbeMemMakeWriteable(tls, pMem) - if rc == 0 { + if rc == SQLITE_OK { *(*int32)(unsafe.Pointer(pMem + 12 /* &.n */)) -= (2) - libc.Xmemmove(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, ((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(2)), uint64((*Mem)(unsafe.Pointer(pMem)).Fn)) + libc.Xmemmove(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, ((*Mem)(unsafe.Pointer(pMem)).Fz + 2), uint64((*Mem)(unsafe.Pointer(pMem)).Fn)) *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn))) = int8(0) *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(((*Mem)(unsafe.Pointer(pMem)).Fn + 1)))) = int8(0) - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16((0x0200)) + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16((MEM_Term)) (*Mem)(unsafe.Pointer(pMem)).Fenc = bom } } @@ -17813,7 +17489,7 @@ func Xsqlite3Utf16to8(tls *libc.TLS, db uintptr, z uintptr, nByte int32, enc U8) libc.Xmemset(tls, bp /* &m */, 0, uint64(unsafe.Sizeof(Mem{}))) (*Mem)(unsafe.Pointer(bp /* &m */)).Fdb = db Xsqlite3VdbeMemSetStr(tls, bp /* &m */, z, nByte, enc, uintptr(0)) - Xsqlite3VdbeChangeEncoding(tls, bp /* &m */, 1) + Xsqlite3VdbeChangeEncoding(tls, bp /* &m */, SQLITE_UTF8) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { Xsqlite3VdbeMemRelease(tls, bp /* &m */) (*Mem)(unsafe.Pointer(bp /* &m */)).Fz = uintptr(0) @@ -17830,19 +17506,19 @@ func Xsqlite3Utf16ByteLen(tls *libc.TLS, zIn uintptr, nChar int32) int32 { /* sq var z uintptr = zIn var n int32 = 0 - if 2 == 2 { + if SQLITE_UTF16LE == SQLITE_UTF16LE { z++ } for n < nChar { - c = int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) + c = int32(*(*uint8)(unsafe.Pointer(z))) z += uintptr(2) - if (((c >= 0xd8) && (c < 0xdc)) && (int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) >= 0xdc)) && (int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) < 0xe0) { + if (((c >= 0xd8) && (c < 0xdc)) && (int32(*(*uint8)(unsafe.Pointer(z))) >= 0xdc)) && (int32(*(*uint8)(unsafe.Pointer(z))) < 0xe0) { z += uintptr(2) } n++ } return ((int32((int64(z) - int64(zIn)) / 1)) - - (libc.Bool32(2 == 2))) + (libc.Bool32(SQLITE_UTF16LE == SQLITE_UTF16LE))) } // This routine is called from the TCL test function "translate_selftest". @@ -17886,7 +17562,7 @@ func Xsqlite3UtfSelfTest(tls *libc.TLS) { /* sqlite3.c:31160:21: */ n = (int32(int64((*(*uintptr)(unsafe.Pointer(bp + 24 /* z */)) - bp /* &zBuf[0] */) / 1))) - *(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* z */)) + uintptr(0))) = uint8(0) + *(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* z */)))) = uint8(0) *(*uintptr)(unsafe.Pointer(bp + 24 /* z */)) = bp /* &zBuf[0] */ c = Xsqlite3Utf8Read(tls, bp+24 /* &z */) t = i @@ -18184,7 +17860,7 @@ func Xsqlite3FaultSim(tls *libc.TLS, iTest int32) int32 { /* sqlite3.c:31240:20: if xCallback != 0 { return (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(&xCallback)))(tls, iTest) } - return 0 + return SQLITE_OK } // Return true if the floating point value is Not a Number (NaN). @@ -18218,7 +17894,7 @@ func Xsqlite3Strlen30(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:31265:20: * // The column type is an extra string stored after the zero-terminator on // the column name if and only if the COLFLAG_HASTYPE flag is set. func Xsqlite3ColumnType(tls *libc.TLS, pCol uintptr, zDflt uintptr) uintptr { /* sqlite3.c:31277:21: */ - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0004) == 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_HASTYPE) == 0 { return zDflt } return (((*Column)(unsafe.Pointer(pCol)).FzName + uintptr(libc.Xstrlen(tls, (*Column)(unsafe.Pointer(pCol)).FzName))) + uintptr(1)) @@ -18248,11 +17924,11 @@ func Xsqlite3Error(tls *libc.TLS, db uintptr, err_code int32) { /* sqlite3.c:312 // Load the sqlite3.iSysErrno field if that is an appropriate thing // to do based on the SQLite error code in rc. func Xsqlite3SystemError(tls *libc.TLS, db uintptr, rc int32) { /* sqlite3.c:31307:21: */ - if rc == (10 | (int32(12) << 8)) { + if rc == (SQLITE_IOERR | (int32(12) << 8)) { return } rc = rc & (0xff) - if (rc == 14) || (rc == 10) { + if (rc == SQLITE_CANTOPEN) || (rc == SQLITE_IOERR) { (*Sqlite3)(unsafe.Pointer(db)).FiSysErrno = Xsqlite3OsGetLastError(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs) } } @@ -18289,7 +17965,7 @@ func Xsqlite3ErrorWithMsg(tls *libc.TLS, db uintptr, err_code int32, zFormat uin ap = va z = Xsqlite3VMPrintf(tls, db, zFormat, ap) _ = ap - Xsqlite3ValueSetStr(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr, -1, z, uint8(1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) + Xsqlite3ValueSetStr(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr, -1, z, SQLITE_UTF8, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) } } @@ -18322,7 +17998,7 @@ func Xsqlite3ErrorMsg(tls *libc.TLS, pParse uintptr, zFormat uintptr, va uintptr (*Parse)(unsafe.Pointer(pParse)).FnErr++ Xsqlite3DbFree(tls, db, (*Parse)(unsafe.Pointer(pParse)).FzErrMsg) (*Parse)(unsafe.Pointer(pParse)).FzErrMsg = zMsg - (*Parse)(unsafe.Pointer(pParse)).Frc = 1 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR (*Parse)(unsafe.Pointer(pParse)).FpWith = uintptr(0) } } @@ -18362,7 +18038,7 @@ func Xsqlite3Dequote(tls *libc.TLS, z uintptr) { /* sqlite3.c:31417:21: */ if z == uintptr(0) { return } - quote = *(*int8)(unsafe.Pointer(z + uintptr(0))) + quote = *(*int8)(unsafe.Pointer(z)) if !((int32(Xsqlite3CtypeMap[uint8(quote)]) & 0x80) != 0) { return } @@ -18390,10 +18066,10 @@ func Xsqlite3Dequote(tls *libc.TLS, z uintptr) { /* sqlite3.c:31417:21: */ func Xsqlite3DequoteExpr(tls *libc.TLS, p uintptr) { /* sqlite3.c:31439:21: */ *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= (func() uint32 { - if int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) + uintptr(0)))) == '"' { - return (uint32(0x4000000 | 0x000040)) + if int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))))) == '"' { + return (uint32(EP_Quoted | EP_DblQuoted)) } - return uint32(0x4000000) + return EP_Quoted }()) Xsqlite3Dequote(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))) } @@ -18481,8 +18157,8 @@ func Xsqlite3StrIHash(tls *libc.TLS, z uintptr) U8 { /* sqlite3.c:31509:19: */ if z == uintptr(0) { return U8(0) } - for *(*int8)(unsafe.Pointer(z + uintptr(0))) != 0 { - h = U8(int32(h) + (int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(z + uintptr(0))))]))) + for *(*int8)(unsafe.Pointer(z)) != 0 { + h = U8(int32(h) + (int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(z)))]))) z++ } return h @@ -18568,7 +18244,7 @@ func Xsqlite3AtoF(tls *libc.TLS, z uintptr, pResult uintptr, length int32, enc U __1: ; - if !(int32(enc) == 1) { + if !(int32(enc) == SQLITE_UTF8) { goto __2 } incr = 1 @@ -18576,7 +18252,7 @@ __1: goto __3 __2: incr = 2 - length = length & (^libc.Int32(1)) + length = length & (libc.CplInt32(1)) i = (3 - int32(enc)) __4: @@ -18933,7 +18609,7 @@ func Xsqlite3Int64ToText(tls *libc.TLS, v I64, zOut uintptr) { /* sqlite3.c:3178 x = U64(v) } i = (int32(uint64(unsafe.Sizeof([22]int8{})) - uint64(2))) - *(*int8)(unsafe.Pointer(bp /* &zTemp[0] */ + uintptr((uint64(unsafe.Sizeof([22]int8{})) - uint64(1))))) = int8(0) + *(*int8)(unsafe.Pointer(bp /* &zTemp[0] */ + 21)) = int8(0) for ok := true; ok; ok = x != 0 { *(*int8)(unsafe.Pointer(bp /* &zTemp[0] */ + uintptr(libc.PostDecInt32(&i, 1)))) = (int8((x % uint64(10)) + uint64('0'))) x = (x / uint64(10)) @@ -18996,7 +18672,7 @@ func Xsqlite3Atoi64(tls *libc.TLS, zNum uintptr, pNum uintptr, length int32, enc var zStart uintptr var zEnd uintptr = (zNum + uintptr(length)) - if int32(enc) == 1 { + if int32(enc) == SQLITE_UTF8 { incr = 1 } else { incr = 2 @@ -19019,7 +18695,7 @@ func Xsqlite3Atoi64(tls *libc.TLS, zNum uintptr, pNum uintptr, length int32, enc } } zStart = zNum - for (zNum < zEnd) && (int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '0') { + for (zNum < zEnd) && (int32(*(*int8)(unsafe.Pointer(zNum))) == '0') { zNum += uintptr(incr) } // Skip leading zeros. for i = 0; (((zNum + uintptr(i)) < zEnd) && ((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(zNum + uintptr(i)))))) >= '0')) && (c <= '9'); i = i + (incr) { @@ -19110,8 +18786,8 @@ func Xsqlite3DecOrHexToI64(tls *libc.TLS, z uintptr, pOut uintptr) int32 { /* sq bp := tls.Alloc(8) defer tls.Free(8) - if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '0') && - ((int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == 'x') || (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == 'X')) { + if (int32(*(*int8)(unsafe.Pointer(z))) == '0') && + ((int32(*(*int8)(unsafe.Pointer(z + 1))) == 'x') || (int32(*(*int8)(unsafe.Pointer(z + 1))) == 'X')) { *(*U64)(unsafe.Pointer(bp /* u */)) = uint64(0) var i int32 var k int32 @@ -19126,7 +18802,7 @@ func Xsqlite3DecOrHexToI64(tls *libc.TLS, z uintptr, pOut uintptr) int32 { /* sq } return 2 } else { - return Xsqlite3Atoi64(tls, z, pOut, Xsqlite3Strlen30(tls, z), uint8(1)) + return Xsqlite3Atoi64(tls, z, pOut, Xsqlite3Strlen30(tls, z), SQLITE_UTF8) } return int32(0) } @@ -19147,17 +18823,17 @@ func Xsqlite3GetInt32(tls *libc.TLS, zNum uintptr, pValue uintptr) int32 { /* sq var i int32 var c int32 var neg int32 = 0 - if int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '-' { + if int32(*(*int8)(unsafe.Pointer(zNum))) == '-' { neg = 1 zNum++ - } else if int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '+' { + } else if int32(*(*int8)(unsafe.Pointer(zNum))) == '+' { zNum++ - } else if ((int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '0') && - ((int32(*(*int8)(unsafe.Pointer(zNum + uintptr(1)))) == 'x') || (int32(*(*int8)(unsafe.Pointer(zNum + uintptr(1)))) == 'X'))) && - ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zNum + uintptr(2))))]) & 0x08) != 0) { + } else if ((int32(*(*int8)(unsafe.Pointer(zNum))) == '0') && + ((int32(*(*int8)(unsafe.Pointer(zNum + 1))) == 'x') || (int32(*(*int8)(unsafe.Pointer(zNum + 1))) == 'X'))) && + ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zNum + 2)))]) & 0x08) != 0) { *(*U32)(unsafe.Pointer(bp /* u */)) = U32(0) zNum += uintptr(2) - for int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '0' { + for int32(*(*int8)(unsafe.Pointer(zNum))) == '0' { zNum++ } for i = 0; ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zNum + uintptr(i))))]) & 0x08) != 0) && (i < 8); i++ { @@ -19170,10 +18846,10 @@ func Xsqlite3GetInt32(tls *libc.TLS, zNum uintptr, pValue uintptr) int32 { /* sq return 0 } } - if !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zNum + uintptr(0))))]) & 0x04) != 0) { + if !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zNum)))]) & 0x04) != 0) { return 0 } - for int32(*(*int8)(unsafe.Pointer(zNum + uintptr(0)))) == '0' { + for int32(*(*int8)(unsafe.Pointer(zNum))) == '0' { zNum++ } for i = 0; ((i < 11) && ((libc.AssignInt32(&c, (int32(*(*int8)(unsafe.Pointer(zNum + uintptr(i)))) - '0'))) >= 0)) && (c <= 9); i++ { @@ -19267,7 +18943,7 @@ func putVarint64(tls *libc.TLS, p uintptr, v U64) int32 { /* sqlite3.c:32099:28: // var buf [10]U8 at bp, 10 if (v & (U64((uint64(0xff000000))) << 32)) != 0 { - *(*uint8)(unsafe.Pointer(p + uintptr(8))) = U8(v) + *(*uint8)(unsafe.Pointer(p + 8)) = U8(v) v >>= 8 for i = 7; i >= 0; i-- { *(*uint8)(unsafe.Pointer(p + uintptr(i))) = (U8((v & uint64(0x7f)) | uint64(0x80))) @@ -19280,7 +18956,7 @@ func putVarint64(tls *libc.TLS, p uintptr, v U64) int32 { /* sqlite3.c:32099:28: *(*U8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(libc.PostIncInt32(&n, 1)))) = (U8((v & uint64(0x7f)) | uint64(0x80))) v >>= 7 } - *(*U8)(unsafe.Pointer(bp /* &buf */ + uintptr(0))) &= U8((0x7f)) + *(*U8)(unsafe.Pointer(bp /* &buf */)) &= U8((0x7f)) i = 0 j = (n - 1) @@ -19305,12 +18981,12 @@ __3: func Xsqlite3PutVarint(tls *libc.TLS, p uintptr, v U64) int32 { /* sqlite3.c:32123:20: */ if v <= uint64(0x7f) { - *(*uint8)(unsafe.Pointer(p + uintptr(0))) = (uint8(v & uint64(0x7f))) + *(*uint8)(unsafe.Pointer(p)) = (uint8(v & uint64(0x7f))) return 1 } if v <= uint64(0x3fff) { - *(*uint8)(unsafe.Pointer(p + uintptr(0))) = (uint8(((v >> 7) & uint64(0x7f)) | uint64(0x80))) - *(*uint8)(unsafe.Pointer(p + uintptr(1))) = (uint8(v & uint64(0x7f))) + *(*uint8)(unsafe.Pointer(p)) = (uint8(((v >> 7) & uint64(0x7f)) | uint64(0x80))) + *(*uint8)(unsafe.Pointer(p + 1)) = (uint8(v & uint64(0x7f))) return 2 } return putVarint64(tls, p, v) @@ -19331,24 +19007,24 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 var b U32 var s U32 - if int32(*(*int8)(unsafe.Pointer((p) + uintptr(0)))) >= 0 { + if int32(*(*int8)(unsafe.Pointer((p)))) >= 0 { *(*U64)(unsafe.Pointer(v)) = U64(*(*uint8)(unsafe.Pointer(p))) return U8(1) } - if int32(*(*int8)(unsafe.Pointer((p) + uintptr(1)))) >= 0 { - *(*U64)(unsafe.Pointer(v)) = (U64(((U32(int32(*(*uint8)(unsafe.Pointer(p + uintptr(0)))) & 0x7f)) << 7) | U32(*(*uint8)(unsafe.Pointer(p + uintptr(1)))))) + if int32(*(*int8)(unsafe.Pointer((p) + 1))) >= 0 { + *(*U64)(unsafe.Pointer(v)) = (U64(((U32(int32(*(*uint8)(unsafe.Pointer(p))) & 0x7f)) << 7) | U32(*(*uint8)(unsafe.Pointer(p + 1))))) return U8(2) } // Verify that constants are precomputed correctly - a = ((U32(*(*uint8)(unsafe.Pointer(p + uintptr(0))))) << 14) - b = U32(*(*uint8)(unsafe.Pointer(p + uintptr(1)))) + a = ((U32(*(*uint8)(unsafe.Pointer(p)))) << 14) + b = U32(*(*uint8)(unsafe.Pointer(p + 1))) p += uintptr(2) a = a | (U32(*(*uint8)(unsafe.Pointer(p)))) // a: p0<<14 | p2 (unmasked) if !((a & U32(0x80)) != 0) { - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) b = b & (U32(0x7f)) b = (b << 7) a = a | (b) @@ -19357,13 +19033,13 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 } // CSE1 from below - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) p++ b = (b << 14) b = b | (U32(*(*uint8)(unsafe.Pointer(p)))) // b: p1<<14 | p3 (unmasked) if !((b & U32(0x80)) != 0) { - b = b & (U32(0x001fc07f)) + b = b & (SLOT_2_0) // moved CSE1 up // a &= (0x7f<<14)|(0x7f); a = (a << 7) @@ -19377,7 +19053,7 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 // 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) // moved CSE1 up // a &= (0x7f<<14)|(0x7f); - b = b & (U32(0x001fc07f)) + b = b & (SLOT_2_0) s = a // s: p0<<14 | p2 (masked) @@ -19409,7 +19085,7 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 if !((b & U32(0x80)) != 0) { // we can skip this cause it was (effectively) done above in calc'ing s // b &= (0x7f<<28)|(0x7f<<14)|(0x7f); - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) a = (a << 7) a = a | (b) s = (s >> 18) @@ -19422,8 +19098,8 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 a = a | (U32(*(*uint8)(unsafe.Pointer(p)))) // a: p2<<28 | p4<<14 | p6 (unmasked) if !((a & U32(0x80)) != 0) { - a = a & (0xf01fc07f) - b = b & (U32(0x001fc07f)) + a = a & (SLOT_4_2_0) + b = b & (SLOT_2_0) b = (b << 7) a = a | (b) s = (s >> 11) @@ -19432,13 +19108,13 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 } // CSE2 from below - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) p++ b = (b << 14) b = b | (U32(*(*uint8)(unsafe.Pointer(p)))) // b: p3<<28 | p5<<14 | p7 (unmasked) if !((b & U32(0x80)) != 0) { - b = b & (0xf01fc07f) + b = b & (SLOT_4_2_0) // moved CSE2 up // a &= (0x7f<<14)|(0x7f); a = (a << 7) @@ -19455,7 +19131,7 @@ func Xsqlite3GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c:32 // moved CSE2 up // a &= (0x7f<<29)|(0x7f<<15)|(0xff); - b = b & (U32(0x001fc07f)) + b = b & (SLOT_2_0) b = (b << 8) a = a | (b) @@ -19608,7 +19284,7 @@ func logBadConnection(tls *libc.TLS, zType uintptr) { /* sqlite3.c:32527:13: */ bp := tls.Alloc(8) defer tls.Free(8) - Xsqlite3_log(tls, 21, + Xsqlite3_log(tls, SQLITE_MISUSE, ts+846, /* "API call with %s..." */ libc.VaList(bp, zType)) } @@ -19632,7 +19308,7 @@ func Xsqlite3SafetyCheckOk(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:32548 return 0 } magic = (*Sqlite3)(unsafe.Pointer(db)).Fmagic - if magic != 0xa029a697 { + if magic != SQLITE_MAGIC_OPEN { if Xsqlite3SafetyCheckSickOrOk(tls, db) != 0 { logBadConnection(tls, ts+891 /* "unopened" */) @@ -19647,7 +19323,7 @@ func Xsqlite3SafetyCheckOk(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:32548 func Xsqlite3SafetyCheckSickOrOk(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:32565:20: */ var magic U32 magic = (*Sqlite3)(unsafe.Pointer(db)).Fmagic - if ((magic != U32(0x4b771290)) && (magic != 0xa029a697)) && (magic != 0xf03b7906) { + if ((magic != SQLITE_MAGIC_SICK) && (magic != SQLITE_MAGIC_OPEN)) && (magic != SQLITE_MAGIC_BUSY) { logBadConnection(tls, ts+900 /* "invalid" */) return 0 @@ -19829,11 +19505,11 @@ func Xsqlite3VListAdd(tls *libc.TLS, db uintptr, pIn uintptr, zName uintptr, nNa nInt = ((nName / 4) + 3) // Verify ok to add new elements - if (pIn == uintptr(0)) || ((*(*VList)(unsafe.Pointer(pIn + uintptr(1)*4)) + nInt) > *(*VList)(unsafe.Pointer(pIn + uintptr(0)*4))) { + if (pIn == uintptr(0)) || ((*(*VList)(unsafe.Pointer(pIn + 1*4)) + nInt) > *(*VList)(unsafe.Pointer(pIn))) { // Enlarge the allocation var nAlloc Sqlite3_int64 = ((func() int64 { if pIn != 0 { - return (int64(2) * Sqlite3_int64(*(*VList)(unsafe.Pointer(pIn + uintptr(0)*4)))) + return (int64(2) * Sqlite3_int64(*(*VList)(unsafe.Pointer(pIn)))) } return int64(10) }()) + Sqlite3_int64(nInt)) @@ -19842,16 +19518,16 @@ func Xsqlite3VListAdd(tls *libc.TLS, db uintptr, pIn uintptr, zName uintptr, nNa return pIn } if pIn == uintptr(0) { - *(*VList)(unsafe.Pointer(pOut + uintptr(1)*4)) = 2 + *(*VList)(unsafe.Pointer(pOut + 1*4)) = 2 } pIn = pOut - *(*VList)(unsafe.Pointer(pIn + uintptr(0)*4)) = VList(nAlloc) + *(*VList)(unsafe.Pointer(pIn)) = VList(nAlloc) } - i = *(*VList)(unsafe.Pointer(pIn + uintptr(1)*4)) + i = *(*VList)(unsafe.Pointer(pIn + 1*4)) *(*VList)(unsafe.Pointer(pIn + uintptr(i)*4)) = iVal *(*VList)(unsafe.Pointer(pIn + uintptr((i+1))*4)) = nInt z = (pIn + uintptr((i+2))*4) - *(*VList)(unsafe.Pointer(pIn + uintptr(1)*4)) = (i + nInt) + *(*VList)(unsafe.Pointer(pIn + 1*4)) = (i + nInt) libc.Xmemcpy(tls, z, zName, uint64(nName)) *(*int8)(unsafe.Pointer(z + uintptr(nName))) = int8(0) @@ -19867,7 +19543,7 @@ func Xsqlite3VListNumToName(tls *libc.TLS, pIn uintptr, iVal int32) uintptr { /* if pIn == uintptr(0) { return uintptr(0) } - mx = *(*VList)(unsafe.Pointer(pIn + uintptr(1)*4)) + mx = *(*VList)(unsafe.Pointer(pIn + 1*4)) i = 2 for ok := true; ok; ok = (i < mx) { if *(*VList)(unsafe.Pointer(pIn + uintptr(i)*4)) == iVal { @@ -19886,7 +19562,7 @@ func Xsqlite3VListNameToNum(tls *libc.TLS, pIn uintptr, zName uintptr, nName int if pIn == uintptr(0) { return 0 } - mx = *(*VList)(unsafe.Pointer(pIn + uintptr(1)*4)) + mx = *(*VList)(unsafe.Pointer(pIn + 1*4)) i = 2 for ok := true; ok; ok = (i < mx) { var z uintptr = (pIn + uintptr((i+2))*4) @@ -20004,8 +19680,8 @@ func rehash(tls *libc.TLS, pH uintptr, new_size uint32) int32 { /* sqlite3.c:329 var elem uintptr var next_elem uintptr // For looping over existing elements - if (uint64(new_size) * uint64(unsafe.Sizeof(_ht{}))) > uint64(1024) { - new_size = (uint32(uint64(1024) / uint64(unsafe.Sizeof(_ht{})))) + if (uint64(new_size) * uint64(unsafe.Sizeof(_ht{}))) > SQLITE_MALLOC_SOFT_LIMIT { + new_size = (uint32(SQLITE_MALLOC_SOFT_LIMIT / uint64(unsafe.Sizeof(_ht{})))) } if new_size == (*Hash)(unsafe.Pointer(pH)).Fhtsize { return 0 @@ -21937,165 +21613,79 @@ type unix_syscall = struct { // testing and sandboxing. The following array holds the names and pointers // to all overrideable system calls. var aSyscall = [29]unix_syscall{ - { - FzName: ts + 4414, /* "open" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4414 /* "open" */, FpCurrent: 0}, - { - FzName: ts + 4419, /* "close" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4419 /* "close" */, FpCurrent: 0}, - { - FzName: ts + 4425, /* "access" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4425 /* "access" */, FpCurrent: 0}, - { - FzName: ts + 4432, /* "getcwd" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4432 /* "getcwd" */, FpCurrent: 0}, - { - FzName: ts + 4439, /* "stat" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4439 /* "stat" */, FpCurrent: 0}, // The DJGPP compiler environment looks mostly like Unix, but it // lacks the fcntl() system call. So redefine fcntl() to be something // that always succeeds. This means that locking does not occur under // DJGPP. But it is DOS - what did you expect? - { - FzName: ts + 4444, /* "fstat" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4444 /* "fstat" */, FpCurrent: 0}, - { - FzName: ts + 4450, /* "ftruncate" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4450 /* "ftruncate" */, FpCurrent: 0}, - { - FzName: ts + 4460, /* "fcntl" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4460 /* "fcntl" */, FpCurrent: 0}, - { - FzName: ts + 4466, /* "read" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4466 /* "read" */, FpCurrent: 0}, - { - FzName: ts + 4471, /* "pread" */ - FpCurrent: uintptr(0), - FpDefault: uintptr(0)}, + {FzName: ts + 4471 /* "pread" */}, - { - FzName: ts + 4477, /* "pread64" */ - FpCurrent: uintptr(0), - FpDefault: uintptr(0)}, + {FzName: ts + 4477 /* "pread64" */}, - { - FzName: ts + 4485, /* "write" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4485 /* "write" */, FpCurrent: 0}, - { - FzName: ts + 4491, /* "pwrite" */ - FpCurrent: uintptr(0), - FpDefault: uintptr(0)}, + {FzName: ts + 4491 /* "pwrite" */}, - { - FzName: ts + 4498, /* "pwrite64" */ - FpCurrent: uintptr(0), - FpDefault: uintptr(0)}, + {FzName: ts + 4498 /* "pwrite64" */}, - { - FzName: ts + 4507, /* "fchmod" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4507 /* "fchmod" */, FpCurrent: 0}, - { - FzName: ts + 4514, /* "fallocate" */ - FpCurrent: uintptr(0), - FpDefault: uintptr(0)}, + {FzName: ts + 4514 /* "fallocate" */}, - { - FzName: ts + 4524, /* "unlink" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4524 /* "unlink" */, FpCurrent: 0}, - { - FzName: ts + 4531, /* "openDirectory" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4531 /* "openDirectory" */, FpCurrent: 0}, - { - FzName: ts + 4545, /* "mkdir" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4545 /* "mkdir" */, FpCurrent: 0}, - { - FzName: ts + 4551, /* "rmdir" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4551 /* "rmdir" */, FpCurrent: 0}, - { - FzName: ts + 4557, /* "fchown" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4557 /* "fchown" */, FpCurrent: 0}, - { - FzName: ts + 4564, /* "geteuid" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4564 /* "geteuid" */, FpCurrent: 0}, - { - FzName: ts + 4572, /* "mmap" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4572 /* "mmap" */, FpCurrent: 0}, - { - FzName: ts + 4577, /* "munmap" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4577 /* "munmap" */, FpCurrent: 0}, - { - FzName: ts + 4584, /* "mremap" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4584 /* "mremap" */, FpCurrent: 0}, - { - FzName: ts + 4591, /* "getpagesize" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4591 /* "getpagesize" */, FpCurrent: 0}, - { - FzName: ts + 4603, /* "readlink" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4603 /* "readlink" */, FpCurrent: 0}, - { - FzName: ts + 4612, /* "lstat" */ - FpCurrent: 0, - FpDefault: uintptr(0)}, + {FzName: ts + 4612 /* "lstat" */, FpCurrent: 0}, - { - FzName: ts + 4618, /* "ioctl" */ - FpCurrent: uintptr(0), - FpDefault: uintptr(0)}, + {FzName: ts + 4618 /* "ioctl" */}, } /* sqlite3.c:33935:3 */ + // End of the overrideable system calls // On some systems, calls to fchown() will trigger a message in a security // log if they come from non-root processes. So avoid calling fchown() if // we are not running as root. func robustFchown(tls *libc.TLS, fd int32, uid Uid_t, gid Gid_t) int32 { /* sqlite3.c:34105:12: */ - if (*(*func(*libc.TLS) Uid_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(21)*24 + 8 /* &.pCurrent */))))(tls) != 0 { + if (*(*func(*libc.TLS) Uid_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 21*24 + 8 /* &.pCurrent */))))(tls) != 0 { return 0 } - return (*(*func(*libc.TLS, int32, Uid_t, Gid_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(20)*24 + 8 /* &.pCurrent */))))(tls, fd, uid, gid) + return (*(*func(*libc.TLS, int32, Uid_t, Gid_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 20*24 + 8 /* &.pCurrent */))))(tls, fd, uid, gid) } // This is the xSetSystemCall() method of sqlite3_vfs for all of the @@ -22104,13 +21694,13 @@ func robustFchown(tls *libc.TLS, fd int32, uid Uid_t, gid Gid_t) int32 { /* sqli // system call named zName. func unixSetSystemCall(tls *libc.TLS, pNotUsed uintptr, zName uintptr, pNewFunc Sqlite3_syscall_ptr) int32 { /* sqlite3.c:34119:12: */ var i uint32 - var rc int32 = 12 + var rc int32 = SQLITE_NOTFOUND _ = pNotUsed if zName == uintptr(0) { // If no zName is given, restore all system calls to their default // settings and return NULL - rc = 0 + rc = SQLITE_OK for i = uint32(0); uint64(i) < (uint64(unsafe.Sizeof(aSyscall)) / uint64(unsafe.Sizeof(unix_syscall{}))); i++ { if aSyscall[i].FpDefault != 0 { aSyscall[i].FpCurrent = aSyscall[i].FpDefault @@ -22124,7 +21714,7 @@ func unixSetSystemCall(tls *libc.TLS, pNotUsed uintptr, zName uintptr, pNewFunc if aSyscall[i].FpDefault == uintptr(0) { aSyscall[i].FpDefault = aSyscall[i].FpCurrent } - rc = 0 + rc = SQLITE_OK if pNewFunc == uintptr(0) { pNewFunc = aSyscall[i].FpDefault } @@ -22202,24 +21792,24 @@ func robust_open(tls *libc.TLS, z uintptr, f int32, m Mode_t) int32 { /* sqlite3 if m != 0 { m2 = m } else { - m2 = uint32(0644) + m2 = SQLITE_DEFAULT_FILE_PERMISSIONS } for 1 != 0 { - fd = (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(0)*24 + 8 /* &.pCurrent */))))(tls, z, (f | 02000000), int32(m2)) + fd = (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 8 /* &.pCurrent */))))(tls, z, (f | 02000000), int32(m2)) if fd < 0 { - if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 4 { + if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == EINTR { continue } break } - if fd >= 3 { + if fd >= SQLITE_MINIMUM_FILE_DESCRIPTOR { break } - (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(1)*24 + 8 /* &.pCurrent */))))(tls, fd) - Xsqlite3_log(tls, 28, + (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 1*24 + 8 /* &.pCurrent */))))(tls, fd) + Xsqlite3_log(tls, SQLITE_WARNING, ts+4624 /* "attempt to open ..." */, libc.VaList(bp, z, fd)) fd = -1 - if (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(0)*24 + 8 /* &.pCurrent */))))(tls, ts+4667 /* "/dev/null" */, 00, int32(m)) < 0 { + if (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 8 /* &.pCurrent */))))(tls, ts+4667 /* "/dev/null" */, O_RDONLY, int32(m)) < 0 { break } } @@ -22227,10 +21817,10 @@ func robust_open(tls *libc.TLS, z uintptr, f int32, m Mode_t) int32 { /* sqlite3 if m != Mode_t(0) { // var statbuf stat at bp+16, 144 - if (((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, fd, bp+16 /* &statbuf */) == 0) && + if (((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, fd, bp+16 /* &statbuf */) == 0) && ((*stat)(unsafe.Pointer(bp+16 /* &statbuf */)).Fst_size == int64(0))) && (((*stat)(unsafe.Pointer(bp+16 /* &statbuf */)).Fst_mode & X__mode_t(0777)) != m) { - (*(*func(*libc.TLS, int32, Mode_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(14)*24 + 8 /* &.pCurrent */))))(tls, fd, m) + (*(*func(*libc.TLS, int32, Mode_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 14*24 + 8 /* &.pCurrent */))))(tls, fd, m) } } } @@ -22277,15 +21867,15 @@ func unixLeaveMutex(tls *libc.TLS) { /* sqlite3.c:34289:13: */ // integer lock-type. func azFileLock(tls *libc.TLS, eFileLock int32) uintptr { /* sqlite3.c:34306:19: */ switch eFileLock { - case 0: + case NO_LOCK: return ts + 4677 /* "NONE" */ - case 1: + case SHARED_LOCK: return ts + 4682 /* "SHARED" */ - case 2: + case RESERVED_LOCK: return ts + 4689 /* "RESERVED" */ - case 3: + case PENDING_LOCK: return ts + 4698 /* "PENDING" */ - case 4: + case EXCLUSIVE_LOCK: return ts + 4706 /* "EXCLUSIVE" */ } return ts + 4716 /* "ERROR" */ @@ -22298,8 +21888,8 @@ func azFileLock(tls *libc.TLS, eFileLock int32) uintptr { /* sqlite3.c:34306:19: // could lead to a corrupt database. func robust_ftruncate(tls *libc.TLS, h int32, sz Sqlite3_int64) int32 { /* sqlite3.c:34385:12: */ var rc int32 - for ok := true; ok; ok = ((rc < 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 4)) { - rc = (*(*func(*libc.TLS, int32, Off_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(6)*24 + 8 /* &.pCurrent */))))(tls, h, int64(sz)) + for ok := true; ok; ok = ((rc < 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == EINTR)) { + rc = (*(*func(*libc.TLS, int32, Off_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 6*24 + 8 /* &.pCurrent */))))(tls, h, int64(sz)) } return rc } @@ -22315,23 +21905,23 @@ func robust_ftruncate(tls *libc.TLS, h int32, sz Sqlite3_int64) int32 { /* sqlit func sqliteErrorFromPosixError(tls *libc.TLS, posixError int32, sqliteIOErr int32) int32 { /* sqlite3.c:34410:12: */ switch posixError { - case 13: + case EACCES: fallthrough - case 11: + case EAGAIN: fallthrough - case 110: + case ETIMEDOUT: fallthrough - case 16: + case EBUSY: fallthrough - case 4: + case EINTR: fallthrough - case 37: + case ENOLCK: // random NFS retry error, unless during file system support // introspection, in which it actually means what it says - return 5 + return SQLITE_BUSY - case 1: - return 3 + case EPERM: + return SQLITE_PERM default: return sqliteIOErr @@ -22468,6 +22058,7 @@ type unixFileId = struct { // // Must hold unixBigLock in order to read or write this variable. var inodeList uintptr = uintptr(0) /* sqlite3.c:34734:22 */ + // All unixInodeInfo objects // @@ -22519,8 +22110,8 @@ func unixLogErrorAtLine(tls *libc.TLS, errcode int32, zFunc uintptr, zPath uintp // So we don't even try to recover from an EINTR. Just log the error // and move on. func robust_close(tls *libc.TLS, pFile uintptr, h int32, lineno int32) { /* sqlite3.c:34834:13: */ - if (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(1)*24 + 8 /* &.pCurrent */))))(tls, h) != 0 { - unixLogErrorAtLine(tls, (10 | (int32(16) << 8)), ts+4419, /* "close" */ + if (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 1*24 + 8 /* &.pCurrent */))))(tls, h) != 0 { + unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(16) << 8)), ts+4419, /* "close" */ func() uintptr { if pFile != 0 { return (*UnixFile)(unsafe.Pointer(pFile)).FzPath @@ -22603,10 +22194,10 @@ func findInodeInfo(tls *libc.TLS, pFile uintptr, ppInode uintptr) int32 { /* sql // Get low-level information about the file that we can used to // create a unique name for the file. fd = (*UnixFile)(unsafe.Pointer(pFile)).Fh - rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, fd, bp /* &statbuf */) + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, fd, bp /* &statbuf */) if rc != 0 { storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - return 10 + return SQLITE_IOERR } libc.Xmemset(tls, bp+144 /* &fileId */, 0, uint64(unsafe.Sizeof(unixFileId{}))) @@ -22620,15 +22211,15 @@ func findInodeInfo(tls *libc.TLS, pFile uintptr, ppInode uintptr) int32 { /* sql if pInode == uintptr(0) { pInode = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(UnixInodeInfo{}))) if pInode == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pInode, 0, uint64(unsafe.Sizeof(UnixInodeInfo{}))) libc.Xmemcpy(tls, (pInode /* &.fileId */), bp+144 /* &fileId */, uint64(unsafe.Sizeof(unixFileId{}))) if Xsqlite3Config.FbCoreMutex != 0 { - (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex = Xsqlite3_mutex_alloc(tls, 0) + (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST) if (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex == uintptr(0) { Xsqlite3_free(tls, pInode) - return 7 + return SQLITE_NOMEM } } (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnRef = 1 @@ -22643,7 +22234,7 @@ func findInodeInfo(tls *libc.TLS, pFile uintptr, ppInode uintptr) int32 { /* sql (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnRef++ } *(*uintptr)(unsafe.Pointer(ppInode)) = pInode - return 0 + return SQLITE_OK } // Return TRUE if pFile has been renamed or unlinked since it was first opened. @@ -22653,7 +22244,7 @@ func fileHasMoved(tls *libc.TLS, pFile uintptr) int32 { /* sqlite3.c:35000:12: * // var buf stat at bp, 144 - return (libc.Bool32(((*UnixFile)(unsafe.Pointer(pFile)).FpInode != uintptr(0)) && (((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(4)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, bp /* &buf */) != 0) || + return (libc.Bool32(((*UnixFile)(unsafe.Pointer(pFile)).FpInode != uintptr(0)) && (((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 4*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, bp /* &buf */) != 0) || (U64((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_ino) != (*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FfileId.Fino)))) } @@ -22673,25 +22264,25 @@ func verifyDbFile(tls *libc.TLS, pFile uintptr) { /* sqlite3.c:35021:13: */ var rc int32 // These verifications occurs for the main database only - if (int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags) & 0x80) != 0 { + if (int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags) & UNIXFILE_NOLOCK) != 0 { return } - rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, bp+32 /* &buf */) + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, bp+32 /* &buf */) if rc != 0 { - Xsqlite3_log(tls, 28, ts+4753 /* "cannot fstat db ..." */, libc.VaList(bp, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) + Xsqlite3_log(tls, SQLITE_WARNING, ts+4753 /* "cannot fstat db ..." */, libc.VaList(bp, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) return } if (*stat)(unsafe.Pointer(bp+32 /* &buf */)).Fst_nlink == uint64(0) { - Xsqlite3_log(tls, 28, ts+4777 /* "file unlinked wh..." */, libc.VaList(bp+8, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) + Xsqlite3_log(tls, SQLITE_WARNING, ts+4777 /* "file unlinked wh..." */, libc.VaList(bp+8, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) return } if (*stat)(unsafe.Pointer(bp+32 /* &buf */)).Fst_nlink > uint64(1) { - Xsqlite3_log(tls, 28, ts+4806 /* "multiple links t..." */, libc.VaList(bp+16, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) + Xsqlite3_log(tls, SQLITE_WARNING, ts+4806 /* "multiple links t..." */, libc.VaList(bp+16, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) return } if fileHasMoved(tls, pFile) != 0 { - Xsqlite3_log(tls, 28, ts+4833 /* "file renamed whi..." */, libc.VaList(bp+24, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) + Xsqlite3_log(tls, SQLITE_WARNING, ts+4833 /* "file renamed whi..." */, libc.VaList(bp+24, (*UnixFile)(unsafe.Pointer(pFile)).FzPath)) return } } @@ -22704,19 +22295,19 @@ func unixCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int32 { / bp := tls.Alloc(64) defer tls.Free(64) - var rc int32 = 0 + var rc int32 = SQLITE_OK var reserved int32 = 0 var pFile uintptr = id if ((Xsqlite3_io_error_persist != 0) && (Xsqlite3_io_error_hit != 0)) || (libc.PostDecAtomicInt32(&Xsqlite3_io_error_pending, 1) == 1) { local_ioerr(tls) - return (10 | (int32(14) << 8)) + return (SQLITE_IOERR | (int32(14) << 8)) } Xsqlite3_mutex_enter(tls, (*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FpLockMutex) // Check if a thread in this process holds such a lock - if int32((*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FeFileLock) > 1 { + if int32((*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FeFileLock) > SHARED_LOCK { reserved = 1 } @@ -22724,14 +22315,14 @@ func unixCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int32 { / if !(reserved != 0) && !(int32((*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FbProcessLock) != 0) { // var lock flock at bp+32, 32 - (*flock)(unsafe.Pointer(bp + 32 /* &lock */)).Fl_whence = int16(0) + (*flock)(unsafe.Pointer(bp + 32 /* &lock */)).Fl_whence = SEEK_SET (*flock)(unsafe.Pointer(bp + 32 /* &lock */)).Fl_start = (X__off64_t(Xsqlite3PendingByte + 1)) (*flock)(unsafe.Pointer(bp + 32 /* &lock */)).Fl_len = int64(1) - (*flock)(unsafe.Pointer(bp + 32 /* &lock */)).Fl_type = int16(1) - if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(7)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, 5, libc.VaList(bp, bp+32 /* &lock */)) != 0 { - rc = (10 | (int32(14) << 8)) + (*flock)(unsafe.Pointer(bp + 32 /* &lock */)).Fl_type = F_WRLCK + if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 7*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, F_GETLK64, libc.VaList(bp, bp+32 /* &lock */)) != 0 { + rc = (SQLITE_IOERR | (int32(14) << 8)) storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - } else if int32((*flock)(unsafe.Pointer(bp+32 /* &lock */)).Fl_type) != 2 { + } else if int32((*flock)(unsafe.Pointer(bp+32 /* &lock */)).Fl_type) != F_UNLCK { reserved = 1 } } @@ -22781,15 +22372,15 @@ func unixFileLock(tls *libc.TLS, pFile uintptr, pLock uintptr) int32 { /* sqlite var rc int32 var pInode uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FpInode - if (int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags) & (0x01 | 0x02)) == 0x01 { + if (int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags) & (UNIXFILE_EXCL | UNIXFILE_RDONLY)) == UNIXFILE_EXCL { if int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FbProcessLock) == 0 { // var lock flock at bp+16, 32 - (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_whence = int16(0) + (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_whence = SEEK_SET (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_start = (X__off64_t(Xsqlite3PendingByte + 2)) - (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_len = int64(510) - (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_type = int16(1) - rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(7)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, 6, libc.VaList(bp, bp+16 /* &lock */)) + (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_len = SHARED_SIZE + (*flock)(unsafe.Pointer(bp + 16 /* &lock */)).Fl_type = F_WRLCK + rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 7*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, F_SETLK64, libc.VaList(bp, bp+16 /* &lock */)) if rc < 0 { return rc } @@ -22799,7 +22390,7 @@ func unixFileLock(tls *libc.TLS, pFile uintptr, pLock uintptr) int32 { /* sqlite rc = 0 } } else { - rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(7)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, 6, libc.VaList(bp+8, pLock)) + rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 7*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, F_SETLK64, libc.VaList(bp+8, pLock)) } return rc } @@ -22874,7 +22465,7 @@ func unixLock(tls *libc.TLS, id uintptr, eFileLock int32) int32 { /* sqlite3.c:3 // var lock flock at bp+88, 32 var tErrno int32 - rc = 0 + rc = SQLITE_OK pFile = id tErrno = 0 @@ -22897,7 +22488,7 @@ __1: Xsqlite3DebugPrintf(tls, ts+4934 /* "LOCK %d %s ok..." */, libc.VaList(bp+48, (*UnixFile)(unsafe.Pointer(pFile)).Fh, azFileLock(tls, eFileLock))) __3: ; - return 0 + return SQLITE_OK __2: ; @@ -22912,10 +22503,10 @@ __2: // If some thread using this PID has a lock via a different unixFile* // handle that precludes the requested lock, return BUSY. - if !((int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) != int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock)) && ((int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) >= 3) || (eFileLock > 1))) { + if !((int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) != int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock)) && ((int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) >= PENDING_LOCK) || (eFileLock > SHARED_LOCK))) { goto __4 } - rc = 5 + rc = SQLITE_BUSY goto end_lock __4: ; @@ -22923,11 +22514,11 @@ __4: // If a SHARED lock is requested, and some thread using this PID already // has a SHARED or RESERVED lock, then increment reference counts and // return SQLITE_OK. - if !((eFileLock == 1) && ((int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == 1) || (int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == 2))) { + if !((eFileLock == SHARED_LOCK) && ((int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == SHARED_LOCK) || (int32((*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock) == RESERVED_LOCK))) { goto __5 } - (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(1) + (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = SHARED_LOCK (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared++ (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnLock++ goto end_lock @@ -22938,24 +22529,24 @@ __5: // acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will // be released. (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_len = 1 - (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_whence = int16(0) - if !((eFileLock == 1) || - ((eFileLock == 4) && (int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) < 3))) { + (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_whence = SEEK_SET + if !((eFileLock == SHARED_LOCK) || + ((eFileLock == EXCLUSIVE_LOCK) && (int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) < PENDING_LOCK))) { goto __6 } (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_type = func() int16 { - if eFileLock == 1 { - return int16(0) + if eFileLock == SHARED_LOCK { + return F_RDLCK } - return int16(1) + return F_WRLCK }() (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_start = X__off64_t(Xsqlite3PendingByte) if !(unixFileLock(tls, pFile, bp+88 /* &lock */) != 0) { goto __7 } tErrno = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) - rc = sqliteErrorFromPosixError(tls, tErrno, (10 | (int32(15) << 8))) - if !(rc != 5) { + rc = sqliteErrorFromPosixError(tls, tErrno, (SQLITE_IOERR | (int32(15) << 8))) + if !(rc != SQLITE_BUSY) { goto __8 } storeLastErrno(tls, pFile, tErrno) @@ -22969,38 +22560,38 @@ __6: // If control gets to this point, then actually go ahead and make // operating system calls for the specified lock. - if !(eFileLock == 1) { + if !(eFileLock == SHARED_LOCK) { goto __9 } // Now get the read-lock (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_start = (X__off64_t(Xsqlite3PendingByte + 2)) - (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_len = int64(510) + (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_len = SHARED_SIZE if !(unixFileLock(tls, pFile, bp+88 /* &lock */) != 0) { goto __11 } tErrno = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) - rc = sqliteErrorFromPosixError(tls, tErrno, (10 | (int32(15) << 8))) + rc = sqliteErrorFromPosixError(tls, tErrno, (SQLITE_IOERR | (int32(15) << 8))) __11: ; // Drop the temporary PENDING lock (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_start = X__off64_t(Xsqlite3PendingByte) (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_len = 1 - (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_type = int16(2) - if !((unixFileLock(tls, pFile, bp+88 /* &lock */) != 0) && (rc == 0)) { + (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_type = F_UNLCK + if !((unixFileLock(tls, pFile, bp+88 /* &lock */) != 0) && (rc == SQLITE_OK)) { goto __12 } // This could happen with a network mount tErrno = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) - rc = (10 | (int32(8) << 8)) + rc = (SQLITE_IOERR | (int32(8) << 8)) __12: ; if !(rc != 0) { goto __13 } - if !(rc != 5) { + if !(rc != SQLITE_BUSY) { goto __15 } storeLastErrno(tls, pFile, tErrno) @@ -23009,28 +22600,28 @@ __15: goto end_lock goto __14 __13: - (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(1) + (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = SHARED_LOCK (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnLock++ (*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared = 1 __14: ; goto __10 __9: - if !((eFileLock == 4) && ((*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared > 1)) { + if !((eFileLock == EXCLUSIVE_LOCK) && ((*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared > 1)) { goto __16 } // We are trying for an exclusive lock but another thread in this // same process is still holding a shared lock. - rc = 5 + rc = SQLITE_BUSY goto __17 __16: // The request was for a RESERVED or EXCLUSIVE lock. It is // assumed that there is a SHARED or greater lock on the file // already. ; - (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_type = int16(1) + (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_type = F_WRLCK - if !(eFileLock == 2) { + if !(eFileLock == RESERVED_LOCK) { goto __18 } (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_start = (X__off64_t(Xsqlite3PendingByte + 1)) @@ -23038,7 +22629,7 @@ __16: goto __19 __18: (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_start = (X__off64_t(Xsqlite3PendingByte + 2)) - (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_len = int64(510) + (*flock)(unsafe.Pointer(bp + 88 /* &lock */)).Fl_len = SHARED_SIZE __19: ; @@ -23046,8 +22637,8 @@ __19: goto __20 } tErrno = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) - rc = sqliteErrorFromPosixError(tls, tErrno, (10 | (int32(15) << 8))) - if !(rc != 5) { + rc = sqliteErrorFromPosixError(tls, tErrno, (SQLITE_IOERR | (int32(15) << 8))) + if !(rc != SQLITE_BUSY) { goto __21 } storeLastErrno(tls, pFile, tErrno) @@ -23060,18 +22651,18 @@ __17: __10: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __22 } (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(eFileLock) (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(eFileLock) goto __23 __22: - if !(eFileLock == 4) { + if !(eFileLock == EXCLUSIVE_LOCK) { goto __24 } - (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(3) - (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(3) + (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = PENDING_LOCK + (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = PENDING_LOCK __24: ; __23: @@ -23083,7 +22674,7 @@ end_lock: goto __25 } Xsqlite3DebugPrintf(tls, ts+4974 /* "LOCK %d %s %s..." */, libc.VaList(bp+64, (*UnixFile)(unsafe.Pointer(pFile)).Fh, azFileLock(tls, eFileLock), func() uintptr { - if rc == 0 { + if rc == SQLITE_OK { return ts + 4999 /* "ok" */ } return ts + 5002 /* "failed" */ @@ -23126,7 +22717,7 @@ func posixUnlock(tls *libc.TLS, id uintptr, eFileLock int32, handleNFSUnlock int var rc int32 pFile = id - rc = 0 + rc = SQLITE_OK if !(Xsqlite3OSTrace != 0) { goto __1 @@ -23138,13 +22729,13 @@ __1: if !(int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) <= eFileLock) { goto __2 } - return 0 + return SQLITE_OK __2: ; pInode = (*UnixFile)(unsafe.Pointer(pFile)).FpInode Xsqlite3_mutex_enter(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) - if !(int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) > 1) { + if !(int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) > SHARED_LOCK) { goto __3 } @@ -23156,15 +22747,15 @@ __2: // 2: [....W] // 3: [RRRRW] // 4: [RRRR.] - if !(eFileLock == 1) { + if !(eFileLock == SHARED_LOCK) { goto __4 } _ = handleNFSUnlock - (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_type = int16(0) - (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_whence = int16(0) + (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_type = F_RDLCK + (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_whence = SEEK_SET (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_start = (X__off64_t(Xsqlite3PendingByte + 2)) - (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_len = int64(510) + (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_len = SHARED_SIZE if !(unixFileLock(tls, pFile, bp+48 /* &lock */) != 0) { goto __5 } @@ -23174,7 +22765,7 @@ __2: // protocol. If this happens, return SQLITE_IOERR_RDLOCK. Returning // SQLITE_BUSY would confuse the upper layer (in practice it causes // an assert to fail). - rc = (10 | (int32(9) << 8)) + rc = (SQLITE_IOERR | (int32(9) << 8)) storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) goto end_unlock __5: @@ -23182,24 +22773,24 @@ __5: __4: ; - (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_type = int16(2) - (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_whence = int16(0) + (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_type = F_UNLCK + (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_whence = SEEK_SET (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_start = X__off64_t(Xsqlite3PendingByte) (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_len = 2 if !(unixFileLock(tls, pFile, bp+48 /* &lock */) == 0) { goto __6 } - (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(1) + (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = SHARED_LOCK goto __7 __6: - rc = (10 | (int32(8) << 8)) + rc = (SQLITE_IOERR | (int32(8) << 8)) storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) goto end_unlock __7: ; __3: ; - if !(eFileLock == 0) { + if !(eFileLock == NO_LOCK) { goto __8 } // Decrement the shared lock counter. Release the lock using an @@ -23209,19 +22800,19 @@ __3: if !((*UnixInodeInfo)(unsafe.Pointer(pInode)).FnShared == 0) { goto __9 } - (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_type = int16(2) - (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_whence = int16(0) + (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_type = F_UNLCK + (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_whence = SEEK_SET (*flock)(unsafe.Pointer(bp + 48 /* &lock */)).Fl_start = libc.AssignPtrInt64(bp+48 /* &lock */ +16 /* &.l_len */, 0) if !(unixFileLock(tls, pFile, bp+48 /* &lock */) == 0) { goto __10 } - (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(0) + (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = NO_LOCK goto __11 __10: - rc = (10 | (int32(8) << 8)) + rc = (SQLITE_IOERR | (int32(8) << 8)) storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(0) - (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(0) + (*UnixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = NO_LOCK + (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = NO_LOCK __11: ; __9: @@ -23243,7 +22834,7 @@ __8: end_unlock: Xsqlite3_mutex_leave(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __13 } (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(eFileLock) @@ -23286,17 +22877,17 @@ func closeUnixFile(tls *libc.TLS, id uintptr) int32 { /* sqlite3.c:35634:12: */ libc.AtomicAddInt32(&Xsqlite3_open_file_count, int32(-1)) Xsqlite3_free(tls, (*UnixFile)(unsafe.Pointer(pFile)).FpPreallocatedUnused) libc.Xmemset(tls, pFile, 0, uint64(unsafe.Sizeof(UnixFile{}))) - return 0 + return SQLITE_OK } // Close a file. func unixClose(tls *libc.TLS, id uintptr) int32 { /* sqlite3.c:35669:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pFile uintptr = id var pInode uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FpInode verifyDbFile(tls, pFile) - unixUnlock(tls, id, 0) + unixUnlock(tls, id, NO_LOCK) unixEnterMutex(tls) @@ -23342,19 +22933,19 @@ func unixClose(tls *libc.TLS, id uintptr) int32 { /* sqlite3.c:35669:12: */ func nolockCheckReservedLock(tls *libc.TLS, NotUsed uintptr, pResOut uintptr) int32 { /* sqlite3.c:35720:12: */ _ = NotUsed *(*int32)(unsafe.Pointer(pResOut)) = 0 - return 0 + return SQLITE_OK } func nolockLock(tls *libc.TLS, NotUsed uintptr, NotUsed2 int32) int32 { /* sqlite3.c:35725:12: */ _ = NotUsed _ = NotUsed2 - return 0 + return SQLITE_OK } func nolockUnlock(tls *libc.TLS, NotUsed uintptr, NotUsed2 int32) int32 { /* sqlite3.c:35729:12: */ _ = NotUsed _ = NotUsed2 - return 0 + return SQLITE_OK } // Close the file. @@ -23403,16 +22994,16 @@ func dotlockCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int32 bp := tls.Alloc(24) defer tls.Free(24) - var rc int32 = 0 + var rc int32 = SQLITE_OK var reserved int32 = 0 var pFile uintptr = id if ((Xsqlite3_io_error_persist != 0) && (Xsqlite3_io_error_hit != 0)) || (libc.PostDecAtomicInt32(&Xsqlite3_io_error_pending, 1) == 1) { local_ioerr(tls) - return (10 | (int32(14) << 8)) + return (SQLITE_IOERR | (int32(14) << 8)) } - reserved = (libc.Bool32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(2)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FlockingContext, 0) == 0)) + reserved = (libc.Bool32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 2*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FlockingContext, 0) == 0)) if Xsqlite3OSTrace != 0 { Xsqlite3DebugPrintf(tls, ts+5066 /* "TEST WR-LOCK %d ..." */, libc.VaList(bp, (*UnixFile)(unsafe.Pointer(pFile)).Fh, rc, reserved)) } @@ -23448,27 +23039,27 @@ func dotlockCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) int32 func dotlockLock(tls *libc.TLS, id uintptr, eFileLock int32) int32 { /* sqlite3.c:35823:12: */ var pFile uintptr = id var zLockFile uintptr = (*UnixFile)(unsafe.Pointer(pFile)).FlockingContext - var rc int32 = 0 + var rc int32 = SQLITE_OK // If we have any lock, then the lock file already exists. All we have // to do is adjust our internal record of the lock level. - if int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) > 0 { + if int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) > NO_LOCK { (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(eFileLock) // Always update the timestamp on the old file libc.Xutimes(tls, zLockFile, uintptr(0)) - return 0 + return SQLITE_OK } // grab an exclusive lock - rc = (*(*func(*libc.TLS, uintptr, Mode_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(18)*24 + 8 /* &.pCurrent */))))(tls, zLockFile, uint32(0777)) + rc = (*(*func(*libc.TLS, uintptr, Mode_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 18*24 + 8 /* &.pCurrent */))))(tls, zLockFile, uint32(0777)) if rc < 0 { // failed to open/create the lock directory var tErrno int32 = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) - if 17 == tErrno { - rc = 5 + if EEXIST == tErrno { + rc = SQLITE_BUSY } else { - rc = sqliteErrorFromPosixError(tls, tErrno, (10 | (int32(15) << 8))) - if rc != 5 { + rc = sqliteErrorFromPosixError(tls, tErrno, (SQLITE_IOERR | (int32(15) << 8))) + if rc != SQLITE_BUSY { storeLastErrno(tls, pFile, tErrno) } } @@ -23501,38 +23092,38 @@ func dotlockUnlock(tls *libc.TLS, id uintptr, eFileLock int32) int32 { /* sqlite // no-op if possible if int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) == eFileLock { - return 0 + return SQLITE_OK } // To downgrade to shared, simply update our internal notion of the // lock state. No need to mess with the file on disk. - if eFileLock == 1 { - (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(1) - return 0 + if eFileLock == SHARED_LOCK { + (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = SHARED_LOCK + return SQLITE_OK } // To fully unlock the database, delete the lock file - rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(19)*24 + 8 /* &.pCurrent */))))(tls, zLockFile) + rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 19*24 + 8 /* &.pCurrent */))))(tls, zLockFile) if rc < 0 { var tErrno int32 = *(*int32)(unsafe.Pointer(libc.X__errno_location(tls))) - if tErrno == 2 { - rc = 0 + if tErrno == ENOENT { + rc = SQLITE_OK } else { - rc = (10 | (int32(8) << 8)) + rc = (SQLITE_IOERR | (int32(8) << 8)) storeLastErrno(tls, pFile, tErrno) } return rc } - (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(0) - return 0 + (*UnixFile)(unsafe.Pointer(pFile)).FeFileLock = NO_LOCK + return SQLITE_OK } // Close a file. Make sure the lock has been released before closing. func dotlockClose(tls *libc.TLS, id uintptr) int32 { /* sqlite3.c:35916:12: */ var pFile uintptr = id - dotlockUnlock(tls, id, 0) + dotlockUnlock(tls, id, NO_LOCK) Xsqlite3_free(tls, (*UnixFile)(unsafe.Pointer(pFile)).FlockingContext) return closeUnixFile(tls, id) } @@ -23637,7 +23228,7 @@ func seekAndRead(tls *libc.TLS, id uintptr, offset Sqlite3_int64, pBuf uintptr, var newOffset I64 for ok := true; ok; ok = (got > 0) { - newOffset = I64(libc.Xlseek(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, int64(offset), 0)) + newOffset = I64(libc.Xlseek(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, int64(offset), SEEK_SET)) if ((Xsqlite3_io_error_persist != 0) && (Xsqlite3_io_error_hit != 0)) || (libc.PostDecAtomicInt32(&Xsqlite3_io_error_pending, 1) == 1) { local_ioerr(tls) newOffset = int64(-1) @@ -23647,12 +23238,12 @@ func seekAndRead(tls *libc.TLS, id uintptr, offset Sqlite3_int64, pBuf uintptr, storeLastErrno(tls, id, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) return -1 } - got = int32((*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(8)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, pBuf, uint64(cnt))) + got = int32((*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 8*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, pBuf, uint64(cnt))) if got == cnt { break } if got < 0 { - if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 4 { + if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == EINTR { got = 1 continue } @@ -23688,7 +23279,7 @@ func unixRead(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Sqlite3 if offset < (*UnixFile)(unsafe.Pointer(pFile)).FmmapSize { if (offset + Sqlite3_int64(amt)) <= (*UnixFile)(unsafe.Pointer(pFile)).FmmapSize { libc.Xmemcpy(tls, pBuf, (((*UnixFile)(unsafe.Pointer(pFile)).FpMapRegion) + uintptr(offset)), uint64(amt)) - return 0 + return SQLITE_OK } else { var nCopy int32 = (int32((*UnixFile)(unsafe.Pointer(pFile)).FmmapSize - offset)) libc.Xmemcpy(tls, pBuf, (((*UnixFile)(unsafe.Pointer(pFile)).FpMapRegion) + uintptr(offset)), uint64(nCopy)) @@ -23700,15 +23291,15 @@ func unixRead(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Sqlite3 got = seekAndRead(tls, pFile, offset, pBuf, amt) if got == amt { - return 0 + return SQLITE_OK } else if got < 0 { // lastErrno set by seekAndRead - return (10 | (int32(1) << 8)) + return (SQLITE_IOERR | (int32(1) << 8)) } else { storeLastErrno(tls, pFile, 0) // not a system error // Unread parts of the buffer must be zero-filled libc.Xmemset(tls, ((pBuf) + uintptr(got)), 0, (uint64(amt - got))) - return (10 | (int32(2) << 8)) + return (SQLITE_IOERR | (int32(2) << 8)) } return int32(0) } @@ -23726,8 +23317,8 @@ func seekAndWriteFd(tls *libc.TLS, fd int32, iOff I64, pBuf uintptr, nBuf int32, nBuf = nBuf & (0x1ffff) - for ok := true; ok; ok = ((rc < 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 4)) { - var iSeek I64 = I64(libc.Xlseek(tls, fd, int64(iOff), 0)) + for ok := true; ok; ok = ((rc < 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == EINTR)) { + var iSeek I64 = I64(libc.Xlseek(tls, fd, int64(iOff), SEEK_SET)) if ((Xsqlite3_io_error_persist != 0) && (Xsqlite3_io_error_hit != 0)) || (libc.PostDecAtomicInt32(&Xsqlite3_io_error_pending, 1) == 1) { local_ioerr(tls) iSeek = int64(-1) @@ -23737,7 +23328,7 @@ func seekAndWriteFd(tls *libc.TLS, fd int32, iOff I64, pBuf uintptr, nBuf int32, rc = -1 break } - rc = int32((*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(11)*24 + 8 /* &.pCurrent */))))(tls, fd, pBuf, uint64(nBuf))) + rc = int32((*(*func(*libc.TLS, int32, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 11*24 + 8 /* &.pCurrent */))))(tls, fd, pBuf, uint64(nBuf))) } if Xsqlite3OSTrace != 0 { @@ -23792,16 +23383,16 @@ func unixWrite(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Sqlite } if amt > wrote { - if (wrote < 0) && ((*UnixFile)(unsafe.Pointer(pFile)).FlastErrno != 28) { + if (wrote < 0) && ((*UnixFile)(unsafe.Pointer(pFile)).FlastErrno != ENOSPC) { // lastErrno set by seekAndWrite - return (10 | (int32(3) << 8)) + return (SQLITE_IOERR | (int32(3) << 8)) } else { storeLastErrno(tls, pFile, 0) // not a system error - return 13 + return SQLITE_FULL } } - return 0 + return SQLITE_OK } // Count the number of fullsyncs and normal syncs. This is used to test @@ -23898,18 +23489,18 @@ func openDirectory(tls *libc.TLS, zFilename uintptr, pFd uintptr) int32 { /* sql var fd int32 = -1 // var zDirname [513]int8 at bp+24, 513 - Xsqlite3_snprintf(tls, 512, bp+24 /* &zDirname[0] */, ts+824 /* "%s" */, libc.VaList(bp, zFilename)) + Xsqlite3_snprintf(tls, MAX_PATHNAME, bp+24 /* &zDirname[0] */, ts+824 /* "%s" */, libc.VaList(bp, zFilename)) for ii = int32(libc.Xstrlen(tls, bp+24 /* &zDirname[0] */)); (ii > 0) && (int32(*(*int8)(unsafe.Pointer(bp + 24 /* &zDirname[0] */ + uintptr(ii)))) != '/'); ii-- { } if ii > 0 { *(*int8)(unsafe.Pointer(bp + 24 /* &zDirname[0] */ + uintptr(ii))) = int8(0) } else { - if int32(*(*int8)(unsafe.Pointer(bp + 24 /* &zDirname[0] */ + uintptr(0)))) != '/' { - *(*int8)(unsafe.Pointer(bp + 24 /* &zDirname[0] */ + uintptr(0))) = int8('.') + if int32(*(*int8)(unsafe.Pointer(bp + 24 /* &zDirname[0] */))) != '/' { + *(*int8)(unsafe.Pointer(bp + 24 /* &zDirname[0] */)) = int8('.') } - *(*int8)(unsafe.Pointer(bp + 24 /* &zDirname[0] */ + uintptr(1))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 24 /* &zDirname[0] */ + 1)) = int8(0) } - fd = robust_open(tls, bp+24 /* &zDirname[0] */, (00 | 0), uint32(0)) + fd = robust_open(tls, bp+24 /* &zDirname[0] */, (O_RDONLY | O_BINARY), uint32(0)) if fd >= 0 { if Xsqlite3OSTrace != 0 { Xsqlite3DebugPrintf(tls, ts+5196 /* "OPENDIR %-3d %s\n" */, libc.VaList(bp+8, fd, bp+24 /* &zDirname[0] */)) @@ -23917,7 +23508,7 @@ func openDirectory(tls *libc.TLS, zFilename uintptr, pFd uintptr) int32 { /* sql } *(*int32)(unsafe.Pointer(pFd)) = fd if fd >= 0 { - return 0 + return SQLITE_OK } return unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 37243), ts+4531 /* "openDirectory" */, bp+24 /* &zDirname[0] */, 37243) } @@ -23942,8 +23533,8 @@ func unixSync(tls *libc.TLS, id uintptr, flags int32) int32 { /* sqlite3.c:37261 var rc int32 var pFile uintptr = id - var isDataOnly int32 = (flags & 0x00010) - var isFullsync int32 = (libc.Bool32((flags & 0x0F) == 0x00003)) + var isDataOnly int32 = (flags & SQLITE_SYNC_DATAONLY) + var isFullsync int32 = (libc.Bool32((flags & 0x0F) == SQLITE_SYNC_FULL)) // Check that one of SQLITE_SYNC_NORMAL or FULL was passed @@ -23954,7 +23545,7 @@ func unixSync(tls *libc.TLS, id uintptr, flags int32) int32 { /* sqlite3.c:37261 local_ioerr(tls) Xsqlite3_diskfull = 1 Xsqlite3_io_error_hit = 1 - return 13 + return SQLITE_FULL } else { Xsqlite3_diskfull_pending-- } @@ -23971,27 +23562,27 @@ func unixSync(tls *libc.TLS, id uintptr, flags int32) int32 { /* sqlite3.c:37261 if rc != 0 { storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - return unixLogErrorAtLine(tls, (10 | (int32(4) << 8)), ts+5227 /* "full_fsync" */, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 37284) + return unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(4) << 8)), ts+5227 /* "full_fsync" */, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 37284) } // Also fsync the directory containing the file if the DIRSYNC flag // is set. This is a one-time occurrence. Many systems (examples: AIX) // are unable to fsync a directory, so ignore errors on the fsync. - if (int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags) & 0x08) != 0 { + if (int32((*UnixFile)(unsafe.Pointer(pFile)).FctrlFlags) & UNIXFILE_DIRSYNC) != 0 { // var dirfd int32 at bp+32, 4 if Xsqlite3OSTrace != 0 { - Xsqlite3DebugPrintf(tls, ts+5238 /* "DIRSYNC %s (have..." */, libc.VaList(bp+8, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 0, isFullsync)) + Xsqlite3DebugPrintf(tls, ts+5238 /* "DIRSYNC %s (have..." */, libc.VaList(bp+8, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, HAVE_FULLFSYNC, isFullsync)) } - rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(17)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, bp+32 /* &dirfd */) - if rc == 0 { + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 17*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, bp+32 /* &dirfd */) + if rc == SQLITE_OK { full_fsync(tls, *(*int32)(unsafe.Pointer(bp + 32 /* dirfd */)), 0, 0) robust_close(tls, pFile, *(*int32)(unsafe.Pointer(bp + 32 /* dirfd */)), 37298) } else { - rc = 0 + rc = SQLITE_OK } - *(*uint16)(unsafe.Pointer(pFile + 30 /* &.ctrlFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x08))) + *(*uint16)(unsafe.Pointer(pFile + 30 /* &.ctrlFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(UNIXFILE_DIRSYNC))) } return rc } @@ -24003,7 +23594,7 @@ func unixTruncate(tls *libc.TLS, id uintptr, nByte I64) int32 { /* sqlite3.c:373 if ((Xsqlite3_io_error_persist != 0) && (Xsqlite3_io_error_hit != 0)) || (libc.PostDecAtomicInt32(&Xsqlite3_io_error_pending, 1) == 1) { local_ioerr(tls) - return (10 | (int32(6) << 8)) + return (SQLITE_IOERR | (int32(6) << 8)) } // If the user has configured a chunk-size for this file, truncate the @@ -24017,7 +23608,7 @@ func unixTruncate(tls *libc.TLS, id uintptr, nByte I64) int32 { /* sqlite3.c:373 rc = robust_ftruncate(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, nByte) if rc != 0 { storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - return unixLogErrorAtLine(tls, (10 | (int32(6) << 8)), ts+4450 /* "ftruncate" */, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 37329) + return unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(6) << 8)), ts+4450 /* "ftruncate" */, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 37329) } else { // If the file was just truncated to a size smaller than the currently @@ -24027,7 +23618,7 @@ func unixTruncate(tls *libc.TLS, id uintptr, nByte I64) int32 { /* sqlite3.c:373 (*UnixFile)(unsafe.Pointer(pFile)).FmmapSize = nByte } - return 0 + return SQLITE_OK } return int32(0) } @@ -24040,7 +23631,7 @@ func unixFileSize(tls *libc.TLS, id uintptr, pSize uintptr) int32 { /* sqlite3.c var rc int32 // var buf stat at bp, 144 - rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, bp /* &buf */) + rc = (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(id)).Fh, bp /* &buf */) if ((Xsqlite3_io_error_persist != 0) && (Xsqlite3_io_error_hit != 0)) || (libc.PostDecAtomicInt32(&Xsqlite3_io_error_pending, 1) == 1) { local_ioerr(tls) rc = 1 @@ -24048,7 +23639,7 @@ func unixFileSize(tls *libc.TLS, id uintptr, pSize uintptr) int32 { /* sqlite3.c if rc != 0 { storeLastErrno(tls, id, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - return (10 | (int32(7) << 8)) + return (SQLITE_IOERR | (int32(7) << 8)) } *(*I64)(unsafe.Pointer(pSize)) = I64((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_size) @@ -24061,7 +23652,7 @@ func unixFileSize(tls *libc.TLS, id uintptr, pSize uintptr) int32 { /* sqlite3.c *(*I64)(unsafe.Pointer(pSize)) = int64(0) } - return 0 + return SQLITE_OK } // This function is called to handle the SQLITE_FCNTL_SIZE_HINT @@ -24077,8 +23668,8 @@ func fcntlSizeHint(tls *libc.TLS, pFile uintptr, nByte I64) int32 { /* sqlite3.c // var buf stat at bp, 144 // Used to hold return values of fstat() - if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, bp /* &buf */) != 0 { - return (10 | (int32(7) << 8)) + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, bp /* &buf */) != 0 { + return (SQLITE_IOERR | (int32(7) << 8)) } nSize = ((((nByte + I64((*UnixFile)(unsafe.Pointer(pFile)).FszChunk)) - int64(1)) / I64((*UnixFile)(unsafe.Pointer(pFile)).FszChunk)) * I64((*UnixFile)(unsafe.Pointer(pFile)).FszChunk)) @@ -24102,7 +23693,7 @@ func fcntlSizeHint(tls *libc.TLS, pFile uintptr, nByte I64) int32 { /* sqlite3.c } nWrite = seekAndWrite(tls, pFile, iWrite, ts+800 /* "" */, 1) if nWrite != 1 { - return (10 | (int32(3) << 8)) + return (SQLITE_IOERR | (int32(3) << 8)) } } } @@ -24113,7 +23704,7 @@ func fcntlSizeHint(tls *libc.TLS, pFile uintptr, nByte I64) int32 { /* sqlite3.c if (*UnixFile)(unsafe.Pointer(pFile)).FszChunk <= 0 { if robust_ftruncate(tls, (*UnixFile)(unsafe.Pointer(pFile)).Fh, nByte) != 0 { storeLastErrno(tls, pFile, *(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) - return unixLogErrorAtLine(tls, (10 | (int32(6) << 8)), ts+4450 /* "ftruncate" */, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 37450) + return unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(6) << 8)), ts+4450 /* "ftruncate" */, (*UnixFile)(unsafe.Pointer(pFile)).FzPath, 37450) } } @@ -24121,7 +23712,7 @@ func fcntlSizeHint(tls *libc.TLS, pFile uintptr, nByte I64) int32 { /* sqlite3.c return rc } - return 0 + return SQLITE_OK } // If *pArg is initially negative then this is a query. Set *pArg to @@ -24146,25 +23737,25 @@ func unixFileControl(tls *libc.TLS, id uintptr, op int32, pArg uintptr) int32 { var pFile uintptr = id switch op { - case 1: + case SQLITE_FCNTL_LOCKSTATE: { *(*int32)(unsafe.Pointer(pArg)) = int32((*UnixFile)(unsafe.Pointer(pFile)).FeFileLock) - return 0 + return SQLITE_OK } - case 4: + case SQLITE_FCNTL_LAST_ERRNO: { *(*int32)(unsafe.Pointer(pArg)) = (*UnixFile)(unsafe.Pointer(pFile)).FlastErrno - return 0 + return SQLITE_OK } - case 6: + case SQLITE_FCNTL_CHUNK_SIZE: { (*UnixFile)(unsafe.Pointer(pFile)).FszChunk = *(*int32)(unsafe.Pointer(pArg)) - return 0 + return SQLITE_OK } - case 5: + case SQLITE_FCNTL_SIZE_HINT: { var rc int32 Xsqlite3_io_error_benign = 1 @@ -24173,44 +23764,44 @@ func unixFileControl(tls *libc.TLS, id uintptr, op int32, pArg uintptr) int32 { return rc } - case 10: + case SQLITE_FCNTL_PERSIST_WAL: { - unixModeBit(tls, pFile, uint8(0x04), pArg) - return 0 + unixModeBit(tls, pFile, UNIXFILE_PERSIST_WAL, pArg) + return SQLITE_OK } - case 13: + case SQLITE_FCNTL_POWERSAFE_OVERWRITE: { - unixModeBit(tls, pFile, uint8(0x10), pArg) - return 0 + unixModeBit(tls, pFile, UNIXFILE_PSOW, pArg) + return SQLITE_OK } - case 12: + case SQLITE_FCNTL_VFSNAME: { *(*uintptr)(unsafe.Pointer(pArg)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp, (*Sqlite3_vfs)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpVfs)).FzName)) - return 0 + return SQLITE_OK } - case 16: + case SQLITE_FCNTL_TEMPFILENAME: { var zTFile uintptr = Xsqlite3_malloc64(tls, uint64((*Sqlite3_vfs)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpVfs)).FmxPathname)) if zTFile != 0 { unixGetTempname(tls, (*Sqlite3_vfs)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpVfs)).FmxPathname, zTFile) *(*uintptr)(unsafe.Pointer(pArg)) = zTFile } - return 0 + return SQLITE_OK } - case 20: + case SQLITE_FCNTL_HAS_MOVED: { *(*int32)(unsafe.Pointer(pArg)) = fileHasMoved(tls, pFile) - return 0 + return SQLITE_OK } - case 18: + case SQLITE_FCNTL_MMAP_SIZE: { var newLimit I64 = *(*I64)(unsafe.Pointer(pArg)) - var rc int32 = 0 + var rc int32 = SQLITE_OK if newLimit > Xsqlite3Config.FmxMmap { newLimit = Xsqlite3Config.FmxMmap } @@ -24234,7 +23825,7 @@ func unixFileControl(tls *libc.TLS, id uintptr, op int32, pArg uintptr) int32 { } } - return 12 + return SQLITE_NOTFOUND } // If pFd->sectorSize is non-zero when this function is called, it is a @@ -24249,11 +23840,11 @@ func setDeviceCharacteristics(tls *libc.TLS, pFd uintptr) { /* sqlite3.c:37610:1 if (*UnixFile)(unsafe.Pointer(pFd)).FsectorSize == 0 { // Set the POWERSAFE_OVERWRITE flag if requested. - if (int32((*UnixFile)(unsafe.Pointer(pFd)).FctrlFlags) & 0x10) != 0 { - *(*int32)(unsafe.Pointer(pFd + 116 /* &.deviceCharacteristics */)) |= (0x00001000) + if (int32((*UnixFile)(unsafe.Pointer(pFd)).FctrlFlags) & UNIXFILE_PSOW) != 0 { + *(*int32)(unsafe.Pointer(pFd + 116 /* &.deviceCharacteristics */)) |= (SQLITE_IOCAP_POWERSAFE_OVERWRITE) } - (*UnixFile)(unsafe.Pointer(pFd)).FsectorSize = 4096 + (*UnixFile)(unsafe.Pointer(pFd)).FsectorSize = SQLITE_DEFAULT_SECTOR_SIZE } } @@ -24309,7 +23900,7 @@ func unixShmSystemLock(tls *libc.TLS, pFile uintptr, lockType int32, ofst int32, var pShmNode uintptr // Apply locks to this open shared-memory segment // var f flock at bp+8, 32 // The posix advisory locking structure - var rc int32 = 0 // Result code form fcntl() + var rc int32 = SQLITE_OK // Result code form fcntl() // Access to the unixShmNode object is serialized by the caller pShmNode = (*UnixInodeInfo)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(pFile)).FpInode)).FpShmNode @@ -24322,12 +23913,12 @@ func unixShmSystemLock(tls *libc.TLS, pFile uintptr, lockType int32, ofst int32, var res int32 // Initialize the locking parameters (*flock)(unsafe.Pointer(bp + 8 /* &f */)).Fl_type = int16(lockType) - (*flock)(unsafe.Pointer(bp + 8 /* &f */)).Fl_whence = int16(0) + (*flock)(unsafe.Pointer(bp + 8 /* &f */)).Fl_whence = SEEK_SET (*flock)(unsafe.Pointer(bp + 8 /* &f */)).Fl_start = X__off64_t(ofst) (*flock)(unsafe.Pointer(bp + 8 /* &f */)).Fl_len = X__off64_t(n) - res = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(7)*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, 6, libc.VaList(bp, bp+8 /* &f */)) + res = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 7*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, F_SETLK64, libc.VaList(bp, bp+8 /* &f */)) if res == -1 { - rc = 5 + rc = SQLITE_BUSY } } @@ -24344,8 +23935,8 @@ func unixShmSystemLock(tls *libc.TLS, pFile uintptr, lockType int32, ofst int32, // to use 64KB pages - in this case each mapping must cover at least two // shm regions. func unixShmRegionPerMap(tls *libc.TLS) int32 { /* sqlite3.c:37931:12: */ - var shmsz int32 = (32 * 1024) // SHM region size - var pgsz int32 = (*(*func(*libc.TLS) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(25)*24 + 8 /* &.pCurrent */))))(tls) // System page size + var shmsz int32 = (32 * 1024) // SHM region size + var pgsz int32 = (*(*func(*libc.TLS) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 25*24 + 8 /* &.pCurrent */))))(tls) // System page size // Page size must be a power of 2 if pgsz < shmsz { return 1 @@ -24367,7 +23958,7 @@ func unixShmPurge(tls *libc.TLS, pFd uintptr) { /* sqlite3.c:37945:13: */ Xsqlite3_mutex_free(tls, (*UnixShmNode)(unsafe.Pointer(p)).FpShmMutex) for i = 0; i < int32((*UnixShmNode)(unsafe.Pointer(p)).FnRegion); i = i + (nShmPerMap) { if (*UnixShmNode)(unsafe.Pointer(p)).FhShm >= 0 { - (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(23)*24 + 8 /* &.pCurrent */))))(tls, *(*uintptr)(unsafe.Pointer((*UnixShmNode)(unsafe.Pointer(p)).FapRegion + uintptr(i)*8)), uint64((*UnixShmNode)(unsafe.Pointer(p)).FszRegion)) + (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 23*24 + 8 /* &.pCurrent */))))(tls, *(*uintptr)(unsafe.Pointer((*UnixShmNode)(unsafe.Pointer(p)).FapRegion + uintptr(i)*8)), uint64((*UnixShmNode)(unsafe.Pointer(p)).FszRegion)) } else { Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*UnixShmNode)(unsafe.Pointer(p)).FapRegion + uintptr(i)*8))) } @@ -24395,7 +23986,7 @@ func unixLockSharedMemory(tls *libc.TLS, pDbFd uintptr, pShmNode uintptr) int32 // var lock flock at bp+8, 32 - var rc int32 = 0 + var rc int32 = SQLITE_OK // Use F_GETLK to determine the locks other processes are holding // on the DMS byte. If it indicates that another process is holding @@ -24415,34 +24006,34 @@ func unixLockSharedMemory(tls *libc.TLS, pDbFd uintptr, pShmNode uintptr) int32 // process might open and use the *-shm file without truncating it. // And if the *-shm file has been corrupted by a power failure or // system crash, the database itself may also become corrupt. - (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_whence = int16(0) - (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_start = (int64(((22 + 8) * 4) + 8)) + (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_whence = SEEK_SET + (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_start = (int64(((22 + SQLITE_SHM_NLOCK) * 4) + SQLITE_SHM_NLOCK)) (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_len = int64(1) - (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_type = int16(1) - if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(7)*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, 5, libc.VaList(bp, bp+8 /* &lock */)) != 0 { - rc = (10 | (int32(15) << 8)) - } else if int32((*flock)(unsafe.Pointer(bp+8 /* &lock */)).Fl_type) == 2 { + (*flock)(unsafe.Pointer(bp + 8 /* &lock */)).Fl_type = F_WRLCK + if (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 7*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, F_GETLK64, libc.VaList(bp, bp+8 /* &lock */)) != 0 { + rc = (SQLITE_IOERR | (int32(15) << 8)) + } else if int32((*flock)(unsafe.Pointer(bp+8 /* &lock */)).Fl_type) == F_UNLCK { if (*UnixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 { (*UnixShmNode)(unsafe.Pointer(pShmNode)).FisUnlocked = U8(1) - rc = (8 | (int32(5) << 8)) + rc = (SQLITE_READONLY | (int32(5) << 8)) } else { - rc = unixShmSystemLock(tls, pDbFd, 1, (((22 + 8) * 4) + 8), 1) + rc = unixShmSystemLock(tls, pDbFd, F_WRLCK, (((22 + SQLITE_SHM_NLOCK) * 4) + SQLITE_SHM_NLOCK), 1) // The first connection to attach must truncate the -shm file. We // truncate to 3 bytes (an arbitrary small number, less than the // -shm header size) rather than 0 as a system debugging aid, to // help detect if a -shm file truncation is legitimate or is the work // or a rogue process. - if (rc == 0) && (robust_ftruncate(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int64(3)) != 0) { - rc = unixLogErrorAtLine(tls, (10 | (int32(18) << 8)), ts+4450 /* "ftruncate" */, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename, 38019) + if (rc == SQLITE_OK) && (robust_ftruncate(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, int64(3)) != 0) { + rc = unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(18) << 8)), ts+4450 /* "ftruncate" */, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename, 38019) } } - } else if int32((*flock)(unsafe.Pointer(bp+8 /* &lock */)).Fl_type) == 1 { - rc = 5 + } else if int32((*flock)(unsafe.Pointer(bp+8 /* &lock */)).Fl_type) == F_WRLCK { + rc = SQLITE_BUSY } - if rc == 0 { + if rc == SQLITE_OK { - rc = unixShmSystemLock(tls, pDbFd, 0, (((22 + 8) * 4) + 8), 1) + rc = unixShmSystemLock(tls, pDbFd, F_RDLCK, (((22 + SQLITE_SHM_NLOCK) * 4) + SQLITE_SHM_NLOCK), 1) } return rc } @@ -24494,14 +24085,14 @@ func unixOpenSharedMemory(tls *libc.TLS, pDbFd uintptr) int32 { /* sqlite3.c:380 // fstat() info for database file var zBasePath uintptr p = uintptr(0) - rc = 0 // Size of the SHM filename in bytes + rc = SQLITE_OK // Size of the SHM filename in bytes // Allocate space for the new unixShm object. p = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(unixShm{}))) if !(p == uintptr(0)) { goto __1 } - return 7 + return SQLITE_NOMEM __1: ; libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(unixShm{}))) @@ -24520,10 +24111,10 @@ __1: // Call fstat() to figure out the permissions on the database file. If // a new *-shm file is created, an attempt will be made to create it // with the same permissions. - if !((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pDbFd)).Fh, bp+8 /* &sStat */) != 0) { + if !((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pDbFd)).Fh, bp+8 /* &sStat */) != 0) { goto __3 } - rc = (10 | (int32(7) << 8)) + rc = (SQLITE_IOERR | (int32(7) << 8)) goto shm_open_err __3: ; @@ -24533,12 +24124,12 @@ __3: if !(pShmNode == uintptr(0)) { goto __4 } - rc = 7 + rc = SQLITE_NOMEM goto shm_open_err __4: ; libc.Xmemset(tls, pShmNode, 0, (uint64(unsafe.Sizeof(unixShmNode{})) + uint64(nShmFilename))) - zShm = libc.AssignPtrUintptr(pShmNode+16 /* &.zFilename */, (pShmNode + uintptr(1)*64)) + zShm = libc.AssignPtrUintptr(pShmNode+16 /* &.zFilename */, (pShmNode + 1*64)) Xsqlite3_snprintf(tls, nShmFilename, zShm, ts+5282 /* "%s-shm" */, libc.VaList(bp, zBasePath)) (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = -1 @@ -24547,11 +24138,11 @@ __4: if !(Xsqlite3Config.FbCoreMutex != 0) { goto __5 } - (*unixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex = Xsqlite3_mutex_alloc(tls, 0) + (*unixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST) if !((*unixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex == uintptr(0)) { goto __6 } - rc = 7 + rc = SQLITE_NOMEM goto shm_open_err __6: ; @@ -24564,14 +24155,14 @@ __5: if !(0 == Xsqlite3_uri_boolean(tls, (*UnixFile)(unsafe.Pointer(pDbFd)).FzPath, ts+5289 /* "readonly_shm" */, 0)) { goto __8 } - (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = robust_open(tls, zShm, ((02 | 0100) | 0400000), + (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = robust_open(tls, zShm, ((O_RDWR | O_CREAT) | 0400000), ((*stat)(unsafe.Pointer(bp+8 /* &sStat */)).Fst_mode & X__mode_t(0777))) __8: ; if !((*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm < 0) { goto __9 } - (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = robust_open(tls, zShm, (00 | 0400000), + (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm = robust_open(tls, zShm, (O_RDONLY | 0400000), ((*stat)(unsafe.Pointer(bp+8 /* &sStat */)).Fst_mode & X__mode_t(0777))) if !((*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm < 0) { goto __10 @@ -24590,7 +24181,7 @@ __9: robustFchown(tls, (*unixShmNode)(unsafe.Pointer(pShmNode)).FhShm, (*stat)(unsafe.Pointer(bp+8 /* &sStat */)).Fst_uid, (*stat)(unsafe.Pointer(bp+8 /* &sStat */)).Fst_gid) rc = unixLockSharedMemory(tls, pDbFd, pShmNode) - if !((rc != 0) && (rc != (8 | (int32(5) << 8)))) { + if !((rc != SQLITE_OK) && (rc != (SQLITE_READONLY | (int32(5) << 8)))) { goto __11 } goto shm_open_err @@ -24665,7 +24256,7 @@ func unixShmMap(tls *libc.TLS, fd uintptr, iRegion int32, szRegion int32, bExten var nByte int32 // Minimum required file size // var sStat stat at bp, 144 pDbFd = fd - rc = 0 + rc = SQLITE_OK nShmPerMap = unixShmRegionPerMap(tls) // If the shared-memory file has not yet been opened, open it now. @@ -24673,7 +24264,7 @@ func unixShmMap(tls *libc.TLS, fd uintptr, iRegion int32, szRegion int32, bExten goto __1 } rc = unixOpenSharedMemory(tls, pDbFd) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __2 } return rc @@ -24689,7 +24280,7 @@ __1: goto __3 } rc = unixLockSharedMemory(tls, pDbFd, pShmNode) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } goto shmpage_out @@ -24715,10 +24306,10 @@ __3: // The requested region is not mapped into this processes address space. // Check to see if it has been allocated (i.e. if the wal-index file is // large enough to contain the requested region). - if !((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, bp /* &sStat */) != 0) { + if !((*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, bp /* &sStat */) != 0) { goto __7 } - rc = (10 | (int32(19) << 8)) + rc = (SQLITE_IOERR | (int32(19) << 8)) goto shmpage_out __7: ; @@ -24747,7 +24338,7 @@ __11: goto __14 } zFile = (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename - rc = unixLogErrorAtLine(tls, (10 | (int32(19) << 8)), ts+4485 /* "write" */, zFile, 38288) + rc = unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(19) << 8)), ts+4485 /* "write" */, zFile, 38288) goto shmpage_out __14: ; @@ -24771,7 +24362,7 @@ __6: if !(!(apNew != 0)) { goto __15 } - rc = (10 | (int32(12) << 8)) + rc = (SQLITE_IOERR | (int32(12) << 8)) goto shmpage_out __15: ; @@ -24784,18 +24375,18 @@ __16: if !((*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0) { goto __18 } - pMem = (*(*func(*libc.TLS, uintptr, Size_t, int32, int32, int32, Off_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(22)*24 + 8 /* &.pCurrent */))))(tls, uintptr(0), uint64(nMap), + pMem = (*(*func(*libc.TLS, uintptr, Size_t, int32, int32, int32, Off_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 22*24 + 8 /* &.pCurrent */))))(tls, uintptr(0), uint64(nMap), func() int32 { if (*UnixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0 { - return 0x1 + return PROT_READ } - return (0x1 | 0x2) + return (PROT_READ | PROT_WRITE) }(), - 0x01, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, (int64(I64(szRegion) * I64((*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRegion)))) + MAP_SHARED, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm, (int64(I64(szRegion) * I64((*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRegion)))) if !(pMem == (libc.UintptrFromInt32(-1))) { goto __20 } - rc = unixLogErrorAtLine(tls, (10 | (int32(21) << 8)), ts+4572 /* "mmap" */, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename, 38315) + rc = unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(21) << 8)), ts+4572 /* "mmap" */, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename, 38315) goto shmpage_out __20: ; @@ -24805,7 +24396,7 @@ __18: if !(pMem == uintptr(0)) { goto __21 } - rc = 7 + rc = SQLITE_NOMEM goto shmpage_out __21: ; @@ -24843,10 +24434,10 @@ __25: *(*uintptr)(unsafe.Pointer(libc.AtomicLoadUintptr(&pp))) = uintptr(0) __26: ; - if !(((*UnixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0) && (rc == 0)) { + if !(((*UnixShmNode)(unsafe.Pointer(pShmNode)).FisReadonly != 0) && (rc == SQLITE_OK)) { goto __27 } - rc = 8 + rc = SQLITE_READONLY __27: ; Xsqlite3_mutex_leave(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) @@ -24869,7 +24460,7 @@ func unixShmLock(tls *libc.TLS, fd uintptr, ofst int32, n int32, flags int32) in var p uintptr = (*UnixFile)(unsafe.Pointer(pDbFd)).FpShm // The shared memory being locked var pX uintptr // For looping over all siblings var pShmNode uintptr = (*UnixShm)(unsafe.Pointer(p)).FpShmNode // The underlying file iNode - var rc int32 = 0 // Result code + var rc int32 = SQLITE_OK // Result code var mask U16 // Mask of locks to take or release // Check that, if this to be a blocking lock, no locks that occur later @@ -24888,7 +24479,7 @@ func unixShmLock(tls *libc.TLS, fd uintptr, ofst int32, n int32, flags int32) in mask = (U16((int32(1) << (ofst + n)) - (int32(1) << ofst))) Xsqlite3_mutex_enter(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpShmMutex) - if (flags & 1) != 0 { + if (flags & SQLITE_SHM_UNLOCK) != 0 { var allMask U16 = U16(0) // Mask of locks held by siblings // See if any siblings hold this same lock @@ -24902,17 +24493,17 @@ func unixShmLock(tls *libc.TLS, fd uintptr, ofst int32, n int32, flags int32) in // Unlock the system-level locks if (int32(mask) & int32(allMask)) == 0 { - rc = unixShmSystemLock(tls, pDbFd, 2, (ofst + ((22 + 8) * 4)), n) + rc = unixShmSystemLock(tls, pDbFd, F_UNLCK, (ofst + ((22 + SQLITE_SHM_NLOCK) * 4)), n) } else { - rc = 0 + rc = SQLITE_OK } // Undo the local locks - if rc == 0 { + if rc == SQLITE_OK { *(*U16)(unsafe.Pointer(p + 20 /* &.exclMask */)) &= U16((^int32(mask))) *(*U16)(unsafe.Pointer(p + 18 /* &.sharedMask */)) &= U16((^int32(mask))) } - } else if (flags & 4) != 0 { + } else if (flags & SQLITE_SHM_SHARED) != 0 { var allShared U16 = U16(0) // Union of locks held by connections other than "p" // Find out which shared locks are already held by sibling connections. @@ -24920,23 +24511,23 @@ func unixShmLock(tls *libc.TLS, fd uintptr, ofst int32, n int32, flags int32) in // SQLITE_BUSY. for pX = (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpFirst; pX != 0; pX = (*UnixShm)(unsafe.Pointer(pX)).FpNext { if (int32((*UnixShm)(unsafe.Pointer(pX)).FexclMask) & int32(mask)) != 0 { - rc = 5 + rc = SQLITE_BUSY break } allShared = U16(int32(allShared) | (int32((*UnixShm)(unsafe.Pointer(pX)).FsharedMask))) } // Get shared locks at the system level, if necessary - if rc == 0 { + if rc == SQLITE_OK { if (int32(allShared) & int32(mask)) == 0 { - rc = unixShmSystemLock(tls, pDbFd, 0, (ofst + ((22 + 8) * 4)), n) + rc = unixShmSystemLock(tls, pDbFd, F_RDLCK, (ofst + ((22 + SQLITE_SHM_NLOCK) * 4)), n) } else { - rc = 0 + rc = SQLITE_OK } } // Get the local shared locks - if rc == 0 { + if rc == SQLITE_OK { *(*U16)(unsafe.Pointer(p + 18 /* &.sharedMask */)) |= U16((int32(mask))) } } else { @@ -24944,16 +24535,16 @@ func unixShmLock(tls *libc.TLS, fd uintptr, ofst int32, n int32, flags int32) in // lock. If any do, return SQLITE_BUSY right away. for pX = (*UnixShmNode)(unsafe.Pointer(pShmNode)).FpFirst; pX != 0; pX = (*UnixShm)(unsafe.Pointer(pX)).FpNext { if ((int32((*UnixShm)(unsafe.Pointer(pX)).FexclMask) & int32(mask)) != 0) || ((int32((*UnixShm)(unsafe.Pointer(pX)).FsharedMask) & int32(mask)) != 0) { - rc = 5 + rc = SQLITE_BUSY break } } // Get the exclusive locks at the system level. Then if successful // also mark the local connection as being locked. - if rc == 0 { - rc = unixShmSystemLock(tls, pDbFd, 1, (ofst + ((22 + 8) * 4)), n) - if rc == 0 { + if rc == SQLITE_OK { + rc = unixShmSystemLock(tls, pDbFd, F_WRLCK, (ofst + ((22 + SQLITE_SHM_NLOCK) * 4)), n) + if rc == SQLITE_OK { *(*U16)(unsafe.Pointer(p + 20 /* &.exclMask */)) |= U16((int32(mask))) } @@ -24992,7 +24583,7 @@ func unixShmUnmap(tls *libc.TLS, fd uintptr, deleteFlag int32) int32 { /* sqlite pDbFd = fd p = (*UnixFile)(unsafe.Pointer(pDbFd)).FpShm if p == uintptr(0) { - return 0 + return SQLITE_OK } pShmNode = (*UnixShm)(unsafe.Pointer(p)).FpShmNode @@ -25016,20 +24607,20 @@ func unixShmUnmap(tls *libc.TLS, fd uintptr, deleteFlag int32) int32 { /* sqlite (*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRef-- if (*UnixShmNode)(unsafe.Pointer(pShmNode)).FnRef == 0 { if (deleteFlag != 0) && ((*UnixShmNode)(unsafe.Pointer(pShmNode)).FhShm >= 0) { - (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(16)*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename) + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 16*24 + 8 /* &.pCurrent */))))(tls, (*UnixShmNode)(unsafe.Pointer(pShmNode)).FzFilename) } unixShmPurge(tls, pDbFd) } unixLeaveMutex(tls) - return 0 + return SQLITE_OK } // If it is currently memory mapped, unmap file pFd. func unixUnmapfile(tls *libc.TLS, pFd uintptr) { /* sqlite3.c:38563:13: */ if (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion != 0 { - (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(23)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion, uint64((*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeActual)) + (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 23*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion, uint64((*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeActual)) (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion = uintptr(0) (*UnixFile)(unsafe.Pointer(pFd)).FmmapSize = int64(0) (*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeActual = int64(0) @@ -25055,7 +24646,7 @@ func unixRemapfile(tls *libc.TLS, pFd uintptr, nNew I64) { /* sqlite3.c:38588:13 var pOrig uintptr = (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion // Pointer to current file mapping var nOrig I64 = (*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeActual // Size of pOrig region in bytes var pNew uintptr = uintptr(0) // Location of new mapping - var flags int32 = 0x1 // Flags to pass to mmap() + var flags int32 = PROT_READ // Flags to pass to mmap() if pOrig != 0 { var nReuse I64 = (*UnixFile)(unsafe.Pointer(pFd)).FmmapSize @@ -25063,27 +24654,27 @@ func unixRemapfile(tls *libc.TLS, pFd uintptr, nNew I64) { /* sqlite3.c:38588:13 // Unmap any pages of the existing mapping that cannot be reused. if nReuse != nOrig { - (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(23)*24 + 8 /* &.pCurrent */))))(tls, pReq, (uint64(nOrig - nReuse))) + (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 23*24 + 8 /* &.pCurrent */))))(tls, pReq, (uint64(nOrig - nReuse))) } - pNew = (*(*func(*libc.TLS, uintptr, Size_t, Size_t, int32, uintptr) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(24)*24 + 8 /* &.pCurrent */))))(tls, pOrig, uint64(nReuse), uint64(nNew), 1, 0) + pNew = (*(*func(*libc.TLS, uintptr, Size_t, Size_t, int32, uintptr) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 24*24 + 8 /* &.pCurrent */))))(tls, pOrig, uint64(nReuse), uint64(nNew), MREMAP_MAYMOVE, 0) zErr = ts + 4584 /* "mremap" */ // The attempt to extend the existing mapping failed. Free it. if (pNew == (libc.UintptrFromInt32(-1))) || (pNew == uintptr(0)) { - (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(23)*24 + 8 /* &.pCurrent */))))(tls, pOrig, uint64(nReuse)) + (*(*func(*libc.TLS, uintptr, Size_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 23*24 + 8 /* &.pCurrent */))))(tls, pOrig, uint64(nReuse)) } } // If pNew is still NULL, try to create an entirely new mapping. if pNew == uintptr(0) { - pNew = (*(*func(*libc.TLS, uintptr, Size_t, int32, int32, int32, Off_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(22)*24 + 8 /* &.pCurrent */))))(tls, uintptr(0), uint64(nNew), flags, 0x01, h, int64(0)) + pNew = (*(*func(*libc.TLS, uintptr, Size_t, int32, int32, int32, Off_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 22*24 + 8 /* &.pCurrent */))))(tls, uintptr(0), uint64(nNew), flags, MAP_SHARED, h, int64(0)) } if pNew == (libc.UintptrFromInt32(-1)) { pNew = uintptr(0) nNew = int64(0) - unixLogErrorAtLine(tls, 0, zErr, (*UnixFile)(unsafe.Pointer(pFd)).FzPath, 38653) + unixLogErrorAtLine(tls, SQLITE_OK, zErr, (*UnixFile)(unsafe.Pointer(pFd)).FzPath, 38653) // If the mmap() above failed, assume that all subsequent mmap() calls // will probably fail too. Fall back to using xRead/xWrite exclusively @@ -25113,14 +24704,14 @@ func unixMapfile(tls *libc.TLS, pFd uintptr, nMap I64) int32 { /* sqlite3.c:3868 defer tls.Free(144) if (*UnixFile)(unsafe.Pointer(pFd)).FnFetchOut > 0 { - return 0 + return SQLITE_OK } if nMap < int64(0) { // var statbuf stat at bp, 144 // Low-level file information - if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(5)*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFd)).Fh, bp /* &statbuf */) != 0 { - return (10 | (int32(7) << 8)) + if (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*24 + 8 /* &.pCurrent */))))(tls, (*UnixFile)(unsafe.Pointer(pFd)).Fh, bp /* &statbuf */) != 0 { + return (SQLITE_IOERR | (int32(7) << 8)) } nMap = I64((*stat)(unsafe.Pointer(bp /* &statbuf */)).Fst_size) } @@ -25132,7 +24723,7 @@ func unixMapfile(tls *libc.TLS, pFd uintptr, nMap I64) int32 { /* sqlite3.c:3868 unixRemapfile(tls, pFd, nMap) } - return 0 + return SQLITE_OK } // If possible, return a pointer to a mapping of file fd starting at offset @@ -25152,7 +24743,7 @@ func unixFetch(tls *libc.TLS, fd uintptr, iOff I64, nAmt int32, pp uintptr) int3 if (*UnixFile)(unsafe.Pointer(pFd)).FmmapSizeMax > int64(0) { if (*UnixFile)(unsafe.Pointer(pFd)).FpMapRegion == uintptr(0) { var rc int32 = unixMapfile(tls, pFd, int64(-1)) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -25161,7 +24752,7 @@ func unixFetch(tls *libc.TLS, fd uintptr, iOff I64, nAmt int32, pp uintptr) int3 (*UnixFile)(unsafe.Pointer(pFd)).FnFetchOut++ } } - return 0 + return SQLITE_OK } // If the third argument is non-NULL, then this function releases a @@ -25188,7 +24779,7 @@ func unixUnfetch(tls *libc.TLS, fd uintptr, iOff I64, p uintptr) int32 { /* sqli unixUnmapfile(tls, pFd) } - return 0 + return SQLITE_OK } // @@ -25233,80 +24824,26 @@ func unixUnfetch(tls *libc.TLS, fd uintptr, iOff I64, p uintptr) int32 { /* sqli // Here are all of the sqlite3_io_methods objects for each of the // locking strategies. Functions that return pointers to these methods // are also created. -var posixIoMethods = Sqlite3_io_methods{ - FiVersion: 3, - FxClose:/* iVersion */ 0, - FxRead:/* xClose */ 0, - FxWrite:/* xRead */ 0, - FxTruncate:/* xWrite */ 0, - FxSync:/* xTruncate */ 0, - FxFileSize:/* xSync */ 0, - FxLock:/* xFileSize */ 0, - FxUnlock:/* xLock */ 0, - FxCheckReservedLock:/* xUnlock */ 0, - FxFileControl:/* xCheckReservedLock */ 0, - FxSectorSize:/* xFileControl */ 0, - FxDeviceCharacteristics:/* xSectorSize */ 0, - FxShmMap:/* xDeviceCapabilities */ 0, - FxShmLock:/* xShmMap */ 0, - FxShmBarrier:/* xShmLock */ 0, - FxShmUnmap:/* xShmBarrier */ 0, - FxFetch:/* xShmUnmap */ 0, - FxUnfetch:/* xFetch */ 0 /* xUnfetch */} /* sqlite3.c:38850:1 */ +var posixIoMethods = Sqlite3_io_methods{FiVersion: 3 /* iVersion */, FxClose: 0 /* xClose */, FxRead: 0 /* xRead */, FxWrite: 0 /* xWrite */, FxTruncate: 0 /* xTruncate */, FxSync: 0 /* xSync */, FxFileSize: 0 /* xFileSize */, FxLock: 0 /* xLock */, FxUnlock: 0 /* xUnlock */, FxCheckReservedLock: 0 /* xCheckReservedLock */, FxFileControl: 0 /* xFileControl */, FxSectorSize: 0 /* xSectorSize */, FxDeviceCharacteristics: 0 /* xDeviceCapabilities */, FxShmMap: 0 /* xShmMap */, FxShmLock: 0 /* xShmLock */, FxShmBarrier: 0 /* xShmBarrier */, FxShmUnmap: 0 /* xShmUnmap */, FxFetch: 0 /* xFetch */, FxUnfetch: 0 /* xUnfetch */} /* sqlite3.c:38850:1 */ + func posixIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) uintptr { /* sqlite3.c:38850:1: */ _ = z _ = p return uintptr(unsafe.Pointer(&posixIoMethods)) } -var posixIoFinder uintptr = 0 /* sqlite3.c:38850:1 */ -var nolockIoMethods = Sqlite3_io_methods{ - FiVersion: 3, - FxClose:/* iVersion */ 0, - FxRead:/* xClose */ 0, - FxWrite:/* xRead */ 0, - FxTruncate:/* xWrite */ 0, - FxSync:/* xTruncate */ 0, - FxFileSize:/* xSync */ 0, - FxLock:/* xFileSize */ 0, - FxUnlock:/* xLock */ 0, - FxCheckReservedLock:/* xUnlock */ 0, - FxFileControl:/* xCheckReservedLock */ 0, - FxSectorSize:/* xFileControl */ 0, - FxDeviceCharacteristics:/* xSectorSize */ 0, - FxShmMap:/* xDeviceCapabilities */ uintptr(0), - FxShmLock:/* xShmMap */ 0, - FxShmBarrier:/* xShmLock */ 0, - FxShmUnmap:/* xShmBarrier */ 0, - FxFetch:/* xShmUnmap */ 0, - FxUnfetch:/* xFetch */ 0 /* xUnfetch */} /* sqlite3.c:38860:1 */ +var posixIoFinder uintptr = 0 /* sqlite3.c:38850:1 */ +var nolockIoMethods = Sqlite3_io_methods{FiVersion: 3 /* iVersion */, FxClose: 0 /* xClose */, FxRead: 0 /* xRead */, FxWrite: 0 /* xWrite */, FxTruncate: 0 /* xTruncate */, FxSync: 0 /* xSync */, FxFileSize: 0 /* xFileSize */, FxLock: 0 /* xLock */, FxUnlock: 0 /* xUnlock */, FxCheckReservedLock: 0 /* xCheckReservedLock */, FxFileControl: 0 /* xFileControl */, FxSectorSize: 0 /* xSectorSize */, FxDeviceCharacteristics: 0 /* xShmMap */, FxShmLock: 0 /* xShmLock */, FxShmBarrier: 0 /* xShmBarrier */, FxShmUnmap: 0 /* xShmUnmap */, FxFetch: 0 /* xFetch */, FxUnfetch: 0 /* xUnfetch */} /* sqlite3.c:38860:1 */ + func nolockIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) uintptr { /* sqlite3.c:38860:1: */ _ = z _ = p return uintptr(unsafe.Pointer(&nolockIoMethods)) } -var nolockIoFinder uintptr = 0 /* sqlite3.c:38860:1 */ -var dotlockIoMethods = Sqlite3_io_methods{ - FiVersion: 1, - FxClose:/* iVersion */ 0, - FxRead:/* xClose */ 0, - FxWrite:/* xRead */ 0, - FxTruncate:/* xWrite */ 0, - FxSync:/* xTruncate */ 0, - FxFileSize:/* xSync */ 0, - FxLock:/* xFileSize */ 0, - FxUnlock:/* xLock */ 0, - FxCheckReservedLock:/* xUnlock */ 0, - FxFileControl:/* xCheckReservedLock */ 0, - FxSectorSize:/* xFileControl */ 0, - FxDeviceCharacteristics:/* xSectorSize */ 0, - FxShmMap:/* xDeviceCapabilities */ uintptr(0), - FxShmLock:/* xShmMap */ 0, - FxShmBarrier:/* xShmLock */ 0, - FxShmUnmap:/* xShmBarrier */ 0, - FxFetch:/* xShmUnmap */ 0, - FxUnfetch:/* xFetch */ 0 /* xUnfetch */} /* sqlite3.c:38870:1 */ +var nolockIoFinder uintptr = 0 /* sqlite3.c:38860:1 */ +var dotlockIoMethods = Sqlite3_io_methods{FiVersion: 1 /* iVersion */, FxClose: 0 /* xClose */, FxRead: 0 /* xRead */, FxWrite: 0 /* xWrite */, FxTruncate: 0 /* xTruncate */, FxSync: 0 /* xSync */, FxFileSize: 0 /* xFileSize */, FxLock: 0 /* xLock */, FxUnlock: 0 /* xUnlock */, FxCheckReservedLock: 0 /* xCheckReservedLock */, FxFileControl: 0 /* xFileControl */, FxSectorSize: 0 /* xSectorSize */, FxDeviceCharacteristics: 0 /* xShmMap */, FxShmLock: 0 /* xShmLock */, FxShmBarrier: 0 /* xShmBarrier */, FxShmUnmap: 0 /* xShmUnmap */, FxFetch: 0 /* xFetch */, FxUnfetch: 0 /* xUnfetch */} /* sqlite3.c:38870:1 */ + func dotlockIoFinderImpl(tls *libc.TLS, z uintptr, p uintptr) uintptr { /* sqlite3.c:38870:1: */ _ = z _ = p @@ -25342,7 +24879,7 @@ func fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename var pLockingStyle uintptr var pNew uintptr = pId - var rc int32 = 0 + var rc int32 = SQLITE_OK // No locking occurs in temporary files @@ -25355,19 +24892,19 @@ func fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename (*UnixFile)(unsafe.Pointer(pNew)).FctrlFlags = uint16(U8(ctrlFlags)) (*UnixFile)(unsafe.Pointer(pNew)).FmmapSizeMax = Xsqlite3Config.FszMmap if Xsqlite3_uri_boolean(tls, func() uintptr { - if (ctrlFlags & 0x40) != 0 { + if (ctrlFlags & UNIXFILE_URI) != 0 { return zFilename } return uintptr(0) }(), - ts+5360 /* "psow" */, 1) != 0 { - *(*uint16)(unsafe.Pointer(pNew + 30 /* &.ctrlFlags */)) |= uint16((0x10)) + ts+5360 /* "psow" */, SQLITE_POWERSAFE_OVERWRITE) != 0 { + *(*uint16)(unsafe.Pointer(pNew + 30 /* &.ctrlFlags */)) |= uint16((UNIXFILE_PSOW)) } if libc.Xstrcmp(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FzName, ts+5365 /* "unix-excl" */) == 0 { - *(*uint16)(unsafe.Pointer(pNew + 30 /* &.ctrlFlags */)) |= uint16((0x01)) + *(*uint16)(unsafe.Pointer(pNew + 30 /* &.ctrlFlags */)) |= uint16((UNIXFILE_EXCL)) } - if (ctrlFlags & 0x80) != 0 { + if (ctrlFlags & UNIXFILE_NOLOCK) != 0 { pLockingStyle = uintptr(unsafe.Pointer(&nolockIoMethods)) } else { pLockingStyle = (**(**func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer((pVfs + 32 /* &.pAppData */))))(tls, zFilename, pNew) @@ -25376,7 +24913,7 @@ func fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename if pLockingStyle == uintptr(unsafe.Pointer(&posixIoMethods)) { unixEnterMutex(tls) rc = findInodeInfo(tls, pNew, (pNew + 16 /* &.pInode */)) - if rc != 0 { + if rc != SQLITE_OK { // If an error occurred in findInodeInfo(), close the file descriptor // immediately, before releasing the mutex. findInodeInfo() may fail // in two scenarios: @@ -25407,7 +24944,7 @@ func fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename nFilename = (int32(libc.Xstrlen(tls, zFilename)) + 6) zLockFile = Xsqlite3_malloc64(tls, uint64(nFilename)) if zLockFile == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { Xsqlite3_snprintf(tls, nFilename, zLockFile, ts+5375 /* "%s.lock" */, libc.VaList(bp+16, zFilename)) } @@ -25415,7 +24952,7 @@ func fillInUnixFile(tls *libc.TLS, pVfs uintptr, h int32, pId uintptr, zFilename } storeLastErrno(tls, pNew, 0) - if rc != 0 { + if rc != SQLITE_OK { if h >= 0 { robust_close(tls, pNew, h, 39241) } @@ -25446,9 +24983,9 @@ func unixTempFileDir(tls *libc.TLS) uintptr { /* sqlite3.c:39254:19: */ } for 1 != 0 { if (((zDir != uintptr(0)) && - ((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(4)*24 + 8 /* &.pCurrent */))))(tls, zDir, bp /* &buf */) == 0)) && + ((*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 4*24 + 8 /* &.pCurrent */))))(tls, zDir, bp /* &buf */) == 0)) && ((((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_mode) & X__mode_t(0170000)) == (X__mode_t(0040000)))) && - ((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(2)*24 + 8 /* &.pCurrent */))))(tls, zDir, 03) == 0) { + ((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 2*24 + 8 /* &.pCurrent */))))(tls, zDir, 03) == 0) { return zDir } if uint64(i) >= (uint64(unsafe.Sizeof(azDirs)) / uint64(unsafe.Sizeof(uintptr(0)))) { @@ -25481,17 +25018,17 @@ func unixGetTempname(tls *libc.TLS, nBuf int32, zBuf uintptr) int32 { /* sqlite3 // It's odd to simulate an io-error here, but really this is just // using the io-error infrastructure to test that SQLite handles this // function failing. - *(*int8)(unsafe.Pointer(zBuf + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(zBuf)) = int8(0) if ((Xsqlite3_io_error_persist != 0) && (Xsqlite3_io_error_hit != 0)) || (libc.PostDecAtomicInt32(&Xsqlite3_io_error_pending, 1) == 1) { local_ioerr(tls) - return 10 + return SQLITE_IOERR } zDir = unixTempFileDir(tls) if zDir == uintptr(0) { - return (10 | (int32(25) << 8)) + return (SQLITE_IOERR | (int32(25) << 8)) } - for ok := true; ok; ok = ((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(2)*24 + 8 /* &.pCurrent */))))(tls, zBuf, 0) == 0) { + for ok := true; ok; ok = ((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 2*24 + 8 /* &.pCurrent */))))(tls, zBuf, 0) == 0) { // var r U64 at bp+24, 8 Xsqlite3_randomness(tls, int32(unsafe.Sizeof(U64(0))), bp+24 /* &r */) @@ -25500,10 +25037,10 @@ func unixGetTempname(tls *libc.TLS, nBuf int32, zBuf uintptr) int32 { /* sqlite3 Xsqlite3_snprintf(tls, nBuf, zBuf, ts+5427, /* "%s/etilqs_%llx%c" */ libc.VaList(bp, zDir, *(*U64)(unsafe.Pointer(bp + 24 /* r */)), 0)) if (int32(*(*int8)(unsafe.Pointer(zBuf + uintptr((nBuf - 2))))) != 0) || ((libc.PostIncInt32(&iLimit, 1)) > 10) { - return 1 + return SQLITE_ERROR } } - return 0 + return SQLITE_OK } // Search for an unused file descriptor that was opened on the database @@ -25544,7 +25081,7 @@ func findReusableFd(tls *libc.TLS, zPath uintptr, flags int32) uintptr { /* sqli // // Even if a subsequent open() call does succeed, the consequences of // not searching for a reusable file descriptor are not dire. - if (inodeList != uintptr(0)) && (0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(4)*24 + 8 /* &.pCurrent */))))(tls, zPath, bp /* &sStat */)) { + if (inodeList != uintptr(0)) && (0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 4*24 + 8 /* &.pCurrent */))))(tls, zPath, bp /* &sStat */)) { var pInode uintptr pInode = inodeList @@ -25556,7 +25093,7 @@ func findReusableFd(tls *libc.TLS, zPath uintptr, flags int32) uintptr { /* sqli var pp uintptr Xsqlite3_mutex_enter(tls, (*UnixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex) - flags = flags & (0x00000001 | 0x00000002) + flags = flags & (SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE) for pp = (pInode + 40 /* &.pUnused */); (*(*uintptr)(unsafe.Pointer(pp)) != 0) && ((*UnixUnusedFd)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pp))))).Fflags != flags); pp = (*(*uintptr)(unsafe.Pointer(pp)) + 8 /* &.pNext */) { } pUnused = *(*uintptr)(unsafe.Pointer(pp)) @@ -25577,13 +25114,13 @@ func getFileMode(tls *libc.TLS, zFile uintptr, pMode uintptr, pUid uintptr, pGid // var sStat stat at bp, 144 // Output of stat() on database file - var rc int32 = 0 - if 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(4)*24 + 8 /* &.pCurrent */))))(tls, zFile, bp /* &sStat */) { + var rc int32 = SQLITE_OK + if 0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 4*24 + 8 /* &.pCurrent */))))(tls, zFile, bp /* &sStat */) { *(*Mode_t)(unsafe.Pointer(pMode)) = ((*stat)(unsafe.Pointer(bp /* &sStat */)).Fst_mode & X__mode_t(0777)) *(*Uid_t)(unsafe.Pointer(pUid)) = (*stat)(unsafe.Pointer(bp /* &sStat */)).Fst_uid *(*Gid_t)(unsafe.Pointer(pGid)) = (*stat)(unsafe.Pointer(bp /* &sStat */)).Fst_gid } else { - rc = (10 | (int32(7) << 8)) + rc = (SQLITE_IOERR | (int32(7) << 8)) } return rc } @@ -25611,11 +25148,11 @@ func findCreateFileMode(tls *libc.TLS, zPath uintptr, flags int32, pMode uintptr bp := tls.Alloc(513) defer tls.Free(513) - var rc int32 = 0 // Return Code + var rc int32 = SQLITE_OK // Return Code *(*Mode_t)(unsafe.Pointer(pMode)) = Mode_t(0) *(*Uid_t)(unsafe.Pointer(pUid)) = Uid_t(0) *(*Gid_t)(unsafe.Pointer(pGid)) = Gid_t(0) - if (flags & (0x00080000 | 0x00000800)) != 0 { + if (flags & (SQLITE_OPEN_WAL | SQLITE_OPEN_MAIN_JOURNAL)) != 0 { // var zDb [513]int8 at bp, 513 // Database file path var nDb int32 // Number of valid bytes in zDb @@ -25638,7 +25175,7 @@ func findCreateFileMode(tls *libc.TLS, zPath uintptr, flags int32, pMode uintptr // rollback journal specifies a super-journal with a goofy name, then // the '-' might be missing. if (nDb == 0) || (int32(*(*int8)(unsafe.Pointer(zPath + uintptr(nDb)))) == '.') { - return 0 + return SQLITE_OK } nDb-- } @@ -25646,9 +25183,9 @@ func findCreateFileMode(tls *libc.TLS, zPath uintptr, flags int32, pMode uintptr *(*int8)(unsafe.Pointer(bp /* &zDb[0] */ + uintptr(nDb))) = int8(0) rc = getFileMode(tls, bp /* &zDb[0] */, pMode, pUid, pGid) - } else if (flags & 0x00000008) != 0 { + } else if (flags & SQLITE_OPEN_DELETEONCLOSE) != 0 { *(*Mode_t)(unsafe.Pointer(pMode)) = Mode_t(0600) - } else if (flags & 0x00000040) != 0 { + } else if (flags & SQLITE_OPEN_URI) != 0 { // If this is a main database file and the file was opened using a URI // filename, check for the "modeof" parameter. If present, interpret // its value as a filename and try to copy the mode, uid and gid from @@ -25720,16 +25257,16 @@ func unixOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr, pFile uintptr, flags i fd = -1 openFlags = 0 eType = (flags & 0x0FFF00) - rc = 0 + rc = SQLITE_OK ctrlFlags = 0 - isExclusive = (flags & 0x00000010) - isDelete = (flags & 0x00000008) - isCreate = (flags & 0x00000004) - isReadonly = (flags & 0x00000001) - isReadWrite = (flags & 0x00000002) - isNewJrnl = (libc.Bool32((isCreate != 0) && (((eType == 0x00004000) || - (eType == 0x00000800)) || - (eType == 0x00080000)))) + isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE) + isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE) + isCreate = (flags & SQLITE_OPEN_CREATE) + isReadonly = (flags & SQLITE_OPEN_READONLY) + isReadWrite = (flags & SQLITE_OPEN_READWRITE) + isNewJrnl = (libc.Bool32((isCreate != 0) && (((eType == SQLITE_OPEN_SUPER_JOURNAL) || + (eType == SQLITE_OPEN_MAIN_JOURNAL)) || + (eType == SQLITE_OPEN_WAL)))) zName = zPath // Check the following statements are true: @@ -25757,7 +25294,7 @@ __1: ; libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(UnixFile{}))) - if !(eType == 0x00000100) { + if !(eType == SQLITE_OPEN_MAIN_DB) { goto __2 } pUnused = findReusableFd(tls, zName, flags) @@ -25771,7 +25308,7 @@ __4: if !(!(pUnused != 0)) { goto __6 } - return 7 + return SQLITE_NOMEM __6: ; __5: @@ -25790,7 +25327,7 @@ __2: // If zName is NULL, the upper layer is requesting a temp file. rc = unixGetTempname(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname, bp+24 /* &zTmpname[0] */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __8 } return rc @@ -25813,34 +25350,34 @@ __3: if !(isReadonly != 0) { goto __9 } - openFlags = openFlags | (00) + openFlags = openFlags | (O_RDONLY) __9: ; if !(isReadWrite != 0) { goto __10 } - openFlags = openFlags | (02) + openFlags = openFlags | (O_RDWR) __10: ; if !(isCreate != 0) { goto __11 } - openFlags = openFlags | (0100) + openFlags = openFlags | (O_CREAT) __11: ; if !(isExclusive != 0) { goto __12 } - openFlags = openFlags | (0200 | 0400000) + openFlags = openFlags | (O_EXCL | 0400000) __12: ; - openFlags = openFlags | ((0 | 0) | 0400000) + openFlags = openFlags | ((0 | O_BINARY) | 0400000) if !(fd < 0) { goto __13 } // Groupid for the file rc = findCreateFileMode(tls, zName, flags, bp+540 /* &openMode */, bp+544 /* &uid */, bp+548 /* &gid */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __14 } @@ -25858,22 +25395,22 @@ __15: if !(fd < 0) { goto __16 } - if !(((isNewJrnl != 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 13)) && ((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(2)*24 + 8 /* &.pCurrent */))))(tls, zName, 0) != 0)) { + if !(((isNewJrnl != 0) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == EACCES)) && ((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 2*24 + 8 /* &.pCurrent */))))(tls, zName, F_OK) != 0)) { goto __17 } // If unable to create a journal because the directory is not // writable, change the error code to indicate that. - rc = (8 | (int32(6) << 8)) + rc = (SQLITE_READONLY | (int32(6) << 8)) goto __18 __17: - if !(((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) != 21) && (isReadWrite != 0)) { + if !(((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) != EISDIR) && (isReadWrite != 0)) { goto __19 } // Failed to open the file for read/write access. Try read-only. - flags = flags & (^libc.Int32((0x00000002 | 0x00000004))) - openFlags = openFlags & (^libc.Int32((02 | 0100))) - flags = flags | (0x00000001) - openFlags = openFlags | (00) + flags = flags & (libc.CplInt32((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE))) + openFlags = openFlags & (libc.CplInt32((O_RDWR | O_CREAT))) + flags = flags | (SQLITE_OPEN_READONLY) + openFlags = openFlags | (O_RDONLY) isReadonly = 1 fd = robust_open(tls, zName, openFlags, *(*Mode_t)(unsafe.Pointer(bp + 540 /* openMode */))) __19: @@ -25886,7 +25423,7 @@ __16: goto __20 } rc2 = unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 39655), ts+4414 /* "open" */, zName, 39655) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __21 } rc = rc2 @@ -25907,7 +25444,7 @@ __20: // If openMode==0, then that means uid and gid are not set correctly // (probably because SQLite is configured to use 8+3 filename mode) and // in that case we do not want to attempt the chown(). - if !((*(*Mode_t)(unsafe.Pointer(bp + 540 /* openMode */)) != 0) && ((flags & (0x00080000 | 0x00000800)) != 0)) { + if !((*(*Mode_t)(unsafe.Pointer(bp + 540 /* openMode */)) != 0) && ((flags & (SQLITE_OPEN_WAL | SQLITE_OPEN_MAIN_JOURNAL)) != 0)) { goto __22 } robustFchown(tls, fd, *(*Uid_t)(unsafe.Pointer(bp + 544 /* uid */)), *(*Gid_t)(unsafe.Pointer(bp + 548 /* gid */))) @@ -25927,14 +25464,14 @@ __23: goto __24 } (*UnixUnusedFd)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused)).Ffd = fd - (*UnixUnusedFd)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused)).Fflags = (flags & (0x00000001 | 0x00000002)) + (*UnixUnusedFd)(unsafe.Pointer((*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused)).Fflags = (flags & (SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE)) __24: ; if !(isDelete != 0) { goto __25 } - (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(16)*24 + 8 /* &.pCurrent */))))(tls, zName) + (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 16*24 + 8 /* &.pCurrent */))))(tls, zName) __25: ; @@ -25942,39 +25479,39 @@ __25: if !(isDelete != 0) { goto __26 } - ctrlFlags = ctrlFlags | (0x20) + ctrlFlags = ctrlFlags | (UNIXFILE_DELETE) __26: ; if !(isReadonly != 0) { goto __27 } - ctrlFlags = ctrlFlags | (0x02) + ctrlFlags = ctrlFlags | (UNIXFILE_RDONLY) __27: ; - noLock = (libc.Bool32(eType != 0x00000100)) + noLock = (libc.Bool32(eType != SQLITE_OPEN_MAIN_DB)) if !(noLock != 0) { goto __28 } - ctrlFlags = ctrlFlags | (0x80) + ctrlFlags = ctrlFlags | (UNIXFILE_NOLOCK) __28: ; if !(isNewJrnl != 0) { goto __29 } - ctrlFlags = ctrlFlags | (0x08) + ctrlFlags = ctrlFlags | (UNIXFILE_DIRSYNC) __29: ; - if !((flags & 0x00000040) != 0) { + if !((flags & SQLITE_OPEN_URI) != 0) { goto __30 } - ctrlFlags = ctrlFlags | (0x40) + ctrlFlags = ctrlFlags | (UNIXFILE_URI) __30: ; rc = fillInUnixFile(tls, pVfs, fd, pFile, zPath, ctrlFlags) open_finished: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __31 } Xsqlite3_free(tls, (*UnixFile)(unsafe.Pointer(p)).FpPreallocatedUnused) @@ -25989,33 +25526,33 @@ func unixDelete(tls *libc.TLS, NotUsed uintptr, zPath uintptr, dirSync int32) in bp := tls.Alloc(4) defer tls.Free(4) - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = NotUsed if ((Xsqlite3_io_error_persist != 0) && (Xsqlite3_io_error_hit != 0)) || (libc.PostDecAtomicInt32(&Xsqlite3_io_error_pending, 1) == 1) { local_ioerr(tls) - return (10 | (int32(10) << 8)) + return (SQLITE_IOERR | (int32(10) << 8)) } - if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(16)*24 + 8 /* &.pCurrent */))))(tls, zPath) == (-1) { - if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == 2 { - rc = (10 | (int32(23) << 8)) + if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 16*24 + 8 /* &.pCurrent */))))(tls, zPath) == (-1) { + if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == ENOENT { + rc = (SQLITE_IOERR | (int32(23) << 8)) } else { - rc = unixLogErrorAtLine(tls, (10 | (int32(10) << 8)), ts+4524 /* "unlink" */, zPath, 39794) + rc = unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(10) << 8)), ts+4524 /* "unlink" */, zPath, 39794) } return rc } if (dirSync & 1) != 0 { // var fd int32 at bp, 4 - rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(17)*24 + 8 /* &.pCurrent */))))(tls, zPath, bp /* &fd */) - if rc == 0 { + rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 17*24 + 8 /* &.pCurrent */))))(tls, zPath, bp /* &fd */) + if rc == SQLITE_OK { if full_fsync(tls, *(*int32)(unsafe.Pointer(bp /* fd */)), 0, 0) != 0 { - rc = unixLogErrorAtLine(tls, (10 | (int32(5) << 8)), ts+5472 /* "fsync" */, zPath, 39804) + rc = unixLogErrorAtLine(tls, (SQLITE_IOERR | (int32(5) << 8)), ts+5472 /* "fsync" */, zPath, 39804) } robust_close(tls, uintptr(0), *(*int32)(unsafe.Pointer(bp /* fd */)), 39806) } else { - rc = 0 + rc = SQLITE_OK } } return rc @@ -26036,20 +25573,20 @@ func unixAccess(tls *libc.TLS, NotUsed uintptr, zPath uintptr, flags int32, pRes _ = NotUsed if ((Xsqlite3_io_error_persist != 0) && (Xsqlite3_io_error_hit != 0)) || (libc.PostDecAtomicInt32(&Xsqlite3_io_error_pending, 1) == 1) { local_ioerr(tls) - return (10 | (int32(13) << 8)) + return (SQLITE_IOERR | (int32(13) << 8)) } // The spec says there are three possible values for flags. But only // two of them are actually used - if flags == 0 { + if flags == SQLITE_ACCESS_EXISTS { // var buf stat at bp, 144 - *(*int32)(unsafe.Pointer(pResOut)) = (libc.Bool32((0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(4)*24 + 8 /* &.pCurrent */))))(tls, zPath, bp /* &buf */)) && (!((((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_mode) & X__mode_t(0170000)) == (X__mode_t(0100000))) || ((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_size > int64(0))))) + *(*int32)(unsafe.Pointer(pResOut)) = (libc.Bool32((0 == (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 4*24 + 8 /* &.pCurrent */))))(tls, zPath, bp /* &buf */)) && (!((((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_mode) & X__mode_t(0170000)) == (X__mode_t(0100000))) || ((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_size > int64(0))))) } else { - *(*int32)(unsafe.Pointer(pResOut)) = (libc.Bool32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(2)*24 + 8 /* &.pCurrent */))))(tls, zPath, (2|4)) == 0)) + *(*int32)(unsafe.Pointer(pResOut)) = (libc.Bool32((*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 2*24 + 8 /* &.pCurrent */))))(tls, zPath, (W_OK|R_OK)) == 0)) } - return 0 + return SQLITE_OK } // @@ -26059,8 +25596,8 @@ func mkFullPathname(tls *libc.TLS, zPath uintptr, zOut uintptr, nOut int32) int3 var nPath int32 = Xsqlite3Strlen30(tls, zPath) var iOff int32 = 0 - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) != '/' { - if (*(*func(*libc.TLS, uintptr, Size_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(3)*24 + 8 /* &.pCurrent */))))(tls, zOut, (uint64(nOut-2))) == uintptr(0) { + if int32(*(*int8)(unsafe.Pointer(zPath))) != '/' { + if (*(*func(*libc.TLS, uintptr, Size_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 3*24 + 8 /* &.pCurrent */))))(tls, zOut, (uint64(nOut-2))) == uintptr(0) { return unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 39862), ts+4432 /* "getcwd" */, zPath, 39862) } iOff = Xsqlite3Strlen30(tls, zOut) @@ -26073,7 +25610,7 @@ func mkFullPathname(tls *libc.TLS, zPath uintptr, zOut uintptr, nOut int32) int3 return Xsqlite3CantopenError(tls, 39871) } Xsqlite3_snprintf(tls, (nOut - iOff), (zOut + uintptr(iOff)), ts+824 /* "%s" */, libc.VaList(bp, zPath)) - return 0 + return SQLITE_OK } // Turn a relative pathname into a full pathname. The relative path @@ -26087,7 +25624,7 @@ func unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zO bp := tls.Alloc(144) defer tls.Free(144) - var rc int32 = 0 + var rc int32 = SQLITE_OK var nByte int32 var nLink int32 = 0 // Number of symbolic links followed so far var zIn uintptr = zPath // Input path for each iteration of loop @@ -26101,18 +25638,18 @@ func unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zO // current working directory has been unlinked. if ((Xsqlite3_io_error_persist != 0) && (Xsqlite3_io_error_hit != 0)) || (libc.PostDecAtomicInt32(&Xsqlite3_io_error_pending, 1) == 1) { local_ioerr(tls) - return 1 + return SQLITE_ERROR } - for ok := true; ok; ok = (rc == 0) { + for ok := true; ok; ok = (rc == SQLITE_OK) { // Call stat() on path zIn. Set bLink to true if the path is a symbolic // link, or false otherwise. var bLink int32 = 0 // var buf stat at bp, 144 - if (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(27)*24 + 8 /* &.pCurrent */))))(tls, zIn, bp /* &buf */) != 0 { - if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) != 2 { + if (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 27*24 + 8 /* &.pCurrent */))))(tls, zIn, bp /* &buf */) != 0 { + if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) != ENOENT { rc = unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 39919), ts+4612 /* "lstat" */, zIn, 39919) } } else { @@ -26124,18 +25661,18 @@ func unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zO if zDel == uintptr(0) { zDel = Xsqlite3_malloc(tls, nOut) if zDel == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } - } else if nLink >= 100 { + } else if nLink >= SQLITE_MAX_SYMLINKS { rc = Xsqlite3CantopenError(tls, 39931) } - if rc == 0 { - nByte = int32((*(*func(*libc.TLS, uintptr, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + uintptr(26)*24 + 8 /* &.pCurrent */))))(tls, zIn, zDel, (uint64(nOut - 1)))) + if rc == SQLITE_OK { + nByte = int32((*(*func(*libc.TLS, uintptr, uintptr, Size_t) Ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 26*24 + 8 /* &.pCurrent */))))(tls, zIn, zDel, (uint64(nOut - 1)))) if nByte < 0 { rc = unixLogErrorAtLine(tls, Xsqlite3CantopenError(tls, 39937), ts+4603 /* "readlink" */, zIn, 39937) } else { - if int32(*(*int8)(unsafe.Pointer(zDel + uintptr(0)))) != '/' { + if int32(*(*int8)(unsafe.Pointer(zDel))) != '/' { var n int32 for n = Xsqlite3Strlen30(tls, zIn); (n > 0) && (int32(*(*int8)(unsafe.Pointer(zIn + uintptr((n - 1))))) != '/'); n-- { } @@ -26154,7 +25691,7 @@ func unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zO zIn = zDel } - if (rc == 0) && (zIn != zOut) { + if (rc == SQLITE_OK) && (zIn != zOut) { rc = mkFullPathname(tls, zIn, zOut, nOut) } if bLink == 0 { @@ -26164,8 +25701,8 @@ func unixFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zO } Xsqlite3_free(tls, zDel) - if (rc == 0) && (nLink != 0) { - rc = (0 | (int32(2) << 8)) + if (rc == SQLITE_OK) && (nLink != 0) { + rc = (SQLITE_OK | (int32(2) << 8)) } return rc } @@ -26210,7 +25747,7 @@ type Dl_serinfo = struct { func unixDlOpen(tls *libc.TLS, NotUsed uintptr, zFilename uintptr) uintptr { /* sqlite3.c:39978:13: */ _ = NotUsed - return libc.Xdlopen(tls, zFilename, (0x00002 | 0x00100)) + return libc.Xdlopen(tls, zFilename, (RTLD_NOW | RTLD_GLOBAL)) } // SQLite calls this function immediately after a call to unixDlSym() or @@ -26297,6 +25834,7 @@ func unixSleep(tls *libc.TLS, NotUsed uintptr, microseconds int32) int32 { /* sq // the number of seconds since 1970 and is used to set the result of // sqlite3OsCurrentTime() during testing. var Xsqlite3_current_time int32 = 0 /* sqlite3.c:40111:16 */ + // Fake system time in seconds since 1970. // Find the current time (in Universal Coordinated Time). Write into *piNow @@ -26311,7 +25849,7 @@ func unixCurrentTimeInt64(tls *libc.TLS, NotUsed uintptr, piNow uintptr) int32 { bp := tls.Alloc(16) defer tls.Free(16) - var rc int32 = 0 + var rc int32 = SQLITE_OK // var sNow timeval at bp, 16 libc.Xgettimeofday(tls, bp /* &sNow */, uintptr(0)) // Cannot fail given valid arguments @@ -26537,103 +26075,15 @@ func Xsqlite3_os_init(tls *libc.TLS) int32 { /* sqlite3.c:41379:16: */ for i = uint32(0); uint64(i) < (uint64(unsafe.Sizeof(aVfs)) / uint64(unsafe.Sizeof(Sqlite3_vfs{}))); i++ { Xsqlite3_vfs_register(tls, (uintptr(unsafe.Pointer(&aVfs)) + uintptr(i)*168), (libc.Bool32(i == uint32(0)))) } - unixBigLock = Xsqlite3MutexAlloc(tls, 11) - return 0 + unixBigLock = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_VFS1) + return SQLITE_OK } var aVfs = [4]Sqlite3_vfs{ - { - FiVersion: 3, - FszOsFile:/* iVersion */ int32(unsafe.Sizeof(UnixFile{})), - FmxPathname:/* szOsFile */ 512, - FpNext:/* mxPathname */ uintptr(0), - FzName:/* pNext */ ts + 5478, /* "unix" */ - FpAppData:/* zName */ 0, - FxOpen:/* pAppData */ 0, - FxDelete:/* xOpen */ 0, - FxAccess:/* xDelete */ 0, - FxFullPathname:/* xAccess */ 0, - FxDlOpen:/* xFullPathname */ 0, - FxDlError:/* xDlOpen */ 0, - FxDlSym:/* xDlError */ 0, - FxDlClose:/* xDlSym */ 0, - FxRandomness:/* xDlClose */ 0, - FxSleep:/* xRandomness */ 0, - FxCurrentTime:/* xSleep */ 0, - FxGetLastError:/* xCurrentTime */ 0, - FxCurrentTimeInt64:/* xGetLastError */ 0, - FxSetSystemCall:/* xCurrentTimeInt64 */ 0, - FxGetSystemCall:/* xSetSystemCall */ 0, - FxNextSystemCall:/* xGetSystemCall */ 0 /* xNextSystemCall */}, - { - FiVersion: 3, - FszOsFile:/* iVersion */ int32(unsafe.Sizeof(UnixFile{})), - FmxPathname:/* szOsFile */ 512, - FpNext:/* mxPathname */ uintptr(0), - FzName:/* pNext */ ts + 5483, /* "unix-none" */ - FpAppData:/* zName */ 0, - FxOpen:/* pAppData */ 0, - FxDelete:/* xOpen */ 0, - FxAccess:/* xDelete */ 0, - FxFullPathname:/* xAccess */ 0, - FxDlOpen:/* xFullPathname */ 0, - FxDlError:/* xDlOpen */ 0, - FxDlSym:/* xDlError */ 0, - FxDlClose:/* xDlSym */ 0, - FxRandomness:/* xDlClose */ 0, - FxSleep:/* xRandomness */ 0, - FxCurrentTime:/* xSleep */ 0, - FxGetLastError:/* xCurrentTime */ 0, - FxCurrentTimeInt64:/* xGetLastError */ 0, - FxSetSystemCall:/* xCurrentTimeInt64 */ 0, - FxGetSystemCall:/* xSetSystemCall */ 0, - FxNextSystemCall:/* xGetSystemCall */ 0 /* xNextSystemCall */}, - { - FiVersion: 3, - FszOsFile:/* iVersion */ int32(unsafe.Sizeof(UnixFile{})), - FmxPathname:/* szOsFile */ 512, - FpNext:/* mxPathname */ uintptr(0), - FzName:/* pNext */ ts + 5493, /* "unix-dotfile" */ - FpAppData:/* zName */ 0, - FxOpen:/* pAppData */ 0, - FxDelete:/* xOpen */ 0, - FxAccess:/* xDelete */ 0, - FxFullPathname:/* xAccess */ 0, - FxDlOpen:/* xFullPathname */ 0, - FxDlError:/* xDlOpen */ 0, - FxDlSym:/* xDlError */ 0, - FxDlClose:/* xDlSym */ 0, - FxRandomness:/* xDlClose */ 0, - FxSleep:/* xRandomness */ 0, - FxCurrentTime:/* xSleep */ 0, - FxGetLastError:/* xCurrentTime */ 0, - FxCurrentTimeInt64:/* xGetLastError */ 0, - FxSetSystemCall:/* xCurrentTimeInt64 */ 0, - FxGetSystemCall:/* xSetSystemCall */ 0, - FxNextSystemCall:/* xGetSystemCall */ 0 /* xNextSystemCall */}, - { - FiVersion: 3, - FszOsFile:/* iVersion */ int32(unsafe.Sizeof(UnixFile{})), - FmxPathname:/* szOsFile */ 512, - FpNext:/* mxPathname */ uintptr(0), - FzName:/* pNext */ ts + 5365, /* "unix-excl" */ - FpAppData:/* zName */ 0, - FxOpen:/* pAppData */ 0, - FxDelete:/* xOpen */ 0, - FxAccess:/* xDelete */ 0, - FxFullPathname:/* xAccess */ 0, - FxDlOpen:/* xFullPathname */ 0, - FxDlError:/* xDlOpen */ 0, - FxDlSym:/* xDlError */ 0, - FxDlClose:/* xDlSym */ 0, - FxRandomness:/* xDlClose */ 0, - FxSleep:/* xRandomness */ 0, - FxCurrentTime:/* xSleep */ 0, - FxGetLastError:/* xCurrentTime */ 0, - FxCurrentTimeInt64:/* xGetLastError */ 0, - FxSetSystemCall:/* xCurrentTimeInt64 */ 0, - FxGetSystemCall:/* xSetSystemCall */ 0, - FxNextSystemCall:/* xGetSystemCall */ 0 /* xNextSystemCall */}, + {FiVersion: 3 /* iVersion */, FszOsFile: int32(unsafe.Sizeof(UnixFile{})) /* szOsFile */, FmxPathname: MAX_PATHNAME /* pNext */, FzName: ts + 5478 /* "unix" */ /* zName */, FpAppData: 0 /* pAppData */, FxOpen: 0 /* xOpen */, FxDelete: 0 /* xDelete */, FxAccess: 0 /* xAccess */, FxFullPathname: 0 /* xFullPathname */, FxDlOpen: 0 /* xDlOpen */, FxDlError: 0 /* xDlError */, FxDlSym: 0 /* xDlSym */, FxDlClose: 0 /* xDlClose */, FxRandomness: 0 /* xRandomness */, FxSleep: 0 /* xSleep */, FxCurrentTime: 0 /* xCurrentTime */, FxGetLastError: 0 /* xGetLastError */, FxCurrentTimeInt64: 0 /* xCurrentTimeInt64 */, FxSetSystemCall: 0 /* xSetSystemCall */, FxGetSystemCall: 0 /* xGetSystemCall */, FxNextSystemCall: 0 /* xNextSystemCall */}, + {FiVersion: 3 /* iVersion */, FszOsFile: int32(unsafe.Sizeof(UnixFile{})) /* szOsFile */, FmxPathname: MAX_PATHNAME /* pNext */, FzName: ts + 5483 /* "unix-none" */ /* zName */, FpAppData: 0 /* pAppData */, FxOpen: 0 /* xOpen */, FxDelete: 0 /* xDelete */, FxAccess: 0 /* xAccess */, FxFullPathname: 0 /* xFullPathname */, FxDlOpen: 0 /* xDlOpen */, FxDlError: 0 /* xDlError */, FxDlSym: 0 /* xDlSym */, FxDlClose: 0 /* xDlClose */, FxRandomness: 0 /* xRandomness */, FxSleep: 0 /* xSleep */, FxCurrentTime: 0 /* xCurrentTime */, FxGetLastError: 0 /* xGetLastError */, FxCurrentTimeInt64: 0 /* xCurrentTimeInt64 */, FxSetSystemCall: 0 /* xSetSystemCall */, FxGetSystemCall: 0 /* xGetSystemCall */, FxNextSystemCall: 0 /* xNextSystemCall */}, + {FiVersion: 3 /* iVersion */, FszOsFile: int32(unsafe.Sizeof(UnixFile{})) /* szOsFile */, FmxPathname: MAX_PATHNAME /* pNext */, FzName: ts + 5493 /* "unix-dotfile" */ /* zName */, FpAppData: 0 /* pAppData */, FxOpen: 0 /* xOpen */, FxDelete: 0 /* xDelete */, FxAccess: 0 /* xAccess */, FxFullPathname: 0 /* xFullPathname */, FxDlOpen: 0 /* xDlOpen */, FxDlError: 0 /* xDlError */, FxDlSym: 0 /* xDlSym */, FxDlClose: 0 /* xDlClose */, FxRandomness: 0 /* xRandomness */, FxSleep: 0 /* xSleep */, FxCurrentTime: 0 /* xCurrentTime */, FxGetLastError: 0 /* xGetLastError */, FxCurrentTimeInt64: 0 /* xCurrentTimeInt64 */, FxSetSystemCall: 0 /* xSetSystemCall */, FxGetSystemCall: 0 /* xGetSystemCall */, FxNextSystemCall: 0 /* xNextSystemCall */}, + {FiVersion: 3 /* iVersion */, FszOsFile: int32(unsafe.Sizeof(UnixFile{})) /* szOsFile */, FmxPathname: MAX_PATHNAME /* pNext */, FzName: ts + 5365 /* "unix-excl" */ /* zName */, FpAppData: 0 /* pAppData */, FxOpen: 0 /* xOpen */, FxDelete: 0 /* xDelete */, FxAccess: 0 /* xAccess */, FxFullPathname: 0 /* xFullPathname */, FxDlOpen: 0 /* xDlOpen */, FxDlError: 0 /* xDlError */, FxDlSym: 0 /* xDlSym */, FxDlClose: 0 /* xDlClose */, FxRandomness: 0 /* xRandomness */, FxSleep: 0 /* xSleep */, FxCurrentTime: 0 /* xCurrentTime */, FxGetLastError: 0 /* xGetLastError */, FxCurrentTimeInt64: 0 /* xCurrentTimeInt64 */, FxSetSystemCall: 0 /* xSetSystemCall */, FxGetSystemCall: 0 /* xGetSystemCall */, FxNextSystemCall: 0 /* xNextSystemCall */}, } /* sqlite3.c:41432:22 */ // Shutdown the operating system interface. @@ -26643,7 +26093,7 @@ var aVfs = [4]Sqlite3_vfs{ // This routine is a no-op for unix. func Xsqlite3_os_end(tls *libc.TLS) int32 { /* sqlite3.c:41479:16: */ unixBigLock = uintptr(0) - return 0 + return SQLITE_OK } //************* End of os_unix.c ******************************************** @@ -26699,83 +26149,36 @@ type MemFile1 = struct { type MemFile = MemFile1 /* sqlite3.c:47864:24 */ var memdb_vfs = Sqlite3_vfs{ - FiVersion: 2, - FszOsFile:// iVersion - 0, - FmxPathname:// szOsFile (set when registered) - 1024, - FpNext:// mxPathname - uintptr(0), - FzName:// pNext - ts + 5506, /* "memdb" */ - FpAppData:// zName - uintptr(0), - FxOpen:// pAppData (set when registered) - 0, - FxDelete:// xOpen - uintptr(0), - FxAccess:/* memdbDelete, */ // xDelete - 0, - FxFullPathname:// xAccess - 0, - FxDlOpen:// xFullPathname - 0, - FxDlError:// xDlOpen - 0, - FxDlSym:// xDlError - 0, - FxDlClose:// xDlSym - 0, - FxRandomness:// xDlClose - 0, - FxSleep:// xRandomness - 0, - FxCurrentTime:// xSleep - uintptr(0), - FxGetLastError:/* memdbCurrentTime, */ // xCurrentTime - 0, - FxCurrentTimeInt64:// xGetLastError - 0, // xCurrentTimeInt64 + FiVersion: 2, // szOsFile (set when registered) + FmxPathname: 1024, // pNext + FzName: ts + 5506, /* "memdb" */ // pAppData (set when registered) + FxOpen: 0, /* memdbDelete, */ // xDelete + FxAccess: 0, // xAccess + FxFullPathname: 0, // xFullPathname + FxDlOpen: 0, // xDlOpen + FxDlError: 0, // xDlError + FxDlSym: 0, // xDlSym + FxDlClose: 0, // xDlClose + FxRandomness: 0, // xRandomness + FxSleep: 0, /* memdbCurrentTime, */ // xCurrentTime + FxGetLastError: 0, // xGetLastError + FxCurrentTimeInt64: 0, // xCurrentTimeInt64 } /* sqlite3.c:47917:20 */ var memdb_io_methods = Sqlite3_io_methods{ - FiVersion: 3, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - 0, - FxUnlock:// xLock - 0, - FxCheckReservedLock:// xUnlock - same as xLock in this case - uintptr(0), - FxFileControl:/* memdbCheckReservedLock, */ // xCheckReservedLock - 0, - FxSectorSize:// xFileControl - uintptr(0), - FxDeviceCharacteristics:/* memdbSectorSize,*/ // xSectorSize - 0, - FxShmMap:// xDeviceCharacteristics - uintptr(0), - FxShmLock:// xShmMap - uintptr(0), - FxShmBarrier:// xShmLock - uintptr(0), - FxShmUnmap:// xShmBarrier - uintptr(0), - FxFetch:// xShmUnmap - 0, - FxUnfetch:// xFetch - 0, // xUnfetch + FiVersion: 3, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xFileSize + FxLock: 0, // xLock + FxUnlock: 0, /* memdbCheckReservedLock, */ // xCheckReservedLock + FxFileControl: 0, /* memdbSectorSize,*/ // xSectorSize + FxDeviceCharacteristics: 0, // xShmUnmap + FxFetch: 0, // xFetch + FxUnfetch: 0, // xUnfetch } /* sqlite3.c:47939:33 */ // Close an memdb-file. @@ -26784,10 +26187,10 @@ var memdb_io_methods = Sqlite3_io_methods{ // to free. func memdbClose(tls *libc.TLS, pFile uintptr) int32 { /* sqlite3.c:47969:12: */ var p uintptr = pFile - if ((*MemFile)(unsafe.Pointer(p)).FmFlags & uint32(1)) != 0 { + if ((*MemFile)(unsafe.Pointer(p)).FmFlags & SQLITE_DESERIALIZE_FREEONCLOSE) != 0 { Xsqlite3_free(tls, (*MemFile)(unsafe.Pointer(p)).FaData) } - return 0 + return SQLITE_OK } // Read data from an memdb-file. @@ -26798,20 +26201,20 @@ func memdbRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Sql if iOfst < (*MemFile)(unsafe.Pointer(p)).Fsz { libc.Xmemcpy(tls, zBuf, ((*MemFile)(unsafe.Pointer(p)).FaData + uintptr(iOfst)), (uint64((*MemFile)(unsafe.Pointer(p)).Fsz - iOfst))) } - return (10 | (int32(2) << 8)) + return (SQLITE_IOERR | (int32(2) << 8)) } libc.Xmemcpy(tls, zBuf, ((*MemFile)(unsafe.Pointer(p)).FaData + uintptr(iOfst)), uint64(iAmt)) - return 0 + return SQLITE_OK } // Try to enlarge the memory allocation to hold at least sz bytes func memdbEnlarge(tls *libc.TLS, p uintptr, newSz Sqlite3_int64) int32 { /* sqlite3.c:47997:12: */ var pNew uintptr - if (((*MemFile)(unsafe.Pointer(p)).FmFlags & uint32(2)) == uint32(0)) || ((*MemFile)(unsafe.Pointer(p)).FnMmap > 0) { - return 13 + if (((*MemFile)(unsafe.Pointer(p)).FmFlags & SQLITE_DESERIALIZE_RESIZEABLE) == uint32(0)) || ((*MemFile)(unsafe.Pointer(p)).FnMmap > 0) { + return SQLITE_FULL } if newSz > (*MemFile)(unsafe.Pointer(p)).FszMax { - return 13 + return SQLITE_FULL } newSz = newSz * (int64(2)) if newSz > (*MemFile)(unsafe.Pointer(p)).FszMax { @@ -26819,23 +26222,23 @@ func memdbEnlarge(tls *libc.TLS, p uintptr, newSz Sqlite3_int64) int32 { /* sqli } pNew = Xsqlite3Realloc(tls, (*MemFile)(unsafe.Pointer(p)).FaData, uint64(newSz)) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*MemFile)(unsafe.Pointer(p)).FaData = pNew (*MemFile)(unsafe.Pointer(p)).FszAlloc = newSz - return 0 + return SQLITE_OK } // Write data to an memdb-file. func memdbWrite(tls *libc.TLS, pFile uintptr, z uintptr, iAmt int32, iOfst Sqlite_int64) int32 { /* sqlite3.c:48017:12: */ var p uintptr = pFile - if ((*MemFile)(unsafe.Pointer(p)).FmFlags & uint32(4)) != 0 { - return 8 + if ((*MemFile)(unsafe.Pointer(p)).FmFlags & SQLITE_DESERIALIZE_READONLY) != 0 { + return SQLITE_READONLY } if (iOfst + Sqlite_int64(iAmt)) > (*MemFile)(unsafe.Pointer(p)).Fsz { var rc int32 if ((iOfst + Sqlite_int64(iAmt)) > (*MemFile)(unsafe.Pointer(p)).FszAlloc) && - ((libc.AssignInt32(&rc, memdbEnlarge(tls, p, (iOfst+Sqlite_int64(iAmt))))) != 0) { + ((libc.AssignInt32(&rc, memdbEnlarge(tls, p, (iOfst+Sqlite_int64(iAmt))))) != SQLITE_OK) { return rc } if iOfst > (*MemFile)(unsafe.Pointer(p)).Fsz { @@ -26844,7 +26247,7 @@ func memdbWrite(tls *libc.TLS, pFile uintptr, z uintptr, iAmt int32, iOfst Sqlit (*MemFile)(unsafe.Pointer(p)).Fsz = (iOfst + Sqlite_int64(iAmt)) } libc.Xmemcpy(tls, ((*MemFile)(unsafe.Pointer(p)).FaData + uintptr(iOfst)), z, uint64(iAmt)) - return 0 + return SQLITE_OK } // Truncate an memdb-file. @@ -26855,33 +26258,33 @@ func memdbWrite(tls *libc.TLS, pFile uintptr, z uintptr, iAmt int32, iOfst Sqlit func memdbTruncate(tls *libc.TLS, pFile uintptr, size Sqlite_int64) int32 { /* sqlite3.c:48046:12: */ var p uintptr = pFile if size > (*MemFile)(unsafe.Pointer(p)).Fsz { - return 13 + return SQLITE_FULL } (*MemFile)(unsafe.Pointer(p)).Fsz = size - return 0 + return SQLITE_OK } // Sync an memdb-file. func memdbSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* sqlite3.c:48056:12: */ - return 0 + return SQLITE_OK } // Return the current file-size of an memdb-file. func memdbFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* sqlite3.c:48063:12: */ var p uintptr = pFile *(*Sqlite_int64)(unsafe.Pointer(pSize)) = (*MemFile)(unsafe.Pointer(p)).Fsz - return 0 + return SQLITE_OK } // Lock an memdb-file. func memdbLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* sqlite3.c:48072:12: */ var p uintptr = pFile - if (eLock > 1) && - (((*MemFile)(unsafe.Pointer(p)).FmFlags & uint32(4)) != uint32(0)) { - return 8 + if (eLock > SQLITE_LOCK_SHARED) && + (((*MemFile)(unsafe.Pointer(p)).FmFlags & SQLITE_DESERIALIZE_READONLY) != uint32(0)) { + return SQLITE_READONLY } (*MemFile)(unsafe.Pointer(p)).FeLock = eLock - return 0 + return SQLITE_OK } // File control method. For custom operations on an memdb-file. @@ -26890,12 +26293,12 @@ func memdbFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int3 defer tls.Free(16) var p uintptr = pFile - var rc int32 = 12 - if op == 12 { + var rc int32 = SQLITE_NOTFOUND + if op == SQLITE_FCNTL_VFSNAME { *(*uintptr)(unsafe.Pointer(pArg)) = Xsqlite3_mprintf(tls, ts+5512 /* "memdb(%p,%lld)" */, libc.VaList(bp, (*MemFile)(unsafe.Pointer(p)).FaData, (*MemFile)(unsafe.Pointer(p)).Fsz)) - rc = 0 + rc = SQLITE_OK } - if op == 36 { + if op == SQLITE_FCNTL_SIZE_LIMIT { var iLimit Sqlite3_int64 = *(*Sqlite3_int64)(unsafe.Pointer(pArg)) if iLimit < (*MemFile)(unsafe.Pointer(p)).Fsz { if iLimit < int64(0) { @@ -26906,14 +26309,14 @@ func memdbFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int3 } (*MemFile)(unsafe.Pointer(p)).FszMax = iLimit *(*Sqlite3_int64)(unsafe.Pointer(pArg)) = iLimit - rc = 0 + rc = SQLITE_OK } return rc } // Return the device characteristic flags supported by an memdb-file. func memdbDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* sqlite3.c:48131:12: */ - return (((0x00000001 | 0x00001000) | 0x00000200) | 0x00000400) + return (((SQLITE_IOCAP_ATOMIC | SQLITE_IOCAP_POWERSAFE_OVERWRITE) | SQLITE_IOCAP_SAFE_APPEND) | SQLITE_IOCAP_SEQUENTIAL) } // Fetch a page of a memory-mapped file @@ -26925,29 +26328,29 @@ func memdbFetch(tls *libc.TLS, pFile uintptr, iOfst Sqlite3_int64, iAmt int32, p (*MemFile)(unsafe.Pointer(p)).FnMmap++ *(*uintptr)(unsafe.Pointer(pp)) = ((*MemFile)(unsafe.Pointer(p)).FaData + uintptr(iOfst)) } - return 0 + return SQLITE_OK } // Release a memory-mapped page func memdbUnfetch(tls *libc.TLS, pFile uintptr, iOfst Sqlite3_int64, pPage uintptr) int32 { /* sqlite3.c:48156:12: */ var p uintptr = pFile (*MemFile)(unsafe.Pointer(p)).FnMmap-- - return 0 + return SQLITE_OK } // Open an mem file handle. func memdbOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { /* sqlite3.c:48165:12: */ var p uintptr = pFile - if (flags & 0x00000100) == 0 { + if (flags & SQLITE_OPEN_MAIN_DB) == 0 { return (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 40 /* &.xOpen */))))(tls, (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zName, pFile, flags, pOutFlags) } libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(MemFile{}))) - (*MemFile)(unsafe.Pointer(p)).FmFlags = (uint32(2 | 1)) + (*MemFile)(unsafe.Pointer(p)).FmFlags = (uint32(SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE)) // True because flags==SQLITE_OPEN_MAIN_DB - *(*int32)(unsafe.Pointer(pOutFlags)) = (flags | 0x00000080) + *(*int32)(unsafe.Pointer(pOutFlags)) = (flags | SQLITE_OPEN_MEMORY) (*Sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&memdb_io_methods)) (*MemFile)(unsafe.Pointer(p)).FszMax = Xsqlite3Config.FmxMemdbSize - return 0 + return SQLITE_OK } // Test for access permissions. Return true if the requested permission @@ -26956,7 +26359,7 @@ func memdbOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags // With memdb, no files ever exist on disk. So always return false. func memdbAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 { /* sqlite3.c:48203:12: */ *(*int32)(unsafe.Pointer(pResOut)) = 0 - return 0 + return SQLITE_OK } // Populate buffer zOut with the full canonical pathname corresponding @@ -26967,7 +26370,7 @@ func memdbFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, z defer tls.Free(8) Xsqlite3_snprintf(tls, nOut, zOut, ts+824 /* "%s" */, libc.VaList(bp, zPath)) - return 0 + return SQLITE_OK } // Open the dynamic library located at zPath and return a handle. @@ -27019,7 +26422,7 @@ func memdbFromDbSchema(tls *libc.TLS, db uintptr, zSchema uintptr) uintptr { /* defer tls.Free(8) *(*uintptr)(unsafe.Pointer(bp /* p */)) = uintptr(0) - var rc int32 = Xsqlite3_file_control(tls, db, zSchema, 7, bp /* &p */) + var rc int32 = Xsqlite3_file_control(tls, db, zSchema, SQLITE_FCNTL_FILE_POINTER, bp /* &p */) if rc != 0 { return uintptr(0) } @@ -27045,7 +26448,7 @@ func Xsqlite3_serialize(tls *libc.TLS, db uintptr, zSchema uintptr, piSize uintp var rc int32 if zSchema == uintptr(0) { - zSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FzDbSName + zSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName } p = memdbFromDbSchema(tls, db, zSchema) iDb = Xsqlite3FindDbName(tls, db, zSchema) @@ -27059,7 +26462,7 @@ func Xsqlite3_serialize(tls *libc.TLS, db uintptr, zSchema uintptr, piSize uintp if piSize != 0 { *(*Sqlite3_int64)(unsafe.Pointer(piSize)) = (*MemFile)(unsafe.Pointer(p)).Fsz } - if (mFlags & uint32(0x001)) != 0 { + if (mFlags & SQLITE_SERIALIZE_NOCOPY) != 0 { pOut = (*MemFile)(unsafe.Pointer(p)).FaData } else { pOut = Xsqlite3_malloc64(tls, uint64((*MemFile)(unsafe.Pointer(p)).Fsz)) @@ -27078,21 +26481,21 @@ func Xsqlite3_serialize(tls *libc.TLS, db uintptr, zSchema uintptr, piSize uintp if zSql != 0 { rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+8 /* &pStmt */, uintptr(0)) } else { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3_free(tls, zSql) if rc != 0 { return uintptr(0) } rc = Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) - if rc != 100 { + if rc != SQLITE_ROW { pOut = uintptr(0) } else { sz = (Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 0) * Sqlite_int64(szPage)) if piSize != 0 { *(*Sqlite3_int64)(unsafe.Pointer(piSize)) = sz } - if (mFlags & uint32(0x001)) != 0 { + if (mFlags & SQLITE_SERIALIZE_NOCOPY) != 0 { pOut = uintptr(0) } else { pOut = Xsqlite3_malloc64(tls, uint64(sz)) @@ -27104,7 +26507,7 @@ func Xsqlite3_serialize(tls *libc.TLS, db uintptr, zSchema uintptr, piSize uintp *(*uintptr)(unsafe.Pointer(bp + 16 /* pPage */)) = uintptr(0) var pTo uintptr = (pOut + uintptr((Sqlite3_int64(szPage) * (Sqlite3_int64(pgno - 1))))) rc = Xsqlite3PagerGet(tls, pPager, uint32(pgno), bp+16 /* &pPage */, 0) - if rc == 0 { + if rc == SQLITE_OK { libc.Xmemcpy(tls, pTo, Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pPage */))), uint64(szPage)) } else { libc.Xmemset(tls, pTo, 0, uint64(szPage)) @@ -27135,14 +26538,14 @@ func Xsqlite3_deserialize(tls *libc.TLS, db uintptr, zSchema uintptr, pData uint if !(zSchema == uintptr(0)) { goto __1 } - zSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FzDbSName + zSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName __1: ; iDb = Xsqlite3FindDbName(tls, db, zSchema) if !(iDb < 0) { goto __2 } - rc = 1 + rc = SQLITE_ERROR goto end_deserialize __2: ; @@ -27159,10 +26562,10 @@ __3: libc.SetBitFieldPtr8Uint32(db+176 /* &.init */ +8 /* &.reopenMemdb */, uint32(1), 2, 0x4) rc = Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) libc.SetBitFieldPtr8Uint32(db+176 /* &.init */ +8 /* &.reopenMemdb */, uint32(0), 2, 0x4) - if !(rc != 101) { + if !(rc != SQLITE_DONE) { goto __4 } - rc = 1 + rc = SQLITE_ERROR goto end_deserialize __4: ; @@ -27170,7 +26573,7 @@ __4: if !(p == uintptr(0)) { goto __5 } - rc = 1 + rc = SQLITE_ERROR goto __6 __5: (*MemFile)(unsafe.Pointer(p)).FaData = pData @@ -27184,7 +26587,7 @@ __5: __7: ; (*MemFile)(unsafe.Pointer(p)).FmFlags = mFlags - rc = 0 + rc = SQLITE_OK __6: ; @@ -27241,15 +26644,15 @@ func Xsqlite3BitvecTestNotNull(tls *libc.TLS, p uintptr, i U32) int32 { /* sqlit return 0 } } - if uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) <= (((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * uint64(8)) { - return (libc.Bool32((int32(*(*U8)(unsafe.Pointer((p + 16 /* &.u */ /* &.aBitmap */) + uintptr((i / U32(8)))))) & (int32(1) << (i & (U32(8 - 1))))) != 0)) + if uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) <= (((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * BITVEC_SZELEM) { + return (libc.Bool32((int32(*(*U8)(unsafe.Pointer((p + 16 /* &.u */ /* &.aBitmap */) + uintptr((i / BITVEC_SZELEM))))) & (int32(1) << (i & (U32(BITVEC_SZELEM - 1))))) != 0)) } else { - var h U32 = (U32((uint64((libc.PostIncUint32(&i, 1)) * U32(1))) % ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) + var h U32 = (U32((uint64((libc.PostIncUint32(&i, 1)) * U32(1))) % ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) for *(*U32)(unsafe.Pointer((p + 16 /* &.u */ /* &.aHash */) + uintptr(h)*4)) != 0 { if *(*U32)(unsafe.Pointer((p + 16 /* &.u */ /* &.aHash */) + uintptr(h)*4)) == i { return 1 } - h = (U32((uint64(h + U32(1))) % ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) + h = (U32((uint64(h + U32(1))) % ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) } return 0 } @@ -27279,13 +26682,13 @@ func Xsqlite3BitvecSet(tls *libc.TLS, p uintptr, i U32) int32 { /* sqlite3.c:486 if !(p == uintptr(0)) { goto __1 } - return 0 + return SQLITE_OK __1: ; i-- __2: - if !((uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) > (((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * uint64(8))) && ((*Bitvec)(unsafe.Pointer(p)).FiDivisor != 0)) { + if !((uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) > (((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * BITVEC_SZELEM)) && ((*Bitvec)(unsafe.Pointer(p)).FiDivisor != 0)) { goto __3 } bin = (i / (*Bitvec)(unsafe.Pointer(p)).FiDivisor) @@ -27297,7 +26700,7 @@ __2: if !(*(*uintptr)(unsafe.Pointer((p + 16 /* &.u */ /* &.apSub */) + uintptr(bin)*8)) == uintptr(0)) { goto __5 } - return 7 + return SQLITE_NOMEM __5: ; __4: @@ -27306,21 +26709,21 @@ __4: goto __2 __3: ; - if !(uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) <= (((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * uint64(8))) { + if !(uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) <= (((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * BITVEC_SZELEM)) { goto __6 } - *(*U8)(unsafe.Pointer((p + 16 /* &.u */ /* &.aBitmap */) + uintptr((i / U32(8))))) |= U8((int32(1) << (i & (U32(8 - 1))))) - return 0 + *(*U8)(unsafe.Pointer((p + 16 /* &.u */ /* &.aBitmap */) + uintptr((i / BITVEC_SZELEM)))) |= U8((int32(1) << (i & (U32(BITVEC_SZELEM - 1))))) + return SQLITE_OK __6: ; - h = (U32((uint64((libc.PostIncUint32(&i, 1)) * U32(1))) % ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) + h = (U32((uint64((libc.PostIncUint32(&i, 1)) * U32(1))) % ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) // if there wasn't a hash collision, and this doesn't // completely fill the hash, then just add it without // worring about sub-dividing and re-hashing. if !(!(int32(*(*U32)(unsafe.Pointer((p + 16 /* &.u */ /* &.aHash */) + uintptr(h)*4))) != 0)) { goto __7 } - if !(uint64((*Bitvec)(unsafe.Pointer(p)).FnSet) < (((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))) - uint64(1))) { + if !(uint64((*Bitvec)(unsafe.Pointer(p)).FnSet) < (((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))) - uint64(1))) { goto __8 } goto bitvec_set_end @@ -27337,11 +26740,11 @@ __10: if !(*(*U32)(unsafe.Pointer((p + 16 /* &.u */ /* &.aHash */) + uintptr(h)*4)) == i) { goto __13 } - return 0 + return SQLITE_OK __13: ; h++ - if !(uint64(h) >= ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0))))) { + if !(uint64(h) >= ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0))))) { goto __14 } h = U32(0) @@ -27359,23 +26762,23 @@ __12: // available free spot. check to see if this is going to // make our hash too "full". bitvec_set_rehash: - if !(uint64((*Bitvec)(unsafe.Pointer(p)).FnSet) >= (((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))) / uint64(2))) { + if !(uint64((*Bitvec)(unsafe.Pointer(p)).FnSet) >= (((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))) / uint64(2))) { goto __15 } aiValues = Xsqlite3DbMallocRaw(tls, uintptr(0), uint64(unsafe.Sizeof([124]U32{}))) if !(aiValues == uintptr(0)) { goto __16 } - return 7 + return SQLITE_NOMEM goto __17 __16: libc.Xmemcpy(tls, aiValues, p+16 /* &.u */ /* &.aHash */, uint64(unsafe.Sizeof([124]U32{}))) libc.Xmemset(tls, p+16 /* &.u */ /* &.apSub */, 0, uint64(unsafe.Sizeof([62]uintptr{}))) - (*Bitvec)(unsafe.Pointer(p)).FiDivisor = (U32(((uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) + ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(uintptr(0))))) - uint64(1)) / ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(uintptr(0)))))) + (*Bitvec)(unsafe.Pointer(p)).FiDivisor = (U32(((uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) + ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(uintptr(0))))) - uint64(1)) / ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(uintptr(0)))))) rc = Xsqlite3BitvecSet(tls, p, i) j = uint32(0) __18: - if !(uint64(j) < ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0))))) { + if !(uint64(j) < ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0))))) { goto __20 } if !(*(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) != 0) { @@ -27400,7 +26803,7 @@ __15: bitvec_set_end: (*Bitvec)(unsafe.Pointer(p)).FnSet++ *(*U32)(unsafe.Pointer((p + 16 /* &.u */ /* &.aHash */) + uintptr(h)*4)) = i - return 0 + return SQLITE_OK } // Clear the i-th bit. @@ -27421,21 +26824,21 @@ func Xsqlite3BitvecClear(tls *libc.TLS, p uintptr, i U32, pBuf uintptr) { /* sql return } } - if uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) <= (((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * uint64(8)) { - *(*U8)(unsafe.Pointer((p + 16 /* &.u */ /* &.aBitmap */) + uintptr((i / U32(8))))) &= U8((^(int32(1) << (i & (U32(8 - 1)))))) + if uint64((*Bitvec)(unsafe.Pointer(p)).FiSize) <= (((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U8(0)))) * BITVEC_SZELEM) { + *(*U8)(unsafe.Pointer((p + 16 /* &.u */ /* &.aBitmap */) + uintptr((i / BITVEC_SZELEM)))) &= U8((^(int32(1) << (i & (U32(BITVEC_SZELEM - 1)))))) } else { var j uint32 var aiValues uintptr = pBuf libc.Xmemcpy(tls, aiValues, p+16 /* &.u */ /* &.aHash */, uint64(unsafe.Sizeof([124]U32{}))) libc.Xmemset(tls, p+16 /* &.u */ /* &.aHash */, 0, uint64(unsafe.Sizeof([124]U32{}))) (*Bitvec)(unsafe.Pointer(p)).FnSet = U32(0) - for j = uint32(0); uint64(j) < ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))); j++ { + for j = uint32(0); uint64(j) < ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))); j++ { if (*(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) != 0) && (*(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) != (i + U32(1))) { - var h U32 = (U32((uint64((*(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) - U32(1)) * U32(1))) % ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) + var h U32 = (U32((uint64((*(*U32)(unsafe.Pointer(aiValues + uintptr(j)*4)) - U32(1)) * U32(1))) % ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))))) (*Bitvec)(unsafe.Pointer(p)).FnSet++ for *(*U32)(unsafe.Pointer((p + 16 /* &.u */ /* &.aHash */) + uintptr(h)*4)) != 0 { h++ - if uint64(h) >= ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))) { + if uint64(h) >= ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(U32(0)))) { h = U32(0) } } @@ -27452,7 +26855,7 @@ func Xsqlite3BitvecDestroy(tls *libc.TLS, p uintptr) { /* sqlite3.c:48742:21: */ } if (*Bitvec)(unsafe.Pointer(p)).FiDivisor != 0 { var i uint32 - for i = uint32(0); uint64(i) < ((((uint64(512) - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { + for i = uint32(0); uint64(i) < ((((BITVEC_SZ - (uint64(3) * uint64(unsafe.Sizeof(U32(0))))) / uint64(unsafe.Sizeof(uintptr(0)))) * uint64(unsafe.Sizeof(uintptr(0)))) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { Xsqlite3BitvecDestroy(tls, *(*uintptr)(unsafe.Pointer((p + 16 /* &.u */ /* &.apSub */) + uintptr(i)*8))) } } @@ -27519,7 +26922,7 @@ func Xsqlite3BitvecBuiltinTest(tls *libc.TLS, sz int32, aOp uintptr) int32 { /* // bits to act as the reference pBitvec = Xsqlite3BitvecCreate(tls, uint32(sz)) pV = Xsqlite3MallocZero(tls, (uint64(((sz + 7) / 8) + 1))) - pTmpSpace = Xsqlite3_malloc64(tls, uint64(512)) + pTmpSpace = Xsqlite3_malloc64(tls, BITVEC_SZ) if !(((pBitvec == uintptr(0)) || (pV == uintptr(0))) || (pTmpSpace == uintptr(0))) { goto __1 } @@ -27664,7 +27067,7 @@ bitvec_end: func pcacheManageDirtyList(tls *libc.TLS, pPage uintptr, addRemove U8) { /* sqlite3.c:49037:13: */ var p uintptr = (*PgHdr)(unsafe.Pointer(pPage)).FpCache - if (int32(addRemove) & 1) != 0 { + if (int32(addRemove) & PCACHE_DIRTYLIST_REMOVE) != 0 { // Update the PCache1.pSynced variable if necessary. if (*PCache)(unsafe.Pointer(p)).FpSynced == pPage { @@ -27693,7 +27096,7 @@ func pcacheManageDirtyList(tls *libc.TLS, pPage uintptr, addRemove U8) { /* sqli } } } - if (int32(addRemove) & 2) != 0 { + if (int32(addRemove) & PCACHE_DIRTYLIST_ADD) != 0 { (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyPrev = uintptr(0) (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyNext = (*PCache)(unsafe.Pointer(p)).FpDirty if (*PgHdr)(unsafe.Pointer(pPage)).FpDirtyNext != 0 { @@ -27714,7 +27117,7 @@ func pcacheManageDirtyList(tls *libc.TLS, pPage uintptr, addRemove U8) { /* sqli // flag set sqlite3PcacheFetchStress() searches through all newer // entries of the dirty-list for a page with NEED_SYNC clear anyway. if !(int32((*PCache)(unsafe.Pointer(p)).FpSynced) != 0) && - (0 == (int32((*PgHdr)(unsafe.Pointer(pPage)).Fflags) & 0x008)) { + (0 == (int32((*PgHdr)(unsafe.Pointer(pPage)).Fflags) & PGHDR_NEED_SYNC)) { (*PCache)(unsafe.Pointer(p)).FpSynced = pPage } } @@ -27808,10 +27211,10 @@ func Xsqlite3PcacheSetPageSize(tls *libc.TLS, pCache uintptr, szPage int32) int3 if (*PCache)(unsafe.Pointer(pCache)).FszPage != 0 { var pNew uintptr pNew = (*(*func(*libc.TLS, int32, int32, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 168 /* &.pcache2 */ + 32 /* &.xCreate */))))(tls, - szPage, (int32(uint64((*PCache)(unsafe.Pointer(pCache)).FszExtra) + (((uint64(unsafe.Sizeof(PgHdr{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))), + szPage, (int32(uint64((*PCache)(unsafe.Pointer(pCache)).FszExtra) + (((uint64(unsafe.Sizeof(PgHdr{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))))), int32((*PCache)(unsafe.Pointer(pCache)).FbPurgeable)) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 168 /* &.pcache2 */ + 40 /* &.xCachesize */))))(tls, pNew, numberOfCachePages(tls, pCache)) if (*PCache)(unsafe.Pointer(pCache)).FpCache != 0 { @@ -27821,7 +27224,7 @@ func Xsqlite3PcacheSetPageSize(tls *libc.TLS, pCache uintptr, szPage int32) int3 (*PCache)(unsafe.Pointer(pCache)).FszPage = szPage } - return 0 + return SQLITE_OK } // Try to obtain a page from the cache. @@ -27888,7 +27291,7 @@ func Xsqlite3PcacheFetchStress(tls *libc.TLS, pCache uintptr, pgno Pgno, ppPage // flag is currently referenced, then the following may leave pSynced // set incorrectly (pointing to other than the LRU page with NEED_SYNC // cleared). This is Ok, as pSynced is just an optimization. - for pPg = (*PCache)(unsafe.Pointer(pCache)).FpSynced; (pPg != 0) && (((*PgHdr)(unsafe.Pointer(pPg)).FnRef != 0) || ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & 0x008) != 0)); pPg = (*PgHdr)(unsafe.Pointer(pPg)).FpDirtyPrev { + for pPg = (*PCache)(unsafe.Pointer(pCache)).FpSynced; (pPg != 0) && (((*PgHdr)(unsafe.Pointer(pPg)).FnRef != 0) || ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & PGHDR_NEED_SYNC) != 0)); pPg = (*PgHdr)(unsafe.Pointer(pPg)).FpDirtyPrev { } (*PCache)(unsafe.Pointer(pCache)).FpSynced = pPg if !(pPg != 0) { @@ -27900,16 +27303,16 @@ func Xsqlite3PcacheFetchStress(tls *libc.TLS, pCache uintptr, pgno Pgno, ppPage rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pCache + 48 /* &.xStress */))))(tls, (*PCache)(unsafe.Pointer(pCache)).FpStress, pPg) - if (rc != 0) && (rc != 5) { + if (rc != SQLITE_OK) && (rc != SQLITE_BUSY) { return rc } } } *(*uintptr)(unsafe.Pointer(ppPage)) = (*(*func(*libc.TLS, uintptr, uint32, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 168 /* &.pcache2 */ + 56 /* &.xFetch */))))(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache, pgno, 2) if *(*uintptr)(unsafe.Pointer(ppPage)) == uintptr(0) { - return 7 + return SQLITE_NOMEM } - return 0 + return SQLITE_OK } // This is a helper routine for sqlite3PcacheFetchFinish() @@ -27927,11 +27330,11 @@ func pcacheFetchFinishWithInit(tls *libc.TLS, pCache uintptr, pgno Pgno, pPage u libc.Xmemset(tls, (pPgHdr + 32 /* &.pDirty */), 0, (uint64(unsafe.Sizeof(PgHdr{})) - (uint64((uintptr(0) + 32 /* &.pDirty */))))) (*PgHdr)(unsafe.Pointer(pPgHdr)).FpPage = pPage (*PgHdr)(unsafe.Pointer(pPgHdr)).FpData = (*Sqlite3_pcache_page)(unsafe.Pointer(pPage)).FpBuf - (*PgHdr)(unsafe.Pointer(pPgHdr)).FpExtra = (pPgHdr + uintptr(1)*72) + (*PgHdr)(unsafe.Pointer(pPgHdr)).FpExtra = (pPgHdr + 1*72) libc.Xmemset(tls, (*PgHdr)(unsafe.Pointer(pPgHdr)).FpExtra, 0, uint64(8)) (*PgHdr)(unsafe.Pointer(pPgHdr)).FpCache = pCache (*PgHdr)(unsafe.Pointer(pPgHdr)).Fpgno = pgno - (*PgHdr)(unsafe.Pointer(pPgHdr)).Fflags = U16(0x001) + (*PgHdr)(unsafe.Pointer(pPgHdr)).Fflags = PGHDR_CLEAN return Xsqlite3PcacheFetchFinish(tls, pCache, pgno, pPage) } @@ -27959,10 +27362,10 @@ func Xsqlite3PcacheRelease(tls *libc.TLS, p uintptr) { /* sqlite3.c:49388:37: */ (*PCache)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum-- if (int32(libc.PreDecInt16(&(*PgHdr)(unsafe.Pointer(p)).FnRef, 1))) == 0 { - if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & 0x001) != 0 { + if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & PGHDR_CLEAN) != 0 { pcacheUnpin(tls, p) } else { - pcacheManageDirtyList(tls, p, uint8(3)) + pcacheManageDirtyList(tls, p, PCACHE_DIRTYLIST_FRONT) } } } @@ -27979,8 +27382,8 @@ func Xsqlite3PcacheRef(tls *libc.TLS, p uintptr) { /* sqlite3.c:49403:21: */ // page pointed to by p is invalid. func Xsqlite3PcacheDrop(tls *libc.TLS, p uintptr) { /* sqlite3.c:49415:21: */ - if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & 0x002) != 0 { - pcacheManageDirtyList(tls, p, uint8(1)) + if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & PGHDR_DIRTY) != 0 { + pcacheManageDirtyList(tls, p, PCACHE_DIRTYLIST_REMOVE) } (*PCache)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum-- (*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 168 /* &.pcache2 */ + 64 /* &.xUnpin */))))(tls, (*PCache)(unsafe.Pointer((*PgHdr)(unsafe.Pointer(p)).FpCache)).FpCache, (*PgHdr)(unsafe.Pointer(p)).FpPage, 1) @@ -27990,12 +27393,12 @@ func Xsqlite3PcacheDrop(tls *libc.TLS, p uintptr) { /* sqlite3.c:49415:21: */ // make it so. func Xsqlite3PcacheMakeDirty(tls *libc.TLS, p uintptr) { /* sqlite3.c:49429:21: */ - if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & (0x001 | 0x010)) != 0 { //OPTIMIZATION-IF-FALSE - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x010))) - if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & 0x001) != 0 { - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) ^= U16((0x002 | 0x001)) + if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & (PGHDR_CLEAN | PGHDR_DONT_WRITE)) != 0 { //OPTIMIZATION-IF-FALSE + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(PGHDR_DONT_WRITE))) + if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & PGHDR_CLEAN) != 0 { + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) ^= U16((PGHDR_DIRTY | PGHDR_CLEAN)) - pcacheManageDirtyList(tls, p, uint8(2)) + pcacheManageDirtyList(tls, p, PCACHE_DIRTYLIST_ADD) } } @@ -28005,9 +27408,9 @@ func Xsqlite3PcacheMakeDirty(tls *libc.TLS, p uintptr) { /* sqlite3.c:49429:21: // make it so. func Xsqlite3PcacheMakeClean(tls *libc.TLS, p uintptr) { /* sqlite3.c:49448:21: */ - pcacheManageDirtyList(tls, p, uint8(1)) - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((0x002 | 0x008) | 0x004)))) - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) |= U16((0x001)) + pcacheManageDirtyList(tls, p, PCACHE_DIRTYLIST_REMOVE) + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((PGHDR_DIRTY | PGHDR_NEED_SYNC) | PGHDR_WRITEABLE)))) + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) |= U16((PGHDR_CLEAN)) if int32((*PgHdr)(unsafe.Pointer(p)).FnRef) == 0 { pcacheUnpin(tls, p) @@ -28028,7 +27431,7 @@ func Xsqlite3PcacheClearWritable(tls *libc.TLS, pCache uintptr) { /* sqlite3.c:4 var p uintptr for p = (*PCache)(unsafe.Pointer(pCache)).FpDirty; p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirtyNext { - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32((0x008 | 0x004)))) + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32((PGHDR_NEED_SYNC | PGHDR_WRITEABLE)))) } (*PCache)(unsafe.Pointer(pCache)).FpSynced = (*PCache)(unsafe.Pointer(pCache)).FpDirtyTail } @@ -28037,7 +27440,7 @@ func Xsqlite3PcacheClearWritable(tls *libc.TLS, pCache uintptr) { /* sqlite3.c:4 func Xsqlite3PcacheClearSyncFlags(tls *libc.TLS, pCache uintptr) { /* sqlite3.c:49488:21: */ var p uintptr for p = (*PCache)(unsafe.Pointer(pCache)).FpDirty; p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirtyNext { - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x008))) + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(PGHDR_NEED_SYNC))) } (*PCache)(unsafe.Pointer(pCache)).FpSynced = (*PCache)(unsafe.Pointer(pCache)).FpDirtyTail } @@ -28048,8 +27451,8 @@ func Xsqlite3PcacheMove(tls *libc.TLS, p uintptr, newPgno Pgno) { /* sqlite3.c:4 (*(*func(*libc.TLS, uintptr, uintptr, uint32, uint32))(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3Config)) + 168 /* &.pcache2 */ + 72 /* &.xRekey */))))(tls, (*PCache)(unsafe.Pointer(pCache)).FpCache, (*PgHdr)(unsafe.Pointer(p)).FpPage, (*PgHdr)(unsafe.Pointer(p)).Fpgno, newPgno) (*PgHdr)(unsafe.Pointer(p)).Fpgno = newPgno - if ((int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & 0x002) != 0) && ((int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & 0x008) != 0) { - pcacheManageDirtyList(tls, p, uint8(3)) + if ((int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & PGHDR_DIRTY) != 0) && ((int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & PGHDR_NEED_SYNC) != 0) { + pcacheManageDirtyList(tls, p, PCACHE_DIRTYLIST_FRONT) } } @@ -28154,7 +27557,7 @@ func pcacheSortDirtyList(tls *libc.TLS, pIn uintptr) uintptr { /* sqlite3.c:4960 p = pIn pIn = (*PgHdr)(unsafe.Pointer(p)).FpDirty (*PgHdr)(unsafe.Pointer(p)).FpDirty = uintptr(0) - for i = 0; i < (32 - 1); i++ { + for i = 0; i < (N_SORT_BUCKET - 1); i++ { if *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(i)*8)) == uintptr(0) { *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(i)*8)) = p break @@ -28163,14 +27566,14 @@ func pcacheSortDirtyList(tls *libc.TLS, pIn uintptr) uintptr { /* sqlite3.c:4960 *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(i)*8)) = uintptr(0) } } - if i == (32 - 1) { + if i == (N_SORT_BUCKET - 1) { // To get here, there need to be 2^(N_SORT_BUCKET) elements in // the input list. But that is impossible. *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(i)*8)) = pcacheMergeDirtyList(tls, *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(i)*8)), p) } } - p = *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(0)*8)) - for i = 1; i < 32; i++ { + p = *(*uintptr)(unsafe.Pointer(bp /* &a[0] */)) + for i = 1; i < N_SORT_BUCKET; i++ { if *(*uintptr)(unsafe.Pointer(bp /* &a[0] */ + uintptr(i)*8)) == uintptr(0) { continue } @@ -28252,7 +27655,7 @@ func Xsqlite3PcacheShrink(tls *libc.TLS, pCache uintptr) { /* sqlite3.c:49717:21 // Return the size of the header added by this middleware layer // in the page-cache hierarchy. func Xsqlite3HeaderSizePcache(tls *libc.TLS) int32 { /* sqlite3.c:49726:20: */ - return (int32(((uint64(unsafe.Sizeof(PgHdr{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + return (int32(((uint64(unsafe.Sizeof(PgHdr{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) } // Return the number of dirty pages currently in the cache, as a percentage @@ -28530,7 +27933,7 @@ func Xsqlite3PCacheBufferSetup(tls *libc.TLS, pBuf uintptr, sz int32, n int32) { if n == 0 { sz = 0 } - sz = ((sz) & ^libc.Int32(7)) + sz = ((sz) & libc.CplInt32(7)) pcache1_g.FszSlot = sz pcache1_g.FnSlot = libc.AssignPtrInt32(uintptr(unsafe.Pointer(&pcache1_g))+136 /* &.nFreeSlot */, n) pcache1_g.FnReserve = func() int32 { @@ -28580,7 +27983,7 @@ func pcache1InitBulk(tls *libc.TLS, pCache uintptr) int32 { /* sqlite3.c:50054:1 for ok := true; ok; ok = libc.PreDecInt32(&nBulk, 1) != 0 { var pX uintptr = (zBulk + uintptr((*PCache1)(unsafe.Pointer(pCache)).FszPage)) (*PgHdr1)(unsafe.Pointer(pX)).Fpage.FpBuf = zBulk - (*PgHdr1)(unsafe.Pointer(pX)).Fpage.FpExtra = (pX + uintptr(1)*56) + (*PgHdr1)(unsafe.Pointer(pX)).Fpage.FpExtra = (pX + 1*56) (*PgHdr1)(unsafe.Pointer(pX)).FisBulkLocal = U16(1) (*PgHdr1)(unsafe.Pointer(pX)).FisAnchor = U16(0) (*PgHdr1)(unsafe.Pointer(pX)).FpNext = (*PCache1)(unsafe.Pointer(pCache)).FpFree @@ -28610,8 +28013,8 @@ func pcache1Alloc(tls *libc.TLS, nByte int32) uintptr { /* sqlite3.c:50097:13: * pcache1_g.FnFreeSlot-- pcache1_g.FbUnderPressure = (libc.Bool32(pcache1_g.FnFreeSlot < pcache1_g.FnReserve)) - Xsqlite3StatusHighwater(tls, 7, nByte) - Xsqlite3StatusUp(tls, 1, 1) + Xsqlite3StatusHighwater(tls, SQLITE_STATUS_PAGECACHE_SIZE, nByte) + Xsqlite3StatusUp(tls, SQLITE_STATUS_PAGECACHE_USED, 1) } Xsqlite3_mutex_leave(tls, pcache1_g.Fmutex) } @@ -28622,8 +28025,8 @@ func pcache1Alloc(tls *libc.TLS, nByte int32) uintptr { /* sqlite3.c:50097:13: * if p != 0 { var sz int32 = Xsqlite3MallocSize(tls, p) Xsqlite3_mutex_enter(tls, pcache1_g.Fmutex) - Xsqlite3StatusHighwater(tls, 7, nByte) - Xsqlite3StatusUp(tls, 2, sz) + Xsqlite3StatusHighwater(tls, SQLITE_STATUS_PAGECACHE_SIZE, nByte) + Xsqlite3StatusUp(tls, SQLITE_STATUS_PAGECACHE_OVERFLOW, sz) Xsqlite3_mutex_leave(tls, pcache1_g.Fmutex) } @@ -28639,7 +28042,7 @@ func pcache1Free(tls *libc.TLS, p uintptr) { /* sqlite3.c:50135:13: */ if (Uptr((p)) >= Uptr((pcache1_g.FpStart))) && (Uptr((p)) < Uptr((pcache1_g.FpEnd))) { var pSlot uintptr Xsqlite3_mutex_enter(tls, pcache1_g.Fmutex) - Xsqlite3StatusDown(tls, 1, 1) + Xsqlite3StatusDown(tls, SQLITE_STATUS_PAGECACHE_USED, 1) pSlot = p (*PgFreeslot)(unsafe.Pointer(pSlot)).FpNext = pcache1_g.FpFree pcache1_g.FpFree = pSlot @@ -28653,7 +28056,7 @@ func pcache1Free(tls *libc.TLS, p uintptr) { /* sqlite3.c:50135:13: */ var nFreed int32 = 0 nFreed = Xsqlite3MallocSize(tls, p) Xsqlite3_mutex_enter(tls, pcache1_g.Fmutex) - Xsqlite3StatusDown(tls, 2, nFreed) + Xsqlite3StatusDown(tls, SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed) Xsqlite3_mutex_leave(tls, pcache1_g.Fmutex) } @@ -28704,7 +28107,7 @@ func pcache1AllocPage(tls *libc.TLS, pCache uintptr, benignMalloc int32) uintptr } p = ((pPg) + uintptr((*PCache1)(unsafe.Pointer(pCache)).FszPage)) (*PgHdr1)(unsafe.Pointer(p)).Fpage.FpBuf = pPg - (*PgHdr1)(unsafe.Pointer(p)).Fpage.FpExtra = (p + uintptr(1)*56) + (*PgHdr1)(unsafe.Pointer(p)).Fpage.FpExtra = (p + 1*56) (*PgHdr1)(unsafe.Pointer(p)).FisBulkLocal = U16(0) (*PgHdr1)(unsafe.Pointer(p)).FisAnchor = U16(0) } @@ -28935,8 +28338,8 @@ func pcache1Init(tls *libc.TLS, NotUsed uintptr) int32 { /* sqlite3.c:50464:12: pcache1_g.FseparateCache = 0 if Xsqlite3Config.FbCoreMutex != 0 { - pcache1_g.Fgrp.Fmutex = Xsqlite3MutexAlloc(tls, 6) - pcache1_g.Fmutex = Xsqlite3MutexAlloc(tls, 7) + pcache1_g.Fgrp.Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_LRU) + pcache1_g.Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_PMEM) } if ((pcache1_g.FseparateCache != 0) && (Xsqlite3Config.FnPage != 0)) && @@ -28947,7 +28350,7 @@ func pcache1Init(tls *libc.TLS, NotUsed uintptr) int32 { /* sqlite3.c:50464:12: } pcache1_g.Fgrp.FmxPinned = uint32(10) pcache1_g.FisInit = 1 - return 0 + return SQLITE_OK } // Implementation of the sqlite3_pcache.xShutdown method. @@ -28971,7 +28374,7 @@ func pcache1Create(tls *libc.TLS, szPage int32, szExtra int32, bPurgeable int32) pCache = Xsqlite3MallocZero(tls, uint64(sz)) if pCache != 0 { if pcache1_g.FseparateCache != 0 { - pGroup = (pCache + uintptr(1)*88) + pGroup = (pCache + 1*88) (*PGroup)(unsafe.Pointer(pGroup)).FmxPinned = uint32(10) } else { pGroup = (uintptr(unsafe.Pointer(&pcache1_g)) /* &.grp */) @@ -28984,7 +28387,7 @@ func pcache1Create(tls *libc.TLS, szPage int32, szExtra int32, bPurgeable int32) (*PCache1)(unsafe.Pointer(pCache)).FpGroup = pGroup (*PCache1)(unsafe.Pointer(pCache)).FszPage = szPage (*PCache1)(unsafe.Pointer(pCache)).FszExtra = szExtra - (*PCache1)(unsafe.Pointer(pCache)).FszAlloc = (int32((uint64(szPage + szExtra)) + (((uint64(unsafe.Sizeof(PgHdr1{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + (*PCache1)(unsafe.Pointer(pCache)).FszAlloc = (int32((uint64(szPage + szExtra)) + (((uint64(unsafe.Sizeof(PgHdr1{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))))) (*PCache1)(unsafe.Pointer(pCache)).FbPurgeable = func() int32 { if bPurgeable != 0 { return 1 @@ -29327,40 +28730,27 @@ func Xsqlite3PCacheSetDefault(tls *libc.TLS) { /* sqlite3.c:50952:21: */ bp := tls.Alloc(8) defer tls.Free(8) - Xsqlite3_config(tls, 18, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultMethods1)))) + Xsqlite3_config(tls, SQLITE_CONFIG_PCACHE2, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultMethods1)))) } var defaultMethods1 = Sqlite3_pcache_methods2{ - FiVersion: 1, - FpArg:// iVersion - uintptr(0), - FxInit:// pArg - 0, - FxShutdown:// xInit - 0, - FxCreate:// xShutdown - 0, - FxCachesize:// xCreate - 0, - FxPagecount:// xCachesize - 0, - FxFetch:// xPagecount - 0, - FxUnpin:// xFetch - 0, - FxRekey:// xUnpin - 0, - FxTruncate:// xRekey - 0, - FxDestroy:// xTruncate - 0, - FxShrink:// xDestroy - 0, // xShrink + FiVersion: 1, // pArg + FxInit: 0, // xInit + FxShutdown: 0, // xShutdown + FxCreate: 0, // xCreate + FxCachesize: 0, // xCachesize + FxPagecount: 0, // xPagecount + FxFetch: 0, // xFetch + FxUnpin: 0, // xUnpin + FxRekey: 0, // xRekey + FxTruncate: 0, // xTruncate + FxDestroy: 0, // xDestroy + FxShrink: 0, // xShrink } /* sqlite3.c:50953:40 */ // Return the size of the header on each page of this PCACHE implementation. func Xsqlite3HeaderSizePcache1(tls *libc.TLS) int32 { /* sqlite3.c:50974:20: */ - return (int32(((uint64(unsafe.Sizeof(PgHdr1{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + return (int32(((uint64(unsafe.Sizeof(PgHdr1{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) } // Return the global mutex used by this PCACHE implementation. The @@ -29517,9 +28907,9 @@ func Xsqlite3RowSetInit(tls *libc.TLS, db uintptr) uintptr { /* sqlite3.c:51174: (*RowSet)(unsafe.Pointer(p)).FpEntry = uintptr(0) (*RowSet)(unsafe.Pointer(p)).FpLast = uintptr(0) (*RowSet)(unsafe.Pointer(p)).FpForest = uintptr(0) - (*RowSet)(unsafe.Pointer(p)).FpFresh = (uintptr((((uint64(unsafe.Sizeof(RowSet{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + p) - (*RowSet)(unsafe.Pointer(p)).FnFresh = (U16((uint64(N) - (((uint64(unsafe.Sizeof(RowSet{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) / uint64(unsafe.Sizeof(RowSetEntry{})))) - (*RowSet)(unsafe.Pointer(p)).FrsFlags = U16(0x01) + (*RowSet)(unsafe.Pointer(p)).FpFresh = (uintptr((((uint64(unsafe.Sizeof(RowSet{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) + p) + (*RowSet)(unsafe.Pointer(p)).FnFresh = (U16((uint64(N) - (((uint64(unsafe.Sizeof(RowSet{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) / uint64(unsafe.Sizeof(RowSetEntry{})))) + (*RowSet)(unsafe.Pointer(p)).FrsFlags = ROWSET_SORTED (*RowSet)(unsafe.Pointer(p)).FiBatch = 0 } return p @@ -29541,7 +28931,7 @@ func Xsqlite3RowSetClear(tls *libc.TLS, pArg uintptr) { /* sqlite3.c:51196:21: * (*RowSet)(unsafe.Pointer(p)).FpEntry = uintptr(0) (*RowSet)(unsafe.Pointer(p)).FpLast = uintptr(0) (*RowSet)(unsafe.Pointer(p)).FpForest = uintptr(0) - (*RowSet)(unsafe.Pointer(p)).FrsFlags = U16(0x01) + (*RowSet)(unsafe.Pointer(p)).FrsFlags = ROWSET_SORTED } // Deallocate all chunks from a RowSet. This frees all memory that @@ -29571,7 +28961,7 @@ func rowSetEntryAlloc(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:51229:27: (*RowSetChunk)(unsafe.Pointer(pNew)).FpNextChunk = (*RowSet)(unsafe.Pointer(p)).FpChunk (*RowSet)(unsafe.Pointer(p)).FpChunk = pNew (*RowSet)(unsafe.Pointer(p)).FpFresh = pNew + 8 /* &.aEntry */ - (*RowSet)(unsafe.Pointer(p)).FnFresh = (uint16((uint64(1024 - 8)) / uint64(unsafe.Sizeof(RowSetEntry{})))) + (*RowSet)(unsafe.Pointer(p)).FnFresh = (uint16((uint64(ROWSET_ALLOCATION_SIZE - 8)) / uint64(unsafe.Sizeof(RowSetEntry{})))) } (*RowSet)(unsafe.Pointer(p)).FnFresh-- return libc.PostIncUintptr(&(*RowSet)(unsafe.Pointer(p)).FpFresh, 24) @@ -29598,7 +28988,7 @@ func Xsqlite3RowSetInsert(tls *libc.TLS, p uintptr, rowid I64) { /* sqlite3.c:51 if rowid <= (*RowSetEntry)(unsafe.Pointer(pLast)).Fv { //OPTIMIZATION-IF-FALSE // Avoid unnecessary sorts by preserving the ROWSET_SORTED flags // where possible - *(*U16)(unsafe.Pointer(p + 50 /* &.rsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x01))) + *(*U16)(unsafe.Pointer(p + 50 /* &.rsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(ROWSET_SORTED))) } (*RowSetEntry)(unsafe.Pointer(pLast)).FpRight = pEntry } else { @@ -29665,7 +29055,7 @@ func rowSetEntrySort(tls *libc.TLS, pIn uintptr) uintptr { /* sqlite3.c:51320:27 *(*uintptr)(unsafe.Pointer(bp /* &aBucket[0] */ + uintptr(i)*8)) = pIn pIn = pNext } - pIn = *(*uintptr)(unsafe.Pointer(bp /* &aBucket[0] */ + uintptr(0)*8)) + pIn = *(*uintptr)(unsafe.Pointer(bp /* &aBucket[0] */)) for i = uint32(1); uint64(i) < (uint64(unsafe.Sizeof([40]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { if *(*uintptr)(unsafe.Pointer(bp /* &aBucket[0] */ + uintptr(i)*8)) == uintptr(0) { continue @@ -29782,11 +29172,11 @@ func Xsqlite3RowSetNext(tls *libc.TLS, p uintptr, pRowid uintptr) int32 { /* sql // Cannot be used with sqlite3RowSetText() // Merge the forest into a single sorted list on first call - if (int32((*RowSet)(unsafe.Pointer(p)).FrsFlags) & 0x02) == 0 { //OPTIMIZATION-IF-FALSE - if (int32((*RowSet)(unsafe.Pointer(p)).FrsFlags) & 0x01) == 0 { //OPTIMIZATION-IF-FALSE + if (int32((*RowSet)(unsafe.Pointer(p)).FrsFlags) & ROWSET_NEXT) == 0 { //OPTIMIZATION-IF-FALSE + if (int32((*RowSet)(unsafe.Pointer(p)).FrsFlags) & ROWSET_SORTED) == 0 { //OPTIMIZATION-IF-FALSE (*RowSet)(unsafe.Pointer(p)).FpEntry = rowSetEntrySort(tls, (*RowSet)(unsafe.Pointer(p)).FpEntry) } - *(*U16)(unsafe.Pointer(p + 50 /* &.rsFlags */)) |= U16((0x01 | 0x02)) + *(*U16)(unsafe.Pointer(p + 50 /* &.rsFlags */)) |= U16((ROWSET_SORTED | ROWSET_NEXT)) } // Return the next entry on the list @@ -29825,7 +29215,7 @@ func Xsqlite3RowSetTest(tls *libc.TLS, pRowSet uintptr, iBatch int32, iRowid Sql p = (*RowSet)(unsafe.Pointer(pRowSet)).FpEntry if p != 0 { var ppPrevTree uintptr = (pRowSet + 40 /* &.pForest */) - if (int32((*RowSet)(unsafe.Pointer(pRowSet)).FrsFlags) & 0x01) == 0 { //OPTIMIZATION-IF-FALSE + if (int32((*RowSet)(unsafe.Pointer(pRowSet)).FrsFlags) & ROWSET_SORTED) == 0 { //OPTIMIZATION-IF-FALSE // Only sort the current set of entries if they need it p = rowSetEntrySort(tls, p) } @@ -29854,7 +29244,7 @@ func Xsqlite3RowSetTest(tls *libc.TLS, pRowSet uintptr, iBatch int32, iRowid Sql } (*RowSet)(unsafe.Pointer(pRowSet)).FpEntry = uintptr(0) (*RowSet)(unsafe.Pointer(pRowSet)).FpLast = uintptr(0) - *(*U16)(unsafe.Pointer(pRowSet + 50 /* &.rsFlags */)) |= U16((0x01)) + *(*U16)(unsafe.Pointer(pRowSet + 50 /* &.rsFlags */)) |= U16((ROWSET_SORTED)) } (*RowSet)(unsafe.Pointer(pRowSet)).FiBatch = iBatch } @@ -30851,7 +30241,7 @@ func read32bits(tls *libc.TLS, fd uintptr, offset I64, pRes uintptr) int32 { /* // var ac [4]uint8 at bp, 4 var rc int32 = Xsqlite3OsRead(tls, fd, bp /* &ac[0] */, int32(unsafe.Sizeof([4]uint8{})), offset) - if rc == 0 { + if rc == SQLITE_OK { *(*U32)(unsafe.Pointer(pRes)) = Xsqlite3Get4byte(tls, bp /* &ac[0] */) } return rc @@ -30879,16 +30269,16 @@ func write32bits(tls *libc.TLS, fd uintptr, offset I64, val U32) int32 { /* sqli // called, do not modify it. See the comment above the #define of // UNKNOWN_LOCK for an explanation of this. func pagerUnlockDb(tls *libc.TLS, pPager uintptr, eLock int32) int32 { /* sqlite3.c:52837:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0) { if (*Pager)(unsafe.Pointer(pPager)).FnoLock != 0 { - rc = 0 + rc = SQLITE_OK } else { rc = Xsqlite3OsUnlock(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, eLock) } - if int32((*Pager)(unsafe.Pointer(pPager)).FeLock) != (4 + 1) { + if int32((*Pager)(unsafe.Pointer(pPager)).FeLock) != (EXCLUSIVE_LOCK + 1) { (*Pager)(unsafe.Pointer(pPager)).FeLock = U8(eLock) } @@ -30906,15 +30296,15 @@ func pagerUnlockDb(tls *libc.TLS, pPager uintptr, eLock int32) int32 { /* sqlite // See the comment above the #define of UNKNOWN_LOCK for an explanation // of this. func pagerLockDb(tls *libc.TLS, pPager uintptr, eLock int32) int32 { /* sqlite3.c:52865:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK - if (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) < eLock) || (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) == (4 + 1)) { + if (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) < eLock) || (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) == (EXCLUSIVE_LOCK + 1)) { if (*Pager)(unsafe.Pointer(pPager)).FnoLock != 0 { - rc = 0 + rc = SQLITE_OK } else { rc = Xsqlite3OsLock(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, eLock) } - if (rc == 0) && ((int32((*Pager)(unsafe.Pointer(pPager)).FeLock) != (4 + 1)) || (eLock == 4)) { + if (rc == SQLITE_OK) && ((int32((*Pager)(unsafe.Pointer(pPager)).FeLock) != (EXCLUSIVE_LOCK + 1)) || (eLock == EXCLUSIVE_LOCK)) { (*Pager)(unsafe.Pointer(pPager)).FeLock = U8(eLock) } @@ -30987,18 +30377,18 @@ func readSuperJournal(tls *libc.TLS, pJrnl uintptr, zSuper uintptr, nSuper U32) var u U32 // Unsigned loop counter // var aMagic [8]uint8 at bp+16, 8 // A buffer to hold the magic header - *(*int8)(unsafe.Pointer(zSuper + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(zSuper)) = int8(0) - if (((((((((0 != (libc.AssignInt32(&rc, Xsqlite3OsFileSize(tls, pJrnl, bp /* &szJ */)))) || + if (((((((((SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3OsFileSize(tls, pJrnl, bp /* &szJ */)))) || (*(*I64)(unsafe.Pointer(bp /* szJ */)) < int64(16))) || - (0 != (libc.AssignInt32(&rc, read32bits(tls, pJrnl, (*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(16)), bp+8 /* &len */))))) || + (SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, pJrnl, (*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(16)), bp+8 /* &len */))))) || (*(*U32)(unsafe.Pointer(bp + 8 /* len */)) >= nSuper)) || (I64(*(*U32)(unsafe.Pointer(bp + 8 /* len */))) > (*(*I64)(unsafe.Pointer(bp /* szJ */)) - int64(16)))) || (*(*U32)(unsafe.Pointer(bp + 8 /* len */)) == U32(0))) || - (0 != (libc.AssignInt32(&rc, read32bits(tls, pJrnl, (*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(12)), bp+12 /* &cksum */))))) || - (0 != (libc.AssignInt32(&rc, Xsqlite3OsRead(tls, pJrnl, bp+16 /* &aMagic[0] */, 8, (*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(8))))))) || + (SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, pJrnl, (*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(12)), bp+12 /* &cksum */))))) || + (SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3OsRead(tls, pJrnl, bp+16 /* &aMagic[0] */, 8, (*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(8))))))) || (libc.Xmemcmp(tls, bp+16 /* &aMagic[0] */, uintptr(unsafe.Pointer(&aJournalMagic)), uint64(8)) != 0)) || - (0 != (libc.AssignInt32(&rc, Xsqlite3OsRead(tls, pJrnl, zSuper, int32(*(*U32)(unsafe.Pointer(bp + 8 /* len */))), ((*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(16))-I64(*(*U32)(unsafe.Pointer(bp + 8 /* len */)))))))) { + (SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3OsRead(tls, pJrnl, zSuper, int32(*(*U32)(unsafe.Pointer(bp + 8 /* len */))), ((*(*I64)(unsafe.Pointer(bp /* szJ */))-int64(16))-I64(*(*U32)(unsafe.Pointer(bp + 8 /* len */)))))))) { return rc } @@ -31016,7 +30406,7 @@ func readSuperJournal(tls *libc.TLS, pJrnl uintptr, zSuper uintptr, nSuper U32) *(*int8)(unsafe.Pointer(zSuper + uintptr(*(*U32)(unsafe.Pointer(bp + 8 /* len */))))) = int8(0) *(*int8)(unsafe.Pointer(zSuper + uintptr((*(*U32)(unsafe.Pointer(bp + 8 /* len */)) + U32(1))))) = int8(0) - return 0 + return SQLITE_OK } // Return the offset of the sector boundary at or immediately @@ -31065,7 +30455,7 @@ func zeroJournalHdr(tls *libc.TLS, pPager uintptr, doTruncate int32) int32 { /* bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code if (*Pager)(unsafe.Pointer(pPager)).FjournalOff != 0 { var iLimit I64 = (*Pager)(unsafe.Pointer(pPager)).FjournalSizeLimit // Local cache of jsl @@ -31075,8 +30465,8 @@ func zeroJournalHdr(tls *libc.TLS, pPager uintptr, doTruncate int32) int32 { /* } else { rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, uintptr(unsafe.Pointer(&zeroHdr)), int32(unsafe.Sizeof(zeroHdr)), int64(0)) } - if (rc == 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { - rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (0x00010 | int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags))) + if (rc == SQLITE_OK) && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { + rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (SQLITE_SYNC_DATAONLY | int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags))) } // At this point the transaction is committed but the write lock @@ -31084,11 +30474,11 @@ func zeroJournalHdr(tls *libc.TLS, pPager uintptr, doTruncate int32) int32 { /* // the persistent journal and the journal file currently consumes more // space than that limit allows for, truncate it now. There is no need // to sync the file following this operation. - if (rc == 0) && (iLimit > int64(0)) { + if (rc == SQLITE_OK) && (iLimit > int64(0)) { // var sz I64 at bp, 8 rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp /* &sz */) - if (rc == 0) && (*(*I64)(unsafe.Pointer(bp /* sz */)) > iLimit) { + if (rc == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp /* sz */)) > iLimit) { rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iLimit) } } @@ -31096,7 +30486,7 @@ func zeroJournalHdr(tls *libc.TLS, pPager uintptr, doTruncate int32) int32 { /* return rc } -var zeroHdr = [28]int8{int8(0)} /* sqlite3.c:53103:25 */ +var zeroHdr = [28]int8{0: int8(0)} /* sqlite3.c:53103:25 */ // The journal file must be open when this routine is called. A journal // header (JOURNAL_HDR_SZ bytes) is written into the journal file at the @@ -31112,7 +30502,7 @@ var zeroHdr = [28]int8{int8(0)} /* sqlite3.c:53103:25 */ // // Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space. func writeJournalHdr(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:53142:12: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var zHeader uintptr = (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace // Temporary space used to build header var nHeader U32 = U32((*Pager)(unsafe.Pointer(pPager)).FpageSize) // Size of buffer pointed to by zHeader var nWrite U32 // Bytes of header sector written @@ -31154,30 +30544,30 @@ func writeJournalHdr(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:53142:1 // * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees // that garbage data is never appended to the journal file. - if (((*Pager)(unsafe.Pointer(pPager)).FnoSync != 0) || (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 4)) || - ((Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd) & 0x00000200) != 0) { + if (((*Pager)(unsafe.Pointer(pPager)).FnoSync != 0) || (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_MEMORY)) || + ((Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd) & SQLITE_IOCAP_SAFE_APPEND) != 0) { libc.Xmemcpy(tls, zHeader, uintptr(unsafe.Pointer(&aJournalMagic)), uint64(unsafe.Sizeof(aJournalMagic))) - Xsqlite3Put4byte(tls, (zHeader + uintptr(uint64(unsafe.Sizeof(aJournalMagic)))), 0xffffffff) + Xsqlite3Put4byte(tls, (zHeader + 8), 0xffffffff) } else { libc.Xmemset(tls, zHeader, 0, (uint64(unsafe.Sizeof(aJournalMagic)) + uint64(4))) } // The random check-hash initializer Xsqlite3_randomness(tls, int32(unsafe.Sizeof(U32(0))), (pPager + 52 /* &.cksumInit */)) - Xsqlite3Put4byte(tls, (zHeader + uintptr((uint64(unsafe.Sizeof(aJournalMagic)) + uint64(4)))), (*Pager)(unsafe.Pointer(pPager)).FcksumInit) + Xsqlite3Put4byte(tls, (zHeader + 12), (*Pager)(unsafe.Pointer(pPager)).FcksumInit) // The initial database size - Xsqlite3Put4byte(tls, (zHeader + uintptr((uint64(unsafe.Sizeof(aJournalMagic)) + uint64(8)))), (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize) + Xsqlite3Put4byte(tls, (zHeader + 16), (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize) // The assumed sector size for this process - Xsqlite3Put4byte(tls, (zHeader + uintptr((uint64(unsafe.Sizeof(aJournalMagic)) + uint64(12)))), (*Pager)(unsafe.Pointer(pPager)).FsectorSize) + Xsqlite3Put4byte(tls, (zHeader + 20), (*Pager)(unsafe.Pointer(pPager)).FsectorSize) // The page size - Xsqlite3Put4byte(tls, (zHeader + uintptr((uint64(unsafe.Sizeof(aJournalMagic)) + uint64(16)))), uint32((*Pager)(unsafe.Pointer(pPager)).FpageSize)) + Xsqlite3Put4byte(tls, (zHeader + 24), uint32((*Pager)(unsafe.Pointer(pPager)).FpageSize)) // Initializing the tail of the buffer is not necessary. Everything // works find if the following memset() is omitted. But initializing // the memory prevents valgrind from complaining, so we are willing to // take the performance hit. - libc.Xmemset(tls, (zHeader + uintptr((uint64(unsafe.Sizeof(aJournalMagic)) + uint64(20)))), 0, + libc.Xmemset(tls, (zHeader + 28), 0, (uint64(nHeader) - (uint64(unsafe.Sizeof(aJournalMagic)) + uint64(20)))) // In theory, it is only necessary to write the 28 bytes that the @@ -31196,7 +30586,7 @@ func writeJournalHdr(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:53142:1 // database page size. Since the zHeader buffer is only Pager.pageSize // bytes in size, more than one call to sqlite3OsWrite() may be required // to populate the entire journal header sector. - for nWrite = U32(0); (rc == 0) && (nWrite < ((*Pager)(unsafe.Pointer(pPager)).FsectorSize)); nWrite = nWrite + (nHeader) { + for nWrite = U32(0); (rc == SQLITE_OK) && (nWrite < ((*Pager)(unsafe.Pointer(pPager)).FsectorSize)); nWrite = nWrite + (nHeader) { rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, zHeader, int32(nHeader), (*Pager)(unsafe.Pointer(pPager)).FjournalOff) @@ -31237,7 +30627,7 @@ func readJournalHdr(tls *libc.TLS, pPager uintptr, isHot int32, journalSize I64, // point, return SQLITE_DONE. (*Pager)(unsafe.Pointer(pPager)).FjournalOff = journalHdrOffset(tls, pPager) if ((*Pager)(unsafe.Pointer(pPager)).FjournalOff + (I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize))) > journalSize { - return 101 + return SQLITE_DONE } iHdrOff = (*Pager)(unsafe.Pointer(pPager)).FjournalOff @@ -31251,16 +30641,16 @@ func readJournalHdr(tls *libc.TLS, pPager uintptr, isHot int32, journalSize I64, return rc } if libc.Xmemcmp(tls, bp /* &aMagic[0] */, uintptr(unsafe.Pointer(&aJournalMagic)), uint64(unsafe.Sizeof([8]uint8{}))) != 0 { - return 101 + return SQLITE_DONE } } // Read the first three 32-bit fields of the journal header: The nRec // field, the checksum-initializer and the database size at the start // of the transaction. Return an error code if anything goes wrong. - if ((0 != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(8)), pNRec)))) || - (0 != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(12)), (pPager+52 /* &.cksumInit */)))))) || - (0 != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(16)), pDbSize)))) { + if ((SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(8)), pNRec)))) || + (SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(12)), (pPager+52 /* &.cksumInit */)))))) || + (SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(16)), pDbSize)))) { return rc } @@ -31271,8 +30661,8 @@ func readJournalHdr(tls *libc.TLS, pPager uintptr, isHot int32, journalSize I64, // Sector-size field of journal header // Read the page-size and sector-size journal header fields. - if (0 != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(20)), bp+8 /* &iSectorSize */)))) || - (0 != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(24)), bp+12 /* &iPageSize */)))) { + if (SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(20)), bp+8 /* &iSectorSize */)))) || + (SQLITE_OK != (libc.AssignInt32(&rc, read32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (iHdrOff+int64(24)), bp+12 /* &iPageSize */)))) { return rc } @@ -31288,13 +30678,13 @@ func readJournalHdr(tls *libc.TLS, pPager uintptr, isHot int32, journalSize I64, // of two greater than or equal to 512 or 32, and not greater than their // respective compile time maximum limits. if (((((*(*U32)(unsafe.Pointer(bp + 12 /* iPageSize */)) < U32(512)) || (*(*U32)(unsafe.Pointer(bp + 8 /* iSectorSize */)) < U32(32))) || - (*(*U32)(unsafe.Pointer(bp + 12 /* iPageSize */)) > U32(65536))) || (*(*U32)(unsafe.Pointer(bp + 8 /* iSectorSize */)) > U32(0x10000))) || + (*(*U32)(unsafe.Pointer(bp + 12 /* iPageSize */)) > SQLITE_MAX_PAGE_SIZE)) || (*(*U32)(unsafe.Pointer(bp + 8 /* iSectorSize */)) > MAX_SECTOR_SIZE)) || (((*(*U32)(unsafe.Pointer(bp + 12 /* iPageSize */)) - U32(1)) & *(*U32)(unsafe.Pointer(bp + 12 /* iPageSize */))) != U32(0))) || (((*(*U32)(unsafe.Pointer(bp + 8 /* iSectorSize */)) - U32(1)) & *(*U32)(unsafe.Pointer(bp + 8 /* iSectorSize */))) != U32(0)) { // If the either the page-size or sector-size in the journal-header is // invalid, then the process that wrote the journal-header must have // crashed before the header was synced. In this case stop reading // the journal file here. - return 101 + return SQLITE_DONE } // Update the page-size to match the value read from the journal. @@ -31343,9 +30733,9 @@ func writeSuperJournal(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 { /* var cksum U32 = U32(0) // Checksum of string zSuper if (!(zSuper != 0) || - (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 4)) || + (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_MEMORY)) || !((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) { - return 0 + return SQLITE_OK } (*Pager)(unsafe.Pointer(pPager)).FsetSuper = U8(1) @@ -31383,7 +30773,7 @@ func writeSuperJournal(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 { /* // // Easiest thing to do in this scenario is to truncate the journal // file to the required size. - if (0 == (libc.AssignInt32(&rc, Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp /* &jrnlSize */)))) && + if (SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp /* &jrnlSize */)))) && (*(*I64)(unsafe.Pointer(bp /* jrnlSize */)) > (*Pager)(unsafe.Pointer(pPager)).FjournalOff) { rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (*Pager)(unsafe.Pointer(pPager)).FjournalOff) } @@ -31423,8 +30813,8 @@ func releaseAllSavepoints(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53471:13 // bitvecs of all open savepoints. Return SQLITE_OK if successful // or SQLITE_NOMEM if a malloc failure occurs. func addToSavepointBitvecs(tls *libc.TLS, pPager uintptr, pgno Pgno) int32 { /* sqlite3.c:53490:12: */ - var ii int32 // Loop counter - var rc int32 = 0 // Result code + var ii int32 // Loop counter + var rc int32 = SQLITE_OK // Result code for ii = 0; ii < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint; ii++ { var p uintptr = ((*Pager)(unsafe.Pointer(pPager)).FaSavepoint + uintptr(ii)*48) @@ -31460,7 +30850,7 @@ func pager_unlock(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53522:13: */ if (*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0) { Xsqlite3WalEndReadTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal) - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(0) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_OPEN } else if !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) { var rc int32 // Error code returned by pagerUnlockDb() var iDc int32 @@ -31475,7 +30865,7 @@ func pager_unlock(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53522:13: */ // another connection with journal_mode=delete might delete the file // out from under us. - if (0 == (iDc & 0x00000800)) || + if (0 == (iDc & SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN)) || (1 != (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) & 5)) { Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) } @@ -31484,16 +30874,16 @@ func pager_unlock(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53522:13: */ // file fails, set the current lock to UNKNOWN_LOCK. See the comment // above the #define for UNKNOWN_LOCK for an explanation of why this // is necessary. - rc = pagerUnlockDb(tls, pPager, 0) - if (rc != 0) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 6) { - (*Pager)(unsafe.Pointer(pPager)).FeLock = (U8(4 + 1)) + rc = pagerUnlockDb(tls, pPager, NO_LOCK) + if (rc != SQLITE_OK) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_ERROR) { + (*Pager)(unsafe.Pointer(pPager)).FeLock = (U8(EXCLUSIVE_LOCK + 1)) } // The pager state may be changed from PAGER_ERROR to PAGER_OPEN here // without clearing the error code. This is intentional - the error // code is cleared and the cache reset in the block below. - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(0) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_OPEN } // If Pager.errCode is set, the contents of the pager cache cannot be @@ -31505,19 +30895,19 @@ func pager_unlock(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53522:13: */ if int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) == 0 { pager_reset(tls, pPager) (*Pager)(unsafe.Pointer(pPager)).FchangeCountDone = U8(0) - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(0) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_OPEN } else { (*Pager)(unsafe.Pointer(pPager)).FeState = func() uint8 { if (*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0) { - return uint8(0) + return PAGER_OPEN } - return uint8(1) + return PAGER_READER }() } if (*Pager)(unsafe.Pointer(pPager)).FbUseFetch != 0 { Xsqlite3OsUnfetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, int64(0), uintptr(0)) } - (*Pager)(unsafe.Pointer(pPager)).FerrCode = 0 + (*Pager)(unsafe.Pointer(pPager)).FerrCode = SQLITE_OK setGetterMethod(tls, pPager) } @@ -31546,9 +30936,9 @@ func pager_unlock(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53522:13: */ func pager_error(tls *libc.TLS, pPager uintptr, rc int32) int32 { /* sqlite3.c:53619:12: */ var rc2 int32 = (rc & 0xff) - if (rc2 == 13) || (rc2 == 10) { + if (rc2 == SQLITE_FULL) || (rc2 == SQLITE_IOERR) { (*Pager)(unsafe.Pointer(pPager)).FerrCode = rc - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(6) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_ERROR setGetterMethod(tls, pPager) } return rc @@ -31633,8 +31023,8 @@ func pagerFlushOnCommit(tls *libc.TLS, pPager uintptr, bCommit int32) int32 { /* // to the first error encountered (the journal finalization one) is // returned. func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommit int32) int32 { /* sqlite3.c:53713:12: */ - var rc int32 = 0 // Error code from journal finalization operation - var rc2 int32 = 0 // Error code from db file unlock operation + var rc int32 = SQLITE_OK // Error code from journal finalization operation + var rc2 int32 = SQLITE_OK // Error code from db file unlock operation // Do nothing if the pager does not have an open write transaction // or at least a RESERVED lock. This function may be called when there @@ -31649,8 +31039,8 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi // read-transaction, this function is called with eState==PAGER_READER // and eLock==EXCLUSIVE_LOCK when the read-transaction is closed. - if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) < 2) && (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) < 2) { - return 0 + if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) < PAGER_WRITER_LOCKED) && (int32((*Pager)(unsafe.Pointer(pPager)).FeLock) < RESERVED_LOCK) { + return SQLITE_OK } releaseAllSavepoints(tls, pPager) @@ -31661,12 +31051,12 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi if Xsqlite3JournalIsInMemory(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) != 0 { // assert( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ); Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) - } else if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 3 { + } else if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_TRUNCATE { if (*Pager)(unsafe.Pointer(pPager)).FjournalOff == int64(0) { - rc = 0 + rc = SQLITE_OK } else { rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, int64(0)) - if (rc == 0) && ((*Pager)(unsafe.Pointer(pPager)).FfullSync != 0) { + if (rc == SQLITE_OK) && ((*Pager)(unsafe.Pointer(pPager)).FfullSync != 0) { // Make sure the new file size is written into the inode right away. // Otherwise the journal might resurrect following a power loss and // cause the last transaction to roll back. See @@ -31675,8 +31065,8 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi } } (*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0) - } else if (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 1) || - (((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) && (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != 5)) { + } else if (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_PERSIST) || + (((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) && (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_WAL)) { rc = zeroJournalHdr(tls, pPager, (libc.Bool32((hasSuper != 0) || ((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0)))) (*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0) } else { @@ -31696,7 +31086,7 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi Xsqlite3BitvecDestroy(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal) (*Pager)(unsafe.Pointer(pPager)).FpInJournal = uintptr(0) (*Pager)(unsafe.Pointer(pPager)).FnRec = 0 - if rc == 0 { + if rc == SQLITE_OK { if ((*Pager)(unsafe.Pointer(pPager)).FmemDb != 0) || (pagerFlushOnCommit(tls, pPager, bCommit) != 0) { Xsqlite3PcacheCleanAll(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) } else { @@ -31711,7 +31101,7 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi // lock held on the database file. rc2 = Xsqlite3WalEndWriteTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal) - } else if ((rc == 0) && (bCommit != 0)) && ((*Pager)(unsafe.Pointer(pPager)).FdbFileSize > (*Pager)(unsafe.Pointer(pPager)).FdbSize) { + } else if ((rc == SQLITE_OK) && (bCommit != 0)) && ((*Pager)(unsafe.Pointer(pPager)).FdbFileSize > (*Pager)(unsafe.Pointer(pPager)).FdbSize) { // This branch is taken when committing a transaction in rollback-journal // mode if the database file on disk is larger than the database image. // At this point the journal has been finalized and the transaction @@ -31722,22 +31112,22 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi rc = pager_truncate(tls, pPager, (*Pager)(unsafe.Pointer(pPager)).FdbSize) } - if (rc == 0) && (bCommit != 0) { - rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, 22, uintptr(0)) - if rc == 12 { - rc = 0 + if (rc == SQLITE_OK) && (bCommit != 0) { + rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_COMMIT_PHASETWO, uintptr(0)) + if rc == SQLITE_NOTFOUND { + rc = SQLITE_OK } } if !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) && (!((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0)) || (Xsqlite3WalExclusiveMode(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, 0) != 0)) { - rc2 = pagerUnlockDb(tls, pPager, 1) + rc2 = pagerUnlockDb(tls, pPager, SHARED_LOCK) } - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(1) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_READER (*Pager)(unsafe.Pointer(pPager)).FsetSuper = U8(0) return func() int32 { - if rc == 0 { + if rc == SQLITE_OK { return rc2 } return rc @@ -31760,9 +31150,9 @@ func pager_end_transaction(tls *libc.TLS, pPager uintptr, hasSuper int32, bCommi // the pager to enter the ERROR state. Which will be cleared by the // call to pager_unlock(), as described above. func pagerUnlockAndRollback(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:53860:13: */ - if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) != 6) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) != 0) { + if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) != PAGER_ERROR) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) != PAGER_OPEN) { - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= 2 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_LOCKED { Xsqlite3BeginBenignMalloc(tls) Xsqlite3PagerRollback(tls, pPager) Xsqlite3EndBenignMalloc(tls) @@ -31873,11 +31263,11 @@ func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDo jfd = (*Pager)(unsafe.Pointer(pPager)).Fsjfd } rc = read32bits(tls, jfd, *(*I64)(unsafe.Pointer(pOffset)), bp /* &pgno */) - if rc != 0 { + if rc != SQLITE_OK { return rc } rc = Xsqlite3OsRead(tls, jfd, aData, (*Pager)(unsafe.Pointer(pPager)).FpageSize, ((*(*I64)(unsafe.Pointer(pOffset))) + int64(4))) - if rc != 0 { + if rc != SQLITE_OK { return rc } *(*I64)(unsafe.Pointer(pOffset)) += (I64(((*Pager)(unsafe.Pointer(pPager)).FpageSize + 4) + (isMainJrnl * 4))) @@ -31888,10 +31278,10 @@ func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDo // detect this invalid data (with high probability) and ignore it. if (*(*Pgno)(unsafe.Pointer(bp /* pgno */)) == Pgno(0)) || (*(*Pgno)(unsafe.Pointer(bp /* pgno */)) == (Pgno((Xsqlite3PendingByte / ((*Pager)(unsafe.Pointer(pPager)).FpageSize)) + 1))) { - return 101 + return SQLITE_DONE } if (*(*Pgno)(unsafe.Pointer(bp /* pgno */)) > (*Pager)(unsafe.Pointer(pPager)).FdbSize) || (Xsqlite3BitvecTest(tls, pDone, *(*Pgno)(unsafe.Pointer(bp /* pgno */))) != 0) { - return 0 + return SQLITE_OK } if isMainJrnl != 0 { rc = read32bits(tls, jfd, ((*(*I64)(unsafe.Pointer(pOffset))) - int64(4)), bp+4 /* &cksum */) @@ -31899,19 +31289,19 @@ func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDo return rc } if !(isSavepnt != 0) && (pager_cksum(tls, pPager, aData) != *(*U32)(unsafe.Pointer(bp + 4 /* cksum */))) { - return 101 + return SQLITE_DONE } } // If this page has already been played back before during the current // rollback, then don't bother to play it back again. - if (pDone != 0) && ((libc.AssignInt32(&rc, Xsqlite3BitvecSet(tls, pDone, *(*Pgno)(unsafe.Pointer(bp /* pgno */))))) != 0) { + if (pDone != 0) && ((libc.AssignInt32(&rc, Xsqlite3BitvecSet(tls, pDone, *(*Pgno)(unsafe.Pointer(bp /* pgno */))))) != SQLITE_OK) { return rc } // When playing back page 1, restore the nReserve setting - if (*(*Pgno)(unsafe.Pointer(bp /* pgno */)) == Pgno(1)) && (int32((*Pager)(unsafe.Pointer(pPager)).FnReserve) != int32(*(*U8)(unsafe.Pointer((aData) + uintptr(20))))) { - (*Pager)(unsafe.Pointer(pPager)).FnReserve = I16(*(*U8)(unsafe.Pointer((aData) + uintptr(20)))) + if (*(*Pgno)(unsafe.Pointer(bp /* pgno */)) == Pgno(1)) && (int32((*Pager)(unsafe.Pointer(pPager)).FnReserve) != int32(*(*U8)(unsafe.Pointer((aData) + 20)))) { + (*Pager)(unsafe.Pointer(pPager)).FnReserve = I16(*(*U8)(unsafe.Pointer((aData) + 20))) } // If the pager is in CACHEMOD state, then there must be a copy of this @@ -31957,10 +31347,10 @@ func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDo if isMainJrnl != 0 { isSynced = (libc.Bool32(((*Pager)(unsafe.Pointer(pPager)).FnoSync != 0) || (*(*I64)(unsafe.Pointer(pOffset)) <= (*Pager)(unsafe.Pointer(pPager)).FjournalHdr))) } else { - isSynced = (libc.Bool32((*(*uintptr)(unsafe.Pointer(bp + 8 /* pPg */)) == uintptr(0)) || (0 == (int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pPg */)))).Fflags) & 0x008)))) + isSynced = (libc.Bool32((*(*uintptr)(unsafe.Pointer(bp + 8 /* pPg */)) == uintptr(0)) || (0 == (int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pPg */)))).Fflags) & PGHDR_NEED_SYNC)))) } if (((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0)) && - ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= 4) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 0))) && + ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_DBMOD) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN))) && (isSynced != 0) { var ofst I64 = ((I64(*(*Pgno)(unsafe.Pointer(bp /* pgno */)) - Pgno(1))) * I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)) @@ -31995,11 +31385,11 @@ func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDo // and if the pager requires a journal-sync, then mark the page as // requiring a journal-sync before it is written. - *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) |= U8((0x02)) + *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) |= U8((SPILLFLAG_ROLLBACK)) rc = Xsqlite3PagerGet(tls, pPager, *(*Pgno)(unsafe.Pointer(bp /* pgno */)), bp+8 /* &pPg */, 1) - *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) &= libc.Uint8FromInt32((^libc.Int32(0x02))) - if rc != 0 { + *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) &= libc.Uint8FromInt32((libc.CplInt32(SPILLFLAG_ROLLBACK))) + if rc != SQLITE_OK { return rc } Xsqlite3PcacheMakeDirty(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPg */))) @@ -32022,7 +31412,7 @@ func pager_playback_one_page(tls *libc.TLS, pPager uintptr, pOffset uintptr, pDo // If this was page 1, then restore the value of Pager.dbFileVers. // Do this before any decoding. if *(*Pgno)(unsafe.Pointer(bp /* pgno */)) == Pgno(1) { - libc.Xmemcpy(tls, (pPager + 136 /* &.dbFileVers */), ((pData) + uintptr(24)), uint64(unsafe.Sizeof([16]int8{}))) + libc.Xmemcpy(tls, (pPager + 136 /* &.dbFileVers */), ((pData) + 24), uint64(unsafe.Sizeof([16]int8{}))) } Xsqlite3PcacheRelease(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPg */))) } @@ -32103,16 +31493,16 @@ func pager_delsuper(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 { /* sq if !(!(pSuper != 0)) { goto __1 } - rc = 7 + rc = SQLITE_NOMEM pJournal = uintptr(0) goto __2 __1: - flags = (0x00000001 | 0x00004000) + flags = (SQLITE_OPEN_READONLY | SQLITE_OPEN_SUPER_JOURNAL) rc = Xsqlite3OsOpen(tls, pVfs, zSuper, pSuper, flags, uintptr(0)) pJournal = ((pSuper) + uintptr((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)) __2: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __3 } goto delsuper_out @@ -32124,7 +31514,7 @@ __3: // sufficient space (in zSuperPtr) to hold the names of super-journal // files extracted from regular rollback-journals. rc = Xsqlite3OsFileSize(tls, pSuper, bp /* &nSuperJournal */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } goto delsuper_out @@ -32135,13 +31525,13 @@ __4: if !(!(zSuperJournal != 0)) { goto __5 } - rc = 7 + rc = SQLITE_NOMEM goto delsuper_out __5: ; zSuperPtr = (zSuperJournal + uintptr((*(*I64)(unsafe.Pointer(bp /* nSuperJournal */)) + int64(2)))) rc = Xsqlite3OsRead(tls, pSuper, zSuperJournal, int32(*(*I64)(unsafe.Pointer(bp /* nSuperJournal */))), int64(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __6 } goto delsuper_out @@ -32155,8 +31545,8 @@ __7: if !((I64((int64(zJournal) - int64(zSuperJournal)) / 1)) < *(*I64)(unsafe.Pointer(bp /* nSuperJournal */))) { goto __8 } - rc = Xsqlite3OsAccess(tls, pVfs, zJournal, 0, bp+8 /* &exists */) - if !(rc != 0) { + rc = Xsqlite3OsAccess(tls, pVfs, zJournal, SQLITE_ACCESS_EXISTS, bp+8 /* &exists */) + if !(rc != SQLITE_OK) { goto __9 } goto delsuper_out @@ -32165,9 +31555,9 @@ __9: if !(*(*int32)(unsafe.Pointer(bp + 8 /* exists */)) != 0) { goto __10 } - flags1 = (0x00000001 | 0x00004000) + flags1 = (SQLITE_OPEN_READONLY | SQLITE_OPEN_SUPER_JOURNAL) rc = Xsqlite3OsOpen(tls, pVfs, zJournal, pJournal, flags1, uintptr(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __11 } goto delsuper_out @@ -32176,14 +31566,14 @@ __11: rc = readSuperJournal(tls, pJournal, zSuperPtr, uint32(nSuperPtr)) Xsqlite3OsClose(tls, pJournal) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } goto delsuper_out __12: ; - c = (libc.Bool32((int32(*(*int8)(unsafe.Pointer(zSuperPtr + uintptr(0)))) != 0) && (libc.Xstrcmp(tls, zSuperPtr, zSuper) == 0))) + c = (libc.Bool32((int32(*(*int8)(unsafe.Pointer(zSuperPtr))) != 0) && (libc.Xstrcmp(tls, zSuperPtr, zSuper) == 0))) if !(c != 0) { goto __13 } @@ -32236,10 +31626,10 @@ func pager_truncate(tls *libc.TLS, pPager uintptr, nPage Pgno) int32 { /* sqlite bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK if ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0)) && - ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= 4) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 0)) { + ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_DBMOD) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN)) { // var currentSize I64 at bp, 8 var newSize I64 @@ -32248,7 +31638,7 @@ func pager_truncate(tls *libc.TLS, pPager uintptr, nPage Pgno) int32 { /* sqlite // TODO: Is it safe to use Pager.dbFileSize here? rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp /* ¤tSize */) newSize = (I64(szPage) * I64(nPage)) - if (rc == 0) && (*(*I64)(unsafe.Pointer(bp /* currentSize */)) != newSize) { + if (rc == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp /* currentSize */)) != newSize) { if *(*I64)(unsafe.Pointer(bp /* currentSize */)) > newSize { rc = Xsqlite3OsTruncate(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, newSize) } else if (*(*I64)(unsafe.Pointer(bp /* currentSize */)) + I64(szPage)) <= newSize { @@ -32257,7 +31647,7 @@ func pager_truncate(tls *libc.TLS, pPager uintptr, nPage Pgno) int32 { /* sqlite rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, pTmp, szPage, (newSize - I64(szPage))) } - if rc == 0 { + if rc == SQLITE_OK { (*Pager)(unsafe.Pointer(pPager)).FdbFileSize = nPage } } @@ -32271,9 +31661,9 @@ func Xsqlite3SectorSize(tls *libc.TLS, pFile uintptr) int32 { /* sqlite3.c:54339 var iRet int32 = Xsqlite3OsSectorSize(tls, pFile) if iRet < 32 { iRet = 512 - } else if iRet > 0x10000 { + } else if iRet > MAX_SECTOR_SIZE { - iRet = 0x10000 + iRet = MAX_SECTOR_SIZE } return iRet } @@ -32302,7 +31692,7 @@ func Xsqlite3SectorSize(tls *libc.TLS, pFile uintptr) int32 { /* sqlite3.c:54339 func setSectorSize(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:54373:13: */ if ((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0) || - ((Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd) & 0x00001000) != 0) { + ((Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd) & SQLITE_IOCAP_POWERSAFE_OVERWRITE) != 0) { // Sector size doesn't matter for temporary files. Also, the file // may not have been opened yet, in which case the OsSectorSize() // call will segfault. @@ -32397,7 +31787,7 @@ func pager_playback(tls *libc.TLS, pPager uintptr, isHot int32) int32 { /* sqlit // the journal is empty. rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp+16 /* &szJ */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __1 } goto end_playback @@ -32416,14 +31806,14 @@ __1: // for pageSize. zSuper = (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace rc = readSuperJournal(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, zSuper, (uint32((*Sqlite3_vfs)(unsafe.Pointer((*Pager)(unsafe.Pointer(pPager)).FpVfs)).FmxPathname + 1))) - if !((rc == 0) && (*(*int8)(unsafe.Pointer(zSuper + uintptr(0))) != 0)) { + if !((rc == SQLITE_OK) && (*(*int8)(unsafe.Pointer(zSuper)) != 0)) { goto __2 } - rc = Xsqlite3OsAccess(tls, pVfs, zSuper, 0, bp+24 /* &res */) + rc = Xsqlite3OsAccess(tls, pVfs, zSuper, SQLITE_ACCESS_EXISTS, bp+24 /* &res */) __2: ; zSuper = uintptr(0) - if !((rc != 0) || !(*(*int32)(unsafe.Pointer(bp + 24 /* res */)) != 0)) { + if !((rc != SQLITE_OK) || !(*(*int32)(unsafe.Pointer(bp + 24 /* res */)) != 0)) { goto __3 } goto end_playback @@ -32444,13 +31834,13 @@ __4: // it is corrupted, then a process must have failed while writing it. // This indicates nothing more needs to be rolled back. rc = readJournalHdr(tls, pPager, isHot, *(*I64)(unsafe.Pointer(bp + 16 /* szJ */)), bp+28 /* &nRec */, bp+32 /* &mxPg */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __6 } - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __7 } - rc = 0 + rc = SQLITE_OK __7: ; goto end_playback @@ -32495,7 +31885,7 @@ __9: goto __10 } rc = pager_truncate(tls, pPager, *(*Pgno)(unsafe.Pointer(bp + 32 /* mxPg */))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __11 } goto end_playback @@ -32520,20 +31910,20 @@ __12: __15: ; rc = pager_playback_one_page(tls, pPager, (pPager + 96 /* &.journalOff */), uintptr(0), 1, 0) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __16 } nPlayback++ goto __17 __16: - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __18 } (*Pager)(unsafe.Pointer(pPager)).FjournalOff = *(*I64)(unsafe.Pointer(bp + 16 /* szJ */)) goto __14 goto __19 __18: - if !(rc == (10 | (int32(2) << 8))) { + if !(rc == (SQLITE_IOERR | (int32(2) << 8))) { goto __20 } // If the journal has been truncated, simply stop reading and @@ -32541,7 +31931,7 @@ __18: // not completely written and synced prior to a crash. In that // case, the database should have never been written in the // first place so it is OK to simply abandon the rollback. - rc = 0 + rc = SQLITE_OK goto end_playback goto __21 __20: @@ -32569,7 +31959,7 @@ __5: //NOTREACHED end_playback: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __22 } rc = Xsqlite3PagerSetPagesize(tls, pPager, bp+36 /* &savedPageSize */, -1) @@ -32590,7 +31980,7 @@ __22: // in case this has happened, clear the changeCountDone flag now. (*Pager)(unsafe.Pointer(pPager)).FchangeCountDone = (*Pager)(unsafe.Pointer(pPager)).FtempFile - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __23 } zSuper = (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace @@ -32598,21 +31988,21 @@ __22: __23: ; - if !((rc == 0) && - ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= 4) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 0))) { + if !((rc == SQLITE_OK) && + ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_DBMOD) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN))) { goto __24 } rc = Xsqlite3PagerSync(tls, pPager, uintptr(0)) __24: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __25 } - rc = pager_end_transaction(tls, pPager, (libc.Bool32(int32(*(*int8)(unsafe.Pointer(zSuper + uintptr(0)))) != 0)), 0) + rc = pager_end_transaction(tls, pPager, (libc.Bool32(int32(*(*int8)(unsafe.Pointer(zSuper))) != 0)), 0) __25: ; - if !(((rc == 0) && (*(*int8)(unsafe.Pointer(zSuper + uintptr(0))) != 0)) && (*(*int32)(unsafe.Pointer(bp + 24 /* res */)) != 0)) { + if !(((rc == SQLITE_OK) && (*(*int8)(unsafe.Pointer(zSuper)) != 0)) && (*(*int32)(unsafe.Pointer(bp + 24 /* res */)) != 0)) { goto __26 } // If there was a super-journal and this routine will return success, @@ -32624,7 +32014,7 @@ __26: if !((isHot != 0) && (nPlayback != 0)) { goto __27 } - Xsqlite3_log(tls, (27 | (int32(2) << 8)), ts+5565, /* "recovered %d pag..." */ + Xsqlite3_log(tls, (SQLITE_NOTICE | (int32(2) << 8)), ts+5565, /* "recovered %d pag..." */ libc.VaList(bp, nPlayback, (*Pager)(unsafe.Pointer(pPager)).FzJournal)) __27: ; @@ -32651,7 +32041,7 @@ func readDbPage(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:54657:12: */ defer tls.Free(4) var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager // Pager object associated with page pPg - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code *(*U32)(unsafe.Pointer(bp /* iFrame */)) = U32(0) // Frame of WAL containing pgno @@ -32666,8 +32056,8 @@ func readDbPage(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:54657:12: */ } else { var iOffset I64 = ((I64((*PgHdr)(unsafe.Pointer(pPg)).Fpgno - Pgno(1))) * I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)) rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, (*PgHdr)(unsafe.Pointer(pPg)).FpData, (*Pager)(unsafe.Pointer(pPager)).FpageSize, iOffset) - if rc == (10 | (int32(2) << 8)) { - rc = 0 + if rc == (SQLITE_IOERR | (int32(2) << 8)) { + rc = SQLITE_OK } } @@ -32686,7 +32076,7 @@ func readDbPage(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:54657:12: */ // we should still be ok. libc.Xmemset(tls, pPager+136 /* &.dbFileVers */, 0xff, uint64(unsafe.Sizeof([16]int8{}))) } else { - var dbFileVers uintptr = (((*PgHdr)(unsafe.Pointer(pPg)).FpData) + uintptr(24)) + var dbFileVers uintptr = (((*PgHdr)(unsafe.Pointer(pPg)).FpData) + 24) libc.Xmemcpy(tls, (pPager + 136 /* &.dbFileVers */), dbFileVers, uint64(unsafe.Sizeof([16]int8{}))) } } @@ -32713,7 +32103,7 @@ func pager_write_changecounter(tls *libc.TLS, pPg uintptr) { /* sqlite3.c:54720: // bytes 92..95 store the change counter for which the version number // is valid. Xsqlite3Put4byte(tls, (((*PgHdr)(unsafe.Pointer(pPg)).FpData) + uintptr(92)), change_counter) - Xsqlite3Put4byte(tls, (((*PgHdr)(unsafe.Pointer(pPg)).FpData) + uintptr(96)), uint32(3033000)) + Xsqlite3Put4byte(tls, (((*PgHdr)(unsafe.Pointer(pPg)).FpData) + uintptr(96)), SQLITE_VERSION_NUMBER) } // This function is invoked once for each page that has already been @@ -32727,7 +32117,7 @@ func pager_write_changecounter(tls *libc.TLS, pPg uintptr) { /* sqlite3.c:54720: // attempt to reload content from the database is required and fails, // return an SQLite error code. Otherwise, SQLITE_OK. func pagerUndoCallback(tls *libc.TLS, pCtx uintptr, iPg Pgno) int32 { /* sqlite3.c:54747:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pPager uintptr = pCtx var pPg uintptr @@ -32737,7 +32127,7 @@ func pagerUndoCallback(tls *libc.TLS, pCtx uintptr, iPg Pgno) int32 { /* sqlite3 Xsqlite3PcacheDrop(tls, pPg) } else { rc = readDbPage(tls, pPg) - if rc == 0 { + if rc == SQLITE_OK { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((pPager + 264 /* &.xReiniter */))))(tls, pPg) } Xsqlite3PagerUnrefNotNull(tls, pPg) @@ -32772,7 +32162,7 @@ func pagerRollbackWal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:54782: f func(*libc.TLS, uintptr, Pgno) int32 }{pagerUndoCallback})), pPager) pList = Xsqlite3PcacheDirtyList(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) - for (pList != 0) && (rc == 0) { + for (pList != 0) && (rc == SQLITE_OK) { var pNext uintptr = (*PgHdr)(unsafe.Pointer(pList)).FpDirty rc = pagerUndoCallback(tls, pPager, (*PgHdr)(unsafe.Pointer(pList)).Fpgno) pList = pNext @@ -32814,14 +32204,14 @@ func pagerWalFrames(tls *libc.TLS, pPager uintptr, pList uintptr, nTruncate Pgno } else { nList = 1 } - *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(2)*4)) += (nList) + *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + 2*4)) += (nList) if (*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pList */)))).Fpgno == Pgno(1) { pager_write_changecounter(tls, *(*uintptr)(unsafe.Pointer(bp /* pList */))) } rc = Xsqlite3WalFrames(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, (*Pager)(unsafe.Pointer(pPager)).FpageSize, *(*uintptr)(unsafe.Pointer(bp /* pList */)), nTruncate, isCommit, int32((*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags)) - if (rc == 0) && ((*Pager)(unsafe.Pointer(pPager)).FpBackup != 0) { + if (rc == SQLITE_OK) && ((*Pager)(unsafe.Pointer(pPager)).FpBackup != 0) { for p = *(*uintptr)(unsafe.Pointer(bp /* pList */)); p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirty { Xsqlite3BackupUpdate(tls, (*Pager)(unsafe.Pointer(pPager)).FpBackup, (*PgHdr)(unsafe.Pointer(p)).Fpgno, (*PgHdr)(unsafe.Pointer(p)).FpData) } @@ -32850,7 +32240,7 @@ func pagerBeginReadTransaction(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3 Xsqlite3WalEndReadTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal) rc = Xsqlite3WalBeginReadTransaction(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, bp /* &changed */) - if (rc != 0) || (*(*int32)(unsafe.Pointer(bp /* changed */)) != 0) { + if (rc != SQLITE_OK) || (*(*int32)(unsafe.Pointer(bp /* changed */)) != 0) { pager_reset(tls, pPager) if (*Pager)(unsafe.Pointer(pPager)).FbUseFetch != 0 { Xsqlite3OsUnfetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, int64(0), uintptr(0)) @@ -32888,7 +32278,7 @@ func pagerPagecount(tls *libc.TLS, pPager uintptr, pnPage uintptr) int32 { /* sq if (nPage == Pgno(0)) && ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0)) { *(*I64)(unsafe.Pointer(bp /* n */)) = int64(0) // Size of db file in bytes var rc int32 = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp /* &n */) - if rc != 0 { + if rc != SQLITE_OK { return rc } nPage = (Pgno(((*(*I64)(unsafe.Pointer(bp /* n */)) + I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)) - int64(1)) / I64((*Pager)(unsafe.Pointer(pPager)).FpageSize))) @@ -32902,7 +32292,7 @@ func pagerPagecount(tls *libc.TLS, pPager uintptr, pnPage uintptr) int32 { /* sq } *(*Pgno)(unsafe.Pointer(pnPage)) = nPage - return 0 + return SQLITE_OK } // Check if the *-wal file that corresponds to the database opened by pPager @@ -32925,14 +32315,14 @@ func pagerOpenWalIfPresent(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK if !(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) { // var isWal int32 at bp, 4 // True if WAL file exists rc = Xsqlite3OsAccess(tls, - (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzWal, 0, bp /* &isWal */) - if rc == 0 { + (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzWal, SQLITE_ACCESS_EXISTS, bp /* &isWal */) + if rc == SQLITE_OK { if *(*int32)(unsafe.Pointer(bp /* isWal */)) != 0 { // var nPage Pgno at bp+4, 4 // Size of the database file @@ -32947,8 +32337,8 @@ func pagerOpenWalIfPresent(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5 rc = Xsqlite3PagerOpenWal(tls, pPager, uintptr(0)) } - } else if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 5 { - (*Pager)(unsafe.Pointer(pPager)).FjournalMode = U8(0) + } else if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_WAL { + (*Pager)(unsafe.Pointer(pPager)).FjournalMode = PAGER_JOURNALMODE_DELETE } } } @@ -32995,14 +32385,14 @@ func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) i var szJ I64 // Effective size of the main journal var iHdrOff I64 // End of first segment of main-journal records - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var pDone uintptr = uintptr(0) // Bitvec to ensure pages played back only once // Allocate a bitvec to use to store the set of pages rolled back if pSavepoint != 0 { pDone = Xsqlite3BitvecCreate(tls, (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FnOrig) if !(pDone != 0) { - return 7 + return SQLITE_NOMEM } } @@ -33039,7 +32429,7 @@ func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) i iHdrOff = szJ } (*Pager)(unsafe.Pointer(pPager)).FjournalOff = (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FiOffset - for (rc == 0) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff < iHdrOff) { + for (rc == SQLITE_OK) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff < iHdrOff) { rc = pager_playback_one_page(tls, pPager, (pPager + 96 /* &.journalOff */), pDone, 1, 1) } @@ -33051,7 +32441,7 @@ func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) i // the first journal header seen and continuing until the effective end // of the main journal file. Continue to skip out-of-range pages and // continue adding pages rolled back to pDone. - for (rc == 0) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff < szJ) { + for (rc == SQLITE_OK) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff < szJ) { var ii U32 // Loop counter *(*U32)(unsafe.Pointer(bp /* nJRec */)) = U32(0) // Number of Journal Records // var dummy U32 at bp+4, 4 @@ -33065,7 +32455,7 @@ func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) i (((*Pager)(unsafe.Pointer(pPager)).FjournalHdr + (I64((*Pager)(unsafe.Pointer(pPager)).FsectorSize))) == (*Pager)(unsafe.Pointer(pPager)).FjournalOff) { *(*U32)(unsafe.Pointer(bp /* nJRec */)) = (U32((szJ - (*Pager)(unsafe.Pointer(pPager)).FjournalOff) / (I64(((*Pager)(unsafe.Pointer(pPager)).FpageSize) + 8)))) } - for ii = U32(0); ((rc == 0) && (ii < *(*U32)(unsafe.Pointer(bp /* nJRec */)))) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff < szJ); ii++ { + for ii = U32(0); ((rc == SQLITE_OK) && (ii < *(*U32)(unsafe.Pointer(bp /* nJRec */)))) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff < szJ); ii++ { rc = pager_playback_one_page(tls, pPager, (pPager + 96 /* &.journalOff */), pDone, 1, 1) } @@ -33081,7 +32471,7 @@ func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) i if (*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0) { rc = Xsqlite3WalSavepointUndo(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, pSavepoint+32 /* &.aWalData */) } - for ii = (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FiSubRec; (rc == 0) && (ii < (*Pager)(unsafe.Pointer(pPager)).FnSubRec); ii++ { + for ii = (*PagerSavepoint)(unsafe.Pointer(pSavepoint)).FiSubRec; (rc == SQLITE_OK) && (ii < (*Pager)(unsafe.Pointer(pPager)).FnSubRec); ii++ { rc = pager_playback_one_page(tls, pPager, bp+8 /* &offset */, pDone, 0, 1) } @@ -33089,7 +32479,7 @@ func pagerPlaybackSavepoint(tls *libc.TLS, pPager uintptr, pSavepoint uintptr) i } Xsqlite3BitvecDestroy(tls, pDone) - if rc == 0 { + if rc == SQLITE_OK { (*Pager)(unsafe.Pointer(pPager)).FjournalOff = szJ } @@ -33120,7 +32510,7 @@ func pagerFixMaplimit(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:55168:13: */ *(*Sqlite3_int64)(unsafe.Pointer(bp /* sz */)) = (*Pager)(unsafe.Pointer(pPager)).FszMmap (*Pager)(unsafe.Pointer(pPager)).FbUseFetch = (U8(libc.Bool32(*(*Sqlite3_int64)(unsafe.Pointer(bp /* sz */)) > int64(0)))) setGetterMethod(tls, pPager) - Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, 18, bp /* &sz */) + Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_MMAP_SIZE, bp /* &sz */) } } @@ -33185,26 +32575,26 @@ func Xsqlite3PagerShrink(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:55192:21: // Numeric values associated with these states are OFF==1, NORMAL=2, // and FULL=3. func Xsqlite3PagerSetFlags(tls *libc.TLS, pPager uintptr, pgFlags uint32) { /* sqlite3.c:55248:21: */ - var level uint32 = (pgFlags & uint32(0x07)) + var level uint32 = (pgFlags & PAGER_SYNCHRONOUS_MASK) if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 { (*Pager)(unsafe.Pointer(pPager)).FnoSync = U8(1) (*Pager)(unsafe.Pointer(pPager)).FfullSync = U8(0) (*Pager)(unsafe.Pointer(pPager)).FextraSync = U8(0) } else { (*Pager)(unsafe.Pointer(pPager)).FnoSync = func() uint8 { - if level == uint32(0x01) { + if level == PAGER_SYNCHRONOUS_OFF { return uint8(1) } return uint8(0) }() (*Pager)(unsafe.Pointer(pPager)).FfullSync = func() uint8 { - if level >= uint32(0x03) { + if level >= PAGER_SYNCHRONOUS_FULL { return uint8(1) } return uint8(0) }() (*Pager)(unsafe.Pointer(pPager)).FextraSync = func() uint8 { - if level == uint32(0x04) { + if level == PAGER_SYNCHRONOUS_EXTRA { return uint8(1) } return uint8(0) @@ -33212,22 +32602,22 @@ func Xsqlite3PagerSetFlags(tls *libc.TLS, pPager uintptr, pgFlags uint32) { /* s } if (*Pager)(unsafe.Pointer(pPager)).FnoSync != 0 { (*Pager)(unsafe.Pointer(pPager)).FsyncFlags = U8(0) - } else if (pgFlags & uint32(0x08)) != 0 { - (*Pager)(unsafe.Pointer(pPager)).FsyncFlags = U8(0x00003) + } else if (pgFlags & PAGER_FULLFSYNC) != 0 { + (*Pager)(unsafe.Pointer(pPager)).FsyncFlags = SQLITE_SYNC_FULL } else { - (*Pager)(unsafe.Pointer(pPager)).FsyncFlags = U8(0x00002) + (*Pager)(unsafe.Pointer(pPager)).FsyncFlags = SQLITE_SYNC_NORMAL } (*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags = (U8(int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags) << 2)) if (*Pager)(unsafe.Pointer(pPager)).FfullSync != 0 { *(*U8)(unsafe.Pointer(pPager + 15 /* &.walSyncFlags */)) |= U8((int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags))) } - if ((pgFlags & uint32(0x10)) != 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { - *(*U8)(unsafe.Pointer(pPager + 15 /* &.walSyncFlags */)) |= U8((int32(0x00003) << 2)) + if ((pgFlags & PAGER_CKPT_FULLFSYNC) != 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { + *(*U8)(unsafe.Pointer(pPager + 15 /* &.walSyncFlags */)) |= U8((int32(SQLITE_SYNC_FULL) << 2)) } - if (pgFlags & uint32(0x20)) != 0 { - *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) &= libc.Uint8FromInt32((^libc.Int32(0x01))) + if (pgFlags & PAGER_CACHESPILL) != 0 { + *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) &= libc.Uint8FromInt32((libc.CplInt32(SPILLFLAG_OFF))) } else { - *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) |= U8((0x01)) + *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) |= U8((SPILLFLAG_OFF)) } } @@ -33254,7 +32644,7 @@ func pagerOpentemp(tls *libc.TLS, pPager uintptr, pFile uintptr, vfsFlags int32) Xsqlite3_opentemp_count++ // Used for testing and analysis only - vfsFlags = vfsFlags | (((0x00000002 | 0x00000004) | 0x00000010) | 0x00000008) + vfsFlags = vfsFlags | (((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_DELETEONCLOSE) rc = Xsqlite3OsOpen(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, uintptr(0), pFile, vfsFlags, uintptr(0)) return rc @@ -33285,7 +32675,7 @@ func Xsqlite3PagerSetBusyHandler(tls *libc.TLS, pPager uintptr, xBusyHandler uin (*Pager)(unsafe.Pointer(pPager)).FpBusyHandlerArg = pBusyHandlerArg ap = (pPager + 224 /* &.xBusyHandler */) - Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, 15, ap) + Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_BUSYHANDLER, ap) } // Change the page size used by the Pager object. The new page size @@ -33320,7 +32710,7 @@ func Xsqlite3PagerSetPagesize(tls *libc.TLS, pPager uintptr, pPageSize uintptr, bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK // It is not possible to do a full assert_pager_state() here, as this // function may be called from within PagerOpen(), before the state @@ -33339,25 +32729,25 @@ func Xsqlite3PagerSetPagesize(tls *libc.TLS, pPager uintptr, pPageSize uintptr, var pNew uintptr = uintptr(0) // New temp space *(*I64)(unsafe.Pointer(bp /* nByte */)) = int64(0) - if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) > 0) && ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0)) { + if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) > PAGER_OPEN) && ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0)) { rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp /* &nByte */) } - if rc == 0 { + if rc == SQLITE_OK { // 8 bytes of zeroed overrun space is sufficient so that the b-tree // cell header parser will never run off the end of the allocation pNew = Xsqlite3PageMalloc(tls, (int32(pageSize + U32(8)))) if !(pNew != 0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, (pNew + uintptr(pageSize)), 0, uint64(8)) } } - if rc == 0 { + if rc == SQLITE_OK { pager_reset(tls, pPager) rc = Xsqlite3PcacheSetPageSize(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, int32(pageSize)) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3PageFree(tls, (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace) (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace = pNew (*Pager)(unsafe.Pointer(pPager)).FdbSize = (Pgno(((*(*I64)(unsafe.Pointer(bp /* nByte */)) + I64(pageSize)) - int64(1)) / I64(pageSize))) @@ -33368,7 +32758,7 @@ func Xsqlite3PagerSetPagesize(tls *libc.TLS, pPager uintptr, pPageSize uintptr, } *(*U32)(unsafe.Pointer(pPageSize)) = U32((*Pager)(unsafe.Pointer(pPager)).FpageSize) - if rc == 0 { + if rc == SQLITE_OK { if nReserve < 0 { nReserve = int32((*Pager)(unsafe.Pointer(pPager)).FnReserve) } @@ -33430,7 +32820,7 @@ func Xenable_simulated_io_errors(tls *libc.TLS) { /* sqlite3.c:55498:6: */ // the error code is returned to the caller and the contents of the // output buffer undefined. func Xsqlite3PagerReadFileheader(tls *libc.TLS, pPager uintptr, N int32, pDest uintptr) int32 { /* sqlite3.c:55520:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK libc.Xmemset(tls, pDest, 0, uint64(N)) // This routine is only called by btree immediately after creating @@ -33440,8 +32830,8 @@ func Xsqlite3PagerReadFileheader(tls *libc.TLS, pPager uintptr, N int32, pDest u if (*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Ffd))).FpMethods != uintptr(0) { rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, pDest, N, int64(0)) - if rc == (10 | (int32(2) << 8)) { - rc = 0 + if rc == (SQLITE_IOERR | (int32(2) << 8)) { + rc = SQLITE_OK } } return rc @@ -33477,7 +32867,7 @@ func pager_wait_on_lock(tls *libc.TLS, pPager uintptr, locktype int32) int32 { / // may be invoked during, according to the comment above // sqlite3PagerSetBusyhandler(). - for ok := true; ok; ok = ((rc == 5) && ((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((pPager + 224 /* &.xBusyHandler */))))(tls, (*Pager)(unsafe.Pointer(pPager)).FpBusyHandlerArg) != 0)) { + for ok := true; ok; ok = ((rc == SQLITE_BUSY) && ((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((pPager + 224 /* &.xBusyHandler */))))(tls, (*Pager)(unsafe.Pointer(pPager)).FpBusyHandlerArg) != 0)) { rc = pagerLockDb(tls, pPager, locktype) } return rc @@ -33541,11 +32931,11 @@ func Xsqlite3PagerTruncateImage(tls *libc.TLS, pPager uintptr, nPage Pgno) { /* // If everything goes as planned, SQLITE_OK is returned. Otherwise, // an SQLite error code. func pagerSyncHotJournal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:55664:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { - rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, 0x00002) + rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, SQLITE_SYNC_NORMAL) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3OsFileSize(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (pPager + 104 /* &.journalHdr */)) } return rc @@ -33572,10 +32962,10 @@ func pagerAcquireMapPage(tls *libc.TLS, pPager uintptr, pgno Pgno, pData uintptr *(*uintptr)(unsafe.Pointer(ppPage)) = libc.AssignUintptr(&p, Xsqlite3MallocZero(tls, (uint64(uint64(unsafe.Sizeof(PgHdr{}))+uint64((*Pager)(unsafe.Pointer(pPager)).FnExtra))))) if p == uintptr(0) { Xsqlite3OsUnfetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, ((I64(pgno - Pgno(1))) * I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)), pData) - return 7 + return SQLITE_NOMEM } - (*PgHdr)(unsafe.Pointer(p)).FpExtra = (p + uintptr(1)*72) - (*PgHdr)(unsafe.Pointer(p)).Fflags = U16(0x020) + (*PgHdr)(unsafe.Pointer(p)).FpExtra = (p + 1*72) + (*PgHdr)(unsafe.Pointer(p)).Fflags = PGHDR_MMAP (*PgHdr)(unsafe.Pointer(p)).FnRef = int16(1) (*PgHdr)(unsafe.Pointer(p)).FpPager = pPager } @@ -33584,7 +32974,7 @@ func pagerAcquireMapPage(tls *libc.TLS, pPager uintptr, pgno Pgno, pData uintptr (*PgHdr)(unsafe.Pointer(p)).FpData = pData (*Pager)(unsafe.Pointer(pPager)).FnMmapOut++ - return 0 + return SQLITE_OK } // Release a reference to page pPg. pPg must have been returned by an @@ -33620,20 +33010,20 @@ func databaseIsUnmoved(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:55757 var rc int32 if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 { - return 0 + return SQLITE_OK } if (*Pager)(unsafe.Pointer(pPager)).FdbSize == Pgno(0) { - return 0 + return SQLITE_OK } - rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, 20, bp /* &bHasMoved */) - if rc == 12 { + rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_HAS_MOVED, bp /* &bHasMoved */) + if rc == SQLITE_NOTFOUND { // If the HAS_MOVED file-control is unimplemented, assume that the file // has not been moved. That is the historical behavior of SQLite: prior to // version 3.8.3, it never checked - rc = 0 - } else if (rc == 0) && (*(*int32)(unsafe.Pointer(bp /* bHasMoved */)) != 0) { - rc = (8 | (int32(4) << 8)) + rc = SQLITE_OK + } else if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* bHasMoved */)) != 0) { + rc = (SQLITE_READONLY | (int32(4) << 8)) } return rc } @@ -33661,8 +33051,8 @@ func Xsqlite3PagerClose(tls *libc.TLS, pPager uintptr, db uintptr) int32 { /* sq { var a uintptr = uintptr(0) - if ((db != 0) && (uint64(0) == ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000800)))) && - (0 == databaseIsUnmoved(tls, pPager)) { + if ((db != 0) && (uint64(0) == ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_NoCkptOnClose))) && + (SQLITE_OK == databaseIsUnmoved(tls, pPager)) { a = pTmp } Xsqlite3WalClose(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, db, int32((*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags), (*Pager)(unsafe.Pointer(pPager)).FpageSize, a) @@ -33697,7 +33087,7 @@ func Xsqlite3PagerClose(tls *libc.TLS, pPager uintptr, db uintptr) int32 { /* sq Xsqlite3PcacheClose(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) Xsqlite3_free(tls, pPager) - return 0 + return SQLITE_OK } // Return the page number for page pPg. @@ -33750,16 +33140,16 @@ func syncJournal(tls *libc.TLS, pPager uintptr, newHdr int32) int32 { /* sqlite3 var rc int32 // Return code rc = Xsqlite3PagerExclusiveLock(tls, pPager) - if rc != 0 { + if rc != SQLITE_OK { return rc } if !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { - if ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) && (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != 4) { + if ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) && (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_MEMORY) { var iDc int32 = Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd) - if 0 == (iDc & 0x00000200) { + if 0 == (iDc & SQLITE_IOCAP_SAFE_APPEND) { // This block deals with an obscure problem. If the last connection // that wrote to this database was operating in persistent-journal // mode, then the journal file may at this point actually be larger @@ -33787,14 +33177,14 @@ func syncJournal(tls *libc.TLS, pPager uintptr, newHdr int32) int32 { /* sqlite3 // var zHeader [12]U8 at bp, 12 libc.Xmemcpy(tls, bp /* &zHeader[0] */, uintptr(unsafe.Pointer(&aJournalMagic)), uint64(unsafe.Sizeof(aJournalMagic))) - Xsqlite3Put4byte(tls, (bp /* &zHeader */ + uintptr(uint64(unsafe.Sizeof(aJournalMagic)))), uint32((*Pager)(unsafe.Pointer(pPager)).FnRec)) + Xsqlite3Put4byte(tls, (bp /* &zHeader */ + 8), uint32((*Pager)(unsafe.Pointer(pPager)).FnRec)) iNextHdrOffset = journalHdrOffset(tls, pPager) rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp+12 /* &aMagic[0] */, 8, iNextHdrOffset) - if (rc == 0) && (0 == libc.Xmemcmp(tls, bp+12 /* &aMagic[0] */, uintptr(unsafe.Pointer(&aJournalMagic)), uint64(8))) { + if (rc == SQLITE_OK) && (0 == libc.Xmemcmp(tls, bp+12 /* &aMagic[0] */, uintptr(unsafe.Pointer(&aJournalMagic)), uint64(8))) { rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, uintptr(unsafe.Pointer(&zerobyte)), 1, iNextHdrOffset) } - if (rc != 0) && (rc != (10 | (int32(2) << 8))) { + if (rc != SQLITE_OK) && (rc != (SQLITE_IOERR | (int32(2) << 8))) { return rc } @@ -33808,38 +33198,38 @@ func syncJournal(tls *libc.TLS, pPager uintptr, newHdr int32) int32 { /* sqlite3 // for garbage data to be appended to the file, the nRec field // is populated with 0xFFFFFFFF when the journal header is written // and never needs to be updated. - if ((*Pager)(unsafe.Pointer(pPager)).FfullSync != 0) && (0 == (iDc & 0x00000400)) { + if ((*Pager)(unsafe.Pointer(pPager)).FfullSync != 0) && (0 == (iDc & SQLITE_IOCAP_SEQUENTIAL)) { rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags)) - if rc != 0 { + if rc != SQLITE_OK { return rc } } rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp /* &zHeader[0] */, int32(unsafe.Sizeof([12]U8{})), (*Pager)(unsafe.Pointer(pPager)).FjournalHdr) - if rc != 0 { + if rc != SQLITE_OK { return rc } } - if 0 == (iDc & 0x00000400) { + if 0 == (iDc & SQLITE_IOCAP_SEQUENTIAL) { rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, (int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags) | (func() int32 { - if int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags) == 0x00003 { - return 0x00010 + if int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags) == SQLITE_SYNC_FULL { + return SQLITE_SYNC_DATAONLY } return 0 }()))) - if rc != 0 { + if rc != SQLITE_OK { return rc } } (*Pager)(unsafe.Pointer(pPager)).FjournalHdr = (*Pager)(unsafe.Pointer(pPager)).FjournalOff - if (newHdr != 0) && (0 == (iDc & 0x00000200)) { + if (newHdr != 0) && (0 == (iDc & SQLITE_IOCAP_SAFE_APPEND)) { (*Pager)(unsafe.Pointer(pPager)).FnRec = 0 rc = writeJournalHdr(tls, pPager) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -33852,9 +33242,9 @@ func syncJournal(tls *libc.TLS, pPager uintptr, newHdr int32) int32 { /* sqlite3 // successfully synced. Either way, clear the PGHDR_NEED_SYNC flag on // all pages. Xsqlite3PcacheClearSyncFlags(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(4) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_WRITER_DBMOD - return 0 + return SQLITE_OK } var zerobyte U8 = U8(0) /* sqlite3.c:55950:27 */ @@ -33893,7 +33283,7 @@ func pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) int32 { bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code // This function is only called for rollback pagers in WRITER_DBMOD state. @@ -33908,15 +33298,15 @@ func pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) int32 { // Before the first write, give the VFS a hint of what the final // file size will be. - if ((rc == 0) && + if ((rc == SQLITE_OK) && ((*Pager)(unsafe.Pointer(pPager)).FdbHintSize < (*Pager)(unsafe.Pointer(pPager)).FdbSize)) && (((*PgHdr)(unsafe.Pointer(pList)).FpDirty != 0) || ((*PgHdr)(unsafe.Pointer(pList)).Fpgno > (*Pager)(unsafe.Pointer(pPager)).FdbHintSize)) { *(*Sqlite3_int64)(unsafe.Pointer(bp /* szFile */)) = (Sqlite3_int64((*Pager)(unsafe.Pointer(pPager)).FpageSize) * Sqlite3_int64((*Pager)(unsafe.Pointer(pPager)).FdbSize)) - Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, 5, bp /* &szFile */) + Xsqlite3OsFileControlHint(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_SIZE_HINT, bp /* &szFile */) (*Pager)(unsafe.Pointer(pPager)).FdbHintSize = (*Pager)(unsafe.Pointer(pPager)).FdbSize } - for (rc == 0) && (pList != 0) { + for (rc == SQLITE_OK) && (pList != 0) { var pgno Pgno = (*PgHdr)(unsafe.Pointer(pList)).Fpgno // If there are dirty pages in the page cache with page numbers greater @@ -33926,7 +33316,7 @@ func pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) int32 { // // Also, do not write out any page that has the PGHDR_DONT_WRITE flag // set (set by sqlite3PagerDontWrite()). - if (pgno <= (*Pager)(unsafe.Pointer(pPager)).FdbSize) && (0 == (int32((*PgHdr)(unsafe.Pointer(pList)).Fflags) & 0x010)) { + if (pgno <= (*Pager)(unsafe.Pointer(pPager)).FdbSize) && (0 == (int32((*PgHdr)(unsafe.Pointer(pList)).Fflags) & PGHDR_DONT_WRITE)) { var offset I64 = ((I64(pgno - Pgno(1))) * I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)) // Offset to write var pData uintptr // Data to write @@ -33943,12 +33333,12 @@ func pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) int32 { // the value now stored in the database file. If writing this // page caused the database file to grow, update dbFileSize. if pgno == Pgno(1) { - libc.Xmemcpy(tls, (pPager + 136 /* &.dbFileVers */), (pData + uintptr(24)), uint64(unsafe.Sizeof([16]int8{}))) + libc.Xmemcpy(tls, (pPager + 136 /* &.dbFileVers */), (pData + 24), uint64(unsafe.Sizeof([16]int8{}))) } if pgno > (*Pager)(unsafe.Pointer(pPager)).FdbFileSize { (*Pager)(unsafe.Pointer(pPager)).FdbFileSize = pgno } - *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(2)*4))++ + *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + 2*4))++ // Update any backup objects copying the contents of this pager. Xsqlite3BackupUpdate(tls, (*Pager)(unsafe.Pointer(pPager)).FpBackup, pgno, (*PgHdr)(unsafe.Pointer(pList)).FpData) @@ -33971,13 +33361,13 @@ func pager_write_pagelist(tls *libc.TLS, pPager uintptr, pList uintptr) int32 { // SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() // fails. func openSubJournal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:56133:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if !((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fsjfd))).FpMethods != uintptr(0)) { - var flags int32 = ((((0x00002000 | 0x00000002) | - 0x00000004) | 0x00000010) | - 0x00000008) + var flags int32 = ((((SQLITE_OPEN_SUBJOURNAL | SQLITE_OPEN_READWRITE) | + SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | + SQLITE_OPEN_DELETEONCLOSE) var nStmtSpill int32 = Xsqlite3Config.FnStmtSpill - if (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 4) || ((*Pager)(unsafe.Pointer(pPager)).FsubjInMemory != 0) { + if (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_MEMORY) || ((*Pager)(unsafe.Pointer(pPager)).FsubjInMemory != 0) { nStmtSpill = -1 } rc = Xsqlite3JournalOpen(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, uintptr(0), (*Pager)(unsafe.Pointer(pPager)).Fsjfd, flags, nStmtSpill) @@ -33995,9 +33385,9 @@ func openSubJournal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:56133:12 // SQLITE_NOMEM if a malloc fails while setting a bit in a savepoint // bitvec. func subjournalPage(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:56159:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager - if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != 2 { + if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_OFF { // Open the sub-journal, if it has not already been opened @@ -34005,19 +33395,19 @@ func subjournalPage(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:56159:12: * // If the sub-journal was opened successfully (or was already open), // write the journal record into the file. - if rc == 0 { + if rc == SQLITE_OK { var pData uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpData var offset I64 = (I64((*Pager)(unsafe.Pointer(pPager)).FnSubRec) * (I64(4 + (*Pager)(unsafe.Pointer(pPager)).FpageSize))) var pData2 uintptr pData2 = pData rc = write32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fsjfd, offset, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fsjfd, pData2, (*Pager)(unsafe.Pointer(pPager)).FpageSize, (offset + int64(4))) } } } - if rc == 0 { + if rc == SQLITE_OK { (*Pager)(unsafe.Pointer(pPager)).FnSubRec++ rc = addToSavepointBitvecs(tls, pPager, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) @@ -34029,7 +33419,7 @@ func subjournalPageIfRequired(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5 if subjRequiresPage(tls, pPg) != 0 { return subjournalPage(tls, pPg) } else { - return 0 + return SQLITE_OK } return int32(0) } @@ -34053,7 +33443,7 @@ func subjournalPageIfRequired(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5 // is returned by sqlite3PcacheMakeClean() is not called. func pagerStress(tls *libc.TLS, p uintptr, pPg uintptr) int32 { /* sqlite3.c:56222:12: */ var pPager uintptr = p - var rc int32 = 0 + var rc int32 = SQLITE_OK // The doNotSpill NOSYNC bit is set during times when doing a sync of // journal (and adding a new header) is not allowed. This occurs @@ -34071,40 +33461,40 @@ func pagerStress(tls *libc.TLS, p uintptr, pPg uintptr) int32 { /* sqlite3.c:562 // be called in the error state. Nevertheless, we include a NEVER() // test for the error state as a safeguard against future changes. if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 { - return 0 + return SQLITE_OK } if ((*Pager)(unsafe.Pointer(pPager)).FdoNotSpill != 0) && - (((int32((*Pager)(unsafe.Pointer(pPager)).FdoNotSpill) & (0x02 | 0x01)) != 0) || - ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & 0x008) != 0)) { - return 0 + (((int32((*Pager)(unsafe.Pointer(pPager)).FdoNotSpill) & (SPILLFLAG_ROLLBACK | SPILLFLAG_OFF)) != 0) || + ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & PGHDR_NEED_SYNC) != 0)) { + return SQLITE_OK } - *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(3)*4))++ + *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + 3*4))++ (*PgHdr)(unsafe.Pointer(pPg)).FpDirty = uintptr(0) if (*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0) { // Write a single frame for this page to the log. rc = subjournalPageIfRequired(tls, pPg) - if rc == 0 { + if rc == SQLITE_OK { rc = pagerWalFrames(tls, pPager, pPg, uint32(0), 0) } } else { // Sync the journal file if required. - if ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & 0x008) != 0) || - (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 3) { + if ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & PGHDR_NEED_SYNC) != 0) || + (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_WRITER_CACHEMOD) { rc = syncJournal(tls, pPager, 1) } // Write the contents of the page out to the database file. - if rc == 0 { + if rc == SQLITE_OK { rc = pager_write_pagelist(tls, pPager, pPg) } } // Mark the page as clean. - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3PcacheMakeClean(tls, pPg) } @@ -34118,7 +33508,7 @@ func Xsqlite3PagerFlush(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5629 if !(int32((*Pager)(unsafe.Pointer(pPager)).FmemDb) != 0) { var pList uintptr = Xsqlite3PcacheDirtyList(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) - for (rc == 0) && (pList != 0) { + for (rc == SQLITE_OK) && (pList != 0) { var pNext uintptr = (*PgHdr)(unsafe.Pointer(pList)).FpDirty if int32((*PgHdr)(unsafe.Pointer(pList)).FnRef) == 0 { rc = pagerStress(tls, pPager, pList) @@ -34186,39 +33576,39 @@ func Xsqlite3PagerOpen(tls *libc.TLS, pVfs uintptr, ppPager uintptr, zFilename u var iDc int32 // var fout int32 at bp+8, 4 *(*uintptr)(unsafe.Pointer(bp /* pPager */)) = uintptr(0) - rc = 0 + rc = SQLITE_OK tempFile = 0 memDb = 0 memJM = 0 readOnly = 0 zPathname = uintptr(0) nPathname = 0 - useJournal = (libc.Bool32((flags & 0x0001) == 0)) + useJournal = (libc.Bool32((flags & PAGER_OMIT_JOURNAL) == 0)) pcacheSize = Xsqlite3PcacheSize(tls) - *(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */)) = U32(1024) + *(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */)) = SQLITE_DEFAULT_PAGE_SIZE zUri = uintptr(0) nUriByte = 1 nUri = 0 // Number of URI parameters // Figure out how much space is required for each journal file-handle // (there are two of them, the main journal and the sub-journal). - journalFileSize = (((Xsqlite3JournalSize(tls, pVfs)) + 7) & ^libc.Int32(7)) + journalFileSize = (((Xsqlite3JournalSize(tls, pVfs)) + 7) & libc.CplInt32(7)) // Set the output variable to NULL in case an error occurs. *(*uintptr)(unsafe.Pointer(ppPager)) = uintptr(0) - if !((flags & 0x0002) != 0) { + if !((flags & PAGER_MEMORY) != 0) { goto __1 } memDb = 1 - if !((zFilename != 0) && (*(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0)) { + if !((zFilename != 0) && (*(*int8)(unsafe.Pointer(zFilename)) != 0)) { goto __2 } zPathname = Xsqlite3DbStrDup(tls, uintptr(0), zFilename) if !(zPathname == uintptr(0)) { goto __3 } - return 7 + return SQLITE_NOMEM __3: ; nPathname = Xsqlite3Strlen30(tls, zPathname) @@ -34231,7 +33621,7 @@ __1: // Compute and store the full pathname in an allocated buffer pointed // to by zPathname, length nPathname. Or, if this is a temporary file, // leave both nPathname and zPathname set to 0. - if !((zFilename != 0) && (*(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0)) { + if !((zFilename != 0) && (*(*int8)(unsafe.Pointer(zFilename)) != 0)) { goto __4 } nPathname = ((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname + 1) @@ -34239,24 +33629,24 @@ __1: if !(zPathname == uintptr(0)) { goto __5 } - return 7 + return SQLITE_NOMEM __5: ; - *(*int8)(unsafe.Pointer(zPathname + uintptr(0))) = int8(0) // Make sure initialized even if FullPathname() fails + *(*int8)(unsafe.Pointer(zPathname)) = int8(0) // Make sure initialized even if FullPathname() fails rc = Xsqlite3OsFullPathname(tls, pVfs, zFilename, nPathname, zPathname) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __6 } - if !(rc == (0 | (int32(2) << 8))) { + if !(rc == (SQLITE_OK | (int32(2) << 8))) { goto __7 } - if !((vfsFlags & 0x01000000) != 0) { + if !((vfsFlags & SQLITE_OPEN_NOFOLLOW) != 0) { goto __8 } - rc = (14 | (int32(6) << 8)) + rc = (SQLITE_CANTOPEN | (int32(6) << 8)) goto __9 __8: - rc = 0 + rc = SQLITE_OK __9: ; __7: @@ -34275,9 +33665,9 @@ __10: goto __10 __11: ; - nUriByte = (int32((int64((z + uintptr(1))) - int64(zUri)) / 1)) + nUriByte = (int32((int64((z + 1)) - int64(zUri)) / 1)) - if !((rc == 0) && ((nPathname + 8) > (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname)) { + if !((rc == SQLITE_OK) && ((nPathname + 8) > (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname)) { goto __12 } // This branch is taken when the journal path required by @@ -34288,7 +33678,7 @@ __11: rc = Xsqlite3CantopenError(tls, 56435) __12: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __13 } Xsqlite3DbFree(tls, uintptr(0), zPathname) @@ -34342,21 +33732,21 @@ __4: // specific formatting and order of the various filenames, so if the format // changes here, be sure to change it there as well. pPtr = Xsqlite3MallocZero(tls, - (uint64((((((((((((((((((uint64(unsafe.Sizeof(Pager{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)) + (uint64(((pcacheSize) + 7) & ^libc.Int32(7)))) + (uint64((((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile) + 7) & ^libc.Int32(7)))) + (uint64(journalFileSize * 2))) + uint64(unsafe.Sizeof(uintptr(0)))) + uint64(4)) + uint64(nPathname)) + uint64(1)) + uint64(nUriByte)) + uint64(nPathname)) + uint64(8)) + uint64(1)) + uint64(nPathname)) + uint64(4)) + uint64(1)) + uint64(3)))) + (uint64((((((((((((((((((uint64(unsafe.Sizeof(Pager{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))) + (uint64(((pcacheSize) + 7) & libc.CplInt32(7)))) + (uint64((((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile) + 7) & libc.CplInt32(7)))) + (uint64(journalFileSize * 2))) + uint64(unsafe.Sizeof(uintptr(0)))) + uint64(4)) + uint64(nPathname)) + uint64(1)) + uint64(nUriByte)) + uint64(nPathname)) + uint64(8)) + uint64(1)) + uint64(nPathname)) + uint64(4)) + uint64(1)) + uint64(3)))) if !(!(pPtr != 0)) { goto __14 } Xsqlite3DbFree(tls, uintptr(0), zPathname) - return 7 + return SQLITE_NOMEM __14: ; *(*uintptr)(unsafe.Pointer(bp /* pPager */)) = pPtr - pPtr += (uintptr(((uint64(unsafe.Sizeof(Pager{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + pPtr += (uintptr(((uint64(unsafe.Sizeof(Pager{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FpPCache = pPtr - pPtr += (uintptr(((pcacheSize) + 7) & ^libc.Int32(7))) + pPtr += (uintptr(((pcacheSize) + 7) & libc.CplInt32(7))) (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).Ffd = pPtr - pPtr += (uintptr((((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile) + 7) & ^libc.Int32(7))) + pPtr += (uintptr((((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile) + 7) & libc.CplInt32(7))) (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).Fsjfd = pPtr pPtr += uintptr(journalFileSize) (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).Fjfd = pPtr @@ -34426,14 +33816,14 @@ __22: (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FvfsFlags = U32(vfsFlags) // Open the pager file. - if !((zFilename != 0) && (*(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0)) { + if !((zFilename != 0) && (*(*int8)(unsafe.Pointer(zFilename)) != 0)) { goto __23 } *(*int32)(unsafe.Pointer(bp + 8 /* fout */)) = 0 // VFS flags returned by xOpen() rc = Xsqlite3OsOpen(tls, pVfs, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FzFilename, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).Ffd, vfsFlags, bp+8 /* &fout */) - memJM = (libc.Bool32((*(*int32)(unsafe.Pointer(bp + 8 /* fout */)) & 0x00000080) != 0)) - readOnly = (libc.Bool32((*(*int32)(unsafe.Pointer(bp + 8 /* fout */)) & 0x00000001) != 0)) + memJM = (libc.Bool32((*(*int32)(unsafe.Pointer(bp + 8 /* fout */)) & SQLITE_OPEN_MEMORY) != 0)) + readOnly = (libc.Bool32((*(*int32)(unsafe.Pointer(bp + 8 /* fout */)) & SQLITE_OPEN_READONLY) != 0)) // If the file was successfully opened for read/write access, // choose a default page size in case we have to create the @@ -34442,7 +33832,7 @@ __22: // + SQLITE_DEFAULT_PAGE_SIZE, // + The value returned by sqlite3OsSectorSize() // + The largest page size that can be written atomically. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __25 } iDc = Xsqlite3OsDeviceCharacteristics(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).Ffd) @@ -34454,10 +33844,10 @@ __22: if !(*(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */)) < (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FsectorSize) { goto __27 } - if !((*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FsectorSize > U32(8192)) { + if !((*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FsectorSize > SQLITE_MAX_DEFAULT_PAGE_SIZE) { goto __28 } - *(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */)) = U32(8192) + *(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */)) = SQLITE_MAX_DEFAULT_PAGE_SIZE goto __29 __28: *(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */)) = (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FsectorSize @@ -34468,11 +33858,11 @@ __27: __26: ; (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FnoLock = U8(Xsqlite3_uri_boolean(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FzFilename, ts+5606 /* "nolock" */, 0)) - if !(((iDc & 0x00002000) != 0) || + if !(((iDc & SQLITE_IOCAP_IMMUTABLE) != 0) || (Xsqlite3_uri_boolean(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FzFilename, ts+5613 /* "immutable" */, 0) != 0)) { goto __30 } - vfsFlags = vfsFlags | (0x00000001) + vfsFlags = vfsFlags | (SQLITE_OPEN_READONLY) goto act_like_temp_file __30: ; @@ -34491,16 +33881,16 @@ __23: // This branch also runs for files marked as immutable. act_like_temp_file: tempFile = 1 - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FeState = U8(1) // Pretend we already have a lock - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FeLock = U8(4) // Pretend we are in EXCLUSIVE mode - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FnoLock = U8(1) // Do no locking - readOnly = (vfsFlags & 0x00000001) + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FeState = PAGER_READER // Pretend we already have a lock + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FeLock = EXCLUSIVE_LOCK // Pretend we are in EXCLUSIVE mode + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FnoLock = U8(1) // Do no locking + readOnly = (vfsFlags & SQLITE_OPEN_READONLY) __24: ; // The following call to PagerSetPagesize() serves to set the value of // Pager.pageSize and to allocate the Pager.pTmpSpace buffer. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __31 } @@ -34510,10 +33900,10 @@ __31: ; // Initialize the PCache object. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __32 } - nExtra = (((nExtra) + 7) & ^libc.Int32(7)) + nExtra = (((nExtra) + 7) & libc.CplInt32(7)) rc = Xsqlite3PcacheOpen(tls, int32(*(*U32)(unsafe.Pointer(bp + 12 /* szPageDflt */))), nExtra, libc.BoolInt32(!(memDb != 0)), func() uintptr { @@ -34528,7 +33918,7 @@ __32: ; // If an error occurred above, free the Pager structure and close the file. - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __33 } Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).Ffd) @@ -34545,7 +33935,7 @@ __33: // pPager->stmtSize = 0; // pPager->stmtJSize = 0; // pPager->nPage = 0; - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FmxPgno = Pgno(1073741823) + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FmxPgno = SQLITE_MAX_PAGE_COUNT // pPager->state = PAGER_UNLOCK; // pPager->errMask = 0; (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FtempFile = U8(tempFile) @@ -34564,8 +33954,8 @@ __33: __34: (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FfullSync = U8(1) (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FextraSync = U8(0) - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FsyncFlags = U8(0x00002) - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FwalSyncFlags = (U8(0x00002 | (int32(0x00002) << 2))) + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FsyncFlags = SQLITE_SYNC_NORMAL + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FwalSyncFlags = (U8(SQLITE_SYNC_NORMAL | (int32(SQLITE_SYNC_NORMAL) << 2))) __35: ; // pPager->pFirst = 0; @@ -34578,13 +33968,13 @@ __35: if !(!(useJournal != 0)) { goto __36 } - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FjournalMode = U8(2) + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FjournalMode = PAGER_JOURNALMODE_OFF goto __37 __36: if !((memDb != 0) || (memJM != 0)) { goto __38 } - (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FjournalMode = U8(4) + (*Pager)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPager */)))).FjournalMode = PAGER_JOURNALMODE_MEMORY __38: ; __37: @@ -34597,7 +33987,7 @@ __37: // pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c *(*uintptr)(unsafe.Pointer(ppPager)) = *(*uintptr)(unsafe.Pointer(bp /* pPager */)) - return 0 + return SQLITE_OK } // Return the sqlite3_file for the main database given the name @@ -34646,15 +34036,15 @@ func hasHotJournal(tls *libc.TLS, pPager uintptr, pExists uintptr) int32 { /* sq defer tls.Free(17) var pVfs uintptr = (*Pager)(unsafe.Pointer(pPager)).FpVfs - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code *(*int32)(unsafe.Pointer(bp /* exists */)) = 1 // True if a journal file is present var jrnlOpen int32 = libc.BoolInt32(!(!((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)))) *(*int32)(unsafe.Pointer(pExists)) = 0 if !(jrnlOpen != 0) { - rc = Xsqlite3OsAccess(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0, bp /* &exists */) + rc = Xsqlite3OsAccess(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, SQLITE_ACCESS_EXISTS, bp /* &exists */) } - if (rc == 0) && (*(*int32)(unsafe.Pointer(bp /* exists */)) != 0) { + if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* exists */)) != 0) { *(*int32)(unsafe.Pointer(bp + 4 /* locked */)) = 0 // True if some process holds a RESERVED lock // Race condition here: Another process might have been holding the @@ -34665,12 +34055,12 @@ func hasHotJournal(tls *libc.TLS, pPager uintptr, pExists uintptr) int32 { /* sq // in fact there is none. This results in a false-positive which will // be dealt with by the playback routine. Ticket #3883. rc = Xsqlite3OsCheckReservedLock(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp+4 /* &locked */) - if (rc == 0) && !(*(*int32)(unsafe.Pointer(bp + 4 /* locked */)) != 0) { + if (rc == SQLITE_OK) && !(*(*int32)(unsafe.Pointer(bp + 4 /* locked */)) != 0) { // var nPage Pgno at bp+8, 4 // Number of pages in database file rc = pagerPagecount(tls, pPager, bp+8 /* &nPage */) - if rc == 0 { + if rc == SQLITE_OK { // If the database is zero pages in size, that means that either (1) the // journal is a remnant from a prior database with the same name where // the database file but not the journal was deleted, or (2) the initial @@ -34680,10 +34070,10 @@ func hasHotJournal(tls *libc.TLS, pPager uintptr, pExists uintptr) int32 { /* sq // journal_mode=PERSIST. if (*(*Pgno)(unsafe.Pointer(bp + 8 /* nPage */)) == Pgno(0)) && !(jrnlOpen != 0) { Xsqlite3BeginBenignMalloc(tls) - if pagerLockDb(tls, pPager, 2) == 0 { + if pagerLockDb(tls, pPager, RESERVED_LOCK) == SQLITE_OK { Xsqlite3OsDelete(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0) if !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) { - pagerUnlockDb(tls, pPager, 1) + pagerUnlockDb(tls, pPager, SHARED_LOCK) } } Xsqlite3EndBenignMalloc(tls) @@ -34694,20 +34084,20 @@ func hasHotJournal(tls *libc.TLS, pPager uintptr, pExists uintptr) int32 { /* sq // If there is, then we consider this journal to be hot. If not, // it can be ignored. if !(jrnlOpen != 0) { - *(*int32)(unsafe.Pointer(bp + 12 /* f */)) = (0x00000001 | 0x00000800) + *(*int32)(unsafe.Pointer(bp + 12 /* f */)) = (SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_JOURNAL) rc = Xsqlite3OsOpen(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, (*Pager)(unsafe.Pointer(pPager)).Fjfd, *(*int32)(unsafe.Pointer(bp + 12 /* f */)), bp+12 /* &f */) } - if rc == 0 { + if rc == SQLITE_OK { *(*U8)(unsafe.Pointer(bp + 16 /* first */)) = U8(0) rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, bp+16 /* &first */, 1, int64(0)) - if rc == (10 | (int32(2) << 8)) { - rc = 0 + if rc == (SQLITE_IOERR | (int32(2) << 8)) { + rc = SQLITE_OK } if !(jrnlOpen != 0) { Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) } *(*int32)(unsafe.Pointer(pExists)) = (libc.Bool32(int32(*(*U8)(unsafe.Pointer(bp + 16 /* first */))) != 0)) - } else if rc == 14 { + } else if rc == SQLITE_CANTOPEN { // If we cannot open the rollback journal file in order to see if // it has a zero header, that might be due to an I/O error, or // it might be due to the race condition described above and in @@ -34717,7 +34107,7 @@ func hasHotJournal(tls *libc.TLS, pPager uintptr, pExists uintptr) int32 { /* sq // with it under an EXCLUSIVE lock where we do not need to // worry so much with race conditions. *(*int32)(unsafe.Pointer(pExists)) = 1 - rc = 0 + rc = SQLITE_OK } } } @@ -34781,20 +34171,20 @@ func Xsqlite3PagerSharedLock(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c // var dbFileVers [16]int8 at bp+12, 16 // var bHotJournal int32 at bp, 4 - rc = 0 // Return code + rc = SQLITE_OK // Return code // This routine is only called from b-tree and only when there are no // outstanding pages. This implies that the pager state should either // be OPEN or READER. READER is only possible if the pager is or was in // exclusive access mode. - if !(!((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0)) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 0)) { + if !(!((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0)) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN)) { goto __1 } *(*int32)(unsafe.Pointer(bp /* bHotJournal */)) = 1 // True if there exists a hot journal-file - rc = pager_wait_on_lock(tls, pPager, 1) - if !(rc != 0) { + rc = pager_wait_on_lock(tls, pPager, SHARED_LOCK) + if !(rc != SQLITE_OK) { goto __2 } @@ -34804,13 +34194,13 @@ __2: // If a journal file exists, and there is no RESERVED lock on the // database file, then it either needs to be played back or deleted. - if !(int32((*Pager)(unsafe.Pointer(pPager)).FeLock) <= 1) { + if !(int32((*Pager)(unsafe.Pointer(pPager)).FeLock) <= SHARED_LOCK) { goto __3 } rc = hasHotJournal(tls, pPager, bp /* &bHotJournal */) __3: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } goto failed @@ -34822,7 +34212,7 @@ __4: if !((*Pager)(unsafe.Pointer(pPager)).FreadOnly != 0) { goto __6 } - rc = (8 | (int32(3) << 8)) + rc = (SQLITE_READONLY | (int32(3) << 8)) goto failed __6: ; @@ -34841,8 +34231,8 @@ __6: // // Unless the pager is in locking_mode=exclusive mode, the lock is // downgraded to SHARED_LOCK before this function returns. - rc = pagerLockDb(tls, pPager, 4) - if !(rc != 0) { + rc = pagerLockDb(tls, pPager, EXCLUSIVE_LOCK) + if !(rc != SQLITE_OK) { goto __7 } goto failed @@ -34866,16 +34256,16 @@ __7: } pVfs = (*Pager)(unsafe.Pointer(pPager)).FpVfs // True if journal file exists rc = Xsqlite3OsAccess(tls, - pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0, bp+4 /* &bExists */) - if !((rc == 0) && (*(*int32)(unsafe.Pointer(bp + 4 /* bExists */)) != 0)) { + pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, SQLITE_ACCESS_EXISTS, bp+4 /* &bExists */) + if !((rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 4 /* bExists */)) != 0)) { goto __9 } *(*int32)(unsafe.Pointer(bp + 8 /* fout */)) = 0 - f = (0x00000002 | 0x00000800) + f = (SQLITE_OPEN_READWRITE | SQLITE_OPEN_MAIN_JOURNAL) rc = Xsqlite3OsOpen(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, (*Pager)(unsafe.Pointer(pPager)).Fjfd, f, bp+8 /* &fout */) - if !((rc == 0) && ((*(*int32)(unsafe.Pointer(bp + 8 /* fout */)) & 0x00000001) != 0)) { + if !((rc == SQLITE_OK) && ((*(*int32)(unsafe.Pointer(bp + 8 /* fout */)) & SQLITE_OPEN_READONLY) != 0)) { goto __10 } rc = Xsqlite3CantopenError(tls, 56964) @@ -34899,11 +34289,11 @@ __8: } rc = pagerSyncHotJournal(tls, pPager) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __13 } rc = pager_playback(tls, pPager, libc.BoolInt32(!((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0))) - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(0) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_OPEN __13: ; goto __12 @@ -34911,13 +34301,13 @@ __11: if !(!(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0)) { goto __14 } - pagerUnlockDb(tls, pPager, 1) + pagerUnlockDb(tls, pPager, SHARED_LOCK) __14: ; __12: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __15 } // This branch is taken if an error occurs while trying to open @@ -34948,10 +34338,10 @@ __5: } rc = Xsqlite3OsRead(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, bp+12 /* &dbFileVers */, int32(unsafe.Sizeof([16]int8{})), int64(24)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __17 } - if !(rc != (10 | (int32(2) << 8))) { + if !(rc != (SQLITE_IOERR | (int32(2) << 8))) { goto __18 } goto failed @@ -34998,7 +34388,7 @@ __1: __21: ; - if !(((int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) == 0) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 0)) && (rc == 0)) { + if !(((int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) == 0) && (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN)) && (rc == SQLITE_OK)) { goto __22 } rc = pagerPagecount(tls, pPager, (pPager + 28 /* &.dbSize */)) @@ -35006,7 +34396,7 @@ __22: ; failed: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __23 } @@ -35014,7 +34404,7 @@ failed: goto __24 __23: - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(1) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_READER (*Pager)(unsafe.Pointer(pPager)).FhasHeldSharedLock = U8(1) __24: ; @@ -35097,7 +34487,7 @@ func getPageNormal(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, fla var pPg uintptr var noContent U8 // True if PAGER_GET_NOCONTENT is set // var pBase uintptr at bp, 8 - rc = 0 + rc = SQLITE_OK if !(pgno == Pgno(0)) { goto __1 @@ -35111,7 +34501,7 @@ __1: } pPg = uintptr(0) rc = Xsqlite3PcacheFetchStress(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, pgno, bp /* &pBase */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __3 } goto pager_acquire_err @@ -35120,7 +34510,7 @@ __3: if !(*(*uintptr)(unsafe.Pointer(bp /* pBase */)) == uintptr(0)) { goto __4 } - rc = 7 + rc = SQLITE_NOMEM goto pager_acquire_err __4: ; @@ -35128,15 +34518,15 @@ __2: ; pPg = libc.AssignPtrUintptr(ppPage, Xsqlite3PcacheFetchFinish(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache, pgno, *(*uintptr)(unsafe.Pointer(bp /* pBase */)))) - noContent = (U8(libc.Bool32((flags & 0x01) != 0))) + noContent = (U8(libc.Bool32((flags & PAGER_GET_NOCONTENT) != 0))) if !(((*PgHdr)(unsafe.Pointer(pPg)).FpPager != 0) && !(noContent != 0)) { goto __5 } // In this case the pcache already contains an initialized copy of // the page. Return without further ado. - *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(0)*4))++ - return 0 + *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */)))++ + return SQLITE_OK goto __6 __5: @@ -35161,7 +34551,7 @@ __7: if !(pgno > (*Pager)(unsafe.Pointer(pPager)).FmxPgno) { goto __10 } - rc = 13 + rc = SQLITE_FULL goto pager_acquire_err __10: ; @@ -35191,9 +34581,9 @@ __11: goto __9 __8: ; - *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(1)*4))++ + *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + 1*4))++ rc = readDbPage(tls, pPg) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __13 } goto pager_acquire_err @@ -35204,7 +34594,7 @@ __9: __6: ; - return 0 + return SQLITE_OK pager_acquire_err: ; @@ -35224,7 +34614,7 @@ func getPageMMap(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags bp := tls.Alloc(24) defer tls.Free(24) - var rc int32 = 0 + var rc int32 = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */)) = uintptr(0) *(*U32)(unsafe.Pointer(bp /* iFrame */)) = U32(0) // Frame to read from WAL file @@ -35233,7 +34623,7 @@ func getPageMMap(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags // flag was specified by the caller. And so long as the db is not a // temporary or in-memory database. var bMmapOk int32 = (libc.Bool32((pgno > Pgno(1)) && - ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 1) || ((flags & 0x02) != 0)))) + ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_READER) || ((flags & PAGER_GET_READONLY) != 0)))) // Optimization note: Adding the "pgno<=1" term before "pgno==0" here // allows the compiler optimizer to reuse the results of the "pgno>1" @@ -35245,7 +34635,7 @@ func getPageMMap(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags if (bMmapOk != 0) && ((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0)) { rc = Xsqlite3WalFindFrame(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, pgno, bp /* &iFrame */) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0) return rc } @@ -35254,8 +34644,8 @@ func getPageMMap(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags *(*uintptr)(unsafe.Pointer(bp + 8 /* pData */)) = uintptr(0) rc = Xsqlite3OsFetch(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, ((I64(pgno - Pgno(1))) * I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)), (*Pager)(unsafe.Pointer(pPager)).FpageSize, bp+8 /* &pData */) - if (rc == 0) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* pData */)) != 0) { - if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) > 1) || ((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0) { + if (rc == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* pData */)) != 0) { + if (int32((*Pager)(unsafe.Pointer(pPager)).FeState) > PAGER_READER) || ((*Pager)(unsafe.Pointer(pPager)).FtempFile != 0) { *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */)) = Xsqlite3PagerLookup(tls, pPager, pgno) } if *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */)) == uintptr(0) { @@ -35266,10 +34656,10 @@ func getPageMMap(tls *libc.TLS, pPager uintptr, pgno Pgno, ppPage uintptr, flags if *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */)) != 0 { *(*uintptr)(unsafe.Pointer(ppPage)) = *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */)) - return 0 + return SQLITE_OK } } - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0) return rc } @@ -35323,7 +34713,7 @@ func Xsqlite3PagerLookup(tls *libc.TLS, pPager uintptr, pgno Pgno) uintptr { /* // pages reaches zero it drops the database lock. func Xsqlite3PagerUnrefNotNull(tls *libc.TLS, pPg uintptr) { /* sqlite3.c:57391:21: */ - if (int32((*DbPage)(unsafe.Pointer(pPg)).Fflags) & 0x020) != 0 { + if (int32((*DbPage)(unsafe.Pointer(pPg)).Fflags) & PGHDR_MMAP) != 0 { // Page1 is never memory mapped pagerReleaseMapPage(tls, pPg) } else { @@ -35369,7 +34759,7 @@ func Xsqlite3PagerUnrefPageOne(tls *libc.TLS, pPg uintptr) { /* sqlite3.c:57406: // SQLITE_NOMEM if the attempt to allocate Pager.pInJournal fails, or // an IO error code if opening or writing the journal file fails. func pager_open_journal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:57438:12: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var pVfs uintptr = (*Pager)(unsafe.Pointer(pPager)).FpVfs // Local cache of vfs pointer // If already in the error state, this function is a no-op. But on @@ -35379,32 +34769,32 @@ func pager_open_journal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5743 return (*Pager)(unsafe.Pointer(pPager)).FerrCode } - if !((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0)) && (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != 2) { + if !((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0)) && (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) != PAGER_JOURNALMODE_OFF) { (*Pager)(unsafe.Pointer(pPager)).FpInJournal = Xsqlite3BitvecCreate(tls, (*Pager)(unsafe.Pointer(pPager)).FdbSize) if (*Pager)(unsafe.Pointer(pPager)).FpInJournal == uintptr(0) { - return 7 + return SQLITE_NOMEM } // Open the journal file if it is not already open. if !((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) { - if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 4 { + if int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_MEMORY { Xsqlite3MemJournalOpen(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) } else { - var flags int32 = (0x00000002 | 0x00000004) + var flags int32 = (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) var nSpill int32 if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 { - flags = flags | (0x00000008 | 0x00001000) + flags = flags | (SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_TEMP_JOURNAL) nSpill = Xsqlite3Config.FnStmtSpill } else { - flags = flags | (0x00000800) + flags = flags | (SQLITE_OPEN_MAIN_JOURNAL) nSpill = jrnlBufferSize(tls, pPager) } // Verify that the database still has the same name as it did when // it was originally opened. rc = databaseIsUnmoved(tls, pPager) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3JournalOpen(tls, pVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, (*Pager)(unsafe.Pointer(pPager)).Fjfd, flags, nSpill) } @@ -35414,7 +34804,7 @@ func pager_open_journal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5743 // Write the first journal header to the journal file and open // the sub-journal if necessary. - if rc == 0 { + if rc == SQLITE_OK { // TODO: Check if all of these are really required. (*Pager)(unsafe.Pointer(pPager)).FnRec = 0 (*Pager)(unsafe.Pointer(pPager)).FjournalOff = int64(0) @@ -35424,12 +34814,12 @@ func pager_open_journal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5743 } } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3BitvecDestroy(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal) (*Pager)(unsafe.Pointer(pPager)).FpInJournal = uintptr(0) } else { - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(3) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_WRITER_CACHEMOD } return rc @@ -35451,7 +34841,7 @@ func pager_open_journal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5743 // sub-journal is implemented in-memory if pPager is an in-memory database, // or using a temporary file otherwise. func Xsqlite3PagerBegin(tls *libc.TLS, pPager uintptr, exFlag int32, subjInMemory int32) int32 { /* sqlite3.c:57527:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 { return (*Pager)(unsafe.Pointer(pPager)).FerrCode @@ -35459,14 +34849,14 @@ func Xsqlite3PagerBegin(tls *libc.TLS, pPager uintptr, exFlag int32, subjInMemor (*Pager)(unsafe.Pointer(pPager)).FsubjInMemory = U8(subjInMemory) - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 1 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_READER { if (*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0) { // If the pager is configured to use locking_mode=exclusive, and an // exclusive lock on the database is not already held, obtain it now. if ((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0) && (Xsqlite3WalExclusiveMode(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, -1) != 0) { - rc = pagerLockDb(tls, pPager, 4) - if rc != 0 { + rc = pagerLockDb(tls, pPager, EXCLUSIVE_LOCK) + if rc != SQLITE_OK { return rc } Xsqlite3WalExclusiveMode(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, 1) @@ -35482,13 +34872,13 @@ func Xsqlite3PagerBegin(tls *libc.TLS, pPager uintptr, exFlag int32, subjInMemor // is true, then immediately upgrade this to an EXCLUSIVE lock. The // busy-handler callback can be used when upgrading to the EXCLUSIVE // lock, but not when obtaining the RESERVED lock. - rc = pagerLockDb(tls, pPager, 2) - if (rc == 0) && (exFlag != 0) { - rc = pager_wait_on_lock(tls, pPager, 4) + rc = pagerLockDb(tls, pPager, RESERVED_LOCK) + if (rc == SQLITE_OK) && (exFlag != 0) { + rc = pager_wait_on_lock(tls, pPager, EXCLUSIVE_LOCK) } } - if rc == 0 { + if rc == SQLITE_OK { // Change to WRITER_LOCKED state. // // WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD @@ -35497,7 +34887,7 @@ func Xsqlite3PagerBegin(tls *libc.TLS, pPager uintptr, exFlag int32, subjInMemor // transactions may copy data from the sub-journal into the database // file as well as into the page cache. Which would be incorrect in // WAL mode. - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(2) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_WRITER_LOCKED (*Pager)(unsafe.Pointer(pPager)).FdbHintSize = (*Pager)(unsafe.Pointer(pPager)).FdbSize (*Pager)(unsafe.Pointer(pPager)).FdbFileSize = (*Pager)(unsafe.Pointer(pPager)).FdbSize (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize = (*Pager)(unsafe.Pointer(pPager)).FdbSize @@ -35530,18 +34920,18 @@ func pagerAddPageToRollbackJournal(tls *libc.TLS, pPg uintptr) int32 { /* sqlite // playback_one_page() will think that the page needs to be restored // in the database file. And if an IO error occurs while doing so, // then corruption may follow. - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((0x008)) + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((PGHDR_NEED_SYNC)) rc = write32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, iOff, (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) - if rc != 0 { + if rc != SQLITE_OK { return rc } rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, pData2, (*Pager)(unsafe.Pointer(pPager)).FpageSize, (iOff + int64(4))) - if rc != 0 { + if rc != SQLITE_OK { return rc } rc = write32bits(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd, ((iOff + I64((*Pager)(unsafe.Pointer(pPager)).FpageSize)) + int64(4)), cksum) - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -35564,7 +34954,7 @@ func pagerAddPageToRollbackJournal(tls *libc.TLS, pPg uintptr) int32 { /* sqlite // of any open savepoints as appropriate. func pager_write(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:57653:12: */ var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager - var rc int32 = 0 + var rc int32 = SQLITE_OK // This routine is not called unless a write-transaction has already // been started. The journal file may or may not be open at this point. @@ -35578,9 +34968,9 @@ func pager_write(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:57653:12: */ // Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then // an error might occur and the pager would end up in WRITER_LOCKED state // with pages marked as dirty in the cache. - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 2 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_WRITER_LOCKED { rc = pager_open_journal(tls, pPager) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -35597,12 +34987,12 @@ func pager_write(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:57653:12: */ if (*PgHdr)(unsafe.Pointer(pPg)).Fpgno <= (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize { rc = pagerAddPageToRollbackJournal(tls, pPg) - if rc != 0 { + if rc != SQLITE_OK { return rc } } else { - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) != 4 { - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((0x008)) + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) != PAGER_WRITER_DBMOD { + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((PGHDR_NEED_SYNC)) } } @@ -35612,7 +35002,7 @@ func pager_write(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:57653:12: */ // and before writing the page into the rollback journal. Wait until now, // after the page has been successfully journalled, before setting the // PGHDR_WRITEABLE bit that indicates that the page can be safely modified. - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((0x004)) + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((PGHDR_WRITEABLE)) // If the statement journal is open and the page is not in it, // then write the page into the statement journal. @@ -35640,7 +35030,7 @@ func pagerWriteLargeSector(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5774 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var nPageCount Pgno // Total number of pages in database file var pg1 Pgno // First page of the sector pPg is located on. var nPage int32 = 0 // Number of pages starting at pg1 to journal @@ -35653,7 +35043,7 @@ func pagerWriteLargeSector(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5774 // a journal header to be written between the pages journaled by // this function. - *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) |= U8((0x04)) + *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) |= U8((SPILLFLAG_NOSYNC)) // This trick assumes that both the page-size and sector-size are // an integer power of 2. It sets variable pg1 to the identifier @@ -35669,23 +35059,23 @@ func pagerWriteLargeSector(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5774 nPage = int32(nPagePerSector) } - for ii = 0; (ii < nPage) && (rc == 0); ii++ { + for ii = 0; (ii < nPage) && (rc == SQLITE_OK); ii++ { var pg Pgno = (pg1 + Pgno(ii)) // var pPage uintptr at bp, 8 if (pg == (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) || !(Xsqlite3BitvecTest(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal, pg) != 0) { if pg != (Pgno((Xsqlite3PendingByte / ((*Pager)(unsafe.Pointer(pPager)).FpageSize)) + 1)) { rc = Xsqlite3PagerGet(tls, pPager, pg, bp /* &pPage */, 0) - if rc == 0 { + if rc == SQLITE_OK { rc = pager_write(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */))) - if (int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).Fflags) & 0x008) != 0 { + if (int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).Fflags) & PGHDR_NEED_SYNC) != 0 { needSync = 1 } Xsqlite3PagerUnrefNotNull(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */))) } } } else if (libc.AssignPtrUintptr(bp /* pPage */, Xsqlite3PagerLookup(tls, pPager, pg))) != uintptr(0) { - if (int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).Fflags) & 0x008) != 0 { + if (int32((*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).Fflags) & PGHDR_NEED_SYNC) != 0 { needSync = 1 } Xsqlite3PagerUnrefNotNull(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */))) @@ -35697,18 +35087,18 @@ func pagerWriteLargeSector(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5774 // writing to any of these nPage pages may damage the others, the // journal file must contain sync()ed copies of all of them // before any of them can be written out to the database file. - if (rc == 0) && (needSync != 0) { + if (rc == SQLITE_OK) && (needSync != 0) { for ii = 0; ii < nPage; ii++ { var pPage uintptr = Xsqlite3PagerLookup(tls, pPager, (pg1 + Pgno(ii))) if pPage != 0 { - *(*U16)(unsafe.Pointer(pPage + 52 /* &.flags */)) |= U16((0x008)) + *(*U16)(unsafe.Pointer(pPage + 52 /* &.flags */)) |= U16((PGHDR_NEED_SYNC)) Xsqlite3PagerUnrefNotNull(tls, pPage) } } } - *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) &= libc.Uint8FromInt32((^libc.Int32(0x04))) + *(*U8)(unsafe.Pointer(pPager + 24 /* &.doNotSpill */)) &= libc.Uint8FromInt32((libc.CplInt32(SPILLFLAG_NOSYNC))) return rc } @@ -35727,11 +35117,11 @@ func pagerWriteLargeSector(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:5774 func Xsqlite3PagerWrite(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:57839:20: */ var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager - if ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & 0x004) != 0) && ((*Pager)(unsafe.Pointer(pPager)).FdbSize >= (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) { + if ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & PGHDR_WRITEABLE) != 0) && ((*Pager)(unsafe.Pointer(pPager)).FdbSize >= (*PgHdr)(unsafe.Pointer(pPg)).Fpgno) { if (*Pager)(unsafe.Pointer(pPager)).FnSavepoint != 0 { return subjournalPageIfRequired(tls, pPg) } - return 0 + return SQLITE_OK } else if (*Pager)(unsafe.Pointer(pPager)).FerrCode != 0 { return (*Pager)(unsafe.Pointer(pPager)).FerrCode } else if (*Pager)(unsafe.Pointer(pPager)).FsectorSize > U32((*Pager)(unsafe.Pointer(pPager)).FpageSize) { @@ -35767,10 +35157,10 @@ func Xsqlite3PagerWrite(tls *libc.TLS, pPg uintptr) int32 { /* sqlite3.c:57839:2 // current transaction is rolled back. func Xsqlite3PagerDontWrite(tls *libc.TLS, pPg uintptr) { /* sqlite3.c:57888:21: */ var pPager uintptr = (*PgHdr)(unsafe.Pointer(pPg)).FpPager - if (!(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) && ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & 0x002) != 0)) && ((*Pager)(unsafe.Pointer(pPager)).FnSavepoint == 0) { + if (!(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) && ((int32((*PgHdr)(unsafe.Pointer(pPg)).Fflags) & PGHDR_DIRTY) != 0)) && ((*Pager)(unsafe.Pointer(pPager)).FnSavepoint == 0) { - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((0x010)) - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x004))) + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((PGHDR_DONT_WRITE)) + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(PGHDR_WRITEABLE))) } } @@ -35799,7 +35189,7 @@ func pager_incr_changecounter(tls *libc.TLS, pPager uintptr, isDirectMode int32) bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK // Declare and initialize constant integer 'isDirect'. If the // atomic-write optimization is enabled in this build, then isDirect @@ -35824,11 +35214,11 @@ func pager_incr_changecounter(tls *libc.TLS, pPager uintptr, isDirectMode int32) // operating in direct-mode, make page 1 writable. When not in // direct mode, page 1 is always held in cache and hence the PagerGet() // above is always successful - hence the ALWAYS on rc==SQLITE_OK. - if !(0 != 0) && (rc == 0) { + if !(0 != 0) && (rc == SQLITE_OK) { rc = Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp /* pPgHdr */))) } - if rc == 0 { + if rc == SQLITE_OK { // Actually do the update of the change counter pager_write_changecounter(tls, *(*uintptr)(unsafe.Pointer(bp /* pPgHdr */))) @@ -35837,15 +35227,15 @@ func pager_incr_changecounter(tls *libc.TLS, pPager uintptr, isDirectMode int32) var zBuf uintptr zBuf = (*PgHdr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPgHdr */)))).FpData - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3OsWrite(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, zBuf, (*Pager)(unsafe.Pointer(pPager)).FpageSize, int64(0)) - *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(2)*4))++ + *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + 2*4))++ } - if rc == 0 { + if rc == SQLITE_OK { // Update the pager's copy of the change-counter. Otherwise, the // next time a read transaction is opened the cache will be // flushed (as the change-counter values will not match). - var pCopy uintptr = ((zBuf) + uintptr(24)) + var pCopy uintptr = ((zBuf) + 24) libc.Xmemcpy(tls, (pPager + 136 /* &.dbFileVers */), pCopy, uint64(unsafe.Sizeof([16]int8{}))) (*Pager)(unsafe.Pointer(pPager)).FchangeCountDone = U8(1) } @@ -35866,13 +35256,13 @@ func pager_incr_changecounter(tls *libc.TLS, pPager uintptr, isDirectMode int32) // If successful, or if called on a pager for which it is a no-op, this // function returns SQLITE_OK. Otherwise, an IO error code is returned. func Xsqlite3PagerSync(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 { /* sqlite3.c:58005:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pArg uintptr = zSuper - rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, 21, pArg) - if rc == 12 { - rc = 0 + rc = Xsqlite3OsFileControl(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, SQLITE_FCNTL_SYNC, pArg) + if rc == SQLITE_NOTFOUND { + rc = SQLITE_OK } - if (rc == 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { + if (rc == SQLITE_OK) && !(int32((*Pager)(unsafe.Pointer(pPager)).FnoSync) != 0) { rc = Xsqlite3OsSync(tls, (*Pager)(unsafe.Pointer(pPager)).Ffd, int32((*Pager)(unsafe.Pointer(pPager)).FsyncFlags)) } @@ -35891,10 +35281,10 @@ func Xsqlite3PagerSync(tls *libc.TLS, pPager uintptr, zSuper uintptr) int32 { /* func Xsqlite3PagerExclusiveLock(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:58028:20: */ var rc int32 = (*Pager)(unsafe.Pointer(pPager)).FerrCode - if rc == 0 { + if rc == SQLITE_OK { if 0 == (libc.Bool32((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0))) { - rc = pager_wait_on_lock(tls, pPager, 4) + rc = pager_wait_on_lock(tls, pPager, EXCLUSIVE_LOCK) } } return rc @@ -35933,7 +35323,7 @@ func Xsqlite3PagerCommitPhaseOne(tls *libc.TLS, pPager uintptr, zSuper uintptr, var nNew Pgno var pList uintptr - rc = 0 // Return code + rc = SQLITE_OK // Return code // If a prior error occurred, report that error again. if !((*Pager)(unsafe.Pointer(pPager)).FerrCode != 0) { @@ -35947,15 +35337,15 @@ __1: if !(Xsqlite3FaultSim(tls, 400) != 0) { goto __2 } - return 10 + return SQLITE_IOERR __2: ; // If no database changes have been made, return early. - if !(int32((*Pager)(unsafe.Pointer(pPager)).FeState) < 3) { + if !(int32((*Pager)(unsafe.Pointer(pPager)).FeState) < PAGER_WRITER_CACHEMOD) { goto __3 } - return 0 + return SQLITE_OK __3: ; @@ -35991,7 +35381,7 @@ __8: __9: ; Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp /* pPageOne */))) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __10 } Xsqlite3PcacheCleanAll(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) @@ -36004,7 +35394,7 @@ __6: // is enabled. rc = pager_incr_changecounter(tls, pPager, 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __11 } goto commit_phase_one_exit @@ -36015,7 +35405,7 @@ __11: // super-journal file name has already been written to the journal file, // or if zSuper is NULL (no super-journal), then this call is a no-op. rc = writeSuperJournal(tls, pPager, zSuper) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } goto commit_phase_one_exit @@ -36033,7 +35423,7 @@ __12: // not the case. In this case it is likely enough that the redundant // xSync() call will be changed to a no-op by the OS anyhow. rc = syncJournal(tls, pPager, 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __13 } goto commit_phase_one_exit @@ -36042,13 +35432,13 @@ __13: pList = Xsqlite3PcacheDirtyList(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) - if !(0 == 0) { + if !(BBatch == 0) { goto __14 } rc = pager_write_pagelist(tls, pPager, pList) __14: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __15 } @@ -36069,7 +35459,7 @@ __15: nNew = ((*Pager)(unsafe.Pointer(pPager)).FdbSize - (Pgno(libc.Bool32((*Pager)(unsafe.Pointer(pPager)).FdbSize == (Pgno((Xsqlite3PendingByte / ((*Pager)(unsafe.Pointer(pPager)).FpageSize)) + 1)))))) rc = pager_truncate(tls, pPager, nNew) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __17 } goto commit_phase_one_exit @@ -36092,10 +35482,10 @@ __5: ; commit_phase_one_exit: - if !((rc == 0) && !((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0))) { + if !((rc == SQLITE_OK) && !((*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0))) { goto __19 } - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(5) + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_WRITER_FINISHED __19: ; return rc @@ -36115,7 +35505,7 @@ __19: // If an error occurs, an IO error code is returned and the pager // moves into the error state. Otherwise, SQLITE_OK is returned. func Xsqlite3PagerCommitPhaseTwo(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:58300:20: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code // This routine should not be called if a prior error has occurred. // But if (due to a coding error elsewhere in the system) it does get @@ -36135,12 +35525,12 @@ func Xsqlite3PagerCommitPhaseTwo(tls *libc.TLS, pPager uintptr) int32 { /* sqlit // to the database file. So there is no need to zero the journal // header. Since the pager is in exclusive mode, there is no need // to drop any locks either. - if ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 2) && + if ((int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_WRITER_LOCKED) && ((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode != 0)) && - (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == 1) { + (int32((*Pager)(unsafe.Pointer(pPager)).FjournalMode) == PAGER_JOURNALMODE_PERSIST) { - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(1) - return 0 + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_READER + return SQLITE_OK } rc = pager_end_transaction(tls, pPager, int32((*Pager)(unsafe.Pointer(pPager)).FsetSuper), 1) @@ -36172,35 +35562,35 @@ func Xsqlite3PagerCommitPhaseTwo(tls *libc.TLS, pPager uintptr) int32 { /* sqlit // their pre-transaction state by re-reading data from the database or // WAL files. The WAL transaction is then closed. func Xsqlite3PagerRollback(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:58366:20: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code // PagerRollback() is a no-op if called in READER or OPEN state. If // the pager is already in the ERROR state, the rollback is not // attempted here. Instead, the error code is returned to the caller. - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 6 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_ERROR { return (*Pager)(unsafe.Pointer(pPager)).FerrCode } - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) <= 1 { - return 0 + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) <= PAGER_READER { + return SQLITE_OK } if (*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0) { var rc2 int32 - rc = Xsqlite3PagerSavepoint(tls, pPager, 2, -1) + rc = Xsqlite3PagerSavepoint(tls, pPager, SAVEPOINT_ROLLBACK, -1) rc2 = pager_end_transaction(tls, pPager, int32((*Pager)(unsafe.Pointer(pPager)).FsetSuper), 0) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } - } else if !((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 2) { + } else if !((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) || (int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_WRITER_LOCKED) { var eState int32 = int32((*Pager)(unsafe.Pointer(pPager)).FeState) rc = pager_end_transaction(tls, pPager, 0, 0) - if !(int32((*Pager)(unsafe.Pointer(pPager)).FmemDb) != 0) && (eState > 2) { + if !(int32((*Pager)(unsafe.Pointer(pPager)).FmemDb) != 0) && (eState > PAGER_WRITER_LOCKED) { // This can happen using journal_mode=off. Move the pager to the error // state to indicate that the contents of the cache may not be trusted. // Any active readers will get SQLITE_ABORT. - (*Pager)(unsafe.Pointer(pPager)).FerrCode = 4 - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(6) + (*Pager)(unsafe.Pointer(pPager)).FerrCode = SQLITE_ABORT + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_ERROR setGetterMethod(tls, pPager) return rc } @@ -36240,18 +35630,18 @@ func Xsqlite3PagerStats(tls *libc.TLS, pPager uintptr) uintptr { /* sqlite3.c:58 a1[1] = Xsqlite3PcachePagecount(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) a1[2] = Xsqlite3PcacheGetCachesize(tls, (*Pager)(unsafe.Pointer(pPager)).FpPCache) a1[3] = func() int32 { - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 0 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN { return -1 } return int32((*Pager)(unsafe.Pointer(pPager)).FdbSize) }() a1[4] = int32((*Pager)(unsafe.Pointer(pPager)).FeState) a1[5] = (*Pager)(unsafe.Pointer(pPager)).FerrCode - a1[6] = *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(0)*4)) - a1[7] = *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(1)*4)) + a1[6] = *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */))) + a1[7] = *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + 1*4)) a1[8] = 0 // Used to be pPager->nOvfl a1[9] = (*Pager)(unsafe.Pointer(pPager)).FnRead - a1[10] = *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(2)*4)) + a1[10] = *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + 2*4)) return uintptr(unsafe.Pointer(&a1)) } @@ -36268,7 +35658,7 @@ var a1 [11]int32 /* sqlite3.c:58453:14: */ // returning. func Xsqlite3PagerCacheStat(tls *libc.TLS, pPager uintptr, eStat int32, reset int32, pnVal uintptr) { /* sqlite3.c:58480:21: */ - eStat = eStat - (7) + eStat = eStat - (SQLITE_DBSTATUS_CACHE_HIT) *(*int32)(unsafe.Pointer(pnVal)) += (*(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(eStat)*4))) if reset != 0 { *(*int32)(unsafe.Pointer((pPager + 240 /* &.aStat */) + uintptr(eStat)*4)) = 0 @@ -36289,7 +35679,7 @@ func Xsqlite3PagerIsMemdb(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:58 // occurs while opening the sub-journal file, then an IO error code is // returned. Otherwise, SQLITE_OK. func pagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) int32 { /* sqlite3.c:58517:28: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var nCurrent int32 = (*Pager)(unsafe.Pointer(pPager)).FnSavepoint // Current number of savepoints var ii int32 // Iterator variable var aNew uintptr // New Pager.aSavepoint array @@ -36300,7 +35690,7 @@ func pagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) int32 { aNew = Xsqlite3Realloc(tls, (*Pager)(unsafe.Pointer(pPager)).FaSavepoint, (uint64(uint64(unsafe.Sizeof(PagerSavepoint{})) * uint64(nSavepoint)))) if !(aNew != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, (aNew + uintptr(nCurrent)*48), 0, ((uint64(nSavepoint - nCurrent)) * uint64(unsafe.Sizeof(PagerSavepoint{})))) (*Pager)(unsafe.Pointer(pPager)).FaSavepoint = aNew @@ -36316,7 +35706,7 @@ func pagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) int32 { (*PagerSavepoint)(unsafe.Pointer(aNew + uintptr(ii)*48)).FiSubRec = (*Pager)(unsafe.Pointer(pPager)).FnSubRec (*PagerSavepoint)(unsafe.Pointer(aNew + uintptr(ii)*48)).FpInSavepoint = Xsqlite3BitvecCreate(tls, (*Pager)(unsafe.Pointer(pPager)).FdbSize) if !(int32((*PagerSavepoint)(unsafe.Pointer(aNew+uintptr(ii)*48)).FpInSavepoint) != 0) { - return 7 + return SQLITE_NOMEM } if (*Pager)(unsafe.Pointer((pPager))).FpWal != uintptr(0) { Xsqlite3WalSavepoint(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, aNew+uintptr(ii)*48+32 /* &.aWalData */) @@ -36332,7 +35722,7 @@ func Xsqlite3PagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) if (nSavepoint > (*Pager)(unsafe.Pointer(pPager)).FnSavepoint) && ((*Pager)(unsafe.Pointer(pPager)).FuseJournal != 0) { return pagerOpenSavepoint(tls, pPager, nSavepoint) } else { - return 0 + return SQLITE_OK } return int32(0) } @@ -36368,7 +35758,7 @@ func Xsqlite3PagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) func Xsqlite3PagerSavepoint(tls *libc.TLS, pPager uintptr, op int32, iSavepoint int32) int32 { /* sqlite3.c:58604:20: */ var rc int32 = (*Pager)(unsafe.Pointer(pPager)).FerrCode - if (rc == 0) && (iSavepoint < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint) { + if (rc == SQLITE_OK) && (iSavepoint < (*Pager)(unsafe.Pointer(pPager)).FnSavepoint) { var ii int32 // Iterator variable var nNew int32 // Number of remaining savepoints after this op. @@ -36376,7 +35766,7 @@ func Xsqlite3PagerSavepoint(tls *libc.TLS, pPager uintptr, op int32, iSavepoint // operation. Store this value in nNew. Then free resources associated // with any savepoints that are destroyed by this operation. nNew = (iSavepoint + (func() int32 { - if op == 1 { + if op == SAVEPOINT_RELEASE { return 0 } return 1 @@ -36388,7 +35778,7 @@ func Xsqlite3PagerSavepoint(tls *libc.TLS, pPager uintptr, op int32, iSavepoint // If this is a release of the outermost savepoint, truncate // the sub-journal to zero bytes in size. - if op == 1 { + if op == SAVEPOINT_RELEASE { if (nNew == 0) && ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fsjfd))).FpMethods != uintptr(0)) { // Only truncate if it is an in-memory sub-journal. if Xsqlite3JournalIsInMemory(tls, (*Pager)(unsafe.Pointer(pPager)).Fsjfd) != 0 { @@ -36426,7 +35816,7 @@ func Xsqlite3PagerSavepoint(tls *libc.TLS, pPager uintptr, op int32, iSavepoint // sqlite3_uri_parameter() and sqlite3_filename_database() and friends. func Xsqlite3PagerFilename(tls *libc.TLS, pPager uintptr, nullIfMemDb int32) uintptr { /* sqlite3.c:58683:27: */ if (nullIfMemDb != 0) && ((*Pager)(unsafe.Pointer(pPager)).FmemDb != 0) { - return (uintptr(unsafe.Pointer(&zFake)) + uintptr(4)) + return (uintptr(unsafe.Pointer(&zFake)) + 4) } return (*Pager)(unsafe.Pointer(pPager)).FzFilename } @@ -36518,8 +35908,8 @@ func Xsqlite3PagerMovepage(tls *libc.TLS, pPager uintptr, pPg uintptr, pgno Pgno // subjournalPage() may need to allocate space to store pPg->pgno into // one or more savepoint bitvecs. This is the reason this function // may return SQLITE_NOMEM. - if ((int32((*DbPage)(unsafe.Pointer(pPg)).Fflags) & 0x002) != 0) && - (0 != (libc.AssignInt32(&rc, subjournalPageIfRequired(tls, pPg)))) { + if ((int32((*DbPage)(unsafe.Pointer(pPg)).Fflags) & PGHDR_DIRTY) != 0) && + (SQLITE_OK != (libc.AssignInt32(&rc, subjournalPageIfRequired(tls, pPg)))) { return rc } @@ -36529,7 +35919,7 @@ func Xsqlite3PagerMovepage(tls *libc.TLS, pPager uintptr, pPg uintptr, pgno Pgno // If the isCommit flag is set, there is no need to remember that // the journal needs to be sync()ed before database page pPg->pgno // can be written to. The caller has already promised not to write to it. - if ((int32((*DbPage)(unsafe.Pointer(pPg)).Fflags) & 0x008) != 0) && !(isCommit != 0) { + if ((int32((*DbPage)(unsafe.Pointer(pPg)).Fflags) & PGHDR_NEED_SYNC) != 0) && !(isCommit != 0) { needSyncPgno = (*DbPage)(unsafe.Pointer(pPg)).Fpgno } @@ -36538,7 +35928,7 @@ func Xsqlite3PagerMovepage(tls *libc.TLS, pPager uintptr, pPg uintptr, pgno Pgno // from its hash chain. Also, if the PGHDR_NEED_SYNC flag was set for // page pgno before the 'move' operation, it needs to be retained // for the page moved there. - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x008))) + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(PGHDR_NEED_SYNC))) pPgOld = Xsqlite3PagerLookup(tls, pPager, pgno) if pPgOld != 0 { @@ -36546,7 +35936,7 @@ func Xsqlite3PagerMovepage(tls *libc.TLS, pPager uintptr, pPg uintptr, pgno Pgno Xsqlite3PagerUnrefNotNull(tls, pPgOld) return Xsqlite3CorruptError(tls, 58823) } - *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((int32((*PgHdr)(unsafe.Pointer(pPgOld)).Fflags) & 0x008)) + *(*U16)(unsafe.Pointer(pPg + 52 /* &.flags */)) |= U16((int32((*PgHdr)(unsafe.Pointer(pPgOld)).Fflags) & PGHDR_NEED_SYNC)) if (*Pager)(unsafe.Pointer(pPager)).FtempFile != 0 { // Do not discard pages from an in-memory database since we might // need to rollback later. Just move the page out of the way. @@ -36585,19 +35975,19 @@ func Xsqlite3PagerMovepage(tls *libc.TLS, pPager uintptr, pPg uintptr, pgno Pgno // var pPgHdr uintptr at bp, 8 rc = Xsqlite3PagerGet(tls, pPager, needSyncPgno, bp /* &pPgHdr */, 0) - if rc != 0 { + if rc != SQLITE_OK { if needSyncPgno <= (*Pager)(unsafe.Pointer(pPager)).FdbOrigSize { Xsqlite3BitvecClear(tls, (*Pager)(unsafe.Pointer(pPager)).FpInJournal, needSyncPgno, (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace) } return rc } - *(*U16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPgHdr */)) + 52 /* &.flags */)) |= U16((0x008)) + *(*U16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPgHdr */)) + 52 /* &.flags */)) |= U16((PGHDR_NEED_SYNC)) Xsqlite3PcacheMakeDirty(tls, *(*uintptr)(unsafe.Pointer(bp /* pPgHdr */))) Xsqlite3PagerUnrefNotNull(tls, *(*uintptr)(unsafe.Pointer(bp /* pPgHdr */))) } - return 0 + return SQLITE_OK } // The page handle passed as the first argument refers to a dirty page @@ -36669,7 +36059,7 @@ func Xsqlite3PagerSetJournalMode(tls *libc.TLS, pPager uintptr, eMode int32) int // anything other than MEMORY or OFF if (*Pager)(unsafe.Pointer(pPager)).FmemDb != 0 { - if (eMode != 4) && (eMode != 2) { + if (eMode != PAGER_JOURNALMODE_MEMORY) && (eMode != PAGER_JOURNALMODE_OFF) { eMode = int32(eOld) } } @@ -36694,30 +36084,30 @@ func Xsqlite3PagerSetJournalMode(tls *libc.TLS, pPager uintptr, eMode int32) int // database file. This ensures that the journal file is not deleted // while it is in use by some other client. Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) - if int32((*Pager)(unsafe.Pointer(pPager)).FeLock) >= 2 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeLock) >= RESERVED_LOCK { Xsqlite3OsDelete(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0) } else { - var rc int32 = 0 + var rc int32 = SQLITE_OK var state int32 = int32((*Pager)(unsafe.Pointer(pPager)).FeState) - if state == 0 { + if state == PAGER_OPEN { rc = Xsqlite3PagerSharedLock(tls, pPager) } - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == 1 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) == PAGER_READER { - rc = pagerLockDb(tls, pPager, 2) + rc = pagerLockDb(tls, pPager, RESERVED_LOCK) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3OsDelete(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzJournal, 0) } - if (rc == 0) && (state == 1) { - pagerUnlockDb(tls, pPager, 1) - } else if state == 0 { + if (rc == SQLITE_OK) && (state == PAGER_READER) { + pagerUnlockDb(tls, pPager, SHARED_LOCK) + } else if state == PAGER_OPEN { pager_unlock(tls, pPager) } } - } else if eMode == 2 { + } else if eMode == PAGER_JOURNALMODE_OFF { Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) } } @@ -36736,7 +36126,7 @@ func Xsqlite3PagerGetJournalMode(tls *libc.TLS, pPager uintptr) int32 { /* sqlit // is unmodified. func Xsqlite3PagerOkToChangeJournalMode(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:59052:20: */ - if int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= 3 { + if int32((*Pager)(unsafe.Pointer(pPager)).FeState) >= PAGER_WRITER_CACHEMOD { return 0 } if ((*Sqlite3_file)(unsafe.Pointer(((*Pager)(unsafe.Pointer(pPager)).Fjfd))).FpMethods != uintptr(0)) && ((*Pager)(unsafe.Pointer(pPager)).FjournalOff > int64(0)) { @@ -36779,11 +36169,11 @@ func Xsqlite3PagerClearCache(tls *libc.TLS, pPager uintptr) { /* sqlite3.c:59087 // // Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART. func Xsqlite3PagerCheckpoint(tls *libc.TLS, pPager uintptr, db uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) int32 { /* sqlite3.c:59102:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 { rc = Xsqlite3WalCheckpoint(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, db, eMode, func() uintptr { - if eMode == 0 { + if eMode == SQLITE_CHECKPOINT_PASSIVE { return uintptr(0) } return (*Pager)(unsafe.Pointer(pPager)).FxBusyHandler @@ -36814,11 +36204,11 @@ func Xsqlite3PagerWalSupported(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3 func pagerExclusiveLock(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:59139:12: */ var rc int32 // Return code - rc = pagerLockDb(tls, pPager, 4) - if rc != 0 { + rc = pagerLockDb(tls, pPager, EXCLUSIVE_LOCK) + if rc != SQLITE_OK { // If the attempt to grab the exclusive lock failed, release the // pending lock that may have been obtained instead. - pagerUnlockDb(tls, pPager, 1) + pagerUnlockDb(tls, pPager, SHARED_LOCK) } return rc @@ -36829,7 +36219,7 @@ func pagerExclusiveLock(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:5913 // lock on the database file and use heap-memory to store the wal-index // in. Otherwise, use the normal shared-memory. func pagerOpenWal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:59159:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK // If the pager is already in exclusive-mode, the WAL module will use // heap-memory for the wal-index instead of the VFS shared-memory @@ -36841,7 +36231,7 @@ func pagerOpenWal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:59159:12: // Open the connection to the log file. If this operation fails, // (e.g. due to malloc() failure), return an error code. - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3WalOpen(tls, (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).Ffd, (*Pager)(unsafe.Pointer(pPager)).FzWal, int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode), (*Pager)(unsafe.Pointer(pPager)).FjournalSizeLimit, (pPager + 296 /* &.pWal */)) @@ -36865,20 +36255,20 @@ func pagerOpenWal(tls *libc.TLS, pPager uintptr) int32 { /* sqlite3.c:59159:12: // the WAL file is already open, set *pbOpen to 1 and return SQLITE_OK // without doing anything. func Xsqlite3PagerOpenWal(tls *libc.TLS, pPager uintptr, pbOpen uintptr) int32 { /* sqlite3.c:59204:20: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code if !(int32((*Pager)(unsafe.Pointer(pPager)).FtempFile) != 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FpWal) != 0) { if !(Xsqlite3PagerWalSupported(tls, pPager) != 0) { - return 14 + return SQLITE_CANTOPEN } // Close any rollback journal previously open Xsqlite3OsClose(tls, (*Pager)(unsafe.Pointer(pPager)).Fjfd) rc = pagerOpenWal(tls, pPager) - if rc == 0 { - (*Pager)(unsafe.Pointer(pPager)).FjournalMode = U8(5) - (*Pager)(unsafe.Pointer(pPager)).FeState = U8(0) + if rc == SQLITE_OK { + (*Pager)(unsafe.Pointer(pPager)).FjournalMode = PAGER_JOURNALMODE_WAL + (*Pager)(unsafe.Pointer(pPager)).FeState = PAGER_OPEN } } else { *(*int32)(unsafe.Pointer(pbOpen)) = 1 @@ -36898,34 +36288,34 @@ func Xsqlite3PagerCloseWal(tls *libc.TLS, pPager uintptr, db uintptr) int32 { /* bp := tls.Alloc(4) defer tls.Free(4) - var rc int32 = 0 + var rc int32 = SQLITE_OK // If the log file is not already open, but does exist in the file-system, // it may need to be checkpointed before the connection can switch to // rollback mode. Open it now so this can happen. if !(int32((*Pager)(unsafe.Pointer(pPager)).FpWal) != 0) { *(*int32)(unsafe.Pointer(bp /* logexists */)) = 0 - rc = pagerLockDb(tls, pPager, 1) - if rc == 0 { + rc = pagerLockDb(tls, pPager, SHARED_LOCK) + if rc == SQLITE_OK { rc = Xsqlite3OsAccess(tls, - (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzWal, 0, bp /* &logexists */) + (*Pager)(unsafe.Pointer(pPager)).FpVfs, (*Pager)(unsafe.Pointer(pPager)).FzWal, SQLITE_ACCESS_EXISTS, bp /* &logexists */) } - if (rc == 0) && (*(*int32)(unsafe.Pointer(bp /* logexists */)) != 0) { + if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* logexists */)) != 0) { rc = pagerOpenWal(tls, pPager) } } // Checkpoint and close the log. Because an EXCLUSIVE lock is held on // the database file, the log and log-summary files will be deleted. - if (rc == 0) && ((*Pager)(unsafe.Pointer(pPager)).FpWal != 0) { + if (rc == SQLITE_OK) && ((*Pager)(unsafe.Pointer(pPager)).FpWal != 0) { rc = pagerExclusiveLock(tls, pPager) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3WalClose(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, db, int32((*Pager)(unsafe.Pointer(pPager)).FwalSyncFlags), (*Pager)(unsafe.Pointer(pPager)).FpageSize, (*Pager)(unsafe.Pointer(pPager)).FpTmpSpace) (*Pager)(unsafe.Pointer(pPager)).FpWal = uintptr(0) pagerFixMaplimit(tls, pPager) if (rc != 0) && !(int32((*Pager)(unsafe.Pointer(pPager)).FexclusiveMode) != 0) { - pagerUnlockDb(tls, pPager, 1) + pagerUnlockDb(tls, pPager, SHARED_LOCK) } } } @@ -36935,7 +36325,7 @@ func Xsqlite3PagerCloseWal(tls *libc.TLS, pPager uintptr, db uintptr) int32 { /* // If this is a WAL database, obtain a snapshot handle for the snapshot // currently open. Otherwise, return an error. func Xsqlite3PagerSnapshotGet(tls *libc.TLS, pPager uintptr, ppSnapshot uintptr) int32 { /* sqlite3.c:59312:20: */ - var rc int32 = 1 + var rc int32 = SQLITE_ERROR if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 { rc = Xsqlite3WalSnapshotGet(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, ppSnapshot) } @@ -36946,11 +36336,11 @@ func Xsqlite3PagerSnapshotGet(tls *libc.TLS, pPager uintptr, ppSnapshot uintptr) // read transaction is opened, attempt to read from the snapshot it // identifies. If this is not a WAL database, return an error. func Xsqlite3PagerSnapshotOpen(tls *libc.TLS, pPager uintptr, pSnapshot uintptr) int32 { /* sqlite3.c:59325:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 { Xsqlite3WalSnapshotOpen(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, pSnapshot) } else { - rc = 1 + rc = SQLITE_ERROR } return rc } @@ -36962,7 +36352,7 @@ func Xsqlite3PagerSnapshotRecover(tls *libc.TLS, pPager uintptr) int32 { /* sqli if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 { rc = Xsqlite3WalSnapshotRecover(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal) } else { - rc = 1 + rc = SQLITE_ERROR } return rc } @@ -36982,7 +36372,7 @@ func Xsqlite3PagerSnapshotCheck(tls *libc.TLS, pPager uintptr, pSnapshot uintptr if (*Pager)(unsafe.Pointer(pPager)).FpWal != 0 { rc = Xsqlite3WalSnapshotCheck(tls, (*Pager)(unsafe.Pointer(pPager)).FpWal, pSnapshot) } else { - rc = 1 + rc = SQLITE_ERROR } return rc } @@ -37643,68 +37033,68 @@ type WalSegment = struct { // page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs, // then an SQLite error code is returned and *ppPage is set to 0. func walIndexPageRealloc(tls *libc.TLS, pWal uintptr, iPage int32, ppPage uintptr) int32 { /* sqlite3.c:59963:28: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK // Enlarge the pWal->apWiData[] array if required if (*Wal)(unsafe.Pointer(pWal)).FnWiData <= iPage { var nByte Sqlite3_int64 = (Sqlite3_int64(uint64(unsafe.Sizeof(uintptr(0))) * (uint64(iPage + 1)))) var apNew uintptr - apNew = Xsqlite3Realloc(tls, (*Wal)(unsafe.Pointer(pWal)).FapWiData, uint64(nByte)) - if !(apNew != 0) { - *(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0) - return 7 + libc.AtomicStoreUintptr(&apNew, uintptr(Xsqlite3Realloc(tls, (*Wal)(unsafe.Pointer(pWal)).FapWiData, uint64(nByte)))) + if !(libc.AtomicLoadUintptr(&apNew) != 0) { + *(*uintptr)(unsafe.Pointer(libc.AtomicLoadUintptr(&ppPage))) = uintptr(0) + return SQLITE_NOMEM } - libc.Xmemset(tls, (apNew + uintptr((*Wal)(unsafe.Pointer(pWal)).FnWiData)*8), 0, + libc.Xmemset(tls, (libc.AtomicLoadUintptr(&apNew) + uintptr((*Wal)(unsafe.Pointer(pWal)).FnWiData)*8), 0, (uint64(unsafe.Sizeof(uintptr(0))) * (uint64((iPage + 1) - (*Wal)(unsafe.Pointer(pWal)).FnWiData)))) - (*Wal)(unsafe.Pointer(pWal)).FapWiData = apNew + (*Wal)(unsafe.Pointer(pWal)).FapWiData = libc.AtomicLoadUintptr(&apNew) (*Wal)(unsafe.Pointer(pWal)).FnWiData = (iPage + 1) } // Request a pointer to the required page from the VFS - if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == 2 { - *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) = Xsqlite3MallocZero(tls, ((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(4096 * 2))) + (uint64(4096) * uint64(unsafe.Sizeof(U32(0)))))) + if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_HEAPMEMORY_MODE { + *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) = Xsqlite3MallocZero(tls, ((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(HASHTABLE_NPAGE * 2))) + (HASHTABLE_NPAGE * uint64(unsafe.Sizeof(U32(0)))))) if !(int32(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8))) != 0) { - rc = 7 + rc = SQLITE_NOMEM } } else { - rc = Xsqlite3OsShmMap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, iPage, (int32((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(4096 * 2))) + (uint64(4096) * uint64(unsafe.Sizeof(U32(0)))))), + rc = Xsqlite3OsShmMap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, iPage, (int32((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(HASHTABLE_NPAGE * 2))) + (HASHTABLE_NPAGE * uint64(unsafe.Sizeof(U32(0)))))), int32((*Wal)(unsafe.Pointer(pWal)).FwriteLock), ((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) - if rc == 0 { + if rc == SQLITE_OK { if (iPage > 0) && (Xsqlite3FaultSim(tls, 600) != 0) { - rc = 7 + rc = SQLITE_NOMEM } - } else if (rc & 0xff) == 8 { - *(*U8)(unsafe.Pointer(pWal + 66 /* &.readOnly */)) |= U8((2)) - if rc == 8 { - rc = 0 + } else if (rc & 0xff) == SQLITE_READONLY { + *(*U8)(unsafe.Pointer(pWal + 66 /* &.readOnly */)) |= U8((WAL_SHM_RDONLY)) + if rc == SQLITE_READONLY { + rc = SQLITE_OK } } } - *(*uintptr)(unsafe.Pointer(ppPage)) = *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) + *(*uintptr)(unsafe.Pointer(libc.AtomicLoadUintptr(&ppPage))) = *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)) return rc } func walIndexPage(tls *libc.TLS, pWal uintptr, iPage int32, ppPage uintptr) int32 { /* sqlite3.c:60010:12: */ - if ((*Wal)(unsafe.Pointer(pWal)).FnWiData <= iPage) || ((libc.AssignPtrUintptr(ppPage, *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)))) == uintptr(0)) { - return walIndexPageRealloc(tls, pWal, iPage, ppPage) + if ((*Wal)(unsafe.Pointer(pWal)).FnWiData <= iPage) || ((libc.AssignPtrUintptr(libc.AtomicLoadUintptr(&ppPage), *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iPage)*8)))) == uintptr(0)) { + return walIndexPageRealloc(tls, pWal, iPage, libc.AtomicLoadUintptr(&ppPage)) } - return 0 + return SQLITE_OK } // Return a pointer to the WalCkptInfo structure in the wal-index. func walCkptInfo(tls *libc.TLS, pWal uintptr) uintptr { /* sqlite3.c:60024:29: */ - return (*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(0)*8)) + uintptr((uint64(unsafe.Sizeof(WalIndexHdr{}))/uint64(2)))*4) + return (*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData)) + 24*4) } // Return a pointer to the WalIndexHdr structure in the wal-index. func walIndexHdr(tls *libc.TLS, pWal uintptr) uintptr { /* sqlite3.c:60032:29: */ - return *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(0)*8)) + return *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData)) } // The argument to this macro must be of type u32. On a little-endian @@ -37727,8 +37117,8 @@ func walChecksumBytes(tls *libc.TLS, nativeCksum int32, a uintptr, nByte int32, var aEnd uintptr = (a + uintptr(nByte)) if aIn != 0 { - s1 = *(*U32)(unsafe.Pointer(aIn + uintptr(0)*4)) - s2 = *(*U32)(unsafe.Pointer(aIn + uintptr(1)*4)) + s1 = *(*U32)(unsafe.Pointer(aIn)) + s2 = *(*U32)(unsafe.Pointer(aIn + 1*4)) } else { s1 = libc.AssignUint32(&s2, U32(0)) } @@ -37740,20 +37130,20 @@ func walChecksumBytes(tls *libc.TLS, nativeCksum int32, a uintptr, nByte int32, } } else { for ok1 := true; ok1; ok1 = (aData < aEnd) { - s1 = s1 + (((((((*(*U32)(unsafe.Pointer(aData + uintptr(0)*4))) & U32(0x000000FF)) << 24) + (((*(*U32)(unsafe.Pointer(aData + uintptr(0)*4))) & U32(0x0000FF00)) << 8)) + (((*(*U32)(unsafe.Pointer(aData + uintptr(0)*4))) & U32(0x00FF0000)) >> 8)) + (((*(*U32)(unsafe.Pointer(aData + uintptr(0)*4))) & 0xFF000000) >> 24)) + s2) - s2 = s2 + (((((((*(*U32)(unsafe.Pointer(aData + uintptr(1)*4))) & U32(0x000000FF)) << 24) + (((*(*U32)(unsafe.Pointer(aData + uintptr(1)*4))) & U32(0x0000FF00)) << 8)) + (((*(*U32)(unsafe.Pointer(aData + uintptr(1)*4))) & U32(0x00FF0000)) >> 8)) + (((*(*U32)(unsafe.Pointer(aData + uintptr(1)*4))) & 0xFF000000) >> 24)) + s1) + s1 = s1 + (((((((*(*U32)(unsafe.Pointer(aData))) & U32(0x000000FF)) << 24) + (((*(*U32)(unsafe.Pointer(aData))) & U32(0x0000FF00)) << 8)) + (((*(*U32)(unsafe.Pointer(aData))) & U32(0x00FF0000)) >> 8)) + (((*(*U32)(unsafe.Pointer(aData))) & 0xFF000000) >> 24)) + s2) + s2 = s2 + (((((((*(*U32)(unsafe.Pointer(aData + 1*4))) & U32(0x000000FF)) << 24) + (((*(*U32)(unsafe.Pointer(aData + 1*4))) & U32(0x0000FF00)) << 8)) + (((*(*U32)(unsafe.Pointer(aData + 1*4))) & U32(0x00FF0000)) >> 8)) + (((*(*U32)(unsafe.Pointer(aData + 1*4))) & 0xFF000000) >> 24)) + s1) aData += 4 * (uintptr(2)) } } - *(*U32)(unsafe.Pointer(aOut + uintptr(0)*4)) = s1 - *(*U32)(unsafe.Pointer(aOut + uintptr(1)*4)) = s2 + *(*U32)(unsafe.Pointer(aOut)) = s1 + *(*U32)(unsafe.Pointer(aOut + 1*4)) = s2 } // If there is the possibility of concurrent access to the SHM file // from multiple threads and/or processes, then do a memory barrier. func walShmBarrier(tls *libc.TLS, pWal uintptr) { /* sqlite3.c:60101:13: */ - if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != 2 { + if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != WAL_HEAPMEMORY_MODE { Xsqlite3OsShmBarrier(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd) } } @@ -37772,12 +37162,12 @@ func walIndexWriteHdr(tls *libc.TLS, pWal uintptr) { /* sqlite3.c:60125:28: */ var nCksum int32 = int32((uintptr(0) + 40 /* &.aCksum */)) (*Wal)(unsafe.Pointer(pWal)).Fhdr.FisInit = U8(1) - (*Wal)(unsafe.Pointer(pWal)).Fhdr.FiVersion = U32(3007000) + (*Wal)(unsafe.Pointer(pWal)).Fhdr.FiVersion = WALINDEX_MAX_VERSION walChecksumBytes(tls, 1, (pWal + 72 /* &.hdr */), nCksum, uintptr(0), pWal+72 /* &.hdr */ +40 /* &.aCksum */) // Possible TSAN false-positive. See tag-20200519-1 - libc.Xmemcpy(tls, (aHdr + uintptr(1)*48), (pWal + 72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) + libc.Xmemcpy(tls, (libc.AtomicLoadUintptr(&aHdr) + 1*48), (pWal + 72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) walShmBarrier(tls, pWal) - libc.Xmemcpy(tls, (aHdr + uintptr(0)*48), (pWal + 72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) + libc.Xmemcpy(tls, (libc.AtomicLoadUintptr(&aHdr)), (pWal + 72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) } // This function encodes a single frame header and writes it to a buffer @@ -37795,19 +37185,19 @@ func walEncodeFrame(tls *libc.TLS, pWal uintptr, iPage U32, nTruncate U32, aData var nativeCksum int32 // True for native byte-order checksums var aCksum uintptr = pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */ - Xsqlite3Put4byte(tls, (aFrame + uintptr(0)), iPage) - Xsqlite3Put4byte(tls, (aFrame + uintptr(4)), nTruncate) + Xsqlite3Put4byte(tls, (aFrame), iPage) + Xsqlite3Put4byte(tls, (aFrame + 4), nTruncate) if (*Wal)(unsafe.Pointer(pWal)).FiReCksum == U32(0) { - libc.Xmemcpy(tls, (aFrame + uintptr(8)), pWal+72 /* &.hdr */ +32 /* &.aSalt */, uint64(8)) + libc.Xmemcpy(tls, (aFrame + 8), pWal+72 /* &.hdr */ +32 /* &.aSalt */, uint64(8)) - nativeCksum = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == 0)) + nativeCksum = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN)) walChecksumBytes(tls, nativeCksum, aFrame, 8, aCksum, aCksum) walChecksumBytes(tls, nativeCksum, aData, int32((*Wal)(unsafe.Pointer(pWal)).FszPage), aCksum, aCksum) - Xsqlite3Put4byte(tls, (aFrame + uintptr(16)), *(*U32)(unsafe.Pointer(aCksum + uintptr(0)*4))) - Xsqlite3Put4byte(tls, (aFrame + uintptr(20)), *(*U32)(unsafe.Pointer(aCksum + uintptr(1)*4))) + Xsqlite3Put4byte(tls, (aFrame + 16), *(*U32)(unsafe.Pointer(aCksum))) + Xsqlite3Put4byte(tls, (aFrame + 20), *(*U32)(unsafe.Pointer(aCksum + 1*4))) } else { - libc.Xmemset(tls, (aFrame + uintptr(8)), 0, uint64(16)) + libc.Xmemset(tls, (aFrame + 8), 0, uint64(16)) } } @@ -37821,12 +37211,12 @@ func walDecodeFrame(tls *libc.TLS, pWal uintptr, piPage uintptr, pnTruncate uint // A frame is only valid if the salt values in the frame-header // match the salt values in the wal-header. - if libc.Xmemcmp(tls, (pWal+72 /* &.hdr */ +32 /* &.aSalt */), (aFrame+uintptr(8)), uint64(8)) != 0 { + if libc.Xmemcmp(tls, (pWal+72 /* &.hdr */ +32 /* &.aSalt */), (aFrame+8), uint64(8)) != 0 { return 0 } // A frame is only valid if the page number is creater than zero. - pgno = Xsqlite3Get4byte(tls, (aFrame + uintptr(0))) + pgno = Xsqlite3Get4byte(tls, (aFrame)) if pgno == U32(0) { return 0 } @@ -37835,11 +37225,11 @@ func walDecodeFrame(tls *libc.TLS, pWal uintptr, piPage uintptr, pnTruncate uint // all prior frams, the first 16 bytes of this frame-header, // and the frame-data matches the checksum in the last 8 // bytes of this frame-header. - nativeCksum = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == 0)) + nativeCksum = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN)) walChecksumBytes(tls, nativeCksum, aFrame, 8, aCksum, aCksum) walChecksumBytes(tls, nativeCksum, aData, int32((*Wal)(unsafe.Pointer(pWal)).FszPage), aCksum, aCksum) - if (*(*U32)(unsafe.Pointer(aCksum + uintptr(0)*4)) != Xsqlite3Get4byte(tls, (aFrame+uintptr(16)))) || - (*(*U32)(unsafe.Pointer(aCksum + uintptr(1)*4)) != Xsqlite3Get4byte(tls, (aFrame+uintptr(20)))) { + if (*(*U32)(unsafe.Pointer(aCksum)) != Xsqlite3Get4byte(tls, (aFrame+16))) || + (*(*U32)(unsafe.Pointer(aCksum + 1*4)) != Xsqlite3Get4byte(tls, (aFrame+20))) { // Checksum failed. return 0 } @@ -37847,7 +37237,7 @@ func walDecodeFrame(tls *libc.TLS, pWal uintptr, piPage uintptr, pnTruncate uint // If we reach this point, the frame is valid. Return the page number // and the new database size. *(*U32)(unsafe.Pointer(piPage)) = pgno - *(*U32)(unsafe.Pointer(pnTruncate)) = Xsqlite3Get4byte(tls, (aFrame + uintptr(4))) + *(*U32)(unsafe.Pointer(pnTruncate)) = Xsqlite3Get4byte(tls, (aFrame + 4)) return 1 } @@ -37859,10 +37249,10 @@ func walDecodeFrame(tls *libc.TLS, pWal uintptr, piPage uintptr, pnTruncate uint func walLockShared(tls *libc.TLS, pWal uintptr, lockIdx int32) int32 { /* sqlite3.c:60262:12: */ var rc int32 if (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 { - return 0 + return SQLITE_OK } rc = Xsqlite3OsShmLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, 1, - (2 | 4)) + (SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)) return rc } @@ -37872,17 +37262,17 @@ func walUnlockShared(tls *libc.TLS, pWal uintptr, lockIdx int32) { /* sqlite3.c: return } Xsqlite3OsShmLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, 1, - (1 | 4)) + (SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)) } func walLockExclusive(tls *libc.TLS, pWal uintptr, lockIdx int32, n int32) int32 { /* sqlite3.c:60278:12: */ var rc int32 if (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 { - return 0 + return SQLITE_OK } rc = Xsqlite3OsShmLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, n, - (2 | 8)) + (SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)) return rc } @@ -37892,7 +37282,7 @@ func walUnlockExclusive(tls *libc.TLS, pWal uintptr, lockIdx int32, n int32) { / return } Xsqlite3OsShmLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, n, - (1 | 8)) + (SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE)) } @@ -37901,11 +37291,11 @@ func walUnlockExclusive(tls *libc.TLS, pWal uintptr, lockIdx int32, n int32) { / // the hash to the next value in the event of a collision. func walHash(tls *libc.TLS, iPage U32) int32 { /* sqlite3.c:60301:12: */ - return (int32((iPage * U32(383)) & (U32((4096 * 2) - 1)))) + return (int32((iPage * HASHTABLE_HASH_1) & (U32((HASHTABLE_NPAGE * 2) - 1)))) } func walNextHash(tls *libc.TLS, iPriorHash int32) int32 { /* sqlite3.c:60306:12: */ - return ((iPriorHash + 1) & ((4096 * 2) - 1)) + return ((iPriorHash + 1) & ((HASHTABLE_NPAGE * 2) - 1)) } // An instance of the WalHashLoc object is used to describe the location @@ -37940,13 +37330,13 @@ func walHashGet(tls *libc.TLS, pWal uintptr, iHash int32, pLoc uintptr) int32 { rc = walIndexPage(tls, pWal, iHash, (pLoc + 8 /* &.aPgno */)) - if rc == 0 { - (*WalHashLoc)(unsafe.Pointer(pLoc)).FaHash = ((*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + uintptr(4096)*4) + if rc == SQLITE_OK { + (*WalHashLoc)(unsafe.Pointer(pLoc)).FaHash = ((*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + 4096*4) if iHash == 0 { - (*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno = ((*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + uintptr((((uint64(unsafe.Sizeof(WalIndexHdr{}))*uint64(2))+uint64(unsafe.Sizeof(WalCkptInfo{})))/uint64(unsafe.Sizeof(U32(0)))))*4) + (*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno = ((*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + 34*4) (*WalHashLoc)(unsafe.Pointer(pLoc)).FiZero = U32(0) } else { - (*WalHashLoc)(unsafe.Pointer(pLoc)).FiZero = (U32((uint64(4096) - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64((iHash - 1) * 4096)))) + (*WalHashLoc)(unsafe.Pointer(pLoc)).FiZero = (U32((HASHTABLE_NPAGE - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64((iHash - 1) * HASHTABLE_NPAGE)))) } (*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno = ((*WalHashLoc)(unsafe.Pointer(pLoc)).FaPgno + libc.UintptrFromInt32(-1)*4) } @@ -37958,7 +37348,7 @@ func walHashGet(tls *libc.TLS, pWal uintptr, iHash int32, pLoc uintptr) int32 { // iFrame. The wal-index is broken up into 32KB pages. Wal-index pages // are numbered starting from 0. func walFramePage(tls *libc.TLS, iFrame U32) int32 { /* sqlite3.c:60365:12: */ - var iHash int32 = (int32((((uint64(iFrame + U32(4096))) - (uint64(4096) - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0)))))) - uint64(1)) / uint64(4096))) + var iHash int32 = (int32((((uint64(iFrame + HASHTABLE_NPAGE)) - (HASHTABLE_NPAGE - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0)))))) - uint64(1)) / HASHTABLE_NPAGE)) return iHash } @@ -37967,9 +37357,9 @@ func walFramePage(tls *libc.TLS, iFrame U32) int32 { /* sqlite3.c:60365:12: */ func walFramePgno(tls *libc.TLS, pWal uintptr, iFrame U32) U32 { /* sqlite3.c:60380:12: */ var iHash int32 = walFramePage(tls, iFrame) if iHash == 0 { - return *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(0)*8)) + uintptr((((((uint64(unsafe.Sizeof(WalIndexHdr{}))*uint64(2))+uint64(unsafe.Sizeof(WalCkptInfo{})))/uint64(unsafe.Sizeof(U32(0))))+uint64(iFrame))-uint64(1)))*4)) + return *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData)) + uintptr((((((uint64(unsafe.Sizeof(WalIndexHdr{}))*uint64(2))+uint64(unsafe.Sizeof(WalCkptInfo{})))/uint64(unsafe.Sizeof(U32(0))))+uint64(iFrame))-uint64(1)))*4)) } - return *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iHash)*8)) + uintptr((((uint64(iFrame-U32(1)))-(uint64(4096)-(((uint64(unsafe.Sizeof(WalIndexHdr{}))*uint64(2))+uint64(unsafe.Sizeof(WalCkptInfo{})))/uint64(unsafe.Sizeof(U32(0))))))%uint64(4096)))*4)) + return *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(iHash)*8)) + uintptr((((uint64(iFrame-U32(1)))-(HASHTABLE_NPAGE-(((uint64(unsafe.Sizeof(WalIndexHdr{}))*uint64(2))+uint64(unsafe.Sizeof(WalCkptInfo{})))/uint64(unsafe.Sizeof(U32(0))))))%HASHTABLE_NPAGE))*4)) } // Remove entries from the hash table that point to WAL slots greater @@ -38010,7 +37400,7 @@ func walCleanupHash(tls *libc.TLS, pWal uintptr) { /* sqlite3.c:60400:13: */ // than pWal->hdr.mxFrame. iLimit = (int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame - (*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FiZero)) - for i = 0; i < (4096 * 2); i++ { + for i = 0; i < (HASHTABLE_NPAGE * 2); i++ { if int32(*(*Ht_slot)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaHash + uintptr(i)*2))) > iLimit { *(*Ht_slot)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaHash + uintptr(i)*2)) = Ht_slot(0) } @@ -38037,7 +37427,7 @@ func walIndexAppend(tls *libc.TLS, pWal uintptr, iFrame U32, iPage U32) int32 { // Assuming the wal-index file was successfully mapped, populate the // page number array and hash table entry. - if rc == 0 { + if rc == SQLITE_OK { var iKey int32 // Hash table key var idx int32 // Value to write to hash-table slot var nCollide int32 // Number of hash collisions @@ -38047,9 +37437,9 @@ func walIndexAppend(tls *libc.TLS, pWal uintptr, iFrame U32, iPage U32) int32 { // If this is the first entry to be added to this hash-table, zero the // entire hash table and aPgno[] array before proceeding. if idx == 1 { - var nByte int32 = (int32((int64(((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaHash + uintptr((4096*2))*2)) - - int64(((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaPgno + uintptr(1)*4))) / 1)) - libc.Xmemset(tls, ((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaPgno + uintptr(1)*4), 0, uint64(nByte)) + var nByte int32 = (int32((int64(((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaHash + 8192*2)) - + int64(((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaPgno + 1*4))) / 1)) + libc.Xmemset(tls, ((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaPgno + 1*4), 0, uint64(nByte)) } // If the entry in aPgno[] is already set, then the previous writer @@ -38129,7 +37519,7 @@ func walIndexRecover(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3.c:60552:12: // If successful, the same bytes that are locked here are unlocked before // this function returns. - iLock = (1 + int32((*Wal)(unsafe.Pointer(pWal)).FckptLock)) + iLock = (WAL_ALL_BUT_WRITE + int32((*Wal)(unsafe.Pointer(pWal)).FckptLock)) rc = walLockExclusive(tls, pWal, iLock, ((3 + (0)) - iLock)) if !(rc != 0) { goto __1 @@ -38141,22 +37531,22 @@ __1: libc.Xmemset(tls, (pWal + 72 /* &.hdr */), 0, uint64(unsafe.Sizeof(WalIndexHdr{}))) rc = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+16 /* &nSize */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __2 } goto recovery_error __2: ; - if !(*(*I64)(unsafe.Pointer(bp + 16 /* nSize */)) > int64(32)) { + if !(*(*I64)(unsafe.Pointer(bp + 16 /* nSize */)) > WAL_HDRSIZE) { goto __3 } // Buffer to load WAL header into aPrivate = uintptr(0) // Heap copy of *-shm hash being populated aFrame = uintptr(0) // Last frame in wal, based on nSize alone // Read in the WAL header. - rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+24 /* &aBuf[0] */, 32, int64(0)) - if !(rc != 0) { + rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+24 /* &aBuf[0] */, WAL_HDRSIZE, int64(0)) + if !(rc != SQLITE_OK) { goto __4 } goto recovery_error @@ -38167,11 +37557,11 @@ __4: // SQLITE_MAX_PAGE_SIZE, conclude that the WAL file contains no valid // data. Similarly, if the 'magic' value is invalid, ignore the whole // WAL file. - magic = Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + uintptr(0))) - szPage = int32(Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + uintptr(8)))) - if !(((((magic & 0xFFFFFFFE) != U32(0x377f0682)) || + magic = Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */)) + szPage = int32(Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + 8))) + if !(((((magic & 0xFFFFFFFE) != WAL_MAGIC) || ((szPage & (szPage - 1)) != 0)) || - (szPage > 65536)) || + (szPage > SQLITE_MAX_PAGE_SIZE)) || (szPage < 512)) { goto __5 } @@ -38180,14 +37570,14 @@ __5: ; (*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum = (U8(magic & U32(0x00000001))) (*Wal)(unsafe.Pointer(pWal)).FszPage = U32(szPage) - (*Wal)(unsafe.Pointer(pWal)).FnCkpt = Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + uintptr(12))) - libc.Xmemcpy(tls, (pWal + 72 /* &.hdr */ + 32 /* &.aSalt */), (bp + 24 /* &aBuf */ + uintptr(16)), uint64(8)) + (*Wal)(unsafe.Pointer(pWal)).FnCkpt = Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + 12)) + libc.Xmemcpy(tls, (pWal + 72 /* &.hdr */ + 32 /* &.aSalt */), (bp + 24 /* &aBuf */ + 16), uint64(8)) // Verify that the WAL header checksum is correct - walChecksumBytes(tls, (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == 0)), - bp+24 /* &aBuf[0] */, (32 - (2 * 4)), uintptr(0), pWal+72 /* &.hdr */ +24 /* &.aFrameCksum */) - if !((*(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) != Xsqlite3Get4byte(tls, (bp+24 /* &aBuf */ +uintptr(24)))) || - (*(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) != Xsqlite3Get4byte(tls, (bp+24 /* &aBuf */ +uintptr(28))))) { + walChecksumBytes(tls, (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum) == SQLITE_BIGENDIAN)), + bp+24 /* &aBuf[0] */, (WAL_HDRSIZE - (2 * 4)), uintptr(0), pWal+72 /* &.hdr */ +24 /* &.aFrameCksum */) + if !((*(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) != Xsqlite3Get4byte(tls, (bp+24 /* &aBuf */ +24))) || + (*(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) != Xsqlite3Get4byte(tls, (bp+24 /* &aBuf */ +28)))) { goto __6 } goto finished @@ -38196,8 +37586,8 @@ __6: // Verify that the version number on the WAL format is one that // are able to understand - version = Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + uintptr(4))) - if !(version != U32(3007000)) { + version = Xsqlite3Get4byte(tls, (bp + 24 /* &aBuf */ + 4)) + if !(version != WAL_MAX_VERSION) { goto __7 } rc = Xsqlite3CantopenError(tls, 60635) @@ -38206,36 +37596,36 @@ __7: ; // Malloc a buffer to read frames into. - szFrame = (szPage + 24) - aFrame = Xsqlite3_malloc64(tls, (uint64(uint64(szFrame) + ((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(4096 * 2))) + (uint64(4096) * uint64(unsafe.Sizeof(U32(0)))))))) + szFrame = (szPage + WAL_FRAME_HDRSIZE) + aFrame = Xsqlite3_malloc64(tls, (uint64(uint64(szFrame) + ((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(HASHTABLE_NPAGE * 2))) + (HASHTABLE_NPAGE * uint64(unsafe.Sizeof(U32(0)))))))) if !(!(aFrame != 0)) { goto __8 } - rc = 7 + rc = SQLITE_NOMEM goto recovery_error __8: ; - aData = (aFrame + uintptr(24)) + aData = (aFrame + 24) aPrivate = (aData + uintptr(szPage)) // Read all frames from the log file. - iLastFrame = (U32((*(*I64)(unsafe.Pointer(bp + 16 /* nSize */)) - int64(32)) / I64(szFrame))) + iLastFrame = (U32((*(*I64)(unsafe.Pointer(bp + 16 /* nSize */)) - WAL_HDRSIZE) / I64(szFrame))) iPg = U32(0) __9: if !(iPg <= U32(walFramePage(tls, iLastFrame))) { goto __11 } // Index of last frame read iLast = func() uint32 { - if (uint64(iLastFrame)) < ((uint64(4096) - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64(iPg * U32(4096)))) { + if (uint64(iLastFrame)) < ((HASHTABLE_NPAGE - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64(iPg * HASHTABLE_NPAGE))) { return iLastFrame } - return (uint32((uint64(4096) - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64(iPg * U32(4096))))) + return (uint32((HASHTABLE_NPAGE - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64(iPg * HASHTABLE_NPAGE)))) }() iFirst = (U32(uint64(1) + (func() uint64 { if iPg == U32(0) { return uint64(0) } - return ((uint64(4096) - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64((iPg - U32(1)) * U32(4096)))) + return ((HASHTABLE_NPAGE - (((uint64(unsafe.Sizeof(WalIndexHdr{})) * uint64(2)) + uint64(unsafe.Sizeof(WalCkptInfo{}))) / uint64(unsafe.Sizeof(U32(0))))) + (uint64((iPg - U32(1)) * HASHTABLE_NPAGE))) }()))) rc = walIndexPage(tls, pWal, int32(iPg), bp+56 /* &aShare */) if !(rc != 0) { @@ -38251,11 +37641,11 @@ __13: if !(iFrame <= iLast) { goto __15 } - iOffset = (int64(32) + ((I64((iFrame) - U32(1))) * (I64((szPage) + 24)))) // dbsize field from frame header + iOffset = (WAL_HDRSIZE + ((I64((iFrame) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) // dbsize field from frame header // Read and decode the next log frame. rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aFrame, szFrame, iOffset) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __16 } goto __15 @@ -38269,7 +37659,7 @@ __16: __17: ; rc = walIndexAppend(tls, pWal, iFrame, *(*U32)(unsafe.Pointer(bp + 64 /* pgno */))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __18 } goto __15 @@ -38284,8 +37674,8 @@ __18: (*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage = *(*U32)(unsafe.Pointer(bp + 68 /* nTruncate */)) (*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage = (U16((szPage & 0xff00) | (szPage >> 16))) - *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */ + uintptr(0)*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) - *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */ + uintptr(1)*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) + *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) + *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */ + 1*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) __19: ; goto __14 @@ -38310,7 +37700,7 @@ __15: // do that, according to the spec, but no memcpy() implementation that // we know of actually does that, which is why we say that memcpy() // is safe for this. Memcpy() is certainly a lot faster. - libc.Xmemcpy(tls, (*(*uintptr)(unsafe.Pointer(bp + 56 /* aShare */)) + uintptr(nHdr32)*4), (aPrivate + uintptr(nHdr32)*4), (((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(4096 * 2))) + (uint64(4096) * uint64(unsafe.Sizeof(U32(0))))) - uint64(nHdr))) + libc.Xmemcpy(tls, (*(*uintptr)(unsafe.Pointer(bp + 56 /* aShare */)) + uintptr(nHdr32)*4), (aPrivate + uintptr(nHdr32)*4), (((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(HASHTABLE_NPAGE * 2))) + (HASHTABLE_NPAGE * uint64(unsafe.Sizeof(U32(0))))) - uint64(nHdr))) if !(iFrame <= iLast) { goto __20 } @@ -38330,42 +37720,42 @@ __3: ; finished: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __21 } - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) = *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */ + uintptr(0)*4)) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) = *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */ + uintptr(1)*4)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) = *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) = *(*U32)(unsafe.Pointer(bp + 72 /* &aFrameCksum[0] */ + 1*4)) walIndexWriteHdr(tls, pWal) // Reset the checkpoint-header. This is safe because this thread is // currently holding locks that exclude all other writers and // checkpointers. Then set the values of read-mark slots 1 through N. - pInfo = walCkptInfo(tls, pWal) - (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill = U32(0) - (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame - *(*U32)(unsafe.Pointer((pInfo + 4 /* &.aReadMark */) + uintptr(0)*4)) = U32(0) + libc.AtomicStoreUintptr(&pInfo, uintptr(walCkptInfo(tls, pWal))) + (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill = U32(0) + (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + *(*U32)(unsafe.Pointer((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */))) = U32(0) i = 1 __22: - if !(i < (8 - 3)) { + if !(i < (SQLITE_SHM_NLOCK - 3)) { goto __24 } rc = walLockExclusive(tls, pWal, (3 + (i)), 1) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __25 } if !((i == 1) && ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame != 0)) { goto __27 } - *(*U32)(unsafe.Pointer((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4)) = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + *(*U32)(unsafe.Pointer((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4)) = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame goto __28 __27: - *(*U32)(unsafe.Pointer((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4)) = 0xffffffff + *(*U32)(unsafe.Pointer((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4)) = READMARK_NOT_USED __28: ; walUnlockExclusive(tls, pWal, (3 + (i)), 1) goto __26 __25: - if !(rc != 5) { + if !(rc != SQLITE_BUSY) { goto __29 } goto recovery_error @@ -38388,7 +37778,7 @@ __24: if !((*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage != 0) { goto __30 } - Xsqlite3_log(tls, (27 | (int32(1) << 8)), + Xsqlite3_log(tls, (SQLITE_NOTICE | (int32(1) << 8)), ts+5623, /* "recovered %d fra..." */ libc.VaList(bp, (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame, (*Wal)(unsafe.Pointer(pWal)).FzWalName)) __30: @@ -38404,14 +37794,14 @@ recovery_error: // Close an open wal-index. func walIndexClose(tls *libc.TLS, pWal uintptr, isDelete int32) { /* sqlite3.c:60774:13: */ - if (int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == 2) || ((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable != 0) { + if (int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_HEAPMEMORY_MODE) || ((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable != 0) { var i int32 for i = 0; i < (*Wal)(unsafe.Pointer(pWal)).FnWiData; i++ { Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*8))) *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(i)*8)) = uintptr(0) } } - if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != 2 { + if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != WAL_HEAPMEMORY_MODE { Xsqlite3OsShmUnmap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, isDelete) } } @@ -38448,11 +37838,11 @@ func Xsqlite3WalOpen(tls *libc.TLS, pVfs uintptr, pDbFd uintptr, zWalName uintpt *(*uintptr)(unsafe.Pointer(ppWal)) = uintptr(0) pRet = Xsqlite3MallocZero(tls, (uint64(uint64(unsafe.Sizeof(Wal{})) + uint64((*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)))) if !(pRet != 0) { - return 7 + return SQLITE_NOMEM } (*Wal)(unsafe.Pointer(pRet)).FpVfs = pVfs - (*Wal)(unsafe.Pointer(pRet)).FpWalFd = (pRet + uintptr(1)*152) + (*Wal)(unsafe.Pointer(pRet)).FpWalFd = (pRet + 1*152) (*Wal)(unsafe.Pointer(pRet)).FpDbFd = pDbFd (*Wal)(unsafe.Pointer(pRet)).FreadLock = int16(-1) (*Wal)(unsafe.Pointer(pRet)).FmxWalSize = mxWalSize @@ -38461,28 +37851,28 @@ func Xsqlite3WalOpen(tls *libc.TLS, pVfs uintptr, pDbFd uintptr, zWalName uintpt (*Wal)(unsafe.Pointer(pRet)).FpadToSectorBoundary = U8(1) (*Wal)(unsafe.Pointer(pRet)).FexclusiveMode = func() uint8 { if bNoShm != 0 { - return uint8(2) + return WAL_HEAPMEMORY_MODE } - return uint8(0) + return WAL_NORMAL_MODE }() // Open file handle on the write-ahead log file. - *(*int32)(unsafe.Pointer(bp /* flags */)) = ((0x00000002 | 0x00000004) | 0x00080000) + *(*int32)(unsafe.Pointer(bp /* flags */)) = ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_WAL) rc = Xsqlite3OsOpen(tls, pVfs, zWalName, (*Wal)(unsafe.Pointer(pRet)).FpWalFd, *(*int32)(unsafe.Pointer(bp /* flags */)), bp /* &flags */) - if (rc == 0) && ((*(*int32)(unsafe.Pointer(bp /* flags */)) & 0x00000001) != 0) { - (*Wal)(unsafe.Pointer(pRet)).FreadOnly = U8(1) + if (rc == SQLITE_OK) && ((*(*int32)(unsafe.Pointer(bp /* flags */)) & SQLITE_OPEN_READONLY) != 0) { + (*Wal)(unsafe.Pointer(pRet)).FreadOnly = WAL_RDONLY } - if rc != 0 { + if rc != SQLITE_OK { walIndexClose(tls, pRet, 0) Xsqlite3OsClose(tls, (*Wal)(unsafe.Pointer(pRet)).FpWalFd) Xsqlite3_free(tls, pRet) } else { var iDC int32 = Xsqlite3OsDeviceCharacteristics(tls, pDbFd) - if (iDC & 0x00000400) != 0 { + if (iDC & SQLITE_IOCAP_SEQUENTIAL) != 0 { (*Wal)(unsafe.Pointer(pRet)).FsyncHeader = U8(0) } - if (iDC & 0x00001000) != 0 { + if (iDC & SQLITE_IOCAP_POWERSAFE_OVERWRITE) != 0 { (*Wal)(unsafe.Pointer(pRet)).FpadToSectorBoundary = U8(0) } *(*uintptr)(unsafe.Pointer(ppWal)) = pRet @@ -38667,13 +38057,13 @@ func walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill U32, pp uintptr) int bp := tls.Alloc(28) defer tls.Free(28) - var p uintptr // Return value - var nSegment int32 // Number of segments to merge - var iLast U32 // Last frame in log - var nByte Sqlite3_int64 // Number of bytes to allocate - var i int32 // Iterator variable - var aTmp uintptr // Temp space used by merge-sort - var rc int32 = 0 // Return Code + var p uintptr // Return value + var nSegment int32 // Number of segments to merge + var iLast U32 // Last frame in log + var nByte Sqlite3_int64 // Number of bytes to allocate + var i int32 // Iterator variable + var aTmp uintptr // Temp space used by merge-sort + var rc int32 = SQLITE_OK // Return Code // This routine only runs while holding the checkpoint lock. And // it only runs if there is actually content in the log (mxFrame>0). @@ -38687,7 +38077,7 @@ func walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill U32, pp uintptr) int (uint64(iLast) * uint64(unsafe.Sizeof(Ht_slot(0)))))) p = Xsqlite3_malloc64(tls, uint64(nByte)) if !(p != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, p, 0, uint64(nByte)) (*WalIterator)(unsafe.Pointer(p)).FnSegment = nSegment @@ -38696,20 +38086,20 @@ func walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill U32, pp uintptr) int // of memory will be freed before this function returns. aTmp = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(Ht_slot(0))) * (func() uint64 { - if iLast > U32(4096) { - return uint64(4096) + if iLast > HASHTABLE_NPAGE { + return HASHTABLE_NPAGE } return uint64(iLast) }())))) if !(aTmp != 0) { - rc = 7 + rc = SQLITE_NOMEM } - for i = walFramePage(tls, (nBackfill + U32(1))); (rc == 0) && (i < nSegment); i++ { + for i = walFramePage(tls, (nBackfill + U32(1))); (rc == SQLITE_OK) && (i < nSegment); i++ { // var sLoc WalHashLoc at bp, 24 rc = walHashGet(tls, pWal, i, bp /* &sLoc */) - if rc == 0 { + if rc == SQLITE_OK { var j int32 // Counter variable // var nEntry int32 at bp+24, 4 // Number of entries in this segment @@ -38736,7 +38126,7 @@ func walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill U32, pp uintptr) int } Xsqlite3_free(tls, aTmp) - if rc != 0 { + if rc != SQLITE_OK { walIteratorFree(tls, p) p = uintptr(0) } @@ -38750,7 +38140,7 @@ func walIteratorInit(tls *libc.TLS, pWal uintptr, nBackfill U32, pp uintptr) int // lock is successfully obtained or the busy-handler returns 0. func walBusyLock(tls *libc.TLS, pWal uintptr, xBusy uintptr, pBusyArg uintptr, lockIdx int32, n int32) int32 { /* sqlite3.c:61244:12: */ var rc int32 - for ok := true; ok; ok = (((xBusy != 0) && (rc == 5)) && ((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&xBusy)))(tls, pBusyArg) != 0)) { + for ok := true; ok; ok = (((xBusy != 0) && (rc == SQLITE_BUSY)) && ((*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&xBusy)))(tls, pBusyArg) != 0)) { rc = walLockExclusive(tls, pWal, lockIdx, n) } return rc @@ -38787,14 +38177,14 @@ func walRestartHdr(tls *libc.TLS, pWal uintptr, salt1 U32) { /* sqlite3.c:61289: var aSalt uintptr = pWal + 72 /* &.hdr */ + 32 /* &.aSalt */ // Big-endian salt values (*Wal)(unsafe.Pointer(pWal)).FnCkpt++ (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = U32(0) - Xsqlite3Put4byte(tls, (aSalt + uintptr(0)*4), (U32(1) + Xsqlite3Get4byte(tls, (aSalt+uintptr(0)*4)))) - libc.Xmemcpy(tls, ((pWal + 72 /* &.hdr */ + 32 /* &.aSalt */) + uintptr(1)*4), bp /* &salt1 */, uint64(4)) + Xsqlite3Put4byte(tls, (aSalt), (U32(1) + Xsqlite3Get4byte(tls, (aSalt)))) + libc.Xmemcpy(tls, ((pWal + 72 /* &.hdr */ + 32 /* &.aSalt */) + 1*4), bp /* &salt1 */, uint64(4)) walIndexWriteHdr(tls, pWal) - libc.AtomicStoreNInt32((pInfo /* &.nBackfill */), int32(0), 0) - (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = U32(0) - *(*U32)(unsafe.Pointer((pInfo + 4 /* &.aReadMark */) + uintptr(1)*4)) = U32(0) - for i = 2; i < (8 - 3); i++ { - *(*U32)(unsafe.Pointer((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4)) = 0xffffffff + libc.AtomicStoreNInt32((libc.AtomicLoadUintptr(&pInfo) /* &.nBackfill */), int32(0), 0) + (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted = U32(0) + *(*U32)(unsafe.Pointer((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + 1*4)) = U32(0) + for i = 2; i < (SQLITE_SHM_NLOCK - 3); i++ { + *(*U32)(unsafe.Pointer((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4)) = READMARK_NOT_USED } } @@ -38854,15 +38244,15 @@ func walCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, xBusy u var szDb I64 var nBackfill U32 // var salt1 U32 at bp+32, 4 - rc = 0 + rc = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp /* pIter */)) = uintptr(0) *(*U32)(unsafe.Pointer(bp + 24 /* iDbpage */)) = U32(0) *(*U32)(unsafe.Pointer(bp + 28 /* iFrame */)) = U32(0) // The checkpoint status information szPage = walPagesize(tls, pWal) - pInfo = walCkptInfo(tls, pWal) - if !((*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) { + libc.AtomicStoreUintptr(&pInfo, uintptr(walCkptInfo(tls, pWal))) + if !((*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) { goto __1 } @@ -38877,29 +38267,29 @@ func walCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, xBusy u mxPage = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage i = 1 __2: - if !(i < (8 - 3)) { + if !(i < (SQLITE_SHM_NLOCK - 3)) { goto __4 } - y = U32(libc.AtomicLoadNUint32(((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4), 0)) + y = U32(libc.AtomicLoadNUint32(((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4), 0)) if !(mxSafeFrame > y) { goto __5 } rc = walBusyLock(tls, pWal, xBusy, pBusyArg, (3 + (i)), 1) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __6 } iMark = func() uint32 { if i == 1 { return mxSafeFrame } - return 0xffffffff + return READMARK_NOT_USED }() - libc.AtomicStoreNUint32(((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4), uint32(iMark), 0) + libc.AtomicStoreNUint32(((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4), uint32(iMark), 0) walUnlockExclusive(tls, pWal, (3 + (i)), 1) goto __7 __6: - if !(rc == 5) { + if !(rc == SQLITE_BUSY) { goto __8 } mxSafeFrame = y @@ -38922,34 +38312,34 @@ __4: ; // Allocate the iterator - if !((*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill < mxSafeFrame) { + if !((*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill < mxSafeFrame) { goto __10 } - rc = walIteratorInit(tls, pWal, (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill, bp /* &pIter */) + rc = walIteratorInit(tls, pWal, (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill, bp /* &pIter */) __10: ; if !((*(*uintptr)(unsafe.Pointer(bp /* pIter */)) != 0) && - ((libc.AssignInt32(&rc, walBusyLock(tls, pWal, xBusy, pBusyArg, (3+(0)), 1))) == 0)) { + ((libc.AssignInt32(&rc, walBusyLock(tls, pWal, xBusy, pBusyArg, (3+(0)), 1))) == SQLITE_OK)) { goto __11 } - nBackfill = (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill + nBackfill = (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill - (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = mxSafeFrame + (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted = mxSafeFrame // Sync the WAL to disk rc = Xsqlite3OsSync(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, (((sync_flags) >> 2) & 0x03)) // If the database may grow as a result of this checkpoint, hint // about the eventual size of the db file to the VFS layer. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __12 } *(*I64)(unsafe.Pointer(bp + 16 /* nReq */)) = (I64(mxPage) * I64(szPage)) // Current size of database file - Xsqlite3OsFileControl(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 39, uintptr(0)) + Xsqlite3OsFileControl(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_FCNTL_CKPT_START, uintptr(0)) rc = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, bp+8 /* &nSize */) - if !((rc == 0) && (*(*I64)(unsafe.Pointer(bp + 8 /* nSize */)) < *(*I64)(unsafe.Pointer(bp + 16 /* nReq */)))) { + if !((rc == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp + 8 /* nSize */)) < *(*I64)(unsafe.Pointer(bp + 16 /* nReq */)))) { goto __13 } if !(((*(*I64)(unsafe.Pointer(bp + 8 /* nSize */)) + int64(65536)) + (I64((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) * I64(szPage))) < *(*I64)(unsafe.Pointer(bp + 16 /* nReq */))) { @@ -38962,7 +38352,7 @@ __10: rc = Xsqlite3CorruptError(tls, 61420) goto __15 __14: - Xsqlite3OsFileControlHint(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 5, bp+16 /* &nReq */) + Xsqlite3OsFileControlHint(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_FCNTL_SIZE_HINT, bp+16 /* &nReq */) __15: ; __13: @@ -38973,7 +38363,7 @@ __12: // Iterate through the contents of the WAL, copying data to the db file __16: - if !((rc == 0) && (0 == walIteratorNext(tls, *(*uintptr)(unsafe.Pointer(bp /* pIter */)), bp+24 /* &iDbpage */, bp+28 /* &iFrame */))) { + if !((rc == SQLITE_OK) && (0 == walIteratorNext(tls, *(*uintptr)(unsafe.Pointer(bp /* pIter */)), bp+24 /* &iDbpage */, bp+28 /* &iFrame */))) { goto __17 } @@ -38981,9 +38371,9 @@ __16: goto __18 } if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - rc = 7 + rc = SQLITE_NOMEM } else { - rc = 9 + rc = SQLITE_INTERRUPT } goto __17 __18: @@ -38994,10 +38384,10 @@ __18: goto __16 __19: ; - iOffset = ((int64(32) + ((I64((*(*U32)(unsafe.Pointer(bp + 28 /* iFrame */))) - U32(1))) * (I64((szPage) + 24)))) + int64(24)) + iOffset = ((WAL_HDRSIZE + ((I64((*(*U32)(unsafe.Pointer(bp + 28 /* iFrame */))) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) + WAL_FRAME_HDRSIZE) // testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, zBuf, szPage, iOffset) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __20 } goto __17 @@ -39006,7 +38396,7 @@ __20: iOffset = ((I64(*(*U32)(unsafe.Pointer(bp + 24 /* iDbpage */)) - U32(1))) * I64(szPage)) rc = Xsqlite3OsWrite(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, zBuf, szPage, iOffset) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __21 } goto __17 @@ -39015,10 +38405,10 @@ __21: goto __16 __17: ; - Xsqlite3OsFileControl(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 37, uintptr(0)) + Xsqlite3OsFileControl(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_FCNTL_CKPT_DONE, uintptr(0)) // If work was actually accomplished... - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __22 } if !(mxSafeFrame == (*WalIndexHdr)(unsafe.Pointer(walIndexHdr(tls, pWal))).FmxFrame) { @@ -39027,7 +38417,7 @@ __17: szDb = (I64((*Wal)(unsafe.Pointer(pWal)).Fhdr.FnPage) * I64(szPage)) rc = Xsqlite3OsTruncate(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, szDb) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __24 } rc = Xsqlite3OsSync(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, (((sync_flags) >> 2) & 0x03)) @@ -39035,10 +38425,10 @@ __24: ; __23: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __25 } - libc.AtomicStoreNUint32((pInfo /* &.nBackfill */), uint32(mxSafeFrame), 0) + libc.AtomicStoreNUint32((libc.AtomicLoadUintptr(&pInfo) /* &.nBackfill */), uint32(mxSafeFrame), 0) __25: ; __22: @@ -39049,12 +38439,12 @@ __22: __11: ; - if !(rc == 5) { + if !(rc == SQLITE_BUSY) { goto __26 } // Reset the return code so as not to report a checkpoint failure // just because there are active readers. - rc = 0 + rc = SQLITE_OK __26: ; __1: @@ -39064,26 +38454,26 @@ __1: // entire wal file has been copied into the database file, then block // until all readers have finished using the wal file. This ensures that // the next process to write to the database restarts the wal file. - if !((rc == 0) && (eMode != 0)) { + if !((rc == SQLITE_OK) && (eMode != SQLITE_CHECKPOINT_PASSIVE)) { goto __27 } - if !((*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) { + if !((*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) { goto __28 } - rc = 5 + rc = SQLITE_BUSY goto __29 __28: - if !(eMode >= 2) { + if !(eMode >= SQLITE_CHECKPOINT_RESTART) { goto __30 } Xsqlite3_randomness(tls, 4, bp+32 /* &salt1 */) - rc = walBusyLock(tls, pWal, xBusy, pBusyArg, (3 + (1)), ((8 - 3) - 1)) - if !(rc == 0) { + rc = walBusyLock(tls, pWal, xBusy, pBusyArg, (3 + (1)), ((SQLITE_SHM_NLOCK - 3) - 1)) + if !(rc == SQLITE_OK) { goto __31 } - if !(eMode == 3) { + if !(eMode == SQLITE_CHECKPOINT_TRUNCATE) { goto __32 } // IMPLEMENTATION-OF: R-44699-57140 This mode works the same way as @@ -39103,7 +38493,7 @@ __28: rc = Xsqlite3OsTruncate(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, int64(0)) __32: ; - walUnlockExclusive(tls, pWal, (3 + (1)), ((8 - 3) - 1)) + walUnlockExclusive(tls, pWal, (3 + (1)), ((SQLITE_SHM_NLOCK - 3) - 1)) __31: ; __30: @@ -39129,7 +38519,7 @@ func walLimitSize(tls *libc.TLS, pWal uintptr, nMax I64) { /* sqlite3.c:61522:13 var rx int32 Xsqlite3BeginBenignMalloc(tls) rx = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+8 /* &sz */) - if (rx == 0) && (*(*I64)(unsafe.Pointer(bp + 8 /* sz */)) > nMax) { + if (rx == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp + 8 /* sz */)) > nMax) { rx = Xsqlite3OsTruncate(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, nMax) } Xsqlite3EndBenignMalloc(tls) @@ -39143,7 +38533,7 @@ func Xsqlite3WalClose(tls *libc.TLS, pWal uintptr, db uintptr, sync_flags int32, bp := tls.Alloc(4) defer tls.Free(4) - var rc int32 = 0 + var rc int32 = SQLITE_OK if pWal != 0 { var isDelete int32 = 0 // True to unlink wal and wal-index files @@ -39155,16 +38545,16 @@ func Xsqlite3WalClose(tls *libc.TLS, pWal uintptr, db uintptr, sync_flags int32, // // The EXCLUSIVE lock is not released before returning. if (zBuf != uintptr(0)) && - (0 == (libc.AssignInt32(&rc, Xsqlite3OsLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 4)))) { - if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == 0 { - (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(1) + (SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3OsLock(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_LOCK_EXCLUSIVE)))) { + if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_NORMAL_MODE { + (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = WAL_EXCLUSIVE_MODE } rc = Xsqlite3WalCheckpoint(tls, pWal, db, - 0, uintptr(0), uintptr(0), sync_flags, nBuf, zBuf, uintptr(0), uintptr(0)) - if rc == 0 { + SQLITE_CHECKPOINT_PASSIVE, uintptr(0), uintptr(0), sync_flags, nBuf, zBuf, uintptr(0), uintptr(0)) + if rc == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* bPersist */)) = -1 Xsqlite3OsFileControlHint(tls, - (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 10, bp /* &bPersist */) + (*Wal)(unsafe.Pointer(pWal)).FpDbFd, SQLITE_FCNTL_PERSIST_WAL, bp /* &bPersist */) if *(*int32)(unsafe.Pointer(bp /* bPersist */)) != 1 { // Try to delete the WAL file if the checkpoint completed and // fsyned (rc==SQLITE_OK) and if we are not in persistent-wal @@ -39240,10 +38630,10 @@ func walIndexTryHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* sq // here would be problematic as the memory being accessed is potentially // shared among multiple processes and not all mutex implementions work // reliably in that environment. - aHdr = walIndexHdr(tls, pWal) - libc.Xmemcpy(tls, bp /* &h1 */, (aHdr + uintptr(0)*48), uint64(unsafe.Sizeof(WalIndexHdr{}))) // Possible TSAN false-positive + libc.AtomicStoreUintptr(&aHdr, uintptr(walIndexHdr(tls, pWal))) + libc.Xmemcpy(tls, bp /* &h1 */, (libc.AtomicLoadUintptr(&aHdr)), uint64(unsafe.Sizeof(WalIndexHdr{}))) // Possible TSAN false-positive walShmBarrier(tls, pWal) - libc.Xmemcpy(tls, bp+48 /* &h2 */, (aHdr + uintptr(1)*48), uint64(unsafe.Sizeof(WalIndexHdr{}))) + libc.Xmemcpy(tls, bp+48 /* &h2 */, (libc.AtomicLoadUintptr(&aHdr) + 1*48), uint64(unsafe.Sizeof(WalIndexHdr{}))) if (libc.Xmemcmp(tls, bp /* &h1 */, bp+48 /* &h2 */, uint64(unsafe.Sizeof(WalIndexHdr{}))) != 0) { return 1 // Dirty read @@ -39252,7 +38642,7 @@ func walIndexTryHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* sq return 1 // Malformed header - probably all zeros } walChecksumBytes(tls, 1, bp /* &h1 */, (int32(uint64(unsafe.Sizeof(WalIndexHdr{})) - uint64(unsafe.Sizeof([2]U32{})))), uintptr(0), bp+96 /* &aCksum[0] */) - if (*(*U32)(unsafe.Pointer(bp + 96 /* &aCksum[0] */ + uintptr(0)*4)) != *(*U32)(unsafe.Pointer((bp /* &h1 */ + 40 /* &.aCksum */) + uintptr(0)*4))) || (*(*U32)(unsafe.Pointer(bp + 96 /* &aCksum[0] */ + uintptr(1)*4)) != *(*U32)(unsafe.Pointer((bp /* &h1 */ + 40 /* &.aCksum */) + uintptr(1)*4))) { + if (*(*U32)(unsafe.Pointer(bp + 96 /* &aCksum[0] */)) != *(*U32)(unsafe.Pointer((bp /* &h1 */ + 40 /* &.aCksum */)))) || (*(*U32)(unsafe.Pointer(bp + 96 /* &aCksum[0] */ + 1*4)) != *(*U32)(unsafe.Pointer((bp /* &h1 */ + 40 /* &.aCksum */) + 1*4))) { return 1 // Checksum does not match } @@ -39293,9 +38683,9 @@ func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* s // wal-index header) is mapped. Return early if an error occurs here. rc = walIndexPage(tls, pWal, 0, bp /* &page0 */) - if rc != 0 { + if rc != SQLITE_OK { // READONLY changed to OK in walIndexPage - if rc == (8 | (int32(5) << 8)) { + if rc == (SQLITE_READONLY | (int32(5) << 8)) { // The SQLITE_READONLY_CANTINIT return means that the shared-memory // was openable but is not writable, and this thread is unable to // confirm that another write-capable connection has the shared-memory @@ -39304,7 +38694,7 @@ func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* s // and there is no writer on hand to fix it. (*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable = U8(1) - (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(2) + (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = WAL_HEAPMEMORY_MODE *(*int32)(unsafe.Pointer(pChanged)) = 1 } else { return rc // Any other non-OK return is just an error @@ -39320,7 +38710,7 @@ func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* s // works, but may fail if the wal-index header is corrupt or currently // being modified by another thread or process. badHdr = func() int32 { - if *(*uintptr)(unsafe.Pointer(bp /* page0 */)) != 0 { + if libc.AtomicLoadPUintptr(bp /* page0 */) != 0 { return walIndexTryHdr(tls, pWal, pChanged) } return 1 @@ -39329,16 +38719,16 @@ func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* s // If the first attempt failed, it might have been due to a race // with a writer. So get a WRITE lock and try again. if badHdr != 0 { - if (int32((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0) && ((int32((*Wal)(unsafe.Pointer(pWal)).FreadOnly) & 2) != 0) { - if 0 == (libc.AssignInt32(&rc, walLockShared(tls, pWal, 0))) { - walUnlockShared(tls, pWal, 0) - rc = (8 | (int32(1) << 8)) + if (int32((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0) && ((int32((*Wal)(unsafe.Pointer(pWal)).FreadOnly) & WAL_SHM_RDONLY) != 0) { + if SQLITE_OK == (libc.AssignInt32(&rc, walLockShared(tls, pWal, WAL_WRITE_LOCK))) { + walUnlockShared(tls, pWal, WAL_WRITE_LOCK) + rc = (SQLITE_READONLY | (int32(1) << 8)) } } else { var bWriteLock int32 = int32((*Wal)(unsafe.Pointer(pWal)).FwriteLock) - if (bWriteLock != 0) || (0 == (libc.AssignInt32(&rc, walLockExclusive(tls, pWal, 0, 1)))) { + if (bWriteLock != 0) || (SQLITE_OK == (libc.AssignInt32(&rc, walLockExclusive(tls, pWal, WAL_WRITE_LOCK, 1)))) { (*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(1) - if 0 == (libc.AssignInt32(&rc, walIndexPage(tls, pWal, 0, bp /* &page0 */))) { + if SQLITE_OK == (libc.AssignInt32(&rc, walIndexPage(tls, pWal, 0, bp /* &page0 */))) { badHdr = walIndexTryHdr(tls, pWal, pChanged) if badHdr != 0 { // If the wal-index header is still malformed even while holding @@ -39350,7 +38740,7 @@ func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* s } if bWriteLock == 0 { (*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(0) - walUnlockExclusive(tls, pWal, 0, 1) + walUnlockExclusive(tls, pWal, WAL_WRITE_LOCK, 1) } } } @@ -39359,22 +38749,22 @@ func walIndexReadHdr(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 { /* s // If the header is read successfully, check the version number to make // sure the wal-index was not constructed with some future format that // this version of SQLite cannot understand. - if (badHdr == 0) && ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FiVersion != U32(3007000)) { + if (badHdr == 0) && ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FiVersion != WALINDEX_MAX_VERSION) { rc = Xsqlite3CantopenError(tls, 61769) } if (*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable != 0 { - if rc != 0 { + if rc != SQLITE_OK { walIndexClose(tls, pWal, 0) (*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable = U8(0) // walIndexRecover() might have returned SHORT_READ if a concurrent // writer truncated the WAL out from under it. If that happens, it // indicates that a writer has fixed the SHM file for us, so retry - if rc == (10 | (int32(2) << 8)) { + if rc == (SQLITE_IOERR | (int32(2) << 8)) { rc = -1 } } - (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(0) + (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = WAL_NORMAL_MODE } return rc @@ -39433,10 +38823,10 @@ func walBeginShmUnreliable(tls *libc.TLS, pWal uintptr, pChanged uintptr) int32 // writers from running a checkpoint, but does not stop them // from running recovery. rc = walLockShared(tls, pWal, (3 + (0))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __1 } - if !(rc == 5) { + if !(rc == SQLITE_BUSY) { goto __2 } rc = -1 @@ -39468,13 +38858,13 @@ __1: // even if some external agent does a "chmod" to make the shared-memory // writable by us, until sqlite3OsShmUnmap() has been called. // This is a requirement on the VFS implementation. - rc = Xsqlite3OsShmMap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 0, (int32((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(4096 * 2))) + (uint64(4096) * uint64(unsafe.Sizeof(U32(0)))))), 0, bp /* &pDummy */) + rc = Xsqlite3OsShmMap(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, 0, (int32((uint64(unsafe.Sizeof(Ht_slot(0))) * (uint64(HASHTABLE_NPAGE * 2))) + (HASHTABLE_NPAGE * uint64(unsafe.Sizeof(U32(0)))))), 0, bp /* &pDummy */) // SQLITE_OK not possible for read-only connection - if !(rc != (8 | (int32(5) << 8))) { + if !(rc != (SQLITE_READONLY | (int32(5) << 8))) { goto __3 } rc = func() int32 { - if rc == 8 { + if rc == SQLITE_READONLY { return -1 } return rc @@ -39491,13 +38881,13 @@ __3: // Make sure some writer hasn't come in and changed the WAL file out // from under us, then disconnected, while we were not looking. rc = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+8 /* &szWal */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } goto begin_unreliable_shm_out __4: ; - if !(*(*I64)(unsafe.Pointer(bp + 8 /* szWal */)) < int64(32)) { + if !(*(*I64)(unsafe.Pointer(bp + 8 /* szWal */)) < WAL_HDRSIZE) { goto __5 } // If the wal file is too small to contain a wal-header and the @@ -39509,7 +38899,7 @@ __4: *(*int32)(unsafe.Pointer(pChanged)) = 1 rc = func() int32 { if (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame == U32(0) { - return 0 + return SQLITE_OK } return -1 }() @@ -39518,14 +38908,14 @@ __5: ; // Check the salt keys at the start of the wal file still match. - rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+16 /* &aBuf[0] */, 32, int64(0)) - if !(rc != 0) { + rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp+16 /* &aBuf[0] */, WAL_HDRSIZE, int64(0)) + if !(rc != SQLITE_OK) { goto __6 } goto begin_unreliable_shm_out __6: ; - if !(libc.Xmemcmp(tls, (pWal+72 /* &.hdr */ +32 /* &.aSalt */), (bp+16 /* &aBuf */ +uintptr(16)), uint64(8)) != 0) { + if !(libc.Xmemcmp(tls, (pWal+72 /* &.hdr */ +32 /* &.aSalt */), (bp+16 /* &aBuf */ +16), uint64(8)) != 0) { goto __7 } // Some writer has wrapped the WAL file while we were not looking. @@ -39537,24 +38927,24 @@ __7: ; // Allocate a buffer to read frames into - szFrame = (int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage) + 24) + szFrame = (int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage) + WAL_FRAME_HDRSIZE) aFrame = Xsqlite3_malloc64(tls, uint64(szFrame)) if !(aFrame == uintptr(0)) { goto __8 } - rc = 7 + rc = SQLITE_NOMEM goto begin_unreliable_shm_out __8: ; - aData = (aFrame + uintptr(24)) + aData = (aFrame + 24) // Check to see if a complete transaction has been appended to the // wal file since the heap-memory wal-index was created. If so, the // heap-memory wal-index is discarded and WAL_RETRY returned to // the caller. - *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */ + uintptr(0)*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) - *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */ + uintptr(1)*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) - iOffset = (int64(32) + ((I64(((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + U32(1)) - U32(1))) * (I64((int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage)) + 24)))) + *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) + *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */ + 1*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) + iOffset = (WAL_HDRSIZE + ((I64(((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + U32(1)) - U32(1))) * (I64((int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage)) + WAL_FRAME_HDRSIZE)))) __9: if !((iOffset + I64(szFrame)) <= *(*I64)(unsafe.Pointer(bp + 8 /* szWal */))) { goto __11 @@ -39562,7 +38952,7 @@ __9: // Read and decode the next log frame. rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aFrame, szFrame, iOffset) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } goto __11 @@ -39592,12 +38982,12 @@ __10: goto __11 __11: ; - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) = *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */ + uintptr(0)*4)) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) = *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */ + uintptr(1)*4)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) = *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) = *(*U32)(unsafe.Pointer(bp + 48 /* &aSaveCksum[0] */ + 1*4)) begin_unreliable_shm_out: Xsqlite3_free(tls, aFrame) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __15 } i = 0 @@ -39671,12 +39061,12 @@ __15: // so it takes care to hold an exclusive lock on the corresponding // WAL_READ_LOCK() while changing values. func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32, cnt int32) int32 { /* sqlite3.c:62009:12: */ - var pInfo uintptr // Checkpoint information in wal-index - var mxReadMark U32 // Largest aReadMark[] value - var mxI int32 // Index of largest aReadMark[] value - var i int32 // Loop counter - var rc int32 = 0 // Return code - var mxFrame U32 // Wal frame to lock to + var pInfo uintptr // Checkpoint information in wal-index + var mxReadMark U32 // Largest aReadMark[] value + var mxI int32 // Index of largest aReadMark[] value + var i int32 // Loop counter + var rc int32 = SQLITE_OK // Return code + var mxFrame U32 // Wal frame to lock to // Not currently locked @@ -39702,7 +39092,7 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 var nDelay int32 = 1 // Pause time in microseconds if cnt > 100 { - return 15 + return SQLITE_PROTOCOL } if cnt >= 10 { nDelay = (((cnt - 9) * (cnt - 9)) * 39) @@ -39715,7 +39105,7 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 if int32((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0 { rc = walIndexReadHdr(tls, pWal, pChanged) } - if rc == 5 { + if rc == SQLITE_BUSY { // If there is not a recovery running in another thread or process // then convert BUSY errors to WAL_RETRY. If recovery is known to // be running, convert BUSY to BUSY_RECOVERY. There is a race here @@ -39723,7 +39113,7 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 // would be technically correct. But the race is benign since with // WAL_RETRY this routine will be called again and will probably be // right on the second iteration. - if *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData + uintptr(0)*8)) == uintptr(0) { + if *(*uintptr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FapWiData)) == uintptr(0) { // This branch is taken when the xShmMap() method returns SQLITE_BUSY. // We assume this is a transient condition, so return WAL_RETRY. The // xShmMap() implementation used by the default unix and win32 VFS @@ -39731,28 +39121,28 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 // code that determines whether or not the shared-memory region // must be zeroed before the requested page is returned. rc = -1 - } else if 0 == (libc.AssignInt32(&rc, walLockShared(tls, pWal, 2))) { - walUnlockShared(tls, pWal, 2) + } else if SQLITE_OK == (libc.AssignInt32(&rc, walLockShared(tls, pWal, WAL_RECOVER_LOCK))) { + walUnlockShared(tls, pWal, WAL_RECOVER_LOCK) rc = -1 - } else if rc == 5 { - rc = (5 | (int32(1) << 8)) + } else if rc == SQLITE_BUSY { + rc = (SQLITE_BUSY | (int32(1) << 8)) } } - if rc != 0 { + if rc != SQLITE_OK { return rc } else if (*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable != 0 { return walBeginShmUnreliable(tls, pWal, pChanged) } } - pInfo = walCkptInfo(tls, pWal) - if (!(useWal != 0) && (U32(libc.AtomicLoadNUint32((pInfo /* &.nBackfill */), 0)) == (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame)) && + libc.AtomicStoreUintptr(&pInfo, uintptr(walCkptInfo(tls, pWal))) + if (!(useWal != 0) && (U32(libc.AtomicLoadNUint32((libc.AtomicLoadUintptr(&pInfo) /* &.nBackfill */), 0)) == (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame)) && (((*Wal)(unsafe.Pointer(pWal)).FpSnapshot == uintptr(0)) || ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame == U32(0))) { // The WAL has been completely backfilled (or it is empty). // and can be safely ignored. rc = walLockShared(tls, pWal, (3 + (0))) walShmBarrier(tls, pWal) - if rc == 0 { + if rc == SQLITE_OK { if libc.Xmemcmp(tls, walIndexHdr(tls, pWal), (pWal+72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) != 0 { // It is not safe to allow the reader to continue here if frames // may have been appended to the log before READ_LOCK(0) was obtained. @@ -39770,8 +39160,8 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 return -1 } (*Wal)(unsafe.Pointer(pWal)).FreadLock = int16(0) - return 0 - } else if rc != 5 { + return SQLITE_OK + } else if rc != SQLITE_BUSY { return rc } } @@ -39786,40 +39176,40 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 if ((*Wal)(unsafe.Pointer(pWal)).FpSnapshot != 0) && ((*WalIndexHdr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FpSnapshot)).FmxFrame < mxFrame) { mxFrame = (*WalIndexHdr)(unsafe.Pointer((*Wal)(unsafe.Pointer(pWal)).FpSnapshot)).FmxFrame } - for i = 1; i < (8 - 3); i++ { - var thisMark U32 = U32(libc.AtomicLoadNUint32(((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4), 0)) + for i = 1; i < (SQLITE_SHM_NLOCK - 3); i++ { + var thisMark U32 = U32(libc.AtomicLoadNUint32(((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4), 0)) if (mxReadMark <= thisMark) && (thisMark <= mxFrame) { mxReadMark = thisMark mxI = i } } - if ((int32((*Wal)(unsafe.Pointer(pWal)).FreadOnly) & 2) == 0) && + if ((int32((*Wal)(unsafe.Pointer(pWal)).FreadOnly) & WAL_SHM_RDONLY) == 0) && ((mxReadMark < mxFrame) || (mxI == 0)) { - for i = 1; i < (8 - 3); i++ { + for i = 1; i < (SQLITE_SHM_NLOCK - 3); i++ { rc = walLockExclusive(tls, pWal, (3 + (i)), 1) - if rc == 0 { - libc.AtomicStoreNUint32(((pInfo + 4 /* &.aReadMark */) + uintptr(i)*4), uint32(mxFrame), 0) + if rc == SQLITE_OK { + libc.AtomicStoreNUint32(((libc.AtomicLoadUintptr(&pInfo) + 4 /* &.aReadMark */) + uintptr(i)*4), uint32(mxFrame), 0) mxReadMark = mxFrame mxI = i walUnlockExclusive(tls, pWal, (3 + (i)), 1) break - } else if rc != 5 { + } else if rc != SQLITE_BUSY { return rc } } } if mxI == 0 { - if rc == 5 { + if rc == SQLITE_BUSY { return -1 } - return (8 | (int32(5) << 8)) + return (SQLITE_READONLY | (int32(5) << 8)) } rc = walLockShared(tls, pWal, (3 + (mxI))) if rc != 0 { - if rc == 5 { + if rc == SQLITE_BUSY { return -1 } return rc @@ -39857,9 +39247,9 @@ func walTryBeginRead(tls *libc.TLS, pWal uintptr, pChanged uintptr, useWal int32 // that it can read version A from the database file. However, since // we can guarantee that the checkpointer that set nBackfill could not // see any pages past pWal->hdr.mxFrame, this problem does not come up. - (*Wal)(unsafe.Pointer(pWal)).FminFrame = (U32(libc.AtomicLoadNUint32((pInfo /* &.nBackfill */), 0) + 1)) + (*Wal)(unsafe.Pointer(pWal)).FminFrame = (U32(libc.AtomicLoadNUint32((libc.AtomicLoadUintptr(&pInfo) /* &.nBackfill */), 0) + 1)) walShmBarrier(tls, pWal) - if (U32(libc.AtomicLoadNUint32(((pInfo+4 /* &.aReadMark */)+uintptr(mxI)*4), 0)) != mxReadMark) || + if (U32(libc.AtomicLoadNUint32(((libc.AtomicLoadUintptr(&pInfo)+4 /* &.aReadMark */)+uintptr(mxI)*4), 0)) != mxReadMark) || (libc.Xmemcmp(tls, walIndexHdr(tls, pWal), (pWal+72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) != 0) { walUnlockShared(tls, pWal, (3 + (mxI))) return -1 @@ -39893,22 +39283,22 @@ func Xsqlite3WalSnapshotRecover(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3. var rc int32 - rc = walLockExclusive(tls, pWal, 1, 1) - if rc == 0 { + rc = walLockExclusive(tls, pWal, WAL_CKPT_LOCK, 1) + if rc == SQLITE_OK { var pInfo uintptr = walCkptInfo(tls, pWal) var szPage int32 = int32((*Wal)(unsafe.Pointer(pWal)).FszPage) // var szDb I64 at bp, 8 // Size of db file in bytes rc = Xsqlite3OsFileSize(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, bp /* &szDb */) - if rc == 0 { + if rc == SQLITE_OK { var pBuf1 uintptr = Xsqlite3_malloc(tls, szPage) var pBuf2 uintptr = Xsqlite3_malloc(tls, szPage) if (pBuf1 == uintptr(0)) || (pBuf2 == uintptr(0)) { - rc = 7 + rc = SQLITE_NOMEM } else { - var i U32 = (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted - for i = (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted; i > U32(libc.AtomicLoadNUint32((pInfo /* &.nBackfill */), 0)); i-- { + var i U32 = (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted + for i = (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted; i > U32(libc.AtomicLoadNUint32((libc.AtomicLoadUintptr(&pInfo) /* &.nBackfill */), 0)); i-- { // var sLoc WalHashLoc at bp+8, 24 // Hash table location var pgno U32 // Page number in db file @@ -39916,33 +39306,33 @@ func Xsqlite3WalSnapshotRecover(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3. var iWalOff I64 // Offset of wal file entry rc = walHashGet(tls, pWal, walFramePage(tls, i), bp+8 /* &sLoc */) - if rc != 0 { + if rc != SQLITE_OK { break } pgno = *(*U32)(unsafe.Pointer((*WalHashLoc)(unsafe.Pointer(bp+8 /* &sLoc */)).FaPgno + uintptr((i-(*WalHashLoc)(unsafe.Pointer(bp+8 /* &sLoc */)).FiZero))*4)) iDbOff = ((I64(pgno - U32(1))) * I64(szPage)) if (iDbOff + I64(szPage)) <= *(*I64)(unsafe.Pointer(bp /* szDb */)) { - iWalOff = ((int64(32) + ((I64((i) - U32(1))) * (I64((szPage) + 24)))) + int64(24)) + iWalOff = ((WAL_HDRSIZE + ((I64((i) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) + WAL_FRAME_HDRSIZE) rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, pBuf1, szPage, iWalOff) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpDbFd, pBuf2, szPage, iDbOff) } - if (rc != 0) || (0 == libc.Xmemcmp(tls, pBuf1, pBuf2, uint64(szPage))) { + if (rc != SQLITE_OK) || (0 == libc.Xmemcmp(tls, pBuf1, pBuf2, uint64(szPage))) { break } } - (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted = (i - U32(1)) + (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted = (i - U32(1)) } } Xsqlite3_free(tls, pBuf1) Xsqlite3_free(tls, pBuf2) } - walUnlockExclusive(tls, pWal, 1, 1) + walUnlockExclusive(tls, pWal, WAL_CKPT_LOCK, 1) } return rc @@ -39980,9 +39370,9 @@ func Xsqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintp // there is no checkpointer process by taking a shared CKPT lock // before checking pInfo->nBackfillAttempted. - rc = walLockShared(tls, pWal, 1) + rc = walLockShared(tls, pWal, WAL_CKPT_LOCK) - if rc != 0 { + if rc != SQLITE_OK { return rc } (*Wal)(unsafe.Pointer(pWal)).FckptLock = U8(1) @@ -39992,7 +39382,7 @@ func Xsqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintp rc = walTryBeginRead(tls, pWal, pChanged, 0, libc.PreIncInt32(&cnt, 1)) } - if rc == 0 { + if rc == SQLITE_OK { if (pSnapshot != 0) && (libc.Xmemcmp(tls, pSnapshot, (pWal+72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) != 0) { // At this point the client has a lock on an aReadMark[] slot holding // a value equal to or smaller than pSnapshot->mxFrame, but pWal->hdr @@ -40015,12 +39405,12 @@ func Xsqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintp // with *pSnapshot and set *pChanged as appropriate for opening the // snapshot. if !(libc.Xmemcmp(tls, pSnapshot+32 /* &.aSalt */, pWal+72 /* &.hdr */ +32 /* &.aSalt */, uint64(unsafe.Sizeof([2]U32{}))) != 0) && - ((*WalIndexHdr)(unsafe.Pointer(pSnapshot)).FmxFrame >= (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfillAttempted) { + ((*WalIndexHdr)(unsafe.Pointer(pSnapshot)).FmxFrame >= (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfillAttempted) { libc.Xmemcpy(tls, (pWal + 72 /* &.hdr */), pSnapshot, uint64(unsafe.Sizeof(WalIndexHdr{}))) *(*int32)(unsafe.Pointer(pChanged)) = bChanged } else { - rc = (1 | (int32(3) << 8)) + rc = (SQLITE_ERROR | (int32(3) << 8)) } // A client using a non-current snapshot may not ignore any frames @@ -40031,7 +39421,7 @@ func Xsqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintp // is the same database page. (*Wal)(unsafe.Pointer(pWal)).FminFrame = U32(1) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3WalEndReadTransaction(tls, pWal) } } @@ -40040,7 +39430,7 @@ func Xsqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintp // Release the shared CKPT lock obtained above. if (*Wal)(unsafe.Pointer(pWal)).FckptLock != 0 { - walUnlockShared(tls, pWal, 1) + walUnlockShared(tls, pWal, WAL_CKPT_LOCK) (*Wal)(unsafe.Pointer(pWal)).FckptLock = U8(0) } return rc @@ -40080,7 +39470,7 @@ func Xsqlite3WalFindFrame(tls *libc.TLS, pWal uintptr, pgno Pgno, piRead uintptr // WAL were empty. if (iLast == U32(0)) || ((int32((*Wal)(unsafe.Pointer(pWal)).FreadLock) == 0) && (int32((*Wal)(unsafe.Pointer(pWal)).FbShmUnreliable) == 0)) { *(*U32)(unsafe.Pointer(piRead)) = U32(0) - return 0 + return SQLITE_OK } // Search the hash table or tables for an entry matching page number @@ -40117,10 +39507,10 @@ func Xsqlite3WalFindFrame(tls *libc.TLS, pWal uintptr, pgno Pgno, piRead uintptr var iH U32 rc = walHashGet(tls, pWal, iHash, bp /* &sLoc */) - if rc != 0 { + if rc != SQLITE_OK { return rc } - nCollide = (4096 * 2) + nCollide = (HASHTABLE_NPAGE * 2) iKey = walHash(tls, pgno) for (libc.AssignUint32(&iH, U32(libc.AtomicLoadNUint16(((*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FaHash+uintptr(iKey)*2), 0)))) != U32(0) { var iFrame U32 = (iH + (*WalHashLoc)(unsafe.Pointer(bp /* &sLoc */)).FiZero) @@ -40139,7 +39529,7 @@ func Xsqlite3WalFindFrame(tls *libc.TLS, pWal uintptr, pgno Pgno, piRead uintptr } *(*U32)(unsafe.Pointer(piRead)) = iRead - return 0 + return SQLITE_OK } // Read the contents of frame iRead from the wal file into buffer pOut @@ -40151,7 +39541,7 @@ func Xsqlite3WalReadFrame(tls *libc.TLS, pWal uintptr, iRead U32, nOut int32, pO sz = int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage) sz = ((sz & 0xfe00) + ((sz & 0x0001) << 16)) - iOffset = ((int64(32) + ((I64((iRead) - U32(1))) * (I64((sz) + 24)))) + int64(24)) + iOffset = ((WAL_HDRSIZE + ((I64((iRead) - U32(1))) * (I64((sz) + WAL_FRAME_HDRSIZE)))) + WAL_FRAME_HDRSIZE) // testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL return Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, pOut, func() int32 { if nOut > sz { @@ -40187,12 +39577,12 @@ func Xsqlite3WalBeginWriteTransaction(tls *libc.TLS, pWal uintptr) int32 { /* sq // transaction. if (*Wal)(unsafe.Pointer(pWal)).FreadOnly != 0 { - return 8 + return SQLITE_READONLY } // Only one writer allowed at a time. Get the write lock. Return // SQLITE_BUSY if unable. - rc = walLockExclusive(tls, pWal, 0, 1) + rc = walLockExclusive(tls, pWal, WAL_WRITE_LOCK, 1) if rc != 0 { return rc } @@ -40202,9 +39592,9 @@ func Xsqlite3WalBeginWriteTransaction(tls *libc.TLS, pWal uintptr) int32 { /* sq // time the read transaction on this connection was started, then // the write is disallowed. if (libc.Xmemcmp(tls, (pWal+72 /* &.hdr */), walIndexHdr(tls, pWal), uint64(unsafe.Sizeof(WalIndexHdr{}))) != 0) { - walUnlockExclusive(tls, pWal, 0, 1) + walUnlockExclusive(tls, pWal, WAL_WRITE_LOCK, 1) (*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(0) - rc = (5 | (int32(2) << 8)) + rc = (SQLITE_BUSY | (int32(2) << 8)) } return rc @@ -40214,12 +39604,12 @@ func Xsqlite3WalBeginWriteTransaction(tls *libc.TLS, pWal uintptr) int32 { /* sq // routine merely releases the lock. func Xsqlite3WalEndWriteTransaction(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3.c:62626:20: */ if (*Wal)(unsafe.Pointer(pWal)).FwriteLock != 0 { - walUnlockExclusive(tls, pWal, 0, 1) + walUnlockExclusive(tls, pWal, WAL_WRITE_LOCK, 1) (*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(0) (*Wal)(unsafe.Pointer(pWal)).FiReCksum = U32(0) (*Wal)(unsafe.Pointer(pWal)).FtruncateOnCommit = U8(0) } - return 0 + return SQLITE_OK } // If any data has been written (but not committed) to the log file, this @@ -40233,7 +39623,7 @@ func Xsqlite3WalEndWriteTransaction(tls *libc.TLS, pWal uintptr) int32 { /* sqli // Otherwise, if the callback function does not return an error, this // function returns SQLITE_OK. func Xsqlite3WalUndo(tls *libc.TLS, pWal uintptr, xUndo uintptr, pUndoCtx uintptr) int32 { /* sqlite3.c:62648:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Wal)(unsafe.Pointer(pWal)).FwriteLock != 0 { var iMax Pgno = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame var iFrame Pgno @@ -40242,7 +39632,7 @@ func Xsqlite3WalUndo(tls *libc.TLS, pWal uintptr, xUndo uintptr, pUndoCtx uintpt // was in before the client began writing to the database. libc.Xmemcpy(tls, (pWal + 72 /* &.hdr */), walIndexHdr(tls, pWal), uint64(unsafe.Sizeof(WalIndexHdr{}))) - for iFrame = ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + U32(1)); (rc == 0) && (iFrame <= iMax); iFrame++ { + for iFrame = ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + U32(1)); (rc == SQLITE_OK) && (iFrame <= iMax); iFrame++ { // This call cannot fail. Unless the page for which the page number // is passed as the second argument is (a) in the cache and // (b) has an outstanding reference, then xUndo is either a no-op @@ -40269,10 +39659,10 @@ func Xsqlite3WalUndo(tls *libc.TLS, pWal uintptr, xUndo uintptr, pUndoCtx uintpt // point in the event of a savepoint rollback (via WalSavepointUndo()). func Xsqlite3WalSavepoint(tls *libc.TLS, pWal uintptr, aWalData uintptr) { /* sqlite3.c:62688:21: */ - *(*U32)(unsafe.Pointer(aWalData + uintptr(0)*4)) = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame - *(*U32)(unsafe.Pointer(aWalData + uintptr(1)*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) - *(*U32)(unsafe.Pointer(aWalData + uintptr(2)*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) - *(*U32)(unsafe.Pointer(aWalData + uintptr(3)*4)) = (*Wal)(unsafe.Pointer(pWal)).FnCkpt + *(*U32)(unsafe.Pointer(aWalData)) = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame + *(*U32)(unsafe.Pointer(aWalData + 1*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) + *(*U32)(unsafe.Pointer(aWalData + 2*4)) = *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) + *(*U32)(unsafe.Pointer(aWalData + 3*4)) = (*Wal)(unsafe.Pointer(pWal)).FnCkpt } // Move the write position of the WAL back to the point identified by @@ -40280,20 +39670,20 @@ func Xsqlite3WalSavepoint(tls *libc.TLS, pWal uintptr, aWalData uintptr) { /* sq // of WAL_SAVEPOINT_NDATA u32 values that has been previously populated // by a call to WalSavepoint(). func Xsqlite3WalSavepointUndo(tls *libc.TLS, pWal uintptr, aWalData uintptr) int32 { /* sqlite3.c:62702:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK - if *(*U32)(unsafe.Pointer(aWalData + uintptr(3)*4)) != (*Wal)(unsafe.Pointer(pWal)).FnCkpt { + if *(*U32)(unsafe.Pointer(aWalData + 3*4)) != (*Wal)(unsafe.Pointer(pWal)).FnCkpt { // This savepoint was opened immediately after the write-transaction // was started. Right after that, the writer decided to wrap around // to the start of the log. Update the savepoint values to match. - *(*U32)(unsafe.Pointer(aWalData + uintptr(0)*4)) = U32(0) - *(*U32)(unsafe.Pointer(aWalData + uintptr(3)*4)) = (*Wal)(unsafe.Pointer(pWal)).FnCkpt + *(*U32)(unsafe.Pointer(aWalData)) = U32(0) + *(*U32)(unsafe.Pointer(aWalData + 3*4)) = (*Wal)(unsafe.Pointer(pWal)).FnCkpt } - if *(*U32)(unsafe.Pointer(aWalData + uintptr(0)*4)) < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame { - (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = *(*U32)(unsafe.Pointer(aWalData + uintptr(0)*4)) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) = *(*U32)(unsafe.Pointer(aWalData + uintptr(1)*4)) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) = *(*U32)(unsafe.Pointer(aWalData + uintptr(2)*4)) + if *(*U32)(unsafe.Pointer(aWalData)) < (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame { + (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame = *(*U32)(unsafe.Pointer(aWalData)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) = *(*U32)(unsafe.Pointer(aWalData + 1*4)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) = *(*U32)(unsafe.Pointer(aWalData + 2*4)) walCleanupHash(tls, pWal) } @@ -40314,18 +39704,18 @@ func walRestartLog(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3.c:62739:12: * bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var cnt int32 if int32((*Wal)(unsafe.Pointer(pWal)).FreadLock) == 0 { var pInfo uintptr = walCkptInfo(tls, pWal) - if (*WalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill > U32(0) { + if (*WalCkptInfo)(unsafe.Pointer(libc.AtomicLoadUintptr(&pInfo))).FnBackfill > U32(0) { // var salt1 U32 at bp, 4 Xsqlite3_randomness(tls, 4, bp /* &salt1 */) - rc = walLockExclusive(tls, pWal, (3 + (1)), ((8 - 3) - 1)) - if rc == 0 { + rc = walLockExclusive(tls, pWal, (3 + (1)), ((SQLITE_SHM_NLOCK - 3) - 1)) + if rc == SQLITE_OK { // If all readers are using WAL_READ_LOCK(0) (in other words if no // readers are currently using the WAL), then the transactions // frames will overwrite the start of the existing log. Update the @@ -40336,8 +39726,8 @@ func walRestartLog(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3.c:62739:12: * // safe and means there is no special case for sqlite3WalUndo() // to handle if this transaction is rolled back. walRestartHdr(tls, pWal, *(*U32)(unsafe.Pointer(bp /* salt1 */))) - walUnlockExclusive(tls, pWal, (3 + (1)), ((8 - 3) - 1)) - } else if rc != 5 { + walUnlockExclusive(tls, pWal, (3 + (1)), ((SQLITE_SHM_NLOCK - 3) - 1)) + } else if rc != SQLITE_BUSY { return rc } } @@ -40429,16 +39819,16 @@ func walRewriteChecksums(tls *libc.TLS, pWal uintptr, iLast U32) int32 { /* sqli defer tls.Free(24) var szPage int32 = int32((*Wal)(unsafe.Pointer(pWal)).FszPage) // Database page size - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var aBuf uintptr // Buffer to load data from wal file into // var aFrame [24]U8 at bp, 24 // Buffer to assemble frame-headers in var iRead U32 // Next frame to read from wal file var iCksumOff I64 - aBuf = Xsqlite3_malloc(tls, (szPage + 24)) + aBuf = Xsqlite3_malloc(tls, (szPage + WAL_FRAME_HDRSIZE)) if aBuf == uintptr(0) { - return 7 + return SQLITE_NOMEM } // Find the checksum values to use as input for the recalculating the @@ -40450,24 +39840,24 @@ func walRewriteChecksums(tls *libc.TLS, pWal uintptr, iLast U32) int32 { /* sqli if (*Wal)(unsafe.Pointer(pWal)).FiReCksum == U32(1) { iCksumOff = int64(24) } else { - iCksumOff = ((int64(32) + ((I64(((*Wal)(unsafe.Pointer(pWal)).FiReCksum - U32(1)) - U32(1))) * (I64((szPage) + 24)))) + int64(16)) + iCksumOff = ((WAL_HDRSIZE + ((I64(((*Wal)(unsafe.Pointer(pWal)).FiReCksum - U32(1)) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) + int64(16)) } rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aBuf, (int32(uint64(unsafe.Sizeof(U32(0))) * uint64(2))), iCksumOff) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) = Xsqlite3Get4byte(tls, aBuf) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) = Xsqlite3Get4byte(tls, (aBuf + uintptr(uint64(unsafe.Sizeof(U32(0)))))) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) = Xsqlite3Get4byte(tls, aBuf) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) = Xsqlite3Get4byte(tls, (aBuf + 4)) iRead = (*Wal)(unsafe.Pointer(pWal)).FiReCksum (*Wal)(unsafe.Pointer(pWal)).FiReCksum = U32(0) - for ; (rc == 0) && (iRead <= iLast); iRead++ { - var iOff I64 = (int64(32) + ((I64((iRead) - U32(1))) * (I64((szPage) + 24)))) - rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aBuf, (szPage + 24), iOff) - if rc == 0 { + for ; (rc == SQLITE_OK) && (iRead <= iLast); iRead++ { + var iOff I64 = (WAL_HDRSIZE + ((I64((iRead) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) + rc = Xsqlite3OsRead(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, aBuf, (szPage + WAL_FRAME_HDRSIZE), iOff) + if rc == SQLITE_OK { var iPgno U32 var nDbSize U32 iPgno = Xsqlite3Get4byte(tls, aBuf) - nDbSize = Xsqlite3Get4byte(tls, (aBuf + uintptr(4))) + nDbSize = Xsqlite3Get4byte(tls, (aBuf + 4)) - walEncodeFrame(tls, pWal, iPgno, nDbSize, (aBuf + uintptr(24)), bp /* &aFrame[0] */) + walEncodeFrame(tls, pWal, iPgno, nDbSize, (aBuf + 24), bp /* &aFrame[0] */) rc = Xsqlite3OsWrite(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp /* &aFrame[0] */, int32(unsafe.Sizeof([24]U8{})), iOff) } } @@ -40504,7 +39894,7 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, // See if it is possible to write these frames into the start of the // log file, instead of appending to it at pWal->hdr.mxFrame. - if 0 != (libc.AssignInt32(&rc, walRestartLog(tls, pWal))) { + if SQLITE_OK != (libc.AssignInt32(&rc, walRestartLog(tls, pWal))) { return rc } @@ -40518,27 +39908,27 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, // var aCksum [2]U32 at bp+32, 8 // Checksum for wal-header - Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + uintptr(0)), (uint32(0x377f0682 | 0))) - Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + uintptr(4)), uint32(3007000)) - Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + uintptr(8)), uint32(szPage)) - Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + uintptr(12)), (*Wal)(unsafe.Pointer(pWal)).FnCkpt) + Xsqlite3Put4byte(tls, (bp /* &aWalHdr */), (uint32(WAL_MAGIC | SQLITE_BIGENDIAN))) + Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + 4), WAL_MAX_VERSION) + Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + 8), uint32(szPage)) + Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + 12), (*Wal)(unsafe.Pointer(pWal)).FnCkpt) if (*Wal)(unsafe.Pointer(pWal)).FnCkpt == U32(0) { Xsqlite3_randomness(tls, 8, pWal+72 /* &.hdr */ +32 /* &.aSalt */) } - libc.Xmemcpy(tls, (bp /* &aWalHdr */ + uintptr(16)), pWal+72 /* &.hdr */ +32 /* &.aSalt */, uint64(8)) - walChecksumBytes(tls, 1, bp /* &aWalHdr[0] */, (32 - (2 * 4)), uintptr(0), bp+32 /* &aCksum[0] */) - Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + uintptr(24)), *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */ + uintptr(0)*4))) - Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + uintptr(28)), *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */ + uintptr(1)*4))) + libc.Xmemcpy(tls, (bp /* &aWalHdr */ + 16), pWal+72 /* &.hdr */ +32 /* &.aSalt */, uint64(8)) + walChecksumBytes(tls, 1, bp /* &aWalHdr[0] */, (WAL_HDRSIZE - (2 * 4)), uintptr(0), bp+32 /* &aCksum[0] */) + Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + 24), *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */))) + Xsqlite3Put4byte(tls, (bp /* &aWalHdr */ + 28), *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */ + 1*4))) (*Wal)(unsafe.Pointer(pWal)).FszPage = U32(szPage) - (*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum = U8(0) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(0)*4)) = *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */ + uintptr(0)*4)) - *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + uintptr(1)*4)) = *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */ + uintptr(1)*4)) + (*Wal)(unsafe.Pointer(pWal)).Fhdr.FbigEndCksum = SQLITE_BIGENDIAN + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */))) = *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */)) + *(*U32)(unsafe.Pointer((pWal + 72 /* &.hdr */ + 24 /* &.aFrameCksum */) + 1*4)) = *(*U32)(unsafe.Pointer(bp + 32 /* &aCksum[0] */ + 1*4)) (*Wal)(unsafe.Pointer(pWal)).FtruncateOnCommit = U8(1) rc = Xsqlite3OsWrite(tls, (*Wal)(unsafe.Pointer(pWal)).FpWalFd, bp /* &aWalHdr[0] */, int32(unsafe.Sizeof([32]U8{})), int64(0)) - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -40562,8 +39952,8 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, (*WalWriter)(unsafe.Pointer(bp + 48 /* &w */)).FiSyncPoint = int64(0) (*WalWriter)(unsafe.Pointer(bp + 48 /* &w */)).FsyncFlags = sync_flags (*WalWriter)(unsafe.Pointer(bp + 48 /* &w */)).FszPage = szPage - iOffset = (int64(32) + ((I64((iFrame + U32(1)) - U32(1))) * (I64((szPage) + 24)))) - szFrame = (szPage + 24) + iOffset = (WAL_HDRSIZE + ((I64((iFrame + U32(1)) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) + szFrame = (szPage + WAL_FRAME_HDRSIZE) // Write all frames into the log file exactly once for p = pList; p != 0; p = (*PgHdr)(unsafe.Pointer(p)).FpDirty { @@ -40578,7 +39968,7 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, Xsqlite3WalFindFrame(tls, pWal, (*PgHdr)(unsafe.Pointer(p)).Fpgno, bp+40 /* &iWrite */) if *(*U32)(unsafe.Pointer(bp + 40 /* iWrite */)) >= iFirst { - var iOff I64 = ((int64(32) + ((I64((*(*U32)(unsafe.Pointer(bp + 40 /* iWrite */))) - U32(1))) * (I64((szPage) + 24)))) + int64(24)) + var iOff I64 = ((WAL_HDRSIZE + ((I64((*(*U32)(unsafe.Pointer(bp + 40 /* iWrite */))) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) + WAL_FRAME_HDRSIZE) var pData uintptr if ((*Wal)(unsafe.Pointer(pWal)).FiReCksum == U32(0)) || (*(*U32)(unsafe.Pointer(bp + 40 /* iWrite */)) < (*Wal)(unsafe.Pointer(pWal)).FiReCksum) { (*Wal)(unsafe.Pointer(pWal)).FiReCksum = *(*U32)(unsafe.Pointer(bp + 40 /* iWrite */)) @@ -40588,7 +39978,7 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, if rc != 0 { return rc } - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x040))) + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(PGHDR_WAL_APPEND))) continue } } @@ -40606,7 +39996,7 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, } pLast = p iOffset = iOffset + (I64(szFrame)) - *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) |= U16((0x040)) + *(*U16)(unsafe.Pointer(p + 52 /* &.flags */)) |= U16((PGHDR_WAL_APPEND)) } // Recalculate checksums within the wal file if required. @@ -40658,8 +40048,8 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, // journal size limit, if possible. if ((isCommit != 0) && ((*Wal)(unsafe.Pointer(pWal)).FtruncateOnCommit != 0)) && ((*Wal)(unsafe.Pointer(pWal)).FmxWalSize >= int64(0)) { var sz I64 = (*Wal)(unsafe.Pointer(pWal)).FmxWalSize - if (int64(32) + ((I64(((iFrame + U32(nExtra)) + U32(1)) - U32(1))) * (I64((szPage) + 24)))) > (*Wal)(unsafe.Pointer(pWal)).FmxWalSize { - sz = (int64(32) + ((I64(((iFrame + U32(nExtra)) + U32(1)) - U32(1))) * (I64((szPage) + 24)))) + if (WAL_HDRSIZE + ((I64(((iFrame + U32(nExtra)) + U32(1)) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) > (*Wal)(unsafe.Pointer(pWal)).FmxWalSize { + sz = (WAL_HDRSIZE + ((I64(((iFrame + U32(nExtra)) + U32(1)) - U32(1))) * (I64((szPage) + WAL_FRAME_HDRSIZE)))) } walLimitSize(tls, pWal, sz) (*Wal)(unsafe.Pointer(pWal)).FtruncateOnCommit = U8(0) @@ -40670,21 +40060,21 @@ func Xsqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, // guarantees that there are no other writers, and no data that may // be in use by existing readers is being overwritten. iFrame = (*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame - for p = pList; (p != 0) && (rc == 0); p = (*PgHdr)(unsafe.Pointer(p)).FpDirty { - if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & 0x040) == 0 { + for p = pList; (p != 0) && (rc == SQLITE_OK); p = (*PgHdr)(unsafe.Pointer(p)).FpDirty { + if (int32((*PgHdr)(unsafe.Pointer(p)).Fflags) & PGHDR_WAL_APPEND) == 0 { continue } iFrame++ rc = walIndexAppend(tls, pWal, iFrame, (*PgHdr)(unsafe.Pointer(p)).Fpgno) } - for (rc == 0) && (nExtra > 0) { + for (rc == SQLITE_OK) && (nExtra > 0) { iFrame++ nExtra-- rc = walIndexAppend(tls, pWal, iFrame, (*PgHdr)(unsafe.Pointer(pLast)).Fpgno) } - if rc == 0 { + if rc == SQLITE_OK { // Update the private copy of the header. (*Wal)(unsafe.Pointer(pWal)).Fhdr.FszPage = (U16((szPage & 0xff00) | (szPage >> 16))) @@ -40724,7 +40114,7 @@ func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, // in the SQLITE_CHECKPOINT_PASSIVE mode. if (*Wal)(unsafe.Pointer(pWal)).FreadOnly != 0 { - return 8 + return SQLITE_READONLY } // Enable blocking locks, if possible. If blocking locks are successfully @@ -40737,9 +40127,9 @@ func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, // SQLITE_BUSY is returned. // EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured, // it will not be invoked in this case. - rc = walLockExclusive(tls, pWal, 1, 1) + rc = walLockExclusive(tls, pWal, WAL_CKPT_LOCK, 1) - if rc == 0 { + if rc == SQLITE_OK { (*Wal)(unsafe.Pointer(pWal)).FckptLock = U8(1) // IMPLEMENTATION-OF: R-59782-36818 The SQLITE_CHECKPOINT_FULL, RESTART and @@ -40750,20 +40140,20 @@ func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, // immediately, and a busy-handler is configured, it is invoked and the // writer lock retried until either the busy-handler returns 0 or the // lock is successfully obtained. - if eMode != 0 { - rc = walBusyLock(tls, pWal, xBusy2, pBusyArg, 0, 1) - if rc == 0 { + if eMode != SQLITE_CHECKPOINT_PASSIVE { + rc = walBusyLock(tls, pWal, xBusy2, pBusyArg, WAL_WRITE_LOCK, 1) + if rc == SQLITE_OK { (*Wal)(unsafe.Pointer(pWal)).FwriteLock = U8(1) - } else if rc == 5 { - eMode2 = 0 + } else if rc == SQLITE_BUSY { + eMode2 = SQLITE_CHECKPOINT_PASSIVE xBusy2 = uintptr(0) - rc = 0 + rc = SQLITE_OK } } } // Read the wal-index header. - if rc == 0 { + if rc == SQLITE_OK { rc = walIndexReadHdr(tls, pWal, bp /* &isChanged */) @@ -40773,7 +40163,7 @@ func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, } // Copy data from the log to the database file. - if rc == 0 { + if rc == SQLITE_OK { if ((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame != 0) && (walPagesize(tls, pWal) != nBuf) { rc = Xsqlite3CorruptError(tls, 63222) @@ -40782,7 +40172,7 @@ func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, } // If no error occurred, set the output variables. - if (rc == 0) || (rc == 5) { + if (rc == SQLITE_OK) || (rc == SQLITE_BUSY) { if pnLog != 0 { *(*int32)(unsafe.Pointer(pnLog)) = int32((*Wal)(unsafe.Pointer(pWal)).Fhdr.FmxFrame) } @@ -40804,13 +40194,13 @@ func Xsqlite3WalCheckpoint(tls *libc.TLS, pWal uintptr, db uintptr, eMode int32, // Release the locks. Xsqlite3WalEndWriteTransaction(tls, pWal) if (*Wal)(unsafe.Pointer(pWal)).FckptLock != 0 { - walUnlockExclusive(tls, pWal, 1, 1) + walUnlockExclusive(tls, pWal, WAL_CKPT_LOCK, 1) (*Wal)(unsafe.Pointer(pWal)).FckptLock = U8(0) } return func() int32 { - if (rc == 0) && (eMode != eMode2) { - return 5 + if (rc == SQLITE_OK) && (eMode != eMode2) { + return SQLITE_BUSY } return rc }() @@ -40861,12 +40251,12 @@ func Xsqlite3WalExclusiveMode(tls *libc.TLS, pWal uintptr, op int32) int32 { /* // upgrade to exclusive-mode following such an error. if op == 0 { - if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != 0 { - (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(0) - if walLockShared(tls, pWal, (3+(int32((*Wal)(unsafe.Pointer(pWal)).FreadLock)))) != 0 { - (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(1) + if int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) != WAL_NORMAL_MODE { + (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = WAL_NORMAL_MODE + if walLockShared(tls, pWal, (3+(int32((*Wal)(unsafe.Pointer(pWal)).FreadLock)))) != SQLITE_OK { + (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = WAL_EXCLUSIVE_MODE } - rc = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == 0)) + rc = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_NORMAL_MODE)) } else { // Already in locking_mode=NORMAL rc = 0 @@ -40874,10 +40264,10 @@ func Xsqlite3WalExclusiveMode(tls *libc.TLS, pWal uintptr, op int32) int32 { /* } else if op > 0 { walUnlockShared(tls, pWal, (3 + (int32((*Wal)(unsafe.Pointer(pWal)).FreadLock)))) - (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = U8(1) + (*Wal)(unsafe.Pointer(pWal)).FexclusiveMode = WAL_EXCLUSIVE_MODE rc = 1 } else { - rc = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == 0)) + rc = (libc.Bool32(int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_NORMAL_MODE)) } return rc } @@ -40886,23 +40276,23 @@ func Xsqlite3WalExclusiveMode(tls *libc.TLS, pWal uintptr, op int32) int32 { /* // heap-memory for the wal-index. Otherwise, if the argument is NULL or the // WAL module is using shared-memory, return false. func Xsqlite3WalHeapMemory(tls *libc.TLS, pWal uintptr) int32 { /* sqlite3.c:63340:20: */ - return (libc.Bool32((pWal != 0) && (int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == 2))) + return (libc.Bool32((pWal != 0) && (int32((*Wal)(unsafe.Pointer(pWal)).FexclusiveMode) == WAL_HEAPMEMORY_MODE))) } // Create a snapshot object. The content of a snapshot is opaque to // every other subsystem, so the WAL module can put whatever it needs // in the object. func Xsqlite3WalSnapshotGet(tls *libc.TLS, pWal uintptr, ppSnapshot uintptr) int32 { /* sqlite3.c:63349:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pRet uintptr - if libc.Xmemcmp(tls, ((pWal+72 /* &.hdr */ +24 /* &.aFrameCksum */)+uintptr(0)*4), uintptr(unsafe.Pointer(&aZero)), uint64(16)) == 0 { + if libc.Xmemcmp(tls, (pWal+72 /* &.hdr */ +24 /* &.aFrameCksum */), uintptr(unsafe.Pointer(&aZero)), uint64(16)) == 0 { *(*uintptr)(unsafe.Pointer(ppSnapshot)) = uintptr(0) - return 1 + return SQLITE_ERROR } pRet = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(WalIndexHdr{}))) if pRet == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemcpy(tls, pRet, (pWal + 72 /* &.hdr */), uint64(unsafe.Sizeof(WalIndexHdr{}))) *(*uintptr)(unsafe.Pointer(ppSnapshot)) = pRet @@ -40926,10 +40316,10 @@ func Xsqlite3_snapshot_cmp(tls *libc.TLS, p1 uintptr, p2 uintptr) int32 { /* sql // aSalt[0] is a copy of the value stored in the wal file header. It // is incremented each time the wal file is restarted. - if *(*U32)(unsafe.Pointer((pHdr1 + 32 /* &.aSalt */) + uintptr(0)*4)) < *(*U32)(unsafe.Pointer((pHdr2 + 32 /* &.aSalt */) + uintptr(0)*4)) { + if *(*U32)(unsafe.Pointer((pHdr1 + 32 /* &.aSalt */))) < *(*U32)(unsafe.Pointer((pHdr2 + 32 /* &.aSalt */))) { return -1 } - if *(*U32)(unsafe.Pointer((pHdr1 + 32 /* &.aSalt */) + uintptr(0)*4)) > *(*U32)(unsafe.Pointer((pHdr2 + 32 /* &.aSalt */) + uintptr(0)*4)) { + if *(*U32)(unsafe.Pointer((pHdr1 + 32 /* &.aSalt */))) > *(*U32)(unsafe.Pointer((pHdr2 + 32 /* &.aSalt */))) { return +1 } if (*WalIndexHdr)(unsafe.Pointer(pHdr1)).FmxFrame < (*WalIndexHdr)(unsafe.Pointer(pHdr2)).FmxFrame { @@ -40952,13 +40342,13 @@ func Xsqlite3_snapshot_cmp(tls *libc.TLS, p1 uintptr, p2 uintptr) int32 { /* sql // lock is released before returning. func Xsqlite3WalSnapshotCheck(tls *libc.TLS, pWal uintptr, pSnapshot uintptr) int32 { /* sqlite3.c:63408:20: */ var rc int32 - rc = walLockShared(tls, pWal, 1) - if rc == 0 { + rc = walLockShared(tls, pWal, WAL_CKPT_LOCK) + if rc == SQLITE_OK { var pNew uintptr = pSnapshot if (libc.Xmemcmp(tls, pNew+32 /* &.aSalt */, pWal+72 /* &.hdr */ +32 /* &.aSalt */, uint64(unsafe.Sizeof([2]U32{}))) != 0) || ((*WalIndexHdr)(unsafe.Pointer(pNew)).FmxFrame < (*WalCkptInfo)(unsafe.Pointer(walCkptInfo(tls, pWal))).FnBackfillAttempted) { - rc = (1 | (int32(3) << 8)) - walUnlockShared(tls, pWal, 1) + rc = (SQLITE_ERROR | (int32(3) << 8)) + walUnlockShared(tls, pWal, WAL_CKPT_LOCK) } } return rc @@ -40968,7 +40358,7 @@ func Xsqlite3WalSnapshotCheck(tls *libc.TLS, pWal uintptr, pSnapshot uintptr) in // sqlite3WalSnapshotCheck(). func Xsqlite3WalSnapshotUnlock(tls *libc.TLS, pWal uintptr) { /* sqlite3.c:63427:21: */ - walUnlockShared(tls, pWal, 1) + walUnlockShared(tls, pWal, WAL_CKPT_LOCK) } // Return the sqlite3_file object for the WAL file @@ -41795,7 +41185,7 @@ func btreeLockCarefully(tls *libc.TLS, p uintptr) { /* sqlite3.c:64277:29: */ // In most cases, we should be able to acquire the lock we // want without having to go through the ascending lock // procedure that follows. Just be sure not to block. - if Xsqlite3_mutex_try(tls, (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).Fmutex) == 0 { + if Xsqlite3_mutex_try(tls, (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).Fmutex) == SQLITE_OK { (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).Fdb = (*Btree)(unsafe.Pointer(p)).Fdb (*Btree)(unsafe.Pointer(p)).Flocked = U8(1) return @@ -41949,7 +41339,7 @@ var Xsqlite3SharedCacheList uintptr = uintptr(0) /* sqlite3.c:64558:25 */ // sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2(). func Xsqlite3_enable_shared_cache(tls *libc.TLS, enable int32) int32 { /* sqlite3.c:64572:16: */ Xsqlite3Config.FsharedCacheEnabled = enable - return 0 + return SQLITE_OK } // Implementation of the SQLITE_CORRUPT_PAGE() macro. Takes a single @@ -41974,14 +41364,14 @@ func querySharedCacheTableLock(tls *libc.TLS, p uintptr, iTab Pgno, eLock U8) in // This routine is a no-op if the shared-cache is not enabled if !(int32((*Btree)(unsafe.Pointer(p)).Fsharable) != 0) { - return 0 + return SQLITE_OK } // If some other connection is holding an exclusive lock, the // requested lock may not be obtained. - if ((*BtShared)(unsafe.Pointer(pBt)).FpWriter != p) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0040) != 0) { + if ((*BtShared)(unsafe.Pointer(pBt)).FpWriter != p) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_EXCLUSIVE) != 0) { Xsqlite3ConnectionBlocked(tls, (*Btree)(unsafe.Pointer(p)).Fdb, (*Btree)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpWriter)).Fdb) - return (6 | (int32(1) << 8)) + return (SQLITE_LOCKED | (int32(1) << 8)) } for pIter = (*BtShared)(unsafe.Pointer(pBt)).FpLock; pIter != 0; pIter = (*BtLock)(unsafe.Pointer(pIter)).FpNext { @@ -41996,14 +41386,14 @@ func querySharedCacheTableLock(tls *libc.TLS, p uintptr, iTab Pgno, eLock U8) in if (((*BtLock)(unsafe.Pointer(pIter)).FpBtree != p) && ((*BtLock)(unsafe.Pointer(pIter)).FiTable == iTab)) && (int32((*BtLock)(unsafe.Pointer(pIter)).FeLock) != int32(eLock)) { Xsqlite3ConnectionBlocked(tls, (*Btree)(unsafe.Pointer(p)).Fdb, (*Btree)(unsafe.Pointer((*BtLock)(unsafe.Pointer(pIter)).FpBtree)).Fdb) - if int32(eLock) == 2 { + if int32(eLock) == WRITE_LOCK { - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0080)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_PENDING)) } - return (6 | (int32(1) << 8)) + return (SQLITE_LOCKED | (int32(1) << 8)) } } - return 0 + return SQLITE_OK } // Add a lock on the table with root-page iTable to the shared-btree used @@ -42047,7 +41437,7 @@ func setSharedCacheTableLock(tls *libc.TLS, p uintptr, iTable Pgno, eLock U8) in if !(pLock != 0) { pLock = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(BtLock{}))) if !(pLock != 0) { - return 7 + return SQLITE_NOMEM } (*BtLock)(unsafe.Pointer(pLock)).FiTable = iTable (*BtLock)(unsafe.Pointer(pLock)).FpBtree = p @@ -42063,7 +41453,7 @@ func setSharedCacheTableLock(tls *libc.TLS, p uintptr, iTable Pgno, eLock U8) in (*BtLock)(unsafe.Pointer(pLock)).FeLock = eLock } - return 0 + return SQLITE_OK } // Release all the table locks (locks obtained via calls to @@ -42092,7 +41482,7 @@ func clearAllSharedCacheTableLocks(tls *libc.TLS, p uintptr) { /* sqlite3.c:6489 if (*BtShared)(unsafe.Pointer(pBt)).FpWriter == p { (*BtShared)(unsafe.Pointer(pBt)).FpWriter = uintptr(0) - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32((0x0040 | 0x0080)))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32((BTS_EXCLUSIVE | BTS_PENDING)))) } else if (*BtShared)(unsafe.Pointer(pBt)).FnTransaction == 2 { // This function is called when Btree p is concluding its // transaction. If there currently exists a writer, and p is not @@ -42102,7 +41492,7 @@ func clearAllSharedCacheTableLocks(tls *libc.TLS, p uintptr) { /* sqlite3.c:6489 // // If there is not currently a writer, then BTS_PENDING must // be zero already. So this next line is harmless in that case. - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0080))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_PENDING))) } } @@ -42112,10 +41502,10 @@ func downgradeAllSharedCacheTableLocks(tls *libc.TLS, p uintptr) { /* sqlite3.c: if (*BtShared)(unsafe.Pointer(pBt)).FpWriter == p { var pLock uintptr (*BtShared)(unsafe.Pointer(pBt)).FpWriter = uintptr(0) - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32((0x0040 | 0x0080)))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32((BTS_EXCLUSIVE | BTS_PENDING)))) for pLock = (*BtShared)(unsafe.Pointer(pBt)).FpLock; pLock != 0; pLock = (*BtLock)(unsafe.Pointer(pLock)).FpNext { - (*BtLock)(unsafe.Pointer(pLock)).FeLock = U8(1) + (*BtLock)(unsafe.Pointer(pLock)).FeLock = READ_LOCK } } } @@ -42135,7 +41525,7 @@ func invalidateAllOverflowCache(tls *libc.TLS, pBt uintptr) { /* sqlite3.c:64993 var p uintptr for p = (*BtShared)(unsafe.Pointer(pBt)).FpCursor; p != 0; p = (*BtCursor)(unsafe.Pointer(p)).FpNext { - *(*U8)(unsafe.Pointer(p + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x04))) + *(*U8)(unsafe.Pointer(p + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_ValidOvfl))) } } @@ -42158,10 +41548,10 @@ func invalidateIncrblobCursors(tls *libc.TLS, pBtree uintptr, pgnoRoot Pgno, iRo (*Btree)(unsafe.Pointer(pBtree)).FhasIncrblobCur = U8(0) for p = (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBtree)).FpBt)).FpCursor; p != 0; p = (*BtCursor)(unsafe.Pointer(p)).FpNext { - if (int32((*BtCursor)(unsafe.Pointer(p)).FcurFlags) & 0x10) != 0 { + if (int32((*BtCursor)(unsafe.Pointer(p)).FcurFlags) & BTCF_Incrblob) != 0 { (*Btree)(unsafe.Pointer(pBtree)).FhasIncrblobCur = U8(1) if ((*BtCursor)(unsafe.Pointer(p)).FpgnoRoot == pgnoRoot) && ((isClearTable != 0) || ((*BtCursor)(unsafe.Pointer(p)).Finfo.FnKey == iRow)) { - (*BtCursor)(unsafe.Pointer(p)).FeState = U8(1) + (*BtCursor)(unsafe.Pointer(p)).FeState = CURSOR_INVALID } } } @@ -42201,15 +41591,15 @@ func invalidateIncrblobCursors(tls *libc.TLS, pBtree uintptr, pgnoRoot Pgno, iRo // set in BtShared.pHasContent. The contents of the bitvec are cleared // at the end of every transaction. func btreeSetHasContent(tls *libc.TLS, pBt uintptr, pgno Pgno) int32 { /* sqlite3.c:65075:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if !(int32((*BtShared)(unsafe.Pointer(pBt)).FpHasContent) != 0) { (*BtShared)(unsafe.Pointer(pBt)).FpHasContent = Xsqlite3BitvecCreate(tls, (*BtShared)(unsafe.Pointer(pBt)).FnPage) if !(int32((*BtShared)(unsafe.Pointer(pBt)).FpHasContent) != 0) { - rc = 7 + rc = SQLITE_NOMEM } } - if (rc == 0) && (pgno <= Xsqlite3BitvecSize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpHasContent)) { + if (rc == SQLITE_OK) && (pgno <= Xsqlite3BitvecSize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpHasContent)) { rc = Xsqlite3BitvecSet(tls, (*BtShared)(unsafe.Pointer(pBt)).FpHasContent, pgno) } return rc @@ -42256,7 +41646,7 @@ func btreeReleaseAllCursorPages(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:6511 // set to point to a malloced buffer pCur->nKey bytes in size containing // the key. func saveCursorKey(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:65138:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*BtCursor)(unsafe.Pointer(pCur)).FcurIntKey != 0 { // Only the rowid is required for a table btree @@ -42273,14 +41663,14 @@ func saveCursorKey(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:65138:12: * pKey = Xsqlite3Malloc(tls, (uint64(((*BtCursor)(unsafe.Pointer(pCur)).FnKey + int64(9)) + int64(8)))) if pKey != 0 { rc = Xsqlite3BtreePayload(tls, pCur, uint32(0), uint32(int32((*BtCursor)(unsafe.Pointer(pCur)).FnKey)), pKey) - if rc == 0 { + if rc == SQLITE_OK { libc.Xmemset(tls, ((pKey) + uintptr((*BtCursor)(unsafe.Pointer(pCur)).FnKey)), 0, (uint64(9 + 8))) (*BtCursor)(unsafe.Pointer(pCur)).FpKey = pKey } else { Xsqlite3_free(tls, pKey) } } else { - rc = 7 + rc = SQLITE_NOMEM } } @@ -42295,22 +41685,22 @@ func saveCursorKey(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:65138:12: * func saveCursorPosition(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:65180:12: */ var rc int32 - if (int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x40) != 0 { - return (19 | (int32(11) << 8)) + if (int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_Pinned) != 0 { + return (SQLITE_CONSTRAINT | (int32(11) << 8)) } - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 2 { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(0) + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_SKIPNEXT { + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_VALID } else { (*BtCursor)(unsafe.Pointer(pCur)).FskipNext = 0 } rc = saveCursorKey(tls, pCur) - if rc == 0 { + if rc == SQLITE_OK { btreeReleaseAllCursorPages(tls, pCur) - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(3) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_REQUIRESEEK } - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(((0x02 | 0x04) | 0x08)))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(((BTCF_ValidNKey | BTCF_ValidOvfl) | BTCF_AtLast)))) return rc } @@ -42345,9 +41735,9 @@ func saveAllCursors(tls *libc.TLS, pBt uintptr, iRoot Pgno, pExcept uintptr) int return saveCursorsOnList(tls, p, iRoot, pExcept) } if pExcept != 0 { - *(*U8)(unsafe.Pointer(pExcept + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x20))) + *(*U8)(unsafe.Pointer(pExcept + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_Multiple))) } - return 0 + return SQLITE_OK } // This helper routine to saveAllCursors does the actual work of saving @@ -42357,9 +41747,9 @@ func saveAllCursors(tls *libc.TLS, pBt uintptr, iRoot Pgno, pExcept uintptr) int func saveCursorsOnList(tls *libc.TLS, p uintptr, iRoot Pgno, pExcept uintptr) int32 { /* sqlite3.c:65247:28: */ for ok := true; ok; ok = p != 0 { if (p != pExcept) && ((Pgno(0) == iRoot) || ((*BtCursor)(unsafe.Pointer(p)).FpgnoRoot == iRoot)) { - if (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == 0) || (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == 2) { + if (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_VALID) || (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_SKIPNEXT) { var rc int32 = saveCursorPosition(tls, p) - if 0 != rc { + if SQLITE_OK != rc { return rc } } else { @@ -42369,7 +41759,7 @@ func saveCursorsOnList(tls *libc.TLS, p uintptr, iRoot Pgno, pExcept uintptr) in } p = (*BtCursor)(unsafe.Pointer(p)).FpNext } - return 0 + return SQLITE_OK } // Clear the current cursor position. @@ -42377,7 +41767,7 @@ func Xsqlite3BtreeClearCursor(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:65272: Xsqlite3_free(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpKey) (*BtCursor)(unsafe.Pointer(pCur)).FpKey = uintptr(0) - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID } // In this version of BtreeMoveto, pKey is a packed index record @@ -42397,7 +41787,7 @@ func btreeMoveto(tls *libc.TLS, pCur uintptr, pKey uintptr, nKey I64, bias int32 if !(pIdxKey == uintptr(0)) { goto __3 } - return 7 + return SQLITE_NOMEM __3: ; Xsqlite3VdbeRecordUnpack(tls, pKeyInfo, int32(nKey), pKey, pIdxKey) @@ -42436,24 +41826,24 @@ func btreeRestoreCursorPosition(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3. var rc int32 *(*int32)(unsafe.Pointer(bp /* skipNext */)) = 0 - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 4 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_FAULT { return (*BtCursor)(unsafe.Pointer(pCur)).FskipNext } - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID if Xsqlite3FaultSim(tls, 410) != 0 { - rc = 10 + rc = SQLITE_IOERR } else { rc = btreeMoveto(tls, pCur, (*BtCursor)(unsafe.Pointer(pCur)).FpKey, (*BtCursor)(unsafe.Pointer(pCur)).FnKey, 0, bp /* &skipNext */) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_free(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpKey) (*BtCursor)(unsafe.Pointer(pCur)).FpKey = uintptr(0) if *(*int32)(unsafe.Pointer(bp /* skipNext */)) != 0 { (*BtCursor)(unsafe.Pointer(pCur)).FskipNext = *(*int32)(unsafe.Pointer(bp /* skipNext */)) } - if ((*BtCursor)(unsafe.Pointer(pCur)).FskipNext != 0) && (int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 0) { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(2) + if ((*BtCursor)(unsafe.Pointer(pCur)).FskipNext != 0) && (int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID) { + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_SKIPNEXT } } return rc @@ -42471,7 +41861,7 @@ func btreeRestoreCursorPosition(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3. // back to where it ought to be if this routine returns true. func Xsqlite3BtreeCursorHasMoved(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:65365:20: */ - return (libc.Bool32(0 != int32(*(*U8)(unsafe.Pointer(pCur))))) + return (libc.Bool32(CURSOR_VALID != int32(*(*U8)(unsafe.Pointer(pCur))))) } // Return a pointer to a fake BtCursor object that will always answer @@ -42482,7 +41872,7 @@ func Xsqlite3BtreeFakeValidCursor(tls *libc.TLS) uintptr { /* sqlite3.c:65378:25 return uintptr(unsafe.Pointer(&fakeCursor)) } -var fakeCursor U8 = U8(0) /* sqlite3.c:65379:13 */ +var fakeCursor U8 = CURSOR_VALID /* sqlite3.c:65379:13 */ // This routine restores a cursor back to its original position after it // has been moved by some outside activity (such as a btree rebalance or @@ -42499,21 +41889,21 @@ func Xsqlite3BtreeCursorRestore(tls *libc.TLS, pCur uintptr, pDifferentRow uintp var rc int32 rc = func() int32 { - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= 3 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK { return btreeRestoreCursorPosition(tls, pCur) } - return 0 + return SQLITE_OK }() if rc != 0 { *(*int32)(unsafe.Pointer(pDifferentRow)) = 1 return rc } - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != 0 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { *(*int32)(unsafe.Pointer(pDifferentRow)) = 1 } else { *(*int32)(unsafe.Pointer(pDifferentRow)) = 0 } - return 0 + return SQLITE_OK } // Provide flag hints to the cursor. @@ -42583,14 +41973,14 @@ __2: ; iPtrmap = ptrmapPageno(tls, pBt, key) rc = Xsqlite3PagerGet(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, iPtrmap, bp /* &pDbPage */, 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __3 } *(*int32)(unsafe.Pointer(pRC)) = rc return __3: ; - if !(int32(*(*int8)(unsafe.Pointer((Xsqlite3PagerGetExtra(tls, *(*uintptr)(unsafe.Pointer(bp /* pDbPage */)))) + uintptr(0)))) != 0) { + if !(int32(*(*int8)(unsafe.Pointer((Xsqlite3PagerGetExtra(tls, *(*uintptr)(unsafe.Pointer(bp /* pDbPage */))))))) != 0) { goto __4 } // The first byte of the extra data is the MemPage.isInit byte. @@ -42616,7 +42006,7 @@ __5: } *(*int32)(unsafe.Pointer(pRC)) = libc.AssignInt32(&rc, Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp /* pDbPage */)))) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __7 } *(*U8)(unsafe.Pointer(pPtrmap + uintptr(offset))) = eType @@ -42668,7 +42058,7 @@ func ptrmapGet(tls *libc.TLS, pBt uintptr, key Pgno, pEType uintptr, pPgno uintp if (int32(*(*U8)(unsafe.Pointer(pEType))) < 1) || (int32(*(*U8)(unsafe.Pointer(pEType))) > 5) { return Xsqlite3CorruptError(tls, 65555) } - return 0 + return SQLITE_OK } // Given a btree page and a cell index (0 means the first cell on @@ -42724,7 +42114,7 @@ func btreeParseCellAdjustSizeForOverflow(tls *libc.TLS, pPage uintptr, pCell uin func btreeParseCellPtrNoPayload(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) { /* sqlite3.c:65632:13: */ _ = pPage - (*CellInfo)(unsafe.Pointer(pInfo)).FnSize = (U16(4 + int32(Xsqlite3GetVarint(tls, (pCell+uintptr(4)), (pInfo /* &.nKey */))))) + (*CellInfo)(unsafe.Pointer(pInfo)).FnSize = (U16(4 + int32(Xsqlite3GetVarint(tls, (pCell+4), (pInfo /* &.nKey */))))) (*CellInfo)(unsafe.Pointer(pInfo)).FnPayload = U32(0) (*CellInfo)(unsafe.Pointer(pInfo)).FnLocal = U16(0) (*CellInfo)(unsafe.Pointer(pInfo)).FpPayload = uintptr(0) @@ -42749,7 +42139,7 @@ func btreeParseCellPtr(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintpt // The code is inlined to avoid a function call. nPayload = U32(*(*U8)(unsafe.Pointer(pIter))) if nPayload >= U32(0x80) { - var pEnd uintptr = (pIter + uintptr(8)) + var pEnd uintptr = (pIter + 8) nPayload = nPayload & (U32(0x7f)) for ok := true; ok; ok = (((int32(*(*U8)(unsafe.Pointer(pIter)))) >= 0x80) && (pIter < pEnd)) { nPayload = ((nPayload << 7) | (U32(int32(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))) & 0x7f))) @@ -42764,7 +42154,7 @@ func btreeParseCellPtr(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintpt // The code is inlined to avoid a function call. *(*U64)(unsafe.Pointer(bp /* iKey */)) = U64(*(*U8)(unsafe.Pointer(pIter))) if *(*U64)(unsafe.Pointer(bp /* iKey */)) >= uint64(0x80) { - var pEnd uintptr = (pIter + uintptr(7)) + var pEnd uintptr = (pIter + 7) *(*U64)(unsafe.Pointer(bp /* iKey */)) &= uint64(0x7f) for 1 != 0 { *(*U64)(unsafe.Pointer(bp /* iKey */)) = ((*(*U64)(unsafe.Pointer(bp /* iKey */)) << 7) | (U64(int32(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))) & 0x7f))) @@ -42803,7 +42193,7 @@ func btreeParseCellPtrIndex(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo u pIter = (pCell + uintptr((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)) nPayload = U32(*(*U8)(unsafe.Pointer(pIter))) if nPayload >= U32(0x80) { - var pEnd uintptr = (pIter + uintptr(8)) + var pEnd uintptr = (pIter + 8) nPayload = nPayload & (U32(0x7f)) for ok := true; ok; ok = ((int32(*(*U8)(unsafe.Pointer(pIter))) >= 0x80) && (pIter < pEnd)) { nPayload = ((nPayload << 7) | (U32(int32(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))) & 0x7f))) @@ -42848,7 +42238,7 @@ func cellSizePtr(tls *libc.TLS, pPage uintptr, pCell uintptr) U16 { /* sqlite3.c nSize = U32(*(*U8)(unsafe.Pointer(pIter))) if nSize >= U32(0x80) { - pEnd = (pIter + uintptr(8)) + pEnd = (pIter + 8) nSize = nSize & (U32(0x7f)) for ok := true; ok; ok = ((int32(*(*U8)(unsafe.Pointer(pIter))) >= 0x80) && (pIter < pEnd)) { nSize = ((nSize << 7) | (U32(int32(*(*U8)(unsafe.Pointer(libc.PreIncUintptr(&pIter, 1)))) & 0x7f))) @@ -42859,7 +42249,7 @@ func cellSizePtr(tls *libc.TLS, pPage uintptr, pCell uintptr) U16 { /* sqlite3.c // pIter now points at the 64-bit integer key value, a variable length // integer. The following block moves pIter to point at the first byte // past the end of the key value. - pEnd = (pIter + uintptr(9)) + pEnd = (pIter + 9) for (((int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&pIter, 1))))) & 0x80) != 0) && (pIter < pEnd) { } } @@ -42918,7 +42308,7 @@ func ptrmapPutOvflPtr(tls *libc.TLS, pPage uintptr, pSrc uintptr, pCell uintptr, return } ovfl = Xsqlite3Get4byte(tls, (pCell + uintptr((int32((*CellInfo)(unsafe.Pointer(bp /* &info */)).FnSize) - 4)))) - ptrmapPut(tls, (*MemPage)(unsafe.Pointer(pPage)).FpBt, ovfl, uint8(3), (*MemPage)(unsafe.Pointer(pPage)).Fpgno, pRC) + ptrmapPut(tls, (*MemPage)(unsafe.Pointer(pPage)).FpBt, ovfl, PTRMAP_OVERFLOW1, (*MemPage)(unsafe.Pointer(pPage)).Fpgno, pRC) } } @@ -42973,7 +42363,7 @@ func defragmentPage(tls *libc.TLS, pPage uintptr, nMaxFrag int32) int32 { /* sql if !(int32(*(*uint8)(unsafe.Pointer(data + uintptr((hdr + 7))))) <= nMaxFrag) { goto __1 } - iFree = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 1))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 1))) + uintptr(1))))) + iFree = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 1)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 1))) + 1)))) if !(iFree > (usableSize - 4)) { goto __2 } @@ -42983,7 +42373,7 @@ __2: if !(iFree != 0) { goto __3 } - iFree2 = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFree)) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFree)) + uintptr(1))))) + iFree2 = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFree))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFree)) + 1)))) if !(iFree2 > (usableSize - 4)) { goto __4 } @@ -42995,8 +42385,8 @@ __4: } pEnd = (data + uintptr((cellOffset + (nCell * 2)))) sz2 = 0 - sz = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree + 2))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree + 2))) + uintptr(1))))) - top = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))))) + sz = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree + 2)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree + 2))) + 1)))) + top = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)))) if !(top >= iFree) { goto __6 } @@ -43012,7 +42402,7 @@ __6: return Xsqlite3CorruptError(tls, 65941) __9: ; - sz2 = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree2 + 2))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree2 + 2))) + uintptr(1))))) + sz2 = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree2 + 2)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((iFree2 + 2))) + 1)))) if !((iFree2 + sz2) > usableSize) { goto __10 } @@ -43040,19 +42430,19 @@ __12: if !(pAddr < pEnd) { goto __14 } - pc = ((int32(*(*U8)(unsafe.Pointer((pAddr) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((pAddr) + uintptr(1))))) + pc = ((int32(*(*U8)(unsafe.Pointer((pAddr)))) << 8) | int32(*(*U8)(unsafe.Pointer((pAddr) + 1)))) if !(pc < iFree) { goto __15 } - *(*U8)(unsafe.Pointer((pAddr) + uintptr(0))) = (U8((pc + sz) >> 8)) - *(*U8)(unsafe.Pointer((pAddr) + uintptr(1))) = (U8(pc + sz)) + *(*U8)(unsafe.Pointer((pAddr))) = (U8((pc + sz) >> 8)) + *(*U8)(unsafe.Pointer((pAddr) + 1)) = (U8(pc + sz)) goto __16 __15: if !(pc < iFree2) { goto __17 } - *(*U8)(unsafe.Pointer((pAddr) + uintptr(0))) = (U8((pc + sz2) >> 8)) - *(*U8)(unsafe.Pointer((pAddr) + uintptr(1))) = (U8(pc + sz2)) + *(*U8)(unsafe.Pointer((pAddr))) = (U8((pc + sz2) >> 8)) + *(*U8)(unsafe.Pointer((pAddr) + 1)) = (U8(pc + sz2)) __17: ; __16: @@ -43080,7 +42470,7 @@ __18: goto __20 } // The i-th cell pointer pAddr1 = (data + uintptr((cellOffset + (i * 2)))) - pc = ((int32(*(*U8)(unsafe.Pointer((pAddr1) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((pAddr1) + uintptr(1))))) + pc = ((int32(*(*U8)(unsafe.Pointer((pAddr1)))) << 8) | int32(*(*U8)(unsafe.Pointer((pAddr1) + 1)))) // These conditions have already been verified in btreeInitPage() // if PRAGMA cell_size_check=ON. @@ -43100,8 +42490,8 @@ __21: __22: ; - *(*U8)(unsafe.Pointer((pAddr1) + uintptr(0))) = (U8((cbrk) >> 8)) - *(*U8)(unsafe.Pointer((pAddr1) + uintptr(1))) = U8(cbrk) + *(*U8)(unsafe.Pointer((pAddr1))) = (U8((cbrk) >> 8)) + *(*U8)(unsafe.Pointer((pAddr1) + 1)) = U8(cbrk) if !(temp == uintptr(0)) { goto __23 } @@ -43112,7 +42502,7 @@ __22: __24: ; temp = Xsqlite3PagerTempSpace(tls, (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FpPager) - x = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))))) + x = ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)))) libc.Xmemcpy(tls, (temp + uintptr(x)), (data + uintptr(x)), (uint64((cbrk + size) - x))) src = temp __23: @@ -43136,13 +42526,13 @@ defragment_out: __25: ; - *(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0))) = (U8((cbrk) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))) = U8(cbrk) + *(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))))) = (U8((cbrk) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)) = U8(cbrk) *(*uint8)(unsafe.Pointer(data + uintptr((hdr + 1)))) = uint8(0) *(*uint8)(unsafe.Pointer(data + uintptr((hdr + 2)))) = uint8(0) libc.Xmemset(tls, (data + uintptr(iCellFirst)), 0, (uint64(cbrk - iCellFirst))) - return 0 + return SQLITE_OK } // Search the free-list on page pPg for space to store a cell nByte bytes in @@ -43158,19 +42548,19 @@ __25: // will be ignored if adding the extra space to the fragmentation count // causes the fragmentation count to exceed 60. func pageFindSlot(tls *libc.TLS, pPg uintptr, nByte int32, pRc uintptr) uintptr { /* sqlite3.c:66027:11: */ - var hdr int32 = int32((*MemPage)(unsafe.Pointer(pPg)).FhdrOffset) // Offset to page header - var aData uintptr = (*MemPage)(unsafe.Pointer(pPg)).FaData // Page data - var iAddr int32 = (hdr + 1) // Address of ptr to pc - var pc int32 = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr(iAddr)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr(iAddr)) + uintptr(1))))) // Address of a free slot - var x int32 // Excess size of the slot - var maxPC int32 = (int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPg)).FpBt)).FusableSize - U32(nByte))) // Max address for a usable slot - var size int32 // Size of the free slot + var hdr int32 = int32((*MemPage)(unsafe.Pointer(pPg)).FhdrOffset) // Offset to page header + var aData uintptr = (*MemPage)(unsafe.Pointer(pPg)).FaData // Page data + var iAddr int32 = (hdr + 1) // Address of ptr to pc + var pc int32 = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr(iAddr))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr(iAddr)) + 1)))) // Address of a free slot + var x int32 // Excess size of the slot + var maxPC int32 = (int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPg)).FpBt)).FusableSize - U32(nByte))) // Max address for a usable slot + var size int32 // Size of the free slot for pc <= maxPC { // EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each // freeblock form a big-endian integer which is the size of the freeblock // in bytes, including the 4-byte header. - size = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))) + uintptr(1))))) + size = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr((pc + 2)))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))) + 1)))) if (libc.AssignInt32(&x, (size - nByte))) >= 0 { if x < 4 { @@ -43191,13 +42581,13 @@ func pageFindSlot(tls *libc.TLS, pPg uintptr, nByte int32, pRc uintptr) uintptr } else { // The slot remains on the free-list. Reduce its size to account // for the portion used by the new allocation. - *(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))) + uintptr(0))) = (U8((x) >> 8)) - *(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))) + uintptr(1))) = U8(x) + *(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))))) = (U8((x) >> 8)) + *(*U8)(unsafe.Pointer((aData + uintptr((pc + 2))) + 1)) = U8(x) } return (aData + uintptr((pc + x))) } iAddr = pc - pc = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr(pc)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr(pc)) + uintptr(1))))) + pc = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr(pc))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr(pc)) + 1)))) if pc <= (iAddr + size) { if pc != 0 { // The next slot in the chain is not past the end of the current slot @@ -43231,7 +42621,7 @@ func allocateSpace(tls *libc.TLS, pPage uintptr, nByte int32, pIdx uintptr) int3 var hdr int32 = int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset) // Local cache of pPage->hdrOffset var data uintptr = (*MemPage)(unsafe.Pointer(pPage)).FaData // Local cache of pPage->aData var top int32 // First byte of cell content area - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 // Integer return code + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK // Integer return code var gap int32 // First byte of gap between cell pointers and cell content // Minimum cell size is 4 @@ -43243,7 +42633,7 @@ func allocateSpace(tls *libc.TLS, pPage uintptr, nByte int32, pIdx uintptr) int3 // then the cell content offset of an empty page wants to be 65536. // However, that integer is too large to be stored in a 2-byte unsigned // integer, so a value of 0 is used in its place. - top = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))))) + top = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)))) // by btreeComputeFreeSpace() if gap > top { if (top == 0) && ((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize == U32(65536)) { @@ -43266,7 +42656,7 @@ func allocateSpace(tls *libc.TLS, pPage uintptr, nByte int32, pIdx uintptr) int3 if g2 <= gap { return Xsqlite3CorruptError(tls, 66142) } else { - return 0 + return SQLITE_OK } } else if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -43287,7 +42677,7 @@ func allocateSpace(tls *libc.TLS, pPage uintptr, nByte int32, pIdx uintptr) int3 if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp /* rc */)) } - top = (((((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))))) - 1) & 0xffff) + 1) + top = (((((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)))) - 1) & 0xffff) + 1) } @@ -43297,11 +42687,11 @@ func allocateSpace(tls *libc.TLS, pPage uintptr, nByte int32, pIdx uintptr) int3 // is no way that the allocation can extend off the end of the page. // The assert() below verifies the previous sentence. top = top - (nByte) - *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0))) = (U8((top) >> 8)) - *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))) = U8(top) + *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))))) = (U8((top) >> 8)) + *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)) = U8(top) *(*int32)(unsafe.Pointer(pIdx)) = top - return 0 + return SQLITE_OK } // Return a section of the pPage->aData to the freelist. @@ -43334,7 +42724,7 @@ func freeSpace(tls *libc.TLS, pPage uintptr, iStart U16, iSize U16) int32 { /* s if (int32(*(*uint8)(unsafe.Pointer(data + uintptr((int32(iPtr) + 1))))) == 0) && (int32(*(*uint8)(unsafe.Pointer(data + uintptr(iPtr)))) == 0) { iFreeBlk = U16(0) // Shortcut for the case when the freelist is empty } else { - for (int32(libc.AssignUint16(&iFreeBlk, (U16((int32(*(*uint8)(unsafe.Pointer((data + uintptr(iPtr)) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr(iPtr)) + uintptr(1))))))))) < int32(iStart) { + for (int32(libc.AssignUint16(&iFreeBlk, (U16((int32(*(*uint8)(unsafe.Pointer((data + uintptr(iPtr))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr(iPtr)) + 1)))))))) < int32(iStart) { if int32(iFreeBlk) < (int32(iPtr) + 4) { if int32(iFreeBlk) == 0 { break @@ -43357,19 +42747,19 @@ func freeSpace(tls *libc.TLS, pPage uintptr, iStart U16, iSize U16) int32 { /* s if iEnd > U32(iFreeBlk) { return Xsqlite3CorruptError(tls, 66237) } - iEnd = (U32(int32(iFreeBlk) + ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iFreeBlk) + 2))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iFreeBlk) + 2))) + uintptr(1))))))) + iEnd = (U32(int32(iFreeBlk) + ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iFreeBlk) + 2)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iFreeBlk) + 2))) + 1)))))) if iEnd > (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize { return Xsqlite3CorruptError(tls, 66240) } iSize = (U16(iEnd - U32(iStart))) - iFreeBlk = (U16((int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFreeBlk)) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFreeBlk)) + uintptr(1)))))) + iFreeBlk = (U16((int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFreeBlk))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr(iFreeBlk)) + 1))))) } // If iPtr is another freeblock (that is, if iPtr is not the freelist // pointer in the page header) then check to see if iStart should be // coalesced onto the end of iPtr. if int32(iPtr) > (int32(hdr) + 1) { - var iPtrEnd int32 = (int32(iPtr) + ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iPtr) + 2))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iPtr) + 2))) + uintptr(1)))))) + var iPtrEnd int32 = (int32(iPtr) + ((int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iPtr) + 2)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(iPtr) + 2))) + 1))))) if (iPtrEnd + 3) >= int32(iStart) { if iPtrEnd > int32(iStart) { return Xsqlite3CorruptError(tls, 66253) @@ -43384,7 +42774,7 @@ func freeSpace(tls *libc.TLS, pPage uintptr, iStart U16, iSize U16) int32 { /* s } *(*uint8)(unsafe.Pointer(data + uintptr((int32(hdr) + 7)))) -= uint8((int32(nFrag))) } - x = (U16((int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(0)))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(1)))))) + x = (U16((int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5)))))) << 8) | int32(*(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + 1))))) if int32(iStart) <= int32(x) { // The new freeblock is at the beginning of the cell content area, // so just extend the cell content area rather than create another @@ -43395,26 +42785,26 @@ func freeSpace(tls *libc.TLS, pPage uintptr, iStart U16, iSize U16) int32 { /* s if int32(iPtr) != (int32(hdr) + 1) { return Xsqlite3CorruptError(tls, 66268) } - *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))) + uintptr(0))) = (U8((int32(iFreeBlk)) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))) + uintptr(1))) = U8(iFreeBlk) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(0))) = (U8((iEnd) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(1))) = U8(iEnd) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))))) = (U8((int32(iFreeBlk)) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))) + 1)) = U8(iFreeBlk) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))))) = (U8((iEnd) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + 1)) = U8(iEnd) } else { // Insert the new freeblock into the freelist - *(*uint8)(unsafe.Pointer((data + uintptr(iPtr)) + uintptr(0))) = (U8((int32(iStart)) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr(iPtr)) + uintptr(1))) = U8(iStart) + *(*uint8)(unsafe.Pointer((data + uintptr(iPtr)))) = (U8((int32(iStart)) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr(iPtr)) + 1)) = U8(iStart) } - if (int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FbtsFlags) & 0x000c) != 0 { + if (int32((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FbtsFlags) & BTS_FAST_SECURE) != 0 { // Overwrite deleted information with zeros when the secure_delete // option is enabled libc.Xmemset(tls, (data + uintptr(iStart)), 0, uint64(iSize)) } - *(*uint8)(unsafe.Pointer((data + uintptr(iStart)) + uintptr(0))) = (U8((int32(iFreeBlk)) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr(iStart)) + uintptr(1))) = U8(iFreeBlk) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(iStart) + 2))) + uintptr(0))) = (U8((int32(iSize)) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(iStart) + 2))) + uintptr(1))) = U8(iSize) + *(*uint8)(unsafe.Pointer((data + uintptr(iStart)))) = (U8((int32(iFreeBlk)) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr(iStart)) + 1)) = U8(iFreeBlk) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(iStart) + 2))))) = (U8((int32(iSize)) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(iStart) + 2))) + 1)) = U8(iSize) *(*int32)(unsafe.Pointer(pPage + 20 /* &.nFree */)) += (int32(iOrigSize)) - return 0 + return SQLITE_OK } // Decode the flags byte (the first byte of the header) for a page @@ -43431,13 +42821,13 @@ func decodeFlags(tls *libc.TLS, pPage uintptr, flagByte int32) int32 { /* sqlite var pBt uintptr // A copy of pPage->pBt (*MemPage)(unsafe.Pointer(pPage)).Fleaf = (U8(flagByte >> 3)) - flagByte = flagByte & (^libc.Int32(0x08)) + flagByte = flagByte & (libc.CplInt32(PTF_LEAF)) (*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize = (U8(4 - (4 * int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf)))) (*MemPage)(unsafe.Pointer(pPage)).FxCellSize = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) U16 }{cellSizePtr})) pBt = (*MemPage)(unsafe.Pointer(pPage)).FpBt - if flagByte == (0x04 | 0x01) { + if flagByte == (PTF_LEAFDATA | PTF_INTKEY) { // EVIDENCE-OF: R-07291-35328 A value of 5 (0x05) means the page is an // interior table b-tree page. @@ -43461,7 +42851,7 @@ func decodeFlags(tls *libc.TLS, pPage uintptr, flagByte int32) int32 { /* sqlite } (*MemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*BtShared)(unsafe.Pointer(pBt)).FmaxLeaf (*MemPage)(unsafe.Pointer(pPage)).FminLocal = (*BtShared)(unsafe.Pointer(pBt)).FminLeaf - } else if flagByte == 0x02 { + } else if flagByte == PTF_ZERODATA { // EVIDENCE-OF: R-43316-37308 A value of 2 (0x02) means the page is an // interior index b-tree page. @@ -43481,7 +42871,7 @@ func decodeFlags(tls *libc.TLS, pPage uintptr, flagByte int32) int32 { /* sqlite return Xsqlite3CorruptError(tls, 66341) } (*MemPage)(unsafe.Pointer(pPage)).Fmax1bytePayload = (*BtShared)(unsafe.Pointer(pBt)).Fmax1bytePayload - return 0 + return SQLITE_OK } // Compute the amount of freespace on the page. In other words, fill @@ -43502,7 +42892,7 @@ func btreeComputeFreeSpace(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66 // EVIDENCE-OF: R-58015-48175 The two-byte integer at offset 5 designates // the start of the cell content area. A zero value for this integer is // interpreted as 65536. - top = (((((int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(1))))) - 1) & 0xffff) + 1) + top = (((((int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + 1)))) - 1) & 0xffff) + 1) iCellFirst = (((int32(hdr) + 8) + int32((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)) + (2 * int32((*MemPage)(unsafe.Pointer(pPage)).FnCell))) iCellLast = (usableSize - 4) @@ -43510,7 +42900,7 @@ func btreeComputeFreeSpace(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66 // EVIDENCE-OF: R-23588-34450 The two-byte integer at offset 1 gives the // start of the first freeblock on the page, or is zero if there are no // freeblocks. - pc = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))) + uintptr(1))))) + pc = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((int32(hdr) + 1))) + 1)))) nFree = (int32(*(*U8)(unsafe.Pointer(data + uintptr((int32(hdr) + 7))))) + top) // Init nFree to non-freeblock free space if pc > 0 { var next U32 @@ -43525,8 +42915,8 @@ func btreeComputeFreeSpace(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66 // Freeblock off the end of the page return Xsqlite3CorruptError(tls, 66397) } - next = (U32((int32(*(*U8)(unsafe.Pointer((data + uintptr(pc)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr(pc)) + uintptr(1)))))) - size = (U32((int32(*(*U8)(unsafe.Pointer((data + uintptr((pc + 2))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((pc + 2))) + uintptr(1)))))) + next = (U32((int32(*(*U8)(unsafe.Pointer((data + uintptr(pc))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr(pc)) + 1))))) + size = (U32((int32(*(*U8)(unsafe.Pointer((data + uintptr((pc + 2)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((pc + 2))) + 1))))) nFree = (int32(U32(nFree) + size)) if next <= ((U32(pc) + size) + U32(3)) { break @@ -43553,7 +42943,7 @@ func btreeComputeFreeSpace(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66 return Xsqlite3CorruptError(tls, 66423) } (*MemPage)(unsafe.Pointer(pPage)).FnFree = int32((U16(nFree - iCellFirst))) - return 0 + return SQLITE_OK } // Do additional sanity check after btreeInitPage() if @@ -43588,7 +42978,7 @@ func btreeCellSizeCheck(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66433 return Xsqlite3CorruptError(tls, 66459) } } - return 0 + return SQLITE_OK } // Initialize the auxiliary information for a disk block. @@ -43606,7 +42996,7 @@ func btreeInitPage(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66474:12: data = ((*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)) // EVIDENCE-OF: R-28594-02890 The one-byte flag at offset 0 indicating // the b-tree page type. - if decodeFlags(tls, pPage, int32(*(*U8)(unsafe.Pointer(data + uintptr(0))))) != 0 { + if decodeFlags(tls, pPage, int32(*(*U8)(unsafe.Pointer(data)))) != 0 { return Xsqlite3CorruptError(tls, 66491) } @@ -43618,7 +43008,7 @@ func btreeInitPage(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66474:12: (*MemPage)(unsafe.Pointer(pPage)).FaDataOfst = ((*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)) // EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the // number of cells on the page. - (*MemPage)(unsafe.Pointer(pPage)).FnCell = (U16((int32(*(*U8)(unsafe.Pointer((data + uintptr(3)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr(3)) + uintptr(1)))))) + (*MemPage)(unsafe.Pointer(pPage)).FnCell = (U16((int32(*(*U8)(unsafe.Pointer((data + 3)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + 3) + 1))))) if U32((*MemPage)(unsafe.Pointer(pPage)).FnCell) > (((*BtShared)(unsafe.Pointer(pBt)).FpageSize - U32(8)) / U32(6)) { // To many cells for a single page. The page must be corrupt return Xsqlite3CorruptError(tls, 66505) @@ -43631,10 +43021,10 @@ func btreeInitPage(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:66474:12: (*MemPage)(unsafe.Pointer(pPage)).FnFree = -1 // Indicate that this value is yet uncomputed (*MemPage)(unsafe.Pointer(pPage)).FisInit = U8(1) - if ((*Sqlite3)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags & uint64(0x00200000)) != 0 { + if ((*Sqlite3)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags & SQLITE_CellSizeCk) != 0 { return btreeCellSizeCheck(tls, pPage) } - return 0 + return SQLITE_OK } // Set up a raw page so that it looks like a database page holding @@ -43645,20 +43035,20 @@ func zeroPage(tls *libc.TLS, pPage uintptr, flags int32) { /* sqlite3.c:66527:13 var hdr U8 = (*MemPage)(unsafe.Pointer(pPage)).FhdrOffset var first U16 - if (int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x000c) != 0 { + if (int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_FAST_SECURE) != 0 { libc.Xmemset(tls, (data + uintptr(hdr)), 0, (uint64((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(hdr)))) } *(*uint8)(unsafe.Pointer(data + uintptr(hdr))) = uint8(int8(flags)) first = (U16(int32(hdr) + (func() int32 { - if (flags & 0x08) == 0 { + if (flags & PTF_LEAF) == 0 { return 12 } return 8 }()))) libc.Xmemset(tls, (data + uintptr((int32(hdr) + 1))), 0, uint64(4)) *(*uint8)(unsafe.Pointer(data + uintptr((int32(hdr) + 7)))) = uint8(0) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(0))) = (U8(((*BtShared)(unsafe.Pointer(pBt)).FusableSize) >> 8)) - *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + uintptr(1))) = U8((*BtShared)(unsafe.Pointer(pBt)).FusableSize) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))))) = (U8(((*BtShared)(unsafe.Pointer(pBt)).FusableSize) >> 8)) + *(*uint8)(unsafe.Pointer((data + uintptr((int32(hdr) + 5))) + 1)) = U8((*BtShared)(unsafe.Pointer(pBt)).FusableSize) (*MemPage)(unsafe.Pointer(pPage)).FnFree = int32((U16((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(first)))) decodeFlags(tls, pPage, flags) (*MemPage)(unsafe.Pointer(pPage)).FcellOffset = first @@ -43713,7 +43103,7 @@ func btreeGetPage(tls *libc.TLS, pBt uintptr, pgno Pgno, ppPage uintptr, flags i return rc } *(*uintptr)(unsafe.Pointer(ppPage)) = btreePageFromDbPage(tls, *(*uintptr)(unsafe.Pointer(bp /* pDbPage */)), pgno, pBt) - return 0 + return SQLITE_OK } // Retrieve a page from the pager cache. If the requested page is not @@ -43778,7 +43168,7 @@ __2: } btreePageFromDbPage(tls, *(*uintptr)(unsafe.Pointer(bp /* pDbPage */)), pgno, pBt) rc = btreeInitPage(tls, *(*uintptr)(unsafe.Pointer(ppPage))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } goto getAndInitPage_error2 @@ -43796,7 +43186,7 @@ __3: goto getAndInitPage_error2 __5: ; - return 0 + return SQLITE_OK getAndInitPage_error2: releasePage(tls, *(*uintptr)(unsafe.Pointer(ppPage))) @@ -43841,7 +43231,7 @@ func releasePageOne(tls *libc.TLS, pPage uintptr) { /* sqlite3.c:66716:13: */ // * Make sure the isInit flag is clear func btreeGetUnusedPage(tls *libc.TLS, pBt uintptr, pgno Pgno, ppPage uintptr, flags int32) int32 { /* sqlite3.c:66736:12: */ var rc int32 = btreeGetPage(tls, pBt, pgno, ppPage, flags) - if rc == 0 { + if rc == SQLITE_OK { if Xsqlite3PagerPageRefcount(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FpDbPage) > 1 { releasePage(tls, *(*uintptr)(unsafe.Pointer(ppPage))) *(*uintptr)(unsafe.Pointer(ppPage)) = uintptr(0) @@ -43935,11 +43325,11 @@ func Xsqlite3BtreeOpen(tls *libc.TLS, pVfs uintptr, zFilename uintptr, db uintpt var pFile uintptr pBt = uintptr(0) mutexOpen = uintptr(0) - rc = 0 - isTempDb = (libc.Bool32((zFilename == uintptr(0)) || (int32(*(*int8)(unsafe.Pointer(zFilename + uintptr(0)))) == 0))) + rc = SQLITE_OK + isTempDb = (libc.Bool32((zFilename == uintptr(0)) || (int32(*(*int8)(unsafe.Pointer(zFilename))) == 0))) isMemdb = (libc.Bool32((((zFilename != 0) && (libc.Xstrcmp(tls, zFilename, ts+5702 /* ":memory:" */) == 0)) || ((isTempDb != 0) && (Xsqlite3TempInMemory(tls, db) != 0))) || - ((vfsFlags & 0x00000080) != 0))) + ((vfsFlags & SQLITE_OPEN_MEMORY) != 0))) // flags fit in 8 bits @@ -43950,33 +43340,33 @@ func Xsqlite3BtreeOpen(tls *libc.TLS, pVfs uintptr, zFilename uintptr, db uintpt if !(isMemdb != 0) { goto __1 } - flags = flags | (2) + flags = flags | (BTREE_MEMORY) __1: ; - if !(((vfsFlags & 0x00000100) != 0) && ((isMemdb != 0) || (isTempDb != 0))) { + if !(((vfsFlags & SQLITE_OPEN_MAIN_DB) != 0) && ((isMemdb != 0) || (isTempDb != 0))) { goto __2 } - vfsFlags = ((vfsFlags & ^libc.Int32(0x00000100)) | 0x00000200) + vfsFlags = ((vfsFlags & libc.CplInt32(SQLITE_OPEN_MAIN_DB)) | SQLITE_OPEN_TEMP_DB) __2: ; p = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(Btree{}))) if !(!(p != 0)) { goto __3 } - return 7 + return SQLITE_NOMEM __3: ; - (*Btree)(unsafe.Pointer(p)).FinTrans = U8(0) + (*Btree)(unsafe.Pointer(p)).FinTrans = TRANS_NONE (*Btree)(unsafe.Pointer(p)).Fdb = db (*Btree)(unsafe.Pointer(p)).Flock.FpBtree = p (*Btree)(unsafe.Pointer(p)).Flock.FiTable = Pgno(1) // If this Btree is a candidate for shared cache, try to find an // existing BtShared object that we can share with - if !((isTempDb == 0) && ((isMemdb == 0) || ((vfsFlags & 0x00000040) != 0))) { + if !((isTempDb == 0) && ((isMemdb == 0) || ((vfsFlags & SQLITE_OPEN_URI) != 0))) { goto __4 } - if !((vfsFlags & 0x00020000) != 0) { + if !((vfsFlags & SQLITE_OPEN_SHAREDCACHE) != 0) { goto __5 } nFilename = (Xsqlite3Strlen30(tls, zFilename) + 1) @@ -43993,7 +43383,7 @@ __3: goto __6 } Xsqlite3_free(tls, p) - return 7 + return SQLITE_NOMEM __6: ; if !(isMemdb != 0) { @@ -44007,10 +43397,10 @@ __7: if !(rc != 0) { goto __9 } - if !(rc == (0 | (int32(2) << 8))) { + if !(rc == (SQLITE_OK | (int32(2) << 8))) { goto __10 } - rc = 0 + rc = SQLITE_OK goto __11 __10: Xsqlite3_free(tls, zFullPathname) @@ -44022,9 +43412,9 @@ __9: ; __8: ; - mutexOpen = Xsqlite3MutexAlloc(tls, 4) + mutexOpen = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_OPEN) Xsqlite3_mutex_enter(tls, mutexOpen) - mutexShared = Xsqlite3MutexAlloc(tls, 2) + mutexShared = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutexShared) pBt = Xsqlite3SharedCacheList __12: @@ -44049,7 +43439,7 @@ __16: Xsqlite3_mutex_leave(tls, mutexOpen) Xsqlite3_free(tls, zFullPathname) Xsqlite3_free(tls, p) - return 19 + return SQLITE_CONSTRAINT __19: ; goto __17 @@ -44088,20 +43478,20 @@ __4: if !(pBt == uintptr(0)) { goto __21 } - rc = 7 + rc = SQLITE_NOMEM goto btree_open_out __21: ; rc = Xsqlite3PagerOpen(tls, pVfs, (pBt /* &.pPager */), zFilename, int32(unsafe.Sizeof(MemPage{})), flags, vfsFlags, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{pageReinit}))) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __22 } Xsqlite3PagerSetMmapLimit(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, (*Sqlite3)(unsafe.Pointer(db)).FszMmap) rc = Xsqlite3PagerReadFileheader(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, int32(unsafe.Sizeof([100]uint8{})), bp /* &zDbHeader[0] */) __22: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __23 } goto btree_open_out @@ -44119,14 +43509,14 @@ __23: if !(Xsqlite3PagerIsreadonly(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) != 0) { goto __24 } - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0001)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_READ_ONLY)) __24: ; // EVIDENCE-OF: R-51873-39618 The page size for a database file is // determined by the 2-byte integer located at an offset of 16 bytes from // the beginning of the database file. - (*BtShared)(unsafe.Pointer(pBt)).FpageSize = (U32((int32(*(*uint8)(unsafe.Pointer(bp /* &zDbHeader[0] */ + uintptr(16)))) << 8) | (int32(*(*uint8)(unsafe.Pointer(bp /* &zDbHeader[0] */ + uintptr(17)))) << 16))) - if !((((*BtShared)(unsafe.Pointer(pBt)).FpageSize < U32(512)) || ((*BtShared)(unsafe.Pointer(pBt)).FpageSize > U32(65536))) || + (*BtShared)(unsafe.Pointer(pBt)).FpageSize = (U32((int32(*(*uint8)(unsafe.Pointer(bp /* &zDbHeader[0] */ + 16))) << 8) | (int32(*(*uint8)(unsafe.Pointer(bp /* &zDbHeader[0] */ + 17))) << 16))) + if !((((*BtShared)(unsafe.Pointer(pBt)).FpageSize < U32(512)) || ((*BtShared)(unsafe.Pointer(pBt)).FpageSize > SQLITE_MAX_PAGE_SIZE)) || ((((*BtShared)(unsafe.Pointer(pBt)).FpageSize - U32(1)) & (*BtShared)(unsafe.Pointer(pBt)).FpageSize) != U32(0))) { goto __25 } @@ -44146,7 +43536,7 @@ __24: return uint8(0) }() (*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = func() uint8 { - if 0 == 2 { + if SQLITE_DEFAULT_AUTOVACUUM == 2 { return uint8(1) } return uint8(0) @@ -44159,16 +43549,16 @@ __25: // EVIDENCE-OF: R-37497-42412 The size of the reserved region is // determined by the one-byte unsigned integer found at an offset of 20 // into the database file header. - nReserve = *(*uint8)(unsafe.Pointer(bp /* &zDbHeader[0] */ + uintptr(20))) - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0002)) + nReserve = *(*uint8)(unsafe.Pointer(bp /* &zDbHeader[0] */ + 20)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_PAGESIZE_FIXED)) (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum = func() uint8 { - if Xsqlite3Get4byte(tls, (bp /* &zDbHeader */ +uintptr((36+(4*4))))) != 0 { + if Xsqlite3Get4byte(tls, (bp /* &zDbHeader */ +52)) != 0 { return uint8(1) } return uint8(0) }() (*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = func() uint8 { - if Xsqlite3Get4byte(tls, (bp /* &zDbHeader */ +uintptr((36+(7*4))))) != 0 { + if Xsqlite3Get4byte(tls, (bp /* &zDbHeader */ +64)) != 0 { return uint8(1) } return uint8(0) @@ -44190,15 +43580,15 @@ __28: if !((*Btree)(unsafe.Pointer(p)).Fsharable != 0) { goto __29 } - mutexShared1 = Xsqlite3MutexAlloc(tls, 2) + mutexShared1 = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) if !((1 != 0) && (Xsqlite3Config.FbCoreMutex != 0)) { goto __30 } - (*BtShared)(unsafe.Pointer(pBt)).Fmutex = Xsqlite3MutexAlloc(tls, 0) + (*BtShared)(unsafe.Pointer(pBt)).Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_FAST) if !((*BtShared)(unsafe.Pointer(pBt)).Fmutex == uintptr(0)) { goto __31 } - rc = 7 + rc = SQLITE_NOMEM goto btree_open_out __31: ; @@ -44277,7 +43667,7 @@ __32: *(*uintptr)(unsafe.Pointer(ppBtree)) = p btree_open_out: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __44 } if !((pBt != 0) && ((*BtShared)(unsafe.Pointer(pBt)).FpPager != 0)) { @@ -44306,7 +43696,7 @@ __47: if !((*Sqlite3_file)(unsafe.Pointer(pFile)).FpMethods != 0) { goto __48 } - Xsqlite3OsFileControlHint(tls, pFile, 30, (pBt + 8 /* &.db */)) + Xsqlite3OsFileControlHint(tls, pFile, SQLITE_FCNTL_PDB, (pBt + 8 /* &.db */)) __48: ; __45: @@ -44331,7 +43721,7 @@ func removeFromSharingList(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:6711 var pList uintptr var removed int32 = 0 - pMainMtx = Xsqlite3MutexAlloc(tls, 2) + pMainMtx = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, pMainMtx) (*BtShared)(unsafe.Pointer(pBt)).FnRef-- if (*BtShared)(unsafe.Pointer(pBt)).FnRef <= 0 { @@ -44412,7 +43802,7 @@ func Xsqlite3BtreeClose(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:67192:20: // Rollback any active transaction and free the handle structure. // The call to sqlite3BtreeRollback() drops any table-locks held by // this handle. - Xsqlite3BtreeRollback(tls, p, 0, 0) + Xsqlite3BtreeRollback(tls, p, SQLITE_OK, 0) Xsqlite3BtreeLeave(tls, p) // If there are still other outstanding references to the shared-btree @@ -44442,7 +43832,7 @@ func Xsqlite3BtreeClose(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:67192:20: } Xsqlite3_free(tls, p) - return 0 + return SQLITE_OK } // Change the "soft" limit on the number of pages in the cache. @@ -44456,7 +43846,7 @@ func Xsqlite3BtreeSetCacheSize(tls *libc.TLS, p uintptr, mxPage int32) int32 { / Xsqlite3BtreeEnter(tls, p) Xsqlite3PagerSetCachesize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, mxPage) Xsqlite3BtreeLeave(tls, p) - return 0 + return SQLITE_OK } // Change the "spill" limit on the number of pages in the cache. @@ -44485,7 +43875,7 @@ func Xsqlite3BtreeSetMmapLimit(tls *libc.TLS, p uintptr, szMmap Sqlite3_int64) i Xsqlite3BtreeEnter(tls, p) Xsqlite3PagerSetMmapLimit(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, szMmap) Xsqlite3BtreeLeave(tls, p) - return 0 + return SQLITE_OK } // Change the way data is synced to disk in order to increase or decrease @@ -44500,7 +43890,7 @@ func Xsqlite3BtreeSetPagerFlags(tls *libc.TLS, p uintptr, pgFlags uint32) int32 Xsqlite3BtreeEnter(tls, p) Xsqlite3PagerSetFlags(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, pgFlags) Xsqlite3BtreeLeave(tls, p) - return 0 + return SQLITE_OK } // Change the default pages size and the number of reserved bytes per page. @@ -44522,7 +43912,7 @@ func Xsqlite3BtreeSetPagerFlags(tls *libc.TLS, p uintptr, pgFlags uint32) int32 // If the iFix!=0 then the BTS_PAGESIZE_FIXED flag is set so that the page size // and autovacuum mode can no longer be changed. func Xsqlite3BtreeSetPageSize(tls *libc.TLS, p uintptr, pageSize int32, nReserve int32, iFix int32) int32 { /* sqlite3.c:67340:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var x int32 var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt @@ -44532,12 +43922,12 @@ func Xsqlite3BtreeSetPageSize(tls *libc.TLS, p uintptr, pageSize int32, nReserve if nReserve < x { nReserve = x } - if (int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0002) != 0 { + if (int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_PAGESIZE_FIXED) != 0 { Xsqlite3BtreeLeave(tls, p) - return 8 + return SQLITE_READONLY } - if ((pageSize >= 512) && (pageSize <= 65536)) && (((pageSize - 1) & pageSize) == 0) { + if ((pageSize >= 512) && (pageSize <= SQLITE_MAX_PAGE_SIZE)) && (((pageSize - 1) & pageSize) == 0) { (*BtShared)(unsafe.Pointer(pBt)).FpageSize = U32(pageSize) freeTempSpace(tls, pBt) @@ -44545,7 +43935,7 @@ func Xsqlite3BtreeSetPageSize(tls *libc.TLS, p uintptr, pageSize int32, nReserve rc = Xsqlite3PagerSetPagesize(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, (pBt + 52 /* &.pageSize */), nReserve) (*BtShared)(unsafe.Pointer(pBt)).FusableSize = ((*BtShared)(unsafe.Pointer(pBt)).FpageSize - U32(U16(nReserve))) if iFix != 0 { - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0002)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_PAGESIZE_FIXED)) } Xsqlite3BtreeLeave(tls, p) return rc @@ -44627,10 +44017,10 @@ func Xsqlite3BtreeSecureDelete(tls *libc.TLS, p uintptr, newFlag int32) int32 { Xsqlite3BtreeEnter(tls, p) if newFlag >= 0 { - *(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x000c))) - *(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt + 40 /* &.btsFlags */)) |= U16((0x0004 * newFlag)) + *(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_FAST_SECURE))) + *(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt + 40 /* &.btsFlags */)) |= U16((BTS_SECURE_DELETE * newFlag)) } - b = ((int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FbtsFlags) & 0x000c) / 0x0004) + b = ((int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FbtsFlags) & BTS_FAST_SECURE) / BTS_SECURE_DELETE) Xsqlite3BtreeLeave(tls, p) return b } @@ -44641,17 +44031,17 @@ func Xsqlite3BtreeSecureDelete(tls *libc.TLS, p uintptr, newFlag int32) int32 { // determined by the SQLITE_DEFAULT_AUTOVACUUM macro. func Xsqlite3BtreeSetAutoVacuum(tls *libc.TLS, p uintptr, autoVacuum int32) int32 { /* sqlite3.c:67464:20: */ var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt - var rc int32 = 0 + var rc int32 = SQLITE_OK var av U8 = U8(autoVacuum) Xsqlite3BtreeEnter(tls, p) - if ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0002) != 0) && ((func() int32 { + if ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_PAGESIZE_FIXED) != 0) && ((func() int32 { if av != 0 { return 1 } return 0 }()) != int32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum)) { - rc = 8 + rc = SQLITE_READONLY } else { (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum = func() uint8 { if av != 0 { @@ -44677,13 +44067,13 @@ func Xsqlite3BtreeGetAutoVacuum(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:6 Xsqlite3BtreeEnter(tls, p) rc = func() int32 { if !(int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FautoVacuum) != 0) { - return 0 + return BTREE_AUTOVACUUM_NONE } return func() int32 { if !(int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FincrVacuum) != 0) { - return 1 + return BTREE_AUTOVACUUM_FULL } - return 2 + return BTREE_AUTOVACUUM_INCR }() }() Xsqlite3BtreeLeave(tls, p) @@ -44717,14 +44107,14 @@ func lockBtree(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:67544:12: */ *(*U32)(unsafe.Pointer(bp + 8 /* nPageFile */)) = U32(0) // Number of pages in the database according to hdr rc = Xsqlite3PagerSharedLock(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __1 } return rc __1: ; rc = btreeGetPage(tls, pBt, uint32(1), bp /* &pPage1 */, 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __2 } return rc @@ -44741,7 +44131,7 @@ __2: nPage = *(*U32)(unsafe.Pointer(bp + 8 /* nPageFile */)) __3: ; - if !(((*Sqlite3)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags & uint64(0x02000000)) != uint64(0)) { + if !(((*Sqlite3)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb)).Fflags & SQLITE_ResetDatabase) != uint64(0)) { goto __4 } nPage = U32(0) @@ -44751,7 +44141,7 @@ __4: goto __5 } page1 = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage1 */)))).FaData - rc = 26 + rc = SQLITE_NOTADB // EVIDENCE-OF: R-43737-39999 Every valid SQLite database file begins // with the following 16 bytes (in hex): 53 51 4c 69 74 65 20 66 6f 72 6d // 61 74 20 33 00. @@ -44762,13 +44152,13 @@ __4: __6: ; - if !(int32(*(*U8)(unsafe.Pointer(page1 + uintptr(18)))) > 2) { + if !(int32(*(*U8)(unsafe.Pointer(page1 + 18))) > 2) { goto __7 } - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0001)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_READ_ONLY)) __7: ; - if !(int32(*(*U8)(unsafe.Pointer(page1 + uintptr(19)))) > 2) { + if !(int32(*(*U8)(unsafe.Pointer(page1 + 19))) > 2) { goto __8 } goto page1_init_failed @@ -44782,12 +44172,12 @@ __8: // required as the version of page 1 currently in the page1 buffer // may not be the latest version - there may be a newer one in the log // file. - if !((int32(*(*U8)(unsafe.Pointer(page1 + uintptr(19)))) == 2) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0020) == 0)) { + if !((int32(*(*U8)(unsafe.Pointer(page1 + 19))) == 2) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_NO_WAL) == 0)) { goto __9 } *(*int32)(unsafe.Pointer(bp + 12 /* isOpen */)) = 0 rc = Xsqlite3PagerOpenWal(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, bp+12 /* &isOpen */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __11 } goto page1_init_failed @@ -44798,12 +44188,12 @@ __11: goto __13 } releasePageOne(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage1 */))) - return 0 + return SQLITE_OK __13: ; __12: ; - rc = 26 + rc = SQLITE_NOTADB goto __10 __9: ; @@ -44815,7 +44205,7 @@ __10: // // The original design allowed these amounts to vary, but as of // version 3.6.0, we require them to be fixed. - if !(libc.Xmemcmp(tls, (page1+uintptr(21)), ts+5711 /* "@ " */, uint64(3)) != 0) { + if !(libc.Xmemcmp(tls, (page1+21), ts+5711 /* "@ " */, uint64(3)) != 0) { goto __14 } goto page1_init_failed @@ -44824,18 +44214,18 @@ __14: // EVIDENCE-OF: R-51873-39618 The page size for a database file is // determined by the 2-byte integer located at an offset of 16 bytes from // the beginning of the database file. - pageSize = (U32((int32(*(*U8)(unsafe.Pointer(page1 + uintptr(16)))) << 8) | (int32(*(*U8)(unsafe.Pointer(page1 + uintptr(17)))) << 16))) + pageSize = (U32((int32(*(*U8)(unsafe.Pointer(page1 + 16))) << 8) | (int32(*(*U8)(unsafe.Pointer(page1 + 17))) << 16))) // EVIDENCE-OF: R-25008-21688 The size of a page is a power of two // between 512 and 65536 inclusive. if !(((((pageSize - U32(1)) & pageSize) != U32(0)) || - (pageSize > U32(65536))) || + (pageSize > SQLITE_MAX_PAGE_SIZE)) || (pageSize <= U32(256))) { goto __15 } goto page1_init_failed __15: ; - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0002)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_PAGESIZE_FIXED)) // EVIDENCE-OF: R-59310-51205 The "reserved space" size in the 1-byte // integer at offset 20 is the number of bytes of space at the end of @@ -44844,7 +44234,7 @@ __15: // EVIDENCE-OF: R-37497-42412 The size of the reserved region is // determined by the one-byte unsigned integer found at an offset of 20 // into the database file header. - usableSize = (pageSize - U32(*(*U8)(unsafe.Pointer(page1 + uintptr(20))))) + usableSize = (pageSize - U32(*(*U8)(unsafe.Pointer(page1 + 20)))) if !(pageSize != (*BtShared)(unsafe.Pointer(pBt)).FpageSize) { goto __16 } @@ -44881,13 +44271,13 @@ __18: (*BtShared)(unsafe.Pointer(pBt)).FpageSize = pageSize (*BtShared)(unsafe.Pointer(pBt)).FusableSize = usableSize (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum = func() uint8 { - if Xsqlite3Get4byte(tls, (page1+uintptr((36+(4*4))))) != 0 { + if Xsqlite3Get4byte(tls, (page1+52)) != 0 { return uint8(1) } return uint8(0) }() (*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = func() uint8 { - if Xsqlite3Get4byte(tls, (page1+uintptr((36+(7*4))))) != 0 { + if Xsqlite3Get4byte(tls, (page1+64)) != 0 { return uint8(1) } return uint8(0) @@ -44923,7 +44313,7 @@ __20: (*BtShared)(unsafe.Pointer(pBt)).FpPage1 = *(*uintptr)(unsafe.Pointer(bp /* pPage1 */)) (*BtShared)(unsafe.Pointer(pBt)).FnPage = nPage - return 0 + return SQLITE_OK page1_init_failed: releasePageOne(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage1 */))) @@ -44939,7 +44329,7 @@ page1_init_failed: // If there is a transaction in progress, this routine is a no-op. func unlockBtreeIfUnused(tls *libc.TLS, pBt uintptr) { /* sqlite3.c:67751:13: */ - if (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == 0) && ((*BtShared)(unsafe.Pointer(pBt)).FpPage1 != uintptr(0)) { + if (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_NONE) && ((*BtShared)(unsafe.Pointer(pBt)).FpPage1 != uintptr(0)) { var pPage1 uintptr = (*BtShared)(unsafe.Pointer(pBt)).FpPage1 (*BtShared)(unsafe.Pointer(pBt)).FpPage1 = uintptr(0) @@ -44956,7 +44346,7 @@ func newDatabase(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:67768:12: */ var rc int32 if (*BtShared)(unsafe.Pointer(pBt)).FnPage > U32(0) { - return 0 + return SQLITE_OK } pP1 = (*BtShared)(unsafe.Pointer(pBt)).FpPage1 @@ -44967,24 +44357,24 @@ func newDatabase(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:67768:12: */ } libc.Xmemcpy(tls, data, uintptr(unsafe.Pointer(&zMagicHeader)), uint64(unsafe.Sizeof(zMagicHeader))) - *(*uint8)(unsafe.Pointer(data + uintptr(16))) = (U8(((*BtShared)(unsafe.Pointer(pBt)).FpageSize >> 8) & U32(0xff))) - *(*uint8)(unsafe.Pointer(data + uintptr(17))) = (U8(((*BtShared)(unsafe.Pointer(pBt)).FpageSize >> 16) & U32(0xff))) - *(*uint8)(unsafe.Pointer(data + uintptr(18))) = uint8(1) - *(*uint8)(unsafe.Pointer(data + uintptr(19))) = uint8(1) + *(*uint8)(unsafe.Pointer(data + 16)) = (U8(((*BtShared)(unsafe.Pointer(pBt)).FpageSize >> 8) & U32(0xff))) + *(*uint8)(unsafe.Pointer(data + 17)) = (U8(((*BtShared)(unsafe.Pointer(pBt)).FpageSize >> 16) & U32(0xff))) + *(*uint8)(unsafe.Pointer(data + 18)) = uint8(1) + *(*uint8)(unsafe.Pointer(data + 19)) = uint8(1) - *(*uint8)(unsafe.Pointer(data + uintptr(20))) = (U8((*BtShared)(unsafe.Pointer(pBt)).FpageSize - (*BtShared)(unsafe.Pointer(pBt)).FusableSize)) - *(*uint8)(unsafe.Pointer(data + uintptr(21))) = uint8(64) - *(*uint8)(unsafe.Pointer(data + uintptr(22))) = uint8(32) - *(*uint8)(unsafe.Pointer(data + uintptr(23))) = uint8(32) - libc.Xmemset(tls, (data + uintptr(24)), 0, (uint64(100 - 24))) - zeroPage(tls, pP1, ((0x01 | 0x08) | 0x04)) - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0002)) + *(*uint8)(unsafe.Pointer(data + 20)) = (U8((*BtShared)(unsafe.Pointer(pBt)).FpageSize - (*BtShared)(unsafe.Pointer(pBt)).FusableSize)) + *(*uint8)(unsafe.Pointer(data + 21)) = uint8(64) + *(*uint8)(unsafe.Pointer(data + 22)) = uint8(32) + *(*uint8)(unsafe.Pointer(data + 23)) = uint8(32) + libc.Xmemset(tls, (data + 24), 0, (uint64(100 - 24))) + zeroPage(tls, pP1, ((PTF_INTKEY | PTF_LEAF) | PTF_LEAFDATA)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_PAGESIZE_FIXED)) - Xsqlite3Put4byte(tls, (data + uintptr((36 + (4 * 4)))), uint32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum)) - Xsqlite3Put4byte(tls, (data + uintptr((36 + (7 * 4)))), uint32((*BtShared)(unsafe.Pointer(pBt)).FincrVacuum)) + Xsqlite3Put4byte(tls, (data + 52), uint32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum)) + Xsqlite3Put4byte(tls, (data + 64), uint32((*BtShared)(unsafe.Pointer(pBt)).FincrVacuum)) (*BtShared)(unsafe.Pointer(pBt)).FnPage = U32(1) - *(*uint8)(unsafe.Pointer(data + uintptr(31))) = uint8(1) - return 0 + *(*uint8)(unsafe.Pointer(data + 31)) = uint8(1) + return SQLITE_OK } // Initialize the first page of the database file (creating a database @@ -45041,33 +44431,33 @@ func Xsqlite3BtreeBeginTrans(tls *libc.TLS, p uintptr, wrflag int32, pSchemaVers var pPage1 uintptr pBt = (*Btree)(unsafe.Pointer(p)).FpBt pPager = (*BtShared)(unsafe.Pointer(pBt)).FpPager - rc = 0 + rc = SQLITE_OK Xsqlite3BtreeEnter(tls, p) // If the btree is already in a write-transaction, or it // is already in a read-transaction and a read-transaction // is requested, this is a no-op. - if !((int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 2) || ((int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 1) && !(wrflag != 0))) { + if !((int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE) || ((int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_READ) && !(wrflag != 0))) { goto __1 } goto trans_begun __1: ; - if !((((*Sqlite3)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).Fdb)).Fflags & uint64(0x02000000)) != 0) && + if !((((*Sqlite3)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).Fdb)).Fflags & SQLITE_ResetDatabase) != 0) && (int32(Xsqlite3PagerIsreadonly(tls, pPager)) == 0)) { goto __2 } - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0001))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_READ_ONLY))) __2: ; // Write transactions are not possible on a read-only database - if !(((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0001) != 0) && (wrflag != 0)) { + if !(((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_READ_ONLY) != 0) && (wrflag != 0)) { goto __3 } - rc = 8 + rc = SQLITE_READONLY goto trans_begun __3: ; @@ -45076,8 +44466,8 @@ __3: // If another database handle has already opened a write transaction // on this shared-btree structure and a second write transaction is // requested, return SQLITE_LOCKED. - if !(((wrflag != 0) && (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == 2)) || - ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0080) != 0)) { + if !(((wrflag != 0) && (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_WRITE)) || + ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_PENDING) != 0)) { goto __4 } pBlock = (*Btree)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpWriter)).Fdb @@ -45113,7 +44503,7 @@ __5: goto __11 } Xsqlite3ConnectionBlocked(tls, (*Btree)(unsafe.Pointer(p)).Fdb, pBlock) - rc = (6 | (int32(1) << 8)) + rc = (SQLITE_LOCKED | (int32(1) << 8)) goto trans_begun __11: ; @@ -45121,19 +44511,19 @@ __11: // Any read-only or read-write transaction implies a read-lock on // page 1. So if some other shared-cache client already has a write-lock // on page 1, the transaction cannot be opened. - rc = querySharedCacheTableLock(tls, p, uint32(1), uint8(1)) - if !(0 != rc) { + rc = querySharedCacheTableLock(tls, p, SCHEMA_ROOT, READ_LOCK) + if !(SQLITE_OK != rc) { goto __12 } goto trans_begun __12: ; - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0010))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_INITIALLY_EMPTY))) if !((*BtShared)(unsafe.Pointer(pBt)).FnPage == U32(0)) { goto __13 } - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0010)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_INITIALLY_EMPTY)) __13: ; __14: @@ -45146,36 +44536,36 @@ __14: // file is not pBt->pageSize. In this case lockBtree() will update // pBt->pageSize to the page-size of the file on disk. __17: - if !(((*BtShared)(unsafe.Pointer(pBt)).FpPage1 == uintptr(0)) && (0 == (libc.AssignInt32(&rc, lockBtree(tls, pBt))))) { + if !(((*BtShared)(unsafe.Pointer(pBt)).FpPage1 == uintptr(0)) && (SQLITE_OK == (libc.AssignInt32(&rc, lockBtree(tls, pBt))))) { goto __18 } goto __17 __18: ; - if !((rc == 0) && (wrflag != 0)) { + if !((rc == SQLITE_OK) && (wrflag != 0)) { goto __19 } - if !((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0001) != 0) { + if !((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_READ_ONLY) != 0) { goto __20 } - rc = 8 + rc = SQLITE_READONLY goto __21 __20: rc = Xsqlite3PagerBegin(tls, pPager, (libc.Bool32(wrflag > 1)), Xsqlite3TempInMemory(tls, (*Btree)(unsafe.Pointer(p)).Fdb)) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __22 } rc = newDatabase(tls, pBt) goto __23 __22: - if !((rc == (5 | (int32(2) << 8))) && (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == 0)) { + if !((rc == (SQLITE_BUSY | (int32(2) << 8))) && (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_NONE)) { goto __24 } // if there was no transaction opened when this function was // called and SQLITE_BUSY_SNAPSHOT is returned, change the error // code to SQLITE_BUSY. - rc = 5 + rc = SQLITE_BUSY __24: ; __23: @@ -45185,7 +44575,7 @@ __21: __19: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __25 } @@ -45194,17 +44584,17 @@ __25: ; goto __15 __15: - if (((rc & 0xFF) == 5) && (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == 0)) && (btreeInvokeBusyHandler(tls, pBt) != 0) { + if (((rc & 0xFF) == SQLITE_BUSY) && (int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) == TRANS_NONE)) && (btreeInvokeBusyHandler(tls, pBt) != 0) { goto __14 } goto __16 __16: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __26 } - if !(int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 0) { + if !(int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_NONE) { goto __27 } (*BtShared)(unsafe.Pointer(pBt)).FnTransaction++ @@ -45212,7 +44602,7 @@ __16: goto __28 } - (*Btree)(unsafe.Pointer(p)).Flock.FeLock = U8(1) + (*Btree)(unsafe.Pointer(p)).Flock.FeLock = READ_LOCK (*Btree)(unsafe.Pointer(p)).Flock.FpNext = (*BtShared)(unsafe.Pointer(pBt)).FpLock (*BtShared)(unsafe.Pointer(pBt)).FpLock = (p + 48 /* &.lock */) __28: @@ -45221,9 +44611,9 @@ __27: ; (*Btree)(unsafe.Pointer(p)).FinTrans = func() uint8 { if wrflag != 0 { - return uint8(2) + return TRANS_WRITE } - return uint8(1) + return TRANS_READ }() if !(int32((*Btree)(unsafe.Pointer(p)).FinTrans) > int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction)) { goto __29 @@ -45237,11 +44627,11 @@ __29: pPage1 = (*BtShared)(unsafe.Pointer(pBt)).FpPage1 (*BtShared)(unsafe.Pointer(pBt)).FpWriter = p - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0040))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_EXCLUSIVE))) if !(wrflag > 1) { goto __31 } - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0040)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_EXCLUSIVE)) __31: ; @@ -45250,14 +44640,14 @@ __31: // this sooner rather than later means the database size can safely // re-read the database size from page 1 if a savepoint or transaction // rollback occurs within the transaction. - if !((*BtShared)(unsafe.Pointer(pBt)).FnPage != Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData+uintptr(28)))) { + if !((*BtShared)(unsafe.Pointer(pBt)).FnPage != Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData+28))) { goto __32 } rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPage1)).FpDbPage) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __33 } - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(28)), (*BtShared)(unsafe.Pointer(pBt)).FnPage) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 28), (*BtShared)(unsafe.Pointer(pBt)).FnPage) __33: ; __32: @@ -45268,13 +44658,13 @@ __26: ; trans_begun: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __34 } if !(pSchemaVersion != 0) { goto __35 } - *(*int32)(unsafe.Pointer(pSchemaVersion)) = int32(Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(40)))) + *(*int32)(unsafe.Pointer(pSchemaVersion)) = int32(Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 40))) __35: ; if !(wrflag != 0) { @@ -45308,11 +44698,11 @@ func setChildPtrmaps(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:68036:12 var pgno Pgno = (*MemPage)(unsafe.Pointer(pPage)).Fpgno if (*MemPage)(unsafe.Pointer(pPage)).FisInit != 0 { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK } else { *(*int32)(unsafe.Pointer(bp /* rc */)) = btreeInitPage(tls, pPage) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } nCell = int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) @@ -45324,13 +44714,13 @@ func setChildPtrmaps(tls *libc.TLS, pPage uintptr) int32 { /* sqlite3.c:68036:12 if !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) { var childPgno Pgno = Xsqlite3Get4byte(tls, pCell) - ptrmapPut(tls, pBt, childPgno, uint8(5), pgno, bp /* &rc */) + ptrmapPut(tls, pBt, childPgno, PTRMAP_BTREE, pgno, bp /* &rc */) } } if !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) { var childPgno Pgno = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr((int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset) + 8)))) - ptrmapPut(tls, pBt, childPgno, uint8(5), pgno, bp /* &rc */) + ptrmapPut(tls, pBt, childPgno, PTRMAP_BTREE, pgno, bp /* &rc */) } return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -45352,7 +44742,7 @@ func modifyPagePointer(tls *libc.TLS, pPage uintptr, iFrom Pgno, iTo Pgno, eType bp := tls.Alloc(24) defer tls.Free(24) - if int32(eType) == 4 { + if int32(eType) == PTRMAP_OVERFLOW2 { // The pointer is always the first 4 bytes of the page in this case. if Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pPage)).FaData) != iFrom { return Xsqlite3CorruptError(tls, 68087) @@ -45364,7 +44754,7 @@ func modifyPagePointer(tls *libc.TLS, pPage uintptr, iFrom Pgno, iTo Pgno, eType var rc int32 if (*MemPage)(unsafe.Pointer(pPage)).FisInit != 0 { - rc = 0 + rc = SQLITE_OK } else { rc = btreeInitPage(tls, pPage) } @@ -45375,7 +44765,7 @@ func modifyPagePointer(tls *libc.TLS, pPage uintptr, iFrom Pgno, iTo Pgno, eType for i = 0; i < nCell; i++ { var pCell uintptr = ((*MemPage)(unsafe.Pointer((pPage))).FaData + uintptr((int32((*MemPage)(unsafe.Pointer((pPage))).FmaskPage) & int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(((*MemPage)(unsafe.Pointer((pPage))).FaCellIdx + uintptr((2 * (i))))))))))) - if int32(eType) == 3 { + if int32(eType) == PTRMAP_OVERFLOW1 { // var info CellInfo at bp, 24 (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer((pPage + 128 /* &.xParseCell */))))(tls, pPage, pCell, bp /* &info */) @@ -45397,13 +44787,13 @@ func modifyPagePointer(tls *libc.TLS, pPage uintptr, iFrom Pgno, iTo Pgno, eType } if i == nCell { - if (int32(eType) != 5) || (Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr((int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+8)))) != iFrom) { + if (int32(eType) != PTRMAP_BTREE) || (Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage)).FaData+uintptr((int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)+8)))) != iFrom) { return Xsqlite3CorruptError(tls, 68124) } Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage)).FaData + uintptr((int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset) + 8))), iTo) } } - return 0 + return SQLITE_OK } // Move the open database page pDbPage to location iFreePage in the @@ -45430,7 +44820,7 @@ func relocatePage(tls *libc.TLS, pBt uintptr, pDbPage uintptr, eType U8, iPtrPag // Move page iDbPage from its current location to page number iFreePage *(*int32)(unsafe.Pointer(bp /* rc */)) = Xsqlite3PagerMovepage(tls, pPager, (*MemPage)(unsafe.Pointer(pDbPage)).FpDbPage, iFreePage, isCommit) - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } (*MemPage)(unsafe.Pointer(pDbPage)).Fpgno = iFreePage @@ -45442,16 +44832,16 @@ func relocatePage(tls *libc.TLS, pBt uintptr, pDbPage uintptr, eType U8, iPtrPag // If pDbPage is an overflow page, then the first 4 bytes may store a // pointer to a subsequent overflow page. If this is the case, then // the pointer map needs to be updated for the subsequent overflow page. - if (int32(eType) == 5) || (int32(eType) == 1) { + if (int32(eType) == PTRMAP_BTREE) || (int32(eType) == PTRMAP_ROOTPAGE) { *(*int32)(unsafe.Pointer(bp /* rc */)) = setChildPtrmaps(tls, pDbPage) - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } } else { var nextOvfl Pgno = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(pDbPage)).FaData) if nextOvfl != Pgno(0) { - ptrmapPut(tls, pBt, nextOvfl, uint8(4), iFreePage, bp /* &rc */) - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + ptrmapPut(tls, pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, bp /* &rc */) + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } } @@ -45460,19 +44850,19 @@ func relocatePage(tls *libc.TLS, pBt uintptr, pDbPage uintptr, eType U8, iPtrPag // Fix the database pointer on page iPtrPage that pointed at iDbPage so // that it points at iFreePage. Also fix the pointer map entry for // iPtrPage. - if int32(eType) != 1 { + if int32(eType) != PTRMAP_ROOTPAGE { *(*int32)(unsafe.Pointer(bp /* rc */)) = btreeGetPage(tls, pBt, iPtrPage, bp+8 /* &pPtrPage */, 0) - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp /* rc */)) } *(*int32)(unsafe.Pointer(bp /* rc */)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pPtrPage */)))).FpDbPage) - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPtrPage */))) return *(*int32)(unsafe.Pointer(bp /* rc */)) } *(*int32)(unsafe.Pointer(bp /* rc */)) = modifyPagePointer(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPtrPage */)), iDbPage, iFreePage, eType) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPtrPage */))) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { ptrmapPut(tls, pBt, iFreePage, eType, iPtrPage, bp /* &rc */) } } @@ -45506,20 +44896,20 @@ func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit // var iPtrPage Pgno at bp+4, 4 - nFreeList = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(36))) + nFreeList = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 36)) if nFreeList == Pgno(0) { - return 101 + return SQLITE_DONE } rc = ptrmapGet(tls, pBt, iLastPg, bp /* &eType */, bp+4 /* &iPtrPage */) - if rc != 0 { + if rc != SQLITE_OK { return rc } - if int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == 1 { + if int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == PTRMAP_ROOTPAGE { return Xsqlite3CorruptError(tls, 68257) } - if int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == 2 { + if int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == PTRMAP_FREEPAGE { if bCommit == 0 { // Remove the page from the files free-list. This is not required // if bCommit is non-zero. In that case, the free-list will be @@ -45529,8 +44919,8 @@ func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit // var pFreePg uintptr at bp+8, 8 - rc = allocateBtreePage(tls, pBt, bp+8 /* &pFreePg */, bp+16 /* &iFreePg */, iLastPg, uint8(1)) - if rc != 0 { + rc = allocateBtreePage(tls, pBt, bp+8 /* &pFreePg */, bp+16 /* &iFreePg */, iLastPg, BTALLOC_EXACT) + if rc != SQLITE_OK { return rc } @@ -45541,11 +44931,11 @@ func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit // Index of free page to move pLastPg to // var pLastPg uintptr at bp+24, 8 - var eMode U8 = U8(0) // Mode parameter for allocateBtreePage() - var iNear Pgno = Pgno(0) // nearby parameter for allocateBtreePage() + var eMode U8 = BTALLOC_ANY // Mode parameter for allocateBtreePage() + var iNear Pgno = Pgno(0) // nearby parameter for allocateBtreePage() rc = btreeGetPage(tls, pBt, iLastPg, bp+24 /* &pLastPg */, 0) - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -45556,14 +44946,14 @@ func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit // looping until a free-page located within the first nFin pages // of the file is found. if bCommit == 0 { - eMode = U8(2) + eMode = BTALLOC_LE iNear = nFin } for ok := true; ok; ok = ((bCommit != 0) && (*(*Pgno)(unsafe.Pointer(bp + 40 /* iFreePg */)) > nFin)) { // var pFreePg uintptr at bp+32, 8 rc = allocateBtreePage(tls, pBt, bp+32 /* &pFreePg */, bp+40 /* &iFreePg */, iNear, eMode) - if rc != 0 { + if rc != SQLITE_OK { releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pLastPg */))) return rc } @@ -45572,7 +44962,7 @@ func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit rc = relocatePage(tls, pBt, *(*uintptr)(unsafe.Pointer(bp + 24 /* pLastPg */)), *(*U8)(unsafe.Pointer(bp /* eType */)), *(*Pgno)(unsafe.Pointer(bp + 4 /* iPtrPage */)), *(*Pgno)(unsafe.Pointer(bp + 40 /* iFreePg */)), bCommit) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pLastPg */))) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -45585,7 +44975,7 @@ func incrVacuumStep(tls *libc.TLS, pBt uintptr, nFin Pgno, iLastPg Pgno, bCommit (*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate = U8(1) (*BtShared)(unsafe.Pointer(pBt)).FnPage = iLastPg } - return 0 + return SQLITE_OK } // The database opened by the first argument is an auto-vacuum database @@ -45622,26 +45012,26 @@ func Xsqlite3BtreeIncrVacuum(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:6835 Xsqlite3BtreeEnter(tls, p) if !(int32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum) != 0) { - rc = 101 + rc = SQLITE_DONE } else { var nOrig Pgno = btreePagecount(tls, pBt) - var nFree Pgno = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(36))) + var nFree Pgno = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 36)) var nFin Pgno = finalDbSize(tls, pBt, nOrig, nFree) if (nOrig < nFin) || (nFree >= nOrig) { rc = Xsqlite3CorruptError(tls, 68372) } else if nFree > Pgno(0) { rc = saveAllCursors(tls, pBt, uint32(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { invalidateAllOverflowCache(tls, pBt) rc = incrVacuumStep(tls, pBt, nFin, nOrig, 0) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(28)), (*BtShared)(unsafe.Pointer(pBt)).FnPage) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 28), (*BtShared)(unsafe.Pointer(pBt)).FnPage) } } else { - rc = 101 + rc = SQLITE_DONE } } Xsqlite3BtreeLeave(tls, p) @@ -45656,7 +45046,7 @@ func Xsqlite3BtreeIncrVacuum(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:6835 // i.e. the database has been reorganized so that only the first *pnTrunc // pages are in use. func autoVacuumCommit(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:68400:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pPager uintptr = (*BtShared)(unsafe.Pointer(pBt)).FpPager invalidateAllOverflowCache(tls, pBt) @@ -45675,7 +45065,7 @@ func autoVacuumCommit(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:68400:12: return Xsqlite3CorruptError(tls, 68420) } - nFree = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(36))) + nFree = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 36)) nFin = finalDbSize(tls, pBt, nOrig, nFree) if nFin > nOrig { return Xsqlite3CorruptError(tls, 68425) @@ -45683,18 +45073,18 @@ func autoVacuumCommit(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:68400:12: if nFin < nOrig { rc = saveAllCursors(tls, pBt, uint32(0), uintptr(0)) } - for iFree = nOrig; (iFree > nFin) && (rc == 0); iFree-- { + for iFree = nOrig; (iFree > nFin) && (rc == SQLITE_OK); iFree-- { rc = incrVacuumStep(tls, pBt, nFin, iFree, 1) } - if ((rc == 101) || (rc == 0)) && (nFree > Pgno(0)) { + if ((rc == SQLITE_DONE) || (rc == SQLITE_OK)) && (nFree > Pgno(0)) { rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(32)), uint32(0)) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(36)), uint32(0)) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(28)), nFin) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 32), uint32(0)) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 36), uint32(0)) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 28), nFin) (*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate = U8(1) (*BtShared)(unsafe.Pointer(pBt)).FnPage = nFin } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3PagerRollback(tls, pPager) } } @@ -45727,13 +45117,13 @@ func autoVacuumCommit(tls *libc.TLS, pBt uintptr) int32 { /* sqlite3.c:68400:12: // Once this is routine has returned, the only thing required to commit // the write-transaction for this database file is to delete the journal. func Xsqlite3BtreeCommitPhaseOne(tls *libc.TLS, p uintptr, zSuperJrnl uintptr) int32 { /* sqlite3.c:68479:20: */ - var rc int32 = 0 - if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 2 { + var rc int32 = SQLITE_OK + if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE { var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt Xsqlite3BtreeEnter(tls, p) if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { rc = autoVacuumCommit(tls, pBt) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3BtreeLeave(tls, p) return rc } @@ -45754,28 +45144,28 @@ func btreeEndTransaction(tls *libc.TLS, p uintptr) { /* sqlite3.c:68506:13: */ var db uintptr = (*Btree)(unsafe.Pointer(p)).Fdb (*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate = U8(0) - if (int32((*Btree)(unsafe.Pointer(p)).FinTrans) > 0) && ((*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead > 1) { + if (int32((*Btree)(unsafe.Pointer(p)).FinTrans) > TRANS_NONE) && ((*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead > 1) { // If there are other active statements that belong to this database // handle, downgrade to a read-only transaction. The other statements // may still be reading from the database. downgradeAllSharedCacheTableLocks(tls, p) - (*Btree)(unsafe.Pointer(p)).FinTrans = U8(1) + (*Btree)(unsafe.Pointer(p)).FinTrans = TRANS_READ } else { // If the handle had any kind of transaction open, decrement the // transaction count of the shared btree. If the transaction count // reaches 0, set the shared state to TRANS_NONE. The unlockBtreeIfUnused() // call below will unlock the pager. - if int32((*Btree)(unsafe.Pointer(p)).FinTrans) != 0 { + if int32((*Btree)(unsafe.Pointer(p)).FinTrans) != TRANS_NONE { clearAllSharedCacheTableLocks(tls, p) (*BtShared)(unsafe.Pointer(pBt)).FnTransaction-- if 0 == (*BtShared)(unsafe.Pointer(pBt)).FnTransaction { - (*BtShared)(unsafe.Pointer(pBt)).FinTransaction = U8(0) + (*BtShared)(unsafe.Pointer(pBt)).FinTransaction = TRANS_NONE } } // Set the current transaction state to TRANS_NONE and unlock the // pager if this call closed the only read or write transaction. - (*Btree)(unsafe.Pointer(p)).FinTrans = U8(0) + (*Btree)(unsafe.Pointer(p)).FinTrans = TRANS_NONE unlockBtreeIfUnused(tls, pBt) } @@ -45807,30 +45197,30 @@ func btreeEndTransaction(tls *libc.TLS, p uintptr) { /* sqlite3.c:68506:13: */ // are no active cursors, it also releases the read lock. func Xsqlite3BtreeCommitPhaseTwo(tls *libc.TLS, p uintptr, bCleanup int32) int32 { /* sqlite3.c:68568:20: */ - if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 0 { - return 0 + if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_NONE { + return SQLITE_OK } Xsqlite3BtreeEnter(tls, p) // If the handle has a write-transaction open, commit the shared-btrees // transaction and set the shared state to TRANS_READ. - if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 2 { + if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE { var rc int32 var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt rc = Xsqlite3PagerCommitPhaseTwo(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) - if (rc != 0) && (bCleanup == 0) { + if (rc != SQLITE_OK) && (bCleanup == 0) { Xsqlite3BtreeLeave(tls, p) return rc } (*Btree)(unsafe.Pointer(p)).FiDataVersion-- // Compensate for pPager->iDataVersion++; - (*BtShared)(unsafe.Pointer(pBt)).FinTransaction = U8(1) + (*BtShared)(unsafe.Pointer(pBt)).FinTransaction = TRANS_READ btreeClearHasContent(tls, pBt) } btreeEndTransaction(tls, p) Xsqlite3BtreeLeave(tls, p) - return 0 + return SQLITE_OK } // Do both phases of a commit. @@ -45838,7 +45228,7 @@ func Xsqlite3BtreeCommit(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:68600:20 var rc int32 Xsqlite3BtreeEnter(tls, p) rc = Xsqlite3BtreeCommitPhaseOne(tls, p, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3BtreeCommitPhaseTwo(tls, p, 0) } Xsqlite3BtreeLeave(tls, p) @@ -45871,22 +45261,22 @@ func Xsqlite3BtreeCommit(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:68600:20 // saving a cursor position, an SQLite error code. func Xsqlite3BtreeTripAllCursors(tls *libc.TLS, pBtree uintptr, errCode int32, writeOnly int32) int32 { /* sqlite3.c:68637:20: */ var p uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK if pBtree != 0 { Xsqlite3BtreeEnter(tls, pBtree) for p = (*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBtree)).FpBt)).FpCursor; p != 0; p = (*BtCursor)(unsafe.Pointer(p)).FpNext { - if (writeOnly != 0) && ((int32((*BtCursor)(unsafe.Pointer(p)).FcurFlags) & 0x01) == 0) { - if (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == 0) || (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == 2) { + if (writeOnly != 0) && ((int32((*BtCursor)(unsafe.Pointer(p)).FcurFlags) & BTCF_WriteFlag) == 0) { + if (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_VALID) || (int32((*BtCursor)(unsafe.Pointer(p)).FeState) == CURSOR_SKIPNEXT) { rc = saveCursorPosition(tls, p) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3BtreeTripAllCursors(tls, pBtree, rc, 0) break } } } else { Xsqlite3BtreeClearCursor(tls, p) - (*BtCursor)(unsafe.Pointer(p)).FeState = U8(4) + (*BtCursor)(unsafe.Pointer(p)).FeState = CURSOR_FAULT (*BtCursor)(unsafe.Pointer(p)).FskipNext = errCode } btreeReleaseAllCursorPages(tls, p) @@ -45902,7 +45292,7 @@ func btreeSetNPage(tls *libc.TLS, pBt uintptr, pPage1 uintptr) { /* sqlite3.c:68 bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* nPage */)) = int32(Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(28)))) + *(*int32)(unsafe.Pointer(bp /* nPage */)) = int32(Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 28))) if *(*int32)(unsafe.Pointer(bp /* nPage */)) == 0 { Xsqlite3PagerPagecount(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, bp /* &nPage */) @@ -45929,39 +45319,39 @@ func Xsqlite3BtreeRollback(tls *libc.TLS, p uintptr, tripCode int32, writeOnly i // var pPage1 uintptr at bp, 8 Xsqlite3BtreeEnter(tls, p) - if tripCode == 0 { + if tripCode == SQLITE_OK { rc = libc.AssignInt32(&tripCode, saveAllCursors(tls, pBt, uint32(0), uintptr(0))) if rc != 0 { writeOnly = 0 } } else { - rc = 0 + rc = SQLITE_OK } if tripCode != 0 { var rc2 int32 = Xsqlite3BtreeTripAllCursors(tls, p, tripCode, writeOnly) - if rc2 != 0 { + if rc2 != SQLITE_OK { rc = rc2 } } - if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 2 { + if int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE { var rc2 int32 rc2 = Xsqlite3PagerRollback(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) - if rc2 != 0 { + if rc2 != SQLITE_OK { rc = rc2 } // The rollback may have destroyed the pPage1->aData value. So // call btreeGetPage() on page 1 again to make // sure pPage1->aData is set correctly. - if btreeGetPage(tls, pBt, uint32(1), bp /* &pPage1 */, 0) == 0 { + if btreeGetPage(tls, pBt, uint32(1), bp /* &pPage1 */, 0) == SQLITE_OK { btreeSetNPage(tls, pBt, *(*uintptr)(unsafe.Pointer(bp /* pPage1 */))) releasePageOne(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage1 */))) } - (*BtShared)(unsafe.Pointer(pBt)).FinTransaction = U8(1) + (*BtShared)(unsafe.Pointer(pBt)).FinTransaction = TRANS_READ btreeClearHasContent(tls, pBt) } @@ -46011,19 +45401,19 @@ func Xsqlite3BtreeBeginStmt(tls *libc.TLS, p uintptr, iStatement int32) int32 { // from a normal transaction rollback, as no locks are released and the // transaction remains open. func Xsqlite3BtreeSavepoint(tls *libc.TLS, p uintptr, op int32, iSavepoint int32) int32 { /* sqlite3.c:68784:20: */ - var rc int32 = 0 - if (p != 0) && (int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 2) { + var rc int32 = SQLITE_OK + if (p != 0) && (int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE) { var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt Xsqlite3BtreeEnter(tls, p) - if op == 2 { + if op == SAVEPOINT_ROLLBACK { rc = saveAllCursors(tls, pBt, uint32(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerSavepoint(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, op, iSavepoint) } - if rc == 0 { - if (iSavepoint < 0) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0010) != 0) { + if rc == SQLITE_OK { + if (iSavepoint < 0) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_INITIALLY_EMPTY) != 0) { (*BtShared)(unsafe.Pointer(pBt)).FnPage = U32(0) } rc = newDatabase(tls, pBt) @@ -46092,7 +45482,7 @@ func btreeCursor(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pKeyInfo u if wrFlag != 0 { allocateTempSpace(tls, pBt) if (*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace == uintptr(0) { - return 7 + return SQLITE_NOMEM } } if iTable <= Pgno(1) { @@ -46113,7 +45503,7 @@ func btreeCursor(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pKeyInfo u (*BtCursor)(unsafe.Pointer(pCur)).FpBt = pBt (*BtCursor)(unsafe.Pointer(pCur)).FcurFlags = func() uint8 { if wrFlag != 0 { - return uint8(0x01) + return BTCF_WriteFlag } return uint8(0) }() @@ -46121,20 +45511,20 @@ func btreeCursor(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pKeyInfo u if wrFlag != 0 { return uint8(0) } - return uint8(0x02) + return PAGER_GET_READONLY }() // If there are two or more cursors on the same btree, then all such // cursors *must* have the BTCF_Multiple flag set. for pX = (*BtShared)(unsafe.Pointer(pBt)).FpCursor; pX != 0; pX = (*BtCursor)(unsafe.Pointer(pX)).FpNext { if (*BtCursor)(unsafe.Pointer(pX)).FpgnoRoot == iTable { - *(*U8)(unsafe.Pointer(pX + 1 /* &.curFlags */)) |= U8((0x20)) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x20)) + *(*U8)(unsafe.Pointer(pX + 1 /* &.curFlags */)) |= U8((BTCF_Multiple)) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_Multiple)) } } (*BtCursor)(unsafe.Pointer(pCur)).FpNext = (*BtShared)(unsafe.Pointer(pBt)).FpCursor (*BtShared)(unsafe.Pointer(pBt)).FpCursor = pCur - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) - return 0 + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID + return SQLITE_OK } func btreeCursorWithLock(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pKeyInfo uintptr, pCur uintptr) int32 { /* sqlite3.c:68920:12: */ @@ -46161,7 +45551,7 @@ func Xsqlite3BtreeCursor(tls *libc.TLS, p uintptr, iTable Pgno, wrFlag int32, pK // to users so they cannot do the sizeof() themselves - they must call // this routine. func Xsqlite3BtreeCursorSize(tls *libc.TLS) int32 { /* sqlite3.c:68955:20: */ - return (int32(((uint64(unsafe.Sizeof(BtCursor{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + return (int32(((uint64(unsafe.Sizeof(BtCursor{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) } // Initialize memory that will be converted into a BtCursor object. @@ -46201,7 +45591,7 @@ func Xsqlite3BtreeCloseCursor(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c: Xsqlite3BtreeLeave(tls, pBtree) (*BtCursor)(unsafe.Pointer(pCur)).FpBtree = uintptr(0) } - return 0 + return SQLITE_OK } // Make sure the BtCursor* given in the argument has a valid @@ -46212,7 +45602,7 @@ func Xsqlite3BtreeCloseCursor(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c: // Using this cache reduces the number of calls to btreeParseCell(). func getCellInfo(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:69029:29: */ if int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize) == 0 { - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x02)) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_ValidNKey)) btreeParseCell(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpPage, int32((*BtCursor)(unsafe.Pointer(pCur)).Fix), (pCur + 48 /* &.info */)) } else { @@ -46221,7 +45611,7 @@ func getCellInfo(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:69029:29: */ func Xsqlite3BtreeCursorIsValidNN(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:69048:20: */ - return (libc.Bool32(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 0)) + return (libc.Bool32(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID)) } // Return the value of the integer key or "rowid" for a table btree. @@ -46237,12 +45627,12 @@ func Xsqlite3BtreeIntegerKey(tls *libc.TLS, pCur uintptr) I64 { /* sqlite3.c:690 // Pin or unpin a cursor. func Xsqlite3BtreeCursorPin(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:69070:21: */ - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x40)) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_Pinned)) } func Xsqlite3BtreeCursorUnpin(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:69074:21: */ - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x40))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_Pinned))) } // Return the offset into the database file for the start of the @@ -46305,7 +45695,7 @@ func getOverflowPage(tls *libc.TLS, pBt uintptr, ovfl Pgno, ppPage uintptr, pPgn var next Pgno = Pgno(0) *(*uintptr)(unsafe.Pointer(bp + 8 /* pPage */)) = uintptr(0) - var rc int32 = 0 + var rc int32 = SQLITE_OK // Try to find the next page in the overflow list using the // autovacuum pointer-map pages. Guess that the next page in @@ -46324,22 +45714,22 @@ func getOverflowPage(tls *libc.TLS, pBt uintptr, ovfl Pgno, ppPage uintptr, pPgn if iGuess <= btreePagecount(tls, pBt) { rc = ptrmapGet(tls, pBt, iGuess, bp /* &eType */, bp+4 /* &pgno */) - if ((rc == 0) && (int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == 4)) && (*(*Pgno)(unsafe.Pointer(bp + 4 /* pgno */)) == ovfl) { + if ((rc == SQLITE_OK) && (int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == PTRMAP_OVERFLOW2)) && (*(*Pgno)(unsafe.Pointer(bp + 4 /* pgno */)) == ovfl) { next = iGuess - rc = 101 + rc = SQLITE_DONE } } } - if rc == 0 { + if rc == SQLITE_OK { rc = btreeGetPage(tls, pBt, ovfl, bp+8 /* &pPage */, func() int32 { if ppPage == uintptr(0) { - return 0x02 + return PAGER_GET_READONLY } return 0 }()) - if rc == 0 { + if rc == SQLITE_OK { next = Xsqlite3Get4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pPage */)))).FaData) } } @@ -46351,8 +45741,8 @@ func getOverflowPage(tls *libc.TLS, pBt uintptr, ovfl Pgno, ppPage uintptr, pPgn releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPage */))) } return func() int32 { - if rc == 101 { - return 0 + if rc == SQLITE_DONE { + return SQLITE_OK } return rc }() @@ -46371,7 +45761,7 @@ func copyPayload(tls *libc.TLS, pPayload uintptr, pBuf uintptr, nByte int32, eOp if eOp != 0 { // Copy data from buffer to page (a write operation) var rc int32 = Xsqlite3PagerWrite(tls, pDbPage) - if rc != 0 { + if rc != SQLITE_OK { return rc } libc.Xmemcpy(tls, pPayload, pBuf, uint64(nByte)) @@ -46379,7 +45769,7 @@ func copyPayload(tls *libc.TLS, pPayload uintptr, pBuf uintptr, nByte int32, eOp // Copy data from page to buffer (a read operation) libc.Xmemcpy(tls, pBuf, pPayload, uint64(nByte)) } - return 0 + return SQLITE_OK } // This function is used to read or overwrite payload information @@ -46414,7 +45804,7 @@ func accessPayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintpt defer tls.Free(16) var aPayload uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK var iIdx int32 = 0 var pPage uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpPage // Btree page of current entry var pBt uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpBt // Btree this cursor belongs to @@ -46444,7 +45834,7 @@ func accessPayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintpt offset = offset - (U32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)) } - if (rc == 0) && (amt > U32(0)) { + if (rc == SQLITE_OK) && (amt > U32(0)) { var ovflSize U32 = ((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(4)) // Bytes content per ovfl page // var nextPage Pgno at bp, 4 @@ -46456,20 +45846,20 @@ func accessPayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintpt // in the overflow chain. The page number of the first overflow page is // stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array // means "not yet known" (the cache is lazily populated). - if (int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x04) == 0 { + if (int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_ValidOvfl) == 0 { var nOvfl int32 = (int32(((((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnPayload - U32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal)) + ovflSize) - U32(1)) / ovflSize)) if ((*BtCursor)(unsafe.Pointer(pCur)).FaOverflow == uintptr(0)) || ((nOvfl * int32(unsafe.Sizeof(Pgno(0)))) > Xsqlite3MallocSize(tls, (*BtCursor)(unsafe.Pointer(pCur)).FaOverflow)) { var aNew uintptr = Xsqlite3Realloc(tls, (*BtCursor)(unsafe.Pointer(pCur)).FaOverflow, (uint64((uint64(nOvfl * 2)) * uint64(unsafe.Sizeof(Pgno(0)))))) if aNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } else { (*BtCursor)(unsafe.Pointer(pCur)).FaOverflow = aNew } } libc.Xmemset(tls, (*BtCursor)(unsafe.Pointer(pCur)).FaOverflow, 0, (uint64(nOvfl) * uint64(unsafe.Sizeof(Pgno(0))))) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x04)) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_ValidOvfl)) } else { // If the overflow page-list cache has been allocated and the // entry for the first required overflow page is valid, skip @@ -46516,11 +45906,11 @@ func accessPayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintpt rc = Xsqlite3PagerGet(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, *(*Pgno)(unsafe.Pointer(bp /* nextPage */)), bp+8, /* &pDbPage */ func() int32 { if eOp == 0 { - return 0x02 + return PAGER_GET_READONLY } return 0 }()) - if rc == 0 { + if rc == SQLITE_OK { aPayload = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pDbPage */))) *(*Pgno)(unsafe.Pointer(bp /* nextPage */)) = Xsqlite3Get4byte(tls, aPayload) rc = copyPayload(tls, (aPayload + uintptr((offset + U32(4)))), pBuf, a, eOp, *(*uintptr)(unsafe.Pointer(bp + 8 /* pDbPage */))) @@ -46542,7 +45932,7 @@ func accessPayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintpt } } - if (rc == 0) && (amt > U32(0)) { + if (rc == SQLITE_OK) && (amt > U32(0)) { // Overflow chain ends prematurely return Xsqlite3CorruptError(tls, 69445) } @@ -46574,8 +45964,8 @@ func Xsqlite3BtreePayload(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf // interface. func accessPayloadChecked(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintptr) int32 { /* sqlite3.c:69481:28: */ var rc int32 - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 1 { - return 4 + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_INVALID { + return SQLITE_ABORT } rc = btreeRestoreCursorPosition(tls, pCur) @@ -46586,7 +45976,7 @@ func accessPayloadChecked(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf } func Xsqlite3BtreePayloadChecked(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pBuf uintptr) int32 { /* sqlite3.c:69495:20: */ - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 0 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID { return accessPayload(tls, pCur, offset, amt, pBuf, 0) } else { @@ -46657,11 +46047,11 @@ func Xsqlite3BtreePayloadFetch(tls *libc.TLS, pCur uintptr, pAmt uintptr) uintpt func moveToChild(tls *libc.TLS, pCur uintptr, newPgno U32) int32 { /* sqlite3.c:69577:12: */ var pBt uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpBt - if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) >= (20 - 1) { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) >= (BTCURSOR_MAX_DEPTH - 1) { return Xsqlite3CorruptError(tls, 69585) } (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32((0x02 | 0x04)))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32((BTCF_ValidNKey | BTCF_ValidOvfl)))) *(*U16)(unsafe.Pointer((pCur + 88 /* &.aiIdx */) + uintptr((*BtCursor)(unsafe.Pointer(pCur)).FiPage)*2)) = (*BtCursor)(unsafe.Pointer(pCur)).Fix *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */) + uintptr((*BtCursor)(unsafe.Pointer(pCur)).FiPage)*8)) = (*BtCursor)(unsafe.Pointer(pCur)).FpPage (*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(0) @@ -46679,7 +46069,7 @@ func moveToParent(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:69626:13: */ var pLeaf uintptr (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32((0x02 | 0x04)))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32((BTCF_ValidNKey | BTCF_ValidOvfl)))) (*BtCursor)(unsafe.Pointer(pCur)).Fix = *(*U16)(unsafe.Pointer((pCur + 88 /* &.aiIdx */) + uintptr((int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage)-1))*2)) pLeaf = (*BtCursor)(unsafe.Pointer(pCur)).FpPage (*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */) + uintptr(libc.PreDecInt8(&(*BtCursor)(unsafe.Pointer(pCur)).FiPage, 1))*8)) @@ -46709,7 +46099,7 @@ func moveToRoot(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:69667:12: */ var pRoot uintptr var rc int32 var subpage Pgno - rc = 0 + rc = SQLITE_OK if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) >= 0) { goto __1 @@ -46726,7 +46116,7 @@ __4: goto __4 __5: ; - (*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */) + uintptr(0)*8)) + (*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */))) goto skip_init __3: ; @@ -46735,15 +46125,15 @@ __1: if !((*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot == Pgno(0)) { goto __6 } - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) - return 16 + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID + return SQLITE_EMPTY goto __7 __6: ; - if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= 3) { + if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK) { goto __8 } - if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 4) { + if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_FAULT) { goto __9 } @@ -46755,10 +46145,10 @@ __8: ; rc = getAndInitPage(tls, (*Btree)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBtree)).FpBt, (*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, (pCur + 136 /* &.pPage */), uintptr(0), int32((*BtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __10 } - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID return rc __10: ; @@ -46791,13 +46181,13 @@ __11: skip_init: (*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(0) (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(((0x08 | 0x02) | 0x04)))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(((BTCF_AtLast | BTCF_ValidNKey) | BTCF_ValidOvfl)))) pRoot = (*BtCursor)(unsafe.Pointer(pCur)).FpPage if !(int32((*MemPage)(unsafe.Pointer(pRoot)).FnCell) > 0) { goto __12 } - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(0) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_VALID goto __13 __12: if !(!(int32((*MemPage)(unsafe.Pointer(pRoot)).Fleaf) != 0)) { @@ -46810,12 +46200,12 @@ __12: __16: ; subpage = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pRoot)).FaData + uintptr((int32((*MemPage)(unsafe.Pointer(pRoot)).FhdrOffset) + 8)))) - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(0) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_VALID rc = moveToChild(tls, pCur, subpage) goto __15 __14: - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) - rc = 16 + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID + rc = SQLITE_EMPTY __15: ; __13: @@ -46830,10 +46220,10 @@ __13: // in ascending order. func moveToLeftmost(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:69754:12: */ var pgno Pgno - var rc int32 = 0 + var rc int32 = SQLITE_OK var pPage uintptr - for (rc == 0) && !(int32((*MemPage)(unsafe.Pointer(libc.AssignUintptr(&pPage, (*BtCursor)(unsafe.Pointer(pCur)).FpPage))).Fleaf) != 0) { + for (rc == SQLITE_OK) && !(int32((*MemPage)(unsafe.Pointer(libc.AssignUintptr(&pPage, (*BtCursor)(unsafe.Pointer(pCur)).FpPage))).Fleaf) != 0) { pgno = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((pPage))).FaData + uintptr((int32((*MemPage)(unsafe.Pointer((pPage))).FmaskPage) & int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(((*MemPage)(unsafe.Pointer((pPage))).FaCellIdx + uintptr((2 * (int32((*BtCursor)(unsafe.Pointer(pCur)).Fix))))))))))))) rc = moveToChild(tls, pCur, pgno) @@ -46851,7 +46241,7 @@ func moveToLeftmost(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:69754:12: // key in ascending order. func moveToRightmost(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:69779:12: */ var pgno Pgno - var rc int32 = 0 + var rc int32 = SQLITE_OK var pPage uintptr = uintptr(0) for !(int32((*MemPage)(unsafe.Pointer(libc.AssignUintptr(&pPage, (*BtCursor)(unsafe.Pointer(pCur)).FpPage))).Fleaf) != 0) { @@ -46864,7 +46254,7 @@ func moveToRightmost(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:69779:12: } (*BtCursor)(unsafe.Pointer(pCur)).Fix = (U16(int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - 1)) - return 0 + return SQLITE_OK } // Move the cursor to the first entry in the table. Return SQLITE_OK @@ -46874,14 +46264,14 @@ func Xsqlite3BtreeFirst(tls *libc.TLS, pCur uintptr, pRes uintptr) int32 { /* sq var rc int32 rc = moveToRoot(tls, pCur) - if rc == 0 { + if rc == SQLITE_OK { *(*int32)(unsafe.Pointer(pRes)) = 0 rc = moveToLeftmost(tls, pCur) - } else if rc == 16 { + } else if rc == SQLITE_EMPTY { *(*int32)(unsafe.Pointer(pRes)) = 1 - rc = 0 + rc = SQLITE_OK } return rc } @@ -46893,25 +46283,25 @@ func Xsqlite3BtreeLast(tls *libc.TLS, pCur uintptr, pRes uintptr) int32 { /* sql var rc int32 // If the cursor already points to the last entry, this is a no-op. - if (0 == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState)) && ((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x08) != 0) { + if (CURSOR_VALID == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState)) && ((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_AtLast) != 0) { *(*int32)(unsafe.Pointer(pRes)) = 0 - return 0 + return SQLITE_OK } rc = moveToRoot(tls, pCur) - if rc == 0 { + if rc == SQLITE_OK { *(*int32)(unsafe.Pointer(pRes)) = 0 rc = moveToRightmost(tls, pCur) - if rc == 0 { - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x08)) + if rc == SQLITE_OK { + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_AtLast)) } else { - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x08))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_AtLast))) } - } else if rc == 16 { + } else if rc == SQLITE_EMPTY { *(*int32)(unsafe.Pointer(pRes)) = 1 - rc = 0 + rc = SQLITE_OK } return rc } @@ -46977,24 +46367,24 @@ func Xsqlite3BtreeMovetoUnpacked(tls *libc.TLS, pCur uintptr, pIdxKey uintptr, i // If the cursor is already positioned at the point we are trying // to move to, then just return without doing any work if !(((pIdxKey == uintptr(0)) && - (int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 0)) && ((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x02) != 0)) { + (int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_VALID)) && ((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_ValidNKey) != 0)) { goto __1 } if !((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey == intKey) { goto __2 } *(*int32)(unsafe.Pointer(pRes)) = 0 - return 0 + return SQLITE_OK __2: ; if !((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey < intKey) { goto __3 } - if !((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x08) != 0) { + if !((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_AtLast) != 0) { goto __4 } *(*int32)(unsafe.Pointer(pRes)) = -1 - return 0 + return SQLITE_OK __4: ; // If the requested key is one more than the previous key, then @@ -47006,22 +46396,22 @@ __4: } *(*int32)(unsafe.Pointer(pRes)) = 0 rc = Xsqlite3BtreeNext(tls, pCur, 0) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __6 } getCellInfo(tls, pCur) if !((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey == intKey) { goto __8 } - return 0 + return SQLITE_OK __8: ; goto __7 __6: - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __9 } - rc = 0 + rc = SQLITE_OK goto __10 __9: return rc @@ -47052,12 +46442,12 @@ __12: if !(rc != 0) { goto __13 } - if !(rc == 16) { + if !(rc == SQLITE_EMPTY) { goto __14 } *(*int32)(unsafe.Pointer(pRes)) = -1 - return 0 + return SQLITE_OK __14: ; return rc @@ -47138,11 +46528,11 @@ __30: goto moveto_next_layer goto __34 __33: - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x02)) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_ValidNKey)) (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey = *(*I64)(unsafe.Pointer(bp /* nCellKey */)) (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0) *(*int32)(unsafe.Pointer(pRes)) = 0 - return 0 + return SQLITE_OK __34: ; __31: @@ -47169,7 +46559,7 @@ __35: // Size of the pCell cell in bytes // the entire cell by checking for the cases where the record is // stored entirely within the b-tree page by inspecting the first // 2 bytes of the cell. - nCell = int32(*(*U8)(unsafe.Pointer(pCell + uintptr(0)))) + nCell = int32(*(*U8)(unsafe.Pointer(pCell))) if !(nCell <= int32((*MemPage)(unsafe.Pointer(pPage)).Fmax1bytePayload)) { goto __38 } @@ -47177,17 +46567,17 @@ __35: // Size of the pCell cell in bytes // single byte varint and the record fits entirely on the main // b-tree page. - c = (*(*func(*libc.TLS, int32, uintptr, uintptr) int32)(unsafe.Pointer(&xRecordCompare)))(tls, nCell, (pCell + uintptr(1)), pIdxKey) + c = (*(*func(*libc.TLS, int32, uintptr, uintptr) int32)(unsafe.Pointer(&xRecordCompare)))(tls, nCell, (pCell + 1), pIdxKey) goto __39 __38: - if !(!((int32(*(*U8)(unsafe.Pointer(pCell + uintptr(1)))) & 0x80) != 0) && - ((libc.AssignInt32(&nCell, (((nCell & 0x7f) << 7) + int32(*(*U8)(unsafe.Pointer(pCell + uintptr(1))))))) <= int32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal))) { + if !(!((int32(*(*U8)(unsafe.Pointer(pCell + 1))) & 0x80) != 0) && + ((libc.AssignInt32(&nCell, (((nCell & 0x7f) << 7) + int32(*(*U8)(unsafe.Pointer(pCell + 1)))))) <= int32((*MemPage)(unsafe.Pointer(pPage)).FmaxLocal))) { goto __40 } // The record-size field is a 2 byte varint and the record // fits entirely on the main b-tree page. - c = (*(*func(*libc.TLS, int32, uintptr, uintptr) int32)(unsafe.Pointer(&xRecordCompare)))(tls, nCell, (pCell + uintptr(2)), pIdxKey) + c = (*(*func(*libc.TLS, int32, uintptr, uintptr) int32)(unsafe.Pointer(&xRecordCompare)))(tls, nCell, (pCell + 2), pIdxKey) goto __41 __40: pCellBody = (pCell - uintptr((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)) @@ -47209,14 +46599,14 @@ __42: if !(pCellKey == uintptr(0)) { goto __43 } - rc = 7 + rc = SQLITE_NOMEM goto moveto_finish __43: ; (*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(idx) rc = accessPayload(tls, pCur, uint32(0), uint32(nCell), pCellKey, 0) libc.Xmemset(tls, ((pCellKey) + uintptr(nCell)), 0, uint64(nOverrun)) // Fix uninit warnings - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x04))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_ValidOvfl))) if !(rc != 0) { goto __44 } @@ -47245,7 +46635,7 @@ __45: __47: ; *(*int32)(unsafe.Pointer(pRes)) = 0 - rc = 0 + rc = SQLITE_OK (*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(idx) if !((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FerrCode != 0) { goto __49 @@ -47281,7 +46671,7 @@ __19: (*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(idx) *(*int32)(unsafe.Pointer(pRes)) = c - rc = 0 + rc = SQLITE_OK goto moveto_finish __51: ; @@ -47324,7 +46714,7 @@ func Xsqlite3BtreeEof(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70145:20 // TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries // have been deleted? This API will need to change to return an error code // as well as the boolean result value. - return (libc.Bool32(0 != int32((*BtCursor)(unsafe.Pointer(pCur)).FeState))) + return (libc.Bool32(CURSOR_VALID != int32((*BtCursor)(unsafe.Pointer(pCur)).FeState))) } // Return an estimate for the number of rows in the table that pCur is @@ -47337,7 +46727,7 @@ func Xsqlite3BtreeRowCountEst(tls *libc.TLS, pCur uintptr) I64 { /* sqlite3.c:70 // Currently this interface is only called by the OP_IfSmaller // opcode, and it that case the cursor will always be valid and // will always point to a leaf node. - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != 0 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { return int64(-1) } if int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).Fleaf) == 0 { @@ -47374,24 +46764,24 @@ func btreeNext(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70198:28: */ var idx int32 var pPage uintptr - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != 0 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { rc = func() int32 { - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= 3 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK { return btreeRestoreCursorPosition(tls, pCur) } - return 0 + return SQLITE_OK }() - if rc != 0 { + if rc != SQLITE_OK { return rc } - if 1 == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) { - return 101 + if CURSOR_INVALID == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) { + return SQLITE_DONE } - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 2 { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(0) + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_SKIPNEXT { + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_VALID if (*BtCursor)(unsafe.Pointer(pCur)).FskipNext > 0 { - return 0 + return SQLITE_OK } } } @@ -47428,8 +46818,8 @@ func btreeNext(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70198:28: */ } for ok := true; ok; ok = (int32((*BtCursor)(unsafe.Pointer(pCur)).Fix) >= int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)) { if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) == 0 { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) - return 101 + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID + return SQLITE_DONE } moveToParent(tls, pCur) pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage @@ -47437,11 +46827,11 @@ func btreeNext(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70198:28: */ if (*MemPage)(unsafe.Pointer(pPage)).FintKey != 0 { return Xsqlite3BtreeNext(tls, pCur, 0) } else { - return 0 + return SQLITE_OK } } if (*MemPage)(unsafe.Pointer(pPage)).Fleaf != 0 { - return 0 + return SQLITE_OK } else { return moveToLeftmost(tls, pCur) } @@ -47453,8 +46843,8 @@ func Xsqlite3BtreeNext(tls *libc.TLS, pCur uintptr, flags int32) int32 { /* sqli _ = flags // Used in COMDB2 but not native SQLite (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32((0x02 | 0x04)))) - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != 0 { + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32((BTCF_ValidNKey | BTCF_ValidOvfl)))) + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { return btreeNext(tls, pCur) } pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage @@ -47463,7 +46853,7 @@ func Xsqlite3BtreeNext(tls *libc.TLS, pCur uintptr, flags int32) int32 { /* sqli return btreeNext(tls, pCur) } if (*MemPage)(unsafe.Pointer(pPage)).Fleaf != 0 { - return 0 + return SQLITE_OK } else { return moveToLeftmost(tls, pCur) } @@ -47492,23 +46882,23 @@ func btreePrevious(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70308:28: * var rc int32 var pPage uintptr - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != 0 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID { rc = func() int32 { - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= 3 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) >= CURSOR_REQUIRESEEK { return btreeRestoreCursorPosition(tls, pCur) } - return 0 + return SQLITE_OK }() - if rc != 0 { + if rc != SQLITE_OK { return rc } - if 1 == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) { - return 101 + if CURSOR_INVALID == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) { + return SQLITE_DONE } - if 2 == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(0) + if CURSOR_SKIPNEXT == int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) { + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_VALID if (*BtCursor)(unsafe.Pointer(pCur)).FskipNext < 0 { - return 0 + return SQLITE_OK } } } @@ -47525,8 +46915,8 @@ func btreePrevious(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70308:28: * } else { for int32((*BtCursor)(unsafe.Pointer(pCur)).Fix) == 0 { if int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) == 0 { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) - return 101 + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID + return SQLITE_DONE } moveToParent(tls, pCur) } @@ -47536,7 +46926,7 @@ func btreePrevious(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70308:28: * if ((*MemPage)(unsafe.Pointer(pPage)).FintKey != 0) && !(int32((*MemPage)(unsafe.Pointer(pPage)).Fleaf) != 0) { rc = Xsqlite3BtreePrevious(tls, pCur, 0) } else { - rc = 0 + rc = SQLITE_OK } } return rc @@ -47545,15 +46935,15 @@ func btreePrevious(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:70308:28: * func Xsqlite3BtreePrevious(tls *libc.TLS, pCur uintptr, flags int32) int32 { /* sqlite3.c:70357:20: */ _ = flags // Used in COMDB2 but not native SQLite - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(((0x08 | 0x04) | 0x02)))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(((BTCF_AtLast | BTCF_ValidOvfl) | BTCF_ValidNKey)))) (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnSize = U16(0) - if ((int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != 0) || + if ((int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) != CURSOR_VALID) || (int32((*BtCursor)(unsafe.Pointer(pCur)).Fix) == 0)) || (int32((*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).Fleaf) == 0) { return btreePrevious(tls, pCur) } (*BtCursor)(unsafe.Pointer(pCur)).Fix-- - return 0 + return SQLITE_OK } // Allocate a new page from the database file. @@ -47638,7 +47028,7 @@ func allocateBtreePage(tls *libc.TLS, pBt uintptr, ppPage uintptr, pPgno uintptr mxPage = btreePagecount(tls, pBt) // EVIDENCE-OF: R-05119-02637 The 4-byte big-endian integer at offset 36 // stores stores the total number of pages on the freelist. - n = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(36))) + n = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 36)) if !(n >= mxPage) { goto __1 @@ -47655,7 +47045,7 @@ __1: // If eMode==BTALLOC_EXACT and a query of the pointer-map // shows that the page 'nearby' is somewhere on the free-list, then // the entire-list will be searched for that page. - if !(int32(eMode) == 1) { + if !(int32(eMode) == BTALLOC_EXACT) { goto __4 } if !(nearby <= mxPage) { @@ -47669,7 +47059,7 @@ __1: return rc __7: ; - if !(int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == 2) { + if !(int32(*(*U8)(unsafe.Pointer(bp /* eType */))) == PTRMAP_FREEPAGE) { goto __8 } searchList = U8(1) @@ -47679,7 +47069,7 @@ __6: ; goto __5 __4: - if !(int32(eMode) == 2) { + if !(int32(eMode) == BTALLOC_LE) { goto __9 } searchList = U8(1) @@ -47697,7 +47087,7 @@ __5: return rc __10: ; - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(36)), (n - U32(1))) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 36), (n - U32(1))) // The code within this loop is run only once if the 'searchList' variable // is not true. Otherwise, it runs once for each trunk-page on the @@ -47711,13 +47101,13 @@ __11: // EVIDENCE-OF: R-01506-11053 The first integer on a freelist trunk page // is the page number of the next freelist trunk page in the list or // zero if this is the last freelist trunk page. - iTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData + uintptr(0))) + iTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData)) goto __15 __14: // EVIDENCE-OF: R-59841-13798 The 4-byte big-endian integer at offset 32 // stores the page number of the first page of the freelist, or zero if // the freelist is empty. - iTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(32))) + iTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 32)) __15: ; @@ -47740,7 +47130,7 @@ __18: // EVIDENCE-OF: R-13523-04394 The second integer on a freelist trunk page // is the number of leaf page pointers to follow. - k = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(4))) + k = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + 4)) if !((k == U32(0)) && !(searchList != 0)) { goto __19 } @@ -47756,7 +47146,7 @@ __18: __21: ; *(*Pgno)(unsafe.Pointer(pPgno)) = iTrunk - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(32)), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(0)), uint64(4)) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 32), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData), uint64(4)) *(*uintptr)(unsafe.Pointer(ppPage)) = *(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)) *(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)) = uintptr(0) @@ -47771,7 +47161,7 @@ __19: goto __23 __22: if !((searchList != 0) && - ((nearby == iTrunk) || ((iTrunk < nearby) && (int32(eMode) == 2)))) { + ((nearby == iTrunk) || ((iTrunk < nearby) && (int32(eMode) == BTALLOC_LE)))) { goto __24 } // The list is being searched and this trunk page is the page @@ -47792,22 +47182,22 @@ __26: if !(!(pPrevTrunk != 0)) { goto __29 } - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(32)), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(0)), uint64(4)) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 32), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData), uint64(4)) goto __30 __29: rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPrevTrunk)).FpDbPage) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __31 } goto end_allocate_page __31: ; - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData + uintptr(0)), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(0)), uint64(4)) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData), uint64(4)) __30: ; goto __28 __27: - iNewTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(8))) + iNewTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + 8)) if !(iNewTrunk > mxPage) { goto __32 } @@ -47817,29 +47207,29 @@ __32: ; rc = btreeGetUnusedPage(tls, pBt, iNewTrunk, bp+16 /* &pNewTrunk */, 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __33 } goto end_allocate_page __33: ; rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FpDbPage) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __34 } releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */))) goto end_allocate_page __34: ; - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FaData + uintptr(0)), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(0)), uint64(4)) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FaData + uintptr(4)), (k - U32(1))) - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FaData + uintptr(8)), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + uintptr(12)), (uint64((k - U32(1)) * U32(4)))) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FaData), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData), uint64(4)) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FaData + 4), (k - U32(1))) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */)))).FaData + 8), ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pTrunk */)))).FaData + 12), (uint64((k - U32(1)) * U32(4)))) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pNewTrunk */))) if !(!(pPrevTrunk != 0)) { goto __35 } - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(32)), iNewTrunk) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 32), iNewTrunk) goto __36 __35: rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPrevTrunk)).FpDbPage) @@ -47849,7 +47239,7 @@ __35: goto end_allocate_page __37: ; - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData + uintptr(0)), iNewTrunk) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPrevTrunk)).FaData), iNewTrunk) __36: ; __28: @@ -47866,7 +47256,7 @@ __24: goto __39 } closest = U32(0) - if !(int32(eMode) == 2) { + if !(int32(eMode) == BTALLOC_LE) { goto __41 } i = U32(0) @@ -47891,7 +47281,7 @@ __45: ; goto __42 __41: - dist = Xsqlite3AbsInt32(tls, (int32(Xsqlite3Get4byte(tls, (aData+uintptr(8))) - nearby))) + dist = Xsqlite3AbsInt32(tls, (int32(Xsqlite3Get4byte(tls, (aData+8)) - nearby))) i = U32(1) __47: if !(i < k) { @@ -47931,7 +47321,7 @@ __51: ; if !(!(searchList != 0) || - ((iPage == nearby) || ((iPage < nearby) && (int32(eMode) == 2)))) { + ((iPage == nearby) || ((iPage < nearby) && (int32(eMode) == BTALLOC_LE)))) { goto __52 } *(*Pgno)(unsafe.Pointer(pPgno)) = iPage @@ -47949,18 +47339,18 @@ __53: libc.Xmemcpy(tls, (aData + uintptr((U32(8) + (closest * U32(4))))), (aData + uintptr((U32(4) + (k * U32(4))))), uint64(4)) __54: ; - Xsqlite3Put4byte(tls, (aData + uintptr(4)), (k - U32(1))) + Xsqlite3Put4byte(tls, (aData + 4), (k - U32(1))) if !(btreeGetHasContent(tls, pBt, *(*Pgno)(unsafe.Pointer(pPgno))) != 0) { - noContent = 0x01 + noContent = PAGER_GET_NOCONTENT } else { noContent = 0 } rc = btreeGetUnusedPage(tls, pBt, *(*Pgno)(unsafe.Pointer(pPgno)), ppPage, noContent) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __55 } rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FpDbPage) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __56 } releasePage(tls, *(*uintptr)(unsafe.Pointer(ppPage))) @@ -48010,7 +47400,7 @@ __2: // here are confined to those pages that lie between the end of the // database image and the end of the database file. if 0 == (int32((*BtShared)(unsafe.Pointer(pBt)).FbDoTruncate)) { - bNoContent = 0x01 + bNoContent = PAGER_GET_NOCONTENT } else { bNoContent = 0 } @@ -48039,7 +47429,7 @@ __58: *(*uintptr)(unsafe.Pointer(bp + 24 /* pPg */)) = uintptr(0) rc = btreeGetUnusedPage(tls, pBt, (*BtShared)(unsafe.Pointer(pBt)).FnPage, bp+24 /* &pPg */, bNoContent) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __60 } rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pPg */)))).FpDbPage) @@ -48072,7 +47462,7 @@ __59: __63: ; rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppPage)))).FpDbPage) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __64 } releasePage(tls, *(*uintptr)(unsafe.Pointer(ppPage))) @@ -48143,10 +47533,10 @@ __3: goto freepage_out __4: ; - nFree = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(36))) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(36)), (nFree + U32(1))) + nFree = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 36)) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 36), (nFree + U32(1))) - if !((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0004) != 0) { + if !((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_SECURE_DELETE) != 0) { goto __5 } // If the secure_delete option is enabled, then @@ -48167,7 +47557,7 @@ __5: if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) { goto __7 } - ptrmapPut(tls, pBt, iPage, uint8(2), uint32(0), bp+8 /* &rc */) + ptrmapPut(tls, pBt, iPage, PTRMAP_FREEPAGE, uint32(0), bp+8 /* &rc */) if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != 0) { goto __8 } @@ -48187,7 +47577,7 @@ __7: goto __9 } // Initial number of leaf cells on trunk page - iTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(32))) + iTrunk = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 32)) if !(iTrunk > btreePagecount(tls, pBt)) { goto __10 } @@ -48196,14 +47586,14 @@ __7: __10: ; *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = btreeGetPage(tls, pBt, iTrunk, bp+16 /* &pTrunk */, 0) - if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != 0) { + if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != SQLITE_OK) { goto __11 } goto freepage_out __11: ; - nLeaf = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pTrunk */)))).FaData + uintptr(4))) + nLeaf = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pTrunk */)))).FaData + 4)) if !(nLeaf > (((*BtShared)(unsafe.Pointer(pBt)).FusableSize / U32(4)) - U32(2))) { goto __12 @@ -48234,12 +47624,12 @@ __12: // order that database files created by newer versions of SQLite can be // read by older versions of SQLite. *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pTrunk */)))).FpDbPage) - if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0) { + if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK) { goto __14 } - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pTrunk */)))).FaData + uintptr(4)), (nLeaf + U32(1))) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pTrunk */)))).FaData + 4), (nLeaf + U32(1))) Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pTrunk */)))).FaData + uintptr((U32(8) + (nLeaf * U32(4))))), iPage) - if !((*(*uintptr)(unsafe.Pointer(bp /* pPage */)) != 0) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x0004) == 0)) { + if !((*(*uintptr)(unsafe.Pointer(bp /* pPage */)) != 0) && ((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_SECURE_DELETE) == 0)) { goto __15 } Xsqlite3PagerDontWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FpDbPage) @@ -48260,22 +47650,22 @@ __9: // Possibly because the free-list is empty, or possibly because the // first trunk in the free-list is full. Either way, the page being freed // will become the new first trunk page in the free-list. - if !((*(*uintptr)(unsafe.Pointer(bp /* pPage */)) == uintptr(0)) && (0 != (libc.AssignPtrInt32(bp+8 /* rc */, btreeGetPage(tls, pBt, iPage, bp /* &pPage */, 0))))) { + if !((*(*uintptr)(unsafe.Pointer(bp /* pPage */)) == uintptr(0)) && (SQLITE_OK != (libc.AssignPtrInt32(bp+8 /* rc */, btreeGetPage(tls, pBt, iPage, bp /* &pPage */, 0))))) { goto __16 } goto freepage_out __16: ; *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FpDbPage) - if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != 0) { + if !(*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != SQLITE_OK) { goto __17 } goto freepage_out __17: ; Xsqlite3Put4byte(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FaData, iTrunk) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FaData + uintptr(4)), uint32(0)) - Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + uintptr(32)), iPage) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FaData + 4), uint32(0)) + Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pPage1)).FaData + 32), iPage) freepage_out: if !(*(*uintptr)(unsafe.Pointer(bp /* pPage */)) != 0) { @@ -48290,7 +47680,7 @@ __18: } func freePage(tls *libc.TLS, pPage uintptr, pRC uintptr) { /* sqlite3.c:70851:13: */ - if (*(*int32)(unsafe.Pointer(pRC))) == 0 { + if (*(*int32)(unsafe.Pointer(pRC))) == SQLITE_OK { *(*int32)(unsafe.Pointer(pRC)) = freePage2(tls, (*MemPage)(unsafe.Pointer(pPage)).FpBt, pPage, (*MemPage)(unsafe.Pointer(pPage)).Fpgno) } } @@ -48309,7 +47699,7 @@ func clearCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) int32 (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer((pPage + 128 /* &.xParseCell */))))(tls, pPage, pCell, pInfo) if U32((*CellInfo)(unsafe.Pointer(pInfo)).FnLocal) == (*CellInfo)(unsafe.Pointer(pInfo)).FnPayload { - return 0 // No overflow pages. Return without doing anything + return SQLITE_OK // No overflow pages. Return without doing anything } if (pCell + uintptr((*CellInfo)(unsafe.Pointer(pInfo)).FnSize)) > (*MemPage)(unsafe.Pointer(pPage)).FaDataEnd { @@ -48362,7 +47752,7 @@ func clearCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pInfo uintptr) int32 } ovflPgno = *(*Pgno)(unsafe.Pointer(bp + 8 /* iNext */)) } - return 0 + return SQLITE_OK } // Create the byte sequence used to represent a cell on page pPage @@ -48438,7 +47828,7 @@ func fillInCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pX uintptr, pnSize libc.Xmemcpy(tls, pPayload, pSrc, uint64(nSrc)) libc.Xmemset(tls, (pPayload + uintptr(nSrc)), 0, (uint64(nPayload - nSrc))) - return 0 + return SQLITE_OK } // If we reach this point, it means that some of the content will need @@ -48515,12 +47905,12 @@ func fillInCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pX uintptr, pnSize // then the optimistic overflow chain processing in clearCell() // may misinterpret the uninitialized values and delete the // wrong pages from the database. - if ((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) && (*(*int32)(unsafe.Pointer(bp + 12 /* rc */)) == 0) { + if ((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) && (*(*int32)(unsafe.Pointer(bp + 12 /* rc */)) == SQLITE_OK) { var eType U8 = func() uint8 { if pgnoPtrmap != 0 { - return uint8(4) + return PTRMAP_OVERFLOW2 } - return uint8(3) + return PTRMAP_OVERFLOW1 }() ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* pgnoOvfl */)), eType, pgnoPtrmap, bp+12 /* &rc */) if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != 0 { @@ -48543,12 +47933,12 @@ func fillInCell(tls *libc.TLS, pPage uintptr, pCell uintptr, pX uintptr, pnSize pToRelease = *(*uintptr)(unsafe.Pointer(bp /* pOvfl */)) pPrior = (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pOvfl */)))).FaData Xsqlite3Put4byte(tls, pPrior, uint32(0)) - pPayload = ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pOvfl */)))).FaData + uintptr(4)) + pPayload = ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pOvfl */)))).FaData + 4) spaceLeft = (int32((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(4))) } } releasePage(tls, pToRelease) - return 0 + return SQLITE_OK } // Remove the i-th cell from pPage. This routine effects pPage only. @@ -48570,7 +47960,7 @@ func dropCell(tls *libc.TLS, pPage uintptr, idx int32, sz int32, pRC uintptr) { data = (*MemPage)(unsafe.Pointer(pPage)).FaData ptr = ((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr((2 * idx))) - pc = (U32((int32(*(*U8)(unsafe.Pointer((ptr) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((ptr) + uintptr(1)))))) + pc = (U32((int32(*(*U8)(unsafe.Pointer((ptr)))) << 8) | int32(*(*U8)(unsafe.Pointer((ptr) + 1))))) hdr = int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset) if (pc + U32(sz)) > (*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize { @@ -48586,14 +47976,14 @@ func dropCell(tls *libc.TLS, pPage uintptr, idx int32, sz int32, pRC uintptr) { if int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) == 0 { libc.Xmemset(tls, (data + uintptr((hdr + 1))), 0, uint64(4)) *(*U8)(unsafe.Pointer(data + uintptr((hdr + 7)))) = U8(0) - *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0))) = (U8(((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) >> 8)) - *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))) = U8((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) + *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))))) = (U8(((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) >> 8)) + *(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)) = U8((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize) (*MemPage)(unsafe.Pointer(pPage)).FnFree = (int32((((*BtShared)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pPage)).FpBt)).FusableSize - U32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset)) - U32((*MemPage)(unsafe.Pointer(pPage)).FchildPtrSize)) - U32(8))) } else { libc.Xmemmove(tls, ptr, (ptr + uintptr(2)), (uint64(2 * (int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - idx)))) - *(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))) + uintptr(0))) = (U8((int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)) >> 8)) - *(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))) + uintptr(1))) = U8((*MemPage)(unsafe.Pointer(pPage)).FnCell) + *(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))))) = (U8((int32((*MemPage)(unsafe.Pointer(pPage)).FnCell)) >> 8)) + *(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))) + 1)) = U8((*MemPage)(unsafe.Pointer(pPage)).FnCell) *(*int32)(unsafe.Pointer(pPage + 20 /* &.nFree */)) += (2) } } @@ -48643,7 +48033,7 @@ func insertCell(tls *libc.TLS, pPage uintptr, i int32, pCell uintptr, sz int32, // Overflows are sequential } else { var rc int32 = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pPage)).FpDbPage) - if rc != 0 { + if rc != SQLITE_OK { *(*int32)(unsafe.Pointer(pRC)) = rc return } @@ -48672,8 +48062,8 @@ func insertCell(tls *libc.TLS, pPage uintptr, i int32, pCell uintptr, sz int32, } pIns = ((*MemPage)(unsafe.Pointer(pPage)).FaCellIdx + uintptr((i * 2))) libc.Xmemmove(tls, (pIns + uintptr(2)), pIns, (uint64(2 * (int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - i)))) - *(*U8)(unsafe.Pointer((pIns) + uintptr(0))) = (U8((*(*int32)(unsafe.Pointer(bp /* idx */))) >> 8)) - *(*U8)(unsafe.Pointer((pIns) + uintptr(1))) = U8(*(*int32)(unsafe.Pointer(bp /* idx */))) + *(*U8)(unsafe.Pointer((pIns))) = (U8((*(*int32)(unsafe.Pointer(bp /* idx */))) >> 8)) + *(*U8)(unsafe.Pointer((pIns) + 1)) = U8(*(*int32)(unsafe.Pointer(bp /* idx */))) (*MemPage)(unsafe.Pointer(pPage)).FnCell++ // increment the cell count if (int32(libc.PreIncUint8(&*(*U8)(unsafe.Pointer(data + uintptr((int32((*MemPage)(unsafe.Pointer(pPage)).FhdrOffset) + 4)))), 1))) == 0 { @@ -48906,13 +48296,13 @@ func rebuildPage(tls *libc.TLS, pCArray uintptr, iFirst int32, nCell int32, pPg var k int32 // Current slot in pCArray->apEnd[] var pSrcEnd uintptr // Current pCArray->apEnd[k] value - j = (U32((int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(1)))))) + j = (U32((int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + 1))))) if j > U32(usableSize) { j = U32(0) } libc.Xmemcpy(tls, (pTmp + uintptr(j)), (aData + uintptr(j)), (uint64(U32(usableSize) - j))) - for k = 0; (*(*int32)(unsafe.Pointer((pCArray + 80 /* &.ixNx */) + uintptr(k)*4)) <= i) && (k < (3 * 2)); k++ { + for k = 0; (*(*int32)(unsafe.Pointer((pCArray + 80 /* &.ixNx */) + uintptr(k)*4)) <= i) && (k < (NB * 2)); k++ { } pSrcEnd = *(*uintptr)(unsafe.Pointer((pCArray + 32 /* &.apEnd */) + uintptr(k)*8)) @@ -48932,8 +48322,8 @@ func rebuildPage(tls *libc.TLS, pCArray uintptr, iFirst int32, nCell int32, pPg } pData -= uintptr(sz) - *(*U8)(unsafe.Pointer((pCellptr) + uintptr(0))) = (U8(((int64(pData) - int64(aData)) / 1) >> 8)) - *(*U8)(unsafe.Pointer((pCellptr) + uintptr(1))) = (U8((int64(pData) - int64(aData)) / 1)) + *(*U8)(unsafe.Pointer((pCellptr))) = (U8(((int64(pData) - int64(aData)) / 1) >> 8)) + *(*U8)(unsafe.Pointer((pCellptr) + 1)) = (U8((int64(pData) - int64(aData)) / 1)) pCellptr += uintptr(2) if pData < pCellptr { return Xsqlite3CorruptError(tls, 71466) @@ -48954,14 +48344,14 @@ func rebuildPage(tls *libc.TLS, pCArray uintptr, iFirst int32, nCell int32, pPg (*MemPage)(unsafe.Pointer(pPg)).FnCell = U16(nCell) (*MemPage)(unsafe.Pointer(pPg)).FnOverflow = U8(0) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 1))) + uintptr(0))) = (U8(int32((0)) >> 8)) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 1))) + uintptr(1))) = U8(0) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))) + uintptr(0))) = (U8((int32((*MemPage)(unsafe.Pointer(pPg)).FnCell)) >> 8)) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))) + uintptr(1))) = U8((*MemPage)(unsafe.Pointer(pPg)).FnCell) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(0))) = (U8(((int64(pData) - int64(aData)) / 1) >> 8)) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(1))) = (U8((int64(pData) - int64(aData)) / 1)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 1))))) = (U8(int32((0)) >> 8)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 1))) + 1)) = U8(0) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))))) = (U8((int32((*MemPage)(unsafe.Pointer(pPg)).FnCell)) >> 8)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))) + 1)) = U8((*MemPage)(unsafe.Pointer(pPg)).FnCell) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))))) = (U8(((int64(pData) - int64(aData)) / 1) >> 8)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + 1)) = (U8((int64(pData) - int64(aData)) / 1)) *(*U8)(unsafe.Pointer(aData + uintptr((hdr + 7)))) = U8(0x00) - return 0 + return SQLITE_OK } // The pCArray objects contains pointers to b-tree cells and the cell sizes. @@ -49000,7 +48390,7 @@ func pageInsertArray(tls *libc.TLS, pPg uintptr, pBegin uintptr, ppData uintptr, if iEnd <= iFirst { return 0 } - for k = 0; (*(*int32)(unsafe.Pointer((pCArray + 80 /* &.ixNx */) + uintptr(k)*4)) <= i) && (k < (3 * 2)); k++ { + for k = 0; (*(*int32)(unsafe.Pointer((pCArray + 80 /* &.ixNx */) + uintptr(k)*4)) <= i) && (k < (NB * 2)); k++ { } pEnd = *(*uintptr)(unsafe.Pointer((pCArray + 32 /* &.apEnd */) + uintptr(k)*8)) for 1 != 0 { @@ -49010,7 +48400,7 @@ func pageInsertArray(tls *libc.TLS, pPg uintptr, pBegin uintptr, ppData uintptr, var pSlot uintptr sz = int32(*(*U16)(unsafe.Pointer((*CellArray)(unsafe.Pointer(pCArray)).FszCell + uintptr(i)*2))) - if ((int32(*(*U8)(unsafe.Pointer(aData + uintptr(1)))) == 0) && (int32(*(*U8)(unsafe.Pointer(aData + uintptr(2)))) == 0)) || ((libc.AssignUintptr(&pSlot, pageFindSlot(tls, pPg, sz, bp /* &rc */))) == uintptr(0)) { + if ((int32(*(*U8)(unsafe.Pointer(aData + 1))) == 0) && (int32(*(*U8)(unsafe.Pointer(aData + 2))) == 0)) || ((libc.AssignUintptr(&pSlot, pageFindSlot(tls, pPg, sz, bp /* &rc */))) == uintptr(0)) { if ((int64(pData) - int64(pBegin)) / 1) < int64(sz) { return 1 } @@ -49028,8 +48418,8 @@ func pageInsertArray(tls *libc.TLS, pPg uintptr, pBegin uintptr, ppData uintptr, return 1 } libc.Xmemmove(tls, pSlot, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(pCArray)).FapCell + uintptr(i)*8)), uint64(sz)) - *(*U8)(unsafe.Pointer((pCellptr) + uintptr(0))) = (U8(((int64(pSlot) - int64(aData)) / 1) >> 8)) - *(*U8)(unsafe.Pointer((pCellptr) + uintptr(1))) = (U8((int64(pSlot) - int64(aData)) / 1)) + *(*U8)(unsafe.Pointer((pCellptr))) = (U8(((int64(pSlot) - int64(aData)) / 1) >> 8)) + *(*U8)(unsafe.Pointer((pCellptr) + 1)) = (U8((int64(pSlot) - int64(aData)) / 1)) pCellptr += uintptr(2) i++ if i >= iEnd { @@ -49153,7 +48543,7 @@ __1: __3: ; - *(*uintptr)(unsafe.Pointer(bp /* pData */)) = (aData + uintptr((((((int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(1))))) - 1) & 0xffff) + 1))) + *(*uintptr)(unsafe.Pointer(bp /* pData */)) = (aData + uintptr((((((int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + 1)))) - 1) & 0xffff) + 1))) if !(*(*uintptr)(unsafe.Pointer(bp /* pData */)) < pBegin) { goto __4 } @@ -49200,7 +48590,7 @@ __7: if !(nCell > iCell) { goto __11 } - libc.Xmemmove(tls, (pCellptr + uintptr(2)), pCellptr, (uint64((nCell - iCell) * 2))) + libc.Xmemmove(tls, (pCellptr + 2), pCellptr, (uint64((nCell - iCell) * 2))) __11: ; nCell++ @@ -49238,12 +48628,12 @@ __13: (*MemPage)(unsafe.Pointer(pPg)).FnCell = U16(nNew) (*MemPage)(unsafe.Pointer(pPg)).FnOverflow = U8(0) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))) + uintptr(0))) = (U8((int32((*MemPage)(unsafe.Pointer(pPg)).FnCell)) >> 8)) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))) + uintptr(1))) = U8((*MemPage)(unsafe.Pointer(pPg)).FnCell) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(0))) = (U8(((int64(*(*uintptr)(unsafe.Pointer(bp /* pData */))) - int64(aData)) / 1) >> 8)) - *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + uintptr(1))) = (U8((int64(*(*uintptr)(unsafe.Pointer(bp /* pData */))) - int64(aData)) / 1)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))))) = (U8((int32((*MemPage)(unsafe.Pointer(pPg)).FnCell)) >> 8)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 3))) + 1)) = U8((*MemPage)(unsafe.Pointer(pPg)).FnCell) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))))) = (U8(((int64(*(*uintptr)(unsafe.Pointer(bp /* pData */))) - int64(aData)) / 1) >> 8)) + *(*U8)(unsafe.Pointer((aData + uintptr((hdr + 5))) + 1)) = (U8((int64(*(*uintptr)(unsafe.Pointer(bp /* pData */))) - int64(aData)) / 1)) - return 0 + return SQLITE_OK editpage_fail: // Unable to edit this page. Rebuild it from scratch instead. populateCellCache(tls, pCArray, iNew, nNew) @@ -49292,21 +48682,21 @@ func balance_quick(tls *libc.TLS, pParent uintptr, pPage uintptr, pSpace uintptr // may be inserted. If both these operations are successful, proceed. *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) = allocateBtreePage(tls, pBt, bp /* &pNew */, bp+8 /* &pgnoNew */, uint32(0), uint8(0)) - if *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) == SQLITE_OK { - var pOut uintptr = (pSpace + uintptr(4)) - *(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) = *(*uintptr)(unsafe.Pointer((pPage + 40 /* &.apOvfl */) + uintptr(0)*8)) + var pOut uintptr = (pSpace + 4) + *(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) = *(*uintptr)(unsafe.Pointer((pPage + 40 /* &.apOvfl */))) *(*U16)(unsafe.Pointer(bp + 24 /* szCell */)) = (*(*func(*libc.TLS, uintptr, uintptr) U16)(unsafe.Pointer((pPage + 120 /* &.xCellSize */))))(tls, pPage, *(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */))) var pStop uintptr // var b CellArray at bp+32, 104 - zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */)), ((0x01 | 0x04) | 0x08)) + zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */)), ((PTF_INTKEY | PTF_LEAFDATA) | PTF_LEAF)) (*CellArray)(unsafe.Pointer(bp + 32 /* &b */)).FnCell = 1 (*CellArray)(unsafe.Pointer(bp + 32 /* &b */)).FpRef = pPage (*CellArray)(unsafe.Pointer(bp + 32 /* &b */)).FapCell = bp + 16 /* &pCell */ (*CellArray)(unsafe.Pointer(bp + 32 /* &b */)).FszCell = bp + 24 /* &szCell */ - *(*uintptr)(unsafe.Pointer((bp + 32 /* &b */ + 32 /* &.apEnd */) + uintptr(0)*8)) = (*MemPage)(unsafe.Pointer(pPage)).FaDataEnd - *(*int32)(unsafe.Pointer((bp + 32 /* &b */ + 80 /* &.ixNx */) + uintptr(0)*4)) = 2 + *(*uintptr)(unsafe.Pointer((bp + 32 /* &b */ + 32 /* &.apEnd */))) = (*MemPage)(unsafe.Pointer(pPage)).FaDataEnd + *(*int32)(unsafe.Pointer((bp + 32 /* &b */ + 80 /* &.ixNx */))) = 2 *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) = rebuildPage(tls, bp+32 /* &b */, 0, 1, *(*uintptr)(unsafe.Pointer(bp /* pNew */))) if *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) != 0 { releasePage(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */))) @@ -49323,7 +48713,7 @@ func balance_quick(tls *libc.TLS, pParent uintptr, pPage uintptr, pSpace uintptr // be marked as dirty. Returning an error code will cause a // rollback, undoing any changes made to the parent page. if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { - ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* pgnoNew */)), uint8(5), (*MemPage)(unsafe.Pointer(pParent)).Fpgno, bp+136 /* &rc */) + ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* pgnoNew */)), PTRMAP_BTREE, (*MemPage)(unsafe.Pointer(pParent)).Fpgno, bp+136 /* &rc */) if int32(*(*U16)(unsafe.Pointer(bp + 24 /* szCell */))) > int32((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pNew */)))).FminLocal) { ptrmapPutOvflPtr(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */)), *(*uintptr)(unsafe.Pointer(bp /* pNew */)), *(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)), bp+136 /* &rc */) } @@ -49342,15 +48732,15 @@ func balance_quick(tls *libc.TLS, pParent uintptr, pPage uintptr, pSpace uintptr // field. The second while(...) loop copies the key value from the // cell on pPage into the pSpace buffer. *(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) = ((*MemPage)(unsafe.Pointer((pPage))).FaData + uintptr((int32((*MemPage)(unsafe.Pointer((pPage))).FmaskPage) & int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(((*MemPage)(unsafe.Pointer((pPage))).FaCellIdx + uintptr((2 * (int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - 1))))))))))) - pStop = (*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) + uintptr(9)) + pStop = (*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) + 9) for ((int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)), 1)))) & 0x80) != 0) && (*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) < pStop) { } - pStop = (*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) + uintptr(9)) + pStop = (*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) + 9) for (((int32(libc.AssignPtrUint8(libc.PostIncUintptr(&pOut, 1), *(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)), 1)))))) & 0x80) != 0) && (*(*uintptr)(unsafe.Pointer(bp + 16 /* pCell */)) < pStop) { } // Insert the new divider cell into pParent. - if *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 136 /* rc */)) == SQLITE_OK { insertCell(tls, pParent, int32((*MemPage)(unsafe.Pointer(pParent)).FnCell), pSpace, (int32((int64(pOut) - int64(pSpace)) / 1)), uintptr(0), (*MemPage)(unsafe.Pointer(pPage)).Fpgno, bp+136 /* &rc */) } @@ -49381,7 +48771,7 @@ func balance_quick(tls *libc.TLS, pParent uintptr, pPage uintptr, pSpace uintptr // the balance_shallower() and balance_deeper() procedures, neither of // which are called often under normal circumstances. func copyNodeContent(tls *libc.TLS, pFrom uintptr, pTo uintptr, pRC uintptr) { /* sqlite3.c:71918:13: */ - if (*(*int32)(unsafe.Pointer(pRC))) == 0 { + if (*(*int32)(unsafe.Pointer(pRC))) == SQLITE_OK { var pBt uintptr = (*MemPage)(unsafe.Pointer(pFrom)).FpBt var aFrom uintptr = (*MemPage)(unsafe.Pointer(pFrom)).FaData var aTo uintptr = (*MemPage)(unsafe.Pointer(pTo)).FaData @@ -49396,7 +48786,7 @@ func copyNodeContent(tls *libc.TLS, pFrom uintptr, pTo uintptr, pRC uintptr) { / var iData int32 // Copy the b-tree node content from page pFrom to page pTo. - iData = ((int32(*(*U8)(unsafe.Pointer((aFrom + uintptr((iFromHdr + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aFrom + uintptr((iFromHdr + 5))) + uintptr(1))))) + iData = ((int32(*(*U8)(unsafe.Pointer((aFrom + uintptr((iFromHdr + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((aFrom + uintptr((iFromHdr + 5))) + 1)))) libc.Xmemcpy(tls, (aTo + uintptr(iData)), (aFrom + uintptr(iData)), (uint64((*BtShared)(unsafe.Pointer(pBt)).FusableSize - U32(iData)))) libc.Xmemcpy(tls, (aTo + uintptr(iToHdr)), (aFrom + uintptr(iFromHdr)), (uint64(int32((*MemPage)(unsafe.Pointer(pFrom)).FcellOffset) + (2 * int32((*MemPage)(unsafe.Pointer(pFrom)).FnCell))))) @@ -49406,10 +48796,10 @@ func copyNodeContent(tls *libc.TLS, pFrom uintptr, pTo uintptr, pRC uintptr) { / // page pFrom. (*MemPage)(unsafe.Pointer(pTo)).FisInit = U8(0) rc = btreeInitPage(tls, pTo) - if rc == 0 { + if rc == SQLITE_OK { rc = btreeComputeFreeSpace(tls, pTo) } - if rc != 0 { + if rc != SQLITE_OK { *(*int32)(unsafe.Pointer(pRC)) = rc return } @@ -49549,7 +48939,7 @@ func balance_nonroot(tls *libc.TLS, pParent uintptr, iParentIdx int32, aOvflSpac var key U32 nMaxCells = 0 nNew = 0 - *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = SQLITE_OK iSpace1 = 0 iOvflSpace = 0 // Parsed information on cells being balanced @@ -49566,7 +48956,7 @@ func balance_nonroot(tls *libc.TLS, pParent uintptr, iParentIdx int32, aOvflSpac if !(!(aOvflSpace != 0)) { goto __1 } - return 7 + return SQLITE_NOMEM __1: ; @@ -49651,10 +49041,10 @@ __13: __15: ; - if !(((*MemPage)(unsafe.Pointer(pParent)).FnOverflow != 0) && ((i + nxDiv) == int32(*(*U16)(unsafe.Pointer((pParent + 28 /* &.aiOvfl */) + uintptr(0)*2))))) { + if !(((*MemPage)(unsafe.Pointer(pParent)).FnOverflow != 0) && ((i + nxDiv) == int32(*(*U16)(unsafe.Pointer((pParent + 28 /* &.aiOvfl */)))))) { goto __16 } - *(*uintptr)(unsafe.Pointer(bp + 32 /* &apDiv[0] */ + uintptr(i)*8)) = *(*uintptr)(unsafe.Pointer((pParent + 40 /* &.apOvfl */) + uintptr(0)*8)) + *(*uintptr)(unsafe.Pointer(bp + 32 /* &apDiv[0] */ + uintptr(i)*8)) = *(*uintptr)(unsafe.Pointer((pParent + 40 /* &.apOvfl */))) *(*Pgno)(unsafe.Pointer(bp + 272 /* pgno */)) = Xsqlite3Get4byte(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &apDiv[0] */ + uintptr(i)*8))) *(*int32)(unsafe.Pointer(bp + 48 /* &szNew[0] */ + uintptr(i)*4)) = int32((*(*func(*libc.TLS, uintptr, uintptr) U16)(unsafe.Pointer((pParent + 120 /* &.xCellSize */))))(tls, pParent, *(*uintptr)(unsafe.Pointer(bp + 32 /* &apDiv[0] */ + uintptr(i)*8)))) (*MemPage)(unsafe.Pointer(pParent)).FnOverflow = U8(0) @@ -49676,7 +49066,7 @@ __16: // In this case, temporarily copy the cell into the aOvflSpace[] // buffer. It will be copied out again as soon as the aSpace[] buffer // is allocated. - if !((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & 0x000c) != 0) { + if !((int32((*BtShared)(unsafe.Pointer(pBt)).FbtsFlags) & BTS_FAST_SECURE) != 0) { goto __18 } @@ -49705,7 +49095,7 @@ __11: // Make nMaxCells a multiple of 4 in order to preserve 8-byte // alignment nMaxCells = (int32(U32(nOld) * ((((*BtShared)(unsafe.Pointer(pBt)).FpageSize - U32(8)) / U32(6)) + (U32((int32(uint64(unsafe.Sizeof([4]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))))))))) - nMaxCells = ((nMaxCells + 3) & ^libc.Int32(3)) + nMaxCells = ((nMaxCells + 3) & libc.CplInt32(3)) // Allocate space for memory structures szScratch = (int32(((uint64(nMaxCells) * uint64(unsafe.Sizeof(uintptr(0)))) + // b.apCell @@ -49716,7 +49106,7 @@ __11: if !((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FapCell == uintptr(0)) { goto __21 } - *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = SQLITE_NOMEM goto balance_cleanup __21: ; @@ -49737,7 +49127,7 @@ __21: // // leafCorrection: 4 if pPage is a leaf. 0 if pPage is not a leaf. // leafData: 1 if pPage holds key+data and pParent holds only keys. - (*CellArray)(unsafe.Pointer(bp + 96 /* &b */)).FpRef = *(*uintptr)(unsafe.Pointer(bp + 8 /* &apOld[0] */ + uintptr(0)*8)) + (*CellArray)(unsafe.Pointer(bp + 96 /* &b */)).FpRef = *(*uintptr)(unsafe.Pointer(bp + 8 /* &apOld[0] */)) leafCorrection = (U16(int32((*MemPage)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FpRef)).Fleaf) * 4)) leafData = int32((*MemPage)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp + 96 /* &b */)).FpRef)).FintKeyLeaf) i = 0 @@ -49753,7 +49143,7 @@ __22: // Verify that all sibling pages are of the same "type" (table-leaf, // table-interior, index-leaf, or index-interior). - if !(int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pOld)).FaData + uintptr(0)))) != int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* &apOld[0] */ + uintptr(0)*8)))).FaData + uintptr(0))))) { + if !(int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(pOld)).FaData))) != int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* &apOld[0] */)))).FaData)))) { goto __25 } *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = Xsqlite3CorruptError(tls, 72197) @@ -49781,14 +49171,14 @@ __25: if !(int32((*MemPage)(unsafe.Pointer(pOld)).FnOverflow) > 0) { goto __26 } - if !(limit < int32(*(*U16)(unsafe.Pointer((pOld + 28 /* &.aiOvfl */) + uintptr(0)*2)))) { + if !(limit < int32(*(*U16)(unsafe.Pointer((pOld + 28 /* &.aiOvfl */))))) { goto __27 } *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = Xsqlite3CorruptError(tls, 72221) goto balance_cleanup __27: ; - limit = int32(*(*U16)(unsafe.Pointer((pOld + 28 /* &.aiOvfl */) + uintptr(0)*2))) + limit = int32(*(*U16)(unsafe.Pointer((pOld + 28 /* &.aiOvfl */)))) j = 0 __28: if !(j < limit) { @@ -49854,7 +49244,7 @@ __35: // The right pointer of the child page pOld becomes the left // pointer of the divider cell - libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FapCell + uintptr((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FnCell)*8)), ((*MemPage)(unsafe.Pointer(pOld)).FaData + uintptr(8)), uint64(4)) + libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FapCell + uintptr((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FnCell)*8)), ((*MemPage)(unsafe.Pointer(pOld)).FaData + 8), uint64(4)) goto __38 __37: ; @@ -49958,7 +49348,7 @@ __52: goto __54 } k = (i + 2) - if !(k > (3 + 2)) { + if !(k > (NB + 2)) { goto __55 } *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = Xsqlite3CorruptError(tls, 72322) @@ -50128,7 +49518,7 @@ __70: // that page. // Allocate k new pages. Reuse old pages where possible. - pageFlags = int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* &apOld[0] */ + uintptr(0)*8)))).FaData + uintptr(0)))) + pageFlags = int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* &apOld[0] */)))).FaData))) i = 0 __76: if !(i < k) { @@ -50171,8 +49561,8 @@ __82: if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) { goto __83 } - ptrmapPut(tls, pBt, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 264 /* pNew */)))).Fpgno, uint8(5), (*MemPage)(unsafe.Pointer(pParent)).Fpgno, bp+68 /* &rc */) - if !(*(*int32)(unsafe.Pointer(bp + 68 /* rc */)) != 0) { + ptrmapPut(tls, pBt, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 264 /* pNew */)))).Fpgno, PTRMAP_BTREE, (*MemPage)(unsafe.Pointer(pParent)).Fpgno, bp+68 /* &rc */) + if !(*(*int32)(unsafe.Pointer(bp + 68 /* rc */)) != SQLITE_OK) { goto __84 } goto balance_cleanup @@ -50292,7 +49682,7 @@ __94: // If the sibling pages are not leaves, ensure that the right-child pointer // of the right-most new sibling page is set to the value that was // originally in the same field of the right-most old sibling page. - if !(((pageFlags & 0x08) == 0) && (nOld != nNew)) { + if !(((pageFlags & PTF_LEAF) == 0) && (nOld != nNew)) { goto __101 } pOld1 = *(*uintptr)(unsafe.Pointer(func() uintptr { @@ -50301,7 +49691,7 @@ __94: } return bp + 8 /* &apOld[0] */ }() + uintptr((nOld-1))*8)) - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr((nNew-1))*8)))).FaData + uintptr(8)), ((*MemPage)(unsafe.Pointer(pOld1)).FaData + uintptr(8)), uint64(4)) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr((nNew-1))*8)))).FaData + 8), ((*MemPage)(unsafe.Pointer(pOld1)).FaData + 8), uint64(4)) __101: ; @@ -50323,7 +49713,7 @@ __101: if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) { goto __102 } - pNew1 = libc.AssignUintptr(&pOld2, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(0)*8))) + pNew1 = libc.AssignUintptr(&pOld2, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */))) cntOldNext = (int32((*MemPage)(unsafe.Pointer(pNew1)).FnCell) + int32((*MemPage)(unsafe.Pointer(pNew1)).FnOverflow)) iNew = 0 iOld = 0 @@ -50376,7 +49766,7 @@ __108: if !(!(leafCorrection != 0)) { goto __111 } - ptrmapPut(tls, pBt, Xsqlite3Get4byte(tls, pCell), uint8(5), (*MemPage)(unsafe.Pointer(pNew1)).Fpgno, bp+68 /* &rc */) + ptrmapPut(tls, pBt, Xsqlite3Get4byte(tls, pCell), PTRMAP_BTREE, (*MemPage)(unsafe.Pointer(pNew1)).Fpgno, bp+68 /* &rc */) __111: ; if !(int32(cachedCellSize(tls, bp+96 /* &b */, i)) > int32((*MemPage)(unsafe.Pointer(pNew1)).FminLocal)) { @@ -50418,7 +49808,7 @@ __114: if !(!(int32((*MemPage)(unsafe.Pointer(pNew2)).Fleaf) != 0)) { goto __117 } - libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pNew2)).FaData + uintptr(8)), pCell1, uint64(4)) + libc.Xmemcpy(tls, ((*MemPage)(unsafe.Pointer(pNew2)).FaData + 8), pCell1, uint64(4)) goto __118 __117: if !(leafData != 0) { @@ -50427,7 +49817,7 @@ __117: j-- (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer((pNew2 + 128 /* &.xParseCell */))))(tls, pNew2, *(*uintptr)(unsafe.Pointer((*CellArray)(unsafe.Pointer(bp+96 /* &b */)).FapCell + uintptr(j)*8)), bp+328 /* &info */) pCell1 = pTemp1 - sz2 = (4 + Xsqlite3PutVarint(tls, (pCell1+uintptr(4)), uint64((*CellInfo)(unsafe.Pointer(bp+328 /* &info */)).FnKey))) + sz2 = (4 + Xsqlite3PutVarint(tls, (pCell1+4), uint64((*CellInfo)(unsafe.Pointer(bp+328 /* &info */)).FnKey))) pTemp1 = uintptr(0) goto __120 __119: @@ -50456,7 +49846,7 @@ __118: iOvflSpace = iOvflSpace + (sz2) insertCell(tls, pParent, (nxDiv + i), pCell1, sz2, pTemp1, (*MemPage)(unsafe.Pointer(pNew2)).Fpgno, bp+68 /* &rc */) - if !(*(*int32)(unsafe.Pointer(bp + 68 /* rc */)) != 0) { + if !(*(*int32)(unsafe.Pointer(bp + 68 /* rc */)) != SQLITE_OK) { goto __122 } goto balance_cleanup @@ -50524,7 +49914,7 @@ __126: goto __128 } iNew1 = libc.AssignInt32(&iOld1, 0) - nNewCell = *(*int32)(unsafe.Pointer(bp + 200 /* &cntNew[0] */ + uintptr(0)*4)) + nNewCell = *(*int32)(unsafe.Pointer(bp + 200 /* &cntNew[0] */)) goto __129 __128: if iPg < nOld { @@ -50559,7 +49949,7 @@ __125: // All pages have been processed exactly once - if !(((isRoot != 0) && (int32((*MemPage)(unsafe.Pointer(pParent)).FnCell) == 0)) && (int32((*MemPage)(unsafe.Pointer(pParent)).FhdrOffset) <= (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(0)*8)))).FnFree)) { + if !(((isRoot != 0) && (int32((*MemPage)(unsafe.Pointer(pParent)).FnCell) == 0)) && (int32((*MemPage)(unsafe.Pointer(pParent)).FhdrOffset) <= (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */)))).FnFree)) { goto __131 } // The root page of the b-tree now contains no cells. The only sibling @@ -50577,10 +49967,10 @@ __125: // by smaller than the child due to the database header, and so all the // free space needs to be up front. - *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = defragmentPage(tls, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(0)*8)), -1) + *(*int32)(unsafe.Pointer(bp + 68 /* rc */)) = defragmentPage(tls, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */)), -1) - copyNodeContent(tls, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(0)*8)), pParent, bp+68 /* &rc */) - freePage(tls, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(0)*8)), bp+68 /* &rc */) + copyNodeContent(tls, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */)), pParent, bp+68 /* &rc */) + freePage(tls, *(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */)), bp+68 /* &rc */) goto __132 __131: if !(((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) && !(leafCorrection != 0)) { @@ -50594,8 +49984,8 @@ __134: if !(i < nNew) { goto __136 } - key = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(i)*8)))).FaData + uintptr(8))) - ptrmapPut(tls, pBt, key, uint8(5), (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(i)*8)))).Fpgno, bp+68 /* &rc */) + key = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(i)*8)))).FaData + 8)) + ptrmapPut(tls, pBt, key, PTRMAP_BTREE, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 224 /* &apNew[0] */ + uintptr(i)*8)))).Fpgno, bp+68 /* &rc */) goto __135 __135: i++ @@ -50687,11 +50077,11 @@ func balance_deeper(tls *libc.TLS, pRoot uintptr, ppChild uintptr) int32 { /* sq // page that will become the new right-child of pPage. Copy the contents // of the node stored on pRoot into the new child page. *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pRoot)).FpDbPage) - if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) = allocateBtreePage(tls, pBt, bp /* &pChild */, bp+8 /* &pgnoChild */, (*MemPage)(unsafe.Pointer(pRoot)).Fpgno, uint8(0)) copyNodeContent(tls, pRoot, *(*uintptr)(unsafe.Pointer(bp /* pChild */)), bp+12 /* &rc */) if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { - ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* pgnoChild */)), uint8(5), (*MemPage)(unsafe.Pointer(pRoot)).Fpgno, bp+12 /* &rc */) + ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* pgnoChild */)), PTRMAP_BTREE, (*MemPage)(unsafe.Pointer(pRoot)).Fpgno, bp+12 /* &rc */) } } if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != 0 { @@ -50708,11 +50098,11 @@ func balance_deeper(tls *libc.TLS, pRoot uintptr, ppChild uintptr) int32 { /* sq (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pChild */)))).FnOverflow = (*MemPage)(unsafe.Pointer(pRoot)).FnOverflow // Zero the contents of pRoot. Then install pChild as the right-child. - zeroPage(tls, pRoot, (int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pChild */)))).FaData + uintptr(0)))) & ^libc.Int32(0x08))) + zeroPage(tls, pRoot, (int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pChild */)))).FaData))) & libc.CplInt32(PTF_LEAF))) Xsqlite3Put4byte(tls, ((*MemPage)(unsafe.Pointer(pRoot)).FaData + uintptr((int32((*MemPage)(unsafe.Pointer(pRoot)).FhdrOffset) + 8))), *(*Pgno)(unsafe.Pointer(bp + 8 /* pgnoChild */))) *(*uintptr)(unsafe.Pointer(ppChild)) = *(*uintptr)(unsafe.Pointer(bp /* pChild */)) - return 0 + return SQLITE_OK } // Return SQLITE_CORRUPT if any cursor other than pCur is currently valid @@ -50728,12 +50118,12 @@ func anotherValidCursor(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:72844: var pOther uintptr for pOther = (*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FpCursor; pOther != 0; pOther = (*BtCursor)(unsafe.Pointer(pOther)).FpNext { if ((pOther != pCur) && - (int32((*BtCursor)(unsafe.Pointer(pOther)).FeState) == 0)) && + (int32((*BtCursor)(unsafe.Pointer(pOther)).FeState) == CURSOR_VALID)) && ((*BtCursor)(unsafe.Pointer(pOther)).FpPage == (*BtCursor)(unsafe.Pointer(pCur)).FpPage) { return Xsqlite3CorruptError(tls, 72851) } } - return 0 + return SQLITE_OK } // The page that pCur currently points to has just been modified in @@ -50748,13 +50138,13 @@ func balance(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:72867:12: */ bp := tls.Alloc(13) defer tls.Free(13) - var rc int32 = 0 + var rc int32 = SQLITE_OK var nMin int32 = (int32(((*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FusableSize * U32(2)) / U32(3))) // var aBalanceQuickSpace [13]U8 at bp, 13 var pFree uintptr = uintptr(0) - for ok := true; ok; ok = (rc == 0) { + for ok := true; ok; ok = (rc == SQLITE_OK) { var iPage int32 var pPage uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpPage @@ -50764,19 +50154,19 @@ func balance(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:72867:12: */ if (int32((*MemPage)(unsafe.Pointer(pPage)).FnOverflow) == 0) && ((*MemPage)(unsafe.Pointer(pPage)).FnFree <= nMin) { break } else if (libc.AssignInt32(&iPage, int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage))) == 0 { - if ((*MemPage)(unsafe.Pointer(pPage)).FnOverflow != 0) && ((libc.AssignInt32(&rc, anotherValidCursor(tls, pCur))) == 0) { + if ((*MemPage)(unsafe.Pointer(pPage)).FnOverflow != 0) && ((libc.AssignInt32(&rc, anotherValidCursor(tls, pCur))) == SQLITE_OK) { // The root page of the b-tree is overfull. In this case call the // balance_deeper() function to create a new child for the root-page // and copy the current contents of the root-page to it. The // next iteration of the do-loop will balance the child page. - rc = balance_deeper(tls, pPage, ((pCur + 144 /* &.apPage */) + uintptr(1)*8)) - if rc == 0 { + rc = balance_deeper(tls, pPage, ((pCur + 144 /* &.apPage */) + 1*8)) + if rc == SQLITE_OK { (*BtCursor)(unsafe.Pointer(pCur)).FiPage = int8(1) (*BtCursor)(unsafe.Pointer(pCur)).Fix = U16(0) - *(*U16)(unsafe.Pointer((pCur + 88 /* &.aiIdx */) + uintptr(0)*2)) = U16(0) - *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */) + uintptr(0)*8)) = pPage - (*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */) + uintptr(1)*8)) + *(*U16)(unsafe.Pointer((pCur + 88 /* &.aiIdx */))) = U16(0) + *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */))) = pPage + (*BtCursor)(unsafe.Pointer(pCur)).FpPage = *(*uintptr)(unsafe.Pointer((pCur + 144 /* &.apPage */) + 1*8)) } } else { @@ -50787,13 +50177,13 @@ func balance(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:72867:12: */ var iIdx int32 = int32(*(*U16)(unsafe.Pointer((pCur + 88 /* &.aiIdx */) + uintptr((iPage-1))*2))) rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pParent)).FpDbPage) - if (rc == 0) && ((*MemPage)(unsafe.Pointer(pParent)).FnFree < 0) { + if (rc == SQLITE_OK) && ((*MemPage)(unsafe.Pointer(pParent)).FnFree < 0) { rc = btreeComputeFreeSpace(tls, pParent) } - if rc == 0 { + if rc == SQLITE_OK { if (((((*MemPage)(unsafe.Pointer(pPage)).FintKeyLeaf != 0) && (int32((*MemPage)(unsafe.Pointer(pPage)).FnOverflow) == 1)) && - (int32(*(*U16)(unsafe.Pointer((pPage + 28 /* &.aiOvfl */) + uintptr(0)*2))) == int32((*MemPage)(unsafe.Pointer(pPage)).FnCell))) && + (int32(*(*U16)(unsafe.Pointer((pPage + 28 /* &.aiOvfl */)))) == int32((*MemPage)(unsafe.Pointer(pPage)).FnCell))) && ((*MemPage)(unsafe.Pointer(pParent)).Fpgno != Pgno(1))) && (int32((*MemPage)(unsafe.Pointer(pParent)).FnCell) == iIdx) { // Call balance_quick() to create a new sibling of pPage on which @@ -50829,7 +50219,7 @@ func balance(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:72867:12: */ // pSpace buffer passed to the latter call to balance_nonroot(). var pSpace uintptr = Xsqlite3PageMalloc(tls, int32((*BtShared)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBt)).FpageSize)) rc = balance_nonroot(tls, pParent, iIdx, pSpace, (libc.Bool32(iPage == 1)), - (int32((*BtCursor)(unsafe.Pointer(pCur)).Fhints) & 0x00000001)) + (int32((*BtCursor)(unsafe.Pointer(pCur)).Fhints) & BTREE_BULKLOAD)) if pFree != 0 { // If pFree is not NULL, it points to the pSpace buffer used // by a previous call to balance_nonroot(). Its contents are @@ -50900,7 +50290,7 @@ func btreeOverwriteContent(tls *libc.TLS, pPage uintptr, pDest uintptr, pX uintp libc.Xmemmove(tls, pDest, (((*BtreePayload)(unsafe.Pointer(pX)).FpData) + uintptr(iOffset)), uint64(iAmt)) } } - return 0 + return SQLITE_OK } // Overwrite the cell that cursor pCur is pointing to with fresh content @@ -50928,7 +50318,7 @@ func btreeOverwriteCell(tls *libc.TLS, pCur uintptr, pX uintptr) int32 { /* sqli return rc } if int32((*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnLocal) == nTotal { - return 0 + return SQLITE_OK } // Now overwrite the overflow pages @@ -50959,7 +50349,7 @@ func btreeOverwriteCell(tls *libc.TLS, pCur uintptr, pX uintptr) int32 { /* sqli } iOffset = int32(U32(iOffset) + (ovflPageSize)) } - return 0 + return SQLITE_OK } // Insert a new record into the BTree. The content of the new record @@ -51017,7 +50407,7 @@ func Xsqlite3BtreeInsert(tls *libc.TLS, pCur uintptr, pX uintptr, flags int32, s pBt = (*Btree)(unsafe.Pointer(p)).FpBt newCell = uintptr(0) - if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 4) { + if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_FAULT) { goto __1 } @@ -51041,7 +50431,7 @@ __1: // that the cursor is already where it needs to be and returns without // doing any work. To avoid thwarting these optimizations, it is important // not to clear the cursor here. - if !((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x20) != 0) { + if !((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_Multiple) != 0) { goto __2 } *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = saveAllCursors(tls, pBt, (*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, pCur) @@ -51068,7 +50458,7 @@ __2: // On the other hand, BTREE_SAVEPOSITION==0 does not imply // that the cursor is not pointing to a row to be overwritten. // So do a complete check. - if !(((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x02) != 0) && ((*BtreePayload)(unsafe.Pointer(pX)).FnKey == (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey)) { + if !(((int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_ValidNKey) != 0) && ((*BtreePayload)(unsafe.Pointer(pX)).FnKey == (*BtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey)) { goto __6 } // The cursor is pointing to the entry that is to be @@ -51114,7 +50504,7 @@ __4: // overwritten, or if a new cell is being inserted, if the cursor is // not pointing to an immediately adjacent cell, then move the cursor // so that it does. - if !((*(*int32)(unsafe.Pointer(bp /* loc */)) == 0) && ((flags & 0x02) == 0)) { + if !((*(*int32)(unsafe.Pointer(bp /* loc */)) == 0) && ((flags & BTREE_SAVEPOSITION) == 0)) { goto __11 } if !((*BtreePayload)(unsafe.Pointer(pX)).FnMem != 0) { @@ -51170,7 +50560,7 @@ __5: if !((*MemPage)(unsafe.Pointer(pPage)).FnFree < 0) { goto __17 } - if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) > 1) { + if !(int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) > CURSOR_INVALID) { goto __18 } *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = Xsqlite3CorruptError(tls, 73263) @@ -51219,7 +50609,7 @@ __25: ; *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = clearCell(tls, pPage, oldCell, bp+88 /* &info */) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x04))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_ValidOvfl))) if !(((int32((*CellInfo)(unsafe.Pointer(bp+88 /* &info */)).FnSize) == *(*int32)(unsafe.Pointer(bp + 80 /* szNew */))) && (U32((*CellInfo)(unsafe.Pointer(bp+88 /* &info */)).FnLocal) == (*CellInfo)(unsafe.Pointer(bp+88 /* &info */)).FnPayload)) && (!(int32((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum) != 0) || (*(*int32)(unsafe.Pointer(bp + 80 /* szNew */)) < int32((*MemPage)(unsafe.Pointer(pPage)).FminLocal)))) { goto __26 @@ -51247,7 +50637,7 @@ __27: __28: ; libc.Xmemcpy(tls, oldCell, newCell, uint64(*(*int32)(unsafe.Pointer(bp + 80 /* szNew */)))) - return 0 + return SQLITE_OK __26: ; dropCell(tls, pPage, idx, int32((*CellInfo)(unsafe.Pointer(bp+88 /* &info */)).FnSize), bp+112 /* &rc */) @@ -51264,7 +50654,7 @@ __22: } idx = int32(libc.PreIncUint16(&(*BtCursor)(unsafe.Pointer(pCur)).Fix, 1)) - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x02))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_ValidNKey))) goto __31 __30: ; @@ -51298,7 +50688,7 @@ __23: goto __32 } - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((^libc.Int32(0x02))) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) &= libc.Uint8FromInt32((libc.CplInt32(BTCF_ValidNKey))) *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = balance(tls, pCur) // Must make sure nOverflow is reset to zero even if the balance() @@ -51306,8 +50696,8 @@ __23: // Also, set the cursor state to invalid. This stops saveCursorPosition() // from trying to save the current position of the cursor. (*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).FnOverflow = U8(0) - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(1) - if !(((flags & 0x02) != 0) && (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == 0)) { + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_INVALID + if !(((flags & BTREE_SAVEPOSITION) != 0) && (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK)) { goto __33 } btreeReleaseAllCursorPages(tls, pCur) @@ -51319,7 +50709,7 @@ __23: if !((*BtCursor)(unsafe.Pointer(pCur)).FpKey == uintptr(0)) { goto __35 } - *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = SQLITE_NOMEM goto __36 __35: libc.Xmemcpy(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpKey, (*BtreePayload)(unsafe.Pointer(pX)).FpKey, uint64((*BtreePayload)(unsafe.Pointer(pX)).FnKey)) @@ -51327,7 +50717,7 @@ __36: ; __34: ; - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(3) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_REQUIRESEEK (*BtCursor)(unsafe.Pointer(pCur)).FnKey = (*BtreePayload)(unsafe.Pointer(pX)).FnKey __33: ; @@ -51367,10 +50757,10 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit var iCellDepth int32 // Depth of node containing pCell // var info CellInfo at bp, 24 // Size of the cell being deleted - var bSkipnext int32 = 0 // Leaf cursor in SKIPNEXT state - var bPreserve U8 = (U8(int32(flags) & 0x02)) // Keep cursor valid + var bSkipnext int32 = 0 // Leaf cursor in SKIPNEXT state + var bPreserve U8 = (U8(int32(flags) & BTREE_SAVEPOSITION)) // Keep cursor valid - if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == 3 { + if int32((*BtCursor)(unsafe.Pointer(pCur)).FeState) == CURSOR_REQUIRESEEK { *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = btreeRestoreCursorPosition(tls, pCur) if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) @@ -51382,7 +50772,7 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit pPage = (*BtCursor)(unsafe.Pointer(pCur)).FpPage pCell = ((*MemPage)(unsafe.Pointer((pPage))).FaData + uintptr((int32((*MemPage)(unsafe.Pointer((pPage))).FmaskPage) & int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(((*MemPage)(unsafe.Pointer((pPage))).FaCellIdx + uintptr((2 * (iCellIdx))))))))))) if ((*MemPage)(unsafe.Pointer(pPage)).FnFree < 0) && (btreeComputeFreeSpace(tls, pPage) != 0) { - return 11 + return SQLITE_CORRUPT } // If the bPreserve flag is set to true, then the cursor position must @@ -51426,7 +50816,7 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit // Save the positions of any other cursors open on this table before // making any modifications. - if (int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & 0x20) != 0 { + if (int32((*BtCursor)(unsafe.Pointer(pCur)).FcurFlags) & BTCF_Multiple) != 0 { *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = saveAllCursors(tls, pBt, (*BtCursor)(unsafe.Pointer(pCur)).FpgnoRoot, pCur) if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) @@ -51475,7 +50865,7 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit n = (*MemPage)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpPage)).Fpgno } pCell = ((*MemPage)(unsafe.Pointer((pLeaf))).FaData + uintptr((int32((*MemPage)(unsafe.Pointer((pLeaf))).FmaskPage) & int32(libc.X__builtin_bswap16(tls, *(*U16)(unsafe.Pointer(((*MemPage)(unsafe.Pointer((pLeaf))).FaCellIdx + uintptr((2 * (int32((*MemPage)(unsafe.Pointer(pLeaf)).FnCell) - 1))))))))))) - if pCell < ((*MemPage)(unsafe.Pointer(pLeaf)).FaData + uintptr(4)) { + if pCell < ((*MemPage)(unsafe.Pointer(pLeaf)).FaData + 4) { return Xsqlite3CorruptError(tls, 73510) } nCell = int32((*(*func(*libc.TLS, uintptr, uintptr) U16)(unsafe.Pointer((pLeaf + 120 /* &.xCellSize */))))(tls, pLeaf, pCell)) @@ -51483,7 +50873,7 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit pTmp = (*BtShared)(unsafe.Pointer(pBt)).FpTmpSpace *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(pLeaf)).FpDbPage) - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { insertCell(tls, pPage, iCellIdx, (pCell - uintptr(4)), (nCell + 4), pTmp, n, bp+24 /* &rc */) } dropCell(tls, pLeaf, (int32((*MemPage)(unsafe.Pointer(pLeaf)).FnCell) - 1), nCell, bp+24 /* &rc */) @@ -51508,7 +50898,7 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit // walk the cursor up the tree to the internal node and balance it as // well. *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = balance(tls, pCur) - if (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0) && (int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) > iCellDepth) { + if (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK) && (int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) > iCellDepth) { releasePageNotNull(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpPage) (*BtCursor)(unsafe.Pointer(pCur)).FiPage-- for int32((*BtCursor)(unsafe.Pointer(pCur)).FiPage) > iCellDepth { @@ -51518,10 +50908,10 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = balance(tls, pCur) } - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { if bSkipnext != 0 { - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(2) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_SKIPNEXT if iCellIdx >= int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) { (*BtCursor)(unsafe.Pointer(pCur)).FskipNext = -1 (*BtCursor)(unsafe.Pointer(pCur)).Fix = (U16(int32((*MemPage)(unsafe.Pointer(pPage)).FnCell) - 1)) @@ -51532,10 +50922,10 @@ func Xsqlite3BtreeDelete(tls *libc.TLS, pCur uintptr, flags U8) int32 { /* sqlit *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = moveToRoot(tls, pCur) if bPreserve != 0 { btreeReleaseAllCursorPages(tls, pCur) - (*BtCursor)(unsafe.Pointer(pCur)).FeState = U8(3) + (*BtCursor)(unsafe.Pointer(pCur)).FeState = CURSOR_REQUIRESEEK } - if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 16 { - *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = 0 + if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_EMPTY { + *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = SQLITE_OK } } } @@ -51579,7 +50969,7 @@ func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags // Read the value of meta[3] from the database to determine where the // root page of the new table should go. meta[3] is the largest root-page // created so far, so the new root-page is (meta[3]+1). - Xsqlite3BtreeGetMeta(tls, p, 4, bp /* &pgnoRoot */) + Xsqlite3BtreeGetMeta(tls, p, BTREE_LARGEST_ROOT_PAGE, bp /* &pgnoRoot */) if *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)) > btreePagecount(tls, pBt) { return Xsqlite3CorruptError(tls, 73618) } @@ -51594,8 +50984,8 @@ func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags // Allocate a page. The page that currently resides at pgnoRoot will // be moved to the allocated page (unless the allocated page happens // to reside at pgnoRoot). - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = allocateBtreePage(tls, pBt, bp+8 /* &pPageMove */, bp+16 /* &pgnoMove */, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), uint8(1)) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = allocateBtreePage(tls, pBt, bp+8 /* &pPageMove */, bp+16 /* &pgnoMove */, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), BTALLOC_EXACT) + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } @@ -51613,20 +51003,20 @@ func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags // corresponding to page pgnoRoot. *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = saveAllCursors(tls, pBt, uint32(0), uintptr(0)) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pPageMove */))) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } // Move the page currently at pgnoRoot to pgnoMove. *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = btreeGetPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), bp+24 /* &pRoot */, 0) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = ptrmapGet(tls, pBt, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), bp+32 /* &eType */, bp+36 /* &iPtrPage */) - if (int32(*(*U8)(unsafe.Pointer(bp + 32 /* eType */))) == 1) || (int32(*(*U8)(unsafe.Pointer(bp + 32 /* eType */))) == 2) { + if (int32(*(*U8)(unsafe.Pointer(bp + 32 /* eType */))) == PTRMAP_ROOTPAGE) || (int32(*(*U8)(unsafe.Pointer(bp + 32 /* eType */))) == PTRMAP_FREEPAGE) { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = Xsqlite3CorruptError(tls, 73666) } - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */))) return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } @@ -51635,15 +51025,15 @@ func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */))) // Obtain the page at pgnoRoot - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = btreeGetPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), bp+24 /* &pRoot */, 0) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)))).FpDbPage) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */))) return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } @@ -51652,7 +51042,7 @@ func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags } // Update the pointer-map and meta-data with the new root-page number. - ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), uint8(1), uint32(0), bp+40 /* &rc */) + ptrmapPut(tls, pBt, *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)), PTRMAP_ROOTPAGE, uint32(0), bp+40 /* &rc */) if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */))) return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) @@ -51675,16 +51065,16 @@ func btreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, createTabFlags } } - if (createTabFlags & 1) != 0 { - ptfFlags = ((0x01 | 0x04) | 0x08) + if (createTabFlags & BTREE_INTKEY) != 0 { + ptfFlags = ((PTF_INTKEY | PTF_LEAFDATA) | PTF_LEAF) } else { - ptfFlags = (0x02 | 0x08) + ptfFlags = (PTF_ZERODATA | PTF_LEAF) } zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)), ptfFlags) Xsqlite3PagerUnref(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)))).FpDbPage) *(*Pgno)(unsafe.Pointer(piTable)) = *(*Pgno)(unsafe.Pointer(bp /* pgnoRoot */)) - return 0 + return SQLITE_OK } func Xsqlite3BtreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, flags int32) int32 { /* sqlite3.c:73729:20: */ @@ -51794,7 +51184,7 @@ __14: if !((libc.AssignPtrInt32(bp+32 /* rc */, Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FpDbPage))) == 0) { goto __16 } - zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */)), (int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FaData + uintptr(hdr)))) | 0x08)) + zeroPage(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */)), (int32(*(*U8)(unsafe.Pointer((*MemPage)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pPage */)))).FaData + uintptr(hdr)))) | PTF_LEAF)) __16: ; __15: @@ -51824,7 +51214,7 @@ func Xsqlite3BtreeClearTable(tls *libc.TLS, p uintptr, iTable int32, pnChange ui rc = saveAllCursors(tls, pBt, Pgno(iTable), uintptr(0)) - if 0 == rc { + if SQLITE_OK == rc { // Invalidate all incrblob cursors open on table iTable (assuming iTable // is the root of a table b-tree - if it is not, the following call is // a no-op). @@ -51888,14 +51278,14 @@ func btreeDropTable(tls *libc.TLS, p uintptr, iTable Pgno, piMoved uintptr) int3 if (*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0 { // var maxRootPgno Pgno at bp+8, 4 - Xsqlite3BtreeGetMeta(tls, p, 4, bp+8 /* &maxRootPgno */) + Xsqlite3BtreeGetMeta(tls, p, BTREE_LARGEST_ROOT_PAGE, bp+8 /* &maxRootPgno */) if iTable == *(*Pgno)(unsafe.Pointer(bp + 8 /* maxRootPgno */)) { // If the table being dropped is the table with the largest root-page // number in the database, put the root page on the free list. freePage(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */)), bp+12 /* &rc */) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */))) - if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) } } else { @@ -51906,19 +51296,19 @@ func btreeDropTable(tls *libc.TLS, p uintptr, iTable Pgno, piMoved uintptr) int3 releasePage(tls, *(*uintptr)(unsafe.Pointer(bp /* pPage */))) *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) = btreeGetPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* maxRootPgno */)), bp+16 /* &pMove */, 0) - if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) } - *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) = relocatePage(tls, pBt, *(*uintptr)(unsafe.Pointer(bp + 16 /* pMove */)), uint8(1), uint32(0), iTable, 0) + *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) = relocatePage(tls, pBt, *(*uintptr)(unsafe.Pointer(bp + 16 /* pMove */)), PTRMAP_ROOTPAGE, uint32(0), iTable, 0) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pMove */))) - if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) } *(*uintptr)(unsafe.Pointer(bp + 16 /* pMove */)) = uintptr(0) *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) = btreeGetPage(tls, pBt, *(*Pgno)(unsafe.Pointer(bp + 8 /* maxRootPgno */)), bp+16 /* &pMove */, 0) freePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pMove */)), bp+12 /* &rc */) releasePage(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pMove */))) - if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) != SQLITE_OK { return *(*int32)(unsafe.Pointer(bp + 12 /* rc */)) } *(*int32)(unsafe.Pointer(piMoved)) = int32(*(*Pgno)(unsafe.Pointer(bp + 8 /* maxRootPgno */))) @@ -51973,7 +51363,7 @@ func Xsqlite3BtreeGetMeta(tls *libc.TLS, p uintptr, idx int32, pMeta uintptr) { Xsqlite3BtreeEnter(tls, p) - if idx == 15 { + if idx == BTREE_DATA_VERSION { *(*U32)(unsafe.Pointer(pMeta)) = (Xsqlite3PagerDataVersion(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager) + (*Btree)(unsafe.Pointer(p)).FiDataVersion) } else { *(*U32)(unsafe.Pointer(pMeta)) = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr((36 + (idx * 4))))) @@ -51996,9 +51386,9 @@ func Xsqlite3BtreeUpdateMeta(tls *libc.TLS, p uintptr, idx int32, iMeta U32) int pP1 = (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3Put4byte(tls, (pP1 + uintptr((36 + (idx * 4)))), iMeta) - if idx == 7 { + if idx == BTREE_INCR_VACUUM { (*BtShared)(unsafe.Pointer(pBt)).FincrVacuum = U8(iMeta) } @@ -52018,14 +51408,14 @@ func Xsqlite3BtreeCount(tls *libc.TLS, db uintptr, pCur uintptr, pnEntry uintptr var rc int32 // Return code rc = moveToRoot(tls, pCur) - if rc == 16 { + if rc == SQLITE_EMPTY { *(*I64)(unsafe.Pointer(pnEntry)) = int64(0) - return 0 + return SQLITE_OK } // Unless an error occurs, the following loop runs one iteration for each // page in the B-Tree structure (not including overflow pages). - for (rc == 0) && !(libc.AtomicLoadNInt32((db+392 /* &.u1 */ /* &.isInterrupted */), 0) != 0) { + for (rc == SQLITE_OK) && !(libc.AtomicLoadNInt32((db+392 /* &.u1 */ /* &.isInterrupted */), 0) != 0) { var iIdx int32 // Index of child node in parent var pPage uintptr // Current page of the b-tree @@ -52101,7 +51491,7 @@ func checkAppendMsg(tls *libc.TLS, pCheck uintptr, zFormat uintptr, va uintptr) } Xsqlite3_str_vappendf(tls, (pCheck + 56 /* &.errMsg */), zFormat, ap) _ = ap - if int32((*IntegrityCk)(unsafe.Pointer(pCheck)).FerrMsg.FaccError) == 7 { + if int32((*IntegrityCk)(unsafe.Pointer(pCheck)).FerrMsg.FaccError) == SQLITE_NOMEM { (*IntegrityCk)(unsafe.Pointer(pCheck)).FbOomFault = 1 } } @@ -52157,8 +51547,8 @@ func checkPtrmap(tls *libc.TLS, pCheck uintptr, iChild Pgno, eType U8, iParent P // var iPtrmapParent Pgno at bp+52, 4 rc = ptrmapGet(tls, (*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt, iChild, bp+48 /* &ePtrmapType */, bp+52 /* &iPtrmapParent */) - if rc != 0 { - if (rc == 7) || (rc == (10 | (int32(12) << 8))) { + if rc != SQLITE_OK { + if (rc == SQLITE_NOMEM) || (rc == (SQLITE_IOERR | (int32(12) << 8))) { (*IntegrityCk)(unsafe.Pointer(pCheck)).FbOomFault = 1 } checkAppendMsg(tls, pCheck, ts+5765 /* "Failed to read p..." */, libc.VaList(bp, iChild)) @@ -52195,9 +51585,9 @@ func checkList(tls *libc.TLS, pCheck uintptr, isFreeList int32, iPage Pgno, N U3 } pOvflData = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pOvflPage */))) if isFreeList != 0 { - var n U32 = Xsqlite3Get4byte(tls, (pOvflData + uintptr(4))) + var n U32 = Xsqlite3Get4byte(tls, (pOvflData + 4)) if (*BtShared)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 { - checkPtrmap(tls, pCheck, iPage, uint8(2), uint32(0)) + checkPtrmap(tls, pCheck, iPage, PTRMAP_FREEPAGE, uint32(0)) } if n > (((*BtShared)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FusableSize / U32(4)) - U32(2)) { checkAppendMsg(tls, pCheck, @@ -52207,7 +51597,7 @@ func checkList(tls *libc.TLS, pCheck uintptr, isFreeList int32, iPage Pgno, N U3 for i = 0; i < int32(n); i++ { var iFreePage Pgno = Xsqlite3Get4byte(tls, (pOvflData + uintptr((8 + (i * 4))))) if (*BtShared)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 { - checkPtrmap(tls, pCheck, iFreePage, uint8(2), uint32(0)) + checkPtrmap(tls, pCheck, iFreePage, PTRMAP_FREEPAGE, uint32(0)) } checkRef(tls, pCheck, iFreePage) } @@ -52219,7 +51609,7 @@ func checkList(tls *libc.TLS, pCheck uintptr, isFreeList int32, iPage Pgno, N U3 // the following page matches iPage. if ((*BtShared)(unsafe.Pointer((*IntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0) && (N > U32(0)) { i = int32(Xsqlite3Get4byte(tls, pOvflData)) - checkPtrmap(tls, pCheck, uint32(i), uint8(4), iPage) + checkPtrmap(tls, pCheck, uint32(i), PTRMAP_OVERFLOW2, iPage) } } iPage = Xsqlite3Get4byte(tls, pOvflData) @@ -52260,7 +51650,7 @@ func checkList(tls *libc.TLS, pCheck uintptr, isFreeList int32, iPage Pgno, N U3 // lower 16 bits are the index of the last byte of that range. func btreeHeapInsert(tls *libc.TLS, aHeap uintptr, x U32) { /* sqlite3.c:74299:13: */ var j U32 - var i U32 = libc.PreIncUint32(&*(*U32)(unsafe.Pointer(aHeap + uintptr(0)*4)), 1) + var i U32 = libc.PreIncUint32(&*(*U32)(unsafe.Pointer(aHeap)), 1) *(*U32)(unsafe.Pointer(aHeap + uintptr(i)*4)) = x for ((libc.AssignUint32(&j, (i / U32(2)))) > U32(0)) && (*(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4)) > *(*U32)(unsafe.Pointer(aHeap + uintptr(i)*4))) { x = *(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4)) @@ -52274,15 +51664,15 @@ func btreeHeapPull(tls *libc.TLS, aHeap uintptr, pOut uintptr) int32 { /* sqlite var j U32 var i U32 var x U32 - if (libc.AssignUint32(&x, *(*U32)(unsafe.Pointer(aHeap + uintptr(0)*4)))) == U32(0) { + if (libc.AssignUint32(&x, *(*U32)(unsafe.Pointer(aHeap)))) == U32(0) { return 0 } - *(*U32)(unsafe.Pointer(pOut)) = *(*U32)(unsafe.Pointer(aHeap + uintptr(1)*4)) - *(*U32)(unsafe.Pointer(aHeap + uintptr(1)*4)) = *(*U32)(unsafe.Pointer(aHeap + uintptr(x)*4)) + *(*U32)(unsafe.Pointer(pOut)) = *(*U32)(unsafe.Pointer(aHeap + 1*4)) + *(*U32)(unsafe.Pointer(aHeap + 1*4)) = *(*U32)(unsafe.Pointer(aHeap + uintptr(x)*4)) *(*U32)(unsafe.Pointer(aHeap + uintptr(x)*4)) = 0xffffffff - *(*U32)(unsafe.Pointer(aHeap + uintptr(0)*4))-- + *(*U32)(unsafe.Pointer(aHeap))-- i = U32(1) - for (libc.AssignUint32(&j, (i * U32(2)))) <= *(*U32)(unsafe.Pointer(aHeap + uintptr(0)*4)) { + for (libc.AssignUint32(&j, (i * U32(2)))) <= *(*U32)(unsafe.Pointer(aHeap)) { if *(*U32)(unsafe.Pointer(aHeap + uintptr(j)*4)) > *(*U32)(unsafe.Pointer(aHeap + uintptr((j+U32(1)))*4)) { j++ } @@ -52413,12 +51803,12 @@ __5: // Set up for cell analysis (*IntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = ts + 6069 /* "On tree page %u ..." */ - contentOffset = (U32(((((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + uintptr(1))))) - 1) & 0xffff) + 1)) + contentOffset = (U32(((((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 5))) + 1)))) - 1) & 0xffff) + 1)) // Enforced by btreeInitPage() // EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the // number of cells on the page. - nCell = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))) + uintptr(1))))) + nCell = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 3)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 3))) + 1)))) // EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page // immediately follows the b-tree page header. @@ -52435,7 +51825,7 @@ __5: goto __8 } (*IntegrityCk)(unsafe.Pointer(pCheck)).FzPfx = ts + 6095 /* "On page %u at ri..." */ - checkPtrmap(tls, pCheck, uint32(pgno), uint8(5), iPage) + checkPtrmap(tls, pCheck, uint32(pgno), PTRMAP_BTREE, iPage) __8: ; depth = checkTreePage(tls, pCheck, uint32(pgno), bp+104 /* &maxKey */, *(*I64)(unsafe.Pointer(bp + 104 /* maxKey */))) @@ -52445,7 +51835,7 @@ __6: // For leaf pages, the coverage check will occur in the same loop // as the other cell checks, so initialize the heap. heap = (*IntegrityCk)(unsafe.Pointer(pCheck)).Fheap - *(*U32)(unsafe.Pointer(heap + uintptr(0)*4)) = U32(0) + *(*U32)(unsafe.Pointer(heap)) = U32(0) __7: ; @@ -52512,7 +51902,7 @@ __14: if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) { goto __17 } - checkPtrmap(tls, pCheck, pgnoOvfl, uint8(3), iPage) + checkPtrmap(tls, pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage) __17: ; checkList(tls, pCheck, 0, pgnoOvfl, nPage) @@ -52527,7 +51917,7 @@ __16: if !((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) { goto __20 } - checkPtrmap(tls, pCheck, uint32(pgno), uint8(5), iPage) + checkPtrmap(tls, pCheck, uint32(pgno), PTRMAP_BTREE, iPage) __20: ; d2 = checkTreePage(tls, pCheck, uint32(pgno), bp+104 /* &maxKey */, *(*I64)(unsafe.Pointer(bp + 104 /* maxKey */))) @@ -52566,7 +51956,7 @@ __11: goto __23 } heap = (*IntegrityCk)(unsafe.Pointer(pCheck)).Fheap - *(*U32)(unsafe.Pointer(heap + uintptr(0)*4)) = U32(0) + *(*U32)(unsafe.Pointer(heap)) = U32(0) i = (nCell - 1) __24: if !(i >= 0) { @@ -52589,20 +51979,20 @@ __23: // EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header // is the offset of the first freeblock, or zero if there are no // freeblocks on the page. - i = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 1))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 1))) + uintptr(1))))) + i = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 1)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((hdr + 1))) + 1)))) __27: if !(i > 0) { goto __28 } // Enforced by btreeComputeFreeSpace() - size1 = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((i + 2))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((i + 2))) + uintptr(1))))) + size1 = ((int32(*(*U8)(unsafe.Pointer((data + uintptr((i + 2)))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr((i + 2))) + 1)))) // due to btreeComputeFreeSpace() btreeHeapInsert(tls, heap, (((U32(i)) << 16) | (U32((i + size1) - 1)))) // EVIDENCE-OF: R-58208-19414 The first 2 bytes of a freeblock are a // big-endian integer which is the offset in the b-tree page of the next // freeblock in the chain, or zero if the freeblock is the last on the // chain. - j = ((int32(*(*U8)(unsafe.Pointer((data + uintptr(i)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr(i)) + uintptr(1))))) + j = ((int32(*(*U8)(unsafe.Pointer((data + uintptr(i))))) << 8) | int32(*(*U8)(unsafe.Pointer((data + uintptr(i)) + 1)))) // EVIDENCE-OF: R-06866-39125 Freeblocks are always connected in order of // increasing offset. // Enforced by btreeComputeFreeSpace() @@ -52649,7 +52039,7 @@ __30: // is stored in the fifth field of the b-tree page header. // EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the // number of fragmented free bytes within the cell content area. - if !((*(*U32)(unsafe.Pointer(heap + uintptr(0)*4)) == U32(0)) && (nFrag != int32(*(*U8)(unsafe.Pointer(data + uintptr((hdr + 7))))))) { + if !((*(*U32)(unsafe.Pointer(heap)) == U32(0)) && (nFrag != int32(*(*U8)(unsafe.Pointer(data + uintptr((hdr + 7))))))) { goto __33 } checkAppendMsg(tls, pCheck, @@ -52716,12 +52106,12 @@ func Xsqlite3BtreeIntegrityCheck(tls *libc.TLS, db uintptr, p uintptr, aRoot uin bCkFreelist = 1 // True to scan the freelist // aRoot[0]==0 means this is a partial check - if !(*(*Pgno)(unsafe.Pointer(aRoot + uintptr(0)*4)) == Pgno(0)) { + if !(*(*Pgno)(unsafe.Pointer(aRoot)) == Pgno(0)) { goto __1 } bPartial = 1 - if !(*(*Pgno)(unsafe.Pointer(aRoot + uintptr(1)*4)) != Pgno(1)) { + if !(*(*Pgno)(unsafe.Pointer(aRoot + 1*4)) != Pgno(1)) { goto __2 } bCkFreelist = 0 @@ -52744,8 +52134,8 @@ __1: (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).Fv2 = 0 (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).FaPgRef = uintptr(0) (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).Fheap = uintptr(0) - Xsqlite3StrAccumInit(tls, (bp + 32 /* &sCheck */ + 56 /* &.errMsg */), uintptr(0), bp+136 /* &zErr[0] */, int32(unsafe.Sizeof([100]int8{})), 1000000000) - (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).FerrMsg.FprintfFlags = U8(0x01) + Xsqlite3StrAccumInit(tls, (bp + 32 /* &sCheck */ + 56 /* &.errMsg */), uintptr(0), bp+136 /* &zErr[0] */, int32(unsafe.Sizeof([100]int8{})), SQLITE_MAX_LENGTH) + (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).FerrMsg.FprintfFlags = SQLITE_PRINTF_INTERNAL if !((*IntegrityCk)(unsafe.Pointer(bp+32 /* &sCheck */)).FnPage == Pgno(0)) { goto __3 } @@ -52783,8 +52173,8 @@ __6: goto __7 } (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).FzPfx = ts + 6315 /* "Main freelist: " */ - checkList(tls, bp+32 /* &sCheck */, 1, Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+uintptr(32))), - Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+uintptr(36)))) + checkList(tls, bp+32 /* &sCheck */, 1, Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+32)), + Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36))) (*IntegrityCk)(unsafe.Pointer(bp + 32 /* &sCheck */)).FzPfx = uintptr(0) __7: ; @@ -52815,7 +52205,7 @@ __12: goto __13 __13: ; - mxInHdr = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + uintptr(52))) + mxInHdr = Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData + 52)) if !(mx != mxInHdr) { goto __15 } @@ -52826,7 +52216,7 @@ __15: ; goto __10 __9: - if !(Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+uintptr(64))) != U32(0)) { + if !(Xsqlite3Get4byte(tls, ((*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+64)) != U32(0)) { goto __16 } checkAppendMsg(tls, bp+32, /* &sCheck */ @@ -52838,7 +52228,7 @@ __10: __8: ; - *(*U64)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x00200000))) + *(*U64)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).Fdb + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_CellSizeCk)) i = Pgno(0) __17: if !((int32(i) < nRoot) && ((*IntegrityCk)(unsafe.Pointer(bp+32 /* &sCheck */)).FmxErr != 0)) { @@ -52853,7 +52243,7 @@ __20: if !((((*BtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) && (*(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4)) > Pgno(1))) && !(bPartial != 0)) { goto __21 } - checkPtrmap(tls, bp+32 /* &sCheck */, *(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4)), uint8(1), uint32(0)) + checkPtrmap(tls, bp+32 /* &sCheck */, *(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4)), PTRMAP_ROOTPAGE, uint32(0)) __21: ; checkTreePage(tls, bp+32 /* &sCheck */, *(*Pgno)(unsafe.Pointer(aRoot + uintptr(i)*4)), bp+240 /* ¬Used */, (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))) @@ -52947,7 +52337,7 @@ func Xsqlite3BtreeGetJournalname(tls *libc.TLS, p uintptr) uintptr { /* sqlite3. // Return non-zero if a transaction is active. func Xsqlite3BtreeIsInTrans(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:74798:20: */ - return (libc.Bool32((p != 0) && (int32((*Btree)(unsafe.Pointer(p)).FinTrans) == 2))) + return (libc.Bool32((p != 0) && (int32((*Btree)(unsafe.Pointer(p)).FinTrans) == TRANS_WRITE))) } // Run a checkpoint on the Btree passed as the first argument. @@ -52957,12 +52347,12 @@ func Xsqlite3BtreeIsInTrans(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:74798 // // Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART. func Xsqlite3BtreeCheckpoint(tls *libc.TLS, p uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) int32 { /* sqlite3.c:74812:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if p != 0 { var pBt uintptr = (*Btree)(unsafe.Pointer(p)).FpBt Xsqlite3BtreeEnter(tls, p) - if int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) != 0 { - rc = 6 + if int32((*BtShared)(unsafe.Pointer(pBt)).FinTransaction) != TRANS_NONE { + rc = SQLITE_LOCKED } else { rc = Xsqlite3PagerCheckpoint(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, (*Btree)(unsafe.Pointer(p)).Fdb, eMode, pnLog, pnCkpt) } @@ -52974,7 +52364,7 @@ func Xsqlite3BtreeCheckpoint(tls *libc.TLS, p uintptr, eMode int32, pnLog uintpt // Return non-zero if a read (or write) transaction is active. func Xsqlite3BtreeIsInReadTrans(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:74831:20: */ - return (libc.Bool32(int32((*Btree)(unsafe.Pointer(p)).FinTrans) != 0)) + return (libc.Bool32(int32((*Btree)(unsafe.Pointer(p)).FinTrans) != TRANS_NONE)) } func Xsqlite3BtreeIsInBackup(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:74837:20: */ @@ -53018,7 +52408,7 @@ func Xsqlite3BtreeSchemaLocked(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:74 var rc int32 Xsqlite3BtreeEnter(tls, p) - rc = querySharedCacheTableLock(tls, p, uint32(1), uint8(1)) + rc = querySharedCacheTableLock(tls, p, SCHEMA_ROOT, READ_LOCK) Xsqlite3BtreeLeave(tls, p) return rc @@ -53028,14 +52418,14 @@ func Xsqlite3BtreeSchemaLocked(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:74 // lock is a write lock if isWritelock is true or a read lock // if it is false. func Xsqlite3BtreeLockTable(tls *libc.TLS, p uintptr, iTab int32, isWriteLock U8) int32 { /* sqlite3.c:74896:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Btree)(unsafe.Pointer(p)).Fsharable != 0 { - var lockType U8 = (U8(1 + int32(isWriteLock))) + var lockType U8 = (U8(READ_LOCK + int32(isWriteLock))) Xsqlite3BtreeEnter(tls, p) rc = querySharedCacheTableLock(tls, p, uint32(iTab), lockType) - if rc == 0 { + if rc == SQLITE_OK { rc = setSharedCacheTableLock(tls, p, uint32(iTab), lockType) } Xsqlite3BtreeLeave(tls, p) @@ -53055,17 +52445,17 @@ func Xsqlite3BtreePutData(tls *libc.TLS, pCsr uintptr, offset U32, amt U32, z ui var rc int32 rc = func() int32 { - if int32((*BtCursor)(unsafe.Pointer(pCsr)).FeState) >= 3 { + if int32((*BtCursor)(unsafe.Pointer(pCsr)).FeState) >= CURSOR_REQUIRESEEK { return btreeRestoreCursorPosition(tls, pCsr) } - return 0 + return SQLITE_OK }() - if rc != 0 { + if rc != SQLITE_OK { return rc } - if int32((*BtCursor)(unsafe.Pointer(pCsr)).FeState) != 0 { - return 4 + if int32((*BtCursor)(unsafe.Pointer(pCsr)).FeState) != CURSOR_VALID { + return SQLITE_ABORT } // Save the positions of all other cursors open on this table. This is @@ -53083,8 +52473,8 @@ func Xsqlite3BtreePutData(tls *libc.TLS, pCsr uintptr, offset U32, amt U32, z ui // (c) the connection holds a write-lock on the table (if required), // (d) there are no conflicting read-locks, and // (e) the cursor points at a valid row of an intKey table. - if (int32((*BtCursor)(unsafe.Pointer(pCsr)).FcurFlags) & 0x01) == 0 { - return 8 + if (int32((*BtCursor)(unsafe.Pointer(pCsr)).FcurFlags) & BTCF_WriteFlag) == 0 { + return SQLITE_READONLY } return accessPayload(tls, pCsr, offset, amt, z, 1) @@ -53092,7 +52482,7 @@ func Xsqlite3BtreePutData(tls *libc.TLS, pCsr uintptr, offset U32, amt U32, z ui // Mark this cursor as an incremental blob cursor. func Xsqlite3BtreeIncrblobCursor(tls *libc.TLS, pCur uintptr) { /* sqlite3.c:74974:21: */ - *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((0x10)) + *(*U8)(unsafe.Pointer(pCur + 1 /* &.curFlags */)) |= U8((BTCF_Incrblob)) (*Btree)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBtree)).FhasIncrblobCur = U8(1) } @@ -53105,27 +52495,27 @@ func Xsqlite3BtreeSetVersion(tls *libc.TLS, pBtree uintptr, iVersion int32) int3 // If setting the version fields to 1, do not automatically open the // WAL connection, even if the version fields are currently set to 2. - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0020))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_NO_WAL))) if iVersion == 1 { - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((0x0020)) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) |= U16((BTS_NO_WAL)) } rc = Xsqlite3BtreeBeginTrans(tls, pBtree, 0, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { var aData uintptr = (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData - if (int32(*(*U8)(unsafe.Pointer(aData + uintptr(18)))) != int32(U8(iVersion))) || (int32(*(*U8)(unsafe.Pointer(aData + uintptr(19)))) != int32(U8(iVersion))) { + if (int32(*(*U8)(unsafe.Pointer(aData + 18))) != int32(U8(iVersion))) || (int32(*(*U8)(unsafe.Pointer(aData + 19))) != int32(U8(iVersion))) { rc = Xsqlite3BtreeBeginTrans(tls, pBtree, 2, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerWrite(tls, (*MemPage)(unsafe.Pointer((*BtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage) - if rc == 0 { - *(*U8)(unsafe.Pointer(aData + uintptr(18))) = U8(iVersion) - *(*U8)(unsafe.Pointer(aData + uintptr(19))) = U8(iVersion) + if rc == SQLITE_OK { + *(*U8)(unsafe.Pointer(aData + 18)) = U8(iVersion) + *(*U8)(unsafe.Pointer(aData + 19)) = U8(iVersion) } } } } - *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0020))) + *(*U16)(unsafe.Pointer(pBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_NO_WAL))) return rc } @@ -53137,12 +52527,12 @@ func Xsqlite3BtreeCursorHasHint(tls *libc.TLS, pCsr uintptr, mask uint32) int32 // Return true if the given Btree is read-only. func Xsqlite3BtreeIsReadonly(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:75027:20: */ - return (libc.Bool32((int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FbtsFlags) & 0x0001) != 0)) + return (libc.Bool32((int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer(p)).FpBt)).FbtsFlags) & BTS_READ_ONLY) != 0)) } // Return the size of the header added to each page by this module. func Xsqlite3HeaderSizeBtree(tls *libc.TLS) int32 { /* sqlite3.c:75034:20: */ - return (int32(((uint64(unsafe.Sizeof(MemPage{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + return (int32(((uint64(unsafe.Sizeof(MemPage{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) } // Return true if the Btree passed as the only argument is sharable. @@ -53207,7 +52597,7 @@ func findBtree(tls *libc.TLS, pErrorDb uintptr, pDb uintptr, zDb uintptr) uintpt (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).Fdb = pDb if Xsqlite3OpenTempDatabase(tls, bp+16 /* &sParse */) != 0 { Xsqlite3ErrorWithMsg(tls, pErrorDb, (*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).Frc, ts+824 /* "%s" */, libc.VaList(bp, (*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).FzErrMsg)) - rc = 1 + rc = SQLITE_ERROR } Xsqlite3DbFree(tls, pErrorDb, (*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).FzErrMsg) Xsqlite3ParserReset(tls, bp+16 /* &sParse */) @@ -53217,7 +52607,7 @@ func findBtree(tls *libc.TLS, pErrorDb uintptr, pDb uintptr, zDb uintptr) uintpt } if i < 0 { - Xsqlite3ErrorWithMsg(tls, pErrorDb, 1, ts+6487 /* "unknown database..." */, libc.VaList(bp+8, zDb)) + Xsqlite3ErrorWithMsg(tls, pErrorDb, SQLITE_ERROR, ts+6487 /* "unknown database..." */, libc.VaList(bp+8, zDb)) return uintptr(0) } @@ -53238,10 +52628,10 @@ func setDestPgsz(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:75169:12: */ // message in database handle db. func checkReadTransaction(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:75181:12: */ if Xsqlite3BtreeIsInReadTrans(tls, p) != 0 { - Xsqlite3ErrorWithMsg(tls, db, 1, ts+6507 /* "destination data..." */, 0) - return 1 + Xsqlite3ErrorWithMsg(tls, db, SQLITE_ERROR, ts+6507 /* "destination data..." */, 0) + return SQLITE_ERROR } - return 0 + return SQLITE_OK } // Create an sqlite3_backup process to copy the contents of zSrcDb from @@ -53265,7 +52655,7 @@ func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcD if pSrcDb == pDestDb { Xsqlite3ErrorWithMsg(tls, - pDestDb, 1, ts+6538 /* "source and desti..." */, 0) + pDestDb, SQLITE_ERROR, ts+6538 /* "source and desti..." */, 0) p = uintptr(0) } else { // Allocate space for a new sqlite3_backup object... @@ -53274,7 +52664,7 @@ func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcD // sqlite3_backup_finish(). p = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(Sqlite3_backup{}))) if !(p != 0) { - Xsqlite3Error(tls, pDestDb, 7) + Xsqlite3Error(tls, pDestDb, SQLITE_NOMEM) } } @@ -53288,7 +52678,7 @@ func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcD (*Sqlite3_backup)(unsafe.Pointer(p)).FisAttached = 0 if ((uintptr(0) == (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc) || (uintptr(0) == (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)) || - (checkReadTransaction(tls, pDestDb, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest) != 0) { + (checkReadTransaction(tls, pDestDb, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest) != SQLITE_OK) { // One (or both) of the named databases did not exist or an OOM // error was hit. Or there is a transaction open on the destination // database. The error has already been written into the pDestDb @@ -53311,7 +52701,7 @@ func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcD // considered fatal if encountered during a backup operation. All errors // are considered fatal except for SQLITE_BUSY and SQLITE_LOCKED. func isFatalError(tls *libc.TLS, rc int32) int32 { /* sqlite3.c:75274:12: */ - return (libc.Bool32(((rc != 0) && (rc != 5)) && (rc != 6))) + return (libc.Bool32(((rc != SQLITE_OK) && (rc != SQLITE_BUSY)) && (rc != SQLITE_LOCKED))) } // Parameter zSrcData points to a buffer containing the data for @@ -53331,26 +52721,26 @@ func backupOnePage(tls *libc.TLS, p uintptr, iSrcPg Pgno, zSrcData uintptr, bUpd return nDestPgsz }() var iEnd I64 = (I64(iSrcPg) * I64(nSrcPgsz)) - var rc int32 = 0 + var rc int32 = SQLITE_OK var iOff I64 // Catch the case where the destination is an in-memory database and the // page sizes of the source and destination differ. if (nSrcPgsz != nDestPgsz) && (Xsqlite3PagerIsMemdb(tls, pDestPager) != 0) { - rc = 8 + rc = SQLITE_READONLY } // This loop runs once for each destination page spanned by the source // page. For each iteration, variable iOff is set to the byte offset // of the destination page. - for iOff = (iEnd - I64(nSrcPgsz)); (rc == 0) && (iOff < iEnd); iOff = iOff + (I64(nDestPgsz)) { + for iOff = (iEnd - I64(nSrcPgsz)); (rc == SQLITE_OK) && (iOff < iEnd); iOff = iOff + (I64(nDestPgsz)) { *(*uintptr)(unsafe.Pointer(bp /* pDestPg */)) = uintptr(0) var iDest Pgno = ((Pgno(iOff / I64(nDestPgsz))) + Pgno(1)) if iDest == ((U32(Xsqlite3PendingByte) / ((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)).FpBt)).FpageSize)) + U32(1)) { continue } - if (0 == (libc.AssignInt32(&rc, Xsqlite3PagerGet(tls, pDestPager, iDest, bp /* &pDestPg */, 0)))) && - (0 == (libc.AssignInt32(&rc, Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp /* pDestPg */)))))) { + if (SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3PagerGet(tls, pDestPager, iDest, bp /* &pDestPg */, 0)))) && + (SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp /* pDestPg */)))))) { var zIn uintptr = (zSrcData + uintptr((iOff % I64(nSrcPgsz)))) var zDestData uintptr = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp /* pDestPg */))) var zOut uintptr = (zDestData + uintptr((iOff % I64(nDestPgsz)))) @@ -53362,9 +52752,9 @@ func backupOnePage(tls *libc.TLS, p uintptr, iSrcPg Pgno, zSrcData uintptr, bUpd // cached parse of the page). MemPage.isInit is marked // "MUST BE FIRST" for this purpose. libc.Xmemcpy(tls, zOut, zIn, uint64(nCopy)) - *(*U8)(unsafe.Pointer((Xsqlite3PagerGetExtra(tls, *(*uintptr)(unsafe.Pointer(bp /* pDestPg */)))) + uintptr(0))) = U8(0) + *(*U8)(unsafe.Pointer((Xsqlite3PagerGetExtra(tls, *(*uintptr)(unsafe.Pointer(bp /* pDestPg */)))))) = U8(0) if (iOff == int64(0)) && (bUpdate == 0) { - Xsqlite3Put4byte(tls, (zOut + uintptr(28)), Xsqlite3BtreeLastPage(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)) + Xsqlite3Put4byte(tls, (zOut + 28), Xsqlite3BtreeLastPage(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)) } } Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp /* pDestPg */))) @@ -53386,7 +52776,7 @@ func backupTruncateFile(tls *libc.TLS, pFile uintptr, iSize I64) int32 { /* sqli // var iCurrent I64 at bp, 8 var rc int32 = Xsqlite3OsFileSize(tls, pFile, bp /* &iCurrent */) - if (rc == 0) && (*(*I64)(unsafe.Pointer(bp /* iCurrent */)) > iSize) { + if (rc == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp /* iCurrent */)) > iSize) { rc = Xsqlite3OsTruncate(tls, pFile, iSize) } return rc @@ -53429,16 +52819,16 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli // If the source pager is currently in a write-transaction, return // SQLITE_BUSY immediately. - if ((*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0) && (int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FpBt)).FinTransaction) == 2) { - rc = 5 + if ((*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0) && (int32((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FpBt)).FinTransaction) == TRANS_WRITE) { + rc = SQLITE_BUSY } else { - rc = 0 + rc = SQLITE_OK } // If there is no open read-transaction on the source database, open // one now. If a transaction is opened here, then it will be closed // before this function exits. - if (rc == 0) && (0 == Xsqlite3BtreeIsInReadTrans(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)) { + if (rc == SQLITE_OK) && (0 == Xsqlite3BtreeIsInReadTrans(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)) { rc = Xsqlite3BtreeBeginTrans(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc, 0, uintptr(0)) bCloseTrans = 1 } @@ -53449,13 +52839,13 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli // is especially important on ZipVFS systems, as in that case it is // not possible to create a database file that uses one page size by // writing to it with another. - if (((*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked == 0) && (rc == 0)) && (setDestPgsz(tls, p) == 7) { - rc = 7 + if (((*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked == 0) && (rc == SQLITE_OK)) && (setDestPgsz(tls, p) == SQLITE_NOMEM) { + rc = SQLITE_NOMEM } // Lock the destination database, if it is not locked already. - if ((0 == rc) && ((*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked == 0)) && - (0 == (libc.AssignInt32(&rc, Xsqlite3BtreeBeginTrans(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 2, + if ((SQLITE_OK == rc) && ((*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked == 0)) && + (SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3BtreeBeginTrans(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 2, (p+16 /* &.iDestSchema */))))) { (*Sqlite3_backup)(unsafe.Pointer(p)).FbDestLocked = 1 } @@ -53465,8 +52855,8 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli pgszSrc = Xsqlite3BtreeGetPageSize(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc) pgszDest = Xsqlite3BtreeGetPageSize(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest) destMode = Xsqlite3PagerGetJournalMode(tls, Xsqlite3BtreePager(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)) - if ((0 == rc) && (destMode == 5)) && (pgszSrc != pgszDest) { - rc = 8 + if ((SQLITE_OK == rc) && (destMode == PAGER_JOURNALMODE_WAL)) && (pgszSrc != pgszDest) { + rc = SQLITE_READONLY } // Now that there is a read-lock on the source database, query the @@ -53478,19 +52868,19 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli if iSrcPg != ((U32(Xsqlite3PendingByte) / ((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpSrc)).FpBt)).FpageSize)) + U32(1)) { // var pSrcPg uintptr at bp, 8 // Source page object - rc = Xsqlite3PagerGet(tls, pSrcPager, iSrcPg, bp /* &pSrcPg */, 0x02) - if rc == 0 { + rc = Xsqlite3PagerGet(tls, pSrcPager, iSrcPg, bp /* &pSrcPg */, PAGER_GET_READONLY) + if rc == SQLITE_OK { rc = backupOnePage(tls, p, iSrcPg, Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp /* pSrcPg */))), 0) Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp /* pSrcPg */))) } } (*Sqlite3_backup)(unsafe.Pointer(p)).FiNext++ } - if rc == 0 { + if rc == SQLITE_OK { (*Sqlite3_backup)(unsafe.Pointer(p)).FnPagecount = Pgno(nSrcPage) (*Sqlite3_backup)(unsafe.Pointer(p)).FnRemaining = ((Pgno(nSrcPage + 1)) - (*Sqlite3_backup)(unsafe.Pointer(p)).FiNext) if (*Sqlite3_backup)(unsafe.Pointer(p)).FiNext > Pgno(nSrcPage) { - rc = 101 + rc = SQLITE_DONE } else if !((*Sqlite3_backup)(unsafe.Pointer(p)).FisAttached != 0) { attachBackupObject(tls, p) } @@ -53500,23 +52890,23 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli // is to make sure that the schema-version really does change in // the case where the source and destination databases have the // same schema version. - if rc == 101 { + if rc == SQLITE_DONE { if nSrcPage == 0 { rc = Xsqlite3BtreeNewDb(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest) nSrcPage = 1 } - if (rc == 0) || (rc == 101) { + if (rc == SQLITE_OK) || (rc == SQLITE_DONE) { rc = Xsqlite3BtreeUpdateMeta(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 1, ((*Sqlite3_backup)(unsafe.Pointer(p)).FiDestSchema + U32(1))) } - if rc == 0 { + if rc == SQLITE_OK { if (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb != 0 { Xsqlite3ResetAllSchemasOfConnection(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb) } - if destMode == 5 { + if destMode == PAGER_JOURNALMODE_WAL { rc = Xsqlite3BtreeSetVersion(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 2) } } - if rc == 0 { + if rc == SQLITE_OK { var nDestTruncate int32 // Set nDestTruncate to the final number of pages in the destination // database. The complication here is that the destination page @@ -53564,18 +52954,18 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli // occurs, the original database will be reconstructed from the // journal file. Xsqlite3PagerPagecount(tls, pDestPager, bp+8 /* &nDstPage */) - for iPg = Pgno(nDestTruncate); (rc == 0) && (iPg <= Pgno(*(*int32)(unsafe.Pointer(bp + 8 /* nDstPage */)))); iPg++ { + for iPg = Pgno(nDestTruncate); (rc == SQLITE_OK) && (iPg <= Pgno(*(*int32)(unsafe.Pointer(bp + 8 /* nDstPage */)))); iPg++ { if iPg != ((U32(Xsqlite3PendingByte) / ((*BtShared)(unsafe.Pointer((*Btree)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDest)).FpBt)).FpageSize)) + U32(1)) { // var pPg uintptr at bp+16, 8 rc = Xsqlite3PagerGet(tls, pDestPager, iPg, bp+16 /* &pPg */, 0) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */))) Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */))) } } } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerCommitPhaseOne(tls, pDestPager, uintptr(0), 1) } @@ -53586,22 +52976,22 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli } return iSize }() - for iOff = (I64(Xsqlite3PendingByte + pgszSrc)); (rc == 0) && (iOff < iEnd); iOff = iOff + (I64(pgszSrc)) { + for iOff = (I64(Xsqlite3PendingByte + pgszSrc)); (rc == SQLITE_OK) && (iOff < iEnd); iOff = iOff + (I64(pgszSrc)) { *(*uintptr)(unsafe.Pointer(bp + 24 /* pSrcPg */)) = uintptr(0) var iSrcPg Pgno = (Pgno((iOff / I64(pgszSrc)) + int64(1))) rc = Xsqlite3PagerGet(tls, pSrcPager, iSrcPg, bp+24 /* &pSrcPg */, 0) - if rc == 0 { + if rc == SQLITE_OK { var zData uintptr = Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pSrcPg */))) rc = Xsqlite3OsWrite(tls, pFile, zData, pgszSrc, iOff) } Xsqlite3PagerUnref(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pSrcPg */))) } - if rc == 0 { + if rc == SQLITE_OK { rc = backupTruncateFile(tls, pFile, iSize) } // Sync the database file to disk. - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerSync(tls, pDestPager, uintptr(0)) } } else { @@ -53610,9 +53000,9 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli } // Finish committing the transaction to the destination database. - if (0 == rc) && - (0 == (libc.AssignInt32(&rc, Xsqlite3BtreeCommitPhaseTwo(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 0)))) { - rc = 101 + if (SQLITE_OK == rc) && + (SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3BtreeCommitPhaseTwo(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 0)))) { + rc = SQLITE_DONE } } } @@ -53628,8 +53018,8 @@ func Xsqlite3_backup_step(tls *libc.TLS, p uintptr, nPage int32) int32 { /* sqli } - if rc == (10 | (int32(12) << 8)) { - rc = 7 + if rc == (SQLITE_IOERR | (int32(12) << 8)) { + rc = SQLITE_NOMEM } (*Sqlite3_backup)(unsafe.Pointer(p)).Frc = rc } @@ -53649,7 +53039,7 @@ func Xsqlite3_backup_finish(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:75631 // Enter the mutexes if p == uintptr(0) { - return 0 + return SQLITE_OK } pSrcDb = (*Sqlite3_backup)(unsafe.Pointer(p)).FpSrcDb Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(pSrcDb)).Fmutex) @@ -53673,11 +53063,11 @@ func Xsqlite3_backup_finish(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:75631 } // If a transaction is still open on the Btree, roll it back. - Xsqlite3BtreeRollback(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, 0, 0) + Xsqlite3BtreeRollback(tls, (*Sqlite3_backup)(unsafe.Pointer(p)).FpDest, SQLITE_OK, 0) // Set the error code of the destination database handle. - if (*Sqlite3_backup)(unsafe.Pointer(p)).Frc == 101 { - rc = 0 + if (*Sqlite3_backup)(unsafe.Pointer(p)).Frc == SQLITE_DONE { + rc = SQLITE_OK } else { rc = (*Sqlite3_backup)(unsafe.Pointer(p)).Frc } @@ -53734,7 +53124,7 @@ func backupUpdate(tls *libc.TLS, p uintptr, iPage Pgno, aData uintptr) { /* sqli rc = backupOnePage(tls, p, iPage, aData, 1) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Sqlite3_backup)(unsafe.Pointer(p)).FpDestDb)).Fmutex) - if rc != 0 { + if rc != SQLITE_OK { (*Sqlite3_backup)(unsafe.Pointer(p)).Frc = rc } } @@ -53788,11 +53178,11 @@ func Xsqlite3BtreeCopyFile(tls *libc.TLS, pTo uintptr, pFrom uintptr) int32 { /* goto __1 } *(*I64)(unsafe.Pointer(bp /* nByte */)) = (I64(Xsqlite3BtreeGetPageSize(tls, pFrom)) * I64(Xsqlite3BtreeLastPage(tls, pFrom))) - rc = Xsqlite3OsFileControl(tls, pFd, 11, bp /* &nByte */) - if !(rc == 12) { + rc = Xsqlite3OsFileControl(tls, pFd, SQLITE_FCNTL_OVERWRITE, bp /* &nByte */) + if !(rc == SQLITE_NOTFOUND) { goto __2 } - rc = 0 + rc = SQLITE_OK __2: ; if !(rc != 0) { @@ -53823,10 +53213,10 @@ __1: Xsqlite3_backup_step(tls, bp+8 /* &b */, 0x7FFFFFFF) rc = Xsqlite3_backup_finish(tls, bp+8 /* &b */) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __4 } - *(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(pTo)).FpBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0002))) + *(*U16)(unsafe.Pointer((*Btree)(unsafe.Pointer(pTo)).FpBt + 40 /* &.btsFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(BTS_PAGESIZE_FIXED))) goto __5 __4: Xsqlite3PagerClearCache(tls, Xsqlite3BtreePager(tls, (*Sqlite3_backup)(unsafe.Pointer(bp+8 /* &b */)).FpDest)) @@ -53870,18 +53260,18 @@ func vdbeMemRenderNum(tls *libc.TLS, sz int32, zBuf uintptr, p uintptr) { /* sql // var acc StrAccum at bp+16, 32 - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0004) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Int) != 0 { // Work-around for GCC bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96270 // var x I64 at bp+8, 8 - libc.Xmemcpy(tls, bp+8 /* &x */, (p /* &.u */), (uint64((int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0004) * 2))) + libc.Xmemcpy(tls, bp+8 /* &x */, (p /* &.u */), (uint64((int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Int) * 2))) Xsqlite3Int64ToText(tls, *(*I64)(unsafe.Pointer(bp + 8 /* x */)), zBuf) } else { Xsqlite3StrAccumInit(tls, bp+16 /* &acc */, uintptr(0), zBuf, sz, 0) Xsqlite3_str_appendf(tls, bp+16 /* &acc */, ts+6578, /* "%!.15g" */ libc.VaList(bp, func() float64 { - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0020) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_IntReal) != 0 { return float64(*(*I64)(unsafe.Pointer(p /* &.u */))) } return *(*float64)(unsafe.Pointer(p /* &.u */)) @@ -53905,8 +53295,8 @@ func vdbeMemRenderNum(tls *libc.TLS, sz int32, zBuf uintptr, p uintptr) { /* sql func Xsqlite3VdbeChangeEncoding(tls *libc.TLS, pMem uintptr, desiredEnc int32) int32 { /* sqlite3.c:76027:20: */ var rc int32 - if !((int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0002) != 0) || (int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == desiredEnc) { - return 0 + if !((int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Str) != 0) || (int32((*Mem)(unsafe.Pointer(pMem)).Fenc) == desiredEnc) { + return SQLITE_OK } // MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned, @@ -53948,7 +53338,7 @@ func Xsqlite3VdbeMemGrow(tls *libc.TLS, pMem uintptr, n int32, bPreserve int32) Xsqlite3VdbeMemSetNull(tls, pMem) (*Mem)(unsafe.Pointer(pMem)).Fz = uintptr(0) (*Mem)(unsafe.Pointer(pMem)).FszMalloc = 0 - return 7 + return SQLITE_NOMEM } else { (*Mem)(unsafe.Pointer(pMem)).FszMalloc = Xsqlite3DbMallocSize(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, (*Mem)(unsafe.Pointer(pMem)).FzMalloc) } @@ -53957,14 +53347,14 @@ func Xsqlite3VdbeMemGrow(tls *libc.TLS, pMem uintptr, n int32, bPreserve int32) libc.Xmemcpy(tls, (*Mem)(unsafe.Pointer(pMem)).FzMalloc, (*Mem)(unsafe.Pointer(pMem)).Fz, uint64((*Mem)(unsafe.Pointer(pMem)).Fn)) } - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0400) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Dyn) != 0 { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((pMem + 48 /* &.xDel */))))(tls, (*Mem)(unsafe.Pointer(pMem)).Fz) } (*Mem)(unsafe.Pointer(pMem)).Fz = (*Mem)(unsafe.Pointer(pMem)).FzMalloc - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((0x0400 | 0x1000) | 0x0800)))) - return 0 + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((MEM_Dyn | MEM_Ephem) | MEM_Static)))) + return SQLITE_OK } // Change the pMem->zMalloc allocation to be at least szNew bytes. @@ -53985,8 +53375,8 @@ func Xsqlite3VdbeMemClearAndResize(tls *libc.TLS, pMem uintptr, szNew int32) int } (*Mem)(unsafe.Pointer(pMem)).Fz = (*Mem)(unsafe.Pointer(pMem)).FzMalloc - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= U16((((0x0001 | 0x0004) | 0x0008) | 0x0020)) - return 0 + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= U16((((MEM_Null | MEM_Int) | MEM_Real) | MEM_IntReal)) + return SQLITE_OK } // It is already known that pMem contains an unterminated string. @@ -53998,13 +53388,13 @@ func Xsqlite3VdbeMemClearAndResize(tls *libc.TLS, pMem uintptr, szNew int32) int // is an odd number of bytes. func vdbeMemAddTerminator(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:76143:28: */ if Xsqlite3VdbeMemGrow(tls, pMem, ((*Mem)(unsafe.Pointer(pMem)).Fn+3), 1) != 0 { - return 7 + return SQLITE_NOMEM } *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn))) = int8(0) *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(((*Mem)(unsafe.Pointer(pMem)).Fn + 1)))) = int8(0) *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(((*Mem)(unsafe.Pointer(pMem)).Fn + 2)))) = int8(0) - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16((0x0200)) - return 0 + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16((MEM_Term)) + return SQLITE_OK } // Change pMem so that its MEM_Str or MEM_Blob value is stored in @@ -54013,14 +53403,14 @@ func vdbeMemAddTerminator(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:7614 // Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails. func Xsqlite3VdbeMemMakeWriteable(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:76160:20: */ - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0002 | 0x0010)) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Str | MEM_Blob)) != 0 { if func() int32 { - if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pMem) } return 0 }() != 0 { - return 7 + return SQLITE_NOMEM } if ((*Mem)(unsafe.Pointer(pMem)).FszMalloc == 0) || ((*Mem)(unsafe.Pointer(pMem)).Fz != (*Mem)(unsafe.Pointer(pMem)).FzMalloc) { var rc int32 = vdbeMemAddTerminator(tls, pMem) @@ -54029,9 +53419,9 @@ func Xsqlite3VdbeMemMakeWriteable(tls *libc.TLS, pMem uintptr) int32 { /* sqlite } } } - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x1000))) + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Ephem))) - return 0 + return SQLITE_OK } // If the given Mem* has a zero-filled tail, turn it into an ordinary @@ -54042,26 +53432,26 @@ func Xsqlite3VdbeMemExpandBlob(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c // Set nByte to the number of bytes required to store the expanded blob. nByte = ((*Mem)(unsafe.Pointer(pMem)).Fn + *(*int32)(unsafe.Pointer(pMem /* &.u */))) if nByte <= 0 { - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0010) == 0 { - return 0 + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Blob) == 0 { + return SQLITE_OK } nByte = 1 } if Xsqlite3VdbeMemGrow(tls, pMem, nByte, 1) != 0 { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, ((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr((*Mem)(unsafe.Pointer(pMem)).Fn)), 0, uint64(*(*int32)(unsafe.Pointer(pMem /* &.u */)))) *(*int32)(unsafe.Pointer(pMem + 12 /* &.n */)) += (*(*int32)(unsafe.Pointer(pMem /* &.u */))) - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32((0x4000 | 0x0200)))) - return 0 + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32((MEM_Zero | MEM_Term)))) + return SQLITE_OK } // Make sure the given Mem is \u0000 terminated. func Xsqlite3VdbeMemNulTerminate(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:76211:20: */ - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0200 | 0x0002)) != 0x0002 { - return 0 // Nothing to do + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Term | MEM_Str)) != MEM_Str { + return SQLITE_OK // Nothing to do } else { return vdbeMemAddTerminator(tls, pMem) } @@ -54085,19 +53475,19 @@ func Xsqlite3VdbeMemStringify(tls *libc.TLS, pMem uintptr, enc U8, bForce U8) in if Xsqlite3VdbeMemClearAndResize(tls, pMem, nByte) != 0 { (*Mem)(unsafe.Pointer(pMem)).Fenc = U8(0) - return 7 + return SQLITE_NOMEM } vdbeMemRenderNum(tls, nByte, (*Mem)(unsafe.Pointer(pMem)).Fz, pMem) (*Mem)(unsafe.Pointer(pMem)).Fn = (int32(libc.Xstrlen(tls, (*Mem)(unsafe.Pointer(pMem)).Fz) & uint64(0x3fffffff))) - (*Mem)(unsafe.Pointer(pMem)).Fenc = U8(1) - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16((0x0002 | 0x0200)) + (*Mem)(unsafe.Pointer(pMem)).Fenc = SQLITE_UTF8 + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16((MEM_Str | MEM_Term)) if bForce != 0 { - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((0x0004 | 0x0008) | 0x0020)))) + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((MEM_Int | MEM_Real) | MEM_IntReal)))) } Xsqlite3VdbeChangeEncoding(tls, pMem, int32(enc)) - return 0 + return SQLITE_OK } // Memory cell pMem contains the context of an aggregate function. @@ -54116,7 +53506,7 @@ func Xsqlite3VdbeMemFinalize(tls *libc.TLS, pMem uintptr, pFunc uintptr) int32 { libc.Xmemset(tls, bp /* &ctx */, 0, uint64(unsafe.Sizeof(Sqlite3_context{}))) libc.Xmemset(tls, bp+56 /* &t */, 0, uint64(unsafe.Sizeof(Mem{}))) - (*Mem)(unsafe.Pointer(bp + 56 /* &t */)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(bp + 56 /* &t */)).Fflags = MEM_Null (*Mem)(unsafe.Pointer(bp + 56 /* &t */)).Fdb = (*Mem)(unsafe.Pointer(pMem)).Fdb (*Sqlite3_context)(unsafe.Pointer(bp /* &ctx */)).FpOut = bp + 56 /* &t */ (*Sqlite3_context)(unsafe.Pointer(bp /* &ctx */)).FpMem = pMem @@ -54160,15 +53550,15 @@ func Xsqlite3VdbeMemAggValue(tls *libc.TLS, pAccum uintptr, pOut uintptr, pFunc // entry point for releasing Mem resources. func vdbeMemClearExternAndSetNull(tls *libc.TLS, p uintptr) { /* sqlite3.c:76325:29: */ - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x2000) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Agg) != 0 { Xsqlite3VdbeMemFinalize(tls, p, *(*uintptr)(unsafe.Pointer(p /* &.u */))) } - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0400) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Dyn) != 0 { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((p + 48 /* &.xDel */))))(tls, (*Mem)(unsafe.Pointer(p)).Fz) } - (*Mem)(unsafe.Pointer(p)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(p)).Fflags = MEM_Null } // Release memory held by the Mem p, both external memory cleared @@ -54178,7 +53568,7 @@ func vdbeMemClearExternAndSetNull(tls *libc.TLS, p uintptr) { /* sqlite3.c:76325 // the unusual case where there really is memory in p that needs // to be freed. func vdbeMemClear(tls *libc.TLS, p uintptr) { /* sqlite3.c:76348:29: */ - if (int32((*Mem)(unsafe.Pointer((p))).Fflags) & (0x2000 | 0x0400)) != 0 { + if (int32((*Mem)(unsafe.Pointer((p))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { vdbeMemClearExternAndSetNull(tls, p) } if (*Mem)(unsafe.Pointer(p)).FszMalloc != 0 { @@ -54198,7 +53588,7 @@ func vdbeMemClear(tls *libc.TLS, p uintptr) { /* sqlite3.c:76348:29: */ // prior to inserting new content into the Mem. func Xsqlite3VdbeMemRelease(tls *libc.TLS, p uintptr) { /* sqlite3.c:76369:21: */ - if ((int32((*Mem)(unsafe.Pointer((p))).Fflags) & (0x2000 | 0x0400)) != 0) || ((*Mem)(unsafe.Pointer(p)).FszMalloc != 0) { + if ((int32((*Mem)(unsafe.Pointer((p))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0) || ((*Mem)(unsafe.Pointer(p)).FszMalloc != 0) { vdbeMemClear(tls, p) } } @@ -54243,12 +53633,12 @@ func Xsqlite3VdbeIntValue(tls *libc.TLS, pMem uintptr) I64 { /* sqlite3.c:76422: var flags int32 flags = int32((*Mem)(unsafe.Pointer(pMem)).Fflags) - if (flags & (0x0004 | 0x0020)) != 0 { + if (flags & (MEM_Int | MEM_IntReal)) != 0 { return *(*I64)(unsafe.Pointer(pMem /* &.u */)) - } else if (flags & 0x0008) != 0 { + } else if (flags & MEM_Real) != 0 { return doubleToInt64(tls, *(*float64)(unsafe.Pointer(pMem /* &.u */))) - } else if ((flags & (0x0002 | 0x0010)) != 0) && ((*Mem)(unsafe.Pointer(pMem)).Fz != uintptr(0)) { + } else if ((flags & (MEM_Str | MEM_Blob)) != 0) && ((*Mem)(unsafe.Pointer(pMem)).Fz != uintptr(0)) { return memIntValue(tls, pMem) } else { return int64(0) @@ -54272,12 +53662,12 @@ func memRealValue(tls *libc.TLS, pMem uintptr) float64 { /* sqlite3.c:76445:31: func Xsqlite3VdbeRealValue(tls *libc.TLS, pMem uintptr) float64 { /* sqlite3.c:76451:23: */ - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0008) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Real) != 0 { return *(*float64)(unsafe.Pointer(pMem /* &.u */)) - } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0004 | 0x0020)) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Int | MEM_IntReal)) != 0 { return float64(*(*I64)(unsafe.Pointer(pMem /* &.u */))) - } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0002 | 0x0010)) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Str | MEM_Blob)) != 0 { return memRealValue(tls, pMem) } else { // (double)0 In case of SQLITE_OMIT_FLOATING_POINT... @@ -54290,10 +53680,10 @@ func Xsqlite3VdbeRealValue(tls *libc.TLS, pMem uintptr) float64 { /* sqlite3.c:7 // Return the value ifNull if pMem is NULL. func Xsqlite3VdbeBooleanValue(tls *libc.TLS, pMem uintptr, ifNull int32) int32 { /* sqlite3.c:76471:20: */ - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0004 | 0x0020)) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Int | MEM_IntReal)) != 0 { return (libc.Bool32(*(*I64)(unsafe.Pointer(pMem /* &.u */)) != int64(0))) } - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0001) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Null) != 0 { return ifNull } return (libc.Bool32(Xsqlite3VdbeRealValue(tls, pMem) != 0.0)) @@ -54317,7 +53707,7 @@ func Xsqlite3VdbeIntegerAffinity(tls *libc.TLS, pMem uintptr) { /* sqlite3.c:764 // values to wrap around. if ((*(*float64)(unsafe.Pointer(pMem /* &.u */)) == float64(ix)) && (ix > ((int64(-1)) - (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))))) && (ix < (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))) { *(*I64)(unsafe.Pointer(pMem /* &.u */)) = ix - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) } } @@ -54325,8 +53715,8 @@ func Xsqlite3VdbeIntegerAffinity(tls *libc.TLS, pMem uintptr) { /* sqlite3.c:764 func Xsqlite3VdbeMemIntegerify(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:76510:20: */ *(*I64)(unsafe.Pointer(pMem /* &.u */)) = Xsqlite3VdbeIntValue(tls, pMem) - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) - return 0 + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) + return SQLITE_OK } // Convert pMem so that it is of type MEM_Real. @@ -54334,8 +53724,8 @@ func Xsqlite3VdbeMemIntegerify(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c func Xsqlite3VdbeMemRealify(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:76524:20: */ *(*float64)(unsafe.Pointer(pMem /* &.u */)) = Xsqlite3VdbeRealValue(tls, pMem) - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0008)) - return 0 + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Real)) + return SQLITE_OK } // Compare a floating point value to an integer. Return true if the two @@ -54367,7 +53757,7 @@ func Xsqlite3VdbeMemNumerify(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:7 bp := tls.Alloc(8) defer tls.Free(8) - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (((0x0004 | 0x0008) | 0x0020) | 0x0001)) == 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (((MEM_Int | MEM_Real) | MEM_IntReal) | MEM_Null)) == 0 { var rc int32 // var ix Sqlite3_int64 at bp, 8 @@ -54375,14 +53765,14 @@ func Xsqlite3VdbeMemNumerify(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:7 if (((rc == 0) || (rc == 1)) && (Xsqlite3Atoi64(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, bp /* &ix */, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc) <= 1)) || (Xsqlite3RealSameAsInt(tls, *(*float64)(unsafe.Pointer(pMem /* &.u */)), libc.AssignPtrInt64(bp /* ix */, I64(*(*float64)(unsafe.Pointer(pMem /* &.u */))))) != 0) { *(*I64)(unsafe.Pointer(pMem /* &.u */)) = *(*Sqlite3_int64)(unsafe.Pointer(bp /* ix */)) - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) } else { - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0008)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Real)) } } - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((0x0002 | 0x0010) | 0x4000)))) - return 0 + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((MEM_Str | MEM_Blob) | MEM_Zero)))) + return SQLITE_OK } // Cast the datatype of the value in pMem according to the affinity @@ -54391,37 +53781,37 @@ func Xsqlite3VdbeMemNumerify(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c:7 // affinity even if that results in loss of data. This routine is // used (for example) to implement the SQL "cast()" operator. func Xsqlite3VdbeMemCast(tls *libc.TLS, pMem uintptr, aff U8, encoding U8) int32 { /* sqlite3.c:76589:20: */ - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0001) != 0 { - return 0 + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Null) != 0 { + return SQLITE_OK } switch int32(aff) { - case 0x41: + case SQLITE_AFF_BLOB: { // Really a cast to BLOB - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0010) == 0 { - Xsqlite3ValueApplyAffinity(tls, pMem, uint8(0x42), encoding) + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Blob) == 0 { + Xsqlite3ValueApplyAffinity(tls, pMem, SQLITE_AFF_TEXT, encoding) - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0002) != 0 { - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0010)) + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Str) != 0 { + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Blob)) } } else { - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32((0xc1bf & ^libc.Int32(0x0010))))) + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32((MEM_TypeMask & libc.CplInt32(MEM_Blob))))) } break } - case 0x43: + case SQLITE_AFF_NUMERIC: { Xsqlite3VdbeMemNumerify(tls, pMem) break } - case 0x44: + case SQLITE_AFF_INTEGER: { Xsqlite3VdbeMemIntegerify(tls, pMem) break } - case 0x45: + case SQLITE_AFF_REAL: { Xsqlite3VdbeMemRealify(tls, pMem) break @@ -54430,15 +53820,15 @@ func Xsqlite3VdbeMemCast(tls *libc.TLS, pMem uintptr, aff U8, encoding U8) int32 default: { - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16(((int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0010) >> 3)) - Xsqlite3ValueApplyAffinity(tls, pMem, uint8(0x42), encoding) + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) |= U16(((int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Blob) >> 3)) + Xsqlite3ValueApplyAffinity(tls, pMem, SQLITE_AFF_TEXT, encoding) - *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((((0x0004 | 0x0008) | 0x0020) | 0x0010) | 0x4000)))) + *(*U16)(unsafe.Pointer(pMem + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((((MEM_Int | MEM_Real) | MEM_IntReal) | MEM_Blob) | MEM_Zero)))) return Xsqlite3VdbeChangeEncoding(tls, pMem, int32(encoding)) } } - return 0 + return SQLITE_OK } // Initialize bulk memory to be a consistent Mem object. @@ -54462,10 +53852,10 @@ func Xsqlite3VdbeMemInit(tls *libc.TLS, pMem uintptr, db uintptr, flags U16) { / // // Use sqlite3VdbeMemRelease() to complete erase the Mem prior to abandoning it. func Xsqlite3VdbeMemSetNull(tls *libc.TLS, pMem uintptr) { /* sqlite3.c:76652:21: */ - if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & (0x2000 | 0x0400)) != 0 { + if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { vdbeMemClearExternAndSetNull(tls, pMem) } else { - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Null } } @@ -54477,13 +53867,13 @@ func Xsqlite3ValueSetNull(tls *libc.TLS, p uintptr) { /* sqlite3.c:76659:21: */ // n containing all zeros. func Xsqlite3VdbeMemSetZeroBlob(tls *libc.TLS, pMem uintptr, n int32) { /* sqlite3.c:76667:21: */ Xsqlite3VdbeMemRelease(tls, pMem) - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(0x0010 | 0x4000)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(MEM_Blob | MEM_Zero)) (*Mem)(unsafe.Pointer(pMem)).Fn = 0 if n < 0 { n = 0 } *(*int32)(unsafe.Pointer(pMem /* &.u */)) = n - (*Mem)(unsafe.Pointer(pMem)).Fenc = U8(1) + (*Mem)(unsafe.Pointer(pMem)).Fenc = SQLITE_UTF8 (*Mem)(unsafe.Pointer(pMem)).Fz = uintptr(0) } @@ -54493,17 +53883,17 @@ func Xsqlite3VdbeMemSetZeroBlob(tls *libc.TLS, pMem uintptr, n int32) { /* sqlit func vdbeReleaseAndSetInt64(tls *libc.TLS, pMem uintptr, val I64) { /* sqlite3.c:76682:29: */ Xsqlite3VdbeMemSetNull(tls, pMem) *(*I64)(unsafe.Pointer(pMem /* &.u */)) = val - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int } // Delete any previous value and set the value stored in *pMem to val, // manifest type INTEGER. func Xsqlite3VdbeMemSetInt64(tls *libc.TLS, pMem uintptr, val I64) { /* sqlite3.c:76692:21: */ - if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & (0x2000 | 0x0400)) != 0 { + if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { vdbeReleaseAndSetInt64(tls, pMem, val) } else { *(*I64)(unsafe.Pointer(pMem /* &.u */)) = val - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int } } @@ -54523,7 +53913,7 @@ func Xsqlite3VdbeMemSetPointer(tls *libc.TLS, pMem uintptr, pPtr uintptr, zPType return ts + 800 /* "" */ }() (*Mem)(unsafe.Pointer(pMem)).Fz = pPtr - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(((0x0001 | 0x0400) | 0x8000) | 0x0200)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(((MEM_Null | MEM_Dyn) | MEM_Subtype) | MEM_Term)) (*Mem)(unsafe.Pointer(pMem)).FeSubtype = U8('p') (*Mem)(unsafe.Pointer(pMem)).FxDel = func() uintptr { if xDestructor != 0 { @@ -54539,7 +53929,7 @@ func Xsqlite3VdbeMemSetDouble(tls *libc.TLS, pMem uintptr, val float64) { /* sql Xsqlite3VdbeMemSetNull(tls, pMem) if !(Xsqlite3IsNaN(tls, val) != 0) { *(*float64)(unsafe.Pointer(pMem /* &.u */)) = val - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0008) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Real } } @@ -54555,24 +53945,24 @@ func Xsqlite3VdbeMemSetRowSet(tls *libc.TLS, pMem uintptr) int32 { /* sqlite3.c: Xsqlite3VdbeMemRelease(tls, pMem) p = Xsqlite3RowSetInit(tls, db) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Mem)(unsafe.Pointer(pMem)).Fz = p - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(0x0010 | 0x0400)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(MEM_Blob | MEM_Dyn)) (*Mem)(unsafe.Pointer(pMem)).FxDel = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3RowSetDelete})) - return 0 + return SQLITE_OK } // Return true if the Mem object contains a TEXT or BLOB that is // too large - whose size exceeds SQLITE_MAX_LENGTH. func Xsqlite3VdbeMemTooBig(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:76772:20: */ - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & (0x0002 | 0x0010)) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & (MEM_Str | MEM_Blob)) != 0 { var n int32 = (*Mem)(unsafe.Pointer(p)).Fn - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Zero) != 0 { n = n + (*(*int32)(unsafe.Pointer(p /* &.u */))) } - return (libc.Bool32(n > *(*int32)(unsafe.Pointer(((*Mem)(unsafe.Pointer(p)).Fdb + 124 /* &.aLimit */) + uintptr(0)*4)))) + return (libc.Bool32(n > *(*int32)(unsafe.Pointer(((*Mem)(unsafe.Pointer(p)).Fdb + 124 /* &.aLimit */))))) } return 0 } @@ -54589,13 +53979,13 @@ func vdbeClrCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr, eType int32) { /* sq func Xsqlite3VdbeMemShallowCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr, srcType int32) { /* sqlite3.c:76833:21: */ - if (int32((*Mem)(unsafe.Pointer((pTo))).Fflags) & (0x2000 | 0x0400)) != 0 { + if (int32((*Mem)(unsafe.Pointer((pTo))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { vdbeClrCopy(tls, pTo, pFrom, srcType) return } libc.Xmemcpy(tls, pTo, pFrom, uint64((uintptr(0) + 24 /* &.zMalloc */))) - if (int32((*Mem)(unsafe.Pointer(pFrom)).Fflags) & 0x0800) == 0 { - *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((0x0400 | 0x0800) | 0x1000)))) + if (int32((*Mem)(unsafe.Pointer(pFrom)).Fflags) & MEM_Static) == 0 { + *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((MEM_Dyn | MEM_Static) | MEM_Ephem)))) *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) |= U16((srcType)) } @@ -54604,16 +53994,16 @@ func Xsqlite3VdbeMemShallowCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr, srcTy // Make a full copy of pFrom into pTo. Prior contents of pTo are // freed before the copy is made. func Xsqlite3VdbeMemCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr) int32 { /* sqlite3.c:76849:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK - if (int32((*Mem)(unsafe.Pointer((pTo))).Fflags) & (0x2000 | 0x0400)) != 0 { + if (int32((*Mem)(unsafe.Pointer((pTo))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { vdbeMemClearExternAndSetNull(tls, pTo) } libc.Xmemcpy(tls, pTo, pFrom, uint64((uintptr(0) + 24 /* &.zMalloc */))) - *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0400))) - if (int32((*Mem)(unsafe.Pointer(pTo)).Fflags) & (0x0002 | 0x0010)) != 0 { - if 0 == (int32((*Mem)(unsafe.Pointer(pFrom)).Fflags) & 0x0800) { - *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) |= U16((0x1000)) + *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Dyn))) + if (int32((*Mem)(unsafe.Pointer(pTo)).Fflags) & (MEM_Str | MEM_Blob)) != 0 { + if 0 == (int32((*Mem)(unsafe.Pointer(pFrom)).Fflags) & MEM_Static) { + *(*U16)(unsafe.Pointer(pTo + 8 /* &.flags */)) |= U16((MEM_Ephem)) rc = Xsqlite3VdbeMemMakeWriteable(tls, pTo) } } @@ -54629,7 +54019,7 @@ func Xsqlite3VdbeMemMove(tls *libc.TLS, pTo uintptr, pFrom uintptr) { /* sqlite3 Xsqlite3VdbeMemRelease(tls, pTo) libc.Xmemcpy(tls, pTo, pFrom, uint64(unsafe.Sizeof(Mem{}))) - (*Mem)(unsafe.Pointer(pFrom)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pFrom)).Fflags = MEM_Null (*Mem)(unsafe.Pointer(pFrom)).FszMalloc = 0 } @@ -54654,29 +54044,29 @@ func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n int32, enc // If z is a NULL pointer, set pMem to contain an SQL NULL. if !(z != 0) { Xsqlite3VdbeMemSetNull(tls, pMem) - return 0 + return SQLITE_OK } if (*Mem)(unsafe.Pointer(pMem)).Fdb != 0 { - iLimit = *(*int32)(unsafe.Pointer(((*Mem)(unsafe.Pointer(pMem)).Fdb + 124 /* &.aLimit */) + uintptr(0)*4)) + iLimit = *(*int32)(unsafe.Pointer(((*Mem)(unsafe.Pointer(pMem)).Fdb + 124 /* &.aLimit */))) } else { - iLimit = 1000000000 + iLimit = SQLITE_MAX_LENGTH } flags = func() uint16 { if int32(enc) == 0 { - return uint16(0x0010) + return MEM_Blob } - return uint16(0x0002) + return MEM_Str }() if nByte < 0 { - if int32(enc) == 1 { + if int32(enc) == SQLITE_UTF8 { nByte = (0x7fffffff & int32(libc.Xstrlen(tls, z))) } else { for nByte = 0; (nByte <= iLimit) && ((int32(*(*int8)(unsafe.Pointer(z + uintptr(nByte)))) | int32(*(*int8)(unsafe.Pointer(z + uintptr((nByte + 1)))))) != 0); nByte = nByte + (2) { } } - flags = U16(int32(flags) | (0x0200)) + flags = U16(int32(flags) | (MEM_Term)) } // The following block sets the new values of Mem.z and Mem.xDel. It @@ -54684,16 +54074,16 @@ func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n int32, enc // management (one of MEM_Dyn or MEM_Static). if xDel == (libc.UintptrFromInt32(-1)) { var nAlloc U32 = U32(nByte) - if (int32(flags) & 0x0200) != 0 { + if (int32(flags) & MEM_Term) != 0 { nAlloc = nAlloc + (func() uint32 { - if int32(enc) == 1 { + if int32(enc) == SQLITE_UTF8 { return uint32(1) } return uint32(2) }()) } if nByte > iLimit { - return Xsqlite3ErrorToParser(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, 18) + return Xsqlite3ErrorToParser(tls, (*Mem)(unsafe.Pointer(pMem)).Fdb, SQLITE_TOOBIG) } if Xsqlite3VdbeMemClearAndResize(tls, pMem, func() int32 { @@ -54702,7 +54092,7 @@ func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n int32, enc } return 32 }()) != 0 { - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, z, uint64(nAlloc)) } else { @@ -54715,9 +54105,9 @@ func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n int32, enc (*Mem)(unsafe.Pointer(pMem)).FxDel = xDel flags = U16(int32(flags) | (func() int32 { if xDel == (uintptr(0)) { - return 0x0800 + return MEM_Static } - return 0x0400 + return MEM_Dyn }())) } } @@ -54731,15 +54121,15 @@ func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n int32, enc (*Mem)(unsafe.Pointer(pMem)).Fenc = (*Sqlite3)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fdb)).Fenc } - if (int32(enc) > 1) && (Xsqlite3VdbeMemHandleBom(tls, pMem) != 0) { - return 7 + if (int32(enc) > SQLITE_UTF8) && (Xsqlite3VdbeMemHandleBom(tls, pMem) != 0) { + return SQLITE_NOMEM } if nByte > iLimit { - return 18 + return SQLITE_TOOBIG } - return 0 + return SQLITE_OK } // Move data out of a btree key or data field and into a Mem structure. @@ -54757,15 +54147,15 @@ func Xsqlite3VdbeMemSetStr(tls *libc.TLS, pMem uintptr, z uintptr, n int32, enc // to read from the disk) then the pMem is left in an inconsistent state. func Xsqlite3VdbeMemFromBtree(tls *libc.TLS, pCur uintptr, offset U32, amt U32, pMem uintptr) int32 { /* sqlite3.c:77006:20: */ var rc int32 - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Null if Xsqlite3BtreeMaxRecordSize(tls, pCur) < (Sqlite3_int64(offset + amt)) { return Xsqlite3CorruptError(tls, 77015) } - if 0 == (libc.AssignInt32(&rc, Xsqlite3VdbeMemClearAndResize(tls, pMem, (int32(amt+U32(1)))))) { + if SQLITE_OK == (libc.AssignInt32(&rc, Xsqlite3VdbeMemClearAndResize(tls, pMem, (int32(amt+U32(1)))))) { rc = Xsqlite3BtreePayload(tls, pCur, offset, amt, (*Mem)(unsafe.Pointer(pMem)).Fz) - if rc == 0 { + if rc == SQLITE_OK { *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(amt))) = int8(0) // Overrun area used when reading malformed records - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0010) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Blob (*Mem)(unsafe.Pointer(pMem)).Fn = int32(amt) } else { Xsqlite3VdbeMemRelease(tls, pMem) @@ -54779,7 +54169,7 @@ func Xsqlite3VdbeMemFromBtreeZeroOffset(tls *libc.TLS, pCur uintptr, amt U32, pM defer tls.Free(4) *(*U32)(unsafe.Pointer(bp /* available */)) = U32(0) // Number of bytes available on the local btree page - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code // Note: the calls to BtreeKeyFetch() and DataFetch() below assert() // that both the BtShared and database handle mutexes are held. @@ -54787,7 +54177,7 @@ func Xsqlite3VdbeMemFromBtreeZeroOffset(tls *libc.TLS, pCur uintptr, amt U32, pM (*Mem)(unsafe.Pointer(pMem)).Fz = Xsqlite3BtreePayloadFetch(tls, pCur, bp /* &available */) if amt <= *(*U32)(unsafe.Pointer(bp /* available */)) { - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(0x0010 | 0x1000)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(MEM_Blob | MEM_Ephem)) (*Mem)(unsafe.Pointer(pMem)).Fn = int32(amt) } else { rc = Xsqlite3VdbeMemFromBtree(tls, pCur, uint32(0), amt, pMem) @@ -54801,22 +54191,22 @@ func Xsqlite3VdbeMemFromBtreeZeroOffset(tls *libc.TLS, pCur uintptr, amt U32, pM // to a zero-terminated version of that string. func valueToText(tls *libc.TLS, pVal uintptr, enc U8) uintptr { /* sqlite3.c:77061:35: */ - if (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & (0x0010 | 0x0002)) != 0 { + if (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & (MEM_Blob | MEM_Str)) != 0 { if func() int32 { - if (int32((*Sqlite3_value)(unsafe.Pointer((pVal))).Fflags) & 0x4000) != 0 { + if (int32((*Sqlite3_value)(unsafe.Pointer((pVal))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pVal) } return 0 }() != 0 { return uintptr(0) } - *(*U16)(unsafe.Pointer(pVal + 8 /* &.flags */)) |= U16((0x0002)) - if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) != (int32(enc) & ^libc.Int32(8)) { - Xsqlite3VdbeChangeEncoding(tls, pVal, (int32(enc) & ^libc.Int32(8))) + *(*U16)(unsafe.Pointer(pVal + 8 /* &.flags */)) |= U16((MEM_Str)) + if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) != (int32(enc) & libc.CplInt32(SQLITE_UTF16_ALIGNED)) { + Xsqlite3VdbeChangeEncoding(tls, pVal, (int32(enc) & libc.CplInt32(SQLITE_UTF16_ALIGNED))) } - if ((int32(enc) & 8) != 0) && (1 == (1 & (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fz)))) { + if ((int32(enc) & SQLITE_UTF16_ALIGNED) != 0) && (1 == (1 & (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fz)))) { - if Xsqlite3VdbeMemMakeWriteable(tls, pVal) != 0 { + if Xsqlite3VdbeMemMakeWriteable(tls, pVal) != SQLITE_OK { return uintptr(0) } } @@ -54826,7 +54216,7 @@ func valueToText(tls *libc.TLS, pVal uintptr, enc U8) uintptr { /* sqlite3.c:770 } - if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == (int32(enc) & ^libc.Int32(8)) { + if int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == (int32(enc) & libc.CplInt32(SQLITE_UTF16_ALIGNED)) { return (*Sqlite3_value)(unsafe.Pointer(pVal)).Fz } else { @@ -54849,11 +54239,11 @@ func Xsqlite3ValueText(tls *libc.TLS, pVal uintptr, enc U8) uintptr { /* sqlite3 return uintptr(0) } - if ((int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & (0x0002 | 0x0200)) == (0x0002 | 0x0200)) && (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == int32(enc)) { + if ((int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & (MEM_Str | MEM_Term)) == (MEM_Str | MEM_Term)) && (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == int32(enc)) { return (*Sqlite3_value)(unsafe.Pointer(pVal)).Fz } - if (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & 0x0001) != 0 { + if (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & MEM_Null) != 0 { return uintptr(0) } return valueToText(tls, pVal, enc) @@ -54863,7 +54253,7 @@ func Xsqlite3ValueText(tls *libc.TLS, pVal uintptr, enc U8) uintptr { /* sqlite3 func Xsqlite3ValueNew(tls *libc.TLS, db uintptr) uintptr { /* sqlite3.c:77122:30: */ var p uintptr = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Mem{}))) if p != 0 { - (*Mem)(unsafe.Pointer(p)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(p)).Fflags = MEM_Null (*Mem)(unsafe.Pointer(p)).Fdb = db } return p @@ -54890,7 +54280,7 @@ type ValueNewStat4Ctx = struct { // an sqlite3_value within the UnpackedRecord.a[] array. func valueNew(tls *libc.TLS, db uintptr, p uintptr) uintptr { /* sqlite3.c:77153:22: */ if p != 0 { - var pRec uintptr = *(*uintptr)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FppRec + uintptr(0)*8)) + var pRec uintptr = *(*uintptr)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FppRec)) if pRec == uintptr(0) { var pIdx uintptr = (*ValueNewStat4Ctx)(unsafe.Pointer(p)).FpIdx // Index being probed @@ -54898,15 +54288,15 @@ func valueNew(tls *libc.TLS, db uintptr, p uintptr) uintptr { /* sqlite3.c:77153 var i int32 // Counter variable var nCol int32 = int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) // Number of index columns including rowid - nByte = (int32((uint64(unsafe.Sizeof(Mem{})) * uint64(nCol)) + (((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + nByte = (int32((uint64(unsafe.Sizeof(Mem{})) * uint64(nCol)) + (((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))))) pRec = Xsqlite3DbMallocZero(tls, db, uint64(nByte)) if pRec != 0 { (*UnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo = Xsqlite3KeyInfoOfIndex(tls, (*ValueNewStat4Ctx)(unsafe.Pointer(p)).FpParse, pIdx) if (*UnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo != 0 { - (*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem = (pRec + uintptr((((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + (*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem = (pRec + uintptr((((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))))) for i = 0; i < nCol; i++ { - (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem + uintptr(i)*56)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem + uintptr(i)*56)).Fflags = MEM_Null (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem + uintptr(i)*56)).Fdb = db } } else { @@ -54917,7 +54307,7 @@ func valueNew(tls *libc.TLS, db uintptr, p uintptr) uintptr { /* sqlite3.c:77153 if pRec == uintptr(0) { return uintptr(0) } - *(*uintptr)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FppRec + uintptr(0)*8)) = pRec + *(*uintptr)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FppRec)) = pRec } (*UnpackedRecord)(unsafe.Pointer(pRec)).FnField = (U16((*ValueNewStat4Ctx)(unsafe.Pointer(p)).FiVal + 1)) @@ -54961,7 +54351,7 @@ func valueFromFunction(tls *libc.TLS, db uintptr, p uintptr, enc U8, aff U8, ppV nVal = 0 pFunc = uintptr(0) pVal = uintptr(0) - rc = 0 + rc = SQLITE_OK pList = uintptr(0) // Iterator variable pList = *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) @@ -54973,11 +54363,11 @@ __1: ; pFunc = Xsqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)), nVal, enc, uint8(0)) - if !((((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & (U32(0x0800 | 0x2000))) == U32(0)) || - (((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & U32(0x0020)) != 0)) { + if !((((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & (U32(SQLITE_FUNC_CONSTANT | SQLITE_FUNC_SLOCHNG))) == U32(0)) || + (((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != 0)) { goto __2 } - return 0 + return SQLITE_OK __2: ; @@ -54988,7 +54378,7 @@ __2: if !(apVal == uintptr(0)) { goto __4 } - rc = 7 + rc = SQLITE_NOMEM goto value_from_function_out __4: ; @@ -54998,7 +54388,7 @@ __5: goto __7 } rc = Xsqlite3ValueFromExpr(tls, db, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FpExpr, enc, aff, (apVal + uintptr(i)*8)) - if !((*(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8)) == uintptr(0)) || (rc != 0)) { + if !((*(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8)) == uintptr(0)) || (rc != SQLITE_OK)) { goto __8 } goto value_from_function_out @@ -55018,7 +54408,7 @@ __3: if !(pVal == uintptr(0)) { goto __9 } - rc = 7 + rc = SQLITE_NOMEM goto value_from_function_out __9: ; @@ -55034,13 +54424,13 @@ __9: Xsqlite3ErrorMsg(tls, (*ValueNewStat4Ctx)(unsafe.Pointer(pCtx)).FpParse, ts+824 /* "%s" */, libc.VaList(bp, Xsqlite3_value_text(tls, pVal))) goto __11 __10: - Xsqlite3ValueApplyAffinity(tls, pVal, aff, uint8(1)) + Xsqlite3ValueApplyAffinity(tls, pVal, aff, SQLITE_UTF8) rc = Xsqlite3VdbeChangeEncoding(tls, pVal, int32(enc)) - if !((rc == 0) && (Xsqlite3VdbeMemTooBig(tls, pVal) != 0)) { + if !((rc == SQLITE_OK) && (Xsqlite3VdbeMemTooBig(tls, pVal) != 0)) { goto __12 } - rc = 18 + rc = SQLITE_TOOBIG (*Parse)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(pCtx)).FpParse)).FnErr++ __12: ; @@ -55049,7 +54439,7 @@ __11: (*Parse)(unsafe.Pointer((*ValueNewStat4Ctx)(unsafe.Pointer(pCtx)).FpParse)).Frc = rc value_from_function_out: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __13 } pVal = uintptr(0) @@ -55104,17 +54494,17 @@ func valueFromExpr(tls *libc.TLS, db uintptr, pExpr uintptr, enc U8, affinity U8 *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) = uintptr(0) negInt = 1 zNeg = ts + 800 /* "" */ - rc = 0 + rc = SQLITE_OK __1: - if !(((libc.AssignInt32(&op, int32((*Expr)(unsafe.Pointer(pExpr)).Fop))) == 171) || (op == 178)) { + if !(((libc.AssignInt32(&op, int32((*Expr)(unsafe.Pointer(pExpr)).Fop))) == TK_UPLUS) || (op == TK_SPAN)) { goto __2 } pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft goto __1 __2: ; - if !(op == 173) { + if !(op == TK_REGISTER) { goto __3 } op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) @@ -55126,7 +54516,7 @@ __3: // check ensures that an EP_TokenOnly expression is never passed down // into valueFromFunction(). - if !(op == 36) { + if !(op == TK_CAST) { goto __4 } aff = U8(Xsqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), uintptr(0))) @@ -55135,8 +54525,8 @@ __3: if !(*(*uintptr)(unsafe.Pointer(ppVal)) != 0) { goto __5 } - Xsqlite3VdbeMemCast(tls, *(*uintptr)(unsafe.Pointer(ppVal)), aff, uint8(1)) - Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(ppVal)), affinity, uint8(1)) + Xsqlite3VdbeMemCast(tls, *(*uintptr)(unsafe.Pointer(ppVal)), aff, SQLITE_UTF8) + Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(ppVal)), affinity, SQLITE_UTF8) __5: ; return rc @@ -55145,8 +54535,8 @@ __4: // Handle negative integers in a single step. This is needed in the // case when the value is -9223372036854775808. - if !((op == 170) && - ((int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == 152) || (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == 150))) { + if !((op == TK_UMINUS) && + ((int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_INTEGER) || (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_FLOAT))) { goto __6 } pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft @@ -55156,7 +54546,7 @@ __4: __6: ; - if !(((op == 115) || (op == 150)) || (op == 152)) { + if !(((op == TK_STRING) || (op == TK_FLOAT)) || (op == TK_INTEGER)) { goto __7 } *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) = valueNew(tls, db, pCtx) @@ -55166,7 +54556,7 @@ __6: goto no_mem __9: ; - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000400))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_IntValue)) != U32(0)) { goto __10 } Xsqlite3VdbeMemSetInt64(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), (I64(*(*int32)(unsafe.Pointer(pExpr + 8 /* &.u */))) * I64(negInt))) @@ -55179,27 +54569,27 @@ __10: goto no_mem __12: ; - Xsqlite3ValueSetStr(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), -1, zVal, uint8(1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) + Xsqlite3ValueSetStr(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), -1, zVal, SQLITE_UTF8, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) __11: ; - if !(((op == 152) || (op == 150)) && (int32(affinity) == 0x41)) { + if !(((op == TK_INTEGER) || (op == TK_FLOAT)) && (int32(affinity) == SQLITE_AFF_BLOB)) { goto __13 } - Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), uint8(0x43), uint8(1)) + Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), SQLITE_AFF_NUMERIC, SQLITE_UTF8) goto __14 __13: - Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), affinity, uint8(1)) + Xsqlite3ValueApplyAffinity(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), affinity, SQLITE_UTF8) __14: ; - if !((int32((*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags) & ((0x0004 | 0x0020) | 0x0008)) != 0) { + if !((int32((*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags) & ((MEM_Int | MEM_IntReal) | MEM_Real)) != 0) { goto __15 } - *(*U16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0002))) + *(*U16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Str))) __15: ; - if !(int32(enc) != 1) { + if !(int32(enc) != SQLITE_UTF8) { goto __16 } rc = Xsqlite3VdbeChangeEncoding(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), int32(enc)) @@ -55207,16 +54597,16 @@ __16: ; goto __8 __7: - if !(op == 170) { + if !(op == TK_UMINUS) { goto __17 } // This branch happens for multiple negative signs. Ex: -(-5) - if !((0 == valueFromExpr(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, enc, affinity, bp+16 /* &pVal */, pCtx)) && + if !((SQLITE_OK == valueFromExpr(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, enc, affinity, bp+16 /* &pVal */, pCtx)) && (*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) != uintptr(0))) { goto __19 } Xsqlite3VdbeMemNumerify(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */))) - if !((int32((*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags) & 0x0008) != 0) { + if !((int32((*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags) & MEM_Real) != 0) { goto __20 } *(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) = -*(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) @@ -55226,7 +54616,7 @@ __20: goto __22 } *(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) = -(float64((int64(-1)) - (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32)))) - (*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags = (U16((int32((*Sqlite3_value)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */))))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0008)) + (*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags = (U16((int32((*Sqlite3_value)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */))))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Real)) goto __23 __22: *(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) = -*(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) @@ -55239,7 +54629,7 @@ __19: ; goto __18 __17: - if !(op == 119) { + if !(op == TK_NULL) { goto __24 } *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) = valueNew(tls, db, pCtx) @@ -55252,7 +54642,7 @@ __26: Xsqlite3VdbeMemSetNull(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */))) goto __25 __24: - if !(op == 151) { + if !(op == TK_BLOB) { goto __27 } @@ -55263,28 +54653,28 @@ __24: goto no_mem __29: ; - zVal = (*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + uintptr(2)) + zVal = (*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + 2) nVal = (Xsqlite3Strlen30(tls, zVal) - 1) Xsqlite3VdbeMemSetStr(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), Xsqlite3HexToBlob(tls, db, zVal, nVal), (nVal / 2), uint8(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) goto __28 __27: - if !((op == 169) && (pCtx != uintptr(0))) { + if !((op == TK_FUNCTION) && (pCtx != uintptr(0))) { goto __30 } rc = valueFromFunction(tls, db, pExpr, enc, affinity, bp+16 /* &pVal */, pCtx) goto __31 __30: - if !(op == 167) { + if !(op == TK_TRUEFALSE) { goto __32 } *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) = valueNew(tls, db, pCtx) if !(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) != 0) { goto __33 } - (*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags = U16(0x0004) - *(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) = (I64(libc.Bool32(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + uintptr(4)))) == 0))) + (*Sqlite3_value)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)))).Fflags = MEM_Int + *(*I64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)) /* &.u */)) = (I64(libc.Bool32(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + 4))) == 0))) __33: ; __32: @@ -55318,7 +54708,7 @@ __34: Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */))) __35: ; - return 7 + return SQLITE_NOMEM } // Create a new sqlite3_value object, containing the value of pExpr. @@ -55356,7 +54746,7 @@ func stat4ValueFromExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr, affinity U bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp /* pVal */)) = uintptr(0) var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb @@ -55368,7 +54758,7 @@ func stat4ValueFromExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr, affinity U if *(*uintptr)(unsafe.Pointer(bp /* pVal */)) != 0 { Xsqlite3VdbeMemSetNull(tls, *(*uintptr)(unsafe.Pointer(bp /* pVal */))) } - } else if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 153) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00800000)) == uint64(0)) { + } else if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_VARIABLE) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_EnableQPSG) == uint64(0)) { var v uintptr var iBindVar int32 = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) Xsqlite3VdbeSetVarmask(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, iBindVar) @@ -55424,10 +54814,10 @@ func Xsqlite3Stat4ProbeSetValue(tls *libc.TLS, pParse uintptr, pIdx uintptr, ppR bp := tls.Alloc(40) defer tls.Free(40) - var rc int32 = 0 + var rc int32 = SQLITE_OK var nExtract int32 = 0 - if (pExpr == uintptr(0)) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 136) { + if (pExpr == uintptr(0)) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_SELECT) { var i int32 // var alloc ValueNewStat4Ctx at bp, 32 @@ -55526,12 +54916,12 @@ func Xsqlite3Stat4Column(tls *libc.TLS, db uintptr, pRec uintptr, nRec int32, iC if pMem == uintptr(0) { pMem = libc.AssignPtrUintptr(ppVal, Xsqlite3ValueNew(tls, db)) if pMem == uintptr(0) { - return 7 + return SQLITE_NOMEM } } Xsqlite3VdbeSerialGet(tls, (a + uintptr((iField - szField))), *(*U32)(unsafe.Pointer(bp + 4 /* t */)), pMem) (*Mem)(unsafe.Pointer(pMem)).Fenc = (*Sqlite3)(unsafe.Pointer(db)).Fenc - return 0 + return SQLITE_OK } // Unless it is NULL, the argument must be an UnpackedRecord object returned @@ -55542,7 +54932,7 @@ func Xsqlite3Stat4ProbeFree(tls *libc.TLS, pRec uintptr) { /* sqlite3.c:77675:21 var i int32 var nCol int32 = int32((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pRec)).FpKeyInfo)).FnAllField) var aMem uintptr = (*UnpackedRecord)(unsafe.Pointer(pRec)).FaMem - var db uintptr = (*Mem)(unsafe.Pointer(aMem + uintptr(0)*56)).Fdb + var db uintptr = (*Mem)(unsafe.Pointer(aMem)).Fdb for i = 0; i < nCol; i++ { Xsqlite3VdbeMemRelease(tls, (aMem + uintptr(i)*56)) } @@ -55580,17 +54970,17 @@ func valueBytes(tls *libc.TLS, pVal uintptr, enc U8) int32 { /* sqlite3.c:77717: func Xsqlite3ValueBytes(tls *libc.TLS, pVal uintptr, enc U8) int32 { /* sqlite3.c:77720:20: */ var p uintptr = pVal - if ((int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0002) != 0) && (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == int32(enc)) { + if ((int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Str) != 0) && (int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fenc) == int32(enc)) { return (*Mem)(unsafe.Pointer(p)).Fn } - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0010) != 0 { - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Blob) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Zero) != 0 { return ((*Mem)(unsafe.Pointer(p)).Fn + *(*int32)(unsafe.Pointer(p /* &.u */))) } else { return (*Mem)(unsafe.Pointer(p)).Fn } } - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & 0x0001) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & MEM_Null) != 0 { return 0 } return valueBytes(tls, pVal, enc) @@ -55612,11 +55002,11 @@ func Xsqlite3VdbeCreate(tls *libc.TLS, pParse uintptr) uintptr { /* sqlite3.c:77 (*Vdbe)(unsafe.Pointer(p)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).FpVdbe (*Vdbe)(unsafe.Pointer(p)).FpPrev = uintptr(0) (*Sqlite3)(unsafe.Pointer(db)).FpVdbe = p - (*Vdbe)(unsafe.Pointer(p)).Fmagic = U32(0x16bceaa5) + (*Vdbe)(unsafe.Pointer(p)).Fmagic = VDBE_MAGIC_INIT (*Vdbe)(unsafe.Pointer(p)).FpParse = pParse (*Parse)(unsafe.Pointer(pParse)).FpVdbe = p - Xsqlite3VdbeAddOp2(tls, p, 62, 0, 1) + Xsqlite3VdbeAddOp2(tls, p, OP_Init, 0, 1) return p } @@ -55641,7 +55031,7 @@ func Xsqlite3VdbeSetSql(tls *libc.TLS, p uintptr, z uintptr, n int32, prepFlags return } (*Vdbe)(unsafe.Pointer(p)).FprepFlags = prepFlags - if (int32(prepFlags) & 0x80) == 0 { + if (int32(prepFlags) & SQLITE_PREPARE_SAVESQL) == 0 { (*Vdbe)(unsafe.Pointer(p)).Fexpmask = U32(0) } @@ -55669,7 +55059,7 @@ func Xsqlite3VdbeSwap(tls *libc.TLS, pA uintptr, pB uintptr) { /* sqlite3.c:7785 (*Vdbe)(unsafe.Pointer(pB)).Fexpmask = (*Vdbe)(unsafe.Pointer(pA)).Fexpmask (*Vdbe)(unsafe.Pointer(pB)).FprepFlags = (*Vdbe)(unsafe.Pointer(pA)).FprepFlags libc.Xmemcpy(tls, pB+212 /* &.aCounter */, pA+212 /* &.aCounter */, uint64(unsafe.Sizeof([7]U32{}))) - *(*U32)(unsafe.Pointer((pB + 212 /* &.aCounter */) + uintptr(5)*4))++ + *(*U32)(unsafe.Pointer((pB + 212 /* &.aCounter */) + 5*4))++ } // Resize the Vdbe.aOp array so that it is at least nOp elements larger @@ -55700,9 +55090,9 @@ func growOpArray(tls *libc.TLS, v uintptr, nOp int32) int32 { /* sqlite3.c:77895 _ = nOp // Ensure that the size of a VDBE does not grow too large - if nNew > Sqlite3_int64(*(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(p)).Fdb + 124 /* &.aLimit */) + uintptr(5)*4))) { + if nNew > Sqlite3_int64(*(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(p)).Fdb + 124 /* &.aLimit */) + 5*4))) { Xsqlite3OomFault(tls, (*Parse)(unsafe.Pointer(p)).Fdb) - return 7 + return SQLITE_NOMEM } pNew = Xsqlite3DbRealloc(tls, (*Parse)(unsafe.Pointer(p)).Fdb, (*Vdbe)(unsafe.Pointer(v)).FaOp, (uint64(nNew) * uint64(unsafe.Sizeof(Op{})))) @@ -55713,9 +55103,9 @@ func growOpArray(tls *libc.TLS, v uintptr, nOp int32) int32 { /* sqlite3.c:77895 } return func() int32 { if pNew != 0 { - return 0 + return SQLITE_OK } - return 7 + return SQLITE_NOMEM }() } @@ -55759,7 +55149,7 @@ func Xsqlite3VdbeAddOp3(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, (*VdbeOp)(unsafe.Pointer(pOp)).Fp2 = p2 (*VdbeOp)(unsafe.Pointer(pOp)).Fp3 = p3 *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) = uintptr(0) - (*VdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(0) + (*VdbeOp)(unsafe.Pointer(pOp)).Fp4type = P4_NOTUSED (*VdbeOp)(unsafe.Pointer(pOp)).FzComment = uintptr(0) return i } @@ -55778,13 +55168,13 @@ func Xsqlite3VdbeAddOp2(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32) // Generate code for an unconditional jump to instruction iDest func Xsqlite3VdbeGoto(tls *libc.TLS, p uintptr, iDest int32) int32 { /* sqlite3.c:78021:20: */ - return Xsqlite3VdbeAddOp3(tls, p, 11, 0, iDest, 0) + return Xsqlite3VdbeAddOp3(tls, p, OP_Goto, 0, iDest, 0) } // Generate code to cause the string zStr to be loaded into // register iDest func Xsqlite3VdbeLoadString(tls *libc.TLS, p uintptr, iDest int32, zStr uintptr) int32 { /* sqlite3.c:78028:20: */ - return Xsqlite3VdbeAddOp4(tls, p, 115, 0, iDest, 0, zStr, 0) + return Xsqlite3VdbeAddOp4(tls, p, OP_String8, 0, iDest, 0, zStr, 0) } // Generate code that initializes multiple registers to string or integer @@ -55814,16 +55204,16 @@ __1: z = libc.VaUintptr(&ap) Xsqlite3VdbeAddOp4(tls, p, func() int32 { if z == uintptr(0) { - return 72 + return OP_Null } - return 115 + return OP_String8 }(), 0, (iDest + i), 0, z, 0) goto __5 __4: if !(int32(c) == 'i') { goto __6 } - Xsqlite3VdbeAddOp2(tls, p, 69, int32(libc.VaInt32(&ap)), (iDest + i)) + Xsqlite3VdbeAddOp2(tls, p, OP_Integer, int32(libc.VaInt32(&ap)), (iDest + i)) goto __7 __6: goto skip_op_resultrow @@ -55838,7 +55228,7 @@ __2: goto __3 __3: ; - Xsqlite3VdbeAddOp2(tls, p, 80, iDest, i) + Xsqlite3VdbeAddOp2(tls, p, OP_ResultRow, iDest, i) skip_op_resultrow: _ = ap } @@ -55879,12 +55269,12 @@ func Xsqlite3VdbeAddFunctionCall(tls *libc.TLS, pParse uintptr, p1 int32, p2 int (*Sqlite3_context)(unsafe.Pointer(pCtx)).FiOp = Xsqlite3VdbeCurrentAddr(tls, v) addr = Xsqlite3VdbeAddOp4(tls, v, func() int32 { if eCallCtx != 0 { - return 63 + return OP_PureFunc } - return 64 + return OP_Function }(), p1, p2, p3, pCtx, -16) - Xsqlite3VdbeChangeP5(tls, v, (uint16(eCallCtx & 0x0002e))) + Xsqlite3VdbeChangeP5(tls, v, (uint16(eCallCtx & NC_SelfRef))) return addr } @@ -55930,7 +55320,7 @@ func Xsqlite3VdbeExplain(tls *libc.TLS, pParse uintptr, bPush U8, zFmt uintptr, _ = ap v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe iThis = (*Vdbe)(unsafe.Pointer(v)).FnOp - Xsqlite3VdbeAddOp4(tls, v, 174, iThis, (*Parse)(unsafe.Pointer(pParse)).FaddrExplain, 0, + Xsqlite3VdbeAddOp4(tls, v, OP_Explain, iThis, (*Parse)(unsafe.Pointer(pParse)).FaddrExplain, 0, zMsg, -7) if bPush != 0 { @@ -55953,7 +55343,7 @@ func Xsqlite3VdbeExplainPop(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:78198: // This routine will take ownership of the allocated memory. func Xsqlite3VdbeAddParseSchemaOp(tls *libc.TLS, p uintptr, iDb int32, zWhere uintptr) { /* sqlite3.c:78212:21: */ var j int32 - Xsqlite3VdbeAddOp4(tls, p, 141, iDb, 0, 0, zWhere, -7) + Xsqlite3VdbeAddOp4(tls, p, OP_ParseSchema, iDb, 0, 0, zWhere, -7) for j = 0; j < (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FnDb; j++ { Xsqlite3VdbeUsesBtree(tls, p, j) } @@ -55972,7 +55362,7 @@ func Xsqlite3VdbeAddOp4Int(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int3 // Insert the end of a co-routine func Xsqlite3VdbeEndCoroutine(tls *libc.TLS, v uintptr, regYield int32) { /* sqlite3.c:78240:21: */ - Xsqlite3VdbeAddOp1(tls, v, 66, regYield) + Xsqlite3VdbeAddOp1(tls, v, OP_EndCoroutine, regYield) // Clear the temporary register cache, thereby ensuring that each // co-routine has its own independent set of registers, because co-routines @@ -56081,33 +55471,32 @@ func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) { /* sqlite // all these opcodes together near the front of the opcode list. Skip // any opcode that does not need processing by virtual of the fact that // it is larger than SQLITE_MX_JUMP_OPCODE, as a performance optimization. - if int32((*Op)(unsafe.Pointer(pOp)).Fopcode) <= 62 { + if int32((*Op)(unsafe.Pointer(pOp)).Fopcode) <= SQLITE_MX_JUMP_OPCODE { // NOTE: Be sure to update mkopcodeh.tcl when adding or removing // cases from this switch! switch int32((*Op)(unsafe.Pointer(pOp)).Fopcode) { - case 2: + case OP_Transaction: { if (*Op)(unsafe.Pointer(pOp)).Fp2 != 0 { libc.SetBitFieldPtr16Uint32(p+200 /* &.readOnly */, Bft(0), 7, 0x80) } - /* no break */ } fallthrough - case 1: + case OP_AutoCommit: fallthrough - case 0: + case OP_Savepoint: { libc.SetBitFieldPtr16Uint32(p+200 /* &.bIsReader */, Bft(1), 8, 0x100) break } fallthrough - case 6: + case OP_Checkpoint: fallthrough - case 8: + case OP_Vacuum: fallthrough - case 7: + case OP_JournalMode: { libc.SetBitFieldPtr16Uint32(p+200 /* &.readOnly */, Bft(0), 7, 0x80) libc.SetBitFieldPtr16Uint32(p+200 /* &.bIsReader */, Bft(1), 8, 0x100) @@ -56115,9 +55504,9 @@ func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) { /* sqlite } fallthrough - case 5: + case OP_Next: fallthrough - case 3: + case OP_SorterNext: { *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32) int32 @@ -56131,7 +55520,7 @@ func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) { /* sqlite } fallthrough - case 4: + case OP_Prev: { *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32) int32 @@ -56145,7 +55534,7 @@ func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) { /* sqlite } fallthrough - case 10: + case OP_VUpdate: { if (*Op)(unsafe.Pointer(pOp)).Fp2 > nMaxArgs { nMaxArgs = (*Op)(unsafe.Pointer(pOp)).Fp2 @@ -56154,7 +55543,7 @@ func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) { /* sqlite } fallthrough - case 9: + case OP_VFilter: { var n int32 @@ -56162,8 +55551,6 @@ func resolveP2Values(tls *libc.TLS, p uintptr, pMaxFuncArgs uintptr) { /* sqlite if n > nMaxArgs { nMaxArgs = n } - // Fall through into the default case - /* no break */ } fallthrough @@ -56264,11 +55651,11 @@ __1: (*VdbeOp)(unsafe.Pointer(pOut)).Fp1 = int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp1) (*VdbeOp)(unsafe.Pointer(pOut)).Fp2 = int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp2) - if ((int32(Xsqlite3OpcodeProperty[(*VdbeOpList)(unsafe.Pointer(aOp)).Fopcode]) & 0x01) != 0) && (int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp2) > 0) { + if ((int32(Xsqlite3OpcodeProperty[(*VdbeOpList)(unsafe.Pointer(aOp)).Fopcode]) & OPFLG_JUMP) != 0) && (int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp2) > 0) { *(*int32)(unsafe.Pointer(pOut + 8 /* &.p2 */)) += ((*Vdbe)(unsafe.Pointer(p)).FnOp) } (*VdbeOp)(unsafe.Pointer(pOut)).Fp3 = int32((*VdbeOpList)(unsafe.Pointer(aOp)).Fp3) - (*VdbeOp)(unsafe.Pointer(pOut)).Fp4type = int8(0) + (*VdbeOp)(unsafe.Pointer(pOut)).Fp4type = P4_NOTUSED *(*uintptr)(unsafe.Pointer(pOut + 16 /* &.p4 */)) = uintptr(0) (*VdbeOp)(unsafe.Pointer(pOut)).Fp5 = U16(0) (*VdbeOp)(unsafe.Pointer(pOut)).FzComment = uintptr(0) @@ -56342,7 +55729,7 @@ func Xsqlite3VdbeJumpHereOrPopInst(tls *libc.TLS, p uintptr, addr int32) { /* sq // If the input FuncDef structure is ephemeral, then free it. If // the FuncDef is not ephermal, then do nothing. func freeEphemeralFunction(tls *libc.TLS, db uintptr, pDef uintptr) { /* sqlite3.c:78840:13: */ - if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0010)) != U32(0) { + if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_EPHEM) != U32(0) { Xsqlite3DbFreeNN(tls, db, pDef) } } @@ -56456,9 +55843,9 @@ func Xsqlite3VdbeChangeToNoop(tls *libc.TLS, p uintptr, addr int32) int32 { /* s pOp = ((*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(addr)*32) freeP4(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp4type), *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */))) - (*VdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(0) + (*VdbeOp)(unsafe.Pointer(pOp)).Fp4type = P4_NOTUSED *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) = uintptr(0) - (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(173) + (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = OP_Noop return 1 } @@ -56605,7 +55992,7 @@ func Xsqlite3VdbeNoopComment(tls *libc.TLS, p uintptr, zFormat uintptr, va uintp var ap Va_list _ = ap if p != 0 { - Xsqlite3VdbeAddOp0(tls, p, 173) + Xsqlite3VdbeAddOp0(tls, p, OP_Noop) ap = va vdbeVComment(tls, p, zFormat, ap) _ = ap @@ -56680,7 +56067,7 @@ func Xsqlite3VdbeDisplayComment(tls *libc.TLS, db uintptr, pOp uintptr, zP4 uint // var x StrAccum at bp+80, 32 - Xsqlite3StrAccumInit(tls, bp+80 /* &x */, uintptr(0), uintptr(0), 0, 1000000000) + Xsqlite3StrAccumInit(tls, bp+80 /* &x */, uintptr(0), uintptr(0), 0, SQLITE_MAX_LENGTH) zOpName = Xsqlite3OpcodeName(tls, int32((*Op)(unsafe.Pointer(pOp)).Fopcode)) nOpName = Xsqlite3Strlen30(tls, zOpName) if *(*int8)(unsafe.Pointer(zOpName + uintptr((nOpName + 1)))) != 0 { @@ -56688,7 +56075,7 @@ func Xsqlite3VdbeDisplayComment(tls *libc.TLS, db uintptr, pOp uintptr, zP4 uint var c int8 zSynopsis = libc.AssignAddUintptr(&zOpName, (uintptr(nOpName + 1))) if libc.Xstrncmp(tls, zSynopsis, ts+6592 /* "IF " */, uint64(3)) == 0 { - if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x20) != 0 { + if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_STOREP2) != 0 { Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+112 /* &zAlt[0] */, ts+6596 /* "r[P2] = (%s)" */, libc.VaList(bp, (zSynopsis+uintptr(3)))) } else { Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+112 /* &zAlt[0] */, ts+6609 /* "if %s goto P2" */, libc.VaList(bp+8, (zSynopsis+uintptr(3)))) @@ -56747,7 +56134,7 @@ func Xsqlite3VdbeDisplayComment(tls *libc.TLS, db uintptr, pOp uintptr, zP4 uint } else if (*Op)(unsafe.Pointer(pOp)).FzComment != 0 { Xsqlite3_str_appendall(tls, bp+80 /* &x */, (*Op)(unsafe.Pointer(pOp)).FzComment) } - if ((int32((*StrAccum)(unsafe.Pointer(bp+80 /* &x */)).FaccError) & 7) != 0) && (db != uintptr(0)) { + if ((int32((*StrAccum)(unsafe.Pointer(bp+80 /* &x */)).FaccError) & SQLITE_NOMEM) != 0) && (db != uintptr(0)) { Xsqlite3OomFault(tls, db) } return Xsqlite3StrAccumFinish(tls, bp+80 /* &x */) @@ -56762,7 +56149,7 @@ func Xsqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) uintptr { /* var zP4 uintptr = uintptr(0) // var x StrAccum at bp+144, 32 - Xsqlite3StrAccumInit(tls, bp+144 /* &x */, uintptr(0), uintptr(0), 0, 1000000000) + Xsqlite3StrAccumInit(tls, bp+144 /* &x */, uintptr(0), uintptr(0), 0, SQLITE_MAX_LENGTH) switch int32((*Op)(unsafe.Pointer(pOp)).Fp4type) { case -9: { @@ -56783,13 +56170,13 @@ func Xsqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) uintptr { /* } Xsqlite3_str_appendf(tls, bp+144 /* &x */, ts+6660, /* ",%s%s%s" */ libc.VaList(bp+8, func() uintptr { - if (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j)))) & 0x01) != 0 { + if (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j)))) & KEYINFO_ORDER_DESC) != 0 { return ts + 6585 /* "-" */ } return ts + 800 /* "" */ }(), func() uintptr { - if (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j)))) & 0x02) != 0 { + if (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(j)))) & KEYINFO_ORDER_BIGNULL) != 0 { return ts + 6668 /* "N." */ } return ts + 800 /* "" */ @@ -56844,13 +56231,13 @@ func Xsqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) uintptr { /* case -11: { var pMem uintptr = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0002) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Str) != 0 { zP4 = (*Mem)(unsafe.Pointer(pMem)).Fz - } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0004 | 0x0020)) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Int | MEM_IntReal)) != 0 { Xsqlite3_str_appendf(tls, bp+144 /* &x */, ts+6689 /* "%lld" */, libc.VaList(bp+104, *(*I64)(unsafe.Pointer(pMem /* &.u */)))) - } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0008) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Real) != 0 { Xsqlite3_str_appendf(tls, bp+144 /* &x */, ts+583 /* "%.16g" */, libc.VaList(bp+112, *(*float64)(unsafe.Pointer(pMem /* &.u */)))) - } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0001) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Null) != 0 { zP4 = ts + 801 /* "NULL" */ } else { @@ -56870,7 +56257,7 @@ func Xsqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) uintptr { /* { var i U32 var ai uintptr = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) - var n U32 = *(*U32)(unsafe.Pointer(ai + uintptr(0)*4)) // The first element of an INTARRAY is always the + var n U32 = *(*U32)(unsafe.Pointer(ai)) // The first element of an INTARRAY is always the // count of the number of elements to follow for i = U32(1); i <= n; i++ { Xsqlite3_str_appendf(tls, bp+144 /* &x */, ts+6709 /* "%c%u" */, libc.VaList(bp+128, func() int32 { @@ -56912,7 +56299,7 @@ func Xsqlite3VdbeDisplayP4(tls *libc.TLS, db uintptr, pOp uintptr) uintptr { /* if zP4 != 0 { Xsqlite3_str_appendall(tls, bp+144 /* &x */, zP4) } - if (int32((*StrAccum)(unsafe.Pointer(bp+144 /* &x */)).FaccError) & 7) != 0 { + if (int32((*StrAccum)(unsafe.Pointer(bp+144 /* &x */)).FaccError) & SQLITE_NOMEM) != 0 { Xsqlite3OomFault(tls, db) } return Xsqlite3StrAccumFinish(tls, bp+144 /* &x */) @@ -57031,14 +56418,14 @@ func releaseMemArray(tls *libc.TLS, p uintptr, N int32) { /* sqlite3.c:79619:13: // with no indexes using a single prepared INSERT statement, bind() // and reset(). Inserts are grouped into a transaction. - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & (0x2000 | 0x0400)) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { Xsqlite3VdbeMemRelease(tls, p) } else if (*Mem)(unsafe.Pointer(p)).FszMalloc != 0 { Xsqlite3DbFreeNN(tls, db, (*Mem)(unsafe.Pointer(p)).FzMalloc) (*Mem)(unsafe.Pointer(p)).FszMalloc = 0 } - (*Mem)(unsafe.Pointer(p)).Fflags = U16(0x0080) + (*Mem)(unsafe.Pointer(p)).Fflags = MEM_Undefined } } } @@ -57065,7 +56452,7 @@ func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, var nSub int32 = 0 // Number of sub-vdbes seen so far var apSub uintptr = uintptr(0) // Array of sub-vdbes var i int32 // Next instruction address - var rc int32 = 0 // Result code + var rc int32 = SQLITE_OK // Result code var aOp uintptr = uintptr(0) // Opcode array var iPc int32 // Rowid. Copy of value in *piPc @@ -57077,7 +56464,7 @@ func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, // encountered, but p->pc will eventually catch up to nRow. nRow = (*Vdbe)(unsafe.Pointer(p)).FnOp if pSub != uintptr(0) { - if (int32((*Mem)(unsafe.Pointer(pSub)).Fflags) & 0x0010) != 0 { + if (int32((*Mem)(unsafe.Pointer(pSub)).Fflags) & MEM_Blob) != 0 { // pSub is initiallly NULL. It is initialized to a BLOB by // the P4_SUBPROGRAM processing logic below nSub = (int32(uint64((*Mem)(unsafe.Pointer(pSub)).Fn) / uint64(unsafe.Sizeof(uintptr(0))))) @@ -57091,8 +56478,8 @@ func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, for 1 != 0 { // Loop exits via break i = libc.PostIncInt32(&iPc, 1) if i >= nRow { - (*Vdbe)(unsafe.Pointer(p)).Frc = 0 - rc = 101 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK + rc = SQLITE_DONE break } if i < (*Vdbe)(unsafe.Pointer(p)).FnOp { @@ -57126,13 +56513,13 @@ func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, } if j == nSub { (*Vdbe)(unsafe.Pointer(p)).Frc = Xsqlite3VdbeMemGrow(tls, pSub, nByte, (libc.Bool32(nSub != 0))) - if (*Vdbe)(unsafe.Pointer(p)).Frc != 0 { - rc = 1 + if (*Vdbe)(unsafe.Pointer(p)).Frc != SQLITE_OK { + rc = SQLITE_ERROR break } apSub = (*Mem)(unsafe.Pointer(pSub)).Fz *(*uintptr)(unsafe.Pointer(apSub + uintptr(libc.PostIncInt32(&nSub, 1))*8)) = *(*uintptr)(unsafe.Pointer(aOp + uintptr(i)*32 + 16 /* &.p4 */)) - (*Mem)(unsafe.Pointer(pSub)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pSub))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0010)) + (*Mem)(unsafe.Pointer(pSub)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pSub))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Blob)) (*Mem)(unsafe.Pointer(pSub)).Fn = (int32(uint64(nSub) * uint64(unsafe.Sizeof(uintptr(0))))) nRow = nRow + ((*SubProgram)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aOp + uintptr(i)*32 + 16 /* &.p4 */)))).FnOp) } @@ -57142,21 +56529,21 @@ func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, } if eMode == 2 { var pOp uintptr = (aOp + uintptr(i)*32) - if int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 96 { + if int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_OpenRead { break } - if (int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 97) && ((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x10) == 0) { + if (int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_OpenWrite) && ((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_P2ISREG) == 0) { break } - if int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 95 { + if int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_ReopenIdx { break } } else { - if int32((*Op)(unsafe.Pointer(aOp+uintptr(i)*32)).Fopcode) == 174 { + if int32((*Op)(unsafe.Pointer(aOp+uintptr(i)*32)).Fopcode) == OP_Explain { break } - if (int32((*Op)(unsafe.Pointer(aOp+uintptr(i)*32)).Fopcode) == 62) && (iPc > 1) { + if (int32((*Op)(unsafe.Pointer(aOp+uintptr(i)*32)).Fopcode) == OP_Init) && (iPc > 1) { break } } @@ -57171,7 +56558,7 @@ func Xsqlite3VdbeNextOpcode(tls *libc.TLS, p uintptr, pSub uintptr, eMode int32, // allocated by the OP_Program opcode in sqlite3VdbeExec(). func Xsqlite3VdbeFrameDelete(tls *libc.TLS, p uintptr) { /* sqlite3.c:79808:21: */ var i int32 - var aMem uintptr = ((p) + uintptr((((uint64(unsafe.Sizeof(VdbeFrame{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + var aMem uintptr = ((p) + 112) var apCsr uintptr = (aMem + uintptr((*VdbeFrame)(unsafe.Pointer(p)).FnChildMem)*56) for i = 0; i < (*VdbeFrame)(unsafe.Pointer(p)).FnChildCsr; i++ { @@ -57206,9 +56593,9 @@ func Xsqlite3VdbeList(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:79840:20: * var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb // The database connection // var i int32 at bp, 4 // Loop counter - var rc int32 = 0 // Return code - var pMem uintptr = ((*Vdbe)(unsafe.Pointer(p)).FaMem + uintptr(1)*56) // First Mem of result set - var bListSubprogs int32 = (libc.Bool32(((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.explain */)) & 0xc >> 2)) == 1) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x01000000)) != uint64(0)))) + var rc int32 = SQLITE_OK // Return code + var pMem uintptr = ((*Vdbe)(unsafe.Pointer(p)).FaMem + 1*56) // First Mem of result set + var bListSubprogs int32 = (libc.Bool32(((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.explain */)) & 0xc >> 2)) == 1) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_TriggerEQP) != uint64(0)))) // var aOp uintptr at bp+8, 8 // Array of opcodes var pOp uintptr // Current opcode @@ -57219,11 +56606,11 @@ func Xsqlite3VdbeList(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:79840:20: * releaseMemArray(tls, pMem, 8) (*Vdbe)(unsafe.Pointer(p)).FpResultSet = uintptr(0) - if (*Vdbe)(unsafe.Pointer(p)).Frc == 7 { + if (*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_NOMEM { // This happens if a malloc() inside a call to sqlite3_column_text() or // sqlite3_column_text16() failed. Xsqlite3OomFault(tls, db) - return 1 + return SQLITE_ERROR } if bListSubprogs != 0 { @@ -57232,7 +56619,7 @@ func Xsqlite3VdbeList(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:79840:20: * // to trigger subprograms. The VDBE is guaranteed to have at least 9 // cells. - pSub = ((*Vdbe)(unsafe.Pointer(p)).FaMem + uintptr(9)*56) + pSub = ((*Vdbe)(unsafe.Pointer(p)).FaMem + 9*56) } else { pSub = uintptr(0) } @@ -57240,11 +56627,11 @@ func Xsqlite3VdbeList(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:79840:20: * // Figure out which opcode is next to display rc = Xsqlite3VdbeNextOpcode(tls, p, pSub, (libc.Bool32((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.explain */)) & 0xc >> 2)) == 2)), (p + 52 /* &.pc */), bp /* &i */, bp+8 /* &aOp */) - if rc == 0 { + if rc == SQLITE_OK { pOp = (*(*uintptr)(unsafe.Pointer(bp + 8 /* aOp */)) + uintptr(*(*int32)(unsafe.Pointer(bp /* i */)))*32) if libc.AtomicLoadNInt32((db+392 /* &.u1 */ /* &.isInterrupted */), 0) != 0 { - (*Vdbe)(unsafe.Pointer(p)).Frc = 9 - rc = 1 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_INTERRUPT + rc = SQLITE_ERROR Xsqlite3VdbeError(tls, p, Xsqlite3ErrStr(tls, (*Vdbe)(unsafe.Pointer(p)).Frc), 0) } else { var zP4 uintptr = Xsqlite3VdbeDisplayP4(tls, db, pOp) @@ -57252,12 +56639,12 @@ func Xsqlite3VdbeList(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:79840:20: * Xsqlite3VdbeMemSetInt64(tls, pMem, int64((*Op)(unsafe.Pointer(pOp)).Fp1)) Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(1)*56), int64((*Op)(unsafe.Pointer(pOp)).Fp2)) Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(2)*56), int64((*Op)(unsafe.Pointer(pOp)).Fp3)) - Xsqlite3VdbeMemSetStr(tls, (pMem + uintptr(3)*56), zP4, -1, uint8(1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) + Xsqlite3VdbeMemSetStr(tls, (pMem + uintptr(3)*56), zP4, -1, SQLITE_UTF8, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) (*Vdbe)(unsafe.Pointer(p)).FnResColumn = U16(4) } else { Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(0)*56), int64(*(*int32)(unsafe.Pointer(bp /* i */)))) Xsqlite3VdbeMemSetStr(tls, (pMem + uintptr(1)*56), Xsqlite3OpcodeName(tls, int32((*Op)(unsafe.Pointer(pOp)).Fopcode)), - -1, uint8(1), uintptr(0)) + -1, SQLITE_UTF8, uintptr(0)) Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(2)*56), int64((*Op)(unsafe.Pointer(pOp)).Fp1)) Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(3)*56), int64((*Op)(unsafe.Pointer(pOp)).Fp2)) Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(4)*56), int64((*Op)(unsafe.Pointer(pOp)).Fp3)) @@ -57265,19 +56652,19 @@ func Xsqlite3VdbeList(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:79840:20: * Xsqlite3VdbeMemSetInt64(tls, (pMem + uintptr(6)*56), int64((*Op)(unsafe.Pointer(pOp)).Fp5)) { var zCom uintptr = Xsqlite3VdbeDisplayComment(tls, db, pOp, zP4) - Xsqlite3VdbeMemSetStr(tls, (pMem + uintptr(7)*56), zCom, -1, uint8(1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) + Xsqlite3VdbeMemSetStr(tls, (pMem + uintptr(7)*56), zCom, -1, SQLITE_UTF8, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) } - Xsqlite3VdbeMemSetStr(tls, (pMem + uintptr(5)*56), zP4, -1, uint8(1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) + Xsqlite3VdbeMemSetStr(tls, (pMem + uintptr(5)*56), zP4, -1, SQLITE_UTF8, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) (*Vdbe)(unsafe.Pointer(p)).FnResColumn = U16(8) } (*Vdbe)(unsafe.Pointer(p)).FpResultSet = pMem if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - (*Vdbe)(unsafe.Pointer(p)).Frc = 7 - rc = 1 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM + rc = SQLITE_ERROR } else { - (*Vdbe)(unsafe.Pointer(p)).Frc = 0 - rc = 100 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK + rc = SQLITE_ROW } } } @@ -57309,7 +56696,7 @@ type ReusableSpace = struct { func allocSpace(tls *libc.TLS, p uintptr, pBuf uintptr, nByte Sqlite3_int64) uintptr { /* sqlite3.c:80005:13: */ if pBuf == uintptr(0) { - nByte = (((nByte) + int64(7)) & ^libc.Int64FromInt32(7)) + nByte = (((nByte) + int64(7)) & int64(libc.CplInt32(7))) if nByte <= (*ReusableSpace)(unsafe.Pointer(p)).FnFree { *(*Sqlite3_int64)(unsafe.Pointer(p + 8 /* &.nFree */)) -= (nByte) pBuf = ((*ReusableSpace)(unsafe.Pointer(p)).FpSpace + uintptr((*ReusableSpace)(unsafe.Pointer(p)).FnFree)) @@ -57328,11 +56715,11 @@ func Xsqlite3VdbeRewind(tls *libc.TLS, p uintptr) { /* sqlite3.c:80028:21: */ // There should be at least one opcode. // Set the magic to VDBE_MAGIC_RUN sooner rather than later. - (*Vdbe)(unsafe.Pointer(p)).Fmagic = U32(0x2df20da3) + (*Vdbe)(unsafe.Pointer(p)).Fmagic = VDBE_MAGIC_RUN (*Vdbe)(unsafe.Pointer(p)).Fpc = -1 - (*Vdbe)(unsafe.Pointer(p)).Frc = 0 - (*Vdbe)(unsafe.Pointer(p)).FerrorAction = U8(2) + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK + (*Vdbe)(unsafe.Pointer(p)).FerrorAction = OE_Abort (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 (*Vdbe)(unsafe.Pointer(p)).FcacheCtr = U32(1) (*Vdbe)(unsafe.Pointer(p)).FminWriteFileFormat = U8(255) @@ -57389,10 +56776,10 @@ func Xsqlite3VdbeMakeReady(tls *libc.TLS, p uintptr, pParse uintptr) { /* sqlite // Figure out how much reusable memory is available at the end of the // opcode array. This extra memory will be reallocated for other elements // of the prepared statement. - n = (int32(((uint64(unsafe.Sizeof(Op{})) * uint64((*Vdbe)(unsafe.Pointer(p)).FnOp)) + uint64(7)) & ^libc.Uint64FromInt32(7))) // Bytes of opcode memory used - (*ReusableSpace)(unsafe.Pointer(bp + 8 /* &x */)).FpSpace = (((*Vdbe)(unsafe.Pointer(p)).FaOp) + uintptr(n)) // Unused opcode memory + n = (int32(((uint64(unsafe.Sizeof(Op{})) * uint64((*Vdbe)(unsafe.Pointer(p)).FnOp)) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) // Bytes of opcode memory used + (*ReusableSpace)(unsafe.Pointer(bp + 8 /* &x */)).FpSpace = (((*Vdbe)(unsafe.Pointer(p)).FaOp) + uintptr(n)) // Unused opcode memory - (*ReusableSpace)(unsafe.Pointer(bp + 8 /* &x */)).FnFree = (Sqlite3_int64(((*Parse)(unsafe.Pointer(pParse)).FszOpAlloc - n) & ^libc.Int32(7))) // Bytes of unused memory + (*ReusableSpace)(unsafe.Pointer(bp + 8 /* &x */)).FnFree = (Sqlite3_int64(((*Parse)(unsafe.Pointer(pParse)).FszOpAlloc - n) & libc.CplInt32(7))) // Bytes of unused memory resolveP2Values(tls, p, bp /* &nArg */) libc.SetBitFieldPtr16Uint32(p+200 /* &.usesStmtJournal */, Bft((U8(libc.Bool32(((*Parse)(unsafe.Pointer(pParse)).FisMultiWrite != 0) && ((*Parse)(unsafe.Pointer(pParse)).FmayAbort != 0))))), 6, 0x40) @@ -57414,7 +56801,7 @@ func Xsqlite3VdbeMakeReady(tls *libc.TLS, p uintptr, pParse uintptr) { /* sqlite mx = 8 } for i = iFirst; i < mx; i++ { - Xsqlite3VdbeSetColName(tls, p, (i - iFirst), 0, + Xsqlite3VdbeSetColName(tls, p, (i - iFirst), COLNAME_NAME, azColName[i], uintptr(0)) } } @@ -57454,9 +56841,9 @@ func Xsqlite3VdbeMakeReady(tls *libc.TLS, p uintptr, pParse uintptr) { /* sqlite } else { (*Vdbe)(unsafe.Pointer(p)).FnCursor = nCursor (*Vdbe)(unsafe.Pointer(p)).FnVar = YnVar(nVar) - initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar, nVar, db, uint16(0x0001)) + initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar, nVar, db, MEM_Null) (*Vdbe)(unsafe.Pointer(p)).FnMem = nMem - initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaMem, nMem, db, uint16(0x0080)) + initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaMem, nMem, db, MEM_Undefined) libc.Xmemset(tls, (*Vdbe)(unsafe.Pointer(p)).FapCsr, 0, (uint64(nCursor) * uint64(unsafe.Sizeof(uintptr(0))))) } Xsqlite3VdbeRewind(tls, p) @@ -57475,13 +56862,13 @@ func Xsqlite3VdbeFreeCursor(tls *libc.TLS, p uintptr, pCx uintptr) { /* sqlite3. } switch int32((*VdbeCursor)(unsafe.Pointer(pCx)).FeCurType) { - case 1: + case CURTYPE_SORTER: { Xsqlite3VdbeSorterClose(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, pCx) break } - case 0: + case CURTYPE_BTREE: { if (Bool(int32(*(*uint8)(unsafe.Pointer(pCx + 8 /* &.isEphemeral */)) & 0x1 >> 0))) != 0 { if (*VdbeCursor)(unsafe.Pointer(pCx)).FpBtx != 0 { @@ -57496,7 +56883,7 @@ func Xsqlite3VdbeFreeCursor(tls *libc.TLS, p uintptr, pCx uintptr) { /* sqlite3. break } - case 2: + case CURTYPE_VTAB: { var pVCur uintptr = *(*uintptr)(unsafe.Pointer(pCx + 56 /* &.uc */)) var pModule uintptr = (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(pVCur)).FpVtab)).FpModule @@ -57586,16 +56973,16 @@ func Xsqlite3VdbeSetNumCols(tls *libc.TLS, p uintptr, nResColumn int32) { /* sql var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb if (*Vdbe)(unsafe.Pointer(p)).FnResColumn != 0 { - releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, (int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn) * 5)) + releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, (int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn) * COLNAME_N)) Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FaColName) } - n = (nResColumn * 5) + n = (nResColumn * COLNAME_N) (*Vdbe)(unsafe.Pointer(p)).FnResColumn = U16(nResColumn) (*Vdbe)(unsafe.Pointer(p)).FaColName = Xsqlite3DbMallocRawNN(tls, db, (uint64(uint64(unsafe.Sizeof(Mem{})) * uint64(n)))) if (*Vdbe)(unsafe.Pointer(p)).FaColName == uintptr(0) { return } - initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, n, db, uint16(0x0001)) + initMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, n, db, MEM_Null) } // Set the name of the idx'th column to be returned by the SQL statement. @@ -57612,11 +56999,11 @@ func Xsqlite3VdbeSetColName(tls *libc.TLS, p uintptr, idx int32, var1 int32, zNa if (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FmallocFailed != 0 { - return 7 + return SQLITE_NOMEM } pColName = ((*Vdbe)(unsafe.Pointer(p)).FaColName + uintptr((idx+(var1*int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn))))*56) - rc = Xsqlite3VdbeMemSetStr(tls, pColName, zName, -1, uint8(1), xDel) + rc = Xsqlite3VdbeMemSetStr(tls, pColName, zName, -1, SQLITE_UTF8, xDel) return rc } @@ -57633,7 +57020,7 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 var nTrans int32 = 0 // Number of databases with an active write-transaction // that are candidates for a two-phase commit using a // super-journal - var rc int32 = 0 + var rc int32 = SQLITE_OK var needXcommit int32 = 0 // Before doing anything else, call the xSync() callback for any @@ -57648,14 +57035,14 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 // including the temp database. (b) is important because if more than // one database file has an open write transaction, a super-journal // file is required for an atomic commit. - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt if Xsqlite3BtreeIsInTrans(tls, pBt) != 0 { var pPager uintptr // Pager associated with pBt needXcommit = 1 Xsqlite3BtreeEnter(tls, pBt) pPager = Xsqlite3BtreePager(tls, pBt) - if ((int32((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).Fsafety_level) != 0x01) && + if ((int32((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).Fsafety_level) != PAGER_SYNCHRONOUS_OFF) && (aMJNeeded[Xsqlite3PagerGetJournalMode(tls, pPager)] != 0)) && (Xsqlite3PagerIsMemdb(tls, pPager) == 0) { @@ -57665,7 +57052,7 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 Xsqlite3BtreeLeave(tls, pBt) } } - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -57673,7 +57060,7 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 if (needXcommit != 0) && ((*Sqlite3)(unsafe.Pointer(db)).FxCommitCallback != 0) { rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((db + 272 /* &.xCommitCallback */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpCommitArg) if rc != 0 { - return (19 | (int32(2) << 8)) + return (SQLITE_CONSTRAINT | (int32(2) << 8)) } } @@ -57685,9 +57072,9 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 // string, it means the main database is :memory: or a temp file. In // that case we do not support atomic multi-file commits, so use the // simple case then too. - if (0 == Xsqlite3Strlen30(tls, Xsqlite3BtreeGetFilename(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt))) || + if (0 == Xsqlite3Strlen30(tls, Xsqlite3BtreeGetFilename(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt))) || (nTrans <= 1) { - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt if pBt != 0 { rc = Xsqlite3BtreeCommitPhaseOne(tls, pBt, uintptr(0)) @@ -57698,19 +57085,19 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 // If one of the BtreeCommitPhaseOne() calls fails, this indicates an // IO error while deleting or truncating a journal file. It is unlikely, // but could happen. In this case abandon processing and return the error. - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt if pBt != 0 { rc = Xsqlite3BtreeCommitPhaseTwo(tls, pBt, 0) } } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3VtabCommit(tls, db) } } else { var pVfs uintptr = (*Sqlite3)(unsafe.Pointer(db)).FpVfs var zSuper uintptr = uintptr(0) // File-name for the super-journal - var zMainFile uintptr = Xsqlite3BtreeGetFilename(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt) + var zMainFile uintptr = Xsqlite3BtreeGetFilename(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt) *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */)) = uintptr(0) var offset I64 = int64(0) // var res int32 at bp+60, 4 @@ -57722,19 +57109,19 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 nMainFile = Xsqlite3Strlen30(tls, zMainFile) zSuper = Xsqlite3MPrintf(tls, db, ts+6798 /* "%.4c%s%.16c" */, libc.VaList(bp, 0, zMainFile, 0)) if zSuper == uintptr(0) { - return 7 + return SQLITE_NOMEM } zSuper += uintptr(4) - for ok := true; ok; ok = ((rc == 0) && (*(*int32)(unsafe.Pointer(bp + 60 /* res */)) != 0)) { + for ok := true; ok; ok = ((rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 60 /* res */)) != 0)) { // var iRandom U32 at bp+56, 4 if retryCount != 0 { if retryCount > 100 { - Xsqlite3_log(tls, 13, ts+6810 /* "MJ delete: %s" */, libc.VaList(bp+24, zSuper)) + Xsqlite3_log(tls, SQLITE_FULL, ts+6810 /* "MJ delete: %s" */, libc.VaList(bp+24, zSuper)) Xsqlite3OsDelete(tls, pVfs, zSuper, 0) break } else if retryCount == 1 { - Xsqlite3_log(tls, 13, ts+6824 /* "MJ collide: %s" */, libc.VaList(bp+32, zSuper)) + Xsqlite3_log(tls, SQLITE_FULL, ts+6824 /* "MJ collide: %s" */, libc.VaList(bp+32, zSuper)) } } retryCount++ @@ -57744,14 +57131,14 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 // The antipenultimate character of the super-journal name must // be "9" to avoid name collisions when using 8+3 filenames. - rc = Xsqlite3OsAccess(tls, pVfs, zSuper, 0, bp+60 /* &res */) + rc = Xsqlite3OsAccess(tls, pVfs, zSuper, SQLITE_ACCESS_EXISTS, bp+60 /* &res */) } - if rc == 0 { + if rc == SQLITE_OK { // Open the super-journal. rc = Xsqlite3OsOpenMalloc(tls, pVfs, zSuper, bp+64, /* &pSuperJrnl */ - (((0x00000002 | 0x00000004) | 0x00000010) | 0x00004000), uintptr(0)) + (((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_SUPER_JOURNAL), uintptr(0)) } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3DbFree(tls, db, (zSuper - uintptr(4))) return rc } @@ -57771,7 +57158,7 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 rc = Xsqlite3OsWrite(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */)), zFile, (Xsqlite3Strlen30(tls, zFile) + 1), offset) offset = offset + (I64(Xsqlite3Strlen30(tls, zFile) + 1)) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3OsCloseFree(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */))) Xsqlite3OsDelete(tls, pVfs, zSuper, 0) Xsqlite3DbFree(tls, db, (zSuper - uintptr(4))) @@ -57782,8 +57169,8 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 // Sync the super-journal file. If the IOCAP_SEQUENTIAL device // flag is set this is not required. - if (0 == (Xsqlite3OsDeviceCharacteristics(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */))) & 0x00000400)) && - (0 != (libc.AssignInt32(&rc, Xsqlite3OsSync(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */)), 0x00002)))) { + if (0 == (Xsqlite3OsDeviceCharacteristics(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */))) & SQLITE_IOCAP_SEQUENTIAL)) && + (SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3OsSync(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */)), SQLITE_SYNC_NORMAL)))) { Xsqlite3OsCloseFree(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */))) Xsqlite3OsDelete(tls, pVfs, zSuper, 0) Xsqlite3DbFree(tls, db, (zSuper - uintptr(4))) @@ -57799,7 +57186,7 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 // super-journal file will be orphaned. But we cannot delete it, // in case the super-journal file name was written into the journal // file before the failure occurred. - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt if pBt != 0 { rc = Xsqlite3BtreeCommitPhaseOne(tls, pBt, zSuper) @@ -57807,7 +57194,7 @@ func vdbeCommit(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:80373 } Xsqlite3OsCloseFree(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pSuperJrnl */))) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3DbFree(tls, db, (zSuper - uintptr(4))) return rc } @@ -57872,21 +57259,21 @@ var aMJNeeded = [6]U8{ // Otherwise SQLITE_OK. func vdbeCloseStatement(tls *libc.TLS, p uintptr, eOp int32) int32 { /* sqlite3.c:80669:28: */ var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 var iSavepoint int32 = ((*Vdbe)(unsafe.Pointer(p)).FiStatement - 1) for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { - var rc2 int32 = 0 + var rc2 int32 = SQLITE_OK var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt if pBt != 0 { - if eOp == 2 { - rc2 = Xsqlite3BtreeSavepoint(tls, pBt, 2, iSavepoint) + if eOp == SAVEPOINT_ROLLBACK { + rc2 = Xsqlite3BtreeSavepoint(tls, pBt, SAVEPOINT_ROLLBACK, iSavepoint) } - if rc2 == 0 { - rc2 = Xsqlite3BtreeSavepoint(tls, pBt, 1, iSavepoint) + if rc2 == SQLITE_OK { + rc2 = Xsqlite3BtreeSavepoint(tls, pBt, SAVEPOINT_RELEASE, iSavepoint) } - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } @@ -57894,19 +57281,19 @@ func vdbeCloseStatement(tls *libc.TLS, p uintptr, eOp int32) int32 { /* sqlite3. (*Sqlite3)(unsafe.Pointer(db)).FnStatement-- (*Vdbe)(unsafe.Pointer(p)).FiStatement = 0 - if rc == 0 { - if eOp == 2 { - rc = Xsqlite3VtabSavepoint(tls, db, 2, iSavepoint) + if rc == SQLITE_OK { + if eOp == SAVEPOINT_ROLLBACK { + rc = Xsqlite3VtabSavepoint(tls, db, SAVEPOINT_ROLLBACK, iSavepoint) } - if rc == 0 { - rc = Xsqlite3VtabSavepoint(tls, db, 1, iSavepoint) + if rc == SQLITE_OK { + rc = Xsqlite3VtabSavepoint(tls, db, SAVEPOINT_RELEASE, iSavepoint) } } // If the statement transaction is being rolled back, also restore the // database handles deferred constraint counter to the value it had when // the statement transaction was opened. - if eOp == 2 { + if eOp == SAVEPOINT_ROLLBACK { (*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons = (*Vdbe)(unsafe.Pointer(p)).FnStmtDefCons (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = (*Vdbe)(unsafe.Pointer(p)).FnStmtDefImmCons } @@ -57917,7 +57304,7 @@ func Xsqlite3VdbeCloseStatement(tls *libc.TLS, p uintptr, eOp int32) int32 { /* if ((*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FnStatement != 0) && ((*Vdbe)(unsafe.Pointer(p)).FiStatement != 0) { return vdbeCloseStatement(tls, p, eOp) } - return 0 + return SQLITE_OK } // This function is called when a transaction opened by the database @@ -57932,12 +57319,12 @@ func Xsqlite3VdbeCheckFk(tls *libc.TLS, p uintptr, deferred int32) int32 { /* sq var db uintptr = (*Vdbe)(unsafe.Pointer(p)).Fdb if ((deferred != 0) && (((*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons + (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons) > int64(0))) || (!(deferred != 0) && ((*Vdbe)(unsafe.Pointer(p)).FnFkConstraint > int64(0))) { - (*Vdbe)(unsafe.Pointer(p)).Frc = (19 | (int32(3) << 8)) - (*Vdbe)(unsafe.Pointer(p)).FerrorAction = U8(2) + (*Vdbe)(unsafe.Pointer(p)).Frc = (SQLITE_CONSTRAINT | (int32(3) << 8)) + (*Vdbe)(unsafe.Pointer(p)).FerrorAction = OE_Abort Xsqlite3VdbeError(tls, p, ts+6852 /* "FOREIGN KEY cons..." */, 0) - return 1 + return SQLITE_ERROR } - return 0 + return SQLITE_OK } // This routine is called the when a VDBE tries to halt. If the VDBE @@ -57970,11 +57357,11 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * // state. We need to rollback the statement transaction, if there is // one, or the complete transaction if there is no statement transaction. - if (*Vdbe)(unsafe.Pointer(p)).Fmagic != U32(0x2df20da3) { - return 0 + if (*Vdbe)(unsafe.Pointer(p)).Fmagic != VDBE_MAGIC_RUN { + return SQLITE_OK } if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - (*Vdbe)(unsafe.Pointer(p)).Frc = 7 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } closeAllCursors(tls, p) @@ -57990,8 +57377,8 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * // Check for one of the special errors mrc = ((*Vdbe)(unsafe.Pointer(p)).Frc & 0xff) - isSpecialError = (libc.Bool32((((mrc == 7) || (mrc == 10)) || - (mrc == 9)) || (mrc == 13))) + isSpecialError = (libc.Bool32((((mrc == SQLITE_NOMEM) || (mrc == SQLITE_IOERR)) || + (mrc == SQLITE_INTERRUPT)) || (mrc == SQLITE_FULL))) if isSpecialError != 0 { // If the query was read-only and the error code is SQLITE_INTERRUPT, // no rollback is necessary. Otherwise, at least a savepoint @@ -58004,13 +57391,13 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * // file as part of an effort to free up cache space (see function // pagerStress() in pager.c), the rollback is required to restore // the pager to a consistent state. - if !((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.readOnly */)) & 0x80 >> 7)) != 0) || (mrc != 9) { - if ((mrc == 7) || (mrc == 13)) && ((Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.usesStmtJournal */)) & 0x40 >> 6))) != 0) { - eStatementOp = 2 + if !((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.readOnly */)) & 0x80 >> 7)) != 0) || (mrc != SQLITE_INTERRUPT) { + if ((mrc == SQLITE_NOMEM) || (mrc == SQLITE_FULL)) && ((Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.usesStmtJournal */)) & 0x40 >> 6))) != 0) { + eStatementOp = SAVEPOINT_ROLLBACK } else { // We are forced to roll back the active transaction. Before doing // so, abort any other statements this handle currently has active. - Xsqlite3RollbackAll(tls, db, (4 | (int32(2) << 8))) + Xsqlite3RollbackAll(tls, db, (SQLITE_ABORT | (int32(2) << 8))) Xsqlite3CloseSavepoints(tls, db) (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1) (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 @@ -58019,7 +57406,7 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * } // Check for immediate foreign key violations. - if ((*Vdbe)(unsafe.Pointer(p)).Frc == 0) || ((int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == 3) && !(isSpecialError != 0)) { + if ((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK) || ((int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == OE_Fail) && !(isSpecialError != 0)) { Xsqlite3VdbeCheckFk(tls, p, 0) } @@ -58031,14 +57418,14 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * if (!(((*Sqlite3)(unsafe.Pointer((db))).FnVTrans > 0) && ((*Sqlite3)(unsafe.Pointer((db))).FaVTrans == uintptr(0))) && ((*Sqlite3)(unsafe.Pointer(db)).FautoCommit != 0)) && ((*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite == (libc.Bool32((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.readOnly */)) & 0x80 >> 7)) == 0))) { - if ((*Vdbe)(unsafe.Pointer(p)).Frc == 0) || ((int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == 3) && !(isSpecialError != 0)) { + if ((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK) || ((int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == OE_Fail) && !(isSpecialError != 0)) { rc = Xsqlite3VdbeCheckFk(tls, p, 1) - if rc != 0 { + if rc != SQLITE_OK { if (Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.readOnly */)) & 0x80 >> 7))) != 0 { Xsqlite3VdbeLeave(tls, p) - return 1 + return SQLITE_ERROR } - rc = (19 | (int32(3) << 8)) + rc = (SQLITE_CONSTRAINT | (int32(3) << 8)) } else { // The auto-commit flag is true, the vdbe program was successful // or hit an 'OR FAIL' constraint and there are no deferred foreign @@ -58046,31 +57433,31 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * // is required. rc = vdbeCommit(tls, db, p) } - if (rc == 5) && ((Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.readOnly */)) & 0x80 >> 7))) != 0) { + if (rc == SQLITE_BUSY) && ((Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.readOnly */)) & 0x80 >> 7))) != 0) { Xsqlite3VdbeLeave(tls, p) - return 5 - } else if rc != 0 { + return SQLITE_BUSY + } else if rc != SQLITE_OK { (*Vdbe)(unsafe.Pointer(p)).Frc = rc - Xsqlite3RollbackAll(tls, db, 0) + Xsqlite3RollbackAll(tls, db, SQLITE_OK) (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 } else { (*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons = int64(0) (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = int64(0) - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x00080000))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_DeferFKs)) Xsqlite3CommitInternalChanges(tls, db) } } else { - Xsqlite3RollbackAll(tls, db, 0) + Xsqlite3RollbackAll(tls, db, SQLITE_OK) (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 } (*Sqlite3)(unsafe.Pointer(db)).FnStatement = 0 } else if eStatementOp == 0 { - if ((*Vdbe)(unsafe.Pointer(p)).Frc == 0) || (int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == 3) { - eStatementOp = 1 - } else if int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == 2 { - eStatementOp = 2 + if ((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK) || (int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == OE_Fail) { + eStatementOp = SAVEPOINT_RELEASE + } else if int32((*Vdbe)(unsafe.Pointer(p)).FerrorAction) == OE_Abort { + eStatementOp = SAVEPOINT_ROLLBACK } else { - Xsqlite3RollbackAll(tls, db, (4 | (int32(2) << 8))) + Xsqlite3RollbackAll(tls, db, (SQLITE_ABORT | (int32(2) << 8))) Xsqlite3CloseSavepoints(tls, db) (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1) (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 @@ -58085,12 +57472,12 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * if eStatementOp != 0 { rc = Xsqlite3VdbeCloseStatement(tls, p, eStatementOp) if rc != 0 { - if ((*Vdbe)(unsafe.Pointer(p)).Frc == 0) || (((*Vdbe)(unsafe.Pointer(p)).Frc & 0xff) == 19) { + if ((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK) || (((*Vdbe)(unsafe.Pointer(p)).Frc & 0xff) == SQLITE_CONSTRAINT) { (*Vdbe)(unsafe.Pointer(p)).Frc = rc Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg) (*Vdbe)(unsafe.Pointer(p)).FzErrMsg = uintptr(0) } - Xsqlite3RollbackAll(tls, db, (4 | (int32(2) << 8))) + Xsqlite3RollbackAll(tls, db, (SQLITE_ABORT | (int32(2) << 8))) Xsqlite3CloseSavepoints(tls, db) (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1) (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 @@ -58100,7 +57487,7 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * // If this was an INSERT, UPDATE or DELETE and no statement transaction // has been rolled back, update the database connection change-counter. if (Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.changeCntOn */)) & 0x10 >> 4))) != 0 { - if eStatementOp != 2 { + if eStatementOp != SAVEPOINT_ROLLBACK { Xsqlite3VdbeSetChanges(tls, db, (*Vdbe)(unsafe.Pointer(p)).FnChange) } else { Xsqlite3VdbeSetChanges(tls, db, 0) @@ -58123,10 +57510,10 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * } } - (*Vdbe)(unsafe.Pointer(p)).Fmagic = U32(0x319c2973) + (*Vdbe)(unsafe.Pointer(p)).Fmagic = VDBE_MAGIC_HALT if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - (*Vdbe)(unsafe.Pointer(p)).Frc = 7 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } // If the auto-commit flag is set to true, then any locks that were held @@ -58137,17 +57524,17 @@ func Xsqlite3VdbeHalt(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80761:20: * } return func() int32 { - if (*Vdbe)(unsafe.Pointer(p)).Frc == 5 { - return 5 + if (*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_BUSY { + return SQLITE_BUSY } - return 0 + return SQLITE_OK }() } // Each VDBE holds the result of the most recent sqlite3_step() call // in p->rc. This routine sets that result back to SQLITE_OK. func Xsqlite3VdbeResetStepResult(tls *libc.TLS, p uintptr) { /* sqlite3.c:80962:21: */ - (*Vdbe)(unsafe.Pointer(p)).Frc = 0 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK } // Copy the error code and error message belonging to the VDBE passed @@ -58165,7 +57552,7 @@ func Xsqlite3VdbeTransferError(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:80 if (*Sqlite3)(unsafe.Pointer(db)).FpErr == uintptr(0) { (*Sqlite3)(unsafe.Pointer(db)).FpErr = Xsqlite3ValueNew(tls, db) } - Xsqlite3ValueSetStr(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr, -1, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg, uint8(1), libc.UintptrFromInt32(-1)) + Xsqlite3ValueSetStr(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr, -1, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg, SQLITE_UTF8, libc.UintptrFromInt32(-1)) Xsqlite3EndBenignMalloc(tls) (*Sqlite3)(unsafe.Pointer(db)).FbBenignMalloc-- } else if (*Sqlite3)(unsafe.Pointer(db)).FpErr != 0 { @@ -58230,15 +57617,15 @@ func Xsqlite3VdbeReset(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:81023:20: (*Vdbe)(unsafe.Pointer(p)).FpResultSet = uintptr(0) // Save profiling information from this VDBE run. - (*Vdbe)(unsafe.Pointer(p)).Fmagic = U32(0x48fa9f76) + (*Vdbe)(unsafe.Pointer(p)).Fmagic = VDBE_MAGIC_RESET return ((*Vdbe)(unsafe.Pointer(p)).Frc & (*Sqlite3)(unsafe.Pointer(db)).FerrMask) } // Clean up and delete a VDBE after execution. Return an integer which is // the result code. Write any error message text into *pzErrMsg. func Xsqlite3VdbeFinalize(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:81120:20: */ - var rc int32 = 0 - if ((*Vdbe)(unsafe.Pointer(p)).Fmagic == U32(0x2df20da3)) || ((*Vdbe)(unsafe.Pointer(p)).Fmagic == U32(0x319c2973)) { + var rc int32 = SQLITE_OK + if ((*Vdbe)(unsafe.Pointer(p)).Fmagic == VDBE_MAGIC_RUN) || ((*Vdbe)(unsafe.Pointer(p)).Fmagic == VDBE_MAGIC_HALT) { rc = Xsqlite3VdbeReset(tls, p) } @@ -58289,13 +57676,13 @@ func Xsqlite3VdbeClearObject(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3. var pSub uintptr var pNext uintptr - releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, (int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn) * 5)) + releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaColName, (int32((*Vdbe)(unsafe.Pointer(p)).FnResColumn) * COLNAME_N)) for pSub = (*Vdbe)(unsafe.Pointer(p)).FpProgram; pSub != 0; pSub = pNext { pNext = (*SubProgram)(unsafe.Pointer(pSub)).FpNext vdbeFreeOpArray(tls, db, (*SubProgram)(unsafe.Pointer(pSub)).FaOp, (*SubProgram)(unsafe.Pointer(pSub)).FnOp) Xsqlite3DbFree(tls, db, pSub) } - if (*Vdbe)(unsafe.Pointer(p)).Fmagic != U32(0x16bceaa5) { + if (*Vdbe)(unsafe.Pointer(p)).Fmagic != VDBE_MAGIC_INIT { releaseMemArray(tls, (*Vdbe)(unsafe.Pointer(p)).FaVar, int32((*Vdbe)(unsafe.Pointer(p)).FnVar)) Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FpVList) Xsqlite3DbFree(tls, db, (*Vdbe)(unsafe.Pointer(p)).FpFree) @@ -58321,7 +57708,7 @@ func Xsqlite3VdbeDelete(tls *libc.TLS, p uintptr) { /* sqlite3.c:81215:21: */ if (*Vdbe)(unsafe.Pointer(p)).FpNext != 0 { (*Vdbe)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FpNext)).FpPrev = (*Vdbe)(unsafe.Pointer(p)).FpPrev } - (*Vdbe)(unsafe.Pointer(p)).Fmagic = U32(0x5606c3c8) + (*Vdbe)(unsafe.Pointer(p)).Fmagic = VDBE_MAGIC_DEAD (*Vdbe)(unsafe.Pointer(p)).Fdb = uintptr(0) Xsqlite3DbFreeNN(tls, db, p) } @@ -58346,8 +57733,8 @@ func Xsqlite3VdbeFinishMoveto(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:812 } atomic.AddInt32(&Xsqlite3_search_count, 1) (*VdbeCursor)(unsafe.Pointer(p)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(p)).FcacheStatus = U32(0) - return 0 + (*VdbeCursor)(unsafe.Pointer(p)).FcacheStatus = CACHE_STALE + return SQLITE_OK } // Something has moved cursor "p" out of place. Maybe the row it was @@ -58364,7 +57751,7 @@ func handleMovedCursor(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:81267:28: var rc int32 rc = Xsqlite3BtreeCursorRestore(tls, *(*uintptr)(unsafe.Pointer(p + 56 /* &.uc */)), bp /* &isDifferentRow */) - (*VdbeCursor)(unsafe.Pointer(p)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(p)).FcacheStatus = CACHE_STALE if *(*int32)(unsafe.Pointer(bp /* isDifferentRow */)) != 0 { (*VdbeCursor)(unsafe.Pointer(p)).FnullRow = U8(1) } @@ -58378,7 +57765,7 @@ func Xsqlite3VdbeCursorRestore(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:81 if Xsqlite3BtreeCursorHasMoved(tls, *(*uintptr)(unsafe.Pointer(p + 56 /* &.uc */))) != 0 { return handleMovedCursor(tls, p) } - return 0 + return SQLITE_OK } // Make sure the cursor p is ready to read or write the row to which it @@ -58400,14 +57787,14 @@ func Xsqlite3VdbeCursorMoveto(tls *libc.TLS, pp uintptr, piCol uintptr) int32 { if (((*VdbeCursor)(unsafe.Pointer(p)).FaAltMap != 0) && ((libc.AssignUint32(&iMap, *(*U32)(unsafe.Pointer((*VdbeCursor)(unsafe.Pointer(p)).FaAltMap + uintptr((U32(1)+*(*U32)(unsafe.Pointer(piCol))))*4)))) > U32(0))) && !(int32((*VdbeCursor)(unsafe.Pointer(p)).FnullRow) != 0) { *(*uintptr)(unsafe.Pointer(pp)) = (*VdbeCursor)(unsafe.Pointer(p)).FpAltCursor *(*U32)(unsafe.Pointer(piCol)) = (iMap - U32(1)) - return 0 + return SQLITE_OK } return Xsqlite3VdbeFinishMoveto(tls, p) } if Xsqlite3BtreeCursorHasMoved(tls, *(*uintptr)(unsafe.Pointer(p + 56 /* &.uc */))) != 0 { return handleMovedCursor(tls, p) } - return 0 + return SQLITE_OK } // The following functions: @@ -58583,14 +57970,14 @@ func serialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uintptr) U32 { bp := tls.Alloc(8) defer tls.Free(8) - *(*U64)(unsafe.Pointer(bp /* x */)) = (U64((((U32(*(*uint8)(unsafe.Pointer((buf) + uintptr(0)))) << 24) | (U32(int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(1)))) << 16))) | (U32(int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(2)))) << 8))) | U32(*(*uint8)(unsafe.Pointer((buf) + uintptr(3)))))) - var y U32 = ((((U32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + uintptr(0)))) << 24) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + uintptr(1)))) << 16))) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + uintptr(2)))) << 8))) | U32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + uintptr(3))))) + *(*U64)(unsafe.Pointer(bp /* x */)) = (U64((((U32(*(*uint8)(unsafe.Pointer((buf)))) << 24) | (U32(int32(*(*uint8)(unsafe.Pointer((buf) + 1))) << 16))) | (U32(int32(*(*uint8)(unsafe.Pointer((buf) + 2))) << 8))) | U32(*(*uint8)(unsafe.Pointer((buf) + 3))))) + var y U32 = ((((U32(*(*uint8)(unsafe.Pointer((buf + uintptr(4))))) << 24) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + 1))) << 16))) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + 2))) << 8))) | U32(*(*uint8)(unsafe.Pointer((buf + uintptr(4)) + 3)))) *(*U64)(unsafe.Pointer(bp /* x */)) = ((*(*U64)(unsafe.Pointer(bp /* x */)) << 32) + U64(y)) if serial_type == U32(6) { // EVIDENCE-OF: R-29851-52272 Value is a big-endian 64-bit // twos-complement integer. *(*I64)(unsafe.Pointer(pMem /* &.u */)) = *(*I64)(unsafe.Pointer(bp /* &x */)) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int } else { // EVIDENCE-OF: R-57343-49114 Value is a big-endian IEEE 754-2008 64-bit @@ -58599,9 +57986,9 @@ func serialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uintptr) U32 { libc.Xmemcpy(tls, (pMem /* &.u */ /* &.r */), bp /* &x */, uint64(unsafe.Sizeof(U64(0)))) (*Mem)(unsafe.Pointer(pMem)).Fflags = func() uint16 { if (((*(*U64)(unsafe.Pointer(bp /* x */))) & (U64((uint64(0x7ff))) << 52)) == (U64((uint64(0x7ff))) << 52)) && (((*(*U64)(unsafe.Pointer(bp /* x */))) & ((U64((uint64(1))) << 52) - uint64(1))) != uint64(0)) { - return uint16(0x0001) + return MEM_Null } - return uint16(0x0008) + return MEM_Real }() } return U32(8) @@ -58612,7 +57999,7 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin case U32(10): { // Internal use only: NULL with virtual table // UPDATE no-change flag set - (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(0x0001 | 0x4000)) + (*Mem)(unsafe.Pointer(pMem)).Fflags = (U16(MEM_Null | MEM_Zero)) (*Mem)(unsafe.Pointer(pMem)).Fn = 0 *(*int32)(unsafe.Pointer(pMem /* &.u */)) = 0 break @@ -58623,7 +58010,7 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin case U32(0): { // Null // EVIDENCE-OF: R-24078-09375 Value is a NULL. - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Null break } @@ -58631,8 +58018,8 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin { // EVIDENCE-OF: R-44885-25196 Value is an 8-bit twos-complement // integer. - *(*I64)(unsafe.Pointer(pMem /* &.u */)) = I64(I8(*(*uint8)(unsafe.Pointer((buf) + uintptr(0))))) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + *(*I64)(unsafe.Pointer(pMem /* &.u */)) = I64(I8(*(*uint8)(unsafe.Pointer((buf))))) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int return U32(1) @@ -58641,8 +58028,8 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin { // 2-byte signed integer // EVIDENCE-OF: R-49794-35026 Value is a big-endian 16-bit // twos-complement integer. - *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64((256 * int32((I8(*(*uint8)(unsafe.Pointer((buf) + uintptr(0))))))) | int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(1)))))) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64((256 * int32((I8(*(*uint8)(unsafe.Pointer((buf))))))) | int32(*(*uint8)(unsafe.Pointer((buf) + 1))))) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int return U32(2) @@ -58651,8 +58038,8 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin { // 3-byte signed integer // EVIDENCE-OF: R-37839-54301 Value is a big-endian 24-bit // twos-complement integer. - *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64(((65536 * int32((I8(*(*uint8)(unsafe.Pointer((buf) + uintptr(0))))))) | (int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(1)))) << 8)) | int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(2)))))) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64(((65536 * int32((I8(*(*uint8)(unsafe.Pointer((buf))))))) | (int32(*(*uint8)(unsafe.Pointer((buf) + 1))) << 8)) | int32(*(*uint8)(unsafe.Pointer((buf) + 2))))) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int return U32(3) @@ -58661,8 +58048,8 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin { // 4-byte signed integer // EVIDENCE-OF: R-01849-26079 Value is a big-endian 32-bit // twos-complement integer. - *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64((((16777216 * int32((I8(*(*uint8)(unsafe.Pointer((buf) + uintptr(0))))))) | (int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(1)))) << 16)) | (int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(2)))) << 8)) | int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(3)))))) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64((((16777216 * int32((I8(*(*uint8)(unsafe.Pointer((buf))))))) | (int32(*(*uint8)(unsafe.Pointer((buf) + 1))) << 16)) | (int32(*(*uint8)(unsafe.Pointer((buf) + 2))) << 8)) | int32(*(*uint8)(unsafe.Pointer((buf) + 3))))) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int return U32(4) @@ -58671,8 +58058,8 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin { // 6-byte signed integer // EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit // twos-complement integer. - *(*I64)(unsafe.Pointer(pMem /* &.u */)) = ((I64((((U32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + uintptr(0)))) << 24) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + uintptr(1)))) << 16))) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + uintptr(2)))) << 8))) | U32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + uintptr(3)))))) + ((I64((int64(1))) << 32) * (I64((256 * int32((I8(*(*uint8)(unsafe.Pointer((buf) + uintptr(0))))))) | int32(*(*uint8)(unsafe.Pointer((buf) + uintptr(1)))))))) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + *(*I64)(unsafe.Pointer(pMem /* &.u */)) = ((I64((((U32(*(*uint8)(unsafe.Pointer((buf + uintptr(2))))) << 24) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + 1))) << 16))) | (U32(int32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + 2))) << 8))) | U32(*(*uint8)(unsafe.Pointer((buf + uintptr(2)) + 3))))) + ((I64((int64(1))) << 32) * (I64((256 * int32((I8(*(*uint8)(unsafe.Pointer((buf))))))) | int32(*(*uint8)(unsafe.Pointer((buf) + 1))))))) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int return U32(6) @@ -58693,7 +58080,7 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin // EVIDENCE-OF: R-12976-22893 Value is the integer 0. // EVIDENCE-OF: R-18143-12121 Value is the integer 1. *(*I64)(unsafe.Pointer(pMem /* &.u */)) = (I64(serial_type - U32(8))) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Int return U32(0) } @@ -58709,7 +58096,7 @@ func Xsqlite3VdbeSerialGet(tls *libc.TLS, buf uintptr, serial_type U32, pMem uin return U32(0) } -var aFlag = [2]U16{(U16(0x0010 | 0x1000)), (U16(0x0002 | 0x1000))} /* sqlite3.c:81711:24 */ +var aFlag = [2]U16{(U16(MEM_Blob | MEM_Ephem)), (U16(MEM_Str | MEM_Ephem))} /* sqlite3.c:81711:24 */ // This routine is used to allocate sufficient space for an UnpackedRecord // structure large enough to be used with sqlite3VdbeRecordUnpack() if @@ -58726,12 +58113,12 @@ var aFlag = [2]U16{(U16(0x0010 | 0x1000)), (U16(0x0002 | 0x1000))} /* sqlite3.c: func Xsqlite3VdbeAllocUnpackedRecord(tls *libc.TLS, pKeyInfo uintptr) uintptr { /* sqlite3.c:81734:31: */ var p uintptr // Unpacked record to return var nByte int32 // Number of bytes required for *p - nByte = (int32((((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)) + (uint64(unsafe.Sizeof(Mem{})) * (uint64(int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField) + 1))))) + nByte = (int32((((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))) + (uint64(unsafe.Sizeof(Mem{})) * (uint64(int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField) + 1))))) p = Xsqlite3DbMallocRaw(tls, (*KeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb, uint64(nByte)) if !(p != 0) { return uintptr(0) } - (*UnpackedRecord)(unsafe.Pointer(p)).FaMem = ((p) + uintptr((((uint64(unsafe.Sizeof(UnpackedRecord{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + (*UnpackedRecord)(unsafe.Pointer(p)).FaMem = ((p) + 24) (*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo = pKeyInfo (*UnpackedRecord)(unsafe.Pointer(p)).FnField = (U16(int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField) + 1)) @@ -58820,15 +58207,15 @@ func vdbeCompareMemString(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uin // var c2 Mem at bp+56, 56 - Xsqlite3VdbeMemInit(tls, bp /* &c1 */, (*Mem)(unsafe.Pointer(pMem1)).Fdb, uint16(0x0001)) - Xsqlite3VdbeMemInit(tls, bp+56 /* &c2 */, (*Mem)(unsafe.Pointer(pMem1)).Fdb, uint16(0x0001)) - Xsqlite3VdbeMemShallowCopy(tls, bp /* &c1 */, pMem1, 0x1000) - Xsqlite3VdbeMemShallowCopy(tls, bp+56 /* &c2 */, pMem2, 0x1000) + Xsqlite3VdbeMemInit(tls, bp /* &c1 */, (*Mem)(unsafe.Pointer(pMem1)).Fdb, MEM_Null) + Xsqlite3VdbeMemInit(tls, bp+56 /* &c2 */, (*Mem)(unsafe.Pointer(pMem1)).Fdb, MEM_Null) + Xsqlite3VdbeMemShallowCopy(tls, bp /* &c1 */, pMem1, MEM_Ephem) + Xsqlite3VdbeMemShallowCopy(tls, bp+56 /* &c2 */, pMem2, MEM_Ephem) v1 = Xsqlite3ValueText(tls, bp /* &c1 */, (*CollSeq)(unsafe.Pointer(pColl)).Fenc) v2 = Xsqlite3ValueText(tls, bp+56 /* &c2 */, (*CollSeq)(unsafe.Pointer(pColl)).Fenc) if (v1 == uintptr(0)) || (v2 == uintptr(0)) { if prcErr != 0 { - *(*U8)(unsafe.Pointer(prcErr)) = U8(7) + *(*U8)(unsafe.Pointer(prcErr)) = SQLITE_NOMEM } rc = 0 } else { @@ -58866,10 +58253,10 @@ func Xsqlite3BlobCompare(tls *libc.TLS, pB1 uintptr, pB2 uintptr) int32 { /* sql // by the OP_MakeRecord opcode, and such Blobs never get passed into // sqlite3MemCompare(). - if ((int32((*Mem)(unsafe.Pointer(pB1)).Fflags) | int32((*Mem)(unsafe.Pointer(pB2)).Fflags)) & 0x4000) != 0 { - if ((int32((*Mem)(unsafe.Pointer(pB1)).Fflags) & int32((*Mem)(unsafe.Pointer(pB2)).Fflags)) & 0x4000) != 0 { + if ((int32((*Mem)(unsafe.Pointer(pB1)).Fflags) | int32((*Mem)(unsafe.Pointer(pB2)).Fflags)) & MEM_Zero) != 0 { + if ((int32((*Mem)(unsafe.Pointer(pB1)).Fflags) & int32((*Mem)(unsafe.Pointer(pB2)).Fflags)) & MEM_Zero) != 0 { return (*(*int32)(unsafe.Pointer(pB1 /* &.u */)) - *(*int32)(unsafe.Pointer(pB2 /* &.u */))) - } else if (int32((*Mem)(unsafe.Pointer(pB1)).Fflags) & 0x4000) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pB1)).Fflags) & MEM_Zero) != 0 { if !(isAllZero(tls, (*Mem)(unsafe.Pointer(pB2)).Fz, (*Mem)(unsafe.Pointer(pB2)).Fn) != 0) { return -1 } @@ -58952,14 +58339,14 @@ func Xsqlite3MemCompare(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintp // If one value is NULL, it is less than the other. If both values // are NULL, return 0. - if (combined_flags & 0x0001) != 0 { - return ((f2 & 0x0001) - (f1 & 0x0001)) + if (combined_flags & MEM_Null) != 0 { + return ((f2 & MEM_Null) - (f1 & MEM_Null)) } // At least one of the two values is a number - if (combined_flags & ((0x0004 | 0x0008) | 0x0020)) != 0 { + if (combined_flags & ((MEM_Int | MEM_Real) | MEM_IntReal)) != 0 { - if ((f1 & f2) & (0x0004 | 0x0020)) != 0 { + if ((f1 & f2) & (MEM_Int | MEM_IntReal)) != 0 { if *(*I64)(unsafe.Pointer(pMem1 /* &.u */)) < *(*I64)(unsafe.Pointer(pMem2 /* &.u */)) { return -1 @@ -58969,7 +58356,7 @@ func Xsqlite3MemCompare(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintp } return 0 } - if ((f1 & f2) & 0x0008) != 0 { + if ((f1 & f2) & MEM_Real) != 0 { if *(*float64)(unsafe.Pointer(pMem1 /* &.u */)) < *(*float64)(unsafe.Pointer(pMem2 /* &.u */)) { return -1 } @@ -58978,11 +58365,11 @@ func Xsqlite3MemCompare(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintp } return 0 } - if (f1 & (0x0004 | 0x0020)) != 0 { + if (f1 & (MEM_Int | MEM_IntReal)) != 0 { - if (f2 & 0x0008) != 0 { + if (f2 & MEM_Real) != 0 { return sqlite3IntFloatCompare(tls, *(*I64)(unsafe.Pointer(pMem1 /* &.u */)), *(*float64)(unsafe.Pointer(pMem2 /* &.u */))) - } else if (f2 & (0x0004 | 0x0020)) != 0 { + } else if (f2 & (MEM_Int | MEM_IntReal)) != 0 { if *(*I64)(unsafe.Pointer(pMem1 /* &.u */)) < *(*I64)(unsafe.Pointer(pMem2 /* &.u */)) { return -1 } @@ -58994,8 +58381,8 @@ func Xsqlite3MemCompare(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintp return -1 } } - if (f1 & 0x0008) != 0 { - if (f2 & (0x0004 | 0x0020)) != 0 { + if (f1 & MEM_Real) != 0 { + if (f2 & (MEM_Int | MEM_IntReal)) != 0 { return -sqlite3IntFloatCompare(tls, *(*I64)(unsafe.Pointer(pMem2 /* &.u */)), *(*float64)(unsafe.Pointer(pMem1 /* &.u */))) } else { @@ -59007,11 +58394,11 @@ func Xsqlite3MemCompare(tls *libc.TLS, pMem1 uintptr, pMem2 uintptr, pColl uintp // If one value is a string and the other is a blob, the string is less. // If both are strings, compare using the collating functions. - if (combined_flags & 0x0002) != 0 { - if (f1 & 0x0002) == 0 { + if (combined_flags & MEM_Str) != 0 { + if (f1 & MEM_Str) == 0 { return 1 } - if (f2 & 0x0002) == 0 { + if (f2 & MEM_Str) == 0 { return -1 } @@ -59046,31 +58433,31 @@ func vdbeRecordDecodeInt(tls *libc.TLS, serial_type U32, aKey uintptr) I64 { /* fallthrough case U32(1): - return I64(I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))) + return I64(I8(*(*U8)(unsafe.Pointer((aKey))))) case U32(2): - return (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))))) + return (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + 1))))) case U32(3): - return (I64(((65536 * int32((I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))))) | (int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))) << 8)) | int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(2)))))) + return (I64(((65536 * int32((I8(*(*U8)(unsafe.Pointer((aKey))))))) | (int32(*(*U8)(unsafe.Pointer((aKey) + 1))) << 8)) | int32(*(*U8)(unsafe.Pointer((aKey) + 2))))) case U32(4): { - *(*U32)(unsafe.Pointer(bp /* y */)) = ((((U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(3))))) + *(*U32)(unsafe.Pointer(bp /* y */)) = ((((U32(*(*U8)(unsafe.Pointer((aKey)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + 3)))) return I64(*(*int32)(unsafe.Pointer(bp /* &y */))) } case U32(5): { - return ((I64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(3)))))) + ((I64((int64(1))) << 32) * (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))))))) + return ((I64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2))))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + 3))))) + ((I64((int64(1))) << 32) * (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + 1))))))) } case U32(6): { - *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = (U64((((U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(3)))))) + *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = (U64((((U32(*(*U8)(unsafe.Pointer((aKey)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + 3))))) - *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = ((*(*U64)(unsafe.Pointer(bp + 8 /* x */)) << 32) | (U64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(3))))))) + *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = ((*(*U64)(unsafe.Pointer(bp + 8 /* x */)) << 32) | (U64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4))))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + 3)))))) return *(*I64)(unsafe.Pointer(bp + 8 /* &x */)) } @@ -59120,15 +58507,15 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr // var s1 U32 at bp, 4 idx1 = (U32(1 + int32((func() uint8 { - if int32(*(*uint8)(unsafe.Pointer((aKey1 + uintptr(1))))) < int32(U8(0x80)) { + if int32(*(*uint8)(unsafe.Pointer((aKey1 + 1)))) < int32(U8(0x80)) { return uint8(func() int32 { - (*(*U32)(unsafe.Pointer(bp /* s1 */))) = U32(*(*uint8)(unsafe.Pointer((aKey1 + uintptr(1))))) + (*(*U32)(unsafe.Pointer(bp /* s1 */))) = U32(*(*uint8)(unsafe.Pointer((aKey1 + 1)))) return 1 }()) } - return Xsqlite3GetVarint32(tls, (aKey1 + uintptr(1)), bp /* &s1 */) + return Xsqlite3GetVarint32(tls, (aKey1 + 1), bp /* &s1 */) }())))) - *(*U32)(unsafe.Pointer(bp + 4 /* szHdr1 */)) = U32(*(*uint8)(unsafe.Pointer(aKey1 + uintptr(0)))) + *(*U32)(unsafe.Pointer(bp + 4 /* szHdr1 */)) = U32(*(*uint8)(unsafe.Pointer(aKey1))) d1 = (*(*U32)(unsafe.Pointer(bp + 4 /* szHdr1 */)) + Xsqlite3VdbeSerialTypeLen(tls, *(*U32)(unsafe.Pointer(bp /* s1 */)))) i = 1 pRhs += 56 @@ -59154,7 +58541,7 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr // var serial_type U32 at bp+64, 4 // RHS is an integer - if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & (0x0004 | 0x0020)) != 0 { + if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & (MEM_Int | MEM_IntReal)) != 0 { *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) = U32(*(*uint8)(unsafe.Pointer(aKey1 + uintptr(idx1)))) @@ -59174,7 +58561,7 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr rc = +1 } } - } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & 0x0008) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & MEM_Real) != 0 { *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) = U32(*(*uint8)(unsafe.Pointer(aKey1 + uintptr(idx1)))) if *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) >= U32(10) { // Serial types 12 or greater are strings and blobs (greater than @@ -59196,7 +58583,7 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr rc = sqlite3IntFloatCompare(tls, *(*I64)(unsafe.Pointer(bp + 8 /* &mem1 */ /* &.u */)), *(*float64)(unsafe.Pointer(pRhs /* &.u */))) } } - } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & 0x0002) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & MEM_Str) != 0 { *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) = U32(*(*uint8)(unsafe.Pointer((aKey1 + uintptr(idx1))))) if *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) >= U32(0x80) { Xsqlite3GetVarint32(tls, (aKey1 + uintptr(idx1)), bp+64 /* &serial_type */) @@ -59216,7 +58603,7 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr } else if *(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */) + uintptr(i)*8)) != 0 { (*Mem)(unsafe.Pointer(bp + 8 /* &mem1 */)).Fenc = (*KeyInfo)(unsafe.Pointer(pKeyInfo)).Fenc (*Mem)(unsafe.Pointer(bp + 8 /* &mem1 */)).Fdb = (*KeyInfo)(unsafe.Pointer(pKeyInfo)).Fdb - (*Mem)(unsafe.Pointer(bp + 8 /* &mem1 */)).Fflags = U16(0x0002) + (*Mem)(unsafe.Pointer(bp + 8 /* &mem1 */)).Fflags = MEM_Str (*Mem)(unsafe.Pointer(bp + 8 /* &mem1 */)).Fz = (aKey1 + uintptr(d1)) rc = vdbeCompareMemString(tls, bp+8 /* &mem1 */, pRhs, *(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */) + uintptr(i)*8)), (pPKey2 + 19 /* &.errCode */)) @@ -59233,7 +58620,7 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr } } } - } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & 0x0010) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & MEM_Blob) != 0 { *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) = U32(*(*uint8)(unsafe.Pointer((aKey1 + uintptr(idx1))))) if *(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) >= U32(0x80) { @@ -59248,7 +58635,7 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr if (d1 + U32(nStr)) > uint32(nKey1) { (*UnpackedRecord)(unsafe.Pointer(pPKey2)).FerrCode = U8(Xsqlite3CorruptError(tls, 82354)) return 0 // Corruption - } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & 0x4000) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & MEM_Zero) != 0 { if !(isAllZero(tls, (aKey1+uintptr(d1)), nStr) != 0) { rc = 1 } else { @@ -59275,9 +58662,9 @@ func Xsqlite3VdbeRecordCompareWithSkip(tls *libc.TLS, nKey1 int32, pKey1 uintptr if rc != 0 { var sortFlags int32 = int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FpKeyInfo)).FaSortFlags + uintptr(i)))) if sortFlags != 0 { - if ((sortFlags & 0x02) == 0) || - ((sortFlags & 0x01) != - (libc.Bool32((*(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) == U32(0)) || ((int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & 0x0001) != 0)))) { + if ((sortFlags & KEYINFO_ORDER_BIGNULL) == 0) || + ((sortFlags & KEYINFO_ORDER_DESC) != + (libc.Bool32((*(*U32)(unsafe.Pointer(bp + 64 /* serial_type */)) == U32(0)) || ((int32((*Mem)(unsafe.Pointer(pRhs)).Fflags) & MEM_Null) != 0)))) { rc = -rc } } @@ -59323,7 +58710,7 @@ func vdbeRecordCompareInt(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uint defer tls.Free(16) var aKey uintptr = ((pKey1) + uintptr((int32(*(*U8)(unsafe.Pointer(pKey1))) & 0x3F))) - var serial_type int32 = int32(*(*U8)(unsafe.Pointer((pKey1) + uintptr(1)))) + var serial_type int32 = int32(*(*U8)(unsafe.Pointer((pKey1) + 1))) var res int32 // var y U32 at bp, 4 @@ -59335,28 +58722,28 @@ func vdbeRecordCompareInt(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uint switch serial_type { case 1: { // 1-byte signed integer - lhs = I64(I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))) + lhs = I64(I8(*(*U8)(unsafe.Pointer((aKey))))) break } case 2: { // 2-byte signed integer - lhs = (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))))) + lhs = (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + 1))))) break } case 3: { // 3-byte signed integer - lhs = (I64(((65536 * int32((I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))))) | (int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))) << 8)) | int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(2)))))) + lhs = (I64(((65536 * int32((I8(*(*U8)(unsafe.Pointer((aKey))))))) | (int32(*(*U8)(unsafe.Pointer((aKey) + 1))) << 8)) | int32(*(*U8)(unsafe.Pointer((aKey) + 2))))) break } case 4: { // 4-byte signed integer - *(*U32)(unsafe.Pointer(bp /* y */)) = ((((U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(3))))) + *(*U32)(unsafe.Pointer(bp /* y */)) = ((((U32(*(*U8)(unsafe.Pointer((aKey)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + 3)))) lhs = I64(*(*int32)(unsafe.Pointer(bp /* &y */))) break @@ -59364,15 +58751,15 @@ func vdbeRecordCompareInt(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uint } case 5: { // 6-byte signed integer - lhs = ((I64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + uintptr(3)))))) + ((I64((int64(1))) << 32) * (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey) + uintptr(0))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))))))) + lhs = ((I64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2))))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(2)) + 3))))) + ((I64((int64(1))) << 32) * (I64((256 * int32((I8(*(*U8)(unsafe.Pointer((aKey))))))) | int32(*(*U8)(unsafe.Pointer((aKey) + 1))))))) break } case 6: { // 8-byte signed integer - *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = (U64((((U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + uintptr(3)))))) - *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = ((*(*U64)(unsafe.Pointer(bp + 8 /* x */)) << 32) | (U64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(0)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(1)))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(2)))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + uintptr(3))))))) + *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = (U64((((U32(*(*U8)(unsafe.Pointer((aKey)))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey) + 3))))) + *(*U64)(unsafe.Pointer(bp + 8 /* x */)) = ((*(*U64)(unsafe.Pointer(bp + 8 /* x */)) << 32) | (U64((((U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4))))) << 24) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + 1))) << 16))) | (U32(int32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + 2))) << 8))) | U32(*(*U8)(unsafe.Pointer((aKey + uintptr(4)) + 3)))))) lhs = *(*I64)(unsafe.Pointer(bp + 8 /* &x */)) break @@ -59400,7 +58787,7 @@ func vdbeRecordCompareInt(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uint return Xsqlite3VdbeRecordCompare(tls, nKey1, pKey1, pPKey2) } - v = *(*I64)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem + uintptr(0)*56 /* &.u */)) + v = *(*I64)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem /* &.u */)) if v > lhs { res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1) } else if v < lhs { @@ -59432,9 +58819,9 @@ func vdbeRecordCompareString(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 u var res int32 - *(*int32)(unsafe.Pointer(bp /* serial_type */)) = int32(*(*U8)(unsafe.Pointer(aKey1 + uintptr(1)))) + *(*int32)(unsafe.Pointer(bp /* serial_type */)) = int32(*(*U8)(unsafe.Pointer(aKey1 + 1))) if *(*int32)(unsafe.Pointer(bp /* serial_type */)) >= 0x80 { - Xsqlite3GetVarint32(tls, (aKey1 + uintptr(1)), bp /* &serial_type */) + Xsqlite3GetVarint32(tls, (aKey1 + 1), bp /* &serial_type */) } if *(*int32)(unsafe.Pointer(bp /* serial_type */)) < 12 { res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1) // (pKey1/nKey1) is a number or a null @@ -59443,7 +58830,7 @@ func vdbeRecordCompareString(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 u } else { var nCmp int32 var nStr int32 - var szHdr int32 = int32(*(*U8)(unsafe.Pointer(aKey1 + uintptr(0)))) + var szHdr int32 = int32(*(*U8)(unsafe.Pointer(aKey1))) nStr = ((*(*int32)(unsafe.Pointer(bp /* serial_type */)) - 12) / 2) if (szHdr + nStr) > nKey1 { @@ -59451,19 +58838,19 @@ func vdbeRecordCompareString(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 u return 0 // Corruption } nCmp = func() int32 { - if ((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem + uintptr(0)*56)).Fn) < (nStr) { - return (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem + uintptr(0)*56)).Fn + if ((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem)).Fn) < (nStr) { + return (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem)).Fn } return nStr }() - res = libc.Xmemcmp(tls, (aKey1 + uintptr(szHdr)), (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem+uintptr(0)*56)).Fz, uint64(nCmp)) + res = libc.Xmemcmp(tls, (aKey1 + uintptr(szHdr)), (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem)).Fz, uint64(nCmp)) if res > 0 { res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr2) } else if res < 0 { res = int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).Fr1) } else { - res = (nStr - (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem+uintptr(0)*56)).Fn) + res = (nStr - (*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FaMem)).Fn) if res == 0 { if int32((*UnpackedRecord)(unsafe.Pointer(pPKey2)).FnField) > 1 { res = Xsqlite3VdbeRecordCompareWithSkip(tls, nKey1, pKey1, pPKey2, 1) @@ -59500,9 +58887,9 @@ func Xsqlite3VdbeFindCompare(tls *libc.TLS, p uintptr) RecordCompare { /* sqlite // 13 fields or less. If the first field is an integer, the maximum legal // header size is (12*5 + 1 + 1) bytes. if int32((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FnAllField) <= 13 { - var flags int32 = int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FaMem + uintptr(0)*56)).Fflags) - if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FaSortFlags + uintptr(0))) != 0 { - if (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FaSortFlags + uintptr(0)))) & 0x02) != 0 { + var flags int32 = int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FaMem)).Fflags) + if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FaSortFlags)) != 0 { + if (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo)).FaSortFlags))) & KEYINFO_ORDER_BIGNULL) != 0 { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, int32, uintptr, uintptr) int32 }{Xsqlite3VdbeRecordCompare})) @@ -59513,14 +58900,14 @@ func Xsqlite3VdbeFindCompare(tls *libc.TLS, p uintptr) RecordCompare { /* sqlite (*UnpackedRecord)(unsafe.Pointer(p)).Fr1 = int8(-1) (*UnpackedRecord)(unsafe.Pointer(p)).Fr2 = int8(1) } - if (flags & 0x0004) != 0 { + if (flags & MEM_Int) != 0 { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, int32, uintptr, uintptr) int32 }{vdbeRecordCompareInt})) } - if ((flags & (((0x0008 | 0x0020) | 0x0001) | 0x0010)) == 0) && - (*(*uintptr)(unsafe.Pointer(((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo + 32 /* &.aColl */) + uintptr(0)*8)) == uintptr(0)) { + if ((flags & (((MEM_Real | MEM_IntReal) | MEM_Null) | MEM_Blob)) == 0) && + (*(*uintptr)(unsafe.Pointer(((*UnpackedRecord)(unsafe.Pointer(p)).FpKeyInfo + 32 /* &.aColl */))) == uintptr(0)) { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, int32, uintptr, uintptr) int32 @@ -59617,7 +59004,7 @@ __6: Xsqlite3VdbeSerialGet(tls, ((*Mem)(unsafe.Pointer(bp /* &m */)).Fz + uintptr((U32((*Mem)(unsafe.Pointer(bp /* &m */)).Fn) - lenRowid))), *(*U32)(unsafe.Pointer(bp + 60 /* typeRowid */)), bp+64 /* &v */) *(*I64)(unsafe.Pointer(rowid)) = *(*I64)(unsafe.Pointer(bp + 64 /* &v */ /* &.u */)) Xsqlite3VdbeMemRelease(tls, bp /* &m */) - return 0 + return SQLITE_OK // Jump here if database corruption is detected after m has been // allocated. Free the m object and return SQLITE_CORRUPT. @@ -59661,7 +59048,7 @@ func Xsqlite3VdbeIdxKeyCompare(tls *libc.TLS, db uintptr, pC uintptr, pUnpacked } *(*int32)(unsafe.Pointer(res)) = Xsqlite3VdbeRecordCompareWithSkip(tls, (*Mem)(unsafe.Pointer(bp /* &m */)).Fn, (*Mem)(unsafe.Pointer(bp /* &m */)).Fz, pUnpacked, 0) Xsqlite3VdbeMemRelease(tls, bp /* &m */) - return 0 + return SQLITE_OK } // This routine sets the value to be returned by subsequent calls to @@ -59722,11 +59109,11 @@ func Xsqlite3VdbeGetBoundValue(tls *libc.TLS, v uintptr, iVar int32, aff U8) uin if v != 0 { var pMem uintptr = ((*Vdbe)(unsafe.Pointer(v)).FaVar + uintptr((iVar-1))*56) - if 0 == (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x0001) { + if 0 == (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Null) { var pRet uintptr = Xsqlite3ValueNew(tls, (*Vdbe)(unsafe.Pointer(v)).Fdb) if pRet != 0 { Xsqlite3VdbeMemCopy(tls, pRet, pMem) - Xsqlite3ValueApplyAffinity(tls, pRet, aff, uint8(1)) + Xsqlite3ValueApplyAffinity(tls, pRet, aff, SQLITE_UTF8) } return pRet } @@ -59762,12 +59149,12 @@ func Xsqlite3NotPureFunc(tls *libc.TLS, pCtx uintptr) int32 { /* sqlite3.c:82855 return 1 } pOp = ((*Vdbe)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe)).FaOp + uintptr((*Sqlite3_context)(unsafe.Pointer(pCtx)).FiOp)*32) - if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 63 { + if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_PureFunc { var zContext uintptr var zMsg uintptr - if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5) & 0x00004) != 0 { + if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5) & NC_IsCheck) != 0 { zContext = ts + 6882 /* "a CHECK constrai..." */ - } else if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5) & 0x00008) != 0 { + } else if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5) & NC_GenCol) != 0 { zContext = ts + 6901 /* "a generated colu..." */ } else { zContext = ts + 6920 /* "an index" */ @@ -59828,11 +59215,11 @@ func Xsqlite3VdbePreUpdateHook(tls *libc.TLS, v uintptr, pCsr uintptr, op int32, var zTbl uintptr = (*Table)(unsafe.Pointer(pTab)).FzName libc.Xmemset(tls, bp /* &preupdate */, 0, uint64(unsafe.Sizeof(PreUpdate{}))) - if (libc.Bool32(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) == 0 { + if (libc.Bool32(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) == 0 { iKey1 = libc.AssignInt64(&iKey2, int64(0)) (*PreUpdate)(unsafe.Pointer(bp /* &preupdate */)).FpPk = Xsqlite3PrimaryKeyIndex(tls, pTab) } else { - if op == 23 { + if op == SQLITE_UPDATE { iKey2 = *(*I64)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + uintptr(iReg)*56 /* &.u */)) } else { iKey2 = iKey1 @@ -59902,7 +59289,7 @@ func Xsqlite3_expired(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83015:1 // invalid). Return false if it is ok. func vdbeSafety(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:83026:12: */ if (*Vdbe)(unsafe.Pointer(p)).Fdb == uintptr(0) { - Xsqlite3_log(tls, 21, ts+6965 /* "API called with ..." */, 0) + Xsqlite3_log(tls, SQLITE_MISUSE, ts+6965 /* "API called with ..." */, 0) return 1 } else { return 0 @@ -59912,7 +59299,7 @@ func vdbeSafety(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:83026:12: */ func vdbeSafetyNotNull(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:83034:12: */ if p == uintptr(0) { - Xsqlite3_log(tls, 21, ts+7010 /* "API called with ..." */, 0) + Xsqlite3_log(tls, SQLITE_MISUSE, ts+7010 /* "API called with ..." */, 0) return 1 } else { return vdbeSafety(tls, p) @@ -59935,8 +59322,8 @@ func invokeProfileCallback(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3.c: if (*Sqlite3)(unsafe.Pointer(db)).FxProfile != 0 { (*(*func(*libc.TLS, uintptr, uintptr, U64))(unsafe.Pointer((db + 248 /* &.xProfile */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpProfileArg, (*Vdbe)(unsafe.Pointer(p)).FzSql, uint64(*(*Sqlite3_int64)(unsafe.Pointer(bp + 8 /* iElapse */)))) } - if (int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & 0x02) != 0 { - (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, uint32(0x02), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, bp+8 /* &iElapse */) + if (int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & SQLITE_TRACE_PROFILE) != 0 { + (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, SQLITE_TRACE_PROFILE, (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, bp+8 /* &iElapse */) } (*Vdbe)(unsafe.Pointer(p)).FstartTime = int64(0) } @@ -59956,7 +59343,7 @@ func Xsqlite3_finalize(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83086: if pStmt == uintptr(0) { // IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL // pointer is a harmless no-op. - rc = 0 + rc = SQLITE_OK } else { var v uintptr = pStmt var db uintptr = (*Vdbe)(unsafe.Pointer(v)).Fdb @@ -59984,7 +59371,7 @@ func Xsqlite3_finalize(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83086: func Xsqlite3_reset(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83113:16: */ var rc int32 if pStmt == uintptr(0) { - rc = 0 + rc = SQLITE_OK } else { var v uintptr = pStmt var db uintptr = (*Vdbe)(unsafe.Pointer(v)).Fdb @@ -60005,13 +59392,13 @@ func Xsqlite3_reset(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83113:16: // Set all the parameters in the compiled SQL statement to NULL. func Xsqlite3_clear_bindings(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83134:16: */ var i int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr = pStmt var mutex uintptr = (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(pStmt)).Fdb)).Fmutex Xsqlite3_mutex_enter(tls, mutex) for i = 0; i < int32((*Vdbe)(unsafe.Pointer(p)).FnVar); i++ { Xsqlite3VdbeMemRelease(tls, ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr(i)*56)) - (*Mem)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr(i)*56)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr(i)*56)).Fflags = MEM_Null } if (*Vdbe)(unsafe.Pointer(p)).Fexpmask != 0 { @@ -60027,17 +59414,17 @@ func Xsqlite3_clear_bindings(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c: // structure. func Xsqlite3_value_blob(tls *libc.TLS, pVal uintptr) uintptr { /* sqlite3.c:83159:23: */ var p uintptr = pVal - if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & (0x0010 | 0x0002)) != 0 { + if (int32((*Mem)(unsafe.Pointer(p)).Fflags) & (MEM_Blob | MEM_Str)) != 0 { if (func() int32 { - if (int32((*Mem)(unsafe.Pointer((p))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((p))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, p) } return 0 - }()) != 0 { + }()) != SQLITE_OK { return uintptr(0) } - *(*U16)(unsafe.Pointer(p + 8 /* &.flags */)) |= U16((0x0010)) + *(*U16)(unsafe.Pointer(p + 8 /* &.flags */)) |= U16((MEM_Blob)) if (*Mem)(unsafe.Pointer(p)).Fn != 0 { return (*Mem)(unsafe.Pointer(p)).Fz } @@ -60049,11 +59436,11 @@ func Xsqlite3_value_blob(tls *libc.TLS, pVal uintptr) uintptr { /* sqlite3.c:831 } func Xsqlite3_value_bytes(tls *libc.TLS, pVal uintptr) int32 { /* sqlite3.c:83172:16: */ - return Xsqlite3ValueBytes(tls, pVal, uint8(1)) + return Xsqlite3ValueBytes(tls, pVal, SQLITE_UTF8) } func Xsqlite3_value_bytes16(tls *libc.TLS, pVal uintptr) int32 { /* sqlite3.c:83175:16: */ - return Xsqlite3ValueBytes(tls, pVal, uint8(2)) + return Xsqlite3ValueBytes(tls, pVal, SQLITE_UTF16LE) } func Xsqlite3_value_double(tls *libc.TLS, pVal uintptr) float64 { /* sqlite3.c:83178:19: */ @@ -60071,7 +59458,7 @@ func Xsqlite3_value_int64(tls *libc.TLS, pVal uintptr) Sqlite_int64 { /* sqlite3 func Xsqlite3_value_subtype(tls *libc.TLS, pVal uintptr) uint32 { /* sqlite3.c:83187:25: */ var pMem uintptr = pVal return func() uint32 { - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & 0x8000) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & MEM_Subtype) != 0 { return uint32((*Mem)(unsafe.Pointer(pMem)).FeSubtype) } return uint32(0) @@ -60080,7 +59467,7 @@ func Xsqlite3_value_subtype(tls *libc.TLS, pVal uintptr) uint32 { /* sqlite3.c:8 func Xsqlite3_value_pointer(tls *libc.TLS, pVal uintptr, zPType uintptr) uintptr { /* sqlite3.c:83191:17: */ var p uintptr = pVal - if ((((int32((*Mem)(unsafe.Pointer(p)).Fflags) & ((0xc1bf | 0x0200) | 0x8000)) == ((0x0001 | 0x0200) | 0x8000)) && + if ((((int32((*Mem)(unsafe.Pointer(p)).Fflags) & ((MEM_TypeMask | MEM_Term) | MEM_Subtype)) == ((MEM_Null | MEM_Term) | MEM_Subtype)) && (zPType != uintptr(0))) && (int32((*Mem)(unsafe.Pointer(p)).FeSubtype) == 'p')) && (libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(p /* &.u */)), zPType) == 0) { @@ -60092,103 +59479,103 @@ func Xsqlite3_value_pointer(tls *libc.TLS, pVal uintptr, zPType uintptr) uintptr } func Xsqlite3_value_text(tls *libc.TLS, pVal uintptr) uintptr { /* sqlite3.c:83204:32: */ - return Xsqlite3ValueText(tls, pVal, uint8(1)) + return Xsqlite3ValueText(tls, pVal, SQLITE_UTF8) } func Xsqlite3_value_text16(tls *libc.TLS, pVal uintptr) uintptr { /* sqlite3.c:83208:23: */ - return Xsqlite3ValueText(tls, pVal, uint8(2)) + return Xsqlite3ValueText(tls, pVal, SQLITE_UTF16LE) } func Xsqlite3_value_text16be(tls *libc.TLS, pVal uintptr) uintptr { /* sqlite3.c:83211:23: */ - return Xsqlite3ValueText(tls, pVal, uint8(3)) + return Xsqlite3ValueText(tls, pVal, SQLITE_UTF16BE) } func Xsqlite3_value_text16le(tls *libc.TLS, pVal uintptr) uintptr { /* sqlite3.c:83214:23: */ - return Xsqlite3ValueText(tls, pVal, uint8(2)) + return Xsqlite3ValueText(tls, pVal, SQLITE_UTF16LE) } // EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five // fundamental datatypes: 64-bit signed integer 64-bit IEEE floating // point number string BLOB NULL func Xsqlite3_value_type(tls *libc.TLS, pVal uintptr) int32 { /* sqlite3.c:83222:16: */ - return int32(aType[(int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & 0x003f)]) + return int32(aType[(int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & MEM_AffMask)]) } var aType = [64]U8{ - U8(4), // 0x00 (not possible) - U8(5), // 0x01 NULL - U8(3), // 0x02 TEXT - U8(5), // 0x03 (not possible) - U8(1), // 0x04 INTEGER - U8(5), // 0x05 (not possible) - U8(1), // 0x06 INTEGER + TEXT - U8(5), // 0x07 (not possible) - U8(2), // 0x08 FLOAT - U8(5), // 0x09 (not possible) - U8(2), // 0x0a FLOAT + TEXT - U8(5), // 0x0b (not possible) - U8(1), // 0x0c (not possible) - U8(5), // 0x0d (not possible) - U8(1), // 0x0e (not possible) - U8(5), // 0x0f (not possible) - U8(4), // 0x10 BLOB - U8(5), // 0x11 (not possible) - U8(3), // 0x12 (not possible) - U8(5), // 0x13 (not possible) - U8(1), // 0x14 INTEGER + BLOB - U8(5), // 0x15 (not possible) - U8(1), // 0x16 (not possible) - U8(5), // 0x17 (not possible) - U8(2), // 0x18 FLOAT + BLOB - U8(5), // 0x19 (not possible) - U8(2), // 0x1a (not possible) - U8(5), // 0x1b (not possible) - U8(1), // 0x1c (not possible) - U8(5), // 0x1d (not possible) - U8(1), // 0x1e (not possible) - U8(5), // 0x1f (not possible) - U8(2), // 0x20 INTREAL - U8(5), // 0x21 (not possible) - U8(3), // 0x22 INTREAL + TEXT - U8(5), // 0x23 (not possible) - U8(2), // 0x24 (not possible) - U8(5), // 0x25 (not possible) - U8(2), // 0x26 (not possible) - U8(5), // 0x27 (not possible) - U8(2), // 0x28 (not possible) - U8(5), // 0x29 (not possible) - U8(2), // 0x2a (not possible) - U8(5), // 0x2b (not possible) - U8(2), // 0x2c (not possible) - U8(5), // 0x2d (not possible) - U8(2), // 0x2e (not possible) - U8(5), // 0x2f (not possible) - U8(4), // 0x30 (not possible) - U8(5), // 0x31 (not possible) - U8(3), // 0x32 (not possible) - U8(5), // 0x33 (not possible) - U8(2), // 0x34 (not possible) - U8(5), // 0x35 (not possible) - U8(2), // 0x36 (not possible) - U8(5), // 0x37 (not possible) - U8(2), // 0x38 (not possible) - U8(5), // 0x39 (not possible) - U8(2), // 0x3a (not possible) - U8(5), // 0x3b (not possible) - U8(2), // 0x3c (not possible) - U8(5), // 0x3d (not possible) - U8(2), // 0x3e (not possible) - U8(5), // 0x3f (not possible) + SQLITE_BLOB, // 0x00 (not possible) + SQLITE_NULL, // 0x01 NULL + SQLITE_TEXT, // 0x02 TEXT + SQLITE_NULL, // 0x03 (not possible) + SQLITE_INTEGER, // 0x04 INTEGER + SQLITE_NULL, // 0x05 (not possible) + SQLITE_INTEGER, // 0x06 INTEGER + TEXT + SQLITE_NULL, // 0x07 (not possible) + SQLITE_FLOAT, // 0x08 FLOAT + SQLITE_NULL, // 0x09 (not possible) + SQLITE_FLOAT, // 0x0a FLOAT + TEXT + SQLITE_NULL, // 0x0b (not possible) + SQLITE_INTEGER, // 0x0c (not possible) + SQLITE_NULL, // 0x0d (not possible) + SQLITE_INTEGER, // 0x0e (not possible) + SQLITE_NULL, // 0x0f (not possible) + SQLITE_BLOB, // 0x10 BLOB + SQLITE_NULL, // 0x11 (not possible) + SQLITE_TEXT, // 0x12 (not possible) + SQLITE_NULL, // 0x13 (not possible) + SQLITE_INTEGER, // 0x14 INTEGER + BLOB + SQLITE_NULL, // 0x15 (not possible) + SQLITE_INTEGER, // 0x16 (not possible) + SQLITE_NULL, // 0x17 (not possible) + SQLITE_FLOAT, // 0x18 FLOAT + BLOB + SQLITE_NULL, // 0x19 (not possible) + SQLITE_FLOAT, // 0x1a (not possible) + SQLITE_NULL, // 0x1b (not possible) + SQLITE_INTEGER, // 0x1c (not possible) + SQLITE_NULL, // 0x1d (not possible) + SQLITE_INTEGER, // 0x1e (not possible) + SQLITE_NULL, // 0x1f (not possible) + SQLITE_FLOAT, // 0x20 INTREAL + SQLITE_NULL, // 0x21 (not possible) + SQLITE_TEXT, // 0x22 INTREAL + TEXT + SQLITE_NULL, // 0x23 (not possible) + SQLITE_FLOAT, // 0x24 (not possible) + SQLITE_NULL, // 0x25 (not possible) + SQLITE_FLOAT, // 0x26 (not possible) + SQLITE_NULL, // 0x27 (not possible) + SQLITE_FLOAT, // 0x28 (not possible) + SQLITE_NULL, // 0x29 (not possible) + SQLITE_FLOAT, // 0x2a (not possible) + SQLITE_NULL, // 0x2b (not possible) + SQLITE_FLOAT, // 0x2c (not possible) + SQLITE_NULL, // 0x2d (not possible) + SQLITE_FLOAT, // 0x2e (not possible) + SQLITE_NULL, // 0x2f (not possible) + SQLITE_BLOB, // 0x30 (not possible) + SQLITE_NULL, // 0x31 (not possible) + SQLITE_TEXT, // 0x32 (not possible) + SQLITE_NULL, // 0x33 (not possible) + SQLITE_FLOAT, // 0x34 (not possible) + SQLITE_NULL, // 0x35 (not possible) + SQLITE_FLOAT, // 0x36 (not possible) + SQLITE_NULL, // 0x37 (not possible) + SQLITE_FLOAT, // 0x38 (not possible) + SQLITE_NULL, // 0x39 (not possible) + SQLITE_FLOAT, // 0x3a (not possible) + SQLITE_NULL, // 0x3b (not possible) + SQLITE_FLOAT, // 0x3c (not possible) + SQLITE_NULL, // 0x3d (not possible) + SQLITE_FLOAT, // 0x3e (not possible) + SQLITE_NULL, // 0x3f (not possible) } /* sqlite3.c:83223:19 */ // Return true if a parameter to xUpdate represents an unchanged column func Xsqlite3_value_nochange(tls *libc.TLS, pVal uintptr) int32 { /* sqlite3.c:83308:16: */ - return (libc.Bool32((int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & (0x0001 | 0x4000)) == (0x0001 | 0x4000))) + return (libc.Bool32((int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & (MEM_Null | MEM_Zero)) == (MEM_Null | MEM_Zero))) } // Return true if a parameter value originated from an sqlite3_bind() func Xsqlite3_value_frombind(tls *libc.TLS, pVal uintptr) int32 { /* sqlite3.c:83313:16: */ - return (libc.Bool32((int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & 0x0040) != 0)) + return (libc.Bool32((int32((*Sqlite3_value)(unsafe.Pointer(pVal)).Fflags) & MEM_FromBind) != 0)) } // Make a copy of an sqlite3_value object @@ -60203,12 +59590,12 @@ func Xsqlite3_value_dup(tls *libc.TLS, pOrig uintptr) uintptr { /* sqlite3.c:833 } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(Sqlite3_value{}))) libc.Xmemcpy(tls, pNew, pOrig, uint64((uintptr(0) + 24 /* &.zMalloc */))) - *(*U16)(unsafe.Pointer(pNew + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0400))) + *(*U16)(unsafe.Pointer(pNew + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Dyn))) (*Sqlite3_value)(unsafe.Pointer(pNew)).Fdb = uintptr(0) - if (int32((*Sqlite3_value)(unsafe.Pointer(pNew)).Fflags) & (0x0002 | 0x0010)) != 0 { - *(*U16)(unsafe.Pointer(pNew + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32((0x0800 | 0x0400)))) - *(*U16)(unsafe.Pointer(pNew + 8 /* &.flags */)) |= U16((0x1000)) - if Xsqlite3VdbeMemMakeWriteable(tls, pNew) != 0 { + if (int32((*Sqlite3_value)(unsafe.Pointer(pNew)).Fflags) & (MEM_Str | MEM_Blob)) != 0 { + *(*U16)(unsafe.Pointer(pNew + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32((MEM_Static | MEM_Dyn)))) + *(*U16)(unsafe.Pointer(pNew + 8 /* &.flags */)) |= U16((MEM_Ephem)) + if Xsqlite3VdbeMemMakeWriteable(tls, pNew) != SQLITE_OK { Xsqlite3ValueFree(tls, pNew) pNew = uintptr(0) } @@ -60234,7 +59621,7 @@ func Xsqlite3_value_free(tls *libc.TLS, pOld uintptr) { /* sqlite3.c:83342:17: * // The invokeValueDestructor(P,X) routine invokes destructor function X() // on value P is not going to be used and need to be destroyed. func setResultStrOrError(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, enc U8, xDel uintptr) { /* sqlite3.c:83358:13: */ - if Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, n, enc, xDel) == 18 { + if Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, n, enc, xDel) == SQLITE_TOOBIG { Xsqlite3_result_error_toobig(tls, pCtx) } } @@ -60251,7 +59638,7 @@ func invokeValueDestructor(tls *libc.TLS, p uintptr, xDel uintptr, pCtx uintptr) if pCtx != 0 { Xsqlite3_result_error_toobig(tls, pCtx) } - return 18 + return SQLITE_TOOBIG } func Xsqlite3_result_blob(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) { /* sqlite3.c:83385:17: */ @@ -60275,14 +59662,14 @@ func Xsqlite3_result_double(tls *libc.TLS, pCtx uintptr, rVal float64) { /* sqli func Xsqlite3_result_error(tls *libc.TLS, pCtx uintptr, z uintptr, n int32) { /* sqlite3.c:83413:17: */ - (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = 1 - Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, n, uint8(1), libc.UintptrFromInt32(-1)) + (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = SQLITE_ERROR + Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, n, SQLITE_UTF8, libc.UintptrFromInt32(-1)) } func Xsqlite3_result_error16(tls *libc.TLS, pCtx uintptr, z uintptr, n int32) { /* sqlite3.c:83419:17: */ - (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = 1 - Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, n, uint8(2), libc.UintptrFromInt32(-1)) + (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = SQLITE_ERROR + Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, n, SQLITE_UTF16LE, libc.UintptrFromInt32(-1)) } func Xsqlite3_result_int(tls *libc.TLS, pCtx uintptr, iVal int32) { /* sqlite3.c:83425:17: */ @@ -60304,7 +59691,7 @@ func Xsqlite3_result_pointer(tls *libc.TLS, pCtx uintptr, pPtr uintptr, zPType u var pOut uintptr = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut Xsqlite3VdbeMemRelease(tls, pOut) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Null Xsqlite3VdbeMemSetPointer(tls, pOut, pPtr, zPType, xDestructor) } @@ -60312,18 +59699,18 @@ func Xsqlite3_result_subtype(tls *libc.TLS, pCtx uintptr, eSubtype uint32) { /* var pOut uintptr = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut (*Mem)(unsafe.Pointer(pOut)).FeSubtype = (U8(eSubtype & uint32(0xff))) - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((0x8000)) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((MEM_Subtype)) } func Xsqlite3_result_text(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) { /* sqlite3.c:83455:17: */ - setResultStrOrError(tls, pCtx, z, n, uint8(1), xDel) + setResultStrOrError(tls, pCtx, z, n, SQLITE_UTF8, xDel) } func Xsqlite3_result_text64(tls *libc.TLS, pCtx uintptr, z uintptr, n Sqlite3_uint64, xDel uintptr, enc uint8) { /* sqlite3.c:83464:17: */ - if int32(enc) == 4 { - enc = uint8(2) + if int32(enc) == SQLITE_UTF16 { + enc = SQLITE_UTF16LE } if n > uint64(0x7fffffff) { invokeValueDestructor(tls, z, xDel, pCtx) @@ -60334,17 +59721,17 @@ func Xsqlite3_result_text64(tls *libc.TLS, pCtx uintptr, z uintptr, n Sqlite3_ui func Xsqlite3_result_text16(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) { /* sqlite3.c:83481:17: */ - setResultStrOrError(tls, pCtx, z, n, uint8(2), xDel) + setResultStrOrError(tls, pCtx, z, n, SQLITE_UTF16LE, xDel) } func Xsqlite3_result_text16be(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) { /* sqlite3.c:83490:17: */ - setResultStrOrError(tls, pCtx, z, n, uint8(3), xDel) + setResultStrOrError(tls, pCtx, z, n, SQLITE_UTF16BE, xDel) } func Xsqlite3_result_text16le(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, xDel uintptr) { /* sqlite3.c:83499:17: */ - setResultStrOrError(tls, pCtx, z, n, uint8(2), xDel) + setResultStrOrError(tls, pCtx, z, n, SQLITE_UTF16LE, xDel) } func Xsqlite3_result_value(tls *libc.TLS, pCtx uintptr, pValue uintptr) { /* sqlite3.c:83509:17: */ @@ -60360,11 +59747,11 @@ func Xsqlite3_result_zeroblob(tls *libc.TLS, pCtx uintptr, n int32) { /* sqlite3 func Xsqlite3_result_zeroblob64(tls *libc.TLS, pCtx uintptr, n U64) int32 { /* sqlite3.c:83517:16: */ var pOut uintptr = (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut - if n > U64(*(*int32)(unsafe.Pointer(((*Mem)(unsafe.Pointer(pOut)).Fdb + 124 /* &.aLimit */) + uintptr(0)*4))) { - return 18 + if n > U64(*(*int32)(unsafe.Pointer(((*Mem)(unsafe.Pointer(pOut)).Fdb + 124 /* &.aLimit */)))) { + return SQLITE_TOOBIG } Xsqlite3VdbeMemSetZeroBlob(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, int32(n)) - return 0 + return SQLITE_OK } func Xsqlite3_result_error_code(tls *libc.TLS, pCtx uintptr, errCode int32) { /* sqlite3.c:83526:17: */ @@ -60374,25 +59761,25 @@ func Xsqlite3_result_error_code(tls *libc.TLS, pCtx uintptr, errCode int32) { /* } return -1 }() - if (int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fflags) & 0x0001) != 0 { + if (int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fflags) & MEM_Null) != 0 { Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, Xsqlite3ErrStr(tls, errCode), -1, - uint8(1), uintptr(0)) + SQLITE_UTF8, uintptr(0)) } } // Force an SQLITE_TOOBIG error. func Xsqlite3_result_error_toobig(tls *libc.TLS, pCtx uintptr) { /* sqlite3.c:83538:17: */ - (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = 18 + (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = SQLITE_TOOBIG Xsqlite3VdbeMemSetStr(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, ts+7050 /* "string or blob t..." */, -1, - uint8(1), uintptr(0)) + SQLITE_UTF8, uintptr(0)) } // An SQLITE_NOMEM error. func Xsqlite3_result_error_nomem(tls *libc.TLS, pCtx uintptr) { /* sqlite3.c:83546:17: */ Xsqlite3VdbeMemSetNull(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut) - (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = 7 + (*Sqlite3_context)(unsafe.Pointer(pCtx)).FisError = SQLITE_NOMEM Xsqlite3OomFault(tls, (*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fdb) } @@ -60401,16 +59788,16 @@ func Xsqlite3_result_error_nomem(tls *libc.TLS, pCtx uintptr) { /* sqlite3.c:835 // test-control. func Xsqlite3ResultIntReal(tls *libc.TLS, pCtx uintptr) { /* sqlite3.c:83558:21: */ - if (int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fflags) & 0x0004) != 0 { - *(*U16)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0004))) - *(*U16)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut + 8 /* &.flags */)) |= U16((0x0020)) + if (int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fflags) & MEM_Int) != 0 { + *(*U16)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Int))) + *(*U16)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut + 8 /* &.flags */)) |= U16((MEM_IntReal)) } } // This function is called after a transaction has been committed. It // invokes callbacks registered with sqlite3_wal_hook() as required. func doWalCallbacks(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:83572:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt @@ -60419,7 +59806,7 @@ func doWalCallbacks(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:83572:12: */ Xsqlite3BtreeEnter(tls, pBt) nEntry = Xsqlite3PagerWalCallback(tls, Xsqlite3BtreePager(tls, pBt)) Xsqlite3BtreeLeave(tls, pBt) - if ((nEntry > 0) && ((*Sqlite3)(unsafe.Pointer(db)).FxWalCallback != 0)) && (rc == 0) { + if ((nEntry > 0) && ((*Sqlite3)(unsafe.Pointer(db)).FxWalCallback != 0)) && (rc == SQLITE_OK) { rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32) int32)(unsafe.Pointer((db + 344 /* &.xWalCallback */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpWalArg, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).FzDbSName, nEntry) } } @@ -60438,7 +59825,7 @@ func sqlite3Step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:83602:12: */ var db uintptr var rc int32 - if !((*Vdbe)(unsafe.Pointer(p)).Fmagic != U32(0x2df20da3)) { + if !((*Vdbe)(unsafe.Pointer(p)).Fmagic != VDBE_MAGIC_RUN) { goto __1 } // We used to require that sqlite3_reset() be called before retrying @@ -60465,17 +59852,17 @@ __1: if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __2 } - (*Vdbe)(unsafe.Pointer(p)).Frc = 7 - return 7 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM + return SQLITE_NOMEM __2: ; if !(((*Vdbe)(unsafe.Pointer(p)).Fpc < 0) && ((Bft(int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.expired */)) & 0x3 >> 0))) != 0)) { goto __3 } - (*Vdbe)(unsafe.Pointer(p)).Frc = 17 - rc = 1 - if !((int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags) & 0x80) != 0) { + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_SCHEMA + rc = SQLITE_ERROR + if !((int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags) & SQLITE_PREPARE_SAVESQL) != 0) { goto __4 } // If this statement was prepared using saved SQL and an @@ -60500,7 +59887,7 @@ __3: __6: ; - if !((((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & (0x02 | 0x80)) != 0) && + if !((((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & (SQLITE_TRACE_PROFILE | SQLITE_TRACE_XPROFILE)) != 0) && !(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0)) && ((*Vdbe)(unsafe.Pointer(p)).FzSql != 0)) { goto __7 } @@ -60540,7 +59927,7 @@ __11: __12: ; - if !(rc != 100) { + if !(rc != SQLITE_ROW) { goto __13 } // If the statement completed successfully, invoke the profile callback @@ -60551,20 +59938,20 @@ __12: __14: ; - if !((rc == 101) && ((*Sqlite3)(unsafe.Pointer(db)).FautoCommit != 0)) { + if !((rc == SQLITE_DONE) && ((*Sqlite3)(unsafe.Pointer(db)).FautoCommit != 0)) { goto __15 } (*Vdbe)(unsafe.Pointer(p)).Frc = doWalCallbacks(tls, db) - if !((*Vdbe)(unsafe.Pointer(p)).Frc != 0) { + if !((*Vdbe)(unsafe.Pointer(p)).Frc != SQLITE_OK) { goto __17 } - rc = 1 + rc = SQLITE_ERROR __17: ; goto __16 __15: - if !((rc != 101) && ((int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags) & 0x80) != 0)) { + if !((rc != SQLITE_DONE) && ((int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags) & SQLITE_PREPARE_SAVESQL) != 0)) { goto __18 } // If this statement was prepared using saved SQL and an @@ -60579,11 +59966,11 @@ __13: ; (*Sqlite3)(unsafe.Pointer(db)).FerrCode = rc - if !(7 == Xsqlite3ApiExit(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, (*Vdbe)(unsafe.Pointer(p)).Frc)) { + if !(SQLITE_NOMEM == Xsqlite3ApiExit(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, (*Vdbe)(unsafe.Pointer(p)).Frc)) { goto __19 } - (*Vdbe)(unsafe.Pointer(p)).Frc = 7 - if !((int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags) & 0x80) != 0) { + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM + if !((int32((*Vdbe)(unsafe.Pointer(p)).FprepFlags) & SQLITE_PREPARE_SAVESQL) != 0) { goto __20 } rc = (*Vdbe)(unsafe.Pointer(p)).Frc @@ -60602,10 +59989,10 @@ end_of_step: // sqlite3Step() to do most of the work. If a schema error occurs, // call sqlite3Reprepare() and try again. func Xsqlite3_step(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83736:16: */ - var rc int32 = 0 // Result from sqlite3Step() - var v uintptr = pStmt // the prepared statement - var cnt int32 = 0 // Counter to prevent infinite loop of reprepares - var db uintptr // The database connection + var rc int32 = SQLITE_OK // Result from sqlite3Step() + var v uintptr = pStmt // the prepared statement + var cnt int32 = 0 // Counter to prevent infinite loop of reprepares + var db uintptr // The database connection if vdbeSafetyNotNull(tls, v) != 0 { return Xsqlite3MisuseError(tls, 83743) @@ -60613,11 +60000,11 @@ func Xsqlite3_step(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83736:16: db = (*Vdbe)(unsafe.Pointer(v)).Fdb Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) (*Vdbe)(unsafe.Pointer(v)).FdoingRerun = U8(0) - for ((libc.AssignInt32(&rc, sqlite3Step(tls, v))) == 17) && - (libc.PostIncInt32(&cnt, 1) < 50) { + for ((libc.AssignInt32(&rc, sqlite3Step(tls, v))) == SQLITE_SCHEMA) && + (libc.PostIncInt32(&cnt, 1) < SQLITE_MAX_SCHEMA_RETRY) { var savedPc int32 = (*Vdbe)(unsafe.Pointer(v)).Fpc rc = Xsqlite3Reprepare(tls, v) - if rc != 0 { + if rc != SQLITE_OK { // This case occurs after failing to recompile an sql statement. // The error message from the SQL compiler has already been loaded // into the database handle. This block copies the error message @@ -60632,7 +60019,7 @@ func Xsqlite3_step(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:83736:16: (*Vdbe)(unsafe.Pointer(v)).Frc = libc.AssignInt32(&rc, Xsqlite3ApiExit(tls, db, rc)) } else { (*Vdbe)(unsafe.Pointer(v)).FzErrMsg = uintptr(0) - (*Vdbe)(unsafe.Pointer(v)).Frc = libc.AssignInt32(&rc, 7) + (*Vdbe)(unsafe.Pointer(v)).Frc = libc.AssignInt32(&rc, SQLITE_NOMEM) } break } @@ -60719,7 +60106,7 @@ func createAggContext(tls *libc.TLS, p uintptr, nByte int32) uintptr { /* sqlite (*Mem)(unsafe.Pointer(pMem)).Fz = uintptr(0) } else { Xsqlite3VdbeMemClearAndResize(tls, pMem, nByte) - (*Mem)(unsafe.Pointer(pMem)).Fflags = U16(0x2000) + (*Mem)(unsafe.Pointer(pMem)).Fflags = MEM_Agg *(*uintptr)(unsafe.Pointer(pMem /* &.u */)) = (*Sqlite3_context)(unsafe.Pointer(p)).FpFunc if (*Mem)(unsafe.Pointer(pMem)).Fz != 0 { libc.Xmemset(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, 0, uint64(nByte)) @@ -60733,7 +60120,7 @@ func createAggContext(tls *libc.TLS, p uintptr, nByte int32) uintptr { /* sqlite // same context that was returned on prior calls. func Xsqlite3_aggregate_context(tls *libc.TLS, p uintptr, nByte int32) uintptr { /* sqlite3.c:83873:17: */ - if (int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(p)).FpMem)).Fflags) & 0x2000) == 0 { + if (int32((*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(p)).FpMem)).Fflags) & MEM_Agg) == 0 { return createAggContext(tls, p, nByte) } else { return (*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(p)).FpMem)).Fz @@ -60882,28 +60269,7 @@ func columnNullValue(tls *libc.TLS) uintptr { /* sqlite3.c:84002:18: */ } var nullMem = Mem{ - /* .u = */ Fu: - /* .u = */ MemValue{}, - Fflags: - /* .flags = */ U16(0x0001), - Fenc: - /* .enc = */ U8(0), - FeSubtype: - /* .eSubtype = */ U8(0), - Fn: - /* .n = */ 0, - Fz: - /* .z = */ uintptr(0), - FzMalloc: - /* .zMalloc = */ uintptr(0), - FszMalloc: - /* .szMalloc = */ 0, - FuTemp: - /* .uTemp = */ U32(0), - Fdb: - /* .db = */ uintptr(0), - FxDel: - /* .xDel = */ uintptr(0), + /* .flags = */ Fflags: MEM_Null, } /* sqlite3.c:84012:20 */ // Check to see if column iCol of the given statement is valid. If @@ -60923,7 +60289,7 @@ func columnMem(tls *libc.TLS, pStmt uintptr, i int32) uintptr { /* sqlite3.c:840 if (((*Vdbe)(unsafe.Pointer(pVm)).FpResultSet != uintptr(0)) && (i < int32((*Vdbe)(unsafe.Pointer(pVm)).FnResColumn))) && (i >= 0) { pOut = ((*Vdbe)(unsafe.Pointer(pVm)).FpResultSet + uintptr(i)*56) } else { - Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(pVm)).Fdb, 25) + Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(pVm)).Fdb, SQLITE_RANGE) pOut = columnNullValue(tls) } return pOut @@ -61010,9 +60376,9 @@ func Xsqlite3_column_text(tls *libc.TLS, pStmt uintptr, i int32) uintptr { /* sq func Xsqlite3_column_value(tls *libc.TLS, pStmt uintptr, i int32) uintptr { /* sqlite3.c:84137:26: */ var pOut uintptr = columnMem(tls, pStmt, i) - if (int32((*Mem)(unsafe.Pointer(pOut)).Fflags) & 0x0800) != 0 { - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0800))) - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((0x1000)) + if (int32((*Mem)(unsafe.Pointer(pOut)).Fflags) & MEM_Static) != 0 { + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Static))) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((MEM_Ephem)) } columnMallocFailure(tls, pStmt) return pOut @@ -61077,11 +60443,11 @@ func columnName(tls *libc.TLS, pStmt uintptr, N int32, useUtf16 int32, useType i // Return the name of the Nth column of the result set returned by SQL // statement pStmt. func Xsqlite3_column_name(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84224:23: */ - return columnName(tls, pStmt, N, 0, 0) + return columnName(tls, pStmt, N, 0, COLNAME_NAME) } func Xsqlite3_column_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84228:23: */ - return columnName(tls, pStmt, N, 1, 0) + return columnName(tls, pStmt, N, 1, COLNAME_NAME) } // Constraint: If you have ENABLE_COLUMN_METADATA then you must @@ -61090,44 +60456,44 @@ func Xsqlite3_column_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* // Return the column declaration type (if applicable) of the 'i'th column // of the result set of SQL statement pStmt. func Xsqlite3_column_decltype(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84247:23: */ - return columnName(tls, pStmt, N, 0, 1) + return columnName(tls, pStmt, N, 0, COLNAME_DECLTYPE) } func Xsqlite3_column_decltype16(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84251:23: */ - return columnName(tls, pStmt, N, 1, 1) + return columnName(tls, pStmt, N, 1, COLNAME_DECLTYPE) } // Return the name of the database from which a result column derives. // NULL is returned if the result column is an expression or constant or // anything else which is not an unambiguous reference to a database column. func Xsqlite3_column_database_name(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84263:23: */ - return columnName(tls, pStmt, N, 0, 2) + return columnName(tls, pStmt, N, 0, COLNAME_DATABASE) } func Xsqlite3_column_database_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84267:23: */ - return columnName(tls, pStmt, N, 1, 2) + return columnName(tls, pStmt, N, 1, COLNAME_DATABASE) } // Return the name of the table from which a result column derives. // NULL is returned if the result column is an expression or constant or // anything else which is not an unambiguous reference to a database column. func Xsqlite3_column_table_name(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84277:23: */ - return columnName(tls, pStmt, N, 0, 3) + return columnName(tls, pStmt, N, 0, COLNAME_TABLE) } func Xsqlite3_column_table_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84281:23: */ - return columnName(tls, pStmt, N, 1, 3) + return columnName(tls, pStmt, N, 1, COLNAME_TABLE) } // Return the name of the table column from which a result column derives. // NULL is returned if the result column is an expression or constant or // anything else which is not an unambiguous reference to a database column. func Xsqlite3_column_origin_name(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84291:23: */ - return columnName(tls, pStmt, N, 0, 4) + return columnName(tls, pStmt, N, 0, COLNAME_COLUMN) } func Xsqlite3_column_origin_name16(tls *libc.TLS, pStmt uintptr, N int32) uintptr { /* sqlite3.c:84295:23: */ - return columnName(tls, pStmt, N, 1, 4) + return columnName(tls, pStmt, N, 1, COLNAME_COLUMN) } // ****************************** sqlite3_bind_ *************************** @@ -61152,23 +60518,23 @@ func vdbeUnbind(tls *libc.TLS, p uintptr, i int32) int32 { /* sqlite3.c:84317:12 return Xsqlite3MisuseError(tls, 84320) } Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) - if ((*Vdbe)(unsafe.Pointer(p)).Fmagic != U32(0x2df20da3)) || ((*Vdbe)(unsafe.Pointer(p)).Fpc >= 0) { - Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, 21) + if ((*Vdbe)(unsafe.Pointer(p)).Fmagic != VDBE_MAGIC_RUN) || ((*Vdbe)(unsafe.Pointer(p)).Fpc >= 0) { + Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, SQLITE_MISUSE) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) - Xsqlite3_log(tls, 21, + Xsqlite3_log(tls, SQLITE_MISUSE, ts+7073 /* "bind on a busy p..." */, libc.VaList(bp, (*Vdbe)(unsafe.Pointer(p)).FzSql)) return Xsqlite3MisuseError(tls, 84328) } if (i < 1) || (i > int32((*Vdbe)(unsafe.Pointer(p)).FnVar)) { - Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, 25) + Xsqlite3Error(tls, (*Vdbe)(unsafe.Pointer(p)).Fdb, SQLITE_RANGE) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) - return 25 + return SQLITE_RANGE } i-- pVar = ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr(i)*56) Xsqlite3VdbeMemRelease(tls, pVar) - (*Mem)(unsafe.Pointer(pVar)).Fflags = U16(0x0001) - (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FerrCode = 0 + (*Mem)(unsafe.Pointer(pVar)).Fflags = MEM_Null + (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).FerrCode = SQLITE_OK // If the bit corresponding to this variable in Vdbe.expmask is set, then // binding a new value to this variable invalidates the current query plan. @@ -61187,7 +60553,7 @@ func vdbeUnbind(tls *libc.TLS, p uintptr, i int32) int32 { /* sqlite3.c:84317:12 }())) != U32(0)) { libc.SetBitFieldPtr16Uint32(p+200 /* &.expired */, Bft(1), 0, 0x3) } - return 0 + return SQLITE_OK } // Bind a text or BLOB value. @@ -61197,11 +60563,11 @@ func bindText(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData int32, var rc int32 rc = vdbeUnbind(tls, p, i) - if rc == 0 { + if rc == SQLITE_OK { if zData != uintptr(0) { pVar = ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((i-1))*56) rc = Xsqlite3VdbeMemSetStr(tls, pVar, zData, nData, encoding, xDel) - if (rc == 0) && (int32(encoding) != 0) { + if (rc == SQLITE_OK) && (int32(encoding) != 0) { rc = Xsqlite3VdbeChangeEncoding(tls, pVar, int32((*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fenc)) } if rc != 0 { @@ -61235,7 +60601,7 @@ func Xsqlite3_bind_double(tls *libc.TLS, pStmt uintptr, i int32, rValue float64) var rc int32 var p uintptr = pStmt rc = vdbeUnbind(tls, p, i) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3VdbeMemSetDouble(tls, ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((i-1))*56), rValue) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) } @@ -61250,7 +60616,7 @@ func Xsqlite3_bind_int64(tls *libc.TLS, pStmt uintptr, i int32, iValue Sqlite_in var rc int32 var p uintptr = pStmt rc = vdbeUnbind(tls, p, i) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3VdbeMemSetInt64(tls, ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((i-1))*56), iValue) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) } @@ -61261,7 +60627,7 @@ func Xsqlite3_bind_null(tls *libc.TLS, pStmt uintptr, i int32) int32 { /* sqlite var rc int32 var p uintptr = pStmt rc = vdbeUnbind(tls, p, i) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) } return rc @@ -61271,7 +60637,7 @@ func Xsqlite3_bind_pointer(tls *libc.TLS, pStmt uintptr, i int32, pPtr uintptr, var rc int32 var p uintptr = pStmt rc = vdbeUnbind(tls, p, i) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3VdbeMemSetPointer(tls, ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((i-1))*56), pPtr, zPTtype, xDestructor) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) } else if xDestructor != 0 { @@ -61281,7 +60647,7 @@ func Xsqlite3_bind_pointer(tls *libc.TLS, pStmt uintptr, i int32, pPtr uintptr, } func Xsqlite3_bind_text(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData int32, xDel uintptr) int32 { /* sqlite3.c:84472:16: */ - return bindText(tls, pStmt, i, zData, nData, xDel, uint8(1)) + return bindText(tls, pStmt, i, zData, nData, xDel, SQLITE_UTF8) } func Xsqlite3_bind_text64(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData Sqlite3_uint64, xDel uintptr, enc uint8) int32 { /* sqlite3.c:84481:16: */ @@ -61289,8 +60655,8 @@ func Xsqlite3_bind_text64(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, if nData > uint64(0x7fffffff) { return invokeValueDestructor(tls, zData, xDel, uintptr(0)) } else { - if int32(enc) == 4 { - enc = uint8(2) + if int32(enc) == SQLITE_UTF16 { + enc = SQLITE_UTF16LE } return bindText(tls, pStmt, i, zData, int32(nData), xDel, enc) } @@ -61298,27 +60664,27 @@ func Xsqlite3_bind_text64(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, } func Xsqlite3_bind_text16(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData int32, xDel uintptr) int32 { /* sqlite3.c:84498:16: */ - return bindText(tls, pStmt, i, zData, nData, xDel, uint8(2)) + return bindText(tls, pStmt, i, zData, nData, xDel, SQLITE_UTF16LE) } func Xsqlite3_bind_value(tls *libc.TLS, pStmt uintptr, i int32, pValue uintptr) int32 { /* sqlite3.c:84508:16: */ var rc int32 switch Xsqlite3_value_type(tls, pValue) { - case 1: + case SQLITE_INTEGER: { rc = Xsqlite3_bind_int64(tls, pStmt, i, *(*I64)(unsafe.Pointer(pValue /* &.u */))) break } - case 2: + case SQLITE_FLOAT: { rc = Xsqlite3_bind_double(tls, pStmt, i, *(*float64)(unsafe.Pointer(pValue /* &.u */))) break } - case 4: + case SQLITE_BLOB: { - if (int32((*Sqlite3_value)(unsafe.Pointer(pValue)).Fflags) & 0x4000) != 0 { + if (int32((*Sqlite3_value)(unsafe.Pointer(pValue)).Fflags) & MEM_Zero) != 0 { rc = Xsqlite3_bind_zeroblob(tls, pStmt, i, *(*int32)(unsafe.Pointer(pValue /* &.u */))) } else { rc = Xsqlite3_bind_blob(tls, pStmt, i, (*Sqlite3_value)(unsafe.Pointer(pValue)).Fz, (*Sqlite3_value)(unsafe.Pointer(pValue)).Fn, libc.UintptrFromInt32(-1)) @@ -61326,7 +60692,7 @@ func Xsqlite3_bind_value(tls *libc.TLS, pStmt uintptr, i int32, pValue uintptr) break } - case 3: + case SQLITE_TEXT: { rc = bindText(tls, pStmt, i, (*Sqlite3_value)(unsafe.Pointer(pValue)).Fz, (*Sqlite3_value)(unsafe.Pointer(pValue)).Fn, libc.UintptrFromInt32(-1), (*Sqlite3_value)(unsafe.Pointer(pValue)).Fenc) @@ -61347,7 +60713,7 @@ func Xsqlite3_bind_zeroblob(tls *libc.TLS, pStmt uintptr, i int32, n int32) int3 var rc int32 var p uintptr = pStmt rc = vdbeUnbind(tls, p, i) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3VdbeMemSetZeroBlob(tls, ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((i-1))*56), n) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) } @@ -61358,8 +60724,8 @@ func Xsqlite3_bind_zeroblob64(tls *libc.TLS, pStmt uintptr, i int32, n Sqlite3_u var rc int32 var p uintptr = pStmt Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).Fdb)).Fmutex) - if n > U64(*(*int32)(unsafe.Pointer(((*Vdbe)(unsafe.Pointer(p)).Fdb + 124 /* &.aLimit */) + uintptr(0)*4))) { - rc = 18 + if n > U64(*(*int32)(unsafe.Pointer(((*Vdbe)(unsafe.Pointer(p)).Fdb + 124 /* &.aLimit */)))) { + rc = SQLITE_TOOBIG } else { rc = Xsqlite3_bind_zeroblob(tls, pStmt, i, int32(n)) @@ -61416,7 +60782,7 @@ func Xsqlite3TransferBindings(tls *libc.TLS, pFromStmt uintptr, pToStmt uintptr) Xsqlite3VdbeMemMove(tls, ((*Vdbe)(unsafe.Pointer(pTo)).FaVar + uintptr(i)*56), ((*Vdbe)(unsafe.Pointer(pFrom)).FaVar + uintptr(i)*56)) } Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(pTo)).Fdb)).Fmutex) - return 0 + return SQLITE_OK } // Deprecated external interface. Internal/core SQLite code @@ -61433,7 +60799,7 @@ func Xsqlite3_transfer_bindings(tls *libc.TLS, pFromStmt uintptr, pToStmt uintpt var pFrom uintptr = pFromStmt var pTo uintptr = pToStmt if int32((*Vdbe)(unsafe.Pointer(pFrom)).FnVar) != int32((*Vdbe)(unsafe.Pointer(pTo)).FnVar) { - return 1 + return SQLITE_ERROR } if (*Vdbe)(unsafe.Pointer(pTo)).Fexpmask != 0 { @@ -61478,7 +60844,7 @@ func Xsqlite3_stmt_isexplain(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c: // Return true if the prepared statement is in need of being reset. func Xsqlite3_stmt_busy(tls *libc.TLS, pStmt uintptr) int32 { /* sqlite3.c:84675:16: */ var v uintptr = pStmt - return (libc.Bool32(((v != uintptr(0)) && ((*Vdbe)(unsafe.Pointer(v)).Fmagic == U32(0x2df20da3))) && ((*Vdbe)(unsafe.Pointer(v)).Fpc >= 0))) + return (libc.Bool32(((v != uintptr(0)) && ((*Vdbe)(unsafe.Pointer(v)).Fmagic == VDBE_MAGIC_RUN)) && ((*Vdbe)(unsafe.Pointer(v)).Fpc >= 0))) } // Return a pointer to the next prepared statement after pStmt associated @@ -61505,7 +60871,7 @@ func Xsqlite3_stmt_status(tls *libc.TLS, pStmt uintptr, op int32, resetFlag int3 var pVdbe uintptr = pStmt // var v U32 at bp, 4 - if op == 99 { + if op == SQLITE_STMTSTATUS_MEMUSED { var db uintptr = (*Vdbe)(unsafe.Pointer(pVdbe)).Fdb Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) *(*U32)(unsafe.Pointer(bp /* v */)) = U32(0) @@ -61574,11 +60940,11 @@ func Xsqlite3_preupdate_old(tls *libc.TLS, db uintptr, iIdx int32, ppValue uintp var nRec U32 var aRec uintptr p = (*Sqlite3)(unsafe.Pointer(db)).FpPreUpdate - rc = 0 + rc = SQLITE_OK // Test that this call is being made from within an SQLITE_DELETE or // SQLITE_UPDATE pre-update callback, and that iIdx is within range. - if !(!(p != 0) || ((*PreUpdate)(unsafe.Pointer(p)).Fop == 18)) { + if !(!(p != 0) || ((*PreUpdate)(unsafe.Pointer(p)).Fop == SQLITE_INSERT)) { goto __1 } rc = Xsqlite3MisuseError(tls, 84816) @@ -61594,7 +60960,7 @@ __2: if !((iIdx >= int32((*VdbeCursor)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpCsr)).FnField)) || (iIdx < 0)) { goto __3 } - rc = 25 + rc = SQLITE_RANGE goto preupdate_old_out __3: ; @@ -61613,19 +60979,19 @@ __3: __5: ; rc = Xsqlite3BtreePayload(tls, *(*uintptr)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpCsr + 56 /* &.uc */)), uint32(0), nRec, aRec) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __6 } (*PreUpdate)(unsafe.Pointer(p)).FpUnpacked = vdbeUnpackRecord(tls, (p + 32 /* &.keyinfo */), int32(nRec), aRec) if !(!(int32((*PreUpdate)(unsafe.Pointer(p)).FpUnpacked) != 0)) { goto __7 } - rc = 7 + rc = SQLITE_NOMEM __7: ; __6: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __8 } Xsqlite3DbFree(tls, db, aRec) @@ -61649,10 +61015,10 @@ __9: *(*uintptr)(unsafe.Pointer(ppValue)) = columnNullValue(tls) goto __12 __11: - if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpTab)).FaCol+uintptr(iIdx)*32)).Faffinity) == 0x45) { + if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpTab)).FaCol+uintptr(iIdx)*32)).Faffinity) == SQLITE_AFF_REAL) { goto __13 } - if !((int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0004 | 0x0020)) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Int | MEM_IntReal)) != 0) { goto __14 } @@ -61713,16 +61079,16 @@ func Xsqlite3_preupdate_new(tls *libc.TLS, db uintptr, iIdx int32, ppValue uintp // that is being inserted. Deserialize it. var pUnpack uintptr p = (*Sqlite3)(unsafe.Pointer(db)).FpPreUpdate - rc = 0 + rc = SQLITE_OK - if !(!(p != 0) || ((*PreUpdate)(unsafe.Pointer(p)).Fop == 9)) { + if !(!(p != 0) || ((*PreUpdate)(unsafe.Pointer(p)).Fop == SQLITE_DELETE)) { goto __1 } rc = Xsqlite3MisuseError(tls, 84906) goto preupdate_new_out __1: ; - if !(((*PreUpdate)(unsafe.Pointer(p)).FpPk != 0) && ((*PreUpdate)(unsafe.Pointer(p)).Fop != 23)) { + if !(((*PreUpdate)(unsafe.Pointer(p)).FpPk != 0) && ((*PreUpdate)(unsafe.Pointer(p)).Fop != SQLITE_UPDATE)) { goto __2 } iIdx = int32(Xsqlite3TableColumnToIndex(tls, (*PreUpdate)(unsafe.Pointer(p)).FpPk, int16(iIdx))) @@ -61731,12 +61097,12 @@ __2: if !((iIdx >= int32((*VdbeCursor)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).FpCsr)).FnField)) || (iIdx < 0)) { goto __3 } - rc = 25 + rc = SQLITE_RANGE goto preupdate_new_out __3: ; - if !((*PreUpdate)(unsafe.Pointer(p)).Fop == 18) { + if !((*PreUpdate)(unsafe.Pointer(p)).Fop == SQLITE_INSERT) { goto __4 } // For an INSERT, memory cell p->iNewReg contains the serialized record @@ -61747,12 +61113,12 @@ __3: } pData = ((*Vdbe)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).Fv)).FaMem + uintptr((*PreUpdate)(unsafe.Pointer(p)).FiNewReg)*56) rc = func() int32 { - if (int32((*Mem)(unsafe.Pointer((pData))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pData))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pData) } return 0 }() - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __7 } goto preupdate_new_out @@ -61762,7 +61128,7 @@ __7: if !(!(pUnpack != 0)) { goto __8 } - rc = 7 + rc = SQLITE_NOMEM goto preupdate_new_out __8: ; @@ -61798,7 +61164,7 @@ __4: if !(!(int32((*PreUpdate)(unsafe.Pointer(p)).FaNew) != 0)) { goto __13 } - rc = 7 + rc = SQLITE_NOMEM goto preupdate_new_out __13: ; @@ -61816,7 +61182,7 @@ __12: goto __16 __15: rc = Xsqlite3VdbeMemCopy(tls, pMem, ((*Vdbe)(unsafe.Pointer((*PreUpdate)(unsafe.Pointer(p)).Fv)).FaMem + uintptr((((*PreUpdate)(unsafe.Pointer(p)).FiNewReg+1)+iIdx))*56)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __17 } goto preupdate_new_out @@ -61869,10 +61235,10 @@ func findNextHostParameter(tls *libc.TLS, zSql uintptr, pnToken uintptr) int32 { var n int32 *(*int32)(unsafe.Pointer(pnToken)) = 0 - for *(*int8)(unsafe.Pointer(zSql + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(zSql)) != 0 { n = Xsqlite3GetToken(tls, zSql, bp /* &tokenType */) - if *(*int32)(unsafe.Pointer(bp /* tokenType */)) == 153 { + if *(*int32)(unsafe.Pointer(bp /* tokenType */)) == TK_VARIABLE { *(*int32)(unsafe.Pointer(pnToken)) = n break } @@ -61925,7 +61291,7 @@ func Xsqlite3VdbeExpandSql(tls *libc.TLS, p uintptr, zRawSql uintptr) uintptr { db = (*Vdbe)(unsafe.Pointer(p)).Fdb Xsqlite3StrAccumInit(tls, bp+48 /* &out */, uintptr(0), bp+80 /* &zBase[0] */, int32(unsafe.Sizeof([100]int8{})), - *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) + *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeExec > 1 { for *(*int8)(unsafe.Pointer(zRawSql)) != 0 { var zStart uintptr = zRawSql @@ -61938,7 +61304,7 @@ func Xsqlite3VdbeExpandSql(tls *libc.TLS, p uintptr, zRawSql uintptr) uintptr { } else if int32((*Vdbe)(unsafe.Pointer(p)).FnVar) == 0 { Xsqlite3_str_append(tls, bp+48 /* &out */, zRawSql, Xsqlite3Strlen30(tls, zRawSql)) } else { - for *(*int8)(unsafe.Pointer(zRawSql + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(zRawSql)) != 0 { n = findNextHostParameter(tls, zRawSql, bp+180 /* &nToken */) Xsqlite3_str_append(tls, bp+48 /* &out */, zRawSql, n) @@ -61947,10 +61313,10 @@ func Xsqlite3VdbeExpandSql(tls *libc.TLS, p uintptr, zRawSql uintptr) uintptr { if *(*int32)(unsafe.Pointer(bp + 180 /* nToken */)) == 0 { break } - if int32(*(*int8)(unsafe.Pointer(zRawSql + uintptr(0)))) == '?' { + if int32(*(*int8)(unsafe.Pointer(zRawSql))) == '?' { if *(*int32)(unsafe.Pointer(bp + 180 /* nToken */)) > 1 { - Xsqlite3GetInt32(tls, (zRawSql + uintptr(1)), bp+184 /* &idx */) + Xsqlite3GetInt32(tls, (zRawSql + 1), bp+184 /* &idx */) } else { *(*int32)(unsafe.Pointer(bp + 184 /* idx */)) = nextIndex } @@ -61963,31 +61329,31 @@ func Xsqlite3VdbeExpandSql(tls *libc.TLS, p uintptr, zRawSql uintptr) uintptr { nextIndex = (*(*int32)(unsafe.Pointer(bp + 184 /* idx */)) + 1) pVar = ((*Vdbe)(unsafe.Pointer(p)).FaVar + uintptr((*(*int32)(unsafe.Pointer(bp + 184 /* idx */))-1))*56) - if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & 0x0001) != 0 { + if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & MEM_Null) != 0 { Xsqlite3_str_append(tls, bp+48 /* &out */, ts+801 /* "NULL" */, 4) - } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & (0x0004 | 0x0020)) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & (MEM_Int | MEM_IntReal)) != 0 { Xsqlite3_str_appendf(tls, bp+48 /* &out */, ts+6689 /* "%lld" */, libc.VaList(bp, *(*I64)(unsafe.Pointer(pVar /* &.u */)))) - } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & 0x0008) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & MEM_Real) != 0 { Xsqlite3_str_appendf(tls, bp+48 /* &out */, ts+6578 /* "%!.15g" */, libc.VaList(bp+8, *(*float64)(unsafe.Pointer(pVar /* &.u */)))) - } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & 0x0002) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & MEM_Str) != 0 { var nOut int32 // Number of bytes of the string text to include in output var enc U8 = (*Sqlite3)(unsafe.Pointer(db)).Fenc - if int32(enc) != 1 { + if int32(enc) != SQLITE_UTF8 { libc.Xmemset(tls, bp+192 /* &utf8 */, 0, uint64(unsafe.Sizeof(Mem{}))) (*Mem)(unsafe.Pointer(bp + 192 /* &utf8 */)).Fdb = db Xsqlite3VdbeMemSetStr(tls, bp+192 /* &utf8 */, (*Mem)(unsafe.Pointer(pVar)).Fz, (*Mem)(unsafe.Pointer(pVar)).Fn, enc, uintptr(0)) - if 7 == Xsqlite3VdbeChangeEncoding(tls, bp+192 /* &utf8 */, 1) { - (*StrAccum)(unsafe.Pointer(bp + 48 /* &out */)).FaccError = U8(7) + if SQLITE_NOMEM == Xsqlite3VdbeChangeEncoding(tls, bp+192 /* &utf8 */, SQLITE_UTF8) { + (*StrAccum)(unsafe.Pointer(bp + 48 /* &out */)).FaccError = SQLITE_NOMEM (*StrAccum)(unsafe.Pointer(bp + 48 /* &out */)).FnAlloc = U32(0) } pVar = bp + 192 /* &utf8 */ } nOut = (*Mem)(unsafe.Pointer(pVar)).Fn Xsqlite3_str_appendf(tls, bp+48 /* &out */, ts+7117 /* "'%.*q'" */, libc.VaList(bp+16, nOut, (*Mem)(unsafe.Pointer(pVar)).Fz)) - if int32(enc) != 1 { + if int32(enc) != SQLITE_UTF8 { Xsqlite3VdbeMemRelease(tls, bp+192 /* &utf8 */) } - } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & 0x4000) != 0 { + } else if (int32((*Mem)(unsafe.Pointer(pVar)).Fflags) & MEM_Zero) != 0 { Xsqlite3_str_appendf(tls, bp+48 /* &out */, ts+7124 /* "zeroblob(%d)" */, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(pVar /* &.u */)))) } else { var nOut int32 // Number of bytes of the blob to include in output @@ -62068,7 +61434,7 @@ var Xsqlite3_sort_count int32 = 0 /* sqlite3.c:85308:16 */ var Xsqlite3_max_blobsize int32 = 0 /* sqlite3.c:85319:16 */ func updateMaxBlobsize(tls *libc.TLS, p uintptr) { /* sqlite3.c:85320:13: */ - if ((int32((*Mem)(unsafe.Pointer(p)).Fflags) & (0x0002 | 0x0010)) != 0) && ((*Mem)(unsafe.Pointer(p)).Fn > Xsqlite3_max_blobsize) { + if ((int32((*Mem)(unsafe.Pointer(p)).Fflags) & (MEM_Str | MEM_Blob)) != 0) && ((*Mem)(unsafe.Pointer(p)).Fn > Xsqlite3_max_blobsize) { Xsqlite3_max_blobsize = (*Mem)(unsafe.Pointer(p)).Fn } } @@ -62162,8 +61528,8 @@ func allocateCursor(tls *libc.TLS, p uintptr, iCur int32, nField int32, iDb int3 } var nByte int32 var pCx uintptr = uintptr(0) - nByte = (int32(((((uint64(unsafe.Sizeof(VdbeCursor{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)) + ((uint64(2) * uint64(unsafe.Sizeof(U32(0)))) * uint64(nField))) + (func() uint64 { - if int32(eCurType) == 0 { + nByte = (int32(((((uint64(unsafe.Sizeof(VdbeCursor{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))) + ((uint64(2) * uint64(unsafe.Sizeof(U32(0)))) * uint64(nField))) + (func() uint64 { + if int32(eCurType) == CURTYPE_BTREE { return uint64(Xsqlite3BtreeCursorSize(tls)) } return uint64(0) @@ -62180,15 +61546,15 @@ func allocateCursor(tls *libc.TLS, p uintptr, iCur int32, nField int32, iDb int3 Xsqlite3VdbeFreeCursor(tls, p, *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8))) *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8)) = uintptr(0) } - if 0 == Xsqlite3VdbeMemClearAndResize(tls, pMem, nByte) { + if SQLITE_OK == Xsqlite3VdbeMemClearAndResize(tls, pMem, nByte) { *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr(iCur)*8)) = libc.AssignUintptr(&pCx, (*Mem)(unsafe.Pointer(pMem)).Fz) libc.Xmemset(tls, pCx, 0, uint64((uintptr(0) + 48 /* &.pAltCursor */))) (*VdbeCursor)(unsafe.Pointer(pCx)).FeCurType = eCurType (*VdbeCursor)(unsafe.Pointer(pCx)).FiDb = I8(iDb) (*VdbeCursor)(unsafe.Pointer(pCx)).FnField = I16(nField) (*VdbeCursor)(unsafe.Pointer(pCx)).FaOffset = ((pCx + 120 /* &.aType */) + uintptr(nField)*4) - if int32(eCurType) == 0 { - *(*uintptr)(unsafe.Pointer(pCx + 56 /* &.uc */)) = ((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(((((uint64(unsafe.Sizeof(VdbeCursor{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)) + ((uint64(2) * uint64(unsafe.Sizeof(U32(0)))) * uint64(nField))))) + if int32(eCurType) == CURTYPE_BTREE { + *(*uintptr)(unsafe.Pointer(pCx + 56 /* &.uc */)) = ((*Mem)(unsafe.Pointer(pMem)).Fz + uintptr(((((uint64(unsafe.Sizeof(VdbeCursor{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))) + ((uint64(2) * uint64(unsafe.Sizeof(U32(0)))) * uint64(nField))))) Xsqlite3BtreeCursorZero(tls, *(*uintptr)(unsafe.Pointer(pCx + 56 /* &.uc */))) } } @@ -62235,10 +61601,10 @@ func applyNumericAffinity(tls *libc.TLS, pRec uintptr, bTryForInt int32) { /* sq return } if (rc == 1) && (alsoAnInt(tls, pRec, *(*float64)(unsafe.Pointer(bp /* rValue */)), (pRec /* &.u */ /* &.i */)) != 0) { - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((MEM_Int)) } else { *(*float64)(unsafe.Pointer(pRec /* &.u */)) = *(*float64)(unsafe.Pointer(bp /* rValue */)) - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((MEM_Real)) if bTryForInt != 0 { Xsqlite3VdbeIntegerAffinity(tls, pRec) } @@ -62247,7 +61613,7 @@ func applyNumericAffinity(tls *libc.TLS, pRec uintptr, bTryForInt int32) { /* sq // string representation after computing a numeric equivalent, because the // string representation might not be the canonical representation for the // numeric value. Ticket [343634942dd54ab57b7024] 2018-01-31. - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0002))) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Str))) } // Processing is determine by the affinity parameter: @@ -62268,30 +61634,30 @@ func applyNumericAffinity(tls *libc.TLS, pRec uintptr, bTryForInt int32) { /* sq // SQLITE_AFF_NONE: // No-op. pRec is unchanged. func applyAffinity(tls *libc.TLS, pRec uintptr, affinity int8, enc U8) { /* sqlite3.c:85607:13: */ - if int32(affinity) >= 0x43 { + if int32(affinity) >= SQLITE_AFF_NUMERIC { - if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0004) == 0 { //OPTIMIZATION-IF-FALSE - if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0008) == 0 { - if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0002) != 0 { + if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Int) == 0 { //OPTIMIZATION-IF-FALSE + if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Real) == 0 { + if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Str) != 0 { applyNumericAffinity(tls, pRec, 1) } } else { Xsqlite3VdbeIntegerAffinity(tls, pRec) } } - } else if int32(affinity) == 0x42 { + } else if int32(affinity) == SQLITE_AFF_TEXT { // Only attempt the conversion to TEXT if there is an integer or real // representation (blob and NULL do not get converted) but no string // representation. It would be harmless to repeat the conversion if // there is already a string rep, but it is pointless to waste those // CPU cycles. - if 0 == (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0002) { //OPTIMIZATION-IF-FALSE - if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & ((0x0008 | 0x0004) | 0x0020)) != 0 { + if 0 == (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Str) { //OPTIMIZATION-IF-FALSE + if (int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & ((MEM_Real | MEM_Int) | MEM_IntReal)) != 0 { Xsqlite3VdbeMemStringify(tls, pRec, enc, uint8(1)) } } - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(((0x0008 | 0x0004) | 0x0020)))) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(((MEM_Real | MEM_Int) | MEM_IntReal)))) } } @@ -62301,7 +61667,7 @@ func applyAffinity(tls *libc.TLS, pRec uintptr, affinity int8, enc U8) { /* sqli // loss of information and return the revised type of the argument. func Xsqlite3_value_numeric_type(tls *libc.TLS, pVal uintptr) int32 { /* sqlite3.c:85646:16: */ var eType int32 = Xsqlite3_value_type(tls, pVal) - if eType == 3 { + if eType == SQLITE_TEXT { var pMem uintptr = pVal applyNumericAffinity(tls, pMem, 0) eType = Xsqlite3_value_type(tls, pVal) @@ -62326,7 +61692,7 @@ func computeNumericType(tls *libc.TLS, pMem uintptr) U16 { /* sqlite3.c:85674:28 var rc int32 // var ix Sqlite3_int64 at bp, 8 - if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pMem))).Fflags) & MEM_Zero) != 0 { Xsqlite3VdbeMemExpandBlob(tls, pMem) } else { } @@ -62334,15 +61700,15 @@ func computeNumericType(tls *libc.TLS, pMem uintptr) U16 { /* sqlite3.c:85674:28 if rc <= 0 { if (rc == 0) && (Xsqlite3Atoi64(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, bp /* &ix */, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc) <= 1) { *(*I64)(unsafe.Pointer(pMem /* &.u */)) = *(*Sqlite3_int64)(unsafe.Pointer(bp /* ix */)) - return U16(0x0004) + return MEM_Int } else { - return U16(0x0008) + return MEM_Real } } else if (rc == 1) && (Xsqlite3Atoi64(tls, (*Mem)(unsafe.Pointer(pMem)).Fz, bp /* &ix */, (*Mem)(unsafe.Pointer(pMem)).Fn, (*Mem)(unsafe.Pointer(pMem)).Fenc) == 0) { *(*I64)(unsafe.Pointer(pMem /* &.u */)) = *(*Sqlite3_int64)(unsafe.Pointer(bp /* ix */)) - return U16(0x0004) + return MEM_Int } - return U16(0x0008) + return MEM_Real } // Return the numeric type for pMem, either MEM_Int or MEM_Real or both or @@ -62351,11 +61717,11 @@ func computeNumericType(tls *libc.TLS, pMem uintptr) U16 { /* sqlite3.c:85674:28 // Unlike applyNumericAffinity(), this routine does not modify pMem->flags. // But it does set pMem->u.r and pMem->u.i appropriately. func numericType(tls *libc.TLS, pMem uintptr) U16 { /* sqlite3.c:85702:12: */ - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & ((0x0004 | 0x0008) | 0x0020)) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & ((MEM_Int | MEM_Real) | MEM_IntReal)) != 0 { - return (U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & ((0x0004 | 0x0008) | 0x0020))) + return (U16(int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & ((MEM_Int | MEM_Real) | MEM_IntReal))) } - if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (0x0002 | 0x0010)) != 0 { + if (int32((*Mem)(unsafe.Pointer(pMem)).Fflags) & (MEM_Str | MEM_Blob)) != 0 { return computeNumericType(tls, pMem) } @@ -62366,7 +61732,7 @@ func numericType(tls *libc.TLS, pMem uintptr) U16 { /* sqlite3.c:85702:12: */ // overwritten with an integer value. func out2PrereleaseWithClear(tls *libc.TLS, pOut uintptr) uintptr { /* sqlite3.c:85961:28: */ Xsqlite3VdbeMemSetNull(tls, pOut) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Int return pOut } @@ -62375,10 +61741,10 @@ func out2Prerelease(tls *libc.TLS, p uintptr, pOp uintptr) uintptr { /* sqlite3. pOut = ((*Vdbe)(unsafe.Pointer(p)).FaMem + uintptr((*VdbeOp)(unsafe.Pointer(pOp)).Fp2)*56) - if (int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & (0x2000 | 0x0400)) != 0 { //OPTIMIZATION-IF-FALSE + if (int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0 { //OPTIMIZATION-IF-FALSE return out2PrereleaseWithClear(tls, pOut) } else { - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Int return pOut } return uintptr(0) @@ -62747,7 +62113,7 @@ func Xsqlite3VdbeExec(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:85985:20: * var zTrace uintptr aOp = (*Vdbe)(unsafe.Pointer(p)).FaOp pOp = aOp - rc = 0 + rc = SQLITE_OK db = (*Vdbe)(unsafe.Pointer(p)).Fdb resetSchemaOnFault = U8(0) encoding = (*Sqlite3)(unsafe.Pointer(db)).Fenc @@ -62765,7 +62131,7 @@ func Xsqlite3VdbeExec(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:85985:20: * if !((*Sqlite3)(unsafe.Pointer(db)).FxProgress != 0) { goto __1 } - iPrior = *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + uintptr(4)*4)) + iPrior = *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + 4*4)) nProgressLimit = (U64((*Sqlite3)(unsafe.Pointer(db)).FnProgressOps - (iPrior % (*Sqlite3)(unsafe.Pointer(db)).FnProgressOps))) goto __2 @@ -62773,7 +62139,7 @@ __1: nProgressLimit = (uint64(0xffffffff) | (U64((uint64(0xffffffff))) << 32)) __2: ; - if !((*Vdbe)(unsafe.Pointer(p)).Frc == 7) { + if !((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_NOMEM) { goto __3 } // This happens if a malloc() inside a call to sqlite3_column_text() or @@ -62782,7 +62148,7 @@ __2: __3: ; - (*Vdbe)(unsafe.Pointer(p)).Frc = 0 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK (*Vdbe)(unsafe.Pointer(p)).FiCurrentTime = int64(0) @@ -62873,21 +62239,21 @@ __8: // is sometimes set to 1 instead of 0 as a hint to the command-line shell // that this Goto is the bottom of a loop and that the lines from P2 down // to the current line should be indented for EXPLAIN output. - case 11: + case OP_Goto: goto __11 // Opcode: Gosub P1 P2 * * * // // Write the current address onto register P1 // and then jump to address P2. - case 12: + case OP_Gosub: goto __12 // Opcode: Return P1 * * * * // // Jump to the next instruction after the address in register P1. After // the jump, register P1 becomes undefined. - case 65: + case OP_Return: goto __13 // Opcode: InitCoroutine P1 P2 P3 * * @@ -62900,7 +62266,7 @@ __8: // address P2. // // See also: EndCoroutine - case 13: + case OP_InitCoroutine: goto __14 // Opcode: EndCoroutine P1 * * * * @@ -62910,7 +62276,7 @@ __8: // After the jump, register P1 becomes undefined. // // See also: InitCoroutine - case 66: + case OP_EndCoroutine: goto __15 // Opcode: Yield P1 P2 * * * @@ -62925,7 +62291,7 @@ __8: // next instruction. // // See also: InitCoroutine - case 14: + case OP_Yield: goto __16 // Opcode: HaltIfNull P1 P2 P3 P4 P5 @@ -62935,7 +62301,7 @@ __8: // parameter P1, P2, and P4 as if this were a Halt instruction. If the // value in register P3 is not NULL, then this routine is a no-op. // The P5 parameter should be 1. - case 67: + case OP_HaltIfNull: goto __17 // Opcode: Halt P1 P2 * P4 P5 @@ -62967,14 +62333,14 @@ __8: // There is an implied "Halt 0 0 0" instruction inserted at the very end of // every program. So a jump past the last instruction of the program // is the same as executing Halt. - case 68: + case OP_Halt: goto __18 // Opcode: Integer P1 P2 * * * // Synopsis: r[P2]=P1 // // The 32-bit integer value P1 is written into register P2. - case 69: + case OP_Integer: goto __19 // Opcode: Int64 * P2 * P4 * @@ -62982,7 +62348,7 @@ __8: // // P4 is a pointer to a 64-bit integer value. // Write that value into register P2. - case 70: + case OP_Int64: goto __20 // Opcode: Real * P2 * P4 * @@ -62990,7 +62356,7 @@ __8: // // P4 is a pointer to a 64-bit floating point value. // Write that value into register P2. - case 150: + case OP_Real: goto __21 // Opcode: String8 * P2 * P4 * @@ -63000,7 +62366,7 @@ __8: // into a String opcode before it is executed for the first time. During // this transformation, the length of string P4 is computed and stored // as the P1 parameter. - case 115: + case OP_String8: goto __22 // Opcode: String P1 P2 P3 P4 P5 @@ -63014,7 +62380,7 @@ __8: // of a string, as if it had been CAST. In other words: // // if( P3!=0 and reg[P3]==P5 ) reg[P2] := CAST(reg[P2] as BLOB) - case 71: + case OP_String: goto __23 // Opcode: Null P1 P2 P3 * * @@ -63028,7 +62394,7 @@ __8: // If the P1 value is non-zero, then also set the MEM_Cleared flag so that // NULL values will not compare equal even if SQLITE_NULLEQ is set on // OP_Ne or OP_Eq. - case 72: + case OP_Null: goto __24 // Opcode: SoftNull P1 * * * * @@ -63038,7 +62404,7 @@ __8: // instruction, but do not free any string or blob memory associated with // the register, so that if the value was a string or blob that was // previously copied using OP_SCopy, the copies will continue to be valid. - case 73: + case OP_SoftNull: goto __25 // Opcode: Blob P1 P2 * P4 * @@ -63046,7 +62412,7 @@ __8: // // P4 points to a blob of data P1 bytes long. Store this // blob in register P2. - case 74: + case OP_Blob: goto __26 // Opcode: Variable P1 P2 * P4 * @@ -63056,7 +62422,7 @@ __8: // // If the parameter is named, then its name appears in P4. // The P4 value is used by sqlite3_bind_parameter_name(). - case 75: + case OP_Variable: goto __27 // Opcode: Move P1 P2 P3 * * @@ -63067,7 +62433,7 @@ __8: // left holding a NULL. It is an error for register ranges // P1..P1+P3-1 and P2..P2+P3-1 to overlap. It is an error // for P3 to be less than 1. - case 76: + case OP_Move: goto __28 // Opcode: Copy P1 P2 P3 * * @@ -63077,7 +62443,7 @@ __8: // // This instruction makes a deep copy of the value. A duplicate // is made of any string or blob constant. See also OP_SCopy. - case 77: + case OP_Copy: goto __29 // Opcode: SCopy P1 P2 * * * @@ -63092,7 +62458,7 @@ __8: // Thus the program must guarantee that the original will not change // during the lifetime of the copy. Use OP_Copy to make a complete // copy. - case 78: + case OP_SCopy: goto __30 // Opcode: IntCopy P1 P2 * * * @@ -63102,7 +62468,7 @@ __8: // // This is an optimized version of SCopy that works only for integer // values. - case 79: + case OP_IntCopy: goto __31 // Opcode: ResultRow P1 P2 * * * @@ -63113,7 +62479,7 @@ __8: // with an SQLITE_ROW return code and it sets up the sqlite3_stmt // structure to provide access to the r(P1)..r(P1+P2-1) values as // the result row. - case 80: + case OP_ResultRow: goto __32 // Opcode: Concat P1 P2 P3 * * @@ -63128,7 +62494,7 @@ __8: // It is illegal for P1 and P3 to be the same register. Sometimes, // if P3 is the same register as P2, the implementation is able // to avoid a memcpy(). - case 110: + case OP_Concat: goto __33 // Opcode: Add P1 P2 P3 * * @@ -63164,15 +62530,15 @@ __8: // register P1 and store the result in register P3. // If the value in register P1 is zero the result is NULL. // If either operand is NULL, the result is NULL. - case 105: + case OP_Add: goto __34 // same as TK_PLUS, in1, in2, out3 - case 106: + case OP_Subtract: goto __35 // same as TK_MINUS, in1, in2, out3 - case 107: + case OP_Multiply: goto __36 // same as TK_STAR, in1, in2, out3 - case 108: + case OP_Divide: goto __37 // same as TK_SLASH, in1, in2, out3 - case 109: + case OP_Remainder: goto __38 // Opcode: CollSeq P1 * * P4 @@ -63189,7 +62555,7 @@ __8: // The interface used by the implementation of the aforementioned functions // to retrieve the collation sequence set by this opcode is not available // publicly. Only built-in functions have access to this feature. - case 81: + case OP_CollSeq: goto __39 // Opcode: BitAnd P1 P2 P3 * * @@ -63218,13 +62584,13 @@ __8: // number of bits specified by the integer in register P1. // Store the result in register P3. // If either input is NULL, the result is NULL. - case 101: + case OP_BitAnd: goto __40 // same as TK_BITAND, in1, in2, out3 - case 102: + case OP_BitOr: goto __41 // same as TK_BITOR, in1, in2, out3 - case 103: + case OP_ShiftLeft: goto __42 // same as TK_LSHIFT, in1, in2, out3 - case 104: + case OP_ShiftRight: goto __43 // Opcode: AddImm P1 P2 * * * @@ -63234,7 +62600,7 @@ __8: // The result is always an integer. // // To force any register to be an integer, just add 0. - case 82: + case OP_AddImm: goto __44 // Opcode: MustBeInt P1 P2 * * * @@ -63243,7 +62609,7 @@ __8: // in P1 is not an integer and cannot be converted into an integer // without data loss, then jump immediately to P2, or if P2==0 // raise an SQLITE_MISMATCH exception. - case 15: + case OP_MustBeInt: goto __45 // Opcode: RealAffinity P1 * * * * @@ -63254,7 +62620,7 @@ __8: // has REAL affinity. Such column values may still be stored as // integers, for space efficiency, but after extraction we want them // to have only a real value. - case 83: + case OP_RealAffinity: goto __46 // Opcode: Cast P1 P2 * * * @@ -63271,7 +62637,7 @@ __8: // // // A NULL value is not changed by this routine. It remains NULL. - case 84: + case OP_Cast: goto __47 // Opcode: Eq P1 P2 P3 P4 P5 @@ -63364,17 +62730,17 @@ __8: // This works just like the Lt opcode except that the jump is taken if // the content of register P3 is greater than or equal to the content of // register P1. See the Lt opcode for additional information. - case 53: + case OP_Eq: goto __48 // same as TK_EQ, jump, in1, in3 - case 52: + case OP_Ne: goto __49 // same as TK_NE, jump, in1, in3 - case 56: + case OP_Lt: goto __50 // same as TK_LT, jump, in1, in3 - case 55: + case OP_Le: goto __51 // same as TK_LE, jump, in1, in3 - case 54: + case OP_Gt: goto __52 // same as TK_GT, jump, in1, in3 - case 57: + case OP_Ge: goto __53 // Opcode: ElseNotEq * P2 * * * @@ -63389,7 +62755,7 @@ __8: // prior OP_Lt or OP_Gt would have been NULL or false (0), then then // jump to P2. If the result of an OP_Eq comparison on the two previous // operands would have been true (1), then fall through. - case 58: + case OP_ElseNotEq: goto __54 // Opcode: Permutation * * * P4 * @@ -63403,7 +62769,7 @@ __8: // // The first integer in the P4 integer array is the length of the array // and does not become part of the permutation. - case 85: + case OP_Permutation: goto __55 // Opcode: Compare P1 P2 P3 P4 P5 @@ -63425,7 +62791,7 @@ __8: // The comparison is a sort comparison, so NULLs compare equal, // NULLs are less than numbers, numbers are less than strings, // and strings are less than blobs. - case 86: + case OP_Compare: goto __56 // Opcode: Jump P1 P2 P3 * * @@ -63433,7 +62799,7 @@ __8: // Jump to the instruction at address P1, P2, or P3 depending on whether // in the most recent OP_Compare instruction the P1 vector was less than // equal to, or greater than the P2 vector, respectively. - case 16: + case OP_Jump: goto __57 // Opcode: And P1 P2 P3 * * @@ -63454,9 +62820,9 @@ __8: // If either P1 or P2 is nonzero (true) then the result is 1 (true) // even if the other input is NULL. A NULL and false or two NULLs // give a NULL output. - case 44: + case OP_And: goto __58 // same as TK_AND, in1, in2, out3 - case 43: + case OP_Or: goto __59 // Opcode: IsTrue P1 P2 P3 P4 * @@ -63478,7 +62844,7 @@ __8: //
  • If P3==0 and P4==1 then r[P2] := r[P1] IS NOT TRUE //
  • If P3==1 and P4==0 then r[P2] := r[P1] IS NOT FALSE // - case 87: + case OP_IsTrue: goto __60 // Opcode: Not P1 P2 * * * @@ -63487,7 +62853,7 @@ __8: // Interpret the value in register P1 as a boolean value. Store the // boolean complement in register P2. If the value in register P1 is // NULL, then a NULL is stored in P2. - case 19: + case OP_Not: goto __61 // Opcode: BitNot P1 P2 * * * @@ -63496,7 +62862,7 @@ __8: // Interpret the content of register P1 as an integer. Store the // ones-complement of the P1 value into register P2. If P1 holds // a NULL then store a NULL in P2. - case 112: + case OP_BitNot: goto __62 // Opcode: Once P1 P2 * * * @@ -63515,7 +62881,7 @@ __8: // whether or not the jump should be taken. The bitmask is necessary // because the self-altering code trick does not work for recursive // triggers. - case 17: + case OP_Once: goto __63 // Opcode: If P1 P2 P3 * * @@ -63523,7 +62889,7 @@ __8: // Jump to P2 if the value in register P1 is true. The value // is considered true if it is numeric and non-zero. If the value // in P1 is NULL then take the jump if and only if P3 is non-zero. - case 18: + case OP_If: goto __64 // Opcode: IfNot P1 P2 P3 * * @@ -63531,21 +62897,21 @@ __8: // Jump to P2 if the value in register P1 is False. The value // is considered false if it has a numeric value of zero. If the value // in P1 is NULL then take the jump if and only if P3 is non-zero. - case 20: + case OP_IfNot: goto __65 // Opcode: IsNull P1 P2 * * * // Synopsis: if r[P1]==NULL goto P2 // // Jump to P2 if the value in register P1 is NULL. - case 50: + case OP_IsNull: goto __66 // Opcode: NotNull P1 P2 * * * // Synopsis: if r[P1]!=NULL goto P2 // // Jump to P2 if the value in register P1 is not NULL. - case 51: + case OP_NotNull: goto __67 // Opcode: IfNullRow P1 P2 P3 * * @@ -63555,7 +62921,7 @@ __8: // If it is, then set register P3 to NULL and jump immediately to P2. // If P1 is not on a NULL row, then fall through without making any // changes. - case 21: + case OP_IfNullRow: goto __68 // Opcode: Offset P1 P2 P3 * * @@ -63572,7 +62938,7 @@ __8: // // This opcode is only available if SQLite is compiled with the // -DSQLITE_ENABLE_OFFSET_SQL_FUNC option. - case 88: + case OP_Offset: goto __69 // Opcode: Column P1 P2 P3 P4 P5 @@ -63594,7 +62960,7 @@ __8: // the result is guaranteed to only be used as the argument of a length() // or typeof() function, respectively. The loading of large blobs can be // skipped for length() and all content loading can be skipped for typeof(). - case 89: + case OP_Column: goto __70 // Opcode: Affinity P1 P2 * P4 * @@ -63605,7 +62971,7 @@ __8: // P4 is a string that is P2 characters long. The N-th character of the // string indicates the column affinity that should be used for the N-th // memory cell in the range. - case 90: + case OP_Affinity: goto __71 // Opcode: MakeRecord P1 P2 P3 P4 * @@ -63634,7 +63000,7 @@ __8: // OPFLAG_NOCHNG_MAGIC if the OP_MakeRecord opcode is allowed to // accept no-change records with serial_type 10. This value is // only used inside an assert() and does not affect the end result. - case 91: + case OP_MakeRecord: goto __72 // Opcode: Count P1 P2 p3 * * @@ -63646,7 +63012,7 @@ __8: // If P3==0, then an exact count is obtained, which involves visiting // every btree page of the table. But if P3 is non-zero, an estimate // is returned based on the current cursor position. - case 92: + case OP_Count: goto __73 // Opcode: Savepoint P1 * * P4 * @@ -63655,7 +63021,7 @@ __8: // on the value of P1. To open a new savepoint set P1==0 (SAVEPOINT_BEGIN). // To release (commit) an existing savepoint set P1==1 (SAVEPOINT_RELEASE). // To rollback an existing savepoint set P1==2 (SAVEPOINT_ROLLBACK). - case 0: + case OP_Savepoint: goto __74 // Opcode: AutoCommit P1 P2 * * * @@ -63666,7 +63032,7 @@ __8: // there are active writing VMs or active VMs that use shared cache. // // This instruction causes the VM to halt. - case 1: + case OP_AutoCommit: goto __75 // Opcode: Transaction P1 P2 P3 P4 P5 @@ -63702,7 +63068,7 @@ __8: // generation counter, then an SQLITE_SCHEMA error is raised and execution // halts. The sqlite3_step() wrapper function might then reprepare the // statement and rerun it from the beginning. - case 2: + case OP_Transaction: goto __76 // Opcode: ReadCookie P1 P2 P3 * * @@ -63716,7 +63082,7 @@ __8: // There must be a read-lock on the database (either a transaction // must be started or there must be an open cursor) before // executing this instruction. - case 93: + case OP_ReadCookie: goto __77 // Opcode: SetCookie P1 P2 P3 * P5 @@ -63733,7 +63099,7 @@ __8: // schema version is set to P3-P5. The "PRAGMA schema_version=N" statement // has P5 set to 1, so that the internal schema version will be different // from the database schema version, resulting in a schema reset. - case 94: + case OP_SetCookie: goto __78 // Opcode: OpenRead P1 P2 P3 P4 P5 @@ -63817,13 +63183,13 @@ __8: // in read/write mode. // // See also: OP_OpenRead, OP_ReopenIdx - case 95: + case OP_ReopenIdx: goto __79 // If the cursor is not currently open or is open on a different // index, then fall through into OP_OpenRead to force a reopen - case 96: + case OP_OpenRead: goto __80 - case 97: + case OP_OpenWrite: goto __81 // Opcode: OpenDup P1 P2 * * * @@ -63833,7 +63199,7 @@ __8: // opcode. Only ephemeral cursors may be duplicated. // // Duplicate ephemeral cursors are used for self-joins of materialized views. - case 98: + case OP_OpenDup: goto __82 // Opcode: OpenEphemeral P1 P2 * P4 P5 @@ -63863,9 +63229,9 @@ __8: // different name to distinguish its use. Tables created using // by this opcode will be used for automatically created transient // indices in joins. - case 99: + case OP_OpenAutoindex: goto __83 - case 100: + case OP_OpenEphemeral: goto __84 // Opcode: SorterOpen P1 P2 P3 P4 * @@ -63877,7 +63243,7 @@ __8: // If argument P3 is non-zero, then it indicates that the sorter may // assume that a stable sort considering the first P3 fields of each // key is sufficient to produce the required results. - case 111: + case OP_SorterOpen: goto __85 // Opcode: SequenceTest P1 P2 * * * @@ -63886,7 +63252,7 @@ __8: // P1 is a sorter cursor. If the sequence counter is currently zero, jump // to P2. Regardless of whether or not the jump is taken, increment the // the sequence value. - case 113: + case OP_SequenceTest: goto __86 // Opcode: OpenPseudo P1 P2 P3 * * @@ -63904,14 +63270,14 @@ __8: // // P3 is the number of fields in the records that will be stored by // the pseudo-table. - case 114: + case OP_OpenPseudo: goto __87 // Opcode: Close P1 * * * * // // Close a cursor previously opened as P1. If P1 is not // currently open, this instruction is a no-op. - case 116: + case OP_Close: goto __88 // Opcode: SeekGE P1 P2 P3 P4 * @@ -64000,13 +63366,13 @@ __8: // is an equality search. // // See also: Found, NotFound, SeekGt, SeekGe, SeekLt - case 22: + case OP_SeekLT: goto __89 // jump, in3, group - case 23: + case OP_SeekLE: goto __90 // jump, in3, group - case 24: + case OP_SeekGE: goto __91 // jump, in3, group - case 25: + case OP_SeekGT: goto __92 // Opcode: SeekHit P1 P2 * * * @@ -64017,14 +63383,14 @@ __8: // // P1 must be a valid b-tree cursor. P2 must be a boolean value, // either 0 or 1. - case 118: + case OP_SeekHit: goto __93 // Opcode: IfNotOpen P1 P2 * * * // Synopsis: if( !csr[P1] ) goto P2 // // If cursor P1 is not open, jump to instruction P2. Otherwise, fall through. - case 26: + case OP_IfNotOpen: goto __94 // Opcode: Found P1 P2 P3 P4 * @@ -64109,13 +63475,13 @@ __8: // opcodes do not work after this operation. // // See also: NotFound, Found, NotExists - case 27: + case OP_IfNoHope: goto __95 - case 28: + case OP_NoConflict: goto __96 // jump, in3 - case 29: + case OP_NotFound: goto __97 // jump, in3 - case 30: + case OP_Found: goto __98 // Opcode: SeekRowid P1 P2 P3 * * @@ -64163,9 +63529,9 @@ __8: // not work following this opcode. // // See also: Found, NotFound, NoConflict, SeekRowid - case 31: + case OP_SeekRowid: goto __99 - case 32: + case OP_NotExists: goto __100 // Opcode: Sequence P1 P2 * * * @@ -64175,7 +63541,7 @@ __8: // Write the sequence number into register P2. // The sequence number on the cursor is incremented after this // instruction. - case 119: + case OP_Sequence: goto __101 // Opcode: NewRowid P1 P2 P3 * * @@ -64192,7 +63558,7 @@ __8: // an SQLITE_FULL error is generated. The P3 register is updated with the ' // generated record number. This P3 mechanism is used to help implement the // AUTOINCREMENT feature. - case 120: + case OP_NewRowid: goto __102 // Opcode: Insert P1 P2 P3 P4 P5 @@ -64231,7 +63597,7 @@ __8: // // This instruction only works on tables. The equivalent instruction // for indices is OP_IdxInsert. - case 121: + case OP_Insert: goto __103 // Opcode: Delete P1 P2 P3 P4 P5 @@ -64268,7 +63634,7 @@ __8: // If the OPFLAG_ISUPDATE flag is set in P2, then P3 contains the address // of the memory cell that contains the value that the rowid of the row will // be set to by the update. - case 122: + case OP_Delete: goto __104 // Opcode: ResetCount * * * * * // @@ -64276,7 +63642,7 @@ __8: // change counter (returned by subsequent calls to sqlite3_changes()). // Then the VMs internal change counter resets to 0. // This is used by trigger programs. - case 123: + case OP_ResetCount: goto __105 // Opcode: SorterCompare P1 P2 P3 P4 @@ -64293,7 +63659,7 @@ __8: // // Fall through to next instruction if the two records compare equal to // each other. Jump to P2 if they are different. - case 124: + case OP_SorterCompare: goto __106 // Opcode: SorterData P1 P2 P3 * * @@ -64307,7 +63673,7 @@ __8: // OpenPseudo. That pseudo-table cursor is the one that is identified by // parameter P3. Clearing the P3 column cache as part of this opcode saves // us from having to issue a separate NullRow instruction to clear that cache. - case 125: + case OP_SorterData: goto __107 // Opcode: RowData P1 P2 P3 * * @@ -64337,7 +63703,7 @@ __8: // in OP_Result and any OP_Result will invalidate the P2 register content. // The P2 register content is invalidated by opcodes like OP_Function or // by any use of another cursor pointing to the same table. - case 126: + case OP_RowData: goto __108 // Opcode: Rowid P1 P2 * * * @@ -64349,7 +63715,7 @@ __8: // P1 can be either an ordinary table or a virtual table. There used to // be a separate OP_VRowid opcode for use with virtual tables, but this // one opcode now works for both table types. - case 127: + case OP_Rowid: goto __109 // Opcode: NullRow P1 * * * * @@ -64357,7 +63723,7 @@ __8: // Move the cursor P1 to a null row. Any OP_Column operations // that occur while the cursor is on the null row will always // write a NULL. - case 128: + case OP_NullRow: goto __110 // Opcode: SeekEnd P1 * * * * @@ -64380,16 +63746,16 @@ __8: // This opcode leaves the cursor configured to move in reverse order, // from the end toward the beginning. In other words, the cursor is // configured to use Prev, not Next. - case 129: + case OP_SeekEnd: goto __111 - case 33: + case OP_Last: goto __112 // Opcode: IfSmaller P1 P2 P3 * * // // Estimate the number of rows in the table P1. Jump to P2 if that // estimate is less than approximately 2**(0.1*P3). - case 34: + case OP_IfSmaller: goto __113 // Opcode: SorterSort P1 P2 * * * @@ -64411,9 +63777,9 @@ __8: // rewinding so that the global variable will be incremented and // regression tests can determine whether or not the optimizer is // correctly optimizing out sorts. - case 35: + case OP_SorterSort: goto __114 // jump - case 36: + case OP_Sort: goto __115 // Opcode: Rewind P1 P2 * * * // @@ -64426,7 +63792,7 @@ __8: // This opcode leaves the cursor configured to move in forward order, // from the beginning toward the end. In other words, the cursor is // configured to use Next, not Prev. - case 37: + case OP_Rewind: goto __116 // Opcode: Next P1 P2 P3 P4 P5 @@ -64486,11 +63852,11 @@ __8: // sorter object for which the OP_SorterSort opcode has been // invoked. This opcode advances the cursor to the next sorted // record, or jumps to P2 if there are no more sorted records. - case 3: + case OP_SorterNext: goto __117 - case 4: + case OP_Prev: goto __118 // jump - case 5: + case OP_Next: goto __119 // Opcode: IdxInsert P1 P2 P3 P4 P5 @@ -64520,7 +63886,7 @@ __8: // // This instruction only works for indices. The equivalent instruction // for tables is OP_Insert. - case 130: + case OP_IdxInsert: goto __120 // Opcode: SorterInsert P1 P2 * * * @@ -64529,7 +63895,7 @@ __8: // Register P2 holds an SQL index key made using the // MakeRecord instructions. This opcode writes that key // into the sorter P1. Data for the entry is nil. - case 131: + case OP_SorterInsert: goto __121 // Opcode: IdxDelete P1 P2 P3 * P5 @@ -64545,7 +63911,7 @@ __8: // or deleted is not found. For some uses of IdxDelete // (example: the EXCEPT operator) it does not matter that no matching // entry is found. For those cases, P5 is zero. - case 132: + case OP_IdxDelete: goto __122 // Opcode: DeferredSeek P1 * P3 P4 * @@ -64574,9 +63940,9 @@ __8: // the rowid of the table entry to which this index entry points. // // See also: Rowid, MakeRecord. - case 133: + case OP_DeferredSeek: goto __123 - case 134: + case OP_IdxRowid: goto __124 // Opcode: FinishSeek P1 * * * * @@ -64584,7 +63950,7 @@ __8: // If cursor P1 was previously moved via OP_DeferredSeek, complete that // seek operation now, without further delay. If the cursor seek has // already occurred, this instruction is a no-op. - case 135: + case OP_FinishSeek: goto __125 // Opcode: IdxGE P1 P2 P3 P4 P5 @@ -64627,13 +63993,13 @@ __8: // // If the P1 index entry is less than or equal to the key value then jump // to P2. Otherwise fall through to the next instruction. - case 38: + case OP_IdxLE: goto __126 // jump - case 39: + case OP_IdxGT: goto __127 // jump - case 40: + case OP_IdxLT: goto __128 // jump - case 41: + case OP_IdxGE: goto __129 // Opcode: Destroy P1 P2 P3 * * @@ -64662,7 +64028,7 @@ __8: // and non-autovacuum modes. // // See also: Clear - case 136: + case OP_Destroy: goto __130 // Opcode: Clear P1 P2 P3 @@ -64682,7 +64048,7 @@ __8: // also incremented by the number of rows in the table being cleared. // // See also: Destroy - case 137: + case OP_Clear: goto __131 // Opcode: ResetSorter P1 * * * * @@ -64692,7 +64058,7 @@ __8: // // This opcode only works for cursors used for sorting and // opened with OP_OpenEphemeral or OP_SorterOpen. - case 138: + case OP_ResetSorter: goto __132 // Opcode: CreateBtree P1 P2 P3 * * @@ -64703,13 +64069,13 @@ __8: // P1>1. The P3 argument must be 1 (BTREE_INTKEY) for a rowid table // it must be 2 (BTREE_BLOBKEY) for an index or WITHOUT ROWID table. // The root page number of the new b-tree is stored in register P2. - case 139: + case OP_CreateBtree: goto __133 // Opcode: SqlExec * * * P4 * // // Run the SQL statement or statements specified in the P4 string. - case 140: + case OP_SqlExec: goto __134 // Opcode: ParseSchema P1 * * P4 * @@ -64720,7 +64086,7 @@ __8: // // This opcode invokes the parser to create a new virtual machine, // then runs the new virtual machine. It is thus a re-entrant opcode. - case 141: + case OP_ParseSchema: goto __135 // Opcode: LoadAnalysis P1 * * * * @@ -64728,7 +64094,7 @@ __8: // Read the sqlite_stat1 table for database P1 and load the content // of that table into the internal index hash table. This will cause // the analysis to be used when preparing all subsequent queries. - case 142: + case OP_LoadAnalysis: goto __136 // Opcode: DropTable P1 * * P4 * @@ -64738,7 +64104,7 @@ __8: // is dropped from disk (using the Destroy opcode) in order to keep // the internal representation of the // schema consistent with what is on disk. - case 143: + case OP_DropTable: goto __137 // Opcode: DropIndex P1 * * P4 * @@ -64748,7 +64114,7 @@ __8: // is dropped from disk (using the Destroy opcode) // in order to keep the internal representation of the // schema consistent with what is on disk. - case 144: + case OP_DropIndex: goto __138 // Opcode: DropTrigger P1 * * P4 * @@ -64758,7 +64124,7 @@ __8: // is dropped from disk (using the Destroy opcode) in order to keep // the internal representation of the // schema consistent with what is on disk. - case 145: + case OP_DropTrigger: goto __139 // Opcode: IntegrityCk P1 P2 P3 P4 P5 @@ -64779,7 +64145,7 @@ __8: // file, not the main database file. // // This opcode is used to implement the integrity_check pragma. - case 146: + case OP_IntegrityCk: goto __140 // Opcode: RowSetAdd P1 P2 * * * @@ -64789,7 +64155,7 @@ __8: // held in register P1. // // An assertion fails if P2 is not an integer. - case 147: + case OP_RowSetAdd: goto __141 // Opcode: RowSetRead P1 P2 P3 * * @@ -64799,7 +64165,7 @@ __8: // and put that value into register P3. // Or, if RowSet object P1 is initially empty, leave P3 // unchanged and jump to instruction P2. - case 42: + case OP_RowSetRead: goto __142 // Opcode: RowSetTest P1 P2 P3 P4 @@ -64824,7 +64190,7 @@ __8: // inserted, there is no need to search to see if the same value was // previously inserted as part of set X (only if it was previously // inserted as part of some other set). - case 45: + case OP_RowSetTest: goto __143 // Opcode: Program P1 P2 P3 P4 P5 @@ -64841,7 +64207,7 @@ __8: // P4 is a pointer to the VM containing the trigger program. // // If P5 is non-zero, then recursive program invocation is enabled. - case 46: + case OP_Program: goto __144 // Opcode: Param P1 P2 * * * @@ -64855,7 +64221,7 @@ __8: // The address of the cell in the parent frame is determined by adding // the value of the P1 argument to the value of the P1 argument to the // calling OP_Program instruction. - case 148: + case OP_Param: goto __145 // Opcode: FkCounter P1 P2 * * * @@ -64865,7 +64231,7 @@ __8: // If P1 is non-zero, the database constraint counter is incremented // (deferred foreign key constraints). Otherwise, if P1 is zero, the // statement counter is incremented (immediate foreign key constraints). - case 149: + case OP_FkCounter: goto __146 // Opcode: FkIfZero P1 P2 * * * @@ -64879,7 +64245,7 @@ __8: // is zero (the one that counts deferred constraint violations). If P1 is // zero, the jump is taken if the statement constraint-counter is zero // (immediate foreign key constraint violations). - case 47: + case OP_FkIfZero: goto __147 // Opcode: MemMax P1 P2 * * * @@ -64892,7 +64258,7 @@ __8: // // This instruction throws an error if the memory cell is not initially // an integer. - case 151: + case OP_MemMax: goto __148 // Opcode: IfPos P1 P2 P3 * * @@ -64904,7 +64270,7 @@ __8: // // If the initial value of register P1 is less than 1, then the // value is unchanged and control passes through to the next instruction. - case 48: + case OP_IfPos: goto __149 // Opcode: OffsetLimit P1 P2 P3 * * @@ -64924,7 +64290,7 @@ __8: // and r[P2] is set to -1. // // Otherwise, r[P2] is set to the sum of r[P1] and r[P3]. - case 152: + case OP_OffsetLimit: goto __150 // Opcode: IfNotZero P1 P2 * * * @@ -64934,7 +64300,7 @@ __8: // initially greater than zero, then decrement the value in register P1. // If it is non-zero (negative or positive) and then also jump to P2. // If register P1 is initially zero, leave it unchanged and fall through. - case 49: + case OP_IfNotZero: goto __151 // Opcode: DecrJumpZero P1 P2 * * * @@ -64942,7 +64308,7 @@ __8: // // Register P1 must hold an integer. Decrement the value in P1 // and jump to P2 if the new value is exactly zero. - case 59: + case OP_DecrJumpZero: goto __152 // Opcode: AggStep * P2 P3 P4 P5 @@ -64981,11 +64347,11 @@ __8: // the opcode is changed. In this way, the initialization of the // sqlite3_context only happens once, instead of on each call to the // step function. - case 153: + case OP_AggInverse: goto __153 - case 154: + case OP_AggStep: goto __154 - case 155: + case OP_AggStep1: goto __155 // Opcode: AggFinal P1 P2 * P4 * @@ -65012,9 +64378,9 @@ __8: // functions that can take varying numbers of arguments. The // P4 argument is only needed for the case where // the step function was not previously called. - case 156: + case OP_AggValue: goto __156 - case 157: + case OP_AggFinal: goto __157 // Opcode: Checkpoint P1 P2 P3 * * @@ -65027,7 +64393,7 @@ __8: // in the WAL that have been checkpointed after the checkpoint // completes into mem[P3+2]. However on an error, mem[P3+1] and // mem[P3+2] are initialized to -1. - case 6: + case OP_Checkpoint: goto __158 // Opcode: JournalMode P1 P2 P3 * * @@ -65040,7 +64406,7 @@ __8: // If changing into or out of WAL mode the procedure is more complicated. // // Write a string containing the final journal-mode to register P2. - case 7: + case OP_JournalMode: goto __159 // Opcode: Vacuum P1 P2 * * * @@ -65051,7 +64417,7 @@ __8: // If P2 is not zero, then it is a register holding a string which is // the file into which the result of vacuum should be written. When // P2 is zero, the vacuum overwrites the original database. - case 8: + case OP_Vacuum: goto __160 // Opcode: IncrVacuum P1 P2 * * * @@ -65059,7 +64425,7 @@ __8: // Perform a single step of the incremental vacuum procedure on // the P1 database. If the vacuum has finished, jump to instruction // P2. Otherwise, fall through to the next instruction. - case 60: + case OP_IncrVacuum: goto __161 // Opcode: Expire P1 P2 * * * @@ -65077,21 +64443,21 @@ __8: // The P2==1 case occurs when a CREATE INDEX or similar schema change happens // that might help the statement run faster but which does not affect the // correctness of operation. - case 158: + case OP_Expire: goto __162 // Opcode: CursorLock P1 * * * * // // Lock the btree to which cursor P1 is pointing so that the btree cannot be // written by an other cursor. - case 159: + case OP_CursorLock: goto __163 // Opcode: CursorUnlock P1 * * * * // // Unlock the btree to which cursor P1 is pointing so that it can be // written by other cursors. - case 160: + case OP_CursorUnlock: goto __164 // Opcode: TableLock P1 P2 P3 P4 * @@ -65108,7 +64474,7 @@ __8: // // P4 contains a pointer to the name of the table being locked. This is only // used to generate an error message if the lock cannot be obtained. - case 161: + case OP_TableLock: goto __165 // Opcode: VBegin * * * P4 * @@ -65119,21 +64485,21 @@ __8: // Also, whether or not P4 is set, check that this is not being called from // within a callback to a virtual table xSync() method. If it is, the error // code will be set to SQLITE_LOCKED. - case 162: + case OP_VBegin: goto __166 // Opcode: VCreate P1 P2 * * * // // P2 is a register that holds the name of a virtual table in database // P1. Call the xCreate method for that table. - case 163: + case OP_VCreate: goto __167 // Opcode: VDestroy P1 * * P4 * // // P4 is the name of a virtual table in database P1. Call the xDestroy method // of that table. - case 164: + case OP_VDestroy: goto __168 // Opcode: VOpen P1 * * P4 * @@ -65141,7 +64507,7 @@ __8: // P4 is a pointer to a virtual table object, an sqlite3_vtab structure. // P1 is a cursor number. This opcode opens a cursor to the virtual // table and stores that cursor in P1. - case 165: + case OP_VOpen: goto __169 // Opcode: VFilter P1 P2 P3 P4 * @@ -65162,7 +64528,7 @@ __8: // xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter. // // A jump is made to P2 if the result set after filtering would be empty. - case 9: + case OP_VFilter: goto __170 // Opcode: VColumn P1 P2 P3 * P5 @@ -65178,7 +64544,7 @@ __8: // table implementation. The P5 column might also contain other // bits (OPFLAG_LENGTHARG or OPFLAG_TYPEOFARG) but those bits are // unused by OP_VColumn. - case 166: + case OP_VColumn: goto __171 // Opcode: VNext P1 P2 * * * @@ -65186,7 +64552,7 @@ __8: // Advance virtual table P1 to the next row in its result set and // jump to instruction P2. Or, if the virtual table has reached // the end of its result set, then fall through to the next instruction. - case 61: + case OP_VNext: goto __172 // Opcode: VRename P1 * * P4 * @@ -65194,7 +64560,7 @@ __8: // P4 is a pointer to a virtual table object, an sqlite3_vtab structure. // This opcode invokes the corresponding xRename method. The value // in register P1 is passed as the zName argument to the xRename method. - case 167: + case OP_VRename: goto __173 // Opcode: VUpdate P1 P2 P3 P4 P5 @@ -65223,13 +64589,13 @@ __8: // // P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to // apply in the case of a constraint failure on an insert or update. - case 10: + case OP_VUpdate: goto __174 // Opcode: Pagecount P1 P2 * * * // // Write the current number of pages in database P1 to memory cell P2. - case 168: + case OP_Pagecount: goto __175 // Opcode: MaxPgcnt P1 P2 P3 * * @@ -65239,7 +64605,7 @@ __8: // do not change the maximum page count value if P3==0. // // Store the maximum page count after the change in register P2. - case 169: + case OP_MaxPgcnt: goto __176 // Opcode: Function P1 P2 P3 P4 * @@ -65286,9 +64652,9 @@ __8: // if they were, they throw an error. // // See also: AggStep, AggFinal, Function - case 63: + case OP_PureFunc: goto __177 // group - case 64: + case OP_Function: goto __178 // Opcode: Trace P1 P2 * P4 * @@ -65314,9 +64680,9 @@ __8: // // If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT // error is encountered. - case 170: + case OP_Trace: goto __179 - case 62: + case OP_Init: goto __180 // Opcode: Noop * * * * * @@ -65416,7 +64782,7 @@ __183: goto __185 } nProgressLimit = (uint64(0xffffffff) | (U64((uint64(0xffffffff))) << 32)) - rc = 9 + rc = SQLITE_INTERRUPT goto abort_due_to_error __185: ; @@ -65434,7 +64800,7 @@ __12: // jump ; pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - (*Mem)(unsafe.Pointer(pIn1)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pIn1)).Fflags = MEM_Int *(*I64)(unsafe.Pointer(pIn1 /* &.u */)) = I64((int32((int64(pOp) - int64(aOp)) / 32))) // Most jump operations do a goto to this spot in order to update @@ -65451,7 +64817,7 @@ __13: // in1 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) pOp = (aOp + uintptr(*(*I64)(unsafe.Pointer(pIn1 /* &.u */)))*32) - (*Mem)(unsafe.Pointer(pIn1)).Fflags = U16(0x0080) + (*Mem)(unsafe.Pointer(pIn1)).Fflags = MEM_Undefined goto __10 // Opcode: InitCoroutine P1 P2 P3 * * @@ -65470,7 +64836,7 @@ __14: // jump pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) *(*I64)(unsafe.Pointer(pOut /* &.u */)) = (I64((*Op)(unsafe.Pointer(pOp)).Fp3 - 1)) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Int if !((*Op)(unsafe.Pointer(pOp)).Fp2 != 0) { goto __186 } @@ -65492,7 +64858,7 @@ __15: pCaller = (aOp + uintptr(*(*I64)(unsafe.Pointer(pIn1 /* &.u */)))*32) pOp = (aOp + uintptr(((*VdbeOp)(unsafe.Pointer(pCaller)).Fp2-1))*32) - (*Mem)(unsafe.Pointer(pIn1)).Fflags = U16(0x0080) + (*Mem)(unsafe.Pointer(pIn1)).Fflags = MEM_Undefined goto __10 // Opcode: Yield P1 P2 * * * @@ -65510,7 +64876,7 @@ __15: __16: pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - (*Mem)(unsafe.Pointer(pIn1)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pIn1)).Fflags = MEM_Int pcDest = int32(*(*I64)(unsafe.Pointer(pIn1 /* &.u */))) *(*I64)(unsafe.Pointer(pIn1 /* &.u */)) = I64((int32((int64(pOp) - int64(aOp)) / 32))) @@ -65526,14 +64892,12 @@ __16: // The P5 parameter should be 1. __17: // in3 pIn3 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn3)).Fflags) & 0x0001) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn3)).Fflags) & MEM_Null) == 0) { goto __187 } goto __10 __187: ; - // Fall through into OP_Halt - /* no break */ // Opcode: Halt P1 P2 * P4 P5 // @@ -65567,7 +64931,7 @@ __187: __18: pcx = (int32((int64(pOp) - int64(aOp)) / 32)) - if !(((*Op)(unsafe.Pointer(pOp)).Fp1 == 0) && ((*Vdbe)(unsafe.Pointer(p)).FpFrame != 0)) { + if !(((*Op)(unsafe.Pointer(pOp)).Fp1 == SQLITE_OK) && ((*Vdbe)(unsafe.Pointer(p)).FpFrame != 0)) { goto __188 } // Halt the sub-program. Return control to the parent frame. @@ -65576,7 +64940,7 @@ __18: (*Vdbe)(unsafe.Pointer(p)).FnFrame-- Xsqlite3VdbeSetChanges(tls, db, (*Vdbe)(unsafe.Pointer(p)).FnChange) pcx = Xsqlite3VdbeFrameRestore(tls, pFrame) - if !((*Op)(unsafe.Pointer(pOp)).Fp2 == 4) { + if !((*Op)(unsafe.Pointer(pOp)).Fp2 == OE_Ignore) { goto __189 } // Instruction pcx is the OP_Program that invoked the sub-program @@ -65621,18 +64985,18 @@ __190: ; rc = Xsqlite3VdbeHalt(tls, p) - if !(rc == 5) { + if !(rc == SQLITE_BUSY) { goto __194 } - (*Vdbe)(unsafe.Pointer(p)).Frc = 5 + (*Vdbe)(unsafe.Pointer(p)).Frc = SQLITE_BUSY goto __195 __194: ; if (*Vdbe)(unsafe.Pointer(p)).Frc != 0 { - rc = 1 + rc = SQLITE_ERROR } else { - rc = 101 + rc = SQLITE_DONE } __195: ; @@ -65665,7 +65029,7 @@ __20: // out2 // Write that value into register P2. __21: // same as TK_FLOAT, out2 pOut = out2Prerelease(tls, p, pOp) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0008) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Real *(*float64)(unsafe.Pointer(pOut /* &.u */)) = *(*float64)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)))) goto __10 @@ -65682,10 +65046,10 @@ __22: // same as TK_STRING, out2 pOut = out2Prerelease(tls, p, pOp) (*Op)(unsafe.Pointer(pOp)).Fp1 = Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */))) - if !(int32(encoding) != 1) { + if !(int32(encoding) != SQLITE_UTF8) { goto __196 } - rc = Xsqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)), -1, uint8(1), uintptr(0)) + rc = Xsqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)), -1, SQLITE_UTF8, uintptr(0)) if !(rc != 0) { goto __197 @@ -65693,7 +65057,7 @@ __22: // same as TK_STRING, out2 goto too_big __197: ; - if !(0 != Xsqlite3VdbeChangeEncoding(tls, pOut, int32(encoding))) { + if !(SQLITE_OK != Xsqlite3VdbeChangeEncoding(tls, pOut, int32(encoding))) { goto __198 } goto no_mem @@ -65701,7 +65065,7 @@ __198: ; (*Mem)(unsafe.Pointer(pOut)).FszMalloc = 0 - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((0x0800)) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((MEM_Static)) if !(int32((*Op)(unsafe.Pointer(pOp)).Fp4type) == (-7)) { goto __199 } @@ -65713,16 +65077,13 @@ __199: (*Op)(unsafe.Pointer(pOp)).Fp1 = (*Mem)(unsafe.Pointer(pOut)).Fn __196: ; - if !((*Op)(unsafe.Pointer(pOp)).Fp1 > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) { + if !((*Op)(unsafe.Pointer(pOp)).Fp1 > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) { goto __200 } goto too_big __200: ; - (*Op)(unsafe.Pointer(pOp)).Fopcode = U8(71) - - // Fall through to the next case, OP_String - /* no break */ + (*Op)(unsafe.Pointer(pOp)).Fopcode = OP_String // Opcode: String P1 P2 P3 P4 P5 // Synopsis: r[P2]='P4' (len=P1) @@ -65738,7 +65099,7 @@ __200: __23: // out2 ; pOut = out2Prerelease(tls, p, pOp) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((0x0002 | 0x0800) | 0x0200)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((MEM_Str | MEM_Static) | MEM_Term)) (*Mem)(unsafe.Pointer(pOut)).Fz = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) (*Mem)(unsafe.Pointer(pOut)).Fn = (*Op)(unsafe.Pointer(pOp)).Fp1 (*Mem)(unsafe.Pointer(pOut)).Fenc = encoding @@ -65762,9 +65123,9 @@ __24: (*Mem)(unsafe.Pointer(pOut)).Fflags = libc.AssignUint16(&nullFlag, func() uint16 { if (*Op)(unsafe.Pointer(pOp)).Fp1 != 0 { - return (uint16(0x0001 | 0x0100)) + return (uint16(MEM_Null | MEM_Cleared)) } - return uint16(0x0001) + return MEM_Null }()) (*Mem)(unsafe.Pointer(pOut)).Fn = 0 __201: @@ -65792,7 +65153,7 @@ __202: __25: ; pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer(pOut)).Fflags) & ^libc.Int32((0x0080 | 0x003f))) | 0x0001)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer(pOut)).Fflags) & libc.CplInt32((MEM_Undefined | MEM_AffMask))) | MEM_Null)) goto __10 // Opcode: Blob P1 P2 * P4 * @@ -65827,15 +65188,15 @@ __27: // Value being transferred __203: ; pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) - if !((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & (0x2000 | 0x0400)) != 0) { + if !((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0) { goto __204 } Xsqlite3VdbeMemSetNull(tls, pOut) __204: ; libc.Xmemcpy(tls, pOut, pVar, uint64((uintptr(0) + 24 /* &.zMalloc */))) - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32((0x0400 | 0x1000)))) - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((0x0800 | 0x0040)) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32((MEM_Dyn | MEM_Ephem)))) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((MEM_Static | MEM_FromBind)) updateMaxBlobsize(tls, pOut) goto __10 @@ -65859,7 +65220,7 @@ __205: ; Xsqlite3VdbeMemMove(tls, pOut, pIn1) - if !(((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & 0x1000) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0)) { + if !(((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & MEM_Ephem) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0)) { goto __208 } goto no_mem @@ -65896,8 +65257,8 @@ __209: goto __210 } - Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn1, 0x1000) - if !(((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & 0x1000) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0)) { + Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn1, MEM_Ephem) + if !(((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & MEM_Ephem) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0)) { goto __211 } goto no_mem @@ -65933,7 +65294,7 @@ __30: // out2 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) - Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn1, 0x1000) + Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn1, MEM_Ephem) goto __10 // Opcode: IntCopy P1 P2 * * * @@ -65964,7 +65325,7 @@ __32: // If this statement has violated immediate foreign key constraints, do // not return the number of rows modified. And do not RELEASE the statement // transaction. It needs to be rolled back. - if !(0 != (libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 0)))) { + if !(SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 0)))) { goto __213 } @@ -65987,7 +65348,7 @@ __213: // The statement transaction is never a top-level transaction. Hence // the RELEASE call below can never fail. - rc = Xsqlite3VdbeCloseStatement(tls, p, 1) + rc = Xsqlite3VdbeCloseStatement(tls, p, SAVEPOINT_RELEASE) // Invalidate all ephemeral cursor row caches (*Vdbe)(unsafe.Pointer(p)).FcacheCtr = (((*Vdbe)(unsafe.Pointer(p)).FcacheCtr + U32(2)) | U32(1)) @@ -66002,7 +65363,7 @@ __214: goto __216 } - if !(((int32((*Mem)(unsafe.Pointer((pMem + uintptr(i)*56))).Fflags) & 0x1000) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, (pMem+uintptr(i)*56)) != 0)) { + if !(((int32((*Mem)(unsafe.Pointer((pMem + uintptr(i)*56))).Fflags) & MEM_Ephem) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, (pMem+uintptr(i)*56)) != 0)) { goto __217 } goto no_mem @@ -66025,16 +65386,16 @@ __216: __218: ; - if !((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & 0x04) != 0) { + if !((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & SQLITE_TRACE_ROW) != 0) { goto __219 } - (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, uint32(0x04), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, uintptr(0)) + (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, SQLITE_TRACE_ROW, (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, uintptr(0)) __219: ; // Return SQLITE_ROW (*Vdbe)(unsafe.Pointer(p)).Fpc = ((int32((int64(pOp) - int64(aOp)) / 32)) + 1) - rc = 100 + rc = SQLITE_ROW goto vdbe_return // Opcode: Concat P1 P2 P3 * * @@ -66057,14 +65418,14 @@ __33: // Initial flags for P2 flags1 = (*Mem)(unsafe.Pointer(pIn1)).Fflags - if !(((int32(flags1) | int32((*Mem)(unsafe.Pointer(pIn2)).Fflags)) & 0x0001) != 0) { + if !(((int32(flags1) | int32((*Mem)(unsafe.Pointer(pIn2)).Fflags)) & MEM_Null) != 0) { goto __220 } Xsqlite3VdbeMemSetNull(tls, pOut) goto __10 __220: ; - if !((int32(flags1) & (0x0002 | 0x0010)) == 0) { + if !((int32(flags1) & (MEM_Str | MEM_Blob)) == 0) { goto __221 } if !(Xsqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(0)) != 0) { @@ -66073,10 +65434,10 @@ __220: goto no_mem __223: ; - flags1 = (U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32(0x0002))) + flags1 = (U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & libc.CplInt32(MEM_Str))) goto __222 __221: - if !((int32(flags1) & 0x4000) != 0) { + if !((int32(flags1) & MEM_Zero) != 0) { goto __224 } if !(Xsqlite3VdbeMemExpandBlob(tls, pIn1) != 0) { @@ -66085,13 +65446,13 @@ __221: goto no_mem __225: ; - flags1 = (U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32(0x0002))) + flags1 = (U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & libc.CplInt32(MEM_Str))) __224: ; __222: ; flags2 = (*Mem)(unsafe.Pointer(pIn2)).Fflags - if !((int32(flags2) & (0x0002 | 0x0010)) == 0) { + if !((int32(flags2) & (MEM_Str | MEM_Blob)) == 0) { goto __226 } if !(Xsqlite3VdbeMemStringify(tls, pIn2, encoding, uint8(0)) != 0) { @@ -66100,10 +65461,10 @@ __222: goto no_mem __228: ; - flags2 = (U16(int32((*Mem)(unsafe.Pointer(pIn2)).Fflags) & ^libc.Int32(0x0002))) + flags2 = (U16(int32((*Mem)(unsafe.Pointer(pIn2)).Fflags) & libc.CplInt32(MEM_Str))) goto __227 __226: - if !((int32(flags2) & 0x4000) != 0) { + if !((int32(flags2) & MEM_Zero) != 0) { goto __229 } if !(Xsqlite3VdbeMemExpandBlob(tls, pIn2) != 0) { @@ -66112,13 +65473,13 @@ __226: goto no_mem __230: ; - flags2 = (U16(int32((*Mem)(unsafe.Pointer(pIn2)).Fflags) & ^libc.Int32(0x0002))) + flags2 = (U16(int32((*Mem)(unsafe.Pointer(pIn2)).Fflags) & libc.CplInt32(MEM_Str))) __229: ; __227: ; nByte = (I64((*Mem)(unsafe.Pointer(pIn1)).Fn + (*Mem)(unsafe.Pointer(pIn2)).Fn)) - if !(nByte > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4)))) { + if !(nByte > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */))))) { goto __231 } goto too_big @@ -66130,7 +65491,7 @@ __231: goto no_mem __232: ; - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0002)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Str)) if !(pOut != pIn2) { goto __233 } @@ -66145,7 +65506,7 @@ __233: *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pOut)).Fz + uintptr(nByte))) = int8(0) *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pOut)).Fz + uintptr((nByte + int64(1))))) = int8(0) *(*int8)(unsafe.Pointer((*Mem)(unsafe.Pointer(pOut)).Fz + uintptr((nByte + int64(2))))) = int8(0) - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((0x0200)) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((MEM_Term)) (*Mem)(unsafe.Pointer(pOut)).Fn = int32(nByte) (*Mem)(unsafe.Pointer(pOut)).Fenc = encoding updateMaxBlobsize(tls, pOut) @@ -66196,19 +65557,19 @@ __38: // Real value of right operand type2 = numericType(tls, pIn2) pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) flags = (U16(int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) | int32((*Mem)(unsafe.Pointer(pIn2)).Fflags))) - if !(((int32(type1) & int32(type2)) & 0x0004) != 0) { + if !(((int32(type1) & int32(type2)) & MEM_Int) != 0) { goto __234 } iA = *(*I64)(unsafe.Pointer(pIn1 /* &.u */)) *(*I64)(unsafe.Pointer(bp + 176 /* iB */)) = *(*I64)(unsafe.Pointer(pIn2 /* &.u */)) switch int32((*Op)(unsafe.Pointer(pOp)).Fopcode) { - case 105: + case OP_Add: goto __237 - case 106: + case OP_Subtract: goto __238 - case 107: + case OP_Multiply: goto __239 - case 108: + case OP_Divide: goto __240 default: goto __241 @@ -66273,10 +65634,10 @@ __248: __236: ; *(*I64)(unsafe.Pointer(pOut /* &.u */)) = *(*I64)(unsafe.Pointer(bp + 176 /* iB */)) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) goto __235 __234: - if !((int32(flags) & 0x0001) != 0) { + if !((int32(flags) & MEM_Null) != 0) { goto __249 } goto arithmetic_result_is_null @@ -66286,13 +65647,13 @@ fp_math: rA = Xsqlite3VdbeRealValue(tls, pIn1) rB = Xsqlite3VdbeRealValue(tls, pIn2) switch int32((*Op)(unsafe.Pointer(pOp)).Fopcode) { - case 105: + case OP_Add: goto __252 - case 106: + case OP_Subtract: goto __253 - case 107: + case OP_Multiply: goto __254 - case 108: + case OP_Divide: goto __255 default: goto __256 @@ -66345,7 +65706,7 @@ __251: __260: ; *(*float64)(unsafe.Pointer(pOut /* &.u */)) = rB - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0008)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Real)) __250: ; __235: @@ -66414,7 +65775,7 @@ __43: pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) pIn2 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) - if !(((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) | int32((*Mem)(unsafe.Pointer(pIn2)).Fflags)) & 0x0001) != 0) { + if !(((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) | int32((*Mem)(unsafe.Pointer(pIn2)).Fflags)) & MEM_Null) != 0) { goto __262 } Xsqlite3VdbeMemSetNull(tls, pOut) @@ -66424,13 +65785,13 @@ __262: *(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) = Xsqlite3VdbeIntValue(tls, pIn2) iB1 = Xsqlite3VdbeIntValue(tls, pIn1) op = (*Op)(unsafe.Pointer(pOp)).Fopcode - if !(int32(op) == 101) { + if !(int32(op) == OP_BitAnd) { goto __263 } *(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) &= iB1 goto __264 __263: - if !(int32(op) == 102) { + if !(int32(op) == OP_BitOr) { goto __265 } *(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) |= iB1 @@ -66445,7 +65806,7 @@ __265: goto __268 } - op = (U8(((2 * 103) + 1) - int32(op))) + op = (U8(((2 * OP_ShiftLeft) + 1) - int32(op))) if iB1 > (int64(-64)) { iB1 = -iB1 } else { @@ -66457,7 +65818,7 @@ __268: if !(iB1 >= int64(64)) { goto __269 } - if (*(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) >= int64(0)) || (int32(op) == 103) { + if (*(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) >= int64(0)) || (int32(op) == OP_ShiftLeft) { *(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) = int64(0) } else { *(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) = int64(-1) @@ -66465,7 +65826,7 @@ __268: goto __270 __269: libc.Xmemcpy(tls, bp+184 /* &uA */, bp+192 /* &iA1 */, uint64(unsafe.Sizeof(U64(0)))) - if !(int32(op) == 103) { + if !(int32(op) == OP_ShiftLeft) { goto __271 } *(*U64)(unsafe.Pointer(bp + 184 /* uA */)) <<= iB1 @@ -66491,7 +65852,7 @@ __266: __264: ; *(*I64)(unsafe.Pointer(pOut /* &.u */)) = *(*I64)(unsafe.Pointer(bp + 192 /* iA1 */)) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) goto __10 // Opcode: AddImm P1 P2 * * * @@ -66516,18 +65877,18 @@ __44: // in1 // raise an SQLITE_MISMATCH exception. __45: // jump, in1 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0004) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Int) == 0) { goto __274 } - applyAffinity(tls, pIn1, int8(0x43), encoding) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0004) == 0) { + applyAffinity(tls, pIn1, SQLITE_AFF_NUMERIC, encoding) + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Int) == 0) { goto __275 } if !((*Op)(unsafe.Pointer(pOp)).Fp2 == 0) { goto __276 } - rc = 20 + rc = SQLITE_MISMATCH goto abort_due_to_error goto __277 __276: @@ -66539,7 +65900,7 @@ __275: __274: ; - (*Mem)(unsafe.Pointer(pIn1)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pIn1))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pIn1)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pIn1))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) goto __10 // Opcode: RealAffinity P1 * * * * @@ -66552,7 +65913,7 @@ __274: // to have only a real value. __46: // in1 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & (0x0004 | 0x0020)) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & (MEM_Int | MEM_IntReal)) != 0) { goto __278 } @@ -66582,7 +65943,7 @@ __47: // in1 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) rc = func() int32 { - if (int32((*Mem)(unsafe.Pointer((pIn1))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pIn1))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pIn1) } return 0 @@ -66705,26 +66066,26 @@ __53: // Copy of initial value of pIn3->flags pIn3 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) flags11 = (*Mem)(unsafe.Pointer(pIn1)).Fflags flags3 = (*Mem)(unsafe.Pointer(pIn3)).Fflags - if !(((int32(flags11) | int32(flags3)) & 0x0001) != 0) { + if !(((int32(flags11) | int32(flags3)) & MEM_Null) != 0) { goto __281 } // One or both operands are NULL - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x80) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_NULLEQ) != 0) { goto __283 } // If SQLITE_NULLEQ is set (which will only happen if the operator is // OP_Eq or OP_Ne) then take the jump or not depending on whether // or not both operands are null. - if !((((int32(flags11) & int32(flags3)) & 0x0001) != 0) && - ((int32(flags3) & 0x0100) == 0)) { + if !((((int32(flags11) & int32(flags3)) & MEM_Null) != 0) && + ((int32(flags3) & MEM_Cleared) == 0)) { goto __285 } res = 0 // Operands are equal goto __286 __285: res = func() int32 { - if (int32(flags3) & 0x0001) != 0 { + if (int32(flags3) & MEM_Null) != 0 { return -1 } return +1 @@ -66736,18 +66097,18 @@ __283: // SQLITE_NULLEQ is clear and at least one operand is NULL, // then the result is always NULL. // The jump is taken if the SQLITE_JUMPIFNULL bit is set. - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x20) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_STOREP2) != 0) { goto __287 } pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) iCompare = 1 // Operands are not equal - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0001)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Null)) goto __288 __287: ; - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x10) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_JUMPIFNULL) != 0) { goto __289 } goto jump_to_p2 @@ -66761,14 +66122,14 @@ __284: goto __282 __281: // Neither operand is NULL. Do a comparison. - affinity = (int8(int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x47)) - if !(int32(affinity) >= 0x43) { + affinity = (int8(int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_AFF_MASK)) + if !(int32(affinity) >= SQLITE_AFF_NUMERIC) { goto __290 } - if !(((int32(flags11) | int32(flags3)) & 0x0002) != 0) { + if !(((int32(flags11) | int32(flags3)) & MEM_Str) != 0) { goto __292 } - if !((int32(flags11) & (((0x0004 | 0x0020) | 0x0008) | 0x0002)) == 0x0002) { + if !((int32(flags11) & (((MEM_Int | MEM_IntReal) | MEM_Real) | MEM_Str)) == MEM_Str) { goto __293 } applyNumericAffinity(tls, pIn1, 0) @@ -66776,7 +66137,7 @@ __281: flags3 = (*Mem)(unsafe.Pointer(pIn3)).Fflags __293: ; - if !((int32(flags3) & (((0x0004 | 0x0020) | 0x0008) | 0x0002)) == 0x0002) { + if !((int32(flags3) & (((MEM_Int | MEM_IntReal) | MEM_Real) | MEM_Str)) == MEM_Str) { goto __294 } applyNumericAffinity(tls, pIn3, 0) @@ -66786,7 +66147,7 @@ __292: ; // Handle the common case of integer comparison here, as an // optimization, to avoid a call to sqlite3MemCompare() - if !(((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & int32((*Mem)(unsafe.Pointer(pIn3)).Fflags)) & 0x0004) != 0) { + if !(((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & int32((*Mem)(unsafe.Pointer(pIn3)).Fflags)) & MEM_Int) != 0) { goto __295 } if !(*(*I64)(unsafe.Pointer(pIn3 /* &.u */)) > *(*I64)(unsafe.Pointer(pIn1 /* &.u */))) { @@ -66809,31 +66170,31 @@ __295: ; goto __291 __290: - if !(int32(affinity) == 0x42) { + if !(int32(affinity) == SQLITE_AFF_TEXT) { goto __298 } - if !(((int32(flags11) & 0x0002) == 0) && ((int32(flags11) & ((0x0004 | 0x0008) | 0x0020)) != 0)) { + if !(((int32(flags11) & MEM_Str) == 0) && ((int32(flags11) & ((MEM_Int | MEM_Real) | MEM_IntReal)) != 0)) { goto __299 } Xsqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(1)) - flags11 = (U16((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32(0xc1bf)) | (int32(flags11) & 0xc1bf))) + flags11 = (U16((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & libc.CplInt32(MEM_TypeMask)) | (int32(flags11) & MEM_TypeMask))) if !(pIn1 == pIn3) { goto __300 } - flags3 = (U16(int32(flags11) | 0x0002)) + flags3 = (U16(int32(flags11) | MEM_Str)) __300: ; __299: ; - if !(((int32(flags3) & 0x0002) == 0) && ((int32(flags3) & ((0x0004 | 0x0008) | 0x0020)) != 0)) { + if !(((int32(flags3) & MEM_Str) == 0) && ((int32(flags3) & ((MEM_Int | MEM_Real) | MEM_IntReal)) != 0)) { goto __301 } Xsqlite3VdbeMemStringify(tls, pIn3, encoding, uint8(1)) - flags3 = (U16((int32((*Mem)(unsafe.Pointer(pIn3)).Fflags) & ^libc.Int32(0xc1bf)) | (int32(flags3) & 0xc1bf))) + flags3 = (U16((int32((*Mem)(unsafe.Pointer(pIn3)).Fflags) & libc.CplInt32(MEM_TypeMask)) | (int32(flags3) & MEM_TypeMask))) __301: ; __298: @@ -66856,16 +66217,16 @@ compare_op: if !(res < 0) { goto __302 } - res2 = int32(aLTb[(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) - 52)]) + res2 = int32(aLTb[(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) - OP_Ne)]) goto __303 __302: if !(res == 0) { goto __304 } - res2 = int32(aEQb[(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) - 52)]) + res2 = int32(aEQb[(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) - OP_Ne)]) goto __305 __304: - res2 = int32(aGTb[(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) - 52)]) + res2 = int32(aGTb[(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) - OP_Ne)]) __305: ; __303: @@ -66877,12 +66238,12 @@ __303: (*Mem)(unsafe.Pointer(pIn1)).Fflags = flags11 - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x20) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_STOREP2) != 0) { goto __306 } pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) iCompare = res - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x08) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & SQLITE_KEEPNULL) != 0) { goto __308 } // The KEEPNULL flag prevents OP_Eq from overwriting a NULL with 1 @@ -66893,7 +66254,7 @@ __303: // Therefore it is not necessary to check the content of r[P2] for // NULL. - if !((libc.Bool32(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 53)) == res2) { + if !((libc.Bool32(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_Eq)) == res2) { goto __309 } goto __10 @@ -66902,7 +66263,7 @@ __309: __308: ; - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) *(*I64)(unsafe.Pointer(pOut /* &.u */)) = I64(res2) goto __307 @@ -66978,7 +66339,7 @@ __55: // and strings are less than blobs. __56: // The permutation - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x01) == 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_PERMUTE) == 0) { goto __312 } aPermute = uintptr(0) @@ -67007,13 +66368,13 @@ __314: } pColl = *(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */) + uintptr(i1)*8)) - bRev = (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i1)))) & 0x01) + bRev = (int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i1)))) & KEYINFO_ORDER_DESC) iCompare = Xsqlite3MemCompare(tls, (aMem + uintptr((U32(p11)+idx))*56), (aMem + uintptr((U32(p21)+idx))*56), pColl) if !(iCompare != 0) { goto __317 } - if !(((int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i1)))) & 0x02) != 0) && - (((int32((*Mem)(unsafe.Pointer(aMem+uintptr((U32(p11)+idx))*56)).Fflags) & 0x0001) != 0) || ((int32((*Mem)(unsafe.Pointer(aMem+uintptr((U32(p21)+idx))*56)).Fflags) & 0x0001) != 0))) { + if !(((int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i1)))) & KEYINFO_ORDER_BIGNULL) != 0) && + (((int32((*Mem)(unsafe.Pointer(aMem+uintptr((U32(p11)+idx))*56)).Fflags) & MEM_Null) != 0) || ((int32((*Mem)(unsafe.Pointer(aMem+uintptr((U32(p21)+idx))*56)).Fflags) & MEM_Null) != 0))) { goto __318 } iCompare = -iCompare @@ -67086,7 +66447,7 @@ __59: // Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL v1 = Xsqlite3VdbeBooleanValue(tls, (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56), 2) v2 = Xsqlite3VdbeBooleanValue(tls, (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56), 2) - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 44) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_And) { goto __324 } v1 = int32(and_logic[((v1 * 3) + v2)]) @@ -67099,11 +66460,11 @@ __325: if !(v1 == 2) { goto __326 } - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0001)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Null)) goto __327 __326: *(*I64)(unsafe.Pointer(pOut /* &.u */)) = I64(v1) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0004)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Int)) __327: ; goto __10 @@ -67143,7 +66504,7 @@ __60: // in1, out2 __61: // same as TK_NOT, in1, out2 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0001) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Null) == 0) { goto __328 } Xsqlite3VdbeMemSetInt64(tls, pOut, libc.BoolInt64(!(Xsqlite3VdbeBooleanValue(tls, pIn1, 0) != 0))) @@ -67164,10 +66525,10 @@ __62: // same as TK_BITNOT, in1, out2 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) pOut = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) Xsqlite3VdbeMemSetNull(tls, pOut) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0001) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Null) == 0) { goto __330 } - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Int *(*I64)(unsafe.Pointer(pOut /* &.u */)) = ^Xsqlite3VdbeIntValue(tls, pIn1) __330: ; @@ -67205,7 +66566,7 @@ __333: *(*U8)(unsafe.Pointer((*VdbeFrame)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FpFrame)).FaOnce + uintptr((iAddr / U32(8))))) |= U8((int32(1) << (iAddr & U32(7)))) goto __332 __331: - if !((*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp+uintptr(0)*32)).Fp1 == (*Op)(unsafe.Pointer(pOp)).Fp1) { + if !((*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp)).Fp1 == (*Op)(unsafe.Pointer(pOp)).Fp1) { goto __334 } @@ -67215,7 +66576,7 @@ __334: __332: ; - (*Op)(unsafe.Pointer(pOp)).Fp1 = (*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(0)*32)).Fp1 + (*Op)(unsafe.Pointer(pOp)).Fp1 = (*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp)).Fp1 goto __10 // Opcode: If P1 P2 P3 * * @@ -67257,7 +66618,7 @@ __336: __66: // same as TK_ISNULL, jump, in1 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0001) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Null) != 0) { goto __337 } goto jump_to_p2 @@ -67272,7 +66633,7 @@ __337: __67: // same as TK_NOTNULL, jump, in1 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0001) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Null) == 0) { goto __338 } goto jump_to_p2 @@ -67317,7 +66678,7 @@ __69: // The VDBE cursor ; pC = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*8)) pOut = ((*Vdbe)(unsafe.Pointer(p)).FaMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) - if !((pC == uintptr(0)) || (int32((*VdbeCursor)(unsafe.Pointer(pC)).FeCurType) != 0)) { + if !((pC == uintptr(0)) || (int32((*VdbeCursor)(unsafe.Pointer(pC)).FeCurType) != CURTYPE_BTREE)) { goto __340 } Xsqlite3VdbeMemSetNull(tls, pOut) @@ -67375,7 +66736,7 @@ __342: if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FnullRow != 0) { goto __344 } - if !(int32((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FeCurType) == 3) { + if !(int32((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FeCurType) == CURTYPE_PSEUDO) { goto __346 } // For the special case of as pseudo-cursor, the seekResult field @@ -67399,7 +66760,7 @@ __344: (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FaRow = Xsqlite3BtreePayloadFetch(tls, pCrsr, (*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)) + 116 /* &.szRow */)) // Maximum page size is 64KiB - if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FpayloadSize > U32(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4)))) { + if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FpayloadSize > U32(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */))))) { goto __348 } goto too_big @@ -67411,15 +66772,15 @@ __345: (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FiHdrOffset = U32(func() uint8 { if int32(*(*U8)(unsafe.Pointer((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FaRow))) < int32(U8(0x80)) { return uint8(func() int32 { - (*(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4))) = U32(*(*U8)(unsafe.Pointer((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FaRow))) + (*(*U32)(unsafe.Pointer(aOffset))) = U32(*(*U8)(unsafe.Pointer((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FaRow))) return 1 }()) } - return Xsqlite3GetVarint32(tls, (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FaRow, (aOffset + uintptr(0)*4)) + return Xsqlite3GetVarint32(tls, (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FaRow, (aOffset)) }()) (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FnHdrParsed = U16(0) - if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FszRow < *(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4))) { + if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FszRow < *(*U32)(unsafe.Pointer(aOffset))) { goto __349 } //OPTIMIZATION-IF-FALSE // pC->aRow does not have to hold the entire row, but it does at least @@ -67437,7 +66798,7 @@ __345: // them, respectively. So the maximum header length results from a // 3-byte type for each of the maximum of 32768 columns plus three // extra bytes for the header length itself. 32768*3 + 3 = 98307. - if !((*(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4)) > U32(98307)) || (*(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4)) > (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FpayloadSize)) { + if !((*(*U32)(unsafe.Pointer(aOffset)) > U32(98307)) || (*(*U32)(unsafe.Pointer(aOffset)) > (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FpayloadSize)) { goto __351 } goto op_column_corrupt @@ -67473,7 +66834,7 @@ __343: } // If there is more header available for parsing in the record, try // to extract additional fields up through the p2+1-th field - if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FiHdrOffset < *(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4))) { + if !((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FiHdrOffset < *(*U32)(unsafe.Pointer(aOffset))) { goto __354 } // Make sure zData points to enough of the record to cover the header. @@ -67481,8 +66842,8 @@ __343: goto __356 } libc.Xmemset(tls, bp+216 /* &sMem */, 0, uint64(unsafe.Sizeof(Mem{}))) - rc = Xsqlite3VdbeMemFromBtreeZeroOffset(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)) + 56 /* &.uc */)), *(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4)), bp+216 /* &sMem */) - if !(rc != 0) { + rc = Xsqlite3VdbeMemFromBtreeZeroOffset(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)) + 56 /* &.uc */)), *(*U32)(unsafe.Pointer(aOffset)), bp+216 /* &sMem */) + if !(rc != SQLITE_OK) { goto __358 } goto abort_due_to_error @@ -67500,10 +66861,10 @@ op_column_read_header: i2 = int32((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FnHdrParsed) offset64 = U64(*(*U32)(unsafe.Pointer(aOffset + uintptr(i2)*4))) zHdr = (zData + uintptr((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FiHdrOffset)) - zEndHdr = (zData + uintptr(*(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4)))) + zEndHdr = (zData + uintptr(*(*U32)(unsafe.Pointer(aOffset)))) __359: - if !((libc.AssignPtrUint32((*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */))+120 /* &.aType */)+uintptr(i2)*4, libc.AssignPtrUint32(bp+272 /* t */, U32(*(*U8)(unsafe.Pointer(zHdr + uintptr(0))))))) < U32(0x80)) { + if !((libc.AssignPtrUint32((*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */))+120 /* &.aType */)+uintptr(i2)*4, libc.AssignPtrUint32(bp+272 /* t */, U32(*(*U8)(unsafe.Pointer(zHdr)))))) < U32(0x80)) { goto __362 } zHdr++ @@ -67533,7 +66894,7 @@ __361: (offset64 > U64((*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)))).FpayloadSize))) { goto __364 } - if !(*(*U32)(unsafe.Pointer(aOffset + uintptr(0)*4)) == U32(0)) { + if !(*(*U32)(unsafe.Pointer(aOffset)) == U32(0)) { goto __365 } i2 = 0 @@ -67575,7 +66936,7 @@ __355: if !(int32((*Op)(unsafe.Pointer(pOp)).Fp4type) == (-11)) { goto __370 } - Xsqlite3VdbeMemShallowCopy(tls, pDest, *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)), 0x0800) + Xsqlite3VdbeMemShallowCopy(tls, pDest, *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)), MEM_Static) goto __371 __370: Xsqlite3VdbeMemSetNull(tls, pDest) @@ -67594,7 +66955,7 @@ __353: // reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are // all valid. - if !((int32((*Mem)(unsafe.Pointer((pDest))).Fflags) & (0x2000 | 0x0400)) != 0) { + if !((int32((*Mem)(unsafe.Pointer((pDest))).Fflags) & (MEM_Agg | MEM_Dyn)) != 0) { goto __372 } Xsqlite3VdbeMemSetNull(tls, pDest) @@ -67618,7 +66979,7 @@ __375: if !((*Mem)(unsafe.Pointer(pDest)).FszMalloc < (len + 2)) { goto __377 } - (*Mem)(unsafe.Pointer(pDest)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pDest)).Fflags = MEM_Null if !(Xsqlite3VdbeMemGrow(tls, pDest, (len+2), 0) != 0) { goto __379 } @@ -67640,8 +67001,8 @@ __376: __373: (*Mem)(unsafe.Pointer(pDest)).Fenc = encoding // This branch happens only when content is on overflow pages - if !((((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (0x40 | 0x80)) != 0) && - (((*(*U32)(unsafe.Pointer(bp + 272 /* t */)) >= U32(12)) && ((*(*U32)(unsafe.Pointer(bp + 272 /* t */)) & U32(1)) == U32(0))) || ((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x80) != 0))) || + if !((((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (OPFLAG_LENGTHARG | OPFLAG_TYPEOFARG)) != 0) && + (((*(*U32)(unsafe.Pointer(bp + 272 /* t */)) >= U32(12)) && ((*(*U32)(unsafe.Pointer(bp + 272 /* t */)) & U32(1)) == U32(0))) || ((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_TYPEOFARG) != 0))) || ((libc.AssignInt32(&len, int32(Xsqlite3VdbeSerialTypeLen(tls, *(*U32)(unsafe.Pointer(bp + 272 /* t */)))))) == 0)) { goto __380 } @@ -67661,14 +67022,14 @@ __373: goto __381 __380: rc = Xsqlite3VdbeMemFromBtree(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 200 /* pC1 */)) + 56 /* &.uc */)), *(*U32)(unsafe.Pointer(aOffset + uintptr(*(*U32)(unsafe.Pointer(bp + 208 /* p22 */)))*4)), uint32(len), pDest) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __382 } goto abort_due_to_error __382: ; Xsqlite3VdbeSerialGet(tls, (*Mem)(unsafe.Pointer(pDest)).Fz, *(*U32)(unsafe.Pointer(bp + 272 /* t */)), pDest) - *(*U16)(unsafe.Pointer(pDest + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x1000))) + *(*U16)(unsafe.Pointer(pDest + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Ephem))) __381: ; __374: @@ -67680,10 +67041,10 @@ op_column_out: goto __10 op_column_corrupt: - if !((*Op)(unsafe.Pointer(aOp+uintptr(0)*32)).Fp3 > 0) { + if !((*Op)(unsafe.Pointer(aOp)).Fp3 > 0) { goto __383 } - pOp = (aOp + uintptr(((*Op)(unsafe.Pointer(aOp+uintptr(0)*32)).Fp3-1))*32) + pOp = (aOp + uintptr(((*Op)(unsafe.Pointer(aOp)).Fp3-1))*32) goto __10 goto __384 __383: @@ -67710,8 +67071,8 @@ __385: goto __386 } - applyAffinity(tls, pIn1, *(*int8)(unsafe.Pointer(zAffinity + uintptr(0))), encoding) - if !((int32(*(*int8)(unsafe.Pointer(zAffinity + uintptr(0)))) == 0x45) && ((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0004) != 0)) { + applyAffinity(tls, pIn1, *(*int8)(unsafe.Pointer(zAffinity)), encoding) + if !((int32(*(*int8)(unsafe.Pointer(zAffinity))) == SQLITE_AFF_REAL) && ((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Int) != 0)) { goto __387 } // When applying REAL affinity, if the result is still an MEM_Int @@ -67722,20 +67083,20 @@ __385: if !((*(*I64)(unsafe.Pointer(pIn1 /* &.u */)) <= 140737488355327) && (*(*I64)(unsafe.Pointer(pIn1 /* &.u */)) >= -140737488355328)) { goto __388 } - *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) |= U16((0x0020)) - *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0004))) + *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) |= U16((MEM_IntReal)) + *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Int))) goto __389 __388: *(*float64)(unsafe.Pointer(pIn1 /* &.u */)) = float64(*(*I64)(unsafe.Pointer(pIn1 /* &.u */))) - *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) |= U16((0x0008)) - *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0004))) + *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) |= U16((MEM_Real)) + *(*U16)(unsafe.Pointer(pIn1 + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Int))) __389: ; __387: ; zAffinity++ - if !(int32(*(*int8)(unsafe.Pointer(zAffinity + uintptr(0)))) == 0) { + if !(int32(*(*int8)(unsafe.Pointer(zAffinity))) == 0) { goto __390 } goto __386 @@ -67811,12 +67172,12 @@ __72: // Where to write next byte of the payload } pRec = pData0 __392: - applyAffinity(tls, pRec, *(*int8)(unsafe.Pointer(zAffinity1 + uintptr(0))), encoding) - if !((int32(*(*int8)(unsafe.Pointer(zAffinity1 + uintptr(0)))) == 0x45) && ((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0004) != 0)) { + applyAffinity(tls, pRec, *(*int8)(unsafe.Pointer(zAffinity1)), encoding) + if !((int32(*(*int8)(unsafe.Pointer(zAffinity1))) == SQLITE_AFF_REAL) && ((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Int) != 0)) { goto __395 } - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((0x0020)) - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0004))) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((MEM_IntReal)) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_Int))) __395: ; @@ -67825,7 +67186,7 @@ __395: goto __393 __393: - if *(*int8)(unsafe.Pointer(zAffinity1 + uintptr(0))) != 0 { + if *(*int8)(unsafe.Pointer(zAffinity1)) != 0 { goto __392 } goto __394 @@ -67862,10 +67223,10 @@ __391: pRec = pLast __396: ; - if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0001) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Null) != 0) { goto __399 } - if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x4000) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Zero) != 0) { goto __401 } // Values with MEM_Null and MEM_Zero are created by xColumn virtual @@ -67884,7 +67245,7 @@ __402: nHdr++ goto __400 __399: - if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & (0x0004 | 0x0020)) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & (MEM_Int | MEM_IntReal)) != 0) { goto __403 } // Figure out whether to use 1, 2, 4, 6 or 8 bytes. @@ -67945,15 +67306,15 @@ __415: goto __418 __417: nData = nData + (uint64(8)) - if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0020) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_IntReal) != 0) { goto __419 } // If the value is IntReal and is going to take up 8 bytes to store // as an integer, then we might as well make it an 8-byte floating // point value *(*float64)(unsafe.Pointer(pRec /* &.u */)) = float64(*(*I64)(unsafe.Pointer(pRec /* &.u */))) - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0020))) - *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) &= libc.Uint16FromInt32((libc.CplInt32(MEM_IntReal))) + *(*U16)(unsafe.Pointer(pRec + 8 /* &.flags */)) |= U16((MEM_Real)) (*Mem)(unsafe.Pointer(pRec)).FuTemp = U32(7) goto __420 __419: @@ -67972,7 +67333,7 @@ __408: ; goto __404 __403: - if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0008) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Real) != 0) { goto __421 } nHdr++ @@ -67983,8 +67344,8 @@ __421: ; len1 = U32((*Mem)(unsafe.Pointer(pRec)).Fn) - serial_type = (((len1 * U32(2)) + U32(12)) + (U32(libc.Bool32((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x0002) != 0)))) - if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & 0x4000) != 0) { + serial_type = (((len1 * U32(2)) + U32(12)) + (U32(libc.Bool32((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Str) != 0)))) + if !((int32((*Mem)(unsafe.Pointer(pRec)).Fflags) & MEM_Zero) != 0) { goto __423 } serial_type = serial_type + (U32(*(*int32)(unsafe.Pointer(pRec /* &.u */)) * 2)) @@ -68069,7 +67430,7 @@ __429: __431: // Need to make sure that the output is not too big and then enlarge // the output register to hold the full result - if !((nByte1 + nZero) > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4)))) { + if !((nByte1 + nZero) > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */))))) { goto __433 } goto too_big @@ -68084,12 +67445,12 @@ __434: __432: ; (*Mem)(unsafe.Pointer(pOut)).Fn = int32(nByte1) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0010) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Blob if !(nZero != 0) { goto __435 } *(*int32)(unsafe.Pointer(pOut /* &.u */)) = int32(nZero) - *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((0x4000)) + *(*U16)(unsafe.Pointer(pOut + 8 /* &.flags */)) |= U16((MEM_Zero)) __435: ; updateMaxBlobsize(tls, pOut) @@ -68176,7 +67537,7 @@ __74: // Assert that the p1 parameter is valid. Also that if there is no open // transaction, then there cannot be any savepoints. - if !(p12 == 0) { + if !(p12 == SAVEPOINT_BEGIN) { goto __442 } if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0) { @@ -68185,7 +67546,7 @@ __74: // A new savepoint cannot be created if there are active write // statements (i.e. open read/write incremental blob handles). Xsqlite3VdbeError(tls, p, ts+7199 /* "cannot open save..." */, 0) - rc = 5 + rc = SQLITE_BUSY goto __445 __444: nName = Xsqlite3Strlen30(tls, zName) @@ -68195,9 +67556,9 @@ __444: // If this is a transaction savepoint being opened, it is guaranteed // that the db->aVTrans[] array is empty. - rc = Xsqlite3VtabSavepoint(tls, db, 0, + rc = Xsqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, ((*Sqlite3)(unsafe.Pointer(db)).FnStatement + (*Sqlite3)(unsafe.Pointer(db)).FnSavepoint)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __446 } goto abort_due_to_error @@ -68209,7 +67570,7 @@ __446: if !(pNew != 0) { goto __447 } - (*Savepoint)(unsafe.Pointer(pNew)).FzName = (pNew + uintptr(1)*32) + (*Savepoint)(unsafe.Pointer(pNew)).FzName = (pNew + 1*32) libc.Xmemcpy(tls, (*Savepoint)(unsafe.Pointer(pNew)).FzName, zName, (uint64(nName + 1))) // If there is no open transaction, then mark this as a special @@ -68258,17 +67619,17 @@ __452: goto __453 } Xsqlite3VdbeError(tls, p, ts+7250 /* "no such savepoin..." */, libc.VaList(bp+56, zName)) - rc = 1 + rc = SQLITE_ERROR goto __454 __453: - if !(((*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0) && (p12 == 1)) { + if !(((*Sqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0) && (p12 == SAVEPOINT_RELEASE)) { goto __455 } // It is not possible to release (commit) a savepoint if there are // active write statements. Xsqlite3VdbeError(tls, p, ts+7272 /* "cannot release s..." */, 0) - rc = 5 + rc = SQLITE_BUSY goto __456 __455: @@ -68276,22 +67637,22 @@ __455: // and this is a RELEASE command, then the current transaction // is committed. isTransaction = (libc.Bool32(((*Savepoint)(unsafe.Pointer(pSavepoint)).FpNext == uintptr(0)) && ((*Sqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint != 0))) - if !((isTransaction != 0) && (p12 == 1)) { + if !((isTransaction != 0) && (p12 == SAVEPOINT_RELEASE)) { goto __457 } - if !((libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 1))) != 0) { + if !((libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 1))) != SQLITE_OK) { goto __459 } goto vdbe_return __459: ; (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1) - if !(Xsqlite3VdbeHalt(tls, p) == 5) { + if !(Xsqlite3VdbeHalt(tls, p) == SQLITE_BUSY) { goto __460 } (*Vdbe)(unsafe.Pointer(p)).Fpc = (int32((int64(pOp) - int64(aOp)) / 32)) (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(0) - (*Vdbe)(unsafe.Pointer(p)).Frc = libc.AssignInt32(&rc, 5) + (*Vdbe)(unsafe.Pointer(p)).Frc = libc.AssignInt32(&rc, SQLITE_BUSY) goto vdbe_return __460: ; @@ -68308,19 +67669,19 @@ __462: goto __458 __457: iSavepoint = (((*Sqlite3)(unsafe.Pointer(db)).FnSavepoint - iSavepoint) - 1) - if !(p12 == 2) { + if !(p12 == SAVEPOINT_ROLLBACK) { goto __463 } - isSchemaChange = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0001)) != U32(0))) + isSchemaChange = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_SchemaChange) != U32(0))) ii = 0 __465: if !(ii < (*Sqlite3)(unsafe.Pointer(db)).FnDb) { goto __467 } rc = Xsqlite3BtreeTripAllCursors(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii)*32)).FpBt, - (4 | (int32(2) << 8)), + (SQLITE_ABORT | (int32(2) << 8)), (libc.Bool32(isSchemaChange == 0))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __468 } goto abort_due_to_error @@ -68345,7 +67706,7 @@ __469: goto __471 } rc = Xsqlite3BtreeSavepoint(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(ii)*32)).FpBt, p12, iSavepoint) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __472 } goto abort_due_to_error @@ -68363,7 +67724,7 @@ __471: } Xsqlite3ExpirePreparedStatements(tls, db, 0) Xsqlite3ResetAllSchemasOfConnection(tls, db) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) __473: ; __458: @@ -68393,7 +67754,7 @@ __476: // too. If it is a ROLLBACK TO, then set the number of deferred // constraint violations present in the database to the value stored // when the savepoint was created. - if !(p12 == 1) { + if !(p12 == SAVEPOINT_RELEASE) { goto __477 } @@ -68413,11 +67774,11 @@ __477: __478: ; - if !(!(isTransaction != 0) || (p12 == 2)) { + if !(!(isTransaction != 0) || (p12 == SAVEPOINT_ROLLBACK)) { goto __480 } rc = Xsqlite3VtabSavepoint(tls, db, p12, iSavepoint) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __481 } goto abort_due_to_error @@ -68462,7 +67823,7 @@ __75: goto __485 } - Xsqlite3RollbackAll(tls, db, (4 | (int32(2) << 8))) + Xsqlite3RollbackAll(tls, db, (SQLITE_ABORT | (int32(2) << 8))) (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1) goto __486 __485: @@ -68473,11 +67834,11 @@ __485: // return an error indicating that the other VMs must complete first. Xsqlite3VdbeError(tls, p, ts+7326 /* "cannot commit tr..." */, 0) - rc = 5 + rc = SQLITE_BUSY goto abort_due_to_error goto __488 __487: - if !((libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 1))) != 0) { + if !((libc.AssignInt32(&rc, Xsqlite3VdbeCheckFk(tls, p, 1))) != SQLITE_OK) { goto __489 } goto vdbe_return @@ -68490,23 +67851,23 @@ __488: ; __486: ; - if !(Xsqlite3VdbeHalt(tls, p) == 5) { + if !(Xsqlite3VdbeHalt(tls, p) == SQLITE_BUSY) { goto __491 } (*Vdbe)(unsafe.Pointer(p)).Fpc = (int32((int64(pOp) - int64(aOp)) / 32)) (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = (U8(1 - desiredAutoCommit)) - (*Vdbe)(unsafe.Pointer(p)).Frc = libc.AssignInt32(&rc, 5) + (*Vdbe)(unsafe.Pointer(p)).Frc = libc.AssignInt32(&rc, SQLITE_BUSY) goto vdbe_return __491: ; Xsqlite3CloseSavepoints(tls, db) - if !((*Vdbe)(unsafe.Pointer(p)).Frc == 0) { + if !((*Vdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK) { goto __492 } - rc = 101 + rc = SQLITE_DONE goto __493 __492: - rc = 1 + rc = SQLITE_ERROR __493: ; goto vdbe_return @@ -68525,7 +67886,7 @@ __483: }() }(), 0) - rc = 1 + rc = SQLITE_ERROR goto abort_due_to_error __484: ; @@ -68567,10 +67928,10 @@ __484: __76: *(*int32)(unsafe.Pointer(bp + 288 /* iMeta */)) = 0 - if !(((*Op)(unsafe.Pointer(pOp)).Fp2 != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00100000)) != uint64(0))) { + if !(((*Op)(unsafe.Pointer(pOp)).Fp2 != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_QueryOnly) != uint64(0))) { goto __494 } - rc = 8 + rc = SQLITE_READONLY goto abort_due_to_error __494: ; @@ -68581,10 +67942,10 @@ __494: } rc = Xsqlite3BtreeBeginTrans(tls, pBt, (*Op)(unsafe.Pointer(pOp)).Fp2, bp+288 /* &iMeta */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __496 } - if !((rc & 0xff) == 5) { + if !((rc & 0xff) == SQLITE_BUSY) { goto __497 } (*Vdbe)(unsafe.Pointer(p)).Fpc = (int32((int64(pOp) - int64(aOp)) / 32)) @@ -68611,8 +67972,8 @@ __496: __499: ; - rc = Xsqlite3VtabSavepoint(tls, db, 0, ((*Vdbe)(unsafe.Pointer(p)).FiStatement - 1)) - if !(rc == 0) { + rc = Xsqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, ((*Vdbe)(unsafe.Pointer(p)).FiStatement - 1)) + if !(rc == SQLITE_OK) { goto __500 } rc = Xsqlite3BtreeBeginStmt(tls, pBt, (*Vdbe)(unsafe.Pointer(p)).FiStatement) @@ -68658,7 +68019,7 @@ __495: __502: ; libc.SetBitFieldPtr16Uint32(p+200 /* &.expired */, Bft(1), 0, 0x3) - rc = 17 + rc = SQLITE_SCHEMA __501: ; if !(rc != 0) { @@ -68711,15 +68072,15 @@ __78: // See note about index shifting on OP_ReadCookie rc = Xsqlite3BtreeUpdateMeta(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, (*Op)(unsafe.Pointer(pOp)).Fp2, uint32((*Op)(unsafe.Pointer(pOp)).Fp3)) - if !((*Op)(unsafe.Pointer(pOp)).Fp2 == 1) { + if !((*Op)(unsafe.Pointer(pOp)).Fp2 == BTREE_SCHEMA_VERSION) { goto __504 } // When the schema cookie changes, record the new cookie internally (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fschema_cookie = ((*Op)(unsafe.Pointer(pOp)).Fp3 - int32((*Op)(unsafe.Pointer(pOp)).Fp5)) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) goto __505 __504: - if !((*Op)(unsafe.Pointer(pOp)).Fp2 == 2) { + if !((*Op)(unsafe.Pointer(pOp)).Fp2 == BTREE_FILE_FORMAT) { goto __506 } // Record changes in the file format @@ -68846,7 +68207,7 @@ __81: if !((int32(*(*uint16)(unsafe.Pointer(p + 200 /* &.expired */)) & 0x3 >> 0)) == 1) { goto __510 } - rc = (4 | (int32(2) << 8)) + rc = (SQLITE_ABORT | (int32(2) << 8)) goto abort_due_to_error __510: ; @@ -68859,11 +68220,11 @@ __510: pDb1 = ((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb1)*32) pX = (*Db)(unsafe.Pointer(pDb1)).FpBt - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 97) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_OpenWrite) { goto __511 } - wrFlag = (0x00000004 | (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x08)) + wrFlag = (BTREE_WRCSR | (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_FORDELETE)) if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb1)).FpSchema)).Ffile_format) < int32((*Vdbe)(unsafe.Pointer(p)).FminWriteFileFormat)) { goto __513 @@ -68876,7 +68237,7 @@ __511: wrFlag = 0 __512: ; - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x10) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_P2ISREG) != 0) { goto __514 } @@ -68909,7 +68270,7 @@ __516: ; // Table with INTEGER PRIMARY KEY and nothing else - pCur = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, nField1, iDb1, uint8(0)) + pCur = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, nField1, iDb1, CURTYPE_BTREE) if !(pCur == uintptr(0)) { goto __518 } @@ -68931,7 +68292,7 @@ open_cursor_set_hints: ; Xsqlite3BtreeCursorHintFlags(tls, *(*uintptr)(unsafe.Pointer(pCur + 56 /* &.uc */)), - (uint32(int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (0x01 | 0x02)))) + (uint32(int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (OPFLAG_BULKCSR | OPFLAG_SEEKEQ)))) if !(rc != 0) { goto __519 } @@ -68953,7 +68314,7 @@ __82: // The new cursor // Only ephemeral cursors can be duplicated - pCx = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, int32((*VdbeCursor)(unsafe.Pointer(pOrig)).FnField), -1, uint8(0)) + pCx = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, int32((*VdbeCursor)(unsafe.Pointer(pOrig)).FnField), -1, CURTYPE_BTREE) if !(pCx == uintptr(0)) { goto __520 } @@ -68966,7 +68327,7 @@ __520: (*VdbeCursor)(unsafe.Pointer(pCx)).FisTable = (*VdbeCursor)(unsafe.Pointer(pOrig)).FisTable (*VdbeCursor)(unsafe.Pointer(pCx)).FpgnoRoot = (*VdbeCursor)(unsafe.Pointer(pOrig)).FpgnoRoot libc.SetBitFieldPtr8Uint32(pCx+8 /* &.isOrdered */, (Bool(int32(*(*uint8)(unsafe.Pointer(pOrig + 8 /* &.isOrdered */)) & 0x4 >> 2))), 2, 0x4) - rc = Xsqlite3BtreeCursor(tls, (*VdbeCursor)(unsafe.Pointer(pOrig)).FpBtx, (*VdbeCursor)(unsafe.Pointer(pCx)).FpgnoRoot, 0x00000004, + rc = Xsqlite3BtreeCursor(tls, (*VdbeCursor)(unsafe.Pointer(pOrig)).FpBtx, (*VdbeCursor)(unsafe.Pointer(pCx)).FpgnoRoot, BTREE_WRCSR, (*VdbeCursor)(unsafe.Pointer(pCx)).FpKeyInfo, *(*uintptr)(unsafe.Pointer(pCx + 56 /* &.uc */))) // The sqlite3BtreeCursor() routine can only fail for the first cursor // opened for a database. Since there is already an open cursor when this @@ -69013,11 +68374,11 @@ __84: // so that the table is empty again, rather than creating a new table. (*VdbeCursor)(unsafe.Pointer(pCx1)).FseqCount = int64(0) - (*VdbeCursor)(unsafe.Pointer(pCx1)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pCx1)).FcacheStatus = CACHE_STALE rc = Xsqlite3BtreeClearTable(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, int32((*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot), uintptr(0)) goto __522 __521: - pCx1 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, -1, uint8(0)) + pCx1 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, -1, CURTYPE_BTREE) if !(pCx1 == uintptr(0)) { goto __523 } @@ -69026,15 +68387,15 @@ __523: ; libc.SetBitFieldPtr8Uint32(pCx1+8 /* &.isEphemeral */, Bool(1), 0, 0x1) rc = Xsqlite3BtreeOpen(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), db, (pCx1 + 16 /* &.pBtx */), - ((1 | 4) | int32((*Op)(unsafe.Pointer(pOp)).Fp5)), + ((BTREE_OMIT_JOURNAL | BTREE_SINGLE) | int32((*Op)(unsafe.Pointer(pOp)).Fp5)), vfsFlags) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __524 } rc = Xsqlite3BtreeBeginTrans(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, 1, uintptr(0)) __524: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __525 } // If a transient index is required, create it by calling @@ -69046,27 +68407,27 @@ __524: } rc = Xsqlite3BtreeCreateTable(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, (pCx1 + 76 /* &.pgnoRoot */), - (2 | int32((*Op)(unsafe.Pointer(pOp)).Fp5))) - if !(rc == 0) { + (BTREE_BLOBKEY | int32((*Op)(unsafe.Pointer(pOp)).Fp5))) + if !(rc == SQLITE_OK) { goto __528 } - rc = Xsqlite3BtreeCursor(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot, 0x00000004, + rc = Xsqlite3BtreeCursor(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot, BTREE_WRCSR, pKeyInfo2, *(*uintptr)(unsafe.Pointer(pCx1 + 56 /* &.uc */))) __528: ; (*VdbeCursor)(unsafe.Pointer(pCx1)).FisTable = U8(0) goto __527 __526: - (*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot = Pgno(1) - rc = Xsqlite3BtreeCursor(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, uint32(1), 0x00000004, + (*VdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot = SCHEMA_ROOT + rc = Xsqlite3BtreeCursor(tls, (*VdbeCursor)(unsafe.Pointer(pCx1)).FpBtx, SCHEMA_ROOT, BTREE_WRCSR, uintptr(0), *(*uintptr)(unsafe.Pointer(pCx1 + 56 /* &.uc */))) (*VdbeCursor)(unsafe.Pointer(pCx1)).FisTable = U8(1) __527: ; __525: ; - libc.SetBitFieldPtr8Uint32(pCx1+8 /* &.isOrdered */, (Bool(libc.Bool32(int32((*Op)(unsafe.Pointer(pOp)).Fp5) != 8))), 2, 0x4) + libc.SetBitFieldPtr8Uint32(pCx1+8 /* &.isOrdered */, (Bool(libc.Bool32(int32((*Op)(unsafe.Pointer(pOp)).Fp5) != BTREE_UNORDERED))), 2, 0x4) __522: ; if !(rc != 0) { @@ -69090,7 +68451,7 @@ __529: __85: ; - pCx2 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, -1, uint8(1)) + pCx2 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, -1, CURTYPE_SORTER) if !(pCx2 == uintptr(0)) { goto __530 } @@ -69144,7 +68505,7 @@ __532: __87: ; - pCx3 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp3, -1, uint8(3)) + pCx3 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp3, -1, CURTYPE_PSEUDO) if !(pCx3 == uintptr(0)) { goto __533 } @@ -69272,7 +68633,7 @@ __92: // Only interested in == results (*VdbeCursor)(unsafe.Pointer(pC3)).FnullRow = U8(0) (*VdbeCursor)(unsafe.Pointer(pC3)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus = CACHE_STALE if !((*VdbeCursor)(unsafe.Pointer(pC3)).FisTable != 0) { goto __534 } @@ -69283,7 +68644,7 @@ __92: // Only interested in == results // the seek, so convert it. pIn3 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) flags31 = (*Mem)(unsafe.Pointer(pIn3)).Fflags - if !((int32(flags31) & (((0x0004 | 0x0008) | 0x0020) | 0x0002)) == 0x0002) { + if !((int32(flags31) & (((MEM_Int | MEM_Real) | MEM_IntReal) | MEM_Str)) == MEM_Str) { goto __536 } applyNumericAffinity(tls, pIn3, 0) @@ -69295,13 +68656,13 @@ __536: // If the P3 value could not be converted into an integer without // loss of information, then special processing is required... - if !((int32(newType) & (0x0004 | 0x0020)) == 0) { + if !((int32(newType) & (MEM_Int | MEM_IntReal)) == 0) { goto __537 } - if !((int32(newType) & 0x0008) == 0) { + if !((int32(newType) & MEM_Real) == 0) { goto __538 } - if !(((int32(newType) & 0x0001) != 0) || (oc >= 24)) { + if !(((int32(newType) & MEM_Null) != 0) || (oc >= OP_SeekGE)) { goto __540 } @@ -69309,7 +68670,7 @@ __536: goto __541 __540: rc = Xsqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), bp+296 /* &res1 */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __542 } goto abort_due_to_error @@ -69331,7 +68692,7 @@ __538: goto __543 } - if !((oc & 0x0001) == (25 & 0x0001)) { + if !((oc & 0x0001) == (OP_SeekGT & 0x0001)) { goto __545 } oc-- @@ -69343,7 +68704,7 @@ __543: goto __546 } - if !((oc & 0x0001) == (22 & 0x0001)) { + if !((oc & 0x0001) == (OP_SeekLT & 0x0001)) { goto __547 } oc++ @@ -69359,7 +68720,7 @@ __537: ; rc = Xsqlite3BtreeMovetoUnpacked(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), uintptr(0), int64(U64(iKey)), 0, bp+296 /* &res1 */) (*VdbeCursor)(unsafe.Pointer(pC3)).FmovetoTarget = iKey // Used by OP_Delete - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __548 } goto abort_due_to_error @@ -69371,7 +68732,7 @@ __534: // OP_SeekGE and OP_SeekLE opcodes are allowed, and these must be // immediately followed by an OP_IdxGT or OP_IdxLT opcode, respectively, // with the same key. - if !(Xsqlite3BtreeCursorHasHint(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), uint32(0x00000002)) != 0) { + if !(Xsqlite3BtreeCursorHasHint(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), BTREE_SEEK_EQ) != 0) { goto __549 } eqOnly = 1 @@ -69391,7 +68752,7 @@ __549: // r.default_rc = +1; // } (*UnpackedRecord)(unsafe.Pointer(bp + 304 /* &r */)).Fdefault_rc = func() int8 { - if (1 & (oc - 22)) != 0 { + if (1 & (oc - OP_SeekLT)) != 0 { return int8(-1) } return +int8(1) @@ -69400,7 +68761,7 @@ __549: (*UnpackedRecord)(unsafe.Pointer(bp + 304 /* &r */)).FaMem = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) (*UnpackedRecord)(unsafe.Pointer(bp + 304 /* &r */)).FeqSeen = U8(0) rc = Xsqlite3BtreeMovetoUnpacked(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), bp+304 /* &r */, int64(0), 0, bp+296 /* &res1 */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __550 } goto abort_due_to_error @@ -69416,21 +68777,21 @@ __551: __535: ; atomic.AddInt32(&Xsqlite3_search_count, 1) - if !(oc >= 24) { + if !(oc >= OP_SeekGE) { goto __552 } - if !((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) < 0) || ((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) == 0) && (oc == 25))) { + if !((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) < 0) || ((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) == 0) && (oc == OP_SeekGT))) { goto __554 } *(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) = 0 rc = Xsqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __556 } - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __557 } - rc = 0 + rc = SQLITE_OK *(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) = 1 goto __558 __557: @@ -69447,18 +68808,18 @@ __555: goto __553 __552: ; - if !((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) > 0) || ((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) == 0) && (oc == 22))) { + if !((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) > 0) || ((*(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) == 0) && (oc == OP_SeekLT))) { goto __559 } *(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) = 0 rc = Xsqlite3BtreePrevious(tls, *(*uintptr)(unsafe.Pointer(pC3 + 56 /* &.uc */)), 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __561 } - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __562 } - rc = 0 + rc = SQLITE_OK *(*int32)(unsafe.Pointer(bp + 296 /* res1 */)) = 1 goto __563 __562: @@ -69618,14 +68979,12 @@ __95: goto __10 __568: ; - // Fall through into OP_NotFound - /* no break */ __96: // jump, in3 __97: // jump, in3 __98: - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) != 28) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) != OP_NoConflict) { goto __569 } Xsqlite3_found_count++ @@ -69648,7 +69007,7 @@ __569: __570: ; rc = func() int32 { - if (int32((*Mem)(unsafe.Pointer((pIn3))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pIn3))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pIn3) } return 0 @@ -69672,7 +69031,7 @@ __571: ; (*UnpackedRecord)(unsafe.Pointer(pIdxKey)).Fdefault_rc = int8(0) takeJump = 0 - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 28) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_NoConflict) { goto __574 } // For the OP_NoConflict opcode, take the jump if any of the @@ -69683,7 +69042,7 @@ __575: if !(ii1 < int32((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FnField)) { goto __577 } - if !((int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FaMem+uintptr(ii1)*56)).Fflags) & 0x0001) != 0) { + if !((int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(pIdxKey)).FaMem+uintptr(ii1)*56)).Fflags) & MEM_Null) != 0) { goto __578 } takeJump = 1 @@ -69706,7 +69065,7 @@ __574: Xsqlite3DbFreeNN(tls, db, pFree) __579: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __580 } goto abort_due_to_error @@ -69716,8 +69075,8 @@ __580: alreadyExists = (libc.Bool32(*(*int32)(unsafe.Pointer(bp + 352 /* res3 */)) == 0)) (*VdbeCursor)(unsafe.Pointer(pC6)).FnullRow = (U8(1 - alreadyExists)) (*VdbeCursor)(unsafe.Pointer(pC6)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC6)).FcacheStatus = U32(0) - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 30) { + (*VdbeCursor)(unsafe.Pointer(pC6)).FcacheStatus = CACHE_STALE + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_Found) { goto __581 } @@ -69789,7 +69148,7 @@ __99: pIn3 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn3)).Fflags) & (0x0004 | 0x0020)) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn3)).Fflags) & (MEM_Int | MEM_IntReal)) == 0) { goto __585 } // If pIn3->u.i does not contain an integer, compute iKey as the @@ -69797,9 +69156,9 @@ __99: // into an integer without loss of information. Take care to avoid // changing the datatype of pIn3, however, as it is used by other // parts of the prepared statement. - *(*Mem)(unsafe.Pointer(bp + 360 /* x */)) = *(*Mem)(unsafe.Pointer(pIn3 + uintptr(0)*56)) - applyAffinity(tls, bp+360 /* &x */, int8(0x43), encoding) - if !((int32((*Mem)(unsafe.Pointer(bp+360 /* &x */)).Fflags) & 0x0004) == 0) { + *(*Mem)(unsafe.Pointer(bp + 360 /* x */)) = *(*Mem)(unsafe.Pointer(pIn3)) + applyAffinity(tls, bp+360 /* &x */, SQLITE_AFF_NUMERIC, encoding) + if !((int32((*Mem)(unsafe.Pointer(bp+360 /* &x */)).Fflags) & MEM_Int) == 0) { goto __586 } goto jump_to_p2 @@ -69809,8 +69168,6 @@ __586: goto notExistsWithKey __585: ; - // Fall through into OP_NotExists - /* no break */ __100: // jump, in3 pIn3 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) @@ -69825,7 +69182,7 @@ notExistsWithKey: (*VdbeCursor)(unsafe.Pointer(pC7)).FmovetoTarget = I64(iKey1) // Used by OP_Delete (*VdbeCursor)(unsafe.Pointer(pC7)).FnullRow = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC7)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC7)).FcacheStatus = CACHE_STALE (*VdbeCursor)(unsafe.Pointer(pC7)).FdeferredMoveto = U8(0) (*VdbeCursor)(unsafe.Pointer(pC7)).FseekResult = *(*int32)(unsafe.Pointer(bp + 416 /* res4 */)) @@ -69909,7 +69266,7 @@ __102: // Root frame of VDBE goto __591 } rc = Xsqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC8 + 56 /* &.uc */)), bp+420 /* &res5 */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __592 } goto abort_due_to_error @@ -69974,7 +69331,7 @@ __599: if !((*(*I64)(unsafe.Pointer(pMem1 /* &.u */)) == (int64((U64((uint64(0x7fffffff))) << 32) | uint64(0xffffffff)))) || ((Bool(int32(*(*uint8)(unsafe.Pointer(pC8 + 8 /* &.useRandomRowid */)) & 0x2 >> 1))) != 0)) { goto __603 } - rc = 13 // IMP: R-17817-00630 + rc = SQLITE_FULL // IMP: R-17817-00630 goto abort_due_to_error __603: ; @@ -70004,7 +69361,7 @@ __606: goto __607 __607: if (((libc.AssignInt32(&rc, Xsqlite3BtreeMovetoUnpacked(tls, *(*uintptr)(unsafe.Pointer(pC8 + 56 /* &.uc */)), uintptr(0), int64(U64(*(*I64)(unsafe.Pointer(bp + 424 /* v */)))), - 0, bp+420 /* &res5 */))) == 0) && + 0, bp+420 /* &res5 */))) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 420 /* res5 */)) == 0)) && (libc.PreIncInt32(&cnt1, 1) < 100) { goto __606 @@ -70021,7 +69378,7 @@ __609: if !(*(*int32)(unsafe.Pointer(bp + 420 /* res5 */)) == 0) { goto __610 } - rc = 13 // IMP: R-38219-53002 + rc = SQLITE_FULL // IMP: R-38219-53002 goto abort_due_to_error __610: ; @@ -70029,7 +69386,7 @@ __610: __605: ; (*VdbeCursor)(unsafe.Pointer(pC8)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC8)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC8)).FcacheStatus = CACHE_STALE *(*I64)(unsafe.Pointer(pOut /* &.u */)) = *(*I64)(unsafe.Pointer(bp + 424 /* v */)) goto __10 @@ -70098,10 +69455,10 @@ __612: if !(pTab != 0) { goto __613 } - if !(((*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0) && !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x04) != 0)) { + if !(((*Sqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0) && !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_ISUPDATE) != 0)) { goto __614 } - Xsqlite3VdbePreUpdateHook(tls, p, pC9, 18, zDb, pTab, (*BtreePayload)(unsafe.Pointer(bp+432 /* &x1 */)).FnKey, (*Op)(unsafe.Pointer(pOp)).Fp2) + Xsqlite3VdbePreUpdateHook(tls, p, pC9, SQLITE_INSERT, zDb, pTab, (*BtreePayload)(unsafe.Pointer(bp+432 /* &x1 */)).FnKey, (*Op)(unsafe.Pointer(pOp)).Fp2) __614: ; if !(((*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback == uintptr(0)) || ((*Table)(unsafe.Pointer(pTab)).FaCol == uintptr(0))) { @@ -70113,20 +69470,20 @@ __615: ; __613: ; - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x40) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_ISNOOP) != 0) { goto __616 } goto __10 __616: ; - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x01) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_NCHANGE) != 0) { goto __617 } (*Vdbe)(unsafe.Pointer(p)).FnChange++ __617: ; - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x20) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_LASTROWID) != 0) { goto __618 } (*Sqlite3)(unsafe.Pointer(db)).FlastRowid = (*BtreePayload)(unsafe.Pointer(bp + 432 /* &x1 */)).FnKey @@ -70136,12 +69493,12 @@ __618: (*BtreePayload)(unsafe.Pointer(bp + 432 /* &x1 */)).FpData = (*Mem)(unsafe.Pointer(pData)).Fz (*BtreePayload)(unsafe.Pointer(bp + 432 /* &x1 */)).FnData = (*Mem)(unsafe.Pointer(pData)).Fn seekResult = func() int32 { - if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x10) != 0 { + if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_USESEEKRESULT) != 0 { return (*VdbeCursor)(unsafe.Pointer(pC9)).FseekResult } return 0 }() - if !((int32((*Mem)(unsafe.Pointer(pData)).Fflags) & 0x4000) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pData)).Fflags) & MEM_Zero) != 0) { goto __619 } (*BtreePayload)(unsafe.Pointer(bp + 432 /* &x1 */)).FnZero = *(*int32)(unsafe.Pointer(pData /* &.u */)) @@ -70152,9 +69509,9 @@ __620: ; (*BtreePayload)(unsafe.Pointer(bp + 432 /* &x1 */)).FpKey = uintptr(0) rc = Xsqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC9 + 56 /* &.uc */)), bp+432, /* &x1 */ - (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (0x08 | 0x02)), seekResult) + (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (OPFLAG_APPEND | OPFLAG_SAVEPOSITION)), seekResult) (*VdbeCursor)(unsafe.Pointer(pC9)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC9)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC9)).FcacheStatus = CACHE_STALE // Invoke the update-hook if required. if !(rc != 0) { @@ -70169,10 +69526,10 @@ __621: (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Sqlite_int64))(unsafe.Pointer((db + 304 /* &.xUpdateCallback */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpUpdateArg, func() int32 { - if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x04) != 0 { - return 23 + if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_ISUPDATE) != 0 { + return SQLITE_UPDATE } - return 18 + return SQLITE_INSERT }(), zDb, (*Table)(unsafe.Pointer(pTab)).FzName, (*BtreePayload)(unsafe.Pointer(bp+432 /* &x1 */)).FnKey) __622: @@ -70230,7 +69587,7 @@ __104: zDb1 = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*VdbeCursor)(unsafe.Pointer(pC10)).FiDb)*32)).FzDbSName pTab1 = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) - if !(((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x02) != 0) && ((*VdbeCursor)(unsafe.Pointer(pC10)).FisTable != 0)) { + if !(((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_SAVEPOSITION) != 0) && ((*VdbeCursor)(unsafe.Pointer(pC10)).FisTable != 0)) { goto __625 } (*VdbeCursor)(unsafe.Pointer(pC10)).FmovetoTarget = Xsqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC10 + 56 /* &.uc */))) @@ -70250,16 +69607,16 @@ __624: Xsqlite3VdbePreUpdateHook(tls, p, pC10, func() int32 { - if (opflags & 0x04) != 0 { - return 23 + if (opflags & OPFLAG_ISUPDATE) != 0 { + return SQLITE_UPDATE } - return 9 + return SQLITE_DELETE }(), zDb1, pTab1, (*VdbeCursor)(unsafe.Pointer(pC10)).FmovetoTarget, (*Op)(unsafe.Pointer(pOp)).Fp3) __626: ; - if !((opflags & 0x40) != 0) { + if !((opflags & OPFLAG_ISNOOP) != 0) { goto __627 } goto __10 @@ -70269,7 +69626,7 @@ __627: // Only flags that can be set are SAVEPOISTION and AUXDELETE rc = Xsqlite3BtreeDelete(tls, *(*uintptr)(unsafe.Pointer(pC10 + 56 /* &.uc */)), uint8((*Op)(unsafe.Pointer(pOp)).Fp5)) - (*VdbeCursor)(unsafe.Pointer(pC10)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC10)).FcacheStatus = CACHE_STALE (*VdbeCursor)(unsafe.Pointer(pC10)).FseekResult = 0 if !(rc != 0) { goto __628 @@ -70279,14 +69636,14 @@ __628: ; // Invoke the update-hook if required. - if !((opflags & 0x01) != 0) { + if !((opflags & OPFLAG_NCHANGE) != 0) { goto __629 } (*Vdbe)(unsafe.Pointer(p)).FnChange++ - if !(((*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0) && (((*Table)(unsafe.Pointer((pTab1))).FtabFlags & U32(0x0080)) == U32(0))) { + if !(((*Sqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0) && (((*Table)(unsafe.Pointer((pTab1))).FtabFlags & TF_WithoutRowid) == U32(0))) { goto __630 } - (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Sqlite_int64))(unsafe.Pointer((db + 304 /* &.xUpdateCallback */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpUpdateArg, 9, zDb1, (*Table)(unsafe.Pointer(pTab1)).FzName, + (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Sqlite_int64))(unsafe.Pointer((db + 304 /* &.xUpdateCallback */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpUpdateArg, SQLITE_DELETE, zDb1, (*Table)(unsafe.Pointer(pTab1)).FzName, (*VdbeCursor)(unsafe.Pointer(pC10)).FmovetoTarget) __630: @@ -70368,7 +69725,7 @@ __107: goto abort_due_to_error __633: ; - (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*8)))).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*8)))).FcacheStatus = CACHE_STALE goto __10 // Opcode: RowData P1 P2 P3 * * @@ -70415,7 +69772,7 @@ __108: // sqlite3VdbeCursorMoveto(). n3 = Xsqlite3BtreePayloadSize(tls, pCrsr3) - if !(n3 > U32(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4)))) { + if !(n3 > U32(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */))))) { goto __634 } goto too_big @@ -70432,7 +69789,7 @@ __635: if !(!((*Op)(unsafe.Pointer(pOp)).Fp3 != 0)) { goto __636 } - if !(((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & 0x1000) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0)) { + if !(((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & MEM_Ephem) != 0) && (Xsqlite3VdbeMemMakeWriteable(tls, pOut) != 0)) { goto __637 } goto no_mem @@ -70463,7 +69820,7 @@ __109: if !((*VdbeCursor)(unsafe.Pointer(pC14)).FnullRow != 0) { goto __638 } - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Null goto __10 goto __639 __638: @@ -70473,7 +69830,7 @@ __638: *(*I64)(unsafe.Pointer(bp + 488 /* v3 */)) = (*VdbeCursor)(unsafe.Pointer(pC14)).FmovetoTarget goto __641 __640: - if !(int32((*VdbeCursor)(unsafe.Pointer(pC14)).FeCurType) == 2) { + if !(int32((*VdbeCursor)(unsafe.Pointer(pC14)).FeCurType) == CURTYPE_VTAB) { goto __642 } @@ -70502,7 +69859,7 @@ __645: if !((*VdbeCursor)(unsafe.Pointer(pC14)).FnullRow != 0) { goto __646 } - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Null goto __10 __646: ; @@ -70526,8 +69883,8 @@ __110: pC15 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*8)) (*VdbeCursor)(unsafe.Pointer(pC15)).FnullRow = U8(1) - (*VdbeCursor)(unsafe.Pointer(pC15)).FcacheStatus = U32(0) - if !(int32((*VdbeCursor)(unsafe.Pointer(pC15)).FeCurType) == 0) { + (*VdbeCursor)(unsafe.Pointer(pC15)).FcacheStatus = CACHE_STALE + if !(int32((*VdbeCursor)(unsafe.Pointer(pC15)).FeCurType) == CURTYPE_BTREE) { goto __647 } @@ -70564,7 +69921,7 @@ __112: pCrsr4 = *(*uintptr)(unsafe.Pointer(pC16 + 56 /* &.uc */)) *(*int32)(unsafe.Pointer(bp + 496 /* res7 */)) = 0 - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 129) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_SeekEnd) { goto __648 } @@ -70580,7 +69937,7 @@ __648: rc = Xsqlite3BtreeLast(tls, pCrsr4, bp+496 /* &res7 */) (*VdbeCursor)(unsafe.Pointer(pC16)).FnullRow = U8(*(*int32)(unsafe.Pointer(bp + 496 /* res7 */))) (*VdbeCursor)(unsafe.Pointer(pC16)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC16)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC16)).FcacheStatus = CACHE_STALE if !(rc != 0) { goto __650 } @@ -70662,9 +70019,7 @@ __114: // jump __115: // jump atomic.AddInt32(&Xsqlite3_sort_count, 1) atomic.AddInt32(&Xsqlite3_search_count, -1) - *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + uintptr(2)*4))++ - // Fall through into OP_Rewind - /* no break */ + *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + 2*4))++ // Opcode: Rewind P1 P2 * * * // @@ -70683,7 +70038,7 @@ __116: pC18 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*8)) *(*int32)(unsafe.Pointer(bp + 504 /* res9 */)) = 1 - if !(int32((*VdbeCursor)(unsafe.Pointer((pC18))).FeCurType) == 1) { + if !(int32((*VdbeCursor)(unsafe.Pointer((pC18))).FeCurType) == CURTYPE_SORTER) { goto __657 } rc = Xsqlite3VdbeSorterRewind(tls, pC18, bp+504 /* &res9 */) @@ -70694,7 +70049,7 @@ __657: rc = Xsqlite3BtreeFirst(tls, pCrsr6, bp+504 /* &res9 */) (*VdbeCursor)(unsafe.Pointer(pC18)).FdeferredMoveto = U8(0) - (*VdbeCursor)(unsafe.Pointer(pC18)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC18)).FcacheStatus = CACHE_STALE __658: ; if !(rc != 0) { @@ -70787,9 +70142,9 @@ __119: // jump rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((pOp + 16 /* &.p4 */ /* &.xAdvance */))))(tls, *(*uintptr)(unsafe.Pointer(pC19 + 56 /* &.uc */)), (*Op)(unsafe.Pointer(pOp)).Fp3) next_tail: - (*VdbeCursor)(unsafe.Pointer(pC19)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC19)).FcacheStatus = CACHE_STALE - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __661 } (*VdbeCursor)(unsafe.Pointer(pC19)).FnullRow = U8(0) @@ -70798,13 +70153,13 @@ next_tail: goto jump_to_p2_and_check_for_interrupt __661: ; - if !(rc != 101) { + if !(rc != SQLITE_DONE) { goto __662 } goto abort_due_to_error __662: ; - rc = 0 + rc = SQLITE_OK (*VdbeCursor)(unsafe.Pointer(pC19)).FnullRow = U8(1) goto check_for_interrupt @@ -70841,7 +70196,7 @@ __120: pIn2 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x01) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_NCHANGE) != 0) { goto __663 } (*Vdbe)(unsafe.Pointer(p)).FnChange++ @@ -70849,7 +70204,7 @@ __663: ; rc = func() int32 { - if (int32((*Mem)(unsafe.Pointer((pIn2))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pIn2))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pIn2) } return 0 @@ -70865,15 +70220,15 @@ __664: (*BtreePayload)(unsafe.Pointer(bp + 512 /* &x2 */)).FaMem = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) (*BtreePayload)(unsafe.Pointer(bp + 512 /* &x2 */)).FnMem = U16(*(*int32)(unsafe.Pointer(pOp + 16 /* &.p4 */))) rc = Xsqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC20 + 56 /* &.uc */)), bp+512, /* &x2 */ - (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (0x08 | 0x02)), + (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & (OPFLAG_APPEND | OPFLAG_SAVEPOSITION)), func() int32 { - if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x10) != 0 { + if (int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_USESEEKRESULT) != 0 { return (*VdbeCursor)(unsafe.Pointer(pC20)).FseekResult } return 0 }()) - (*VdbeCursor)(unsafe.Pointer(pC20)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC20)).FcacheStatus = CACHE_STALE if !(rc != 0) { goto __665 } @@ -70895,7 +70250,7 @@ __121: pIn2 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) rc = func() int32 { - if (int32((*Mem)(unsafe.Pointer((pIn2))).Fflags) & 0x4000) != 0 { + if (int32((*Mem)(unsafe.Pointer((pIn2))).Fflags) & MEM_Zero) != 0 { return Xsqlite3VdbeMemExpandBlob(tls, pIn2) } return 0 @@ -70949,7 +70304,7 @@ __668: if !(*(*int32)(unsafe.Pointer(bp + 584 /* res10 */)) == 0) { goto __669 } - rc = Xsqlite3BtreeDelete(tls, pCrsr7, uint8(0x04)) + rc = Xsqlite3BtreeDelete(tls, pCrsr7, BTREE_AUXDELETE) if !(rc != 0) { goto __671 } @@ -70961,14 +70316,14 @@ __669: if !((*Op)(unsafe.Pointer(pOp)).Fp5 != 0) { goto __672 } - rc = (11 | (int32(3) << 8)) + rc = (SQLITE_CORRUPT | (int32(3) << 8)) goto abort_due_to_error __672: ; __670: ; - (*VdbeCursor)(unsafe.Pointer(pC22)).FcacheStatus = U32(0) + (*VdbeCursor)(unsafe.Pointer(pC22)).FcacheStatus = CACHE_STALE (*VdbeCursor)(unsafe.Pointer(pC22)).FseekResult = 0 goto __10 @@ -71011,7 +70366,7 @@ __124: // Rowid that P1 current points to // sqlite3VbeCursorRestore() can only fail if the record has been deleted // out from under the cursor. That will never happens for an IdxRowid // or Seek opcode - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __673 } goto abort_due_to_error @@ -71023,13 +70378,13 @@ __673: } *(*I64)(unsafe.Pointer(bp + 592 /* rowid */)) = int64(0) // Not needed. Only used to silence a warning. rc = Xsqlite3VdbeIdxRowid(tls, db, *(*uintptr)(unsafe.Pointer(pC23 + 56 /* &.uc */)), bp+592 /* &rowid */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __676 } goto abort_due_to_error __676: ; - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 133) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_DeferredSeek) { goto __677 } @@ -71127,7 +70482,7 @@ __129: (*UnpackedRecord)(unsafe.Pointer(bp + 600 /* &r3 */)).FpKeyInfo = (*VdbeCursor)(unsafe.Pointer(pC25)).FpKeyInfo (*UnpackedRecord)(unsafe.Pointer(bp + 600 /* &r3 */)).FnField = U16(*(*int32)(unsafe.Pointer(pOp + 16 /* &.p4 */))) - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) < 40) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) < OP_IdxLT) { goto __681 } @@ -71142,7 +70497,7 @@ __682: *(*int32)(unsafe.Pointer(bp + 624 /* res11 */)) = 0 // Not needed. Only used to silence a warning. rc = Xsqlite3VdbeIdxKeyCompare(tls, db, pC25, bp+600 /* &r3 */, bp+624 /* &res11 */) - if !((int32((*Op)(unsafe.Pointer(pOp)).Fopcode) & 1) == (40 & 1)) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fopcode) & 1) == (OP_IdxLT & 1)) { goto __683 } @@ -71198,12 +70553,12 @@ __130: ; pOut = out2Prerelease(tls, p, pOp) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Null if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead > ((*Sqlite3)(unsafe.Pointer(db)).FnVDestroy + 1)) { goto __687 } - rc = 6 - (*Vdbe)(unsafe.Pointer(p)).FerrorAction = U8(2) + rc = SQLITE_LOCKED + (*Vdbe)(unsafe.Pointer(p)).FerrorAction = OE_Abort goto abort_due_to_error goto __688 __687: @@ -71211,7 +70566,7 @@ __687: *(*int32)(unsafe.Pointer(bp + 628 /* iMoved */)) = 0 // Not needed. Only to silence a warning. rc = Xsqlite3BtreeDropTable(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb2)*32)).FpBt, (*Op)(unsafe.Pointer(pOp)).Fp1, bp+628 /* &iMoved */) - (*Mem)(unsafe.Pointer(pOut)).Fflags = U16(0x0004) + (*Mem)(unsafe.Pointer(pOut)).Fflags = MEM_Int *(*I64)(unsafe.Pointer(pOut /* &.u */)) = I64(*(*int32)(unsafe.Pointer(bp + 628 /* iMoved */))) if !(rc != 0) { goto __689 @@ -71292,7 +70647,7 @@ __132: ; pC26 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*8)) - if !(int32((*VdbeCursor)(unsafe.Pointer((pC26))).FeCurType) == 1) { + if !(int32((*VdbeCursor)(unsafe.Pointer((pC26))).FeCurType) == CURTYPE_SORTER) { goto __694 } Xsqlite3VdbeSorterReset(tls, db, *(*uintptr)(unsafe.Pointer(pC26 + 56 /* &.uc */))) @@ -71372,9 +70727,9 @@ __135: goto __699 } Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb3)*32)).FpSchema) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (^libc.Uint32FromInt32(0x0010)) - rc = Xsqlite3InitOne(tls, db, iDb3, (p + 168 /* &.zErrMsg */), uint32(0x0001)) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaKnownOk))) + rc = Xsqlite3InitOne(tls, db, iDb3, (p + 168 /* &.zErrMsg */), INITFLAG_AlterTable) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) libc.SetBitFieldPtr16Uint32(p+200 /* &.expired */, Bft(0), 0, 0x3) goto __700 __699: @@ -71391,24 +70746,24 @@ __699: if !(zSql == uintptr(0)) { goto __701 } - rc = 7 + rc = SQLITE_NOMEM goto __702 __701: ; (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy = U8(1) - (*InitData)(unsafe.Pointer(bp + 640 /* &initData */)).Frc = 0 + (*InitData)(unsafe.Pointer(bp + 640 /* &initData */)).Frc = SQLITE_OK (*InitData)(unsafe.Pointer(bp + 640 /* &initData */)).FnInitRow = U32(0) rc = Xsqlite3_exec(tls, db, zSql, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 }{Xsqlite3InitCallback})), bp+640 /* &initData */, uintptr(0)) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __703 } rc = (*InitData)(unsafe.Pointer(bp + 640 /* &initData */)).Frc __703: ; - if !((rc == 0) && ((*InitData)(unsafe.Pointer(bp+640 /* &initData */)).FnInitRow == U32(0))) { + if !((rc == SQLITE_OK) && ((*InitData)(unsafe.Pointer(bp+640 /* &initData */)).FnInitRow == U32(0))) { goto __704 } // The OP_ParseSchema opcode with a non-NULL P4 argument should parse @@ -71427,7 +70782,7 @@ __700: goto __705 } Xsqlite3ResetAllSchemasOfConnection(tls, db) - if !(rc == 7) { + if !(rc == SQLITE_NOMEM) { goto __706 } goto no_mem @@ -71518,7 +70873,7 @@ __140: // Register keeping track of errors remaining pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - z = Xsqlite3BtreeIntegrityCheck(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr((*Op)(unsafe.Pointer(pOp)).Fp5)*32)).FpBt, (aRoot + uintptr(1)*4), nRoot, + z = Xsqlite3BtreeIntegrityCheck(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr((*Op)(unsafe.Pointer(pOp)).Fp5)*32)).FpBt, (aRoot + 1*4), nRoot, (int32(*(*I64)(unsafe.Pointer(pnErr /* &.u */))) + 1), bp+680 /* &nErr */) Xsqlite3VdbeMemSetNull(tls, pIn1) if !(*(*int32)(unsafe.Pointer(bp + 680 /* nErr */)) == 0) { @@ -71534,7 +70889,7 @@ __708: goto __711 __710: *(*I64)(unsafe.Pointer(pnErr /* &.u */ /* &.i */)) -= (I64(*(*int32)(unsafe.Pointer(bp + 680 /* nErr */)) - 1)) - Xsqlite3VdbeMemSetStr(tls, pIn1, z, -1, uint8(1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) + Xsqlite3VdbeMemSetStr(tls, pIn1, z, -1, SQLITE_UTF8, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) __711: ; __709: @@ -71554,7 +70909,7 @@ __141: // in1, in2 pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) pIn2 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp2)*56) - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0010) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Blob) == 0) { goto __712 } if !(Xsqlite3VdbeMemSetRowSet(tls, pIn1) != 0) { @@ -71580,7 +70935,7 @@ __142: pIn1 = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - if !(((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0010) == 0) || + if !(((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Blob) == 0) || (Xsqlite3RowSetNext(tls, (*Mem)(unsafe.Pointer(pIn1)).Fz, bp+688 /* &val */) == 0)) { goto __714 } @@ -71627,7 +70982,7 @@ __143: // If there is anything other than a rowset object in memory cell P1, // delete it now and initialize P1 with an empty rowset - if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & 0x0010) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pIn1)).Fflags) & MEM_Blob) == 0) { goto __716 } if !(Xsqlite3VdbeMemSetRowSet(tls, pIn1) != 0) { @@ -71715,10 +71070,10 @@ __725: __721: ; - if !((*Vdbe)(unsafe.Pointer(p)).FnFrame >= *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(10)*4))) { + if !((*Vdbe)(unsafe.Pointer(p)).FnFrame >= *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 10*4))) { goto __726 } - rc = 1 + rc = SQLITE_ERROR Xsqlite3VdbeError(tls, p, ts+7598 /* "too many levels ..." */, 0) goto abort_due_to_error __726: @@ -71728,7 +71083,7 @@ __726: // of the current program, and the memory required at runtime to execute // the trigger program. If this trigger has been fired before, then pRt // is already allocated. Otherwise, it must be initialized. - if !((int32((*Mem)(unsafe.Pointer(pRt)).Fflags) & 0x0010) == 0) { + if !((int32((*Mem)(unsafe.Pointer(pRt)).Fflags) & MEM_Blob) == 0) { goto __727 } // SubProgram.nMem is set to the number of memory cells used by the @@ -71743,7 +71098,7 @@ __726: nMem++ __729: ; - nByte2 = (int32((((((uint64(unsafe.Sizeof(VdbeFrame{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)) + + nByte2 = (int32((((((uint64(unsafe.Sizeof(VdbeFrame{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))) + (uint64(nMem) * uint64(unsafe.Sizeof(Mem{})))) + (uint64((*SubProgram)(unsafe.Pointer(pProgram)).FnCsr) * uint64(unsafe.Sizeof(uintptr(0))))) + (uint64(((*SubProgram)(unsafe.Pointer(pProgram)).FnOp + 7) / 8)))) @@ -71755,7 +71110,7 @@ __729: __730: ; Xsqlite3VdbeMemRelease(tls, pRt) - (*Mem)(unsafe.Pointer(pRt)).Fflags = (U16(0x0010 | 0x0400)) + (*Mem)(unsafe.Pointer(pRt)).Fflags = (U16(MEM_Blob | MEM_Dyn)) (*Mem)(unsafe.Pointer(pRt)).Fz = pFrame2 (*Mem)(unsafe.Pointer(pRt)).Fn = nByte2 (*Mem)(unsafe.Pointer(pRt)).FxDel = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3VdbeFrameMemDel})) @@ -71772,13 +71127,13 @@ __730: (*VdbeFrame)(unsafe.Pointer(pFrame2)).FnOp = (*Vdbe)(unsafe.Pointer(p)).FnOp (*VdbeFrame)(unsafe.Pointer(pFrame2)).Ftoken = (*SubProgram)(unsafe.Pointer(pProgram)).Ftoken - pEnd = (((pFrame2) + uintptr((((uint64(unsafe.Sizeof(VdbeFrame{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + uintptr((*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem)*56) - pMem2 = ((pFrame2) + uintptr((((uint64(unsafe.Sizeof(VdbeFrame{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + pEnd = (((pFrame2) + 112) + uintptr((*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem)*56) + pMem2 = ((pFrame2) + 112) __731: if !(pMem2 != pEnd) { goto __733 } - (*Mem)(unsafe.Pointer(pMem2)).Fflags = U16(0x0080) + (*Mem)(unsafe.Pointer(pMem2)).Fflags = MEM_Undefined (*Mem)(unsafe.Pointer(pMem2)).Fdb = db goto __732 __732: @@ -71804,7 +71159,7 @@ __728: (*Vdbe)(unsafe.Pointer(p)).FpAuxData = uintptr(0) (*Vdbe)(unsafe.Pointer(p)).FnChange = 0 (*Vdbe)(unsafe.Pointer(p)).FpFrame = pFrame2 - (*Vdbe)(unsafe.Pointer(p)).FaMem = libc.AssignUintptr(&aMem, ((pFrame2) + uintptr((((uint64(unsafe.Sizeof(VdbeFrame{}))) + uint64(7)) & ^libc.Uint64FromInt32(7))))) + (*Vdbe)(unsafe.Pointer(p)).FaMem = libc.AssignUintptr(&aMem, ((pFrame2) + 112)) (*Vdbe)(unsafe.Pointer(p)).FnMem = (*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem (*Vdbe)(unsafe.Pointer(p)).FnCursor = int32(U16((*VdbeFrame)(unsafe.Pointer(pFrame2)).FnChildCsr)) (*Vdbe)(unsafe.Pointer(p)).FapCsr = (aMem + uintptr((*Vdbe)(unsafe.Pointer(p)).FnMem)*56) @@ -71830,7 +71185,7 @@ __145: pOut = out2Prerelease(tls, p, pOp) pFrame3 = (*Vdbe)(unsafe.Pointer(p)).FpFrame pIn = ((*VdbeFrame)(unsafe.Pointer(pFrame3)).FaMem + uintptr(((*Op)(unsafe.Pointer(pOp)).Fp1+(*Op)(unsafe.Pointer((*VdbeFrame)(unsafe.Pointer(pFrame3)).FaOp+uintptr((*VdbeFrame)(unsafe.Pointer(pFrame3)).Fpc)*32)).Fp1))*56) - Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn, 0x1000) + Xsqlite3VdbeMemShallowCopy(tls, pOut, pIn, MEM_Ephem) goto __10 // Opcode: FkCounter P1 P2 * * * @@ -71841,7 +71196,7 @@ __145: // (deferred foreign key constraints). Otherwise, if P1 is zero, the // statement counter is incremented (immediate foreign key constraints). __146: - if !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00080000)) != 0) { + if !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DeferFKs) != 0) { goto __734 } *(*I64)(unsafe.Pointer(db + 744 /* &.nDeferredImmCons */)) += (I64((*Op)(unsafe.Pointer(pOp)).Fp2)) @@ -72103,7 +71458,7 @@ __755: ; (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpMem = uintptr(0) (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut = ((pCtx + 48 /* &.argv */) + uintptr(n4)*8) - Xsqlite3VdbeMemInit(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, db, uint16(0x0001)) + Xsqlite3VdbeMemInit(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpOut, db, MEM_Null) (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpFunc = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) (*Sqlite3_context)(unsafe.Pointer(pCtx)).FiOp = (int32((int64(pOp) - int64(aOp)) / 32)) (*Sqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe = p @@ -72115,9 +71470,7 @@ __755: // OP_AggInverse must have P1==1 and OP_AggStep must have P1==0 - (*Op)(unsafe.Pointer(pOp)).Fopcode = U8(155) - // Fall through into OP_AggStep - /* no break */ + (*Op)(unsafe.Pointer(pOp)).Fopcode = OP_AggStep1 __155: ; @@ -72185,7 +71538,7 @@ __765: __764: ; Xsqlite3VdbeMemRelease(tls, (*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpOut) - (*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpOut)).Fflags = U16(0x0001) + (*Mem)(unsafe.Pointer((*Sqlite3_context)(unsafe.Pointer(pCtx1)).FpOut)).Fflags = MEM_Null (*Sqlite3_context)(unsafe.Pointer(pCtx1)).FisError = 0 if !(rc != 0) { goto __766 @@ -72271,21 +71624,21 @@ __770: __158: // Write results here ; - *(*int32)(unsafe.Pointer(bp + 704 /* &aRes[0] */ + uintptr(0)*4)) = 0 - *(*int32)(unsafe.Pointer(bp + 704 /* &aRes[0] */ + uintptr(1)*4)) = libc.AssignPtrInt32(bp+704 /* &aRes */ +uintptr(2)*4, -1) + *(*int32)(unsafe.Pointer(bp + 704 /* &aRes[0] */)) = 0 + *(*int32)(unsafe.Pointer(bp + 704 /* &aRes[0] */ + 1*4)) = libc.AssignPtrInt32(bp+704 /* &aRes */ +2*4, -1) - rc = Xsqlite3Checkpoint(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, (bp + 704 /* &aRes */ + uintptr(1)*4), (bp + 704 /* &aRes */ + uintptr(2)*4)) + rc = Xsqlite3Checkpoint(tls, db, (*Op)(unsafe.Pointer(pOp)).Fp1, (*Op)(unsafe.Pointer(pOp)).Fp2, (bp + 704 /* &aRes */ + 1*4), (bp + 704 /* &aRes */ + 2*4)) if !(rc != 0) { goto __771 } - if !(rc != 5) { + if !(rc != SQLITE_BUSY) { goto __772 } goto abort_due_to_error __772: ; - rc = 0 - *(*int32)(unsafe.Pointer(bp + 704 /* &aRes[0] */ + uintptr(0)*4)) = 1 + rc = SQLITE_OK + *(*int32)(unsafe.Pointer(bp + 704 /* &aRes[0] */)) = 1 __771: ; i5 = 0 @@ -72340,7 +71693,7 @@ __777: // Do not allow a transition to journal_mode=WAL for a database // in temporary storage or if the VFS does not support shared memory - if !((eNew == 5) && + if !((eNew == PAGER_JOURNALMODE_WAL) && ((Xsqlite3Strlen30(tls, zFilename) == 0) || // Temp file !(Xsqlite3PagerWalSupported(tls, pPager) != 0))) { goto __778 @@ -72350,17 +71703,17 @@ __778: ; if !((eNew != eOld) && - ((eOld == 5) || (eNew == 5))) { + ((eOld == PAGER_JOURNALMODE_WAL) || (eNew == PAGER_JOURNALMODE_WAL))) { goto __779 } if !(!(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FnVdbeRead > 1)) { goto __780 } - rc = 1 + rc = SQLITE_ERROR Xsqlite3VdbeError(tls, p, ts+7635, /* "cannot change %s..." */ libc.VaList(bp+104, func() uintptr { - if eNew == 5 { + if eNew == PAGER_JOURNALMODE_WAL { return ts + 7687 /* "into" */ } return ts + 7692 /* "out of" */ @@ -72369,7 +71722,7 @@ __778: goto __781 __780: - if !(eOld == 5) { + if !(eOld == PAGER_JOURNALMODE_WAL) { goto __782 } // If leaving WAL mode, close the log file. If successful, the call @@ -72377,7 +71730,7 @@ __780: // file. An EXCLUSIVE lock may still be held on the database file // after a successful return. rc = Xsqlite3PagerCloseWal(tls, pPager, db) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __784 } Xsqlite3PagerSetJournalMode(tls, pPager, eNew) @@ -72385,12 +71738,12 @@ __784: ; goto __783 __782: - if !(eOld == 4) { + if !(eOld == PAGER_JOURNALMODE_MEMORY) { goto __785 } // Cannot transition directly from MEMORY to WAL. Use mode OFF // as an intermediate - Xsqlite3PagerSetJournalMode(tls, pPager, 2) + Xsqlite3PagerSetJournalMode(tls, pPager, PAGER_JOURNALMODE_OFF) __785: ; __783: @@ -72399,11 +71752,11 @@ __783: // Open a transaction on the database file. Regardless of the journal // mode, this transaction always uses a rollback journal. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __786 } rc = Xsqlite3BtreeSetVersion(tls, pBt1, func() int32 { - if eNew == 5 { + if eNew == PAGER_JOURNALMODE_WAL { return 2 } return 1 @@ -72423,10 +71776,10 @@ __787: ; eNew = Xsqlite3PagerSetJournalMode(tls, pPager, eNew) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((0x0002 | 0x0800) | 0x0200)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((MEM_Str | MEM_Static) | MEM_Term)) (*Mem)(unsafe.Pointer(pOut)).Fz = Xsqlite3JournalModename(tls, eNew) (*Mem)(unsafe.Pointer(pOut)).Fn = Xsqlite3Strlen30(tls, (*Mem)(unsafe.Pointer(pOut)).Fz) - (*Mem)(unsafe.Pointer(pOut)).Fenc = U8(1) + (*Mem)(unsafe.Pointer(pOut)).Fenc = SQLITE_UTF8 Xsqlite3VdbeChangeEncoding(tls, pOut, int32(encoding)) if !(rc != 0) { goto __788 @@ -72475,13 +71828,13 @@ __161: if !(rc != 0) { goto __790 } - if !(rc != 101) { + if !(rc != SQLITE_DONE) { goto __791 } goto abort_due_to_error __791: ; - rc = 0 + rc = SQLITE_OK goto jump_to_p2 __790: ; @@ -72553,7 +71906,7 @@ __164: // used to generate an error message if the lock cannot be obtained. __165: isWriteLock = U8((*Op)(unsafe.Pointer(pOp)).Fp3) - if !((isWriteLock != 0) || (uint64(0) == ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000400)))) { + if !((isWriteLock != 0) || (uint64(0) == ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ReadUncommit))) { goto __794 } p13 = (*Op)(unsafe.Pointer(pOp)).Fp1 @@ -72562,7 +71915,7 @@ __165: if !(rc != 0) { goto __795 } - if !((rc & 0xFF) == 6) { + if !((rc & 0xFF) == SQLITE_LOCKED) { goto __796 } z1 = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) @@ -72661,7 +72014,7 @@ __169: if !((pVtab1 == uintptr(0)) || ((*Sqlite3_vtab)(unsafe.Pointer(pVtab1)).FpModule == uintptr(0))) { goto __802 } - rc = 6 + rc = SQLITE_LOCKED goto abort_due_to_error __802: ; @@ -72679,7 +72032,7 @@ __803: (*Sqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 776 /* pVCur */)))).FpVtab = pVtab1 // Initialize vdbe cursor object - pCur1 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, 0, -1, uint8(2)) + pCur1 = allocateCursor(tls, p, (*Op)(unsafe.Pointer(pOp)).Fp1, 0, -1, CURTYPE_VTAB) if !(pCur1 != 0) { goto __804 } @@ -72715,7 +72068,7 @@ __805: __170: pQuery = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp3)*56) - pArgc = (pQuery + uintptr(1)*56) + pArgc = (pQuery + 1*56) pCur2 = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*8)) pVCur1 = *(*uintptr)(unsafe.Pointer(pCur2 + 56 /* &.uc */)) @@ -72794,15 +72147,15 @@ __811: libc.Xmemset(tls, bp+784 /* &sContext */, 0, uint64(unsafe.Sizeof(Sqlite3_context{}))) (*Sqlite3_context)(unsafe.Pointer(bp + 784 /* &sContext */)).FpOut = pDest1 - if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & 0x01) != 0) { + if !((int32((*Op)(unsafe.Pointer(pOp)).Fp5) & OPFLAG_NOCHNG) != 0) { goto __812 } Xsqlite3VdbeMemSetNull(tls, pDest1) - (*Mem)(unsafe.Pointer(pDest1)).Fflags = (U16(0x0001 | 0x4000)) + (*Mem)(unsafe.Pointer(pDest1)).Fflags = (U16(MEM_Null | MEM_Zero)) *(*int32)(unsafe.Pointer(pDest1 /* &.u */)) = 0 goto __813 __812: - (*Mem)(unsafe.Pointer(pDest1)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pDest1))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0001)) + (*Mem)(unsafe.Pointer(pDest1)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pDest1))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Null)) __813: ; rc = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pModule3 + 88 /* &.xColumn */))))(tls, *(*uintptr)(unsafe.Pointer(pCur3 + 56 /* &.uc */)), bp+784 /* &sContext */, (*Op)(unsafe.Pointer(pOp)).Fp2) @@ -72882,12 +72235,12 @@ __819: // in register P1 is passed as the zName argument to the xRename method. __173: - isLegacy = (int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x04000000))) - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(0x04000000)) + isLegacy = (int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_LegacyAlter)) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (SQLITE_LegacyAlter) pVtab5 = (*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)))).FpVtab pName = (aMem + uintptr((*Op)(unsafe.Pointer(pOp)).Fp1)*56) - rc = Xsqlite3VdbeChangeEncoding(tls, pName, 1) + rc = Xsqlite3VdbeChangeEncoding(tls, pName, SQLITE_UTF8) if !(rc != 0) { goto __820 } @@ -72898,7 +72251,7 @@ __820: if !(isLegacy == 0) { goto __821 } - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x04000000))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_LegacyAlter)) __821: ; Xsqlite3VtabImportErrmsg(tls, p, pVtab5) @@ -72951,7 +72304,7 @@ __823: if !((pVtab6 == uintptr(0)) || ((*Sqlite3_vtab)(unsafe.Pointer(pVtab6)).FpModule == uintptr(0))) { goto __824 } - rc = 6 + rc = SQLITE_LOCKED goto abort_due_to_error __824: ; @@ -72983,25 +72336,25 @@ __828: rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pModule5 + 104 /* &.xUpdate */))))(tls, pVtab6, nArg1, apArg1, bp+840 /* &rowid1 */) (*Sqlite3)(unsafe.Pointer(db)).FvtabOnConflict = vtabOnConflict Xsqlite3VtabImportErrmsg(tls, p, pVtab6) - if !((rc == 0) && ((*Op)(unsafe.Pointer(pOp)).Fp1 != 0)) { + if !((rc == SQLITE_OK) && ((*Op)(unsafe.Pointer(pOp)).Fp1 != 0)) { goto __829 } (*Sqlite3)(unsafe.Pointer(db)).FlastRowid = *(*Sqlite_int64)(unsafe.Pointer(bp + 840 /* rowid1 */)) __829: ; - if !(((rc & 0xff) == 19) && ((*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)))).FbConstraint != 0)) { + if !(((rc & 0xff) == SQLITE_CONSTRAINT) && ((*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)))).FbConstraint != 0)) { goto __830 } - if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5) == 4) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fp5) == OE_Ignore) { goto __832 } - rc = 0 + rc = SQLITE_OK goto __833 __832: (*Vdbe)(unsafe.Pointer(p)).FerrorAction = func() uint8 { - if int32((*Op)(unsafe.Pointer(pOp)).Fp5) == 5 { - return uint8(2) + if int32((*Op)(unsafe.Pointer(pOp)).Fp5) == OE_Replace { + return OE_Abort } return uint8((*Op)(unsafe.Pointer(pOp)).Fp5) }() @@ -73132,7 +72485,7 @@ __840: __837: ; - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0001)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Null)) (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(((*Sqlite3_context)(unsafe.Pointer(pCtx2)).FpFunc + 24 /* &.xSFunc */))))(tls, pCtx2, int32((*Sqlite3_context)(unsafe.Pointer(pCtx2)).Fargc), pCtx2+48 /* &.argv */) // IMP: R-24505-23230 @@ -73159,7 +72512,7 @@ __841: ; // Copy the result of the function into register P3 - if !((int32((*Mem)(unsafe.Pointer(pOut)).Fflags) & (0x0002 | 0x0010)) != 0) { + if !((int32((*Mem)(unsafe.Pointer(pOut)).Fflags) & (MEM_Str | MEM_Blob)) != 0) { goto __844 } Xsqlite3VdbeChangeEncoding(tls, pOut, int32(encoding)) @@ -73213,7 +72566,7 @@ __180: // OP_Init is always instruction 0 - if !((((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & (0x01 | 0x40)) != 0) && + if !((((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & (SQLITE_TRACE_STMT | SQLITE_TRACE_LEGACY)) != 0) && !(int32((*Vdbe)(unsafe.Pointer(p)).FdoingRerun) != 0)) && ((libc.AssignUintptr(&zTrace, func() uintptr { if *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) != 0 { @@ -73223,7 +72576,7 @@ __180: }())) != uintptr(0))) { goto __846 } - if !((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & 0x40) != 0) { + if !((int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & SQLITE_TRACE_LEGACY) != 0) { goto __847 } z2 = Xsqlite3VdbeExpandSql(tls, p, zTrace) @@ -73235,11 +72588,11 @@ __847: goto __849 } z3 = Xsqlite3MPrintf(tls, db, ts+7728 /* "-- %s" */, libc.VaList(bp+136, zTrace)) - (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, uint32(0x01), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, z3) + (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, SQLITE_TRACE_STMT, (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, z3) Xsqlite3DbFree(tls, db, z3) goto __850 __849: - (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, uint32(0x01), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, zTrace) + (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, SQLITE_TRACE_STMT, (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, p, zTrace) __850: ; __848: @@ -73250,7 +72603,7 @@ __846: if !((*Op)(unsafe.Pointer(pOp)).Fp1 >= Xsqlite3Config.FiOnceResetThreshold) { goto __851 } - if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 170) { + if !(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_Trace) { goto __852 } goto __10 @@ -73261,7 +72614,7 @@ __853: if !(i9 < (*Vdbe)(unsafe.Pointer(p)).FnOp) { goto __855 } - if !(int32((*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp+uintptr(i9)*32)).Fopcode) == 17) { + if !(int32((*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp+uintptr(i9)*32)).Fopcode) == OP_Once) { goto __856 } (*Op)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(p)).FaOp + uintptr(i9)*32)).Fp1 = 0 @@ -73278,7 +72631,7 @@ __855: __851: ; (*Op)(unsafe.Pointer(pOp)).Fp1++ - *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + uintptr(6)*4))++ + *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + 6*4))++ goto jump_to_p2 // Opcode: Noop * * * * * @@ -73322,11 +72675,11 @@ abort_due_to_error: if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __857 } - rc = 7 + rc = SQLITE_NOMEM __857: ; - if !(((*Vdbe)(unsafe.Pointer(p)).FzErrMsg == uintptr(0)) && (rc != (10 | (int32(12) << 8)))) { + if !(((*Vdbe)(unsafe.Pointer(p)).FzErrMsg == uintptr(0)) && (rc != (SQLITE_IOERR | (int32(12) << 8)))) { goto __858 } Xsqlite3VdbeError(tls, p, ts+824 /* "%s" */, libc.VaList(bp+144, Xsqlite3ErrStr(tls, rc))) @@ -73338,13 +72691,13 @@ __858: Xsqlite3_log(tls, rc, ts+7734, /* "statement aborts..." */ libc.VaList(bp+152, (int32((int64(pOp)-int64(aOp))/32)), (*Vdbe)(unsafe.Pointer(p)).FzSql, (*Vdbe)(unsafe.Pointer(p)).FzErrMsg)) Xsqlite3VdbeHalt(tls, p) - if !(rc == (10 | (int32(12) << 8))) { + if !(rc == (SQLITE_IOERR | (int32(12) << 8))) { goto __859 } Xsqlite3OomFault(tls, db) __859: ; - rc = 1 + rc = SQLITE_ERROR if !(int32(resetSchemaOnFault) > 0) { goto __860 } @@ -73365,14 +72718,14 @@ __861: goto __863 } nProgressLimit = (uint64(0xffffffff) | (U64((uint64(0xffffffff))) << 32)) - rc = 9 + rc = SQLITE_INTERRUPT goto abort_due_to_error __863: ; goto __861 __862: ; - *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + uintptr(4)*4)) += (U32(int32(nVmStep))) + *(*U32)(unsafe.Pointer((p + 212 /* &.aCounter */) + 4*4)) += (U32(int32(nVmStep))) Xsqlite3VdbeLeave(tls, p) return rc @@ -73381,34 +72734,34 @@ __862: // is encountered. too_big: Xsqlite3VdbeError(tls, p, ts+7050 /* "string or blob t..." */, 0) - rc = 18 + rc = SQLITE_TOOBIG goto abort_due_to_error // Jump to here if a malloc() fails. no_mem: Xsqlite3OomFault(tls, db) Xsqlite3VdbeError(tls, p, ts+7766 /* "out of memory" */, 0) - rc = 7 + rc = SQLITE_NOMEM goto abort_due_to_error // Jump to here if the sqlite3_interrupt() API sets the interrupt // flag. abort_due_to_interrupt: ; - rc = 9 + rc = SQLITE_INTERRUPT goto abort_due_to_error return int32(0) } var azType = [4]uintptr{ts + 7780 /* "NOT NULL" */, ts + 7789 /* "UNIQUE" */, ts + 7796, /* "CHECK" */ - ts + 7802 /* "FOREIGN KEY" */} /* sqlite3.c:86430:25 */ -var aLTb = [6]uint8{uint8(1), uint8(0), uint8(0), uint8(1), uint8(1), uint8(0)} /* sqlite3.c:87455:32 */ -var aEQb = [6]uint8{uint8(0), uint8(1), uint8(0), uint8(1), uint8(0), uint8(1)} /* sqlite3.c:87458:32 */ -var aGTb = [6]uint8{uint8(1), uint8(0), uint8(1), uint8(0), uint8(0), uint8(1)} /* sqlite3.c:87461:32 */ -var and_logic = [9]uint8{uint8(0), uint8(0), uint8(0), uint8(0), uint8(1), uint8(2), uint8(0), uint8(2), uint8(2)} /* sqlite3.c:87681:32 */ -var or_logic = [9]uint8{uint8(0), uint8(1), uint8(2), uint8(1), uint8(1), uint8(1), uint8(2), uint8(1), uint8(2)} /* sqlite3.c:87684:32 */ -var aFlag1 = [2]U16{U16(0x0010), (U16(0x0002 | 0x0200))} /* sqlite3.c:88134:24 */ -var vfsFlags int32 = ((((0x00000002 | 0x00000004) | 0x00000010) | 0x00000008) | 0x00000400) /* sqlite3.c:89263:20 */ + ts + 7802 /* "FOREIGN KEY" */} /* sqlite3.c:86430:25 */ +var aLTb = [6]uint8{uint8(1), uint8(0), uint8(0), uint8(1), uint8(1), uint8(0)} /* sqlite3.c:87455:32 */ +var aEQb = [6]uint8{uint8(0), uint8(1), uint8(0), uint8(1), uint8(0), uint8(1)} /* sqlite3.c:87458:32 */ +var aGTb = [6]uint8{uint8(1), uint8(0), uint8(1), uint8(0), uint8(0), uint8(1)} /* sqlite3.c:87461:32 */ +var and_logic = [9]uint8{uint8(0), uint8(0), uint8(0), uint8(0), uint8(1), uint8(2), uint8(0), uint8(2), uint8(2)} /* sqlite3.c:87681:32 */ +var or_logic = [9]uint8{uint8(0), uint8(1), uint8(2), uint8(1), uint8(1), uint8(1), uint8(2), uint8(1), uint8(2)} /* sqlite3.c:87684:32 */ +var aFlag1 = [2]U16{MEM_Blob, (U16(MEM_Str | MEM_Term))} /* sqlite3.c:88134:24 */ +var vfsFlags int32 = ((((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_DELETEONCLOSE) | SQLITE_OPEN_TRANSIENT_DB) /* sqlite3.c:89263:20 */ //************* End of vdbe.c *********************************************** //************* Begin file vdbeblob.c *************************************** @@ -73487,8 +72840,8 @@ func blobSeekToRow(tls *libc.TLS, p uintptr, iRow Sqlite3_int64, pzErr uintptr) // Set the value of register r[1] in the SQL statement to integer iRow. // This is done directly as a performance optimization - (*Mem)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + uintptr(1)*56)).Fflags = U16(0x0004) - *(*I64)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + uintptr(1)*56 /* &.u */)) = iRow + (*Mem)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + 1*56)).Fflags = MEM_Int + *(*I64)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FaMem + 1*56 /* &.u */)) = iRow // If the statement has been run before (and is paused at the OP_ResultRow) // then back it up to the point where it does the OP_NotExists. This could @@ -73501,8 +72854,8 @@ func blobSeekToRow(tls *libc.TLS, p uintptr, iRow Sqlite3_int64, pzErr uintptr) } else { rc = Xsqlite3_step(tls, (*Incrblob)(unsafe.Pointer(p)).FpStmt) } - if rc == 100 { - var pC uintptr = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FapCsr + uintptr(0)*8)) + if rc == SQLITE_ROW { + var pC uintptr = *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FapCsr)) var type1 U32 if int32((*VdbeCursor)(unsafe.Pointer(pC)).FnHdrParsed) > int32((*Incrblob)(unsafe.Pointer(p)).FiCol) { type1 = *(*U32)(unsafe.Pointer((pC + 120 /* &.aType */) + uintptr((*Incrblob)(unsafe.Pointer(p)).FiCol)*4)) @@ -73523,7 +72876,7 @@ func blobSeekToRow(tls *libc.TLS, p uintptr, iRow Sqlite3_int64, pzErr uintptr) return ts + 7853 /* "integer" */ }() }())) - rc = 1 + rc = SQLITE_ERROR Xsqlite3_finalize(tls, (*Incrblob)(unsafe.Pointer(p)).FpStmt) (*Incrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0) } else { @@ -73534,14 +72887,14 @@ func blobSeekToRow(tls *libc.TLS, p uintptr, iRow Sqlite3_int64, pzErr uintptr) } } - if rc == 100 { - rc = 0 + if rc == SQLITE_ROW { + rc = SQLITE_OK } else if (*Incrblob)(unsafe.Pointer(p)).FpStmt != 0 { rc = Xsqlite3_finalize(tls, (*Incrblob)(unsafe.Pointer(p)).FpStmt) (*Incrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0) - if rc == 0 { + if rc == SQLITE_OK { zErr = Xsqlite3MPrintf(tls, (*Incrblob)(unsafe.Pointer(p)).Fdb, ts+7861 /* "no such rowid: %..." */, libc.VaList(bp+8, iRow)) - rc = 1 + rc = SQLITE_ERROR } else { zErr = Xsqlite3MPrintf(tls, (*Incrblob)(unsafe.Pointer(p)).Fdb, ts+824 /* "%s" */, libc.VaList(bp+16, Xsqlite3_errmsg(tls, (*Incrblob)(unsafe.Pointer(p)).Fdb))) } @@ -73578,7 +72931,7 @@ func Xsqlite3_blob_open(tls *libc.TLS, db uintptr, zDb uintptr, zTable uintptr, var iDb int32 var aOp uintptr nAttempt = 0 - rc = 0 + rc = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp + 472 /* zErr */)) = uintptr(0) pBlob = uintptr(0) @@ -73609,7 +72962,7 @@ __4: Xsqlite3ErrorMsg(tls, bp+48 /* &sParse */, ts+7881 /* "cannot open virt..." */, libc.VaList(bp, zTable)) __5: ; - if !((pTab != 0) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) { + if !((pTab != 0) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) { goto __6 } pTab = uintptr(0) @@ -73634,7 +72987,7 @@ __7: (*Parse)(unsafe.Pointer(bp + 48 /* &sParse */)).FzErrMsg = uintptr(0) __9: ; - rc = 1 + rc = SQLITE_ERROR Xsqlite3BtreeLeaveAll(tls, db) goto blob_open_out __8: @@ -73666,7 +73019,7 @@ __12: } Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 472 /* zErr */))) *(*uintptr)(unsafe.Pointer(bp + 472 /* zErr */)) = Xsqlite3MPrintf(tls, db, ts+7968 /* "no such column: ..." */, libc.VaList(bp+24, zColumn)) - rc = 1 + rc = SQLITE_ERROR Xsqlite3BtreeLeaveAll(tls, db) goto blob_open_out __14: @@ -73678,7 +73031,7 @@ __14: goto __15 } zFault = uintptr(0) - if !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00004000)) != 0) { + if !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ForeignKeys) != 0) { goto __16 } pFKey = (*Table)(unsafe.Pointer(pTab)).FpFKey @@ -73749,7 +73102,7 @@ __26: } Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 472 /* zErr */))) *(*uintptr)(unsafe.Pointer(bp + 472 /* zErr */)) = Xsqlite3MPrintf(tls, db, ts+8009 /* "cannot open %s c..." */, libc.VaList(bp+32, zFault)) - rc = 1 + rc = SQLITE_ERROR Xsqlite3BtreeLeaveAll(tls, db) goto blob_open_out __31: @@ -73765,7 +73118,7 @@ __15: v = (*Incrblob)(unsafe.Pointer(pBlob)).FpStmt iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) - Xsqlite3VdbeAddOp4Int(tls, v, 2, iDb, wrFlag, + Xsqlite3VdbeAddOp4Int(tls, v, OP_Transaction, iDb, wrFlag, (*Schema)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FpSchema)).Fschema_cookie, (*Schema)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FpSchema)).FiGeneration) Xsqlite3VdbeChangeP5(tls, v, uint16(1)) @@ -73780,10 +73133,10 @@ __15: } // Configure the OP_TableLock instruction - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*32)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*32)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).Ftnum) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*32)).Fp3 = wrFlag - Xsqlite3VdbeChangeP4(tls, v, 2, (*Table)(unsafe.Pointer(pTab)).FzName, 0) + (*VdbeOp)(unsafe.Pointer(aOp)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).Ftnum) + (*VdbeOp)(unsafe.Pointer(aOp)).Fp3 = wrFlag + Xsqlite3VdbeChangeP4(tls, v, 2, (*Table)(unsafe.Pointer(pTab)).FzName, P4_TRANSIENT) __33: ; if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0) { @@ -73795,11 +73148,11 @@ __33: if !(wrFlag != 0) { goto __35 } - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(1)*32)).Fopcode = U8(97) + (*VdbeOp)(unsafe.Pointer(aOp + 1*32)).Fopcode = OP_OpenWrite __35: ; - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(1)*32)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).Ftnum) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(1)*32)).Fp3 = iDb + (*VdbeOp)(unsafe.Pointer(aOp + 1*32)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).Ftnum) + (*VdbeOp)(unsafe.Pointer(aOp + 1*32)).Fp3 = iDb // Configure the number of columns. Configure the cursor to // think that the table has one more column than it really @@ -73807,9 +73160,9 @@ __35: // always return an SQL NULL. This is useful because it means // we can invoke OP_Column to fill in the vdbe cursors type // and offset cache without causing any IO. - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(1)*32)).Fp4type = int8(-3) - *(*int32)(unsafe.Pointer(aOp + uintptr(1)*32 + 16 /* &.p4 */)) = (int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*32)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).FnCol) + (*VdbeOp)(unsafe.Pointer(aOp + 1*32)).Fp4type = int8(-3) + *(*int32)(unsafe.Pointer(aOp + 1*32 + 16 /* &.p4 */)) = (int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 1) + (*VdbeOp)(unsafe.Pointer(aOp + 3*32)).Fp2 = int32((*Table)(unsafe.Pointer(pTab)).FnCol) (*Parse)(unsafe.Pointer(bp + 48 /* &sParse */)).FnVar = int16(0) (*Parse)(unsafe.Pointer(bp + 48 /* &sParse */)).FnMem = 1 @@ -73832,7 +73185,7 @@ __36: rc = blobSeekToRow(tls, pBlob, iRow, bp+472 /* &zErr */) goto __2 __2: - if ((libc.PreIncInt32(&nAttempt, 1)) < 50) && (rc == 17) { + if ((libc.PreIncInt32(&nAttempt, 1)) < SQLITE_MAX_SCHEMA_RETRY) && (rc == SQLITE_SCHEMA) { goto __1 } goto __3 @@ -73840,7 +73193,7 @@ __3: ; blob_open_out: - if !((rc == 0) && (int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0)) { + if !((rc == SQLITE_OK) && (int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0)) { goto __37 } *(*uintptr)(unsafe.Pointer(ppBlob)) = pBlob @@ -73870,37 +73223,13 @@ __38: var iLn int32 = 0 /* sqlite3.c:93635:24 */ var openBlob = [6]VdbeOpList{ - { - Fopcode: U8(161), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 0: Acquire a read or write lock - { - Fopcode: U8(96), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 1: Open a cursor + {Fopcode: OP_TableLock}, // 0: Acquire a read or write lock + {Fopcode: OP_OpenRead}, // 1: Open a cursor // blobSeekToRow() will initialize r[1] to the desired rowid - { - Fopcode: U8(32), - Fp1: int8(0), - Fp2: int8(5), - Fp3: int8(1)}, // 2: Seek the cursor to rowid=r[1] - { - Fopcode: U8(89), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(1)}, // 3 - { - Fopcode: U8(80), - Fp1: int8(1), - Fp2: int8(0), - Fp3: int8(0)}, // 4 - { - Fopcode: U8(68), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 5 + {Fopcode: OP_NotExists, Fp2: int8(5), Fp3: int8(1)}, // 2: Seek the cursor to rowid=r[1] + {Fopcode: OP_Column, Fp3: int8(1)}, // 3 + {Fopcode: OP_ResultRow, Fp1: int8(1)}, // 4 + {Fopcode: OP_Halt}, // 5 } /* sqlite3.c:93636:31 */ // Close a blob handle that was previously created using @@ -73918,7 +73247,7 @@ func Xsqlite3_blob_close(tls *libc.TLS, pBlob uintptr) int32 { /* sqlite3.c:9372 Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) rc = Xsqlite3_finalize(tls, pStmt) } else { - rc = 0 + rc = SQLITE_OK } return rc } @@ -73939,11 +73268,11 @@ func blobReadWrite(tls *libc.TLS, pBlob uintptr, z uintptr, n int32, iOffset int if ((n < 0) || (iOffset < 0)) || ((Sqlite3_int64(iOffset) + Sqlite3_int64(n)) > Sqlite3_int64((*Incrblob)(unsafe.Pointer(p)).FnByte)) { // Request is out of range. Return a transient error. - rc = 1 + rc = SQLITE_ERROR } else if v == uintptr(0) { // If there is no statement handle, then the blob-handle has // already been invalidated. Return SQLITE_ABORT in this case. - rc = 4 + rc = SQLITE_ABORT } else { // Call either BtreeData() or BtreePutData(). If SQLITE_ABORT is // returned, clean-up the statement handle. @@ -73968,12 +73297,12 @@ func blobReadWrite(tls *libc.TLS, pBlob uintptr, z uintptr, n int32, iOffset int var iKey Sqlite3_int64 iKey = Xsqlite3BtreeIntegerKey(tls, (*Incrblob)(unsafe.Pointer(p)).FpCsr) Xsqlite3VdbePreUpdateHook(tls, - v, *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FapCsr + uintptr(0)*8)), 9, (*Incrblob)(unsafe.Pointer(p)).FzDb, (*Incrblob)(unsafe.Pointer(p)).FpTab, iKey, -1) + v, *(*uintptr)(unsafe.Pointer((*Vdbe)(unsafe.Pointer(v)).FapCsr)), SQLITE_DELETE, (*Incrblob)(unsafe.Pointer(p)).FzDb, (*Incrblob)(unsafe.Pointer(p)).FpTab, iKey, -1) } rc = (*(*func(*libc.TLS, uintptr, U32, U32, uintptr) int32)(unsafe.Pointer(&xCall)))(tls, (*Incrblob)(unsafe.Pointer(p)).FpCsr, (uint32(iOffset + (*Incrblob)(unsafe.Pointer(p)).FiOffset)), uint32(n), z) Xsqlite3BtreeLeaveCursor(tls, (*Incrblob)(unsafe.Pointer(p)).FpCsr) - if rc == 4 { + if rc == SQLITE_ABORT { Xsqlite3VdbeFinalize(tls, v) (*Incrblob)(unsafe.Pointer(p)).FpStmt = uintptr(0) } else { @@ -74037,12 +73366,12 @@ func Xsqlite3_blob_reopen(tls *libc.TLS, pBlob uintptr, iRow Sqlite3_int64) int3 if (*Incrblob)(unsafe.Pointer(p)).FpStmt == uintptr(0) { // If there is no statement handle, then the blob-handle has // already been invalidated. Return SQLITE_ABORT in this case. - rc = 4 + rc = SQLITE_ABORT } else { // var zErr uintptr at bp+8, 8 rc = blobSeekToRow(tls, p, iRow, bp+8 /* &zErr */) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3ErrorWithMsg(tls, db, rc, func() uintptr { if *(*uintptr)(unsafe.Pointer(bp + 8 /* zErr */)) != 0 { return ts + 824 /* "%s" */ @@ -74512,7 +73841,7 @@ func vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) int32 if (*PmaReader)(unsafe.Pointer(p)).FaMap != 0 { *(*uintptr)(unsafe.Pointer(ppOut)) = ((*PmaReader)(unsafe.Pointer(p)).FaMap + uintptr((*PmaReader)(unsafe.Pointer(p)).FiReadOff)) *(*I64)(unsafe.Pointer(p /* &.iReadOff */)) += (I64(nByte)) - return 0 + return SQLITE_OK } // If there is no more data to be read from the buffer, read the next @@ -74533,7 +73862,7 @@ func vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) int32 // Readr data from the file. Return early if an error occurs. rc = Xsqlite3OsRead(tls, (*PmaReader)(unsafe.Pointer(p)).FpFd, (*PmaReader)(unsafe.Pointer(p)).FaBuffer, nRead, (*PmaReader)(unsafe.Pointer(p)).FiReadOff) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -74565,7 +73894,7 @@ func vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) int32 } aNew = Xsqlite3Realloc(tls, (*PmaReader)(unsafe.Pointer(p)).FaAlloc, uint64(nNew)) if !(aNew != 0) { - return 7 + return SQLITE_NOMEM } (*PmaReader)(unsafe.Pointer(p)).FnAlloc = int32(nNew) (*PmaReader)(unsafe.Pointer(p)).FaAlloc = aNew @@ -74590,7 +73919,7 @@ func vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) int32 nCopy = (*PmaReader)(unsafe.Pointer(p)).FnBuffer } rc = vdbePmaReadBlob(tls, p, nCopy, bp /* &aNext */) - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -74601,7 +73930,7 @@ func vdbePmaReadBlob(tls *libc.TLS, p uintptr, nByte int32, ppOut uintptr) int32 *(*uintptr)(unsafe.Pointer(ppOut)) = (*PmaReader)(unsafe.Pointer(p)).FaAlloc } - return 0 + return SQLITE_OK } // Read a varint from the stream of data accessed by p. Set *pnOut to @@ -74625,18 +73954,18 @@ func vdbePmaReadVarint(tls *libc.TLS, p uintptr, pnOut uintptr) int32 { /* sqlit var i int32 = 0 var rc int32 - for ok := true; ok; ok = ((int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* a */)) + uintptr(0)))) & 0x80) != 0) { + for ok := true; ok; ok = ((int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* a */))))) & 0x80) != 0) { rc = vdbePmaReadBlob(tls, p, 1, bp /* &a */) if rc != 0 { return rc } - *(*U8)(unsafe.Pointer(bp + 8 /* &aVarint[0] */ + uintptr(((libc.PostIncInt32(&i, 1)) & 0xf)))) = *(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* a */)) + uintptr(0))) + *(*U8)(unsafe.Pointer(bp + 8 /* &aVarint[0] */ + uintptr(((libc.PostIncInt32(&i, 1)) & 0xf)))) = *(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* a */)))) } Xsqlite3GetVarint(tls, bp+8 /* &aVarint[0] */, pnOut) } } - return 0 + return SQLITE_OK } // Attempt to memory map file pFile. If successful, set *pp to point to the @@ -74647,7 +73976,7 @@ func vdbePmaReadVarint(tls *libc.TLS, p uintptr, pnOut uintptr) int32 { /* sqlit // Or, if an error occurs, return an SQLite error code. The final value of // *pp is undefined in this case. func vdbeSorterMapFile(tls *libc.TLS, pTask uintptr, pFile uintptr, pp uintptr) int32 { /* sqlite3.c:94497:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*SorterFile)(unsafe.Pointer(pFile)).FiEof <= (I64((*Sqlite3)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb)).FnMaxSorterMmap)) { var pFd uintptr = (*SorterFile)(unsafe.Pointer(pFile)).FpFd if (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pFd)).FpMethods)).FiVersion >= 3 { @@ -74662,10 +73991,10 @@ func vdbeSorterMapFile(tls *libc.TLS, pTask uintptr, pFile uintptr, pp uintptr) // that file) and seek it to offset iOff within the file. Return SQLITE_OK // if successful, or an SQLite error code if an error occurs. func vdbePmaReaderSeek(tls *libc.TLS, pTask uintptr, pReadr uintptr, pFile uintptr, iOff I64) int32 { /* sqlite3.c:94514:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if Xsqlite3FaultSim(tls, 201) != 0 { - return (10 | (int32(1) << 8)) + return (SQLITE_IOERR | (int32(1) << 8)) } if (*PmaReader)(unsafe.Pointer(pReadr)).FaMap != 0 { Xsqlite3OsUnfetch(tls, (*PmaReader)(unsafe.Pointer(pReadr)).FpFd, int64(0), (*PmaReader)(unsafe.Pointer(pReadr)).FaMap) @@ -74676,17 +74005,17 @@ func vdbePmaReaderSeek(tls *libc.TLS, pTask uintptr, pReadr uintptr, pFile uintp (*PmaReader)(unsafe.Pointer(pReadr)).FpFd = (*SorterFile)(unsafe.Pointer(pFile)).FpFd rc = vdbeSorterMapFile(tls, pTask, pFile, (pReadr + 64 /* &.aMap */)) - if (rc == 0) && ((*PmaReader)(unsafe.Pointer(pReadr)).FaMap == uintptr(0)) { + if (rc == SQLITE_OK) && ((*PmaReader)(unsafe.Pointer(pReadr)).FaMap == uintptr(0)) { var pgsz int32 = (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fpgsz var iBuf int32 = (int32((*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff % I64(pgsz))) if (*PmaReader)(unsafe.Pointer(pReadr)).FaBuffer == uintptr(0) { (*PmaReader)(unsafe.Pointer(pReadr)).FaBuffer = Xsqlite3Malloc(tls, uint64(pgsz)) if (*PmaReader)(unsafe.Pointer(pReadr)).FaBuffer == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } (*PmaReader)(unsafe.Pointer(pReadr)).FnBuffer = pgsz } - if (rc == 0) && (iBuf != 0) { + if (rc == SQLITE_OK) && (iBuf != 0) { var nRead int32 = (pgsz - iBuf) if ((*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff + I64(nRead)) > (*PmaReader)(unsafe.Pointer(pReadr)).FiEof { nRead = (int32((*PmaReader)(unsafe.Pointer(pReadr)).FiEof - (*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff)) @@ -74706,7 +74035,7 @@ func vdbePmaReaderNext(tls *libc.TLS, pReadr uintptr) int32 { /* sqlite3.c:94561 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 // Return Code + var rc int32 = SQLITE_OK // Return Code *(*U64)(unsafe.Pointer(bp /* nRec */)) = uint64(0) // Size of record in bytes if (*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff >= (*PmaReader)(unsafe.Pointer(pReadr)).FiEof { @@ -74714,9 +74043,9 @@ func vdbePmaReaderNext(tls *libc.TLS, pReadr uintptr) int32 { /* sqlite3.c:94561 var bEof int32 = 1 if pIncr != 0 { rc = vdbeIncrSwap(tls, pIncr) - if (rc == 0) && ((*IncrMerger)(unsafe.Pointer(pIncr)).FbEof == 0) { + if (rc == SQLITE_OK) && ((*IncrMerger)(unsafe.Pointer(pIncr)).FbEof == 0) { rc = vdbePmaReaderSeek(tls, - (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask, pReadr, ((pIncr + 40 /* &.aFile */) + uintptr(0)*16), (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff) + (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask, pReadr, (pIncr + 40 /* &.aFile */), (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff) bEof = 0 } } @@ -74729,10 +74058,10 @@ func vdbePmaReaderNext(tls *libc.TLS, pReadr uintptr) int32 { /* sqlite3.c:94561 } } - if rc == 0 { + if rc == SQLITE_OK { rc = vdbePmaReadVarint(tls, pReadr, bp /* &nRec */) } - if rc == 0 { + if rc == SQLITE_OK { (*PmaReader)(unsafe.Pointer(pReadr)).FnKey = int32(*(*U64)(unsafe.Pointer(bp /* nRec */))) rc = vdbePmaReadBlob(tls, pReadr, int32(*(*U64)(unsafe.Pointer(bp /* nRec */))), (pReadr + 40 /* &.aKey */)) @@ -74755,14 +74084,14 @@ func vdbePmaReaderInit(tls *libc.TLS, pTask uintptr, pFile uintptr, iStart I64, var rc int32 rc = vdbePmaReaderSeek(tls, pTask, pReadr, pFile, iStart) - if rc == 0 { + if rc == SQLITE_OK { *(*U64)(unsafe.Pointer(bp /* nByte */)) = uint64(0) // Size of PMA in bytes rc = vdbePmaReadVarint(tls, pReadr, bp /* &nByte */) (*PmaReader)(unsafe.Pointer(pReadr)).FiEof = (I64(U64((*PmaReader)(unsafe.Pointer(pReadr)).FiReadOff) + *(*U64)(unsafe.Pointer(bp /* nByte */)))) *(*I64)(unsafe.Pointer(pnByte)) += I64((*(*U64)(unsafe.Pointer(bp /* nByte */)))) } - if rc == 0 { + if rc == SQLITE_OK { rc = vdbePmaReaderNext(tls, pReadr) } return rc @@ -74809,8 +74138,8 @@ func vdbeSorterCompareText(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, p var p1 uintptr = pKey1 var p2 uintptr = pKey2 - var v1 uintptr = (p1 + uintptr(*(*U8)(unsafe.Pointer(p1 + uintptr(0))))) // Pointer to value 1 - var v2 uintptr = (p2 + uintptr(*(*U8)(unsafe.Pointer(p2 + uintptr(0))))) // Pointer to value 2 + var v1 uintptr = (p1 + uintptr(*(*U8)(unsafe.Pointer(p1)))) // Pointer to value 1 + var v2 uintptr = (p2 + uintptr(*(*U8)(unsafe.Pointer(p2)))) // Pointer to value 2 // var n1 int32 at bp, 4 @@ -74818,13 +74147,13 @@ func vdbeSorterCompareText(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, p var res int32 - *(*int32)(unsafe.Pointer(bp /* n1 */)) = int32(U32(*(*U8)(unsafe.Pointer((p1 + uintptr(1)))))) + *(*int32)(unsafe.Pointer(bp /* n1 */)) = int32(U32(*(*U8)(unsafe.Pointer((p1 + 1))))) if *(*int32)(unsafe.Pointer(bp /* n1 */)) >= 0x80 { - Xsqlite3GetVarint32(tls, (p1 + uintptr(1)), bp /* &n1 */) + Xsqlite3GetVarint32(tls, (p1 + 1), bp /* &n1 */) } - *(*int32)(unsafe.Pointer(bp + 4 /* n2 */)) = int32(U32(*(*U8)(unsafe.Pointer((p2 + uintptr(1)))))) + *(*int32)(unsafe.Pointer(bp + 4 /* n2 */)) = int32(U32(*(*U8)(unsafe.Pointer((p2 + 1))))) if *(*int32)(unsafe.Pointer(bp + 4 /* n2 */)) >= 0x80 { - Xsqlite3GetVarint32(tls, (p2 + uintptr(1)), bp+4 /* &n2 */) + Xsqlite3GetVarint32(tls, (p2 + 1), bp+4 /* &n2 */) } res = libc.Xmemcmp(tls, v1, v2, (uint64(((func() int32 { if (*(*int32)(unsafe.Pointer(bp /* n1 */))) < (*(*int32)(unsafe.Pointer(bp + 4 /* n2 */))) { @@ -74843,7 +74172,7 @@ func vdbeSorterCompareText(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, p } } else { - if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FaSortFlags + uintptr(0))) != 0 { + if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FaSortFlags)) != 0 { res = (res * -1) } } @@ -74856,11 +74185,11 @@ func vdbeSorterCompareText(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, p func vdbeSorterCompareInt(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pKey1 uintptr, nKey1 int32, pKey2 uintptr, nKey2 int32) int32 { /* sqlite3.c:94729:12: */ var p1 uintptr = pKey1 var p2 uintptr = pKey2 - var s1 int32 = int32(*(*U8)(unsafe.Pointer(p1 + uintptr(1)))) // Left hand serial type - var s2 int32 = int32(*(*U8)(unsafe.Pointer(p2 + uintptr(1)))) // Right hand serial type - var v1 uintptr = (p1 + uintptr(*(*U8)(unsafe.Pointer(p1 + uintptr(0))))) // Pointer to value 1 - var v2 uintptr = (p2 + uintptr(*(*U8)(unsafe.Pointer(p2 + uintptr(0))))) // Pointer to value 2 - var res int32 // Return value + var s1 int32 = int32(*(*U8)(unsafe.Pointer(p1 + 1))) // Left hand serial type + var s2 int32 = int32(*(*U8)(unsafe.Pointer(p2 + 1))) // Right hand serial type + var v1 uintptr = (p1 + uintptr(*(*U8)(unsafe.Pointer(p1)))) // Pointer to value 1 + var v2 uintptr = (p2 + uintptr(*(*U8)(unsafe.Pointer(p2)))) // Pointer to value 2 + var res int32 // Return value if s1 == s2 { var n U8 = aLen[s1] @@ -74868,8 +74197,8 @@ func vdbeSorterCompareInt(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pK res = 0 for i = 0; i < int32(n); i++ { if (libc.AssignInt32(&res, (int32(*(*U8)(unsafe.Pointer(v1 + uintptr(i)))) - int32(*(*U8)(unsafe.Pointer(v2 + uintptr(i))))))) != 0 { - if ((int32(*(*U8)(unsafe.Pointer(v1 + uintptr(0)))) ^ int32(*(*U8)(unsafe.Pointer(v2 + uintptr(0))))) & 0x80) != 0 { - if (int32(*(*U8)(unsafe.Pointer(v1 + uintptr(0)))) & 0x80) != 0 { + if ((int32(*(*U8)(unsafe.Pointer(v1))) ^ int32(*(*U8)(unsafe.Pointer(v2)))) & 0x80) != 0 { + if (int32(*(*U8)(unsafe.Pointer(v1))) & 0x80) != 0 { res = -1 } else { res = +1 @@ -74905,7 +74234,7 @@ func vdbeSorterCompareInt(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pK res = vdbeSorterCompareTail(tls, pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2) } - } else if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FaSortFlags + uintptr(0))) != 0 { + } else if *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FaSortFlags)) != 0 { res = (res * -1) } @@ -74939,14 +74268,14 @@ func Xsqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintpt var pKeyInfo uintptr // Copy of pCsr->pKeyInfo with db==0 var szKeyInfo int32 // Size of pCsr->pKeyInfo in bytes var sz int32 // Size of pSorter in bytes - var rc int32 = 0 + var rc int32 = SQLITE_OK var nWorker int32 // Initialize the upper limit on the number of worker threads if (Xsqlite3TempInMemory(tls, db) != 0) || (int32(Xsqlite3Config.FbCoreMutex) == 0) { nWorker = 0 } else { - nWorker = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(11)*4)) + nWorker = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 11*4)) } // Do not allow the total number of threads (main thread + all workers) @@ -74958,7 +74287,7 @@ func Xsqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintpt pSorter = Xsqlite3DbMallocZero(tls, db, (uint64(sz + szKeyInfo))) *(*uintptr)(unsafe.Pointer(pCsr + 56 /* &.uc */)) = pSorter if pSorter == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { (*VdbeSorter)(unsafe.Pointer(pSorter)).FpKeyInfo = libc.AssignUintptr(&pKeyInfo, (pSorter + uintptr(sz))) libc.Xmemcpy(tls, pKeyInfo, (*VdbeCursor)(unsafe.Pointer(pCsr)).FpKeyInfo, uint64(szKeyInfo)) @@ -74966,7 +74295,7 @@ func Xsqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintpt if (nField != 0) && (nWorker == 0) { (*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnKeyField = U16(nField) } - (*VdbeSorter)(unsafe.Pointer(pSorter)).Fpgsz = libc.AssignInt32(&pgsz, Xsqlite3BtreeGetPageSize(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt)) + (*VdbeSorter)(unsafe.Pointer(pSorter)).Fpgsz = libc.AssignInt32(&pgsz, Xsqlite3BtreeGetPageSize(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt)) (*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask = (U8(nWorker + 1)) (*VdbeSorter)(unsafe.Pointer(pSorter)).FiPrev = (U8(nWorker - 1)) (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads = (U8(libc.Bool32(int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) > 1))) @@ -74981,7 +74310,7 @@ func Xsqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintpt var szPma U32 = Xsqlite3Config.FszPma (*VdbeSorter)(unsafe.Pointer(pSorter)).FmnPmaSize = (int32(szPma * U32(pgsz))) - mxCache = I64((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FpSchema)).Fcache_size) + mxCache = I64((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema)).Fcache_size) if mxCache < int64(0) { // A negative cache-size value C indicates that the cache is abs(C) // KiB in size. @@ -75009,15 +74338,15 @@ func Xsqlite3VdbeSorterInit(tls *libc.TLS, db uintptr, nField int32, pCsr uintpt (*VdbeSorter)(unsafe.Pointer(pSorter)).FnMemory = pgsz (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = Xsqlite3Malloc(tls, uint64(pgsz)) if !(int32((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory) != 0) { - rc = 7 + rc = SQLITE_NOMEM } } } if ((int32((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FnAllField) < 13) && - ((*(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */) + uintptr(0)*8)) == uintptr(0)) || (*(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */) + uintptr(0)*8)) == (*Sqlite3)(unsafe.Pointer(db)).FpDfltColl))) && - ((int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(0)))) & 0x02) == 0) { - (*VdbeSorter)(unsafe.Pointer(pSorter)).FtypeMask = (U8(0x01 | 0x02)) + ((*(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */))) == uintptr(0)) || (*(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */))) == (*Sqlite3)(unsafe.Pointer(db)).FpDfltColl))) && + ((int32(*(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags))) & KEYINFO_ORDER_BIGNULL) == 0) { + (*VdbeSorter)(unsafe.Pointer(pSorter)).FtypeMask = (U8(SORTER_TYPE_INTEGER | SORTER_TYPE_TEXT)) } } @@ -75060,9 +74389,9 @@ func vdbeSorterJoinThread(tls *libc.TLS, pTask uintptr) int32 { /* sqlite3.c:949 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*SortSubtask)(unsafe.Pointer(pTask)).FpThread != 0 { - *(*uintptr)(unsafe.Pointer(bp /* pRet */)) = uintptr(int64(1)) + *(*uintptr)(unsafe.Pointer(bp /* pRet */)) = uintptr(SQLITE_ERROR) Xsqlite3ThreadJoin(tls, (*SortSubtask)(unsafe.Pointer(pTask)).FpThread, bp /* &pRet */) @@ -75096,7 +74425,7 @@ func vdbeSorterJoinAll(tls *libc.TLS, pSorter uintptr, rcin int32) int32 { /* sq for i = (int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) - 1); i >= 0; i-- { var pTask uintptr = ((pSorter + 96 /* &.aTask */) + uintptr(i)*104) var rc2 int32 = vdbeSorterJoinThread(tls, pTask) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } @@ -75126,7 +74455,7 @@ func vdbeMergeEngineNew(tls *libc.TLS, nReader int32) uintptr { /* sqlite3.c:950 if pNew != 0 { (*MergeEngine)(unsafe.Pointer(pNew)).FnTree = N (*MergeEngine)(unsafe.Pointer(pNew)).FpTask = uintptr(0) - (*MergeEngine)(unsafe.Pointer(pNew)).FaReadr = (pNew + uintptr(1)*32) + (*MergeEngine)(unsafe.Pointer(pNew)).FaReadr = (pNew + 1*32) (*MergeEngine)(unsafe.Pointer(pNew)).FaTree = ((*MergeEngine)(unsafe.Pointer(pNew)).FaReadr + uintptr(N)*80) } return pNew @@ -75149,11 +74478,11 @@ func vdbeIncrFree(tls *libc.TLS, pIncr uintptr) { /* sqlite3.c:95093:13: */ if pIncr != 0 { if (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { vdbeSorterJoinThread(tls, (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask) - if (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+uintptr(0)*16)).FpFd != 0 { - Xsqlite3OsCloseFree(tls, (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+uintptr(0)*16)).FpFd) + if (*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))).FpFd != 0 { + Xsqlite3OsCloseFree(tls, (*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))).FpFd) } - if (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+uintptr(1)*16)).FpFd != 0 { - Xsqlite3OsCloseFree(tls, (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+uintptr(1)*16)).FpFd) + if (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+1*16)).FpFd != 0 { + Xsqlite3OsCloseFree(tls, (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+1*16)).FpFd) } } vdbeMergeEngineFree(tls, (*IncrMerger)(unsafe.Pointer(pIncr)).FpMerger) @@ -75164,7 +74493,7 @@ func vdbeIncrFree(tls *libc.TLS, pIncr uintptr) { /* sqlite3.c:95093:13: */ // Reset a sorting cursor back to its original empty state. func Xsqlite3VdbeSorterReset(tls *libc.TLS, db uintptr, pSorter uintptr) { /* sqlite3.c:95110:21: */ var i int32 - vdbeSorterJoinAll(tls, pSorter, 0) + vdbeSorterJoinAll(tls, pSorter, SQLITE_OK) if (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader != 0 { vdbePmaReaderClear(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader) @@ -75218,8 +74547,8 @@ func vdbeSorterExtendFile(tls *libc.TLS, db uintptr, pFd uintptr, nByte I64) { / if (*(*I64)(unsafe.Pointer(bp + 8 /* nByte */)) <= (I64((*Sqlite3)(unsafe.Pointer(db)).FnMaxSorterMmap))) && ((*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer(pFd)).FpMethods)).FiVersion >= 3) { *(*uintptr)(unsafe.Pointer(bp + 16 /* p */)) = uintptr(0) *(*int32)(unsafe.Pointer(bp /* chunksize */)) = (4 * 1024) - Xsqlite3OsFileControlHint(tls, pFd, 6, bp /* &chunksize */) - Xsqlite3OsFileControlHint(tls, pFd, 5, bp+8 /* &nByte */) + Xsqlite3OsFileControlHint(tls, pFd, SQLITE_FCNTL_CHUNK_SIZE, bp /* &chunksize */) + Xsqlite3OsFileControlHint(tls, pFd, SQLITE_FCNTL_SIZE_HINT, bp+8 /* &nByte */) Xsqlite3OsFetch(tls, pFd, int64(0), int32(*(*I64)(unsafe.Pointer(bp + 8 /* nByte */))), bp+16 /* &p */) Xsqlite3OsUnfetch(tls, pFd, int64(0), *(*uintptr)(unsafe.Pointer(bp + 16 /* p */))) } @@ -75235,13 +74564,13 @@ func vdbeSorterOpenTempFile(tls *libc.TLS, db uintptr, nExtend I64, ppFd uintptr // var rc int32 at bp, 4 if Xsqlite3FaultSim(tls, 202) != 0 { - return (10 | (int32(13) << 8)) + return (SQLITE_IOERR | (int32(13) << 8)) } *(*int32)(unsafe.Pointer(bp /* rc */)) = Xsqlite3OsOpenMalloc(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), ppFd, - ((((0x00001000 | 0x00000002) | 0x00000004) | 0x00000010) | 0x00000008), bp /* &rc */) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { - *(*I64)(unsafe.Pointer(bp + 8 /* max */)) = int64(0x7fff0000) - Xsqlite3OsFileControlHint(tls, *(*uintptr)(unsafe.Pointer(ppFd)), 18, bp+8 /* &max */) + ((((SQLITE_OPEN_TEMP_JOURNAL | SQLITE_OPEN_READWRITE) | SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_DELETEONCLOSE), bp /* &rc */) + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { + *(*I64)(unsafe.Pointer(bp + 8 /* max */)) = SQLITE_MAX_MMAP_SIZE + Xsqlite3OsFileControlHint(tls, *(*uintptr)(unsafe.Pointer(ppFd)), SQLITE_FCNTL_MMAP_SIZE, bp+8 /* &max */) if nExtend > int64(0) { vdbeSorterExtendFile(tls, db, *(*uintptr)(unsafe.Pointer(ppFd)), nExtend) } @@ -75256,12 +74585,12 @@ func vdbeSortAllocUnpacked(tls *libc.TLS, pTask uintptr) int32 { /* sqlite3.c:95 if (*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked == uintptr(0) { (*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked = Xsqlite3VdbeAllocUnpackedRecord(tls, (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo) if (*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*UnpackedRecord)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FnField = (*KeyInfo)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FnKeyField (*UnpackedRecord)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode = U8(0) } - return 0 + return SQLITE_OK } // Merge the two sorted lists p1 and p2 into a single list. @@ -75303,11 +74632,11 @@ func vdbeSorterMerge(tls *libc.TLS, pTask uintptr, p1 uintptr, p2 uintptr) uintp // Return the SorterCompare function to compare values collected by the // sorter object passed as the only argument. func vdbeSorterGetCompare(tls *libc.TLS, p uintptr) SorterCompare { /* sqlite3.c:95267:22: */ - if int32((*VdbeSorter)(unsafe.Pointer(p)).FtypeMask) == 0x01 { + if int32((*VdbeSorter)(unsafe.Pointer(p)).FtypeMask) == SORTER_TYPE_INTEGER { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32 }{vdbeSorterCompareInt})) - } else if int32((*VdbeSorter)(unsafe.Pointer(p)).FtypeMask) == 0x02 { + } else if int32((*VdbeSorter)(unsafe.Pointer(p)).FtypeMask) == SORTER_TYPE_TEXT { return *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr, int32) int32 }{vdbeSorterCompareText})) @@ -75330,7 +74659,7 @@ func vdbeSorterSort(tls *libc.TLS, pTask uintptr, pList uintptr) int32 { /* sqli // var aSlot [64]uintptr at bp, 512 rc = vdbeSortAllocUnpacked(tls, pTask) - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -75381,7 +74710,7 @@ func vdbePmaWriterInit(tls *libc.TLS, pFd uintptr, p uintptr, nBuf int32, iStart libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(PmaWriter{}))) (*PmaWriter)(unsafe.Pointer(p)).FaBuffer = Xsqlite3Malloc(tls, uint64(nBuf)) if !(int32((*PmaWriter)(unsafe.Pointer(p)).FaBuffer) != 0) { - (*PmaWriter)(unsafe.Pointer(p)).FeFWErr = 7 + (*PmaWriter)(unsafe.Pointer(p)).FeFWErr = SQLITE_NOMEM } else { (*PmaWriter)(unsafe.Pointer(p)).FiBufEnd = libc.AssignPtrInt32(p+20 /* &.iBufStart */, (int32(iStart % I64(nBuf)))) (*PmaWriter)(unsafe.Pointer(p)).FiWriteOff = (iStart - I64((*PmaWriter)(unsafe.Pointer(p)).FiBufStart)) @@ -75465,7 +74794,7 @@ func vdbeSorterListToPMA(tls *libc.TLS, pTask uintptr, pList uintptr) int32 { /* defer tls.Free(48) var db uintptr = (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code // var writer PmaWriter at bp, 48 // Object used to write to the file @@ -75478,16 +74807,16 @@ func vdbeSorterListToPMA(tls *libc.TLS, pTask uintptr, pList uintptr) int32 { /* } // Try to get the file to memory map - if rc == 0 { + if rc == SQLITE_OK { vdbeSorterExtendFile(tls, db, (*SortSubtask)(unsafe.Pointer(pTask)).Ffile.FpFd, (((*SortSubtask)(unsafe.Pointer(pTask)).Ffile.FiEof + I64((*SorterList)(unsafe.Pointer(pList)).FszPMA)) + int64(9))) } // Sort the list - if rc == 0 { + if rc == SQLITE_OK { rc = vdbeSorterSort(tls, pTask, pList) } - if rc == 0 { + if rc == SQLITE_OK { var p uintptr var pNext uintptr = uintptr(0) @@ -75520,14 +74849,14 @@ func vdbeMergeEngineStep(tls *libc.TLS, pMerger uintptr, pbEof uintptr) int32 { defer tls.Free(4) var rc int32 - var iPrev int32 = *(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(1)*4)) // Index of PmaReader to advance + var iPrev int32 = *(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + 1*4)) // Index of PmaReader to advance var pTask uintptr = (*MergeEngine)(unsafe.Pointer(pMerger)).FpTask // Advance the current PmaReader rc = vdbePmaReaderNext(tls, ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(iPrev)*80)) // Update contents of aTree[] - if rc == 0 { + if rc == SQLITE_OK { var i int32 // Index of aTree[] to recalculate var pReadr1 uintptr // First PmaReader to compare var pReadr2 uintptr // Second PmaReader to compare @@ -75577,11 +74906,11 @@ func vdbeMergeEngineStep(tls *libc.TLS, pMerger uintptr, pbEof uintptr) int32 { pReadr1 = ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr((i^0x0001))*4)))*80) } } - *(*int32)(unsafe.Pointer(pbEof)) = (libc.Bool32((*PmaReader)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(1)*4)))*80)).FpFd == uintptr(0))) + *(*int32)(unsafe.Pointer(pbEof)) = (libc.Bool32((*PmaReader)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr+uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + 1*4)))*80)).FpFd == uintptr(0))) } return func() int32 { - if rc == 0 { + if rc == SQLITE_OK { return int32((*UnpackedRecord)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode) } return rc @@ -75601,7 +74930,7 @@ func vdbeSorterFlushThread(tls *libc.TLS, pCtx uintptr) uintptr { /* sqlite3.c:9 // Flush the current contents of VdbeSorter.list to a new PMA, possibly // using a background thread. func vdbeSorterFlushPMA(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:95576:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 var pTask uintptr = uintptr(0) // Thread context used to create new PMA var nWorker int32 = (int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) - 1) @@ -75624,12 +74953,12 @@ func vdbeSorterFlushPMA(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:955 if (*SortSubtask)(unsafe.Pointer(pTask)).FbDone != 0 { rc = vdbeSorterJoinThread(tls, pTask) } - if (rc != 0) || ((*SortSubtask)(unsafe.Pointer(pTask)).FpThread == uintptr(0)) { + if (rc != SQLITE_OK) || ((*SortSubtask)(unsafe.Pointer(pTask)).FpThread == uintptr(0)) { break } } - if rc == 0 { + if rc == SQLITE_OK { if i == nWorker { // Use the foreground thread for this operation rc = vdbeSorterListToPMA(tls, ((pSorter + 96 /* &.aTask */) + uintptr(nWorker)*104), (pSorter + 56 /* &.list */)) @@ -75650,7 +74979,7 @@ func vdbeSorterFlushPMA(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:955 } else if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory != 0 { (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory = Xsqlite3Malloc(tls, uint64((*VdbeSorter)(unsafe.Pointer(pSorter)).FnMemory)) if !(int32((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory) != 0) { - return 7 + return SQLITE_NOMEM } } @@ -75669,23 +74998,23 @@ func Xsqlite3VdbeSorterWrite(tls *libc.TLS, pCsr uintptr, pVal uintptr) int32 { defer tls.Free(4) var pSorter uintptr - var rc int32 = 0 // Return Code - var pNew uintptr // New list element - var bFlush int32 // True to flush contents of memory to PMA - var nReq int32 // Bytes of memory required - var nPMA int32 // Bytes of PMA space required + var rc int32 = SQLITE_OK // Return Code + var pNew uintptr // New list element + var bFlush int32 // True to flush contents of memory to PMA + var nReq int32 // Bytes of memory required + var nPMA int32 // Bytes of PMA space required // var t int32 at bp, 4 // serial type of first record field pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 56 /* &.uc */)) - *(*int32)(unsafe.Pointer(bp /* t */)) = int32(U32(*(*U8)(unsafe.Pointer(((*Mem)(unsafe.Pointer(pVal)).Fz + uintptr(1)))))) + *(*int32)(unsafe.Pointer(bp /* t */)) = int32(U32(*(*U8)(unsafe.Pointer(((*Mem)(unsafe.Pointer(pVal)).Fz + 1))))) if *(*int32)(unsafe.Pointer(bp /* t */)) >= 0x80 { - Xsqlite3GetVarint32(tls, ((*Mem)(unsafe.Pointer(pVal)).Fz + uintptr(1)), bp /* &t */) + Xsqlite3GetVarint32(tls, ((*Mem)(unsafe.Pointer(pVal)).Fz + 1), bp /* &t */) } if ((*(*int32)(unsafe.Pointer(bp /* t */)) > 0) && (*(*int32)(unsafe.Pointer(bp /* t */)) < 10)) && (*(*int32)(unsafe.Pointer(bp /* t */)) != 7) { - *(*U8)(unsafe.Pointer(pSorter + 92 /* &.typeMask */)) &= U8((0x01)) + *(*U8)(unsafe.Pointer(pSorter + 92 /* &.typeMask */)) &= U8((SORTER_TYPE_INTEGER)) } else if (*(*int32)(unsafe.Pointer(bp /* t */)) > 10) && ((*(*int32)(unsafe.Pointer(bp /* t */)) & 0x01) != 0) { - *(*U8)(unsafe.Pointer(pSorter + 92 /* &.typeMask */)) &= U8((0x02)) + *(*U8)(unsafe.Pointer(pSorter + 92 /* &.typeMask */)) &= U8((SORTER_TYPE_TEXT)) } else { (*VdbeSorter)(unsafe.Pointer(pSorter)).FtypeMask = U8(0) } @@ -75748,7 +75077,7 @@ func Xsqlite3VdbeSorterWrite(tls *libc.TLS, pCsr uintptr, pVal uintptr) int32 { } aNew = Xsqlite3Realloc(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory, uint64(nNew)) if !(aNew != 0) { - return 7 + return SQLITE_NOMEM } if iListOff >= 0 { (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList = (aNew + uintptr(iListOff)) @@ -75758,14 +75087,14 @@ func Xsqlite3VdbeSorterWrite(tls *libc.TLS, pCsr uintptr, pVal uintptr) int32 { } pNew = ((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory + uintptr((*VdbeSorter)(unsafe.Pointer(pSorter)).FiMemory)) - *(*int32)(unsafe.Pointer(pSorter + 80 /* &.iMemory */)) += (((nReq) + 7) & ^libc.Int32(7)) + *(*int32)(unsafe.Pointer(pSorter + 80 /* &.iMemory */)) += (((nReq) + 7) & libc.CplInt32(7)) if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 { *(*int32)(unsafe.Pointer(pNew + 8 /* &.u */)) = (int32((int64(((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList)) - int64((*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FaMemory)) / 1)) } } else { pNew = Xsqlite3Malloc(tls, uint64(nReq)) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } *(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)) = (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList } @@ -75784,19 +75113,19 @@ func vdbeIncrPopulate(tls *libc.TLS, pIncr uintptr) int32 { /* sqlite3.c:95758:1 bp := tls.Alloc(52) defer tls.Free(52) - var rc int32 = 0 + var rc int32 = SQLITE_OK var rc2 int32 var iStart I64 = (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff - var pOut uintptr = ((pIncr + 40 /* &.aFile */) + uintptr(1)*16) + var pOut uintptr = ((pIncr + 40 /* &.aFile */) + 1*16) var pTask uintptr = (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask var pMerger uintptr = (*IncrMerger)(unsafe.Pointer(pIncr)).FpMerger // var writer PmaWriter at bp, 48 vdbePmaWriterInit(tls, (*SorterFile)(unsafe.Pointer(pOut)).FpFd, bp /* &writer */, (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fpgsz, iStart) - for rc == 0 { + for rc == SQLITE_OK { // var dummy int32 at bp+48, 4 - var pReader uintptr = ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + uintptr(1)*4)))*80) + var pReader uintptr = ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(pMerger)).FaTree + 1*4)))*80) var nKey int32 = (*PmaReader)(unsafe.Pointer(pReader)).FnKey var iEof I64 = ((*PmaWriter)(unsafe.Pointer(bp /* &writer */)).FiWriteOff + I64((*PmaWriter)(unsafe.Pointer(bp /* &writer */)).FiBufEnd)) @@ -75817,7 +75146,7 @@ func vdbeIncrPopulate(tls *libc.TLS, pIncr uintptr) int32 { /* sqlite3.c:95758:1 } rc2 = vdbePmaWriterFinish(tls, bp /* &writer */, (pOut + 8 /* &.iEof */)) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } @@ -75858,19 +75187,19 @@ func vdbeIncrBgPopulate(tls *libc.TLS, pIncr uintptr) int32 { /* sqlite3.c:95810 // // SQLITE_OK is returned on success, or an SQLite error code otherwise. func vdbeIncrSwap(tls *libc.TLS, pIncr uintptr) int32 { /* sqlite3.c:95834:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { rc = vdbeSorterJoinThread(tls, (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask) - if rc == 0 { - var f0 = *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(0)*16)) - *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(0)*16)) = *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(1)*16)) - *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(1)*16)) = f0 + if rc == SQLITE_OK { + var f0 = *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))) + *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))) = *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + 1*16)) + *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + 1*16)) = f0 } - if rc == 0 { - if (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+uintptr(0)*16)).FiEof == (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff { + if rc == SQLITE_OK { + if (*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))).FiEof == (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff { (*IncrMerger)(unsafe.Pointer(pIncr)).FbEof = 1 } else { rc = vdbeIncrBgPopulate(tls, pIncr) @@ -75878,8 +75207,8 @@ func vdbeIncrSwap(tls *libc.TLS, pIncr uintptr) int32 { /* sqlite3.c:95834:12: * } } else { rc = vdbeIncrPopulate(tls, pIncr) - *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(0)*16)) = *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(1)*16)) - if (*SorterFile)(unsafe.Pointer((pIncr+40 /* &.aFile */)+uintptr(0)*16)).FiEof == (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff { + *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))) = *(*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + 1*16)) + if (*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */))).FiEof == (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff { (*IncrMerger)(unsafe.Pointer(pIncr)).FbEof = 1 } } @@ -75892,7 +75221,7 @@ func vdbeIncrSwap(tls *libc.TLS, pIncr uintptr) int32 { /* sqlite3.c:95834:12: * // If an OOM condition is encountered, return NULL. In this case free the // pMerger argument before returning. func vdbeIncrMergerNew(tls *libc.TLS, pTask uintptr, pMerger uintptr, ppOut uintptr) int32 { /* sqlite3.c:95873:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pIncr uintptr = libc.AssignPtrUintptr(ppOut, func() uintptr { if Xsqlite3FaultSim(tls, 100) != 0 { return uintptr(0) @@ -75911,7 +75240,7 @@ func vdbeIncrMergerNew(tls *libc.TLS, pTask uintptr, pMerger uintptr, ppOut uint *(*I64)(unsafe.Pointer(pTask + 88 /* &.file2 */ + 8 /* &.iEof */)) += (I64((*IncrMerger)(unsafe.Pointer(pIncr)).FmxSz)) } else { vdbeMergeEngineFree(tls, pMerger) - rc = 7 + rc = SQLITE_NOMEM } return rc } @@ -75984,9 +75313,9 @@ func vdbeMergeEngineCompare(tls *libc.TLS, pMerger uintptr, iOut int32) { /* sql // // SQLITE_OK is returned if successful, or an SQLite error code otherwise. func vdbeMergeEngineInit(tls *libc.TLS, pTask uintptr, pMerger uintptr, eMode int32) int32 { /* sqlite3.c:95992:12: */ - var rc int32 = 0 // Return code - var i int32 // For looping over PmaReader objects - var nTree int32 // Number of subtrees to merge + var rc int32 = SQLITE_OK // Return code + var i int32 // For looping over PmaReader objects + var nTree int32 // Number of subtrees to merge // Failure to allocate the merge would have been detected prior to // invoking this routine @@ -75999,7 +75328,7 @@ func vdbeMergeEngineInit(tls *libc.TLS, pTask uintptr, pMerger uintptr, eMode in nTree = (*MergeEngine)(unsafe.Pointer(pMerger)).FnTree for i = 0; i < nTree; i++ { - if (8 > 0) && (eMode == 2) { + if (SQLITE_MAX_WORKER_THREADS > 0) && (eMode == INCRINIT_ROOT) { // PmaReaders should be normally initialized in order, as if they are // reading from the same temp file this makes for more linear file IO. // However, in the INCRINIT_ROOT case, if PmaReader aReadr[nTask-1] is @@ -76009,9 +75338,9 @@ func vdbeMergeEngineInit(tls *libc.TLS, pTask uintptr, pMerger uintptr, eMode in // better advantage of multi-processor hardware. rc = vdbePmaReaderNext(tls, ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(((nTree-i)-1))*80)) } else { - rc = vdbePmaReaderIncrInit(tls, ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(i)*80), 0) + rc = vdbePmaReaderIncrInit(tls, ((*MergeEngine)(unsafe.Pointer(pMerger)).FaReadr + uintptr(i)*80), INCRINIT_NORMAL) } - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -76054,7 +75383,7 @@ func vdbeMergeEngineInit(tls *libc.TLS, pTask uintptr, pMerger uintptr, eMode in // // SQLITE_OK is returned if successful, or an SQLite error code otherwise. func vdbePmaReaderIncrMergeInit(tls *libc.TLS, pReadr uintptr, eMode int32) int32 { /* sqlite3.c:96068:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pIncr uintptr = (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr var pTask uintptr = (*IncrMerger)(unsafe.Pointer(pIncr)).FpTask var db uintptr = (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb @@ -76066,12 +75395,12 @@ func vdbePmaReaderIncrMergeInit(tls *libc.TLS, pReadr uintptr, eMode int32) int3 // Set up the required files for pIncr. A multi-theaded IncrMerge object // requires two temp files to itself, whereas a single-threaded object // only requires a region of pTask->file2. - if rc == 0 { + if rc == SQLITE_OK { var mxSz int32 = (*IncrMerger)(unsafe.Pointer(pIncr)).FmxSz if (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { - rc = vdbeSorterOpenTempFile(tls, db, int64(mxSz), ((pIncr + 40 /* &.aFile */) + uintptr(0)*16 /* &.pFd */)) - if rc == 0 { - rc = vdbeSorterOpenTempFile(tls, db, int64(mxSz), ((pIncr + 40 /* &.aFile */) + uintptr(1)*16 /* &.pFd */)) + rc = vdbeSorterOpenTempFile(tls, db, int64(mxSz), (pIncr + 40 /* &.aFile */) /* &.pFd */) + if rc == SQLITE_OK { + rc = vdbeSorterOpenTempFile(tls, db, int64(mxSz), ((pIncr + 40 /* &.aFile */) + 1*16 /* &.pFd */)) } } else { if (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd == uintptr(0) { @@ -76079,15 +75408,15 @@ func vdbePmaReaderIncrMergeInit(tls *libc.TLS, pReadr uintptr, eMode int32) int3 rc = vdbeSorterOpenTempFile(tls, db, (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof, (pTask + 88 /* &.file2 */ /* &.pFd */)) (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof = int64(0) } - if rc == 0 { - (*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + uintptr(1)*16)).FpFd = (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd + if rc == SQLITE_OK { + (*SorterFile)(unsafe.Pointer((pIncr + 40 /* &.aFile */) + 1*16)).FpFd = (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FpFd (*IncrMerger)(unsafe.Pointer(pIncr)).FiStartOff = (*SortSubtask)(unsafe.Pointer(pTask)).Ffile2.FiEof *(*I64)(unsafe.Pointer(pTask + 88 /* &.file2 */ + 8 /* &.iEof */)) += (I64(mxSz)) } } } - if (rc == 0) && ((*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0) { + if (rc == SQLITE_OK) && ((*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0) { // Use the current thread to populate aFile[1], even though this // PmaReader is multi-threaded. If this is an INCRINIT_TASK object, // then this function is already running in background thread @@ -76101,7 +75430,7 @@ func vdbePmaReaderIncrMergeInit(tls *libc.TLS, pReadr uintptr, eMode int32) int3 rc = vdbeIncrPopulate(tls, pIncr) } - if (rc == 0) && ((8 == 0) || (eMode != 1)) { + if (rc == SQLITE_OK) && ((SQLITE_MAX_WORKER_THREADS == 0) || (eMode != INCRINIT_TASK)) { rc = vdbePmaReaderNext(tls, pReadr) } @@ -76112,7 +75441,7 @@ func vdbePmaReaderIncrMergeInit(tls *libc.TLS, pReadr uintptr, eMode int32) int3 // background threads. func vdbePmaReaderBgIncrInit(tls *libc.TLS, pCtx uintptr) uintptr { /* sqlite3.c:96135:13: */ var pReader uintptr = pCtx - var pRet uintptr = uintptr(int64(vdbePmaReaderIncrMergeInit(tls, pReader, 1))) + var pRet uintptr = uintptr(int64(vdbePmaReaderIncrMergeInit(tls, pReader, INCRINIT_TASK))) (*SortSubtask)(unsafe.Pointer((*IncrMerger)(unsafe.Pointer((*PmaReader)(unsafe.Pointer(pReader)).FpIncr)).FpTask)).FbDone = 1 return pRet } @@ -76128,7 +75457,7 @@ func vdbePmaReaderBgIncrInit(tls *libc.TLS, pCtx uintptr) uintptr { /* sqlite3.c // using the current thread. func vdbePmaReaderIncrInit(tls *libc.TLS, pReadr uintptr, eMode int32) int32 { /* sqlite3.c:96156:12: */ var pIncr uintptr = (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr // Incremental merger - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code if pIncr != 0 { if (*IncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 { @@ -76160,21 +75489,21 @@ func vdbeMergeEngineLevel0(tls *libc.TLS, pTask uintptr, nPMA int32, piOffset ui var pNew uintptr // Merge engine to return var iOff I64 = *(*I64)(unsafe.Pointer(piOffset)) var i int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK *(*uintptr)(unsafe.Pointer(ppOut)) = libc.AssignUintptr(&pNew, vdbeMergeEngineNew(tls, nPMA)) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } - for i = 0; (i < nPMA) && (rc == 0); i++ { + for i = 0; (i < nPMA) && (rc == SQLITE_OK); i++ { *(*I64)(unsafe.Pointer(bp /* nDummy */)) = int64(0) var pReadr uintptr = ((*MergeEngine)(unsafe.Pointer(pNew)).FaReadr + uintptr(i)*80) rc = vdbePmaReaderInit(tls, pTask, (pTask + 72 /* &.file */), iOff, pReadr, bp /* &nDummy */) iOff = (*PmaReader)(unsafe.Pointer(pReadr)).FiEof } - if rc != 0 { + if rc != SQLITE_OK { vdbeMergeEngineFree(tls, pNew) *(*uintptr)(unsafe.Pointer(ppOut)) = uintptr(0) } @@ -76192,9 +75521,9 @@ func vdbeMergeEngineLevel0(tls *libc.TLS, pTask uintptr, nPMA int32, piOffset ui // nPMA<=65536 -> TreeDepth() == 2 func vdbeSorterTreeDepth(tls *libc.TLS, nPMA int32) int32 { /* sqlite3.c:96225:12: */ var nDepth int32 = 0 - var nDiv I64 = int64(16) + var nDiv I64 = SORTER_MAX_MERGE_COUNT for nDiv < I64(nPMA) { - nDiv = (nDiv * int64(16)) + nDiv = (nDiv * SORTER_MAX_MERGE_COUNT) nDepth++ } return nDepth @@ -76210,7 +75539,7 @@ func vdbeSorterAddToTree(tls *libc.TLS, pTask uintptr, nDepth int32, iSeq int32, bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var nDiv int32 = 1 var i int32 var p uintptr = pRoot @@ -76219,29 +75548,29 @@ func vdbeSorterAddToTree(tls *libc.TLS, pTask uintptr, nDepth int32, iSeq int32, rc = vdbeIncrMergerNew(tls, pTask, pLeaf, bp /* &pIncr */) for i = 1; i < nDepth; i++ { - nDiv = (nDiv * 16) + nDiv = (nDiv * SORTER_MAX_MERGE_COUNT) } - for i = 1; (i < nDepth) && (rc == 0); i++ { - var iIter int32 = ((iSeq / nDiv) % 16) + for i = 1; (i < nDepth) && (rc == SQLITE_OK); i++ { + var iIter int32 = ((iSeq / nDiv) % SORTER_MAX_MERGE_COUNT) var pReadr uintptr = ((*MergeEngine)(unsafe.Pointer(p)).FaReadr + uintptr(iIter)*80) if (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr == uintptr(0) { - var pNew uintptr = vdbeMergeEngineNew(tls, 16) + var pNew uintptr = vdbeMergeEngineNew(tls, SORTER_MAX_MERGE_COUNT) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = vdbeIncrMergerNew(tls, pTask, pNew, (pReadr + 72 /* &.pIncr */)) } } - if rc == 0 { + if rc == SQLITE_OK { p = (*IncrMerger)(unsafe.Pointer((*PmaReader)(unsafe.Pointer(pReadr)).FpIncr)).FpMerger - nDiv = (nDiv / 16) + nDiv = (nDiv / SORTER_MAX_MERGE_COUNT) } } - if rc == 0 { - (*PmaReader)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(p)).FaReadr + uintptr((iSeq%16))*80)).FpIncr = *(*uintptr)(unsafe.Pointer(bp /* pIncr */)) + if rc == SQLITE_OK { + (*PmaReader)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer(p)).FaReadr + uintptr((iSeq%SORTER_MAX_MERGE_COUNT))*80)).FpIncr = *(*uintptr)(unsafe.Pointer(bp /* pIncr */)) } else { vdbeIncrFree(tls, *(*uintptr)(unsafe.Pointer(bp /* pIncr */))) } @@ -76262,7 +75591,7 @@ func vdbeSorterMergeTreeBuild(tls *libc.TLS, pSorter uintptr, ppOut uintptr) int defer tls.Free(24) var pMain uintptr = uintptr(0) - var rc int32 = 0 + var rc int32 = SQLITE_OK var iTask int32 // If the sorter uses more than one task, then create the top-level @@ -76272,45 +75601,45 @@ func vdbeSorterMergeTreeBuild(tls *libc.TLS, pSorter uintptr, ppOut uintptr) int if int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) > 1 { pMain = vdbeMergeEngineNew(tls, int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)) if pMain == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } } - for iTask = 0; (rc == 0) && (iTask < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)); iTask++ { + for iTask = 0; (rc == SQLITE_OK) && (iTask < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)); iTask++ { var pTask uintptr = ((pSorter + 96 /* &.aTask */) + uintptr(iTask)*104) - if (8 == 0) || ((*SortSubtask)(unsafe.Pointer(pTask)).FnPMA != 0) { + if (SQLITE_MAX_WORKER_THREADS == 0) || ((*SortSubtask)(unsafe.Pointer(pTask)).FnPMA != 0) { *(*uintptr)(unsafe.Pointer(bp + 8 /* pRoot */)) = uintptr(0) // Root node of tree for this task var nDepth int32 = vdbeSorterTreeDepth(tls, (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA) *(*I64)(unsafe.Pointer(bp /* iReadOff */)) = int64(0) - if (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA <= 16 { + if (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA <= SORTER_MAX_MERGE_COUNT { rc = vdbeMergeEngineLevel0(tls, pTask, (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA, bp /* &iReadOff */, bp+8 /* &pRoot */) } else { var i int32 var iSeq int32 = 0 - *(*uintptr)(unsafe.Pointer(bp + 8 /* pRoot */)) = vdbeMergeEngineNew(tls, 16) + *(*uintptr)(unsafe.Pointer(bp + 8 /* pRoot */)) = vdbeMergeEngineNew(tls, SORTER_MAX_MERGE_COUNT) if *(*uintptr)(unsafe.Pointer(bp + 8 /* pRoot */)) == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } - for i = 0; (i < (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA) && (rc == 0); i = i + (16) { + for i = 0; (i < (*SortSubtask)(unsafe.Pointer(pTask)).FnPMA) && (rc == SQLITE_OK); i = i + (SORTER_MAX_MERGE_COUNT) { *(*uintptr)(unsafe.Pointer(bp + 16 /* pMerger */)) = uintptr(0) // New level-0 PMA merger var nReader int32 // Number of level-0 PMAs to merge nReader = func() int32 { - if ((*SortSubtask)(unsafe.Pointer(pTask)).FnPMA - i) < (16) { + if ((*SortSubtask)(unsafe.Pointer(pTask)).FnPMA - i) < (SORTER_MAX_MERGE_COUNT) { return ((*SortSubtask)(unsafe.Pointer(pTask)).FnPMA - i) } - return 16 + return SORTER_MAX_MERGE_COUNT }() rc = vdbeMergeEngineLevel0(tls, pTask, nReader, bp /* &iReadOff */, bp+16 /* &pMerger */) - if rc == 0 { + if rc == SQLITE_OK { rc = vdbeSorterAddToTree(tls, pTask, nDepth, libc.PostIncInt32(&iSeq, 1), *(*uintptr)(unsafe.Pointer(bp + 8 /* pRoot */)), *(*uintptr)(unsafe.Pointer(bp + 16 /* pMerger */))) } } } - if rc == 0 { + if rc == SQLITE_OK { if pMain != uintptr(0) { rc = vdbeIncrMergerNew(tls, pTask, *(*uintptr)(unsafe.Pointer(bp + 8 /* pRoot */)), ((*MergeEngine)(unsafe.Pointer(pMain)).FaReadr + uintptr(iTask)*80 + 72 /* &.pIncr */)) } else { @@ -76323,7 +75652,7 @@ func vdbeSorterMergeTreeBuild(tls *libc.TLS, pSorter uintptr, ppOut uintptr) int } } - if rc != 0 { + if rc != SQLITE_OK { vdbeMergeEngineFree(tls, pMain) pMain = uintptr(0) } @@ -76343,7 +75672,7 @@ func vdbeSorterSetupMerge(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:9 defer tls.Free(8) var rc int32 // Return code - var pTask0 uintptr = ((pSorter + 96 /* &.aTask */) + uintptr(0)*104) + var pTask0 uintptr = (pSorter + 96 /* &.aTask */) *(*uintptr)(unsafe.Pointer(bp /* pMain */)) = uintptr(0) var db uintptr = (*VdbeSorter)(unsafe.Pointer((*SortSubtask)(unsafe.Pointer(pTask0)).FpSorter)).Fdb var i int32 @@ -76353,23 +75682,23 @@ func vdbeSorterSetupMerge(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:9 } rc = vdbeSorterMergeTreeBuild(tls, pSorter, bp /* &pMain */) - if rc == 0 { + if rc == SQLITE_OK { if (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads != 0 { var iTask int32 var pReadr uintptr = uintptr(0) var pLast uintptr = ((pSorter + 96 /* &.aTask */) + uintptr((int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)-1))*104) rc = vdbeSortAllocUnpacked(tls, pLast) - if rc == 0 { + if rc == SQLITE_OK { pReadr = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(PmaReader{}))) (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader = pReadr if pReadr == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } } - if rc == 0 { + if rc == SQLITE_OK { rc = vdbeIncrMergerNew(tls, pLast, *(*uintptr)(unsafe.Pointer(bp /* pMain */)), (pReadr + 72 /* &.pIncr */)) - if rc == 0 { + if rc == SQLITE_OK { vdbeIncrMergerSetThreads(tls, (*PmaReader)(unsafe.Pointer(pReadr)).FpIncr) for iTask = 0; iTask < (int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask) - 1); iTask++ { var pIncr uintptr @@ -76378,7 +75707,7 @@ func vdbeSorterSetupMerge(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:9 } } - for iTask = 0; (rc == 0) && (iTask < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)); iTask++ { + for iTask = 0; (rc == SQLITE_OK) && (iTask < int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FnTask)); iTask++ { // Check that: // // a) The incremental merge object is configured to use the @@ -76389,22 +75718,22 @@ func vdbeSorterSetupMerge(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:9 // object. var p uintptr = ((*MergeEngine)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pMain */)))).FaReadr + uintptr(iTask)*80) - rc = vdbePmaReaderIncrInit(tls, p, 1) + rc = vdbePmaReaderIncrInit(tls, p, INCRINIT_TASK) } } *(*uintptr)(unsafe.Pointer(bp /* pMain */)) = uintptr(0) } - if rc == 0 { - rc = vdbePmaReaderIncrMergeInit(tls, pReadr, 2) + if rc == SQLITE_OK { + rc = vdbePmaReaderIncrMergeInit(tls, pReadr, INCRINIT_ROOT) } } else { - rc = vdbeMergeEngineInit(tls, pTask0, *(*uintptr)(unsafe.Pointer(bp /* pMain */)), 0) + rc = vdbeMergeEngineInit(tls, pTask0, *(*uintptr)(unsafe.Pointer(bp /* pMain */)), INCRINIT_NORMAL) (*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger = *(*uintptr)(unsafe.Pointer(bp /* pMain */)) *(*uintptr)(unsafe.Pointer(bp /* pMain */)) = uintptr(0) } } - if rc != 0 { + if rc != SQLITE_OK { vdbeMergeEngineFree(tls, *(*uintptr)(unsafe.Pointer(bp /* pMain */))) } return rc @@ -76415,7 +75744,7 @@ func vdbeSorterSetupMerge(tls *libc.TLS, pSorter uintptr) int32 { /* sqlite3.c:9 // in sorted order. func Xsqlite3VdbeSorterRewind(tls *libc.TLS, pCsr uintptr, pbEof uintptr) int32 { /* sqlite3.c:96460:20: */ var pSorter uintptr - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 56 /* &.uc */)) @@ -76425,7 +75754,7 @@ func Xsqlite3VdbeSorterRewind(tls *libc.TLS, pCsr uintptr, pbEof uintptr) int32 if int32((*VdbeSorter)(unsafe.Pointer(pSorter)).FbUsePMA) == 0 { if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 { *(*int32)(unsafe.Pointer(pbEof)) = 0 - rc = vdbeSorterSort(tls, ((pSorter + 96 /* &.aTask */) + uintptr(0)*104), (pSorter + 56 /* &.list */)) + rc = vdbeSorterSort(tls, (pSorter + 96 /* &.aTask */), (pSorter + 56 /* &.list */)) } else { *(*int32)(unsafe.Pointer(pbEof)) = 1 } @@ -76445,7 +75774,7 @@ func Xsqlite3VdbeSorterRewind(tls *libc.TLS, pCsr uintptr, pbEof uintptr) int32 // Assuming no errors have occurred, set up a merger structure to // incrementally read and merge all remaining PMAs. - if rc == 0 { + if rc == SQLITE_OK { rc = vdbeSorterSetupMerge(tls, pSorter) *(*int32)(unsafe.Pointer(pbEof)) = 0 } @@ -76471,15 +75800,15 @@ func Xsqlite3VdbeSorterNext(tls *libc.TLS, db uintptr, pCsr uintptr) int32 { /* if (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads != 0 { rc = vdbePmaReaderNext(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader) - if (rc == 0) && ((*PmaReader)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader)).FpFd == uintptr(0)) { - rc = 101 + if (rc == SQLITE_OK) && ((*PmaReader)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader)).FpFd == uintptr(0)) { + rc = SQLITE_DONE } } else { *(*int32)(unsafe.Pointer(bp /* res */)) = 0 rc = vdbeMergeEngineStep(tls, (*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger, bp /* &res */) - if (rc == 0) && (*(*int32)(unsafe.Pointer(bp /* res */)) != 0) { - rc = 101 + if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* res */)) != 0) { + rc = SQLITE_DONE } } } else { @@ -76490,9 +75819,9 @@ func Xsqlite3VdbeSorterNext(tls *libc.TLS, db uintptr, pCsr uintptr) int32 { /* vdbeSorterRecordFree(tls, db, pFree) } if (*VdbeSorter)(unsafe.Pointer(pSorter)).Flist.FpList != 0 { - rc = 0 + rc = SQLITE_OK } else { - rc = 101 + rc = SQLITE_DONE } } return rc @@ -76507,7 +75836,7 @@ func vdbeSorterRowkey(tls *libc.TLS, pSorter uintptr, pnKey uintptr) uintptr { / if (*VdbeSorter)(unsafe.Pointer(pSorter)).FbUseThreads != 0 { pReader = (*VdbeSorter)(unsafe.Pointer(pSorter)).FpReader } else { - pReader = ((*MergeEngine)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)).FaTree + uintptr(1)*4)))*80) + pReader = ((*MergeEngine)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)).FaReadr + uintptr(*(*int32)(unsafe.Pointer((*MergeEngine)(unsafe.Pointer((*VdbeSorter)(unsafe.Pointer(pSorter)).FpMerger)).FaTree + 1*4)))*80) } *(*int32)(unsafe.Pointer(pnKey)) = (*PmaReader)(unsafe.Pointer(pReader)).FnKey pKey = (*PmaReader)(unsafe.Pointer(pReader)).FaKey @@ -76531,13 +75860,13 @@ func Xsqlite3VdbeSorterRowkey(tls *libc.TLS, pCsr uintptr, pOut uintptr) int32 { pSorter = *(*uintptr)(unsafe.Pointer(pCsr + 56 /* &.uc */)) pKey = vdbeSorterRowkey(tls, pSorter, bp /* &nKey */) if Xsqlite3VdbeMemClearAndResize(tls, pOut, *(*int32)(unsafe.Pointer(bp /* nKey */))) != 0 { - return 7 + return SQLITE_NOMEM } (*Mem)(unsafe.Pointer(pOut)).Fn = *(*int32)(unsafe.Pointer(bp /* nKey */)) - (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & ^libc.Int32((0xc1bf | 0x4000))) | 0x0010)) + (*Mem)(unsafe.Pointer(pOut)).Fflags = (U16((int32((*Mem)(unsafe.Pointer((pOut))).Fflags) & libc.CplInt32((MEM_TypeMask | MEM_Zero))) | MEM_Blob)) libc.Xmemcpy(tls, (*Mem)(unsafe.Pointer(pOut)).Fz, pKey, uint64(*(*int32)(unsafe.Pointer(bp /* nKey */)))) - return 0 + return SQLITE_OK } // Compare the key in memory cell pVal with the key that the sorter cursor @@ -76572,7 +75901,7 @@ func Xsqlite3VdbeSorterCompare(tls *libc.TLS, pCsr uintptr, pVal uintptr, nKeyCo if r2 == uintptr(0) { r2 = libc.AssignPtrUintptr(pSorter+48 /* &.pUnpacked */, Xsqlite3VdbeAllocUnpackedRecord(tls, pKeyInfo)) if r2 == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*UnpackedRecord)(unsafe.Pointer(r2)).FnField = U16(nKeyCol) } @@ -76580,14 +75909,14 @@ func Xsqlite3VdbeSorterCompare(tls *libc.TLS, pCsr uintptr, pVal uintptr, nKeyCo pKey = vdbeSorterRowkey(tls, pSorter, bp /* &nKey */) Xsqlite3VdbeRecordUnpack(tls, pKeyInfo, *(*int32)(unsafe.Pointer(bp /* nKey */)), pKey, r2) for i = 0; i < nKeyCol; i++ { - if (int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(r2)).FaMem+uintptr(i)*56)).Fflags) & 0x0001) != 0 { + if (int32((*Mem)(unsafe.Pointer((*UnpackedRecord)(unsafe.Pointer(r2)).FaMem+uintptr(i)*56)).Fflags) & MEM_Null) != 0 { *(*int32)(unsafe.Pointer(pRes)) = -1 - return 0 + return SQLITE_OK } } *(*int32)(unsafe.Pointer(pRes)) = Xsqlite3VdbeRecordCompare(tls, (*Mem)(unsafe.Pointer(pVal)).Fn, (*Mem)(unsafe.Pointer(pVal)).Fz, r2) - return 0 + return SQLITE_OK } //************* End of vdbesort.c ******************************************* @@ -76675,11 +76004,11 @@ func bytecodevtabConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, ar } rc = Xsqlite3_declare_vtab(tls, db, *(*uintptr)(unsafe.Pointer(bp /* &azSchema[0] */ + uintptr(isTabUsed)*8))) - if rc == 0 { + if rc == SQLITE_OK { pNew = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Bytecodevtab{}))) *(*uintptr)(unsafe.Pointer(ppVtab)) = pNew if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(Bytecodevtab{}))) (*Bytecodevtab)(unsafe.Pointer(pNew)).Fdb = db @@ -76692,7 +76021,7 @@ func bytecodevtabConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, ar func bytecodevtabDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:96748:12: */ var p uintptr = pVtab Xsqlite3_free(tls, p) - return 0 + return SQLITE_OK } // Constructor for a new bytecodevtab_cursor object. @@ -76701,12 +76030,12 @@ func bytecodevtabOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* sql var pCur uintptr pCur = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Bytecodevtab_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(Bytecodevtab_cursor{}))) Xsqlite3VdbeMemInit(tls, (pCur + 72 /* &.sub */), (*Bytecodevtab)(unsafe.Pointer(pVTab)).Fdb, uint16(1)) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Clear all internal content from a bytecodevtab cursor. @@ -76730,7 +76059,7 @@ func bytecodevtabClose(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:96789:12 var pCur uintptr = cur bytecodevtabCursorClear(tls, pCur) Xsqlite3_free(tls, pCur) - return 0 + return SQLITE_OK } // Advance a bytecodevtab_cursor to its next row of output. @@ -76759,11 +76088,11 @@ func bytecodevtabNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:96800:12: (pCur + 16 /* &.iRowid */), (pCur + 20 /* &.iAddr */), (pCur + 32 /* &.aOp */)) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3VdbeMemSetNull(tls, (pCur + 72 /* &.sub */)) (*Bytecodevtab_cursor)(unsafe.Pointer(pCur)).FaOp = uintptr(0) } - return 0 + return SQLITE_OK } // Return TRUE if the cursor has been moved off of the last @@ -76851,8 +76180,8 @@ func bytecodevtabColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 if (*Bytecodevtab_cursor)(unsafe.Pointer(pCur)).FiRowid == ((*Bytecodevtab_cursor)(unsafe.Pointer(pCur)).FiAddr + 1) { break // Result is NULL for the main program - } else if *(*uintptr)(unsafe.Pointer(aOp + uintptr(0)*32 + 16 /* &.p4 */)) != uintptr(0) { - Xsqlite3_result_text(tls, ctx, (*(*uintptr)(unsafe.Pointer(aOp + uintptr(0)*32 + 16 /* &.p4 */)) + uintptr(3)), -1, uintptr(0)) + } else if *(*uintptr)(unsafe.Pointer(aOp + 16 /* &.p4 */)) != uintptr(0) { + Xsqlite3_result_text(tls, ctx, (*(*uintptr)(unsafe.Pointer(aOp + 16 /* &.p4 */)) + uintptr(3)), -1, uintptr(0)) } else { Xsqlite3_result_text(tls, ctx, ts+8248 /* "(FK)" */, 4, uintptr(0)) } @@ -76869,10 +76198,10 @@ func bytecodevtabColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 Xsqlite3_result_text(tls, ctx, (*Bytecodevtab_cursor)(unsafe.Pointer(pCur)).FzName, -1, uintptr(0)) break case 13: // tables_used.wr - Xsqlite3_result_int(tls, ctx, (libc.Bool32(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == 97))) + Xsqlite3_result_int(tls, ctx, (libc.Bool32(int32((*Op)(unsafe.Pointer(pOp)).Fopcode) == OP_OpenWrite))) break } - return 0 + return SQLITE_OK } // Return the rowid for the current row. In this implementation, the @@ -76880,7 +76209,7 @@ func bytecodevtabColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 func bytecodevtabRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* sqlite3.c:96948:12: */ var pCur uintptr = cur *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = Sqlite_int64((*Bytecodevtab_cursor)(unsafe.Pointer(pCur)).FiRowid) - return 0 + return SQLITE_OK } // Initialize a cursor. @@ -76893,23 +76222,23 @@ func bytecodevtabFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr var pCur uintptr = pVtabCursor var pVTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab - var rc int32 = 0 + var rc int32 = SQLITE_OK bytecodevtabCursorClear(tls, pCur) (*Bytecodevtab_cursor)(unsafe.Pointer(pCur)).FiRowid = 0 (*Bytecodevtab_cursor)(unsafe.Pointer(pCur)).FiAddr = 0 (*Bytecodevtab_cursor)(unsafe.Pointer(pCur)).FshowSubprograms = (libc.Bool32(idxNum == 0)) - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 3 { - var zSql uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_TEXT { + var zSql uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_prepare_v2(tls, (*Bytecodevtab)(unsafe.Pointer(pVTab)).Fdb, zSql, -1, (pCur + 8 /* &.pStmt */), uintptr(0)) (*Bytecodevtab_cursor)(unsafe.Pointer(pCur)).FneedFinalize = 1 } } else { - (*Bytecodevtab_cursor)(unsafe.Pointer(pCur)).FpStmt = Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), ts+8253 /* "stmt-pointer" */) + (*Bytecodevtab_cursor)(unsafe.Pointer(pCur)).FpStmt = Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(argv)), ts+8253 /* "stmt-pointer" */) } if (*Bytecodevtab_cursor)(unsafe.Pointer(pCur)).FpStmt == uintptr(0) { (*Bytecodevtab)(unsafe.Pointer(pVTab)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, @@ -76920,7 +76249,7 @@ func bytecodevtabFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr } return ts + 8324 /* "bytecode" */ }())) - rc = 1 + rc = SQLITE_ERROR } else { bytecodevtabNext(tls, pVtabCursor) } @@ -76932,7 +76261,7 @@ func bytecodevtabFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr // then return an SQLITE_CONSTRAINT error. func bytecodevtabBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sqlite3.c:97002:12: */ var i int32 - var rc int32 = 19 + var rc int32 = SQLITE_CONSTRAINT var p uintptr var pVTab uintptr = tab var iBaseCol int32 @@ -76954,12 +76283,12 @@ __1: if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) == 0 { goto __2 } - if (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == (iBaseCol + 1)) { - rc = 0 + if (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == (iBaseCol + 1)) { + rc = SQLITE_OK (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 } - if (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 71) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == iBaseCol) { + if (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_ISNULL) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == iBaseCol) { (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1 } @@ -76979,54 +76308,16 @@ __3: // This following structure defines all the methods for the // virtual table. var bytecodevtabModule = Sqlite3_module{ - FiVersion: - /* iVersion */ 0, - FxCreate: - /* xCreate */ uintptr(0), - FxConnect: - /* xConnect */ 0, - FxBestIndex: - /* xBestIndex */ 0, - FxDisconnect: - /* xDisconnect */ 0, - FxDestroy: - /* xDestroy */ uintptr(0), - FxOpen: - /* xOpen */ 0, - FxClose: - /* xClose */ 0, - FxFilter: - /* xFilter */ 0, - FxNext: - /* xNext */ 0, - FxEof: - /* xEof */ 0, - FxColumn: - /* xColumn */ 0, - FxRowid: - /* xRowid */ 0, - FxUpdate: - /* xUpdate */ uintptr(0), - FxBegin: - /* xBegin */ uintptr(0), - FxSync: - /* xSync */ uintptr(0), - FxCommit: - /* xCommit */ uintptr(0), - FxRollback: - /* xRollback */ uintptr(0), - FxFindFunction: - /* xFindMethod */ uintptr(0), - FxRename: - /* xRename */ uintptr(0), - FxSavepoint: - /* xSavepoint */ uintptr(0), - FxRelease: - /* xRelease */ uintptr(0), - FxRollbackTo: - /* xRollbackTo */ uintptr(0), - FxShadowName: - /* xShadowName */ uintptr(0), + /* xConnect */ FxConnect: 0, + /* xBestIndex */ FxBestIndex: 0, + /* xDisconnect */ FxDisconnect: 0, + /* xOpen */ FxOpen: 0, + /* xClose */ FxClose: 0, + /* xFilter */ FxFilter: 0, + /* xNext */ FxNext: 0, + /* xEof */ FxEof: 0, + /* xColumn */ FxColumn: 0, + /* xRowid */ FxRowid: 0, } /* sqlite3.c:97033:23 */ func Xsqlite3VdbeBytecodeVtabInit(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:97061:20: */ @@ -77036,7 +76327,7 @@ func Xsqlite3VdbeBytecodeVtabInit(tls *libc.TLS, db uintptr) int32 { /* sqlite3. var rc int32 rc = Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+8324 /* "bytecode" */, uintptr(unsafe.Pointer(&bytecodevtabModule)), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+8312 /* "tables_used" */, uintptr(unsafe.Pointer(&bytecodevtabModule)), bp /* &db */) } return rc @@ -77137,7 +76428,7 @@ func memjrnlRead(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst Sq var pChunk uintptr if (Sqlite_int64(iAmt) + iOfst) > (*MemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset { - return (10 | (int32(2) << 8)) + return (SQLITE_IOERR | (int32(2) << 8)) } if ((*MemJournal)(unsafe.Pointer(p)).Freadpoint.FiOffset != iOfst) || (iOfst == int64(0)) { @@ -77172,7 +76463,7 @@ func memjrnlRead(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst Sq }() (*MemJournal)(unsafe.Pointer(p)).Freadpoint.FpChunk = pChunk - return 0 + return SQLITE_OK } // Free the list of FileChunk structures headed at MemJournal.pFirst. @@ -77197,7 +76488,7 @@ func memjrnlCreateFile(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:97221:12: libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(MemJournal{}))) rc = Xsqlite3OsOpen(tls, (*MemJournal)(unsafe.Pointer(bp /* © */)).FpVfs, (*MemJournal)(unsafe.Pointer(bp /* © */)).FzJournal, pReal, (*MemJournal)(unsafe.Pointer(bp /* © */)).Fflags, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { var nChunk int32 = (*MemJournal)(unsafe.Pointer(bp /* © */)).FnChunkSize var iOff I64 = int64(0) var pIter uintptr @@ -77211,12 +76502,12 @@ func memjrnlCreateFile(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:97221:12: } iOff = iOff + (I64(nChunk)) } - if rc == 0 { + if rc == SQLITE_OK { // No error has occurred. Free the in-memory buffers. memjrnlFreeChunks(tls, bp /* © */) } } - if rc != 0 { + if rc != SQLITE_OK { // If an error occurred while creating or writing to the file, restore // the original before returning. This way, SQLite uses the in-memory // journal data to roll back changes made to the internal page-cache @@ -77237,7 +76528,7 @@ func memjrnlWrite(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst S // into the file on disk. if ((*MemJournal)(unsafe.Pointer(p)).FnSpill > 0) && ((Sqlite_int64(iAmt) + iOfst) > Sqlite_int64((*MemJournal)(unsafe.Pointer(p)).FnSpill)) { var rc int32 = memjrnlCreateFile(tls, p) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3OsWrite(tls, pJfd, zBuf, iAmt, iOfst) } return rc @@ -77263,7 +76554,7 @@ func memjrnlWrite(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst S // New chunk is required to extend the file. var pNew uintptr = Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(FileChunk{})) + (uint64(((*MemJournal)(unsafe.Pointer(p)).FnChunkSize) - 8))))) if !(pNew != 0) { - return (10 | (int32(12) << 8)) + return (SQLITE_IOERR | (int32(12) << 8)) } (*FileChunk)(unsafe.Pointer(pNew)).FpNext = uintptr(0) if pChunk != 0 { @@ -77286,7 +76577,7 @@ func memjrnlWrite(tls *libc.TLS, pJfd uintptr, zBuf uintptr, iAmt int32, iOfst S } } - return 0 + return SQLITE_OK } // Truncate the file. @@ -77304,14 +76595,14 @@ func memjrnlTruncate(tls *libc.TLS, pJfd uintptr, size Sqlite_int64) int32 { /* (*MemJournal)(unsafe.Pointer(p)).Freadpoint.FpChunk = uintptr(0) (*MemJournal)(unsafe.Pointer(p)).Freadpoint.FiOffset = int64(0) } - return 0 + return SQLITE_OK } // Close the file. func memjrnlClose(tls *libc.TLS, pJfd uintptr) int32 { /* sqlite3.c:97355:12: */ var p uintptr = pJfd memjrnlFreeChunks(tls, p) - return 0 + return SQLITE_OK } // Sync the file. @@ -77321,55 +76612,25 @@ func memjrnlClose(tls *libc.TLS, pJfd uintptr) int32 { /* sqlite3.c:97355:12: */ func memjrnlSync(tls *libc.TLS, pJfd uintptr, flags int32) int32 { /* sqlite3.c:97367:12: */ _ = pJfd _ = flags - return 0 + return SQLITE_OK } // Query the size of the file in bytes. func memjrnlFileSize(tls *libc.TLS, pJfd uintptr, pSize uintptr) int32 { /* sqlite3.c:97375:12: */ var p uintptr = pJfd *(*Sqlite_int64)(unsafe.Pointer(pSize)) = (*MemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset - return 0 + return SQLITE_OK } // Table of methods for MemJournal sqlite3_file object. var sMemJournalMethods = sqlite3_io_methods{ - FiVersion: 1, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - uintptr(0), - FxUnlock:// xLock - uintptr(0), - FxCheckReservedLock:// xUnlock - uintptr(0), - FxFileControl:// xCheckReservedLock - uintptr(0), - FxSectorSize:// xFileControl - uintptr(0), - FxDeviceCharacteristics:// xSectorSize - uintptr(0), - FxShmMap:// xDeviceCharacteristics - uintptr(0), - FxShmLock:// xShmMap - uintptr(0), - FxShmBarrier:// xShmLock - uintptr(0), - FxShmUnmap:// xShmBarrier - uintptr(0), - FxFetch:// xShmUnmap - uintptr(0), - FxUnfetch:// xFetch - uintptr(0), // xUnfetch + FiVersion: 1, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xUnfetch } /* sqlite3.c:97384:40 */ // Open a journal file. @@ -77397,7 +76658,7 @@ func Xsqlite3JournalOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pJfd uintpt if nSpill > 0 { (*MemJournal)(unsafe.Pointer(p)).FnChunkSize = nSpill } else { - (*MemJournal)(unsafe.Pointer(p)).FnChunkSize = (int32((uint64(8 + 1024)) - uint64(unsafe.Sizeof(FileChunk{})))) + (*MemJournal)(unsafe.Pointer(p)).FnChunkSize = (int32((uint64(8 + MEMJOURNAL_DFLT_FILECHUNKSIZE)) - uint64(unsafe.Sizeof(FileChunk{})))) } @@ -77406,7 +76667,7 @@ func Xsqlite3JournalOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pJfd uintpt (*MemJournal)(unsafe.Pointer(p)).Fflags = flags (*MemJournal)(unsafe.Pointer(p)).FzJournal = zName (*MemJournal)(unsafe.Pointer(p)).FpVfs = pVfs - return 0 + return SQLITE_OK } // Open an in-memory journal file. @@ -77458,15 +76719,15 @@ func walkWindowList(tls *libc.TLS, pWalker uintptr, pList uintptr) int32 { /* sq var rc int32 rc = Xsqlite3WalkExprList(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpOrderBy) if rc != 0 { - return 2 + return WRC_Abort } rc = Xsqlite3WalkExprList(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpPartition) if rc != 0 { - return 2 + return WRC_Abort } rc = Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpFilter) if rc != 0 { - return 2 + return WRC_Abort } // The next two are purely for calls to sqlite3RenameExprUnmap() @@ -77475,14 +76736,14 @@ func walkWindowList(tls *libc.TLS, pWalker uintptr, pList uintptr) int32 { /* sq // not matter anyhow. rc = Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpStart) if rc != 0 { - return 2 + return WRC_Abort } rc = Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpEnd) if rc != 0 { - return 2 + return WRC_Abort } } - return 0 + return WRC_Continue } // Walk an expression tree. Invoke the callback once for each node @@ -77508,45 +76769,45 @@ func walkExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3. for 1 != 0 { rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pWalker + 8 /* &.xExprCallback */))))(tls, pWalker, pExpr) if rc != 0 { - return (rc & 2) + return (rc & WRC_Abort) } - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x004000 | 0x800000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_TokenOnly | EP_Leaf))) != U32(0)) { if ((*Expr)(unsafe.Pointer(pExpr)).FpLeft != 0) && (walkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) != 0) { - return 2 + return WRC_Abort } if (*Expr)(unsafe.Pointer(pExpr)).FpRight != 0 { pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpRight continue - } else if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + } else if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { if Xsqlite3WalkSelect(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) != 0 { - return 2 + return WRC_Abort } } else { if *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) != 0 { if Xsqlite3WalkExprList(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) != 0 { - return 2 + return WRC_Abort } } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { if walkWindowList(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */))) != 0 { - return 2 + return WRC_Abort } } } } break } - return 0 + return WRC_Continue } func Xsqlite3WalkExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:97606:20: */ if pExpr != 0 { return walkExpr(tls, pWalker, pExpr) } - return 0 + return WRC_Continue } // Call sqlite3WalkExpr() for every expression in list p or until @@ -77563,7 +76824,7 @@ func Xsqlite3WalkExprList(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* } { if Xsqlite3WalkExpr(tls, pWalker, (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr) != 0 { - return 2 + return WRC_Abort } } @@ -77575,7 +76836,7 @@ func Xsqlite3WalkExprList(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* goto __3 __3: } - return 0 + return WRC_Continue } // Walk all expressions associated with SELECT statement p. Do @@ -77584,26 +76845,26 @@ func Xsqlite3WalkExprList(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* // Return WRC_Abort or WRC_Continue. func Xsqlite3WalkSelectExpr(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sqlite3.c:97631:20: */ if Xsqlite3WalkExprList(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpEList) != 0 { - return 2 + return WRC_Abort } if Xsqlite3WalkExpr(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpWhere) != 0 { - return 2 + return WRC_Abort } if Xsqlite3WalkExprList(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpGroupBy) != 0 { - return 2 + return WRC_Abort } if Xsqlite3WalkExpr(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpHaving) != 0 { - return 2 + return WRC_Abort } if Xsqlite3WalkExprList(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpOrderBy) != 0 { - return 2 + return WRC_Abort } if Xsqlite3WalkExpr(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpLimit) != 0 { - return 2 + return WRC_Abort } { var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse - if (pParse != 0) && (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if (pParse != 0) && (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { // The following may return WRC_Abort if there are unresolvable // symbols (e.g. a table that does not exist) in a window definition. var rc int32 = walkWindowList(tls, pWalker, (*Select)(unsafe.Pointer(p)).FpWinDefn) @@ -77611,7 +76872,7 @@ func Xsqlite3WalkSelectExpr(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { / } } - return 0 + return WRC_Continue } // Walk the parse trees associated with all subqueries in the @@ -77634,11 +76895,11 @@ func Xsqlite3WalkSelectFrom(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { / } { if ((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect != 0) && (Xsqlite3WalkSelect(tls, pWalker, (*SrcList_item)(unsafe.Pointer(pItem)).FpSelect) != 0) { - return 2 + return WRC_Abort } if ((uint32(int32(*(*uint8)(unsafe.Pointer((pItem + 60 /* &.fg */) + 4 /* &.isTabFunc */)) & 0x4 >> 2))) != 0) && (Xsqlite3WalkExprList(tls, pWalker, *(*uintptr)(unsafe.Pointer(pItem + 96 /* &.u1 */))) != 0) { - return 2 + return WRC_Abort } } @@ -77650,7 +76911,7 @@ func Xsqlite3WalkSelectFrom(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { / goto __3 __3: } - return 0 + return WRC_Continue } // Call sqlite3WalkExpr() for every expression in Select statement p. @@ -77671,26 +76932,26 @@ func Xsqlite3WalkSelectFrom(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { / func Xsqlite3WalkSelect(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sqlite3.c:97697:20: */ var rc int32 if p == uintptr(0) { - return 0 + return WRC_Continue } if (*Walker)(unsafe.Pointer(pWalker)).FxSelectCallback == uintptr(0) { - return 0 + return WRC_Continue } for ok := true; ok; ok = (p != uintptr(0)) { rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pWalker + 16 /* &.xSelectCallback */))))(tls, pWalker, p) if rc != 0 { - return (rc & 2) + return (rc & WRC_Abort) } if (Xsqlite3WalkSelectExpr(tls, pWalker, p) != 0) || (Xsqlite3WalkSelectFrom(tls, pWalker, p) != 0) { - return 2 + return WRC_Abort } if (*Walker)(unsafe.Pointer(pWalker)).FxSelectCallback2 != 0 { (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer((pWalker + 24 /* &.xSelectCallback2 */))))(tls, pWalker, p) } p = (*Select)(unsafe.Pointer(p)).FpPrior } - return 0 + return WRC_Continue } // Increase the walkerDepth when entering a subquery, and @@ -77698,7 +76959,7 @@ func Xsqlite3WalkSelect(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sq func Xsqlite3WalkerDepthIncrease(tls *libc.TLS, pWalker uintptr, pSelect uintptr) int32 { /* sqlite3.c:97720:20: */ _ = pSelect (*Walker)(unsafe.Pointer(pWalker)).FwalkerDepth++ - return 0 + return WRC_Continue } func Xsqlite3WalkerDepthDecrease(tls *libc.TLS, pWalker uintptr, pSelect uintptr) { /* sqlite3.c:97725:21: */ @@ -77716,7 +76977,7 @@ func Xsqlite3WalkerDepthDecrease(tls *libc.TLS, pWalker uintptr, pSelect uintptr func Xsqlite3ExprWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) int32 { /* sqlite3.c:97740:20: */ _ = NotUsed _ = NotUsed2 - return 0 + return WRC_Continue } // No-op routine for the parse-tree walker for SELECT statements. @@ -77724,7 +76985,7 @@ func Xsqlite3ExprWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) int3 func Xsqlite3SelectWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) int32 { /* sqlite3.c:97749:20: */ _ = NotUsed _ = NotUsed2 - return 0 + return WRC_Continue } //************* End of walker.c ********************************************* @@ -77757,10 +77018,10 @@ func Xsqlite3SelectWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) in // // See also the sqlite3WindowExtraAggFuncDepth() routine in window.c func incrAggDepth(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:97790:12: */ - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 165 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_FUNCTION { *(*U8)(unsafe.Pointer(pExpr + 2 /* &.op2 */)) += U8((*(*int32)(unsafe.Pointer(pWalker + 40 /* &.u */)))) } - return 0 + return WRC_Continue } func incrAggFunctionDepth(tls *libc.TLS, pExpr uintptr, N int32) { /* sqlite3.c:97794:13: */ @@ -77806,10 +77067,10 @@ func resolveAlias(tls *libc.TLS, pParse uintptr, pEList uintptr, iCol int32, pEx db = (*Parse)(unsafe.Pointer(pParse)).Fdb pDup = Xsqlite3ExprDup(tls, db, pOrig, 0) if pDup != uintptr(0) { - if int32(*(*int8)(unsafe.Pointer(zType + uintptr(0)))) != 'G' { + if int32(*(*int8)(unsafe.Pointer(zType))) != 'G' { incrAggFunctionDepth(tls, pDup, nSubquery) } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 111 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLLATE { pDup = Xsqlite3ExprAddCollateString(tls, pParse, pDup, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */))) } @@ -77819,15 +77080,15 @@ func resolveAlias(tls *libc.TLS, pParse uintptr, pEList uintptr, iCol int32, pEx // The pExpr->u.zToken might point into memory that will be freed by the // sqlite3DbFree(db, pDup) on the last line of this block, so be sure to // make a copy of the token before doing the sqlite3DbFree(). - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x8000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Static) Xsqlite3ExprDelete(tls, db, pExpr) libc.Xmemcpy(tls, pExpr, pDup, uint64(unsafe.Sizeof(Expr{}))) - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000400))) != U32(0)) && (*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) != uintptr(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_IntValue)) != U32(0)) && (*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) != uintptr(0)) { *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) = Xsqlite3DbStrDup(tls, db, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */))) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x010000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_MemToken) } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { if *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) != uintptr(0) { (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FpOwner = pExpr } else { @@ -77836,7 +77097,7 @@ func resolveAlias(tls *libc.TLS, pParse uintptr, pEList uintptr, iCol int32, pEx } Xsqlite3DbFree(tls, db, pDup) } - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x400000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Alias) } // Return TRUE if the name zCol occurs anywhere in the USING clause. @@ -77863,7 +77124,7 @@ func nameInUsingClause(tls *libc.TLS, pUsing uintptr, zCol uintptr) int32 { /* s func Xsqlite3MatchEName(tls *libc.TLS, pItem uintptr, zCol uintptr, zTab uintptr, zDb uintptr) int32 { /* sqlite3.c:97897:20: */ var n int32 var zSpan uintptr - if (int32(*(*uint8)(unsafe.Pointer(pItem + 20 /* &.eEName */)) & 0x3 >> 0)) != 2 { + if (int32(*(*uint8)(unsafe.Pointer(pItem + 20 /* &.eEName */)) & 0x3 >> 0)) != ENAME_TAB { return 0 } zSpan = (*ExprList_item)(unsafe.Pointer(pItem)).FzEName @@ -77890,15 +77151,15 @@ func areDoubleQuotedStringsEnabled(tls *libc.TLS, db uintptr, pTopNC uintptr) in if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 { return 1 } // Always support for legacy schemas - if ((*NameContext)(unsafe.Pointer(pTopNC)).FncFlags & 0x10000) != 0 { + if ((*NameContext)(unsafe.Pointer(pTopNC)).FncFlags & NC_IsDDL) != 0 { // Currently parsing a DDL statement - if (Xsqlite3WritableSchema(tls, db) != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x40000000)) != uint64(0)) { + if (Xsqlite3WritableSchema(tls, db) != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DqsDML) != uint64(0)) { return 1 } - return (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x20000000)) != uint64(0))) + return (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DqsDDL) != uint64(0))) } else { // Currently parsing a DML statement - return (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x40000000)) != uint64(0))) + return (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DqsDML) != uint64(0))) } return int32(0) } @@ -77912,8 +77173,8 @@ func Xsqlite3ExprColUsed(tls *libc.TLS, pExpr uintptr) Bitmask { /* sqlite3.c:97 n = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) pExTab = *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) - if (((*Table)(unsafe.Pointer(pExTab)).FtabFlags & U32(0x0060)) != U32(0)) && - ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pExTab)).FaCol+uintptr(n)*32)).FcolFlags) & 0x0060) != 0) { + if (((*Table)(unsafe.Pointer(pExTab)).FtabFlags & TF_HasGenerated) != U32(0)) && + ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pExTab)).FaCol+uintptr(n)*32)).FcolFlags) & COLFLAG_GENERATED) != 0) { if int32((*Table)(unsafe.Pointer(pExTab)).FnCol) >= (int32(uint64(unsafe.Sizeof(Bitmask(0))) * uint64(8))) { return libc.Uint64(libc.Uint64FromInt32(-1)) @@ -77990,7 +77251,7 @@ func lookupName(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, zCol u pMatch = uintptr(0) pTopNC = pNC pSchema = uintptr(0) - eNewExprOp = 164 + eNewExprOp = TK_COLUMN pTab = uintptr(0) // A column of pTab // the name context cannot be NULL. @@ -78006,7 +77267,7 @@ func lookupName(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, zCol u goto __1 } - if !(((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (0x00002 | 0x00004)) != 0) { + if !(((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_PartIdx | NC_IsCheck)) != 0) { goto __2 } // Silently ignore database qualifiers inside CHECK constraints and @@ -78041,8 +77302,8 @@ __6: } // This branch is taken when the main database has been renamed // using SQLITE_DBCONFIG_MAINDBNAME. - pSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FpSchema - zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FzDbSName + pSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema + zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName __8: ; __3: @@ -78066,7 +77327,7 @@ __13: } pTab = (*SrcList_item)(unsafe.Pointer(pItem)).FpTab - if !(((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect != 0) && (((*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect)).FselFlags & U32(0x0000800)) != U32(0))) { + if !(((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect != 0) && (((*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect)).FselFlags & SF_NestedFrom) != U32(0))) { goto __16 } hit = 0 @@ -78122,7 +77383,7 @@ __22: goto __14 __24: ; - if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && ((*SrcList_item)(unsafe.Pointer(pItem)).FzAlias != 0)) { + if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && ((*SrcList_item)(unsafe.Pointer(pItem)).FzAlias != 0)) { goto __25 } Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), (pExpr + 64 /* &.y */ /* &.pTab */)) @@ -78152,7 +77413,7 @@ __27: if !(cnt == 1) { goto __31 } - if !((int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & 0x0004) != 0) { + if !((int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & JT_NATURAL) != 0) { goto __32 } goto __28 @@ -78201,10 +77462,10 @@ __15: *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = (*SrcList_item)(unsafe.Pointer(pMatch)).FpTab // RIGHT JOIN not (yet) supported - if !((int32((*SrcList_item)(unsafe.Pointer(pMatch)).Ffg.Fjointype) & 0x0008) != 0) { + if !((int32((*SrcList_item)(unsafe.Pointer(pMatch)).Ffg.Fjointype) & JT_LEFT) != 0) { goto __35 } - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x100000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_CanBeNull) __35: ; pSchema = (*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FpSchema @@ -78225,14 +77486,14 @@ __12: } op = int32((*Parse)(unsafe.Pointer(pParse)).FeTriggerOp) - if !((op != 126) && (Xsqlite3StrICmp(tls, ts+8338 /* "new" */, zTab) == 0)) { + if !((op != TK_DELETE) && (Xsqlite3StrICmp(tls, ts+8338 /* "new" */, zTab) == 0)) { goto __38 } (*Expr)(unsafe.Pointer(pExpr)).FiTable = 1 pTab = (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab goto __39 __38: - if !((op != 125) && (Xsqlite3StrICmp(tls, ts+8342 /* "old" */, zTab) == 0)) { + if !((op != TK_INSERT) && (Xsqlite3StrICmp(tls, ts+8342 /* "old" */, zTab) == 0)) { goto __40 } (*Expr)(unsafe.Pointer(pExpr)).FiTable = 0 @@ -78243,15 +77504,15 @@ __39: ; __37: ; - if !(((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00200) != 0) { + if !(((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_UUpsert) != 0) { goto __41 } pUpsert = *(*uintptr)(unsafe.Pointer(pNC + 16 /* &.uNC */)) if !((pUpsert != 0) && (Xsqlite3StrICmp(tls, ts+8346 /* "excluded" */, zTab) == 0)) { goto __42 } - pTab = (*SrcList_item)(unsafe.Pointer(((*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab - (*Expr)(unsafe.Pointer(pExpr)).FiTable = 2 + pTab = (*SrcList_item)(unsafe.Pointer(((*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc + 8 /* &.a */))).FpTab + (*Expr)(unsafe.Pointer(pExpr)).FiTable = EXCLUDED_TABLE_NUMBER __42: ; __41: @@ -78289,7 +77550,7 @@ __45: goto __46 __46: ; - if !(((iCol >= int32((*Table)(unsafe.Pointer(pTab)).FnCol)) && (Xsqlite3IsRowid(tls, zCol) != 0)) && (((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0200)) == U32(0))) { + if !(((iCol >= int32((*Table)(unsafe.Pointer(pTab)).FnCol)) && (Xsqlite3IsRowid(tls, zCol) != 0)) && (((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_NoVisibleRowid) == U32(0))) { goto __49 } // IMP: R-51414-32910 @@ -78300,21 +77561,21 @@ __49: goto __50 } cnt++ - if !((*Expr)(unsafe.Pointer(pExpr)).FiTable == 2) { + if !((*Expr)(unsafe.Pointer(pExpr)).FiTable == EXCLUDED_TABLE_NUMBER) { goto __51 } - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __53 } (*Expr)(unsafe.Pointer(pExpr)).FiColumn = YnVar(iCol) *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = pTab - eNewExprOp = 164 + eNewExprOp = TK_COLUMN goto __54 __53: (*Expr)(unsafe.Pointer(pExpr)).FiTable = ((*Upsert)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNC + 16 /* &.uNC */)))).FregData + int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(iCol)))) - eNewExprOp = 173 - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x400000)) + eNewExprOp = TK_REGISTER + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Alias) __54: ; goto __52 @@ -78323,7 +77584,7 @@ __51: if !(iCol < 0) { goto __55 } - (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = int8(0x44) + (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = SQLITE_AFF_INTEGER goto __56 __55: if !((*Expr)(unsafe.Pointer(pExpr)).FiTable == 0) { @@ -78352,7 +77613,7 @@ __56: ; *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = pTab (*Expr)(unsafe.Pointer(pExpr)).FiColumn = I16(iCol) - eNewExprOp = 77 + eNewExprOp = TK_TRIGGER __52: ; __50: @@ -78366,14 +77627,14 @@ __36: if !((((((cnt == 0) && (cntTab == 1)) && (pMatch != 0)) && - (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (0x00020 | 0x00008)) == 0)) && + (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_IdxExpr | NC_GenCol)) == 0)) && (Xsqlite3IsRowid(tls, zCol) != 0)) && - (((*Table)(unsafe.Pointer(((*SrcList_item)(unsafe.Pointer(pMatch)).FpTab))).FtabFlags & U32(0x0200)) == U32(0))) { + (((*Table)(unsafe.Pointer(((*SrcList_item)(unsafe.Pointer(pMatch)).FpTab))).FtabFlags & TF_NoVisibleRowid) == U32(0))) { goto __59 } cnt = 1 (*Expr)(unsafe.Pointer(pExpr)).FiColumn = int16(-1) - (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = int8(0x44) + (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = SQLITE_AFF_INTEGER __59: ; @@ -78393,7 +77654,7 @@ __59: // clause is not standard SQL. This is a (goofy) SQLite extension, that // is supported for backwards compatibility only. Hence, we issue a warning // on sqlite3_log() whenever the capability is used. - if !(((((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00080) != 0) && + if !(((((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_UEList) != 0) && (cnt == 0)) && (zTab == uintptr(0))) { goto __60 @@ -78406,39 +77667,39 @@ __61: goto __63 } zAs = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(j)*32)).FzEName - if !(((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(j)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0) && + if !(((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(j)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME) && (Xsqlite3_stricmp(tls, zAs, zCol) == 0)) { goto __64 } pOrig = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(j)*32)).FpExpr - if !((((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00001) == 0) && (((*Expr)(unsafe.Pointer((pOrig))).Fflags & (U32(0x000010))) != U32(0))) { + if !((((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_AllowAgg) == 0) && (((*Expr)(unsafe.Pointer((pOrig))).Fflags & (EP_Agg)) != U32(0))) { goto __65 } Xsqlite3ErrorMsg(tls, pParse, ts+8355 /* "misuse of aliase..." */, libc.VaList(bp, zAs)) - return 2 + return WRC_Abort __65: ; - if !((((*Expr)(unsafe.Pointer((pOrig))).Fflags & (U32(0x008000))) != U32(0)) && - ((((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x04000) == 0) || (pNC != pTopNC))) { + if !((((*Expr)(unsafe.Pointer((pOrig))).Fflags & (EP_Win)) != U32(0)) && + ((((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_AllowWin) == 0) || (pNC != pTopNC))) { goto __66 } Xsqlite3ErrorMsg(tls, pParse, ts+8386 /* "misuse of aliase..." */, libc.VaList(bp+8, zAs)) - return 2 + return WRC_Abort __66: ; if !(Xsqlite3ExprVectorSize(tls, pOrig) != 1) { goto __67 } Xsqlite3ErrorMsg(tls, pParse, ts+8423 /* "row value misuse..." */, 0) - return 2 + return WRC_Abort __67: ; resolveAlias(tls, pParse, pEList, j, pExpr, ts+800 /* "" */, nSubquery) cnt = 1 pMatch = uintptr(0) - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __68 } Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr) @@ -78488,7 +77749,7 @@ __11: goto __70 } - if !((((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000040))) != U32(0)) && + if !((((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_DblQuoted)) != U32(0)) && (areDoubleQuotedStringsEnabled(tls, db, pTopNC) != 0)) { goto __71 } @@ -78505,17 +77766,17 @@ __11: // Someday, I hope to get rid of this hack. Unfortunately there is // a huge amount of legacy SQL that uses it. So for now, we just // issue a warning. - Xsqlite3_log(tls, 28, + Xsqlite3_log(tls, SQLITE_WARNING, ts+8441 /* "double-quoted st..." */, libc.VaList(bp+16, zCol)) - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(115) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_STRING *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = uintptr(0) - return 1 + return WRC_Prune __71: ; if !(Xsqlite3ExprIdToTrueFalse(tls, pExpr) != 0) { goto __72 } - return 1 + return WRC_Prune __72: ; __70: @@ -78579,13 +77840,13 @@ __78: Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpRight) (*Expr)(unsafe.Pointer(pExpr)).FpRight = uintptr(0) (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(eNewExprOp) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x800000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Leaf) lookupname_end: if !(cnt == 1) { goto __79 } - if !(!(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x400000))) != U32(0))) { + if !(!(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Alias)) != U32(0))) { goto __81 } Xsqlite3AuthRead(tls, pParse, pExpr, pSchema, (*NameContext)(unsafe.Pointer(pNC)).FpSrcList) @@ -78609,10 +77870,10 @@ __83: goto __84 __84: ; - return 1 + return WRC_Prune goto __80 __79: - return 2 + return WRC_Abort __80: ; return int32(0) @@ -78621,7 +77882,7 @@ __80: // Allocate and return a pointer to an expression to load the column iCol // from datasource iSrc in SrcList pSrc. func Xsqlite3CreateColumnExpr(tls *libc.TLS, db uintptr, pSrc uintptr, iSrc int32, iCol int32) uintptr { /* sqlite3.c:98406:21: */ - var p uintptr = Xsqlite3ExprAlloc(tls, db, 164, uintptr(0), 0) + var p uintptr = Xsqlite3ExprAlloc(tls, db, TK_COLUMN, uintptr(0), 0) if p != 0 { var pItem uintptr = ((pSrc + 8 /* &.a */) + uintptr(iSrc)*112) var pTab uintptr = libc.AssignPtrUintptr(p+64 /* &.y */ /* &.pTab */, (*SrcList_item)(unsafe.Pointer(pItem)).FpTab) @@ -78630,8 +77891,8 @@ func Xsqlite3CreateColumnExpr(tls *libc.TLS, db uintptr, pSrc uintptr, iSrc int3 (*Expr)(unsafe.Pointer(p)).FiColumn = int16(-1) } else { (*Expr)(unsafe.Pointer(p)).FiColumn = YnVar(iCol) - if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != U32(0)) && - ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*32)).FcolFlags) & 0x0060) != 0) { + if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != U32(0)) && + ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*32)).FcolFlags) & COLFLAG_GENERATED) != 0) { (*SrcList_item)(unsafe.Pointer(pItem)).FcolUsed = func() uint64 { if int32((*Table)(unsafe.Pointer(pTab)).FnCol) >= 64 { @@ -78672,16 +77933,16 @@ func notValidImpl(tls *libc.TLS, pParse uintptr, pNC uintptr, zMsg uintptr, pExp defer tls.Free(16) var zIn uintptr = ts + 8543 /* "partial index WH..." */ - if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00020) != 0 { + if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_IdxExpr) != 0 { zIn = ts + 8571 /* "index expression..." */ - } else if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00004) != 0 { + } else if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_IsCheck) != 0 { zIn = ts + 8589 /* "CHECK constraint..." */ - } else if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00008) != 0 { + } else if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_GenCol) != 0 { zIn = ts + 8607 /* "generated column..." */ } Xsqlite3ErrorMsg(tls, pParse, ts+8625 /* "%s prohibited in..." */, libc.VaList(bp, zMsg, zIn)) if pExpr != 0 { - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(119) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_NULL } } @@ -78693,10 +77954,10 @@ func exprProbability(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:98474:12: */ defer tls.Free(8) *(*float64)(unsafe.Pointer(bp /* r */)) = -1.0 - if int32((*Expr)(unsafe.Pointer(p)).Fop) != 150 { + if int32((*Expr)(unsafe.Pointer(p)).Fop) != TK_FLOAT { return -1 } - Xsqlite3AtoF(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)), bp /* &r */, Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))), uint8(1)) + Xsqlite3AtoF(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)), bp /* &r */, Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))), SQLITE_UTF8) if *(*float64)(unsafe.Pointer(bp /* r */)) > 1.0 { return -1 @@ -78730,17 +77991,17 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s // column in the FROM clause. This is used by the LIMIT and ORDER BY // clause processing on UPDATE and DELETE statements, and by // UPDATE ... FROM statement processing. - case 75: + case TK_ROW: { var pSrcList uintptr = (*NameContext)(unsafe.Pointer(pNC)).FpSrcList var pItem uintptr pItem = pSrcList + 8 /* &.a */ - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(164) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_COLUMN *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = (*SrcList_item)(unsafe.Pointer(pItem)).FpTab (*Expr)(unsafe.Pointer(pExpr)).FiTable = (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor (*Expr)(unsafe.Pointer(pExpr)).FiColumn-- - (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = int8(0x44) + (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = SQLITE_AFF_INTEGER break } @@ -78752,28 +78013,28 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s // The TK_ID and TK_OUT cases are combined so that there will only // be one call to lookupName(). Then the compiler will in-line // lookupName() for a size reduction and performance increase. - case 59: + case TK_ID: fallthrough - case 139: + case TK_DOT: { var zColumn uintptr var zTable uintptr var zDb uintptr var pRight uintptr - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 59 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_ID { zDb = uintptr(0) zTable = uintptr(0) zColumn = *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) } else { var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft - if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & (0x00020 | 0x00008)) != 0 { + if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & (NC_IdxExpr | NC_GenCol)) != 0 { notValidImpl(tls, pParse, pNC, ts+8645 /* "the \".\" operator" */, uintptr(0)) } pRight = (*Expr)(unsafe.Pointer(pExpr)).FpRight - if int32((*Expr)(unsafe.Pointer(pRight)).Fop) == 59 { + if int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_ID { zDb = uintptr(0) } else { @@ -78783,7 +78044,7 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } zTable = *(*uintptr)(unsafe.Pointer(pLeft + 8 /* &.u */)) zColumn = *(*uintptr)(unsafe.Pointer(pRight + 8 /* &.u */)) - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameTokenRemap(tls, pParse, pExpr, pRight) Xsqlite3RenameTokenRemap(tls, pParse, (pExpr + 64 /* &.y */ /* &.pTab */), pLeft) } @@ -78793,7 +78054,7 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } // Resolve function names - case 169: + case TK_FUNCTION: { var pList uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) // The argument list var n int32 @@ -78809,9 +78070,9 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s var zId uintptr // The function name. var pDef uintptr // Information about the function var enc U8 = (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fenc // The database encoding - var savedAllowFlags int32 = ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (0x00001 | 0x04000)) + var savedAllowFlags int32 = ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_AllowAgg | NC_AllowWin)) var pWin uintptr = func() uintptr { - if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) && (int32((*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FeFrmType) != 163) { + if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) && (int32((*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FeFrmType) != TK_FILTER) { return *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) } return uintptr(0) @@ -78829,10 +78090,10 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } } else { is_agg = (libc.Bool32((*FuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0))) - if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0400)) != 0 { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x040000)) + if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_UNLIKELY) != 0 { + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Unlikely) if n == 2 { - (*Expr)(unsafe.Pointer(pExpr)).FiTable = exprProbability(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(1)*32)).FpExpr) + (*Expr)(unsafe.Pointer(pExpr)).FiTable = exprProbability(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+1*32)).FpExpr) if (*Expr)(unsafe.Pointer(pExpr)).FiTable < 0 { Xsqlite3ErrorMsg(tls, pParse, @@ -78850,7 +78111,7 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s // to likelihood(X,0.9375). // TUNING: unlikely() probability is 0.0625. likely() is 0.9375 (*Expr)(unsafe.Pointer(pExpr)).FiTable = func() int32 { - if int32(*(*int8)(unsafe.Pointer((*FuncDef)(unsafe.Pointer(pDef)).FzName + uintptr(0)))) == 'u' { + if int32(*(*int8)(unsafe.Pointer((*FuncDef)(unsafe.Pointer(pDef)).FzName))) == 'u' { return 8388608 } return 125829120 @@ -78858,69 +78119,69 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } } { - var auth int32 = Xsqlite3AuthCheck(tls, pParse, 31, uintptr(0), (*FuncDef)(unsafe.Pointer(pDef)).FzName, uintptr(0)) - if auth != 0 { - if auth == 1 { + var auth int32 = Xsqlite3AuthCheck(tls, pParse, SQLITE_FUNCTION, uintptr(0), (*FuncDef)(unsafe.Pointer(pDef)).FzName, uintptr(0)) + if auth != SQLITE_OK { + if auth == SQLITE_DENY { Xsqlite3ErrorMsg(tls, pParse, ts+8733, /* "not authorized t..." */ libc.VaList(bp, (*FuncDef)(unsafe.Pointer(pDef)).FzName)) (*NameContext)(unsafe.Pointer(pNC)).FnErr++ } - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(119) - return 1 + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_NULL + return WRC_Prune } } - if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(0x0800 | 0x2000))) != 0 { + if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(SQLITE_FUNC_CONSTANT | SQLITE_FUNC_SLOCHNG))) != 0 { // For the purposes of the EP_ConstFunc flag, date and time // functions and other functions that change slowly are considered // constant because they are constant for the duration of one query. // This allows them to be factored out of inner loops. - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x080000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_ConstFunc) } - if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0800)) == U32(0) { + if ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_CONSTANT) == U32(0) { // Clearly non-deterministic functions like random(), but also // date/time functions that use 'now', and other functions like // sqlite_version() that might change over time cannot be used // in an index or generated column. Curiously, they can be used // in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all // all this. - if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & ((0x00020 | 0x00002) | 0x00008)) != 0 { + if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & ((NC_IdxExpr | NC_PartIdx) | NC_GenCol)) != 0 { notValidImpl(tls, pParse, pNC, ts+8768 /* "non-deterministi..." */, uintptr(0)) } } else { // Must fit in 8 bits - (*Expr)(unsafe.Pointer(pExpr)).Fop2 = (U8((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x0002e)) - if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x40000) != 0 { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x40000000)) + (*Expr)(unsafe.Pointer(pExpr)).Fop2 = (U8((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_SelfRef)) + if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_FromDDL) != 0 { + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_FromDDL) } } - if ((((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x00040000)) != U32(0)) && + if ((((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_INTERNAL) != U32(0)) && (int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0)) && - (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags & U32(0x0020)) == U32(0)) { + (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags & DBFLAG_InternalFunc) == U32(0)) { // Internal-use-only functions are disallowed unless the // SQL is being compiled using sqlite3NestedParse() or // the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control has be // used to activate internal functionsn for testing purposes no_such_func = 1 pDef = uintptr(0) - } else if (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(0x00080000 | 0x00200000))) != U32(0)) && - !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + } else if (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(SQLITE_FUNC_DIRECT | SQLITE_FUNC_UNSAFE))) != U32(0)) && + !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { Xsqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef) } } - if 0 == (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) { + if 0 == (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) { if ((pDef != 0) && ((*FuncDef)(unsafe.Pointer(pDef)).FxValue == uintptr(0))) && (pWin != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+8796 /* "%.*s() may not b..." */, libc.VaList(bp+8, nId, zId)) (*NameContext)(unsafe.Pointer(pNC)).FnErr++ - } else if (((is_agg != 0) && (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x00001) == 0)) || - (((is_agg != 0) && (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x00010000)) != 0)) && !(pWin != 0))) || - (((is_agg != 0) && (pWin != 0)) && (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x04000) == 0)) { + } else if (((is_agg != 0) && (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_AllowAgg) == 0)) || + (((is_agg != 0) && (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_WINDOW) != 0)) && !(pWin != 0))) || + (((is_agg != 0) && (pWin != 0)) && (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_AllowWin) == 0)) { var zType uintptr - if (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x00010000)) != 0) || (pWin != 0) { + if (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_WINDOW) != 0) || (pWin != 0) { zType = ts + 8840 /* "window" */ } else { zType = ts + 8847 /* "aggregate" */ @@ -78935,7 +78196,7 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s Xsqlite3ErrorMsg(tls, pParse, ts+8909, /* "wrong number of ..." */ libc.VaList(bp+64, nId, zId)) (*NameContext)(unsafe.Pointer(pNC)).FnErr++ - } else if (is_agg == 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + } else if (is_agg == 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) { Xsqlite3ErrorMsg(tls, pParse, ts+8954, /* "FILTER may not b..." */ libc.VaList(bp+80, nId, zId)) @@ -78945,14 +78206,14 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s // Window functions may not be arguments of aggregate functions. // Or arguments of other window functions. But aggregate functions // may be arguments for window functions. - *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (^(0x04000 | (func() int32 { + *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (^(NC_AllowWin | (func() int32 { if !(pWin != 0) { - return 0x00001 + return NC_AllowAgg } return 0 }()))) } - } else if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + } else if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { is_agg = 1 } Xsqlite3WalkExprList(tls, pWalker, pList) @@ -78960,7 +78221,7 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s if pWin != 0 { var pSel uintptr = (*NameContext)(unsafe.Pointer(pNC)).FpWinSelect - if (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) == 0 { + if (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) == 0 { Xsqlite3WindowUpdate(tls, pParse, func() uintptr { if pSel != 0 { return (*Select)(unsafe.Pointer(pSel)).FpWinDefn @@ -78972,12 +78233,12 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s Xsqlite3WalkExprList(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpOrderBy) Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(pWin)).FpFilter) Xsqlite3WindowLink(tls, pSel, pWin) - *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) |= (0x08000) + *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) |= (NC_HasWin) } else { var pNC2 uintptr = pNC - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(165) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_AGG_FUNCTION (*Expr)(unsafe.Pointer(pExpr)).Fop2 = U8(0) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { Xsqlite3WalkExpr(tls, pWalker, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FpFilter) } for (pNC2 != 0) && !(Xsqlite3FunctionUsesThisSrc(tls, pExpr, (*NameContext)(unsafe.Pointer(pNC2)).FpSrcList) != 0) { @@ -78987,7 +78248,7 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s if (pNC2 != 0) && (pDef != 0) { - *(*int32)(unsafe.Pointer(pNC2 + 40 /* &.ncFlags */)) |= int32((U32(0x00010) | ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x1000)))) + *(*int32)(unsafe.Pointer(pNC2 + 40 /* &.ncFlags */)) |= int32((NC_HasAgg | ((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_MINMAX))) } } @@ -78995,79 +78256,78 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } // FIX ME: Compute pExpr->affinity based on the expected return // type of the function - return 1 + return WRC_Prune } - case 136: + case TK_SELECT: fallthrough - case 20: + case TK_EXISTS: fallthrough - case 49: + case TK_IN: { - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { var nRef int32 = (*NameContext)(unsafe.Pointer(pNC)).FnRef - if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & (((0x00004 | 0x00002) | 0x00020) | 0x00008)) != 0 { + if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & (((NC_IsCheck | NC_PartIdx) | NC_IdxExpr) | NC_GenCol)) != 0 { notValidImpl(tls, pParse, pNC, ts+9003 /* "subqueries" */, pExpr) } Xsqlite3WalkSelect(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) if nRef != (*NameContext)(unsafe.Pointer(pNC)).FnRef { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x000020)) - *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) |= (0x00040) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_VarSelect) + *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) |= (NC_VarSelect) } } break } - case 153: + case TK_VARIABLE: { - if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & (((0x00004 | 0x00002) | 0x00020) | 0x00008)) != 0 { + if ((*NameContext)(unsafe.Pointer((pNC))).FncFlags & (((NC_IsCheck | NC_PartIdx) | NC_IdxExpr) | NC_GenCol)) != 0 { notValidImpl(tls, pParse, pNC, ts+9014 /* "parameters" */, pExpr) } break } - case 45: + case TK_IS: fallthrough - case 168: + case TK_ISNOT: { var pRight uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) // Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE", // and "x IS NOT FALSE". - if (pRight != 0) && (int32((*Expr)(unsafe.Pointer(pRight)).Fop) == 59) { + if (pRight != 0) && (int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_ID) { var rc int32 = resolveExprStep(tls, pWalker, pRight) - if rc == 2 { - return 2 + if rc == WRC_Abort { + return WRC_Abort } - if int32((*Expr)(unsafe.Pointer(pRight)).Fop) == 167 { + if int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_TRUEFALSE { (*Expr)(unsafe.Pointer(pExpr)).Fop2 = (*Expr)(unsafe.Pointer(pExpr)).Fop - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(172) - return 0 + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_TRUTH + return WRC_Continue } } - /* no break */ } fallthrough - case 48: + case TK_BETWEEN: fallthrough - case 53: + case TK_EQ: fallthrough - case 52: + case TK_NE: fallthrough - case 56: + case TK_LT: fallthrough - case 55: + case TK_LE: fallthrough - case 54: + case TK_GT: fallthrough - case 57: + case TK_GE: { var nLeft int32 var nRight int32 @@ -79076,10 +78336,10 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } nLeft = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 48 { - nRight = Xsqlite3ExprVectorSize(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))+8 /* &.a */)+uintptr(0)*32)).FpExpr) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_BETWEEN { + nRight = Xsqlite3ExprVectorSize(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */))).FpExpr) if nRight == nLeft { - nRight = Xsqlite3ExprVectorSize(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))+8 /* &.a */)+uintptr(1)*32)).FpExpr) + nRight = Xsqlite3ExprVectorSize(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))+8 /* &.a */)+1*32)).FpExpr) } } else { @@ -79094,9 +78354,9 @@ func resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* s } } if ((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) || ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0) { - return 2 + return WRC_Abort } - return 0 + return WRC_Continue } // pEList is a list of expressions which are really the result set of the @@ -79114,10 +78374,10 @@ func resolveAsName(tls *libc.TLS, pParse uintptr, pEList uintptr, pE uintptr) in _ = pParse - if int32((*Expr)(unsafe.Pointer(pE)).Fop) == 59 { + if int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_ID { var zCol uintptr = *(*uintptr)(unsafe.Pointer(pE + 8 /* &.u */)) for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ { - if ((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0) && + if ((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME) && (Xsqlite3_stricmp(tls, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FzEName, zCol) == 0) { return (i + 1) } @@ -79161,11 +78421,11 @@ func resolveOrderByTermToExprList(tls *libc.TLS, pParse uintptr, pSelect uintptr (*NameContext)(unsafe.Pointer(bp /* &nc */)).FpParse = pParse (*NameContext)(unsafe.Pointer(bp /* &nc */)).FpSrcList = (*Select)(unsafe.Pointer(pSelect)).FpSrc *(*uintptr)(unsafe.Pointer(bp /* &nc */ + 16 /* &.uNC */)) = pEList - (*NameContext)(unsafe.Pointer(bp /* &nc */)).FncFlags = (0x00001 | 0x00080) + (*NameContext)(unsafe.Pointer(bp /* &nc */)).FncFlags = (NC_AllowAgg | NC_UEList) (*NameContext)(unsafe.Pointer(bp /* &nc */)).FnErr = 0 db = (*Parse)(unsafe.Pointer(pParse)).Fdb savedSuppErr = (*Sqlite3)(unsafe.Pointer(db)).FsuppressErr - if (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) == 0 { + if (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) == 0 { (*Sqlite3)(unsafe.Pointer(db)).FsuppressErr = U8(1) } rc = Xsqlite3ResolveExprNames(tls, bp /* &nc */, pE) @@ -79225,7 +78485,7 @@ func resolveCompoundOrderBy(tls *libc.TLS, pParse uintptr, pSelect uintptr) int3 return 0 } db = (*Parse)(unsafe.Pointer(pParse)).Fdb - if (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(2)*4)) { + if (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 2*4)) { Xsqlite3ErrorMsg(tls, pParse, ts+9081 /* "too many terms i..." */, 0) return 1 } @@ -79277,7 +78537,7 @@ func resolveCompoundOrderBy(tls *libc.TLS, pParse uintptr, pSelect uintptr) int3 // as is instead of transforming it to an integer as in the usual // case. This allows the code in alter.c to modify column // refererences within the ORDER BY expression as required. - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { pDup = pE } else { pDup = Xsqlite3ExprDup(tls, db, pE, 0) @@ -79286,7 +78546,7 @@ func resolveCompoundOrderBy(tls *libc.TLS, pParse uintptr, pSelect uintptr) int3 *(*int32)(unsafe.Pointer(bp + 8 /* iCol */)) = resolveOrderByTermToExprList(tls, pParse, pSelect, pDup) } - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { Xsqlite3ExprDelete(tls, db, pDup) } } @@ -79294,19 +78554,19 @@ func resolveCompoundOrderBy(tls *libc.TLS, pParse uintptr, pSelect uintptr) int3 if *(*int32)(unsafe.Pointer(bp + 8 /* iCol */)) > 0 { // Convert the ORDER BY term into an integer column number iCol, // taking care to preserve the COLLATE clause if it exists - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { - var pNew uintptr = Xsqlite3Expr(tls, db, 152, uintptr(0)) + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { + var pNew uintptr = Xsqlite3Expr(tls, db, TK_INTEGER, uintptr(0)) if pNew == uintptr(0) { return 1 } - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x000400)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (EP_IntValue) *(*int32)(unsafe.Pointer(pNew + 8 /* &.u */)) = *(*int32)(unsafe.Pointer(bp + 8 /* iCol */)) if (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr == pE { (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr = pNew } else { var pParent uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr - for int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pParent)).FpLeft)).Fop) == 111 { + for int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pParent)).FpLeft)).Fop) == TK_COLLATE { pParent = (*Expr)(unsafe.Pointer(pParent)).FpLeft } @@ -79358,10 +78618,10 @@ func Xsqlite3ResolveOrderGroupBy(tls *libc.TLS, pParse uintptr, pSelect uintptr, var pEList uintptr var pItem uintptr - if ((pOrderBy == uintptr(0)) || ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0)) || (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if ((pOrderBy == uintptr(0)) || ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0)) || (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { return 0 } - if (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(2)*4)) { + if (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 2*4)) { Xsqlite3ErrorMsg(tls, pParse, ts+9182 /* "too many terms i..." */, libc.VaList(bp, zType)) return 1 } @@ -79398,11 +78658,11 @@ __3: // Walker callback for windowRemoveExprFromSelect(). func resolveRemoveWindowsCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:99159:12: */ _ = pWalker - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { var pWin uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) Xsqlite3WindowUnlinkFromSelect(tls, pWin) } - return 0 + return WRC_Continue } // Remove any Window objects owned by the expression pExpr from the @@ -79465,7 +78725,7 @@ __1: { var pE uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr var pE2 uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, pE) - if int32(*(*int8)(unsafe.Pointer(zType + uintptr(0)))) != 'G' { + if int32(*(*int8)(unsafe.Pointer(zType))) != 'G' { *(*int32)(unsafe.Pointer(bp /* iCol */)) = resolveAsName(tls, pParse, (*Select)(unsafe.Pointer(pSelect)).FpEList, pE2) if *(*int32)(unsafe.Pointer(bp /* iCol */)) > 0 { // If an AS-name match is found, mark this ORDER BY column as being @@ -79531,8 +78791,8 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql var pLeftmost uintptr // Left-most of SELECT of a compound var db uintptr // Database connection - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000004)) != 0 { - return 1 + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_Resolved) != 0 { + return WRC_Prune } pOuterNC = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) pParse = (*Walker)(unsafe.Pointer(pWalker)).FpParse @@ -79545,12 +78805,12 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // sqlite3SelectPrep() do all of the processing for this SELECT. // sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and // this routine in the correct order. - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000040)) == U32(0) { + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_Expanded) == U32(0) { Xsqlite3SelectPrep(tls, pParse, p, pOuterNC) if ((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { - return 2 + return WRC_Abort } - return 1 + return WRC_Prune } isCompound = (libc.Bool32((*Select)(unsafe.Pointer(p)).FpPrior != uintptr(0))) @@ -79558,7 +78818,7 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql pLeftmost = p for p != 0 { - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0000004)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_Resolved) // Resolve the expressions in the LIMIT and OFFSET clauses. These // are not allowed to refer to any names, so pass an empty NameContext. @@ -79566,7 +78826,7 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpParse = pParse (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpWinSelect = p if Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*Select)(unsafe.Pointer(p)).FpLimit) != 0 { - return 2 + return WRC_Abort } // If the SF_Converted flags is set, then this Select object was @@ -79575,8 +78835,8 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // as if it were part of the sub-query, not the parent. This block // moves the pOrderBy down to the sub-query. It will be moved back // after the names have been resolved. - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0010000)) != 0 { - var pSub uintptr = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpSelect + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_Converted) != 0 { + var pSub uintptr = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpSelect (*Select)(unsafe.Pointer(pSub)).FpOrderBy = (*Select)(unsafe.Pointer(p)).FpOrderBy (*Select)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) @@ -79585,7 +78845,7 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // Recursively resolve names in all subqueries for i = 0; i < (*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc; i++ { var pItem uintptr = (((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(i)*112) - if ((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect != 0) && (((*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect)).FselFlags & U32(0x0000004)) == U32(0)) { + if ((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect != 0) && (((*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem)).FpSelect)).FselFlags & SF_Resolved) == U32(0)) { var pNC uintptr // Used to iterate name contexts var nRef int32 = 0 // Refcount for pOuterNC and outer contexts var zSavedContext uintptr = (*Parse)(unsafe.Pointer(pParse)).FzAuthContext @@ -79605,7 +78865,7 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql Xsqlite3ResolveSelectNames(tls, pParse, (*SrcList_item)(unsafe.Pointer(pItem)).FpSelect, pOuterNC) (*Parse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedContext if ((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { - return 2 + return WRC_Abort } for pNC = pOuterNC; pNC != 0; pNC = (*NameContext)(unsafe.Pointer(pNC)).FpNext { @@ -79618,31 +78878,31 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // Set up the local name-context to pass to sqlite3ResolveExprNames() to // resolve the result-set expression list. - (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = (0x00001 | 0x04000) + (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = (NC_AllowAgg | NC_AllowWin) (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpSrcList = (*Select)(unsafe.Pointer(p)).FpSrc (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpNext = pOuterNC // Resolve names in the result set. if Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, (*Select)(unsafe.Pointer(p)).FpEList) != 0 { - return 2 + return WRC_Abort } - *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) &= (^libc.Int32(0x04000)) + *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) &= (libc.CplInt32(NC_AllowWin)) // If there are no aggregate functions in the result-set, and no GROUP BY // expression, do not allow aggregates in any of the other expressions. pGroupBy = (*Select)(unsafe.Pointer(p)).FpGroupBy - if (pGroupBy != 0) || (((*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags & 0x00010) != 0) { + if (pGroupBy != 0) || (((*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags & NC_HasAgg) != 0) { - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0000008 | ((*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags & 0x01000))) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(SF_Aggregate | ((*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags & NC_MinMaxAgg))) } else { - *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) &= (^libc.Int32(0x00001)) + *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) &= (libc.CplInt32(NC_AllowAgg)) } // If a HAVING clause is present, then there must be a GROUP BY clause. if ((*Select)(unsafe.Pointer(p)).FpHaving != 0) && !(pGroupBy != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+9213 /* "a GROUP BY claus..." */, 0) - return 2 + return WRC_Abort } // Add the output column list to the name-context before parsing the @@ -79654,12 +78914,12 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // re-evaluated for each reference to it. *(*uintptr)(unsafe.Pointer(bp /* &sNC */ + 16 /* &.uNC */)) = (*Select)(unsafe.Pointer(p)).FpEList - *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) |= (0x00080) + *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) |= (NC_UEList) if Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*Select)(unsafe.Pointer(p)).FpHaving) != 0 { - return 2 + return WRC_Abort } if Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*Select)(unsafe.Pointer(p)).FpWhere) != 0 { - return 2 + return WRC_Abort } // Resolve names in table-valued-function arguments @@ -79667,22 +78927,22 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql var pItem uintptr = (((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(i)*112) if ((uint32(int32(*(*uint8)(unsafe.Pointer((pItem + 60 /* &.fg */) + 4 /* &.isTabFunc */)) & 0x4 >> 2))) != 0) && (Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, *(*uintptr)(unsafe.Pointer(pItem + 96 /* &.u1 */))) != 0) { - return 2 + return WRC_Abort } } // The ORDER BY and GROUP BY clauses may not refer to terms in // outer queries (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpNext = uintptr(0) - *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) |= (0x00001 | 0x04000) + *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) |= (NC_AllowAgg | NC_AllowWin) // If this is a converted compound query, move the ORDER BY clause from // the sub-query back to the parent query. At this point each term // within the ORDER BY clause has been transformed to an integer value. // These integers will be replaced by copies of the corresponding result // set expressions by the call to resolveOrderGroupBy() below. - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0010000)) != 0 { - var pSub uintptr = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpSelect + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_Converted) != 0 { + var pSub uintptr = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpSelect (*Select)(unsafe.Pointer(p)).FpOrderBy = (*Select)(unsafe.Pointer(pSub)).FpOrderBy (*Select)(unsafe.Pointer(pSub)).FpOrderBy = uintptr(0) } @@ -79698,12 +78958,12 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // resolve those symbols on the incorrect ORDER BY for consistency. if (isCompound <= nCompound) && // Defer right-most ORDER BY of a compound (resolveOrderGroupBy(tls, bp /* &sNC */, p, (*Select)(unsafe.Pointer(p)).FpOrderBy, ts+9115 /* "ORDER" */) != 0) { - return 2 + return WRC_Abort } if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - return 2 + return WRC_Abort } - *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) &= (^libc.Int32(0x04000)) + *(*int32)(unsafe.Pointer(bp /* &sNC */ + 40 /* &.ncFlags */)) &= (libc.CplInt32(NC_AllowWin)) // Resolve the GROUP BY clause. At the same time, make sure // the GROUP BY clause does not contain aggregate functions. @@ -79711,7 +78971,7 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql var pItem uintptr if (resolveOrderGroupBy(tls, bp /* &sNC */, p, pGroupBy, ts+9257 /* "GROUP" */) != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { - return 2 + return WRC_Abort } i = 0 pItem = pGroupBy + 8 /* &.a */ @@ -79720,10 +78980,10 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql goto __3 } { - if ((*Expr)(unsafe.Pointer(((*ExprList_item)(unsafe.Pointer(pItem)).FpExpr))).Fflags & (U32(0x000010))) != U32(0) { + if ((*Expr)(unsafe.Pointer(((*ExprList_item)(unsafe.Pointer(pItem)).FpExpr))).Fflags & (EP_Agg)) != U32(0) { Xsqlite3ErrorMsg(tls, pParse, ts+9263 /* "aggregate functi..." */, 0) - return 2 + return WRC_Abort } } @@ -79736,12 +78996,12 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql __3: } - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { var pWin uintptr for pWin = (*Select)(unsafe.Pointer(p)).FpWinDefn; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { if (Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, (*Window)(unsafe.Pointer(pWin)).FpOrderBy) != 0) || (Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, (*Window)(unsafe.Pointer(pWin)).FpPartition) != 0) { - return 2 + return WRC_Abort } } } @@ -79750,7 +79010,7 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // number of expressions in the select list. if ((*Select)(unsafe.Pointer(p)).FpNext != 0) && ((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr != (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpNext)).FpEList)).FnExpr) { Xsqlite3SelectWrongNumTermsError(tls, pParse, (*Select)(unsafe.Pointer(p)).FpNext) - return 2 + return WRC_Abort } // Advance to the next term of the compound @@ -79761,10 +79021,10 @@ func resolveSelectStep(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sql // Resolve the ORDER BY on a compound SELECT after all terms of // the compound have been resolved. if (isCompound != 0) && (resolveCompoundOrderBy(tls, pParse, pLeftmost) != 0) { - return 2 + return WRC_Abort } - return 1 + return WRC_Prune } // This routine walks an expression tree and resolves references to @@ -79821,10 +79081,10 @@ func Xsqlite3ResolveExprNames(tls *libc.TLS, pNC uintptr, pExpr uintptr) int32 { // var w Walker at bp, 48 if pExpr == uintptr(0) { - return 0 + return SQLITE_OK } - savedHasAgg = ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((0x00010 | 0x01000) | 0x08000)) - *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (^libc.Int32(((0x00010 | 0x01000) | 0x08000))) + savedHasAgg = ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin)) + *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (libc.CplInt32(((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin))) (*Walker)(unsafe.Pointer(bp /* &w */)).FpParse = (*NameContext)(unsafe.Pointer(pNC)).FpParse (*Walker)(unsafe.Pointer(bp /* &w */)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) int32 @@ -79836,12 +79096,12 @@ func Xsqlite3ResolveExprNames(tls *libc.TLS, pNC uintptr, pExpr uintptr) int32 { *(*uintptr)(unsafe.Pointer(bp /* &w */ + 40 /* &.u */)) = pNC *(*int32)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse + 292 /* &.nHeight */)) += ((*Expr)(unsafe.Pointer(pExpr)).FnHeight) if Xsqlite3ExprCheckHeight(tls, (*Walker)(unsafe.Pointer(bp /* &w */)).FpParse, (*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse)).FnHeight) != 0 { - return 1 + return SQLITE_ERROR } Xsqlite3WalkExpr(tls, bp /* &w */, pExpr) *(*int32)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse + 292 /* &.nHeight */)) -= ((*Expr)(unsafe.Pointer(pExpr)).FnHeight) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (0x00010 | 0x08000))) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_HasAgg | NC_HasWin))) *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) |= (savedHasAgg) return (libc.Bool32(((*NameContext)(unsafe.Pointer(pNC)).FnErr > 0) || ((*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse)).FnErr > 0))) } @@ -79858,7 +79118,7 @@ func Xsqlite3ResolveExprListNames(tls *libc.TLS, pNC uintptr, pList uintptr) int // var w Walker at bp, 48 if pList == uintptr(0) { - return 0 + return WRC_Continue } (*Walker)(unsafe.Pointer(bp /* &w */)).FpParse = (*NameContext)(unsafe.Pointer(pNC)).FpParse (*Walker)(unsafe.Pointer(bp /* &w */)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct { @@ -79869,8 +79129,8 @@ func Xsqlite3ResolveExprListNames(tls *libc.TLS, pNC uintptr, pList uintptr) int }{resolveSelectStep})) (*Walker)(unsafe.Pointer(bp /* &w */)).FxSelectCallback2 = uintptr(0) *(*uintptr)(unsafe.Pointer(bp /* &w */ + 40 /* &.u */)) = pNC - savedHasAgg = ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((0x00010 | 0x01000) | 0x08000)) - *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (^libc.Int32(((0x00010 | 0x01000) | 0x08000))) + savedHasAgg = ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin)) + *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (libc.CplInt32(((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin))) for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ { var pExpr uintptr = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(i)*32)).FpExpr if pExpr == uintptr(0) { @@ -79878,22 +79138,22 @@ func Xsqlite3ResolveExprListNames(tls *libc.TLS, pNC uintptr, pList uintptr) int } *(*int32)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse + 292 /* &.nHeight */)) += ((*Expr)(unsafe.Pointer(pExpr)).FnHeight) if Xsqlite3ExprCheckHeight(tls, (*Walker)(unsafe.Pointer(bp /* &w */)).FpParse, (*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse)).FnHeight) != 0 { - return 2 + return WRC_Abort } Xsqlite3WalkExpr(tls, bp /* &w */, pExpr) *(*int32)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse + 292 /* &.nHeight */)) -= ((*Expr)(unsafe.Pointer(pExpr)).FnHeight) - if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((0x00010 | 0x01000) | 0x08000)) != 0 { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (0x00010 | 0x08000))) - savedHasAgg = savedHasAgg | ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((0x00010 | 0x01000) | 0x08000)) - *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (^libc.Int32(((0x00010 | 0x01000) | 0x08000))) + if ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin)) != 0 { + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32((*NameContext)(unsafe.Pointer(pNC)).FncFlags & (NC_HasAgg | NC_HasWin))) + savedHasAgg = savedHasAgg | ((*NameContext)(unsafe.Pointer(pNC)).FncFlags & ((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin)) + *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) &= (libc.CplInt32(((NC_HasAgg | NC_MinMaxAgg) | NC_HasWin))) } if ((*NameContext)(unsafe.Pointer(pNC)).FnErr > 0) || ((*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(bp /* &w */)).FpParse)).FnErr > 0) { - return 2 + return WRC_Abort } } *(*int32)(unsafe.Pointer(pNC + 40 /* &.ncFlags */)) |= (savedHasAgg) - return 0 + return WRC_Continue } // Resolve all names in all expressions of a SELECT and in all @@ -79954,19 +79214,19 @@ func Xsqlite3ResolveSelfReference(tls *libc.TLS, pParse uintptr, pTab uintptr, t libc.Xmemset(tls, bp+56 /* &sSrc */, 0, uint64(unsafe.Sizeof(SrcList{}))) if pTab != 0 { (*SrcList)(unsafe.Pointer(bp + 56 /* &sSrc */)).FnSrc = 1 - (*SrcList_item)(unsafe.Pointer((bp + 56 /* &sSrc */ + 8 /* &.a */) + uintptr(0)*112)).FzName = (*Table)(unsafe.Pointer(pTab)).FzName - (*SrcList_item)(unsafe.Pointer((bp + 56 /* &sSrc */ + 8 /* &.a */) + uintptr(0)*112)).FpTab = pTab - (*SrcList_item)(unsafe.Pointer((bp + 56 /* &sSrc */ + 8 /* &.a */) + uintptr(0)*112)).FiCursor = -1 - if (*Table)(unsafe.Pointer(pTab)).FpSchema != (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb+uintptr(1)*32)).FpSchema { + (*SrcList_item)(unsafe.Pointer((bp + 56 /* &sSrc */ + 8 /* &.a */))).FzName = (*Table)(unsafe.Pointer(pTab)).FzName + (*SrcList_item)(unsafe.Pointer((bp + 56 /* &sSrc */ + 8 /* &.a */))).FpTab = pTab + (*SrcList_item)(unsafe.Pointer((bp + 56 /* &sSrc */ + 8 /* &.a */))).FiCursor = -1 + if (*Table)(unsafe.Pointer(pTab)).FpSchema != (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb+1*32)).FpSchema { // Cause EP_FromDDL to be set on TK_FUNCTION nodes of non-TEMP // schema elements - type1 = type1 | (0x40000) + type1 = type1 | (NC_FromDDL) } } (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpParse = pParse (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpSrcList = bp + 56 /* &sSrc */ - (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = (type1 | 0x10000) - if (libc.AssignInt32(&rc, Xsqlite3ResolveExprNames(tls, bp /* &sNC */, pExpr))) != 0 { + (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = (type1 | NC_IsDDL) + if (libc.AssignInt32(&rc, Xsqlite3ResolveExprNames(tls, bp /* &sNC */, pExpr))) != SQLITE_OK { return rc } if pList != 0 { @@ -79981,7 +79241,7 @@ func Xsqlite3TableColumnAffinity(tls *libc.TLS, pTab uintptr, iCol int32) int8 { if iCol >= 0 { return (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*32)).Faffinity } - return int8(0x44) + return SQLITE_AFF_INTEGER } // Return the 'affinity' of the expression pExpr if any. @@ -80000,33 +79260,33 @@ func Xsqlite3TableColumnAffinity(tls *libc.TLS, pTab uintptr, iCol int32) int8 { // SELECT * FROM t1 WHERE (select a from t1); func Xsqlite3ExprAffinity(tls *libc.TLS, pExpr uintptr) int8 { /* sqlite3.c:99759:21: */ var op int32 - for ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x001000))) != U32(0) { + for ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Skip)) != U32(0) { pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft } op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop) - if op == 136 { + if op == TK_SELECT { - return Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList+8 /* &.a */)+uintptr(0)*32)).FpExpr) + return Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList + 8 /* &.a */))).FpExpr) } - if op == 173 { + if op == TK_REGISTER { op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) } - if op == 36 { + if op == TK_CAST { return Xsqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), uintptr(0)) } - if ((op == 166) || (op == 164)) && (*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) != 0) { + if ((op == TK_AGG_COLUMN) || (op == TK_COLUMN)) && (*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) != 0) { return Xsqlite3TableColumnAffinity(tls, *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)), int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)) } - if op == 175 { + if op == TK_SELECT_COLUMN { return Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft + 32 /* &.x */)))).FpEList+8 /* &.a */)+uintptr((*Expr)(unsafe.Pointer(pExpr)).FiColumn)*32)).FpExpr) } - if op == 174 { - return Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))+8 /* &.a */)+uintptr(0)*32)).FpExpr) + if op == TK_VECTOR { + return Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */))).FpExpr) } return (*Expr)(unsafe.Pointer(pExpr)).FaffExpr } @@ -80039,10 +79299,10 @@ func Xsqlite3ExprAffinity(tls *libc.TLS, pExpr uintptr) int8 { /* sqlite3.c:9975 // and the pExpr parameter is returned unchanged. func Xsqlite3ExprAddCollateToken(tls *libc.TLS, pParse uintptr, pExpr uintptr, pCollName uintptr, dequote int32) uintptr { /* sqlite3.c:99804:21: */ if (*Token)(unsafe.Pointer(pCollName)).Fn > uint32(0) { - var pNew uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 111, pCollName, dequote) + var pNew uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_COLLATE, pCollName, dequote) if pNew != 0 { (*Expr)(unsafe.Pointer(pNew)).FpLeft = pExpr - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x000100 | 0x001000)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(EP_Collate | EP_Skip)) pExpr = pNew } } @@ -80061,7 +79321,7 @@ func Xsqlite3ExprAddCollateString(tls *libc.TLS, pParse uintptr, pExpr uintptr, // Skip over any TK_COLLATE operators. func Xsqlite3ExprSkipCollate(tls *libc.TLS, pExpr uintptr) uintptr { /* sqlite3.c:99830:21: */ - for (pExpr != 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x001000))) != U32(0)) { + for (pExpr != 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Skip)) != U32(0)) { pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft } @@ -80072,10 +79332,10 @@ func Xsqlite3ExprSkipCollate(tls *libc.TLS, pExpr uintptr) uintptr { /* sqlite3. // or likelihood() or likely() functions at the root of an // expression. func Xsqlite3ExprSkipCollateAndLikely(tls *libc.TLS, pExpr uintptr) uintptr { /* sqlite3.c:99843:21: */ - for (pExpr != 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x001000 | 0x040000))) != U32(0)) { - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x040000))) != U32(0) { + for (pExpr != 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_Skip | EP_Unlikely))) != U32(0)) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Unlikely)) != U32(0) { - pExpr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + uintptr(0)*32)).FpExpr + pExpr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */))).FpExpr } else { pExpr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft @@ -80102,10 +79362,10 @@ func Xsqlite3ExprCollSeq(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr { var p uintptr = pExpr for p != 0 { var op int32 = int32((*Expr)(unsafe.Pointer(p)).Fop) - if op == 173 { + if op == TK_REGISTER { op = int32((*Expr)(unsafe.Pointer(p)).Fop2) } - if (((op == 166) || (op == 164)) || (op == 77)) && + if (((op == TK_AGG_COLUMN) || (op == TK_COLUMN)) || (op == TK_TRIGGER)) && (*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) != uintptr(0)) { // op==TK_REGISTER && p->y.pTab!=0 happens when pExpr was originally // a TK_COLUMN but was previously evaluated and cached in a register @@ -80116,20 +79376,20 @@ func Xsqlite3ExprCollSeq(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr { } break } - if (op == 36) || (op == 171) { + if (op == TK_CAST) || (op == TK_UPLUS) { p = (*Expr)(unsafe.Pointer(p)).FpLeft continue } - if op == 174 { - p = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) + 8 /* &.a */) + uintptr(0)*32)).FpExpr + if op == TK_VECTOR { + p = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) + 8 /* &.a */))).FpExpr continue } - if op == 111 { + if op == TK_COLLATE { pColl = Xsqlite3GetCollSeq(tls, pParse, (*Sqlite3)(unsafe.Pointer(db)).Fenc, uintptr(0), *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))) break } - if ((*Expr)(unsafe.Pointer(p)).Fflags & U32(0x000100)) != 0 { - if ((*Expr)(unsafe.Pointer(p)).FpLeft != 0) && (((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fflags & U32(0x000100)) != U32(0)) { + if ((*Expr)(unsafe.Pointer(p)).Fflags & EP_Collate) != 0 { + if ((*Expr)(unsafe.Pointer(p)).FpLeft != 0) && (((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fflags & EP_Collate) != U32(0)) { p = (*Expr)(unsafe.Pointer(p)).FpLeft } else { var pNext uintptr = (*Expr)(unsafe.Pointer(p)).FpRight @@ -80137,10 +79397,10 @@ func Xsqlite3ExprCollSeq(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr { if ((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != uintptr(0)) && !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0)) && - (!(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000800))) != U32(0))) { + (!(((*Expr)(unsafe.Pointer((p))).Fflags & (EP_xIsSelect)) != U32(0))) { var i int32 for i = 0; i < (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))).FnExpr; i++ { - if ((*Expr)(unsafe.Pointer(((*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) + 8 /* &.a */) + uintptr(i)*32)).FpExpr))).Fflags & (U32(0x000100))) != U32(0) { + if ((*Expr)(unsafe.Pointer(((*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) + 8 /* &.a */) + uintptr(i)*32)).FpExpr))).Fflags & (EP_Collate)) != U32(0) { pNext = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) + 8 /* &.a */) + uintptr(i)*32)).FpExpr break } @@ -80187,23 +79447,23 @@ func Xsqlite3ExprCollSeqMatch(tls *libc.TLS, pParse uintptr, pE1 uintptr, pE2 ui // type affinity that should be used for the comparison operator. func Xsqlite3CompareAffinity(tls *libc.TLS, pExpr uintptr, aff2 int8) int8 { /* sqlite3.c:99965:21: */ var aff1 int8 = Xsqlite3ExprAffinity(tls, pExpr) - if (int32(aff1) > 0x40) && (int32(aff2) > 0x40) { + if (int32(aff1) > SQLITE_AFF_NONE) && (int32(aff2) > SQLITE_AFF_NONE) { // Both sides of the comparison are columns. If one has numeric // affinity, use that. Otherwise use no affinity. - if ((int32(aff1)) >= 0x43) || ((int32(aff2)) >= 0x43) { - return int8(0x43) + if ((int32(aff1)) >= SQLITE_AFF_NUMERIC) || ((int32(aff2)) >= SQLITE_AFF_NUMERIC) { + return SQLITE_AFF_NUMERIC } else { - return int8(0x41) + return SQLITE_AFF_BLOB } } else { // One side is a column, the other is not. Use the columns affinity. return (int8((func() int32 { - if int32(aff1) <= 0x40 { + if int32(aff1) <= SQLITE_AFF_NONE { return int32(aff2) } return int32(aff1) - }()) | 0x40)) + }()) | SQLITE_AFF_NONE)) } return int8(0) } @@ -80216,10 +79476,10 @@ func comparisonAffinity(tls *libc.TLS, pExpr uintptr) int8 { /* sqlite3.c:99987: aff = Xsqlite3ExprAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) if (*Expr)(unsafe.Pointer(pExpr)).FpRight != 0 { aff = Xsqlite3CompareAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight, aff) - } else if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { - aff = Xsqlite3CompareAffinity(tls, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList+8 /* &.a */)+uintptr(0)*32)).FpExpr, aff) + } else if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { + aff = Xsqlite3CompareAffinity(tls, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList + 8 /* &.a */))).FpExpr, aff) } else if int32(aff) == 0 { - aff = int8(0x41) + aff = SQLITE_AFF_BLOB } return aff } @@ -80230,13 +79490,13 @@ func comparisonAffinity(tls *libc.TLS, pExpr uintptr) int8 { /* sqlite3.c:99987: // the comparison in pExpr. func Xsqlite3IndexAffinityOk(tls *libc.TLS, pExpr uintptr, idx_affinity int8) int32 { /* sqlite3.c:100010:20: */ var aff int8 = comparisonAffinity(tls, pExpr) - if int32(aff) < 0x42 { + if int32(aff) < SQLITE_AFF_TEXT { return 1 } - if int32(aff) == 0x42 { - return (libc.Bool32(int32(idx_affinity) == 0x42)) + if int32(aff) == SQLITE_AFF_TEXT { + return (libc.Bool32(int32(idx_affinity) == SQLITE_AFF_TEXT)) } - return (libc.Bool32((int32(idx_affinity)) >= 0x43)) + return (libc.Bool32((int32(idx_affinity)) >= SQLITE_AFF_NUMERIC)) } // Return the P5 value that should be used for a binary comparison @@ -80260,9 +79520,9 @@ func binaryCompareP5(tls *libc.TLS, pExpr1 uintptr, pExpr2 uintptr, jumpIfNull i func Xsqlite3BinaryCompareCollSeq(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintptr) uintptr { /* sqlite3.c:100047:24: */ var pColl uintptr - if ((*Expr)(unsafe.Pointer(pLeft)).Fflags & U32(0x000100)) != 0 { + if ((*Expr)(unsafe.Pointer(pLeft)).Fflags & EP_Collate) != 0 { pColl = Xsqlite3ExprCollSeq(tls, pParse, pLeft) - } else if (pRight != 0) && (((*Expr)(unsafe.Pointer(pRight)).Fflags & U32(0x000100)) != U32(0)) { + } else if (pRight != 0) && (((*Expr)(unsafe.Pointer(pRight)).Fflags & EP_Collate) != U32(0)) { pColl = Xsqlite3ExprCollSeq(tls, pParse, pRight) } else { pColl = Xsqlite3ExprCollSeq(tls, pParse, pLeft) @@ -80281,7 +79541,7 @@ func Xsqlite3BinaryCompareCollSeq(tls *libc.TLS, pParse uintptr, pLeft uintptr, // is reversed in the sqlite3BinaryCompareCollSeq() call so that the // correct collating sequence is found. func Xsqlite3ExprCompareCollSeq(tls *libc.TLS, pParse uintptr, p uintptr) uintptr { /* sqlite3.c:100075:24: */ - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000200))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_Commuted)) != U32(0) { return Xsqlite3BinaryCompareCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpRight, (*Expr)(unsafe.Pointer(p)).FpLeft) } else { return Xsqlite3BinaryCompareCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, (*Expr)(unsafe.Pointer(p)).FpRight) @@ -80327,12 +79587,12 @@ func Xsqlite3ExprIsVector(tls *libc.TLS, pExpr uintptr) int32 { /* sqlite3.c:100 // any other type of expression, return 1. func Xsqlite3ExprVectorSize(tls *libc.TLS, pExpr uintptr) int32 { /* sqlite3.c:100132:20: */ var op U8 = (*Expr)(unsafe.Pointer(pExpr)).Fop - if int32(op) == 173 { + if int32(op) == TK_REGISTER { op = (*Expr)(unsafe.Pointer(pExpr)).Fop2 } - if int32(op) == 174 { + if int32(op) == TK_VECTOR { return (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FnExpr - } else if int32(op) == 136 { + } else if int32(op) == TK_SELECT { return (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList)).FnExpr } else { return 1 @@ -80357,7 +79617,7 @@ func Xsqlite3VectorFieldSubexpr(tls *libc.TLS, pVector uintptr, i int32) uintptr if Xsqlite3ExprIsVector(tls, pVector) != 0 { - if (int32((*Expr)(unsafe.Pointer(pVector)).Fop) == 136) || (int32((*Expr)(unsafe.Pointer(pVector)).Fop2) == 136) { + if (int32((*Expr)(unsafe.Pointer(pVector)).Fop) == TK_SELECT) || (int32((*Expr)(unsafe.Pointer(pVector)).Fop2) == TK_SELECT) { return (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pVector + 32 /* &.x */)))).FpEList + 8 /* &.a */) + uintptr(i)*32)).FpExpr } else { return (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pVector + 32 /* &.x */)) + 8 /* &.a */) + uintptr(i)*32)).FpExpr @@ -80387,7 +79647,7 @@ func Xsqlite3VectorFieldSubexpr(tls *libc.TLS, pVector uintptr, i int32) uintptr // of the returned TK_SELECT_COLUMN Expr object. func Xsqlite3ExprForVectorField(tls *libc.TLS, pParse uintptr, pVector uintptr, iField int32) uintptr { /* sqlite3.c:100193:21: */ var pRet uintptr - if int32((*Expr)(unsafe.Pointer(pVector)).Fop) == 136 { + if int32((*Expr)(unsafe.Pointer(pVector)).Fop) == TK_SELECT { // The TK_SELECT_COLUMN Expr node: // @@ -80404,14 +79664,14 @@ func Xsqlite3ExprForVectorField(tls *libc.TLS, pParse uintptr, pVector uintptr, // pVector. Typically there will be multiple TK_SELECT_COLUMN nodes // with the same pLeft pointer to the pVector, but only one of them // will own the pVector. - pRet = Xsqlite3PExpr(tls, pParse, 175, uintptr(0), uintptr(0)) + pRet = Xsqlite3PExpr(tls, pParse, TK_SELECT_COLUMN, uintptr(0), uintptr(0)) if pRet != 0 { (*Expr)(unsafe.Pointer(pRet)).FiColumn = YnVar(iField) (*Expr)(unsafe.Pointer(pRet)).FpLeft = pVector } } else { - if int32((*Expr)(unsafe.Pointer(pVector)).Fop) == 174 { + if int32((*Expr)(unsafe.Pointer(pVector)).Fop) == TK_VECTOR { pVector = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pVector + 32 /* &.x */)) + 8 /* &.a */) + uintptr(iField)*32)).FpExpr } pRet = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pVector, 0) @@ -80428,7 +79688,7 @@ func Xsqlite3ExprForVectorField(tls *libc.TLS, pParse uintptr, pVector uintptr, // If pExpr is not a TK_SELECT expression, return 0. func exprCodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { /* sqlite3.c:100239:12: */ var reg int32 = 0 - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 136 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_SELECT { reg = Xsqlite3CodeSubselect(tls, pParse, pExpr) } return reg @@ -80453,11 +79713,11 @@ func exprCodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { /* func exprVectorRegister(tls *libc.TLS, pParse uintptr, pVector uintptr, iField int32, regSelect int32, ppExpr uintptr, pRegFree uintptr) int32 { /* sqlite3.c:100267:12: */ var op U8 = (*Expr)(unsafe.Pointer(pVector)).Fop - if int32(op) == 173 { + if int32(op) == TK_REGISTER { *(*uintptr)(unsafe.Pointer(ppExpr)) = Xsqlite3VectorFieldSubexpr(tls, pVector, iField) return ((*Expr)(unsafe.Pointer(pVector)).FiTable + iField) } - if int32(op) == 136 { + if int32(op) == TK_SELECT { *(*uintptr)(unsafe.Pointer(ppExpr)) = (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pVector + 32 /* &.x */)))).FpEList + 8 /* &.a */) + uintptr(iField)*32)).FpExpr return (regSelect + iField) } @@ -80487,7 +79747,7 @@ func codeVectorCompare(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, var regRight int32 = 0 var opx U8 = op var addrDone int32 = Xsqlite3VdbeMakeLabel(tls, pParse) - var isCommuted int32 = (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000200))) != U32(0))) + var isCommuted int32 = (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Commuted)) != U32(0))) if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { return @@ -80497,12 +79757,12 @@ func codeVectorCompare(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, return } - p5 = U8(int32(p5) | (0x20)) - if int32(opx) == 55 { - opx = U8(56) + p5 = U8(int32(p5) | (SQLITE_STOREP2)) + if int32(opx) == TK_LE { + opx = TK_LT } - if int32(opx) == 57 { - opx = U8(54) + if int32(opx) == TK_GE { + opx = TK_GT } regLeft = exprCodeSubselect(tls, pParse, pLeft) @@ -80527,15 +79787,15 @@ func codeVectorCompare(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, if i == (nLeft - 1) { break } - if int32(opx) == 53 { - Xsqlite3VdbeAddOp2(tls, v, 20, dest, addrDone) - p5 = U8(int32(p5) | (0x08)) - } else if int32(opx) == 52 { - Xsqlite3VdbeAddOp2(tls, v, 18, dest, addrDone) - p5 = U8(int32(p5) | (0x08)) + if int32(opx) == TK_EQ { + Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, dest, addrDone) + p5 = U8(int32(p5) | (SQLITE_KEEPNULL)) + } else if int32(opx) == TK_NE { + Xsqlite3VdbeAddOp2(tls, v, OP_If, dest, addrDone) + p5 = U8(int32(p5) | (SQLITE_KEEPNULL)) } else { - Xsqlite3VdbeAddOp2(tls, v, 58, 0, addrDone) + Xsqlite3VdbeAddOp2(tls, v, OP_ElseNotEq, 0, addrDone) if i == (nLeft - 2) { opx = op @@ -80552,12 +79812,12 @@ func Xsqlite3ExprCheckHeight(tls *libc.TLS, pParse uintptr, nHeight int32) int32 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 - var mxHeight int32 = *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + uintptr(3)*4)) + var rc int32 = SQLITE_OK + var mxHeight int32 = *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + 3*4)) if nHeight > mxHeight { Xsqlite3ErrorMsg(tls, pParse, ts+9322 /* "Expression tree ..." */, libc.VaList(bp, mxHeight)) - rc = 1 + rc = SQLITE_ERROR } return rc } @@ -80614,11 +79874,11 @@ func exprSetHeight(tls *libc.TLS, p uintptr) { /* sqlite3.c:100443:13: */ *(*int32)(unsafe.Pointer(bp /* nHeight */)) = 0 heightOfExpr(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, bp /* &nHeight */) heightOfExpr(tls, (*Expr)(unsafe.Pointer(p)).FpRight, bp /* &nHeight */) - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_xIsSelect)) != U32(0) { heightOfSelect(tls, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)), bp /* &nHeight */) } else if *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0 { heightOfExprList(tls, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)), bp /* &nHeight */) - *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= ((U32((0x000100 | 0x200000) | 0x000004)) & Xsqlite3ExprListFlags(tls, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))) + *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= ((U32((EP_Collate | EP_Subquery) | EP_HasFunc)) & Xsqlite3ExprListFlags(tls, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))) } (*Expr)(unsafe.Pointer(p)).FnHeight = (*(*int32)(unsafe.Pointer(bp /* nHeight */)) + 1) } @@ -80675,7 +79935,7 @@ func Xsqlite3ExprAlloc(tls *libc.TLS, db uintptr, op int32, pToken uintptr, dequ *(*int32)(unsafe.Pointer(bp /* iValue */)) = 0 if pToken != 0 { - if ((op != 152) || ((*Token)(unsafe.Pointer(pToken)).Fz == uintptr(0))) || + if ((op != TK_INTEGER) || ((*Token)(unsafe.Pointer(pToken)).Fz == uintptr(0))) || (Xsqlite3GetInt32(tls, (*Token)(unsafe.Pointer(pToken)).Fz, bp /* &iValue */) == 0) { nExtra = (int32((*Token)(unsafe.Pointer(pToken)).Fn + uint32(1))) @@ -80688,21 +79948,21 @@ func Xsqlite3ExprAlloc(tls *libc.TLS, db uintptr, op int32, pToken uintptr, dequ (*Expr)(unsafe.Pointer(pNew)).FiAgg = int16(-1) if pToken != 0 { if nExtra == 0 { - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32((0x000400 | 0x800000) | (func() int32 { + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32((EP_IntValue | EP_Leaf) | (func() int32 { if *(*int32)(unsafe.Pointer(bp /* iValue */)) != 0 { - return 0x10000000 + return EP_IsTrue } - return 0x20000000 + return EP_IsFalse }()))) *(*int32)(unsafe.Pointer(pNew + 8 /* &.u */)) = *(*int32)(unsafe.Pointer(bp /* iValue */)) } else { - *(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)) = (pNew + uintptr(1)*72) + *(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)) = (pNew + 1*72) if (*Token)(unsafe.Pointer(pToken)).Fn != 0 { libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)), (*Token)(unsafe.Pointer(pToken)).Fz, uint64((*Token)(unsafe.Pointer(pToken)).Fn)) } *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)) + uintptr((*Token)(unsafe.Pointer(pToken)).Fn))) = int8(0) - if (dequote != 0) && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)) + uintptr(0))))]) & 0x80) != 0) { + if (dequote != 0) && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNew + 8 /* &.u */)))))]) & 0x80) != 0) { Xsqlite3DequoteExpr(tls, pNew) } } @@ -80737,11 +79997,11 @@ func Xsqlite3ExprAttachSubtrees(tls *libc.TLS, db uintptr, pRoot uintptr, pLeft } else { if pRight != 0 { (*Expr)(unsafe.Pointer(pRoot)).FpRight = pRight - *(*U32)(unsafe.Pointer(pRoot + 4 /* &.flags */)) |= ((U32((0x000100 | 0x200000) | 0x000004)) & (*Expr)(unsafe.Pointer(pRight)).Fflags) + *(*U32)(unsafe.Pointer(pRoot + 4 /* &.flags */)) |= ((U32((EP_Collate | EP_Subquery) | EP_HasFunc)) & (*Expr)(unsafe.Pointer(pRight)).Fflags) } if pLeft != 0 { (*Expr)(unsafe.Pointer(pRoot)).FpLeft = pLeft - *(*U32)(unsafe.Pointer(pRoot + 4 /* &.flags */)) |= ((U32((0x000100 | 0x200000) | 0x000004)) & (*Expr)(unsafe.Pointer(pLeft)).Fflags) + *(*U32)(unsafe.Pointer(pRoot + 4 /* &.flags */)) |= ((U32((EP_Collate | EP_Subquery) | EP_HasFunc)) & (*Expr)(unsafe.Pointer(pLeft)).Fflags) } exprSetHeight(tls, pRoot) } @@ -80773,7 +80033,7 @@ func Xsqlite3PExpr(tls *libc.TLS, pParse uintptr, op int32, pLeft uintptr, pRigh func Xsqlite3PExprAddSelect(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSelect uintptr) { /* sqlite3.c:100632:21: */ if pExpr != 0 { *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) = pSelect - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x000800 | 0x200000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(EP_xIsSelect | EP_Subquery)) Xsqlite3ExprSetHeightAndFlags(tls, pParse, pExpr) } else { @@ -80793,13 +80053,13 @@ func Xsqlite3ExprAnd(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintpt return pRight } else if pRight == uintptr(0) { return pLeft - } else if ((((*Expr)(unsafe.Pointer((pLeft))).Fflags & (U32(0x000001 | 0x20000000))) == U32(0x20000000)) || (((*Expr)(unsafe.Pointer((pRight))).Fflags & (U32(0x000001 | 0x20000000))) == U32(0x20000000))) && - !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + } else if ((((*Expr)(unsafe.Pointer((pLeft))).Fflags & (U32(EP_FromJoin | EP_IsFalse))) == EP_IsFalse) || (((*Expr)(unsafe.Pointer((pRight))).Fflags & (U32(EP_FromJoin | EP_IsFalse))) == EP_IsFalse)) && + !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { Xsqlite3ExprDelete(tls, db, pLeft) Xsqlite3ExprDelete(tls, db, pRight) - return Xsqlite3Expr(tls, db, 152, ts+9370 /* "0" */) + return Xsqlite3Expr(tls, db, TK_INTEGER, ts+9370 /* "0" */) } else { - return Xsqlite3PExpr(tls, pParse, 44, pLeft, pRight) + return Xsqlite3PExpr(tls, pParse, TK_AND, pLeft, pRight) } return uintptr(0) } @@ -80813,20 +80073,20 @@ func Xsqlite3ExprFunction(tls *libc.TLS, pParse uintptr, pList uintptr, pToken u var pNew uintptr var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - pNew = Xsqlite3ExprAlloc(tls, db, 169, pToken, 1) + pNew = Xsqlite3ExprAlloc(tls, db, TK_FUNCTION, pToken, 1) if pNew == uintptr(0) { Xsqlite3ExprListDelete(tls, db, pList) // Avoid memory leak when malloc fails return uintptr(0) } - if (pList != 0) && ((*ExprList)(unsafe.Pointer(pList)).FnExpr > *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + uintptr(6)*4))) { + if (pList != 0) && ((*ExprList)(unsafe.Pointer(pList)).FnExpr > *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + 6*4))) { Xsqlite3ErrorMsg(tls, pParse, ts+9372 /* "too many argumen..." */, libc.VaList(bp, pToken)) } *(*uintptr)(unsafe.Pointer(pNew + 32 /* &.x */)) = pList - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x000004)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (EP_HasFunc) Xsqlite3ExprSetHeightAndFlags(tls, pParse, pNew) - if eDistinct == 0x0000001 { - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x000002)) + if eDistinct == SF_Distinct { + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (EP_Distinct) } return pNew } @@ -80844,9 +80104,9 @@ func Xsqlite3ExprFunctionUsable(tls *libc.TLS, pParse uintptr, pExpr uintptr, pD bp := tls.Alloc(8) defer tls.Free(8) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x40000000))) != U32(0) { - if (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x00080000)) != U32(0)) || - (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00000080)) == uint64(0)) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromDDL)) != U32(0) { + if (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_DIRECT) != U32(0)) || + (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_TrustedSchema) == uint64(0)) { // Functions prohibited in triggers and views if: // (1) tagged with SQLITE_DIRECTONLY // (2) not tagged with SQLITE_INNOCUOUS (which means it @@ -80886,28 +80146,28 @@ func Xsqlite3ExprAssignVarNumber(tls *libc.TLS, pParse uintptr, pExpr uintptr, n z = *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) - if int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(z + 1))) == 0 { // Wildcard of the form "?". Assign the next variable number x = libc.PreIncInt16(&(*Parse)(unsafe.Pointer(pParse)).FnVar, 1) } else { var doAdd int32 = 0 - if int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '?' { + if int32(*(*int8)(unsafe.Pointer(z))) == '?' { // Wildcard of the form "?nnn". Convert "nnn" to an integer and // use it as the variable number // var i I64 at bp+8, 8 var bOk int32 if n == U32(2) { //OPTIMIZATION-IF-TRUE - *(*I64)(unsafe.Pointer(bp + 8 /* i */)) = (I64(int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) - '0')) // The common case of ?N for a single digit N + *(*I64)(unsafe.Pointer(bp + 8 /* i */)) = (I64(int32(*(*int8)(unsafe.Pointer(z + 1))) - '0')) // The common case of ?N for a single digit N bOk = 1 } else { - bOk = (libc.Bool32(0 == Xsqlite3Atoi64(tls, (z+uintptr(1)), bp+8 /* &i */, (int32(n-U32(1))), uint8(1)))) + bOk = (libc.Bool32(0 == Xsqlite3Atoi64(tls, (z+1), bp+8 /* &i */, (int32(n-U32(1))), SQLITE_UTF8))) } - if ((bOk == 0) || (*(*I64)(unsafe.Pointer(bp + 8 /* i */)) < int64(1))) || (*(*I64)(unsafe.Pointer(bp + 8 /* i */)) > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(9)*4)))) { + if ((bOk == 0) || (*(*I64)(unsafe.Pointer(bp + 8 /* i */)) < int64(1))) || (*(*I64)(unsafe.Pointer(bp + 8 /* i */)) > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 9*4)))) { Xsqlite3ErrorMsg(tls, pParse, ts+9425, /* "variable number ..." */ - libc.VaList(bp, *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(9)*4)))) + libc.VaList(bp, *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 9*4)))) return } x = YnVar(*(*I64)(unsafe.Pointer(bp + 8 /* i */))) @@ -80932,7 +80192,7 @@ func Xsqlite3ExprAssignVarNumber(tls *libc.TLS, pParse uintptr, pExpr uintptr, n } } (*Expr)(unsafe.Pointer(pExpr)).FiColumn = x - if int32(x) > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(9)*4)) { + if int32(x) > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 9*4)) { Xsqlite3ErrorMsg(tls, pParse, ts+9468 /* "too many SQL var..." */, 0) } } @@ -80942,29 +80202,29 @@ func sqlite3ExprDeleteNN(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3.c:10 // Sanity check: Assert that the IntValue is non-negative if it exists - if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x004000 | 0x800000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(EP_TokenOnly | EP_Leaf))) != U32(0)) { // The Expr.x union is never used at the same time as Expr.pRight - if ((*Expr)(unsafe.Pointer(p)).FpLeft != 0) && (int32((*Expr)(unsafe.Pointer(p)).Fop) != 175) { + if ((*Expr)(unsafe.Pointer(p)).FpLeft != 0) && (int32((*Expr)(unsafe.Pointer(p)).Fop) != TK_SELECT_COLUMN) { sqlite3ExprDeleteNN(tls, db, (*Expr)(unsafe.Pointer(p)).FpLeft) } if (*Expr)(unsafe.Pointer(p)).FpRight != 0 { sqlite3ExprDeleteNN(tls, db, (*Expr)(unsafe.Pointer(p)).FpRight) - } else if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000800))) != U32(0) { + } else if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_xIsSelect)) != U32(0) { Xsqlite3SelectDelete(tls, db, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */))) } else { Xsqlite3ExprListDelete(tls, db, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */))) - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_WinFunc)) != U32(0) { Xsqlite3WindowDelete(tls, db, *(*uintptr)(unsafe.Pointer(p + 64 /* &.y */))) } } } - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x010000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_MemToken)) != U32(0) { Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))) } - if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x8000000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((p))).Fflags & (EP_Static)) != U32(0)) { Xsqlite3DbFreeNN(tls, db, p) } } @@ -80979,7 +80239,7 @@ func Xsqlite3ExprDelete(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3.c:100 // expression. func Xsqlite3ExprUnmapAndDelete(tls *libc.TLS, pParse uintptr, p uintptr) { /* sqlite3.c:100862:21: */ if p != 0 { - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameExprUnmap(tls, pParse, p) } sqlite3ExprDeleteNN(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p) @@ -80990,10 +80250,10 @@ func Xsqlite3ExprUnmapAndDelete(tls *libc.TLS, pParse uintptr, p uintptr) { /* s // passed as the first argument. This is always one of EXPR_FULLSIZE, // EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. func exprStructSize(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:100876:12: */ - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x004000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_TokenOnly)) != U32(0) { return int32((uintptr(0) + 16 /* &.pLeft */)) } - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x002000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_Reduced)) != U32(0) { return int32((uintptr(0) + 44 /* &.iTable */)) } return int32(unsafe.Sizeof(Expr{})) @@ -81035,16 +80295,16 @@ func dupedExprStructSize(tls *libc.TLS, p uintptr, flags int32) int32 { /* sqlit var nSize int32 // Only one flag value allowed - if ((0 == flags) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == 175)) || - (((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x1000000))) != U32(0)) { + if ((0 == flags) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_SELECT_COLUMN)) || + (((*Expr)(unsafe.Pointer((p))).Fflags & (EP_WinFunc)) != U32(0)) { nSize = int32(unsafe.Sizeof(Expr{})) } else { if ((*Expr)(unsafe.Pointer(p)).FpLeft != 0) || (*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0) { - nSize = (int32((uint64((uintptr(0) + 44 /* &.iTable */))) | uint64(0x002000))) + nSize = (int32((uint64((uintptr(0) + 44 /* &.iTable */))) | EP_Reduced)) } else { - nSize = (int32((uint64((uintptr(0) + 16 /* &.pLeft */))) | uint64(0x004000))) + nSize = (int32((uint64((uintptr(0) + 16 /* &.pLeft */))) | EP_TokenOnly)) } } return nSize @@ -81055,10 +80315,10 @@ func dupedExprStructSize(tls *libc.TLS, p uintptr, flags int32) int32 { /* sqlit // string is defined.) func dupedExprNodeSize(tls *libc.TLS, p uintptr, flags int32) int32 { /* sqlite3.c:100947:12: */ var nByte int32 = (dupedExprStructSize(tls, p, flags) & 0xfff) - if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000400))) != U32(0)) && (*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) != 0) { + if !(((*Expr)(unsafe.Pointer((p))).Fflags & (EP_IntValue)) != U32(0)) && (*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) != 0) { nByte = int32(Size_t(nByte) + ((libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))) & uint64(0x3fffffff)) + uint64(1))) } - return (((nByte) + 7) & ^libc.Int32(7)) + return (((nByte) + 7) & libc.CplInt32(7)) } // Return the number of bytes required to create a duplicate of the @@ -81076,7 +80336,7 @@ func dupedExprSize(tls *libc.TLS, p uintptr, flags int32) int32 { /* sqlite3.c:1 var nByte int32 = 0 if p != 0 { nByte = dupedExprNodeSize(tls, p, flags) - if (flags & 0x0001) != 0 { + if (flags & EXPRDUP_REDUCE) != 0 { nByte = nByte + (dupedExprSize(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, flags) + dupedExprSize(tls, (*Expr)(unsafe.Pointer(p)).FpRight, flags)) } } @@ -81101,7 +80361,7 @@ func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uint // Figure out where to write the new Expr structure. if pzBuffer != 0 { *(*uintptr)(unsafe.Pointer(bp /* zAlloc */)) = *(*uintptr)(unsafe.Pointer(pzBuffer)) - staticFlag = U32(0x8000000) + staticFlag = EP_Static } else { *(*uintptr)(unsafe.Pointer(bp /* zAlloc */)) = Xsqlite3DbMallocRawNN(tls, db, uint64(dupedExprSize(tls, p, dupFlags))) staticFlag = U32(0) @@ -81116,7 +80376,7 @@ func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uint var nStructSize uint32 = uint32(dupedExprStructSize(tls, p, dupFlags)) var nNewSize int32 = (int32(nStructSize & uint32(0xfff))) var nToken int32 - if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000400))) != U32(0)) && (*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) != 0) { + if !(((*Expr)(unsafe.Pointer((p))).Fflags & (EP_IntValue)) != U32(0)) && (*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) != 0) { nToken = (Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */))) + 1) } else { nToken = 0 @@ -81133,8 +80393,8 @@ func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uint } // Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) &= (^libc.Uint32FromInt32((((0x002000 | 0x004000) | 0x8000000) | 0x010000))) - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (nStructSize & (uint32(0x002000 | 0x004000))) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32((((EP_Reduced | EP_TokenOnly) | EP_Static) | EP_MemToken)))) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (nStructSize & (uint32(EP_Reduced | EP_TokenOnly))) *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (staticFlag) if dupFlags != 0 { @@ -81147,9 +80407,9 @@ func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uint libc.Xmemcpy(tls, zToken, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)), uint64(nToken)) } - if U32(0) == (((*Expr)(unsafe.Pointer(p)).Fflags | (*Expr)(unsafe.Pointer(pNew)).Fflags) & (U32(0x004000 | 0x800000))) { + if U32(0) == (((*Expr)(unsafe.Pointer(p)).Fflags | (*Expr)(unsafe.Pointer(pNew)).Fflags) & (U32(EP_TokenOnly | EP_Leaf))) { // Fill in the pNew->x.pSelect or pNew->x.pList member. - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_xIsSelect)) != U32(0) { *(*uintptr)(unsafe.Pointer(pNew + 32 /* &.x */)) = Xsqlite3SelectDup(tls, db, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)), dupFlags) } else { *(*uintptr)(unsafe.Pointer(pNew + 32 /* &.x */)) = Xsqlite3ExprListDup(tls, db, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)), dupFlags) @@ -81157,23 +80417,23 @@ func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uint } // Fill in pNew->pLeft and pNew->pRight. - if ((*Expr)(unsafe.Pointer((pNew))).Fflags & (U32((0x002000 | 0x004000) | 0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pNew))).Fflags & (U32((EP_Reduced | EP_TokenOnly) | EP_WinFunc))) != U32(0) { *(*uintptr)(unsafe.Pointer(bp /* zAlloc */)) += uintptr(dupedExprNodeSize(tls, p, dupFlags)) - if !(((*Expr)(unsafe.Pointer((pNew))).Fflags & (U32(0x004000 | 0x800000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pNew))).Fflags & (U32(EP_TokenOnly | EP_Leaf))) != U32(0)) { (*Expr)(unsafe.Pointer(pNew)).FpLeft = func() uintptr { if (*Expr)(unsafe.Pointer(p)).FpLeft != 0 { - return exprDup(tls, db, (*Expr)(unsafe.Pointer(p)).FpLeft, 0x0001, bp /* &zAlloc */) + return exprDup(tls, db, (*Expr)(unsafe.Pointer(p)).FpLeft, EXPRDUP_REDUCE, bp /* &zAlloc */) } return uintptr(0) }() (*Expr)(unsafe.Pointer(pNew)).FpRight = func() uintptr { if (*Expr)(unsafe.Pointer(p)).FpRight != 0 { - return exprDup(tls, db, (*Expr)(unsafe.Pointer(p)).FpRight, 0x0001, bp /* &zAlloc */) + return exprDup(tls, db, (*Expr)(unsafe.Pointer(p)).FpRight, EXPRDUP_REDUCE, bp /* &zAlloc */) } return uintptr(0) }() } - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_WinFunc)) != U32(0) { *(*uintptr)(unsafe.Pointer(pNew + 64 /* &.y */)) = Xsqlite3WindowDup(tls, db, pNew, *(*uintptr)(unsafe.Pointer(p + 64 /* &.y */))) } @@ -81181,8 +80441,8 @@ func exprDup(tls *libc.TLS, db uintptr, p uintptr, dupFlags int32, pzBuffer uint *(*uintptr)(unsafe.Pointer(pzBuffer)) = *(*uintptr)(unsafe.Pointer(bp /* zAlloc */)) } } else { - if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x004000 | 0x800000))) != U32(0)) { - if int32((*Expr)(unsafe.Pointer(pNew)).Fop) == 175 { + if !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(EP_TokenOnly | EP_Leaf))) != U32(0)) { + if int32((*Expr)(unsafe.Pointer(pNew)).Fop) == TK_SELECT_COLUMN { (*Expr)(unsafe.Pointer(pNew)).FpLeft = (*Expr)(unsafe.Pointer(p)).FpLeft } else { @@ -81221,20 +80481,20 @@ func withDup(tls *libc.TLS, db uintptr, p uintptr) uintptr { /* sqlite3.c:101096 // an a newly duplicated SELECT statement and gather all of the Window // objects found there, assembling them onto the linked list at Select->pWin. func gatherSelectWindowsCallback(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:101124:12: */ - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 169) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_FUNCTION) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) { var pSelect uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) var pWin uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) Xsqlite3WindowLink(tls, pSelect, pWin) } - return 0 + return WRC_Continue } func gatherSelectWindowsSelectCallback(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sqlite3.c:101135:12: */ if p == *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) { - return 0 + return WRC_Continue } - return 1 + return WRC_Prune } func gatherSelectWindows(tls *libc.TLS, p uintptr) { /* sqlite3.c:101138:13: */ @@ -81305,7 +80565,7 @@ __1: var pNewExpr uintptr (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr = Xsqlite3ExprDup(tls, db, pOldExpr, flags) if ((pOldExpr != 0) && - (int32((*Expr)(unsafe.Pointer(pOldExpr)).Fop) == 175)) && + (int32((*Expr)(unsafe.Pointer(pOldExpr)).Fop) == TK_SELECT_COLUMN)) && ((libc.AssignUintptr(&pNewExpr, (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr)) != uintptr(0)) { if int32((*Expr)(unsafe.Pointer(pNewExpr)).FiColumn) == 0 { @@ -81446,9 +80706,9 @@ func Xsqlite3SelectDup(tls *libc.TLS, db uintptr, pDup uintptr, flags int32) uin (*Select)(unsafe.Pointer(pNew)).FpLimit = Xsqlite3ExprDup(tls, db, (*Select)(unsafe.Pointer(p)).FpLimit, flags) (*Select)(unsafe.Pointer(pNew)).FiLimit = 0 (*Select)(unsafe.Pointer(pNew)).FiOffset = 0 - (*Select)(unsafe.Pointer(pNew)).FselFlags = ((*Select)(unsafe.Pointer(p)).FselFlags & ^libc.Uint32FromInt32(0x0000020)) - *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */) + uintptr(0)*4)) = -1 - *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */) + uintptr(1)*4)) = -1 + (*Select)(unsafe.Pointer(pNew)).FselFlags = ((*Select)(unsafe.Pointer(p)).FselFlags & libc.Uint32FromInt32(libc.CplInt32(SF_UsesEphemeral))) + *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */))) = -1 + *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */) + 1*4)) = -1 (*Select)(unsafe.Pointer(pNew)).FnSelectRow = (*Select)(unsafe.Pointer(p)).FnSelectRow (*Select)(unsafe.Pointer(pNew)).FpWith = withDup(tls, db, (*Select)(unsafe.Pointer(p)).FpWith) (*Select)(unsafe.Pointer(pNew)).FpWin = uintptr(0) @@ -81570,7 +80830,7 @@ __2: // the size of the RHS and LHS match. But if the RHS is a SELECT, // wildcards ("*") in the result set of the SELECT must be expanded before // we can do the size check, so defer the size check until code generation. - if !((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 136) && ((*IdList)(unsafe.Pointer(pColumns)).FnId != (libc.AssignInt32(&n, Xsqlite3ExprVectorSize(tls, pExpr))))) { + if !((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_SELECT) && ((*IdList)(unsafe.Pointer(pColumns)).FnId != (libc.AssignInt32(&n, Xsqlite3ExprVectorSize(tls, pExpr))))) { goto __3 } Xsqlite3ErrorMsg(tls, pParse, ts+9491, /* "%d columns assig..." */ @@ -81610,7 +80870,7 @@ __5: __6: ; - if !((!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 136)) && (pList != uintptr(0))) { + if !((!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_SELECT)) && (pList != uintptr(0))) { goto __9 } pFirst = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(iFirst)*32)).FpExpr @@ -81642,14 +80902,14 @@ func Xsqlite3ExprListSetSortOrder(tls *libc.TLS, p uintptr, iSortOrder int32, eN pItem = ((p + 8 /* &.a */) + uintptr(((*ExprList)(unsafe.Pointer(p)).FnExpr-1))*32) if iSortOrder == -1 { - iSortOrder = 0 + iSortOrder = SQLITE_SO_ASC } (*ExprList_item)(unsafe.Pointer(pItem)).FsortFlags = U8(iSortOrder) if eNulls != -1 { libc.SetBitFieldPtr8Uint32(pItem+20 /* &.bNulls */, uint32(1), 5, 0x20) if iSortOrder != eNulls { - *(*U8)(unsafe.Pointer(pItem + 16 /* &.sortFlags */)) |= U8((0x02)) + *(*U8)(unsafe.Pointer(pItem + 16 /* &.sortFlags */)) |= U8((KEYINFO_ORDER_BIGNULL)) } } } @@ -81673,7 +80933,7 @@ func Xsqlite3ExprListSetName(tls *libc.TLS, pParse uintptr, pList uintptr, pName // statement handled by the parser. And so no token need be added // to the token-map. Xsqlite3Dequote(tls, (*ExprList_item)(unsafe.Pointer(pItem)).FzEName) - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameTokenMap(tls, pParse, (*ExprList_item)(unsafe.Pointer(pItem)).FzEName, pName) } } @@ -81694,7 +80954,7 @@ func Xsqlite3ExprListSetSpan(tls *libc.TLS, pParse uintptr, pList uintptr, zStar if (*ExprList_item)(unsafe.Pointer(pItem)).FzEName == uintptr(0) { (*ExprList_item)(unsafe.Pointer(pItem)).FzEName = Xsqlite3DbSpanDup(tls, db, zStart, zEnd) - libc.SetBitFieldPtr8Uint32(pItem+20 /* &.eEName */, uint32(1), 0, 0x3) + libc.SetBitFieldPtr8Uint32(pItem+20 /* &.eEName */, ENAME_SPAN, 0, 0x3) } } } @@ -81705,7 +80965,7 @@ func Xsqlite3ExprListCheckLength(tls *libc.TLS, pParse uintptr, pEList uintptr, bp := tls.Alloc(8) defer tls.Free(8) - var mx int32 = *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + uintptr(2)*4)) + var mx int32 = *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + 2*4)) if (pEList != 0) && ((*ExprList)(unsafe.Pointer(pEList)).FnExpr > mx) { Xsqlite3ErrorMsg(tls, pParse, ts+9521 /* "too many columns..." */, libc.VaList(bp, zObject)) @@ -81753,7 +81013,7 @@ func Xsqlite3ExprListFlags(tls *libc.TLS, pList uintptr) U32 { /* sqlite3.c:1015 func Xsqlite3SelectWalkFail(tls *libc.TLS, pWalker uintptr, NotUsed uintptr) int32 { /* sqlite3.c:101611:20: */ _ = NotUsed (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 + return WRC_Abort } // Check the input string to see if it is "true" or "false" (in any case). @@ -81764,10 +81024,10 @@ func Xsqlite3SelectWalkFail(tls *libc.TLS, pWalker uintptr, NotUsed uintptr) int // anything else 0 func Xsqlite3IsTrueOrFalse(tls *libc.TLS, zIn uintptr) U32 { /* sqlite3.c:101625:20: */ if Xsqlite3StrICmp(tls, zIn, ts+9544 /* "true" */) == 0 { - return U32(0x10000000) + return EP_IsTrue } if Xsqlite3StrICmp(tls, zIn, ts+9549 /* "false" */) == 0 { - return U32(0x20000000) + return EP_IsFalse } return U32(0) } @@ -81778,9 +81038,9 @@ func Xsqlite3IsTrueOrFalse(tls *libc.TLS, zIn uintptr) U32 { /* sqlite3.c:101625 func Xsqlite3ExprIdToTrueFalse(tls *libc.TLS, pExpr uintptr) int32 { /* sqlite3.c:101637:20: */ var v U32 - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x4000000))) != U32(0)) && + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Quoted)) != U32(0)) && ((libc.AssignUint32(&v, Xsqlite3IsTrueOrFalse(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */))))) != U32(0)) { - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(167) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_TRUEFALSE *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (v) return 1 } @@ -81792,7 +81052,7 @@ func Xsqlite3ExprIdToTrueFalse(tls *libc.TLS, pExpr uintptr) int32 { /* sqlite3. func Xsqlite3ExprTruthValue(tls *libc.TLS, pExpr uintptr) int32 { /* sqlite3.c:101654:20: */ pExpr = Xsqlite3ExprSkipCollate(tls, pExpr) - return (libc.Bool32(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + uintptr(4)))) == 0)) + return (libc.Bool32(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + 4))) == 0)) } // If pExpr is an AND or OR expression, try to simplify it by eliminating @@ -81808,17 +81068,17 @@ func Xsqlite3ExprTruthValue(tls *libc.TLS, pExpr uintptr) int32 { /* sqlite3.c:1 // (y=22) OR true => true func Xsqlite3ExprSimplifiedAndOr(tls *libc.TLS, pExpr uintptr) uintptr { /* sqlite3.c:101675:21: */ - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 44) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 43) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_OR) { var pRight uintptr = Xsqlite3ExprSimplifiedAndOr(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) var pLeft uintptr = Xsqlite3ExprSimplifiedAndOr(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) - if (((*Expr)(unsafe.Pointer((pLeft))).Fflags & (U32(0x000001 | 0x10000000))) == U32(0x10000000)) || (((*Expr)(unsafe.Pointer((pRight))).Fflags & (U32(0x000001 | 0x20000000))) == U32(0x20000000)) { - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 44 { + if (((*Expr)(unsafe.Pointer((pLeft))).Fflags & (U32(EP_FromJoin | EP_IsTrue))) == EP_IsTrue) || (((*Expr)(unsafe.Pointer((pRight))).Fflags & (U32(EP_FromJoin | EP_IsFalse))) == EP_IsFalse) { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND { pExpr = pRight } else { pExpr = pLeft } - } else if (((*Expr)(unsafe.Pointer((pRight))).Fflags & (U32(0x000001 | 0x10000000))) == U32(0x10000000)) || (((*Expr)(unsafe.Pointer((pLeft))).Fflags & (U32(0x000001 | 0x20000000))) == U32(0x20000000)) { - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 44 { + } else if (((*Expr)(unsafe.Pointer((pRight))).Fflags & (U32(EP_FromJoin | EP_IsTrue))) == EP_IsTrue) || (((*Expr)(unsafe.Pointer((pLeft))).Fflags & (U32(EP_FromJoin | EP_IsFalse))) == EP_IsFalse) { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND { pExpr = pLeft } else { pExpr = pRight @@ -81857,75 +81117,72 @@ func exprNodeIsConstant(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { / // If pWalker->eCode is 2 then any term of the expression that comes from // the ON or USING clauses of a left join disqualifies the expression // from being considered constant. - if (int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 2) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0)) { + if (int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 2) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0)) { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 + return WRC_Abort } switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) { // Consider functions to be constant if all their arguments are constant // and either pWalker->eCode==4 or 5 or the function has the // SQLITE_FUNC_CONST flag. - case 169: - if ((int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) >= 4) || (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x080000))) != U32(0))) && - !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + case TK_FUNCTION: + if ((int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) >= 4) || (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_ConstFunc)) != U32(0))) && + !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) { if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 5 { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x40000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_FromDDL) } - return 0 + return WRC_Continue } else { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 + return WRC_Abort } fallthrough - case 59: + case TK_ID: // Convert "true" or "false" in a DEFAULT clause into the // appropriate TK_TRUEFALSE operator if Xsqlite3ExprIdToTrueFalse(tls, pExpr) != 0 { - return 1 + return WRC_Prune } - /* no break */ fallthrough - case 164: + case TK_COLUMN: fallthrough - case 165: + case TK_AGG_FUNCTION: fallthrough - case 166: + case TK_AGG_COLUMN: - if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000008))) != U32(0)) && (int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) != 2) { - return 0 + if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FixedCol)) != U32(0)) && (int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) != 2) { + return WRC_Continue } if (int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 3) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == *(*int32)(unsafe.Pointer(pWalker + 40 /* &.u */))) { - return 0 + return WRC_Continue } - /* no break */ fallthrough - case 176: + case TK_IF_NULL_ROW: fallthrough - case 173: + case TK_REGISTER: fallthrough - case 139: + case TK_DOT: (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 - case 153: + return WRC_Abort + case TK_VARIABLE: if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 5 { // Silently convert bound parameters that appear inside of CREATE // statements into a NULL when parsing the CREATE statement text out // of the sqlite_schema table - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(119) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_NULL } else if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 4 { // A bound parameter in a CREATE statement that originates from // sqlite3_prepare() causes an error (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 + return WRC_Abort } - /* no break */ fallthrough default: // sqlite3SelectWalkFail() disallows // sqlite3SelectWalkFail() disallows - return 0 + return WRC_Continue } return int32(0) } @@ -81993,15 +81250,15 @@ func exprNodeIsConstantOrGroupBy(tls *libc.TLS, pWalker uintptr, pExpr uintptr) if Xsqlite3ExprCompare(tls, uintptr(0), pExpr, p, -1) < 2 { var pColl uintptr = Xsqlite3ExprNNCollSeq(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p) if Xsqlite3IsBinary(tls, pColl) != 0 { - return 1 + return WRC_Prune } } } // Check if pExpr is a sub-select. If so, consider it variable. - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 + return WRC_Abort } return exprNodeIsConstant(tls, pWalker, pExpr) @@ -82081,18 +81338,18 @@ func Xsqlite3ExprIsInteger(tls *libc.TLS, p uintptr, pValue uintptr) int32 { /* // If an expression is an integer literal that fits in a signed 32-bit // integer, then the EP_IntValue flag will have already been set - if ((*Expr)(unsafe.Pointer(p)).Fflags & U32(0x000400)) != 0 { + if ((*Expr)(unsafe.Pointer(p)).Fflags & EP_IntValue) != 0 { *(*int32)(unsafe.Pointer(pValue)) = *(*int32)(unsafe.Pointer(p + 8 /* &.u */)) return 1 } switch int32((*Expr)(unsafe.Pointer(p)).Fop) { - case 171: + case TK_UPLUS: { rc = Xsqlite3ExprIsInteger(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, pValue) break } - case 170: + case TK_UMINUS: { // var v int32 at bp, 4 @@ -82124,24 +81381,24 @@ func Xsqlite3ExprIsInteger(tls *libc.TLS, p uintptr, pValue uintptr) int32 { /* // TRUE. func Xsqlite3ExprCanBeNull(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:101995:20: */ var op U8 - for (int32((*Expr)(unsafe.Pointer(p)).Fop) == 171) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == 170) { + for (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UPLUS) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UMINUS) { p = (*Expr)(unsafe.Pointer(p)).FpLeft } op = (*Expr)(unsafe.Pointer(p)).Fop - if int32(op) == 173 { + if int32(op) == TK_REGISTER { op = (*Expr)(unsafe.Pointer(p)).Fop2 } switch int32(op) { - case 152: + case TK_INTEGER: fallthrough - case 115: + case TK_STRING: fallthrough - case 150: + case TK_FLOAT: fallthrough - case 151: + case TK_BLOB: return 0 - case 164: - return (libc.Bool32(((((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x100000))) != U32(0)) || (*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) == uintptr(0))) || (((int32((*Expr)(unsafe.Pointer(p)).FiColumn) >= 0) && + case TK_COLUMN: + return (libc.Bool32(((((*Expr)(unsafe.Pointer((p))).Fflags & (EP_CanBeNull)) != U32(0)) || (*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) == uintptr(0))) || (((int32((*Expr)(unsafe.Pointer(p)).FiColumn) >= 0) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)))).FaCol != uintptr(0))) && // Defense against OOM problems (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)))).FaCol+uintptr((*Expr)(unsafe.Pointer(p)).FiColumn)*32)).FnotNull) == 0)))) default: @@ -82161,44 +81418,44 @@ func Xsqlite3ExprCanBeNull(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:101995 func Xsqlite3ExprNeedsNoAffinityChange(tls *libc.TLS, p uintptr, aff int8) int32 { /* sqlite3.c:102029:20: */ var op U8 var unaryMinus int32 = 0 - if int32(aff) == 0x41 { + if int32(aff) == SQLITE_AFF_BLOB { return 1 } - for (int32((*Expr)(unsafe.Pointer(p)).Fop) == 171) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == 170) { - if int32((*Expr)(unsafe.Pointer(p)).Fop) == 170 { + for (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UPLUS) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UMINUS) { + if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_UMINUS { unaryMinus = 1 } p = (*Expr)(unsafe.Pointer(p)).FpLeft } op = (*Expr)(unsafe.Pointer(p)).Fop - if int32(op) == 173 { + if int32(op) == TK_REGISTER { op = (*Expr)(unsafe.Pointer(p)).Fop2 } switch int32(op) { - case 152: + case TK_INTEGER: { - return (libc.Bool32(int32(aff) >= 0x43)) + return (libc.Bool32(int32(aff) >= SQLITE_AFF_NUMERIC)) } - case 150: + case TK_FLOAT: { - return (libc.Bool32(int32(aff) >= 0x43)) + return (libc.Bool32(int32(aff) >= SQLITE_AFF_NUMERIC)) } - case 115: + case TK_STRING: { - return (libc.Bool32(!(unaryMinus != 0) && (int32(aff) == 0x42))) + return (libc.Bool32(!(unaryMinus != 0) && (int32(aff) == SQLITE_AFF_TEXT))) } - case 151: + case TK_BLOB: { return libc.BoolInt32(!(unaryMinus != 0)) } - case 164: + case TK_COLUMN: { // p cannot be part of a CHECK constraint - return (libc.Bool32((int32(aff) >= 0x43) && (int32((*Expr)(unsafe.Pointer(p)).FiColumn) < 0))) + return (libc.Bool32((int32(aff) >= SQLITE_AFF_NUMERIC) && (int32((*Expr)(unsafe.Pointer(p)).FiColumn) < 0))) } default: @@ -82235,17 +81492,17 @@ func isCandidateForInOpt(tls *libc.TLS, pX uintptr) uintptr { /* sqlite3.c:10208 var pEList uintptr var pTab uintptr var i int32 - if !(((*Expr)(unsafe.Pointer((pX))).Fflags & (U32(0x000800))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pX))).Fflags & (EP_xIsSelect)) != U32(0)) { return uintptr(0) } // Not a subquery - if ((*Expr)(unsafe.Pointer((pX))).Fflags & (U32(0x000020))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pX))).Fflags & (EP_VarSelect)) != U32(0) { return uintptr(0) } // Correlated subq p = *(*uintptr)(unsafe.Pointer(pX + 32 /* &.x */)) if (*Select)(unsafe.Pointer(p)).FpPrior != 0 { return uintptr(0) } // Not a compound SELECT - if ((*Select)(unsafe.Pointer(p)).FselFlags & (U32(0x0000001 | 0x0000008))) != 0 { + if ((*Select)(unsafe.Pointer(p)).FselFlags & (U32(SF_Distinct | SF_Aggregate))) != 0 { return uintptr(0) // No DISTINCT keyword and no aggregate functions } @@ -82261,10 +81518,10 @@ func isCandidateForInOpt(tls *libc.TLS, pX uintptr) uintptr { /* sqlite3.c:10208 if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc != 1 { return uintptr(0) } // Single term in FROM clause - if (*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(0)*112)).FpSelect != 0 { + if (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FpSelect != 0 { return uintptr(0) } // FROM is not a subquery or view - pTab = (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab + pTab = (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FpTab // FROM clause is not a view if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { @@ -82275,7 +81532,7 @@ func isCandidateForInOpt(tls *libc.TLS, pX uintptr) uintptr { /* sqlite3.c:10208 // All SELECT results must be columns. for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ { var pRes uintptr = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(i)*32)).FpExpr - if int32((*Expr)(unsafe.Pointer(pRes)).Fop) != 164 { + if int32((*Expr)(unsafe.Pointer(pRes)).Fop) != TK_COLUMN { return uintptr(0) } // Not a correlated subquery @@ -82292,10 +81549,10 @@ func sqlite3SetHasNullFlag(tls *libc.TLS, v uintptr, iCur int32, regHasNull int3 defer tls.Free(8) var addr1 int32 - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regHasNull) - addr1 = Xsqlite3VdbeAddOp1(tls, v, 37, iCur) - Xsqlite3VdbeAddOp3(tls, v, 89, iCur, 0, regHasNull) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x80)) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regHasNull) + addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iCur) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iCur, 0, regHasNull) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_TYPEOFARG) Xsqlite3VdbeComment(tls, v, ts+9573 /* "first_entry_in(%..." */, libc.VaList(bp, iCur)) Xsqlite3VdbeJumpHere(tls, v, addr1) } @@ -82401,14 +81658,14 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, var mustBeUnique int32 // True if RHS must be unique var v uintptr = Xsqlite3GetVdbe(tls, pParse) // Virtual machine being coded - mustBeUnique = (libc.Bool32((inFlags & U32(0x0004)) != U32(0))) + mustBeUnique = (libc.Bool32((inFlags & IN_INDEX_LOOP) != U32(0))) // If the RHS of this IN(...) operator is a SELECT, and if it matters // whether or not the SELECT result contains NULL values, check whether // or not NULL is actually possible (it may not be, for example, due // to NOT NULL constraints in the schema). If no NULL values are possible, // set prRhsHasNull to 0 before continuing. - if (prRhsHasNull != 0) && (((*Expr)(unsafe.Pointer(pX)).Fflags & U32(0x000800)) != 0) { + if (prRhsHasNull != 0) && (((*Expr)(unsafe.Pointer(pX)).Fflags & EP_xIsSelect) != 0) { var i int32 var pEList uintptr = (*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32 /* &.x */)))).FpEList for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ { @@ -82434,7 +81691,7 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, // Because of isCandidateForInOpt(p) // Because of isCandidateForInOpt(p) // Because of isCandidateForInOpt(p) - pTab = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab + pTab = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpTab // Code an OP_Transaction and OP_TableLock for
  • . iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) @@ -82443,12 +81700,12 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, uint8(0), (*Table)(unsafe.Pointer(pTab)).FzName) // sqlite3GetVdbe() has always been previously called - if (nExpr == 1) && (int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(0)*32)).FpExpr)).FiColumn) < 0) { + if (nExpr == 1) && (int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */))).FpExpr)).FiColumn) < 0) { // The "x IN (SELECT rowid FROM table)" case - var iAddr int32 = Xsqlite3VdbeAddOp0(tls, v, 17) + var iAddr int32 = Xsqlite3VdbeAddOp0(tls, v, OP_Once) - Xsqlite3OpenTable(tls, pParse, iTab, iDb, pTab, 96) - eType = 1 + Xsqlite3OpenTable(tls, pParse, iTab, iDb, pTab, OP_OpenRead) + eType = IN_INDEX_ROWID Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+9592 /* "USING ROWID SEAR..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName)) Xsqlite3VdbeJumpHere(tls, v, iAddr) } else { @@ -82467,10 +81724,10 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, var cmpaff int8 = Xsqlite3CompareAffinity(tls, pLhs, idxaff) switch int32(cmpaff) { - case 0x41: + case SQLITE_AFF_BLOB: break fallthrough - case 0x42: + case SQLITE_AFF_TEXT: // sqlite3CompareAffinity() only returns TEXT if one side or the // other has no affinity and the other side is TEXT. Hence, // the only way for cmpaff to be TEXT is for idxaff to be TEXT @@ -82479,7 +81736,7 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, break fallthrough default: - affinity_ok = (libc.Bool32((int32(idxaff)) >= 0x43)) + affinity_ok = (libc.Bool32((int32(idxaff)) >= SQLITE_AFF_NUMERIC)) } } @@ -82502,7 +81759,7 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, } if mustBeUnique != 0 { if (int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) > nExpr) || - ((int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) > nExpr) && !(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0)) { + ((int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) > nExpr) && !(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None)) { continue // This index is not unique over the IN RHS columns } } @@ -82539,13 +81796,13 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, if colUsed == ((Bitmask((uint64(1))) << (nExpr)) - uint64(1)) { // If we reach this point, that means the index pIdx is usable - var iAddr int32 = Xsqlite3VdbeAddOp0(tls, v, 17) + var iAddr int32 = Xsqlite3VdbeAddOp0(tls, v, OP_Once) Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+9639 /* "USING INDEX %s F..." */, libc.VaList(bp+8, (*Index)(unsafe.Pointer(pIdx)).FzName)) - Xsqlite3VdbeAddOp3(tls, v, 96, iTab, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, iTab, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx) Xsqlite3VdbeComment(tls, v, ts+824 /* "%s" */, libc.VaList(bp+16, (*Index)(unsafe.Pointer(pIdx)).FzName)) - eType = (3 + int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(0))))) + eType = (IN_INDEX_INDEX_ASC + int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder)))) if prRhsHasNull != 0 { *(*int32)(unsafe.Pointer(prRhsHasNull)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) @@ -82567,10 +81824,10 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, // then it is not worth creating an ephemeral table to evaluate // the IN operator so return IN_INDEX_NOOP. if (((eType == 0) && - ((inFlags & U32(0x0001)) != 0)) && - !(((*Expr)(unsafe.Pointer((pX))).Fflags & (U32(0x000800))) != U32(0))) && + ((inFlags & IN_INDEX_NOOP_OK) != 0)) && + !(((*Expr)(unsafe.Pointer((pX))).Fflags & (EP_xIsSelect)) != U32(0))) && (!(sqlite3InRhsIsConstant(tls, pX) != 0) || ((*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32 /* &.x */)))).FnExpr <= 2)) { - eType = 5 + eType = IN_INDEX_NOOP } if eType == 0 { @@ -82578,8 +81835,8 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, // We will have to generate an ephemeral table to do the job. var savedNQueryLoop U32 = (*Parse)(unsafe.Pointer(pParse)).FnQueryLoop var rMayHaveNull int32 = 0 - eType = 2 - if (inFlags & U32(0x0004)) != 0 { + eType = IN_INDEX_EPH + if (inFlags & IN_INDEX_LOOP) != 0 { (*Parse)(unsafe.Pointer(pParse)).FnQueryLoop = U32(0) } else if prRhsHasNull != 0 { *(*int32)(unsafe.Pointer(prRhsHasNull)) = libc.AssignInt32(&rMayHaveNull, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)) @@ -82592,7 +81849,7 @@ func Xsqlite3FindInIndex(tls *libc.TLS, pParse uintptr, pX uintptr, inFlags U32, (*Parse)(unsafe.Pointer(pParse)).FnQueryLoop = savedNQueryLoop } - if ((aiMap != 0) && (eType != 3)) && (eType != 4) { + if ((aiMap != 0) && (eType != IN_INDEX_INDEX_ASC)) && (eType != IN_INDEX_INDEX_DESC) { var i int32 var n int32 n = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pX)).FpLeft) @@ -82614,7 +81871,7 @@ func exprINAffinity(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr { /* s var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft var nVal int32 = Xsqlite3ExprVectorSize(tls, pLeft) var pSelect uintptr - if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & U32(0x000800)) != 0 { + if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & EP_xIsSelect) != 0 { pSelect = *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) } else { pSelect = uintptr(0) @@ -82662,7 +81919,7 @@ func Xsqlite3SubselectError(tls *libc.TLS, pParse uintptr, nActual int32, nExpec // // "row value misused" func Xsqlite3VectorErrorMsg(tls *libc.TLS, pParse uintptr, pExpr uintptr) { /* sqlite3.c:102509:21: */ - if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & U32(0x000800)) != 0 { + if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & EP_xIsSelect) != 0 { Xsqlite3SubselectError(tls, pParse, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList)).FnExpr, 1) } else { Xsqlite3ErrorMsg(tls, pParse, ts+8423 /* "row value misuse..." */, 0) @@ -82711,30 +81968,30 @@ func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int3 // // If all of the above are false, then we can compute the RHS just once // and reuse it many names. - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000020))) != U32(0)) && ((*Parse)(unsafe.Pointer(pParse)).FiSelfTab == 0) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_VarSelect)) != U32(0)) && ((*Parse)(unsafe.Pointer(pParse)).FiSelfTab == 0) { // Reuse of the RHS is allowed // If this routine has already been coded, but the previous code // might not have been invoked yet, so invoke it now as a subroutine. - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x2000000))) != U32(0) { - addrOnce = Xsqlite3VdbeAddOp0(tls, v, 17) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Subrtn)) != U32(0) { + addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once) + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+9714 /* "REUSE LIST SUBQU..." */, libc.VaList(bp, (*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FselId)) } - Xsqlite3VdbeAddOp2(tls, v, 12, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */)), + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */)), *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ /* &.iAddr */))) - Xsqlite3VdbeAddOp2(tls, v, 98, iTab, (*Expr)(unsafe.Pointer(pExpr)).FiTable) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, iTab, (*Expr)(unsafe.Pointer(pExpr)).FiTable) Xsqlite3VdbeJumpHere(tls, v, addrOnce) return } // Begin coding the subroutine - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x2000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Subrtn) *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ /* &.iAddr */)) = (Xsqlite3VdbeAddOp2(tls, v, 69, 0, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) + 1) + *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ /* &.iAddr */)) = (Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) + 1) Xsqlite3VdbeComment(tls, v, ts+9737 /* "return address" */, 0) - addrOnce = Xsqlite3VdbeAddOp0(tls, v, 17) + addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once) } // Check to see if this is a vector IN operator @@ -82744,15 +82001,15 @@ func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int3 // Construct the ephemeral table that will contain the content of // RHS of the IN operator. (*Expr)(unsafe.Pointer(pExpr)).FiTable = iTab - addr = Xsqlite3VdbeAddOp2(tls, v, 100, (*Expr)(unsafe.Pointer(pExpr)).FiTable, nVal) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + addr = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*Expr)(unsafe.Pointer(pExpr)).FiTable, nVal) + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { Xsqlite3VdbeComment(tls, v, ts+9752 /* "Result of SELECT..." */, libc.VaList(bp+8, (*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FselId)) } else { Xsqlite3VdbeComment(tls, v, ts+9772 /* "RHS of IN operat..." */, 0) } pKeyInfo = Xsqlite3KeyInfoAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, nVal, 1) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { // Case 1: expr IN (SELECT ...) // // Generate code to write the results of the select into the temporary @@ -82772,7 +82029,7 @@ func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int3 // var dest SelectDest at bp+32, 40 var i int32 - Xsqlite3SelectDestInit(tls, bp+32 /* &dest */, 11, iTab) + Xsqlite3SelectDestInit(tls, bp+32 /* &dest */, SRT_Set, iTab) (*SelectDest)(unsafe.Pointer(bp + 32 /* &dest */)).FzAffSdst = exprINAffinity(tls, pParse, pExpr) (*Select)(unsafe.Pointer(pSelect)).FiLimit = 0 @@ -82806,14 +82063,14 @@ func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int3 var r1 int32 var r2 int32 *(*int8)(unsafe.Pointer(bp + 72 /* affinity */)) = Xsqlite3ExprAffinity(tls, pLeft) - if int32(*(*int8)(unsafe.Pointer(bp + 72 /* affinity */))) <= 0x40 { - *(*int8)(unsafe.Pointer(bp + 72 /* affinity */)) = int8(0x41) - } else if int32(*(*int8)(unsafe.Pointer(bp + 72 /* affinity */))) == 0x45 { - *(*int8)(unsafe.Pointer(bp + 72 /* affinity */)) = int8(0x43) + if int32(*(*int8)(unsafe.Pointer(bp + 72 /* affinity */))) <= SQLITE_AFF_NONE { + *(*int8)(unsafe.Pointer(bp + 72 /* affinity */)) = SQLITE_AFF_BLOB + } else if int32(*(*int8)(unsafe.Pointer(bp + 72 /* affinity */))) == SQLITE_AFF_REAL { + *(*int8)(unsafe.Pointer(bp + 72 /* affinity */)) = SQLITE_AFF_NUMERIC } if pKeyInfo != 0 { - *(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */) + uintptr(0)*8)) = Xsqlite3ExprCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) + *(*uintptr)(unsafe.Pointer((pKeyInfo + 32 /* &.aColl */))) = Xsqlite3ExprCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) } // Loop through each expression in . @@ -82834,14 +82091,14 @@ func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int3 // expression we need to rerun this code each time. if (addrOnce != 0) && !(Xsqlite3ExprIsConstant(tls, pE2) != 0) { Xsqlite3VdbeChangeToNoop(tls, v, addrOnce) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(0x2000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(EP_Subrtn))) addrOnce = 0 } // Evaluate the expression and insert it into the temp table Xsqlite3ExprCode(tls, pParse, pE2, r1) - Xsqlite3VdbeAddOp4(tls, v, 91, r1, 1, r2, bp+72 /* &affinity */, 1) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iTab, r2, r1, 1) + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, r1, 1, r2, bp+72 /* &affinity */, 1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iTab, r2, r1, 1) } goto __2 @@ -82861,7 +82118,7 @@ func Xsqlite3CodeRhsOfIN(tls *libc.TLS, pParse uintptr, pExpr uintptr, iTab int3 if addrOnce != 0 { Xsqlite3VdbeJumpHere(tls, v, addrOnce) // Subroutine return - Xsqlite3VdbeAddOp1(tls, v, 65, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) Xsqlite3VdbeChangeP1(tls, v, (*(*int32)(unsafe.Pointer((pExpr + 64 /* &.y */ /* &.sub */) /* &.iAddr */)) - 1), (Xsqlite3VdbeCurrentAddr(tls, v) - 1)) Xsqlite3ClearTempRegCache(tls, pParse) } @@ -82904,23 +82161,23 @@ func Xsqlite3CodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { // // If all of the above are false, then we can run this code just once // save the results, and reuse the same result on subsequent invocations. - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000020))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_VarSelect)) != U32(0)) { // If this routine has already been coded, then invoke it as a // subroutine. - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x2000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Subrtn)) != U32(0) { Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+9822 /* "REUSE SUBQUERY %..." */, libc.VaList(bp, (*Select)(unsafe.Pointer(pSel)).FselId)) - Xsqlite3VdbeAddOp2(tls, v, 12, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */)), + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */)), *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ /* &.iAddr */))) return (*Expr)(unsafe.Pointer(pExpr)).FiTable } // Begin coding the subroutine - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x2000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Subrtn) *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ /* &.iAddr */)) = (Xsqlite3VdbeAddOp2(tls, v, 69, 0, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) + 1) + *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ /* &.iAddr */)) = (Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) + 1) Xsqlite3VdbeComment(tls, v, ts+9737 /* "return address" */, 0) - addrOnce = Xsqlite3VdbeAddOp0(tls, v, 17) + addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once) } // For a SELECT, generate code to put the values for all columns of @@ -82938,40 +82195,40 @@ func Xsqlite3CodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { } return ts + 9810 /* "CORRELATED " */ }(), (*Select)(unsafe.Pointer(pSel)).FselId)) - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 136 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_SELECT { nReg = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpEList)).FnExpr } else { nReg = 1 } Xsqlite3SelectDestInit(tls, bp+24 /* &dest */, 0, ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1)) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (nReg) - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 136 { - (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FeDest = U8(10) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_SELECT { + (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FeDest = SRT_Mem (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FiSdst = (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FiSDParm (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FnSdst = nReg - Xsqlite3VdbeAddOp3(tls, v, 72, 0, (*SelectDest)(unsafe.Pointer(bp+24 /* &dest */)).FiSDParm, (((*SelectDest)(unsafe.Pointer(bp+24 /* &dest */)).FiSDParm + nReg) - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, (*SelectDest)(unsafe.Pointer(bp+24 /* &dest */)).FiSDParm, (((*SelectDest)(unsafe.Pointer(bp+24 /* &dest */)).FiSDParm + nReg) - 1)) Xsqlite3VdbeComment(tls, v, ts+9861 /* "Init subquery re..." */, 0) } else { - (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FeDest = U8(3) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, (*SelectDest)(unsafe.Pointer(bp+24 /* &dest */)).FiSDParm) + (*SelectDest)(unsafe.Pointer(bp + 24 /* &dest */)).FeDest = SRT_Exists + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*SelectDest)(unsafe.Pointer(bp+24 /* &dest */)).FiSDParm) Xsqlite3VdbeComment(tls, v, ts+9882 /* "Init EXISTS resu..." */, 0) } if (*Select)(unsafe.Pointer(pSel)).FpLimit != 0 { // The subquery already has a limit. If the pre-existing limit is X // then make the new limit X<>0 so that the new limit is either 1 or 0 var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - pLimit = Xsqlite3Expr(tls, db, 152, ts+9370 /* "0" */) + pLimit = Xsqlite3Expr(tls, db, TK_INTEGER, ts+9370 /* "0" */) if pLimit != 0 { - (*Expr)(unsafe.Pointer(pLimit)).FaffExpr = int8(0x43) - pLimit = Xsqlite3PExpr(tls, pParse, 52, + (*Expr)(unsafe.Pointer(pLimit)).FaffExpr = SQLITE_AFF_NUMERIC + pLimit = Xsqlite3PExpr(tls, pParse, TK_NE, Xsqlite3ExprDup(tls, db, (*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpLimit)).FpLeft, 0), pLimit) } Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpLimit)).FpLeft) (*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpLimit)).FpLeft = pLimit } else { // If there is no pre-existing limit add a limit of 1 - pLimit = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 152, ts+9901 /* "1" */) - (*Select)(unsafe.Pointer(pSel)).FpLimit = Xsqlite3PExpr(tls, pParse, 146, pLimit, uintptr(0)) + pLimit = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_INTEGER, ts+9901 /* "1" */) + (*Select)(unsafe.Pointer(pSel)).FpLimit = Xsqlite3PExpr(tls, pParse, TK_LIMIT, pLimit, uintptr(0)) } (*Select)(unsafe.Pointer(pSel)).FiLimit = 0 if Xsqlite3Select(tls, pParse, pSel, bp+24 /* &dest */) != 0 { @@ -82983,7 +82240,7 @@ func Xsqlite3CodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { Xsqlite3VdbeJumpHere(tls, v, addrOnce) // Subroutine return - Xsqlite3VdbeAddOp1(tls, v, 65, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, *(*int32)(unsafe.Pointer(pExpr + 64 /* &.y */ /* &.sub */ + 4 /* &.regReturn */))) Xsqlite3VdbeChangeP1(tls, v, (*(*int32)(unsafe.Pointer((pExpr + 64 /* &.y */ /* &.sub */) /* &.iAddr */)) - 1), (Xsqlite3VdbeCurrentAddr(tls, v) - 1)) Xsqlite3ClearTempRegCache(tls, pParse) } @@ -82997,7 +82254,7 @@ func Xsqlite3CodeSubselect(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { // a sub-query, that the LHS is a vector of size 1. func Xsqlite3ExprCheckIN(tls *libc.TLS, pParse uintptr, pIn uintptr) int32 { /* sqlite3.c:102846:20: */ var nVector int32 = Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pIn)).FpLeft) - if ((*Expr)(unsafe.Pointer(pIn)).Fflags & U32(0x000800)) != 0 { + if ((*Expr)(unsafe.Pointer(pIn)).Fflags & EP_xIsSelect) != 0 { if nVector != (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIn + 32 /* &.x */)))).FpEList)).FnExpr { Xsqlite3SubselectError(tls, pParse, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pIn + 32 /* &.x */)))).FpEList)).FnExpr, nVector) return 1 @@ -83104,7 +82361,7 @@ __2: // OOM detected prior to this routine Xsqlite3VdbeNoopComment(tls, v, ts+9903 /* "begin IN expr" */, 0) eType = Xsqlite3FindInIndex(tls, pParse, pExpr, - (uint32(0x0002 | 0x0001)), + (uint32(IN_INDEX_MEMBERSHIP | IN_INDEX_NOOP_OK)), func() uintptr { if destIfFalse == destIfNull { return uintptr(0) @@ -83155,7 +82412,7 @@ __8: if !(i < nVector) { goto __10 } - Xsqlite3VdbeAddOp3(tls, v, 77, (rLhsOrig + i), (rLhs + *(*int32)(unsafe.Pointer(aiMap + uintptr(i)*4))), 0) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, (rLhsOrig + i), (rLhs + *(*int32)(unsafe.Pointer(aiMap + uintptr(i)*4))), 0) goto __9 __9: i++ @@ -83171,7 +82428,7 @@ __7: // sequence of comparisons. // // This is step (1) in the in-operator.md optimized algorithm. - if !(eType == 5) { + if !(eType == IN_INDEX_NOOP) { goto __11 } pList = *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) @@ -83183,7 +82440,7 @@ __7: goto __12 } regCkNull = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 101, rLhs, rLhs, regCkNull) + Xsqlite3VdbeAddOp3(tls, v, OP_BitAnd, rLhs, rLhs, regCkNull) __12: ; ii = 0 @@ -83195,7 +82452,7 @@ __13: if !((regCkNull != 0) && (Xsqlite3ExprCanBeNull(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(ii)*32)).FpExpr) != 0)) { goto __16 } - Xsqlite3VdbeAddOp3(tls, v, 101, regCkNull, r2, regCkNull) + Xsqlite3VdbeAddOp3(tls, v, OP_BitAnd, regCkNull, r2, regCkNull) __16: ; Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 12 /* regToFree */))) @@ -83203,26 +82460,26 @@ __16: goto __17 } if rLhs != r2 { - op = 53 + op = OP_Eq } else { - op = 51 + op = OP_NotNull } Xsqlite3VdbeAddOp4(tls, v, op, rLhs, labelOk, r2, pColl, -2) - Xsqlite3VdbeChangeP5(tls, v, uint16(*(*int8)(unsafe.Pointer(zAff + uintptr(0))))) + Xsqlite3VdbeChangeP5(tls, v, uint16(*(*int8)(unsafe.Pointer(zAff)))) goto __18 __17: if rLhs != r2 { - op1 = 52 + op1 = OP_Ne } else { - op1 = 50 + op1 = OP_IsNull } Xsqlite3VdbeAddOp4(tls, v, op1, rLhs, destIfFalse, r2, pColl, -2) - Xsqlite3VdbeChangeP5(tls, v, (uint16(int32(*(*int8)(unsafe.Pointer(zAff + uintptr(0)))) | 0x10))) + Xsqlite3VdbeChangeP5(tls, v, (uint16(int32(*(*int8)(unsafe.Pointer(zAff))) | SQLITE_JUMPIFNULL))) __18: ; goto __14 @@ -83235,7 +82492,7 @@ __15: if !(regCkNull != 0) { goto __19 } - Xsqlite3VdbeAddOp2(tls, v, 50, regCkNull, destIfNull) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regCkNull, destIfNull) Xsqlite3VdbeGoto(tls, v, destIfFalse) __19: ; @@ -83272,7 +82529,7 @@ __23: if !(Xsqlite3ExprCanBeNull(tls, p) != 0) { goto __26 } - Xsqlite3VdbeAddOp2(tls, v, 50, (rLhs + i), destStep2) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (rLhs + i), destStep2) __26: ; @@ -83287,29 +82544,29 @@ __25: // Step 3. The LHS is now known to be non-NULL. Do the binary search // of the RHS using the LHS as a probe. If found, the result is // true. - if !(eType == 1) { + if !(eType == IN_INDEX_ROWID) { goto __27 } // In this case, the RHS is the ROWID of table b-tree and so we also // know that the RHS is non-NULL. Hence, we combine steps 3 and 4 // into a single opcode. - Xsqlite3VdbeAddOp3(tls, v, 31, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), destIfFalse, rLhs) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), destIfFalse, rLhs) - addrTruthOp = Xsqlite3VdbeAddOp0(tls, v, 11) // Return True + addrTruthOp = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) // Return True goto __28 __27: - Xsqlite3VdbeAddOp4(tls, v, 90, rLhs, nVector, 0, zAff, nVector) + Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, rLhs, nVector, 0, zAff, nVector) if !(destIfFalse == destIfNull) { goto __29 } // Combine Step 3 and Step 5 into a single opcode - Xsqlite3VdbeAddOp4Int(tls, v, 29, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), destIfFalse, + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), destIfFalse, rLhs, nVector) goto sqlite3ExprCodeIN_finished __29: ; // Ordinary Step 3, for the case where FALSE and NULL are distinct - addrTruthOp = Xsqlite3VdbeAddOp4Int(tls, v, 30, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), 0, + addrTruthOp = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), 0, rLhs, nVector) __28: ; @@ -83319,7 +82576,7 @@ __28: if !((*(*int32)(unsafe.Pointer(bp /* rRhsHasNull */)) != 0) && (nVector == 1)) { goto __30 } - Xsqlite3VdbeAddOp2(tls, v, 51, *(*int32)(unsafe.Pointer(bp /* rRhsHasNull */)), destIfFalse) + Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, *(*int32)(unsafe.Pointer(bp /* rRhsHasNull */)), destIfFalse) __30: ; @@ -83345,7 +82602,7 @@ __31: Xsqlite3VdbeResolveLabel(tls, v, destStep6) __32: ; - addrTop = Xsqlite3VdbeAddOp2(tls, v, 37, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), destIfFalse) + addrTop = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), destIfFalse) if !(nVector > 1) { goto __33 @@ -83366,8 +82623,8 @@ __35: r3 = Xsqlite3GetTempReg(tls, pParse) p1 = Xsqlite3VectorFieldSubexpr(tls, pLeft, i) pColl1 = Xsqlite3ExprCollSeq(tls, pParse, p1) - Xsqlite3VdbeAddOp3(tls, v, 89, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), i, r3) - Xsqlite3VdbeAddOp4(tls, v, 52, (rLhs + i), destNotNull, r3, + Xsqlite3VdbeAddOp3(tls, v, OP_Column, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), i, r3) + Xsqlite3VdbeAddOp4(tls, v, OP_Ne, (rLhs + i), destNotNull, r3, pColl1, -2) Xsqlite3ReleaseTempReg(tls, pParse, r3) @@ -83378,16 +82635,16 @@ __36: goto __37 __37: ; - Xsqlite3VdbeAddOp2(tls, v, 11, 0, destIfNull) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, destIfNull) if !(nVector > 1) { goto __38 } Xsqlite3VdbeResolveLabel(tls, v, destNotNull) - Xsqlite3VdbeAddOp2(tls, v, 5, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), (addrTop + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, *(*int32)(unsafe.Pointer(bp + 4 /* iTab */)), (addrTop + 1)) // Step 7: If we reach this point, we know that the result must // be false. - Xsqlite3VdbeAddOp2(tls, v, 11, 0, destIfFalse) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, destIfFalse) __38: ; @@ -83420,12 +82677,12 @@ func codeReal(tls *libc.TLS, v uintptr, z uintptr, negateFlag int32, iMem int32) if z != uintptr(0) { // var value float64 at bp, 8 - Xsqlite3AtoF(tls, z, bp /* &value */, Xsqlite3Strlen30(tls, z), uint8(1)) + Xsqlite3AtoF(tls, z, bp /* &value */, Xsqlite3Strlen30(tls, z), SQLITE_UTF8) // The new AtoF never returns NaN if negateFlag != 0 { *(*float64)(unsafe.Pointer(bp /* value */)) = -*(*float64)(unsafe.Pointer(bp /* value */)) } - Xsqlite3VdbeAddOp4Dup8(tls, v, 150, 0, iMem, 0, bp /* &value */, -13) + Xsqlite3VdbeAddOp4Dup8(tls, v, OP_Real, 0, iMem, 0, bp /* &value */, -13) } } @@ -83438,13 +82695,13 @@ func codeInteger(tls *libc.TLS, pParse uintptr, pExpr uintptr, negFlag int32, iM defer tls.Free(24) var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe - if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & U32(0x000400)) != 0 { + if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & EP_IntValue) != 0 { var i int32 = *(*int32)(unsafe.Pointer(pExpr + 8 /* &.u */)) if negFlag != 0 { i = -i } - Xsqlite3VdbeAddOp2(tls, v, 69, i, iMem) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, i, iMem) } else { var c int32 // var value I64 at bp+16, 8 @@ -83471,7 +82728,7 @@ func codeInteger(tls *libc.TLS, pParse uintptr, pExpr uintptr, negFlag int32, iM *(*I64)(unsafe.Pointer(bp + 16 /* value */)) = -*(*I64)(unsafe.Pointer(bp + 16 /* value */)) } } - Xsqlite3VdbeAddOp4Dup8(tls, v, 70, 0, iMem, 0, bp+16 /* &value */, -14) + Xsqlite3VdbeAddOp4Dup8(tls, v, OP_Int64, 0, iMem, 0, bp+16 /* &value */, -14) } } } @@ -83498,13 +82755,13 @@ func Xsqlite3ExprCodeGeneratedColumn(tls *libc.TLS, pParse uintptr, pCol uintptr var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe if (*Parse)(unsafe.Pointer(pParse)).FiSelfTab > 0 { - iAddr = Xsqlite3VdbeAddOp3(tls, v, 21, ((*Parse)(unsafe.Pointer(pParse)).FiSelfTab - 1), 0, regOut) + iAddr = Xsqlite3VdbeAddOp3(tls, v, OP_IfNullRow, ((*Parse)(unsafe.Pointer(pParse)).FiSelfTab - 1), 0, regOut) } else { iAddr = 0 } Xsqlite3ExprCodeCopy(tls, pParse, (*Column)(unsafe.Pointer(pCol)).FpDflt, regOut) - if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) >= 0x42 { - Xsqlite3VdbeAddOp4(tls, v, 90, regOut, 1, 0, (pCol + 25 /* &.affinity */), 1) + if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) >= SQLITE_AFF_TEXT { + Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, regOut, 1, 0, (pCol + 25 /* &.affinity */), 1) } if iAddr != 0 { Xsqlite3VdbeJumpHere(tls, v, iAddr) @@ -83519,38 +82776,38 @@ func Xsqlite3ExprCodeGetColumnOfTable(tls *libc.TLS, v uintptr, pTab uintptr, iT var pCol uintptr if pTab == uintptr(0) { - Xsqlite3VdbeAddOp3(tls, v, 89, iTabCur, iCol, regOut) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iTabCur, iCol, regOut) return } if (iCol < 0) || (iCol == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) { - Xsqlite3VdbeAddOp2(tls, v, 127, iTabCur, regOut) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iTabCur, regOut) } else { var op int32 var x int32 if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { - op = 166 + op = OP_VColumn x = iCol - } else if (int32((*Column)(unsafe.Pointer((libc.AssignUintptr(&pCol, ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*32))))).FcolFlags) & 0x0020) != 0 { + } else if (int32((*Column)(unsafe.Pointer((libc.AssignUintptr(&pCol, ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*32))))).FcolFlags) & COLFLAG_VIRTUAL) != 0 { var pParse uintptr = Xsqlite3VdbeParser(tls, v) - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0100) != 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_BUSY) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+9958 /* "generated column..." */, libc.VaList(bp, (*Column)(unsafe.Pointer(pCol)).FzName)) } else { var savedSelfTab int32 = (*Parse)(unsafe.Pointer(pParse)).FiSelfTab - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((0x0100)) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((COLFLAG_BUSY)) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = (iTabCur + 1) Xsqlite3ExprCodeGeneratedColumn(tls, pParse, pCol, regOut) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = savedSelfTab - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0100))) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(COLFLAG_BUSY))) } return - } else if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + } else if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { x = int32(Xsqlite3TableColumnToIndex(tls, Xsqlite3PrimaryKeyIndex(tls, pTab), int16(iCol))) - op = 89 + op = OP_Column } else { x = int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(iCol))) - op = 89 + op = OP_Column } Xsqlite3VdbeAddOp3(tls, v, op, iTabCur, x, regOut) Xsqlite3ColumnDefault(tls, v, pTab, iCol, regOut) @@ -83567,7 +82824,7 @@ func Xsqlite3ExprCodeGetColumn(tls *libc.TLS, pParse uintptr, pTab uintptr, iCol Xsqlite3ExprCodeGetColumnOfTable(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, pTab, iTable, iColumn, iReg) if p5 != 0 { var pOp uintptr = Xsqlite3VdbeGetOp(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, -1) - if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 89 { + if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column { (*VdbeOp)(unsafe.Pointer(pOp)).Fp5 = U16(p5) } } @@ -83577,7 +82834,7 @@ func Xsqlite3ExprCodeGetColumn(tls *libc.TLS, pParse uintptr, pTab uintptr, iCol // Generate code to move content from registers iFrom...iFrom+nReg-1 // over to iTo..iTo+nReg-1. func Xsqlite3ExprCodeMove(tls *libc.TLS, pParse uintptr, iFrom int32, iTo int32, nReg int32) { /* sqlite3.c:103326:21: */ - Xsqlite3VdbeAddOp3(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, 76, iFrom, iTo, nReg) + Xsqlite3VdbeAddOp3(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_Move, iFrom, iTo, nReg) } // Convert a scalar expression node to a TK_REGISTER referencing @@ -83586,9 +82843,9 @@ func Xsqlite3ExprCodeMove(tls *libc.TLS, pParse uintptr, iFrom int32, iTo int32, func exprToRegister(tls *libc.TLS, pExpr uintptr, iReg int32) { /* sqlite3.c:103335:13: */ var p uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, pExpr) (*Expr)(unsafe.Pointer(p)).Fop2 = (*Expr)(unsafe.Pointer(p)).Fop - (*Expr)(unsafe.Pointer(p)).Fop = U8(173) + (*Expr)(unsafe.Pointer(p)).Fop = TK_REGISTER (*Expr)(unsafe.Pointer(p)).FiTable = iReg - *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(0x001000)) + *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(EP_Skip))) } // Evaluate an expression (either a vector or a scalar expression) and store @@ -83606,7 +82863,7 @@ func exprCodeVector(tls *libc.TLS, pParse uintptr, p uintptr, piFreeable uintptr iResult = Xsqlite3ExprCodeTemp(tls, pParse, p, piFreeable) } else { *(*int32)(unsafe.Pointer(piFreeable)) = 0 - if int32((*Expr)(unsafe.Pointer(p)).Fop) == 136 { + if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_SELECT { iResult = Xsqlite3CodeSubselect(tls, pParse, p) } else { var i int32 @@ -83623,7 +82880,7 @@ func exprCodeVector(tls *libc.TLS, pParse uintptr, p uintptr, piFreeable uintptr // If the last opcode is a OP_Copy, then set the do-not-merge flag (p5) // so that a subsequent copy will not be merged into this one. func setDoNotMergeFlagOnCopy(tls *libc.TLS, v uintptr) { /* sqlite3.c:103382:13: */ - if int32((*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, v, -1))).Fopcode) == 77 { + if int32((*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, v, -1))).Fopcode) == OP_Copy { Xsqlite3VdbeChangeP5(tls, v, uint16(1)) // Tag trailing OP_Copy as not mergable } } @@ -83640,7 +82897,7 @@ func exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncI nFarg = (*ExprList)(unsafe.Pointer(pFarg)).FnExpr // All in-line functions have at least one argument switch iFuncId { - case 0: + case INLINEFUNC_coalesce: { // Attempt a direct implementation of the built-in COALESCE() and // IFNULL() functions. This avoids unnecessary evaluation of @@ -83648,9 +82905,9 @@ func exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncI var endCoalesce int32 = Xsqlite3VdbeMakeLabel(tls, pParse) var i int32 - Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(0)*32)).FpExpr, target) + Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */))).FpExpr, target) for i = 1; i < nFarg; i++ { - Xsqlite3VdbeAddOp2(tls, v, 51, target, endCoalesce) + Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, target, endCoalesce) Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(i)*32)).FpExpr, target) } @@ -83659,12 +82916,12 @@ func exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncI break } - case 5: + case INLINEFUNC_iif: { // var caseExpr Expr at bp, 72 libc.Xmemset(tls, bp /* &caseExpr */, 0, uint64(unsafe.Sizeof(Expr{}))) - (*Expr)(unsafe.Pointer(bp /* &caseExpr */)).Fop = U8(154) + (*Expr)(unsafe.Pointer(bp /* &caseExpr */)).Fop = TK_CASE *(*uintptr)(unsafe.Pointer(bp /* &caseExpr */ + 32 /* &.x */)) = pFarg return Xsqlite3ExprCodeTarget(tls, pParse, bp /* &caseExpr */, target) @@ -83675,7 +82932,7 @@ func exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncI // The UNLIKELY() function is a no-op. The result is the value // of the first argument. - target = Xsqlite3ExprCodeTarget(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(0)*32)).FpExpr, target) + target = Xsqlite3ExprCodeTarget(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */))).FpExpr, target) break } @@ -83684,40 +82941,40 @@ func exprCodeInlineFunction(tls *libc.TLS, pParse uintptr, pFarg uintptr, iFuncI // // Test-only SQL functions that are only usable if enabled // via SQLITE_TESTCTRL_INTERNAL_FUNCTIONS - case 3: + case INLINEFUNC_expr_compare: { // Compare two expressions using sqlite3ExprCompare() - Xsqlite3VdbeAddOp2(tls, v, 69, - Xsqlite3ExprCompare(tls, uintptr(0), (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(0)*32)).FpExpr, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(1)*32)).FpExpr, -1), + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, + Xsqlite3ExprCompare(tls, uintptr(0), (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */))).FpExpr, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+1*32)).FpExpr, -1), target) break } - case 2: + case INLINEFUNC_expr_implies_expr: { // Compare two expressions using sqlite3ExprImpliesExpr() - Xsqlite3VdbeAddOp2(tls, v, 69, - Xsqlite3ExprImpliesExpr(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(0)*32)).FpExpr, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(1)*32)).FpExpr, -1), + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, + Xsqlite3ExprImpliesExpr(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */))).FpExpr, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+1*32)).FpExpr, -1), target) break } - case 1: + case INLINEFUNC_implies_nonnull_row: { // REsult of sqlite3ExprImpliesNonNullRow() var pA1 uintptr - pA1 = (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */) + uintptr(1)*32)).FpExpr - if int32((*Expr)(unsafe.Pointer(pA1)).Fop) == 164 { - Xsqlite3VdbeAddOp2(tls, v, 69, - Xsqlite3ExprImpliesNonNullRow(tls, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(0)*32)).FpExpr, (*Expr)(unsafe.Pointer(pA1)).FiTable), + pA1 = (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */) + 1*32)).FpExpr + if int32((*Expr)(unsafe.Pointer(pA1)).Fop) == TK_COLUMN { + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, + Xsqlite3ExprImpliesNonNullRow(tls, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */))).FpExpr, (*Expr)(unsafe.Pointer(pA1)).FiTable), target) } else { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target) } break @@ -83848,7 +83105,7 @@ expr_code_doover: if !(pExpr == uintptr(0)) { goto __1 } - op = 119 + op = TK_NULL goto __2 __1: ; @@ -83856,92 +83113,92 @@ __1: __2: ; switch op { - case 166: + case TK_AGG_COLUMN: goto __4 - case 164: + case TK_COLUMN: goto __5 - case 152: + case TK_INTEGER: goto __6 - case 167: + case TK_TRUEFALSE: goto __7 - case 150: + case TK_FLOAT: goto __8 - case 115: + case TK_STRING: goto __9 default: goto __10 - case 151: + case TK_BLOB: goto __11 - case 153: + case TK_VARIABLE: goto __12 - case 173: + case TK_REGISTER: goto __13 - case 36: + case TK_CAST: goto __14 - case 45: + case TK_IS: goto __15 - case 168: + case TK_ISNOT: goto __16 // fall-through - case 56: + case TK_LT: goto __17 - case 55: + case TK_LE: goto __18 - case 54: + case TK_GT: goto __19 - case 57: + case TK_GE: goto __20 - case 52: + case TK_NE: goto __21 - case 53: + case TK_EQ: goto __22 - case 44: + case TK_AND: goto __23 - case 43: + case TK_OR: goto __24 - case 105: + case TK_PLUS: goto __25 - case 107: + case TK_STAR: goto __26 - case 106: + case TK_MINUS: goto __27 - case 109: + case TK_REM: goto __28 - case 101: + case TK_BITAND: goto __29 - case 102: + case TK_BITOR: goto __30 - case 108: + case TK_SLASH: goto __31 - case 103: + case TK_LSHIFT: goto __32 - case 104: + case TK_RSHIFT: goto __33 - case 110: + case TK_CONCAT: goto __34 - case 170: + case TK_UMINUS: goto __35 - case 112: + case TK_BITNOT: goto __36 - case 19: + case TK_NOT: goto __37 - case 172: + case TK_TRUTH: goto __38 - case 50: + case TK_ISNULL: goto __39 - case 51: + case TK_NOTNULL: goto __40 - case 165: + case TK_AGG_FUNCTION: goto __41 - case 169: + case TK_FUNCTION: goto __42 - case 20: + case TK_EXISTS: goto __43 - case 136: + case TK_SELECT: goto __44 - case 175: + case TK_SELECT_COLUMN: goto __45 - case 49: + case TK_IN: goto __46 // x BETWEEN y AND z @@ -83953,19 +83210,19 @@ __2: // X is stored in pExpr->pLeft. // Y is stored in pExpr->pList->a[0].pExpr. // Z is stored in pExpr->pList->a[1].pExpr. - case 48: + case TK_BETWEEN: goto __47 - case 178: + case TK_SPAN: goto __48 - case 111: + case TK_COLLATE: goto __49 - case 171: + case TK_UPLUS: goto __50 - case 77: + case TK_TRIGGER: goto __51 - case 174: + case TK_VECTOR: goto __52 // TK_IF_NULL_ROW Expr nodes are inserted ahead of expressions @@ -83973,7 +83230,7 @@ __2: // Expr.iTable value is the table number for the right-hand table. // The expression is only evaluated if that table is not currently // on a LEFT JOIN NULL row. - case 176: + case TK_IF_NULL_ROW: goto __53 // Form A: @@ -83995,9 +83252,9 @@ __2: // The result of the expression is the Ri for the first matching Ei, // or if there is no matching Ei, the ELSE term Y, or if there is // no ELSE term, NULL. - case 154: + case TK_CASE: goto __54 - case 71: + case TK_RAISE: goto __55 } goto __3 @@ -84016,7 +83273,7 @@ __56: goto __58 } pTab = (*AggInfo_col)(unsafe.Pointer(pCol)).FpTab - Xsqlite3VdbeAddOp3(tls, v, 89, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab, + Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab, int32((*AggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn), target) if !(int32((*AggInfo_col)(unsafe.Pointer(pCol)).FiColumn) < 0) { goto __59 @@ -84025,10 +83282,10 @@ __56: goto __60 __59: Xsqlite3VdbeComment(tls, v, ts+9997 /* "%s.%s" */, libc.VaList(bp+8, (*Table)(unsafe.Pointer(pTab)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*AggInfo_col)(unsafe.Pointer(pCol)).FiColumn)*32)).FzName)) - if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*AggInfo_col)(unsafe.Pointer(pCol)).FiColumn)*32)).Faffinity) == 0x45) { + if !(int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*AggInfo_col)(unsafe.Pointer(pCol)).FiColumn)*32)).Faffinity) == SQLITE_AFF_REAL) { goto __61 } - Xsqlite3VdbeAddOp1(tls, v, 83, target) + Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, target) __61: ; __60: @@ -84038,12 +83295,10 @@ __58: ; __57: ; - // Otherwise, fall thru into the TK_COLUMN case - /* no break */ __5: iTab = (*Expr)(unsafe.Pointer(pExpr)).FiTable - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000008))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FixedCol)) != U32(0)) { goto __62 } iReg = Xsqlite3ExprCodeTarget(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, target) @@ -84056,11 +83311,11 @@ __63: aff = int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) __64: ; - if !(aff > 0x41) { + if !(aff > SQLITE_AFF_BLOB) { goto __65 } - Xsqlite3VdbeAddOp4(tls, v, 90, iReg, 1, 0, + Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, iReg, 1, 0, (uintptr(unsafe.Pointer(&zAff)) + uintptr(((aff - 'B') * 2))), -1) __65: ; @@ -84085,10 +83340,10 @@ __69: pCol1 = ((*Table)(unsafe.Pointer(pTab1)).FaCol + uintptr(iCol)*32) iSrc = (int32(Xsqlite3TableColumnToStorage(tls, pTab1, int16(iCol))) - (*Parse)(unsafe.Pointer(pParse)).FiSelfTab) - if !((int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags) & 0x0060) != 0) { + if !((int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags) & COLFLAG_GENERATED) != 0) { goto __70 } - if !((int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags) & 0x0100) != 0) { + if !((int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags) & COLFLAG_BUSY) != 0) { goto __72 } Xsqlite3ErrorMsg(tls, pParse, ts+9958, /* "generated column..." */ @@ -84096,22 +83351,22 @@ __69: return 0 __72: ; - *(*U16)(unsafe.Pointer(pCol1 + 28 /* &.colFlags */)) |= U16((0x0100)) - if !((int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags) & 0x0080) != 0) { + *(*U16)(unsafe.Pointer(pCol1 + 28 /* &.colFlags */)) |= U16((COLFLAG_BUSY)) + if !((int32((*Column)(unsafe.Pointer(pCol1)).FcolFlags) & COLFLAG_NOTAVAIL) != 0) { goto __73 } Xsqlite3ExprCodeGeneratedColumn(tls, pParse, pCol1, iSrc) __73: ; - *(*U16)(unsafe.Pointer(pCol1 + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((^libc.Int32((0x0100 | 0x0080)))) + *(*U16)(unsafe.Pointer(pCol1 + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((libc.CplInt32((COLFLAG_BUSY | COLFLAG_NOTAVAIL)))) return iSrc goto __71 __70: - if !(int32((*Column)(unsafe.Pointer(pCol1)).Faffinity) == 0x45) { + if !(int32((*Column)(unsafe.Pointer(pCol1)).Faffinity) == SQLITE_AFF_REAL) { goto __74 } - Xsqlite3VdbeAddOp2(tls, v, 78, iSrc, target) - Xsqlite3VdbeAddOp1(tls, v, 83, target) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, iSrc, target) + Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, target) return target goto __75 __74: @@ -84132,10 +83387,10 @@ __66: iReg = Xsqlite3ExprCodeGetColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)), int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn), iTab, target, (*Expr)(unsafe.Pointer(pExpr)).Fop2) - if !((*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) == uintptr(0)) && (int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == 0x45)) { + if !((*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) == uintptr(0)) && (int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == SQLITE_AFF_REAL)) { goto __76 } - Xsqlite3VdbeAddOp1(tls, v, 83, iReg) + Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, iReg) __76: ; return iReg @@ -84145,7 +83400,7 @@ __6: return target __7: - Xsqlite3VdbeAddOp2(tls, v, 69, Xsqlite3ExprTruthValue(tls, pExpr), target) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, Xsqlite3ExprTruthValue(tls, pExpr), target) return target __8: @@ -84164,29 +83419,29 @@ __10: // sanely and not crash. But keep the assert() to bring the problem // to the attention of the developers. ; - Xsqlite3VdbeAddOp2(tls, v, 72, 0, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target) return target __11: ; - z = (*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + uintptr(2)) + z = (*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + 2) n = (Xsqlite3Strlen30(tls, z) - 1) zBlob = Xsqlite3HexToBlob(tls, Xsqlite3VdbeDb(tls, v), z, n) - Xsqlite3VdbeAddOp4(tls, v, 74, (n / 2), target, 0, zBlob, -7) + Xsqlite3VdbeAddOp4(tls, v, OP_Blob, (n / 2), target, 0, zBlob, -7) return target __12: ; - Xsqlite3VdbeAddOp2(tls, v, 75, int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn), target) - if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + uintptr(1)))) != 0) { + Xsqlite3VdbeAddOp2(tls, v, OP_Variable, int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn), target) + if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)) + 1))) != 0) { goto __77 } z1 = Xsqlite3VListNumToName(tls, (*Parse)(unsafe.Pointer(pParse)).FpVList, int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)) - *(*VList)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).FpVList + uintptr(0)*4)) = 0 // Indicate VList may no longer be enlarged + *(*VList)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).FpVList)) = 0 // Indicate VList may no longer be enlarged Xsqlite3VdbeAppendP4(tls, v, z1, -1) __77: ; @@ -84201,22 +83456,22 @@ __14: if !(inReg != target) { goto __78 } - Xsqlite3VdbeAddOp2(tls, v, 78, inReg, target) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, inReg, target) inReg = target __78: ; - Xsqlite3VdbeAddOp2(tls, v, 84, target, + Xsqlite3VdbeAddOp2(tls, v, OP_Cast, target, int32(Xsqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), uintptr(0)))) return inReg __15: __16: - if op == 45 { - op = 53 + if op == TK_IS { + op = TK_EQ } else { - op = 52 + op = TK_NE } - p5 = 0x80 + p5 = SQLITE_NULLEQ // fall-through __17: __18: @@ -84234,8 +83489,8 @@ __79: r1 = Xsqlite3ExprCodeTemp(tls, pParse, pLeft, bp+88 /* ®Free1 */) r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+92 /* ®Free2 */) codeCompare(tls, pParse, pLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight, op, - r1, r2, inReg, (0x20 | p5), - (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000200))) != U32(0)))) + r1, r2, inReg, (SQLITE_STOREP2 | p5), + (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Commuted)) != U32(0)))) __80: ; @@ -84264,14 +83519,14 @@ __34: __35: pLeft1 = (*Expr)(unsafe.Pointer(pExpr)).FpLeft - if !(int32((*Expr)(unsafe.Pointer(pLeft1)).Fop) == 152) { + if !(int32((*Expr)(unsafe.Pointer(pLeft1)).Fop) == TK_INTEGER) { goto __81 } codeInteger(tls, pParse, pLeft1, 1, target) return target goto __82 __81: - if !(int32((*Expr)(unsafe.Pointer(pLeft1)).Fop) == 150) { + if !(int32((*Expr)(unsafe.Pointer(pLeft1)).Fop) == TK_FLOAT) { goto __83 } @@ -84279,13 +83534,13 @@ __81: return target goto __84 __83: - (*Expr)(unsafe.Pointer(bp + 96 /* &tempX */)).Fop = U8(152) - (*Expr)(unsafe.Pointer(bp + 96 /* &tempX */)).Fflags = (U32(0x000400 | 0x004000)) + (*Expr)(unsafe.Pointer(bp + 96 /* &tempX */)).Fop = TK_INTEGER + (*Expr)(unsafe.Pointer(bp + 96 /* &tempX */)).Fflags = (U32(EP_IntValue | EP_TokenOnly)) *(*int32)(unsafe.Pointer(bp + 96 /* &tempX */ + 8 /* &.u */)) = 0 r1 = Xsqlite3ExprCodeTemp(tls, pParse, bp+96 /* &tempX */, bp+88 /* ®Free1 */) r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp+92 /* ®Free2 */) - Xsqlite3VdbeAddOp3(tls, v, 106, r2, r1, target) + Xsqlite3VdbeAddOp3(tls, v, OP_Subtract, r2, r1, target) __84: ; @@ -84306,21 +83561,21 @@ __38: // IS TRUE or IS FALSE r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp+88 /* ®Free1 */) isTrue = Xsqlite3ExprTruthValue(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) - bNormal = (libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == 45)) + bNormal = (libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == TK_IS)) - Xsqlite3VdbeAddOp4Int(tls, v, 87, r1, inReg, libc.BoolInt32(!(isTrue != 0)), (isTrue ^ bNormal)) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IsTrue, r1, inReg, libc.BoolInt32(!(isTrue != 0)), (isTrue ^ bNormal)) goto __3 __39: __40: ; - Xsqlite3VdbeAddOp2(tls, v, 69, 1, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, target) r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp+88 /* ®Free1 */) addr = Xsqlite3VdbeAddOp1(tls, v, op, r1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, target) Xsqlite3VdbeJumpHere(tls, v, addr) goto __3 @@ -84346,7 +83601,7 @@ __42: // The function name enc = (*Sqlite3)(unsafe.Pointer(db)).Fenc // The text encoding used by this database pColl = uintptr(0) // A collating sequence - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) { goto __87 } return (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FregResult @@ -84378,7 +83633,7 @@ __88: goto __3 __89: ; - if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x00400000)) != 0) { + if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_INLINE) != 0) { goto __90 } @@ -84386,7 +83641,7 @@ __89: int32((*FuncDef)(unsafe.Pointer(pDef)).FpUserData), target) goto __91 __90: - if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(0x00080000 | 0x00200000))) != 0) { + if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(SQLITE_FUNC_DIRECT | SQLITE_FUNC_UNSAFE))) != 0) { goto __92 } Xsqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef) @@ -84407,7 +83662,7 @@ __93: constMask = constMask | (uint32((uint32(1))) << (i)) __96: ; - if !((((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0020)) != U32(0)) && !(pColl != 0)) { + if !((((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != U32(0)) && !(pColl != 0)) { goto __97 } pColl = Xsqlite3ExprCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(i)*32)).FpExpr) @@ -84438,23 +83693,23 @@ __101: // set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG // or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data // loading. - if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(0x0040 | 0x0080))) != U32(0)) { + if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(SQLITE_FUNC_LENGTH | SQLITE_FUNC_TYPEOF))) != U32(0)) { goto __102 } - exprOp = (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */) + uintptr(0)*32)).FpExpr)).Fop - if !((int32(exprOp) == 164) || (int32(exprOp) == 166)) { + exprOp = (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */))).FpExpr)).Fop + if !((int32(exprOp) == TK_COLUMN) || (int32(exprOp) == TK_AGG_COLUMN)) { goto __103 } - (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */) + uintptr(0)*32)).FpExpr)).Fop2 = (U8((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(0x40 | 0x80)))) + (*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */))).FpExpr)).Fop2 = (U8((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & (U32(OPFLAG_LENGTHARG | OPFLAG_TYPEOFARG)))) __103: ; __102: ; Xsqlite3ExprCodeExprList(tls, pParse, pFarg, r1, 0, - (uint8(0x01 | 0x02))) + (uint8(SQLITE_ECEL_DUP | SQLITE_ECEL_FACTOR))) goto __99 __98: r1 = 0 @@ -84471,21 +83726,21 @@ __99: // function. The expression "A glob B" is equivalent to // "glob(B,A). We want to use the A in "A glob B" to test // for function overloading. But we use the B term in "glob(B,A)". - if !((nFarg >= 2) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000080))) != U32(0))) { + if !((nFarg >= 2) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_InfixFunc)) != U32(0))) { goto __104 } - pDef = Xsqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(1)*32)).FpExpr) + pDef = Xsqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+1*32)).FpExpr) goto __105 __104: if !(nFarg > 0) { goto __106 } - pDef = Xsqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*ExprList_item)(unsafe.Pointer((pFarg+8 /* &.a */)+uintptr(0)*32)).FpExpr) + pDef = Xsqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */))).FpExpr) __106: ; __105: ; - if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0020)) != 0) { + if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != 0) { goto __107 } if !(!(pColl != 0)) { @@ -84494,20 +83749,20 @@ __105: pColl = (*Sqlite3)(unsafe.Pointer(db)).FpDfltColl __108: ; - Xsqlite3VdbeAddOp4(tls, v, 81, 0, 0, 0, pColl, -2) + Xsqlite3VdbeAddOp4(tls, v, OP_CollSeq, 0, 0, 0, pColl, -2) __107: ; - if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x8000)) != 0) { + if !(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_OFFSET) != 0) { goto __109 } - pArg = (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */) + uintptr(0)*32)).FpExpr - if !(int32((*Expr)(unsafe.Pointer(pArg)).Fop) == 164) { + pArg = (*ExprList_item)(unsafe.Pointer((pFarg + 8 /* &.a */))).FpExpr + if !(int32((*Expr)(unsafe.Pointer(pArg)).Fop) == TK_COLUMN) { goto __111 } - Xsqlite3VdbeAddOp3(tls, v, 88, (*Expr)(unsafe.Pointer(pArg)).FiTable, int32((*Expr)(unsafe.Pointer(pArg)).FiColumn), target) + Xsqlite3VdbeAddOp3(tls, v, OP_Offset, (*Expr)(unsafe.Pointer(pArg)).FiTable, int32((*Expr)(unsafe.Pointer(pArg)).FiColumn), target) goto __112 __111: - Xsqlite3VdbeAddOp2(tls, v, 72, 0, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target) __112: ; goto __110 @@ -84543,7 +83798,7 @@ __44: return 0 goto __117 __116: - if !((op == 136) && ((libc.AssignInt32(&nCol, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList)).FnExpr)) != 1)) { + if !((op == TK_SELECT) && ((libc.AssignInt32(&nCol, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpEList)).FnExpr)) != 1)) { goto __118 } Xsqlite3SubselectError(tls, pParse, nCol, 1) @@ -84577,11 +83832,11 @@ __121: __46: destIfFalse = Xsqlite3VdbeMakeLabel(tls, pParse) destIfNull = Xsqlite3VdbeMakeLabel(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target) sqlite3ExprCodeIN(tls, pParse, pExpr, destIfFalse, destIfNull) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, target) Xsqlite3VdbeResolveLabel(tls, v, destIfFalse) - Xsqlite3VdbeAddOp2(tls, v, 82, target, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, target, 0) Xsqlite3VdbeResolveLabel(tls, v, destIfNull) return target @@ -84634,7 +83889,7 @@ __51: p1 = ((((*Expr)(unsafe.Pointer(pExpr)).FiTable * (int32((*Table)(unsafe.Pointer(pTab2)).FnCol) + 1)) + 1) + int32(Xsqlite3TableColumnToStorage(tls, pTab2, int16(iCol1)))) - Xsqlite3VdbeAddOp2(tls, v, 148, p1, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Param, p1, target) Xsqlite3VdbeComment(tls, v, ts+10052 /* "r[%d]=%s.%s" */, libc.VaList(bp+64, target, func() uintptr { if (*Expr)(unsafe.Pointer(pExpr)).FiTable != 0 { return ts + 8338 /* "new" */ @@ -84652,10 +83907,10 @@ __51: // // EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to // floating point when extracting it from the record. - if !((iCol1 >= 0) && (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab2)).FaCol+uintptr(iCol1)*32)).Faffinity) == 0x45)) { + if !((iCol1 >= 0) && (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab2)).FaCol+uintptr(iCol1)*32)).Faffinity) == SQLITE_AFF_REAL)) { goto __122 } - Xsqlite3VdbeAddOp1(tls, v, 83, target) + Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, target) __122: ; goto __3 @@ -84671,7 +83926,7 @@ __52: // on a LEFT JOIN NULL row. __53: okConstFactor = (*Parse)(unsafe.Pointer(pParse)).FokConstFactor - addrINR = Xsqlite3VdbeAddOp1(tls, v, 21, (*Expr)(unsafe.Pointer(pExpr)).FiTable) + addrINR = Xsqlite3VdbeAddOp1(tls, v, OP_IfNullRow, (*Expr)(unsafe.Pointer(pExpr)).FiTable) // Temporarily disable factoring of constant expressions, since // even though expressions may appear to be constant, they are not // really constant because they originate from the right-hand side @@ -84726,7 +83981,7 @@ __124: exprToRegister(tls, pDel, exprCodeVector(tls, pParse, pDel, bp+88 /* ®Free1 */)) libc.Xmemset(tls, bp+168 /* &opCompare */, 0, uint64(unsafe.Sizeof(Expr{}))) - (*Expr)(unsafe.Pointer(bp + 168 /* &opCompare */)).Fop = U8(53) + (*Expr)(unsafe.Pointer(bp + 168 /* &opCompare */)).Fop = TK_EQ (*Expr)(unsafe.Pointer(bp + 168 /* &opCompare */)).FpLeft = pDel pTest = bp + 168 /* &opCompare */ // Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001: @@ -84753,7 +84008,7 @@ __129: ; nextCase = Xsqlite3VdbeMakeLabel(tls, pParse) - Xsqlite3ExprIfFalse(tls, pParse, pTest, nextCase, 0x10) + Xsqlite3ExprIfFalse(tls, pParse, pTest, nextCase, SQLITE_JUMPIFNULL) Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer(aListelem+uintptr((i1+1))*32)).FpExpr, target) Xsqlite3VdbeGoto(tls, v, endLabel) @@ -84771,7 +84026,7 @@ __127: Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr((nExpr-1))*32)).FpExpr, target) goto __131 __130: - Xsqlite3VdbeAddOp2(tls, v, 72, 0, target) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, target) __131: ; Xsqlite3ExprDelete(tls, db1, pDel) @@ -84789,27 +84044,27 @@ __55: return 0 __132: ; - if !(int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == 2) { + if !(int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == OE_Abort) { goto __133 } Xsqlite3MayAbort(tls, pParse) __133: ; - if !(int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == 4) { + if !(int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr) == OE_Ignore) { goto __134 } Xsqlite3VdbeAddOp4(tls, - v, 68, 0, 4, 0, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), 0) + v, OP_Halt, SQLITE_OK, OE_Ignore, 0, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), 0) goto __135 __134: Xsqlite3HaltConstraint(tls, pParse, func() int32 { if (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab != 0 { - return (19 | (int32(7) << 8)) + return (SQLITE_CONSTRAINT | (int32(7) << 8)) } - return 1 + return SQLITE_ERROR }(), int32((*Expr)(unsafe.Pointer(pExpr)).FaffExpr), *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), int8(0), uint8(0)) __135: @@ -84869,11 +84124,11 @@ func Xsqlite3ExprCodeRunJustOnce(tls *libc.TLS, pParse uintptr, pExpr uintptr, r __3: } pExpr = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0) - if (pExpr != uintptr(0)) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000004))) != U32(0)) { + if (pExpr != uintptr(0)) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_HasFunc)) != U32(0)) { var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe var addr int32 - addr = Xsqlite3VdbeAddOp0(tls, v, 17) + addr = Xsqlite3VdbeAddOp0(tls, v, OP_Once) (*Parse)(unsafe.Pointer(pParse)).FokConstFactor = U8(0) if !(int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed) != 0) { if regDest < 0 { @@ -84914,7 +84169,7 @@ func Xsqlite3ExprCodeTemp(tls *libc.TLS, pParse uintptr, pExpr uintptr, pReg uin var r2 int32 pExpr = Xsqlite3ExprSkipCollateAndLikely(tls, pExpr) if (((*Parse)(unsafe.Pointer(pParse)).FokConstFactor != 0) && - (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 173)) && + (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_REGISTER)) && (Xsqlite3ExprIsConstantNotJoin(tls, pExpr) != 0) { *(*int32)(unsafe.Pointer(pReg)) = 0 r2 = Xsqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, -1) @@ -84943,10 +84198,10 @@ func Xsqlite3ExprCode(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32 inReg = Xsqlite3ExprCodeTarget(tls, pParse, pExpr, target) if inReg != target { var op U8 - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x200000))) != U32(0) { - op = U8(77) + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Subquery)) != U32(0) { + op = OP_Copy } else { - op = U8(78) + op = OP_SCopy } Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, int32(op), inReg, target) } @@ -85000,17 +84255,17 @@ func Xsqlite3ExprCodeExprList(tls *libc.TLS, pParse uintptr, pList uintptr, targ var j int32 var n int32 var copyOp U8 - if (int32(flags) & 0x01) != 0 { - copyOp = uint8(77) + if (int32(flags) & SQLITE_ECEL_DUP) != 0 { + copyOp = OP_Copy } else { - copyOp = uint8(78) + copyOp = OP_SCopy } var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe // Never gets this far otherwise n = (*ExprList)(unsafe.Pointer(pList)).FnExpr if !(int32((*Parse)(unsafe.Pointer(pParse)).FokConstFactor) != 0) { - flags = libc.Uint8FromInt32(int32(flags) & (^libc.Int32(0x02))) + flags = libc.Uint8FromInt32(int32(flags) & (libc.CplInt32(SQLITE_ECEL_FACTOR))) } pItem = pList + 8 /* &.a */ i = 0 @@ -85020,22 +84275,22 @@ __1: } { var pExpr uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr - if ((int32(flags) & 0x04) != 0) && ((libc.AssignInt32(&j, int32(*(*U16)(unsafe.Pointer(pItem + 24 /* &.u */ /* &.x */ /* &.iOrderByCol */))))) > 0) { - if (int32(flags) & 0x08) != 0 { + if ((int32(flags) & SQLITE_ECEL_REF) != 0) && ((libc.AssignInt32(&j, int32(*(*U16)(unsafe.Pointer(pItem + 24 /* &.u */ /* &.x */ /* &.iOrderByCol */))))) > 0) { + if (int32(flags) & SQLITE_ECEL_OMITREF) != 0 { i-- n-- } else { Xsqlite3VdbeAddOp2(tls, v, int32(copyOp), ((j + srcReg) - 1), (target + i)) } - } else if ((int32(flags) & 0x02) != 0) && + } else if ((int32(flags) & SQLITE_ECEL_FACTOR) != 0) && (Xsqlite3ExprIsConstantNotJoin(tls, pExpr) != 0) { Xsqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, (target + i)) } else { var inReg int32 = Xsqlite3ExprCodeTarget(tls, pParse, pExpr, (target + i)) if inReg != (target + i) { var pOp uintptr - if ((((int32(copyOp) == 77) && - (int32((*VdbeOp)(unsafe.Pointer((libc.AssignUintptr(&pOp, Xsqlite3VdbeGetOp(tls, v, -1))))).Fopcode) == 77)) && + if ((((int32(copyOp) == OP_Copy) && + (int32((*VdbeOp)(unsafe.Pointer((libc.AssignUintptr(&pOp, Xsqlite3VdbeGetOp(tls, v, -1))))).Fopcode) == OP_Copy)) && ((((*VdbeOp)(unsafe.Pointer(pOp)).Fp1 + (*VdbeOp)(unsafe.Pointer(pOp)).Fp3) + 1) == inReg)) && ((((*VdbeOp)(unsafe.Pointer(pOp)).Fp2 + (*VdbeOp)(unsafe.Pointer(pOp)).Fp3) + 1) == (target + i))) && (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fp5) == 0) { @@ -85096,15 +84351,15 @@ func exprCodeBetween(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, x pDel = Xsqlite3ExprDup(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, 0) if int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { - (*Expr)(unsafe.Pointer(bp + 144 /* &exprAnd */)).Fop = U8(44) + (*Expr)(unsafe.Pointer(bp + 144 /* &exprAnd */)).Fop = TK_AND (*Expr)(unsafe.Pointer(bp + 144 /* &exprAnd */)).FpLeft = bp /* &compLeft */ (*Expr)(unsafe.Pointer(bp + 144 /* &exprAnd */)).FpRight = bp + 72 /* &compRight */ - (*Expr)(unsafe.Pointer(bp /* &compLeft */)).Fop = U8(57) + (*Expr)(unsafe.Pointer(bp /* &compLeft */)).Fop = TK_GE (*Expr)(unsafe.Pointer(bp /* &compLeft */)).FpLeft = pDel - (*Expr)(unsafe.Pointer(bp /* &compLeft */)).FpRight = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + uintptr(0)*32)).FpExpr - (*Expr)(unsafe.Pointer(bp + 72 /* &compRight */)).Fop = U8(55) + (*Expr)(unsafe.Pointer(bp /* &compLeft */)).FpRight = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */))).FpExpr + (*Expr)(unsafe.Pointer(bp + 72 /* &compRight */)).Fop = TK_LE (*Expr)(unsafe.Pointer(bp + 72 /* &compRight */)).FpLeft = pDel - (*Expr)(unsafe.Pointer(bp + 72 /* &compRight */)).FpRight = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + uintptr(1)*32)).FpExpr + (*Expr)(unsafe.Pointer(bp + 72 /* &compRight */)).FpRight = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + 1*32)).FpExpr exprToRegister(tls, pDel, exprCodeVector(tls, pParse, pDel, bp+216 /* ®Free1 */)) if xJump != 0 { (*(*func(*libc.TLS, uintptr, uintptr, int32, int32))(unsafe.Pointer(&xJump)))(tls, pParse, bp+144 /* &exprAnd */, dest, jumpIfNull) @@ -85114,7 +84369,7 @@ func exprCodeBetween(tls *libc.TLS, pParse uintptr, pExpr uintptr, dest int32, x // it into the Parse.pConstExpr list. We should use a new bit for this, // for clarity, but we are out of bits in the Expr.flags field so we // have to reuse the EP_FromJoin bit. Bummer. - *(*U32)(unsafe.Pointer(pDel + 4 /* &.flags */)) |= (U32(0x000001)) + *(*U32)(unsafe.Pointer(pDel + 4 /* &.flags */)) |= (EP_FromJoin) Xsqlite3ExprCodeTarget(tls, pParse, bp+144 /* &exprAnd */, dest) } Xsqlite3ReleaseTempReg(tls, pParse, *(*int32)(unsafe.Pointer(bp + 216 /* regFree1 */))) @@ -85175,37 +84430,37 @@ __2: op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop) switch op { - case 44: + case TK_AND: goto __4 - case 43: + case TK_OR: goto __5 - case 19: + case TK_NOT: goto __6 - case 172: + case TK_TRUTH: goto __7 - case 45: + case TK_IS: goto __8 - case 168: + case TK_ISNOT: goto __9 - case 56: + case TK_LT: goto __10 - case 55: + case TK_LE: goto __11 - case 54: + case TK_GT: goto __12 - case 57: + case TK_GE: goto __13 - case 52: + case TK_NE: goto __14 - case 53: + case TK_EQ: goto __15 - case 50: + case TK_ISNULL: goto __16 - case 51: + case TK_NOTNULL: goto __17 - case 48: + case TK_BETWEEN: goto __18 - case 49: + case TK_IN: goto __19 default: goto __20 @@ -85220,13 +84475,13 @@ __5: Xsqlite3ExprIfTrue(tls, pParse, pAlt, dest, jumpIfNull) goto __22 __21: - if !(op == 44) { + if !(op == TK_AND) { goto __23 } d2 = Xsqlite3VdbeMakeLabel(tls, pParse) Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, d2, - (jumpIfNull ^ 0x10)) + (jumpIfNull ^ SQLITE_JUMPIFNULL)) Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, dest, jumpIfNull) Xsqlite3VdbeResolveLabel(tls, v, d2) goto __24 @@ -85247,7 +84502,7 @@ __6: __7: // IS TRUE or IS NOT TRUE ; - isNot = (libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == 168)) + isNot = (libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == TK_ISNOT)) isTrue = Xsqlite3ExprTruthValue(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) if !((isTrue ^ isNot) != 0) { @@ -85256,7 +84511,7 @@ __7: // IS TRUE or IS NOT TRUE Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, dest, func() int32 { if isNot != 0 { - return 0x10 + return SQLITE_JUMPIFNULL } return 0 }()) @@ -85265,7 +84520,7 @@ __25: Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, dest, func() int32 { if isNot != 0 { - return 0x10 + return SQLITE_JUMPIFNULL } return 0 }()) @@ -85277,13 +84532,12 @@ __8: __9: ; - if op == 45 { - op = 53 + if op == TK_IS { + op = TK_EQ } else { - op = 52 + op = TK_NE } - jumpIfNull = 0x80 - /* no break */ + jumpIfNull = SQLITE_NULLEQ __10: __11: __12: @@ -85300,7 +84554,7 @@ __27: r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp /* ®Free1 */) r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+4 /* ®Free2 */) codeCompare(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight, op, - r1, r2, dest, jumpIfNull, (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000200))) != U32(0)))) + r1, r2, dest, jumpIfNull, (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Commuted)) != U32(0)))) goto __3 @@ -85334,20 +84588,20 @@ __19: __20: default_expr: - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001 | 0x10000000))) == U32(0x10000000)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_FromJoin | EP_IsTrue))) == EP_IsTrue) { goto __28 } Xsqlite3VdbeGoto(tls, v, dest) goto __29 __28: - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001 | 0x20000000))) == U32(0x20000000)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_FromJoin | EP_IsFalse))) == EP_IsFalse) { goto __30 } // No-op goto __31 __30: r1 = Xsqlite3ExprCodeTemp(tls, pParse, pExpr, bp /* ®Free1 */) - Xsqlite3VdbeAddOp3(tls, v, 18, r1, dest, (libc.Bool32(jumpIfNull != 0))) + Xsqlite3VdbeAddOp3(tls, v, OP_If, r1, dest, (libc.Bool32(jumpIfNull != 0))) __31: ; @@ -85420,42 +84674,42 @@ __2: // The value of TK_ and OP_ constants are arranged such that we // can compute the mapping above using the following expression. // Assert()s verify that the computation is correct. - op = (((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) + (50 & 1)) ^ 1) - (50 & 1)) + op = (((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) + (TK_ISNULL & 1)) ^ 1) - (TK_ISNULL & 1)) // Verify correct alignment of TK_ and OP_ constants switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) { - case 44: + case TK_AND: goto __4 - case 43: + case TK_OR: goto __5 - case 19: + case TK_NOT: goto __6 - case 172: + case TK_TRUTH: goto __7 - case 45: + case TK_IS: goto __8 - case 168: + case TK_ISNOT: goto __9 - case 56: + case TK_LT: goto __10 - case 55: + case TK_LE: goto __11 - case 54: + case TK_GT: goto __12 - case 57: + case TK_GE: goto __13 - case 52: + case TK_NE: goto __14 - case 53: + case TK_EQ: goto __15 - case 50: + case TK_ISNULL: goto __16 - case 51: + case TK_NOTNULL: goto __17 - case 48: + case TK_BETWEEN: goto __18 - case 49: + case TK_IN: goto __19 default: goto __20 @@ -85470,7 +84724,7 @@ __5: Xsqlite3ExprIfFalse(tls, pParse, pAlt, dest, jumpIfNull) goto __22 __21: - if !(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 44) { + if !(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND) { goto __23 } @@ -85481,7 +84735,7 @@ __23: d2 = Xsqlite3VdbeMakeLabel(tls, pParse) Xsqlite3ExprIfTrue(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, d2, - (jumpIfNull ^ 0x10)) + (jumpIfNull ^ SQLITE_JUMPIFNULL)) Xsqlite3ExprIfFalse(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, dest, jumpIfNull) Xsqlite3VdbeResolveLabel(tls, v, d2) __24: @@ -85497,7 +84751,7 @@ __6: __7: // IS TRUE or IS NOT TRUE ; - isNot = (libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == 168)) + isNot = (libc.Bool32(int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) == TK_ISNOT)) isTrue = Xsqlite3ExprTruthValue(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) if !((isTrue ^ isNot) != 0) { @@ -85509,7 +84763,7 @@ __7: // IS TRUE or IS NOT TRUE if isNot != 0 { return 0 } - return 0x10 + return SQLITE_JUMPIFNULL }()) goto __26 @@ -85520,7 +84774,7 @@ __25: if isNot != 0 { return 0 } - return 0x10 + return SQLITE_JUMPIFNULL }()) __26: ; @@ -85530,13 +84784,12 @@ __8: __9: ; - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 45 { - op = 52 + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IS { + op = TK_NE } else { - op = 53 + op = TK_EQ } - jumpIfNull = 0x80 - /* no break */ + jumpIfNull = SQLITE_NULLEQ __10: __11: __12: @@ -85553,7 +84806,7 @@ __27: r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, bp /* ®Free1 */) r2 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+4 /* ®Free2 */) codeCompare(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight, op, - r1, r2, dest, jumpIfNull, (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000200))) != U32(0)))) + r1, r2, dest, jumpIfNull, (libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_Commuted)) != U32(0)))) goto __3 @@ -85587,20 +84840,20 @@ __29: __20: default_expr: - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001 | 0x20000000))) == U32(0x20000000)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_FromJoin | EP_IsFalse))) == EP_IsFalse) { goto __30 } Xsqlite3VdbeGoto(tls, v, dest) goto __31 __30: - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001 | 0x10000000))) == U32(0x10000000)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_FromJoin | EP_IsTrue))) == EP_IsTrue) { goto __32 } // no-op goto __33 __32: r1 = Xsqlite3ExprCodeTemp(tls, pParse, pExpr, bp /* ®Free1 */) - Xsqlite3VdbeAddOp3(tls, v, 20, r1, dest, (libc.Bool32(jumpIfNull != 0))) + Xsqlite3VdbeAddOp3(tls, v, OP_IfNot, r1, dest, (libc.Bool32(jumpIfNull != 0))) __33: ; @@ -85646,13 +84899,13 @@ func exprCompareVariable(tls *libc.TLS, pParse uintptr, pVar uintptr, pExpr uint var pL uintptr *(*uintptr)(unsafe.Pointer(bp /* pR */)) = uintptr(0) - Xsqlite3ValueFromExpr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, uint8(1), uint8(0x41), bp /* &pR */) + Xsqlite3ValueFromExpr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, bp /* &pR */) if *(*uintptr)(unsafe.Pointer(bp /* pR */)) != 0 { iVar = int32((*Expr)(unsafe.Pointer(pVar)).FiColumn) Xsqlite3VdbeSetVarmask(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, iVar) - pL = Xsqlite3VdbeGetBoundValue(tls, (*Parse)(unsafe.Pointer(pParse)).FpReprepare, iVar, uint8(0x41)) + pL = Xsqlite3VdbeGetBoundValue(tls, (*Parse)(unsafe.Pointer(pParse)).FpReprepare, iVar, SQLITE_AFF_BLOB) if pL != 0 { - if Xsqlite3_value_type(tls, pL) == 3 { + if Xsqlite3_value_type(tls, pL) == SQLITE_TEXT { Xsqlite3_value_text(tls, pL) // Make sure the encoding is UTF-8 } res = (libc.Bool32(0 == Xsqlite3MemCompare(tls, pL, *(*uintptr)(unsafe.Pointer(bp /* pR */)), uintptr(0)))) @@ -85699,42 +84952,42 @@ func Xsqlite3ExprCompare(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, } return 2 } - if ((pParse != 0) && (int32((*Expr)(unsafe.Pointer(pA)).Fop) == 153)) && (exprCompareVariable(tls, pParse, pA, pB) != 0) { + if ((pParse != 0) && (int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_VARIABLE)) && (exprCompareVariable(tls, pParse, pA, pB) != 0) { return 0 } combinedFlags = ((*Expr)(unsafe.Pointer(pA)).Fflags | (*Expr)(unsafe.Pointer(pB)).Fflags) - if (combinedFlags & U32(0x000400)) != 0 { - if ((((*Expr)(unsafe.Pointer(pA)).Fflags & (*Expr)(unsafe.Pointer(pB)).Fflags) & U32(0x000400)) != U32(0)) && (*(*int32)(unsafe.Pointer(pA + 8 /* &.u */)) == *(*int32)(unsafe.Pointer(pB + 8 /* &.u */))) { + if (combinedFlags & EP_IntValue) != 0 { + if ((((*Expr)(unsafe.Pointer(pA)).Fflags & (*Expr)(unsafe.Pointer(pB)).Fflags) & EP_IntValue) != U32(0)) && (*(*int32)(unsafe.Pointer(pA + 8 /* &.u */)) == *(*int32)(unsafe.Pointer(pB + 8 /* &.u */))) { return 0 } return 2 } - if (int32((*Expr)(unsafe.Pointer(pA)).Fop) != int32((*Expr)(unsafe.Pointer(pB)).Fop)) || (int32((*Expr)(unsafe.Pointer(pA)).Fop) == 71) { - if (int32((*Expr)(unsafe.Pointer(pA)).Fop) == 111) && (Xsqlite3ExprCompare(tls, pParse, (*Expr)(unsafe.Pointer(pA)).FpLeft, pB, iTab) < 2) { + if (int32((*Expr)(unsafe.Pointer(pA)).Fop) != int32((*Expr)(unsafe.Pointer(pB)).Fop)) || (int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_RAISE) { + if (int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_COLLATE) && (Xsqlite3ExprCompare(tls, pParse, (*Expr)(unsafe.Pointer(pA)).FpLeft, pB, iTab) < 2) { return 1 } - if (int32((*Expr)(unsafe.Pointer(pB)).Fop) == 111) && (Xsqlite3ExprCompare(tls, pParse, pA, (*Expr)(unsafe.Pointer(pB)).FpLeft, iTab) < 2) { + if (int32((*Expr)(unsafe.Pointer(pB)).Fop) == TK_COLLATE) && (Xsqlite3ExprCompare(tls, pParse, pA, (*Expr)(unsafe.Pointer(pB)).FpLeft, iTab) < 2) { return 1 } return 2 } - if ((int32((*Expr)(unsafe.Pointer(pA)).Fop) != 164) && (int32((*Expr)(unsafe.Pointer(pA)).Fop) != 166)) && (*(*uintptr)(unsafe.Pointer(pA + 8 /* &.u */)) != 0) { - if (int32((*Expr)(unsafe.Pointer(pA)).Fop) == 169) || (int32((*Expr)(unsafe.Pointer(pA)).Fop) == 165) { + if ((int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_COLUMN) && (int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_AGG_COLUMN)) && (*(*uintptr)(unsafe.Pointer(pA + 8 /* &.u */)) != 0) { + if (int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_FUNCTION) || (int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_AGG_FUNCTION) { if Xsqlite3StrICmp(tls, *(*uintptr)(unsafe.Pointer(pA + 8 /* &.u */)), *(*uintptr)(unsafe.Pointer(pB + 8 /* &.u */))) != 0 { return 2 } - if (libc.Bool32(((*Expr)(unsafe.Pointer((pA))).Fflags & (U32(0x1000000))) != U32(0))) != (libc.Bool32(((*Expr)(unsafe.Pointer((pB))).Fflags & (U32(0x1000000))) != U32(0))) { + if (libc.Bool32(((*Expr)(unsafe.Pointer((pA))).Fflags & (EP_WinFunc)) != U32(0))) != (libc.Bool32(((*Expr)(unsafe.Pointer((pB))).Fflags & (EP_WinFunc)) != U32(0))) { return 2 } - if ((*Expr)(unsafe.Pointer((pA))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pA))).Fflags & (EP_WinFunc)) != U32(0) { if Xsqlite3WindowCompare(tls, pParse, *(*uintptr)(unsafe.Pointer(pA + 64 /* &.y */)), *(*uintptr)(unsafe.Pointer(pB + 64 /* &.y */)), 1) != 0 { return 2 } } - } else if int32((*Expr)(unsafe.Pointer(pA)).Fop) == 119 { + } else if int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_NULL { return 0 - } else if int32((*Expr)(unsafe.Pointer(pA)).Fop) == 111 { + } else if int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_COLLATE { if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(pA + 8 /* &.u */)), *(*uintptr)(unsafe.Pointer(pB + 8 /* &.u */))) != 0 { return 2 } @@ -85742,15 +84995,15 @@ func Xsqlite3ExprCompare(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, return 2 } } - if ((*Expr)(unsafe.Pointer(pA)).Fflags & (U32(0x000002 | 0x000200))) != - ((*Expr)(unsafe.Pointer(pB)).Fflags & (U32(0x000002 | 0x000200))) { + if ((*Expr)(unsafe.Pointer(pA)).Fflags & (U32(EP_Distinct | EP_Commuted))) != + ((*Expr)(unsafe.Pointer(pB)).Fflags & (U32(EP_Distinct | EP_Commuted))) { return 2 } - if (combinedFlags & U32(0x004000)) == U32(0) { - if (combinedFlags & U32(0x000800)) != 0 { + if (combinedFlags & EP_TokenOnly) == U32(0) { + if (combinedFlags & EP_xIsSelect) != 0 { return 2 } - if ((combinedFlags & U32(0x000008)) == U32(0)) && + if ((combinedFlags & EP_FixedCol) == U32(0)) && (Xsqlite3ExprCompare(tls, pParse, (*Expr)(unsafe.Pointer(pA)).FpLeft, (*Expr)(unsafe.Pointer(pB)).FpLeft, iTab) != 0) { return 2 } @@ -85760,16 +85013,16 @@ func Xsqlite3ExprCompare(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, if Xsqlite3ExprListCompare(tls, *(*uintptr)(unsafe.Pointer(pA + 32 /* &.x */)), *(*uintptr)(unsafe.Pointer(pB + 32 /* &.x */)), iTab) != 0 { return 2 } - if ((int32((*Expr)(unsafe.Pointer(pA)).Fop) != 115) && - (int32((*Expr)(unsafe.Pointer(pA)).Fop) != 167)) && - ((combinedFlags & U32(0x002000)) == U32(0)) { + if ((int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_STRING) && + (int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_TRUEFALSE)) && + ((combinedFlags & EP_Reduced) == U32(0)) { if int32((*Expr)(unsafe.Pointer(pA)).FiColumn) != int32((*Expr)(unsafe.Pointer(pB)).FiColumn) { return 2 } - if (int32((*Expr)(unsafe.Pointer(pA)).Fop2) != int32((*Expr)(unsafe.Pointer(pB)).Fop2)) && (int32((*Expr)(unsafe.Pointer(pA)).Fop) == 172) { + if (int32((*Expr)(unsafe.Pointer(pA)).Fop2) != int32((*Expr)(unsafe.Pointer(pB)).Fop2)) && (int32((*Expr)(unsafe.Pointer(pA)).Fop) == TK_TRUTH) { return 2 } - if ((int32((*Expr)(unsafe.Pointer(pA)).Fop) != 49) && ((*Expr)(unsafe.Pointer(pA)).FiTable != (*Expr)(unsafe.Pointer(pB)).FiTable)) && ((*Expr)(unsafe.Pointer(pA)).FiTable != iTab) { + if ((int32((*Expr)(unsafe.Pointer(pA)).Fop) != TK_IN) && ((*Expr)(unsafe.Pointer(pA)).FiTable != (*Expr)(unsafe.Pointer(pB)).FiTable)) && ((*Expr)(unsafe.Pointer(pA)).FiTable != iTab) { return 2 } } @@ -85832,98 +85085,96 @@ func Xsqlite3ExprCompareSkip(tls *libc.TLS, pA uintptr, pB uintptr, iTab int32) func exprImpliesNotNull(tls *libc.TLS, pParse uintptr, p uintptr, pNN uintptr, iTab int32, seenNot int32) int32 { /* sqlite3.c:105063:12: */ if Xsqlite3ExprCompare(tls, pParse, p, pNN, iTab) == 0 { - return (libc.Bool32(int32((*Expr)(unsafe.Pointer(pNN)).Fop) != 119)) + return (libc.Bool32(int32((*Expr)(unsafe.Pointer(pNN)).Fop) != TK_NULL)) } switch int32((*Expr)(unsafe.Pointer(p)).Fop) { - case 49: + case TK_IN: { - if (seenNot != 0) && (((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000800))) != U32(0)) { + if (seenNot != 0) && (((*Expr)(unsafe.Pointer((p))).Fflags & (EP_xIsSelect)) != U32(0)) { return 0 } return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, 1) } - case 48: + case TK_BETWEEN: { var pList uintptr = *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) if seenNot != 0 { return 0 } - if (exprImpliesNotNull(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(0)*32)).FpExpr, pNN, iTab, 1) != 0) || - (exprImpliesNotNull(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(1)*32)).FpExpr, pNN, iTab, 1) != 0) { + if (exprImpliesNotNull(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */))).FpExpr, pNN, iTab, 1) != 0) || + (exprImpliesNotNull(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+1*32)).FpExpr, pNN, iTab, 1) != 0) { return 1 } return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, 1) } - case 53: + case TK_EQ: fallthrough - case 52: + case TK_NE: fallthrough - case 56: + case TK_LT: fallthrough - case 55: + case TK_LE: fallthrough - case 54: + case TK_GT: fallthrough - case 57: + case TK_GE: fallthrough - case 105: + case TK_PLUS: fallthrough - case 106: + case TK_MINUS: fallthrough - case 102: + case TK_BITOR: fallthrough - case 103: + case TK_LSHIFT: fallthrough - case 104: + case TK_RSHIFT: fallthrough - case 110: + case TK_CONCAT: seenNot = 1 - /* no break */ fallthrough - case 107: + case TK_STAR: fallthrough - case 109: + case TK_REM: fallthrough - case 101: + case TK_BITAND: fallthrough - case 108: + case TK_SLASH: { if exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpRight, pNN, iTab, seenNot) != 0 { return 1 } - /* no break */ } fallthrough - case 178: + case TK_SPAN: fallthrough - case 111: + case TK_COLLATE: fallthrough - case 171: + case TK_UPLUS: fallthrough - case 170: + case TK_UMINUS: { return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, seenNot) } - case 172: + case TK_TRUTH: { if seenNot != 0 { return 0 } - if int32((*Expr)(unsafe.Pointer(p)).Fop2) != 45 { + if int32((*Expr)(unsafe.Pointer(p)).Fop2) != TK_IS { return 0 } return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, 1) } - case 112: + case TK_BITNOT: fallthrough - case 19: + case TK_NOT: { return exprImpliesNotNull(tls, pParse, (*Expr)(unsafe.Pointer(p)).FpLeft, pNN, iTab, 1) @@ -85959,12 +85210,12 @@ func Xsqlite3ExprImpliesExpr(tls *libc.TLS, pParse uintptr, pE1 uintptr, pE2 uin if Xsqlite3ExprCompare(tls, pParse, pE1, pE2, iTab) == 0 { return 1 } - if (int32((*Expr)(unsafe.Pointer(pE2)).Fop) == 43) && + if (int32((*Expr)(unsafe.Pointer(pE2)).Fop) == TK_OR) && ((Xsqlite3ExprImpliesExpr(tls, pParse, pE1, (*Expr)(unsafe.Pointer(pE2)).FpLeft, iTab) != 0) || (Xsqlite3ExprImpliesExpr(tls, pParse, pE1, (*Expr)(unsafe.Pointer(pE2)).FpRight, iTab) != 0)) { return 1 } - if (int32((*Expr)(unsafe.Pointer(pE2)).Fop) == 51) && + if (int32((*Expr)(unsafe.Pointer(pE2)).Fop) == TK_NOTNULL) && (exprImpliesNotNull(tls, pParse, pE1, (*Expr)(unsafe.Pointer(pE2)).FpLeft, iTab, 0) != 0) { return 1 } @@ -85980,39 +85231,39 @@ func Xsqlite3ExprImpliesExpr(tls *libc.TLS, pParse uintptr, pE1 uintptr, pE2 uin // (never setting pWalker->eCode) is a harmless missed optimization. func impliesNotNullRow(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:105186:12: */ - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0) { - return 1 + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0) { + return WRC_Prune } switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) { - case 168: + case TK_ISNOT: fallthrough - case 50: + case TK_ISNULL: fallthrough - case 51: + case TK_NOTNULL: fallthrough - case 45: + case TK_IS: fallthrough - case 43: + case TK_OR: fallthrough - case 174: + case TK_VECTOR: fallthrough - case 154: + case TK_CASE: fallthrough - case 49: + case TK_IN: fallthrough - case 169: + case TK_FUNCTION: fallthrough - case 172: + case TK_TRUTH: - return 1 - case 164: + return WRC_Prune + case TK_COLUMN: if *(*int32)(unsafe.Pointer(pWalker + 40 /* &.u */)) == (*Expr)(unsafe.Pointer(pExpr)).FiTable { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(1) - return 2 + return WRC_Abort } - return 1 + return WRC_Prune - case 44: + case TK_AND: if int32((*Walker)(unsafe.Pointer(pWalker)).FeCode) == 0 { Xsqlite3WalkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) if (*Walker)(unsafe.Pointer(pWalker)).FeCode != 0 { @@ -86020,47 +85271,46 @@ func impliesNotNullRow(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* Xsqlite3WalkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpRight) } } - return 1 + return WRC_Prune - case 48: - if Xsqlite3WalkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) == 2 { + case TK_BETWEEN: + if Xsqlite3WalkExpr(tls, pWalker, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) == WRC_Abort { - return 2 + return WRC_Abort } - return 1 + return WRC_Prune // Virtual tables are allowed to use constraints like x=NULL. So // a term of the form x=y does not prove that y is not null if x // is the column of a virtual table - case 53: + case TK_EQ: fallthrough - case 52: + case TK_NE: fallthrough - case 56: + case TK_LT: fallthrough - case 55: + case TK_LE: fallthrough - case 54: + case TK_GT: fallthrough - case 57: + case TK_GE: { var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft var pRight uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpRight // The y.pTab=0 assignment in wherecode.c always happens after the // impliesNotNullRow() test - if (((int32((*Expr)(unsafe.Pointer(pLeft)).Fop) == 164) && (*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)) != uintptr(0))) && + if (((int32((*Expr)(unsafe.Pointer(pLeft)).Fop) == TK_COLUMN) && (*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)))).FnModuleArg != 0)) || - (((int32((*Expr)(unsafe.Pointer(pRight)).Fop) == 164) && (*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)) != uintptr(0))) && + (((int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_COLUMN) && (*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)))).FnModuleArg != 0)) { - return 1 + return WRC_Prune } - /* no break */ } fallthrough default: - return 0 + return WRC_Continue } return int32(0) } @@ -86095,10 +85345,10 @@ func Xsqlite3ExprImpliesNonNullRow(tls *libc.TLS, p uintptr, iTab int32) int32 { if p == uintptr(0) { return 0 } - if int32((*Expr)(unsafe.Pointer(p)).Fop) == 51 { + if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_NOTNULL { p = (*Expr)(unsafe.Pointer(p)).FpLeft } else { - for int32((*Expr)(unsafe.Pointer(p)).Fop) == 44 { + for int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_AND { if Xsqlite3ExprImpliesNonNullRow(tls, (*Expr)(unsafe.Pointer(p)).FpLeft, iTab) != 0 { return 1 } @@ -86120,13 +85370,13 @@ func Xsqlite3ExprImpliesNonNullRow(tls *libc.TLS, p uintptr, iTab int32) int32 { // pWalker->u.pIdxCover->iCur can be satisfied using the index // pWalker->u.pIdxCover->pIdx. func exprIdxCover(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:105329:12: */ - if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) && + if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == (*IdxCover)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)))).FiCur)) && (int32(Xsqlite3TableColumnToIndex(tls, (*IdxCover)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)))).FpIdx, (*Expr)(unsafe.Pointer(pExpr)).FiColumn)) < 0) { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(1) - return 2 + return WRC_Abort } - return 0 + return WRC_Continue } // Determine if an index pIdx on table with cursor iCur contains will @@ -86163,9 +85413,9 @@ func Xsqlite3ExprCoveredByIndex(tls *libc.TLS, pExpr uintptr, iCur int32, pIdx u func selectSrcCount(tls *libc.TLS, pWalker uintptr, pSel uintptr) int32 { /* sqlite3.c:105386:12: */ var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) if (((*SrcCount)(unsafe.Pointer(p)).FiSrcInner == 0x7FFFFFFF) && ((*Select)(unsafe.Pointer(pSel)).FpSrc != 0)) && ((*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpSrc)).FnSrc != 0) { - (*SrcCount)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)))).FiSrcInner = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pSel)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FiCursor + (*SrcCount)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)))).FiSrcInner = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pSel)).FpSrc + 8 /* &.a */))).FiCursor } - return 0 + return WRC_Continue } // Count the number of references to columns. @@ -86176,7 +85426,7 @@ func exprSrcCount(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqli // been converted into TK_AGG_COLUMN. But this is no longer true due // to window functions - sqlite3WindowRewrite() may now indirectly call // FunctionUsesThisSrc() when creating a new sub-select. - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 166) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_COLUMN) { var i int32 var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) var pSrc uintptr = (*SrcCount)(unsafe.Pointer(p)).FpSrc @@ -86200,7 +85450,7 @@ func exprSrcCount(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqli (*SrcCount)(unsafe.Pointer(p)).FnOther++ } } - return 0 + return WRC_Continue } // Determine if any of the arguments to the pExpr Function reference @@ -86226,14 +85476,14 @@ func Xsqlite3FunctionUsesThisSrc(tls *libc.TLS, pExpr uintptr, pSrcList uintptr) (*SrcCount)(unsafe.Pointer(bp + 48 /* &cnt */)).FpSrc = pSrcList (*SrcCount)(unsafe.Pointer(bp + 48 /* &cnt */)).FiSrcInner = func() int32 { if (pSrcList != 0) && ((*SrcList)(unsafe.Pointer(pSrcList)).FnSrc != 0) { - return (*SrcList_item)(unsafe.Pointer((pSrcList + 8 /* &.a */) + uintptr(0)*112)).FiCursor + return (*SrcList_item)(unsafe.Pointer((pSrcList + 8 /* &.a */))).FiCursor } return 0x7FFFFFFF }() (*SrcCount)(unsafe.Pointer(bp + 48 /* &cnt */)).FnThis = 0 (*SrcCount)(unsafe.Pointer(bp + 48 /* &cnt */)).FnOther = 0 Xsqlite3WalkExprList(tls, bp /* &w */, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { Xsqlite3WalkExpr(tls, bp /* &w */, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FpFilter) } return (libc.Bool32(((*SrcCount)(unsafe.Pointer(bp+48 /* &cnt */)).FnThis > 0) || ((*SrcCount)(unsafe.Pointer(bp+48 /* &cnt */)).FnOther == 0))) @@ -86251,14 +85501,14 @@ func Xsqlite3FunctionUsesThisSrc(tls *libc.TLS, pExpr uintptr, pSrcList uintptr) // Parse object is destroyed, but the zero register number means that it // will not generate any code in the preamble. func agginfoPersistExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:105464:12: */ - if (!(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x004000 | 0x002000))) != U32(0))) && + if (!(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_TokenOnly | EP_Reduced))) != U32(0))) && ((*Expr)(unsafe.Pointer(pExpr)).FpAggInfo != uintptr(0)) { var pAggInfo uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo var iAgg int32 = int32((*Expr)(unsafe.Pointer(pExpr)).FiAgg) var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 166 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_COLUMN { if (*AggInfo_col)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol+uintptr(iAgg)*32)).FpCExpr == pExpr { pExpr = Xsqlite3ExprDup(tls, db, pExpr, 0) @@ -86278,7 +85528,7 @@ func agginfoPersistExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { } } } - return 0 + return WRC_Continue } // Initialize a Walker object so that will persist AggInfo entries referenced @@ -86339,9 +85589,9 @@ func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* var pAggInfo uintptr = *(*uintptr)(unsafe.Pointer(pNC + 16 /* &.uNC */)) switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) { - case 166: + case TK_AGG_COLUMN: fallthrough - case 164: + case TK_COLUMN: { // Check to see if the column is in one of the tables in the FROM @@ -86405,7 +85655,7 @@ func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* } { var pE uintptr = (*ExprList_item)(unsafe.Pointer(pTerm)).FpExpr - if ((int32((*Expr)(unsafe.Pointer(pE)).Fop) == 164) && ((*Expr)(unsafe.Pointer(pE)).FiTable == (*Expr)(unsafe.Pointer(pExpr)).FiTable)) && (int32((*Expr)(unsafe.Pointer(pE)).FiColumn) == int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)) { + if ((int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_COLUMN) && ((*Expr)(unsafe.Pointer(pE)).FiTable == (*Expr)(unsafe.Pointer(pExpr)).FiTable)) && (int32((*Expr)(unsafe.Pointer(pE)).FiColumn) == int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn)) { (*AggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn = I16(j) goto __9 } @@ -86429,7 +85679,7 @@ func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* // pAggInfo->aCol[] entry. (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(166) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_AGG_COLUMN (*Expr)(unsafe.Pointer(pExpr)).FiAgg = I16(k) goto __3 } // endif pExpr->iTable==pItem->iCursor @@ -86443,12 +85693,12 @@ func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* goto __3 __3: // end loop over pSrcList } - return 1 + return WRC_Prune } - case 165: + case TK_AGG_FUNCTION: { - if (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & 0x20000) == 0) && + if (((*NameContext)(unsafe.Pointer(pNC)).FncFlags & NC_InAggFunc) == 0) && ((*Walker)(unsafe.Pointer(pWalker)).FwalkerDepth == int32((*Expr)(unsafe.Pointer(pExpr)).Fop2)) { // Check to see if pExpr is a duplicate of another aggregate // function that is already in the pAggInfo structure @@ -86490,7 +85740,7 @@ func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* } return 0 }(), enc, uint8(0)) - if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & U32(0x000002)) != 0 { + if ((*Expr)(unsafe.Pointer(pExpr)).Fflags & EP_Distinct) != 0 { (*AggInfo_func)(unsafe.Pointer(pItem)).FiDistinct = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) } else { (*AggInfo_func)(unsafe.Pointer(pItem)).FiDistinct = -1 @@ -86501,14 +85751,14 @@ func analyzeAggregate(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* (*Expr)(unsafe.Pointer(pExpr)).FiAgg = I16(i) (*Expr)(unsafe.Pointer(pExpr)).FpAggInfo = pAggInfo - return 1 + return WRC_Prune } else { - return 0 + return WRC_Continue } } } - return 0 + return WRC_Continue } // Analyze the pExpr expression looking for aggregate functions and @@ -86663,7 +85913,7 @@ func isAlterableTable(tls *libc.TLS, pParse uintptr, pTab uintptr) int32 { /* sq defer tls.Free(8) if (0 == Xsqlite3_strnicmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName, ts+10128 /* "sqlite_" */, 7)) || - ((((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x1000)) != U32(0)) && + ((((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Shadow) != U32(0)) && (Xsqlite3ReadOnlyShadowTables(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb) != 0)) { Xsqlite3ErrorMsg(tls, pParse, ts+10136 /* "table %s may not..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName)) return 1 @@ -86736,7 +85986,7 @@ func Xsqlite3AlterRenameTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pName __1: ; - pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), ((pSrc + 8 /* &.a */) + uintptr(0)*112)) + pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), (pSrc + 8 /* &.a */)) if !(!(pTab != 0)) { goto __2 } @@ -86745,7 +85995,7 @@ __2: ; iDb = Xsqlite3SchemaToIndex(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Table)(unsafe.Pointer(pTab)).FpSchema) zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0002)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_PreferBuiltin) // Get a NULL terminated version of the new table name. zName = Xsqlite3NameFromToken(tls, db, pName) @@ -86771,13 +86021,13 @@ __4: // Make sure it is not a system table being altered, or a reserved name // that the table is being renamed to. - if !(0 != isAlterableTable(tls, pParse, pTab)) { + if !(SQLITE_OK != isAlterableTable(tls, pParse, pTab)) { goto __5 } goto exit_rename_table __5: ; - if !(0 != Xsqlite3CheckObjectName(tls, pParse, zName, ts+8236 /* "table" */, zName)) { + if !(SQLITE_OK != Xsqlite3CheckObjectName(tls, pParse, zName, ts+8236 /* "table" */, zName)) { goto __6 } goto exit_rename_table @@ -86793,7 +86043,7 @@ __7: ; // Invoke the authorization callback. - if !(Xsqlite3AuthCheck(tls, pParse, 26, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_ALTER_TABLE, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0) { goto __8 } goto exit_rename_table @@ -86883,7 +86133,7 @@ __14: } i = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) Xsqlite3VdbeLoadString(tls, v, i, zName) - Xsqlite3VdbeAddOp4(tls, v, 167, i, 0, 0, pVTab, -12) + Xsqlite3VdbeAddOp4(tls, v, OP_VRename, i, 0, 0, pVTab, -12) __15: ; @@ -86937,20 +86187,20 @@ func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pNew)).FpSchema) zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName - zTab = ((*Table)(unsafe.Pointer(pNew)).FzName + uintptr(16)) // Skip the "sqlite_altertab_" prefix on the name + zTab = ((*Table)(unsafe.Pointer(pNew)).FzName + 16) // Skip the "sqlite_altertab_" prefix on the name pCol = ((*Table)(unsafe.Pointer(pNew)).FaCol + uintptr((int32((*Table)(unsafe.Pointer(pNew)).FnCol)-1))*32) pDflt = (*Column)(unsafe.Pointer(pCol)).FpDflt pTab = Xsqlite3FindTable(tls, db, zTab, zDb) // Invoke the authorization callback. - if Xsqlite3AuthCheck(tls, pParse, 26, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { + if Xsqlite3AuthCheck(tls, pParse, SQLITE_ALTER_TABLE, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { return } // Check that the new column is not specified as PRIMARY KEY or UNIQUE. // If there is a NOT NULL constraint, then the default value for the // column must not be NULL. - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0001) != 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_PRIMKEY) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+11438 /* "Cannot add a PRI..." */, 0) return } @@ -86959,15 +86209,15 @@ func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr ts+11470 /* "Cannot add a UNI..." */, 0) return } - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0060) == 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_GENERATED) == 0 { // If the default value for the new column was specified with a // literal NULL, then set pDflt to 0. This simplifies checking // for an SQL NULL default below. - if (pDflt != 0) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pDflt)).FpLeft)).Fop) == 119) { + if (pDflt != 0) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pDflt)).FpLeft)).Fop) == TK_NULL) { pDflt = uintptr(0) } - if ((((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00004000)) != 0) && ((*Table)(unsafe.Pointer(pNew)).FpFKey != 0)) && (pDflt != 0) { + if ((((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ForeignKeys) != 0) && ((*Table)(unsafe.Pointer(pNew)).FpFKey != 0)) && (pDflt != 0) { sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, ts+11497 /* "Cannot add a REF..." */) } @@ -86981,9 +86231,9 @@ func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr if pDflt != 0 { *(*uintptr)(unsafe.Pointer(bp + 40 /* pVal */)) = uintptr(0) var rc int32 - rc = Xsqlite3ValueFromExpr(tls, db, pDflt, uint8(1), uint8(0x41), bp+40 /* &pVal */) + rc = Xsqlite3ValueFromExpr(tls, db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, bp+40 /* &pVal */) - if rc != 0 { + if rc != SQLITE_OK { return } @@ -86993,7 +86243,7 @@ func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr } Xsqlite3ValueFree(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pVal */))) } - } else if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0040) != 0 { + } else if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_STORED) != 0 { sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, ts+11655 /* "cannot add a STO..." */) } @@ -87005,7 +86255,7 @@ func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr for (zEnd > zCol) && ((int32(*(*int8)(unsafe.Pointer(zEnd))) == ';') || ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zEnd)))]) & 0x01) != 0)) { *(*int8)(unsafe.Pointer(libc.PostDecUintptr(&zEnd, 1))) = int8(0) } - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0002)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_PreferBuiltin) Xsqlite3NestedParse(tls, pParse, ts+11682, /* "UPDATE \"%w\".sqli..." */ @@ -87021,12 +86271,12 @@ func Xsqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr v = Xsqlite3GetVdbe(tls, pParse) if v != 0 { r1 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 93, iDb, r1, 2) + Xsqlite3VdbeAddOp3(tls, v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT) Xsqlite3VdbeUsesBtree(tls, v, iDb) - Xsqlite3VdbeAddOp2(tls, v, 82, r1, -2) - Xsqlite3VdbeAddOp2(tls, v, 48, r1, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, r1, -2) + Xsqlite3VdbeAddOp2(tls, v, OP_IfPos, r1, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) - Xsqlite3VdbeAddOp3(tls, v, 94, iDb, 2, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3) Xsqlite3ReleaseTempReg(tls, pParse, r1) } @@ -87068,7 +86318,7 @@ func Xsqlite3AlterBeginAddColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr) { goto exit_begin_add_column __1: ; - pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), ((pSrc + 8 /* &.a */) + uintptr(0)*112)) + pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), (pSrc + 8 /* &.a */)) if !(!(pTab != 0)) { goto __2 } @@ -87092,7 +86342,7 @@ __3: goto exit_begin_add_column __4: ; - if !(0 != isAlterableTable(tls, pParse, pTab)) { + if !(SQLITE_OK != isAlterableTable(tls, pParse, pTab)) { goto __5 } goto exit_begin_add_column @@ -87203,7 +86453,7 @@ func Xsqlite3AlterRenameColumn(tls *libc.TLS, pParse uintptr, pSrc uintptr, pOld zNew = uintptr(0) // True to quote the new name // Locate the table to be altered - pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), ((pSrc + 8 /* &.a */) + uintptr(0)*112)) + pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), (pSrc + 8 /* &.a */)) if !(!(pTab != 0)) { goto __1 } @@ -87212,13 +86462,13 @@ __1: ; // Cannot alter a system table - if !(0 != isAlterableTable(tls, pParse, pTab)) { + if !(SQLITE_OK != isAlterableTable(tls, pParse, pTab)) { goto __2 } goto exit_rename_column __2: ; - if !(0 != isRealTable(tls, pParse, pTab)) { + if !(SQLITE_OK != isRealTable(tls, pParse, pTab)) { goto __3 } goto exit_rename_column @@ -87231,7 +86481,7 @@ __3: zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iSchema)*32)).FzDbSName // Invoke the authorization callback. - if !(Xsqlite3AuthCheck(tls, pParse, 26, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_ALTER_TABLE, zDb, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0) { goto __4 } goto exit_rename_column @@ -87285,7 +86535,7 @@ __10: __11: ; - bQuote = (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(pNew)).Fz + uintptr(0))))]) & 0x80) + bQuote = (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(pNew)).Fz)))]) & 0x80) Xsqlite3NestedParse(tls, pParse, ts+11937, /* "UPDATE \"%w\".sqli..." */ @@ -87326,7 +86576,7 @@ type RenameCtx = RenameCtx1 /* sqlite3.c:106452:26 */ func Xsqlite3RenameTokenMap(tls *libc.TLS, pParse uintptr, pPtr uintptr, pToken uintptr) uintptr { /* sqlite3.c:106513:21: */ var pNew uintptr - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != 3 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_UNMAP { pNew = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(RenameToken{}))) if pNew != 0 { (*RenameToken)(unsafe.Pointer(pNew)).Fp = pPtr @@ -87357,7 +86607,7 @@ func Xsqlite3RenameTokenRemap(tls *libc.TLS, pParse uintptr, pTo uintptr, pFrom func renameUnmapExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:106549:12: */ var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr) - return 0 + return WRC_Continue } // Iterate through the Select objects that are part of WITH clauses attached @@ -87397,15 +86647,15 @@ func renameUnmapSelectCb(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* s var pParse uintptr = (*Walker)(unsafe.Pointer(pWalker)).FpParse var i int32 if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { - return 2 + return WRC_Abort } - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0200000)) != 0 { - return 1 + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_View) != 0 { + return WRC_Prune } if (*Select)(unsafe.Pointer(p)).FpEList != 0 { var pList uintptr = (*Select)(unsafe.Pointer(p)).FpEList for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ { - if ((*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FzEName != 0) && ((int32(*(*uint8)(unsafe.Pointer(((pList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0) { + if ((*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FzEName != 0) && ((int32(*(*uint8)(unsafe.Pointer(((pList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME) { Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FzEName) } } @@ -87415,14 +86665,14 @@ func renameUnmapSelectCb(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* s for i = 0; i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc; i++ { Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(i)*112)).FzName) if Xsqlite3WalkExpr(tls, pWalker, (*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(i)*112)).FpOn) != 0 { - return 2 + return WRC_Abort } unmapColumnIdlistNames(tls, pParse, (*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(i)*112)).FpUsing) } } renameWalkWith(tls, pWalker, p) - return 0 + return WRC_Continue } // Remove all nodes that are part of expression pExpr from the rename list. @@ -87441,7 +86691,7 @@ func Xsqlite3RenameExprUnmap(tls *libc.TLS, pParse uintptr, pExpr uintptr) { /* (*Walker)(unsafe.Pointer(bp /* &sWalker */)).FxSelectCallback = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) int32 }{renameUnmapSelectCb})) - (*Parse)(unsafe.Pointer(pParse)).FeParseMode = U8(3) + (*Parse)(unsafe.Pointer(pParse)).FeParseMode = PARSE_MODE_UNMAP Xsqlite3WalkExpr(tls, bp /* &sWalker */, pExpr) (*Parse)(unsafe.Pointer(pParse)).FeParseMode = eMode } @@ -87463,7 +86713,7 @@ func Xsqlite3RenameExprlistUnmap(tls *libc.TLS, pParse uintptr, pEList uintptr) }{renameUnmapExprCb})) Xsqlite3WalkExprList(tls, bp /* &sWalker */, pEList) for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ { - if (int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0 { + if (int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME { Xsqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FzEName) } } @@ -87503,11 +86753,11 @@ func renameTokenFind(tls *libc.TLS, pParse uintptr, pCtx uintptr, pPtr uintptr) // because without a dummy callback, sqlite3WalkExpr() and similar do not // descend into sub-select statements. func renameColumnSelectCb(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sqlite3.c:106692:12: */ - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0200000)) != 0 { - return 1 + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_View) != 0 { + return WRC_Prune } renameWalkWith(tls, pWalker, p) - return 0 + return WRC_Continue } // This is a Walker expression callback. @@ -87519,16 +86769,16 @@ func renameColumnSelectCb(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* // constructed in RenameCtx object at pWalker->u.pRename. func renameColumnExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:106707:12: */ var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) - if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 77) && + if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_TRIGGER) && (int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) == (*RenameCtx)(unsafe.Pointer(p)).FiCol)) && ((*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(pWalker)).FpParse)).FpTriggerTab == (*RenameCtx)(unsafe.Pointer(p)).FpTab) { renameTokenFind(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p, pExpr) - } else if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) && + } else if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) && (int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) == (*RenameCtx)(unsafe.Pointer(p)).FiCol)) && ((*RenameCtx)(unsafe.Pointer(p)).FpTab == *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */))) { renameTokenFind(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p, pExpr) } - return 0 + return WRC_Continue } // The RenameCtx contains a list of tokens that reference a column that @@ -87589,7 +86839,7 @@ func renameColumnElistNames(tls *libc.TLS, pParse uintptr, pCtx uintptr, pEList var i int32 for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ { var zName uintptr = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(i)*32)).FzEName - if (((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0) && + if (((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME) && (zName != uintptr(0))) && (0 == Xsqlite3_stricmp(tls, zName, zOld)) { renameTokenFind(tls, pParse, pCtx, zName) @@ -87633,16 +86883,16 @@ func renameParseSql(tls *libc.TLS, p uintptr, zDb uintptr, db uintptr, zSql uint // occurs and the parse does not result in a new table, index or // trigger object, the database must be corrupt. libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(Parse{}))) - (*Parse)(unsafe.Pointer(p)).FeParseMode = U8(2) + (*Parse)(unsafe.Pointer(p)).FeParseMode = PARSE_MODE_RENAME (*Parse)(unsafe.Pointer(p)).Fdb = db (*Parse)(unsafe.Pointer(p)).FnQueryLoop = U32(1) rc = Xsqlite3RunParser(tls, p, zSql, bp /* &zErr */) (*Parse)(unsafe.Pointer(p)).FzErrMsg = *(*uintptr)(unsafe.Pointer(bp /* zErr */)) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - rc = 7 + rc = SQLITE_NOMEM } - if (((rc == 0) && + if (((rc == SQLITE_OK) && ((*Parse)(unsafe.Pointer(p)).FpNewTable == uintptr(0))) && ((*Parse)(unsafe.Pointer(p)).FpNewIndex == uintptr(0))) && ((*Parse)(unsafe.Pointer(p)).FpNewTrigger == uintptr(0)) { rc = Xsqlite3CorruptError(tls, 106852) } @@ -87665,7 +86915,7 @@ func renameEditSql(tls *libc.TLS, pCtx uintptr, pRename uintptr, zSql uintptr, z var nNew int32 = Xsqlite3Strlen30(tls, zNew) var nSql int32 = Xsqlite3Strlen30(tls, zSql) var db uintptr = Xsqlite3_context_db_handle(tls, pCtx) - var rc int32 = 0 + var rc int32 = SQLITE_OK var zQuot uintptr var zOut uintptr var nQuot int32 @@ -87677,7 +86927,7 @@ func renameEditSql(tls *libc.TLS, pCtx uintptr, pRename uintptr, zSql uintptr, z // quoted version of the new column name. zQuot = Xsqlite3MPrintf(tls, db, ts+12321 /* "\"%w\"" */, libc.VaList(bp, zNew)) if zQuot == uintptr(0) { - return 7 + return SQLITE_NOMEM } else { nQuot = Xsqlite3Strlen30(tls, zQuot) } @@ -87722,7 +86972,7 @@ func renameEditSql(tls *libc.TLS, pCtx uintptr, pRename uintptr, zSql uintptr, z Xsqlite3_result_text(tls, pCtx, zOut, -1, libc.UintptrFromInt32(-1)) Xsqlite3DbFree(tls, db, zOut) } else { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3_free(tls, zQuot) @@ -87742,7 +86992,7 @@ func renameResolveTrigger(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:10 var pStep uintptr // var sNC NameContext at bp, 56 - var rc int32 = 0 + var rc int32 = SQLITE_OK libc.Xmemset(tls, bp /* &sNC */, 0, uint64(unsafe.Sizeof(NameContext{}))) (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpParse = pParse @@ -87757,37 +87007,37 @@ func renameResolveTrigger(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:10 } // Resolve symbols in WHEN clause - if (rc == 0) && ((*Trigger)(unsafe.Pointer(pNew)).FpWhen != 0) { + if (rc == SQLITE_OK) && ((*Trigger)(unsafe.Pointer(pNew)).FpWhen != 0) { rc = Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*Trigger)(unsafe.Pointer(pNew)).FpWhen) } - for pStep = (*Trigger)(unsafe.Pointer(pNew)).Fstep_list; (rc == 0) && (pStep != 0); pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext { + for pStep = (*Trigger)(unsafe.Pointer(pNew)).Fstep_list; (rc == SQLITE_OK) && (pStep != 0); pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext { if (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect != 0 { Xsqlite3SelectPrep(tls, pParse, (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect, bp /* &sNC */) if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { rc = (*Parse)(unsafe.Pointer(pParse)).Frc } } - if (rc == 0) && ((*TriggerStep)(unsafe.Pointer(pStep)).FzTarget != 0) { + if (rc == SQLITE_OK) && ((*TriggerStep)(unsafe.Pointer(pStep)).FzTarget != 0) { var pSrc uintptr = Xsqlite3TriggerStepSrc(tls, pParse, pStep) if pSrc != 0 { var i int32 - for i = 0; (i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc) && (rc == 0); i++ { + for i = 0; (i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc) && (rc == SQLITE_OK); i++ { var p uintptr = ((pSrc + 8 /* &.a */) + uintptr(i)*112) (*SrcList_item)(unsafe.Pointer(p)).FpTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), p) (*SrcList_item)(unsafe.Pointer(p)).FiCursor = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) if (*SrcList_item)(unsafe.Pointer(p)).FpTab == uintptr(0) { - rc = 1 + rc = SQLITE_ERROR } else { (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(p)).FpTab)).FnTabRef++ rc = Xsqlite3ViewGetColumnNames(tls, pParse, (*SrcList_item)(unsafe.Pointer(p)).FpTab) } } (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpSrcList = pSrc - if (rc == 0) && ((*TriggerStep)(unsafe.Pointer(pStep)).FpWhere != 0) { + if (rc == SQLITE_OK) && ((*TriggerStep)(unsafe.Pointer(pStep)).FpWhere != 0) { rc = Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList) } @@ -87796,16 +87046,16 @@ func renameResolveTrigger(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:10 (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc = pSrc *(*uintptr)(unsafe.Pointer(bp /* &sNC */ + 16 /* &.uNC */)) = pUpsert - (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = 0x00200 + (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = NC_UUpsert rc = Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) - if rc == 0 { + if rc == SQLITE_OK { var pUpsertSet uintptr = (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet rc = Xsqlite3ResolveExprListNames(tls, bp /* &sNC */, pUpsertSet) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3ResolveExprNames(tls, bp /* &sNC */, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere) } (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FncFlags = 0 @@ -87813,7 +87063,7 @@ func renameResolveTrigger(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:10 (*NameContext)(unsafe.Pointer(bp /* &sNC */)).FpSrcList = uintptr(0) Xsqlite3SrcListDelete(tls, db, pSrc) } else { - rc = 7 + rc = SQLITE_NOMEM } } } @@ -87916,13 +87166,13 @@ func renameColumnFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintpt // A trigger var pStep uintptr db = Xsqlite3_context_db_handle(tls, context) - zSql = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zDb = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) - zTable = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8))) - iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(5)*8))) - zNew = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(6)*8))) - bQuote = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(7)*8))) - bTemp = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(8)*8))) + zSql = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + zDb = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) + zTable = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) + iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) + zNew = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 6*8))) + bQuote = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 7*8))) + bTemp = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 8*8))) xAuth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth _ = NotUsed @@ -87983,7 +87233,7 @@ __5: *(*uintptr)(unsafe.Pointer(bp + 456 /* &sWalker */ + 40 /* &.u */)) = bp /* &sCtx */ (*RenameCtx)(unsafe.Pointer(bp /* &sCtx */)).FpTab = pTab - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __6 } goto renameColumnFunc_done @@ -87996,22 +87246,22 @@ __6: if !(pSelect != 0) { goto __9 } - *(*U32)(unsafe.Pointer(pSelect + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0200000)) - (*Parse)(unsafe.Pointer(bp + 32 /* &sParse */)).Frc = 0 + *(*U32)(unsafe.Pointer(pSelect + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_View))) + (*Parse)(unsafe.Pointer(bp + 32 /* &sParse */)).Frc = SQLITE_OK Xsqlite3SelectPrep(tls, bp+32 /* &sParse */, pSelect, uintptr(0)) rc = func() int32 { if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - return 7 + return SQLITE_NOMEM } return (*Parse)(unsafe.Pointer(bp + 32 /* &sParse */)).Frc }() - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __11 } Xsqlite3WalkSelect(tls, bp+456 /* &sWalker */, pSelect) __11: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } goto renameColumnFunc_done @@ -88126,7 +87376,7 @@ __7: goto __33 __32: rc = renameResolveTrigger(tls, bp+32 /* &sParse */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __34 } goto renameColumnFunc_done @@ -88184,13 +87434,13 @@ __8: rc = renameEditSql(tls, context, bp /* &sCtx */, zSql, zNew, bQuote) renameColumnFunc_done: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __42 } if !((*Parse)(unsafe.Pointer(bp+32 /* &sParse */)).FzErrMsg != 0) { goto __43 } - renameColumnParseError(tls, context, 0, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+32 /* &sParse */) + renameColumnParseError(tls, context, 0, *(*uintptr)(unsafe.Pointer(argv + 1*8)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+32 /* &sParse */) goto __44 __43: Xsqlite3_result_error_code(tls, context, rc) @@ -88208,10 +87458,10 @@ __42: // Walker expression callback used by "RENAME TABLE". func renameTableExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:107274:12: */ var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) && ((*RenameCtx)(unsafe.Pointer(p)).FpTab == *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */))) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) && ((*RenameCtx)(unsafe.Pointer(p)).FpTab == *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */))) { renameTokenFind(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, p, (pExpr + 64 /* &.y */ /* &.pTab */)) } - return 0 + return WRC_Continue } // Walker select callback used by "RENAME TABLE". @@ -88219,12 +87469,12 @@ func renameTableSelectCb(tls *libc.TLS, pWalker uintptr, pSelect uintptr) int32 var i int32 var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) var pSrc uintptr = (*Select)(unsafe.Pointer(pSelect)).FpSrc - if ((*Select)(unsafe.Pointer(pSelect)).FselFlags & U32(0x0200000)) != 0 { - return 1 + if ((*Select)(unsafe.Pointer(pSelect)).FselFlags & SF_View) != 0 { + return WRC_Prune } if pSrc == uintptr(0) { - return 2 + return WRC_Abort } for i = 0; i < (*SrcList)(unsafe.Pointer(pSrc)).FnSrc; i++ { var pItem uintptr = ((pSrc + 8 /* &.a */) + uintptr(i)*112) @@ -88234,7 +87484,7 @@ func renameTableSelectCb(tls *libc.TLS, pWalker uintptr, pSelect uintptr) int32 } renameWalkWith(tls, pWalker, pSelect) - return 0 + return WRC_Continue } // This C function implements an SQL user function that is used by SQL code @@ -88259,11 +87509,11 @@ func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr defer tls.Free(560) var db uintptr = Xsqlite3_context_db_handle(tls, context) - var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var zInput uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) - var zOld uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8))) - var zNew uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(5)*8))) - var bTemp int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(6)*8))) + var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + var zInput uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) + var zOld uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) + var zNew uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) + var bTemp int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 6*8))) _ = NotUsed if ((zInput != 0) && (zOld != 0)) && (zNew != 0) { @@ -88294,8 +87544,8 @@ func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr rc = renameParseSql(tls, bp+80 /* &sParse */, zDb, db, zInput, bTemp) - if rc == 0 { - var isLegacy int32 = (int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x04000000))) + if rc == SQLITE_OK { + var isLegacy int32 = (int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_LegacyAlter)) if (*Parse)(unsafe.Pointer(bp+80 /* &sParse */)).FpNewTable != 0 { var pTab uintptr = (*Parse)(unsafe.Pointer(bp + 80 /* &sParse */)).FpNewTable @@ -88307,7 +87557,7 @@ func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr libc.Xmemset(tls, bp+504 /* &sNC */, 0, uint64(unsafe.Sizeof(NameContext{}))) (*NameContext)(unsafe.Pointer(bp + 504 /* &sNC */)).FpParse = bp + 80 /* &sParse */ - *(*U32)(unsafe.Pointer(pSelect + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0200000)) + *(*U32)(unsafe.Pointer(pSelect + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_View))) Xsqlite3SelectPrep(tls, bp+80 /* &sParse */, (*Table)(unsafe.Pointer(pTab)).FpSelect, bp+504 /* &sNC */) if (*Parse)(unsafe.Pointer(bp+80 /* &sParse */)).FnErr != 0 { rc = (*Parse)(unsafe.Pointer(bp + 80 /* &sParse */)).Frc @@ -88317,7 +87567,7 @@ func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr } } else { // Modify any FK definitions to point to the new table. - if (isLegacy == 0) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00004000)) != 0) { + if (isLegacy == 0) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ForeignKeys) != 0) { var pFKey uintptr for pFKey = (*Table)(unsafe.Pointer(pTab)).FpFKey; pFKey != 0; pFKey = (*FKey)(unsafe.Pointer(pFKey)).FpNextFrom { if Xsqlite3_stricmp(tls, (*FKey)(unsafe.Pointer(pFKey)).FzTo, zOld) == 0 { @@ -88352,7 +87602,7 @@ func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr if isLegacy == 0 { rc = renameResolveTrigger(tls, bp+80 /* &sParse */) - if rc == 0 { + if rc == SQLITE_OK { renameWalkTrigger(tls, bp+32 /* &sWalker */, pTrigger) for pStep = (*Trigger)(unsafe.Pointer(pTrigger)).Fstep_list; pStep != 0; pStep = (*TriggerStep)(unsafe.Pointer(pStep)).FpNext { if ((*TriggerStep)(unsafe.Pointer(pStep)).FzTarget != 0) && (0 == Xsqlite3_stricmp(tls, (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget, zOld)) { @@ -88364,12 +87614,12 @@ func renameTableFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr } } - if rc == 0 { + if rc == SQLITE_OK { rc = renameEditSql(tls, context, bp /* &sCtx */, zInput, zNew, bQuote) } - if rc != 0 { + if rc != SQLITE_OK { if (*Parse)(unsafe.Pointer(bp+80 /* &sParse */)).FzErrMsg != 0 { - renameColumnParseError(tls, context, 0, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), bp+80 /* &sParse */) + renameColumnParseError(tls, context, 0, *(*uintptr)(unsafe.Pointer(argv + 1*8)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+80 /* &sParse */) } else { Xsqlite3_result_error_code(tls, context, rc) } @@ -88406,10 +87656,10 @@ func renameTableTest(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr defer tls.Free(480) var db uintptr = Xsqlite3_context_db_handle(tls, context) - var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var zInput uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - var bTemp int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8))) - var isLegacy int32 = (int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x04000000))) + var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + var zInput uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + var bTemp int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) + var isLegacy int32 = (int32((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_LegacyAlter)) var xAuth Sqlite3_xauth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth (*Sqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) @@ -88420,7 +87670,7 @@ func renameTableTest(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr // var sParse Parse at bp, 424 rc = renameParseSql(tls, bp /* &sParse */, zDb, db, zInput, bTemp) - if rc == 0 { + if rc == SQLITE_OK { if ((isLegacy == 0) && ((*Parse)(unsafe.Pointer(bp /* &sParse */)).FpNewTable != 0)) && ((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp /* &sParse */)).FpNewTable)).FpSelect != 0) { // var sNC NameContext at bp+424, 56 @@ -88434,7 +87684,7 @@ func renameTableTest(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr if isLegacy == 0 { rc = renameResolveTrigger(tls, bp /* &sParse */) } - if rc == 0 { + if rc == SQLITE_OK { var i1 int32 = Xsqlite3SchemaToIndex(tls, db, (*Trigger)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp /* &sParse */)).FpNewTrigger)).FpTabSchema) var i2 int32 = Xsqlite3FindDbName(tls, db, zDb) if i1 == i2 { @@ -88444,8 +87694,8 @@ func renameTableTest(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr } } - if rc != 0 { - renameColumnParseError(tls, context, 1, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)), bp /* &sParse */) + if rc != SQLITE_OK { + renameColumnParseError(tls, context, 1, *(*uintptr)(unsafe.Pointer(argv + 2*8)), *(*uintptr)(unsafe.Pointer(argv + 3*8)), bp /* &sParse */) } renameParseCleanup(tls, bp /* &sParse */) } @@ -88459,37 +87709,9 @@ func Xsqlite3AlterFunctions(tls *libc.TLS) { /* sqlite3.c:107538:21: */ } var aAlterTableFuncs = [3]FuncDef{ - { - FnArg: int8(9), - FfuncFlags: (U32((0x00040000 | 1) | 0x0800)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12326 /* "sqlite_rename_co..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(7), - FfuncFlags: (U32((0x00040000 | 1) | 0x0800)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12347 /* "sqlite_rename_ta..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(5), - FfuncFlags: (U32((0x00040000 | 1) | 0x0800)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 12367 /* "sqlite_rename_te..." */, Fu: struct{ FpHash uintptr }{}}, -} /* sqlite3.c:107539:18 */ + {FnArg: int8(9), FfuncFlags: (U32((SQLITE_FUNC_INTERNAL | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FxSFunc: 0, FzName: ts + 12326 /* "sqlite_rename_co..." */}, + {FnArg: int8(7), FfuncFlags: (U32((SQLITE_FUNC_INTERNAL | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FxSFunc: 0, FzName: ts + 12347 /* "sqlite_rename_ta..." */}, + {FnArg: int8(5), FfuncFlags: (U32((SQLITE_FUNC_INTERNAL | SQLITE_UTF8) | SQLITE_FUNC_CONSTANT)), FxSFunc: 0, FzName: ts + 12367 /* "sqlite_rename_te..." */}} /* sqlite3.c:107539:18 */ //************* End of alter.c ********************************************** //************* Begin file analyze.c **************************************** @@ -88658,7 +87880,7 @@ func openStatTable(tls *libc.TLS, pParse uintptr, iDb int32, iStatCur int32, zWh // var aCreateTbl [3]U8 at bp+72, 3 var nToOpen int32 - if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0 { + if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0 { nToOpen = 2 } else { nToOpen = 1 @@ -88688,7 +87910,7 @@ func openStatTable(tls *libc.TLS, pParse uintptr, iDb int32, iStatCur int32, zWh Xsqlite3NestedParse(tls, pParse, ts+12386 /* "CREATE TABLE %Q...." */, libc.VaList(bp, (*Db)(unsafe.Pointer(pDb)).FzDbSName, zTab, aTable[i].FzCols)) *(*U32)(unsafe.Pointer(bp + 76 /* &aRoot[0] */ + uintptr(i)*4)) = U32((*Parse)(unsafe.Pointer(pParse)).FregRoot) - *(*U8)(unsafe.Pointer(bp + 72 /* &aCreateTbl[0] */ + uintptr(i))) = U8(0x10) + *(*U8)(unsafe.Pointer(bp + 72 /* &aCreateTbl[0] */ + uintptr(i))) = OPFLAG_P2ISREG } } else { // The table already exists. If zWhere is not NULL, delete all entries @@ -88704,7 +87926,7 @@ func openStatTable(tls *libc.TLS, pParse uintptr, iDb int32, iStatCur int32, zWh Xsqlite3NestedParse(tls, pParse, ts+12439 /* "DELETE FROM %Q.%..." */, libc.VaList(bp+56, (*Db)(unsafe.Pointer(pDb)).FzDbSName, zTab)) } else { // The sqlite_stat[134] table already exists. Delete all rows. - Xsqlite3VdbeAddOp2(tls, v, 137, int32(*(*U32)(unsafe.Pointer(bp + 76 /* &aRoot[0] */ + uintptr(i)*4))), iDb) + Xsqlite3VdbeAddOp2(tls, v, OP_Clear, int32(*(*U32)(unsafe.Pointer(bp + 76 /* &aRoot[0] */ + uintptr(i)*4))), iDb) } } } @@ -88712,7 +87934,7 @@ func openStatTable(tls *libc.TLS, pParse uintptr, iDb int32, iStatCur int32, zWh // Open the sqlite_stat[134] tables for writing. for i = 0; i < nToOpen; i++ { - Xsqlite3VdbeAddOp4Int(tls, v, 97, (iStatCur + i), int32(*(*U32)(unsafe.Pointer(bp + 76 /* &aRoot[0] */ + uintptr(i)*4))), iDb, 3) + Xsqlite3VdbeAddOp4Int(tls, v, OP_OpenWrite, (iStatCur + i), int32(*(*U32)(unsafe.Pointer(bp + 76 /* &aRoot[0] */ + uintptr(i)*4))), iDb, 3) Xsqlite3VdbeChangeP5(tls, v, uint16(*(*U8)(unsafe.Pointer(bp + 72 /* &aCreateTbl[0] */ + uintptr(i))))) Xsqlite3VdbeComment(tls, v, aTable[i].FzName, 0) } @@ -88722,15 +87944,9 @@ var aTable = [3]struct { FzName uintptr FzCols uintptr }{ - { - FzName: ts + 12457, /* "sqlite_stat1" */ - FzCols: ts + 12470 /* "tbl,idx,stat" */}, - { - FzName: ts + 12483, /* "sqlite_stat4" */ - FzCols: ts + 12496 /* "tbl,idx,neq,nlt,..." */}, - { - FzName: ts + 12524, /* "sqlite_stat3" */ - FzCols: uintptr(0)}, + {FzName: ts + 12457 /* "sqlite_stat1" */, FzCols: ts + 12470 /* "tbl,idx,stat" */}, + {FzName: ts + 12483 /* "sqlite_stat4" */, FzCols: ts + 12496 /* "tbl,idx,neq,nlt,..." */}, + {FzName: ts + 12524 /* "sqlite_stat3" */}, } /* sqlite3.c:107725:5 */ // Recommended number of samples for sqlite_stat4 @@ -88874,22 +88090,22 @@ func statInit(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql var db uintptr = Xsqlite3_context_db_handle(tls, context) // Database connection // Maximum number of samples. 0 if STAT4 data is not collected var mxSample int32 - if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0 { - mxSample = 24 + if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0 { + mxSample = SQLITE_STAT4_SAMPLES } else { mxSample = 0 } // Decode the three function arguments _ = argc - nCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + nCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) if uint64(unsafe.Sizeof(TRowcnt(0))) < uint64(8) { - nColUp = ((nCol + 1) & ^libc.Int32(1)) + nColUp = ((nCol + 1) & libc.CplInt32(1)) } else { nColUp = nCol } - nKeyCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + nKeyCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) // Allocate the space required for the StatAccum object n = (int32((uint64(unsafe.Sizeof(StatAccum{})) + @@ -88908,13 +88124,13 @@ func statInit(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql } (*StatAccum)(unsafe.Pointer(p)).Fdb = db - (*StatAccum)(unsafe.Pointer(p)).FnEst = TRowcnt(Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + (*StatAccum)(unsafe.Pointer(p)).FnEst = TRowcnt(Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) (*StatAccum)(unsafe.Pointer(p)).FnRow = TRowcnt(0) - (*StatAccum)(unsafe.Pointer(p)).FnLimit = int32(Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)))) + (*StatAccum)(unsafe.Pointer(p)).FnLimit = int32(Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8)))) (*StatAccum)(unsafe.Pointer(p)).FnCol = nCol (*StatAccum)(unsafe.Pointer(p)).FnKeyCol = nKeyCol (*StatAccum)(unsafe.Pointer(p)).FnSkipAhead = U8(0) - (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt = (p + uintptr(1)*128) + (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt = (p + 1*128) (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq = ((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt + uintptr(nColUp)*4) (*StatAccum)(unsafe.Pointer(p)).FmxSample = func() int32 { @@ -88930,7 +88146,7 @@ func statInit(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql (*StatAccum)(unsafe.Pointer(p)).FiGet = -1 (*StatAccum)(unsafe.Pointer(p)).FnPSample = (((*StatAccum)(unsafe.Pointer(p)).FnEst / (TRowcnt((mxSample / 3) + 1))) + TRowcnt(1)) (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanLt = ((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanEq + uintptr(nColUp)*4) - (*StatAccum)(unsafe.Pointer(p)).FiPrn = ((U32(0x689e962d) * U32(nCol)) ^ (0xd0944565 * U32(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))))) + (*StatAccum)(unsafe.Pointer(p)).FiPrn = ((U32(0x689e962d) * U32(nCol)) ^ (0xd0944565 * U32(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))))) // Set up the StatAccum.a[] and aBest[] arrays (*StatAccum)(unsafe.Pointer(p)).Fa = ((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanLt + uintptr(nColUp)*4) @@ -88958,25 +88174,10 @@ func statInit(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql } var statInitFuncdef = FuncDef{ - FnArg: int8(4), - FfuncFlags:// nArg - U32(1), - FpUserData:// funcFlags - uintptr(0), - FpNext:// pUserData - uintptr(0), - FxSFunc:// pNext - 0, - FxFinalize:// xSFunc - uintptr(0), - FxValue:// xFinalize - uintptr(0), - FxInverse: uintptr(0), - FzName:// xValue, xInverse - ts + 12537, /* "stat_init" */ // zName - Fu:// zName - struct{ FpHash uintptr }{}, -} /* sqlite3.c:108036:22 */ + FnArg: int8(4), // nArg + FfuncFlags: SQLITE_UTF8, // pNext + FxSFunc: 0, // xValue, xInverse + FzName: ts + 12537 /* "stat_init" */} /* sqlite3.c:108036:22 */ // pNew and pOld are both candidate non-periodic samples selected for // the same column (pNew->iCol==pOld->iCol). Ignoring this column and @@ -89110,7 +88311,7 @@ __2: anLt = (*StatSample)(unsafe.Pointer(pMin)).FanLt anDLt = (*StatSample)(unsafe.Pointer(pMin)).FanDLt sampleClear(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, pMin) - libc.Xmemmove(tls, pMin, (pMin + uintptr(1)*48), (uint64(unsafe.Sizeof(StatSample{})) * (uint64(((*StatAccum)(unsafe.Pointer(p)).FnSample - (*StatAccum)(unsafe.Pointer(p)).FiMin) - 1)))) + libc.Xmemmove(tls, pMin, (pMin + 1*48), (uint64(unsafe.Sizeof(StatSample{})) * (uint64(((*StatAccum)(unsafe.Pointer(p)).FnSample - (*StatAccum)(unsafe.Pointer(p)).FiMin) - 1)))) pSample = ((*StatAccum)(unsafe.Pointer(p)).Fa + uintptr(((*StatAccum)(unsafe.Pointer(p)).FnSample-1))*48) (*StatSample)(unsafe.Pointer(pSample)).FnRowid = U32(0) (*StatSample)(unsafe.Pointer(pSample)).FanEq = anEq @@ -89226,8 +88427,8 @@ func statPush(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql var i int32 // The three function arguments - var p uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var iChng int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + var p uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) + var iChng int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) _ = argc _ = context @@ -89260,11 +88461,11 @@ func statPush(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql (*StatAccum)(unsafe.Pointer(p)).FnRow++ if (*StatAccum)(unsafe.Pointer(p)).FmxSample != 0 { var nLt TRowcnt - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) == 1 { - sampleSetRowidInt64(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, (p + 32 /* &.current */), Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) == SQLITE_INTEGER { + sampleSetRowidInt64(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, (p + 32 /* &.current */), Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) } else { - sampleSetRowid(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, (p + 32 /* &.current */), Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))), - Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + sampleSetRowid(tls, (*StatAccum)(unsafe.Pointer(p)).Fdb, (p + 32 /* &.current */), Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))), + Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) } (*StatAccum)(unsafe.Pointer(p)).Fcurrent.FiHash = libc.AssignPtrUint32(p+88 /* &.iPrn */, (((*StatAccum)(unsafe.Pointer(p)).FiPrn * U32(1103515245)) + U32(12345))) @@ -89286,30 +88487,15 @@ func statPush(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql } } else if ((*StatAccum)(unsafe.Pointer(p)).FnLimit != 0) && ((*StatAccum)(unsafe.Pointer(p)).FnRow > (TRowcnt((*StatAccum)(unsafe.Pointer(p)).FnLimit) * (TRowcnt(int32((*StatAccum)(unsafe.Pointer(p)).FnSkipAhead) + 1)))) { (*StatAccum)(unsafe.Pointer(p)).FnSkipAhead++ - Xsqlite3_result_int(tls, context, (libc.Bool32(*(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt + uintptr(0)*4)) > TRowcnt(0)))) + Xsqlite3_result_int(tls, context, (libc.Bool32(*(*TRowcnt)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fcurrent.FanDLt)) > TRowcnt(0)))) } } var statPushFuncdef = FuncDef{ - FnArg: (int8(2 + 1)), - FfuncFlags:// nArg - U32(1), - FpUserData:// funcFlags - uintptr(0), - FpNext:// pUserData - uintptr(0), - FxSFunc:// pNext - 0, - FxFinalize:// xSFunc - uintptr(0), - FxValue:// xFinalize - uintptr(0), - FxInverse: uintptr(0), - FzName:// xValue, xInverse - ts + 12547, /* "stat_push" */ // zName - Fu:// zName - struct{ FpHash uintptr }{}, -} /* sqlite3.c:108326:22 */ + FnArg: (int8(2 + IsStat4)), // nArg + FfuncFlags: SQLITE_UTF8, // pNext + FxSFunc: 0, // xValue, xInverse + FzName: ts + 12547 /* "stat_push" */} /* sqlite3.c:108326:22 */ // Implementation of the stat_get(P,J) SQL function. This routine is // used to query statistical information that has been gathered into @@ -89332,11 +88518,11 @@ func statGet(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli bp := tls.Alloc(24) defer tls.Free(24) - var p uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var p uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) // STAT4 has a parameter on this routine. - var eCall int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + var eCall int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) - if eCall == 0 { + if eCall == STAT_GET_STAT1 { // Return the value to store in the "stat" column of the sqlite_stat1 // table for this index. // @@ -89383,7 +88569,7 @@ func statGet(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli } Xsqlite3_result_text(tls, context, zRet, -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) - } else if eCall == 1 { + } else if eCall == STAT_GET_ROWID { if (*StatAccum)(unsafe.Pointer(p)).FiGet < 0 { samplePushPrevious(tls, p, 0) (*StatAccum)(unsafe.Pointer(p)).FiGet = 0 @@ -89401,11 +88587,11 @@ func statGet(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli var aCnt uintptr = uintptr(0) switch eCall { - case 2: + case STAT_GET_NEQ: aCnt = (*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa + uintptr((*StatAccum)(unsafe.Pointer(p)).FiGet)*48)).FanEq break fallthrough - case 3: + case STAT_GET_NLT: aCnt = (*StatSample)(unsafe.Pointer((*StatAccum)(unsafe.Pointer(p)).Fa + uintptr((*StatAccum)(unsafe.Pointer(p)).FiGet)*48)).FanLt break fallthrough @@ -89440,30 +88626,15 @@ func statGet(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli } var statGetFuncdef = FuncDef{ - FnArg: (int8(1 + 1)), - FfuncFlags:// nArg - U32(1), - FpUserData:// funcFlags - uintptr(0), - FpNext:// pUserData - uintptr(0), - FxSFunc:// pNext - 0, - FxFinalize:// xSFunc - uintptr(0), - FxValue:// xFinalize - uintptr(0), - FxInverse: uintptr(0), - FzName:// xValue, xInverse - ts + 12574, /* "stat_get" */ // zName - Fu:// zName - struct{ FpHash uintptr }{}, -} /* sqlite3.c:108478:22 */ + FnArg: (int8(1 + IsStat4)), // nArg + FfuncFlags: SQLITE_UTF8, // pNext + FxSFunc: 0, // xValue, xInverse + FzName: ts + 12574 /* "stat_get" */} /* sqlite3.c:108478:22 */ func callStatGet(tls *libc.TLS, pParse uintptr, regStat int32, iParam int32, regOut int32) { /* sqlite3.c:108490:13: */ - Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, 69, iParam, (regStat + 1)) + Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_Integer, iParam, (regStat + 1)) - Xsqlite3VdbeAddFunctionCall(tls, pParse, 0, regStat, regOut, (1 + 1), + Xsqlite3VdbeAddFunctionCall(tls, pParse, 0, regStat, regOut, (1 + IsStat4), uintptr(unsafe.Pointer(&statGetFuncdef)), 0) } @@ -89533,7 +88704,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) - if Xsqlite3AuthCheck(tls, pParse, 28, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), + if Xsqlite3AuthCheck(tls, pParse, SQLITE_ANALYZE, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) != 0 { return } @@ -89543,11 +88714,11 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp if pStat1 == uintptr(0) { return } - (*Table)(unsafe.Pointer(pStat1)).FzName = (pStat1 + uintptr(1)*128) + (*Table)(unsafe.Pointer(pStat1)).FzName = (pStat1 + 1*128) libc.Xmemcpy(tls, (*Table)(unsafe.Pointer(pStat1)).FzName, ts+12457 /* "sqlite_stat1" */, uint64(13)) (*Table)(unsafe.Pointer(pStat1)).FnCol = int16(3) (*Table)(unsafe.Pointer(pStat1)).FiPKey = int16(-1) - Xsqlite3VdbeAddOp4(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, 173, 0, 0, 0, pStat1, -17) + Xsqlite3VdbeAddOp4(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_Noop, 0, 0, 0, pStat1, -17) } // Establish a read-lock on the table at the shared-cache level. @@ -89563,7 +88734,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp } return iTab }() - Xsqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab, 96) + Xsqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab, OP_OpenRead) Xsqlite3VdbeLoadString(tls, v, regTabname, (*Table)(unsafe.Pointer(pTab)).FzName) for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { @@ -89579,7 +88750,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) { needTableCnt = U8(0) } - if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2) { + if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY) { nCol = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) zIdxName = (*Table)(unsafe.Pointer(pTab)).FzName nColTest = (nCol - 1) @@ -89640,7 +88811,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp // Open a read-only cursor on the index being analyzed. - Xsqlite3VdbeAddOp3(tls, v, 96, iIdxCur, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, iIdxCur, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx) Xsqlite3VdbeComment(tls, v, ts+824 /* "%s" */, libc.VaList(bp+16, (*Index)(unsafe.Pointer(pIdx)).FzName)) @@ -89650,20 +88821,20 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp // (or for a WITHOUT ROWID table, the number of PK columns), // (2) the number of columns in the key without the rowid/pk // (3) estimated number of rows in the index, - Xsqlite3VdbeAddOp2(tls, v, 69, nCol, (regStat + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, nCol, (regStat + 1)) - Xsqlite3VdbeAddOp2(tls, v, 69, int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol), regRowid) - if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0 { - Xsqlite3VdbeAddOp2(tls, v, 92, iIdxCur, regTemp) - addrRewind = Xsqlite3VdbeAddOp1(tls, v, 37, iIdxCur) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol), regRowid) + if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0 { + Xsqlite3VdbeAddOp2(tls, v, OP_Count, iIdxCur, regTemp) + addrRewind = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iIdxCur) } else { - addrRewind = Xsqlite3VdbeAddOp1(tls, v, 37, iIdxCur) + addrRewind = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iIdxCur) - Xsqlite3VdbeAddOp3(tls, v, 92, iIdxCur, regTemp, 1) + Xsqlite3VdbeAddOp3(tls, v, OP_Count, iIdxCur, regTemp, 1) } - Xsqlite3VdbeAddOp2(tls, v, 69, (*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit, regTemp2) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, (*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit, regTemp2) Xsqlite3VdbeAddFunctionCall(tls, pParse, 0, (regStat + 1), regStat, 4, uintptr(unsafe.Pointer(&statInitFuncdef)), 0) @@ -89674,7 +88845,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp // regChng = 0 // goto next_push_0; // - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regChng) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regChng) addrNextRow = Xsqlite3VdbeCurrentAddr(tls, v) if nColTest > 0 { @@ -89693,25 +88864,25 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp // ... // regChng = N // goto endDistinctTest - Xsqlite3VdbeAddOp0(tls, v, 11) + Xsqlite3VdbeAddOp0(tls, v, OP_Goto) addrNextRow = Xsqlite3VdbeCurrentAddr(tls, v) - if ((nColTest == 1) && (int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) == 1)) && (int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0) { + if ((nColTest == 1) && (int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) == 1)) && (int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None) { // For a single-column UNIQUE index, once we have found a non-NULL // row, we know that all the rest will be distinct, so skip // subsequent distinctness tests. - Xsqlite3VdbeAddOp2(tls, v, 51, regPrev, endDistinctTest) + Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, regPrev, endDistinctTest) } for i = 0; i < nColTest; i++ { var pColl uintptr = Xsqlite3LocateCollSeq(tls, pParse, *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(i)*8))) - Xsqlite3VdbeAddOp2(tls, v, 69, i, regChng) - Xsqlite3VdbeAddOp3(tls, v, 89, iIdxCur, i, regTemp) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, i, regChng) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, i, regTemp) analyzeVdbeCommentIndexWithColumnName(tls, v, pIdx, i) - *(*int32)(unsafe.Pointer(aGotoChng + uintptr(i)*4)) = Xsqlite3VdbeAddOp4(tls, v, 52, regTemp, 0, (regPrev + i), pColl, -2) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x80)) + *(*int32)(unsafe.Pointer(aGotoChng + uintptr(i)*4)) = Xsqlite3VdbeAddOp4(tls, v, OP_Ne, regTemp, 0, (regPrev + i), pColl, -2) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NULLEQ) } - Xsqlite3VdbeAddOp2(tls, v, 69, nColTest, regChng) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, nColTest, regChng) Xsqlite3VdbeGoto(tls, v, endDistinctTest) // chng_addr_0: @@ -89722,7 +88893,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp Xsqlite3VdbeJumpHere(tls, v, (addrNextRow - 1)) for i = 0; i < nColTest; i++ { Xsqlite3VdbeJumpHere(tls, v, *(*int32)(unsafe.Pointer(aGotoChng + uintptr(i)*4))) - Xsqlite3VdbeAddOp3(tls, v, 89, iIdxCur, i, (regPrev + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, i, (regPrev + i)) analyzeVdbeCommentIndexWithColumnName(tls, v, pIdx, i) } Xsqlite3VdbeResolveLabel(tls, v, endDistinctTest) @@ -89734,10 +88905,10 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp // stat_push(P, regChng, regRowid) // 3rd parameter STAT4 only // Next csr // if !eof(csr) goto next_row; - if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0 { + if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0 { - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { - Xsqlite3VdbeAddOp2(tls, v, 134, iIdxCur, regRowid) + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { + Xsqlite3VdbeAddOp2(tls, v, OP_IdxRowid, iIdxCur, regRowid) } else { var pPk uintptr = Xsqlite3PrimaryKeyIndex(tls, (*Index)(unsafe.Pointer(pIdx)).FpTable) var j int32 @@ -89747,46 +88918,46 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp for j = 0; j < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); j++ { k = int32(Xsqlite3TableColumnToIndex(tls, pIdx, *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)))) - Xsqlite3VdbeAddOp3(tls, v, 89, iIdxCur, k, (regKey + j)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, k, (regKey + j)) analyzeVdbeCommentIndexWithColumnName(tls, v, pIdx, k) } - Xsqlite3VdbeAddOp3(tls, v, 91, regKey, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol), regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regKey, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol), regRowid) Xsqlite3ReleaseTempRange(tls, pParse, regKey, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) } } { - Xsqlite3VdbeAddFunctionCall(tls, pParse, 1, regStat, regTemp, (2 + 1), + Xsqlite3VdbeAddFunctionCall(tls, pParse, 1, regStat, regTemp, (2 + IsStat4), uintptr(unsafe.Pointer(&statPushFuncdef)), 0) if (*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit != 0 { var j1 int32 var j2 int32 var j3 int32 - j1 = Xsqlite3VdbeAddOp1(tls, v, 50, regTemp) - j2 = Xsqlite3VdbeAddOp1(tls, v, 18, regTemp) - j3 = Xsqlite3VdbeAddOp4Int(tls, v, 25, iIdxCur, 0, regPrev, 1) + j1 = Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, regTemp) + j2 = Xsqlite3VdbeAddOp1(tls, v, OP_If, regTemp) + j3 = Xsqlite3VdbeAddOp4Int(tls, v, OP_SeekGT, iIdxCur, 0, regPrev, 1) Xsqlite3VdbeJumpHere(tls, v, j1) - Xsqlite3VdbeAddOp2(tls, v, 5, iIdxCur, addrNextRow) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iIdxCur, addrNextRow) Xsqlite3VdbeJumpHere(tls, v, j2) Xsqlite3VdbeJumpHere(tls, v, j3) } else { - Xsqlite3VdbeAddOp2(tls, v, 5, iIdxCur, addrNextRow) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iIdxCur, addrNextRow) } } // Add the entry to the stat1 table. - callStatGet(tls, pParse, regStat, 0, regStat1) + callStatGet(tls, pParse, regStat, STAT_GET_STAT1, regStat1) - Xsqlite3VdbeAddOp4(tls, v, 91, regTabname, 3, regTemp, ts+12624 /* "BBB" */, 0) - Xsqlite3VdbeAddOp2(tls, v, 120, iStatCur, regNewRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, iStatCur, regTemp, regNewRowid) + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regTabname, 3, regTemp, ts+12624 /* "BBB" */, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iStatCur, regNewRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iStatCur, regTemp, regNewRowid) Xsqlite3VdbeChangeP4(tls, v, -1, pStat1, -6) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x08)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_APPEND) // Add the entries to the stat4 table. - if ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0) && ((*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit == 0) { + if ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0) && ((*Sqlite3)(unsafe.Pointer(db)).FnAnalysisLimit == 0) { var regEq int32 = regStat1 var regLt int32 = (regStat1 + 1) var regDLt int32 = (regStat1 + 2) @@ -89796,10 +88967,10 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp var addrNext int32 var addrIsNull int32 var seekOp U8 - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { - seekOp = uint8(32) + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { + seekOp = OP_NotExists } else { - seekOp = uint8(29) + seekOp = OP_NotFound } (*Parse)(unsafe.Pointer(pParse)).FnMem = func() int32 { @@ -89810,22 +88981,22 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp }() addrNext = Xsqlite3VdbeCurrentAddr(tls, v) - callStatGet(tls, pParse, regStat, 1, regSampleRowid) - addrIsNull = Xsqlite3VdbeAddOp1(tls, v, 50, regSampleRowid) + callStatGet(tls, pParse, regStat, STAT_GET_ROWID, regSampleRowid) + addrIsNull = Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, regSampleRowid) - callStatGet(tls, pParse, regStat, 2, regEq) - callStatGet(tls, pParse, regStat, 3, regLt) - callStatGet(tls, pParse, regStat, 4, regDLt) + callStatGet(tls, pParse, regStat, STAT_GET_NEQ, regEq) + callStatGet(tls, pParse, regStat, STAT_GET_NLT, regLt) + callStatGet(tls, pParse, regStat, STAT_GET_NDLT, regDLt) Xsqlite3VdbeAddOp4Int(tls, v, int32(seekOp), iTabCur, addrNext, regSampleRowid, 0) for i = 0; i < nCol; i++ { Xsqlite3ExprCodeLoadIndexColumn(tls, pParse, pIdx, iTabCur, i, (regCol + i)) } - Xsqlite3VdbeAddOp3(tls, v, 91, regCol, nCol, regSample) - Xsqlite3VdbeAddOp3(tls, v, 91, regTabname, 6, regTemp) - Xsqlite3VdbeAddOp2(tls, v, 120, (iStatCur + 1), regNewRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, (iStatCur + 1), regTemp, regNewRowid) - Xsqlite3VdbeAddOp2(tls, v, 11, 1, addrNext) // P1==1 for end-of-loop + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regCol, nCol, regSample) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regTabname, 6, regTemp) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, (iStatCur + 1), regNewRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, (iStatCur + 1), regTemp, regNewRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 1, addrNext) // P1==1 for end-of-loop Xsqlite3VdbeJumpHere(tls, v, addrIsNull) } @@ -89837,14 +89008,14 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp // name and the row count as the content. if (pOnlyIdx == uintptr(0)) && (needTableCnt != 0) { Xsqlite3VdbeComment(tls, v, ts+824 /* "%s" */, libc.VaList(bp+24, (*Table)(unsafe.Pointer(pTab)).FzName)) - Xsqlite3VdbeAddOp2(tls, v, 92, iTabCur, regStat1) - jZeroRows = Xsqlite3VdbeAddOp1(tls, v, 20, regStat1) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, regIdxname) + Xsqlite3VdbeAddOp2(tls, v, OP_Count, iTabCur, regStat1) + jZeroRows = Xsqlite3VdbeAddOp1(tls, v, OP_IfNot, regStat1) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regIdxname) - Xsqlite3VdbeAddOp4(tls, v, 91, regTabname, 3, regTemp, ts+12624 /* "BBB" */, 0) - Xsqlite3VdbeAddOp2(tls, v, 120, iStatCur, regNewRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, iStatCur, regTemp, regNewRowid) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x08)) + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regTabname, 3, regTemp, ts+12624 /* "BBB" */, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iStatCur, regNewRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iStatCur, regTemp, regNewRowid) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_APPEND) Xsqlite3VdbeChangeP4(tls, v, -1, pStat1, -6) Xsqlite3VdbeJumpHere(tls, v, jZeroRows) } @@ -89855,7 +89026,7 @@ func analyzeOneTable(tls *libc.TLS, pParse uintptr, pTab uintptr, pOnlyIdx uintp func loadAnalysis(tls *libc.TLS, pParse uintptr, iDb int32) { /* sqlite3.c:108893:13: */ var v uintptr = Xsqlite3GetVdbe(tls, pParse) if v != 0 { - Xsqlite3VdbeAddOp1(tls, v, 142, iDb) + Xsqlite3VdbeAddOp1(tls, v, OP_LoadAnalysis, iDb) } } @@ -89930,7 +89101,7 @@ func Xsqlite3Analyze(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintp // Read the database schema. If an error occurs, leave an error message // and code in pParse and return NULL. - if 0 != Xsqlite3ReadSchema(tls, pParse) { + if SQLITE_OK != Xsqlite3ReadSchema(tls, pParse) { return } @@ -89966,7 +89137,7 @@ func Xsqlite3Analyze(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintp } } if (int32((*Sqlite3)(unsafe.Pointer(db)).FnSqlExec) == 0) && ((libc.AssignUintptr(&v, Xsqlite3GetVdbe(tls, pParse))) != uintptr(0)) { - Xsqlite3VdbeAddOp0(tls, v, 158) + Xsqlite3VdbeAddOp0(tls, v, OP_Expire) } } @@ -89995,7 +89166,7 @@ func decodeIntArray(tls *libc.TLS, zIntArray uintptr, nOut int32, aOut uintptr, } for i = 0; (*(*int8)(unsafe.Pointer(z)) != 0) && (i < nOut); i++ { v = TRowcnt(0) - for ((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))))) >= '0') && (c <= '9') { + for ((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(z))))) >= '0') && (c <= '9') { v = (((v * TRowcnt(10)) + TRowcnt(c)) - TRowcnt('0')) z++ } @@ -90012,7 +89183,7 @@ func decodeIntArray(tls *libc.TLS, zIntArray uintptr, nOut int32, aOut uintptr, if pIndex != 0 { libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.bUnordered */, uint32(0), 2, 0x4) libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.noSkipScan */, uint32(0), 6, 0x40) - for *(*int8)(unsafe.Pointer(z + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(z)) != 0 { if Xsqlite3_strglob(tls, ts+12636 /* "unordered*" */, z) == 0 { libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.bUnordered */, uint32(1), 2, 0x4) } else if Xsqlite3_strglob(tls, ts+12647 /* "sz=[0-9]*" */, z) == 0 { @@ -90024,10 +89195,10 @@ func decodeIntArray(tls *libc.TLS, zIntArray uintptr, nOut int32, aOut uintptr, } else if Xsqlite3_strglob(tls, ts+12657 /* "noskipscan*" */, z) == 0 { libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.noSkipScan */, uint32(1), 6, 0x40) } - for (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) != 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) != ' ') { + for (int32(*(*int8)(unsafe.Pointer(z))) != 0) && (int32(*(*int8)(unsafe.Pointer(z))) != ' ') { z++ } - for int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == ' ' { + for int32(*(*int8)(unsafe.Pointer(z))) == ' ' { z++ } } @@ -90055,21 +89226,21 @@ func analysisLoader(tls *libc.TLS, pData uintptr, argc int32, argv uintptr, NotU _ = NotUsed _ = argc - if ((argv == uintptr(0)) || (*(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)) == uintptr(0))) || (*(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)) == uintptr(0)) { + if ((argv == uintptr(0)) || (*(*uintptr)(unsafe.Pointer(argv)) == uintptr(0))) || (*(*uintptr)(unsafe.Pointer(argv + 2*8)) == uintptr(0)) { return 0 } - pTable = Xsqlite3FindTable(tls, (*AnalysisInfo)(unsafe.Pointer(pInfo)).Fdb, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), (*AnalysisInfo)(unsafe.Pointer(pInfo)).FzDatabase) + pTable = Xsqlite3FindTable(tls, (*AnalysisInfo)(unsafe.Pointer(pInfo)).Fdb, *(*uintptr)(unsafe.Pointer(argv)), (*AnalysisInfo)(unsafe.Pointer(pInfo)).FzDatabase) if pTable == uintptr(0) { return 0 } - if *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) == uintptr(0) { + if *(*uintptr)(unsafe.Pointer(argv + 1*8)) == uintptr(0) { pIndex = uintptr(0) - } else if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) == 0 { + } else if Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv)), *(*uintptr)(unsafe.Pointer(argv + 1*8))) == 0 { pIndex = Xsqlite3PrimaryKeyIndex(tls, pTable) } else { - pIndex = Xsqlite3FindIndex(tls, (*AnalysisInfo)(unsafe.Pointer(pInfo)).Fdb, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), (*AnalysisInfo)(unsafe.Pointer(pInfo)).FzDatabase) + pIndex = Xsqlite3FindIndex(tls, (*AnalysisInfo)(unsafe.Pointer(pInfo)).Fdb, *(*uintptr)(unsafe.Pointer(argv + 1*8)), (*AnalysisInfo)(unsafe.Pointer(pInfo)).FzDatabase) } - z = *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)) + z = *(*uintptr)(unsafe.Pointer(argv + 2*8)) if pIndex != 0 { var aiRowEst uintptr = uintptr(0) @@ -90088,8 +89259,8 @@ func analysisLoader(tls *libc.TLS, pData uintptr, argc int32, argv uintptr, NotU decodeIntArray(tls, z, nCol, aiRowEst, (*Index)(unsafe.Pointer(pIndex)).FaiRowLogEst, pIndex) libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.hasStat1 */, uint32(1), 7, 0x80) if (*Index)(unsafe.Pointer(pIndex)).FpPartIdxWhere == uintptr(0) { - (*Table)(unsafe.Pointer(pTable)).FnRowLogEst = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiRowLogEst + uintptr(0)*2)) - *(*U32)(unsafe.Pointer(pTable + 64 /* &.tabFlags */)) |= (U32(0x0010)) + (*Table)(unsafe.Pointer(pTable)).FnRowLogEst = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiRowLogEst)) + *(*U32)(unsafe.Pointer(pTable + 64 /* &.tabFlags */)) |= (TF_HasStat1) } } else { // var fakeIdx Index at bp, 152 @@ -90097,7 +89268,7 @@ func analysisLoader(tls *libc.TLS, pData uintptr, argc int32, argv uintptr, NotU (*Index)(unsafe.Pointer(bp /* &fakeIdx */)).FszIdxRow = (*Table)(unsafe.Pointer(pTable)).FszTabRow decodeIntArray(tls, z, 1, uintptr(0), (pTable + 74 /* &.nRowLogEst */), bp /* &fakeIdx */) (*Table)(unsafe.Pointer(pTable)).FszTabRow = (*Index)(unsafe.Pointer(bp /* &fakeIdx */)).FszIdxRow - *(*U32)(unsafe.Pointer(pTable + 64 /* &.tabFlags */)) |= (U32(0x0010)) + *(*U32)(unsafe.Pointer(pTable + 64 /* &.tabFlags */)) |= (TF_HasStat1) } return 0 @@ -90150,8 +89321,8 @@ func initAvgEq(tls *libc.TLS, pIdx uintptr) { /* sqlite3.c:109185:13: */ nDist100 = (int64(100) * I64(*(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(pFinal)).FanDLt + uintptr(iCol)*4)))) nSample-- } else { - nRow = *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst + uintptr(0)*4)) - nDist100 = ((int64(100) * I64(*(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst + uintptr(0)*4)))) / I64(*(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst + uintptr((iCol+1))*4)))) + nRow = *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst)) + nDist100 = ((int64(100) * I64(*(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst)))) / I64(*(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowEst + uintptr((iCol+1))*4)))) } (*Index)(unsafe.Pointer(pIdx)).FnRowEst0 = nRow @@ -90184,7 +89355,7 @@ func findIndexOrPrimaryKey(tls *libc.TLS, db uintptr, zName uintptr, zDb uintptr var pIdx uintptr = Xsqlite3FindIndex(tls, db, zName, zDb) if pIdx == uintptr(0) { var pTab uintptr = Xsqlite3FindTable(tls, db, zName, zDb) - if (pTab != 0) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if (pTab != 0) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { pIdx = Xsqlite3PrimaryKeyIndex(tls, pTab) } } @@ -90213,7 +89384,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui zSql = Xsqlite3MPrintf(tls, db, zSql1, libc.VaList(bp, zDb)) if !(zSql != 0) { - return 7 + return SQLITE_NOMEM } rc = Xsqlite3_prepare(tls, db, zSql, -1, bp+16 /* &pStmt */, uintptr(0)) Xsqlite3DbFree(tls, db, zSql) @@ -90221,7 +89392,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui return rc } - for Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == 100 { + for Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == SQLITE_ROW { var nIdxCol int32 = 1 // Number of columns in stat4 records var zIndex uintptr // Index name @@ -90242,7 +89413,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui continue } - if !(((*Table)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FpTable))).FtabFlags & U32(0x0080)) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2) { + if !(((*Table)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FpTable))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY) { nIdxCol = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) } else { nIdxCol = int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) @@ -90255,7 +89426,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui (*Index)(unsafe.Pointer(pIdx)).FaSample = Xsqlite3DbMallocZero(tls, db, uint64(nByte)) if (*Index)(unsafe.Pointer(pIdx)).FaSample == uintptr(0) { Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) - return 7 + return SQLITE_NOMEM } pSpace = ((*Index)(unsafe.Pointer(pIdx)).FaSample + uintptr(nSample)*40) (*Index)(unsafe.Pointer(pIdx)).FaAvgEq = pSpace @@ -90277,7 +89448,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui zSql = Xsqlite3MPrintf(tls, db, zSql2, libc.VaList(bp+8, zDb)) if !(zSql != 0) { - return 7 + return SQLITE_NOMEM } rc = Xsqlite3_prepare(tls, db, zSql, -1, bp+16 /* &pStmt */, uintptr(0)) Xsqlite3DbFree(tls, db, zSql) @@ -90285,7 +89456,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui return rc } - for Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == 100 { + for Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == SQLITE_ROW { var zIndex uintptr // Index name var pIdx uintptr // Pointer to the index object var nCol int32 = 1 // Number of columns in index @@ -90320,7 +89491,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui (*IndexSample)(unsafe.Pointer(pSample)).Fp = Xsqlite3DbMallocZero(tls, db, (uint64((*IndexSample)(unsafe.Pointer(pSample)).Fn + 2))) if (*IndexSample)(unsafe.Pointer(pSample)).Fp == uintptr(0) { Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) - return 7 + return SQLITE_NOMEM } if (*IndexSample)(unsafe.Pointer(pSample)).Fn != 0 { libc.Xmemcpy(tls, (*IndexSample)(unsafe.Pointer(pSample)).Fp, Xsqlite3_column_blob(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)), 4), uint64((*IndexSample)(unsafe.Pointer(pSample)).Fn)) @@ -90328,7 +89499,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui (*Index)(unsafe.Pointer(pIdx)).FnSample++ } rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) - if rc == 0 { + if rc == SQLITE_OK { initAvgEq(tls, pPrevIdx) } return rc @@ -90337,7 +89508,7 @@ func loadStatTbl(tls *libc.TLS, db uintptr, zSql1 uintptr, zSql2 uintptr, zDb ui // Load content from the sqlite_stat4 table into // the Index.aSample[] arrays of all indices. func loadStat4(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* sqlite3.c:109389:12: */ - var rc int32 = 0 // Result codes from subroutines + var rc int32 = SQLITE_OK // Result codes from subroutines if Xsqlite3FindTable(tls, db, ts+12483 /* "sqlite_stat4" */, zDb) != 0 { rc = loadStatTbl(tls, db, @@ -90374,14 +89545,14 @@ func Xsqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) int32 { /* sqlit var i uintptr var zSql uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK var pSchema uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpSchema // Clear any prior statistics for i = (*Hash)(unsafe.Pointer((pSchema + 8 /* &.tblHash */))).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext { var pTab uintptr = (*HashElem)(unsafe.Pointer(i)).Fdata - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) &= (^libc.Uint32FromInt32(0x0010)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(TF_HasStat1))) } for i = (*Hash)(unsafe.Pointer((pSchema + 32 /* &.idxHash */))).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext { var pIdx uintptr = (*HashElem)(unsafe.Pointer(i)).Fdata @@ -90397,7 +89568,7 @@ func Xsqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) int32 { /* sqlit zSql = Xsqlite3MPrintf(tls, db, ts+12775 /* "SELECT tbl,idx,s..." */, libc.VaList(bp, (*AnalysisInfo)(unsafe.Pointer(bp+8 /* &sInfo */)).FzDatabase)) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_exec(tls, db, zSql, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 @@ -90416,7 +89587,7 @@ func Xsqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) int32 { /* sqlit } // Load the statistics from the sqlite_stat4 table. - if rc == 0 { + if rc == SQLITE_OK { (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable++ (*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0) rc = loadStat4(tls, db, (*AnalysisInfo)(unsafe.Pointer(bp+8 /* &sInfo */)).FzDatabase) @@ -90434,7 +89605,7 @@ func Xsqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) int32 { /* sqlit (*Index)(unsafe.Pointer(pIdx)).FaiRowEst = uintptr(0) } - if rc == 7 { + if rc == SQLITE_NOMEM { Xsqlite3OomFault(tls, db) } return rc @@ -90472,12 +89643,12 @@ func Xsqlite3AnalysisLoad(tls *libc.TLS, db uintptr, iDb int32) int32 { /* sqlit // // will fail because neither abc or def can be resolved. func resolveAttachExpr(tls *libc.TLS, pName uintptr, pExpr uintptr) int32 { /* sqlite3.c:109529:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if pExpr != 0 { - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 59 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_ID { rc = Xsqlite3ResolveExprNames(tls, pName, pExpr) } else { - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(115) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_STRING } } return rc @@ -90533,8 +89704,8 @@ func attachFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { / *(*uintptr)(unsafe.Pointer(bp + 56 /* zErrDyn */)) = uintptr(0) _ = NotUsed - zFile = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zName = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zFile = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + zName = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if !(zFile == uintptr(0)) { goto __1 } @@ -90570,7 +89741,7 @@ __6: ; (*Db)(unsafe.Pointer(pNew)).FpBt = uintptr(0) (*Db)(unsafe.Pointer(pNew)).FpSchema = uintptr(0) - rc = Xsqlite3BtreeOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pVfs */)), ts+12816 /* "x\x00" */, db, (pNew + 8 /* &.pBt */), 0, 0x00000100) + rc = Xsqlite3BtreeOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pVfs */)), ts+12816 /* "x\x00" */, db, (pNew + 8 /* &.pBt */), 0, SQLITE_OPEN_MAIN_DB) goto __4 __3: // This is a real ATTACH @@ -90580,11 +89751,11 @@ __3: // * Too many attached databases, // * Transaction currently open // * Specified database name already being used. - if !((*Sqlite3)(unsafe.Pointer(db)).FnDb >= (*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(7)*4)) + 2)) { + if !((*Sqlite3)(unsafe.Pointer(db)).FnDb >= (*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 7*4)) + 2)) { goto __7 } *(*uintptr)(unsafe.Pointer(bp + 56 /* zErrDyn */)) = Xsqlite3MPrintf(tls, db, ts+12819, /* "too many attache..." */ - libc.VaList(bp, *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(7)*4)))) + libc.VaList(bp, *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 7*4)))) goto attach_error __7: ; @@ -90642,10 +89813,10 @@ __13: // or may not be initialized. *(*uint32)(unsafe.Pointer(bp + 24 /* flags */)) = (*Sqlite3)(unsafe.Pointer(db)).FopenFlags rc = Xsqlite3ParseUri(tls, (*Sqlite3_vfs)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FpVfs)).FzName, zFile, bp+24 /* &flags */, bp+32 /* &pVfs */, bp+40 /* &zPath */, bp+48 /* &zErr */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __16 } - if !(rc == 7) { + if !(rc == SQLITE_NOMEM) { goto __17 } Xsqlite3OomFault(tls, db) @@ -90657,28 +89828,28 @@ __17: __16: ; - *(*uint32)(unsafe.Pointer(bp + 24 /* flags */)) |= uint32(0x00000100) + *(*uint32)(unsafe.Pointer(bp + 24 /* flags */)) |= SQLITE_OPEN_MAIN_DB rc = Xsqlite3BtreeOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pVfs */)), *(*uintptr)(unsafe.Pointer(bp + 40 /* zPath */)), db, (pNew + 8 /* &.pBt */), 0, int32(*(*uint32)(unsafe.Pointer(bp + 24 /* flags */)))) (*Sqlite3)(unsafe.Pointer(db)).FnDb++ (*Db)(unsafe.Pointer(pNew)).FzDbSName = Xsqlite3DbStrDup(tls, db, zName) __4: ; (*Sqlite3)(unsafe.Pointer(db)).FnoSharedCache = U8(0) - if !(rc == 19) { + if !(rc == SQLITE_CONSTRAINT) { goto __18 } - rc = 1 + rc = SQLITE_ERROR *(*uintptr)(unsafe.Pointer(bp + 56 /* zErrDyn */)) = Xsqlite3MPrintf(tls, db, ts+12886 /* "database is alre..." */, 0) goto __19 __18: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __20 } (*Db)(unsafe.Pointer(pNew)).FpSchema = Xsqlite3SchemaGet(tls, db, (*Db)(unsafe.Pointer(pNew)).FpBt) if !(!(int32((*Db)(unsafe.Pointer(pNew)).FpSchema) != 0)) { goto __21 } - rc = 7 + rc = SQLITE_NOMEM goto __22 __21: if !(((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pNew)).FpSchema)).Ffile_format != 0) && (int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pNew)).FpSchema)).Fenc) != (int32((*Sqlite3)(unsafe.Pointer(db)).Fenc)))) { @@ -90686,7 +89857,7 @@ __21: } *(*uintptr)(unsafe.Pointer(bp + 56 /* zErrDyn */)) = Xsqlite3MPrintf(tls, db, ts+12915 /* "attached databas..." */, 0) - rc = 1 + rc = SQLITE_ERROR __23: ; __22: @@ -90695,19 +89866,19 @@ __22: pPager = Xsqlite3BtreePager(tls, (*Db)(unsafe.Pointer(pNew)).FpBt) Xsqlite3PagerLockingMode(tls, pPager, int32((*Sqlite3)(unsafe.Pointer(db)).FdfltLockMode)) Xsqlite3BtreeSecureDelete(tls, (*Db)(unsafe.Pointer(pNew)).FpBt, - Xsqlite3BtreeSecureDelete(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt, -1)) + Xsqlite3BtreeSecureDelete(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt, -1)) Xsqlite3BtreeSetPagerFlags(tls, (*Db)(unsafe.Pointer(pNew)).FpBt, - (uint32(uint64(0x03) | ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x38))))) + (uint32(PAGER_SYNCHRONOUS_FULL | ((*Sqlite3)(unsafe.Pointer(db)).Fflags & PAGER_FLAGS_MASK)))) Xsqlite3BtreeLeave(tls, (*Db)(unsafe.Pointer(pNew)).FpBt) __20: ; __19: ; - (*Db)(unsafe.Pointer(pNew)).Fsafety_level = (U8(2 + 1)) - if !((rc == 0) && ((*Db)(unsafe.Pointer(pNew)).FzDbSName == uintptr(0))) { + (*Db)(unsafe.Pointer(pNew)).Fsafety_level = (U8(SQLITE_DEFAULT_SYNCHRONOUS + 1)) + if !((rc == SQLITE_OK) && ((*Db)(unsafe.Pointer(pNew)).FzDbSName == uintptr(0))) { goto __24 } - rc = 7 + rc = SQLITE_NOMEM __24: ; Xsqlite3_free_filename(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* zPath */))) @@ -90716,12 +89887,12 @@ __24: // If this fails, or if opening the file failed, then close the file and // remove the entry from the db->aDb[] array. i.e. put everything back the // way we found it. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __25 } Xsqlite3BtreeEnterAll(tls, db) (*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = U8(0) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (^libc.Uint32FromInt32(0x0010)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaKnownOk))) if !(!((int32(*(*uint8)(unsafe.Pointer(db + 176 /* &.init */ + 8 /* &.reopenMemdb */)) & 0x4 >> 2)) != 0)) { goto __26 } @@ -90750,7 +89921,7 @@ __29: ; Xsqlite3ResetAllSchemasOfConnection(tls, db) (*Sqlite3)(unsafe.Pointer(db)).FnDb = iDb - if !((rc == 7) || (rc == (10 | (int32(12) << 8)))) { + if !((rc == SQLITE_NOMEM) || (rc == (SQLITE_IOERR | (int32(12) << 8)))) { goto __30 } Xsqlite3OomFault(tls, db) @@ -90808,7 +89979,7 @@ func detachFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { / // var zErr [128]int8 at bp+24, 128 var pTrig uintptr - zName = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zName = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) db = Xsqlite3_context_db_handle(tls, context) pDb = uintptr(0) @@ -90871,7 +90042,7 @@ __9: // If any TEMP triggers reference the schema being detached, move those // triggers to reference the TEMP schema itself. - pEntry = (*Hash)(unsafe.Pointer(((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema + 56 /* &.trigHash */))).Ffirst + pEntry = (*Hash)(unsafe.Pointer(((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema + 56 /* &.trigHash */))).Ffirst __10: if !(pEntry != 0) { goto __11 @@ -90922,7 +90093,7 @@ __1: libc.Xmemset(tls, bp /* &sName */, 0, uint64(unsafe.Sizeof(NameContext{}))) (*NameContext)(unsafe.Pointer(bp /* &sName */)).FpParse = pParse - if !(((0 != (libc.AssignInt32(&rc, resolveAttachExpr(tls, bp /* &sName */, pFilename)))) || (0 != (libc.AssignInt32(&rc, resolveAttachExpr(tls, bp /* &sName */, pDbname))))) || (0 != (libc.AssignInt32(&rc, resolveAttachExpr(tls, bp /* &sName */, pKey))))) { + if !(((SQLITE_OK != (libc.AssignInt32(&rc, resolveAttachExpr(tls, bp /* &sName */, pFilename)))) || (SQLITE_OK != (libc.AssignInt32(&rc, resolveAttachExpr(tls, bp /* &sName */, pDbname))))) || (SQLITE_OK != (libc.AssignInt32(&rc, resolveAttachExpr(tls, bp /* &sName */, pKey))))) { goto __2 } goto attach_end @@ -90932,7 +90103,7 @@ __2: if !(pAuthArg != 0) { goto __3 } - if !(int32((*Expr)(unsafe.Pointer(pAuthArg)).Fop) == 115) { + if !(int32((*Expr)(unsafe.Pointer(pAuthArg)).Fop) == TK_STRING) { goto __4 } zAuthArg = *(*uintptr)(unsafe.Pointer(pAuthArg + 8 /* &.u */)) @@ -90942,7 +90113,7 @@ __4: __5: ; rc = Xsqlite3AuthCheck(tls, pParse, type1, zAuthArg, uintptr(0), uintptr(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __6 } goto attach_end @@ -90965,7 +90136,7 @@ __3: // Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this // statement only). For DETACH, set it to false (expire all existing // statements). - Xsqlite3VdbeAddOp1(tls, v, 158, (libc.Bool32(type1 == 24))) + Xsqlite3VdbeAddOp1(tls, v, OP_Expire, (libc.Bool32(type1 == SQLITE_ATTACH))) __7: ; @@ -90979,57 +90150,27 @@ attach_end: // // DETACH pDbname func Xsqlite3Detach(tls *libc.TLS, pParse uintptr, pDbname uintptr) { /* sqlite3.c:109892:21: */ - codeAttach(tls, pParse, 25, uintptr(unsafe.Pointer(&detach_func)), pDbname, uintptr(0), uintptr(0), pDbname) + codeAttach(tls, pParse, SQLITE_DETACH, uintptr(unsafe.Pointer(&detach_func)), pDbname, uintptr(0), uintptr(0), pDbname) } var detach_func = FuncDef{ - FnArg: int8(1), - FfuncFlags:// nArg - U32(1), - FpUserData:// funcFlags - uintptr(0), - FpNext:// pUserData - uintptr(0), - FxSFunc:// pNext - 0, - FxFinalize:// xSFunc - uintptr(0), - FxValue:// xFinalize - uintptr(0), - FxInverse: uintptr(0), - FzName:// xValue, xInverse - ts + 13080, /* "sqlite_detach" */ // zName - Fu:// zName - struct{ FpHash uintptr }{}, -} /* sqlite3.c:109893:24 */ + FnArg: int8(1), // nArg + FfuncFlags: SQLITE_UTF8, // pNext + FxSFunc: 0, // xValue, xInverse + FzName: ts + 13080 /* "sqlite_detach" */} /* sqlite3.c:109893:24 */ // Called by the parser to compile an ATTACH statement. // // ATTACH p AS pDbname KEY pKey func Xsqlite3Attach(tls *libc.TLS, pParse uintptr, p uintptr, pDbname uintptr, pKey uintptr) { /* sqlite3.c:109912:21: */ - codeAttach(tls, pParse, 24, uintptr(unsafe.Pointer(&attach_func)), p, p, pDbname, pKey) + codeAttach(tls, pParse, SQLITE_ATTACH, uintptr(unsafe.Pointer(&attach_func)), p, p, pDbname, pKey) } var attach_func = FuncDef{ - FnArg: int8(3), - FfuncFlags:// nArg - U32(1), - FpUserData:// funcFlags - uintptr(0), - FpNext:// pUserData - uintptr(0), - FxSFunc:// pNext - 0, - FxFinalize:// xSFunc - uintptr(0), - FxValue:// xFinalize - uintptr(0), - FxInverse: uintptr(0), - FzName:// xValue, xInverse - ts + 13094, /* "sqlite_attach" */ // zName - Fu:// zName - struct{ FpHash uintptr }{}, -} /* sqlite3.c:109913:24 */ + FnArg: int8(3), // nArg + FfuncFlags: SQLITE_UTF8, // pNext + FxSFunc: 0, // xValue, xInverse + FzName: ts + 13094 /* "sqlite_attach" */} /* sqlite3.c:109913:24 */ // Initialize a DbFixer structure. This routine must be called prior // to passing the structure to one of the sqliteFixAAAA() routines below. @@ -91154,20 +90295,20 @@ func Xsqlite3FixExpr(tls *libc.TLS, pFix uintptr, pExpr uintptr) int32 { /* sqli for pExpr != 0 { if !(int32((*DbFixer)(unsafe.Pointer(pFix)).FbTemp) != 0) { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x40000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_FromDDL) } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 153 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_VARIABLE { if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*DbFixer)(unsafe.Pointer(pFix)).FpParse)).Fdb)).Finit.Fbusy != 0 { - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(119) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_NULL } else { Xsqlite3ErrorMsg(tls, (*DbFixer)(unsafe.Pointer(pFix)).FpParse, ts+13154 /* "%s cannot use va..." */, libc.VaList(bp, (*DbFixer)(unsafe.Pointer(pFix)).FzType)) return 1 } } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x004000 | 0x800000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_TokenOnly | EP_Leaf))) != U32(0) { break } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { if Xsqlite3FixSelect(tls, pFix, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) != 0 { return 1 } @@ -91313,14 +90454,14 @@ func Xsqlite3_set_authorizer(tls *libc.TLS, db uintptr, xAuth uintptr, pArg uint Xsqlite3ExpirePreparedStatements(tls, db, 1) } Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // Write an error message into pParse->zErrMsg that explains that the // user-supplied authorization function returned an illegal value. func sqliteAuthBadReturnCode(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110208:13: */ Xsqlite3ErrorMsg(tls, pParse, ts+13178 /* "authorizer malfu..." */, 0) - (*Parse)(unsafe.Pointer(pParse)).Frc = 1 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR } // Invoke the authorization callback for permission to read column zCol from @@ -91339,17 +90480,17 @@ func Xsqlite3AuthReadCol(tls *libc.TLS, pParse uintptr, zTab uintptr, zCol uintp var rc int32 // Auth callback return code if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 { - return 0 + return SQLITE_OK } - rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 488 /* &.xAuth */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpAuthArg, 20, zTab, zCol, zDb, (*Parse)(unsafe.Pointer(pParse)).FzAuthContext) - if rc == 1 { + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 488 /* &.xAuth */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpAuthArg, SQLITE_READ, zTab, zCol, zDb, (*Parse)(unsafe.Pointer(pParse)).FzAuthContext) + if rc == SQLITE_DENY { var z uintptr = Xsqlite3_mprintf(tls, ts+9997 /* "%s.%s" */, libc.VaList(bp, zTab, zCol)) if ((*Sqlite3)(unsafe.Pointer(db)).FnDb > 2) || (iDb != 0) { z = Xsqlite3_mprintf(tls, ts+13201 /* "%s.%z" */, libc.VaList(bp+16, zDb, z)) } Xsqlite3ErrorMsg(tls, pParse, ts+13207 /* "access to %z is ..." */, libc.VaList(bp+32, z)) - (*Parse)(unsafe.Pointer(pParse)).Frc = 23 - } else if (rc != 2) && (rc != 0) { + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_AUTH + } else if (rc != SQLITE_IGNORE) && (rc != SQLITE_OK) { sqliteAuthBadReturnCode(tls, pParse) } return rc @@ -91380,7 +90521,7 @@ func Xsqlite3AuthRead(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSchema uint return } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 77 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_TRIGGER { pTab = (*Parse)(unsafe.Pointer(pParse)).FpTriggerTab } else { @@ -91406,8 +90547,8 @@ func Xsqlite3AuthRead(tls *libc.TLS, pParse uintptr, pExpr uintptr, pSchema uint zCol = ts + 9563 /* "ROWID" */ } - if 2 == Xsqlite3AuthReadCol(tls, pParse, (*Table)(unsafe.Pointer(pTab)).FzName, zCol, iDb) { - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(119) + if SQLITE_IGNORE == Xsqlite3AuthReadCol(tls, pParse, (*Table)(unsafe.Pointer(pTab)).FzName, zCol, iDb) { + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_NULL } } @@ -91422,12 +90563,12 @@ func Xsqlite3AuthCheck(tls *libc.TLS, pParse uintptr, code int32, zArg1 uintptr, // Don't do any authorization checks if the database is initialising // or if the parser is being invoked from within sqlite3_declare_vtab. - if ((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0) || (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != 0) { - return 0 + if ((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0) || (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL) { + return SQLITE_OK } if (*Sqlite3)(unsafe.Pointer(db)).FxAuth == uintptr(0) { - return 0 + return SQLITE_OK } // EVIDENCE-OF: R-43249-19882 The third through sixth parameters to the @@ -91438,11 +90579,11 @@ func Xsqlite3AuthCheck(tls *libc.TLS, pParse uintptr, code int32, zArg1 uintptr, // parameters can be either NULL or a string. rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 488 /* &.xAuth */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpAuthArg, code, zArg1, zArg2, zArg3, (*Parse)(unsafe.Pointer(pParse)).FzAuthContext) - if rc == 1 { + if rc == SQLITE_DENY { Xsqlite3ErrorMsg(tls, pParse, ts+13234 /* "not authorized" */, 0) - (*Parse)(unsafe.Pointer(pParse)).Frc = 23 - } else if (rc != 0) && (rc != 2) { - rc = 1 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_AUTH + } else if (rc != SQLITE_OK) && (rc != SQLITE_IGNORE) { + rc = SQLITE_DENY sqliteAuthBadReturnCode(tls, pParse) } return rc @@ -91526,7 +90667,7 @@ func codeTableLocks(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110485:13: */ for i = 0; i < (*Parse)(unsafe.Pointer(pParse)).FnTableLock; i++ { var p uintptr = ((*Parse)(unsafe.Pointer(pParse)).FaTableLock + uintptr(i)*24) var p1 int32 = (*TableLock)(unsafe.Pointer(p)).FiDb - Xsqlite3VdbeAddOp4(tls, pVdbe, 161, p1, int32((*TableLock)(unsafe.Pointer(p)).FiTab), int32((*TableLock)(unsafe.Pointer(p)).FisWriteLock), + Xsqlite3VdbeAddOp4(tls, pVdbe, OP_TableLock, p1, int32((*TableLock)(unsafe.Pointer(p)).FiTab), int32((*TableLock)(unsafe.Pointer(p)).FisWriteLock), (*TableLock)(unsafe.Pointer(p)).FzLockName, -1) } } @@ -91555,8 +90696,8 @@ func Xsqlite3FinishCoding(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110526:2 return } if ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) || ((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) { - if (*Parse)(unsafe.Pointer(pParse)).Frc == 0 { - (*Parse)(unsafe.Pointer(pParse)).Frc = 1 + if (*Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR } return } @@ -91566,7 +90707,7 @@ func Xsqlite3FinishCoding(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110526:2 v = Xsqlite3GetVdbe(tls, pParse) if v != 0 { - Xsqlite3VdbeAddOp0(tls, v, 68) + Xsqlite3VdbeAddOp0(tls, v, OP_Halt) // The cookie mask contains one bit for each database file open. // (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are @@ -91587,8 +90728,8 @@ func Xsqlite3FinishCoding(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110526:2 Xsqlite3VdbeUsesBtree(tls, v, iDb) pSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpSchema Xsqlite3VdbeAddOp4Int(tls, v, - 2, // Opcode - iDb, // P1 + OP_Transaction, // Opcode + iDb, // P1 (libc.Bool32((((*Parse)(unsafe.Pointer(pParse)).FwriteMask) & (YDbMask((YDbMask(1))) << (iDb))) != YDbMask(0))), // P2 (*Schema)(unsafe.Pointer(pSchema)).Fschema_cookie, // P3 (*Schema)(unsafe.Pointer(pSchema)).FiGeneration) @@ -91599,7 +90740,7 @@ func Xsqlite3FinishCoding(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110526:2 } for i = 0; i < (*Parse)(unsafe.Pointer(pParse)).FnVtabLock; i++ { var vtab uintptr = Xsqlite3GetVTable(tls, db, *(*uintptr)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).FapVtabLock + uintptr(i)*8))) - Xsqlite3VdbeAddOp4(tls, v, 162, 0, 0, 0, vtab, -12) + Xsqlite3VdbeAddOp4(tls, v, OP_VBegin, 0, 0, 0, vtab, -12) } (*Parse)(unsafe.Pointer(pParse)).FnVtabLock = 0 @@ -91639,9 +90780,9 @@ func Xsqlite3FinishCoding(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:110526:2 // See ticket [a696379c1f08866] Xsqlite3VdbeMakeReady(tls, v, pParse) - (*Parse)(unsafe.Pointer(pParse)).Frc = 101 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_DONE } else { - (*Parse)(unsafe.Pointer(pParse)).Frc = 1 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR } } @@ -91678,7 +90819,7 @@ func Xsqlite3NestedParse(tls *libc.TLS, pParse uintptr, zFormat uintptr, va uint // exceeds SQLITE_LIMIT_LENGTH. In the latter case, we need to set // an error if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) { - (*Parse)(unsafe.Pointer(pParse)).Frc = 18 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_TOOBIG } (*Parse)(unsafe.Pointer(pParse)).FnErr++ return @@ -91727,14 +90868,14 @@ func Xsqlite3FindTable(tls *libc.TLS, db uintptr, zName uintptr, zDatabase uintp p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).FpSchema + 8 /* &.tblHash */), zName) if (p == uintptr(0)) && (Xsqlite3_strnicmp(tls, zName, ts+10128 /* "sqlite_" */, 7) == 0) { if i == 1 { - if ((Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+13268 /* "sqlite_temp_sche..." */ +uintptr(7))) == 0) || - (Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+13287 /* "sqlite_schema" */ +uintptr(7))) == 0)) || - (Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+7541 /* "sqlite_master" */ +uintptr(7))) == 0) { - p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema + 8 /* &.tblHash */), + if ((Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+13268 /* "sqlite_temp_sche..." */ +7)) == 0) || + (Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+13287 /* "sqlite_schema" */ +7)) == 0)) || + (Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+7541 /* "sqlite_master" */ +7)) == 0) { + p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema + 8 /* &.tblHash */), ts+13301 /* "sqlite_temp_mast..." */) } } else { - if Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+13287 /* "sqlite_schema" */ +uintptr(7))) == 0 { + if Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+13287 /* "sqlite_schema" */ +7)) == 0 { p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).FpSchema + 8 /* &.tblHash */), ts+7541 /* "sqlite_master" */) } @@ -91742,12 +90883,12 @@ func Xsqlite3FindTable(tls *libc.TLS, db uintptr, zName uintptr, zDatabase uintp } } else { // Match against TEMP first - p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema + 8 /* &.tblHash */), zName) + p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema + 8 /* &.tblHash */), zName) if p != 0 { return p } // The main database is second - p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpSchema + 8 /* &.tblHash */), zName) + p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema + 8 /* &.tblHash */), zName) if p != 0 { return p } @@ -91760,10 +90901,10 @@ func Xsqlite3FindTable(tls *libc.TLS, db uintptr, zName uintptr, zDatabase uintp } } if (p == uintptr(0)) && (Xsqlite3_strnicmp(tls, zName, ts+10128 /* "sqlite_" */, 7) == 0) { - if Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+13287 /* "sqlite_schema" */ +uintptr(7))) == 0 { - p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpSchema + 8 /* &.tblHash */), ts+7541 /* "sqlite_master" */) - } else if Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+13268 /* "sqlite_temp_sche..." */ +uintptr(7))) == 0 { - p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema + 8 /* &.tblHash */), + if Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+13287 /* "sqlite_schema" */ +7)) == 0 { + p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema + 8 /* &.tblHash */), ts+7541 /* "sqlite_master" */) + } else if Xsqlite3StrICmp(tls, (zName+uintptr(7)), (ts+13268 /* "sqlite_temp_sche..." */ +7)) == 0 { + p = Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema + 8 /* &.tblHash */), ts+13301 /* "sqlite_temp_mast..." */) } } @@ -91788,8 +90929,8 @@ func Xsqlite3LocateTable(tls *libc.TLS, pParse uintptr, flags U32, zName uintptr // Read the database schema. If an error occurs, leave an error message // and code in pParse and return NULL. - if (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0010)) == U32(0)) && - (0 != Xsqlite3ReadSchema(tls, pParse)) { + if (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_SchemaKnownOk) == U32(0)) && + (SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) { return uintptr(0) } @@ -91807,7 +90948,7 @@ func Xsqlite3LocateTable(tls *libc.TLS, pParse uintptr, flags U32, zName uintptr return (*Module)(unsafe.Pointer(pMod)).FpEpoTab } } - if (flags & U32(0x02)) != 0 { + if (flags & LOCATE_NOERR) != 0 { return uintptr(0) } (*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1) @@ -91817,7 +90958,7 @@ func Xsqlite3LocateTable(tls *libc.TLS, pParse uintptr, flags U32, zName uintptr if p == uintptr(0) { var zMsg uintptr - if (flags & U32(0x01)) != 0 { + if (flags & LOCATE_VIEW) != 0 { zMsg = ts + 13328 /* "no such view" */ } else { zMsg = ts + 13341 /* "no such table" */ @@ -91866,7 +91007,7 @@ func Xsqlite3FindIndex(tls *libc.TLS, db uintptr, zName uintptr, zDb uintptr) ui var i int32 // All mutexes are required for schema access. Make sure we hold them. - for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { + for i = OMIT_TEMPDB; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { var j int32 if i < 2 { j = (i ^ 1) @@ -91927,7 +91068,7 @@ func Xsqlite3UnlinkAndDeleteIndex(tls *libc.TLS, db uintptr, iDb int32, zIdxName } Xsqlite3FreeIndex(tls, db, pIndex) } - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) } // Look through the list of open database files in db->aDb[] and if @@ -91967,14 +91108,14 @@ func Xsqlite3ResetOneSchema(tls *libc.TLS, db uintptr, iDb int32) { /* sqlite3.c if iDb >= 0 { - *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(iDb)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((0x0008)) - *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(1)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((0x0008)) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (^libc.Uint32FromInt32(0x0010)) + *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(iDb)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((DB_ResetWanted)) + *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+1*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((DB_ResetWanted)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaKnownOk))) } if (*Sqlite3)(unsafe.Pointer(db)).FnSchemaLock == U32(0) { for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { - if (int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(i)*32)).FpSchema)).FschemaFlags) & (0x0008)) == (0x0008) { + if (int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(i)*32)).FpSchema)).FschemaFlags) & (DB_ResetWanted)) == (DB_ResetWanted) { Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).FpSchema) } } @@ -91992,11 +91133,11 @@ func Xsqlite3ResetAllSchemasOfConnection(tls *libc.TLS, db uintptr) { /* sqlite3 if (*Sqlite3)(unsafe.Pointer(db)).FnSchemaLock == U32(0) { Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer(pDb)).FpSchema) } else { - *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(i)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(i)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((DB_ResetWanted)) } } } - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (^libc.Uint32FromInt32((0x0001 | 0x0010))) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32((DBFLAG_SchemaChange | DBFLAG_SchemaKnownOk)))) Xsqlite3VtabUnlockList(tls, db) Xsqlite3BtreeLeaveAll(tls, db) if (*Sqlite3)(unsafe.Pointer(db)).FnSchemaLock == U32(0) { @@ -92006,7 +91147,7 @@ func Xsqlite3ResetAllSchemasOfConnection(tls *libc.TLS, db uintptr) { /* sqlite3 // This routine is called when a commit occurs. func Xsqlite3CommitInternalChanges(tls *libc.TLS, db uintptr) { /* sqlite3.c:111019:21: */ - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (^libc.Uint32FromInt32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(DBFLAG_SchemaChange))) } // Delete memory allocated for the column names of a table or view (the @@ -92107,7 +91248,7 @@ func Xsqlite3UnlinkAndDeleteTable(tls *libc.TLS, db uintptr, iDb int32, zTabName pDb = ((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32) p = Xsqlite3HashInsert(tls, ((*Db)(unsafe.Pointer(pDb)).FpSchema + 8 /* &.tblHash */), zTabName, uintptr(0)) Xsqlite3DeleteTable(tls, db, p) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) } // Given a token, return a string that consists of the text of that @@ -92136,8 +91277,8 @@ func Xsqlite3NameFromToken(tls *libc.TLS, db uintptr, pName uintptr) uintptr { / // writing. The table is opened using cursor 0. func Xsqlite3OpenSchemaTable(tls *libc.TLS, p uintptr, iDb int32) { /* sqlite3.c:111163:21: */ var v uintptr = Xsqlite3GetVdbe(tls, p) - Xsqlite3TableLock(tls, p, iDb, uint32(1), uint8(1), ts+7541 /* "sqlite_master" */) - Xsqlite3VdbeAddOp4Int(tls, v, 97, 0, 1, iDb, 5) + Xsqlite3TableLock(tls, p, iDb, SCHEMA_ROOT, uint8(1), ts+7541 /* "sqlite_master" */) + Xsqlite3VdbeAddOp4Int(tls, v, OP_OpenWrite, 0, SCHEMA_ROOT, iDb, 5) if (*Parse)(unsafe.Pointer(p)).FnTab == 0 { (*Parse)(unsafe.Pointer(p)).FnTab = 1 } @@ -92236,7 +91377,7 @@ func Xsqlite3TwoPartName(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 u // True if PRAGMA writable_schema is ON func Xsqlite3WritableSchema(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:111256:20: */ - return (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & (uint64(0x00000001 | 0x10000000))) == uint64(0x00000001))) + return (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & (uint64(SQLITE_WriteSchema | SQLITE_Defensive))) == SQLITE_WriteSchema)) } // This routine is used to check if the UTF-8 string zName is a legal @@ -92257,31 +91398,31 @@ func Xsqlite3CheckObjectName(tls *libc.TLS, pParse uintptr, zName uintptr, zType ((uint32(int32(*(*uint8)(unsafe.Pointer((db + 176 /* &.init */) + 8 /* &.imposterTable */)) & 0x2 >> 1))) != 0)) || !(int32(Xsqlite3Config.FbExtraSchemaChecks) != 0) { // Skip these error checks for writable_schema=ON - return 0 + return SQLITE_OK } if (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0 { - if ((Xsqlite3_stricmp(tls, zType, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit + uintptr(0)*8))) != 0) || - (Xsqlite3_stricmp(tls, zName, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit + uintptr(1)*8))) != 0)) || - (Xsqlite3_stricmp(tls, zTblName, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit + uintptr(2)*8))) != 0) { + if ((Xsqlite3_stricmp(tls, zType, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit))) != 0) || + (Xsqlite3_stricmp(tls, zName, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit + 1*8))) != 0)) || + (Xsqlite3_stricmp(tls, zTblName, *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit + 2*8))) != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+800 /* "" */, 0) // corruptSchema() will supply the error - return 1 + return SQLITE_ERROR } } else { if ((int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0) && (0 == Xsqlite3_strnicmp(tls, zName, ts+10128 /* "sqlite_" */, 7))) || ((Xsqlite3ReadOnlyShadowTables(tls, db) != 0) && (Xsqlite3ShadowTableName(tls, db, zName) != 0)) { Xsqlite3ErrorMsg(tls, pParse, ts+13392, /* "object name rese..." */ libc.VaList(bp, zName)) - return 1 + return SQLITE_ERROR } } - return 0 + return SQLITE_OK } // Return the PRIMARY KEY index of a table func Xsqlite3PrimaryKeyIndex(tls *libc.TLS, pTab uintptr) uintptr { /* sqlite3.c:111316:22: */ var p uintptr - for p = (*Table)(unsafe.Pointer(pTab)).FpIndex; (p != 0) && !((int32(*(*uint16)(unsafe.Pointer((p) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2); p = (*Index)(unsafe.Pointer(p)).FpNext { + for p = (*Table)(unsafe.Pointer(pTab)).FpIndex; (p != 0) && !((int32(*(*uint16)(unsafe.Pointer((p) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY); p = (*Index)(unsafe.Pointer(p)).FpNext { } return p } @@ -92311,10 +91452,10 @@ func Xsqlite3TableColumnToIndex(tls *libc.TLS, pIdx uintptr, iCol I16) I16 { /* // // If SQLITE_OMIT_GENERATED_COLUMNS, this routine is a no-op macro. func Xsqlite3StorageColumnToTable(tls *libc.TLS, pTab uintptr, iCol I16) I16 { /* sqlite3.c:111348:20: */ - if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0020)) != 0 { + if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasVirtual) != 0 { var i int32 for i = 0; i <= int32(iCol); i++ { - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) != 0 { + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0 { iCol++ } } @@ -92361,17 +91502,17 @@ func Xsqlite3TableColumnToStorage(tls *libc.TLS, pTab uintptr, iCol I16) I16 { / var i int32 var n I16 - if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0020)) == U32(0)) || (int32(iCol) < 0) { + if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasVirtual) == U32(0)) || (int32(iCol) < 0) { return iCol } i = 0 n = int16(0) for ; i < int32(iCol); i++ { - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) == 0 { + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) == 0 { n++ } } - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) != 0 { + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0 { // iCol is a virtual column itself return (I16((int32((*Table)(unsafe.Pointer(pTab)).FnNVCol) + i) - int32(n))) } else { @@ -92454,7 +91595,7 @@ __4: __5: ; zName = Xsqlite3NameFromToken(tls, db, *(*uintptr)(unsafe.Pointer(bp + 16 /* pName */))) - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __6 } Xsqlite3RenameTokenMap(tls, pParse, zName, *(*uintptr)(unsafe.Pointer(bp + 16 /* pName */))) @@ -92488,7 +91629,7 @@ __9: ; zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName - if !(Xsqlite3AuthCheck(tls, pParse, 18, func() uintptr { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_INSERT, func() uintptr { if (!(0 != 0)) && (isTemp == 1) { return ts + 13301 /* "sqlite_temp_mast..." */ } @@ -92513,11 +91654,11 @@ __11: // to an sqlite3_declare_vtab() call. In that case only the column names // and types will be used, so there is no need to test for namespace // collisions. - if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != 0)) { + if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL)) { goto __12 } zDb1 = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName - if !(0 != Xsqlite3ReadSchema(tls, pParse)) { + if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) { goto __13 } goto begin_table_error @@ -92555,7 +91696,7 @@ __12: goto __18 } - (*Parse)(unsafe.Pointer(pParse)).Frc = 7 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM (*Parse)(unsafe.Pointer(pParse)).FnErr++ goto begin_table_error __18: @@ -92594,7 +91735,7 @@ __19: if !(isVirtual != 0) { goto __21 } - Xsqlite3VdbeAddOp0(tls, v, 162) + Xsqlite3VdbeAddOp0(tls, v, OP_VBegin) __21: ; @@ -92603,16 +91744,16 @@ __21: reg1 = libc.AssignPtrInt32(pParse+120 /* &.regRowid */, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)) reg2 = libc.AssignPtrInt32(pParse+124 /* &.regRoot */, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)) reg3 = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp3(tls, v, 93, iDb, reg3, 2) + Xsqlite3VdbeAddOp3(tls, v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT) Xsqlite3VdbeUsesBtree(tls, v, iDb) - addr1 = Xsqlite3VdbeAddOp1(tls, v, 18, reg3) - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000002)) != uint64(0) { + addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_If, reg3) + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_LegacyFileFmt) != uint64(0) { fileFormat = 1 } else { - fileFormat = 4 + fileFormat = SQLITE_MAX_FILE_FORMAT } - Xsqlite3VdbeAddOp3(tls, v, 94, iDb, 2, fileFormat) - Xsqlite3VdbeAddOp3(tls, v, 94, iDb, 5, int32((*Sqlite3)(unsafe.Pointer(db)).Fenc)) + Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, fileFormat) + Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, int32((*Sqlite3)(unsafe.Pointer(db)).Fenc)) Xsqlite3VdbeJumpHere(tls, v, addr1) // This just creates a place-holder record in the sqlite_schema table. @@ -92626,19 +91767,19 @@ __21: if !((isView != 0) || (isVirtual != 0)) { goto __22 } - Xsqlite3VdbeAddOp2(tls, v, 69, 0, reg2) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, reg2) goto __23 __22: - (*Parse)(unsafe.Pointer(pParse)).FaddrCrTab = Xsqlite3VdbeAddOp3(tls, v, 139, iDb, reg2, 1) + (*Parse)(unsafe.Pointer(pParse)).FaddrCrTab = Xsqlite3VdbeAddOp3(tls, v, OP_CreateBtree, iDb, reg2, BTREE_INTKEY) __23: ; Xsqlite3OpenSchemaTable(tls, pParse, iDb) - Xsqlite3VdbeAddOp2(tls, v, 120, 0, reg1) - Xsqlite3VdbeAddOp4(tls, v, 74, 6, reg3, 0, uintptr(unsafe.Pointer(&nullRow)), -1) - Xsqlite3VdbeAddOp3(tls, v, 121, 0, reg3, reg1) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x08)) - Xsqlite3VdbeAddOp0(tls, v, 116) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, 0, reg1) + Xsqlite3VdbeAddOp4(tls, v, OP_Blob, 6, reg3, 0, uintptr(unsafe.Pointer(&nullRow)), -1) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, 0, reg3, reg1) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_APPEND) + Xsqlite3VdbeAddOp0(tls, v, OP_Close) __20: ; @@ -92652,10 +91793,10 @@ begin_table_error: } var aCode = [4]U8{ - U8(2), - U8(4), - U8(8), - U8(6), + SQLITE_CREATE_TABLE, + SQLITE_CREATE_TEMP_TABLE, + SQLITE_CREATE_VIEW, + SQLITE_CREATE_TEMP_VIEW, } /* sqlite3.c:111477:21 */ var nullRow = [6]int8{int8(6), int8(0), int8(0), int8(0), int8(0), int8(0)} /* sqlite3.c:111565:23 */ @@ -92681,7 +91822,7 @@ func Xsqlite3AddColumn(tls *libc.TLS, pParse uintptr, pName uintptr, pType uintp if (libc.AssignUintptr(&p, (*Parse)(unsafe.Pointer(pParse)).FpNewTable)) == uintptr(0) { return } - if (int32((*Table)(unsafe.Pointer(p)).FnCol) + 1) > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(2)*4)) { + if (int32((*Table)(unsafe.Pointer(p)).FnCol) + 1) > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 2*4)) { Xsqlite3ErrorMsg(tls, pParse, ts+13534 /* "too many columns..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(p)).FzName)) return } @@ -92689,7 +91830,7 @@ func Xsqlite3AddColumn(tls *libc.TLS, pParse uintptr, pName uintptr, pType uintp if z == uintptr(0) { return } - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameTokenMap(tls, pParse, z, pName) } libc.Xmemcpy(tls, z, (*Token)(unsafe.Pointer(pName)).Fz, uint64((*Token)(unsafe.Pointer(pName)).Fn)) @@ -92719,7 +91860,7 @@ func Xsqlite3AddColumn(tls *libc.TLS, pParse uintptr, pName uintptr, pType uintp if (*Token)(unsafe.Pointer(pType)).Fn == uint32(0) { // If there is no type specified, columns have the default affinity // 'BLOB' with a default size of 4 bytes. - (*Column)(unsafe.Pointer(pCol)).Faffinity = int8(0x41) + (*Column)(unsafe.Pointer(pCol)).Faffinity = SQLITE_AFF_BLOB (*Column)(unsafe.Pointer(pCol)).FszEst = U8(1) } else { zType = ((z + uintptr(Xsqlite3Strlen30(tls, z))) + uintptr(1)) @@ -92727,7 +91868,7 @@ func Xsqlite3AddColumn(tls *libc.TLS, pParse uintptr, pName uintptr, pType uintp *(*int8)(unsafe.Pointer(zType + uintptr((*Token)(unsafe.Pointer(pType)).Fn))) = int8(0) Xsqlite3Dequote(tls, zType) (*Column)(unsafe.Pointer(pCol)).Faffinity = Xsqlite3AffinityType(tls, zType, pCol) - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((COLFLAG_HASTYPE)) } (*Table)(unsafe.Pointer(p)).FnCol++ (*Table)(unsafe.Pointer(p)).FnNVCol++ @@ -92747,15 +91888,15 @@ func Xsqlite3AddNotNull(tls *libc.TLS, pParse uintptr, onError int32) { /* sqlit } pCol = ((*Table)(unsafe.Pointer(p)).FaCol + uintptr((int32((*Table)(unsafe.Pointer(p)).FnCol)-1))*32) (*Column)(unsafe.Pointer(pCol)).FnotNull = U8(onError) - *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (U32(0x0800)) + *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (TF_HasNotNull) // Set the uniqNotNull flag on any UNIQUE or PK indexes already created // on this column. - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0008) != 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_UNIQUE) != 0 { var pIdx uintptr for pIdx = (*Table)(unsafe.Pointer(p)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { - if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(0)*2))) == (int32((*Table)(unsafe.Pointer(p)).FnCol) - 1) { + if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn))) == (int32((*Table)(unsafe.Pointer(p)).FnCol) - 1) { libc.SetBitFieldPtr16Uint32(pIdx+100 /* &.uniqNotNull */, uint32(1), 3, 0x8) } } @@ -92790,36 +91931,36 @@ func Xsqlite3AffinityType(tls *libc.TLS, zIn uintptr, pCol uintptr) int8 { /* sq defer tls.Free(4) var h U32 = U32(0) - var aff int8 = int8(0x43) + var aff int8 = SQLITE_AFF_NUMERIC var zChar uintptr = uintptr(0) - for *(*int8)(unsafe.Pointer(zIn + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(zIn)) != 0 { h = ((h << 8) + U32(Xsqlite3UpperToLower[((int32(*(*int8)(unsafe.Pointer(zIn))))&0xff)])) zIn++ if h == (U32((((int32('c') << 24) + (int32('h') << 16)) + (int32('a') << 8)) + 'r')) { // CHAR - aff = int8(0x42) + aff = SQLITE_AFF_TEXT zChar = zIn } else if h == (U32((((int32('c') << 24) + (int32('l') << 16)) + (int32('o') << 8)) + 'b')) { // CLOB - aff = int8(0x42) + aff = SQLITE_AFF_TEXT } else if h == (U32((((int32('t') << 24) + (int32('e') << 16)) + (int32('x') << 8)) + 't')) { // TEXT - aff = int8(0x42) + aff = SQLITE_AFF_TEXT } else if (h == (U32((((int32('b') << 24) + (int32('l') << 16)) + (int32('o') << 8)) + 'b'))) && // BLOB - ((int32(aff) == 0x43) || (int32(aff) == 0x45)) { - aff = int8(0x41) - if int32(*(*int8)(unsafe.Pointer(zIn + uintptr(0)))) == '(' { + ((int32(aff) == SQLITE_AFF_NUMERIC) || (int32(aff) == SQLITE_AFF_REAL)) { + aff = SQLITE_AFF_BLOB + if int32(*(*int8)(unsafe.Pointer(zIn))) == '(' { zChar = zIn } } else if (h == (U32((((int32('r') << 24) + (int32('e') << 16)) + (int32('a') << 8)) + 'l'))) && // REAL - (int32(aff) == 0x43) { - aff = int8(0x45) + (int32(aff) == SQLITE_AFF_NUMERIC) { + aff = SQLITE_AFF_REAL } else if (h == (U32((((int32('f') << 24) + (int32('l') << 16)) + (int32('o') << 8)) + 'a'))) && // FLOA - (int32(aff) == 0x43) { - aff = int8(0x45) + (int32(aff) == SQLITE_AFF_NUMERIC) { + aff = SQLITE_AFF_REAL } else if (h == (U32((((int32('d') << 24) + (int32('o') << 16)) + (int32('u') << 8)) + 'b'))) && // DOUB - (int32(aff) == 0x43) { - aff = int8(0x45) + (int32(aff) == SQLITE_AFF_NUMERIC) { + aff = SQLITE_AFF_REAL } else if (h & U32(0x00FFFFFF)) == (U32(((int32('i') << 16) + (int32('n') << 8)) + 't')) { // INT - aff = int8(0x44) + aff = SQLITE_AFF_INTEGER break } } @@ -92828,10 +91969,10 @@ func Xsqlite3AffinityType(tls *libc.TLS, zIn uintptr, pCol uintptr) int8 { /* sq // estimate is scaled so that the size of an integer is 1. if pCol != 0 { *(*int32)(unsafe.Pointer(bp /* v */)) = 0 // default size is approx 4 bytes - if int32(aff) < 0x43 { + if int32(aff) < SQLITE_AFF_NUMERIC { if zChar != 0 { - for *(*int8)(unsafe.Pointer(zChar + uintptr(0))) != 0 { - if (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zChar + uintptr(0))))]) & 0x04) != 0 { + for *(*int8)(unsafe.Pointer(zChar)) != 0 { + if (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zChar)))]) & 0x04) != 0 { // BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) Xsqlite3GetInt32(tls, zChar, bp /* &v */) break @@ -92873,7 +92014,7 @@ func Xsqlite3AddDefaultValue(tls *libc.TLS, pParse uintptr, pExpr uintptr, zStar if !(Xsqlite3ExprIsConstantOrFunction(tls, pExpr, uint8(isInit)) != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+13583, /* "default value of..." */ libc.VaList(bp, (*Column)(unsafe.Pointer(pCol)).FzName)) - } else if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0060) != 0 { + } else if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_GENERATED) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+13628 /* "cannot use DEFAU..." */, 0) } else { @@ -92883,15 +92024,15 @@ func Xsqlite3AddDefaultValue(tls *libc.TLS, pParse uintptr, pExpr uintptr, zStar Xsqlite3ExprDelete(tls, db, (*Column)(unsafe.Pointer(pCol)).FpDflt) libc.Xmemset(tls, bp+8 /* &x */, 0, uint64(unsafe.Sizeof(Expr{}))) - (*Expr)(unsafe.Pointer(bp + 8 /* &x */)).Fop = U8(178) + (*Expr)(unsafe.Pointer(bp + 8 /* &x */)).Fop = TK_SPAN *(*uintptr)(unsafe.Pointer(bp + 8 /* &x */ + 8 /* &.u */)) = Xsqlite3DbSpanDup(tls, db, zStart, zEnd) (*Expr)(unsafe.Pointer(bp + 8 /* &x */)).FpLeft = pExpr - (*Expr)(unsafe.Pointer(bp + 8 /* &x */)).Fflags = U32(0x001000) - (*Column)(unsafe.Pointer(pCol)).FpDflt = Xsqlite3ExprDup(tls, db, bp+8 /* &x */, 0x0001) + (*Expr)(unsafe.Pointer(bp + 8 /* &x */)).Fflags = EP_Skip + (*Column)(unsafe.Pointer(pCol)).FpDflt = Xsqlite3ExprDup(tls, db, bp+8 /* &x */, EXPRDUP_REDUCE) Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 8 /* &x */ + 8 /* &.u */))) } } - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameExprUnmap(tls, pParse, pExpr) } Xsqlite3ExprDelete(tls, db, pExpr) @@ -92912,17 +92053,17 @@ func Xsqlite3AddDefaultValue(tls *libc.TLS, pParse uintptr, pExpr uintptr, zStar // If the expression is anything other than TK_STRING, the expression is // unchanged. func sqlite3StringToId(tls *libc.TLS, p uintptr) { /* sqlite3.c:111898:13: */ - if int32((*Expr)(unsafe.Pointer(p)).Fop) == 115 { - (*Expr)(unsafe.Pointer(p)).Fop = U8(59) - } else if (int32((*Expr)(unsafe.Pointer(p)).Fop) == 111) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fop) == 115) { - (*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fop = U8(59) + if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_STRING { + (*Expr)(unsafe.Pointer(p)).Fop = TK_ID + } else if (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLLATE) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fop) == TK_STRING) { + (*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(p)).FpLeft)).Fop = TK_ID } } // Tag the given column as being part of the PRIMARY KEY func makeColumnPartOfPrimaryKey(tls *libc.TLS, pParse uintptr, pCol uintptr) { /* sqlite3.c:111909:13: */ - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((0x0001)) - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0060) != 0 { + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((COLFLAG_PRIMKEY)) + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_GENERATED) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+13669 /* "generated column..." */, 0) @@ -92966,7 +92107,7 @@ func Xsqlite3AddPrimaryKey(tls *libc.TLS, pParse uintptr, pList uintptr, onError goto primary_key_exit __1: ; - if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0004)) != 0) { + if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasPrimaryKey) != 0) { goto __2 } Xsqlite3ErrorMsg(tls, pParse, @@ -92974,7 +92115,7 @@ __1: goto primary_key_exit __2: ; - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0004)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (TF_HasPrimaryKey) if !(pList == uintptr(0)) { goto __3 } @@ -92993,7 +92134,7 @@ __5: pCExpr = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FpExpr) sqlite3StringToId(tls, pCExpr) - if !(int32((*Expr)(unsafe.Pointer(pCExpr)).Fop) == 59) { + if !(int32((*Expr)(unsafe.Pointer(pCExpr)).Fop) == TK_ID) { goto __8 } zCName = *(*uintptr)(unsafe.Pointer(pCExpr + 8 /* &.u */)) @@ -93031,24 +92172,24 @@ __4: if !((((nTerm == 1) && (pCol != 0)) && (Xsqlite3StrICmp(tls, Xsqlite3ColumnType(tls, pCol, ts+800 /* "" */), ts+13762 /* "INTEGER" */) == 0)) && - (sortOrder != 1)) { + (sortOrder != SQLITE_SO_DESC)) { goto __13 } - if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && (pList != 0)) { + if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && (pList != 0)) { goto __15 } - pCExpr1 = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(0)*32)).FpExpr) + pCExpr1 = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FpExpr) Xsqlite3RenameTokenRemap(tls, pParse, (pTab + 68 /* &.iPKey */), pCExpr1) __15: ; (*Table)(unsafe.Pointer(pTab)).FiPKey = I16(iCol) (*Table)(unsafe.Pointer(pTab)).FkeyConf = U8(onError) - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(autoInc * 0x0008)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(autoInc * TF_Autoincrement)) if !(pList != 0) { goto __16 } - (*Parse)(unsafe.Pointer(pParse)).FiPkSortOrder = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(0)*32)).FsortFlags + (*Parse)(unsafe.Pointer(pParse)).FiPkSortOrder = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FsortFlags __16: ; Xsqlite3HasExplicitNulls(tls, pParse, pList) @@ -93062,7 +92203,7 @@ __13: goto __18 __17: Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), pList, onError, uintptr(0), - uintptr(0), sortOrder, 0, uint8(2)) + uintptr(0), sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY) pList = uintptr(0) __18: ; @@ -93078,7 +92219,7 @@ primary_key_exit: func Xsqlite3AddCheckConstraint(tls *libc.TLS, pParse uintptr, pCheckExpr uintptr) { /* sqlite3.c:112014:21: */ var pTab uintptr = (*Parse)(unsafe.Pointer(pParse)).FpNewTable var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if ((pTab != 0) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == 1)) && + if ((pTab != 0) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == PARSE_MODE_DECLARE_VTAB)) && !(Xsqlite3BtreeIsReadonly(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr((*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb)*32)).FpBt) != 0) { (*Table)(unsafe.Pointer(pTab)).FpCheck = Xsqlite3ExprListAppend(tls, pParse, (*Table)(unsafe.Pointer(pTab)).FpCheck, pCheckExpr) if (*Parse)(unsafe.Pointer(pParse)).FconstraintName.Fn != 0 { @@ -93117,8 +92258,8 @@ func Xsqlite3AddCollateType(tls *libc.TLS, pParse uintptr, pToken uintptr) { /* // collation type was added. Correct this if it is the case. for pIdx = (*Table)(unsafe.Pointer(p)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { - if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(0)*2))) == i { - *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(0)*8)) = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(i)*32)).FzColl + if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn))) == i { + *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl)) = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(i)*32)).FzColl } } } else { @@ -93135,7 +92276,7 @@ func Xsqlite3AddGenerated(tls *libc.TLS, pParse uintptr, pExpr uintptr, pType ui var eType U8 var pTab uintptr var pCol uintptr - eType = U8(0x0020) + eType = COLFLAG_VIRTUAL pTab = (*Parse)(unsafe.Pointer(pParse)).FpNewTable if !(pTab == uintptr(0)) { goto __1 @@ -93145,7 +92286,7 @@ func Xsqlite3AddGenerated(tls *libc.TLS, pParse uintptr, pExpr uintptr, pType ui __1: ; pCol = ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr((int32((*Table)(unsafe.Pointer(pTab)).FnCol)-1))*32) - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == 1) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == PARSE_MODE_DECLARE_VTAB) { goto __2 } Xsqlite3ErrorMsg(tls, pParse, ts+13826 /* "virtual tables c..." */, 0) @@ -93170,7 +92311,7 @@ __5: if !(((*Token)(unsafe.Pointer(pType)).Fn == uint32(6)) && (Xsqlite3_strnicmp(tls, ts+13877 /* "stored" */, (*Token)(unsafe.Pointer(pType)).Fz, 6) == 0)) { goto __7 } - eType = U8(0x0040) + eType = COLFLAG_STORED goto __8 __7: goto generated_error @@ -93180,7 +92321,7 @@ __6: ; __4: ; - if !(int32(eType) == 0x0020) { + if !(int32(eType) == COLFLAG_VIRTUAL) { goto __9 } (*Table)(unsafe.Pointer(pTab)).FnNVCol-- @@ -93189,7 +92330,7 @@ __9: *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((int32(eType))) *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(eType)) - if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0001) != 0) { + if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_PRIMKEY) != 0) { goto __10 } makeColumnPartOfPrimaryKey(tls, pParse, pCol) // For the error message @@ -93227,7 +92368,7 @@ func Xsqlite3ChangeCookie(tls *libc.TLS, pParse uintptr, iDb int32) { /* sqlite3 var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe - Xsqlite3VdbeAddOp3(tls, v, 94, iDb, 1, + Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, (int32(uint32(1) + uint32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FpSchema)).Fschema_cookie)))) } @@ -93284,8 +92425,8 @@ func identPut(tls *libc.TLS, z uintptr, pIdx uintptr, zSignedIdent uintptr) { /* break } } - needQuote = (libc.Bool32(((((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zIdent + uintptr(0)))]) & 0x04) != 0) || - (Xsqlite3KeywordCode(tls, zIdent, j) != 59)) || + needQuote = (libc.Bool32(((((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(zIdent))]) & 0x04) != 0) || + (Xsqlite3KeywordCode(tls, zIdent, j) != TK_ID)) || (int32(*(*uint8)(unsafe.Pointer(zIdent + uintptr(j)))) != 0)) || (j == 0))) @@ -93375,7 +92516,7 @@ __4: zSep = zSep2 identPut(tls, zStmt, bp+8 /* &k */, (*Column)(unsafe.Pointer(pCol)).FzName) - zType = azType1[(int32((*Column)(unsafe.Pointer(pCol)).Faffinity) - 0x41)] + zType = azType1[(int32((*Column)(unsafe.Pointer(pCol)).Faffinity) - SQLITE_AFF_BLOB)] len = Xsqlite3Strlen30(tls, zType) libc.Xmemcpy(tls, (zStmt + uintptr(*(*int32)(unsafe.Pointer(bp + 8 /* k */)))), zType, uint64(len)) @@ -93408,13 +92549,13 @@ func resizeIndexObject(tls *libc.TLS, db uintptr, pIdx uintptr, N int32) int32 { var zExtra uintptr var nByte int32 if int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) >= N { - return 0 + return SQLITE_OK } nByte = (int32(((uint64(unsafe.Sizeof(uintptr(0))) + uint64(unsafe.Sizeof(I16(0)))) + uint64(1)) * uint64(N))) zExtra = Xsqlite3DbMallocZero(tls, db, uint64(nByte)) if zExtra == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, zExtra, (*Index)(unsafe.Pointer(pIdx)).FazColl, (uint64(unsafe.Sizeof(uintptr(0))) * uint64((*Index)(unsafe.Pointer(pIdx)).FnColumn))) (*Index)(unsafe.Pointer(pIdx)).FazColl = zExtra @@ -93426,7 +92567,7 @@ func resizeIndexObject(tls *libc.TLS, db uintptr, pIdx uintptr, N int32) int32 { (*Index)(unsafe.Pointer(pIdx)).FaSortOrder = zExtra (*Index)(unsafe.Pointer(pIdx)).FnColumn = U16(N) libc.SetBitFieldPtr16Uint32(pIdx+100 /* &.isResized */, uint32(1), 4, 0x10) - return 0 + return SQLITE_OK } // Estimate the total row width for a table. @@ -93539,7 +92680,7 @@ func recomputeColumnsNotIndexed(tls *libc.TLS, pIdx uintptr) { /* sqlite3.c:1123 var pTab uintptr = (*Index)(unsafe.Pointer(pIdx)).FpTable for j = (int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) - 1); j >= 0; j-- { var x int32 = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(j)*2))) - if (x >= 0) && ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(x)*32)).FcolFlags) & 0x0020) == 0) { + if (x >= 0) && ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(x)*32)).FcolFlags) & COLFLAG_VIRTUAL) == 0) { if x < ((int32(uint64(unsafe.Sizeof(Bitmask(0))) * uint64(8))) - 1) { m = m | (Bitmask((uint64(1))) << (x)) @@ -93588,18 +92729,18 @@ func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { / // Mark every PRIMARY KEY column as NOT NULL (except for imposter tables) if !((int32(*(*uint8)(unsafe.Pointer(db + 176 /* &.init */ + 8 /* &.imposterTable */)) & 0x2 >> 1)) != 0) { for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0001) != 0 { - (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32)).FnotNull = U8(2) + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_PRIMKEY) != 0 { + (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32)).FnotNull = OE_Abort } } - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0800)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (TF_HasNotNull) } // Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY // into BTREE_BLOBKEY. if (*Parse)(unsafe.Pointer(pParse)).FaddrCrTab != 0 { - Xsqlite3VdbeChangeP3(tls, v, (*Parse)(unsafe.Pointer(pParse)).FaddrCrTab, 2) + Xsqlite3VdbeChangeP3(tls, v, (*Parse)(unsafe.Pointer(pParse)).FaddrCrTab, BTREE_BLOBKEY) } // Locate the PRIMARY KEY index. Or, if this table was originally @@ -93610,18 +92751,18 @@ func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { / Xsqlite3TokenInit(tls, bp /* &ipkToken */, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*Table)(unsafe.Pointer(pTab)).FiPKey)*32)).FzName) pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), - Xsqlite3ExprAlloc(tls, db, 59, bp /* &ipkToken */, 0)) + Xsqlite3ExprAlloc(tls, db, TK_ID, bp /* &ipkToken */, 0)) if pList == uintptr(0) { return } - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { - Xsqlite3RenameTokenRemap(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(0)*32)).FpExpr, (pTab + 68 /* &.iPKey */)) + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { + Xsqlite3RenameTokenRemap(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FpExpr, (pTab + 68 /* &.iPKey */)) } - (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(0)*32)).FsortFlags = (*Parse)(unsafe.Pointer(pParse)).FiPkSortOrder + (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FsortFlags = (*Parse)(unsafe.Pointer(pParse)).FiPkSortOrder (*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1) Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), pList, int32((*Table)(unsafe.Pointer(pTab)).FkeyConf), uintptr(0), uintptr(0), 0, 0, - uint8(2)) + SQLITE_IDXTYPE_PRIMARYKEY) if ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) || ((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) { return } @@ -93658,7 +92799,7 @@ func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { / // a database schema). if (v != 0) && ((*Index)(unsafe.Pointer(pPk)).Ftnum > Pgno(0)) { - Xsqlite3VdbeChangeOpcode(tls, v, int32((*Index)(unsafe.Pointer(pPk)).Ftnum), uint8(11)) + Xsqlite3VdbeChangeOpcode(tls, v, int32((*Index)(unsafe.Pointer(pPk)).Ftnum), OP_Goto) } // The root page of the PRIMARY KEY is the table root page @@ -93668,7 +92809,7 @@ func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { / // the final rowid column into one or more columns of the PRIMARY KEY. for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { var n int32 - if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2 { + if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY { continue } for i = libc.AssignInt32(&n, 0); i < nPk; i++ { @@ -93706,7 +92847,7 @@ func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { / nExtra = 0 for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { if !(hasColumn(tls, (*Index)(unsafe.Pointer(pPk)).FaiColumn, nPk, i) != 0) && - ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) == 0) { + ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) == 0) { nExtra++ } } @@ -93717,7 +92858,7 @@ func convertToWithoutRowidTable(tls *libc.TLS, pParse uintptr, pTab uintptr) { / j = nPk for ; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { if !(hasColumn(tls, (*Index)(unsafe.Pointer(pPk)).FaiColumn, j, i) != 0) && - ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) == 0) { + ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) == 0) { *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)) = I16(i) *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FazColl + uintptr(j)*8)) = uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)) @@ -93744,7 +92885,7 @@ func Xsqlite3IsShadowTableOf(tls *libc.TLS, db uintptr, pTab uintptr, zName uint if int32(*(*int8)(unsafe.Pointer(zName + uintptr(nName)))) != '_' { return 0 } - pMod = Xsqlite3HashFind(tls, (db + 528 /* &.aModule */), *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg + uintptr(0)*8))) + pMod = Xsqlite3HashFind(tls, (db + 528 /* &.aModule */), *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg))) if pMod == uintptr(0) { return 0 } @@ -93818,7 +92959,7 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr } if (pSelect == uintptr(0)) && (Xsqlite3ShadowTableName(tls, db, (*Table)(unsafe.Pointer(p)).FzName) != 0) { - *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (U32(0x1000)) + *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (TF_Shadow) } // If the db->init.busy is 1 it means we are reading the SQL off the @@ -93836,29 +92977,29 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr } (*Table)(unsafe.Pointer(p)).Ftnum = (*Sqlite3)(unsafe.Pointer(db)).Finit.FnewTnum if (*Table)(unsafe.Pointer(p)).Ftnum == Pgno(1) { - *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (TF_Readonly) } } // Special processing for WITHOUT ROWID Tables - if (int32(tabOpts) & 0x0080) != 0 { - if ((*Table)(unsafe.Pointer(p)).FtabFlags & U32(0x0008)) != 0 { + if (int32(tabOpts) & TF_WithoutRowid) != 0 { + if ((*Table)(unsafe.Pointer(p)).FtabFlags & TF_Autoincrement) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+13965 /* "AUTOINCREMENT no..." */, 0) return } - if ((*Table)(unsafe.Pointer(p)).FtabFlags & U32(0x0004)) == U32(0) { + if ((*Table)(unsafe.Pointer(p)).FtabFlags & TF_HasPrimaryKey) == U32(0) { Xsqlite3ErrorMsg(tls, pParse, ts+14015 /* "PRIMARY KEY miss..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(p)).FzName)) return } - *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (U32(0x0080 | 0x0200)) + *(*U32)(unsafe.Pointer(p + 64 /* &.tabFlags */)) |= (U32(TF_WithoutRowid | TF_NoVisibleRowid)) convertToWithoutRowidTable(tls, pParse, p) } iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(p)).FpSchema) // Resolve names in all CHECK constraint expressions. if (*Table)(unsafe.Pointer(p)).FpCheck != 0 { - Xsqlite3ResolveSelfReference(tls, pParse, p, 0x00004, uintptr(0), (*Table)(unsafe.Pointer(p)).FpCheck) + Xsqlite3ResolveSelfReference(tls, pParse, p, NC_IsCheck, uintptr(0), (*Table)(unsafe.Pointer(p)).FpCheck) if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { // If errors are seen, delete the CHECK constraints now, else they might // actually be used if PRAGMA writable_schema=ON is set. @@ -93868,16 +93009,16 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr } } - if ((*Table)(unsafe.Pointer(p)).FtabFlags & U32(0x0060)) != 0 { + if ((*Table)(unsafe.Pointer(p)).FtabFlags & TF_HasGenerated) != 0 { var ii int32 var nNG int32 = 0 for ii = 0; ii < int32((*Table)(unsafe.Pointer(p)).FnCol); ii++ { var colFlags U32 = U32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(ii)*32)).FcolFlags) - if (colFlags & U32(0x0060)) != U32(0) { + if (colFlags & COLFLAG_GENERATED) != U32(0) { var pX uintptr = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(ii)*32)).FpDflt - if Xsqlite3ResolveSelfReference(tls, pParse, p, 0x00008, pX, uintptr(0)) != 0 { + if Xsqlite3ResolveSelfReference(tls, pParse, p, NC_GenCol, pX, uintptr(0)) != 0 { // If there are errors in resolving the expression, change the // expression to a NULL. This prevents code generators that operate // on the expression from inserting extra parts into the expression @@ -93885,7 +93026,7 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr // illegal in a schema and will lead to errors or heap corruption // when the database connection closes. Xsqlite3ExprDelete(tls, db, pX) - (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(ii)*32)).FpDflt = Xsqlite3ExprAlloc(tls, db, 119, uintptr(0), 0) + (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(p)).FaCol + uintptr(ii)*32)).FpDflt = Xsqlite3ExprAlloc(tls, db, TK_NULL, uintptr(0), 0) } } else { nNG++ @@ -93920,7 +93061,7 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr return } - Xsqlite3VdbeAddOp1(tls, v, 116, 0) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, 0) // Initialize zType for the new view or table. if (*Table)(unsafe.Pointer(p)).FpSelect == uintptr(0) { @@ -93960,15 +93101,15 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr regRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) Xsqlite3MayAbort(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 97, 1, (*Parse)(unsafe.Pointer(pParse)).FregRoot, iDb) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenWrite, 1, (*Parse)(unsafe.Pointer(pParse)).FregRoot, iDb) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_P2ISREG) (*Parse)(unsafe.Pointer(pParse)).FnTab = 2 addrTop = (Xsqlite3VdbeCurrentAddr(tls, v) + 1) - Xsqlite3VdbeAddOp3(tls, v, 13, regYield, 0, addrTop) + Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regYield, 0, addrTop) if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { return } - pSelTab = Xsqlite3ResultSetOfSelect(tls, pParse, pSelect, int8(0x41)) + pSelTab = Xsqlite3ResultSetOfSelect(tls, pParse, pSelect, SQLITE_AFF_BLOB) if pSelTab == uintptr(0) { return } @@ -93978,22 +93119,22 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr (*Table)(unsafe.Pointer(pSelTab)).FnCol = int16(0) (*Table)(unsafe.Pointer(pSelTab)).FaCol = uintptr(0) Xsqlite3DeleteTable(tls, db, pSelTab) - Xsqlite3SelectDestInit(tls, bp+104 /* &dest */, 13, regYield) + Xsqlite3SelectDestInit(tls, bp+104 /* &dest */, SRT_Coroutine, regYield) Xsqlite3Select(tls, pParse, pSelect, bp+104 /* &dest */) if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { return } Xsqlite3VdbeEndCoroutine(tls, v, regYield) Xsqlite3VdbeJumpHere(tls, v, (addrTop - 1)) - addrInsLoop = Xsqlite3VdbeAddOp1(tls, v, 14, (*SelectDest)(unsafe.Pointer(bp+104 /* &dest */)).FiSDParm) + addrInsLoop = Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(bp+104 /* &dest */)).FiSDParm) - Xsqlite3VdbeAddOp3(tls, v, 91, (*SelectDest)(unsafe.Pointer(bp+104 /* &dest */)).FiSdst, (*SelectDest)(unsafe.Pointer(bp+104 /* &dest */)).FnSdst, regRec) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (*SelectDest)(unsafe.Pointer(bp+104 /* &dest */)).FiSdst, (*SelectDest)(unsafe.Pointer(bp+104 /* &dest */)).FnSdst, regRec) Xsqlite3TableAffinity(tls, v, p, 0) - Xsqlite3VdbeAddOp2(tls, v, 120, 1, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, 1, regRec, regRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, 1, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, 1, regRec, regRowid) Xsqlite3VdbeGoto(tls, v, addrInsLoop) Xsqlite3VdbeJumpHere(tls, v, addrInsLoop) - Xsqlite3VdbeAddOp1(tls, v, 116, 1) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, 1) } // Compute the complete text of the CREATE statement @@ -94007,7 +93148,7 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr pEnd2 = pEnd } n = (int32((int64((*Token)(unsafe.Pointer(pEnd2)).Fz) - int64((*Parse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) / 1)) - if int32(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(pEnd2)).Fz + uintptr(0)))) != ';' { + if int32(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(pEnd2)).Fz))) != ';' { n = int32(uint32(n) + ((*Token)(unsafe.Pointer(pEnd2)).Fn)) } zStmt = Xsqlite3MPrintf(tls, db, @@ -94032,7 +93173,7 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr // Check to see if we need to create an sqlite_sequence table for // keeping track of autoincrement keys. - if ((*Table)(unsafe.Pointer(p)).FtabFlags & U32(0x0008)) != U32(0) { + if ((*Table)(unsafe.Pointer(p)).FtabFlags & TF_Autoincrement) != U32(0) { var pDb uintptr = ((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32) if (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab == uintptr(0) { @@ -94059,7 +93200,7 @@ func Xsqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr return } (*Parse)(unsafe.Pointer(pParse)).FpNewTable = uintptr(0) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) if !(int32((*Table)(unsafe.Pointer(p)).FpSelect) != 0) { var zName uintptr = (*Parse)(unsafe.Pointer(pParse)).FsNameToken.Fz @@ -94122,18 +93263,18 @@ __3: // This will force all the Expr.token.z values to be dynamically // allocated rather than point to the input string - which means that // they will persist after the current sqlite3_exec() call returns. - *(*U32)(unsafe.Pointer(pSelect + 4 /* &.selFlags */)) |= (U32(0x0200000)) - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + *(*U32)(unsafe.Pointer(pSelect + 4 /* &.selFlags */)) |= (SF_View) + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __4 } (*Table)(unsafe.Pointer(p)).FpSelect = pSelect pSelect = uintptr(0) goto __5 __4: - (*Table)(unsafe.Pointer(p)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, 0x0001) + (*Table)(unsafe.Pointer(p)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, EXPRDUP_REDUCE) __5: ; - (*Table)(unsafe.Pointer(p)).FpCheck = Xsqlite3ExprListDup(tls, db, pCNames, 0x0001) + (*Table)(unsafe.Pointer(p)).FpCheck = Xsqlite3ExprListDup(tls, db, pCNames, EXPRDUP_REDUCE) if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __6 } @@ -94145,7 +93286,7 @@ __6: // the end. *(*Token)(unsafe.Pointer(bp + 56 /* sEnd */)) = (*Parse)(unsafe.Pointer(pParse)).FsLastToken - if !(int32(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(bp+56 /* &sEnd */)).Fz + uintptr(0)))) != ';') { + if !(int32(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(bp + 56 /* &sEnd */)).Fz))) != ';') { goto __7 } *(*uintptr)(unsafe.Pointer(bp + 56 /* &sEnd */ /* &.z */)) += (uintptr((*Token)(unsafe.Pointer(bp + 56 /* &sEnd */)).Fn)) @@ -94171,7 +93312,7 @@ __9: create_view_fail: Xsqlite3SelectDelete(tls, db, pSelect) - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __10 } Xsqlite3RenameExprlistUnmap(tls, pParse, pCNames) @@ -94241,7 +93382,7 @@ func Xsqlite3ViewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) i pSel = Xsqlite3SelectDup(tls, db, (*Table)(unsafe.Pointer(pTable)).FpSelect, 0) if pSel != 0 { var eParseMode U8 = (*Parse)(unsafe.Pointer(pParse)).FeParseMode - (*Parse)(unsafe.Pointer(pParse)).FeParseMode = U8(0) + (*Parse)(unsafe.Pointer(pParse)).FeParseMode = PARSE_MODE_NORMAL n = (*Parse)(unsafe.Pointer(pParse)).FnTab Xsqlite3SrcListAssignCursors(tls, pParse, (*Select)(unsafe.Pointer(pSel)).FpSrc) (*Table)(unsafe.Pointer(pTable)).FnCol = int16(-1) @@ -94249,7 +93390,7 @@ func Xsqlite3ViewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) i (*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0) xAuth = (*Sqlite3)(unsafe.Pointer(db)).FxAuth (*Sqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) - pSelTab = Xsqlite3ResultSetOfSelect(tls, pParse, pSel, int8(0x40)) + pSelTab = Xsqlite3ResultSetOfSelect(tls, pParse, pSel, SQLITE_AFF_NONE) (*Sqlite3)(unsafe.Pointer(db)).FxAuth = xAuth (*Parse)(unsafe.Pointer(pParse)).FnTab = n if pSelTab == uintptr(0) { @@ -94267,7 +93408,7 @@ func Xsqlite3ViewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) i ((*Parse)(unsafe.Pointer(pParse)).FnErr == 0)) && (int32((*Table)(unsafe.Pointer(pTable)).FnCol) == (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSel)).FpEList)).FnExpr) { Xsqlite3SelectAddColumnTypeAndCollation(tls, pParse, pTable, pSel, - int8(0x40)) + SQLITE_AFF_NONE) } } else { // CREATE VIEW name AS... without an argument list. Construct @@ -94293,7 +93434,7 @@ func Xsqlite3ViewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) i } else { nErr++ } - *(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTable)).FpSchema + 114 /* &.schemaFlags */)) |= U16((0x0002)) + *(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTable)).FpSchema + 114 /* &.schemaFlags */)) |= U16((DB_UnresetViews)) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { Xsqlite3DeleteColumnNames(tls, db, pTable) (*Table)(unsafe.Pointer(pTable)).FaCol = uintptr(0) @@ -94306,7 +93447,7 @@ func Xsqlite3ViewGetColumnNames(tls *libc.TLS, pParse uintptr, pTable uintptr) i func sqliteViewResetAll(tls *libc.TLS, db uintptr, idx int32) { /* sqlite3.c:113168:13: */ var i uintptr - if !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(idx)*32)).FpSchema)).FschemaFlags) & (0x0002)) == (0x0002)) { + if !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(idx)*32)).FpSchema)).FschemaFlags) & (DB_UnresetViews)) == (DB_UnresetViews)) { return } for i = (*Hash)(unsafe.Pointer(((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(idx)*32)).FpSchema + 8 /* &.tblHash */))).Ffirst; i != 0; i = (*HashElem)(unsafe.Pointer(i)).Fnext { @@ -94317,7 +93458,7 @@ func sqliteViewResetAll(tls *libc.TLS, db uintptr, idx int32) { /* sqlite3.c:113 (*Table)(unsafe.Pointer(pTab)).FnCol = int16(0) } } - *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(idx)*32)).FpSchema + 114 /* &.schemaFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0002))) + *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(idx)*32)).FpSchema + 114 /* &.schemaFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(DB_UnresetViews))) } // This function is called by the VDBE to adjust the internal schema @@ -94370,7 +93511,7 @@ func destroyRootPage(tls *libc.TLS, pParse uintptr, iTable int32, iDb int32) { / if iTable < 2 { Xsqlite3ErrorMsg(tls, pParse, ts+14357 /* "corrupt schema" */, 0) } - Xsqlite3VdbeAddOp3(tls, v, 136, iTable, r1, iDb) + Xsqlite3VdbeAddOp3(tls, v, OP_Destroy, iTable, r1, iDb) Xsqlite3MayAbort(tls, pParse) // OP_Destroy stores an in integer r1. If this integer // is non-zero, then it is the root page number of a table moved to @@ -94470,7 +93611,7 @@ func Xsqlite3CodeDropTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iDb int3 Xsqlite3BeginWriteOperation(tls, pParse, 1, iDb) if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { - Xsqlite3VdbeAddOp0(tls, v, 162) + Xsqlite3VdbeAddOp0(tls, v, OP_VBegin) } // Drop all triggers associated with the table being dropped. Code @@ -94487,7 +93628,7 @@ func Xsqlite3CodeDropTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iDb int3 // the table being dropped. This is done before the table is dropped // at the btree level, in case the sqlite_sequence table needs to // move as a result of the drop (can happen in auto-vacuum mode). - if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0008)) != 0 { + if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Autoincrement) != 0 { Xsqlite3NestedParse(tls, pParse, ts+14453, /* "DELETE FROM %Q.s..." */ libc.VaList(bp, (*Db)(unsafe.Pointer(pDb)).FzDbSName, (*Table)(unsafe.Pointer(pTab)).FzName)) @@ -94510,10 +93651,10 @@ func Xsqlite3CodeDropTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iDb int3 // Remove the table entry from SQLite's internal schema and modify // the schema cookie. if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { - Xsqlite3VdbeAddOp4(tls, v, 164, iDb, 0, 0, (*Table)(unsafe.Pointer(pTab)).FzName, 0) + Xsqlite3VdbeAddOp4(tls, v, OP_VDestroy, iDb, 0, 0, (*Table)(unsafe.Pointer(pTab)).FzName, 0) Xsqlite3MayAbort(tls, pParse) } - Xsqlite3VdbeAddOp4(tls, v, 143, iDb, 0, 0, (*Table)(unsafe.Pointer(pTab)).FzName, 0) + Xsqlite3VdbeAddOp4(tls, v, OP_DropTable, iDb, 0, 0, (*Table)(unsafe.Pointer(pTab)).FzName, 0) Xsqlite3ChangeCookie(tls, pParse, iDb) sqliteViewResetAll(tls, db, iDb) } @@ -94521,7 +93662,7 @@ func Xsqlite3CodeDropTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iDb int3 // Return TRUE if shadow tables should be read-only in the current // context. func Xsqlite3ReadOnlyShadowTables(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:113409:20: */ - if ((((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x10000000)) != uint64(0)) && + if ((((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_Defensive) != uint64(0)) && ((*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx == uintptr(0))) && ((*Sqlite3)(unsafe.Pointer(db)).FnVdbeExec == 0) { return 1 @@ -94540,7 +93681,7 @@ func tableMayNotBeDropped(tls *libc.TLS, db uintptr, pTab uintptr) int32 { /* sq } return 1 } - if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x1000)) != U32(0)) && (Xsqlite3ReadOnlyShadowTables(tls, db) != 0) { + if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Shadow) != U32(0)) && (Xsqlite3ReadOnlyShadowTables(tls, db) != 0) { return 1 } return 0 @@ -94582,7 +93723,7 @@ __2: __3: ; - pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(isView), ((pName + 8 /* &.a */) + uintptr(0)*112)) + pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(isView), (pName + 8 /* &.a */)) if !(noErr != 0) { goto __4 } @@ -94596,7 +93737,7 @@ __4: if !(noErr != 0) { goto __6 } - Xsqlite3CodeVerifyNamedSchema(tls, pParse, (*SrcList_item)(unsafe.Pointer((pName+8 /* &.a */)+uintptr(0)*112)).FzDatabase) + Xsqlite3CodeVerifyNamedSchema(tls, pParse, (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */))).FzDatabase) __6: ; goto exit_drop_table @@ -94621,7 +93762,7 @@ __7: }() zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName zArg2 = uintptr(0) - if !(Xsqlite3AuthCheck(tls, pParse, 9, zTab, uintptr(0), zDb) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, zTab, uintptr(0), zDb) != 0) { goto __8 } goto exit_drop_table @@ -94633,10 +93774,10 @@ __8: if !(!(0 != 0) && (iDb == 1)) { goto __11 } - code = 15 + code = SQLITE_DROP_TEMP_VIEW goto __12 __11: - code = 17 + code = SQLITE_DROP_VIEW __12: ; goto __10 @@ -94644,17 +93785,17 @@ __9: if !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { goto __13 } - code = 30 + code = SQLITE_DROP_VTABLE zArg2 = (*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer(Xsqlite3GetVTable(tls, db, pTab))).FpMod)).FzName goto __14 __13: if !(!(0 != 0) && (iDb == 1)) { goto __15 } - code = 13 + code = SQLITE_DROP_TEMP_TABLE goto __16 __15: - code = 11 + code = SQLITE_DROP_TABLE __16: ; __14: @@ -94667,7 +93808,7 @@ __10: goto exit_drop_table __17: ; - if !(Xsqlite3AuthCheck(tls, pParse, 9, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), zDb) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), zDb) != 0) { goto __18 } goto exit_drop_table @@ -94754,7 +93895,7 @@ func Xsqlite3CreateForeignKey(tls *libc.TLS, pParse uintptr, pFromCol uintptr, p pFKey = uintptr(0) p = (*Parse)(unsafe.Pointer(pParse)).FpNewTable - if !((p == uintptr(0)) || (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == 1)) { + if !((p == uintptr(0)) || (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == PARSE_MODE_DECLARE_VTAB)) { goto __1 } goto fk_end @@ -94826,7 +93967,7 @@ __12: (*FKey)(unsafe.Pointer(pFKey)).FpNextFrom = (*Table)(unsafe.Pointer(p)).FpFKey z = ((pFKey + 64 /* &.aCol */) + uintptr(nCol)*16) (*FKey)(unsafe.Pointer(pFKey)).FzTo = z - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __13 } Xsqlite3RenameTokenMap(tls, pParse, z, pTo) @@ -94840,7 +93981,7 @@ __13: if !(pFromCol == uintptr(0)) { goto __14 } - (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(0)*16)).FiFrom = (int32((*Table)(unsafe.Pointer(p)).FnCol) - 1) + (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */))).FiFrom = (int32((*Table)(unsafe.Pointer(p)).FnCol) - 1) goto __15 __14: i = 0 @@ -94876,7 +94017,7 @@ __21: goto fk_end __23: ; - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __24 } Xsqlite3RenameTokenRemap(tls, pParse, ((pFKey + 64 /* &.aCol */) + uintptr(i)*16), (*ExprList_item)(unsafe.Pointer((pFromCol+8 /* &.a */)+uintptr(i)*32)).FzEName) @@ -94901,7 +94042,7 @@ __26: } n = Xsqlite3Strlen30(tls, (*ExprList_item)(unsafe.Pointer((pToCol+8 /* &.a */)+uintptr(i)*32)).FzEName) (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(i)*16)).FzCol = z - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __29 } Xsqlite3RenameTokenRemap(tls, pParse, z, (*ExprList_item)(unsafe.Pointer((pToCol+8 /* &.a */)+uintptr(i)*32)).FzEName) @@ -94920,8 +94061,8 @@ __28: __25: ; (*FKey)(unsafe.Pointer(pFKey)).FisDeferred = U8(0) - *(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + uintptr(0))) = (U8(flags & 0xff)) // ON DELETE action - *(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + uintptr(1))) = (U8((flags >> 8) & 0xff)) // ON UPDATE action + *(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */))) = (U8(flags & 0xff)) // ON DELETE action + *(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + 1)) = (U8((flags >> 8) & 0xff)) // ON UPDATE action pNextTo = Xsqlite3HashInsert(tls, ((*Table)(unsafe.Pointer(p)).FpSchema + 80 /* &.fkeyHash */), (*FKey)(unsafe.Pointer(pFKey)).FzTo, pFKey) @@ -94994,7 +94135,7 @@ func sqlite3RefillIndex(tls *libc.TLS, pParse uintptr, pIndex uintptr, memRootPa var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb // The database connection var iDb int32 = Xsqlite3SchemaToIndex(tls, db, (*Index)(unsafe.Pointer(pIndex)).FpSchema) - if Xsqlite3AuthCheck(tls, pParse, 27, (*Index)(unsafe.Pointer(pIndex)).FzName, uintptr(0), + if Xsqlite3AuthCheck(tls, pParse, SQLITE_REINDEX, (*Index)(unsafe.Pointer(pIndex)).FzName, uintptr(0), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) != 0 { return } @@ -95015,40 +94156,40 @@ func sqlite3RefillIndex(tls *libc.TLS, pParse uintptr, pIndex uintptr, memRootPa // Open the sorter cursor if we are to use one. iSorter = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - Xsqlite3VdbeAddOp4(tls, v, 111, iSorter, 0, int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol), Xsqlite3KeyInfoRef(tls, pKey), -9) + Xsqlite3VdbeAddOp4(tls, v, OP_SorterOpen, iSorter, 0, int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol), Xsqlite3KeyInfoRef(tls, pKey), -9) // Open the table. Loop through all rows of the table, inserting index // records into the sorter. - Xsqlite3OpenTable(tls, pParse, iTab, iDb, pTab, 96) - addr1 = Xsqlite3VdbeAddOp2(tls, v, 37, iTab, 0) + Xsqlite3OpenTable(tls, pParse, iTab, iDb, pTab, OP_OpenRead) + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iTab, 0) regRecord = Xsqlite3GetTempReg(tls, pParse) Xsqlite3MultiWrite(tls, pParse) Xsqlite3GenerateIndexKey(tls, pParse, pIndex, iTab, regRecord, 0, bp /* &iPartIdxLabel */, uintptr(0), 0) - Xsqlite3VdbeAddOp2(tls, v, 131, iSorter, regRecord) + Xsqlite3VdbeAddOp2(tls, v, OP_SorterInsert, iSorter, regRecord) Xsqlite3ResolvePartIdxLabel(tls, pParse, *(*int32)(unsafe.Pointer(bp /* iPartIdxLabel */))) - Xsqlite3VdbeAddOp2(tls, v, 5, iTab, (addr1 + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iTab, (addr1 + 1)) Xsqlite3VdbeJumpHere(tls, v, addr1) if memRootPage < 0 { - Xsqlite3VdbeAddOp2(tls, v, 137, int32(tnum), iDb) + Xsqlite3VdbeAddOp2(tls, v, OP_Clear, int32(tnum), iDb) } - Xsqlite3VdbeAddOp4(tls, v, 97, iIdx, int32(tnum), iDb, + Xsqlite3VdbeAddOp4(tls, v, OP_OpenWrite, iIdx, int32(tnum), iDb, pKey, -9) - Xsqlite3VdbeChangeP5(tls, v, (uint16(0x01 | (func() int32 { + Xsqlite3VdbeChangeP5(tls, v, (uint16(OPFLAG_BULKCSR | (func() int32 { if memRootPage >= 0 { - return 0x10 + return OPFLAG_P2ISREG } return 0 }())))) - addr1 = Xsqlite3VdbeAddOp2(tls, v, 35, iSorter, 0) - if int32((*Index)(unsafe.Pointer((pIndex))).FonError) != 0 { + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_SorterSort, iSorter, 0) + if int32((*Index)(unsafe.Pointer((pIndex))).FonError) != OE_None { var j2 int32 = Xsqlite3VdbeGoto(tls, v, 1) addr2 = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp4Int(tls, v, 124, iSorter, j2, regRecord, + Xsqlite3VdbeAddOp4Int(tls, v, OP_SorterCompare, iSorter, j2, regRecord, int32((*Index)(unsafe.Pointer(pIndex)).FnKeyCol)) - Xsqlite3UniqueConstraint(tls, pParse, 2, pIndex) + Xsqlite3UniqueConstraint(tls, pParse, OE_Abort, pIndex) Xsqlite3VdbeJumpHere(tls, v, j2) } else { // Most CREATE INDEX and REINDEX statements that are not UNIQUE can not @@ -95061,7 +94202,7 @@ func sqlite3RefillIndex(tls *libc.TLS, pParse uintptr, pIndex uintptr, memRootPa Xsqlite3MayAbort(tls, pParse) addr2 = Xsqlite3VdbeCurrentAddr(tls, v) } - Xsqlite3VdbeAddOp3(tls, v, 125, iSorter, regRecord, iIdx) + Xsqlite3VdbeAddOp3(tls, v, OP_SorterData, iSorter, regRecord, iIdx) if !((int32(*(*uint16)(unsafe.Pointer(pIndex + 100 /* &.bAscKeyBug */)) & 0x200 >> 9)) != 0) { // This OP_SeekEnd opcode makes index insert for a REINDEX go much // faster by avoiding unnecessary seeks. But the optimization does @@ -95069,17 +94210,17 @@ func sqlite3RefillIndex(tls *libc.TLS, pParse uintptr, pIndex uintptr, memRootPa // with DESC primary keys, since those indexes have there keys in // a different order from the main table. // See ticket: https://www.sqlite.org/src/info/bba7b69f9849b5bf - Xsqlite3VdbeAddOp1(tls, v, 129, iIdx) + Xsqlite3VdbeAddOp1(tls, v, OP_SeekEnd, iIdx) } - Xsqlite3VdbeAddOp2(tls, v, 130, iIdx, regRecord) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, iIdx, regRecord) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_USESEEKRESULT) Xsqlite3ReleaseTempReg(tls, pParse, regRecord) - Xsqlite3VdbeAddOp2(tls, v, 3, iSorter, addr2) + Xsqlite3VdbeAddOp2(tls, v, OP_SorterNext, iSorter, addr2) Xsqlite3VdbeJumpHere(tls, v, addr1) - Xsqlite3VdbeAddOp1(tls, v, 116, iTab) - Xsqlite3VdbeAddOp1(tls, v, 116, iIdx) - Xsqlite3VdbeAddOp1(tls, v, 116, iSorter) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iTab) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iIdx) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iSorter) } // Allocate heap space to hold an Index object with nCol columns. @@ -95091,12 +94232,12 @@ func Xsqlite3AllocateIndexObject(tls *libc.TLS, db uintptr, nCol I16, nExtra int var p uintptr // Allocated index object var nByte int32 // Bytes of space for Index object + arrays - nByte = (int32(((((uint64(unsafe.Sizeof(Index{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)) + (((uint64(unsafe.Sizeof(uintptr(0))) * uint64(nCol)) + uint64(7)) & ^libc.Uint64FromInt32(7))) + (((((uint64(unsafe.Sizeof(LogEst(0))) * (uint64(int32(nCol) + 1))) + (uint64(unsafe.Sizeof(I16(0))) * uint64(nCol))) + (uint64(unsafe.Sizeof(U8(0))) * uint64(nCol))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) // Index.aSortOrder + nByte = (int32(((((uint64(unsafe.Sizeof(Index{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))) + (((uint64(unsafe.Sizeof(uintptr(0))) * uint64(nCol)) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) + (((((uint64(unsafe.Sizeof(LogEst(0))) * (uint64(int32(nCol) + 1))) + (uint64(unsafe.Sizeof(I16(0))) * uint64(nCol))) + (uint64(unsafe.Sizeof(U8(0))) * uint64(nCol))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))))) // Index.aSortOrder p = Xsqlite3DbMallocZero(tls, db, (uint64(nByte + nExtra))) if p != 0 { - var pExtra uintptr = ((p) + uintptr((((uint64(unsafe.Sizeof(Index{}))) + uint64(7)) & ^libc.Uint64FromInt32(7)))) + var pExtra uintptr = ((p) + uintptr((((uint64(unsafe.Sizeof(Index{}))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7))))) (*Index)(unsafe.Pointer(p)).FazColl = pExtra - pExtra += (uintptr(((uint64(unsafe.Sizeof(uintptr(0))) * uint64(nCol)) + uint64(7)) & ^libc.Uint64FromInt32(7))) + pExtra += (uintptr(((uint64(unsafe.Sizeof(uintptr(0))) * uint64(nCol)) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) (*Index)(unsafe.Pointer(p)).FaiRowLogEst = pExtra pExtra += (uintptr(uint64(unsafe.Sizeof(LogEst(0))) * (uint64(int32(nCol) + 1)))) (*Index)(unsafe.Pointer(p)).FaiColumn = pExtra @@ -95228,13 +94369,13 @@ func Xsqlite3CreateIndex(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 u goto exit_create_index __1: ; - if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == 1) && (int32(idxType) != 2)) { + if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) == PARSE_MODE_DECLARE_VTAB) && (int32(idxType) != SQLITE_IDXTYPE_PRIMARYKEY)) { goto __2 } goto exit_create_index __2: ; - if !(0 != Xsqlite3ReadSchema(tls, pParse)) { + if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) { goto __3 } goto exit_create_index @@ -95271,7 +94412,7 @@ __7: goto __8 } pTab = Xsqlite3SrcListLookup(tls, pParse, pTblName) - if !((((*Token)(unsafe.Pointer(pName2)).Fn == uint32(0)) && (pTab != 0)) && ((*Table)(unsafe.Pointer(pTab)).FpSchema == (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema)) { + if !((((*Token)(unsafe.Pointer(pName2)).Fn == uint32(0)) && (pTab != 0)) && ((*Table)(unsafe.Pointer(pTab)).FpSchema == (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema)) { goto __9 } iDb = 1 @@ -95289,7 +94430,7 @@ __8: __10: ; - pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), ((pTblName + 8 /* &.a */) + uintptr(0)*112)) + pTab = Xsqlite3LocateTableItem(tls, pParse, uint32(0), (pTblName + 8 /* &.a */)) if !(pTab == uintptr(0)) { goto __11 @@ -95306,7 +94447,7 @@ __11: goto exit_create_index __12: ; - if !(!(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) { + if !(!(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) { goto __13 } pPk = Xsqlite3PrimaryKeyIndex(tls, pTab) @@ -95374,13 +94515,13 @@ __17: __20: ; - if !(0 != Xsqlite3CheckObjectName(tls, pParse, zName, ts+8242 /* "index" */, (*Table)(unsafe.Pointer(pTab)).FzName)) { + if !(SQLITE_OK != Xsqlite3CheckObjectName(tls, pParse, zName, ts+8242 /* "index" */, (*Table)(unsafe.Pointer(pTab)).FzName)) { goto __21 } goto exit_create_index __21: ; - if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) { + if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) { goto __22 } if !(!(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0)) { @@ -95442,21 +94583,21 @@ __31: // The following statement converts "sqlite3_autoindex..." into // "sqlite3_butoindex..." in order to make the names distinct. // The "vtab_err.test" test demonstrates the need of this statement. - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != 0) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL) { goto __32 } - *(*int8)(unsafe.Pointer(zName + uintptr(7)))++ + *(*int8)(unsafe.Pointer(zName + 7))++ __32: ; __19: ; // Check for authorization to create an index. - if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) { + if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) { goto __33 } zDb = (*Db)(unsafe.Pointer(pDb)).FzDbSName - if !(Xsqlite3AuthCheck(tls, pParse, 18, func() uintptr { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_INSERT, func() uintptr { if (!(0 != 0)) && (iDb == 1) { return ts + 13301 /* "sqlite_temp_mast..." */ } @@ -95467,11 +94608,11 @@ __19: goto exit_create_index __34: ; - i = 1 + i = SQLITE_CREATE_INDEX if !(!(0 != 0) && (iDb == 1)) { goto __35 } - i = 3 + i = SQLITE_CREATE_TEMP_INDEX __35: ; if !(Xsqlite3AuthCheck(tls, pParse, i, zName, (*Table)(unsafe.Pointer(pTab)).FzName, zDb) != 0) { @@ -95490,10 +94631,10 @@ __33: goto __37 } pCol = ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr((int32((*Table)(unsafe.Pointer(pTab)).FnCol)-1))*32) - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((COLFLAG_UNIQUE)) Xsqlite3TokenInit(tls, bp+184 /* &prevCol */, (*Column)(unsafe.Pointer(pCol)).FzName) pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), - Xsqlite3ExprAlloc(tls, db, 59, bp+184 /* &prevCol */, 0)) + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+184 /* &prevCol */, 0)) if !(pList == uintptr(0)) { goto __39 } @@ -95523,7 +94664,7 @@ __41: } pExpr = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(i)*32)).FpExpr - if !(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 111) { + if !(int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLLATE) { goto __44 } nExtra = nExtra + (1 + Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)))) @@ -95559,14 +94700,14 @@ __45: libc.Xmemcpy(tls, (*Index)(unsafe.Pointer(pIndex)).FzName, zName, (uint64(nName + 1))) (*Index)(unsafe.Pointer(pIndex)).FpTable = pTab (*Index)(unsafe.Pointer(pIndex)).FonError = U8(onError) - libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.uniqNotNull */, (uint32(libc.Bool32(onError != 0))), 3, 0x8) + libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.uniqNotNull */, (uint32(libc.Bool32(onError != OE_None))), 3, 0x8) libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.idxType */, uint32(idxType), 0, 0x3) (*Index)(unsafe.Pointer(pIndex)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpSchema (*Index)(unsafe.Pointer(pIndex)).FnKeyCol = U16((*ExprList)(unsafe.Pointer(pList)).FnExpr) if !(pPIWhere != 0) { goto __46 } - Xsqlite3ResolveSelfReference(tls, pParse, pTab, 0x00002, pPIWhere, uintptr(0)) + Xsqlite3ResolveSelfReference(tls, pParse, pTab, NC_PartIdx, pPIWhere, uintptr(0)) (*Index)(unsafe.Pointer(pIndex)).FpPartIdxWhere = pPIWhere pPIWhere = uintptr(0) __46: @@ -95592,7 +94733,7 @@ __48: // TODO: Issue a warning if the table primary key is used as part of the // index key. pListItem = pList + 8 /* &.a */ - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __49 } (*Index)(unsafe.Pointer(pIndex)).FaColExpr = pList @@ -95606,7 +94747,7 @@ __50: } // Collation sequence name sqlite3StringToId(tls, (*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr) - Xsqlite3ResolveSelfReference(tls, pParse, pTab, 0x00020, (*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr, uintptr(0)) + Xsqlite3ResolveSelfReference(tls, pParse, pTab, NC_IdxExpr, (*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr, uintptr(0)) if !((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) { goto __53 } @@ -95614,7 +94755,7 @@ __50: __53: ; pCExpr = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr) - if !(int32((*Expr)(unsafe.Pointer(pCExpr)).Fop) != 164) { + if !(int32((*Expr)(unsafe.Pointer(pCExpr)).Fop) != TK_COLUMN) { goto __54 } if !(pTab == (*Parse)(unsafe.Pointer(pParse)).FpNewTable) { @@ -95651,7 +94792,7 @@ __58: libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.uniqNotNull */, uint32(0), 3, 0x8) __60: ; - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & 0x0020) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0) { goto __61 } libc.SetBitFieldPtr16Uint32(pIndex+100 /* &.bHasVCol */, uint32(1), 10, 0x400) @@ -95663,7 +94804,7 @@ __59: __55: ; zColl = uintptr(0) - if !(int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr)).Fop) == 111) { + if !(int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr)).Fop) == TK_COLLATE) { goto __62 } zColl = *(*uintptr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(pListItem)).FpExpr + 8 /* &.u */)) @@ -95846,14 +94987,14 @@ __88: // constraint and the previous equivalent constraint have explicit // ON CONFLICT clauses this is an error. Otherwise, use the // explicitly specified behavior for the index. - if !(!((int32((*Index)(unsafe.Pointer(pIdx)).FonError) == 11) || (int32((*Index)(unsafe.Pointer(pIndex)).FonError) == 11))) { + if !(!((int32((*Index)(unsafe.Pointer(pIdx)).FonError) == OE_Default) || (int32((*Index)(unsafe.Pointer(pIndex)).FonError) == OE_Default))) { goto __93 } Xsqlite3ErrorMsg(tls, pParse, ts+15180 /* "conflicting ON C..." */, libc.VaList(bp+48, 0)) __93: ; - if !(int32((*Index)(unsafe.Pointer(pIdx)).FonError) == 11) { + if !(int32((*Index)(unsafe.Pointer(pIdx)).FonError) == OE_Default) { goto __94 } (*Index)(unsafe.Pointer(pIdx)).FonError = (*Index)(unsafe.Pointer(pIndex)).FonError @@ -95861,13 +95002,13 @@ __94: ; __92: ; - if !(int32(idxType) == 2) { + if !(int32(idxType) == SQLITE_IDXTYPE_PRIMARYKEY) { goto __95 } libc.SetBitFieldPtr16Uint32(pIdx+100 /* &.idxType */, uint32(idxType), 0, 0x3) __95: ; - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __96 } (*Index)(unsafe.Pointer(pIndex)).FpNext = (*Parse)(unsafe.Pointer(pParse)).FpNewIndex @@ -95888,7 +95029,7 @@ __84: __81: ; - if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) { + if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) { goto __97 } @@ -95923,10 +95064,10 @@ __100: goto exit_create_index __102: ; - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) goto __99 __98: - if !((((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) || (pTblName != uintptr(0))) { + if !((((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) || (pTblName != uintptr(0))) { goto __103 } iMem = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) @@ -95947,8 +95088,8 @@ __104: // PRIMARY KEY and the table is actually a WITHOUT ROWID table. In // that case the convertToWithoutRowidTable() routine will replace // the Noop with a Goto to jump over the VDBE code generated below. - (*Index)(unsafe.Pointer(pIndex)).Ftnum = Pgno(Xsqlite3VdbeAddOp0(tls, v, 173)) - Xsqlite3VdbeAddOp3(tls, v, 139, iDb, iMem, 2) + (*Index)(unsafe.Pointer(pIndex)).Ftnum = Pgno(Xsqlite3VdbeAddOp0(tls, v, OP_Noop)) + Xsqlite3VdbeAddOp3(tls, v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY) // Gather the complete text of the CREATE INDEX statement into // the zStmt variable @@ -95966,7 +95107,7 @@ __107: // A named index with an explicit CREATE INDEX statement zStmt = Xsqlite3MPrintf(tls, db, ts+15239, /* "CREATE%s INDEX %..." */ libc.VaList(bp+56, func() uintptr { - if onError == 0 { + if onError == OE_None { return ts + 800 /* "" */ } return ts + 15259 /* " UNIQUE" */ @@ -95998,7 +95139,7 @@ __106: Xsqlite3ChangeCookie(tls, pParse, iDb) Xsqlite3VdbeAddParseSchemaOp(tls, v, iDb, Xsqlite3MPrintf(tls, db, ts+15326 /* "name='%q' AND ty..." */, libc.VaList(bp+120, (*Index)(unsafe.Pointer(pIndex)).FzName))) - Xsqlite3VdbeAddOp2(tls, v, 158, 0, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_Expire, 0, 1) __108: ; @@ -96017,7 +95158,7 @@ __97: pIndex = uintptr(0) goto __110 __109: - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __111 } @@ -96045,14 +95186,14 @@ __114: if !((libc.AssignUintptr(&pThis, *(*uintptr)(unsafe.Pointer(ppFrom)))) != uintptr(0)) { goto __116 } - if !(int32((*Index)(unsafe.Pointer(pThis)).FonError) != 5) { + if !(int32((*Index)(unsafe.Pointer(pThis)).FonError) != OE_Replace) { goto __117 } goto __115 __117: ; __118: - if !(((libc.AssignUintptr(&pNext, (*Index)(unsafe.Pointer(pThis)).FpNext)) != uintptr(0)) && (int32((*Index)(unsafe.Pointer(pNext)).FonError) != 5)) { + if !(((libc.AssignUintptr(&pNext, (*Index)(unsafe.Pointer(pThis)).FpNext)) != uintptr(0)) && (int32((*Index)(unsafe.Pointer(pNext)).FonError) != OE_Replace)) { goto __119 } *(*uintptr)(unsafe.Pointer(ppFrom)) = pNext @@ -96124,16 +95265,16 @@ func Xsqlite3DefaultRowEst(tls *libc.TLS, pIdx uintptr) { /* sqlite3.c:114468:21 if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0) { x = int16(int32(x) - (10)) } - *(*LogEst)(unsafe.Pointer(a + uintptr(0)*2)) = x + *(*LogEst)(unsafe.Pointer(a)) = x // Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is // 6 and each subsequent value (if any) is 5. - libc.Xmemcpy(tls, (a + uintptr(1)*2), uintptr(unsafe.Pointer(&aVal)), (uint64(nCopy) * uint64(unsafe.Sizeof(LogEst(0))))) + libc.Xmemcpy(tls, (a + 1*2), uintptr(unsafe.Pointer(&aVal)), (uint64(nCopy) * uint64(unsafe.Sizeof(LogEst(0))))) for i = (nCopy + 1); i <= int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol); i++ { *(*LogEst)(unsafe.Pointer(a + uintptr(i)*2)) = int16(23) } - if int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0 { + if int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None { *(*LogEst)(unsafe.Pointer(a + uintptr((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)*2)) = int16(0) } } @@ -96164,13 +95305,13 @@ func Xsqlite3DropIndex(tls *libc.TLS, pParse uintptr, pName uintptr, ifExists in __1: ; - if !(0 != Xsqlite3ReadSchema(tls, pParse)) { + if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) { goto __2 } goto exit_drop_index __2: ; - pIndex = Xsqlite3FindIndex(tls, db, (*SrcList_item)(unsafe.Pointer((pName+8 /* &.a */)+uintptr(0)*112)).FzName, (*SrcList_item)(unsafe.Pointer((pName+8 /* &.a */)+uintptr(0)*112)).FzDatabase) + pIndex = Xsqlite3FindIndex(tls, db, (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */))).FzName, (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */))).FzDatabase) if !(pIndex == uintptr(0)) { goto __3 } @@ -96180,14 +95321,14 @@ __2: Xsqlite3ErrorMsg(tls, pParse, ts+15353 /* "no such index: %..." */, libc.VaList(bp, pName, 0)) goto __5 __4: - Xsqlite3CodeVerifyNamedSchema(tls, pParse, (*SrcList_item)(unsafe.Pointer((pName+8 /* &.a */)+uintptr(0)*112)).FzDatabase) + Xsqlite3CodeVerifyNamedSchema(tls, pParse, (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */))).FzDatabase) __5: ; (*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1) goto exit_drop_index __3: ; - if !((int32(*(*uint16)(unsafe.Pointer(pIndex + 100 /* &.idxType */)) & 0x3 >> 0)) != 0) { + if !((int32(*(*uint16)(unsafe.Pointer(pIndex + 100 /* &.idxType */)) & 0x3 >> 0)) != SQLITE_IDXTYPE_APPDEF) { goto __6 } Xsqlite3ErrorMsg(tls, pParse, @@ -96197,7 +95338,7 @@ __6: ; iDb = Xsqlite3SchemaToIndex(tls, db, (*Index)(unsafe.Pointer(pIndex)).FpSchema) - code = 10 + code = SQLITE_DROP_INDEX pTab = (*Index)(unsafe.Pointer(pIndex)).FpTable zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName zTab = func() uintptr { @@ -96206,7 +95347,7 @@ __6: } return ts + 7541 /* "sqlite_master" */ }() - if !(Xsqlite3AuthCheck(tls, pParse, 9, zTab, uintptr(0), zDb) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, zTab, uintptr(0), zDb) != 0) { goto __7 } goto exit_drop_index @@ -96215,7 +95356,7 @@ __7: if !(!(0 != 0) && (iDb != 0)) { goto __8 } - code = 12 + code = SQLITE_DROP_TEMP_INDEX __8: ; if !(Xsqlite3AuthCheck(tls, pParse, code, (*Index)(unsafe.Pointer(pIndex)).FzName, (*Table)(unsafe.Pointer(pTab)).FzName, zDb) != 0) { @@ -96237,7 +95378,7 @@ __9: sqlite3ClearStatTables(tls, pParse, iDb, ts+12628 /* "idx" */, (*Index)(unsafe.Pointer(pIndex)).FzName) Xsqlite3ChangeCookie(tls, pParse, iDb) destroyRootPage(tls, pParse, int32((*Index)(unsafe.Pointer(pIndex)).Ftnum), iDb) - Xsqlite3VdbeAddOp4(tls, v, 144, iDb, 0, 0, (*Index)(unsafe.Pointer(pIndex)).FzName, 0) + Xsqlite3VdbeAddOp4(tls, v, OP_DropIndex, iDb, 0, 0, (*Index)(unsafe.Pointer(pIndex)).FzName, 0) __10: ; @@ -96311,7 +95452,7 @@ func Xsqlite3IdListAppend(tls *libc.TLS, pParse uintptr, pList uintptr, pToken u return uintptr(0) } (*IdList_item)(unsafe.Pointer((*IdList)(unsafe.Pointer(pList)).Fa + uintptr(*(*int32)(unsafe.Pointer(bp /* i */)))*16)).FzName = Xsqlite3NameFromToken(tls, db, pToken) - if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && ((*IdList_item)(unsafe.Pointer((*IdList)(unsafe.Pointer(pList)).Fa+uintptr(*(*int32)(unsafe.Pointer(bp /* i */)))*16)).FzName != 0) { + if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && ((*IdList_item)(unsafe.Pointer((*IdList)(unsafe.Pointer(pList)).Fa+uintptr(*(*int32)(unsafe.Pointer(bp /* i */)))*16)).FzName != 0) { Xsqlite3RenameTokenMap(tls, pParse, (*IdList_item)(unsafe.Pointer((*IdList)(unsafe.Pointer(pList)).Fa+uintptr(*(*int32)(unsafe.Pointer(bp /* i */)))*16)).FzName, pToken) } return pList @@ -96384,13 +95525,13 @@ func Xsqlite3SrcListEnlarge(tls *libc.TLS, pParse uintptr, pSrc uintptr, nExtra var nAlloc Sqlite3_int64 = ((int64(2) * Sqlite3_int64((*SrcList)(unsafe.Pointer(pSrc)).FnSrc)) + Sqlite3_int64(nExtra)) var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if ((*SrcList)(unsafe.Pointer(pSrc)).FnSrc + nExtra) >= 200 { + if ((*SrcList)(unsafe.Pointer(pSrc)).FnSrc + nExtra) >= SQLITE_MAX_SRCLIST { Xsqlite3ErrorMsg(tls, pParse, ts+15504, /* "too many FROM cl..." */ - libc.VaList(bp, 200)) + libc.VaList(bp, SQLITE_MAX_SRCLIST)) return uintptr(0) } - if nAlloc > int64(200) { - nAlloc = int64(200) + if nAlloc > SQLITE_MAX_SRCLIST { + nAlloc = SQLITE_MAX_SRCLIST } pNew = Xsqlite3DbRealloc(tls, db, pSrc, (uint64(unsafe.Sizeof(SrcList{})) + ((uint64(nAlloc - int64(1))) * uint64(unsafe.Sizeof(SrcList_item{}))))) @@ -96465,8 +95606,8 @@ func Xsqlite3SrcListAppend(tls *libc.TLS, pParse uintptr, pList uintptr, pTable } (*SrcList)(unsafe.Pointer(pList)).FnAlloc = U32(1) (*SrcList)(unsafe.Pointer(pList)).FnSrc = 1 - libc.Xmemset(tls, ((pList + 8 /* &.a */) + uintptr(0)*112), 0, uint64(unsafe.Sizeof(SrcList_item{}))) - (*SrcList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(0)*112)).FiCursor = -1 + libc.Xmemset(tls, (pList + 8 /* &.a */), 0, uint64(unsafe.Sizeof(SrcList_item{}))) + (*SrcList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FiCursor = -1 } else { var pNew uintptr = Xsqlite3SrcListEnlarge(tls, pParse, pList, 1, (*SrcList)(unsafe.Pointer(pList)).FnSrc) if pNew == uintptr(0) { @@ -96607,7 +95748,7 @@ __2: pItem = ((p + 8 /* &.a */) + uintptr(((*SrcList)(unsafe.Pointer(p)).FnSrc-1))*112) - if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && ((*SrcList_item)(unsafe.Pointer(pItem)).FzName != 0)) { + if !((int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && ((*SrcList_item)(unsafe.Pointer(pItem)).FzName != 0)) { goto __3 } if (pDatabase != 0) && ((*Token)(unsafe.Pointer(pDatabase)).Fz != 0) { @@ -96669,7 +95810,7 @@ func Xsqlite3SrcListAppendList(tls *libc.TLS, pParse uintptr, p1 uintptr, p2 uin Xsqlite3SrcListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p2) } else { p1 = pNew - libc.Xmemcpy(tls, ((p1 + 8 /* &.a */) + uintptr(1)*112), p2+8 /* &.a */, (uint64((*SrcList)(unsafe.Pointer(p2)).FnSrc) * uint64(unsafe.Sizeof(SrcList_item{})))) + libc.Xmemcpy(tls, ((p1 + 8 /* &.a */) + 1*112), p2+8 /* &.a */, (uint64((*SrcList)(unsafe.Pointer(p2)).FnSrc) * uint64(unsafe.Sizeof(SrcList_item{})))) Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p2) } } @@ -96708,7 +95849,7 @@ func Xsqlite3SrcListShiftJoinType(tls *libc.TLS, p uintptr) { /* sqlite3.c:11501 for i = ((*SrcList)(unsafe.Pointer(p)).FnSrc - 1); i > 0; i-- { (*SrcList_item)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(i)*112)).Ffg.Fjointype = (*SrcList_item)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((i-1))*112)).Ffg.Fjointype } - (*SrcList_item)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(0)*112)).Ffg.Fjointype = U8(0) + (*SrcList_item)(unsafe.Pointer((p + 8 /* &.a */))).Ffg.Fjointype = U8(0) } } @@ -96720,20 +95861,20 @@ func Xsqlite3BeginTransaction(tls *libc.TLS, pParse uintptr, type1 int32) { /* s db = (*Parse)(unsafe.Pointer(pParse)).Fdb - if Xsqlite3AuthCheck(tls, pParse, 22, ts+15585 /* "BEGIN" */, uintptr(0), uintptr(0)) != 0 { + if Xsqlite3AuthCheck(tls, pParse, SQLITE_TRANSACTION, ts+15585 /* "BEGIN" */, uintptr(0), uintptr(0)) != 0 { return } v = Xsqlite3GetVdbe(tls, pParse) if !(v != 0) { return } - if type1 != 7 { + if type1 != TK_DEFERRED { for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { - Xsqlite3VdbeAddOp2(tls, v, 2, i, ((libc.Bool32(type1 == 9)) + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Transaction, i, ((libc.Bool32(type1 == TK_EXCLUSIVE)) + 1)) Xsqlite3VdbeUsesBtree(tls, v, i) } } - Xsqlite3VdbeAddOp0(tls, v, 1) + Xsqlite3VdbeAddOp0(tls, v, OP_AutoCommit) } // Generate VDBE code for a COMMIT or ROLLBACK statement. @@ -96743,8 +95884,8 @@ func Xsqlite3EndTransaction(tls *libc.TLS, pParse uintptr, eType int32) { /* sql var v uintptr var isRollback int32 - isRollback = (libc.Bool32(eType == 12)) - if Xsqlite3AuthCheck(tls, pParse, 22, + isRollback = (libc.Bool32(eType == TK_ROLLBACK)) + if Xsqlite3AuthCheck(tls, pParse, SQLITE_TRANSACTION, func() uintptr { if isRollback != 0 { return ts + 15591 /* "ROLLBACK" */ @@ -96755,7 +95896,7 @@ func Xsqlite3EndTransaction(tls *libc.TLS, pParse uintptr, eType int32) { /* sql } v = Xsqlite3GetVdbe(tls, pParse) if v != 0 { - Xsqlite3VdbeAddOp2(tls, v, 1, 1, isRollback) + Xsqlite3VdbeAddOp2(tls, v, OP_AutoCommit, 1, isRollback) } } @@ -96766,11 +95907,11 @@ func Xsqlite3Savepoint(tls *libc.TLS, pParse uintptr, op int32, pName uintptr) { if zName != 0 { var v uintptr = Xsqlite3GetVdbe(tls, pParse) - if !(v != 0) || (Xsqlite3AuthCheck(tls, pParse, 32, az[op], zName, uintptr(0)) != 0) { + if !(v != 0) || (Xsqlite3AuthCheck(tls, pParse, SQLITE_SAVEPOINT, az[op], zName, uintptr(0)) != 0) { Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, zName) return } - Xsqlite3VdbeAddOp4(tls, v, 0, op, 0, 0, zName, -7) + Xsqlite3VdbeAddOp4(tls, v, OP_Savepoint, op, 0, 0, zName, -7) } } @@ -96783,20 +95924,20 @@ func Xsqlite3OpenTempDatabase(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3. defer tls.Free(8) var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpBt == uintptr(0)) && !(int32((*Parse)(unsafe.Pointer(pParse)).Fexplain) != 0) { + if ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpBt == uintptr(0)) && !(int32((*Parse)(unsafe.Pointer(pParse)).Fexplain) != 0) { var rc int32 // var pBt uintptr at bp, 8 rc = Xsqlite3BtreeOpen(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), db, bp /* &pBt */, 0, flags) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3ErrorMsg(tls, pParse, ts+15615 /* "unable to open a..." */, 0) (*Parse)(unsafe.Pointer(pParse)).Frc = rc return 1 } - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(1)*32)).FpBt = *(*uintptr)(unsafe.Pointer(bp /* pBt */)) + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*32)).FpBt = *(*uintptr)(unsafe.Pointer(bp /* pBt */)) - if 7 == Xsqlite3BtreeSetPageSize(tls, *(*uintptr)(unsafe.Pointer(bp /* pBt */)), (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0) { + if SQLITE_NOMEM == Xsqlite3BtreeSetPageSize(tls, *(*uintptr)(unsafe.Pointer(bp /* pBt */)), (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0) { Xsqlite3OomFault(tls, db) return 1 } @@ -96804,7 +95945,7 @@ func Xsqlite3OpenTempDatabase(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3. return 0 } -var flags int32 = ((((0x00000002 | 0x00000004) | 0x00000010) | 0x00000008) | 0x00000200) /* sqlite3.c:115102:22 */ +var flags int32 = ((((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_DELETEONCLOSE) | SQLITE_OPEN_TEMP_DB) /* sqlite3.c:115102:22 */ // Record the fact that the schema cookie will need to be verified // for database iDb. The code to actually verify the schema cookie @@ -96907,10 +96048,10 @@ func Xsqlite3MayAbort(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:115210:21: * func Xsqlite3HaltConstraint(tls *libc.TLS, pParse uintptr, errCode int32, onError int32, p4 uintptr, p4type I8, p5Errmsg U8) { /* sqlite3.c:115220:21: */ var v uintptr = Xsqlite3GetVdbe(tls, pParse) - if onError == 2 { + if onError == OE_Abort { Xsqlite3MayAbort(tls, pParse) } - Xsqlite3VdbeAddOp4(tls, v, 68, errCode, onError, 0, p4, int32(p4type)) + Xsqlite3VdbeAddOp4(tls, v, OP_Halt, errCode, onError, 0, p4, int32(p4type)) Xsqlite3VdbeChangeP5(tls, v, uint16(p5Errmsg)) } @@ -96926,7 +96067,7 @@ func Xsqlite3UniqueConstraint(tls *libc.TLS, pParse uintptr, onError int32, pIdx var pTab uintptr = (*Index)(unsafe.Pointer(pIdx)).FpTable Xsqlite3StrAccumInit(tls, bp+8 /* &errMsg */, (*Parse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), 0, - *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + uintptr(0)*4))) + *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */)))) if (*Index)(unsafe.Pointer(pIdx)).FaColExpr != 0 { Xsqlite3_str_appendf(tls, bp+8 /* &errMsg */, ts+15685 /* "index '%q'" */, libc.VaList(bp, (*Index)(unsafe.Pointer(pIdx)).FzName)) } else { @@ -96945,12 +96086,12 @@ func Xsqlite3UniqueConstraint(tls *libc.TLS, pParse uintptr, onError int32, pIdx zErr = Xsqlite3StrAccumFinish(tls, bp+8 /* &errMsg */) Xsqlite3HaltConstraint(tls, pParse, func() int32 { - if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2 { - return (19 | (int32(6) << 8)) + if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY { + return (SQLITE_CONSTRAINT | (int32(6) << 8)) } - return (19 | (int32(8) << 8)) + return (SQLITE_CONSTRAINT | (int32(8) << 8)) }(), - onError, zErr, int8(-7), uint8(2)) + onError, zErr, int8(-7), P5_ConstraintUnique) } // Code an OP_Halt due to non-unique rowid. @@ -96963,13 +96104,13 @@ func Xsqlite3RowidConstraint(tls *libc.TLS, pParse uintptr, onError int32, pTab if int32((*Table)(unsafe.Pointer(pTab)).FiPKey) >= 0 { zMsg = Xsqlite3MPrintf(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, ts+9997 /* "%s.%s" */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr((*Table)(unsafe.Pointer(pTab)).FiPKey)*32)).FzName)) - rc = (19 | (int32(6) << 8)) + rc = (SQLITE_CONSTRAINT | (int32(6) << 8)) } else { zMsg = Xsqlite3MPrintf(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, ts+9988 /* "%s.rowid" */, libc.VaList(bp+16, (*Table)(unsafe.Pointer(pTab)).FzName)) - rc = (19 | (int32(10) << 8)) + rc = (SQLITE_CONSTRAINT | (int32(10) << 8)) } Xsqlite3HaltConstraint(tls, pParse, rc, onError, zMsg, int8(-7), - uint8(2)) + P5_ConstraintUnique) } // Check to see if pIndex uses the collating sequence pColl. Return @@ -97064,7 +96205,7 @@ func Xsqlite3Reindex(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintp // Read the database schema. If an error occurs, leave an error message // and code in pParse and return NULL. - if 0 != Xsqlite3ReadSchema(tls, pParse) { + if SQLITE_OK != Xsqlite3ReadSchema(tls, pParse) { return } @@ -97151,7 +96292,7 @@ func Xsqlite3KeyInfoOfIndex(tls *libc.TLS, pParse uintptr, pIdx uintptr) uintptr // the missing index using the collation-needed callback. For // simplicity, SQLite will not give the application a second chance. libc.SetBitFieldPtr16Uint32(pIdx+100 /* &.bNoQuery */, uint32(1), 8, 0x100) - (*Parse)(unsafe.Pointer(pParse)).Frc = (1 | (int32(2) << 8)) + (*Parse)(unsafe.Pointer(pParse)).Frc = (SQLITE_ERROR | (int32(2) << 8)) } Xsqlite3KeyInfoUnref(tls, pKey) pKey = uintptr(0) @@ -97252,8 +96393,8 @@ func callCollNeeded(tls *libc.TLS, db uintptr, enc int32, zName uintptr) { /* sq if (*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded16 != 0 { var zExternal uintptr var pTmp uintptr = Xsqlite3ValueNew(tls, db) - Xsqlite3ValueSetStr(tls, pTmp, -1, zName, uint8(1), uintptr(0)) - zExternal = Xsqlite3ValueText(tls, pTmp, uint8(2)) + Xsqlite3ValueSetStr(tls, pTmp, -1, zName, SQLITE_UTF8, uintptr(0)) + zExternal = Xsqlite3ValueText(tls, pTmp, SQLITE_UTF16LE) if zExternal != 0 { (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr))(unsafe.Pointer((db + 368 /* &.xCollNeeded16 */))))(tls, (*Sqlite3)(unsafe.Pointer(db)).FpCollNeededArg, db, int32((*Sqlite3)(unsafe.Pointer(db)).Fenc), zExternal) } @@ -97275,13 +96416,13 @@ func synthCollSeq(tls *libc.TLS, db uintptr, pColl uintptr) int32 { /* sqlite3.c if (*CollSeq)(unsafe.Pointer(pColl2)).FxCmp != uintptr(0) { libc.Xmemcpy(tls, pColl, pColl2, uint64(unsafe.Sizeof(CollSeq{}))) (*CollSeq)(unsafe.Pointer(pColl)).FxDel = uintptr(0) // Do not copy the destructor - return 0 + return SQLITE_OK } } - return 1 + return SQLITE_ERROR } -var aEnc = [3]U8{U8(3), U8(2), U8(1)} /* sqlite3.c:115598:19 */ +var aEnc = [3]U8{SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8} /* sqlite3.c:115598:19 */ // This routine is called on a collation sequence before it is used to // check that it is defined. An undefined collation sequence exists when @@ -97298,11 +96439,11 @@ func Xsqlite3CheckCollSeq(tls *libc.TLS, pParse uintptr, pColl uintptr) int32 { var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var p uintptr = Xsqlite3GetCollSeq(tls, pParse, (*Sqlite3)(unsafe.Pointer(db)).Fenc, pColl, zName) if !(p != 0) { - return 1 + return SQLITE_ERROR } } - return 0 + return SQLITE_OK } // Locate and return an entry from the db.aCollSeq hash table. If the entry @@ -97325,14 +96466,14 @@ func findCollSeqEntry(tls *libc.TLS, db uintptr, zName uintptr, create int32) ui pColl = Xsqlite3DbMallocZero(tls, db, (uint64((uint64(3) * uint64(unsafe.Sizeof(CollSeq{}))) + uint64(nName)))) if pColl != 0 { var pDel uintptr = uintptr(0) - (*CollSeq)(unsafe.Pointer(pColl + uintptr(0)*40)).FzName = (pColl + uintptr(3)*40) - (*CollSeq)(unsafe.Pointer(pColl + uintptr(0)*40)).Fenc = U8(1) - (*CollSeq)(unsafe.Pointer(pColl + uintptr(1)*40)).FzName = (pColl + uintptr(3)*40) - (*CollSeq)(unsafe.Pointer(pColl + uintptr(1)*40)).Fenc = U8(2) - (*CollSeq)(unsafe.Pointer(pColl + uintptr(2)*40)).FzName = (pColl + uintptr(3)*40) - (*CollSeq)(unsafe.Pointer(pColl + uintptr(2)*40)).Fenc = U8(3) - libc.Xmemcpy(tls, (*CollSeq)(unsafe.Pointer(pColl+uintptr(0)*40)).FzName, zName, uint64(nName)) - pDel = Xsqlite3HashInsert(tls, (db + 600 /* &.aCollSeq */), (*CollSeq)(unsafe.Pointer(pColl+uintptr(0)*40)).FzName, pColl) + (*CollSeq)(unsafe.Pointer(pColl)).FzName = (pColl + 3*40) + (*CollSeq)(unsafe.Pointer(pColl)).Fenc = SQLITE_UTF8 + (*CollSeq)(unsafe.Pointer(pColl + 1*40)).FzName = (pColl + 3*40) + (*CollSeq)(unsafe.Pointer(pColl + 1*40)).Fenc = SQLITE_UTF16LE + (*CollSeq)(unsafe.Pointer(pColl + 2*40)).FzName = (pColl + 3*40) + (*CollSeq)(unsafe.Pointer(pColl + 2*40)).Fenc = SQLITE_UTF16BE + libc.Xmemcpy(tls, (*CollSeq)(unsafe.Pointer(pColl)).FzName, zName, uint64(nName)) + pDel = Xsqlite3HashInsert(tls, (db + 600 /* &.aCollSeq */), (*CollSeq)(unsafe.Pointer(pColl)).FzName, pColl) // If a malloc() failure occurred in sqlite3HashInsert(), it will // return the pColl pointer to be deleted (because it wasn't added @@ -97420,7 +96561,7 @@ func Xsqlite3GetCollSeq(tls *libc.TLS, pParse uintptr, enc U8, pColl uintptr, zN if p == uintptr(0) { Xsqlite3ErrorMsg(tls, pParse, ts+15775 /* "no such collatio..." */, libc.VaList(bp, zName)) - (*Parse)(unsafe.Pointer(pParse)).Frc = (1 | (int32(1) << 8)) + (*Parse)(unsafe.Pointer(pParse)).Frc = (SQLITE_ERROR | (int32(1) << 8)) } return p } @@ -97493,7 +96634,7 @@ func matchQuality(tls *libc.TLS, p uintptr, nArg int32, enc U8) int32 { /* sqlit if (*FuncDef)(unsafe.Pointer(p)).FxSFunc == uintptr(0) { return 0 } - return 6 + return FUNC_PERFECT_MATCH } if int32((*FuncDef)(unsafe.Pointer(p)).FnArg) >= 0 { return 0 @@ -97509,7 +96650,7 @@ func matchQuality(tls *libc.TLS, p uintptr, nArg int32, enc U8) int32 { /* sqlit } // Bonus points if the text encoding matches - if U32(enc) == ((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & U32(0x0003)) { + if U32(enc) == ((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & SQLITE_FUNC_ENCMASK) { match = match + (2) // Exact encoding match } else if ((U32(enc) & (*FuncDef)(unsafe.Pointer(p)).FfuncFlags) & U32(2)) != U32(0) { match = match + (1) // Both are UTF16, but with different byte orders @@ -97537,7 +96678,7 @@ func Xsqlite3InsertBuiltinFuncs(tls *libc.TLS, aDef uintptr, nDef int32) { /* sq var pOther uintptr var zName uintptr = (*FuncDef)(unsafe.Pointer(aDef + uintptr(i)*72)).FzName var nName int32 = Xsqlite3Strlen30(tls, zName) - var h int32 = (((int32(*(*int8)(unsafe.Pointer(zName + uintptr(0))))) + (nName)) % 23) + var h int32 = (((int32(*(*int8)(unsafe.Pointer(zName)))) + (nName)) % SQLITE_FUNC_HASH_SZ) pOther = Xsqlite3FunctionSearch(tls, h, zName) if pOther != 0 { @@ -97600,9 +96741,9 @@ func Xsqlite3FindFunction(tls *libc.TLS, db uintptr, zName uintptr, nArg int32, // have fields overwritten with new information appropriate for the // new function. But the FuncDefs for built-in functions are read-only. // So we must not search for built-ins when creating a new function. - if !(createFlag != 0) && ((pBest == uintptr(0)) || (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0002)) != U32(0))) { + if !(createFlag != 0) && ((pBest == uintptr(0)) || (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_PreferBuiltin) != U32(0))) { bestScore = 0 - h = (((int32(Xsqlite3UpperToLower[U8(*(*int8)(unsafe.Pointer(zName + uintptr(0))))])) + (nName)) % 23) + h = (((int32(Xsqlite3UpperToLower[U8(*(*int8)(unsafe.Pointer(zName)))])) + (nName)) % SQLITE_FUNC_HASH_SZ) p = Xsqlite3FunctionSearch(tls, h, zName) for p != 0 { var score int32 = matchQuality(tls, p, nArg, enc) @@ -97617,13 +96758,13 @@ func Xsqlite3FindFunction(tls *libc.TLS, db uintptr, zName uintptr, nArg int32, // If the createFlag parameter is true and the search did not reveal an // exact match for the name, number of arguments and encoding, then add a // new entry to the hash table and return it. - if ((createFlag != 0) && (bestScore < 6)) && ((libc.AssignUintptr(&pBest, Xsqlite3DbMallocZero(tls, db, (uint64((uint64(unsafe.Sizeof(FuncDef{}))+uint64(nName))+uint64(1)))))) != uintptr(0)) { + if ((createFlag != 0) && (bestScore < FUNC_PERFECT_MATCH)) && ((libc.AssignUintptr(&pBest, Xsqlite3DbMallocZero(tls, db, (uint64((uint64(unsafe.Sizeof(FuncDef{}))+uint64(nName))+uint64(1)))))) != uintptr(0)) { var pOther uintptr var z uintptr - (*FuncDef)(unsafe.Pointer(pBest)).FzName = (pBest + uintptr(1)*72) + (*FuncDef)(unsafe.Pointer(pBest)).FzName = (pBest + 1*72) (*FuncDef)(unsafe.Pointer(pBest)).FnArg = I8(U16(nArg)) (*FuncDef)(unsafe.Pointer(pBest)).FfuncFlags = U32(enc) - libc.Xmemcpy(tls, (pBest + uintptr(1)*72), zName, (uint64(nName + 1))) + libc.Xmemcpy(tls, (pBest + 1*72), zName, (uint64(nName + 1))) for z = (*FuncDef)(unsafe.Pointer(pBest)).FzName; *(*U8)(unsafe.Pointer(z)) != 0; z++ { *(*U8)(unsafe.Pointer(z)) = Xsqlite3UpperToLower[*(*U8)(unsafe.Pointer(z))] } @@ -97676,10 +96817,10 @@ func Xsqlite3SchemaClear(tls *libc.TLS, p uintptr) { /* sqlite3.c:116029:21: */ Xsqlite3HashClear(tls, bp+24 /* &temp1 */) Xsqlite3HashClear(tls, (pSchema + 80 /* &.fkeyHash */)) (*Schema)(unsafe.Pointer(pSchema)).FpSeqTab = uintptr(0) - if (int32((*Schema)(unsafe.Pointer(pSchema)).FschemaFlags) & 0x0001) != 0 { + if (int32((*Schema)(unsafe.Pointer(pSchema)).FschemaFlags) & DB_SchemaLoaded) != 0 { (*Schema)(unsafe.Pointer(pSchema)).FiGeneration++ } - *(*U16)(unsafe.Pointer(pSchema + 114 /* &.schemaFlags */)) &= libc.Uint16FromInt32((^libc.Int32((0x0001 | 0x0008)))) + *(*U16)(unsafe.Pointer(pSchema + 114 /* &.schemaFlags */)) &= libc.Uint16FromInt32((libc.CplInt32((DB_SchemaLoaded | DB_ResetWanted)))) } // Find and return the schema associated with a BTree. Create @@ -97698,7 +96839,7 @@ func Xsqlite3SchemaGet(tls *libc.TLS, db uintptr, pBt uintptr) uintptr { /* sqli Xsqlite3HashInit(tls, (p + 32 /* &.idxHash */)) Xsqlite3HashInit(tls, (p + 56 /* &.trigHash */)) Xsqlite3HashInit(tls, (p + 80 /* &.fkeyHash */)) - (*Schema)(unsafe.Pointer(p)).Fenc = U8(1) + (*Schema)(unsafe.Pointer(p)).Fenc = SQLITE_UTF8 } return p } @@ -97766,11 +96907,11 @@ func tabIsReadOnly(tls *libc.TLS, pParse uintptr, pTab uintptr) int32 { /* sqlit if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { return (libc.Bool32((*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer(Xsqlite3GetVTable(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pTab))).FpMod)).FpModule)).FxUpdate == uintptr(0))) } - if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & (U32(0x0001 | 0x1000))) == U32(0) { + if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & (U32(TF_Readonly | TF_Shadow))) == U32(0) { return 0 } db = (*Parse)(unsafe.Pointer(pParse)).Fdb - if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0001)) != U32(0) { + if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Readonly) != U32(0) { return (libc.Bool32((Xsqlite3WritableSchema(tls, db) == 0) && (int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0))) } @@ -97812,13 +96953,13 @@ func Xsqlite3MaterializeView(tls *libc.TLS, pParse uintptr, pView uintptr, pWher pFrom = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) if pFrom != 0 { - (*SrcList_item)(unsafe.Pointer((pFrom + 8 /* &.a */) + uintptr(0)*112)).FzName = Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pView)).FzName) - (*SrcList_item)(unsafe.Pointer((pFrom + 8 /* &.a */) + uintptr(0)*112)).FzDatabase = Xsqlite3DbStrDup(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) + (*SrcList_item)(unsafe.Pointer((pFrom + 8 /* &.a */))).FzName = Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pView)).FzName) + (*SrcList_item)(unsafe.Pointer((pFrom + 8 /* &.a */))).FzDatabase = Xsqlite3DbStrDup(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) } pSel = Xsqlite3SelectNew(tls, pParse, uintptr(0), pFrom, pWhere, uintptr(0), uintptr(0), pOrderBy, - uint32(0x0020000), pLimit) - Xsqlite3SelectDestInit(tls, bp /* &dest */, 12, iCur) + SF_IncludeHidden, pLimit) + Xsqlite3SelectDestInit(tls, bp /* &dest */, SRT_EphemTab, iCur) Xsqlite3Select(tls, pParse, pSel, bp /* &dest */) Xsqlite3SelectDelete(tls, db, pSel) } @@ -97911,7 +97052,7 @@ __2: // Figure out if we have any triggers and if the table being // deleted from is a view - pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, 126, uintptr(0), uintptr(0)) + pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, TK_DELETE, uintptr(0), uintptr(0)) isView = (libc.Bool32((*Table)(unsafe.Pointer(pTab)).FpSelect != uintptr(0))) bComplex = (libc.Bool32((pTrigger != 0) || (Xsqlite3FkRequired(tls, pParse, pTab, uintptr(0), 0) != 0))) @@ -97936,10 +97077,10 @@ __4: ; iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) - rcauth = Xsqlite3AuthCheck(tls, pParse, 9, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), + rcauth = Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) - if !(rcauth == 1) { + if !(rcauth == SQLITE_DENY) { goto __5 } goto delete_from_cleanup @@ -97948,7 +97089,7 @@ __5: // Assign cursor numbers to the table and all its indices. - iTabCur = libc.AssignPtrInt32((pTabList+8 /* &.a */)+uintptr(0)*112+68 /* &.iCursor */, libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)) + iTabCur = libc.AssignPtrInt32((pTabList+8 /* &.a */)+68 /* &.iCursor */, libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)) nIdx = 0 pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex __6: @@ -98021,7 +97162,7 @@ __13: goto __14 } memCnt = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, memCnt) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, memCnt) __14: ; @@ -98035,7 +97176,7 @@ __14: // the callback returns SQLITE_IGNORE then the DELETE operation proceeds but // the truncate optimization is disabled and all rows are deleted // individually. - if !(((((rcauth == 0) && + if !(((((rcauth == SQLITE_OK) && (pWhere == uintptr(0))) && !(bComplex != 0)) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0)) && @@ -98044,10 +97185,10 @@ __14: } Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, uint8(1), (*Table)(unsafe.Pointer(pTab)).FzName) - if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { goto __17 } - Xsqlite3VdbeAddOp4(tls, v, 137, int32((*Table)(unsafe.Pointer(pTab)).Ftnum), iDb, func() int32 { + Xsqlite3VdbeAddOp4(tls, v, OP_Clear, int32((*Table)(unsafe.Pointer(pTab)).Ftnum), iDb, func() int32 { if memCnt != 0 { return memCnt } @@ -98062,7 +97203,7 @@ __18: goto __20 } - Xsqlite3VdbeAddOp2(tls, v, 137, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) + Xsqlite3VdbeAddOp2(tls, v, OP_Clear, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) goto __19 __19: pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext @@ -98073,8 +97214,8 @@ __20: goto __16 __15: - wcf = (U16((0x0004 | 0x0010) | 0x0400)) - if !(((*NameContext)(unsafe.Pointer(bp+16 /* &sNC */)).FncFlags & 0x00040) != 0) { + wcf = (U16((WHERE_ONEPASS_DESIRED | WHERE_DUPLICATES_OK) | WHERE_SEEK_TABLE)) + if !(((*NameContext)(unsafe.Pointer(bp+16 /* &sNC */)).FncFlags & NC_VarSelect) != 0) { goto __21 } bComplex = 1 @@ -98084,16 +97225,16 @@ __21: if bComplex != 0 { return 0 } - return 0x0008 + return WHERE_ONEPASS_MULTIROW }())) - if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { goto __22 } // For a rowid table, initialize the RowSet to an empty set pPk = uintptr(0) nPk = int16(1) iRowSet = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, iRowSet) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, iRowSet) goto __23 __22: // For a WITHOUT ROWID table, create an ephemeral table used to @@ -98104,7 +97245,7 @@ __22: iPk = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (int32(nPk)) iEphCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - addrEphOpen = Xsqlite3VdbeAddOp2(tls, v, 100, iEphCur, int32(nPk)) + addrEphOpen = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, iEphCur, int32(nPk)) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pPk) __23: ; @@ -98125,7 +97266,7 @@ __24: ; eOnePass = Xsqlite3WhereOkOnePass(tls, pWInfo, bp+72 /* &aiCurOnePass[0] */) - if !(eOnePass != 1) { + if !(eOnePass != ONEPASS_SINGLE) { goto __25 } Xsqlite3MultiWrite(tls, pParse) @@ -98136,7 +97277,7 @@ __25: if !(memCnt != 0) { goto __26 } - Xsqlite3VdbeAddOp2(tls, v, 82, memCnt, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, memCnt, 1) __26: ; @@ -98167,7 +97308,7 @@ __27: __28: ; - if !(eOnePass != 0) { + if !(eOnePass != ONEPASS_OFF) { goto __32 } // For ONEPASS, no need to store the rowid/primary-key. There is only @@ -98184,16 +97325,16 @@ __34: ; libc.Xmemset(tls, aToOpen, 1, (uint64(nIdx + 1))) *(*U8)(unsafe.Pointer(aToOpen + uintptr((nIdx + 1)))) = U8(0) - if !(*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + uintptr(0)*4)) >= 0) { + if !(*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */)) >= 0) { goto __35 } - *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + uintptr(0)*4)) - iTabCur)))) = U8(0) + *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */)) - iTabCur)))) = U8(0) __35: ; - if !(*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + uintptr(1)*4)) >= 0) { + if !(*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + 1*4)) >= 0) { goto __36 } - *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + uintptr(1)*4)) - iTabCur)))) = U8(0) + *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + 1*4)) - iTabCur)))) = U8(0) __36: ; if !(addrEphOpen != 0) { @@ -98210,14 +97351,14 @@ __32: // Add the PK key for this row to the temporary table iKey = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) nKey = int16(0) // Zero tells OP_Found to use a composite key - Xsqlite3VdbeAddOp4(tls, v, 91, iPk, int32(nPk), iKey, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, iPk, int32(nPk), iKey, Xsqlite3IndexAffinityStr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pPk), int32(nPk)) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iEphCur, iKey, iPk, int32(nPk)) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iEphCur, iKey, iPk, int32(nPk)) goto __39 __38: // Add the rowid of the row to be deleted to the RowSet nKey = int16(1) // OP_DeferredSeek always uses a single rowid - Xsqlite3VdbeAddOp2(tls, v, 147, iRowSet, iKey) + Xsqlite3VdbeAddOp2(tls, v, OP_RowSetAdd, iRowSet, iKey) __39: ; __33: @@ -98225,7 +97366,7 @@ __33: // If this DELETE cannot use the ONEPASS strategy, this is the // end of the WHERE loop - if !(eOnePass != 0) { + if !(eOnePass != ONEPASS_OFF) { goto __40 } addrBypass = Xsqlite3VdbeMakeLabel(tls, pParse) @@ -98243,17 +97384,17 @@ __41: goto __42 } iAddrOnce = 0 - if !(eOnePass == 2) { + if !(eOnePass == ONEPASS_MULTI) { goto __43 } - iAddrOnce = Xsqlite3VdbeAddOp0(tls, v, 17) + iAddrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once) __43: ; - Xsqlite3OpenTableAndIndices(tls, pParse, pTab, 97, uint8(0x08), + Xsqlite3OpenTableAndIndices(tls, pParse, pTab, OP_OpenWrite, OPFLAG_FORDELETE, iTabCur, aToOpen, bp+80 /* &iDataCur */, bp+84 /* &iIdxCur */) - if !(eOnePass == 2) { + if !(eOnePass == ONEPASS_MULTI) { goto __44 } Xsqlite3VdbeJumpHereOrPopInst(tls, v, iAddrOnce) @@ -98264,7 +97405,7 @@ __42: // Set up a loop over the rowids/primary-keys that were found in the // where-clause loop above. - if !(eOnePass != 0) { + if !(eOnePass != ONEPASS_OFF) { goto __45 } // OP_Found will use an unpacked key @@ -98272,7 +97413,7 @@ __42: goto __47 } - Xsqlite3VdbeAddOp4Int(tls, v, 29, *(*int32)(unsafe.Pointer(bp + 80 /* iDataCur */)), addrBypass, iKey, int32(nKey)) + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, *(*int32)(unsafe.Pointer(bp + 80 /* iDataCur */)), addrBypass, iKey, int32(nKey)) __47: ; @@ -98281,20 +97422,20 @@ __45: if !(pPk != 0) { goto __48 } - addrLoop = Xsqlite3VdbeAddOp1(tls, v, 37, iEphCur) + addrLoop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, iEphCur) if !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { goto __50 } - Xsqlite3VdbeAddOp3(tls, v, 89, iEphCur, 0, iKey) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEphCur, 0, iKey) goto __51 __50: - Xsqlite3VdbeAddOp2(tls, v, 126, iEphCur, iKey) + Xsqlite3VdbeAddOp2(tls, v, OP_RowData, iEphCur, iKey) __51: ; // OP_Found will use a composite key goto __49 __48: - addrLoop = Xsqlite3VdbeAddOp3(tls, v, 42, iRowSet, 0, iKey) + addrLoop = Xsqlite3VdbeAddOp3(tls, v, OP_RowSetRead, iRowSet, 0, iKey) __49: ; @@ -98309,10 +97450,10 @@ __46: Xsqlite3VtabMakeWritable(tls, pParse, pTab) Xsqlite3MayAbort(tls, pParse) - if !(eOnePass == 1) { + if !(eOnePass == ONEPASS_SINGLE) { goto __54 } - Xsqlite3VdbeAddOp1(tls, v, 116, iTabCur) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iTabCur) if !((*Parse)(unsafe.Pointer((pParse))).FpToplevel == uintptr(0)) { goto __55 } @@ -98321,19 +97462,19 @@ __55: ; __54: ; - Xsqlite3VdbeAddOp4(tls, v, 10, 0, 1, iKey, pVTab, -12) - Xsqlite3VdbeChangeP5(tls, v, uint16(2)) + Xsqlite3VdbeAddOp4(tls, v, OP_VUpdate, 0, 1, iKey, pVTab, -12) + Xsqlite3VdbeChangeP5(tls, v, OE_Abort) goto __53 __52: count = (libc.Bool32(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0)) // True to count changes Xsqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, *(*int32)(unsafe.Pointer(bp + 80 /* iDataCur */)), *(*int32)(unsafe.Pointer(bp + 84 /* iIdxCur */)), - iKey, nKey, uint8(count), uint8(11), uint8(eOnePass), *(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + uintptr(1)*4))) + iKey, nKey, uint8(count), OE_Default, uint8(eOnePass), *(*int32)(unsafe.Pointer(bp + 72 /* &aiCurOnePass[0] */ + 1*4))) __53: ; // End of the loop over all rowids/primary-keys. - if !(eOnePass != 0) { + if !(eOnePass != ONEPASS_OFF) { goto __56 } Xsqlite3VdbeResolveLabel(tls, v, addrBypass) @@ -98343,7 +97484,7 @@ __56: if !(pPk != 0) { goto __58 } - Xsqlite3VdbeAddOp2(tls, v, 5, iEphCur, (addrLoop + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iEphCur, (addrLoop + 1)) Xsqlite3VdbeJumpHere(tls, v, addrLoop) goto __59 __58: @@ -98372,9 +97513,9 @@ __60: if !(memCnt != 0) { goto __61 } - Xsqlite3VdbeAddOp2(tls, v, 80, memCnt, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, memCnt, 1) Xsqlite3VdbeSetNumCols(tls, v, 1) - Xsqlite3VdbeSetColName(tls, v, 0, 0, ts+15873 /* "rows deleted" */, uintptr(0)) + Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, ts+15873 /* "rows deleted" */, uintptr(0)) __61: ; @@ -98441,12 +97582,12 @@ func Xsqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTri // (this can happen if a trigger program has already deleted it), do // not attempt to delete it or fire any DELETE triggers. iLabel = Xsqlite3VdbeMakeLabel(tls, pParse) - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { - opSeek = uint8(32) + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { + opSeek = OP_NotExists } else { - opSeek = uint8(29) + opSeek = OP_NotFound } - if int32(eMode) == 0 { + if int32(eMode) == ONEPASS_OFF { Xsqlite3VdbeAddOp4Int(tls, v, int32(opSeek), iDataCur, iLabel, iPk, int32(nPk)) } @@ -98461,14 +97602,14 @@ func Xsqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTri // TODO: Could use temporary registers here. Also could attempt to // avoid copying the contents of the rowid register. mask = Xsqlite3TriggerColmask(tls, - pParse, pTrigger, uintptr(0), 0, (1 | 2), pTab, int32(onconf)) + pParse, pTrigger, uintptr(0), 0, (TRIGGER_BEFORE | TRIGGER_AFTER), pTab, int32(onconf)) mask = mask | (Xsqlite3FkOldmask(tls, pParse, pTab)) iOld = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (1 + int32((*Table)(unsafe.Pointer(pTab)).FnCol)) // Populate the OLD.* pseudo-table register array. These values will be // used by any BEFORE and AFTER triggers that exist. - Xsqlite3VdbeAddOp2(tls, v, 77, iPk, iOld) + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, iPk, iOld) for iCol = 0; iCol < int32((*Table)(unsafe.Pointer(pTab)).FnCol); iCol++ { if (mask == 0xffffffff) || ((iCol <= 31) && ((mask & (uint32((uint32(1))) << (iCol))) != U32(0))) { @@ -98480,7 +97621,7 @@ func Xsqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTri // Invoke BEFORE DELETE trigger programs. addrStart = Xsqlite3VdbeCurrentAddr(tls, v) Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, - 126, uintptr(0), 1, pTab, iOld, int32(onconf), iLabel) + TK_DELETE, uintptr(0), TRIGGER_BEFORE, pTab, iOld, int32(onconf), iLabel) // If any BEFORE triggers were coded, then seek the cursor to the // row to be deleted again. It may be that the BEFORE triggers moved @@ -98513,23 +97654,23 @@ func Xsqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTri if (*Table)(unsafe.Pointer(pTab)).FpSelect == uintptr(0) { var p5 U8 = U8(0) Xsqlite3GenerateRowIndexDelete(tls, pParse, pTab, iDataCur, iIdxCur, uintptr(0), iIdxNoSeek) - Xsqlite3VdbeAddOp2(tls, v, 122, iDataCur, func() int32 { + Xsqlite3VdbeAddOp2(tls, v, OP_Delete, iDataCur, func() int32 { if count != 0 { - return 0x01 + return OPFLAG_NCHANGE } return 0 }()) if (int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0) || (0 == Xsqlite3_stricmp(tls, (*Table)(unsafe.Pointer(pTab)).FzName, ts+12457 /* "sqlite_stat1" */)) { Xsqlite3VdbeAppendP4(tls, v, pTab, -6) } - if int32(eMode) != 0 { - Xsqlite3VdbeChangeP5(tls, v, uint16(0x04)) + if int32(eMode) != ONEPASS_OFF { + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_AUXDELETE) } if (iIdxNoSeek >= 0) && (iIdxNoSeek != iDataCur) { - Xsqlite3VdbeAddOp1(tls, v, 122, iIdxNoSeek) + Xsqlite3VdbeAddOp1(tls, v, OP_Delete, iIdxNoSeek) } - if int32(eMode) == 2 { - p5 = U8(int32(p5) | (0x02)) + if int32(eMode) == ONEPASS_MULTI { + p5 = U8(int32(p5) | (OPFLAG_SAVEPOSITION)) } Xsqlite3VdbeChangeP5(tls, v, uint16(p5)) } @@ -98541,7 +97682,7 @@ func Xsqlite3GenerateRowDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, pTri // Invoke AFTER DELETE trigger programs. Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, - 126, uintptr(0), 2, pTab, iOld, int32(onconf), iLabel) + TK_DELETE, uintptr(0), TRIGGER_AFTER, pTab, iOld, int32(onconf), iLabel) // Jump here if the row had already been deleted before any BEFORE // trigger programs were invoked. Or if a trigger program throws a @@ -98580,7 +97721,7 @@ func Xsqlite3GenerateRowIndexDelete(tls *libc.TLS, pParse uintptr, pTab uintptr, var pPk uintptr // PRIMARY KEY index, or NULL for rowid tables v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { pPk = uintptr(0) } else { pPk = Xsqlite3PrimaryKeyIndex(tls, pTab) @@ -98605,7 +97746,7 @@ __1: r1 = Xsqlite3GenerateIndexKey(tls, pParse, pIdx, iDataCur, 0, 1, bp /* &iPartIdxLabel */, pPrior, r1) - Xsqlite3VdbeAddOp3(tls, v, 132, (iIdxCur + i), r1, + Xsqlite3VdbeAddOp3(tls, v, OP_IdxDelete, (iIdxCur + i), r1, func() int32 { if (uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 100 /* &.uniqNotNull */)) & 0x8 >> 3))) != 0 { return int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) @@ -98666,7 +97807,7 @@ func Xsqlite3GenerateIndexKey(tls *libc.TLS, pParse uintptr, pIdx uintptr, iData *(*int32)(unsafe.Pointer(piPartIdxLabel)) = Xsqlite3VdbeMakeLabel(tls, pParse) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = (iDataCur + 1) Xsqlite3ExprIfFalseDup(tls, pParse, (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere, *(*int32)(unsafe.Pointer(piPartIdxLabel)), - 0x10) + SQLITE_JUMPIFNULL) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0 pPrior = uintptr(0) // Ticket a9efb42811fa41ee 2019-11-02; // pPartIdxWhere may have corrupted regPrior registers @@ -98697,13 +97838,13 @@ func Xsqlite3GenerateIndexKey(tls *libc.TLS, pParse uintptr, pIdx uintptr, iData // But we are getting ready to store this value back into an index, where // it should be converted by to INTEGER again. So omit the OP_RealAffinity // opcode if it is present - Xsqlite3VdbeDeletePriorOpcode(tls, v, uint8(83)) + Xsqlite3VdbeDeletePriorOpcode(tls, v, OP_RealAffinity) } if regOut != 0 { - Xsqlite3VdbeAddOp3(tls, v, 91, regBase, nCol, regOut) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regBase, nCol, regOut) if (*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FpSelect != 0 { var zAff uintptr = Xsqlite3IndexAffinityStr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pIdx) - Xsqlite3VdbeChangeP4(tls, v, -1, zAff, 0) + Xsqlite3VdbeChangeP4(tls, v, -1, zAff, P4_TRANSIENT) } } Xsqlite3ReleaseTempRange(tls, pParse, regBase, nCol) @@ -98772,11 +97913,11 @@ func minmaxFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s pColl = sqlite3GetFuncCollSeq(tls, context) iBest = 0 - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } for i = 1; i < argc; i++ { - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) == 5 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) == SQLITE_NULL { return } if (Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(iBest)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), pColl) ^ mask) >= 0 { @@ -98789,7 +97930,7 @@ func minmaxFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s // Return the type of the argument. func typeofFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { /* sqlite3.c:117129:13: */ - var i int32 = (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - 1) + var i int32 = (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) - 1) _ = NotUsed // EVIDENCE-OF: R-01470-60482 The sqlite3_value_type(V) interface returns @@ -98805,20 +97946,20 @@ var azType2 = [5]uintptr{ts + 7853 /* "integer" */, ts + 7848 /* "real" */, ts + func lengthFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:117154:13: */ _ = argc - switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) { - case 4: + switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) { + case SQLITE_BLOB: fallthrough - case 1: + case SQLITE_INTEGER: fallthrough - case 2: + case SQLITE_FLOAT: { - Xsqlite3_result_int(tls, context, Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + Xsqlite3_result_int(tls, context, Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) break } - case 3: + case SQLITE_TEXT: { - var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) var z0 uintptr var c uint8 if z == uintptr(0) { @@ -98854,10 +97995,10 @@ func lengthFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s func absFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:117196:13: */ _ = argc - switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) { - case 1: + switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) { + case SQLITE_INTEGER: { - var iVal I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var iVal I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) if iVal < int64(0) { if iVal == ((int64(-1)) - (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))) { // IMP: R-31676-45509 If X is the integer -9223372036854775808 @@ -98872,7 +98013,7 @@ func absFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli break } - case 5: + case SQLITE_NULL: { // IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. Xsqlite3_result_null(tls, context) @@ -98885,7 +98026,7 @@ func absFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli // something that can be converted into a number, we have: // IMP: R-01992-00519 Abs(X) returns 0.0 if X is a string or blob // that cannot be converted to a numeric value. - var rVal float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var rVal float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) if rVal < float64(0) { rVal = -rVal } @@ -98922,36 +98063,36 @@ func instrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq pC2 = uintptr(0) _ = argc - typeHaystack = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - typeNeedle = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - if !((typeHaystack == 5) || (typeNeedle == 5)) { + typeHaystack = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) + typeNeedle = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + if !((typeHaystack == SQLITE_NULL) || (typeNeedle == SQLITE_NULL)) { goto __1 } return __1: ; - nHaystack = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - nNeedle = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + nHaystack = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + nNeedle = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if !(nNeedle > 0) { goto __2 } - if !((typeHaystack == 4) && (typeNeedle == 4)) { + if !((typeHaystack == SQLITE_BLOB) && (typeNeedle == SQLITE_BLOB)) { goto __3 } - zHaystack = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zNeedle = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zHaystack = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) + zNeedle = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) isText = 0 goto __4 __3: - if !((typeHaystack != 4) && (typeNeedle != 4)) { + if !((typeHaystack != SQLITE_BLOB) && (typeNeedle != SQLITE_BLOB)) { goto __5 } - zHaystack = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zNeedle = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zHaystack = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + zNeedle = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) isText = 1 goto __6 __5: - pC1 = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + pC1 = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(argv))) zHaystack = Xsqlite3_value_text(tls, pC1) if !(zHaystack == uintptr(0)) { goto __7 @@ -98960,7 +98101,7 @@ __5: __7: ; nHaystack = Xsqlite3_value_bytes(tls, pC1) - pC2 = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + pC2 = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) zNeedle = Xsqlite3_value_text(tls, pC2) if !(zNeedle == uintptr(0)) { goto __8 @@ -98980,10 +98121,10 @@ __4: goto endInstrOOM __9: ; - firstChar = *(*uint8)(unsafe.Pointer(zNeedle + uintptr(0))) + firstChar = *(*uint8)(unsafe.Pointer(zNeedle)) __10: if !((nNeedle <= nHaystack) && - ((int32(*(*uint8)(unsafe.Pointer(zHaystack + uintptr(0)))) != int32(firstChar)) || (libc.Xmemcmp(tls, zHaystack, zNeedle, uint64(nNeedle)) != 0))) { + ((int32(*(*uint8)(unsafe.Pointer(zHaystack))) != int32(firstChar)) || (libc.Xmemcmp(tls, zHaystack, zNeedle, uint64(nNeedle)) != 0))) { goto __11 } N++ @@ -98992,7 +98133,7 @@ __12: zHaystack++ goto __13 __13: - if (isText != 0) && ((int32(*(*uint8)(unsafe.Pointer(zHaystack + uintptr(0)))) & 0xc0) == 0x80) { + if (isText != 0) && ((int32(*(*uint8)(unsafe.Pointer(zHaystack))) & 0xc0) == 0x80) { goto __12 } goto __14 @@ -99032,12 +98173,12 @@ func printfFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s var n int32 var db uintptr = Xsqlite3_context_db_handle(tls, context) - if (argc >= 1) && ((libc.AssignUintptr(&zFormat, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) != uintptr(0)) { + if (argc >= 1) && ((libc.AssignUintptr(&zFormat, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))))) != uintptr(0)) { (*PrintfArguments)(unsafe.Pointer(bp + 40 /* &x */)).FnArg = (argc - 1) (*PrintfArguments)(unsafe.Pointer(bp + 40 /* &x */)).FnUsed = 0 (*PrintfArguments)(unsafe.Pointer(bp + 40 /* &x */)).FapArg = (argv + uintptr(1)*8) - Xsqlite3StrAccumInit(tls, bp+8 /* &str */, db, uintptr(0), 0, *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) - (*StrAccum)(unsafe.Pointer(bp + 8 /* &str */)).FprintfFlags = U8(0x02) + Xsqlite3StrAccumInit(tls, bp+8 /* &str */, db, uintptr(0), 0, *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) + (*StrAccum)(unsafe.Pointer(bp + 8 /* &str */)).FprintfFlags = SQLITE_PRINTF_SQLFUNC Xsqlite3_str_appendf(tls, bp+8 /* &str */, zFormat, libc.VaList(bp, bp+40 /* &x */)) n = int32((*StrAccum)(unsafe.Pointer(bp + 8 /* &str */)).FnChar) Xsqlite3_result_text(tls, context, Xsqlite3StrAccumFinish(tls, bp+8 /* &str */), n, @@ -99064,21 +98205,21 @@ func substrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s var p2 I64 var negP2 int32 = 0 - if (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) == 5) || - ((argc == 3) && (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) == 5)) { + if (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) == SQLITE_NULL) || + ((argc == 3) && (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) == SQLITE_NULL)) { return } - p0type = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - p1 = I64(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) - if p0type == 4 { - len = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - z = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + p0type = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) + p1 = I64(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) + if p0type == SQLITE_BLOB { + len = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + z = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) if z == uintptr(0) { return } } else { - z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if z == uintptr(0) { return } @@ -99097,13 +98238,13 @@ func substrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s } } if argc == 3 { - p2 = I64(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + p2 = I64(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) if p2 < int64(0) { p2 = -p2 negP2 = 1 } } else { - p2 = I64(*(*int32)(unsafe.Pointer((Xsqlite3_context_db_handle(tls, context) + 124 /* &.aLimit */) + uintptr(0)*4))) + p2 = I64(*(*int32)(unsafe.Pointer((Xsqlite3_context_db_handle(tls, context) + 124 /* &.aLimit */)))) } if p1 < int64(0) { p1 = p1 + (I64(len)) @@ -99127,7 +98268,7 @@ func substrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s } } - if p0type != 4 { + if p0type != SQLITE_BLOB { for (*(*uint8)(unsafe.Pointer(z)) != 0) && (p1 != 0) { { if (int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))) >= 0xc0 { @@ -99150,7 +98291,7 @@ func substrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s } Xsqlite3_result_text64(tls, context, z, (uint64((int64(z2) - int64(z)) / 1)), libc.UintptrFromInt32(-1), - uint8(1)) + SQLITE_UTF8) } else { if (p1 + p2) > I64(len) { p2 = (I64(len) - p1) @@ -99173,10 +98314,10 @@ func roundFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq var zBuf uintptr if argc == 2 { - if 5 == Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) { + if SQLITE_NULL == Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) { return } - n = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + n = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if n > 30 { n = 30 } @@ -99184,10 +98325,10 @@ func roundFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq n = 0 } } - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } - *(*float64)(unsafe.Pointer(bp + 16 /* r */)) = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + *(*float64)(unsafe.Pointer(bp + 16 /* r */)) = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) // If Y==0 and X will fit in a 64-bit int, // handle the rounding directly, // otherwise use printf. @@ -99206,7 +98347,7 @@ func roundFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq Xsqlite3_result_error_nomem(tls, context) return } - Xsqlite3AtoF(tls, zBuf, bp+16 /* &r */, Xsqlite3Strlen30(tls, zBuf), uint8(1)) + Xsqlite3AtoF(tls, zBuf, bp+16 /* &r */, Xsqlite3Strlen30(tls, zBuf), SQLITE_UTF8) Xsqlite3_free(tls, zBuf) } Xsqlite3_result_double(tls, context, *(*float64)(unsafe.Pointer(bp + 16 /* r */))) @@ -99221,7 +98362,7 @@ func contextMalloc(tls *libc.TLS, context uintptr, nByte I64) uintptr { /* sqlit var z uintptr var db uintptr = Xsqlite3_context_db_handle(tls, context) - if nByte > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) { + if nByte > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) { Xsqlite3_result_error_toobig(tls, context) z = uintptr(0) } else { @@ -99240,8 +98381,8 @@ func upperFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq var i int32 var n int32 _ = argc - z2 = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + z2 = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) // Verify that the call to _bytes() does not invalidate the _text() pointer if z2 != 0 { @@ -99261,8 +98402,8 @@ func lowerFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq var i int32 var n int32 _ = argc - z2 = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + z2 = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) // Verify that the call to _bytes() does not invalidate the _text() pointer if z2 != 0 { @@ -99313,7 +98454,7 @@ func randomBlob(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s var p uintptr _ = argc - n = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + n = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) if n < int64(1) { n = int64(1) } @@ -99372,25 +98513,13 @@ type compareInfo = struct { // macro for fast reading of the next character in the common case where // the next character is ASCII. -var globInfo = compareInfo{ - FmatchAll: U8('*'), - FmatchOne: U8('?'), - FmatchSet: U8('['), - FnoCase: U8(0)} /* sqlite3.c:117677:33 */ +var globInfo = compareInfo{FmatchAll: U8('*'), FmatchOne: U8('?'), FmatchSet: U8('[')} /* sqlite3.c:117677:33 */ // The correct SQL-92 behavior is for the LIKE operator to ignore // case. Thus 'a' LIKE 'A' would be true. -var likeInfoNorm = compareInfo{ - FmatchAll: U8('%'), - FmatchOne: U8('_'), - FmatchSet: U8(0), - FnoCase: U8(1)} /* sqlite3.c:117680:33 */ +var likeInfoNorm = compareInfo{FmatchAll: U8('%'), FmatchOne: U8('_'), FnoCase: U8(1)} /* sqlite3.c:117680:33 */ // If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator // is case sensitive causing 'a' LIKE 'A' to be false -var likeInfoAlt = compareInfo{ - FmatchAll: U8('%'), - FmatchOne: U8('_'), - FmatchSet: U8(0), - FnoCase: U8(0)} /* sqlite3.c:117683:33 */ +var likeInfoAlt = compareInfo{FmatchAll: U8('%'), FmatchOne: U8('_')} /* sqlite3.c:117683:33 */ // Possible error returns from patternMatch() @@ -99444,7 +98573,7 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint var zEscaped uintptr = uintptr(0) // One past the last escaped input char for (libc.AssignUint32(&c, func() uint32 { - if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */)) + uintptr(0)))) < 0x80 { + if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */))))) < 0x80 { return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp /* zPattern */)), 1)))) } return Xsqlite3Utf8Read(tls, bp /* &zPattern */) @@ -99454,22 +98583,22 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint // are also "?" characters, skip those as well, but consume a // single character of the input string for each "?" skipped for ((libc.AssignUint32(&c, func() uint32 { - if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */)) + uintptr(0)))) < 0x80 { + if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */))))) < 0x80 { return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp /* zPattern */)), 1)))) } return Xsqlite3Utf8Read(tls, bp /* &zPattern */) }())) == matchAll) || (c == matchOne) { if (c == matchOne) && (Xsqlite3Utf8Read(tls, bp+8 /* &zString */) == U32(0)) { - return 2 + return SQLITE_NOWILDCARDMATCH } } if c == U32(0) { - return 0 // "*" at the end of the pattern matches + return SQLITE_MATCH // "*" at the end of the pattern matches } else if c == matchOther { if int32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchSet) == 0 { c = Xsqlite3Utf8Read(tls, bp /* &zPattern */) if c == U32(0) { - return 2 + return SQLITE_NOWILDCARDMATCH } } else { // "[...]" immediately follows the "*". We have to do a slow @@ -99477,7 +98606,7 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint // '[' is a single-byte character for *(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)))) != 0 { var bMatch int32 = patternCompare(tls, (*(*uintptr)(unsafe.Pointer(bp /* zPattern */)) + libc.UintptrFromInt32(-1)), *(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)), pInfo, matchOther) - if bMatch != 1 { + if bMatch != SQLITE_NOMATCH { return bMatch } { @@ -99489,7 +98618,7 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint } } - return 2 + return SQLITE_NOWILDCARDMATCH } } @@ -99506,28 +98635,28 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint var bMatch int32 if noCase != 0 { - *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + uintptr(0))) = (int8((c) & U32(^(int32(Xsqlite3CtypeMap[uint8(c)]) & 0x20)))) - *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + uintptr(1))) = int8(Xsqlite3UpperToLower[uint8(c)]) - *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + uintptr(2))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */)) = (int8((c) & U32(^(int32(Xsqlite3CtypeMap[uint8(c)]) & 0x20)))) + *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + 1)) = int8(Xsqlite3UpperToLower[uint8(c)]) + *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + 2)) = int8(0) } else { - *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + uintptr(0))) = int8(c) - *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + uintptr(1))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */)) = int8(c) + *(*int8)(unsafe.Pointer(bp + 16 /* &zStop[0] */ + 1)) = int8(0) } for 1 != 0 { *(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)) += uintptr(libc.Xstrcspn(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)), bp+16 /* &zStop[0] */)) - if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)) + uintptr(0)))) == 0 { + if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */))))) == 0 { break } *(*uintptr)(unsafe.Pointer(bp + 8 /* zString */))++ bMatch = patternCompare(tls, *(*uintptr)(unsafe.Pointer(bp /* zPattern */)), *(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)), pInfo, matchOther) - if bMatch != 1 { + if bMatch != SQLITE_NOMATCH { return bMatch } } } else { var bMatch int32 for (libc.AssignUint32(&c2, func() uint32 { - if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)) + uintptr(0)))) < 0x80 { + if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */))))) < 0x80 { return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)), 1)))) } return Xsqlite3Utf8Read(tls, bp+8 /* &zString */) @@ -99536,18 +98665,18 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint continue } bMatch = patternCompare(tls, *(*uintptr)(unsafe.Pointer(bp /* zPattern */)), *(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)), pInfo, matchOther) - if bMatch != 1 { + if bMatch != SQLITE_NOMATCH { return bMatch } } } - return 2 + return SQLITE_NOWILDCARDMATCH } if c == matchOther { if int32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchSet) == 0 { c = Xsqlite3Utf8Read(tls, bp /* &zPattern */) if c == U32(0) { - return 1 + return SQLITE_NOMATCH } zEscaped = *(*uintptr)(unsafe.Pointer(bp /* zPattern */)) } else { @@ -99556,7 +98685,7 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint var invert int32 = 0 c = Xsqlite3Utf8Read(tls, bp+8 /* &zString */) if c == U32(0) { - return 1 + return SQLITE_NOMATCH } c2 = Xsqlite3Utf8Read(tls, bp /* &zPattern */) if c2 == U32('^') { @@ -99570,7 +98699,7 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint c2 = Xsqlite3Utf8Read(tls, bp /* &zPattern */) } for (c2 != 0) && (c2 != U32(']')) { - if (((c2 == U32('-')) && (int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */)) + uintptr(0)))) != ']')) && (int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */)) + uintptr(0)))) != 0)) && (prior_c > U32(0)) { + if (((c2 == U32('-')) && (int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */))))) != ']')) && (int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zPattern */))))) != 0)) && (prior_c > U32(0)) { c2 = Xsqlite3Utf8Read(tls, bp /* &zPattern */) if (c >= prior_c) && (c <= c2) { seen = 1 @@ -99585,13 +98714,13 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint c2 = Xsqlite3Utf8Read(tls, bp /* &zPattern */) } if (c2 == U32(0)) || ((seen ^ invert) == 0) { - return 1 + return SQLITE_NOMATCH } continue } } c2 = func() uint32 { - if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)) + uintptr(0)))) < 0x80 { + if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */))))) < 0x80 { return uint32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */)), 1)))) } return Xsqlite3Utf8Read(tls, bp+8 /* &zString */) @@ -99605,12 +98734,12 @@ func patternCompare(tls *libc.TLS, zPattern uintptr, zString uintptr, pInfo uint if ((c == matchOne) && (*(*uintptr)(unsafe.Pointer(bp /* zPattern */)) != zEscaped)) && (c2 != U32(0)) { continue } - return 1 + return SQLITE_NOMATCH } if int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zString */))))) == 0 { - return 0 + return SQLITE_MATCH } - return 1 + return SQLITE_NOMATCH } // The sqlite3_strglob() interface. Return 0 on a match (like strcmp()) and @@ -99652,8 +98781,8 @@ func likeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql var pInfo uintptr = Xsqlite3_user_data(tls, context) // var backupInfo compareInfo at bp+8, 4 - if (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 4) || - (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) == 4) { + if (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_BLOB) || + (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) == SQLITE_BLOB) { Xsqlite3_like_count++ Xsqlite3_result_int(tls, context, 0) return @@ -99661,16 +98790,16 @@ func likeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql // Limit the length of the LIKE or GLOB pattern to avoid problems // of deep recursion and N*N behavior in patternCompare(). - nPat = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + nPat = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) - if nPat > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(8)*4)) { + if nPat > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 8*4)) { Xsqlite3_result_error(tls, context, ts+15918 /* "LIKE or GLOB pat..." */, -1) return } if argc == 3 { // The escape character string must consist of a single UTF-8 character. // Otherwise, return an error. - *(*uintptr)(unsafe.Pointer(bp /* zEsc */)) = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + *(*uintptr)(unsafe.Pointer(bp /* zEsc */)) = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) if *(*uintptr)(unsafe.Pointer(bp /* zEsc */)) == uintptr(0) { return } @@ -99693,12 +98822,12 @@ func likeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql } else { escape = U32((*compareInfo)(unsafe.Pointer(pInfo)).FmatchSet) } - zB = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - zA = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zB = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + zA = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if (zA != 0) && (zB != 0) { Xsqlite3_like_count++ Xsqlite3_result_int(tls, context, - (libc.Bool32(patternCompare(tls, zB, zA, pInfo, escape) == 0))) + (libc.Bool32(patternCompare(tls, zB, zA, pInfo, escape) == SQLITE_MATCH))) } } @@ -99708,8 +98837,8 @@ func likeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql func nullifFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { /* sqlite3.c:117967:13: */ var pColl uintptr = sqlite3GetFuncCollSeq(tls, context) _ = NotUsed - if Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), pColl) != 0 { - Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + if Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(argv)), *(*uintptr)(unsafe.Pointer(argv + 1*8)), pColl) != 0 { + Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv))) } } @@ -99743,7 +98872,7 @@ func errlogFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s _ = argc _ = context - Xsqlite3_log(tls, Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))), ts+824 /* "%s" */, libc.VaList(bp, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))))) + Xsqlite3_log(tls, Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))), ts+824 /* "%s" */, libc.VaList(bp, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))))) } // Implementation of the sqlite_compileoption_used() function. @@ -99756,7 +98885,7 @@ func compileoptionusedFunc(tls *libc.TLS, context uintptr, argc int32, argv uint // IMP: R-39564-36305 The sqlite_compileoption_used() SQL // function is a wrapper around the sqlite3_compileoption_used() C/C++ // function. - if (libc.AssignUintptr(&zOptName, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) != uintptr(0) { + if (libc.AssignUintptr(&zOptName, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))))) != uintptr(0) { Xsqlite3_result_int(tls, context, Xsqlite3_compileoption_used(tls, zOptName)) } } @@ -99770,7 +98899,7 @@ func compileoptiongetFunc(tls *libc.TLS, context uintptr, argc int32, argv uintp _ = argc // IMP: R-04922-24076 The sqlite_compileoption_get() SQL function // is a wrapper around the sqlite3_compileoption_get() C/C++ function. - n = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + n = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) Xsqlite3_result_text(tls, context, Xsqlite3_compileoption_get(tls, n), -1, uintptr(0)) } @@ -99791,17 +98920,17 @@ func quoteFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq defer tls.Free(80) _ = argc - switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) { - case 2: + switch Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) { + case SQLITE_FLOAT: { var r1 float64 // var r2 float64 at bp+72, 8 // var zBuf [50]int8 at bp+16, 50 - r1 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + r1 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+16 /* &zBuf[0] */, ts+6578 /* "%!.15g" */, libc.VaList(bp, r1)) - Xsqlite3AtoF(tls, bp+16 /* &zBuf[0] */, bp+72 /* &r2 */, 20, uint8(1)) + Xsqlite3AtoF(tls, bp+16 /* &zBuf[0] */, bp+72 /* &r2 */, 20, SQLITE_UTF8) if r1 != *(*float64)(unsafe.Pointer(bp + 72 /* r2 */)) { Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+16 /* &zBuf[0] */, ts+15996 /* "%!.20e" */, libc.VaList(bp+8, r1)) } @@ -99809,17 +98938,17 @@ func quoteFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq break } - case 1: + case SQLITE_INTEGER: { - Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv))) break } - case 4: + case SQLITE_BLOB: { var zText uintptr = uintptr(0) - var zBlob uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var nBlob int32 = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zBlob uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) + var nBlob int32 = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) // No encoding change zText = contextMalloc(tls, context, ((int64(2) * I64(nBlob)) + int64(4))) if zText != 0 { @@ -99830,20 +98959,20 @@ func quoteFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq } *(*int8)(unsafe.Pointer(zText + uintptr(((nBlob * 2) + 2)))) = int8('\'') *(*int8)(unsafe.Pointer(zText + uintptr(((nBlob * 2) + 3)))) = int8(0) - *(*int8)(unsafe.Pointer(zText + uintptr(0))) = int8('X') - *(*int8)(unsafe.Pointer(zText + uintptr(1))) = int8('\'') + *(*int8)(unsafe.Pointer(zText)) = int8('X') + *(*int8)(unsafe.Pointer(zText + 1)) = int8('\'') Xsqlite3_result_text(tls, context, zText, -1, libc.UintptrFromInt32(-1)) Xsqlite3_free(tls, zText) } break } - case 3: + case SQLITE_TEXT: { var i int32 var j int32 var n U64 - var zArg uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zArg uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) var z uintptr if zArg == uintptr(0) { @@ -99858,7 +98987,7 @@ func quoteFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sq } z = contextMalloc(tls, context, (((I64(i)) + (I64(n))) + int64(3))) if z != 0 { - *(*int8)(unsafe.Pointer(z + uintptr(0))) = int8('\'') + *(*int8)(unsafe.Pointer(z)) = int8('\'') i = 0 j = 1 for ; *(*uint8)(unsafe.Pointer(zArg + uintptr(i))) != 0; i++ { @@ -99890,9 +99019,9 @@ func unicodeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* bp := tls.Alloc(8) defer tls.Free(8) - *(*uintptr)(unsafe.Pointer(bp /* z */)) = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + *(*uintptr)(unsafe.Pointer(bp /* z */)) = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) _ = argc - if (*(*uintptr)(unsafe.Pointer(bp /* z */)) != 0) && (*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* z */)) + uintptr(0))) != 0) { + if (*(*uintptr)(unsafe.Pointer(bp /* z */)) != 0) && (*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* z */)))) != 0) { Xsqlite3_result_int(tls, context, int32(Xsqlite3Utf8Read(tls, bp /* &z */))) } } @@ -99933,7 +99062,7 @@ func charFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql *(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = (uint8(0x80 + int32((U8(c & uint32(0x3F)))))) } } - Xsqlite3_result_text64(tls, context, z, (uint64((int64(zOut) - int64(z)) / 1)), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})), uint8(1)) + Xsqlite3_result_text64(tls, context, z, (uint64((int64(zOut) - int64(z)) / 1)), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})), SQLITE_UTF8) } // The hex() function. Interpret the argument as a blob. Return @@ -99946,8 +99075,8 @@ func hexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli var z uintptr _ = argc - pBlob = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + pBlob = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) + n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) // No encoding change z = libc.AssignUintptr(&zHex, contextMalloc(tls, context, (((I64(n))*int64(2))+int64(1)))) if zHex != 0 { @@ -99981,7 +99110,7 @@ func zeroblobFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* var rc int32 _ = argc - n = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + n = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) if n < int64(0) { n = int64(0) } @@ -100011,29 +99140,29 @@ func replaceFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* var db uintptr = Xsqlite3_context_db_handle(tls, context) _ = argc - zStr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zStr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zStr == uintptr(0) { return } - nStr = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + nStr = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) // No encoding change - zPattern = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zPattern = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if zPattern == uintptr(0) { return } - if int32(*(*uint8)(unsafe.Pointer(zPattern + uintptr(0)))) == 0 { + if int32(*(*uint8)(unsafe.Pointer(zPattern))) == 0 { - Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv))) return } - nPattern = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + nPattern = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) // No encoding change - zRep = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + zRep = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) if zRep == uintptr(0) { return } - nRep = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + nRep = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) nOut = (I64(nStr + 1)) @@ -100044,13 +99173,13 @@ func replaceFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* loopLimit = (nStr - nPattern) cntExpand = uint32(0) for i = libc.AssignInt32(&j, 0); i <= loopLimit; i++ { - if (int32(*(*uint8)(unsafe.Pointer(zStr + uintptr(i)))) != int32(*(*uint8)(unsafe.Pointer(zPattern + uintptr(0))))) || (libc.Xmemcmp(tls, (zStr+uintptr(i)), zPattern, uint64(nPattern)) != 0) { + if (int32(*(*uint8)(unsafe.Pointer(zStr + uintptr(i)))) != int32(*(*uint8)(unsafe.Pointer(zPattern)))) || (libc.Xmemcmp(tls, (zStr+uintptr(i)), zPattern, uint64(nPattern)) != 0) { *(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&j, 1)))) = *(*uint8)(unsafe.Pointer(zStr + uintptr(i))) } else { if nRep > nPattern { nOut = nOut + (I64(nRep - nPattern)) - if (nOut - int64(1)) > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) { + if (nOut - int64(1)) > I64(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) { Xsqlite3_result_error_toobig(tls, context) Xsqlite3_free(tls, zOut) return @@ -100094,21 +99223,21 @@ func trimFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sql var azChar uintptr = uintptr(0) // Individual characters in zCharSet var nChar int32 // Number of characters in zCharSet - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } - zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zIn == uintptr(0) { return } - nIn = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + nIn = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) if argc == 1 { nChar = 1 aLen = uintptr(uintptr(unsafe.Pointer(&lenOne))) azChar = uintptr(uintptr(unsafe.Pointer(&azOne))) zCharSet = uintptr(0) - } else if (libc.AssignUintptr(&zCharSet, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))))) == uintptr(0) { + } else if (libc.AssignUintptr(&zCharSet, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))))) == uintptr(0) { return } else { var z uintptr @@ -100206,7 +99335,7 @@ func soundexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* var i int32 var j int32 - zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zIn == uintptr(0) { zIn = ts + 800 /* "" */ } @@ -100214,7 +99343,7 @@ func soundexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* } if *(*U8)(unsafe.Pointer(zIn + uintptr(i))) != 0 { var prevcode U8 = iCode[(int32(*(*U8)(unsafe.Pointer(zIn + uintptr(i)))) & 0x7f)] - *(*int8)(unsafe.Pointer(bp /* &zResult[0] */ + uintptr(0))) = (int8((int32(*(*U8)(unsafe.Pointer(zIn + uintptr(i))))) & ^(int32(Xsqlite3CtypeMap[*(*U8)(unsafe.Pointer(zIn + uintptr(i)))]) & 0x20))) + *(*int8)(unsafe.Pointer(bp /* &zResult[0] */)) = (int8((int32(*(*U8)(unsafe.Pointer(zIn + uintptr(i))))) & ^(int32(Xsqlite3CtypeMap[*(*U8)(unsafe.Pointer(zIn + uintptr(i)))]) & 0x20))) for j = 1; (j < 4) && (*(*U8)(unsafe.Pointer(zIn + uintptr(i))) != 0); i++ { var code int32 = int32(iCode[(int32(*(*U8)(unsafe.Pointer(zIn + uintptr(i)))) & 0x7f)]) if code > 0 { @@ -100254,20 +99383,20 @@ func loadExt(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli bp := tls.Alloc(8) defer tls.Free(8) - var zFile uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zFile uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) var zProc uintptr var db uintptr = Xsqlite3_context_db_handle(tls, context) *(*uintptr)(unsafe.Pointer(bp /* zErrMsg */)) = uintptr(0) // Disallow the load_extension() SQL function unless the SQLITE_LoadExtFunc // flag is set. See the sqlite3_enable_load_extension() API. - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00020000)) == uint64(0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_LoadExtFunc) == uint64(0) { Xsqlite3_result_error(tls, context, ts+13234 /* "not authorized" */, -1) return } if argc == 2 { - zProc = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zProc = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) } else { zProc = uintptr(0) } @@ -100306,17 +99435,17 @@ func sumStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqli _ = argc p = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(SumCtx{}))) - type1 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - if (p != 0) && (type1 != 5) { + type1 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv))) + if (p != 0) && (type1 != SQLITE_NULL) { (*SumCtx)(unsafe.Pointer(p)).Fcnt++ - if type1 == 1 { - var v I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + if type1 == SQLITE_INTEGER { + var v I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) *(*float64)(unsafe.Pointer(p /* &.rSum */)) += (float64(v)) if ((int32((*SumCtx)(unsafe.Pointer(p)).Fapprox) | int32((*SumCtx)(unsafe.Pointer(p)).Foverflow)) == 0) && (Xsqlite3AddInt64(tls, (p+8 /* &.iSum */), v) != 0) { (*SumCtx)(unsafe.Pointer(p)).Fapprox = libc.AssignPtrUint8(p+24 /* &.overflow */, U8(1)) } } else { - *(*float64)(unsafe.Pointer(p /* &.rSum */)) += (Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + *(*float64)(unsafe.Pointer(p /* &.rSum */)) += (Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))) (*SumCtx)(unsafe.Pointer(p)).Fapprox = U8(1) } } @@ -100328,19 +99457,19 @@ func sumInverse(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* s _ = argc p = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(SumCtx{}))) - type1 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + type1 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv))) // p is always non-NULL because sumStep() will have been called first // to initialize it - if (p != 0) && (type1 != 5) { + if (p != 0) && (type1 != SQLITE_NULL) { (*SumCtx)(unsafe.Pointer(p)).Fcnt-- - if (type1 == 1) && (int32((*SumCtx)(unsafe.Pointer(p)).Fapprox) == 0) { - var v I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + if (type1 == SQLITE_INTEGER) && (int32((*SumCtx)(unsafe.Pointer(p)).Fapprox) == 0) { + var v I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) *(*float64)(unsafe.Pointer(p /* &.rSum */)) -= (float64(v)) *(*I64)(unsafe.Pointer(p + 8 /* &.iSum */)) -= (v) } else { - *(*float64)(unsafe.Pointer(p /* &.rSum */)) -= (Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + *(*float64)(unsafe.Pointer(p /* &.rSum */)) -= (Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))) } } } @@ -100391,7 +99520,7 @@ type CountCtx = CountCtx1 /* sqlite3.c:118654:25 */ func countStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:118665:13: */ var p uintptr p = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(CountCtx{}))) - if ((argc == 0) || (5 != Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) && (p != 0) { + if ((argc == 0) || (SQLITE_NULL != Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))))) && (p != 0) { (*CountCtx)(unsafe.Pointer(p)).Fn++ } @@ -100417,14 +99546,14 @@ func countInverse(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* sql var p uintptr p = Xsqlite3_aggregate_context(tls, ctx, int32(unsafe.Sizeof(CountCtx{}))) // p is always non-NULL since countStep() will have been called first - if ((argc == 0) || (5 != Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))))) && (p != 0) { + if ((argc == 0) || (SQLITE_NULL != Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))))) && (p != 0) { (*CountCtx)(unsafe.Pointer(p)).Fn-- } } // Routines to implement min() and max() aggregate functions. func minmaxStep(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { /* sqlite3.c:118705:13: */ - var pArg uintptr = *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)) + var pArg uintptr = *(*uintptr)(unsafe.Pointer(argv)) var pBest uintptr _ = NotUsed @@ -100433,7 +99562,7 @@ func minmaxStep(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) { / return } - if Xsqlite3_value_type(tls, pArg) == 5 { + if Xsqlite3_value_type(tls, pArg) == SQLITE_NULL { if (*Mem)(unsafe.Pointer(pBest)).Fflags != 0 { sqlite3SkipAccumulatorLoad(tls, context) } @@ -100490,7 +99619,7 @@ func groupConcatStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { var nVal int32 var nSep int32 - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } pAccum = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(StrAccum{}))) @@ -100498,11 +99627,11 @@ func groupConcatStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { if pAccum != 0 { var db uintptr = Xsqlite3_context_db_handle(tls, context) var firstTerm int32 = (libc.Bool32((*StrAccum)(unsafe.Pointer(pAccum)).FmxAlloc == U32(0))) - (*StrAccum)(unsafe.Pointer(pAccum)).FmxAlloc = U32(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(0)*4))) + (*StrAccum)(unsafe.Pointer(pAccum)).FmxAlloc = U32(*(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */)))) if !(firstTerm != 0) { if argc == 2 { - zSep = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - nSep = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zSep = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + nSep = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) } else { zSep = ts + 13915 /* "," */ nSep = 1 @@ -100511,8 +99640,8 @@ func groupConcatStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { Xsqlite3_str_append(tls, pAccum, zSep, nSep) } } - zVal = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - nVal = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zVal = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + nVal = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) if zVal != 0 { Xsqlite3_str_append(tls, pAccum, zVal, nVal) } @@ -100523,16 +99652,16 @@ func groupConcatInverse(tls *libc.TLS, context uintptr, argc int32, argv uintptr var n int32 var pAccum uintptr - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == 5 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { return } pAccum = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(StrAccum{}))) // pAccum is always non-NULL since groupConcatStep() will have always // run frist to initialize it if pAccum != 0 { - n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) if argc == 2 { - n = n + (Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) + n = n + (Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) } else { n++ } @@ -100552,9 +99681,9 @@ func groupConcatFinalize(tls *libc.TLS, context uintptr) { /* sqlite3.c:118831:1 var pAccum uintptr pAccum = Xsqlite3_aggregate_context(tls, context, 0) if pAccum != 0 { - if int32((*StrAccum)(unsafe.Pointer(pAccum)).FaccError) == 18 { + if int32((*StrAccum)(unsafe.Pointer(pAccum)).FaccError) == SQLITE_TOOBIG { Xsqlite3_result_error_toobig(tls, context) - } else if int32((*StrAccum)(unsafe.Pointer(pAccum)).FaccError) == 7 { + } else if int32((*StrAccum)(unsafe.Pointer(pAccum)).FaccError) == SQLITE_NOMEM { Xsqlite3_result_error_nomem(tls, context) } else { Xsqlite3_result_text(tls, context, Xsqlite3StrAccumFinish(tls, pAccum), -1, @@ -100567,9 +99696,9 @@ func groupConcatValue(tls *libc.TLS, context uintptr) { /* sqlite3.c:118846:13: var pAccum uintptr pAccum = Xsqlite3_aggregate_context(tls, context, 0) if pAccum != 0 { - if int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 18 { + if int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == SQLITE_TOOBIG { Xsqlite3_result_error_toobig(tls, context) - } else if int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 7 { + } else if int32((*Sqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == SQLITE_NOMEM { Xsqlite3_result_error_nomem(tls, context) } else { var zText uintptr = Xsqlite3_str_value(tls, pAccum) @@ -100584,7 +99713,7 @@ func groupConcatValue(tls *libc.TLS, context uintptr) { /* sqlite3.c:118846:13: func Xsqlite3RegisterPerConnectionBuiltinFunctions(tls *libc.TLS, db uintptr) { /* sqlite3.c:118869:21: */ var rc int32 = Xsqlite3_overload_function(tls, db, ts+16010 /* "MATCH" */, 2) - if rc == 7 { + if rc == SQLITE_NOMEM { Xsqlite3OomFault(tls, db) } } @@ -100597,19 +99726,19 @@ func Xsqlite3RegisterLikeFunctions(tls *libc.TLS, db uintptr, caseSensitive int3 var flags int32 if caseSensitive != 0 { pInfo = uintptr(unsafe.Pointer(&likeInfoAlt)) - flags = (0x0004 | 0x0008) + flags = (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) } else { pInfo = uintptr(unsafe.Pointer(&likeInfoNorm)) - flags = 0x0004 + flags = SQLITE_FUNC_LIKE } - Xsqlite3CreateFunc(tls, db, ts+16016 /* "like" */, 2, 1, pInfo, *(*uintptr)(unsafe.Pointer(&struct { + Xsqlite3CreateFunc(tls, db, ts+16016 /* "like" */, 2, SQLITE_UTF8, pInfo, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{likeFunc})), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) - Xsqlite3CreateFunc(tls, db, ts+16016 /* "like" */, 3, 1, pInfo, *(*uintptr)(unsafe.Pointer(&struct { + Xsqlite3CreateFunc(tls, db, ts+16016 /* "like" */, 3, SQLITE_UTF8, pInfo, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{likeFunc})), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) - *(*U32)(unsafe.Pointer(Xsqlite3FindFunction(tls, db, ts+16016 /* "like" */, 2, uint8(1), uint8(0)) + 4 /* &.funcFlags */)) |= (U32(flags)) - *(*U32)(unsafe.Pointer(Xsqlite3FindFunction(tls, db, ts+16016 /* "like" */, 3, uint8(1), uint8(0)) + 4 /* &.funcFlags */)) |= (U32(flags)) + *(*U32)(unsafe.Pointer(Xsqlite3FindFunction(tls, db, ts+16016 /* "like" */, 2, SQLITE_UTF8, uint8(0)) + 4 /* &.funcFlags */)) |= (U32(flags)) + *(*U32)(unsafe.Pointer(Xsqlite3FindFunction(tls, db, ts+16016 /* "like" */, 3, SQLITE_UTF8, uint8(0)) + 4 /* &.funcFlags */)) |= (U32(flags)) } // pExpr points to an expression which implements a function. If @@ -100630,13 +99759,13 @@ func Xsqlite3RegisterLikeFunctions(tls *libc.TLS, db uintptr, caseSensitive int3 func Xsqlite3IsLikeFunction(tls *libc.TLS, db uintptr, pExpr uintptr, pIsNocase uintptr, aWc uintptr) int32 { /* sqlite3.c:118915:20: */ var pDef uintptr var nExpr int32 - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 169) || !(int32(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) != 0) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_FUNCTION) || !(int32(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) != 0) { return 0 } nExpr = (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FnExpr - pDef = Xsqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), nExpr, uint8(1), uint8(0)) - if (pDef == uintptr(0)) || (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0004)) == U32(0)) { + pDef = Xsqlite3FindFunction(tls, db, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), nExpr, SQLITE_UTF8, uint8(0)) + if (pDef == uintptr(0)) || (((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_LIKE) == U32(0)) { return 0 } @@ -100646,27 +99775,27 @@ func Xsqlite3IsLikeFunction(tls *libc.TLS, db uintptr, pExpr uintptr, pIsNocase libc.Xmemcpy(tls, aWc, (*FuncDef)(unsafe.Pointer(pDef)).FpUserData, uint64(3)) if nExpr < 3 { - *(*int8)(unsafe.Pointer(aWc + uintptr(3))) = int8(0) + *(*int8)(unsafe.Pointer(aWc + 3)) = int8(0) } else { - var pEscape uintptr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + uintptr(2)*32)).FpExpr + var pEscape uintptr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + 2*32)).FpExpr var zEscape uintptr - if int32((*Expr)(unsafe.Pointer(pEscape)).Fop) != 115 { + if int32((*Expr)(unsafe.Pointer(pEscape)).Fop) != TK_STRING { return 0 } zEscape = *(*uintptr)(unsafe.Pointer(pEscape + 8 /* &.u */)) - if (int32(*(*int8)(unsafe.Pointer(zEscape + uintptr(0)))) == 0) || (int32(*(*int8)(unsafe.Pointer(zEscape + uintptr(1)))) != 0) { + if (int32(*(*int8)(unsafe.Pointer(zEscape))) == 0) || (int32(*(*int8)(unsafe.Pointer(zEscape + 1))) != 0) { return 0 } - if int32(*(*int8)(unsafe.Pointer(zEscape + uintptr(0)))) == int32(*(*int8)(unsafe.Pointer(aWc + uintptr(0)))) { + if int32(*(*int8)(unsafe.Pointer(zEscape))) == int32(*(*int8)(unsafe.Pointer(aWc))) { return 0 } - if int32(*(*int8)(unsafe.Pointer(zEscape + uintptr(0)))) == int32(*(*int8)(unsafe.Pointer(aWc + uintptr(1)))) { + if int32(*(*int8)(unsafe.Pointer(zEscape))) == int32(*(*int8)(unsafe.Pointer(aWc + 1))) { return 0 } - *(*int8)(unsafe.Pointer(aWc + uintptr(3))) = *(*int8)(unsafe.Pointer(zEscape + uintptr(0))) + *(*int8)(unsafe.Pointer(aWc + 3)) = *(*int8)(unsafe.Pointer(zEscape)) } - *(*int32)(unsafe.Pointer(pIsNocase)) = (libc.Bool32(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & U32(0x0008)) == U32(0))) + *(*int32)(unsafe.Pointer(pIsNocase)) = (libc.Bool32(((*FuncDef)(unsafe.Pointer(pDef)).FfuncFlags & SQLITE_FUNC_CASE) == U32(0))) return 1 } @@ -100685,659 +99814,73 @@ func Xsqlite3RegisterBuiltinFunctions(tls *libc.TLS) { /* sqlite3.c:118964:21: * var aBuiltinFunc = [65]FuncDef{ //**** Functions only available with SQLITE_TESTCTRL_INTERNAL_FUNCTIONS **** - { - FnArg: int8(2), - FfuncFlags: (U32(((((1 | 0x00040000) | 0x4000) | 0x00400000) | 0x0800) | (0))), - FpUserData: uintptr(int64(1)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16021 /* "implies_nonnull_..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32(((((1 | 0x00040000) | 0x4000) | 0x00400000) | 0x0800) | (0))), - FpUserData: uintptr(int64(3)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16041 /* "expr_compare" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32(((((1 | 0x00040000) | 0x4000) | 0x00400000) | 0x0800) | (0))), - FpUserData: uintptr(int64(2)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16054 /* "expr_implies_exp..." */, Fu: struct{ FpHash uintptr }{}}, + {FnArg: int8(2), FfuncFlags: (U32(((((SQLITE_UTF8 | SQLITE_FUNC_INTERNAL) | SQLITE_FUNC_TEST) | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (0))), FpUserData: uintptr(INLINEFUNC_implies_nonnull_row), FxSFunc: 0, FzName: ts + 16021 /* "implies_nonnull_..." */}, + {FnArg: int8(2), FfuncFlags: (U32(((((SQLITE_UTF8 | SQLITE_FUNC_INTERNAL) | SQLITE_FUNC_TEST) | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (0))), FpUserData: uintptr(INLINEFUNC_expr_compare), FxSFunc: 0, FzName: ts + 16041 /* "expr_compare" */}, + {FnArg: int8(2), FfuncFlags: (U32(((((SQLITE_UTF8 | SQLITE_FUNC_INTERNAL) | SQLITE_FUNC_TEST) | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (0))), FpUserData: uintptr(INLINEFUNC_expr_implies_expr), FxSFunc: 0, FzName: ts + 16054 /* "expr_implies_exp..." */}, //**** Regular functions **** - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16072 /* "soundex" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | 0x000080000) | 0x00200000)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16080 /* "load_extension" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((1 | 0x000080000) | 0x00200000)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16080 /* "load_extension" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16095 /* "sqlite_compileop..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16121 /* "sqlite_compileop..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(((1 | 0x00400000) | 0x0800) | (0x0400))), - FpUserData: uintptr(int64(99)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16146 /* "unlikely" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32(((1 | 0x00400000) | 0x0800) | (0x0400))), - FpUserData: uintptr(int64(99)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16155 /* "likelihood" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(((1 | 0x00400000) | 0x0800) | (0x0400))), - FpUserData: uintptr(int64(99)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16166 /* "likely" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((((0x0800 | 1) | (0 * 0x0020)) | 0x8000) | 0x0080)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16173 /* "sqlite_offset" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(1)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16187 /* "ltrim" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(1)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16187 /* "ltrim" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(2)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16193 /* "rtrim" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(2)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16193 /* "rtrim" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(3)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16199 /* "trim" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(3)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16199 /* "trim" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x0800 | 1) | (1 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16204 /* "min" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((0x0800 | 1) | (1 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: uintptr(0), - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16204 /* "min" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (1 * 0x0020)) | 0x1000)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: uintptr(0), - FzName: ts + 16204 /* "min" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x0800 | 1) | (1 * 0x0020))), - FpUserData: uintptr(int64(1)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16208 /* "max" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((0x0800 | 1) | (1 * 0x0020))), - FpUserData: uintptr(int64(1)), - FpNext: uintptr(0), - FxSFunc: uintptr(0), - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16208 /* "max" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (1 * 0x0020)) | 0x1000)), - FpUserData: uintptr(int64(1)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: uintptr(0), - FzName: ts + 16208 /* "max" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(((0x0800 | 1) | (0 * 0x0020)) | 0x0080)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16212 /* "typeof" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(((0x0800 | 1) | (0 * 0x0020)) | 0x0040)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16219 /* "length" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16226 /* "instr" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16232 /* "printf" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16239 /* "unicode" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16247 /* "char" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16252 /* "abs" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16256 /* "round" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16256 /* "round" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16262 /* "upper" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16268 /* "lower" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16274 /* "hex" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32(((1 | 0x00400000) | 0x0800) | (0))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16278 /* "ifnull" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(1 | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16285 /* "random" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32(1 | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16292 /* "randomblob" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (1 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16303 /* "nullif" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16310 /* "sqlite_version" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(0x2000 | 1)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16325 /* "sqlite_source_id" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16342 /* "sqlite_log" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16353 /* "quote" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(1 | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16359 /* "last_insert_rowi..." */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(1 | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16377 /* "changes" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32(1 | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16385 /* "total_changes" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(3), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16399 /* "replace" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16407 /* "zeroblob" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16416 /* "substr" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(3), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16416 /* "substr" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 16423 /* "sum" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 16427 /* "total" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 16433 /* "avg" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0x0100)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 16437 /* "count" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 16437 /* "count" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 16443 /* "group_concat" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((1 | (0 * 0x0020)) | 0)), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: ts + 16443 /* "group_concat" */, Fu: struct{ FpHash uintptr }{}}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16072 /* "soundex" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_DIRECTONLY) | SQLITE_FUNC_UNSAFE)), FxSFunc: 0, FzName: ts + 16080 /* "load_extension" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_DIRECTONLY) | SQLITE_FUNC_UNSAFE)), FxSFunc: 0, FzName: ts + 16080 /* "load_extension" */}, + {FnArg: int8(1), FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 16095 /* "sqlite_compileop..." */}, + {FnArg: int8(1), FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 16121 /* "sqlite_compileop..." */}, + {FnArg: int8(1), FfuncFlags: (U32(((SQLITE_UTF8 | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (SQLITE_FUNC_UNLIKELY))), FpUserData: uintptr(INLINEFUNC_unlikely), FxSFunc: 0, FzName: ts + 16146 /* "unlikely" */}, + {FnArg: int8(2), FfuncFlags: (U32(((SQLITE_UTF8 | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (SQLITE_FUNC_UNLIKELY))), FpUserData: uintptr(INLINEFUNC_unlikely), FxSFunc: 0, FzName: ts + 16155 /* "likelihood" */}, + {FnArg: int8(1), FfuncFlags: (U32(((SQLITE_UTF8 | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (SQLITE_FUNC_UNLIKELY))), FpUserData: uintptr(INLINEFUNC_unlikely), FxSFunc: 0, FzName: ts + 16166 /* "likely" */}, + {FnArg: int8(1), FfuncFlags: (U32((((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL)) | SQLITE_FUNC_OFFSET) | SQLITE_FUNC_TYPEOF)), FxSFunc: 0, FzName: ts + 16173 /* "sqlite_offset" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(1)), FxSFunc: 0, FzName: ts + 16187 /* "ltrim" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(1)), FxSFunc: 0, FzName: ts + 16187 /* "ltrim" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(2)), FxSFunc: 0, FzName: ts + 16193 /* "rtrim" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(2)), FxSFunc: 0, FzName: ts + 16193 /* "rtrim" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(3)), FxSFunc: 0, FzName: ts + 16199 /* "trim" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(3)), FxSFunc: 0, FzName: ts + 16199 /* "trim" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (1 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16204 /* "min" */}, + {FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (1 * SQLITE_FUNC_NEEDCOLL))), FzName: ts + 16204 /* "min" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (1 * SQLITE_FUNC_NEEDCOLL)) | SQLITE_FUNC_MINMAX)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FzName: ts + 16204 /* "min" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (1 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(1)), FxSFunc: 0, FzName: ts + 16208 /* "max" */}, + {FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (1 * SQLITE_FUNC_NEEDCOLL))), FpUserData: uintptr(int64(1)), FzName: ts + 16208 /* "max" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (1 * SQLITE_FUNC_NEEDCOLL)) | SQLITE_FUNC_MINMAX)), FpUserData: uintptr(int64(1)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FzName: ts + 16208 /* "max" */}, + {FnArg: int8(1), FfuncFlags: (U32(((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL)) | SQLITE_FUNC_TYPEOF)), FxSFunc: 0, FzName: ts + 16212 /* "typeof" */}, + {FnArg: int8(1), FfuncFlags: (U32(((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL)) | SQLITE_FUNC_LENGTH)), FxSFunc: 0, FzName: ts + 16219 /* "length" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16226 /* "instr" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16232 /* "printf" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16239 /* "unicode" */}, + {FnArg: int8(-1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16247 /* "char" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16252 /* "abs" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16256 /* "round" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16256 /* "round" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16262 /* "upper" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16268 /* "lower" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16274 /* "hex" */}, + {FnArg: int8(2), FfuncFlags: (U32(((SQLITE_UTF8 | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (0))), FxSFunc: 0, FzName: ts + 16278 /* "ifnull" */}, + {FfuncFlags: (U32(SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16285 /* "random" */}, + {FnArg: int8(1), FfuncFlags: (U32(SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16292 /* "randomblob" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (1 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16303 /* "nullif" */}, + {FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 16310 /* "sqlite_version" */}, + {FfuncFlags: (U32(SQLITE_FUNC_SLOCHNG | SQLITE_UTF8)), FxSFunc: 0, FzName: ts + 16325 /* "sqlite_source_id" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16342 /* "sqlite_log" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16353 /* "quote" */}, + {FfuncFlags: (U32(SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16359 /* "last_insert_rowi..." */}, + {FfuncFlags: (U32(SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16377 /* "changes" */}, + {FfuncFlags: (U32(SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16385 /* "total_changes" */}, + {FnArg: int8(3), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16399 /* "replace" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16407 /* "zeroblob" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16416 /* "substr" */}, + {FnArg: int8(3), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FxSFunc: 0, FzName: ts + 16416 /* "substr" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 16423 /* "sum" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 16427 /* "total" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 16433 /* "avg" */}, + {FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | SQLITE_FUNC_COUNT)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 16437 /* "count" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 16437 /* "count" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 16443 /* "group_concat" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_UTF8 | (0 * SQLITE_FUNC_NEEDCOLL)) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: ts + 16443 /* "group_concat" */}, - { - FnArg: int8(2), - FfuncFlags: (U32(((0x0800 | 1) | 0x0004) | 0x0008)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16456 /* "glob" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((0x0800 | 1) | 0x0004)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16016 /* "like" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(3), - FfuncFlags: (U32((0x0800 | 1) | 0x0004)), - FpUserData: 0, - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16016 /* "like" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: uintptr(0), - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16461 /* "coalesce" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((0x0800 | 1) | (0 * 0x0020))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: uintptr(0), - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16461 /* "coalesce" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(-1), - FfuncFlags: (U32(((1 | 0x00400000) | 0x0800) | (0))), - FpUserData: uintptr(int64(0)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16461 /* "coalesce" */, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(3), - FfuncFlags: (U32(((1 | 0x00400000) | 0x0800) | (0))), - FpUserData: uintptr(int64(5)), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: uintptr(0), - FxValue: uintptr(0), - FxInverse: uintptr(0), - FzName: ts + 16470 /* "iif" */, Fu: struct{ FpHash uintptr }{}}, -} /* sqlite3.c:118975:18 */ + {FnArg: int8(2), FfuncFlags: (U32(((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | SQLITE_FUNC_LIKE) | SQLITE_FUNC_CASE)), FpUserData: 0, FxSFunc: 0, FzName: ts + 16456 /* "glob" */}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | SQLITE_FUNC_LIKE)), FpUserData: 0, FxSFunc: 0, FzName: ts + 16016 /* "like" */}, + {FnArg: int8(3), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | SQLITE_FUNC_LIKE)), FpUserData: 0, FxSFunc: 0, FzName: ts + 16016 /* "like" */}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FzName: ts + 16461 /* "coalesce" */}, + {FfuncFlags: (U32((SQLITE_FUNC_CONSTANT | SQLITE_UTF8) | (0 * SQLITE_FUNC_NEEDCOLL))), FzName: ts + 16461 /* "coalesce" */}, + {FnArg: int8(-1), FfuncFlags: (U32(((SQLITE_UTF8 | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (0))), FxSFunc: 0, FzName: ts + 16461 /* "coalesce" */}, + {FnArg: int8(3), FfuncFlags: (U32(((SQLITE_UTF8 | SQLITE_FUNC_INLINE) | SQLITE_FUNC_CONSTANT) | (0))), FpUserData: uintptr(INLINEFUNC_iif), FxSFunc: 0, FzName: ts + 16470 /* "iif" */}} /* sqlite3.c:118975:18 */ //************* End of func.c *********************************************** //************* Begin file fkey.c ******************************************* @@ -101516,10 +100059,10 @@ func Xsqlite3FkLocateIndex(tls *libc.TLS, pParse uintptr, pParent uintptr, pFKey bp := tls.Alloc(16) defer tls.Free(16) - var pIdx uintptr = uintptr(0) // Value to return via *ppIdx - var aiCol uintptr = uintptr(0) // Value to return via *paiCol - var nCol int32 = (*FKey)(unsafe.Pointer(pFKey)).FnCol // Number of columns in parent key - var zKey uintptr = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(0)*16)).FzCol // Name of left-most parent key column + var pIdx uintptr = uintptr(0) // Value to return via *ppIdx + var aiCol uintptr = uintptr(0) // Value to return via *paiCol + var nCol int32 = (*FKey)(unsafe.Pointer(pFKey)).FnCol // Number of columns in parent key + var zKey uintptr = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */))).FzCol // Name of left-most parent key column // The caller is responsible for zeroing output parameters. @@ -101555,7 +100098,7 @@ func Xsqlite3FkLocateIndex(tls *libc.TLS, pParse uintptr, pParent uintptr, pFKey } for pIdx = (*Table)(unsafe.Pointer(pParent)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { - if ((int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) == nCol) && (int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0)) && ((*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0)) { + if ((int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) == nCol) && (int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None)) && ((*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0)) { // pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number // of columns. If each indexed column corresponds to a foreign key // column of pFKey, then this index is a winner. @@ -101564,7 +100107,7 @@ func Xsqlite3FkLocateIndex(tls *libc.TLS, pParse uintptr, pParent uintptr, pFKey // If zKey is NULL, then this foreign key is implicitly mapped to // the PRIMARY KEY of table pParent. The PRIMARY KEY index may be // identified by the test. - if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2 { + if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY { if aiCol != 0 { var i int32 for i = 0; i < nCol; i++ { @@ -101672,12 +100215,12 @@ func fkLookupParent(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr, pIdx // any are, then the constraint is considered satisfied. No need to // search for a matching row in the parent table. if nIncr < 0 { - Xsqlite3VdbeAddOp2(tls, v, 47, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), iOk) + Xsqlite3VdbeAddOp2(tls, v, OP_FkIfZero, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), iOk) } for i = 0; i < (*FKey)(unsafe.Pointer(pFKey)).FnCol; i++ { var iReg int32 = ((int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4))))) + regData) + 1) - Xsqlite3VdbeAddOp2(tls, v, 50, iReg, iOk) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, iReg, iOk) } if isIgnore == 0 { @@ -101692,21 +100235,21 @@ func fkLookupParent(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr, pIdx // is no matching parent key. Before using MustBeInt, make a copy of // the value. Otherwise, the value inserted into the child key column // will have INTEGER affinity applied to it, which may not be correct. - Xsqlite3VdbeAddOp2(tls, v, 78, - ((int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(*(*int32)(unsafe.Pointer(aiCol + uintptr(0)*4))))) + 1) + regData), regTemp) - iMustBeInt = Xsqlite3VdbeAddOp2(tls, v, 15, regTemp, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, + ((int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(*(*int32)(unsafe.Pointer(aiCol))))) + 1) + regData), regTemp) + iMustBeInt = Xsqlite3VdbeAddOp2(tls, v, OP_MustBeInt, regTemp, 0) // If the parent table is the same as the child table, and we are about // to increment the constraint-counter (i.e. this is an INSERT operation), // then check if the row being inserted matches itself. If so, do not // increment the constraint-counter. if (pTab == (*FKey)(unsafe.Pointer(pFKey)).FpFrom) && (nIncr == 1) { - Xsqlite3VdbeAddOp3(tls, v, 53, regData, iOk, regTemp) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x90)) + Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regData, iOk, regTemp) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NOTNULL) } - Xsqlite3OpenTable(tls, pParse, iCur, iDb, pTab, 96) - Xsqlite3VdbeAddOp3(tls, v, 32, iCur, 0, regTemp) + Xsqlite3OpenTable(tls, pParse, iCur, iDb, pTab, OP_OpenRead) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iCur, 0, regTemp) Xsqlite3VdbeGoto(tls, v, iOk) Xsqlite3VdbeJumpHere(tls, v, (Xsqlite3VdbeCurrentAddr(tls, v) - 2)) Xsqlite3VdbeJumpHere(tls, v, iMustBeInt) @@ -101716,10 +100259,10 @@ func fkLookupParent(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr, pIdx var regTemp int32 = Xsqlite3GetTempRange(tls, pParse, nCol) var regRec int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 96, iCur, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, iCur, int32((*Index)(unsafe.Pointer(pIdx)).Ftnum), iDb) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx) for i = 0; i < nCol; i++ { - Xsqlite3VdbeAddOp2(tls, v, 77, + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, ((int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4))))) + 1) + regData), (regTemp + i)) } @@ -101746,22 +100289,22 @@ func fkLookupParent(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr, pIdx // The parent key is a composite key that includes the IPK column iParent = regData } - Xsqlite3VdbeAddOp3(tls, v, 52, iChild, iJump, iParent) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeAddOp3(tls, v, OP_Ne, iChild, iJump, iParent) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_JUMPIFNULL) } Xsqlite3VdbeGoto(tls, v, iOk) } - Xsqlite3VdbeAddOp4(tls, v, 91, regTemp, nCol, regRec, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regTemp, nCol, regRec, Xsqlite3IndexAffinityStr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pIdx), nCol) - Xsqlite3VdbeAddOp4Int(tls, v, 30, iCur, iOk, regRec, 0) + Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, iCur, iOk, regRec, 0) Xsqlite3ReleaseTempReg(tls, pParse, regRec) Xsqlite3ReleaseTempRange(tls, pParse, regTemp, nCol) } } - if ((!(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && !(((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00080000)) != 0)) && + if ((!(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && !(((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_DeferFKs) != 0)) && !(int32((*Parse)(unsafe.Pointer(pParse)).FpToplevel) != 0)) && !(int32((*Parse)(unsafe.Pointer(pParse)).FisMultiWrite) != 0) { // Special case: If this is an INSERT statement that will insert exactly @@ -101769,17 +100312,17 @@ func fkLookupParent(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr, pIdx // incrementing a counter. This is necessary as the VM code is being // generated for will not open a statement transaction. - Xsqlite3HaltConstraint(tls, pParse, (19 | (int32(3) << 8)), - 2, uintptr(0), int8(-1), uint8(4)) + Xsqlite3HaltConstraint(tls, pParse, (SQLITE_CONSTRAINT | (int32(3) << 8)), + OE_Abort, uintptr(0), int8(-1), P5_ConstraintFK) } else { if (nIncr > 0) && (int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) == 0) { Xsqlite3MayAbort(tls, pParse) } - Xsqlite3VdbeAddOp2(tls, v, 149, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr) + Xsqlite3VdbeAddOp2(tls, v, OP_FkCounter, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr) } Xsqlite3VdbeResolveLabel(tls, v, iOk) - Xsqlite3VdbeAddOp1(tls, v, 116, iCur) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iCur) } // Return an Expr object that refers to a memory register corresponding @@ -101794,7 +100337,7 @@ func exprTableRegister(tls *libc.TLS, pParse uintptr, pTab uintptr, regBase int3 var zColl uintptr var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - pExpr = Xsqlite3Expr(tls, db, 173, uintptr(0)) + pExpr = Xsqlite3Expr(tls, db, TK_REGISTER, uintptr(0)) if pExpr != 0 { if (int32(iCol) >= 0) && (int32(iCol) != int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) { pCol = ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*32) @@ -101807,7 +100350,7 @@ func exprTableRegister(tls *libc.TLS, pParse uintptr, pTab uintptr, regBase int3 pExpr = Xsqlite3ExprAddCollateString(tls, pParse, pExpr, zColl) } else { (*Expr)(unsafe.Pointer(pExpr)).FiTable = regBase - (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = int8(0x44) + (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = SQLITE_AFF_INTEGER } } return pExpr @@ -101816,7 +100359,7 @@ func exprTableRegister(tls *libc.TLS, pParse uintptr, pTab uintptr, regBase int3 // Return an Expr object that refers to column iCol of table pTab which // has cursor iCur. func exprTableColumn(tls *libc.TLS, db uintptr, pTab uintptr, iCursor int32, iCol I16) uintptr { /* sqlite3.c:119604:13: */ - var pExpr uintptr = Xsqlite3Expr(tls, db, 164, uintptr(0)) + var pExpr uintptr = Xsqlite3Expr(tls, db, TK_COLUMN, uintptr(0)) if pExpr != 0 { *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = pTab (*Expr)(unsafe.Pointer(pExpr)).FiTable = iCursor @@ -101869,7 +100412,7 @@ func fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, p var v uintptr = Xsqlite3GetVdbe(tls, pParse) if nIncr < 0 { - iFkIfZero = Xsqlite3VdbeAddOp2(tls, v, 47, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), 0) + iFkIfZero = Xsqlite3VdbeAddOp2(tls, v, OP_FkIfZero, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), 0) } @@ -101896,12 +100439,12 @@ func fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, p if aiCol != 0 { iCol = int16(*(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4))) } else { - iCol = int16((*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(0)*16)).FiFrom) + iCol = int16((*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */))).FiFrom) } zCol = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iCol)*32)).FzName - pRight = Xsqlite3Expr(tls, db, 59, zCol) - pEq = Xsqlite3PExpr(tls, pParse, 53, pLeft, pRight) + pRight = Xsqlite3Expr(tls, db, TK_ID, zCol) + pEq = Xsqlite3PExpr(tls, pParse, TK_EQ, pLeft, pRight) pWhere = Xsqlite3ExprAnd(tls, pParse, pWhere, pEq) } @@ -101922,10 +100465,10 @@ func fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, p var pNe uintptr // Expression (pLeft != pRight) var pLeft uintptr // Value from parent table row var pRight uintptr // Column ref to child table - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { pLeft = exprTableRegister(tls, pParse, pTab, regData, int16(-1)) - pRight = exprTableColumn(tls, db, pTab, (*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(0)*112)).FiCursor, int16(-1)) - pNe = Xsqlite3PExpr(tls, pParse, 52, pLeft, pRight) + pRight = exprTableColumn(tls, db, pTab, (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FiCursor, int16(-1)) + pNe = Xsqlite3PExpr(tls, pParse, TK_NE, pLeft, pRight) } else { var pEq uintptr var pAll uintptr = uintptr(0) @@ -101934,11 +100477,11 @@ func fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, p var iCol I16 = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i)*2)) pLeft = exprTableRegister(tls, pParse, pTab, regData, iCol) - pRight = Xsqlite3Expr(tls, db, 59, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*32)).FzName) - pEq = Xsqlite3PExpr(tls, pParse, 45, pLeft, pRight) + pRight = Xsqlite3Expr(tls, db, TK_ID, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iCol)*32)).FzName) + pEq = Xsqlite3PExpr(tls, pParse, TK_IS, pLeft, pRight) pAll = Xsqlite3ExprAnd(tls, pParse, pAll, pEq) } - pNe = Xsqlite3PExpr(tls, pParse, 19, pAll, uintptr(0)) + pNe = Xsqlite3PExpr(tls, pParse, TK_NOT, pAll, uintptr(0)) } pWhere = Xsqlite3ExprAnd(tls, pParse, pWhere, pNe) } @@ -101954,7 +100497,7 @@ func fkScanChildren(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintptr, p // foreign key constraint counter. if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 { pWInfo = Xsqlite3WhereBegin(tls, pParse, pSrc, pWhere, uintptr(0), uintptr(0), uint16(0), 0) - Xsqlite3VdbeAddOp2(tls, v, 149, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr) + Xsqlite3VdbeAddOp2(tls, v, OP_FkCounter, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), nIncr) if pWInfo != 0 { Xsqlite3WhereEnd(tls, pWInfo) } @@ -102017,7 +100560,7 @@ func fkTriggerDelete(tls *libc.TLS, dbMem uintptr, p uintptr) { /* sqlite3.c:119 // DELETE, but foreign key actions are not. func Xsqlite3FkDropTable(tls *libc.TLS, pParse uintptr, pName uintptr, pTab uintptr) { /* sqlite3.c:119820:21: */ var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00004000)) != 0) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { + if (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ForeignKeys) != 0) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { var iSkip int32 = 0 var v uintptr = Xsqlite3GetVdbe(tls, pParse) @@ -102031,7 +100574,7 @@ func Xsqlite3FkDropTable(tls *libc.TLS, pParse uintptr, pName uintptr, pTab uint // when this statement is run. var p uintptr for p = (*Table)(unsafe.Pointer(pTab)).FpFKey; p != 0; p = (*FKey)(unsafe.Pointer(p)).FpNextFrom { - if ((*FKey)(unsafe.Pointer(p)).FisDeferred != 0) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00080000)) != 0) { + if ((*FKey)(unsafe.Pointer(p)).FisDeferred != 0) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DeferFKs) != 0) { break } } @@ -102039,7 +100582,7 @@ func Xsqlite3FkDropTable(tls *libc.TLS, pParse uintptr, pName uintptr, pTab uint return } iSkip = Xsqlite3VdbeMakeLabel(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 47, 1, iSkip) + Xsqlite3VdbeAddOp2(tls, v, OP_FkIfZero, 1, iSkip) } (*Parse)(unsafe.Pointer(pParse)).FdisableTriggers = U8(1) @@ -102054,12 +100597,12 @@ func Xsqlite3FkDropTable(tls *libc.TLS, pParse uintptr, pName uintptr, pTab uint // If the SQLITE_DeferFKs flag is set, then this is not required, as // the statement transaction will not be rolled back even if FK // constraints are violated. - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00080000)) == uint64(0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DeferFKs) == uint64(0) { - Xsqlite3VdbeAddOp2(tls, v, 47, 0, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_FkIfZero, 0, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) - Xsqlite3HaltConstraint(tls, pParse, (19 | (int32(3) << 8)), - 2, uintptr(0), int8(-1), uint8(4)) + Xsqlite3HaltConstraint(tls, pParse, (SQLITE_CONSTRAINT | (int32(3) << 8)), + OE_Abort, uintptr(0), int8(-1), P5_ConstraintFK) } if iSkip != 0 { @@ -102114,7 +100657,7 @@ func fkParentIsModified(tls *libc.TLS, pTab uintptr, p uintptr, aChange uintptr, if 0 == Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer(pCol)).FzName, zKey) { return 1 } - } else if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0001) != 0 { + } else if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_PRIMKEY) != 0 { return 1 } } @@ -102135,8 +100678,8 @@ func isSetNullAction(tls *libc.TLS, pParse uintptr, pFKey uintptr) int32 { /* sq }() if (*Parse)(unsafe.Pointer(pTop)).FpTriggerPrg != 0 { var p uintptr = (*TriggerPrg)(unsafe.Pointer((*Parse)(unsafe.Pointer(pTop)).FpTriggerPrg)).FpTrigger - if ((p == *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + uintptr(0)*8))) && (int32(*(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + uintptr(0)))) == 8)) || - ((p == *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + uintptr(1)*8))) && (int32(*(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + uintptr(1)))) == 8)) { + if ((p == *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */)))) && (int32(*(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */)))) == OE_SetNull)) || + ((p == *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + 1*8))) && (int32(*(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + 1))) == OE_SetNull)) { return 1 } } @@ -102174,7 +100717,7 @@ func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, // Exactly one of regOld and regNew should be non-zero. // If foreign-keys are disabled, this function is a no-op. - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00004000)) == uint64(0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ForeignKeys) == uint64(0) { return } @@ -102227,9 +100770,9 @@ func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, var iReg int32 iFromCol = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(i)*16)).FiFrom iReg = ((int32(Xsqlite3TableColumnToStorage(tls, (*FKey)(unsafe.Pointer(pFKey)).FpFrom, int16(iFromCol))) + regOld) + 1) - Xsqlite3VdbeAddOp2(tls, v, 50, iReg, iJump) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, iReg, iJump) } - Xsqlite3VdbeAddOp2(tls, v, 149, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), -1) + Xsqlite3VdbeAddOp2(tls, v, OP_FkCounter, int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred), -1) } continue } @@ -102237,7 +100780,7 @@ func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, if *(*uintptr)(unsafe.Pointer(bp + 8 /* aiFree */)) != 0 { aiCol = *(*uintptr)(unsafe.Pointer(bp + 8 /* aiFree */)) } else { - *(*int32)(unsafe.Pointer(bp + 16 /* iCol */)) = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(0)*16)).FiFrom + *(*int32)(unsafe.Pointer(bp + 16 /* iCol */)) = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */))).FiFrom aiCol = bp + 16 /* &iCol */ } for i = 0; i < (*FKey)(unsafe.Pointer(pFKey)).FnCol; i++ { @@ -102257,7 +100800,7 @@ func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, return int32((*Table)(unsafe.Pointer(pTo)).FiPKey) }())*32)).FzName rcauth = Xsqlite3AuthReadCol(tls, pParse, (*Table)(unsafe.Pointer(pTo)).FzName, zCol, iDb) - bIgnore = (libc.Bool32(rcauth == 2)) + bIgnore = (libc.Bool32(rcauth == SQLITE_IGNORE)) } } @@ -102299,7 +100842,7 @@ func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, continue } - if ((!(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00080000)) != 0)) && + if ((!(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DeferFKs) != 0)) && !(int32((*Parse)(unsafe.Pointer(pParse)).FpToplevel) != 0)) && !(int32((*Parse)(unsafe.Pointer(pParse)).FisMultiWrite) != 0) { // Inserting a single row into a parent table cannot cause (or fix) @@ -102347,7 +100890,7 @@ func Xsqlite3FkCheck(tls *libc.TLS, pParse uintptr, pTab uintptr, regOld int32, // child table to fire. In these cases the fk constraint counters // might be set incorrectly if any OP_FkCounter related scans are // omitted. - if (!(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && (eAction != 10)) && (eAction != 8) { + if (!(int32((*FKey)(unsafe.Pointer(pFKey)).FisDeferred) != 0) && (eAction != OE_Cascade)) && (eAction != OE_SetNull) { Xsqlite3MayAbort(tls, pParse) } } @@ -102365,7 +100908,7 @@ func Xsqlite3FkOldmask(tls *libc.TLS, pParse uintptr, pTab uintptr) U32 { /* sql defer tls.Free(8) var mask U32 = U32(0) - if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00004000)) != 0 { + if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_ForeignKeys) != 0 { var p uintptr var i int32 for p = (*Table)(unsafe.Pointer(pTab)).FpFKey; p != 0; p = (*FKey)(unsafe.Pointer(p)).FpNextFrom { @@ -102419,7 +100962,7 @@ func Xsqlite3FkOldmask(tls *libc.TLS, pParse uintptr, pTab uintptr) U32 { /* sql // Or, assuming some other foreign key processing is required, 1. func Xsqlite3FkRequired(tls *libc.TLS, pParse uintptr, pTab uintptr, aChange uintptr, chngRowid int32) int32 { /* sqlite3.c:120222:20: */ var eRet int32 = 0 - if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00004000)) != 0 { + if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_ForeignKeys) != 0 { if !(aChange != 0) { // A DELETE operation. Foreign key processing is required if the // table in question is either the child or parent table for any @@ -102443,7 +100986,7 @@ func Xsqlite3FkRequired(tls *libc.TLS, pParse uintptr, pTab uintptr, aChange uin // Check if any parent key columns are being modified. for p = Xsqlite3FkReferences(tls, pTab); p != 0; p = (*FKey)(unsafe.Pointer(p)).FpNextTo { if fkParentIsModified(tls, pTab, p, aChange, chngRowid) != 0 { - if int32(*(*U8)(unsafe.Pointer((p + 45 /* &.aAction */) + uintptr(1)))) != 0 { + if int32(*(*U8)(unsafe.Pointer((p + 45 /* &.aAction */) + 1))) != OE_None { return 2 } eRet = 1 @@ -102491,12 +101034,12 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, var iAction int32 = (libc.Bool32(pChanges != uintptr(0))) // 1 for UPDATE, 0 for DELETE action = int32(*(*U8)(unsafe.Pointer((pFKey + 45 /* &.aAction */) + uintptr(iAction)))) - if (action == 7) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00080000)) != 0) { + if (action == OE_Restrict) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_DeferFKs) != 0) { return uintptr(0) } pTrigger = *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + uintptr(iAction)*8)) - if (action != 0) && !(pTrigger != 0) { + if (action != OE_None) && !(pTrigger != 0) { var zFrom uintptr // Name of child table var nFrom int32 // Length in bytes of zFrom *(*uintptr)(unsafe.Pointer(bp /* pIdx */)) = uintptr(0) // Parent key index for this FK @@ -102513,12 +101056,8 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, } for i = 0; i < (*FKey)(unsafe.Pointer(pFKey)).FnCol; i++ { - *(*Token)(unsafe.Pointer(bp + 48 /* tOld */)) = Token{ - Fz: ts + 8342, /* "old" */ - Fn: uint32(3)} // Literal "old" token - *(*Token)(unsafe.Pointer(bp + 64 /* tNew */)) = Token{ - Fz: ts + 8338, /* "new" */ - Fn: uint32(3)} // Literal "new" token + *(*Token)(unsafe.Pointer(bp + 48 /* tOld */)) = Token{Fz: ts + 8342 /* "old" */, Fn: uint32(3)} // Literal "old" token + *(*Token)(unsafe.Pointer(bp + 64 /* tNew */)) = Token{Fz: ts + 8338 /* "new" */, Fn: uint32(3)} // Literal "new" token // var tFromCol Token at bp+32, 16 // Name of column in child table // var tToCol Token at bp+16, 16 @@ -102529,7 +101068,7 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, if *(*uintptr)(unsafe.Pointer(bp + 8 /* aiCol */)) != 0 { iFromCol = *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* aiCol */)) + uintptr(i)*4)) } else { - iFromCol = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */) + uintptr(0)*16)).FiFrom + iFromCol = (*sColMap)(unsafe.Pointer((pFKey + 64 /* &.aCol */))).FiFrom } Xsqlite3TokenInit(tls, bp+16, /* &tToCol */ @@ -102545,11 +101084,11 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, // that the "OLD.zToCol" term is on the LHS of the = operator, so // that the affinity and collation sequence associated with the // parent table are used for the comparison. - pEq = Xsqlite3PExpr(tls, pParse, 53, - Xsqlite3PExpr(tls, pParse, 139, - Xsqlite3ExprAlloc(tls, db, 59, bp+48 /* &tOld */, 0), - Xsqlite3ExprAlloc(tls, db, 59, bp+16 /* &tToCol */, 0)), - Xsqlite3ExprAlloc(tls, db, 59, bp+32 /* &tFromCol */, 0)) + pEq = Xsqlite3PExpr(tls, pParse, TK_EQ, + Xsqlite3PExpr(tls, pParse, TK_DOT, + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+48 /* &tOld */, 0), + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+16 /* &tToCol */, 0)), + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+32 /* &tFromCol */, 0)) pWhere = Xsqlite3ExprAnd(tls, pParse, pWhere, pEq) // For ON UPDATE, construct the next term of the WHEN clause. @@ -102557,26 +101096,26 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, // // WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN) if pChanges != 0 { - pEq = Xsqlite3PExpr(tls, pParse, 45, - Xsqlite3PExpr(tls, pParse, 139, - Xsqlite3ExprAlloc(tls, db, 59, bp+48 /* &tOld */, 0), - Xsqlite3ExprAlloc(tls, db, 59, bp+16 /* &tToCol */, 0)), - Xsqlite3PExpr(tls, pParse, 139, - Xsqlite3ExprAlloc(tls, db, 59, bp+64 /* &tNew */, 0), - Xsqlite3ExprAlloc(tls, db, 59, bp+16 /* &tToCol */, 0))) + pEq = Xsqlite3PExpr(tls, pParse, TK_IS, + Xsqlite3PExpr(tls, pParse, TK_DOT, + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+48 /* &tOld */, 0), + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+16 /* &tToCol */, 0)), + Xsqlite3PExpr(tls, pParse, TK_DOT, + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+64 /* &tNew */, 0), + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+16 /* &tToCol */, 0))) pWhen = Xsqlite3ExprAnd(tls, pParse, pWhen, pEq) } - if (action != 7) && ((action != 10) || (pChanges != 0)) { + if (action != OE_Restrict) && ((action != OE_Cascade) || (pChanges != 0)) { var pNew uintptr - if action == 10 { - pNew = Xsqlite3PExpr(tls, pParse, 139, - Xsqlite3ExprAlloc(tls, db, 59, bp+64 /* &tNew */, 0), - Xsqlite3ExprAlloc(tls, db, 59, bp+16 /* &tToCol */, 0)) - } else if action == 9 { + if action == OE_Cascade { + pNew = Xsqlite3PExpr(tls, pParse, TK_DOT, + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+64 /* &tNew */, 0), + Xsqlite3ExprAlloc(tls, db, TK_ID, bp+16 /* &tToCol */, 0)) + } else if action == OE_SetDflt { var pCol uintptr = ((*Table)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iFromCol)*32) var pDflt uintptr - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0060) != 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_GENERATED) != 0 { pDflt = uintptr(0) } else { @@ -102585,10 +101124,10 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, if pDflt != 0 { pNew = Xsqlite3ExprDup(tls, db, pDflt, 0) } else { - pNew = Xsqlite3ExprAlloc(tls, db, 119, uintptr(0), 0) + pNew = Xsqlite3ExprAlloc(tls, db, TK_NULL, uintptr(0), 0) } } else { - pNew = Xsqlite3ExprAlloc(tls, db, 119, uintptr(0), 0) + pNew = Xsqlite3ExprAlloc(tls, db, TK_NULL, uintptr(0), 0) } pList = Xsqlite3ExprListAppend(tls, pParse, pList, pNew) Xsqlite3ExprListSetName(tls, pParse, pList, bp+32 /* &tFromCol */, 0) @@ -102599,16 +101138,16 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, zFrom = (*Table)(unsafe.Pointer((*FKey)(unsafe.Pointer(pFKey)).FpFrom)).FzName nFrom = Xsqlite3Strlen30(tls, zFrom) - if action == 7 { + if action == OE_Restrict { // var tFrom Token at bp+80, 16 var pRaise uintptr (*Token)(unsafe.Pointer(bp + 80 /* &tFrom */)).Fz = zFrom (*Token)(unsafe.Pointer(bp + 80 /* &tFrom */)).Fn = uint32(nFrom) - pRaise = Xsqlite3Expr(tls, db, 71, ts+6852 /* "FOREIGN KEY cons..." */) + pRaise = Xsqlite3Expr(tls, db, TK_RAISE, ts+6852 /* "FOREIGN KEY cons..." */) if pRaise != 0 { - (*Expr)(unsafe.Pointer(pRaise)).FaffExpr = int8(2) + (*Expr)(unsafe.Pointer(pRaise)).FaffExpr = OE_Abort } pSelect = Xsqlite3SelectNew(tls, pParse, Xsqlite3ExprListAppend(tls, pParse, uintptr(0), pRaise), @@ -102625,16 +101164,16 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, pTrigger = Xsqlite3DbMallocZero(tls, db, (uint64(((uint64(unsafe.Sizeof(Trigger{})) + uint64(unsafe.Sizeof(TriggerStep{}))) + uint64(nFrom)) + uint64(1)))) if pTrigger != 0 { - pStep = libc.AssignPtrUintptr(pTrigger+56 /* &.step_list */, (pTrigger + uintptr(1)*72)) - (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget = (pStep + uintptr(1)*96) + pStep = libc.AssignPtrUintptr(pTrigger+56 /* &.step_list */, (pTrigger + 1*72)) + (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget = (pStep + 1*96) libc.Xmemcpy(tls, (*TriggerStep)(unsafe.Pointer(pStep)).FzTarget, zFrom, uint64(nFrom)) - (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, 0x0001) - (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList = Xsqlite3ExprListDup(tls, db, pList, 0x0001) - (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, 0x0001) + (*TriggerStep)(unsafe.Pointer(pStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, EXPRDUP_REDUCE) + (*TriggerStep)(unsafe.Pointer(pStep)).FpExprList = Xsqlite3ExprListDup(tls, db, pList, EXPRDUP_REDUCE) + (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, EXPRDUP_REDUCE) if pWhen != 0 { - pWhen = Xsqlite3PExpr(tls, pParse, 19, pWhen, uintptr(0)) - (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = Xsqlite3ExprDup(tls, db, pWhen, 0x0001) + pWhen = Xsqlite3PExpr(tls, pParse, TK_NOT, pWhen, uintptr(0)) + (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = Xsqlite3ExprDup(tls, db, pWhen, EXPRDUP_REDUCE) } } @@ -102657,19 +101196,18 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, } switch action { - case 7: - (*TriggerStep)(unsafe.Pointer(pStep)).Fop = U8(136) + case OE_Restrict: + (*TriggerStep)(unsafe.Pointer(pStep)).Fop = TK_SELECT break fallthrough - case 10: + case OE_Cascade: if !(pChanges != 0) { - (*TriggerStep)(unsafe.Pointer(pStep)).Fop = U8(126) + (*TriggerStep)(unsafe.Pointer(pStep)).Fop = TK_DELETE break } - /* no break */ fallthrough default: - (*TriggerStep)(unsafe.Pointer(pStep)).Fop = U8(127) + (*TriggerStep)(unsafe.Pointer(pStep)).Fop = TK_UPDATE } (*TriggerStep)(unsafe.Pointer(pStep)).FpTrig = pTrigger (*Trigger)(unsafe.Pointer(pTrigger)).FpSchema = (*Table)(unsafe.Pointer(pTab)).FpSchema @@ -102677,9 +101215,9 @@ func fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + uintptr(iAction)*8)) = pTrigger (*Trigger)(unsafe.Pointer(pTrigger)).Fop = func() uint8 { if pChanges != 0 { - return uint8(127) + return TK_UPDATE } - return uint8(126) + return TK_DELETE }() } @@ -102693,13 +101231,13 @@ func Xsqlite3FkActions(tls *libc.TLS, pParse uintptr, pTab uintptr, pChanges uin // refer to table pTab. If there is an action associated with the FK // for this operation (either update or delete), invoke the associated // trigger sub-program. - if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00004000)) != 0 { + if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_ForeignKeys) != 0 { var pFKey uintptr // Iterator variable for pFKey = Xsqlite3FkReferences(tls, pTab); pFKey != 0; pFKey = (*FKey)(unsafe.Pointer(pFKey)).FpNextTo { if (aChange == uintptr(0)) || (fkParentIsModified(tls, pTab, pFKey, aChange, bChngRowid) != 0) { var pAct uintptr = fkActionTrigger(tls, pParse, pTab, pFKey, pChanges) if pAct != 0 { - Xsqlite3CodeRowTriggerDirect(tls, pParse, pAct, pTab, regOld, 2, 0) + Xsqlite3CodeRowTriggerDirect(tls, pParse, pAct, pTab, regOld, OE_Abort, 0) } } } @@ -102738,8 +101276,8 @@ func Xsqlite3FkDelete(tls *libc.TLS, db uintptr, pTab uintptr) { /* sqlite3.c:12 // classified as either immediate or deferred. // Delete any triggers created to implement actions for this FK. - fkTriggerDelete(tls, db, *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + uintptr(0)*8))) - fkTriggerDelete(tls, db, *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + uintptr(1)*8))) + fkTriggerDelete(tls, db, *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */)))) + fkTriggerDelete(tls, db, *(*uintptr)(unsafe.Pointer((pFKey + 48 /* &.apTrigger */) + 1*8))) pNext = (*FKey)(unsafe.Pointer(pFKey)).FpNextFrom Xsqlite3DbFree(tls, db, pFKey) @@ -102779,12 +101317,12 @@ func Xsqlite3OpenTable(tls *libc.TLS, pParse uintptr, iCur int32, iDb int32, pTa Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, func() uint8 { - if opcode == 97 { + if opcode == OP_OpenWrite { return uint8(1) } return uint8(0) }(), (*Table)(unsafe.Pointer(pTab)).FzName) - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { Xsqlite3VdbeAddOp4Int(tls, v, opcode, iCur, int32((*Table)(unsafe.Pointer(pTab)).Ftnum), iDb, int32((*Table)(unsafe.Pointer(pTab)).FnNVCol)) Xsqlite3VdbeComment(tls, v, ts+824 /* "%s" */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName)) } else { @@ -102836,16 +101374,16 @@ func Xsqlite3IndexAffinityStr(tls *libc.TLS, db uintptr, pIdx uintptr) uintptr { if int32(x) >= 0 { aff = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(x)*32)).Faffinity } else if int32(x) == (-1) { - aff = int8(0x44) + aff = SQLITE_AFF_INTEGER } else { aff = Xsqlite3ExprAffinity(tls, (*ExprList_item)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FaColExpr+8 /* &.a */)+uintptr(n)*32)).FpExpr) } - if int32(aff) < 0x41 { - aff = int8(0x41) + if int32(aff) < SQLITE_AFF_BLOB { + aff = SQLITE_AFF_BLOB } - if int32(aff) > 0x43 { - aff = int8(0x43) + if int32(aff) > SQLITE_AFF_NUMERIC { + aff = SQLITE_AFF_NUMERIC } *(*int8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FzColAff + uintptr(n))) = aff } @@ -102887,11 +101425,11 @@ func Xsqlite3TableAffinity(tls *libc.TLS, v uintptr, pTab uintptr, iReg int32) { for i = libc.AssignInt32(&j, 0); i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) == 0 { + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) == 0 { *(*int8)(unsafe.Pointer(zColAff + uintptr(libc.PostIncInt32(&j, 1)))) = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32)).Faffinity } } - for ok := true; ok; ok = ((j >= 0) && (int32(*(*int8)(unsafe.Pointer(zColAff + uintptr(j)))) <= 0x41)) { + for ok := true; ok; ok = ((j >= 0) && (int32(*(*int8)(unsafe.Pointer(zColAff + uintptr(j)))) <= SQLITE_AFF_BLOB)) { *(*int8)(unsafe.Pointer(zColAff + uintptr(libc.PostDecInt32(&j, 1)))) = int8(0) } (*Table)(unsafe.Pointer(pTab)).FzColAff = zColAff @@ -102900,7 +101438,7 @@ func Xsqlite3TableAffinity(tls *libc.TLS, v uintptr, pTab uintptr, iReg int32) { i = (int32(libc.Xstrlen(tls, zColAff) & uint64(0x3fffffff))) if i != 0 { if iReg != 0 { - Xsqlite3VdbeAddOp4(tls, v, 90, iReg, i, 0, zColAff, i) + Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, iReg, i, 0, zColAff, i) } else { Xsqlite3VdbeChangeP4(tls, v, -1, zColAff, i) } @@ -102925,7 +101463,7 @@ func readsTable(tls *libc.TLS, p uintptr, iDb int32, pTab uintptr) int32 { /* sq for i = 1; i < iEnd; i++ { var pOp uintptr = Xsqlite3VdbeGetOp(tls, v, i) - if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 96) && ((*VdbeOp)(unsafe.Pointer(pOp)).Fp3 == iDb) { + if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_OpenRead) && ((*VdbeOp)(unsafe.Pointer(pOp)).Fp3 == iDb) { var pIndex uintptr var tnum Pgno = Pgno((*VdbeOp)(unsafe.Pointer(pOp)).Fp2) if tnum == (*Table)(unsafe.Pointer(pTab)).Ftnum { @@ -102937,7 +101475,7 @@ func readsTable(tls *libc.TLS, p uintptr, iDb int32, pTab uintptr) int32 { /* sq } } } - if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 165) && (*(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) == pVTab) { + if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_VOpen) && (*(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) == pVTab) { return 1 } @@ -102948,11 +101486,11 @@ func readsTable(tls *libc.TLS, p uintptr, iDb int32, pTab uintptr) int32 { /* sq // This walker callback will compute the union of colFlags flags for all // referenced columns in a CHECK constraint or generated column expression. func exprColumnFlagUnion(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:120760:12: */ - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) && (int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) >= 0) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) && (int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) >= 0) { *(*U16)(unsafe.Pointer(pWalker + 36 /* &.eCode */)) |= U16((int32((*Column)(unsafe.Pointer((*Table1)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)))).FaCol + uintptr((*Expr)(unsafe.Pointer(pExpr)).FiColumn)*32)).FcolFlags))) } - return 0 + return WRC_Continue } // All regular columns for table pTab have been puts into registers @@ -102974,8 +101512,8 @@ func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore in // Before computing generated columns, first go through and make sure // that appropriate affinity has been applied to the regular columns Xsqlite3TableAffinity(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, pTab, iRegStore) - if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0040)) != U32(0)) && - (int32((*VdbeOp)(unsafe.Pointer((libc.AssignUintptr(&pOp, Xsqlite3VdbeGetOp(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, -1))))).Fopcode) == 90) { + if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasStored) != U32(0)) && + (int32((*VdbeOp)(unsafe.Pointer((libc.AssignUintptr(&pOp, Xsqlite3VdbeGetOp(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, -1))))).Fopcode) == OP_Affinity) { // Change the OP_Affinity argument to '@' (NONE) for all stored // columns. '@' is the no-op affinity and those columns have not // yet been computed. @@ -102984,11 +101522,11 @@ func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore in var zP4 uintptr = *(*uintptr)(unsafe.Pointer(pOp + 16 /* &.p4 */)) for ii = libc.AssignInt32(&jj, 0); *(*int8)(unsafe.Pointer(zP4 + uintptr(jj))) != 0; ii++ { - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(ii)*32)).FcolFlags) & 0x0020) != 0 { + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(ii)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0 { continue } - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(ii)*32)).FcolFlags) & 0x0040) != 0 { - *(*int8)(unsafe.Pointer(zP4 + uintptr(jj))) = int8(0x40) + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(ii)*32)).FcolFlags) & COLFLAG_STORED) != 0 { + *(*int8)(unsafe.Pointer(zP4 + uintptr(jj))) = SQLITE_AFF_NONE } jj++ } @@ -102998,9 +101536,9 @@ func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore in // this is a two-pass algorithm. On the first pass, mark all generated // columns as "not available". for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0060) != 0 { + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_GENERATED) != 0 { - *(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32 + 28 /* &.colFlags */)) |= U16((0x0080)) + *(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32 + 28 /* &.colFlags */)) |= U16((COLFLAG_NOTAVAIL)) } } @@ -103021,13 +101559,13 @@ func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore in pRedo = uintptr(0) for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { var pCol uintptr = ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32) - if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0080) != 0 { + if (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_NOTAVAIL) != 0 { var x int32 - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((0x0100)) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((COLFLAG_BUSY)) (*Walker)(unsafe.Pointer(bp + 8 /* &w */)).FeCode = U16(0) Xsqlite3WalkExpr(tls, bp+8 /* &w */, (*Column)(unsafe.Pointer(pCol)).FpDflt) - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0100))) - if (int32((*Walker)(unsafe.Pointer(bp+8 /* &w */)).FeCode) & 0x0080) != 0 { + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(COLFLAG_BUSY))) + if (int32((*Walker)(unsafe.Pointer(bp+8 /* &w */)).FeCode) & COLFLAG_NOTAVAIL) != 0 { pRedo = pCol continue } @@ -103035,7 +101573,7 @@ func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore in x = (int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(i))) + iRegStore) Xsqlite3ExprCodeGeneratedColumn(tls, pParse, pCol, x) - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0080))) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(COLFLAG_NOTAVAIL))) } } } @@ -103069,8 +101607,8 @@ func Xsqlite3ComputeGeneratedColumns(tls *libc.TLS, pParse uintptr, iRegStore in func autoIncBegin(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr) int32 { /* sqlite3.c:120894:12: */ var memId int32 = 0 // Register holding maximum rowid - if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0008)) != U32(0)) && - (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags & U32(0x0004)) == U32(0)) { + if (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Autoincrement) != U32(0)) && + (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags & DBFLAG_Vacuum) == U32(0)) { var pToplevel uintptr = func() uintptr { if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 { return (*Parse)(unsafe.Pointer(pParse)).FpToplevel @@ -103084,11 +101622,11 @@ func autoIncBegin(tls *libc.TLS, pParse uintptr, iDb int32, pTab uintptr) int32 // rowid table with exactly two columns. // Ticket d8dc2b3a58cd5dc2918a1d4acb 2018-05-23 if (((pSeqTab == uintptr(0)) || - !(((*Table)(unsafe.Pointer((pSeqTab))).FtabFlags & U32(0x0080)) == U32(0))) || + !(((*Table)(unsafe.Pointer((pSeqTab))).FtabFlags & TF_WithoutRowid) == U32(0))) || ((*Table)(unsafe.Pointer(pSeqTab)).FnModuleArg != 0)) || (int32((*Table)(unsafe.Pointer(pSeqTab)).FnCol) != 2) { (*Parse)(unsafe.Pointer(pParse)).FnErr++ - (*Parse)(unsafe.Pointer(pParse)).Frc = (11 | (int32(2) << 8)) + (*Parse)(unsafe.Pointer(pParse)).Frc = (SQLITE_CORRUPT | (int32(2) << 8)) return 0 } @@ -103132,24 +101670,24 @@ func Xsqlite3AutoincrementBegin(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:12 pDb = ((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*AutoincInfo)(unsafe.Pointer(p)).FiDb)*32) memId = (*AutoincInfo)(unsafe.Pointer(p)).FregCtr - Xsqlite3OpenTable(tls, pParse, 0, (*AutoincInfo)(unsafe.Pointer(p)).FiDb, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab, 96) + Xsqlite3OpenTable(tls, pParse, 0, (*AutoincInfo)(unsafe.Pointer(p)).FiDb, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab, OP_OpenRead) Xsqlite3VdbeLoadString(tls, v, (memId - 1), (*Table)(unsafe.Pointer((*AutoincInfo)(unsafe.Pointer(p)).FpTab)).FzName) aOp = Xsqlite3VdbeAddOpList(tls, v, (int32(uint64(unsafe.Sizeof(autoInc)) / uint64(unsafe.Sizeof(VdbeOpList{})))), uintptr(unsafe.Pointer(&autoInc)), iLn1) if aOp == uintptr(0) { break } - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*32)).Fp2 = memId - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*32)).Fp3 = (memId + 2) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(2)*32)).Fp3 = memId - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*32)).Fp1 = (memId - 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*32)).Fp3 = memId - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*32)).Fp5 = U16(0x10) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(4)*32)).Fp2 = (memId + 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(5)*32)).Fp3 = memId - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(6)*32)).Fp1 = memId - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(7)*32)).Fp2 = (memId + 2) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(7)*32)).Fp1 = memId - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(10)*32)).Fp2 = memId + (*VdbeOp)(unsafe.Pointer(aOp)).Fp2 = memId + (*VdbeOp)(unsafe.Pointer(aOp)).Fp3 = (memId + 2) + (*VdbeOp)(unsafe.Pointer(aOp + 2*32)).Fp3 = memId + (*VdbeOp)(unsafe.Pointer(aOp + 3*32)).Fp1 = (memId - 1) + (*VdbeOp)(unsafe.Pointer(aOp + 3*32)).Fp3 = memId + (*VdbeOp)(unsafe.Pointer(aOp + 3*32)).Fp5 = SQLITE_JUMPIFNULL + (*VdbeOp)(unsafe.Pointer(aOp + 4*32)).Fp2 = (memId + 1) + (*VdbeOp)(unsafe.Pointer(aOp + 5*32)).Fp3 = memId + (*VdbeOp)(unsafe.Pointer(aOp + 6*32)).Fp1 = memId + (*VdbeOp)(unsafe.Pointer(aOp + 7*32)).Fp2 = (memId + 2) + (*VdbeOp)(unsafe.Pointer(aOp + 7*32)).Fp1 = memId + (*VdbeOp)(unsafe.Pointer(aOp + 10*32)).Fp2 = memId if (*Parse)(unsafe.Pointer(pParse)).FnTab == 0 { (*Parse)(unsafe.Pointer(pParse)).FnTab = 1 } @@ -103158,66 +101696,18 @@ func Xsqlite3AutoincrementBegin(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:12 var iLn1 int32 = 0 /* sqlite3.c:120957:22 */ var autoInc = [12]VdbeOpList{ - /* 0 */ { - Fopcode: U8(72), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 1 */ { - Fopcode: U8(37), - Fp1: int8(0), - Fp2: int8(10), - Fp3: int8(0)}, - /* 2 */ { - Fopcode: U8(89), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 3 */ { - Fopcode: U8(52), - Fp1: int8(0), - Fp2: int8(9), - Fp3: int8(0)}, - /* 4 */ { - Fopcode: U8(127), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 5 */ { - Fopcode: U8(89), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(0)}, - /* 6 */ { - Fopcode: U8(82), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 7 */ { - Fopcode: U8(77), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 8 */ { - Fopcode: U8(11), - Fp1: int8(0), - Fp2: int8(11), - Fp3: int8(0)}, - /* 9 */ { - Fopcode: U8(5), - Fp1: int8(0), - Fp2: int8(2), - Fp3: int8(0)}, - /* 10 */ { - Fopcode: U8(69), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 11 */ { - Fopcode: U8(116), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, + /* 0 */ {Fopcode: OP_Null}, + /* 1 */ {Fopcode: OP_Rewind, Fp2: int8(10)}, + /* 2 */ {Fopcode: OP_Column}, + /* 3 */ {Fopcode: OP_Ne, Fp2: int8(9)}, + /* 4 */ {Fopcode: OP_Rowid}, + /* 5 */ {Fopcode: OP_Column, Fp2: int8(1)}, + /* 6 */ {Fopcode: OP_AddImm}, + /* 7 */ {Fopcode: OP_Copy}, + /* 8 */ {Fopcode: OP_Goto, Fp2: int8(11)}, + /* 9 */ {Fopcode: OP_Next, Fp2: int8(2)}, + /* 10 */ {Fopcode: OP_Integer}, + /* 11 */ {Fopcode: OP_Close}, } /* sqlite3.c:120958:29 */ // Update the maximum rowid for an autoincrement calculation. @@ -103228,7 +101718,7 @@ var autoInc = [12]VdbeOpList{ // memory cell is updated. func autoIncStep(tls *libc.TLS, pParse uintptr, memId int32, regRowid int32) { /* sqlite3.c:121004:13: */ if memId > 0 { - Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, 151, memId, regRowid) + Xsqlite3VdbeAddOp2(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, OP_MemMax, memId, regRowid) } } @@ -103250,51 +101740,31 @@ func autoIncrementEnd(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:121017:29: * iRec = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 55, (memId + 2), (Xsqlite3VdbeCurrentAddr(tls, v) + 7), memId) + Xsqlite3VdbeAddOp3(tls, v, OP_Le, (memId + 2), (Xsqlite3VdbeCurrentAddr(tls, v) + 7), memId) - Xsqlite3OpenTable(tls, pParse, 0, (*AutoincInfo)(unsafe.Pointer(p)).FiDb, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab, 97) + Xsqlite3OpenTable(tls, pParse, 0, (*AutoincInfo)(unsafe.Pointer(p)).FiDb, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab, OP_OpenWrite) aOp = Xsqlite3VdbeAddOpList(tls, v, (int32(uint64(unsafe.Sizeof(autoIncEnd)) / uint64(unsafe.Sizeof(VdbeOpList{})))), uintptr(unsafe.Pointer(&autoIncEnd)), iLn2) if aOp == uintptr(0) { break } - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*32)).Fp1 = (memId + 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(1)*32)).Fp2 = (memId + 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(2)*32)).Fp1 = (memId - 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(2)*32)).Fp3 = iRec - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*32)).Fp2 = iRec - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*32)).Fp3 = (memId + 1) - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(3)*32)).Fp5 = U16(0x08) + (*VdbeOp)(unsafe.Pointer(aOp)).Fp1 = (memId + 1) + (*VdbeOp)(unsafe.Pointer(aOp + 1*32)).Fp2 = (memId + 1) + (*VdbeOp)(unsafe.Pointer(aOp + 2*32)).Fp1 = (memId - 1) + (*VdbeOp)(unsafe.Pointer(aOp + 2*32)).Fp3 = iRec + (*VdbeOp)(unsafe.Pointer(aOp + 3*32)).Fp2 = iRec + (*VdbeOp)(unsafe.Pointer(aOp + 3*32)).Fp3 = (memId + 1) + (*VdbeOp)(unsafe.Pointer(aOp + 3*32)).Fp5 = OPFLAG_APPEND Xsqlite3ReleaseTempReg(tls, pParse, iRec) } } var iLn2 int32 = 0 /* sqlite3.c:121024:22 */ var autoIncEnd = [5]VdbeOpList{ - /* 0 */ { - Fopcode: U8(51), - Fp1: int8(0), - Fp2: int8(2), - Fp3: int8(0)}, - /* 1 */ { - Fopcode: U8(120), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 2 */ { - Fopcode: U8(91), - Fp1: int8(0), - Fp2: int8(2), - Fp3: int8(0)}, - /* 3 */ { - Fopcode: U8(121), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - /* 4 */ { - Fopcode: U8(116), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, + /* 0 */ {Fopcode: OP_NotNull, Fp2: int8(2)}, + /* 1 */ {Fopcode: OP_NewRowid}, + /* 2 */ {Fopcode: OP_MakeRecord, Fp2: int8(2)}, + /* 3 */ {Fopcode: OP_Insert}, + /* 4 */ {Fopcode: OP_Close}, } /* sqlite3.c:121025:29 */ func Xsqlite3AutoincrementEnd(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:121054:21: */ @@ -103501,7 +101971,7 @@ __1: // If the Select object is really just a simple VALUES() list with a // single row (the common case) then keep that one row of values // and discard the other (unused) parts of the pSelect object - if !(((pSelect != 0) && (((*Select)(unsafe.Pointer(pSelect)).FselFlags & U32(0x0000200)) != U32(0))) && ((*Select)(unsafe.Pointer(pSelect)).FpPrior == uintptr(0))) { + if !(((pSelect != 0) && (((*Select)(unsafe.Pointer(pSelect)).FselFlags & SF_Values) != U32(0))) && ((*Select)(unsafe.Pointer(pSelect)).FpPrior == uintptr(0))) { goto __2 } pList = (*Select)(unsafe.Pointer(pSelect)).FpEList @@ -103522,18 +101992,18 @@ __3: ; iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) - if !(Xsqlite3AuthCheck(tls, pParse, 18, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_INSERT, (*Table)(unsafe.Pointer(pTab)).FzName, uintptr(0), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) != 0) { goto __4 } goto insert_cleanup __4: ; - withoutRowid = libc.BoolUint8(!(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) + withoutRowid = libc.BoolUint8(!(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) // Figure out if we have any triggers and if the table being // inserted into is a view - pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, 125, uintptr(0), bp+88 /* &tmask */) + pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, TK_INSERT, uintptr(0), bp+88 /* &tmask */) isView = (libc.Bool32((*Table)(unsafe.Pointer(pTab)).FpSelect != uintptr(0))) // If pTab is really a view, make sure it has been initialized. @@ -103620,7 +102090,7 @@ __10: // order. This enables an optimization that avoids shuffling the // columns into storage order. False negatives are harmless, // but false positives will cause database corruption. - bIdListInOrder = (U8(libc.Bool32(((*Table)(unsafe.Pointer(pTab)).FtabFlags & (U32(0x0400 | 0x0040))) == U32(0)))) + bIdListInOrder = (U8(libc.Bool32(((*Table)(unsafe.Pointer(pTab)).FtabFlags & (U32(TF_OOOHidden | TF_HasStored))) == U32(0)))) if !(pColumn != 0) { goto __11 } @@ -103663,7 +102133,7 @@ __22: ipkColumn = i __23: ; - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & (0x0040 | 0x0020)) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & (COLFLAG_STORED | COLFLAG_VIRTUAL)) != 0) { goto __24 } Xsqlite3ErrorMsg(tls, pParse, @@ -103720,8 +102190,8 @@ __11: regYield = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) addrTop = (Xsqlite3VdbeCurrentAddr(tls, v) + 1) - Xsqlite3VdbeAddOp3(tls, v, 13, regYield, 0, addrTop) - Xsqlite3SelectDestInit(tls, bp+96 /* &dest */, 13, regYield) + Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regYield, 0, addrTop) + Xsqlite3SelectDestInit(tls, bp+96 /* &dest */, SRT_Coroutine, regYield) (*SelectDest)(unsafe.Pointer(bp + 96 /* &dest */)).FiSdst = func() int32 { if bIdListInOrder != 0 { return regData @@ -103764,11 +102234,11 @@ __31: srcTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) regRec = Xsqlite3GetTempReg(tls, pParse) regTempRowid = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 100, srcTab, nColumn) - addrL = Xsqlite3VdbeAddOp1(tls, v, 14, (*SelectDest)(unsafe.Pointer(bp+96 /* &dest */)).FiSDParm) - Xsqlite3VdbeAddOp3(tls, v, 91, regFromSelect, nColumn, regRec) - Xsqlite3VdbeAddOp2(tls, v, 120, srcTab, regTempRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, srcTab, regRec, regTempRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, srcTab, nColumn) + addrL = Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(bp+96 /* &dest */)).FiSDParm) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regFromSelect, nColumn, regRec) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, srcTab, regTempRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, srcTab, regRec, regTempRowid) Xsqlite3VdbeGoto(tls, v, addrL) Xsqlite3VdbeJumpHere(tls, v, addrL) Xsqlite3ReleaseTempReg(tls, pParse, regRec) @@ -103806,7 +102276,7 @@ __29: goto __36 } ipkColumn = int32((*Table)(unsafe.Pointer(pTab)).FiPKey) - if !((ipkColumn >= 0) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != U32(0))) { + if !((ipkColumn >= 0) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != U32(0))) { goto __37 } @@ -103815,7 +102285,7 @@ __38: if !(i >= 0) { goto __40 } - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0060) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_GENERATED) != 0) { goto __41 } @@ -103841,7 +102311,7 @@ __42: if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) { goto __44 } - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0062) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_NOINSERT) != 0) { goto __45 } nHidden++ @@ -103878,7 +102348,7 @@ __47: goto __48 } regRowCount = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regRowCount) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regRowCount) __48: ; @@ -103886,7 +102356,7 @@ __48: if !(!(isView != 0)) { goto __49 } - nIdx = Xsqlite3OpenTableAndIndices(tls, pParse, pTab, 97, uint8(0), -1, uintptr(0), + nIdx = Xsqlite3OpenTableAndIndices(tls, pParse, pTab, OP_OpenWrite, uint8(0), -1, uintptr(0), bp+192 /* &iDataCur */, bp+196 /* &iIdxCur */) aRegIdx = Xsqlite3DbMallocRawNN(tls, db, (uint64(uint64(unsafe.Sizeof(int32(0))) * (uint64(nIdx + 2))))) if !(aRegIdx == uintptr(0)) { @@ -103939,7 +102409,7 @@ __56: goto insert_cleanup __57: ; - (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FiCursor = *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)) + (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FiCursor = *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)) (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc = pTabList (*Upsert)(unsafe.Pointer(pUpsert)).FregData = regData (*Upsert)(unsafe.Pointer(pUpsert)).FiDataCur = *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)) @@ -103965,7 +102435,7 @@ __54: // transfer values form intermediate table into
    // end loop // D: ... - addrInsTop = Xsqlite3VdbeAddOp1(tls, v, 37, srcTab) + addrInsTop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, srcTab) addrCont = Xsqlite3VdbeCurrentAddr(tls, v) goto __60 __59: @@ -103980,7 +102450,7 @@ __59: // goto C // D: ... - addrInsTop = libc.AssignInt32(&addrCont, Xsqlite3VdbeAddOp1(tls, v, 14, (*SelectDest)(unsafe.Pointer(bp+96 /* &dest */)).FiSDParm)) + addrInsTop = libc.AssignInt32(&addrCont, Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(bp+96 /* &dest */)).FiSDParm)) if !(ipkColumn >= 0) { goto __62 @@ -103988,7 +102458,7 @@ __59: // tag-20191021-001: If the INTEGER PRIMARY KEY is being generated by the // SELECT, go ahead and copy the value into the rowid slot now, so that // the value does not get overwritten by a NULL at tag-20191021-002. - Xsqlite3VdbeAddOp2(tls, v, 77, (regFromSelect + ipkColumn), regRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, (regFromSelect + ipkColumn), regRowid) __62: ; __61: @@ -104017,15 +102487,15 @@ __63: // using the rowid. So put a NULL in the IPK slot of the record to avoid // using excess space. The file format definition requires this extra // NULL - we cannot optimize further by skipping the column completely - Xsqlite3VdbeAddOp1(tls, v, 73, iRegStore) + Xsqlite3VdbeAddOp1(tls, v, OP_SoftNull, iRegStore) goto __64 __66: ; - if !(((libc.AssignUint32(&colFlags, U32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags))) & U32(0x0062)) != U32(0)) { + if !(((libc.AssignUint32(&colFlags, U32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags))) & COLFLAG_NOINSERT) != U32(0)) { goto __67 } nHidden++ - if !((colFlags & U32(0x0020)) != U32(0)) { + if !((colFlags & COLFLAG_VIRTUAL) != U32(0)) { goto __68 } // Virtual columns do not participate in OP_MakeRecord. So back up @@ -104035,17 +102505,17 @@ __66: goto __64 goto __69 __68: - if !((colFlags & U32(0x0040)) != U32(0)) { + if !((colFlags & COLFLAG_STORED) != U32(0)) { goto __70 } // Stored columns are computed later. But if there are BEFORE // triggers, the slots used for stored columns will be OP_Copy-ed // to a second block of registers, so the register needs to be // initialized to NULL to avoid an uninitialized register read - if !((*(*int32)(unsafe.Pointer(bp + 88 /* tmask */)) & 1) != 0) { + if !((*(*int32)(unsafe.Pointer(bp + 88 /* tmask */)) & TRIGGER_BEFORE) != 0) { goto __72 } - Xsqlite3VdbeAddOp1(tls, v, 73, iRegStore) + Xsqlite3VdbeAddOp1(tls, v, OP_SoftNull, iRegStore) __72: ; goto __64 @@ -104110,7 +102580,7 @@ __75: if !(useTempTable != 0) { goto __82 } - Xsqlite3VdbeAddOp3(tls, v, 89, srcTab, k, iRegStore) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, srcTab, k, iRegStore) goto __83 __82: if !(pSelect != 0) { @@ -104119,7 +102589,7 @@ __82: if !(regFromSelect != regData) { goto __86 } - Xsqlite3VdbeAddOp2(tls, v, 78, (regFromSelect + k), iRegStore) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, (regFromSelect + k), iRegStore) __86: ; goto __85 @@ -104140,7 +102610,7 @@ __65: // Run the BEFORE and INSTEAD OF triggers, if there are any endOfLoop = Xsqlite3VdbeMakeLabel(tls, pParse) - if !((*(*int32)(unsafe.Pointer(bp + 88 /* tmask */)) & 1) != 0) { + if !((*(*int32)(unsafe.Pointer(bp + 88 /* tmask */)) & TRIGGER_BEFORE) != 0) { goto __87 } regCols = Xsqlite3GetTempRange(tls, pParse, (int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 1)) @@ -104153,24 +102623,24 @@ __65: if !(ipkColumn < 0) { goto __88 } - Xsqlite3VdbeAddOp2(tls, v, 69, -1, regCols) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, -1, regCols) goto __89 __88: ; if !(useTempTable != 0) { goto __90 } - Xsqlite3VdbeAddOp3(tls, v, 89, srcTab, ipkColumn, regCols) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, srcTab, ipkColumn, regCols) goto __91 __90: ; // Otherwise useTempTable is true Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(ipkColumn)*32)).FpExpr, regCols) __91: ; - addr1 = Xsqlite3VdbeAddOp1(tls, v, 51, regCols) - Xsqlite3VdbeAddOp2(tls, v, 69, -1, regCols) + addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, regCols) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, -1, regCols) Xsqlite3VdbeJumpHere(tls, v, addr1) - Xsqlite3VdbeAddOp1(tls, v, 15, regCols) + Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, regCols) __89: ; @@ -104179,13 +102649,13 @@ __89: // Copy the new data already generated. - Xsqlite3VdbeAddOp3(tls, v, 77, (regRowid + 1), (regCols + 1), (int32((*Table)(unsafe.Pointer(pTab)).FnNVCol) - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, (regRowid + 1), (regCols + 1), (int32((*Table)(unsafe.Pointer(pTab)).FnNVCol) - 1)) // Compute the new value for generated columns after all other // columns have already been computed. This must be done after // computing the ROWID in case one of the generated columns // refers to the ROWID. - if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != 0) { + if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != 0) { goto __92 } @@ -104205,7 +102675,7 @@ __93: ; // Fire BEFORE or INSTEAD OF triggers - Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, 125, uintptr(0), 1, + Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, TK_INSERT, uintptr(0), TRIGGER_BEFORE, pTab, ((regCols - int32((*Table)(unsafe.Pointer(pTab)).FnCol)) - 1), onError, endOfLoop) Xsqlite3ReleaseTempRange(tls, pParse, regCols, (int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 1)) @@ -104219,7 +102689,7 @@ __87: goto __95 } // The row that the VUpdate opcode will delete: none - Xsqlite3VdbeAddOp2(tls, v, 72, 0, regIns) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regIns) __95: ; if !(ipkColumn >= 0) { @@ -104229,7 +102699,7 @@ __95: if !(useTempTable != 0) { goto __98 } - Xsqlite3VdbeAddOp3(tls, v, 89, srcTab, ipkColumn, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, srcTab, ipkColumn, regRowid) goto __99 __98: if !(pSelect != 0) { @@ -104239,10 +102709,10 @@ __98: goto __101 __100: pIpk = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(ipkColumn)*32)).FpExpr - if !((int32((*Expr)(unsafe.Pointer(pIpk)).Fop) == 119) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0)) { + if !((int32((*Expr)(unsafe.Pointer(pIpk)).Fop) == TK_NULL) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0)) { goto __102 } - Xsqlite3VdbeAddOp3(tls, v, 120, *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)), regRowid, regAutoinc) + Xsqlite3VdbeAddOp3(tls, v, OP_NewRowid, *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)), regRowid, regAutoinc) appendFlag = U8(1) goto __103 __102: @@ -104261,16 +102731,16 @@ __99: if !(!((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0)) { goto __105 } - addr11 = Xsqlite3VdbeAddOp1(tls, v, 51, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 120, *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)), regRowid, regAutoinc) + addr11 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_NewRowid, *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)), regRowid, regAutoinc) Xsqlite3VdbeJumpHere(tls, v, addr11) goto __106 __105: addr11 = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp2(tls, v, 50, regRowid, (addr11 + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regRowid, (addr11 + 2)) __106: ; - Xsqlite3VdbeAddOp1(tls, v, 15, regRowid) + Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, regRowid) __104: ; goto __97 @@ -104278,10 +102748,10 @@ __96: if !(((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) || (withoutRowid != 0)) { goto __107 } - Xsqlite3VdbeAddOp2(tls, v, 72, 0, regRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regRowid) goto __108 __107: - Xsqlite3VdbeAddOp3(tls, v, 120, *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)), regRowid, regAutoinc) + Xsqlite3VdbeAddOp3(tls, v, OP_NewRowid, *(*int32)(unsafe.Pointer(bp + 192 /* iDataCur */)), regRowid, regAutoinc) appendFlag = U8(1) __108: ; @@ -104293,7 +102763,7 @@ __97: // columns have already been computed. This must be done after // computing the ROWID in case one of the generated columns // is derived from the INTEGER PRIMARY KEY. - if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != 0) { + if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != 0) { goto __109 } Xsqlite3ComputeGeneratedColumns(tls, pParse, (regRowid + 1), pTab) @@ -104307,10 +102777,10 @@ __109: } pVTab = Xsqlite3GetVTable(tls, db, pTab) Xsqlite3VtabMakeWritable(tls, pParse, pTab) - Xsqlite3VdbeAddOp4(tls, v, 10, 1, (int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 2), regIns, pVTab, -12) + Xsqlite3VdbeAddOp4(tls, v, OP_VUpdate, 1, (int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 2), regIns, pVTab, -12) Xsqlite3VdbeChangeP5(tls, v, func() uint16 { - if onError == 11 { - return uint16(2) + if onError == OE_Default { + return OE_Abort } return uint16(onError) }()) @@ -104342,7 +102812,7 @@ __94: if !(regRowCount != 0) { goto __112 } - Xsqlite3VdbeAddOp2(tls, v, 82, regRowCount, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, regRowCount, 1) __112: ; @@ -104350,7 +102820,7 @@ __112: goto __113 } // Code AFTER triggers - Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, 125, uintptr(0), 2, + Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, TK_INSERT, uintptr(0), TRIGGER_AFTER, pTab, ((regData - 2) - int32((*Table)(unsafe.Pointer(pTab)).FnCol)), onError, endOfLoop) __113: ; @@ -104361,9 +102831,9 @@ __113: if !(useTempTable != 0) { goto __114 } - Xsqlite3VdbeAddOp2(tls, v, 5, srcTab, addrCont) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, srcTab, addrCont) Xsqlite3VdbeJumpHere(tls, v, addrInsTop) - Xsqlite3VdbeAddOp1(tls, v, 116, srcTab) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, srcTab) goto __115 __114: if !(pSelect != 0) { @@ -104393,9 +102863,9 @@ __117: if !(regRowCount != 0) { goto __118 } - Xsqlite3VdbeAddOp2(tls, v, 80, regRowCount, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, regRowCount, 1) Xsqlite3VdbeSetNumCols(tls, v, 1) - Xsqlite3VdbeSetColName(tls, v, 0, 0, ts+16736 /* "rows inserted" */, uintptr(0)) + Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, ts+16736 /* "rows inserted" */, uintptr(0)) __118: ; @@ -104420,17 +102890,17 @@ insert_cleanup: // expression node references any of the // columns that are being modifed by an UPDATE statement. func checkConstraintExprNode(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:121903:12: */ - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN { if int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) >= 0 { if *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) + uintptr((*Expr)(unsafe.Pointer(pExpr)).FiColumn)*4)) >= 0 { - *(*U16)(unsafe.Pointer(pWalker + 36 /* &.eCode */)) |= U16((0x01)) + *(*U16)(unsafe.Pointer(pWalker + 36 /* &.eCode */)) |= U16((CKCNSTRNT_COLUMN)) } } else { - *(*U16)(unsafe.Pointer(pWalker + 36 /* &.eCode */)) |= U16((0x02)) + *(*U16)(unsafe.Pointer(pWalker + 36 /* &.eCode */)) |= U16((CKCNSTRNT_ROWID)) } } - return 0 + return WRC_Continue } // pExpr is a CHECK constraint on a row that is being UPDATE-ed. The @@ -104461,7 +102931,7 @@ func Xsqlite3ExprReferencesUpdatedColumn(tls *libc.TLS, pExpr uintptr, aiChng ui Xsqlite3WalkExpr(tls, bp /* &w */, pExpr) if !(chngRowid != 0) { - *(*U16)(unsafe.Pointer(bp /* &w */ + 36 /* &.eCode */)) &= libc.Uint16FromInt32((^libc.Int32(0x02))) + *(*U16)(unsafe.Pointer(bp /* &w */ + 36 /* &.eCode */)) &= libc.Uint16FromInt32((libc.CplInt32(CKCNSTRNT_ROWID))) } return (libc.Bool32(int32((*Walker)(unsafe.Pointer(bp /* &w */)).FeCode) != 0)) @@ -104596,7 +103066,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // normal rowid tables. nPkField is the number of key fields in the // pPk index or 1 for a rowid table. In other words, nPkField is the // number of fields in the true primary key of the table. - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { pPk = uintptr(0) nPkField = 1 } else { @@ -104607,7 +103077,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // Record that this module has started // Test all NOT NULL constraints. - if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0800)) != 0 { + if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasNotNull) != 0 { var b2ndPass int32 = 0 // True if currently running 2nd pass var nSeenReplace int32 = 0 // Number of ON CONFLICT REPLACE operations var nGenerated int32 = 0 // Number of generated columns with NOT NULL @@ -104617,13 +103087,13 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt var pCol uintptr = ((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*32) // The column to check for NOT NULL var isGenerated int32 // non-zero if column is generated onError = int32((*Column)(unsafe.Pointer(pCol)).FnotNull) - if onError == 0 { + if onError == OE_None { continue } // No NOT NULL on this column if i == int32((*Table)(unsafe.Pointer(pTab)).FiPKey) { continue // ROWID is never NULL } - isGenerated = (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0060) + isGenerated = (int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_GENERATED) if (isGenerated != 0) && !(b2ndPass != 0) { nGenerated++ continue // Generated columns processed on 2nd pass @@ -104632,16 +103102,16 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // Do not check NOT NULL on columns that do not change continue } - if int32(overrideError) != 11 { + if int32(overrideError) != OE_Default { onError = int32(overrideError) - } else if onError == 11 { - onError = 2 + } else if onError == OE_Default { + onError = OE_Abort } - if onError == 5 { + if onError == OE_Replace { if (b2ndPass != 0) || // REPLACE becomes ABORT on the 2nd pass ((*Column)(unsafe.Pointer(pCol)).FpDflt == uintptr(0)) { - onError = 2 + onError = OE_Abort } else { } @@ -104651,9 +103121,9 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt iReg = ((int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(i))) + regNewData) + 1) switch onError { - case 5: + case OE_Replace: { - var addr1 int32 = Xsqlite3VdbeAddOp1(tls, v, 51, iReg) + var addr1 int32 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, iReg) nSeenReplace++ Xsqlite3ExprCodeCopy(tls, pParse, (*Column)(unsafe.Pointer(pCol)).FpDflt, iReg) @@ -104662,20 +103132,19 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt } fallthrough - case 2: + case OE_Abort: Xsqlite3MayAbort(tls, pParse) - /* no break */ fallthrough - case 1: + case OE_Rollback: fallthrough - case 3: + case OE_Fail: { var zMsg uintptr = Xsqlite3MPrintf(tls, db, ts+9997 /* "%s.%s" */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName, (*Column)(unsafe.Pointer(pCol)).FzName)) - Xsqlite3VdbeAddOp3(tls, v, 67, (19 | (int32(5) << 8)), + Xsqlite3VdbeAddOp3(tls, v, OP_HaltIfNull, (SQLITE_CONSTRAINT | (int32(5) << 8)), onError, iReg) Xsqlite3VdbeAppendP4(tls, v, zMsg, -7) - Xsqlite3VdbeChangeP5(tls, v, uint16(1)) + Xsqlite3VdbeChangeP5(tls, v, P5_ConstraintNotNull) break @@ -104684,7 +103153,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt default: { - Xsqlite3VdbeAddOp2(tls, v, 50, iReg, ignoreDest) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, iReg, ignoreDest) break @@ -104701,7 +103170,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt break } // Never need more than 2 passes b2ndPass = 1 - if (nSeenReplace > 0) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != U32(0)) { + if (nSeenReplace > 0) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != U32(0)) { // If any NOT NULL ON CONFLICT REPLACE constraints fired on the // first pass, recomputed values for all generated columns, as // those values might depend on columns affected by the REPLACE. @@ -104711,13 +103180,13 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt } // end if( has-not-null-constraints ) // Test all CHECK constraints - if ((*Table)(unsafe.Pointer(pTab)).FpCheck != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000200)) == uint64(0)) { + if ((*Table)(unsafe.Pointer(pTab)).FpCheck != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_IgnoreChecks) == uint64(0)) { var pCheck uintptr = (*Table)(unsafe.Pointer(pTab)).FpCheck (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = -(regNewData + 1) - if int32(overrideError) != 11 { + if int32(overrideError) != OE_Default { onError = int32(overrideError) } else { - onError = 2 + onError = OE_Abort } for i = 0; i < (*ExprList)(unsafe.Pointer(pCheck)).FnExpr; i++ { var allOk int32 @@ -104737,22 +103206,22 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt pCopy = Xsqlite3ExprDup(tls, db, pExpr, 0) if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) { - Xsqlite3ExprIfTrue(tls, pParse, pCopy, allOk, 0x10) + Xsqlite3ExprIfTrue(tls, pParse, pCopy, allOk, SQLITE_JUMPIFNULL) } Xsqlite3ExprDelete(tls, db, pCopy) - if onError == 4 { + if onError == OE_Ignore { Xsqlite3VdbeGoto(tls, v, ignoreDest) } else { var zName uintptr = (*ExprList_item)(unsafe.Pointer((pCheck + 8 /* &.a */) + uintptr(i)*32)).FzEName if zName == uintptr(0) { zName = (*Table)(unsafe.Pointer(pTab)).FzName } - if onError == 5 { - onError = 2 + if onError == OE_Replace { + onError = OE_Abort } // IMP: R-26383-51744 - Xsqlite3HaltConstraint(tls, pParse, (19 | (int32(1) << 8)), - onError, zName, int8(0), - uint8(3)) + Xsqlite3HaltConstraint(tls, pParse, (SQLITE_CONSTRAINT | (int32(1) << 8)), + onError, zName, P4_TRANSIENT, + P5_ConstraintCheck) } Xsqlite3VdbeResolveLabel(tls, v, allOk) } @@ -104792,12 +103261,12 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // An ON CONFLICT DO NOTHING clause, without a constraint-target. // Make all unique constraint resolution be OE_Ignore - overrideError = U8(4) + overrideError = OE_Ignore pUpsert = uintptr(0) } else if (libc.AssignUintptr(&pUpIdx, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx)) != uintptr(0) { // If the constraint-target uniqueness check must be run first. // Jump to that uniqueness check now - upsertJump = Xsqlite3VdbeAddOp0(tls, v, 11) + upsertJump = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) Xsqlite3VdbeComment(tls, v, ts+16750 /* "UPSERT constrain..." */, 0) } } @@ -104821,14 +103290,14 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // in a second pass. The addrRecheck and lblRecheckOk variables are // used to link together these tests which are separated from each other // in the generate bytecode. - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & (uint64(0x00002000 | 0x00004000))) == uint64(0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & (uint64(SQLITE_RecTriggers | SQLITE_ForeignKeys))) == uint64(0) { // There are not DELETE triggers nor FK constraints. No constraint // rechecks are needed. pTrigger = uintptr(0) regTrigCnt = 0 } else { - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00002000)) != 0 { - pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, 126, uintptr(0), uintptr(0)) + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_RecTriggers) != 0 { + pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, TK_DELETE, uintptr(0), uintptr(0)) regTrigCnt = (libc.Bool32((pTrigger != uintptr(0)) || (Xsqlite3FkRequired(tls, pParse, pTab, uintptr(0), 0) != 0))) } else { pTrigger = uintptr(0) @@ -104838,7 +103307,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // Replace triggers might exist. Allocate the counter and // initialize it to zero. regTrigCnt = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regTrigCnt) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regTrigCnt) Xsqlite3VdbeComment(tls, v, ts+16779 /* "trigger count" */, 0) lblRecheckOk = Xsqlite3VdbeMakeLabel(tls, pParse) addrRecheck = lblRecheckOk @@ -104852,18 +103321,18 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // Figure out what action to take in case of a rowid collision onError = int32((*Table)(unsafe.Pointer(pTab)).FkeyConf) - if int32(overrideError) != 11 { + if int32(overrideError) != OE_Default { onError = int32(overrideError) - } else if onError == 11 { - onError = 2 + } else if onError == OE_Default { + onError = OE_Abort } // figure out whether or not upsert applies in this case if (pUpsert != 0) && ((*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx == uintptr(0)) { if (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet == uintptr(0) { - onError = 4 // DO NOTHING is the same as INSERT OR IGNORE + onError = OE_Ignore // DO NOTHING is the same as INSERT OR IGNORE } else { - onError = 6 // DO UPDATE + onError = OE_Update // DO UPDATE } } @@ -104871,10 +103340,10 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // to some other UNIQUE constraint is FAIL or IGNORE, then we need // to defer the running of the rowid conflict checking until after // the UNIQUE constraints have run. - if ((onError == 5) && // IPK rule is REPLACE + if ((onError == OE_Replace) && // IPK rule is REPLACE (onError != int32(overrideError))) && // Rules for other contraints are different ((*Table)(unsafe.Pointer(pTab)).FpIndex != 0) { - ipkTop = (Xsqlite3VdbeAddOp0(tls, v, 11) + 1) + ipkTop = (Xsqlite3VdbeAddOp0(tls, v, OP_Goto) + 1) Xsqlite3VdbeComment(tls, v, ts+16793 /* "defer IPK REPLAC..." */, 0) } @@ -104882,8 +103351,8 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // pkChng!=0 does not mean that the rowid has changed, only that // it might have changed. Skip the conflict logic below if the rowid // is unchanged. - Xsqlite3VdbeAddOp3(tls, v, 53, regNewData, addrRowidOk, regOldData) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x90)) + Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regNewData, addrRowidOk, regOldData) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NOTNULL) } @@ -104891,21 +103360,20 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // the following conflict logic if it does not. Xsqlite3VdbeNoopComment(tls, v, ts+16822 /* "uniqueness check..." */, 0) - Xsqlite3VdbeAddOp3(tls, v, 32, iDataCur, addrRowidOk, regNewData) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, addrRowidOk, regNewData) switch onError { default: { - onError = 2 - /* no break */ + onError = OE_Abort } fallthrough - case 1: + case OE_Rollback: fallthrough - case 2: + case OE_Abort: fallthrough - case 3: + case OE_Fail: { Xsqlite3RowidConstraint(tls, pParse, onError, pTab) @@ -104913,7 +103381,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt } fallthrough - case 5: + case OE_Replace: { // If there are DELETE triggers on this table and the // recursive-triggers flag is set, call GenerateRowDelete() to @@ -104939,8 +103407,8 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt if regTrigCnt != 0 { Xsqlite3MultiWrite(tls, pParse) Xsqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, iDataCur, iIdxCur, - regNewData, int16(1), uint8(0), uint8(5), uint8(1), -1) - Xsqlite3VdbeAddOp2(tls, v, 82, regTrigCnt, 1) // incr trigger cnt + regNewData, int16(1), uint8(0), OE_Replace, uint8(1), -1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, regTrigCnt, 1) // incr trigger cnt nReplaceTrig++ } else { @@ -104948,7 +103416,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt // not modify the b-tree. It is more efficient to let the coming // OP_Insert replace the existing entry than it is to delete the // existing entry and then insert a new one. - Xsqlite3VdbeAddOp2(tls, v, 122, iDataCur, 0x40) + Xsqlite3VdbeAddOp2(tls, v, OP_Delete, iDataCur, OPFLAG_ISNOOP) Xsqlite3VdbeAppendP4(tls, v, pTab, -6) if (*Table)(unsafe.Pointer(pTab)).FpIndex != 0 { Xsqlite3MultiWrite(tls, pParse) @@ -104960,14 +103428,13 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt } fallthrough - case 6: + case OE_Update: { Xsqlite3UpsertDoUpdate(tls, pParse, pUpsert, pTab, uintptr(0), iDataCur) - /* no break */ } fallthrough - case 4: + case OE_Ignore: { Xsqlite3VdbeGoto(tls, v, ignoreDest) @@ -104977,7 +103444,7 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt } Xsqlite3VdbeResolveLabel(tls, v, addrRowidOk) if ipkTop != 0 { - ipkBottom = Xsqlite3VdbeAddOp0(tls, v, 11) + ipkBottom = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) Xsqlite3VdbeJumpHere(tls, v, (ipkTop - 1)) } } @@ -105021,10 +103488,10 @@ __1: // Skip partial indices for which the WHERE clause is not true if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(ix)*4))) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(ix)*4))) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = -(regNewData + 1) Xsqlite3ExprIfFalseDup(tls, pParse, (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere, addrUniqueOk, - 0x10) + SQLITE_JUMPIFNULL) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0 } @@ -105041,16 +103508,16 @@ __1: Xsqlite3VdbeComment(tls, v, ts+16886 /* "%s column %d" */, libc.VaList(bp+24, (*Index)(unsafe.Pointer(pIdx)).FzName, i)) } else if (iField == (-1)) || (iField == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) { x = regNewData - Xsqlite3VdbeAddOp2(tls, v, 79, x, (regIdx + i)) + Xsqlite3VdbeAddOp2(tls, v, OP_IntCopy, x, (regIdx + i)) Xsqlite3VdbeComment(tls, v, ts+10064 /* "rowid" */, 0) } else { x = ((int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(iField))) + regNewData) + 1) - Xsqlite3VdbeAddOp2(tls, v, 78, x, (regIdx + i)) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, x, (regIdx + i)) Xsqlite3VdbeComment(tls, v, ts+824 /* "%s" */, libc.VaList(bp+40, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iField)*32)).FzName)) } } - Xsqlite3VdbeAddOp3(tls, v, 91, regIdx, int32((*Index)(unsafe.Pointer(pIdx)).FnColumn), *(*int32)(unsafe.Pointer(aRegIdx + uintptr(ix)*4))) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regIdx, int32((*Index)(unsafe.Pointer(pIdx)).FnColumn), *(*int32)(unsafe.Pointer(aRegIdx + uintptr(ix)*4))) Xsqlite3VdbeComment(tls, v, ts+16899 /* "for %s" */, libc.VaList(bp+48, (*Index)(unsafe.Pointer(pIdx)).FzName)) // In an UPDATE operation, if this index is the PRIMARY KEY index @@ -105064,22 +103531,22 @@ __1: // Find out what action to take in case there is a uniqueness conflict onError = int32((*Index)(unsafe.Pointer(pIdx)).FonError) - if onError == 0 { + if onError == OE_None { Xsqlite3VdbeResolveLabel(tls, v, addrUniqueOk) goto __2 // pIdx is not a UNIQUE index } - if int32(overrideError) != 11 { + if int32(overrideError) != OE_Default { onError = int32(overrideError) - } else if onError == 11 { - onError = 2 + } else if onError == OE_Default { + onError = OE_Abort } // Figure out if the upsert clause applies to this index if pUpIdx == pIdx { if (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet == uintptr(0) { - onError = 4 // DO NOTHING is the same as INSERT OR IGNORE + onError = OE_Ignore // DO NOTHING is the same as INSERT OR IGNORE } else { - onError = 6 // DO UPDATE + onError = OE_Update // DO UPDATE } } @@ -105096,7 +103563,7 @@ __1: // Check to see if the new index entry will be unique - addrConflictCk = Xsqlite3VdbeAddOp4Int(tls, v, 28, iThisCur, addrUniqueOk, + addrConflictCk = Xsqlite3VdbeAddOp4Int(tls, v, OP_NoConflict, iThisCur, addrUniqueOk, regIdx, int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)) // Generate code to handle collisions @@ -105105,14 +103572,14 @@ __1: } else { regR = Xsqlite3GetTempRange(tls, pParse, nPkField) } - if (isUpdate != 0) || (onError == 5) { - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { - Xsqlite3VdbeAddOp2(tls, v, 134, iThisCur, regR) + if (isUpdate != 0) || (onError == OE_Replace) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { + Xsqlite3VdbeAddOp2(tls, v, OP_IdxRowid, iThisCur, regR) // Conflict only if the rowid of the existing index entry // is different from old-rowid if isUpdate != 0 { - Xsqlite3VdbeAddOp3(tls, v, 53, regR, addrUniqueOk, regOldData) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x90)) + Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regR, addrUniqueOk, regOldData) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NOTNULL) } } else { @@ -105123,7 +103590,7 @@ __1: for i = 0; i < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); i++ { x = int32(Xsqlite3TableColumnToIndex(tls, pIdx, *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))) - Xsqlite3VdbeAddOp3(tls, v, 89, iThisCur, x, (regR + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iThisCur, x, (regR + i)) Xsqlite3VdbeComment(tls, v, ts+9997 /* "%s.%s" */, libc.VaList(bp+56, (*Table)(unsafe.Pointer(pTab)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))*32)).FzName)) } } @@ -105136,9 +103603,9 @@ __1: // of the matched index row are different from the original PRIMARY // KEY values of this row before the update. var addrJump int32 = (Xsqlite3VdbeCurrentAddr(tls, v) + int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) - var op int32 = 52 + var op int32 = OP_Ne var regCmp int32 = func() int32 { - if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2 { + if (int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY { return regIdx } return regR @@ -105150,12 +103617,12 @@ __1: if i == (int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol) - 1) { addrJump = addrUniqueOk - op = 53 + op = OP_Eq } x = int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(x))) Xsqlite3VdbeAddOp4(tls, v, op, ((regOldData + 1) + x), addrJump, (regCmp + i), p4, -2) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x90)) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NOTNULL) } } @@ -105165,25 +103632,24 @@ __1: // Generate code that executes if the new index entry is not unique switch onError { - case 1: + case OE_Rollback: fallthrough - case 2: + case OE_Abort: fallthrough - case 3: + case OE_Fail: { Xsqlite3UniqueConstraint(tls, pParse, onError, pIdx) break } - case 6: + case OE_Update: { Xsqlite3UpsertDoUpdate(tls, pParse, pUpsert, pTab, pIdx, (iIdxCur + ix)) - /* no break */ } fallthrough - case 4: + case OE_Ignore: { Xsqlite3VdbeGoto(tls, v, ignoreDest) @@ -105201,24 +103667,24 @@ __1: nReplaceTrig++ } if (pTrigger != 0) && (isUpdate != 0) { - Xsqlite3VdbeAddOp1(tls, v, 159, iDataCur) + Xsqlite3VdbeAddOp1(tls, v, OP_CursorLock, iDataCur) } Xsqlite3GenerateRowDelete(tls, pParse, pTab, pTrigger, iDataCur, iIdxCur, - regR, int16(nPkField), uint8(0), uint8(5), + regR, int16(nPkField), uint8(0), OE_Replace, func() uint8 { if pIdx == pPk { - return uint8(1) + return ONEPASS_SINGLE } - return uint8(0) + return ONEPASS_OFF }(), iThisCur) if (pTrigger != 0) && (isUpdate != 0) { - Xsqlite3VdbeAddOp1(tls, v, 160, iDataCur) + Xsqlite3VdbeAddOp1(tls, v, OP_CursorUnlock, iDataCur) } if regTrigCnt != 0 { var addrBypass int32 // Jump destination to bypass recheck logic - Xsqlite3VdbeAddOp2(tls, v, 82, regTrigCnt, 1) // incr trigger cnt - addrBypass = Xsqlite3VdbeAddOp0(tls, v, 11) // Bypass recheck + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, regTrigCnt, 1) // incr trigger cnt + addrBypass = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) // Bypass recheck Xsqlite3VdbeComment(tls, v, ts+16906 /* "bypass recheck" */, 0) // Here we insert code that will be invoked after all constraint @@ -105229,7 +103695,7 @@ __1: if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { // Bypass the recheck if this partial index is not defined // for the current row - Xsqlite3VdbeAddOp2(tls, v, 50, (regIdx - 1), lblRecheckOk) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (regIdx - 1), lblRecheckOk) } // Copy the constraint check code from above, except change @@ -105242,10 +103708,10 @@ __1: // Hence, make a complete copy of the opcode, rather than using // a pointer to the opcode. *(*VdbeOp)(unsafe.Pointer(bp + 72 /* x */)) = *(*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, v, addrConflictCk))) - if int32((*VdbeOp)(unsafe.Pointer(bp+72 /* &x */)).Fopcode) != 134 { + if int32((*VdbeOp)(unsafe.Pointer(bp+72 /* &x */)).Fopcode) != OP_IdxRowid { var p2 int32 // New P2 value for copied conflict check opcode var zP4 uintptr - if (int32(Xsqlite3OpcodeProperty[(*VdbeOp)(unsafe.Pointer(bp+72 /* &x */)).Fopcode]) & 0x01) != 0 { + if (int32(Xsqlite3OpcodeProperty[(*VdbeOp)(unsafe.Pointer(bp+72 /* &x */)).Fopcode]) & OPFLG_JUMP) != 0 { p2 = lblRecheckOk } else { p2 = (*VdbeOp)(unsafe.Pointer(bp + 72 /* &x */)).Fp2 @@ -105263,7 +103729,7 @@ __1: addrConflictCk++ } // If the retest fails, issue an abort - Xsqlite3UniqueConstraint(tls, pParse, 2, pIdx) + Xsqlite3UniqueConstraint(tls, pParse, OE_Abort, pIdx) Xsqlite3VdbeJumpHere(tls, v, addrBypass) // Terminate the recheck bypass } @@ -105302,17 +103768,17 @@ __3: // Recheck all uniqueness constraints after replace triggers have run if nReplaceTrig != 0 { - Xsqlite3VdbeAddOp2(tls, v, 20, regTrigCnt, lblRecheckOk) + Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, regTrigCnt, lblRecheckOk) if !(pPk != 0) { if isUpdate != 0 { - Xsqlite3VdbeAddOp3(tls, v, 53, regNewData, addrRecheck, regOldData) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x90)) + Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regNewData, addrRecheck, regOldData) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NOTNULL) } - Xsqlite3VdbeAddOp3(tls, v, 32, iDataCur, addrRecheck, regNewData) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, addrRecheck, regNewData) - Xsqlite3RowidConstraint(tls, pParse, 2, pTab) + Xsqlite3RowidConstraint(tls, pParse, OE_Abort, pTab) } else { Xsqlite3VdbeGoto(tls, v, addrRecheck) } @@ -105320,9 +103786,9 @@ __3: } // Generate the table record - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { var regRec int32 = *(*int32)(unsafe.Pointer(aRegIdx + uintptr(ix)*4)) - Xsqlite3VdbeAddOp3(tls, v, 91, (regNewData + 1), int32((*Table)(unsafe.Pointer(pTab)).FnNVCol), regRec) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (regNewData + 1), int32((*Table)(unsafe.Pointer(pTab)).FnNVCol), regRec) if !(bAffinityDone != 0) { Xsqlite3TableAffinity(tls, v, pTab, 0) @@ -105362,29 +103828,29 @@ __1: goto __2 } if (*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != 0 { - Xsqlite3VdbeAddOp2(tls, v, 50, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) } pik_flags = func() uint8 { if useSeekResult != 0 { - return uint8(0x10) + return OPFLAG_USESEEKRESULT } return uint8(0) }() - if ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { - pik_flags = U8(int32(pik_flags) | (0x01)) - pik_flags = U8(int32(pik_flags) | (update_flags & 0x02)) + pik_flags = U8(int32(pik_flags) | (OPFLAG_NCHANGE)) + pik_flags = U8(int32(pik_flags) | (update_flags & OPFLAG_SAVEPOSITION)) if update_flags == 0 { var r int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, r) - Xsqlite3VdbeAddOp4(tls, v, 121, + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, r) + Xsqlite3VdbeAddOp4(tls, v, OP_Insert, (iIdxCur + i), *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), r, pTab, -6) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x40)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_ISNOOP) Xsqlite3ReleaseTempReg(tls, pParse, r) } } - Xsqlite3VdbeAddOp4Int(tls, v, 130, (iIdxCur + i), *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, (iIdxCur + i), *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), (*(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)) + 1), func() int32 { if (uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 100 /* &.uniqNotNull */)) & 0x8 >> 3))) != 0 { @@ -105403,27 +103869,27 @@ __2: goto __3 __3: ; - if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { return } if (*Parse)(unsafe.Pointer(pParse)).Fnested != 0 { pik_flags = U8(0) } else { - pik_flags = U8(0x01) + pik_flags = OPFLAG_NCHANGE pik_flags = U8(int32(pik_flags) | (func() int32 { if update_flags != 0 { return update_flags } - return 0x20 + return OPFLAG_LASTROWID }())) } if appendBias != 0 { - pik_flags = U8(int32(pik_flags) | (0x08)) + pik_flags = U8(int32(pik_flags) | (OPFLAG_APPEND)) } if useSeekResult != 0 { - pik_flags = U8(int32(pik_flags) | (0x10)) + pik_flags = U8(int32(pik_flags) | (OPFLAG_USESEEKRESULT)) } - Xsqlite3VdbeAddOp3(tls, v, 121, iDataCur, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), regNewData) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iDataCur, *(*int32)(unsafe.Pointer(aRegIdx + uintptr(i)*4)), regNewData) if !(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0) { Xsqlite3VdbeAppendP4(tls, v, pTab, -6) } @@ -105475,10 +103941,10 @@ func Xsqlite3OpenTableAndIndices(tls *libc.TLS, pParse uintptr, pTab uintptr, op if piDataCur != 0 { *(*int32)(unsafe.Pointer(piDataCur)) = iDataCur } - if (((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) && ((aToOpen == uintptr(0)) || (*(*U8)(unsafe.Pointer(aToOpen + uintptr(0))) != 0)) { + if (((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((aToOpen == uintptr(0)) || (*(*U8)(unsafe.Pointer(aToOpen)) != 0)) { Xsqlite3OpenTable(tls, pParse, iDataCur, iDb, pTab, op) } else { - Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, (uint8(libc.Bool32(op == 97))), (*Table)(unsafe.Pointer(pTab)).FzName) + Xsqlite3TableLock(tls, pParse, iDb, (*Table)(unsafe.Pointer(pTab)).Ftnum, (uint8(libc.Bool32(op == OP_OpenWrite))), (*Table)(unsafe.Pointer(pTab)).FzName) } if piIdxCur != 0 { *(*int32)(unsafe.Pointer(piIdxCur)) = iBase @@ -105492,7 +103958,7 @@ __1: { var iIdxCur int32 = libc.PostIncInt32(&iBase, 1) - if ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY) && !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { if piDataCur != 0 { *(*int32)(unsafe.Pointer(piDataCur)) = iIdxCur } @@ -105632,19 +104098,19 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint if (*Table)(unsafe.Pointer(pDest)).FnModuleArg != 0 { return 0 // tab1 must not be a virtual table } - if onError == 11 { + if onError == OE_Default { if int32((*Table)(unsafe.Pointer(pDest)).FiPKey) >= 0 { onError = int32((*Table)(unsafe.Pointer(pDest)).FkeyConf) } - if onError == 11 { - onError = 2 + if onError == OE_Default { + onError = OE_Abort } } // allocated even if there is no FROM clause if (*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSelect)).FpSrc)).FnSrc != 1 { return 0 // FROM clause must have exactly one term } - if (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pSelect)).FpSrc+8 /* &.a */)+uintptr(0)*112)).FpSelect != 0 { + if (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pSelect)).FpSrc + 8 /* &.a */))).FpSelect != 0 { return 0 // FROM clause cannot contain a subquery } if (*Select)(unsafe.Pointer(pSelect)).FpWhere != 0 { @@ -105664,7 +104130,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint if (*Select)(unsafe.Pointer(pSelect)).FpPrior != 0 { return 0 // SELECT may not be a compound query } - if ((*Select)(unsafe.Pointer(pSelect)).FselFlags & U32(0x0000001)) != 0 { + if ((*Select)(unsafe.Pointer(pSelect)).FselFlags & SF_Distinct) != 0 { return 0 // SELECT may not be DISTINCT } pEList = (*Select)(unsafe.Pointer(pSelect)).FpEList @@ -105673,7 +104139,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint return 0 // The result set must have exactly one column } - if int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(0)*32)).FpExpr)).Fop) != 177 { + if int32((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */))).FpExpr)).Fop) != TK_ASTERISK { return 0 // The result set must be the special operator "*" } @@ -105689,7 +104155,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint // Possible due to bad sqlite_schema.rootpage return 0 // tab1 and tab2 may not be the same table } - if (libc.Bool32(((*Table)(unsafe.Pointer((pDest))).FtabFlags & U32(0x0080)) == U32(0))) != (libc.Bool32(((*Table)(unsafe.Pointer((pSrc))).FtabFlags & U32(0x0080)) == U32(0))) { + if (libc.Bool32(((*Table)(unsafe.Pointer((pDest))).FtabFlags & TF_WithoutRowid) == U32(0))) != (libc.Bool32(((*Table)(unsafe.Pointer((pSrc))).FtabFlags & TF_WithoutRowid) == U32(0))) { return 0 // source and destination must both be WITHOUT ROWID or not } if (*Table)(unsafe.Pointer(pSrc)).FnModuleArg != 0 { @@ -105722,13 +104188,13 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint // We could, in theory, disable this (except for internal use by the // VACUUM command where it is actually needed). But why do that? It // seems harmless enough, and provides a useful service. - if (int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags) & 0x0060) != (int32((*Column)(unsafe.Pointer(pSrcCol)).FcolFlags) & 0x0060) { + if (int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags) & COLFLAG_GENERATED) != (int32((*Column)(unsafe.Pointer(pSrcCol)).FcolFlags) & COLFLAG_GENERATED) { return 0 // Both columns have the same generated-column type } // But the transfer is only allowed if both the source and destination // tables have the exact same expressions for generated columns. // This requirement could be relaxed for VIRTUAL columns, I suppose. - if (int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags) & 0x0060) != 0 { + if (int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags) & COLFLAG_GENERATED) != 0 { if Xsqlite3ExprCompare(tls, uintptr(0), (*Column)(unsafe.Pointer(pSrcCol)).FpDflt, (*Column)(unsafe.Pointer(pDestCol)).FpDflt, -1) != 0 { return 0 // Different generator expressions @@ -105744,7 +104210,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint return 0 // tab2 must be NOT NULL if tab1 is } // Default values for second and subsequent columns need to match. - if ((int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags) & 0x0060) == 0) && (i > 0) { + if ((int32((*Column)(unsafe.Pointer(pDestCol)).FcolFlags) & COLFLAG_GENERATED) == 0) && (i > 0) { if ((libc.Bool32((*Column)(unsafe.Pointer(pDestCol)).FpDflt == uintptr(0))) != (libc.Bool32((*Column)(unsafe.Pointer(pSrcCol)).FpDflt == uintptr(0)))) || (((*Column)(unsafe.Pointer(pDestCol)).FpDflt != 0) && (libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer((*Column)(unsafe.Pointer(pDestCol)).FpDflt + 8 /* &.u */)), @@ -105754,7 +104220,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint } } for pDestIdx = (*Table)(unsafe.Pointer(pDest)).FpIndex; pDestIdx != 0; pDestIdx = (*Index)(unsafe.Pointer(pDestIdx)).FpNext { - if int32((*Index)(unsafe.Pointer((pDestIdx))).FonError) != 0 { + if int32((*Index)(unsafe.Pointer((pDestIdx))).FonError) != OE_None { destHasUniqueIdx = 1 } for pSrcIdx = (*Table)(unsafe.Pointer(pSrc)).FpIndex; pSrcIdx != 0; pSrcIdx = (*Index)(unsafe.Pointer(pSrcIdx)).FpNext { @@ -105766,7 +104232,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint return 0 // pDestIdx has no corresponding index in pSrc } if (((*Index)(unsafe.Pointer(pSrcIdx)).Ftnum == (*Index)(unsafe.Pointer(pDestIdx)).Ftnum) && ((*Table)(unsafe.Pointer(pSrc)).FpSchema == (*Table)(unsafe.Pointer(pDest)).FpSchema)) && - (Xsqlite3FaultSim(tls, 411) == 0) { + (Xsqlite3FaultSim(tls, 411) == SQLITE_OK) { // The sqlite3FaultSim() call allows this corruption test to be // bypassed during testing, in order to exercise other corruption tests // further downstream. @@ -105782,7 +104248,7 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint // command, and the VACUUM command disables foreign key constraints. So // the extra complication to make this rule less restrictive is probably // not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e] - if (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00004000)) != uint64(0)) && ((*Table)(unsafe.Pointer(pDest)).FpFKey != uintptr(0)) { + if (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ForeignKeys) != uint64(0)) && ((*Table)(unsafe.Pointer(pDest)).FpFKey != uintptr(0)) { return 0 } if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & (U64((uint64(0x00001))) << 32)) != uint64(0) { @@ -105801,11 +104267,11 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint regAutoinc = autoIncBegin(tls, pParse, iDbDest, pDest) regData = Xsqlite3GetTempReg(tls, pParse) regRowid = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3OpenTable(tls, pParse, iDest, iDbDest, pDest, 97) + Xsqlite3OpenTable(tls, pParse, iDest, iDbDest, pDest, OP_OpenWrite) - if (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0004)) == U32(0)) && ((((int32((*Table)(unsafe.Pointer(pDest)).FiPKey) < 0) && ((*Table)(unsafe.Pointer(pDest)).FpIndex != uintptr(0))) || // (1) + if (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_Vacuum) == U32(0)) && ((((int32((*Table)(unsafe.Pointer(pDest)).FiPKey) < 0) && ((*Table)(unsafe.Pointer(pDest)).FpIndex != uintptr(0))) || // (1) (destHasUniqueIdx != 0)) || // (2) - ((onError != 2) && (onError != 1))) { + ((onError != OE_Abort) && (onError != OE_Rollback))) { // In some circumstances, we are able to run the xfer optimization // only if the destination table is initially empty. Unless the // DBFLAG_Vacuum flag is set, this block generates code to make @@ -105822,41 +104288,41 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint // is unable to test uniqueness.) // // (3) onError is something other than OE_Abort and OE_Rollback. - addr1 = Xsqlite3VdbeAddOp2(tls, v, 37, iDest, 0) - emptyDestTest = Xsqlite3VdbeAddOp0(tls, v, 11) + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iDest, 0) + emptyDestTest = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) Xsqlite3VdbeJumpHere(tls, v, addr1) } - if ((*Table)(unsafe.Pointer((pSrc))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pSrc))).FtabFlags & TF_WithoutRowid) == U32(0) { var insFlags U8 - Xsqlite3OpenTable(tls, pParse, iSrc, iDbSrc, pSrc, 96) - emptySrcTest = Xsqlite3VdbeAddOp2(tls, v, 37, iSrc, 0) + Xsqlite3OpenTable(tls, pParse, iSrc, iDbSrc, pSrc, OP_OpenRead) + emptySrcTest = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iSrc, 0) if int32((*Table)(unsafe.Pointer(pDest)).FiPKey) >= 0 { - addr1 = Xsqlite3VdbeAddOp2(tls, v, 127, iSrc, regRowid) + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iSrc, regRowid) - addr2 = Xsqlite3VdbeAddOp3(tls, v, 32, iDest, 0, regRowid) + addr2 = Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDest, 0, regRowid) Xsqlite3RowidConstraint(tls, pParse, onError, pDest) Xsqlite3VdbeJumpHere(tls, v, addr2) autoIncStep(tls, pParse, regAutoinc, regRowid) - } else if ((*Table)(unsafe.Pointer(pDest)).FpIndex == uintptr(0)) && !(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0008)) != 0) { - addr1 = Xsqlite3VdbeAddOp2(tls, v, 120, iDest, regRowid) + } else if ((*Table)(unsafe.Pointer(pDest)).FpIndex == uintptr(0)) && !(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_VacuumInto) != 0) { + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iDest, regRowid) } else { - addr1 = Xsqlite3VdbeAddOp2(tls, v, 127, iSrc, regRowid) + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iSrc, regRowid) } - if ((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0004)) != 0 { - Xsqlite3VdbeAddOp1(tls, v, 129, iDest) - insFlags = (U8(0x08 | 0x10)) + if ((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_Vacuum) != 0 { + Xsqlite3VdbeAddOp1(tls, v, OP_SeekEnd, iDest) + insFlags = (U8(OPFLAG_APPEND | OPFLAG_USESEEKRESULT)) } else { - insFlags = (U8((0x01 | 0x20) | 0x08)) + insFlags = (U8((OPFLAG_NCHANGE | OPFLAG_LASTROWID) | OPFLAG_APPEND)) } - Xsqlite3VdbeAddOp3(tls, v, 126, iSrc, regData, 1) - Xsqlite3VdbeAddOp4(tls, v, 121, iDest, regData, regRowid, + Xsqlite3VdbeAddOp3(tls, v, OP_RowData, iSrc, regData, 1) + Xsqlite3VdbeAddOp4(tls, v, OP_Insert, iDest, regData, regRowid, pDest, -6) Xsqlite3VdbeChangeP5(tls, v, uint16(insFlags)) - Xsqlite3VdbeAddOp2(tls, v, 5, iSrc, addr1) - Xsqlite3VdbeAddOp2(tls, v, 116, iSrc, 0) - Xsqlite3VdbeAddOp2(tls, v, 116, iDest, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iSrc, addr1) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, iSrc, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, iDest, 0) } else { Xsqlite3TableLock(tls, pParse, iDbDest, (*Table)(unsafe.Pointer(pDest)).Ftnum, uint8(1), (*Table)(unsafe.Pointer(pDest)).FzName) Xsqlite3TableLock(tls, pParse, iDbSrc, (*Table)(unsafe.Pointer(pSrc)).Ftnum, uint8(0), (*Table)(unsafe.Pointer(pSrc)).FzName) @@ -105869,15 +104335,15 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint } } - Xsqlite3VdbeAddOp3(tls, v, 96, iSrc, int32((*Index)(unsafe.Pointer(pSrcIdx)).Ftnum), iDbSrc) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, iSrc, int32((*Index)(unsafe.Pointer(pSrcIdx)).Ftnum), iDbSrc) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pSrcIdx) Xsqlite3VdbeComment(tls, v, ts+824 /* "%s" */, libc.VaList(bp, (*Index)(unsafe.Pointer(pSrcIdx)).FzName)) - Xsqlite3VdbeAddOp3(tls, v, 97, iDest, int32((*Index)(unsafe.Pointer(pDestIdx)).Ftnum), iDbDest) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenWrite, iDest, int32((*Index)(unsafe.Pointer(pDestIdx)).Ftnum), iDbDest) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pDestIdx) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x01)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_BULKCSR) Xsqlite3VdbeComment(tls, v, ts+824 /* "%s" */, libc.VaList(bp+8, (*Index)(unsafe.Pointer(pDestIdx)).FzName)) - addr1 = Xsqlite3VdbeAddOp2(tls, v, 37, iSrc, 0) - if ((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0004)) != 0 { + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iSrc, 0) + if ((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_Vacuum) != 0 { // This INSERT command is part of a VACUUM operation, which guarantees // that the destination table is empty. If all indexed columns use // collation sequence BINARY, then it can also be assumed that the @@ -105899,19 +104365,19 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint } } if i == int32((*Index)(unsafe.Pointer(pSrcIdx)).FnColumn) { - idxInsFlags = U8(0x10) - Xsqlite3VdbeAddOp1(tls, v, 129, iDest) + idxInsFlags = OPFLAG_USESEEKRESULT + Xsqlite3VdbeAddOp1(tls, v, OP_SeekEnd, iDest) } - } else if !(((*Table)(unsafe.Pointer((pSrc))).FtabFlags & U32(0x0080)) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer(pDestIdx + 100 /* &.idxType */)) & 0x3 >> 0)) == 2) { - idxInsFlags = U8(int32(idxInsFlags) | (0x01)) + } else if !(((*Table)(unsafe.Pointer((pSrc))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer(pDestIdx + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY) { + idxInsFlags = U8(int32(idxInsFlags) | (OPFLAG_NCHANGE)) } - Xsqlite3VdbeAddOp3(tls, v, 126, iSrc, regData, 1) - Xsqlite3VdbeAddOp2(tls, v, 130, iDest, regData) - Xsqlite3VdbeChangeP5(tls, v, (uint16(int32(idxInsFlags) | 0x08))) - Xsqlite3VdbeAddOp2(tls, v, 5, iSrc, (addr1 + 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_RowData, iSrc, regData, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, iDest, regData) + Xsqlite3VdbeChangeP5(tls, v, (uint16(int32(idxInsFlags) | OPFLAG_APPEND))) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iSrc, (addr1 + 1)) Xsqlite3VdbeJumpHere(tls, v, addr1) - Xsqlite3VdbeAddOp2(tls, v, 116, iSrc, 0) - Xsqlite3VdbeAddOp2(tls, v, 116, iDest, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, iSrc, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, iDest, 0) } if emptySrcTest != 0 { Xsqlite3VdbeJumpHere(tls, v, emptySrcTest) @@ -105920,9 +104386,9 @@ func xferOptimization(tls *libc.TLS, pParse uintptr, pDest uintptr, pSelect uint Xsqlite3ReleaseTempReg(tls, pParse, regData) if emptyDestTest != 0 { Xsqlite3AutoincrementEnd(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 68, 0, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Halt, SQLITE_OK, 0) Xsqlite3VdbeJumpHere(tls, v, emptyDestTest) - Xsqlite3VdbeAddOp2(tls, v, 116, iDest, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, iDest, 0) return 0 } else { return 1 @@ -105971,7 +104437,7 @@ func Xsqlite3_exec(tls *libc.TLS, db uintptr, zSql uintptr, xCallback Sqlite3_ca var i int32 var nCol int32 var azVals uintptr - rc = 0 + rc = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) azCols = uintptr(0) // True if callback data is initialized @@ -105989,9 +104455,9 @@ __2: ; Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - Xsqlite3Error(tls, db, 0) + Xsqlite3Error(tls, db, SQLITE_OK) __3: - if !((rc == 0) && (*(*int8)(unsafe.Pointer(zSql + uintptr(0))) != 0)) { + if !((rc == SQLITE_OK) && (*(*int8)(unsafe.Pointer(zSql)) != 0)) { goto __4 } nCol = 0 @@ -106000,7 +104466,7 @@ __3: *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp /* &pStmt */, bp+8 /* &zLeftover */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __5 } goto __3 @@ -106023,8 +104489,8 @@ __7: rc = Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) // Invoke the callback function if required - if !((xCallback != 0) && ((100 == rc) || (((101 == rc) && !(callbackIsInit != 0)) && - (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000100)) != 0)))) { + if !((xCallback != 0) && ((SQLITE_ROW == rc) || (((SQLITE_DONE == rc) && !(callbackIsInit != 0)) && + (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_NullCallback) != 0)))) { goto __9 } if !(!(callbackIsInit != 0)) { @@ -106057,7 +104523,7 @@ __14: callbackIsInit = 1 __10: ; - if !(rc == 100) { + if !(rc == SQLITE_ROW) { goto __15 } azVals = (azCols + uintptr(nCol)*8) @@ -106067,7 +104533,7 @@ __16: goto __18 } *(*uintptr)(unsafe.Pointer(azVals + uintptr(i)*8)) = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i) - if !(!(int32(*(*uintptr)(unsafe.Pointer(azVals + uintptr(i)*8))) != 0) && (Xsqlite3_column_type(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i) != 5)) { + if !(!(int32(*(*uintptr)(unsafe.Pointer(azVals + uintptr(i)*8))) != 0) && (Xsqlite3_column_type(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i) != SQLITE_NULL)) { goto __19 } Xsqlite3OomFault(tls, db) @@ -106090,24 +104556,24 @@ __15: // EVIDENCE-OF: R-38229-40159 If the callback function to // sqlite3_exec() returns non-zero, then sqlite3_exec() will // return SQLITE_ABORT. - rc = 4 + rc = SQLITE_ABORT Xsqlite3VdbeFinalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) - Xsqlite3Error(tls, db, 4) + Xsqlite3Error(tls, db, SQLITE_ABORT) goto exec_out __20: ; __9: ; - if !(rc != 100) { + if !(rc != SQLITE_ROW) { goto __21 } rc = Xsqlite3VdbeFinalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) zSql = *(*uintptr)(unsafe.Pointer(bp + 8 /* zLeftover */)) __22: - if !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zSql + uintptr(0))))]) & 0x01) != 0) { + if !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zSql)))]) & 0x01) != 0) { goto __23 } zSql++ @@ -106137,15 +104603,15 @@ __24: Xsqlite3DbFree(tls, db, azCols) rc = Xsqlite3ApiExit(tls, db, rc) - if !((rc != 0) && (pzErrMsg != 0)) { + if !((rc != SQLITE_OK) && (pzErrMsg != 0)) { goto __25 } *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3DbStrDup(tls, uintptr(0), Xsqlite3_errmsg(tls, db)) if !(*(*uintptr)(unsafe.Pointer(pzErrMsg)) == uintptr(0)) { goto __27 } - rc = 7 - Xsqlite3Error(tls, db, 7) + rc = SQLITE_NOMEM + Xsqlite3Error(tls, db, SQLITE_NOMEM) __27: ; goto __26 @@ -106264,82 +104730,76 @@ var sqlite3Apis = Sqlite3_api_routines{ Ffree_table: 0, Fget_autocommit: 0, Fget_auxdata: 0, - Fget_table: 0, - Fglobal_recover: uintptr(0), - Finterruptx:// Was sqlite3_global_recover(), but that function is deprecated - 0, - Flast_insert_rowid: 0, - Flibversion: 0, - Flibversion_number: 0, - Fmalloc: 0, - Fmprintf: 0, - Fopen: 0, - Fopen16: 0, - Fprepare: 0, - Fprepare16: 0, - Fprofile: 0, - Fprogress_handler: 0, - Frealloc: 0, - Freset: 0, - Fresult_blob: 0, - Fresult_double: 0, - Fresult_error: 0, - Fresult_error16: 0, - Fresult_int: 0, - Fresult_int64: 0, - Fresult_null: 0, - Fresult_text: 0, - Fresult_text16: 0, - Fresult_text16be: 0, - Fresult_text16le: 0, - Fresult_value: 0, - Frollback_hook: 0, - Fset_authorizer: 0, - Fset_auxdata: 0, - Fxsnprintf: 0, - Fstep: 0, - Ftable_column_metadata: 0, - Fthread_cleanup: 0, - Ftotal_changes: 0, - Ftrace: 0, - Ftransfer_bindings: 0, - Fupdate_hook: 0, - Fuser_data: 0, - Fvalue_blob: 0, - Fvalue_bytes: 0, - Fvalue_bytes16: 0, - Fvalue_double: 0, - Fvalue_int: 0, - Fvalue_int64: 0, - Fvalue_numeric_type: 0, - Fvalue_text: 0, - Fvalue_text16: 0, - Fvalue_text16be: 0, - Fvalue_text16le: 0, - Fvalue_type: 0, - Fvmprintf: 0, - Foverload_function: + Fget_table: 0, // Was sqlite3_global_recover(), but that function is deprecated + Finterruptx: 0, + Flast_insert_rowid: 0, + Flibversion: 0, + Flibversion_number: 0, + Fmalloc: 0, + Fmprintf: 0, + Fopen: 0, + Fopen16: 0, + Fprepare: 0, + Fprepare16: 0, + Fprofile: 0, + Fprogress_handler: 0, + Frealloc: 0, + Freset: 0, + Fresult_blob: 0, + Fresult_double: 0, + Fresult_error: 0, + Fresult_error16: 0, + Fresult_int: 0, + Fresult_int64: 0, + Fresult_null: 0, + Fresult_text: 0, + Fresult_text16: 0, + Fresult_text16be: 0, + Fresult_text16le: 0, + Fresult_value: 0, + Frollback_hook: 0, + Fset_authorizer: 0, + Fset_auxdata: 0, + Fxsnprintf: 0, + Fstep: 0, + Ftable_column_metadata: 0, + Fthread_cleanup: 0, + Ftotal_changes: 0, + Ftrace: 0, + Ftransfer_bindings: 0, + Fupdate_hook: 0, + Fuser_data: 0, + Fvalue_blob: 0, + Fvalue_bytes: 0, + Fvalue_bytes16: 0, + Fvalue_double: 0, + Fvalue_int: 0, + Fvalue_int64: 0, + Fvalue_numeric_type: 0, + Fvalue_text: 0, + Fvalue_text16: 0, + Fvalue_text16be: 0, + Fvalue_text16le: 0, + Fvalue_type: 0, + Fvmprintf: 0, // The original API set ends here. All extensions can call any // of the APIs above provided that the pointer is not NULL. But // before calling APIs that follow, extension should check the // sqlite3_libversion_number() to make sure they are dealing with // a library that is new enough to support that API. // - 0, - Fprepare_v2: + Foverload_function: 0, // Added after 3.3.13 - 0, + Fprepare_v2: 0, Fprepare16_v2: 0, Fclear_bindings: 0, - Fcreate_module_v2: // Added for 3.4.1 - 0, - Fbind_zeroblob: + Fcreate_module_v2: 0, // Added for 3.5.0 - 0, + Fbind_zeroblob: 0, Fblob_bytes: 0, Fblob_close: 0, Fblob_open: 0, @@ -106363,27 +104823,24 @@ var sqlite3Apis = Sqlite3_api_routines{ Fvfs_find: 0, Fvfs_register: 0, Fvfs_unregister: 0, - Fxthreadsafe: // Added for 3.5.8 - 0, + Fxthreadsafe: 0, Fresult_zeroblob: 0, Fresult_error_code: 0, Ftest_control: 0, Frandomness: 0, Fcontext_db_handle: 0, - Fextended_result_codes: // Added for 3.6.0 - 0, - Flimit: 0, - Fnext_stmt: 0, - Fsql: 0, - Fstatus: 0, - Fbackup_finish: + Fextended_result_codes: 0, + Flimit: 0, + Fnext_stmt: 0, + Fsql: 0, + Fstatus: 0, // Added for 3.7.4 - 0, + Fbackup_finish: 0, Fbackup_init: 0, Fbackup_pagecount: 0, Fbackup_remaining: 0, @@ -106420,9 +104877,8 @@ var sqlite3Apis = Sqlite3_api_routines{ Furi_parameter: 0, Fxvsnprintf: 0, Fwal_checkpoint_v2: 0, - Fauto_extension: // Version 3.8.7 and later - 0, + Fauto_extension: 0, Fbind_blob64: 0, Fbind_text64: 0, Fcancel_auto_extension: 0, @@ -106434,46 +104890,37 @@ var sqlite3Apis = Sqlite3_api_routines{ Fresult_blob64: 0, Fresult_text64: 0, Fstrglob: 0, - Fvalue_dup: // Version 3.8.11 and later - 0, + Fvalue_dup: 0, Fvalue_free: 0, Fresult_zeroblob64: 0, Fbind_zeroblob64: 0, - Fvalue_subtype: // Version 3.9.0 and later - 0, + Fvalue_subtype: 0, Fresult_subtype: 0, - Fstatus64: // Version 3.10.0 and later - 0, + Fstatus64: 0, Fstrlike: 0, Fdb_cacheflush: 0, - Fsystem_errno: // Version 3.12.0 and later - 0, - Ftrace_v2: + Fsystem_errno: 0, // Version 3.14.0 and later - 0, + Ftrace_v2: 0, Fexpanded_sql: 0, - Fset_last_insert_rowid: // Version 3.18.0 and later - 0, - Fprepare_v3: + Fset_last_insert_rowid: 0, // Version 3.20.0 and later - 0, + Fprepare_v3: 0, Fprepare16_v3: 0, Fbind_pointer: 0, Fresult_pointer: 0, Fvalue_pointer: 0, - Fvtab_nochange: // Version 3.22.0 and later - 0, + Fvtab_nochange: 0, Fvalue_nochange: 0, Fvtab_collation: 0, - Fkeyword_count: // Version 3.24.0 and later - 0, + Fkeyword_count: 0, Fkeyword_name: 0, Fkeyword_check: 0, Fstr_new: 0, @@ -106487,29 +104934,21 @@ var sqlite3Apis = Sqlite3_api_routines{ Fstr_errcode: 0, Fstr_length: 0, Fstr_value: 0, - Fcreate_window_function: // Version 3.25.0 and later - 0, - Fnormalized_sql: - // Version 3.26.0 and later - uintptr(0), - Fstmt_isexplain: + Fcreate_window_function: 0, // Version 3.28.0 and later - 0, + Fstmt_isexplain: 0, Fvalue_frombind: 0, - Fdrop_modules: // Version 3.30.0 and later - 0, - Fhard_heap_limit64: + Fdrop_modules: 0, // Version 3.31.0 and later - 0, + Fhard_heap_limit64: 0, Furi_key: 0, Ffilename_database: 0, Ffilename_journal: 0, Ffilename_wal: 0, - Fcreate_filename: // Version 3.32.0 and later - 0, + Fcreate_filename: 0, Ffree_filename: 0, Fdatabase_file_object: 0, } /* sqlite3.c:124371:35 */ @@ -106551,11 +104990,11 @@ func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintpt // must call either sqlite3_enable_load_extension(db) or // sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, 0) // to turn on extension loading. - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00010000)) == uint64(0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_LoadExtension) == uint64(0) { if pzErrMsg != 0 { *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+13234 /* "not authorized" */, 0) } - return 1 + return SQLITE_ERROR } if zProc != 0 { @@ -106568,7 +105007,7 @@ func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintpt for ii = 0; (ii < (int32(uint64(unsafe.Sizeof(azEndings)) / uint64(unsafe.Sizeof(uintptr(0)))))) && (handle == uintptr(0)); ii++ { var zAltFile uintptr = Xsqlite3_mprintf(tls, ts+9997 /* "%s.%s" */, libc.VaList(bp, zFile, azEndings[ii])) if zAltFile == uintptr(0) { - return 7 + return SQLITE_NOMEM } handle = Xsqlite3OsDlOpen(tls, pVfs, zAltFile) Xsqlite3_free(tls, zAltFile) @@ -106582,7 +105021,7 @@ func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintpt Xsqlite3OsDlError(tls, pVfs, (int32(nMsg - uint64(1))), *(*uintptr)(unsafe.Pointer(bp + 48 /* zErrmsg */))) } } - return 1 + return SQLITE_ERROR } xInit = Xsqlite3OsDlSym(tls, pVfs, handle, zEntry) @@ -106604,7 +105043,7 @@ func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintpt zAltEntry = Xsqlite3_malloc64(tls, (uint64(ncFile + 30))) if zAltEntry == uintptr(0) { Xsqlite3OsDlClose(tls, pVfs, handle) - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, zAltEntry, ts+16994 /* "sqlite3_" */, uint64(8)) for iFile = (ncFile - 1); (iFile >= 0) && !((int32(*(*int8)(unsafe.Pointer(zFile + uintptr(iFile))))) == '/'); iFile-- { @@ -106634,26 +105073,26 @@ func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintpt } Xsqlite3OsDlClose(tls, pVfs, handle) Xsqlite3_free(tls, zAltEntry) - return 1 + return SQLITE_ERROR } Xsqlite3_free(tls, zAltEntry) rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&xInit)))(tls, db, bp+48 /* &zErrmsg */, uintptr(unsafe.Pointer(&sqlite3Apis))) if rc != 0 { - if rc == (0 | (int32(1) << 8)) { - return 0 + if rc == (SQLITE_OK | (int32(1) << 8)) { + return SQLITE_OK } if pzErrMsg != 0 { *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+17056 /* "error during ini..." */, libc.VaList(bp+40, *(*uintptr)(unsafe.Pointer(bp + 48 /* zErrmsg */)))) } Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* zErrmsg */))) Xsqlite3OsDlClose(tls, pVfs, handle) - return 1 + return SQLITE_ERROR } // Append the new shared library handle to the db->aExtension array. aHandle = Xsqlite3DbMallocZero(tls, db, (uint64(uint64(unsafe.Sizeof(handle)) * (uint64((*Sqlite3)(unsafe.Pointer(db)).FnExtension + 1))))) if aHandle == uintptr(0) { - return 7 + return SQLITE_NOMEM } if (*Sqlite3)(unsafe.Pointer(db)).FnExtension > 0 { libc.Xmemcpy(tls, aHandle, (*Sqlite3)(unsafe.Pointer(db)).FaExtension, (uint64(unsafe.Sizeof(handle)) * uint64((*Sqlite3)(unsafe.Pointer(db)).FnExtension))) @@ -106662,7 +105101,7 @@ func sqlite3LoadExtension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintpt (*Sqlite3)(unsafe.Pointer(db)).FaExtension = aHandle *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaExtension + uintptr(libc.PostIncInt32(&(*Sqlite3)(unsafe.Pointer(db)).FnExtension, 1))*8)) = handle - return 0 + return SQLITE_OK } var azEndings = [1]uintptr{ @@ -106694,12 +105133,12 @@ func Xsqlite3CloseExtensions(tls *libc.TLS, db uintptr) { /* sqlite3.c:124900:21 func Xsqlite3_enable_load_extension(tls *libc.TLS, db uintptr, onoff int32) int32 { /* sqlite3.c:124913:16: */ Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) if onoff != 0 { - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(0x00010000 | 0x00020000)) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(SQLITE_LoadExtension | SQLITE_LoadExtFunc)) } else { - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64((uint64(0x00010000 | 0x00020000)))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64((uint64(SQLITE_LoadExtension | SQLITE_LoadExtFunc)))) } Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // The following object holds the list of automatically loaded @@ -106730,13 +105169,13 @@ var sqlite3Autoext = sqlite3AutoExtList{} /* sqlite3.c:124937:3 */ // Register a statically linked extension that is automatically // loaded by every new database connection. func Xsqlite3_auto_extension(tls *libc.TLS, xInit uintptr) int32 { /* sqlite3.c:124959:16: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK rc = Xsqlite3_initialize(tls) if rc != 0 { return rc } else { var i U32 - var mutex uintptr = Xsqlite3MutexAlloc(tls, 2) + var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutex) for i = U32(0); i < sqlite3Autoext.FnExt; i++ { @@ -106749,7 +105188,7 @@ func Xsqlite3_auto_extension(tls *libc.TLS, xInit uintptr) int32 { /* sqlite3.c: var aNew uintptr aNew = Xsqlite3_realloc64(tls, sqlite3Autoext.FaExt, nByte) if aNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { sqlite3Autoext.FaExt = aNew *(*uintptr)(unsafe.Pointer(sqlite3Autoext.FaExt + uintptr(sqlite3Autoext.FnExt)*8)) = xInit @@ -106771,7 +105210,7 @@ func Xsqlite3_auto_extension(tls *libc.TLS, xInit uintptr) int32 { /* sqlite3.c: // Return 1 if xInit was found on the list and removed. Return 0 if xInit // was not on the list. func Xsqlite3_cancel_auto_extension(tls *libc.TLS, xInit uintptr) int32 { /* sqlite3.c:125006:16: */ - var mutex uintptr = Xsqlite3MutexAlloc(tls, 2) + var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) var i int32 var n int32 = 0 @@ -106790,8 +105229,8 @@ func Xsqlite3_cancel_auto_extension(tls *libc.TLS, xInit uintptr) int32 { /* sql // Reset the automatic extension loading mechanism. func Xsqlite3_reset_auto_extension(tls *libc.TLS) { /* sqlite3.c:125031:17: */ - if Xsqlite3_initialize(tls) == 0 { - var mutex uintptr = Xsqlite3MutexAlloc(tls, 2) + if Xsqlite3_initialize(tls) == SQLITE_OK { + var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, mutex) Xsqlite3_free(tls, sqlite3Autoext.FaExt) @@ -106820,7 +105259,7 @@ func Xsqlite3AutoLoadExtensions(tls *libc.TLS, db uintptr) { /* sqlite3.c:125053 for i = U32(0); go1 != 0; i++ { // var zErrmsg uintptr at bp+8, 8 - var mutex uintptr = Xsqlite3MutexAlloc(tls, 2) + var mutex uintptr = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) var pThunk uintptr = uintptr(unsafe.Pointer(&sqlite3Apis)) Xsqlite3_mutex_enter(tls, mutex) if i >= sqlite3Autoext.FnExt { @@ -106949,732 +105388,241 @@ type PragmaName1 = struct { // Definitions of all built-in pragmas type PragmaName = PragmaName1 /* sqlite3.c:125259:3 */ var aPragmaName = [66]PragmaName{ - { - FzName:/* zName: */ ts + 17358, /* "analysis_limit" */ - FePragTyp: - /* ePragTyp: */ U8(1), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17373, /* "application_id" */ - FePragTyp: - /* ePragTyp: */ U8(2), - FmPragFlg: - /* ePragFlg: */ (U8(0x04 | 0x10)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(8)}, - { - FzName:/* zName: */ ts + 17388, /* "auto_vacuum" */ - FePragTyp: - /* ePragTyp: */ U8(3), - FmPragFlg: - /* ePragFlg: */ (U8(((0x01 | 0x10) | 0x80) | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17400, /* "automatic_index" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00008000)}, - { - FzName:/* zName: */ ts + 17416, /* "busy_timeout" */ - FePragTyp: - /* ePragTyp: */ U8(5), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(50), - FnPragCName: U8(1), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17339, /* "cache_size" */ - FePragTyp: - /* ePragTyp: */ U8(6), - FmPragFlg: - /* ePragFlg: */ (U8(((0x01 | 0x10) | 0x80) | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17429, /* "cache_spill" */ - FePragTyp: - /* ePragTyp: */ U8(7), - FmPragFlg: - /* ePragFlg: */ (U8((0x10 | 0x80) | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17441, /* "case_sensitive_l..." */ - FePragTyp: - /* ePragTyp: */ U8(8), - FmPragFlg: - /* ePragFlg: */ U8(0x02), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17461, /* "cell_size_check" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00200000)}, - { - FzName:/* zName: */ ts + 17477, /* "checkpoint_fullf..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000010)}, - { - FzName:/* zName: */ ts + 17498, /* "collation_list" */ - FePragTyp: - /* ePragTyp: */ U8(9), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(32), - FnPragCName: U8(2), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17513, /* "compile_options" */ - FePragTyp: - /* ePragTyp: */ U8(10), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17529, /* "count_changes" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ (U64((uint64(0x00001))) << 32)}, - { - FzName:/* zName: */ ts + 17543, /* "data_version" */ - FePragTyp: - /* ePragTyp: */ U8(2), - FmPragFlg: - /* ePragFlg: */ (U8(0x08 | 0x10)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(15)}, - { - FzName:/* zName: */ ts + 17556, /* "database_list" */ - FePragTyp: - /* ePragTyp: */ U8(12), - FmPragFlg: - /* ePragFlg: */ (U8(0x01 | 0x10)), - FiPragCName: - /* ColNames: */ U8(41), - FnPragCName: U8(3), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17570, /* "default_cache_si..." */ - FePragTyp: - /* ePragTyp: */ U8(13), - FmPragFlg: - /* ePragFlg: */ (U8(((0x01 | 0x10) | 0x80) | 0x04)), - FiPragCName: - /* ColNames: */ U8(49), - FnPragCName: U8(1), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17589, /* "defer_foreign_ke..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00080000)}, - { - FzName:/* zName: */ ts + 17608, /* "empty_result_cal..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000100)}, - { - FzName:/* zName: */ ts + 17631, /* "encoding" */ - FePragTyp: - /* ePragTyp: */ U8(14), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17640, /* "foreign_key_chec..." */ - FePragTyp: - /* ePragTyp: */ U8(15), - FmPragFlg: - /* ePragFlg: */ (U8(((0x01 | 0x10) | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(37), - FnPragCName: U8(4), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17658, /* "foreign_key_list" */ - FePragTyp: - /* ePragTyp: */ U8(16), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(8), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17675, /* "foreign_keys" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00004000)}, - { - FzName:/* zName: */ ts + 17688, /* "freelist_count" */ - FePragTyp: - /* ePragTyp: */ U8(2), - FmPragFlg: - /* ePragFlg: */ (U8(0x08 | 0x10)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17703, /* "full_column_name..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000004)}, - { - FzName:/* zName: */ ts + 17721, /* "fullfsync" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000008)}, - { - FzName:/* zName: */ ts + 17731, /* "function_list" */ - FePragTyp: - /* ePragTyp: */ U8(17), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(21), - FnPragCName: U8(6), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17745, /* "hard_heap_limit" */ - FePragTyp: - /* ePragTyp: */ U8(18), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17761, /* "ignore_check_con..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000200)}, - { - FzName:/* zName: */ ts + 17786, /* "incremental_vacu..." */ - FePragTyp: - /* ePragTyp: */ U8(19), - FmPragFlg: - /* ePragFlg: */ (U8(0x01 | 0x02)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17805, /* "index_info" */ - FePragTyp: - /* ePragTyp: */ U8(20), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(15), - FnPragCName: U8(3), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17816, /* "index_list" */ - FePragTyp: - /* ePragTyp: */ U8(21), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(32), - FnPragCName: U8(5), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17827, /* "index_xinfo" */ - FePragTyp: - /* ePragTyp: */ U8(20), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(15), - FnPragCName: U8(6), - FiArg: - /* iArg: */ uint64(1)}, - { - FzName:/* zName: */ ts + 17839, /* "integrity_check" */ - FePragTyp: - /* ePragTyp: */ U8(22), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x10) | 0x20)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17855, /* "journal_mode" */ - FePragTyp: - /* ePragTyp: */ U8(23), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x10) | 0x80)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17868, /* "journal_size_lim..." */ - FePragTyp: - /* ePragTyp: */ U8(24), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x80)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17887, /* "legacy_alter_tab..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x04000000)}, - { - FzName:/* zName: */ ts + 17906, /* "lock_status" */ - FePragTyp: - /* ePragTyp: */ U8(43), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(47), - FnPragCName: U8(2), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17918, /* "locking_mode" */ - FePragTyp: - /* ePragTyp: */ U8(26), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x80)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17931, /* "max_page_count" */ - FePragTyp: - /* ePragTyp: */ U8(27), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x10) | 0x80)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17946, /* "mmap_size" */ - FePragTyp: - /* ePragTyp: */ U8(28), - FmPragFlg: - /* ePragFlg: */ U8(0), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17956, /* "module_list" */ - FePragTyp: - /* ePragTyp: */ U8(29), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(9), - FnPragCName: U8(1), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17968, /* "optimize" */ - FePragTyp: - /* ePragTyp: */ U8(30), - FmPragFlg: - /* ePragFlg: */ (U8(0x20 | 0x01)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17977, /* "page_count" */ - FePragTyp: - /* ePragTyp: */ U8(27), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x10) | 0x80)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17988, /* "page_size" */ - FePragTyp: - /* ePragTyp: */ U8(31), - FmPragFlg: - /* ePragFlg: */ (U8((0x10 | 0x80) | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 17998, /* "pragma_list" */ - FePragTyp: - /* ePragTyp: */ U8(32), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(9), - FnPragCName: U8(1), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 18010, /* "query_only" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00100000)}, - { - FzName:/* zName: */ ts + 18021, /* "quick_check" */ - FePragTyp: - /* ePragTyp: */ U8(22), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x10) | 0x20)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 18033, /* "read_uncommitted" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000400)}, - { - FzName:/* zName: */ ts + 18050, /* "recursive_trigge..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00002000)}, - { - FzName:/* zName: */ ts + 18069, /* "reverse_unordere..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00001000)}, - { - FzName:/* zName: */ ts + 18095, /* "schema_version" */ - FePragTyp: - /* ePragTyp: */ U8(2), - FmPragFlg: - /* ePragFlg: */ (U8(0x04 | 0x10)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(1)}, - { - FzName:/* zName: */ ts + 18110, /* "secure_delete" */ - FePragTyp: - /* ePragTyp: */ U8(33), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 18124, /* "short_column_nam..." */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000040)}, - { - FzName:/* zName: */ ts + 18143, /* "shrink_memory" */ - FePragTyp: - /* ePragTyp: */ U8(34), - FmPragFlg: - /* ePragFlg: */ U8(0x02), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 18157, /* "soft_heap_limit" */ - FePragTyp: - /* ePragTyp: */ U8(35), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 18173, /* "synchronous" */ - FePragTyp: - /* ePragTyp: */ U8(36), - FmPragFlg: - /* ePragFlg: */ (U8(((0x01 | 0x10) | 0x80) | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 18185, /* "table_info" */ - FePragTyp: - /* ePragTyp: */ U8(37), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(8), - FnPragCName: U8(6), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 18196, /* "table_xinfo" */ - FePragTyp: - /* ePragTyp: */ U8(37), - FmPragFlg: - /* ePragFlg: */ (U8((0x01 | 0x20) | 0x40)), - FiPragCName: - /* ColNames: */ U8(8), - FnPragCName: U8(7), - FiArg: - /* iArg: */ uint64(1)}, - { - FzName:/* zName: */ ts + 18208, /* "temp_store" */ - FePragTyp: - /* ePragTyp: */ U8(38), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 18219, /* "temp_store_direc..." */ - FePragTyp: - /* ePragTyp: */ U8(39), - FmPragFlg: - /* ePragFlg: */ U8(0x04), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 18240, /* "threads" */ - FePragTyp: - /* ePragTyp: */ U8(40), - FmPragFlg: - /* ePragFlg: */ U8(0x10), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 18248, /* "trusted_schema" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0x00000080)}, - { - FzName:/* zName: */ ts + 18263, /* "user_version" */ - FePragTyp: - /* ePragTyp: */ U8(2), - FmPragFlg: - /* ePragFlg: */ (U8(0x04 | 0x10)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(6)}, - { - FzName:/* zName: */ ts + 18276, /* "wal_autocheckpoi..." */ - FePragTyp: - /* ePragTyp: */ U8(41), - FmPragFlg: - /* ePragFlg: */ U8(0), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 18295, /* "wal_checkpoint" */ - FePragTyp: - /* ePragTyp: */ U8(42), - FmPragFlg: - /* ePragFlg: */ U8(0x01), - FiPragCName: - /* ColNames: */ U8(44), - FnPragCName: U8(3), - FiArg: - /* iArg: */ uint64(0)}, - { - FzName:/* zName: */ ts + 18310, /* "writable_schema" */ - FePragTyp: - /* ePragTyp: */ U8(4), - FmPragFlg: - /* ePragFlg: */ (U8(0x10 | 0x04)), - FiPragCName: - /* ColNames: */ U8(0), - FnPragCName: U8(0), - FiArg: - /* iArg: */ (uint64(0x00000001 | 0x08000000))}, + { /* zName: */ FzName: ts + 17358, /* "analysis_limit" */ + /* ePragTyp: */ FePragTyp: PragTyp_ANALYSIS_LIMIT, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0}, + { /* zName: */ FzName: ts + 17373, /* "application_id" */ + /* ePragTyp: */ FePragTyp: PragTyp_HEADER_VALUE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_NoColumns1 | PragFlg_Result0)), + /* iArg: */ FiArg: BTREE_APPLICATION_ID}, + { /* zName: */ FzName: ts + 17388, /* "auto_vacuum" */ + /* ePragTyp: */ FePragTyp: PragTyp_AUTO_VACUUM, + /* ePragFlg: */ FmPragFlg: (U8(((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq) | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 17400, /* "automatic_index" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_AutoIndex}, + { /* zName: */ FzName: ts + 17416, /* "busy_timeout" */ + /* ePragTyp: */ FePragTyp: PragTyp_BUSY_TIMEOUT, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0, + /* ColNames: */ FiPragCName: U8(50), FnPragCName: U8(1)}, + { /* zName: */ FzName: ts + 17339, /* "cache_size" */ + /* ePragTyp: */ FePragTyp: PragTyp_CACHE_SIZE, + /* ePragFlg: */ FmPragFlg: (U8(((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq) | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 17429, /* "cache_spill" */ + /* ePragTyp: */ FePragTyp: PragTyp_CACHE_SPILL, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_Result0 | PragFlg_SchemaReq) | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 17441, /* "case_sensitive_l..." */ + /* ePragTyp: */ FePragTyp: PragTyp_CASE_SENSITIVE_LIKE, + /* ePragFlg: */ FmPragFlg: PragFlg_NoColumns}, + { /* zName: */ FzName: ts + 17461, /* "cell_size_check" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_CellSizeCk}, + { /* zName: */ FzName: ts + 17477, /* "checkpoint_fullf..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_CkptFullFSync}, + { /* zName: */ FzName: ts + 17498, /* "collation_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_COLLATION_LIST, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0, + /* ColNames: */ FiPragCName: U8(32), FnPragCName: U8(2)}, + { /* zName: */ FzName: ts + 17513, /* "compile_options" */ + /* ePragTyp: */ FePragTyp: PragTyp_COMPILE_OPTIONS, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0}, + { /* zName: */ FzName: ts + 17529, /* "count_changes" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: (U64((uint64(0x00001))) << 32)}, + { /* zName: */ FzName: ts + 17543, /* "data_version" */ + /* ePragTyp: */ FePragTyp: PragTyp_HEADER_VALUE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_ReadOnly | PragFlg_Result0)), + /* iArg: */ FiArg: BTREE_DATA_VERSION}, + { /* zName: */ FzName: ts + 17556, /* "database_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_DATABASE_LIST, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_NeedSchema | PragFlg_Result0)), + /* ColNames: */ FiPragCName: U8(41), FnPragCName: U8(3)}, + { /* zName: */ FzName: ts + 17570, /* "default_cache_si..." */ + /* ePragTyp: */ FePragTyp: PragTyp_DEFAULT_CACHE_SIZE, + /* ePragFlg: */ FmPragFlg: (U8(((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq) | PragFlg_NoColumns1)), + /* ColNames: */ FiPragCName: U8(49), FnPragCName: U8(1)}, + { /* zName: */ FzName: ts + 17589, /* "defer_foreign_ke..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_DeferFKs}, + { /* zName: */ FzName: ts + 17608, /* "empty_result_cal..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_NullCallback}, + { /* zName: */ FzName: ts + 17631, /* "encoding" */ + /* ePragTyp: */ FePragTyp: PragTyp_ENCODING, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 17640, /* "foreign_key_chec..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FOREIGN_KEY_CHECK, + /* ePragFlg: */ FmPragFlg: (U8(((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_Result1) | PragFlg_SchemaOpt)), + /* ColNames: */ FiPragCName: U8(37), FnPragCName: U8(4)}, + { /* zName: */ FzName: ts + 17658, /* "foreign_key_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_FOREIGN_KEY_LIST, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result1) | PragFlg_SchemaOpt)), FnPragCName: U8(8)}, + { /* zName: */ FzName: ts + 17675, /* "foreign_keys" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_ForeignKeys}, + { /* zName: */ FzName: ts + 17688, /* "freelist_count" */ + /* ePragTyp: */ FePragTyp: PragTyp_HEADER_VALUE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_ReadOnly | PragFlg_Result0))}, + { /* zName: */ FzName: ts + 17703, /* "full_column_name..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_FullColNames}, + { /* zName: */ FzName: ts + 17721, /* "fullfsync" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_FullFSync}, + { /* zName: */ FzName: ts + 17731, /* "function_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_FUNCTION_LIST, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0, + /* ColNames: */ FiPragCName: U8(21), FnPragCName: U8(6)}, + { /* zName: */ FzName: ts + 17745, /* "hard_heap_limit" */ + /* ePragTyp: */ FePragTyp: PragTyp_HARD_HEAP_LIMIT, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0}, + { /* zName: */ FzName: ts + 17761, /* "ignore_check_con..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_IgnoreChecks}, + { /* zName: */ FzName: ts + 17786, /* "incremental_vacu..." */ + /* ePragTyp: */ FePragTyp: PragTyp_INCREMENTAL_VACUUM, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_NeedSchema | PragFlg_NoColumns))}, + { /* zName: */ FzName: ts + 17805, /* "index_info" */ + /* ePragTyp: */ FePragTyp: PragTyp_INDEX_INFO, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result1) | PragFlg_SchemaOpt)), + /* ColNames: */ FiPragCName: U8(15), FnPragCName: U8(3)}, + { /* zName: */ FzName: ts + 17816, /* "index_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_INDEX_LIST, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result1) | PragFlg_SchemaOpt)), + /* ColNames: */ FiPragCName: U8(32), FnPragCName: U8(5)}, + { /* zName: */ FzName: ts + 17827, /* "index_xinfo" */ + /* ePragTyp: */ FePragTyp: PragTyp_INDEX_INFO, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result1) | PragFlg_SchemaOpt)), + /* ColNames: */ FiPragCName: U8(15), FnPragCName: U8(6), + /* iArg: */ FiArg: uint64(1)}, + { /* zName: */ FzName: ts + 17839, /* "integrity_check" */ + /* ePragTyp: */ FePragTyp: PragTyp_INTEGRITY_CHECK, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_Result1))}, + { /* zName: */ FzName: ts + 17855, /* "journal_mode" */ + /* ePragTyp: */ FePragTyp: PragTyp_JOURNAL_MODE, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq))}, + { /* zName: */ FzName: ts + 17868, /* "journal_size_lim..." */ + /* ePragTyp: */ FePragTyp: PragTyp_JOURNAL_SIZE_LIMIT, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_SchemaReq))}, + { /* zName: */ FzName: ts + 17887, /* "legacy_alter_tab..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_LegacyAlter}, + { /* zName: */ FzName: ts + 17906, /* "lock_status" */ + /* ePragTyp: */ FePragTyp: PragTyp_LOCK_STATUS, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0, + /* ColNames: */ FiPragCName: U8(47), FnPragCName: U8(2)}, + { /* zName: */ FzName: ts + 17918, /* "locking_mode" */ + /* ePragTyp: */ FePragTyp: PragTyp_LOCKING_MODE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_SchemaReq))}, + { /* zName: */ FzName: ts + 17931, /* "max_page_count" */ + /* ePragTyp: */ FePragTyp: PragTyp_PAGE_COUNT, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq))}, + { /* zName: */ FzName: ts + 17946, /* "mmap_size" */ + /* ePragTyp: */ FePragTyp: PragTyp_MMAP_SIZE}, + { /* zName: */ FzName: ts + 17956, /* "module_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_MODULE_LIST, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0, + /* ColNames: */ FiPragCName: U8(9), FnPragCName: U8(1)}, + { /* zName: */ FzName: ts + 17968, /* "optimize" */ + /* ePragTyp: */ FePragTyp: PragTyp_OPTIMIZE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result1 | PragFlg_NeedSchema))}, + { /* zName: */ FzName: ts + 17977, /* "page_count" */ + /* ePragTyp: */ FePragTyp: PragTyp_PAGE_COUNT, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq))}, + { /* zName: */ FzName: ts + 17988, /* "page_size" */ + /* ePragTyp: */ FePragTyp: PragTyp_PAGE_SIZE, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_Result0 | PragFlg_SchemaReq) | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 17998, /* "pragma_list" */ + /* ePragTyp: */ FePragTyp: PragTyp_PRAGMA_LIST, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0, + /* ColNames: */ FiPragCName: U8(9), FnPragCName: U8(1)}, + { /* zName: */ FzName: ts + 18010, /* "query_only" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_QueryOnly}, + { /* zName: */ FzName: ts + 18021, /* "quick_check" */ + /* ePragTyp: */ FePragTyp: PragTyp_INTEGRITY_CHECK, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_Result1))}, + { /* zName: */ FzName: ts + 18033, /* "read_uncommitted" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_ReadUncommit}, + { /* zName: */ FzName: ts + 18050, /* "recursive_trigge..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_RecTriggers}, + { /* zName: */ FzName: ts + 18069, /* "reverse_unordere..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_ReverseOrder}, + { /* zName: */ FzName: ts + 18095, /* "schema_version" */ + /* ePragTyp: */ FePragTyp: PragTyp_HEADER_VALUE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_NoColumns1 | PragFlg_Result0)), + /* iArg: */ FiArg: BTREE_SCHEMA_VERSION}, + { /* zName: */ FzName: ts + 18110, /* "secure_delete" */ + /* ePragTyp: */ FePragTyp: PragTyp_SECURE_DELETE, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0}, + { /* zName: */ FzName: ts + 18124, /* "short_column_nam..." */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_ShortColNames}, + { /* zName: */ FzName: ts + 18143, /* "shrink_memory" */ + /* ePragTyp: */ FePragTyp: PragTyp_SHRINK_MEMORY, + /* ePragFlg: */ FmPragFlg: PragFlg_NoColumns}, + { /* zName: */ FzName: ts + 18157, /* "soft_heap_limit" */ + /* ePragTyp: */ FePragTyp: PragTyp_SOFT_HEAP_LIMIT, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0}, + { /* zName: */ FzName: ts + 18173, /* "synchronous" */ + /* ePragTyp: */ FePragTyp: PragTyp_SYNCHRONOUS, + /* ePragFlg: */ FmPragFlg: (U8(((PragFlg_NeedSchema | PragFlg_Result0) | PragFlg_SchemaReq) | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 18185, /* "table_info" */ + /* ePragTyp: */ FePragTyp: PragTyp_TABLE_INFO, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result1) | PragFlg_SchemaOpt)), + /* ColNames: */ FiPragCName: U8(8), FnPragCName: U8(6)}, + { /* zName: */ FzName: ts + 18196, /* "table_xinfo" */ + /* ePragTyp: */ FePragTyp: PragTyp_TABLE_INFO, + /* ePragFlg: */ FmPragFlg: (U8((PragFlg_NeedSchema | PragFlg_Result1) | PragFlg_SchemaOpt)), + /* ColNames: */ FiPragCName: U8(8), FnPragCName: U8(7), + /* iArg: */ FiArg: uint64(1)}, + { /* zName: */ FzName: ts + 18208, /* "temp_store" */ + /* ePragTyp: */ FePragTyp: PragTyp_TEMP_STORE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1))}, + { /* zName: */ FzName: ts + 18219, /* "temp_store_direc..." */ + /* ePragTyp: */ FePragTyp: PragTyp_TEMP_STORE_DIRECTORY, + /* ePragFlg: */ FmPragFlg: PragFlg_NoColumns1}, + { /* zName: */ FzName: ts + 18240, /* "threads" */ + /* ePragTyp: */ FePragTyp: PragTyp_THREADS, + /* ePragFlg: */ FmPragFlg: PragFlg_Result0}, + { /* zName: */ FzName: ts + 18248, /* "trusted_schema" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: SQLITE_TrustedSchema}, + { /* zName: */ FzName: ts + 18263, /* "user_version" */ + /* ePragTyp: */ FePragTyp: PragTyp_HEADER_VALUE, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_NoColumns1 | PragFlg_Result0)), + /* iArg: */ FiArg: BTREE_USER_VERSION}, + { /* zName: */ FzName: ts + 18276, /* "wal_autocheckpoi..." */ + /* ePragTyp: */ FePragTyp: PragTyp_WAL_AUTOCHECKPOINT}, + { /* zName: */ FzName: ts + 18295, /* "wal_checkpoint" */ + /* ePragTyp: */ FePragTyp: PragTyp_WAL_CHECKPOINT, + /* ePragFlg: */ FmPragFlg: PragFlg_NeedSchema, + /* ColNames: */ FiPragCName: U8(44), FnPragCName: U8(3)}, + { /* zName: */ FzName: ts + 18310, /* "writable_schema" */ + /* ePragTyp: */ FePragTyp: PragTyp_FLAG, + /* ePragFlg: */ FmPragFlg: (U8(PragFlg_Result0 | PragFlg_NoColumns1)), + /* iArg: */ FiArg: (uint64(SQLITE_WriteSchema | SQLITE_NoSchemaError))}, } /* sqlite3.c:125260:25 */ // Number of pragmas: 67 on by default, 77 total. @@ -107726,10 +105674,10 @@ func Xsqlite3GetBoolean(tls *libc.TLS, z uintptr, dflt U8) U8 { /* sqlite3.c:125 func getLockingMode(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:125827:12: */ if z != 0 { if 0 == Xsqlite3StrICmp(tls, z, ts+18351 /* "exclusive" */) { - return 1 + return PAGER_LOCKINGMODE_EXCLUSIVE } if 0 == Xsqlite3StrICmp(tls, z, ts+18361 /* "normal" */) { - return 0 + return PAGER_LOCKINGMODE_NORMAL } } return -1 @@ -107742,13 +105690,13 @@ func getLockingMode(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:125827:12: */ func getAutoVacuum(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:125842:12: */ var i int32 if 0 == Xsqlite3StrICmp(tls, z, ts+18368 /* "none" */) { - return 0 + return BTREE_AUTOVACUUM_NONE } if 0 == Xsqlite3StrICmp(tls, z, ts+18373 /* "full" */) { - return 1 + return BTREE_AUTOVACUUM_FULL } if 0 == Xsqlite3StrICmp(tls, z, ts+18378 /* "incremental" */) { - return 2 + return BTREE_AUTOVACUUM_INCR } i = Xsqlite3Atoi(tls, z) return int32(func() uint8 { @@ -107763,8 +105711,8 @@ func getAutoVacuum(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:125842:12: */ // backed temporary databases, 2 for the Red-Black tree in memory database // and 0 to use the compile-time default. func getTempStore(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:125858:12: */ - if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) <= '2') { - return (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) - '0') + if (int32(*(*int8)(unsafe.Pointer(z))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z))) <= '2') { + return (int32(*(*int8)(unsafe.Pointer(z))) - '0') } else if Xsqlite3StrICmp(tls, z, ts+17296 /* "file" */) == 0 { return 1 } else if Xsqlite3StrICmp(tls, z, ts+18390 /* "memory" */) == 0 { @@ -107779,17 +105727,17 @@ func getTempStore(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:125858:12: */ // from default, or when 'file' and the temp_store_directory has changed func invalidateTempStorage(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:125876:12: */ var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpBt != uintptr(0) { - if !(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0) || (Xsqlite3BtreeIsInReadTrans(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpBt) != 0) { + if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpBt != uintptr(0) { + if !(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0) || (Xsqlite3BtreeIsInReadTrans(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpBt) != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+18397 /* "temporary storag..." */, 0) - return 1 + return SQLITE_ERROR } - Xsqlite3BtreeClose(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpBt) - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(1)*32)).FpBt = uintptr(0) + Xsqlite3BtreeClose(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpBt) + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*32)).FpBt = uintptr(0) Xsqlite3ResetAllSchemasOfConnection(tls, db) } - return 0 + return SQLITE_OK } // If the TEMP database is open, close it and mark the database schema @@ -107799,13 +105747,13 @@ func changeTempStorage(tls *libc.TLS, pParse uintptr, zStorageType uintptr) int3 var ts int32 = getTempStore(tls, zStorageType) var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb if int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) == ts { - return 0 + return SQLITE_OK } - if invalidateTempStorage(tls, pParse) != 0 { - return 1 + if invalidateTempStorage(tls, pParse) != SQLITE_OK { + return SQLITE_ERROR } (*Sqlite3)(unsafe.Pointer(db)).Ftemp_store = U8(ts) - return 0 + return SQLITE_OK } // Set result column names for a pragma. @@ -107818,7 +105766,7 @@ func setPragmaResultColumnNames(tls *libc.TLS, v uintptr, pPragma uintptr) { /* return int32(n) }()) if int32(n) == 0 { - Xsqlite3VdbeSetColName(tls, v, 0, 0, (*PragmaName)(unsafe.Pointer(pPragma)).FzName, uintptr(0)) + Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, (*PragmaName)(unsafe.Pointer(pPragma)).FzName, uintptr(0)) } else { var i int32 var j int32 @@ -107829,7 +105777,7 @@ func setPragmaResultColumnNames(tls *libc.TLS, v uintptr, pPragma uintptr) { /* goto __3 } { - Xsqlite3VdbeSetColName(tls, v, i, 0, pragCName[j], uintptr(0)) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, pragCName[j], uintptr(0)) } goto __2 @@ -107848,15 +105796,15 @@ func returnSingleInt(tls *libc.TLS, v uintptr, value I64) { /* sqlite3.c:125932: defer tls.Free(8) *(*I64)(unsafe.Pointer(bp)) = value - Xsqlite3VdbeAddOp4Dup8(tls, v, 70, 0, 1, 0, bp /* &value */, -14) - Xsqlite3VdbeAddOp2(tls, v, 80, 1, 1) + Xsqlite3VdbeAddOp4Dup8(tls, v, OP_Int64, 0, 1, 0, bp /* &value */, -14) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 1) } // Generate code to return a single text value. func returnSingleText(tls *libc.TLS, v uintptr, zValue uintptr) { /* sqlite3.c:125940:13: */ if zValue != 0 { Xsqlite3VdbeLoadString(tls, v, 1, zValue) - Xsqlite3VdbeAddOp2(tls, v, 80, 1, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 1) } } @@ -107870,7 +105818,7 @@ func setAllPagerFlags(tls *libc.TLS, db uintptr) { /* sqlite3.c:125956:13: */ for (libc.PostDecInt32(&n, 1)) > 0 { if (*Db)(unsafe.Pointer(pDb)).FpBt != 0 { Xsqlite3BtreeSetPagerFlags(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, - (uint32(U64((*Db)(unsafe.Pointer(pDb)).Fsafety_level) | ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x38))))) + (uint32(U64((*Db)(unsafe.Pointer(pDb)).Fsafety_level) | ((*Sqlite3)(unsafe.Pointer(db)).Fflags & PAGER_FLAGS_MASK)))) } pDb += 32 } @@ -107881,16 +105829,16 @@ func setAllPagerFlags(tls *libc.TLS, db uintptr) { /* sqlite3.c:125956:13: */ func actionName(tls *libc.TLS, action U8) uintptr { /* sqlite3.c:125984:19: */ var zName uintptr switch int32(action) { - case 8: + case OE_SetNull: zName = ts + 18459 /* "SET NULL" */ break - case 9: + case OE_SetDflt: zName = ts + 18468 /* "SET DEFAULT" */ break - case 10: + case OE_Cascade: zName = ts + 18480 /* "CASCADE" */ break - case 7: + case OE_Restrict: zName = ts + 18488 /* "RESTRICT" */ break default: @@ -107953,7 +105901,7 @@ func pragmaFunclistLine(tls *libc.TLS, v uintptr, p uintptr, isBuiltin int32, sh if (*FuncDef)(unsafe.Pointer(p)).FxSFunc == uintptr(0) { continue } - if (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & U32(0x00040000)) != U32(0)) && + if (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & SQLITE_FUNC_INTERNAL) != U32(0)) && (showInternFuncs == 0) { continue } @@ -107966,14 +105914,14 @@ func pragmaFunclistLine(tls *libc.TLS, v uintptr, p uintptr, isBuiltin int32, sh } Xsqlite3VdbeMultiLoad(tls, v, 1, ts+18545, /* "sissii" */ libc.VaList(bp, (*FuncDef)(unsafe.Pointer(p)).FzName, isBuiltin, - zType, azEnc[((*FuncDef)(unsafe.Pointer(p)).FfuncFlags&U32(0x0003))], + zType, azEnc[((*FuncDef)(unsafe.Pointer(p)).FfuncFlags&SQLITE_FUNC_ENCMASK)], int32((*FuncDef)(unsafe.Pointer(p)).FnArg), - (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags&mask)^U32(0x000200000)))) + (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags&mask)^SQLITE_INNOCUOUS))) } } -var mask U32 = (U32((((0x000000800 | 0x000080000) | 0x000100000) | 0x000200000) | 0x00040000)) /* sqlite3.c:126055:22 */ -var azEnc = [4]uintptr{uintptr(0), ts + 18552 /* "utf8" */, ts + 18557 /* "utf16le" */, ts + 18565 /* "utf16be" */} /* sqlite3.c:126062:23 */ +var mask U32 = (U32((((SQLITE_DETERMINISTIC | SQLITE_DIRECTONLY) | SQLITE_SUBTYPE) | SQLITE_INNOCUOUS) | SQLITE_FUNC_INTERNAL)) /* sqlite3.c:126055:22 */ +var azEnc = [4]uintptr{uintptr(0), ts + 18552 /* "utf8" */, ts + 18557 /* "utf16le" */, ts + 18565 /* "utf16be" */} /* sqlite3.c:126062:23 */ // Helper subroutine for PRAGMA integrity_check: // @@ -107982,10 +105930,10 @@ var azEnc = [4]uintptr{uintptr(0), ts + 18552 /* "utf8" */, ts + 18557 /* "utf16 // and halt if the maximum number of result rows have been issued. func integrityCheckResultRow(tls *libc.TLS, v uintptr) int32 { /* sqlite3.c:126099:12: */ var addr int32 - Xsqlite3VdbeAddOp2(tls, v, 80, 3, 1) - addr = Xsqlite3VdbeAddOp3(tls, v, 48, 1, (Xsqlite3VdbeCurrentAddr(tls, v) + 2), 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 3, 1) + addr = Xsqlite3VdbeAddOp3(tls, v, OP_IfPos, 1, (Xsqlite3VdbeCurrentAddr(tls, v) + 2), 1) - Xsqlite3VdbeAddOp0(tls, v, 68) + Xsqlite3VdbeAddOp0(tls, v, OP_Halt) return addr } @@ -108253,7 +106201,7 @@ __6: } else { zDb = uintptr(0) } - if !(Xsqlite3AuthCheck(tls, pParse, 19, zLeft, zRight, zDb) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) != 0) { goto __7 } goto pragma_out @@ -108274,30 +106222,30 @@ __7: // second element of the array is the name of the pragma and the third // element is the argument to the pragma or NULL if the pragma has no // argument. - *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + uintptr(0)*8)) = uintptr(0) - *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + uintptr(1)*8)) = zLeft - *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + uintptr(2)*8)) = zRight - *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + uintptr(3)*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + 1*8)) = zLeft + *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + 2*8)) = zRight + *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + 3*8)) = uintptr(0) (*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 - rc = Xsqlite3_file_control(tls, db, zDb, 14, bp+384 /* aFcntl */) - if !(rc == 0) { + rc = Xsqlite3_file_control(tls, db, zDb, SQLITE_FCNTL_PRAGMA, bp+384 /* aFcntl */) + if !(rc == SQLITE_OK) { goto __8 } Xsqlite3VdbeSetNumCols(tls, v, 1) - Xsqlite3VdbeSetColName(tls, v, 0, 0, *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + uintptr(0)*8)), libc.UintptrFromInt32(-1)) - returnSingleText(tls, v, *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + uintptr(0)*8))) - Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + uintptr(0)*8))) + Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */)), libc.UintptrFromInt32(-1)) + returnSingleText(tls, v, *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */))) + Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */))) goto pragma_out __8: ; - if !(rc != 12) { + if !(rc != SQLITE_NOTFOUND) { goto __9 } - if !(*(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + uintptr(0)*8)) != 0) { + if !(*(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */)) != 0) { goto __10 } - Xsqlite3ErrorMsg(tls, pParse, ts+824 /* "%s" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + uintptr(0)*8)))) - Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */ + uintptr(0)*8))) + Xsqlite3ErrorMsg(tls, pParse, ts+824 /* "%s" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */)))) + Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 384 /* &aFcntl[0] */))) __10: ; (*Parse)(unsafe.Pointer(pParse)).FnErr++ @@ -108316,7 +106264,7 @@ __11: ; // Make sure the database schema is loaded if the pragma requires that - if !((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & 0x01) != 0) { + if !((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & PragFlg_NeedSchema) != 0) { goto __12 } if !(Xsqlite3ReadSchema(tls, pParse) != 0) { @@ -108329,8 +106277,8 @@ __12: ; // Register the result column names for pragmas that return results - if !(((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & 0x02) == 0) && - (((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & 0x04) == 0) || (zRight == uintptr(0)))) { + if !(((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & PragFlg_NoColumns) == 0) && + (((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & PragFlg_NoColumns1) == 0) || (zRight == uintptr(0)))) { goto __14 } setPragmaResultColumnNames(tls, v, pPragma) @@ -108354,7 +106302,7 @@ __14: // is always on by default regardless of the sign of the default cache // size. But continue to take the absolute value of the default cache // size of historical compatibility. - case 13: + case PragTyp_DEFAULT_CACHE_SIZE: goto __16 // PRAGMA [schema.]page_size @@ -108364,7 +106312,7 @@ __14: // database page size in bytes. The second form sets the // database page size value. The value can only be set if // the database has not yet been created. - case 31: + case PragTyp_PAGE_SIZE: goto __17 // PRAGMA [schema.]secure_delete @@ -108373,7 +106321,7 @@ __14: // The first form reports the current setting for the // secure_delete flag. The second form changes the secure_delete // flag setting and reports the new value. - case 33: + case PragTyp_SECURE_DELETE: goto __18 // PRAGMA [schema.]max_page_count @@ -108391,25 +106339,25 @@ __14: // PRAGMA [schema.]page_count // // Return the number of pages in the specified database. - case 27: + case PragTyp_PAGE_COUNT: goto __19 // PRAGMA [schema.]locking_mode // PRAGMA [schema.]locking_mode = (normal|exclusive) - case 26: + case PragTyp_LOCKING_MODE: goto __20 // PRAGMA [schema.]journal_mode // PRAGMA [schema.]journal_mode = // (delete|persist|off|truncate|memory|wal|off) - case 23: + case PragTyp_JOURNAL_MODE: goto __21 // PRAGMA [schema.]journal_size_limit // PRAGMA [schema.]journal_size_limit=N // // Get or set the size limit on rollback journal files. - case 24: + case PragTyp_JOURNAL_SIZE_LIMIT: goto __22 // PRAGMA [schema.]auto_vacuum @@ -108417,13 +106365,13 @@ __14: // // Get or set the value of the database 'auto-vacuum' parameter. // The value is one of: 0 NONE 1 FULL 2 INCREMENTAL - case 3: + case PragTyp_AUTO_VACUUM: goto __23 // PRAGMA [schema.]incremental_vacuum(N) // // Do N steps of incremental vacuuming on a database. - case 19: + case PragTyp_INCREMENTAL_VACUUM: goto __24 // PRAGMA [schema.]cache_size @@ -108435,7 +106383,7 @@ __14: // number of pages in the cache. If N is negative, then the // number of pages is adjusted so that the cache uses -N kibibytes // of memory. - case 6: + case PragTyp_CACHE_SIZE: goto __25 // PRAGMA [schema.]cache_spill @@ -108458,7 +106406,7 @@ __14: // // The cache_spill=BOOLEAN setting applies to all attached schemas, // not just the schema specified. - case 7: + case PragTyp_CACHE_SPILL: goto __26 // PRAGMA [schema.]mmap_size(N) @@ -108473,7 +106421,7 @@ __14: // This value is advisory. The underlying VFS is free to memory map // as little or as much as it wants. Except, if N is set to 0 then the // upper layers will never invoke the xFetch interfaces to the VFS. - case 28: + case PragTyp_MMAP_SIZE: goto __27 // PRAGMA temp_store @@ -108485,7 +106433,7 @@ __14: // // Note that it is possible for the library compile-time options to // override this setting - case 38: + case PragTyp_TEMP_STORE: goto __28 // PRAGMA temp_store_directory @@ -108496,7 +106444,7 @@ __14: // Setting to a null string reverts to the default temporary directory search. // If temporary directory is changed, then invalidateTempStorage. // - case 39: + case PragTyp_TEMP_STORE_DIRECTORY: goto __29 // PRAGMA [schema.]synchronous @@ -108506,10 +106454,10 @@ __14: // the local value does not make changes to the disk file and the // default value will be restored the next time the database is // opened. - case 36: + case PragTyp_SYNCHRONOUS: goto __30 - case 4: + case PragTyp_FLAG: goto __31 // PRAGMA table_info(
    ) @@ -108523,39 +106471,39 @@ __14: // notnull: True if 'NOT NULL' is part of column declaration // dflt_value: The default value for the column, if any. // pk: Non-zero for PK fields. - case 37: + case PragTyp_TABLE_INFO: goto __32 - case 20: + case PragTyp_INDEX_INFO: goto __33 - case 21: + case PragTyp_INDEX_LIST: goto __34 - case 12: + case PragTyp_DATABASE_LIST: goto __35 - case 9: + case PragTyp_COLLATION_LIST: goto __36 - case 17: + case PragTyp_FUNCTION_LIST: goto __37 - case 29: + case PragTyp_MODULE_LIST: goto __38 - case 32: + case PragTyp_PRAGMA_LIST: goto __39 - case 16: + case PragTyp_FOREIGN_KEY_LIST: goto __40 - case 15: + case PragTyp_FOREIGN_KEY_CHECK: goto __41 // Reinstall the LIKE and GLOB functions. The variant of LIKE // used will be case sensitive or not depending on the RHS. - case 8: + case PragTyp_CASE_SENSITIVE_LIKE: goto __42 // PRAGMA integrity_check @@ -108581,7 +106529,7 @@ __14: // schema, use the form: // // PRAGMA schema.integrity_check; - case 22: + case PragTyp_INTEGRITY_CHECK: goto __43 // PRAGMA encoding @@ -108604,7 +106552,7 @@ __14: // In the second form this pragma sets the text encoding to be used in // new database files created using this database handle. It is only // useful if invoked immediately after the main database i - case 14: + case PragTyp_ENCODING: goto __44 // PRAGMA [schema.]schema_version @@ -108637,20 +106585,20 @@ __14: // // The user-version is not used internally by SQLite. It may be used by // applications for any purpose. - case 2: + case PragTyp_HEADER_VALUE: goto __45 // PRAGMA compile_options // // Return the names of all compile-time options used in this build, // one option per row. - case 10: + case PragTyp_COMPILE_OPTIONS: goto __46 // PRAGMA [schema.]wal_checkpoint = passive|full|restart|truncate // // Checkpoint the database. - case 42: + case PragTyp_WAL_CHECKPOINT: goto __47 // PRAGMA wal_autocheckpoint @@ -108659,7 +106607,7 @@ __14: // Configure a database connection to automatically checkpoint a database // after accumulating N frames in the log. Or query for the current value // of N. - case 41: + case PragTyp_WAL_AUTOCHECKPOINT: goto __48 // PRAGMA shrink_memory @@ -108667,7 +106615,7 @@ __14: // IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database // connection on which it is invoked to free up as much memory as it // can, by calling sqlite3_db_release_memory(). - case 34: + case PragTyp_SHRINK_MEMORY: goto __49 // PRAGMA optimize @@ -108722,7 +106670,7 @@ __14: // // The rules for when tables are analyzed are likely to change in // future releases. - case 30: + case PragTyp_OPTIMIZE: goto __50 // PRAGMA busy_timeout @@ -108745,7 +106693,7 @@ __14: // IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always // returns the same integer that would be returned by the // sqlite3_soft_heap_limit64(-1) C-language function. - case 35: + case PragTyp_SOFT_HEAP_LIMIT: goto __52 // PRAGMA hard_heap_limit @@ -108757,7 +106705,7 @@ __14: // sqlite3_hard_heap_limit64() C-language API can raise or deactivate // the hard heap limit. This allows an application to set a heap limit // constraint that cannot be relaxed by an untrusted SQL script. - case 18: + case PragTyp_HARD_HEAP_LIMIT: goto __53 // PRAGMA threads @@ -108765,7 +106713,7 @@ __14: // // Configure the maximum number of worker threads. Return the new // maximum, which might be less than requested. - case 40: + case PragTyp_THREADS: goto __54 // PRAGMA analysis_limit @@ -108773,11 +106721,11 @@ __14: // // Configure the maximum number of rows that ANALYZE will examine // in each index that it looks at. Return the new limit. - case 1: + case PragTyp_ANALYSIS_LIMIT: goto __55 // Report the current state of file logs for all databases - case 43: + case PragTyp_LOCK_STATUS: goto __56 } goto __15 @@ -108810,14 +106758,14 @@ __16: goto __15 __59: ; - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(0)*32)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(1)*32)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp + uintptr(6)*32)).Fp1 = -2000 + (*VdbeOp)(unsafe.Pointer(aOp)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp + 1*32)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp + 6*32)).Fp1 = -2000 goto __58 __57: size = Xsqlite3AbsInt32(tls, Xsqlite3Atoi(tls, zRight)) Xsqlite3BeginWriteOperation(tls, pParse, 0, iDb) - Xsqlite3VdbeAddOp3(tls, v, 94, iDb, 3, size) + Xsqlite3VdbeAddOp3(tls, v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, size) (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size Xsqlite3BtreeSetCacheSize(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size) @@ -108849,7 +106797,7 @@ __60: // Malloc may fail when setting the page-size, as there is an internal // buffer that the pager module resizes using sqlite3_realloc(). (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize = Xsqlite3Atoi(tls, zRight) - if !(7 == Xsqlite3BtreeSetPageSize(tls, pBt, (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0)) { + if !(SQLITE_NOMEM == Xsqlite3BtreeSetPageSize(tls, pBt, (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0)) { goto __62 } Xsqlite3OomFault(tls, db) @@ -108924,10 +106872,10 @@ __19: *(*I64)(unsafe.Pointer(bp + 416 /* x */)) = int64(0) Xsqlite3CodeVerifySchema(tls, pParse, iDb) iReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - if !((int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(zLeft + uintptr(0))))])) == 'p') { + if !((int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(zLeft)))])) == 'p') { goto __70 } - Xsqlite3VdbeAddOp2(tls, v, 168, iDb, iReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Pagecount, iDb, iReg) goto __71 __70: if !((zRight != 0) && (Xsqlite3DecOrHexToI64(tls, zRight, bp+416 /* &x */) == 0)) { @@ -108952,10 +106900,10 @@ __72: *(*I64)(unsafe.Pointer(bp + 416 /* x */)) = int64(0) __73: ; - Xsqlite3VdbeAddOp3(tls, v, 169, iDb, iReg, int32(*(*I64)(unsafe.Pointer(bp + 416 /* x */)))) + Xsqlite3VdbeAddOp3(tls, v, OP_MaxPgcnt, iDb, iReg, int32(*(*I64)(unsafe.Pointer(bp + 416 /* x */)))) __71: ; - Xsqlite3VdbeAddOp2(tls, v, 80, iReg, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, iReg, 1) goto __15 // PRAGMA [schema.]locking_mode @@ -108999,7 +106947,7 @@ __79: __78: ; - if !(eMode == 1) { + if !(eMode == PAGER_LOCKINGMODE_EXCLUSIVE) { goto __83 } zRet = ts + 18351 /* "exclusive" */ @@ -109048,7 +106996,7 @@ __88: eMode1 = -1 __90: ; - if !((eMode1 == 2) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x10000000)) != uint64(0))) { + if !((eMode1 == PAGER_JOURNALMODE_OFF) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_Defensive) != uint64(0))) { goto __91 } // Do not allow journal-mode "OFF" in defensive since the database @@ -109075,7 +107023,7 @@ __93: goto __96 } Xsqlite3VdbeUsesBtree(tls, v, ii2) - Xsqlite3VdbeAddOp3(tls, v, 7, ii2, 1, eMode1) + Xsqlite3VdbeAddOp3(tls, v, OP_JournalMode, ii2, 1, eMode1) __96: ; goto __94 @@ -109085,7 +107033,7 @@ __94: goto __95 __95: ; - Xsqlite3VdbeAddOp2(tls, v, 80, 1, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 1) goto __15 // PRAGMA [schema.]journal_size_limit @@ -109133,7 +107081,7 @@ __99: // creates the database file. It is important that it is created // as an auto-vacuum capable db. rc = Xsqlite3BtreeSetAutoVacuum(tls, pBt2, eAuto) - if !((rc == 0) && ((eAuto == 1) || (eAuto == 2))) { + if !((rc == SQLITE_OK) && ((eAuto == 1) || (eAuto == 2))) { goto __101 } iAddr = Xsqlite3VdbeCurrentAddr(tls, v) @@ -109145,11 +107093,11 @@ __99: goto __15 __102: ; - (*VdbeOp)(unsafe.Pointer(aOp1 + uintptr(0)*32)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp1 + uintptr(1)*32)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp1 + uintptr(2)*32)).Fp2 = (iAddr + 4) - (*VdbeOp)(unsafe.Pointer(aOp1 + uintptr(4)*32)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp1 + uintptr(4)*32)).Fp3 = (eAuto - 1) + (*VdbeOp)(unsafe.Pointer(aOp1)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp1 + 1*32)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp1 + 2*32)).Fp2 = (iAddr + 4) + (*VdbeOp)(unsafe.Pointer(aOp1 + 4*32)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp1 + 4*32)).Fp3 = (eAuto - 1) Xsqlite3VdbeUsesBtree(tls, v, iDb) __101: ; @@ -109168,11 +107116,11 @@ __24: __103: ; Xsqlite3BeginWriteOperation(tls, pParse, 0, iDb) - Xsqlite3VdbeAddOp2(tls, v, 69, *(*int32)(unsafe.Pointer(bp + 432 /* iLimit1 */)), 1) - addr = Xsqlite3VdbeAddOp1(tls, v, 60, iDb) - Xsqlite3VdbeAddOp1(tls, v, 80, 1) - Xsqlite3VdbeAddOp2(tls, v, 82, 1, -1) - Xsqlite3VdbeAddOp2(tls, v, 48, 1, addr) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, *(*int32)(unsafe.Pointer(bp + 432 /* iLimit1 */)), 1) + addr = Xsqlite3VdbeAddOp1(tls, v, OP_IncrVacuum, iDb) + Xsqlite3VdbeAddOp1(tls, v, OP_ResultRow, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, 1, -1) + Xsqlite3VdbeAddOp2(tls, v, OP_IfPos, 1, addr) Xsqlite3VdbeJumpHere(tls, v, addr) goto __15 @@ -109227,7 +107175,7 @@ __26: } returnSingleInt(tls, v, func() int64 { - if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000020)) == uint64(0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_CacheSpill) == uint64(0) { return int64(0) } return int64(Xsqlite3BtreeSetSpillSize(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, 0)) @@ -109244,10 +107192,10 @@ __108: if !(Xsqlite3GetBoolean(tls, zRight, (uint8(libc.Bool32(*(*int32)(unsafe.Pointer(bp + 436 /* size3 */)) != 0)))) != 0) { goto __109 } - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(0x00000020)) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (SQLITE_CacheSpill) goto __110 __109: - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x00000020))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_CacheSpill)) __110: ; setAllPagerFlags(tls, db) @@ -109306,14 +107254,14 @@ __116: __111: ; *(*Sqlite3_int64)(unsafe.Pointer(bp + 440 /* sz */)) = int64(-1) - rc = Xsqlite3_file_control(tls, db, zDb, 18, bp+440 /* &sz */) - if !(rc == 0) { + rc = Xsqlite3_file_control(tls, db, zDb, SQLITE_FCNTL_MMAP_SIZE, bp+440 /* &sz */) + if !(rc == SQLITE_OK) { goto __118 } returnSingleInt(tls, v, *(*Sqlite3_int64)(unsafe.Pointer(bp + 440 /* sz */))) goto __119 __118: - if !(rc != 12) { + if !(rc != SQLITE_NOTFOUND) { goto __120 } (*Parse)(unsafe.Pointer(pParse)).FnErr++ @@ -109360,11 +107308,11 @@ __29: returnSingleText(tls, v, Xsqlite3_temp_directory) goto __124 __123: - if !(*(*int8)(unsafe.Pointer(zRight + uintptr(0))) != 0) { + if !(*(*int8)(unsafe.Pointer(zRight)) != 0) { goto __125 } - rc = Xsqlite3OsAccess(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, zRight, 1, bp+448 /* &res */) - if !((rc != 0) || (*(*int32)(unsafe.Pointer(bp + 448 /* res */)) == 0)) { + rc = Xsqlite3OsAccess(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, zRight, SQLITE_ACCESS_READWRITE, bp+448 /* &res */) + if !((rc != SQLITE_OK) || (*(*int32)(unsafe.Pointer(bp + 448 /* res */)) == 0)) { goto __126 } Xsqlite3ErrorMsg(tls, pParse, ts+18582 /* "not a writable d..." */, 0) @@ -109373,16 +107321,16 @@ __126: ; __125: ; - if !(((1 == 0) || - ((1 == 1) && (int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) <= 1))) || - ((1 == 2) && (int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) == 1))) { + if !(((SQLITE_TEMP_STORE == 0) || + ((SQLITE_TEMP_STORE == 1) && (int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) <= 1))) || + ((SQLITE_TEMP_STORE == 2) && (int32((*Sqlite3)(unsafe.Pointer(db)).Ftemp_store) == 1))) { goto __127 } invalidateTempStorage(tls, pParse) __127: ; Xsqlite3_free(tls, Xsqlite3_temp_directory) - if !(*(*int8)(unsafe.Pointer(zRight + uintptr(0))) != 0) { + if !(*(*int8)(unsafe.Pointer(zRight)) != 0) { goto __128 } Xsqlite3_temp_directory = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp+16, zRight)) @@ -109419,7 +107367,7 @@ __132: if !(iDb != 1) { goto __134 } - iLevel = ((int32(getSafetyLevel(tls, zRight, 0, uint8(1))) + 1) & 0x07) + iLevel = ((int32(getSafetyLevel(tls, zRight, 0, uint8(1))) + 1) & PAGER_SYNCHRONOUS_MASK) if !(iLevel == 0) { goto __135 } @@ -109451,7 +107399,7 @@ __136: } // Foreign key support may not be enabled or disabled while not // in auto-commit mode. - mask = mask & (^libc.Uint64FromInt32(0x00004000)) + mask = mask & (libc.Uint64FromInt32(libc.CplInt32(SQLITE_ForeignKeys))) __138: ; @@ -109462,7 +107410,7 @@ __138: goto __140 __139: *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^mask) - if !(mask == uint64(0x00080000)) { + if !(mask == SQLITE_DeferFKs) { goto __141 } (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = int64(0) @@ -109474,7 +107422,7 @@ __140: // Many of the flag-pragmas modify the code generated by the SQL // compiler (eg. count_changes). So add an opcode to expire all // compiled SQL statements after modifying a pragma value. - Xsqlite3VdbeAddOp0(tls, v, 158) + Xsqlite3VdbeAddOp0(tls, v, OP_Expire) setAllPagerFlags(tls, db) __137: ; @@ -109496,7 +107444,7 @@ __32: goto __142 } Xsqlite3CodeVerifyNamedSchema(tls, pParse, zDb) - pTab = Xsqlite3LocateTable(tls, pParse, uint32(0x02), zRight, zDb) + pTab = Xsqlite3LocateTable(tls, pParse, LOCATE_NOERR, zRight, zDb) if !(pTab != 0) { goto __143 } @@ -109511,7 +107459,7 @@ __144: goto __146 } isHidden = 0 - if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0062) != 0) { + if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_NOINSERT) != 0) { goto __147 } if !((*PragmaName)(unsafe.Pointer(pPragma)).FiArg == uint64(0)) { @@ -109521,13 +107469,13 @@ __144: goto __145 __148: ; - if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0020) != 0) { + if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_VIRTUAL) != 0) { goto __149 } isHidden = 2 // GENERATED ALWAYS AS ... VIRTUAL goto __150 __149: - if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0040) != 0) { + if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_STORED) != 0) { goto __151 } isHidden = 3 // GENERATED ALWAYS AS ... STORED @@ -109541,7 +107489,7 @@ __150: ; __147: ; - if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0001) == 0) { + if !((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_PRIMKEY) == 0) { goto __153 } k = 0 @@ -109618,8 +107566,8 @@ __33: // If there is no index named zRight, check to see if there is a // WITHOUT ROWID table named zRight, and if there is, show the // structure of the PRIMARY KEY index for that table. - pTab1 = Xsqlite3LocateTable(tls, pParse, uint32(0x02), zRight, zDb) - if !((pTab1 != 0) && !(((*Table)(unsafe.Pointer((pTab1))).FtabFlags & U32(0x0080)) == U32(0))) { + pTab1 = Xsqlite3LocateTable(tls, pParse, LOCATE_NOERR, zRight, zDb) + if !((pTab1 != 0) && !(((*Table)(unsafe.Pointer((pTab1))).FtabFlags & TF_WithoutRowid) == U32(0))) { goto __162 } pIdx = Xsqlite3PrimaryKeyIndex(tls, pTab1) @@ -109669,7 +107617,7 @@ __166: (libc.Bool32(i1 < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol))))) __169: ; - Xsqlite3VdbeAddOp2(tls, v, 80, 1, (*Parse)(unsafe.Pointer(pParse)).FnMem) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, (*Parse)(unsafe.Pointer(pParse)).FnMem) goto __167 __167: i1++ @@ -109704,7 +107652,7 @@ __172: Xsqlite3VdbeMultiLoad(tls, v, 1, ts+18689, /* "isisi" */ libc.VaList(bp+128, i2, (*Index)(unsafe.Pointer(pIdx1)).FzName, - (libc.Bool32(int32((*Index)(unsafe.Pointer((pIdx1))).FonError) != 0)), + (libc.Bool32(int32((*Index)(unsafe.Pointer((pIdx1))).FonError) != OE_None)), *(*uintptr)(unsafe.Pointer(bp + 456 /* &azOrigin[0] */ + uintptr((uint32(int32(*(*uint16)(unsafe.Pointer(pIdx1 + 100 /* &.idxType */))&0x3>>0))))*8)), (libc.Bool32((*Index)(unsafe.Pointer(pIdx1)).FpPartIdxWhere != uintptr(0))))) goto __173 @@ -109770,11 +107718,11 @@ __181: goto __15 __37: - showInternFunc = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0020)) != U32(0))) + showInternFunc = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_InternalFunc) != U32(0))) (*Parse)(unsafe.Pointer(pParse)).FnMem = 6 i5 = 0 __182: - if !(i5 < 23) { + if !(i5 < SQLITE_FUNC_HASH_SZ) { goto __184 } p1 = *(*uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&Xsqlite3BuiltinFunctions)) /* &.a */) + uintptr(i5)*8)) @@ -109881,8 +107829,8 @@ __202: (*FKey)(unsafe.Pointer(pFK)).FzTo, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab3)).FaCol+uintptr((*sColMap)(unsafe.Pointer((pFK+64 /* &.aCol */)+uintptr(j2)*16)).FiFrom)*32)).FzName, (*sColMap)(unsafe.Pointer((pFK+64 /* &.aCol */)+uintptr(j2)*16)).FzCol, - actionName(tls, *(*U8)(unsafe.Pointer((pFK + 45 /* &.aAction */) + uintptr(1)))), // ON UPDATE - actionName(tls, *(*U8)(unsafe.Pointer((pFK + 45 /* &.aAction */) + uintptr(0)))), // ON DELETE + actionName(tls, *(*U8)(unsafe.Pointer((pFK + 45 /* &.aAction */) + 1))), // ON UPDATE + actionName(tls, *(*U8)(unsafe.Pointer((pFK + 45 /* &.aAction */)))), // ON DELETE ts+4677 /* "NONE" */)) goto __203 __203: @@ -109942,7 +107890,7 @@ __209: (*Parse)(unsafe.Pointer(pParse)).FnMem = (int32((*Table)(unsafe.Pointer(pTab4)).FnCol) + regRow) __210: ; - Xsqlite3OpenTable(tls, pParse, 0, iDb, pTab4, 96) + Xsqlite3OpenTable(tls, pParse, 0, iDb, pTab4, OP_OpenRead) Xsqlite3VdbeLoadString(tls, v, regResult, (*Table)(unsafe.Pointer(pTab4)).FzName) i8 = 1 pFK1 = (*Table)(unsafe.Pointer(pTab4)).FpFKey @@ -109966,10 +107914,10 @@ __214: if !(*(*uintptr)(unsafe.Pointer(bp + 480 /* pIdx2 */)) == uintptr(0)) { goto __217 } - Xsqlite3OpenTable(tls, pParse, i8, iDb, pParent, 96) + Xsqlite3OpenTable(tls, pParse, i8, iDb, pParent, OP_OpenRead) goto __218 __217: - Xsqlite3VdbeAddOp3(tls, v, 96, i8, int32((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 480 /* pIdx2 */)))).Ftnum), iDb) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenRead, i8, int32((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 480 /* pIdx2 */)))).Ftnum), iDb) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 480 /* pIdx2 */))) __218: ; @@ -110000,7 +107948,7 @@ __219: (*Parse)(unsafe.Pointer(pParse)).FnTab = i8 __220: ; - addrTop = Xsqlite3VdbeAddOp1(tls, v, 37, 0) + addrTop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, 0) i8 = 1 pFK1 = (*Table)(unsafe.Pointer(pTab4)).FpFKey __221: @@ -110034,7 +107982,7 @@ __225: iCol = (*sColMap)(unsafe.Pointer((pFK1 + 64 /* &.aCol */) + uintptr(j3)*16)).FiFrom } Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab4, 0, iCol, (regRow + j3)) - Xsqlite3VdbeAddOp2(tls, v, 50, (regRow + j3), addrOk) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (regRow + j3), addrOk) goto __226 __226: j3++ @@ -110048,9 +107996,9 @@ __227: if !(*(*uintptr)(unsafe.Pointer(bp + 480 /* pIdx2 */)) != 0) { goto __228 } - Xsqlite3VdbeAddOp4(tls, v, 91, regRow, (*FKey)(unsafe.Pointer(pFK1)).FnCol, regKey, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regRow, (*FKey)(unsafe.Pointer(pFK1)).FnCol, regKey, Xsqlite3IndexAffinityStr(tls, db, *(*uintptr)(unsafe.Pointer(bp + 480 /* pIdx2 */))), (*FKey)(unsafe.Pointer(pFK1)).FnCol) - Xsqlite3VdbeAddOp4Int(tls, v, 30, i8, addrOk, regKey, 0) + Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, i8, addrOk, regKey, 0) goto __229 __228: @@ -110058,7 +108006,7 @@ __228: goto __230 } jmp = (Xsqlite3VdbeCurrentAddr(tls, v) + 2) - Xsqlite3VdbeAddOp3(tls, v, 31, i8, jmp, regRow) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, i8, jmp, regRow) Xsqlite3VdbeGoto(tls, v, addrOk) __230: @@ -110067,17 +108015,17 @@ __229: ; // Generate code to report an FK violation to the caller. - if !(((*Table)(unsafe.Pointer((pTab4))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab4))).FtabFlags & TF_WithoutRowid) == U32(0)) { goto __231 } - Xsqlite3VdbeAddOp2(tls, v, 127, 0, (regResult + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, 0, (regResult + 1)) goto __232 __231: - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (regResult + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (regResult + 1)) __232: ; Xsqlite3VdbeMultiLoad(tls, v, (regResult + 2), ts+18711 /* "siX" */, libc.VaList(bp+288, (*FKey)(unsafe.Pointer(pFK1)).FzTo, (i8-1))) - Xsqlite3VdbeAddOp2(tls, v, 80, regResult, 4) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, regResult, 4) Xsqlite3VdbeResolveLabel(tls, v, addrOk) Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 488 /* aiCols */))) goto __222 @@ -110088,7 +108036,7 @@ __222: goto __223 __223: ; - Xsqlite3VdbeAddOp2(tls, v, 5, 0, (addrTop + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, 0, (addrTop + 1)) Xsqlite3VdbeJumpHere(tls, v, addrTop) goto __205 __206: @@ -110134,7 +108082,7 @@ __233: __43: pObjTab = uintptr(0) // Check only this one table, if not NULL - isQuick = (libc.Bool32((int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(zLeft + uintptr(0))))])) == 'q')) + isQuick = (libc.Bool32((int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(zLeft)))])) == 'q')) // If the PRAGMA command was of the form "PRAGMA .integrity_check", // then iDb is set to the index of the database identified by . @@ -110157,7 +108105,7 @@ __234: (*Parse)(unsafe.Pointer(pParse)).FnMem = 6 // Set the maximum error count - *(*int32)(unsafe.Pointer(bp + 496 /* mxErr */)) = 100 + *(*int32)(unsafe.Pointer(bp + 496 /* mxErr */)) = SQLITE_INTEGRITY_CHECK_ERROR_MAX if !(zRight != 0) { goto __235 } @@ -110167,7 +108115,7 @@ __234: if !(*(*int32)(unsafe.Pointer(bp + 496 /* mxErr */)) <= 0) { goto __238 } - *(*int32)(unsafe.Pointer(bp + 496 /* mxErr */)) = 100 + *(*int32)(unsafe.Pointer(bp + 496 /* mxErr */)) = SQLITE_INTEGRITY_CHECK_ERROR_MAX __238: ; goto __237 @@ -110183,7 +108131,7 @@ __237: ; __235: ; - Xsqlite3VdbeAddOp2(tls, v, 69, (*(*int32)(unsafe.Pointer(bp + 496 /* mxErr */)) - 1), 1) // reg[1] holds errors left + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, (*(*int32)(unsafe.Pointer(bp + 496 /* mxErr */)) - 1), 1) // reg[1] holds errors left // Do an integrity check on each database file i9 = 0 @@ -110228,7 +108176,7 @@ __244: goto __245 __247: ; - if !(((*Table)(unsafe.Pointer((pTab5))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab5))).FtabFlags & TF_WithoutRowid) == U32(0)) { goto __248 } cnt++ @@ -110300,7 +108248,7 @@ __257: goto __258 __260: ; - if !(((*Table)(unsafe.Pointer((pTab6))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab6))).FtabFlags & TF_WithoutRowid) == U32(0)) { goto __261 } *(*int32)(unsafe.Pointer(aRoot + uintptr(libc.PreIncInt32(&cnt, 1))*4)) = int32((*Table)(unsafe.Pointer(pTab6)).Ftnum) @@ -110326,7 +108274,7 @@ __258: goto __259 __259: ; - *(*int32)(unsafe.Pointer(aRoot + uintptr(0)*4)) = cnt + *(*int32)(unsafe.Pointer(aRoot)) = cnt // Make sure sufficient number of registers have been allocated (*Parse)(unsafe.Pointer(pParse)).FnMem = func() int32 { @@ -110338,13 +108286,13 @@ __259: Xsqlite3ClearTempRegCache(tls, pParse) // Do the b-tree integrity checks - Xsqlite3VdbeAddOp4(tls, v, 146, 2, cnt, 1, aRoot, -15) + Xsqlite3VdbeAddOp4(tls, v, OP_IntegrityCk, 2, cnt, 1, aRoot, -15) Xsqlite3VdbeChangeP5(tls, v, uint16(U8(i9))) - addr1 = Xsqlite3VdbeAddOp1(tls, v, 50, 2) - Xsqlite3VdbeAddOp4(tls, v, 115, 0, 3, 0, + addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, 2) + Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0, Xsqlite3MPrintf(tls, db, ts+18715 /* "*** in database ..." */, libc.VaList(bp+304, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i9)*32)).FzDbSName)), -7) - Xsqlite3VdbeAddOp3(tls, v, 110, 2, 3, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 2, 3, 3) integrityCheckResultRow(tls, v) Xsqlite3VdbeJumpHere(tls, v, addr1) @@ -110370,23 +108318,23 @@ __268: goto __266 __269: ; - if ((*Table)(unsafe.Pointer((pTab7))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab7))).FtabFlags & TF_WithoutRowid) == U32(0) { pPk1 = uintptr(0) } else { pPk1 = Xsqlite3PrimaryKeyIndex(tls, pTab7) } - Xsqlite3OpenTableAndIndices(tls, pParse, pTab7, 96, uint8(0), + Xsqlite3OpenTableAndIndices(tls, pParse, pTab7, OP_OpenRead, uint8(0), 1, uintptr(0), bp+500 /* &iDataCur */, bp+504 /* &iIdxCur */) // reg[7] counts the number of entries in the table. // reg[8+i] counts the number of entries in the i-th index - Xsqlite3VdbeAddOp2(tls, v, 69, 0, 7) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, 7) j4 = 0 pIdx5 = (*Table)(unsafe.Pointer(pTab7)).FpIndex __270: if !(pIdx5 != 0) { goto __272 } - Xsqlite3VdbeAddOp2(tls, v, 69, 0, (8 + j4)) // index entries counter + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (8 + j4)) // index entries counter goto __271 __271: pIdx5 = (*Index)(unsafe.Pointer(pIdx5)).FpNext @@ -110396,14 +108344,14 @@ __271: __272: ; - Xsqlite3VdbeAddOp2(tls, v, 37, *(*int32)(unsafe.Pointer(bp + 500 /* iDataCur */)), 0) - loopTop = Xsqlite3VdbeAddOp2(tls, v, 82, 7, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, *(*int32)(unsafe.Pointer(bp + 500 /* iDataCur */)), 0) + loopTop = Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, 7, 1) if !(!(isQuick != 0)) { goto __273 } // Sanity check on record header decoding - Xsqlite3VdbeAddOp3(tls, v, 89, *(*int32)(unsafe.Pointer(bp + 500 /* iDataCur */)), (int32((*Table)(unsafe.Pointer(pTab7)).FnNVCol) - 1), 3) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x80)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, *(*int32)(unsafe.Pointer(bp + 500 /* iDataCur */)), (int32((*Table)(unsafe.Pointer(pTab7)).FnNVCol) - 1), 3) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_TYPEOFARG) __273: ; // Verify that all NOT NULL columns really are NOT NULL @@ -110425,16 +108373,16 @@ __277: __278: ; Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab7, *(*int32)(unsafe.Pointer(bp + 500 /* iDataCur */)), j4, 3) - if !(int32((*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, v, -1))).Fopcode) == 89) { + if !(int32((*VdbeOp)(unsafe.Pointer(Xsqlite3VdbeGetOp(tls, v, -1))).Fopcode) == OP_Column) { goto __279 } - Xsqlite3VdbeChangeP5(tls, v, uint16(0x80)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_TYPEOFARG) __279: ; - jmp2 = Xsqlite3VdbeAddOp1(tls, v, 51, 3) + jmp2 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, 3) zErr = Xsqlite3MPrintf(tls, db, ts+18739 /* "NULL value in %s..." */, libc.VaList(bp+312, (*Table)(unsafe.Pointer(pTab7)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab7)).FaCol+uintptr(j4)*32)).FzName)) - Xsqlite3VdbeAddOp4(tls, v, 115, 0, 3, 0, zErr, -7) + Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0, zErr, -7) integrityCheckResultRow(tls, v) Xsqlite3VdbeJumpHere(tls, v, jmp2) goto __275 @@ -110445,7 +108393,7 @@ __275: __276: ; // Verify CHECK constraints - if !(((*Table)(unsafe.Pointer(pTab7)).FpCheck != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000200)) == uint64(0))) { + if !(((*Table)(unsafe.Pointer(pTab7)).FpCheck != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_IgnoreChecks) == uint64(0))) { goto __280 } pCheck = Xsqlite3ExprListDup(tls, db, (*Table)(unsafe.Pointer(pTab7)).FpCheck, 0) @@ -110468,13 +108416,13 @@ __283: goto __284 __284: ; - Xsqlite3ExprIfTrue(tls, pParse, (*ExprList_item)(unsafe.Pointer((pCheck+8 /* &.a */)+uintptr(0)*32)).FpExpr, addrCkOk, - 0x10) + Xsqlite3ExprIfTrue(tls, pParse, (*ExprList_item)(unsafe.Pointer((pCheck + 8 /* &.a */))).FpExpr, addrCkOk, + SQLITE_JUMPIFNULL) Xsqlite3VdbeResolveLabel(tls, v, addrCkFault) (*Parse)(unsafe.Pointer(pParse)).FiSelfTab = 0 zErr1 = Xsqlite3MPrintf(tls, db, ts+18759, /* "CHECK constraint..." */ libc.VaList(bp+328, (*Table)(unsafe.Pointer(pTab7)).FzName)) - Xsqlite3VdbeAddOp4(tls, v, 115, 0, 3, 0, zErr1, -7) + Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, 3, 0, zErr1, -7) integrityCheckResultRow(tls, v) Xsqlite3VdbeResolveLabel(tls, v, addrCkOk) __281: @@ -110502,22 +108450,22 @@ __289: r1 = Xsqlite3GenerateIndexKey(tls, pParse, pIdx5, *(*int32)(unsafe.Pointer(bp + 500 /* iDataCur */)), 0, 0, bp+508, /* &jmp3 */ pPrior, r1) pPrior = pIdx5 - Xsqlite3VdbeAddOp2(tls, v, 82, (8 + j4), 1) // increment entry count + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (8 + j4), 1) // increment entry count // Verify that an index entry exists for the current table row - jmp21 = Xsqlite3VdbeAddOp4Int(tls, v, 30, (*(*int32)(unsafe.Pointer(bp + 504 /* iIdxCur */)) + j4), ckUniq, r1, + jmp21 = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, (*(*int32)(unsafe.Pointer(bp + 504 /* iIdxCur */)) + j4), ckUniq, r1, int32((*Index)(unsafe.Pointer(pIdx5)).FnColumn)) Xsqlite3VdbeLoadString(tls, v, 3, ts+18789 /* "row " */) - Xsqlite3VdbeAddOp3(tls, v, 110, 7, 3, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 7, 3, 3) Xsqlite3VdbeLoadString(tls, v, 4, ts+18794 /* " missing from in..." */) - Xsqlite3VdbeAddOp3(tls, v, 110, 4, 3, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 4, 3, 3) jmp5 = Xsqlite3VdbeLoadString(tls, v, 4, (*Index)(unsafe.Pointer(pIdx5)).FzName) - Xsqlite3VdbeAddOp3(tls, v, 110, 4, 3, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 4, 3, 3) jmp4 = integrityCheckResultRow(tls, v) Xsqlite3VdbeJumpHere(tls, v, jmp21) // For UNIQUE indexes, verify that only one entry exists with the // current key. The entry is unique if (1) any column is NULL // or (2) the next entry has a different key - if !(int32((*Index)(unsafe.Pointer((pIdx5))).FonError) != 0) { + if !(int32((*Index)(unsafe.Pointer((pIdx5))).FonError) != OE_None) { goto __290 } uniqOk = Xsqlite3VdbeMakeLabel(tls, pParse) @@ -110534,7 +108482,7 @@ __291: goto __292 __294: ; - Xsqlite3VdbeAddOp2(tls, v, 50, (r1 + kk), uniqOk) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (r1 + kk), uniqOk) goto __292 __292: @@ -110543,10 +108491,10 @@ __292: goto __293 __293: ; - jmp6 = Xsqlite3VdbeAddOp1(tls, v, 5, (*(*int32)(unsafe.Pointer(bp + 504 /* iIdxCur */)) + j4)) + jmp6 = Xsqlite3VdbeAddOp1(tls, v, OP_Next, (*(*int32)(unsafe.Pointer(bp + 504 /* iIdxCur */)) + j4)) Xsqlite3VdbeGoto(tls, v, uniqOk) Xsqlite3VdbeJumpHere(tls, v, jmp6) - Xsqlite3VdbeAddOp4Int(tls, v, 39, (*(*int32)(unsafe.Pointer(bp + 504 /* iIdxCur */)) + j4), uniqOk, r1, + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxGT, (*(*int32)(unsafe.Pointer(bp + 504 /* iIdxCur */)) + j4), uniqOk, r1, int32((*Index)(unsafe.Pointer(pIdx5)).FnKeyCol)) Xsqlite3VdbeLoadString(tls, v, 3, ts+18815 /* "non-unique entry..." */) Xsqlite3VdbeGoto(tls, v, jmp5) @@ -110565,7 +108513,7 @@ __288: ; __285: ; - Xsqlite3VdbeAddOp2(tls, v, 5, *(*int32)(unsafe.Pointer(bp + 500 /* iDataCur */)), loopTop) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, *(*int32)(unsafe.Pointer(bp + 500 /* iDataCur */)), loopTop) Xsqlite3VdbeJumpHere(tls, v, (loopTop - 1)) if !(!(isQuick != 0)) { goto __295 @@ -110583,11 +108531,11 @@ __296: goto __297 __299: ; - Xsqlite3VdbeAddOp2(tls, v, 92, (*(*int32)(unsafe.Pointer(bp + 504 /* iIdxCur */)) + j4), 3) - addr1 = Xsqlite3VdbeAddOp3(tls, v, 53, (8 + j4), 0, 3) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x90)) + Xsqlite3VdbeAddOp2(tls, v, OP_Count, (*(*int32)(unsafe.Pointer(bp + 504 /* iIdxCur */)) + j4), 3) + addr1 = Xsqlite3VdbeAddOp3(tls, v, OP_Eq, (8 + j4), 0, 3) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NOTNULL) Xsqlite3VdbeLoadString(tls, v, 4, (*Index)(unsafe.Pointer(pIdx5)).FzName) - Xsqlite3VdbeAddOp3(tls, v, 110, 4, 2, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_Concat, 4, 2, 3) integrityCheckResultRow(tls, v) Xsqlite3VdbeJumpHere(tls, v, addr1) goto __297 @@ -110619,11 +108567,11 @@ __241: if !(aOp2 != 0) { goto __300 } - (*VdbeOp)(unsafe.Pointer(aOp2 + uintptr(0)*32)).Fp2 = (1 - *(*int32)(unsafe.Pointer(bp + 496 /* mxErr */))) - (*VdbeOp)(unsafe.Pointer(aOp2 + uintptr(2)*32)).Fp4type = int8(-1) - *(*uintptr)(unsafe.Pointer(aOp2 + uintptr(2)*32 + 16 /* &.p4 */)) = ts + 4999 /* "ok" */ - (*VdbeOp)(unsafe.Pointer(aOp2 + uintptr(5)*32)).Fp4type = int8(-1) - *(*uintptr)(unsafe.Pointer(aOp2 + uintptr(5)*32 + 16 /* &.p4 */)) = Xsqlite3ErrStr(tls, 11) + (*VdbeOp)(unsafe.Pointer(aOp2)).Fp2 = (1 - *(*int32)(unsafe.Pointer(bp + 496 /* mxErr */))) + (*VdbeOp)(unsafe.Pointer(aOp2 + 2*32)).Fp4type = int8(-1) + *(*uintptr)(unsafe.Pointer(aOp2 + 2*32 + 16 /* &.p4 */)) = ts + 4999 /* "ok" */ + (*VdbeOp)(unsafe.Pointer(aOp2 + 5*32)).Fp4type = int8(-1) + *(*uintptr)(unsafe.Pointer(aOp2 + 5*32 + 16 /* &.p4 */)) = Xsqlite3ErrStr(tls, SQLITE_CORRUPT) __300: ; Xsqlite3VdbeChangeP3(tls, v, 0, (Xsqlite3VdbeCurrentAddr(tls, v) - 2)) @@ -110668,10 +108616,10 @@ __301: // "PRAGMA encoding = XXX" // initialized. If the main database exists, the new sqlite.enc value // will be overwritten when the schema is next loaded. If it does not // already exists, it will be created to use the new encoding value. - if !(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0040)) == U32(0)) { + if !(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_EncodingFixed) == U32(0)) { goto __304 } - pEnc = (uintptr(unsafe.Pointer(&encnames1)) + uintptr(0)*16) + pEnc = (uintptr(unsafe.Pointer(&encnames1))) __305: if !((*EncName)(unsafe.Pointer(pEnc)).FzName != 0) { goto __307 @@ -110682,9 +108630,9 @@ __305: if (*EncName)(unsafe.Pointer(pEnc)).Fenc != 0 { enc = (*EncName)(unsafe.Pointer(pEnc)).Fenc } else { - enc = uint8(2) + enc = SQLITE_UTF16LE } - ((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb + uintptr(0)*32)).FpSchema)).Fenc) = enc + ((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb)).FpSchema)).Fenc) = enc Xsqlite3SetTextEncoding(tls, db, enc) goto __307 __308: @@ -110742,7 +108690,7 @@ __302: __45: iCookie = int32((*PragmaName)(unsafe.Pointer(pPragma)).FiArg) // Which cookie to read or write Xsqlite3VdbeUsesBtree(tls, v, iDb) - if !((zRight != 0) && ((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & 0x08) == 0)) { + if !((zRight != 0) && ((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & PragFlg_ReadOnly) == 0)) { goto __310 } @@ -110753,11 +108701,11 @@ __45: goto __15 __312: ; - (*VdbeOp)(unsafe.Pointer(aOp3 + uintptr(0)*32)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp3 + uintptr(1)*32)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp3 + uintptr(1)*32)).Fp2 = iCookie - (*VdbeOp)(unsafe.Pointer(aOp3 + uintptr(1)*32)).Fp3 = Xsqlite3Atoi(tls, zRight) - (*VdbeOp)(unsafe.Pointer(aOp3 + uintptr(1)*32)).Fp5 = U16(1) + (*VdbeOp)(unsafe.Pointer(aOp3)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp3 + 1*32)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp3 + 1*32)).Fp2 = iCookie + (*VdbeOp)(unsafe.Pointer(aOp3 + 1*32)).Fp3 = Xsqlite3Atoi(tls, zRight) + (*VdbeOp)(unsafe.Pointer(aOp3 + 1*32)).Fp5 = U16(1) goto __311 __310: ; @@ -110768,9 +108716,9 @@ __310: goto __15 __313: ; - (*VdbeOp)(unsafe.Pointer(aOp4 + uintptr(0)*32)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp4 + uintptr(1)*32)).Fp1 = iDb - (*VdbeOp)(unsafe.Pointer(aOp4 + uintptr(1)*32)).Fp3 = iCookie + (*VdbeOp)(unsafe.Pointer(aOp4)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp4 + 1*32)).Fp1 = iDb + (*VdbeOp)(unsafe.Pointer(aOp4 + 1*32)).Fp3 = iCookie Xsqlite3VdbeReusable(tls, v) __311: ; @@ -110789,7 +108737,7 @@ __314: goto __315 } Xsqlite3VdbeLoadString(tls, v, 1, zOpt) - Xsqlite3VdbeAddOp2(tls, v, 80, 1, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 1) goto __314 __315: ; @@ -110805,28 +108753,28 @@ __47: if (*Token)(unsafe.Pointer(pId2)).Fz != 0 { return iDb } - return 10 + return SQLITE_MAX_ATTACHED }() - eMode2 = 0 + eMode2 = SQLITE_CHECKPOINT_PASSIVE if !(zRight != 0) { goto __316 } if !(Xsqlite3StrICmp(tls, zRight, ts+18373 /* "full" */) == 0) { goto __317 } - eMode2 = 1 + eMode2 = SQLITE_CHECKPOINT_FULL goto __318 __317: if !(Xsqlite3StrICmp(tls, zRight, ts+18896 /* "restart" */) == 0) { goto __319 } - eMode2 = 2 + eMode2 = SQLITE_CHECKPOINT_RESTART goto __320 __319: if !(Xsqlite3StrICmp(tls, zRight, ts+18526 /* "truncate" */) == 0) { goto __321 } - eMode2 = 3 + eMode2 = SQLITE_CHECKPOINT_TRUNCATE __321: ; __320: @@ -110836,8 +108784,8 @@ __318: __316: ; (*Parse)(unsafe.Pointer(pParse)).FnMem = 3 - Xsqlite3VdbeAddOp3(tls, v, 6, iBt, eMode2, 1) - Xsqlite3VdbeAddOp2(tls, v, 80, 1, 3) + Xsqlite3VdbeAddOp3(tls, v, OP_Checkpoint, iBt, eMode2, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, 1, 3) goto __15 @@ -110973,7 +108921,7 @@ __330: // If table pTab has not been used in a way that would benefit from // having analysis statistics during the current session, then skip it. // This also has the effect of skipping virtual tables and views - if !(((*Table)(unsafe.Pointer(pTab8)).FtabFlags & U32(0x0100)) == U32(0)) { + if !(((*Table)(unsafe.Pointer(pTab8)).FtabFlags & TF_StatsUsed) == U32(0)) { goto __333 } goto __331 @@ -111004,8 +108952,8 @@ __336: if !(szThreshold != 0) { goto __338 } - Xsqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab8, 96) - Xsqlite3VdbeAddOp3(tls, v, 34, iTabCur, + Xsqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab8, OP_OpenRead) + Xsqlite3VdbeAddOp3(tls, v, OP_IfSmaller, iTabCur, (int32((U32(Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + (opMask & U32(1)))), int32(szThreshold)) __338: @@ -111016,11 +108964,11 @@ __338: goto __339 } r11 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp4(tls, v, 115, 0, r11, 0, zSubSql, -7) - Xsqlite3VdbeAddOp2(tls, v, 80, r11, 1) + Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, r11, 0, zSubSql, -7) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, r11, 1) goto __340 __339: - Xsqlite3VdbeAddOp4(tls, v, 140, 0, 0, 0, zSubSql, -7) + Xsqlite3VdbeAddOp4(tls, v, OP_SqlExec, 0, 0, 0, zSubSql, -7) __340: ; goto __331 @@ -111037,7 +108985,7 @@ __327: goto __328 __328: ; - Xsqlite3VdbeAddOp0(tls, v, 158) + Xsqlite3VdbeAddOp0(tls, v, OP_Expire) goto __15 // PRAGMA busy_timeout @@ -111069,7 +109017,7 @@ __341: // returns the same integer that would be returned by the // sqlite3_soft_heap_limit64(-1) C-language function. __52: - if !((zRight != 0) && (Xsqlite3DecOrHexToI64(tls, zRight, bp+512 /* &N */) == 0)) { + if !((zRight != 0) && (Xsqlite3DecOrHexToI64(tls, zRight, bp+512 /* &N */) == SQLITE_OK)) { goto __342 } Xsqlite3_soft_heap_limit64(tls, *(*Sqlite3_int64)(unsafe.Pointer(bp + 512 /* N */))) @@ -111088,7 +109036,7 @@ __342: // the hard heap limit. This allows an application to set a heap limit // constraint that cannot be relaxed by an untrusted SQL script. __53: - if !((zRight != 0) && (Xsqlite3DecOrHexToI64(tls, zRight, bp+520 /* &N1 */) == 0)) { + if !((zRight != 0) && (Xsqlite3DecOrHexToI64(tls, zRight, bp+520 /* &N1 */) == SQLITE_OK)) { goto __343 } iPrior = Xsqlite3_hard_heap_limit64(tls, int64(-1)) @@ -111110,14 +109058,14 @@ __343: // maximum, which might be less than requested. __54: if !(((zRight != 0) && - (Xsqlite3DecOrHexToI64(tls, zRight, bp+528 /* &N2 */) == 0)) && + (Xsqlite3DecOrHexToI64(tls, zRight, bp+528 /* &N2 */) == SQLITE_OK)) && (*(*Sqlite3_int64)(unsafe.Pointer(bp + 528 /* N2 */)) >= int64(0))) { goto __345 } - Xsqlite3_limit(tls, db, 11, (int32(*(*Sqlite3_int64)(unsafe.Pointer(bp + 528 /* N2 */)) & int64(0x7fffffff)))) + Xsqlite3_limit(tls, db, SQLITE_LIMIT_WORKER_THREADS, (int32(*(*Sqlite3_int64)(unsafe.Pointer(bp + 528 /* N2 */)) & int64(0x7fffffff)))) __345: ; - returnSingleInt(tls, v, int64(Xsqlite3_limit(tls, db, 11, -1))) + returnSingleInt(tls, v, int64(Xsqlite3_limit(tls, db, SQLITE_LIMIT_WORKER_THREADS, -1))) goto __15 // PRAGMA analysis_limit @@ -111127,7 +109075,7 @@ __345: // in each index that it looks at. Return the new limit. __55: if !(((zRight != 0) && - (Xsqlite3DecOrHexToI64(tls, zRight, bp+536 /* &N3 */) == 0)) && + (Xsqlite3DecOrHexToI64(tls, zRight, bp+536 /* &N3 */) == SQLITE_OK)) && (*(*Sqlite3_int64)(unsafe.Pointer(bp + 536 /* N3 */)) >= int64(0))) { goto __346 } @@ -111165,7 +109113,7 @@ __351: } return uintptr(0) }(), - 1, bp+544 /* &j5 */) == 0) { + SQLITE_FCNTL_LOCKSTATE, bp+544 /* &j5 */) == SQLITE_OK) { goto __353 } zState = azLockName[*(*int32)(unsafe.Pointer(bp + 544 /* j5 */))] @@ -111191,7 +109139,7 @@ __15: // PragFlg_NoColumns1 flag is set and the caller specified an argument // to the PRAGMA, the implementation has not added any OP_ResultRow // instructions to the VM. - if !(((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & 0x04) != 0) && (zRight != 0)) { + if !(((int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & PragFlg_NoColumns1) != 0) && (zRight != 0)) { goto __354 } @@ -111211,173 +109159,53 @@ type EncName = struct { var iLn3 int32 = 0 /* sqlite3.c:126248:22 */ var getCacheSize = [9]VdbeOpList{ - { - Fopcode: U8(2), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 0 - { - Fopcode: U8(93), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(3)}, // 1 - { - Fopcode: U8(48), - Fp1: int8(1), - Fp2: int8(8), - Fp3: int8(0)}, - { - Fopcode: U8(69), - Fp1: int8(0), - Fp2: int8(2), - Fp3: int8(0)}, - { - Fopcode: U8(106), - Fp1: int8(1), - Fp2: int8(2), - Fp3: int8(1)}, - { - Fopcode: U8(48), - Fp1: int8(1), - Fp2: int8(8), - Fp3: int8(0)}, - { - Fopcode: U8(69), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(0)}, // 6 - { - Fopcode: U8(173), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, - { - Fopcode: U8(80), - Fp1: int8(1), - Fp2: int8(1), - Fp3: int8(0)}, + {Fopcode: OP_Transaction}, // 0 + {Fopcode: OP_ReadCookie, Fp2: int8(1), Fp3: BTREE_DEFAULT_CACHE_SIZE}, // 1 + {Fopcode: OP_IfPos, Fp1: int8(1), Fp2: int8(8)}, + {Fopcode: OP_Integer, Fp2: int8(2)}, + {Fopcode: OP_Subtract, Fp1: int8(1), Fp2: int8(2), Fp3: int8(1)}, + {Fopcode: OP_IfPos, Fp1: int8(1), Fp2: int8(8)}, + {Fopcode: OP_Integer, Fp2: int8(1)}, // 6 + {Fopcode: OP_Noop}, + {Fopcode: OP_ResultRow, Fp1: int8(1), Fp2: int8(1)}, } /* sqlite3.c:126249:29 */ var iLn4 int32 = 0 /* sqlite3.c:126517:26 */ var setMeta6 = [5]VdbeOpList{ - { - Fopcode: U8(2), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(0)}, // 0 - { - Fopcode: U8(93), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(4)}, - { - Fopcode: U8(18), - Fp1: int8(1), - Fp2: int8(0), - Fp3: int8(0)}, // 2 - { - Fopcode: U8(68), - Fp1: int8(0), - Fp2: int8(2), - Fp3: int8(0)}, // 3 - { - Fopcode: U8(94), - Fp1: int8(0), - Fp2: int8(7), - Fp3: int8(0)}, // 4 + {Fopcode: OP_Transaction, Fp2: int8(1)}, // 0 + {Fopcode: OP_ReadCookie, Fp2: int8(1), Fp3: BTREE_LARGEST_ROOT_PAGE}, + {Fopcode: OP_If, Fp1: int8(1)}, // 2 + {Fopcode: OP_Halt, Fp2: OE_Abort}, // 3 + {Fopcode: OP_SetCookie, Fp2: BTREE_INCR_VACUUM}, // 4 } /* sqlite3.c:126518:33 */ var iLn5 int32 = 0 /* sqlite3.c:127522:24 */ var endCode = [7]VdbeOpList{ - { - Fopcode: U8(82), - Fp1: int8(1), - Fp2: int8(0), - Fp3: int8(0)}, // 0 - { - Fopcode: U8(49), - Fp1: int8(1), - Fp2: int8(4), - Fp3: int8(0)}, // 1 - { - Fopcode: U8(115), - Fp1: int8(0), - Fp2: int8(3), - Fp3: int8(0)}, // 2 - { - Fopcode: U8(80), - Fp1: int8(3), - Fp2: int8(1), - Fp3: int8(0)}, // 3 - { - Fopcode: U8(68), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 4 - { - Fopcode: U8(115), - Fp1: int8(0), - Fp2: int8(3), - Fp3: int8(0)}, // 5 - { - Fopcode: U8(11), - Fp1: int8(0), - Fp2: int8(3), - Fp3: int8(0)}, // 6 + {Fopcode: OP_AddImm, Fp1: int8(1)}, // 0 + {Fopcode: OP_IfNotZero, Fp1: int8(1), Fp2: int8(4)}, // 1 + {Fopcode: OP_String8, Fp2: int8(3)}, // 2 + {Fopcode: OP_ResultRow, Fp1: int8(3), Fp2: int8(1)}, // 3 + {Fopcode: OP_Halt}, // 4 + {Fopcode: OP_String8, Fp2: int8(3)}, // 5 + {Fopcode: OP_Goto, Fp2: int8(3)}, // 6 } /* sqlite3.c:127523:31 */ var encnames1 = [9]EncName{ - { - FzName: ts + 18940, /* "UTF8" */ - Fenc: U8(1)}, - { - FzName: ts + 18945, /* "UTF-8" */ - Fenc: U8(1)}, // Must be element [1] - { - FzName: ts + 18951, /* "UTF-16le" */ - Fenc: U8(2)}, // Must be element [2] - { - FzName: ts + 18960, /* "UTF-16be" */ - Fenc: U8(3)}, // Must be element [3] - { - FzName: ts + 18969, /* "UTF16le" */ - Fenc: U8(2)}, - { - FzName: ts + 18977, /* "UTF16be" */ - Fenc: U8(3)}, - { - FzName: ts + 18985, /* "UTF-16" */ - Fenc: U8(0)}, // SQLITE_UTF16NATIVE - { - FzName: ts + 18992, /* "UTF16" */ - Fenc: U8(0)}, // SQLITE_UTF16NATIVE + {FzName: ts + 18940 /* "UTF8" */, Fenc: SQLITE_UTF8}, + {FzName: ts + 18945 /* "UTF-8" */, Fenc: SQLITE_UTF8}, // Must be element [1] + {FzName: ts + 18951 /* "UTF-16le" */, Fenc: SQLITE_UTF16LE}, // Must be element [2] + {FzName: ts + 18960 /* "UTF-16be" */, Fenc: SQLITE_UTF16BE}, // Must be element [3] + {FzName: ts + 18969 /* "UTF16le" */, Fenc: SQLITE_UTF16LE}, + {FzName: ts + 18977 /* "UTF16be" */, Fenc: SQLITE_UTF16BE}, + {FzName: ts + 18985 /* "UTF-16" */}, // SQLITE_UTF16NATIVE + {FzName: ts + 18992 /* "UTF16" */}, // SQLITE_UTF16NATIVE {}, } /* sqlite3.c:127575:7 */ var setCookie = [2]VdbeOpList{ - { - Fopcode: U8(2), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(0)}, // 0 - { - Fopcode: U8(94), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 1 + {Fopcode: OP_Transaction, Fp2: int8(1)}, // 0 + {Fopcode: OP_SetCookie}, // 1 } /* sqlite3.c:127655:31 */ var readCookie = [3]VdbeOpList{ - { - Fopcode: U8(2), - Fp1: int8(0), - Fp2: int8(0), - Fp3: int8(0)}, // 0 - { - Fopcode: U8(93), - Fp1: int8(0), - Fp2: int8(1), - Fp3: int8(0)}, // 1 - { - Fopcode: U8(80), - Fp1: int8(1), - Fp2: int8(1), - Fp3: int8(0)}, + {Fopcode: OP_Transaction}, // 0 + {Fopcode: OP_ReadCookie, Fp2: int8(1)}, // 1 + {Fopcode: OP_ResultRow, Fp1: int8(1), Fp2: int8(1)}, } /* sqlite3.c:127670:31 */ var azLockName = [5]uintptr{ ts + 18998 /* "unlocked" */, ts + 19007 /* "shared" */, ts + 19014 /* "reserved" */, ts + 19023 /* "pending" */, ts + 18351, /* "exclusive" */ @@ -111452,11 +109280,11 @@ __3: i++ } j = 0 - if (int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & 0x20) != 0 { + if (int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & PragFlg_Result1) != 0 { Xsqlite3_str_appendall(tls, bp+32 /* &acc */, ts+19059 /* ",arg HIDDEN" */) j++ } - if (int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & (0x40 | 0x80)) != 0 { + if (int32((*PragmaName)(unsafe.Pointer(pPragma)).FmPragFlg) & (PragFlg_SchemaOpt | PragFlg_SchemaReq)) != 0 { Xsqlite3_str_appendall(tls, bp+32 /* &acc */, ts+19071 /* ",schema HIDDEN" */) j++ } @@ -111464,10 +109292,10 @@ __3: Xsqlite3StrAccumFinish(tls, bp+32 /* &acc */) rc = Xsqlite3_declare_vtab(tls, db, bp+64 /* &zBuf[0] */) - if rc == 0 { + if rc == SQLITE_OK { pTab = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(PragmaVtab{}))) if pTab == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, pTab, 0, uint64(unsafe.Sizeof(PragmaVtab{}))) (*PragmaVtab)(unsafe.Pointer(pTab)).FpName = pPragma @@ -111487,7 +109315,7 @@ __3: func pragmaVtabDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:128111:12: */ var pTab uintptr = pVtab Xsqlite3_free(tls, pTab) - return 0 + return SQLITE_OK } // Figure out the best index to use to search a pragma virtual table. @@ -111508,11 +109336,11 @@ func pragmaVtabBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { / (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1) if int32((*PragmaVtab)(unsafe.Pointer(pTab)).FnHidden) == 0 { - return 0 + return SQLITE_OK } pConstraint = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint - *(*int32)(unsafe.Pointer(bp /* &seen[0] */ + uintptr(0)*4)) = 0 - *(*int32)(unsafe.Pointer(bp /* &seen[0] */ + uintptr(1)*4)) = 0 + *(*int32)(unsafe.Pointer(bp /* &seen[0] */)) = 0 + *(*int32)(unsafe.Pointer(bp /* &seen[0] */ + 1*4)) = 0 i = 0 __1: if !(i < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { @@ -111522,7 +109350,7 @@ __1: if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { goto __2 } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) != 2 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) != SQLITE_INDEX_CONSTRAINT_EQ { goto __2 } if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < int32((*PragmaVtab)(unsafe.Pointer(pTab)).FiHidden) { @@ -111541,23 +109369,23 @@ __2: goto __3 __3: ; - if *(*int32)(unsafe.Pointer(bp /* &seen[0] */ + uintptr(0)*4)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* &seen[0] */)) == 0 { (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(2147483647) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(2147483647) - return 0 + return SQLITE_OK } - j = (*(*int32)(unsafe.Pointer(bp /* &seen[0] */ + uintptr(0)*4)) - 1) + j = (*(*int32)(unsafe.Pointer(bp /* &seen[0] */)) - 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).FargvIndex = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).Fomit = uint8(1) - if *(*int32)(unsafe.Pointer(bp /* &seen[0] */ + uintptr(1)*4)) == 0 { - return 0 + if *(*int32)(unsafe.Pointer(bp /* &seen[0] */ + 1*4)) == 0 { + return SQLITE_OK } (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(20) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(20) - j = (*(*int32)(unsafe.Pointer(bp /* &seen[0] */ + uintptr(1)*4)) - 1) + j = (*(*int32)(unsafe.Pointer(bp /* &seen[0] */ + 1*4)) - 1) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).FargvIndex = 2 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).Fomit = uint8(1) - return 0 + return SQLITE_OK } // Create a new cursor for the pragma virtual table @@ -111565,12 +109393,12 @@ func pragmaVtabOpen(tls *libc.TLS, pVtab uintptr, ppCursor uintptr) int32 { /* s var pCsr uintptr pCsr = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(PragmaVtabCursor{}))) if pCsr == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCsr, 0, uint64(unsafe.Sizeof(PragmaVtabCursor{}))) (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVtab *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCsr /* &.base */) - return 0 + return SQLITE_OK } // Clear all content from pragma virtual table cursor. @@ -111589,18 +109417,18 @@ func pragmaVtabClose(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:128183:12: var pCsr uintptr = cur pragmaVtabCursorClear(tls, pCsr) Xsqlite3_free(tls, pCsr) - return 0 + return SQLITE_OK } // Advance the pragma virtual table cursor to the next row func pragmaVtabNext(tls *libc.TLS, pVtabCursor uintptr) int32 { /* sqlite3.c:128191:12: */ var pCsr uintptr = pVtabCursor - var rc int32 = 0 + var rc int32 = SQLITE_OK // Increment the xRowid value (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FiRowid++ - if 100 != Xsqlite3_step(tls, (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma) { + if SQLITE_ROW != Xsqlite3_step(tls, (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma) { rc = Xsqlite3_finalize(tls, (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma) (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma = uintptr(0) pragmaVtabCursorClear(tls, pCsr) @@ -111625,7 +109453,7 @@ func pragmaVtabFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr u _ = idxNum _ = idxStr pragmaVtabCursorClear(tls, pCsr) - if (int32((*PragmaName)(unsafe.Pointer((*PragmaVtab)(unsafe.Pointer(pTab)).FpName)).FmPragFlg) & 0x20) != 0 { + if (int32((*PragmaName)(unsafe.Pointer((*PragmaVtab)(unsafe.Pointer(pTab)).FpName)).FmPragFlg) & PragFlg_Result1) != 0 { j = 0 } else { j = 1 @@ -111641,7 +109469,7 @@ __1: if zText != 0 { *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr(j)*8)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp, zText)) if *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr(j)*8)) == uintptr(0) { - return 7 + return SQLITE_NOMEM } } @@ -111654,22 +109482,22 @@ __2: goto __3 __3: ; - Xsqlite3StrAccumInit(tls, bp+32 /* &acc */, uintptr(0), uintptr(0), 0, *(*int32)(unsafe.Pointer(((*PragmaVtab)(unsafe.Pointer(pTab)).Fdb + 124 /* &.aLimit */) + uintptr(1)*4))) + Xsqlite3StrAccumInit(tls, bp+32 /* &acc */, uintptr(0), uintptr(0), 0, *(*int32)(unsafe.Pointer(((*PragmaVtab)(unsafe.Pointer(pTab)).Fdb + 124 /* &.aLimit */) + 1*4))) Xsqlite3_str_appendall(tls, bp+32 /* &acc */, ts+19086 /* "PRAGMA " */) - if *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr(1)*8)) != 0 { - Xsqlite3_str_appendf(tls, bp+32 /* &acc */, ts+19094 /* "%Q." */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr(1)*8)))) + if *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + 1*8)) != 0 { + Xsqlite3_str_appendf(tls, bp+32 /* &acc */, ts+19094 /* "%Q." */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + 1*8)))) } Xsqlite3_str_appendall(tls, bp+32 /* &acc */, (*PragmaName)(unsafe.Pointer((*PragmaVtab)(unsafe.Pointer(pTab)).FpName)).FzName) - if *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr(0)*8)) != 0 { - Xsqlite3_str_appendf(tls, bp+32 /* &acc */, ts+19098 /* "=%Q" */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr(0)*8)))) + if *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */))) != 0 { + Xsqlite3_str_appendf(tls, bp+32 /* &acc */, ts+19098 /* "=%Q" */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */))))) } zSql = Xsqlite3StrAccumFinish(tls, bp+32 /* &acc */) if zSql == uintptr(0) { - return 7 + return SQLITE_NOMEM } rc = Xsqlite3_prepare_v2(tls, (*PragmaVtab)(unsafe.Pointer(pTab)).Fdb, zSql, -1, (pCsr + 8 /* &.pPragma */), uintptr(0)) Xsqlite3_free(tls, zSql) - if rc != 0 { + if rc != SQLITE_OK { (*PragmaVtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp+24, Xsqlite3_errmsg(tls, (*PragmaVtab)(unsafe.Pointer(pTab)).Fdb))) return rc } @@ -111692,65 +109520,28 @@ func pragmaVtabColumn(tls *libc.TLS, pVtabCursor uintptr, ctx uintptr, i int32) } else { Xsqlite3_result_text(tls, ctx, *(*uintptr)(unsafe.Pointer((pCsr + 24 /* &.azArg */) + uintptr((i-int32((*PragmaVtab)(unsafe.Pointer(pTab)).FiHidden)))*8)), -1, libc.UintptrFromInt32(-1)) } - return 0 + return SQLITE_OK } // Pragma virtual table module xRowid method. func pragmaVtabRowid(tls *libc.TLS, pVtabCursor uintptr, p uintptr) int32 { /* sqlite3.c:128285:12: */ var pCsr uintptr = pVtabCursor *(*Sqlite_int64)(unsafe.Pointer(p)) = (*PragmaVtabCursor)(unsafe.Pointer(pCsr)).FiRowid - return 0 + return SQLITE_OK } // The pragma virtual table object -var pragmaVtabModule = Sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - uintptr(0), - FxConnect:// xCreate - create a table - 0, - FxBestIndex:// xConnect - connect to an existing table - 0, - FxDisconnect:// xBestIndex - Determine search strategy - 0, - FxDestroy:// xDisconnect - Disconnect from a table - uintptr(0), - FxOpen:// xDestroy - Drop a table - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - write data - uintptr(0), - FxSync:// xBegin - begin transaction - uintptr(0), - FxCommit:// xSync - sync transaction - uintptr(0), - FxRollback:// xCommit - commit transaction - uintptr(0), - FxFindFunction:// xRollback - rollback transaction - uintptr(0), - FxRename:// xFindFunction - function overloading - uintptr(0), - FxSavepoint:// xRename - rename the table - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var pragmaVtabModule = Sqlite3_module{ // xCreate - create a table + FxConnect: 0, // xConnect - connect to an existing table + FxBestIndex: 0, // xBestIndex - Determine search strategy + FxDisconnect: 0, // xDestroy - Drop a table + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xShadowName } /* sqlite3.c:128292:29 */ // Check to see if zTabName is really the name of a pragma. If it is, @@ -111763,7 +109554,7 @@ func Xsqlite3PragmaVtabRegister(tls *libc.TLS, db uintptr, zName uintptr) uintpt if pName == uintptr(0) { return uintptr(0) } - if (int32((*PragmaName)(unsafe.Pointer(pName)).FmPragFlg) & (0x10 | 0x20)) == 0 { + if (int32((*PragmaName)(unsafe.Pointer(pName)).FmPragFlg) & (PragFlg_Result0 | PragFlg_Result1)) == 0 { return uintptr(0) } @@ -111795,13 +109586,13 @@ func corruptSchema(tls *libc.TLS, pData uintptr, zObj uintptr, zExtra uintptr) { var db uintptr = (*InitData)(unsafe.Pointer(pData)).Fdb if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - (*InitData)(unsafe.Pointer(pData)).Frc = 7 - } else if *(*uintptr)(unsafe.Pointer((*InitData)(unsafe.Pointer(pData)).FpzErrMsg + uintptr(0)*8)) != uintptr(0) { + (*InitData)(unsafe.Pointer(pData)).Frc = SQLITE_NOMEM + } else if *(*uintptr)(unsafe.Pointer((*InitData)(unsafe.Pointer(pData)).FpzErrMsg)) != uintptr(0) { // A error message has already been generated. Do not overwrite it - } else if ((*InitData)(unsafe.Pointer(pData)).FmInitFlags & U32(0x0001)) != 0 { + } else if ((*InitData)(unsafe.Pointer(pData)).FmInitFlags & INITFLAG_AlterTable) != 0 { *(*uintptr)(unsafe.Pointer((*InitData)(unsafe.Pointer(pData)).FpzErrMsg)) = Xsqlite3DbStrDup(tls, db, zExtra) - (*InitData)(unsafe.Pointer(pData)).Frc = 1 - } else if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000001)) != 0 { + (*InitData)(unsafe.Pointer(pData)).Frc = SQLITE_ERROR + } else if ((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_WriteSchema) != 0 { (*InitData)(unsafe.Pointer(pData)).Frc = Xsqlite3CorruptError(tls, 128375) } else { var z uintptr @@ -111809,7 +109600,7 @@ func corruptSchema(tls *libc.TLS, pData uintptr, zObj uintptr, zExtra uintptr) { zObj = ts + 6724 /* "?" */ } z = Xsqlite3MPrintf(tls, db, ts+19102 /* "malformed databa..." */, libc.VaList(bp, zObj)) - if (zExtra != 0) && (*(*int8)(unsafe.Pointer(zExtra + uintptr(0))) != 0) { + if (zExtra != 0) && (*(*int8)(unsafe.Pointer(zExtra)) != 0) { z = Xsqlite3MPrintf(tls, db, ts+19133 /* "%z - %s" */, libc.VaList(bp+8, z, zExtra)) } *(*uintptr)(unsafe.Pointer((*InitData)(unsafe.Pointer(pData)).FpzErrMsg)) = z @@ -111853,19 +109644,19 @@ func Xsqlite3InitCallback(tls *libc.TLS, pInit uintptr, argc int32, argv uintptr _ = NotUsed _ = argc - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0040)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_EncodingFixed) (*InitData)(unsafe.Pointer(pData)).FnInitRow++ if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uintptr(0)) + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uintptr(0)) return 1 } if argv == uintptr(0) { return 0 } // Might happen if EMPTY_RESULT_CALLBACKS are on - if *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)) == uintptr(0) { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uintptr(0)) - } else if Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)), ts+19141 /* "create " */, 7) == 0 { + if *(*uintptr)(unsafe.Pointer(argv + 3*8)) == uintptr(0) { + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uintptr(0)) + } else if Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), ts+19141 /* "create " */, 7) == 0 { // Call the parser to process a CREATE TABLE, INDEX or VIEW. // But because db->init.busy is set to 1, no VDBE code is generated // or executed. All the parser does is build the internal data @@ -111877,37 +109668,37 @@ func Xsqlite3InitCallback(tls *libc.TLS, pInit uintptr, argc int32, argv uintptr // Return code from sqlite3_prepare() (*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = U8(iDb) - if (Xsqlite3GetUInt32(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)), (db+176 /* &.init */ /* &.newTnum */)) == 0) || + if (Xsqlite3GetUInt32(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8)), (db+176 /* &.init */ /* &.newTnum */)) == 0) || (((*Sqlite3)(unsafe.Pointer(db)).Finit.FnewTnum > (*InitData)(unsafe.Pointer(pData)).FmxPage) && ((*InitData)(unsafe.Pointer(pData)).FmxPage > Pgno(0))) { if Xsqlite3Config.FbExtraSchemaChecks != 0 { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+15222 /* "invalid rootpage" */) + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+15222 /* "invalid rootpage" */) } } libc.SetBitFieldPtr8Uint32(db+176 /* &.init */ +8 /* &.orphanTrigger */, uint32(0), 0, 0x1) (*Sqlite3)(unsafe.Pointer(db)).Finit.FazInit = argv *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) - sqlite3Prepare(tls, db, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)), -1, uint32(0), uintptr(0), bp /* &pStmt */, uintptr(0)) + sqlite3Prepare(tls, db, *(*uintptr)(unsafe.Pointer(argv + 4*8)), -1, uint32(0), uintptr(0), bp /* &pStmt */, uintptr(0)) rc = (*Sqlite3)(unsafe.Pointer(db)).FerrCode (*Sqlite3)(unsafe.Pointer(db)).Finit.FiDb = saved_iDb // assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); - if 0 != rc { + if SQLITE_OK != rc { if (uint32(int32(*(*uint8)(unsafe.Pointer(db + 176 /* &.init */ + 8 /* &.orphanTrigger */)) & 0x1 >> 0))) != 0 { } else { if rc > (*InitData)(unsafe.Pointer(pData)).Frc { (*InitData)(unsafe.Pointer(pData)).Frc = rc } - if rc == 7 { + if rc == SQLITE_NOMEM { Xsqlite3OomFault(tls, db) - } else if (rc != 9) && ((rc & 0xFF) != 6) { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), Xsqlite3_errmsg(tls, db)) + } else if (rc != SQLITE_INTERRUPT) && ((rc & 0xFF) != SQLITE_LOCKED) { + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), Xsqlite3_errmsg(tls, db)) } } } Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) - } else if (*(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) == uintptr(0)) || ((*(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)) != uintptr(0)) && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)) + uintptr(0)))) != 0)) { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uintptr(0)) + } else if (*(*uintptr)(unsafe.Pointer(argv + 1*8)) == uintptr(0)) || ((*(*uintptr)(unsafe.Pointer(argv + 4*8)) != uintptr(0)) && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 4*8))))) != 0)) { + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uintptr(0)) } else { // If the SQL column is blank it means this is an index that // was created to be the PRIMARY KEY or to fulfill a UNIQUE @@ -111915,15 +109706,15 @@ func Xsqlite3InitCallback(tls *libc.TLS, pInit uintptr, argc int32, argv uintptr // been created when we processed the CREATE TABLE. All we have // to do here is record the root page number for that index. var pIndex uintptr - pIndex = Xsqlite3FindIndex(tls, db, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) + pIndex = Xsqlite3FindIndex(tls, db, *(*uintptr)(unsafe.Pointer(argv + 1*8)), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) if pIndex == uintptr(0) { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+19149 /* "orphan index" */) - } else if (((Xsqlite3GetUInt32(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)), (pIndex+88 /* &.tnum */)) == 0) || + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+19149 /* "orphan index" */) + } else if (((Xsqlite3GetUInt32(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8)), (pIndex+88 /* &.tnum */)) == 0) || ((*Index)(unsafe.Pointer(pIndex)).Ftnum < Pgno(2))) || ((*Index)(unsafe.Pointer(pIndex)).Ftnum > (*InitData)(unsafe.Pointer(pData)).FmxPage)) || (Xsqlite3IndexHasDuplicateRootPage(tls, pIndex) != 0) { if Xsqlite3Config.FbExtraSchemaChecks != 0 { - corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), ts+15222 /* "invalid rootpage" */) + corruptSchema(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+15222 /* "invalid rootpage" */) } } } @@ -111957,7 +109748,7 @@ func Xsqlite3InitOne(tls *libc.TLS, db uintptr, iDb int32, pzErrMsg uintptr, mFl var xAuth Sqlite3_xauth var zSql uintptr openedTransaction = 0 - mask = (int32(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0040)) | ^libc.Uint32FromInt32(0x0040))) + mask = (int32(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_EncodingFixed) | libc.Uint32FromInt32(libc.CplInt32(DBFLAG_EncodingFixed)))) (*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy = U8(1) @@ -111966,20 +109757,20 @@ func Xsqlite3InitOne(tls *libc.TLS, db uintptr, iDb int32, pzErrMsg uintptr, mFl // table name will be inserted automatically by the parser so we can just // use the abbreviation "x" here. The parser will also automatically tag // the schema table as read-only. - *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(0)*8)) = ts + 8236 /* "table" */ - *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(1)*8)) = libc.AssignUintptr(&zSchemaTabName, func() uintptr { + *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */)) = ts + 8236 /* "table" */ + *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + 1*8)) = libc.AssignUintptr(&zSchemaTabName, func() uintptr { if (!(0 != 0)) && (iDb == 1) { return ts + 13301 /* "sqlite_temp_mast..." */ } return ts + 7541 /* "sqlite_master" */ }()) - *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(2)*8)) = *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(1)*8)) - *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(3)*8)) = ts + 9901 /* "1" */ - *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(4)*8)) = ts + 19162 /* "CREATE TABLE x(t..." */ - *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + uintptr(5)*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + 2*8)) = *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + 1*8)) + *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + 3*8)) = ts + 9901 /* "1" */ + *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + 4*8)) = ts + 19162 /* "CREATE TABLE x(t..." */ + *(*uintptr)(unsafe.Pointer(bp + 16 /* &azArg[0] */ + 5*8)) = uintptr(0) (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).Fdb = db (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).FiDb = iDb - (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).Frc = 0 + (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).Frc = SQLITE_OK (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).FpzErrMsg = pzErrMsg (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).FmInitFlags = mFlags (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).FnInitRow = U32(0) @@ -112000,8 +109791,8 @@ __1: goto __2 } - *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(1)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((0x0001)) - rc = 0 + *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+1*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((DB_SchemaLoaded)) + rc = SQLITE_OK goto error_out __2: ; @@ -112014,7 +109805,7 @@ __2: goto __3 } rc = Xsqlite3BtreeBeginTrans(tls, (*Db)(unsafe.Pointer(pDb)).FpBt, 0, uintptr(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __4 } Xsqlite3SetString(tls, pzErrMsg, db, Xsqlite3ErrStr(tls, rc)) @@ -112054,42 +109845,42 @@ __6: goto __7 __7: ; - if !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x02000000)) != uint64(0)) { + if !(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ResetDatabase) != uint64(0)) { goto __8 } libc.Xmemset(tls, bp+104 /* &meta[0] */, 0, uint64(unsafe.Sizeof([5]int32{}))) __8: ; - (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fschema_cookie = *(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((1-1))*4)) + (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fschema_cookie = *(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */)) // If opening a non-empty database, check the text encoding. For the // main database, set sqlite3.enc to the encoding of the main database. // For an attached db, it is an error if the encoding is not the same // as sqlite3.enc. - if !(*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((5-1))*4)) != 0) { + if !(*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + 4*4)) != 0) { goto __9 } // text encoding - if !((iDb == 0) && (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0040)) == U32(0))) { + if !((iDb == 0) && (((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_EncodingFixed) == U32(0))) { goto __10 } // If opening the main database, set ENC(db). - encoding = (U8(int32(U8(*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((5-1))*4)))) & 3)) + encoding = (U8(int32(U8(*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + 4*4)))) & 3)) if !(int32(encoding) == 0) { goto __12 } - encoding = U8(1) + encoding = SQLITE_UTF8 __12: ; Xsqlite3SetTextEncoding(tls, db, encoding) goto __11 __10: // If opening an attached database, the encoding much match ENC(db) - if !((*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((5-1))*4)) & 3) != (int32((*Sqlite3)(unsafe.Pointer(db)).Fenc))) { + if !((*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + 4*4)) & 3) != (int32((*Sqlite3)(unsafe.Pointer(db)).Fenc))) { goto __13 } Xsqlite3SetString(tls, pzErrMsg, db, ts+12915 /* "attached databas..." */) - rc = 1 + rc = SQLITE_ERROR goto initone_error_out __13: ; @@ -112102,7 +109893,7 @@ __9: if !((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size == 0) { goto __14 } - size = Xsqlite3AbsInt32(tls, *(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((3-1))*4))) + size = Xsqlite3AbsInt32(tls, *(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + 2*4))) if !(size == 0) { goto __15 } @@ -112118,18 +109909,18 @@ __14: // file_format==2 Version 3.1.3. // ALTER TABLE ADD COLUMN // file_format==3 Version 3.1.4. // ditto but with non-NULL defaults // file_format==4 Version 3.3.0. // DESC indices. Boolean constants - (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format = U8(*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((2-1))*4))) + (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format = U8(*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + 1*4))) if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) == 0) { goto __16 } (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format = U8(1) __16: ; - if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) > 4) { + if !(int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) > SQLITE_MAX_FILE_FORMAT) { goto __17 } Xsqlite3SetString(tls, pzErrMsg, db, ts+19234 /* "unsupported file..." */) - rc = 1 + rc = SQLITE_ERROR goto initone_error_out __17: ; @@ -112138,10 +109929,10 @@ __17: // clear the legacy_file_format pragma flag so that a VACUUM will // not downgrade the database and thus invalidate any descending // indices that the user might have created. - if !((iDb == 0) && (*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + uintptr((2-1))*4)) >= 4)) { + if !((iDb == 0) && (*(*int32)(unsafe.Pointer(bp + 104 /* &meta[0] */ + 1*4)) >= 4)) { goto __18 } - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x00000002))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_LegacyFileFmt)) __18: ; @@ -112160,14 +109951,14 @@ __18: }{Xsqlite3InitCallback})), bp+64 /* &initData */, uintptr(0)) (*Sqlite3)(unsafe.Pointer(db)).FxAuth = xAuth - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __19 } rc = (*InitData)(unsafe.Pointer(bp + 64 /* &initData */)).Frc __19: ; Xsqlite3DbFree(tls, db, zSql) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __20 } Xsqlite3AnalysisLoad(tls, db, iDb) @@ -112177,11 +109968,11 @@ __20: if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __21 } - rc = 7 + rc = SQLITE_NOMEM Xsqlite3ResetAllSchemasOfConnection(tls, db) __21: ; - if !((rc == 0) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x08000000)) != 0)) { + if !((rc == SQLITE_OK) || (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_NoSchemaError) != 0)) { goto __22 } // Black magic: If the SQLITE_NoSchemaError flag is set, then consider @@ -112191,8 +109982,8 @@ __21: // of the schema was loaded before the error occurred. The primary // purpose of this is to allow access to the sqlite_schema table // even when its contents have been corrupted. - *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(iDb)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((0x0001)) - rc = 0 + *(*U16)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(iDb)*32)).FpSchema + 114 /* &.schemaFlags */)) |= U16((DB_SchemaLoaded)) + rc = SQLITE_OK __22: ; @@ -112212,7 +110003,7 @@ error_out: if !(rc != 0) { goto __24 } - if !((rc == 7) || (rc == (10 | (int32(12) << 8)))) { + if !((rc == SQLITE_NOMEM) || (rc == (SQLITE_IOERR | (int32(12) << 8)))) { goto __25 } Xsqlite3OomFault(tls, db) @@ -112235,12 +110026,12 @@ __24: func Xsqlite3Init(tls *libc.TLS, db uintptr, pzErrMsg uintptr) int32 { /* sqlite3.c:128755:20: */ var i int32 var rc int32 - var commit_internal int32 = libc.BoolInt32(!(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0001)) != 0)) + var commit_internal int32 = libc.BoolInt32(!(((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_SchemaChange) != 0)) - ((*Sqlite3)(unsafe.Pointer(db)).Fenc) = (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb + uintptr(0)*32)).FpSchema)).Fenc + ((*Sqlite3)(unsafe.Pointer(db)).Fenc) = (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb)).FpSchema)).Fenc // Do the main schema first - if !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(0)*32)).FpSchema)).FschemaFlags) & (0x0001)) == (0x0001)) { + if !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb)).FpSchema)).FschemaFlags) & (DB_SchemaLoaded)) == (DB_SchemaLoaded)) { rc = Xsqlite3InitOne(tls, db, 0, pzErrMsg, uint32(0)) if rc != 0 { return rc @@ -112249,7 +110040,7 @@ func Xsqlite3Init(tls *libc.TLS, db uintptr, pzErrMsg uintptr) int32 { /* sqlite // All other schemas after the main schema. The "temp" schema must be last for i = ((*Sqlite3)(unsafe.Pointer(db)).FnDb - 1); i > 0; i-- { - if !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(i)*32)).FpSchema)).FschemaFlags) & (0x0001)) == (0x0001)) { + if !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(i)*32)).FpSchema)).FschemaFlags) & (DB_SchemaLoaded)) == (DB_SchemaLoaded)) { rc = Xsqlite3InitOne(tls, db, i, pzErrMsg, uint32(0)) if rc != 0 { return rc @@ -112259,22 +110050,22 @@ func Xsqlite3Init(tls *libc.TLS, db uintptr, pzErrMsg uintptr) int32 { /* sqlite if commit_internal != 0 { Xsqlite3CommitInternalChanges(tls, db) } - return 0 + return SQLITE_OK } // This routine is a no-op if the database schema is already initialized. // Otherwise, the schema is loaded. An error code is returned. func Xsqlite3ReadSchema(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:128787:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb if !(int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) != 0) { rc = Xsqlite3Init(tls, db, (pParse + 8 /* &.zErrMsg */)) - if rc != 0 { + if rc != SQLITE_OK { (*Parse)(unsafe.Pointer(pParse)).Frc = rc (*Parse)(unsafe.Pointer(pParse)).FnErr++ } else if (*Sqlite3)(unsafe.Pointer(db)).FnoSharedCache != 0 { - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0010)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaKnownOk) } } return rc @@ -112304,10 +110095,10 @@ func schemaIsValid(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:128809:13: */ // will be closed immediately after reading the meta-value. if !(Xsqlite3BtreeIsInReadTrans(tls, pBt) != 0) { rc = Xsqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0)) - if (rc == 7) || (rc == (10 | (int32(12) << 8))) { + if (rc == SQLITE_NOMEM) || (rc == (SQLITE_IOERR | (int32(12) << 8))) { Xsqlite3OomFault(tls, db) } - if rc != 0 { + if rc != SQLITE_OK { return } openedTransaction = 1 @@ -112316,11 +110107,11 @@ func schemaIsValid(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:128809:13: */ // Read the schema cookie from the database. If it does not match the // value stored as part of the in-memory schema representation, // set Parse.rc to SQLITE_SCHEMA. - Xsqlite3BtreeGetMeta(tls, pBt, 1, bp /* &cookie */) + Xsqlite3BtreeGetMeta(tls, pBt, BTREE_SCHEMA_VERSION, bp /* &cookie */) if *(*int32)(unsafe.Pointer(bp /* cookie */)) != (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FpSchema)).Fschema_cookie { Xsqlite3ResetOneSchema(tls, db, iDb) - (*Parse)(unsafe.Pointer(pParse)).Frc = 17 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_SCHEMA } // Close the transaction, if one was opened. @@ -112409,7 +110200,7 @@ func sqlite3Prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepF var mxLen int32 var pT uintptr *(*uintptr)(unsafe.Pointer(bp + 440 /* zErrMsg */)) = uintptr(0) - rc = 0 // Parsing context + rc = SQLITE_OK // Parsing context libc.Xmemset(tls, bp+16 /* &sParse */, 0, uint64((uintptr(0) + 212 /* &.aTempReg */))) libc.Xmemset(tls, ((bp + 16 /* &sParse */) + uintptr((uint64((uintptr(0) + 264 /* &.sLastToken */))))), 0, (uint64(unsafe.Sizeof(Parse{})) - (uint64((uintptr(0) + 264 /* &.sLastToken */))))) @@ -112419,7 +110210,7 @@ func sqlite3Prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepF // For a long-term use prepared statement avoid the use of // lookaside memory. - if !((prepFlags & U32(0x01)) != 0) { + if !((prepFlags & SQLITE_PREPARE_PERSISTENT) != 0) { goto __1 } (*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).FdisableLookaside++ @@ -112427,7 +110218,7 @@ func sqlite3Prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepF (*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0) __1: ; - (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).FdisableVtab = (U8(libc.Bool32((prepFlags & U32(0x04)) != U32(0)))) + (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).FdisableVtab = (U8(libc.Bool32((prepFlags & SQLITE_PREPARE_NO_VTAB) != U32(0)))) // Check to verify that it is possible to get a read lock on all // database schemas. The inability to get a read lock indicates that @@ -112492,13 +110283,13 @@ __2: if !((nBytes >= 0) && ((nBytes == 0) || (int32(*(*int8)(unsafe.Pointer(zSql + uintptr((nBytes - 1))))) != 0))) { goto __8 } - mxLen = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(1)*4)) + mxLen = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 1*4)) if !(nBytes > mxLen) { goto __10 } - Xsqlite3ErrorWithMsg(tls, db, 18, ts+19322 /* "statement too lo..." */, 0) - rc = Xsqlite3ApiExit(tls, db, 18) + Xsqlite3ErrorWithMsg(tls, db, SQLITE_TOOBIG, ts+19322 /* "statement too lo..." */, 0) + rc = Xsqlite3ApiExit(tls, db, SQLITE_TOOBIG) goto end_prepare __10: ; @@ -112520,10 +110311,10 @@ __8: __9: ; - if !((*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).Frc == 101) { + if !((*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).Frc == SQLITE_DONE) { goto __13 } - (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).Frc = 0 + (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).Frc = SQLITE_OK __13: ; if !((*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).FcheckSchema != 0) { @@ -112548,11 +110339,11 @@ __16: if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __17 } - (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).Frc = 7 + (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).Frc = SQLITE_NOMEM __17: ; rc = (*Parse)(unsafe.Pointer(bp + 16 /* &sParse */)).Frc - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __18 } if !((*Parse)(unsafe.Pointer(bp+16 /* &sParse */)).FpVdbe != 0) { @@ -112607,8 +110398,8 @@ func sqlite3LockAndPrepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32 } Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) Xsqlite3BtreeEnterAll(tls, db) - for ok := true; ok; ok = ((rc == (1 | (int32(2) << 8))) || - ((rc == 17) && ((func() int32 { Xsqlite3ResetOneSchema(tls, db, -1); return libc.PostIncInt32(&cnt, 1) }()) == 0))) { + for ok := true; ok; ok = ((rc == (SQLITE_ERROR | (int32(2) << 8))) || + ((rc == SQLITE_SCHEMA) && ((func() int32 { Xsqlite3ResetOneSchema(tls, db, -1); return libc.PostIncInt32(&cnt, 1) }()) == 0))) { // Make multiple attempts to compile the SQL, until it either succeeds // or encounters a permanent error. A schema problem after one schema // reset is considered a permanent error. @@ -112646,7 +110437,7 @@ func Xsqlite3Reprepare(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:129101:20: prepFlags = Xsqlite3VdbePrepareFlags(tls, p) rc = sqlite3LockAndPrepare(tls, db, zSql, -1, uint32(prepFlags), p, bp /* &pNew */, uintptr(0)) if rc != 0 { - if rc == 7 { + if rc == SQLITE_NOMEM { Xsqlite3OomFault(tls, db) } @@ -112658,7 +110449,7 @@ func Xsqlite3Reprepare(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:129101:20: Xsqlite3TransferBindings(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */)), p) Xsqlite3VdbeResetStepResult(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */))) Xsqlite3VdbeFinalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */))) - return 0 + return SQLITE_OK } // Two versions of the official API. Legacy and new use. In the legacy @@ -112681,7 +110472,7 @@ func Xsqlite3_prepare_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, // parameter. // // Proof in that the 5th parameter to sqlite3LockAndPrepare is 0 - rc = sqlite3LockAndPrepare(tls, db, zSql, nBytes, uint32(0x80), uintptr(0), + rc = sqlite3LockAndPrepare(tls, db, zSql, nBytes, SQLITE_PREPARE_SAVESQL, uintptr(0), ppStmt, pzTail) return rc @@ -112697,7 +110488,7 @@ func Xsqlite3_prepare_v3(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, // Proof by comparison to the implementation of sqlite3_prepare_v2() // directly above. rc = sqlite3LockAndPrepare(tls, db, zSql, nBytes, - (uint32(0x80) | (prepFlags & uint32(0x0f))), + (SQLITE_PREPARE_SAVESQL | (prepFlags & SQLITE_PREPARE_MASK)), uintptr(0), ppStmt, pzTail) return rc @@ -112713,7 +110504,7 @@ func sqlite3Prepare16(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, pre // tricky bit is figuring out the pointer to return in *pzTail. var zSql8 uintptr *(*uintptr)(unsafe.Pointer(bp /* zTail8 */)) = uintptr(0) - var rc int32 = 0 + var rc int32 = SQLITE_OK *(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0) if !(Xsqlite3SafetyCheckOk(tls, db) != 0) || (zSql == uintptr(0)) { @@ -112727,7 +110518,7 @@ func sqlite3Prepare16(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, pre nBytes = sz } Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - zSql8 = Xsqlite3Utf16to8(tls, db, zSql, nBytes, uint8(2)) + zSql8 = Xsqlite3Utf16to8(tls, db, zSql, nBytes, SQLITE_UTF16LE) if zSql8 != 0 { rc = sqlite3LockAndPrepare(tls, db, zSql8, -1, prepFlags, uintptr(0), ppStmt, bp /* &zTail8 */) } @@ -112761,7 +110552,7 @@ func Xsqlite3_prepare16(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, p func Xsqlite3_prepare16_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) int32 { /* sqlite3.c:129268:16: */ var rc int32 - rc = sqlite3Prepare16(tls, db, zSql, nBytes, uint32(0x80), ppStmt, pzTail) + rc = sqlite3Prepare16(tls, db, zSql, nBytes, SQLITE_PREPARE_SAVESQL, ppStmt, pzTail) // VERIFY: F13021 return rc } @@ -112769,7 +110560,7 @@ func Xsqlite3_prepare16_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32 func Xsqlite3_prepare16_v3(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags uint32, ppStmt uintptr, pzTail uintptr) int32 { /* sqlite3.c:129280:16: */ var rc int32 rc = sqlite3Prepare16(tls, db, zSql, nBytes, - (uint32(0x80) | (prepFlags & uint32(0x0f))), + (SQLITE_PREPARE_SAVESQL | (prepFlags & SQLITE_PREPARE_MASK)), ppStmt, pzTail) // VERIFY: F13021 return rc @@ -112932,16 +110723,16 @@ func Xsqlite3SelectNew(tls *libc.TLS, pParse uintptr, pEList uintptr, pSrc uintp } if pEList == uintptr(0) { pEList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), - Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 177, uintptr(0))) + Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ASTERISK, uintptr(0))) } (*Select)(unsafe.Pointer(pNew)).FpEList = pEList - (*Select)(unsafe.Pointer(pNew)).Fop = U8(136) + (*Select)(unsafe.Pointer(pNew)).Fop = TK_SELECT (*Select)(unsafe.Pointer(pNew)).FselFlags = selFlags (*Select)(unsafe.Pointer(pNew)).FiLimit = 0 (*Select)(unsafe.Pointer(pNew)).FiOffset = 0 (*Select)(unsafe.Pointer(pNew)).FselId = U32(libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnSelect, 1)) - *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */) + uintptr(0)*4)) = -1 - *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */) + uintptr(1)*4)) = -1 + *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */))) = -1 + *(*int32)(unsafe.Pointer((pNew + 20 /* &.addrOpenEphm */) + 1*4)) = -1 (*Select)(unsafe.Pointer(pNew)).FnSelectRow = int16(0) if pSrc == uintptr(0) { pSrc = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(SrcList{}))) @@ -113006,9 +110797,9 @@ func Xsqlite3JoinType(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, pC var p uintptr var i int32 var j int32 - *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + uintptr(0)*8)) = pA - *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + uintptr(1)*8)) = pB - *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + uintptr(2)*8)) = pC + *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */)) = pA + *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + 1*8)) = pB + *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + 2*8)) = pC for i = 0; (i < 3) && (*(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + uintptr(i)*8)) != 0); i++ { p = *(*uintptr)(unsafe.Pointer(bp + 32 /* &apAll[0] */ + uintptr(i)*8)) for j = 0; j < (int32(uint64(unsafe.Sizeof(aKeyword)) / uint64(unsafe.Sizeof(struct { @@ -113028,11 +110819,11 @@ func Xsqlite3JoinType(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, pC FnChar U8 Fcode U8 }{})))) { - jointype = jointype | (0x0040) + jointype = jointype | (JT_ERROR) break } } - if ((jointype & (0x0001 | 0x0020)) == (0x0001 | 0x0020)) || ((jointype & 0x0040) != 0) { + if ((jointype & (JT_INNER | JT_OUTER)) == (JT_INNER | JT_OUTER)) || ((jointype & JT_ERROR) != 0) { var zSp uintptr = ts + 16003 /* " " */ if pC == uintptr(0) { @@ -113040,12 +110831,12 @@ func Xsqlite3JoinType(tls *libc.TLS, pParse uintptr, pA uintptr, pB uintptr, pC } Xsqlite3ErrorMsg(tls, pParse, ts+19341 /* "unknown or unsup..." */, libc.VaList(bp, pA, pB, zSp, pC)) - jointype = 0x0001 - } else if ((jointype & 0x0020) != 0) && - ((jointype & (0x0008 | 0x0010)) != 0x0008) { + jointype = JT_INNER + } else if ((jointype & JT_OUTER) != 0) && + ((jointype & (JT_LEFT | JT_RIGHT)) != JT_LEFT) { Xsqlite3ErrorMsg(tls, pParse, ts+19385 /* "RIGHT and FULL O..." */, 0) - jointype = 0x0001 + jointype = JT_INNER } return jointype } @@ -113056,34 +110847,13 @@ var aKeyword = [7]struct { FnChar U8 Fcode U8 }{ - /* natural */ { - Fi: U8(0), - FnChar: U8(7), - Fcode: U8(0x0004)}, - /* left */ { - Fi: U8(6), - FnChar: U8(4), - Fcode: (U8(0x0008 | 0x0020))}, - /* outer */ { - Fi: U8(10), - FnChar: U8(5), - Fcode: U8(0x0020)}, - /* right */ { - Fi: U8(14), - FnChar: U8(5), - Fcode: (U8(0x0010 | 0x0020))}, - /* full */ { - Fi: U8(19), - FnChar: U8(4), - Fcode: (U8((0x0008 | 0x0010) | 0x0020))}, - /* inner */ { - Fi: U8(23), - FnChar: U8(5), - Fcode: U8(0x0001)}, - /* cross */ { - Fi: U8(28), - FnChar: U8(5), - Fcode: (U8(0x0001 | 0x0002))}, + /* natural */ {FnChar: U8(7), Fcode: JT_NATURAL}, + /* left */ {Fi: U8(6), FnChar: U8(4), Fcode: (U8(JT_LEFT | JT_OUTER))}, + /* outer */ {Fi: U8(10), FnChar: U8(5), Fcode: JT_OUTER}, + /* right */ {Fi: U8(14), FnChar: U8(5), Fcode: (U8(JT_RIGHT | JT_OUTER))}, + /* full */ {Fi: U8(19), FnChar: U8(4), Fcode: (U8((JT_LEFT | JT_RIGHT) | JT_OUTER))}, + /* inner */ {Fi: U8(23), FnChar: U8(5), Fcode: JT_INNER}, + /* cross */ {Fi: U8(28), FnChar: U8(5), Fcode: (U8(JT_INNER | JT_CROSS))}, } /* sqlite3.c:129513:5 */ // Return the index of a column in a table. Return -1 if the column @@ -113130,7 +110900,7 @@ func tableAndColumnIndex(tls *libc.TLS, pSrc uintptr, N int32, zCol uintptr, piT for i = 0; i < N; i++ { iCol = columnIndex(tls, (*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(i)*112)).FpTab, zCol) if (iCol >= 0) && - ((bIgnoreHidden == 0) || ((libc.Bool32((int32((*Column)(unsafe.Pointer(((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(i)*112)).FpTab)).FaCol + uintptr(iCol)*32))).FcolFlags) & 0x0002) != 0)) == 0)) { + ((bIgnoreHidden == 0) || ((libc.Bool32((int32((*Column)(unsafe.Pointer(((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(i)*112)).FpTab)).FaCol + uintptr(iCol)*32))).FcolFlags) & COLFLAG_HIDDEN) != 0)) == 0)) { if piTab != 0 { *(*int32)(unsafe.Pointer(piTab)) = i *(*int32)(unsafe.Pointer(piCol)) = iCol @@ -113159,9 +110929,9 @@ func addWhereTerm(tls *libc.TLS, pParse uintptr, pSrc uintptr, iLeft int32, iCol pE1 = Xsqlite3CreateColumnExpr(tls, db, pSrc, iLeft, iColLeft) pE2 = Xsqlite3CreateColumnExpr(tls, db, pSrc, iRight, iColRight) - pEq = Xsqlite3PExpr(tls, pParse, 53, pE1, pE2) + pEq = Xsqlite3PExpr(tls, pParse, TK_EQ, pE1, pE2) if (pEq != 0) && (isOuterJoin != 0) { - *(*U32)(unsafe.Pointer(pEq + 4 /* &.flags */)) |= (U32(0x000001)) + *(*U32)(unsafe.Pointer(pEq + 4 /* &.flags */)) |= (EP_FromJoin) (*Expr)(unsafe.Pointer(pEq)).FiRightJoinTable = I16((*Expr)(unsafe.Pointer(pE2)).FiTable) } @@ -113194,10 +110964,10 @@ func addWhereTerm(tls *libc.TLS, pParse uintptr, pSrc uintptr, iLeft int32, iCol // the output, which is incorrect. func Xsqlite3SetJoinExpr(tls *libc.TLS, p uintptr, iTable int32) { /* sqlite3.c:129680:21: */ for p != 0 { - *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= (U32(0x000001)) + *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= (EP_FromJoin) (*Expr)(unsafe.Pointer(p)).FiRightJoinTable = I16(iTable) - if (int32((*Expr)(unsafe.Pointer(p)).Fop) == 169) && (*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0) { + if (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_FUNCTION) && (*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0) { var i int32 for i = 0; i < (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))).FnExpr; i++ { Xsqlite3SetJoinExpr(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */))+8 /* &.a */)+uintptr(i)*32)).FpExpr, iTable) @@ -113215,11 +110985,11 @@ func Xsqlite3SetJoinExpr(tls *libc.TLS, p uintptr, iTable int32) { /* sqlite3.c: // This happens when a LEFT JOIN is simplified into an ordinary JOIN. func unsetJoinExpr(tls *libc.TLS, p uintptr, iTable int32) { /* sqlite3.c:129703:13: */ for p != 0 { - if (((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000001))) != U32(0)) && + if (((*Expr)(unsafe.Pointer((p))).Fflags & (EP_FromJoin)) != U32(0)) && ((iTable < 0) || (int32((*Expr)(unsafe.Pointer(p)).FiRightJoinTable) == iTable)) { - *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(0x000001)) + *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(EP_FromJoin))) } - if (int32((*Expr)(unsafe.Pointer(p)).Fop) == 169) && (*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0) { + if (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_FUNCTION) && (*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0) { var i int32 for i = 0; i < (*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))).FnExpr; i++ { unsetJoinExpr(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(p + 32 /* &.x */))+8 /* &.a */)+uintptr(i)*32)).FpExpr, iTable) @@ -113253,8 +111023,8 @@ func sqliteProcessJoin(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* sqli var pRight uintptr // Right table being joined pSrc = (*Select)(unsafe.Pointer(p)).FpSrc - pLeft = ((pSrc + 8 /* &.a */) + uintptr(0)*112) - pRight = (pLeft + uintptr(1)*112) + pLeft = (pSrc + 8 /* &.a */) + pRight = (pLeft + 1*112) i = 0 __1: if !(i < ((*SrcList)(unsafe.Pointer(pSrc)).FnSrc - 1)) { @@ -113267,11 +111037,11 @@ __1: if ((*SrcList_item)(unsafe.Pointer(pLeft)).FpTab == uintptr(0)) || (pRightTab == uintptr(0)) { goto __2 } - isOuter = (libc.Bool32((int32((*SrcList_item)(unsafe.Pointer(pRight)).Ffg.Fjointype) & 0x0020) != 0)) + isOuter = (libc.Bool32((int32((*SrcList_item)(unsafe.Pointer(pRight)).Ffg.Fjointype) & JT_OUTER) != 0)) // When the NATURAL keyword is present, add WHERE clause terms for // every column that the two tables have in common. - if (int32((*SrcList_item)(unsafe.Pointer(pRight)).Ffg.Fjointype) & 0x0004) != 0 { + if (int32((*SrcList_item)(unsafe.Pointer(pRight)).Ffg.Fjointype) & JT_NATURAL) != 0 { if ((*SrcList_item)(unsafe.Pointer(pRight)).FpOn != 0) || ((*SrcList_item)(unsafe.Pointer(pRight)).FpUsing != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+19474 /* "a NATURAL join m..." */, libc.VaList(bp, 0)) @@ -113284,7 +111054,7 @@ __1: // var iLeftCol int32 at bp+20, 4 // Matching column in the left table - if (int32((*Column)(unsafe.Pointer(((*Table)(unsafe.Pointer(pRightTab)).FaCol + uintptr(j)*32))).FcolFlags) & 0x0002) != 0 { + if (int32((*Column)(unsafe.Pointer(((*Table)(unsafe.Pointer(pRightTab)).FaCol + uintptr(j)*32))).FcolFlags) & COLFLAG_HIDDEN) != 0 { continue } zName = (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pRightTab)).FaCol + uintptr(j)*32)).FzName @@ -113376,7 +111146,7 @@ func makeSorterRecord(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uint if (*SortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad != 0 { innerLoopLoadRow(tls, pParse, pSelect, (*SortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad) } - Xsqlite3VdbeAddOp3(tls, v, 91, (regBase + nOBSat), (nBase - nOBSat), regOut) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (regBase + nOBSat), (nBase - nOBSat), regOut) return regOut } @@ -113384,7 +111154,7 @@ func makeSorterRecord(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uint // through regData+nData-1 onto the sorter. func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintptr, regData int32, regOrigData int32, nData int32, nPrefixReg int32) { /* sqlite3.c:129882:13: */ var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe // Stmt under construction - var bSeq int32 = (libc.Bool32((int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & 0x01) == 0)) + var bSeq int32 = (libc.Bool32((int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & SORTFLAG_UseSorter) == 0)) var nExpr int32 = (*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr // No. of ORDER BY terms var nBase int32 = ((nExpr + bSeq) + nData) // Fields in sorter record var regBase int32 // Regs for sorter record @@ -113422,14 +111192,14 @@ func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintpt } (*SortCtx)(unsafe.Pointer(pSort)).FlabelDone = Xsqlite3VdbeMakeLabel(tls, pParse) Xsqlite3ExprCodeExprList(tls, pParse, (*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy, regBase, regOrigData, - (uint8(0x01 | (func() int32 { + (uint8(SQLITE_ECEL_DUP | (func() int32 { if regOrigData != 0 { - return 0x04 + return SQLITE_ECEL_REF } return 0 }())))) if bSeq != 0 { - Xsqlite3VdbeAddOp2(tls, v, 119, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor, (regBase + nExpr)) + Xsqlite3VdbeAddOp2(tls, v, OP_Sequence, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor, (regBase + nExpr)) } if (nPrefixReg == 0) && (nData > 0) { Xsqlite3ExprCodeMove(tls, pParse, regData, ((regBase + nExpr) + bSeq), nData) @@ -113447,12 +111217,12 @@ func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintpt *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += ((*SortCtx)(unsafe.Pointer(pSort)).FnOBSat) nKey = ((nExpr - (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat) + bSeq) if bSeq != 0 { - addrFirst = Xsqlite3VdbeAddOp1(tls, v, 20, (regBase + nExpr)) + addrFirst = Xsqlite3VdbeAddOp1(tls, v, OP_IfNot, (regBase + nExpr)) } else { - addrFirst = Xsqlite3VdbeAddOp1(tls, v, 113, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor) + addrFirst = Xsqlite3VdbeAddOp1(tls, v, OP_SequenceTest, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor) } - Xsqlite3VdbeAddOp3(tls, v, 86, regPrevKey, regBase, (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat) + Xsqlite3VdbeAddOp3(tls, v, OP_Compare, regPrevKey, regBase, (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat) pOp = Xsqlite3VdbeGetOp(tls, v, (*SortCtx)(unsafe.Pointer(pSort)).FaddrSortIndex) if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { return @@ -113466,13 +111236,13 @@ func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintpt ((int32((*KeyInfo)(unsafe.Pointer(pKI)).FnAllField) - int32((*KeyInfo)(unsafe.Pointer(pKI)).FnKeyField)) - 1)) pOp = uintptr(0) // Ensure pOp not used after sqltie3VdbeAddOp3() addrJmp = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp3(tls, v, 16, (addrJmp + 1), 0, (addrJmp + 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, (addrJmp + 1), 0, (addrJmp + 1)) (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut = Xsqlite3VdbeMakeLabel(tls, pParse) (*SortCtx)(unsafe.Pointer(pSort)).FregReturn = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 12, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) - Xsqlite3VdbeAddOp1(tls, v, 138, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) + Xsqlite3VdbeAddOp1(tls, v, OP_ResetSorter, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor) if iLimit != 0 { - Xsqlite3VdbeAddOp2(tls, v, 20, iLimit, (*SortCtx)(unsafe.Pointer(pSort)).FlabelDone) + Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, iLimit, (*SortCtx)(unsafe.Pointer(pSort)).FlabelDone) } Xsqlite3VdbeJumpHere(tls, v, addrFirst) @@ -113495,21 +111265,21 @@ func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintpt // just bypass the row insert logic. See the header comment on the // sqlite3WhereOrderByLimitOptLabel() function for additional info. var iCsr int32 = (*SortCtx)(unsafe.Pointer(pSort)).FiECursor - Xsqlite3VdbeAddOp2(tls, v, 49, iLimit, (Xsqlite3VdbeCurrentAddr(tls, v) + 4)) + Xsqlite3VdbeAddOp2(tls, v, OP_IfNotZero, iLimit, (Xsqlite3VdbeCurrentAddr(tls, v) + 4)) - Xsqlite3VdbeAddOp2(tls, v, 33, iCsr, 0) - iSkip = Xsqlite3VdbeAddOp4Int(tls, v, 38, + Xsqlite3VdbeAddOp2(tls, v, OP_Last, iCsr, 0) + iSkip = Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxLE, iCsr, 0, (regBase + nOBSat), (nExpr - nOBSat)) - Xsqlite3VdbeAddOp1(tls, v, 122, iCsr) + Xsqlite3VdbeAddOp1(tls, v, OP_Delete, iCsr) } if regRecord == 0 { regRecord = makeSorterRecord(tls, pParse, pSort, pSelect, regBase, nBase) } - if (int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & 0x01) != 0 { - op = 131 + if (int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & SORTFLAG_UseSorter) != 0 { + op = OP_SorterInsert } else { - op = 130 + op = OP_IdxInsert } Xsqlite3VdbeAddOp4Int(tls, v, op, (*SortCtx)(unsafe.Pointer(pSort)).FiECursor, regRecord, (regBase + nOBSat), (nBase - nOBSat)) @@ -113527,7 +111297,7 @@ func pushOntoSorter(tls *libc.TLS, pParse uintptr, pSort uintptr, pSelect uintpt // Add code to implement the OFFSET func codeOffset(tls *libc.TLS, v uintptr, iOffset int32, iContinue int32) { /* sqlite3.c:130024:13: */ if iOffset > 0 { - Xsqlite3VdbeAddOp3(tls, v, 48, iOffset, iContinue, 1) + Xsqlite3VdbeAddOp3(tls, v, OP_IfPos, iOffset, iContinue, 1) Xsqlite3VdbeComment(tls, v, ts+19643 /* "OFFSET" */, 0) } } @@ -113545,10 +111315,10 @@ func codeDistinct(tls *libc.TLS, pParse uintptr, iTab int32, addrRepeat int32, N v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe r1 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp4Int(tls, v, 30, iTab, addrRepeat, iMem, N) - Xsqlite3VdbeAddOp3(tls, v, 91, iMem, N, r1) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iTab, r1, iMem, N) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, iTab, addrRepeat, iMem, N) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, iMem, N, r1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iTab, r1, iMem, N) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_USESEEKRESULT) Xsqlite3ReleaseTempReg(tls, pParse, r1) } @@ -113584,7 +111354,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo if pDistinct != 0 { hasDistinct = int32((*DistinctCtx)(unsafe.Pointer(pDistinct)).FeTnctType) } else { - hasDistinct = 0 + hasDistinct = WHERE_DISTINCT_NOOP } if (pSort != 0) && ((*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy == uintptr(0)) { pSort = uintptr(0) @@ -113600,7 +111370,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo if (*SelectDest)(unsafe.Pointer(pDest)).FiSdst == 0 { if pSort != 0 { nPrefixReg = (*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr - if !((int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & 0x01) != 0) { + if !((int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & SORTFLAG_UseSorter) != 0) { nPrefixReg++ } *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (nPrefixReg) @@ -113619,27 +111389,27 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo regOrig = libc.AssignInt32(®Result, (*SelectDest)(unsafe.Pointer(pDest)).FiSdst) if srcTab >= 0 { for i = 0; i < nResultCol; i++ { - Xsqlite3VdbeAddOp3(tls, v, 89, srcTab, i, (regResult + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, srcTab, i, (regResult + i)) Xsqlite3VdbeComment(tls, v, ts+824 /* "%s" */, libc.VaList(bp, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpEList+8 /* &.a */)+uintptr(i)*32)).FzEName)) } - } else if eDest != 3 { + } else if eDest != SRT_Exists { // If the destination is an EXISTS(...) expression, the actual // values returned by the SELECT are not required. var ecelFlags U8 // "ecel" is an abbreviation of "ExprCodeExprList" var pEList uintptr - if ((eDest == 10) || (eDest == 9)) || (eDest == 13) { - ecelFlags = U8(0x01) + if ((eDest == SRT_Mem) || (eDest == SRT_Output)) || (eDest == SRT_Coroutine) { + ecelFlags = SQLITE_ECEL_DUP } else { ecelFlags = U8(0) } - if (((pSort != 0) && (hasDistinct == 0)) && (eDest != 12)) && (eDest != 14) { + if (((pSort != 0) && (hasDistinct == 0)) && (eDest != SRT_EphemTab)) && (eDest != SRT_Table) { // For each expression in p->pEList that is a copy of an expression in // the ORDER BY clause (pSort->pOrderBy), set the associated // iOrderByCol value to one more than the index of the ORDER BY // expression within the sort-key that pushOntoSorter() will generate. // This allows the p->pEList field to be omitted from the sorted record, // saving space and CPU cycles. - ecelFlags = U8(int32(ecelFlags) | (0x08 | 0x04)) + ecelFlags = U8(int32(ecelFlags) | (SQLITE_ECEL_OMITREF | SQLITE_ECEL_REF)) for i = (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat; i < (*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(pSort)).FpOrderBy)).FnExpr; i++ { var j int32 @@ -113662,7 +111432,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo (*RowLoadInfo)(unsafe.Pointer(bp + 8 /* &sRowLoadInfo */)).FregResult = regResult (*RowLoadInfo)(unsafe.Pointer(bp + 8 /* &sRowLoadInfo */)).FecelFlags = ecelFlags if (((*Select)(unsafe.Pointer(p)).FiLimit != 0) && - ((int32(ecelFlags) & 0x08) != 0)) && + ((int32(ecelFlags) & SQLITE_ECEL_OMITREF) != 0)) && (nPrefixReg > 0) { (*SortCtx)(unsafe.Pointer(pSort)).FpDeferredRowLoad = bp + 8 /* &sRowLoadInfo */ @@ -113677,7 +111447,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // part of the result. if hasDistinct != 0 { switch int32((*DistinctCtx)(unsafe.Pointer(pDistinct)).FeTnctType) { - case 2: + case WHERE_DISTINCT_ORDERED: { var pOp uintptr // No longer required OpenEphemeral instr. var iJump int32 // Jump destination @@ -113694,7 +111464,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // row is all NULLs. Xsqlite3VdbeChangeToNoop(tls, v, (*DistinctCtx)(unsafe.Pointer(pDistinct)).FaddrTnct) pOp = Xsqlite3VdbeGetOp(tls, v, (*DistinctCtx)(unsafe.Pointer(pDistinct)).FaddrTnct) - (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(72) + (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = OP_Null (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = 1 (*VdbeOp)(unsafe.Pointer(pOp)).Fp2 = regPrev pOp = uintptr(0) // Ensure pOp is not used after sqlite3VdbeAddOp() @@ -113703,23 +111473,23 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo for i = 0; i < nResultCol; i++ { var pColl uintptr = Xsqlite3ExprCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpEList+8 /* &.a */)+uintptr(i)*32)).FpExpr) if i < (nResultCol - 1) { - Xsqlite3VdbeAddOp3(tls, v, 52, (regResult + i), iJump, (regPrev + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Ne, (regResult + i), iJump, (regPrev + i)) } else { - Xsqlite3VdbeAddOp3(tls, v, 53, (regResult + i), iContinue, (regPrev + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Eq, (regResult + i), iContinue, (regPrev + i)) } Xsqlite3VdbeChangeP4(tls, v, -1, pColl, -2) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x80)) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NULLEQ) } - Xsqlite3VdbeAddOp3(tls, v, 77, regResult, regPrev, (nResultCol - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regResult, regPrev, (nResultCol - 1)) break } fallthrough - case 1: + case WHERE_DISTINCT_UNIQUE: { Xsqlite3VdbeChangeToNoop(tls, v, (*DistinctCtx)(unsafe.Pointer(pDistinct)).FaddrTnct) break @@ -113744,12 +111514,12 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo switch eDest { // In this mode, write each query result to the key of the temporary // table iParm. - case 1: + case SRT_Union: { var r1 int32 r1 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 91, regResult, nResultCol, r1) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iParm, r1, regResult, nResultCol) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regResult, nResultCol, r1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, regResult, nResultCol) Xsqlite3ReleaseTempReg(tls, pParse, r1) break @@ -113758,35 +111528,35 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // Construct a record from the query result, but instead of // saving that record, use it as a key to delete elements from // the temporary table iParm. - case 2: + case SRT_Except: { - Xsqlite3VdbeAddOp3(tls, v, 132, iParm, regResult, nResultCol) + Xsqlite3VdbeAddOp3(tls, v, OP_IdxDelete, iParm, regResult, nResultCol) break } // Store the result as data using a unique key. - case 5: + case SRT_Fifo: fallthrough - case 6: + case SRT_DistFifo: fallthrough - case 14: + case SRT_Table: fallthrough - case 12: + case SRT_EphemTab: { var r1 int32 = Xsqlite3GetTempRange(tls, pParse, (nPrefixReg + 1)) - Xsqlite3VdbeAddOp3(tls, v, 91, regResult, nResultCol, (r1 + nPrefixReg)) - if eDest == 6 { + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regResult, nResultCol, (r1 + nPrefixReg)) + if eDest == SRT_DistFifo { // If the destination is DistFifo, then cursor (iParm+1) is open // on an ephemeral index. If the current row is already present // in the index, do not write it to the output. If not, add the // current row to the index and proceed with writing it to the // output table as well. var addr int32 = (Xsqlite3VdbeCurrentAddr(tls, v) + 4) - Xsqlite3VdbeAddOp4Int(tls, v, 30, (iParm + 1), addr, r1, 0) + Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, (iParm + 1), addr, r1, 0) - Xsqlite3VdbeAddOp4Int(tls, v, 130, (iParm + 1), r1, regResult, nResultCol) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, (iParm + 1), r1, regResult, nResultCol) } if pSort != 0 { @@ -113794,9 +111564,9 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo pushOntoSorter(tls, pParse, pSort, p, (r1 + nPrefixReg), regOrig, 1, nPrefixReg) } else { var r2 int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 120, iParm, r2) - Xsqlite3VdbeAddOp3(tls, v, 121, iParm, r1, r2) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x08)) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iParm, r2) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iParm, r1, r2) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_APPEND) Xsqlite3ReleaseTempReg(tls, pParse, r2) } Xsqlite3ReleaseTempRange(tls, pParse, r1, (nPrefixReg + 1)) @@ -113804,7 +111574,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo } - case 15: + case SRT_Upfrom: { if pSort != 0 { pushOntoSorter(tls, @@ -113816,14 +111586,14 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // If the UPDATE FROM join is an aggregate that matches no rows, it // might still be trying to return one row, because that is what // aggregates do. Don't record that empty row in the output table. - Xsqlite3VdbeAddOp2(tls, v, 50, regResult, iBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, regResult, iBreak) - Xsqlite3VdbeAddOp3(tls, v, 91, + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (regResult + (libc.Bool32(i2 < 0))), (nResultCol - (libc.Bool32(i2 < 0))), r1) if i2 < 0 { - Xsqlite3VdbeAddOp3(tls, v, 121, iParm, r1, regResult) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iParm, r1, regResult) } else { - Xsqlite3VdbeAddOp4Int(tls, v, 130, iParm, r1, regResult, i2) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, regResult, i2) } } break @@ -113833,7 +111603,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // If we are creating a set for an "expr IN (SELECT ...)" construct, // then there should be a single item on the stack. Write this // item into the set table with bogus data. - case 11: + case SRT_Set: { if pSort != 0 { // At first glance you would think we could optimize out the @@ -113845,9 +111615,9 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo } else { var r1 int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp4(tls, v, 91, regResult, nResultCol, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regResult, nResultCol, r1, (*SelectDest)(unsafe.Pointer(pDest)).FzAffSdst, nResultCol) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iParm, r1, regResult, nResultCol) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, regResult, nResultCol) Xsqlite3ReleaseTempReg(tls, pParse, r1) } break @@ -113855,9 +111625,9 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo } // If any row exist in the result set, record that fact and abort. - case 3: + case SRT_Exists: { - Xsqlite3VdbeAddOp2(tls, v, 69, 1, iParm) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, iParm) // The LIMIT clause will terminate the loop for us break @@ -113866,7 +111636,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // If this is a scalar select that is part of an expression, then // store the results in the appropriate memory cell or array of // memory cells and break out of the scan loop. - case 10: + case SRT_Mem: { if pSort != 0 { @@ -113880,18 +111650,18 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo } - case 13: + case SRT_Coroutine: fallthrough // Send data to a co-routine - case 9: + case SRT_Output: { // Return the results if pSort != 0 { pushOntoSorter(tls, pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg) - } else if eDest == 13 { - Xsqlite3VdbeAddOp1(tls, v, 14, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm) + } else if eDest == SRT_Coroutine { + Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm) } else { - Xsqlite3VdbeAddOp2(tls, v, 80, regResult, nResultCol) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, regResult, nResultCol) } break @@ -113902,9 +111672,9 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // index with pSO->nExpr+2 columns. Build a key using pSO for the first // pSO->nExpr columns, then make sure all keys are unique by adding a // final OP_Sequence column. The last column is the record as a blob. - case 8: + case SRT_DistQueue: fallthrough - case 7: + case SRT_Queue: { var nKey int32 var r1 int32 @@ -113918,27 +111688,27 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo r1 = Xsqlite3GetTempReg(tls, pParse) r2 = Xsqlite3GetTempRange(tls, pParse, (nKey + 2)) r3 = ((r2 + nKey) + 1) - if eDest == 8 { + if eDest == SRT_DistQueue { // If the destination is DistQueue, then cursor (iParm+1) is open // on a second ephemeral index that holds all values every previously // added to the queue. - addrTest = Xsqlite3VdbeAddOp4Int(tls, v, 30, (iParm + 1), 0, + addrTest = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, (iParm + 1), 0, regResult, nResultCol) } - Xsqlite3VdbeAddOp3(tls, v, 91, regResult, nResultCol, r3) - if eDest == 8 { - Xsqlite3VdbeAddOp2(tls, v, 130, (iParm + 1), r3) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regResult, nResultCol, r3) + if eDest == SRT_DistQueue { + Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, (iParm + 1), r3) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_USESEEKRESULT) } for i = 0; i < nKey; i++ { - Xsqlite3VdbeAddOp2(tls, v, 78, + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, ((regResult + int32(*(*U16)(unsafe.Pointer(((pSO + 8 /* &.a */) + uintptr(i)*32 + 24 /* &.u */ /* &.x */) /* &.iOrderByCol */)))) - 1), (r2 + i)) } - Xsqlite3VdbeAddOp2(tls, v, 119, iParm, (r2 + nKey)) - Xsqlite3VdbeAddOp3(tls, v, 91, r2, (nKey + 2), r1) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iParm, r1, r2, (nKey + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_Sequence, iParm, (r2 + nKey)) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, r2, (nKey + 2), r1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, r2, (nKey + 2)) if addrTest != 0 { Xsqlite3VdbeJumpHere(tls, v, addrTest) } @@ -113964,7 +111734,7 @@ func selectInnerLoop(tls *libc.TLS, pParse uintptr, p uintptr, srcTab int32, pSo // there is a sorter, in which case the sorter has already limited // the output for us. if (pSort == uintptr(0)) && ((*Select)(unsafe.Pointer(p)).FiLimit != 0) { - Xsqlite3VdbeAddOp2(tls, v, 59, (*Select)(unsafe.Pointer(p)).FiLimit, iBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_DecrJumpZero, (*Select)(unsafe.Pointer(p)).FiLimit, iBreak) } } @@ -113980,7 +111750,7 @@ func Xsqlite3KeyInfoAlloc(tls *libc.TLS, db uintptr, N int32, X int32) uintptr { (*KeyInfo)(unsafe.Pointer(p)).Fenc = (*Sqlite3)(unsafe.Pointer(db)).Fenc (*KeyInfo)(unsafe.Pointer(p)).Fdb = db (*KeyInfo)(unsafe.Pointer(p)).FnRef = U32(1) - libc.Xmemset(tls, (p + uintptr(1)*40), 0, uint64(nExtra)) + libc.Xmemset(tls, (p + 1*40), 0, uint64(nExtra)) } else { Xsqlite3OomFault(tls, db) } @@ -114056,13 +111826,13 @@ func Xsqlite3KeyInfoFromExprList(tls *libc.TLS, pParse uintptr, pList uintptr, i func selectOpName(tls *libc.TLS, id int32) uintptr { /* sqlite3.c:130685:19: */ var z uintptr switch id { - case 133: + case TK_ALL: z = ts + 19650 /* "UNION ALL" */ break - case 135: + case TK_INTERSECT: z = ts + 19660 /* "INTERSECT" */ break - case 134: + case TK_EXCEPT: z = ts + 19670 /* "EXCEPT" */ break default: @@ -114121,18 +111891,18 @@ func generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, n var aOutEx uintptr = (*Select)(unsafe.Pointer(p)).FpEList + 8 /* &.a */ if (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut != 0 { - Xsqlite3VdbeAddOp2(tls, v, 12, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) Xsqlite3VdbeGoto(tls, v, addrBreak) Xsqlite3VdbeResolveLabel(tls, v, (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut) } iTab = (*SortCtx)(unsafe.Pointer(pSort)).FiECursor - if ((eDest == 9) || (eDest == 13)) || (eDest == 10) { + if ((eDest == SRT_Output) || (eDest == SRT_Coroutine)) || (eDest == SRT_Mem) { regRowid = 0 regRow = (*SelectDest)(unsafe.Pointer(pDest)).FiSdst } else { regRowid = Xsqlite3GetTempReg(tls, pParse) - if (eDest == 12) || (eDest == 14) { + if (eDest == SRT_EphemTab) || (eDest == SRT_Table) { regRow = Xsqlite3GetTempReg(tls, pParse) nColumn = 0 } else { @@ -114140,24 +111910,24 @@ func generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, n } } nKey = ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - (*SortCtx)(unsafe.Pointer(pSort)).FnOBSat) - if (int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & 0x01) != 0 { + if (int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & SORTFLAG_UseSorter) != 0 { var regSortOut int32 = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) iSortTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) if (*SortCtx)(unsafe.Pointer(pSort)).FlabelBkOut != 0 { - addrOnce = Xsqlite3VdbeAddOp0(tls, v, 17) + addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once) } - Xsqlite3VdbeAddOp3(tls, v, 114, iSortTab, regSortOut, + Xsqlite3VdbeAddOp3(tls, v, OP_OpenPseudo, iSortTab, regSortOut, (((nKey + 1) + nColumn) + nRefKey)) if addrOnce != 0 { Xsqlite3VdbeJumpHere(tls, v, addrOnce) } - addr = (1 + Xsqlite3VdbeAddOp2(tls, v, 35, iTab, addrBreak)) + addr = (1 + Xsqlite3VdbeAddOp2(tls, v, OP_SorterSort, iTab, addrBreak)) codeOffset(tls, v, (*Select)(unsafe.Pointer(p)).FiOffset, addrContinue) - Xsqlite3VdbeAddOp3(tls, v, 125, iTab, regSortOut, iSortTab) + Xsqlite3VdbeAddOp3(tls, v, OP_SorterData, iTab, regSortOut, iSortTab) bSeq = 0 } else { - addr = (1 + Xsqlite3VdbeAddOp2(tls, v, 36, iTab, addrBreak)) + addr = (1 + Xsqlite3VdbeAddOp2(tls, v, OP_Sort, iTab, addrBreak)) codeOffset(tls, v, (*Select)(unsafe.Pointer(p)).FiOffset, addrContinue) iSortTab = iTab bSeq = 1 @@ -114177,47 +111947,47 @@ func generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, n } else { iRead = libc.PostDecInt32(&iCol, 1) } - Xsqlite3VdbeAddOp3(tls, v, 89, iSortTab, iRead, (regRow + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iSortTab, iRead, (regRow + i)) Xsqlite3VdbeComment(tls, v, ts+824 /* "%s" */, libc.VaList(bp, (*ExprList_item)(unsafe.Pointer(aOutEx+uintptr(i)*32)).FzEName)) } } switch eDest { - case 14: + case SRT_Table: fallthrough - case 12: + case SRT_EphemTab: { - Xsqlite3VdbeAddOp3(tls, v, 89, iSortTab, (nKey + bSeq), regRow) - Xsqlite3VdbeAddOp2(tls, v, 120, iParm, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, iParm, regRow, regRowid) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x08)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iSortTab, (nKey + bSeq), regRow) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, iParm, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iParm, regRow, regRowid) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_APPEND) break } - case 11: + case SRT_Set: { - Xsqlite3VdbeAddOp4(tls, v, 91, regRow, nColumn, regRowid, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, regRow, nColumn, regRowid, (*SelectDest)(unsafe.Pointer(pDest)).FzAffSdst, nColumn) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iParm, regRowid, regRow, nColumn) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, regRowid, regRow, nColumn) break } - case 10: + case SRT_Mem: { // The LIMIT clause will terminate the loop for us break } - case 15: + case SRT_Upfrom: { var i2 int32 = (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm2 var r1 int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 91, (regRow + (libc.Bool32(i2 < 0))), (nColumn - (libc.Bool32(i2 < 0))), r1) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (regRow + (libc.Bool32(i2 < 0))), (nColumn - (libc.Bool32(i2 < 0))), r1) if i2 < 0 { - Xsqlite3VdbeAddOp3(tls, v, 121, iParm, r1, regRow) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, iParm, r1, regRow) } else { - Xsqlite3VdbeAddOp4Int(tls, v, 130, iParm, r1, regRow, i2) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iParm, r1, regRow, i2) } break @@ -114225,17 +111995,17 @@ func generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, n default: { - if eDest == 9 { - Xsqlite3VdbeAddOp2(tls, v, 80, (*SelectDest)(unsafe.Pointer(pDest)).FiSdst, nColumn) + if eDest == SRT_Output { + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, (*SelectDest)(unsafe.Pointer(pDest)).FiSdst, nColumn) } else { - Xsqlite3VdbeAddOp1(tls, v, 14, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm) + Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm) } break } } if regRowid != 0 { - if eDest == 11 { + if eDest == SRT_Set { Xsqlite3ReleaseTempRange(tls, pParse, regRow, nColumn) } else { Xsqlite3ReleaseTempReg(tls, pParse, regRow) @@ -114244,13 +112014,13 @@ func generateSortTail(tls *libc.TLS, pParse uintptr, p uintptr, pSort uintptr, n } // The bottom of the loop Xsqlite3VdbeResolveLabel(tls, v, addrContinue) - if (int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & 0x01) != 0 { - Xsqlite3VdbeAddOp2(tls, v, 3, iTab, addr) + if (int32((*SortCtx)(unsafe.Pointer(pSort)).FsortFlags) & SORTFLAG_UseSorter) != 0 { + Xsqlite3VdbeAddOp2(tls, v, OP_SorterNext, iTab, addr) } else { - Xsqlite3VdbeAddOp2(tls, v, 5, iTab, addr) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iTab, addr) } if (*SortCtx)(unsafe.Pointer(pSort)).FregReturn != 0 { - Xsqlite3VdbeAddOp1(tls, v, 65, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, (*SortCtx)(unsafe.Pointer(pSort)).FregReturn) } Xsqlite3VdbeResolveLabel(tls, v, addrBreak) } @@ -114288,7 +112058,7 @@ func columnTypeImpl(tls *libc.TLS, pNC uintptr, pExpr uintptr, pzOrigDb uintptr, *(*uintptr)(unsafe.Pointer(bp + 72 /* zOrigCol */)) = uintptr(0) switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) { - case 164: + case TK_COLUMN: { // The expression is a column. Locate the table the column is being // extracted from in NameContext.pSrcList. This table may be real @@ -114368,7 +112138,7 @@ func columnTypeImpl(tls *libc.TLS, pNC uintptr, pExpr uintptr, pzOrigDb uintptr, break } - case 136: + case TK_SELECT: { // The expression is a sub-select. Return the declaration type and // origin info for the single column in the result set of the SELECT @@ -114376,7 +112146,7 @@ func columnTypeImpl(tls *libc.TLS, pNC uintptr, pExpr uintptr, pzOrigDb uintptr, // var sNC NameContext at bp+80, 56 var pS uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) - var p uintptr = (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pS)).FpEList + 8 /* &.a */) + uintptr(0)*32)).FpExpr + var p uintptr = (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pS)).FpEList + 8 /* &.a */))).FpExpr (*NameContext)(unsafe.Pointer(bp + 80 /* &sNC */)).FpSrcList = (*Select)(unsafe.Pointer(pS)).FpSrc (*NameContext)(unsafe.Pointer(bp + 80 /* &sNC */)).FpNext = pNC @@ -114420,10 +112190,10 @@ func generateColumnTypes(tls *libc.TLS, pParse uintptr, pTabList uintptr, pEList // The vdbe must make its own copy of the column-type and other // column specific strings, in case the schema is reset before this // virtual machine is deleted. - Xsqlite3VdbeSetColName(tls, v, i, 2, *(*uintptr)(unsafe.Pointer(bp + 56 /* zOrigDb */)), libc.UintptrFromInt32(-1)) - Xsqlite3VdbeSetColName(tls, v, i, 3, *(*uintptr)(unsafe.Pointer(bp + 64 /* zOrigTab */)), libc.UintptrFromInt32(-1)) - Xsqlite3VdbeSetColName(tls, v, i, 4, *(*uintptr)(unsafe.Pointer(bp + 72 /* zOrigCol */)), libc.UintptrFromInt32(-1)) - Xsqlite3VdbeSetColName(tls, v, i, 1, zType, libc.UintptrFromInt32(-1)) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_DATABASE, *(*uintptr)(unsafe.Pointer(bp + 56 /* zOrigDb */)), libc.UintptrFromInt32(-1)) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_TABLE, *(*uintptr)(unsafe.Pointer(bp + 64 /* zOrigTab */)), libc.UintptrFromInt32(-1)) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_COLUMN, *(*uintptr)(unsafe.Pointer(bp + 72 /* zOrigCol */)), libc.UintptrFromInt32(-1)) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_DECLTYPE, zType, libc.UintptrFromInt32(-1)) } } @@ -114485,19 +112255,19 @@ func generateColumnNames(tls *libc.TLS, pParse uintptr, pSelect uintptr) { /* sq pEList = (*Select)(unsafe.Pointer(pSelect)).FpEList (*Parse)(unsafe.Pointer(pParse)).FcolNamesSet = U8(1) - fullName = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000004)) != uint64(0))) - srcName = (libc.Bool32((((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000040)) != uint64(0)) || (fullName != 0))) + fullName = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_FullColNames) != uint64(0))) + srcName = (libc.Bool32((((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ShortColNames) != uint64(0)) || (fullName != 0))) Xsqlite3VdbeSetNumCols(tls, v, (*ExprList)(unsafe.Pointer(pEList)).FnExpr) for i = 0; i < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; i++ { var p uintptr = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(i)*32)).FpExpr // Agg processing has not run yet // Covering idx not yet coded - if ((*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FzEName != 0) && ((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0) { + if ((*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FzEName != 0) && ((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME) { // An AS clause always takes first priority var zName uintptr = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(i)*32)).FzEName - Xsqlite3VdbeSetColName(tls, v, i, 0, zName, libc.UintptrFromInt32(-1)) - } else if (srcName != 0) && (int32((*Expr)(unsafe.Pointer(p)).Fop) == 164) { + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zName, libc.UintptrFromInt32(-1)) + } else if (srcName != 0) && (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN) { var zCol uintptr var iCol int32 = int32((*Expr)(unsafe.Pointer(p)).FiColumn) pTab = *(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) @@ -114514,9 +112284,9 @@ func generateColumnNames(tls *libc.TLS, pParse uintptr, pSelect uintptr) { /* sq if fullName != 0 { var zName uintptr = uintptr(0) zName = Xsqlite3MPrintf(tls, db, ts+9997 /* "%s.%s" */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName, zCol)) - Xsqlite3VdbeSetColName(tls, v, i, 0, zName, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zName, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) } else { - Xsqlite3VdbeSetColName(tls, v, i, 0, zCol, libc.UintptrFromInt32(-1)) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, zCol, libc.UintptrFromInt32(-1)) } } else { var z uintptr = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(i)*32)).FzEName @@ -114525,7 +112295,7 @@ func generateColumnNames(tls *libc.TLS, pParse uintptr, pSelect uintptr) { /* sq } else { z = Xsqlite3DbStrDup(tls, db, z) } - Xsqlite3VdbeSetColName(tls, v, i, 0, z, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) + Xsqlite3VdbeSetColName(tls, v, i, COLNAME_NAME, z, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3OomFault}))) } } generateColumnTypes(tls, pParse, pTabList, pEList) @@ -114592,15 +112362,15 @@ __1: } { // Get an appropriate name for the column - if ((libc.AssignUintptr(&zName, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FzEName)) != uintptr(0)) && ((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == 0) { + if ((libc.AssignUintptr(&zName, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FzEName)) != uintptr(0)) && ((int32(*(*uint8)(unsafe.Pointer(((pEList + 8 /* &.a */) + uintptr(i)*32) + 20 /* &.eEName */)) & 0x3 >> 0)) == ENAME_NAME) { // If the column contains an "AS " phrase, use as the name } else { var pColExpr uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(i)*32)).FpExpr) - for int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == 139 { + for int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == TK_DOT { pColExpr = (*Expr)(unsafe.Pointer(pColExpr)).FpRight } - if int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == 164 { + if int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == TK_COLUMN { // For columns use the column name name var iCol int32 = int32((*Expr)(unsafe.Pointer(pColExpr)).FiColumn) var pTab uintptr = *(*uintptr)(unsafe.Pointer(pColExpr + 64 /* &.y */)) @@ -114613,7 +112383,7 @@ __1: } else { zName = ts + 10064 /* "rowid" */ } - } else if int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == 59 { + } else if int32((*Expr)(unsafe.Pointer(pColExpr)).Fop) == TK_ID { zName = *(*uintptr)(unsafe.Pointer(pColExpr + 8 /* &.u */)) } else { @@ -114668,9 +112438,9 @@ __3: Xsqlite3DbFree(tls, db, aCol) *(*uintptr)(unsafe.Pointer(paCol)) = uintptr(0) *(*I16)(unsafe.Pointer(pnCol)) = int16(0) - return 7 + return SQLITE_NOMEM } - return 0 + return SQLITE_OK } // Add type and collation information to a column list based on @@ -114721,10 +112491,10 @@ __1: (*Column)(unsafe.Pointer(pCol)).FzName = Xsqlite3DbReallocOrFree(tls, db, (*Column)(unsafe.Pointer(pCol)).FzName, (uint64((n + m) + 2))) if (*Column)(unsafe.Pointer(pCol)).FzName != 0 { libc.Xmemcpy(tls, ((*Column)(unsafe.Pointer(pCol)).FzName + uintptr((n + 1))), zType, (uint64(m + 1))) - *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pCol + 28 /* &.colFlags */)) |= U16((COLFLAG_HASTYPE)) } } - if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) <= 0x40 { + if int32((*Column)(unsafe.Pointer(pCol)).Faffinity) <= SQLITE_AFF_NONE { (*Column)(unsafe.Pointer(pCol)).Faffinity = aff } pColl = Xsqlite3ExprCollSeq(tls, pParse, p) @@ -114752,8 +112522,8 @@ func Xsqlite3ResultSetOfSelect(tls *libc.TLS, pParse uintptr, pSelect uintptr, a var savedFlags U64 savedFlags = (*Sqlite3)(unsafe.Pointer(db)).Fflags - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x00000004))) - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(0x00000040)) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_FullColNames)) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (SQLITE_ShortColNames) Xsqlite3SelectPrep(tls, pParse, pSelect, uintptr(0)) (*Sqlite3)(unsafe.Pointer(db)).Fflags = savedFlags if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { @@ -114786,7 +112556,7 @@ func Xsqlite3GetVdbe(tls *libc.TLS, pParse uintptr) uintptr { /* sqlite3.c:13144 return (*Parse)(unsafe.Pointer(pParse)).FpVdbe } if ((*Parse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0)) && - ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (0x0008)) == 0) { + ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (SQLITE_FactorOutConst)) == 0) { (*Parse)(unsafe.Pointer(pParse)).FokConstFactor = U8(1) } return Xsqlite3VdbeCreate(tls, pParse) @@ -114838,27 +112608,27 @@ func computeLimitRegisters(tls *libc.TLS, pParse uintptr, p uintptr, iBreak int3 v = Xsqlite3GetVdbe(tls, pParse) if Xsqlite3ExprIsInteger(tls, (*Expr)(unsafe.Pointer(pLimit)).FpLeft, bp /* &n */) != 0 { - Xsqlite3VdbeAddOp2(tls, v, 69, *(*int32)(unsafe.Pointer(bp /* n */)), iLimit) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, *(*int32)(unsafe.Pointer(bp /* n */)), iLimit) Xsqlite3VdbeComment(tls, v, ts+19723 /* "LIMIT counter" */, 0) if *(*int32)(unsafe.Pointer(bp /* n */)) == 0 { Xsqlite3VdbeGoto(tls, v, iBreak) } else if (*(*int32)(unsafe.Pointer(bp /* n */)) >= 0) && (int32((*Select)(unsafe.Pointer(p)).FnSelectRow) > int32(Xsqlite3LogEst(tls, U64(*(*int32)(unsafe.Pointer(bp /* n */)))))) { (*Select)(unsafe.Pointer(p)).FnSelectRow = Xsqlite3LogEst(tls, U64(*(*int32)(unsafe.Pointer(bp /* n */)))) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0004000)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_FixedLimit) } } else { Xsqlite3ExprCode(tls, pParse, (*Expr)(unsafe.Pointer(pLimit)).FpLeft, iLimit) - Xsqlite3VdbeAddOp1(tls, v, 15, iLimit) + Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, iLimit) Xsqlite3VdbeComment(tls, v, ts+19723 /* "LIMIT counter" */, 0) - Xsqlite3VdbeAddOp2(tls, v, 20, iLimit, iBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, iLimit, iBreak) } if (*Expr)(unsafe.Pointer(pLimit)).FpRight != 0 { (*Select)(unsafe.Pointer(p)).FiOffset = libc.AssignInt32(&iOffset, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)) (*Parse)(unsafe.Pointer(pParse)).FnMem++ // Allocate an extra register for limit+offset Xsqlite3ExprCode(tls, pParse, (*Expr)(unsafe.Pointer(pLimit)).FpRight, iOffset) - Xsqlite3VdbeAddOp1(tls, v, 15, iOffset) + Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, iOffset) Xsqlite3VdbeComment(tls, v, ts+19737 /* "OFFSET counter" */, 0) - Xsqlite3VdbeAddOp3(tls, v, 152, iLimit, (iOffset + 1), iOffset) + Xsqlite3VdbeAddOp3(tls, v, OP_OffsetLimit, iLimit, (iOffset + 1), iOffset) Xsqlite3VdbeComment(tls, v, ts+19752 /* "LIMIT+OFFSET" */, 0) } } @@ -114906,7 +112676,7 @@ func multiSelectOrderByKeyInfo(tls *libc.TLS, pParse uintptr, p uintptr, nExtra var pTerm uintptr = (*ExprList_item)(unsafe.Pointer(pItem)).FpExpr var pColl uintptr - if ((*Expr)(unsafe.Pointer(pTerm)).Fflags & U32(0x000100)) != 0 { + if ((*Expr)(unsafe.Pointer(pTerm)).Fflags & EP_Collate) != 0 { pColl = Xsqlite3ExprCollSeq(tls, pParse, pTerm) } else { pColl = multiSelectCollSeq(tls, pParse, p, (int32(*(*U16)(unsafe.Pointer((pItem + 24 /* &.u */ /* &.x */) /* &.iOrderByCol */))) - 1)) @@ -114989,7 +112759,7 @@ func generateWithRecursiveQuery(tls *libc.TLS, pParse uintptr, p uintptr, pDest pSetup = (*Select)(unsafe.Pointer(p)).FpPrior iCurrent = 0 iDistinct = 0 - eDest = 5 // Registers used by LIMIT and OFFSET + eDest = SRT_Fifo // Registers used by LIMIT and OFFSET if !((*Select)(unsafe.Pointer(p)).FpWin != 0) { goto __1 @@ -115000,7 +112770,7 @@ __1: ; // Obtain authorization to do a recursive query - if !(Xsqlite3AuthCheck(tls, pParse, 33, uintptr(0), uintptr(0), uintptr(0)) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_RECURSIVE, uintptr(0), uintptr(0), uintptr(0)) != 0) { goto __2 } return @@ -115043,21 +112813,21 @@ __5: // the Distinct table must be exactly one greater than Queue in order // for the SRT_DistFifo and SRT_DistQueue destinations to work. iQueue = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - if !(int32((*Select)(unsafe.Pointer(p)).Fop) == 132) { + if !(int32((*Select)(unsafe.Pointer(p)).Fop) == TK_UNION) { goto __7 } if pOrderBy != 0 { - eDest = 8 + eDest = SRT_DistQueue } else { - eDest = 6 + eDest = SRT_DistFifo } iDistinct = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) goto __8 __7: if pOrderBy != 0 { - eDest = 7 + eDest = SRT_Queue } else { - eDest = 5 + eDest = SRT_Fifo } __8: ; @@ -115065,25 +112835,25 @@ __8: // Allocate cursors for Current, Queue, and Distinct. regCurrent = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp3(tls, v, 114, iCurrent, regCurrent, nCol) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenPseudo, iCurrent, regCurrent, nCol) if !(pOrderBy != 0) { goto __9 } pKeyInfo = multiSelectOrderByKeyInfo(tls, pParse, p, 1) - Xsqlite3VdbeAddOp4(tls, v, 100, iQueue, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr + 2), 0, + Xsqlite3VdbeAddOp4(tls, v, OP_OpenEphemeral, iQueue, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr + 2), 0, pKeyInfo, -9) (*SelectDest)(unsafe.Pointer(bp /* &destQueue */)).FpOrderBy = pOrderBy goto __10 __9: - Xsqlite3VdbeAddOp2(tls, v, 100, iQueue, nCol) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, iQueue, nCol) __10: ; Xsqlite3VdbeComment(tls, v, ts+19814 /* "Queue table" */, 0) if !(iDistinct != 0) { goto __11 } - *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */) + uintptr(0)*4)) = Xsqlite3VdbeAddOp2(tls, v, 100, iDistinct, 0) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0000020)) + *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */))) = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, iDistinct, 0) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_UsesEphemeral) __11: ; @@ -115103,20 +112873,20 @@ __12: ; // Find the next row in the Queue and output that row - addrTop = Xsqlite3VdbeAddOp2(tls, v, 37, iQueue, addrBreak) + addrTop = Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iQueue, addrBreak) // Transfer the next row in Queue over to Current - Xsqlite3VdbeAddOp1(tls, v, 128, iCurrent) // To reset column cache + Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, iCurrent) // To reset column cache if !(pOrderBy != 0) { goto __13 } - Xsqlite3VdbeAddOp3(tls, v, 89, iQueue, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr + 1), regCurrent) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iQueue, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr + 1), regCurrent) goto __14 __13: - Xsqlite3VdbeAddOp2(tls, v, 126, iQueue, regCurrent) + Xsqlite3VdbeAddOp2(tls, v, OP_RowData, iQueue, regCurrent) __14: ; - Xsqlite3VdbeAddOp1(tls, v, 122, iQueue) + Xsqlite3VdbeAddOp1(tls, v, OP_Delete, iQueue) // Output the single row in Current addrCont = Xsqlite3VdbeMakeLabel(tls, pParse) @@ -115126,7 +112896,7 @@ __14: if !(regLimit != 0) { goto __15 } - Xsqlite3VdbeAddOp2(tls, v, 59, regLimit, addrBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_DecrJumpZero, regLimit, addrBreak) __15: ; @@ -115134,7 +112904,7 @@ __15: // Execute the recursive SELECT taking the single row in Current as // the value for the recursive-table. Store the results in the Queue. - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000008)) != 0) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_Aggregate) != 0) { goto __16 } Xsqlite3ErrorMsg(tls, pParse, ts+19832 /* "recursive aggreg..." */, 0) @@ -115279,7 +113049,7 @@ func multiSelect(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) int32 var pLoop uintptr // For looping through SELECT statements var apColl uintptr // For looping through pKeyInfo->aColl[] var nCol int32 - rc = 0 + rc = SQLITE_OK pDelete = uintptr(0) // Database connection // Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only @@ -115308,17 +113078,17 @@ __1: // The VDBE already created by calling function // Create the destination temporary table if necessary - if !(int32((*SelectDest)(unsafe.Pointer(bp+32 /* &dest */)).FeDest) == 12) { + if !(int32((*SelectDest)(unsafe.Pointer(bp+32 /* &dest */)).FeDest) == SRT_EphemTab) { goto __2 } - Xsqlite3VdbeAddOp2(tls, v, 100, (*SelectDest)(unsafe.Pointer(bp+32 /* &dest */)).FiSDParm, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr) - (*SelectDest)(unsafe.Pointer(bp + 32 /* &dest */)).FeDest = U8(14) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*SelectDest)(unsafe.Pointer(bp+32 /* &dest */)).FiSDParm, (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr) + (*SelectDest)(unsafe.Pointer(bp + 32 /* &dest */)).FeDest = SRT_Table __2: ; // Special handling for a compound-select that originates as a VALUES clause. - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000400)) != 0) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_MultiValue) != 0) { goto __3 } rc = multiSelectValues(tls, pParse, p, bp+32 /* &dest */) @@ -115328,14 +113098,14 @@ __2: goto multi_select_end __4: ; - rc = 0 + rc = SQLITE_OK __3: ; // Make sure all SELECTs in the statement have the same number of elements // in their result sets. - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0002000)) != 0) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_Recursive) != 0) { goto __5 } generateWithRecursiveQuery(tls, pParse, p, bp+32 /* &dest */) @@ -115360,11 +113130,11 @@ __9: // Generate code for the left and right SELECT statements. switch int32((*Select)(unsafe.Pointer(p)).Fop) { - case 133: + case TK_ALL: goto __11 - case 134: + case TK_EXCEPT: goto __12 - case 132: + case TK_UNION: goto __13 default: goto __14 @@ -115390,12 +113160,12 @@ __15: if !((*Select)(unsafe.Pointer(p)).FiLimit != 0) { goto __16 } - addr = Xsqlite3VdbeAddOp1(tls, v, 20, (*Select)(unsafe.Pointer(p)).FiLimit) + addr = Xsqlite3VdbeAddOp1(tls, v, OP_IfNot, (*Select)(unsafe.Pointer(p)).FiLimit) Xsqlite3VdbeComment(tls, v, ts+20005 /* "Jump ahead if LI..." */, 0) if !((*Select)(unsafe.Pointer(p)).FiOffset != 0) { goto __17 } - Xsqlite3VdbeAddOp3(tls, v, 152, + Xsqlite3VdbeAddOp3(tls, v, OP_OffsetLimit, (*Select)(unsafe.Pointer(p)).FiLimit, ((*Select)(unsafe.Pointer(p)).FiOffset + 1), (*Select)(unsafe.Pointer(p)).FiOffset) __17: ; @@ -115427,7 +113197,7 @@ __12: __13: // Cursor number of the temp table holding result op = U8(0) - priorOp = 1 + priorOp = SRT_Union if !(int32((*SelectDest)(unsafe.Pointer(bp+32 /* &dest */)).FeDest) == priorOp) { goto __20 } @@ -115441,10 +113211,10 @@ __20: // intermediate results. unionTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - addr1 = Xsqlite3VdbeAddOp2(tls, v, 100, unionTab, 0) + addr1 = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, unionTab, 0) - *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */) + uintptr(0)*4)) = addr1 - *(*U32)(unsafe.Pointer(findRightmost(tls, p) + 4 /* &.selFlags */)) |= (U32(0x0000020)) + *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */))) = addr1 + *(*U32)(unsafe.Pointer(findRightmost(tls, p) + 4 /* &.selFlags */)) |= (SF_UsesEphemeral) __21: ; @@ -115461,14 +113231,14 @@ __22: ; // Code the current SELECT statement - if !(int32((*Select)(unsafe.Pointer(p)).Fop) == 134) { + if !(int32((*Select)(unsafe.Pointer(p)).Fop) == TK_EXCEPT) { goto __23 } - op = U8(2) + op = SRT_Except goto __24 __23: ; - op = U8(1) + op = SRT_Union __24: ; (*Select)(unsafe.Pointer(p)).FpPrior = uintptr(0) @@ -115481,7 +113251,7 @@ __24: pDelete = (*Select)(unsafe.Pointer(p)).FpPrior (*Select)(unsafe.Pointer(p)).FpPrior = pPrior (*Select)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) - if !(int32((*Select)(unsafe.Pointer(p)).Fop) == 132) { + if !(int32((*Select)(unsafe.Pointer(p)).Fop) == TK_UNION) { goto __25 } (*Select)(unsafe.Pointer(p)).FnSelectRow = Xsqlite3LogEstAdd(tls, (*Select)(unsafe.Pointer(p)).FnSelectRow, (*Select)(unsafe.Pointer(pPrior)).FnSelectRow) @@ -115501,14 +113271,14 @@ __25: iBreak = Xsqlite3VdbeMakeLabel(tls, pParse) iCont = Xsqlite3VdbeMakeLabel(tls, pParse) computeLimitRegisters(tls, pParse, p, iBreak) - Xsqlite3VdbeAddOp2(tls, v, 37, unionTab, iBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, unionTab, iBreak) iStart = Xsqlite3VdbeCurrentAddr(tls, v) selectInnerLoop(tls, pParse, p, unionTab, uintptr(0), uintptr(0), bp+32 /* &dest */, iCont, iBreak) Xsqlite3VdbeResolveLabel(tls, v, iCont) - Xsqlite3VdbeAddOp2(tls, v, 5, unionTab, iStart) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, unionTab, iStart) Xsqlite3VdbeResolveLabel(tls, v, iBreak) - Xsqlite3VdbeAddOp2(tls, v, 116, unionTab, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, unionTab, 0) __26: ; goto __10 @@ -115522,13 +113292,13 @@ __14: tab1 = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) tab2 = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - addr2 = Xsqlite3VdbeAddOp2(tls, v, 100, tab1, 0) + addr2 = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, tab1, 0) - *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */) + uintptr(0)*4)) = addr2 - *(*U32)(unsafe.Pointer(findRightmost(tls, p) + 4 /* &.selFlags */)) |= (U32(0x0000020)) + *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */))) = addr2 + *(*U32)(unsafe.Pointer(findRightmost(tls, p) + 4 /* &.selFlags */)) |= (SF_UsesEphemeral) // Code the SELECTs to our left into temporary table "tab1". - Xsqlite3SelectDestInit(tls, bp+120 /* &intersectdest */, 1, tab1) + Xsqlite3SelectDestInit(tls, bp+120 /* &intersectdest */, SRT_Union, tab1) rc = Xsqlite3Select(tls, pParse, pPrior, bp+120 /* &intersectdest */) if !(rc != 0) { goto __27 @@ -115538,9 +113308,9 @@ __27: ; // Code the current SELECT into temporary table "tab2" - addr2 = Xsqlite3VdbeAddOp2(tls, v, 100, tab2, 0) + addr2 = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, tab2, 0) - *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */) + uintptr(1)*4)) = addr2 + *(*int32)(unsafe.Pointer((p + 20 /* &.addrOpenEphm */) + 1*4)) = addr2 (*Select)(unsafe.Pointer(p)).FpPrior = uintptr(0) pLimit1 = (*Select)(unsafe.Pointer(p)).FpLimit (*Select)(unsafe.Pointer(p)).FpLimit = uintptr(0) @@ -115571,19 +113341,19 @@ __29: iBreak1 = Xsqlite3VdbeMakeLabel(tls, pParse) iCont1 = Xsqlite3VdbeMakeLabel(tls, pParse) computeLimitRegisters(tls, pParse, p, iBreak1) - Xsqlite3VdbeAddOp2(tls, v, 37, tab1, iBreak1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, tab1, iBreak1) r1 = Xsqlite3GetTempReg(tls, pParse) - iStart1 = Xsqlite3VdbeAddOp2(tls, v, 126, tab1, r1) - Xsqlite3VdbeAddOp4Int(tls, v, 29, tab2, iCont1, r1, 0) + iStart1 = Xsqlite3VdbeAddOp2(tls, v, OP_RowData, tab1, r1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, tab2, iCont1, r1, 0) Xsqlite3ReleaseTempReg(tls, pParse, r1) selectInnerLoop(tls, pParse, p, tab1, uintptr(0), uintptr(0), bp+32 /* &dest */, iCont1, iBreak1) Xsqlite3VdbeResolveLabel(tls, v, iCont1) - Xsqlite3VdbeAddOp2(tls, v, 5, tab1, iStart1) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, tab1, iStart1) Xsqlite3VdbeResolveLabel(tls, v, iBreak1) - Xsqlite3VdbeAddOp2(tls, v, 116, tab2, 0) - Xsqlite3VdbeAddOp2(tls, v, 116, tab1, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, tab2, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, tab1, 0) goto __10 __10: @@ -115614,7 +113384,7 @@ __31: // SELECT statements to the left always skip this part. The right-most // SELECT might also skip this part if it has no ORDER BY clause and // no temp tables are required. - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000020)) != 0) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_UsesEphemeral) != 0) { goto __32 } // Number of columns in result set @@ -115623,7 +113393,7 @@ __31: if !(!(pKeyInfo != 0)) { goto __33 } - rc = 7 + rc = SQLITE_NOMEM goto multi_select_end __33: ; @@ -115704,7 +113474,7 @@ func Xsqlite3SelectWrongNumTermsError(tls *libc.TLS, pParse uintptr, p uintptr) bp := tls.Alloc(8) defer tls.Free(8) - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000200)) != 0 { + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_Values) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+20054 /* "all VALUES must ..." */, 0) } else { Xsqlite3ErrorMsg(tls, pParse, @@ -115742,13 +113512,13 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint if regPrev != 0 { var addr1 int32 var addr2 int32 - addr1 = Xsqlite3VdbeAddOp1(tls, v, 20, regPrev) - addr2 = Xsqlite3VdbeAddOp4(tls, v, 86, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (regPrev + 1), (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, + addr1 = Xsqlite3VdbeAddOp1(tls, v, OP_IfNot, regPrev) + addr2 = Xsqlite3VdbeAddOp4(tls, v, OP_Compare, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (regPrev + 1), (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, Xsqlite3KeyInfoRef(tls, pKeyInfo), -9) - Xsqlite3VdbeAddOp3(tls, v, 16, (addr2 + 2), iContinue, (addr2 + 2)) + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, (addr2 + 2), iContinue, (addr2 + 2)) Xsqlite3VdbeJumpHere(tls, v, addr1) - Xsqlite3VdbeAddOp3(tls, v, 77, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (regPrev + 1), ((*SelectDest)(unsafe.Pointer(pIn)).FnSdst - 1)) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, regPrev) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (regPrev + 1), ((*SelectDest)(unsafe.Pointer(pIn)).FnSdst - 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, regPrev) } if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { return 0 @@ -115759,14 +113529,14 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint switch int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) { // Store the result as data using a unique key. - case 12: + case SRT_EphemTab: { var r1 int32 = Xsqlite3GetTempReg(tls, pParse) var r2 int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 91, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, r1) - Xsqlite3VdbeAddOp2(tls, v, 120, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r2) - Xsqlite3VdbeAddOp3(tls, v, 121, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r1, r2) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x08)) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, r1) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r2) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r1, r2) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_APPEND) Xsqlite3ReleaseTempReg(tls, pParse, r2) Xsqlite3ReleaseTempReg(tls, pParse, r1) break @@ -115774,14 +113544,14 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint } // If we are creating a set for an "expr IN (SELECT ...)". - case 11: + case SRT_Set: { var r1 int32 r1 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp4(tls, v, 91, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst, r1, (*SelectDest)(unsafe.Pointer(pDest)).FzAffSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst) - Xsqlite3VdbeAddOp4Int(tls, v, 130, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r1, + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, r1, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst) Xsqlite3ReleaseTempReg(tls, pParse, r1) break @@ -115792,7 +113562,7 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint // store the results in the appropriate memory cell and break out // of the scan loop. Note that the select might return multiple columns // if it is the RHS of a row-value IN operator. - case 10: + case SRT_Mem: { if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 { @@ -115805,14 +113575,14 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint // The results are stored in a sequence of registers // starting at pDest->iSdst. Then the co-routine yields. - case 13: + case SRT_Coroutine: { if (*SelectDest)(unsafe.Pointer(pDest)).FiSdst == 0 { (*SelectDest)(unsafe.Pointer(pDest)).FiSdst = Xsqlite3GetTempRange(tls, pParse, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst) (*SelectDest)(unsafe.Pointer(pDest)).FnSdst = (*SelectDest)(unsafe.Pointer(pIn)).FnSdst } Xsqlite3ExprCodeMove(tls, pParse, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pDest)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst) - Xsqlite3VdbeAddOp1(tls, v, 14, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm) + Xsqlite3VdbeAddOp1(tls, v, OP_Yield, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm) break } @@ -115827,7 +113597,7 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint default: { - Xsqlite3VdbeAddOp2(tls, v, 80, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, (*SelectDest)(unsafe.Pointer(pIn)).FiSdst, (*SelectDest)(unsafe.Pointer(pIn)).FnSdst) break } @@ -115835,12 +113605,12 @@ func generateOutputSubroutine(tls *libc.TLS, pParse uintptr, p uintptr, pIn uint // Jump to the end of the loop if the LIMIT is reached. if (*Select)(unsafe.Pointer(p)).FiLimit != 0 { - Xsqlite3VdbeAddOp2(tls, v, 59, (*Select)(unsafe.Pointer(p)).FiLimit, iBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_DecrJumpZero, (*Select)(unsafe.Pointer(p)).FiLimit, iBreak) } // Generate the subroutine return Xsqlite3VdbeResolveLabel(tls, v, iContinue) - Xsqlite3VdbeAddOp1(tls, v, 65, regReturn) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regReturn) return addr } @@ -115988,7 +113758,7 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // For operators other than UNION ALL we have to make sure that // the ORDER BY clause covers every term of the result set. Add // terms to the ORDER BY clause as necessary. - if op != 133 { + if op != TK_ALL { for i = 1; (int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0) && (i <= (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr); i++ { var pItem uintptr j = 0 @@ -116013,11 +113783,11 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) __3: ; if j == nOrderBy { - var pNew uintptr = Xsqlite3Expr(tls, db, 152, uintptr(0)) + var pNew uintptr = Xsqlite3Expr(tls, db, TK_INTEGER, uintptr(0)) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x000400)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (EP_IntValue) *(*int32)(unsafe.Pointer(pNew + 8 /* &.u */)) = i (*Select)(unsafe.Pointer(p)).FpOrderBy = libc.AssignUintptr(&pOrderBy, Xsqlite3ExprListAppend(tls, pParse, pOrderBy, pNew)) if pOrderBy != 0 { @@ -116036,7 +113806,7 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) aPermute = Xsqlite3DbMallocRawNN(tls, db, (uint64(uint64(unsafe.Sizeof(U32(0))) * (uint64(nOrderBy + 1))))) if aPermute != 0 { var pItem uintptr - *(*U32)(unsafe.Pointer(aPermute + uintptr(0)*4)) = U32(nOrderBy) + *(*U32)(unsafe.Pointer(aPermute)) = U32(nOrderBy) i = 1 pItem = pOrderBy + 8 /* &.a */ __4: @@ -116068,14 +113838,14 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // Allocate a range of temporary registers and the KeyInfo needed // for the logic that removes duplicate result rows when the // operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL). - if op == 133 { + if op == TK_ALL { regPrev = 0 } else { var nExpr int32 = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr regPrev = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (nExpr + 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regPrev) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regPrev) pKeyDup = Xsqlite3KeyInfoAlloc(tls, db, nExpr, 1) if pKeyDup != 0 { @@ -116096,17 +113866,17 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // Compute the limit registers computeLimitRegisters(tls, pParse, p, labelEnd) - if ((*Select)(unsafe.Pointer(p)).FiLimit != 0) && (op == 133) { + if ((*Select)(unsafe.Pointer(p)).FiLimit != 0) && (op == TK_ALL) { regLimitA = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) regLimitB = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 77, func() int32 { + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, func() int32 { if (*Select)(unsafe.Pointer(p)).FiOffset != 0 { return ((*Select)(unsafe.Pointer(p)).FiOffset + 1) } return (*Select)(unsafe.Pointer(p)).FiLimit }(), regLimitA) - Xsqlite3VdbeAddOp2(tls, v, 77, regLimitA, regLimitB) + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, regLimitA, regLimitB) } else { regLimitA = libc.AssignInt32(®LimitB, 0) } @@ -116117,15 +113887,15 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) regAddrB = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) regOutA = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) regOutB = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3SelectDestInit(tls, bp+8 /* &destA */, 13, regAddrA) - Xsqlite3SelectDestInit(tls, bp+48 /* &destB */, 13, regAddrB) + Xsqlite3SelectDestInit(tls, bp+8 /* &destA */, SRT_Coroutine, regAddrA) + Xsqlite3SelectDestInit(tls, bp+48 /* &destB */, SRT_Coroutine, regAddrB) Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+20182 /* "MERGE (%s)" */, libc.VaList(bp, selectOpName(tls, int32((*Select)(unsafe.Pointer(p)).Fop)))) // Generate a coroutine to evaluate the SELECT statement to the // left of the compound operator - the "A" select. addrSelectA = (Xsqlite3VdbeCurrentAddr(tls, v) + 1) - addr1 = Xsqlite3VdbeAddOp3(tls, v, 13, regAddrA, 0, addrSelectA) + addr1 = Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regAddrA, 0, addrSelectA) Xsqlite3VdbeComment(tls, v, ts+20193 /* "left SELECT" */, 0) (*Select)(unsafe.Pointer(pPrior)).FiLimit = regLimitA Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+20205 /* "LEFT" */, 0) @@ -116136,7 +113906,7 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // Generate a coroutine to evaluate the SELECT statement on // the right - the "B" select addrSelectB = (Xsqlite3VdbeCurrentAddr(tls, v) + 1) - addr1 = Xsqlite3VdbeAddOp3(tls, v, 13, regAddrB, 0, addrSelectB) + addr1 = Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regAddrB, 0, addrSelectB) Xsqlite3VdbeComment(tls, v, ts+20210 /* "right SELECT" */, 0) savedLimit = (*Select)(unsafe.Pointer(p)).FiLimit savedOffset = (*Select)(unsafe.Pointer(p)).FiOffset @@ -116157,7 +113927,7 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // Generate a subroutine that outputs the current row of the B // select as the next output row of the compound select. - if (op == 133) || (op == 132) { + if (op == TK_ALL) || (op == TK_UNION) { Xsqlite3VdbeNoopComment(tls, v, ts+20250 /* "Output routine f..." */, 0) addrOutB = generateOutputSubroutine(tls, pParse, p, bp+48 /* &destB */, pDest, regOutB, @@ -116167,12 +113937,12 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // Generate a subroutine to run when the results from select A // are exhausted and only data in select B remains. - if (op == 134) || (op == 135) { + if (op == TK_EXCEPT) || (op == TK_INTERSECT) { addrEofA_noB = libc.AssignInt32(&addrEofA, labelEnd) } else { Xsqlite3VdbeNoopComment(tls, v, ts+20271 /* "eof-A subroutine" */, 0) - addrEofA = Xsqlite3VdbeAddOp2(tls, v, 12, regOutB, addrOutB) - addrEofA_noB = Xsqlite3VdbeAddOp2(tls, v, 14, regAddrB, labelEnd) + addrEofA = Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutB, addrOutB) + addrEofA_noB = Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrB, labelEnd) Xsqlite3VdbeGoto(tls, v, addrEofA) (*Select)(unsafe.Pointer(p)).FnSelectRow = Xsqlite3LogEstAdd(tls, (*Select)(unsafe.Pointer(p)).FnSelectRow, (*Select)(unsafe.Pointer(pPrior)).FnSelectRow) @@ -116180,57 +113950,57 @@ func multiSelectOrderBy(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) // Generate a subroutine to run when the results from select B // are exhausted and only data in select A remains. - if op == 135 { + if op == TK_INTERSECT { addrEofB = addrEofA if int32((*Select)(unsafe.Pointer(p)).FnSelectRow) > int32((*Select)(unsafe.Pointer(pPrior)).FnSelectRow) { (*Select)(unsafe.Pointer(p)).FnSelectRow = (*Select)(unsafe.Pointer(pPrior)).FnSelectRow } } else { Xsqlite3VdbeNoopComment(tls, v, ts+20288 /* "eof-B subroutine" */, 0) - addrEofB = Xsqlite3VdbeAddOp2(tls, v, 12, regOutA, addrOutA) - Xsqlite3VdbeAddOp2(tls, v, 14, regAddrA, labelEnd) + addrEofB = Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutA, addrOutA) + Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrA, labelEnd) Xsqlite3VdbeGoto(tls, v, addrEofB) } // Generate code to handle the case of AB Xsqlite3VdbeNoopComment(tls, v, ts+20341 /* "A-gt-B subroutin..." */, 0) addrAgtB = Xsqlite3VdbeCurrentAddr(tls, v) - if (op == 133) || (op == 132) { - Xsqlite3VdbeAddOp2(tls, v, 12, regOutB, addrOutB) + if (op == TK_ALL) || (op == TK_UNION) { + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutB, addrOutB) } - Xsqlite3VdbeAddOp2(tls, v, 14, regAddrB, addrEofB) + Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrB, addrEofB) Xsqlite3VdbeGoto(tls, v, labelCmpr) // This code runs once to initialize everything. Xsqlite3VdbeJumpHere(tls, v, addr1) - Xsqlite3VdbeAddOp2(tls, v, 14, regAddrA, addrEofA_noB) - Xsqlite3VdbeAddOp2(tls, v, 14, regAddrB, addrEofB) + Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrA, addrEofA_noB) + Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regAddrB, addrEofB) // Implement the main merge loop Xsqlite3VdbeResolveLabel(tls, v, labelCmpr) - Xsqlite3VdbeAddOp4(tls, v, 85, 0, 0, 0, aPermute, -15) - Xsqlite3VdbeAddOp4(tls, v, 86, (*SelectDest)(unsafe.Pointer(bp+8 /* &destA */)).FiSdst, (*SelectDest)(unsafe.Pointer(bp+48 /* &destB */)).FiSdst, nOrderBy, + Xsqlite3VdbeAddOp4(tls, v, OP_Permutation, 0, 0, 0, aPermute, -15) + Xsqlite3VdbeAddOp4(tls, v, OP_Compare, (*SelectDest)(unsafe.Pointer(bp+8 /* &destA */)).FiSdst, (*SelectDest)(unsafe.Pointer(bp+48 /* &destB */)).FiSdst, nOrderBy, pKeyMerge, -9) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x01)) - Xsqlite3VdbeAddOp3(tls, v, 16, addrAltB, addrAeqB, addrAgtB) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_PERMUTE) + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, addrAltB, addrAeqB, addrAgtB) // Jump to the this point in order to terminate the query. Xsqlite3VdbeResolveLabel(tls, v, labelEnd) @@ -116288,15 +114058,15 @@ func substExpr(tls *libc.TLS, pSubst uintptr, pExpr uintptr) uintptr { /* sqlite if pExpr == uintptr(0) { return uintptr(0) } - if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0)) && + if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0)) && (int32((*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable) == (*SubstContext)(unsafe.Pointer(pSubst)).FiTable) { (*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable = I16((*SubstContext)(unsafe.Pointer(pSubst)).FiNewTable) } - if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) && + if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SubstContext)(unsafe.Pointer(pSubst)).FiTable)) && - !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000008))) != U32(0)) { + !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FixedCol)) != U32(0)) { if int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) < 0 { - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(119) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_NULL } else { var pNew uintptr var pCopy uintptr = (*ExprList_item)(unsafe.Pointer(((*SubstContext)(unsafe.Pointer(pSubst)).FpEList + 8 /* &.a */) + uintptr((*Expr)(unsafe.Pointer(pExpr)).FiColumn)*32)).FpExpr @@ -116306,22 +114076,22 @@ func substExpr(tls *libc.TLS, pSubst uintptr, pExpr uintptr) uintptr { /* sqlite Xsqlite3VectorErrorMsg(tls, (*SubstContext)(unsafe.Pointer(pSubst)).FpParse, pCopy) } else { var db uintptr = (*Parse)(unsafe.Pointer((*SubstContext)(unsafe.Pointer(pSubst)).FpParse)).Fdb - if ((*SubstContext)(unsafe.Pointer(pSubst)).FisLeftJoin != 0) && (int32((*Expr)(unsafe.Pointer(pCopy)).Fop) != 164) { + if ((*SubstContext)(unsafe.Pointer(pSubst)).FisLeftJoin != 0) && (int32((*Expr)(unsafe.Pointer(pCopy)).Fop) != TK_COLUMN) { libc.Xmemset(tls, bp /* &ifNullRow */, 0, uint64(unsafe.Sizeof(Expr{}))) - (*Expr)(unsafe.Pointer(bp /* &ifNullRow */)).Fop = U8(176) + (*Expr)(unsafe.Pointer(bp /* &ifNullRow */)).Fop = TK_IF_NULL_ROW (*Expr)(unsafe.Pointer(bp /* &ifNullRow */)).FpLeft = pCopy (*Expr)(unsafe.Pointer(bp /* &ifNullRow */)).FiTable = (*SubstContext)(unsafe.Pointer(pSubst)).FiNewTable - (*Expr)(unsafe.Pointer(bp /* &ifNullRow */)).Fflags = U32(0x001000) + (*Expr)(unsafe.Pointer(bp /* &ifNullRow */)).Fflags = EP_Skip pCopy = bp /* &ifNullRow */ } pNew = Xsqlite3ExprDup(tls, db, pCopy, 0) if (pNew != 0) && ((*SubstContext)(unsafe.Pointer(pSubst)).FisLeftJoin != 0) { - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x100000)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (EP_CanBeNull) } - if (pNew != 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0)) { + if (pNew != 0) && (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0)) { (*Expr)(unsafe.Pointer(pNew)).FiRightJoinTable = (*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable - *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (U32(0x000001)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.flags */)) |= (EP_FromJoin) } Xsqlite3ExprDelete(tls, db, pExpr) pExpr = pNew @@ -116329,7 +114099,7 @@ func substExpr(tls *libc.TLS, pSubst uintptr, pExpr uintptr) uintptr { /* sqlite // Ensure that the expression now has an implicit collation sequence, // just as it did when it was a column of a view or sub-query. if pExpr != 0 { - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 164) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 111) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLLATE) { var pColl uintptr = Xsqlite3ExprCollSeq(tls, (*SubstContext)(unsafe.Pointer(pSubst)).FpParse, pExpr) pExpr = Xsqlite3ExprAddCollateString(tls, (*SubstContext)(unsafe.Pointer(pSubst)).FpParse, pExpr, func() uintptr { @@ -116339,22 +114109,22 @@ func substExpr(tls *libc.TLS, pSubst uintptr, pExpr uintptr) uintptr { /* sqlite return ts + 363 /* "BINARY" */ }()) } - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(0x000100)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(EP_Collate))) } } } } else { - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 176) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SubstContext)(unsafe.Pointer(pSubst)).FiTable) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IF_NULL_ROW) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == (*SubstContext)(unsafe.Pointer(pSubst)).FiTable) { (*Expr)(unsafe.Pointer(pExpr)).FiTable = (*SubstContext)(unsafe.Pointer(pSubst)).FiNewTable } (*Expr)(unsafe.Pointer(pExpr)).FpLeft = substExpr(tls, pSubst, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) (*Expr)(unsafe.Pointer(pExpr)).FpRight = substExpr(tls, pSubst, (*Expr)(unsafe.Pointer(pExpr)).FpRight) - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { substSelect(tls, pSubst, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)), 1) } else { substExprList(tls, pSubst, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0) { var pWin uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) (*Window)(unsafe.Pointer(pWin)).FpFilter = substExpr(tls, pSubst, (*Window)(unsafe.Pointer(pWin)).FpFilter) substExprList(tls, pSubst, (*Window)(unsafe.Pointer(pWin)).FpPartition) @@ -116419,18 +114189,18 @@ func substSelect(tls *libc.TLS, pSubst uintptr, p uintptr, doPrior int32) { /* s // pSrcItem->colUsed mask. func recomputeColumnsUsedExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:132903:12: */ var pItem uintptr - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 164 { - return 0 + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN { + return WRC_Continue } pItem = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) if (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor != (*Expr)(unsafe.Pointer(pExpr)).FiTable { - return 0 + return WRC_Continue } if int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) < 0 { - return 0 + return WRC_Continue } *(*Bitmask)(unsafe.Pointer(pItem + 88 /* &.colUsed */)) |= (Xsqlite3ExprColUsed(tls, pExpr)) - return 0 + return WRC_Continue } func recomputeColumnsUsed(tls *libc.TLS, pSelect uintptr, pSrcItem uintptr) { /* sqlite3.c:132912:13: */ @@ -116629,7 +114399,7 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg // Check to see if flattening is permitted. Return 0 if not. - if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0001)) != 0 { + if (int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_QueryFlattener)) != 0 { return 0 } pSrc = (*Select)(unsafe.Pointer(p)).FpSrc @@ -116655,13 +114425,13 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg if ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) && ((*Expr)(unsafe.Pointer((*Select)(unsafe.Pointer(pSub)).FpLimit)).FpRight != 0) { return 0 } // Restriction (14) - if (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000100)) != U32(0)) && ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) { + if (((*Select)(unsafe.Pointer(p)).FselFlags & SF_Compound) != U32(0)) && ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) { return 0 // Restriction (15) } if (*SrcList)(unsafe.Pointer(pSubSrc)).FnSrc == 0 { return 0 } // Restriction (7) - if ((*Select)(unsafe.Pointer(pSub)).FselFlags & U32(0x0000001)) != 0 { + if ((*Select)(unsafe.Pointer(pSub)).FselFlags & SF_Distinct) != 0 { return 0 } // Restriction (4) if ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) && (((*SrcList)(unsafe.Pointer(pSrc)).FnSrc > 1) || (isAgg != 0)) { @@ -116676,10 +114446,10 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg if ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) && ((*Select)(unsafe.Pointer(p)).FpWhere != 0) { return 0 } // Restriction (19) - if ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) && (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000001)) != U32(0)) { + if ((*Select)(unsafe.Pointer(pSub)).FpLimit != 0) && (((*Select)(unsafe.Pointer(p)).FselFlags & SF_Distinct) != U32(0)) { return 0 // Restriction (21) } - if ((*Select)(unsafe.Pointer(pSub)).FselFlags & (U32(0x0002000))) != 0 { + if ((*Select)(unsafe.Pointer(pSub)).FselFlags & (SF_Recursive)) != 0 { return 0 // Restrictions (22) } @@ -116701,12 +114471,12 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg // the LEFT JOIN table should be all-NULL. // // See also tickets #306, #350, and #3300. - if (int32((*SrcList_item)(unsafe.Pointer(pSubitem)).Ffg.Fjointype) & 0x0020) != 0 { + if (int32((*SrcList_item)(unsafe.Pointer(pSubitem)).Ffg.Fjointype) & JT_OUTER) != 0 { isLeftJoin = 1 if ((((*SrcList)(unsafe.Pointer(pSubSrc)).FnSrc > 1) || // (3a) (isAgg != 0)) || // (3b) - ((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pSubSrc+8 /* &.a */)+uintptr(0)*112)).FpTab)).FnModuleArg != 0)) || // (3c) - (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000001)) != U32(0)) { + ((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pSubSrc + 8 /* &.a */))).FpTab)).FnModuleArg != 0)) || // (3c) + (((*Select)(unsafe.Pointer(p)).FselFlags & SF_Distinct) != U32(0)) { return 0 } } @@ -116719,13 +114489,13 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg if (*Select)(unsafe.Pointer(pSub)).FpOrderBy != 0 { return 0 // Restriction (20) } - if ((isAgg != 0) || (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000001)) != U32(0))) || ((*SrcList)(unsafe.Pointer(pSrc)).FnSrc != 1) { + if ((isAgg != 0) || (((*Select)(unsafe.Pointer(p)).FselFlags & SF_Distinct) != U32(0))) || ((*SrcList)(unsafe.Pointer(pSrc)).FnSrc != 1) { return 0 // (17d1), (17d2), or (17d3) } for pSub1 = pSub; pSub1 != 0; pSub1 = (*Select)(unsafe.Pointer(pSub1)).FpPrior { - if (((((*Select)(unsafe.Pointer(pSub1)).FselFlags & (U32(0x0000001 | 0x0000008))) != U32(0)) || // (17b) - (((*Select)(unsafe.Pointer(pSub1)).FpPrior != 0) && (int32((*Select)(unsafe.Pointer(pSub1)).Fop) != 133))) || // (17a) + if (((((*Select)(unsafe.Pointer(pSub1)).FselFlags & (U32(SF_Distinct | SF_Aggregate))) != U32(0)) || // (17b) + (((*Select)(unsafe.Pointer(pSub1)).FpPrior != 0) && (int32((*Select)(unsafe.Pointer(pSub1)).Fop) != TK_ALL))) || // (17a) ((*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(pSub1)).FpSrc)).FnSrc < 1)) || // (17c) ((*Select)(unsafe.Pointer(pSub1)).FpWin != 0) { return 0 @@ -116754,7 +114524,7 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg // Authorize the subquery (*Parse)(unsafe.Pointer(pParse)).FzAuthContext = (*SrcList_item)(unsafe.Pointer(pSubitem)).FzName - Xsqlite3AuthCheck(tls, pParse, 21, uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3AuthCheck(tls, pParse, SQLITE_SELECT, uintptr(0), uintptr(0), uintptr(0)) (*Parse)(unsafe.Pointer(pParse)).FzAuthContext = zSavedAuthContext @@ -116803,7 +114573,7 @@ func flattenSubquery(tls *libc.TLS, pParse uintptr, p uintptr, iFrom int32, isAg (*Select)(unsafe.Pointer(p)).FpLimit = pLimit (*Select)(unsafe.Pointer(p)).FpOrderBy = pOrderBy (*Select)(unsafe.Pointer(p)).FpSrc = pSrc - (*Select)(unsafe.Pointer(p)).Fop = U8(133) + (*Select)(unsafe.Pointer(p)).Fop = TK_ALL if pNew == uintptr(0) { (*Select)(unsafe.Pointer(p)).FpPrior = pPrior } else { @@ -116938,7 +114708,7 @@ __1: // // We look at every expression in the outer query and every place we see // "a" we substitute "x*3" and every place we see "b" we substitute "y+10". - if ((*Select)(unsafe.Pointer(pSub)).FpOrderBy != 0) && (((*Select)(unsafe.Pointer(pParent)).FselFlags & U32(0x0400000)) == U32(0)) { + if ((*Select)(unsafe.Pointer(pSub)).FpOrderBy != 0) && (((*Select)(unsafe.Pointer(pParent)).FselFlags & SF_NoopOrderBy) == U32(0)) { // At this point, any non-zero iOrderByCol values indicate that the // ORDER BY column expression is identical to the iOrderByCol'th // expression returned by SELECT statement pSub. Since these values @@ -116964,7 +114734,7 @@ __1: } if pWhere != 0 { if (*Select)(unsafe.Pointer(pParent)).FpWhere != 0 { - (*Select)(unsafe.Pointer(pParent)).FpWhere = Xsqlite3PExpr(tls, pParse, 44, pWhere, (*Select)(unsafe.Pointer(pParent)).FpWhere) + (*Select)(unsafe.Pointer(pParent)).FpWhere = Xsqlite3PExpr(tls, pParse, TK_AND, pWhere, (*Select)(unsafe.Pointer(pParent)).FpWhere) } else { (*Select)(unsafe.Pointer(pParent)).FpWhere = pWhere } @@ -116982,7 +114752,7 @@ __1: // The flattened query is a compound if either the inner or the // outer query is a compound. - *(*U32)(unsafe.Pointer(pParent + 4 /* &.selFlags */)) |= ((*Select)(unsafe.Pointer(pSub)).FselFlags & U32(0x0000100)) + *(*U32)(unsafe.Pointer(pParent + 4 /* &.selFlags */)) |= ((*Select)(unsafe.Pointer(pSub)).FselFlags & SF_Compound) // restriction (17b) // SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y; @@ -117032,7 +114802,7 @@ type WhereConst = WhereConst1 /* sqlite3.c:133502:27 */ func constInsert(tls *libc.TLS, pConst uintptr, pColumn uintptr, pValue uintptr, pExpr uintptr) { /* sqlite3.c:133518:13: */ var i int32 - if ((*Expr)(unsafe.Pointer((pColumn))).Fflags & (U32(0x000008))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pColumn))).Fflags & (EP_FixedCol)) != U32(0) { return } if int32(Xsqlite3ExprAffinity(tls, pValue)) != 0 { @@ -117074,24 +114844,24 @@ func findConstInWhere(tls *libc.TLS, pConst uintptr, pExpr uintptr) { /* sqlite3 if pExpr == uintptr(0) { return } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0) { return } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 44 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AND { findConstInWhere(tls, pConst, (*Expr)(unsafe.Pointer(pExpr)).FpRight) findConstInWhere(tls, pConst, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) return } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 53 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_EQ { return } pRight = (*Expr)(unsafe.Pointer(pExpr)).FpRight pLeft = (*Expr)(unsafe.Pointer(pExpr)).FpLeft - if (int32((*Expr)(unsafe.Pointer(pRight)).Fop) == 164) && (Xsqlite3ExprIsConstant(tls, pLeft) != 0) { + if (int32((*Expr)(unsafe.Pointer(pRight)).Fop) == TK_COLUMN) && (Xsqlite3ExprIsConstant(tls, pLeft) != 0) { constInsert(tls, pConst, pRight, pLeft, pExpr) } - if (int32((*Expr)(unsafe.Pointer(pLeft)).Fop) == 164) && (Xsqlite3ExprIsConstant(tls, pRight) != 0) { + if (int32((*Expr)(unsafe.Pointer(pLeft)).Fop) == TK_COLUMN) && (Xsqlite3ExprIsConstant(tls, pRight) != 0) { constInsert(tls, pConst, pLeft, pRight, pExpr) } } @@ -117103,12 +114873,12 @@ func findConstInWhere(tls *libc.TLS, pConst uintptr, pExpr uintptr) { /* sqlite3 func propagateConstantExprRewrite(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:133591:12: */ var i int32 var pConst uintptr - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 164 { - return 0 + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN { + return WRC_Continue } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000008 | 0x000001))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_FixedCol | EP_FromJoin))) != U32(0) { - return 0 + return WRC_Continue } pConst = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) for i = 0; i < (*WhereConst)(unsafe.Pointer(pConst)).FnConst; i++ { @@ -117124,13 +114894,13 @@ func propagateConstantExprRewrite(tls *libc.TLS, pWalker uintptr, pExpr uintptr) } // A match is found. Add the EP_FixedCol property (*WhereConst)(unsafe.Pointer(pConst)).FnChng++ - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(0x800000)) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x000008)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(EP_Leaf))) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_FixedCol) (*Expr)(unsafe.Pointer(pExpr)).FpLeft = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FpParse)).Fdb, *(*uintptr)(unsafe.Pointer((*WhereConst)(unsafe.Pointer(pConst)).FapExpr + uintptr(((i*2)+1))*8)), 0) break } - return 1 + return WRC_Prune } // The WHERE-clause constant propagation optimization. @@ -117263,7 +115033,7 @@ func pushDownWhereTerms(tls *libc.TLS, pParse uintptr, pSubq uintptr, pWhere uin if pWhere == uintptr(0) { return 0 } - if ((*Select)(unsafe.Pointer(pSubq)).FselFlags & U32(0x0002000)) != 0 { + if ((*Select)(unsafe.Pointer(pSubq)).FselFlags & SF_Recursive) != 0 { return 0 } // restriction (2) @@ -117276,17 +115046,17 @@ func pushDownWhereTerms(tls *libc.TLS, pParse uintptr, pSubq uintptr, pWhere uin if (*Select)(unsafe.Pointer(pSubq)).FpLimit != uintptr(0) { return 0 // restriction (3) } - for int32((*Expr)(unsafe.Pointer(pWhere)).Fop) == 44 { + for int32((*Expr)(unsafe.Pointer(pWhere)).Fop) == TK_AND { nChng = nChng + (pushDownWhereTerms(tls, pParse, pSubq, (*Expr)(unsafe.Pointer(pWhere)).FpRight, iCursor, isLeftJoin)) pWhere = (*Expr)(unsafe.Pointer(pWhere)).FpLeft } if (isLeftJoin != 0) && - (((libc.Bool32(((*Expr)(unsafe.Pointer((pWhere))).Fflags & (U32(0x000001))) != U32(0))) == 0) || + (((libc.Bool32(((*Expr)(unsafe.Pointer((pWhere))).Fflags & (EP_FromJoin)) != U32(0))) == 0) || (int32((*Expr)(unsafe.Pointer(pWhere)).FiRightJoinTable) != iCursor)) { return 0 // restriction (4) } - if (((*Expr)(unsafe.Pointer((pWhere))).Fflags & (U32(0x000001))) != U32(0)) && (int32((*Expr)(unsafe.Pointer(pWhere)).FiRightJoinTable) != iCursor) { + if (((*Expr)(unsafe.Pointer((pWhere))).Fflags & (EP_FromJoin)) != U32(0)) && (int32((*Expr)(unsafe.Pointer(pWhere)).FiRightJoinTable) != iCursor) { return 0 // restriction (5) } if Xsqlite3ExprIsTableConstant(tls, pWhere, iCursor) != 0 { @@ -117302,7 +115072,7 @@ func pushDownWhereTerms(tls *libc.TLS, pParse uintptr, pSubq uintptr, pWhere uin (*SubstContext)(unsafe.Pointer(bp /* &x */)).FisLeftJoin = 0 (*SubstContext)(unsafe.Pointer(bp /* &x */)).FpEList = (*Select)(unsafe.Pointer(pSubq)).FpEList pNew = substExpr(tls, bp /* &x */, pNew) - if ((*Select)(unsafe.Pointer(pSubq)).FselFlags & U32(0x0000008)) != 0 { + if ((*Select)(unsafe.Pointer(pSubq)).FselFlags & SF_Aggregate) != 0 { (*Select)(unsafe.Pointer(pSubq)).FpHaving = Xsqlite3ExprAnd(tls, pParse, (*Select)(unsafe.Pointer(pSubq)).FpHaving, pNew) } else { (*Select)(unsafe.Pointer(pSubq)).FpWhere = Xsqlite3ExprAnd(tls, pParse, (*Select)(unsafe.Pointer(pSubq)).FpWhere, pNew) @@ -117328,31 +115098,31 @@ func pushDownWhereTerms(tls *libc.TLS, pParse uintptr, pSubq uintptr, pWhere uin // located but before their arguments have been subjected to aggregate // analysis. func minMaxQuery(tls *libc.TLS, db uintptr, pFunc uintptr, ppMinMax uintptr) U8 { /* sqlite3.c:133825:11: */ - var eRet int32 = 0x0000 // Return value + var eRet int32 = WHERE_ORDERBY_NORMAL // Return value var pEList uintptr = *(*uintptr)(unsafe.Pointer(pFunc + 32 /* &.x */)) // Arguments to agg function var zFunc uintptr // Name of aggregate function pFunc var pOrderBy uintptr var sortFlags U8 = U8(0) - if ((pEList == uintptr(0)) || ((*ExprList)(unsafe.Pointer(pEList)).FnExpr != 1)) || (((*Expr)(unsafe.Pointer((pFunc))).Fflags & (U32(0x1000000))) != U32(0)) { + if ((pEList == uintptr(0)) || ((*ExprList)(unsafe.Pointer(pEList)).FnExpr != 1)) || (((*Expr)(unsafe.Pointer((pFunc))).Fflags & (EP_WinFunc)) != U32(0)) { return U8(eRet) } zFunc = *(*uintptr)(unsafe.Pointer(pFunc + 8 /* &.u */)) if Xsqlite3StrICmp(tls, zFunc, ts+16204 /* "min" */) == 0 { - eRet = 0x0001 - if Xsqlite3ExprCanBeNull(tls, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */)+uintptr(0)*32)).FpExpr) != 0 { - sortFlags = U8(0x02) + eRet = WHERE_ORDERBY_MIN + if Xsqlite3ExprCanBeNull(tls, (*ExprList_item)(unsafe.Pointer((pEList+8 /* &.a */))).FpExpr) != 0 { + sortFlags = KEYINFO_ORDER_BIGNULL } } else if Xsqlite3StrICmp(tls, zFunc, ts+16208 /* "max" */) == 0 { - eRet = 0x0002 - sortFlags = U8(0x01) + eRet = WHERE_ORDERBY_MAX + sortFlags = KEYINFO_ORDER_DESC } else { return U8(eRet) } *(*uintptr)(unsafe.Pointer(ppMinMax)) = libc.AssignUintptr(&pOrderBy, Xsqlite3ExprListDup(tls, db, pEList, 0)) if pOrderBy != 0 { - (*ExprList_item)(unsafe.Pointer((pOrderBy + 8 /* &.a */) + uintptr(0)*32)).FsortFlags = sortFlags + (*ExprList_item)(unsafe.Pointer((pOrderBy + 8 /* &.a */))).FsortFlags = sortFlags } return U8(eRet) } @@ -117371,25 +115141,25 @@ func isSimpleCount(tls *libc.TLS, p uintptr, pAggInfo uintptr) uintptr { /* sqli var pExpr uintptr if ((((*Select)(unsafe.Pointer(p)).FpWhere != 0) || ((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr != 1)) || - ((*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc != 1)) || ((*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc+8 /* &.a */)+uintptr(0)*112)).FpSelect != 0) { + ((*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc != 1)) || ((*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpSelect != 0) { return uintptr(0) } - pTab = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab - pExpr = (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpEList + 8 /* &.a */) + uintptr(0)*32)).FpExpr + pTab = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpTab + pExpr = (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpEList + 8 /* &.a */))).FpExpr if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { return uintptr(0) } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 165 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_AGG_FUNCTION { return uintptr(0) } if (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == 0 { return uintptr(0) } - if ((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(0)*24)).FpFunc)).FfuncFlags & U32(0x0100)) == U32(0) { + if ((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FpFunc)).FfuncFlags & SQLITE_FUNC_COUNT) == U32(0) { return uintptr(0) } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000002 | 0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(EP_Distinct | EP_WinFunc))) != U32(0) { return uintptr(0) } @@ -117414,11 +115184,11 @@ func Xsqlite3IndexedByLookup(tls *libc.TLS, pParse uintptr, pFrom uintptr) int32 if !(pIdx != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+20359 /* "no such index: %..." */, libc.VaList(bp, zIndexedBy, 0)) (*Parse)(unsafe.Pointer(pParse)).FcheckSchema = U8(1) - return 1 + return SQLITE_ERROR } (*SrcList_item)(unsafe.Pointer(pFrom)).FpIBIndex = pIdx } - return 0 + return SQLITE_OK } // Detect compound SELECT statements that use an ORDER BY clause with @@ -117454,15 +115224,15 @@ func convertCompoundSelectToSubquery(tls *libc.TLS, pWalker uintptr, p uintptr) // var dummy Token at bp, 16 if (*Select)(unsafe.Pointer(p)).FpPrior == uintptr(0) { - return 0 + return WRC_Continue } if (*Select)(unsafe.Pointer(p)).FpOrderBy == uintptr(0) { - return 0 + return WRC_Continue } - for pX = p; (pX != 0) && ((int32((*Select)(unsafe.Pointer(pX)).Fop) == 133) || (int32((*Select)(unsafe.Pointer(pX)).Fop) == 136)); pX = (*Select)(unsafe.Pointer(pX)).FpPrior { + for pX = p; (pX != 0) && ((int32((*Select)(unsafe.Pointer(pX)).Fop) == TK_ALL) || (int32((*Select)(unsafe.Pointer(pX)).Fop) == TK_SELECT)); pX = (*Select)(unsafe.Pointer(pX)).FpPrior { } if pX == uintptr(0) { - return 0 + return WRC_Continue } a = (*Select)(unsafe.Pointer(p)).FpOrderBy + 8 /* &.a */ // If iOrderByCol is already non-zero, then it has already been matched @@ -117470,16 +115240,16 @@ func convertCompoundSelectToSubquery(tls *libc.TLS, pWalker uintptr, p uintptr) // SELECT is rewritten for window-functions processing and then passed // to sqlite3SelectPrep() and similar a second time. The rewriting done // by this function is not required in this case. - if *(*U16)(unsafe.Pointer(a + uintptr(0)*32 + 24 /* &.u */ /* &.x */ /* &.iOrderByCol */)) != 0 { - return 0 + if *(*U16)(unsafe.Pointer(a + 24 /* &.u */ /* &.x */ /* &.iOrderByCol */)) != 0 { + return WRC_Continue } for i = ((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpOrderBy)).FnExpr - 1); i >= 0; i-- { - if ((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(a+uintptr(i)*32)).FpExpr)).Fflags & U32(0x000100)) != 0 { + if ((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer(a+uintptr(i)*32)).FpExpr)).Fflags & EP_Collate) != 0 { break } } if i < 0 { - return 0 + return WRC_Continue } // If we reach this point, that means the transformation is required. @@ -117488,17 +115258,17 @@ func convertCompoundSelectToSubquery(tls *libc.TLS, pWalker uintptr, p uintptr) db = (*Parse)(unsafe.Pointer(pParse)).Fdb pNew = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Select{}))) if pNew == uintptr(0) { - return 2 + return WRC_Abort } libc.Xmemset(tls, bp /* &dummy */, 0, uint64(unsafe.Sizeof(Token{}))) pNewSrc = Xsqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp /* &dummy */, pNew, uintptr(0), uintptr(0)) if pNewSrc == uintptr(0) { - return 2 + return WRC_Abort } *(*Select)(unsafe.Pointer(pNew)) = *(*Select)(unsafe.Pointer(p)) (*Select)(unsafe.Pointer(p)).FpSrc = pNewSrc - (*Select)(unsafe.Pointer(p)).FpEList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), Xsqlite3Expr(tls, db, 177, uintptr(0))) - (*Select)(unsafe.Pointer(p)).Fop = U8(136) + (*Select)(unsafe.Pointer(p)).FpEList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), Xsqlite3Expr(tls, db, TK_ASTERISK, uintptr(0))) + (*Select)(unsafe.Pointer(p)).Fop = TK_SELECT (*Select)(unsafe.Pointer(p)).FpWhere = uintptr(0) (*Select)(unsafe.Pointer(pNew)).FpGroupBy = uintptr(0) (*Select)(unsafe.Pointer(pNew)).FpHaving = uintptr(0) @@ -117507,13 +115277,13 @@ func convertCompoundSelectToSubquery(tls *libc.TLS, pWalker uintptr, p uintptr) (*Select)(unsafe.Pointer(p)).FpNext = uintptr(0) (*Select)(unsafe.Pointer(p)).FpWith = uintptr(0) (*Select)(unsafe.Pointer(p)).FpWinDefn = uintptr(0) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000100)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_Compound))) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0010000)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_Converted) (*Select)(unsafe.Pointer((*Select)(unsafe.Pointer(pNew)).FpPrior)).FpNext = pNew (*Select)(unsafe.Pointer(pNew)).FpLimit = uintptr(0) - return 0 + return WRC_Continue } // Check to see if the FROM clause term pFrom has table-valued function @@ -117600,7 +115370,7 @@ func withExpand(tls *libc.TLS, pWalker uintptr, pFrom uintptr) int32 { /* sqlite // WITH clause that pCte belongs to if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { - return 1 + return SQLITE_ERROR } pCte = searchWith(tls, (*Parse)(unsafe.Pointer(pParse)).FpWith, pFrom, bp+40 /* &pWith */) @@ -117618,29 +115388,29 @@ func withExpand(tls *libc.TLS, pWalker uintptr, pFrom uintptr) int32 { /* sqlite // In this case, proceed. if (*Cte)(unsafe.Pointer(pCte)).FzCteErr != 0 { Xsqlite3ErrorMsg(tls, pParse, (*Cte)(unsafe.Pointer(pCte)).FzCteErr, libc.VaList(bp, (*Cte)(unsafe.Pointer(pCte)).FzName)) - return 1 + return SQLITE_ERROR } if cannotBeFunction(tls, pParse, pFrom) != 0 { - return 1 + return SQLITE_ERROR } (*SrcList_item)(unsafe.Pointer(pFrom)).FpTab = libc.AssignUintptr(&pTab, Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Table{})))) if pTab == uintptr(0) { - return 2 + return WRC_Abort } (*Table)(unsafe.Pointer(pTab)).FnTabRef = U32(1) (*Table)(unsafe.Pointer(pTab)).FzName = Xsqlite3DbStrDup(tls, db, (*Cte)(unsafe.Pointer(pCte)).FzName) (*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1) (*Table)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200) - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0002 | 0x0200)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(TF_Ephemeral | TF_NoVisibleRowid)) (*SrcList_item)(unsafe.Pointer(pFrom)).FpSelect = Xsqlite3SelectDup(tls, db, (*Cte)(unsafe.Pointer(pCte)).FpSelect, 0) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - return 7 + return SQLITE_NOMEM } // Check if this is a recursive CTE. pSel = (*SrcList_item)(unsafe.Pointer(pFrom)).FpSelect - bMayRecursive = (libc.Bool32((int32((*Select)(unsafe.Pointer(pSel)).Fop) == 133) || (int32((*Select)(unsafe.Pointer(pSel)).Fop) == 132))) + bMayRecursive = (libc.Bool32((int32((*Select)(unsafe.Pointer(pSel)).Fop) == TK_ALL) || (int32((*Select)(unsafe.Pointer(pSel)).Fop) == TK_UNION))) if bMayRecursive != 0 { var i int32 var pSrc uintptr = (*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pFrom)).FpSelect)).FpSrc @@ -117652,7 +115422,7 @@ func withExpand(tls *libc.TLS, pWalker uintptr, pFrom uintptr) int32 { /* sqlite (*SrcList_item)(unsafe.Pointer(pItem)).FpTab = pTab libc.SetBitFieldPtr8Uint32(pItem+60 /* &.fg */ +4 /* &.isRecursive */, uint32(1), 5, 0x20) (*Table)(unsafe.Pointer(pTab)).FnTabRef++ - *(*U32)(unsafe.Pointer(pSel + 4 /* &.selFlags */)) |= (U32(0x0002000)) + *(*U32)(unsafe.Pointer(pSel + 4 /* &.selFlags */)) |= (SF_Recursive) } } } @@ -117661,7 +115431,7 @@ func withExpand(tls *libc.TLS, pWalker uintptr, pFrom uintptr) int32 { /* sqlite if (*Table)(unsafe.Pointer(pTab)).FnTabRef > U32(2) { Xsqlite3ErrorMsg(tls, pParse, ts+20400 /* "multiple referen..." */, libc.VaList(bp+8, (*Cte)(unsafe.Pointer(pCte)).FzName)) - return 1 + return SQLITE_ERROR } (*Cte)(unsafe.Pointer(pCte)).FzCteErr = ts + 20443 /* "circular referen..." */ @@ -117686,14 +115456,14 @@ func withExpand(tls *libc.TLS, pWalker uintptr, pFrom uintptr) int32 { /* sqlite Xsqlite3ErrorMsg(tls, pParse, ts+20466, /* "table %s has %d ..." */ libc.VaList(bp+16, (*Cte)(unsafe.Pointer(pCte)).FzName, (*ExprList)(unsafe.Pointer(pEList)).FnExpr, (*ExprList)(unsafe.Pointer((*Cte)(unsafe.Pointer(pCte)).FpCols)).FnExpr)) (*Parse)(unsafe.Pointer(pParse)).FpWith = pSavedWith - return 1 + return SQLITE_ERROR } pEList = (*Cte)(unsafe.Pointer(pCte)).FpCols } Xsqlite3ColumnsFromExprList(tls, pParse, pEList, (pTab + 70 /* &.nCol */), (pTab + 8 /* &.aCol */)) if bMayRecursive != 0 { - if ((*Select)(unsafe.Pointer(pSel)).FselFlags & U32(0x0002000)) != 0 { + if ((*Select)(unsafe.Pointer(pSel)).FselFlags & SF_Recursive) != 0 { (*Cte)(unsafe.Pointer(pCte)).FzCteErr = ts + 20504 /* "multiple recursi..." */ } else { (*Cte)(unsafe.Pointer(pCte)).FzCteErr = ts + 20538 /* "recursive refere..." */ @@ -117704,7 +115474,7 @@ func withExpand(tls *libc.TLS, pWalker uintptr, pFrom uintptr) int32 { /* sqlite (*Parse)(unsafe.Pointer(pParse)).FpWith = pSavedWith } - return 0 + return SQLITE_OK } // If the SELECT passed as the second argument has an associated WITH @@ -117738,7 +115508,7 @@ func Xsqlite3ExpandSubquery(tls *libc.TLS, pParse uintptr, pFrom uintptr) int32 (*SrcList_item)(unsafe.Pointer(pFrom)).FpTab = libc.AssignUintptr(&pTab, Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(Table{})))) if pTab == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Table)(unsafe.Pointer(pTab)).FnTabRef = U32(1) if (*SrcList_item)(unsafe.Pointer(pFrom)).FzAlias != 0 { @@ -117752,12 +115522,12 @@ func Xsqlite3ExpandSubquery(tls *libc.TLS, pParse uintptr, pFrom uintptr) int32 Xsqlite3ColumnsFromExprList(tls, pParse, (*Select)(unsafe.Pointer(pSel)).FpEList, (pTab + 70 /* &.nCol */), (pTab + 8 /* &.aCol */)) (*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1) (*Table)(unsafe.Pointer(pTab)).FnRowLogEst = int16(200) - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0002)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (TF_Ephemeral) if (*Parse)(unsafe.Pointer(pParse)).FnErr != 0 { - return 1 + return SQLITE_ERROR } - return 0 + return SQLITE_OK } // This routine is a Walker callback for "expanding" a SELECT statement. @@ -117800,13 +115570,13 @@ func selectExpander(tls *libc.TLS, pWalker uintptr, p uintptr) int32 { /* sqlite var selFlags U16 = U16((*Select)(unsafe.Pointer(p)).FselFlags) var elistFlags U32 = U32(0) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0000040)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_Expanded) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - return 2 + return WRC_Abort } - if (int32(selFlags) & 0x0000040) != 0 { - return 1 + if (int32(selFlags) & SF_Expanded) != 0 { + return WRC_Prune } if (*Walker)(unsafe.Pointer(pWalker)).FeCode != 0 { // Renumber selId because it has been copied from a view @@ -117837,7 +115607,7 @@ __1: } if withExpand(tls, pWalker, pFrom) != 0 { - return 2 + return WRC_Abort } if (*SrcList_item)(unsafe.Pointer(pFrom)).FpTab != 0 { } else if (*SrcList_item)(unsafe.Pointer(pFrom)).FzName == uintptr(0) { @@ -117845,43 +115615,43 @@ __1: // A sub-query in the FROM clause of a SELECT if Xsqlite3WalkSelect(tls, pWalker, pSel) != 0 { - return 2 + return WRC_Abort } if Xsqlite3ExpandSubquery(tls, pParse, pFrom) != 0 { - return 2 + return WRC_Abort } } else { // An ordinary table or view name in the FROM clause (*SrcList_item)(unsafe.Pointer(pFrom)).FpTab = libc.AssignUintptr(&pTab, Xsqlite3LocateTableItem(tls, pParse, uint32(0), pFrom)) if pTab == uintptr(0) { - return 2 + return WRC_Abort } if (*Table)(unsafe.Pointer(pTab)).FnTabRef >= U32(0xffff) { Xsqlite3ErrorMsg(tls, pParse, ts+20588, /* "too many referen..." */ libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName)) (*SrcList_item)(unsafe.Pointer(pFrom)).FpTab = uintptr(0) - return 2 + return WRC_Abort } (*Table)(unsafe.Pointer(pTab)).FnTabRef++ if !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) && (cannotBeFunction(tls, pParse, pFrom) != 0) { - return 2 + return WRC_Abort } if ((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) || ((*Table)(unsafe.Pointer(pTab)).FpSelect != 0) { var nCol I16 var eCodeOrig U8 = U8((*Walker)(unsafe.Pointer(pWalker)).FeCode) if Xsqlite3ViewGetColumnNames(tls, pParse, pTab) != 0 { - return 2 + return WRC_Abort } - if ((*Table)(unsafe.Pointer(pTab)).FpSelect != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x80000000)) == uint64(0)) { + if ((*Table)(unsafe.Pointer(pTab)).FpSelect != 0) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_EnableView) == uint64(0)) { Xsqlite3ErrorMsg(tls, pParse, ts+20627, /* "access to view \"..." */ libc.VaList(bp+8, (*Table)(unsafe.Pointer(pTab)).FzName)) } if ((((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) && ((uint32(int32(*(*uint8)(unsafe.Pointer((pFrom + 60 /* &.fg */) + 4 /* &.fromDDL */)) & 0x40 >> 6))) != 0)) && ((*Table)(unsafe.Pointer(pTab)).FpVTable != uintptr(0))) && - (int32((*VTable)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FpVTable)).FeVtabRisk) > (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00000080)) != uint64(0)))) { + (int32((*VTable)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FpVTable)).FeVtabRisk) > (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_TrustedSchema) != uint64(0)))) { Xsqlite3ErrorMsg(tls, pParse, ts+20658, /* "unsafe use of vi..." */ libc.VaList(bp+16, (*Table)(unsafe.Pointer(pTab)).FzName)) } @@ -117897,7 +115667,7 @@ __1: // Locate the index named by the INDEXED BY clause, if any. if Xsqlite3IndexedByLookup(tls, pParse, pFrom) != 0 { - return 2 + return WRC_Abort } } @@ -117912,7 +115682,7 @@ __3: // Process NATURAL keywords, and ON and USING clauses of joins. if (((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0)) || (sqliteProcessJoin(tls, pParse, p) != 0) { - return 2 + return WRC_Abort } // For every "*" that occurs in the column list, insert the names of @@ -117927,11 +115697,11 @@ __3: // that need expanding. for k = 0; k < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; k++ { pE = (*ExprList_item)(unsafe.Pointer((pEList + 8 /* &.a */) + uintptr(k)*32)).FpExpr - if int32((*Expr)(unsafe.Pointer(pE)).Fop) == 177 { + if int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_ASTERISK { break } - if (int32((*Expr)(unsafe.Pointer(pE)).Fop) == 139) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pE)).FpRight)).Fop) == 177) { + if (int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_DOT) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pE)).FpRight)).Fop) == TK_ASTERISK) { break } elistFlags = elistFlags | ((*Expr)(unsafe.Pointer(pE)).Fflags) @@ -117943,16 +115713,16 @@ __3: var a uintptr = pEList + 8 /* &.a */ var pNew uintptr = uintptr(0) var flags int32 = int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags) - var longNames int32 = (libc.Bool32(((flags & 0x00000004) != 0) && - ((flags & 0x00000040) == 0))) + var longNames int32 = (libc.Bool32(((flags & SQLITE_FullColNames) != 0) && + ((flags & SQLITE_ShortColNames) == 0))) for k = 0; k < (*ExprList)(unsafe.Pointer(pEList)).FnExpr; k++ { pE = (*ExprList_item)(unsafe.Pointer(a + uintptr(k)*32)).FpExpr elistFlags = elistFlags | ((*Expr)(unsafe.Pointer(pE)).Fflags) pRight = (*Expr)(unsafe.Pointer(pE)).FpRight - if (int32((*Expr)(unsafe.Pointer(pE)).Fop) != 177) && - ((int32((*Expr)(unsafe.Pointer(pE)).Fop) != 139) || (int32((*Expr)(unsafe.Pointer(pRight)).Fop) != 177)) { + if (int32((*Expr)(unsafe.Pointer(pE)).Fop) != TK_ASTERISK) && + ((int32((*Expr)(unsafe.Pointer(pE)).Fop) != TK_DOT) || (int32((*Expr)(unsafe.Pointer(pRight)).Fop) != TK_ASTERISK)) { // This particular expression does not need to be expanded. pNew = Xsqlite3ExprListAppend(tls, pParse, pNew, (*ExprList_item)(unsafe.Pointer(a+uintptr(k)*32)).FpExpr) if pNew != 0 { @@ -117966,7 +115736,7 @@ __3: // expanded. var tableSeen int32 = 0 // Set to 1 when TABLE matches var zTName uintptr = uintptr(0) // text of name of TABLE - if int32((*Expr)(unsafe.Pointer(pE)).Fop) == 139 { + if int32((*Expr)(unsafe.Pointer(pE)).Fop) == TK_DOT { zTName = *(*uintptr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pE)).FpLeft + 8 /* &.u */)) } @@ -117988,7 +115758,7 @@ __3: if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { goto __6 } - if (pSub == uintptr(0)) || (((*Select)(unsafe.Pointer(pSub)).FselFlags & U32(0x0000800)) == U32(0)) { + if (pSub == uintptr(0)) || (((*Select)(unsafe.Pointer(pSub)).FselFlags & SF_NestedFrom) == U32(0)) { pSub = uintptr(0) if (zTName != 0) && (Xsqlite3StrICmp(tls, zTName, zTabName) != 0) { goto __5 @@ -118015,14 +115785,14 @@ __3: // If a column is marked as 'hidden', omit it from the expanded // result-set list unless the SELECT has the SF_IncludeHidden // bit set. - if (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0020000)) == U32(0)) && - ((int32((*Column)(unsafe.Pointer(((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*32))).FcolFlags) & 0x0002) != 0) { + if (((*Select)(unsafe.Pointer(p)).FselFlags & SF_IncludeHidden) == U32(0)) && + ((int32((*Column)(unsafe.Pointer(((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*32))).FcolFlags) & COLFLAG_HIDDEN) != 0) { continue } tableSeen = 1 if (i > 0) && (zTName == uintptr(0)) { - if ((int32((*SrcList_item)(unsafe.Pointer(pFrom)).Ffg.Fjointype) & 0x0004) != 0) && + if ((int32((*SrcList_item)(unsafe.Pointer(pFrom)).Ffg.Fjointype) & JT_NATURAL) != 0) && (tableAndColumnIndex(tls, pTabList, i, zName, uintptr(0), uintptr(0), 1) != 0) { // In a NATURAL join, omit the join columns from the // table to the right of the join @@ -118034,16 +115804,16 @@ __3: continue } } - pRight = Xsqlite3Expr(tls, db, 59, zName) + pRight = Xsqlite3Expr(tls, db, TK_ID, zName) zColname = zName zToFree = uintptr(0) if (longNames != 0) || ((*SrcList)(unsafe.Pointer(pTabList)).FnSrc > 1) { var pLeft uintptr - pLeft = Xsqlite3Expr(tls, db, 59, zTabName) - pExpr = Xsqlite3PExpr(tls, pParse, 139, pLeft, pRight) + pLeft = Xsqlite3Expr(tls, db, TK_ID, zTabName) + pExpr = Xsqlite3PExpr(tls, pParse, TK_DOT, pLeft, pRight) if zSchemaName != 0 { - pLeft = Xsqlite3Expr(tls, db, 59, zSchemaName) - pExpr = Xsqlite3PExpr(tls, pParse, 139, pLeft, pExpr) + pLeft = Xsqlite3Expr(tls, db, TK_ID, zSchemaName) + pExpr = Xsqlite3PExpr(tls, pParse, TK_DOT, pLeft, pExpr) } if longNames != 0 { zColname = Xsqlite3MPrintf(tls, db, ts+9997 /* "%s.%s" */, libc.VaList(bp+24, zTabName, zName)) @@ -118055,7 +115825,7 @@ __3: pNew = Xsqlite3ExprListAppend(tls, pParse, pNew, pExpr) Xsqlite3TokenInit(tls, bp+72 /* &sColname */, zColname) Xsqlite3ExprListSetName(tls, pParse, pNew, bp+72 /* &sColname */, 0) - if ((pNew != 0) && (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000800)) != U32(0))) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if ((pNew != 0) && (((*Select)(unsafe.Pointer(p)).FselFlags & SF_NestedFrom) != U32(0))) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { var pX uintptr = ((pNew + 8 /* &.a */) + uintptr(((*ExprList)(unsafe.Pointer(pNew)).FnExpr-1))*32) Xsqlite3DbFree(tls, db, (*ExprList_item)(unsafe.Pointer(pX)).FzEName) if pSub != 0 { @@ -118066,7 +115836,7 @@ __3: libc.VaList(bp+40, zSchemaName, zTabName, zColname)) } - libc.SetBitFieldPtr8Uint32(pX+20 /* &.eEName */, uint32(2), 0, 0x3) + libc.SetBitFieldPtr8Uint32(pX+20 /* &.eEName */, ENAME_TAB, 0, 0x3) } Xsqlite3DbFree(tls, db, zToFree) } @@ -118093,15 +115863,15 @@ __3: (*Select)(unsafe.Pointer(p)).FpEList = pNew } if (*Select)(unsafe.Pointer(p)).FpEList != 0 { - if (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(2)*4)) { + if (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpEList)).FnExpr > *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 2*4)) { Xsqlite3ErrorMsg(tls, pParse, ts+20740 /* "too many columns..." */, 0) - return 2 + return WRC_Abort } - if (elistFlags & (U32(0x000004 | 0x200000))) != U32(0) { - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0040000)) + if (elistFlags & (U32(EP_HasFunc | EP_Subquery))) != U32(0) { + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_ComplexResult) } } - return 0 + return WRC_Continue } // This routine "expands" a SELECT statement and all of its subqueries. @@ -118159,10 +115929,10 @@ func selectAddSubqueryTypeInfo(tls *libc.TLS, pWalker uintptr, p uintptr) { /* s var pTabList uintptr var pFrom uintptr - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000080)) != 0 { + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_HasTypeInfo) != 0 { return } - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0000080)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_HasTypeInfo) pParse = (*Walker)(unsafe.Pointer(pWalker)).FpParse pTabList = (*Select)(unsafe.Pointer(p)).FpSrc i = 0 @@ -118174,7 +115944,7 @@ __1: { var pTab uintptr = (*SrcList_item)(unsafe.Pointer(pFrom)).FpTab - if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0002)) != U32(0) { + if ((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Ephemeral) != U32(0) { // A sub-query in the FROM clause of a SELECT var pSel uintptr = (*SrcList_item)(unsafe.Pointer(pFrom)).FpSelect if pSel != 0 { @@ -118182,7 +115952,7 @@ __1: pSel = (*Select)(unsafe.Pointer(pSel)).FpPrior } Xsqlite3SelectAddColumnTypeAndCollation(tls, pParse, pTab, pSel, - int8(0x40)) + SQLITE_AFF_NONE) } } @@ -118235,7 +116005,7 @@ func Xsqlite3SelectPrep(tls *libc.TLS, pParse uintptr, p uintptr, pOuterNC uintp if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { return } - if ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000080)) != 0 { + if ((*Select)(unsafe.Pointer(p)).FselFlags & SF_HasTypeInfo) != 0 { return } sqlite3SelectExpand(tls, pParse, p) @@ -118266,7 +116036,7 @@ func resetAccumulator(tls *libc.TLS, pParse uintptr, pAggInfo uintptr) { /* sqli if ((*Parse)(unsafe.Pointer(pParse)).FnErr != 0) || ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0) { return } - Xsqlite3VdbeAddOp3(tls, v, 72, 0, (*AggInfo)(unsafe.Pointer(pAggInfo)).FmnReg, (*AggInfo)(unsafe.Pointer(pAggInfo)).FmxReg) + Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, (*AggInfo)(unsafe.Pointer(pAggInfo)).FmnReg, (*AggInfo)(unsafe.Pointer(pAggInfo)).FmxReg) pFunc = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc i = 0 __1: @@ -118283,7 +116053,7 @@ __1: (*AggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct = -1 } else { var pKeyInfo uintptr = Xsqlite3KeyInfoFromExprList(tls, pParse, *(*uintptr)(unsafe.Pointer(pE + 32 /* &.x */)), 0, 0) - Xsqlite3VdbeAddOp4(tls, v, 100, (*AggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct, 0, 0, + Xsqlite3VdbeAddOp4(tls, v, OP_OpenEphemeral, (*AggInfo_func)(unsafe.Pointer(pFunc)).FiDistinct, 0, 0, pKeyInfo, -9) } } @@ -118313,7 +116083,7 @@ __1: { var pList uintptr = *(*uintptr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr + 32 /* &.x */)) - Xsqlite3VdbeAddOp2(tls, v, 157, (*AggInfo_func)(unsafe.Pointer(pF)).FiMem, func() int32 { + Xsqlite3VdbeAddOp2(tls, v, OP_AggFinal, (*AggInfo_func)(unsafe.Pointer(pF)).FiMem, func() int32 { if pList != 0 { return (*ExprList)(unsafe.Pointer(pList)).FnExpr } @@ -118359,10 +116129,10 @@ __1: var regAgg int32 var pList uintptr = *(*uintptr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr + 32 /* &.x */)) - if ((*Expr)(unsafe.Pointer(((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr))).Fflags & (U32(0x1000000))) != U32(0) { + if ((*Expr)(unsafe.Pointer(((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr))).Fflags & (EP_WinFunc)) != U32(0) { var pFilter uintptr = (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFExpr + 64 /* &.y */)))).FpFilter if (((*AggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0) && - (((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFunc)).FfuncFlags & U32(0x0020)) != 0)) && + (((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFunc)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != 0)) && (regAcc != 0) { // If regAcc==0, there there exists some min() or max() function // without a FILTER clause that will ensure the magnet registers @@ -118377,15 +116147,15 @@ __1: // the first row (regAcc contains 1), set the magnet register so that // the accumulators are not populated unless the min()/max() is invoked // and indicates that they should be. - Xsqlite3VdbeAddOp2(tls, v, 77, regAcc, regHit) + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, regAcc, regHit) } addrNext = Xsqlite3VdbeMakeLabel(tls, pParse) - Xsqlite3ExprIfFalse(tls, pParse, pFilter, addrNext, 0x10) + Xsqlite3ExprIfFalse(tls, pParse, pFilter, addrNext, SQLITE_JUMPIFNULL) } if pList != 0 { nArg = (*ExprList)(unsafe.Pointer(pList)).FnExpr regAgg = Xsqlite3GetTempRange(tls, pParse, nArg) - Xsqlite3ExprCodeExprList(tls, pParse, pList, regAgg, 0, uint8(0x01)) + Xsqlite3ExprCodeExprList(tls, pParse, pList, regAgg, 0, SQLITE_ECEL_DUP) } else { nArg = 0 regAgg = 0 @@ -118398,7 +116168,7 @@ __1: // Also an error codeDistinct(tls, pParse, (*AggInfo_func)(unsafe.Pointer(pF)).FiDistinct, addrNext, 1, regAgg) } - if ((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFunc)).FfuncFlags & U32(0x0020)) != 0 { + if ((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer(pF)).FpFunc)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != 0 { var pColl uintptr = uintptr(0) var pItem uintptr var j int32 @@ -118427,9 +116197,9 @@ __1: if (regHit == 0) && ((*AggInfo)(unsafe.Pointer(pAggInfo)).FnAccumulator != 0) { regHit = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) } - Xsqlite3VdbeAddOp4(tls, v, 81, regHit, 0, 0, pColl, -2) + Xsqlite3VdbeAddOp4(tls, v, OP_CollSeq, regHit, 0, 0, pColl, -2) } - Xsqlite3VdbeAddOp3(tls, v, 154, 0, regAgg, (*AggInfo_func)(unsafe.Pointer(pF)).FiMem) + Xsqlite3VdbeAddOp3(tls, v, OP_AggStep, 0, regAgg, (*AggInfo_func)(unsafe.Pointer(pF)).FiMem) Xsqlite3VdbeAppendP4(tls, v, (*AggInfo_func)(unsafe.Pointer(pF)).FpFunc, -8) Xsqlite3VdbeChangeP5(tls, v, uint16(U8(nArg))) Xsqlite3ReleaseTempRange(tls, pParse, regAgg, nArg) @@ -118450,7 +116220,7 @@ __3: regHit = regAcc } if regHit != 0 { - addrHitTest = Xsqlite3VdbeAddOp1(tls, v, 18, regHit) + addrHitTest = Xsqlite3VdbeAddOp1(tls, v, OP_If, regHit) } i = 0 pC = (*AggInfo)(unsafe.Pointer(pAggInfo)).FaCol @@ -118484,7 +116254,7 @@ func explainSimpleCount(tls *libc.TLS, pParse uintptr, pTab uintptr, pIdx uintpt defer tls.Free(24) if int32((*Parse)(unsafe.Pointer(pParse)).Fexplain) == 2 { - var bCover int32 = (libc.Bool32((pIdx != uintptr(0)) && ((((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) || !((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2)))) + var bCover int32 = (libc.Bool32((pIdx != uintptr(0)) && ((((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) || !((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY)))) Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+20822, /* "SCAN TABLE %s%s%..." */ libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName, func() uintptr { @@ -118512,11 +116282,11 @@ func explainSimpleCount(tls *libc.TLS, pParse uintptr, pTab uintptr, pIdx uintpt // clause. If so, add it to the WHERE clause and replace the sub-expression // within the HAVING expression with a constant "1". func havingToWhereExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:134884:12: */ - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 44 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_AND { var pS uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) if Xsqlite3ExprIsConstantOrGroupBy(tls, (*Walker)(unsafe.Pointer(pWalker)).FpParse, pExpr, (*Select)(unsafe.Pointer(pS)).FpGroupBy) != 0 { var db uintptr = (*Parse)(unsafe.Pointer((*Walker)(unsafe.Pointer(pWalker)).FpParse)).Fdb - var pNew uintptr = Xsqlite3Expr(tls, db, 152, ts+9901 /* "1" */) + var pNew uintptr = Xsqlite3Expr(tls, db, TK_INTEGER, ts+9901 /* "1" */) if pNew != 0 { var pWhere uintptr = (*Select)(unsafe.Pointer(pS)).FpWhere { @@ -118530,9 +116300,9 @@ func havingToWhereExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(1) } } - return 1 + return WRC_Prune } - return 0 + return WRC_Continue } // Transfer eligible terms from the HAVING clause of a query, which is @@ -118741,14 +116511,14 @@ func Xsqlite3Select(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) int return 1 __1: ; - if !(Xsqlite3AuthCheck(tls, pParse, 21, uintptr(0), uintptr(0), uintptr(0)) != 0) { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_SELECT, uintptr(0), uintptr(0), uintptr(0)) != 0) { goto __2 } return 1 __2: ; - if !((int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest)) <= 8) { + if !((int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest)) <= SRT_DistQueue) { goto __3 } @@ -118756,8 +116526,8 @@ __2: // DISTINCT so it can be removed too. Xsqlite3ExprListDelete(tls, db, (*Select)(unsafe.Pointer(p)).FpOrderBy) (*Select)(unsafe.Pointer(p)).FpOrderBy = uintptr(0) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000001)) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0400000)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_Distinct))) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_NoopOrderBy) __3: ; Xsqlite3SelectPrep(tls, pParse, p, uintptr(0)) @@ -118772,10 +116542,10 @@ __4: // as part of populating the temp table for an UPDATE...FROM statement. // In this case, it is an error if the target object (pSrc->a[0]) name // or alias is duplicated within FROM clause (pSrc->a[1..n]). - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0800000)) != 0) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_UpdateFrom) != 0) { goto __5 } - p0 = (((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112) + p0 = ((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) i = 1 __6: if !(i < (*SrcList)(unsafe.Pointer((*Select)(unsafe.Pointer(p)).FpSrc)).FnSrc) { @@ -118806,7 +116576,7 @@ __8: __5: ; - if !(int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) == 9) { + if !(int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) == SRT_Output) { goto __10 } generateColumnNames(tls, pParse, p) @@ -118822,7 +116592,7 @@ __10: __11: ; pTabList = (*Select)(unsafe.Pointer(p)).FpSrc - isAgg = (libc.Bool32(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000008)) != U32(0))) + isAgg = (libc.Bool32(((*Select)(unsafe.Pointer(p)).FselFlags & SF_Aggregate) != U32(0))) libc.Xmemset(tls, bp+80 /* &sSort */, 0, uint64(unsafe.Sizeof(SortCtx{}))) (*SortCtx)(unsafe.Pointer(bp + 80 /* &sSort */)).FpOrderBy = (*Select)(unsafe.Pointer(p)).FpOrderBy @@ -118843,13 +116613,13 @@ __12: // Convert LEFT JOIN into JOIN if there are terms of the right table // of the LEFT JOIN used in the WHERE clause. - if !((((int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & 0x0008) != 0) && + if !((((int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & JT_LEFT) != 0) && (Xsqlite3ExprImpliesNonNullRow(tls, (*Select)(unsafe.Pointer(p)).FpWhere, (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor) != 0)) && - ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x2000)) == 0)) { + ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_SimplifyJoin)) == 0)) { goto __15 } - *(*U8)(unsafe.Pointer(pItem + 60 /* &.fg */ /* &.jointype */)) &= libc.Uint8FromInt32((^libc.Int32((0x0008 | 0x0020)))) + *(*U8)(unsafe.Pointer(pItem + 60 /* &.fg */ /* &.jointype */)) &= libc.Uint8FromInt32((libc.CplInt32((JT_LEFT | JT_OUTER)))) unsetJoinExpr(tls, (*Select)(unsafe.Pointer(p)).FpWhere, (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor) __15: ; @@ -118879,7 +116649,7 @@ __17: // is not a join. But if the outer query is not a join, then the subquery // will be implemented as a co-routine and there is no advantage to // flattening in that case. - if !(((*Select)(unsafe.Pointer(pSub)).FselFlags & U32(0x0000008)) != U32(0)) { + if !(((*Select)(unsafe.Pointer(pSub)).FselFlags & SF_Aggregate) != U32(0)) { goto __18 } goto __13 @@ -118905,9 +116675,9 @@ __18: // SELECT x FROM (SELECT x FROM tab ORDER BY y LIMIT 10); if !(((((*Select)(unsafe.Pointer(pSub)).FpOrderBy != uintptr(0)) && (i == 0)) && - (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0040000)) != U32(0))) && + (((*Select)(unsafe.Pointer(p)).FselFlags & SF_ComplexResult) != U32(0))) && (((*SrcList)(unsafe.Pointer(pTabList)).FnSrc == 1) || - ((int32((*SrcList_item)(unsafe.Pointer((pTabList+8 /* &.a */)+uintptr(1)*112)).Ffg.Fjointype) & (0x0008 | 0x0002)) != 0))) { + ((int32((*SrcList_item)(unsafe.Pointer((pTabList+8 /* &.a */)+1*112)).Ffg.Fjointype) & (JT_LEFT | JT_CROSS)) != 0))) { goto __19 } goto __13 @@ -118934,7 +116704,7 @@ __20: goto select_end __22: ; - if !(!((int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest)) <= 8)) { + if !(!((int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest)) <= SRT_DistQueue)) { goto __23 } (*SortCtx)(unsafe.Pointer(bp + 80 /* &sSort */)).FpOrderBy = (*Select)(unsafe.Pointer(p)).FpOrderBy @@ -118969,7 +116739,7 @@ __24: // as the equivalent optimization will be handled by query planner in // sqlite3WhereBegin(). if !((((*SrcList)(unsafe.Pointer(pTabList)).FnSrc > 1) && - ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x8000)) == 0)) && + ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_PropagateConst)) == 0)) && (propagateConstants(tls, pParse, p) != 0)) { goto __26 } @@ -119007,7 +116777,7 @@ __28: if !(((*SrcList_item)(unsafe.Pointer(pItem1)).FcolUsed == uint64(0)) && ((*SrcList_item)(unsafe.Pointer(pItem1)).FzName != uintptr(0))) { goto __31 } - Xsqlite3AuthCheck(tls, pParse, 20, (*SrcList_item)(unsafe.Pointer(pItem1)).FzName, ts+800 /* "" */, (*SrcList_item)(unsafe.Pointer(pItem1)).FzDatabase) + Xsqlite3AuthCheck(tls, pParse, SQLITE_READ, (*SrcList_item)(unsafe.Pointer(pItem1)).FzName, ts+800 /* "" */, (*SrcList_item)(unsafe.Pointer(pItem1)).FzDatabase) __31: ; @@ -119042,9 +116812,9 @@ __32: // Make copies of constant WHERE-clause terms in the outer query down // inside the subquery. This can help the subquery to run more efficiently. - if !(((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x1000)) == 0) && + if !(((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_PushDown)) == 0) && (pushDownWhereTerms(tls, pParse, pSub1, (*Select)(unsafe.Pointer(p)).FpWhere, (*SrcList_item)(unsafe.Pointer(pItem1)).FiCursor, - (libc.Bool32((int32((*SrcList_item)(unsafe.Pointer(pItem1)).Ffg.Fjointype)&0x0020) != 0))) != 0)) { + (libc.Bool32((int32((*SrcList_item)(unsafe.Pointer(pItem1)).Ffg.Fjointype)&JT_OUTER) != 0))) != 0)) { goto __33 } goto __34 @@ -119066,7 +116836,7 @@ __34: // implementation? if !((i == 0) && (((*SrcList)(unsafe.Pointer(pTabList)).FnSrc == 1) || - ((int32((*SrcList_item)(unsafe.Pointer((pTabList+8 /* &.a */)+uintptr(1)*112)).Ffg.Fjointype) & (0x0008 | 0x0002)) != 0))) { + ((int32((*SrcList_item)(unsafe.Pointer((pTabList+8 /* &.a */)+1*112)).Ffg.Fjointype) & (JT_LEFT | JT_CROSS)) != 0))) { goto __35 } // Implement a co-routine that will return a single row of the result @@ -119074,10 +116844,10 @@ __34: addrTop = (Xsqlite3VdbeCurrentAddr(tls, v) + 1) (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp3(tls, v, 13, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn, 0, addrTop) + Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn, 0, addrTop) Xsqlite3VdbeComment(tls, v, ts+824 /* "%s" */, libc.VaList(bp+32, (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem1)).FpTab)).FzName)) (*SrcList_item)(unsafe.Pointer(pItem1)).FaddrFillSub = addrTop - Xsqlite3SelectDestInit(tls, bp+128 /* &dest */, 13, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn) + Xsqlite3SelectDestInit(tls, bp+128 /* &dest */, SRT_Coroutine, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn) Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+20957 /* "CO-ROUTINE %u" */, libc.VaList(bp+40, (*Select)(unsafe.Pointer(pSub1)).FselId)) Xsqlite3Select(tls, pParse, pSub1, bp+128 /* &dest */) (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem1)).FpTab)).FnRowLogEst = (*Select)(unsafe.Pointer(pSub1)).FnSelectRow @@ -119092,7 +116862,7 @@ __35: // Ticket c52b09c7f38903b1311 (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - topAddr = Xsqlite3VdbeAddOp2(tls, v, 69, 0, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn) + topAddr = Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn) (*SrcList_item)(unsafe.Pointer(pItem1)).FaddrFillSub = (topAddr + 1) if !((int32(*(*uint8)(unsafe.Pointer((pItem1 + 60 /* &.fg */) + 4 /* &.isCorrelated */)) & 0x8 >> 3)) == 0) { goto __37 @@ -119100,7 +116870,7 @@ __35: // If the subquery is not correlated and if we are not inside of // a trigger, then we only need to compute the value of the subquery // once. - onceAddr = Xsqlite3VdbeAddOp0(tls, v, 17) + onceAddr = Xsqlite3VdbeAddOp0(tls, v, OP_Once) Xsqlite3VdbeComment(tls, v, ts+20971 /* "materialize \"%s\"" */, libc.VaList(bp+48, (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem1)).FpTab)).FzName)) goto __38 __37: @@ -119111,12 +116881,12 @@ __38: if !(pPrior != 0) { goto __39 } - Xsqlite3VdbeAddOp2(tls, v, 98, (*SrcList_item)(unsafe.Pointer(pItem1)).FiCursor, (*SrcList_item)(unsafe.Pointer(pPrior)).FiCursor) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*SrcList_item)(unsafe.Pointer(pItem1)).FiCursor, (*SrcList_item)(unsafe.Pointer(pPrior)).FiCursor) (*Select)(unsafe.Pointer(pSub1)).FnSelectRow = (*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pPrior)).FpSelect)).FnSelectRow goto __40 __39: - Xsqlite3SelectDestInit(tls, bp+128 /* &dest */, 12, (*SrcList_item)(unsafe.Pointer(pItem1)).FiCursor) + Xsqlite3SelectDestInit(tls, bp+128 /* &dest */, SRT_EphemTab, (*SrcList_item)(unsafe.Pointer(pItem1)).FiCursor) Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+20988 /* "MATERIALIZE %u" */, libc.VaList(bp+64, (*Select)(unsafe.Pointer(pSub1)).FselId)) Xsqlite3Select(tls, pParse, pSub1, bp+128 /* &dest */) __40: @@ -119128,7 +116898,7 @@ __40: Xsqlite3VdbeJumpHere(tls, v, onceAddr) __41: ; - retAddr = Xsqlite3VdbeAddOp1(tls, v, 65, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn) + retAddr = Xsqlite3VdbeAddOp1(tls, v, OP_Return, (*SrcList_item)(unsafe.Pointer(pItem1)).FregReturn) Xsqlite3VdbeComment(tls, v, ts+21003 /* "end %s" */, libc.VaList(bp+72, (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem1)).FpTab)).FzName)) Xsqlite3VdbeChangeP1(tls, v, topAddr, retAddr) Xsqlite3ClearTempRegCache(tls, pParse) @@ -119156,7 +116926,7 @@ __30: pWhere = (*Select)(unsafe.Pointer(p)).FpWhere pGroupBy = (*Select)(unsafe.Pointer(p)).FpGroupBy pHaving = (*Select)(unsafe.Pointer(p)).FpHaving - (*DistinctCtx)(unsafe.Pointer(bp + 168 /* &sDistinct */)).FisTnct = (U8(libc.Bool32(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000001)) != U32(0)))) + (*DistinctCtx)(unsafe.Pointer(bp + 168 /* &sDistinct */)).FisTnct = (U8(libc.Bool32(((*Select)(unsafe.Pointer(p)).FselFlags & SF_Distinct) != U32(0)))) // If the query is DISTINCT with an ORDER BY but is not an aggregate, and // if the select-list is the same as the ORDER BY list, then this query @@ -119172,14 +116942,14 @@ __30: // used for both the ORDER BY and DISTINCT processing. As originally // written the query must use a temp-table for at least one of the ORDER // BY and DISTINCT, and an index or separate temp-table for the other. - if !(((((*Select)(unsafe.Pointer(p)).FselFlags & (U32(0x0000001 | 0x0000008))) == U32(0x0000001)) && + if !(((((*Select)(unsafe.Pointer(p)).FselFlags & (U32(SF_Distinct | SF_Aggregate))) == SF_Distinct) && (Xsqlite3ExprListCompare(tls, (*SortCtx)(unsafe.Pointer(bp+80 /* &sSort */)).FpOrderBy, pEList, -1) == 0)) && ((*Select)(unsafe.Pointer(p)).FpWin == uintptr(0))) { goto __43 } - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000001)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_Distinct))) pGroupBy = libc.AssignPtrUintptr(p+56 /* &.pGroupBy */, Xsqlite3ExprListDup(tls, db, pEList, 0)) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0000008)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_Aggregate) // Notice that even thought SF_Distinct has been cleared from p->selFlags, // the sDistinct.isTnct is still set. Hence, isTnct represents the // original setting of the SF_Distinct flag, not the current setting @@ -119200,7 +116970,7 @@ __43: pKeyInfo = Xsqlite3KeyInfoFromExprList(tls, pParse, (*SortCtx)(unsafe.Pointer(bp+80 /* &sSort */)).FpOrderBy, 0, (*ExprList)(unsafe.Pointer(pEList)).FnExpr) (*SortCtx)(unsafe.Pointer(bp + 80 /* &sSort */)).FiECursor = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - (*SortCtx)(unsafe.Pointer(bp + 80 /* &sSort */)).FaddrSortIndex = Xsqlite3VdbeAddOp4(tls, v, 100, + (*SortCtx)(unsafe.Pointer(bp + 80 /* &sSort */)).FaddrSortIndex = Xsqlite3VdbeAddOp4(tls, v, OP_OpenEphemeral, (*SortCtx)(unsafe.Pointer(bp+80 /* &sSort */)).FiECursor, (((*ExprList)(unsafe.Pointer((*SortCtx)(unsafe.Pointer(bp+80 /* &sSort */)).FpOrderBy)).FnExpr + 1) + (*ExprList)(unsafe.Pointer(pEList)).FnExpr), 0, pKeyInfo, -9) goto __45 @@ -119210,16 +116980,16 @@ __45: ; // If the output is destined for a temporary table, open that table. - if !(int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) == 12) { + if !(int32((*SelectDest)(unsafe.Pointer(pDest)).FeDest) == SRT_EphemTab) { goto __46 } - Xsqlite3VdbeAddOp2(tls, v, 100, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, (*ExprList)(unsafe.Pointer(pEList)).FnExpr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*SelectDest)(unsafe.Pointer(pDest)).FiSDParm, (*ExprList)(unsafe.Pointer(pEList)).FnExpr) __46: ; // Set the limiter. iEnd = Xsqlite3VdbeMakeLabel(tls, pParse) - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0004000)) == U32(0)) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_FixedLimit) == U32(0)) { goto __47 } (*Select)(unsafe.Pointer(p)).FnSelectRow = int16(320) // 4 billion rows @@ -119229,25 +116999,25 @@ __47: if !(((*Select)(unsafe.Pointer(p)).FiLimit == 0) && ((*SortCtx)(unsafe.Pointer(bp+80 /* &sSort */)).FaddrSortIndex >= 0)) { goto __48 } - Xsqlite3VdbeChangeOpcode(tls, v, (*SortCtx)(unsafe.Pointer(bp+80 /* &sSort */)).FaddrSortIndex, uint8(111)) - *(*U8)(unsafe.Pointer(bp + 80 /* &sSort */ + 36 /* &.sortFlags */)) |= U8((0x01)) + Xsqlite3VdbeChangeOpcode(tls, v, (*SortCtx)(unsafe.Pointer(bp+80 /* &sSort */)).FaddrSortIndex, OP_SorterOpen) + *(*U8)(unsafe.Pointer(bp + 80 /* &sSort */ + 36 /* &.sortFlags */)) |= U8((SORTFLAG_UseSorter)) __48: ; // Open an ephemeral index to use for the distinct set. - if !(((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000001)) != 0) { + if !(((*Select)(unsafe.Pointer(p)).FselFlags & SF_Distinct) != 0) { goto __49 } (*DistinctCtx)(unsafe.Pointer(bp + 168 /* &sDistinct */)).FtabTnct = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - (*DistinctCtx)(unsafe.Pointer(bp + 168 /* &sDistinct */)).FaddrTnct = Xsqlite3VdbeAddOp4(tls, v, 100, + (*DistinctCtx)(unsafe.Pointer(bp + 168 /* &sDistinct */)).FaddrTnct = Xsqlite3VdbeAddOp4(tls, v, OP_OpenEphemeral, (*DistinctCtx)(unsafe.Pointer(bp+168 /* &sDistinct */)).FtabTnct, 0, 0, Xsqlite3KeyInfoFromExprList(tls, pParse, (*Select)(unsafe.Pointer(p)).FpEList, 0, 0), -9) - Xsqlite3VdbeChangeP5(tls, v, uint16(8)) - (*DistinctCtx)(unsafe.Pointer(bp + 168 /* &sDistinct */)).FeTnctType = U8(3) + Xsqlite3VdbeChangeP5(tls, v, BTREE_UNORDERED) + (*DistinctCtx)(unsafe.Pointer(bp + 168 /* &sDistinct */)).FeTnctType = WHERE_DISTINCT_UNORDERED goto __50 __49: - (*DistinctCtx)(unsafe.Pointer(bp + 168 /* &sDistinct */)).FeTnctType = U8(0) + (*DistinctCtx)(unsafe.Pointer(bp + 168 /* &sDistinct */)).FeTnctType = WHERE_DISTINCT_NOOP __50: ; @@ -119257,11 +117027,11 @@ __50: // No aggregate functions and no GROUP BY clause wctrlFlags = (U16((func() uint32 { if (*DistinctCtx)(unsafe.Pointer(bp+168 /* &sDistinct */)).FisTnct != 0 { - return uint32(0x0100) + return WHERE_WANT_DISTINCT } return uint32(0) }()) | - ((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0004000)))) + ((*Select)(unsafe.Pointer(p)).FselFlags & SF_FixedLimit))) pWin = (*Select)(unsafe.Pointer(p)).FpWin // Main window object (or NULL) if !(pWin != 0) { goto __53 @@ -119326,13 +117096,13 @@ __59: Xsqlite3WindowCodeStep(tls, pParse, p, pWInfo, regGosub, addrGosub) - Xsqlite3VdbeAddOp2(tls, v, 11, 0, iBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, iBreak) Xsqlite3VdbeResolveLabel(tls, v, addrGosub) Xsqlite3VdbeNoopComment(tls, v, ts+21010 /* "inner-loop subro..." */, 0) (*SortCtx)(unsafe.Pointer(bp + 80 /* &sSort */)).FlabelOBLopt = 0 selectInnerLoop(tls, pParse, p, -1, bp+80 /* &sSort */, bp+168 /* &sDistinct */, pDest, iCont, iBreak) Xsqlite3VdbeResolveLabel(tls, v, iCont) - Xsqlite3VdbeAddOp1(tls, v, 65, regGosub) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regGosub) Xsqlite3VdbeComment(tls, v, ts+21032 /* "end inner-loop s..." */, 0) Xsqlite3VdbeResolveLabel(tls, v, iBreak) goto __61 @@ -119418,7 +117188,7 @@ __72: if !(ii < (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) { goto __74 } - sortFlags = (U8(int32((*ExprList_item)(unsafe.Pointer(((*SortCtx)(unsafe.Pointer(bp+80 /* &sSort */)).FpOrderBy+8 /* &.a */)+uintptr(ii)*32)).FsortFlags) & 0x01)) + sortFlags = (U8(int32((*ExprList_item)(unsafe.Pointer(((*SortCtx)(unsafe.Pointer(bp+80 /* &sSort */)).FpOrderBy+8 /* &.a */)+uintptr(ii)*32)).FsortFlags) & KEYINFO_ORDER_DESC)) (*ExprList_item)(unsafe.Pointer((pGroupBy + 8 /* &.a */) + uintptr(ii)*32)).FsortFlags = sortFlags goto __73 __73: @@ -119491,10 +117261,10 @@ __77: if !((((*Select)(unsafe.Pointer(p)).FpGroupBy == uintptr(0)) && ((*Select)(unsafe.Pointer(p)).FpHaving == uintptr(0))) && ((*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc == 1)) { goto __79 } - minMaxFlag = minMaxQuery(tls, db, (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(0)*24)).FpFExpr, bp+240 /* &pMinMaxOrderBy */) + minMaxFlag = minMaxQuery(tls, db, (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FpFExpr, bp+240 /* &pMinMaxOrderBy */) goto __80 __79: - minMaxFlag = U8(0x0000) + minMaxFlag = WHERE_ORDERBY_NORMAL __80: ; i = 0 @@ -119504,16 +117274,16 @@ __81: } pExpr = (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*24)).FpFExpr - *(*int32)(unsafe.Pointer(bp + 184 /* &sNC */ + 40 /* &.ncFlags */)) |= (0x20000) + *(*int32)(unsafe.Pointer(bp + 184 /* &sNC */ + 40 /* &.ncFlags */)) |= (NC_InAggFunc) Xsqlite3ExprAnalyzeAggList(tls, bp+184 /* &sNC */, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) { goto __84 } Xsqlite3ExprAnalyzeAggregates(tls, bp+184 /* &sNC */, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)))).FpFilter) __84: ; - *(*int32)(unsafe.Pointer(bp + 184 /* &sNC */ + 40 /* &.ncFlags */)) &= (^libc.Int32(0x20000)) + *(*int32)(unsafe.Pointer(bp + 184 /* &sNC */ + 40 /* &.ncFlags */)) &= (libc.CplInt32(NC_InAggFunc)) goto __82 __82: i++ @@ -119542,7 +117312,7 @@ __85: (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) pKeyInfo1 = Xsqlite3KeyInfoFromExprList(tls, pParse, pGroupBy, 0, (*AggInfo)(unsafe.Pointer(pAggInfo)).FnColumn) - addrSortingIdx = Xsqlite3VdbeAddOp4(tls, v, 111, + addrSortingIdx = Xsqlite3VdbeAddOp4(tls, v, OP_SorterOpen, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, (*AggInfo)(unsafe.Pointer(pAggInfo)).FnSortingColumn, 0, pKeyInfo1, -9) @@ -119557,20 +117327,20 @@ __85: *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += ((*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) iBMem = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += ((*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, iAbortFlag) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, iAbortFlag) Xsqlite3VdbeComment(tls, v, ts+21058 /* "clear abort flag" */, 0) - Xsqlite3VdbeAddOp3(tls, v, 72, 0, iAMem, ((iAMem + (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, iAMem, ((iAMem + (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) - 1)) // Begin a loop that will extract all source rows in GROUP BY order. // This might involve two separate loops with an OP_Sort in between, or // it might be a single loop that uses an index to extract information // in the right order to begin with. - Xsqlite3VdbeAddOp2(tls, v, 12, regReset, addrReset) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regReset, addrReset) pWInfo = Xsqlite3WhereBegin(tls, pParse, pTabList, pWhere, pGroupBy, uintptr(0), - (uint16(0x0040 | (func() int32 { + (uint16(WHERE_GROUPBY | (func() int32 { if orderByGrp != 0 { - return 0x0200 + return WHERE_SORTBYGROUP } return 0 }()))), 0) @@ -119592,7 +117362,7 @@ __89: explainTempTable(tls, pParse, func() uintptr { - if ((*DistinctCtx)(unsafe.Pointer(bp+168 /* &sDistinct */)).FisTnct != 0) && (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000001)) == U32(0)) { + if ((*DistinctCtx)(unsafe.Pointer(bp+168 /* &sDistinct */)).FisTnct != 0) && (((*Select)(unsafe.Pointer(p)).FselFlags & SF_Distinct) == U32(0)) { return ts + 21075 /* "DISTINCT" */ } return ts + 21084 /* "GROUP BY" */ @@ -119647,15 +117417,15 @@ __96: __97: ; regRecord = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 91, regBase, nCol, regRecord) - Xsqlite3VdbeAddOp2(tls, v, 131, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, regRecord) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regBase, nCol, regRecord) + Xsqlite3VdbeAddOp2(tls, v, OP_SorterInsert, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, regRecord) Xsqlite3ReleaseTempReg(tls, pParse, regRecord) Xsqlite3ReleaseTempRange(tls, pParse, regBase, nCol) Xsqlite3WhereEnd(tls, pWInfo) (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab = libc.AssignInt32(&sortPTab, libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)) sortOut = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 114, sortPTab, sortOut, nCol) - Xsqlite3VdbeAddOp2(tls, v, 35, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrEnd) + Xsqlite3VdbeAddOp3(tls, v, OP_OpenPseudo, sortPTab, sortOut, nCol) + Xsqlite3VdbeAddOp2(tls, v, OP_SorterSort, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrEnd) Xsqlite3VdbeComment(tls, v, ts+21093 /* "GROUP BY sort" */, 0) (*AggInfo)(unsafe.Pointer(pAggInfo)).FuseSortingIdx = U8(1) __90: @@ -119668,7 +117438,7 @@ __90: // This is an optimization - the correct answer should result regardless. // Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER to // disable this optimization for testing purposes. - if !(((orderByGrp != 0) && ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0004)) == 0)) && + if !(((orderByGrp != 0) && ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_GroupByOrder)) == 0)) && ((groupBySort != 0) || (Xsqlite3WhereIsSorted(tls, pWInfo) != 0))) { goto __99 } @@ -119685,7 +117455,7 @@ __99: if !(groupBySort != 0) { goto __100 } - Xsqlite3VdbeAddOp3(tls, v, 125, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, + Xsqlite3VdbeAddOp3(tls, v, OP_SorterData, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, sortOut, sortPTab) __100: ; @@ -119697,7 +117467,7 @@ __101: if !(groupBySort != 0) { goto __104 } - Xsqlite3VdbeAddOp3(tls, v, 89, sortPTab, j, (iBMem + j)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, sortPTab, j, (iBMem + j)) goto __105 __104: (*AggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode = U8(1) @@ -119711,10 +117481,10 @@ __102: goto __103 __103: ; - Xsqlite3VdbeAddOp4(tls, v, 86, iAMem, iBMem, (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr, + Xsqlite3VdbeAddOp4(tls, v, OP_Compare, iAMem, iBMem, (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr, Xsqlite3KeyInfoRef(tls, pKeyInfo1), -9) addr1 = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp3(tls, v, 16, (addr1 + 1), 0, (addr1 + 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, (addr1 + 1), 0, (addr1 + 1)) // Generate code that runs whenever the GROUP BY changes. // Changes in the GROUP BY are detected by the previous code @@ -119725,25 +117495,25 @@ __103: // and resets the aggregate accumulator registers in preparation // for the next GROUP BY batch. Xsqlite3ExprCodeMove(tls, pParse, iBMem, iAMem, (*ExprList)(unsafe.Pointer(pGroupBy)).FnExpr) - Xsqlite3VdbeAddOp2(tls, v, 12, regOutputRow, addrOutputRow) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutputRow, addrOutputRow) Xsqlite3VdbeComment(tls, v, ts+21107 /* "output one row" */, 0) - Xsqlite3VdbeAddOp2(tls, v, 48, iAbortFlag, addrEnd) + Xsqlite3VdbeAddOp2(tls, v, OP_IfPos, iAbortFlag, addrEnd) Xsqlite3VdbeComment(tls, v, ts+21122 /* "check abort flag" */, 0) - Xsqlite3VdbeAddOp2(tls, v, 12, regReset, addrReset) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regReset, addrReset) Xsqlite3VdbeComment(tls, v, ts+21139 /* "reset accumulato..." */, 0) // Update the aggregate accumulators based on the content of // the current row Xsqlite3VdbeJumpHere(tls, v, addr1) updateAccumulator(tls, pParse, iUseFlag, pAggInfo) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, iUseFlag) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, iUseFlag) Xsqlite3VdbeComment(tls, v, ts+21157 /* "indicate data in..." */, 0) // End of the loop if !(groupBySort != 0) { goto __106 } - Xsqlite3VdbeAddOp2(tls, v, 3, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrTopOfLoop) + Xsqlite3VdbeAddOp2(tls, v, OP_SorterNext, (*AggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdx, addrTopOfLoop) goto __107 __106: @@ -119753,7 +117523,7 @@ __107: ; // Output the final row of result - Xsqlite3VdbeAddOp2(tls, v, 12, regOutputRow, addrOutputRow) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regOutputRow, addrOutputRow) Xsqlite3VdbeComment(tls, v, ts+21186 /* "output final row" */, 0) // Jump over the subroutines @@ -119766,29 +117536,29 @@ __107: // increments the iAbortFlag memory location before returning in // order to signal the caller to abort. addrSetAbort = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, iAbortFlag) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, iAbortFlag) Xsqlite3VdbeComment(tls, v, ts+21203 /* "set abort flag" */, 0) - Xsqlite3VdbeAddOp1(tls, v, 65, regOutputRow) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regOutputRow) Xsqlite3VdbeResolveLabel(tls, v, addrOutputRow) addrOutputRow = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp2(tls, v, 48, iUseFlag, (addrOutputRow + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_IfPos, iUseFlag, (addrOutputRow + 2)) Xsqlite3VdbeComment(tls, v, ts+21218 /* "Groupby result g..." */, 0) - Xsqlite3VdbeAddOp1(tls, v, 65, regOutputRow) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regOutputRow) finalizeAggFunctions(tls, pParse, pAggInfo) - Xsqlite3ExprIfFalse(tls, pParse, pHaving, (addrOutputRow + 1), 0x10) + Xsqlite3ExprIfFalse(tls, pParse, pHaving, (addrOutputRow + 1), SQLITE_JUMPIFNULL) selectInnerLoop(tls, pParse, p, -1, bp+80, /* &sSort */ bp+168 /* &sDistinct */, pDest, (addrOutputRow + 1), addrSetAbort) - Xsqlite3VdbeAddOp1(tls, v, 65, regOutputRow) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regOutputRow) Xsqlite3VdbeComment(tls, v, ts+21255 /* "end groupby resu..." */, 0) // Generate a subroutine that will reset the group-by accumulator Xsqlite3VdbeResolveLabel(tls, v, addrReset) resetAccumulator(tls, pParse, pAggInfo) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, iUseFlag) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, iUseFlag) Xsqlite3VdbeComment(tls, v, ts+21284 /* "indicate accumul..." */, 0) - Xsqlite3VdbeAddOp1(tls, v, 65, regReset) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regReset) goto __87 __86: @@ -119824,13 +117594,13 @@ __86: // // In practice the KeyInfo structure will not be used. It is only // passed to keep OP_OpenRead happy. - if !(!(((*Table)(unsafe.Pointer((pTab1))).FtabFlags & U32(0x0080)) == U32(0))) { + if !(!(((*Table)(unsafe.Pointer((pTab1))).FtabFlags & TF_WithoutRowid) == U32(0))) { goto __110 } pBest = Xsqlite3PrimaryKeyIndex(tls, pTab1) __110: ; - if !(!((int32(*(*uint8)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112 + 60 /* &.fg */ + 4 /* &.notIndexed */)) & 0x1 >> 0)) != 0)) { + if !(!((int32(*(*uint8)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + 60 /* &.fg */ + 4 /* &.notIndexed */)) & 0x1 >> 0)) != 0)) { goto __111 } pIdx = (*Table)(unsafe.Pointer(pTab1)).FpIndex @@ -119865,15 +117635,15 @@ __116: ; // Open a read-only cursor, execute the OP_Count, close the cursor. - Xsqlite3VdbeAddOp4Int(tls, v, 96, iCsr, int32(iRoot), iDb, 1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_OpenRead, iCsr, int32(iRoot), iDb, 1) if !(pKeyInfo2 != 0) { goto __117 } Xsqlite3VdbeChangeP4(tls, v, -1, pKeyInfo2, -9) __117: ; - Xsqlite3VdbeAddOp2(tls, v, 92, iCsr, (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(0)*24)).FiMem) - Xsqlite3VdbeAddOp1(tls, v, 116, iCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_Count, iCsr, (*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc)).FiMem) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iCsr) explainSimpleCount(tls, pParse, pTab1, pBest) goto __109 __108: @@ -119896,13 +117666,13 @@ __119: if !(i < (*AggInfo)(unsafe.Pointer(pAggInfo)).FnFunc) { goto __121 } - if !(((*Expr)(unsafe.Pointer(((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*24)).FpFExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + if !(((*Expr)(unsafe.Pointer(((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc + uintptr(i)*24)).FpFExpr))).Fflags & (EP_WinFunc)) != U32(0)) { goto __122 } goto __120 __122: ; - if !(((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(i)*24)).FpFunc)).FfuncFlags & U32(0x0020)) != 0) { + if !(((*FuncDef)(unsafe.Pointer((*AggInfo_func)(unsafe.Pointer((*AggInfo)(unsafe.Pointer(pAggInfo)).FaFunc+uintptr(i)*24)).FpFunc)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != 0) { goto __123 } goto __121 @@ -119919,7 +117689,7 @@ __121: goto __124 } regAcc = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regAcc) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regAcc) __124: ; __118: @@ -119948,7 +117718,7 @@ __125: if !(regAcc != 0) { goto __126 } - Xsqlite3VdbeAddOp2(tls, v, 69, 1, regAcc) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, regAcc) __126: ; addrSkip = Xsqlite3WhereOrderByLimitOptLabel(tls, pWInfo) @@ -119964,7 +117734,7 @@ __109: ; (*SortCtx)(unsafe.Pointer(bp + 80 /* &sSort */)).FpOrderBy = uintptr(0) - Xsqlite3ExprIfFalse(tls, pParse, pHaving, addrEnd, 0x10) + Xsqlite3ExprIfFalse(tls, pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL) selectInnerLoop(tls, pParse, p, -1, uintptr(0), uintptr(0), pDest, addrEnd, addrEnd) __87: @@ -119974,7 +117744,7 @@ __87: __52: ; // endif aggregate query - if !(int32((*DistinctCtx)(unsafe.Pointer(bp+168 /* &sDistinct */)).FeTnctType) == 3) { + if !(int32((*DistinctCtx)(unsafe.Pointer(bp+168 /* &sDistinct */)).FeTnctType) == WHERE_DISTINCT_UNORDERED) { goto __128 } explainTempTable(tls, pParse, ts+21075 /* "DISTINCT" */) @@ -120146,7 +117916,7 @@ __5: Xsqlite3_free(tls, (*TabResult)(unsafe.Pointer(p)).FzErrMsg) (*TabResult)(unsafe.Pointer(p)).FzErrMsg = Xsqlite3_mprintf(tls, ts+21334 /* "sqlite3_get_tabl..." */, 0) - (*TabResult)(unsafe.Pointer(p)).Frc = 1 + (*TabResult)(unsafe.Pointer(p)).Frc = SQLITE_ERROR return 1 __11: ; @@ -120193,7 +117963,7 @@ __12: return 0 malloc_failed: - (*TabResult)(unsafe.Pointer(p)).Frc = 7 + (*TabResult)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM return 1 } @@ -120227,20 +117997,20 @@ func Xsqlite3_get_table(tls *libc.TLS, db uintptr, zSql uintptr, pazResult uintp (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FnColumn = U32(0) (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FnData = U32(1) (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FnAlloc = U32(20) - (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).Frc = 0 + (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).Frc = SQLITE_OK (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FazResult = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(uintptr(0))) * uint64((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FnAlloc)))) if (*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult == uintptr(0) { - (*Sqlite3)(unsafe.Pointer(db)).FerrCode = 7 - return 7 + (*Sqlite3)(unsafe.Pointer(db)).FerrCode = SQLITE_NOMEM + return SQLITE_NOMEM } - *(*uintptr)(unsafe.Pointer((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + uintptr(0)*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer((*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FazResult)) = uintptr(0) rc = Xsqlite3_exec(tls, db, zSql, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 }{sqlite3_get_table_cb})), bp+8 /* &res */, pzErrMsg) - *(*uintptr)(unsafe.Pointer((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + uintptr(0)*8)) = uintptr(int64((*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FnData)) - if (rc & 0xff) == 4 { - Xsqlite3_free_table(tls, ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + uintptr(1)*8)) + *(*uintptr)(unsafe.Pointer((*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FazResult)) = uintptr(int64((*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FnData)) + if (rc & 0xff) == SQLITE_ABORT { + Xsqlite3_free_table(tls, ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + 1*8)) if (*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FzErrMsg != 0 { if pzErrMsg != 0 { Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(pzErrMsg))) @@ -120252,21 +118022,21 @@ func Xsqlite3_get_table(tls *libc.TLS, db uintptr, zSql uintptr, pazResult uintp return (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).Frc } Xsqlite3_free(tls, (*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FzErrMsg) - if rc != 0 { - Xsqlite3_free_table(tls, ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + uintptr(1)*8)) + if rc != SQLITE_OK { + Xsqlite3_free_table(tls, ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + 1*8)) return rc } if (*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FnAlloc > (*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FnData { var azNew uintptr azNew = Xsqlite3Realloc(tls, (*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult, (uint64(uint64(unsafe.Sizeof(uintptr(0))) * uint64((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FnData)))) if azNew == uintptr(0) { - Xsqlite3_free_table(tls, ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + uintptr(1)*8)) - (*Sqlite3)(unsafe.Pointer(db)).FerrCode = 7 - return 7 + Xsqlite3_free_table(tls, ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + 1*8)) + (*Sqlite3)(unsafe.Pointer(db)).FerrCode = SQLITE_NOMEM + return SQLITE_NOMEM } (*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FazResult = azNew } - *(*uintptr)(unsafe.Pointer(pazResult)) = ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + uintptr(1)*8) + *(*uintptr)(unsafe.Pointer(pazResult)) = ((*TabResult)(unsafe.Pointer(bp+8 /* &res */)).FazResult + 1*8) if pnColumn != 0 { *(*int32)(unsafe.Pointer(pnColumn)) = int32((*TabResult)(unsafe.Pointer(bp + 8 /* &res */)).FnColumn) } @@ -120283,7 +118053,7 @@ func Xsqlite3_free_table(tls *libc.TLS, azResult uintptr) { /* sqlite3.c:136374: var n int32 azResult -= 8 - n = int32(*(*uintptr)(unsafe.Pointer(azResult + uintptr(0)*8))) + n = int32(*(*uintptr)(unsafe.Pointer(azResult))) for i = 1; i < n; i++ { if *(*uintptr)(unsafe.Pointer(azResult + uintptr(i)*8)) != 0 { Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(azResult + uintptr(i)*8))) @@ -120338,7 +118108,7 @@ func Xsqlite3DeleteTriggerStep(tls *libc.TLS, db uintptr, pTriggerStep uintptr) // that fire off of pTab. The list will include any TEMP triggers on // pTab as well as the triggers lised in pTab->pTrigger. func Xsqlite3TriggerList(tls *libc.TLS, pParse uintptr, pTab uintptr) uintptr { /* sqlite3.c:136440:24: */ - var pTmpSchema uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb + uintptr(1)*32)).FpSchema + var pTmpSchema uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb + 1*32)).FpSchema var pList uintptr = uintptr(0) // List of triggers to return if (*Parse)(unsafe.Pointer(pParse)).FdisableTriggers != 0 { @@ -120442,8 +118212,8 @@ __5: if !(((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy != 0) && (iDb != 1)) { goto __6 } - Xsqlite3DbFree(tls, db, (*SrcList_item)(unsafe.Pointer((pTableName+8 /* &.a */)+uintptr(0)*112)).FzDatabase) - (*SrcList_item)(unsafe.Pointer((pTableName + 8 /* &.a */) + uintptr(0)*112)).FzDatabase = uintptr(0) + Xsqlite3DbFree(tls, db, (*SrcList_item)(unsafe.Pointer((pTableName + 8 /* &.a */))).FzDatabase) + (*SrcList_item)(unsafe.Pointer((pTableName + 8 /* &.a */))).FzDatabase = uintptr(0) __6: ; @@ -120453,7 +118223,7 @@ __6: // exist, the error is caught by the block below. pTab = Xsqlite3SrcListLookup(tls, pParse, pTableName) if !((((int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0) && ((*Token)(unsafe.Pointer(pName2)).Fn == uint32(0))) && (pTab != 0)) && - ((*Table)(unsafe.Pointer(pTab)).FpSchema == (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema)) { + ((*Table)(unsafe.Pointer(pTab)).FpSchema == (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema)) { goto __7 } iDb = 1 @@ -120521,7 +118291,7 @@ __13: __14: ; - if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) { + if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) { goto __15 } if !(Xsqlite3HashFind(tls, ((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FpSchema+56 /* &.trigHash */), zName) != 0) { @@ -120554,12 +118324,12 @@ __19: // INSTEAD of triggers are only for views and views only support INSTEAD // of triggers. - if !(((*Table)(unsafe.Pointer(pTab)).FpSelect != 0) && (tr_tm != 65)) { + if !(((*Table)(unsafe.Pointer(pTab)).FpSelect != 0) && (tr_tm != TK_INSTEAD)) { goto __20 } Xsqlite3ErrorMsg(tls, pParse, ts+21558, /* "cannot create %s..." */ libc.VaList(bp+8, func() uintptr { - if tr_tm == 33 { + if tr_tm == TK_BEFORE { return ts + 21595 /* "BEFORE" */ } return ts + 21602 /* "AFTER" */ @@ -120567,7 +118337,7 @@ __19: goto trigger_cleanup __20: ; - if !(!(int32((*Table)(unsafe.Pointer(pTab)).FpSelect) != 0) && (tr_tm == 65)) { + if !(!(int32((*Table)(unsafe.Pointer(pTab)).FpSelect) != 0) && (tr_tm == TK_INSTEAD)) { goto __21 } Xsqlite3ErrorMsg(tls, pParse, @@ -120576,21 +118346,21 @@ __20: __21: ; - if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2)) { + if !(!(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME)) { goto __22 } iTabDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) - code = 7 + code = SQLITE_CREATE_TRIGGER zDb = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iTabDb)*32)).FzDbSName if isTemp != 0 { - zDbTrig = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(1)*32)).FzDbSName + zDbTrig = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*32)).FzDbSName } else { zDbTrig = zDb } if !((iTabDb == 1) || (isTemp != 0)) { goto __23 } - code = 5 + code = SQLITE_CREATE_TEMP_TRIGGER __23: ; if !(Xsqlite3AuthCheck(tls, pParse, code, zName, (*Table)(unsafe.Pointer(pTab)).FzName, zDbTrig) != 0) { @@ -120599,7 +118369,7 @@ __23: goto trigger_cleanup __24: ; - if !(Xsqlite3AuthCheck(tls, pParse, 18, func() uintptr { + if !(Xsqlite3AuthCheck(tls, pParse, SQLITE_INSERT, func() uintptr { if (!(0 != 0)) && (iTabDb == 1) { return ts + 13301 /* "sqlite_temp_mast..." */ } @@ -120617,10 +118387,10 @@ __22: // cannot appear on views. So we might as well translate every // INSTEAD OF trigger into a BEFORE trigger. It simplifies code // elsewhere. - if !(tr_tm == 65) { + if !(tr_tm == TK_INSTEAD) { goto __26 } - tr_tm = 33 + tr_tm = TK_BEFORE __26: ; @@ -120634,25 +118404,25 @@ __27: ; (*Trigger)(unsafe.Pointer(pTrigger)).FzName = zName zName = uintptr(0) - (*Trigger)(unsafe.Pointer(pTrigger)).Ftable = Xsqlite3DbStrDup(tls, db, (*SrcList_item)(unsafe.Pointer((pTableName+8 /* &.a */)+uintptr(0)*112)).FzName) + (*Trigger)(unsafe.Pointer(pTrigger)).Ftable = Xsqlite3DbStrDup(tls, db, (*SrcList_item)(unsafe.Pointer((pTableName + 8 /* &.a */))).FzName) (*Trigger)(unsafe.Pointer(pTrigger)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpSchema (*Trigger)(unsafe.Pointer(pTrigger)).FpTabSchema = (*Table)(unsafe.Pointer(pTab)).FpSchema (*Trigger)(unsafe.Pointer(pTrigger)).Fop = U8(op) (*Trigger)(unsafe.Pointer(pTrigger)).Ftr_tm = func() uint8 { - if tr_tm == 33 { - return uint8(1) + if tr_tm == TK_BEFORE { + return TRIGGER_BEFORE } - return uint8(2) + return TRIGGER_AFTER }() - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __28 } - Xsqlite3RenameTokenRemap(tls, pParse, (*Trigger)(unsafe.Pointer(pTrigger)).Ftable, (*SrcList_item)(unsafe.Pointer((pTableName+8 /* &.a */)+uintptr(0)*112)).FzName) + Xsqlite3RenameTokenRemap(tls, pParse, (*Trigger)(unsafe.Pointer(pTrigger)).Ftable, (*SrcList_item)(unsafe.Pointer((pTableName + 8 /* &.a */))).FzName) (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = pWhen pWhen = uintptr(0) goto __29 __28: - (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = Xsqlite3ExprDup(tls, db, pWhen, 0x0001) + (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen = Xsqlite3ExprDup(tls, db, pWhen, EXPRDUP_REDUCE) __29: ; (*Trigger)(unsafe.Pointer(pTrigger)).FpColumns = pColumns @@ -120726,7 +118496,7 @@ __3: __4: ; - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { goto __5 } @@ -120825,9 +118595,9 @@ func Xsqlite3TriggerSelectStep(tls *libc.TLS, db uintptr, pSelect uintptr, zStar Xsqlite3SelectDelete(tls, db, pSelect) return uintptr(0) } - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Fop = U8(136) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Fop = TK_SELECT (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = pSelect - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = U8(11) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = OE_Default (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FzSpan = triggerSpanDup(tls, db, zStart, zEnd) return pTriggerStep } @@ -120842,13 +118612,13 @@ func triggerStepAllocate(tls *libc.TLS, pParse uintptr, op U8, pName uintptr, zS pTriggerStep = Xsqlite3DbMallocZero(tls, db, (uint64((uint64(unsafe.Sizeof(TriggerStep{})) + uint64((*Token)(unsafe.Pointer(pName)).Fn)) + uint64(1)))) if pTriggerStep != 0 { - var z uintptr = (pTriggerStep + uintptr(1)*96) + var z uintptr = (pTriggerStep + 1*96) libc.Xmemcpy(tls, z, (*Token)(unsafe.Pointer(pName)).Fz, uint64((*Token)(unsafe.Pointer(pName)).Fn)) Xsqlite3Dequote(tls, z) (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FzTarget = z (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Fop = op (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FzSpan = triggerSpanDup(tls, db, zStart, zEnd) - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameTokenMap(tls, pParse, (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FzTarget, pName) } } @@ -120864,13 +118634,13 @@ func Xsqlite3TriggerInsertStep(tls *libc.TLS, pParse uintptr, pTableName uintptr var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var pTriggerStep uintptr - pTriggerStep = triggerStepAllocate(tls, pParse, uint8(125), pTableName, zStart, zEnd) + pTriggerStep = triggerStepAllocate(tls, pParse, TK_INSERT, pTableName, zStart, zEnd) if pTriggerStep != 0 { - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = pSelect pSelect = uintptr(0) } else { - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, 0x0001) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpSelect = Xsqlite3SelectDup(tls, db, pSelect, EXPRDUP_REDUCE) } (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpIdList = pColumn (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpUpsert = pUpsert @@ -120896,9 +118666,9 @@ func Xsqlite3TriggerUpdateStep(tls *libc.TLS, pParse uintptr, pTableName uintptr var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var pTriggerStep uintptr - pTriggerStep = triggerStepAllocate(tls, pParse, uint8(127), pTableName, zStart, zEnd) + pTriggerStep = triggerStepAllocate(tls, pParse, TK_UPDATE, pTableName, zStart, zEnd) if pTriggerStep != 0 { - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpExprList = pEList (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = pWhere (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpFrom = pFrom @@ -120906,9 +118676,9 @@ func Xsqlite3TriggerUpdateStep(tls *libc.TLS, pParse uintptr, pTableName uintptr pWhere = uintptr(0) pFrom = uintptr(0) } else { - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpExprList = Xsqlite3ExprListDup(tls, db, pEList, 0x0001) - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, 0x0001) - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpFrom = Xsqlite3SrcListDup(tls, db, pFrom, 0x0001) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpExprList = Xsqlite3ExprListDup(tls, db, pEList, EXPRDUP_REDUCE) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, EXPRDUP_REDUCE) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpFrom = Xsqlite3SrcListDup(tls, db, pFrom, EXPRDUP_REDUCE) } (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = orconf } @@ -120925,15 +118695,15 @@ func Xsqlite3TriggerDeleteStep(tls *libc.TLS, pParse uintptr, pTableName uintptr var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var pTriggerStep uintptr - pTriggerStep = triggerStepAllocate(tls, pParse, uint8(126), pTableName, zStart, zEnd) + pTriggerStep = triggerStepAllocate(tls, pParse, TK_DELETE, pTableName, zStart, zEnd) if pTriggerStep != 0 { - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = pWhere pWhere = uintptr(0) } else { - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, 0x0001) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).FpWhere = Xsqlite3ExprDup(tls, db, pWhere, EXPRDUP_REDUCE) } - (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = U8(11) + (*TriggerStep)(unsafe.Pointer(pTriggerStep)).Forconf = OE_Default } Xsqlite3ExprDelete(tls, db, pWhere) return pTriggerStep @@ -120979,17 +118749,17 @@ func Xsqlite3DropTrigger(tls *libc.TLS, pParse uintptr, pName uintptr, noErr int goto drop_trigger_cleanup __1: ; - if !(0 != Xsqlite3ReadSchema(tls, pParse)) { + if !(SQLITE_OK != Xsqlite3ReadSchema(tls, pParse)) { goto __2 } goto drop_trigger_cleanup __2: ; - zDb = (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */) + uintptr(0)*112)).FzDatabase - zName = (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */) + uintptr(0)*112)).FzName + zDb = (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */))).FzDatabase + zName = (*SrcList_item)(unsafe.Pointer((pName + 8 /* &.a */))).FzName - i = 0 + i = OMIT_TEMPDB __3: if !(i < (*Sqlite3)(unsafe.Pointer(db)).FnDb) { goto __5 @@ -121063,7 +118833,7 @@ func Xsqlite3DropTriggerPtr(tls *libc.TLS, pParse uintptr, pTrigger uintptr) { / pTable = tableOfTrigger(tls, pTrigger) if pTable != 0 { - var code int32 = 16 + var code int32 = SQLITE_DROP_TRIGGER var zDb uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName var zTab uintptr = func() uintptr { if (!(0 != 0)) && (iDb == 1) { @@ -121072,9 +118842,9 @@ func Xsqlite3DropTriggerPtr(tls *libc.TLS, pParse uintptr, pTrigger uintptr) { / return ts + 7541 /* "sqlite_master" */ }() if iDb == 1 { - code = 14 + code = SQLITE_DROP_TEMP_TRIGGER } - if (Xsqlite3AuthCheck(tls, pParse, code, (*Trigger)(unsafe.Pointer(pTrigger)).FzName, (*Table)(unsafe.Pointer(pTable)).FzName, zDb) != 0) || (Xsqlite3AuthCheck(tls, pParse, 9, zTab, uintptr(0), zDb) != 0) { + if (Xsqlite3AuthCheck(tls, pParse, code, (*Trigger)(unsafe.Pointer(pTrigger)).FzName, (*Table)(unsafe.Pointer(pTable)).FzName, zDb) != 0) || (Xsqlite3AuthCheck(tls, pParse, SQLITE_DELETE, zTab, uintptr(0), zDb) != 0) { return } } @@ -121085,7 +118855,7 @@ func Xsqlite3DropTriggerPtr(tls *libc.TLS, pParse uintptr, pTrigger uintptr) { / ts+21778, /* "DELETE FROM %Q.s..." */ libc.VaList(bp, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName, (*Trigger)(unsafe.Pointer(pTrigger)).FzName)) Xsqlite3ChangeCookie(tls, pParse, iDb) - Xsqlite3VdbeAddOp4(tls, v, 145, iDb, 0, 0, (*Trigger)(unsafe.Pointer(pTrigger)).FzName, 0) + Xsqlite3VdbeAddOp4(tls, v, OP_DropTrigger, iDb, 0, 0, (*Trigger)(unsafe.Pointer(pTrigger)).FzName, 0) } } @@ -121110,7 +118880,7 @@ func Xsqlite3UnlinkAndDeleteTrigger(tls *libc.TLS, db uintptr, iDb int32, zName } } Xsqlite3DeleteTrigger(tls, db, pTrigger) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0001)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_SchemaChange) } } @@ -121143,7 +118913,7 @@ func Xsqlite3TriggersExist(tls *libc.TLS, pParse uintptr, pTab uintptr, op int32 var pList uintptr = uintptr(0) var p uintptr - if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00040000)) != uint64(0) { + if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_EnableTrigger) != uint64(0) { pList = Xsqlite3TriggerList(tls, pParse, pTab) } @@ -121179,9 +118949,9 @@ func Xsqlite3TriggerStepSrc(tls *libc.TLS, pParse uintptr, pStep uintptr) uintpt if pSrc != 0 { var pSchema uintptr = (*Trigger)(unsafe.Pointer((*TriggerStep)(unsafe.Pointer(pStep)).FpTrig)).FpSchema - (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */) + uintptr(0)*112)).FzName = zName - if pSchema != (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema { - (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */) + uintptr(0)*112)).FpSchema = pSchema + (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FzName = zName + if pSchema != (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema { + (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FpSchema = pSchema } if (*TriggerStep)(unsafe.Pointer(pStep)).FpFrom != 0 { var pDup uintptr = Xsqlite3SrcListDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FpFrom, 0) @@ -121217,20 +118987,20 @@ func codeTriggerProgram(tls *libc.TLS, pParse uintptr, pStepList uintptr, orconf // INSERT INTO t1 ... ; -- insert into t2 uses REPLACE policy // INSERT OR IGNORE INTO t1 ... ; -- insert into t2 uses IGNORE policy (*Parse)(unsafe.Pointer(pParse)).FeOrconf = func() uint8 { - if orconf == 11 { + if orconf == OE_Default { return (*TriggerStep)(unsafe.Pointer(pStep)).Forconf } return U8(orconf) }() if (*TriggerStep)(unsafe.Pointer(pStep)).FzSpan != 0 { - Xsqlite3VdbeAddOp4(tls, v, 170, 0x7fffffff, 1, 0, + Xsqlite3VdbeAddOp4(tls, v, OP_Trace, 0x7fffffff, 1, 0, Xsqlite3MPrintf(tls, db, ts+7728 /* "-- %s" */, libc.VaList(bp, (*TriggerStep)(unsafe.Pointer(pStep)).FzSpan)), -7) } switch int32((*TriggerStep)(unsafe.Pointer(pStep)).Fop) { - case 127: + case TK_UPDATE: { Xsqlite3Update(tls, pParse, Xsqlite3TriggerStepSrc(tls, pParse, pStep), @@ -121240,7 +119010,7 @@ func codeTriggerProgram(tls *libc.TLS, pParse uintptr, pStepList uintptr, orconf break } - case 125: + case TK_INSERT: { Xsqlite3Insert(tls, pParse, Xsqlite3TriggerStepSrc(tls, pParse, pStep), @@ -121251,7 +119021,7 @@ func codeTriggerProgram(tls *libc.TLS, pParse uintptr, pStepList uintptr, orconf break } - case 126: + case TK_DELETE: { Xsqlite3DeleteFrom(tls, pParse, Xsqlite3TriggerStepSrc(tls, pParse, pStep), @@ -121264,15 +119034,15 @@ func codeTriggerProgram(tls *libc.TLS, pParse uintptr, pStepList uintptr, orconf // var sDest SelectDest at bp+8, 40 var pSelect uintptr = Xsqlite3SelectDup(tls, db, (*TriggerStep)(unsafe.Pointer(pStep)).FpSelect, 0) - Xsqlite3SelectDestInit(tls, bp+8 /* &sDest */, 4, 0) + Xsqlite3SelectDestInit(tls, bp+8 /* &sDest */, SRT_Discard, 0) Xsqlite3Select(tls, pParse, pSelect, bp+8 /* &sDest */) Xsqlite3SelectDelete(tls, db, pSelect) break } } - if int32((*TriggerStep)(unsafe.Pointer(pStep)).Fop) != 136 { - Xsqlite3VdbeAddOp0(tls, v, 123) + if int32((*TriggerStep)(unsafe.Pointer(pStep)).Fop) != TK_SELECT { + Xsqlite3VdbeAddOp0(tls, v, OP_ResetCount) } } @@ -121283,17 +119053,17 @@ func codeTriggerProgram(tls *libc.TLS, pParse uintptr, pStepList uintptr, orconf // program. It is not used in production code, only for debugging. func onErrorText(tls *libc.TLS, onError int32) uintptr { /* sqlite3.c:137251:19: */ switch onError { - case 2: + case OE_Abort: return ts + 21840 /* "abort" */ - case 1: + case OE_Rollback: return ts + 21846 /* "rollback" */ - case 3: + case OE_Fail: return ts + 21855 /* "fail" */ - case 5: + case OE_Replace: return ts + 16399 /* "replace" */ - case 4: + case OE_Ignore: return ts + 21860 /* "ignore" */ - case 11: + case OE_Default: return ts + 21867 /* "default" */ } return ts + 21875 /* "n/a" */ @@ -121351,8 +119121,8 @@ func codeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintpt Xsqlite3VdbeLinkSubProgram(tls, (*Parse)(unsafe.Pointer(pTop)).FpVdbe, pProgram) (*TriggerPrg)(unsafe.Pointer(pPrg)).FpTrigger = pTrigger (*TriggerPrg)(unsafe.Pointer(pPrg)).Forconf = orconf - *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */) + uintptr(0)*4)) = 0xffffffff - *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */) + uintptr(1)*4)) = 0xffffffff + *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */))) = 0xffffffff + *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */) + 1*4)) = 0xffffffff // Allocate and populate a new Parse context to use for coding the // trigger sub-program. @@ -121373,22 +119143,22 @@ func codeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintpt v = Xsqlite3GetVdbe(tls, pSubParse) if v != 0 { Xsqlite3VdbeComment(tls, v, ts+21879 /* "Start: %s.%s (%s..." */, libc.VaList(bp, (*Trigger)(unsafe.Pointer(pTrigger)).FzName, onErrorText(tls, orconf), func() uintptr { - if int32((*Trigger)(unsafe.Pointer(pTrigger)).Ftr_tm) == 1 { + if int32((*Trigger)(unsafe.Pointer(pTrigger)).Ftr_tm) == TRIGGER_BEFORE { return ts + 21595 /* "BEFORE" */ } return ts + 21602 /* "AFTER" */ }(), func() uintptr { - if int32((*Trigger)(unsafe.Pointer(pTrigger)).Fop) == 127 { + if int32((*Trigger)(unsafe.Pointer(pTrigger)).Fop) == TK_UPDATE { return ts + 21910 /* "UPDATE" */ } return ts + 800 /* "" */ }(), func() uintptr { - if int32((*Trigger)(unsafe.Pointer(pTrigger)).Fop) == 125 { + if int32((*Trigger)(unsafe.Pointer(pTrigger)).Fop) == TK_INSERT { return ts + 21917 /* "INSERT" */ } return ts + 800 /* "" */ }(), func() uintptr { - if int32((*Trigger)(unsafe.Pointer(pTrigger)).Fop) == 126 { + if int32((*Trigger)(unsafe.Pointer(pTrigger)).Fop) == TK_DELETE { return ts + 21924 /* "DELETE" */ } return ts + 800 /* "" */ @@ -121403,10 +119173,10 @@ func codeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintpt // OP_Halt inserted at the end of the program. if (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen != 0 { pWhen = Xsqlite3ExprDup(tls, db, (*Trigger)(unsafe.Pointer(pTrigger)).FpWhen, 0) - if (0 == Xsqlite3ResolveExprNames(tls, bp+80 /* &sNC */, pWhen)) && + if (SQLITE_OK == Xsqlite3ResolveExprNames(tls, bp+80 /* &sNC */, pWhen)) && (int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0) { iEndTrigger = Xsqlite3VdbeMakeLabel(tls, pSubParse) - Xsqlite3ExprIfFalse(tls, pSubParse, pWhen, iEndTrigger, 0x10) + Xsqlite3ExprIfFalse(tls, pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL) } Xsqlite3ExprDelete(tls, db, pWhen) } @@ -121418,7 +119188,7 @@ func codeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintpt if iEndTrigger != 0 { Xsqlite3VdbeResolveLabel(tls, v, iEndTrigger) } - Xsqlite3VdbeAddOp0(tls, v, 68) + Xsqlite3VdbeAddOp0(tls, v, OP_Halt) Xsqlite3VdbeComment(tls, v, ts+21945 /* "End: %s.%s" */, libc.VaList(bp+64, (*Trigger)(unsafe.Pointer(pTrigger)).FzName, onErrorText(tls, orconf))) transferParseError(tls, pParse, pSubParse) @@ -121428,8 +119198,8 @@ func codeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintpt (*SubProgram)(unsafe.Pointer(pProgram)).FnMem = (*Parse)(unsafe.Pointer(pSubParse)).FnMem (*SubProgram)(unsafe.Pointer(pProgram)).FnCsr = (*Parse)(unsafe.Pointer(pSubParse)).FnTab (*SubProgram)(unsafe.Pointer(pProgram)).Ftoken = pTrigger - *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */) + uintptr(0)*4)) = (*Parse)(unsafe.Pointer(pSubParse)).Foldmask - *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */) + uintptr(1)*4)) = (*Parse)(unsafe.Pointer(pSubParse)).Fnewmask + *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */))) = (*Parse)(unsafe.Pointer(pSubParse)).Foldmask + *(*U32)(unsafe.Pointer((pPrg + 28 /* &.aColmask */) + 1*4)) = (*Parse)(unsafe.Pointer(pSubParse)).Fnewmask Xsqlite3VdbeDelete(tls, v) } @@ -121482,9 +119252,9 @@ func Xsqlite3CodeRowTriggerDirect(tls *libc.TLS, pParse uintptr, p uintptr, pTab // Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program // is a pointer to the sub-vdbe containing the trigger program. if pPrg != 0 { - var bRecursive int32 = (libc.Bool32(((*Trigger)(unsafe.Pointer(p)).FzName != 0) && (uint64(0) == ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00002000))))) + var bRecursive int32 = (libc.Bool32(((*Trigger)(unsafe.Pointer(p)).FzName != 0) && (uint64(0) == ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_RecTriggers)))) - Xsqlite3VdbeAddOp4(tls, v, 46, reg, ignoreJump, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1), + Xsqlite3VdbeAddOp4(tls, v, OP_Program, reg, ignoreJump, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1), (*TriggerPrg)(unsafe.Pointer(pPrg)).FpProgram, -4) Xsqlite3VdbeComment(tls, v, ts+21956 /* "Call: %s.%s" */, libc.VaList(bp, func() uintptr { if (*Trigger)(unsafe.Pointer(p)).FzName != 0 { @@ -121584,9 +119354,9 @@ func Xsqlite3CodeRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, op func Xsqlite3TriggerColmask(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pChanges uintptr, isNew int32, tr_tm int32, pTab uintptr, orconf int32) U32 { /* sqlite3.c:137569:20: */ var op int32 if pChanges != 0 { - op = 127 + op = TK_UPDATE } else { - op = 126 + op = TK_DELETE } var mask U32 = U32(0) var p uintptr @@ -121649,8 +119419,8 @@ func Xsqlite3ColumnDefault(tls *libc.TLS, v uintptr, pTab uintptr, i int32, iReg Xsqlite3VdbeAppendP4(tls, v, *(*uintptr)(unsafe.Pointer(bp + 16 /* pValue */)), -11) } } - if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).Faffinity) == 0x45) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { - Xsqlite3VdbeAddOp1(tls, v, 83, iReg) + if (int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).Faffinity) == SQLITE_AFF_REAL) && !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { + Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, iReg) } } @@ -121697,7 +119467,7 @@ func indexWhereClauseMightChange(tls *libc.TLS, pIdx uintptr, aXRef uintptr, chn // expression to be a TK_COLUMN reading column iCol of the first // table in the source-list (pSrc->a[0]). func exprRowColumn(tls *libc.TLS, pParse uintptr, iCol int32) uintptr { /* sqlite3.c:137740:13: */ - var pRet uintptr = Xsqlite3PExpr(tls, pParse, 75, uintptr(0), uintptr(0)) + var pRet uintptr = Xsqlite3PExpr(tls, pParse, TK_ROW, uintptr(0), uintptr(0)) if pRet != 0 { (*Expr)(unsafe.Pointer(pRet)).FiColumn = (YnVar(iCol + 1)) } @@ -121753,7 +119523,7 @@ func updateFromSelect(tls *libc.TLS, pParse uintptr, iEph int32, pPk uintptr, pC var pLimit2 uintptr = uintptr(0) var pOrderBy2 uintptr = uintptr(0) var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - var pTab uintptr = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FpTab + var pTab uintptr = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FpTab var pSrc uintptr var pWhere2 uintptr var eDest int32 @@ -121765,28 +119535,28 @@ func updateFromSelect(tls *libc.TLS, pParse uintptr, iEph int32, pPk uintptr, pC pWhere2 = Xsqlite3ExprDup(tls, db, pWhere, 0) if pSrc != 0 { - (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */) + uintptr(0)*112)).FiCursor = -1 - (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pSrc+8 /* &.a */)+uintptr(0)*112)).FpTab)).FnTabRef-- - (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab = uintptr(0) + (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FiCursor = -1 + (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FpTab)).FnTabRef-- + (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FpTab = uintptr(0) } if pPk != 0 { for i = 0; i < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); i++ { var pNew uintptr = exprRowColumn(tls, pParse, int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))) pList = Xsqlite3ExprListAppend(tls, pParse, pList, pNew) } - eDest = 15 + eDest = SRT_Upfrom } else if (*Table)(unsafe.Pointer(pTab)).FpSelect != 0 { for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { pList = Xsqlite3ExprListAppend(tls, pParse, pList, exprRowColumn(tls, pParse, i)) } - eDest = 14 + eDest = SRT_Table } else { if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { - eDest = 14 + eDest = SRT_Table } else { - eDest = 15 + eDest = SRT_Upfrom } - pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), Xsqlite3PExpr(tls, pParse, 75, uintptr(0), uintptr(0))) + pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), Xsqlite3PExpr(tls, pParse, TK_ROW, uintptr(0), uintptr(0))) } if pChanges != 0 { for i = 0; i < (*ExprList)(unsafe.Pointer(pChanges)).FnExpr; i++ { @@ -121795,7 +119565,7 @@ func updateFromSelect(tls *libc.TLS, pParse uintptr, iEph int32, pPk uintptr, pC } } pSelect = Xsqlite3SelectNew(tls, pParse, pList, - pSrc, pWhere2, pGrp, uintptr(0), pOrderBy2, (uint32(0x0800000 | 0x0020000)), pLimit2) + pSrc, pWhere2, pGrp, uintptr(0), pOrderBy2, (uint32(SF_UpdateFrom | SF_IncludeHidden)), pLimit2) Xsqlite3SelectDestInit(tls, bp /* &dest */, eDest, iEph) (*SelectDest)(unsafe.Pointer(bp /* &dest */)).FiSDParm2 = func() int32 { if pPk != 0 { @@ -121932,7 +119702,7 @@ __2: // Figure out if we have any triggers and if the table being // updated is a view. - pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, 127, pChanges, bp+32 /* &tmask */) + pTrigger = Xsqlite3TriggersExist(tls, pParse, pTab, TK_UPDATE, pChanges, bp+32 /* &tmask */) isView = (libc.Bool32((*Table)(unsafe.Pointer(pTab)).FpSelect != uintptr(0))) // If there was a FROM clause, set nChangeFrom to the number of expressions @@ -121964,7 +119734,7 @@ __4: // allocate enough space, just in case. iBaseCur = libc.AssignInt32(&iDataCur, libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1)) iIdxCur = (iDataCur + 1) - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { pPk = uintptr(0) } else { pPk = Xsqlite3PrimaryKeyIndex(tls, pTab) @@ -122000,7 +119770,7 @@ __7: (*Parse)(unsafe.Pointer(pParse)).FnTab = iBaseCur __9: ; - (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FiCursor = iDataCur + (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FiCursor = iDataCur // Allocate space for aXRef[], aRegIdx[], and aToOpen[]. // Initialize aXRef[] and aToOpen[] to their default values. @@ -122034,7 +119804,7 @@ __13: (*NameContext)(unsafe.Pointer(bp + 40 /* &sNC */)).FpParse = pParse (*NameContext)(unsafe.Pointer(bp + 40 /* &sNC */)).FpSrcList = pTabList *(*uintptr)(unsafe.Pointer(bp + 40 /* &sNC */ + 16 /* &.uNC */)) = pUpsert - (*NameContext)(unsafe.Pointer(bp + 40 /* &sNC */)).FncFlags = 0x00200 + (*NameContext)(unsafe.Pointer(bp + 40 /* &sNC */)).FncFlags = NC_UUpsert // Begin generating code. v = Xsqlite3GetVdbe(tls, pParse) @@ -122080,13 +119850,13 @@ __19: iRowidExpr = i goto __24 __23: - if !((pPk != 0) && ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & 0x0001) != 0)) { + if !((pPk != 0) && ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & COLFLAG_PRIMKEY) != 0)) { goto __25 } chngPk = U8(1) goto __26 __25: - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & 0x0060) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*32)).FcolFlags) & COLFLAG_GENERATED) != 0) { goto __27 } @@ -122131,7 +119901,7 @@ __30: __28: ; - rc = Xsqlite3AuthCheck(tls, pParse, 23, (*Table)(unsafe.Pointer(pTab)).FzName, + rc = Xsqlite3AuthCheck(tls, pParse, SQLITE_UPDATE, (*Table)(unsafe.Pointer(pTab)).FzName, func() uintptr { if j < 0 { return ts + 9563 /* "ROWID" */ @@ -122139,13 +119909,13 @@ __28: return (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*32)).FzName }(), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) - if !(rc == 1) { + if !(rc == SQLITE_DENY) { goto __31 } goto update_cleanup goto __32 __31: - if !(rc == 2) { + if !(rc == SQLITE_IGNORE) { goto __33 } *(*int32)(unsafe.Pointer(aXRef + uintptr(j)*4)) = -1 @@ -122170,7 +119940,7 @@ __17: // is non-negative, so the value of aXRef[] for generated columns can be // set to any non-negative number. We use 99999 so that the value is // obvious when looking at aXRef[] in a symbolic debugger. - if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != 0) { + if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != 0) { goto __34 } @@ -122187,7 +119957,7 @@ __38: goto __39 __41: ; - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0060) == 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_GENERATED) == 0) { goto __42 } goto __39 @@ -122223,7 +119993,7 @@ __34: // So reset the colUsed mask. Unless this is a virtual table. In that // case, set all bits of the colUsed mask (to ensure that the virtual // table implementation makes all columns available). - (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FcolUsed = func() uint64 { + (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FcolUsed = func() uint64 { if (*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0 { return libc.Uint64(libc.Uint64FromInt32(-1)) } @@ -122235,7 +120005,7 @@ __34: // There is one entry in the aRegIdx[] array for each index on the table // being updated. Fill in aRegIdx[] with a register number that will hold // the key for accessing each index. - if !(onError == 5) { + if !(onError == OE_Replace) { goto __44 } *(*int32)(unsafe.Pointer(bp + 104 /* bReplace */)) = 1 @@ -122266,7 +120036,7 @@ __50: } reg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (int32((*Index)(unsafe.Pointer(pIdx)).FnColumn)) - if !((onError == 11) && (int32((*Index)(unsafe.Pointer(pIdx)).FonError) == 5)) { + if !((onError == OE_Default) && (int32((*Index)(unsafe.Pointer(pIdx)).FonError) == OE_Replace)) { goto __54 } *(*int32)(unsafe.Pointer(bp + 104 /* bReplace */)) = 1 @@ -122398,14 +120168,14 @@ __64: goto __65 } regRowCount = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regRowCount) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regRowCount) __65: ; - if !((nChangeFrom == 0) && (((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) { + if !((nChangeFrom == 0) && (((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) { goto __66 } - Xsqlite3VdbeAddOp3(tls, v, 72, 0, regRowSet, regOldRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, regRowSet, regOldRowid) goto __67 __66: ; @@ -122431,10 +120201,10 @@ __66: if !(pPk != 0) { goto __69 } - Xsqlite3VdbeAddOp3(tls, v, 72, 0, iPk, ((iPk + int32(nPk)) - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, iPk, ((iPk + int32(nPk)) - 1)) __69: ; - addrOpen = Xsqlite3VdbeAddOp2(tls, v, 100, iEph, nEphCol) + addrOpen = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, iEph, nEphCol) if !(pPk != 0) { goto __70 } @@ -122470,7 +120240,7 @@ __67: goto __74 } Xsqlite3MultiWrite(tls, pParse) - eOnePass = 0 + eOnePass = ONEPASS_OFF nKey = int32(nPk) regKey = iPk goto __75 @@ -122483,8 +120253,8 @@ __74: // that is to be updated. So bypass the code that searches for the // row(s) to be updated. pWInfo = uintptr(0) - eOnePass = 1 - Xsqlite3ExprIfFalse(tls, pParse, pWhere, labelBreak, 0x10) + eOnePass = ONEPASS_SINGLE + Xsqlite3ExprIfFalse(tls, pParse, pWhere, labelBreak, SQLITE_JUMPIFNULL) bFinishSeek = 0 goto __77 __76: @@ -122495,11 +120265,11 @@ __76: // be deleted as a result of REPLACE conflict handling. Any of these // things might disturb a cursor being used to scan through the table // or index, causing a single-pass approach to malfunction. - flags = (0x0004 | 0x1000) + flags = (WHERE_ONEPASS_DESIRED | WHERE_SEEK_UNIQ_TABLE) if !((((!(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0) && !(pTrigger != 0)) && !(hasFK != 0)) && !(chngKey != 0)) && !(*(*int32)(unsafe.Pointer(bp + 104 /* bReplace */)) != 0)) { goto __78 } - flags = flags | (0x0008) + flags = flags | (WHERE_ONEPASS_MULTIROW) __78: ; pWInfo = Xsqlite3WhereBegin(tls, pParse, pTabList, pWhere, uintptr(0), uintptr(0), uint16(flags), iIdxCur) @@ -122522,18 +120292,18 @@ __79: // updated. eOnePass = Xsqlite3WhereOkOnePass(tls, pWInfo, bp+96 /* &aiCurOnePass[0] */) bFinishSeek = Xsqlite3WhereUsesDeferredSeek(tls, pWInfo) - if !(eOnePass != 1) { + if !(eOnePass != ONEPASS_SINGLE) { goto __80 } Xsqlite3MultiWrite(tls, pParse) - if !(eOnePass == 2) { + if !(eOnePass == ONEPASS_MULTI) { goto __81 } - iCur = *(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(1)*4)) + iCur = *(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + 1*4)) if !(((iCur >= 0) && (iCur != iDataCur)) && (*(*U8)(unsafe.Pointer(aToOpen + uintptr((iCur - iBaseCur)))) != 0)) { goto __82 } - eOnePass = 0 + eOnePass = ONEPASS_OFF __82: ; @@ -122544,19 +120314,19 @@ __80: __77: ; - if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { goto __83 } // Read the rowid of the current row of the WHERE scan. In ONEPASS_OFF // mode, write the rowid into the FIFO. In either of the one-pass modes, // leave it in register regOldRowid. - Xsqlite3VdbeAddOp2(tls, v, 127, iDataCur, regOldRowid) - if !(eOnePass == 0) { + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iDataCur, regOldRowid) + if !(eOnePass == ONEPASS_OFF) { goto __85 } // We need to use regRowSet, so reallocate aRegIdx[nAllIdx] *(*int32)(unsafe.Pointer(aRegIdx + uintptr(nAllIdx)*4)) = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 147, regRowSet, regOldRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_RowSetAdd, regRowSet, regOldRowid) __85: ; goto __84 @@ -122594,9 +120364,9 @@ __91: regKey = iPk goto __90 __89: - Xsqlite3VdbeAddOp4(tls, v, 91, iPk, int32(nPk), regKey, + Xsqlite3VdbeAddOp4(tls, v, OP_MakeRecord, iPk, int32(nPk), regKey, Xsqlite3IndexAffinityStr(tls, db, pPk), int32(nPk)) - Xsqlite3VdbeAddOp4Int(tls, v, 130, iEph, regKey, iPk, int32(nPk)) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, iEph, regKey, iPk, int32(nPk)) __90: ; __84: @@ -122607,7 +120377,7 @@ __75: if !(pUpsert == uintptr(0)) { goto __92 } - if !((nChangeFrom == 0) && (eOnePass != 2)) { + if !((nChangeFrom == 0) && (eOnePass != ONEPASS_MULTI)) { goto __93 } Xsqlite3WhereEnd(tls, pWInfo) @@ -122620,31 +120390,31 @@ __93: addrOnce = 0 // Open every index that needs updating. - if !(eOnePass != 0) { + if !(eOnePass != ONEPASS_OFF) { goto __95 } - if !(*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(0)*4)) >= 0) { + if !(*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */)) >= 0) { goto __96 } - *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(0)*4)) - iBaseCur)))) = U8(0) + *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */)) - iBaseCur)))) = U8(0) __96: ; - if !(*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(1)*4)) >= 0) { + if !(*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + 1*4)) >= 0) { goto __97 } - *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(1)*4)) - iBaseCur)))) = U8(0) + *(*U8)(unsafe.Pointer(aToOpen + uintptr((*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + 1*4)) - iBaseCur)))) = U8(0) __97: ; __95: ; - if !((eOnePass == 2) && ((nIdx - (libc.Bool32(*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(1)*4)) >= 0))) > 0)) { + if !((eOnePass == ONEPASS_MULTI) && ((nIdx - (libc.Bool32(*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + 1*4)) >= 0))) > 0)) { goto __98 } - addrOnce = Xsqlite3VdbeAddOp0(tls, v, 17) + addrOnce = Xsqlite3VdbeAddOp0(tls, v, OP_Once) __98: ; - Xsqlite3OpenTableAndIndices(tls, pParse, pTab, 97, uint8(0), iBaseCur, + Xsqlite3OpenTableAndIndices(tls, pParse, pTab, OP_OpenWrite, uint8(0), iBaseCur, aToOpen, uintptr(0), uintptr(0)) if !(addrOnce != 0) { goto __99 @@ -122656,24 +120426,24 @@ __94: ; // Top of the update loop - if !(eOnePass != 0) { + if !(eOnePass != ONEPASS_OFF) { goto __100 } - if !((!(isView != 0) && (*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(0)*4)) != iDataCur)) && (*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + uintptr(1)*4)) != iDataCur)) { + if !((!(isView != 0) && (*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */)) != iDataCur)) && (*(*int32)(unsafe.Pointer(bp + 96 /* &aiCurOnePass[0] */ + 1*4)) != iDataCur)) { goto __102 } - Xsqlite3VdbeAddOp4Int(tls, v, 29, iDataCur, labelBreak, regKey, nKey) + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iDataCur, labelBreak, regKey, nKey) __102: ; - if !(eOnePass != 1) { + if !(eOnePass != ONEPASS_SINGLE) { goto __103 } labelContinue = Xsqlite3VdbeMakeLabel(tls, pParse) __103: ; - Xsqlite3VdbeAddOp2(tls, v, 50, func() int32 { + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, func() int32 { if pPk != 0 { return regKey } @@ -122686,7 +120456,7 @@ __100: goto __104 } labelContinue = Xsqlite3VdbeMakeLabel(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 37, iEph, labelBreak) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, iEph, labelBreak) addrTop = Xsqlite3VdbeCurrentAddr(tls, v) if !(nChangeFrom != 0) { goto __106 @@ -122702,7 +120472,7 @@ __111: if !(i < int32(nPk)) { goto __113 } - Xsqlite3VdbeAddOp3(tls, v, 89, iEph, i, (iPk + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, i, (iPk + i)) goto __112 __112: i++ @@ -122711,29 +120481,29 @@ __112: __113: ; Xsqlite3VdbeAddOp4Int(tls, - v, 29, iDataCur, labelContinue, iPk, int32(nPk)) + v, OP_NotFound, iDataCur, labelContinue, iPk, int32(nPk)) goto __110 __109: - Xsqlite3VdbeAddOp2(tls, v, 127, iEph, regOldRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iEph, regOldRowid) Xsqlite3VdbeAddOp3(tls, - v, 32, iDataCur, labelContinue, regOldRowid) + v, OP_NotExists, iDataCur, labelContinue, regOldRowid) __110: ; __108: ; goto __107 __106: - Xsqlite3VdbeAddOp2(tls, v, 126, iEph, regKey) - Xsqlite3VdbeAddOp4Int(tls, v, 29, iDataCur, labelContinue, regKey, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_RowData, iEph, regKey) + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iDataCur, labelContinue, regKey, 0) __107: ; goto __105 __104: - labelContinue = Xsqlite3VdbeAddOp3(tls, v, 42, regRowSet, labelBreak, + labelContinue = Xsqlite3VdbeAddOp3(tls, v, OP_RowSetRead, regRowSet, labelBreak, regOldRowid) - Xsqlite3VdbeAddOp3(tls, v, 32, iDataCur, labelContinue, regOldRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, labelContinue, regOldRowid) __105: ; @@ -122757,10 +120527,10 @@ __92: Xsqlite3ExprCode(tls, pParse, pRowidExpr, regNewRowid) goto __116 __115: - Xsqlite3VdbeAddOp3(tls, v, 89, iEph, iRowidExpr, regNewRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, iRowidExpr, regNewRowid) __116: ; - Xsqlite3VdbeAddOp1(tls, v, 15, regNewRowid) + Xsqlite3VdbeAddOp1(tls, v, OP_MustBeInt, regNewRowid) __114: ; @@ -122776,7 +120546,7 @@ __114: return uint32(0) }() oldmask = oldmask | (Xsqlite3TriggerColmask(tls, pParse, - pTrigger, pChanges, 0, (1 | 2), pTab, onError)) + pTrigger, pChanges, 0, (TRIGGER_BEFORE | TRIGGER_AFTER), pTab, onError)) i = 0 __118: if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) { @@ -122786,14 +120556,14 @@ __118: k = (int32(Xsqlite3TableColumnToStorage(tls, pTab, int16(i))) + regOld) if !(((oldmask == 0xffffffff) || ((i < 32) && ((oldmask & (uint32((uint32(1))) << (i))) != U32(0)))) || - ((colFlags & U32(0x0001)) != U32(0))) { + ((colFlags & COLFLAG_PRIMKEY) != U32(0))) { goto __121 } Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iDataCur, i, k) goto __122 __121: - Xsqlite3VdbeAddOp2(tls, v, 72, 0, k) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, k) __122: ; goto __119 @@ -122806,7 +120576,7 @@ __120: if !((int32(chngRowid) == 0) && (pPk == uintptr(0))) { goto __123 } - Xsqlite3VdbeAddOp2(tls, v, 77, regOldRowid, regNewRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, regOldRowid, regNewRowid) __123: ; __117: @@ -122825,7 +120595,7 @@ __117: // may have modified them). So not loading those that are not going to // be used eliminates some redundant opcodes. newmask = int32(Xsqlite3TriggerColmask(tls, - pParse, pTrigger, pChanges, 1, 1, pTab, onError)) + pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError)) i = 0 k = regNew __124: @@ -122835,13 +120605,13 @@ __124: if !(i == int32((*Table)(unsafe.Pointer(pTab)).FiPKey)) { goto __127 } - Xsqlite3VdbeAddOp2(tls, v, 72, 0, k) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, k) goto __128 __127: - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0060) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_GENERATED) != 0) { goto __129 } - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0) { goto __131 } k-- @@ -122863,7 +120633,7 @@ __129: return int32(nPk) }() - Xsqlite3VdbeAddOp3(tls, v, 89, iEph, (nOff + j), k) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, (nOff + j), k) goto __135 __134: Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pChanges+8 /* &.a */)+uintptr(j)*32)).FpExpr, k) @@ -122871,7 +120641,7 @@ __135: ; goto __133 __132: - if !(((0 == (*(*int32)(unsafe.Pointer(bp + 32 /* tmask */)) & 1)) || (i > 31)) || ((uint32(newmask) & (uint32((uint32(1))) << (i))) != 0)) { + if !(((0 == (*(*int32)(unsafe.Pointer(bp + 32 /* tmask */)) & TRIGGER_BEFORE)) || (i > 31)) || ((uint32(newmask) & (uint32((uint32(1))) << (i))) != 0)) { goto __136 } // This branch loads the value of a column that will not be changed @@ -122883,7 +120653,7 @@ __132: bFinishSeek = 0 goto __137 __136: - Xsqlite3VdbeAddOp2(tls, v, 72, 0, k) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, k) __137: ; __133: @@ -122900,7 +120670,7 @@ __125: goto __126 __126: ; - if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != 0) { + if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != 0) { goto __138 } @@ -122910,12 +120680,12 @@ __138: // Fire any BEFORE UPDATE triggers. This happens before constraints are // verified. One could argue that this is wrong. - if !((*(*int32)(unsafe.Pointer(bp + 32 /* tmask */)) & 1) != 0) { + if !((*(*int32)(unsafe.Pointer(bp + 32 /* tmask */)) & TRIGGER_BEFORE) != 0) { goto __139 } Xsqlite3TableAffinity(tls, v, pTab, regNew) - Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, 127, pChanges, - 1, pTab, regOldRowid, onError, labelContinue) + Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, TK_UPDATE, pChanges, + TRIGGER_BEFORE, pTab, regOldRowid, onError, labelContinue) if !(!(isView != 0)) { goto __140 @@ -122928,11 +120698,11 @@ __138: if !(pPk != 0) { goto __141 } - Xsqlite3VdbeAddOp4Int(tls, v, 29, iDataCur, labelContinue, regKey, nKey) + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iDataCur, labelContinue, regKey, nKey) goto __142 __141: - Xsqlite3VdbeAddOp3(tls, v, 32, iDataCur, labelContinue, regOldRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, labelContinue, regOldRowid) __142: ; @@ -122951,10 +120721,10 @@ __143: if !(i < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) { goto __145 } - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0060) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_GENERATED) != 0) { goto __146 } - if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & 0x0020) != 0) { + if !((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0) { goto __148 } k-- @@ -122978,7 +120748,7 @@ __144: goto __145 __145: ; - if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0060)) != 0) { + if !(((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_HasGenerated) != 0) { goto __150 } @@ -123008,10 +120778,10 @@ __139: if !(pPk != 0) { goto __153 } - Xsqlite3VdbeAddOp4Int(tls, v, 29, iDataCur, labelContinue, regKey, nKey) + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iDataCur, labelContinue, regKey, nKey) goto __154 __153: - Xsqlite3VdbeAddOp3(tls, v, 32, iDataCur, labelContinue, regOldRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iDataCur, labelContinue, regOldRowid) __154: ; @@ -123037,7 +120807,7 @@ __155: if !(bFinishSeek != 0) { goto __156 } - Xsqlite3VdbeAddOp1(tls, v, 135, iDataCur) + Xsqlite3VdbeAddOp1(tls, v, OP_FinishSeek, iDataCur) __156: ; @@ -123050,19 +120820,19 @@ __156: // value is copied from memory cell (regNewRowid+1+iCol), where iCol // is the column index supplied by the user. - Xsqlite3VdbeAddOp3(tls, v, 122, iDataCur, - (0x04 | (func() int32 { + Xsqlite3VdbeAddOp3(tls, v, OP_Delete, iDataCur, + (OPFLAG_ISUPDATE | (func() int32 { if (hasFK > 1) || (chngKey != 0) { return 0 } - return 0x40 + return OPFLAG_ISNOOP }())), regNewRowid) - if !(eOnePass == 2) { + if !(eOnePass == ONEPASS_MULTI) { goto __157 } - Xsqlite3VdbeChangeP5(tls, v, uint16(0x02)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_SAVEPOSITION) __157: ; if !(!(int32((*Parse)(unsafe.Pointer(pParse)).Fnested) != 0)) { @@ -123082,9 +120852,9 @@ __159: // Insert the new index entries and the new record. Xsqlite3CompleteInsertion(tls, pParse, pTab, iDataCur, iIdxCur, regNewRowid, aRegIdx, - (0x04 | (func() int32 { - if eOnePass == 2 { - return 0x02 + (OPFLAG_ISUPDATE | (func() int32 { + if eOnePass == ONEPASS_MULTI { + return OPFLAG_SAVEPOSITION } return 0 }())), @@ -123106,22 +120876,22 @@ __151: if !(regRowCount != 0) { goto __161 } - Xsqlite3VdbeAddOp2(tls, v, 82, regRowCount, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, regRowCount, 1) __161: ; - Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, 127, pChanges, - 2, pTab, regOldRowid, onError, labelContinue) + Xsqlite3CodeRowTrigger(tls, pParse, pTrigger, TK_UPDATE, pChanges, + TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue) // Repeat the above with the next record to be updated, until // all record selected by the WHERE clause have been updated. - if !(eOnePass == 1) { + if !(eOnePass == ONEPASS_SINGLE) { goto __162 } // Nothing to do at end-of-loop for a single-pass goto __163 __162: - if !(eOnePass == 2) { + if !(eOnePass == ONEPASS_MULTI) { goto __164 } Xsqlite3VdbeResolveLabel(tls, v, labelContinue) @@ -123132,7 +120902,7 @@ __164: goto __166 } Xsqlite3VdbeResolveLabel(tls, v, labelContinue) - Xsqlite3VdbeAddOp2(tls, v, 5, iEph, addrTop) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, iEph, addrTop) goto __167 __166: Xsqlite3VdbeGoto(tls, v, labelContinue) @@ -123159,9 +120929,9 @@ __168: if !(regRowCount != 0) { goto __169 } - Xsqlite3VdbeAddOp2(tls, v, 80, regRowCount, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_ResultRow, regRowCount, 1) Xsqlite3VdbeSetNumCols(tls, v, 1) - Xsqlite3VdbeSetColName(tls, v, 0, 0, ts+22028 /* "rows updated" */, uintptr(0)) + Xsqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, ts+22028 /* "rows updated" */, uintptr(0)) __169: ; @@ -123207,11 +120977,11 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb // Database connection var pVTab uintptr = Xsqlite3GetVTable(tls, db, pTab) var pWInfo uintptr = uintptr(0) - var nArg int32 = (2 + int32((*Table)(unsafe.Pointer(pTab)).FnCol)) // Number of arguments to VUpdate - var regArg int32 // First register in VUpdate arg array - var regRec int32 // Register in which to assemble record - var regRowid int32 // Register for ephem table rowid - var iCsr int32 = (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */) + uintptr(0)*112)).FiCursor // Cursor used for virtual table scan + var nArg int32 = (2 + int32((*Table)(unsafe.Pointer(pTab)).FnCol)) // Number of arguments to VUpdate + var regArg int32 // First register in VUpdate arg array + var regRec int32 // Register in which to assemble record + var regRowid int32 // Register for ephem table rowid + var iCsr int32 = (*SrcList_item)(unsafe.Pointer((pSrc + 8 /* &.a */))).FiCursor // Cursor used for virtual table scan // var aDummy [2]int32 at bp, 8 // Unused arg for sqlite3WhereOkOnePass() var eOnePass int32 // True to use onepass strategy @@ -123222,7 +120992,7 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt // these arguments will be temporarily stored. ephemTab = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - addr = Xsqlite3VdbeAddOp2(tls, v, 100, ephemTab, nArg) + addr = Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, ephemTab, nArg) regArg = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (nArg) if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc > 1 { @@ -123231,7 +121001,7 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt if pRowid != 0 { pRow = Xsqlite3ExprDup(tls, db, pRowid, 0) } else { - pRow = Xsqlite3PExpr(tls, pParse, 75, uintptr(0), uintptr(0)) + pRow = Xsqlite3PExpr(tls, pParse, TK_ROW, uintptr(0), uintptr(0)) } pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), pRow) @@ -123246,13 +121016,13 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt updateFromSelect(tls, pParse, ephemTab, uintptr(0), pList, pSrc, pWhere, uintptr(0), uintptr(0)) Xsqlite3ExprListDelete(tls, db, pList) - eOnePass = 0 + eOnePass = ONEPASS_OFF } else { regRec = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) regRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) // Start scanning the virtual table - pWInfo = Xsqlite3WhereBegin(tls, pParse, pSrc, pWhere, uintptr(0), uintptr(0), uint16(0x0004), 0) + pWInfo = Xsqlite3WhereBegin(tls, pParse, pSrc, pWhere, uintptr(0), uintptr(0), WHERE_ONEPASS_DESIRED, 0) if pWInfo == uintptr(0) { return } @@ -123263,25 +121033,25 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt if *(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4)) >= 0 { Xsqlite3ExprCode(tls, pParse, (*ExprList_item)(unsafe.Pointer((pChanges+8 /* &.a */)+uintptr(*(*int32)(unsafe.Pointer(aXRef + uintptr(i)*4)))*32)).FpExpr, ((regArg + 2) + i)) } else { - Xsqlite3VdbeAddOp3(tls, v, 166, iCsr, i, ((regArg + 2) + i)) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x01)) // For sqlite3_vtab_nochange() + Xsqlite3VdbeAddOp3(tls, v, OP_VColumn, iCsr, i, ((regArg + 2) + i)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_NOCHNG) // For sqlite3_vtab_nochange() } } - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { - Xsqlite3VdbeAddOp2(tls, v, 127, iCsr, regArg) + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iCsr, regArg) if pRowid != 0 { Xsqlite3ExprCode(tls, pParse, pRowid, (regArg + 1)) } else { - Xsqlite3VdbeAddOp2(tls, v, 127, iCsr, (regArg + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iCsr, (regArg + 1)) } } else { var pPk uintptr // PRIMARY KEY index var iPk I16 // PRIMARY KEY column pPk = Xsqlite3PrimaryKeyIndex(tls, pTab) - iPk = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(0)*2)) - Xsqlite3VdbeAddOp3(tls, v, 166, iCsr, int32(iPk), regArg) - Xsqlite3VdbeAddOp2(tls, v, 78, ((regArg + 2) + int32(iPk)), (regArg + 1)) + iPk = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn)) + Xsqlite3VdbeAddOp3(tls, v, OP_VColumn, iCsr, int32(iPk), regArg) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, ((regArg + 2) + int32(iPk)), (regArg + 1)) } eOnePass = Xsqlite3WhereOkOnePass(tls, pWInfo, bp /* &aDummy[0] */) @@ -123292,37 +121062,37 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt // If using the onepass strategy, no-op out the OP_OpenEphemeral coded // above. Xsqlite3VdbeChangeToNoop(tls, v, addr) - Xsqlite3VdbeAddOp1(tls, v, 116, iCsr) + Xsqlite3VdbeAddOp1(tls, v, OP_Close, iCsr) } else { // Create a record from the argument register contents and insert it into // the ephemeral table. Xsqlite3MultiWrite(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 91, regArg, nArg, regRec) - Xsqlite3VdbeAddOp2(tls, v, 120, ephemTab, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, ephemTab, regRec, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regArg, nArg, regRec) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, ephemTab, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, ephemTab, regRec, regRowid) } } - if eOnePass == 0 { + if eOnePass == ONEPASS_OFF { // End the virtual table scan if (*SrcList)(unsafe.Pointer(pSrc)).FnSrc == 1 { Xsqlite3WhereEnd(tls, pWInfo) } // Begin scannning through the ephemeral table. - addr = Xsqlite3VdbeAddOp1(tls, v, 37, ephemTab) + addr = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, ephemTab) // Extract arguments from the current row of the ephemeral table and // invoke the VUpdate method. for i = 0; i < nArg; i++ { - Xsqlite3VdbeAddOp3(tls, v, 89, ephemTab, i, (regArg + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, ephemTab, i, (regArg + i)) } } Xsqlite3VtabMakeWritable(tls, pParse, pTab) - Xsqlite3VdbeAddOp4(tls, v, 10, 0, nArg, regArg, pVTab, -12) + Xsqlite3VdbeAddOp4(tls, v, OP_VUpdate, 0, nArg, regArg, pVTab, -12) Xsqlite3VdbeChangeP5(tls, v, func() uint16 { - if onError == 11 { - return uint16(2) + if onError == OE_Default { + return OE_Abort } return uint16(onError) }()) @@ -123330,10 +121100,10 @@ func updateVirtualTable(tls *libc.TLS, pParse uintptr, pSrc uintptr, pTab uintpt // End of the ephemeral table scan. Or, if using the onepass strategy, // jump to here if the scan visited zero rows. - if eOnePass == 0 { - Xsqlite3VdbeAddOp2(tls, v, 5, ephemTab, (addr + 1)) + if eOnePass == ONEPASS_OFF { + Xsqlite3VdbeAddOp2(tls, v, OP_Next, ephemTab, (addr + 1)) Xsqlite3VdbeJumpHere(tls, v, addr) - Xsqlite3VdbeAddOp2(tls, v, 116, ephemTab, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Close, ephemTab, 0) } else { Xsqlite3WhereEnd(tls, pWInfo) } @@ -123434,16 +121204,16 @@ func Xsqlite3UpsertAnalyzeTarget(tls *libc.TLS, pParse uintptr, pTabList uintptr } // Check to see if the conflict target matches the rowid. - pTab = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FpTab + pTab = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FpTab pTarget = (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget - iCursor = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FiCursor - if (((((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) && + iCursor = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FiCursor + if (((((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((*ExprList)(unsafe.Pointer(pTarget)).FnExpr == 1)) && - (int32((*Expr)(unsafe.Pointer((libc.AssignUintptr(&pTerm, (*ExprList_item)(unsafe.Pointer((pTarget+8 /* &.a */)+uintptr(0)*32)).FpExpr)))).Fop) == 164)) && + (int32((*Expr)(unsafe.Pointer((libc.AssignUintptr(&pTerm, (*ExprList_item)(unsafe.Pointer((pTarget + 8 /* &.a */))).FpExpr)))).Fop) == TK_COLUMN)) && (int32((*Expr)(unsafe.Pointer(pTerm)).FiColumn) == (-1)) { // The conflict-target is the rowid of the primary table - return 0 + return SQLITE_OK } // Initialize sCol[0..1] to be an expression parse tree for a @@ -123452,17 +121222,17 @@ func Xsqlite3UpsertAnalyzeTarget(tls *libc.TLS, pParse uintptr, pTabList uintptr // will populate the specific collation and column number values // prior to comparing against the conflict-target expression. libc.Xmemset(tls, bp+56 /* &sCol[0] */, 0, uint64(unsafe.Sizeof([2]Expr{}))) - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(0)*72)).Fop = U8(111) - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(0)*72)).FpLeft = (bp + 56 /* &sCol */ + uintptr(1)*72) - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(1)*72)).Fop = U8(164) - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(1)*72)).FiTable = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FiCursor + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */)).Fop = TK_COLLATE + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */)).FpLeft = (bp + 56 /* &sCol */ + 1*72) + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + 1*72)).Fop = TK_COLUMN + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + 1*72)).FiTable = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FiCursor // Check for matches against other indexes for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { var ii int32 var jj int32 var nn int32 - if !(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0) { + if !(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None) { continue } if (*ExprList)(unsafe.Pointer(pTarget)).FnExpr != int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) { @@ -123480,18 +121250,18 @@ func Xsqlite3UpsertAnalyzeTarget(tls *libc.TLS, pParse uintptr, pTabList uintptr nn = int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) for ii = 0; ii < nn; ii++ { var pExpr uintptr - *(*uintptr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(0)*72 + 8 /* &.u */)) = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(ii)*8)) + *(*uintptr)(unsafe.Pointer(bp + 56 /* &sCol */ + 8 /* &.u */)) = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(ii)*8)) if int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2))) == (-2) { pExpr = (*ExprList_item)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FaColExpr + 8 /* &.a */) + uintptr(ii)*32)).FpExpr - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 111 { - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(0)*72)).FpLeft = pExpr - pExpr = (bp + 56 /* &sCol */ + uintptr(0)*72) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLLATE { + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */)).FpLeft = pExpr + pExpr = (bp + 56 /* &sCol */) } } else { - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(0)*72)).FpLeft = (bp + 56 /* &sCol */ + uintptr(1)*72) - (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + uintptr(1)*72)).FiColumn = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2)) - pExpr = (bp + 56 /* &sCol */ + uintptr(0)*72) + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */)).FpLeft = (bp + 56 /* &sCol */ + 1*72) + (*Expr)(unsafe.Pointer(bp + 56 /* &sCol */ + 1*72)).FiColumn = *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(ii)*2)) + pExpr = (bp + 56 /* &sCol */) } for jj = 0; jj < nn; jj++ { if Xsqlite3ExprCompare(tls, pParse, (*ExprList_item)(unsafe.Pointer((pTarget+8 /* &.a */)+uintptr(jj)*32)).FpExpr, pExpr, iCursor) < 2 { @@ -123509,11 +121279,11 @@ func Xsqlite3UpsertAnalyzeTarget(tls *libc.TLS, pParse uintptr, pTabList uintptr continue } (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx = pIdx - return 0 + return SQLITE_OK } Xsqlite3ErrorMsg(tls, pParse, ts+22041 /* "ON CONFLICT clau..." */, 0) - return 1 + return SQLITE_ERROR } // Generate bytecode that does an UPDATE as part of an upsert. @@ -123536,10 +121306,10 @@ func Xsqlite3UpsertDoUpdate(tls *libc.TLS, pParse uintptr, pUpsert uintptr, pTab Xsqlite3VdbeNoopComment(tls, v, ts+22112 /* "Begin DO UPDATE ..." */, 0) iDataCur = (*Upsert)(unsafe.Pointer(pUpsert)).FiDataCur if (pIdx != 0) && (iCur != iDataCur) { - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { var regRowid int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 134, iCur, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 31, iDataCur, 0, regRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_IdxRowid, iCur, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, iDataCur, 0, regRowid) Xsqlite3ReleaseTempReg(tls, pParse, regRowid) } else { @@ -123551,13 +121321,13 @@ func Xsqlite3UpsertDoUpdate(tls *libc.TLS, pParse uintptr, pUpsert uintptr, pTab var k int32 k = int32(Xsqlite3TableColumnToIndex(tls, pIdx, *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))) - Xsqlite3VdbeAddOp3(tls, v, 89, iCur, k, (iPk + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iCur, k, (iPk + i)) Xsqlite3VdbeComment(tls, v, ts+9997 /* "%s.%s" */, libc.VaList(bp, (*Index)(unsafe.Pointer(pIdx)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(i)*2)))*32)).FzName)) } - i = Xsqlite3VdbeAddOp4Int(tls, v, 30, iDataCur, 0, iPk, nPk) + i = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, iDataCur, 0, iPk, nPk) - Xsqlite3VdbeAddOp4(tls, v, 68, 11, 2, 0, + Xsqlite3VdbeAddOp4(tls, v, OP_Halt, SQLITE_CORRUPT, OE_Abort, 0, ts+13355 /* "corrupt database" */, -1) Xsqlite3MayAbort(tls, pParse) Xsqlite3VdbeJumpHere(tls, v, i) @@ -123568,12 +121338,12 @@ func Xsqlite3UpsertDoUpdate(tls *libc.TLS, pParse uintptr, pUpsert uintptr, pTab pSrc = Xsqlite3SrcListDup(tls, db, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc, 0) // excluded.* columns of type REAL need to be converted to a hard real for i = 0; i < int32((*Table)(unsafe.Pointer(pTab)).FnCol); i++ { - if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).Faffinity) == 0x45 { - Xsqlite3VdbeAddOp1(tls, v, 83, ((*Upsert)(unsafe.Pointer(pUpsert)).FregData + i)) + if int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*32)).Faffinity) == SQLITE_AFF_REAL { + Xsqlite3VdbeAddOp1(tls, v, OP_RealAffinity, ((*Upsert)(unsafe.Pointer(pUpsert)).FregData + i)) } } Xsqlite3Update(tls, pParse, pSrc, (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet, - (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere, 2, uintptr(0), uintptr(0), pUpsert) + (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere, OE_Abort, uintptr(0), uintptr(0), pUpsert) (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertSet = uintptr(0) // Will have been deleted by sqlite3Update() (*Upsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere = uintptr(0) // Will have been deleted by sqlite3Update() Xsqlite3VdbeNoopComment(tls, v, ts+22138 /* "End DO UPDATE of..." */, 0) @@ -123616,10 +121386,10 @@ func execSql(tls *libc.TLS, db uintptr, pzErrMsg uintptr, zSql uintptr) int32 { // printf("SQL: [%s]\n", zSql); fflush(stdout); rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp /* &pStmt */, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { return rc } - for 100 == (libc.AssignInt32(&rc, Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))))) { + for SQLITE_ROW == (libc.AssignInt32(&rc, Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))))) { var zSubSql uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 0) // The secondary SQL must be one of CREATE TABLE, CREATE INDEX, @@ -123630,14 +121400,14 @@ func execSql(tls *libc.TLS, db uintptr, pzErrMsg uintptr, zSql uintptr) int32 { if (zSubSql != 0) && ((libc.Xstrncmp(tls, zSubSql, ts+22162 /* "CRE" */, uint64(3)) == 0) || (libc.Xstrncmp(tls, zSubSql, ts+22166 /* "INS" */, uint64(3)) == 0)) { rc = execSql(tls, db, pzErrMsg, zSubSql) - if rc != 0 { + if rc != SQLITE_OK { break } } } - if rc == 101 { - rc = 0 + if rc == SQLITE_DONE { + rc = SQLITE_OK } if rc != 0 { Xsqlite3SetString(tls, pzErrMsg, db, Xsqlite3_errmsg(tls, db)) @@ -123655,7 +121425,7 @@ func execSqlF(tls *libc.TLS, db uintptr, pzErrMsg uintptr, zSql uintptr, va uint z = Xsqlite3VMPrintf(tls, db, zSql, ap) _ = ap if z == uintptr(0) { - return 7 + return SQLITE_NOMEM } rc = execSql(tls, db, pzErrMsg, z) Xsqlite3DbFree(tls, db, z) @@ -123737,7 +121507,7 @@ __3: Xsqlite3ExprCode(tls, pParse, pInto, iIntoReg) __6: ; - Xsqlite3VdbeAddOp2(tls, v, 8, iDb, iIntoReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Vacuum, iDb, iIntoReg) Xsqlite3VdbeUsesBtree(tls, v, iDb) __5: ; @@ -123772,37 +121542,37 @@ func Xsqlite3RunVacuum(tls *libc.TLS, pzErrMsg uintptr, db uintptr, iDb int32, p // var meta U32 at bp+48, 4 var i int32 - rc = 0 + rc = SQLITE_OK pDb = uintptr(0) // Name of output file if !(!(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0)) { goto __1 } Xsqlite3SetString(tls, pzErrMsg, db, ts+22170 /* "cannot VACUUM fr..." */) - return 1 // IMP: R-12218-18073 + return SQLITE_ERROR // IMP: R-12218-18073 __1: ; if !((*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive > 1) { goto __2 } Xsqlite3SetString(tls, pzErrMsg, db, ts+22210 /* "cannot VACUUM - ..." */) - return 1 // IMP: R-15610-35227 + return SQLITE_ERROR // IMP: R-15610-35227 __2: ; saved_openFlags = (*Sqlite3)(unsafe.Pointer(db)).FopenFlags if !(pOut != 0) { goto __3 } - if !(Xsqlite3_value_type(tls, pOut) != 3) { + if !(Xsqlite3_value_type(tls, pOut) != SQLITE_TEXT) { goto __5 } Xsqlite3SetString(tls, pzErrMsg, db, ts+22253 /* "non-text filenam..." */) - return 1 + return SQLITE_ERROR __5: ; zOut = Xsqlite3_value_text(tls, pOut) - *(*uint32)(unsafe.Pointer(db + 76 /* &.openFlags */)) &= (^libc.Uint32FromInt32(0x00000001)) - *(*uint32)(unsafe.Pointer(db + 76 /* &.openFlags */)) |= (uint32(0x00000004 | 0x00000002)) + *(*uint32)(unsafe.Pointer(db + 76 /* &.openFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SQLITE_OPEN_READONLY))) + *(*uint32)(unsafe.Pointer(db + 76 /* &.openFlags */)) |= (uint32(SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)) goto __4 __3: zOut = ts + 800 /* "" */ @@ -123817,10 +121587,10 @@ __4: saved_nChange = (*Sqlite3)(unsafe.Pointer(db)).FnChange saved_nTotalChange = (*Sqlite3)(unsafe.Pointer(db)).FnTotalChange saved_mTrace = (*Sqlite3)(unsafe.Pointer(db)).FmTrace - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(0x00000001 | 0x00000200)) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0002 | 0x0004)) - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(((uint64((0x00004000 | 0x00001000) | - 0x10000000)) | (U64((uint64(0x00001))) << 32)))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(SQLITE_WriteSchema | SQLITE_IgnoreChecks)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(DBFLAG_PreferBuiltin | DBFLAG_Vacuum)) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(((uint64((SQLITE_ForeignKeys | SQLITE_ReverseOrder) | + SQLITE_Defensive)) | (U64((uint64(0x00001))) << 32)))) (*Sqlite3)(unsafe.Pointer(db)).FmTrace = U8(0) zDbMain = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName @@ -123843,7 +121613,7 @@ __4: nDb = (*Sqlite3)(unsafe.Pointer(db)).FnDb rc = execSqlF(tls, db, pzErrMsg, ts+22271 /* "ATTACH %Q AS vac..." */, libc.VaList(bp, zOut)) (*Sqlite3)(unsafe.Pointer(db)).FopenFlags = saved_openFlags - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __6 } goto end_of_vacuum @@ -123858,28 +121628,28 @@ __6: } id = Xsqlite3PagerFile(tls, Xsqlite3BtreePager(tls, pTemp)) *(*I64)(unsafe.Pointer(bp + 40 /* sz */)) = int64(0) - if !(((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods != uintptr(0)) && ((Xsqlite3OsFileSize(tls, id, bp+40 /* &sz */) != 0) || (*(*I64)(unsafe.Pointer(bp + 40 /* sz */)) > int64(0)))) { + if !(((*Sqlite3_file)(unsafe.Pointer(id)).FpMethods != uintptr(0)) && ((Xsqlite3OsFileSize(tls, id, bp+40 /* &sz */) != SQLITE_OK) || (*(*I64)(unsafe.Pointer(bp + 40 /* sz */)) > int64(0)))) { goto __8 } - rc = 1 + rc = SQLITE_ERROR Xsqlite3SetString(tls, pzErrMsg, db, ts+22294 /* "output file alre..." */) goto end_of_vacuum __8: ; - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (U32(0x0008)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) |= (DBFLAG_VacuumInto) __7: ; nRes = Xsqlite3BtreeGetRequestedReserve(tls, pMain) Xsqlite3BtreeSetCacheSize(tls, pTemp, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FpSchema)).Fcache_size) Xsqlite3BtreeSetSpillSize(tls, pTemp, Xsqlite3BtreeSetSpillSize(tls, pMain, 0)) - Xsqlite3BtreeSetPagerFlags(tls, pTemp, (uint32(0x01 | 0x20))) + Xsqlite3BtreeSetPagerFlags(tls, pTemp, (uint32(PAGER_SYNCHRONOUS_OFF | PAGER_CACHESPILL))) // Begin a transaction and take an exclusive lock on the main database // file. This is done before the sqlite3BtreeGetPageSize(pMain) call below, // to ensure that we do not try to change the page-size on a WAL database. rc = execSql(tls, db, pzErrMsg, ts+15585 /* "BEGIN" */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __9 } goto end_of_vacuum @@ -123891,7 +121661,7 @@ __9: } return 0 }(), uintptr(0)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __10 } goto end_of_vacuum @@ -123900,7 +121670,7 @@ __10: // Do not attempt to change the page size for a WAL database if !(Xsqlite3PagerGetJournalMode(tls, Xsqlite3BtreePager(tls, pMain)) == - 5) { + PAGER_JOURNALMODE_WAL) { goto __11 } (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize = 0 @@ -123912,7 +121682,7 @@ __11: ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0)) { goto __12 } - rc = 7 + rc = SQLITE_NOMEM goto end_of_vacuum __12: ; @@ -123931,7 +121701,7 @@ __12: ts+22321, /* "SELECT sql FROM ..." */ libc.VaList(bp+8, zDbMain)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __13 } goto end_of_vacuum @@ -123941,7 +121711,7 @@ __13: ts+22429, /* "SELECT sql FROM ..." */ libc.VaList(bp+16, zDbMain)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __14 } goto end_of_vacuum @@ -123957,8 +121727,8 @@ __14: ts+22483, /* "SELECT'INSERT IN..." */ libc.VaList(bp+24, zDbMain)) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (^libc.Uint32FromInt32(0x0004)) - if !(rc != 0) { + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(DBFLAG_Vacuum))) + if !(rc != SQLITE_OK) { goto __15 } goto end_of_vacuum @@ -123997,7 +121767,7 @@ __17: // we already have page 1 loaded into cache and marked dirty. Xsqlite3BtreeGetMeta(tls, pMain, int32(aCopy[i]), bp+48 /* &meta */) rc = Xsqlite3BtreeUpdateMeta(tls, pTemp, int32(aCopy[i]), (*(*U32)(unsafe.Pointer(bp + 48 /* meta */)) + U32(aCopy[(i+1)]))) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __20 } goto end_of_vacuum @@ -124017,14 +121787,14 @@ __19: rc = Xsqlite3BtreeCopyFile(tls, pMain, pTemp) __21: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __22 } goto end_of_vacuum __22: ; rc = Xsqlite3BtreeCommit(tls, pTemp) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __23 } goto end_of_vacuum @@ -124079,11 +121849,11 @@ __26: } var aCopy = [10]uint8{ - uint8(1), uint8(1), // Add one to the old schema cookie - uint8(3), uint8(0), // Preserve the default page cache size - uint8(5), uint8(0), // Preserve the text encoding - uint8(6), uint8(0), // Preserve the user version - uint8(8), uint8(0), // Preserve the application id + BTREE_SCHEMA_VERSION, uint8(1), // Add one to the old schema cookie + BTREE_DEFAULT_CACHE_SIZE, uint8(0), // Preserve the default page cache size + BTREE_TEXT_ENCODING, uint8(0), // Preserve the text encoding + BTREE_USER_VERSION, uint8(0), // Preserve the user version + BTREE_APPLICATION_ID, uint8(0), // Preserve the application id } /* sqlite3.c:139504:32 */ // Construct and install a Module object for a virtual table. When this @@ -124106,7 +121876,7 @@ func Xsqlite3VtabCreateModule(tls *libc.TLS, db uintptr, zName uintptr, pModule Xsqlite3OomFault(tls, db) return uintptr(0) } - zCopy = (pMod + uintptr(1)*48) + zCopy = (pMod + 1*48) libc.Xmemcpy(tls, zCopy, zName, (uint64(nName + 1))) (*Module)(unsafe.Pointer(pMod)).FzName = zCopy (*Module)(unsafe.Pointer(pMod)).FpModule = pModule @@ -124133,12 +121903,12 @@ func Xsqlite3VtabCreateModule(tls *libc.TLS, db uintptr, zName uintptr, pModule // This function implements the sqlite3_create_module() and // sqlite3_create_module_v2() interfaces. func createModule(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr, xDestroy uintptr) int32 { /* sqlite3.c:139664:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) Xsqlite3VtabCreateModule(tls, db, zName, pModule, pAux, xDestroy) rc = Xsqlite3ApiExit(tls, db, rc) - if (rc != 0) && (xDestroy != 0) { + if (rc != SQLITE_OK) && (xDestroy != 0) { (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&xDestroy)))(tls, pAux) } Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -124173,7 +121943,7 @@ func Xsqlite3_drop_modules(tls *libc.TLS, db uintptr, azNames uintptr) int32 { / } createModule(tls, db, (*Module)(unsafe.Pointer(pMod)).FzName, uintptr(0), uintptr(0), uintptr(0)) } - return 0 + return SQLITE_OK } // Decrement the reference count on a Module object. Destroy the @@ -124350,7 +122120,7 @@ func addModuleArgument(tls *libc.TLS, pParse uintptr, pTable uintptr, zArg uintp var nBytes Sqlite3_int64 = (Sqlite3_int64(uint64(unsafe.Sizeof(uintptr(0))) * (uint64(2 + (*Table)(unsafe.Pointer(pTable)).FnModuleArg)))) var azModuleArg uintptr var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if ((*Table)(unsafe.Pointer(pTable)).FnModuleArg + 3) >= *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(2)*4)) { + if ((*Table)(unsafe.Pointer(pTable)).FnModuleArg + 3) >= *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 2*4)) { Xsqlite3ErrorMsg(tls, pParse, ts+13534 /* "too many columns..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTable)).FzName)) } azModuleArg = Xsqlite3DbRealloc(tls, db, (*Table)(unsafe.Pointer(pTable)).FazModuleArg, uint64(nBytes)) @@ -124392,8 +122162,8 @@ func Xsqlite3VtabBeginParse(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName if (*Table)(unsafe.Pointer(pTable)).FazModuleArg != 0 { var iDb int32 = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTable)).FpSchema) // The database the table is being created in - Xsqlite3AuthCheck(tls, pParse, 29, (*Table)(unsafe.Pointer(pTable)).FzName, - *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTable)).FazModuleArg + uintptr(0)*8)), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb+uintptr(iDb)*32)).FzDbSName) + Xsqlite3AuthCheck(tls, pParse, SQLITE_CREATE_VTABLE, (*Table)(unsafe.Pointer(pTable)).FzName, + *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTable)).FazModuleArg)), (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FaDb+uintptr(iDb)*32)).FzDbSName) } } @@ -124466,14 +122236,14 @@ func Xsqlite3VtabFinishParse(tls *libc.TLS, pParse uintptr, pEnd uintptr) { /* s v = Xsqlite3GetVdbe(tls, pParse) Xsqlite3ChangeCookie(tls, pParse, iDb) - Xsqlite3VdbeAddOp0(tls, v, 158) + Xsqlite3VdbeAddOp0(tls, v, OP_Expire) zWhere = Xsqlite3MPrintf(tls, db, ts+22887 /* "name=%Q AND sql=..." */, libc.VaList(bp+48, (*Table)(unsafe.Pointer(pTab)).FzName, zStmt)) Xsqlite3VdbeAddParseSchemaOp(tls, v, iDb, zWhere) Xsqlite3DbFree(tls, db, zStmt) iReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) Xsqlite3VdbeLoadString(tls, v, iReg, (*Table)(unsafe.Pointer(pTab)).FzName) - Xsqlite3VdbeAddOp2(tls, v, 163, iDb, iReg) + Xsqlite3VdbeAddOp2(tls, v, OP_VCreate, iDb, iReg) } else { var pOld uintptr var pSchema uintptr = (*Table)(unsafe.Pointer(pTab)).FpSchema @@ -124533,27 +122303,27 @@ func vtabCallConstructor(tls *libc.TLS, db uintptr, pTab uintptr, pMod uintptr, if (*VtabCtx)(unsafe.Pointer(pCtx)).FpTab == pTab { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db, ts+22906 /* "vtable construct..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName)) - return 6 + return SQLITE_LOCKED } } zModuleName = Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pTab)).FzName) if !(zModuleName != 0) { - return 7 + return SQLITE_NOMEM } pVTable = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(VTable{}))) if !(pVTable != 0) { Xsqlite3OomFault(tls, db) Xsqlite3DbFree(tls, db, zModuleName) - return 7 + return SQLITE_NOMEM } (*VTable)(unsafe.Pointer(pVTable)).Fdb = db (*VTable)(unsafe.Pointer(pVTable)).FpMod = pMod - (*VTable)(unsafe.Pointer(pVTable)).FeVtabRisk = U8(1) + (*VTable)(unsafe.Pointer(pVTable)).FeVtabRisk = SQLITE_VTABRISK_Normal iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) - *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg + uintptr(1)*8)) = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName + *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg + 1*8)) = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FzDbSName // Invoke the virtual table constructor @@ -124564,11 +122334,11 @@ func vtabCallConstructor(tls *libc.TLS, db uintptr, pTab uintptr, pMod uintptr, (*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx = bp + 32 /* &sCtx */ rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&xConstruct)))(tls, db, (*Module)(unsafe.Pointer(pMod)).FpAux, nArg, azArg, (pVTable + 16 /* &.pVtab */), bp+64 /* &zErr */) (*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx = (*VtabCtx)(unsafe.Pointer(bp + 32 /* &sCtx */)).FpPrior - if rc == 7 { + if rc == SQLITE_NOMEM { Xsqlite3OomFault(tls, db) } - if 0 != rc { + if SQLITE_OK != rc { if *(*uintptr)(unsafe.Pointer(bp + 64 /* zErr */)) == uintptr(0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db, ts+22948 /* "vtable construct..." */, libc.VaList(bp+8, zModuleName)) } else { @@ -124587,7 +122357,7 @@ func vtabCallConstructor(tls *libc.TLS, db uintptr, pTab uintptr, pMod uintptr, var zFormat uintptr = ts + 22978 /* "vtable construct..." */ *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db, zFormat, libc.VaList(bp+24, (*Table)(unsafe.Pointer(pTab)).FzName)) Xsqlite3VtabUnlock(tls, pVTable) - rc = 1 + rc = SQLITE_ERROR } else { var iCol int32 var oooHidden U16 = U16(0) @@ -124626,8 +122396,8 @@ func vtabCallConstructor(tls *libc.TLS, db uintptr, pTab uintptr, pMod uintptr, *(*int8)(unsafe.Pointer(zType + uintptr((i - 1)))) = int8(0) } - *(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*32 + 28 /* &.colFlags */)) |= U16((0x0002)) - oooHidden = U16(0x0400) + *(*U16)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*32 + 28 /* &.colFlags */)) |= U16((COLFLAG_HIDDEN)) + oooHidden = TF_OOOHidden } else { *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(oooHidden)) } @@ -124654,21 +122424,21 @@ func Xsqlite3VtabCallConnect(tls *libc.TLS, pParse uintptr, pTab uintptr) int32 var rc int32 if !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) || (Xsqlite3GetVTable(tls, db, pTab) != 0) { - return 0 + return SQLITE_OK } // Locate the required virtual table module - zMod = *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg + uintptr(0)*8)) + zMod = *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg)) pMod = Xsqlite3HashFind(tls, (db + 528 /* &.aModule */), zMod) if !(pMod != 0) { - var zModule uintptr = *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg + uintptr(0)*8)) + var zModule uintptr = *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg)) Xsqlite3ErrorMsg(tls, pParse, ts+23024 /* "no such module: ..." */, libc.VaList(bp, zModule)) - rc = 1 + rc = SQLITE_ERROR } else { *(*uintptr)(unsafe.Pointer(bp + 16 /* zErr */)) = uintptr(0) rc = vtabCallConstructor(tls, db, pTab, pMod, (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxConnect, bp+16 /* &zErr */) - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3ErrorMsg(tls, pParse, ts+824 /* "%s" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(bp + 16 /* zErr */)))) (*Parse)(unsafe.Pointer(pParse)).Frc = rc } @@ -124689,13 +122459,13 @@ func growVTrans(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:140294:12: */ var nBytes Sqlite3_int64 = (Sqlite3_int64(uint64(unsafe.Sizeof(uintptr(0))) * (uint64(Sqlite3_int64((*Sqlite3)(unsafe.Pointer(db)).FnVTrans) + Sqlite3_int64(ARRAY_INCR))))) aVTrans = Xsqlite3DbRealloc(tls, db, (*Sqlite3)(unsafe.Pointer(db)).FaVTrans, uint64(nBytes)) if !(aVTrans != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, (aVTrans + uintptr((*Sqlite3)(unsafe.Pointer(db)).FnVTrans)*8), 0, (uint64(unsafe.Sizeof(uintptr(0))) * uint64(ARRAY_INCR))) (*Sqlite3)(unsafe.Pointer(db)).FaVTrans = aVTrans } - return 0 + return SQLITE_OK } // Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should @@ -124716,7 +122486,7 @@ func Xsqlite3VtabCallCreate(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr, bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var pTab uintptr var pMod uintptr var zMod uintptr @@ -124724,7 +122494,7 @@ func Xsqlite3VtabCallCreate(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr, pTab = Xsqlite3FindTable(tls, db, zTab, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) // Locate the required virtual table module - zMod = *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg + uintptr(0)*8)) + zMod = *(*uintptr)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FazModuleArg)) pMod = Xsqlite3HashFind(tls, (db + 528 /* &.aModule */), zMod) // If the module has been registered and includes a Create method, @@ -124732,16 +122502,16 @@ func Xsqlite3VtabCallCreate(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr, // error. Otherwise, do nothing. if ((pMod == uintptr(0)) || ((*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxCreate == uintptr(0))) || ((*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxDestroy == uintptr(0)) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3MPrintf(tls, db, ts+23024 /* "no such module: ..." */, libc.VaList(bp, zMod)) - rc = 1 + rc = SQLITE_ERROR } else { rc = vtabCallConstructor(tls, db, pTab, pMod, (*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer(pMod)).FpModule)).FxCreate, pzErr) } // Justification of ALWAYS(): The xConstructor method is required to // create a valid sqlite3_vtab if it returns SQLITE_OK. - if (rc == 0) && (Xsqlite3GetVTable(tls, db, pTab) != 0) { + if (rc == SQLITE_OK) && (Xsqlite3GetVTable(tls, db, pTab) != 0) { rc = growVTrans(tls, db) - if rc == 0 { + if rc == SQLITE_OK { addToVTrans(tls, db, Xsqlite3GetVTable(tls, db, pTab)) } } @@ -124757,7 +122527,7 @@ func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) int3 defer tls.Free(440) var pCtx uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK var pTab uintptr *(*uintptr)(unsafe.Pointer(bp + 432 /* zErr */)) = uintptr(0) // var sParse Parse at bp+8, 424 @@ -124765,17 +122535,17 @@ func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) int3 Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) pCtx = (*Sqlite3)(unsafe.Pointer(db)).FpVtabCtx if !(pCtx != 0) || ((*VtabCtx)(unsafe.Pointer(pCtx)).FbDeclared != 0) { - Xsqlite3Error(tls, db, 21) + Xsqlite3Error(tls, db, SQLITE_MISUSE) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) return Xsqlite3MisuseError(tls, 140389) } pTab = (*VtabCtx)(unsafe.Pointer(pCtx)).FpTab libc.Xmemset(tls, bp+8 /* &sParse */, 0, uint64(unsafe.Sizeof(Parse{}))) - (*Parse)(unsafe.Pointer(bp + 8 /* &sParse */)).FeParseMode = U8(1) + (*Parse)(unsafe.Pointer(bp + 8 /* &sParse */)).FeParseMode = PARSE_MODE_DECLARE_VTAB (*Parse)(unsafe.Pointer(bp + 8 /* &sParse */)).Fdb = db (*Parse)(unsafe.Pointer(bp + 8 /* &sParse */)).FnQueryLoop = U32(1) - if ((((0 == Xsqlite3RunParser(tls, bp+8 /* &sParse */, zCreateTable, bp+432 /* &zErr */)) && + if ((((SQLITE_OK == Xsqlite3RunParser(tls, bp+8 /* &sParse */, zCreateTable, bp+432 /* &zErr */)) && ((*Parse)(unsafe.Pointer(bp+8 /* &sParse */)).FpNewTable != 0)) && !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0)) && !(int32((*Table)(unsafe.Pointer((*Parse)(unsafe.Pointer(bp+8 /* &sParse */)).FpNewTable)).FpSelect) != 0)) && @@ -124785,16 +122555,16 @@ func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) int3 var pIdx uintptr (*Table)(unsafe.Pointer(pTab)).FaCol = (*Table)(unsafe.Pointer(pNew)).FaCol (*Table)(unsafe.Pointer(pTab)).FnCol = (*Table)(unsafe.Pointer(pNew)).FnCol - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= ((*Table)(unsafe.Pointer(pNew)).FtabFlags & (U32(0x0080 | 0x0200))) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= ((*Table)(unsafe.Pointer(pNew)).FtabFlags & (U32(TF_WithoutRowid | TF_NoVisibleRowid))) (*Table)(unsafe.Pointer(pNew)).FnCol = int16(0) (*Table)(unsafe.Pointer(pNew)).FaCol = uintptr(0) - if (!(((*Table)(unsafe.Pointer((pNew))).FtabFlags & U32(0x0080)) == U32(0)) && + if (!(((*Table)(unsafe.Pointer((pNew))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((*Sqlite3_module)(unsafe.Pointer((*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(pCtx)).FpVTable)).FpMod)).FpModule)).FxUpdate != uintptr(0))) && (int32((*Index)(unsafe.Pointer(Xsqlite3PrimaryKeyIndex(tls, pNew))).FnKeyCol) != 1) { // WITHOUT ROWID virtual tables must either be read-only (xUpdate==0) // or else must have a single-column PRIMARY KEY - rc = 1 + rc = SQLITE_ERROR } pIdx = (*Table)(unsafe.Pointer(pNew)).FpIndex if pIdx != 0 { @@ -124806,16 +122576,16 @@ func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) int3 } (*VtabCtx)(unsafe.Pointer(pCtx)).FbDeclared = 1 } else { - Xsqlite3ErrorWithMsg(tls, db, 1, func() uintptr { + Xsqlite3ErrorWithMsg(tls, db, SQLITE_ERROR, func() uintptr { if *(*uintptr)(unsafe.Pointer(bp + 432 /* zErr */)) != 0 { return ts + 824 /* "%s" */ } return uintptr(0) }(), libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 432 /* zErr */)))) Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 432 /* zErr */))) - rc = 1 + rc = SQLITE_ERROR } - (*Parse)(unsafe.Pointer(bp + 8 /* &sParse */)).FeParseMode = U8(0) + (*Parse)(unsafe.Pointer(bp + 8 /* &sParse */)).FeParseMode = PARSE_MODE_NORMAL if (*Parse)(unsafe.Pointer(bp+8 /* &sParse */)).FpVdbe != 0 { Xsqlite3VdbeFinalize(tls, (*Parse)(unsafe.Pointer(bp+8 /* &sParse */)).FpVdbe) @@ -124834,7 +122604,7 @@ func Xsqlite3_declare_vtab(tls *libc.TLS, db uintptr, zCreateTable uintptr) int3 // // This call is a no-op if zTab is not a virtual table. func Xsqlite3VtabCallDestroy(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr) int32 { /* sqlite3.c:140457:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pTab uintptr pTab = Xsqlite3FindTable(tls, db, zTab, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(iDb)*32)).FzDbSName) @@ -124844,7 +122614,7 @@ func Xsqlite3VtabCallDestroy(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr) for p = (*Table)(unsafe.Pointer(pTab)).FpVTable; p != 0; p = (*VTable)(unsafe.Pointer(p)).FpNext { if (*Sqlite3_vtab)(unsafe.Pointer((*VTable)(unsafe.Pointer(p)).FpVtab)).FnRef > 0 { - return 6 + return SQLITE_LOCKED } } p = vtabDisconnectAll(tls, db, pTab) @@ -124856,7 +122626,7 @@ func Xsqlite3VtabCallDestroy(tls *libc.TLS, db uintptr, iDb int32, zTab uintptr) (*Table)(unsafe.Pointer(pTab)).FnTabRef++ rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&xDestroy)))(tls, (*VTable)(unsafe.Pointer(p)).FpVtab) // Remove the sqlite3_vtab* from the aVTrans[] array, if applicable - if rc == 0 { + if rc == SQLITE_OK { (*VTable)(unsafe.Pointer(p)).FpVtab = uintptr(0) (*Table)(unsafe.Pointer(pTab)).FpVTable = uintptr(0) @@ -124904,11 +122674,11 @@ func callFinaliser(tls *libc.TLS, db uintptr, offset int32) { /* sqlite3.c:14049 // If an error message is available, leave it in p->zErrMsg. func Xsqlite3VtabSync(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c:140526:20: */ var i int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var aVTrans uintptr = (*Sqlite3)(unsafe.Pointer(db)).FaVTrans (*Sqlite3)(unsafe.Pointer(db)).FaVTrans = uintptr(0) - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans); i++ { var x uintptr var pVtab uintptr = (*VTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aVTrans + uintptr(i)*8)))).FpVtab if (pVtab != 0) && ((libc.AssignUintptr(&x, (*Sqlite3_module)(unsafe.Pointer((*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule)).FxSync)) != uintptr(0)) { @@ -124924,14 +122694,14 @@ func Xsqlite3VtabSync(tls *libc.TLS, db uintptr, p uintptr) int32 { /* sqlite3.c // sqlite3.aVTrans array. Then clear the array itself. func Xsqlite3VtabRollback(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:140548:20: */ callFinaliser(tls, db, int32((uintptr(0) + 136 /* &.xRollback */))) - return 0 + return SQLITE_OK } // Invoke the xCommit method of all virtual tables in the // sqlite3.aVTrans array. Then clear the array itself. func Xsqlite3VtabCommit(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:140557:20: */ callFinaliser(tls, db, int32((uintptr(0) + 128 /* &.xCommit */))) - return 0 + return SQLITE_OK } // If the virtual table pVtab supports the transaction interface @@ -124941,7 +122711,7 @@ func Xsqlite3VtabCommit(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:140557:2 // If the xBegin call is successful, place the sqlite3_vtab pointer // in the sqlite3.aVTrans array. func Xsqlite3VtabBegin(tls *libc.TLS, db uintptr, pVTab uintptr) int32 { /* sqlite3.c:140570:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pModule uintptr // Special case: If db->aVTrans is NULL and db->nVTrans is greater @@ -124949,10 +122719,10 @@ func Xsqlite3VtabBegin(tls *libc.TLS, db uintptr, pVTab uintptr) int32 { /* sqli // virtual module xSync() callback. It is illegal to write to // virtual module tables in this case, so return SQLITE_LOCKED. if ((*Sqlite3)(unsafe.Pointer((db))).FnVTrans > 0) && ((*Sqlite3)(unsafe.Pointer((db))).FaVTrans == uintptr(0)) { - return 6 + return SQLITE_LOCKED } if !(pVTab != 0) { - return 0 + return SQLITE_OK } pModule = (*Sqlite3_vtab)(unsafe.Pointer((*VTable)(unsafe.Pointer(pVTab)).FpVtab)).FpModule @@ -124962,16 +122732,16 @@ func Xsqlite3VtabBegin(tls *libc.TLS, db uintptr, pVTab uintptr) int32 { /* sqli // If pVtab is already in the aVTrans array, return early for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans; i++ { if *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaVTrans + uintptr(i)*8)) == pVTab { - return 0 + return SQLITE_OK } } // Invoke the xBegin method. If successful, add the vtab to the // sqlite3.aVTrans[] array. rc = growVTrans(tls, db) - if rc == 0 { + if rc == SQLITE_OK { rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((pModule + 112 /* &.xBegin */))))(tls, (*VTable)(unsafe.Pointer(pVTab)).FpVtab) - if rc == 0 { + if rc == SQLITE_OK { var iSvpt int32 = ((*Sqlite3)(unsafe.Pointer(db)).FnStatement + (*Sqlite3)(unsafe.Pointer(db)).FnSavepoint) addToVTrans(tls, db, pVTab) if (iSvpt != 0) && ((*Sqlite3_module)(unsafe.Pointer(pModule)).FxSavepoint != 0) { @@ -124998,23 +122768,23 @@ func Xsqlite3VtabBegin(tls *libc.TLS, db uintptr, pVTab uintptr) int32 { /* sqli // function immediately. If all calls to virtual table methods are successful, // SQLITE_OK is returned. func Xsqlite3VtabSavepoint(tls *libc.TLS, db uintptr, op int32, iSavepoint int32) int32 { /* sqlite3.c:140630:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Sqlite3)(unsafe.Pointer(db)).FaVTrans != 0 { var i int32 - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnVTrans); i++ { var pVTab uintptr = *(*uintptr)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaVTrans + uintptr(i)*8)) var pMod uintptr = (*Module)(unsafe.Pointer((*VTable)(unsafe.Pointer(pVTab)).FpMod)).FpModule if ((*VTable)(unsafe.Pointer(pVTab)).FpVtab != 0) && ((*Sqlite3_module)(unsafe.Pointer(pMod)).FiVersion >= 2) { var xMethod uintptr Xsqlite3VtabLock(tls, pVTab) switch op { - case 0: + case SAVEPOINT_BEGIN: xMethod = (*Sqlite3_module)(unsafe.Pointer(pMod)).FxSavepoint (*VTable)(unsafe.Pointer(pVTab)).FiSavepoint = (iSavepoint + 1) break fallthrough - case 2: + case SAVEPOINT_ROLLBACK: xMethod = (*Sqlite3_module)(unsafe.Pointer(pMod)).FxRollbackTo break fallthrough @@ -125059,7 +122829,7 @@ func Xsqlite3VtabOverloadFunction(tls *libc.TLS, db uintptr, pDef uintptr, nArg if pExpr == uintptr(0) { return pDef } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 164 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN { return pDef } pTab = *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) @@ -125095,11 +122865,11 @@ func Xsqlite3VtabOverloadFunction(tls *libc.TLS, db uintptr, pDef uintptr, nArg return pDef } *(*FuncDef)(unsafe.Pointer(pNew)) = *(*FuncDef)(unsafe.Pointer(pDef)) - (*FuncDef)(unsafe.Pointer(pNew)).FzName = (pNew + uintptr(1)*72) - libc.Xmemcpy(tls, (pNew + uintptr(1)*72), (*FuncDef)(unsafe.Pointer(pDef)).FzName, (uint64(Xsqlite3Strlen30(tls, (*FuncDef)(unsafe.Pointer(pDef)).FzName) + 1))) + (*FuncDef)(unsafe.Pointer(pNew)).FzName = (pNew + 1*72) + libc.Xmemcpy(tls, (pNew + 1*72), (*FuncDef)(unsafe.Pointer(pDef)).FzName, (uint64(Xsqlite3Strlen30(tls, (*FuncDef)(unsafe.Pointer(pDef)).FzName) + 1))) (*FuncDef)(unsafe.Pointer(pNew)).FxSFunc = *(*uintptr)(unsafe.Pointer(bp /* xSFunc */)) (*FuncDef)(unsafe.Pointer(pNew)).FpUserData = *(*uintptr)(unsafe.Pointer(bp + 8 /* pArg */)) - *(*U32)(unsafe.Pointer(pNew + 4 /* &.funcFlags */)) |= (U32(0x0010)) + *(*U32)(unsafe.Pointer(pNew + 4 /* &.funcFlags */)) |= (SQLITE_FUNC_EPHEM) return pNew } @@ -125171,7 +122941,7 @@ func Xsqlite3VtabEponymousTableInit(tls *libc.TLS, pParse uintptr, pMod uintptr) } (*Module)(unsafe.Pointer(pMod)).FpEpoTab = pTab (*Table)(unsafe.Pointer(pTab)).FnTabRef = U32(1) - (*Table)(unsafe.Pointer(pTab)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FpSchema + (*Table)(unsafe.Pointer(pTab)).FpSchema = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema (*Table)(unsafe.Pointer(pTab)).FiPKey = int16(-1) addModuleArgument(tls, pParse, pTab, Xsqlite3DbStrDup(tls, db, (*Table)(unsafe.Pointer(pTab)).FzName)) @@ -125195,7 +122965,7 @@ func Xsqlite3VtabEponymousTableClear(tls *libc.TLS, db uintptr, pMod uintptr) { // Mark the table as Ephemeral prior to deleting it, so that the // sqlite3DeleteTable() routine will know that it is not stored in // the schema. - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0002)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (TF_Ephemeral) Xsqlite3DeleteTable(tls, db, pTab) (*Module)(unsafe.Pointer(pMod)).FpEpoTab = uintptr(0) } @@ -125212,7 +122982,7 @@ func Xsqlite3_vtab_on_conflict(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:1 } var aMap = [5]uint8{ - uint8(1), uint8(4), uint8(3), uint8(2), uint8(5), + SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE, } /* sqlite3.c:140837:30 */ // Call from within the xCreate() or xConnect() methods to provide @@ -125221,7 +122991,7 @@ var aMap = [5]uint8{ func Xsqlite3_vtab_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 { /* sqlite3.c:140854:16: */ var ap Va_list _ = ap - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -125232,23 +123002,23 @@ func Xsqlite3_vtab_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 ap = va switch op { - case 1: + case SQLITE_VTAB_CONSTRAINT_SUPPORT: { (*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FbConstraint = U8(libc.VaInt32(&ap)) break } fallthrough - case 2: + case SQLITE_VTAB_INNOCUOUS: { - (*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FeVtabRisk = U8(0) + (*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FeVtabRisk = SQLITE_VTABRISK_Low break } fallthrough - case 3: + case SQLITE_VTAB_DIRECTONLY: { - (*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FeVtabRisk = U8(2) + (*VTable)(unsafe.Pointer((*VtabCtx)(unsafe.Pointer(p)).FpVTable)).FeVtabRisk = SQLITE_VTABRISK_High break } @@ -125263,7 +123033,7 @@ func Xsqlite3_vtab_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 _ = ap } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3Error(tls, db, rc) } Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -125608,7 +123378,7 @@ func explainIndexRange(tls *libc.TLS, pStr uintptr, pLoop uintptr) { /* sqlite3. var i int32 var j int32 - if (int32(nEq) == 0) && (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(0x00000020 | 0x00000010))) == U32(0)) { + if (int32(nEq) == 0) && (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(WHERE_BTM_LIMIT | WHERE_TOP_LIMIT))) == U32(0)) { return } Xsqlite3_str_append(tls, pStr, ts+23058 /* " (" */, 2) @@ -125626,11 +123396,11 @@ func explainIndexRange(tls *libc.TLS, pStr uintptr, pLoop uintptr) { /* sqlite3. } j = i - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000020)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_BTM_LIMIT) != 0 { explainAppendTerm(tls, pStr, pIndex, int32(*(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 2 /* &.nBtm */))), j, i, ts+23074 /* ">" */) i = 1 } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000010)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_TOP_LIMIT) != 0 { explainAppendTerm(tls, pStr, pIndex, int32(*(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 4 /* &.nTop */))), j, i, ts+23076 /* "<" */) } Xsqlite3_str_append(tls, pStr, ts+6671 /* ")" */, 1) @@ -125668,15 +123438,15 @@ func Xsqlite3WhereExplainOneScan(tls *libc.TLS, pParse uintptr, pTabList uintptr pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop flags = (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags - if ((flags & U32(0x00002000)) != 0) || ((int32(wctrlFlags) & 0x0020) != 0) { + if ((flags & WHERE_MULTI_OR) != 0) || ((int32(wctrlFlags) & WHERE_OR_SUBCLAUSE) != 0) { return 0 } - isSearch = (libc.Bool32((((flags & (U32(0x00000020 | 0x00000010))) != U32(0)) || - (((flags & U32(0x00000400)) == U32(0)) && (int32(*(*U16)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.btree */) /* &.nEq */))) > 0))) || - ((int32(wctrlFlags) & (0x0001 | 0x0002)) != 0))) + isSearch = (libc.Bool32((((flags & (U32(WHERE_BTM_LIMIT | WHERE_TOP_LIMIT))) != U32(0)) || + (((flags & WHERE_VIRTUALTABLE) == U32(0)) && (int32(*(*U16)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.btree */) /* &.nEq */))) > 0))) || + ((int32(wctrlFlags) & (WHERE_ORDERBY_MIN | WHERE_ORDERBY_MAX)) != 0))) - Xsqlite3StrAccumInit(tls, bp+56 /* &str */, db, bp+88 /* &zBuf[0] */, int32(unsafe.Sizeof([100]int8{})), 1000000000) + Xsqlite3StrAccumInit(tls, bp+56 /* &str */, db, bp+88 /* &zBuf[0] */, int32(unsafe.Sizeof([100]int8{})), SQLITE_MAX_LENGTH) Xsqlite3_str_appendall(tls, bp+56 /* &str */, func() uintptr { if isSearch != 0 { return ts + 23078 /* "SEARCH" */ @@ -125692,21 +123462,21 @@ func Xsqlite3WhereExplainOneScan(tls *libc.TLS, pParse uintptr, pTabList uintptr if (*SrcList_item)(unsafe.Pointer(pItem)).FzAlias != 0 { Xsqlite3_str_appendf(tls, bp+56 /* &str */, ts+23113 /* " AS %s" */, libc.VaList(bp+16, (*SrcList_item)(unsafe.Pointer(pItem)).FzAlias)) } - if (flags & (U32(0x00000100 | 0x00000400))) == U32(0) { + if (flags & (U32(WHERE_IPK | WHERE_VIRTUALTABLE))) == U32(0) { var zFmt uintptr = uintptr(0) var pIdx uintptr pIdx = *(*uintptr)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) - if !(((*Table)(unsafe.Pointer(((*SrcList_item)(unsafe.Pointer(pItem)).FpTab))).FtabFlags & U32(0x0080)) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2) { + if !(((*Table)(unsafe.Pointer(((*SrcList_item)(unsafe.Pointer(pItem)).FpTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIdx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY) { if isSearch != 0 { zFmt = ts + 23120 /* "PRIMARY KEY" */ } - } else if (flags & U32(0x00020000)) != 0 { + } else if (flags & WHERE_PARTIALIDX) != 0 { zFmt = ts + 23132 /* "AUTOMATIC PARTIA..." */ - } else if (flags & U32(0x00004000)) != 0 { + } else if (flags & WHERE_AUTO_INDEX) != 0 { zFmt = ts + 23165 /* "AUTOMATIC COVERI..." */ - } else if (flags & U32(0x00000040)) != 0 { + } else if (flags & WHERE_IDX_ONLY) != 0 { zFmt = ts + 23190 /* "COVERING INDEX %..." */ } else { zFmt = ts + 23208 /* "INDEX %s" */ @@ -125716,13 +123486,13 @@ func Xsqlite3WhereExplainOneScan(tls *libc.TLS, pParse uintptr, pTabList uintptr Xsqlite3_str_appendf(tls, bp+56 /* &str */, zFmt, libc.VaList(bp+24, (*Index)(unsafe.Pointer(pIdx)).FzName)) explainIndexRange(tls, bp+56 /* &str */, pLoop) } - } else if ((flags & U32(0x00000100)) != U32(0)) && ((flags & U32(0x0000000f)) != U32(0)) { + } else if ((flags & WHERE_IPK) != U32(0)) && ((flags & WHERE_CONSTRAINT) != U32(0)) { var zRangeOp uintptr - if (flags & (U32(0x00000001 | 0x00000004))) != 0 { + if (flags & (U32(WHERE_COLUMN_EQ | WHERE_COLUMN_IN))) != 0 { zRangeOp = ts + 23225 /* "=" */ - } else if (flags & U32(0x00000030)) == U32(0x00000030) { + } else if (flags & WHERE_BOTH_LIMIT) == WHERE_BOTH_LIMIT { zRangeOp = ts + 23227 /* ">? AND rowid<" */ - } else if (flags & U32(0x00000020)) != 0 { + } else if (flags & WHERE_BTM_LIMIT) != 0 { zRangeOp = ts + 23074 /* ">" */ } else { @@ -125730,13 +123500,13 @@ func Xsqlite3WhereExplainOneScan(tls *libc.TLS, pParse uintptr, pTabList uintptr } Xsqlite3_str_appendf(tls, bp+56, /* &str */ ts+23241 /* " USING INTEGER P..." */, libc.VaList(bp+32, zRangeOp)) - } else if (flags & U32(0x00000400)) != U32(0) { + } else if (flags & WHERE_VIRTUALTABLE) != U32(0) { Xsqlite3_str_appendf(tls, bp+56 /* &str */, ts+23279, /* " VIRTUAL TABLE I..." */ libc.VaList(bp+40, *(*int32)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.vtab */ /* &.idxNum */)), *(*uintptr)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.vtab */ + 8 /* &.idxStr */)))) } zMsg = Xsqlite3StrAccumFinish(tls, bp+56 /* &str */) - ret = Xsqlite3VdbeAddOp4(tls, v, 174, Xsqlite3VdbeCurrentAddr(tls, v), + ret = Xsqlite3VdbeAddOp4(tls, v, OP_Explain, Xsqlite3VdbeCurrentAddr(tls, v), (*Parse)(unsafe.Pointer(pParse)).FaddrExplain, 0, zMsg, -7) } return ret @@ -125785,13 +123555,13 @@ func Xsqlite3WhereExplainOneScan(tls *libc.TLS, pParse uintptr, pTabList uintptr func disableTerm(tls *libc.TLS, pLevel uintptr, pTerm uintptr) { /* sqlite3.c:141818:13: */ var nLoop int32 = 0 - for (((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0004) == 0) && - (((*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin == 0) || (((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000001))) != U32(0)))) && + for (((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_CODED) == 0) && + (((*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin == 0) || (((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_FromJoin)) != U32(0)))) && (((*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady & (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll) == uint64(0)) { - if (nLoop != 0) && ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0400) != 0) { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0200)) + if (nLoop != 0) && ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_LIKE) != 0) { + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_LIKECOND)) } else { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) } if (*WhereTerm)(unsafe.Pointer(pTerm)).FiParent < 0 { break @@ -125825,18 +123595,18 @@ func codeApplyAffinity(tls *libc.TLS, pParse uintptr, base int32, n int32, zAff // Adjust base and n to skip over SQLITE_AFF_BLOB and SQLITE_AFF_NONE // entries at the beginning and end of the affinity string. - for (n > 0) && (int32(*(*int8)(unsafe.Pointer(zAff + uintptr(0)))) <= 0x41) { + for (n > 0) && (int32(*(*int8)(unsafe.Pointer(zAff))) <= SQLITE_AFF_BLOB) { n-- base++ zAff++ } - for (n > 1) && (int32(*(*int8)(unsafe.Pointer(zAff + uintptr((n - 1))))) <= 0x41) { + for (n > 1) && (int32(*(*int8)(unsafe.Pointer(zAff + uintptr((n - 1))))) <= SQLITE_AFF_BLOB) { n-- } // Code the OP_Affinity opcode if there is anything left to do. if n > 0 { - Xsqlite3VdbeAddOp4(tls, v, 90, base, n, 0, zAff, n) + Xsqlite3VdbeAddOp4(tls, v, OP_Affinity, base, n, 0, zAff, n) } } @@ -125852,9 +123622,9 @@ func updateRangeAffinityStr(tls *libc.TLS, pRight uintptr, n int32, zAff uintptr var i int32 for i = 0; i < n; i++ { var p uintptr = Xsqlite3VectorFieldSubexpr(tls, pRight, i) - if (int32(Xsqlite3CompareAffinity(tls, p, *(*int8)(unsafe.Pointer(zAff + uintptr(i))))) == 0x41) || + if (int32(Xsqlite3CompareAffinity(tls, p, *(*int8)(unsafe.Pointer(zAff + uintptr(i))))) == SQLITE_AFF_BLOB) || (Xsqlite3ExprNeedsNoAffinityChange(tls, p, *(*int8)(unsafe.Pointer(zAff + uintptr(i)))) != 0) { - *(*int8)(unsafe.Pointer(zAff + uintptr(i))) = int8(0x41) + *(*int8)(unsafe.Pointer(zAff + uintptr(i))) = SQLITE_AFF_BLOB } } } @@ -125919,8 +123689,8 @@ func removeUnindexableInClauseTerms(tls *libc.TLS, pParse uintptr, iEq int32, pL // Take care here not to generate a TK_VECTOR containing only a // single value. Since the parser never creates such a vector, some // of the subroutines do not handle this case. - var p uintptr = (*ExprList_item)(unsafe.Pointer((pLhs + 8 /* &.a */) + uintptr(0)*32)).FpExpr - (*ExprList_item)(unsafe.Pointer((pLhs + 8 /* &.a */) + uintptr(0)*32)).FpExpr = uintptr(0) + var p uintptr = (*ExprList_item)(unsafe.Pointer((pLhs + 8 /* &.a */))).FpExpr + (*ExprList_item)(unsafe.Pointer((pLhs + 8 /* &.a */))).FpExpr = uintptr(0) Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer(pNew)).FpLeft) (*Expr)(unsafe.Pointer(pNew)).FpLeft = p } @@ -125964,13 +123734,13 @@ func codeEqualityTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintp var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe var iReg int32 // Register holding results - if (int32((*Expr)(unsafe.Pointer(pX)).Fop) == 53) || (int32((*Expr)(unsafe.Pointer(pX)).Fop) == 45) { + if (int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_EQ) || (int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_IS) { iReg = Xsqlite3ExprCodeTarget(tls, pParse, (*Expr)(unsafe.Pointer(pX)).FpRight, iTarget) - } else if int32((*Expr)(unsafe.Pointer(pX)).Fop) == 50 { + } else if int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_ISNULL { iReg = iTarget - Xsqlite3VdbeAddOp2(tls, v, 72, 0, iReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, iReg) } else { - var eType int32 = 5 + var eType int32 = IN_INDEX_NOOP // var iTab int32 at bp, 4 var pIn uintptr @@ -125979,7 +123749,7 @@ func codeEqualityTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintp var nEq int32 = 0 var aiMap uintptr = uintptr(0) - if ((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000400)) == U32(0)) && + if ((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_VIRTUALTABLE) == U32(0)) && (*(*uintptr)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.btree */) + 8 /* &.pIndex */)) != uintptr(0))) && (*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.btree */) + 8 /* &.pIndex */)))).FaSortOrder + uintptr(iEq))) != 0) { @@ -126002,33 +123772,33 @@ func codeEqualityTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintp } *(*int32)(unsafe.Pointer(bp /* iTab */)) = 0 - if (((*Expr)(unsafe.Pointer(pX)).Fflags & U32(0x000800)) == U32(0)) || ((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32 /* &.x */)))).FpEList)).FnExpr == 1) { - eType = Xsqlite3FindInIndex(tls, pParse, pX, uint32(0x0004), uintptr(0), uintptr(0), bp /* &iTab */) + if (((*Expr)(unsafe.Pointer(pX)).Fflags & EP_xIsSelect) == U32(0)) || ((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pX + 32 /* &.x */)))).FpEList)).FnExpr == 1) { + eType = Xsqlite3FindInIndex(tls, pParse, pX, IN_INDEX_LOOP, uintptr(0), uintptr(0), bp /* &iTab */) } else { var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb pX = removeUnindexableInClauseTerms(tls, pParse, iEq, pLoop, pX) if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) { aiMap = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (uint64(uint64(unsafe.Sizeof(int32(0))) * uint64(nEq)))) - eType = Xsqlite3FindInIndex(tls, pParse, pX, uint32(0x0004), uintptr(0), aiMap, bp /* &iTab */) + eType = Xsqlite3FindInIndex(tls, pParse, pX, IN_INDEX_LOOP, uintptr(0), aiMap, bp /* &iTab */) (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FiTable = *(*int32)(unsafe.Pointer(bp /* iTab */)) } Xsqlite3ExprDelete(tls, db, pX) pX = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr } - if eType == 4 { + if eType == IN_INDEX_INDEX_DESC { bRev = libc.BoolInt32(!(bRev != 0)) } Xsqlite3VdbeAddOp2(tls, v, func() int32 { if bRev != 0 { - return 33 + return OP_Last } - return 37 + return OP_Rewind }(), *(*int32)(unsafe.Pointer(bp /* iTab */)), 0) - *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (U32(0x00000800)) + *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (WHERE_IN_ABLE) if *(*int32)(unsafe.Pointer((pLevel + 56 /* &.u */ /* &.in */) /* &.nIn */)) == 0 { (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt = Xsqlite3VdbeMakeLabel(tls, pParse) } @@ -126044,8 +123814,8 @@ func codeEqualityTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintp for i = iEq; i < int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm); i++ { if (*WhereTerm)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(i)*8)))).FpExpr == pX { var iOut int32 = ((iReg + i) - iEq) - if eType == 1 { - *(*int32)(unsafe.Pointer(pIn + 4 /* &.addrInTop */)) = Xsqlite3VdbeAddOp2(tls, v, 127, *(*int32)(unsafe.Pointer(bp /* iTab */)), iOut) + if eType == IN_INDEX_ROWID { + *(*int32)(unsafe.Pointer(pIn + 4 /* &.addrInTop */)) = Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, *(*int32)(unsafe.Pointer(bp /* iTab */)), iOut) } else { var iCol int32 if aiMap != 0 { @@ -126053,26 +123823,26 @@ func codeEqualityTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr, pLevel uintp } else { iCol = 0 } - *(*int32)(unsafe.Pointer(pIn + 4 /* &.addrInTop */)) = Xsqlite3VdbeAddOp3(tls, v, 89, *(*int32)(unsafe.Pointer(bp /* iTab */)), iCol, iOut) + *(*int32)(unsafe.Pointer(pIn + 4 /* &.addrInTop */)) = Xsqlite3VdbeAddOp3(tls, v, OP_Column, *(*int32)(unsafe.Pointer(bp /* iTab */)), iCol, iOut) } - Xsqlite3VdbeAddOp1(tls, v, 50, iOut) + Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, iOut) if i == iEq { *(*int32)(unsafe.Pointer(pIn /* &.iCur */)) = *(*int32)(unsafe.Pointer(bp /* iTab */)) *(*U8)(unsafe.Pointer(pIn + 16 /* &.eEndLoopOp */)) = func() uint8 { if bRev != 0 { - return uint8(4) + return OP_Prev } - return uint8(5) + return OP_Next }() if iEq > 0 { *(*int32)(unsafe.Pointer(pIn + 8 /* &.iBase */)) = (iReg - i) *(*int32)(unsafe.Pointer(pIn + 12 /* &.nPrefix */)) = i - *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (U32(0x00040000)) + *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (WHERE_IN_EARLYOUT) } else { *(*int32)(unsafe.Pointer(pIn + 12 /* &.nPrefix */)) = 0 } } else { - *(*U8)(unsafe.Pointer(pIn + 16 /* &.eEndLoopOp */)) = U8(173) + *(*U8)(unsafe.Pointer(pIn + 16 /* &.eEndLoopOp */)) = OP_Noop } pIn += 20 } @@ -126162,24 +123932,24 @@ func codeAllEqualityTerms(tls *libc.TLS, pParse uintptr, pLevel uintptr, bRev in var iIdxCur int32 = (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur Xsqlite3VdbeAddOp1(tls, v, func() int32 { if bRev != 0 { - return 33 + return OP_Last } - return 37 + return OP_Rewind }(), iIdxCur) Xsqlite3VdbeComment(tls, v, ts+23306 /* "begin skip-scan ..." */, libc.VaList(bp, (*Index)(unsafe.Pointer(pIdx)).FzName)) - j = Xsqlite3VdbeAddOp0(tls, v, 11) + j = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrSkip = Xsqlite3VdbeAddOp4Int(tls, v, func() int32 { if bRev != 0 { - return 22 + return OP_SeekLT } - return 25 + return OP_SeekGT }(), iIdxCur, 0, regBase, int32(nSkip)) Xsqlite3VdbeJumpHere(tls, v, j) for j = 0; j < int32(nSkip); j++ { - Xsqlite3VdbeAddOp3(tls, v, 89, iIdxCur, j, (regBase + j)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, j, (regBase + j)) Xsqlite3VdbeComment(tls, v, ts+824 /* "%s" */, libc.VaList(bp+8, explainIndexColumnName(tls, pIdx, j))) } @@ -126200,31 +123970,31 @@ func codeAllEqualityTerms(tls *libc.TLS, pParse uintptr, pLevel uintptr, bRev in Xsqlite3ReleaseTempReg(tls, pParse, regBase) regBase = r1 } else { - Xsqlite3VdbeAddOp2(tls, v, 78, r1, (regBase + j)) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, r1, (regBase + j)) } } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0001) != 0 { - if ((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags & U32(0x000800)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_IN) != 0 { + if ((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).Fflags & EP_xIsSelect) != 0 { // No affinity ever needs to be (or should be) applied to a value // from the RHS of an "? IN (SELECT ...)" expression. The // sqlite3FindInIndex() routine has already ensured that the // affinity of the comparison has been applied to the value. if zAff != 0 { - *(*int8)(unsafe.Pointer(zAff + uintptr(j))) = int8(0x41) + *(*int8)(unsafe.Pointer(zAff + uintptr(j))) = SQLITE_AFF_BLOB } } - } else if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0100) == 0 { + } else if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_ISNULL) == 0 { var pRight uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight - if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0800) == 0) && (Xsqlite3ExprCanBeNull(tls, pRight) != 0) { - Xsqlite3VdbeAddOp2(tls, v, 50, (regBase + j), (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk) + if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_IS) == 0) && (Xsqlite3ExprCanBeNull(tls, pRight) != 0) { + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (regBase + j), (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBrk) } if zAff != 0 { - if int32(Xsqlite3CompareAffinity(tls, pRight, *(*int8)(unsafe.Pointer(zAff + uintptr(j))))) == 0x41 { - *(*int8)(unsafe.Pointer(zAff + uintptr(j))) = int8(0x41) + if int32(Xsqlite3CompareAffinity(tls, pRight, *(*int8)(unsafe.Pointer(zAff + uintptr(j))))) == SQLITE_AFF_BLOB { + *(*int8)(unsafe.Pointer(zAff + uintptr(j))) = SQLITE_AFF_BLOB } if Xsqlite3ExprNeedsNoAffinityChange(tls, pRight, *(*int8)(unsafe.Pointer(zAff + uintptr(j)))) != 0 { - *(*int8)(unsafe.Pointer(zAff + uintptr(j))) = int8(0x41) + *(*int8)(unsafe.Pointer(zAff + uintptr(j))) = SQLITE_AFF_BLOB } } } @@ -126254,8 +124024,8 @@ func codeDeferredSeek(tls *libc.TLS, pWInfo uintptr, pIdx uintptr, iCur int32, i var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe // Vdbe to generate code within libc.SetBitFieldPtr8Uint32(pWInfo+68 /* &.bDeferredSeek */, uint32(1), 0, 0x1) - Xsqlite3VdbeAddOp3(tls, v, 133, iIdxCur, 0, iCur) - if ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0020) != 0) && + Xsqlite3VdbeAddOp3(tls, v, OP_DeferredSeek, iIdxCur, 0, iCur) + if ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_OR_SUBCLAUSE) != 0) && (((*Parse)(unsafe.Pointer(func() uintptr { if (*Parse)(unsafe.Pointer(pParse)).FpToplevel != 0 { return (*Parse)(unsafe.Pointer(pParse)).FpToplevel @@ -126266,7 +124036,7 @@ func codeDeferredSeek(tls *libc.TLS, pWInfo uintptr, pIdx uintptr, iCur int32, i var pTab uintptr = (*Index)(unsafe.Pointer(pIdx)).FpTable var ai uintptr = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (uint64(uint64(unsafe.Sizeof(U32(0))) * (uint64(int32((*Table)(unsafe.Pointer(pTab)).FnCol) + 1))))) if ai != 0 { - *(*U32)(unsafe.Pointer(ai + uintptr(0)*4)) = U32((*Table)(unsafe.Pointer(pTab)).FnCol) + *(*U32)(unsafe.Pointer(ai)) = U32((*Table)(unsafe.Pointer(pTab)).FnCol) for i = 0; i < (int32((*Index)(unsafe.Pointer(pIdx)).FnColumn) - 1); i++ { var x1 int32 var x2 int32 @@ -126293,12 +124063,12 @@ func codeDeferredSeek(tls *libc.TLS, pWInfo uintptr, pIdx uintptr, iCur int32, i func codeExprOrVector(tls *libc.TLS, pParse uintptr, p uintptr, iReg int32, nReg int32) { /* sqlite3.c:142602:13: */ if (p != 0) && (Xsqlite3ExprIsVector(tls, p) != 0) { - if ((*Expr)(unsafe.Pointer(p)).Fflags & U32(0x000800)) != 0 { + if ((*Expr)(unsafe.Pointer(p)).Fflags & EP_xIsSelect) != 0 { var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe var iSelect int32 iSelect = Xsqlite3CodeSubselect(tls, pParse, p) - Xsqlite3VdbeAddOp3(tls, v, 77, iSelect, iReg, (nReg - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, iSelect, iReg, (nReg - 1)) } else { var i int32 var pList uintptr = *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) @@ -126341,15 +124111,15 @@ func whereIndexExprTransNode(tls *libc.TLS, p uintptr, pExpr uintptr) int32 { /* if Xsqlite3ExprCompare(tls, uintptr(0), pExpr, (*IdxExprTrans)(unsafe.Pointer(pX)).FpIdxExpr, (*IdxExprTrans)(unsafe.Pointer(pX)).FiTabCur) == 0 { preserveExpr(tls, pX, pExpr) (*Expr)(unsafe.Pointer(pExpr)).FaffExpr = Xsqlite3ExprAffinity(tls, pExpr) - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(164) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_COLUMN (*Expr)(unsafe.Pointer(pExpr)).FiTable = (*IdxExprTrans)(unsafe.Pointer(pX)).FiIdxCur (*Expr)(unsafe.Pointer(pExpr)).FiColumn = YnVar((*IdxExprTrans)(unsafe.Pointer(pX)).FiIdxCol) *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = uintptr(0) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (^libc.Uint32FromInt32((0x001000 | 0x040000))) - return 1 + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32((EP_Skip | EP_Unlikely)))) + return WRC_Prune } else { - return 0 + return WRC_Continue } return int32(0) } @@ -126357,7 +124127,7 @@ func whereIndexExprTransNode(tls *libc.TLS, p uintptr, pExpr uintptr) int32 { /* // A walker node callback that translates a column reference to a table // into a corresponding column reference of an index. func whereIndexExprTransColumn(tls *libc.TLS, p uintptr, pExpr uintptr) int32 { /* sqlite3.c:142683:12: */ - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN { var pX uintptr = *(*uintptr)(unsafe.Pointer(p + 40 /* &.u */)) if ((*Expr)(unsafe.Pointer(pExpr)).FiTable == (*IdxExprTrans)(unsafe.Pointer(pX)).FiTabCur) && (int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) == (*IdxExprTrans)(unsafe.Pointer(pX)).FiTabCol) { @@ -126368,7 +124138,7 @@ func whereIndexExprTransColumn(tls *libc.TLS, p uintptr, pExpr uintptr) int32 { *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) = uintptr(0) } } - return 0 + return WRC_Continue } // For an indexes on expression X, locate every instance of expression X @@ -126414,7 +124184,7 @@ func whereIndexExprTrans(tls *libc.TLS, pIdx uintptr, iTabCur int32, iIdxCur int f func(*libc.TLS, uintptr, uintptr) int32 }{whereIndexExprTransNode})) } else if ((int32(iRef) >= 0) && - ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iRef)*32)).FcolFlags) & 0x0020) != 0)) && + ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iRef)*32)).FcolFlags) & COLFLAG_VIRTUAL) != 0)) && (((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iRef)*32)).FzColl == uintptr(0)) || (Xsqlite3StrICmp(tls, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(iRef)*32)).FzColl, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY))) == 0)) { // Check to see if there are direct references to generated columns @@ -126445,7 +124215,7 @@ func whereIndexExprTrans(tls *libc.TLS, pIdx uintptr, iTabCur int32, iIdxCur int func whereApplyPartialIndexConstraints(tls *libc.TLS, pTruth uintptr, iTabCur int32, pWC uintptr) { /* sqlite3.c:142771:13: */ var i int32 var pTerm uintptr - for int32((*Expr)(unsafe.Pointer(pTruth)).Fop) == 44 { + for int32((*Expr)(unsafe.Pointer(pTruth)).Fop) == TK_AND { whereApplyPartialIndexConstraints(tls, (*Expr)(unsafe.Pointer(pTruth)).FpLeft, iTabCur, pWC) pTruth = (*Expr)(unsafe.Pointer(pTruth)).FpRight } @@ -126457,12 +124227,12 @@ __1: } { var pExpr uintptr - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0004) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_CODED) != 0 { goto __2 } pExpr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr if Xsqlite3ExprCompare(tls, uintptr(0), pExpr, pTruth, iTabCur) == 0 { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) } } @@ -126523,9 +124293,9 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // initialize a memory cell that records if this table matches any // row of the left table of the join. - if (int32((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom) > 0) && ((int32((*SrcList_item)(unsafe.Pointer(pTabItem+uintptr(0)*112)).Ffg.Fjointype) & 0x0008) != 0) { + if (int32((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom) > 0) && ((int32((*SrcList_item)(unsafe.Pointer(pTabItem)).Ffg.Fjointype) & JT_LEFT) != 0) { (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) Xsqlite3VdbeComment(tls, v, ts+23328 /* "init LEFT JOIN n..." */, 0) } @@ -126538,12 +124308,12 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // Special case of a FROM clause subquery implemented as a co-routine if (uint32(int32(*(*uint8)(unsafe.Pointer(pTabItem + 60 /* &.fg */ + 4 /* &.viaCoroutine */)) & 0x10 >> 4))) != 0 { var regYield int32 = (*SrcList_item)(unsafe.Pointer(pTabItem)).FregReturn - Xsqlite3VdbeAddOp3(tls, v, 13, regYield, 0, (*SrcList_item)(unsafe.Pointer(pTabItem)).FaddrFillSub) - (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = Xsqlite3VdbeAddOp2(tls, v, 14, regYield, addrBrk) + Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regYield, 0, (*SrcList_item)(unsafe.Pointer(pTabItem)).FaddrFillSub) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = Xsqlite3VdbeAddOp2(tls, v, OP_Yield, regYield, addrBrk) Xsqlite3VdbeComment(tls, v, ts+23357 /* "next row of %s" */, libc.VaList(bp, (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pTabItem)).FpTab)).FzName)) - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(11) - } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000400)) != U32(0) { + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Goto + } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_VIRTUALTABLE) != U32(0) { // Case 1: The table is a virtual-table. Use the VFilter and VNext // to access the data. var iReg int32 // P3 Value for OP_VFilter @@ -126559,7 +124329,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI if pTerm == uintptr(0) { continue } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0001) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_IN) != 0 { codeEqualityTerm(tls, pParse, pTerm, pLevel, j, bRev, iTarget) addrNotFound = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt } else { @@ -126567,9 +124337,9 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI codeExprOrVector(tls, pParse, pRight, iTarget, 1) } } - Xsqlite3VdbeAddOp2(tls, v, 69, *(*int32)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.vtab */ /* &.idxNum */)), iReg) - Xsqlite3VdbeAddOp2(tls, v, 69, nConstraint, (iReg + 1)) - Xsqlite3VdbeAddOp4(tls, v, 9, iCur, addrNotFound, iReg, + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, *(*int32)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.vtab */ /* &.idxNum */)), iReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, nConstraint, (iReg + 1)) + Xsqlite3VdbeAddOp4(tls, v, OP_VFilter, iCur, addrNotFound, iReg, *(*uintptr)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.vtab */ + 8 /* &.idxStr */)), func() int32 { if *(*U8)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.vtab */ + 4 /* &.needFree */)) != 0 { @@ -126582,20 +124352,20 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = func() uint8 { if (*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass != 0 { - return uint8(173) + return OP_Noop } - return uint8(61) + return OP_VNext }() (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = Xsqlite3VdbeCurrentAddr(tls, v) iIn = *(*int32)(unsafe.Pointer(pLevel + 56 /* &.u */ /* &.in */ /* &.nIn */)) for j = (nConstraint - 1); j >= 0; j-- { pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(j)*8)) - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0001) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_IN) != 0 { iIn-- } if (j < 16) && (((int32(*(*U16)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.vtab */) + 6 /* &.omitMask */))) >> j) & 1) != 0) { disableTerm(tls, pLevel, pTerm) - } else if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0001) != 0) && + } else if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_IN) != 0) && (Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft) == 1) { var pCompare uintptr // The comparison operator var pRight uintptr // RHS of the comparison @@ -126615,15 +124385,15 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // Generate code that will continue to the next row if // the IN constraint is not satisfied - pCompare = Xsqlite3PExpr(tls, pParse, 53, uintptr(0), uintptr(0)) + pCompare = Xsqlite3PExpr(tls, pParse, TK_EQ, uintptr(0), uintptr(0)) if pCompare != 0 { (*Expr)(unsafe.Pointer(pCompare)).FpLeft = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft - (*Expr)(unsafe.Pointer(pCompare)).FpRight = libc.AssignUintptr(&pRight, Xsqlite3Expr(tls, db, 173, uintptr(0))) + (*Expr)(unsafe.Pointer(pCompare)).FpRight = libc.AssignUintptr(&pRight, Xsqlite3Expr(tls, db, TK_REGISTER, uintptr(0))) if pRight != 0 { (*Expr)(unsafe.Pointer(pRight)).FiTable = ((iReg + j) + 2) Xsqlite3ExprIfFalse(tls, - pParse, pCompare, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont, 0x10) + pParse, pCompare, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont, SQLITE_JUMPIFNULL) } (*Expr)(unsafe.Pointer(pCompare)).FpLeft = uintptr(0) Xsqlite3ExprDelete(tls, db, pCompare) @@ -126637,14 +124407,14 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // simpler and safer to simply not reuse the registers. // // sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2); - } else if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000100)) != U32(0)) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(0x00000004 | 0x00000001))) != U32(0)) { + } else if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IPK) != U32(0)) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(WHERE_COLUMN_IN | WHERE_COLUMN_EQ))) != U32(0)) { // Case 2: We can directly reference a single row using an // equality comparison against the ROWID field. Or // we reference multiple rows using a "rowid IN (...)" // construct. - pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(0)*8)) + pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) iReleaseReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) iRowidReg = codeEqualityTerm(tls, pParse, pTerm, pLevel, 0, bRev, iReleaseReg) @@ -126652,16 +124422,16 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI Xsqlite3ReleaseTempReg(tls, pParse, iReleaseReg) } addrNxt = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt - Xsqlite3VdbeAddOp3(tls, v, 31, iCur, addrNxt, iRowidReg) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, iCur, addrNxt, iRowidReg) - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(173) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Noop if ((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & (*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady) == uint64(0) { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) } - } else if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000100)) != U32(0)) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000002)) != U32(0)) { + } else if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IPK) != U32(0)) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_COLUMN_RANGE) != U32(0)) { // Case 3: We have an inequality comparison against the ROWID field. - var testOp int32 = 173 + var testOp int32 = OP_Noop var start int32 var memEndValue int32 = 0 var pStart uintptr @@ -126669,10 +124439,10 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI j = 0 pStart = libc.AssignUintptr(&pEnd, uintptr(0)) - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000020)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_BTM_LIMIT) != 0 { pStart = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&j, 1))*8)) } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000010)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_TOP_LIMIT) != 0 { pEnd = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&j, 1))*8)) } @@ -126692,10 +124462,10 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // The following constant maps TK_xx codes into corresponding // seek opcodes. It depends on a particular ordering of TK_xx *(*[4]U8)(unsafe.Pointer(bp + 16 /* aMoveOp */)) = [4]U8{ - /* TK_GT */ U8(25), - /* TK_LE */ U8(23), - /* TK_LT */ U8(22), - /* TK_GE */ U8(24), + /* TK_GT */ OP_SeekGT, + /* TK_LE */ OP_SeekLE, + /* TK_LT */ OP_SeekLT, + /* TK_GE */ OP_SeekGE, } // Make sure the ordering.. // ... of the TK_xx values... @@ -126708,12 +124478,12 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI r1 = libc.AssignPtrInt32(bp+20 /* rTemp */, Xsqlite3GetTempReg(tls, pParse)) codeExprOrVector(tls, pParse, (*Expr)(unsafe.Pointer(pX)).FpRight, r1, 1) - op = int32(*(*U8)(unsafe.Pointer(bp + 16 /* &aMoveOp[0] */ + uintptr(((((int32((*Expr)(unsafe.Pointer(pX)).Fop) - 54) - 1) & 0x3) | 0x1))))) + op = int32(*(*U8)(unsafe.Pointer(bp + 16 /* &aMoveOp[0] */ + uintptr(((((int32((*Expr)(unsafe.Pointer(pX)).Fop) - TK_GT) - 1) & 0x3) | 0x1))))) } else { r1 = Xsqlite3ExprCodeTemp(tls, pParse, (*Expr)(unsafe.Pointer(pX)).FpRight, bp+20 /* &rTemp */) disableTerm(tls, pLevel, pStart) - op = int32(*(*U8)(unsafe.Pointer(bp + 16 /* &aMoveOp[0] */ + uintptr((int32((*Expr)(unsafe.Pointer(pX)).Fop) - 54))))) + op = int32(*(*U8)(unsafe.Pointer(bp + 16 /* &aMoveOp[0] */ + uintptr((int32((*Expr)(unsafe.Pointer(pX)).Fop) - TK_GT))))) } Xsqlite3VdbeAddOp3(tls, v, op, iCur, addrBrk, r1) Xsqlite3VdbeComment(tls, v, ts+17201 /* "pk" */, 0) @@ -126722,9 +124492,9 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI } else { Xsqlite3VdbeAddOp2(tls, v, func() int32 { if bRev != 0 { - return 33 + return OP_Last } - return 37 + return OP_Rewind }(), iCur, addrHalt) } @@ -126737,17 +124507,17 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI memEndValue = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) codeExprOrVector(tls, pParse, (*Expr)(unsafe.Pointer(pX)).FpRight, memEndValue, 1) if (0 == Xsqlite3ExprIsVector(tls, (*Expr)(unsafe.Pointer(pX)).FpRight)) && - ((int32((*Expr)(unsafe.Pointer(pX)).Fop) == 56) || (int32((*Expr)(unsafe.Pointer(pX)).Fop) == 54)) { + ((int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_LT) || (int32((*Expr)(unsafe.Pointer(pX)).Fop) == TK_GT)) { if bRev != 0 { - testOp = 55 + testOp = OP_Le } else { - testOp = 57 + testOp = OP_Ge } } else { if bRev != 0 { - testOp = 56 + testOp = OP_Lt } else { - testOp = 54 + testOp = OP_Gt } } if 0 == Xsqlite3ExprIsVector(tls, (*Expr)(unsafe.Pointer(pX)).FpRight) { @@ -126757,21 +124527,21 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI start = Xsqlite3VdbeCurrentAddr(tls, v) (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = func() uint8 { if bRev != 0 { - return uint8(4) + return OP_Prev } - return uint8(5) + return OP_Next }() (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = start - if testOp != 173 { + if testOp != OP_Noop { iRowidReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 127, iCur, iRowidReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iCur, iRowidReg) Xsqlite3VdbeAddOp3(tls, v, testOp, memEndValue, addrBrk, iRowidReg) - Xsqlite3VdbeChangeP5(tls, v, (uint16(0x43 | 0x10))) + Xsqlite3VdbeChangeP5(tls, v, (uint16(SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL))) } - } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000200)) != 0 { + } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_INDEXED) != 0 { var nEq U16 = *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ /* &.nEq */)) // Number of == or IN terms var nBtm U16 = *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 2 /* &.nBtm */)) // Length of BTM vector var nTop U16 = *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 4 /* &.nTop */)) // Length of TOP vector @@ -126799,7 +124569,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // Find any inequality constraint terms for the start and end // of the range. j = int32(nEq) - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000020)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_BTM_LIMIT) != 0 { pRangeStart = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&j, 1))*8)) nExtraReg = func() int32 { if (nExtraReg) > (int32(*(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 2 /* &.nBtm */)))) { @@ -126810,7 +124580,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // Like optimization range constraints always occur in pairs } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000010)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_TOP_LIMIT) != 0 { pRangeEnd = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(libc.PostIncInt32(&j, 1))*8)) nExtraReg = func() int32 { if (nExtraReg) > (int32(*(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 4 /* &.nTop */)))) { @@ -126832,14 +124602,14 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // index entries for which the column is null and for those for which // it is not. For an ASC sort, the non-NULL entries are scanned first. // For DESC, NULL entries are scanned first. - if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(0x00000010 | 0x00000020))) == U32(0)) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00080000)) != U32(0)) { + if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(WHERE_TOP_LIMIT | WHERE_BTM_LIMIT))) == U32(0)) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_BIGNULL_SORT) != U32(0)) { nExtraReg = 1 bSeekPastNull = U8(1) (*WhereLevel)(unsafe.Pointer(pLevel)).FregBignull = libc.AssignInt32(®Bignull, libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1)) if (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regBignull) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regBignull) } (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull = Xsqlite3VdbeMakeLabel(tls, pParse) } @@ -126847,7 +124617,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // If we are doing a reverse order scan on an ascending index, or // a forward order scan on a descending index, interchange the // start and end terms (pRangeStart and pRangeEnd). - if ((int32(nEq) < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)) && (bRev == (libc.Bool32(int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(nEq)))) == 0)))) || + if ((int32(nEq) < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol)) && (bRev == (libc.Bool32(int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(nEq)))) == SQLITE_SO_ASC)))) || ((bRev != 0) && (int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) == int32(nEq))) { { var t uintptr = pRangeEnd @@ -126885,8 +124655,8 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI return (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt }() - startEq = (libc.Bool32(!(pRangeStart != 0) || ((int32((*WhereTerm)(unsafe.Pointer(pRangeStart)).FeOperator) & ((int32(0x0002) << (55 - 53)) | (int32(0x0002) << (57 - 53)))) != 0))) - endEq = (libc.Bool32(!(pRangeEnd != 0) || ((int32((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FeOperator) & ((int32(0x0002) << (55 - 53)) | (int32(0x0002) << (57 - 53)))) != 0))) + startEq = (libc.Bool32(!(pRangeStart != 0) || ((int32((*WhereTerm)(unsafe.Pointer(pRangeStart)).FeOperator) & ((int32(WO_EQ) << (TK_LE - TK_EQ)) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) != 0))) + endEq = (libc.Bool32(!(pRangeEnd != 0) || ((int32((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FeOperator) & ((int32(WO_EQ) << (TK_LE - TK_EQ)) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) != 0))) start_constraints = (libc.Bool32((pRangeStart != 0) || (int32(nEq) > 0))) // Seek the index cursor to the start of the range. @@ -126895,9 +124665,9 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI var pRight uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pRangeStart)).FpExpr)).FpRight codeExprOrVector(tls, pParse, pRight, (regBase + int32(nEq)), int32(nBtm)) - if ((int32((*WhereTerm)(unsafe.Pointer(pRangeStart)).FwtFlags) & 0x0080) == 0) && + if ((int32((*WhereTerm)(unsafe.Pointer(pRangeStart)).FwtFlags) & TERM_VNULL) == 0) && (Xsqlite3ExprCanBeNull(tls, pRight) != 0) { - Xsqlite3VdbeAddOp2(tls, v, 50, (regBase + int32(nEq)), addrNxt) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (regBase + int32(nEq)), addrNxt) } if *(*uintptr)(unsafe.Pointer(bp + 24 /* zStartAff */)) != 0 { @@ -126913,11 +124683,11 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI bSeekPastNull = U8(0) } else if bSeekPastNull != 0 { startEq = 0 - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (regBase + int32(nEq))) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (regBase + int32(nEq))) start_constraints = 1 nConstraint++ } else if regBignull != 0 { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (regBase + int32(nEq))) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (regBase + int32(nEq))) start_constraints = 1 nConstraint++ } @@ -126927,11 +124697,11 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // above has already left the cursor sitting on the correct row, // so no further seeking is needed } else { - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00040000)) != 0 { - Xsqlite3VdbeAddOp1(tls, v, 118, iIdxCur) + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IN_EARLYOUT) != 0 { + Xsqlite3VdbeAddOp1(tls, v, OP_SeekHit, iIdxCur) } if regBignull != 0 { - Xsqlite3VdbeAddOp2(tls, v, 69, 1, regBignull) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, regBignull) Xsqlite3VdbeComment(tls, v, ts+23372 /* "NULL-scan pass c..." */, 0) } @@ -126941,7 +124711,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI if regBignull != 0 { - Xsqlite3VdbeAddOp2(tls, v, 11, 0, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) op = int32(aStartOp[((((libc.Bool32(nConstraint > 1)) * 4) + 2) + bRev)]) Xsqlite3VdbeAddOp4Int(tls, v, op, iIdxCur, addrNxt, regBase, (nConstraint - startEq)) @@ -126956,9 +124726,9 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI var pRight uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FpExpr)).FpRight codeExprOrVector(tls, pParse, pRight, (regBase + int32(nEq)), int32(nTop)) - if ((int32((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FwtFlags) & 0x0080) == 0) && + if ((int32((*WhereTerm)(unsafe.Pointer(pRangeEnd)).FwtFlags) & TERM_VNULL) == 0) && (Xsqlite3ExprCanBeNull(tls, pRight) != 0) { - Xsqlite3VdbeAddOp2(tls, v, 50, (regBase + int32(nEq)), addrNxt) + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, (regBase + int32(nEq)), addrNxt) } if zEndAff != 0 { @@ -126976,7 +124746,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI } } else if bStopAtNull != 0 { if regBignull == 0 { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (regBase + int32(nEq))) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (regBase + int32(nEq))) endEq = 0 } nConstraint++ @@ -126991,7 +124761,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI if nConstraint != 0 { if regBignull != 0 { // Except, skip the end-of-range check while doing the NULL-scan - Xsqlite3VdbeAddOp2(tls, v, 20, regBignull, (Xsqlite3VdbeCurrentAddr(tls, v) + 3)) + Xsqlite3VdbeAddOp2(tls, v, OP_IfNot, regBignull, (Xsqlite3VdbeCurrentAddr(tls, v) + 3)) Xsqlite3VdbeComment(tls, v, ts+23391 /* "If NULL-scan 2nd..." */, 0) } @@ -127003,7 +124773,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // During a NULL-scan, check to see if we have reached the end of // the NULLs - Xsqlite3VdbeAddOp2(tls, v, 18, regBignull, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_If, regBignull, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) Xsqlite3VdbeComment(tls, v, ts+23413 /* "If NULL-scan 1st..." */, 0) op = int32(aEndOp[((bRev * 2) + int32(bSeekPastNull))]) @@ -127012,22 +124782,22 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00040000)) != 0 { - Xsqlite3VdbeAddOp2(tls, v, 118, iIdxCur, 1) + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IN_EARLYOUT) != 0 { + Xsqlite3VdbeAddOp2(tls, v, OP_SeekHit, iIdxCur, 1) } // Seek the table cursor, if required - omitTable = (libc.Bool32((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000040)) != U32(0)) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0020) == 0))) + omitTable = (libc.Bool32((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IDX_ONLY) != U32(0)) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_OR_SUBCLAUSE) == 0))) if omitTable != 0 { // pIdx is a covering index. No need to access the main table. - } else if ((*Table)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FpTable))).FtabFlags & U32(0x0080)) == U32(0) { - if ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0400) != 0) || - (((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x1000) != 0) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == 1) || (int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm) == 0))) { + } else if ((*Table)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FpTable))).FtabFlags & TF_WithoutRowid) == U32(0) { + if ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_SEEK_TABLE) != 0) || + (((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_SEEK_UNIQ_TABLE) != 0) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == ONEPASS_SINGLE) || (int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm) == 0))) { iRowidReg = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 134, iIdxCur, iRowidReg) - Xsqlite3VdbeAddOp3(tls, v, 32, iCur, 0, iRowidReg) + Xsqlite3VdbeAddOp2(tls, v, OP_IdxRowid, iIdxCur, iRowidReg) + Xsqlite3VdbeAddOp3(tls, v, OP_NotExists, iCur, 0, iRowidReg) } else { codeDeferredSeek(tls, pWInfo, pIdx, iCur, iIdxCur) @@ -127037,9 +124807,9 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI iRowidReg = Xsqlite3GetTempRange(tls, pParse, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) for j = 0; j < int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol); j++ { k = int32(Xsqlite3TableColumnToIndex(tls, pIdx, *(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2)))) - Xsqlite3VdbeAddOp3(tls, v, 89, iIdxCur, k, (iRowidReg + j)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iIdxCur, k, (iRowidReg + j)) } - Xsqlite3VdbeAddOp4Int(tls, v, 29, iCur, addrCont, + Xsqlite3VdbeAddOp4Int(tls, v, OP_NotFound, iCur, addrCont, iRowidReg, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) } @@ -127060,7 +124830,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // OR clause, since the transformation will become invalid once we // move forward to the next index. // https://sqlite.org/src/info/4e8e4857d32d401f - if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0020) == 0 { + if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_OR_SUBCLAUSE) == 0 { whereIndexExprTrans(tls, pIdx, iCur, iIdxCur, pWInfo) } @@ -127082,29 +124852,29 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI } // Record the instruction used to terminate the loop. - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00001000)) != 0 { - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(173) + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_ONEROW) != 0 { + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Noop } else if bRev != 0 { - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(4) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Prev } else { - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(5) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Next } (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iIdxCur (*WhereLevel)(unsafe.Pointer(pLevel)).Fp3 = func() uint8 { - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00010000)) != U32(0) { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_UNQ_WANTED) != U32(0) { return uint8(1) } return uint8(0) }() - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x0000000f)) == U32(0) { - (*WhereLevel)(unsafe.Pointer(pLevel)).Fp5 = U8(1) + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_CONSTRAINT) == U32(0) { + (*WhereLevel)(unsafe.Pointer(pLevel)).Fp5 = SQLITE_STMTSTATUS_FULLSCAN_STEP } else { } if omitTable != 0 { pIdx = uintptr(0) } - } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00002000)) != 0 { + } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_MULTI_OR) != 0 { // Case 5: Two or more separately indexed terms connected by OR // // Example: @@ -127163,10 +124933,10 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI var pAndExpr uintptr = uintptr(0) // An ".. AND (...)" expression var pTab uintptr = (*SrcList_item)(unsafe.Pointer(pTabItem)).FpTab - pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(0)*8)) + pTerm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) pOrWc = (*(*uintptr)(unsafe.Pointer(pTerm + 40 /* &.u */)) /* &.wc */) - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(65) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Return (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = regReturn // Set up a new SrcList in pOrTab containing the table being scanned @@ -127202,19 +124972,19 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // correct response for the end-of-loop code (the OP_Return) is to // fall through to the next instruction, just as an OP_Next does if // called on an uninitialized cursor. - if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0010) == 0 { - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_DUPLICATES_OK) == 0 { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { regRowset = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, regRowset) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, regRowset) } else { var pPk uintptr = Xsqlite3PrimaryKeyIndex(tls, pTab) regRowset = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - Xsqlite3VdbeAddOp2(tls, v, 100, regRowset, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, regRowset, int32((*Index)(unsafe.Pointer(pPk)).FnKeyCol)) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pPk) } regRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) } - iRetInit = Xsqlite3VdbeAddOp2(tls, v, 69, 0, regReturn) + iRetInit = Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regReturn) // If the original WHERE clause is z of the form: (x1 OR x2 OR ...) AND y // Then for every term xN, evaluate as the subexpression: xN AND z @@ -127237,10 +125007,10 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI continue } - if (int32((*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*64)).FwtFlags) & (0x0002 | 0x0004)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*64)).FwtFlags) & (TERM_VIRTUAL | TERM_CODED)) != 0 { continue } - if (int32((*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*64)).FeOperator) & 0x1fff) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa+uintptr(iTerm)*64)).FeOperator) & WO_ALL) == 0 { continue } @@ -127253,18 +125023,18 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // op==TK_AND comparison inside of sqlite3PExpr() false, and this // prevents sqlite3PExpr() from implementing AND short-circuit // optimization, which we do not want here. - pAndExpr = Xsqlite3PExpr(tls, pParse, (44 | 0x10000), uintptr(0), pAndExpr) + pAndExpr = Xsqlite3PExpr(tls, pParse, (TK_AND | 0x10000), uintptr(0), pAndExpr) } } // Run a separate WHERE clause for each term of the OR clause. After // eliminating duplicates from other WHERE clauses, the action for each // sub-WHERE clause is to to invoke the main loop body as a subroutine. - wctrlFlags = (U16(0x0020 | (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0400))) + wctrlFlags = (U16(WHERE_OR_SUBCLAUSE | (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_SEEK_TABLE))) Xsqlite3VdbeExplain(tls, pParse, uint8(1), ts+23435 /* "MULTI-INDEX OR" */, 0) for ii = 0; ii < (*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm; ii++ { var pOrTerm uintptr = ((*WhereClause)(unsafe.Pointer(pOrWc)).Fa + uintptr(ii)*64) - if ((*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCur) || ((int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & 0x0400) != 0) { + if ((*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCur) || ((int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & WO_AND) != 0) { var pSubWInfo uintptr // Info for single OR-term scan var pOrExpr uintptr = (*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr // Current OR clause term var jmp1 int32 = 0 // Address of jump operation @@ -127282,7 +125052,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI if pSubWInfo != 0 { var pSubLoop uintptr var addrExplain int32 = Xsqlite3WhereExplainOneScan(tls, - pParse, pOrTab, ((pSubWInfo + 920 /* &.a */) + uintptr(0)*88), uint16(0)) + pParse, pOrTab, (pSubWInfo + 920 /* &.a */), uint16(0)) _ = addrExplain _ = addrExplain @@ -127290,16 +125060,16 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // duplicate rows from prior sub-WHERE clauses, and record the // rowid (or PRIMARY KEY) for the current row so that the same // row will be skipped in subsequent sub-WHERE clauses. - if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0010) == 0 { + if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_DUPLICATES_OK) == 0 { var iSet int32 = func() int32 { if ii == ((*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm - 1) { return -1 } return ii }() - if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0) { + if ((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0) { Xsqlite3ExprCodeGetColumnOfTable(tls, v, pTab, iCur, -1, regRowid) - jmp1 = Xsqlite3VdbeAddOp4Int(tls, v, 45, regRowset, 0, + jmp1 = Xsqlite3VdbeAddOp4Int(tls, v, OP_RowSetTest, regRowset, 0, regRowid, iSet) } else { @@ -127327,15 +125097,15 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // need to insert the key into the temp table, as it will never // be tested for. if iSet != 0 { - jmp1 = Xsqlite3VdbeAddOp4Int(tls, v, 30, regRowset, 0, r, nPk) + jmp1 = Xsqlite3VdbeAddOp4Int(tls, v, OP_Found, regRowset, 0, r, nPk) } if iSet >= 0 { - Xsqlite3VdbeAddOp3(tls, v, 91, r, nPk, regRowid) - Xsqlite3VdbeAddOp4Int(tls, v, 130, regRowset, regRowid, + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, r, nPk, regRowid) + Xsqlite3VdbeAddOp4Int(tls, v, OP_IdxInsert, regRowset, regRowid, r, nPk) if iSet != 0 { - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_USESEEKRESULT) } } @@ -127345,7 +125115,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI } // Invoke the main loop body as a subroutine - Xsqlite3VdbeAddOp2(tls, v, 12, regReturn, iLoopBody) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, regReturn, iLoopBody) // Jump here (skipping the main loop body subroutine) if the // current sub-WHERE row is a duplicate from prior sub-WHEREs. @@ -127372,11 +125142,11 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // terms, set pCov to the candidate covering index. Otherwise, set // pCov to NULL to indicate that no candidate covering index will // be available. - pSubLoop = (*WhereLevel)(unsafe.Pointer((pSubWInfo + 920 /* &.a */) + uintptr(0)*88)).FpWLoop + pSubLoop = (*WhereLevel)(unsafe.Pointer((pSubWInfo + 920 /* &.a */))).FpWLoop - if ((((*WhereLoop)(unsafe.Pointer(pSubLoop)).FwsFlags & U32(0x00000200)) != U32(0)) && + if ((((*WhereLoop)(unsafe.Pointer(pSubLoop)).FwsFlags & WHERE_INDEXED) != U32(0)) && ((ii == 0) || (*(*uintptr)(unsafe.Pointer((pSubLoop + 24 /* &.u */ /* &.btree */) + 8 /* &.pIndex */)) == pCov))) && - ((((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) || !((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pSubLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */))) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2)) { + ((((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) || !((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pSubLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */))) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY)) { pCov = *(*uintptr)(unsafe.Pointer(pSubLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) } else { @@ -127413,14 +125183,14 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI if (uint32(int32(*(*uint8)(unsafe.Pointer(pTabItem + 60 /* &.fg */ + 4 /* &.isRecursive */)) & 0x20 >> 5))) != 0 { // Tables marked isRecursive have only a single row that is stored in // a pseudo-cursor. No need to Rewind or Next such cursors. - (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = U8(173) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = OP_Noop } else { (*WhereLevel)(unsafe.Pointer(pLevel)).Fop = aStep[bRev] (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1 = iCur (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 = (1 + Xsqlite3VdbeAddOp2(tls, v, int32(aStart[bRev]), iCur, addrHalt)) - (*WhereLevel)(unsafe.Pointer(pLevel)).Fp5 = U8(1) + (*WhereLevel)(unsafe.Pointer(pLevel)).Fp5 = SQLITE_STMTSTATUS_FULLSCAN_STEP } } @@ -127455,7 +125225,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI var pE uintptr var skipLikeAddr int32 = 0 - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & (0x0002 | 0x0004)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & (TERM_VIRTUAL | TERM_CODED)) != 0 { goto __2 } if ((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & (*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady) != uint64(0) { @@ -127465,7 +125235,7 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI } pE = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr - if ((int32((*SrcList_item)(unsafe.Pointer(pTabItem)).Ffg.Fjointype) & 0x0008) != 0) && !(((*Expr)(unsafe.Pointer((pE))).Fflags & (U32(0x000001))) != U32(0)) { + if ((int32((*SrcList_item)(unsafe.Pointer(pTabItem)).Ffg.Fjointype) & JT_LEFT) != 0) && !(((*Expr)(unsafe.Pointer((pE))).Fflags & (EP_FromJoin)) != U32(0)) { goto __2 } @@ -127473,14 +125243,14 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI iNext = 2 goto __2 } - if (iLoop < 3) && ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x1000) != 0) { + if (iLoop < 3) && ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VARSELECT) != 0) { if iNext == 0 { iNext = 3 } goto __2 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0200) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_LIKECOND) != 0 { // If the TERM_LIKECOND flag is set, that means that the range search // is sufficient to guarantee that the LIKE operator is true, so we // can skip the call to the like(A,B) function. But this only works @@ -127488,11 +125258,11 @@ func Xsqlite3WhereCodeOneLoopStart(tls *libc.TLS, pParse uintptr, v uintptr, pWI // that compares BLOBs. goto __2 } - Xsqlite3ExprIfFalse(tls, pParse, pE, addrCont, 0x10) + Xsqlite3ExprIfFalse(tls, pParse, pE, addrCont, SQLITE_JUMPIFNULL) if skipLikeAddr != 0 { Xsqlite3VdbeJumpHere(tls, v, skipLikeAddr) } - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) } goto __2 @@ -127524,40 +125294,40 @@ __4: // var sEAlt Expr at bp+32, 72 var pAlt uintptr - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & (0x0002 | 0x0004)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & (TERM_VIRTUAL | TERM_CODED)) != 0 { goto __5 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (0x0002 | 0x0080)) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (WO_EQ | WO_IS)) == 0 { goto __5 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0800) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_EQUIV) == 0 { goto __5 } if (*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != iCur { goto __5 } - if (int32((*SrcList_item)(unsafe.Pointer(pTabItem)).Ffg.Fjointype) & 0x0008) != 0 { + if (int32((*SrcList_item)(unsafe.Pointer(pTabItem)).Ffg.Fjointype) & JT_LEFT) != 0 { goto __5 } pE = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr pAlt = Xsqlite3WhereFindTerm(tls, pWC, iCur, *(*int32)(unsafe.Pointer(pTerm + 40 /* &.u */)), notReady, - (uint32((0x0002 | 0x0001) | 0x0080)), uintptr(0)) + (uint32((WO_EQ | WO_IN) | WO_IS)), uintptr(0)) if pAlt == uintptr(0) { goto __5 } - if (int32((*WhereTerm)(unsafe.Pointer(pAlt)).FwtFlags) & (0x0004)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pAlt)).FwtFlags) & (TERM_CODED)) != 0 { goto __5 } - if (((int32((*WhereTerm)(unsafe.Pointer(pAlt)).FeOperator) & 0x0001) != 0) && - (((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAlt)).FpExpr)).Fflags & U32(0x000800)) != 0)) && + if (((int32((*WhereTerm)(unsafe.Pointer(pAlt)).FeOperator) & WO_IN) != 0) && + (((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAlt)).FpExpr)).Fflags & EP_xIsSelect) != 0)) && ((*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAlt)).FpExpr + 32 /* &.x */)))).FpEList)).FnExpr > 1) { goto __5 } *(*Expr)(unsafe.Pointer(bp + 32 /* sEAlt */)) = *(*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAlt)).FpExpr)) (*Expr)(unsafe.Pointer(bp + 32 /* &sEAlt */)).FpLeft = (*Expr)(unsafe.Pointer(pE)).FpLeft - Xsqlite3ExprIfFalse(tls, pParse, bp+32 /* &sEAlt */, addrCont, 0x10) + Xsqlite3ExprIfFalse(tls, pParse, bp+32 /* &sEAlt */, addrCont, SQLITE_JUMPIFNULL) } goto __5 @@ -127573,7 +125343,7 @@ __6: // at least one row of the right table has matched the left table. if (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) Xsqlite3VdbeComment(tls, v, ts+23459 /* "record LEFT JOIN..." */, 0) pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa j = 0 @@ -127583,7 +125353,7 @@ __6: } { - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & (0x0002 | 0x0004)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & (TERM_VIRTUAL | TERM_CODED)) != 0 { goto __8 } if ((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & (*WhereLevel)(unsafe.Pointer(pLevel)).FnotReady) != uint64(0) { @@ -127591,8 +125361,8 @@ __6: goto __8 } - Xsqlite3ExprIfFalse(tls, pParse, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr, addrCont, 0x10) - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004)) + Xsqlite3ExprIfFalse(tls, pParse, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr, addrCont, SQLITE_JUMPIFNULL) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) } goto __8 @@ -127610,21 +125380,21 @@ __6: var aStartOp = [8]U8{ U8(0), U8(0), - U8(37), // 2: (!start_constraints && startEq && !bRev) - U8(33), // 3: (!start_constraints && startEq && bRev) - U8(25), // 4: (start_constraints && !startEq && !bRev) - U8(22), // 5: (start_constraints && !startEq && bRev) - U8(24), // 6: (start_constraints && startEq && !bRev) - U8(23), // 7: (start_constraints && startEq && bRev) + OP_Rewind, // 2: (!start_constraints && startEq && !bRev) + OP_Last, // 3: (!start_constraints && startEq && bRev) + OP_SeekGT, // 4: (start_constraints && !startEq && !bRev) + OP_SeekLT, // 5: (start_constraints && !startEq && bRev) + OP_SeekGE, // 6: (start_constraints && startEq && !bRev) + OP_SeekLE, // 7: (start_constraints && startEq && bRev) } /* sqlite3.c:143140:21 */ var aEndOp = [4]U8{ - U8(41), // 0: (end_constraints && !bRev && !endEq) - U8(39), // 1: (end_constraints && !bRev && endEq) - U8(38), // 2: (end_constraints && bRev && !endEq) - U8(40), // 3: (end_constraints && bRev && endEq) -} /* sqlite3.c:143150:21 */ -var aStep = [2]U8{U8(5), U8(4)} /* sqlite3.c:143816:21 */ -var aStart = [2]U8{U8(37), U8(33)} /* sqlite3.c:143817:21 */ + OP_IdxGE, // 0: (end_constraints && !bRev && !endEq) + OP_IdxGT, // 1: (end_constraints && !bRev && endEq) + OP_IdxLE, // 2: (end_constraints && bRev && !endEq) + OP_IdxLT, // 3: (end_constraints && bRev && endEq) +} /* sqlite3.c:143150:21 */ +var aStep = [2]U8{OP_Next, OP_Prev} /* sqlite3.c:143816:21 */ +var aStart = [2]U8{OP_Rewind, OP_Last} /* sqlite3.c:143817:21 */ // Deallocate all memory associated with a WhereOrInfo object. func whereOrInfoDelete(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3.c:144024:13: */ @@ -127664,7 +125434,7 @@ func whereClauseInsert(tls *libc.TLS, pWC uintptr, p uintptr, wtFlags U16) int32 var db uintptr = (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse)).Fdb (*WhereClause)(unsafe.Pointer(pWC)).Fa = Xsqlite3DbMallocRawNN(tls, db, (uint64((uint64(unsafe.Sizeof(WhereTerm{})) * uint64((*WhereClause)(unsafe.Pointer(pWC)).FnSlot)) * uint64(2)))) if (*WhereClause)(unsafe.Pointer(pWC)).Fa == uintptr(0) { - if (int32(wtFlags) & 0x0001) != 0 { + if (int32(wtFlags) & TERM_DYNAMIC) != 0 { Xsqlite3ExprDelete(tls, db, p) } (*WhereClause)(unsafe.Pointer(pWC)).Fa = pOld @@ -127677,7 +125447,7 @@ func whereClauseInsert(tls *libc.TLS, pWC uintptr, p uintptr, wtFlags U16) int32 (*WhereClause)(unsafe.Pointer(pWC)).FnSlot = (int32(uint64(Xsqlite3DbMallocSize(tls, db, (*WhereClause)(unsafe.Pointer(pWC)).Fa)) / uint64(unsafe.Sizeof(WhereTerm{})))) } pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(libc.AssignInt32(&idx, libc.PostIncInt32(&(*WhereClause)(unsafe.Pointer(pWC)).FnTerm, 1)))*64) - if (p != 0) && (((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x040000))) != U32(0)) { + if (p != 0) && (((*Expr)(unsafe.Pointer((p))).Fflags & (EP_Unlikely)) != U32(0)) { (*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb = (LogEst(int32(Xsqlite3LogEst(tls, uint64((*Expr)(unsafe.Pointer(p)).FiTable))) - 270)) } else { (*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb = int16(1) @@ -127696,16 +125466,16 @@ func whereClauseInsert(tls *libc.TLS, pWC uintptr, p uintptr, wtFlags U16) int32 // "=", "<", ">", "<=", ">=", "IN", "IS", and "IS NULL" func allowedOp(tls *libc.TLS, op int32) int32 { /* sqlite3.c:144097:12: */ - return (libc.Bool32((((op == 49) || ((op >= 53) && (op <= 57))) || (op == 50)) || (op == 45))) + return (libc.Bool32((((op == TK_IN) || ((op >= TK_EQ) && (op <= TK_GE))) || (op == TK_ISNULL)) || (op == TK_IS))) } // Commute a comparison operator. Expressions of the form "X op Y" // are converted into "Y op X". func exprCommute(tls *libc.TLS, pParse uintptr, pExpr uintptr) U16 { /* sqlite3.c:144109:12: */ - if ((int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == 174) || - (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpRight)).Fop) == 174)) || + if ((int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_VECTOR) || + (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpRight)).Fop) == TK_VECTOR)) || (Xsqlite3BinaryCompareCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, (*Expr)(unsafe.Pointer(pExpr)).FpRight) != Xsqlite3BinaryCompareCollSeq(tls, pParse, (*Expr)(unsafe.Pointer(pExpr)).FpRight, (*Expr)(unsafe.Pointer(pExpr)).FpLeft)) { - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) ^= (U32(0x000200)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) ^= (EP_Commuted) } { var t uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpRight @@ -127713,9 +125483,9 @@ func exprCommute(tls *libc.TLS, pParse uintptr, pExpr uintptr) U16 { /* sqlite3. (*Expr)(unsafe.Pointer(pExpr)).FpLeft = t } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) >= 54 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) >= TK_GT { - (*Expr)(unsafe.Pointer(pExpr)).Fop = (U8(((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) - 54) ^ 2) + 54)) + (*Expr)(unsafe.Pointer(pExpr)).Fop = (U8(((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) - TK_GT) ^ 2) + TK_GT)) } return U16(0) } @@ -127724,15 +125494,15 @@ func exprCommute(tls *libc.TLS, pParse uintptr, pExpr uintptr) U16 { /* sqlite3. func operatorMask(tls *libc.TLS, op int32) U16 { /* sqlite3.c:144132:12: */ var c U16 - if op == 49 { - c = U16(0x0001) - } else if op == 50 { - c = U16(0x0100) - } else if op == 45 { - c = U16(0x0080) + if op == TK_IN { + c = WO_IN + } else if op == TK_ISNULL { + c = WO_ISNULL + } else if op == TK_IS { + c = WO_IS } else { - c = (U16(int32(0x0002) << (op - 53))) + c = (U16(int32(WO_EQ) << (op - TK_EQ))) } return c @@ -127769,29 +125539,29 @@ func isLikeOrGlob(tls *libc.TLS, pParse uintptr, pExpr uintptr, ppPrefix uintptr return 0 } pList = *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) - pLeft = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(1)*32)).FpExpr + pLeft = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + 1*32)).FpExpr - pRight = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(0)*32)).FpExpr) + pRight = Xsqlite3ExprSkipCollate(tls, (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FpExpr) op = int32((*Expr)(unsafe.Pointer(pRight)).Fop) - if (op == 153) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00800000)) == uint64(0)) { + if (op == TK_VARIABLE) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_EnableQPSG) == uint64(0)) { var pReprepare uintptr = (*Parse)(unsafe.Pointer(pParse)).FpReprepare var iCol int32 = int32((*Expr)(unsafe.Pointer(pRight)).FiColumn) - pVal = Xsqlite3VdbeGetBoundValue(tls, pReprepare, iCol, uint8(0x41)) - if (pVal != 0) && (Xsqlite3_value_type(tls, pVal) == 3) { + pVal = Xsqlite3VdbeGetBoundValue(tls, pReprepare, iCol, SQLITE_AFF_BLOB) + if (pVal != 0) && (Xsqlite3_value_type(tls, pVal) == SQLITE_TEXT) { z = Xsqlite3_value_text(tls, pVal) } Xsqlite3VdbeSetVarmask(tls, (*Parse)(unsafe.Pointer(pParse)).FpVdbe, iCol) - } else if op == 115 { + } else if op == TK_STRING { z = *(*uintptr)(unsafe.Pointer(pRight + 8 /* &.u */)) } if z != 0 { // Count the number of prefix characters prior to the first wildcard cnt = 0 - for ((((int32(libc.AssignUint8(&c, *(*U8)(unsafe.Pointer(z + uintptr(cnt)))))) != 0) && (int32(c) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(0)))))) && (int32(c) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(1)))))) && (int32(c) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(2))))) { + for ((((int32(libc.AssignUint8(&c, *(*U8)(unsafe.Pointer(z + uintptr(cnt)))))) != 0) && (int32(c) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */))))) && (int32(c) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + 1))))) && (int32(c) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + 2)))) { cnt++ - if (int32(c) == int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(3))))) && (int32(*(*U8)(unsafe.Pointer(z + uintptr(cnt)))) != 0) { + if (int32(c) == int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + 3)))) && (int32(*(*U8)(unsafe.Pointer(z + uintptr(cnt)))) != 0) { cnt++ } } @@ -127804,21 +125574,21 @@ func isLikeOrGlob(tls *libc.TLS, pParse uintptr, pExpr uintptr, ppPrefix uintptr // range search. The third is because the caller assumes that the pattern // consists of at least one character after all escapes have been // removed. - if ((cnt != 0) && (255 != int32(*(*U8)(unsafe.Pointer(z + uintptr((cnt - 1))))))) && ((cnt > 1) || (int32(*(*U8)(unsafe.Pointer(z + uintptr(0)))) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(3)))))) { + if ((cnt != 0) && (255 != int32(*(*U8)(unsafe.Pointer(z + uintptr((cnt - 1))))))) && ((cnt > 1) || (int32(*(*U8)(unsafe.Pointer(z))) != int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + 3))))) { var pPrefix uintptr // A "complete" match if the pattern ends with "*" or "%" - *(*int32)(unsafe.Pointer(pisComplete)) = (libc.Bool32((int32(c) == int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(0))))) && (int32(*(*U8)(unsafe.Pointer(z + uintptr((cnt + 1))))) == 0))) + *(*int32)(unsafe.Pointer(pisComplete)) = (libc.Bool32((int32(c) == int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */)))) && (int32(*(*U8)(unsafe.Pointer(z + uintptr((cnt + 1))))) == 0))) // Get the pattern prefix. Remove all escapes from the prefix. - pPrefix = Xsqlite3Expr(tls, db, 115, z) + pPrefix = Xsqlite3Expr(tls, db, TK_STRING, z) if pPrefix != 0 { var iFrom int32 var iTo int32 var zNew uintptr = *(*uintptr)(unsafe.Pointer(pPrefix + 8 /* &.u */)) *(*int8)(unsafe.Pointer(zNew + uintptr(cnt))) = int8(0) for iFrom = libc.AssignInt32(&iTo, 0); iFrom < cnt; iFrom++ { - if int32(*(*int8)(unsafe.Pointer(zNew + uintptr(iFrom)))) == int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + uintptr(3)))) { + if int32(*(*int8)(unsafe.Pointer(zNew + uintptr(iFrom)))) == int32(*(*U8)(unsafe.Pointer(bp /* &wc[0] */ + 3))) { iFrom++ } *(*int8)(unsafe.Pointer(zNew + uintptr(libc.PostIncInt32(&iTo, 1)))) = *(*int8)(unsafe.Pointer(zNew + uintptr(iFrom))) @@ -127837,19 +125607,19 @@ func isLikeOrGlob(tls *libc.TLS, pParse uintptr, pExpr uintptr, ppPrefix uintptr // 2019-06-10 https://sqlite.org/src/info/fd76310a5e843e07 // 2019-06-14 https://sqlite.org/src/info/ce8717f0885af975 // 2019-09-03 https://sqlite.org/src/info/0f0428096f17252a - if ((int32((*Expr)(unsafe.Pointer(pLeft)).Fop) != 164) || - (int32(Xsqlite3ExprAffinity(tls, pLeft)) != 0x42)) || + if ((int32((*Expr)(unsafe.Pointer(pLeft)).Fop) != TK_COLUMN) || + (int32(Xsqlite3ExprAffinity(tls, pLeft)) != SQLITE_AFF_TEXT)) || ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)))).FnModuleArg != 0) { var isNum int32 // var rDummy float64 at bp+8, 8 - isNum = Xsqlite3AtoF(tls, zNew, bp+8 /* &rDummy */, iTo, uint8(1)) + isNum = Xsqlite3AtoF(tls, zNew, bp+8 /* &rDummy */, iTo, SQLITE_UTF8) if isNum <= 0 { - if (iTo == 1) && (int32(*(*int8)(unsafe.Pointer(zNew + uintptr(0)))) == '-') { + if (iTo == 1) && (int32(*(*int8)(unsafe.Pointer(zNew))) == '-') { isNum = +1 } else { *(*int8)(unsafe.Pointer(zNew + uintptr((iTo - 1))))++ - isNum = Xsqlite3AtoF(tls, zNew, bp+8 /* &rDummy */, iTo, uint8(1)) + isNum = Xsqlite3AtoF(tls, zNew, bp+8 /* &rDummy */, iTo, SQLITE_UTF8) *(*int8)(unsafe.Pointer(zNew + uintptr((iTo - 1))))-- } } @@ -127864,10 +125634,10 @@ func isLikeOrGlob(tls *libc.TLS, pParse uintptr, pExpr uintptr, ppPrefix uintptr // If the RHS pattern is a bound parameter, make arrangements to // reprepare the statement when that parameter is rebound - if op == 153 { + if op == TK_VARIABLE { var v uintptr = (*Parse)(unsafe.Pointer(pParse)).FpVdbe Xsqlite3VdbeSetVarmask(tls, v, int32((*Expr)(unsafe.Pointer(pRight)).FiColumn)) - if (*(*int32)(unsafe.Pointer(pisComplete)) != 0) && (*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 8 /* &.u */)) + uintptr(1))) != 0) { + if (*(*int32)(unsafe.Pointer(pisComplete)) != 0) && (*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 8 /* &.u */)) + 1)) != 0) { // If the rhs of the LIKE expression is a variable, and the current // value of the variable means there is no need to invoke the LIKE // function, then no OP_Variable will be added to the program. @@ -127917,7 +125687,7 @@ func isAuxiliaryVtabOperator(tls *libc.TLS, db uintptr, pExpr uintptr, peOp2 uin bp := tls.Alloc(16) defer tls.Free(16) - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 169 { + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_FUNCTION { var pList uintptr var pCol uintptr // Column reference var i int32 @@ -127933,13 +125703,13 @@ func isAuxiliaryVtabOperator(tls *libc.TLS, db uintptr, pExpr uintptr, peOp2 uin // // vtab_column MATCH expression // MATCH(expression,vtab_column) - pCol = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(1)*32)).FpExpr + pCol = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + 1*32)).FpExpr - if ((int32((*Expr)(unsafe.Pointer((pCol))).Fop) == 164) && (*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)))).FnModuleArg != 0) { + if ((int32((*Expr)(unsafe.Pointer((pCol))).Fop) == TK_COLUMN) && (*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)))).FnModuleArg != 0) { for i = 0; i < (int32(uint64(unsafe.Sizeof(aOp)) / uint64(unsafe.Sizeof(Op2{})))); i++ { if Xsqlite3StrICmp(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), aOp[i].FzOp) == 0 { *(*uint8)(unsafe.Pointer(peOp2)) = aOp[i].FeOp2 - *(*uintptr)(unsafe.Pointer(ppRight)) = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(0)*32)).FpExpr + *(*uintptr)(unsafe.Pointer(ppRight)) = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FpExpr *(*uintptr)(unsafe.Pointer(ppLeft)) = pCol return 1 } @@ -127955,9 +125725,9 @@ func isAuxiliaryVtabOperator(tls *libc.TLS, db uintptr, pExpr uintptr, peOp2 uin // Historically, xFindFunction expected to see lower-case function // names. But for this use case, xFindFunction is expected to deal // with function names in an arbitrary case. - pCol = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(0)*32)).FpExpr + pCol = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FpExpr - if ((int32((*Expr)(unsafe.Pointer((pCol))).Fop) == 164) && (*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)))).FnModuleArg != 0) { + if ((int32((*Expr)(unsafe.Pointer((pCol))).Fop) == TK_COLUMN) && (*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCol + 64 /* &.y */)))).FnModuleArg != 0) { var pVtab uintptr var pMod uintptr // var xNotUsed uintptr at bp, 8 @@ -127969,24 +125739,24 @@ func isAuxiliaryVtabOperator(tls *libc.TLS, db uintptr, pExpr uintptr, peOp2 uin pMod = (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule if (*Sqlite3_module)(unsafe.Pointer(pMod)).FxFindFunction != uintptr(0) { i = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pMod + 144 /* &.xFindFunction */))))(tls, pVtab, 2, *(*uintptr)(unsafe.Pointer(pExpr + 8 /* &.u */)), bp /* &xNotUsed */, bp+8 /* &pNotUsed */) - if i >= 150 { + if i >= SQLITE_INDEX_CONSTRAINT_FUNCTION { *(*uint8)(unsafe.Pointer(peOp2)) = uint8(i) - *(*uintptr)(unsafe.Pointer(ppRight)) = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + uintptr(1)*32)).FpExpr + *(*uintptr)(unsafe.Pointer(ppRight)) = (*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */) + 1*32)).FpExpr *(*uintptr)(unsafe.Pointer(ppLeft)) = pCol return 1 } } } - } else if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 52) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 168)) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 51) { + } else if ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NE) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_ISNOT)) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NOTNULL) { var res int32 = 0 var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft var pRight uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpRight - if ((int32((*Expr)(unsafe.Pointer((pLeft))).Fop) == 164) && (*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)))).FnModuleArg != 0) { + if ((int32((*Expr)(unsafe.Pointer((pLeft))).Fop) == TK_COLUMN) && (*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pLeft + 64 /* &.y */)))).FnModuleArg != 0) { res++ } - if (pRight != 0) && (((int32((*Expr)(unsafe.Pointer((pRight))).Fop) == 164) && (*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)))).FnModuleArg != 0)) { + if (pRight != 0) && (((int32((*Expr)(unsafe.Pointer((pRight))).Fop) == TK_COLUMN) && (*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)) != uintptr(0))) && ((*Table)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRight + 64 /* &.y */)))).FnModuleArg != 0)) { res++ { var t uintptr = pLeft @@ -127997,14 +125767,14 @@ func isAuxiliaryVtabOperator(tls *libc.TLS, db uintptr, pExpr uintptr, peOp2 uin } *(*uintptr)(unsafe.Pointer(ppLeft)) = pLeft *(*uintptr)(unsafe.Pointer(ppRight)) = pRight - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 52 { - *(*uint8)(unsafe.Pointer(peOp2)) = uint8(68) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NE { + *(*uint8)(unsafe.Pointer(peOp2)) = SQLITE_INDEX_CONSTRAINT_NE } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 168 { - *(*uint8)(unsafe.Pointer(peOp2)) = uint8(69) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_ISNOT { + *(*uint8)(unsafe.Pointer(peOp2)) = SQLITE_INDEX_CONSTRAINT_ISNOT } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 51 { - *(*uint8)(unsafe.Pointer(peOp2)) = uint8(70) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NOTNULL { + *(*uint8)(unsafe.Pointer(peOp2)) = SQLITE_INDEX_CONSTRAINT_ISNOTNULL } return res } @@ -128018,25 +125788,17 @@ type Op2 = struct { } /* sqlite3.c:144350:18 */ var aOp = [4]Op2{ - { - FzOp: ts + 17162, /* "match" */ - FeOp2: uint8(64)}, - { - FzOp: ts + 16456, /* "glob" */ - FeOp2: uint8(66)}, - { - FzOp: ts + 16016, /* "like" */ - FeOp2: uint8(65)}, - { - FzOp: ts + 23480, /* "regexp" */ - FeOp2: uint8(67)}, + {FzOp: ts + 17162 /* "match" */, FeOp2: SQLITE_INDEX_CONSTRAINT_MATCH}, + {FzOp: ts + 16456 /* "glob" */, FeOp2: SQLITE_INDEX_CONSTRAINT_GLOB}, + {FzOp: ts + 16016 /* "like" */, FeOp2: SQLITE_INDEX_CONSTRAINT_LIKE}, + {FzOp: ts + 23480 /* "regexp" */, FeOp2: SQLITE_INDEX_CONSTRAINT_REGEXP}, } /* sqlite3.c:144353:7 */ // If the pBase expression originated in the ON or USING clause of // a join, then transfer the appropriate markings over to derived. func transferJoinMarkings(tls *libc.TLS, pDerived uintptr, pBase uintptr) { /* sqlite3.c:144447:13: */ if pDerived != 0 { - *(*U32)(unsafe.Pointer(pDerived + 4 /* &.flags */)) |= ((*Expr)(unsafe.Pointer(pBase)).Fflags & U32(0x000001)) + *(*U32)(unsafe.Pointer(pDerived + 4 /* &.flags */)) |= ((*Expr)(unsafe.Pointer(pBase)).Fflags & EP_FromJoin) (*Expr)(unsafe.Pointer(pDerived)).FiRightJoinTable = (*Expr)(unsafe.Pointer(pBase)).FiRightJoinTable } } @@ -128052,7 +125814,7 @@ func markTermAsChild(tls *libc.TLS, pWC uintptr, iChild int32, iParent int32) { // a conjunction, then return just pTerm when N==0. If N is exceeds // the number of available subterms, return NULL. func whereNthSubterm(tls *libc.TLS, pTerm uintptr, N int32) uintptr { /* sqlite3.c:144468:18: */ - if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) != 0x0400 { + if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) != WO_AND { if N == 0 { return pTerm } @@ -128089,14 +125851,14 @@ func whereCombineDisjuncts(tls *libc.TLS, pSrc uintptr, pWC uintptr, pOne uintpt var op int32 // Operator for the combined expression var idxNew int32 // Index in pWC of the next virtual term - if (int32((*WhereTerm)(unsafe.Pointer(pOne)).FeOperator) & ((((0x0002 | (int32(0x0002) << (56 - 53))) | (int32(0x0002) << (55 - 53))) | (int32(0x0002) << (54 - 53))) | (int32(0x0002) << (57 - 53)))) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pOne)).FeOperator) & ((((WO_EQ | (int32(WO_EQ) << (TK_LT - TK_EQ))) | (int32(WO_EQ) << (TK_LE - TK_EQ))) | (int32(WO_EQ) << (TK_GT - TK_EQ))) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) == 0 { return } - if (int32((*WhereTerm)(unsafe.Pointer(pTwo)).FeOperator) & ((((0x0002 | (int32(0x0002) << (56 - 53))) | (int32(0x0002) << (55 - 53))) | (int32(0x0002) << (54 - 53))) | (int32(0x0002) << (57 - 53)))) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTwo)).FeOperator) & ((((WO_EQ | (int32(WO_EQ) << (TK_LT - TK_EQ))) | (int32(WO_EQ) << (TK_LE - TK_EQ))) | (int32(WO_EQ) << (TK_GT - TK_EQ))) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) == 0 { return } - if ((int32(eOp) & ((0x0002 | (int32(0x0002) << (56 - 53))) | (int32(0x0002) << (55 - 53)))) != int32(eOp)) && - ((int32(eOp) & ((0x0002 | (int32(0x0002) << (54 - 53))) | (int32(0x0002) << (57 - 53)))) != int32(eOp)) { + if ((int32(eOp) & ((WO_EQ | (int32(WO_EQ) << (TK_LT - TK_EQ))) | (int32(WO_EQ) << (TK_LE - TK_EQ)))) != int32(eOp)) && + ((int32(eOp) & ((WO_EQ | (int32(WO_EQ) << (TK_GT - TK_EQ))) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) != int32(eOp)) { return } @@ -128108,11 +125870,11 @@ func whereCombineDisjuncts(tls *libc.TLS, pSrc uintptr, pWC uintptr, pOne uintpt } // If we reach this point, it means the two subterms can be combined if (int32(eOp) & (int32(eOp) - 1)) != 0 { - if (int32(eOp) & ((int32(0x0002) << (56 - 53)) | (int32(0x0002) << (55 - 53)))) != 0 { - eOp = (U16(int32(0x0002) << (55 - 53))) + if (int32(eOp) & ((int32(WO_EQ) << (TK_LT - TK_EQ)) | (int32(WO_EQ) << (TK_LE - TK_EQ)))) != 0 { + eOp = (U16(int32(WO_EQ) << (TK_LE - TK_EQ))) } else { - eOp = (U16(int32(0x0002) << (57 - 53))) + eOp = (U16(int32(WO_EQ) << (TK_GE - TK_EQ))) } } db = (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse)).Fdb @@ -128120,10 +125882,10 @@ func whereCombineDisjuncts(tls *libc.TLS, pSrc uintptr, pWC uintptr, pOne uintpt if pNew == uintptr(0) { return } - for op = 53; int32(eOp) != (int32(0x0002) << (op - 53)); op++ { + for op = TK_EQ; int32(eOp) != (int32(WO_EQ) << (op - TK_EQ)); op++ { } (*Expr)(unsafe.Pointer(pNew)).Fop = U8(op) - idxNew = whereClauseInsert(tls, pWC, pNew, (uint16(0x0002 | 0x0001))) + idxNew = whereClauseInsert(tls, pWC, pNew, (uint16(TERM_VIRTUAL | TERM_DYNAMIC))) exprAnalyze(tls, pSrc, pWC, idxNew) } @@ -128233,19 +125995,19 @@ func exprAnalyzeOrTerm(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) if pOrInfo == uintptr(0) { return } - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0010)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_ORINFO)) pOrWc = (pOrInfo /* &.wc */) libc.Xmemset(tls, pOrWc+40 /* &.aStatic */, 0, uint64(unsafe.Sizeof([8]WhereTerm{}))) Xsqlite3WhereClauseInit(tls, pOrWc, pWInfo) - Xsqlite3WhereSplit(tls, pOrWc, pExpr, uint8(43)) + Xsqlite3WhereSplit(tls, pOrWc, pExpr, TK_OR) Xsqlite3WhereExprAnalyze(tls, pSrc, pOrWc) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { return } // Compute the set of tables that might satisfy cases 1 or 3. - indexable = ^Bitmask(0) - chngToIN = ^Bitmask(0) + indexable = libc.CplUint64(uint64(0)) + chngToIN = libc.CplUint64(uint64(0)) i = ((*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm - 1) pOrTerm = (*WhereClause)(unsafe.Pointer(pOrWc)).Fa __1: @@ -128253,7 +126015,7 @@ __1: goto __3 } { - if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & 0x01ff) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & WO_SINGLE) == 0 { var pAndInfo uintptr chngToIN = uint64(0) @@ -128264,12 +126026,12 @@ __1: var j int32 var b Bitmask = uint64(0) *(*uintptr)(unsafe.Pointer(pOrTerm + 40 /* &.u */)) = pAndInfo - *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) |= U16((0x0020)) - (*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator = U16(0x0400) + *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) |= U16((TERM_ANDINFO)) + (*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator = WO_AND pAndWC = (pAndInfo /* &.wc */) libc.Xmemset(tls, pAndWC+40 /* &.aStatic */, 0, uint64(unsafe.Sizeof([8]WhereTerm{}))) Xsqlite3WhereClauseInit(tls, pAndWC, (*WhereClause)(unsafe.Pointer(pWC)).FpWInfo) - Xsqlite3WhereSplit(tls, pAndWC, (*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr, uint8(44)) + Xsqlite3WhereSplit(tls, pAndWC, (*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr, TK_AND) Xsqlite3WhereExprAnalyze(tls, pSrc, pAndWC) (*WhereClause)(unsafe.Pointer(pAndWC)).FpOuter = pWC if !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) { @@ -128282,7 +126044,7 @@ __1: { if (allowedOp(tls, int32((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pAndTerm)).FpExpr)).Fop)) != 0) || - (int32((*WhereTerm)(unsafe.Pointer(pAndTerm)).FeOperator) == 0x0040) { + (int32((*WhereTerm)(unsafe.Pointer(pAndTerm)).FeOperator) == WO_AUX) { b = b | (Xsqlite3WhereGetMask(tls, (pWInfo + 656 /* &.sMaskSet */), (*WhereTerm)(unsafe.Pointer(pAndTerm)).FleftCursor)) } @@ -128297,18 +126059,18 @@ __1: } indexable = indexable & (b) } - } else if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags) & 0x0008) != 0 { + } else if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags) & TERM_COPIED) != 0 { // Skip this term for now. We revisit it when we process the // corresponding TERM_VIRTUAL term } else { var b Bitmask b = Xsqlite3WhereGetMask(tls, (pWInfo + 656 /* &.sMaskSet */), (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor) - if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags) & 0x0002) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags) & TERM_VIRTUAL) != 0 { var pOther uintptr = ((*WhereClause)(unsafe.Pointer(pOrWc)).Fa + uintptr((*WhereTerm)(unsafe.Pointer(pOrTerm)).FiParent)*64) b = b | (Xsqlite3WhereGetMask(tls, (pWInfo + 656 /* &.sMaskSet */), (*WhereTerm)(unsafe.Pointer(pOther)).FleftCursor)) } indexable = indexable & (b) - if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & 0x0002) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & WO_EQ) == 0 { chngToIN = uint64(0) } else { chngToIN = chngToIN & (b) @@ -128329,20 +126091,20 @@ __3: // empty. (*WhereOrInfo)(unsafe.Pointer(pOrInfo)).Findexable = indexable if indexable != 0 { - (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = U16(0x0200) + (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = WO_OR (*WhereClause)(unsafe.Pointer(pWC)).FhasOr = U8(1) } else { - (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = U16(0x0200) + (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = WO_OR } // For a two-way OR, attempt to implementation case 2. if (indexable != 0) && ((*WhereClause)(unsafe.Pointer(pOrWc)).FnTerm == 2) { var iOne int32 = 0 var pOne uintptr - for (libc.AssignUintptr(&pOne, whereNthSubterm(tls, ((*WhereClause)(unsafe.Pointer(pOrWc)).Fa+uintptr(0)*64), libc.PostIncInt32(&iOne, 1)))) != uintptr(0) { + for (libc.AssignUintptr(&pOne, whereNthSubterm(tls, ((*WhereClause)(unsafe.Pointer(pOrWc)).Fa), libc.PostIncInt32(&iOne, 1)))) != uintptr(0) { var iTwo int32 = 0 var pTwo uintptr - for (libc.AssignUintptr(&pTwo, whereNthSubterm(tls, ((*WhereClause)(unsafe.Pointer(pOrWc)).Fa+uintptr(1)*64), libc.PostIncInt32(&iTwo, 1)))) != uintptr(0) { + for (libc.AssignUintptr(&pTwo, whereNthSubterm(tls, ((*WhereClause)(unsafe.Pointer(pOrWc)).Fa+1*64), libc.PostIncInt32(&iTwo, 1)))) != uintptr(0) { whereCombineDisjuncts(tls, pSrc, pWC, pOne, pTwo) } } @@ -128388,7 +126150,7 @@ __3: } { - *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0040))) + *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(TERM_OR_OK))) if (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCursor { // This is the 2-bit case and we are on the second iteration and // current term is from the first iteration. So skip this term. @@ -128435,7 +126197,7 @@ __3: { if (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor != iCursor { - *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) &= libc.Uint16FromInt32((^libc.Int32(0x0040))) + *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) &= libc.Uint16FromInt32((libc.CplInt32(TERM_OR_OK))) } else if (*(*int32)(unsafe.Pointer(pOrTerm + 40 /* &.u */)) != iColumn) || ((iColumn == (-2)) && (Xsqlite3ExprCompare(tls, pParse, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pOrTerm)).FpExpr)).FpLeft, pLeft, -1) != 0)) { okToChngToIN = 0 @@ -128450,7 +126212,7 @@ __3: if (affRight != 0) && (affRight != affLeft) { okToChngToIN = 0 } else { - *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) |= U16((0x0040)) + *(*U16)(unsafe.Pointer(pOrTerm + 18 /* &.wtFlags */)) |= U16((TERM_OR_OK)) } } @@ -128480,7 +126242,7 @@ __3: goto __15 } { - if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags) & 0x0040) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FwtFlags) & TERM_OR_OK) == 0 { goto __14 } @@ -128499,13 +126261,13 @@ __3: ; pDup = Xsqlite3ExprDup(tls, db, pLeft, 0) - pNew = Xsqlite3PExpr(tls, pParse, 49, pDup, uintptr(0)) + pNew = Xsqlite3PExpr(tls, pParse, TK_IN, pDup, uintptr(0)) if pNew != 0 { var idxNew int32 transferJoinMarkings(tls, pNew, pExpr) *(*uintptr)(unsafe.Pointer(pNew + 32 /* &.x */)) = pList - idxNew = whereClauseInsert(tls, pWC, pNew, (uint16(0x0002 | 0x0001))) + idxNew = whereClauseInsert(tls, pWC, pNew, (uint16(TERM_VIRTUAL | TERM_DYNAMIC))) exprAnalyze(tls, pSrc, pWC, idxNew) // pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where used again @@ -128534,19 +126296,19 @@ func termIsEquivalence(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { /* var aff1 int8 var aff2 int8 var pColl uintptr - if !((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (0x0080)) == 0) { + if !((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (SQLITE_Transitive)) == 0) { return 0 } - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 53) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 45) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_EQ) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_IS) { return 0 } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0) { return 0 } aff1 = Xsqlite3ExprAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) aff2 = Xsqlite3ExprAffinity(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) if (int32(aff1) != int32(aff2)) && - (!((int32(aff1)) >= 0x43) || !((int32(aff2)) >= 0x43)) { + (!((int32(aff1)) >= SQLITE_AFF_NUMERIC) || !((int32(aff2)) >= SQLITE_AFF_NUMERIC)) { return 0 } pColl = Xsqlite3ExprCompareCollSeq(tls, pParse, pExpr) @@ -128623,8 +126385,8 @@ __3: continue } if Xsqlite3ExprCompareSkip(tls, pExpr, (*ExprList_item)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FaColExpr+8 /* &.a */)+uintptr(i)*32)).FpExpr, iCur) == 0 { - *(*int32)(unsafe.Pointer(aiCurCol + uintptr(0)*4)) = iCur - *(*int32)(unsafe.Pointer(aiCurCol + uintptr(1)*4)) = -2 + *(*int32)(unsafe.Pointer(aiCurCol)) = iCur + *(*int32)(unsafe.Pointer(aiCurCol + 1*4)) = -2 return 1 } } @@ -128637,13 +126399,13 @@ func exprMightBeIndexed(tls *libc.TLS, pFrom uintptr, mPrereq Bitmask, aiCurCol // inequality constraint (>, <, >= or <=), perform the processing // on the first element of the vector. - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 174) && ((op >= 54) && (op <= 57)) { - pExpr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + uintptr(0)*32)).FpExpr + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_VECTOR) && ((op >= TK_GT) && (op <= TK_GE)) { + pExpr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */))).FpExpr } - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164 { - *(*int32)(unsafe.Pointer(aiCurCol + uintptr(0)*4)) = (*Expr)(unsafe.Pointer(pExpr)).FiTable - *(*int32)(unsafe.Pointer(aiCurCol + uintptr(1)*4)) = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN { + *(*int32)(unsafe.Pointer(aiCurCol)) = (*Expr)(unsafe.Pointer(pExpr)).FiTable + *(*int32)(unsafe.Pointer(aiCurCol + 1*4)) = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) return 1 } if mPrereq == uint64(0) { @@ -128700,17 +126462,17 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s prereqLeft = Xsqlite3WhereExprUsage(tls, pMaskSet, (*Expr)(unsafe.Pointer(pExpr)).FpLeft) op = int32((*Expr)(unsafe.Pointer(pExpr)).Fop) - if op == 49 { + if op == TK_IN { if Xsqlite3ExprCheckIN(tls, pParse, pExpr) != 0 { return } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = exprSelectUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) } else { (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = Xsqlite3WhereExprListUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */))) } - } else if op == 50 { + } else if op == TK_ISNULL { (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = uint64(0) } else { (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight = Xsqlite3WhereExprUsage(tls, pMaskSet, (*Expr)(unsafe.Pointer(pExpr)).FpRight) @@ -128718,9 +126480,9 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s (*WhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect = 0 prereqAll = Xsqlite3WhereExprUsageNN(tls, pMaskSet, pExpr) if (*WhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect != 0 { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x1000)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_VARSELECT)) } - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0) { var x Bitmask = Xsqlite3WhereGetMask(tls, pMaskSet, int32((*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable)) prereqAll = prereqAll | (x) extraRight = (x - uint64(1)) // ON clause terms may not be used with an index @@ -128741,9 +126503,9 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s var pRight uintptr = Xsqlite3ExprSkipCollate(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) var opMask U16 if ((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight & prereqLeft) == uint64(0) { - opMask = uint16(0x1fff) + opMask = WO_ALL } else { - opMask = uint16(0x0800) + opMask = WO_EQUIV } if (*WhereTerm)(unsafe.Pointer(pTerm)).FiField > 0 { @@ -128752,12 +126514,12 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s } if exprMightBeIndexed(tls, pSrc, prereqLeft, bp /* &aiCurCol[0] */, pLeft, op) != 0 { - (*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */ + uintptr(0)*4)) - *(*int32)(unsafe.Pointer(pTerm + 40 /* &.u */)) = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */ + uintptr(1)*4)) + (*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */)) + *(*int32)(unsafe.Pointer(pTerm + 40 /* &.u */)) = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */ + 1*4)) (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = (U16(int32(operatorMask(tls, op)) & int32(opMask))) } - if op == 45 { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0800)) + if op == TK_IS { + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_IS)) } if (pRight != 0) && (exprMightBeIndexed(tls, pSrc, (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight, bp /* &aiCurCol[0] */, pRight, op) != 0) { @@ -128772,35 +126534,35 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s Xsqlite3ExprDelete(tls, db, pDup) return } - idxNew = whereClauseInsert(tls, pWC, pDup, (uint16(0x0002 | 0x0001))) + idxNew = whereClauseInsert(tls, pWC, pDup, (uint16(TERM_VIRTUAL | TERM_DYNAMIC))) if idxNew == 0 { return } pNew = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*64) markTermAsChild(tls, pWC, idxNew, idxTerm) - if op == 45 { - *(*U16)(unsafe.Pointer(pNew + 18 /* &.wtFlags */)) |= U16((0x0800)) + if op == TK_IS { + *(*U16)(unsafe.Pointer(pNew + 18 /* &.wtFlags */)) |= U16((TERM_IS)) } pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*64) - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_COPIED)) if termIsEquivalence(tls, pParse, pDup) != 0 { - *(*U16)(unsafe.Pointer(pTerm + 20 /* &.eOperator */)) |= U16((0x0800)) - eExtraOp = U16(0x0800) + *(*U16)(unsafe.Pointer(pTerm + 20 /* &.eOperator */)) |= U16((WO_EQUIV)) + eExtraOp = WO_EQUIV } } else { pDup = pExpr pNew = pTerm } *(*U16)(unsafe.Pointer(pNew + 18 /* &.wtFlags */)) |= U16((int32(exprCommute(tls, pParse, pDup)))) - (*WhereTerm)(unsafe.Pointer(pNew)).FleftCursor = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */ + uintptr(0)*4)) - *(*int32)(unsafe.Pointer(pNew + 40 /* &.u */)) = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */ + uintptr(1)*4)) + (*WhereTerm)(unsafe.Pointer(pNew)).FleftCursor = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */)) + *(*int32)(unsafe.Pointer(pNew + 40 /* &.u */)) = *(*int32)(unsafe.Pointer(bp /* &aiCurCol[0] */ + 1*4)) (*WhereTerm)(unsafe.Pointer(pNew)).FprereqRight = (prereqLeft | extraRight) (*WhereTerm)(unsafe.Pointer(pNew)).FprereqAll = prereqAll (*WhereTerm)(unsafe.Pointer(pNew)).FeOperator = (U16((int32(operatorMask(tls, int32((*Expr)(unsafe.Pointer(pDup)).Fop))) + int32(eExtraOp)) & int32(opMask))) } - } else if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 48) && (int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == 44) { + } else if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_BETWEEN) && (int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND) { var pList uintptr = *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) var i int32 @@ -128811,13 +126573,13 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s Xsqlite3ExprDup(tls, db, (*Expr)(unsafe.Pointer(pExpr)).FpLeft, 0), Xsqlite3ExprDup(tls, db, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FpExpr, 0)) transferJoinMarkings(tls, pNewExpr, pExpr) - idxNew = whereClauseInsert(tls, pWC, pNewExpr, (uint16(0x0002 | 0x0001))) + idxNew = whereClauseInsert(tls, pWC, pNewExpr, (uint16(TERM_VIRTUAL | TERM_DYNAMIC))) exprAnalyze(tls, pSrc, pWC, idxNew) pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*64) markTermAsChild(tls, pWC, idxNew, idxTerm) } - } else if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 43 { + } else if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_OR { exprAnalyzeOrTerm(tls, pSrc, pWC, idxTerm) pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*64) @@ -128835,7 +126597,7 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s // for LIKE) then the lower-bound is made all uppercase and the upper- // bound is made all lowercase so that the bounds also work when comparing // BLOBs. - if (int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == 44) && + if (int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND) && (isLikeOrGlob(tls, pParse, pExpr, bp+8 /* &pStr1 */, bp+16 /* &isComplete */, bp+20 /* &noCase */) != 0) { var pLeft uintptr // LHS of LIKE/GLOB operator var pStr2 uintptr // Copy of pStr1 - RHS of LIKE/GLOB operator @@ -128844,9 +126606,9 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s var idxNew1 int32 var idxNew2 int32 var zCollSeqName uintptr // Name of collating sequence - var wtFlags U16 = (U16((0x0100 | 0x0002) | 0x0001)) + var wtFlags U16 = (U16((TERM_LIKEOPT | TERM_VIRTUAL) | TERM_DYNAMIC)) - pLeft = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + uintptr(1)*32)).FpExpr + pLeft = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)) + 8 /* &.a */) + 1*32)).FpExpr pStr2 = Xsqlite3ExprDup(tls, db, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStr1 */)), 0) // Convert the lower bound to upper-case and the upper bound to @@ -128855,7 +126617,7 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s if (*(*int32)(unsafe.Pointer(bp + 20 /* noCase */)) != 0) && !(int32((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed) != 0) { var i int32 var c int8 - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0400)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_LIKE)) for i = 0; (int32(libc.AssignInt8(&c, *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pStr1 */)) + 8 /* &.u */)) + uintptr(i)))))) != 0; i++ { *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pStr1 */)) + 8 /* &.u */)) + uintptr(i))) = (int8((int32(c)) & ^(int32(Xsqlite3CtypeMap[uint8(c)]) & 0x20))) *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pStr2 + 8 /* &.u */)) + uintptr(i))) = int8(Xsqlite3UpperToLower[uint8(c)]) @@ -128887,7 +126649,7 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s return uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)) }() pNewExpr1 = Xsqlite3ExprDup(tls, db, pLeft, 0) - pNewExpr1 = Xsqlite3PExpr(tls, pParse, 57, + pNewExpr1 = Xsqlite3PExpr(tls, pParse, TK_GE, Xsqlite3ExprAddCollateString(tls, pParse, pNewExpr1, zCollSeqName), *(*uintptr)(unsafe.Pointer(bp + 8 /* pStr1 */))) transferJoinMarkings(tls, pNewExpr1, pExpr) @@ -128895,7 +126657,7 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s exprAnalyze(tls, pSrc, pWC, idxNew1) pNewExpr2 = Xsqlite3ExprDup(tls, db, pLeft, 0) - pNewExpr2 = Xsqlite3PExpr(tls, pParse, 56, + pNewExpr2 = Xsqlite3PExpr(tls, pParse, TK_LT, Xsqlite3ExprAddCollateString(tls, pParse, pNewExpr2, zCollSeqName), pStr2) transferJoinMarkings(tls, pNewExpr2, pExpr) @@ -128917,7 +126679,7 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s // This information is used by the xBestIndex methods of // virtual tables. The native query optimizer does not attempt // to do anything with MATCH functions. - if int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == 44 { + if int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND { *(*uintptr)(unsafe.Pointer(bp + 40 /* pRight */)) = uintptr(0) *(*uintptr)(unsafe.Pointer(bp + 32 /* pLeft */)) = uintptr(0) var res int32 = isAuxiliaryVtabOperator(tls, db, pExpr, bp+24 /* &eOp2 */, bp+32 /* &pLeft */, bp+40 /* &pRight */) @@ -128931,23 +126693,23 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s prereqColumn = Xsqlite3WhereExprUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(bp + 32 /* pLeft */))) if (prereqExpr & prereqColumn) == uint64(0) { var pNewExpr uintptr - pNewExpr = Xsqlite3PExpr(tls, pParse, 46, + pNewExpr = Xsqlite3PExpr(tls, pParse, TK_MATCH, uintptr(0), Xsqlite3ExprDup(tls, db, *(*uintptr)(unsafe.Pointer(bp + 40 /* pRight */)), 0)) - if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0)) && (pNewExpr != 0) { - *(*U32)(unsafe.Pointer(pNewExpr + 4 /* &.flags */)) |= (U32(0x000001)) + if (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0)) && (pNewExpr != 0) { + *(*U32)(unsafe.Pointer(pNewExpr + 4 /* &.flags */)) |= (EP_FromJoin) (*Expr)(unsafe.Pointer(pNewExpr)).FiRightJoinTable = (*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable } - idxNew = whereClauseInsert(tls, pWC, pNewExpr, (uint16(0x0002 | 0x0001))) + idxNew = whereClauseInsert(tls, pWC, pNewExpr, (uint16(TERM_VIRTUAL | TERM_DYNAMIC))) pNewTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*64) (*WhereTerm)(unsafe.Pointer(pNewTerm)).FprereqRight = prereqExpr (*WhereTerm)(unsafe.Pointer(pNewTerm)).FleftCursor = (*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* pLeft */)))).FiTable *(*int32)(unsafe.Pointer(pNewTerm + 40 /* &.u */)) = int32((*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* pLeft */)))).FiColumn) - (*WhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = U16(0x0040) + (*WhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = WO_AUX (*WhereTerm)(unsafe.Pointer(pNewTerm)).FeMatchOp = *(*uint8)(unsafe.Pointer(bp + 24 /* eOp2 */)) markTermAsChild(tls, pWC, idxNew, idxTerm) pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*64) - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_COPIED)) (*WhereTerm)(unsafe.Pointer(pNewTerm)).FprereqAll = (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll } { @@ -128966,12 +126728,12 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s // // This is only required if at least one side of the comparison operation // is not a sub-select. - if ((((int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == 44) && - ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 53) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 45))) && + if ((((int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND) && + ((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_EQ) || (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IS))) && ((libc.AssignInt32(&nLeft, Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft))) > 1)) && (Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpRight) == nLeft)) && - ((((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fflags & U32(0x000800)) == U32(0)) || - (((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpRight)).Fflags & U32(0x000800)) == U32(0))) { + ((((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fflags & EP_xIsSelect) == U32(0)) || + (((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpRight)).Fflags & EP_xIsSelect) == U32(0))) { var i int32 for i = 0; i < nLeft; i++ { var idxNew int32 @@ -128981,11 +126743,11 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s pNew = Xsqlite3PExpr(tls, pParse, int32((*Expr)(unsafe.Pointer(pExpr)).Fop), pLeft, pRight) transferJoinMarkings(tls, pNew, pExpr) - idxNew = whereClauseInsert(tls, pWC, pNew, uint16(0x0001)) + idxNew = whereClauseInsert(tls, pWC, pNew, TERM_DYNAMIC) exprAnalyze(tls, pSrc, pWC, idxNew) } pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*64) - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004 | 0x0002)) // Disable the original + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED | TERM_VIRTUAL)) // Disable the original (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator = U16(0) } @@ -128997,14 +126759,14 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s // // This only works if the RHS is a simple SELECT (not a compound) that does // not use window functions. - if (((((int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == 44) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 49)) && ((*WhereTerm)(unsafe.Pointer(pTerm)).FiField == 0)) && - (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == 174)) && + if (((((int32((*WhereClause)(unsafe.Pointer(pWC)).Fop) == TK_AND) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_IN)) && ((*WhereTerm)(unsafe.Pointer(pTerm)).FiField == 0)) && + (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_VECTOR)) && ((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpPrior == uintptr(0))) && ((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)))).FpWin == uintptr(0)) { var i int32 for i = 0; i < Xsqlite3ExprVectorSize(tls, (*Expr)(unsafe.Pointer(pExpr)).FpLeft); i++ { var idxNew int32 - idxNew = whereClauseInsert(tls, pWC, pExpr, uint16(0x0002)) + idxNew = whereClauseInsert(tls, pWC, pExpr, TERM_VIRTUAL) (*WhereTerm)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*64)).FiField = (i + 1) exprAnalyze(tls, pSrc, pWC, idxNew) markTermAsChild(tls, pWC, idxNew, idxTerm) @@ -129017,31 +126779,31 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s // virtual term of that form. // // Note that the virtual term must be tagged with TERM_VNULL. - if ((((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 51) && - (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == 164)) && + if ((((int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_NOTNULL) && + (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).Fop) == TK_COLUMN)) && (int32((*Expr)(unsafe.Pointer((*Expr)(unsafe.Pointer(pExpr)).FpLeft)).FiColumn) >= 0)) && - !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0))) && - ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0) { + !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0))) && + ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0) { var pNewExpr uintptr var pLeft uintptr = (*Expr)(unsafe.Pointer(pExpr)).FpLeft var idxNew int32 var pNewTerm uintptr - pNewExpr = Xsqlite3PExpr(tls, pParse, 54, + pNewExpr = Xsqlite3PExpr(tls, pParse, TK_GT, Xsqlite3ExprDup(tls, db, pLeft, 0), - Xsqlite3ExprAlloc(tls, db, 119, uintptr(0), 0)) + Xsqlite3ExprAlloc(tls, db, TK_NULL, uintptr(0), 0)) idxNew = whereClauseInsert(tls, pWC, pNewExpr, - (uint16((0x0002 | 0x0001) | 0x0080))) + (uint16((TERM_VIRTUAL | TERM_DYNAMIC) | TERM_VNULL))) if idxNew != 0 { pNewTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxNew)*64) (*WhereTerm)(unsafe.Pointer(pNewTerm)).FprereqRight = uint64(0) (*WhereTerm)(unsafe.Pointer(pNewTerm)).FleftCursor = (*Expr)(unsafe.Pointer(pLeft)).FiTable *(*int32)(unsafe.Pointer(pNewTerm + 40 /* &.u */)) = int32((*Expr)(unsafe.Pointer(pLeft)).FiColumn) - (*WhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = (U16(int32(0x0002) << (54 - 53))) + (*WhereTerm)(unsafe.Pointer(pNewTerm)).FeOperator = (U16(int32(WO_EQ) << (TK_GT - TK_EQ))) markTermAsChild(tls, pWC, idxNew, idxTerm) pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(idxTerm)*64) - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0008)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_COPIED)) (*WhereTerm)(unsafe.Pointer(pNewTerm)).FprereqAll = (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll } } @@ -129053,7 +126815,7 @@ func exprAnalyze(tls *libc.TLS, pSrc uintptr, pWC uintptr, idxTerm int32) { /* s *(*Bitmask)(unsafe.Pointer(pTerm + 48 /* &.prereqRight */)) |= (extraRight) } -var ops = [2]U8{U8(57), U8(55)} /* sqlite3.c:145161:21 */ +var ops = [2]U8{TK_GE, TK_LE} /* sqlite3.c:145161:21 */ // ************************************************************************** // @@ -129114,12 +126876,12 @@ __1: goto __3 } { - if (int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags) & 0x0001) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags) & TERM_DYNAMIC) != 0 { Xsqlite3ExprDelete(tls, db, (*WhereTerm)(unsafe.Pointer(a)).FpExpr) } - if (int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags) & 0x0010) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags) & TERM_ORINFO) != 0 { whereOrInfoDelete(tls, db, *(*uintptr)(unsafe.Pointer(a + 40 /* &.u */))) - } else if (int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags) & 0x0020) != 0 { + } else if (int32((*WhereTerm)(unsafe.Pointer(a)).FwtFlags) & TERM_ANDINFO) != 0 { whereAndInfoDelete(tls, db, *(*uintptr)(unsafe.Pointer(a + 40 /* &.u */))) } @@ -129142,13 +126904,13 @@ __3: // tree. func Xsqlite3WhereExprUsageNN(tls *libc.TLS, pMaskSet uintptr, p uintptr) Bitmask { /* sqlite3.c:145504:24: */ var mask Bitmask - if (int32((*Expr)(unsafe.Pointer(p)).Fop) == 164) && !(((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000008))) != U32(0)) { + if (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN) && !(((*Expr)(unsafe.Pointer((p))).Fflags & (EP_FixedCol)) != U32(0)) { return Xsqlite3WhereGetMask(tls, pMaskSet, (*Expr)(unsafe.Pointer(p)).FiTable) - } else if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x004000 | 0x800000))) != U32(0) { + } else if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(EP_TokenOnly | EP_Leaf))) != U32(0) { return uint64(0) } - if int32((*Expr)(unsafe.Pointer(p)).Fop) == 176 { + if int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_IF_NULL_ROW { mask = Xsqlite3WhereGetMask(tls, pMaskSet, (*Expr)(unsafe.Pointer(p)).FiTable) } else { mask = uint64(0) @@ -129159,15 +126921,15 @@ func Xsqlite3WhereExprUsageNN(tls *libc.TLS, pMaskSet uintptr, p uintptr) Bitmas if (*Expr)(unsafe.Pointer(p)).FpRight != 0 { mask = mask | (Xsqlite3WhereExprUsageNN(tls, pMaskSet, (*Expr)(unsafe.Pointer(p)).FpRight)) - } else if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000800))) != U32(0) { - if ((*Expr)(unsafe.Pointer((p))).Fflags & (U32(0x000020))) != U32(0) { + } else if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_xIsSelect)) != U32(0) { + if ((*Expr)(unsafe.Pointer((p))).Fflags & (EP_VarSelect)) != U32(0) { (*WhereMaskSet)(unsafe.Pointer(pMaskSet)).FbVarSelect = 1 } mask = mask | (exprSelectUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))) } else if *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)) != 0 { mask = mask | (Xsqlite3WhereExprListUsage(tls, pMaskSet, *(*uintptr)(unsafe.Pointer(p + 32 /* &.x */)))) } - if ((int32((*Expr)(unsafe.Pointer(p)).Fop) == 169) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == 165)) && (*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) != 0) { + if ((int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_FUNCTION) || (int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_AGG_FUNCTION)) && (*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) != 0) { mask = mask | (Xsqlite3WhereExprListUsage(tls, pMaskSet, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)))).FpPartition)) mask = mask | (Xsqlite3WhereExprListUsage(tls, pMaskSet, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)))).FpOrderBy)) mask = mask | (Xsqlite3WhereExprUsage(tls, pMaskSet, (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)))).FpFilter)) @@ -129232,7 +126994,7 @@ func Xsqlite3WhereTabFuncArgs(tls *libc.TLS, pParse uintptr, pItem uintptr, pWC } for j = libc.AssignInt32(&k, 0); j < (*ExprList)(unsafe.Pointer(pArgs)).FnExpr; j++ { var pRhs uintptr - for (k < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) && ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(k)*32)).FcolFlags) & 0x0002) == 0) { + for (k < int32((*Table)(unsafe.Pointer(pTab)).FnCol)) && ((int32((*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTab)).FaCol+uintptr(k)*32)).FcolFlags) & COLFLAG_HIDDEN) == 0) { k++ } if k >= int32((*Table)(unsafe.Pointer(pTab)).FnCol) { @@ -129240,20 +127002,20 @@ func Xsqlite3WhereTabFuncArgs(tls *libc.TLS, pParse uintptr, pItem uintptr, pWC libc.VaList(bp, (*Table)(unsafe.Pointer(pTab)).FzName, j)) return } - pColRef = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 164, uintptr(0), 0) + pColRef = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_COLUMN, uintptr(0), 0) if pColRef == uintptr(0) { return } (*Expr)(unsafe.Pointer(pColRef)).FiTable = (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor (*Expr)(unsafe.Pointer(pColRef)).FiColumn = YnVar(libc.PostIncInt32(&k, 1)) *(*uintptr)(unsafe.Pointer(pColRef + 64 /* &.y */)) = pTab - pRhs = Xsqlite3PExpr(tls, pParse, 171, + pRhs = Xsqlite3PExpr(tls, pParse, TK_UPLUS, Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*ExprList_item)(unsafe.Pointer((pArgs+8 /* &.a */)+uintptr(j)*32)).FpExpr, 0), uintptr(0)) - pTerm = Xsqlite3PExpr(tls, pParse, 53, pColRef, pRhs) - if (int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & 0x0008) != 0 { + pTerm = Xsqlite3PExpr(tls, pParse, TK_EQ, pColRef, pRhs) + if (int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & JT_LEFT) != 0 { Xsqlite3SetJoinExpr(tls, pTerm, (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor) } - whereClauseInsert(tls, pWC, pTerm, uint16(0x0001)) + whereClauseInsert(tls, pWC, pTerm, TERM_DYNAMIC) } } @@ -129457,7 +127219,7 @@ __2: goto __3 __3: ; - if !(int32((*WhereOrSet)(unsafe.Pointer(pSet)).Fn) < 3) { + if !(int32((*WhereOrSet)(unsafe.Pointer(pSet)).Fn) < N_OR_COST) { goto __6 } p = ((pSet + 8 /* &.a */) + uintptr(libc.PostIncUint16(&(*WhereOrSet)(unsafe.Pointer(pSet)).Fn, 1))*16) @@ -129555,11 +127317,11 @@ func whereScanNext(tls *libc.TLS, pScan uintptr) uintptr { /* sqlite3.c:145854:1 ((int32(iColumn) != (-2)) || (Xsqlite3ExprCompareSkip(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft, (*WhereScan)(unsafe.Pointer(pScan)).FpIdxExpr, iCur) == 0))) && - ((int32((*WhereScan)(unsafe.Pointer(pScan)).FiEquiv) <= 1) || !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000001))) != U32(0))) { - if (((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0800) != 0) && + ((int32((*WhereScan)(unsafe.Pointer(pScan)).FiEquiv) <= 1) || !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_FromJoin)) != U32(0))) { + if (((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_EQUIV) != 0) && (int32((*WhereScan)(unsafe.Pointer(pScan)).FnEquiv) < (int32(uint64(unsafe.Sizeof([11]int32{})) / uint64(unsafe.Sizeof(int32(0))))))) && (int32((*Expr)(unsafe.Pointer((libc.AssignUintptr(&pX, Xsqlite3ExprSkipCollateAndLikely(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight))))).Fop) == - 164) { + TK_COLUMN) { var j int32 for j = 0; j < int32((*WhereScan)(unsafe.Pointer(pScan)).FnEquiv); j++ { if (*(*int32)(unsafe.Pointer((pScan + 44 /* &.aiCur */) + uintptr(j)*4)) == (*Expr)(unsafe.Pointer(pX)).FiTable) && @@ -129575,7 +127337,7 @@ func whereScanNext(tls *libc.TLS, pScan uintptr) uintptr { /* sqlite3.c:145854:1 } if (U32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (*WhereScan)(unsafe.Pointer(pScan)).FopMask) != U32(0) { // Verify the affinity and collating sequence match - if ((*WhereScan)(unsafe.Pointer(pScan)).FzCollName != 0) && ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0100) == 0) { + if ((*WhereScan)(unsafe.Pointer(pScan)).FzCollName != 0) && ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_ISNULL) == 0) { var pColl uintptr var pParse uintptr = (*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse pX = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr @@ -129591,10 +127353,10 @@ func whereScanNext(tls *libc.TLS, pScan uintptr) uintptr { /* sqlite3.c:145854:1 goto __2 } } - if ((((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (0x0002 | 0x0080)) != 0) && - (int32((*Expr)(unsafe.Pointer((libc.AssignUintptr(&pX, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight)))).Fop) == 164)) && - ((*Expr)(unsafe.Pointer(pX)).FiTable == *(*int32)(unsafe.Pointer((pScan + 44 /* &.aiCur */) + uintptr(0)*4)))) && - (int32((*Expr)(unsafe.Pointer(pX)).FiColumn) == int32(*(*I16)(unsafe.Pointer((pScan + 88 /* &.aiColumn */) + uintptr(0)*2)))) { + if ((((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (WO_EQ | WO_IS)) != 0) && + (int32((*Expr)(unsafe.Pointer((libc.AssignUintptr(&pX, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight)))).Fop) == TK_COLUMN)) && + ((*Expr)(unsafe.Pointer(pX)).FiTable == *(*int32)(unsafe.Pointer((pScan + 44 /* &.aiCur */))))) && + (int32((*Expr)(unsafe.Pointer(pX)).FiColumn) == int32(*(*I16)(unsafe.Pointer((pScan + 88 /* &.aiColumn */))))) { goto __2 } @@ -129660,7 +127422,7 @@ func whereScanInit(tls *libc.TLS, pScan uintptr, pWC uintptr, iCur int32, iColum (*WhereScan)(unsafe.Pointer(pScan)).FzCollName = uintptr(0) (*WhereScan)(unsafe.Pointer(pScan)).FopMask = opMask (*WhereScan)(unsafe.Pointer(pScan)).Fk = 0 - *(*int32)(unsafe.Pointer((pScan + 44 /* &.aiCur */) + uintptr(0)*4)) = iCur + *(*int32)(unsafe.Pointer((pScan + 44 /* &.aiCur */))) = iCur (*WhereScan)(unsafe.Pointer(pScan)).FnEquiv = uint8(1) (*WhereScan)(unsafe.Pointer(pScan)).FiEquiv = uint8(1) if pIdx != 0 { @@ -129669,7 +127431,7 @@ func whereScanInit(tls *libc.TLS, pScan uintptr, pWC uintptr, iCur int32, iColum if iColumn == (-2) { (*WhereScan)(unsafe.Pointer(pScan)).FpIdxExpr = (*ExprList_item)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FaColExpr + 8 /* &.a */) + uintptr(j)*32)).FpExpr (*WhereScan)(unsafe.Pointer(pScan)).FzCollName = *(*uintptr)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FazColl + uintptr(j)*8)) - *(*I16)(unsafe.Pointer((pScan + 88 /* &.aiColumn */) + uintptr(0)*2)) = int16(-2) + *(*I16)(unsafe.Pointer((pScan + 88 /* &.aiColumn */))) = int16(-2) return whereScanInitIndexExpr(tls, pScan) } else if iColumn == int32((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FpTable)).FiPKey) { iColumn = -1 @@ -129680,7 +127442,7 @@ func whereScanInit(tls *libc.TLS, pScan uintptr, pWC uintptr, iCur int32, iColum } else if iColumn == (-2) { return uintptr(0) } - *(*I16)(unsafe.Pointer((pScan + 88 /* &.aiColumn */) + uintptr(0)*2)) = I16(iColumn) + *(*I16)(unsafe.Pointer((pScan + 88 /* &.aiColumn */))) = I16(iColumn) return whereScanNext(tls, pScan) } @@ -129716,7 +127478,7 @@ func Xsqlite3WhereFindTerm(tls *libc.TLS, pWC uintptr, iCur int32, iColumn int32 // var scan WhereScan at bp, 112 p = whereScanInit(tls, bp /* &scan */, pWC, iCur, iColumn, op, pIdx) - op = op & (U32(0x0002 | 0x0080)) + op = op & (U32(WO_EQ | WO_IS)) for p != 0 { if ((*WhereTerm)(unsafe.Pointer(p)).FprereqRight & notReady) == uint64(0) { if ((*WhereTerm)(unsafe.Pointer(p)).FprereqRight == uint64(0)) && ((U32((*WhereTerm)(unsafe.Pointer(p)).FeOperator) & op) != U32(0)) { @@ -129743,7 +127505,7 @@ func findIndexCol(tls *libc.TLS, pParse uintptr, pList uintptr, iBase int32, pId for i = 0; i < (*ExprList)(unsafe.Pointer(pList)).FnExpr; i++ { var p uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FpExpr) - if ((int32((*Expr)(unsafe.Pointer(p)).Fop) == 164) && + if ((int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN) && (int32((*Expr)(unsafe.Pointer(p)).FiColumn) == int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(iCol)*2))))) && ((*Expr)(unsafe.Pointer(p)).FiTable == iBase) { var pColl uintptr = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FpExpr) @@ -129790,15 +127552,15 @@ func isDistinctRedundant(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWC ui if (*SrcList)(unsafe.Pointer(pTabList)).FnSrc != 1 { return 0 } - iBase = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FiCursor - pTab = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FpTab + iBase = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FiCursor + pTab = (*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FpTab // If any of the expressions is an IPK column on table iBase, then return // true. Note: The (p->iTable==iBase) part of this test may be false if the // current SELECT is a correlated sub-query. for i = 0; i < (*ExprList)(unsafe.Pointer(pDistinct)).FnExpr; i++ { var p uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer((pDistinct+8 /* &.a */)+uintptr(i)*32)).FpExpr) - if ((int32((*Expr)(unsafe.Pointer(p)).Fop) == 164) && ((*Expr)(unsafe.Pointer(p)).FiTable == iBase)) && (int32((*Expr)(unsafe.Pointer(p)).FiColumn) < 0) { + if ((int32((*Expr)(unsafe.Pointer(p)).Fop) == TK_COLUMN) && ((*Expr)(unsafe.Pointer(p)).FiTable == iBase)) && (int32((*Expr)(unsafe.Pointer(p)).FiColumn) < 0) { return 1 } } @@ -129816,11 +127578,11 @@ func isDistinctRedundant(tls *libc.TLS, pParse uintptr, pTabList uintptr, pWC ui // 3. All of those index columns for which the WHERE clause does not // contain a "col=X" term are subject to a NOT NULL constraint. for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { - if !(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0) { + if !(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None) { continue } for i = 0; i < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol); i++ { - if uintptr(0) == Xsqlite3WhereFindTerm(tls, pWC, iBase, i, ^uint64(0), uint32(0x0002), pIdx) { + if uintptr(0) == Xsqlite3WhereFindTerm(tls, pWC, iBase, i, libc.CplUint64(uint64(0)), WO_EQ, pIdx) { if findIndexCol(tls, pParse, pDistinct, iBase, pIdx, i) < 0 { break } @@ -129871,17 +127633,17 @@ __1: if (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 != iTabCur { goto __2 } - if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 89 { - (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(77) + if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column { + (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = OP_Copy (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = ((*VdbeOp)(unsafe.Pointer(pOp)).Fp2 + iRegister) (*VdbeOp)(unsafe.Pointer(pOp)).Fp2 = (*VdbeOp)(unsafe.Pointer(pOp)).Fp3 (*VdbeOp)(unsafe.Pointer(pOp)).Fp3 = 0 - } else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 127 { + } else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Rowid { if iAutoidxCur != 0 { - (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(119) + (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = OP_Sequence (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = iAutoidxCur } else { - (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(72) + (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = OP_Null (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = 0 (*VdbeOp)(unsafe.Pointer(pOp)).Fp3 = 0 } @@ -129910,12 +127672,12 @@ func termCanDriveIndex(tls *libc.TLS, pTerm uintptr, pSrc uintptr, notReady Bitm if (*WhereTerm)(unsafe.Pointer(pTerm)).FleftCursor != (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor { return 0 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (0x0002 | 0x0080)) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (WO_EQ | WO_IS)) == 0 { return 0 } - if (((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & 0x0008) != 0) && - !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000001))) != U32(0))) && - ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0080) != 0) { + if (((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & JT_LEFT) != 0) && + !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_FromJoin)) != U32(0))) && + ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_IS) != 0) { // Cannot use an IS term from the WHERE clause as an index driver for // the RHS of a LEFT JOIN. Such a term can only be used if it is from // the ON clause. @@ -129982,7 +127744,7 @@ func constructAutomaticIndex(tls *libc.TLS, pParse uintptr, pWC uintptr, pSrc ui // transient index on 2nd and subsequent iterations of the loop. v = (*Parse)(unsafe.Pointer(pParse)).FpVdbe - addrInit = Xsqlite3VdbeAddOp0(tls, v, 17) + addrInit = Xsqlite3VdbeAddOp0(tls, v, OP_Once) // Count the number of columns that will be added to the index // and used to match WHERE clause constraints @@ -129999,8 +127761,8 @@ __1: pExpr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr // table of a LEFT JOIN if !(((((*WhereLoop)(unsafe.Pointer(pLoop)).Fprereq == uint64(0)) && - ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0002) == 0)) && - !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0))) && + ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VIRTUAL) == 0)) && + !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0))) && (Xsqlite3ExprIsTableConstant(tls, pExpr, (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor) != 0)) { goto __4 } @@ -130021,7 +127783,7 @@ __4: if !(!(sentWarning != 0)) { goto __6 } - Xsqlite3_log(tls, (28 | (int32(1) << 8)), + Xsqlite3_log(tls, (SQLITE_WARNING | (int32(1) << 8)), ts+23571 /* "automatic index ..." */, libc.VaList(bp, (*Table)(unsafe.Pointer(pTable)).FzName, (*Column)(unsafe.Pointer((*Table)(unsafe.Pointer(pTable)).FaCol+uintptr(iCol)*32)).FzName)) sentWarning = U8(1) @@ -130051,8 +127813,8 @@ __3: ; *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ /* &.nEq */)) = libc.AssignPtrUint16(pLoop+44 /* &.nLTerm */, U16(nKeyCol)) - (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = (U32(((0x00000001 | 0x00000040) | 0x00000200) | - 0x00004000)) + (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = (U32(((WHERE_COLUMN_EQ | WHERE_IDX_ONLY) | WHERE_INDEXED) | + WHERE_AUTO_INDEX)) // Count the number of additional columns needed to create a // covering index. A "covering index" is an index that contains all @@ -130198,7 +127960,7 @@ __24: // Create the automatic index (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - Xsqlite3VdbeAddOp2(tls, v, 99, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, (nKeyCol + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenAutoindex, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, (nKeyCol + 1)) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIdx) Xsqlite3VdbeComment(tls, v, ts+16899 /* "for %s" */, libc.VaList(bp+16, (*Table)(unsafe.Pointer(pTable)).FzName)) @@ -130208,29 +127970,29 @@ __24: goto __28 } regYield = (*SrcList_item)(unsafe.Pointer(pTabItem)).FregReturn - addrCounter = Xsqlite3VdbeAddOp2(tls, v, 69, 0, 0) - Xsqlite3VdbeAddOp3(tls, v, 13, regYield, 0, (*SrcList_item)(unsafe.Pointer(pTabItem)).FaddrFillSub) - addrTop = Xsqlite3VdbeAddOp1(tls, v, 14, regYield) + addrCounter = Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, 0) + Xsqlite3VdbeAddOp3(tls, v, OP_InitCoroutine, regYield, 0, (*SrcList_item)(unsafe.Pointer(pTabItem)).FaddrFillSub) + addrTop = Xsqlite3VdbeAddOp1(tls, v, OP_Yield, regYield) Xsqlite3VdbeComment(tls, v, ts+23357 /* "next row of %s" */, libc.VaList(bp+24, (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pTabItem)).FpTab)).FzName)) goto __29 __28: - addrTop = Xsqlite3VdbeAddOp1(tls, v, 37, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur) + addrTop = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur) __29: ; if !(pPartial != 0) { goto __30 } iContinue = Xsqlite3VdbeMakeLabel(tls, pParse) - Xsqlite3ExprIfFalse(tls, pParse, pPartial, iContinue, 0x10) - *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (U32(0x00020000)) + Xsqlite3ExprIfFalse(tls, pParse, pPartial, iContinue, SQLITE_JUMPIFNULL) + *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (WHERE_PARTIALIDX) __30: ; regRecord = Xsqlite3GetTempReg(tls, pParse) regBase = Xsqlite3GenerateIndexKey(tls, pParse, pIdx, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, regRecord, 0, uintptr(0), uintptr(0), 0) - Xsqlite3VdbeAddOp2(tls, v, 130, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, regRecord) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x10)) + Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, regRecord) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_USESEEKRESULT) if !(pPartial != 0) { goto __31 } @@ -130248,8 +128010,8 @@ __31: libc.SetBitFieldPtr8Uint32(pTabItem+60 /* &.fg */ +4 /* &.viaCoroutine */, uint32(0), 4, 0x10) goto __33 __32: - Xsqlite3VdbeAddOp2(tls, v, 5, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (addrTop + 1)) - Xsqlite3VdbeChangeP5(tls, v, uint16(3)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (addrTop + 1)) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_STMTSTATUS_AUTOINDEX) __33: ; Xsqlite3VdbeJumpHere(tls, v, addrTop) @@ -130294,10 +128056,10 @@ __1: goto __2 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & ^libc.Int32(0x0800)) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & libc.CplInt32(WO_EQUIV)) == 0 { goto __2 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0080) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VNULL) != 0 { goto __2 } @@ -130321,10 +128083,10 @@ __3: var n int32 = (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr for i = 0; i < n; i++ { var pExpr uintptr = (*ExprList_item)(unsafe.Pointer((pOrderBy + 8 /* &.a */) + uintptr(i)*32)).FpExpr - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 164) || ((*Expr)(unsafe.Pointer(pExpr)).FiTable != (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN) || ((*Expr)(unsafe.Pointer(pExpr)).FiTable != (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor) { break } - if (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & 0x02) != 0 { + if (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & KEYINFO_ORDER_BIGNULL) != 0 { break } } @@ -130341,8 +128103,8 @@ __3: Xsqlite3ErrorMsg(tls, pParse, ts+7766 /* "out of memory" */, 0) return uintptr(0) } - pHidden = (pIdxInfo + uintptr(1)*96) - pIdxCons = (pHidden + uintptr(1)*16) + pHidden = (pIdxInfo + 1*96) + pIdxCons = (pHidden + 1*16) pIdxOrderBy = (pIdxCons + uintptr(nTerm)*12) pUsage = (pIdxOrderBy + uintptr(nOrderBy)*8) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy = nOrderBy @@ -130366,34 +128128,34 @@ __4: goto __5 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & ^libc.Int32(0x0800)) == 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & libc.CplInt32(WO_EQUIV)) == 0 { goto __5 } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0080) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VNULL) != 0 { goto __5 } // tag-20191211-002: WHERE-clause constraints are not useful to the // right-hand table of a LEFT JOIN. See tag-20191211-001 for the // equivalent restriction for ordinary tables. - if ((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & 0x0008) != 0) && - !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000001))) != U32(0)) { + if ((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & JT_LEFT) != 0) && + !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_FromJoin)) != U32(0)) { goto __5 } (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).FiColumn = *(*int32)(unsafe.Pointer(pTerm + 40 /* &.u */)) (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).FiTermOffset = i - op = (U16(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x1fff)) - if int32(op) == 0x0001 { - op = U16(0x0002) + op = (U16(int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_ALL)) + if int32(op) == WO_IN { + op = WO_EQ } - if int32(op) == 0x0040 { + if int32(op) == WO_AUX { (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = (*WhereTerm)(unsafe.Pointer(pTerm)).FeMatchOp - } else if (int32(op) & (0x0100 | 0x0080)) != 0 { - if int32(op) == 0x0100 { - (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = uint8(71) + } else if (int32(op) & (WO_ISNULL | WO_IS)) != 0 { + if int32(op) == WO_ISNULL { + (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = SQLITE_INDEX_CONSTRAINT_ISNULL } else { - (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = uint8(72) + (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = SQLITE_INDEX_CONSTRAINT_IS } } else { (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = U8(op) @@ -130401,17 +128163,17 @@ __4: // the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical. The // following asserts verify this fact. - if ((int32(op) & ((((int32(0x0002) << (56 - 53)) | (int32(0x0002) << (55 - 53))) | (int32(0x0002) << (54 - 53))) | (int32(0x0002) << (57 - 53)))) != 0) && + if ((int32(op) & ((((int32(WO_EQ) << (TK_LT - TK_EQ)) | (int32(WO_EQ) << (TK_LE - TK_EQ))) | (int32(WO_EQ) << (TK_GT - TK_EQ))) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) != 0) && (Xsqlite3ExprIsVector(tls, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight) != 0) { if j < 16 { mNoOmit = U16(int32(mNoOmit) | (int32(1) << j)) } - if int32(op) == (int32(0x0002) << (56 - 53)) { - (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = (uint8(int32(0x0002) << (55 - 53))) + if int32(op) == (int32(WO_EQ) << (TK_LT - TK_EQ)) { + (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = (uint8(int32(WO_EQ) << (TK_LE - TK_EQ))) } - if int32(op) == (int32(0x0002) << (54 - 53)) { - (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = (uint8(int32(0x0002) << (57 - 53))) + if int32(op) == (int32(WO_EQ) << (TK_GT - TK_EQ)) { + (*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons + uintptr(j)*12)).Fop = (uint8(int32(WO_EQ) << (TK_GE - TK_EQ))) } } } @@ -130431,7 +128193,7 @@ __6: for i = 0; i < nOrderBy; i++ { var pExpr uintptr = (*ExprList_item)(unsafe.Pointer((pOrderBy + 8 /* &.a */) + uintptr(i)*32)).FpExpr (*sqlite3_index_orderby)(unsafe.Pointer(pIdxOrderBy + uintptr(i)*8)).FiColumn = int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) - (*sqlite3_index_orderby)(unsafe.Pointer(pIdxOrderBy + uintptr(i)*8)).Fdesc = (uint8(int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & 0x01)) + (*sqlite3_index_orderby)(unsafe.Pointer(pIdxOrderBy + uintptr(i)*8)).Fdesc = (uint8(int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & KEYINFO_ORDER_DESC)) } *(*U16)(unsafe.Pointer(pmNoOmit)) = mNoOmit @@ -130461,8 +128223,8 @@ func vtabBestIndex(tls *libc.TLS, pParse uintptr, pTab uintptr, p uintptr) int32 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule + 24 /* &.xBestIndex */))))(tls, pVtab, p) - if (rc != 0) && (rc != 19) { - if rc == 7 { + if (rc != SQLITE_OK) && (rc != SQLITE_CONSTRAINT) { + if rc == SQLITE_NOMEM { Xsqlite3OomFault(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb) } else if !(int32((*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg) != 0) { Xsqlite3ErrorMsg(tls, pParse, ts+824 /* "%s" */, libc.VaList(bp, Xsqlite3ErrStr(tls, rc))) @@ -130583,8 +128345,8 @@ func whereKeyStats(tls *libc.TLS, pParse uintptr, pIdx uintptr, pRec uintptr, ro if res == 0 { // Record pRec is equal to sample i - *(*TRowcnt)(unsafe.Pointer(aStat + uintptr(0)*4)) = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*40)).FanLt + uintptr(iCol)*4)) - *(*TRowcnt)(unsafe.Pointer(aStat + uintptr(1)*4)) = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*40)).FanEq + uintptr(iCol)*4)) + *(*TRowcnt)(unsafe.Pointer(aStat)) = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*40)).FanLt + uintptr(iCol)*4)) + *(*TRowcnt)(unsafe.Pointer(aStat + 1*4)) = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*40)).FanEq + uintptr(iCol)*4)) } else { // At this point, the (iCol+1) field prefix of aSample[i] is the first // sample that is greater than pRec. Or, if i==pIdx->nSample then pRec @@ -130592,7 +128354,7 @@ func whereKeyStats(tls *libc.TLS, pParse uintptr, pIdx uintptr, pRec uintptr, ro var iUpper TRowcnt var iGap TRowcnt if i >= (*Index)(unsafe.Pointer(pIdx)).FnSample { - iUpper = TRowcnt(Xsqlite3LogEstToInt(tls, *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowLogEst + uintptr(0)*2)))) + iUpper = TRowcnt(Xsqlite3LogEstToInt(tls, *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowLogEst)))) } else { iUpper = *(*TRowcnt)(unsafe.Pointer((*IndexSample)(unsafe.Pointer(aSample+uintptr(i)*40)).FanLt + uintptr(iCol)*4)) } @@ -130607,8 +128369,8 @@ func whereKeyStats(tls *libc.TLS, pParse uintptr, pIdx uintptr, pRec uintptr, ro } else { iGap = (iGap / TRowcnt(3)) } - *(*TRowcnt)(unsafe.Pointer(aStat + uintptr(0)*4)) = (iLower + iGap) - *(*TRowcnt)(unsafe.Pointer(aStat + uintptr(1)*4)) = *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaAvgEq + uintptr((nField-1))*4)) + *(*TRowcnt)(unsafe.Pointer(aStat)) = (iLower + iGap) + *(*TRowcnt)(unsafe.Pointer(aStat + 1*4)) = *(*TRowcnt)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaAvgEq + uintptr((nField-1))*4)) } // Restore the pRec->nField value before returning. @@ -130630,7 +128392,7 @@ func whereRangeAdjust(tls *libc.TLS, pTerm uintptr, nNew LogEst) LogEst { /* sql if pTerm != 0 { if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb) <= 0 { nRet = LogEst(int32(nRet) + (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb))) - } else if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0080) == 0 { + } else if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VNULL) == 0 { nRet = int16(int32(nRet) - (20)) } } @@ -130642,7 +128404,7 @@ func Xsqlite3IndexColumnAffinity(tls *libc.TLS, db uintptr, pIdx uintptr, iCol i if !(int32((*Index)(unsafe.Pointer(pIdx)).FzColAff) != 0) { if Xsqlite3IndexAffinityStr(tls, db, pIdx) == uintptr(0) { - return int8(0x41) + return SQLITE_AFF_BLOB } } @@ -130691,7 +128453,7 @@ func whereRangeSkipScanEst(tls *libc.TLS, pParse uintptr, pLower uintptr, pUpper var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var nLower int32 = -1 var nUpper int32 = ((*Index)(unsafe.Pointer(p)).FnSample + 1) - var rc int32 = 0 + var rc int32 = SQLITE_OK var aff U8 = U8(Xsqlite3IndexColumnAffinity(tls, db, p, nEq)) var pColl uintptr @@ -130704,7 +128466,7 @@ func whereRangeSkipScanEst(tls *libc.TLS, pParse uintptr, pLower uintptr, pUpper rc = Xsqlite3Stat4ValueFromExpr(tls, pParse, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pLower)).FpExpr)).FpRight, aff, bp /* &p1 */) nLower = 0 } - if (pUpper != 0) && (rc == 0) { + if (pUpper != 0) && (rc == SQLITE_OK) { rc = Xsqlite3Stat4ValueFromExpr(tls, pParse, (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pUpper)).FpExpr)).FpRight, aff, bp+8 /* &p2 */) if *(*uintptr)(unsafe.Pointer(bp + 8 /* p2 */)) != 0 { nUpper = 0 @@ -130716,15 +128478,15 @@ func whereRangeSkipScanEst(tls *libc.TLS, pParse uintptr, pLower uintptr, pUpper if (*(*uintptr)(unsafe.Pointer(bp /* p1 */)) != 0) || (*(*uintptr)(unsafe.Pointer(bp + 8 /* p2 */)) != 0) { var i int32 var nDiff int32 - for i = 0; (rc == 0) && (i < (*Index)(unsafe.Pointer(p)).FnSample); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Index)(unsafe.Pointer(p)).FnSample); i++ { rc = Xsqlite3Stat4Column(tls, db, (*IndexSample)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaSample+uintptr(i)*40)).Fp, (*IndexSample)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaSample+uintptr(i)*40)).Fn, nEq, bp+16 /* &pVal */) - if (rc == 0) && (*(*uintptr)(unsafe.Pointer(bp /* p1 */)) != 0) { + if (rc == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp /* p1 */)) != 0) { var res int32 = Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(bp /* p1 */)), *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), pColl) if res >= 0 { nLower++ } } - if (rc == 0) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* p2 */)) != 0) { + if (rc == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* p2 */)) != 0) { var res int32 = Xsqlite3MemCompare(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p2 */)), *(*uintptr)(unsafe.Pointer(bp + 16 /* pVal */)), pColl) if res >= 0 { nUpper++ @@ -130801,7 +128563,7 @@ func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower u bp := tls.Alloc(28) defer tls.Free(28) - var rc int32 = 0 + var rc int32 = SQLITE_OK var nOut int32 = int32((*WhereLoop)(unsafe.Pointer(pLoop)).FnOut) var nNew LogEst @@ -130809,7 +128571,7 @@ func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower u var nEq int32 = int32(*(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ /* &.nEq */))) if (((*Index)(unsafe.Pointer(p)).FnSample > 0) && (nEq < (*Index)(unsafe.Pointer(p)).FnSampleCol)) && - ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (0x0800)) == 0) { + ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (SQLITE_Stat4)) == 0) { if nEq == (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid { *(*uintptr)(unsafe.Pointer(bp + 8 /* pRec */)) = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec // var a [2]TRowcnt at bp, 8 @@ -130852,8 +128614,8 @@ func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower u // Note: this call could be optimized away - since the same values must // have been requested when testing key $P in whereEqualScanEst(). whereKeyStats(tls, pParse, p, *(*uintptr)(unsafe.Pointer(bp + 8 /* pRec */)), 0, bp /* &a[0] */) - iLower = *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(0)*4)) - iUpper = (*(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(0)*4)) + *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(1)*4))) + iLower = *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */)) + iUpper = (*(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */)) + *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + 1*4))) } if *(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaSortOrder + uintptr(nEq))) != 0 { @@ -130878,16 +128640,16 @@ func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower u // Values extracted from pExpr var pExpr uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pLower)).FpExpr)).FpRight rc = Xsqlite3Stat4ProbeSetValue(tls, pParse, p, bp+8 /* &pRec */, pExpr, nBtm, nEq, bp+16 /* &n */) - if (rc == 0) && (*(*int32)(unsafe.Pointer(bp + 16 /* n */)) != 0) { + if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 16 /* n */)) != 0) { var iNew TRowcnt - var mask U16 = (U16((int32(0x0002) << (54 - 53)) | (int32(0x0002) << (55 - 53)))) + var mask U16 = (U16((int32(WO_EQ) << (TK_GT - TK_EQ)) | (int32(WO_EQ) << (TK_LE - TK_EQ)))) if Xsqlite3ExprVectorSize(tls, pExpr) > *(*int32)(unsafe.Pointer(bp + 16 /* n */)) { - mask = (U16((int32(0x0002) << (55 - 53)) | (int32(0x0002) << (56 - 53)))) + mask = (U16((int32(WO_EQ) << (TK_LE - TK_EQ)) | (int32(WO_EQ) << (TK_LT - TK_EQ)))) } iLwrIdx = whereKeyStats(tls, pParse, p, *(*uintptr)(unsafe.Pointer(bp + 8 /* pRec */)), 0, bp /* &a[0] */) - iNew = (*(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(0)*4)) + (func() uint32 { + iNew = (*(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */)) + (func() uint32 { if (int32((*WhereTerm)(unsafe.Pointer(pLower)).FeOperator) & int32(mask)) != 0 { - return *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(1)*4)) + return *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + 1*4)) } return uint32(0) }())) @@ -130905,16 +128667,16 @@ func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower u // Values extracted from pExpr var pExpr uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pUpper)).FpExpr)).FpRight rc = Xsqlite3Stat4ProbeSetValue(tls, pParse, p, bp+8 /* &pRec */, pExpr, nTop, nEq, bp+20 /* &n */) - if (rc == 0) && (*(*int32)(unsafe.Pointer(bp + 20 /* n */)) != 0) { + if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 20 /* n */)) != 0) { var iNew TRowcnt - var mask U16 = (U16((int32(0x0002) << (54 - 53)) | (int32(0x0002) << (55 - 53)))) + var mask U16 = (U16((int32(WO_EQ) << (TK_GT - TK_EQ)) | (int32(WO_EQ) << (TK_LE - TK_EQ)))) if Xsqlite3ExprVectorSize(tls, pExpr) > *(*int32)(unsafe.Pointer(bp + 20 /* n */)) { - mask = (U16((int32(0x0002) << (55 - 53)) | (int32(0x0002) << (56 - 53)))) + mask = (U16((int32(WO_EQ) << (TK_LE - TK_EQ)) | (int32(WO_EQ) << (TK_LT - TK_EQ)))) } iUprIdx = whereKeyStats(tls, pParse, p, *(*uintptr)(unsafe.Pointer(bp + 8 /* pRec */)), 1, bp /* &a[0] */) - iNew = (*(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(0)*4)) + (func() uint32 { + iNew = (*(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */)) + (func() uint32 { if (int32((*WhereTerm)(unsafe.Pointer(pUpper)).FeOperator) & int32(mask)) != 0 { - return *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + uintptr(1)*4)) + return *(*TRowcnt)(unsafe.Pointer(bp /* &a[0] */ + 1*4)) } return uint32(0) }())) @@ -130927,7 +128689,7 @@ func whereRangeScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pLower u } (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec = *(*uintptr)(unsafe.Pointer(bp + 8 /* pRec */)) - if rc == 0 { + if rc == SQLITE_OK { if iUpper > iLower { nNew = Xsqlite3LogEst(tls, (uint64(iUpper - iLower))) // TUNING: If both iUpper and iLower are derived from the same @@ -131008,29 +128770,29 @@ func whereEqualScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pExpr ui // If values are not available for all fields of the index to the left // of this one, no estimate can be made. Return SQLITE_NOTFOUND. if (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid < (nEq - 1) { - return 12 + return SQLITE_NOTFOUND } // This is an optimization only. The call to sqlite3Stat4ProbeSetValue() // below would return the same value. if nEq >= int32((*Index)(unsafe.Pointer(p)).FnColumn) { *(*TRowcnt)(unsafe.Pointer(pnRow)) = TRowcnt(1) - return 0 + return SQLITE_OK } rc = Xsqlite3Stat4ProbeSetValue(tls, pParse, p, bp /* &pRec */, pExpr, 1, (nEq - 1), bp+8 /* &bOk */) (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec = *(*uintptr)(unsafe.Pointer(bp /* pRec */)) - if rc != 0 { + if rc != SQLITE_OK { return rc } if *(*int32)(unsafe.Pointer(bp + 8 /* bOk */)) == 0 { - return 12 + return SQLITE_NOTFOUND } (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = nEq whereKeyStats(tls, pParse, p, *(*uintptr)(unsafe.Pointer(bp /* pRec */)), 0, bp+12 /* &a[0] */) - *(*TRowcnt)(unsafe.Pointer(pnRow)) = *(*TRowcnt)(unsafe.Pointer(bp + 12 /* &a[0] */ + uintptr(1)*4)) + *(*TRowcnt)(unsafe.Pointer(pnRow)) = *(*TRowcnt)(unsafe.Pointer(bp + 12 /* &a[0] */ + 1*4)) return rc } @@ -131054,22 +128816,22 @@ func whereInScanEst(tls *libc.TLS, pParse uintptr, pBuilder uintptr, pList uintp defer tls.Free(4) var p uintptr = *(*uintptr)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) - var nRow0 I64 = I64(Xsqlite3LogEstToInt(tls, *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaiRowLogEst + uintptr(0)*2)))) + var nRow0 I64 = I64(Xsqlite3LogEstToInt(tls, *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(p)).FaiRowLogEst)))) var nRecValid int32 = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid - var rc int32 = 0 // Subfunction return code + var rc int32 = SQLITE_OK // Subfunction return code // var nEst TRowcnt at bp, 4 // Number of rows for a single term var nRowEst TRowcnt = TRowcnt(0) // New estimate of the number of rows var i int32 // Loop counter - for i = 0; (rc == 0) && (i < (*ExprList)(unsafe.Pointer(pList)).FnExpr); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*ExprList)(unsafe.Pointer(pList)).FnExpr); i++ { *(*TRowcnt)(unsafe.Pointer(bp /* nEst */)) = TRowcnt(nRow0) rc = whereEqualScanEst(tls, pParse, pBuilder, (*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(i)*32)).FpExpr, bp /* &nEst */) nRowEst = nRowEst + (*(*TRowcnt)(unsafe.Pointer(bp /* nEst */))) (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = nRecValid } - if rc == 0 { + if rc == SQLITE_OK { if I64(nRowEst) > nRow0 { nRowEst = TRowcnt(nRow0) } @@ -131091,12 +128853,12 @@ func whereLoopInit(tls *libc.TLS, p uintptr) { /* sqlite3.c:147466:13: */ // Clear the WhereLoop.u union. Leave WhereLoop.pLTerm intact. func whereLoopClearUnion(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3.c:147476:13: */ - if ((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & (U32(0x00000400 | 0x00004000))) != 0 { - if (((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & U32(0x00000400)) != U32(0)) && (*(*U8)(unsafe.Pointer((p + 24 /* &.u */ /* &.vtab */) + 4 /* &.needFree */)) != 0) { + if ((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & (U32(WHERE_VIRTUALTABLE | WHERE_AUTO_INDEX))) != 0 { + if (((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & WHERE_VIRTUALTABLE) != U32(0)) && (*(*U8)(unsafe.Pointer((p + 24 /* &.u */ /* &.vtab */) + 4 /* &.needFree */)) != 0) { Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.vtab */ + 8 /* &.idxStr */))) *(*U8)(unsafe.Pointer(p + 24 /* &.u */ /* &.vtab */ + 4 /* &.needFree */)) = U8(0) *(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.vtab */ + 8 /* &.idxStr */)) = uintptr(0) - } else if (((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & U32(0x00004000)) != U32(0)) && (*(*uintptr)(unsafe.Pointer((p + 24 /* &.u */ /* &.btree */) + 8 /* &.pIndex */)) != uintptr(0)) { + } else if (((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & WHERE_AUTO_INDEX) != U32(0)) && (*(*uintptr)(unsafe.Pointer((p + 24 /* &.u */ /* &.btree */) + 8 /* &.pIndex */)) != uintptr(0)) { Xsqlite3DbFree(tls, db, (*Index)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)))).FzColAff) Xsqlite3DbFreeNN(tls, db, *(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */))) *(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) = uintptr(0) @@ -131117,12 +128879,12 @@ func whereLoopClear(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3.c:147493: func whereLoopResize(tls *libc.TLS, db uintptr, p uintptr, n int32) int32 { /* sqlite3.c:147502:12: */ var paNew uintptr if int32((*WhereLoop)(unsafe.Pointer(p)).FnLSlot) >= n { - return 0 + return SQLITE_OK } - n = ((n + 7) & ^libc.Int32(7)) + n = ((n + 7) & libc.CplInt32(7)) paNew = Xsqlite3DbMallocRawNN(tls, db, (uint64(uint64(unsafe.Sizeof(uintptr(0))) * uint64(n)))) if paNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, paNew, (*WhereLoop)(unsafe.Pointer(p)).FaLTerm, (uint64(unsafe.Sizeof(uintptr(0))) * uint64((*WhereLoop)(unsafe.Pointer(p)).FnLSlot))) if (*WhereLoop)(unsafe.Pointer(p)).FaLTerm != p+72 /* &.aLTermSpace */ { @@ -131130,7 +128892,7 @@ func whereLoopResize(tls *libc.TLS, db uintptr, p uintptr, n int32) int32 { /* s } (*WhereLoop)(unsafe.Pointer(p)).FaLTerm = paNew (*WhereLoop)(unsafe.Pointer(p)).FnLSlot = U16(n) - return 0 + return SQLITE_OK } // Transfer content from the second pLoop into the first. @@ -131146,16 +128908,16 @@ func whereLoopXfer(tls *libc.TLS, db uintptr, pTo uintptr, pFrom uintptr) int32 FpIndex uintptr } }{}))) - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, pTo, pFrom, uint64((uintptr(0) + 48 /* &.nLSlot */))) libc.Xmemcpy(tls, (*WhereLoop)(unsafe.Pointer(pTo)).FaLTerm, (*WhereLoop)(unsafe.Pointer(pFrom)).FaLTerm, (uint64((*WhereLoop)(unsafe.Pointer(pTo)).FnLTerm) * uint64(unsafe.Sizeof(uintptr(0))))) - if ((*WhereLoop)(unsafe.Pointer(pFrom)).FwsFlags & U32(0x00000400)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pFrom)).FwsFlags & WHERE_VIRTUALTABLE) != 0 { *(*U8)(unsafe.Pointer(pFrom + 24 /* &.u */ /* &.vtab */ + 4 /* &.needFree */)) = U8(0) - } else if ((*WhereLoop)(unsafe.Pointer(pFrom)).FwsFlags & U32(0x00004000)) != U32(0) { + } else if ((*WhereLoop)(unsafe.Pointer(pFrom)).FwsFlags & WHERE_AUTO_INDEX) != U32(0) { *(*uintptr)(unsafe.Pointer(pFrom + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) = uintptr(0) } - return 0 + return SQLITE_OK } // Delete a WhereLoop object @@ -131170,7 +128932,7 @@ func whereInfoFree(tls *libc.TLS, db uintptr, pWInfo uintptr) { /* sqlite3.c:147 for i = 0; i < int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel); i++ { var pLevel uintptr = ((pWInfo + 920 /* &.a */) + uintptr(i)*88) - if ((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop != 0) && (((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags & U32(0x00000800)) != 0) { + if ((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop != 0) && (((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags & WHERE_IN_ABLE) != 0) { Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pLevel + 56 /* &.u */ /* &.in */ + 8 /* &.aInLoop */))) } } @@ -131230,8 +128992,8 @@ func whereLoopCheaperProperSubset(tls *libc.TLS, pX uintptr, pY uintptr) int32 { return 0 } // X not a subset of Y since term X[i] not used by Y } - if (((*WhereLoop)(unsafe.Pointer(pX)).FwsFlags & U32(0x00000040)) != U32(0)) && - (((*WhereLoop)(unsafe.Pointer(pY)).FwsFlags & U32(0x00000040)) == U32(0)) { + if (((*WhereLoop)(unsafe.Pointer(pX)).FwsFlags & WHERE_IDX_ONLY) != U32(0)) && + (((*WhereLoop)(unsafe.Pointer(pY)).FwsFlags & WHERE_IDX_ONLY) == U32(0)) { return 0 // Constraint (5) } return 1 // All conditions meet @@ -131250,14 +129012,14 @@ func whereLoopCheaperProperSubset(tls *libc.TLS, pX uintptr, pY uintptr) int32 { // WHERE clause terms than Y and that every WHERE clause term used by X is // also used by Y. func whereLoopAdjustCost(tls *libc.TLS, p uintptr, pTemplate uintptr) { /* sqlite3.c:147623:13: */ - if ((*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags & U32(0x00000200)) == U32(0) { + if ((*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags & WHERE_INDEXED) == U32(0) { return } for ; p != 0; p = (*WhereLoop)(unsafe.Pointer(p)).FpNextLoop { if int32((*WhereLoop)(unsafe.Pointer(p)).FiTab) != int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FiTab) { continue } - if ((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & U32(0x00000200)) == U32(0) { + if ((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & WHERE_INDEXED) == U32(0) { continue } if whereLoopCheaperProperSubset(tls, p, pTemplate) != 0 { @@ -131313,10 +129075,10 @@ __1: // Any loop using an appliation-defined index (or PRIMARY KEY or // UNIQUE constraint) with one or more == constraints is better // than an automatic index. Unless it is a skip-scan. - if ((((((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & U32(0x00004000)) != U32(0)) && + if ((((((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & WHERE_AUTO_INDEX) != U32(0)) && ((int32((*WhereLoop)(unsafe.Pointer(pTemplate)).FnSkip)) == 0)) && - (((*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags & U32(0x00000200)) != U32(0))) && - (((*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags & U32(0x00000001)) != U32(0))) && + (((*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags & WHERE_INDEXED) != U32(0))) && + (((*WhereLoop)(unsafe.Pointer(pTemplate)).FwsFlags & WHERE_COLUMN_EQ) != U32(0))) && (((*WhereLoop)(unsafe.Pointer(p)).Fprereq & (*WhereLoop)(unsafe.Pointer(pTemplate)).Fprereq) == (*WhereLoop)(unsafe.Pointer(pTemplate)).Fprereq) { goto __3 } @@ -131390,7 +129152,7 @@ func whereLoopInsert(tls *libc.TLS, pBuilder uintptr, pTemplate uintptr) int32 { if (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet != 0 { (*WhereOrSet)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet)).Fn = U16(0) } - return 101 + return SQLITE_DONE } (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit-- @@ -131403,7 +129165,7 @@ func whereLoopInsert(tls *libc.TLS, pBuilder uintptr, pTemplate uintptr) int32 { whereOrInsert(tls, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet, (*WhereLoop)(unsafe.Pointer(pTemplate)).Fprereq, (*WhereLoop)(unsafe.Pointer(pTemplate)).FrRun, (*WhereLoop)(unsafe.Pointer(pTemplate)).FnOut) } - return 0 + return SQLITE_OK } // Look for an existing WhereLoop to replace with pTemplate @@ -131412,7 +129174,7 @@ func whereLoopInsert(tls *libc.TLS, pBuilder uintptr, pTemplate uintptr) int32 { if ppPrev == uintptr(0) { // There already exists a WhereLoop on the list that is better // than pTemplate, so just ignore pTemplate - return 0 + return SQLITE_OK } else { p = *(*uintptr)(unsafe.Pointer(ppPrev)) } @@ -131424,7 +129186,7 @@ func whereLoopInsert(tls *libc.TLS, pBuilder uintptr, pTemplate uintptr) int32 { // Allocate a new WhereLoop to add to the end of the list *(*uintptr)(unsafe.Pointer(ppPrev)) = libc.AssignUintptr(&p, Xsqlite3DbMallocRawNN(tls, db, uint64(unsafe.Sizeof(WhereLoop{})))) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } whereLoopInit(tls, p) (*WhereLoop)(unsafe.Pointer(p)).FpNextLoop = uintptr(0) @@ -131448,9 +129210,9 @@ func whereLoopInsert(tls *libc.TLS, pBuilder uintptr, pTemplate uintptr) int32 { } } rc = whereLoopXfer(tls, db, p, pTemplate) - if ((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & U32(0x00000400)) == U32(0) { + if ((*WhereLoop)(unsafe.Pointer(p)).FwsFlags & WHERE_VIRTUALTABLE) == U32(0) { var pIndex uintptr = *(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) - if (pIndex != 0) && ((int32(*(*uint16)(unsafe.Pointer(pIndex + 100 /* &.idxType */)) & 0x3 >> 0)) == 3) { + if (pIndex != 0) && ((int32(*(*uint16)(unsafe.Pointer(pIndex + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_IPK) { *(*uintptr)(unsafe.Pointer(p + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) = uintptr(0) } } @@ -131503,7 +129265,7 @@ __1: } { - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0002) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VIRTUAL) != 0 { goto __3 } if ((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf) == uint64(0) { @@ -131533,8 +129295,8 @@ __1: // In the absence of explicit truth probabilities, use heuristics to // guess a reasonable truth probability. (*WhereLoop)(unsafe.Pointer(pLoop)).FnOut-- - if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (0x0002 | 0x0080)) != 0) && - ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x4000) == 0) { + if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (WO_EQ | WO_IS)) != 0) && + ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_HIGHTRUTH) == 0) { var pRight uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight *(*int32)(unsafe.Pointer(bp /* k */)) = 0 @@ -131544,7 +129306,7 @@ __1: *(*int32)(unsafe.Pointer(bp /* k */)) = 20 } if int32(iReduce) < *(*int32)(unsafe.Pointer(bp /* k */)) { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x2000)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_HEURTRUTH)) iReduce = LogEst(*(*int32)(unsafe.Pointer(bp /* k */))) } } @@ -131598,7 +129360,7 @@ func whereRangeVectorLen(tls *libc.TLS, pParse uintptr, iCur int32, pIdx uintptr var pColl uintptr // Comparison collation sequence var pLhs uintptr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpLeft + 32 /* &.x */)) + 8 /* &.a */) + uintptr(i)*32)).FpExpr var pRhs uintptr = (*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FpRight - if ((*Expr)(unsafe.Pointer(pRhs)).Fflags & U32(0x000800)) != 0 { + if ((*Expr)(unsafe.Pointer(pRhs)).Fflags & EP_xIsSelect) != 0 { pRhs = (*ExprList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pRhs + 32 /* &.x */)))).FpEList + 8 /* &.a */) + uintptr(i)*32)).FpExpr } else { pRhs = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(pRhs + 32 /* &.x */)) + 8 /* &.a */) + uintptr(i)*32)).FpExpr @@ -131608,7 +129370,7 @@ func whereRangeVectorLen(tls *libc.TLS, pParse uintptr, iCur int32, pIdx uintptr // the right column of the right source table. And that the sort // order of the index column is the same as the sort order of the // leftmost index column. - if (((int32((*Expr)(unsafe.Pointer(pLhs)).Fop) != 164) || + if (((int32((*Expr)(unsafe.Pointer(pLhs)).Fop) != TK_COLUMN) || ((*Expr)(unsafe.Pointer(pLhs)).FiTable != iCur)) || (int32((*Expr)(unsafe.Pointer(pLhs)).FiColumn) != int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiColumn + uintptr((i+nEq))*2))))) || (int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr((i + nEq))))) != int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(nEq))))) { @@ -131665,7 +129427,7 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb var saved_nSkip U16 // Original value of pNew->nSkip var saved_wsFlags U32 // Original value of pNew->wsFlags var saved_nOut LogEst // Original value of pNew->nOut - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var rSize LogEst // Number of rows in the table var rLogSize LogEst // Logarithm of table size var pTop uintptr = uintptr(0) @@ -131673,17 +129435,17 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb pNew = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - return 7 + return SQLITE_NOMEM } - if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & U32(0x00000020)) != 0 { - opMask = ((int32(0x0002) << (56 - 53)) | (int32(0x0002) << (55 - 53))) + if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & WHERE_BTM_LIMIT) != 0 { + opMask = ((int32(WO_EQ) << (TK_LT - TK_EQ)) | (int32(WO_EQ) << (TK_LE - TK_EQ))) } else { - opMask = (((((((0x0002 | 0x0001) | (int32(0x0002) << (54 - 53))) | (int32(0x0002) << (57 - 53))) | (int32(0x0002) << (56 - 53))) | (int32(0x0002) << (55 - 53))) | 0x0100) | 0x0080) + opMask = (((((((WO_EQ | WO_IN) | (int32(WO_EQ) << (TK_GT - TK_EQ))) | (int32(WO_EQ) << (TK_GE - TK_EQ))) | (int32(WO_EQ) << (TK_LT - TK_EQ))) | (int32(WO_EQ) << (TK_LE - TK_EQ))) | WO_ISNULL) | WO_IS) } if (uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.bUnordered */)) & 0x4 >> 2))) != 0 { - opMask = opMask & (^libc.Int32(((((int32(0x0002) << (54 - 53)) | (int32(0x0002) << (57 - 53))) | (int32(0x0002) << (56 - 53))) | (int32(0x0002) << (55 - 53))))) + opMask = opMask & (libc.CplInt32(((((int32(WO_EQ) << (TK_GT - TK_EQ)) | (int32(WO_EQ) << (TK_GE - TK_EQ))) | (int32(WO_EQ) << (TK_LT - TK_EQ))) | (int32(WO_EQ) << (TK_LE - TK_EQ))))) } saved_nEq = *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ /* &.nEq */)) @@ -131697,15 +129459,15 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb pTerm = whereScanInit(tls, bp /* &scan */, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC, (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor, int32(saved_nEq), uint32(opMask), pProbe) (*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(0) - rSize = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(0)*2)) + rSize = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst)) rLogSize = estLog(tls, rSize) - for ; (rc == 0) && (pTerm != uintptr(0)); pTerm = whereScanNext(tls, bp /* &scan */) { + for ; (rc == SQLITE_OK) && (pTerm != uintptr(0)); pTerm = whereScanNext(tls, bp /* &scan */) { var eOp U16 = (*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator // Shorthand for pTerm->eOperator var rCostIdx LogEst var nOutUnadjusted LogEst // nOut before IN() and WHERE adjustments var nIn int32 = 0 var nRecValid int32 = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid - if ((int32(eOp) == 0x0100) || ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0080) != 0)) && + if ((int32(eOp) == WO_ISNULL) || ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_VNULL) != 0)) && (indexColumnNotNull(tls, pProbe, int32(saved_nEq)) != 0) { continue // ignore IS [NOT] NULL constraints on NOT NULL columns } @@ -131715,22 +129477,22 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb // Do not allow the upper bound of a LIKE optimization range constraint // to mix with a lower range bound from some other source - if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0100) != 0) && (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) == (int32(0x0002) << (56 - 53))) { + if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_LIKEOPT) != 0) && (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) == (int32(WO_EQ) << (TK_LT - TK_EQ))) { continue } // tag-20191211-001: Do not allow constraints from the WHERE clause to // be used by the right table of a LEFT JOIN. Only constraints in the // ON clause are allowed. See tag-20191211-002 for the vtab equivalent. - if ((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & 0x0008) != 0) && - !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000001))) != U32(0)) { + if ((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & JT_LEFT) != 0) && + !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_FromJoin)) != U32(0)) { continue } - if (int32((*Index)(unsafe.Pointer((pProbe))).FonError) != 0) && (int32(saved_nEq) == (int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) - 1)) { - *(*uint8)(unsafe.Pointer(pBuilder + 52 /* &.bldFlags1 */)) |= uint8((0x0002)) + if (int32((*Index)(unsafe.Pointer((pProbe))).FonError) != OE_None) && (int32(saved_nEq) == (int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) - 1)) { + *(*uint8)(unsafe.Pointer(pBuilder + 52 /* &.bldFlags1 */)) |= uint8((SQLITE_BLDF1_UNIQUE)) } else { - *(*uint8)(unsafe.Pointer(pBuilder + 52 /* &.bldFlags1 */)) |= uint8((0x0001)) + *(*uint8)(unsafe.Pointer(pBuilder + 52 /* &.bldFlags1 */)) |= uint8((SQLITE_BLDF1_INDEXED)) } (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = saved_wsFlags *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ /* &.nEq */)) = saved_nEq @@ -131743,9 +129505,9 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(libc.PostIncUint16(&(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm, 1))*8)) = pTerm (*WhereLoop)(unsafe.Pointer(pNew)).Fprereq = ((saved_prereq | (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight) & ^(*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf) - if (int32(eOp) & 0x0001) != 0 { + if (int32(eOp) & WO_IN) != 0 { var pExpr uintptr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr - if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000800))) != U32(0) { + if ((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_xIsSelect)) != U32(0) { // "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows var i int32 nIn = 46 @@ -131796,48 +129558,48 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb } } - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00000004)) - } else if (int32(eOp) & (0x0002 | 0x0080)) != 0 { + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_COLUMN_IN) + } else if (int32(eOp) & (WO_EQ | WO_IS)) != 0 { var iCol int32 = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiColumn + uintptr(saved_nEq)*2))) - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00000001)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_COLUMN_EQ) if (iCol == (-1)) || (((iCol >= 0) && (int32(nInMul) == 0)) && (int32(saved_nEq) == (int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) - 1))) { if ((iCol == (-1)) || ((uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.uniqNotNull */)) & 0x8 >> 3))) != 0)) || - (((int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) == 1) && ((*Index)(unsafe.Pointer(pProbe)).FonError != 0)) && (int32(eOp) == 0x0002)) { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00001000)) + (((int32((*Index)(unsafe.Pointer(pProbe)).FnKeyCol) == 1) && ((*Index)(unsafe.Pointer(pProbe)).FonError != 0)) && (int32(eOp) == WO_EQ)) { + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_ONEROW) } else { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00010000)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_UNQ_WANTED) } } - } else if (int32(eOp) & 0x0100) != 0 { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00000008)) - } else if (int32(eOp) & ((int32(0x0002) << (54 - 53)) | (int32(0x0002) << (57 - 53)))) != 0 { + } else if (int32(eOp) & WO_ISNULL) != 0 { + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_COLUMN_NULL) + } else if (int32(eOp) & ((int32(WO_EQ) << (TK_GT - TK_EQ)) | (int32(WO_EQ) << (TK_GE - TK_EQ)))) != 0 { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00000002 | 0x00000020)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(WHERE_COLUMN_RANGE | WHERE_BTM_LIMIT)) *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ + 2 /* &.nBtm */)) = U16(whereRangeVectorLen(tls, pParse, (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor, pProbe, int32(saved_nEq), pTerm)) pBtm = pTerm pTop = uintptr(0) - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x0100) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_LIKEOPT) != 0 { // Range contraints that come from the LIKE optimization are // always used in pairs. - pTop = (pTerm + uintptr(1)*64) + pTop = (pTerm + 1*64) if whereLoopResize(tls, db, pNew, (int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)+1)) != 0 { break } // OOM *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(libc.PostIncUint16(&(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm, 1))*8)) = pTop - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00000010)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_TOP_LIMIT) *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ + 4 /* &.nTop */)) = U16(1) } } else { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00000002 | 0x00000010)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(WHERE_COLUMN_RANGE | WHERE_TOP_LIMIT)) *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ + 4 /* &.nTop */)) = U16(whereRangeVectorLen(tls, pParse, (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor, pProbe, int32(saved_nEq), pTerm)) pTop = pTerm - if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & U32(0x00000020)) != U32(0) { + if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & WHERE_BTM_LIMIT) != U32(0) { pBtm = *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr((int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)-2))*8)) } else { pBtm = uintptr(0) @@ -131850,7 +129612,7 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb // "x IN(...)" terms are replaced with "x = ?". This block updates // the value of pNew->nOut to account for pTerm (but not nIn/nInMul). - if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & U32(0x00000002)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & WHERE_COLUMN_RANGE) != 0 { // Adjust nOut using stat4 data. Or, if there is no stat4 // data, using some other estimate. whereRangeScanEst(tls, pParse, pBuilder, pBtm, pTop, pNew) @@ -131866,19 +129628,19 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb if ((((int32(nInMul) == 0) && ((*Index)(unsafe.Pointer(pProbe)).FnSample != 0)) && (int32(*(*U16)(unsafe.Pointer((pNew + 24 /* &.u */ /* &.btree */) /* &.nEq */))) <= (*Index)(unsafe.Pointer(pProbe)).FnSampleCol)) && - (((int32(eOp) & 0x0001) == 0) || !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000800))) != U32(0)))) && - ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0800)) == 0) { + (((int32(eOp) & WO_IN) == 0) || !(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_xIsSelect)) != U32(0)))) && + ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_Stat4)) == 0) { var pExpr uintptr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr - if (int32(eOp) & ((0x0002 | 0x0100) | 0x0080)) != 0 { + if (int32(eOp) & ((WO_EQ | WO_ISNULL) | WO_IS)) != 0 { rc = whereEqualScanEst(tls, pParse, pBuilder, (*Expr)(unsafe.Pointer(pExpr)).FpRight, bp+112 /* &nOut */) } else { rc = whereInScanEst(tls, pParse, pBuilder, *(*uintptr)(unsafe.Pointer(pExpr + 32 /* &.x */)), bp+112 /* &nOut */) } - if rc == 12 { - rc = 0 + if rc == SQLITE_NOTFOUND { + rc = SQLITE_OK } - if rc != 0 { + if rc != SQLITE_OK { break } // Jump out of the pTerm loop if *(*TRowcnt)(unsafe.Pointer(bp + 112 /* nOut */)) != 0 { @@ -131887,13 +129649,13 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb // TUNING: Mark terms as "low selectivity" if they seem likely // to be true for half or more of the rows in the table. // See tag-202002240-1 - ((int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) + 10) > int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(0)*2)))) { - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x4000)) - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & 0x2000) != 0 { + ((int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) + 10) > int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst)))) { + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_HIGHTRUTH)) + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FwtFlags) & TERM_HEURTRUTH) != 0 { // If the term has previously been used with an assumption of // higher selectivity, then set the flag to rerun the // loop computations. - *(*uint8)(unsafe.Pointer(pBuilder + 53 /* &.bldFlags2 */)) |= uint8((0x0004)) + *(*uint8)(unsafe.Pointer(pBuilder + 53 /* &.bldFlags2 */)) |= uint8((SQLITE_BLDF2_2NDPASS)) } } if int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) > int32(saved_nOut) { @@ -131904,7 +129666,7 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb } if *(*TRowcnt)(unsafe.Pointer(bp + 112 /* nOut */)) == TRowcnt(0) { *(*LogEst)(unsafe.Pointer(pNew + 22 /* &.nOut */)) += LogEst((int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(nEq)*2))) - int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr((nEq-1))*2))))) - if (int32(eOp) & 0x0100) != 0 { + if (int32(eOp) & WO_ISNULL) != 0 { // TUNING: If there is no likelihood() value, assume that a // "col IS NULL" expression matches twice as many rows // as (col=?). @@ -131921,7 +129683,7 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb rCostIdx = (LogEst((int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) + 1) + ((15 * int32((*Index)(unsafe.Pointer(pProbe)).FszIdxRow)) / int32((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pSrc)).FpTab)).FszTabRow)))) (*WhereLoop)(unsafe.Pointer(pNew)).FrRun = Xsqlite3LogEstAdd(tls, rLogSize, rCostIdx) - if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & (U32(0x00000040 | 0x00000100))) == U32(0) { + if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & (U32(WHERE_IDX_ONLY | WHERE_IPK))) == U32(0) { (*WhereLoop)(unsafe.Pointer(pNew)).FrRun = Xsqlite3LogEstAdd(tls, (*WhereLoop)(unsafe.Pointer(pNew)).FrRun, (int16(int32((*WhereLoop)(unsafe.Pointer(pNew)).FnOut) + 16))) } @@ -131931,13 +129693,13 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb whereLoopOutputAdjust(tls, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC, pNew, rSize) rc = whereLoopInsert(tls, pBuilder, pNew) - if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & U32(0x00000002)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & WHERE_COLUMN_RANGE) != 0 { (*WhereLoop)(unsafe.Pointer(pNew)).FnOut = saved_nOut } else { (*WhereLoop)(unsafe.Pointer(pNew)).FnOut = nOutUnadjusted } - if (((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & U32(0x00000010)) == U32(0)) && + if (((*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags & WHERE_TOP_LIMIT) == U32(0)) && (int32(*(*U16)(unsafe.Pointer((pNew + 24 /* &.u */ /* &.btree */) /* &.nEq */))) < int32((*Index)(unsafe.Pointer(pProbe)).FnColumn)) { whereLoopAddBtreeIndex(tls, pBuilder, pSrc, pProbe, (int16(int32(nInMul) + nIn))) } @@ -131969,14 +129731,14 @@ func whereLoopAddBtreeIndex(tls *libc.TLS, pBuilder uintptr, pSrc uintptr, pProb (int32(saved_nEq) == int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm))) && ((int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.noSkipScan */)) & 0x40 >> 6)) == 0)) && ((int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.hasStat1 */)) & 0x80 >> 7)) != 0)) && - ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x4000)) == 0)) && + ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_SkipScan)) == 0)) && (int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr((int32(saved_nEq)+1))*2))) >= 42)) && // TUNING: Minimum for skip-scan - ((libc.AssignInt32(&rc, whereLoopResize(tls, db, pNew, (int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)+1)))) == 0) { + ((libc.AssignInt32(&rc, whereLoopResize(tls, db, pNew, (int32((*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm)+1)))) == SQLITE_OK) { var nIter LogEst *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ /* &.nEq */))++ (*WhereLoop)(unsafe.Pointer(pNew)).FnSkip++ *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(libc.PostIncUint16(&(*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm, 1))*8)) = uintptr(0) - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00008000)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_SKIPSCAN) nIter = (LogEst(int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(saved_nEq)*2))) - int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr((int32(saved_nEq)+1))*2))))) *(*LogEst)(unsafe.Pointer(pNew + 22 /* &.nOut */)) -= LogEst((int32(nIter))) // TUNING: Because uncertainties in the estimates for skip-scan queries, @@ -132012,7 +129774,7 @@ func indexMightHelpWithOrderBy(tls *libc.TLS, pBuilder uintptr, pIndex uintptr, } for ii = 0; ii < (*ExprList)(unsafe.Pointer(pOB)).FnExpr; ii++ { var pExpr uintptr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer((pOB+8 /* &.a */)+uintptr(ii)*32)).FpExpr) - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 164) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == iCursor) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_COLUMN) && ((*Expr)(unsafe.Pointer(pExpr)).FiTable == iCursor) { if int32((*Expr)(unsafe.Pointer(pExpr)).FiColumn) < 0 { return 1 } @@ -132041,13 +129803,13 @@ func whereUsablePartialIndex(tls *libc.TLS, iTab int32, isLeft int32, pWC uintpt var i int32 var pTerm uintptr var pParse uintptr = (*WhereInfo)(unsafe.Pointer((*WhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpParse - for int32((*Expr)(unsafe.Pointer(pWhere)).Fop) == 44 { + for int32((*Expr)(unsafe.Pointer(pWhere)).Fop) == TK_AND { if !(whereUsablePartialIndex(tls, iTab, isLeft, pWC, (*Expr)(unsafe.Pointer(pWhere)).FpLeft) != 0) { return 0 } pWhere = (*Expr)(unsafe.Pointer(pWhere)).FpRight } - if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & uint64(0x00800000)) != 0 { + if ((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).Fflags & SQLITE_EnableQPSG) != 0 { pParse = uintptr(0) } i = 0 @@ -132059,8 +129821,8 @@ __1: { var pExpr uintptr pExpr = (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr - if ((!(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0)) || (int32((*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable) == iTab)) && - ((isLeft == 0) || (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x000001))) != U32(0)))) && + if ((!(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0)) || (int32((*Expr)(unsafe.Pointer(pExpr)).FiRightJoinTable) == iTab)) && + ((isLeft == 0) || (((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_FromJoin)) != U32(0)))) && (Xsqlite3ExprImpliesExpr(tls, pParse, pExpr, pWhere, iTab) != 0) { return 1 } @@ -132125,7 +129887,7 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { var pTabList uintptr // The FROM clause var pSrc uintptr // The FROM clause btree term to add var pNew uintptr // Template WhereLoop object - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var iSortIdx int32 = 1 // Index number var b int32 // A boolean value var rSize LogEst // number of rows in the table @@ -132143,7 +129905,7 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { if (*SrcList_item)(unsafe.Pointer(pSrc)).FpIBIndex != 0 { // An INDEXED BY clause specifies a particular index to use pProbe = (*SrcList_item)(unsafe.Pointer(pSrc)).FpIBIndex - } else if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + } else if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { pProbe = (*Table)(unsafe.Pointer(pTab)).FpIndex } else { // There is no INDEXED BY clause. Create a fake Index object in local @@ -132156,12 +129918,12 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { (*Index)(unsafe.Pointer(bp /* &sPk */)).FnColumn = U16(1) (*Index)(unsafe.Pointer(bp /* &sPk */)).FaiColumn = bp + 152 /* &aiColumnPk */ (*Index)(unsafe.Pointer(bp /* &sPk */)).FaiRowLogEst = bp + 154 /* &aiRowEstPk[0] */ - (*Index)(unsafe.Pointer(bp /* &sPk */)).FonError = U8(5) + (*Index)(unsafe.Pointer(bp /* &sPk */)).FonError = OE_Replace (*Index)(unsafe.Pointer(bp /* &sPk */)).FpTable = pTab (*Index)(unsafe.Pointer(bp /* &sPk */)).FszIdxRow = (*Table)(unsafe.Pointer(pTab)).FszTabRow - libc.SetBitFieldPtr16Uint32(bp /* &sPk */ +100 /* &.idxType */, uint32(3), 0, 0x3) - *(*LogEst)(unsafe.Pointer(bp + 154 /* &aiRowEstPk[0] */ + uintptr(0)*2)) = (*Table)(unsafe.Pointer(pTab)).FnRowLogEst - *(*LogEst)(unsafe.Pointer(bp + 154 /* &aiRowEstPk[0] */ + uintptr(1)*2)) = int16(0) + libc.SetBitFieldPtr16Uint32(bp /* &sPk */ +100 /* &.idxType */, SQLITE_IDXTYPE_IPK, 0, 0x3) + *(*LogEst)(unsafe.Pointer(bp + 154 /* &aiRowEstPk[0] */)) = (*Table)(unsafe.Pointer(pTab)).FnRowLogEst + *(*LogEst)(unsafe.Pointer(bp + 154 /* &aiRowEstPk[0] */ + 1*2)) = int16(0) pFirst = (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pSrc)).FpTab)).FpIndex if (int32(*(*uint8)(unsafe.Pointer((pSrc + 60 /* &.fg */) + 4 /* &.notIndexed */)) & 0x1 >> 0)) == 0 { // The real indices of the table are only considered if the @@ -132175,17 +129937,17 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { // Automatic indexes if ((((((!(int32((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrSet) != 0) && // Not part of an OR optimization - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0020) == 0)) && - (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb)).Fflags & uint64(0x00008000)) != uint64(0))) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_OR_SUBCLAUSE) == 0)) && + (((*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb)).Fflags & SQLITE_AutoIndex) != uint64(0))) && ((*SrcList_item)(unsafe.Pointer(pSrc)).FpIBIndex == uintptr(0))) && // Has no INDEXED BY clause !((int32(*(*uint8)(unsafe.Pointer(pSrc + 60 /* &.fg */ + 4 /* &.notIndexed */)) & 0x1 >> 0)) != 0)) && // Has no NOT INDEXED clause - (((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) && // Not WITHOUT ROWID table. (FIXME: Why not?) + (((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) && // Not WITHOUT ROWID table. (FIXME: Why not?) !((int32(*(*uint8)(unsafe.Pointer(pSrc + 60 /* &.fg */ + 4 /* &.isCorrelated */)) & 0x8 >> 3)) != 0)) && // Not a correlated subquery !((int32(*(*uint8)(unsafe.Pointer(pSrc + 60 /* &.fg */ + 4 /* &.isRecursive */)) & 0x20 >> 5)) != 0) { // Generate auto-index WhereLoops var pTerm uintptr var pWCEnd uintptr = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*WhereClause)(unsafe.Pointer(pWC)).FnTerm)*64) - for pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa; (rc == 0) && (pTerm < pWCEnd); pTerm += 64 { + for pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa; (rc == SQLITE_OK) && (pTerm < pWCEnd); pTerm += 64 { if ((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight & (*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf) != 0 { continue } @@ -132194,7 +129956,7 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { (*WhereLoop)(unsafe.Pointer(pNew)).FnSkip = U16(0) *(*uintptr)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) = uintptr(0) (*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = U16(1) - *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(0)*8)) = pTerm + *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm)) = pTerm // TUNING: One-time cost for computing the automatic index is // estimated to be X*N*log2(N) where N is the number of rows in // the table being indexed and where X is 7 (LogEst=28) for normal @@ -132204,7 +129966,7 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { // those objects, since there is no opportunity to add schema // indexes on subqueries and views. (*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = (LogEst(int32(rLogSize) + int32(rSize))) - if ((*Table)(unsafe.Pointer(pTab)).FpSelect == uintptr(0)) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0002)) == U32(0)) { + if ((*Table)(unsafe.Pointer(pTab)).FpSelect == uintptr(0)) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Ephemeral) == U32(0)) { *(*LogEst)(unsafe.Pointer(pNew + 18 /* &.rSetup */)) += int16((28)) } else { *(*LogEst)(unsafe.Pointer(pNew + 18 /* &.rSetup */)) -= int16((10)) @@ -132219,7 +129981,7 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { // not be unreasonable to make this value much larger. (*WhereLoop)(unsafe.Pointer(pNew)).FnOut = int16(43) (*WhereLoop)(unsafe.Pointer(pNew)).FrRun = Xsqlite3LogEstAdd(tls, rLogSize, (*WhereLoop)(unsafe.Pointer(pNew)).FnOut) - (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(0x00004000) + (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = WHERE_AUTO_INDEX (*WhereLoop)(unsafe.Pointer(pNew)).Fprereq = (mPrereq | (*WhereTerm)(unsafe.Pointer(pTerm)).FprereqRight) rc = whereLoopInsert(tls, pBuilder, pNew) } @@ -132229,11 +129991,11 @@ func whereLoopAddBtree(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask) int32 { // Loop over all indices. If there was an INDEXED BY clause, then only // consider index pProbe. __1: - if !((rc == 0) && (pProbe != 0)) { + if !((rc == SQLITE_OK) && (pProbe != 0)) { goto __3 } { - var isLeft int32 = (libc.Bool32((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & 0x0020) != 0)) + var isLeft int32 = (libc.Bool32((int32((*SrcList_item)(unsafe.Pointer(pSrc)).Ffg.Fjointype) & JT_OUTER) != 0)) if ((*Index)(unsafe.Pointer(pProbe)).FpPartIdxWhere != uintptr(0)) && !(whereUsablePartialIndex(tls, (*SrcList_item)(unsafe.Pointer(pSrc)).FiCursor, isLeft, pWC, (*Index)(unsafe.Pointer(pProbe)).FpPartIdxWhere) != 0) { @@ -132243,7 +130005,7 @@ __1: if (uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.bNoQuery */)) & 0x100 >> 8))) != 0 { goto __2 } - rSize = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst + uintptr(0)*2)) + rSize = *(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pProbe)).FaiRowLogEst)) *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ /* &.nEq */)) = U16(0) *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ + 2 /* &.nBtm */)) = U16(0) *(*U16)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.btree */ + 4 /* &.nTop */)) = U16(0) @@ -132258,9 +130020,9 @@ __1: // The ONEPASS_DESIRED flags never occurs together with ORDER BY - if (int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.idxType */)) & 0x3 >> 0)) == 3 { + if (int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_IPK { // Integer primary key index - (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(0x00000100) + (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = WHERE_IPK // Full table scan (*WhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = func() uint8 { @@ -132281,29 +130043,29 @@ __1: } else { var m Bitmask if (uint32(int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.isCovering */)) & 0x20 >> 5))) != 0 { - (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = (U32(0x00000040 | 0x00000200)) + (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = (U32(WHERE_IDX_ONLY | WHERE_INDEXED)) m = uint64(0) } else { m = ((*SrcList_item)(unsafe.Pointer(pSrc)).FcolUsed & (*Index)(unsafe.Pointer(pProbe)).FcolNotIdxed) (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = func() uint32 { if m == uint64(0) { - return (uint32(0x00000040 | 0x00000200)) + return (uint32(WHERE_IDX_ONLY | WHERE_INDEXED)) } - return uint32(0x00000200) + return WHERE_INDEXED }() } // Full scan via index if ((((b != 0) || - !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0))) || + !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0))) || ((*Index)(unsafe.Pointer(pProbe)).FpPartIdxWhere != uintptr(0))) || ((uint32(int32(*(*uint8)(unsafe.Pointer((pSrc + 60 /* &.fg */) + 4 /* &.isIndexedBy */)) & 0x2 >> 1))) != 0)) || ((((((m == uint64(0)) && ((int32(*(*uint16)(unsafe.Pointer(pProbe + 100 /* &.bUnordered */)) & 0x4 >> 2)) == 0)) && (int32((*Index)(unsafe.Pointer(pProbe)).FszIdxRow) < int32((*Table)(unsafe.Pointer(pTab)).FszTabRow))) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0004) == 0)) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_ONEPASS_DESIRED) == 0)) && (Xsqlite3Config.FbUseCis != 0)) && - ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb))).FdbOptFlags) & (0x0020)) == 0)) { + ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb))).FdbOptFlags) & (SQLITE_CoverIdxScan)) == 0)) { (*WhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = func() uint8 { if b != 0 { return uint8(iSortIdx) @@ -132336,7 +130098,7 @@ __1: nLookup = LogEst(int32(nLookup) + (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FtruthProb))) } else { nLookup-- - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (0x0002 | 0x0080)) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (WO_EQ | WO_IS)) != 0 { nLookup = int16(int32(nLookup) - (19)) } } @@ -132356,12 +130118,12 @@ __1: (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FbldFlags1 = uint8(0) rc = whereLoopAddBtreeIndex(tls, pBuilder, pSrc, pProbe, int16(0)) - if int32((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FbldFlags1) == 0x0001 { + if int32((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FbldFlags1) == SQLITE_BLDF1_INDEXED { // If a non-unique index is used, or if a prefix of the key for // unique index is used (making the index functionally non-unique) // then the sqlite_stat1 data becomes important for scoring the // plan - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0100)) + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (TF_StatsUsed) } Xsqlite3Stat4ProbeFree(tls, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpRec) (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FnRecValid = 0 @@ -132411,7 +130173,7 @@ func whereLoopAddVirtualOne(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mU var pUsage uintptr = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage var i int32 var mxTerm int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var pNew uintptr = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew var pParse uintptr = (*WhereInfo)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo)).FpParse var pSrc uintptr = (((*WhereInfo)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo)).FpTabList + 8 /* &.a */) + uintptr((*WhereLoop)(unsafe.Pointer(pNew)).FiTab)*112) @@ -132460,12 +130222,12 @@ __3: // Invoke the virtual table xBestIndex() method rc = vtabBestIndex(tls, pParse, (*SrcList_item)(unsafe.Pointer(pSrc)).FpTab, pIdxInfo) if rc != 0 { - if rc == 19 { + if rc == SQLITE_CONSTRAINT { // If the xBestIndex method returns SQLITE_CONSTRAINT, that means // that the particular combination of parameters provided is unusable. // Make no entries in the loop table. - return 0 + return SQLITE_OK } return rc } @@ -132494,7 +130256,7 @@ __4: (int32((*sqlite3_index_constraint)(unsafe.Pointer(pIdxCons)).Fusable) == 0) { Xsqlite3ErrorMsg(tls, pParse, ts+23608 /* "%s.xBestIndex ma..." */, libc.VaList(bp, (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pSrc)).FpTab)).FzName)) - return 1 + return SQLITE_ERROR } pTerm = ((*WhereClause)(unsafe.Pointer(pWC)).Fa + uintptr(j)*64) @@ -132513,14 +130275,14 @@ __4: } } - if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0001) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_IN) != 0 { // A virtual table that is constrained by an IN clause may not // consume the ORDER BY clause because (1) the order of IN terms // is not necessarily related to the order of output terms and // (2) Multiple outputs from a single IN value will not merge // together. (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 0 - *(*int32)(unsafe.Pointer(pIdxInfo + 80 /* &.idxFlags */)) &= (^libc.Int32(1)) + *(*int32)(unsafe.Pointer(pIdxInfo + 80 /* &.idxFlags */)) &= (libc.CplInt32(SQLITE_INDEX_SCAN_UNIQUE)) *(*int32)(unsafe.Pointer(pbIn)) = 1 } } @@ -132542,7 +130304,7 @@ __6: // error if they are not Xsqlite3ErrorMsg(tls, pParse, ts+23608 /* "%s.xBestIndex ma..." */, libc.VaList(bp+8, (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pSrc)).FpTab)).FzName)) - return 1 + return SQLITE_ERROR } } @@ -132562,10 +130324,10 @@ __6: // Set the WHERE_ONEROW flag if the xBestIndex() method indicated // that the scan will visit at most one row. Clear it otherwise. - if ((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags & 1) != 0 { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (U32(0x00001000)) + if ((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags & SQLITE_INDEX_SCAN_UNIQUE) != 0 { + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) |= (WHERE_ONEROW) } else { - *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) &= (^libc.Uint32FromInt32(0x00001000)) + *(*U32)(unsafe.Pointer(pNew + 40 /* &.wsFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(WHERE_ONEROW))) } rc = whereLoopInsert(tls, pBuilder, pNew) if *(*U8)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.vtab */ + 4 /* &.needFree */)) != 0 { @@ -132582,7 +130344,7 @@ __6: // array. Or, if iCons is out of range or there is no active xBestIndex // call, return NULL. func Xsqlite3_vtab_collation(tls *libc.TLS, pIdxInfo uintptr, iCons int32) uintptr { /* sqlite3.c:148926:23: */ - var pHidden uintptr = (pIdxInfo + uintptr(1)*96) + var pHidden uintptr = (pIdxInfo + 1*96) var zRet uintptr = uintptr(0) if (iCons >= 0) && (iCons < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { var pC uintptr = uintptr(0) @@ -132628,13 +130390,13 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 // Return code - var pWInfo uintptr // WHERE analysis context - var pParse uintptr // The parsing context - var pWC uintptr // The WHERE clause - var pSrc uintptr // The FROM clause term to search - var p uintptr // Object to pass to xBestIndex() - var nConstraint int32 // Number of constraints in p + var rc int32 = SQLITE_OK // Return code + var pWInfo uintptr // WHERE analysis context + var pParse uintptr // The parsing context + var pWC uintptr // The WHERE clause + var pSrc uintptr // The FROM clause term to search + var p uintptr // Object to pass to xBestIndex() + var nConstraint int32 // Number of constraints in p // var bIn int32 at bp+4, 4 // True if plan uses IN(...) operator var pNew uintptr @@ -132650,16 +130412,16 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus p = allocateIndexInfo(tls, pParse, pWC, mUnusable, pSrc, (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpOrderBy, bp /* &mNoOmit */) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(0) - (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(0x00000400) + (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = WHERE_VIRTUALTABLE (*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = U16(0) *(*U8)(unsafe.Pointer(pNew + 24 /* &.u */ /* &.vtab */ + 4 /* &.needFree */)) = U8(0) nConstraint = (*Sqlite3_index_info)(unsafe.Pointer(p)).FnConstraint if whereLoopResize(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pNew, nConstraint) != 0 { Xsqlite3DbFree(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, p) - return 7 + return SQLITE_NOMEM } // First call xBestIndex() with all constraints usable. @@ -132671,7 +130433,7 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus // and does not use an IN(...) operator, then there is no point in making // any further calls to xBestIndex() since they will all return the same // result (if the xBestIndex() implementation is sane). - if (rc == 0) && (((libc.AssignUint64(&mBest, ((*WhereLoop)(unsafe.Pointer(pNew)).Fprereq & ^mPrereq))) != uint64(0)) || (*(*int32)(unsafe.Pointer(bp + 4 /* bIn */)) != 0)) { + if (rc == SQLITE_OK) && (((libc.AssignUint64(&mBest, ((*WhereLoop)(unsafe.Pointer(pNew)).Fprereq & ^mPrereq))) != uint64(0)) || (*(*int32)(unsafe.Pointer(bp + 4 /* bIn */)) != 0)) { var seenZero int32 = 0 // True if a plan with no prereqs seen var seenZeroNoIN int32 = 0 // Plan with no prereqs and no IN(...) seen var mPrev Bitmask = uint64(0) @@ -132682,7 +130444,7 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus if *(*int32)(unsafe.Pointer(bp + 4 /* bIn */)) != 0 { rc = whereLoopAddVirtualOne(tls, - pBuilder, mPrereq, libc.Uint64(libc.Uint64FromInt32(-1)), uint16(0x0001), p, *(*U16)(unsafe.Pointer(bp /* mNoOmit */)), bp+4 /* &bIn */) + pBuilder, mPrereq, libc.Uint64(libc.Uint64FromInt32(-1)), WO_IN, p, *(*U16)(unsafe.Pointer(bp /* mNoOmit */)), bp+4 /* &bIn */) mBestNoIn = ((*WhereLoop)(unsafe.Pointer(pNew)).Fprereq & ^mPrereq) if mBestNoIn == uint64(0) { @@ -132693,7 +130455,7 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus // Call xBestIndex once for each distinct value of (prereqRight & ~mPrereq) // in the set of terms that apply to the current virtual table. - for rc == 0 { + for rc == SQLITE_OK { var i int32 var mNext Bitmask = libc.Uint64(libc.Uint64FromInt32(-1)) @@ -132724,7 +130486,7 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus // If the calls to xBestIndex() in the above loop did not find a plan // that requires no source tables at all (i.e. one guaranteed to be // usable), make a call here with all source tables disabled - if (rc == 0) && (seenZero == 0) { + if (rc == SQLITE_OK) && (seenZero == 0) { rc = whereLoopAddVirtualOne(tls, pBuilder, mPrereq, mPrereq, uint16(0), p, *(*U16)(unsafe.Pointer(bp /* mNoOmit */)), bp+4 /* &bIn */) @@ -132736,10 +130498,10 @@ func whereLoopAddVirtual(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnus // If the calls to xBestIndex() have so far failed to find a plan // that requires no source tables at all and does not use an IN(...) // operator, make a final call to obtain one here. - if (rc == 0) && (seenZeroNoIN == 0) { + if (rc == SQLITE_OK) && (seenZeroNoIN == 0) { rc = whereLoopAddVirtualOne(tls, - pBuilder, mPrereq, mPrereq, uint16(0x0001), p, *(*U16)(unsafe.Pointer(bp /* mNoOmit */)), bp+4 /* &bIn */) + pBuilder, mPrereq, mPrereq, WO_IN, p, *(*U16)(unsafe.Pointer(bp /* mNoOmit */)), bp+4 /* &bIn */) } } @@ -132762,7 +130524,7 @@ func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable var pNew uintptr var pTerm uintptr var pWCEnd uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK var iCur int32 // var tempWC WhereClause at bp+112, 552 @@ -132781,8 +130543,8 @@ func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable pItem = (((*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 /* &.a */) + uintptr((*WhereLoop)(unsafe.Pointer(pNew)).FiTab)*112) iCur = (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor - for pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa; (pTerm < pWCEnd) && (rc == 0); pTerm += 64 { - if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & 0x0200) != 0) && + for pTerm = (*WhereClause)(unsafe.Pointer(pWC)).Fa; (pTerm < pWCEnd) && (rc == SQLITE_OK); pTerm += 64 { + if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & WO_OR) != 0) && (((*WhereOrInfo)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pTerm + 40 /* &.u */)))).Findexable & (*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf) != uint64(0)) { var pOrWC uintptr = (*(*uintptr)(unsafe.Pointer(pTerm + 40 /* &.u */)) /* &.wc */) var pOrWCEnd uintptr = ((*WhereClause)(unsafe.Pointer(pOrWC)).Fa + uintptr((*WhereClause)(unsafe.Pointer(pOrWC)).FnTerm)*64) @@ -132796,12 +130558,12 @@ func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable (*WhereLoopBuilder)(unsafe.Pointer(bp + 664 /* &sSubBuild */)).FpOrSet = bp + 56 /* &sCur */ for pOrTerm = (*WhereClause)(unsafe.Pointer(pOrWC)).Fa; pOrTerm < pOrWCEnd; pOrTerm += 64 { - if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & 0x0400) != 0 { + if (int32((*WhereTerm)(unsafe.Pointer(pOrTerm)).FeOperator) & WO_AND) != 0 { (*WhereLoopBuilder)(unsafe.Pointer(bp + 664 /* &sSubBuild */)).FpWC = (*(*uintptr)(unsafe.Pointer(pOrTerm + 40 /* &.u */)) /* &.wc */) } else if (*WhereTerm)(unsafe.Pointer(pOrTerm)).FleftCursor == iCur { (*WhereClause)(unsafe.Pointer(bp + 112 /* &tempWC */)).FpWInfo = (*WhereClause)(unsafe.Pointer(pWC)).FpWInfo (*WhereClause)(unsafe.Pointer(bp + 112 /* &tempWC */)).FpOuter = pWC - (*WhereClause)(unsafe.Pointer(bp + 112 /* &tempWC */)).Fop = U8(44) + (*WhereClause)(unsafe.Pointer(bp + 112 /* &tempWC */)).Fop = TK_AND (*WhereClause)(unsafe.Pointer(bp + 112 /* &tempWC */)).FnTerm = 1 (*WhereClause)(unsafe.Pointer(bp + 112 /* &tempWC */)).Fa = pOrTerm (*WhereLoopBuilder)(unsafe.Pointer(bp + 664 /* &sSubBuild */)).FpWC = bp + 112 /* &tempWC */ @@ -132814,7 +130576,7 @@ func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable } else { rc = whereLoopAddBtree(tls, bp+664 /* &sSubBuild */, mPrereq) } - if rc == 0 { + if rc == SQLITE_OK { rc = whereLoopAddOr(tls, bp+664 /* &sSubBuild */, mPrereq, mUnusable) } @@ -132839,8 +130601,8 @@ func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable } } (*WhereLoop)(unsafe.Pointer(pNew)).FnLTerm = U16(1) - *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm + uintptr(0)*8)) = pTerm - (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = U32(0x00002000) + *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pNew)).FaLTerm)) = pTerm + (*WhereLoop)(unsafe.Pointer(pNew)).FwsFlags = WHERE_MULTI_OR (*WhereLoop)(unsafe.Pointer(pNew)).FrSetup = int16(0) (*WhereLoop)(unsafe.Pointer(pNew)).FiSortIdx = U8(0) libc.Xmemset(tls, (pNew + 24 /* &.u */), 0, uint64(unsafe.Sizeof(struct { @@ -132852,7 +130614,7 @@ func whereLoopAddOr(tls *libc.TLS, pBuilder uintptr, mPrereq Bitmask, mUnusable FpIndex uintptr } }{}))) - for i = 0; (rc == 0) && (i < int32((*WhereOrSet)(unsafe.Pointer(bp /* &sSum */)).Fn)); i++ { + for i = 0; (rc == SQLITE_OK) && (i < int32((*WhereOrSet)(unsafe.Pointer(bp /* &sSum */)).Fn)); i++ { // TUNING: Currently sSum.a[i].rRun is set to the sum of the costs // of all sub-scans required by the OR-scan. However, due to rounding // errors, it may be that the cost of the OR-scan is equal to its @@ -132886,13 +130648,13 @@ func whereLoopAddAll(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:14921 var pItem uintptr var pEnd uintptr = ((pTabList + 8 /* &.a */) + uintptr((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel)*112) var db uintptr = (*Parse)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse)).Fdb - var rc int32 = 0 + var rc int32 = SQLITE_OK var pNew uintptr // Loop over the tables in the join, from left to right pNew = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew whereLoopInit(tls, pNew) - (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit = uint32(20000) + (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FiPlanLimit = SQLITE_QUERY_PLANNER_LIMIT iTab = 0 pItem = pTabList + 8 /* &.a */ __1: @@ -132902,9 +130664,9 @@ __1: { var mUnusable Bitmask = uint64(0) (*WhereLoop)(unsafe.Pointer(pNew)).FiTab = U8(iTab) - *(*uint32)(unsafe.Pointer(pBuilder + 56 /* &.iPlanLimit */)) += (uint32(1000)) + *(*uint32)(unsafe.Pointer(pBuilder + 56 /* &.iPlanLimit */)) += (SQLITE_QUERY_PLANNER_LIMIT_INCR) (*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf = Xsqlite3WhereGetMask(tls, (pWInfo + 656 /* &.sMaskSet */), (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor) - if (int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & (0x0008 | 0x0002)) != 0 { + if (int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & (JT_LEFT | JT_CROSS)) != 0 { // This condition is true when pItem is the FROM clause term on the // right-hand-side of a LEFT or CROSS JOIN. mPrereq = mPrior @@ -132913,8 +130675,8 @@ __1: } if (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pItem)).FpTab)).FnModuleArg != 0 { var p uintptr - for p = (pItem + uintptr(1)*112); p < pEnd; p += 112 { - if (mUnusable != 0) || ((int32((*SrcList_item)(unsafe.Pointer(p)).Ffg.Fjointype) & (0x0008 | 0x0002)) != 0) { + for p = (pItem + 1*112); p < pEnd; p += 112 { + if (mUnusable != 0) || ((int32((*SrcList_item)(unsafe.Pointer(p)).Ffg.Fjointype) & (JT_LEFT | JT_CROSS)) != 0) { mUnusable = mUnusable | (Xsqlite3WhereGetMask(tls, (pWInfo + 656 /* &.sMaskSet */), (*SrcList_item)(unsafe.Pointer(p)).FiCursor)) } } @@ -132922,15 +130684,15 @@ __1: } else { rc = whereLoopAddBtree(tls, pBuilder, mPrereq) } - if (rc == 0) && ((*WhereClause)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC)).FhasOr != 0) { + if (rc == SQLITE_OK) && ((*WhereClause)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWC)).FhasOr != 0) { rc = whereLoopAddOr(tls, pBuilder, mPrereq, mUnusable) } mPrior = mPrior | ((*WhereLoop)(unsafe.Pointer(pNew)).FmaskSelf) if (rc != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { - if rc == 101 { + if rc == SQLITE_DONE { // We hit the query planner search limit set by iPlanLimit - Xsqlite3_log(tls, 28, ts+23634 /* "abbreviated quer..." */, 0) - rc = 0 + Xsqlite3_log(tls, SQLITE_WARNING, ts+23634 /* "abbreviated quer..." */, 0) + rc = SQLITE_OK } else { goto __3 } @@ -133012,7 +130774,7 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, // rowid appears in the ORDER BY clause, the corresponding WhereLoop is // automatically order-distinct. - if (nLoop != 0) && ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0040)) != 0) { + if (nLoop != 0) && ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_OrderByIdxJoin)) != 0) { return int8(0) } @@ -133025,9 +130787,9 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, obDone = ((Bitmask((uint64(1))) << (int32(nOrderBy))) - uint64(1)) orderDistinctMask = uint64(0) ready = uint64(0) - eqOpMask = (U16((0x0002 | 0x0080) | 0x0100)) - if (int32(wctrlFlags) & ((0x0800 | 0x0002) | 0x0001)) != 0 { - eqOpMask = U16(int32(eqOpMask) | (0x0001)) + eqOpMask = (U16((WO_EQ | WO_IS) | WO_ISNULL)) + if (int32(wctrlFlags) & ((WHERE_ORDERBY_LIMIT | WHERE_ORDERBY_MAX) | WHERE_ORDERBY_MIN)) != 0 { + eqOpMask = U16(int32(eqOpMask) | (WO_IN)) } for iLoop = 0; ((isOrderDistinct != 0) && (obSat < obDone)) && (iLoop <= int32(nLoop)); iLoop++ { if iLoop > 0 { @@ -133035,18 +130797,18 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, } if iLoop < int32(nLoop) { pLoop = *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pPath)).FaLoop + uintptr(iLoop)*8)) - if (int32(wctrlFlags) & 0x0800) != 0 { + if (int32(wctrlFlags) & WHERE_ORDERBY_LIMIT) != 0 { continue } } else { pLoop = pLast } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000400)) != 0 { - if (*(*I8)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.vtab */) + 5 /* &.isOrdered */)) != 0) && ((int32(wctrlFlags) & 0x0080) == 0) { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_VIRTUALTABLE) != 0 { + if (*(*I8)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.vtab */) + 5 /* &.isOrdered */)) != 0) && ((int32(wctrlFlags) & WHERE_DISTINCTBY) == 0) { obSat = obDone } break - } else if (int32(wctrlFlags) & 0x0080) != 0 { + } else if (int32(wctrlFlags) & WHERE_DISTINCTBY) != 0 { *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 6 /* &.nDistinctCol */)) = U16(0) } iCur = (*SrcList_item)(unsafe.Pointer(((*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 /* &.a */) + uintptr((*WhereLoop)(unsafe.Pointer(pLoop)).FiTab)*112)).FiCursor @@ -133060,7 +130822,7 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, continue } pOBExpr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FpExpr) - if int32((*Expr)(unsafe.Pointer(pOBExpr)).Fop) != 164 { + if int32((*Expr)(unsafe.Pointer(pOBExpr)).Fop) != TK_COLUMN { continue } if (*Expr)(unsafe.Pointer(pOBExpr)).FiTable != iCur { @@ -133071,7 +130833,7 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, if pTerm == uintptr(0) { continue } - if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) == 0x0001 { + if int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) == WO_IN { // IN terms are only valid for sorting in the ORDER BY LIMIT // optimization, and then only if they are actually used // by the query plan @@ -133082,7 +130844,7 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, continue } } - if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (0x0002 | 0x0080)) != 0) && (int32((*Expr)(unsafe.Pointer(pOBExpr)).FiColumn) >= 0) { + if ((int32((*WhereTerm)(unsafe.Pointer(pTerm)).FeOperator) & (WO_EQ | WO_IS)) != 0) && (int32((*Expr)(unsafe.Pointer(pOBExpr)).FiColumn) >= 0) { var pParse uintptr = (*WhereInfo)(unsafe.Pointer(pWInfo)).FpParse var pColl1 uintptr = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FpExpr) var pColl2 uintptr = Xsqlite3ExprCompareCollSeq(tls, pParse, (*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr) @@ -133095,8 +130857,8 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, obSat = obSat | (Bitmask((uint64(1))) << (i)) } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00001000)) == U32(0) { - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000100)) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_ONEROW) == U32(0) { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IPK) != 0 { pIndex = uintptr(0) nKeyCol = U16(0) nColumn = U16(1) @@ -133106,8 +130868,8 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, nKeyCol = (*Index)(unsafe.Pointer(pIndex)).FnKeyCol nColumn = (*Index)(unsafe.Pointer(pIndex)).FnColumn - isOrderDistinct = (U8(libc.Bool32((int32((*Index)(unsafe.Pointer((pIndex))).FonError) != 0) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00008000)) == U32(0))))) + isOrderDistinct = (U8(libc.Bool32((int32((*Index)(unsafe.Pointer((pIndex))).FonError) != OE_None) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_SKIPSCAN) == U32(0))))) } // Loop through all columns of the index and deal with the ones @@ -133132,12 +130894,12 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, // if it is one of two or more, none of the columns can be // considered to match an ORDER BY term. if (int32(eOp) & int32(eqOpMask)) != 0 { - if (int32(eOp) & (0x0100 | 0x0080)) != 0 { + if (int32(eOp) & (WO_ISNULL | WO_IS)) != 0 { isOrderDistinct = U8(0) } continue - } else if (int32(eOp) & 0x0001) != 0 { + } else if (int32(eOp) & WO_IN) != 0 { // ALWAYS() justification: eOp is an equality operator due to the // ju.btree.nEq constraint above. Any equality other // than WO_IN is captured by the previous "if". So this one @@ -133157,7 +130919,7 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, // (revIdx) for the j-th column of the index. if pIndex != 0 { iColumn = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(j)*2))) - revIdx = (U8(int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(j)))) & 0x01)) + revIdx = (U8(int32(*(*U8)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(j)))) & KEYINFO_ORDER_DESC)) if iColumn == int32((*Table)(unsafe.Pointer((*Index)(unsafe.Pointer(pIndex)).FpTable)).FiPKey) { iColumn = -1 } @@ -133184,11 +130946,11 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, } pOBExpr = Xsqlite3ExprSkipCollateAndLikely(tls, (*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FpExpr) - if (int32(wctrlFlags) & (0x0040 | 0x0080)) == 0 { + if (int32(wctrlFlags) & (WHERE_GROUPBY | WHERE_DISTINCTBY)) == 0 { bOnce = U8(0) } if iColumn >= (-1) { - if int32((*Expr)(unsafe.Pointer(pOBExpr)).Fop) != 164 { + if int32((*Expr)(unsafe.Pointer(pOBExpr)).Fop) != TK_COLUMN { continue } if (*Expr)(unsafe.Pointer(pOBExpr)).FiTable != iCur { @@ -133209,30 +130971,30 @@ func wherePathSatisfiesOrderBy(tls *libc.TLS, pWInfo uintptr, pOrderBy uintptr, continue } } - if (int32(wctrlFlags) & 0x0080) != 0 { + if (int32(wctrlFlags) & WHERE_DISTINCTBY) != 0 { *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 6 /* &.nDistinctCol */)) = (U16(j + 1)) } isMatch = U8(1) break } - if (isMatch != 0) && ((int32(wctrlFlags) & 0x0040) == 0) { + if (isMatch != 0) && ((int32(wctrlFlags) & WHERE_GROUPBY) == 0) { // Make sure the sort order is compatible in an ORDER BY clause. // Sort order is irrelevant for a GROUP BY clause. if revSet != 0 { - if (int32(rev) ^ int32(revIdx)) != (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & 0x01) { + if (int32(rev) ^ int32(revIdx)) != (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & KEYINFO_ORDER_DESC) { isMatch = U8(0) } } else { - rev = (U8(int32(revIdx) ^ (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & 0x01))) + rev = (U8(int32(revIdx) ^ (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & KEYINFO_ORDER_DESC))) if rev != 0 { *(*Bitmask)(unsafe.Pointer(pRevMask)) |= (Bitmask((uint64(1))) << (iLoop)) } revSet = U8(1) } } - if (isMatch != 0) && ((int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & 0x02) != 0) { + if (isMatch != 0) && ((int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(i)*32)).FsortFlags) & KEYINFO_ORDER_BIGNULL) != 0) { if j == int32(*(*U16)(unsafe.Pointer((pLoop + 24 /* &.u */ /* &.btree */) /* &.nEq */))) { - *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (U32(0x00080000)) + *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (WHERE_BIGNULL_SORT) } else { isMatch = U8(0) } @@ -133344,7 +131106,7 @@ func whereSortingCost(tls *libc.TLS, pWInfo uintptr, nRow LogEst, nOrderBy int32 // Multiple by log(M) where M is the number of output rows. // Use the LIMIT for M if it is smaller - if ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x4000) != 0) && (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FiLimit) < int32(nRow)) { + if ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_USE_LIMIT) != 0) && (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FiLimit) < int32(nRow)) { nRow = (*WhereInfo)(unsafe.Pointer(pWInfo)).FiLimit } rSortCost = LogEst(int32(rSortCost) + (int32(estLog(tls, nRow)))) @@ -133421,7 +131183,7 @@ func wherePathSolver(tls *libc.TLS, pWInfo uintptr, nRowEst LogEst) int32 { /* s nSpace = int32(uint64(nSpace) + (uint64(unsafe.Sizeof(LogEst(0))) * uint64(nOrderBy))) pSpace = Xsqlite3DbMallocRawNN(tls, db, uint64(nSpace)) if pSpace == uintptr(0) { - return 7 + return SQLITE_NOMEM } aTo = pSpace aFrom = (aTo + uintptr(mxChoice)*32) @@ -133462,7 +131224,7 @@ __3: // TUNING: Do not let the number of iterations go above 28. If the cost // of computing an automatic index is not paid back within the first 28 // rows, then do not use the automatic index. - (*WherePath)(unsafe.Pointer(aFrom + uintptr(0)*32)).FnRow = func() int16 { + (*WherePath)(unsafe.Pointer(aFrom)).FnRow = func() int16 { if ((*Parse)(unsafe.Pointer(pParse)).FnQueryLoop) < (U32(48)) { return int16((*Parse)(unsafe.Pointer(pParse)).FnQueryLoop) } @@ -133477,7 +131239,7 @@ __3: // indicate this. Or, if nLoop is greater than zero, set isOrdered to // -1, indicating that the result set may or may not be ordered, // depending on the loops added to the current plan. - (*WherePath)(unsafe.Pointer(aFrom + uintptr(0)*32)).FisOrdered = func() int8 { + (*WherePath)(unsafe.Pointer(aFrom)).FisOrdered = func() int8 { if nLoop > 0 { return int8(-1) } @@ -133511,7 +131273,7 @@ __3: if ((*WhereLoop)(unsafe.Pointer(pWLoop)).FmaskSelf & (*WherePath)(unsafe.Pointer(pFrom)).FmaskLoop) != uint64(0) { continue } - if (((*WhereLoop)(unsafe.Pointer(pWLoop)).FwsFlags & U32(0x00004000)) != U32(0)) && (int32((*WherePath)(unsafe.Pointer(pFrom)).FnRow) < 3) { + if (((*WhereLoop)(unsafe.Pointer(pWLoop)).FwsFlags & WHERE_AUTO_INDEX) != U32(0)) && (int32((*WherePath)(unsafe.Pointer(pFrom)).FnRow) < 3) { // Do not use an automatic index if the this loop is expected // to run less than 1.25 times. It is tempting to also exclude // automatic index usage on an outer loop, but sometimes an automatic @@ -133631,10 +131393,10 @@ __3: *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pTo)).FaLoop + uintptr(iLoop)*8)) = pWLoop if nTo >= mxChoice { mxI = 0 - mxCost = (*WherePath)(unsafe.Pointer(aTo + uintptr(0)*32)).FrCost - mxUnsorted = (*WherePath)(unsafe.Pointer(aTo + uintptr(0)*32)).FnRow + mxCost = (*WherePath)(unsafe.Pointer(aTo)).FrCost + mxUnsorted = (*WherePath)(unsafe.Pointer(aTo)).FnRow jj = 1 - pTo = (aTo + uintptr(1)*32) + pTo = (aTo + 1*32) __10: if !(jj < mxChoice) { goto __12 @@ -133678,7 +131440,7 @@ __3: if nFrom == 0 { Xsqlite3ErrorMsg(tls, pParse, ts+23669 /* "no query solutio..." */, 0) Xsqlite3DbFreeNN(tls, db, pSpace) - return 1 + return SQLITE_ERROR } // Find the lowest cost path. pFrom will be left pointing to that path @@ -133696,23 +131458,23 @@ __3: (*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom = (*WhereLoop)(unsafe.Pointer(pWLoop)).FiTab (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur = (*SrcList_item)(unsafe.Pointer(((*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 /* &.a */) + uintptr((*WhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*112)).FiCursor } - if ((((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0100) != 0) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0080) == 0)) && - (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == 0)) && + if ((((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_WANT_DISTINCT) != 0) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_DISTINCTBY) == 0)) && + (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == WHERE_DISTINCT_NOOP)) && (nRowEst != 0) { // var notUsed Bitmask at bp+8, 8 var rc int32 = int32(wherePathSatisfiesOrderBy(tls, pWInfo, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet, pFrom, - uint16(0x0080), (uint16(nLoop - 1)), *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr((nLoop-1))*8)), bp+8 /* ¬Used */)) + WHERE_DISTINCTBY, (uint16(nLoop - 1)), *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr((nLoop-1))*8)), bp+8 /* ¬Used */)) if rc == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet)).FnExpr { - (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(2) + (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = WHERE_DISTINCT_ORDERED } } libc.SetBitFieldPtr8Uint32(pWInfo+68 /* &.bOrderedInnerLoop */, uint32(0), 2, 0x4) if (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 { - if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0080) != 0 { + if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_DISTINCTBY) != 0 { if int32((*WherePath)(unsafe.Pointer(pFrom)).FisOrdered) == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr { - (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(2) + (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = WHERE_DISTINCT_ORDERED } } else { (*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = (*WherePath)(unsafe.Pointer(pFrom)).FisOrdered @@ -133721,11 +131483,11 @@ __3: (*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = int8(0) if nLoop > 0 { var wsFlags U32 = (*WhereLoop)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr((nLoop-1))*8)))).FwsFlags - if ((wsFlags & U32(0x00001000)) == U32(0)) && - ((wsFlags & (U32(0x00000100 | 0x00000004))) != (U32(0x00000100 | 0x00000004))) { + if ((wsFlags & WHERE_ONEROW) == U32(0)) && + ((wsFlags & (U32(WHERE_IPK | WHERE_COLUMN_IN))) != (U32(WHERE_IPK | WHERE_COLUMN_IN))) { *(*Bitmask)(unsafe.Pointer(bp + 16 /* m */)) = uint64(0) var rc int32 = int32(wherePathSatisfiesOrderBy(tls, pWInfo, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy, pFrom, - uint16(0x0800), (uint16(nLoop - 1)), *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr((nLoop-1))*8)), bp+16 /* &m */)) + WHERE_ORDERBY_LIMIT, (uint16(nLoop - 1)), *(*uintptr)(unsafe.Pointer((*WherePath)(unsafe.Pointer(pFrom)).FaLoop + uintptr((nLoop-1))*8)), bp+16 /* &m */)) if rc == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr { libc.SetBitFieldPtr8Uint32(pWInfo+68 /* &.bOrderedInnerLoop */, uint32(1), 2, 0x4) @@ -133735,11 +131497,11 @@ __3: } } else if ((nLoop != 0) && (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) == 1)) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & (0x0001 | 0x0002)) != 0) { + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & (WHERE_ORDERBY_MIN | WHERE_ORDERBY_MAX)) != 0) { libc.SetBitFieldPtr8Uint32(pWInfo+68 /* &.bOrderedInnerLoop */, uint32(1), 2, 0x4) } } - if (((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0200) != 0) && + if (((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_SORTBYGROUP) != 0) && (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) == (*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr)) && (nLoop > 0) { *(*Bitmask)(unsafe.Pointer(bp + 24 /* revMask */)) = uint64(0) var nOrder int32 = int32(wherePathSatisfiesOrderBy(tls, pWInfo, (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy, @@ -133756,7 +131518,7 @@ __3: // Free temporary memory and return success Xsqlite3DbFreeNN(tls, db, pSpace) - return 0 + return SQLITE_OK } // Most queries use only a single table (they are not joins) and have @@ -133780,7 +131542,7 @@ func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:150086: var pIdx uintptr pWInfo = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpWInfo - if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0020) != 0 { + if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_OR_SUBCLAUSE) != 0 { return 0 } @@ -133797,11 +131559,11 @@ func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:150086: pLoop = (*WhereLoopBuilder)(unsafe.Pointer(pBuilder)).FpNew (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = U32(0) (*WhereLoop)(unsafe.Pointer(pLoop)).FnSkip = U16(0) - pTerm = Xsqlite3WhereFindTerm(tls, pWC, iCur, -1, uint64(0), (uint32(0x0002 | 0x0080)), uintptr(0)) + pTerm = Xsqlite3WhereFindTerm(tls, pWC, iCur, -1, uint64(0), (uint32(WO_EQ | WO_IS)), uintptr(0)) if pTerm != 0 { - (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = (U32((0x00000001 | 0x00000100) | 0x00001000)) - *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm + uintptr(0)*8)) = pTerm + (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = (U32((WHERE_COLUMN_EQ | WHERE_IPK) | WHERE_ONEROW)) + *(*uintptr)(unsafe.Pointer((*WhereLoop)(unsafe.Pointer(pLoop)).FaLTerm)) = pTerm (*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm = U16(1) *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ /* &.nEq */)) = U16(1) // TUNING: Cost of a rowid lookup is 10 @@ -133810,15 +131572,15 @@ func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:150086: for pIdx = (*Table)(unsafe.Pointer(pTab)).FpIndex; pIdx != 0; pIdx = (*Index)(unsafe.Pointer(pIdx)).FpNext { var opMask int32 - if (!(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != 0) || + if (!(int32((*Index)(unsafe.Pointer((pIdx))).FonError) != OE_None) || ((*Index)(unsafe.Pointer(pIdx)).FpPartIdxWhere != uintptr(0))) || (int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) > (int32(uint64(unsafe.Sizeof([3]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))))) { continue } if (uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 100 /* &.uniqNotNull */)) & 0x8 >> 3))) != 0 { - opMask = (0x0002 | 0x0080) + opMask = (WO_EQ | WO_IS) } else { - opMask = 0x0002 + opMask = WO_EQ } for j = 0; j < int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol); j++ { pTerm = Xsqlite3WhereFindTerm(tls, pWC, iCur, j, uint64(0), uint32(opMask), pIdx) @@ -133831,9 +131593,9 @@ func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:150086: if j != int32((*Index)(unsafe.Pointer(pIdx)).FnKeyCol) { continue } - (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = (U32((0x00000001 | 0x00001000) | 0x00000200)) + (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags = (U32((WHERE_COLUMN_EQ | WHERE_ONEROW) | WHERE_INDEXED)) if ((uint32(int32(*(*uint16)(unsafe.Pointer(pIdx + 100 /* &.isCovering */)) & 0x20 >> 5))) != 0) || (((*SrcList_item)(unsafe.Pointer(pItem)).FcolUsed & (*Index)(unsafe.Pointer(pIdx)).FcolNotIdxed) == uint64(0)) { - *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (U32(0x00000040)) + *(*U32)(unsafe.Pointer(pLoop + 40 /* &.wsFlags */)) |= (WHERE_IDX_ONLY) } (*WhereLoop)(unsafe.Pointer(pLoop)).FnLTerm = U16(j) *(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ /* &.nEq */)) = U16(j) @@ -133845,16 +131607,16 @@ func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:150086: } if (*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags != 0 { (*WhereLoop)(unsafe.Pointer(pLoop)).FnOut = int16(1) - (*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */) + uintptr(0)*88)).FpWLoop = pLoop + (*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */))).FpWLoop = pLoop (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf = uint64(1) // sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); - (*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */) + uintptr(0)*88)).FiTabCur = iCur + (*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */))).FiTabCur = iCur (*WhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut = int16(1) if (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy != 0 { (*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = I8((*ExprList)(unsafe.Pointer((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy)).FnExpr) } - if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0100) != 0 { - (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(1) + if (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_WANT_DISTINCT) != 0 { + (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = WHERE_DISTINCT_UNIQUE } return 1 } @@ -133863,11 +131625,11 @@ func whereShortCut(tls *libc.TLS, pBuilder uintptr) int32 { /* sqlite3.c:150086: // Helper function for exprIsDeterministic(). func exprNodeIsDeterministic(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:150168:12: */ - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 169) && ((libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x080000))) != U32(0))) == 0) { + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_FUNCTION) && ((libc.Bool32(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_ConstFunc)) != U32(0))) == 0) { (*Walker)(unsafe.Pointer(pWalker)).FeCode = U16(0) - return 2 + return WRC_Abort } - return 0 + return WRC_Continue } // Return true if the expression contains no non-deterministic SQL @@ -134044,10 +131806,10 @@ __1: // Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via // sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) - if !((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0010)) != 0) { + if !((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_DistinctOpt)) != 0) { goto __2 } - wctrlFlags = libc.Uint16FromInt32(int32(wctrlFlags) & (^libc.Int32(0x0100))) + wctrlFlags = libc.Uint16FromInt32(int32(wctrlFlags) & (libc.CplInt32(WHERE_WANT_DISTINCT))) __2: ; @@ -134066,7 +131828,7 @@ __3: // pTabList. But if the WHERE_OR_SUBCLAUSE flag is set, then we should // only generate code for the first table in pTabList and assume that // any cursors associated with subsequent tables are uninitialized. - if (int32(wctrlFlags) & 0x0020) != 0 { + if (int32(wctrlFlags) & WHERE_OR_SUBCLAUSE) != 0 { nTabList = 1 } else { nTabList = (*SrcList)(unsafe.Pointer(pTabList)).FnSrc @@ -134078,7 +131840,7 @@ __3: // and the WhereMaskSet structure. Since WhereClause contains an 8-byte // field (type Bitmask) it must be aligned on an 8-byte boundary on // some architectures. Hence the ROUND8() below. - nByteWInfo = (int32(((uint64(unsafe.Sizeof(WhereInfo{})) + ((uint64(nTabList - 1)) * uint64(unsafe.Sizeof(WhereLevel{})))) + uint64(7)) & ^libc.Uint64FromInt32(7))) + nByteWInfo = (int32(((uint64(unsafe.Sizeof(WhereInfo{})) + ((uint64(nTabList - 1)) * uint64(unsafe.Sizeof(WhereLevel{})))) + uint64(7)) & libc.Uint64FromInt32(libc.CplInt32(7)))) pWInfo = Xsqlite3DbMallocRawNN(tls, db, (uint64(uint64(nByteWInfo) + uint64(unsafe.Sizeof(WhereLoop{}))))) if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __4 @@ -134093,7 +131855,7 @@ __4: (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy = pOrderBy (*WhereInfo)(unsafe.Pointer(pWInfo)).FpWhere = pWhere (*WhereInfo)(unsafe.Pointer(pWInfo)).FpResultSet = pResultSet - *(*int32)(unsafe.Pointer((pWInfo + 40 /* &.aiCurOnePass */) + uintptr(0)*4)) = libc.AssignPtrInt32((pWInfo+40 /* &.aiCurOnePass */)+uintptr(1)*4, -1) + *(*int32)(unsafe.Pointer((pWInfo + 40 /* &.aiCurOnePass */))) = libc.AssignPtrInt32((pWInfo+40 /* &.aiCurOnePass */)+1*4, -1) (*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel = U8(nTabList) (*WhereInfo)(unsafe.Pointer(pWInfo)).FiBreak = libc.AssignPtrInt32(pWInfo+48 /* &.iContinue */, Xsqlite3VdbeMakeLabel(tls, pParse)) (*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags = wctrlFlags @@ -134101,7 +131863,7 @@ __4: (*WhereInfo)(unsafe.Pointer(pWInfo)).FsavedNQueryLoop = int32((*Parse)(unsafe.Pointer(pParse)).FnQueryLoop) libc.Xmemset(tls, (pWInfo + 65 /* &.nOBSat */), 0, ((uint64((uintptr(0) + 104 /* &.sWC */))) - (uint64((uintptr(0) + 65 /* &.nOBSat */))))) - libc.Xmemset(tls, ((pWInfo + 920 /* &.a */) + uintptr(0)*88), 0, (uint64(unsafe.Sizeof(WhereLoop{})) + (uint64(nTabList) * uint64(unsafe.Sizeof(WhereLevel{}))))) + libc.Xmemset(tls, (pWInfo + 920 /* &.a */), 0, (uint64(unsafe.Sizeof(WhereLoop{})) + (uint64(nTabList) * uint64(unsafe.Sizeof(WhereLevel{}))))) // ONEPASS defaults to OFF pMaskSet = (pWInfo + 656 /* &.sMaskSet */) (*WhereLoopBuilder)(unsafe.Pointer(bp + 16 /* &sWLB */)).FpWInfo = pWInfo @@ -134114,7 +131876,7 @@ __4: // subexpression is separated by an AND operator. (*WhereMaskSet)(unsafe.Pointer(pMaskSet)).Fn = 0 Xsqlite3WhereClauseInit(tls, (pWInfo + 104 /* &.sWC */), pWInfo) - Xsqlite3WhereSplit(tls, (pWInfo + 104 /* &.sWC */), pWhere, uint8(44)) + Xsqlite3WhereSplit(tls, (pWInfo + 104 /* &.sWC */), pWhere, TK_AND) // Special case: No FROM clause if !(nTabList == 0) { @@ -134126,10 +131888,10 @@ __4: (*WhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat = I8((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr) __7: ; - if !((int32(wctrlFlags) & 0x0100) != 0) { + if !((int32(wctrlFlags) & WHERE_WANT_DISTINCT) != 0) { goto __8 } - (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(1) + (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = WHERE_DISTINCT_UNIQUE __8: ; Xsqlite3VdbeExplain(tls, pParse, uint8(0), ts+23715 /* "SCAN CONSTANT RO..." */, 0) @@ -134188,7 +131950,7 @@ __13: goto __15 } pT = ((*WhereClause)(unsafe.Pointer((*WhereLoopBuilder)(unsafe.Pointer(bp+16 /* &sWLB */)).FpWC)).Fa + uintptr(ii)*64) - if !((int32((*WhereTerm)(unsafe.Pointer(pT)).FwtFlags) & 0x0002) != 0) { + if !((int32((*WhereTerm)(unsafe.Pointer(pT)).FwtFlags) & TERM_VIRTUAL) != 0) { goto __16 } goto __14 @@ -134197,8 +131959,8 @@ __16: if !(((*WhereTerm)(unsafe.Pointer(pT)).FprereqAll == uint64(0)) && ((nTabList == 0) || (exprIsDeterministic(tls, (*WhereTerm)(unsafe.Pointer(pT)).FpExpr) != 0))) { goto __17 } - Xsqlite3ExprIfFalse(tls, pParse, (*WhereTerm)(unsafe.Pointer(pT)).FpExpr, (*WhereInfo)(unsafe.Pointer(pWInfo)).FiBreak, 0x10) - *(*U16)(unsafe.Pointer(pT + 18 /* &.wtFlags */)) |= U16((0x0004)) + Xsqlite3ExprIfFalse(tls, pParse, (*WhereTerm)(unsafe.Pointer(pT)).FpExpr, (*WhereInfo)(unsafe.Pointer(pWInfo)).FiBreak, SQLITE_JUMPIFNULL) + *(*U16)(unsafe.Pointer(pT + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) __17: ; goto __14 @@ -134209,21 +131971,21 @@ __14: __15: ; - if !((int32(wctrlFlags) & 0x0100) != 0) { + if !((int32(wctrlFlags) & WHERE_WANT_DISTINCT) != 0) { goto __18 } if !(isDistinctRedundant(tls, pParse, pTabList, (pWInfo+104 /* &.sWC */), pResultSet) != 0) { goto __19 } // The DISTINCT marking is pointless. Ignore it. - (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = U8(1) + (*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct = WHERE_DISTINCT_UNIQUE goto __20 __19: if !(pOrderBy == uintptr(0)) { goto __21 } // Try to ORDER BY the result set to make distinct processing easier - *(*U16)(unsafe.Pointer(pWInfo + 60 /* &.wctrlFlags */)) |= U16((0x0080)) + *(*U16)(unsafe.Pointer(pWInfo + 60 /* &.wctrlFlags */)) |= U16((WHERE_DISTINCTBY)) (*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy = pResultSet __21: ; @@ -134250,7 +132012,7 @@ __23: // changed based on STAT4 information while computing subsequent loops, // then we need to rerun the whole loop building process so that all // loops will be built using the revised truthProb values. - if !((int32((*WhereLoopBuilder)(unsafe.Pointer(bp+16 /* &sWLB */)).FbldFlags2) & 0x0004) != 0) { + if !((int32((*WhereLoopBuilder)(unsafe.Pointer(bp+16 /* &sWLB */)).FbldFlags2) & SQLITE_BLDF2_2NDPASS) != 0) { goto __24 } @@ -134295,7 +132057,7 @@ __29: ; __22: ; - if !(((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy == uintptr(0)) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & uint64(0x00001000)) != uint64(0))) { + if !(((*WhereInfo)(unsafe.Pointer(pWInfo)).FpOrderBy == uintptr(0)) && (((*Sqlite3)(unsafe.Pointer(db)).Fflags & SQLITE_ReverseOrder) != uint64(0))) { goto __31 } (*WhereInfo)(unsafe.Pointer(pWInfo)).FrevMask = libc.Uint64(libc.Uint64FromInt32(-1)) @@ -134336,10 +132098,10 @@ __32: // SELECT DISTINCT v1, v3 FROM t1 // LEFT JOIN t2 // LEFT JOIN t3 ON (t1.ipk=t3.ipk) - notReady = ^Bitmask(0) + notReady = libc.CplUint64(uint64(0)) if !(((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) >= 2) && (pResultSet != uintptr(0))) && // guarantees condition (1) above - ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (0x0100)) == 0)) { + ((int32((*Sqlite3)(unsafe.Pointer((db))).FdbOptFlags) & (SQLITE_OmitNoopJoin)) == 0)) { goto __33 } tabUsed = Xsqlite3WhereExprListUsage(tls, pMaskSet, pResultSet) @@ -134356,14 +132118,14 @@ __35: } pLoop = (*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */) + uintptr(i)*88)).FpWLoop pItem = (((*WhereInfo)(unsafe.Pointer(pWInfo)).FpTabList + 8 /* &.a */) + uintptr((*WhereLoop)(unsafe.Pointer(pLoop)).FiTab)*112) - if !((int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & 0x0008) == 0) { + if !((int32((*SrcList_item)(unsafe.Pointer(pItem)).Ffg.Fjointype) & JT_LEFT) == 0) { goto __38 } goto __36 __38: ; - if !(((int32(wctrlFlags) & 0x0100) == 0) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00001000)) == U32(0))) { + if !(((int32(wctrlFlags) & WHERE_WANT_DISTINCT) == 0) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_ONEROW) == U32(0))) { goto __39 } goto __36 @@ -134384,7 +132146,7 @@ __41: if !(((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf) != uint64(0)) { goto __44 } - if !(!(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (U32(0x000001))) != U32(0)) || + if !(!(((*Expr)(unsafe.Pointer(((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr))).Fflags & (EP_FromJoin)) != U32(0)) || (int32((*Expr)(unsafe.Pointer((*WhereTerm)(unsafe.Pointer(pTerm)).FpExpr)).FiRightJoinTable) != (*SrcList_item)(unsafe.Pointer(pItem)).FiCursor)) { goto __45 } @@ -134416,7 +132178,7 @@ __47: if !(((*WhereTerm)(unsafe.Pointer(pTerm)).FprereqAll & (*WhereLoop)(unsafe.Pointer(pLoop)).FmaskSelf) != uint64(0)) { goto __50 } - *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((0x0004)) + *(*U16)(unsafe.Pointer(pTerm + 18 /* &.wtFlags */)) |= U16((TERM_CODED)) __50: ; goto __48 @@ -134465,33 +132227,33 @@ __33: // use a one-pass approach, and this is not set accurately for scans // that use the OR optimization. - if !((int32(wctrlFlags) & 0x0004) != 0) { + if !((int32(wctrlFlags) & WHERE_ONEPASS_DESIRED) != 0) { goto __52 } - wsFlags = int32((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */) + uintptr(0)*88)).FpWLoop)).FwsFlags) - bOnerow = (libc.Bool32((wsFlags & 0x00001000) != 0)) + wsFlags = int32((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */))).FpWLoop)).FwsFlags) + bOnerow = (libc.Bool32((wsFlags & WHERE_ONEROW) != 0)) - if !((bOnerow != 0) || (((0 != (int32(wctrlFlags) & 0x0008)) && - !((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pTabList+8 /* &.a */)+uintptr(0)*112)).FpTab)).FnModuleArg != 0)) && - ((0 == (wsFlags & 0x00002000)) || ((int32(wctrlFlags) & 0x0010) != 0)))) { + if !((bOnerow != 0) || (((0 != (int32(wctrlFlags) & WHERE_ONEPASS_MULTIROW)) && + !((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FpTab)).FnModuleArg != 0)) && + ((0 == (wsFlags & WHERE_MULTI_OR)) || ((int32(wctrlFlags) & WHERE_DUPLICATES_OK) != 0)))) { goto __53 } (*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass = func() uint8 { if bOnerow != 0 { - return uint8(1) + return ONEPASS_SINGLE } - return uint8(2) + return ONEPASS_MULTI }() - if !((((*Table)(unsafe.Pointer(((*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */) + uintptr(0)*112)).FpTab))).FtabFlags & U32(0x0080)) == U32(0)) && ((wsFlags & 0x00000040) != 0)) { + if !((((*Table)(unsafe.Pointer(((*SrcList_item)(unsafe.Pointer((pTabList + 8 /* &.a */))).FpTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((wsFlags & WHERE_IDX_ONLY) != 0)) { goto __54 } - if !((int32(wctrlFlags) & 0x0008) != 0) { + if !((int32(wctrlFlags) & WHERE_ONEPASS_MULTIROW) != 0) { goto __55 } - bFordelete = U8(0x08) + bFordelete = OPFLAG_FORDELETE __55: ; - (*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */) + uintptr(0)*88)).FpWLoop)).FwsFlags = (U32(wsFlags & ^libc.Int32(0x00000040))) + (*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer((pWInfo + 920 /* &.a */))).FpWLoop)).FwsFlags = (U32(wsFlags & libc.CplInt32(WHERE_IDX_ONLY))) __54: ; __53: @@ -134512,18 +132274,18 @@ __56: pTab = (*SrcList_item)(unsafe.Pointer(pTabItem)).FpTab iDb = Xsqlite3SchemaToIndex(tls, db, (*Table)(unsafe.Pointer(pTab)).FpSchema) pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop - if !((((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0002)) != U32(0)) || ((*Table)(unsafe.Pointer(pTab)).FpSelect != 0)) { + if !((((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Ephemeral) != U32(0)) || ((*Table)(unsafe.Pointer(pTab)).FpSelect != 0)) { goto __59 } // Do nothing goto __60 __59: - if !(((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000400)) != U32(0)) { + if !(((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_VIRTUALTABLE) != U32(0)) { goto __61 } pVTab = Xsqlite3GetVTable(tls, db, pTab) iCur = (*SrcList_item)(unsafe.Pointer(pTabItem)).FiCursor - Xsqlite3VdbeAddOp4(tls, v, 165, iCur, 0, 0, pVTab, -12) + Xsqlite3VdbeAddOp4(tls, v, OP_VOpen, iCur, 0, 0, pVTab, -12) goto __62 __61: if !((*Table)(unsafe.Pointer(pTab)).FnModuleArg != 0) { @@ -134532,24 +132294,24 @@ __61: // noop goto __64 __63: - if !((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000040)) == U32(0)) && - ((int32(wctrlFlags) & 0x0020) == 0)) { + if !((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IDX_ONLY) == U32(0)) && + ((int32(wctrlFlags) & WHERE_OR_SUBCLAUSE) == 0)) { goto __65 } - op = 96 - if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != 0) { + op = OP_OpenRead + if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != ONEPASS_OFF) { goto __67 } - op = 97 - *(*int32)(unsafe.Pointer((pWInfo + 40 /* &.aiCurOnePass */) + uintptr(0)*4)) = (*SrcList_item)(unsafe.Pointer(pTabItem)).FiCursor + op = OP_OpenWrite + *(*int32)(unsafe.Pointer((pWInfo + 40 /* &.aiCurOnePass */))) = (*SrcList_item)(unsafe.Pointer(pTabItem)).FiCursor __67: ; Xsqlite3OpenTable(tls, pParse, (*SrcList_item)(unsafe.Pointer(pTabItem)).FiCursor, iDb, pTab, op) - if !(((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == 0) && + if !(((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == ONEPASS_OFF) && (int32((*Table)(unsafe.Pointer(pTab)).FnCol) < (int32(uint64(unsafe.Sizeof(Bitmask(0))) * uint64(8))))) && - (((*Table)(unsafe.Pointer(pTab)).FtabFlags & (U32(0x0060 | 0x0080))) == U32(0))) { + (((*Table)(unsafe.Pointer(pTab)).FtabFlags & (U32(TF_HasGenerated | TF_WithoutRowid))) == U32(0))) { goto __68 } // If we know that only a prefix of the record will be used, @@ -134587,15 +132349,15 @@ __62: ; __60: ; - if !(((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000200)) != 0) { + if !(((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_INDEXED) != 0) { goto __72 } pIx = *(*uintptr)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) - op1 = 96 + op1 = OP_OpenRead // iAuxArg is always set to a positive value if ONEPASS is possible - if !((!(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIx) + 100 /* &.idxType */)) & 0x3 >> 0)) == 2)) && - ((int32(wctrlFlags) & 0x0020) != 0)) { + if !((!(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && ((int32(*(*uint16)(unsafe.Pointer((pIx) + 100 /* &.idxType */)) & 0x3 >> 0)) == SQLITE_IDXTYPE_PRIMARYKEY)) && + ((int32(wctrlFlags) & WHERE_OR_SUBCLAUSE) != 0)) { goto __73 } // This is one term of an OR-optimization using the PRIMARY KEY of a @@ -134604,7 +132366,7 @@ __60: op1 = 0 goto __74 __73: - if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != 0) { + if !(int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) != ONEPASS_OFF) { goto __75 } pJ = (*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(pTabItem)).FpTab)).FpIndex @@ -134619,15 +132381,15 @@ __77: goto __77 __78: ; - op1 = 97 - *(*int32)(unsafe.Pointer((pWInfo + 40 /* &.aiCurOnePass */) + uintptr(1)*4)) = iIndexCur + op1 = OP_OpenWrite + *(*int32)(unsafe.Pointer((pWInfo + 40 /* &.aiCurOnePass */) + 1*4)) = iIndexCur goto __76 __75: - if !((iAuxArg != 0) && ((int32(wctrlFlags) & 0x0020) != 0)) { + if !((iAuxArg != 0) && ((int32(wctrlFlags) & WHERE_OR_SUBCLAUSE) != 0)) { goto __79 } iIndexCur = iAuxArg - op1 = 95 + op1 = OP_ReopenIdx goto __80 __79: iIndexCur = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) @@ -134644,14 +132406,14 @@ __74: } Xsqlite3VdbeAddOp3(tls, v, op1, iIndexCur, int32((*Index)(unsafe.Pointer(pIx)).Ftnum), iDb) Xsqlite3VdbeSetP4KeyInfo(tls, pParse, pIx) - if !(((((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x0000000f)) != U32(0)) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(0x00000002 | 0x00008000))) == U32(0))) && - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00080000)) == U32(0))) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & 0x0001) == 0)) && - (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) != 2)) { + if !(((((((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_CONSTRAINT) != U32(0)) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(WHERE_COLUMN_RANGE | WHERE_SKIPSCAN))) == U32(0))) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_BIGNULL_SORT) == U32(0))) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FwctrlFlags) & WHERE_ORDERBY_MIN) == 0)) && + (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) != WHERE_DISTINCT_ORDERED)) { goto __82 } - Xsqlite3VdbeChangeP5(tls, v, uint16(0x02)) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_SEEKEQ) __82: ; Xsqlite3VdbeComment(tls, v, ts+824 /* "%s" */, libc.VaList(bp+8, (*Index)(unsafe.Pointer(pIx)).FzName)) @@ -134691,7 +132453,7 @@ __85: } pLevel = ((pWInfo + 920 /* &.a */) + uintptr(ii)*88) wsFlags1 = int32((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags) - if !(((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags & U32(0x00004000)) != U32(0)) { + if !(((*WhereLoop1)(unsafe.Pointer((*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop)).FwsFlags & WHERE_AUTO_INDEX) != U32(0)) { goto __88 } constructAutomaticIndex(tls, pParse, (pWInfo + 104 /* &.sWC */), @@ -134709,7 +132471,7 @@ __88: (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBody = Xsqlite3VdbeCurrentAddr(tls, v) notReady = Xsqlite3WhereCodeOneLoopStart(tls, pParse, v, pWInfo, ii, pLevel, notReady) (*WhereInfo)(unsafe.Pointer(pWInfo)).FiContinue = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont - if !(((wsFlags1 & 0x00002000) == 0) && ((int32(wctrlFlags) & 0x0020) == 0)) { + if !(((wsFlags1 & WHERE_MULTI_OR) == 0) && ((int32(wctrlFlags) & WHERE_OR_SUBCLAUSE) == 0)) { goto __90 } _ = addrExplain @@ -134764,13 +132526,13 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * var addr int32 pLevel = ((pWInfo + 920 /* &.a */) + uintptr(i)*88) pLoop = (*WhereLevel)(unsafe.Pointer(pLevel)).FpWLoop - if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) != 173 { + if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) != OP_Noop { var addrSeek int32 = 0 var pIdx uintptr var n int32 - if (((((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == 2) && + if (((((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeDistinct) == WHERE_DISTINCT_ORDERED) && (i == (int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FnLevel) - 1))) && // Ticket [ef9318757b152e3] 2017-10-21 - (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000200)) != U32(0))) && + (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_INDEXED) != U32(0))) && ((uint32(int32(*(*uint16)(unsafe.Pointer((libc.AssignUintptr(&pIdx, *(*uintptr)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)))) + 100 /* &.hasStat1 */)) & 0x80 >> 7))) != 0)) && ((libc.AssignInt32(&n, int32(*(*U16)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 6 /* &.nDistinctCol */))))) > 0)) && (int32(*(*LogEst)(unsafe.Pointer((*Index)(unsafe.Pointer(pIdx)).FaiRowLogEst + uintptr(n)*2))) >= 36) { @@ -134778,17 +132540,17 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * var j int32 var op int32 for j = 0; j < n; j++ { - Xsqlite3VdbeAddOp3(tls, v, 89, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, j, (r1 + j)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, j, (r1 + j)) } *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (n + 1) - if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) == 4 { - op = 22 + if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) == OP_Prev { + op = OP_SeekLT } else { - op = 25 + op = OP_SeekGT } addrSeek = Xsqlite3VdbeAddOp4Int(tls, v, op, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, 0, r1, n) - Xsqlite3VdbeAddOp2(tls, v, 11, 1, (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 1, (*WhereLevel)(unsafe.Pointer(pLevel)).Fp2) } // The common case: Advance to the next row Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont) @@ -134797,7 +132559,7 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * if (*WhereLevel)(unsafe.Pointer(pLevel)).FregBignull != 0 { Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBignull) - Xsqlite3VdbeAddOp2(tls, v, 59, (*WhereLevel)(unsafe.Pointer(pLevel)).FregBignull, ((*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 - 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_DecrJumpZero, (*WhereLevel)(unsafe.Pointer(pLevel)).FregBignull, ((*WhereLevel)(unsafe.Pointer(pLevel)).Fp2 - 1)) } if addrSeek != 0 { @@ -134806,7 +132568,7 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * } else { Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrCont) } - if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000800)) != 0) && (*(*int32)(unsafe.Pointer((pLevel + 56 /* &.u */ /* &.in */) /* &.nIn */)) > 0) { + if (((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_IN_ABLE) != 0) && (*(*int32)(unsafe.Pointer((pLevel + 56 /* &.u */ /* &.in */) /* &.nIn */)) > 0) { var pIn uintptr var j int32 Xsqlite3VdbeResolveLabel(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrNxt) @@ -134818,7 +132580,7 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * } { Xsqlite3VdbeJumpHere(tls, v, ((*InLoop)(unsafe.Pointer(pIn)).FaddrInTop + 1)) - if int32((*InLoop)(unsafe.Pointer(pIn)).FeEndLoopOp) != 173 { + if int32((*InLoop)(unsafe.Pointer(pIn)).FeEndLoopOp) != OP_Noop { if (*InLoop)(unsafe.Pointer(pIn)).FnPrefix != 0 { if (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { @@ -134830,12 +132592,12 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * // return the null-row. So, if the cursor is not open yet, // jump over the OP_Next or OP_Prev instruction about to // be coded. - Xsqlite3VdbeAddOp2(tls, v, 26, (*InLoop)(unsafe.Pointer(pIn)).FiCur, - ((Xsqlite3VdbeCurrentAddr(tls, v) + 2) + (libc.Bool32(((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000400)) == U32(0))))) + Xsqlite3VdbeAddOp2(tls, v, OP_IfNotOpen, (*InLoop)(unsafe.Pointer(pIn)).FiCur, + ((Xsqlite3VdbeCurrentAddr(tls, v) + 2) + (libc.Bool32(((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_VIRTUALTABLE) == U32(0))))) } - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00000400)) == U32(0) { - Xsqlite3VdbeAddOp4Int(tls, v, 27, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_VIRTUALTABLE) == U32(0) { + Xsqlite3VdbeAddOp4Int(tls, v, OP_IfNoHope, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, (Xsqlite3VdbeCurrentAddr(tls, v) + 2), (*InLoop)(unsafe.Pointer(pIn)).FiBase, (*InLoop)(unsafe.Pointer(pIn)).FnPrefix) @@ -134864,18 +132626,18 @@ func Xsqlite3WhereEnd(tls *libc.TLS, pWInfo uintptr) { /* sqlite3.c:150895:21: * } if (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin != 0 { var ws int32 = int32((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags) - addr = Xsqlite3VdbeAddOp1(tls, v, 48, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) + addr = Xsqlite3VdbeAddOp1(tls, v, OP_IfPos, (*WhereLevel)(unsafe.Pointer(pLevel)).FiLeftJoin) - if (ws & 0x00000040) == 0 { + if (ws & WHERE_IDX_ONLY) == 0 { - Xsqlite3VdbeAddOp1(tls, v, 128, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur) + Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur) } - if ((ws & 0x00000200) != 0) || - (((ws & 0x00002000) != 0) && (*(*uintptr)(unsafe.Pointer(pLevel + 56 /* &.u */)) != 0)) { - Xsqlite3VdbeAddOp1(tls, v, 128, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur) + if ((ws & WHERE_INDEXED) != 0) || + (((ws & WHERE_MULTI_OR) != 0) && (*(*uintptr)(unsafe.Pointer(pLevel + 56 /* &.u */)) != 0)) { + Xsqlite3VdbeAddOp1(tls, v, OP_NullRow, (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur) } - if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) == 65 { - Xsqlite3VdbeAddOp2(tls, v, 12, (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst) + if int32((*WhereLevel)(unsafe.Pointer(pLevel)).Fop) == OP_Return { + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*WhereLevel)(unsafe.Pointer(pLevel)).Fp1, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst) } else { Xsqlite3VdbeGoto(tls, v, (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrFirst) } @@ -134924,13 +132686,13 @@ __4: // directly. This loop scans all that code looking for opcodes // that reference the table and converts them into opcodes that // reference the index. - if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(0x00000200 | 0x00000040))) != 0 { + if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & (U32(WHERE_INDEXED | WHERE_IDX_ONLY))) != 0 { pIdx = *(*uintptr)(unsafe.Pointer(pLoop + 24 /* &.u */ /* &.btree */ + 8 /* &.pIndex */)) - } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & U32(0x00002000)) != 0 { + } else if ((*WhereLoop)(unsafe.Pointer(pLoop)).FwsFlags & WHERE_MULTI_OR) != 0 { pIdx = *(*uintptr)(unsafe.Pointer(pLevel + 56 /* &.u */)) } if ((pIdx != 0) && - ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == 0) || !(((*Table)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FpTable))).FtabFlags & U32(0x0080)) == U32(0)))) && + ((int32((*WhereInfo)(unsafe.Pointer(pWInfo)).FeOnePass) == ONEPASS_OFF) || !(((*Table)(unsafe.Pointer(((*Index)(unsafe.Pointer(pIdx)).FpTable))).FtabFlags & TF_WithoutRowid) == U32(0)))) && !(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0) { last = Xsqlite3VdbeCurrentAddr(tls, v) k = (*WhereLevel)(unsafe.Pointer(pLevel)).FaddrBody @@ -134943,11 +132705,11 @@ __4: if (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 != (*WhereLevel)(unsafe.Pointer(pLevel)).FiTabCur { goto __8 } - if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 89) || - (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 88) { + if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column) || + (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Offset) { var x int32 = (*VdbeOp)(unsafe.Pointer(pOp)).Fp2 - if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) { + if !(((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) { var pPk uintptr = Xsqlite3PrimaryKeyIndex(tls, pTab) x = int32(*(*I16)(unsafe.Pointer((*Index)(unsafe.Pointer(pPk)).FaiColumn + uintptr(x)*2))) @@ -134962,11 +132724,11 @@ __4: } - } else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 127 { + } else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Rowid { (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur - (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = U8(134) + (*VdbeOp)(unsafe.Pointer(pOp)).Fopcode = OP_IdxRowid - } else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 21 { + } else if int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_IfNullRow { (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = (*WhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur } @@ -135214,20 +132976,20 @@ func nth_valueStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { if !(p != 0) { goto __1 } - switch Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(1)*8))) { - case 1: + switch Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*8))) { + case SQLITE_INTEGER: goto __3 - case 2: + case SQLITE_FLOAT: goto __4 default: goto __5 } goto __2 __3: - iVal = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(1)*8))) + iVal = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*8))) goto __2 __4: - fVal = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(1)*8))) + fVal = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*8))) if !((float64(I64(fVal))) != fVal) { goto __6 } @@ -135252,7 +133014,7 @@ __7: if !(iVal == (*NthValueCtx)(unsafe.Pointer(p)).FnStep) { goto __8 } - (*NthValueCtx)(unsafe.Pointer(p)).FpValue = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) + (*NthValueCtx)(unsafe.Pointer(p)).FpValue = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg))) if !(!(int32((*NthValueCtx)(unsafe.Pointer(p)).FpValue) != 0)) { goto __9 } @@ -135286,7 +133048,7 @@ func first_valueStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) var p uintptr p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(NthValueCtx{}))) if (p != 0) && ((*NthValueCtx)(unsafe.Pointer(p)).FpValue == uintptr(0)) { - (*NthValueCtx)(unsafe.Pointer(p)).FpValue = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) + (*NthValueCtx)(unsafe.Pointer(p)).FpValue = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg))) if !(int32((*NthValueCtx)(unsafe.Pointer(p)).FpValue) != 0) { Xsqlite3_result_error_nomem(tls, pCtx) } @@ -135415,7 +133177,7 @@ func ntileStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { /* p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(NtileCtx{}))) if p != 0 { if (*NtileCtx)(unsafe.Pointer(p)).FnTotal == int64(0) { - (*NtileCtx)(unsafe.Pointer(p)).FnParam = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) + (*NtileCtx)(unsafe.Pointer(p)).FnParam = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg))) if (*NtileCtx)(unsafe.Pointer(p)).FnParam <= int64(0) { Xsqlite3_result_error(tls, pCtx, ts+23810 /* "argument of ntil..." */, -1) @@ -135468,7 +133230,7 @@ func last_valueStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) p = Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(LastValueCtx{}))) if p != 0 { Xsqlite3_value_free(tls, (*LastValueCtx)(unsafe.Pointer(p)).FpVal) - (*LastValueCtx)(unsafe.Pointer(p)).FpVal = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) + (*LastValueCtx)(unsafe.Pointer(p)).FpVal = Xsqlite3_value_dup(tls, *(*uintptr)(unsafe.Pointer(apArg))) if (*LastValueCtx)(unsafe.Pointer(p)).FpVal == uintptr(0) { Xsqlite3_result_error_nomem(tls, pCtx) } else { @@ -135562,157 +133324,21 @@ func Xsqlite3WindowFunctions(tls *libc.TLS) { /* sqlite3.c:151775:21: */ } var aWindowFuncs = [15]FuncDef{ - { - FnArg: int8(0), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(0), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(3), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(1), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(2), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, - { - FnArg: int8(3), - FfuncFlags: (U32((1 | 0x00010000) | 0)), - FpUserData: uintptr(0), - FpNext: uintptr(0), - FxSFunc: 0, - FxFinalize: 0, - FxValue: 0, - FxInverse: 0, - FzName: 0, Fu: struct{ FpHash uintptr }{}}, -} /* sqlite3.c:151776:18 */ + {FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(3), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(1), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(2), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}, + {FnArg: int8(3), FfuncFlags: (U32((SQLITE_UTF8 | SQLITE_FUNC_WINDOW) | 0)), FxSFunc: 0, FxFinalize: 0, FxValue: 0, FxInverse: 0, FzName: 0}} /* sqlite3.c:151776:18 */ func windowFind(tls *libc.TLS, pParse uintptr, pList uintptr, zName uintptr) uintptr { /* sqlite3.c:151796:15: */ bp := tls.Alloc(8) @@ -135765,58 +133391,26 @@ func Xsqlite3WindowUpdate(tls *libc.TLS, pParse uintptr, pList uintptr, pWin uin } else { Xsqlite3WindowChain(tls, pParse, pWin, pList) } - if ((int32((*Window)(unsafe.Pointer(pWin)).FeFrmType) == 89) && + if ((int32((*Window)(unsafe.Pointer(pWin)).FeFrmType) == TK_RANGE) && (((*Window)(unsafe.Pointer(pWin)).FpStart != 0) || ((*Window)(unsafe.Pointer(pWin)).FpEnd != 0))) && (((*Window)(unsafe.Pointer(pWin)).FpOrderBy == uintptr(0)) || ((*ExprList)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOrderBy)).FnExpr != 1)) { Xsqlite3ErrorMsg(tls, pParse, ts+23972 /* "RANGE with offse..." */, 0) - } else if ((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & U32(0x00010000)) != 0 { + } else if ((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & SQLITE_FUNC_WINDOW) != 0 { var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb if (*Window)(unsafe.Pointer(pWin)).FpFilter != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+24043 /* "FILTER clause ma..." */, 0) } else { *(*[8]WindowUpdate)(unsafe.Pointer(bp /* aUp */)) = [8]WindowUpdate{ - { - FzFunc: uintptr(unsafe.Pointer(&row_numberName)), - FeFrmType: 76, - FeStart: 90, - FeEnd: 85}, - { - FzFunc: uintptr(unsafe.Pointer(&dense_rankName)), - FeFrmType: 89, - FeStart: 90, - FeEnd: 85}, - { - FzFunc: uintptr(unsafe.Pointer(&rankName)), - FeFrmType: 89, - FeStart: 90, - FeEnd: 85}, - { - FzFunc: uintptr(unsafe.Pointer(&percent_rankName)), - FeFrmType: 92, - FeStart: 85, - FeEnd: 90}, - { - FzFunc: uintptr(unsafe.Pointer(&cume_distName)), - FeFrmType: 92, - FeStart: 86, - FeEnd: 90}, - { - FzFunc: uintptr(unsafe.Pointer(&ntileName)), - FeFrmType: 76, - FeStart: 85, - FeEnd: 90}, - { - FzFunc: uintptr(unsafe.Pointer(&leadName)), - FeFrmType: 76, - FeStart: 90, - FeEnd: 90}, - { - FzFunc: uintptr(unsafe.Pointer(&lagName)), - FeFrmType: 76, - FeStart: 90, - FeEnd: 85}, + {FzFunc: uintptr(unsafe.Pointer(&row_numberName)), FeFrmType: TK_ROWS, FeStart: TK_UNBOUNDED, FeEnd: TK_CURRENT}, + {FzFunc: uintptr(unsafe.Pointer(&dense_rankName)), FeFrmType: TK_RANGE, FeStart: TK_UNBOUNDED, FeEnd: TK_CURRENT}, + {FzFunc: uintptr(unsafe.Pointer(&rankName)), FeFrmType: TK_RANGE, FeStart: TK_UNBOUNDED, FeEnd: TK_CURRENT}, + {FzFunc: uintptr(unsafe.Pointer(&percent_rankName)), FeFrmType: TK_GROUPS, FeStart: TK_CURRENT, FeEnd: TK_UNBOUNDED}, + {FzFunc: uintptr(unsafe.Pointer(&cume_distName)), FeFrmType: TK_GROUPS, FeStart: TK_FOLLOWING, FeEnd: TK_UNBOUNDED}, + {FzFunc: uintptr(unsafe.Pointer(&ntileName)), FeFrmType: TK_ROWS, FeStart: TK_CURRENT, FeEnd: TK_UNBOUNDED}, + {FzFunc: uintptr(unsafe.Pointer(&leadName)), FeFrmType: TK_ROWS, FeStart: TK_UNBOUNDED, FeEnd: TK_UNBOUNDED}, + {FzFunc: uintptr(unsafe.Pointer(&lagName)), FeFrmType: TK_ROWS, FeStart: TK_UNBOUNDED, FeEnd: TK_CURRENT}, } var i int32 for i = 0; i < (int32(uint64(unsafe.Sizeof([8]WindowUpdate{})) / uint64(unsafe.Sizeof(WindowUpdate{})))); i++ { @@ -135828,8 +133422,8 @@ func Xsqlite3WindowUpdate(tls *libc.TLS, pParse uintptr, pList uintptr, pWin uin (*Window)(unsafe.Pointer(pWin)).FeStart = U8((*WindowUpdate)(unsafe.Pointer(bp /* &aUp */ + uintptr(i)*24)).FeStart) (*Window)(unsafe.Pointer(pWin)).FeEnd = U8((*WindowUpdate)(unsafe.Pointer(bp /* &aUp */ + uintptr(i)*24)).FeEnd) (*Window)(unsafe.Pointer(pWin)).FeExclude = U8(0) - if int32((*Window)(unsafe.Pointer(pWin)).FeStart) == 86 { - (*Window)(unsafe.Pointer(pWin)).FpStart = Xsqlite3Expr(tls, db, 152, ts+9901 /* "1" */) + if int32((*Window)(unsafe.Pointer(pWin)).FeStart) == TK_FOLLOWING { + (*Window)(unsafe.Pointer(pWin)).FpStart = Xsqlite3Expr(tls, db, TK_INTEGER, ts+9901 /* "1" */) } break } @@ -135864,8 +133458,8 @@ func selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) in // not process aggregates or window functions at all, as they belong // to the scalar sub-select. if (*WindowRewrite1)(unsafe.Pointer(p)).FpSubSelect != 0 { - if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != 164 { - return 0 + if int32((*Expr)(unsafe.Pointer(pExpr)).Fop) != TK_COLUMN { + return WRC_Continue } else { var nSrc int32 = (*SrcList)(unsafe.Pointer((*WindowRewrite1)(unsafe.Pointer(p)).FpSrc)).FnSrc var i int32 @@ -135875,31 +133469,30 @@ func selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) in } } if i == nSrc { - return 0 + return WRC_Continue } } } switch int32((*Expr)(unsafe.Pointer(pExpr)).Fop) { - case 169: - if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (U32(0x1000000))) != U32(0)) { + case TK_FUNCTION: + if !(((*Expr)(unsafe.Pointer((pExpr))).Fflags & (EP_WinFunc)) != U32(0)) { break } else { var pWin uintptr for pWin = (*WindowRewrite1)(unsafe.Pointer(p)).FpWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { if *(*uintptr)(unsafe.Pointer(pExpr + 64 /* &.y */)) == pWin { - return 1 + return WRC_Prune } } } - /* no break */ fallthrough - case 165: + case TK_AGG_FUNCTION: fallthrough - case 164: + case TK_COLUMN: { var iCol int32 = -1 if (*WindowRewrite1)(unsafe.Pointer(p)).FpSub != 0 { @@ -135913,20 +133506,20 @@ func selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) in } if iCol < 0 { var pDup uintptr = Xsqlite3ExprDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0) - if (pDup != 0) && (int32((*Expr)(unsafe.Pointer(pDup)).Fop) == 165) { - (*Expr)(unsafe.Pointer(pDup)).Fop = U8(169) + if (pDup != 0) && (int32((*Expr)(unsafe.Pointer(pDup)).Fop) == TK_AGG_FUNCTION) { + (*Expr)(unsafe.Pointer(pDup)).Fop = TK_FUNCTION } (*WindowRewrite1)(unsafe.Pointer(p)).FpSub = Xsqlite3ExprListAppend(tls, pParse, (*WindowRewrite1)(unsafe.Pointer(p)).FpSub, pDup) } if (*WindowRewrite1)(unsafe.Pointer(p)).FpSub != 0 { - var f int32 = (int32((*Expr)(unsafe.Pointer(pExpr)).Fflags & U32(0x000100))) + var f int32 = (int32((*Expr)(unsafe.Pointer(pExpr)).Fflags & EP_Collate)) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (U32(0x8000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) |= (EP_Static) Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr) - *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(0x8000000)) + *(*U32)(unsafe.Pointer(pExpr + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(EP_Static))) libc.Xmemset(tls, pExpr, 0, uint64(unsafe.Sizeof(Expr{}))) - (*Expr)(unsafe.Pointer(pExpr)).Fop = U8(164) + (*Expr)(unsafe.Pointer(pExpr)).Fop = TK_COLUMN (*Expr)(unsafe.Pointer(pExpr)).FiColumn = func() int16 { if iCol < 0 { return (int16((*ExprList)(unsafe.Pointer((*WindowRewrite1)(unsafe.Pointer(p)).FpSub)).FnExpr - 1)) @@ -135938,7 +133531,7 @@ func selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) in (*Expr)(unsafe.Pointer(pExpr)).Fflags = U32(f) } if (*Sqlite3)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { - return 2 + return WRC_Abort } break @@ -135948,20 +133541,20 @@ func selectWindowRewriteExprCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) in break } - return 0 + return WRC_Continue } func selectWindowRewriteSelectCb(tls *libc.TLS, pWalker uintptr, pSelect uintptr) int32 { /* sqlite3.c:151994:12: */ var p uintptr = *(*uintptr)(unsafe.Pointer(pWalker + 40 /* &.u */)) var pSave uintptr = (*WindowRewrite1)(unsafe.Pointer(p)).FpSubSelect if pSave == pSelect { - return 0 + return WRC_Continue } else { (*WindowRewrite1)(unsafe.Pointer(p)).FpSubSelect = pSelect Xsqlite3WalkSelect(tls, pWalker, pSelect) (*WindowRewrite1)(unsafe.Pointer(p)).FpSubSelect = pSave } - return 1 + return WRC_Prune } // Iterate through each expression in expression-list pEList. For each: @@ -136026,12 +133619,12 @@ func exprListAppendList(tls *libc.TLS, pParse uintptr, pList uintptr, pAppend ui // var iDummy int32 at bp, 4 var pSub uintptr - for pSub = pDup; ((*Expr)(unsafe.Pointer((pSub))).Fflags & (U32(0x001000))) != U32(0); pSub = (*Expr)(unsafe.Pointer(pSub)).FpLeft { + for pSub = pDup; ((*Expr)(unsafe.Pointer((pSub))).Fflags & (EP_Skip)) != U32(0); pSub = (*Expr)(unsafe.Pointer(pSub)).FpLeft { } if Xsqlite3ExprIsInteger(tls, pSub, bp /* &iDummy */) != 0 { - (*Expr)(unsafe.Pointer(pSub)).Fop = U8(119) - *(*U32)(unsafe.Pointer(pSub + 4 /* &.flags */)) &= (^libc.Uint32FromInt32(((0x000400 | 0x10000000) | 0x20000000))) + (*Expr)(unsafe.Pointer(pSub)).Fop = TK_NULL + *(*U32)(unsafe.Pointer(pSub + 4 /* &.flags */)) &= (libc.Uint32FromInt32(libc.CplInt32(((EP_IntValue | EP_IsTrue) | EP_IsFalse)))) *(*uintptr)(unsafe.Pointer(pSub + 8 /* &.u */)) = uintptr(0) } } @@ -136051,11 +133644,11 @@ func exprListAppendList(tls *libc.TLS, pParse uintptr, pList uintptr, pAppend ui // // See also the incrAggDepth() routine in resolve.c func sqlite3WindowExtraAggFuncDepth(tls *libc.TLS, pWalker uintptr, pExpr uintptr) int32 { /* sqlite3.c:152094:12: */ - if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == 165) && + if (int32((*Expr)(unsafe.Pointer(pExpr)).Fop) == TK_AGG_FUNCTION) && (int32((*Expr)(unsafe.Pointer(pExpr)).Fop2) >= (*Walker)(unsafe.Pointer(pWalker)).FwalkerDepth) { (*Expr)(unsafe.Pointer(pExpr)).Fop2++ } - return 0 + return WRC_Continue } // If the SELECT statement passed as the second argument does not invoke @@ -136067,8 +133660,8 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* bp := tls.Alloc(56) defer tls.Free(56) - var rc int32 = 0 - if (((*Select)(unsafe.Pointer(p)).FpWin != 0) && ((*Select)(unsafe.Pointer(p)).FpPrior == uintptr(0))) && (((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0100000)) == U32(0)) { + var rc int32 = SQLITE_OK + if (((*Select)(unsafe.Pointer(p)).FpWin != 0) && ((*Select)(unsafe.Pointer(p)).FpPrior == uintptr(0))) && (((*Select)(unsafe.Pointer(p)).FselFlags & SF_WinRewrite) == U32(0)) { var v uintptr = Xsqlite3GetVdbe(tls, pParse) var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb var pSub uintptr = uintptr(0) // The subquery @@ -136088,7 +133681,7 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* pTab = Xsqlite3DbMallocZero(tls, db, uint64(unsafe.Sizeof(Table{}))) if pTab == uintptr(0) { - return Xsqlite3ErrorToParser(tls, db, 7) + return Xsqlite3ErrorToParser(tls, db, SQLITE_NOMEM) } Xsqlite3AggInfoPersistWalkerInit(tls, bp /* &w */, pParse) Xsqlite3WalkSelect(tls, bp /* &w */, p) @@ -136097,8 +133690,8 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* (*Select)(unsafe.Pointer(p)).FpWhere = uintptr(0) (*Select)(unsafe.Pointer(p)).FpGroupBy = uintptr(0) (*Select)(unsafe.Pointer(p)).FpHaving = uintptr(0) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000008)) - *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (U32(0x0100000)) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_Aggregate))) + *(*U32)(unsafe.Pointer(p + 4 /* &.selFlags */)) |= (SF_WinRewrite) // Create the ORDER BY clause for the sub-select. This is the concatenation // of the window PARTITION and ORDER BY clauses. Then, if this makes it @@ -136142,7 +133735,7 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* // results. for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { var pArgs uintptr = *(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 32 /* &.x */)) - if ((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpFunc)).FfuncFlags & U32(0x00100000)) != 0 { + if ((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpFunc)).FfuncFlags & SQLITE_FUNC_SUBTYPE) != 0 { selectWindowRewriteEList(tls, pParse, pMWin, pSrc, pArgs, pTab, bp+48 /* &pSublist */) (*Window)(unsafe.Pointer(pWin)).FiArgCol = func() int32 { if *(*uintptr)(unsafe.Pointer(bp + 48 /* pSublist */)) != 0 { @@ -136166,7 +133759,7 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* } (*Window)(unsafe.Pointer(pWin)).FregAccum = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) (*Window)(unsafe.Pointer(pWin)).FregResult = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) } // If there is no ORDER BY or PARTITION BY clause, and the window @@ -136176,7 +133769,7 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* // keep everything legal in this case. if *(*uintptr)(unsafe.Pointer(bp + 48 /* pSublist */)) == uintptr(0) { *(*uintptr)(unsafe.Pointer(bp + 48 /* pSublist */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), - Xsqlite3Expr(tls, db, 152, ts+9370 /* "0" */)) + Xsqlite3Expr(tls, db, TK_INTEGER, ts+9370 /* "0" */)) } pSub = Xsqlite3SelectNew(tls, @@ -136185,20 +133778,20 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* (*Select)(unsafe.Pointer(p)).FpSrc = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) if (*Select)(unsafe.Pointer(p)).FpSrc != 0 { var pTab2 uintptr - (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpSelect = pSub + (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpSelect = pSub Xsqlite3SrcListAssignCursors(tls, pParse, (*Select)(unsafe.Pointer(p)).FpSrc) - *(*U32)(unsafe.Pointer(pSub + 4 /* &.selFlags */)) |= (U32(0x0000040)) - pTab2 = Xsqlite3ResultSetOfSelect(tls, pParse, pSub, int8(0x40)) - *(*U32)(unsafe.Pointer(pSub + 4 /* &.selFlags */)) |= (selFlags & U32(0x0000008)) + *(*U32)(unsafe.Pointer(pSub + 4 /* &.selFlags */)) |= (SF_Expanded) + pTab2 = Xsqlite3ResultSetOfSelect(tls, pParse, pSub, SQLITE_AFF_NONE) + *(*U32)(unsafe.Pointer(pSub + 4 /* &.selFlags */)) |= (selFlags & SF_Aggregate) if pTab2 == uintptr(0) { // Might actually be some other kind of error, but in that case // pParse->nErr will be set, so if SQLITE_NOMEM is set, we will get // the correct error message regardless. - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemcpy(tls, pTab, pTab2, uint64(unsafe.Sizeof(Table{}))) - *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (U32(0x0002)) - (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab = pTab + *(*U32)(unsafe.Pointer(pTab + 64 /* &.tabFlags */)) |= (TF_Ephemeral) + (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpTab = pTab pTab = pTab2 libc.Xmemset(tls, bp /* &w */, 0, uint64(unsafe.Sizeof(Walker{}))) (*Walker)(unsafe.Pointer(bp /* &w */)).FxExprCallback = *(*uintptr)(unsafe.Pointer(&struct { @@ -136216,7 +133809,7 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* Xsqlite3SelectDelete(tls, db, pSub) } if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3DbFree(tls, db, pTab) } @@ -136224,7 +133817,7 @@ func Xsqlite3WindowRewrite(tls *libc.TLS, pParse uintptr, p uintptr) int32 { /* if rc != 0 { if (*Parse)(unsafe.Pointer(pParse)).FnErr == 0 { - Xsqlite3ErrorToParser(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 7) + Xsqlite3ErrorToParser(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, SQLITE_NOMEM) } } return rc @@ -136273,11 +133866,11 @@ func Xsqlite3WindowListDelete(tls *libc.TLS, db uintptr, p uintptr) { /* sqlite3 // variable values in the expression tree. func sqlite3WindowOffsetExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr) uintptr { /* sqlite3.c:152303:13: */ if 0 == Xsqlite3ExprIsConstant(tls, pExpr) { - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { Xsqlite3RenameExprUnmap(tls, pParse, pExpr) } Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pExpr) - pExpr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 119, uintptr(0), 0) + pExpr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_NULL, uintptr(0), 0) } return pExpr } @@ -136295,7 +133888,7 @@ func Xsqlite3WindowAlloc(tls *libc.TLS, pParse uintptr, eType int32, eStart int3 goto __1 } bImplicitFrame = 1 - eType = 89 + eType = TK_RANGE __1: ; @@ -136312,8 +133905,8 @@ __1: // The parser ensures that "UNBOUNDED PRECEDING" cannot be used as an ending // boundary, and than "UNBOUNDED FOLLOWING" cannot be used as a starting // frame boundary. - if !(((eStart == 85) && (eEnd == 88)) || - ((eStart == 86) && ((eEnd == 88) || (eEnd == 85)))) { + if !(((eStart == TK_CURRENT) && (eEnd == TK_PRECEDING)) || + ((eStart == TK_FOLLOWING) && ((eEnd == TK_PRECEDING) || (eEnd == TK_CURRENT)))) { goto __2 } Xsqlite3ErrorMsg(tls, pParse, ts+24106 /* "unsupported fram..." */, 0) @@ -136331,10 +133924,10 @@ __3: (*Window)(unsafe.Pointer(pWin)).FeFrmType = U8(eType) (*Window)(unsafe.Pointer(pWin)).FeStart = U8(eStart) (*Window)(unsafe.Pointer(pWin)).FeEnd = U8(eEnd) - if !((int32(eExclude) == 0) && ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (0x0002)) != 0)) { + if !((int32(eExclude) == 0) && ((int32((*Sqlite3)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb))).FdbOptFlags) & (SQLITE_WindowFunc)) != 0)) { goto __4 } - eExclude = U8(66) + eExclude = TK_NO __4: ; (*Window)(unsafe.Pointer(pWin)).FeExclude = eExclude @@ -136409,9 +134002,9 @@ func Xsqlite3WindowAttach(tls *libc.TLS, pParse uintptr, p uintptr, pWin uintptr if p != 0 { *(*uintptr)(unsafe.Pointer(p + 64 /* &.y */)) = pWin - *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= (U32(0x1000000)) + *(*U32)(unsafe.Pointer(p + 4 /* &.flags */)) |= (EP_WinFunc) (*Window)(unsafe.Pointer(pWin)).FpOwner = p - if (((*Expr)(unsafe.Pointer(p)).Fflags & U32(0x000002)) != 0) && (int32((*Window)(unsafe.Pointer(pWin)).FeFrmType) != 163) { + if (((*Expr)(unsafe.Pointer(p)).Fflags & EP_Distinct) != 0) && (int32((*Window)(unsafe.Pointer(pWin)).FeFrmType) != TK_FILTER) { Xsqlite3ErrorMsg(tls, pParse, ts+24224 /* "DISTINCT is not ..." */, 0) } @@ -136480,15 +134073,15 @@ func Xsqlite3WindowCompare(tls *libc.TLS, pParse uintptr, p1 uintptr, p2 uintptr // to begin iterating through the sub-query results. It is used to allocate // and initialize registers and cursors used by sqlite3WindowCodeStep(). func Xsqlite3WindowCodeInit(tls *libc.TLS, pParse uintptr, pSelect uintptr) { /* sqlite3.c:152518:21: */ - var nEphExpr int32 = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pSelect)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpSelect)).FpEList)).FnExpr + var nEphExpr int32 = (*ExprList)(unsafe.Pointer((*Select)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(pSelect)).FpSrc + 8 /* &.a */))).FpSelect)).FpEList)).FnExpr var pMWin uintptr = (*Select)(unsafe.Pointer(pSelect)).FpWin var pWin uintptr var v uintptr = Xsqlite3GetVdbe(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 100, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, nEphExpr) - Xsqlite3VdbeAddOp2(tls, v, 98, ((*Window)(unsafe.Pointer(pMWin)).FiEphCsr + 1), (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) - Xsqlite3VdbeAddOp2(tls, v, 98, ((*Window)(unsafe.Pointer(pMWin)).FiEphCsr + 2), (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) - Xsqlite3VdbeAddOp2(tls, v, 98, ((*Window)(unsafe.Pointer(pMWin)).FiEphCsr + 3), (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, nEphExpr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, ((*Window)(unsafe.Pointer(pMWin)).FiEphCsr + 1), (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, ((*Window)(unsafe.Pointer(pMWin)).FiEphCsr + 2), (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, ((*Window)(unsafe.Pointer(pMWin)).FiEphCsr + 3), (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) // Allocate registers to use for PARTITION BY values, if any. Initialize // said registers to NULL. @@ -136496,25 +134089,25 @@ func Xsqlite3WindowCodeInit(tls *libc.TLS, pParse uintptr, pSelect uintptr) { /* var nExpr int32 = (*ExprList)(unsafe.Pointer((*Window)(unsafe.Pointer(pMWin)).FpPartition)).FnExpr (*Window)(unsafe.Pointer(pMWin)).FregPart = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (nExpr) - Xsqlite3VdbeAddOp3(tls, v, 72, 0, (*Window)(unsafe.Pointer(pMWin)).FregPart, (((*Window)(unsafe.Pointer(pMWin)).FregPart + nExpr) - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pMWin)).FregPart, (((*Window)(unsafe.Pointer(pMWin)).FregPart + nExpr) - 1)) } (*Window)(unsafe.Pointer(pMWin)).FregOne = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, (*Window)(unsafe.Pointer(pMWin)).FregOne) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, (*Window)(unsafe.Pointer(pMWin)).FregOne) if (*Window)(unsafe.Pointer(pMWin)).FeExclude != 0 { (*Window)(unsafe.Pointer(pMWin)).FregStartRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) (*Window)(unsafe.Pointer(pMWin)).FregEndRowid = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) (*Window)(unsafe.Pointer(pMWin)).FcsrApp = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - Xsqlite3VdbeAddOp2(tls, v, 69, 1, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid) - Xsqlite3VdbeAddOp2(tls, v, 98, (*Window)(unsafe.Pointer(pMWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*Window)(unsafe.Pointer(pMWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) return } for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { var p uintptr = (*Window)(unsafe.Pointer(pWin)).FpFunc - if (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & U32(0x1000)) != 0) && (int32((*Window)(unsafe.Pointer(pWin)).FeStart) != 90) { + if (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & SQLITE_FUNC_MINMAX) != 0) && (int32((*Window)(unsafe.Pointer(pWin)).FeStart) != TK_UNBOUNDED) { // The inline versions of min() and max() require a single ephemeral // table and 3 registers. The registers are used as follows: // @@ -136526,23 +134119,23 @@ func Xsqlite3WindowCodeInit(tls *libc.TLS, pParse uintptr, pSelect uintptr) { /* (*Window)(unsafe.Pointer(pWin)).FcsrApp = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) (*Window)(unsafe.Pointer(pWin)).FregApp = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (3) - if (pKeyInfo != 0) && (int32(*(*int8)(unsafe.Pointer((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpFunc)).FzName + uintptr(1)))) == 'i') { + if (pKeyInfo != 0) && (int32(*(*int8)(unsafe.Pointer((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpFunc)).FzName + 1))) == 'i') { - *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(0))) = U8(0x01) + *(*U8)(unsafe.Pointer((*KeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags)) = KEYINFO_ORDER_DESC } - Xsqlite3VdbeAddOp2(tls, v, 100, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 2) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenEphemeral, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 2) Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -9) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1)) } else if ((*FuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&nth_valueName))) || ((*FuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&first_valueName))) { // Allocate two registers at pWin->regApp. These will be used to // store the start and end index of the current frame. (*Window)(unsafe.Pointer(pWin)).FregApp = ((*Parse)(unsafe.Pointer(pParse)).FnMem + 1) (*Window)(unsafe.Pointer(pWin)).FcsrApp = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) *(*int32)(unsafe.Pointer(pParse + 56 /* &.nMem */)) += (2) - Xsqlite3VdbeAddOp2(tls, v, 98, (*Window)(unsafe.Pointer(pWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*Window)(unsafe.Pointer(pWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) } else if ((*FuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&leadName))) || ((*FuncDef)(unsafe.Pointer(p)).FzName == uintptr(unsafe.Pointer(&lagName))) { (*Window)(unsafe.Pointer(pWin)).FcsrApp = libc.PostIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnTab, 1) - Xsqlite3VdbeAddOp2(tls, v, 98, (*Window)(unsafe.Pointer(pWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) + Xsqlite3VdbeAddOp2(tls, v, OP_OpenDup, (*Window)(unsafe.Pointer(pWin)).FcsrApp, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr) } } } @@ -136556,15 +134149,15 @@ func windowCheckValue(tls *libc.TLS, pParse uintptr, reg int32, eCond int32) { / var v uintptr = Xsqlite3GetVdbe(tls, pParse) var regZero int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, regZero) - if eCond >= 3 { + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regZero) + if eCond >= WINDOW_STARTING_NUM { var regString int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp4(tls, v, 115, 0, regString, 0, ts+800 /* "" */, -1) - Xsqlite3VdbeAddOp3(tls, v, 57, regString, (Xsqlite3VdbeCurrentAddr(tls, v) + 2), reg) - Xsqlite3VdbeChangeP5(tls, v, (uint16(0x43 | 0x10))) + Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, regString, 0, ts+800 /* "" */, -1) + Xsqlite3VdbeAddOp3(tls, v, OP_Ge, regString, (Xsqlite3VdbeCurrentAddr(tls, v) + 2), reg) + Xsqlite3VdbeChangeP5(tls, v, (uint16(SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL))) } else { - Xsqlite3VdbeAddOp2(tls, v, 15, reg, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_MustBeInt, reg, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) } Xsqlite3VdbeAddOp3(tls, v, aOp1[eCond], regZero, (Xsqlite3VdbeCurrentAddr(tls, v) + 2), reg) @@ -136574,7 +134167,7 @@ func windowCheckValue(tls *libc.TLS, pParse uintptr, reg int32, eCond int32) { / // NULL case caught by // the OP_Ge Xsqlite3MayAbort(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 68, 1, 2) + Xsqlite3VdbeAddOp2(tls, v, OP_Halt, SQLITE_ERROR, OE_Abort) Xsqlite3VdbeAppendP4(tls, v, azErr[eCond], -1) Xsqlite3ReleaseTempReg(tls, pParse, regZero) } @@ -136585,8 +134178,8 @@ var azErr = [5]uintptr{ ts + 23754, /* "second argument ..." */ ts + 24375, /* "frame starting o..." */ ts + 24427, /* "frame ending off..." */ -} /* sqlite3.c:152603:21 */ -var aOp1 = [5]int32{57, 57, 54, 57, 57} /* sqlite3.c:152610:14 */ +} /* sqlite3.c:152603:21 */ +var aOp1 = [5]int32{OP_Ge, OP_Ge, OP_Gt, OP_Ge, OP_Ge} /* sqlite3.c:152610:14 */ // Return the number of arguments passed to the window-function associated // with the object passed as the only argument to this function. @@ -136637,7 +134230,7 @@ func windowReadPeerValues(tls *libc.TLS, p uintptr, csr int32, reg int32) { /* s }())) var i int32 for i = 0; i < (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr; i++ { - Xsqlite3VdbeAddOp3(tls, v, 89, csr, (iColOff + i), (reg + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, (iColOff + i), (reg + i)) } } } @@ -136679,33 +134272,33 @@ func windowAggStep(tls *libc.TLS, p uintptr, pMWin uintptr, csr int32, bInverse for i = 0; i < nArg; i++ { if (i != 1) || ((*FuncDef)(unsafe.Pointer(pFunc)).FzName != uintptr(unsafe.Pointer(&nth_valueName))) { - Xsqlite3VdbeAddOp3(tls, v, 89, csr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + i), (reg + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + i), (reg + i)) } else { - Xsqlite3VdbeAddOp3(tls, v, 89, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + i), (reg + i)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + i), (reg + i)) } } regArg = reg if (((*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0) && - (((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & U32(0x1000)) != 0)) && - (int32((*Window)(unsafe.Pointer(pWin)).FeStart) != 90) { - var addrIsNull int32 = Xsqlite3VdbeAddOp1(tls, v, 50, regArg) + (((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & SQLITE_FUNC_MINMAX) != 0)) && + (int32((*Window)(unsafe.Pointer(pWin)).FeStart) != TK_UNBOUNDED) { + var addrIsNull int32 = Xsqlite3VdbeAddOp1(tls, v, OP_IsNull, regArg) if bInverse == 0 { - Xsqlite3VdbeAddOp2(tls, v, 82, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1), 1) - Xsqlite3VdbeAddOp2(tls, v, 78, regArg, (*Window)(unsafe.Pointer(pWin)).FregApp) - Xsqlite3VdbeAddOp3(tls, v, 91, (*Window)(unsafe.Pointer(pWin)).FregApp, 2, ((*Window)(unsafe.Pointer(pWin)).FregApp + 2)) - Xsqlite3VdbeAddOp2(tls, v, 130, (*Window)(unsafe.Pointer(pWin)).FcsrApp, ((*Window)(unsafe.Pointer(pWin)).FregApp + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1), 1) + Xsqlite3VdbeAddOp2(tls, v, OP_SCopy, regArg, (*Window)(unsafe.Pointer(pWin)).FregApp) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, (*Window)(unsafe.Pointer(pWin)).FregApp, 2, ((*Window)(unsafe.Pointer(pWin)).FregApp + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_IdxInsert, (*Window)(unsafe.Pointer(pWin)).FcsrApp, ((*Window)(unsafe.Pointer(pWin)).FregApp + 2)) } else { - Xsqlite3VdbeAddOp4Int(tls, v, 24, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 0, regArg, 1) + Xsqlite3VdbeAddOp4Int(tls, v, OP_SeekGE, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 0, regArg, 1) - Xsqlite3VdbeAddOp1(tls, v, 122, (*Window)(unsafe.Pointer(pWin)).FcsrApp) + Xsqlite3VdbeAddOp1(tls, v, OP_Delete, (*Window)(unsafe.Pointer(pWin)).FcsrApp) Xsqlite3VdbeJumpHere(tls, v, (Xsqlite3VdbeCurrentAddr(tls, v) - 2)) } Xsqlite3VdbeJumpHere(tls, v, addrIsNull) } else if (*Window)(unsafe.Pointer(pWin)).FregApp != 0 { - Xsqlite3VdbeAddOp2(tls, v, 82, (((*Window)(unsafe.Pointer(pWin)).FregApp + 1) - bInverse), 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (((*Window)(unsafe.Pointer(pWin)).FregApp + 1) - bInverse), 1) } else if (*FuncDef)(unsafe.Pointer(pFunc)).FxSFunc != *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{noopStepFunc})) { @@ -136714,8 +134307,8 @@ func windowAggStep(tls *libc.TLS, p uintptr, pMWin uintptr, csr int32, bInverse var regTmp int32 regTmp = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 89, csr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + nArg), regTmp) - addrIf = Xsqlite3VdbeAddOp3(tls, v, 20, regTmp, 0, 1) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + nArg), regTmp) + addrIf = Xsqlite3VdbeAddOp3(tls, v, OP_IfNot, regTmp, 0, 1) Xsqlite3ReleaseTempReg(tls, pParse, regTmp) } @@ -136731,22 +134324,22 @@ func windowAggStep(tls *libc.TLS, p uintptr, pMWin uintptr, csr int32, bInverse pEnd = Xsqlite3VdbeGetOp(tls, v, -1) for pOp = Xsqlite3VdbeGetOp(tls, v, iStart); pOp <= pEnd; pOp += 32 { - if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == 89) && ((*VdbeOp)(unsafe.Pointer(pOp)).Fp1 == (*Window)(unsafe.Pointer(pWin)).FiEphCsr) { + if (int32((*VdbeOp)(unsafe.Pointer(pOp)).Fopcode) == OP_Column) && ((*VdbeOp)(unsafe.Pointer(pOp)).Fp1 == (*Window)(unsafe.Pointer(pWin)).FiEphCsr) { (*VdbeOp)(unsafe.Pointer(pOp)).Fp1 = csr } } } - if ((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & U32(0x0020)) != 0 { + if ((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & SQLITE_FUNC_NEEDCOLL) != 0 { var pColl uintptr - pColl = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 32 /* &.x */))+8 /* &.a */)+uintptr(0)*32)).FpExpr) - Xsqlite3VdbeAddOp4(tls, v, 81, 0, 0, 0, pColl, -2) + pColl = Xsqlite3ExprNNCollSeq(tls, pParse, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpOwner + 32 /* &.x */)) + 8 /* &.a */))).FpExpr) + Xsqlite3VdbeAddOp4(tls, v, OP_CollSeq, 0, 0, 0, pColl, -2) } Xsqlite3VdbeAddOp3(tls, v, func() int32 { if bInverse != 0 { - return 153 + return OP_AggInverse } - return 154 + return OP_AggStep }(), bInverse, regArg, (*Window)(unsafe.Pointer(pWin)).FregAccum) Xsqlite3VdbeAppendP4(tls, v, pFunc, -8) @@ -136775,24 +134368,24 @@ func windowAggFinal(tls *libc.TLS, p uintptr, bFin int32) { /* sqlite3.c:152888: for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { if (((*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0) && - (((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpFunc)).FfuncFlags & U32(0x1000)) != 0)) && - (int32((*Window)(unsafe.Pointer(pWin)).FeStart) != 90) { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) - Xsqlite3VdbeAddOp1(tls, v, 33, (*Window)(unsafe.Pointer(pWin)).FcsrApp) + (((*FuncDef)(unsafe.Pointer((*Window)(unsafe.Pointer(pWin)).FpFunc)).FfuncFlags & SQLITE_FUNC_MINMAX) != 0)) && + (int32((*Window)(unsafe.Pointer(pWin)).FeStart) != TK_UNBOUNDED) { + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp1(tls, v, OP_Last, (*Window)(unsafe.Pointer(pWin)).FcsrApp) - Xsqlite3VdbeAddOp3(tls, v, 89, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*Window)(unsafe.Pointer(pWin)).FcsrApp, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) Xsqlite3VdbeJumpHere(tls, v, (Xsqlite3VdbeCurrentAddr(tls, v) - 2)) } else if (*Window)(unsafe.Pointer(pWin)).FregApp != 0 { } else { var nArg int32 = windowArgCount(tls, pWin) if bFin != 0 { - Xsqlite3VdbeAddOp2(tls, v, 157, (*Window)(unsafe.Pointer(pWin)).FregAccum, nArg) + Xsqlite3VdbeAddOp2(tls, v, OP_AggFinal, (*Window)(unsafe.Pointer(pWin)).FregAccum, nArg) Xsqlite3VdbeAppendP4(tls, v, (*Window)(unsafe.Pointer(pWin)).FpFunc, -8) - Xsqlite3VdbeAddOp2(tls, v, 77, (*Window)(unsafe.Pointer(pWin)).FregAccum, (*Window)(unsafe.Pointer(pWin)).FregResult) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) + Xsqlite3VdbeAddOp2(tls, v, OP_Copy, (*Window)(unsafe.Pointer(pWin)).FregAccum, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) } else { - Xsqlite3VdbeAddOp3(tls, v, 156, (*Window)(unsafe.Pointer(pWin)).FregAccum, nArg, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp3(tls, v, OP_AggValue, (*Window)(unsafe.Pointer(pWin)).FregAccum, nArg, (*Window)(unsafe.Pointer(pWin)).FregResult) Xsqlite3VdbeAppendP4(tls, v, (*Window)(unsafe.Pointer(pWin)).FpFunc, -8) } } @@ -136838,23 +134431,23 @@ func windowFullScan(tls *libc.TLS, p uintptr) { /* sqlite3.c:152927:13: */ regPeer = Xsqlite3GetTempRange(tls, pParse, nPeer) } - Xsqlite3VdbeAddOp2(tls, v, 127, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, regCRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, regCRowid) windowReadPeerValues(tls, p, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, regCPeer) for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) } - Xsqlite3VdbeAddOp3(tls, v, 24, csr, lblBrk, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekGE, csr, lblBrk, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid) addrNext = Xsqlite3VdbeCurrentAddr(tls, v) - Xsqlite3VdbeAddOp2(tls, v, 127, csr, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 54, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid, lblBrk, regRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, csr, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Gt, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid, lblBrk, regRowid) - if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) == 85 { - Xsqlite3VdbeAddOp3(tls, v, 53, regCRowid, lblNext, regRowid) + if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) == TK_CURRENT { + Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regCRowid, lblNext, regRowid) - } else if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) != 66 { + } else if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) != TK_NO { var addr int32 var addrEq int32 = 0 var pKeyInfo uintptr = uintptr(0) @@ -136862,19 +134455,19 @@ func windowFullScan(tls *libc.TLS, p uintptr) { /* sqlite3.c:152927:13: */ if (*Window)(unsafe.Pointer(pMWin)).FpOrderBy != 0 { pKeyInfo = Xsqlite3KeyInfoFromExprList(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpOrderBy, 0, 0) } - if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) == 94 { - addrEq = Xsqlite3VdbeAddOp3(tls, v, 53, regCRowid, 0, regRowid) + if int32((*Window)(unsafe.Pointer(pMWin)).FeExclude) == TK_TIES { + addrEq = Xsqlite3VdbeAddOp3(tls, v, OP_Eq, regCRowid, 0, regRowid) } if pKeyInfo != 0 { windowReadPeerValues(tls, p, csr, regPeer) - Xsqlite3VdbeAddOp3(tls, v, 86, regPeer, regCPeer, nPeer) + Xsqlite3VdbeAddOp3(tls, v, OP_Compare, regPeer, regCPeer, nPeer) Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -9) addr = (Xsqlite3VdbeCurrentAddr(tls, v) + 1) - Xsqlite3VdbeAddOp3(tls, v, 16, addr, lblNext, addr) + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, addr, lblNext, addr) } else { - Xsqlite3VdbeAddOp2(tls, v, 11, 0, lblNext) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lblNext) } if addrEq != 0 { Xsqlite3VdbeJumpHere(tls, v, addrEq) @@ -136884,7 +134477,7 @@ func windowFullScan(tls *libc.TLS, p uintptr) { /* sqlite3.c:152927:13: */ windowAggStep(tls, p, pMWin, csr, 0, (*WindowCodeArg)(unsafe.Pointer(p)).FregArg) Xsqlite3VdbeResolveLabel(tls, v, lblNext) - Xsqlite3VdbeAddOp2(tls, v, 5, csr, addrNext) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, csr, addrNext) Xsqlite3VdbeJumpHere(tls, v, (addrNext - 1)) Xsqlite3VdbeJumpHere(tls, v, (addrNext + 1)) @@ -136927,20 +134520,20 @@ func windowReturnOneRow(tls *libc.TLS, p uintptr) { /* sqlite3.c:153033:13: */ var csr int32 = (*Window)(unsafe.Pointer(pWin)).FcsrApp var lbl int32 = Xsqlite3VdbeMakeLabel(tls, pParse) var tmpReg int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&nth_valueName)) { - Xsqlite3VdbeAddOp3(tls, v, 89, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + 1), tmpReg) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, (*Window)(unsafe.Pointer(pMWin)).FiEphCsr, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + 1), tmpReg) windowCheckValue(tls, pParse, tmpReg, 2) } else { - Xsqlite3VdbeAddOp2(tls, v, 69, 1, tmpReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, tmpReg) } - Xsqlite3VdbeAddOp3(tls, v, 105, tmpReg, (*Window)(unsafe.Pointer(pWin)).FregApp, tmpReg) - Xsqlite3VdbeAddOp3(tls, v, 54, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1), lbl, tmpReg) + Xsqlite3VdbeAddOp3(tls, v, OP_Add, tmpReg, (*Window)(unsafe.Pointer(pWin)).FregApp, tmpReg) + Xsqlite3VdbeAddOp3(tls, v, OP_Gt, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1), lbl, tmpReg) - Xsqlite3VdbeAddOp3(tls, v, 31, csr, 0, tmpReg) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, csr, 0, tmpReg) - Xsqlite3VdbeAddOp3(tls, v, 89, csr, (*Window)(unsafe.Pointer(pWin)).FiArgCol, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, (*Window)(unsafe.Pointer(pWin)).FiArgCol, (*Window)(unsafe.Pointer(pWin)).FregResult) Xsqlite3VdbeResolveLabel(tls, v, lbl) Xsqlite3ReleaseTempReg(tls, pParse, tmpReg) } else if ((*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&leadName))) || ((*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&lagName))) { @@ -136951,11 +134544,11 @@ func windowReturnOneRow(tls *libc.TLS, p uintptr) { /* sqlite3.c:153033:13: */ var iEph int32 = (*Window)(unsafe.Pointer(pMWin)).FiEphCsr if nArg < 3 { - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregResult) } else { - Xsqlite3VdbeAddOp3(tls, v, 89, iEph, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + 2), (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + 2), (*Window)(unsafe.Pointer(pWin)).FregResult) } - Xsqlite3VdbeAddOp2(tls, v, 127, iEph, tmpReg) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, iEph, tmpReg) if nArg < 2 { var val int32 = func() int32 { if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&leadName)) { @@ -136963,29 +134556,29 @@ func windowReturnOneRow(tls *libc.TLS, p uintptr) { /* sqlite3.c:153033:13: */ } return -1 }() - Xsqlite3VdbeAddOp2(tls, v, 82, tmpReg, val) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, tmpReg, val) } else { var op int32 = func() int32 { if (*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&leadName)) { - return 105 + return OP_Add } - return 106 + return OP_Subtract }() var tmpReg2 int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp3(tls, v, 89, iEph, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + 1), tmpReg2) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, iEph, ((*Window)(unsafe.Pointer(pWin)).FiArgCol + 1), tmpReg2) Xsqlite3VdbeAddOp3(tls, v, op, tmpReg2, tmpReg, tmpReg) Xsqlite3ReleaseTempReg(tls, pParse, tmpReg2) } - Xsqlite3VdbeAddOp3(tls, v, 31, csr, lbl, tmpReg) + Xsqlite3VdbeAddOp3(tls, v, OP_SeekRowid, csr, lbl, tmpReg) - Xsqlite3VdbeAddOp3(tls, v, 89, csr, (*Window)(unsafe.Pointer(pWin)).FiArgCol, (*Window)(unsafe.Pointer(pWin)).FregResult) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, csr, (*Window)(unsafe.Pointer(pWin)).FiArgCol, (*Window)(unsafe.Pointer(pWin)).FregResult) Xsqlite3VdbeResolveLabel(tls, v, lbl) Xsqlite3ReleaseTempReg(tls, pParse, tmpReg) } } } - Xsqlite3VdbeAddOp2(tls, v, 12, (*WindowCodeArg)(unsafe.Pointer(p)).FregGosub, (*WindowCodeArg)(unsafe.Pointer(p)).FaddrGosub) + Xsqlite3VdbeAddOp2(tls, v, OP_Gosub, (*WindowCodeArg)(unsafe.Pointer(p)).FregGosub, (*WindowCodeArg)(unsafe.Pointer(p)).FaddrGosub) } // Generate code to set the accumulator register for each window function @@ -137000,7 +134593,7 @@ func windowInitAccum(tls *libc.TLS, pParse uintptr, pMWin uintptr) int32 { /* sq for pWin = pMWin; pWin != 0; pWin = (*Window)(unsafe.Pointer(pWin)).FpNextWin { var pFunc uintptr = (*Window)(unsafe.Pointer(pWin)).FpFunc - Xsqlite3VdbeAddOp2(tls, v, 72, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) + Xsqlite3VdbeAddOp2(tls, v, OP_Null, 0, (*Window)(unsafe.Pointer(pWin)).FregAccum) nArg = func() int32 { if (nArg) > (windowArgCount(tls, pWin)) { return nArg @@ -137009,14 +134602,14 @@ func windowInitAccum(tls *libc.TLS, pParse uintptr, pMWin uintptr) int32 { /* sq }() if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0 { if ((*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&nth_valueName))) || ((*FuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&first_valueName))) { - Xsqlite3VdbeAddOp2(tls, v, 69, 0, (*Window)(unsafe.Pointer(pWin)).FregApp) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1)) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Window)(unsafe.Pointer(pWin)).FregApp) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1)) } - if (((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & U32(0x1000)) != 0) && ((*Window)(unsafe.Pointer(pWin)).FcsrApp != 0) { + if (((*FuncDef)(unsafe.Pointer(pFunc)).FfuncFlags & SQLITE_FUNC_MINMAX) != 0) && ((*Window)(unsafe.Pointer(pWin)).FcsrApp != 0) { - Xsqlite3VdbeAddOp1(tls, v, 138, (*Window)(unsafe.Pointer(pWin)).FcsrApp) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1)) + Xsqlite3VdbeAddOp1(tls, v, OP_ResetSorter, (*Window)(unsafe.Pointer(pWin)).FcsrApp) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, ((*Window)(unsafe.Pointer(pWin)).FregApp + 1)) } } } @@ -137057,14 +134650,14 @@ func windowIfNewPeer(tls *libc.TLS, pParse uintptr, pOrderBy uintptr, regNew int if pOrderBy != 0 { var nVal int32 = (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr var pKeyInfo uintptr = Xsqlite3KeyInfoFromExprList(tls, pParse, pOrderBy, 0, 0) - Xsqlite3VdbeAddOp3(tls, v, 86, regOld, regNew, nVal) + Xsqlite3VdbeAddOp3(tls, v, OP_Compare, regOld, regNew, nVal) Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -9) - Xsqlite3VdbeAddOp3(tls, v, 16, + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, (Xsqlite3VdbeCurrentAddr(tls, v) + 1), addr, (Xsqlite3VdbeCurrentAddr(tls, v) + 1)) - Xsqlite3VdbeAddOp3(tls, v, 77, regNew, regOld, (nVal - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regNew, regOld, (nVal - 1)) } else { - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addr) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addr) } } @@ -137096,24 +134689,24 @@ func windowCodeRangeTest(tls *libc.TLS, p uintptr, op int32, csr1 int32, regVal var reg1 int32 = Xsqlite3GetTempReg(tls, pParse) // Reg. for csr1.peerVal+regVal var reg2 int32 = Xsqlite3GetTempReg(tls, pParse) // Reg. for csr2.peerVal var regString int32 = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) // Reg. for constant value '' - var arith int32 = 105 // OP_Add or OP_Subtract + var arith int32 = OP_Add // OP_Add or OP_Subtract var addrGe int32 // Jump destination - if (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(0)*32)).FsortFlags) & 0x01) != 0 { + if (int32((*ExprList_item)(unsafe.Pointer((pOrderBy + 8 /* &.a */))).FsortFlags) & KEYINFO_ORDER_DESC) != 0 { switch op { - case 57: - op = 55 + case OP_Ge: + op = OP_Le break fallthrough - case 54: - op = 56 + case OP_Gt: + op = OP_Lt break fallthrough default: - op = 57 + op = OP_Ge break } - arith = 106 + arith = OP_Subtract } // Read the peer-value from each cursor into a register @@ -137133,8 +134726,8 @@ func windowCodeRangeTest(tls *libc.TLS, p uintptr, op int32, csr1 int32, regVal // the add/subtract is skipped for these, as required. If reg1 is a NULL, // then the arithmetic is performed, but since adding or subtracting from // NULL is always NULL anyway, this case is handled as required too. - Xsqlite3VdbeAddOp4(tls, v, 115, 0, regString, 0, ts+800 /* "" */, -1) - addrGe = Xsqlite3VdbeAddOp3(tls, v, 57, regString, 0, reg1) + Xsqlite3VdbeAddOp4(tls, v, OP_String8, 0, regString, 0, ts+800 /* "" */, -1) + addrGe = Xsqlite3VdbeAddOp3(tls, v, OP_Ge, regString, 0, reg1) Xsqlite3VdbeAddOp3(tls, v, arith, regVal, reg1, reg1) Xsqlite3VdbeJumpHere(tls, v, addrGe) @@ -137158,33 +134751,33 @@ func windowCodeRangeTest(tls *libc.TLS, p uintptr, op int32, csr1 int32, regVal // Additionally, if either reg1 or reg2 are NULL but the jump to lbl is // not taken, control jumps over the comparison operator coded below this // block. - if (int32((*ExprList_item)(unsafe.Pointer((pOrderBy+8 /* &.a */)+uintptr(0)*32)).FsortFlags) & 0x02) != 0 { + if (int32((*ExprList_item)(unsafe.Pointer((pOrderBy + 8 /* &.a */))).FsortFlags) & KEYINFO_ORDER_BIGNULL) != 0 { // This block runs if reg1 contains a NULL. - var addr int32 = Xsqlite3VdbeAddOp1(tls, v, 51, reg1) + var addr int32 = Xsqlite3VdbeAddOp1(tls, v, OP_NotNull, reg1) switch op { - case 57: - Xsqlite3VdbeAddOp2(tls, v, 11, 0, lbl) + case OP_Ge: + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lbl) break fallthrough - case 54: - Xsqlite3VdbeAddOp2(tls, v, 51, reg2, lbl) + case OP_Gt: + Xsqlite3VdbeAddOp2(tls, v, OP_NotNull, reg2, lbl) break fallthrough - case 55: - Xsqlite3VdbeAddOp2(tls, v, 50, reg2, lbl) + case OP_Le: + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, reg2, lbl) break fallthrough default: /* no-op */ break } - Xsqlite3VdbeAddOp2(tls, v, 11, 0, (Xsqlite3VdbeCurrentAddr(tls, v) + 3)) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, (Xsqlite3VdbeCurrentAddr(tls, v) + 3)) // This block runs if reg1 is not NULL, but reg2 is. Xsqlite3VdbeJumpHere(tls, v, addr) - Xsqlite3VdbeAddOp2(tls, v, 50, reg2, lbl) - if (op == 54) || (op == 57) { + Xsqlite3VdbeAddOp2(tls, v, OP_IsNull, reg2, lbl) + if (op == OP_Gt) || (op == OP_Ge) { Xsqlite3VdbeChangeP2(tls, v, -1, (Xsqlite3VdbeCurrentAddr(tls, v) + 1)) } } @@ -137193,7 +134786,7 @@ func windowCodeRangeTest(tls *libc.TLS, p uintptr, op int32, csr1 int32, regVal // control skips over this test if the BIGNULL flag is set and either // reg1 or reg2 contain a NULL value. Xsqlite3VdbeAddOp3(tls, v, op, reg2, lbl, reg1) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x80)) + Xsqlite3VdbeChangeP5(tls, v, SQLITE_NULLEQ) Xsqlite3ReleaseTempReg(tls, pParse, reg1) Xsqlite3ReleaseTempReg(tls, pParse, reg2) @@ -137212,41 +134805,41 @@ func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOn var ret int32 = 0 var v uintptr = (*WindowCodeArg)(unsafe.Pointer(p)).FpVdbe var addrContinue int32 = 0 - var bPeer int32 = (libc.Bool32(int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != 76)) + var bPeer int32 = (libc.Bool32(int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_ROWS)) var lblDone int32 = Xsqlite3VdbeMakeLabel(tls, pParse) var addrNextRange int32 = 0 // Special case - WINDOW_AGGINVERSE is always a no-op if the frame // starts with UNBOUNDED PRECEDING. - if (op == 2) && (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 90) { + if (op == WINDOW_AGGINVERSE) && (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_UNBOUNDED) { return 0 } if regCountdown > 0 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89 { + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE { addrNextRange = Xsqlite3VdbeCurrentAddr(tls, v) - if op == 2 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 86 { + if op == WINDOW_AGGINVERSE { + if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING { windowCodeRangeTest(tls, - p, 55, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, lblDone) + p, OP_Le, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, lblDone) } else { windowCodeRangeTest(tls, - p, 57, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, lblDone) + p, OP_Ge, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, lblDone) } } else { windowCodeRangeTest(tls, - p, 54, (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, lblDone) + p, OP_Gt, (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regCountdown, (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr, lblDone) } } else { - Xsqlite3VdbeAddOp3(tls, v, 48, regCountdown, lblDone, 1) + Xsqlite3VdbeAddOp3(tls, v, OP_IfPos, regCountdown, lblDone, 1) } } - if (op == 1) && ((*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0) { + if (op == WINDOW_RETURN_ROW) && ((*Window)(unsafe.Pointer(pMWin)).FregStartRowid == 0) { windowAggFinal(tls, p, 0) } addrContinue = Xsqlite3VdbeCurrentAddr(tls, v) @@ -137256,12 +134849,12 @@ func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOn // start cursor does not advance past the end cursor within the // temporary table. It otherwise might, if (a>b). if (((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == int32((*Window)(unsafe.Pointer(pMWin)).FeEnd)) && (regCountdown != 0)) && - (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89)) && (op == 2) { + (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE)) && (op == WINDOW_AGGINVERSE) { var regRowid1 int32 = Xsqlite3GetTempReg(tls, pParse) var regRowid2 int32 = Xsqlite3GetTempReg(tls, pParse) - Xsqlite3VdbeAddOp2(tls, v, 127, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, regRowid1) - Xsqlite3VdbeAddOp2(tls, v, 127, (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regRowid2) - Xsqlite3VdbeAddOp3(tls, v, 57, regRowid2, lblDone, regRowid1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr, regRowid1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rowid, (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Fcsr, regRowid2) + Xsqlite3VdbeAddOp3(tls, v, OP_Ge, regRowid2, lblDone, regRowid1) Xsqlite3ReleaseTempReg(tls, pParse, regRowid1) Xsqlite3ReleaseTempReg(tls, pParse, regRowid2) @@ -137269,18 +134862,18 @@ func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOn } switch op { - case 1: + case WINDOW_RETURN_ROW: csr = (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Fcsr reg = (*WindowCodeArg)(unsafe.Pointer(p)).Fcurrent.Freg windowReturnOneRow(tls, p) break - case 2: + case WINDOW_AGGINVERSE: csr = (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Fcsr reg = (*WindowCodeArg)(unsafe.Pointer(p)).Fstart.Freg if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid != 0 { - Xsqlite3VdbeAddOp2(tls, v, 82, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid, 1) } else { windowAggStep(tls, p, pMWin, csr, 1, (*WindowCodeArg)(unsafe.Pointer(p)).FregArg) } @@ -137292,7 +134885,7 @@ func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOn reg = (*WindowCodeArg)(unsafe.Pointer(p)).Fend.Freg if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid != 0 { - Xsqlite3VdbeAddOp2(tls, v, 82, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_AddImm, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid, 1) } else { windowAggStep(tls, p, pMWin, csr, 0, (*WindowCodeArg)(unsafe.Pointer(p)).FregArg) } @@ -137300,19 +134893,19 @@ func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOn } if op == (*WindowCodeArg)(unsafe.Pointer(p)).FeDelete { - Xsqlite3VdbeAddOp1(tls, v, 122, csr) - Xsqlite3VdbeChangeP5(tls, v, uint16(0x02)) + Xsqlite3VdbeAddOp1(tls, v, OP_Delete, csr) + Xsqlite3VdbeChangeP5(tls, v, OPFLAG_SAVEPOSITION) } if jumpOnEof != 0 { - Xsqlite3VdbeAddOp2(tls, v, 5, csr, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, csr, (Xsqlite3VdbeCurrentAddr(tls, v) + 2)) - ret = Xsqlite3VdbeAddOp0(tls, v, 11) + ret = Xsqlite3VdbeAddOp0(tls, v, OP_Goto) } else { - Xsqlite3VdbeAddOp2(tls, v, 5, csr, ((Xsqlite3VdbeCurrentAddr(tls, v) + 1) + bPeer)) + Xsqlite3VdbeAddOp2(tls, v, OP_Next, csr, ((Xsqlite3VdbeCurrentAddr(tls, v) + 1) + bPeer)) if bPeer != 0 { - Xsqlite3VdbeAddOp2(tls, v, 11, 0, lblDone) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lblDone) } } @@ -137335,7 +134928,7 @@ func windowCodeOp(tls *libc.TLS, p uintptr, op int32, regCountdown int32, jumpOn } if addrNextRange != 0 { - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addrNextRange) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrNextRange) } Xsqlite3VdbeResolveLabel(tls, v, lblDone) return ret @@ -137407,7 +135000,7 @@ func windowExprGtZero(tls *libc.TLS, pParse uintptr, pExpr uintptr) int32 { /* s var ret int32 = 0 var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb *(*uintptr)(unsafe.Pointer(bp /* pVal */)) = uintptr(0) - Xsqlite3ValueFromExpr(tls, db, pExpr, (*Sqlite3)(unsafe.Pointer(db)).Fenc, uint8(0x43), bp /* &pVal */) + Xsqlite3ValueFromExpr(tls, db, pExpr, (*Sqlite3)(unsafe.Pointer(db)).Fenc, SQLITE_AFF_NUMERIC, bp /* &pVal */) if (*(*uintptr)(unsafe.Pointer(bp /* pVal */)) != 0) && (Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(bp /* pVal */))) > 0) { ret = 1 } @@ -137755,20 +135348,20 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin var pMWin uintptr = (*Select)(unsafe.Pointer(p)).FpWin var pOrderBy uintptr = (*Window)(unsafe.Pointer(pMWin)).FpOrderBy var v uintptr = Xsqlite3GetVdbe(tls, pParse) - var csrWrite int32 // Cursor used to write to eph. table - var csrInput int32 = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FiCursor // Cursor of sub-select - var nInput int32 = int32((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */) + uintptr(0)*112)).FpTab)).FnCol) // Number of cols returned by sub - var iInput int32 // To iterate through sub cols - var addrNe int32 // Address of OP_Ne - var addrGosubFlush int32 = 0 // Address of OP_Gosub to flush: - var addrInteger int32 = 0 // Address of OP_Integer - var addrEmpty int32 // Address of OP_Rewind in flush: - var regNew int32 // Array of registers holding new input row - var regRecord int32 // regNew array in record form - var regRowid int32 // Rowid for regRecord in eph table - var regNewPeer int32 = 0 // Peer values for new row (part of regNew) - var regPeer int32 = 0 // Peer values for current row - var regFlushPart int32 = 0 // Register for "Gosub flush_partition" + var csrWrite int32 // Cursor used to write to eph. table + var csrInput int32 = (*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FiCursor // Cursor of sub-select + var nInput int32 = int32((*Table)(unsafe.Pointer((*SrcList_item)(unsafe.Pointer(((*Select)(unsafe.Pointer(p)).FpSrc + 8 /* &.a */))).FpTab)).FnCol) // Number of cols returned by sub + var iInput int32 // To iterate through sub cols + var addrNe int32 // Address of OP_Ne + var addrGosubFlush int32 = 0 // Address of OP_Gosub to flush: + var addrInteger int32 = 0 // Address of OP_Integer + var addrEmpty int32 // Address of OP_Rewind in flush: + var regNew int32 // Array of registers holding new input row + var regRecord int32 // regNew array in record form + var regRowid int32 // Rowid for regRecord in eph table + var regNewPeer int32 = 0 // Peer values for new row (part of regNew) + var regPeer int32 = 0 // Peer values for current row + var regFlushPart int32 = 0 // Register for "Gosub flush_partition" // var s WindowCodeArg at bp, 64 // Context object for sub-routines var lblWhereEnd int32 // Label just before sqlite3WhereEnd() code @@ -137796,26 +135389,26 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin // has been returned to the caller (WINDOW_RETURN_ROW), or they may // be deleted after they enter the frame (WINDOW_AGGSTEP). switch int32((*Window)(unsafe.Pointer(pMWin)).FeStart) { - case 86: - if (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != 89) && + case TK_FOLLOWING: + if (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_RANGE) && (windowExprGtZero(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpStart) != 0) { - (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = 1 + (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = WINDOW_RETURN_ROW } break - case 90: + case TK_UNBOUNDED: if windowCacheFrame(tls, pMWin) == 0 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == 88 { - if (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != 89) && + if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_PRECEDING { + if (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_RANGE) && (windowExprGtZero(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpEnd) != 0) { - (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = 3 + (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = WINDOW_AGGSTEP } } else { - (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = 1 + (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = WINDOW_RETURN_ROW } } break default: - (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = 2 + (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FeDelete = WINDOW_AGGINVERSE break } @@ -137830,17 +135423,17 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin // If the window frame contains an " PRECEDING" or " FOLLOWING" // clause, allocate registers to store the results of evaluating each // . - if (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 88) || (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 86) { + if (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_PRECEDING) || (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING) { regStart = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) } - if (int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == 88) || (int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == 86) { + if (int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_PRECEDING) || (int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_FOLLOWING) { regEnd = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) } // If this is not a "ROWS BETWEEN ..." frame, then allocate arrays of // registers to store copies of the ORDER BY expressions (peer values) // for the main loop, and for each cursor (start, current and end). - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != 76 { + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_ROWS { var nPeer int32 = func() int32 { if pOrderBy != 0 { return (*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr @@ -137865,9 +135458,9 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin // into an array of registers starting at regNew. Assemble them into // a record in register regRecord. for iInput = 0; iInput < nInput; iInput++ { - Xsqlite3VdbeAddOp3(tls, v, 89, csrInput, iInput, (regNew + iInput)) + Xsqlite3VdbeAddOp3(tls, v, OP_Column, csrInput, iInput, (regNew + iInput)) } - Xsqlite3VdbeAddOp3(tls, v, 91, regNew, nInput, regRecord) + Xsqlite3VdbeAddOp3(tls, v, OP_MakeRecord, regNew, nInput, regRecord) // An input row has just been read into an array of registers starting // at regNew. If the window has a PARTITION clause, this block generates @@ -137882,19 +135475,19 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin var pKeyInfo uintptr = Xsqlite3KeyInfoFromExprList(tls, pParse, pPart, 0, 0) regFlushPart = libc.PreIncInt32(&(*Parse)(unsafe.Pointer(pParse)).FnMem, 1) - addr = Xsqlite3VdbeAddOp3(tls, v, 86, regNewPart, (*Window)(unsafe.Pointer(pMWin)).FregPart, nPart) + addr = Xsqlite3VdbeAddOp3(tls, v, OP_Compare, regNewPart, (*Window)(unsafe.Pointer(pMWin)).FregPart, nPart) Xsqlite3VdbeAppendP4(tls, v, pKeyInfo, -9) - Xsqlite3VdbeAddOp3(tls, v, 16, (addr + 2), (addr + 4), (addr + 2)) + Xsqlite3VdbeAddOp3(tls, v, OP_Jump, (addr + 2), (addr + 4), (addr + 2)) - addrGosubFlush = Xsqlite3VdbeAddOp1(tls, v, 12, regFlushPart) + addrGosubFlush = Xsqlite3VdbeAddOp1(tls, v, OP_Gosub, regFlushPart) Xsqlite3VdbeComment(tls, v, ts+24477 /* "call flush_parti..." */, 0) - Xsqlite3VdbeAddOp3(tls, v, 77, regNewPart, (*Window)(unsafe.Pointer(pMWin)).FregPart, (nPart - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regNewPart, (*Window)(unsafe.Pointer(pMWin)).FregPart, (nPart - 1)) } // Insert the new row into the ephemeral table - Xsqlite3VdbeAddOp2(tls, v, 120, csrWrite, regRowid) - Xsqlite3VdbeAddOp3(tls, v, 121, csrWrite, regRecord, regRowid) - addrNe = Xsqlite3VdbeAddOp3(tls, v, 52, (*Window)(unsafe.Pointer(pMWin)).FregOne, 0, regRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_NewRowid, csrWrite, regRowid) + Xsqlite3VdbeAddOp3(tls, v, OP_Insert, csrWrite, regRecord, regRowid) + addrNe = Xsqlite3VdbeAddOp3(tls, v, OP_Ne, (*Window)(unsafe.Pointer(pMWin)).FregOne, 0, regRowid) // This block is run for the first row of each partition (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).FregArg = windowInitAccum(tls, pParse, pMWin) @@ -137902,7 +135495,7 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin if regStart != 0 { Xsqlite3ExprCode(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpStart, regStart) windowCheckValue(tls, pParse, regStart, (0 + (func() int32 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89 { + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE { return 3 } return 0 @@ -137911,52 +135504,52 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin if regEnd != 0 { Xsqlite3ExprCode(tls, pParse, (*Window)(unsafe.Pointer(pMWin)).FpEnd, regEnd) windowCheckValue(tls, pParse, regEnd, (1 + (func() int32 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89 { + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE { return 3 } return 0 }()))) } - if ((int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != 89) && (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == int32((*Window)(unsafe.Pointer(pMWin)).FeEnd))) && (regStart != 0) { + if ((int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_RANGE) && (int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == int32((*Window)(unsafe.Pointer(pMWin)).FeEnd))) && (regStart != 0) { var op int32 = func() int32 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 86 { - return 57 + if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING { + return OP_Ge } - return 55 + return OP_Le }() var addrGe int32 = Xsqlite3VdbeAddOp3(tls, v, op, regStart, 0, regEnd) // NeverNull because bound // values previously checked windowAggFinal(tls, bp /* &s */, 0) - Xsqlite3VdbeAddOp2(tls, v, 37, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, 1) windowReturnOneRow(tls, bp /* &s */) - Xsqlite3VdbeAddOp1(tls, v, 138, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr) - Xsqlite3VdbeAddOp2(tls, v, 11, 0, lblWhereEnd) + Xsqlite3VdbeAddOp1(tls, v, OP_ResetSorter, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lblWhereEnd) Xsqlite3VdbeJumpHere(tls, v, addrGe) } - if ((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 86) && (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != 89)) && (regEnd != 0) { + if ((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING) && (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) != TK_RANGE)) && (regEnd != 0) { - Xsqlite3VdbeAddOp3(tls, v, 106, regStart, regEnd, regStart) + Xsqlite3VdbeAddOp3(tls, v, OP_Subtract, regStart, regEnd, regStart) } - if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) != 90 { - Xsqlite3VdbeAddOp2(tls, v, 37, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fstart.Fcsr, 1) + if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) != TK_UNBOUNDED { + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fstart.Fcsr, 1) } - Xsqlite3VdbeAddOp2(tls, v, 37, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, 1) - Xsqlite3VdbeAddOp2(tls, v, 37, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Fcsr, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_Rewind, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Fcsr, 1) if (regPeer != 0) && (pOrderBy != 0) { - Xsqlite3VdbeAddOp3(tls, v, 77, regNewPeer, regPeer, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) - Xsqlite3VdbeAddOp3(tls, v, 77, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fstart.Freg, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) - Xsqlite3VdbeAddOp3(tls, v, 77, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Freg, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) - Xsqlite3VdbeAddOp3(tls, v, 77, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Freg, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regNewPeer, regPeer, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fstart.Freg, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Freg, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) + Xsqlite3VdbeAddOp3(tls, v, OP_Copy, regPeer, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Freg, ((*ExprList)(unsafe.Pointer(pOrderBy)).FnExpr - 1)) } - Xsqlite3VdbeAddOp2(tls, v, 11, 0, lblWhereEnd) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, lblWhereEnd) Xsqlite3VdbeJumpHere(tls, v, addrNe) @@ -137964,56 +135557,56 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin if regPeer != 0 { windowIfNewPeer(tls, pParse, pOrderBy, regNewPeer, regPeer, lblWhereEnd) } - if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 86 { - windowCodeOp(tls, bp /* &s */, 3, 0, 0) - if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) != 90 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89 { + if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING { + windowCodeOp(tls, bp /* &s */, WINDOW_AGGSTEP, 0, 0) + if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) != TK_UNBOUNDED { + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE { var lbl int32 = Xsqlite3VdbeMakeLabel(tls, pParse) var addrNext int32 = Xsqlite3VdbeCurrentAddr(tls, v) - windowCodeRangeTest(tls, bp /* &s */, 57, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, regEnd, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Fcsr, lbl) - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) - windowCodeOp(tls, bp /* &s */, 1, 0, 0) - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addrNext) + windowCodeRangeTest(tls, bp /* &s */, OP_Ge, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, regEnd, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Fcsr, lbl) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrNext) Xsqlite3VdbeResolveLabel(tls, v, lbl) } else { - windowCodeOp(tls, bp /* &s */, 1, regEnd, 0) - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, regEnd, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) } } - } else if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == 88 { - var bRPS int32 = (libc.Bool32((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 88) && (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89))) - windowCodeOp(tls, bp /* &s */, 3, regEnd, 0) + } else if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_PRECEDING { + var bRPS int32 = (libc.Bool32((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_PRECEDING) && (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE))) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGSTEP, regEnd, 0) if bRPS != 0 { - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) } - windowCodeOp(tls, bp /* &s */, 1, 0, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 0) if !(bRPS != 0) { - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) } } else { var addr int32 = 0 - windowCodeOp(tls, bp /* &s */, 3, 0, 0) - if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) != 90 { - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89 { + windowCodeOp(tls, bp /* &s */, WINDOW_AGGSTEP, 0, 0) + if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) != TK_UNBOUNDED { + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE { var lbl int32 = 0 addr = Xsqlite3VdbeCurrentAddr(tls, v) if regEnd != 0 { lbl = Xsqlite3VdbeMakeLabel(tls, pParse) - windowCodeRangeTest(tls, bp /* &s */, 57, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, regEnd, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Fcsr, lbl) + windowCodeRangeTest(tls, bp /* &s */, OP_Ge, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr, regEnd, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fend.Fcsr, lbl) } - windowCodeOp(tls, bp /* &s */, 1, 0, 0) - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) if regEnd != 0 { - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addr) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addr) Xsqlite3VdbeResolveLabel(tls, v, lbl) } } else { if regEnd != 0 { - addr = Xsqlite3VdbeAddOp3(tls, v, 48, regEnd, 0, 1) + addr = Xsqlite3VdbeAddOp3(tls, v, OP_IfPos, regEnd, 0, 1) } - windowCodeOp(tls, bp /* &s */, 1, 0, 0) - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) if regEnd != 0 { Xsqlite3VdbeJumpHere(tls, v, addr) } @@ -138027,66 +135620,66 @@ func Xsqlite3WindowCodeStep(tls *libc.TLS, pParse uintptr, p uintptr, pWInfo uin // Fall through if (*Window)(unsafe.Pointer(pMWin)).FpPartition != 0 { - addrInteger = Xsqlite3VdbeAddOp2(tls, v, 69, 0, regFlushPart) + addrInteger = Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, regFlushPart) Xsqlite3VdbeJumpHere(tls, v, addrGosubFlush) } - addrEmpty = Xsqlite3VdbeAddOp1(tls, v, 37, csrWrite) + addrEmpty = Xsqlite3VdbeAddOp1(tls, v, OP_Rewind, csrWrite) - if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == 88 { - var bRPS int32 = (libc.Bool32((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 88) && (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89))) - windowCodeOp(tls, bp /* &s */, 3, regEnd, 0) + if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_PRECEDING { + var bRPS int32 = (libc.Bool32((int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_PRECEDING) && (int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE))) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGSTEP, regEnd, 0) if bRPS != 0 { - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) } - windowCodeOp(tls, bp /* &s */, 1, 0, 0) - } else if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == 86 { + windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 0) + } else if int32((*Window)(unsafe.Pointer(pMWin)).FeStart) == TK_FOLLOWING { var addrStart int32 var addrBreak1 int32 var addrBreak2 int32 var addrBreak3 int32 - windowCodeOp(tls, bp /* &s */, 3, 0, 0) - if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == 89 { + windowCodeOp(tls, bp /* &s */, WINDOW_AGGSTEP, 0, 0) + if int32((*Window)(unsafe.Pointer(pMWin)).FeFrmType) == TK_RANGE { addrStart = Xsqlite3VdbeCurrentAddr(tls, v) - addrBreak2 = windowCodeOp(tls, bp /* &s */, 2, regStart, 1) - addrBreak1 = windowCodeOp(tls, bp /* &s */, 1, 0, 1) - } else if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == 90 { + addrBreak2 = windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 1) + addrBreak1 = windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 1) + } else if int32((*Window)(unsafe.Pointer(pMWin)).FeEnd) == TK_UNBOUNDED { addrStart = Xsqlite3VdbeCurrentAddr(tls, v) - addrBreak1 = windowCodeOp(tls, bp /* &s */, 1, regStart, 1) - addrBreak2 = windowCodeOp(tls, bp /* &s */, 2, 0, 1) + addrBreak1 = windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, regStart, 1) + addrBreak2 = windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, 0, 1) } else { addrStart = Xsqlite3VdbeCurrentAddr(tls, v) - addrBreak1 = windowCodeOp(tls, bp /* &s */, 1, regEnd, 1) - addrBreak2 = windowCodeOp(tls, bp /* &s */, 2, regStart, 1) + addrBreak1 = windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, regEnd, 1) + addrBreak2 = windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 1) } - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addrStart) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrStart) Xsqlite3VdbeJumpHere(tls, v, addrBreak2) addrStart = Xsqlite3VdbeCurrentAddr(tls, v) - addrBreak3 = windowCodeOp(tls, bp /* &s */, 1, 0, 1) - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addrStart) + addrBreak3 = windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 1) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrStart) Xsqlite3VdbeJumpHere(tls, v, addrBreak1) Xsqlite3VdbeJumpHere(tls, v, addrBreak3) } else { var addrBreak int32 var addrStart int32 - windowCodeOp(tls, bp /* &s */, 3, 0, 0) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGSTEP, 0, 0) addrStart = Xsqlite3VdbeCurrentAddr(tls, v) - addrBreak = windowCodeOp(tls, bp /* &s */, 1, 0, 1) - windowCodeOp(tls, bp /* &s */, 2, regStart, 0) - Xsqlite3VdbeAddOp2(tls, v, 11, 0, addrStart) + addrBreak = windowCodeOp(tls, bp /* &s */, WINDOW_RETURN_ROW, 0, 1) + windowCodeOp(tls, bp /* &s */, WINDOW_AGGINVERSE, regStart, 0) + Xsqlite3VdbeAddOp2(tls, v, OP_Goto, 0, addrStart) Xsqlite3VdbeJumpHere(tls, v, addrBreak) } Xsqlite3VdbeJumpHere(tls, v, addrEmpty) - Xsqlite3VdbeAddOp1(tls, v, 138, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr) + Xsqlite3VdbeAddOp1(tls, v, OP_ResetSorter, (*WindowCodeArg)(unsafe.Pointer(bp /* &s */)).Fcurrent.Fcsr) if (*Window)(unsafe.Pointer(pMWin)).FpPartition != 0 { if (*Window)(unsafe.Pointer(pMWin)).FregStartRowid != 0 { - Xsqlite3VdbeAddOp2(tls, v, 69, 1, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid) - Xsqlite3VdbeAddOp2(tls, v, 69, 0, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 1, (*Window)(unsafe.Pointer(pMWin)).FregStartRowid) + Xsqlite3VdbeAddOp2(tls, v, OP_Integer, 0, (*Window)(unsafe.Pointer(pMWin)).FregEndRowid) } Xsqlite3VdbeChangeP1(tls, v, addrInteger, Xsqlite3VdbeCurrentAddr(tls, v)) - Xsqlite3VdbeAddOp1(tls, v, 65, regFlushPart) + Xsqlite3VdbeAddOp1(tls, v, OP_Return, regFlushPart) } } @@ -138184,7 +135777,7 @@ func parserDoubleLinkSelect(tls *libc.TLS, pParse uintptr, p uintptr) { /* sqlit } { (*Select)(unsafe.Pointer(pLoop)).FpNext = pNext - *(*U32)(unsafe.Pointer(pLoop + 4 /* &.selFlags */)) |= (U32(0x0000100)) + *(*U32)(unsafe.Pointer(pLoop + 4 /* &.selFlags */)) |= (SF_Compound) } goto __2 @@ -138196,7 +135789,7 @@ func parserDoubleLinkSelect(tls *libc.TLS, pParse uintptr, p uintptr) { /* sqlit goto __3 __3: ; - if ((((*Select)(unsafe.Pointer(p)).FselFlags & U32(0x0000400)) == U32(0)) && ((libc.AssignInt32(&mxSelect, *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + uintptr(4)*4)))) > 0)) && (cnt > mxSelect) { + if ((((*Select)(unsafe.Pointer(p)).FselFlags & SF_MultiValue) == U32(0)) && ((libc.AssignInt32(&mxSelect, *(*int32)(unsafe.Pointer(((*Parse)(unsafe.Pointer(pParse)).Fdb + 124 /* &.aLimit */) + 4*4)))) > 0)) && (cnt > mxSelect) { Xsqlite3ErrorMsg(tls, pParse, ts+24498 /* "too many terms i..." */, 0) } } @@ -138216,7 +135809,7 @@ func tokenExpr(tls *libc.TLS, pParse uintptr, op int32, t Token) uintptr { /* sq // memset(p, 0, sizeof(Expr)); (*Expr)(unsafe.Pointer(p)).Fop = U8(op) (*Expr)(unsafe.Pointer(p)).FaffExpr = int8(0) - (*Expr)(unsafe.Pointer(p)).Fflags = U32(0x800000) + (*Expr)(unsafe.Pointer(p)).Fflags = EP_Leaf (*Expr)(unsafe.Pointer(p)).FiAgg = int16(-1) (*Expr)(unsafe.Pointer(p)).FpLeft = libc.AssignPtrUintptr(p+24 /* &.pRight */, uintptr(0)) @@ -138226,14 +135819,14 @@ func tokenExpr(tls *libc.TLS, pParse uintptr, op int32, t Token) uintptr { /* sq (*Expr)(unsafe.Pointer(p)).Fop2 = U8(0) (*Expr)(unsafe.Pointer(p)).FiTable = 0 (*Expr)(unsafe.Pointer(p)).FiColumn = int16(0) - *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) = (p + uintptr(1)*72) + *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) = (p + 1*72) libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)), (*Token)(unsafe.Pointer(bp /* &t */)).Fz, uint64((*Token)(unsafe.Pointer(bp /* &t */)).Fn)) *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) + uintptr((*Token)(unsafe.Pointer(bp /* &t */)).Fn))) = int8(0) - if (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)) + uintptr(0))))]) & 0x80) != 0 { + if (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 8 /* &.u */)))))]) & 0x80) != 0 { Xsqlite3DequoteExpr(tls, p) } (*Expr)(unsafe.Pointer(p)).FnHeight = 1 - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { return Xsqlite3RenameTokenMap(tls, pParse, p, bp /* &t */) } } @@ -138245,7 +135838,7 @@ func tokenExpr(tls *libc.TLS, pParse uintptr, op int32, t Token) uintptr { /* sq // unary TK_ISNULL or TK_NOTNULL expression. func binaryToUnaryIfNull(tls *libc.TLS, pParse uintptr, pY uintptr, pA uintptr, op int32) { /* sqlite3.c:154385:15: */ var db uintptr = (*Parse)(unsafe.Pointer(pParse)).Fdb - if (((pA != 0) && (pY != 0)) && (int32((*Expr)(unsafe.Pointer(pY)).Fop) == 119)) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if (((pA != 0) && (pY != 0)) && (int32((*Expr)(unsafe.Pointer(pY)).Fop) == TK_NULL)) && !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { (*Expr)(unsafe.Pointer(pA)).Fop = U8(op) Xsqlite3ExprDelete(tls, db, (*Expr)(unsafe.Pointer(pA)).FpRight) (*Expr)(unsafe.Pointer(pA)).FpRight = uintptr(0) @@ -139213,9 +136806,9 @@ func Xsqlite3ParserInit(tls *libc.TLS, yypRawParser uintptr, pParse uintptr) { / var yypParser uintptr = yypRawParser (*YyParser)(unsafe.Pointer(yypParser)).FpParse = pParse (*YyParser)(unsafe.Pointer(yypParser)).Fyytos = yypParser + 16 /* &.yystack */ - (*YyStackEntry)(unsafe.Pointer((yypParser + 16 /* &.yystack */) + uintptr(0)*24)).Fstateno = uint16(0) - (*YyStackEntry)(unsafe.Pointer((yypParser + 16 /* &.yystack */) + uintptr(0)*24)).Fmajor = uint16(0) - (*YyParser)(unsafe.Pointer(yypParser)).FyystackEnd = ((yypParser + 16 /* &.yystack */) + uintptr((100-1))*24) + (*YyStackEntry)(unsafe.Pointer((yypParser + 16 /* &.yystack */))).Fstateno = uint16(0) + (*YyStackEntry)(unsafe.Pointer((yypParser + 16 /* &.yystack */))).Fmajor = uint16(0) + (*YyParser)(unsafe.Pointer(yypParser)).FyystackEnd = ((yypParser + 16 /* &.yystack */) + 99*24) } // The following function deletes the "minor type" or semantic value @@ -139415,7 +137008,7 @@ func Xsqlite3ParserFinalize(tls *libc.TLS, p uintptr) { /* sqlite3.c:156415:21: func yy_find_shift_action(tls *libc.TLS, iLookAhead uint16, stateno uint16) uint16 { /* sqlite3.c:156495:21: */ var i int32 - if int32(stateno) > 552 { + if int32(stateno) > YY_MAX_SHIFT { return stateno } @@ -139434,9 +137027,9 @@ func yy_find_shift_action(tls *libc.TLS, iLookAhead uint16, stateno uint16) uint continue } { - var j int32 = ((i - int32(iLookAhead)) + 100) + var j int32 = ((i - int32(iLookAhead)) + YYWILDCARD) - if (int32(yy_lookahead[j]) == 100) && (int32(iLookAhead) > 0) { + if (int32(yy_lookahead[j]) == YYWILDCARD) && (int32(iLookAhead) > 0) { return yy_action[j] } @@ -139490,8 +137083,8 @@ func yy_shift(tls *libc.TLS, yypParser uintptr, yyNewState uint16, yyMajor uint1 yyStackOverflow(tls, yypParser) return } - if int32(yyNewState) > 552 { - yyNewState = uint16(int32(yyNewState) + (1191 - 803)) + if int32(yyNewState) > YY_MAX_SHIFT { + yyNewState = uint16(int32(yyNewState) + (YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE)) } yytos = (*YyParser)(unsafe.Pointer(yypParser)).Fyytos (*YyStackEntry)(unsafe.Pointer(yytos)).Fstateno = yyNewState @@ -140279,6 +137872,7 @@ var yyRuleInfoNRhs = [385]int8{ int8(-2), // (383) anylist ::= anylist ANY int8(0), // (384) with ::= } /* sqlite3.c:157063:26 */ + // Forward Declaration // Perform a reduce action and the shift that must immediately @@ -140348,7 +137942,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(4): /* transtype ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = 7 + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = TK_DEFERRED } break case uint32(5): @@ -140359,7 +137953,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(306): /* range_or_rows ::= RANGE|ROWS|GROUPS */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp + uintptr(0)*24)).Fmajor) /*A-overwrites-X*/ + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor) /*A-overwrites-X*/ } break case uint32(8): @@ -140371,22 +137965,22 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(10): /* cmd ::= SAVEPOINT nm */ { - Xsqlite3Savepoint(tls, pParse, 0, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3Savepoint(tls, pParse, SAVEPOINT_BEGIN, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(11): /* cmd ::= RELEASE savepoint_opt nm */ { - Xsqlite3Savepoint(tls, pParse, 1, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3Savepoint(tls, pParse, SAVEPOINT_RELEASE, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(12): /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ { - Xsqlite3Savepoint(tls, pParse, 2, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3Savepoint(tls, pParse, SAVEPOINT_ROLLBACK, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(13): /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ { - Xsqlite3StartTable(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), 0, 0, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) + Xsqlite3StartTable(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), 0, 0, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) } break case uint32(14): /* createkw ::= CREATE */ @@ -140412,7 +138006,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(232): /* collate ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = 0 + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = 0 } break case uint32(16): /* ifnotexists ::= IF NOT EXISTS */ @@ -140424,33 +138018,33 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // temp ::= TEMP case uint32(46): /* autoinc ::= AUTOINCR */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 1 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = 1 } break case uint32(19): /* create_table_args ::= LP columnlist conslist_opt RP table_options */ { - Xsqlite3EndTable(tls, pParse, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), uint8(*(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))), uintptr(0)) + Xsqlite3EndTable(tls, pParse, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), uint8(*(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))), uintptr(0)) } break case uint32(20): /* create_table_args ::= AS select */ { - Xsqlite3EndTable(tls, pParse, uintptr(0), uintptr(0), uint8(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) - Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3EndTable(tls, pParse, uintptr(0), uintptr(0), uint8(0), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) + Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(22): /* table_options ::= WITHOUT nm */ { - if ((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn == uint32(5)) && (Xsqlite3_strnicmp(tls, (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz, ts+10064 /* "rowid" */, 5) == 0) { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = (0x0080 | 0x0200) + if ((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn == uint32(5)) && (Xsqlite3_strnicmp(tls, (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz, ts+10064 /* "rowid" */, 5) == 0) { + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = (TF_WithoutRowid | TF_NoVisibleRowid) } else { *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 0 - Xsqlite3ErrorMsg(tls, pParse, ts+24592 /* "unknown table op..." */, libc.VaList(bp, (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn, (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz)) + Xsqlite3ErrorMsg(tls, pParse, ts+24592 /* "unknown table op..." */, libc.VaList(bp, (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn, (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz)) } } break case uint32(23): /* columnname ::= nm typetoken */ { - Xsqlite3AddColumn(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3AddColumn(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(24): @@ -140459,89 +138053,89 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(102): /* as ::= */ { - (*Token)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)).Fn = uint32(0) - (*Token)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)).Fz = uintptr(0) + (*Token)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)).Fn = uint32(0) + (*Token)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)).Fz = uintptr(0) } break case uint32(25): /* typetoken ::= typename LP signed RP */ { - (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)).Fn = uint32((int32((int64(((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn))) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).Fz)) / 1))) + (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)).Fn = uint32((int32((int64(((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn))) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).Fz)) / 1))) } break case uint32(26): /* typetoken ::= typename LP signed COMMA signed RP */ { - (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)).Fn = uint32((int32((int64(((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn))) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-5)*24+8 /* &.minor */)).Fz)) / 1))) + (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)).Fn = uint32((int32((int64(((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn))) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-5)*24+8 /* &.minor */)).Fz)) / 1))) } break case uint32(27): /* typename ::= typename ID|STRING */ { - (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)).Fn = ((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn + uint32((int32((int64((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz)) / 1)))) + (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)).Fn = ((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn + uint32((int32((int64((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz)) / 1)))) } break case uint32(28): /* scanpt ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = yyLookaheadToken.Fz + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = yyLookaheadToken.Fz } break case uint32(29): /* scantok ::= */ { - *(*Token)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = yyLookaheadToken + *(*Token)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = yyLookaheadToken } break case uint32(30): fallthrough // ccons ::= CONSTRAINT nm case uint32(65): /* tcons ::= CONSTRAINT nm */ { - (*Parse)(unsafe.Pointer(pParse)).FconstraintName = *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + (*Parse)(unsafe.Pointer(pParse)).FconstraintName = *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(31): /* ccons ::= DEFAULT scantok term */ { - Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fn))) + Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fn))) } break case uint32(32): /* ccons ::= DEFAULT LP expr RP */ { - Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fz + uintptr(1)), (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz) + Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fz + uintptr(1)), (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz) } break case uint32(33): /* ccons ::= DEFAULT PLUS scantok term */ { - Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fn))) + Xsqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fn))) } break case uint32(34): /* ccons ::= DEFAULT MINUS scantok term */ { - var p uintptr = Xsqlite3PExpr(tls, pParse, 170, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) + var p uintptr = Xsqlite3PExpr(tls, pParse, TK_UMINUS, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0)) Xsqlite3AddDefaultValue(tls, pParse, p, (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fn))) } break case uint32(35): /* ccons ::= DEFAULT scantok ID|INDEXED */ { - var p uintptr = tokenExpr(tls, pParse, 115, *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + var p uintptr = tokenExpr(tls, pParse, TK_STRING, *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */))) if p != 0 { Xsqlite3ExprIdToTrueFalse(tls, p) } - Xsqlite3AddDefaultValue(tls, pParse, p, (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn))) + Xsqlite3AddDefaultValue(tls, pParse, p, (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz, ((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz + uintptr((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn))) } break case uint32(36): /* ccons ::= NOT NULL onconf */ { - Xsqlite3AddNotNull(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3AddNotNull(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(37): /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ { - Xsqlite3AddPrimaryKey(tls, pParse, uintptr(0), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) + Xsqlite3AddPrimaryKey(tls, pParse, uintptr(0), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) } break case uint32(38): /* ccons ::= UNIQUE onconf */ { - Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), uintptr(0), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), 0, 0, - uint8(1)) + Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), uintptr(0), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0), uintptr(0), 0, 0, + SQLITE_IDXTYPE_UNIQUE) } break case uint32(39): /* ccons ::= CHECK LP expr RP */ @@ -140551,17 +138145,17 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(40): /* ccons ::= REFERENCES nm eidlist_opt refargs */ { - Xsqlite3CreateForeignKey(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3CreateForeignKey(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(41): /* ccons ::= defer_subclause */ { - Xsqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(42): /* ccons ::= COLLATE ID|STRING */ { - Xsqlite3AddCollateType(tls, pParse, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3AddCollateType(tls, pParse, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(43): /* generated ::= LP expr RP */ @@ -140571,17 +138165,17 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(44): /* generated ::= LP expr RP ID */ { - Xsqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(47): /* refargs ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = (0 * 0x0101) /* EV: R-19803-45884 */ + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = (OE_None * 0x0101) /* EV: R-19803-45884 */ } break case uint32(48): /* refargs ::= refargs refarg */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = ((*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) & ^*(*int32)(unsafe.Pointer((yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy207 */) + 4 /* &.mask */))) | *(*int32)(unsafe.Pointer((yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy207 */) /* &.value */))) + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = ((*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) & ^*(*int32)(unsafe.Pointer((yymsp + 8 /* &.minor */ /* &.yy207 */) + 4 /* &.mask */))) | *(*int32)(unsafe.Pointer((yymsp + 8 /* &.minor */ /* &.yy207 */) /* &.value */))) } break case uint32(49): /* refarg ::= MATCH nm */ @@ -140598,39 +138192,39 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(51): /* refarg ::= ON DELETE refact */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy207 */ /* &.value */)) = *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy207 */ /* &.value */)) = *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy207 */ + 4 /* &.mask */)) = 0x0000ff } break case uint32(52): /* refarg ::= ON UPDATE refact */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy207 */ /* &.value */)) = (*(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) << 8) + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy207 */ /* &.value */)) = (*(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) << 8) *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy207 */ + 4 /* &.mask */)) = 0x00ff00 } break case uint32(53): /* refact ::= SET NULL */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 8 /* EV: R-33326-45252 */ + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = OE_SetNull /* EV: R-33326-45252 */ } break case uint32(54): /* refact ::= SET DEFAULT */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 9 /* EV: R-33326-45252 */ + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = OE_SetDflt /* EV: R-33326-45252 */ } break case uint32(55): /* refact ::= CASCADE */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 10 /* EV: R-33326-45252 */ + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Cascade /* EV: R-33326-45252 */ } break case uint32(56): /* refact ::= RESTRICT */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 7 /* EV: R-33326-45252 */ + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Restrict /* EV: R-33326-45252 */ } break case uint32(57): /* refact ::= NO ACTION */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 0 /* EV: R-33326-45252 */ + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = OE_None /* EV: R-33326-45252 */ } break case uint32(58): /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ @@ -140644,7 +138238,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(162): /* insert_cmd ::= INSERT orconf */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(61): @@ -140672,13 +138266,13 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(66): /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ { - Xsqlite3AddPrimaryKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), 0) + Xsqlite3AddPrimaryKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), 0) } break case uint32(67): /* tcons ::= UNIQUE LP sortlist RP onconf */ { - Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), 0, 0, - uint8(1)) + Xsqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0), uintptr(0), 0, 0, + SQLITE_IDXTYPE_UNIQUE) } break case uint32(68): /* tcons ::= CHECK LP expr RP onconf */ @@ -140689,65 +138283,58 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in case uint32(69): /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ { Xsqlite3CreateForeignKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) - Xsqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(71): fallthrough // onconf ::= case uint32(73): /* orconf ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = 11 + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = OE_Default } break case uint32(72): /* onconf ::= ON CONFLICT resolvetype */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(75): /* resolvetype ::= IGNORE */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 4 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Ignore } break case uint32(76): fallthrough // resolvetype ::= REPLACE case uint32(163): /* insert_cmd ::= REPLACE */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 5 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Replace } break case uint32(77): /* cmd ::= DROP TABLE ifexists fullname */ { - Xsqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), 0, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) + Xsqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), 0, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(80): /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ { - Xsqlite3CreateView(tls, pParse, (yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */))) + Xsqlite3CreateView(tls, pParse, (yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */))) } break case uint32(81): /* cmd ::= DROP VIEW ifexists fullname */ { - Xsqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), 1, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) + Xsqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), 1, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(82): /* cmd ::= select */ { - *(*SelectDest)(unsafe.Pointer(bp + 24 /* dest */)) = SelectDest{ - FeDest: U8(9), - FiSDParm: 0, - FiSDParm2: 0, - FiSdst: 0, - FnSdst: 0, - FzAffSdst: uintptr(0), - FpOrderBy: uintptr(0)} - Xsqlite3Select(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), bp+24 /* &dest */) - Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*SelectDest)(unsafe.Pointer(bp + 24 /* dest */)) = SelectDest{FeDest: SRT_Output} + Xsqlite3Select(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), bp+24 /* &dest */) + Xsqlite3SelectDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(83): /* select ::= WITH wqlist selectnowith */ { - var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) if p != 0 { (*Select)(unsafe.Pointer(p)).FpWith = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) parserDoubleLinkSelect(tls, pParse, p) @@ -140759,7 +138346,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(84): /* select ::= WITH RECURSIVE wqlist selectnowith */ { - var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) if p != 0 { (*Select)(unsafe.Pointer(p)).FpWith = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) parserDoubleLinkSelect(tls, pParse, p) @@ -140771,16 +138358,16 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(85): /* select ::= selectnowith */ { - var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + var p uintptr = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) if p != 0 { parserDoubleLinkSelect(tls, pParse, p) } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = p //A-overwrites-X + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = p //A-overwrites-X } break case uint32(86): /* selectnowith ::= selectnowith multiselect_op oneselect */ { - var pRhs uintptr = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + var pRhs uintptr = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) var pLhs uintptr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) if (pRhs != 0) && ((*Select)(unsafe.Pointer(pRhs)).FpPrior != 0) { var pFrom uintptr @@ -140795,10 +138382,10 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in (*Select)(unsafe.Pointer(pRhs)).Fop = U8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) (*Select)(unsafe.Pointer(pRhs)).FpPrior = pLhs if pLhs != 0 { - *(*U32)(unsafe.Pointer(pLhs + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000400)) + *(*U32)(unsafe.Pointer(pLhs + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_MultiValue))) } - *(*U32)(unsafe.Pointer(pRhs + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000400)) - if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) != 133 { + *(*U32)(unsafe.Pointer(pRhs + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_MultiValue))) + if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) != TK_ALL { (*Parse)(unsafe.Pointer(pParse)).FhasCompound = U8(1) } } else { @@ -140811,22 +138398,22 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // multiselect_op ::= UNION case uint32(89): /* multiselect_op ::= EXCEPT|INTERSECT */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp + uintptr(0)*24)).Fmajor) /*A-overwrites-OP*/ + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor) /*A-overwrites-OP*/ } break case uint32(88): /* multiselect_op ::= UNION ALL */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 133 + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = TK_ALL } break case uint32(90): /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uint32(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uint32(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */))), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(91): /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-9)*24 + 8 /* &.minor */)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uint32(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-9)*24 + 8 /* &.minor */)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uint32(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */))), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-9)*24 + 8 /* &.minor */)) != 0 { (*Select)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-9)*24 + 8 /* &.minor */)))).FpWinDefn = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) } else { @@ -140836,19 +138423,19 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(92): /* values ::= VALUES LP nexprlist RP */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0x0000200), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), SF_Values, uintptr(0)) } break case uint32(93): /* values ::= values COMMA LP nexprlist RP */ { var pRight uintptr var pLeft uintptr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) - pRight = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), (uint32(0x0000200 | 0x0000400)), uintptr(0)) + pRight = Xsqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), (uint32(SF_Values | SF_MultiValue)), uintptr(0)) if pLeft != 0 { - *(*U32)(unsafe.Pointer(pLeft + 4 /* &.selFlags */)) &= (^libc.Uint32FromInt32(0x0000400)) + *(*U32)(unsafe.Pointer(pLeft + 4 /* &.selFlags */)) &= (libc.Uint32FromInt32(libc.CplInt32(SF_MultiValue))) } if pRight != 0 { - (*Select)(unsafe.Pointer(pRight)).Fop = U8(133) + (*Select)(unsafe.Pointer(pRight)).Fop = TK_ALL (*Select)(unsafe.Pointer(pRight)).FpPrior = pLeft *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = pRight } else { @@ -140858,12 +138445,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(94): /* distinct ::= DISTINCT */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 0x0000001 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = SF_Distinct } break case uint32(95): /* distinct ::= ALL */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 0x0000002 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = SF_All } break case uint32(97): @@ -140878,29 +138465,29 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(228): /* eidlist_opt ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = uintptr(0) } break case uint32(98): /* selcollist ::= sclp scanpt expr scanpt as */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) - if (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn > uint32(0) { - Xsqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + if (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn > uint32(0) { + Xsqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), (yymsp + 8 /* &.minor */ /* &.yy0 */), 1) } Xsqlite3ExprListSetSpan(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(99): /* selcollist ::= sclp scanpt STAR */ { - var p uintptr = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 177, uintptr(0)) + var p uintptr = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ASTERISK, uintptr(0)) *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), p) } break case uint32(100): /* selcollist ::= sclp scanpt nm DOT STAR */ { - var pRight uintptr = Xsqlite3PExpr(tls, pParse, 177, uintptr(0), uintptr(0)) - var pLeft uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 59, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) - var pDot uintptr = Xsqlite3PExpr(tls, pParse, 139, pLeft, pRight) + var pRight uintptr = Xsqlite3PExpr(tls, pParse, TK_ASTERISK, uintptr(0), uintptr(0)) + var pLeft uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ID, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + var pDot uintptr = Xsqlite3PExpr(tls, pParse, TK_DOT, pLeft, pRight) *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), pDot) } break @@ -140912,53 +138499,53 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(245): /* minus_num ::= MINUS INTEGER|FLOAT */ { - *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(103): fallthrough // from ::= case uint32(106): /* stl_prefix ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = uintptr(0) } break case uint32(104): /* from ::= FROM seltablist */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) Xsqlite3SrcListShiftJoinType(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(105): /* stl_prefix ::= seltablist joinop */ { if (*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) != 0) && ((*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FnSrc > 0) { - (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(((*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FnSrc-1))*112)).Ffg.Fjointype = U8(*(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(((*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FnSrc-1))*112)).Ffg.Fjointype = U8(*(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } } break case uint32(107): /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) Xsqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(108): /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) Xsqlite3SrcListFuncArgs(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) } break case uint32(109): /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(110): /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ { - if (((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) == uintptr(0)) && ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fn == uint32(0))) && (*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) == uintptr(0))) && (*(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) == uintptr(0)) { + if (((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) == uintptr(0)) && ((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-2)*24+8 /* &.minor */)).Fn == uint32(0))) && (*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) == uintptr(0))) && (*(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) == uintptr(0)) { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) } else if (*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)))).FnSrc == 1 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) != 0 { var pNew uintptr = ((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(((*SrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)))).FnSrc-1))*112) var pOld uintptr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 8 /* &.a */ @@ -140978,8 +138565,8 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in } else { var pSubquery uintptr Xsqlite3SrcListShiftJoinType(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) - pSubquery = Xsqlite3SelectNew(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0x0000800), uintptr(0)) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), pSubquery, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + pSubquery = Xsqlite3SelectNew(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), SF_NestedFrom, uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), pSubquery, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } } @@ -140988,43 +138575,43 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // dbnm ::= case uint32(125): /* indexed_opt ::= */ { - (*Token)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)).Fz = uintptr(0) - (*Token)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)).Fn = uint32(0) + (*Token)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)).Fz = uintptr(0) + (*Token)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)).Fn = uint32(0) } break case uint32(113): /* fullname ::= nm */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0)) - if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && (*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) != 0) { - Xsqlite3RenameTokenMap(tls, pParse, (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */))+8 /* &.a */)+uintptr(0)*112)).FzName, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + 8 /* &.minor */ /* &.yy0 */), uintptr(0)) + if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && (*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) != 0) { + Xsqlite3RenameTokenMap(tls, pParse, (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + 8 /* &.a */))).FzName, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(114): /* fullname ::= nm DOT nm */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) - if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && (*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) != 0) { - Xsqlite3RenameTokenMap(tls, pParse, (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */))+8 /* &.a */)+uintptr(0)*112)).FzName, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */)) + if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && (*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) != 0) { + Xsqlite3RenameTokenMap(tls, pParse, (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + 8 /* &.a */))).FzName, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(115): /* xfullname ::= nm */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0)) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + 8 /* &.minor */ /* &.yy0 */), uintptr(0)) /*A-overwrites-X*/ } break case uint32(116): /* xfullname ::= nm DOT nm */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */)) /*A-overwrites-X*/ } break case uint32(117): /* xfullname ::= nm DOT nm AS nm */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */)) //A-overwrites-X if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) != 0 { - (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(0)*112)).FzAlias = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 8 /* &.a */))).FzAlias = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } } break @@ -141032,13 +138619,13 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0)) //A-overwrites-X if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) != 0 { - (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(0)*112)).FzAlias = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + (*SrcList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) + 8 /* &.a */))).FzAlias = Xsqlite3NameFromToken(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } } break case uint32(119): /* joinop ::= COMMA|JOIN */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 0x0001 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = JT_INNER } break case uint32(120): /* joinop ::= JOIN_KW JOIN */ @@ -141066,7 +138653,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(237): /* vinto ::= INTO expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(124): @@ -141083,12 +138670,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(238): /* vinto ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = uintptr(0) } break case uint32(126): /* indexed_opt ::= INDEXED BY nm */ { - *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(127): /* indexed_opt ::= NOT INDEXED */ @@ -141106,74 +138693,74 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // using_opt ::= case uint32(164): /* idlist_opt ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = uintptr(0) } break case uint32(131): fallthrough // orderby_opt ::= ORDER BY sortlist case uint32(141): /* groupby_opt ::= GROUP BY nexprlist */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(132): /* sortlist ::= sortlist COMMA expr sortorder nulls */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) - Xsqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(133): /* sortlist ::= expr sortorder nulls */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) //A-overwrites-Y - Xsqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(134): /* sortorder ::= ASC */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 0 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = SQLITE_SO_ASC } break case uint32(135): /* sortorder ::= DESC */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 1 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = SQLITE_SO_DESC } break case uint32(136): fallthrough // sortorder ::= case uint32(139): /* nulls ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = -1 + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = -1 } break case uint32(137): /* nulls ::= NULLS FIRST */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 0 + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = SQLITE_SO_ASC } break case uint32(138): /* nulls ::= NULLS LAST */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 1 + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = SQLITE_SO_DESC } break case uint32(145): /* limit_opt ::= LIMIT expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 146, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_LIMIT, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0)) } break case uint32(146): /* limit_opt ::= LIMIT expr OFFSET expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 146, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_LIMIT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(147): /* limit_opt ::= LIMIT expr COMMA expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 146, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_LIMIT, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) } break case uint32(148): /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ { Xsqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */)) - Xsqlite3DeleteFrom(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0)) + Xsqlite3DeleteFrom(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0), uintptr(0)) } break case uint32(151): /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt */ @@ -141181,35 +138768,35 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in Xsqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */)) Xsqlite3ExprListCheckLength(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), ts+24619 /* "set list" */) *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = Xsqlite3SrcListAppendList(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) - Xsqlite3Update(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0)) + Xsqlite3Update(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), uintptr(0)) } break case uint32(152): /* setlist ::= setlist COMMA nm EQ expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) Xsqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) } break case uint32(153): /* setlist ::= setlist COMMA LP idlist RP EQ expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppendVector(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppendVector(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(154): /* setlist ::= nm EQ expr */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) Xsqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(155): /* setlist ::= LP idlist RP EQ expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppendVector(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppendVector(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(156): /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ { - Xsqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(157): /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ @@ -141219,12 +138806,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(158): /* upsert ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = uintptr(0) } break case uint32(159): /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*24 + 8 /* &.minor */)) = Xsqlite3UpsertNew(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*24 + 8 /* &.minor */)) = Xsqlite3UpsertNew(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(160): /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ @@ -141244,12 +138831,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(166): /* idlist ::= idlist COMMA nm */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3IdListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3IdListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(167): /* idlist ::= nm */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = Xsqlite3IdListAppend(tls, pParse, uintptr(0), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) /*A-overwrites-Y*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = Xsqlite3IdListAppend(tls, pParse, uintptr(0), (yymsp + 8 /* &.minor */ /* &.yy0 */)) /*A-overwrites-Y*/ } break case uint32(168): /* expr ::= LP expr RP */ @@ -141261,32 +138848,32 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // expr ::= ID|INDEXED case uint32(170): /* expr ::= JOIN_KW */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = tokenExpr(tls, pParse, 59, *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = tokenExpr(tls, pParse, TK_ID, *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */))) /*A-overwrites-X*/ } break case uint32(171): /* expr ::= nm DOT nm */ { - var temp1 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 59, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) - var temp2 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 59, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 1) - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { - Xsqlite3RenameTokenMap(tls, pParse, temp2, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + var temp1 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ID, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + var temp2 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ID, (yymsp + 8 /* &.minor */ /* &.yy0 */), 1) + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { + Xsqlite3RenameTokenMap(tls, pParse, temp2, (yymsp + 8 /* &.minor */ /* &.yy0 */)) Xsqlite3RenameTokenMap(tls, pParse, temp1, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */)) } - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3PExpr(tls, pParse, 139, temp1, temp2) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3PExpr(tls, pParse, TK_DOT, temp1, temp2) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(172): /* expr ::= nm DOT nm DOT nm */ { - var temp1 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 59, (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), 1) - var temp2 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 59, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) - var temp3 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 59, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 1) - var temp4 uintptr = Xsqlite3PExpr(tls, pParse, 139, temp2, temp3) - if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2 { - Xsqlite3RenameTokenMap(tls, pParse, temp3, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + var temp1 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ID, (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + var temp2 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ID, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + var temp3 uintptr = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_ID, (yymsp + 8 /* &.minor */ /* &.yy0 */), 1) + var temp4 uintptr = Xsqlite3PExpr(tls, pParse, TK_DOT, temp2, temp3) + if int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME { + Xsqlite3RenameTokenMap(tls, pParse, temp3, (yymsp + 8 /* &.minor */ /* &.yy0 */)) Xsqlite3RenameTokenMap(tls, pParse, temp2, (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */)) } - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3PExpr(tls, pParse, 139, temp1, temp4) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3PExpr(tls, pParse, TK_DOT, temp1, temp4) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break @@ -141294,34 +138881,34 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // term ::= NULL|FLOAT|BLOB case uint32(174): /* term ::= STRING */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = tokenExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+uintptr(0)*24)).Fmajor), *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = tokenExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor), *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */))) /*A-overwrites-X*/ } break case uint32(175): /* term ::= INTEGER */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 152, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_INTEGER, (yymsp + 8 /* &.minor */ /* &.yy0 */), 1) } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(176): /* expr ::= VARIABLE */ { - if !((int32(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz + uintptr(0)))) == '#') && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz + uintptr(1))))]) & 0x04) != 0)) { - var n U32 = (*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)).Fn - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = tokenExpr(tls, pParse, 153, *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) - Xsqlite3ExprAssignVarNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), n) + if !((int32(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)).Fz))) == '#') && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz + 1)))]) & 0x04) != 0)) { + var n U32 = (*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)).Fn + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = tokenExpr(tls, pParse, TK_VARIABLE, *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */))) + Xsqlite3ExprAssignVarNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), n) } else { // When doing a nested parse, one can include terms in an expression // that look like this: #1 #2 ... These terms refer to registers // in the virtual machine. #N is the N-th register. - *(*Token)(unsafe.Pointer(bp + 96 /* t */)) = *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) //A-overwrites-X + *(*Token)(unsafe.Pointer(bp + 96 /* t */)) = *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)) //A-overwrites-X if int32((*Parse)(unsafe.Pointer(pParse)).Fnested) == 0 { Xsqlite3ErrorMsg(tls, pParse, ts+24628 /* "near \"%T\": synta..." */, libc.VaList(bp+16, bp+96 /* &t */)) - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = uintptr(0) } else { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 173, uintptr(0), uintptr(0)) - if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) != 0 { - Xsqlite3GetInt32(tls, ((*Token)(unsafe.Pointer(bp+96 /* &t */)).Fz + uintptr(1)), (*(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + 44 /* &.iTable */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_REGISTER, uintptr(0), uintptr(0)) + if *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) != 0 { + Xsqlite3GetInt32(tls, ((*Token)(unsafe.Pointer(bp+96 /* &t */)).Fz + 1), (*(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) + 44 /* &.iTable */)) } } } @@ -141329,12 +138916,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(177): /* expr ::= expr COLLATE ID|STRING */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprAddCollateToken(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprAddCollateToken(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + 8 /* &.minor */ /* &.yy0 */), 1) } break case uint32(178): /* expr ::= CAST LP expr AS typetoken RP */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 36, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_CAST, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), 1) Xsqlite3ExprAttachSubtrees(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), uintptr(0)) } break @@ -141353,31 +138940,31 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in case uint32(181): /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ { *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */))) - Xsqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(182): /* expr ::= ID|INDEXED LP STAR RP filter_over */ { *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprFunction(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), 0) - Xsqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(183): /* term ::= CTIME_KW */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprFunction(tls, pParse, uintptr(0), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 0) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3ExprFunction(tls, pParse, uintptr(0), (yymsp + 8 /* &.minor */ /* &.yy0 */), 0) } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(184): /* expr ::= LP nexprlist COMMA expr RP */ { var pList uintptr = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 174, uintptr(0), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_VECTOR, uintptr(0), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) != 0 { *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 32 /* &.x */)) = pList if (*ExprList)(unsafe.Pointer(pList)).FnExpr != 0 { - *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 4 /* &.flags */)) |= ((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pList+8 /* &.a */)+uintptr(0)*32)).FpExpr)).Fflags & (U32((0x000100 | 0x200000) | 0x000004))) + *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 4 /* &.flags */)) |= ((*Expr)(unsafe.Pointer((*ExprList_item)(unsafe.Pointer((pList + 8 /* &.a */))).FpExpr)).Fflags & (U32((EP_Collate | EP_Subquery) | EP_HasFunc))) } } else { Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pList) @@ -141386,7 +138973,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(185): /* expr ::= expr AND expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(186): @@ -141403,12 +138990,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(192): /* expr ::= expr CONCAT expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(193): /* likeop ::= NOT LIKE_KW|MATCH */ { - *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)) *(*uint32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */ + 8 /* &.n */)) |= (0x80000000) /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/ } break @@ -141417,14 +139004,14 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in var pList uintptr var bNot int32 = (int32((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).Fn & 0x80000000)) *(*uint32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */ + 8 /* &.n */)) &= (uint32(0x7fffffff)) - pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprFunction(tls, pParse, pList, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), 0) if bNot != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), uintptr(0)) } if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) != 0 { - *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) + 4 /* &.flags */)) |= (U32(0x000080)) + *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) + 4 /* &.flags */)) |= (EP_InfixFunc) } } break @@ -141435,53 +139022,53 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in *(*uint32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */ + 8 /* &.n */)) &= (uint32(0x7fffffff)) pList = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) - pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprFunction(tls, pParse, pList, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), 0) if bNot != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) } if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) != 0 { - *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 4 /* &.flags */)) |= (U32(0x000080)) + *(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 4 /* &.flags */)) |= (EP_InfixFunc) } } break case uint32(196): /* expr ::= expr ISNULL|NOTNULL */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+uintptr(0)*24)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0)) } break case uint32(197): /* expr ::= expr NOT NULL */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 51, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOTNULL, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), uintptr(0)) } break case uint32(198): /* expr ::= expr IS expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 45, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) - binaryToUnaryIfNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), 50) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_IS, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) + binaryToUnaryIfNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), TK_ISNULL) } break case uint32(199): /* expr ::= expr IS NOT expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 168, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) - binaryToUnaryIfNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), 51) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_ISNOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) + binaryToUnaryIfNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), TK_NOTNULL) } break case uint32(200): fallthrough // expr ::= NOT expr case uint32(201): /* expr ::= BITNOT expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) /*A-overwrites-B*/ + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24)).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0)) /*A-overwrites-B*/ } break case uint32(202): /* expr ::= PLUS|MINUS expr */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, func() int32 { - if int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24)).Fmajor) == 105 { - return 171 + if int32((*YyStackEntry)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24)).Fmajor) == TK_PLUS { + return TK_UPLUS } - return 170 - }(), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) + return TK_UMINUS + }(), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0)) //A-overwrites-B } break @@ -141489,21 +139076,21 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // between_op ::= BETWEEN case uint32(206): /* in_op ::= IN */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 0 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = 0 } break case uint32(205): /* expr ::= expr between_op expr AND expr */ { var pList uintptr = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) - pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 48, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + pList = Xsqlite3ExprListAppend(tls, pParse, pList, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_BETWEEN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) != 0 { *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 32 /* &.x */)) = pList } else { Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, pList) } if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) } } break @@ -141518,23 +139105,23 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in // simplify to constants 0 (false) and 1 (true), respectively, // regardless of the value of expr1. Xsqlite3ExprUnmapAndDelete(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 152, func() uintptr { + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3Expr(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_INTEGER, func() uintptr { if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { return ts + 9901 /* "1" */ } return ts + 9370 /* "0" */ }()) - } else if ((*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FnExpr == 1) && (Xsqlite3ExprIsConstant(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))+8 /* &.a */)+uintptr(0)*32)).FpExpr) != 0) { - var pRHS uintptr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(0)*32)).FpExpr - (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + 8 /* &.a */) + uintptr(0)*32)).FpExpr = uintptr(0) + } else if ((*ExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FnExpr == 1) && (Xsqlite3ExprIsConstant(tls, (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))+8 /* &.a */))).FpExpr) != 0) { + var pRHS uintptr = (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + 8 /* &.a */))).FpExpr + (*ExprList_item)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + 8 /* &.a */))).FpExpr = uintptr(0) Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) - pRHS = Xsqlite3PExpr(tls, pParse, 171, pRHS, uintptr(0)) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 53, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), pRHS) + pRHS = Xsqlite3PExpr(tls, pParse, TK_UPLUS, pRHS, uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_EQ, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), pRHS) if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) } } else { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 49, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_IN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) != 0 { *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 32 /* &.x */)) = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) Xsqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) @@ -141542,7 +139129,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in Xsqlite3ExprListDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) } } @@ -141550,17 +139137,17 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(209): /* expr ::= LP select RP */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 136, uintptr(0), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_SELECT, uintptr(0), uintptr(0)) Xsqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(210): /* expr ::= expr in_op LP select RP */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 49, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_IN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) Xsqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) } } @@ -141569,18 +139156,18 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in { var pSrc uintptr = Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */)) var pSelect uintptr = Xsqlite3SelectNew(tls, pParse, uintptr(0), pSrc, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) - if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) != 0 { + if *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) != 0 { Xsqlite3SrcListFuncArgs(tls, pParse, func() uintptr { if pSelect != 0 { return pSrc } return uintptr(0) - }(), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + }(), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 49, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_IN, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) Xsqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), pSelect) if *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 19, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_NOT, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), uintptr(0)) } } @@ -141588,14 +139175,14 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in case uint32(212): /* expr ::= EXISTS LP select RP */ { var p uintptr - p = libc.AssignPtrUintptr(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */ /* &.yy202 */, Xsqlite3PExpr(tls, pParse, 20, uintptr(0), uintptr(0))) + p = libc.AssignPtrUintptr(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */ /* &.yy202 */, Xsqlite3PExpr(tls, pParse, TK_EXISTS, uintptr(0), uintptr(0))) Xsqlite3PExprAddSelect(tls, pParse, p, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(213): /* expr ::= CASE case_operand case_exprlist case_else END */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 154, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_CASE, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) != 0 { *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) + 32 /* &.x */)) = func() uintptr { if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) != 0 { @@ -141613,28 +139200,28 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in case uint32(214): /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(215): /* case_exprlist ::= WHEN expr THEN expr */ { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(218): /* case_operand ::= expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) /*A-overwrites-X*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) /*A-overwrites-X*/ } break case uint32(221): /* nexprlist ::= nexprlist COMMA expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(222): /* nexprlist ::= expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) /*A-overwrites-Y*/ + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = Xsqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) /*A-overwrites-Y*/ } break case uint32(224): @@ -141648,8 +139235,8 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in { Xsqlite3CreateIndex(tls, pParse, (yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), Xsqlite3SrcListAppend(tls, pParse, uintptr(0), (yymsp+libc.UintptrFromInt32(-4)*24+8 /* &.minor */ /* &.yy0 */), uintptr(0)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*24 + 8 /* &.minor */)), - (yymsp + libc.UintptrFromInt32(-11)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), 0, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)), uint8(0)) - if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) && ((*Parse)(unsafe.Pointer(pParse)).FpNewIndex != 0) { + (yymsp + libc.UintptrFromInt32(-11)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), SQLITE_SO_ASC, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)), SQLITE_IDXTYPE_APPDEF) + if (int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) && ((*Parse)(unsafe.Pointer(pParse)).FpNewIndex != 0) { Xsqlite3RenameTokenMap(tls, pParse, (*Index)(unsafe.Pointer((*Parse)(unsafe.Pointer(pParse)).FpNewIndex)).FzName, (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */)) } } @@ -141658,47 +139245,47 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // uniqueflag ::= UNIQUE case uint32(268): /* raisetype ::= ABORT */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 2 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Abort } break case uint32(227): /* uniqueflag ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = 0 + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = OE_None } break case uint32(230): /* eidlist ::= eidlist COMMA nm collate sortorder */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = parserAddExprIdListTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = parserAddExprIdListTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(231): /* eidlist ::= nm collate sortorder */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = parserAddExprIdListTerm(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) //A-overwrites-Y + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = parserAddExprIdListTerm(tls, pParse, uintptr(0), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */))) //A-overwrites-Y } break case uint32(234): /* cmd ::= DROP INDEX ifexists fullname */ { - Xsqlite3DropIndex(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) + Xsqlite3DropIndex(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(235): /* cmd ::= VACUUM vinto */ { - Xsqlite3Vacuum(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3Vacuum(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(236): /* cmd ::= VACUUM nm vinto */ { - Xsqlite3Vacuum(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3Vacuum(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(239): /* cmd ::= PRAGMA nm dbnm */ { - Xsqlite3Pragma(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), uintptr(0), 0) + Xsqlite3Pragma(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */), uintptr(0), 0) } break case uint32(240): /* cmd ::= PRAGMA nm dbnm EQ nmnum */ { - Xsqlite3Pragma(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 0) + Xsqlite3Pragma(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */), 0) } break case uint32(241): /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ @@ -141708,7 +139295,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(242): /* cmd ::= PRAGMA nm dbnm EQ minus_num */ { - Xsqlite3Pragma(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + Xsqlite3Pragma(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */), 1) } break case uint32(243): /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ @@ -141721,13 +139308,13 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in // var all Token at bp+112, 16 (*Token)(unsafe.Pointer(bp + 112 /* &all */)).Fz = (*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)).Fz - (*Token)(unsafe.Pointer(bp + 112 /* &all */)).Fn = (uint32((int32((int64((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).Fz)) / 1))) + (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn) + (*Token)(unsafe.Pointer(bp + 112 /* &all */)).Fn = (uint32((int32((int64((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz) - int64((*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).Fz)) / 1))) + (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn) Xsqlite3FinishTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), bp+112 /* &all */) } break case uint32(247): /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ { - Xsqlite3BeginTrigger(tls, pParse, (yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (*TrigEvent)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-4)*24+8 /* &.minor */)).Fa, (*TrigEvent)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-4)*24+8 /* &.minor */)).Fb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */))) + Xsqlite3BeginTrigger(tls, pParse, (yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (*TrigEvent)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-4)*24+8 /* &.minor */)).Fa, (*TrigEvent)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-4)*24+8 /* &.minor */)).Fb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */))) *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-10)*24 + 8 /* &.minor */)) = func() Token1 { if (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-6)*24+8 /* &.minor */)).Fn == uint32(0) { return *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)) @@ -141738,45 +139325,45 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(248): /* trigger_time ::= BEFORE|AFTER */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp + uintptr(0)*24)).Fmajor) /*A-overwrites-X*/ + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor) /*A-overwrites-X*/ } break case uint32(249): /* trigger_time ::= INSTEAD OF */ { - *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = 65 + *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = TK_INSTEAD } break case uint32(250): /* trigger_time ::= */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = 33 + *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = TK_BEFORE } break case uint32(251): fallthrough // trigger_event ::= DELETE|INSERT case uint32(252): /* trigger_event ::= UPDATE */ { - (*TrigEvent)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)).Fa = int32((*YyStackEntry)(unsafe.Pointer(yymsp + uintptr(0)*24)).Fmajor) /*A-overwrites-X*/ - (*TrigEvent)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)).Fb = uintptr(0) + (*TrigEvent)(unsafe.Pointer(yymsp + 8 /* &.minor */)).Fa = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor) /*A-overwrites-X*/ + (*TrigEvent)(unsafe.Pointer(yymsp + 8 /* &.minor */)).Fb = uintptr(0) } break case uint32(253): /* trigger_event ::= UPDATE OF idlist */ { - (*TrigEvent)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)).Fa = 127 - (*TrigEvent)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)).Fb = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + (*TrigEvent)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)).Fa = TK_UPDATE + (*TrigEvent)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)).Fb = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(254): fallthrough // when_clause ::= case uint32(273): /* key_opt ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = uintptr(0) } break case uint32(255): fallthrough // when_clause ::= WHEN expr case uint32(274): /* key_opt ::= KEY expr */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(256): /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ @@ -141794,7 +139381,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(258): /* trnm ::= nm DOT nm */ { - *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*Token)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*Token)(unsafe.Pointer(yymsp + 8 /* &.minor */)) Xsqlite3ErrorMsg(tls, pParse, ts+24652 /* "qualified table ..." */, 0) @@ -141816,39 +139403,39 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(261): /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerUpdateStep(tls, pParse, (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uint8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */))), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-8)*24+8 /* &.minor */)).Fz, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerUpdateStep(tls, pParse, (yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uint8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */))), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-8)*24+8 /* &.minor */)).Fz, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-8)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(262): /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerInsertStep(tls, pParse, (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), uint8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */))), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) //yylhsminor.yy447-overwrites-yymsp[-6].minor.yy192 + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerInsertStep(tls, pParse, (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), uint8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-6)*24 + 8 /* &.minor */))), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) //yylhsminor.yy447-overwrites-yymsp[-6].minor.yy192 } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-7)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(263): /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerDeleteStep(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-5)*24+8 /* &.minor */)).Fz, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerDeleteStep(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (*Token)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-5)*24+8 /* &.minor */)).Fz, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(264): /* trigger_cmd ::= scanpt select scanpt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerSelectStep(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) /*yylhsminor.yy447-overwrites-yymsp[-1].minor.yy539*/ + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3TriggerSelectStep(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) /*yylhsminor.yy447-overwrites-yymsp[-1].minor.yy539*/ } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(265): /* expr ::= RAISE LP IGNORE RP */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, 71, uintptr(0), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3PExpr(tls, pParse, TK_RAISE, uintptr(0), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) != 0 { - (*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)))).FaffExpr = int8(4) + (*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)))).FaffExpr = OE_Ignore } } break case uint32(266): /* expr ::= RAISE LP raisetype COMMA nm RP */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, 71, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), 1) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = Xsqlite3ExprAlloc(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, TK_RAISE, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), 1) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) != 0 { (*Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)))).FaffExpr = int8(*(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */))) } @@ -141856,27 +139443,27 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(267): /* raisetype ::= ROLLBACK */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 1 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Rollback } break case uint32(269): /* raisetype ::= FAIL */ { - *(*int32)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 3 + *(*int32)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = OE_Fail } break case uint32(270): /* cmd ::= DROP TRIGGER ifexists fullname */ { - Xsqlite3DropTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) + Xsqlite3DropTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(271): /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ { - Xsqlite3Attach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3Attach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(272): /* cmd ::= DETACH database_kw_opt expr */ { - Xsqlite3Detach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3Detach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(275): /* cmd ::= REINDEX */ @@ -141886,7 +139473,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(276): /* cmd ::= REINDEX nm dbnm */ { - Xsqlite3Reindex(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3Reindex(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(277): /* cmd ::= ANALYZE */ @@ -141896,12 +139483,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(278): /* cmd ::= ANALYZE nm dbnm */ { - Xsqlite3Analyze(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3Analyze(tls, pParse, (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(279): /* cmd ::= ALTER TABLE fullname RENAME TO nm */ { - Xsqlite3AlterRenameTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3AlterRenameTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(280): /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ @@ -141913,12 +139500,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in case uint32(281): /* add_column_fullname ::= fullname */ { disableLookaside(tls, pParse) - Xsqlite3AlterBeginAddColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3AlterBeginAddColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } break case uint32(282): /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ { - Xsqlite3AlterRenameColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3AlterRenameColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(283): /* cmd ::= create_vtab */ @@ -141928,12 +139515,12 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(284): /* cmd ::= create_vtab LP vtabarglist RP */ { - Xsqlite3VtabFinishParse(tls, pParse, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3VtabFinishParse(tls, pParse, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(285): /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ { - Xsqlite3VtabBeginParse(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) + Xsqlite3VtabBeginParse(tls, pParse, (yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */ /* &.yy0 */), (yymsp + 8 /* &.minor */ /* &.yy0 */), *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */))) } break case uint32(286): /* vtabarg ::= */ @@ -141947,14 +139534,14 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough case uint32(289): /* lp ::= LP */ { - Xsqlite3VtabArgExtend(tls, pParse, (yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.yy0 */)) + Xsqlite3VtabArgExtend(tls, pParse, (yymsp + 8 /* &.minor */ /* &.yy0 */)) } break case uint32(290): fallthrough // with ::= WITH wqlist case uint32(291): /* with ::= WITH RECURSIVE wqlist */ { - Xsqlite3WithPush(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uint8(1)) + Xsqlite3WithPush(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uint8(1)) } break case uint32(292): /* wqlist ::= nm eidlist_opt AS LP select RP */ @@ -141969,16 +139556,16 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(294): /* windowdefn_list ::= windowdefn */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(295): /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ { - Xsqlite3WindowChain(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) - (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)))).FpNextWin = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + Xsqlite3WindowChain(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) + (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)))).FpNextWin = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break @@ -141993,23 +139580,23 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(297): /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0)) } break case uint32(298): /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */ /* &.yy0 */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */ /* &.yy0 */)) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(299): /* window ::= ORDER BY sortlist frame_opt */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), uintptr(0)) } break case uint32(300): /* window ::= nm ORDER BY sortlist frame_opt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */ /* &.yy0 */)) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-4)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break @@ -142017,30 +139604,30 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // window ::= frame_opt case uint32(320): /* filter_over ::= over_clause */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(302): /* window ::= nm frame_opt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)), uintptr(0), uintptr(0), (yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.yy0 */)) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(303): /* frame_opt ::= */ { - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = Xsqlite3WindowAlloc(tls, pParse, 0, 90, uintptr(0), 85, uintptr(0), uint8(0)) + *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = Xsqlite3WindowAlloc(tls, pParse, 0, TK_UNBOUNDED, uintptr(0), TK_CURRENT, uintptr(0), uint8(0)) } break case uint32(304): /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FpExpr, 85, uintptr(0), *(*U8)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FpExpr, TK_CURRENT, uintptr(0), *(*U8)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(305): /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ { - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).FpExpr, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FpExpr, *(*U8)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)), (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-3)*24+8 /* &.minor */)).FpExpr, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FeType, (*FrameBound)(unsafe.Pointer(yymsp+libc.UintptrFromInt32(-1)*24+8 /* &.minor */)).FpExpr, *(*U8)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-5)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break @@ -142048,9 +139635,9 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in fallthrough // frame_bound_s ::= frame_bound case uint32(309): /* frame_bound_e ::= frame_bound */ { - *(*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*FrameBound)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*FrameBound)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } - *(*FrameBound)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*FrameBound)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(308): fallthrough // frame_bound_s ::= UNBOUNDED PRECEDING @@ -142065,19 +139652,19 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(311): /* frame_bound ::= expr PRECEDING|FOLLOWING */ { - (*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)).FeType = int32((*YyStackEntry)(unsafe.Pointer(yymsp + uintptr(0)*24)).Fmajor) + (*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)).FeType = int32((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor) (*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)).FpExpr = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) } *(*FrameBound)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*FrameBound)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(313): /* frame_exclude_opt ::= */ { - *(*U8)(unsafe.Pointer(yymsp + uintptr(1)*24 + 8 /* &.minor */)) = U8(0) + *(*U8)(unsafe.Pointer(yymsp + 1*24 + 8 /* &.minor */)) = U8(0) } break case uint32(314): /* frame_exclude_opt ::= EXCLUDE frame_exclude */ { - *(*U8)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*U8)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*U8)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*U8)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(315): @@ -142089,18 +139676,18 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in break case uint32(317): /* frame_exclude ::= GROUP|TIES */ { - *(*U8)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = U8((*YyStackEntry)(unsafe.Pointer(yymsp + uintptr(0)*24)).Fmajor) /*A-overwrites-X*/ + *(*U8)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = U8((*YyStackEntry)(unsafe.Pointer(yymsp)).Fmajor) /*A-overwrites-X*/ } break case uint32(318): /* window_clause ::= WINDOW windowdefn_list */ { - *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } break case uint32(319): /* filter_over ::= filter_clause over_clause */ { - (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) - *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break @@ -142108,13 +139695,13 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in { *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(Window{}))) if *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) != 0 { - (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)))).FeFrmType = U8(163) - (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) + (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)))).FeFrmType = TK_FILTER + (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) } else { - Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */))) + Xsqlite3ExprDelete(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */))) } } - *(*uintptr)(unsafe.Pointer(yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) + *(*uintptr)(unsafe.Pointer(yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp + 80 /* &yylhsminor */)) break case uint32(322): /* over_clause ::= OVER LP window RP */ { @@ -142126,7 +139713,7 @@ func yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead in { *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = Xsqlite3DbMallocZero(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, uint64(unsafe.Sizeof(Window{}))) if *(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) != 0 { - (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FzName = Xsqlite3DbStrNDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fz, uint64((*Token)(unsafe.Pointer(yymsp+uintptr(0)*24+8 /* &.minor */)).Fn)) + (*Window)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)))).FzName = Xsqlite3DbStrNDup(tls, (*Parse)(unsafe.Pointer(pParse)).Fdb, (*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fz, uint64((*Token)(unsafe.Pointer(yymsp+8 /* &.minor */)).Fn)) } } break @@ -142229,7 +139816,7 @@ func yy_syntax_error(tls *libc.TLS, yypParser uintptr, yymajor int32, yyminor To //*********** Begin %syntax_error code *************************************** _ = yymajor // Silence some compiler warnings - if *(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(bp+8 /* &yyminor */)).Fz + uintptr(0))) != 0 { + if *(*int8)(unsafe.Pointer((*Token)(unsafe.Pointer(bp + 8 /* &yyminor */)).Fz)) != 0 { Xsqlite3ErrorMsg(tls, pParse, ts+24628 /* "near \"%T\": synta..." */, libc.VaList(bp, bp+8 /* &yyminor */)) } else { Xsqlite3ErrorMsg(tls, pParse, ts+24916 /* "incomplete input" */, 0) @@ -142285,13 +139872,13 @@ func Xsqlite3Parser(tls *libc.TLS, yyp uintptr, yymajor int32, yyminor Token) { for ok := true; ok; ok = ((*YyParser)(unsafe.Pointer(yypParser)).Fyytos > yypParser+16 /* &.yystack */) { yyact = yy_find_shift_action(tls, uint16(yymajor), yyact) - if int32(yyact) >= 1191 { - yyact = yy_reduce(tls, yypParser, (uint32(int32(yyact) - 1191)), yymajor, + if int32(yyact) >= YY_MIN_REDUCE { + yyact = yy_reduce(tls, yypParser, (uint32(int32(yyact) - YY_MIN_REDUCE)), yymajor, yyminor, pParse) - } else if int32(yyact) <= 1187 { + } else if int32(yyact) <= YY_MAX_SHIFTREDUCE { yy_shift(tls, yypParser, yyact, uint16(yymajor), yyminor) break - } else if int32(yyact) == 1189 { + } else if int32(yyact) == YY_ACCEPT_ACTION { (*YyParser)(unsafe.Pointer(yypParser)).Fyytos -= 24 yy_accept(tls, yypParser) return @@ -142513,35 +140100,35 @@ var aKWOffset = [145]uint16{ } /* sqlite3.c:159521:33 */ // aKWCode[i] is the parser symbol code for the i-th keyword var aKWCode = [145]uint8{ - uint8(97), uint8(114), uint8(158), uint8(39), uint8(58), - uint8(41), uint8(122), uint8(67), uint8(33), uint8(130), - uint8(62), uint8(63), uint8(47), uint8(2), uint8(65), - uint8(160), uint8(38), uint8(24), uint8(136), uint8(16), - uint8(116), uint8(156), uint8(11), uint8(129), uint8(157), - uint8(91), uint8(126), uint8(21), uint8(21), uint8(43), - uint8(50), uint8(82), uint8(13), uint8(135), uint8(94), - uint8(51), uint8(19), uint8(66), uint8(119), uint8(47), - uint8(134), uint8(6), uint8(28), uint8(113), uint8(116), - uint8(159), uint8(71), uint8(9), uint8(20), uint8(117), - uint8(148), uint8(69), uint8(68), uint8(128), uint8(77), - uint8(89), uint8(95), uint8(40), uint8(145), uint8(47), - uint8(5), uint8(116), uint8(123), uint8(121), uint8(3), - uint8(25), uint8(81), uint8(116), uint8(14), uint8(32), - uint8(48), uint8(149), uint8(92), uint8(144), uint8(35), - uint8(31), uint8(118), uint8(154), uint8(111), uint8(17), - uint8(99), uint8(8), uint8(141), uint8(125), uint8(46), - uint8(4), uint8(30), uint8(70), uint8(27), uint8(127), - uint8(137), uint8(80), uint8(96), uint8(155), uint8(147), - uint8(72), uint8(29), uint8(98), uint8(44), uint8(7), - uint8(138), uint8(45), uint8(124), uint8(15), uint8(49), - uint8(36), uint8(60), uint8(10), uint8(37), uint8(116), - uint8(99), uint8(99), uint8(85), uint8(87), uint8(131), - uint8(88), uint8(42), uint8(84), uint8(163), uint8(73), - uint8(83), uint8(86), uint8(140), uint8(116), uint8(146), - uint8(18), uint8(143), uint8(74), uint8(93), uint8(162), - uint8(116), uint8(12), uint8(76), uint8(75), uint8(90), - uint8(132), uint8(142), uint8(78), uint8(79), uint8(161), - uint8(61), uint8(34), uint8(64), uint8(133), uint8(120), + TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE, + TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN, + TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD, + TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE, + TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE, + TK_EXCLUDE, TK_DELETE, TK_TEMP, TK_TEMP, TK_OR, + TK_ISNULL, TK_NULLS, TK_SAVEPOINT, TK_INTERSECT, TK_TIES, + TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW, + TK_EXCEPT, TK_TRANSACTION, TK_ACTION, TK_ON, TK_JOIN_KW, + TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_CONSTRAINT, + TK_INTO, TK_OFFSET, TK_OF, TK_SET, TK_TRIGGER, + TK_RANGE, TK_GENERATED, TK_DETACH, TK_HAVING, TK_LIKE_KW, + TK_BEGIN, TK_JOIN_KW, TK_REFERENCES, TK_UNIQUE, TK_QUERY, + TK_WITHOUT, TK_WITH, TK_JOIN_KW, TK_RELEASE, TK_ATTACH, + TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP, TK_CASCADE, + TK_ASC, TK_DEFAULT, TK_CASE, TK_COLLATE, TK_CREATE, + TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_MATCH, + TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT, TK_UPDATE, + TK_VALUES, TK_VIRTUAL, TK_ALWAYS, TK_WHEN, TK_WHERE, + TK_RECURSIVE, TK_AFTER, TK_RENAME, TK_AND, TK_DEFERRED, + TK_DISTINCT, TK_IS, TK_AUTOINCR, TK_TO, TK_IN, + TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, + TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT, TK_PARTITION, TK_DROP, + TK_PRECEDING, TK_FAIL, TK_LAST, TK_FILTER, TK_REPLACE, + TK_FIRST, TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_LIMIT, + TK_IF, TK_ORDER, TK_RESTRICT, TK_OTHERS, TK_OVER, + TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNBOUNDED, + TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_WINDOW, + TK_DO, TK_BY, TK_INITIALLY, TK_ALL, TK_PRIMARY, } /* sqlite3.c:159536:28 */ // Hash table decoded: @@ -142680,20 +140267,20 @@ func keywordCode(tls *libc.TLS, z uintptr, n int32, pType uintptr) int32 { /* sq var j int32 var zKW uintptr if n >= 2 { - i = ((((int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(z + uintptr(0))))]) * 4) ^ (int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(z + uintptr((n - 1)))))]) * 3)) ^ n) % 127) + i = ((((int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(z)))]) * 4) ^ (int32(Xsqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(z + uintptr((n - 1)))))]) * 3)) ^ n) % 127) for i = ((int32(aKWHash[i])) - 1); i >= 0; i = ((int32(aKWNext[i])) - 1) { if int32(aKWLen[i]) != n { continue } zKW = (uintptr(unsafe.Pointer(&zKWText)) + uintptr(aKWOffset[i])) - if (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) & ^libc.Int32(0x20)) != int32(*(*int8)(unsafe.Pointer(zKW + uintptr(0)))) { + if (int32(*(*int8)(unsafe.Pointer(z))) & libc.CplInt32(0x20)) != int32(*(*int8)(unsafe.Pointer(zKW))) { continue } - if (int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))) & ^libc.Int32(0x20)) != int32(*(*int8)(unsafe.Pointer(zKW + uintptr(1)))) { + if (int32(*(*int8)(unsafe.Pointer(z + 1))) & libc.CplInt32(0x20)) != int32(*(*int8)(unsafe.Pointer(zKW + 1))) { continue } j = 2 - for (j < n) && ((int32(*(*int8)(unsafe.Pointer(z + uintptr(j)))) & ^libc.Int32(0x20)) == int32(*(*int8)(unsafe.Pointer(zKW + uintptr(j))))) { + for (j < n) && ((int32(*(*int8)(unsafe.Pointer(z + uintptr(j)))) & libc.CplInt32(0x20)) == int32(*(*int8)(unsafe.Pointer(zKW + uintptr(j))))) { j++ } if j < n { @@ -142855,26 +140442,26 @@ func Xsqlite3KeywordCode(tls *libc.TLS, z uintptr, n int32) int32 { /* sqlite3.c bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* id */)) = 59 + *(*int32)(unsafe.Pointer(bp /* id */)) = TK_ID keywordCode(tls, z, n, bp /* &id */) return *(*int32)(unsafe.Pointer(bp /* id */)) } func Xsqlite3_keyword_name(tls *libc.TLS, i int32, pzName uintptr, pnName uintptr) int32 { /* sqlite3.c:159877:16: */ - if (i < 0) || (i >= 145) { - return 1 + if (i < 0) || (i >= SQLITE_N_KEYWORD) { + return SQLITE_ERROR } *(*uintptr)(unsafe.Pointer(pzName)) = (uintptr(unsafe.Pointer(&zKWText)) + uintptr(aKWOffset[i])) *(*int32)(unsafe.Pointer(pnName)) = int32(aKWLen[i]) - return 0 + return SQLITE_OK } func Xsqlite3_keyword_count(tls *libc.TLS) int32 { /* sqlite3.c:159883:16: */ - return 145 + return SQLITE_N_KEYWORD } func Xsqlite3_keyword_check(tls *libc.TLS, zName uintptr, nName int32) int32 { /* sqlite3.c:159884:16: */ - return (libc.Bool32(59 != Xsqlite3KeywordCode(tls, zName, nName))) + return (libc.Bool32(TK_ID != Xsqlite3KeywordCode(tls, zName, nName))) } //************* End of keywordhash.h **************************************** @@ -142909,16 +140496,16 @@ func getToken(tls *libc.TLS, pz uintptr) int32 { /* sqlite3.c:159938:12: */ var z uintptr = *(*uintptr)(unsafe.Pointer(pz)) // var t int32 at bp, 4 // Token type to return - for ok := true; ok; ok = (*(*int32)(unsafe.Pointer(bp /* t */)) == 179) { + for ok := true; ok; ok = (*(*int32)(unsafe.Pointer(bp /* t */)) == TK_SPACE) { z += uintptr(Xsqlite3GetToken(tls, z, bp /* &t */)) } - if (((((*(*int32)(unsafe.Pointer(bp /* t */)) == 59) || - (*(*int32)(unsafe.Pointer(bp /* t */)) == 115)) || - (*(*int32)(unsafe.Pointer(bp /* t */)) == 116)) || - (*(*int32)(unsafe.Pointer(bp /* t */)) == 161)) || - (*(*int32)(unsafe.Pointer(bp /* t */)) == 162)) || - (Xsqlite3ParserFallback(tls, *(*int32)(unsafe.Pointer(bp /* t */))) == 59) { - *(*int32)(unsafe.Pointer(bp /* t */)) = 59 + if (((((*(*int32)(unsafe.Pointer(bp /* t */)) == TK_ID) || + (*(*int32)(unsafe.Pointer(bp /* t */)) == TK_STRING)) || + (*(*int32)(unsafe.Pointer(bp /* t */)) == TK_JOIN_KW)) || + (*(*int32)(unsafe.Pointer(bp /* t */)) == TK_WINDOW)) || + (*(*int32)(unsafe.Pointer(bp /* t */)) == TK_OVER)) || + (Xsqlite3ParserFallback(tls, *(*int32)(unsafe.Pointer(bp /* t */))) == TK_ID) { + *(*int32)(unsafe.Pointer(bp /* t */)) = TK_ID } *(*uintptr)(unsafe.Pointer(pz)) = z return *(*int32)(unsafe.Pointer(bp /* t */)) @@ -142959,14 +140546,14 @@ func analyzeWindowKeyword(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:159987: var t int32 t = getToken(tls, bp /* &z */) - if t != 59 { - return 59 + if t != TK_ID { + return TK_ID } t = getToken(tls, bp /* &z */) - if t != 24 { - return 59 + if t != TK_AS { + return TK_ID } - return 161 + return TK_WINDOW } func analyzeOverKeyword(tls *libc.TLS, z uintptr, lastToken int32) int32 { /* sqlite3.c:159995:12: */ @@ -142974,13 +140561,13 @@ func analyzeOverKeyword(tls *libc.TLS, z uintptr, lastToken int32) int32 { /* sq defer tls.Free(8) *(*uintptr)(unsafe.Pointer(bp)) = z - if lastToken == 23 { + if lastToken == TK_RP { var t int32 = getToken(tls, bp /* &z */) - if (t == 22) || (t == 59) { - return 162 + if (t == TK_LP) || (t == TK_ID) { + return TK_OVER } } - return 59 + return TK_ID } func analyzeFilterKeyword(tls *libc.TLS, z uintptr, lastToken int32) int32 { /* sqlite3.c:160002:12: */ @@ -142988,10 +140575,10 @@ func analyzeFilterKeyword(tls *libc.TLS, z uintptr, lastToken int32) int32 { /* defer tls.Free(8) *(*uintptr)(unsafe.Pointer(bp)) = z - if (lastToken == 23) && (getToken(tls, bp /* &z */) == 22) { - return 163 + if (lastToken == TK_RP) && (getToken(tls, bp /* &z */) == TK_LP) { + return TK_FILTER } - return 59 + return TK_ID } // Return the length (in bytes) of the token that begins at z[0]. @@ -143002,164 +140589,164 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq switch int32(aiClass[*(*uint8)(unsafe.Pointer(z))]) { // Switch on the character-class of the first byte // of the token. See the comment on the CC_ defines // above. - case 7: + case CC_SPACE: { for i = 1; (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x01) != 0; i++ { } - *(*int32)(unsafe.Pointer(tokenType)) = 179 + *(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE return i } - case 11: + case CC_MINUS: { - if int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == '-' { + if int32(*(*uint8)(unsafe.Pointer(z + 1))) == '-' { for i = 2; ((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0) && (c != '\n'); i++ { } - *(*int32)(unsafe.Pointer(tokenType)) = 179 // IMP: R-22934-25134 + *(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE // IMP: R-22934-25134 return i } - *(*int32)(unsafe.Pointer(tokenType)) = 106 + *(*int32)(unsafe.Pointer(tokenType)) = TK_MINUS return 1 } - case 17: + case CC_LP: { - *(*int32)(unsafe.Pointer(tokenType)) = 22 + *(*int32)(unsafe.Pointer(tokenType)) = TK_LP return 1 } - case 18: + case CC_RP: { - *(*int32)(unsafe.Pointer(tokenType)) = 23 + *(*int32)(unsafe.Pointer(tokenType)) = TK_RP return 1 } - case 19: + case CC_SEMI: { - *(*int32)(unsafe.Pointer(tokenType)) = 1 + *(*int32)(unsafe.Pointer(tokenType)) = TK_SEMI return 1 } - case 20: + case CC_PLUS: { - *(*int32)(unsafe.Pointer(tokenType)) = 105 + *(*int32)(unsafe.Pointer(tokenType)) = TK_PLUS return 1 } - case 21: + case CC_STAR: { - *(*int32)(unsafe.Pointer(tokenType)) = 107 + *(*int32)(unsafe.Pointer(tokenType)) = TK_STAR return 1 } - case 16: + case CC_SLASH: { - if (int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) != '*') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(2)))) == 0) { - *(*int32)(unsafe.Pointer(tokenType)) = 108 + if (int32(*(*uint8)(unsafe.Pointer(z + 1))) != '*') || (int32(*(*uint8)(unsafe.Pointer(z + 2))) == 0) { + *(*int32)(unsafe.Pointer(tokenType)) = TK_SLASH return 1 } i = 3 - c = int32(*(*uint8)(unsafe.Pointer(z + uintptr(2)))) + c = int32(*(*uint8)(unsafe.Pointer(z + 2))) for ; ((c != '*') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '/')) && ((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0); i++ { } if c != 0 { i++ } - *(*int32)(unsafe.Pointer(tokenType)) = 179 // IMP: R-22934-25134 + *(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE // IMP: R-22934-25134 return i } - case 22: + case CC_PERCENT: { - *(*int32)(unsafe.Pointer(tokenType)) = 109 + *(*int32)(unsafe.Pointer(tokenType)) = TK_REM return 1 } - case 14: + case CC_EQ: { - *(*int32)(unsafe.Pointer(tokenType)) = 53 - return (1 + (libc.Bool32(int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == '='))) + *(*int32)(unsafe.Pointer(tokenType)) = TK_EQ + return (1 + (libc.Bool32(int32(*(*uint8)(unsafe.Pointer(z + 1))) == '='))) } - case 12: + case CC_LT: { - if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))))) == '=' { - *(*int32)(unsafe.Pointer(tokenType)) = 55 + if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + 1))))) == '=' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_LE return 2 } else if c == '>' { - *(*int32)(unsafe.Pointer(tokenType)) = 52 + *(*int32)(unsafe.Pointer(tokenType)) = TK_NE return 2 } else if c == '<' { - *(*int32)(unsafe.Pointer(tokenType)) = 103 + *(*int32)(unsafe.Pointer(tokenType)) = TK_LSHIFT return 2 } else { - *(*int32)(unsafe.Pointer(tokenType)) = 56 + *(*int32)(unsafe.Pointer(tokenType)) = TK_LT return 1 } } fallthrough - case 13: + case CC_GT: { - if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))))) == '=' { - *(*int32)(unsafe.Pointer(tokenType)) = 57 + if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + 1))))) == '=' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_GE return 2 } else if c == '>' { - *(*int32)(unsafe.Pointer(tokenType)) = 104 + *(*int32)(unsafe.Pointer(tokenType)) = TK_RSHIFT return 2 } else { - *(*int32)(unsafe.Pointer(tokenType)) = 54 + *(*int32)(unsafe.Pointer(tokenType)) = TK_GT return 1 } } fallthrough - case 15: + case CC_BANG: { - if int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) != '=' { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + if int32(*(*uint8)(unsafe.Pointer(z + 1))) != '=' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL return 1 } else { - *(*int32)(unsafe.Pointer(tokenType)) = 52 + *(*int32)(unsafe.Pointer(tokenType)) = TK_NE return 2 } } fallthrough - case 10: + case CC_PIPE: { - if int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) != '|' { - *(*int32)(unsafe.Pointer(tokenType)) = 102 + if int32(*(*uint8)(unsafe.Pointer(z + 1))) != '|' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_BITOR return 1 } else { - *(*int32)(unsafe.Pointer(tokenType)) = 110 + *(*int32)(unsafe.Pointer(tokenType)) = TK_CONCAT return 2 } } fallthrough - case 23: + case CC_COMMA: { - *(*int32)(unsafe.Pointer(tokenType)) = 26 + *(*int32)(unsafe.Pointer(tokenType)) = TK_COMMA return 1 } - case 24: + case CC_AND: { - *(*int32)(unsafe.Pointer(tokenType)) = 101 + *(*int32)(unsafe.Pointer(tokenType)) = TK_BITAND return 1 } - case 25: + case CC_TILDA: { - *(*int32)(unsafe.Pointer(tokenType)) = 112 + *(*int32)(unsafe.Pointer(tokenType)) = TK_BITNOT return 1 } - case 8: + case CC_QUOTE: { - var delim int32 = int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) + var delim int32 = int32(*(*uint8)(unsafe.Pointer(z))) for i = 1; (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0; i++ { if c == delim { @@ -143171,35 +140758,32 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq } } if c == '\'' { - *(*int32)(unsafe.Pointer(tokenType)) = 115 + *(*int32)(unsafe.Pointer(tokenType)) = TK_STRING return (i + 1) } else if c != 0 { - *(*int32)(unsafe.Pointer(tokenType)) = 59 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ID return (i + 1) } else { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL return i } } fallthrough - case 26: + case CC_DOT: { - if !((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(1)))]) & 0x04) != 0) { - *(*int32)(unsafe.Pointer(tokenType)) = 139 + if !((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + 1))]) & 0x04) != 0) { + *(*int32)(unsafe.Pointer(tokenType)) = TK_DOT return 1 } - // If the next character is a digit, this is a floating point - // number that begins with ".". Fall thru into the next case - /* no break */ } fallthrough - case 3: + case CC_DIGIT: { - *(*int32)(unsafe.Pointer(tokenType)) = 152 - if ((int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) == '0') && ((int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == 'x') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == 'X'))) && ((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(2)))]) & 0x08) != 0) { + *(*int32)(unsafe.Pointer(tokenType)) = TK_INTEGER + if ((int32(*(*uint8)(unsafe.Pointer(z))) == '0') && ((int32(*(*uint8)(unsafe.Pointer(z + 1))) == 'x') || (int32(*(*uint8)(unsafe.Pointer(z + 1))) == 'X'))) && ((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + 2))]) & 0x08) != 0) { for i = 3; (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x08) != 0; i++ { } return i @@ -143211,7 +140795,7 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq for (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0 { i++ } - *(*int32)(unsafe.Pointer(tokenType)) = 150 + *(*int32)(unsafe.Pointer(tokenType)) = TK_FLOAT } if ((int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == 'e') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == 'E')) && (((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))]) & 0x04) != 0) || (((int32(*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))) == '+') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))) == '-')) && ((int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr((i + 2))))]) & 0x04) != 0))) { @@ -143219,45 +140803,45 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq for (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0 { i++ } - *(*int32)(unsafe.Pointer(tokenType)) = 150 + *(*int32)(unsafe.Pointer(tokenType)) = TK_FLOAT } for (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x46) != 0 { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL i++ } return i } - case 9: + case CC_QUOTE2: { i = 1 - c = int32(*(*uint8)(unsafe.Pointer(z + uintptr(0)))) + c = int32(*(*uint8)(unsafe.Pointer(z))) for ; (c != ']') && ((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0); i++ { } *(*int32)(unsafe.Pointer(tokenType)) = func() int32 { if c == ']' { - return 59 + return TK_ID } - return 180 + return TK_ILLEGAL }() return i } - case 6: + case CC_VARNUM: { - *(*int32)(unsafe.Pointer(tokenType)) = 153 + *(*int32)(unsafe.Pointer(tokenType)) = TK_VARIABLE for i = 1; (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0; i++ { } return i } - case 4: + case CC_DOLLAR: fallthrough - case 5: + case CC_VARALPHA: { var n int32 = 0 - *(*int32)(unsafe.Pointer(tokenType)) = 153 + *(*int32)(unsafe.Pointer(tokenType)) = TK_VARIABLE for i = 1; (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0; i++ { if (int32(Xsqlite3CtypeMap[uint8(c)]) & 0x46) != 0 { n++ @@ -143268,7 +140852,7 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq if c == ')' { i++ } else { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL } break } else if (c == ':') && (int32(*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))) == ':') { @@ -143278,14 +140862,14 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq } } if n == 0 { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL } return i } - case 1: + case CC_KYWD: { - for i = 1; int32(aiClass[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) <= 1; i++ { + for i = 1; int32(aiClass[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) <= CC_KYWD; i++ { } if (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x46) != 0 { // This token started out using characters that can appear in keywords, @@ -143294,19 +140878,19 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq i++ break } - *(*int32)(unsafe.Pointer(tokenType)) = 59 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ID return keywordCode(tls, z, i, tokenType) } - case 0: + case CC_X: { - if int32(*(*uint8)(unsafe.Pointer(z + uintptr(1)))) == '\'' { - *(*int32)(unsafe.Pointer(tokenType)) = 151 + if int32(*(*uint8)(unsafe.Pointer(z + 1))) == '\'' { + *(*int32)(unsafe.Pointer(tokenType)) = TK_BLOB for i = 2; (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x08) != 0; i++ { } if (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '\'') || ((i % 2) != 0) { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL for (*(*uint8)(unsafe.Pointer(z + uintptr(i))) != 0) && (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '\'') { i++ } @@ -143316,27 +140900,24 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq } return i } - // If it is not a BLOB literal, then it must be an ID, since no - // SQL keywords start with the letter 'x'. Fall through - /* no break */ } fallthrough - case 2: + case CC_ID: { i = 1 break } - case 28: + case CC_NUL: { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL return 0 } default: { - *(*int32)(unsafe.Pointer(tokenType)) = 180 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ILLEGAL return 1 } @@ -143344,7 +140925,7 @@ func Xsqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* sq for (int32(Xsqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x46) != 0 { i++ } - *(*int32)(unsafe.Pointer(tokenType)) = 59 + *(*int32)(unsafe.Pointer(tokenType)) = TK_ID return i } @@ -143368,11 +140949,11 @@ func Xsqlite3RunParser(tls *libc.TLS, pParse uintptr, zSql uintptr, pzErrMsg uin // var sEngine YyParser at bp+40, 2424 // Space to hold the Lemon-generated Parser object - mxSqlLen = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(1)*4)) + mxSqlLen = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 1*4)) if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 { libc.AtomicStoreNInt32((db + 392 /* &.u1 */ /* &.isInterrupted */), int32(0), 0) } - (*Parse)(unsafe.Pointer(pParse)).Frc = 0 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_OK (*Parse)(unsafe.Pointer(pParse)).FzTail = zSql pEngine = bp + 40 /* &sEngine */ @@ -143384,39 +140965,39 @@ func Xsqlite3RunParser(tls *libc.TLS, pParse uintptr, zSql uintptr, pzErrMsg uin n = Xsqlite3GetToken(tls, zSql, bp+2464 /* &tokenType */) mxSqlLen = mxSqlLen - (n) if mxSqlLen < 0 { - (*Parse)(unsafe.Pointer(pParse)).Frc = 18 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_TOOBIG break } - if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) >= 161 { + if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) >= TK_WINDOW { if libc.AtomicLoadNInt32((db+392 /* &.u1 */ /* &.isInterrupted */), 0) != 0 { - (*Parse)(unsafe.Pointer(pParse)).Frc = 9 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_INTERRUPT break } - if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == 179 { + if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == TK_SPACE { zSql += uintptr(n) continue } - if int32(*(*int8)(unsafe.Pointer(zSql + uintptr(0)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(zSql))) == 0 { // Upon reaching the end of input, call the parser two more times // with tokens TK_SEMI and 0, in that order. - if lastTokenParsed == 1 { + if lastTokenParsed == TK_SEMI { *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = 0 } else if lastTokenParsed == 0 { break } else { - *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = 1 + *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = TK_SEMI } n = 0 - } else if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == 161 { + } else if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == TK_WINDOW { - *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = analyzeWindowKeyword(tls, (zSql + uintptr(6))) - } else if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == 162 { + *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = analyzeWindowKeyword(tls, (zSql + 6)) + } else if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == TK_OVER { - *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = analyzeOverKeyword(tls, (zSql + uintptr(4)), lastTokenParsed) - } else if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == 163 { + *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = analyzeOverKeyword(tls, (zSql + 4), lastTokenParsed) + } else if *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) == TK_FILTER { - *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = analyzeFilterKeyword(tls, (zSql + uintptr(6)), lastTokenParsed) + *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) = analyzeFilterKeyword(tls, (zSql + 6), lastTokenParsed) } else { Xsqlite3ErrorMsg(tls, pParse, ts+24933 /* "unrecognized tok..." */, libc.VaList(bp, n, zSql)) break @@ -143428,16 +141009,16 @@ func Xsqlite3RunParser(tls *libc.TLS, pParse uintptr, zSql uintptr, pzErrMsg uin lastTokenParsed = *(*int32)(unsafe.Pointer(bp + 2464 /* tokenType */)) zSql += uintptr(n) - if (*Parse)(unsafe.Pointer(pParse)).Frc != 0 { + if (*Parse)(unsafe.Pointer(pParse)).Frc != SQLITE_OK { break } } Xsqlite3ParserFinalize(tls, pEngine) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - (*Parse)(unsafe.Pointer(pParse)).Frc = 7 + (*Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM } - if (((*Parse)(unsafe.Pointer(pParse)).Frc != 0) && ((*Parse)(unsafe.Pointer(pParse)).Frc != 101)) && ((*Parse)(unsafe.Pointer(pParse)).FzErrMsg == uintptr(0)) { + if (((*Parse)(unsafe.Pointer(pParse)).Frc != SQLITE_OK) && ((*Parse)(unsafe.Pointer(pParse)).Frc != SQLITE_DONE)) && ((*Parse)(unsafe.Pointer(pParse)).FzErrMsg == uintptr(0)) { (*Parse)(unsafe.Pointer(pParse)).FzErrMsg = Xsqlite3MPrintf(tls, db, ts+824 /* "%s" */, libc.VaList(bp+16, Xsqlite3ErrStr(tls, (*Parse)(unsafe.Pointer(pParse)).Frc))) } @@ -143460,13 +141041,13 @@ func Xsqlite3RunParser(tls *libc.TLS, pParse uintptr, zSql uintptr, pzErrMsg uin } Xsqlite3_free(tls, (*Parse)(unsafe.Pointer(pParse)).FapVtabLock) - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != 0) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL) { // If the pParse->declareVtab flag is set, do not delete any table // structure built up in pParse->pNewTable. The calling code (see vtab.c) // will take responsibility for freeing the Table structure. Xsqlite3DeleteTable(tls, db, (*Parse)(unsafe.Pointer(pParse)).FpNewTable) } - if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= 2) { + if !(int32((*Parse)(unsafe.Pointer(pParse)).FeParseMode) >= PARSE_MODE_RENAME) { Xsqlite3DeleteTrigger(tls, db, (*Parse)(unsafe.Pointer(pParse)).FpNewTrigger) } @@ -143574,7 +141155,7 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: switch int32(*(*int8)(unsafe.Pointer(zSql))) { case ';': { // A semicolon - token = U8(0) + token = TkSEMI break } @@ -143588,32 +141169,32 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: fallthrough case '\f': { // White space is ignored - token = U8(1) + token = TkWS break } case '/': { // C-style comments - if int32(*(*int8)(unsafe.Pointer(zSql + uintptr(1)))) != '*' { - token = U8(2) + if int32(*(*int8)(unsafe.Pointer(zSql + 1))) != '*' { + token = TkOTHER break } zSql += uintptr(2) - for (*(*int8)(unsafe.Pointer(zSql + uintptr(0))) != 0) && ((int32(*(*int8)(unsafe.Pointer(zSql + uintptr(0)))) != '*') || (int32(*(*int8)(unsafe.Pointer(zSql + uintptr(1)))) != '/')) { + for (*(*int8)(unsafe.Pointer(zSql)) != 0) && ((int32(*(*int8)(unsafe.Pointer(zSql))) != '*') || (int32(*(*int8)(unsafe.Pointer(zSql + 1))) != '/')) { zSql++ } - if int32(*(*int8)(unsafe.Pointer(zSql + uintptr(0)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(zSql))) == 0 { return 0 } zSql++ - token = U8(1) + token = TkWS break } case '-': { // SQL-style comments from "--" to end of line - if int32(*(*int8)(unsafe.Pointer(zSql + uintptr(1)))) != '-' { - token = U8(2) + if int32(*(*int8)(unsafe.Pointer(zSql + 1))) != '-' { + token = TkOTHER break } for (*(*int8)(unsafe.Pointer(zSql)) != 0) && (int32(*(*int8)(unsafe.Pointer(zSql))) != '\n') { @@ -143622,7 +141203,7 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: if int32(*(*int8)(unsafe.Pointer(zSql))) == 0 { return (libc.Bool32(int32(state) == 1)) } - token = U8(1) + token = TkWS break } @@ -143635,7 +141216,7 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: if int32(*(*int8)(unsafe.Pointer(zSql))) == 0 { return 0 } - token = U8(2) + token = TkOTHER break } @@ -143653,7 +141234,7 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: if int32(*(*int8)(unsafe.Pointer(zSql))) == 0 { return 0 } - token = U8(2) + token = TkOTHER break } @@ -143670,9 +141251,9 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: case 'C': { if (nId == 6) && (Xsqlite3_strnicmp(tls, zSql, ts+24971 /* "create" */, 6) == 0) { - token = U8(4) + token = TkCREATE } else { - token = U8(2) + token = TkOTHER } break @@ -143683,13 +141264,13 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: case 'T': { if (nId == 7) && (Xsqlite3_strnicmp(tls, zSql, ts+21445 /* "trigger" */, 7) == 0) { - token = U8(6) + token = TkTRIGGER } else if (nId == 4) && (Xsqlite3_strnicmp(tls, zSql, ts+24978 /* "temp" */, 4) == 0) { - token = U8(5) + token = TkTEMP } else if (nId == 9) && (Xsqlite3_strnicmp(tls, zSql, ts+24983 /* "temporary" */, 9) == 0) { - token = U8(5) + token = TkTEMP } else { - token = U8(2) + token = TkOTHER } break @@ -143700,11 +141281,11 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: case 'E': { if (nId == 3) && (Xsqlite3_strnicmp(tls, zSql, ts+24993 /* "end" */, 3) == 0) { - token = U8(7) + token = TkEND } else if (nId == 7) && (Xsqlite3_strnicmp(tls, zSql, ts+24997 /* "explain" */, 7) == 0) { - token = U8(3) + token = TkEXPLAIN } else { - token = U8(2) + token = TkOTHER } break @@ -143712,7 +141293,7 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: fallthrough default: { - token = U8(2) + token = TkOTHER break } @@ -143720,7 +141301,7 @@ func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:160716: zSql += (uintptr(nId - 1)) } else { // Operators and special symbols - token = U8(2) + token = TkOTHER } break @@ -143758,12 +141339,12 @@ func Xsqlite3_complete16(tls *libc.TLS, zSql uintptr) int32 { /* sqlite3.c:16088 return rc } pVal = Xsqlite3ValueNew(tls, uintptr(0)) - Xsqlite3ValueSetStr(tls, pVal, -1, zSql, uint8(2), uintptr(0)) - zSql8 = Xsqlite3ValueText(tls, pVal, uint8(1)) + Xsqlite3ValueSetStr(tls, pVal, -1, zSql, SQLITE_UTF16LE, uintptr(0)) + zSql8 = Xsqlite3ValueText(tls, pVal, SQLITE_UTF8) if zSql8 != 0 { rc = Xsqlite3_complete(tls, zSql8) } else { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3ValueFree(tls, pVal) return (rc & 0xff) @@ -143809,20 +141390,20 @@ func Xsqlite3_libversion(tls *libc.TLS) uintptr { /* sqlite3.c:161110:23: */ // IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function // returns an integer equal to SQLITE_VERSION_NUMBER. func Xsqlite3_libversion_number(tls *libc.TLS) int32 { /* sqlite3.c:161123:16: */ - return 3033000 + return SQLITE_VERSION_NUMBER } // IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns // zero if and only if SQLite was compiled with mutexing code omitted due to // the SQLITE_THREADSAFE compile-time option being set to 0. func Xsqlite3_threadsafe(tls *libc.TLS) int32 { /* sqlite3.c:161129:16: */ - return 1 + return SQLITE_THREADSAFE } // When compiling the test fixture or with debugging enabled (on Win32), // this variable being set to non-zero will cause OSTRACE macros to emit // extra diagnostic information. -var Xsqlite3OSTrace int32 = 0 /* sqlite3.c:161140:7 */ +var Xsqlite3OSTrace int32 = SQLITE_DEBUG_OS_TRACE /* sqlite3.c:161140:7 */ // If the following global variable points to a string which is the // name of a directory, then that directory will be used to store @@ -143881,7 +141462,7 @@ func Xsqlite3_initialize(tls *libc.TLS) int32 { /* sqlite3.c:161202:16: */ // of this routine. if Xsqlite3Config.FisInit != 0 { - return 0 + return SQLITE_OK } // Make sure the mutex subsystem is initialized. If unable to @@ -143901,22 +141482,22 @@ func Xsqlite3_initialize(tls *libc.TLS) int32 { /* sqlite3.c:161202:16: */ // MutexAlloc() is called for a static mutex prior to initializing the // malloc subsystem - this implies that the allocation of a static // mutex must not require support from the malloc subsystem. - pMainMtx = Xsqlite3MutexAlloc(tls, 2) + pMainMtx = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN) Xsqlite3_mutex_enter(tls, pMainMtx) Xsqlite3Config.FisMutexInit = 1 if !(Xsqlite3Config.FisMallocInit != 0) { rc = Xsqlite3MallocInit(tls) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3Config.FisMallocInit = 1 if !(int32(Xsqlite3Config.FpInitMutex) != 0) { - Xsqlite3Config.FpInitMutex = Xsqlite3MutexAlloc(tls, 1) + Xsqlite3Config.FpInitMutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_RECURSIVE) if (Xsqlite3Config.FbCoreMutex != 0) && !(int32(Xsqlite3Config.FpInitMutex) != 0) { - rc = 7 + rc = SQLITE_NOMEM } } } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3Config.FnRefInitMutex++ } Xsqlite3_mutex_leave(tls, pMainMtx) @@ -143924,7 +141505,7 @@ func Xsqlite3_initialize(tls *libc.TLS) int32 { /* sqlite3.c:161202:16: */ // If rc is not SQLITE_OK at this point, then either the malloc // subsystem could not be initialized or the system failed to allocate // the pInitMutex mutex. Return an error in either case. - if rc != 0 { + if rc != SQLITE_OK { return rc } @@ -143948,14 +141529,14 @@ func Xsqlite3_initialize(tls *libc.TLS) int32 { /* sqlite3.c:161202:16: */ if Xsqlite3Config.FisPCacheInit == 0 { rc = Xsqlite3PcacheInitialize(tls) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3Config.FisPCacheInit = 1 rc = Xsqlite3OsInit(tls) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3MemdbInit(tls) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3PCacheBufferSetup(tls, Xsqlite3Config.FpPage, Xsqlite3Config.FszPage, Xsqlite3Config.FnPage) @@ -144022,7 +141603,7 @@ func Xsqlite3_shutdown(tls *libc.TLS) int32 { /* sqlite3.c:161377:16: */ Xsqlite3Config.FisMutexInit = 0 } - return 0 + return SQLITE_OK } // This API allows applications to modify the global configuration of @@ -144035,7 +141616,7 @@ func Xsqlite3_shutdown(tls *libc.TLS) int32 { /* sqlite3.c:161377:16: */ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:161431:16: */ var ap Va_list _ = ap - var rc int32 = 0 + var rc int32 = SQLITE_OK // sqlite3_config() shall return SQLITE_MISUSE if it is invoked while // the SQLite library is in use. @@ -144048,7 +141629,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 // Mutex configuration options are only available in a threadsafe // compile. - case 1: + case SQLITE_CONFIG_SINGLETHREAD: { // EVIDENCE-OF: R-02748-19096 This option sets the threading mode to // Single-thread. @@ -144057,7 +141638,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 2: + case SQLITE_CONFIG_MULTITHREAD: { // EVIDENCE-OF: R-14374-42468 This option sets the threading mode to // Multi-thread. @@ -144066,7 +141647,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 3: + case SQLITE_CONFIG_SERIALIZED: { // EVIDENCE-OF: R-41220-51800 This option sets the threading mode to // Serialized. @@ -144075,14 +141656,14 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 10: + case SQLITE_CONFIG_MUTEX: { // Specify an alternative mutex implementation Xsqlite3Config.Fmutex = *(*Sqlite3_mutex_methods)(unsafe.Pointer(libc.VaUintptr(&ap))) break } - case 11: + case SQLITE_CONFIG_GETMUTEX: { // Retrieve the current mutex implementation *(*Sqlite3_mutex_methods)(unsafe.Pointer(libc.VaUintptr(&ap))) = Xsqlite3Config.Fmutex @@ -144090,7 +141671,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 } - case 4: + case SQLITE_CONFIG_MALLOC: { // EVIDENCE-OF: R-55594-21030 The SQLITE_CONFIG_MALLOC option takes a // single argument which is a pointer to an instance of the @@ -144101,7 +141682,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 5: + case SQLITE_CONFIG_GETMALLOC: { // EVIDENCE-OF: R-51213-46414 The SQLITE_CONFIG_GETMALLOC option takes a // single argument which is a pointer to an instance of the @@ -144114,7 +141695,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 9: + case SQLITE_CONFIG_MEMSTATUS: { // EVIDENCE-OF: R-61275-35157 The SQLITE_CONFIG_MEMSTATUS option takes // single argument of type int, interpreted as a boolean, which enables @@ -144123,13 +141704,13 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 27: + case SQLITE_CONFIG_SMALL_MALLOC: { Xsqlite3Config.FbSmallMalloc = U8(libc.VaInt32(&ap)) break } - case 7: + case SQLITE_CONFIG_PAGECACHE: { // EVIDENCE-OF: R-18761-36601 There are three arguments to // SQLITE_CONFIG_PAGECACHE: A pointer to 8-byte aligned memory (pMem), @@ -144141,7 +141722,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 24: + case SQLITE_CONFIG_PCACHE_HDRSZ: { // EVIDENCE-OF: R-39100-27317 The SQLITE_CONFIG_PCACHE_HDRSZ option takes // a single parameter which is a pointer to an integer and writes into @@ -144152,21 +141733,21 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 } - case 14: + case SQLITE_CONFIG_PCACHE: { // no-op break } - case 15: + case SQLITE_CONFIG_GETPCACHE: { // now an error - rc = 1 + rc = SQLITE_ERROR break } - case 18: + case SQLITE_CONFIG_PCACHE2: { // EVIDENCE-OF: R-63325-48378 The SQLITE_CONFIG_PCACHE2 option takes a // single argument which is a pointer to an sqlite3_pcache_methods2 @@ -144176,7 +141757,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 break } - case 19: + case SQLITE_CONFIG_GETPCACHE2: { // EVIDENCE-OF: R-22035-46182 The SQLITE_CONFIG_GETPCACHE2 option takes a // single argument which is a pointer to an sqlite3_pcache_methods2 @@ -144194,7 +141775,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 // available if SQLite is compiled with either SQLITE_ENABLE_MEMSYS3 or // SQLITE_ENABLE_MEMSYS5 and returns SQLITE_ERROR if invoked otherwise. - case 13: + case SQLITE_CONFIG_LOOKASIDE: { Xsqlite3Config.FszLookaside = int32(libc.VaInt32(&ap)) Xsqlite3Config.FnLookaside = int32(libc.VaInt32(&ap)) @@ -144205,7 +141786,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 // Record a pointer to the logger function and its first argument. // The default is NULL. Logging is disabled if the function pointer is // NULL. - case 16: + case SQLITE_CONFIG_LOG: { Xsqlite3Config.FxLog = libc.VaUintptr(&ap) Xsqlite3Config.FpLogArg = libc.VaUintptr(&ap) @@ -144217,7 +141798,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 // can be changed at start-time using the // sqlite3_config(SQLITE_CONFIG_URI,1) or // sqlite3_config(SQLITE_CONFIG_URI,0) configuration calls. - case 17: + case SQLITE_CONFIG_URI: { // EVIDENCE-OF: R-25451-61125 The SQLITE_CONFIG_URI option takes a single // argument of type int. If non-zero, then URI handling is globally @@ -144228,7 +141809,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 } - case 20: + case SQLITE_CONFIG_COVERING_INDEX_SCAN: { // EVIDENCE-OF: R-36592-02772 The SQLITE_CONFIG_COVERING_INDEX_SCAN // option takes a single integer argument which is interpreted as a @@ -144239,7 +141820,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 } - case 22: + case SQLITE_CONFIG_MMAP_SIZE: { // EVIDENCE-OF: R-58063-38258 SQLITE_CONFIG_MMAP_SIZE takes two 64-bit // integer (sqlite3_int64) values that are the default mmap size limit @@ -144254,11 +141835,11 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 // silently truncated if necessary so that it does not exceed the // compile-time maximum mmap size set by the SQLITE_MAX_MMAP_SIZE // compile-time option. - if (mxMmap < int64(0)) || (mxMmap > int64(0x7fff0000)) { - mxMmap = int64(0x7fff0000) + if (mxMmap < int64(0)) || (mxMmap > SQLITE_MAX_MMAP_SIZE) { + mxMmap = SQLITE_MAX_MMAP_SIZE } if szMmap < int64(0) { - szMmap = int64(0) + szMmap = SQLITE_DEFAULT_MMAP_SIZE } if szMmap > mxMmap { szMmap = mxMmap @@ -144269,21 +141850,21 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 } - case 25: + case SQLITE_CONFIG_PMASZ: { Xsqlite3Config.FszPma = U32(libc.VaUint32(&ap)) break } - case 26: + case SQLITE_CONFIG_STMTJRNL_SPILL: { Xsqlite3Config.FnStmtSpill = int32(libc.VaInt32(&ap)) break } - case 29: + case SQLITE_CONFIG_MEMDB_MAXSIZE: { Xsqlite3Config.FmxMemdbSize = Sqlite3_int64(libc.VaInt64(&ap)) break @@ -144292,7 +141873,7 @@ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlite3.c:1 default: { - rc = 1 + rc = SQLITE_ERROR break } @@ -144317,7 +141898,7 @@ func setupLookaside(tls *libc.TLS, db uintptr, pBuf uintptr, sz int32, cnt int32 var nSm int32 // Number smaller LOOKASIDE_SMALL-byte slots if Xsqlite3LookasideUsed(tls, db, uintptr(0)) > 0 { - return 5 + return SQLITE_BUSY } // Free any existing lookaside buffer for this handle before // allocating a new one so we don't have to have space for @@ -144327,7 +141908,7 @@ func setupLookaside(tls *libc.TLS, db uintptr, pBuf uintptr, sz int32, cnt int32 } // The size of a lookaside slot after ROUNDDOWN8 needs to be larger // than a pointer to be useful. - sz = ((sz) & ^libc.Int32(7)) // IMP: R-33038-09382 + sz = ((sz) & libc.CplInt32(7)) // IMP: R-33038-09382 if sz <= int32(unsafe.Sizeof(uintptr(0))) { sz = 0 } @@ -144347,12 +141928,12 @@ func setupLookaside(tls *libc.TLS, db uintptr, pBuf uintptr, sz int32, cnt int32 } else { pStart = pBuf } - if sz >= (128 * 3) { - nBig = (int32(szAlloc / (Sqlite3_int64((3 * 128) + sz)))) - nSm = (int32((szAlloc - (Sqlite3_int64(sz * nBig))) / int64(128))) - } else if sz >= (128 * 2) { - nBig = (int32(szAlloc / (Sqlite3_int64(128 + sz)))) - nSm = (int32((szAlloc - (Sqlite3_int64(sz * nBig))) / int64(128))) + if sz >= (LOOKASIDE_SMALL * 3) { + nBig = (int32(szAlloc / (Sqlite3_int64((3 * LOOKASIDE_SMALL) + sz)))) + nSm = (int32((szAlloc - (Sqlite3_int64(sz * nBig))) / LOOKASIDE_SMALL)) + } else if sz >= (LOOKASIDE_SMALL * 2) { + nBig = (int32(szAlloc / (Sqlite3_int64(LOOKASIDE_SMALL + sz)))) + nSm = (int32((szAlloc - (Sqlite3_int64(sz * nBig))) / LOOKASIDE_SMALL)) } else if sz > 0 { nBig = (int32(szAlloc / Sqlite3_int64(sz))) nSm = 0 @@ -144380,7 +141961,7 @@ func setupLookaside(tls *libc.TLS, db uintptr, pBuf uintptr, sz int32, cnt int32 for i = 0; i < nSm; i++ { (*LookasideSlot)(unsafe.Pointer(p)).FpNext = (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpSmallInit = p - p = ((p) + uintptr(128)) + p = ((p) + 128) } (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FpEnd = p @@ -144404,7 +141985,7 @@ func setupLookaside(tls *libc.TLS, db uintptr, pBuf uintptr, sz int32, cnt int32 (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FnSlot = U32(0) } - return 0 + return SQLITE_OK } // Return the mutex associated with a database connection. @@ -144428,34 +142009,34 @@ func Xsqlite3_db_release_memory(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c: } Xsqlite3BtreeLeaveAll(tls, db) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // Flush any dirty pages in the pager-cache for any attached database // to disk. func Xsqlite3_db_cacheflush(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:161887:16: */ var i int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var bSeenBusy int32 = 0 Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) Xsqlite3BtreeEnterAll(tls, db) - for i = 0; (rc == 0) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb); i++ { var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt if (pBt != 0) && (Xsqlite3BtreeIsInTrans(tls, pBt) != 0) { var pPager uintptr = Xsqlite3BtreePager(tls, pBt) rc = Xsqlite3PagerFlush(tls, pPager) - if rc == 5 { + if rc == SQLITE_BUSY { bSeenBusy = 1 - rc = 0 + rc = SQLITE_OK } } } Xsqlite3BtreeLeaveAll(tls, db) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) return func() int32 { - if (rc == 0) && (bSeenBusy != 0) { - return 5 + if (rc == SQLITE_OK) && (bSeenBusy != 0) { + return SQLITE_BUSY } return rc }() @@ -144468,16 +142049,16 @@ func Xsqlite3_db_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 { var rc int32 ap = va switch op { - case 1000: + case SQLITE_DBCONFIG_MAINDBNAME: { // IMP: R-06824-28531 // IMP: R-36257-52125 - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FzDbSName = libc.VaUintptr(&ap) - rc = 0 + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName = libc.VaUintptr(&ap) + rc = SQLITE_OK break } - case 1001: + case SQLITE_DBCONFIG_LOOKASIDE: { var pBuf uintptr = libc.VaUintptr(&ap) // IMP: R-26835-10964 var sz int32 = int32(libc.VaInt32(&ap)) // IMP: R-47871-25994 @@ -144489,7 +142070,7 @@ func Xsqlite3_db_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 { default: { var i uint32 - rc = 1 // IMP: R-42790-23372 + rc = SQLITE_ERROR // IMP: R-42790-23372 for i = uint32(0); i < (uint32((int32(uint64(unsafe.Sizeof(aFlagOp)) / uint64(unsafe.Sizeof(struct { Fop int32 Fmask U32 @@ -144509,7 +142090,7 @@ func Xsqlite3_db_config(tls *libc.TLS, db uintptr, op int32, va uintptr) int32 { if pRes != 0 { *(*int32)(unsafe.Pointer(pRes)) = (libc.Bool32(((*Sqlite3)(unsafe.Pointer(db)).Fflags & U64(aFlagOp[i].Fmask)) != uint64(0))) } - rc = 0 + rc = SQLITE_OK break } } @@ -144525,54 +142106,22 @@ var aFlagOp = [16]struct { Fop int32 Fmask U32 }{ - { - Fop: 1002, - Fmask: U32(0x00004000)}, - { - Fop: 1003, - Fmask: U32(0x00040000)}, - { - Fop: 1015, - Fmask: 0x80000000}, - { - Fop: 1004, - Fmask: U32(0x00400000)}, - { - Fop: 1005, - Fmask: U32(0x00010000)}, - { - Fop: 1006, - Fmask: U32(0x00000800)}, - { - Fop: 1007, - Fmask: U32(0x00800000)}, - { - Fop: 1008, - Fmask: U32(0x01000000)}, - { - Fop: 1009, - Fmask: U32(0x02000000)}, - { - Fop: 1010, - Fmask: U32(0x10000000)}, - { - Fop: 1011, - Fmask: (U32(0x00000001 | 0x08000000))}, - { - Fop: 1012, - Fmask: U32(0x04000000)}, - { - Fop: 1014, - Fmask: U32(0x20000000)}, - { - Fop: 1013, - Fmask: U32(0x40000000)}, - { - Fop: 1016, - Fmask: U32(0x00000002)}, - { - Fop: 1017, - Fmask: U32(0x00000080)}, + {Fop: SQLITE_DBCONFIG_ENABLE_FKEY, Fmask: SQLITE_ForeignKeys}, + {Fop: SQLITE_DBCONFIG_ENABLE_TRIGGER, Fmask: SQLITE_EnableTrigger}, + {Fop: SQLITE_DBCONFIG_ENABLE_VIEW, Fmask: SQLITE_EnableView}, + {Fop: SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, Fmask: SQLITE_Fts3Tokenizer}, + {Fop: SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, Fmask: SQLITE_LoadExtension}, + {Fop: SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, Fmask: SQLITE_NoCkptOnClose}, + {Fop: SQLITE_DBCONFIG_ENABLE_QPSG, Fmask: SQLITE_EnableQPSG}, + {Fop: SQLITE_DBCONFIG_TRIGGER_EQP, Fmask: SQLITE_TriggerEQP}, + {Fop: SQLITE_DBCONFIG_RESET_DATABASE, Fmask: SQLITE_ResetDatabase}, + {Fop: SQLITE_DBCONFIG_DEFENSIVE, Fmask: SQLITE_Defensive}, + {Fop: SQLITE_DBCONFIG_WRITABLE_SCHEMA, Fmask: (U32(SQLITE_WriteSchema | SQLITE_NoSchemaError))}, + {Fop: SQLITE_DBCONFIG_LEGACY_ALTER_TABLE, Fmask: SQLITE_LegacyAlter}, + {Fop: SQLITE_DBCONFIG_DQS_DDL, Fmask: SQLITE_DqsDDL}, + {Fop: SQLITE_DBCONFIG_DQS_DML, Fmask: SQLITE_DqsDML}, + {Fop: SQLITE_DBCONFIG_LEGACY_FILE_FORMAT, Fmask: SQLITE_LegacyFileFmt}, + {Fop: SQLITE_DBCONFIG_TRUSTED_SCHEMA, Fmask: SQLITE_TrustedSchema}, } /* sqlite3.c:161939:9 */ // This is the default collating function named "BINARY" which is always @@ -144741,14 +142290,14 @@ func sqlite3Close(tls *libc.TLS, db uintptr, forceZombie int32) int32 { /* sqlit if !(db != 0) { // EVIDENCE-OF: R-63257-11740 Calling sqlite3_close() or // sqlite3_close_v2() with a NULL pointer argument is a harmless no-op. - return 0 + return SQLITE_OK } if !(Xsqlite3SafetyCheckSickOrOk(tls, db) != 0) { return Xsqlite3MisuseError(tls, 162200) } Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - if (int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & 0x08) != 0 { - (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, uint32(0x08), (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, db, uintptr(0)) + if (int32((*Sqlite3)(unsafe.Pointer(db)).FmTrace) & SQLITE_TRACE_CLOSE) != 0 { + (*(*func(*libc.TLS, U32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((db + 232 /* &.trace */ /* &.xV2 */))))(tls, SQLITE_TRACE_CLOSE, (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg, db, uintptr(0)) } // Force xDisconnect calls on all virtual tables @@ -144765,16 +142314,16 @@ func sqlite3Close(tls *libc.TLS, db uintptr, forceZombie int32) int32 { /* sqlit // Legacy behavior (sqlite3_close() behavior) is to return // SQLITE_BUSY if the connection can not be closed immediately. if !(forceZombie != 0) && (connectionIsBusy(tls, db) != 0) { - Xsqlite3ErrorWithMsg(tls, db, 5, + Xsqlite3ErrorWithMsg(tls, db, SQLITE_BUSY, ts+25005 /* "unable to close ..." */, 0) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 5 + return SQLITE_BUSY } // Convert the connection into a zombie and then close it. - (*Sqlite3)(unsafe.Pointer(db)).Fmagic = U32(0x64cffc7f) + (*Sqlite3)(unsafe.Pointer(db)).Fmagic = SQLITE_MAGIC_ZOMBIE Xsqlite3LeaveMutexAndCloseZombie(tls, db) - return 0 + return SQLITE_OK } // Two variations on the public interface for closing a database @@ -144805,7 +142354,7 @@ func Xsqlite3LeaveMutexAndCloseZombie(tls *libc.TLS, db uintptr) { /* sqlite3.c: // If there are outstanding sqlite3_stmt or sqlite3_backup objects // or if the connection has not yet been closed by sqlite3_close_v2(), // then just leave the mutex and return. - if ((*Sqlite3)(unsafe.Pointer(db)).Fmagic != U32(0x64cffc7f)) || (connectionIsBusy(tls, db) != 0) { + if ((*Sqlite3)(unsafe.Pointer(db)).Fmagic != SQLITE_MAGIC_ZOMBIE) || (connectionIsBusy(tls, db) != 0) { Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) return } @@ -144819,7 +142368,7 @@ func Xsqlite3LeaveMutexAndCloseZombie(tls *libc.TLS, db uintptr) { /* sqlite3.c: // any database schemas have been modified by an uncommitted transaction // they are reset. And that the required b-tree mutex is held to make // the pager rollback and schema reset an atomic operation. - Xsqlite3RollbackAll(tls, db, 0) + Xsqlite3RollbackAll(tls, db, SQLITE_OK) // Free any outstanding Savepoint structures. Xsqlite3CloseSavepoints(tls, db) @@ -144836,8 +142385,8 @@ func Xsqlite3LeaveMutexAndCloseZombie(tls *libc.TLS, db uintptr) { /* sqlite3.c: } } // Clear the TEMP schema separately and last - if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema != 0 { - Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema) + if (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema != 0 { + Xsqlite3SchemaClear(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema) } Xsqlite3VtabUnlockList(tls, db) @@ -144878,20 +142427,20 @@ func Xsqlite3LeaveMutexAndCloseZombie(tls *libc.TLS, db uintptr) { /* sqlite3.c: } Xsqlite3HashClear(tls, (db + 528 /* &.aModule */)) - Xsqlite3Error(tls, db, 0) // Deallocates any cached error strings. + Xsqlite3Error(tls, db, SQLITE_OK) // Deallocates any cached error strings. Xsqlite3ValueFree(tls, (*Sqlite3)(unsafe.Pointer(db)).FpErr) Xsqlite3CloseExtensions(tls, db) - (*Sqlite3)(unsafe.Pointer(db)).Fmagic = 0xb5357930 + (*Sqlite3)(unsafe.Pointer(db)).Fmagic = SQLITE_MAGIC_ERROR // The temp-database schema is allocated differently from the other schema // objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()). // So it needs to be freed here. Todo: Why not roll the temp schema into // the same sqliteMalloc() as the one that allocates the database // structure? - Xsqlite3DbFree(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(1)*32)).FpSchema) + Xsqlite3DbFree(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+1*32)).FpSchema) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - (*Sqlite3)(unsafe.Pointer(db)).Fmagic = 0x9f3c2d33 + (*Sqlite3)(unsafe.Pointer(db)).Fmagic = SQLITE_MAGIC_CLOSED Xsqlite3_mutex_free(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) if (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbMalloced != 0 { @@ -144919,7 +142468,7 @@ func Xsqlite3RollbackAll(tls *libc.TLS, db uintptr, tripCode int32) { /* sqlite3 // the database rollback and schema reset, which can cause false // corruption reports in some cases. Xsqlite3BtreeEnterAll(tls, db) - schemaChange = (libc.Bool32((((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & U32(0x0001)) != U32(0)) && (int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0))) + schemaChange = (libc.Bool32((((*Sqlite3)(unsafe.Pointer(db)).FmDbFlags & DBFLAG_SchemaChange) != U32(0)) && (int32((*Sqlite3)(unsafe.Pointer(db)).Finit.Fbusy) == 0))) for i = 0; i < (*Sqlite3)(unsafe.Pointer(db)).FnDb; i++ { var p uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32)).FpBt @@ -144942,7 +142491,7 @@ func Xsqlite3RollbackAll(tls *libc.TLS, db uintptr, tripCode int32) { /* sqlite3 // Any deferred constraint violations have now been resolved. (*Sqlite3)(unsafe.Pointer(db)).FnDeferredCons = int64(0) (*Sqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = int64(0) - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (^libc.Uint64(uint64(0x00080000))) + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) &= (libc.CplUint64(SQLITE_DeferFKs)) // If one has been configured, invoke the rollback-hook callback if ((*Sqlite3)(unsafe.Pointer(db)).FxRollbackCallback != 0) && ((inTrans != 0) || !(int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) != 0)) { @@ -144966,259 +142515,259 @@ __1: } { switch rc { - case 0: + case SQLITE_OK: zName = ts + 25073 /* "SQLITE_OK" */ break - case 1: + case SQLITE_ERROR: zName = ts + 25083 /* "SQLITE_ERROR" */ break - case (1 | (int32(3) << 8)): + case (SQLITE_ERROR | (int32(3) << 8)): zName = ts + 25096 /* "SQLITE_ERROR_SNA..." */ break - case 2: + case SQLITE_INTERNAL: zName = ts + 25118 /* "SQLITE_INTERNAL" */ break - case 3: + case SQLITE_PERM: zName = ts + 25134 /* "SQLITE_PERM" */ break - case 4: + case SQLITE_ABORT: zName = ts + 25146 /* "SQLITE_ABORT" */ break - case (4 | (int32(2) << 8)): + case (SQLITE_ABORT | (int32(2) << 8)): zName = ts + 25159 /* "SQLITE_ABORT_ROL..." */ break - case 5: + case SQLITE_BUSY: zName = ts + 25181 /* "SQLITE_BUSY" */ break - case (5 | (int32(1) << 8)): + case (SQLITE_BUSY | (int32(1) << 8)): zName = ts + 25193 /* "SQLITE_BUSY_RECO..." */ break - case (5 | (int32(2) << 8)): + case (SQLITE_BUSY | (int32(2) << 8)): zName = ts + 25214 /* "SQLITE_BUSY_SNAP..." */ break - case 6: + case SQLITE_LOCKED: zName = ts + 25235 /* "SQLITE_LOCKED" */ break - case (6 | (int32(1) << 8)): + case (SQLITE_LOCKED | (int32(1) << 8)): zName = ts + 25249 /* "SQLITE_LOCKED_SH..." */ break - case 7: + case SQLITE_NOMEM: zName = ts + 25275 /* "SQLITE_NOMEM" */ break - case 8: + case SQLITE_READONLY: zName = ts + 25288 /* "SQLITE_READONLY" */ break - case (8 | (int32(1) << 8)): + case (SQLITE_READONLY | (int32(1) << 8)): zName = ts + 25304 /* "SQLITE_READONLY_..." */ break - case (8 | (int32(5) << 8)): + case (SQLITE_READONLY | (int32(5) << 8)): zName = ts + 25329 /* "SQLITE_READONLY_..." */ break - case (8 | (int32(3) << 8)): + case (SQLITE_READONLY | (int32(3) << 8)): zName = ts + 25354 /* "SQLITE_READONLY_..." */ break - case (8 | (int32(4) << 8)): + case (SQLITE_READONLY | (int32(4) << 8)): zName = ts + 25379 /* "SQLITE_READONLY_..." */ break - case (8 | (int32(6) << 8)): + case (SQLITE_READONLY | (int32(6) << 8)): zName = ts + 25403 /* "SQLITE_READONLY_..." */ break - case 9: + case SQLITE_INTERRUPT: zName = ts + 25429 /* "SQLITE_INTERRUPT" */ break - case 10: + case SQLITE_IOERR: zName = ts + 25446 /* "SQLITE_IOERR" */ break - case (10 | (int32(1) << 8)): + case (SQLITE_IOERR | (int32(1) << 8)): zName = ts + 25459 /* "SQLITE_IOERR_REA..." */ break - case (10 | (int32(2) << 8)): + case (SQLITE_IOERR | (int32(2) << 8)): zName = ts + 25477 /* "SQLITE_IOERR_SHO..." */ break - case (10 | (int32(3) << 8)): + case (SQLITE_IOERR | (int32(3) << 8)): zName = ts + 25501 /* "SQLITE_IOERR_WRI..." */ break - case (10 | (int32(4) << 8)): + case (SQLITE_IOERR | (int32(4) << 8)): zName = ts + 25520 /* "SQLITE_IOERR_FSY..." */ break - case (10 | (int32(5) << 8)): + case (SQLITE_IOERR | (int32(5) << 8)): zName = ts + 25539 /* "SQLITE_IOERR_DIR..." */ break - case (10 | (int32(6) << 8)): + case (SQLITE_IOERR | (int32(6) << 8)): zName = ts + 25562 /* "SQLITE_IOERR_TRU..." */ break - case (10 | (int32(7) << 8)): + case (SQLITE_IOERR | (int32(7) << 8)): zName = ts + 25584 /* "SQLITE_IOERR_FST..." */ break - case (10 | (int32(8) << 8)): + case (SQLITE_IOERR | (int32(8) << 8)): zName = ts + 25603 /* "SQLITE_IOERR_UNL..." */ break - case (10 | (int32(9) << 8)): + case (SQLITE_IOERR | (int32(9) << 8)): zName = ts + 25623 /* "SQLITE_IOERR_RDL..." */ break - case (10 | (int32(10) << 8)): + case (SQLITE_IOERR | (int32(10) << 8)): zName = ts + 25643 /* "SQLITE_IOERR_DEL..." */ break - case (10 | (int32(12) << 8)): + case (SQLITE_IOERR | (int32(12) << 8)): zName = ts + 25663 /* "SQLITE_IOERR_NOM..." */ break - case (10 | (int32(13) << 8)): + case (SQLITE_IOERR | (int32(13) << 8)): zName = ts + 25682 /* "SQLITE_IOERR_ACC..." */ break - case (10 | (int32(14) << 8)): + case (SQLITE_IOERR | (int32(14) << 8)): zName = ts + 25702 /* "SQLITE_IOERR_CHE..." */ break - case (10 | (int32(15) << 8)): + case (SQLITE_IOERR | (int32(15) << 8)): zName = ts + 25733 /* "SQLITE_IOERR_LOC..." */ break - case (10 | (int32(16) << 8)): + case (SQLITE_IOERR | (int32(16) << 8)): zName = ts + 25751 /* "SQLITE_IOERR_CLO..." */ break - case (10 | (int32(17) << 8)): + case (SQLITE_IOERR | (int32(17) << 8)): zName = ts + 25770 /* "SQLITE_IOERR_DIR..." */ break - case (10 | (int32(18) << 8)): + case (SQLITE_IOERR | (int32(18) << 8)): zName = ts + 25793 /* "SQLITE_IOERR_SHM..." */ break - case (10 | (int32(19) << 8)): + case (SQLITE_IOERR | (int32(19) << 8)): zName = ts + 25814 /* "SQLITE_IOERR_SHM..." */ break - case (10 | (int32(20) << 8)): + case (SQLITE_IOERR | (int32(20) << 8)): zName = ts + 25835 /* "SQLITE_IOERR_SHM..." */ break - case (10 | (int32(21) << 8)): + case (SQLITE_IOERR | (int32(21) << 8)): zName = ts + 25856 /* "SQLITE_IOERR_SHM..." */ break - case (10 | (int32(22) << 8)): + case (SQLITE_IOERR | (int32(22) << 8)): zName = ts + 25876 /* "SQLITE_IOERR_SEE..." */ break - case (10 | (int32(23) << 8)): + case (SQLITE_IOERR | (int32(23) << 8)): zName = ts + 25894 /* "SQLITE_IOERR_DEL..." */ break - case (10 | (int32(24) << 8)): + case (SQLITE_IOERR | (int32(24) << 8)): zName = ts + 25920 /* "SQLITE_IOERR_MMA..." */ break - case (10 | (int32(25) << 8)): + case (SQLITE_IOERR | (int32(25) << 8)): zName = ts + 25938 /* "SQLITE_IOERR_GET..." */ break - case (10 | (int32(26) << 8)): + case (SQLITE_IOERR | (int32(26) << 8)): zName = ts + 25963 /* "SQLITE_IOERR_CON..." */ break - case 11: + case SQLITE_CORRUPT: zName = ts + 25985 /* "SQLITE_CORRUPT" */ break - case (11 | (int32(1) << 8)): + case (SQLITE_CORRUPT | (int32(1) << 8)): zName = ts + 26000 /* "SQLITE_CORRUPT_V..." */ break - case 12: + case SQLITE_NOTFOUND: zName = ts + 26020 /* "SQLITE_NOTFOUND" */ break - case 13: + case SQLITE_FULL: zName = ts + 26036 /* "SQLITE_FULL" */ break - case 14: + case SQLITE_CANTOPEN: zName = ts + 26048 /* "SQLITE_CANTOPEN" */ break - case (14 | (int32(1) << 8)): + case (SQLITE_CANTOPEN | (int32(1) << 8)): zName = ts + 26064 /* "SQLITE_CANTOPEN_..." */ break - case (14 | (int32(2) << 8)): + case (SQLITE_CANTOPEN | (int32(2) << 8)): zName = ts + 26090 /* "SQLITE_CANTOPEN_..." */ break - case (14 | (int32(3) << 8)): + case (SQLITE_CANTOPEN | (int32(3) << 8)): zName = ts + 26112 /* "SQLITE_CANTOPEN_..." */ break - case (14 | (int32(4) << 8)): + case (SQLITE_CANTOPEN | (int32(4) << 8)): zName = ts + 26137 /* "SQLITE_CANTOPEN_..." */ break - case (14 | (int32(6) << 8)): + case (SQLITE_CANTOPEN | (int32(6) << 8)): zName = ts + 26162 /* "SQLITE_CANTOPEN_..." */ break - case 15: + case SQLITE_PROTOCOL: zName = ts + 26186 /* "SQLITE_PROTOCOL" */ break - case 16: + case SQLITE_EMPTY: zName = ts + 26202 /* "SQLITE_EMPTY" */ break - case 17: + case SQLITE_SCHEMA: zName = ts + 26215 /* "SQLITE_SCHEMA" */ break - case 18: + case SQLITE_TOOBIG: zName = ts + 26229 /* "SQLITE_TOOBIG" */ break - case 19: + case SQLITE_CONSTRAINT: zName = ts + 26243 /* "SQLITE_CONSTRAIN..." */ break - case (19 | (int32(8) << 8)): + case (SQLITE_CONSTRAINT | (int32(8) << 8)): zName = ts + 26261 /* "SQLITE_CONSTRAIN..." */ break - case (19 | (int32(7) << 8)): + case (SQLITE_CONSTRAINT | (int32(7) << 8)): zName = ts + 26286 /* "SQLITE_CONSTRAIN..." */ break - case (19 | (int32(3) << 8)): + case (SQLITE_CONSTRAINT | (int32(3) << 8)): zName = ts + 26312 /* "SQLITE_CONSTRAIN..." */ break - case (19 | (int32(1) << 8)): + case (SQLITE_CONSTRAINT | (int32(1) << 8)): zName = ts + 26341 /* "SQLITE_CONSTRAIN..." */ break - case (19 | (int32(6) << 8)): + case (SQLITE_CONSTRAINT | (int32(6) << 8)): zName = ts + 26365 /* "SQLITE_CONSTRAIN..." */ break - case (19 | (int32(5) << 8)): + case (SQLITE_CONSTRAINT | (int32(5) << 8)): zName = ts + 26394 /* "SQLITE_CONSTRAIN..." */ break - case (19 | (int32(2) << 8)): + case (SQLITE_CONSTRAINT | (int32(2) << 8)): zName = ts + 26420 /* "SQLITE_CONSTRAIN..." */ break - case (19 | (int32(9) << 8)): + case (SQLITE_CONSTRAINT | (int32(9) << 8)): zName = ts + 26449 /* "SQLITE_CONSTRAIN..." */ break - case (19 | (int32(4) << 8)): + case (SQLITE_CONSTRAINT | (int32(4) << 8)): zName = ts + 26472 /* "SQLITE_CONSTRAIN..." */ break - case (19 | (int32(10) << 8)): + case (SQLITE_CONSTRAINT | (int32(10) << 8)): zName = ts + 26499 /* "SQLITE_CONSTRAIN..." */ break - case 20: + case SQLITE_MISMATCH: zName = ts + 26523 /* "SQLITE_MISMATCH" */ break - case 21: + case SQLITE_MISUSE: zName = ts + 26539 /* "SQLITE_MISUSE" */ break - case 22: + case SQLITE_NOLFS: zName = ts + 26553 /* "SQLITE_NOLFS" */ break - case 23: + case SQLITE_AUTH: zName = ts + 26566 /* "SQLITE_AUTH" */ break - case 24: + case SQLITE_FORMAT: zName = ts + 26578 /* "SQLITE_FORMAT" */ break - case 25: + case SQLITE_RANGE: zName = ts + 26592 /* "SQLITE_RANGE" */ break - case 26: + case SQLITE_NOTADB: zName = ts + 26605 /* "SQLITE_NOTADB" */ break - case 100: + case SQLITE_ROW: zName = ts + 26619 /* "SQLITE_ROW" */ break - case 27: + case SQLITE_NOTICE: zName = ts + 26630 /* "SQLITE_NOTICE" */ break - case (27 | (int32(1) << 8)): + case (SQLITE_NOTICE | (int32(1) << 8)): zName = ts + 26644 /* "SQLITE_NOTICE_RE..." */ break - case (27 | (int32(2) << 8)): + case (SQLITE_NOTICE | (int32(2) << 8)): zName = ts + 26670 /* "SQLITE_NOTICE_RE..." */ break - case 28: + case SQLITE_WARNING: zName = ts + 26701 /* "SQLITE_WARNING" */ break - case (28 | (int32(1) << 8)): + case (SQLITE_WARNING | (int32(1) << 8)): zName = ts + 26716 /* "SQLITE_WARNING_A..." */ break - case 101: + case SQLITE_DONE: zName = ts + 26741 /* "SQLITE_DONE" */ break } @@ -145246,19 +142795,19 @@ var zBuf [50]int8 /* sqlite3.c:162533:17: */ func Xsqlite3ErrStr(tls *libc.TLS, rc int32) uintptr { /* sqlite3.c:162545:27: */ var zErr uintptr = ts + 26772 /* "unknown error" */ switch rc { - case (4 | (int32(2) << 8)): + case (SQLITE_ABORT | (int32(2) << 8)): { zErr = ts + 26786 /* "abort due to ROL..." */ break } - case 100: + case SQLITE_ROW: { zErr = ts + 26808 /* "another row avai..." */ break } - case 101: + case SQLITE_DONE: { zErr = ts + 26830 /* "no more rows ava..." */ break @@ -145372,7 +142921,7 @@ func Xsqlite3_busy_handler(tls *libc.TLS, db uintptr, xBusy uintptr, pArg uintpt (*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 (*Sqlite3)(unsafe.Pointer(db)).FbusyTimeout = 0 Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // This routine sets the progress callback for an Sqlite database to the @@ -145404,7 +142953,7 @@ func Xsqlite3_busy_timeout(tls *libc.TLS, db uintptr, ms int32) int32 { /* sqlit } else { Xsqlite3_busy_handler(tls, db, uintptr(0), uintptr(0)) } - return 0 + return SQLITE_OK } // Cause any pending operation to stop at its earliest opportunity. @@ -145426,18 +142975,18 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i ((xSFunc != uintptr(0)) && (xFinal != uintptr(0)))) || // Not both xSFunc and xFinal ((libc.Bool32(xFinal == uintptr(0))) != (libc.Bool32(xStep == uintptr(0))))) || // Both or neither of xFinal and xStep ((libc.Bool32(xValue == uintptr(0))) != (libc.Bool32(xInverse == uintptr(0))))) || // Both or neither of xValue, xInverse - ((nArg < -1) || (nArg > 127))) || + ((nArg < -1) || (nArg > SQLITE_MAX_FUNCTION_ARG))) || (255 < (libc.AssignInt32(&nName, Xsqlite3Strlen30(tls, zFunctionName)))) { return Xsqlite3MisuseError(tls, 162797) } - extraFlags = (enc & (((0x000000800 | 0x000080000) | 0x000100000) | 0x000200000)) - enc = enc & (0x0003 | 5) + extraFlags = (enc & (((SQLITE_DETERMINISTIC | SQLITE_DIRECTONLY) | SQLITE_SUBTYPE) | SQLITE_INNOCUOUS)) + enc = enc & (SQLITE_FUNC_ENCMASK | SQLITE_ANY) // The SQLITE_INNOCUOUS flag is the same bit as SQLITE_FUNC_UNSAFE. But // the meaning is inverted. So flip the bit. - extraFlags = extraFlags ^ (0x00200000) + extraFlags = extraFlags ^ (SQLITE_FUNC_UNSAFE) // If SQLITE_UTF16 is specified as the encoding type, transform this // to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the @@ -145445,22 +142994,22 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i // // If SQLITE_ANY is specified, add three versions of the function // to the hash table. - if enc == 4 { - enc = 2 - } else if enc == 5 { + if enc == SQLITE_UTF16 { + enc = SQLITE_UTF16LE + } else if enc == SQLITE_ANY { var rc int32 rc = Xsqlite3CreateFunc(tls, db, zFunctionName, nArg, - ((1 | extraFlags) ^ 0x00200000), + ((SQLITE_UTF8 | extraFlags) ^ SQLITE_FUNC_UNSAFE), pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3CreateFunc(tls, db, zFunctionName, nArg, - ((2 | extraFlags) ^ 0x00200000), + ((SQLITE_UTF16LE | extraFlags) ^ SQLITE_FUNC_UNSAFE), pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor) } - if rc != 0 { + if rc != SQLITE_OK { return rc } - enc = 3 + enc = SQLITE_UTF16BE } // Check if an existing function is being overridden or deleted. If so, @@ -145468,12 +143017,12 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i // is being overridden/deleted but there are no active VMs, allow the // operation to continue but invalidate all precompiled statements. p = Xsqlite3FindFunction(tls, db, zFunctionName, nArg, U8(enc), uint8(0)) - if ((p != 0) && (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & U32(0x0003)) == U32(enc))) && (int32((*FuncDef)(unsafe.Pointer(p)).FnArg) == nArg) { + if ((p != 0) && (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & SQLITE_FUNC_ENCMASK) == U32(enc))) && (int32((*FuncDef)(unsafe.Pointer(p)).FnArg) == nArg) { if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive != 0 { - Xsqlite3ErrorWithMsg(tls, db, 5, + Xsqlite3ErrorWithMsg(tls, db, SQLITE_BUSY, ts+27328 /* "unable to delete..." */, 0) - return 5 + return SQLITE_BUSY } else { Xsqlite3ExpirePreparedStatements(tls, db, 0) } @@ -145482,7 +143031,7 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i p = Xsqlite3FindFunction(tls, db, zFunctionName, nArg, U8(enc), uint8(1)) if !(p != 0) { - return 7 + return SQLITE_NOMEM } // If an older version of the function with a configured destructor is @@ -145493,7 +143042,7 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i (*FuncDestructor)(unsafe.Pointer(pDestructor)).FnRef++ } *(*uintptr)(unsafe.Pointer(p + 64 /* &.u */)) = pDestructor - (*FuncDef)(unsafe.Pointer(p)).FfuncFlags = (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & U32(0x0003)) | U32(extraFlags)) + (*FuncDef)(unsafe.Pointer(p)).FfuncFlags = (((*FuncDef)(unsafe.Pointer(p)).FfuncFlags & SQLITE_FUNC_ENCMASK) | U32(extraFlags)) (*FuncDef)(unsafe.Pointer(p)).FxSFunc = func() uintptr { if xSFunc != 0 { @@ -145506,7 +143055,7 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i (*FuncDef)(unsafe.Pointer(p)).FxInverse = xInverse (*FuncDef)(unsafe.Pointer(p)).FpUserData = pUserData (*FuncDef)(unsafe.Pointer(p)).FnArg = I8(U16(nArg)) - return 0 + return SQLITE_OK } // Worker function used by utf-8 APIs that create new functions: @@ -145517,7 +143066,7 @@ func Xsqlite3CreateFunc(tls *libc.TLS, db uintptr, zFunctionName uintptr, nArg i func createFunctionApi(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, xSFunc uintptr, xStep uintptr, xFinal uintptr, xValue uintptr, xInverse uintptr, xDestroy uintptr) int32 { /* sqlite3.c:162891:12: */ var rc int32 var pArg uintptr - rc = 1 + rc = SQLITE_ERROR pArg = uintptr(0) Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -145577,7 +143126,7 @@ func Xsqlite3_create_function16(tls *libc.TLS, db uintptr, zFunctionName uintptr Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - zFunc8 = Xsqlite3Utf16to8(tls, db, zFunctionName, -1, uint8(2)) + zFunc8 = Xsqlite3Utf16to8(tls, db, zFunctionName, -1, SQLITE_UTF16LE) rc = Xsqlite3CreateFunc(tls, db, zFunc8, nArg, eTextRep, p, xSFunc, xStep, xFinal, uintptr(0), uintptr(0), uintptr(0)) Xsqlite3DbFree(tls, db, zFunc8) rc = Xsqlite3ApiExit(tls, db, rc) @@ -145620,16 +143169,16 @@ func Xsqlite3_overload_function(tls *libc.TLS, db uintptr, zName uintptr, nArg i var zCopy uintptr Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - rc = (libc.Bool32(Xsqlite3FindFunction(tls, db, zName, nArg, uint8(1), uint8(0)) != uintptr(0))) + rc = (libc.Bool32(Xsqlite3FindFunction(tls, db, zName, nArg, SQLITE_UTF8, uint8(0)) != uintptr(0))) Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) if rc != 0 { - return 0 + return SQLITE_OK } zCopy = Xsqlite3_mprintf(tls, zName, 0) if zCopy == uintptr(0) { - return 7 + return SQLITE_NOMEM } - return Xsqlite3_create_function_v2(tls, db, zName, nArg, 1, + return Xsqlite3_create_function_v2(tls, db, zName, nArg, SQLITE_UTF8, zCopy, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{sqlite3InvalidFunction})), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) @@ -145648,7 +143197,7 @@ func Xsqlite3_trace(tls *libc.TLS, db uintptr, xTrace uintptr, pArg uintptr) uin pOld = (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg (*Sqlite3)(unsafe.Pointer(db)).FmTrace = func() uint8 { if xTrace != 0 { - return uint8(0x40) + return SQLITE_TRACE_LEGACY } return uint8(0) }() @@ -145671,7 +143220,7 @@ func Xsqlite3_trace_v2(tls *libc.TLS, db uintptr, mTrace uint32, xTrace uintptr, *(*uintptr)(unsafe.Pointer(db + 232 /* &.trace */)) = xTrace (*Sqlite3)(unsafe.Pointer(db)).FpTraceArg = pArg Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // Register a profile function. The pArg from the previously registered @@ -145687,9 +143236,9 @@ func Xsqlite3_profile(tls *libc.TLS, db uintptr, xProfile uintptr, pArg uintptr) pOld = (*Sqlite3)(unsafe.Pointer(db)).FpProfileArg (*Sqlite3)(unsafe.Pointer(db)).FxProfile = xProfile (*Sqlite3)(unsafe.Pointer(db)).FpProfileArg = pArg - *(*U8)(unsafe.Pointer(db + 104 /* &.mTrace */)) &= U8((0x0f)) + *(*U8)(unsafe.Pointer(db + 104 /* &.mTrace */)) &= U8((SQLITE_TRACE_NONLEGACY_MASK)) if (*Sqlite3)(unsafe.Pointer(db)).FxProfile != 0 { - *(*U8)(unsafe.Pointer(db + 104 /* &.mTrace */)) |= U8((0x80)) + *(*U8)(unsafe.Pointer(db + 104 /* &.mTrace */)) |= U8((SQLITE_TRACE_XPROFILE)) } Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) return pOld @@ -145757,7 +143306,7 @@ func Xsqlite3WalDefaultHook(tls *libc.TLS, pClientData uintptr, db uintptr, zDb Xsqlite3_wal_checkpoint(tls, db, zDb) Xsqlite3EndBenignMalloc(tls) } - return 0 + return SQLITE_OK } // Configure an sqlite3_wal_hook() callback to automatically checkpoint @@ -145777,7 +143326,7 @@ func Xsqlite3_wal_autocheckpoint(tls *libc.TLS, db uintptr, nFrame int32) int32 } else { Xsqlite3_wal_hook(tls, db, uintptr(0), uintptr(0)) } - return 0 + return SQLITE_OK } // Register a callback to be invoked each time a transaction is written @@ -145797,8 +143346,8 @@ func Xsqlite3_wal_checkpoint_v2(tls *libc.TLS, db uintptr, zDb uintptr, eMode in bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 // Return code - var iDb int32 = 10 // sqlite3.aDb[] index of db to checkpoint + var rc int32 // Return code + var iDb int32 = SQLITE_MAX_ATTACHED // sqlite3.aDb[] index of db to checkpoint // Initialize the output variables to -1 in case an error occurs. if pnLog != 0 { @@ -145808,19 +143357,19 @@ func Xsqlite3_wal_checkpoint_v2(tls *libc.TLS, db uintptr, zDb uintptr, eMode in *(*int32)(unsafe.Pointer(pnCkpt)) = -1 } - if (eMode < 0) || (eMode > 3) { + if (eMode < SQLITE_CHECKPOINT_PASSIVE) || (eMode > SQLITE_CHECKPOINT_TRUNCATE) { // EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint // mode: - return 21 + return SQLITE_MISUSE } Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - if (zDb != 0) && (*(*int8)(unsafe.Pointer(zDb + uintptr(0))) != 0) { + if (zDb != 0) && (*(*int8)(unsafe.Pointer(zDb)) != 0) { iDb = Xsqlite3FindDbName(tls, db, zDb) } if iDb < 0 { - rc = 1 - Xsqlite3ErrorWithMsg(tls, db, 1, ts+27442 /* "unknown database..." */, libc.VaList(bp, zDb)) + rc = SQLITE_ERROR + Xsqlite3ErrorWithMsg(tls, db, SQLITE_ERROR, ts+27442 /* "unknown database..." */, libc.VaList(bp, zDb)) } else { (*Sqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 rc = Xsqlite3Checkpoint(tls, db, iDb, eMode, pnLog, pnCkpt) @@ -145844,7 +143393,7 @@ func Xsqlite3_wal_checkpoint_v2(tls *libc.TLS, db uintptr, zDb uintptr, eMode in func Xsqlite3_wal_checkpoint(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* sqlite3.c:163397:16: */ // EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to // sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). - return Xsqlite3_wal_checkpoint_v2(tls, db, zDb, 0, uintptr(0), uintptr(0)) + return Xsqlite3_wal_checkpoint_v2(tls, db, zDb, SQLITE_CHECKPOINT_PASSIVE, uintptr(0), uintptr(0)) } // Run a checkpoint on database iDb. This is a no-op if database iDb is @@ -145866,24 +143415,24 @@ func Xsqlite3_wal_checkpoint(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* // Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL, RESTART // or TRUNCATE. func Xsqlite3Checkpoint(tls *libc.TLS, db uintptr, iDb int32, eMode int32, pnLog uintptr, pnCkpt uintptr) int32 { /* sqlite3.c:163424:20: */ - var rc int32 = 0 // Return code - var i int32 // Used to iterate through attached dbs - var bBusy int32 = 0 // True if SQLITE_BUSY has been encountered + var rc int32 = SQLITE_OK // Return code + var i int32 // Used to iterate through attached dbs + var bBusy int32 = 0 // True if SQLITE_BUSY has been encountered - for i = 0; (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb) && (rc == 0); i++ { - if (i == iDb) || (iDb == 10) { + for i = 0; (i < (*Sqlite3)(unsafe.Pointer(db)).FnDb) && (rc == SQLITE_OK); i++ { + if (i == iDb) || (iDb == SQLITE_MAX_ATTACHED) { rc = Xsqlite3BtreeCheckpoint(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(i)*32)).FpBt, eMode, pnLog, pnCkpt) pnLog = uintptr(0) pnCkpt = uintptr(0) - if rc == 5 { + if rc == SQLITE_BUSY { bBusy = 1 - rc = 0 + rc = SQLITE_OK } } } - if (rc == 0) && (bBusy != 0) { - return 5 + if (rc == SQLITE_OK) && (bBusy != 0) { + return SQLITE_BUSY } return rc } @@ -145914,14 +143463,14 @@ func Xsqlite3TempInMemory(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:163468 func Xsqlite3_errmsg(tls *libc.TLS, db uintptr) uintptr { /* sqlite3.c:163489:23: */ var z uintptr if !(db != 0) { - return Xsqlite3ErrStr(tls, 7) + return Xsqlite3ErrStr(tls, SQLITE_NOMEM) } if !(Xsqlite3SafetyCheckSickOrOk(tls, db) != 0) { return Xsqlite3ErrStr(tls, Xsqlite3MisuseError(tls, 163495)) } Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) if (*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { - z = Xsqlite3ErrStr(tls, 7) + z = Xsqlite3ErrStr(tls, SQLITE_NOMEM) } else { if (*Sqlite3)(unsafe.Pointer(db)).FerrCode != 0 { @@ -145983,7 +143532,7 @@ func Xsqlite3_errcode(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:163559:16: return Xsqlite3MisuseError(tls, 163561) } if !(db != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { - return 7 + return SQLITE_NOMEM } return ((*Sqlite3)(unsafe.Pointer(db)).FerrCode & (*Sqlite3)(unsafe.Pointer(db)).FerrMask) } @@ -145993,7 +143542,7 @@ func Xsqlite3_extended_errcode(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:1 return Xsqlite3MisuseError(tls, 163570) } if !(db != 0) || ((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { - return 7 + return SQLITE_NOMEM } return (*Sqlite3)(unsafe.Pointer(db)).FerrCode } @@ -146023,10 +143572,10 @@ func createCollation(tls *libc.TLS, db uintptr, zName uintptr, enc U8, pCtx uint // SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. enc2 = int32(enc) - if (enc2 == 4) || (enc2 == 8) { - enc2 = 2 + if (enc2 == SQLITE_UTF16) || (enc2 == SQLITE_UTF16_ALIGNED) { + enc2 = SQLITE_UTF16LE } - if (enc2 < 1) || (enc2 > 3) { + if (enc2 < SQLITE_UTF8) || (enc2 > SQLITE_UTF16BE) { return Xsqlite3MisuseError(tls, 163618) } @@ -146036,9 +143585,9 @@ func createCollation(tls *libc.TLS, db uintptr, zName uintptr, enc U8, pCtx uint pColl = Xsqlite3FindCollSeq(tls, db, U8(enc2), zName, 0) if (pColl != 0) && ((*CollSeq)(unsafe.Pointer(pColl)).FxCmp != 0) { if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive != 0 { - Xsqlite3ErrorWithMsg(tls, db, 5, + Xsqlite3ErrorWithMsg(tls, db, SQLITE_BUSY, ts+27463 /* "unable to delete..." */, 0) - return 5 + return SQLITE_BUSY } Xsqlite3ExpirePreparedStatements(tls, db, 0) @@ -146047,7 +143596,7 @@ func createCollation(tls *libc.TLS, db uintptr, zName uintptr, enc U8, pCtx uint // then any copies made by synthCollSeq() need to be invalidated. // Also, collation destructor - CollSeq.xDel() - function may need // to be called. - if (int32((*CollSeq)(unsafe.Pointer(pColl)).Fenc) & ^libc.Int32(8)) == enc2 { + if (int32((*CollSeq)(unsafe.Pointer(pColl)).Fenc) & libc.CplInt32(SQLITE_UTF16_ALIGNED)) == enc2 { var aColl uintptr = Xsqlite3HashFind(tls, (db + 600 /* &.aCollSeq */), zName) var j int32 for j = 0; j < 3; j++ { @@ -146064,32 +143613,32 @@ func createCollation(tls *libc.TLS, db uintptr, zName uintptr, enc U8, pCtx uint pColl = Xsqlite3FindCollSeq(tls, db, U8(enc2), zName, 1) if pColl == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*CollSeq)(unsafe.Pointer(pColl)).FxCmp = xCompare (*CollSeq)(unsafe.Pointer(pColl)).FpUser = pCtx (*CollSeq)(unsafe.Pointer(pColl)).FxDel = xDel - (*CollSeq)(unsafe.Pointer(pColl)).Fenc = (U8(enc2 | (int32(enc) & 8))) - Xsqlite3Error(tls, db, 0) - return 0 + (*CollSeq)(unsafe.Pointer(pColl)).Fenc = (U8(enc2 | (int32(enc) & SQLITE_UTF16_ALIGNED))) + Xsqlite3Error(tls, db, SQLITE_OK) + return SQLITE_OK } // This array defines hard upper bounds on limit values. The // initializer must be kept in sync with the SQLITE_LIMIT_* // #defines in sqlite3.h. var aHardLimit = [12]int32{ - 1000000000, - 1000000000, - 2000, - 1000, - 500, - 250000000, - 127, - 10, - 50000, - 32766, // IMP: R-38091-32352 - 1000, - 8, + SQLITE_MAX_LENGTH, + SQLITE_MAX_SQL_LENGTH, + SQLITE_MAX_COLUMN, + SQLITE_MAX_EXPR_DEPTH, + SQLITE_MAX_COMPOUND_SELECT, + SQLITE_MAX_VDBE_OP, + SQLITE_MAX_FUNCTION_ARG, + SQLITE_MAX_ATTACHED, + SQLITE_MAX_LIKE_PATTERN_LENGTH, + SQLITE_MAX_VARIABLE_NUMBER, // IMP: R-38091-32352 + SQLITE_MAX_TRIGGER_DEPTH, + SQLITE_MAX_WORKER_THREADS, } /* sqlite3.c:163671:18 */ // Make sure the hard limits are set to reasonable values @@ -146110,7 +143659,7 @@ func Xsqlite3_limit(tls *libc.TLS, db uintptr, limitId int32, newLimit int32) in // macro called SQLITE_MAX_NAME. (The "_LIMIT_" in the name is changed to // "_MAX_".) - if (limitId < 0) || (limitId >= (11 + 1)) { + if (limitId < 0) || (limitId >= (SQLITE_LIMIT_WORKER_THREADS + 1)) { return -1 } oldLimit = *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(limitId)*4)) @@ -146173,12 +143722,12 @@ func Xsqlite3ParseUri(tls *libc.TLS, zDefaultVfs uintptr, zUri uintptr, pFlags u var iIn int32 // Input character index var iOut int32 // Output character index var nByte U64 - rc = 0 + rc = SQLITE_OK flags = *(*uint32)(unsafe.Pointer(pFlags)) zVfs = zDefaultVfs nUri = Xsqlite3Strlen30(tls, zUri) - if !(((((flags & uint32(0x00000040)) != 0) || // IMP: R-48725-32206 + if !(((((flags & SQLITE_OPEN_URI) != 0) || // IMP: R-48725-32206 (Xsqlite3Config.FbOpenUri != 0)) && // IMP: R-51689-46548 (nUri >= 5)) && (libc.Xmemcmp(tls, zUri, ts+27531 /* "file:" */, uint64(5)) == 0)) { goto __1 @@ -146188,7 +143737,7 @@ func Xsqlite3ParseUri(tls *libc.TLS, zDefaultVfs uintptr, zUri uintptr, pFlags u // Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen // method that there may be extra parameters following the file-name. - flags = flags | (uint32(0x00000040)) + flags = flags | (SQLITE_OPEN_URI) iIn = 0 __3: @@ -146207,7 +143756,7 @@ __5: if !(!(zFile != 0)) { goto __6 } - return 7 + return SQLITE_NOMEM __6: ; @@ -146216,7 +143765,7 @@ __6: iIn = 5 // Discard the scheme and authority segments of the URI. - if !((int32(*(*int8)(unsafe.Pointer(zUri + uintptr(5)))) == '/') && (int32(*(*int8)(unsafe.Pointer(zUri + uintptr(6)))) == '/')) { + if !((int32(*(*int8)(unsafe.Pointer(zUri + 5))) == '/') && (int32(*(*int8)(unsafe.Pointer(zUri + 6))) == '/')) { goto __7 } iIn = 7 @@ -146228,12 +143777,12 @@ __8: goto __8 __9: ; - if !((iIn != 7) && ((iIn != 16) || (libc.Xmemcmp(tls, ts+27537 /* "localhost" */, (zUri+uintptr(7)), uint64(9)) != 0))) { + if !((iIn != 7) && ((iIn != 16) || (libc.Xmemcmp(tls, ts+27537 /* "localhost" */, (zUri+7), uint64(9)) != 0))) { goto __10 } *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+27547, /* "invalid uri auth..." */ - libc.VaList(bp, (iIn-7), (zUri+uintptr(7)))) - rc = 1 + libc.VaList(bp, (iIn-7), (zUri+7))) + rc = SQLITE_ERROR goto parse_uri_out __10: ; @@ -146346,7 +143895,7 @@ __26: // method. zOpt = (zFile + uintptr((Xsqlite3Strlen30(tls, zFile) + 1))) __27: - if !(*(*int8)(unsafe.Pointer(zOpt + uintptr(0))) != 0) { + if !(*(*int8)(unsafe.Pointer(zOpt)) != 0) { goto __28 } nOpt = Xsqlite3Strlen30(tls, zOpt) @@ -146368,7 +143917,7 @@ __29: goto __31 } - mask = (0x00020000 | 0x00040000) + mask = (SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_PRIVATECACHE) aMode = uintptr(unsafe.Pointer(&aCacheMode)) limit = mask zModeType = ts + 27579 /* "cache" */ @@ -146378,8 +143927,8 @@ __31: goto __32 } - mask = (((0x00000001 | 0x00000002) | - 0x00000004) | 0x00000080) + mask = (((SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE) | + SQLITE_OPEN_CREATE) | SQLITE_OPEN_MEMORY) aMode = uintptr(unsafe.Pointer(&aOpenMode)) limit = (int32(uint32(mask) & flags)) zModeType = ts + 4425 /* "access" */ @@ -146414,16 +143963,16 @@ __36: goto __38 } *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+27590 /* "no such %s mode:..." */, libc.VaList(bp+16, zModeType, zVal)) - rc = 1 + rc = SQLITE_ERROR goto parse_uri_out __38: ; - if !((mode & ^libc.Int32(0x00000080)) > limit) { + if !((mode & libc.CplInt32(SQLITE_OPEN_MEMORY)) > limit) { goto __39 } *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+27610, /* "%s mode not allo..." */ libc.VaList(bp+32, zModeType, zVal)) - rc = 3 + rc = SQLITE_PERM goto parse_uri_out __39: ; @@ -146444,7 +143993,7 @@ __1: if !(!(zFile != 0)) { goto __40 } - return 7 + return SQLITE_NOMEM __40: ; libc.Xmemset(tls, zFile, 0, uint64(4)) @@ -146456,7 +144005,7 @@ __40: __41: ; libc.Xmemset(tls, (zFile + uintptr(nUri)), 0, uint64(4)) - flags = flags & (^libc.Uint32FromInt32(0x00000040)) + flags = flags & (libc.Uint32FromInt32(libc.CplInt32(SQLITE_OPEN_URI))) __2: ; @@ -146465,11 +144014,11 @@ __2: goto __42 } *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+27634 /* "no such vfs: %s" */, libc.VaList(bp+48, zVfs)) - rc = 1 + rc = SQLITE_ERROR __42: ; parse_uri_out: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __43 } Xsqlite3_free_filename(tls, zFile) @@ -146488,27 +144037,15 @@ type OpenMode = struct { } /* sqlite3.c:163946:9 */ var aCacheMode = [3]OpenMode{ - { - Fz: ts + 19007, /* "shared" */ - Fmode: 0x00020000}, - { - Fz: ts + 27650, /* "private" */ - Fmode: 0x00040000}, + {Fz: ts + 19007 /* "shared" */, Fmode: SQLITE_OPEN_SHAREDCACHE}, + {Fz: ts + 27650 /* "private" */, Fmode: SQLITE_OPEN_PRIVATECACHE}, {}, } /* sqlite3.c:163955:34 */ var aOpenMode = [5]OpenMode{ - { - Fz: ts + 27658, /* "ro" */ - Fmode: 0x00000001}, - { - Fz: ts + 27661, /* "rw" */ - Fmode: 0x00000002}, - { - Fz: ts + 27664, /* "rwc" */ - Fmode: (0x00000002 | 0x00000004)}, - { - Fz: ts + 18390, /* "memory" */ - Fmode: 0x00000080}, + {Fz: ts + 27658 /* "ro" */, Fmode: SQLITE_OPEN_READONLY}, + {Fz: ts + 27661 /* "rw" */, Fmode: SQLITE_OPEN_READWRITE}, + {Fz: ts + 27664 /* "rwc" */, Fmode: (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)}, + {Fz: ts + 18390 /* "memory" */, Fmode: SQLITE_OPEN_MEMORY}, {}, } /* sqlite3.c:163967:34 */ @@ -146516,7 +144053,7 @@ var aOpenMode = [5]OpenMode{ // database filename for the sqlite3_uri_parameter() interface. func uriParameter(tls *libc.TLS, zFilename uintptr, zParam uintptr) uintptr { /* sqlite3.c:164041:19: */ zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) - for *(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(zFilename)) != 0 { var x int32 = libc.Xstrcmp(tls, zFilename, zParam) zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) if x == 0 { @@ -146561,13 +144098,13 @@ __1: isThreadsafe = 0 goto __3 __2: - if !((*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) & uint32(0x00008000)) != 0) { + if !((*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) & SQLITE_OPEN_NOMUTEX) != 0) { goto __4 } isThreadsafe = 0 goto __5 __4: - if !((*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) & uint32(0x00010000)) != 0) { + if !((*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) & SQLITE_OPEN_FULLMUTEX) != 0) { goto __6 } isThreadsafe = 1 @@ -146581,16 +144118,16 @@ __5: __3: ; - if !((*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) & uint32(0x00040000)) != 0) { + if !((*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) & SQLITE_OPEN_PRIVATECACHE) != 0) { goto __8 } - *(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) &= ^libc.Uint32FromInt32(0x00020000) + *(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) &= libc.Uint32FromInt32(libc.CplInt32(SQLITE_OPEN_SHAREDCACHE)) goto __9 __8: if !(Xsqlite3Config.FsharedCacheEnabled != 0) { goto __10 } - *(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) |= uint32(0x00020000) + *(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) |= SQLITE_OPEN_SHAREDCACHE __10: ; __9: @@ -146604,7 +144141,7 @@ __9: // SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE, // SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask // off all other flags. - *(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) &= ^libc.Uint32FromInt32((((((((((((0x00000008 | 0x00000010) | 0x00000100) | 0x00000200) | 0x00000400) | 0x00000800) | 0x00001000) | 0x00002000) | 0x00004000) | 0x00008000) | 0x00010000) | 0x00080000)) + *(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) &= libc.Uint32FromInt32(libc.CplInt32((((((((((((SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_MAIN_DB) | SQLITE_OPEN_TEMP_DB) | SQLITE_OPEN_TRANSIENT_DB) | SQLITE_OPEN_MAIN_JOURNAL) | SQLITE_OPEN_TEMP_JOURNAL) | SQLITE_OPEN_SUBJOURNAL) | SQLITE_OPEN_SUPER_JOURNAL) | SQLITE_OPEN_NOMUTEX) | SQLITE_OPEN_FULLMUTEX) | SQLITE_OPEN_WAL))) // Allocate the sqlite data structure db = Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(Sqlite3{}))) @@ -146617,7 +144154,7 @@ __11: if !(isThreadsafe != 0) { goto __12 } - (*Sqlite3)(unsafe.Pointer(db)).Fmutex = Xsqlite3MutexAlloc(tls, 1) + (*Sqlite3)(unsafe.Pointer(db)).Fmutex = Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_RECURSIVE) if !((*Sqlite3)(unsafe.Pointer(db)).Fmutex == uintptr(0)) { goto __13 } @@ -146637,23 +144174,23 @@ __12: Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) (*Sqlite3)(unsafe.Pointer(db)).FerrMask = 0xff (*Sqlite3)(unsafe.Pointer(db)).FnDb = 2 - (*Sqlite3)(unsafe.Pointer(db)).Fmagic = 0xf03b7906 + (*Sqlite3)(unsafe.Pointer(db)).Fmagic = SQLITE_MAGIC_BUSY (*Sqlite3)(unsafe.Pointer(db)).FaDb = db + 648 /* &.aDbStatic */ (*Sqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = U32(1) (*Sqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = U16(0) libc.Xmemcpy(tls, db+124 /* &.aLimit */, uintptr(unsafe.Pointer(&aHardLimit)), uint64(unsafe.Sizeof([12]int32{}))) - *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + uintptr(11)*4)) = 0 + *(*int32)(unsafe.Pointer((db + 124 /* &.aLimit */) + 11*4)) = SQLITE_DEFAULT_WORKER_THREADS (*Sqlite3)(unsafe.Pointer(db)).FautoCommit = U8(1) (*Sqlite3)(unsafe.Pointer(db)).FnextAutovac = int8(-1) (*Sqlite3)(unsafe.Pointer(db)).FszMmap = Xsqlite3Config.FszMmap (*Sqlite3)(unsafe.Pointer(db)).FnextPagesize = 0 (*Sqlite3)(unsafe.Pointer(db)).FnMaxSorterMmap = 0x7FFFFFFF - *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(((((((uint32(0x00000040 | - 0x00040000)) | - 0x80000000) | - uint32(0x00000020)) | - uint32(0x00000080)) | + *(*U64)(unsafe.Pointer(db + 48 /* &.flags */)) |= (uint64(((((((uint32(SQLITE_ShortColNames | + SQLITE_EnableTrigger)) | + SQLITE_EnableView) | + SQLITE_CacheSpill) | + SQLITE_TrustedSchema) | // The SQLITE_DQS compile-time option determines the default settings // for SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML. // @@ -146668,10 +144205,10 @@ __12: // Legacy behavior is 3 (double-quoted string literals are allowed anywhere) // and so that is the default. But developers are encouranged to use // -DSQLITE_DQS=0 (best) or -DSQLITE_DQS=1 (second choice) if possible. - uint32(0x40000000)) | - uint32(0x20000000)) | + SQLITE_DqsDML) | + SQLITE_DqsDDL) | - uint32(0x00008000))) + SQLITE_AutoIndex)) Xsqlite3HashInit(tls, (db + 600 /* &.aCollSeq */)) Xsqlite3HashInit(tls, (db + 528 /* &.aModule */)) @@ -146681,19 +144218,19 @@ __12: // // EVIDENCE-OF: R-52786-44878 SQLite defines three built-in collating // functions: - createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), uint8(1), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{binCollFunc})), uintptr(0)) - createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), uint8(3), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), SQLITE_UTF16BE, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{binCollFunc})), uintptr(0)) - createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), uint8(2), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + createCollation(tls, db, uintptr(unsafe.Pointer(&Xsqlite3StrBINARY)), SQLITE_UTF16LE, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{binCollFunc})), uintptr(0)) - createCollation(tls, db, ts+23528 /* "NOCASE" */, uint8(1), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + createCollation(tls, db, ts+23528 /* "NOCASE" */, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{nocaseCollatingFunc})), uintptr(0)) - createCollation(tls, db, ts+27668 /* "RTRIM" */, uint8(1), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + createCollation(tls, db, ts+27668 /* "RTRIM" */, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 }{rtrimCollFunc})), uintptr(0)) if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { @@ -146728,10 +144265,10 @@ __16: rc = Xsqlite3ParseUri(tls, zVfs, zFilename, bp+8 /* &flags */, (db /* &.pVfs */), bp+16 /* &zOpen */, bp+24 /* &zErrMsg */) __17: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __18 } - if !(rc == 7) { + if !(rc == SQLITE_NOMEM) { goto __19 } Xsqlite3OomFault(tls, db) @@ -146749,40 +144286,40 @@ __18: ; // Open the backend database driver - rc = Xsqlite3BtreeOpen(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, *(*uintptr)(unsafe.Pointer(bp + 16 /* zOpen */)), db, ((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32 + 8 /* &.pBt */), 0, - (int32(*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) | uint32(0x00000100)))) - if !(rc != 0) { + rc = Xsqlite3BtreeOpen(tls, (*Sqlite3)(unsafe.Pointer(db)).FpVfs, *(*uintptr)(unsafe.Pointer(bp + 16 /* zOpen */)), db, ((*Sqlite3)(unsafe.Pointer(db)).FaDb + 8 /* &.pBt */), 0, + (int32(*(*uint32)(unsafe.Pointer(bp + 8 /* flags */)) | SQLITE_OPEN_MAIN_DB))) + if !(rc != SQLITE_OK) { goto __20 } - if !(rc == (10 | (int32(12) << 8))) { + if !(rc == (SQLITE_IOERR | (int32(12) << 8))) { goto __21 } - rc = 7 + rc = SQLITE_NOMEM __21: ; Xsqlite3Error(tls, db, rc) goto opendb_out __20: ; - Xsqlite3BtreeEnter(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt) - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FpSchema = Xsqlite3SchemaGet(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt) + Xsqlite3BtreeEnter(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt) + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema = Xsqlite3SchemaGet(tls, db, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt) if !(!(int32((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed) != 0)) { goto __22 } - Xsqlite3SetTextEncoding(tls, db, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb+uintptr(0)*32)).FpSchema)).Fenc) + Xsqlite3SetTextEncoding(tls, db, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((db))).FaDb)).FpSchema)).Fenc) __22: ; - Xsqlite3BtreeLeave(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpBt) - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(1)*32)).FpSchema = Xsqlite3SchemaGet(tls, db, uintptr(0)) + Xsqlite3BtreeLeave(tls, (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpBt) + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*32)).FpSchema = Xsqlite3SchemaGet(tls, db, uintptr(0)) // The default safety_level for the main database is FULL; for the temp // database it is OFF. This matches the pager layer defaults. - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).FzDbSName = ts + 8333 /* "main" */ - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(0)*32)).Fsafety_level = (U8(2 + 1)) - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(1)*32)).FzDbSName = ts + 24978 /* "temp" */ - (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(1)*32)).Fsafety_level = U8(0x01) + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FzDbSName = ts + 8333 /* "main" */ + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).Fsafety_level = (U8(SQLITE_DEFAULT_SYNCHRONOUS + 1)) + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*32)).FzDbSName = ts + 24978 /* "temp" */ + (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + 1*32)).Fsafety_level = PAGER_SYNCHRONOUS_OFF - (*Sqlite3)(unsafe.Pointer(db)).Fmagic = 0xa029a697 + (*Sqlite3)(unsafe.Pointer(db)).Fmagic = SQLITE_MAGIC_OPEN if !((*Sqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) { goto __23 } @@ -146793,14 +144330,14 @@ __23: // Register all built-in functions, but do not attempt to read the // database schema yet. This is delayed until the first time the database // is accessed. - Xsqlite3Error(tls, db, 0) + Xsqlite3Error(tls, db, SQLITE_OK) Xsqlite3RegisterPerConnectionBuiltinFunctions(tls, db) rc = Xsqlite3_errcode(tls, db) // Load compiled-in extensions i = 0 __24: - if !((rc == 0) && (i < (int32(uint64(unsafe.Sizeof(sqlite3BuiltinExtensions)) / uint64(unsafe.Sizeof(uintptr(0))))))) { + if !((rc == SQLITE_OK) && (i < (int32(uint64(unsafe.Sizeof(sqlite3BuiltinExtensions)) / uint64(unsafe.Sizeof(uintptr(0))))))) { goto __26 } rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&sqlite3BuiltinExtensions)) + uintptr(i)*8))))(tls, db) @@ -146814,12 +144351,12 @@ __26: // Load automatic extensions - extensions that have been registered // using the sqlite3_automatic_extension() API. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __27 } Xsqlite3AutoLoadExtensions(tls, db) rc = Xsqlite3_errcode(tls, db) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __28 } goto opendb_out @@ -146843,7 +144380,7 @@ __29: setupLookaside(tls, db, uintptr(0), Xsqlite3Config.FszLookaside, Xsqlite3Config.FnLookaside) - Xsqlite3_wal_autocheckpoint(tls, db, 1000) + Xsqlite3_wal_autocheckpoint(tls, db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT) opendb_out: if !(db != 0) { @@ -146855,17 +144392,17 @@ __30: ; rc = Xsqlite3_errcode(tls, db) - if !(rc == 7) { + if !(rc == SQLITE_NOMEM) { goto __31 } Xsqlite3_close(tls, db) db = uintptr(0) goto __32 __31: - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __33 } - (*Sqlite3)(unsafe.Pointer(db)).Fmagic = U32(0x4b771290) + (*Sqlite3)(unsafe.Pointer(db)).Fmagic = SQLITE_MAGIC_SICK __33: ; __32: @@ -146878,7 +144415,7 @@ __32: // Open a new database handle. func Xsqlite3_open(tls *libc.TLS, zFilename uintptr, ppDb uintptr) int32 { /* sqlite3.c:164386:16: */ return openDatabase(tls, zFilename, ppDb, - (uint32(0x00000002 | 0x00000004)), uintptr(0)) + (uint32(SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)), uintptr(0)) } func Xsqlite3_open_v2(tls *libc.TLS, filename uintptr, ppDb uintptr, flags int32, zVfs uintptr) int32 { /* sqlite3.c:164393:16: */ @@ -146900,17 +144437,17 @@ func Xsqlite3_open16(tls *libc.TLS, zFilename uintptr, ppDb uintptr) int32 { /* zFilename = ts + 27674 /* "\x00\x00" */ } pVal = Xsqlite3ValueNew(tls, uintptr(0)) - Xsqlite3ValueSetStr(tls, pVal, -1, zFilename, uint8(2), uintptr(0)) - zFilename8 = Xsqlite3ValueText(tls, pVal, uint8(1)) + Xsqlite3ValueSetStr(tls, pVal, -1, zFilename, SQLITE_UTF16LE, uintptr(0)) + zFilename8 = Xsqlite3ValueText(tls, pVal, SQLITE_UTF8) if zFilename8 != 0 { rc = openDatabase(tls, zFilename8, ppDb, - (uint32(0x00000002 | 0x00000004)), uintptr(0)) + (uint32(SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)), uintptr(0)) - if (rc == 0) && !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(ppDb))))).FaDb+uintptr(0)*32)).FpSchema)).FschemaFlags) & (0x0001)) == (0x0001)) { - ((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(ppDb))))).FaDb + uintptr(0)*32)).FpSchema)).Fenc) = libc.AssignPtrUint8(*(*uintptr)(unsafe.Pointer(ppDb))+94 /* &.enc */, U8(2)) + if (rc == SQLITE_OK) && !((int32((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(ppDb))))).FaDb)).FpSchema)).FschemaFlags) & (DB_SchemaLoaded)) == (DB_SchemaLoaded)) { + ((*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(ppDb))))).FaDb)).FpSchema)).Fenc) = libc.AssignPtrUint8(*(*uintptr)(unsafe.Pointer(ppDb))+94 /* &.enc */, SQLITE_UTF16LE) } } else { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3ValueFree(tls, pVal) @@ -146936,12 +144473,12 @@ func Xsqlite3_create_collation_v2(tls *libc.TLS, db uintptr, zName uintptr, enc // Register a new collation sequence with the database handle db. func Xsqlite3_create_collation16(tls *libc.TLS, db uintptr, zName uintptr, enc int32, pCtx uintptr, xCompare uintptr) int32 { /* sqlite3.c:164483:16: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var zName8 uintptr Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - zName8 = Xsqlite3Utf16to8(tls, db, zName, -1, uint8(2)) + zName8 = Xsqlite3Utf16to8(tls, db, zName, -1, SQLITE_UTF16LE) if zName8 != 0 { rc = createCollation(tls, db, zName8, U8(enc), pCtx, xCompare, uintptr(0)) Xsqlite3DbFree(tls, db, zName8) @@ -146959,7 +144496,7 @@ func Xsqlite3_collation_needed(tls *libc.TLS, db uintptr, pCollNeededArg uintptr (*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded16 = uintptr(0) (*Sqlite3)(unsafe.Pointer(db)).FpCollNeededArg = pCollNeededArg Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // Register a collation sequence factory callback with the database handle @@ -146970,13 +144507,13 @@ func Xsqlite3_collation_needed16(tls *libc.TLS, db uintptr, pCollNeededArg uintp (*Sqlite3)(unsafe.Pointer(db)).FxCollNeeded16 = xCollNeeded16 (*Sqlite3)(unsafe.Pointer(db)).FpCollNeededArg = pCollNeededArg Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // This function is now an anachronism. It used to be used to recover from a // malloc() failure, but SQLite now does this automatically. func Xsqlite3_global_recover(tls *libc.TLS) int32 { /* sqlite3.c:164556:16: */ - return 0 + return SQLITE_OK } // Test to see whether or not the database connection is in autocommit @@ -147007,17 +144544,17 @@ func Xsqlite3ReportError(tls *libc.TLS, iErr int32, lineno int32, zType uintptr) func Xsqlite3CorruptError(tls *libc.TLS, lineno int32) int32 { /* sqlite3.c:164593:20: */ - return Xsqlite3ReportError(tls, 11, lineno, ts+27702 /* "database corrupt..." */) + return Xsqlite3ReportError(tls, SQLITE_CORRUPT, lineno, ts+27702 /* "database corrupt..." */) } func Xsqlite3MisuseError(tls *libc.TLS, lineno int32) int32 { /* sqlite3.c:164597:20: */ - return Xsqlite3ReportError(tls, 21, lineno, ts+27722 /* "misuse" */) + return Xsqlite3ReportError(tls, SQLITE_MISUSE, lineno, ts+27722 /* "misuse" */) } func Xsqlite3CantopenError(tls *libc.TLS, lineno int32) int32 { /* sqlite3.c:164601:20: */ - return Xsqlite3ReportError(tls, 14, lineno, ts+27729 /* "cannot open file" */) + return Xsqlite3ReportError(tls, SQLITE_CANTOPEN, lineno, ts+27729 /* "cannot open file" */) } // This is a convenience routine that makes sure that all thread-specific @@ -147059,7 +144596,7 @@ func Xsqlite3_table_column_metadata(tls *libc.TLS, db uintptr, zDbName uintptr, Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) Xsqlite3BtreeEnterAll(tls, db) rc = Xsqlite3Init(tls, db, bp+24 /* &zErrMsg */) - if !(0 != rc) { + if !(SQLITE_OK != rc) { goto __1 } goto error_out @@ -147105,7 +144642,7 @@ __7: if !(iCol == int32((*Table)(unsafe.Pointer(pTab)).FnCol)) { goto __9 } - if !((((*Table)(unsafe.Pointer((pTab))).FtabFlags & U32(0x0080)) == U32(0)) && (Xsqlite3IsRowid(tls, zColumnName) != 0)) { + if !((((*Table)(unsafe.Pointer((pTab))).FtabFlags & TF_WithoutRowid) == U32(0)) && (Xsqlite3IsRowid(tls, zColumnName) != 0)) { goto __10 } iCol = int32((*Table)(unsafe.Pointer(pTab)).FiPKey) @@ -147140,8 +144677,8 @@ __4: zDataType = Xsqlite3ColumnType(tls, pCol, uintptr(0)) zCollSeq = (*Column)(unsafe.Pointer(pCol)).FzColl notnull = (libc.Bool32(int32((*Column)(unsafe.Pointer(pCol)).FnotNull) != 0)) - primarykey = (libc.Bool32((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & 0x0001) != 0)) - autoinc = (libc.Bool32((int32((*Table)(unsafe.Pointer(pTab)).FiPKey) == iCol) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & U32(0x0008)) != U32(0)))) + primarykey = (libc.Bool32((int32((*Column)(unsafe.Pointer(pCol)).FcolFlags) & COLFLAG_PRIMKEY) != 0)) + autoinc = (libc.Bool32((int32((*Table)(unsafe.Pointer(pTab)).FiPKey) == iCol) && (((*Table)(unsafe.Pointer(pTab)).FtabFlags & TF_Autoincrement) != U32(0)))) goto __13 __12: zDataType = ts + 13762 /* "INTEGER" */ @@ -147192,13 +144729,13 @@ __18: __19: ; - if !((0 == rc) && !(pTab != 0)) { + if !((SQLITE_OK == rc) && !(pTab != 0)) { goto __20 } Xsqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(bp + 24 /* zErrMsg */))) *(*uintptr)(unsafe.Pointer(bp + 24 /* zErrMsg */)) = Xsqlite3MPrintf(tls, db, ts+27746 /* "no such table co..." */, libc.VaList(bp, zTableName, zColumnName)) - rc = 1 + rc = SQLITE_ERROR __20: ; Xsqlite3ErrorWithMsg(tls, db, rc, func() uintptr { @@ -147238,12 +144775,12 @@ func Xsqlite3_extended_result_codes(tls *libc.TLS, db uintptr, onoff int32) int3 return 0xff }() Xsqlite3_mutex_leave(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) - return 0 + return SQLITE_OK } // Invoke the xFileControl method on a particular database. func Xsqlite3_file_control(tls *libc.TLS, db uintptr, zDbName uintptr, op int32, pArg uintptr) int32 { /* sqlite3.c:164787:16: */ - var rc int32 = 1 + var rc int32 = SQLITE_ERROR var pBtree uintptr Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -147256,25 +144793,25 @@ func Xsqlite3_file_control(tls *libc.TLS, db uintptr, zDbName uintptr, op int32, fd = Xsqlite3PagerFile(tls, pPager) - if op == 7 { + if op == SQLITE_FCNTL_FILE_POINTER { *(*uintptr)(unsafe.Pointer(pArg)) = fd - rc = 0 - } else if op == 27 { + rc = SQLITE_OK + } else if op == SQLITE_FCNTL_VFS_POINTER { *(*uintptr)(unsafe.Pointer(pArg)) = Xsqlite3PagerVfs(tls, pPager) - rc = 0 - } else if op == 28 { + rc = SQLITE_OK + } else if op == SQLITE_FCNTL_JOURNAL_POINTER { *(*uintptr)(unsafe.Pointer(pArg)) = Xsqlite3PagerJrnlFile(tls, pPager) - rc = 0 - } else if op == 35 { + rc = SQLITE_OK + } else if op == SQLITE_FCNTL_DATA_VERSION { *(*uint32)(unsafe.Pointer(pArg)) = Xsqlite3PagerDataVersion(tls, pPager) - rc = 0 - } else if op == 38 { + rc = SQLITE_OK + } else if op == SQLITE_FCNTL_RESERVE_BYTES { var iNew int32 = *(*int32)(unsafe.Pointer(pArg)) *(*int32)(unsafe.Pointer(pArg)) = Xsqlite3BtreeGetRequestedReserve(tls, pBtree) if (iNew >= 0) && (iNew <= 255) { Xsqlite3BtreeSetPageSize(tls, pBtree, 0, iNew, 0) } - rc = 0 + rc = SQLITE_OK } else { rc = Xsqlite3OsFileControl(tls, fd, op, pArg) } @@ -147293,7 +144830,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit switch op { // Save the current state of the PRNG. - case 5: + case SQLITE_TESTCTRL_PRNG_SAVE: { Xsqlite3PrngSaveState(tls) break @@ -147303,7 +144840,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // Restore the state of the PRNG to the last state saved using // PRNG_SAVE. If PRNG_SAVE has never before been called, then // this verb acts like PRNG_RESET. - case 6: + case SQLITE_TESTCTRL_PRNG_RESTORE: { Xsqlite3PrngRestoreState(tls) break @@ -147329,13 +144866,13 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // // This test-control also resets the PRNG so that the new seed will // be used for the next call to sqlite3_randomness(). - case 28: + case SQLITE_TESTCTRL_PRNG_SEED: { var x int32 = int32(libc.VaInt32(&ap)) var y int32 var db uintptr = libc.VaUintptr(&ap) - if (db != 0) && ((libc.AssignInt32(&y, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb+uintptr(0)*32)).FpSchema)).Fschema_cookie)) != 0) { + if (db != 0) && ((libc.AssignInt32(&y, (*Schema)(unsafe.Pointer((*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb)).FpSchema)).Fschema_cookie)) != 0) { x = y } Xsqlite3Config.FiPrngSeed = uint32(x) @@ -147350,7 +144887,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // is an array of integers that defines the test. Return -1 on a // memory allocation error, 0 on success, or non-zero for an error. // See the sqlite3BitvecBuiltinTest() for additional information. - case 8: + case SQLITE_TESTCTRL_BITVEC_TEST: { var sz int32 = int32(libc.VaInt32(&ap)) var aProg uintptr = libc.VaUintptr(&ap) @@ -147368,7 +144905,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // is called immediately after installing the new callback and the return // value from sqlite3FaultSim(0) becomes the return from // sqlite3_test_control(). - case 9: + case SQLITE_TESTCTRL_FAULT_INSTALL: { Xsqlite3Config.FxTestCallback = libc.VaUintptr(&ap) rc = Xsqlite3FaultSim(tls, 0) @@ -147380,7 +144917,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // // Register hooks to call to indicate which malloc() failures // are benign. - case 10: + case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: { var xBenignBegin uintptr var xBenignEnd uintptr @@ -147401,7 +144938,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // an incompatible database file format. Changing the PENDING byte // while any database connection is open results in undefined and // deleterious behavior. - case 11: + case SQLITE_TESTCTRL_PENDING_BYTE: { rc = Xsqlite3PendingByte { @@ -147424,7 +144961,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // false and assert() is enabled, then the assertion fires and the // process aborts. If X is false and assert() is disabled, then the // return value is zero. - case 12: + case SQLITE_TESTCTRL_ASSERT: { var x int32 = 0 @@ -147458,7 +144995,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // }else{ // // ALWAYS(x) is a constant 1. NEVER(x) is a constant 0. // } - case 13: + case SQLITE_TESTCTRL_ALWAYS: { var x int32 = int32(libc.VaInt32(&ap)) if x != 0 { @@ -147479,9 +145016,9 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // 10 little-endian, determined at run-time // 432101 big-endian, determined at compile-time // 123410 little-endian, determined at compile-time - case 22: + case SQLITE_TESTCTRL_BYTEORDER: { - rc = (((1234 * 100) + (1 * 10)) + 0) + rc = (((SQLITE_BYTEORDER * 100) + (SQLITE_LITTLEENDIAN * 10)) + SQLITE_BIGENDIAN) break } @@ -147494,10 +145031,10 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // SQL Logic Test or SLT test module) can run the same SQL multiple times // with various optimizations disabled to verify that the same answer // is obtained in every case. - case 15: + case SQLITE_TESTCTRL_OPTIMIZATIONS: { var db uintptr = libc.VaUintptr(&ap) - (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags = (U16(int32(libc.VaInt32(&ap)) & 0xffff)) + (*Sqlite3)(unsafe.Pointer(db)).FdbOptFlags = (U16((int32(libc.VaInt32(&ap))) & 0xffff)) break } @@ -147506,7 +145043,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // // If parameter onoff is non-zero, subsequent calls to localtime() // and its variants fail. If onoff is zero, undo this setting. - case 18: + case SQLITE_TESTCTRL_LOCALTIME_FAULT: { Xsqlite3Config.FbLocaltimeFault = int32(libc.VaInt32(&ap)) break @@ -147517,10 +145054,10 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // // Toggle the ability to use internal functions on or off for // the database connection given in the argument. - case 17: + case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS: { var db uintptr = libc.VaUintptr(&ap) - *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) ^= (U32(0x0020)) + *(*U32)(unsafe.Pointer(db + 44 /* &.mDbFlags */)) ^= (DBFLAG_InternalFunc) break } @@ -147532,7 +145069,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // database files might have arbitrary corruption. Setting the flag during // testing causes certain assert() statements in the code to be activated // that demonstrat invariants on well-formed database files. - case 20: + case SQLITE_TESTCTRL_NEVER_CORRUPT: { Xsqlite3Config.FneverCorrupt = int32(libc.VaInt32(&ap)) break @@ -147550,7 +145087,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // is useful to make it easier to reach strange internal error states // during testing. The EXTRA_SCHEMA_CHECKS setting is always enabled // in production. - case 29: + case SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS: { Xsqlite3Config.FbExtraSchemaChecks = U8(libc.VaInt32(&ap)) break @@ -147561,7 +145098,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // By default this is 0x7ffffffe (over 2 billion), but that value is // too big to test in a reasonable amount of time, so this control is // provided to set a small and easily reachable reset value. - case 19: + case SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD: { Xsqlite3Config.FiOnceResetThreshold = int32(libc.VaInt32(&ap)) break @@ -147572,14 +145109,14 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // // Set the VDBE coverage callback function to xCallback with context // pointer ptr. - case 21: + case SQLITE_TESTCTRL_VDBE_COVERAGE: { break } // sqlite3_test_control(SQLITE_TESTCTRL_SORTER_MMAP, db, nMax); - case 24: + case SQLITE_TESTCTRL_SORTER_MMAP: { var db uintptr = libc.VaUintptr(&ap) (*Sqlite3)(unsafe.Pointer(db)).FnMaxSorterMmap = int32(libc.VaInt32(&ap)) @@ -147591,10 +145128,10 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // // Return SQLITE_OK if SQLite has been initialized and SQLITE_ERROR if // not. - case 23: + case SQLITE_TESTCTRL_ISINIT: { if Xsqlite3Config.FisInit == 0 { - rc = 1 + rc = SQLITE_ERROR } break @@ -147615,7 +145152,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // If onOff==0 and tnum>0 then reset the schema for all databases, causing // the schema to be reparsed the next time it is needed. This has the // effect of erasing all imposter tables. - case 25: + case SQLITE_TESTCTRL_IMPOSTER: { var db uintptr = libc.VaUintptr(&ap) Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -147639,7 +145176,7 @@ func Xsqlite3_test_control(tls *libc.TLS, op int32, va uintptr) int32 { /* sqlit // test-control enables us to write an intreal() SQL function that can // inject an intreal() value at arbitrary places in an SQL statement, // for testing purposes. - case 27: + case SQLITE_TESTCTRL_RESULT_INTREAL: { var pCtx uintptr = libc.VaUintptr(&ap) Xsqlite3ResultIntReal(tls, pCtx) @@ -147742,11 +145279,11 @@ func Xsqlite3_uri_key(tls *libc.TLS, zFilename uintptr, N int32) uintptr { /* sq } zFilename = databaseName(tls, zFilename) zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) - for (*(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0) && ((libc.PostDecInt32(&N, 1)) > 0) { + for (*(*int8)(unsafe.Pointer(zFilename)) != 0) && ((libc.PostDecInt32(&N, 1)) > 0) { zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) } - if *(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0 { + if *(*int8)(unsafe.Pointer(zFilename)) != 0 { return zFilename } return uintptr(0) @@ -147791,7 +145328,7 @@ func Xsqlite3_filename_database(tls *libc.TLS, zFilename uintptr) uintptr { /* s func Xsqlite3_filename_journal(tls *libc.TLS, zFilename uintptr) uintptr { /* sqlite3.c:165359:23: */ zFilename = databaseName(tls, zFilename) zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) - for *(*int8)(unsafe.Pointer(zFilename + uintptr(0))) != 0 { + for *(*int8)(unsafe.Pointer(zFilename)) != 0 { zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) zFilename += (uintptr(Xsqlite3Strlen30(tls, zFilename) + 1)) } @@ -147843,7 +145380,7 @@ func Xsqlite3_db_readonly(tls *libc.TLS, db uintptr, zDbName uintptr) int32 { /* // Obtain a snapshot handle for the snapshot of database zDb currently // being read by handle db. func Xsqlite3_snapshot_get(tls *libc.TLS, db uintptr, zDb uintptr, ppSnapshot uintptr) int32 { /* sqlite3.c:165423:16: */ - var rc int32 = 1 + var rc int32 = SQLITE_ERROR Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -147853,7 +145390,7 @@ func Xsqlite3_snapshot_get(tls *libc.TLS, db uintptr, zDb uintptr, ppSnapshot ui var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpBt if 0 == Xsqlite3BtreeIsInTrans(tls, pBt) { rc = Xsqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerSnapshotGet(tls, Xsqlite3BtreePager(tls, pBt), ppSnapshot) } } @@ -147866,7 +145403,7 @@ func Xsqlite3_snapshot_get(tls *libc.TLS, db uintptr, zDb uintptr, ppSnapshot ui // Open a read-transaction on the snapshot idendified by pSnapshot. func Xsqlite3_snapshot_open(tls *libc.TLS, db uintptr, zDb uintptr, pSnapshot uintptr) int32 { /* sqlite3.c:165459:16: */ - var rc int32 = 1 + var rc int32 = SQLITE_ERROR Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) if int32((*Sqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 { @@ -147880,18 +145417,18 @@ func Xsqlite3_snapshot_open(tls *libc.TLS, db uintptr, zDb uintptr, pSnapshot ui if Xsqlite3BtreeIsInReadTrans(tls, pBt) != 0 { if (*Sqlite3)(unsafe.Pointer(db)).FnVdbeActive == 0 { rc = Xsqlite3PagerSnapshotCheck(tls, pPager, pSnapshot) - if rc == 0 { + if rc == SQLITE_OK { bUnlock = 1 rc = Xsqlite3BtreeCommit(tls, pBt) } } } else { - rc = 0 + rc = SQLITE_OK } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerSnapshotOpen(tls, pPager, pSnapshot) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0)) Xsqlite3PagerSnapshotOpen(tls, pPager, uintptr(0)) } @@ -147909,7 +145446,7 @@ func Xsqlite3_snapshot_open(tls *libc.TLS, db uintptr, zDb uintptr, pSnapshot ui // Recover as many snapshots as possible from the wal file associated with // schema zDb of database db. func Xsqlite3_snapshot_recover(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* sqlite3.c:165515:16: */ - var rc int32 = 1 + var rc int32 = SQLITE_ERROR var iDb int32 Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) @@ -147918,7 +145455,7 @@ func Xsqlite3_snapshot_recover(tls *libc.TLS, db uintptr, zDb uintptr) int32 { / var pBt uintptr = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpBt if 0 == Xsqlite3BtreeIsInReadTrans(tls, pBt) { rc = Xsqlite3BtreeBeginTrans(tls, pBt, 0, uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3PagerSnapshotRecover(tls, Xsqlite3BtreePager(tls, pBt)) Xsqlite3BtreeCommit(tls, pBt) } @@ -148041,14 +145578,14 @@ func addToBlockedList(tls *libc.TLS, db uintptr) { /* sqlite3.c:165702:13: */ // Obtain the STATIC_MAIN mutex. func enterMutex(tls *libc.TLS) { /* sqlite3.c:165717:13: */ - Xsqlite3_mutex_enter(tls, Xsqlite3MutexAlloc(tls, 2)) + Xsqlite3_mutex_enter(tls, Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)) } // Release the STATIC_MAIN mutex. func leaveMutex(tls *libc.TLS) { /* sqlite3.c:165725:13: */ - Xsqlite3_mutex_leave(tls, Xsqlite3MutexAlloc(tls, 2)) + Xsqlite3_mutex_leave(tls, Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_STATIC_MAIN)) } // Register an unlock-notify callback. @@ -148075,7 +145612,7 @@ func Xsqlite3_unlock_notify(tls *libc.TLS, db uintptr, xNotify uintptr, pArg uin defer tls.Free(8) *(*uintptr)(unsafe.Pointer(bp)) = pArg - var rc int32 = 0 + var rc int32 = SQLITE_OK Xsqlite3_mutex_enter(tls, (*Sqlite3)(unsafe.Pointer(db)).Fmutex) enterMutex(tls) @@ -148097,7 +145634,7 @@ func Xsqlite3_unlock_notify(tls *libc.TLS, db uintptr, xNotify uintptr, pArg uin for p = (*Sqlite3)(unsafe.Pointer(db)).FpBlockingConnection; (p != 0) && (p != db); p = (*Sqlite3)(unsafe.Pointer(p)).FpUnlockConnection { } if p != 0 { - rc = 6 // Deadlock detected. + rc = SQLITE_LOCKED // Deadlock detected. } else { (*Sqlite3)(unsafe.Pointer(db)).FpUnlockConnection = (*Sqlite3)(unsafe.Pointer(db)).FpBlockingConnection (*Sqlite3)(unsafe.Pointer(db)).FxUnlockNotify = xNotify @@ -148973,7 +146510,7 @@ func jsonGrow(tls *libc.TLS, p uintptr, N U32) int32 { /* sqlite3.c:185658:12: * zNew = Xsqlite3_malloc64(tls, nTotal) if zNew == uintptr(0) { jsonOom(tls, p) - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, zNew, (*JsonString)(unsafe.Pointer(p)).FzBuf, Size_t((*JsonString)(unsafe.Pointer(p)).FnUsed)) (*JsonString)(unsafe.Pointer(p)).FzBuf = zNew @@ -148982,12 +146519,12 @@ func jsonGrow(tls *libc.TLS, p uintptr, N U32) int32 { /* sqlite3.c:185658:12: * zNew = Xsqlite3_realloc64(tls, (*JsonString)(unsafe.Pointer(p)).FzBuf, nTotal) if zNew == uintptr(0) { jsonOom(tls, p) - return 7 + return SQLITE_NOMEM } (*JsonString)(unsafe.Pointer(p)).FzBuf = zNew } (*JsonString)(unsafe.Pointer(p)).FnAlloc = nTotal - return 0 + return SQLITE_OK } // Append N bytes from zIn onto the end of the JsonString string. @@ -149117,15 +146654,15 @@ var aSpecial = [32]int8{ // construction. func jsonAppendValue(tls *libc.TLS, p uintptr, pValue uintptr) { /* sqlite3.c:185768:13: */ switch Xsqlite3_value_type(tls, pValue) { - case 5: + case SQLITE_NULL: { jsonAppendRaw(tls, p, ts+7843 /* "null" */, uint32(4)) break } - case 1: + case SQLITE_INTEGER: fallthrough - case 2: + case SQLITE_FLOAT: { var z uintptr = Xsqlite3_value_text(tls, pValue) var n U32 = U32(Xsqlite3_value_bytes(tls, pValue)) @@ -149133,11 +146670,11 @@ func jsonAppendValue(tls *libc.TLS, p uintptr, pValue uintptr) { /* sqlite3.c:18 break } - case 3: + case SQLITE_TEXT: { var z uintptr = Xsqlite3_value_text(tls, pValue) var n U32 = U32(Xsqlite3_value_bytes(tls, pValue)) - if Xsqlite3_value_subtype(tls, pValue) == uint32(74) { + if Xsqlite3_value_subtype(tls, pValue) == JSON_SUBTYPE { jsonAppendRaw(tls, p, z, n) } else { jsonAppendString(tls, p, z, n) @@ -149168,7 +146705,7 @@ func jsonResult(tls *libc.TLS, p uintptr) { /* sqlite3.c:185808:13: */ } return *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free})) }(), - uint8(1)) + SQLITE_UTF8) jsonZero(tls, p) } @@ -149187,7 +146724,7 @@ func jsonResult(tls *libc.TLS, p uintptr) { /* sqlite3.c:185808:13: */ // by which the JsonNode counter should increment in order to go to the // next peer value. func jsonNodeSize(tls *libc.TLS, pNode uintptr) U32 { /* sqlite3.c:185831:12: */ - if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) >= 6 { + if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) >= JSON_ARRAY { return ((*JsonNode)(unsafe.Pointer(pNode)).Fn + U32(1)) } return uint32(1) @@ -149214,8 +146751,8 @@ func jsonParseFree(tls *libc.TLS, pParse uintptr) { /* sqlite3.c:185851:13: */ // append to pOut. Subsubstructure is also included. Return // the number of JsonNode objects that are encoded. func jsonRenderNode(tls *libc.TLS, pNode uintptr, pOut uintptr, aReplace uintptr) { /* sqlite3.c:185861:13: */ - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & (0x08 | 0x10)) != 0 { - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x08) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & (JNODE_REPLACE | JNODE_PATCH)) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_REPLACE) != 0 { jsonAppendValue(tls, pOut, *(*uintptr)(unsafe.Pointer(aReplace + uintptr(*(*U32)(unsafe.Pointer(pNode + 8 /* &.u */)))*8))) return } @@ -149229,49 +146766,48 @@ func jsonRenderNode(tls *libc.TLS, pNode uintptr, pOut uintptr, aReplace uintptr break } - case 1: + case JSON_TRUE: { jsonAppendRaw(tls, pOut, ts+9544 /* "true" */, uint32(4)) break } - case 2: + case JSON_FALSE: { jsonAppendRaw(tls, pOut, ts+9549 /* "false" */, uint32(5)) break } - case 5: + case JSON_STRING: { - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x01) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_RAW) != 0 { jsonAppendString(tls, pOut, *(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */)), (*JsonNode)(unsafe.Pointer(pNode)).Fn) break } - /* no break */ } fallthrough - case 4: + case JSON_REAL: fallthrough - case 3: + case JSON_INT: { jsonAppendRaw(tls, pOut, *(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */)), (*JsonNode)(unsafe.Pointer(pNode)).Fn) break } - case 6: + case JSON_ARRAY: { var j U32 = U32(1) jsonAppendChar(tls, pOut, int8('[')) for { for j <= (*JsonNode)(unsafe.Pointer(pNode)).Fn { - if (int32((*JsonNode)(unsafe.Pointer(pNode+uintptr(j)*16)).FjnFlags) & 0x04) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode+uintptr(j)*16)).FjnFlags) & JNODE_REMOVE) == 0 { jsonAppendSeparator(tls, pOut) jsonRenderNode(tls, (pNode + uintptr(j)*16), pOut, aReplace) } j = j + (jsonNodeSize(tls, (pNode + uintptr(j)*16))) } - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x20) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_APPEND) == 0 { break } pNode = (pNode + uintptr(*(*U32)(unsafe.Pointer(pNode + 8 /* &.u */)))*16) @@ -149281,13 +146817,13 @@ func jsonRenderNode(tls *libc.TLS, pNode uintptr, pOut uintptr, aReplace uintptr break } - case 7: + case JSON_OBJECT: { var j U32 = U32(1) jsonAppendChar(tls, pOut, int8('{')) for { for j <= (*JsonNode)(unsafe.Pointer(pNode)).Fn { - if (int32((*JsonNode)(unsafe.Pointer(pNode+uintptr((j+U32(1)))*16)).FjnFlags) & 0x04) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode+uintptr((j+U32(1)))*16)).FjnFlags) & JNODE_REMOVE) == 0 { jsonAppendSeparator(tls, pOut) jsonRenderNode(tls, (pNode + uintptr(j)*16), pOut, aReplace) jsonAppendChar(tls, pOut, int8(':')) @@ -149295,7 +146831,7 @@ func jsonRenderNode(tls *libc.TLS, pNode uintptr, pOut uintptr, aReplace uintptr } j = j + (U32(1) + jsonNodeSize(tls, (pNode+uintptr((j+U32(1)))*16))) } - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x20) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_APPEND) == 0 { break } pNode = (pNode + uintptr(*(*U32)(unsafe.Pointer(pNode + 8 /* &.u */)))*16) @@ -149318,7 +146854,7 @@ func jsonReturnJson(tls *libc.TLS, pNode uintptr, pCtx uintptr, aReplace uintptr jsonInit(tls, bp /* &s */, pCtx) jsonRenderNode(tls, pNode, bp /* &s */, aReplace) jsonResult(tls, bp /* &s */) - Xsqlite3_result_subtype(tls, pCtx, uint32(74)) + Xsqlite3_result_subtype(tls, pCtx, JSON_SUBTYPE) } // Translate a single byte of Hex into an integer. @@ -149334,10 +146870,10 @@ func jsonHexToInt(tls *libc.TLS, h int32) U8 { /* sqlite3.c:185960:11: */ func jsonHexToInt4(tls *libc.TLS, z uintptr) U32 { /* sqlite3.c:185973:12: */ var v U32 - v = (U32((((int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))))) << 12) + - (int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + uintptr(1)))))) << 8)) + - (int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + uintptr(2)))))) << 4)) + - int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + uintptr(3)))))))) + v = (U32((((int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z))))) << 12) + + (int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + 1))))) << 8)) + + (int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + 2))))) << 4)) + + int32(jsonHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z + 3))))))) return v } @@ -149364,19 +146900,19 @@ func jsonReturn(tls *libc.TLS, pNode uintptr, pCtx uintptr, aReplace uintptr) { switch int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) { default: goto __2 - case 1: + case JSON_TRUE: goto __3 - case 2: + case JSON_FALSE: goto __4 - case 3: + case JSON_INT: goto __5 - case 4: + case JSON_REAL: goto __6 - case 5: + case JSON_STRING: goto __7 - case 6: + case JSON_ARRAY: goto __8 - case 7: + case JSON_OBJECT: goto __9 } goto __1 @@ -149396,14 +146932,14 @@ __4: __5: i = int64(0) z = *(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */)) - if !(int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '-') { + if !(int32(*(*int8)(unsafe.Pointer(z))) == '-') { goto __10 } z++ __10: ; __11: - if !((int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) <= '9')) { + if !((int32(*(*int8)(unsafe.Pointer(z))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z))) <= '9')) { goto __12 } v = (uint32(int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1)))) - '0')) @@ -149416,7 +146952,7 @@ __11: goto int_as_real __14: ; - if !((int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) <= '9')) { + if !((int32(*(*int8)(unsafe.Pointer(z))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z))) <= '9')) { goto __15 } goto int_as_real @@ -149431,7 +146967,7 @@ __16: if !(v == uint32(8)) { goto __17 } - if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */)) + uintptr(0)))) == '-') { + if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */))))) == '-') { goto __18 } Xsqlite3_result_int64(tls, pCtx, ((int64(-1)) - (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32)))) @@ -149449,7 +146985,7 @@ __13: goto __11 __12: ; - if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */)) + uintptr(0)))) == '-') { + if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */))))) == '-') { goto __20 } i = -i @@ -149459,17 +146995,17 @@ __20: int_done: goto __1 int_as_real: - i = int64(0) /* no break */ + i = int64(0) __6: z1 = *(*uintptr)(unsafe.Pointer(pNode + 8 /* &.u */)) - Xsqlite3AtoF(tls, z1, bp /* &r */, Xsqlite3Strlen30(tls, z1), uint8(1)) + Xsqlite3AtoF(tls, z1, bp /* &r */, Xsqlite3Strlen30(tls, z1), SQLITE_UTF8) Xsqlite3_result_double(tls, pCtx, *(*float64)(unsafe.Pointer(bp /* r */))) goto __1 __7: ; - if !((int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x02) == 0) { + if !((int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_ESCAPE) == 0) { goto __21 } // JSON formatted without any backslash-escapes @@ -149683,7 +147219,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 } if (int32(libc.AssignInt8(&c, *(*int8)(unsafe.Pointer(z + uintptr(i)))))) == '{' { // Parse object - iThis = jsonParseAddNode(tls, pParse, uint32(7), uint32(0), uintptr(0)) + iThis = jsonParseAddNode(tls, pParse, JSON_OBJECT, uint32(0), uintptr(0)) if iThis < 0 { return -1 } @@ -149691,7 +147227,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 for jsonIsSpace[uint8(*(*int8)(unsafe.Pointer(z + uintptr(j))))] != 0 { j++ } - if int32(libc.PreIncUint16(&(*JsonParse)(unsafe.Pointer(pParse)).FiDepth, 1)) > 2000 { + if int32(libc.PreIncUint16(&(*JsonParse)(unsafe.Pointer(pParse)).FiDepth, 1)) > JSON_MAX_DEPTH { return -1 } x = jsonParseValue(tls, pParse, j) @@ -149706,10 +147242,10 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 return -1 } pNode = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(((*JsonParse)(unsafe.Pointer(pParse)).FnNode-U32(1)))*16) - if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) != 5 { + if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) != JSON_STRING { return -1 } - *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((0x40)) + *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((JNODE_LABEL)) j = U32(x) for jsonIsSpace[uint8(*(*int8)(unsafe.Pointer(z + uintptr(j))))] != 0 { j++ @@ -149740,7 +147276,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 return (int32(j + U32(1))) } else if int32(c) == '[' { // Parse array - iThis = jsonParseAddNode(tls, pParse, uint32(6), uint32(0), uintptr(0)) + iThis = jsonParseAddNode(tls, pParse, JSON_ARRAY, uint32(0), uintptr(0)) if iThis < 0 { return -1 } @@ -149748,7 +147284,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 for jsonIsSpace[uint8(*(*int8)(unsafe.Pointer(z + uintptr(j))))] != 0 { j++ } - if int32(libc.PreIncUint16(&(*JsonParse)(unsafe.Pointer(pParse)).FiDepth, 1)) > 2000 { + if int32(libc.PreIncUint16(&(*JsonParse)(unsafe.Pointer(pParse)).FiDepth, 1)) > JSON_MAX_DEPTH { return -1 } x = jsonParseValue(tls, pParse, j) @@ -149780,7 +147316,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 j = (i + U32(1)) for { c = *(*int8)(unsafe.Pointer(z + uintptr(j))) - if (int32(c) & ^libc.Int32(0x1f)) == 0 { + if (int32(c) & libc.CplInt32(0x1f)) == 0 { // Control characters are not allowed in strings return -1 } @@ -149789,7 +147325,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 if ((((((((int32(c) == '"') || (int32(c) == '\\')) || (int32(c) == '/')) || (int32(c) == 'b')) || (int32(c) == 'f')) || (int32(c) == 'n')) || (int32(c) == 'r')) || (int32(c) == 't')) || ((int32(c) == 'u') && (jsonIs4Hex(tls, ((z+uintptr(j))+uintptr(1))) != 0)) { - jnFlags = U8(0x02) + jnFlags = JNODE_ESCAPE } else { return -1 } @@ -149798,7 +147334,7 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 } j++ } - jsonParseAddNode(tls, pParse, uint32(5), ((j + U32(1)) - i), (z + uintptr(i))) + jsonParseAddNode(tls, pParse, JSON_STRING, ((j + U32(1)) - i), (z + uintptr(i))) if !(int32((*JsonParse)(unsafe.Pointer(pParse)).Foom) != 0) { (*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(((*JsonParse)(unsafe.Pointer(pParse)).FnNode-U32(1)))*16)).FjnFlags = jnFlags } @@ -149806,17 +147342,17 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 } else if ((int32(c) == 'n') && (libc.Xstrncmp(tls, (z+uintptr(i)), ts+7843 /* "null" */, uint64(4)) == 0)) && !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr((i + U32(4))))))]) & 0x06) != 0) { - jsonParseAddNode(tls, pParse, uint32(0), uint32(0), uintptr(0)) + jsonParseAddNode(tls, pParse, JSON_NULL, uint32(0), uintptr(0)) return (int32(i + U32(4))) } else if ((int32(c) == 't') && (libc.Xstrncmp(tls, (z+uintptr(i)), ts+9544 /* "true" */, uint64(4)) == 0)) && !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr((i + U32(4))))))]) & 0x06) != 0) { - jsonParseAddNode(tls, pParse, uint32(1), uint32(0), uintptr(0)) + jsonParseAddNode(tls, pParse, JSON_TRUE, uint32(0), uintptr(0)) return (int32(i + U32(4))) } else if ((int32(c) == 'f') && (libc.Xstrncmp(tls, (z+uintptr(i)), ts+9549 /* "false" */, uint64(5)) == 0)) && !((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr((i + U32(5))))))]) & 0x06) != 0) { - jsonParseAddNode(tls, pParse, uint32(2), uint32(0), uintptr(0)) + jsonParseAddNode(tls, pParse, JSON_FALSE, uint32(0), uintptr(0)) return (int32(i + U32(5))) } else if (int32(c) == '-') || ((int32(c) >= '0') && (int32(c) <= '9')) { // Parse number @@ -149874,9 +147410,9 @@ func jsonParseValue(tls *libc.TLS, pParse uintptr, i U32) int32 { /* sqlite3.c:1 } jsonParseAddNode(tls, pParse, func() uint32 { if seenDP != 0 { - return uint32(4) + return JSON_REAL } - return uint32(3) + return JSON_INT }(), (j - i), (z + uintptr(i))) return int32(j) @@ -149938,7 +147474,7 @@ func jsonParseFillInParentage(tls *libc.TLS, pParse uintptr, i U32, iParent U32) var j U32 *(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaUp + uintptr(i)*4)) = iParent switch int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) { - case 6: + case JSON_ARRAY: { for j = U32(1); j <= (*JsonNode)(unsafe.Pointer(pNode)).Fn; j = j + (jsonNodeSize(tls, (pNode + uintptr(j)*16))) { jsonParseFillInParentage(tls, pParse, (i + j), i) @@ -149946,7 +147482,7 @@ func jsonParseFillInParentage(tls *libc.TLS, pParse uintptr, i U32, iParent U32) break } - case 7: + case JSON_OBJECT: { for j = U32(1); j <= (*JsonNode)(unsafe.Pointer(pNode)).Fn; j = j + (jsonNodeSize(tls, ((pNode+uintptr(j)*16)+uintptr(1)*16)) + U32(1)) { *(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaUp + uintptr((i+j))*4)) = i @@ -149970,10 +147506,10 @@ func jsonParseFindParents(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:18 aUp = libc.AssignPtrUintptr(pParse+24 /* &.aUp */, Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(U32(0)))*uint64((*JsonParse)(unsafe.Pointer(pParse)).FnNode))))) if aUp == uintptr(0) { (*JsonParse)(unsafe.Pointer(pParse)).Foom = U8(1) - return 7 + return SQLITE_NOMEM } jsonParseFillInParentage(tls, pParse, uint32(0), uint32(0)) - return 0 + return SQLITE_OK } // Magic number used for the JSON parse cache in sqlite3_get_auxdata() @@ -149985,8 +147521,8 @@ func jsonParseFindParents(tls *libc.TLS, pParse uintptr) int32 { /* sqlite3.c:18 // and also register the new parse so that it will be available for // future sqlite3_get_auxdata() calls. func jsonParseCached(tls *libc.TLS, pCtx uintptr, argv uintptr, pErrCtx uintptr) uintptr { /* sqlite3.c:186461:18: */ - var zJson uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var nJson int32 = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var zJson uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + var nJson int32 = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) var p uintptr var pMatch uintptr = uintptr(0) var iKey int32 @@ -149996,7 +147532,7 @@ func jsonParseCached(tls *libc.TLS, pCtx uintptr, argv uintptr, pErrCtx uintptr) if zJson == uintptr(0) { return uintptr(0) } - for iKey = 0; iKey < 4; iKey++ { + for iKey = 0; iKey < JSON_CACHE_SZ; iKey++ { p = Xsqlite3_get_auxdata(tls, pCtx, ((-429938) + iKey)) if p == uintptr(0) { iMinKey = iKey @@ -150026,7 +147562,7 @@ func jsonParseCached(tls *libc.TLS, pCtx uintptr, argv uintptr, pErrCtx uintptr) return uintptr(0) } libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(JsonParse{}))) - (*JsonParse)(unsafe.Pointer(p)).FzJson = (p + uintptr(1)*48) + (*JsonParse)(unsafe.Pointer(p)).FzJson = (p + 1*48) libc.Xmemcpy(tls, (*JsonParse)(unsafe.Pointer(p)).FzJson, zJson, (uint64(nJson + 1))) if jsonParse(tls, p, pErrCtx, (*JsonParse)(unsafe.Pointer(p)).FzJson) != 0 { Xsqlite3_free(tls, p) @@ -150042,7 +147578,7 @@ func jsonParseCached(tls *libc.TLS, pCtx uintptr, argv uintptr, pErrCtx uintptr) // Compare the OBJECT label at pNode against zKey,nKey. Return true on // a match. func jsonLabelCompare(tls *libc.TLS, pNode uintptr, zKey uintptr, nKey U32) int32 { /* sqlite3.c:186523:12: */ - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x01) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_RAW) != 0 { if (*JsonNode)(unsafe.Pointer(pNode)).Fn != nKey { return 0 } @@ -150069,18 +147605,18 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp var nKey U32 var zKey uintptr var pRoot uintptr = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*16) - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(zPath))) == 0 { return pRoot } - if (int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags) & 0x08) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags) & JNODE_REPLACE) != 0 { return uintptr(0) } - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) == '.' { - if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != 7 { + if int32(*(*int8)(unsafe.Pointer(zPath))) == '.' { + if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != JSON_OBJECT { return uintptr(0) } zPath++ - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) == '"' { + if int32(*(*int8)(unsafe.Pointer(zPath))) == '"' { zKey = (zPath + uintptr(1)) for i = U32(1); (*(*int8)(unsafe.Pointer(zPath + uintptr(i))) != 0) && (int32(*(*int8)(unsafe.Pointer(zPath + uintptr(i)))) != '"'); i++ { } @@ -150110,7 +147646,7 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp j++ j = j + (jsonNodeSize(tls, (pRoot + uintptr(j)*16))) } - if (int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags) & 0x20) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags) & JNODE_APPEND) == 0 { break } iRoot = iRoot + (*(*U32)(unsafe.Pointer(pRoot + 8 /* &.u */))) @@ -150121,8 +147657,8 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp var iStart U32 var iLabel U32 var pNode uintptr - iStart = U32(jsonParseAddNode(tls, pParse, uint32(7), uint32(2), uintptr(0))) - iLabel = U32(jsonParseAddNode(tls, pParse, uint32(5), nKey, zKey)) + iStart = U32(jsonParseAddNode(tls, pParse, JSON_OBJECT, uint32(2), uintptr(0))) + iLabel = U32(jsonParseAddNode(tls, pParse, JSON_STRING, nKey, zKey)) zPath += uintptr(i) pNode = jsonLookupAppend(tls, pParse, zPath, pApnd, pzErr) if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 { @@ -150131,12 +147667,12 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp if pNode != 0 { pRoot = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*16) *(*U32)(unsafe.Pointer(pRoot + 8 /* &.u */)) = (iStart - iRoot) - *(*U8)(unsafe.Pointer(pRoot + 1 /* &.jnFlags */)) |= U8((0x20)) - *(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iLabel)*16 + 1 /* &.jnFlags */)) |= U8((0x01)) + *(*U8)(unsafe.Pointer(pRoot + 1 /* &.jnFlags */)) |= U8((JNODE_APPEND)) + *(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iLabel)*16 + 1 /* &.jnFlags */)) |= U8((JNODE_RAW)) } return pNode } - } else if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) == '[' { + } else if int32(*(*int8)(unsafe.Pointer(zPath))) == '[' { i = U32(0) j = U32(1) for (int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zPath + uintptr(j))))]) & 0x04) != 0 { @@ -150144,20 +147680,20 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp j++ } if (j < U32(2)) || (int32(*(*int8)(unsafe.Pointer(zPath + uintptr(j)))) != ']') { - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(1)))) == '#' { + if int32(*(*int8)(unsafe.Pointer(zPath + 1))) == '#' { var pBase uintptr = pRoot var iBase int32 = int32(iRoot) - if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != 6 { + if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != JSON_ARRAY { return uintptr(0) } for { for j <= (*JsonNode)(unsafe.Pointer(pBase)).Fn { - if (int32((*JsonNode)(unsafe.Pointer(pBase+uintptr(j)*16)).FjnFlags) & 0x04) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pBase+uintptr(j)*16)).FjnFlags) & JNODE_REMOVE) == 0 { i++ } j = j + (jsonNodeSize(tls, (pBase + uintptr(j)*16))) } - if (int32((*JsonNode)(unsafe.Pointer(pBase)).FjnFlags) & 0x20) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pBase)).FjnFlags) & JNODE_APPEND) == 0 { break } iBase = int32(U32(iBase) + (*(*U32)(unsafe.Pointer(pBase + 8 /* &.u */)))) @@ -150165,7 +147701,7 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp j = U32(1) } j = U32(2) - if (int32(*(*int8)(unsafe.Pointer(zPath + uintptr(2)))) == '-') && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zPath + uintptr(3))))]) & 0x04) != 0) { + if (int32(*(*int8)(unsafe.Pointer(zPath + 2))) == '-') && ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zPath + 3)))]) & 0x04) != 0) { var x uint32 = uint32(0) j = U32(3) for ok := true; ok; ok = ((int32(Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zPath + uintptr(j))))]) & 0x04) != 0) { @@ -150186,19 +147722,19 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp return uintptr(0) } } - if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != 6 { + if int32((*JsonNode)(unsafe.Pointer(pRoot)).FeType) != JSON_ARRAY { return uintptr(0) } zPath += (uintptr(j + U32(1))) j = U32(1) for { - for (j <= (*JsonNode)(unsafe.Pointer(pRoot)).Fn) && ((i > U32(0)) || ((int32((*JsonNode)(unsafe.Pointer(pRoot+uintptr(j)*16)).FjnFlags) & 0x04) != 0)) { - if (int32((*JsonNode)(unsafe.Pointer(pRoot+uintptr(j)*16)).FjnFlags) & 0x04) == 0 { + for (j <= (*JsonNode)(unsafe.Pointer(pRoot)).Fn) && ((i > U32(0)) || ((int32((*JsonNode)(unsafe.Pointer(pRoot+uintptr(j)*16)).FjnFlags) & JNODE_REMOVE) != 0)) { + if (int32((*JsonNode)(unsafe.Pointer(pRoot+uintptr(j)*16)).FjnFlags) & JNODE_REMOVE) == 0 { i-- } j = j + (jsonNodeSize(tls, (pRoot + uintptr(j)*16))) } - if (int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags) & 0x20) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pRoot)).FjnFlags) & JNODE_APPEND) == 0 { break } iRoot = iRoot + (*(*U32)(unsafe.Pointer(pRoot + 8 /* &.u */))) @@ -150211,7 +147747,7 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp if (i == U32(0)) && (pApnd != 0) { var iStart U32 var pNode uintptr - iStart = U32(jsonParseAddNode(tls, pParse, uint32(6), uint32(1), uintptr(0))) + iStart = U32(jsonParseAddNode(tls, pParse, JSON_ARRAY, uint32(1), uintptr(0))) pNode = jsonLookupAppend(tls, pParse, zPath, pApnd, pzErr) if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 { return uintptr(0) @@ -150219,7 +147755,7 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp if pNode != 0 { pRoot = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*16) *(*U32)(unsafe.Pointer(pRoot + 8 /* &.u */)) = (iStart - iRoot) - *(*U8)(unsafe.Pointer(pRoot + 1 /* &.jnFlags */)) |= U8((0x20)) + *(*U8)(unsafe.Pointer(pRoot + 1 /* &.jnFlags */)) |= U8((JNODE_APPEND)) } return pNode } @@ -150233,17 +147769,17 @@ func jsonLookupStep(tls *libc.TLS, pParse uintptr, iRoot U32, zPath uintptr, pAp // to the inserted node, or return NULL if the append fails. func jsonLookupAppend(tls *libc.TLS, pParse uintptr, zPath uintptr, pApnd uintptr, pzErr uintptr) uintptr { /* sqlite3.c:186690:17: */ *(*int32)(unsafe.Pointer(pApnd)) = 1 - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) == 0 { - jsonParseAddNode(tls, pParse, uint32(0), uint32(0), uintptr(0)) + if int32(*(*int8)(unsafe.Pointer(zPath))) == 0 { + jsonParseAddNode(tls, pParse, JSON_NULL, uint32(0), uintptr(0)) if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 { return uintptr(0) } return ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(((*JsonParse)(unsafe.Pointer(pParse)).FnNode-U32(1)))*16) } - if int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) == '.' { - jsonParseAddNode(tls, pParse, uint32(7), uint32(0), uintptr(0)) + if int32(*(*int8)(unsafe.Pointer(zPath))) == '.' { + jsonParseAddNode(tls, pParse, JSON_OBJECT, uint32(0), uintptr(0)) } else if libc.Xstrncmp(tls, zPath, ts+27879 /* "[0]" */, uint64(3)) == 0 { - jsonParseAddNode(tls, pParse, uint32(6), uint32(0), uintptr(0)) + jsonParseAddNode(tls, pParse, JSON_ARRAY, uint32(0), uintptr(0)) } else { return uintptr(0) } @@ -150287,7 +147823,7 @@ func jsonLookup(tls *libc.TLS, pParse uintptr, zPath uintptr, pApnd uintptr, pCt return uintptr(0) __1: ; - if !(int32(*(*int8)(unsafe.Pointer(zPath + uintptr(0)))) != '$') { + if !(int32(*(*int8)(unsafe.Pointer(zPath))) != '$') { goto __2 } *(*uintptr)(unsafe.Pointer(bp /* zErr */)) = zPath @@ -150340,10 +147876,10 @@ func jsonRemoveAllNulls(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:186780:13: n = int32((*JsonNode)(unsafe.Pointer(pNode)).Fn) for i = 2; i <= n; i = int32(U32(i) + (jsonNodeSize(tls, (pNode+uintptr(i)*16)) + U32(1))) { switch int32((*JsonNode)(unsafe.Pointer(pNode + uintptr(i)*16)).FeType) { - case 0: - *(*U8)(unsafe.Pointer(pNode + uintptr(i)*16 + 1 /* &.jnFlags */)) |= U8((0x04)) + case JSON_NULL: + *(*U8)(unsafe.Pointer(pNode + uintptr(i)*16 + 1 /* &.jnFlags */)) |= U8((JNODE_REMOVE)) break - case 7: + case JSON_OBJECT: jsonRemoveAllNulls(tls, (pNode + uintptr(i)*16)) break } @@ -150373,9 +147909,9 @@ func jsonQuoteFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* sq _ = argc jsonInit(tls, bp /* &jx */, ctx) - jsonAppendValue(tls, bp /* &jx */, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + jsonAppendValue(tls, bp /* &jx */, *(*uintptr)(unsafe.Pointer(argv))) jsonResult(tls, bp /* &jx */) - Xsqlite3_result_subtype(tls, ctx, uint32(74)) + Xsqlite3_result_subtype(tls, ctx, JSON_SUBTYPE) } // Implementation of the json_array(VALUE,...) function. Return a JSON @@ -150396,7 +147932,7 @@ func jsonArrayFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* sq } jsonAppendChar(tls, bp /* &jx */, int8(']')) jsonResult(tls, bp /* &jx */) - Xsqlite3_result_subtype(tls, ctx, uint32(74)) + Xsqlite3_result_subtype(tls, ctx, JSON_SUBTYPE) } // json_array_length(JSON) @@ -150416,7 +147952,7 @@ func jsonArrayLengthFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { } if argc == 2 { - var zPath uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + var zPath uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) pNode = jsonLookup(tls, p, zPath, uintptr(0), ctx) } else { pNode = (*JsonParse)(unsafe.Pointer(p)).FaNode @@ -150424,7 +147960,7 @@ func jsonArrayLengthFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { if pNode == uintptr(0) { return } - if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) == 6 { + if int32((*JsonNode)(unsafe.Pointer(pNode)).FeType) == JSON_ARRAY { for i = U32(1); i <= (*JsonNode)(unsafe.Pointer(pNode)).Fn; n++ { i = i + (jsonNodeSize(tls, (pNode + uintptr(i)*16))) @@ -150479,7 +148015,7 @@ func jsonExtractFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* if (argc > 2) && (i == argc) { jsonAppendChar(tls, bp /* &jx */, int8(']')) jsonResult(tls, bp /* &jx */) - Xsqlite3_result_subtype(tls, ctx, uint32(74)) + Xsqlite3_result_subtype(tls, ctx, JSON_SUBTYPE) } jsonReset(tls, bp /* &jx */) } @@ -150490,13 +148026,13 @@ func jsonMergePatch(tls *libc.TLS, pParse uintptr, iTarget U32, pPatch uintptr) var j U32 var iRoot U32 var pTarget uintptr - if int32((*JsonNode)(unsafe.Pointer(pPatch)).FeType) != 7 { + if int32((*JsonNode)(unsafe.Pointer(pPatch)).FeType) != JSON_OBJECT { return pPatch } pTarget = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iTarget)*16) - if int32((*JsonNode)(unsafe.Pointer(pTarget)).FeType) != 7 { + if int32((*JsonNode)(unsafe.Pointer(pTarget)).FeType) != JSON_OBJECT { jsonRemoveAllNulls(tls, pPatch) return pPatch } @@ -150511,11 +148047,11 @@ func jsonMergePatch(tls *libc.TLS, pParse uintptr, iTarget U32, pPatch uintptr) for j = U32(1); j < (*JsonNode)(unsafe.Pointer(pTarget)).Fn; j = j + (jsonNodeSize(tls, (pTarget+uintptr((j+U32(1)))*16)) + U32(1)) { if ((*JsonNode)(unsafe.Pointer(pTarget+uintptr(j)*16)).Fn == nKey) && (libc.Xstrncmp(tls, *(*uintptr)(unsafe.Pointer(pTarget + uintptr(j)*16 + 8 /* &.u */)), zKey, uint64(nKey)) == 0) { - if (int32((*JsonNode)(unsafe.Pointer(pTarget+uintptr((j+U32(1)))*16)).FjnFlags) & (0x04 | 0x10)) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pTarget+uintptr((j+U32(1)))*16)).FjnFlags) & (JNODE_REMOVE | JNODE_PATCH)) != 0 { break } - if int32((*JsonNode)(unsafe.Pointer(pPatch+uintptr((i+U32(1)))*16)).FeType) == 0 { - *(*U8)(unsafe.Pointer(pTarget + uintptr((j+U32(1)))*16 + 1 /* &.jnFlags */)) |= U8((0x04)) + if int32((*JsonNode)(unsafe.Pointer(pPatch+uintptr((i+U32(1)))*16)).FeType) == JSON_NULL { + *(*U8)(unsafe.Pointer(pTarget + uintptr((j+U32(1)))*16 + 1 /* &.jnFlags */)) |= U8((JNODE_REMOVE)) } else { var pNew uintptr = jsonMergePatch(tls, pParse, ((iTarget + j) + U32(1)), (pPatch + uintptr((i+U32(1)))*16)) if pNew == uintptr(0) { @@ -150524,27 +148060,27 @@ func jsonMergePatch(tls *libc.TLS, pParse uintptr, iTarget U32, pPatch uintptr) pTarget = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iTarget)*16) if pNew != (pTarget + uintptr((j+U32(1)))*16) { *(*uintptr)(unsafe.Pointer(pTarget + uintptr((j+U32(1)))*16 + 8 /* &.u */)) = pNew - *(*U8)(unsafe.Pointer(pTarget + uintptr((j+U32(1)))*16 + 1 /* &.jnFlags */)) |= U8((0x10)) + *(*U8)(unsafe.Pointer(pTarget + uintptr((j+U32(1)))*16 + 1 /* &.jnFlags */)) |= U8((JNODE_PATCH)) } } break } } - if (j >= (*JsonNode)(unsafe.Pointer(pTarget)).Fn) && (int32((*JsonNode)(unsafe.Pointer(pPatch+uintptr((i+U32(1)))*16)).FeType) != 0) { + if (j >= (*JsonNode)(unsafe.Pointer(pTarget)).Fn) && (int32((*JsonNode)(unsafe.Pointer(pPatch+uintptr((i+U32(1)))*16)).FeType) != JSON_NULL) { var iStart int32 var iPatch int32 - iStart = jsonParseAddNode(tls, pParse, uint32(7), uint32(2), uintptr(0)) - jsonParseAddNode(tls, pParse, uint32(5), nKey, zKey) - iPatch = jsonParseAddNode(tls, pParse, uint32(1), uint32(0), uintptr(0)) + iStart = jsonParseAddNode(tls, pParse, JSON_OBJECT, uint32(2), uintptr(0)) + jsonParseAddNode(tls, pParse, JSON_STRING, nKey, zKey) + iPatch = jsonParseAddNode(tls, pParse, JSON_TRUE, uint32(0), uintptr(0)) if (*JsonParse)(unsafe.Pointer(pParse)).Foom != 0 { return uintptr(0) } jsonRemoveAllNulls(tls, pPatch) pTarget = ((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iTarget)*16) - *(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*16 + 1 /* &.jnFlags */)) |= U8((0x20)) + *(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*16 + 1 /* &.jnFlags */)) |= U8((JNODE_APPEND)) *(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iRoot)*16 + 8 /* &.u */)) = (U32(iStart) - iRoot) iRoot = U32(iStart) - *(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iPatch)*16 + 1 /* &.jnFlags */)) |= U8((0x10)) + *(*U8)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iPatch)*16 + 1 /* &.jnFlags */)) |= U8((JNODE_PATCH)) *(*uintptr)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(pParse)).FaNode + uintptr(iPatch)*16 + 8 /* &.u */)) = (pPatch + uintptr((i+U32(1)))*16) } } @@ -150565,10 +148101,10 @@ func jsonPatchFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* sq var pResult uintptr // The result of the merge _ = argc - if jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) != 0 { + if jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != 0 { return } - if jsonParse(tls, bp+48 /* &y */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) != 0 { + if jsonParse(tls, bp+48 /* &y */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) != 0 { jsonParseReset(tls, bp /* &x */) return } @@ -150604,7 +148140,7 @@ func jsonObjectFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* s jsonInit(tls, bp /* &jx */, ctx) jsonAppendChar(tls, bp /* &jx */, int8('{')) for i = 0; i < argc; i = i + (2) { - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) != 3 { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) != SQLITE_TEXT { Xsqlite3_result_error(tls, ctx, ts+28003 /* "json_object() la..." */, -1) jsonReset(tls, bp /* &jx */) return @@ -150618,7 +148154,7 @@ func jsonObjectFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* s } jsonAppendChar(tls, bp /* &jx */, int8('}')) jsonResult(tls, bp /* &jx */) - Xsqlite3_result_subtype(tls, ctx, uint32(74)) + Xsqlite3_result_subtype(tls, ctx, JSON_SUBTYPE) } // json_remove(JSON, PATH, ...) @@ -150641,7 +148177,7 @@ func jsonRemoveFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* s return __1: ; - if !(jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) != 0) { + if !(jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != 0) { goto __2 } return @@ -150670,7 +148206,7 @@ __7: if !(pNode != 0) { goto __8 } - *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((0x04)) + *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((JNODE_REMOVE)) __8: ; goto __4 @@ -150680,7 +148216,7 @@ __4: goto __5 __5: ; - if !((int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode+uintptr(0)*16)).FjnFlags) & 0x04) == 0) { + if !((int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode)).FjnFlags) & JNODE_REMOVE) == 0) { goto __9 } jsonReturnJson(tls, (*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode, ctx, uintptr(0)) @@ -150717,7 +148253,7 @@ __1: return __2: ; - if !(jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) != 0) { + if !(jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != 0) { goto __3 } return @@ -150740,7 +148276,7 @@ __7: if !(pNode != 0) { goto __8 } - *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((int32(U8(0x08)))) + *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((int32(JNODE_REPLACE))) *(*U32)(unsafe.Pointer(pNode + 8 /* &.u */)) = (i + U32(1)) __8: ; @@ -150751,10 +148287,10 @@ __5: goto __6 __6: ; - if !((int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode+uintptr(0)*16)).FjnFlags) & 0x08) != 0) { + if !((int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode)).FjnFlags) & JNODE_REPLACE) != 0) { goto __9 } - Xsqlite3_result_value(tls, ctx, *(*uintptr)(unsafe.Pointer(argv + uintptr(*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode + uintptr(0)*16 + 8 /* &.u */)))*8))) + Xsqlite3_result_value(tls, ctx, *(*uintptr)(unsafe.Pointer(argv + uintptr(*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode + 8 /* &.u */)))*8))) goto __10 __9: jsonReturnJson(tls, (*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode, ctx, argv) @@ -150806,7 +148342,7 @@ __1: return __2: ; - if !(jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) != 0) { + if !(jsonParse(tls, bp /* &x */, ctx, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv)))) != 0) { goto __3 } return @@ -150837,7 +148373,7 @@ __9: if !((pNode != 0) && ((*(*int32)(unsafe.Pointer(bp + 48 /* bApnd */)) != 0) || (bIsSet != 0))) { goto __11 } - *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((int32(U8(0x08)))) + *(*U8)(unsafe.Pointer(pNode + 1 /* &.jnFlags */)) |= U8((int32(JNODE_REPLACE))) *(*U32)(unsafe.Pointer(pNode + 8 /* &.u */)) = (i + U32(1)) __11: ; @@ -150852,10 +148388,10 @@ __5: goto __6 __6: ; - if !((int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode+uintptr(0)*16)).FjnFlags) & 0x08) != 0) { + if !((int32((*JsonNode)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode)).FjnFlags) & JNODE_REPLACE) != 0) { goto __12 } - Xsqlite3_result_value(tls, ctx, *(*uintptr)(unsafe.Pointer(argv + uintptr(*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode + uintptr(0)*16 + 8 /* &.u */)))*8))) + Xsqlite3_result_value(tls, ctx, *(*uintptr)(unsafe.Pointer(argv + uintptr(*(*U32)(unsafe.Pointer((*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode + 8 /* &.u */)))*8))) goto __13 __12: jsonReturnJson(tls, (*JsonParse)(unsafe.Pointer(bp /* &x */)).FaNode, ctx, argv) @@ -150880,7 +148416,7 @@ func jsonTypeFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* sql return } if argc == 2 { - zPath = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zPath = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) pNode = jsonLookup(tls, p, zPath, uintptr(0), ctx) } else { pNode = (*JsonParse)(unsafe.Pointer(p)).FaNode @@ -150920,7 +148456,7 @@ func jsonArrayStep(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* sq jsonAppendChar(tls, pStr, int8(',')) (*JsonString)(unsafe.Pointer(pStr)).FpCtx = ctx } - jsonAppendValue(tls, pStr, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + jsonAppendValue(tls, pStr, *(*uintptr)(unsafe.Pointer(argv))) } } @@ -150951,7 +148487,7 @@ func jsonArrayCompute(tls *libc.TLS, ctx uintptr, isFinal int32) { /* sqlite3.c: } else { Xsqlite3_result_text(tls, ctx, ts+28048 /* "[]" */, 2, uintptr(0)) } - Xsqlite3_result_subtype(tls, ctx, uint32(74)) + Xsqlite3_result_subtype(tls, ctx, JSON_SUBTYPE) } func jsonArrayValue(tls *libc.TLS, ctx uintptr) { /* sqlite3.c:187353:13: */ @@ -151001,7 +148537,7 @@ func jsonGroupInverse(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* } } *(*U64)(unsafe.Pointer(pStr + 24 /* &.nUsed */)) -= (U64(i)) - libc.Xmemmove(tls, (z + uintptr(1)), (z + uintptr((i + uint32(1)))), (Size_t((*JsonString)(unsafe.Pointer(pStr)).FnUsed) - uint64(1))) + libc.Xmemmove(tls, (z + 1), (z + uintptr((i + uint32(1)))), (Size_t((*JsonString)(unsafe.Pointer(pStr)).FnUsed) - uint64(1))) } // json_group_obj(NAME,VALUE) @@ -151021,11 +148557,11 @@ func jsonObjectStep(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) { /* s jsonAppendChar(tls, pStr, int8(',')) (*JsonString)(unsafe.Pointer(pStr)).FpCtx = ctx } - z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - n = U32(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) + n = U32(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) jsonAppendString(tls, pStr, z, n) jsonAppendChar(tls, pStr, int8(':')) - jsonAppendValue(tls, pStr, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + jsonAppendValue(tls, pStr, *(*uintptr)(unsafe.Pointer(argv + 1*8))) } } @@ -151055,7 +148591,7 @@ func jsonObjectCompute(tls *libc.TLS, ctx uintptr, isFinal int32) { /* sqlite3.c } else { Xsqlite3_result_text(tls, ctx, ts+28051 /* "{}" */, 2, uintptr(0)) } - Xsqlite3_result_subtype(tls, ctx, uint32(74)) + Xsqlite3_result_subtype(tls, ctx, JSON_SUBTYPE) } func jsonObjectValue(tls *libc.TLS, ctx uintptr) { /* sqlite3.c:187460:13: */ @@ -151107,13 +148643,13 @@ func jsonEachConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv u rc = Xsqlite3_declare_vtab(tls, db, ts+28054 /* "CREATE TABLE x(k..." */) - if rc == 0 { + if rc == SQLITE_OK { pNew = libc.AssignPtrUintptr(ppVtab, Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Sqlite3_vtab{})))) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(Sqlite3_vtab{}))) - Xsqlite3_vtab_config(tls, db, 2, 0) + Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) } return rc } @@ -151121,7 +148657,7 @@ func jsonEachConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv u // destructor for json_each virtual table func jsonEachDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:187530:12: */ Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // constructor for a JsonEachCursor object for json_each(). @@ -151131,17 +148667,17 @@ func jsonEachOpenEach(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* sql _ = p pCur = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(JsonEachCursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(JsonEachCursor{}))) *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // constructor for a JsonEachCursor object for json_tree(). func jsonEachOpenTree(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* sqlite3.c:187548:12: */ var rc int32 = jsonEachOpenEach(tls, p, ppCursor) - if rc == 0 { + if rc == SQLITE_OK { var pCur uintptr = *(*uintptr)(unsafe.Pointer(ppCursor)) (*JsonEachCursor)(unsafe.Pointer(pCur)).FbRecursive = U8(1) } @@ -151167,7 +148703,7 @@ func jsonEachClose(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187572:12: * var p uintptr = cur jsonEachCursorReset(tls, p) Xsqlite3_free(tls, cur) - return 0 + return SQLITE_OK } // Return TRUE if the jsonEachCursor object has been advanced off the end @@ -151181,7 +148717,7 @@ func jsonEachEof(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187581:12: */ func jsonEachNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187587:12: */ var p uintptr = cur if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 { - if (int32((*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*16)).FjnFlags) & 0x40) != 0 { + if (int32((*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*16)).FjnFlags) & JNODE_LABEL) != 0 { (*JsonEachCursor)(unsafe.Pointer(p)).Fi++ } (*JsonEachCursor)(unsafe.Pointer(p)).Fi++ @@ -151190,7 +148726,7 @@ func jsonEachNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187587:12: */ var iUp U32 = *(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaUp + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*4)) var pUp uintptr = ((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(iUp)*16) (*JsonEachCursor)(unsafe.Pointer(p)).FeType = (*JsonNode)(unsafe.Pointer(pUp)).FeType - if int32((*JsonNode)(unsafe.Pointer(pUp)).FeType) == 6 { + if int32((*JsonNode)(unsafe.Pointer(pUp)).FeType) == JSON_ARRAY { if iUp == ((*JsonEachCursor)(unsafe.Pointer(p)).Fi - U32(1)) { *(*U32)(unsafe.Pointer(pUp + 8 /* &.u */)) = U32(0) } else { @@ -151200,7 +148736,7 @@ func jsonEachNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187587:12: */ } } else { switch int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) { - case 6: + case JSON_ARRAY: { *(*U32)(unsafe.Pointer(p + 16 /* &.i */)) += (jsonNodeSize(tls, ((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*16))) (*JsonEachCursor)(unsafe.Pointer(p)).FiRowid++ @@ -151208,7 +148744,7 @@ func jsonEachNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187587:12: */ } fallthrough - case 7: + case JSON_OBJECT: { *(*U32)(unsafe.Pointer(p + 16 /* &.i */)) += (U32(1) + jsonNodeSize(tls, ((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr(((*JsonEachCursor)(unsafe.Pointer(p)).Fi+U32(1)))*16))) (*JsonEachCursor)(unsafe.Pointer(p)).FiRowid++ @@ -151224,7 +148760,7 @@ func jsonEachNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:187587:12: */ } } } - return 0 + return SQLITE_OK } // Append the name of the path for element i to pStr @@ -151243,11 +148779,11 @@ func jsonEachComputePath(tls *libc.TLS, p uintptr, pStr uintptr, i U32) { /* sql jsonEachComputePath(tls, p, pStr, iUp) pNode = ((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(i)*16) pUp = ((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(iUp)*16) - if int32((*JsonNode)(unsafe.Pointer(pUp)).FeType) == 6 { + if int32((*JsonNode)(unsafe.Pointer(pUp)).FeType) == JSON_ARRAY { jsonPrintf(tls, 30, pStr, ts+28137 /* "[%d]" */, libc.VaList(bp, *(*U32)(unsafe.Pointer(pUp + 8 /* &.u */)))) } else { - if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & 0x40) == 0 { + if (int32((*JsonNode)(unsafe.Pointer(pNode)).FjnFlags) & JNODE_LABEL) == 0 { pNode -= 16 } @@ -151263,14 +148799,14 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* var p uintptr = cur var pThis uintptr = ((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*16) switch i { - case 0: + case JEACH_KEY: { if (*JsonEachCursor)(unsafe.Pointer(p)).Fi == U32(0) { break } - if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == 7 { + if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == JSON_OBJECT { jsonReturn(tls, pThis, ctx, uintptr(0)) - } else if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == 6 { + } else if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == JSON_ARRAY { var iKey U32 if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 { if (*JsonEachCursor)(unsafe.Pointer(p)).FiRowid == U32(0) { @@ -151285,44 +148821,44 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* break } - case 1: + case JEACH_VALUE: { - if (int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & 0x40) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & JNODE_LABEL) != 0 { pThis += 16 } jsonReturn(tls, pThis, ctx, uintptr(0)) break } - case 2: + case JEACH_TYPE: { - if (int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & 0x40) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & JNODE_LABEL) != 0 { pThis += 16 } Xsqlite3_result_text(tls, ctx, jsonType[(*JsonNode)(unsafe.Pointer(pThis)).FeType], -1, uintptr(0)) break } - case 3: + case JEACH_ATOM: { - if (int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & 0x40) != 0 { + if (int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & JNODE_LABEL) != 0 { pThis += 16 } - if int32((*JsonNode)(unsafe.Pointer(pThis)).FeType) >= 6 { + if int32((*JsonNode)(unsafe.Pointer(pThis)).FeType) >= JSON_ARRAY { break } jsonReturn(tls, pThis, ctx, uintptr(0)) break } - case 4: + case JEACH_ID: { Xsqlite3_result_int64(tls, ctx, - (Sqlite3_int64((*JsonEachCursor)(unsafe.Pointer(p)).Fi) + (Sqlite3_int64(libc.Bool32((int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & 0x40) != 0))))) + (Sqlite3_int64((*JsonEachCursor)(unsafe.Pointer(p)).Fi) + (Sqlite3_int64(libc.Bool32((int32((*JsonNode)(unsafe.Pointer(pThis)).FjnFlags) & JNODE_LABEL) != 0))))) break } - case 5: + case JEACH_PARENT: { if ((*JsonEachCursor)(unsafe.Pointer(p)).Fi > (*JsonEachCursor)(unsafe.Pointer(p)).FiBegin) && ((*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0) { Xsqlite3_result_int64(tls, ctx, Sqlite3_int64(*(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaUp + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*4)))) @@ -151330,7 +148866,7 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* break } - case 6: + case JEACH_FULLKEY: { // var x JsonString at bp+24, 136 @@ -151343,9 +148879,9 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* } else { jsonAppendChar(tls, bp+24 /* &x */, int8('$')) } - if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == 6 { + if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == JSON_ARRAY { jsonPrintf(tls, 30, bp+24 /* &x */, ts+28137 /* "[%d]" */, libc.VaList(bp, (*JsonEachCursor)(unsafe.Pointer(p)).FiRowid)) - } else if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == 7 { + } else if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) == JSON_OBJECT { jsonPrintf(tls, int32((*JsonNode)(unsafe.Pointer(pThis)).Fn), bp+24 /* &x */, ts+28142 /* ".%.*s" */, libc.VaList(bp+8, ((*JsonNode)(unsafe.Pointer(pThis)).Fn-U32(2)), (*(*uintptr)(unsafe.Pointer(pThis + 8 /* &.u */))+uintptr(1)))) } } @@ -151353,7 +148889,7 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* break } - case 7: + case JEACH_PATH: { if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 { // var x JsonString at bp+160, 136 @@ -151363,9 +148899,6 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* jsonResult(tls, bp+160 /* &x */) break } - // For json_each() path and root are the same so fall through - // into the root case - /* no break */ } fallthrough @@ -151379,7 +148912,7 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* break } - case 8: + case JEACH_JSON: { Xsqlite3_result_text(tls, ctx, (*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FzJson, -1, uintptr(0)) @@ -151387,14 +148920,14 @@ func jsonEachColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* } } - return 0 + return SQLITE_OK } // Return the current rowid value func jsonEachRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* sqlite3.c:187754:12: */ var p uintptr = cur *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = Sqlite_int64((*JsonEachCursor)(unsafe.Pointer(p)).FiRowid) - return 0 + return SQLITE_OK } // The query strategy is to look for an equality constraint on the json @@ -151416,7 +148949,7 @@ func jsonEachBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* // columns in the table _ = tab - *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(0)*4)) = libc.AssignPtrInt32(bp /* &aIdx */ +uintptr(1)*4, -1) + *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */)) = libc.AssignPtrInt32(bp /* &aIdx */ +1*4, -1) pConstraint = (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint i = 0 __1: @@ -151426,15 +148959,15 @@ __1: { var iCol int32 var iMask int32 - if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < 8 { + if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < JEACH_JSON { goto __2 } - iCol = ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn - 8) + iCol = ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn - JEACH_JSON) iMask = (int32(1) << iCol) if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { unusableMask = unusableMask | (iMask) - } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == 2 { + } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ { *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(iCol)*4)) = i idxMask = idxMask | (iMask) } @@ -151451,28 +148984,28 @@ __3: if (unusableMask & ^idxMask) != 0 { // If there are any unusable constraints on JSON or ROOT, then reject // this entire plan - return 19 + return SQLITE_CONSTRAINT } - if *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(0)*4)) < 0 { + if *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */)) < 0 { // No JSON input. Leave estimatedCost at the huge value that it was // initialized to to discourage the query planner from selecting this // plan. (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0 } else { (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1.0 - i = *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(0)*4)) + i = *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */)) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) - if *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(1)*4)) < 0 { + if *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + 1*4)) < 0 { (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1 // Only JSON supplied. Plan 1 } else { - i = *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(1)*4)) + i = *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + 1*4)) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 2 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 3 // Both JSON and ROOT are supplied. Plan 3 } } - return 0 + return SQLITE_OK } // Start a search on a new JSON string @@ -151489,47 +149022,47 @@ func jsonEachFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, ar _ = argc jsonEachCursorReset(tls, p) if idxNum == 0 { - return 0 + return SQLITE_OK } - z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + z = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if z == uintptr(0) { - return 0 + return SQLITE_OK } - n = Sqlite3_int64(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + n = Sqlite3_int64(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) (*JsonEachCursor)(unsafe.Pointer(p)).FzJson = Xsqlite3_malloc64(tls, (uint64(n + int64(1)))) if (*JsonEachCursor)(unsafe.Pointer(p)).FzJson == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, (*JsonEachCursor)(unsafe.Pointer(p)).FzJson, z, (Size_t(n) + uint64(1))) if jsonParse(tls, (p+48 /* &.sParse */), uintptr(0), (*JsonEachCursor)(unsafe.Pointer(p)).FzJson) != 0 { - var rc int32 = 7 + var rc int32 = SQLITE_NOMEM if int32((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.Foom) == 0 { Xsqlite3_free(tls, (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg) (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+27864 /* "malformed JSON" */, 0) if (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { - rc = 1 + rc = SQLITE_ERROR } } jsonEachCursorReset(tls, p) return rc } else if ((*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0) && (jsonParseFindParents(tls, (p+48 /* &.sParse */)) != 0) { jsonEachCursorReset(tls, p) - return 7 + return SQLITE_NOMEM } else { var pNode uintptr = uintptr(0) if idxNum == 3 { *(*uintptr)(unsafe.Pointer(bp /* zErr */)) = uintptr(0) - zRoot = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + zRoot = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) if zRoot == uintptr(0) { - return 0 + return SQLITE_OK } - n = Sqlite3_int64(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) + n = Sqlite3_int64(Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot = Xsqlite3_malloc64(tls, (uint64(n + int64(1)))) if (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemcpy(tls, (*JsonEachCursor)(unsafe.Pointer(p)).FzRoot, zRoot, (Size_t(n) + uint64(1))) - if int32(*(*int8)(unsafe.Pointer(zRoot + uintptr(0)))) != '$' { + if int32(*(*int8)(unsafe.Pointer(zRoot))) != '$' { *(*uintptr)(unsafe.Pointer(bp /* zErr */)) = zRoot } else { pNode = jsonLookupStep(tls, (p + 48 /* &.sParse */), uint32(0), ((*JsonEachCursor)(unsafe.Pointer(p)).FzRoot + uintptr(1)), uintptr(0), bp /* &zErr */) @@ -151539,23 +149072,23 @@ func jsonEachFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, ar (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg = jsonPathSyntaxError(tls, *(*uintptr)(unsafe.Pointer(bp /* zErr */))) jsonEachCursorReset(tls, p) if (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).FzErrMsg != 0 { - return 1 + return SQLITE_ERROR } - return 7 + return SQLITE_NOMEM } else if pNode == uintptr(0) { - return 0 + return SQLITE_OK } } else { pNode = (*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode } (*JsonEachCursor)(unsafe.Pointer(p)).FiBegin = libc.AssignPtrUint32(p+16 /* &.i */, U32((int32((int64(pNode) - int64((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode)) / 16)))) (*JsonEachCursor)(unsafe.Pointer(p)).FeType = (*JsonNode)(unsafe.Pointer(pNode)).FeType - if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) >= 6 { + if int32((*JsonEachCursor)(unsafe.Pointer(p)).FeType) >= JSON_ARRAY { *(*U32)(unsafe.Pointer(pNode + 8 /* &.u */)) = U32(0) (*JsonEachCursor)(unsafe.Pointer(p)).FiEnd = (((*JsonEachCursor)(unsafe.Pointer(p)).Fi + (*JsonNode)(unsafe.Pointer(pNode)).Fn) + U32(1)) if (*JsonEachCursor)(unsafe.Pointer(p)).FbRecursive != 0 { (*JsonEachCursor)(unsafe.Pointer(p)).FeType = (*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode + uintptr(*(*U32)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaUp + uintptr((*JsonEachCursor)(unsafe.Pointer(p)).Fi)*4)))*16)).FeType - if ((*JsonEachCursor)(unsafe.Pointer(p)).Fi > U32(0)) && ((int32((*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr(((*JsonEachCursor)(unsafe.Pointer(p)).Fi-U32(1)))*16)).FjnFlags) & 0x40) != 0) { + if ((*JsonEachCursor)(unsafe.Pointer(p)).Fi > U32(0)) && ((int32((*JsonNode)(unsafe.Pointer((*JsonEachCursor)(unsafe.Pointer(p)).FsParse.FaNode+uintptr(((*JsonEachCursor)(unsafe.Pointer(p)).Fi-U32(1)))*16)).FjnFlags) & JNODE_LABEL) != 0) { (*JsonEachCursor)(unsafe.Pointer(p)).Fi-- } } else { @@ -151565,109 +149098,35 @@ func jsonEachFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, ar (*JsonEachCursor)(unsafe.Pointer(p)).FiEnd = ((*JsonEachCursor)(unsafe.Pointer(p)).Fi + U32(1)) } } - return 0 + return SQLITE_OK } // The methods of the json_each virtual table -var jsonEachModule = Sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - uintptr(0), - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - uintptr(0), - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var jsonEachModule = Sqlite3_module{ // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xShadowName } /* sqlite3.c:187902:23 */ // The methods of the json_tree virtual table. -var jsonTreeModule = Sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - uintptr(0), - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - uintptr(0), - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var jsonTreeModule = Sqlite3_module{ // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xShadowName } /* sqlite3.c:187930:23 */ // *************************************************************************** @@ -151678,14 +149137,14 @@ var jsonTreeModule = Sqlite3_module{ // func Xsqlite3Json1Init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:187964:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var i uint32 for i = uint32(0); (uint64(i) < (uint64(unsafe.Sizeof(aFunc)) / uint64(unsafe.Sizeof(struct { FzName uintptr FnArg int32 Fflag int32 FxFunc uintptr - }{})))) && (rc == 0); i++ { + }{})))) && (rc == SQLITE_OK); i++ { rc = Xsqlite3_create_function(tls, db, aFunc[i].FzName, aFunc[i].FnArg, enc, (uintptr(unsafe.Pointer(&aFunc)) + uintptr(i)*24 + 12 /* &.flag */), aFunc[i].FxFunc, uintptr(0), uintptr(0)) @@ -151697,9 +149156,9 @@ func Xsqlite3Json1Init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:187964:20 FxStep uintptr FxFinal uintptr FxValue uintptr - }{})))) && (rc == 0); i++ { + }{})))) && (rc == SQLITE_OK); i++ { rc = Xsqlite3_create_window_function(tls, db, aAgg[i].FzName, aAgg[i].FnArg, - (0x000100000 | enc), uintptr(0), + (SQLITE_SUBTYPE | enc), uintptr(0), aAgg[i].FxStep, aAgg[i].FxFinal, aAgg[i].FxValue, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) @@ -151708,7 +149167,7 @@ func Xsqlite3Json1Init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:187964:20 for i = uint32(0); (uint64(i) < (uint64(unsafe.Sizeof(aMod)) / uint64(unsafe.Sizeof(struct { FzName uintptr FpModule uintptr - }{})))) && (rc == 0); i++ { + }{})))) && (rc == SQLITE_OK); i++ { rc = Xsqlite3_create_module(tls, db, aMod[i].FzName, aMod[i].FpModule, uintptr(0)) } return rc @@ -151720,81 +149179,21 @@ var aFunc = [15]struct { Fflag int32 FxFunc uintptr }{ - { - FzName: ts + 28150, /* "json" */ - FnArg: 1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28155, /* "json_array" */ - FnArg: -1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28166, /* "json_array_lengt..." */ - FnArg: 1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28166, /* "json_array_lengt..." */ - FnArg: 2, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28184, /* "json_extract" */ - FnArg: -1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28197, /* "json_insert" */ - FnArg: -1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28209, /* "json_object" */ - FnArg: -1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28221, /* "json_patch" */ - FnArg: 2, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28232, /* "json_quote" */ - FnArg: 1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28243, /* "json_remove" */ - FnArg: -1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28255, /* "json_replace" */ - FnArg: -1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28268, /* "json_set" */ - FnArg: -1, - Fflag: 1, - FxFunc: 0}, - { - FzName: ts + 28277, /* "json_type" */ - FnArg: 1, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28277, /* "json_type" */ - FnArg: 2, - Fflag: 0, - FxFunc: 0}, - { - FzName: ts + 28287, /* "json_valid" */ - FnArg: 1, - Fflag: 0, - FxFunc: 0}, + {FzName: ts + 28150 /* "json" */, FnArg: 1, FxFunc: 0}, + {FzName: ts + 28155 /* "json_array" */, FnArg: -1, FxFunc: 0}, + {FzName: ts + 28166 /* "json_array_lengt..." */, FnArg: 1, FxFunc: 0}, + {FzName: ts + 28166 /* "json_array_lengt..." */, FnArg: 2, FxFunc: 0}, + {FzName: ts + 28184 /* "json_extract" */, FnArg: -1, FxFunc: 0}, + {FzName: ts + 28197 /* "json_insert" */, FnArg: -1, FxFunc: 0}, + {FzName: ts + 28209 /* "json_object" */, FnArg: -1, FxFunc: 0}, + {FzName: ts + 28221 /* "json_patch" */, FnArg: 2, FxFunc: 0}, + {FzName: ts + 28232 /* "json_quote" */, FnArg: 1, FxFunc: 0}, + {FzName: ts + 28243 /* "json_remove" */, FnArg: -1, FxFunc: 0}, + {FzName: ts + 28255 /* "json_replace" */, FnArg: -1, FxFunc: 0}, + {FzName: ts + 28268 /* "json_set" */, FnArg: -1, Fflag: 1, FxFunc: 0}, + {FzName: ts + 28277 /* "json_type" */, FnArg: 1, FxFunc: 0}, + {FzName: ts + 28277 /* "json_type" */, FnArg: 2, FxFunc: 0}, + {FzName: ts + 28287 /* "json_valid" */, FnArg: 1, FxFunc: 0}, } /* sqlite3.c:187972:5 */ var aAgg = [2]struct { FzName uintptr @@ -151804,31 +149203,19 @@ var aAgg = [2]struct { FxFinal uintptr FxValue uintptr }{ - { - FzName: ts + 28298, /* "json_group_array" */ - FnArg: 1, - FxStep: 0, - FxFinal: 0, - FxValue: 0}, - { - FzName: ts + 28315, /* "json_group_objec..." */ - FnArg: 2, - FxStep: 0, - FxFinal: 0, - FxValue: 0}, + {FzName: ts + 28298 /* "json_group_array" */, FnArg: 1, + FxStep: 0, FxFinal: 0, FxValue: 0}, + {FzName: ts + 28315 /* "json_group_objec..." */, FnArg: 2, + FxStep: 0, FxFinal: 0, FxValue: 0}, } /* sqlite3.c:188001:5 */ var aMod = [2]struct { FzName uintptr FpModule uintptr }{ - { - FzName: ts + 28333, /* "json_each" */ - FpModule: 0}, - { - FzName: ts + 28343, /* "json_tree" */ - FpModule: 0}, -} /* sqlite3.c:188011:5 */ -var enc int32 = ((1 | 0x000000800) | 0x000200000) /* sqlite3.c:188016:20 */ // In the SQLite core + {FzName: ts + 28333 /* "json_each" */, FpModule: 0}, + {FzName: ts + 28343 /* "json_tree" */, FpModule: 0}, +} /* sqlite3.c:188011:5 */ +var enc int32 = ((SQLITE_UTF8 | SQLITE_DETERMINISTIC) | SQLITE_INNOCUOUS) /* sqlite3.c:188016:20 */ // In the SQLite core // #include // #include @@ -151997,7 +149384,7 @@ type RtreeValue = float32 /* sqlite3.c:188256:17 */ // Functions to deserialize a 16 bit integer, 32 bit real number and // 64 bit integer. The deserialized value is returned. func readInt16(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:188535:12: */ - return ((int32(*(*U8)(unsafe.Pointer(p + uintptr(0)))) << 8) + int32(*(*U8)(unsafe.Pointer(p + uintptr(1))))) + return ((int32(*(*U8)(unsafe.Pointer(p))) << 8) + int32(*(*U8)(unsafe.Pointer(p + 1)))) } func readCoord(tls *libc.TLS, p uintptr, pCoord uintptr) { /* sqlite3.c:188538:13: */ @@ -152019,8 +149406,8 @@ func readInt64(tls *libc.TLS, p uintptr) I64 { /* sqlite3.c:188555:12: */ // 64 bit integer. The value returned is the number of bytes written // to the argument buffer (always 2, 4 and 8 respectively). func writeInt16(tls *libc.TLS, p uintptr, i int32) { /* sqlite3.c:188587:13: */ - *(*U8)(unsafe.Pointer(p + uintptr(0))) = (U8((i >> 8) & 0xFF)) - *(*U8)(unsafe.Pointer(p + uintptr(1))) = (U8((i >> 0) & 0xFF)) + *(*U8)(unsafe.Pointer(p)) = (U8((i >> 8) & 0xFF)) + *(*U8)(unsafe.Pointer(p + 1)) = (U8((i >> 0) & 0xFF)) } func writeCoord(tls *libc.TLS, p uintptr, pCoord uintptr) int32 { /* sqlite3.c:188591:12: */ @@ -152056,14 +149443,14 @@ func nodeReference(tls *libc.TLS, p uintptr) { /* sqlite3.c:188639:13: */ // Clear the content of node p (set all bytes to 0x00). func nodeZero(tls *libc.TLS, pRtree uintptr, p uintptr) { /* sqlite3.c:188649:13: */ - libc.Xmemset(tls, ((*RtreeNode)(unsafe.Pointer(p)).FzData + uintptr(2)), 0, (uint64((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize - 2))) + libc.Xmemset(tls, ((*RtreeNode)(unsafe.Pointer(p)).FzData + 2), 0, (uint64((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize - 2))) (*RtreeNode)(unsafe.Pointer(p)).FisDirty = 1 } // Given a node number iNode, return the corresponding key to use // in the Rtree.aHash table. func nodeHash(tls *libc.TLS, iNode I64) uint32 { /* sqlite3.c:188658:21: */ - return ((uint32(iNode)) % uint32(97)) + return ((uint32(iNode)) % HASHSIZE) } // Search the node hash table for node iNode. If found, return a pointer @@ -152105,7 +149492,7 @@ func nodeNew(tls *libc.TLS, pRtree uintptr, pParent uintptr) uintptr { /* sqlite pNode = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(RtreeNode{})) + uint64((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize)))) if pNode != 0 { libc.Xmemset(tls, pNode, 0, (uint64(unsafe.Sizeof(RtreeNode{})) + uint64((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize))) - (*RtreeNode)(unsafe.Pointer(pNode)).FzData = (pNode + uintptr(1)*40) + (*RtreeNode)(unsafe.Pointer(pNode)).FzData = (pNode + 1*40) (*RtreeNode)(unsafe.Pointer(pNode)).FnRef = 1 (*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef++ (*RtreeNode)(unsafe.Pointer(pNode)).FpParent = pParent @@ -152141,7 +149528,7 @@ func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNo bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var pNode uintptr = uintptr(0) // Check if the requested node is already in the hash table. If so, @@ -152150,17 +149537,17 @@ func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNo if (pParent != 0) && !(int32((*RtreeNode)(unsafe.Pointer(pNode)).FpParent) != 0) { if nodeInParentChain(tls, pNode, pParent) != 0 { - return (11 | (int32(1) << 8)) + return (SQLITE_CORRUPT | (int32(1) << 8)) } (*RtreeNode)(unsafe.Pointer(pParent)).FnRef++ (*RtreeNode)(unsafe.Pointer(pNode)).FpParent = pParent } else if ((pParent != 0) && ((*RtreeNode)(unsafe.Pointer(pNode)).FpParent != 0)) && (pParent != (*RtreeNode)(unsafe.Pointer(pNode)).FpParent) { - return (11 | (int32(1) << 8)) + return (SQLITE_CORRUPT | (int32(1) << 8)) } (*RtreeNode)(unsafe.Pointer(pNode)).FnRef++ *(*uintptr)(unsafe.Pointer(ppNode)) = pNode - return 0 + return SQLITE_OK } if (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob != 0 { @@ -152170,15 +149557,15 @@ func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNo (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob = pBlob if rc != 0 { nodeBlobReset(tls, pRtree) - if rc == 7 { - return 7 + if rc == SQLITE_NOMEM { + return SQLITE_NOMEM } } } if (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob == uintptr(0) { var zTab uintptr = Xsqlite3_mprintf(tls, ts+28353 /* "%s_node" */, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzName)) if zTab == uintptr(0) { - return 7 + return SQLITE_NOMEM } rc = Xsqlite3_blob_open(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, zTab, ts+28361 /* "data" */, iNode, 0, (pRtree + 112 /* &.pNodeBlob */)) @@ -152189,17 +149576,17 @@ func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNo *(*uintptr)(unsafe.Pointer(ppNode)) = uintptr(0) // If unable to open an sqlite3_blob on the desired row, that can only // be because the shadow tables hold erroneous data. - if rc == 1 { - rc = (11 | (int32(1) << 8)) + if rc == SQLITE_ERROR { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } else if (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize == Xsqlite3_blob_bytes(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpNodeBlob) { pNode = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(RtreeNode{})) + uint64((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize)))) if !(pNode != 0) { - rc = 7 + rc = SQLITE_NOMEM } else { (*RtreeNode)(unsafe.Pointer(pNode)).FpParent = pParent - (*RtreeNode)(unsafe.Pointer(pNode)).FzData = (pNode + uintptr(1)*40) + (*RtreeNode)(unsafe.Pointer(pNode)).FzData = (pNode + 1*40) (*RtreeNode)(unsafe.Pointer(pNode)).FnRef = 1 (*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef++ (*RtreeNode)(unsafe.Pointer(pNode)).FiNode = iNode @@ -152217,8 +149604,8 @@ func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNo // is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt. if (pNode != 0) && (iNode == int64(1)) { (*Rtree)(unsafe.Pointer(pRtree)).FiDepth = readInt16(tls, (*RtreeNode)(unsafe.Pointer(pNode)).FzData) - if (*Rtree)(unsafe.Pointer(pRtree)).FiDepth > 40 { - rc = (11 | (int32(1) << 8)) + if (*Rtree)(unsafe.Pointer(pRtree)).FiDepth > RTREE_MAX_DEPTH { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } @@ -152226,19 +149613,19 @@ func nodeAcquire(tls *libc.TLS, pRtree uintptr, iNode I64, pParent uintptr, ppNo // If no error has occurred so far, check if the "number of entries" // field on the node is too large. If so, set the return code to // SQLITE_CORRUPT_VTAB. - if (pNode != 0) && (rc == 0) { - if readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+uintptr(2))) > (((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)) { - rc = (11 | (int32(1) << 8)) + if (pNode != 0) && (rc == SQLITE_OK) { + if readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+2)) > (((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)) { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } - if rc == 0 { + if rc == SQLITE_OK { if pNode != uintptr(0) { nodeReference(tls, pParent) nodeHashInsert(tls, pRtree, pNode) } else { - rc = (11 | (int32(1) << 8)) + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } *(*uintptr)(unsafe.Pointer(ppNode)) = pNode @@ -152268,9 +149655,9 @@ func nodeOverwriteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintp func nodeDeleteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32) { /* sqlite3.c:188881:13: */ var pDst uintptr = ((*RtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr((4 + (int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) * iCell)))) var pSrc uintptr = (pDst + uintptr((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)) - var nByte int32 = (((readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+uintptr(2))) - iCell) - 1) * int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)) + var nByte int32 = (((readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+2)) - iCell) - 1) * int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)) libc.Xmemmove(tls, pDst, pSrc, uint64(nByte)) - writeInt16(tls, ((*RtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr(2)), (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+uintptr(2))) - 1)) + writeInt16(tls, ((*RtreeNode)(unsafe.Pointer(pNode)).FzData + 2), (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+2)) - 1)) (*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 1 } @@ -152283,11 +149670,11 @@ func nodeInsertCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr) var nMaxCell int32 // Maximum number of cells for pNode nMaxCell = (((*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell)) - nCell = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + uintptr(2))) + nCell = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + 2)) if nCell < nMaxCell { nodeOverwriteCell(tls, pRtree, pNode, pCell, nCell) - writeInt16(tls, ((*RtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr(2)), (nCell + 1)) + writeInt16(tls, ((*RtreeNode)(unsafe.Pointer(pNode)).FzData + 2), (nCell + 1)) (*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 1 } @@ -152296,7 +149683,7 @@ func nodeInsertCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr) // If the node is dirty, write it out to the database. func nodeWrite(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sqlite3.c:188920:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*RtreeNode)(unsafe.Pointer(pNode)).FisDirty != 0 { var p uintptr = (*Rtree)(unsafe.Pointer(pRtree)).FpWriteNode if (*RtreeNode)(unsafe.Pointer(pNode)).FiNode != 0 { @@ -152309,7 +149696,7 @@ func nodeWrite(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sqlite3. (*RtreeNode)(unsafe.Pointer(pNode)).FisDirty = 0 rc = Xsqlite3_reset(tls, p) Xsqlite3_bind_null(tls, p, 2) - if ((*RtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(0)) && (rc == 0) { + if ((*RtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(0)) && (rc == SQLITE_OK) { (*RtreeNode)(unsafe.Pointer(pNode)).FiNode = Xsqlite3_last_insert_rowid(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb) nodeHashInsert(tls, pRtree, pNode) } @@ -152320,7 +149707,7 @@ func nodeWrite(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sqlite3. // Release a reference to a node. If the node is dirty and the reference // count drops to zero, the node data is written to the database. func nodeRelease(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sqlite3.c:188946:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if pNode != 0 { (*RtreeNode)(unsafe.Pointer(pNode)).FnRef-- @@ -152332,7 +149719,7 @@ func nodeRelease(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sqlite if (*RtreeNode)(unsafe.Pointer(pNode)).FpParent != 0 { rc = nodeRelease(tls, pRtree, (*RtreeNode)(unsafe.Pointer(pNode)).FpParent) } - if rc == 0 { + if rc == SQLITE_OK { rc = nodeWrite(tls, pRtree, pNode) } nodeHashDelete(tls, pRtree, pNode) @@ -152413,7 +149800,7 @@ func rtreeRelease(tls *libc.TLS, pRtree uintptr) { /* sqlite3.c:189066:13: */ // Rtree virtual table module xDisconnect method. func rtreeDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:189090:12: */ rtreeRelease(tls, pVtab) - return 0 + return SQLITE_OK } // Rtree virtual table module xDestroy method. @@ -152430,13 +149817,13 @@ func rtreeDestroy(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:189098:12: (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName)) if !(zCreate != 0) { - rc = 7 + rc = SQLITE_NOMEM } else { nodeBlobReset(tls, pRtree) rc = Xsqlite3_exec(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb, zCreate, uintptr(0), uintptr(0), uintptr(0)) Xsqlite3_free(tls, zCreate) } - if rc == 0 { + if rc == SQLITE_OK { rtreeRelease(tls, pRtree) } @@ -152445,7 +149832,7 @@ func rtreeDestroy(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:189098:12: // Rtree virtual table module xOpen method. func rtreeOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* sqlite3.c:189126:12: */ - var rc int32 = 7 + var rc int32 = SQLITE_NOMEM var pRtree uintptr = pVTab var pCsr uintptr @@ -152453,7 +149840,7 @@ func rtreeOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* sqlite if pCsr != 0 { libc.Xmemset(tls, pCsr, 0, uint64(unsafe.Sizeof(RtreeCursor{}))) (*RtreeCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVTab - rc = 0 + rc = SQLITE_OK (*Rtree)(unsafe.Pointer(pRtree)).FnCursor++ } *(*uintptr)(unsafe.Pointer(ppCursor)) = pCsr @@ -152480,7 +149867,7 @@ func resetCursor(tls *libc.TLS, pCsr uintptr) { /* sqlite3.c:189147:13: */ Xsqlite3_free(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint) (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = uintptr(0) } - for ii = 0; ii < 5; ii++ { + for ii = 0; ii < RTREE_CACHE_SZ; ii++ { nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */) + uintptr(ii)*8))) } Xsqlite3_free(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FaPoint) @@ -152501,7 +149888,7 @@ func rtreeClose(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:189175:12: */ Xsqlite3_free(tls, pCsr) (*Rtree)(unsafe.Pointer(pRtree)).FnCursor-- nodeBlobReset(tls, pRtree) - return 0 + return SQLITE_OK } // Rtree virtual table module xEof method. @@ -152537,7 +149924,7 @@ func rtreeCallbackConstraint(tls *libc.TLS, pConstraint uintptr, eInt int32, pCe // var aCoord [10]Sqlite3_rtree_dbl at bp+8, 80 // Decoded coordinates - if ((*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop == 0x47) && (int32((*RtreeSearchPoint)(unsafe.Pointer(pSearch)).FiLevel) == 1) { + if ((*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop == RTREE_QUERY) && (int32((*RtreeSearchPoint)(unsafe.Pointer(pSearch)).FiLevel) == 1) { (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FiRowid = readInt64(tls, pCellData) } pCellData += uintptr(8) @@ -152545,73 +149932,73 @@ func rtreeCallbackConstraint(tls *libc.TLS, pConstraint uintptr, eInt int32, pCe switch nCoord { case 10: readCoord(tls, (pCellData + uintptr(36)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(9)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 9*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(32)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(8)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 8*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) fallthrough case 8: readCoord(tls, (pCellData + uintptr(28)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(7)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 7*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(24)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(6)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 6*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) fallthrough case 6: readCoord(tls, (pCellData + uintptr(20)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(5)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 5*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(16)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(4)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 4*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) fallthrough case 4: readCoord(tls, (pCellData + uintptr(12)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(3)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 3*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(8)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(2)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 2*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) fallthrough default: readCoord(tls, (pCellData + uintptr(4)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(1)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 1*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) readCoord(tls, pCellData, bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(0)*8)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */)) = Sqlite3_rtree_dbl(*(*RtreeValue)(unsafe.Pointer(bp /* &c */))) } } else { switch nCoord { case 10: readCoord(tls, (pCellData + uintptr(36)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(9)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 9*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(32)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(8)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 8*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) fallthrough case 8: readCoord(tls, (pCellData + uintptr(28)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(7)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 7*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(24)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(6)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 6*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) fallthrough case 6: readCoord(tls, (pCellData + uintptr(20)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(5)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 5*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(16)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(4)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 4*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) fallthrough case 4: readCoord(tls, (pCellData + uintptr(12)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(3)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 3*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) readCoord(tls, (pCellData + uintptr(8)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(2)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 2*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) fallthrough default: readCoord(tls, (pCellData + uintptr(4)), bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(1)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + 1*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) readCoord(tls, pCellData, bp /* &c */) - *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */ + uintptr(0)*8)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) + *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* &aCoord[0] */)) = Sqlite3_rtree_dbl(*(*int32)(unsafe.Pointer(bp /* &c */))) } } - if (*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop == 0x46 { + if (*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop == RTREE_MATCH { *(*int32)(unsafe.Pointer(bp + 88 /* eWithin */)) = 0 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pConstraint + 8 /* &.u */ /* &.xGeom */))))(tls, pInfo, nCoord, bp+8 /* &aCoord[0] */, bp+88 /* &eWithin */) if *(*int32)(unsafe.Pointer(bp + 88 /* eWithin */)) == 0 { - *(*int32)(unsafe.Pointer(peWithin)) = 0 + *(*int32)(unsafe.Pointer(peWithin)) = NOT_WITHIN } *(*Sqlite3_rtree_dbl)(unsafe.Pointer(prScore)) = 0.0 } else { @@ -152645,15 +150032,15 @@ func rtreeNonleafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uint // 4-byte aligned switch (*RtreeConstraint)(unsafe.Pointer(p)).Fop { - case 0x3f: + case RTREE_TRUE: return // Always satisfied - case 0x40: + case RTREE_FALSE: break // Never satisfied - case 0x42: + case RTREE_LE: fallthrough - case 0x43: + case RTREE_LT: fallthrough - case 0x41: + case RTREE_EQ: { // var c RtreeCoord at bp, 4 /* Coordinate decoded */ @@ -152669,7 +150056,7 @@ func rtreeNonleafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uint if *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) >= val { return } - if (*RtreeConstraint)(unsafe.Pointer(p)).Fop != 0x41 { + if (*RtreeConstraint)(unsafe.Pointer(p)).Fop != RTREE_EQ { break } fallthrough // RTREE_LE and RTREE_LT end here @@ -152693,7 +150080,7 @@ func rtreeNonleafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uint return } } - *(*int32)(unsafe.Pointer(peWithin)) = 0 + *(*int32)(unsafe.Pointer(peWithin)) = NOT_WITHIN } // Check the leaf RTree cell given by pCellData against constraint p. @@ -152724,26 +150111,26 @@ func rtreeLeafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uintptr } switch (*RtreeConstraint)(unsafe.Pointer(p)).Fop { - case 0x3f: + case RTREE_TRUE: return // Always satisfied - case 0x40: + case RTREE_FALSE: break // Never satisfied - case 0x42: + case RTREE_LE: if xN <= *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) { return } break - case 0x43: + case RTREE_LT: if xN < *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) { return } break - case 0x44: + case RTREE_GE: if xN >= *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) { return } break - case 0x45: + case RTREE_GT: if xN > *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) { return } @@ -152754,23 +150141,23 @@ func rtreeLeafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uintptr } break } - *(*int32)(unsafe.Pointer(peWithin)) = 0 + *(*int32)(unsafe.Pointer(peWithin)) = NOT_WITHIN } // One of the cells in node pNode is guaranteed to have a 64-bit // integer value equal to iRowid. Return the index of this cell. func nodeRowidIndex(tls *libc.TLS, pRtree uintptr, pNode uintptr, iRowid I64, piIndex uintptr) int32 { /* sqlite3.c:189402:12: */ var ii int32 - var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + uintptr(2))) + var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + 2)) for ii = 0; ii < nCell; ii++ { if nodeGetRowid(tls, pRtree, pNode, ii) == iRowid { *(*int32)(unsafe.Pointer(piIndex)) = ii - return 0 + return SQLITE_OK } } - return (11 | (int32(1) << 8)) + return (SQLITE_CORRUPT | (int32(1) << 8)) } // Return the index of the cell containing a pointer to node pNode @@ -152781,7 +150168,7 @@ func nodeParentIndex(tls *libc.TLS, pRtree uintptr, pNode uintptr, piIndex uintp return nodeRowidIndex(tls, pRtree, pParent, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode, piIndex) } *(*int32)(unsafe.Pointer(piIndex)) = -1 - return 0 + return SQLITE_OK } // Compare two search points. Return negative, zero, or positive if the first @@ -152816,8 +150203,8 @@ func rtreeSearchPointSwap(tls *libc.TLS, p uintptr, i int32, j int32) { /* sqlit *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(j)*24)) = t i++ j++ - if i < 5 { - if j >= 5 { + if i < RTREE_CACHE_SZ { + if j >= RTREE_CACHE_SZ { nodeRelease(tls, (*RtreeCursor)(unsafe.Pointer((p))).Fbase.FpVtab, *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + uintptr(i)*8))) *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + uintptr(i)*8)) = uintptr(0) } else { @@ -152847,7 +150234,7 @@ func rtreeNodeOfFirstSearchPoint(tls *libc.TLS, pCur uintptr, pRC uintptr) uintp if *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */) + uintptr(ii)*8)) == uintptr(0) { if ii != 0 { - id = (*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint + uintptr(0)*24)).Fid + id = (*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint)).Fid } else { id = (*RtreeCursor)(unsafe.Pointer(pCur)).FsPoint.Fid } @@ -152906,13 +150293,13 @@ func rtreeSearchPointNew(tls *libc.TLS, pCur uintptr, rScore RtreeDValue, iLevel return uintptr(0) } ii = ((int32((int64(pNew) - int64((*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint)) / 24)) + 1) - if ii < 5 { + if ii < RTREE_CACHE_SZ { - *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */) + uintptr(ii)*8)) = *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */) + uintptr(0)*8)) + *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */) + uintptr(ii)*8)) = *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */))) } else { - nodeRelease(tls, (*RtreeCursor)(unsafe.Pointer((pCur))).Fbase.FpVtab, *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */) + uintptr(0)*8))) + nodeRelease(tls, (*RtreeCursor)(unsafe.Pointer((pCur))).Fbase.FpVtab, *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */)))) } - *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */) + uintptr(0)*8)) = uintptr(0) + *(*uintptr)(unsafe.Pointer((pCur + 88 /* &.aNode */))) = uintptr(0) *(*RtreeSearchPoint)(unsafe.Pointer(pNew)) = (*RtreeCursor)(unsafe.Pointer(pCur)).FsPoint } (*RtreeCursor)(unsafe.Pointer(pCur)).FsPoint.FrScore = rScore @@ -152941,11 +150328,11 @@ func rtreeSearchPointPop(tls *libc.TLS, p uintptr) { /* sqlite3.c:189604:13: */ *(*U32)(unsafe.Pointer((p + 128 /* &.anQueue */) + uintptr((*RtreeCursor)(unsafe.Pointer(p)).FsPoint.FiLevel)*4))-- (*RtreeCursor)(unsafe.Pointer(p)).FbPoint = U8(0) } else if (*RtreeCursor)(unsafe.Pointer(p)).FnPoint != 0 { - *(*U32)(unsafe.Pointer((p + 128 /* &.anQueue */) + uintptr((*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint+uintptr(0)*24)).FiLevel)*4))-- + *(*U32)(unsafe.Pointer((p + 128 /* &.anQueue */) + uintptr((*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint)).FiLevel)*4))-- n = libc.PreDecInt32(&(*RtreeCursor)(unsafe.Pointer(p)).FnPoint, 1) - *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(0)*24)) = *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(n)*24)) - if n < (5 - 1) { - *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + uintptr(1)*8)) = *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + uintptr((n+1))*8)) + *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint)) = *(*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(p)).FaPoint + uintptr(n)*24)) + if n < (RTREE_CACHE_SZ - 1) { + *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + 1*8)) = *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + uintptr((n+1))*8)) *(*uintptr)(unsafe.Pointer((p + 88 /* &.aNode */) + uintptr((n+1))*8)) = uintptr(0) } i = 0 @@ -152983,29 +150370,29 @@ func rtreeStepToLeaf(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:189652:12 var pNode uintptr // var eWithin int32 at bp+16, 4 - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var nCell int32 var nConstraint int32 = (*RtreeCursor)(unsafe.Pointer(pCur)).FnConstraint var ii int32 var eInt int32 var x RtreeSearchPoint - eInt = (libc.Bool32(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 1)) + eInt = (libc.Bool32(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_INT32)) for ((libc.AssignUintptr(&p, rtreeSearchPointFirst(tls, pCur))) != uintptr(0)) && (int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiLevel) > 0) { var pCellData uintptr pNode = rtreeNodeOfFirstSearchPoint(tls, pCur, bp /* &rc */) if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp /* rc */)) } - nCell = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + uintptr(2))) + nCell = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + 2)) pCellData = ((*RtreeNode)(unsafe.Pointer(pNode)).FzData + uintptr((4 + (int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) * int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell))))) for int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell) < nCell { *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* rScore */)) = Sqlite3_rtree_dbl(-1) - *(*int32)(unsafe.Pointer(bp + 16 /* eWithin */)) = 2 + *(*int32)(unsafe.Pointer(bp + 16 /* eWithin */)) = FULLY_WITHIN for ii = 0; ii < nConstraint; ii++ { var pConstraint uintptr = ((*RtreeCursor)(unsafe.Pointer(pCur)).FaConstraint + uintptr(ii)*24) - if (*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop >= 0x46 { + if (*RtreeConstraint)(unsafe.Pointer(pConstraint)).Fop >= RTREE_MATCH { *(*int32)(unsafe.Pointer(bp /* rc */)) = rtreeCallbackConstraint(tls, pConstraint, eInt, pCellData, p, bp+8 /* &rScore */, bp+16 /* &eWithin */) if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { @@ -153016,13 +150403,13 @@ func rtreeStepToLeaf(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:189652:12 } else { rtreeNonleafConstraint(tls, pConstraint, eInt, pCellData, bp+16 /* &eWithin */) } - if *(*int32)(unsafe.Pointer(bp + 16 /* eWithin */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* eWithin */)) == NOT_WITHIN { (*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell++ pCellData += uintptr((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) break } } - if *(*int32)(unsafe.Pointer(bp + 16 /* eWithin */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* eWithin */)) == NOT_WITHIN { continue } (*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell++ @@ -153032,7 +150419,7 @@ func rtreeStepToLeaf(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:189652:12 for ii = 0; ii < (*RtreeCursor)(unsafe.Pointer(pCur)).FnPoint; ii++ { if (*RtreeSearchPoint)(unsafe.Pointer((*RtreeCursor)(unsafe.Pointer(pCur)).FaPoint+uintptr(ii)*24)).Fid == x.Fid { - return (11 | (int32(1) << 8)) + return (SQLITE_CORRUPT | (int32(1) << 8)) } } x.FiCell = U8(0) @@ -153049,7 +150436,7 @@ func rtreeStepToLeaf(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:189652:12 } p = rtreeSearchPointNew(tls, pCur, *(*Sqlite3_rtree_dbl)(unsafe.Pointer(bp + 8 /* rScore */)), x.FiLevel) if p == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = U8(*(*int32)(unsafe.Pointer(bp + 16 /* eWithin */))) (*RtreeSearchPoint)(unsafe.Pointer(p)).Fid = x.Fid @@ -153063,13 +150450,13 @@ func rtreeStepToLeaf(tls *libc.TLS, pCur uintptr) int32 { /* sqlite3.c:189652:12 } } (*RtreeCursor)(unsafe.Pointer(pCur)).FatEOF = (U8(libc.Bool32(p == uintptr(0)))) - return 0 + return SQLITE_OK } // Rtree virtual table module xNext method. func rtreeNext(tls *libc.TLS, pVtabCursor uintptr) int32 { /* sqlite3.c:189733:12: */ var pCsr uintptr = pVtabCursor - var rc int32 = 0 + var rc int32 = SQLITE_OK // Move to the next entry that matches the configured constraints. @@ -153089,9 +150476,9 @@ func rtreeRowid(tls *libc.TLS, pVtabCursor uintptr, pRowid uintptr) int32 { /* s var pCsr uintptr = pVtabCursor var p uintptr = rtreeSearchPointFirst(tls, pCsr) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pNode uintptr = rtreeNodeOfFirstSearchPoint(tls, pCsr, bp /* &rc */) - if (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (p != 0) { + if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (p != 0) { *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = nodeGetRowid(tls, (*RtreeCursor)(unsafe.Pointer((pCsr))).Fbase.FpVtab, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell)) } return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -153107,20 +150494,20 @@ func rtreeColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* sq var p uintptr = rtreeSearchPointFirst(tls, pCsr) // var c RtreeCoord at bp+4, 4 - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pNode uintptr = rtreeNodeOfFirstSearchPoint(tls, pCsr, bp /* &rc */) if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp /* rc */)) } if p == uintptr(0) { - return 0 + return SQLITE_OK } if i == 0 { Xsqlite3_result_int64(tls, ctx, nodeGetRowid(tls, pRtree, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell))) } else if i <= int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) { nodeGetCoord(tls, pRtree, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell), (i - 1), bp+4 /* &c */) - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { Xsqlite3_result_double(tls, ctx, float64(*(*RtreeValue)(unsafe.Pointer(bp + 4 /* &c */)))) } else { @@ -153138,12 +150525,12 @@ func rtreeColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* sq Xsqlite3_bind_int64(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, 1, nodeGetRowid(tls, pRtree, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell))) *(*int32)(unsafe.Pointer(bp /* rc */)) = Xsqlite3_step(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 100 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_ROW { (*RtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid = U8(1) } else { Xsqlite3_reset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 101 { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_DONE { + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK } return *(*int32)(unsafe.Pointer(bp /* rc */)) } @@ -153151,7 +150538,7 @@ func rtreeColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* sq Xsqlite3_result_value(tls, ctx, Xsqlite3_column_value(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, ((i-int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2))+1))) } - return 0 + return SQLITE_OK } // Use nodeAcquire() to obtain the leaf node containing the record with @@ -153163,7 +150550,7 @@ func findLeafNode(tls *libc.TLS, pRtree uintptr, iRowid I64, ppLeaf uintptr, piN var rc int32 *(*uintptr)(unsafe.Pointer(ppLeaf)) = uintptr(0) Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid, 1, iRowid) - if Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) == 100 { + if Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) == SQLITE_ROW { var iNode I64 = Xsqlite3_column_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid, 0) if piNode != 0 { *(*Sqlite3_int64)(unsafe.Pointer(piNode)) = iNode @@ -153187,14 +150574,14 @@ func deserializeGeometry(tls *libc.TLS, pValue uintptr, pCons uintptr) int32 { / pSrc = Xsqlite3_value_pointer(tls, pValue, ts+28448 /* "RtreeMatchArg" */) if pSrc == uintptr(0) { - return 1 + return SQLITE_ERROR } pInfo = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(Sqlite3_rtree_query_info{})) + uint64((*RtreeMatchArg)(unsafe.Pointer(pSrc)).FiSize)))) if !(pInfo != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pInfo, 0, uint64(unsafe.Sizeof(Sqlite3_rtree_query_info{}))) - pBlob = (pInfo + uintptr(1)*112) + pBlob = (pInfo + 1*112) libc.Xmemcpy(tls, pBlob, pSrc, uint64((*RtreeMatchArg)(unsafe.Pointer(pSrc)).FiSize)) (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FpContext = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FpContext (*Sqlite3_rtree_query_info)(unsafe.Pointer(pInfo)).FnParam = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).FnParam @@ -153204,11 +150591,11 @@ func deserializeGeometry(tls *libc.TLS, pValue uintptr, pCons uintptr) int32 { / if (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxGeom != 0 { *(*uintptr)(unsafe.Pointer(pCons + 8 /* &.u */)) = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxGeom } else { - (*RtreeConstraint)(unsafe.Pointer(pCons)).Fop = 0x47 + (*RtreeConstraint)(unsafe.Pointer(pCons)).Fop = RTREE_QUERY *(*uintptr)(unsafe.Pointer(pCons + 8 /* &.u */)) = (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb.FxQueryFunc } (*RtreeConstraint)(unsafe.Pointer(pCons)).FpInfo = pInfo - return 0 + return SQLITE_OK } // Rtree virtual table module xFilter method. @@ -153220,7 +150607,7 @@ func rtreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt var pCsr uintptr = pVtabCursor *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) = uintptr(0) var ii int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK *(*int32)(unsafe.Pointer(bp + 16 /* iCell */)) = 0 rtreeReference(tls, pRtree) @@ -153234,22 +150621,22 @@ func rtreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt // var pLeaf uintptr at bp, 8 // Leaf on which the required cell resides var p uintptr // Search point for the leaf - var iRowid I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + var iRowid I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) *(*I64)(unsafe.Pointer(bp + 8 /* iNode */)) = int64(0) - var eType int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - if (eType == 1) || - ((eType == 2) && (Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) == float64(iRowid))) { + var eType int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv))) + if (eType == SQLITE_INTEGER) || + ((eType == SQLITE_FLOAT) && (Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) == float64(iRowid))) { rc = findLeafNode(tls, pRtree, iRowid, bp /* &pLeaf */, bp+8 /* &iNode */) } else { - rc = 0 + rc = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) = uintptr(0) } - if (rc == 0) && (*(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) != uintptr(0)) { + if (rc == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) != uintptr(0)) { p = rtreeSearchPointNew(tls, pCsr, 0.0, uint8(0)) // Always returns pCsr->sPoint - *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */) + uintptr(0)*8)) = *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) + *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */))) = *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) (*RtreeSearchPoint)(unsafe.Pointer(p)).Fid = *(*I64)(unsafe.Pointer(bp + 8 /* iNode */)) - (*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = U8(1) + (*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = PARTLY_WITHIN rc = nodeRowidIndex(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)), iRowid, bp+16 /* &iCell */) (*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell = U8(*(*int32)(unsafe.Pointer(bp + 16 /* iCell */))) @@ -153260,11 +150647,11 @@ func rtreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt // Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array // with the configured constraints. rc = nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp+24 /* &pRoot */) - if (rc == 0) && (argc > 0) { + if (rc == SQLITE_OK) && (argc > 0) { (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(RtreeConstraint{})) * uint64(argc)))) (*RtreeCursor)(unsafe.Pointer(pCsr)).FnConstraint = argc if !(int32((*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint) != 0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint, 0, (uint64(unsafe.Sizeof(RtreeConstraint{})) * uint64(argc))) libc.Xmemset(tls, pCsr+128 /* &.anQueue */, 0, (uint64(unsafe.Sizeof(U32(0))) * (uint64((*Rtree)(unsafe.Pointer(pRtree)).FiDepth + 1)))) @@ -153274,43 +150661,43 @@ func rtreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintpt var eType int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*8))) (*RtreeConstraint)(unsafe.Pointer(p)).Fop = int32(*(*int8)(unsafe.Pointer(idxStr + uintptr((ii * 2))))) (*RtreeConstraint)(unsafe.Pointer(p)).FiCoord = (int32(*(*int8)(unsafe.Pointer(idxStr + uintptr(((ii * 2) + 1))))) - '0') - if (*RtreeConstraint)(unsafe.Pointer(p)).Fop >= 0x46 { + if (*RtreeConstraint)(unsafe.Pointer(p)).Fop >= RTREE_MATCH { // A MATCH operator. The right-hand-side must be a blob that // can be cast into an RtreeMatchArg object. One created using // an sqlite3_rtree_geometry_callback() SQL user function. rc = deserializeGeometry(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*8)), p) - if rc != 0 { + if rc != SQLITE_OK { break } (*Sqlite3_rtree_query_info)(unsafe.Pointer((*RtreeConstraint)(unsafe.Pointer(p)).FpInfo)).FnCoord = int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) (*Sqlite3_rtree_query_info)(unsafe.Pointer((*RtreeConstraint)(unsafe.Pointer(p)).FpInfo)).FanQueue = pCsr + 128 /* &.anQueue */ (*Sqlite3_rtree_query_info)(unsafe.Pointer((*RtreeConstraint)(unsafe.Pointer(p)).FpInfo)).FmxLevel = ((*Rtree)(unsafe.Pointer(pRtree)).FiDepth + 1) - } else if (eType == 1) || (eType == 2) { + } else if (eType == SQLITE_INTEGER) || (eType == SQLITE_FLOAT) { *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*8))) } else { *(*RtreeDValue)(unsafe.Pointer(p + 8 /* &.u */)) = 0.0 - if eType == 5 { - (*RtreeConstraint)(unsafe.Pointer(p)).Fop = 0x40 - } else if ((*RtreeConstraint)(unsafe.Pointer(p)).Fop == 0x43) || ((*RtreeConstraint)(unsafe.Pointer(p)).Fop == 0x42) { - (*RtreeConstraint)(unsafe.Pointer(p)).Fop = 0x3f + if eType == SQLITE_NULL { + (*RtreeConstraint)(unsafe.Pointer(p)).Fop = RTREE_FALSE + } else if ((*RtreeConstraint)(unsafe.Pointer(p)).Fop == RTREE_LT) || ((*RtreeConstraint)(unsafe.Pointer(p)).Fop == RTREE_LE) { + (*RtreeConstraint)(unsafe.Pointer(p)).Fop = RTREE_TRUE } else { - (*RtreeConstraint)(unsafe.Pointer(p)).Fop = 0x40 + (*RtreeConstraint)(unsafe.Pointer(p)).Fop = RTREE_FALSE } } } } } - if rc == 0 { + if rc == SQLITE_OK { var pNew uintptr pNew = rtreeSearchPointNew(tls, pCsr, 0.0, (U8((*Rtree)(unsafe.Pointer(pRtree)).FiDepth + 1))) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*RtreeSearchPoint)(unsafe.Pointer(pNew)).Fid = int64(1) (*RtreeSearchPoint)(unsafe.Pointer(pNew)).FiCell = U8(0) - (*RtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = U8(1) + (*RtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = PARTLY_WITHIN - *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */) + uintptr(0)*8)) = *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) + *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */))) = *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) = uintptr(0) rc = rtreeStepToLeaf(tls, pCsr) @@ -153359,7 +150746,7 @@ func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sql defer tls.Free(49) var pRtree uintptr = tab - var rc int32 = 0 + var rc int32 = SQLITE_OK var ii int32 var bMatch int32 = 0 // True if there exists a MATCH constraint var nRow I64 // Estimated rows returned by this scan @@ -153374,7 +150761,7 @@ func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sql // require the VDBE to evaluate the MATCH constraint, which is not currently // possible. for ii = 0; ii < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { - if int32((*sqlite3_index_constraint)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint+uintptr(ii)*12)).Fop) == 64 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint+uintptr(ii)*12)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH { bMatch = 1 } } @@ -153383,7 +150770,7 @@ func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sql var p uintptr = ((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12) if (((bMatch == 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0)) && - ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0)) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2) { + ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0)) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { // We have an equality constraint on the rowid. Use strategy 1. var jj int32 for jj = 0; jj < ii; jj++ { @@ -153401,37 +150788,37 @@ func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sql // a single row. (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 30.0 (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) - (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = 1 - return 0 + (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = SQLITE_INDEX_SCAN_UNIQUE + return SQLITE_OK } if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) && ((((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn > 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn <= int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2))) || - (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 64)) { + (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH)) { var op U8 switch int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) { - case 2: - op = U8(0x41) + case SQLITE_INDEX_CONSTRAINT_EQ: + op = RTREE_EQ break fallthrough - case 4: - op = U8(0x45) + case SQLITE_INDEX_CONSTRAINT_GT: + op = RTREE_GT break fallthrough - case 8: - op = U8(0x42) + case SQLITE_INDEX_CONSTRAINT_LE: + op = RTREE_LE break fallthrough - case 16: - op = U8(0x43) + case SQLITE_INDEX_CONSTRAINT_LT: + op = RTREE_LT break fallthrough - case 32: - op = U8(0x44) + case SQLITE_INDEX_CONSTRAINT_GE: + op = RTREE_GE break fallthrough - case 64: - op = U8(0x46) + case SQLITE_INDEX_CONSTRAINT_MATCH: + op = RTREE_MATCH break fallthrough default: @@ -153450,7 +150837,7 @@ func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sql (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 2 (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = 1 if (iIdx > 0) && (uintptr(0) == (libc.AssignPtrUintptr(pIdxInfo+48 /* &.idxStr */, Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp, bp+8 /* &zIdxStr[0] */))))) { - return 7 + return SQLITE_NOMEM } nRow = ((*Rtree)(unsafe.Pointer(pRtree)).FnRowEst >> (iIdx / 2)) @@ -153464,39 +150851,39 @@ func rtreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sql func cellArea(tls *libc.TLS, pRtree uintptr, p uintptr) RtreeDValue { /* sqlite3.c:190114:20: */ var area RtreeDValue = RtreeDValue(1) - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { switch int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim) { case 5: - area = (RtreeDValue(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(9)*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(8)*4)))) + area = (RtreeDValue(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 9*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 8*4)))) fallthrough case 4: - area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(7)*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(6)*4)))) + area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 7*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 6*4)))) fallthrough case 3: - area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(5)*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(4)*4)))) + area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 5*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 4*4)))) fallthrough case 2: - area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(3)*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(2)*4)))) + area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 3*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 2*4)))) fallthrough default: - area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(1)*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(0)*4)))) + area = area * (float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + 1*4)) - *(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */))))) } } else { switch int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim) { case 5: - area = (RtreeDValue(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(9)*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(8)*4))))) + area = (RtreeDValue(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 9*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 8*4))))) fallthrough case 4: - area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(7)*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(6)*4))))) + area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 7*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 6*4))))) fallthrough case 3: - area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(5)*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(4)*4))))) + area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 5*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 4*4))))) fallthrough case 2: - area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(3)*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(2)*4))))) + area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 3*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 2*4))))) fallthrough default: - area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(1)*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(0)*4))))) + area = area * (float64(I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + 1*4))) - I64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */)))))) } } return area @@ -153509,12 +150896,12 @@ func cellMargin(tls *libc.TLS, pRtree uintptr, p uintptr) RtreeDValue { /* sqlit var ii int32 = (int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) - 2) for ok := true; ok; ok = (ii >= 0) { margin = margin + ((func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr((ii+1))*4))) } return float64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr((ii+1))*4))) }()) - (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(ii)*4))) } return float64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(ii)*4))) @@ -153527,7 +150914,7 @@ func cellMargin(tls *libc.TLS, pRtree uintptr, p uintptr) RtreeDValue { /* sqlit // Store the union of cells p1 and p2 in p1. func cellUnion(tls *libc.TLS, pRtree uintptr, p1 uintptr, p2 uintptr) { /* sqlite3.c:190157:13: */ var ii int32 = 0 - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { for ok := true; ok; ok = (ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2)) { *(*RtreeValue)(unsafe.Pointer((p1 + 8 /* &.aCoord */) + uintptr(ii)*4)) = func() float32 { if (*(*RtreeValue)(unsafe.Pointer((p1 + 8 /* &.aCoord */) + uintptr(ii)*4))) < (*(*RtreeValue)(unsafe.Pointer((p2 + 8 /* &.aCoord */) + uintptr(ii)*4))) { @@ -153566,12 +150953,12 @@ func cellUnion(tls *libc.TLS, pRtree uintptr, p1 uintptr, p2 uintptr) { /* sqlit // by p1. False otherwise. func cellContains(tls *libc.TLS, pRtree uintptr, p1 uintptr, p2 uintptr) int32 { /* sqlite3.c:190178:12: */ var ii int32 - var isInt int32 = (libc.Bool32(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 1)) + var isInt int32 = (libc.Bool32(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_INT32)) for ii = 0; ii < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2); ii = ii + (2) { var a1 uintptr = ((p1 + 8 /* &.aCoord */) + uintptr(ii)*4) var a2 uintptr = ((p2 + 8 /* &.aCoord */) + uintptr(ii)*4) - if (!(isInt != 0) && ((*(*RtreeValue)(unsafe.Pointer(a2 + uintptr(0)*4)) < *(*RtreeValue)(unsafe.Pointer(a1 + uintptr(0)*4))) || (*(*RtreeValue)(unsafe.Pointer(a2 + uintptr(1)*4)) > *(*RtreeValue)(unsafe.Pointer(a1 + uintptr(1)*4))))) || - ((isInt != 0) && ((*(*int32)(unsafe.Pointer(a2 + uintptr(0)*4)) < *(*int32)(unsafe.Pointer(a1 + uintptr(0)*4))) || (*(*int32)(unsafe.Pointer(a2 + uintptr(1)*4)) > *(*int32)(unsafe.Pointer(a1 + uintptr(1)*4))))) { + if (!(isInt != 0) && ((*(*RtreeValue)(unsafe.Pointer(a2)) < *(*RtreeValue)(unsafe.Pointer(a1))) || (*(*RtreeValue)(unsafe.Pointer(a2 + 1*4)) > *(*RtreeValue)(unsafe.Pointer(a1 + 1*4))))) || + ((isInt != 0) && ((*(*int32)(unsafe.Pointer(a2)) < *(*int32)(unsafe.Pointer(a1))) || (*(*int32)(unsafe.Pointer(a2 + 1*4)) > *(*int32)(unsafe.Pointer(a1 + 1*4))))) { return 0 } } @@ -153603,25 +150990,25 @@ func cellOverlap(tls *libc.TLS, pRtree uintptr, p uintptr, aCell uintptr, nCell var x2 RtreeDValue x1 = func() float64 { if (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(jj)*4))) } return float64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(jj)*4))) }()) > (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(jj)*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(jj)*4))) }()) { return func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(jj)*4))) } return float64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr(jj)*4))) }() } return func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(jj)*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(jj)*4))) @@ -153629,25 +151016,25 @@ func cellOverlap(tls *libc.TLS, pRtree uintptr, p uintptr, aCell uintptr, nCell }() x2 = func() float64 { if (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr((jj+1))*4))) } return float64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr((jj+1))*4))) }()) < (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((jj+1))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((jj+1))*4))) }()) { return func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr((jj+1))*4))) } return float64(*(*int32)(unsafe.Pointer((p + 8 /* &.aCoord */) + uintptr((jj+1))*4))) }() } return func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((jj+1))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((jj+1))*4))) @@ -153676,14 +151063,14 @@ func sChooseLeaf(tls *libc.TLS, pRtree uintptr, pCell uintptr, iHeight int32, pp *(*uintptr)(unsafe.Pointer(bp /* pNode */)) = uintptr(0) rc = nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp /* &pNode */) - for ii = 0; (rc == 0) && (ii < ((*Rtree)(unsafe.Pointer(pRtree)).FiDepth - iHeight)); ii++ { + for ii = 0; (rc == SQLITE_OK) && (ii < ((*Rtree)(unsafe.Pointer(pRtree)).FiDepth - iHeight)); ii++ { var iCell int32 var iBest Sqlite3_int64 = int64(0) var fMinGrowth RtreeDValue = 0.0 var fMinArea RtreeDValue = 0.0 - var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNode */))))).FzData + uintptr(2))) + var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNode */))))).FzData + 2)) // var cell RtreeCell at bp+8, 48 // var pChild uintptr at bp+56, 8 @@ -153737,7 +151124,7 @@ func sAdjustTree(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr) in if ((libc.PreIncInt32(&cnt, 1)) > 1000) || (nodeParentIndex(tls, pRtree, p, bp /* &iCell */) != 0) { - return (11 | (int32(1) << 8)) + return (SQLITE_CORRUPT | (int32(1) << 8)) } nodeGetCell(tls, pRtree, pParent, *(*int32)(unsafe.Pointer(bp /* iCell */)), bp+8 /* &cell */) @@ -153748,7 +151135,7 @@ func sAdjustTree(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr) in p = pParent } - return 0 + return SQLITE_OK } // Write mapping (iRowid->iNode) to the _rowid table. @@ -153848,25 +151235,25 @@ func sSortByDimension(tls *libc.TLS, pRtree uintptr, aIdx uintptr, nIdx int32, i aLeft = aSpare for (iLeft < nLeft) || (iRight < nRight) { var xleft1 RtreeDValue = func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) }() var xleft2 RtreeDValue = func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aLeft + uintptr(iLeft)*4)))*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) }() var xright1 RtreeDValue = func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) }() var xright2 RtreeDValue = func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(*(*int32)(unsafe.Pointer(aRight + uintptr(iRight)*4)))*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) @@ -153902,7 +151289,7 @@ func splitNodeStartree(tls *libc.TLS, pRtree uintptr, aCell uintptr, nCell int32 aaSorted = Xsqlite3_malloc64(tls, uint64(nByte)) if !(aaSorted != 0) { - return 7 + return SQLITE_NOMEM } aSpare = ((aaSorted + uintptr((*Rtree)(unsafe.Pointer(pRtree)).FnDim)*8) + uintptr((int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim)*nCell))*4) @@ -153932,7 +151319,7 @@ func splitNodeStartree(tls *libc.TLS, pRtree uintptr, aCell uintptr, nCell int32 var overlap RtreeDValue var area RtreeDValue - libc.Xmemcpy(tls, bp /* &left */, (aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*8)) + uintptr(0)*4)))*48), uint64(unsafe.Sizeof(RtreeCell{}))) + libc.Xmemcpy(tls, bp /* &left */, (aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*8)))))*48), uint64(unsafe.Sizeof(RtreeCell{}))) libc.Xmemcpy(tls, bp+48 /* &right */, (aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(ii)*8)) + uintptr((nCell-1))*4)))*48), uint64(unsafe.Sizeof(RtreeCell{}))) for kk = 1; kk < (nCell - 1); kk++ { if kk < nLeft { @@ -153961,7 +151348,7 @@ func splitNodeStartree(tls *libc.TLS, pRtree uintptr, aCell uintptr, nCell int32 } } - libc.Xmemcpy(tls, pBboxLeft, (aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(iBestDim)*8)) + uintptr(0)*4)))*48), uint64(unsafe.Sizeof(RtreeCell{}))) + libc.Xmemcpy(tls, pBboxLeft, (aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(iBestDim)*8)))))*48), uint64(unsafe.Sizeof(RtreeCell{}))) libc.Xmemcpy(tls, pBboxRight, (aCell + uintptr(*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aaSorted + uintptr(iBestDim)*8)) + uintptr(iBestSplit)*4)))*48), uint64(unsafe.Sizeof(RtreeCell{}))) for ii = 0; ii < nCell; ii++ { var pTarget uintptr @@ -153982,7 +151369,7 @@ func splitNodeStartree(tls *libc.TLS, pRtree uintptr, aCell uintptr, nCell int32 } Xsqlite3_free(tls, aaSorted) - return 0 + return SQLITE_OK } func updateMapping(tls *libc.TLS, pRtree uintptr, iRowid I64, pNode uintptr, iHeight int32) int32 { /* sqlite3.c:190588:12: */ @@ -154030,8 +151417,8 @@ func sSplitNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHe var iRowid I64 var iRowid1 I64 newCellIsRight = 0 - rc = 0 - nCell = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + uintptr(2))) + rc = SQLITE_OK + nCell = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + 2)) pLeft = uintptr(0) pRight = uintptr(0) @@ -154041,7 +151428,7 @@ func sSplitNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHe if !(!(aCell != 0)) { goto __1 } - rc = 7 + rc = SQLITE_NOMEM goto splitnode_out __1: ; @@ -154083,7 +151470,7 @@ __6: if !(!(pLeft != 0) || !(pRight != 0)) { goto __7 } - rc = 7 + rc = SQLITE_NOMEM goto splitnode_out __7: ; @@ -154093,7 +151480,7 @@ __7: rc = splitNodeStartree(tls, pRtree, aCell, nCell, pLeft, pRight, bp /* &leftbbox */, bp+48 /* &rightbbox */) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __8 } goto splitnode_out @@ -154104,8 +151491,8 @@ __8: // nodeWrite(). Node pRight always needs a node number, as it was created // by nodeNew() above. But node pLeft sometimes already has a node number. // In this case avoid the all to nodeWrite(). - if !((0 != (libc.AssignInt32(&rc, nodeWrite(tls, pRtree, pRight)))) || - ((int64(0) == (*RtreeNode)(unsafe.Pointer(pLeft)).FiNode) && (0 != (libc.AssignInt32(&rc, nodeWrite(tls, pRtree, pLeft)))))) { + if !((SQLITE_OK != (libc.AssignInt32(&rc, nodeWrite(tls, pRtree, pRight)))) || + ((int64(0) == (*RtreeNode)(unsafe.Pointer(pLeft)).FiNode) && (SQLITE_OK != (libc.AssignInt32(&rc, nodeWrite(tls, pRtree, pLeft)))))) { goto __9 } goto splitnode_out @@ -154119,7 +151506,7 @@ __9: goto __10 } rc = rtreeInsertCell(tls, pRtree, (*RtreeNode)(unsafe.Pointer(pLeft)).FpParent, bp /* &leftbbox */, (iHeight + 1)) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __12 } goto splitnode_out @@ -154129,14 +151516,14 @@ __12: __10: pParent = (*RtreeNode)(unsafe.Pointer(pLeft)).FpParent rc = nodeParentIndex(tls, pRtree, pLeft, bp+96 /* &iCell */) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __13 } nodeOverwriteCell(tls, pRtree, pParent, bp /* &leftbbox */, *(*int32)(unsafe.Pointer(bp + 96 /* iCell */))) rc = sAdjustTree(tls, pRtree, pParent, bp /* &leftbbox */) __13: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __14 } goto splitnode_out @@ -154153,7 +151540,7 @@ __15: i = 0 __16: - if !(i < readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pRight))).FzData+uintptr(2)))) { + if !(i < readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pRight))).FzData+2))) { goto __18 } iRowid = nodeGetRowid(tls, pRtree, pRight, i) @@ -154164,7 +151551,7 @@ __16: newCellIsRight = 1 __19: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __20 } goto splitnode_out @@ -154182,12 +151569,12 @@ __18: } i = 0 __23: - if !(i < readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pLeft))).FzData+uintptr(2)))) { + if !(i < readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pLeft))).FzData+2))) { goto __25 } iRowid1 = nodeGetRowid(tls, pRtree, pLeft, i) rc = updateMapping(tls, pRtree, iRowid1, pLeft, iHeight) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __26 } goto splitnode_out @@ -154211,14 +151598,14 @@ __27: __22: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __28 } rc = nodeRelease(tls, pRtree, pRight) pRight = uintptr(0) __28: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __29 } rc = nodeRelease(tls, pRtree, pLeft) @@ -154243,13 +151630,13 @@ splitnode_out: // the entry resides (argument pLeaf). Once the leaf is located, this // function is called to determine its ancestry. func fixLeafParent(tls *libc.TLS, pRtree uintptr, pLeaf uintptr) int32 { /* sqlite3.c:190754:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pChild uintptr = pLeaf - for ((rc == 0) && ((*RtreeNode)(unsafe.Pointer(pChild)).FiNode != int64(1))) && ((*RtreeNode)(unsafe.Pointer(pChild)).FpParent == uintptr(0)) { - var rc2 int32 = 0 // sqlite3_reset() return code + for ((rc == SQLITE_OK) && ((*RtreeNode)(unsafe.Pointer(pChild)).FiNode != int64(1))) && ((*RtreeNode)(unsafe.Pointer(pChild)).FpParent == uintptr(0)) { + var rc2 int32 = SQLITE_OK // sqlite3_reset() return code Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadParent, 1, (*RtreeNode)(unsafe.Pointer(pChild)).FiNode) rc = Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadParent) - if rc == 100 { + if rc == SQLITE_ROW { var pTest uintptr // Used to test for reference loops var iNode I64 // Node number of parent node @@ -154265,12 +151652,12 @@ func fixLeafParent(tls *libc.TLS, pRtree uintptr, pLeaf uintptr) int32 { /* sqli } } rc = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadParent) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } - if (rc == 0) && !(int32((*RtreeNode)(unsafe.Pointer(pChild)).FpParent) != 0) { + if (rc == SQLITE_OK) && !(int32((*RtreeNode)(unsafe.Pointer(pChild)).FpParent) != 0) { - rc = (11 | (int32(1) << 8)) + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } pChild = (*RtreeNode)(unsafe.Pointer(pChild)).FpParent } @@ -154288,30 +151675,30 @@ func removeNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, iHeight int32) int // Remove the entry in the parent cell. rc = nodeParentIndex(tls, pRtree, pNode, bp /* &iCell */) - if rc == 0 { + if rc == SQLITE_OK { pParent = (*RtreeNode)(unsafe.Pointer(pNode)).FpParent (*RtreeNode)(unsafe.Pointer(pNode)).FpParent = uintptr(0) rc = deleteCell(tls, pRtree, pParent, *(*int32)(unsafe.Pointer(bp /* iCell */)), (iHeight + 1)) } rc2 = nodeRelease(tls, pRtree, pParent) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } - if rc != 0 { + if rc != SQLITE_OK { return rc } // Remove the xxx_node entry. Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteNode, 1, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode) Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteNode) - if 0 != (libc.AssignInt32(&rc, Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteNode))) { + if SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteNode))) { return rc } // Remove the xxx_parent entry. Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteParent, 1, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode) Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteParent) - if 0 != (libc.AssignInt32(&rc, Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteParent))) { + if SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteParent))) { return rc } @@ -154323,7 +151710,7 @@ func removeNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, iHeight int32) int (*RtreeNode)(unsafe.Pointer(pNode)).FnRef++ (*Rtree)(unsafe.Pointer(pRtree)).FpDeleted = pNode - return 0 + return SQLITE_OK } func fixBoundingBox(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sqlite3.c:190838:12: */ @@ -154331,11 +151718,11 @@ func fixBoundingBox(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sql defer tls.Free(100) var pParent uintptr = (*RtreeNode)(unsafe.Pointer(pNode)).FpParent - var rc int32 = 0 + var rc int32 = SQLITE_OK if pParent != 0 { // var ii int32 at bp+96, 4 - var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + uintptr(2))) + var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + 2)) // var box RtreeCell at bp, 48 // Bounding box for pNode nodeGetCell(tls, pRtree, pNode, 0, bp /* &box */) @@ -154347,7 +151734,7 @@ func fixBoundingBox(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { /* sql } (*RtreeCell)(unsafe.Pointer(bp /* &box */)).FiRowid = (*RtreeNode)(unsafe.Pointer(pNode)).FiNode rc = nodeParentIndex(tls, pRtree, pNode, bp+96 /* &ii */) - if rc == 0 { + if rc == SQLITE_OK { nodeOverwriteCell(tls, pRtree, pParent, bp /* &box */, *(*int32)(unsafe.Pointer(bp + 96 /* ii */))) rc = fixBoundingBox(tls, pRtree, pParent) } @@ -154361,7 +151748,7 @@ func deleteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32, iHeig var pParent uintptr var rc int32 - if 0 != (libc.AssignInt32(&rc, fixLeafParent(tls, pRtree, pNode))) { + if SQLITE_OK != (libc.AssignInt32(&rc, fixLeafParent(tls, pRtree, pNode))) { return rc } @@ -154376,7 +151763,7 @@ func deleteCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, iCell int32, iHeig pParent = (*RtreeNode)(unsafe.Pointer(pNode)).FpParent if pParent != 0 { - if readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+uintptr(2))) < ((((*Rtree)(unsafe.Pointer((pRtree))).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer((pRtree))).FnBytesPerCell)) / 3) { + if readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+2)) < ((((*Rtree)(unsafe.Pointer((pRtree))).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer((pRtree))).FnBytesPerCell)) / 3) { rc = removeNode(tls, pRtree, pNode, iHeight) } else { rc = fixBoundingBox(tls, pRtree, pNode) @@ -154399,19 +151786,19 @@ func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHei var iDim int32 var ii int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var n int32 - libc.Xmemset(tls, bp /* &aCenterCoord[0] */, 0, (uint64(unsafe.Sizeof(RtreeDValue(0))) * uint64(5))) + libc.Xmemset(tls, bp /* &aCenterCoord[0] */, 0, (uint64(unsafe.Sizeof(RtreeDValue(0))) * RTREE_MAX_DIMENSIONS)) - nCell = (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+uintptr(2))) + 1) - n = ((nCell + 1) & (^libc.Int32(1))) + nCell = (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData+2)) + 1) + n = ((nCell + 1) & (libc.CplInt32(1))) // Allocate the buffers used by this operation. The allocation is // relinquished before this function returns. aCell = Xsqlite3_malloc64(tls, (uint64(uint64(n) * (((uint64(unsafe.Sizeof(RtreeCell{})) + uint64(unsafe.Sizeof(int32(0)))) + uint64(unsafe.Sizeof(int32(0)))) + uint64(unsafe.Sizeof(RtreeDValue(0))))))) if !(aCell != 0) { - return 7 + return SQLITE_NOMEM } aOrder = (aCell + uintptr(n)*48) aSpare = (aOrder + uintptr(n)*4) @@ -154426,13 +151813,13 @@ func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHei *(*int32)(unsafe.Pointer(aOrder + uintptr(ii)*4)) = ii for iDim = 0; iDim < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim); iDim++ { *(*RtreeDValue)(unsafe.Pointer(bp /* &aCenterCoord */ + uintptr(iDim)*8)) += (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) }()) *(*RtreeDValue)(unsafe.Pointer(bp /* &aCenterCoord */ + uintptr(iDim)*8)) += (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) @@ -154447,12 +151834,12 @@ func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHei *(*RtreeDValue)(unsafe.Pointer(aDistance + uintptr(ii)*8)) = 0.0 for iDim = 0; iDim < int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim); iDim++ { var coord RtreeDValue = ((func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr(((iDim*2)+1))*4))) }()) - (func() float64 { - if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0 { + if int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32 { return float64(*(*RtreeValue)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) } return float64(*(*int32)(unsafe.Pointer((aCell + uintptr(ii)*48 + 8 /* &.aCoord */) + uintptr((iDim*2))*4))) @@ -154464,7 +151851,7 @@ func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHei sSortByDistance(tls, aOrder, nCell, aDistance, aSpare) nodeZero(tls, pRtree, pNode) - for ii = 0; (rc == 0) && (ii < (nCell - (((((*Rtree)(unsafe.Pointer((pRtree))).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer((pRtree))).FnBytesPerCell)) / 3) + 1))); ii++ { + for ii = 0; (rc == SQLITE_OK) && (ii < (nCell - (((((*Rtree)(unsafe.Pointer((pRtree))).FiNodeSize - 4) / int32((*Rtree)(unsafe.Pointer((pRtree))).FnBytesPerCell)) / 3) + 1))); ii++ { var p uintptr = (aCell + uintptr(*(*int32)(unsafe.Pointer(aOrder + uintptr(ii)*4)))*48) nodeInsertCell(tls, pRtree, pNode, p) if (*RtreeCell)(unsafe.Pointer(p)).FiRowid == (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid { @@ -154475,21 +151862,21 @@ func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHei } } } - if rc == 0 { + if rc == SQLITE_OK { rc = fixBoundingBox(tls, pRtree, pNode) } - for ; (rc == 0) && (ii < nCell); ii++ { + for ; (rc == SQLITE_OK) && (ii < nCell); ii++ { // Find a node to store this cell in. pNode->iNode currently contains // the height of the sub-tree headed by the cell. // var pInsert uintptr at bp+40, 8 var p uintptr = (aCell + uintptr(*(*int32)(unsafe.Pointer(aOrder + uintptr(ii)*4)))*48) rc = sChooseLeaf(tls, pRtree, p, iHeight, bp+40 /* &pInsert */) - if rc == 0 { + if rc == SQLITE_OK { var rc2 int32 rc = rtreeInsertCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 40 /* pInsert */)), p, iHeight) rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 40 /* pInsert */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } @@ -154502,7 +151889,7 @@ func sReinsert(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHei // Insert cell pCell into node pNode. Node pNode is the head of a // subtree iHeight high (leaf nodes have iHeight==0). func rtreeInsertCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHeight int32) int32 { /* sqlite3.c:191001:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if iHeight > 0 { var pChild uintptr = nodeHashLookup(tls, pRtree, (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid) if pChild != 0 { @@ -154520,7 +151907,7 @@ func rtreeInsertCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr } } else { rc = sAdjustTree(tls, pRtree, pNode, pCell) - if rc == 0 { + if rc == SQLITE_OK { if iHeight == 0 { rc = rowidWrite(tls, pRtree, (*RtreeCell)(unsafe.Pointer(pCell)).FiRowid, (*RtreeNode)(unsafe.Pointer(pNode)).FiNode) } else { @@ -154536,10 +151923,10 @@ func reinsertNodeContent(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { / defer tls.Free(56) var ii int32 - var rc int32 = 0 - var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + uintptr(2))) + var rc int32 = SQLITE_OK + var nCell int32 = readInt16(tls, ((*RtreeNode)(unsafe.Pointer((pNode))).FzData + 2)) - for ii = 0; (rc == 0) && (ii < nCell); ii++ { + for ii = 0; (rc == SQLITE_OK) && (ii < nCell); ii++ { // var pInsert uintptr at bp+48, 8 // var cell RtreeCell at bp, 48 @@ -154549,11 +151936,11 @@ func reinsertNodeContent(tls *libc.TLS, pRtree uintptr, pNode uintptr) int32 { / // Find a node to store this cell in. pNode->iNode currently contains // the height of the sub-tree headed by the cell. rc = sChooseLeaf(tls, pRtree, bp /* &cell */, int32((*RtreeNode)(unsafe.Pointer(pNode)).FiNode), bp+48 /* &pInsert */) - if rc == 0 { + if rc == SQLITE_OK { var rc2 int32 rc = rtreeInsertCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 48 /* pInsert */)), bp /* &cell */, int32((*RtreeNode)(unsafe.Pointer(pNode)).FiNode)) rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 48 /* pInsert */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } @@ -154588,25 +151975,25 @@ func rtreeDeleteRowid(tls *libc.TLS, pRtree uintptr, iDelete Sqlite3_int64) int3 // Obtain a reference to the leaf node that contains the entry // about to be deleted. - if rc == 0 { + if rc == SQLITE_OK { rc = findLeafNode(tls, pRtree, iDelete, bp+8 /* &pLeaf */, uintptr(0)) } // Delete the cell in question from the leaf node. - if (rc == 0) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)) != 0) { + if (rc == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)) != 0) { var rc2 int32 rc = nodeRowidIndex(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)), iDelete, bp+16 /* &iCell */) - if rc == 0 { + if rc == SQLITE_OK { rc = deleteCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)), *(*int32)(unsafe.Pointer(bp + 16 /* iCell */)), 0) } rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } // Delete the corresponding entry in the _rowid table. - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteRowid, 1, iDelete) Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteRowid) rc = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpDeleteRowid) @@ -154619,19 +152006,19 @@ func rtreeDeleteRowid(tls *libc.TLS, pRtree uintptr, iDelete Sqlite3_int64) int3 // This is equivalent to copying the contents of the child into // the root node (the operation that Gutman's paper says to perform // in this scenario). - if ((rc == 0) && ((*Rtree)(unsafe.Pointer(pRtree)).FiDepth > 0)) && (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pRoot */))))).FzData+uintptr(2))) == 1) { + if ((rc == SQLITE_OK) && ((*Rtree)(unsafe.Pointer(pRtree)).FiDepth > 0)) && (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pRoot */))))).FzData+2)) == 1) { var rc2 int32 *(*uintptr)(unsafe.Pointer(bp + 24 /* pChild */)) = uintptr(0) var iChild I64 = nodeGetRowid(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp /* pRoot */)), 0) rc = nodeAcquire(tls, pRtree, iChild, *(*uintptr)(unsafe.Pointer(bp /* pRoot */)), bp+24 /* &pChild */) - if rc == 0 { + if rc == SQLITE_OK { rc = removeNode(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 24 /* pChild */)), ((*Rtree)(unsafe.Pointer(pRtree)).FiDepth - 1)) } rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 24 /* pChild */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } - if rc == 0 { + if rc == SQLITE_OK { (*Rtree)(unsafe.Pointer(pRtree)).FiDepth-- writeInt16(tls, (*RtreeNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pRoot */)))).FzData, (*Rtree)(unsafe.Pointer(pRtree)).FiDepth) (*RtreeNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pRoot */)))).FisDirty = 1 @@ -154640,7 +152027,7 @@ func rtreeDeleteRowid(tls *libc.TLS, pRtree uintptr, iDelete Sqlite3_int64) int3 // Re-insert the contents of any underfull nodes removed from the tree. for *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)) = (*Rtree)(unsafe.Pointer(pRtree)).FpDeleted; *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)) != 0; *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)) = (*Rtree)(unsafe.Pointer(pRtree)).FpDeleted { - if rc == 0 { + if rc == SQLITE_OK { rc = reinsertNodeContent(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */))) } (*Rtree)(unsafe.Pointer(pRtree)).FpDeleted = (*RtreeNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pLeaf */)))).FpNext @@ -154649,7 +152036,7 @@ func rtreeDeleteRowid(tls *libc.TLS, pRtree uintptr, iDelete Sqlite3_int64) int3 } // Release the reference to the root node. - if rc == 0 { + if rc == SQLITE_OK { rc = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp /* pRoot */))) } else { nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp /* pRoot */))) @@ -154713,11 +152100,11 @@ func rtreeConstraintError(tls *libc.TLS, pRtree uintptr, iCol int32) int32 { /* if zSql != 0 { rc = Xsqlite3_prepare_v2(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb, zSql, -1, bp+56 /* &pStmt */, uintptr(0)) } else { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3_free(tls, zSql) - if rc == 0 { + if rc == SQLITE_OK { if iCol == 0 { var zCol uintptr = Xsqlite3_column_name(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)), 0) (*Rtree)(unsafe.Pointer(pRtree)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, @@ -154732,8 +152119,8 @@ func rtreeConstraintError(tls *libc.TLS, pRtree uintptr, iCol int32) int32 { /* Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) return func() int32 { - if rc == 0 { - return 19 + if rc == SQLITE_OK { + return SQLITE_CONSTRAINT } return rc }() @@ -154758,7 +152145,7 @@ func rtreeUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRowi // Insert the new record into the r-tree // var pLeaf uintptr at bp+48, 8 pRtree = pVtab - rc = 0 + rc = SQLITE_OK bHaveRowid = 0 // Set to 1 after new rowid is determined if !((*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef != 0) { @@ -154767,7 +152154,7 @@ func rtreeUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRowi // Unable to write to the btree while another cursor is reading from it, // since the write might do a rebalance which would disrupt the read // cursor. - return (6 | (int32(2) << 8)) + return (SQLITE_LOCKED | (int32(2) << 8)) __1: ; rtreeReference(tls, pRtree) @@ -154803,7 +152190,7 @@ __3: // This problem was discovered after years of use, so we silently ignore // these kinds of misdeclared tables to avoid breaking any legacy. - if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == 0) { + if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FeCoordType) == RTREE_COORD_REAL32) { goto __4 } ii = 0 @@ -154856,21 +152243,21 @@ __5: // If a rowid value was supplied, check if it is already present in // the table. If so, the constraint has failed. - if !(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8))) != 5) { + if !(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + 2*8))) != SQLITE_NULL) { goto __14 } - (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8))) - if !((Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(0)*8))) == 5) || - (Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(0)*8))) != (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid)) { + (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + 2*8))) + if !((Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData))) == SQLITE_NULL) || + (Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData))) != (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid)) { goto __15 } Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid, 1, (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid) steprc = Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) rc = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) - if !(100 == steprc) { + if !(SQLITE_ROW == steprc) { goto __16 } - if !(Xsqlite3_vtab_on_conflict(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb) == 5) { + if !(Xsqlite3_vtab_on_conflict(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb) == SQLITE_REPLACE) { goto __17 } rc = rtreeDeleteRowid(tls, pRtree, (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid) @@ -154893,17 +152280,17 @@ __2: // If aData[0] is not an SQL NULL value, it is the rowid of a // record to delete from the r-tree table. The following block does // just that. - if !(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(0)*8))) != 5) { + if !(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData))) != SQLITE_NULL) { goto __19 } - rc = rtreeDeleteRowid(tls, pRtree, Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(0)*8)))) + rc = rtreeDeleteRowid(tls, pRtree, Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData)))) __19: ; // If the aData[] array contains more than one element, elements // (aData[2]..aData[argc-1]) contain a new record to insert into // the r-tree structure. - if !((rc == 0) && (nData > 1)) { + if !((rc == SQLITE_OK) && (nData > 1)) { goto __20 } // Insert the new record into the r-tree @@ -154918,19 +152305,19 @@ __21: ; *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __22 } rc = sChooseLeaf(tls, pRtree, bp /* &cell */, 0, bp+48 /* &pLeaf */) __22: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __23 } (*Rtree)(unsafe.Pointer(pRtree)).FiReinsertHeight = -1 rc = rtreeInsertCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 48 /* pLeaf */)), bp /* &cell */, 0) rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 48 /* pLeaf */))) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __24 } rc = rc2 @@ -154938,7 +152325,7 @@ __24: ; __23: ; - if !((rc == 0) && ((*Rtree)(unsafe.Pointer(pRtree)).FnAux != 0)) { + if !((rc == SQLITE_OK) && ((*Rtree)(unsafe.Pointer(pRtree)).FnAux != 0)) { goto __25 } pUp = (*Rtree)(unsafe.Pointer(pRtree)).FpWriteAux @@ -154973,7 +152360,7 @@ func rtreeBeginTransaction(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:19 var pRtree uintptr = pVtab (*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans++ - return 0 + return SQLITE_OK } // Called when a transaction completes (either by COMMIT or ROLLBACK). @@ -154982,7 +152369,7 @@ func rtreeEndTransaction(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:1914 var pRtree uintptr = pVtab (*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans = U8(0) nodeBlobReset(tls, pRtree) - return 0 + return SQLITE_OK } // The xRename method for rtree module virtual tables. @@ -154991,7 +152378,7 @@ func rtreeRename(tls *libc.TLS, pVtab uintptr, zNewName uintptr) int32 { /* sqli defer tls.Free(72) var pRtree uintptr = pVtab - var rc int32 = 7 + var rc int32 = SQLITE_NOMEM var zSql uintptr = Xsqlite3_mprintf(tls, ts+28551 /* "ALTER TABLE %Q.'..." */, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName, zNewName, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName, zNewName, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName, zNewName)) @@ -155022,7 +152409,7 @@ func rtreeSavepoint(tls *libc.TLS, pVtab uintptr, iSavepoint int32) int32 { /* s (*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans = U8(0) nodeBlobReset(tls, pRtree) (*Rtree)(unsafe.Pointer(pRtree)).FinWrTrans = iwt - return 0 + return SQLITE_OK } // This function populates the pRtree->nRowEst variable with an estimate @@ -155041,36 +152428,36 @@ func rtreeQueryStat1(tls *libc.TLS, db uintptr, pRtree uintptr) int32 { /* sqlit rc = Xsqlite3_table_column_metadata(tls, db, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, ts+12457 /* "sqlite_stat1" */, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) - if rc != 0 { - (*Rtree)(unsafe.Pointer(pRtree)).FnRowEst = int64(1048576) - if rc == 1 { - return 0 + if rc != SQLITE_OK { + (*Rtree)(unsafe.Pointer(pRtree)).FnRowEst = RTREE_DEFAULT_ROWEST + if rc == SQLITE_ERROR { + return SQLITE_OK } return rc } zSql = Xsqlite3_mprintf(tls, zFmt, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName)) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+16 /* &p */, uintptr(0)) - if rc == 0 { - if Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p */))) == 100 { + if rc == SQLITE_OK { + if Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p */))) == SQLITE_ROW { nRow = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p */)), 0) } rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p */))) - } else if rc != 7 { - rc = 0 + } else if rc != SQLITE_NOMEM { + rc = SQLITE_OK } - if rc == 0 { + if rc == SQLITE_OK { if nRow == int64(0) { - (*Rtree)(unsafe.Pointer(pRtree)).FnRowEst = int64(1048576) + (*Rtree)(unsafe.Pointer(pRtree)).FnRowEst = RTREE_DEFAULT_ROWEST } else { (*Rtree)(unsafe.Pointer(pRtree)).FnRowEst = func() int64 { - if (nRow) > (int64(100)) { + if (nRow) > (RTREE_MIN_ROWEST) { return nRow } - return int64(100) + return RTREE_MIN_ROWEST }() } } @@ -155097,64 +152484,38 @@ var azName1 = [3]uintptr{ } /* sqlite3.c:191506:21 */ var rtreeModule = Sqlite3_module{ - FiVersion: 3, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - create a table - 0, - FxBestIndex:// xConnect - connect to an existing table - 0, - FxDisconnect:// xBestIndex - Determine search strategy - 0, - FxDestroy:// xDisconnect - Disconnect from a table - 0, - FxOpen:// xDestroy - Drop a table - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - write data - 0, - FxSync:// xBegin - begin transaction - 0, - FxCommit:// xSync - sync transaction - 0, - FxRollback:// xCommit - commit transaction - 0, - FxFindFunction:// xRollback - rollback transaction - uintptr(0), - FxRename:// xFindFunction - function overloading - 0, - FxSavepoint:// xRename - rename the table - 0, - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - 0, // xShadowName + FiVersion: 3, // iVersion + FxCreate: 0, // xCreate - create a table + FxConnect: 0, // xConnect - connect to an existing table + FxBestIndex: 0, // xBestIndex - Determine search strategy + FxDisconnect: 0, // xDisconnect - Disconnect from a table + FxDestroy: 0, // xDestroy - Drop a table + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRowid - read data + FxUpdate: 0, // xUpdate - write data + FxBegin: 0, // xBegin - begin transaction + FxSync: 0, // xSync - sync transaction + FxCommit: 0, // xCommit - commit transaction + FxRollback: 0, // xFindFunction - function overloading + FxRename: 0, // xRename - rename the table + FxSavepoint: 0, // xRollbackTo + FxShadowName: 0, // xShadowName } /* sqlite3.c:191516:23 */ func rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefix uintptr, isCreate int32) int32 { /* sqlite3.c:191543:12: */ bp := tls.Alloc(232) defer tls.Free(232) - var rc int32 = 0 + var rc int32 = SQLITE_OK // var appStmt [8]uintptr at bp+168, 64 var i int32 - var f int32 = (0x01 | 0x04) + var f int32 = (SQLITE_PREPARE_PERSISTENT | SQLITE_PREPARE_NO_VTAB) (*Rtree)(unsafe.Pointer(pRtree)).Fdb = db @@ -155179,26 +152540,26 @@ func rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefi libc.VaList(bp+56, zDb, zPrefix, (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize)) zCreate = Xsqlite3_str_finish(tls, p) if !(zCreate != 0) { - return 7 + return SQLITE_NOMEM } rc = Xsqlite3_exec(tls, db, zCreate, uintptr(0), uintptr(0), uintptr(0)) Xsqlite3_free(tls, zCreate) - if rc != 0 { + if rc != SQLITE_OK { return rc } } - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(0)*8)) = (pRtree + 120 /* &.pWriteNode */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(1)*8)) = (pRtree + 128 /* &.pDeleteNode */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(2)*8)) = (pRtree + 136 /* &.pReadRowid */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(3)*8)) = (pRtree + 144 /* &.pWriteRowid */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(4)*8)) = (pRtree + 152 /* &.pDeleteRowid */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(5)*8)) = (pRtree + 160 /* &.pReadParent */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(6)*8)) = (pRtree + 168 /* &.pWriteParent */) - *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(7)*8)) = (pRtree + 176 /* &.pDeleteParent */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */)) = (pRtree + 120 /* &.pWriteNode */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 1*8)) = (pRtree + 128 /* &.pDeleteNode */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 2*8)) = (pRtree + 136 /* &.pReadRowid */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 3*8)) = (pRtree + 144 /* &.pWriteRowid */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 4*8)) = (pRtree + 152 /* &.pDeleteRowid */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 5*8)) = (pRtree + 160 /* &.pReadParent */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 6*8)) = (pRtree + 168 /* &.pWriteParent */) + *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + 7*8)) = (pRtree + 176 /* &.pDeleteParent */) rc = rtreeQueryStat1(tls, db, pRtree) - for i = 0; (i < 8) && (rc == 0); i++ { + for i = 0; (i < N_STATEMENT) && (rc == SQLITE_OK); i++ { var zSql uintptr var zFormat uintptr if (i != 3) || (int32((*Rtree)(unsafe.Pointer(pRtree)).FnAux) == 0) { @@ -155212,7 +152573,7 @@ func rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefi if zSql != 0 { rc = Xsqlite3_prepare_v3(tls, db, zSql, -1, uint32(f), *(*uintptr)(unsafe.Pointer(bp + 168 /* &appStmt[0] */ + uintptr(i)*8)), uintptr(0)) } else { - rc = 7 + rc = SQLITE_NOMEM } Xsqlite3_free(tls, zSql) } @@ -155221,7 +152582,7 @@ func rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefi ts+29115, /* "SELECT * FROM \"%..." */ libc.VaList(bp+96, zDb, zPrefix)) if (*Rtree)(unsafe.Pointer(pRtree)).FzReadAuxSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var p uintptr = Xsqlite3_str_new(tls, db) var ii int32 @@ -155240,7 +152601,7 @@ func rtreeSqlInit(tls *libc.TLS, pRtree uintptr, db uintptr, zDb uintptr, zPrefi Xsqlite3_str_appendf(tls, p, ts+29217 /* " WHERE rowid=?1" */, 0) zSql = Xsqlite3_str_finish(tls, p) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_prepare_v3(tls, db, zSql, -1, uint32(f), (pRtree + 184 /* &.pWriteAux */), uintptr(0)) Xsqlite3_free(tls, zSql) @@ -155276,12 +152637,12 @@ func getIntFromStmt(tls *libc.TLS, db uintptr, zSql uintptr, piVal uintptr) int3 bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 7 + var rc int32 = SQLITE_NOMEM if zSql != 0 { *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) rc = Xsqlite3_prepare_v2(tls, db, zSql, -1, bp /* &pStmt */, uintptr(0)) - if rc == 0 { - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { + if rc == SQLITE_OK { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { *(*int32)(unsafe.Pointer(piVal)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 0) } rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) @@ -155313,10 +152674,10 @@ func getNodeSize(tls *libc.TLS, db uintptr, pRtree uintptr, isCreate int32, pzEr *(*int32)(unsafe.Pointer(bp + 48 /* iPageSize */)) = 0 zSql = Xsqlite3_mprintf(tls, ts+29642 /* "PRAGMA %Q.page_s..." */, libc.VaList(bp, (*Rtree)(unsafe.Pointer(pRtree)).FzDb)) rc = getIntFromStmt(tls, db, zSql, bp+48 /* &iPageSize */) - if rc == 0 { + if rc == SQLITE_OK { (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize = (*(*int32)(unsafe.Pointer(bp + 48 /* iPageSize */)) - 64) - if (4 + (int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) * 51)) < (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize { - (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize = (4 + (int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) * 51)) + if (4 + (int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) * RTREE_MAXCELLS)) < (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize { + (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize = (4 + (int32((*Rtree)(unsafe.Pointer(pRtree)).FnBytesPerCell) * RTREE_MAXCELLS)) } } else { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db))) @@ -155326,10 +152687,10 @@ func getNodeSize(tls *libc.TLS, db uintptr, pRtree uintptr, isCreate int32, pzEr ts+29662, /* "SELECT length(da..." */ libc.VaList(bp+16, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, (*Rtree)(unsafe.Pointer(pRtree)).FzName)) rc = getIntFromStmt(tls, db, zSql, (pRtree + 32 /* &.iNodeSize */)) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp+32, Xsqlite3_errmsg(tls, db))) } else if (*Rtree)(unsafe.Pointer(pRtree)).FiNodeSize < (512 - 64) { - rc = (11 | (int32(1) << 8)) + rc = (SQLITE_CORRUPT | (int32(1) << 8)) *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+29719, /* "undersize RTree ..." */ libc.VaList(bp+40, (*Rtree)(unsafe.Pointer(pRtree)).FzName)) @@ -155372,12 +152733,12 @@ func rtreeInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr // var aErrMsg [5]uintptr at bp+96, 40 var zArg uintptr - rc = 0 + rc = SQLITE_OK eCoordType = func() int32 { if pAux != 0 { - return 1 + return RTREE_COORD_INT32 } - return 0 + return RTREE_COORD_REAL32 }() ii = 4 *(*[5]uintptr)(unsafe.Pointer(bp + 96 /* aErrMsg */)) = [5]uintptr{ @@ -155389,48 +152750,48 @@ func rtreeInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr } // Aux columns counted by a u8 - if !((argc < 6) || (argc > (100 + 3))) { + if !((argc < 6) || (argc > (RTREE_MAX_AUX_COLUMN + 3))) { goto __1 } *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 96 /* &aErrMsg[0] */ + uintptr((2+(libc.Bool32(argc >= 6))))*8)))) - return 1 + return SQLITE_ERROR __1: ; - Xsqlite3_vtab_config(tls, db, 1, libc.VaList(bp+8, 1)) + Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_CONSTRAINT_SUPPORT, libc.VaList(bp+8, 1)) // Allocate the sqlite3_vtab structure - nDb = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) - nName = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + nDb = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) + nName = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) pRtree = Xsqlite3_malloc64(tls, (uint64(((uint64(unsafe.Sizeof(Rtree{})) + uint64(nDb)) + uint64(nName)) + uint64(2)))) if !(!(pRtree != 0)) { goto __2 } - return 7 + return SQLITE_NOMEM __2: ; libc.Xmemset(tls, pRtree, 0, (((uint64(unsafe.Sizeof(Rtree{})) + uint64(nDb)) + uint64(nName)) + uint64(2))) (*Rtree)(unsafe.Pointer(pRtree)).FnBusy = U32(1) (*Rtree)(unsafe.Pointer(pRtree)).Fbase.FpModule = uintptr(unsafe.Pointer(&rtreeModule)) - (*Rtree)(unsafe.Pointer(pRtree)).FzDb = (pRtree + uintptr(1)*968) + (*Rtree)(unsafe.Pointer(pRtree)).FzDb = (pRtree + 1*968) (*Rtree)(unsafe.Pointer(pRtree)).FzName = ((*Rtree)(unsafe.Pointer(pRtree)).FzDb + uintptr((nDb + 1))) (*Rtree)(unsafe.Pointer(pRtree)).FeCoordType = U8(eCoordType) - libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uint64(nDb)) - libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzName, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), uint64(nName)) + libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uint64(nDb)) + libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzName, *(*uintptr)(unsafe.Pointer(argv + 2*8)), uint64(nName)) // Create/Connect to the underlying relational database schema. If // that is successful, call sqlite3_declare_vtab() to configure // the r-tree table schema. pSql = Xsqlite3_str_new(tls, db) Xsqlite3_str_appendf(tls, pSql, ts+29905, /* "CREATE TABLE x(%..." */ - libc.VaList(bp+16, rtreeTokenLength(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))), *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)))) + libc.VaList(bp+16, rtreeTokenLength(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))), *(*uintptr)(unsafe.Pointer(argv + 3*8)))) ii = 4 __3: if !(ii < argc) { goto __5 } zArg = *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*8)) - if !(int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) == '+') { + if !(int32(*(*int8)(unsafe.Pointer(zArg))) == '+') { goto __6 } (*Rtree)(unsafe.Pointer(pRtree)).FnAux++ @@ -155462,17 +152823,17 @@ __5: if !(!(zSql != 0)) { goto __10 } - rc = 7 + rc = SQLITE_NOMEM goto __11 __10: if !(ii < argc) { goto __12 } - *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(bp + 96 /* &aErrMsg[0] */ + uintptr(4)*8)))) - rc = 1 + *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(bp + 96 /* &aErrMsg[0] */ + 4*8)))) + rc = SQLITE_ERROR goto __13 __12: - if !(0 != (libc.AssignInt32(&rc, Xsqlite3_declare_vtab(tls, db, zSql)))) { + if !(SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3_declare_vtab(tls, db, zSql)))) { goto __14 } *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp+72, Xsqlite3_errmsg(tls, db))) @@ -155496,7 +152857,7 @@ __15: iErr = 2 goto __17 __16: - if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) > (5 * 2)) { + if !(int32((*Rtree)(unsafe.Pointer(pRtree)).FnDim2) > (RTREE_MAX_DIMENSIONS * 2)) { goto __18 } iErr = 3 @@ -155532,7 +152893,7 @@ __22: goto rtreeInit_fail __23: ; - rc = rtreeSqlInit(tls, pRtree, db, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), isCreate) + rc = rtreeSqlInit(tls, pRtree, db, *(*uintptr)(unsafe.Pointer(argv + 1*8)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), isCreate) if !(rc != 0) { goto __24 } @@ -155542,13 +152903,13 @@ __24: ; *(*uintptr)(unsafe.Pointer(ppVtab)) = pRtree - return 0 + return SQLITE_OK rtreeInit_fail: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __25 } - rc = 1 + rc = SQLITE_ERROR __25: ; @@ -155588,23 +152949,23 @@ func rtreenode(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* sqlit _ = nArg libc.Xmemset(tls, bp+16 /* &node */, 0, uint64(unsafe.Sizeof(RtreeNode{}))) libc.Xmemset(tls, bp+56 /* &tree */, 0, uint64(unsafe.Sizeof(Rtree{}))) - (*Rtree)(unsafe.Pointer(bp + 56 /* &tree */)).FnDim = U8(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8)))) + (*Rtree)(unsafe.Pointer(bp + 56 /* &tree */)).FnDim = U8(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apArg)))) if (int32((*Rtree)(unsafe.Pointer(bp+56 /* &tree */)).FnDim) < 1) || (int32((*Rtree)(unsafe.Pointer(bp+56 /* &tree */)).FnDim) > 5) { return } (*Rtree)(unsafe.Pointer(bp + 56 /* &tree */)).FnDim2 = (U8(int32((*Rtree)(unsafe.Pointer(bp+56 /* &tree */)).FnDim) * 2)) (*Rtree)(unsafe.Pointer(bp + 56 /* &tree */)).FnBytesPerCell = (U8(8 + (8 * int32((*Rtree)(unsafe.Pointer(bp+56 /* &tree */)).FnDim)))) - (*RtreeNode)(unsafe.Pointer(bp + 16 /* &node */)).FzData = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(1)*8))) - nData = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(1)*8))) + (*RtreeNode)(unsafe.Pointer(bp + 16 /* &node */)).FzData = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*8))) + nData = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*8))) if nData < 4 { return } - if nData < (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((bp+16 /* &node */))).FzData+uintptr(2))) * int32((*Rtree)(unsafe.Pointer(bp+56 /* &tree */)).FnBytesPerCell)) { + if nData < (readInt16(tls, ((*RtreeNode)(unsafe.Pointer((bp+16 /* &node */))).FzData+2)) * int32((*Rtree)(unsafe.Pointer(bp+56 /* &tree */)).FnBytesPerCell)) { return } pOut = Xsqlite3_str_new(tls, uintptr(0)) - for ii = 0; ii < readInt16(tls, ((*RtreeNode)(unsafe.Pointer((bp+16 /* &node */))).FzData+uintptr(2))); ii++ { + for ii = 0; ii < readInt16(tls, ((*RtreeNode)(unsafe.Pointer((bp+16 /* &node */))).FzData+2)); ii++ { // var cell RtreeCell at bp+1024, 48 var jj int32 @@ -155634,11 +152995,11 @@ func rtreenode(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* sqlit // routine. This routine is intended for testing and analysis only. func rtreedepth(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* sqlite3.c:191948:13: */ _ = nArg - if (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) != 4) || - (Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) < 2) { + if (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apArg))) != SQLITE_BLOB) || + (Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apArg))) < 2) { Xsqlite3_result_error(tls, ctx, ts+29971 /* "Invalid argument..." */, -1) } else { - var zBlob uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) + var zBlob uintptr = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apArg))) Xsqlite3_result_int(tls, ctx, readInt16(tls, zBlob)) } } @@ -155670,7 +153031,7 @@ type RtreeCheck = RtreeCheck1 /* sqlite3.c:191964:27 */ // and RtreeCheck.rc==SQLITE_OK, set RtreeCheck.rc to the error code. func rtreeCheckReset(tls *libc.TLS, pCheck uintptr, pStmt uintptr) { /* sqlite3.c:191986:13: */ var rc int32 = Xsqlite3_reset(tls, pStmt) - if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = rc } } @@ -155693,9 +153054,9 @@ func rtreeCheckPrepare(tls *libc.TLS, pCheck uintptr, zFmt uintptr, va uintptr) ap = va z = Xsqlite3_vmprintf(tls, zFmt, ap) - if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { if z == uintptr(0) { - (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = 7 + (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM } else { (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = Xsqlite3_prepare_v2(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).Fdb, z, -1, bp /* &pRet */, uintptr(0)) } @@ -155716,10 +153077,10 @@ func rtreeCheckAppendMsg(tls *libc.TLS, pCheck uintptr, zFmt uintptr, va uintptr var ap Va_list _ = ap ap = va - if ((*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0) && ((*RtreeCheck)(unsafe.Pointer(pCheck)).FnErr < 100) { + if ((*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK) && ((*RtreeCheck)(unsafe.Pointer(pCheck)).FnErr < RTREE_CHECK_MAX_ERROR) { var z uintptr = Xsqlite3_vmprintf(tls, zFmt, ap) if z == uintptr(0) { - (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = 7 + (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM } else { (*RtreeCheck)(unsafe.Pointer(pCheck)).FzReport = Xsqlite3_mprintf(tls, ts+30004, /* "%z%s%z" */ libc.VaList(bp, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzReport, func() uintptr { @@ -155729,7 +153090,7 @@ func rtreeCheckAppendMsg(tls *libc.TLS, pCheck uintptr, zFmt uintptr, va uintptr return ts + 800 /* "" */ }(), z)) if (*RtreeCheck)(unsafe.Pointer(pCheck)).FzReport == uintptr(0) { - (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = 7 + (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM } } (*RtreeCheck)(unsafe.Pointer(pCheck)).FnErr++ @@ -155755,27 +153116,27 @@ func rtreeCheckGetNode(tls *libc.TLS, pCheck uintptr, iNode I64, pnNode uintptr) var pRet uintptr = uintptr(0) // Return value - if ((*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0) && ((*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode == uintptr(0)) { + if ((*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK) && ((*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode == uintptr(0)) { (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode = rtreeCheckPrepare(tls, pCheck, ts+30011, /* "SELECT data FROM..." */ libc.VaList(bp, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzTab)) } - if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { Xsqlite3_bind_int64(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 1, iNode) - if Xsqlite3_step(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode) == 100 { + if Xsqlite3_step(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode) == SQLITE_ROW { var nNode int32 = Xsqlite3_column_bytes(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 0) var pNode uintptr = Xsqlite3_column_blob(tls, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode, 0) pRet = Xsqlite3_malloc64(tls, uint64(nNode)) if pRet == uintptr(0) { - (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = 7 + (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc = SQLITE_NOMEM } else { libc.Xmemcpy(tls, pRet, pNode, uint64(nNode)) *(*int32)(unsafe.Pointer(pnNode)) = nNode } } rtreeCheckReset(tls, pCheck, (*RtreeCheck)(unsafe.Pointer(pCheck)).FpGetNode) - if ((*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0) && (pRet == uintptr(0)) { + if ((*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK) && (pRet == uintptr(0)) { rtreeCheckAppendMsg(tls, pCheck, ts+30056 /* "Node %lld missin..." */, libc.VaList(bp+16, iNode)) } } @@ -155808,14 +153169,14 @@ func rtreeCheckMapping(tls *libc.TLS, pCheck uintptr, bLeaf int32, iKey I64, iVa *(*uintptr)(unsafe.Pointer((pCheck + 40 /* &.aCheckMapping */) + uintptr(bLeaf)*8)) = rtreeCheckPrepare(tls, pCheck, *(*uintptr)(unsafe.Pointer(bp + 80 /* &azSql[0] */ + uintptr(bLeaf)*8)), libc.VaList(bp, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzTab)) } - if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc != 0 { + if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc != SQLITE_OK { return } pStmt = *(*uintptr)(unsafe.Pointer((pCheck + 40 /* &.aCheckMapping */) + uintptr(bLeaf)*8)) Xsqlite3_bind_int64(tls, pStmt, 1, iKey) rc = Xsqlite3_step(tls, pStmt) - if rc == 101 { + if rc == SQLITE_DONE { rtreeCheckAppendMsg(tls, pCheck, ts+30190, /* "Mapping (%lld ->..." */ libc.VaList(bp+16, iKey, iVal, func() uintptr { if bLeaf != 0 { @@ -155823,7 +153184,7 @@ func rtreeCheckMapping(tls *libc.TLS, pCheck uintptr, bLeaf int32, iKey I64, iVa } return ts + 30243 /* "%_parent" */ }())) - } else if rc == 100 { + } else if rc == SQLITE_ROW { var ii I64 = Xsqlite3_column_int64(tls, pStmt, 0) if ii != iVal { rtreeCheckAppendMsg(tls, pCheck, @@ -155924,13 +153285,13 @@ func rtreeCheckNode(tls *libc.TLS, pCheck uintptr, iDepth int32, aParent uintptr var i int32 // Used to iterate through cells if aParent == uintptr(0) { iDepth = readInt16(tls, aNode) - if iDepth > 40 { + if iDepth > RTREE_MAX_DEPTH { rtreeCheckAppendMsg(tls, pCheck, ts+30459 /* "Rtree depth out ..." */, libc.VaList(bp+16, iDepth)) Xsqlite3_free(tls, aNode) return } } - nCell = readInt16(tls, (aNode + uintptr(2))) + nCell = readInt16(tls, (aNode + 2)) if (4 + (nCell * (8 + (((*RtreeCheck)(unsafe.Pointer(pCheck)).FnDim * 2) * 4)))) > *(*int32)(unsafe.Pointer(bp + 48 /* nNode */)) { rtreeCheckAppendMsg(tls, pCheck, ts+30489, /* "Node %lld is too..." */ @@ -155939,11 +153300,11 @@ func rtreeCheckNode(tls *libc.TLS, pCheck uintptr, iDepth int32, aParent uintptr for i = 0; i < nCell; i++ { var pCell uintptr = (aNode + uintptr((4 + (i * (8 + (((*RtreeCheck)(unsafe.Pointer(pCheck)).FnDim * 2) * 4)))))) var iVal I64 = readInt64(tls, pCell) - rtreeCheckCellCoord(tls, pCheck, iNode, i, (pCell + uintptr(8)), aParent) + rtreeCheckCellCoord(tls, pCheck, iNode, i, (pCell + 8), aParent) if iDepth > 0 { rtreeCheckMapping(tls, pCheck, 0, iVal, iNode) - rtreeCheckNode(tls, pCheck, (iDepth - 1), (pCell + uintptr(8)), iVal) + rtreeCheckNode(tls, pCheck, (iDepth - 1), (pCell + 8), iVal) (*RtreeCheck)(unsafe.Pointer(pCheck)).FnNonLeaf++ } else { rtreeCheckMapping(tls, pCheck, 1, iVal, iNode) @@ -155965,12 +153326,12 @@ func rtreeCheckCount(tls *libc.TLS, pCheck uintptr, zTbl uintptr, nExpect I64) { bp := tls.Alloc(48) defer tls.Free(48) - if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK { var pCount uintptr pCount = rtreeCheckPrepare(tls, pCheck, ts+30544, /* "SELECT count(*) ..." */ libc.VaList(bp, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*RtreeCheck)(unsafe.Pointer(pCheck)).FzTab, zTbl)) if pCount != 0 { - if Xsqlite3_step(tls, pCount) == 100 { + if Xsqlite3_step(tls, pCount) == SQLITE_ROW { var nActual I64 = Xsqlite3_column_int64(tls, pCount, 0) if nActual != nExpect { rtreeCheckAppendMsg(tls, pCheck, @@ -156009,13 +153370,13 @@ func rtreeCheckTable(tls *libc.TLS, db uintptr, zDb uintptr, zTab uintptr, pzRep } // Find the number of auxiliary columns - if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).Frc == SQLITE_OK { pStmt = rtreeCheckPrepare(tls, bp+32 /* &check */, ts+30642 /* "SELECT * FROM %Q..." */, libc.VaList(bp, zDb, zTab)) if pStmt != 0 { nAux = (Xsqlite3_column_count(tls, pStmt) - 2) Xsqlite3_finalize(tls, pStmt) } - (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).Frc = 0 + (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).Frc = SQLITE_OK } // Find number of dimensions in the rtree table. @@ -156025,18 +153386,18 @@ func rtreeCheckTable(tls *libc.TLS, db uintptr, zDb uintptr, zTab uintptr, pzRep (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).FnDim = (((Xsqlite3_column_count(tls, pStmt) - 1) - nAux) / 2) if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).FnDim < 1 { rtreeCheckAppendMsg(tls, bp+32 /* &check */, ts+30670 /* "Schema corrupt o..." */, 0) - } else if 100 == Xsqlite3_step(tls, pStmt) { - (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).FbInt = (libc.Bool32(Xsqlite3_column_type(tls, pStmt, 1) == 1)) + } else if SQLITE_ROW == Xsqlite3_step(tls, pStmt) { + (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).FbInt = (libc.Bool32(Xsqlite3_column_type(tls, pStmt, 1) == SQLITE_INTEGER)) } rc = Xsqlite3_finalize(tls, pStmt) - if rc != 11 { + if rc != SQLITE_CORRUPT { (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).Frc = rc } } // Do the actual integrity-check if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).FnDim >= 1 { - if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).Frc == SQLITE_OK { rtreeCheckNode(tls, bp+32 /* &check */, 0, uintptr(0), int64(1)) } rtreeCheckCount(tls, bp+32 /* &check */, ts+30701 /* "_rowid" */, int64((*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).FnLeaf)) @@ -156045,13 +153406,13 @@ func rtreeCheckTable(tls *libc.TLS, db uintptr, zDb uintptr, zTab uintptr, pzRep // Finalize SQL statements used by the integrity-check Xsqlite3_finalize(tls, (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).FpGetNode) - Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer((bp + 32 /* &check */ + 40 /* &.aCheckMapping */) + uintptr(0)*8))) - Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer((bp + 32 /* &check */ + 40 /* &.aCheckMapping */) + uintptr(1)*8))) + Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer((bp + 32 /* &check */ + 40 /* &.aCheckMapping */)))) + Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer((bp + 32 /* &check */ + 40 /* &.aCheckMapping */) + 1*8))) // If one was opened, close the transaction if bEnd != 0 { var rc int32 = Xsqlite3_exec(tls, db, ts+30716 /* "END" */, uintptr(0), uintptr(0), uintptr(0)) - if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).Frc == 0 { + if (*RtreeCheck)(unsafe.Pointer(bp+32 /* &check */)).Frc == SQLITE_OK { (*RtreeCheck)(unsafe.Pointer(bp + 32 /* &check */)).Frc = rc } } @@ -156100,16 +153461,16 @@ func rtreecheck(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* sqli } else { var rc int32 *(*uintptr)(unsafe.Pointer(bp /* zReport */)) = uintptr(0) - var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8))) + var zDb uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg))) var zTab uintptr if nArg == 1 { zTab = zDb zDb = ts + 8333 /* "main" */ } else { - zTab = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(1)*8))) + zTab = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg + 1*8))) } rc = rtreeCheckTable(tls, Xsqlite3_context_db_handle(tls, ctx), zDb, zTab, bp /* &zReport */) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_result_text(tls, ctx, func() uintptr { if *(*uintptr)(unsafe.Pointer(bp /* zReport */)) != 0 { return *(*uintptr)(unsafe.Pointer(bp /* zReport */)) @@ -156228,20 +153589,20 @@ type GeoParse = GeoParse1 /* sqlite3.c:192567:25 */ // Do a 4-byte byte swap func geopolySwab32(tls *libc.TLS, a uintptr) { /* sqlite3.c:192577:13: */ - var t uint8 = *(*uint8)(unsafe.Pointer(a + uintptr(0))) - *(*uint8)(unsafe.Pointer(a + uintptr(0))) = *(*uint8)(unsafe.Pointer(a + uintptr(3))) - *(*uint8)(unsafe.Pointer(a + uintptr(3))) = t - t = *(*uint8)(unsafe.Pointer(a + uintptr(1))) - *(*uint8)(unsafe.Pointer(a + uintptr(1))) = *(*uint8)(unsafe.Pointer(a + uintptr(2))) - *(*uint8)(unsafe.Pointer(a + uintptr(2))) = t + var t uint8 = *(*uint8)(unsafe.Pointer(a)) + *(*uint8)(unsafe.Pointer(a)) = *(*uint8)(unsafe.Pointer(a + 3)) + *(*uint8)(unsafe.Pointer(a + 3)) = t + t = *(*uint8)(unsafe.Pointer(a + 1)) + *(*uint8)(unsafe.Pointer(a + 1)) = *(*uint8)(unsafe.Pointer(a + 2)) + *(*uint8)(unsafe.Pointer(a + 2)) = t } // Skip whitespace. Return the next non-whitespace character. func geopolySkipSpace(tls *libc.TLS, p uintptr) int8 { /* sqlite3.c:192587:13: */ - for jsonIsSpace[*(*uint8)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(p)).Fz + uintptr(0)))] != 0 { + for jsonIsSpace[*(*uint8)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(p)).Fz))] != 0 { (*GeoParse)(unsafe.Pointer(p)).Fz++ } - return int8(*(*uint8)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(p)).Fz + uintptr(0)))) + return int8(*(*uint8)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(p)).Fz))) } // Parse out a number. Write the value into *pVal if pVal!=0. @@ -156305,7 +153666,7 @@ func geopolyParseNumber(tls *libc.TLS, p uintptr, pVal uintptr) int32 { /* sqlit // is available // var r float64 at bp, 8 - Xsqlite3AtoF(tls, (*GeoParse)(unsafe.Pointer(p)).Fz, bp /* &r */, j, uint8(1)) + Xsqlite3AtoF(tls, (*GeoParse)(unsafe.Pointer(p)).Fz, bp /* &r */, j, SQLITE_UTF8) *(*GeoCoord)(unsafe.Pointer(pVal)) = GeoCoord(*(*float64)(unsafe.Pointer(bp /* r */))) } *(*uintptr)(unsafe.Pointer(p /* &.z */)) += (uintptr(j)) @@ -156330,7 +153691,7 @@ func geopolyParseJson(tls *libc.TLS, z uintptr, pRc uintptr) uintptr { /* sqlite var c int8 var pOut uintptr // var x int32 at bp+32, 4 - rc = 0 + rc = SQLITE_OK libc.Xmemset(tls, bp /* &s */, 0, uint64(unsafe.Sizeof(GeoParse{}))) (*GeoParse)(unsafe.Pointer(bp /* &s */)).Fz = z if !(int32(geopolySkipSpace(tls, bp /* &s */)) == '[') { @@ -156351,7 +153712,7 @@ __2: if !(aNew == uintptr(0)) { goto __5 } - rc = 7 + rc = SQLITE_NOMEM (*GeoParse)(unsafe.Pointer(bp /* &s */)).FnErr++ goto __3 __5: @@ -156390,7 +153751,7 @@ __9: __10: ; (*GeoParse)(unsafe.Pointer(bp /* &s */)).FnErr++ - rc = 1 + rc = SQLITE_ERROR goto parse_json_err goto __6 __7: @@ -156408,8 +153769,8 @@ __3: ; if !(((((int32(geopolySkipSpace(tls, bp /* &s */)) == ']') && ((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex >= 4)) && - (*(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + uintptr(0)*4)) == *(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + uintptr((((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex*2)-2))*4)))) && - (*(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + uintptr(1)*4)) == *(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + uintptr((((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex*2)-1))*4)))) && + (*(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa)) == *(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + uintptr((((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex*2)-2))*4)))) && + (*(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + 1*4)) == *(*GeoCoord)(unsafe.Pointer((*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa + uintptr((((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex*2)-1))*4)))) && (func() bool { (*GeoParse)(unsafe.Pointer(bp /* &s */)).Fz++ return (int32(geopolySkipSpace(tls, bp /* &s */)) == 0) @@ -156428,22 +153789,22 @@ __14: ; (*GeoPoly)(unsafe.Pointer(pOut)).FnVertex = (*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex libc.Xmemcpy(tls, pOut+8 /* &.a */, (*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa, ((uint64((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex * 2)) * uint64(unsafe.Sizeof(GeoCoord(0))))) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(0))) = *(*uint8)(unsafe.Pointer(bp + 32 /* &x */)) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(1))) = (uint8(((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex >> 16) & 0xff)) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(2))) = (uint8(((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex >> 8) & 0xff)) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(3))) = (uint8((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex & 0xff)) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */))) = *(*uint8)(unsafe.Pointer(bp + 32 /* &x */)) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + 1)) = (uint8(((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex >> 16) & 0xff)) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + 2)) = (uint8(((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex >> 8) & 0xff)) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + 3)) = (uint8((*GeoParse)(unsafe.Pointer(bp /* &s */)).FnVertex & 0xff)) Xsqlite3_free(tls, (*GeoParse)(unsafe.Pointer(bp /* &s */)).Fa) if !(pRc != 0) { goto __15 } - *(*int32)(unsafe.Pointer(pRc)) = 0 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_OK __15: ; return pOut goto __13 __12: (*GeoParse)(unsafe.Pointer(bp /* &s */)).FnErr++ - rc = 1 + rc = SQLITE_ERROR __13: ; __1: @@ -156469,17 +153830,17 @@ func geopolyFuncParam(tls *libc.TLS, pCtx uintptr, pVal uintptr, pRc uintptr) ui var p uintptr = uintptr(0) var nByte int32 - if (Xsqlite3_value_type(tls, pVal) == 4) && + if (Xsqlite3_value_type(tls, pVal) == SQLITE_BLOB) && ((uint64(libc.AssignInt32(&nByte, Xsqlite3_value_bytes(tls, pVal)))) >= (uint64(4) + (uint64(6) * uint64(unsafe.Sizeof(GeoCoord(0)))))) { var a uintptr = Xsqlite3_value_blob(tls, pVal) var nVertex int32 - nVertex = (((int32(*(*uint8)(unsafe.Pointer(a + uintptr(1)))) << 16) + (int32(*(*uint8)(unsafe.Pointer(a + uintptr(2)))) << 8)) + int32(*(*uint8)(unsafe.Pointer(a + uintptr(3))))) - if ((int32(*(*uint8)(unsafe.Pointer(a + uintptr(0)))) == 0) || (int32(*(*uint8)(unsafe.Pointer(a + uintptr(0)))) == 1)) && + nVertex = (((int32(*(*uint8)(unsafe.Pointer(a + 1))) << 16) + (int32(*(*uint8)(unsafe.Pointer(a + 2))) << 8)) + int32(*(*uint8)(unsafe.Pointer(a + 3)))) + if ((int32(*(*uint8)(unsafe.Pointer(a))) == 0) || (int32(*(*uint8)(unsafe.Pointer(a))) == 1)) && ((((uint64(nVertex * 2)) * uint64(unsafe.Sizeof(GeoCoord(0)))) + uint64(4)) == uint64(uint32(nByte))) { p = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(GeoPoly{})) + ((uint64((nVertex - 1) * 2)) * uint64(unsafe.Sizeof(GeoCoord(0))))))) if p == uintptr(0) { if pRc != 0 { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } if pCtx != 0 { Xsqlite3_result_error_nomem(tls, pCtx) @@ -156488,32 +153849,32 @@ func geopolyFuncParam(tls *libc.TLS, pCtx uintptr, pVal uintptr, pRc uintptr) ui *(*int32)(unsafe.Pointer(bp /* x */)) = 1 (*GeoPoly)(unsafe.Pointer(p)).FnVertex = nVertex libc.Xmemcpy(tls, p+4 /* &.hdr */, a, uint64(nByte)) - if int32(*(*uint8)(unsafe.Pointer(a + uintptr(0)))) != int32(*(*uint8)(unsafe.Pointer(bp /* &x */))) { + if int32(*(*uint8)(unsafe.Pointer(a))) != int32(*(*uint8)(unsafe.Pointer(bp /* &x */))) { var ii int32 for ii = 0; ii < nVertex; ii++ { geopolySwab32(tls, ((p + 8 /* &.a */) + uintptr(((ii)*2))*4)) geopolySwab32(tls, ((p + 8 /* &.a */) + uintptr((((ii)*2)+1))*4)) } - *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + uintptr(0))) ^= uint8((1)) + *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */))) ^= uint8((1)) } } } if pRc != 0 { - *(*int32)(unsafe.Pointer(pRc)) = 0 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_OK } return p - } else if Xsqlite3_value_type(tls, pVal) == 3 { + } else if Xsqlite3_value_type(tls, pVal) == SQLITE_TEXT { var zJson uintptr = Xsqlite3_value_text(tls, pVal) if zJson == uintptr(0) { if pRc != 0 { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } return uintptr(0) } return geopolyParseJson(tls, zJson, pRc) } else { if pRc != 0 { - *(*int32)(unsafe.Pointer(pRc)) = 1 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_ERROR } return uintptr(0) } @@ -156526,7 +153887,7 @@ func geopolyFuncParam(tls *libc.TLS, pCtx uintptr, pVal uintptr, pRc uintptr) ui // then return the BLOB representation of the polygon. Otherwise // return NULL. func geopolyBlobFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:192786:13: */ - var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) + var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) if p != 0 { Xsqlite3_result_blob(tls, context, p+4, /* &.hdr */ (4 + (8 * (*GeoPoly)(unsafe.Pointer(p)).FnVertex)), libc.UintptrFromInt32(-1)) @@ -156542,7 +153903,7 @@ func geopolyJsonFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { bp := tls.Alloc(32) defer tls.Free(32) - var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) + var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) if p != 0 { var db uintptr = Xsqlite3_context_db_handle(tls, context) var x uintptr = Xsqlite3_str_new(tls, db) @@ -156551,7 +153912,7 @@ func geopolyJsonFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { for i = 0; i < (*GeoPoly)(unsafe.Pointer(p)).FnVertex; i++ { Xsqlite3_str_appendf(tls, x, ts+30773 /* "[%!g,%!g]," */, libc.VaList(bp, float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((i)*2))*4))), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((i)*2)+1))*4))))) } - Xsqlite3_str_appendf(tls, x, ts+30784 /* "[%!g,%!g]]" */, libc.VaList(bp+16, float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((0)*2))*4))), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((0)*2)+1))*4))))) + Xsqlite3_str_appendf(tls, x, ts+30784 /* "[%!g,%!g]]" */, libc.VaList(bp+16, float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */)))), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + 1*4))))) Xsqlite3_result_text(tls, context, Xsqlite3_str_finish(tls, x), -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{Xsqlite3_free}))) Xsqlite3_free(tls, p) } @@ -156569,7 +153930,7 @@ func geopolySvgFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { if argc < 1 { return } - p = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) + p = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) if p != 0 { var db uintptr = Xsqlite3_context_db_handle(tls, context) var x uintptr = Xsqlite3_str_new(tls, db) @@ -156580,10 +153941,10 @@ func geopolySvgFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { Xsqlite3_str_appendf(tls, x, ts+30813 /* "%c%g,%g" */, libc.VaList(bp, int32(cSep), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((i)*2))*4))), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((i)*2)+1))*4))))) cSep = int8(' ') } - Xsqlite3_str_appendf(tls, x, ts+30821 /* " %g,%g'" */, libc.VaList(bp+24, float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((0)*2))*4))), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((0)*2)+1))*4))))) + Xsqlite3_str_appendf(tls, x, ts+30821 /* " %g,%g'" */, libc.VaList(bp+24, float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */)))), float64(*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + 1*4))))) for i = 1; i < argc; i++ { var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) - if (z != 0) && (*(*int8)(unsafe.Pointer(z + uintptr(0))) != 0) { + if (z != 0) && (*(*int8)(unsafe.Pointer(z)) != 0) { Xsqlite3_str_appendf(tls, x, ts+30829 /* " %s" */, libc.VaList(bp+40, z)) } } @@ -156608,13 +153969,13 @@ func geopolySvgFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { // // geopoly_xform(poly, cos(R), sin(R), -sin(R), cos(R), 0, 0) func geopolyXformFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:192878:13: */ - var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) - var A float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - var B float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) - var C float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) - var D float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8))) - var E float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(5)*8))) - var F float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(6)*8))) + var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) + var A float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + var B float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) + var C float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) + var D float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) + var E float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) + var F float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 6*8))) var x1 GeoCoord var y1 GeoCoord var x0 GeoCoord @@ -156648,8 +154009,8 @@ func geopolyArea(tls *libc.TLS, p uintptr) float64 { /* sqlite3.c:192914:15: */ ((*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((ii)*2)+1))*4))) + (*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((ii+1)*2)+1))*4)))))) * // (y0 + y1) 0.5) } - rArea = rArea + ((float64(((*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((ii)*2))*4))) - (*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((0)*2))*4)))) * // (xN - x0) - ((*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((ii)*2)+1))*4))) + (*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((0)*2)+1))*4)))))) * // (yN + y0) + rArea = rArea + ((float64(((*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((ii)*2))*4))) - (*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */))))) * // (xN - x0) + ((*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((ii)*2)+1))*4))) + (*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + 1*4)))))) * // (yN + y0) 0.5) return rArea } @@ -156661,7 +154022,7 @@ func geopolyArea(tls *libc.TLS, p uintptr) float64 { /* sqlite3.c:192914:15: */ // of counterclockwise (as it should) then return the negative of the // enclosed area. Otherwise return NULL. func geopolyAreaFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:192936:13: */ - var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) + var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) if p != 0 { Xsqlite3_result_double(tls, context, geopolyArea(tls, p)) Xsqlite3_free(tls, p) @@ -156680,7 +154041,7 @@ func geopolyAreaFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { // Use this routine to sanitize historical inputs that that sometimes // contain polygons that wind in the wrong direction. func geopolyCcwFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:192961:13: */ - var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) + var p uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) if p != 0 { if geopolyArea(tls, p) < 0.0 { var ii int32 @@ -156739,10 +154100,10 @@ func geopolyRegularFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr bp := tls.Alloc(4) defer tls.Free(4) - var x float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - var y float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - var r float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) - var n int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) + var x float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) + var y float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + var r float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) + var n int32 = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) // var i int32 at bp, 4 var p uintptr @@ -156759,10 +154120,10 @@ func geopolyRegularFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr return } *(*int32)(unsafe.Pointer(bp /* i */)) = 1 - *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + uintptr(0))) = *(*uint8)(unsafe.Pointer(bp /* &i */)) - *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + uintptr(1))) = uint8(0) - *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + uintptr(2))) = (uint8((n >> 8) & 0xff)) - *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + uintptr(3))) = (uint8(n & 0xff)) + *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */))) = *(*uint8)(unsafe.Pointer(bp /* &i */)) + *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + 1)) = uint8(0) + *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + 2)) = (uint8((n >> 8) & 0xff)) + *(*uint8)(unsafe.Pointer((p + 4 /* &.hdr */) + 3)) = (uint8(n & 0xff)) for *(*int32)(unsafe.Pointer(bp /* i */)) = 0; *(*int32)(unsafe.Pointer(bp /* i */)) < n; *(*int32)(unsafe.Pointer(bp /* i */))++ { var rAngle float64 = (((float64(2.0) * 3.1415926535897932385) * float64(*(*int32)(unsafe.Pointer(bp /* i */)))) / float64(n)) (*(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((*(*int32)(unsafe.Pointer(bp /* i */)))*2))*4))) = (GeoCoord(x - (r * geopolySine(tls, (rAngle-(float64(0.5)*3.1415926535897932385)))))) @@ -156797,10 +154158,10 @@ func geopolyBBox(tls *libc.TLS, context uintptr, pPoly uintptr, aCoord uintptr, goto __1 } p = uintptr(0) - mnX = *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(0)*4)) - mxX = *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(1)*4)) - mnY = *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(2)*4)) - mxY = *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(3)*4)) + mnX = *(*RtreeValue)(unsafe.Pointer(aCoord)) + mxX = *(*RtreeValue)(unsafe.Pointer(aCoord + 1*4)) + mnY = *(*RtreeValue)(unsafe.Pointer(aCoord + 2*4)) + mxY = *(*RtreeValue)(unsafe.Pointer(aCoord + 3*4)) goto geopolyBboxFill goto __2 __1: @@ -156810,8 +154171,8 @@ __2: if !(p != 0) { goto __3 } - mnX = libc.AssignFloat32(&mxX, *(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr(((0)*2))*4))) - mnY = libc.AssignFloat32(&mxY, *(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + uintptr((((0)*2)+1))*4))) + mnX = libc.AssignFloat32(&mxX, *(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */)))) + mnY = libc.AssignFloat32(&mxY, *(*GeoCoord)(unsafe.Pointer((p + 8 /* &.a */) + 1*4))) *(*int32)(unsafe.Pointer(bp /* ii */)) = 1 __5: if !(*(*int32)(unsafe.Pointer(bp /* ii */)) < (*GeoPoly)(unsafe.Pointer(p)).FnVertex) { @@ -156857,7 +154218,7 @@ __7: if !(pRc != 0) { goto __14 } - *(*int32)(unsafe.Pointer(pRc)) = 0 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_OK __14: ; if !(aCoord == uintptr(0)) { @@ -156878,7 +154239,7 @@ __18: if !(pRc != 0) { goto __19 } - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM __19: ; return uintptr(0) @@ -156886,25 +154247,25 @@ __17: ; (*GeoPoly)(unsafe.Pointer(pOut)).FnVertex = 4 *(*int32)(unsafe.Pointer(bp /* ii */)) = 1 - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(0))) = *(*uint8)(unsafe.Pointer(bp /* &ii */)) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(1))) = uint8(0) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(2))) = uint8(0) - *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + uintptr(3))) = uint8(4) - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr(((0)*2))*4))) = mnX - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr((((0)*2)+1))*4))) = mnY - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr(((1)*2))*4))) = mxX - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr((((1)*2)+1))*4))) = mnY - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr(((2)*2))*4))) = mxX - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr((((2)*2)+1))*4))) = mxY - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr(((3)*2))*4))) = mnX - (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + uintptr((((3)*2)+1))*4))) = mxY + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */))) = *(*uint8)(unsafe.Pointer(bp /* &ii */)) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + 1)) = uint8(0) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + 2)) = uint8(0) + *(*uint8)(unsafe.Pointer((pOut + 4 /* &.hdr */) + 3)) = uint8(4) + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */)))) = mnX + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 1*4))) = mnY + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 2*4))) = mxX + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 3*4))) = mnY + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 4*4))) = mxX + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 5*4))) = mxY + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 6*4))) = mnX + (*(*GeoCoord)(unsafe.Pointer((pOut + 8 /* &.a */) + 7*4))) = mxY goto __16 __15: Xsqlite3_free(tls, p) - *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(0)*4)) = mnX - *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(1)*4)) = mxX - *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(2)*4)) = mnY - *(*RtreeValue)(unsafe.Pointer(aCoord + uintptr(3)*4)) = mxY + *(*RtreeValue)(unsafe.Pointer(aCoord)) = mnX + *(*RtreeValue)(unsafe.Pointer(aCoord + 1*4)) = mxX + *(*RtreeValue)(unsafe.Pointer(aCoord + 2*4)) = mnY + *(*RtreeValue)(unsafe.Pointer(aCoord + 3*4)) = mxY __16: ; goto __4 @@ -156917,7 +154278,7 @@ __4: // Implementation of the geopoly_bbox(X) SQL function. func geopolyBBoxFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:193124:13: */ - var p uintptr = geopolyBBox(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0), uintptr(0)) + var p uintptr = geopolyBBox(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0), uintptr(0)) if p != 0 { Xsqlite3_result_blob(tls, context, p+4, /* &.hdr */ (4 + (8 * (*GeoPoly)(unsafe.Pointer(p)).FnVertex)), libc.UintptrFromInt32(-1)) @@ -156941,9 +154302,9 @@ func geopolyBBoxStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { // var a [4]RtreeCoord at bp, 16 - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 0 - geopolyBBox(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), bp /* &a[0] */, bp+16 /* &rc */) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK + geopolyBBox(tls, context, *(*uintptr)(unsafe.Pointer(argv)), bp /* &a[0] */, bp+16 /* &rc */) + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { var pBBox uintptr pBBox = Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(GeoBBox{}))) if pBBox == uintptr(0) { @@ -156953,17 +154314,17 @@ func geopolyBBoxStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { (*GeoBBox)(unsafe.Pointer(pBBox)).FisInit = 1 libc.Xmemcpy(tls, pBBox+4 /* &.a */, bp /* &a[0] */, (uint64(unsafe.Sizeof(RtreeCoord{})) * uint64(4))) } else { - if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + uintptr(0)*4)) < *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(0)*4)) { - *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(0)*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + uintptr(0)*4)) + if *(*RtreeValue)(unsafe.Pointer(bp /* &a */)) < *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */))) { + *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */))) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */)) } - if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + uintptr(1)*4)) > *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(1)*4)) { - *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(1)*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + uintptr(1)*4)) + if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + 1*4)) > *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + 1*4)) { + *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + 1*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + 1*4)) } - if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + uintptr(2)*4)) < *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(2)*4)) { - *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(2)*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + uintptr(2)*4)) + if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + 2*4)) < *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + 2*4)) { + *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + 2*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + 2*4)) } - if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + uintptr(3)*4)) > *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(3)*4)) { - *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + uintptr(3)*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + uintptr(3)*4)) + if *(*RtreeValue)(unsafe.Pointer(bp /* &a */ + 3*4)) > *(*RtreeValue)(unsafe.Pointer((pBBox + 4 /* &.a */) + 3*4)) { + *(*RtreeCoord)(unsafe.Pointer((pBBox + 4 /* &.a */) + 3*4)) = *(*RtreeCoord)(unsafe.Pointer(bp /* &a[0] */ + 3*4)) } } } @@ -157038,9 +154399,9 @@ func pointBeneathLine(tls *libc.TLS, x0 float64, y0 float64, x1 float64, y1 floa // Return +1 if point X,Y is on the polygon boundary. // Return 0 if point X,Y is outside the polygon func geopolyContainsPointFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:193234:13: */ - var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) - var x0 float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - var y0 float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8))) + var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) + var x0 float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + var y0 float64 = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) var v int32 = 0 var cnt int32 = 0 var ii int32 @@ -157057,7 +154418,7 @@ func geopolyContainsPointFunc(tls *libc.TLS, context uintptr, argc int32, argv u } if v != 2 { v = pointBeneathLine(tls, x0, y0, float64(*(*GeoCoord)(unsafe.Pointer((p1 + 8 /* &.a */) + uintptr(((ii)*2))*4))), float64(*(*GeoCoord)(unsafe.Pointer((p1 + 8 /* &.a */) + uintptr((((ii)*2)+1))*4))), - float64(*(*GeoCoord)(unsafe.Pointer((p1 + 8 /* &.a */) + uintptr(((0)*2))*4))), float64(*(*GeoCoord)(unsafe.Pointer((p1 + 8 /* &.a */) + uintptr((((0)*2)+1))*4)))) + float64(*(*GeoCoord)(unsafe.Pointer((p1 + 8 /* &.a */)))), float64(*(*GeoCoord)(unsafe.Pointer((p1 + 8 /* &.a */) + 1*4)))) } if v == 2 { Xsqlite3_result_int(tls, context, 1) @@ -157076,8 +154437,8 @@ func geopolyContainsPointFunc(tls *libc.TLS, context uintptr, argc int32, argv u // Return 0 if any part of P2 is on the outside of P1 // func geopolyWithinFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:193277:13: */ - var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) - var p2 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uintptr(0)) + var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) + var p2 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uintptr(0)) if (p1 != 0) && (p2 != 0) { var x int32 = geopolyOverlap(tls, p1, p2) if x < 0 { @@ -157173,10 +154534,10 @@ func geopolyAddSegments(tls *libc.TLS, p uintptr, pPoly uintptr, side uint8) { / var x uintptr for i = uint32(0); i < (uint32((*GeoPoly)(unsafe.Pointer(pPoly)).FnVertex) - uint32(1)); i++ { x = ((pPoly + 8 /* &.a */) + uintptr(((i)*uint32(2)))*4) - geopolyAddOneSegment(tls, p, *(*GeoCoord)(unsafe.Pointer(x + uintptr(0)*4)), *(*GeoCoord)(unsafe.Pointer(x + uintptr(1)*4)), *(*GeoCoord)(unsafe.Pointer(x + uintptr(2)*4)), *(*GeoCoord)(unsafe.Pointer(x + uintptr(3)*4)), side, i) + geopolyAddOneSegment(tls, p, *(*GeoCoord)(unsafe.Pointer(x)), *(*GeoCoord)(unsafe.Pointer(x + 1*4)), *(*GeoCoord)(unsafe.Pointer(x + 2*4)), *(*GeoCoord)(unsafe.Pointer(x + 3*4)), side, i) } x = ((pPoly + 8 /* &.a */) + uintptr(((i)*uint32(2)))*4) - geopolyAddOneSegment(tls, p, *(*GeoCoord)(unsafe.Pointer(x + uintptr(0)*4)), *(*GeoCoord)(unsafe.Pointer(x + uintptr(1)*4)), *(*GeoCoord)(unsafe.Pointer((pPoly + 8 /* &.a */) + uintptr(0)*4)), *(*GeoCoord)(unsafe.Pointer((pPoly + 8 /* &.a */) + uintptr(1)*4)), side, i) + geopolyAddOneSegment(tls, p, *(*GeoCoord)(unsafe.Pointer(x)), *(*GeoCoord)(unsafe.Pointer(x + 1*4)), *(*GeoCoord)(unsafe.Pointer((pPoly + 8 /* &.a */))), *(*GeoCoord)(unsafe.Pointer((pPoly + 8 /* &.a */) + 1*4)), side, i) } // Merge two lists of sorted events by X coordinate @@ -157338,7 +154699,7 @@ func geopolyOverlap(tls *libc.TLS, p1 uintptr, p2 uintptr) int32 { /* sqlite3.c: return -1 __1: ; - (*GeoOverlap)(unsafe.Pointer(p)).FaEvent = (p + uintptr(1)*24) + (*GeoOverlap)(unsafe.Pointer(p)).FaEvent = (p + 1*24) (*GeoOverlap)(unsafe.Pointer(p)).FaSegment = ((*GeoOverlap)(unsafe.Pointer(p)).FaEvent + uintptr((nVertex*int64(2)))*32) (*GeoOverlap)(unsafe.Pointer(p)).FnEvent = libc.AssignPtrInt32(p+20 /* &.nSegment */, 0) geopolyAddSegments(tls, p, p1, uint8(1)) @@ -157483,25 +154844,25 @@ __19: goto __2 __3: ; - if !(int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(3)))) == 0) { + if !(int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 3))) == 0) { goto __26 } rc = 0 goto __27 __26: - if !((int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(1)))) != 0) && (int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(2)))) == 0)) { + if !((int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 1))) != 0) && (int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 2))) == 0)) { goto __28 } rc = 3 goto __29 __28: - if !((int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(1)))) == 0) && (int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(2)))) != 0)) { + if !((int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 1))) == 0) && (int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 2))) != 0)) { goto __30 } rc = 2 goto __31 __30: - if !((int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(1)))) == 0) && (int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + uintptr(2)))) == 0)) { + if !((int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 1))) == 0) && (int32(*(*uint8)(unsafe.Pointer(bp /* &aOverlap[0] */ + 2))) == 0)) { goto __32 } rc = 4 @@ -157533,8 +154894,8 @@ geopolyOverlapDone: // 4 P1 and P2 are the same polygon // NULL Either P1 or P2 or both are not valid polygons func geopolyOverlapFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* sqlite3.c:193607:13: */ - var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), uintptr(0)) - var p2 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uintptr(0)) + var p1 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv)), uintptr(0)) + var p2 uintptr = geopolyFuncParam(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uintptr(0)) if (p1 != 0) && (p2 != 0) { var x int32 = geopolyOverlap(tls, p1, p2) if x < 0 { @@ -157569,30 +154930,30 @@ func geopolyInit(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintp var pSql uintptr var zSql uintptr var ii int32 - rc = 0 + rc = SQLITE_OK - Xsqlite3_vtab_config(tls, db, 1, libc.VaList(bp, 1)) + Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_CONSTRAINT_SUPPORT, libc.VaList(bp, 1)) // Allocate the sqlite3_vtab structure - nDb = Sqlite3_int64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) - nName = Sqlite3_int64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)))) + nDb = Sqlite3_int64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) + nName = Sqlite3_int64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) pRtree = Xsqlite3_malloc64(tls, (((uint64(unsafe.Sizeof(Rtree{})) + uint64(nDb)) + uint64(nName)) + uint64(2))) if !(!(pRtree != 0)) { goto __1 } - return 7 + return SQLITE_NOMEM __1: ; libc.Xmemset(tls, pRtree, 0, (uint64(((uint64(unsafe.Sizeof(Rtree{})) + uint64(nDb)) + uint64(nName)) + uint64(2)))) (*Rtree)(unsafe.Pointer(pRtree)).FnBusy = U32(1) (*Rtree)(unsafe.Pointer(pRtree)).Fbase.FpModule = uintptr(unsafe.Pointer(&rtreeModule)) - (*Rtree)(unsafe.Pointer(pRtree)).FzDb = (pRtree + uintptr(1)*968) + (*Rtree)(unsafe.Pointer(pRtree)).FzDb = (pRtree + 1*968) (*Rtree)(unsafe.Pointer(pRtree)).FzName = ((*Rtree)(unsafe.Pointer(pRtree)).FzDb + uintptr((nDb + int64(1)))) - (*Rtree)(unsafe.Pointer(pRtree)).FeCoordType = U8(0) + (*Rtree)(unsafe.Pointer(pRtree)).FeCoordType = RTREE_COORD_REAL32 (*Rtree)(unsafe.Pointer(pRtree)).FnDim = U8(2) (*Rtree)(unsafe.Pointer(pRtree)).FnDim2 = U8(4) - libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uint64(nDb)) - libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzName, *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), uint64(nName)) + libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzDb, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uint64(nDb)) + libc.Xmemcpy(tls, (*Rtree)(unsafe.Pointer(pRtree)).FzName, *(*uintptr)(unsafe.Pointer(argv + 2*8)), uint64(nName)) // Create/Connect to the underlying relational database schema. If // that is successful, call sqlite3_declare_vtab() to configure @@ -157620,10 +154981,10 @@ __4: if !(!(zSql != 0)) { goto __5 } - rc = 7 + rc = SQLITE_NOMEM goto __6 __5: - if !(0 != (libc.AssignInt32(&rc, Xsqlite3_declare_vtab(tls, db, zSql)))) { + if !(SQLITE_OK != (libc.AssignInt32(&rc, Xsqlite3_declare_vtab(tls, db, zSql)))) { goto __7 } *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp+16, Xsqlite3_errmsg(tls, db))) @@ -157648,7 +155009,7 @@ __8: goto geopolyInit_fail __9: ; - rc = rtreeSqlInit(tls, pRtree, db, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(2)*8)), isCreate) + rc = rtreeSqlInit(tls, pRtree, db, *(*uintptr)(unsafe.Pointer(argv + 1*8)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), isCreate) if !(rc != 0) { goto __10 } @@ -157658,13 +155019,13 @@ __10: ; *(*uintptr)(unsafe.Pointer(ppVtab)) = pRtree - return 0 + return SQLITE_OK geopolyInit_fail: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __11 } - rc = 1 + rc = SQLITE_ERROR __11: ; @@ -157718,7 +155079,7 @@ func geopolyFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint pRtree = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab pCsr = pVtabCursor *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = SQLITE_OK *(*int32)(unsafe.Pointer(bp + 16 /* iCell */)) = 0 rtreeReference(tls, pRtree) @@ -157730,17 +155091,17 @@ func geopolyFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uint if !(idxNum == 1) { goto __1 } // Search point for the leaf - iRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + iRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) *(*I64)(unsafe.Pointer(bp + 8 /* iNode */)) = int64(0) *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = findLeafNode(tls, pRtree, iRowid, bp /* &pLeaf */, bp+8 /* &iNode */) - if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) && (*(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) != uintptr(0))) { + if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) != uintptr(0))) { goto __3 } p = rtreeSearchPointNew(tls, pCsr, 0.0, uint8(0)) // Always returns pCsr->sPoint - *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */) + uintptr(0)*8)) = *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) + *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */))) = *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)) (*RtreeSearchPoint)(unsafe.Pointer(p)).Fid = *(*I64)(unsafe.Pointer(bp + 8 /* iNode */)) - (*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = U8(1) + (*RtreeSearchPoint)(unsafe.Pointer(p)).FeWithin = PARTLY_WITHIN *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = nodeRowidIndex(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp /* pLeaf */)), iRowid, bp+16 /* &iCell */) (*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell = U8(*(*int32)(unsafe.Pointer(bp + 16 /* iCell */))) @@ -157754,11 +155115,11 @@ __1: // Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array // with the configured constraints. *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = nodeAcquire(tls, pRtree, int64(1), uintptr(0), bp+24 /* &pRoot */) - if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) && (idxNum <= 3)) { + if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) && (idxNum <= 3)) { goto __5 } - geopolyBBox(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)), bp+32 /* &bbox[0] */, bp+48 /* &rc */) + geopolyBBox(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(argv)), bp+32 /* &bbox[0] */, bp+48 /* &rc */) if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) != 0) { goto __6 } @@ -157770,7 +155131,7 @@ __6: if !(p1 == uintptr(0)) { goto __7 } - *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = SQLITE_NOMEM goto __8 __7: libc.Xmemset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FaConstraint, 0, (uint64(unsafe.Sizeof(RtreeConstraint{})) * uint64(4))) @@ -157781,59 +155142,59 @@ __7: // Overlap query (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'B' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 0 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(1)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + 1*4))) p1 += 24 (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'D' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 1 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(0)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */))) p1 += 24 (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'B' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 2 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(3)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + 3*4))) p1 += 24 (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'D' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 3 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(2)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + 2*4))) goto __10 __9: // Within query (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'D' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 0 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(0)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */))) p1 += 24 (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'B' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 1 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(1)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + 1*4))) p1 += 24 (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'D' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 2 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(2)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + 2*4))) p1 += 24 (*RtreeConstraint)(unsafe.Pointer(p1)).Fop = 'B' (*RtreeConstraint)(unsafe.Pointer(p1)).FiCoord = 3 - *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + uintptr(3)*4))) + *(*RtreeDValue)(unsafe.Pointer(p1 + 8 /* &.u */)) = RtreeDValue(*(*RtreeValue)(unsafe.Pointer(bp + 32 /* &bbox */ + 3*4))) __10: ; __8: ; __5: ; - if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) { + if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) { goto __11 } pNew = rtreeSearchPointNew(tls, pCsr, 0.0, (U8((*Rtree)(unsafe.Pointer(pRtree)).FiDepth + 1))) if !(pNew == uintptr(0)) { goto __12 } - *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = SQLITE_NOMEM goto geopoly_filter_end __12: ; (*RtreeSearchPoint)(unsafe.Pointer(pNew)).Fid = int64(1) (*RtreeSearchPoint)(unsafe.Pointer(pNew)).FiCell = U8(0) - (*RtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = U8(1) + (*RtreeSearchPoint)(unsafe.Pointer(pNew)).FeWithin = PARTLY_WITHIN - *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */) + uintptr(0)*8)) = *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) + *(*uintptr)(unsafe.Pointer((pCsr + 88 /* &.aNode */))) = *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) *(*uintptr)(unsafe.Pointer(bp + 24 /* pRoot */)) = uintptr(0) *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = rtreeStepToLeaf(tls, pCsr) @@ -157870,16 +155231,16 @@ func geopolyBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* s if !(int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) != 0) { continue } - if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn < 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2) { + if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn < 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { iRowidTerm = ii break } - if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) >= 150) { + if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) >= SQLITE_INDEX_CONSTRAINT_FUNCTION) { // p->op==SQLITE_INDEX_CONSTRAINT_FUNCTION for geopoly_overlap() // p->op==(SQLITE_INDEX_CONTRAINT_FUNCTION+1) for geopoly_within(). // See geopolyFindFunction() iFuncTerm = ii - idxNum = ((int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) - 150) + 2) + idxNum = ((int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) - SQLITE_INDEX_CONSTRAINT_FUNCTION) + 2) } } @@ -157890,8 +155251,8 @@ func geopolyBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* s (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8)).Fomit = uint8(1) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 30.0 (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) - (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = 1 - return 0 + (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = SQLITE_INDEX_SCAN_UNIQUE + return SQLITE_OK } if iFuncTerm >= 0 { (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = idxNum @@ -157900,13 +155261,13 @@ func geopolyBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* s (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iFuncTerm)*8)).Fomit = uint8(0) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 300.0 (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(10) - return 0 + return SQLITE_OK } (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 4 (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = ts + 30878 /* "fullscan" */ (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 3000000.0 (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(100000) - return 0 + return SQLITE_OK } // GEOPOLY virtual table module xColumn method. @@ -157917,17 +155278,17 @@ func geopolyColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* var pRtree uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab var pCsr uintptr = cur var p uintptr = rtreeSearchPointFirst(tls, pCsr) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var pNode uintptr = rtreeNodeOfFirstSearchPoint(tls, pCsr, bp /* &rc */) if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { return *(*int32)(unsafe.Pointer(bp /* rc */)) } if p == uintptr(0) { - return 0 + return SQLITE_OK } if (i == 0) && (Xsqlite3_vtab_nochange(tls, ctx) != 0) { - return 0 + return SQLITE_OK } if i <= int32((*Rtree)(unsafe.Pointer(pRtree)).FnAux) { if !(int32((*RtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid) != 0) { @@ -157941,19 +155302,19 @@ func geopolyColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* Xsqlite3_bind_int64(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, 1, nodeGetRowid(tls, pRtree, pNode, int32((*RtreeSearchPoint)(unsafe.Pointer(p)).FiCell))) *(*int32)(unsafe.Pointer(bp /* rc */)) = Xsqlite3_step(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 100 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_ROW { (*RtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid = U8(1) } else { Xsqlite3_reset(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 101 { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_DONE { + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK } return *(*int32)(unsafe.Pointer(bp /* rc */)) } } Xsqlite3_result_value(tls, ctx, Xsqlite3_column_value(tls, (*RtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux, (i+2))) } - return 0 + return SQLITE_OK } // The xUpdate method for GEOPOLY module virtual tables. @@ -157999,7 +155360,7 @@ func geopolyUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRo var jj int32 var nChange int32 pRtree = pVtab - *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = SQLITE_OK coordChange = 0 // Change in coordinates if !((*Rtree)(unsafe.Pointer(pRtree)).FnNodeRef != 0) { @@ -158008,21 +155369,21 @@ func geopolyUpdate(tls *libc.TLS, pVtab uintptr, nData int32, aData uintptr, pRo // Unable to write to the btree while another cursor is reading from it, // since the write might do a rebalance which would disrupt the read // cursor. - return (6 | (int32(2) << 8)) + return (SQLITE_LOCKED | (int32(2) << 8)) __1: ; rtreeReference(tls, pRtree) - oldRowidValid = (libc.Bool32(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(0)*8))) != 5)) + oldRowidValid = (libc.Bool32(Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData))) != SQLITE_NULL)) if oldRowidValid != 0 { - oldRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(0)*8))) + oldRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData))) } else { oldRowid = int64(0) } - newRowidValid = (libc.Bool32((nData > 1) && (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(1)*8))) != 5))) + newRowidValid = (libc.Bool32((nData > 1) && (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + 1*8))) != SQLITE_NULL))) if newRowidValid != 0 { - newRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(1)*8))) + newRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(aData + 1*8))) } else { newRowid = int64(0) } @@ -158030,15 +155391,15 @@ __1: if !((nData > 1) && // not a DELETE ((!(oldRowidValid != 0) || // INSERT - !(Xsqlite3_value_nochange(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8))) != 0)) || // UPDATE _shape + !(Xsqlite3_value_nochange(tls, *(*uintptr)(unsafe.Pointer(aData + 2*8))) != 0)) || // UPDATE _shape (oldRowid != newRowid))) { goto __2 } - geopolyBBox(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8)), bp /* &cell */ +8 /* &.aCoord */, bp+48 /* &rc */) + geopolyBBox(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(aData + 2*8)), bp /* &cell */ +8 /* &.aCoord */, bp+48 /* &rc */) if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) != 0) { goto __3 } - if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 1) { + if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_ERROR) { goto __4 } (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+30887 /* "_shape does not ..." */, 0) @@ -158057,10 +155418,10 @@ __3: Xsqlite3_bind_int64(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid, 1, (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid) steprc = Xsqlite3_step(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = Xsqlite3_reset(tls, (*Rtree)(unsafe.Pointer(pRtree)).FpReadRowid) - if !(100 == steprc) { + if !(SQLITE_ROW == steprc) { goto __6 } - if !(Xsqlite3_vtab_on_conflict(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb) == 5) { + if !(Xsqlite3_vtab_on_conflict(tls, (*Rtree)(unsafe.Pointer(pRtree)).Fdb) == SQLITE_REPLACE) { goto __7 } *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = rtreeDeleteRowid(tls, pRtree, (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid) @@ -158079,7 +155440,7 @@ __2: // If aData[0] is not an SQL NULL value, it is the rowid of a // record to delete from the r-tree table. The following block does // just that. - if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) && ((nData == 1) || ((coordChange != 0) && (oldRowidValid != 0)))) { + if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) && ((nData == 1) || ((coordChange != 0) && (oldRowidValid != 0)))) { goto __9 } *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = rtreeDeleteRowid(tls, pRtree, oldRowid) @@ -158089,7 +155450,7 @@ __9: // If the aData[] array contains more than one element, elements // (aData[2]..aData[argc-1]) contain a new record to insert into // the r-tree structure. - if !(((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) && (nData > 1)) && (coordChange != 0)) { + if !(((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) && (nData > 1)) && (coordChange != 0)) { goto __10 } // Insert the new record into the r-tree @@ -158101,19 +155462,19 @@ __9: __11: ; *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid - if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) { + if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) { goto __12 } *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = sChooseLeaf(tls, pRtree, bp /* &cell */, 0, bp+56 /* &pLeaf */) __12: ; - if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) { + if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) { goto __13 } (*Rtree)(unsafe.Pointer(pRtree)).FiReinsertHeight = -1 *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = rtreeInsertCell(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 56 /* pLeaf */)), bp /* &cell */, 0) rc2 = nodeRelease(tls, pRtree, *(*uintptr)(unsafe.Pointer(bp + 56 /* pLeaf */))) - if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) { + if !(*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) { goto __14 } *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = rc2 @@ -158125,29 +155486,29 @@ __10: ; // Change the data - if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0) && (nData > 1)) { + if !((*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK) && (nData > 1)) { goto __15 } pUp = (*Rtree)(unsafe.Pointer(pRtree)).FpWriteAux nChange = 0 Xsqlite3_bind_int64(tls, pUp, 1, (*RtreeCell)(unsafe.Pointer(bp /* &cell */)).FiRowid) - if !(Xsqlite3_value_nochange(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8))) != 0) { + if !(Xsqlite3_value_nochange(tls, *(*uintptr)(unsafe.Pointer(aData + 2*8))) != 0) { goto __16 } Xsqlite3_bind_null(tls, pUp, 2) goto __17 __16: p = uintptr(0) - if !(((Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8))) == 3) && - ((libc.AssignUintptr(&p, geopolyFuncParam(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8)), bp+48 /* &rc */))) != uintptr(0))) && - (*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == 0)) { + if !(((Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(aData + 2*8))) == SQLITE_TEXT) && + ((libc.AssignUintptr(&p, geopolyFuncParam(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(aData + 2*8)), bp+48 /* &rc */))) != uintptr(0))) && + (*(*int32)(unsafe.Pointer(bp + 48 /* rc */)) == SQLITE_OK)) { goto __18 } Xsqlite3_bind_blob(tls, pUp, 2, p+4 /* &.hdr */, (4 + (8 * (*GeoPoly)(unsafe.Pointer(p)).FnVertex)), libc.UintptrFromInt32(-1)) goto __19 __18: - Xsqlite3_bind_value(tls, pUp, 2, *(*uintptr)(unsafe.Pointer(aData + uintptr(2)*8))) + Xsqlite3_bind_value(tls, pUp, 2, *(*uintptr)(unsafe.Pointer(aData + 2*8))) __19: ; Xsqlite3_free(tls, p) @@ -158191,70 +155552,45 @@ func geopolyFindFunction(tls *libc.TLS, pVtab uintptr, nArg int32, zName uintptr f func(*libc.TLS, uintptr, int32, uintptr) }{geopolyOverlapFunc})) *(*uintptr)(unsafe.Pointer(ppArg)) = uintptr(0) - return 150 + return SQLITE_INDEX_CONSTRAINT_FUNCTION } if Xsqlite3_stricmp(tls, zName, ts+30943 /* "geopoly_within" */) == 0 { *(*uintptr)(unsafe.Pointer(pxFunc)) = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{geopolyWithinFunc})) *(*uintptr)(unsafe.Pointer(ppArg)) = uintptr(0) - return (150 + 1) + return (SQLITE_INDEX_CONSTRAINT_FUNCTION + 1) } return 0 } var geopolyModule = Sqlite3_module{ - FiVersion: 3, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - create a table - 0, - FxBestIndex:// xConnect - connect to an existing table - 0, - FxDisconnect:// xBestIndex - Determine search strategy - 0, - FxDestroy:// xDisconnect - Disconnect from a table - 0, - FxOpen:// xDestroy - Drop a table - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - write data - 0, - FxSync:// xBegin - begin transaction - 0, - FxCommit:// xSync - sync transaction - 0, - FxRollback:// xCommit - commit transaction - 0, - FxFindFunction:// xRollback - rollback transaction - 0, - FxRename:// xFindFunction - function overloading - 0, - FxSavepoint:// xRename - rename the table - 0, - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - 0, // xShadowName + FiVersion: 3, // iVersion + FxCreate: 0, // xCreate - create a table + FxConnect: 0, // xConnect - connect to an existing table + FxBestIndex: 0, // xBestIndex - Determine search strategy + FxDisconnect: 0, // xDisconnect - Disconnect from a table + FxDestroy: 0, // xDestroy - Drop a table + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRowid - read data + FxUpdate: 0, // xUpdate - write data + FxBegin: 0, // xBegin - begin transaction + FxSync: 0, // xSync - sync transaction + FxCommit: 0, // xCommit - commit transaction + FxRollback: 0, // xRollback - rollback transaction + FxFindFunction: 0, // xFindFunction - function overloading + FxRename: 0, // xRename - rename the table + FxSavepoint: 0, // xRollbackTo + FxShadowName: 0, // xShadowName } /* sqlite3.c:194163:23 */ func sqlite3_geopoly_init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:194190:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 for i = 0; (uint64(i) < (uint64(unsafe.Sizeof(aFunc1)) / uint64(unsafe.Sizeof(struct { FxFunc uintptr @@ -158262,12 +155598,12 @@ func sqlite3_geopoly_init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:194190 FbPure uint8 _ [6]byte FzName uintptr - }{})))) && (rc == 0); i++ { + }{})))) && (rc == SQLITE_OK); i++ { var enc int32 if aFunc1[i].FbPure != 0 { - enc = ((1 | 0x000000800) | 0x000200000) + enc = ((SQLITE_UTF8 | SQLITE_DETERMINISTIC) | SQLITE_INNOCUOUS) } else { - enc = (1 | 0x000080000) + enc = (SQLITE_UTF8 | SQLITE_DIRECTONLY) } rc = Xsqlite3_create_function(tls, db, aFunc1[i].FzName, int32(aFunc1[i].FnArg), enc, uintptr(0), @@ -158277,12 +155613,12 @@ func sqlite3_geopoly_init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:194190 FxStep uintptr FxFinal uintptr FzName uintptr - }{})))) && (rc == 0); i++ { + }{})))) && (rc == SQLITE_OK); i++ { rc = Xsqlite3_create_function(tls, db, aAgg1[i].FzName, 1, - ((1 | 0x000000800) | 0x000200000), uintptr(0), + ((SQLITE_UTF8 | SQLITE_DETERMINISTIC) | SQLITE_INNOCUOUS), uintptr(0), uintptr(0), aAgg1[i].FxStep, aAgg1[i].FxFinal) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_module_v2(tls, db, ts+30958 /* "geopoly" */, uintptr(unsafe.Pointer(&geopolyModule)), uintptr(0), uintptr(0)) } return rc @@ -158295,76 +155631,25 @@ var aFunc1 = [12]struct { _ [6]byte FzName uintptr }{ - { - FxFunc: 0, - FnArg: int8(1), - FbPure: uint8(1), - FzName: ts + 30966 /* "geopoly_area" */}, - { - FxFunc: 0, - FnArg: int8(1), - FbPure: uint8(1), - FzName: ts + 30979 /* "geopoly_blob" */}, - { - FxFunc: 0, - FnArg: int8(1), - FbPure: uint8(1), - FzName: ts + 30992 /* "geopoly_json" */}, - { - FxFunc: 0, - FnArg: int8(-1), - FbPure: uint8(1), - FzName: ts + 31005 /* "geopoly_svg" */}, - { - FxFunc: 0, - FnArg: int8(2), - FbPure: uint8(1), - FzName: ts + 30943 /* "geopoly_within" */}, - { - FxFunc: 0, - FnArg: int8(3), - FbPure: uint8(1), - FzName: ts + 31017 /* "geopoly_contains..." */}, - { - FxFunc: 0, - FnArg: int8(2), - FbPure: uint8(1), - FzName: ts + 30927 /* "geopoly_overlap" */}, - { - FxFunc: 0, - FnArg: int8(1), - FbPure: uint8(0), - FzName: ts + 31040 /* "geopoly_debug" */}, - { - FxFunc: 0, - FnArg: int8(1), - FbPure: uint8(1), - FzName: ts + 31054 /* "geopoly_bbox" */}, - { - FxFunc: 0, - FnArg: int8(7), - FbPure: uint8(1), - FzName: ts + 31067 /* "geopoly_xform" */}, - { - FxFunc: 0, - FnArg: int8(4), - FbPure: uint8(1), - FzName: ts + 31081 /* "geopoly_regular" */}, - { - FxFunc: 0, - FnArg: int8(1), - FbPure: uint8(1), - FzName: ts + 31097 /* "geopoly_ccw" */}, + {FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 30966 /* "geopoly_area" */}, + {FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 30979 /* "geopoly_blob" */}, + {FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 30992 /* "geopoly_json" */}, + {FxFunc: 0, FnArg: int8(-1), FbPure: uint8(1), FzName: ts + 31005 /* "geopoly_svg" */}, + {FxFunc: 0, FnArg: int8(2), FbPure: uint8(1), FzName: ts + 30943 /* "geopoly_within" */}, + {FxFunc: 0, FnArg: int8(3), FbPure: uint8(1), FzName: ts + 31017 /* "geopoly_contains..." */}, + {FxFunc: 0, FnArg: int8(2), FbPure: uint8(1), FzName: ts + 30927 /* "geopoly_overlap" */}, + {FxFunc: 0, FnArg: int8(1), FzName: ts + 31040 /* "geopoly_debug" */}, + {FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 31054 /* "geopoly_bbox" */}, + {FxFunc: 0, FnArg: int8(7), FbPure: uint8(1), FzName: ts + 31067 /* "geopoly_xform" */}, + {FxFunc: 0, FnArg: int8(4), FbPure: uint8(1), FzName: ts + 31081 /* "geopoly_regular" */}, + {FxFunc: 0, FnArg: int8(1), FbPure: uint8(1), FzName: ts + 31097 /* "geopoly_ccw" */}, } /* sqlite3.c:194197:5 */ var aAgg1 = [1]struct { FxStep uintptr FxFinal uintptr FzName uintptr }{ - { - FxStep: 0, - FxFinal: 0, - FzName: ts + 31109 /* "geopoly_group_bb..." */}, + {FxStep: 0, FxFinal: 0, FzName: ts + 31109 /* "geopoly_group_bb..." */}, } /* sqlite3.c:194215:5 */ //************* End of geopoly.c ******************************************** @@ -158374,31 +155659,31 @@ var aAgg1 = [1]struct { // virtual table module "rtree" and the debugging/analysis scalar // function "rtreenode". func Xsqlite3RtreeInit(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:194250:20: */ - var utf8 int32 = 1 + var utf8 int32 = SQLITE_UTF8 var rc int32 rc = Xsqlite3_create_function(tls, db, ts+31128 /* "rtreenode" */, 2, utf8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rtreenode})), uintptr(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_function(tls, db, ts+31138 /* "rtreedepth" */, 1, utf8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rtreedepth})), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_function(tls, db, ts+31149 /* "rtreecheck" */, -1, utf8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rtreecheck})), uintptr(0), uintptr(0)) } - if rc == 0 { - var c uintptr = uintptr(0) + if rc == SQLITE_OK { + var c uintptr = RTREE_COORD_REAL32 rc = Xsqlite3_create_module_v2(tls, db, ts+30872 /* "rtree" */, uintptr(unsafe.Pointer(&rtreeModule)), c, uintptr(0)) } - if rc == 0 { - var c uintptr = uintptr(1) + if rc == SQLITE_OK { + var c uintptr = RTREE_COORD_INT32 rc = Xsqlite3_create_module_v2(tls, db, ts+31160 /* "rtree_i32" */, uintptr(unsafe.Pointer(&rtreeModule)), c, uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3_geopoly_init(tls, db) } @@ -158454,7 +155739,7 @@ func geomCallback(tls *libc.TLS, ctx uintptr, nArg int32, aArg uintptr) { /* sql } else { var i int32 (*RtreeMatchArg)(unsafe.Pointer(pBlob)).FiSize = U32(nBlob) - (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb = *(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx + uintptr(0)*32)) + (*RtreeMatchArg)(unsafe.Pointer(pBlob)).Fcb = *(*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)) (*RtreeMatchArg)(unsafe.Pointer(pBlob)).FapSqlParam = ((pBlob + 56 /* &.aParam */) + uintptr(nArg)*8) (*RtreeMatchArg)(unsafe.Pointer(pBlob)).FnParam = nArg for i = 0; i < nArg; i++ { @@ -158480,13 +155765,13 @@ func Xsqlite3_rtree_geometry_callback(tls *libc.TLS, db uintptr, zGeom uintptr, // Allocate and populate the context object. pGeomCtx = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(RtreeGeomCallback{}))) if !(pGeomCtx != 0) { - return 7 + return SQLITE_NOMEM } (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxGeom = xGeom (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxQueryFunc = uintptr(0) (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxDestructor = uintptr(0) (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FpContext = pContext - return Xsqlite3_create_function_v2(tls, db, zGeom, -1, 5, + return Xsqlite3_create_function_v2(tls, db, zGeom, -1, SQLITE_ANY, pGeomCtx, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{geomCallback})), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{rtreeFreeCallback}))) @@ -158500,13 +155785,13 @@ func Xsqlite3_rtree_query_callback(tls *libc.TLS, db uintptr, zQueryFunc uintptr // Allocate and populate the context object. pGeomCtx = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(RtreeGeomCallback{}))) if !(pGeomCtx != 0) { - return 7 + return SQLITE_NOMEM } (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxGeom = uintptr(0) (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxQueryFunc = xQueryFunc (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FxDestructor = xDestructor (*RtreeGeomCallback)(unsafe.Pointer(pGeomCtx)).FpContext = pContext - return Xsqlite3_create_function_v2(tls, db, zQueryFunc, -1, 5, + return Xsqlite3_create_function_v2(tls, db, zQueryFunc, -1, SQLITE_ANY, pGeomCtx, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{geomCallback})), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{rtreeFreeCallback}))) @@ -159647,13 +156932,13 @@ func rbuDeltaApply(tls *libc.TLS, zSrc uintptr, lenSrc int32, zDelta uintptr, le var cnt uint32 var ofst uint32 cnt = rbuDeltaGetInt(tls, bp /* &zDelta */, bp+8 /* &lenDelta */) - switch int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zDelta */)) + uintptr(0)))) { + switch int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zDelta */))))) { case '@': { *(*uintptr)(unsafe.Pointer(bp /* zDelta */))++ *(*int32)(unsafe.Pointer(bp + 8 /* lenDelta */))-- ofst = rbuDeltaGetInt(tls, bp /* &zDelta */, bp+8 /* &lenDelta */) - if (*(*int32)(unsafe.Pointer(bp + 8 /* lenDelta */)) > 0) && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zDelta */)) + uintptr(0)))) != ',') { + if (*(*int32)(unsafe.Pointer(bp + 8 /* lenDelta */)) > 0) && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zDelta */))))) != ',') { // ERROR: copy command not terminated by ',' return -1 } @@ -159697,7 +156982,7 @@ func rbuDeltaApply(tls *libc.TLS, zSrc uintptr, lenSrc int32, zDelta uintptr, le { *(*uintptr)(unsafe.Pointer(bp /* zDelta */))++ *(*int32)(unsafe.Pointer(bp + 8 /* lenDelta */))-- - *(*int8)(unsafe.Pointer(zOut + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(zOut)) = int8(0) if total != limit { // ERROR: generated size does not match predicted size return -1 @@ -159751,10 +157036,10 @@ func rbuFossilDeltaFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr var nOut2 int32 var aOut uintptr - nOrig = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - aOrig = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) - nDelta = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) - aDelta = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) + nOrig = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) + aOrig = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) + nDelta = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) + aDelta = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) // Figure out the size of the output nOut = rbuDeltaOutputSize(tls, aDelta, nDelta) @@ -159790,7 +157075,7 @@ func prepareAndCollectError(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErrmsg defer tls.Free(8) var rc int32 = Xsqlite3_prepare_v2(tls, db, zSql, -1, ppStmt, uintptr(0)) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(pzErrmsg)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp, Xsqlite3_errmsg(tls, db))) *(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0) } @@ -159808,7 +157093,7 @@ func resetAndCollectError(tls *libc.TLS, pStmt uintptr, pzErrmsg uintptr) int32 defer tls.Free(8) var rc int32 = Xsqlite3_reset(tls, pStmt) - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(pzErrmsg)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp, Xsqlite3_errmsg(tls, Xsqlite3_db_handle(tls, pStmt)))) } return rc @@ -159831,7 +157116,7 @@ func prepareFreeAndCollectError(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErr var rc int32 if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM *(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0) } else { rc = prepareAndCollectError(tls, db, ppStmt, pzErrmsg, zSql) @@ -159906,7 +157191,7 @@ func rbuObjIterFinalize(tls *libc.TLS, pIter uintptr) { /* sqlite3.c:196691:13: // error code is returned. func rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3.c:196707:12: */ var rc int32 = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc - if rc == 0 { + if rc == SQLITE_OK { // Free any SQLite statements used while processing the previous object rbuObjIterClearStatements(tls, pIter) @@ -159916,21 +157201,21 @@ func rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3. ts+31191 /* "DROP TRIGGER IF ..." */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } - if rc == 0 { + if rc == SQLITE_OK { if (*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 { rbuObjIterFreeCols(tls, pIter) (*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = 0 rc = Xsqlite3_step(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter) - if rc != 100 { + if rc != SQLITE_ROW { rc = resetAndCollectError(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, (p + 64 /* &.zErrmsg */)) (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl = uintptr(0) } else { (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl = Xsqlite3_column_text(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, 0) (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl = Xsqlite3_column_text(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpTblIter, 1) if ((*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl != 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0) { - rc = 0 + rc = SQLITE_OK } else { - rc = 7 + rc = SQLITE_NOMEM } } } else { @@ -159938,9 +157223,9 @@ func rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3. var pIdx uintptr = (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter rc = Xsqlite3_bind_text(tls, pIdx, 1, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, -1, uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_step(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter) - if rc != 100 { + if rc != SQLITE_ROW { rc = resetAndCollectError(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, (p + 64 /* &.zErrmsg */)) (*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup = 1 (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx = uintptr(0) @@ -159949,9 +157234,9 @@ func rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3. (*RbuObjIter)(unsafe.Pointer(pIter)).FiTnum = Xsqlite3_column_int(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, 1) (*RbuObjIter)(unsafe.Pointer(pIter)).FbUnique = Xsqlite3_column_int(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpIdxIter, 2) if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx != 0 { - rc = 0 + rc = SQLITE_OK } else { - rc = 7 + rc = SQLITE_NOMEM } } } @@ -159959,7 +157244,7 @@ func rbuObjIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3. } } - if rc != 0 { + if rc != SQLITE_OK { rbuObjIterFinalize(tls, pIter) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc } @@ -159989,11 +157274,11 @@ func rbuTargetNameFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { var p uintptr = Xsqlite3_user_data(tls, pCtx) var zIn uintptr - zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zIn = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) if zIn != 0 { if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { - if (argc == 1) || (0 == Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) { + if (argc == 1) || (0 == Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) { Xsqlite3_result_text(tls, pCtx, zIn, -1, uintptr(0)) } } else { @@ -160032,7 +157317,7 @@ func rbuObjIterFirst(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3 return ts + 800 /* "" */ }()))) - if rc == 0 { + if rc == SQLITE_OK { rc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (pIter + 8 /* &.pIdxIter */), (p + 64 /* &.zErrmsg */), ts+31553 /* "SELECT name, roo..." */) @@ -160056,9 +157341,9 @@ func rbuMPrintf(tls *libc.TLS, p uintptr, zFmt uintptr, va uintptr) uintptr { /* _ = ap ap = va zSql = Xsqlite3_vmprintf(tls, zFmt, ap) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { if zSql == uintptr(0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } } else { Xsqlite3_free(tls, zSql) @@ -160082,9 +157367,9 @@ func rbuMPrintfExec(tls *libc.TLS, p uintptr, db uintptr, zFmt uintptr, va uintp var zSql uintptr ap = va zSql = Xsqlite3_vmprintf(tls, zFmt, ap) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { if zSql == uintptr(0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } else { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } @@ -160104,11 +157389,11 @@ func rbuMPrintfExec(tls *libc.TLS, p uintptr, db uintptr, zFmt uintptr, va uintp // error code. func rbuMalloc(tls *libc.TLS, p uintptr, nByte Sqlite3_int64) uintptr { /* sqlite3.c:196910:13: */ var pRet uintptr = uintptr(0) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { pRet = Xsqlite3_malloc64(tls, uint64(nByte)) if pRet == uintptr(0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } else { libc.Xmemset(tls, pRet, 0, uint64(nByte)) } @@ -160145,14 +157430,14 @@ func rbuAllocateIterArrays(tls *libc.TLS, p uintptr, pIter uintptr, nCol int32) func rbuStrndup(tls *libc.TLS, zStr uintptr, pRc uintptr) uintptr { /* sqlite3.c:196955:13: */ var zRet uintptr = uintptr(0) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { if zStr != 0 { var nCopy Size_t = (libc.Xstrlen(tls, zStr) + uint64(1)) zRet = Xsqlite3_malloc64(tls, uint64(nCopy)) if zRet != 0 { libc.Xmemcpy(tls, zRet, zStr, nCopy) } else { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } } @@ -160171,7 +157456,7 @@ func rbuFinalize(tls *libc.TLS, p uintptr, pStmt uintptr) { /* sqlite3.c:196980: var db uintptr = Xsqlite3_db_handle(tls, pStmt) var rc int32 = Xsqlite3_finalize(tls, pStmt) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (rc != 0) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (rc != SQLITE_OK) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp, Xsqlite3_errmsg(tls, db))) } @@ -160230,30 +157515,30 @@ func rbuTableType(tls *libc.TLS, p uintptr, zTab uintptr, peType uintptr, piTnum var i uint32 *(*[4]uintptr)(unsafe.Pointer(bp + 32 /* aStmt */)) = [4]uintptr{uintptr(0), uintptr(0), uintptr(0), uintptr(0)} - *(*int32)(unsafe.Pointer(peType)) = 0 + *(*int32)(unsafe.Pointer(peType)) = RBU_PK_NOTABLE *(*int32)(unsafe.Pointer(piPk)) = 0 - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + uintptr(0)*8), (p + 64 /* &.zErrmsg */), + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */), (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+31678 /* "SELECT (sql LIKE..." */, libc.VaList(bp, zTab))) - if !(((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0) || (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(0)*8))) != 100)) { + if !(((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK) || (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */))) != SQLITE_ROW)) { goto __1 } // Either an error, or no such table. goto rbuTableType_end __1: ; - if !(Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(0)*8)), 0) != 0) { + if !(Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */)), 0) != 0) { goto __2 } - *(*int32)(unsafe.Pointer(peType)) = 5 // virtual table + *(*int32)(unsafe.Pointer(peType)) = RBU_PK_VTAB // virtual table goto rbuTableType_end __2: ; - *(*int32)(unsafe.Pointer(piTnum)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(0)*8)), 1) + *(*int32)(unsafe.Pointer(piTnum)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */)), 1) - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + uintptr(1)*8), (p + 64 /* &.zErrmsg */), + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + 1*8), (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+31759 /* "PRAGMA index_lis..." */, libc.VaList(bp+8, zTab))) if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0) { goto __3 @@ -160262,28 +157547,28 @@ __2: __3: ; __4: - if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(1)*8))) == 100) { + if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 1*8))) == SQLITE_ROW) { goto __5 } - zOrig = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(1)*8)), 3) - zIdx = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(1)*8)), 1) - if !(((zOrig != 0) && (zIdx != 0)) && (int32(*(*U8)(unsafe.Pointer(zOrig + uintptr(0)))) == 'p')) { + zOrig = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 1*8)), 3) + zIdx = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 1*8)), 1) + if !(((zOrig != 0) && (zIdx != 0)) && (int32(*(*U8)(unsafe.Pointer(zOrig))) == 'p')) { goto __6 } - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + uintptr(2)*8), (p + 64 /* &.zErrmsg */), + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + 2*8), (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+31780 /* "SELECT rootpage ..." */, libc.VaList(bp+16, zIdx))) - if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) { + if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) { goto __7 } - if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(2)*8))) == 100) { + if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 2*8))) == SQLITE_ROW) { goto __8 } - *(*int32)(unsafe.Pointer(piPk)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(2)*8)), 0) - *(*int32)(unsafe.Pointer(peType)) = 3 + *(*int32)(unsafe.Pointer(piPk)) = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 2*8)), 0) + *(*int32)(unsafe.Pointer(peType)) = RBU_PK_EXTERNAL goto __9 __8: - *(*int32)(unsafe.Pointer(peType)) = 4 + *(*int32)(unsafe.Pointer(peType)) = RBU_PK_WITHOUT_ROWID __9: ; __7: @@ -160295,26 +157580,26 @@ __6: __5: ; - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + uintptr(3)*8), (p + 64 /* &.zErrmsg */), + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (bp + 32 /* &aStmt */ + 3*8), (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+31831 /* "PRAGMA table_inf..." */, libc.VaList(bp+24, zTab))) - if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) { + if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) { goto __10 } __11: - if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(3)*8))) == 100) { + if !(Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 3*8))) == SQLITE_ROW) { goto __12 } - if !(Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + uintptr(3)*8)), 5) > 0) { + if !(Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* &aStmt[0] */ + 3*8)), 5) > 0) { goto __13 } - *(*int32)(unsafe.Pointer(peType)) = 2 // explicit IPK column + *(*int32)(unsafe.Pointer(peType)) = RBU_PK_IPK // explicit IPK column goto rbuTableType_end __13: ; goto __11 __12: ; - *(*int32)(unsafe.Pointer(peType)) = 1 + *(*int32)(unsafe.Pointer(peType)) = RBU_PK_NONE __10: ; @@ -160331,6 +157616,7 @@ __15: goto __14 goto __16 __16: + } // This is a helper function for rbuObjIterCacheTableInfo(). It populates @@ -160342,14 +157628,14 @@ func rbuObjIterCacheIndexedCols(tls *libc.TLS, p uintptr, pIter uintptr) { /* sq *(*uintptr)(unsafe.Pointer(bp + 16 /* pList */)) = uintptr(0) var bIndex int32 = 0 - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { libc.Xmemcpy(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed, (*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk, (uint64(unsafe.Sizeof(U8(0))) * uint64((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol))) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+16 /* &pList */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+31852 /* "PRAGMA main.inde..." */, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) } (*RbuObjIter)(unsafe.Pointer(pIter)).FnIndex = 0 - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pList */)))) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pList */)))) { var zIdx uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pList */)), 1) var bPartial int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pList */)), 4) *(*uintptr)(unsafe.Pointer(bp + 24 /* pXInfo */)) = uintptr(0) @@ -160361,7 +157647,7 @@ func rbuObjIterCacheIndexedCols(tls *libc.TLS, p uintptr, pIter uintptr) { /* sq } (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+24 /* &pXInfo */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+31880 /* "PRAGMA main.inde..." */, libc.VaList(bp+8, zIdx))) - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pXInfo */)))) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pXInfo */)))) { var iCid int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pXInfo */)), 1) if iCid >= 0 { *(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed + uintptr(iCid))) = U8(1) @@ -160375,7 +157661,7 @@ func rbuObjIterCacheIndexedCols(tls *libc.TLS, p uintptr, pIter uintptr) { /* sq (*RbuObjIter)(unsafe.Pointer(pIter)).FnIndex++ } - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 4 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_WITHOUT_ROWID { // "PRAGMA index_list" includes the main PK b-tree (*RbuObjIter)(unsafe.Pointer(pIter)).FnIndex-- } @@ -160408,8 +157694,8 @@ func rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) int32 { / // Figure out the type of table this step will deal with. rbuTableType(tls, p, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, (pIter + 72 /* &.eType */), bp+56 /* &iTnum */, (pIter + 108 /* &.iPkTnum */)) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NOTABLE) { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+20702 /* "no such table: %..." */, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl)) } if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0 { @@ -160424,11 +157710,11 @@ func rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) int32 { / // "rbu_". (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp+64 /* &pStmt */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+31909 /* "SELECT * FROM '%..." */, libc.VaList(bp+8, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl))) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { nCol = Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */))) rbuAllocateIterArrays(tls, p, pIter, nCol) } - for i = 0; ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (i < nCol); i++ { + for i = 0; ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (i < nCol); i++ { var zName uintptr = Xsqlite3_column_name(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)), i) if Xsqlite3_strnicmp(tls, ts+31928 /* "rbu_" */, zName, 4) != 0 { var zCopy uintptr = rbuStrndup(tls, zName, (p + 56 /* &.rc */)) @@ -160441,10 +157727,10 @@ func rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) int32 { / Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */))) *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)) = uintptr(0) - if (((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && + if (((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((libc.Bool32((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) == 0)) && - (bRbuRowid != (libc.Bool32(((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 5) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1)))) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + (bRbuRowid != (libc.Bool32(((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE)))) { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+31943 /* "table %q %s rbu_..." */, libc.VaList(bp+16, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, func() uintptr { @@ -160458,11 +157744,11 @@ func rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) int32 { / // Check that all non-HIDDEN columns in the destination table are also // present in the input table. Populate the abTblPk[], azTblType[] and // aiTblOrder[] arrays at the same time. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+64 /* &pStmt */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+31994 /* "PRAGMA table_inf..." */, libc.VaList(bp+32, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) } - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)))) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)))) { var zName uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)), 1) if zName == uintptr(0) { break @@ -160473,7 +157759,7 @@ func rbuObjIterCacheTableInfo(tls *libc.TLS, p uintptr, pIter uintptr) int32 { / } } if i == (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+32016, /* "column missing f..." */ libc.VaList(bp+40, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, zName)) } else { @@ -160586,7 +157872,7 @@ func rbuVacuumTableStart(tls *libc.TLS, p uintptr, pIter uintptr, bRowid int32, (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+72 /* &pMax */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+32065 /* "SELECT max(_rowi..." */, libc.VaList(bp, zWrite, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pMax */)))) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pMax */)))) { var iMax Sqlite3_int64 = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pMax */)), 0) zRet = rbuMPrintf(tls, p, ts+32097 /* " WHERE _rowid_ >..." */, libc.VaList(bp+16, iMax)) } @@ -160596,12 +157882,12 @@ func rbuVacuumTableStart(tls *libc.TLS, p uintptr, pIter uintptr, bRowid int32, var zSelect uintptr = rbuObjIterGetPkList(tls, p, pIter, ts+32126 /* "quote(" */, ts+32133 /* "||','||" */, ts+6671 /* ")" */) var zList uintptr = rbuObjIterGetPkList(tls, p, pIter, ts+800 /* "" */, ts+15696 /* ", " */, ts+800 /* "" */) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+72 /* &pMax */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+32141, /* "SELECT %s FROM \"..." */ libc.VaList(bp+24, zSelect, zWrite, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zOrder))) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pMax */)))) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pMax */)))) { var zVal uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pMax */)), 0) zRet = rbuMPrintf(tls, p, ts+32183 /* " WHERE (%s) > (%..." */, libc.VaList(bp+56, zList, zVal)) } @@ -160668,7 +157954,7 @@ func XrbuVacuumIndexStart(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { /* (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+176 /* &pXInfo */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+31880 /* "PRAGMA main.inde..." */, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx))) __1: - if !(((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */))))) { + if !(((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */))))) { goto __2 } iCid = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */)), 1) @@ -160684,7 +157970,7 @@ __3: if !(iCid < 0) { goto __4 } - if !((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 2) { + if !((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_IPK) { goto __6 } i = 0 @@ -160731,7 +158017,7 @@ __2: __11: ; - if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) { + if !((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) { goto __12 } *(*uintptr)(unsafe.Pointer(bp + 184 /* pSel */)) = uintptr(0) @@ -160739,7 +158025,7 @@ __11: (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+184 /* &pSel */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+32295, /* "SELECT %s FROM \"..." */ libc.VaList(bp+112, zSelect, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zOrder))) - if !(((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 184 /* pSel */))))) { + if !(((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 184 /* pSel */))))) { goto __13 } zSep = ts + 800 /* "" */ @@ -160749,7 +158035,7 @@ __14: goto __16 } zQuoted = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 184 /* pSel */)), iCol) - if !(int32(*(*int8)(unsafe.Pointer(zQuoted + uintptr(0)))) == 'N') { + if !(int32(*(*int8)(unsafe.Pointer(zQuoted))) == 'N') { goto __17 } bFailed = 1 @@ -160823,13 +158109,13 @@ func rbuObjIterGetIndexCols(tls *libc.TLS, p uintptr, pIter uintptr, pzImposterC var zAnd uintptr = ts + 800 /* "" */ // Set to " AND " later on *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */)) = uintptr(0) // PRAGMA index_xinfo = ? - if rc == 0 { + if rc == SQLITE_OK { rc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+200 /* &pXInfo */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+31880 /* "PRAGMA main.inde..." */, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx))) } - for (rc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */)))) { + for (rc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */)))) { var iCid int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */)), 1) var bDesc int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */)), 3) var zCollate uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */)), 4) @@ -160845,7 +158131,7 @@ func rbuObjIterGetIndexCols(tls *libc.TLS, p uintptr, pIter uintptr, pzImposterC if iCid < 0 { // An integer primary key. If the table has an explicit IPK, use // its name. Otherwise, use "rbu_rowid". - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 2 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_IPK { var i int32 for i = 0; int32(*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0; i++ { } @@ -160879,7 +158165,7 @@ func rbuObjIterGetIndexCols(tls *libc.TLS, p uintptr, pIter uintptr, pzImposterC zWhere = Xsqlite3_mprintf(tls, ts+32458 /* "%z%s\"rbu_imp_%d%..." */, libc.VaList(bp+168, zWhere, zAnd, nBind, zCol)) if (((zRet == uintptr(0)) || (zImpPK == uintptr(0))) || (zImpCols == uintptr(0))) || (zWhere == uintptr(0)) { - rc = 7 + rc = SQLITE_NOMEM } zCom = ts + 15696 /* ", " */ zAnd = ts + 23050 /* " AND " */ @@ -160887,11 +158173,11 @@ func rbuObjIterGetIndexCols(tls *libc.TLS, p uintptr, pIter uintptr, pzImposterC } rc2 = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 200 /* pXInfo */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_free(tls, zRet) Xsqlite3_free(tls, zImpCols) Xsqlite3_free(tls, zImpPK) @@ -160924,7 +158210,7 @@ func rbuObjIterGetOldlist(tls *libc.TLS, p uintptr, pIter uintptr, zObj uintptr) defer tls.Free(64) var zList uintptr = uintptr(0) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0) { var zS uintptr = ts + 800 /* "" */ var i int32 for i = 0; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; i++ { @@ -160936,13 +158222,13 @@ func rbuObjIterGetOldlist(tls *libc.TLS, p uintptr, pIter uintptr, zObj uintptr) } zS = ts + 15696 /* ", " */ if zList == uintptr(0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM break } } // For a table with implicit rowids, append "old._rowid_" to the list. - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE) { zList = rbuMPrintf(tls, p, ts+32503 /* "%z, %s._rowid_" */, libc.VaList(bp+48, zList, zObj)) } } @@ -160962,9 +158248,9 @@ func rbuObjIterGetWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { /* sq defer tls.Free(80) var zList uintptr = uintptr(0) - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 5) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE) { zList = rbuMPrintf(tls, p, ts+32518 /* "_rowid_ = ?%d" */, libc.VaList(bp, ((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol+1))) - } else if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3 { + } else if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL { var zSep uintptr = ts + 800 /* "" */ var i int32 for i = 0; i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol; i++ { @@ -160996,7 +158282,7 @@ func rbuObjIterGetWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { /* sq // stored in the (p->nCol+1)'th column. Set the error code and error message // of the RBU handle to something reflecting this. func rbuBadControlError(tls *libc.TLS, p uintptr) { /* sqlite3.c:197716:13: */ - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+32607 /* "invalid rbu_cont..." */, 0) } @@ -161020,7 +158306,7 @@ func rbuObjIterGetSetlist(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr defer tls.Free(112) var zList uintptr = uintptr(0) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var i int32 if int32(libc.Xstrlen(tls, zMask)) != (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol { @@ -161097,14 +158383,14 @@ func rbuWithoutRowidPK(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { /* sql var z uintptr = uintptr(0) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var zSep uintptr = ts + 32700 /* "PRIMARY KEY(" */ *(*uintptr)(unsafe.Pointer(bp + 56 /* pXList */)) = uintptr(0) // PRAGMA index_list = (pIter->zTbl) *(*uintptr)(unsafe.Pointer(bp + 64 /* pXInfo */)) = uintptr(0) // PRAGMA index_xinfo = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+56 /* &pXList */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+31852 /* "PRAGMA main.inde..." */, libc.VaList(bp, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl))) - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pXList */)))) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pXList */)))) { var zOrig uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pXList */)), 3) if (zOrig != 0) && (libc.Xstrcmp(tls, zOrig, ts+17201 /* "pk" */) == 0) { var zIdx uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pXList */)), 1) @@ -161117,7 +158403,7 @@ func rbuWithoutRowidPK(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { /* sql } rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 56 /* pXList */))) - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pXInfo */)))) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pXInfo */)))) { if Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pXInfo */)), 5) != 0 { // int iCid = sqlite3_column_int(pXInfo, 0); var zCol uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pXInfo */)), 2) @@ -161158,7 +158444,7 @@ func rbuCreateImposterTable2(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlit bp := tls.Alloc(184) defer tls.Free(184) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) { var tnum int32 = (*RbuObjIter)(unsafe.Pointer(pIter)).FiPkTnum // Root page of PK index *(*uintptr)(unsafe.Pointer(bp + 168 /* pQuery */)) = uintptr(0) // SELECT name ... WHERE rootpage = $tnum var zIdx uintptr = uintptr(0) // Name of PK index @@ -161172,9 +158458,9 @@ func rbuCreateImposterTable2(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlit // zIdx to point to a nul-terminated string containing this name. (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+168 /* &pQuery */, (p + 64 /* &.zErrmsg */), ts+32728 /* "SELECT name FROM..." */) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { Xsqlite3_bind_int(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pQuery */)), 1, tnum) - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pQuery */))) { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pQuery */))) { zIdx = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pQuery */)), 0) } } @@ -161184,7 +158470,7 @@ func rbuCreateImposterTable2(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlit } rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 168 /* pQuery */))) - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */)))) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */)))) { var bKey int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */)), 5) if bKey != 0 { var iCid int32 = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */)), 1) @@ -161204,11 +158490,11 @@ func rbuCreateImposterTable2(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlit zCols = rbuMPrintf(tls, p, ts+32810 /* "%z, id INTEGER" */, libc.VaList(bp+80, zCols)) rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 176 /* pXInfo */))) - Xsqlite3_test_control(tls, 25, libc.VaList(bp+88, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 1, tnum)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+88, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 1, tnum)) rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+32825, /* "CREATE TABLE rbu..." */ libc.VaList(bp+120, zCols, zPk)) - Xsqlite3_test_control(tls, 25, libc.VaList(bp+136, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 0, 0)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+136, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 0, 0)) } } @@ -161234,14 +158520,14 @@ func rbuCreateImposterTable(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite bp := tls.Alloc(200) defer tls.Free(200) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType != 5) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType != RBU_PK_VTAB) { var tnum int32 = (*RbuObjIter)(unsafe.Pointer(pIter)).FiTnum var zComma uintptr = ts + 800 /* "" */ var zSql uintptr = uintptr(0) var iCol int32 - Xsqlite3_test_control(tls, 25, libc.VaList(bp, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 0, 1)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 0, 1)) - for iCol = 0; ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (iCol < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol); iCol++ { + for iCol = 0; ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (iCol < (*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol); iCol++ { var zPk uintptr = ts + 800 /* "" */ var zCol uintptr = *(*uintptr)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FazTblCol + uintptr(iCol)*8)) *(*uintptr)(unsafe.Pointer(bp + 192 /* zColl */)) = uintptr(0) @@ -161249,7 +158535,7 @@ func rbuCreateImposterTable(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_table_column_metadata(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zCol, uintptr(0), bp+192 /* &zColl */, uintptr(0), uintptr(0), uintptr(0)) - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 2) && (*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(iCol))) != 0) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_IPK) && (*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(iCol))) != 0) { // If the target table column is an "INTEGER PRIMARY KEY", add // "PRIMARY KEY" to the imposter table column declaration. zPk = ts + 32887 /* "PRIMARY KEY " */ @@ -161265,23 +158551,23 @@ func rbuCreateImposterTable(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite zComma = ts + 15696 /* ", " */ } - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 4 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_WITHOUT_ROWID { var zPk uintptr = rbuWithoutRowidPK(tls, p, pIter) if zPk != 0 { zSql = rbuMPrintf(tls, p, ts+32937 /* "%z, %z" */, libc.VaList(bp+88, zSql, zPk)) } } - Xsqlite3_test_control(tls, 25, libc.VaList(bp+104, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 1, tnum)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+104, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 1, tnum)) rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+32944, /* "CREATE TABLE \"rb..." */ libc.VaList(bp+136, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, zSql, func() uintptr { - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 4 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_WITHOUT_ROWID { return ts + 32976 /* " WITHOUT ROWID" */ } return ts + 800 /* "" */ }())) - Xsqlite3_test_control(tls, 25, libc.VaList(bp+160, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 0, 0)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+160, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 0, 0)) } } @@ -161298,7 +158584,7 @@ func rbuObjIterPrepareTmpInsert(tls *libc.TLS, p uintptr, pIter uintptr, zCollis bp := tls.Alloc(40) defer tls.Free(40) - var bRbuRowid int32 = (libc.Bool32(((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1))) + var bRbuRowid int32 = (libc.Bool32(((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE))) var zBind uintptr = rbuObjIterGetBindlist(tls, p, (((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol + 1) + bRbuRowid)) if zBind != 0 { @@ -161311,22 +158597,22 @@ func rbuObjIterPrepareTmpInsert(tls *libc.TLS, p uintptr, pIter uintptr, zCollis func rbuTmpInsertFunc(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) { /* sqlite3.c:198027:13: */ var p uintptr = Xsqlite3_user_data(tls, pCtx) - var rc int32 = 0 + var rc int32 = SQLITE_OK var i int32 - if Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) != 0 { + if Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal))) != 0 { *(*I64)(unsafe.Pointer(p + 304 /* &.nPhaseOneStep */)) += (I64((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex)) } - for i = 0; (rc == 0) && (i < nVal); i++ { + for i = 0; (rc == SQLITE_OK) && (i < nVal); i++ { rc = Xsqlite3_bind_value(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpTmpInsert, (i + 1), *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8))) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_step(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpTmpInsert) rc = Xsqlite3_reset(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpTmpInsert) } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_result_error_code(tls, pCtx, rc) } } @@ -161339,14 +158625,14 @@ func rbuObjIterGetIndexWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc var zRet uintptr = uintptr(0) - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp /* &pStmt */, (p + 64 /* &.zErrmsg */), ts+33048 /* "SELECT trim(sql)..." */) } - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { var rc2 int32 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 1, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx, -1, uintptr(0)) - if (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)))) { + if (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)))) { var zSql uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 0) if zSql != 0 { (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdxSql = libc.AssignUintptr(&zSql, rbuStrndup(tls, zSql, bp+8 /* &rc */)) @@ -161364,7 +158650,7 @@ func rbuObjIterGetIndexWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { var aIdxCol uintptr = Xsqlite3_realloc(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol, (int32((uint64(nIdxAlloc + 16)) * uint64(unsafe.Sizeof(RbuSpan{}))))) if aIdxCol == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_NOMEM break } (*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol = aIdxCol @@ -161374,7 +158660,7 @@ func rbuObjIterGetIndexWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { if int32(c) == '(' { if nParen == 0 { - (*RbuSpan)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol + uintptr(0)*16)).FzSpan = (zSql + uintptr((i + 1))) + (*RbuSpan)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol)).FzSpan = (zSql + uintptr((i + 1))) } nParen++ } else if int32(c) == ')' { @@ -161427,7 +158713,7 @@ func rbuObjIterGetIndexWhere(tls *libc.TLS, p uintptr, pIter uintptr) uintptr { } rc2 = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = rc2 } } @@ -161443,7 +158729,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 bp := tls.Alloc(628) defer tls.Free(628) - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect == uintptr(0)) && (rbuObjIterCacheTableInfo(tls, p, pIter) == 0) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect == uintptr(0)) && (rbuObjIterCacheTableInfo(tls, p, pIter) == SQLITE_OK) { var tnum int32 = (*RbuObjIter)(unsafe.Pointer(pIter)).FiTnum var zCollist uintptr = uintptr(0) // List of indexed columns var pz uintptr = (p + 64 /* &.zErrmsg */) @@ -161453,7 +158739,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 if nOffset != 0 { zLimit = Xsqlite3_mprintf(tls, ts+33114 /* " LIMIT -1 OFFSET..." */, libc.VaList(bp, nOffset)) if !(zLimit != 0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } } @@ -161472,30 +158758,30 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 zBind = rbuObjIterGetBindlist(tls, p, *(*int32)(unsafe.Pointer(bp + 624 /* nBind */))) // Create the imposter table used to write to this index. - Xsqlite3_test_control(tls, 25, libc.VaList(bp+8, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 0, 1)) - Xsqlite3_test_control(tls, 25, libc.VaList(bp+40, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 1, tnum)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+8, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 0, 1)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+40, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 1, tnum)) rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+33134, /* "CREATE TABLE \"rb..." */ libc.VaList(bp+72, zTbl, *(*uintptr)(unsafe.Pointer(bp + 600 /* zImposterCols */)), *(*uintptr)(unsafe.Pointer(bp + 608 /* zImposterPK */)))) - Xsqlite3_test_control(tls, 25, libc.VaList(bp+96, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 0, 0)) + Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+96, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 0, 0)) // Create the statement to insert index entries (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol = *(*int32)(unsafe.Pointer(bp + 624 /* nBind */)) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (pIter + 136 /* &.pInsert */), (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+33199 /* "INSERT INTO \"rbu..." */, libc.VaList(bp+128, zTbl, zBind))) } // And to delete index entries - if ((libc.Bool32((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) { + if ((libc.Bool32((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (pIter + 144 /* &.pDelete */), (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+33235 /* "DELETE FROM \"rbu..." */, libc.VaList(bp+144, zTbl, *(*uintptr)(unsafe.Pointer(bp + 616 /* zWhere */))))) } // Create the SELECT statement to read keys in sorted order - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var zSql uintptr if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { var zStart uintptr = uintptr(0) @@ -161525,7 +158811,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 }(), zStart, zCollist, zLimit)) Xsqlite3_free(tls, zStart) - } else if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1) { + } else if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE) { zSql = Xsqlite3_mprintf(tls, ts+33340, /* "SELECT %s, rbu_c..." */ libc.VaList(bp+216, zCollist, p+48 /* &.zStateDb */, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, @@ -161545,7 +158831,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 }(), zCollist, zLimit)) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, (pIter + 128 /* &.pSelect */), pz, zSql) } else { Xsqlite3_free(tls, zSql) @@ -161558,9 +158844,9 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 Xsqlite3_free(tls, zBind) Xsqlite3_free(tls, zPart) } else { - var bRbuRowid int32 = (libc.Bool32((((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 5) || - ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1)) || - (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))))) + var bRbuRowid int32 = (libc.Bool32((((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB) || + ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE)) || + (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))))) var zTbl uintptr = (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl // Table this step applies to var zWrite uintptr // Imposter table name @@ -161576,14 +158862,14 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 rbuCreateImposterTable(tls, p, pIter) rbuCreateImposterTable2(tls, p, pIter) zWrite = func() uintptr { - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 5 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB { return ts + 800 /* "" */ } return ts + 33560 /* "rbu_imp_" */ }() // Create the INSERT statement to write to the target PK b-tree - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (pIter + 136 /* &.pInsert */), pz, Xsqlite3_mprintf(tls, ts+33569, /* "INSERT INTO \"%s%..." */ @@ -161598,7 +158884,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 // Create the DELETE statement to write to the target PK b-tree. // Because it only performs INSERT operations, this is not required for // an rbu vacuum handle. - if ((libc.Bool32((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) { + if ((libc.Bool32((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, (pIter + 144 /* &.pDelete */), pz, Xsqlite3_mprintf(tls, ts+33615 /* "DELETE FROM \"%s%..." */, libc.VaList(bp+384, zWrite, zTbl, zWhere))) @@ -161606,7 +158892,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 if ((libc.Bool32((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FabIndexed != 0) { var zRbuRowid uintptr = ts + 800 /* "" */ - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE) { zRbuRowid = ts + 33643 /* ", rbu_rowid" */ } @@ -161614,7 +158900,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+33655 /* "CREATE TABLE IF ..." */, libc.VaList(bp+408, p+48 /* &.zStateDb */, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, func() uintptr { - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL { return ts + 33731 /* ", 0 AS rbu_rowid" */ } return ts + 800 /* "" */ @@ -161627,7 +158913,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 zWrite, zTbl, zOldlist, zWrite, zTbl, zNewlist)) - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE) { rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+34047, /* "CREATE TEMP TRIG..." */ @@ -161638,7 +158924,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 } // Create the SELECT statement to read keys from data_xxx - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var zRbuRowid uintptr = ts + 800 /* "" */ var zStart uintptr = uintptr(0) var zOrder uintptr = uintptr(0) @@ -161665,7 +158951,7 @@ func rbuObjIterPrepareAll(tls *libc.TLS, p uintptr, pIter uintptr, nOffset int32 } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, (pIter + 128 /* &.pSelect */), pz, Xsqlite3_mprintf(tls, ts+34167, /* "SELECT %s,%s rbu..." */ @@ -161736,12 +159022,12 @@ func rbuGetUpdateStmt(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr, pp (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext = (*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate (*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = pUp *(*uintptr)(unsafe.Pointer(ppStmt)) = (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate - return 0 + return SQLITE_OK } nUp++ } - if nUp >= 16 { + if nUp >= SQLITE_RBU_UPDATE_CACHESIZE { for pp = (pIter + 184 /* &.pRbuUpdate */); *(*uintptr)(unsafe.Pointer(pp)) != pUp; pp = (*(*uintptr)(unsafe.Pointer(pp)) + 16 /* &.pNext */) { } *(*uintptr)(unsafe.Pointer(pp)) = uintptr(0) @@ -161756,7 +159042,7 @@ func rbuGetUpdateStmt(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr, pp var zSet uintptr = rbuObjIterGetSetlist(tls, p, pIter, zMask) var zUpdate uintptr = uintptr(0) - (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask = (pUp + uintptr(1)*24) + (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask = (pUp + 1*24) libc.Xmemcpy(tls, (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FzMask, zMask, uint64((*RbuObjIter)(unsafe.Pointer(pIter)).FnTblCol)) (*RbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext = (*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate (*RbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = pUp @@ -161764,7 +159050,7 @@ func rbuGetUpdateStmt(tls *libc.TLS, p uintptr, pIter uintptr, zMask uintptr, pp if zSet != 0 { var zPrefix uintptr = ts + 800 /* "" */ - if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType != 5 { + if (*RbuObjIter)(unsafe.Pointer(pIter)).FeType != RBU_PK_VTAB { zPrefix = ts + 33560 /* "rbu_imp_" */ } zUpdate = Xsqlite3_mprintf(tls, ts+34221, /* "UPDATE \"%s%w\" SE..." */ @@ -161785,8 +159071,8 @@ func rbuOpenDbhandle(tls *libc.TLS, p uintptr, zName uintptr, bUseVfs int32) uin defer tls.Free(16) *(*uintptr)(unsafe.Pointer(bp + 8 /* db */)) = uintptr(0) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - var flags int32 = ((0x00000002 | 0x00000004) | 0x00000040) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var flags int32 = ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_URI) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_open_v2(tls, zName, bp+8 /* &db */, flags, func() uintptr { if bUseVfs != 0 { return (*Sqlite3rbu)(unsafe.Pointer(p)).FzVfsName @@ -161836,60 +159122,60 @@ func rbuLoadState(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:198531:17: */ *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp+8 /* &pStmt */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+34251 /* "SELECT k, v FROM..." */, libc.VaList(bp, p+48 /* &.zStateDb */))) - for (*(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)))) { + for (*(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)))) { switch Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 0) { - case 1: + case RBU_STATE_STAGE: (*RbuState)(unsafe.Pointer(pRet)).FeStage = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) - if (((*RbuState)(unsafe.Pointer(pRet)).FeStage != 1) && - ((*RbuState)(unsafe.Pointer(pRet)).FeStage != 2)) && - ((*RbuState)(unsafe.Pointer(pRet)).FeStage != 4) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 11 + if (((*RbuState)(unsafe.Pointer(pRet)).FeStage != RBU_STAGE_OAL) && + ((*RbuState)(unsafe.Pointer(pRet)).FeStage != RBU_STAGE_MOVE)) && + ((*RbuState)(unsafe.Pointer(pRet)).FeStage != RBU_STAGE_CKPT) { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT } break - case 2: + case RBU_STATE_TBL: (*RbuState)(unsafe.Pointer(pRet)).FzTbl = rbuStrndup(tls, Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1), bp+16 /* &rc */) break - case 3: + case RBU_STATE_IDX: (*RbuState)(unsafe.Pointer(pRet)).FzIdx = rbuStrndup(tls, Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1), bp+16 /* &rc */) break - case 4: + case RBU_STATE_ROW: (*RbuState)(unsafe.Pointer(pRet)).FnRow = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) break - case 5: + case RBU_STATE_PROGRESS: (*RbuState)(unsafe.Pointer(pRet)).FnProgress = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) break - case 6: + case RBU_STATE_CKPT: (*RbuState)(unsafe.Pointer(pRet)).FiWalCksum = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) break - case 7: + case RBU_STATE_COOKIE: (*RbuState)(unsafe.Pointer(pRet)).FiCookie = U32(Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1)) break - case 8: + case RBU_STATE_OALSZ: (*RbuState)(unsafe.Pointer(pRet)).FiOalSz = I64(U32(Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1))) break - case 9: + case RBU_STATE_PHASEONESTEP: (*RbuState)(unsafe.Pointer(pRet)).FnPhaseOneStep = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) break - case 10: + case RBU_STATE_DATATBL: (*RbuState)(unsafe.Pointer(pRet)).FzDataTbl = rbuStrndup(tls, Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1), bp+16 /* &rc */) break default: - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 11 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_CORRUPT break } } rc2 = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = rc2 } @@ -161906,8 +159192,8 @@ func rbuOpenDatabase(tls *libc.TLS, p uintptr, pbRetry uintptr) { /* sqlite3.c:1 // Open the RBU database (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu = rbuOpenDbhandle(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu, 1) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { - Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+8333 /* "main" */, 5149216, p) + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { + Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+8333 /* "main" */, SQLITE_FCNTL_RBUCNT, p) if (*Sqlite3rbu)(unsafe.Pointer(p)).FzState == uintptr(0) { var zFile uintptr = Xsqlite3_db_filename(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+8333 /* "main" */) (*Sqlite3rbu)(unsafe.Pointer(p)).FzState = rbuMPrintf(tls, p, ts+34281 /* "file://%s-vacuum..." */, libc.VaList(bp, zFile, zFile)) @@ -161926,21 +159212,21 @@ func rbuOpenDatabase(tls *libc.TLS, p uintptr, pbRetry uintptr) { /* sqlite3.c:1 // If it has not already been created, create the rbu_state table rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+34326 /* "CREATE TABLE IF ..." */, libc.VaList(bp+24, p+48 /* &.zStateDb */)) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { var bOpen int32 = 0 var rc int32 (*Sqlite3rbu)(unsafe.Pointer(p)).FnRbu = 0 (*Sqlite3rbu)(unsafe.Pointer(p)).FpRbuFd = uintptr(0) - rc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+8333 /* "main" */, 5149216, p) - if rc != 12 { + rc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+8333 /* "main" */, SQLITE_FCNTL_RBUCNT, p) + if rc != SQLITE_NOTFOUND { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc } - if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage >= 2 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage >= RBU_STAGE_MOVE { bOpen = 1 } else { var pState uintptr = rbuLoadState(tls, p) if pState != 0 { - bOpen = (libc.Bool32((*RbuState)(unsafe.Pointer(pState)).FeStage >= 2)) + bOpen = (libc.Bool32((*RbuState)(unsafe.Pointer(pState)).FeStage >= RBU_STAGE_MOVE)) rbuFreeState(tls, pState) } } @@ -161950,7 +159236,7 @@ func rbuOpenDatabase(tls *libc.TLS, p uintptr, pbRetry uintptr) { /* sqlite3.c:1 } (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 0 - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain == uintptr(0)) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain == uintptr(0)) { if !((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain = rbuOpenDbhandle(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget, 1) } else if (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpRbuFd)).FpWalFd != 0 { @@ -161963,13 +159249,13 @@ func rbuOpenDatabase(tls *libc.TLS, p uintptr, pbRetry uintptr) { /* sqlite3.c:1 *(*int32)(unsafe.Pointer(pbRetry)) = 1 return } - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+34392 /* "cannot vacuum wa..." */, 0) } else { var zTarget uintptr var zExtra uintptr = uintptr(0) if (libc.Xstrlen(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu) >= uint64(5)) && (0 == libc.Xmemcmp(tls, ts+27531 /* "file:" */, (*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu, uint64(5))) { - zExtra = ((*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu + uintptr(5)) + zExtra = ((*Sqlite3rbu)(unsafe.Pointer(p)).FzRbu + 5) for *(*int8)(unsafe.Pointer(zExtra)) != 0 { if int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zExtra, 1)))) == '?' { break @@ -161995,7 +159281,7 @@ func rbuOpenDatabase(tls *libc.TLS, p uintptr, pbRetry uintptr) { /* sqlite3.c:1 }())) if zTarget == uintptr(0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM return } (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain = rbuOpenDbhandle(tls, p, zTarget, (libc.Bool32((*Sqlite3rbu)(unsafe.Pointer(p)).FnRbu <= 1))) @@ -162003,41 +159289,41 @@ func rbuOpenDatabase(tls *libc.TLS, p uintptr, pbRetry uintptr) { /* sqlite3.c:1 } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, - ts+34458 /* "rbu_tmp_insert" */, -1, 1, p, *(*uintptr)(unsafe.Pointer(&struct { + ts+34458 /* "rbu_tmp_insert" */, -1, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rbuTmpInsertFunc})), uintptr(0), uintptr(0)) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, - ts+34473 /* "rbu_fossil_delta" */, 2, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + ts+34473 /* "rbu_fossil_delta" */, 2, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rbuFossilDeltaFunc})), uintptr(0), uintptr(0)) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, - ts+34490 /* "rbu_target_name" */, -1, 1, p, *(*uintptr)(unsafe.Pointer(&struct { + ts+34490 /* "rbu_target_name" */, -1, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rbuTargetNameFunc})), uintptr(0), uintptr(0)) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 26, p) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, SQLITE_FCNTL_RBU, p) } rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+34506 /* "SELECT * FROM sq..." */, 0) // Mark the database file just opened as an RBU target database. If // this call returns SQLITE_NOTFOUND, then the RBU vfs is not in use. // This is an error. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, 26, p) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_file_control(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+8333 /* "main" */, SQLITE_FCNTL_RBU, p) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 12 { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_NOTFOUND { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+34534 /* "rbu vfs not foun..." */, 0) } } @@ -162073,13 +159359,13 @@ func rbuShmChecksum(tls *libc.TLS, p uintptr) I64 { /* sqlite3.c:198808:12: */ defer tls.Free(8) var iRet I64 = int64(0) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal // var ptr uintptr at bp, 8 (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 104 /* &.xShmMap */))))(tls, pDb, 0, (32 * 1024), 0, bp /* &ptr */) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - iRet = ((I64(*(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* ptr */)) + uintptr(10)*4))) << 32) + I64(*(*U32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* ptr */)) + uintptr(11)*4)))) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + iRet = ((I64(*(*U32)(unsafe.Pointer(libc.AtomicLoadPUintptr(bp /* ptr */) + 10*4))) << 32) + I64(*(*U32)(unsafe.Pointer(libc.AtomicLoadPUintptr(bp /* ptr */) + 11*4)))) } } return iRet @@ -162106,7 +159392,7 @@ func rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) { /* sqlite3.c // does not interfere with the "capture" process below. if pState == uintptr(0) { (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 0 - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+34506 /* "SELECT * FROM sq..." */, uintptr(0), uintptr(0), uintptr(0)) } } @@ -162138,17 +159424,17 @@ func rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) { /* sqlite3.c // WRITER, CHECKPOINT and READ0 locks are still held, it is safe to copy // data from the wal file into the database file according to the // contents of aFrame[]. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var rc2 int32 - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 3 + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_CAPTURE rc2 = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+34552 /* "PRAGMA main.wal_..." */, uintptr(0), uintptr(0), uintptr(0)) - if rc2 != 2 { + if rc2 != SQLITE_INTERNAL { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc2 } } - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame > 0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 4 + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame > 0) { + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_CKPT (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep = func() int32 { if pState != 0 { return (*RbuState)(unsafe.Pointer(pState)).FnRow @@ -162159,10 +159445,10 @@ func rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) { /* sqlite3.c (*Sqlite3rbu)(unsafe.Pointer(p)).FiWalCksum = rbuShmChecksum(tls, p) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { if ((*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame == 0) || ((pState != 0) && ((*RbuState)(unsafe.Pointer(pState)).FiWalCksum != (*Sqlite3rbu)(unsafe.Pointer(p)).FiWalCksum)) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 101 - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 5 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_DONE + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_DONE } else { var nSectorSize int32 var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal @@ -162179,7 +159465,7 @@ func rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) { /* sqlite3.c // directory in which the target database and the wal file reside, in // case it has not been synced since the rename() call in // rbuMoveOalFile(). - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pWal)).FpMethods + 40 /* &.xSync */))))(tls, pWal, 0x00002) + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pWal)).FpMethods + 40 /* &.xSync */))))(tls, pWal, SQLITE_SYNC_NORMAL) } } } @@ -162188,12 +159474,12 @@ func rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) { /* sqlite3.c // the rbu object is in capture mode. Record the frame number of the frame // being read in the aFrame[] array. func rbuCaptureWalRead(tls *libc.TLS, pRbu uintptr, iOff I64, iAmt int32) int32 { /* sqlite3.c:198921:12: */ - var mReq U32 = (U32(((int32(1) << 0) | (int32(1) << 1)) | (int32(1) << 3))) + var mReq U32 = (U32(((int32(1) << WAL_LOCK_WRITE) | (int32(1) << WAL_LOCK_CKPT)) | (int32(1) << WAL_LOCK_READ0))) var iFrame U32 if (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FmLock != mReq { - (*Sqlite3rbu)(unsafe.Pointer(pRbu)).Frc = 5 - return 2 + (*Sqlite3rbu)(unsafe.Pointer(pRbu)).Frc = SQLITE_BUSY + return SQLITE_INTERNAL } (*Sqlite3rbu)(unsafe.Pointer(pRbu)).Fpgsz = iAmt @@ -162207,7 +159493,7 @@ func rbuCaptureWalRead(tls *libc.TLS, pRbu uintptr, iOff I64, iAmt int32) int32 var aNew uintptr aNew = Xsqlite3_realloc64(tls, (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame, (uint64(uint64(nNew) * uint64(unsafe.Sizeof(RbuFrame{}))))) if aNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame = aNew (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrameAlloc = nNew @@ -162220,7 +159506,7 @@ func rbuCaptureWalRead(tls *libc.TLS, pRbu uintptr, iOff I64, iAmt int32) int32 (*RbuFrame)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame + uintptr((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame)*8)).FiWalFrame = iFrame (*RbuFrame)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame + uintptr((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame)*8)).FiDbPage = U32(0) (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame++ - return 0 + return SQLITE_OK } // Called when a page of data is written to offset iOff of the database @@ -162228,7 +159514,7 @@ func rbuCaptureWalRead(tls *libc.TLS, pRbu uintptr, iOff I64, iAmt int32) int32 // of the page being written in the aFrame[] array. func rbuCaptureDbWrite(tls *libc.TLS, pRbu uintptr, iOff I64) int32 { /* sqlite3.c:198953:12: */ (*RbuFrame)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FaFrame + uintptr(((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnFrame-1))*8)).FiDbPage = ((U32(iOff / I64((*Sqlite3rbu)(unsafe.Pointer(pRbu)).Fpgsz))) + U32(1)) - return 0 + return SQLITE_OK } // This is called as part of an incremental checkpoint operation. Copy @@ -162253,9 +159539,9 @@ func rbuCheckpointFrame(tls *libc.TLS, p uintptr, pFrame uintptr) { /* sqlite3.c func rbuLockDatabase(tls *libc.TLS, p uintptr) { /* sqlite3.c:198981:13: */ var pReal uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 56 /* &.xLock */))))(tls, pReal, 1) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 56 /* &.xLock */))))(tls, pReal, 4) + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 56 /* &.xLock */))))(tls, pReal, SQLITE_LOCK_SHARED) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 56 /* &.xLock */))))(tls, pReal, SQLITE_LOCK_EXCLUSIVE) } } @@ -162280,7 +159566,7 @@ func rbuMoveOalFile(tls *libc.TLS, p uintptr) { /* sqlite3.c:199021:13: */ zWal = Xsqlite3_mprintf(tls, ts+34594 /* "%s-wal" */, libc.VaList(bp+8, zMove)) if (zWal == uintptr(0)) || (zOal == uintptr(0)) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } else { // Move the *-oal file to *-wal. At this point connection p->db is // holding a SHARED lock on the target database file (because it is @@ -162289,7 +159575,7 @@ func rbuMoveOalFile(tls *libc.TLS, p uintptr) { /* sqlite3.c:199021:13: */ // In order to ensure that there are no database readers, an EXCLUSIVE // lock is obtained here before the *-oal is moved to *-wal. rbuLockDatabase(tls, p) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { rbuFileSuffix3(tls, zBase, zWal) rbuFileSuffix3(tls, zBase, zOal) @@ -162302,12 +159588,12 @@ func rbuMoveOalFile(tls *libc.TLS, p uintptr) { /* sqlite3.c:199021:13: */ (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = func() int32 { if libc.Xrename(tls, zOal, zWal) != 0 { - return 10 + return SQLITE_IOERR } - return 0 + return SQLITE_OK }() - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { rbuOpenDatabase(tls, p, uintptr(0)) rbuSetupCheckpoint(tls, p, uintptr(0)) } @@ -162338,39 +159624,39 @@ func rbuStepType(tls *libc.TLS, p uintptr, pzMask uintptr) int32 { /* sqlite3.c: var res int32 = 0 // Return value switch Xsqlite3_column_type(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol) { - case 1: + case SQLITE_INTEGER: { var iVal int32 = Xsqlite3_column_int(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol) switch iVal { case 0: - res = 1 + res = RBU_INSERT break case 1: - res = 2 + res = RBU_DELETE break case 2: - res = 3 + res = RBU_REPLACE break case 3: - res = 4 + res = RBU_IDX_DELETE break case 4: - res = 5 + res = RBU_IDX_INSERT break } break } - case 3: + case SQLITE_TEXT: { var z uintptr = Xsqlite3_column_text(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol) if z == uintptr(0) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 7 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } else { *(*uintptr)(unsafe.Pointer(pzMask)) = z } - res = 6 + res = RBU_UPDATE break @@ -162399,11 +159685,11 @@ func rbuStepOneOp(tls *libc.TLS, p uintptr, eType int32) { /* sqlite3.c:199168:1 // statement below does actually delete a row, nPhaseOneStep will be // incremented by the same amount when SQL function rbu_tmp_insert() // is invoked by the trigger. - if eType == 2 { + if eType == RBU_DELETE { *(*I64)(unsafe.Pointer(p + 304 /* &.nPhaseOneStep */)) -= (I64((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex)) } - if (eType == 4) || (eType == 2) { + if (eType == RBU_IDX_DELETE) || (eType == RBU_DELETE) { pWriter = (*RbuObjIter)(unsafe.Pointer(pIter)).FpDelete } else { pWriter = (*RbuObjIter)(unsafe.Pointer(pIter)).FpInsert @@ -162413,15 +159699,15 @@ func rbuStepOneOp(tls *libc.TLS, p uintptr, eType int32) { /* sqlite3.c:199168:1 // If this is an INSERT into a table b-tree and the table has an // explicit INTEGER PRIMARY KEY, check that this is not an attempt // to write a NULL into the IPK column. That is not permitted. - if ((((eType == 1) && - ((*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0))) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 2)) && (*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0)) && - (Xsqlite3_column_type(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) == 5) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 20 + if ((((eType == RBU_INSERT) && + ((*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0))) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_IPK)) && (*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0)) && + (Xsqlite3_column_type(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) == SQLITE_NULL) { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_MISMATCH (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+27169 /* "datatype mismatc..." */, 0) return } - if (eType == 2) && (int32(*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0) { + if (eType == RBU_DELETE) && (int32(*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i)))) == 0) { continue } @@ -162432,9 +159718,9 @@ func rbuStepOneOp(tls *libc.TLS, p uintptr, eType int32) { /* sqlite3.c:199168:1 } } if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { - if (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 5) || - ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1)) || - (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 3) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) { + if (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB) || + ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE)) || + (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_EXTERNAL) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0))) { // For a virtual table, or a table with no primary key, the // SELECT statement is: // @@ -162446,7 +159732,7 @@ func rbuStepOneOp(tls *libc.TLS, p uintptr, eType int32) { /* sqlite3.c:199168:1 (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, pWriter, ((*RbuObjIter)(unsafe.Pointer(pIter)).FnCol + 1), pVal) } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { Xsqlite3_step(tls, pWriter) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = resetAndCollectError(tls, pWriter, (p + 64 /* &.zErrmsg */)) } @@ -162471,17 +159757,17 @@ func rbuStep(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199251:12: */ if eType != 0 { - if ((*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0)) && ((eType == 4) || (eType == 5)) { + if ((*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0)) && ((eType == RBU_IDX_DELETE) || (eType == RBU_IDX_INSERT)) { rbuBadControlError(tls, p) - } else if eType == 3 { + } else if eType == RBU_REPLACE { if (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx == uintptr(0) { *(*I64)(unsafe.Pointer(p + 304 /* &.nPhaseOneStep */)) += (I64((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnIndex)) - rbuStepOneOp(tls, p, 2) + rbuStepOneOp(tls, p, RBU_DELETE) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - rbuStepOneOp(tls, p, 1) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + rbuStepOneOp(tls, p, RBU_INSERT) } - } else if eType != 6 { + } else if eType != RBU_UPDATE { rbuStepOneOp(tls, p, eType) } else { var pVal uintptr @@ -162491,21 +159777,21 @@ func rbuStep(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199251:12: */ rbuGetUpdateStmt(tls, p, pIter, *(*uintptr)(unsafe.Pointer(bp /* zMask */)), bp+8 /* &pUpdate */) if *(*uintptr)(unsafe.Pointer(bp + 8 /* pUpdate */)) != 0 { var i int32 - for i = 0; ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol); i++ { + for i = 0; ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (i < (*RbuObjIter)(unsafe.Pointer(pIter)).FnCol); i++ { var c int8 = *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* zMask */)) + uintptr(*(*int32)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FaiSrcOrder + uintptr(i)*4))))) pVal = Xsqlite3_column_value(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, i) if (*(*U8)(unsafe.Pointer((*RbuObjIter)(unsafe.Pointer(pIter)).FabTblPk + uintptr(i))) != 0) || (int32(c) != '.') { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pUpdate */)), (i + 1), pVal) } } - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && - (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 5) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == 1)) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && + (((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_VTAB) || ((*RbuObjIter)(unsafe.Pointer(pIter)).FeType == RBU_PK_NONE)) { // Bind the rbu_rowid value to column _rowid_ pVal = Xsqlite3_column_value(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect, ((*RbuObjIter)(unsafe.Pointer(pIter)).FnCol + 1)) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pUpdate */)), ((*RbuObjIter)(unsafe.Pointer(pIter)).FnCol + 1), pVal) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pUpdate */))) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = resetAndCollectError(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pUpdate */)), (p + 64 /* &.zErrmsg */)) } @@ -162524,7 +159810,7 @@ func rbuIncrSchemaCookie(tls *libc.TLS, p uintptr) { /* sqlite3.c:199316:13: */ bp := tls.Alloc(16) defer tls.Free(16) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var dbread uintptr = func() uintptr { if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { return (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu @@ -162536,18 +159822,18 @@ func rbuIncrSchemaCookie(tls *libc.TLS, p uintptr) { /* sqlite3.c:199316:13: */ (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, dbread, bp+8 /* &pStmt */, (p + 64 /* &.zErrmsg */), ts+34601 /* "PRAGMA schema_ve..." */) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { // Coverage: it may be that this sqlite3_step() cannot fail. There // is already a transaction open, so the prepared statement cannot // throw an SQLITE_SCHEMA exception. The only database page the // statement reads is page 1, which is guaranteed to be in the cache. // And no memory allocations are required. - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) { iCookie = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 0) } rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+34623 /* "PRAGMA schema_ve..." */, libc.VaList(bp, (iCookie+1))) } } @@ -162560,7 +159846,7 @@ func rbuSaveState(tls *libc.TLS, p uintptr, eStage int32) { /* sqlite3.c:199347: bp := tls.Alloc(176) defer tls.Free(176) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) || ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 101) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) || ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_DONE) { *(*uintptr)(unsafe.Pointer(bp + 168 /* pInsert */)) = uintptr(0) var pFd uintptr = func() uintptr { if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { @@ -162575,22 +159861,22 @@ func rbuSaveState(tls *libc.TLS, p uintptr, eStage int32) { /* sqlite3.c:199347: ts+34650, /* "INSERT OR REPLAC..." */ libc.VaList(bp, p+48, /* &.zStateDb */ - 1, eStage, - 2, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl, - 3, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzIdx, - 4, (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep, - 5, (*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress, - 6, (*Sqlite3rbu)(unsafe.Pointer(p)).FiWalCksum, - 7, I64((*Rbu_file)(unsafe.Pointer(pFd)).FiCookie), - 8, (*Sqlite3rbu)(unsafe.Pointer(p)).FiOalSz, - 9, (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep, - 10, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzDataTbl))) + RBU_STATE_STAGE, eStage, + RBU_STATE_TBL, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl, + RBU_STATE_IDX, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzIdx, + RBU_STATE_ROW, (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep, + RBU_STATE_PROGRESS, (*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress, + RBU_STATE_CKPT, (*Sqlite3rbu)(unsafe.Pointer(p)).FiWalCksum, + RBU_STATE_COOKIE, I64((*Rbu_file)(unsafe.Pointer(pFd)).FiCookie), + RBU_STATE_OALSZ, (*Sqlite3rbu)(unsafe.Pointer(p)).FiOalSz, + RBU_STATE_PHASEONESTEP, (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep, + RBU_STATE_DATATBL, (*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzDataTbl))) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pInsert */))) rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pInsert */))) } - if rc != 0 { + if rc != SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc } } @@ -162615,11 +159901,11 @@ func rbuCopyPragma(tls *libc.TLS, p uintptr, zPragma uintptr) { /* sqlite3.c:199 bp := tls.Alloc(32) defer tls.Free(32) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { *(*uintptr)(unsafe.Pointer(bp + 24 /* pPragma */)) = uintptr(0) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareFreeAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp+24 /* &pPragma */, (p + 64 /* &.zErrmsg */), Xsqlite3_mprintf(tls, ts+34808 /* "PRAGMA main.%s" */, libc.VaList(bp, zPragma))) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pPragma */)))) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pPragma */)))) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rbuMPrintfExec(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+34823, /* "PRAGMA main.%s =..." */ libc.VaList(bp+8, zPragma, Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pPragma */)), 0))) } @@ -162638,32 +159924,32 @@ func rbuCreateTargetSchema(tls *libc.TLS, p uintptr) { /* sqlite3.c:199428:13: * *(*uintptr)(unsafe.Pointer(bp + 8 /* pInsert */)) = uintptr(0) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+34843 /* "PRAGMA writable_..." */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp /* &pSql */, (p + 64 /* &.zErrmsg */), ts+34868 /* "SELECT sql FROM ..." */) } - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pSql */))) == 100) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pSql */))) == SQLITE_ROW) { var zSql uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pSql */)), 0) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, zSql, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } rbuFinalize(tls, p, *(*uintptr)(unsafe.Pointer(bp /* pSql */))) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK { return } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp /* &pSql */, (p + 64 /* &.zErrmsg */), ts+34976 /* "SELECT * FROM sq..." */) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, bp+8 /* &pInsert */, (p + 64 /* &.zErrmsg */), ts+35041 /* "INSERT INTO sqli..." */) } - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pSql */))) == 100) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pSql */))) == SQLITE_ROW) { var i int32 for i = 0; i < 5; i++ { Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pInsert */)), (i + 1), Xsqlite3_column_value(tls, *(*uintptr)(unsafe.Pointer(bp /* pSql */)), i)) @@ -162671,7 +159957,7 @@ func rbuCreateTargetSchema(tls *libc.TLS, p uintptr) { /* sqlite3.c:199428:13: * Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pInsert */))) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pInsert */))) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+35085 /* "PRAGMA writable_..." */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } @@ -162686,19 +159972,19 @@ func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199480:16: if p != 0 { switch (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage { - case 1: + case RBU_STAGE_OAL: { var pIter uintptr = (p + 80 /* &.objiter */) // If this is an RBU vacuum operation and the state table was empty // when this handle was opened, create the target database schema. - if (((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress == 0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) { + if (((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress == 0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) { rbuCreateTargetSchema(tls, p) rbuCopyPragma(tls, p, ts+18263 /* "user_version" */) rbuCopyPragma(tls, p, ts+17373 /* "application_id" */) } - for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0) { + for ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0) { if (*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0 { // Clean up the rbu_tmp_xxx table for the previous table. It @@ -162712,9 +159998,9 @@ func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199480:16: rbuObjIterPrepareAll(tls, p, pIter, 0) // Advance to the next row to process. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var rc int32 = Xsqlite3_step(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FpSelect) - if rc == 100 { + if rc == SQLITE_ROW { (*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress++ (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep++ return rbuStep(tls, p) @@ -162727,26 +160013,26 @@ func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199480:16: rbuObjIterNext(tls, p, pIter) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { - rbuSaveState(tls, p, 2) + rbuSaveState(tls, p, RBU_STAGE_MOVE) rbuIncrSchemaCookie(tls, p) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+15600 /* "COMMIT" */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+15600 /* "COMMIT" */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 2 + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_MOVE } break } fallthrough - case 2: + case RBU_STAGE_MOVE: { - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { rbuMoveOalFile(tls, p) (*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress++ } @@ -162755,28 +160041,28 @@ func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199480:16: } fallthrough - case 4: + case RBU_STAGE_CKPT: { - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { if (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep >= (*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame { var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal // Sync the db file - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 40 /* &.xSync */))))(tls, pDb, 0x00002) + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 40 /* &.xSync */))))(tls, pDb, SQLITE_SYNC_NORMAL) // Update nBackfill - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { // var ptr uintptr at bp+16, 8 (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 104 /* &.xShmMap */))))(tls, pDb, 0, (32 * 1024), 0, bp+16 /* &ptr */) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - *(*U32)(unsafe.Pointer((libc.AtomicLoadPUintptr(bp + 16 /* ptr */)) + uintptr(24)*4)) = (*Sqlite3rbu)(unsafe.Pointer(p)).FiMaxFrame + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + *(*U32)(unsafe.Pointer((libc.AtomicLoadPUintptr(bp + 16 /* ptr */)) + 24*4)) = (*Sqlite3rbu)(unsafe.Pointer(p)).FiMaxFrame } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 5 - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 101 + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_DONE + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_DONE } } else { // At one point the following block copied a single frame from the @@ -162792,7 +160078,7 @@ func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199480:16: var iSector U32 for ok := true; ok; ok = ((((*Sqlite3rbu)(unsafe.Pointer(p)).FnStep < (*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame) && (iSector == (((*RbuFrame)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FaFrame+uintptr((*Sqlite3rbu)(unsafe.Pointer(p)).FnStep)*8)).FiDbPage - U32(1)) / U32((*Sqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector)))) && - ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0)) { + ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK)) { var pFrame uintptr = ((*Sqlite3rbu)(unsafe.Pointer(p)).FaFrame + uintptr((*Sqlite3rbu)(unsafe.Pointer(p)).FnStep)*8) iSector = (((*RbuFrame)(unsafe.Pointer(pFrame)).FiDbPage - U32(1)) / U32((*Sqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector)) rbuCheckpointFrame(tls, p, pFrame) @@ -162811,7 +160097,7 @@ func Xsqlite3rbu_step(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:199480:16: } return (*Sqlite3rbu)(unsafe.Pointer(p)).Frc } else { - return 7 + return SQLITE_NOMEM } return int32(0) } @@ -162841,21 +160127,21 @@ func rbuSetupOal(tls *libc.TLS, p uintptr, pState uintptr) { /* sqlite3.c:199625 if (*RbuState)(unsafe.Pointer(pState)).FzTbl != 0 { var pIter uintptr = (p + 80 /* &.objiter */) - var rc int32 = 0 + var rc int32 = SQLITE_OK - for ((rc == 0) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0)) && (((((*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0) || + for ((rc == SQLITE_OK) && ((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl != 0)) && (((((*RbuObjIter)(unsafe.Pointer(pIter)).FbCleanup != 0) || (rbuStrCompare(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FzIdx, (*RbuState)(unsafe.Pointer(pState)).FzIdx) != 0)) || (((*RbuState)(unsafe.Pointer(pState)).FzDataTbl == uintptr(0)) && (rbuStrCompare(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl, (*RbuState)(unsafe.Pointer(pState)).FzTbl) != 0))) || (((*RbuState)(unsafe.Pointer(pState)).FzDataTbl != 0) && (rbuStrCompare(tls, (*RbuObjIter)(unsafe.Pointer(pIter)).FzDataTbl, (*RbuState)(unsafe.Pointer(pState)).FzDataTbl) != 0))) { rc = rbuObjIterNext(tls, p, pIter) } - if (rc == 0) && !(int32((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl) != 0) { - rc = 1 + if (rc == SQLITE_OK) && !(int32((*RbuObjIter)(unsafe.Pointer(pIter)).FzTbl) != 0) { + rc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+35138 /* "rbu_state mismat..." */, 0) } - if rc == 0 { + if rc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep = (*RbuState)(unsafe.Pointer(pState)).FnRow rc = rbuObjIterPrepareAll(tls, p, (p + 80 /* &.objiter */), (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep) } @@ -162895,7 +160181,7 @@ func rbuCreateVfs(tls *libc.TLS, p uintptr) { /* sqlite3.c:199674:13: */ Xsqlite3_randomness(tls, int32(unsafe.Sizeof(int32(0))), bp+8 /* &rnd */) Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([64]int8{})), bp+12 /* &zRnd[0] */, ts+35163 /* "rbu_vfs_%d" */, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* rnd */)))) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3rbu_create_vfs(tls, bp+12 /* &zRnd[0] */, uintptr(0)) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { var pVfs uintptr = Xsqlite3_vfs_find(tls, bp+12 /* &zRnd[0] */) (*Sqlite3rbu)(unsafe.Pointer(p)).FzVfsName = (*Sqlite3_vfs)(unsafe.Pointer(pVfs)).FzName @@ -162932,16 +160218,16 @@ func rbuIndexCntFunc(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) { / rc = prepareFreeAndCollectError(tls, db, bp+8 /* &pStmt */, bp+16, /* &zErrmsg */ Xsqlite3_mprintf(tls, - ts+35174 /* "SELECT count(*) ..." */, libc.VaList(bp, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8)))))) - if rc != 0 { + ts+35174 /* "SELECT count(*) ..." */, libc.VaList(bp, Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal)))))) + if rc != SQLITE_OK { Xsqlite3_result_error(tls, pCtx, *(*uintptr)(unsafe.Pointer(bp + 16 /* zErrmsg */)), -1) } else { var nIndex int32 = 0 - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) { nIndex = Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 0) } rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_result_int(tls, pCtx, nIndex) } else { Xsqlite3_result_error(tls, pCtx, Xsqlite3_errmsg(tls, db), -1) @@ -162968,36 +160254,36 @@ func rbuInitPhaseOneSteps(tls *libc.TLS, p uintptr) { /* sqlite3.c:199756:13: */ bp := tls.Alloc(8) defer tls.Free(8) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) var bExists int32 = 0 // True if rbu_count exists (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = int64(-1) (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_create_function(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, - ts+35246 /* "rbu_index_cnt" */, 1, 1, p, *(*uintptr)(unsafe.Pointer(&struct { + ts+35246 /* "rbu_index_cnt" */, 1, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{rbuIndexCntFunc})), uintptr(0), uintptr(0)) // Check for the rbu_count table. If it does not exist, or if an error // occurs, nPhaseOneStep will be left set to -1. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp /* &pStmt */, (p + 64 /* &.zErrmsg */), ts+35260 /* "SELECT 1 FROM sq..." */) } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { bExists = 1 } (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) } - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && (bExists != 0) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (bExists != 0) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = prepareAndCollectError(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, bp /* &pStmt */, (p + 64 /* &.zErrmsg */), ts+35317 /* "SELECT sum(cnt *..." */) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 0) } (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) @@ -163029,8 +160315,8 @@ func openRbuHandle(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) rbuCreateVfs(tls, p) // Open the target, RBU and state databases - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - var pCsr uintptr = (p + uintptr(1)*392) + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var pCsr uintptr = (p + 1*392) *(*int32)(unsafe.Pointer(bp + 16 /* bRetry */)) = 0 if zTarget != 0 { (*Sqlite3rbu)(unsafe.Pointer(p)).FzTarget = pCsr @@ -163057,15 +160343,15 @@ func openRbuHandle(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { pState = rbuLoadState(tls, p) - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { if (*RbuState)(unsafe.Pointer(pState)).FeStage == 0 { rbuDeleteOalFile(tls, p) rbuInitPhaseOneSteps(tls, p) - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 1 + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_OAL } else { (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = (*RbuState)(unsafe.Pointer(pState)).FeStage (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep = (*RbuState)(unsafe.Pointer(pState)).FnPhaseOneStep @@ -163075,18 +160361,18 @@ func openRbuHandle(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) } } - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpWalFd != 0) { - if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1 { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 1 + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpWalFd != 0) { + if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+35391 /* "cannot update wa..." */, 0) - } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 2 { - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 4 + } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_MOVE { + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_CKPT (*Sqlite3rbu)(unsafe.Pointer(p)).FnStep = 0 } } - if (((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && - (((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1) || ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 2))) && + if (((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && + (((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL) || ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_MOVE))) && ((*RbuState)(unsafe.Pointer(pState)).FeStage != 0) { var pFd uintptr = func() uintptr { if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { @@ -163099,7 +160385,7 @@ func openRbuHandle(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) // change-counter cookie (the thing that gets incremented when a // transaction is committed in rollback mode) currently stored on // page 1 of the database file. - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 5 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_BUSY (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, ts+35423, /* "database modifie..." */ libc.VaList(bp+8, func() uintptr { if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { @@ -163110,56 +160396,56 @@ func openRbuHandle(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL { var db uintptr = (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+15585 /* "BEGIN" */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) // Point the object iterator at the first object - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rbuObjIterFirst(tls, p, (p + 80 /* &.objiter */)) } // If the RBU database contains no data_xxx tables, declare the RBU // update finished. - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl == uintptr(0)) { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 101 - (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = 5 + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FzTbl == uintptr(0)) { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_DONE + (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage = RBU_STAGE_DONE } else { - if (((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*RbuState)(unsafe.Pointer(pState)).FeStage == 0)) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { + if (((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*RbuState)(unsafe.Pointer(pState)).FeStage == 0)) && ((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) { rbuCopyPragma(tls, p, ts+17988 /* "page_size" */) rbuCopyPragma(tls, p, ts+17388 /* "auto_vacuum" */) } // Open transactions both databases. The *-oal file is opened or // created at this point. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, ts+35469 /* "BEGIN IMMEDIATE" */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } // Check if the main database is a zipvfs db. If it is, set the upper // level pager to use "journal_mode=off". This prevents it from // generating a large journal using a temp file. - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { - var frc int32 = Xsqlite3_file_control(tls, db, ts+8333 /* "main" */, 25, uintptr(0)) - if frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var frc int32 = Xsqlite3_file_control(tls, db, ts+8333 /* "main" */, SQLITE_FCNTL_ZIPVFS, uintptr(0)) + if frc == SQLITE_OK { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, db, ts+35485 /* "PRAGMA journal_m..." */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } } - if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK { rbuSetupOal(tls, p, pState) } } - } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 2 { + } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_MOVE { // no-op - } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 4 { + } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_CKPT { rbuSetupCheckpoint(tls, p, pState) - } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 5 { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 101 + } else if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_DONE { + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_DONE } else { - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = 11 + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = SQLITE_CORRUPT } } @@ -163176,7 +160462,7 @@ func rbuMisuseError(tls *libc.TLS) uintptr { /* sqlite3.c:199953:19: */ pRet = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(Sqlite3rbu{}))) if pRet != 0 { libc.Xmemset(tls, pRet, 0, uint64(unsafe.Sizeof(Sqlite3rbu{}))) - (*Sqlite3rbu)(unsafe.Pointer(pRet)).Frc = 21 + (*Sqlite3rbu)(unsafe.Pointer(pRet)).Frc = SQLITE_MISUSE } return pRet } @@ -163223,7 +160509,7 @@ func Xsqlite3rbu_db(tls *libc.TLS, pRbu uintptr, bRbu int32) uintptr { /* sqlite // then edit any error message string so as to remove all occurrences of // the pattern "rbu_imp_[0-9]*". func rbuEditErrmsg(tls *libc.TLS, p uintptr) { /* sqlite3.c:200011:13: */ - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 19) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg != 0) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_CONSTRAINT) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg != 0) { var i uint32 var nErrmsg Size_t = libc.Xstrlen(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzErrmsg) for i = uint32(0); Size_t(i) < (nErrmsg - uint64(8)); i++ { @@ -163245,19 +160531,19 @@ func Xsqlite3rbu_close(tls *libc.TLS, p uintptr, pzErrmsg uintptr) int32 { /* sq if p != 0 { // Commit the transaction to the *-oal file. - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+15600 /* "COMMIT" */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } // Sync the db file if currently doing an incremental checkpoint - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 4) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_CKPT) { var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal - (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 40 /* &.xSync */))))(tls, pDb, 0x00002) + (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 40 /* &.xSync */))))(tls, pDb, SQLITE_SYNC_NORMAL) } rbuSaveState(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+15600 /* "COMMIT" */, uintptr(0), uintptr(0), (p + 64 /* &.zErrmsg */)) } @@ -163269,9 +160555,9 @@ func Xsqlite3rbu_close(tls *libc.TLS, p uintptr, pzErrmsg uintptr) int32 { /* sq // state table. This causes the next call to sqlite3rbu_vacuum() // specifying the current target and state databases to start a new // vacuum from scratch. - if (((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu != 0) { + if (((*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK)) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu != 0) { var rc2 int32 = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+35517 /* "DELETE FROM stat..." */, uintptr(0), uintptr(0), uintptr(0)) - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == 101) && (rc2 != 0) { + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_DONE) && (rc2 != SQLITE_OK) { (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc2 } } @@ -163294,7 +160580,7 @@ func Xsqlite3rbu_close(tls *libc.TLS, p uintptr, pzErrmsg uintptr) int32 { /* sq Xsqlite3_free(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FzState) Xsqlite3_free(tls, p) } else { - rc = 7 + rc = SQLITE_NOMEM *(*uintptr)(unsafe.Pointer(pzErrmsg)) = uintptr(0) } return rc @@ -163312,7 +160598,7 @@ func Xsqlite3rbu_progress(tls *libc.TLS, pRbu uintptr) Sqlite3_int64 { /* sqlite func Xsqlite3rbu_bp_progress(tls *libc.TLS, p uintptr, pnOne uintptr, pnTwo uintptr) { /* sqlite3.c:200100:17: */ var MAX_PROGRESS int32 = 10000 switch (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage { - case 1: + case RBU_STAGE_OAL: if (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep > int64(0) { *(*int32)(unsafe.Pointer(pnOne)) = (int32((I64(MAX_PROGRESS) * I64((*Sqlite3rbu)(unsafe.Pointer(p)).FnProgress)) / (*Sqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep)) } else { @@ -163321,17 +160607,17 @@ func Xsqlite3rbu_bp_progress(tls *libc.TLS, p uintptr, pnOne uintptr, pnTwo uint *(*int32)(unsafe.Pointer(pnTwo)) = 0 break - case 2: + case RBU_STAGE_MOVE: *(*int32)(unsafe.Pointer(pnOne)) = MAX_PROGRESS *(*int32)(unsafe.Pointer(pnTwo)) = 0 break - case 4: + case RBU_STAGE_CKPT: *(*int32)(unsafe.Pointer(pnOne)) = MAX_PROGRESS *(*int32)(unsafe.Pointer(pnTwo)) = (int32((I64(MAX_PROGRESS) * I64((*Sqlite3rbu)(unsafe.Pointer(p)).FnStep)) / I64((*Sqlite3rbu)(unsafe.Pointer(p)).FnFrame))) break - case 5: + case RBU_STAGE_DONE: *(*int32)(unsafe.Pointer(pnOne)) = MAX_PROGRESS *(*int32)(unsafe.Pointer(pnTwo)) = MAX_PROGRESS break @@ -163347,12 +160633,12 @@ func Xsqlite3rbu_state(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:200135:16: defer tls.Free(24) *(*[6]int32)(unsafe.Pointer(bp /* aRes */)) = [6]int32{ - 0, 1, 2, - 0, 3, 4, + 0, SQLITE_RBU_STATE_OAL, SQLITE_RBU_STATE_MOVE, + 0, SQLITE_RBU_STATE_CHECKPOINT, SQLITE_RBU_STATE_DONE, } - if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != 101) { - return 5 + if ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_DONE) { + return SQLITE_RBU_STATE_ERROR } else { return *(*int32)(unsafe.Pointer(bp /* &aRes[0] */ + uintptr((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage)*4)) @@ -163362,33 +160648,33 @@ func Xsqlite3rbu_state(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:200135:16: func Xsqlite3rbu_savestate(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:200163:16: */ var rc int32 = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc - if rc == 101 { - return 0 + if rc == SQLITE_DONE { + return SQLITE_OK } - if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL { - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+15600 /* "COMMIT" */, uintptr(0), uintptr(0), uintptr(0)) } } // Sync the db file - if (rc == 0) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 4) { + if (rc == SQLITE_OK) && ((*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_CKPT) { var pDb uintptr = (*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal - rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 40 /* &.xSync */))))(tls, pDb, 0x00002) + rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pDb)).FpMethods + 40 /* &.xSync */))))(tls, pDb, SQLITE_SYNC_NORMAL) } (*Sqlite3rbu)(unsafe.Pointer(p)).Frc = rc rbuSaveState(tls, p, (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage) rc = (*Sqlite3rbu)(unsafe.Pointer(p)).Frc - if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == 1 { + if (*Sqlite3rbu)(unsafe.Pointer(p)).FeStage == RBU_STAGE_OAL { - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, ts+15600 /* "COMMIT" */, uintptr(0), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { var zBegin uintptr if (*Sqlite3rbu)(unsafe.Pointer((p))).FzTarget == uintptr(0) { zBegin = ts + 15585 /* "BEGIN" */ @@ -163397,7 +160683,7 @@ func Xsqlite3rbu_savestate(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:200163 } rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbRbu, zBegin, uintptr(0), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_exec(tls, (*Sqlite3rbu)(unsafe.Pointer(p)).FdbMain, ts+35469 /* "BEGIN IMMEDIATE" */, uintptr(0), uintptr(0), uintptr(0)) } } @@ -163470,9 +160756,9 @@ func rbuUnlockShm(tls *libc.TLS, p uintptr) { /* sqlite3.c:200256:13: */ if (*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 { var xShmLock uintptr = (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmLock var i int32 - for i = 0; i < 8; i++ { + for i = 0; i < SQLITE_SHM_NLOCK; i++ { if ((U32(int32(1) << i)) & (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FmLock) != 0 { - (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&xShmLock)))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, i, 1, (1 | 8)) + (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&xShmLock)))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, i, 1, (SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE)) } } (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FmLock = U32(0) @@ -163487,9 +160773,9 @@ func rbuUpdateTempSize(tls *libc.TLS, pFd uintptr, nNew Sqlite3_int64) int32 { / (*Rbu_file)(unsafe.Pointer(pFd)).Fsz = nNew if ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FszTemp > (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit) { - return 13 + return SQLITE_FULL } - return 0 + return SQLITE_OK } // Add an item to the main-db lists, if it is not already present. @@ -163573,11 +160859,11 @@ func rbuVfsClose(tls *libc.TLS, pFile uintptr) int32 { /* sqlite3.c:200348:12: * (*Rbu_file)(unsafe.Pointer(p)).FapShm = uintptr(0) Xsqlite3_free(tls, (*Rbu_file)(unsafe.Pointer(p)).FzDel) - if ((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000100) != 0 { + if ((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_MAIN_DB) != 0 { rbuMainlistRemove(tls, p) rbuUnlockShm(tls, p) (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 128 /* &.xShmUnmap */))))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, 0) - } else if (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000008) != 0) && ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0) { + } else if (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_DELETEONCLOSE) != 0) && ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0) { rbuUpdateTempSize(tls, p, int64(0)) } @@ -163589,24 +160875,24 @@ func rbuVfsClose(tls *libc.TLS, pFile uintptr) int32 { /* sqlite3.c:200348:12: * // Read and return an unsigned 32-bit big-endian integer from the buffer // passed as the only argument. func rbuGetU32(tls *libc.TLS, aBuf uintptr) U32 { /* sqlite3.c:200381:12: */ - return ((((U32(*(*U8)(unsafe.Pointer(aBuf + uintptr(0)))) << 24) + - (U32(*(*U8)(unsafe.Pointer(aBuf + uintptr(1)))) << 16)) + - (U32(*(*U8)(unsafe.Pointer(aBuf + uintptr(2)))) << 8)) + - (U32(*(*U8)(unsafe.Pointer(aBuf + uintptr(3)))))) + return ((((U32(*(*U8)(unsafe.Pointer(aBuf))) << 24) + + (U32(*(*U8)(unsafe.Pointer(aBuf + 1))) << 16)) + + (U32(*(*U8)(unsafe.Pointer(aBuf + 2))) << 8)) + + (U32(*(*U8)(unsafe.Pointer(aBuf + 3))))) } // Write an unsigned 32-bit value in big-endian format to the supplied // buffer. func rbuPutU32(tls *libc.TLS, aBuf uintptr, iVal U32) { /* sqlite3.c:200392:13: */ - *(*U8)(unsafe.Pointer(aBuf + uintptr(0))) = (U8((iVal >> 24) & U32(0xFF))) - *(*U8)(unsafe.Pointer(aBuf + uintptr(1))) = (U8((iVal >> 16) & U32(0xFF))) - *(*U8)(unsafe.Pointer(aBuf + uintptr(2))) = (U8((iVal >> 8) & U32(0xFF))) - *(*U8)(unsafe.Pointer(aBuf + uintptr(3))) = (U8((iVal >> 0) & U32(0xFF))) + *(*U8)(unsafe.Pointer(aBuf)) = (U8((iVal >> 24) & U32(0xFF))) + *(*U8)(unsafe.Pointer(aBuf + 1)) = (U8((iVal >> 16) & U32(0xFF))) + *(*U8)(unsafe.Pointer(aBuf + 2)) = (U8((iVal >> 8) & U32(0xFF))) + *(*U8)(unsafe.Pointer(aBuf + 3)) = (U8((iVal >> 0) & U32(0xFF))) } func rbuPutU16(tls *libc.TLS, aBuf uintptr, iVal U16) { /* sqlite3.c:200399:13: */ - *(*U8)(unsafe.Pointer(aBuf + uintptr(0))) = (U8((int32(iVal) >> 8) & 0xFF)) - *(*U8)(unsafe.Pointer(aBuf + uintptr(1))) = (U8((int32(iVal) >> 0) & 0xFF)) + *(*U8)(unsafe.Pointer(aBuf)) = (U8((int32(iVal) >> 8) & 0xFF)) + *(*U8)(unsafe.Pointer(aBuf + 1)) = (U8((int32(iVal) >> 0) & 0xFF)) } // Read data from an rbuVfs-file. @@ -163615,14 +160901,14 @@ func rbuVfsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Sq var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbu var rc int32 - if (pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 3) { + if (pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_CAPTURE) { rc = rbuCaptureWalRead(tls, (*Rbu_file)(unsafe.Pointer(p)).FpRbu, iOfst, iAmt) } else { - if (((pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 1)) && - (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00080000) != 0)) && + if (((pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_OAL)) && + (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_WAL) != 0)) && (iOfst >= (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz) { - rc = 0 + rc = SQLITE_OK libc.Xmemset(tls, zBuf, 0, uint64(iAmt)) } else { rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 16 /* &.xRead */))))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) @@ -163631,39 +160917,39 @@ func rbuVfsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Sq // contents of the first page if it does not yet exist. Otherwise, // SQLite will not check for a *-wal file. if (((((pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer((pRbu))).FzTarget == uintptr(0))) && - (rc == (10 | (int32(2) << 8)))) && (iOfst == int64(0))) && - (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000100) != 0)) && - ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).Frc == 0) { + (rc == (SQLITE_IOERR | (int32(2) << 8)))) && (iOfst == int64(0))) && + (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_MAIN_DB) != 0)) && + ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).Frc == SQLITE_OK) { var pFd uintptr = (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRbuFd rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer(pFd)).FpMethods + 16 /* &.xRead */))))(tls, pFd, zBuf, iAmt, iOfst) - if rc == 0 { + if rc == SQLITE_OK { var aBuf uintptr = zBuf var iRoot U32 - if rbuGetU32(tls, (aBuf+uintptr(52))) != 0 { + if rbuGetU32(tls, (aBuf+52)) != 0 { iRoot = uint32(1) } else { iRoot = uint32(0) } - rbuPutU32(tls, (aBuf + uintptr(52)), iRoot) // largest root page number - rbuPutU32(tls, (aBuf + uintptr(36)), uint32(0)) // number of free pages - rbuPutU32(tls, (aBuf + uintptr(32)), uint32(0)) // first page on free list trunk - rbuPutU32(tls, (aBuf + uintptr(28)), uint32(1)) // size of db file in pages - rbuPutU32(tls, (aBuf + uintptr(24)), ((*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRbuFd)).FiCookie + U32(1))) // Change counter + rbuPutU32(tls, (aBuf + 52), iRoot) // largest root page number + rbuPutU32(tls, (aBuf + 36), uint32(0)) // number of free pages + rbuPutU32(tls, (aBuf + 32), uint32(0)) // first page on free list trunk + rbuPutU32(tls, (aBuf + 28), uint32(1)) // size of db file in pages + rbuPutU32(tls, (aBuf + 24), ((*Rbu_file)(unsafe.Pointer((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRbuFd)).FiCookie + U32(1))) // Change counter if iAmt > 100 { - libc.Xmemset(tls, (aBuf + uintptr(100)), 0, (uint64(iAmt - 100))) - rbuPutU16(tls, (aBuf + uintptr(105)), (uint16(iAmt & 0xFFFF))) - *(*U8)(unsafe.Pointer(aBuf + uintptr(100))) = U8(0x0D) + libc.Xmemset(tls, (aBuf + 100), 0, (uint64(iAmt - 100))) + rbuPutU16(tls, (aBuf + 105), (uint16(iAmt & 0xFFFF))) + *(*U8)(unsafe.Pointer(aBuf + 100)) = U8(0x0D) } } } } - if ((rc == 0) && (iOfst == int64(0))) && (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000100) != 0) { + if ((rc == SQLITE_OK) && (iOfst == int64(0))) && (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_MAIN_DB) != 0) { // These look like magic numbers. But they are stable, as they are part // of the definition of the SQLite file format, which may not change. var pBuf uintptr = zBuf - (*Rbu_file)(unsafe.Pointer(p)).FiCookie = rbuGetU32(tls, (pBuf + uintptr(24))) - (*Rbu_file)(unsafe.Pointer(p)).FiWriteVer = *(*U8)(unsafe.Pointer(pBuf + uintptr(19))) + (*Rbu_file)(unsafe.Pointer(p)).FiCookie = rbuGetU32(tls, (pBuf + 24)) + (*Rbu_file)(unsafe.Pointer(p)).FiWriteVer = *(*U8)(unsafe.Pointer(pBuf + 19)) } } return rc @@ -163675,32 +160961,32 @@ func rbuVfsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst S var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbu var rc int32 - if (pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 3) { + if (pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_CAPTURE) { rc = rbuCaptureDbWrite(tls, (*Rbu_file)(unsafe.Pointer(p)).FpRbu, iOfst) } else { if pRbu != 0 { - if (((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 1) && - (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00080000) != 0)) && + if (((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_OAL) && + (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_WAL) != 0)) && (iOfst >= (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz) { (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz = (Sqlite_int64(iAmt) + iOfst) - } else if ((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000008) != 0 { + } else if ((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_DELETEONCLOSE) != 0 { var szNew I64 = (Sqlite_int64(iAmt) + iOfst) if szNew > (*Rbu_file)(unsafe.Pointer(p)).Fsz { rc = rbuUpdateTempSize(tls, p, szNew) - if rc != 0 { + if rc != SQLITE_OK { return rc } } } } rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Sqlite3_int64) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 24 /* &.xWrite */))))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) - if ((rc == 0) && (iOfst == int64(0))) && (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000100) != 0) { + if ((rc == SQLITE_OK) && (iOfst == int64(0))) && (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_MAIN_DB) != 0) { // These look like magic numbers. But they are stable, as they are part // of the definition of the SQLite file format, which may not change. var pBuf uintptr = zBuf - (*Rbu_file)(unsafe.Pointer(p)).FiCookie = rbuGetU32(tls, (pBuf + uintptr(24))) - (*Rbu_file)(unsafe.Pointer(p)).FiWriteVer = *(*U8)(unsafe.Pointer(pBuf + uintptr(19))) + (*Rbu_file)(unsafe.Pointer(p)).FiCookie = rbuGetU32(tls, (pBuf + 24)) + (*Rbu_file)(unsafe.Pointer(p)).FiWriteVer = *(*U8)(unsafe.Pointer(pBuf + 19)) } } return rc @@ -163709,9 +160995,9 @@ func rbuVfsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst S // Truncate an rbuVfs-file. func rbuVfsTruncate(tls *libc.TLS, pFile uintptr, size Sqlite_int64) int32 { /* sqlite3.c:200516:12: */ var p uintptr = pFile - if (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000008) != 0) && ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0) { + if (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_DELETEONCLOSE) != 0) && ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0) { var rc int32 = rbuUpdateTempSize(tls, p, size) - if rc != 0 { + if rc != SQLITE_OK { return rc } } @@ -163721,11 +161007,11 @@ func rbuVfsTruncate(tls *libc.TLS, pFile uintptr, size Sqlite_int64) int32 { /* // Sync an rbuVfs-file. func rbuVfsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* sqlite3.c:200528:12: */ var p uintptr = pFile - if ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage == 3) { - if ((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000100) != 0 { - return 2 + if ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage == RBU_STAGE_CAPTURE) { + if ((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_MAIN_DB) != 0 { + return SQLITE_INTERNAL } - return 0 + return SQLITE_OK } return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 40 /* &.xSync */))))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, flags) } @@ -163740,9 +161026,9 @@ func rbuVfsFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* sqli // pretend that it has at least one page. Otherwise, SQLite will not // check for the existance of a *-wal file. rbuVfsRead() contains // similar logic. - if ((((rc == 0) && (*(*Sqlite_int64)(unsafe.Pointer(pSize)) == int64(0))) && + if ((((rc == SQLITE_OK) && (*(*Sqlite_int64)(unsafe.Pointer(pSize)) == int64(0))) && ((*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0)) && ((*Sqlite3rbu)(unsafe.Pointer(((*Rbu_file)(unsafe.Pointer(p)).FpRbu))).FzTarget == uintptr(0))) && - (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & 0x00000100) != 0) { + (((*Rbu_file)(unsafe.Pointer(p)).FopenFlags & SQLITE_OPEN_MAIN_DB) != 0) { *(*Sqlite_int64)(unsafe.Pointer(pSize)) = int64(1024) } return rc @@ -163752,13 +161038,13 @@ func rbuVfsFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* sqli func rbuVfsLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* sqlite3.c:200563:12: */ var p uintptr = pFile var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbu - var rc int32 = 0 + var rc int32 = SQLITE_OK - if (eLock == 4) && - (((*Rbu_file)(unsafe.Pointer(p)).FbNolock != 0) || ((pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage != 5))) { + if (eLock == SQLITE_LOCK_EXCLUSIVE) && + (((*Rbu_file)(unsafe.Pointer(p)).FbNolock != 0) || ((pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage != RBU_STAGE_DONE))) { // Do not allow EXCLUSIVE locks. Preventing SQLite from taking this // prevents it from checkpointing the database from sqlite3_close(). - rc = 5 + rc = SQLITE_BUSY } else { rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 56 /* &.xLock */))))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, eLock) } @@ -163787,7 +161073,7 @@ func rbuVfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int var xControl uintptr = (*sqlite3_io_methods)(unsafe.Pointer((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxFileControl var rc int32 - if op == 26 { + if op == SQLITE_FCNTL_RBU { var pRbu uintptr = pArg // First try to find another RBU vfs lower down in the vfs stack. If @@ -163795,26 +161081,26 @@ func rbuVfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int // level vfs will do the special RBU handling. rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&xControl)))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, op, pArg) - if rc == 12 { + if rc == SQLITE_NOTFOUND { // Now search for a zipvfs instance lower down in the VFS stack. If // one is found, this is an error. *(*uintptr)(unsafe.Pointer(bp + 16 /* dummy */)) = uintptr(0) - rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&xControl)))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, 25, bp+16 /* &dummy */) - if rc == 0 { - rc = 1 + rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&xControl)))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, SQLITE_FCNTL_ZIPVFS, bp+16 /* &dummy */) + if rc == SQLITE_OK { + rc = SQLITE_ERROR (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FzErrmsg = Xsqlite3_mprintf(tls, ts+35544 /* "rbu/zipvfs setup..." */, 0) - } else if rc == 12 { + } else if rc == SQLITE_NOTFOUND { (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpTargetFd = p (*Rbu_file)(unsafe.Pointer(p)).FpRbu = pRbu rbuMainlistAdd(tls, p) if (*Rbu_file)(unsafe.Pointer(p)).FpWalFd != 0 { (*Rbu_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpWalFd)).FpRbu = pRbu } - rc = 0 + rc = SQLITE_OK } } return rc - } else if op == 5149216 { + } else if op == SQLITE_FCNTL_RBUCNT { var pRbu uintptr = pArg (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FnRbu++ (*Sqlite3rbu)(unsafe.Pointer(pRbu)).FpRbuFd = p @@ -163822,13 +161108,13 @@ func rbuVfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int } rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&xControl)))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, op, pArg) - if (rc == 0) && (op == 12) { + if (rc == SQLITE_OK) && (op == SQLITE_FCNTL_VFSNAME) { var pRbuVfs uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbuVfs var zIn uintptr = *(*uintptr)(unsafe.Pointer(pArg)) var zOut uintptr = Xsqlite3_mprintf(tls, ts+35567 /* "rbu(%s)/%z" */, libc.VaList(bp, (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).Fbase.FzName, zIn)) *(*uintptr)(unsafe.Pointer(pArg)) = zOut if zOut == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } } @@ -163851,25 +161137,25 @@ func rbuVfsDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* sqlite func rbuVfsShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int32) int32 { /* sqlite3.c:200673:12: */ var p uintptr = pFile var pRbu uintptr = (*Rbu_file)(unsafe.Pointer(p)).FpRbu - var rc int32 = 0 + var rc int32 = SQLITE_OK - if (pRbu != 0) && (((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 1) || ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 2)) { + if (pRbu != 0) && (((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_OAL) || ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_MOVE)) { // Magic number 1 is the WAL_CKPT_LOCK lock. Preventing SQLite from // taking this lock also prevents any checkpoints from occurring. // todo: really, it's not clear why this might occur, as // wal_autocheckpoint ought to be turned off. - if (ofst == 1) && (n == 1) { - rc = 5 + if (ofst == WAL_LOCK_CKPT) && (n == 1) { + rc = SQLITE_BUSY } } else { var bCapture int32 = 0 - if (pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == 3) { + if (pRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == RBU_STAGE_CAPTURE) { bCapture = 1 } - if (bCapture == 0) || (0 == (flags & 1)) { + if (bCapture == 0) || (0 == (flags & SQLITE_SHM_UNLOCK)) { rc = (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 112 /* &.xShmLock */))))(tls, (*Rbu_file)(unsafe.Pointer(p)).FpReal, ofst, n, flags) - if (bCapture != 0) && (rc == 0) { + if (bCapture != 0) && (rc == SQLITE_OK) { *(*U32)(unsafe.Pointer(pRbu + 316 /* &.mLock */)) |= (U32(int32(1) << ofst)) } } @@ -163881,7 +161167,7 @@ func rbuVfsShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int3 // Obtain a pointer to a mapping of a single 32KiB page of the *-shm file. func rbuVfsShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, szRegion int32, isWrite int32, pp uintptr) int32 { /* sqlite3.c:200709:12: */ var p uintptr = pFile - var rc int32 = 0 + var rc int32 = SQLITE_OK var eStage int32 = func() int32 { if (*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 { return (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage @@ -163893,7 +161179,7 @@ func rbuVfsShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, szRegion int32, i // rbu is in the RBU_STAGE_OAL state, use heap memory for *-shm space // instead of a file on disk. - if eStage == 1 { + if eStage == RBU_STAGE_OAL { var nByte Sqlite3_int64 = (Sqlite3_int64((uint64(iRegion + 1)) * uint64(unsafe.Sizeof(uintptr(0))))) var apNew uintptr = Xsqlite3_realloc64(tls, (*Rbu_file)(unsafe.Pointer(p)).FapShm, uint64(nByte)) @@ -163903,24 +161189,24 @@ func rbuVfsShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, szRegion int32, i // from start to finish. if apNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, (apNew + uintptr((*Rbu_file)(unsafe.Pointer(p)).FnShm)*8), 0, (uint64(unsafe.Sizeof(uintptr(0))) * (uint64((1 + iRegion) - (*Rbu_file)(unsafe.Pointer(p)).FnShm)))) (*Rbu_file)(unsafe.Pointer(p)).FapShm = apNew (*Rbu_file)(unsafe.Pointer(p)).FnShm = (iRegion + 1) } - if rc == 0 { + if rc == SQLITE_OK { var pNew uintptr = Xsqlite3_malloc64(tls, uint64(szRegion)) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, pNew, 0, uint64(szRegion)) *(*uintptr)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FapShm + uintptr(iRegion)*8)) = pNew } } - if rc == 0 { + if rc == SQLITE_OK { *(*uintptr)(unsafe.Pointer(libc.AtomicLoadUintptr(&pp))) = *(*uintptr)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FapShm + uintptr(iRegion)*8)) } else { *(*uintptr)(unsafe.Pointer(libc.AtomicLoadUintptr(&pp))) = uintptr(0) @@ -163942,7 +161228,7 @@ func rbuVfsShmBarrier(tls *libc.TLS, pFile uintptr) { /* sqlite3.c:200767:13: */ // The xShmUnmap method. func rbuVfsShmUnmap(tls *libc.TLS, pFile uintptr, delFlag int32) int32 { /* sqlite3.c:200775:12: */ var p uintptr = pFile - var rc int32 = 0 + var rc int32 = SQLITE_OK var eStage int32 = func() int32 { if (*Rbu_file)(unsafe.Pointer(p)).FpRbu != 0 { return (*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage @@ -163950,7 +161236,7 @@ func rbuVfsShmUnmap(tls *libc.TLS, pFile uintptr, delFlag int32) int32 { /* sqli return 0 }() - if (eStage == 1) || (eStage == 2) { + if (eStage == RBU_STAGE_OAL) || (eStage == RBU_STAGE_MOVE) { // no-op } else { // Release the checkpointer and writer locks @@ -163965,26 +161251,26 @@ func rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags var pRbuVfs uintptr = pVfs var pRealVfs uintptr = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRealVfs var pFd uintptr = pFile - var rc int32 = 0 + var rc int32 = SQLITE_OK var zOpen uintptr = zName var oflags int32 = flags libc.Xmemset(tls, pFd, 0, uint64(unsafe.Sizeof(Rbu_file{}))) - (*Rbu_file)(unsafe.Pointer(pFd)).FpReal = (pFd + uintptr(1)*104) + (*Rbu_file)(unsafe.Pointer(pFd)).FpReal = (pFd + 1*104) (*Rbu_file)(unsafe.Pointer(pFd)).FpRbuVfs = pRbuVfs (*Rbu_file)(unsafe.Pointer(pFd)).FopenFlags = flags if zName != 0 { - if (flags & 0x00000100) != 0 { + if (flags & SQLITE_OPEN_MAIN_DB) != 0 { // A main database has just been opened. The following block sets // (pFd->zWal) to point to a buffer owned by SQLite that contains // the name of the *-wal file this db connection will use. SQLite // happens to pass a pointer to this buffer when using xAccess() // or xOpen() to operate on the *-wal file. (*Rbu_file)(unsafe.Pointer(pFd)).FzWal = Xsqlite3_filename_wal(tls, zName) - } else if (flags & 0x00080000) != 0 { + } else if (flags & SQLITE_OPEN_WAL) != 0 { var pDb uintptr = rbuFindMaindb(tls, pRbuVfs, zName, 0) if pDb != 0 { - if ((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == 1) { + if ((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu != 0) && ((*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == RBU_STAGE_OAL) { // This call is to open a *-wal file. Intead, open the *-oal. This // code ensures that the string passed to xOpen() is terminated by a // pair of '\0' bytes in case the VFS attempts to extract a URI @@ -164005,7 +161291,7 @@ func rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags *(*int8)(unsafe.Pointer(zCopy + uintptr((nCopy + uint64(1))))) = int8(0) zOpen = libc.AssignPtrUintptr(pFd+64 /* &.zDel */, zCopy) } else { - rc = 7 + rc = SQLITE_NOMEM } (*Rbu_file)(unsafe.Pointer(pFd)).FpRbu = (*Rbu_file)(unsafe.Pointer(pDb)).FpRbu } @@ -164016,14 +161302,14 @@ func rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags (*Rbu_file)(unsafe.Pointer(pFd)).FpRbu = (*Rbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRbu } - if ((oflags & 0x00000100) != 0) && + if ((oflags & SQLITE_OPEN_MAIN_DB) != 0) && (Xsqlite3_uri_boolean(tls, zName, ts+35578 /* "rbu_memory" */, 0) != 0) { - oflags = ((((0x00000200 | 0x00000002) | 0x00000004) | 0x00000010) | 0x00000008) + oflags = ((((SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_READWRITE) | SQLITE_OPEN_CREATE) | SQLITE_OPEN_EXCLUSIVE) | SQLITE_OPEN_DELETEONCLOSE) zOpen = uintptr(0) } - if rc == 0 { + if rc == SQLITE_OK { rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pRealVfs + 40 /* &.xOpen */))))(tls, pRealVfs, zOpen, (*Rbu_file)(unsafe.Pointer(pFd)).FpReal, oflags, pOutFlags) } if (*Sqlite3_file)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pFd)).FpReal)).FpMethods != 0 { @@ -164031,7 +161317,7 @@ func rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags // pointer and, if the file is a main database file, link it into the // mutex protected linked list of all such files. (*Sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&rbuvfs_io_methods)) - if (flags & 0x00000100) != 0 { + if (flags & SQLITE_OPEN_MAIN_DB) != 0 { rbuMainlistAdd(tls, pFd) } } else { @@ -164042,42 +161328,23 @@ func rbuVfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags } var rbuvfs_io_methods = Sqlite3_io_methods{ - FiVersion: 2, - FxClose:// iVersion - 0, - FxRead:// xClose - 0, - FxWrite:// xRead - 0, - FxTruncate:// xWrite - 0, - FxSync:// xTruncate - 0, - FxFileSize:// xSync - 0, - FxLock:// xFileSize - 0, - FxUnlock:// xLock - 0, - FxCheckReservedLock:// xUnlock - 0, - FxFileControl:// xCheckReservedLock - 0, - FxSectorSize:// xFileControl - 0, - FxDeviceCharacteristics:// xSectorSize - 0, - FxShmMap:// xDeviceCharacteristics - 0, - FxShmLock:// xShmMap - 0, - FxShmBarrier:// xShmLock - 0, - FxShmUnmap:// xShmBarrier - 0, - FxFetch:// xShmUnmap - uintptr(0), - FxUnfetch: uintptr(0), // xFetch, xUnfetch + FiVersion: 2, // iVersion + FxClose: 0, // xClose + FxRead: 0, // xRead + FxWrite: 0, // xWrite + FxTruncate: 0, // xTruncate + FxSync: 0, // xSync + FxFileSize: 0, // xFileSize + FxLock: 0, // xLock + FxUnlock: 0, // xUnlock + FxCheckReservedLock: 0, // xCheckReservedLock + FxFileControl: 0, // xFileControl + FxSectorSize: 0, // xSectorSize + FxDeviceCharacteristics: 0, // xDeviceCharacteristics + FxShmMap: 0, // xShmMap + FxShmLock: 0, // xShmLock + FxShmBarrier: 0, // xShmBarrier + FxShmUnmap: 0, // xFetch, xUnfetch } /* sqlite3.c:200801:29 */ // Delete the file located at zPath. @@ -164111,12 +161378,12 @@ func rbuVfsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResO // causing SQLite to call xOpen() to open it. This call will also // be intercepted (see the rbuVfsOpen() function) and the *-oal // file opened instead. - if (rc == 0) && (flags == 0) { + if (rc == SQLITE_OK) && (flags == SQLITE_ACCESS_EXISTS) { var pDb uintptr = rbuFindMaindb(tls, pRbuVfs, zPath, 1) - if (pDb != 0) && ((*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == 1) { + if (pDb != 0) && ((*Sqlite3rbu)(unsafe.Pointer((*Rbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == RBU_STAGE_OAL) { if *(*int32)(unsafe.Pointer(pResOut)) != 0 { - rc = 14 + rc = SQLITE_CANTOPEN } else { *(*Sqlite3_int64)(unsafe.Pointer(bp /* sz */)) = int64(0) rc = rbuVfsFileSize(tls, (pDb /* &.base */), bp /* &sz */) @@ -164206,7 +161473,7 @@ func Xsqlite3rbu_destroy_vfs(tls *libc.TLS, zName uintptr) { /* sqlite3.c:201050 func Xsqlite3rbu_create_vfs(tls *libc.TLS, zName uintptr, zParent uintptr) int32 { /* sqlite3.c:201064:16: */ var pNew uintptr = uintptr(0) // Newly allocated VFS - var rc int32 = 0 + var rc int32 = SQLITE_OK var nName Size_t var nByte Size_t @@ -164214,32 +161481,32 @@ func Xsqlite3rbu_create_vfs(tls *libc.TLS, zName uintptr, zParent uintptr) int32 nByte = ((uint64(unsafe.Sizeof(Rbu_vfs{})) + nName) + uint64(1)) pNew = Xsqlite3_malloc64(tls, uint64(nByte)) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var pParent uintptr // Parent VFS libc.Xmemset(tls, pNew, 0, nByte) pParent = Xsqlite3_vfs_find(tls, zParent) if pParent == uintptr(0) { - rc = 12 + rc = SQLITE_NOTFOUND } else { var zSpace uintptr libc.Xmemcpy(tls, (pNew /* &.base */), uintptr(unsafe.Pointer(&vfs_template)), uint64(unsafe.Sizeof(Sqlite3_vfs{}))) (*Rbu_vfs)(unsafe.Pointer(pNew)).Fbase.FmxPathname = (*Sqlite3_vfs)(unsafe.Pointer(pParent)).FmxPathname (*Rbu_vfs)(unsafe.Pointer(pNew)).Fbase.FszOsFile = (int32(uint64(unsafe.Sizeof(Rbu_file{})) + uint64((*Sqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile))) (*Rbu_vfs)(unsafe.Pointer(pNew)).FpRealVfs = pParent - (*Rbu_vfs)(unsafe.Pointer(pNew)).Fbase.FzName = libc.AssignUintptr(&zSpace, (pNew + uintptr(1)*208)) + (*Rbu_vfs)(unsafe.Pointer(pNew)).Fbase.FzName = libc.AssignUintptr(&zSpace, (pNew + 1*208)) libc.Xmemcpy(tls, zSpace, zName, nName) // Allocate the mutex and register the new VFS (not as the default) - (*Rbu_vfs)(unsafe.Pointer(pNew)).Fmutex = Xsqlite3_mutex_alloc(tls, 1) + (*Rbu_vfs)(unsafe.Pointer(pNew)).Fmutex = Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_RECURSIVE) if (*Rbu_vfs)(unsafe.Pointer(pNew)).Fmutex == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_vfs_register(tls, (pNew /* &.base */), 0) } } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_mutex_free(tls, (*Rbu_vfs)(unsafe.Pointer(pNew)).Fmutex) Xsqlite3_free(tls, pNew) } @@ -164249,49 +161516,21 @@ func Xsqlite3rbu_create_vfs(tls *libc.TLS, zName uintptr, zParent uintptr) int32 } var vfs_template = Sqlite3_vfs{ - FiVersion: 1, - FszOsFile:// iVersion - 0, - FmxPathname:// szOsFile - 0, - FpNext:// mxPathname - uintptr(0), - FzName:// pNext - uintptr(0), - FpAppData:// zName - uintptr(0), - FxOpen:// pAppData - 0, - FxDelete:// xOpen - 0, - FxAccess:// xDelete - 0, - FxFullPathname:// xAccess - 0, - FxDlOpen:// xFullPathname + FiVersion: 1, // pAppData + FxOpen: 0, // xOpen + FxDelete: 0, // xDelete + FxAccess: 0, // xAccess + FxFullPathname: 0, // xFullPathname - 0, - FxDlError:// xDlOpen - 0, - FxDlSym:// xDlError - 0, - FxDlClose:// xDlSym - 0, - FxRandomness:// xDlClose + FxDlOpen: 0, // xDlOpen + FxDlError: 0, // xDlError + FxDlSym: 0, // xDlSym + FxDlClose: 0, // xDlClose - 0, - FxSleep:// xRandomness - 0, - FxCurrentTime:// xSleep - 0, - FxGetLastError:// xCurrentTime - 0, - FxCurrentTimeInt64:// xGetLastError - uintptr(0), - FxSetSystemCall:// xCurrentTimeInt64 (version 2) - uintptr(0), - FxGetSystemCall: uintptr(0), - FxNextSystemCall: uintptr(0), // Unimplemented version 3 methods + FxRandomness: 0, // xRandomness + FxSleep: 0, // xSleep + FxCurrentTime: 0, // xCurrentTime + FxGetLastError: 0, // Unimplemented version 3 methods } /* sqlite3.c:201067:22 */ // Configure the aggregate temp file size limit for this RBU handle. @@ -164362,7 +161601,21 @@ func Xsqlite3rbu_temp_size(tls *libc.TLS, pRbu uintptr) Sqlite3_int64 { /* sqlit // sort-order than its child page: // // '/1c2/000/' // Left-most child of 451st child of root -var zDbstatSchema = *(*[258]int8)(unsafe.Pointer(ts + 35589 /* "CREATE TABLE x( ..." */)) /* sqlite3.c:201218:19 */ +var zDbstatSchema = + +// 0 Name of table or index +// 1 Path to page from root (NULL for agg) +// 2 Page number (page count for aggregates) +// 3 'internal', 'leaf', 'overflow', or NULL +// 4 Cells on page (0 for overflow) +// 5 Bytes of payload on this page +// 6 Bytes of unused space on this page +// 7 Largest payload size of all cells +// 8 Offset of page in file (NULL for agg) +// 9 Size of the page (sum for aggregate) +// 10 Database schema being analyzed +// 11 aggregate info for each table +*(*[258]int8)(unsafe.Pointer(ts + 35589 /* "CREATE TABLE x( ..." */)) /* sqlite3.c:201218:19 */ // Forward reference to data structured used in this module type StatTable1 = struct { @@ -164434,31 +161687,31 @@ func statConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintp defer tls.Free(24) var pTab uintptr = uintptr(0) - var rc int32 = 0 + var rc int32 = SQLITE_OK var iDb int32 if argc >= 4 { // var nm Token at bp+8, 16 - Xsqlite3TokenInit(tls, bp+8 /* &nm */, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) + Xsqlite3TokenInit(tls, bp+8 /* &nm */, *(*uintptr)(unsafe.Pointer(argv + 3*8))) iDb = Xsqlite3FindDb(tls, db, bp+8 /* &nm */) if iDb < 0 { - *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+13011 /* "no such database..." */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)))) - return 1 + *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+13011 /* "no such database..." */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + 3*8)))) + return SQLITE_ERROR } } else { iDb = 0 } - Xsqlite3_vtab_config(tls, db, 3, 0) + Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_DIRECTONLY, 0) rc = Xsqlite3_declare_vtab(tls, db, uintptr(unsafe.Pointer(&zDbstatSchema))) - if rc == 0 { + if rc == SQLITE_OK { pTab = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(StatTable{}))) if pTab == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } } - if rc == 0 { + if rc == SQLITE_OK { libc.Xmemset(tls, pTab, 0, uint64(unsafe.Sizeof(StatTable{}))) (*StatTable)(unsafe.Pointer(pTab)).Fdb = db (*StatTable)(unsafe.Pointer(pTab)).FiDb = iDb @@ -164471,7 +161724,7 @@ func statConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintp // Disconnect from or destroy the DBSTAT virtual table. func statDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:201350:12: */ Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // Compute the best query strategy and return the result in idxNum. @@ -164493,12 +161746,12 @@ func statBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sqli // lower the cost estimate to encourage the constrained version to be // used. for i = 0; i < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; i++ { - if int32((*sqlite3_index_constraint)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint+uintptr(i)*12)).Fop) != 2 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint+uintptr(i)*12)).Fop) != SQLITE_INDEX_CONSTRAINT_EQ { continue } if int32((*sqlite3_index_constraint)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint+uintptr(i)*12)).Fusable) == 0 { // Force DBSTAT table should always be the right-most table in a join - return 19 + return SQLITE_CONSTRAINT } switch (*sqlite3_index_constraint)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12)).FiColumn { case 0: @@ -164541,17 +161794,17 @@ func statBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sqli // If this will satisfy the client, set the orderByConsumed flag so that // SQLite does not do an external sort. if ((((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1) && - ((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).FiColumn == 0)) && - (int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).Fdesc) == 0)) || ((((((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 2) && - ((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).FiColumn == 0)) && - (int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).Fdesc) == 0)) && - ((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(1)*8)).FiColumn == 1)) && - (int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(1)*8)).Fdesc) == 0)) { + ((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn == 0)) && + (int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0)) || ((((((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 2) && + ((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn == 0)) && + (int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0)) && + ((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+1*8)).FiColumn == 1)) && + (int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+1*8)).Fdesc) == 0)) { (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 *(*int32)(unsafe.Pointer(pIdxInfo + 40 /* &.idxNum */)) |= (0x08) } - return 0 + return SQLITE_OK } // Open a new DBSTAT cursor. @@ -164561,7 +161814,7 @@ func statOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* sqlite3 pCsr = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(StatCursor{}))) if pCsr == uintptr(0) { - return 7 + return SQLITE_NOMEM } else { libc.Xmemset(tls, pCsr, 0, uint64(unsafe.Sizeof(StatCursor{}))) (*StatCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVTab @@ -164569,7 +161822,7 @@ func statOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* sqlite3 } *(*uintptr)(unsafe.Pointer(ppCursor)) = pCsr - return 0 + return SQLITE_OK } func statClearCells(tls *libc.TLS, p uintptr) { /* sqlite3.c:201455:13: */ @@ -164619,7 +161872,7 @@ func statClose(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:201499:12: * statResetCsr(tls, pCsr) Xsqlite3_finalize(tls, (*StatCursor)(unsafe.Pointer(pCsr)).FpStmt) Xsqlite3_free(tls, pCsr) - return 0 + return SQLITE_OK } // For a single cell on a btree page, compute the number of bytes of @@ -164681,7 +161934,7 @@ func statDecodePage(tls *libc.TLS, pBt uintptr, p uintptr) int32 { /* sqlite3.c: return 0 }())) - (*StatPage)(unsafe.Pointer(p)).Fflags = *(*U8)(unsafe.Pointer(aHdr + uintptr(0))) + (*StatPage)(unsafe.Pointer(p)).Fflags = *(*U8)(unsafe.Pointer(aHdr)) if !((int32((*StatPage)(unsafe.Pointer(p)).Fflags) == 0x0A) || (int32((*StatPage)(unsafe.Pointer(p)).Fflags) == 0x0D)) { goto __1 } @@ -164707,13 +161960,13 @@ __2: nHdr = nHdr + (100) __5: ; - (*StatPage)(unsafe.Pointer(p)).FnCell = ((int32(*(*U8)(unsafe.Pointer((aHdr + uintptr(3)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aHdr + uintptr(3)) + uintptr(1))))) + (*StatPage)(unsafe.Pointer(p)).FnCell = ((int32(*(*U8)(unsafe.Pointer((aHdr + 3)))) << 8) | int32(*(*U8)(unsafe.Pointer((aHdr + 3) + 1)))) (*StatPage)(unsafe.Pointer(p)).FnMxPayload = 0 szPage = Xsqlite3BtreeGetPageSize(tls, pBt) - nUnused = ((((int32(*(*U8)(unsafe.Pointer((aHdr + uintptr(5)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aHdr + uintptr(5)) + uintptr(1))))) - nHdr) - (2 * (*StatPage)(unsafe.Pointer(p)).FnCell)) - nUnused = nUnused + (int32(*(*U8)(unsafe.Pointer(aHdr + uintptr(7))))) - iOff = ((int32(*(*U8)(unsafe.Pointer((aHdr + uintptr(1)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aHdr + uintptr(1)) + uintptr(1))))) + nUnused = ((((int32(*(*U8)(unsafe.Pointer((aHdr + 5)))) << 8) | int32(*(*U8)(unsafe.Pointer((aHdr + 5) + 1)))) - nHdr) - (2 * (*StatPage)(unsafe.Pointer(p)).FnCell)) + nUnused = nUnused + (int32(*(*U8)(unsafe.Pointer(aHdr + 7)))) + iOff = ((int32(*(*U8)(unsafe.Pointer((aHdr + 1)))) << 8) | int32(*(*U8)(unsafe.Pointer((aHdr + 1) + 1)))) __6: if !(iOff != 0) { goto __7 @@ -164724,8 +161977,8 @@ __6: goto statPageIsCorrupt __8: ; - nUnused = nUnused + ((int32(*(*U8)(unsafe.Pointer((aData + uintptr((iOff + 2))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((iOff + 2))) + uintptr(1))))) - iNext = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr(iOff)) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr(iOff)) + uintptr(1))))) + nUnused = nUnused + ((int32(*(*U8)(unsafe.Pointer((aData + uintptr((iOff + 2)))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((iOff + 2))) + 1)))) + iNext = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr(iOff))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr(iOff)) + 1)))) if !((iNext < (iOff + 4)) && (iNext > 0)) { goto __9 } @@ -164741,7 +161994,7 @@ __7: if isLeaf != 0 { return uint32(0) } - return Xsqlite3Get4byte(tls, (aHdr + uintptr(8))) + return Xsqlite3Get4byte(tls, (aHdr + 8)) }() if !((*StatPage)(unsafe.Pointer(p)).FnCell != 0) { @@ -164755,7 +162008,7 @@ __7: if !((*StatPage)(unsafe.Pointer(p)).FaCell == uintptr(0)) { goto __11 } - return 7 + return SQLITE_NOMEM __11: ; libc.Xmemset(tls, (*StatPage)(unsafe.Pointer(p)).FaCell, 0, ((uint64((*StatPage)(unsafe.Pointer(p)).FnCell + 1)) * uint64(unsafe.Sizeof(StatCell{})))) @@ -164767,7 +162020,7 @@ __12: } pCell = ((*StatPage)(unsafe.Pointer(p)).FaCell + uintptr(i)*32) - iOff = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr((nHdr + (i * 2)))) + uintptr(0)))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((nHdr + (i * 2)))) + uintptr(1))))) + iOff = ((int32(*(*U8)(unsafe.Pointer((aData + uintptr((nHdr + (i * 2))))))) << 8) | int32(*(*U8)(unsafe.Pointer((aData + uintptr((nHdr + (i * 2)))) + 1)))) if !((iOff < nHdr) || (iOff >= szPage)) { goto __15 } @@ -164833,10 +162086,10 @@ __23: if !((*StatCell)(unsafe.Pointer(pCell)).FaOvfl == uintptr(0)) { goto __24 } - return 7 + return SQLITE_NOMEM __24: ; - *(*U32)(unsafe.Pointer((*StatCell)(unsafe.Pointer(pCell)).FaOvfl + uintptr(0)*4)) = Xsqlite3Get4byte(tls, (aData + uintptr((iOff + nLocal)))) + *(*U32)(unsafe.Pointer((*StatCell)(unsafe.Pointer(pCell)).FaOvfl)) = Xsqlite3Get4byte(tls, (aData + uintptr((iOff + nLocal)))) j = 1 __25: if !(j < nOvfl) { @@ -164845,7 +162098,7 @@ __25: iPrev = *(*U32)(unsafe.Pointer((*StatCell)(unsafe.Pointer(pCell)).FaOvfl + uintptr((j-1))*4)) *(*uintptr)(unsafe.Pointer(bp + 16 /* pPg */)) = uintptr(0) rc = Xsqlite3PagerGet(tls, Xsqlite3BtreePager(tls, pBt), iPrev, bp+16 /* &pPg */, 0) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __28 } @@ -164875,12 +162128,12 @@ __14: __10: ; - return 0 + return SQLITE_OK statPageIsCorrupt: (*StatPage)(unsafe.Pointer(p)).Fflags = U8(0) statClearCells(tls, p) - return 0 + return SQLITE_OK } // Populate the pCsr->iOffset and pCsr->szPage member variables. Based on @@ -164898,10 +162151,10 @@ func statSizeAndOffset(tls *libc.TLS, pCsr uintptr) { /* sqlite3.c:201652:13: */ // If connected to a ZIPVFS backend, find the page size and // offset from ZIPVFS. fd = Xsqlite3PagerFile(tls, pPager) - *(*Sqlite3_int64)(unsafe.Pointer(bp /* &x[0] */ + uintptr(0)*8)) = Sqlite3_int64((*StatCursor)(unsafe.Pointer(pCsr)).FiPageno) - if Xsqlite3OsFileControl(tls, fd, 230440, bp /* &x */) == 0 { - (*StatCursor)(unsafe.Pointer(pCsr)).FiOffset = *(*Sqlite3_int64)(unsafe.Pointer(bp /* &x[0] */ + uintptr(0)*8)) - *(*I64)(unsafe.Pointer(pCsr + 2144 /* &.szPage */)) += (*(*Sqlite3_int64)(unsafe.Pointer(bp /* &x[0] */ + uintptr(1)*8))) + *(*Sqlite3_int64)(unsafe.Pointer(bp /* &x[0] */)) = Sqlite3_int64((*StatCursor)(unsafe.Pointer(pCsr)).FiPageno) + if Xsqlite3OsFileControl(tls, fd, 230440, bp /* &x */) == SQLITE_OK { + (*StatCursor)(unsafe.Pointer(pCsr)).FiOffset = *(*Sqlite3_int64)(unsafe.Pointer(bp /* &x[0] */)) + *(*I64)(unsafe.Pointer(pCsr + 2144 /* &.szPage */)) += (*(*Sqlite3_int64)(unsafe.Pointer(bp /* &x[0] */ + 1*8))) } else { // Not ZIPVFS: The default page size and offset *(*I64)(unsafe.Pointer(pCsr + 2144 /* &.szPage */)) += (I64(Xsqlite3BtreeGetPageSize(tls, pBt))) @@ -164942,13 +162195,13 @@ func statNext(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:201679:12: */ (*StatCursor)(unsafe.Pointer(pCsr)).FzPath = uintptr(0) statNextRestart: - if !((*StatPage)(unsafe.Pointer((pCsr+24 /* &.aPage */)+uintptr(0)*64)).FpPg == uintptr(0)) { + if !((*StatPage)(unsafe.Pointer((pCsr + 24 /* &.aPage */))).FpPg == uintptr(0)) { goto __1 } // Start measuring space on the next btree statResetCounts(tls, pCsr) rc = Xsqlite3_step(tls, (*StatCursor)(unsafe.Pointer(pCsr)).FpStmt) - if !(rc == 100) { + if !(rc == SQLITE_ROW) { goto __3 } iRoot = U32(Xsqlite3_column_int64(tls, (*StatCursor)(unsafe.Pointer(pCsr)).FpStmt, 1)) @@ -164960,17 +162213,17 @@ statNextRestart: return Xsqlite3_reset(tls, (*StatCursor)(unsafe.Pointer(pCsr)).FpStmt) __5: ; - rc = Xsqlite3PagerGet(tls, pPager, iRoot, ((pCsr + 24 /* &.aPage */) + uintptr(0)*64 + 8 /* &.pPg */), 0) - (*StatPage)(unsafe.Pointer((pCsr + 24 /* &.aPage */) + uintptr(0)*64)).FiPgno = iRoot - (*StatPage)(unsafe.Pointer((pCsr + 24 /* &.aPage */) + uintptr(0)*64)).FiCell = 0 + rc = Xsqlite3PagerGet(tls, pPager, iRoot, ((pCsr + 24 /* &.aPage */) + 8 /* &.pPg */), 0) + (*StatPage)(unsafe.Pointer((pCsr + 24 /* &.aPage */))).FiPgno = iRoot + (*StatPage)(unsafe.Pointer((pCsr + 24 /* &.aPage */))).FiCell = 0 if !(!(int32((*StatCursor)(unsafe.Pointer(pCsr)).FisAgg) != 0)) { goto __6 } - (*StatPage)(unsafe.Pointer((pCsr + 24 /* &.aPage */) + uintptr(0)*64)).FzPath = libc.AssignUintptr(&z, Xsqlite3_mprintf(tls, ts+35847 /* "/" */, 0)) + (*StatPage)(unsafe.Pointer((pCsr + 24 /* &.aPage */))).FzPath = libc.AssignUintptr(&z, Xsqlite3_mprintf(tls, ts+35847 /* "/" */, 0)) if !(z == uintptr(0)) { goto __7 } - rc = 7 + rc = SQLITE_NOMEM __7: ; __6: @@ -165028,9 +162281,9 @@ __14: (*StatCursor)(unsafe.Pointer(pCsr)).FzPath = libc.AssignUintptr(&z, Xsqlite3_mprintf(tls, ts+35858 /* "%s%.3x+%.6x" */, libc.VaList(bp, (*StatPage)(unsafe.Pointer(p)).FzPath, (*StatPage)(unsafe.Pointer(p)).FiCell, iOvfl))) if z == uintptr(0) { - return 7 + return SQLITE_NOMEM } - return 0 + return SQLITE_OK __15: ; goto __11 @@ -165062,7 +162315,7 @@ __18: } // label-statNext-done: When computing aggregate space usage over // an entire btree, this is the exit point from this function - return 0 + return SQLITE_OK __20: ; __19: @@ -165082,23 +162335,23 @@ __21: if !((*StatPage)(unsafe.Pointer(p)).FiCell == (*StatPage)(unsafe.Pointer(p)).FnCell) { goto __22 } - (*StatPage)(unsafe.Pointer(p + uintptr(1)*64)).FiPgno = (*StatPage)(unsafe.Pointer(p)).FiRightChildPg + (*StatPage)(unsafe.Pointer(p + 1*64)).FiPgno = (*StatPage)(unsafe.Pointer(p)).FiRightChildPg goto __23 __22: - (*StatPage)(unsafe.Pointer(p + uintptr(1)*64)).FiPgno = (*StatCell)(unsafe.Pointer((*StatPage)(unsafe.Pointer(p)).FaCell + uintptr((*StatPage)(unsafe.Pointer(p)).FiCell)*32)).FiChildPg + (*StatPage)(unsafe.Pointer(p + 1*64)).FiPgno = (*StatCell)(unsafe.Pointer((*StatPage)(unsafe.Pointer(p)).FaCell + uintptr((*StatPage)(unsafe.Pointer(p)).FiCell)*32)).FiChildPg __23: ; - rc = Xsqlite3PagerGet(tls, pPager, (*StatPage)(unsafe.Pointer(p+uintptr(1)*64)).FiPgno, (p + uintptr(1)*64 + 8 /* &.pPg */), 0) + rc = Xsqlite3PagerGet(tls, pPager, (*StatPage)(unsafe.Pointer(p+1*64)).FiPgno, (p + 1*64 + 8 /* &.pPg */), 0) (*StatCursor)(unsafe.Pointer(pCsr)).FnPage++ - (*StatPage)(unsafe.Pointer(p + uintptr(1)*64)).FiCell = 0 + (*StatPage)(unsafe.Pointer(p + 1*64)).FiCell = 0 if !(!(int32((*StatCursor)(unsafe.Pointer(pCsr)).FisAgg) != 0)) { goto __24 } - (*StatPage)(unsafe.Pointer(p + uintptr(1)*64)).FzPath = libc.AssignUintptr(&z, Xsqlite3_mprintf(tls, ts+35870 /* "%s%.3x/" */, libc.VaList(bp+24, (*StatPage)(unsafe.Pointer(p)).FzPath, (*StatPage)(unsafe.Pointer(p)).FiCell))) + (*StatPage)(unsafe.Pointer(p + 1*64)).FzPath = libc.AssignUintptr(&z, Xsqlite3_mprintf(tls, ts+35870 /* "%s%.3x/" */, libc.VaList(bp+24, (*StatPage)(unsafe.Pointer(p)).FzPath, (*StatPage)(unsafe.Pointer(p)).FiCell))) if !(z == uintptr(0)) { goto __25 } - rc = 7 + rc = SQLITE_NOMEM __25: ; __24: @@ -165109,7 +162362,7 @@ __2: // Populate the StatCursor fields with the values to be returned // by the xColumn() and xRowid() methods. - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __26 } p1 = ((pCsr + 24 /* &.aPage */) + uintptr((*StatCursor)(unsafe.Pointer(pCsr)).FiPage)*64) @@ -165117,7 +162370,7 @@ __2: (*StatCursor)(unsafe.Pointer(pCsr)).FiPageno = (*StatPage)(unsafe.Pointer(p1)).FiPgno rc = statDecodePage(tls, pBt, p1) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __27 } statSizeAndOffset(tls, pCsr) @@ -165163,7 +162416,7 @@ __34: if !(z == uintptr(0)) { goto __36 } - rc = 7 + rc = SQLITE_NOMEM __36: ; __35: @@ -165217,7 +162470,7 @@ func statFilter(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, ar var pSql uintptr // Query of btrees to analyze var zSql uintptr // String value of pSql var iArg int32 = 0 // Count of argv[] parameters used so far - var rc int32 = 0 // Result of this operation + var rc int32 = SQLITE_OK // Result of this operation var zName uintptr = uintptr(0) // Only provide analysis of this table statResetCsr(tls, pCsr) @@ -165230,7 +162483,7 @@ func statFilter(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, ar if (*StatCursor)(unsafe.Pointer(pCsr)).FiDb < 0 { (*StatCursor)(unsafe.Pointer(pCsr)).FiDb = 0 (*StatCursor)(unsafe.Pointer(pCsr)).FisEof = U8(1) - return 0 + return SQLITE_OK } } else { (*StatCursor)(unsafe.Pointer(pCsr)).FiDb = (*StatTable)(unsafe.Pointer(pTab)).FiDb @@ -165258,13 +162511,13 @@ func statFilter(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, ar } zSql = Xsqlite3_str_finish(tls, pSql) if zSql == uintptr(0) { - return 7 + return SQLITE_NOMEM } else { rc = Xsqlite3_prepare_v2(tls, (*StatTable)(unsafe.Pointer(pTab)).Fdb, zSql, -1, (pCsr + 8 /* &.pStmt */), uintptr(0)) Xsqlite3_free(tls, zSql) } - if rc == 0 { + if rc == SQLITE_OK { rc = statNext(tls, pCursor) } return rc @@ -165328,13 +162581,13 @@ func statColumn(tls *libc.TLS, pCursor uintptr, ctx uintptr, i int32) int32 { /* } } - return 0 + return SQLITE_OK } func statRowid(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { /* sqlite3.c:201972:12: */ var pCsr uintptr = pCursor *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = Sqlite_int64((*StatCursor)(unsafe.Pointer(pCsr)).FiPageno) - return 0 + return SQLITE_OK } // Invoke this routine to register the "dbstat" virtual table module @@ -165342,54 +162595,19 @@ func Xsqlite3DbstatRegister(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:2019 return Xsqlite3_create_module(tls, db, ts+36086 /* "dbstat" */, uintptr(unsafe.Pointer(&dbstat_module)), uintptr(0)) } -var dbstat_module = Sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - 0, - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var dbstat_module = Sqlite3_module{ // iVersion + FxCreate: 0, // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDisconnect + FxDestroy: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xShadowName } /* sqlite3.c:201982:25 */ //************* End of dbstat.c ********************************************* @@ -165485,19 +162703,19 @@ type DbpageCursor = DbpageCursor1 /* sqlite3.c:202054:29 */ // Connect to or create a dbpagevfs virtual table. func dbpageConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* sqlite3.c:202081:12: */ var pTab uintptr = uintptr(0) - var rc int32 = 0 + var rc int32 = SQLITE_OK - Xsqlite3_vtab_config(tls, db, 3, 0) + Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_DIRECTONLY, 0) rc = Xsqlite3_declare_vtab(tls, db, ts+36093 /* "CREATE TABLE x(p..." */) - if rc == 0 { + if rc == SQLITE_OK { pTab = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(DbpageTable{}))) if pTab == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } } - if rc == 0 { + if rc == SQLITE_OK { libc.Xmemset(tls, pTab, 0, uint64(unsafe.Sizeof(DbpageTable{}))) (*DbpageTable)(unsafe.Pointer(pTab)).Fdb = db } @@ -165509,7 +162727,7 @@ func dbpageConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uin // Disconnect from or destroy a dbpagevfs virtual table. func dbpageDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:202112:12: */ Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // idxNum: @@ -165527,15 +162745,15 @@ func dbpageBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sq // unavailable for i = 0; i < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; i++ { var p uintptr = ((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12) - if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn != 2 { + if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn != DBPAGE_COLUMN_SCHEMA { continue } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) != 2 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) != SQLITE_INDEX_CONSTRAINT_EQ { continue } if !(int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) != 0) { // No solution. - return 19 + return SQLITE_CONSTRAINT } iPlan = 2 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 @@ -165551,9 +162769,9 @@ func dbpageBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sq // Check for constraints against pgno for i = 0; i < (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; i++ { var p uintptr = ((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12) - if (((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn <= 0)) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2) { + if (((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn <= 0)) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) - (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = 1 + (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = SQLITE_INDEX_SCAN_UNIQUE (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1.0 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = func() int32 { if iPlan != 0 { @@ -165569,11 +162787,11 @@ func dbpageBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sq (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = iPlan if (((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy >= 1) && - ((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).FiColumn <= 0)) && - (int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy+uintptr(0)*8)).Fdesc) == 0) { + ((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn <= 0)) && + (int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0) { (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 } - return 0 + return SQLITE_OK } // Open a new dbpagevfs cursor. @@ -165582,7 +162800,7 @@ func dbpageOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* sqlit pCsr = Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(DbpageCursor{}))) if pCsr == uintptr(0) { - return 7 + return SQLITE_NOMEM } else { libc.Xmemset(tls, pCsr, 0, uint64(unsafe.Sizeof(DbpageCursor{}))) (*DbpageCursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab = pVTab @@ -165590,7 +162808,7 @@ func dbpageOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* sqlit } *(*uintptr)(unsafe.Pointer(ppCursor)) = pCsr - return 0 + return SQLITE_OK } // Close a dbpagevfs cursor. @@ -165600,12 +162818,12 @@ func dbpageClose(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:202199:12: Xsqlite3PagerUnrefPageOne(tls, (*DbpageCursor)(unsafe.Pointer(pCsr)).FpPage1) } Xsqlite3_free(tls, pCsr) - return 0 + return SQLITE_OK } // Move a dbpagevfs cursor to the next entry in the file. func dbpageNext(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:202209:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pCsr uintptr = pCursor (*DbpageCursor)(unsafe.Pointer(pCsr)).Fpgno++ return rc @@ -165638,17 +162856,17 @@ func dbpageFilter(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, if (idxNum & 2) != 0 { var zSchema uintptr - zSchema = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + zSchema = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) (*DbpageCursor)(unsafe.Pointer(pCsr)).FiDb = Xsqlite3FindDbName(tls, db, zSchema) if (*DbpageCursor)(unsafe.Pointer(pCsr)).FiDb < 0 { - return 0 + return SQLITE_OK } } else { (*DbpageCursor)(unsafe.Pointer(pCsr)).FiDb = 0 } pBt = (*Db)(unsafe.Pointer((*Sqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*DbpageCursor)(unsafe.Pointer(pCsr)).FiDb)*32)).FpBt if pBt == uintptr(0) { - return 0 + return SQLITE_OK } (*DbpageCursor)(unsafe.Pointer(pCsr)).FpPager = Xsqlite3BtreePager(tls, pBt) (*DbpageCursor)(unsafe.Pointer(pCsr)).FszPage = Xsqlite3BtreeGetPageSize(tls, pBt) @@ -165677,7 +162895,7 @@ func dbpageColumn(tls *libc.TLS, pCursor uintptr, ctx uintptr, i int32) int32 { defer tls.Free(8) var pCsr uintptr = pCursor - var rc int32 = 0 + var rc int32 = SQLITE_OK switch i { case 0: { // pgno @@ -165689,7 +162907,7 @@ func dbpageColumn(tls *libc.TLS, pCursor uintptr, ctx uintptr, i int32) int32 { { // data *(*uintptr)(unsafe.Pointer(bp /* pDbPage */)) = uintptr(0) rc = Xsqlite3PagerGet(tls, (*DbpageCursor)(unsafe.Pointer(pCsr)).FpPager, uint32((*DbpageCursor)(unsafe.Pointer(pCsr)).Fpgno), bp /* &pDbPage */, 0) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_result_blob(tls, ctx, Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp /* pDbPage */))), (*DbpageCursor)(unsafe.Pointer(pCsr)).FszPage, libc.UintptrFromInt32(-1)) } @@ -165705,13 +162923,13 @@ func dbpageColumn(tls *libc.TLS, pCursor uintptr, ctx uintptr, i int32) int32 { } } - return 0 + return SQLITE_OK } func dbpageRowid(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { /* sqlite3.c:202308:12: */ var pCsr uintptr = pCursor *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = Sqlite_int64((*DbpageCursor)(unsafe.Pointer(pCsr)).Fpgno) - return 0 + return SQLITE_OK } func dbpageUpdate(tls *libc.TLS, pVtab uintptr, argc int32, argv uintptr, pRowid uintptr) int32 { /* sqlite3.c:202314:12: */ @@ -165731,10 +162949,10 @@ func dbpageUpdate(tls *libc.TLS, pVtab uintptr, argc int32, argv uintptr, pRowid var szPage int32 pTab = pVtab *(*uintptr)(unsafe.Pointer(bp + 8 /* pDbPage */)) = uintptr(0) - rc = 0 + rc = SQLITE_OK zErr = uintptr(0) - if !(((*Sqlite3)(unsafe.Pointer((*DbpageTable)(unsafe.Pointer(pTab)).Fdb)).Fflags & uint64(0x10000000)) != 0) { + if !(((*Sqlite3)(unsafe.Pointer((*DbpageTable)(unsafe.Pointer(pTab)).Fdb)).Fflags & SQLITE_Defensive) != 0) { goto __1 } zErr = ts + 36160 /* "read-only" */ @@ -165748,15 +162966,15 @@ __1: goto update_fail __2: ; - pgno = Pgno(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) - if !(Pgno(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)))) != pgno) { + pgno = Pgno(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv)))) + if !(Pgno(Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) != pgno) { goto __3 } zErr = ts + 36184 /* "cannot insert" */ goto update_fail __3: ; - zSchema = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8))) + zSchema = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) if zSchema != 0 { iDb = Xsqlite3FindDbName(tls, (*DbpageTable)(unsafe.Pointer(pTab)).Fdb, zSchema) } else { @@ -165778,8 +162996,8 @@ __4: __5: ; szPage = Xsqlite3BtreeGetPageSize(tls, pBt) - if !((Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) != 4) || - (Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))) != szPage)) { + if !((Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) != SQLITE_BLOB) || + (Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) != szPage)) { goto __6 } zErr = ts + 36229 /* "bad page value" */ @@ -165788,15 +163006,15 @@ __6: ; pPager = Xsqlite3BtreePager(tls, pBt) rc = Xsqlite3PagerGet(tls, pPager, pgno, bp+8 /* &pDbPage */, 0) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __7 } rc = Xsqlite3PagerWrite(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pDbPage */))) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __8 } libc.Xmemcpy(tls, Xsqlite3PagerGetData(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pDbPage */))), - Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8))), + Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))), uint64(szPage)) __8: ; @@ -165808,7 +163026,7 @@ __7: update_fail: Xsqlite3_free(tls, (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg) (*Sqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp, zErr)) - return 1 + return SQLITE_ERROR } // Since we do not know in advance which database files will be @@ -165824,7 +163042,7 @@ func dbpageBegin(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:202385:12: * Xsqlite3BtreeBeginTrans(tls, pBt, 1, uintptr(0)) } } - return 0 + return SQLITE_OK } // Invoke this routine to register the "dbpage" virtual table module @@ -165832,54 +163050,21 @@ func Xsqlite3DbpageRegister(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:2024 return Xsqlite3_create_module(tls, db, ts+36244 /* "sqlite_dbpage" */, uintptr(unsafe.Pointer(&dbpage_module)), uintptr(0)) } -var dbpage_module = Sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - 0, - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - 0, - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - 0, - FxBegin:// xUpdate - 0, - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var dbpage_module = Sqlite3_module{ // iVersion + FxCreate: 0, // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDisconnect + FxDestroy: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xRowid - read data + FxUpdate: 0, // xUpdate + FxBegin: 0, // xShadowName } /* sqlite3.c:202401:25 */ //************* End of dbpage.c ********************************************* @@ -166608,9 +163793,9 @@ func sqlite3Fts5ParserInit(tls *libc.TLS, fts5yypRawParser uintptr) { /* sqlite3 var fts5yypParser uintptr = fts5yypRawParser (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos = fts5yypParser + 16 /* &.fts5yystack */ - (*Fts5yyStackEntry)(unsafe.Pointer((fts5yypParser + 16 /* &.fts5yystack */) + uintptr(0)*24)).Fstateno = uint8(0) - (*Fts5yyStackEntry)(unsafe.Pointer((fts5yypParser + 16 /* &.fts5yystack */) + uintptr(0)*24)).Fmajor = uint8(0) - (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystackEnd = ((fts5yypParser + 16 /* &.fts5yystack */) + uintptr((100-1))*24) + (*Fts5yyStackEntry)(unsafe.Pointer((fts5yypParser + 16 /* &.fts5yystack */))).Fstateno = uint8(0) + (*Fts5yyStackEntry)(unsafe.Pointer((fts5yypParser + 16 /* &.fts5yystack */))).Fmajor = uint8(0) + (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystackEnd = ((fts5yypParser + 16 /* &.fts5yystack */) + 99*24) } // This function allocates a new parser. @@ -166745,7 +163930,7 @@ func sqlite3Fts5ParserFree(tls *libc.TLS, p uintptr, freeProc uintptr) { /* sqli func fts5yy_find_shift_action(tls *libc.TLS, iLookAhead uint8, stateno uint8) uint8 { /* sqlite3.c:210050:25: */ var i int32 - if int32(stateno) > 34 { + if int32(stateno) > Fts5YY_MAX_SHIFT { return stateno } @@ -166804,8 +163989,8 @@ func fts5yy_shift(tls *libc.TLS, fts5yypParser uintptr, fts5yyNewState uint8, ft fts5yyStackOverflow(tls, fts5yypParser) return } - if int32(fts5yyNewState) > 34 { - fts5yyNewState = uint8(int32(fts5yyNewState) + (83 - 52)) + if int32(fts5yyNewState) > Fts5YY_MAX_SHIFT { + fts5yyNewState = uint8(int32(fts5yyNewState) + (Fts5YY_MIN_REDUCE - Fts5YY_MIN_SHIFTREDUCE)) } fts5yytos = (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos (*Fts5yyStackEntry)(unsafe.Pointer(fts5yytos)).Fstateno = fts5yyNewState @@ -166879,6 +164064,7 @@ var fts5yyRuleInfoNRhs = [28]int8{ int8(-1), // (26) star_opt ::= STAR int8(0), // (27) star_opt ::= } /* sqlite3.c:210261:26 */ + // Forward Declaration // Perform a reduce action and the shift that must immediately @@ -166928,7 +164114,7 @@ func fts5yy_reduce(tls *libc.TLS, fts5yypParser uintptr, fts5yyruleno uint32, ft case uint32(0): /* input ::= expr */ { - sqlite3Fts5ParseFinished(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + sqlite3Fts5ParseFinished(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } break case uint32(1): /* colset ::= MINUS LCP colsetlist RCP */ @@ -166943,43 +164129,43 @@ func fts5yy_reduce(tls *libc.TLS, fts5yypParser uintptr, fts5yyruleno uint32, ft break case uint32(3): /* colset ::= STRING */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), (fts5yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.fts5yy0 */)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), (fts5yymsp + 8 /* &.minor */ /* &.fts5yy0 */)) } - *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(4): /* colset ::= MINUS STRING */ { - *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), (fts5yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.fts5yy0 */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), (fts5yymsp + 8 /* &.minor */ /* &.fts5yy0 */)) *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = sqlite3Fts5ParseColsetInvert(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */))) } break case uint32(5): /* colsetlist ::= colsetlist STRING */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseColset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (fts5yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.fts5yy0 */)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseColset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), (fts5yymsp + 8 /* &.minor */ /* &.fts5yy0 */)) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(6): /* colsetlist ::= STRING */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), (fts5yymsp + uintptr(0)*24 + 8 /* &.minor */ /* &.fts5yy0 */)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseColset(tls, pParse, uintptr(0), (fts5yymsp + 8 /* &.minor */ /* &.fts5yy0 */)) } - *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(7): /* expr ::= expr AND expr */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, 2, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_AND, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)), uintptr(0)) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(8): /* expr ::= expr OR expr */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, 1, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_OR, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)), uintptr(0)) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(9): /* expr ::= expr NOT expr */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, 3, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)), uintptr(0)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_NOT, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)), uintptr(0)) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break @@ -166999,39 +164185,39 @@ func fts5yy_reduce(tls *libc.TLS, fts5yypParser uintptr, fts5yyruleno uint32, ft fallthrough // expr ::= exprlist case uint32(13): /* exprlist ::= cnearset */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) } - *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(14): /* exprlist ::= exprlist cnearset */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseImplicitAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseImplicitAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(15): /* cnearset ::= nearset */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, 9, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_STRING, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } - *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(16): /* cnearset ::= colset COLON nearset */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, 9, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNode(tls, pParse, FTS5_STRING, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) sqlite3Fts5ParseSetColset(tls, pParse, *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-2)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(17): /* nearset ::= phrase */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } - *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(18): /* nearset ::= CARET phrase */ { - sqlite3Fts5ParseSetCaret(tls, *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) - *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + sqlite3Fts5ParseSetCaret(tls, *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } break case uint32(19): /* nearset ::= STRING LP nearphrases neardist_opt RP */ @@ -167044,47 +164230,47 @@ func fts5yy_reduce(tls *libc.TLS, fts5yypParser uintptr, fts5yyruleno uint32, ft break case uint32(20): /* nearphrases ::= phrase */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNearset(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } - *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) + *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(21): /* nearphrases ::= nearphrases phrase */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNearset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseNearset(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)), *(*uintptr)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(22): /* neardist_opt ::= */ { - (*Fts5Token)(unsafe.Pointer(fts5yymsp + uintptr(1)*24 + 8 /* &.minor */)).Fp = uintptr(0) - (*Fts5Token)(unsafe.Pointer(fts5yymsp + uintptr(1)*24 + 8 /* &.minor */)).Fn = 0 + (*Fts5Token)(unsafe.Pointer(fts5yymsp + 1*24 + 8 /* &.minor */)).Fp = uintptr(0) + (*Fts5Token)(unsafe.Pointer(fts5yymsp + 1*24 + 8 /* &.minor */)).Fn = 0 } break case uint32(23): /* neardist_opt ::= COMMA STRING */ { - *(*Fts5Token)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*Fts5Token)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) + *(*Fts5Token)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*Fts5Token)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) } break case uint32(24): /* phrase ::= phrase PLUS STRING star_opt */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), (fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.fts5yy0 */), *(*int32)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)), (fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.fts5yy0 */), *(*int32)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-3)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(25): /* phrase ::= STRING star_opt */ { - *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseTerm(tls, pParse, uintptr(0), (fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.fts5yy0 */), *(*int32)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */))) + *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) = sqlite3Fts5ParseTerm(tls, pParse, uintptr(0), (fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */ /* &.fts5yy0 */), *(*int32)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */))) } *(*uintptr)(unsafe.Pointer(fts5yymsp + libc.UintptrFromInt32(-1)*24 + 8 /* &.minor */)) = *(*uintptr)(unsafe.Pointer(bp /* &fts5yylhsminor */)) break case uint32(26): /* star_opt ::= STAR */ { - *(*int32)(unsafe.Pointer(fts5yymsp + uintptr(0)*24 + 8 /* &.minor */)) = 1 + *(*int32)(unsafe.Pointer(fts5yymsp + 8 /* &.minor */)) = 1 } break case uint32(27): /* star_opt ::= */ { - *(*int32)(unsafe.Pointer(fts5yymsp + uintptr(1)*24 + 8 /* &.minor */)) = 0 + *(*int32)(unsafe.Pointer(fts5yymsp + 1*24 + 8 /* &.minor */)) = 0 } break default: @@ -167174,13 +164360,13 @@ func sqlite3Fts5Parser(tls *libc.TLS, fts5yyp uintptr, fts5yymajor int32, fts5yy for ok := true; ok; ok = ((*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos > fts5yypParser+16 /* &.fts5yystack */) { fts5yyact = fts5yy_find_shift_action(tls, uint8(fts5yymajor), fts5yyact) - if int32(fts5yyact) >= 83 { - fts5yyact = fts5yy_reduce(tls, fts5yypParser, (uint32(int32(fts5yyact) - 83)), fts5yymajor, + if int32(fts5yyact) >= Fts5YY_MIN_REDUCE { + fts5yyact = fts5yy_reduce(tls, fts5yypParser, (uint32(int32(fts5yyact) - Fts5YY_MIN_REDUCE)), fts5yymajor, fts5yyminor) - } else if int32(fts5yyact) <= 79 { + } else if int32(fts5yyact) <= Fts5YY_MAX_SHIFTREDUCE { fts5yy_shift(tls, fts5yypParser, fts5yyact, uint8(fts5yymajor), fts5yyminor) break - } else if int32(fts5yyact) == 81 { + } else if int32(fts5yyact) == Fts5YY_ACCEPT_ACTION { (*Fts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos -= 24 fts5yy_accept(tls, fts5yypParser) return @@ -167325,11 +164511,11 @@ func fts5CInstIterNext(tls *libc.TLS, pIter uintptr) int32 { /* sqlite3.c:210870 bp := tls.Alloc(12) defer tls.Free(12) - var rc int32 = 0 + var rc int32 = SQLITE_OK (*CInstIter)(unsafe.Pointer(pIter)).FiStart = -1 (*CInstIter)(unsafe.Pointer(pIter)).FiEnd = -1 - for (rc == 0) && ((*CInstIter)(unsafe.Pointer(pIter)).FiInst < (*CInstIter)(unsafe.Pointer(pIter)).FnInst) { + for (rc == SQLITE_OK) && ((*CInstIter)(unsafe.Pointer(pIter)).FiInst < (*CInstIter)(unsafe.Pointer(pIter)).FnInst) { // var ip int32 at bp, 4 // var ic int32 at bp+4, 4 @@ -167337,7 +164523,7 @@ func fts5CInstIterNext(tls *libc.TLS, pIter uintptr) int32 { /* sqlite3.c:210870 // var io int32 at bp+8, 4 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(((*CInstIter)(unsafe.Pointer(pIter)).FpApi + 72 /* &.xInst */))))(tls, (*CInstIter)(unsafe.Pointer(pIter)).FpFts, (*CInstIter)(unsafe.Pointer(pIter)).FiInst, bp /* &ip */, bp+4 /* &ic */, bp+8 /* &io */) - if rc == 0 { + if rc == SQLITE_OK { if *(*int32)(unsafe.Pointer(bp + 4 /* ic */)) == (*CInstIter)(unsafe.Pointer(pIter)).FiCol { var iEnd int32 = ((*(*int32)(unsafe.Pointer(bp + 8 /* io */)) - 1) + (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*CInstIter)(unsafe.Pointer(pIter)).FpApi + 56 /* &.xPhraseSize */))))(tls, (*CInstIter)(unsafe.Pointer(pIter)).FpFts, *(*int32)(unsafe.Pointer(bp /* ip */)))) if (*CInstIter)(unsafe.Pointer(pIter)).FiStart < 0 { @@ -167369,7 +164555,7 @@ func fts5CInstIterInit(tls *libc.TLS, pApi uintptr, pFts uintptr, iCol int32, pI (*CInstIter)(unsafe.Pointer(pIter)).FiCol = iCol rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 64 /* &.xInstCount */))))(tls, pFts, (pIter + 24 /* &.nInst */)) - if rc == 0 { + if rc == SQLITE_OK { rc = fts5CInstIterNext(tls, pIter) } @@ -167409,13 +164595,13 @@ func fts5HighlightAppend(tls *libc.TLS, pRc uintptr, p uintptr, z uintptr, n int bp := tls.Alloc(24) defer tls.Free(24) - if (*(*int32)(unsafe.Pointer(pRc)) == 0) && (z != 0) { + if (*(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK) && (z != 0) { if n < 0 { n = int32(libc.Xstrlen(tls, z)) } (*HighlightContext)(unsafe.Pointer(p)).FzOut = Xsqlite3_mprintf(tls, ts+36317 /* "%z%.*s" */, libc.VaList(bp, (*HighlightContext)(unsafe.Pointer(p)).FzOut, n, z)) if (*HighlightContext)(unsafe.Pointer(p)).FzOut == uintptr(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } } @@ -167426,20 +164612,20 @@ func fts5HighlightCb(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintp defer tls.Free(4) var p uintptr = pContext - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var iPos int32 _ = pToken _ = nToken - if (tflags & 0x0001) != 0 { - return 0 + if (tflags & FTS5_TOKEN_COLOCATED) != 0 { + return SQLITE_OK } iPos = libc.PostIncInt32(&(*HighlightContext)(unsafe.Pointer(p)).FiPos, 1) if (*HighlightContext)(unsafe.Pointer(p)).FiRangeEnd > 0 { if (iPos < (*HighlightContext)(unsafe.Pointer(p)).FiRangeStart) || (iPos > (*HighlightContext)(unsafe.Pointer(p)).FiRangeEnd) { - return 0 + return SQLITE_OK } if ((*HighlightContext)(unsafe.Pointer(p)).FiRangeStart != 0) && (iPos == (*HighlightContext)(unsafe.Pointer(p)).FiRangeStart) { (*HighlightContext)(unsafe.Pointer(p)).FiOff = iStartOff @@ -167459,7 +164645,7 @@ func fts5HighlightCb(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintp fts5HighlightAppend(tls, bp /* &rc */, p, ((*HighlightContext)(unsafe.Pointer(p)).FzIn + uintptr((*HighlightContext)(unsafe.Pointer(p)).FiOff)), (iEndOff - (*HighlightContext)(unsafe.Pointer(p)).FiOff)) fts5HighlightAppend(tls, bp /* &rc */, p, (*HighlightContext)(unsafe.Pointer(p)).FzClose, -1) (*HighlightContext)(unsafe.Pointer(p)).FiOff = iEndOff - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = fts5CInstIterNext(tls, (p /* &.iter */)) } } @@ -167492,30 +164678,30 @@ func fts5HighlightFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintp return } - iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal))) libc.Xmemset(tls, bp /* &ctx */, 0, uint64(unsafe.Sizeof(HighlightContext{}))) - (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOpen = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzClose = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(2)*8))) + (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOpen = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzClose = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 2*8))) *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 88 /* &.xColumnText */))))(tls, pFts, iCol, (bp /* &ctx */ + 72 /* &.zIn */), (bp /* &ctx */ + 80 /* &.nIn */)) if (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzIn != 0 { - if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = fts5CInstIterInit(tls, pApi, pFts, iCol, (bp /* &ctx */ /* &.iter */)) } - if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 40 /* &.xTokenize */))))(tls, pFts, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzIn, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FnIn, bp /* &ctx */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5HighlightCb}))) } fts5HighlightAppend(tls, bp+96 /* &rc */, bp /* &ctx */, ((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzIn + uintptr((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FiOff)), ((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FnIn - (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FiOff)) - if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == SQLITE_OK { Xsqlite3_result_text(tls, pCtx, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOut, -1, libc.UintptrFromInt32(-1)) } Xsqlite3_free(tls, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOut) } - if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) != SQLITE_OK { Xsqlite3_result_error_code(tls, pCtx, *(*int32)(unsafe.Pointer(bp + 96 /* rc */))) } } @@ -167556,26 +164742,26 @@ func fts5SentenceFinderAdd(tls *libc.TLS, p uintptr, iAdd int32) int32 { /* sqli aNew = Xsqlite3_realloc64(tls, (*Fts5SFinder)(unsafe.Pointer(p)).FaFirst, (uint64(uint64(nNew) * uint64(unsafe.Sizeof(int32(0)))))) if aNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Fts5SFinder)(unsafe.Pointer(p)).FaFirst = aNew (*Fts5SFinder)(unsafe.Pointer(p)).FnFirstAlloc = nNew } *(*int32)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(p)).FaFirst + uintptr(libc.PostIncInt32(&(*Fts5SFinder)(unsafe.Pointer(p)).FnFirst, 1))*4)) = iAdd - return 0 + return SQLITE_OK } // This function is an xTokenize() callback used by the auxiliary snippet() // function. Its job is to identify tokens that are the first in a sentence. // For each such token, an entry is added to the SFinder.aFirst[] array. func fts5SentenceFinderCb(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iStartOff int32, iEndOff int32) int32 { /* sqlite3.c:211101:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK _ = pToken _ = nToken _ = iEndOff - if (tflags & 0x0001) == 0 { + if (tflags & FTS5_TOKEN_COLOCATED) == 0 { var p uintptr = pContext if (*Fts5SFinder)(unsafe.Pointer(p)).FiPos > 0 { var i int32 @@ -167614,9 +164800,9 @@ func fts5SnippetScore(tls *libc.TLS, pApi uintptr, pFts uintptr, nDocsize int32, var iEnd Sqlite3_int64 = (Sqlite3_int64(iPos) + Sqlite3_int64(nToken)) rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 64 /* &.xInstCount */))))(tls, pFts, bp /* &nInst */) - for i = 0; (i < *(*int32)(unsafe.Pointer(bp /* nInst */))) && (rc == 0); i++ { + for i = 0; (i < *(*int32)(unsafe.Pointer(bp /* nInst */))) && (rc == SQLITE_OK); i++ { rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 72 /* &.xInst */))))(tls, pFts, i, bp+4 /* &ip */, bp+8 /* &ic */, bp+12 /* &iOff */) - if (((rc == 0) && (*(*int32)(unsafe.Pointer(bp + 8 /* ic */)) == iCol)) && (*(*int32)(unsafe.Pointer(bp + 12 /* iOff */)) >= iPos)) && (Sqlite3_int64(*(*int32)(unsafe.Pointer(bp + 12 /* iOff */))) < iEnd) { + if (((rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 8 /* ic */)) == iCol)) && (*(*int32)(unsafe.Pointer(bp + 12 /* iOff */)) >= iPos)) && (Sqlite3_int64(*(*int32)(unsafe.Pointer(bp + 12 /* iOff */))) < iEnd) { nScore = nScore + (func() int32 { if *(*uint8)(unsafe.Pointer(aSeen + uintptr(*(*int32)(unsafe.Pointer(bp + 4 /* ip */))))) != 0 { return 1 @@ -167664,18 +164850,18 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr // var ctx HighlightContext at bp, 96 - *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = 0 // Return code - var iCol int32 // 1st argument to snippet() - var zEllips uintptr // 4th argument to snippet() - var nToken int32 // 5th argument to snippet() - *(*int32)(unsafe.Pointer(bp + 96 /* nInst */)) = 0 // Number of instance matches this row - var i int32 // Used to iterate through instances - var nPhrase int32 // Number of phrases in query - var aSeen uintptr // Array of "seen instance" flags - var iBestCol int32 // Column containing best snippet - var iBestStart int32 = 0 // First token of best snippet - var nBestScore int32 = 0 // Score of best snippet - *(*int32)(unsafe.Pointer(bp + 164 /* nColSize */)) = 0 // Total size of iBestCol in tokens + *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = SQLITE_OK // Return code + var iCol int32 // 1st argument to snippet() + var zEllips uintptr // 4th argument to snippet() + var nToken int32 // 5th argument to snippet() + *(*int32)(unsafe.Pointer(bp + 96 /* nInst */)) = 0 // Number of instance matches this row + var i int32 // Used to iterate through instances + var nPhrase int32 // Number of phrases in query + var aSeen uintptr // Array of "seen instance" flags + var iBestCol int32 // Column containing best snippet + var iBestStart int32 = 0 // First token of best snippet + var nBestScore int32 = 0 // Score of best snippet + *(*int32)(unsafe.Pointer(bp + 164 /* nColSize */)) = 0 // Total size of iBestCol in tokens // var sFinder Fts5SFinder at bp+104, 32 // Used to find the beginnings of sentences var nCol int32 @@ -167688,11 +164874,11 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr nCol = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((pApi + 16 /* &.xColumnCount */))))(tls, pFts) libc.Xmemset(tls, bp /* &ctx */, 0, uint64(unsafe.Sizeof(HighlightContext{}))) - iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) - (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOpen = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzClose = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(2)*8))) - zEllips = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(3)*8))) - nToken = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(4)*8))) + iCol = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal))) + (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOpen = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzClose = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + 2*8))) + zEllips = fts5ValueToText(tls, *(*uintptr)(unsafe.Pointer(apVal + 3*8))) + nToken = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + 4*8))) iBestCol = func() int32 { if iCol >= 0 { @@ -167703,9 +164889,9 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr nPhrase = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((pApi + 48 /* &.xPhraseCount */))))(tls, pFts) aSeen = Xsqlite3_malloc(tls, nPhrase) if aSeen == uintptr(0) { - *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = SQLITE_NOMEM } - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 64 /* &.xInstCount */))))(tls, pFts, bp+96 /* &nInst */) } @@ -167720,22 +164906,22 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr (*Fts5SFinder)(unsafe.Pointer(bp + 104 /* &sFinder */)).FiPos = 0 (*Fts5SFinder)(unsafe.Pointer(bp + 104 /* &sFinder */)).FnFirst = 0 *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 88 /* &.xColumnText */))))(tls, pFts, i, (bp + 104 /* &sFinder */ + 24 /* &.zDoc */), bp+136 /* &nDoc */) - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != SQLITE_OK { break } *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 40 /* &.xTokenize */))))(tls, pFts, (*Fts5SFinder)(unsafe.Pointer(bp+104 /* &sFinder */)).FzDoc, *(*int32)(unsafe.Pointer(bp + 136 /* nDoc */)), bp+104 /* &sFinder */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5SentenceFinderCb}))) - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != SQLITE_OK { break } *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pApi + 96 /* &.xColumnSize */))))(tls, pFts, i, bp+140 /* &nDocsize */) - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != SQLITE_OK { break } - for ii = 0; (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0) && (ii < *(*int32)(unsafe.Pointer(bp + 96 /* nInst */))); ii++ { + for ii = 0; (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK) && (ii < *(*int32)(unsafe.Pointer(bp + 96 /* nInst */))); ii++ { // var ip int32 at bp+144, 4 // var ic int32 at bp+148, 4 @@ -167753,22 +164939,22 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr continue } if *(*int32)(unsafe.Pointer(bp + 152 /* io */)) > *(*int32)(unsafe.Pointer(bp + 140 /* nDocsize */)) { - *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) != SQLITE_OK { continue } libc.Xmemset(tls, aSeen, 0, uint64(nPhrase)) *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = fts5SnippetScore(tls, pApi, pFts, *(*int32)(unsafe.Pointer(bp + 140 /* nDocsize */)), aSeen, i, *(*int32)(unsafe.Pointer(bp + 152 /* io */)), nToken, bp+156 /* &nScore */, bp+160 /* &iAdj */) - if (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0) && (*(*int32)(unsafe.Pointer(bp + 156 /* nScore */)) > nBestScore) { + if (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 156 /* nScore */)) > nBestScore) { nBestScore = *(*int32)(unsafe.Pointer(bp + 156 /* nScore */)) iBestCol = i iBestStart = *(*int32)(unsafe.Pointer(bp + 160 /* iAdj */)) *(*int32)(unsafe.Pointer(bp + 164 /* nColSize */)) = *(*int32)(unsafe.Pointer(bp + 140 /* nDocsize */)) } - if ((*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0) && ((*Fts5SFinder)(unsafe.Pointer(bp+104 /* &sFinder */)).FnFirst != 0)) && (*(*int32)(unsafe.Pointer(bp + 140 /* nDocsize */)) > nToken) { + if ((*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK) && ((*Fts5SFinder)(unsafe.Pointer(bp+104 /* &sFinder */)).FnFirst != 0)) && (*(*int32)(unsafe.Pointer(bp + 140 /* nDocsize */)) > nToken) { for jj = 0; jj < ((*Fts5SFinder)(unsafe.Pointer(bp+104 /* &sFinder */)).FnFirst - 1); jj++ { if *(*int32)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(bp+104 /* &sFinder */)).FaFirst + uintptr((jj+1))*4)) > *(*int32)(unsafe.Pointer(bp + 152 /* io */)) { break @@ -167786,7 +164972,7 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr } return 100 }() - if (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0) && (*(*int32)(unsafe.Pointer(bp + 156 /* nScore */)) > nBestScore) { + if (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 156 /* nScore */)) > nBestScore) { nBestScore = *(*int32)(unsafe.Pointer(bp + 156 /* nScore */)) iBestCol = i iBestStart = *(*int32)(unsafe.Pointer((*Fts5SFinder)(unsafe.Pointer(bp+104 /* &sFinder */)).FaFirst + uintptr(jj)*4)) @@ -167798,14 +164984,14 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr } } - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 88 /* &.xColumnText */))))(tls, pFts, iBestCol, (bp /* &ctx */ + 72 /* &.zIn */), (bp /* &ctx */ + 80 /* &.nIn */)) } - if (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0) && (*(*int32)(unsafe.Pointer(bp + 164 /* nColSize */)) == 0) { + if (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 164 /* nColSize */)) == 0) { *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pApi + 96 /* &.xColumnSize */))))(tls, pFts, iBestCol, bp+164 /* &nColSize */) } if (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzIn != 0 { - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = fts5CInstIterInit(tls, pApi, pFts, iBestCol, (bp /* &ctx */ /* &.iter */)) } @@ -167818,11 +165004,11 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr // Advance iterator ctx.iter so that it points to the first coalesced // phrase instance at or following position iBestStart. - for (((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).Fiter.FiStart >= 0) && ((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).Fiter.FiStart < iBestStart)) && (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0) { + for (((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).Fiter.FiStart >= 0) && ((*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).Fiter.FiStart < iBestStart)) && (*(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK) { *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = fts5CInstIterNext(tls, (bp /* &ctx */ /* &.iter */)) } - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 40 /* &.xTokenize */))))(tls, pFts, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzIn, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FnIn, bp /* &ctx */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5HighlightCb}))) @@ -167833,7 +165019,7 @@ func fts5SnippetFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr fts5HighlightAppend(tls, bp+168 /* &rc */, bp /* &ctx */, zEllips, -1) } } - if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 168 /* rc */)) == SQLITE_OK { Xsqlite3_result_text(tls, pCtx, (*HighlightContext)(unsafe.Pointer(bp /* &ctx */)).FzOut, -1, libc.UintptrFromInt32(-1)) } else { Xsqlite3_result_error_code(tls, pCtx, *(*int32)(unsafe.Pointer(bp + 168 /* rc */))) @@ -167868,7 +165054,7 @@ func fts5CountCb(tls *libc.TLS, pApi uintptr, pFts uintptr, pUserData uintptr) i _ = pApi _ = pFts (*(*Sqlite3_int64)(unsafe.Pointer(pn)))++ - return 0 + return SQLITE_OK } // Set *ppData to point to the Fts5Bm25Data object for the current query. @@ -167878,8 +165064,8 @@ func fts5Bm25GetData(tls *libc.TLS, pApi uintptr, pFts uintptr, ppData uintptr) bp := tls.Alloc(24) defer tls.Free(24) - var rc int32 = 0 // Return code - var p uintptr // Object to return + var rc int32 = SQLITE_OK // Return code + var p uintptr // Object to return p = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer((pApi + 120 /* &.xGetAuxdata */))))(tls, pFts, 0) if p == uintptr(0) { @@ -167894,33 +165080,33 @@ func fts5Bm25GetData(tls *libc.TLS, pApi uintptr, pFts uintptr, ppData uintptr) nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5Bm25Data{})) + ((uint64(nPhrase * 2)) * uint64(unsafe.Sizeof(float64(0)))))) p = Xsqlite3_malloc64(tls, uint64(nByte)) if p == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, p, 0, Size_t(nByte)) (*Fts5Bm25Data)(unsafe.Pointer(p)).FnPhrase = nPhrase - (*Fts5Bm25Data)(unsafe.Pointer(p)).FaIDF = (p + uintptr(1)*32) + (*Fts5Bm25Data)(unsafe.Pointer(p)).FaIDF = (p + 1*32) (*Fts5Bm25Data)(unsafe.Pointer(p)).FaFreq = ((*Fts5Bm25Data)(unsafe.Pointer(p)).FaIDF + uintptr(nPhrase)*8) } // Calculate the average document length for this FTS5 table - if rc == 0 { + if rc == SQLITE_OK { rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 24 /* &.xRowCount */))))(tls, pFts, bp /* &nRow */) } - if rc == 0 { + if rc == SQLITE_OK { rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pApi + 32 /* &.xColumnTotalSize */))))(tls, pFts, -1, bp+8 /* &nToken */) } - if rc == 0 { + if rc == SQLITE_OK { (*Fts5Bm25Data)(unsafe.Pointer(p)).Favgdl = (float64(*(*Sqlite3_int64)(unsafe.Pointer(bp + 8 /* nToken */))) / float64(*(*Sqlite3_int64)(unsafe.Pointer(bp /* nRow */)))) } // Calculate an IDF for each phrase in the query - for i = 0; (rc == 0) && (i < nPhrase); i++ { + for i = 0; (rc == SQLITE_OK) && (i < nPhrase); i++ { *(*Sqlite3_int64)(unsafe.Pointer(bp + 16 /* nHit */)) = int64(0) rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 104 /* &.xQueryPhrase */))))(tls, pFts, i, bp+16 /* &nHit */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr) int32 }{fts5CountCb}))) - if rc == 0 { + if rc == SQLITE_OK { // Calculate the IDF (Inverse Document Frequency) for phrase i. // This is done using the standard BM25 formula as found on wikipedia: // @@ -167942,12 +165128,12 @@ func fts5Bm25GetData(tls *libc.TLS, pApi uintptr, pFts uintptr, ppData uintptr) } } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_free(tls, p) } else { 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) }{Xsqlite3_free}))) } - if rc != 0 { + if rc != SQLITE_OK { p = uintptr(0) } } @@ -167960,10 +165146,10 @@ func fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, n bp := tls.Alloc(28) defer tls.Free(28) - var k1 float64 = 1.2 // Constant "k1" from BM25 formula - var b float64 = 0.75 // Constant "b" from BM25 formula - var rc int32 = 0 // Error code - var score float64 = 0.0 // SQL function return value + var k1 float64 = 1.2 // Constant "k1" from BM25 formula + var b float64 = 0.75 // Constant "b" from BM25 formula + var rc int32 = SQLITE_OK // Error code + var score float64 = 0.0 // SQL function return value // var pData uintptr at bp, 8 // Values allocated/calculated once only var i int32 // Iterator variable @@ -167974,12 +165160,12 @@ func fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, n // Calculate the phrase frequency (symbol "f(qi,D)" in the documentation) // for each phrase in the query for the current row. rc = fts5Bm25GetData(tls, pApi, pFts, bp /* &pData */) - if rc == 0 { + if rc == SQLITE_OK { aFreq = (*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pData */)))).FaFreq libc.Xmemset(tls, aFreq, 0, (uint64(unsafe.Sizeof(float64(0))) * uint64((*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pData */)))).FnPhrase))) rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 64 /* &.xInstCount */))))(tls, pFts, bp+8 /* &nInst */) } - for i = 0; (rc == 0) && (i < *(*int32)(unsafe.Pointer(bp + 8 /* nInst */))); i++ { + for i = 0; (rc == SQLITE_OK) && (i < *(*int32)(unsafe.Pointer(bp + 8 /* nInst */))); i++ { // var ip int32 at bp+12, 4 // var ic int32 at bp+16, 4 @@ -167987,7 +165173,7 @@ func fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, n // var io int32 at bp+20, 4 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 72 /* &.xInst */))))(tls, pFts, i, bp+12 /* &ip */, bp+16 /* &ic */, bp+20 /* &io */) - if rc == 0 { + if rc == SQLITE_OK { var w float64 if nVal > *(*int32)(unsafe.Pointer(bp + 16 /* ic */)) { w = Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(*(*int32)(unsafe.Pointer(bp + 16 /* ic */)))*8))) @@ -167999,7 +165185,7 @@ func fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, n } // Figure out the total size of the current row in tokens. - if rc == 0 { + if rc == SQLITE_OK { // var nTok int32 at bp+24, 4 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pApi + 96 /* &.xColumnSize */))))(tls, pFts, -1, bp+24 /* &nTok */) @@ -168007,13 +165193,13 @@ func fts5Bm25Function(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, n } // Determine the BM25 score for the current row. - for i = 0; (rc == 0) && (i < (*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pData */)))).FnPhrase); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pData */)))).FnPhrase); i++ { score = score + (*(*float64)(unsafe.Pointer((*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pData */)))).FaIDF + uintptr(i)*8)) * ((*(*float64)(unsafe.Pointer(aFreq + uintptr(i)*8)) * (k1 + 1.0)) / (*(*float64)(unsafe.Pointer(aFreq + uintptr(i)*8)) + (k1 * ((float64(1) - b) + ((b * D) / (*Fts5Bm25Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pData */)))).Favgdl)))))) } // If no error has occurred, return the calculated score. Otherwise, // throw an SQL exception. - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_result_double(tls, pCtx, (-1.0 * score)) } else { Xsqlite3_result_error_code(tls, pCtx, rc) @@ -168025,32 +165211,20 @@ func sqlite3Fts5AuxInit(tls *libc.TLS, pApi uintptr) int32 { /* sqlite3.c:211508 defer tls.Free(96) *(*[3]Builtin)(unsafe.Pointer(bp /* aBuiltin */)) = [3]Builtin{ - { - FzFunc: ts + 36422, /* "snippet" */ - FpUserData: uintptr(0), - FxFunc: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) - }{fts5SnippetFunction})), - FxDestroy: uintptr(0)}, - { - FzFunc: ts + 36430, /* "highlight" */ - FpUserData: uintptr(0), - FxFunc: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) - }{fts5HighlightFunction})), - FxDestroy: uintptr(0)}, - { - FzFunc: ts + 36440, /* "bm25" */ - FpUserData: uintptr(0), - FxFunc: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) - }{fts5Bm25Function})), - FxDestroy: uintptr(0)}, + {FzFunc: ts + 36422 /* "snippet" */, FxFunc: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) + }{fts5SnippetFunction}))}, + {FzFunc: ts + 36430 /* "highlight" */, FxFunc: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) + }{fts5HighlightFunction}))}, + {FzFunc: ts + 36440 /* "bm25" */, FxFunc: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) + }{fts5Bm25Function}))}, } - var rc int32 = 0 // Return code - var i int32 // To iterate through builtin functions + var rc int32 = SQLITE_OK // Return code + var i int32 // To iterate through builtin functions - for i = 0; (rc == 0) && (i < (int32(uint64(unsafe.Sizeof([3]Builtin{})) / uint64(unsafe.Sizeof(Builtin{}))))); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (int32(uint64(unsafe.Sizeof([3]Builtin{})) / uint64(unsafe.Sizeof(Builtin{}))))); i++ { rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, Fts5_extension_function, uintptr) int32)(unsafe.Pointer((pApi + 24 /* &.xCreateFunction */))))(tls, pApi, (*Builtin)(unsafe.Pointer(bp /* &aBuiltin */ +uintptr(i)*32)).FzFunc, (*Builtin)(unsafe.Pointer(bp /* &aBuiltin */ +uintptr(i)*32)).FpUserData, @@ -168095,7 +165269,7 @@ func sqlite3Fts5BufferSize(tls *libc.TLS, pRc uintptr, pBuf uintptr, nByte U32) } pNew = Xsqlite3_realloc64(tls, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp, nNew) if pNew == uintptr(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM return 1 } else { (*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace = int32(nNew) @@ -168120,14 +165294,14 @@ func sqlite3Fts5BufferAppendVarint(tls *libc.TLS, pRc uintptr, pBuf uintptr, iVa } func sqlite3Fts5Put32(tls *libc.TLS, aBuf uintptr, iVal int32) { /* sqlite3.c:211580:13: */ - *(*U8)(unsafe.Pointer(aBuf + uintptr(0))) = (U8((iVal >> 24) & 0x00FF)) - *(*U8)(unsafe.Pointer(aBuf + uintptr(1))) = (U8((iVal >> 16) & 0x00FF)) - *(*U8)(unsafe.Pointer(aBuf + uintptr(2))) = (U8((iVal >> 8) & 0x00FF)) - *(*U8)(unsafe.Pointer(aBuf + uintptr(3))) = (U8((iVal >> 0) & 0x00FF)) + *(*U8)(unsafe.Pointer(aBuf)) = (U8((iVal >> 24) & 0x00FF)) + *(*U8)(unsafe.Pointer(aBuf + 1)) = (U8((iVal >> 16) & 0x00FF)) + *(*U8)(unsafe.Pointer(aBuf + 2)) = (U8((iVal >> 8) & 0x00FF)) + *(*U8)(unsafe.Pointer(aBuf + 3)) = (U8((iVal >> 0) & 0x00FF)) } func sqlite3Fts5Get32(tls *libc.TLS, aBuf uintptr) int32 { /* sqlite3.c:211587:12: */ - return (int32(((((U32(*(*U8)(unsafe.Pointer(aBuf + uintptr(0))))) << 24) + (U32(int32(*(*U8)(unsafe.Pointer(aBuf + uintptr(1)))) << 16))) + (U32(int32(*(*U8)(unsafe.Pointer(aBuf + uintptr(2)))) << 8))) + U32(*(*U8)(unsafe.Pointer(aBuf + uintptr(3)))))) + return (int32(((((U32(*(*U8)(unsafe.Pointer(aBuf)))) << 24) + (U32(int32(*(*U8)(unsafe.Pointer(aBuf + 1))) << 16))) + (U32(int32(*(*U8)(unsafe.Pointer(aBuf + 2))) << 8))) + U32(*(*U8)(unsafe.Pointer(aBuf + 3))))) } // Append buffer nData/pData to buffer pBuf. If an OOM error occurs, set @@ -168165,7 +165339,7 @@ func sqlite3Fts5BufferAppendString(tls *libc.TLS, pRc uintptr, pBuf uintptr, zSt // following the buffer data is set to 0x00, even though this byte is not // included in the pBuf->n count. func sqlite3Fts5BufferAppendPrintf(tls *libc.TLS, pRc uintptr, pBuf uintptr, zFmt uintptr, va uintptr) { /* sqlite3.c:211633:13: */ - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var zTmp uintptr var ap Va_list _ = ap @@ -168174,7 +165348,7 @@ func sqlite3Fts5BufferAppendPrintf(tls *libc.TLS, pRc uintptr, pBuf uintptr, zFm _ = ap if zTmp == uintptr(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } else { sqlite3Fts5BufferAppendString(tls, pRc, pBuf, zTmp) Xsqlite3_free(tls, zTmp) @@ -168184,14 +165358,14 @@ func sqlite3Fts5BufferAppendPrintf(tls *libc.TLS, pRc uintptr, pBuf uintptr, zFm func sqlite3Fts5Mprintf(tls *libc.TLS, pRc uintptr, zFmt uintptr, va uintptr) uintptr { /* sqlite3.c:211654:13: */ var zRet uintptr = uintptr(0) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var ap Va_list _ = ap ap = va zRet = Xsqlite3_vmprintf(tls, zFmt, ap) _ = ap if zRet == uintptr(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } return zRet @@ -168320,16 +165494,16 @@ func sqlite3Fts5PoslistWriterAppend(tls *libc.TLS, pBuf uintptr, pWriter uintptr return *(*int32)(unsafe.Pointer(bp /* rc */)) } sqlite3Fts5PoslistSafeAppend(tls, pBuf, (pWriter /* &.iPrev */), iPos) - return 0 + return SQLITE_OK } func sqlite3Fts5MallocZero(tls *libc.TLS, pRc uintptr, nByte Sqlite3_int64) uintptr { /* sqlite3.c:211789:13: */ var pRet uintptr = uintptr(0) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { pRet = Xsqlite3_malloc64(tls, uint64(nByte)) if pRet == uintptr(0) { if nByte > int64(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } else { libc.Xmemset(tls, pRet, 0, Size_t(nByte)) @@ -168346,7 +165520,7 @@ func sqlite3Fts5MallocZero(tls *libc.TLS, pRc uintptr, nByte Sqlite3_int64) uint // buffer using sqlite3_free(). If an OOM error occurs, NULL is returned. func sqlite3Fts5Strndup(tls *libc.TLS, pRc uintptr, pIn uintptr, nIn int32) uintptr { /* sqlite3.c:211810:13: */ var zRet uintptr = uintptr(0) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { if nIn < 0 { nIn = int32(libc.Xstrlen(tls, pIn)) } @@ -168355,7 +165529,7 @@ func sqlite3Fts5Strndup(tls *libc.TLS, pRc uintptr, pIn uintptr, nIn int32) uint libc.Xmemcpy(tls, zRet, pIn, uint64(nIn)) *(*int8)(unsafe.Pointer(zRet + uintptr(nIn))) = int8(0) } else { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } return zRet @@ -168404,7 +165578,7 @@ func sqlite3Fts5TermsetNew(tls *libc.TLS, pp uintptr) int32 { /* sqlite3.c:21186 bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK *(*uintptr)(unsafe.Pointer(pp)) = sqlite3Fts5MallocZero(tls, bp /* &rc */, int64(unsafe.Sizeof(Fts5Termset{}))) return *(*int32)(unsafe.Pointer(bp /* rc */)) } @@ -168413,7 +165587,7 @@ func sqlite3Fts5TermsetAdd(tls *libc.TLS, p uintptr, iIdx int32, pTerm uintptr, bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK *(*int32)(unsafe.Pointer(pbPresent)) = 0 if p != 0 { var i int32 @@ -168442,7 +165616,7 @@ func sqlite3Fts5TermsetAdd(tls *libc.TLS, p uintptr, iIdx int32, pTerm uintptr, if pEntry == uintptr(0) { pEntry = sqlite3Fts5MallocZero(tls, bp /* &rc */, (int64(uint64(unsafe.Sizeof(Fts5TermsetEntry{})) + uint64(nTerm)))) if pEntry != 0 { - (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FpTerm = (pEntry + uintptr(1)*24) + (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FpTerm = (pEntry + 1*24) (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FnTerm = nTerm (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FiIdx = iIdx libc.Xmemcpy(tls, (*Fts5TermsetEntry)(unsafe.Pointer(pEntry)).FpTerm, pTerm, uint64(nTerm)) @@ -168533,7 +165707,7 @@ func fts5ConfigSkipLiteral(tls *libc.TLS, pIn uintptr) uintptr { /* sqlite3.c:21 fallthrough case 'N': if Xsqlite3_strnicmp(tls, ts+7843 /* "null" */, p, 4) == 0 { - p = (p + uintptr(4)) + p = (p + 4) } else { p = uintptr(0) } @@ -168588,7 +165762,7 @@ func fts5ConfigSkipLiteral(tls *libc.TLS, pIn uintptr) uintptr { /* sqlite3.c:21 // At this point, if the literal was an integer, the parse is // finished. Or, if it is a floating point value, it may continue // with either a decimal point or an 'E' character. - if (int32(*(*int8)(unsafe.Pointer(p))) == '.') && (fts5_isdigit(tls, *(*int8)(unsafe.Pointer(p + uintptr(1)))) != 0) { + if (int32(*(*int8)(unsafe.Pointer(p))) == '.') && (fts5_isdigit(tls, *(*int8)(unsafe.Pointer(p + 1))) != 0) { p += uintptr(2) for fts5_isdigit(tls, *(*int8)(unsafe.Pointer(p))) != 0 { p++ @@ -168619,7 +165793,7 @@ func fts5Dequote(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:212080:12: */ var q int8 var iIn int32 = 1 var iOut int32 = 0 - q = *(*int8)(unsafe.Pointer(z + uintptr(0))) + q = *(*int8)(unsafe.Pointer(z)) // Set stack variable q to the close-quote character @@ -168663,7 +165837,7 @@ func fts5Dequote(tls *libc.TLS, z uintptr) int32 { /* sqlite3.c:212080:12: */ func sqlite3Fts5Dequote(tls *libc.TLS, z uintptr) { /* sqlite3.c:212125:13: */ var quote int8 // Quote character (if any ) - quote = *(*int8)(unsafe.Pointer(z + uintptr(0))) + quote = *(*int8)(unsafe.Pointer(z)) if (((int32(quote) == '[') || (int32(quote) == '\'')) || (int32(quote) == '"')) || (int32(quote) == '`') { fts5Dequote(tls, z) } @@ -168685,7 +165859,7 @@ func fts5ConfigSetEnum(tls *libc.TLS, aEnum uintptr, zEnum uintptr, peVal uintpt for i = 0; (*Fts5Enum)(unsafe.Pointer(aEnum+uintptr(i)*16)).FzName != 0; i++ { if Xsqlite3_strnicmp(tls, (*Fts5Enum)(unsafe.Pointer(aEnum+uintptr(i)*16)).FzName, zEnum, nEnum) == 0 { if iVal >= 0 { - return 1 + return SQLITE_ERROR } iVal = (*Fts5Enum)(unsafe.Pointer(aEnum + uintptr(i)*16)).FeVal } @@ -168693,9 +165867,9 @@ func fts5ConfigSetEnum(tls *libc.TLS, aEnum uintptr, zEnum uintptr, peVal uintpt *(*int32)(unsafe.Pointer(peVal)) = iVal if iVal < 0 { - return 1 + return SQLITE_ERROR } - return 0 + return SQLITE_OK } // Parse a "special" CREATE VIRTUAL TABLE directive and update @@ -168709,10 +165883,10 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm bp := tls.Alloc(112) defer tls.Free(112) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_OK var nCmd int32 = int32(libc.Xstrlen(tls, zCmd)) if Xsqlite3_strnicmp(tls, ts+36445 /* "prefix" */, zCmd, nCmd) == 0 { - var nByte int32 = (int32(uint64(unsafe.Sizeof(int32(0))) * uint64(31))) + var nByte int32 = (int32(uint64(unsafe.Sizeof(int32(0))) * FTS5_MAX_PREFIX_INDEXES)) var p uintptr var bFirst int32 = 1 if (*Fts5Config)(unsafe.Pointer(pConfig)).FaPrefix == uintptr(0) { @@ -168726,38 +165900,38 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm for 1 != 0 { var nPre int32 = 0 - for int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) == ' ' { + for int32(*(*int8)(unsafe.Pointer(p))) == ' ' { p++ } - if (bFirst == 0) && (int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) == ',') { + if (bFirst == 0) && (int32(*(*int8)(unsafe.Pointer(p))) == ',') { p++ - for int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) == ' ' { + for int32(*(*int8)(unsafe.Pointer(p))) == ' ' { p++ } - } else if int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) == 0 { + } else if int32(*(*int8)(unsafe.Pointer(p))) == 0 { break } - if (int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) < '0') || (int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) > '9') { + if (int32(*(*int8)(unsafe.Pointer(p))) < '0') || (int32(*(*int8)(unsafe.Pointer(p))) > '9') { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+36452 /* "malformed prefix..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR break } - if (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix == 31 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix == FTS5_MAX_PREFIX_INDEXES { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, - ts+36483 /* "too many prefix ..." */, libc.VaList(bp, 31)) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + ts+36483 /* "too many prefix ..." */, libc.VaList(bp, FTS5_MAX_PREFIX_INDEXES)) + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR break } - for ((int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) >= '0') && (int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) <= '9')) && (nPre < 1000) { - nPre = ((nPre * 10) + (int32(*(*int8)(unsafe.Pointer(p + uintptr(0)))) - '0')) + for ((int32(*(*int8)(unsafe.Pointer(p))) >= '0') && (int32(*(*int8)(unsafe.Pointer(p))) <= '9')) && (nPre < 1000) { + nPre = ((nPre * 10) + (int32(*(*int8)(unsafe.Pointer(p))) - '0')) p++ } if (nPre <= 0) || (nPre >= 1000) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+36516 /* "prefix length ou..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR break } @@ -168779,7 +165953,7 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm if (azArg != 0) && (pSpace != 0) { if (*Fts5Config)(unsafe.Pointer(pConfig)).FpTok != 0 { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+36562 /* "multiple tokeniz..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { for nArg = int64(0); (p != 0) && (*(*int8)(unsafe.Pointer(p)) != 0); nArg++ { var p2 uintptr = fts5ConfigSkipWhitespace(tls, p) @@ -168798,7 +165972,7 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm } if p == uintptr(0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+36595 /* "parse error in t..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = sqlite3Fts5GetTokenizer(tls, pGlobal, azArg, int32(nArg), (pConfig + 104 /* &.pTok */), (pConfig + 112 /* &.pTokApi */), @@ -168813,15 +165987,15 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm } if Xsqlite3_strnicmp(tls, ts+36629 /* "content" */, zCmd, nCmd) == 0 { - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != 0 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+36637 /* "multiple content..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { - if *(*int8)(unsafe.Pointer(zArg + uintptr(0))) != 0 { - (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent = 2 + if *(*int8)(unsafe.Pointer(zArg)) != 0 { + (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent = FTS5_CONTENT_EXTERNAL (*Fts5Config)(unsafe.Pointer(pConfig)).FzContent = sqlite3Fts5Mprintf(tls, bp+40 /* &rc */, ts+36669 /* "%Q.%Q" */, libc.VaList(bp+8, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, zArg)) } else { - (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent = 1 + (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent = FTS5_CONTENT_NONE } } return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) @@ -168830,7 +166004,7 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm if Xsqlite3_strnicmp(tls, ts+36675 /* "content_rowid" */, zCmd, nCmd) == 0 { if (*Fts5Config)(unsafe.Pointer(pConfig)).FzContentRowid != 0 { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+36689 /* "multiple content..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { (*Fts5Config)(unsafe.Pointer(pConfig)).FzContentRowid = sqlite3Fts5Strndup(tls, bp+40 /* &rc */, zArg, -1) } @@ -168838,26 +166012,20 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm } if Xsqlite3_strnicmp(tls, ts+36727 /* "columnsize" */, zCmd, nCmd) == 0 { - if ((int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) != '0') && (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) != '1')) || (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(1)))) != 0) { + if ((int32(*(*int8)(unsafe.Pointer(zArg))) != '0') && (int32(*(*int8)(unsafe.Pointer(zArg))) != '1')) || (int32(*(*int8)(unsafe.Pointer(zArg + 1))) != 0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+36738 /* "malformed column..." */, 0) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { - (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize = (libc.Bool32(int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) == '1')) + (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize = (libc.Bool32(int32(*(*int8)(unsafe.Pointer(zArg))) == '1')) } return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) } if Xsqlite3_strnicmp(tls, ts+6791 /* "detail" */, zCmd, nCmd) == 0 { *(*[4]Fts5Enum)(unsafe.Pointer(bp + 48 /* aDetail */)) = [4]Fts5Enum{ - { - FzName: ts + 18368, /* "none" */ - FeVal: 1}, - { - FzName: ts + 18373, /* "full" */ - FeVal: 0}, - { - FzName: ts + 36773, /* "columns" */ - FeVal: 2}, + {FzName: ts + 18368 /* "none" */, FeVal: FTS5_DETAIL_NONE}, + {FzName: ts + 18373 /* "full" */}, + {FzName: ts + 36773 /* "columns" */, FeVal: FTS5_DETAIL_COLUMNS}, {}, } @@ -168868,7 +166036,7 @@ func fts5ConfigParseSpecial(tls *libc.TLS, pGlobal uintptr, pConfig uintptr, zCm } *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+36812 /* "unrecognized opt..." */, libc.VaList(bp+24, nCmd, zCmd)) - return 1 + return SQLITE_ERROR } // Allocate an instance of the default tokenizer ("simple") at @@ -168903,10 +166071,10 @@ func fts5ConfigGobbleWord(tls *libc.TLS, pRc uintptr, zIn uintptr, pzOut uintptr *(*uintptr)(unsafe.Pointer(pzOut)) = uintptr(0) if zOut == uintptr(0) { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } else { libc.Xmemcpy(tls, zOut, zIn, (Size_t(nIn + int64(1)))) - if fts5_isopenquote(tls, *(*int8)(unsafe.Pointer(zOut + uintptr(0)))) != 0 { + if fts5_isopenquote(tls, *(*int8)(unsafe.Pointer(zOut))) != 0 { var ii int32 = fts5Dequote(tls, zOut) zRet = (zIn + uintptr(ii)) *(*int32)(unsafe.Pointer(pbQuoted)) = 1 @@ -168931,17 +166099,17 @@ func fts5ConfigParseColumn(tls *libc.TLS, p uintptr, zCol uintptr, zArg uintptr, bp := tls.Alloc(16) defer tls.Free(16) - var rc int32 = 0 + var rc int32 = SQLITE_OK if (0 == Xsqlite3_stricmp(tls, zCol, ts+23877 /* "rank" */)) || (0 == Xsqlite3_stricmp(tls, zCol, ts+10064 /* "rowid" */)) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+36840 /* "reserved fts5 co..." */, libc.VaList(bp, zCol)) - rc = 1 + rc = SQLITE_ERROR } else if zArg != 0 { if 0 == Xsqlite3_stricmp(tls, zArg, ts+36870 /* "unindexed" */) { *(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(p)).FabUnindexed + uintptr((*Fts5Config)(unsafe.Pointer(p)).FnCol))) = U8(1) } else { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+36880 /* "unrecognized col..." */, libc.VaList(bp+8, zArg)) - rc = 1 + rc = SQLITE_ERROR } } @@ -168955,13 +166123,13 @@ func fts5ConfigMakeExprlist(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:21242 defer tls.Free(48) var i int32 - *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = SQLITE_OK *(*Fts5Buffer)(unsafe.Pointer(bp + 32 /* buf */)) = Fts5Buffer{} sqlite3Fts5BufferAppendPrintf(tls, bp+24 /* &rc */, bp+32 /* &buf */, ts+36911 /* "T.%Q" */, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(p)).FzContentRowid)) - if (*Fts5Config)(unsafe.Pointer(p)).FeContent != 1 { + if (*Fts5Config)(unsafe.Pointer(p)).FeContent != FTS5_CONTENT_NONE { for i = 0; i < (*Fts5Config)(unsafe.Pointer(p)).FnCol; i++ { - if (*Fts5Config)(unsafe.Pointer(p)).FeContent == 2 { + if (*Fts5Config)(unsafe.Pointer(p)).FeContent == FTS5_CONTENT_EXTERNAL { sqlite3Fts5BufferAppendPrintf(tls, bp+24 /* &rc */, bp+32 /* &buf */, ts+36916 /* ", T.%Q" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(p)).FazCol + uintptr(i)*8)))) } else { sqlite3Fts5BufferAppendPrintf(tls, bp+24 /* &rc */, bp+32 /* &buf */, ts+36923 /* ", T.c%d" */, libc.VaList(bp+16, i)) @@ -168987,14 +166155,14 @@ func sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int bp := tls.Alloc(76) defer tls.Free(76) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 0 // Return code - var pRet uintptr // New object to return + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_OK // Return code + var pRet uintptr // New object to return var i int32 var nByte Sqlite3_int64 *(*uintptr)(unsafe.Pointer(ppOut)) = libc.AssignUintptr(&pRet, Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5Config{})))) if pRet == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pRet, 0, uint64(unsafe.Sizeof(Fts5Config{}))) (*Fts5Config)(unsafe.Pointer(pRet)).Fdb = db @@ -169003,16 +166171,16 @@ func sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int nByte = (Sqlite3_int64(uint64(nArg) * (uint64(unsafe.Sizeof(uintptr(0))) + uint64(unsafe.Sizeof(U8(0)))))) (*Fts5Config)(unsafe.Pointer(pRet)).FazCol = sqlite3Fts5MallocZero(tls, bp+40 /* &rc */, nByte) (*Fts5Config)(unsafe.Pointer(pRet)).FabUnindexed = ((*Fts5Config)(unsafe.Pointer(pRet)).FazCol + uintptr(nArg)*8) - (*Fts5Config)(unsafe.Pointer(pRet)).FzDb = sqlite3Fts5Strndup(tls, bp+40 /* &rc */, *(*uintptr)(unsafe.Pointer(azArg + uintptr(1)*8)), -1) - (*Fts5Config)(unsafe.Pointer(pRet)).FzName = sqlite3Fts5Strndup(tls, bp+40 /* &rc */, *(*uintptr)(unsafe.Pointer(azArg + uintptr(2)*8)), -1) + (*Fts5Config)(unsafe.Pointer(pRet)).FzDb = sqlite3Fts5Strndup(tls, bp+40 /* &rc */, *(*uintptr)(unsafe.Pointer(azArg + 1*8)), -1) + (*Fts5Config)(unsafe.Pointer(pRet)).FzName = sqlite3Fts5Strndup(tls, bp+40 /* &rc */, *(*uintptr)(unsafe.Pointer(azArg + 2*8)), -1) (*Fts5Config)(unsafe.Pointer(pRet)).FbColumnsize = 1 - (*Fts5Config)(unsafe.Pointer(pRet)).FeDetail = 0 - if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && (Xsqlite3_stricmp(tls, (*Fts5Config)(unsafe.Pointer(pRet)).FzName, ts+23877 /* "rank" */) == 0) { + (*Fts5Config)(unsafe.Pointer(pRet)).FeDetail = FTS5_DETAIL_FULL + if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && (Xsqlite3_stricmp(tls, (*Fts5Config)(unsafe.Pointer(pRet)).FzName, ts+23877 /* "rank" */) == 0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+36931 /* "reserved fts5 ta..." */, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pRet)).FzName)) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } - for i = 3; (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && (i < nArg); i++ { + for i = 3; (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && (i < nArg); i++ { var zOrig uintptr = *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)) var z uintptr *(*uintptr)(unsafe.Pointer(bp + 48 /* zOne */)) = uintptr(0) @@ -169030,19 +166198,19 @@ func sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int } } z = fts5ConfigSkipWhitespace(tls, z) - if (z != 0) && (*(*int8)(unsafe.Pointer(z + uintptr(0))) != 0) { + if (z != 0) && (*(*int8)(unsafe.Pointer(z)) != 0) { // var bDummy int32 at bp+72, 4 z = fts5ConfigGobbleWord(tls, bp+40 /* &rc */, z, bp+64 /* &zTwo */, bp+72 /* &bDummy */) - if (z != 0) && (*(*int8)(unsafe.Pointer(z + uintptr(0))) != 0) { + if (z != 0) && (*(*int8)(unsafe.Pointer(z)) != 0) { z = uintptr(0) } } - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { if z == uintptr(0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+36960 /* "parse error in \"..." */, libc.VaList(bp+8, zOrig)) - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR } else { if bOption != 0 { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5ConfigParseSpecial(tls, pGlobal, pRet, *(*uintptr)(unsafe.Pointer(bp + 48 /* zOne */)), func() uintptr { @@ -169065,15 +166233,15 @@ func sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int // If a tokenizer= option was successfully parsed, the tokenizer has // already been allocated. Otherwise, allocate an instance of the default // tokenizer (unicode61) now. - if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && ((*Fts5Config)(unsafe.Pointer(pRet)).FpTok == uintptr(0)) { + if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pRet)).FpTok == uintptr(0)) { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5ConfigDefaultTokenizer(tls, pGlobal, pRet) } // If no zContent option was specified, fill in the default values. - if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && ((*Fts5Config)(unsafe.Pointer(pRet)).FzContent == uintptr(0)) { + if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pRet)).FzContent == uintptr(0)) { var zTail uintptr = uintptr(0) - if (*Fts5Config)(unsafe.Pointer(pRet)).FeContent == 0 { + if (*Fts5Config)(unsafe.Pointer(pRet)).FeContent == FTS5_CONTENT_NORMAL { zTail = ts + 36629 /* "content" */ } else if (*Fts5Config)(unsafe.Pointer(pRet)).FbColumnsize != 0 { zTail = ts + 36980 /* "docsize" */ @@ -169085,16 +166253,16 @@ func sqlite3Fts5ConfigParse(tls *libc.TLS, pGlobal uintptr, db uintptr, nArg int } } - if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && ((*Fts5Config)(unsafe.Pointer(pRet)).FzContentRowid == uintptr(0)) { + if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pRet)).FzContentRowid == uintptr(0)) { (*Fts5Config)(unsafe.Pointer(pRet)).FzContentRowid = sqlite3Fts5Strndup(tls, bp+40 /* &rc */, ts+10064 /* "rowid" */, -1) } // Formulate the zContentExprlist text - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5ConfigMakeExprlist(tls, pRet) } - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { sqlite3Fts5ConfigFree(tls, pRet) *(*uintptr)(unsafe.Pointer(ppOut)) = uintptr(0) } @@ -169132,7 +166300,7 @@ func sqlite3Fts5ConfigDeclareVtab(tls *libc.TLS, pConfig uintptr) int32 { /* sql defer tls.Free(52) var i int32 - *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 48 /* rc */)) = SQLITE_OK var zSql uintptr zSql = sqlite3Fts5Mprintf(tls, bp+48 /* &rc */, ts+36999 /* "CREATE TABLE x(" */, 0) @@ -169179,7 +166347,7 @@ func sqlite3Fts5ConfigDeclareVtab(tls *libc.TLS, pConfig uintptr) int32 { /* sql // to be an SQLite error code and returned to the caller. func sqlite3Fts5Tokenize(tls *libc.TLS, pConfig uintptr, flags int32, pText uintptr, nText int32, pCtx uintptr, xToken uintptr) int32 { /* sqlite3.c:212650:12: */ if pText == uintptr(0) { - return 0 + return SQLITE_OK } return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*Fts5Config)(unsafe.Pointer(pConfig)).FpTokApi + 16 /* &.xTokenize */))))(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FpTok, pCtx, flags, pText, nText, xToken) @@ -169224,13 +166392,13 @@ func sqlite3Fts5ConfigParseRank(tls *libc.TLS, zIn uintptr, pzRank uintptr, pzRa var pRank uintptr var zRank uintptr = uintptr(0) var zRankArgs uintptr = uintptr(0) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK *(*uintptr)(unsafe.Pointer(pzRank)) = uintptr(0) *(*uintptr)(unsafe.Pointer(pzRankArgs)) = uintptr(0) if p == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR } else { p = fts5ConfigSkipWhitespace(tls, p) pRank = p @@ -169242,24 +166410,24 @@ func sqlite3Fts5ConfigParseRank(tls *libc.TLS, zIn uintptr, pzRank uintptr, pzRa libc.Xmemcpy(tls, zRank, pRank, (uint64((int64(p) - int64(pRank)) / 1))) } } else { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { p = fts5ConfigSkipWhitespace(tls, p) if int32(*(*int8)(unsafe.Pointer(p))) != '(' { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR } p++ } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { var pArgs uintptr p = fts5ConfigSkipWhitespace(tls, p) pArgs = p if int32(*(*int8)(unsafe.Pointer(p))) != ')' { p = fts5ConfigSkipArgs(tls, p) if p == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR } else { zRankArgs = sqlite3Fts5MallocZero(tls, bp /* &rc */, (int64(((int64(uintptr(1) + p)) - int64(pArgs)) / 1))) if zRankArgs != 0 { @@ -169270,7 +166438,7 @@ func sqlite3Fts5ConfigParseRank(tls *libc.TLS, zIn uintptr, pzRank uintptr, pzRa } } - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { Xsqlite3_free(tls, zRank) } else { @@ -169284,11 +166452,11 @@ func sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVa bp := tls.Alloc(16) defer tls.Free(16) - var rc int32 = 0 + var rc int32 = SQLITE_OK if 0 == Xsqlite3_stricmp(tls, zKey, ts+37048 /* "pgsz" */) { var pgsz int32 = 0 - if 1 == Xsqlite3_value_numeric_type(tls, pVal) { + if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) { pgsz = Xsqlite3_value_int(tls, pVal) } if (pgsz < 32) || (pgsz > (64 * 1024)) { @@ -169298,7 +166466,7 @@ func sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVa } } else if 0 == Xsqlite3_stricmp(tls, zKey, ts+37053 /* "hashsize" */) { var nHashSize int32 = -1 - if 1 == Xsqlite3_value_numeric_type(tls, pVal) { + if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) { nHashSize = Xsqlite3_value_int(tls, pVal) } if nHashSize <= 0 { @@ -169308,20 +166476,20 @@ func sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVa } } else if 0 == Xsqlite3_stricmp(tls, zKey, ts+37062 /* "automerge" */) { var nAutomerge int32 = -1 - if 1 == Xsqlite3_value_numeric_type(tls, pVal) { + if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) { nAutomerge = Xsqlite3_value_int(tls, pVal) } if (nAutomerge < 0) || (nAutomerge > 64) { *(*int32)(unsafe.Pointer(pbBadkey)) = 1 } else { if nAutomerge == 1 { - nAutomerge = 4 + nAutomerge = FTS5_DEFAULT_AUTOMERGE } (*Fts5Config)(unsafe.Pointer(pConfig)).FnAutomerge = nAutomerge } } else if 0 == Xsqlite3_stricmp(tls, zKey, ts+37072 /* "usermerge" */) { var nUsermerge int32 = -1 - if 1 == Xsqlite3_value_numeric_type(tls, pVal) { + if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) { nUsermerge = Xsqlite3_value_int(tls, pVal) } if (nUsermerge < 2) || (nUsermerge > 16) { @@ -169331,17 +166499,17 @@ func sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVa } } else if 0 == Xsqlite3_stricmp(tls, zKey, ts+37082 /* "crisismerge" */) { var nCrisisMerge int32 = -1 - if 1 == Xsqlite3_value_numeric_type(tls, pVal) { + if SQLITE_INTEGER == Xsqlite3_value_numeric_type(tls, pVal) { nCrisisMerge = Xsqlite3_value_int(tls, pVal) } if nCrisisMerge < 0 { *(*int32)(unsafe.Pointer(pbBadkey)) = 1 } else { if nCrisisMerge <= 1 { - nCrisisMerge = 16 + nCrisisMerge = FTS5_DEFAULT_CRISISMERGE } - if nCrisisMerge >= 2000 { - nCrisisMerge = (2000 - 1) + if nCrisisMerge >= FTS5_MAX_SEGMENT { + nCrisisMerge = (FTS5_MAX_SEGMENT - 1) } (*Fts5Config)(unsafe.Pointer(pConfig)).FnCrisisMerge = nCrisisMerge } @@ -169352,13 +166520,13 @@ func sqlite3Fts5ConfigSetValue(tls *libc.TLS, pConfig uintptr, zKey uintptr, pVa // var zRankArgs uintptr at bp+8, 8 rc = sqlite3Fts5ConfigParseRank(tls, zIn, bp /* &zRank */, bp+8 /* &zRankArgs */) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzRank) Xsqlite3_free(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).FzRankArgs) (*Fts5Config)(unsafe.Pointer(pConfig)).FzRank = *(*uintptr)(unsafe.Pointer(bp /* zRank */)) (*Fts5Config)(unsafe.Pointer(pConfig)).FzRankArgs = *(*uintptr)(unsafe.Pointer(bp + 8 /* zRankArgs */)) - } else if rc == 1 { - rc = 0 + } else if rc == SQLITE_ERROR { + rc = SQLITE_OK *(*int32)(unsafe.Pointer(pbBadkey)) = 1 } } else { @@ -169375,14 +166543,14 @@ func sqlite3Fts5ConfigLoad(tls *libc.TLS, pConfig uintptr, iCookie int32) int32 var zSelect uintptr = ts + 37094 /* "SELECT k, v FROM..." */ var zSql uintptr *(*uintptr)(unsafe.Pointer(bp + 40 /* p */)) = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = SQLITE_OK var iVersion int32 = 0 // Set default values - (*Fts5Config)(unsafe.Pointer(pConfig)).Fpgsz = 4050 - (*Fts5Config)(unsafe.Pointer(pConfig)).FnAutomerge = 4 - (*Fts5Config)(unsafe.Pointer(pConfig)).FnUsermerge = 4 - (*Fts5Config)(unsafe.Pointer(pConfig)).FnCrisisMerge = 16 + (*Fts5Config)(unsafe.Pointer(pConfig)).Fpgsz = FTS5_DEFAULT_PAGE_SIZE + (*Fts5Config)(unsafe.Pointer(pConfig)).FnAutomerge = FTS5_DEFAULT_AUTOMERGE + (*Fts5Config)(unsafe.Pointer(pConfig)).FnUsermerge = FTS5_DEFAULT_USERMERGE + (*Fts5Config)(unsafe.Pointer(pConfig)).FnCrisisMerge = FTS5_DEFAULT_CRISISMERGE (*Fts5Config)(unsafe.Pointer(pConfig)).FnHashSize = (1024 * 1024) zSql = sqlite3Fts5Mprintf(tls, bp+32 /* &rc */, zSelect, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) @@ -169391,8 +166559,8 @@ func sqlite3Fts5ConfigLoad(tls *libc.TLS, pConfig uintptr, iCookie int32) int32 Xsqlite3_free(tls, zSql) } - if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0 { - for 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* p */))) { + if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK { + for SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* p */))) { var zK uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* p */)), 0) var pVal uintptr = Xsqlite3_column_value(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* p */)), 1) if 0 == Xsqlite3_stricmp(tls, zK, ts+37126 /* "version" */) { @@ -169405,17 +166573,17 @@ func sqlite3Fts5ConfigLoad(tls *libc.TLS, pConfig uintptr, iCookie int32) int32 *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* p */))) } - if (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0) && (iVersion != 4) { - *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = 1 + if (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK) && (iVersion != FTS5_CURRENT_VERSION) { + *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = SQLITE_ERROR if (*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg != 0 { *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg)) = Xsqlite3_mprintf(tls, ts+37134, /* "invalid fts5 fil..." */ - libc.VaList(bp+16, iVersion, 4)) + libc.VaList(bp+16, iVersion, FTS5_CURRENT_VERSION)) } } - if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK { (*Fts5Config)(unsafe.Pointer(pConfig)).FiCookie = iCookie } return *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) @@ -169470,9 +166638,9 @@ func sqlite3Fts5ParseError(tls *libc.TLS, pParse uintptr, zFmt uintptr, va uintp var ap Va_list _ = ap ap = va - if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { (*Fts5Parse)(unsafe.Pointer(pParse)).FzErr = Xsqlite3_vmprintf(tls, zFmt, ap) - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 1 + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR } _ = ap } @@ -169498,54 +166666,54 @@ func fts5ExprGetToken(tls *libc.TLS, pParse uintptr, pz uintptr, pToken uintptr) (*Fts5Token)(unsafe.Pointer(pToken)).Fn = 1 switch int32(*(*int8)(unsafe.Pointer(z))) { case '(': - tok = 10 + tok = FTS5_LP break case ')': - tok = 11 + tok = FTS5_RP break case '{': - tok = 7 + tok = FTS5_LCP break case '}': - tok = 8 + tok = FTS5_RCP break case ':': - tok = 5 + tok = FTS5_COLON break case ',': - tok = 13 + tok = FTS5_COMMA break case '+': - tok = 14 + tok = FTS5_PLUS break case '*': - tok = 15 + tok = FTS5_STAR break case '-': - tok = 6 + tok = FTS5_MINUS break case '^': - tok = 12 + tok = FTS5_CARET break case 0: - tok = 0 + tok = FTS5_EOF break case '"': { var z2 uintptr - tok = 9 + tok = FTS5_STRING - for z2 = (z + uintptr(1)); 1 != 0; z2++ { - if int32(*(*int8)(unsafe.Pointer(z2 + uintptr(0)))) == '"' { + for z2 = (z + 1); 1 != 0; z2++ { + if int32(*(*int8)(unsafe.Pointer(z2))) == '"' { z2++ - if int32(*(*int8)(unsafe.Pointer(z2 + uintptr(0)))) != '"' { + if int32(*(*int8)(unsafe.Pointer(z2))) != '"' { break } } - if int32(*(*int8)(unsafe.Pointer(z2 + uintptr(0)))) == 0 { + if int32(*(*int8)(unsafe.Pointer(z2))) == 0 { sqlite3Fts5ParseError(tls, pParse, ts+37199 /* "unterminated str..." */, 0) - return 0 + return FTS5_EOF } } (*Fts5Token)(unsafe.Pointer(pToken)).Fn = (int32((int64(z2) - int64(z)) / 1)) @@ -169556,22 +166724,22 @@ func fts5ExprGetToken(tls *libc.TLS, pParse uintptr, pz uintptr, pToken uintptr) default: { var z2 uintptr - if sqlite3Fts5IsBareword(tls, *(*int8)(unsafe.Pointer(z + uintptr(0)))) == 0 { + if sqlite3Fts5IsBareword(tls, *(*int8)(unsafe.Pointer(z))) == 0 { sqlite3Fts5ParseError(tls, pParse, ts+37219 /* "fts5: syntax err..." */, libc.VaList(bp, z)) - return 0 + return FTS5_EOF } - tok = 9 - for z2 = (z + uintptr(1)); sqlite3Fts5IsBareword(tls, *(*int8)(unsafe.Pointer(z2))) != 0; z2++ { + tok = FTS5_STRING + for z2 = (z + 1); sqlite3Fts5IsBareword(tls, *(*int8)(unsafe.Pointer(z2))) != 0; z2++ { } (*Fts5Token)(unsafe.Pointer(pToken)).Fn = (int32((int64(z2) - int64(z)) / 1)) if ((*Fts5Token)(unsafe.Pointer(pToken)).Fn == 2) && (libc.Xmemcmp(tls, (*Fts5Token)(unsafe.Pointer(pToken)).Fp, ts+37250 /* "OR" */, uint64(2)) == 0) { - tok = 1 + tok = FTS5_OR } if ((*Fts5Token)(unsafe.Pointer(pToken)).Fn == 3) && (libc.Xmemcmp(tls, (*Fts5Token)(unsafe.Pointer(pToken)).Fp, ts+37253 /* "NOT" */, uint64(3)) == 0) { - tok = 3 + tok = FTS5_NOT } if ((*Fts5Token)(unsafe.Pointer(pToken)).Fn == 3) && (libc.Xmemcmp(tls, (*Fts5Token)(unsafe.Pointer(pToken)).Fp, ts+33330 /* "AND" */, uint64(3)) == 0) { - tok = 2 + tok = FTS5_AND } break @@ -169608,11 +166776,11 @@ func sqlite3Fts5ExprNew(tls *libc.TLS, pConfig uintptr, iCol int32, zExpr uintpt libc.Xmemset(tls, bp /* &sParse */, 0, uint64(unsafe.Sizeof(Fts5Parse{}))) pEngine = sqlite3Fts5ParserAlloc(tls, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, U64) uintptr }{fts5ParseAlloc}))) if pEngine == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).FpConfig = pConfig - for ok := true; ok; ok = (((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == 0) && (t != 0)) { + for ok := true; ok; ok = (((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == SQLITE_OK) && (t != FTS5_EOF)) { t = fts5ExprGetToken(tls, bp /* &sParse */, bp+40 /* &z */, bp+48 /* &token */) sqlite3Fts5Parser(tls, pEngine, t, *(*Fts5Token)(unsafe.Pointer(bp + 48 /* token */)), bp /* &sParse */) } @@ -169620,20 +166788,20 @@ func sqlite3Fts5ExprNew(tls *libc.TLS, pConfig uintptr, iCol int32, zExpr uintpt // If the LHS of the MATCH expression was a user column, apply the // implicit column-filter. - if ((iCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) && ((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).FpExpr != 0)) && ((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == 0) { + if ((iCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) && ((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).FpExpr != 0)) && ((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == SQLITE_OK) { var n int32 = int32(unsafe.Sizeof(Fts5Colset{})) var pColset uintptr = sqlite3Fts5MallocZero(tls, (bp /* &sParse */ + 16 /* &.rc */), int64(n)) if pColset != 0 { (*Fts5Colset)(unsafe.Pointer(pColset)).FnCol = 1 - *(*int32)(unsafe.Pointer((pColset + 4 /* &.aiCol */) + uintptr(0)*4)) = iCol + *(*int32)(unsafe.Pointer((pColset + 4 /* &.aiCol */))) = iCol sqlite3Fts5ParseSetColset(tls, bp /* &sParse */, (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).FpExpr, pColset) } } - if (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == SQLITE_OK { *(*uintptr)(unsafe.Pointer(ppNew)) = libc.AssignUintptr(&pNew, Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5Expr{})))) if pNew == uintptr(0) { - (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc = 7 + (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc = SQLITE_NOMEM sqlite3Fts5ParseNodeFree(tls, (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).FpExpr) } else { if !(int32((*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).FpExpr) != 0) { @@ -169693,14 +166861,14 @@ func sqlite3Fts5ExprAnd(tls *libc.TLS, pp1 uintptr, p2 uintptr) int32 { /* sqlit var p1 uintptr = *(*uintptr)(unsafe.Pointer(pp1)) var nPhrase int32 = ((*Fts5Expr)(unsafe.Pointer(p1)).FnPhrase + (*Fts5Expr)(unsafe.Pointer(p2)).FnPhrase) - (*Fts5Expr)(unsafe.Pointer(p1)).FpRoot = sqlite3Fts5ParseNode(tls, bp /* &sParse */, 2, (*Fts5Expr)(unsafe.Pointer(p1)).FpRoot, (*Fts5Expr)(unsafe.Pointer(p2)).FpRoot, uintptr(0)) + (*Fts5Expr)(unsafe.Pointer(p1)).FpRoot = sqlite3Fts5ParseNode(tls, bp /* &sParse */, FTS5_AND, (*Fts5Expr)(unsafe.Pointer(p1)).FpRoot, (*Fts5Expr)(unsafe.Pointer(p2)).FpRoot, uintptr(0)) (*Fts5Expr)(unsafe.Pointer(p2)).FpRoot = uintptr(0) - if (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc == SQLITE_OK { var ap uintptr = Xsqlite3_realloc(tls, (*Fts5Expr)(unsafe.Pointer(p1)).FapExprPhrase, (int32(uint64(nPhrase) * uint64(unsafe.Sizeof(uintptr(0)))))) if ap == uintptr(0) { - (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc = 7 + (*Fts5Parse)(unsafe.Pointer(bp /* &sParse */)).Frc = SQLITE_NOMEM } else { var i int32 libc.Xmemmove(tls, (ap + uintptr((*Fts5Expr)(unsafe.Pointer(p2)).FnPhrase)*8), ap, (uint64((*Fts5Expr)(unsafe.Pointer(p1)).FnPhrase) * uint64(unsafe.Sizeof(uintptr(0))))) @@ -169766,7 +166934,7 @@ func fts5ExprSynonymList(tls *libc.TLS, pTerm uintptr, iRowid I64, pBuf uintptr, aIter = bp /* aStatic */ nIter = 0 nAlloc = 4 - rc = 0 + rc = SQLITE_OK p = pTerm __1: @@ -169791,7 +166959,7 @@ __5: if !(aNew == uintptr(0)) { goto __7 } - rc = 7 + rc = SQLITE_NOMEM goto synonym_poslist_out __7: ; @@ -169822,8 +166990,8 @@ __3: if !(nIter == 1) { goto __9 } - *(*uintptr)(unsafe.Pointer(pa)) = (*Fts5PoslistReader)(unsafe.Pointer(aIter + uintptr(0)*32)).Fa - *(*int32)(unsafe.Pointer(pn)) = (*Fts5PoslistReader)(unsafe.Pointer(aIter + uintptr(0)*32)).Fn + *(*uintptr)(unsafe.Pointer(pa)) = (*Fts5PoslistReader)(unsafe.Pointer(aIter)).Fa + *(*int32)(unsafe.Pointer(pn)) = (*Fts5PoslistReader)(unsafe.Pointer(aIter)).Fn goto __10 __9: *(*Fts5PoslistWriter)(unsafe.Pointer(bp + 128 /* writer */)) = Fts5PoslistWriter{} @@ -169868,7 +167036,7 @@ __14: goto __15 __15: ; - if !((iMin == (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))) || (rc != 0)) { + if !((iMin == (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))) || (rc != SQLITE_OK)) { goto __20 } goto __12 @@ -169879,7 +167047,7 @@ __20: goto __11 __12: ; - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __21 } *(*uintptr)(unsafe.Pointer(pa)) = (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp @@ -169935,8 +167103,8 @@ func fts5ExprPhraseIsMatch(tls *libc.TLS, pNode uintptr, pPhrase uintptr, pbMatc var iPos I64 *(*Fts5PoslistWriter)(unsafe.Pointer(bp + 160 /* writer */)) = Fts5PoslistWriter{} aIter = bp /* aStatic */ - rc = 0 - bFirst = int32((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32)).FbFirst) + rc = SQLITE_OK + bFirst = int32((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FbFirst) sqlite3Fts5BufferZero(tls, (pPhrase + 8 /* &.poslist */)) @@ -169950,7 +167118,7 @@ func fts5ExprPhraseIsMatch(tls *libc.TLS, pNode uintptr, pPhrase uintptr, pbMatc if !(!(aIter != 0)) { goto __2 } - return 7 + return SQLITE_NOMEM __2: ; __1: @@ -170011,7 +167179,7 @@ __11: if !(1 != 0) { goto __12 } - iPos = (*Fts5PoslistReader)(unsafe.Pointer(aIter + uintptr(0)*32)).FiPos + iPos = (*Fts5PoslistReader)(unsafe.Pointer(aIter)).FiPos __13: bMatch = 1 i = 0 @@ -170067,7 +167235,7 @@ __15: goto __24 } rc = sqlite3Fts5PoslistWriterAppend(tls, (pPhrase + 8 /* &.poslist */), bp+160 /* &writer */, iPos) - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __25 } goto ismatch_out @@ -170213,7 +167381,7 @@ __1: libc.Xmemset(tls, bp /* &aStatic[0] */, 0, uint64(unsafe.Sizeof([4]Fts5NearTrimmer{}))) __2: ; - if !(*(*int32)(unsafe.Pointer(bp + 192 /* rc */)) != 0) { + if !(*(*int32)(unsafe.Pointer(bp + 192 /* rc */)) != SQLITE_OK) { goto __3 } *(*int32)(unsafe.Pointer(pRc)) = *(*int32)(unsafe.Pointer(bp + 192 /* rc */)) @@ -170253,7 +167421,7 @@ __7: // This block advances the phrase iterators until they point to a set of // entries that together comprise a match. - iMax = (*Fts5NearTrimmer)(unsafe.Pointer(a + uintptr(0)*48)).Freader.FiPos + iMax = (*Fts5NearTrimmer)(unsafe.Pointer(a)).Freader.FiPos __9: bMatch = 1 i = 0 @@ -170327,7 +167495,7 @@ __22: ; iAdv = 0 - iMin = (*Fts5NearTrimmer)(unsafe.Pointer(a + uintptr(0)*48)).Freader.FiLookahead + iMin = (*Fts5NearTrimmer)(unsafe.Pointer(a)).Freader.FiLookahead i = 0 __24: if !(i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase) { @@ -170358,7 +167526,7 @@ __8: ; ismatch_out: - bRet = (libc.Bool32((*Fts5Buffer)(unsafe.Pointer((*Fts5NearTrimmer)(unsafe.Pointer(a+uintptr(0)*48)).FpOut)).Fn > 0)) + bRet = (libc.Bool32((*Fts5Buffer)(unsafe.Pointer((*Fts5NearTrimmer)(unsafe.Pointer(a)).FpOut)).Fn > 0)) *(*int32)(unsafe.Pointer(pRc)) = *(*int32)(unsafe.Pointer(bp + 192 /* rc */)) if !(a != bp /* aStatic */) { goto __29 @@ -170402,12 +167570,12 @@ func fts5ExprSynonymAdvanceto(tls *libc.TLS, pTerm uintptr, bDesc int32, piLast bp := tls.Alloc(4) defer tls.Free(4) - var rc int32 = 0 + var rc int32 = SQLITE_OK var iLast I64 = *(*I64)(unsafe.Pointer(piLast)) var p uintptr *(*int32)(unsafe.Pointer(bp /* bEof */)) = 0 - for p = pTerm; (rc == 0) && (p != 0); p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym { + for p = pTerm; (rc == SQLITE_OK) && (p != 0); p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym { if (int32((*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof)) == 0 { var iRowid I64 = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FiRowid if ((bDesc == 0) && (iLast > iRowid)) || ((bDesc != 0) && (iLast < iRowid)) { @@ -170416,7 +167584,7 @@ func fts5ExprSynonymAdvanceto(tls *libc.TLS, pTerm uintptr, bDesc int32, piLast } } - if rc != 0 { + if rc != SQLITE_OK { *(*int32)(unsafe.Pointer(pRc)) = rc *(*int32)(unsafe.Pointer(bp /* bEof */)) = 1 } else { @@ -170432,11 +167600,11 @@ func fts5ExprNearTest(tls *libc.TLS, pRc uintptr, pExpr uintptr, pNode uintptr) var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = *(*int32)(unsafe.Pointer(pRc)) - if (*Fts5Config)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FeDetail != 0 { + if (*Fts5Config)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FeDetail != FTS5_DETAIL_FULL { var pTerm uintptr - var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(0)*8)) + var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */))) (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn = 0 - for pTerm = ((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32); pTerm != 0; pTerm = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym { + for pTerm = (pPhrase + 32 /* &.aTerm */); pTerm != 0; pTerm = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym { var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpIter if (int32((*Fts5IndexIter)(unsafe.Pointer(pIter)).FbEof)) == 0 { if ((*Fts5IndexIter)(unsafe.Pointer(pIter)).FiRowid == (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid) && ((*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData > 0) { @@ -170451,17 +167619,17 @@ func fts5ExprNearTest(tls *libc.TLS, pRc uintptr, pExpr uintptr, pNode uintptr) // Check that each phrase in the nearset matches the current row. // Populate the pPhrase->poslist buffers at the same time. If any // phrase is not a match, break out of the loop early. - for i = 0; (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0) && (i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase); i++ { + for i = 0; (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK) && (i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase); i++ { var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(i)*8)) - if ((((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 1) || ((*Fts5ExprTerm)(unsafe.Pointer((pPhrase+32 /* &.aTerm */)+uintptr(0)*32)).FpSynonym != 0)) || - ((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset != 0)) || ((*Fts5ExprTerm)(unsafe.Pointer((pPhrase+32 /* &.aTerm */)+uintptr(0)*32)).FbFirst != 0) { + if ((((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 1) || ((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FpSynonym != 0)) || + ((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset != 0)) || ((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FbFirst != 0) { *(*int32)(unsafe.Pointer(bp /* bMatch */)) = 0 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = fts5ExprPhraseIsMatch(tls, pNode, pPhrase, bp /* &bMatch */) if *(*int32)(unsafe.Pointer(bp /* bMatch */)) == 0 { break } } else { - var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32)).FpIter + var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FpIter sqlite3Fts5BufferSet(tls, bp+4 /* &rc */, (pPhrase + 8 /* &.poslist */), (*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData, (*Fts5IndexIter)(unsafe.Pointer(pIter)).FpData) } } @@ -170490,7 +167658,7 @@ func fts5ExprNearInitAll(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(i)*8)) if (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm == 0 { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 1 - return 0 + return SQLITE_OK } else { var j int32 for j = 0; j < (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm; j++ { @@ -170508,19 +167676,19 @@ func fts5ExprNearInitAll(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* (*Fts5Expr)(unsafe.Pointer(pExpr)).FpIndex, (*Fts5ExprTerm)(unsafe.Pointer(p)).FzTerm, int32(libc.Xstrlen(tls, (*Fts5ExprTerm)(unsafe.Pointer(p)).FzTerm)), ((func() int32 { if (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FbPrefix != 0 { - return 0x0001 + return FTS5INDEX_QUERY_PREFIX } return 0 }()) | (func() int32 { if (*Fts5Expr)(unsafe.Pointer(pExpr)).FbDesc != 0 { - return 0x0002 + return FTS5INDEX_QUERY_DESC } return 0 }())), (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset, (p + 16 /* &.pIter */)) - if rc != 0 { + if rc != SQLITE_OK { return rc } if 0 == (int32((*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof)) { @@ -170530,14 +167698,14 @@ func fts5ExprNearInitAll(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* if bHit == 0 { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 1 - return 0 + return SQLITE_OK } } } } (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 0 - return 0 + return SQLITE_OK } // If pExpr is an ASC iterator, this function returns a value with the @@ -170574,7 +167742,7 @@ func fts5ExprSetEof(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:213788:13: */ } func fts5ExprNodeZeroPoslist(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:213797:13: */ - if ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == 9) || ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == 4) { + if ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_STRING) || ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_TERM) { var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear var i int32 for i = 0; i < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase; i++ { @@ -170623,8 +167791,8 @@ func fts5ExprNodeTest_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 defer tls.Free(12) var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear - var pLeft uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(0)*8)) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + var pLeft uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */))) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK // var iLast I64 at bp, 8 // Lastest rowid any iterator points to var i int32 @@ -170638,10 +167806,10 @@ func fts5ExprNodeTest_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 // iterator skips through rowids in the default ascending order, this means // the maximum rowid. Or, if the iterator is "ORDER BY rowid DESC", then it // means the minimum rowid. - if (*Fts5ExprTerm)(unsafe.Pointer((pLeft+32 /* &.aTerm */)+uintptr(0)*32)).FpSynonym != 0 { - *(*I64)(unsafe.Pointer(bp /* iLast */)) = fts5ExprSynonymRowid(tls, ((pLeft + 32 /* &.aTerm */) + uintptr(0)*32), bDesc, uintptr(0)) + if (*Fts5ExprTerm)(unsafe.Pointer((pLeft + 32 /* &.aTerm */))).FpSynonym != 0 { + *(*I64)(unsafe.Pointer(bp /* iLast */)) = fts5ExprSynonymRowid(tls, (pLeft + 32 /* &.aTerm */), bDesc, uintptr(0)) } else { - *(*I64)(unsafe.Pointer(bp /* iLast */)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer((pLeft + 32 /* &.aTerm */) + uintptr(0)*32)).FpIter)).FiRowid + *(*I64)(unsafe.Pointer(bp /* iLast */)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer((pLeft + 32 /* &.aTerm */))).FpIter)).FiRowid } for ok := true; ok; ok = (bMatch == 0) { @@ -170676,7 +167844,7 @@ func fts5ExprNodeTest_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 } (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = *(*I64)(unsafe.Pointer(bp /* iLast */)) - (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = (libc.Bool32((0 == fts5ExprNearTest(tls, bp+8 /* &rc */, pExpr, pNode)) && (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0))) + (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = (libc.Bool32((0 == fts5ExprNearTest(tls, bp+8 /* &rc */, pExpr, pNode)) && (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK))) return *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) } @@ -170687,8 +167855,8 @@ func fts5ExprNodeTest_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 // Return SQLITE_OK if successful, or an SQLite error code if an error // occurs. func fts5ExprNodeNext_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 { /* sqlite3.c:213918:12: */ - var pTerm uintptr = ((*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */) + uintptr(0)*8)) + 32 /* &.aTerm */) + uintptr(0)*32) - var rc int32 = 0 + var pTerm uintptr = (*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */))) + 32 /* &.aTerm */) + var rc int32 = SQLITE_OK (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 if (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0 { @@ -170710,7 +167878,7 @@ func fts5ExprNodeNext_STRING(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromV } else { rc = sqlite3Fts5IterNext(tls, (*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter) } - if rc != 0 { + if rc != SQLITE_OK { break } if (int32((*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer(p)).FpIter)).FbEof)) == 0 { @@ -170751,29 +167919,29 @@ func fts5ExprNodeTest_TERM(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { // fts5_index.c iterator object. This is much faster than synthesizing // a new poslist the way we have to for more complicated phrase or NEAR // expressions. - var pPhrase uintptr = *(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */) + uintptr(0)*8)) - var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32)).FpIter + var pPhrase uintptr = *(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */))) + var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FpIter (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn = (*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData - if (*Fts5Config)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FeDetail == 0 { + if (*Fts5Config)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig)).FeDetail == FTS5_DETAIL_FULL { (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fp = (*Fts5IndexIter)(unsafe.Pointer(pIter)).FpData } (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*Fts5IndexIter)(unsafe.Pointer(pIter)).FiRowid (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = (libc.Bool32((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn == 0)) - return 0 + return SQLITE_OK } // xNext() method for a node of type FTS5_TERM. func fts5ExprNodeNext_TERM(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 { /* sqlite3.c:214011:12: */ var rc int32 - var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */) + uintptr(0)*8)) + 32 /* &.aTerm */) + uintptr(0)*32)).FpIter + var pIter uintptr = (*Fts5ExprTerm)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */))) + 32 /* &.aTerm */))).FpIter if bFromValid != 0 { rc = sqlite3Fts5IterNextFrom(tls, pIter, iFrom) } else { rc = sqlite3Fts5IterNext(tls, pIter) } - if (rc == 0) && ((int32((*Fts5IndexIter)(unsafe.Pointer(pIter)).FbEof)) == 0) { + if (rc == SQLITE_OK) && ((int32((*Fts5IndexIter)(unsafe.Pointer(pIter)).FbEof)) == 0) { rc = fts5ExprNodeTest_TERM(tls, pExpr, pNode) } else { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 1 @@ -170783,7 +167951,7 @@ func fts5ExprNodeNext_TERM(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromVal } func fts5ExprNodeTest_OR(tls *libc.TLS, pExpr uintptr, pNode uintptr) { /* sqlite3.c:214035:13: */ - var pNext uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)) + var pNext uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))) var i int32 for i = 1; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ { @@ -170809,7 +167977,7 @@ func fts5ExprNodeNext_OR(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid if ((*Fts5ExprNode)(unsafe.Pointer(p1)).FiRowid == iLast) || ((bFromValid != 0) && (fts5RowidCmp(tls, pExpr, (*Fts5ExprNode)(unsafe.Pointer(p1)).FiRowid, iFrom) < 0)) { var rc int32 = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((p1 + 16 /* &.xNext */))))(tls, pExpr, p1, bFromValid, iFrom) - if rc != 0 { + if rc != SQLITE_OK { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 return rc } @@ -170818,14 +167986,14 @@ func fts5ExprNodeNext_OR(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid } fts5ExprNodeTest_OR(tls, pExpr, pNode) - return 0 + return SQLITE_OK } // Argument pNode is an FTS5_AND node. func fts5ExprNodeTest_AND(tls *libc.TLS, pExpr uintptr, pAnd uintptr) int32 { /* sqlite3.c:214086:12: */ var iChild int32 var iLast I64 = (*Fts5ExprNode)(unsafe.Pointer(pAnd)).FiRowid - var rc int32 = 0 + var rc int32 = SQLITE_OK var bMatch int32 for ok := true; ok; ok = (bMatch == 0) { @@ -170837,7 +168005,7 @@ func fts5ExprNodeTest_AND(tls *libc.TLS, pExpr uintptr, pAnd uintptr) int32 { /* if cmp > 0 { // Advance pChild until it points to iLast or laster rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((pChild + 16 /* &.xNext */))))(tls, pExpr, pChild, 1, iLast) - if rc != 0 { + if rc != SQLITE_OK { (*Fts5ExprNode)(unsafe.Pointer(pAnd)).FbNomatch = 0 return rc } @@ -170867,12 +168035,12 @@ func fts5ExprNodeTest_AND(tls *libc.TLS, pExpr uintptr, pAnd uintptr) int32 { /* fts5ExprNodeZeroPoslist(tls, pAnd) } (*Fts5ExprNode)(unsafe.Pointer(pAnd)).FiRowid = iLast - return 0 + return SQLITE_OK } func fts5ExprNodeNext_AND(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 { /* sqlite3.c:214138:12: */ - var rc int32 = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)) + 16 /* &.xNext */))))(tls, pExpr, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)), bFromValid, iFrom) - if rc == 0 { + var rc int32 = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))) + 16 /* &.xNext */))))(tls, pExpr, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))), bFromValid, iFrom) + if rc == SQLITE_OK { rc = fts5ExprNodeTest_AND(tls, pExpr, pNode) } else { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 @@ -170881,11 +168049,11 @@ func fts5ExprNodeNext_AND(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromVali } func fts5ExprNodeTest_NOT(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sqlite3.c:214153:12: */ - var rc int32 = 0 - var p1 uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)) - var p2 uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(1)*8)) + var rc int32 = SQLITE_OK + var p1 uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))) + var p2 uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + 1*8)) - for (rc == 0) && ((*Fts5ExprNode)(unsafe.Pointer(p1)).FbEof == 0) { + for (rc == SQLITE_OK) && ((*Fts5ExprNode)(unsafe.Pointer(p1)).FbEof == 0) { var cmp int32 = fts5NodeCompare(tls, pExpr, p1, p2) if cmp > 0 { rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((p2 + 16 /* &.xNext */))))(tls, pExpr, p2, 1, (*Fts5ExprNode)(unsafe.Pointer(p1)).FiRowid) @@ -170907,11 +168075,11 @@ func fts5ExprNodeTest_NOT(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { / } func fts5ExprNodeNext_NOT(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromValid int32, iFrom I64) int32 { /* sqlite3.c:214181:12: */ - var rc int32 = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)) + 16 /* &.xNext */))))(tls, pExpr, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)), bFromValid, iFrom) - if rc == 0 { + var rc int32 = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))) + 16 /* &.xNext */))))(tls, pExpr, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))), bFromValid, iFrom) + if rc == SQLITE_OK { rc = fts5ExprNodeTest_NOT(tls, pExpr, pNode) } - if rc != 0 { + if rc != SQLITE_OK { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 } return rc @@ -170921,11 +168089,11 @@ func fts5ExprNodeNext_NOT(tls *libc.TLS, pExpr uintptr, pNode uintptr, bFromVali // without modifying it. Otherwise, pNode is advanced until it does point // to a match or EOF is reached. func fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sqlite3.c:214202:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof == 0 { switch (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType { - case 9: + case FTS5_STRING: { rc = fts5ExprNodeTest_STRING(tls, pExpr, pNode) break @@ -170933,7 +168101,7 @@ func fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sq } fallthrough - case 4: + case FTS5_TERM: { rc = fts5ExprNodeTest_TERM(tls, pExpr, pNode) break @@ -170941,7 +168109,7 @@ func fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sq } fallthrough - case 2: + case FTS5_AND: { rc = fts5ExprNodeTest_AND(tls, pExpr, pNode) break @@ -170949,7 +168117,7 @@ func fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sq } fallthrough - case 1: + case FTS5_OR: { fts5ExprNodeTest_OR(tls, pExpr, pNode) break @@ -170974,11 +168142,11 @@ func fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sq // Return an SQLite error code if an error occurs, or SQLITE_OK otherwise. // It is not an error if there are no matches. func fts5ExprNodeFirst(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* sqlite3.c:214247:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 0 (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbNomatch = 0 - if ((*Fts5ExprNode)(unsafe.Pointer((pNode))).FeType == 4) || ((*Fts5ExprNode)(unsafe.Pointer((pNode))).FeType == 9) { + if ((*Fts5ExprNode)(unsafe.Pointer((pNode))).FeType == FTS5_TERM) || ((*Fts5ExprNode)(unsafe.Pointer((pNode))).FeType == FTS5_STRING) { // Initialize all term iterators in the NEAR object. rc = fts5ExprNearInitAll(tls, pExpr, pNode) } else if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext == uintptr(0) { @@ -170986,23 +168154,23 @@ func fts5ExprNodeFirst(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* s } else { var i int32 var nEof int32 = 0 - for i = 0; (i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild) && (rc == 0); i++ { + for i = 0; (i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild) && (rc == SQLITE_OK); i++ { var pChild uintptr = *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(i)*8)) rc = fts5ExprNodeFirst(tls, pExpr, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(i)*8))) nEof = nEof + ((*Fts5ExprNode)(unsafe.Pointer(pChild)).FbEof) } - (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)))).FiRowid + (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = (*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))))).FiRowid switch (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType { - case 2: + case FTS5_AND: if nEof > 0 { fts5ExprSetEof(tls, pNode) } break fallthrough - case 1: + case FTS5_OR: if (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild == nEof { fts5ExprSetEof(tls, pNode) } @@ -171011,12 +168179,12 @@ func fts5ExprNodeFirst(tls *libc.TLS, pExpr uintptr, pNode uintptr) int32 { /* s default: - (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = (*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)))).FbEof + (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = (*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))))).FbEof break } } - if rc == 0 { + if rc == SQLITE_OK { rc = fts5ExprNodeTest(tls, pExpr, pNode) } return rc @@ -171045,7 +168213,7 @@ func sqlite3Fts5ExprFirst(tls *libc.TLS, p uintptr, pIdx uintptr, iFirst I64, bD // If not at EOF but the current rowid occurs earlier than iFirst in // the iteration order, move to document iFirst or later. - if ((rc == 0) && + if ((rc == SQLITE_OK) && (0 == (*Fts5ExprNode)(unsafe.Pointer(pRoot)).FbEof)) && (fts5RowidCmp(tls, p, (*Fts5ExprNode)(unsafe.Pointer(pRoot)).FiRowid, iFirst) < 0) { rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, I64) int32)(unsafe.Pointer((pRoot + 16 /* &.xNext */))))(tls, p, pRoot, 1, iFirst) @@ -171089,7 +168257,7 @@ func fts5ParseStringFromToken(tls *libc.TLS, pToken uintptr, pz uintptr) int32 { bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK *(*uintptr)(unsafe.Pointer(pz)) = sqlite3Fts5Strndup(tls, bp /* &rc */, (*Fts5Token)(unsafe.Pointer(pToken)).Fp, (*Fts5Token)(unsafe.Pointer(pToken)).Fn) return *(*int32)(unsafe.Pointer(bp /* rc */)) } @@ -171107,7 +168275,7 @@ func fts5ExprPhraseFree(tls *libc.TLS, pPhrase uintptr) { /* sqlite3.c:214368:13 for pSyn = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym; pSyn != 0; pSyn = pNext { pNext = (*Fts5ExprTerm)(unsafe.Pointer(pSyn)).FpSynonym sqlite3Fts5IterClose(tls, (*Fts5ExprTerm)(unsafe.Pointer(pSyn)).FpIter) - sqlite3Fts5BufferFree(tls, (pSyn + uintptr(1)*32)) + sqlite3Fts5BufferFree(tls, (pSyn + 1*32)) Xsqlite3_free(tls, pSyn) } } @@ -171122,7 +168290,7 @@ func fts5ExprPhraseFree(tls *libc.TLS, pPhrase uintptr) { /* sqlite3.c:214368:13 // only argument. func sqlite3Fts5ParseSetCaret(tls *libc.TLS, pPhrase uintptr) { /* sqlite3.c:214393:13: */ if (pPhrase != 0) && ((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm != 0) { - (*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32)).FbFirst = U8(1) + (*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FbFirst = U8(1) } } @@ -171136,7 +168304,7 @@ func sqlite3Fts5ParseNearset(tls *libc.TLS, pParse uintptr, pNear uintptr, pPhra var SZALLOC int32 = 8 var pRet uintptr = uintptr(0) - if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { if pPhrase == uintptr(0) { return pNear } @@ -171145,7 +168313,7 @@ func sqlite3Fts5ParseNearset(tls *libc.TLS, pParse uintptr, pNear uintptr, pPhra nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5ExprNearset{})) + (uint64(SZALLOC) * uint64(unsafe.Sizeof(uintptr(0)))))) pRet = Xsqlite3_malloc64(tls, uint64(nByte)) if pRet == uintptr(0) { - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 7 + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM } else { libc.Xmemset(tls, pRet, 0, Size_t(nByte)) } @@ -171156,7 +168324,7 @@ func sqlite3Fts5ParseNearset(tls *libc.TLS, pParse uintptr, pNear uintptr, pPhra nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5ExprNearset{})) + (uint64(nNew) * uint64(unsafe.Sizeof(uintptr(0)))))) pRet = Xsqlite3_realloc64(tls, pNear, uint64(nByte)) if pRet == uintptr(0) { - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 7 + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM } } else { pRet = pNear @@ -171201,7 +168369,7 @@ func fts5ParseTokenize(tls *libc.TLS, pContext uintptr, tflags int32, pToken uin bp := tls.Alloc(4) defer tls.Free(4) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var SZALLOC int32 = 8 var pCtx uintptr = pContext var pPhrase uintptr = (*TokenCtx)(unsafe.Pointer(pCtx)).FpPhrase @@ -171210,19 +168378,19 @@ func fts5ParseTokenize(tls *libc.TLS, pContext uintptr, tflags int32, pToken uin _ = iUnused2 // If an error has already occurred, this is a no-op - if (*TokenCtx)(unsafe.Pointer(pCtx)).Frc != 0 { + if (*TokenCtx)(unsafe.Pointer(pCtx)).Frc != SQLITE_OK { return (*TokenCtx)(unsafe.Pointer(pCtx)).Frc } - if nToken > 32768 { - nToken = 32768 + if nToken > FTS5_MAX_TOKEN_SIZE { + nToken = FTS5_MAX_TOKEN_SIZE } - if ((pPhrase != 0) && ((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0)) && ((tflags & 0x0001) != 0) { + if ((pPhrase != 0) && ((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0)) && ((tflags & FTS5_TOKEN_COLOCATED) != 0) { var pSyn uintptr var nByte Sqlite3_int64 = (Sqlite3_int64(((uint64(unsafe.Sizeof(Fts5ExprTerm{})) + uint64(unsafe.Sizeof(Fts5Buffer{}))) + uint64(nToken)) + uint64(1))) pSyn = Xsqlite3_malloc64(tls, uint64(nByte)) if pSyn == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_NOMEM } else { libc.Xmemset(tls, pSyn, 0, Size_t(nByte)) (*Fts5ExprTerm)(unsafe.Pointer(pSyn)).FzTerm = (((pSyn) + uintptr(uint64(unsafe.Sizeof(Fts5ExprTerm{})))) + uintptr(uint64(unsafe.Sizeof(Fts5Buffer{})))) @@ -171244,7 +168412,7 @@ func fts5ParseTokenize(tls *libc.TLS, pContext uintptr, tflags int32, pToken uin pNew = Xsqlite3_realloc64(tls, pPhrase, (uint64(uint64(unsafe.Sizeof(Fts5ExprPhrase{})) + (uint64(unsafe.Sizeof(Fts5ExprTerm{})) * uint64(nNew))))) if pNew == uintptr(0) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_NOMEM } else { if pPhrase == uintptr(0) { libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(Fts5ExprPhrase{}))) @@ -171254,7 +168422,7 @@ func fts5ParseTokenize(tls *libc.TLS, pContext uintptr, tflags int32, pToken uin } } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { pTerm = ((pPhrase + 32 /* &.aTerm */) + uintptr(libc.PostIncInt32(&(*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm, 1))*32) libc.Xmemset(tls, pTerm, 0, uint64(unsafe.Sizeof(Fts5ExprTerm{}))) (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FzTerm = sqlite3Fts5Strndup(tls, bp /* &rc */, pToken, nToken) @@ -171304,10 +168472,10 @@ func sqlite3Fts5ParseTerm(tls *libc.TLS, pParse uintptr, pAppend uintptr, pToken (*TokenCtx)(unsafe.Pointer(bp /* &sCtx */)).FpPhrase = pAppend rc = fts5ParseStringFromToken(tls, pToken, bp+16 /* &z */) - if rc == 0 { - var flags int32 = (0x0001 | (func() int32 { + if rc == SQLITE_OK { + var flags int32 = (FTS5_TOKENIZE_QUERY | (func() int32 { if bPrefix != 0 { - return 0x0002 + return FTS5_TOKENIZE_PREFIX } return 0 }())) @@ -171331,7 +168499,7 @@ func sqlite3Fts5ParseTerm(tls *libc.TLS, pParse uintptr, pAppend uintptr, pToken var apNew uintptr apNew = Xsqlite3_realloc64(tls, (*Fts5Parse)(unsafe.Pointer(pParse)).FapPhrase, uint64(nByte)) if apNew == uintptr(0) { - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 7 + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM fts5ExprPhraseFree(tls, (*TokenCtx)(unsafe.Pointer(bp /* &sCtx */)).FpPhrase) return uintptr(0) } @@ -171359,26 +168527,26 @@ func sqlite3Fts5ExprClonePhrase(tls *libc.TLS, pExpr uintptr, iPhrase int32, ppN bp := tls.Alloc(24) defer tls.Free(24) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 // Return code + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK // Return code var pOrig uintptr // The phrase extracted from pExpr var pNew uintptr = uintptr(0) // Expression to return via *ppNew *(*TokenCtx)(unsafe.Pointer(bp + 8 /* sCtx */)) = TokenCtx{} // Context object for fts5ParseTokenize pOrig = *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*8)) pNew = sqlite3Fts5MallocZero(tls, bp /* &rc */, int64(unsafe.Sizeof(Fts5Expr{}))) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*Fts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase = sqlite3Fts5MallocZero(tls, bp, /* &rc */ int64(unsafe.Sizeof(uintptr(0)))) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot = sqlite3Fts5MallocZero(tls, bp, /* &rc */ int64(unsafe.Sizeof(Fts5ExprNode{}))) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear = sqlite3Fts5MallocZero(tls, bp, /* &rc */ (int64(uint64(unsafe.Sizeof(Fts5ExprNearset{})) + uint64(unsafe.Sizeof(uintptr(0)))))) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { var pColsetOrig uintptr = (*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer((*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FpNode)).FpNear)).FpColset if pColsetOrig != 0 { var nByte Sqlite3_int64 @@ -171394,16 +168562,16 @@ func sqlite3Fts5ExprClonePhrase(tls *libc.TLS, pExpr uintptr, iPhrase int32, ppN if (*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm != 0 { var i int32 // Used to iterate through phrase terms - for i = 0; (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0) && (i < (*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm); i++ { + for i = 0; (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (i < (*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm); i++ { var tflags int32 = 0 var p uintptr - for p = ((pOrig + 32 /* &.aTerm */) + uintptr(i)*32); (p != 0) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0); p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym { + for p = ((pOrig + 32 /* &.aTerm */) + uintptr(i)*32); (p != 0) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK); p = (*Fts5ExprTerm)(unsafe.Pointer(p)).FpSynonym { var zTerm uintptr = (*Fts5ExprTerm)(unsafe.Pointer(p)).FzTerm *(*int32)(unsafe.Pointer(bp /* rc */)) = fts5ParseTokenize(tls, bp+8 /* &sCtx */, tflags, zTerm, int32(libc.Xstrlen(tls, zTerm)), 0, 0) - tflags = 0x0001 + tflags = FTS5_TOKEN_COLOCATED } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*Fts5ExprTerm)(unsafe.Pointer(((*TokenCtx)(unsafe.Pointer(bp+8 /* &sCtx */)).FpPhrase + 32 /* &.aTerm */) + uintptr(i)*32)).FbPrefix = (*Fts5ExprTerm)(unsafe.Pointer((pOrig + 32 /* &.aTerm */) + uintptr(i)*32)).FbPrefix (*Fts5ExprTerm)(unsafe.Pointer(((*TokenCtx)(unsafe.Pointer(bp+8 /* &sCtx */)).FpPhrase + 32 /* &.aTerm */) + uintptr(i)*32)).FbFirst = (*Fts5ExprTerm)(unsafe.Pointer((pOrig + 32 /* &.aTerm */) + uintptr(i)*32)).FbFirst } @@ -171414,25 +168582,25 @@ func sqlite3Fts5ExprClonePhrase(tls *libc.TLS, pExpr uintptr, iPhrase int32, ppN (*TokenCtx)(unsafe.Pointer(bp + 8 /* &sCtx */)).FpPhrase = sqlite3Fts5MallocZero(tls, bp /* &rc */, int64(unsafe.Sizeof(Fts5ExprPhrase{}))) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { // All the allocations succeeded. Put the expression object together. (*Fts5Expr)(unsafe.Pointer(pNew)).FpIndex = (*Fts5Expr)(unsafe.Pointer(pExpr)).FpIndex (*Fts5Expr)(unsafe.Pointer(pNew)).FpConfig = (*Fts5Expr)(unsafe.Pointer(pExpr)).FpConfig (*Fts5Expr)(unsafe.Pointer(pNew)).FnPhrase = 1 - *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase + uintptr(0)*8)) = (*TokenCtx)(unsafe.Pointer(bp + 8 /* &sCtx */)).FpPhrase - *(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear + 24 /* &.apPhrase */) + uintptr(0)*8)) = (*TokenCtx)(unsafe.Pointer(bp + 8 /* &sCtx */)).FpPhrase + *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FapExprPhrase)) = (*TokenCtx)(unsafe.Pointer(bp + 8 /* &sCtx */)).FpPhrase + *(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear + 24 /* &.apPhrase */))) = (*TokenCtx)(unsafe.Pointer(bp + 8 /* &sCtx */)).FpPhrase (*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FpNear)).FnPhrase = 1 (*Fts5ExprPhrase)(unsafe.Pointer((*TokenCtx)(unsafe.Pointer(bp + 8 /* &sCtx */)).FpPhrase)).FpNode = (*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot if (((*Fts5ExprPhrase)(unsafe.Pointer(pOrig)).FnTerm == 1) && - ((*Fts5ExprTerm)(unsafe.Pointer((pOrig+32 /* &.aTerm */)+uintptr(0)*32)).FpSynonym == uintptr(0))) && - (int32((*Fts5ExprTerm)(unsafe.Pointer((pOrig+32 /* &.aTerm */)+uintptr(0)*32)).FbFirst) == 0) { - (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = 4 + ((*Fts5ExprTerm)(unsafe.Pointer((pOrig + 32 /* &.aTerm */))).FpSynonym == uintptr(0))) && + (int32((*Fts5ExprTerm)(unsafe.Pointer((pOrig + 32 /* &.aTerm */))).FbFirst) == 0) { + (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = FTS5_TERM (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, I64) int32 }{fts5ExprNodeNext_TERM})) } else { - (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = 9 + (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FeType = FTS5_STRING (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pNew)).FpRoot)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, I64) int32 }{fts5ExprNodeNext_STRING})) @@ -171478,7 +168646,7 @@ func sqlite3Fts5ParseSetDistance(tls *libc.TLS, pParse uintptr, pNear uintptr, p nNear = ((nNear * 10) + (int32(*(*int8)(unsafe.Pointer((*Fts5Token)(unsafe.Pointer(p)).Fp + uintptr(i)))) - '0')) } } else { - nNear = 10 + nNear = FTS5_DEFAULT_NEARDIST } (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnNear = nNear } @@ -171502,7 +168670,7 @@ func fts5ParseColset(tls *libc.TLS, pParse uintptr, p uintptr, iCol int32) uintp pNew = Xsqlite3_realloc64(tls, p, (uint64(uint64(unsafe.Sizeof(Fts5Colset{})) + (uint64(unsafe.Sizeof(int32(0))) * uint64(nCol))))) if pNew == uintptr(0) { - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 7 + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_NOMEM } else { var aiCol uintptr = pNew + 4 /* &.aiCol */ var i int32 @@ -171560,7 +168728,7 @@ func sqlite3Fts5ParseColset(tls *libc.TLS, pParse uintptr, pColset uintptr, p ui var z uintptr // Dequoted copy of token p z = sqlite3Fts5Strndup(tls, (pParse + 16 /* &.rc */), (*Fts5Token)(unsafe.Pointer(p)).Fp, (*Fts5Token)(unsafe.Pointer(p)).Fn) - if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { var pConfig uintptr = (*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig sqlite3Fts5Dequote(tls, z) for iCol = 0; iCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol; iCol++ { @@ -171630,14 +168798,14 @@ func fts5MergeColset(tls *libc.TLS, pColset uintptr, pMerge uintptr) { /* sqlite // of pColset. This function may use the spare copy and set (*ppFree) to // zero, or it may create copies of pColset using fts5CloneColset(). func fts5ParseSetColset(tls *libc.TLS, pParse uintptr, pNode uintptr, pColset uintptr, ppFree uintptr) { /* sqlite3.c:214916:13: */ - if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { - if ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == 9) || ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == 4) { + if ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_STRING) || ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_TERM) { var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear if (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset != 0 { fts5MergeColset(tls, (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset, pColset) if (*Fts5Colset)(unsafe.Pointer((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset)).FnCol == 0 { - (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType = 0 + (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType = FTS5_EOF (*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = uintptr(0) } } else if *(*uintptr)(unsafe.Pointer(ppFree)) != 0 { @@ -171662,8 +168830,8 @@ func sqlite3Fts5ParseSetColset(tls *libc.TLS, pParse uintptr, pExpr uintptr, pCo defer tls.Free(8) *(*uintptr)(unsafe.Pointer(bp /* pFree */)) = pColset - if (*Fts5Config)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail == 1 { - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 1 + if (*Fts5Config)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail == FTS5_DETAIL_NONE { + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR (*Fts5Parse)(unsafe.Pointer(pParse)).FzErr = Xsqlite3_mprintf(tls, ts+37291 /* "fts5: column que..." */, 0) } else { @@ -171674,13 +168842,13 @@ func sqlite3Fts5ParseSetColset(tls *libc.TLS, pParse uintptr, pExpr uintptr, pCo func fts5ExprAssignXNext(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:214971:13: */ switch (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType { - case 9: + case FTS5_STRING: { var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear - if ((((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase == 1) && ((*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(0)*8)))).FnTerm == 1)) && - ((*Fts5ExprTerm)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(0)*8))+32 /* &.aTerm */)+uintptr(0)*32)).FpSynonym == uintptr(0))) && - (int32((*Fts5ExprTerm)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(0)*8))+32 /* &.aTerm */)+uintptr(0)*32)).FbFirst) == 0) { - (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType = 4 + if ((((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase == 1) && ((*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */))))).FnTerm == 1)) && + ((*Fts5ExprTerm)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */))) + 32 /* &.aTerm */))).FpSynonym == uintptr(0))) && + (int32((*Fts5ExprTerm)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */))) + 32 /* &.aTerm */))).FbFirst) == 0) { + (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType = FTS5_TERM (*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, I64) int32 }{fts5ExprNodeNext_TERM})) @@ -171693,7 +168861,7 @@ func fts5ExprAssignXNext(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:214971:13: } - case 1: + case FTS5_OR: { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, I64) int32 @@ -171702,7 +168870,7 @@ func fts5ExprAssignXNext(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:214971:13: } - case 2: + case FTS5_AND: { (*Fts5ExprNode)(unsafe.Pointer(pNode)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, int32, I64) int32 @@ -171724,7 +168892,7 @@ func fts5ExprAssignXNext(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:214971:13: } func fts5ExprAddChildren(tls *libc.TLS, p uintptr, pSub uintptr) { /* sqlite3.c:215004:13: */ - if ((*Fts5ExprNode)(unsafe.Pointer(p)).FeType != 3) && ((*Fts5ExprNode)(unsafe.Pointer(pSub)).FeType == (*Fts5ExprNode)(unsafe.Pointer(p)).FeType) { + if ((*Fts5ExprNode)(unsafe.Pointer(p)).FeType != FTS5_NOT) && ((*Fts5ExprNode)(unsafe.Pointer(pSub)).FeType == (*Fts5ExprNode)(unsafe.Pointer(p)).FeType) { var nByte int32 = (int32(uint64(unsafe.Sizeof(uintptr(0))) * uint64((*Fts5ExprNode)(unsafe.Pointer(pSub)).FnChild))) libc.Xmemcpy(tls, ((p + 48 /* &.apChild */) + uintptr((*Fts5ExprNode)(unsafe.Pointer(p)).FnChild)*8), pSub+48 /* &.apChild */, uint64(nByte)) *(*int32)(unsafe.Pointer(p + 40 /* &.nChild */)) += ((*Fts5ExprNode)(unsafe.Pointer(pSub)).FnChild) @@ -171742,23 +168910,23 @@ func sqlite3Fts5ParseNode(tls *libc.TLS, pParse uintptr, eType int32, pLeft uint var pRet uintptr = uintptr(0) - if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == 0 { + if (*Fts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK { var nChild int32 = 0 // Number of children of returned node var nByte Sqlite3_int64 // Bytes of space to allocate for this node - if (eType == 9) && (pNear == uintptr(0)) { + if (eType == FTS5_STRING) && (pNear == uintptr(0)) { return uintptr(0) } - if (eType != 9) && (pLeft == uintptr(0)) { + if (eType != FTS5_STRING) && (pLeft == uintptr(0)) { return pRight } - if (eType != 9) && (pRight == uintptr(0)) { + if (eType != FTS5_STRING) && (pRight == uintptr(0)) { return pLeft } - if eType == 3 { + if eType == FTS5_NOT { nChild = 2 - } else if (eType == 2) || (eType == 1) { + } else if (eType == FTS5_AND) || (eType == FTS5_OR) { nChild = 2 if (*Fts5ExprNode)(unsafe.Pointer(pLeft)).FeType == eType { nChild = nChild + ((*Fts5ExprNode)(unsafe.Pointer(pLeft)).FnChild - 1) @@ -171775,23 +168943,23 @@ func sqlite3Fts5ParseNode(tls *libc.TLS, pParse uintptr, eType int32, pLeft uint (*Fts5ExprNode)(unsafe.Pointer(pRet)).FeType = eType (*Fts5ExprNode)(unsafe.Pointer(pRet)).FpNear = pNear fts5ExprAssignXNext(tls, pRet) - if eType == 9 { + if eType == FTS5_STRING { var iPhrase int32 for iPhrase = 0; iPhrase < (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase; iPhrase++ { (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(iPhrase)*8)))).FpNode = pRet if (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(iPhrase)*8)))).FnTerm == 0 { (*Fts5ExprNode)(unsafe.Pointer(pRet)).FxNext = uintptr(0) - (*Fts5ExprNode)(unsafe.Pointer(pRet)).FeType = 0 + (*Fts5ExprNode)(unsafe.Pointer(pRet)).FeType = FTS5_EOF } } - if (*Fts5Config)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail != 0 { - var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */) + uintptr(0)*8)) + if (*Fts5Config)(unsafe.Pointer((*Fts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail != FTS5_DETAIL_FULL { + var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((pNear + 24 /* &.apPhrase */))) if (((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FnPhrase != 1) || ((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 1)) || - (((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0) && ((*Fts5ExprTerm)(unsafe.Pointer((pPhrase+32 /* &.aTerm */)+uintptr(0)*32)).FbFirst != 0)) { + (((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FnTerm > 0) && ((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FbFirst != 0)) { - (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = 1 + (*Fts5Parse)(unsafe.Pointer(pParse)).Frc = SQLITE_ERROR (*Fts5Parse)(unsafe.Pointer(pParse)).FzErr = Xsqlite3_mprintf(tls, ts+37344, /* "fts5: %s queries..." */ @@ -171830,18 +168998,18 @@ func sqlite3Fts5ParseImplicitAnd(tls *libc.TLS, pParse uintptr, pLeft uintptr, p sqlite3Fts5ParseNodeFree(tls, pRight) } else { - if (*Fts5ExprNode)(unsafe.Pointer(pLeft)).FeType == 2 { + if (*Fts5ExprNode)(unsafe.Pointer(pLeft)).FeType == FTS5_AND { pPrev = *(*uintptr)(unsafe.Pointer((pLeft + 48 /* &.apChild */) + uintptr(((*Fts5ExprNode)(unsafe.Pointer(pLeft)).FnChild-1))*8)) } else { pPrev = pLeft } - if (*Fts5ExprNode)(unsafe.Pointer(pRight)).FeType == 0 { + if (*Fts5ExprNode)(unsafe.Pointer(pRight)).FeType == FTS5_EOF { sqlite3Fts5ParseNodeFree(tls, pRight) pRet = pLeft (*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase-- - } else if (*Fts5ExprNode)(unsafe.Pointer(pPrev)).FeType == 0 { + } else if (*Fts5ExprNode)(unsafe.Pointer(pPrev)).FeType == FTS5_EOF { var ap uintptr if pPrev == pLeft { @@ -171853,12 +169021,12 @@ func sqlite3Fts5ParseImplicitAnd(tls *libc.TLS, pParse uintptr, pLeft uintptr, p ap = ((*Fts5Parse)(unsafe.Pointer(pParse)).FapPhrase + uintptr((((*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase-1)-(*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pRight)).FpNear)).FnPhrase))*8) - libc.Xmemmove(tls, ap, (ap + uintptr(1)*8), (uint64(unsafe.Sizeof(uintptr(0))) * uint64((*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pRight)).FpNear)).FnPhrase))) + libc.Xmemmove(tls, ap, (ap + 1*8), (uint64(unsafe.Sizeof(uintptr(0))) * uint64((*Fts5ExprNearset)(unsafe.Pointer((*Fts5ExprNode)(unsafe.Pointer(pRight)).FpNear)).FnPhrase))) (*Fts5Parse)(unsafe.Pointer(pParse)).FnPhrase-- sqlite3Fts5ParseNodeFree(tls, pPrev) } else { - pRet = sqlite3Fts5ParseNode(tls, pParse, 2, pLeft, pRight, uintptr(0)) + pRet = sqlite3Fts5ParseNode(tls, pParse, FTS5_AND, pLeft, pRight, uintptr(0)) } } @@ -171929,7 +169097,7 @@ func fts5ExprPrintTcl(tls *libc.TLS, pConfig uintptr, zNearsetCmd uintptr, pExpr defer tls.Free(72) var zRet uintptr = uintptr(0) - if ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == 9) || ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == 4) { + if ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == FTS5_STRING) || ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == FTS5_TERM) { var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pExpr)).FpNear var i int32 var iTerm int32 @@ -171942,9 +169110,9 @@ func fts5ExprPrintTcl(tls *libc.TLS, pConfig uintptr, zNearsetCmd uintptr, pExpr var aiCol uintptr = (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset + 4 /* &.aiCol */ var nCol int32 = (*Fts5Colset)(unsafe.Pointer((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset)).FnCol if nCol == 1 { - zRet = fts5PrintfAppend(tls, zRet, ts+37405 /* "-col %d " */, libc.VaList(bp+8, *(*int32)(unsafe.Pointer(aiCol + uintptr(0)*4)))) + zRet = fts5PrintfAppend(tls, zRet, ts+37405 /* "-col %d " */, libc.VaList(bp+8, *(*int32)(unsafe.Pointer(aiCol)))) } else { - zRet = fts5PrintfAppend(tls, zRet, ts+37414 /* "-col {%d" */, libc.VaList(bp+16, *(*int32)(unsafe.Pointer(aiCol + uintptr(0)*4)))) + zRet = fts5PrintfAppend(tls, zRet, ts+37414 /* "-col {%d" */, libc.VaList(bp+16, *(*int32)(unsafe.Pointer(aiCol)))) for i = 1; i < (*Fts5Colset)(unsafe.Pointer((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset)).FnCol; i++ { zRet = fts5PrintfAppend(tls, zRet, ts+37423 /* " %d" */, libc.VaList(bp+24, *(*int32)(unsafe.Pointer(aiCol + uintptr(i)*4)))) } @@ -171996,11 +169164,11 @@ func fts5ExprPrintTcl(tls *libc.TLS, pConfig uintptr, zNearsetCmd uintptr, pExpr var zOp uintptr = uintptr(0) var i int32 switch (*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType { - case 2: + case FTS5_AND: zOp = ts + 33330 /* "AND" */ break fallthrough - case 3: + case FTS5_NOT: zOp = ts + 37253 /* "NOT" */ break fallthrough @@ -172032,13 +169200,13 @@ func fts5ExprPrint(tls *libc.TLS, pConfig uintptr, pExpr uintptr) uintptr { /* s var zRet uintptr = uintptr(0) if (*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == 0 { return Xsqlite3_mprintf(tls, ts+37452 /* "\"\"" */, 0) - } else if ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == 9) || ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == 4) { + } else if ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == FTS5_STRING) || ((*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType == FTS5_TERM) { var pNear uintptr = (*Fts5ExprNode)(unsafe.Pointer(pExpr)).FpNear var i int32 var iTerm int32 if (*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset != 0 { - var iCol int32 = *(*int32)(unsafe.Pointer(((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset + 4 /* &.aiCol */) + uintptr(0)*4)) + var iCol int32 = *(*int32)(unsafe.Pointer(((*Fts5ExprNearset)(unsafe.Pointer(pNear)).FpColset + 4 /* &.aiCol */))) zRet = fts5PrintfAppend(tls, zRet, ts+37455 /* "%s : " */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FazCol + uintptr(iCol)*8)))) if zRet == uintptr(0) { return uintptr(0) @@ -172090,11 +169258,11 @@ func fts5ExprPrint(tls *libc.TLS, pConfig uintptr, pExpr uintptr) uintptr { /* s var i int32 switch (*Fts5ExprNode)(unsafe.Pointer(pExpr)).FeType { - case 2: + case FTS5_AND: zOp = ts + 23050 /* " AND " */ break fallthrough - case 3: + case FTS5_NOT: zOp = ts + 37477 /* " NOT " */ break fallthrough @@ -172111,7 +169279,7 @@ func fts5ExprPrint(tls *libc.TLS, pConfig uintptr, pExpr uintptr) uintptr { /* s zRet = uintptr(0) } else { var e int32 = (*Fts5ExprNode)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((pExpr + 48 /* &.apChild */) + uintptr(i)*8)))).FeType - var b int32 = (libc.Bool32(((e != 9) && (e != 4)) && (e != 0))) + var b int32 = (libc.Bool32(((e != FTS5_STRING) && (e != FTS5_TERM)) && (e != FTS5_EOF))) zRet = fts5PrintfAppend(tls, zRet, ts+37488, /* "%s%s%z%s" */ libc.VaList(bp+32, func() uintptr { if i == 0 { @@ -172173,7 +169341,7 @@ func fts5ExprFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr, bT } if (bTcl != 0) && (nArg > 1) { - zNearsetCmd = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) + zNearsetCmd = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) iArg = 2 } @@ -172183,9 +169351,9 @@ func fts5ExprFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr, bT Xsqlite3_result_error_nomem(tls, pCtx) return } - *(*uintptr)(unsafe.Pointer(azConfig + uintptr(0)*8)) = uintptr(0) - *(*uintptr)(unsafe.Pointer(azConfig + uintptr(1)*8)) = ts + 8333 /* "main" */ - *(*uintptr)(unsafe.Pointer(azConfig + uintptr(2)*8)) = ts + 12632 /* "tbl" */ + *(*uintptr)(unsafe.Pointer(azConfig)) = uintptr(0) + *(*uintptr)(unsafe.Pointer(azConfig + 1*8)) = ts + 8333 /* "main" */ + *(*uintptr)(unsafe.Pointer(azConfig + 2*8)) = ts + 12632 /* "tbl" */ for i = 3; iArg < nArg; iArg++ { var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(iArg)*8))) *(*uintptr)(unsafe.Pointer(azConfig + uintptr(libc.PostIncInt32(&i, 1))*8)) = func() uintptr { @@ -172196,16 +169364,16 @@ func fts5ExprFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr, bT }() } - zExpr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + zExpr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))) if zExpr == uintptr(0) { zExpr = ts + 800 /* "" */ } rc = sqlite3Fts5ConfigParse(tls, pGlobal, db, nConfig, azConfig, bp+8 /* &pConfig */, bp+16 /* &zErr */) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5ExprNew(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)), (*Fts5Config)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)))).FnCol, zExpr, bp+24 /* &pExpr */, bp+16 /* &zErr */) } - if rc == 0 { + if rc == SQLITE_OK { var zText uintptr if (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pExpr */)))).FpRoot)).FxNext == uintptr(0) { zText = Xsqlite3_mprintf(tls, ts+800 /* "" */, 0) @@ -172215,14 +169383,14 @@ func fts5ExprFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr, bT zText = fts5ExprPrint(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)), (*Fts5Expr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pExpr */)))).FpRoot) } if zText == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { Xsqlite3_result_text(tls, pCtx, zText, -1, libc.UintptrFromInt32(-1)) Xsqlite3_free(tls, zText) } } - if rc != 0 { + if rc != SQLITE_OK { if *(*uintptr)(unsafe.Pointer(bp + 16 /* zErr */)) != 0 { Xsqlite3_result_error(tls, pCtx, *(*uintptr)(unsafe.Pointer(bp + 16 /* zErr */)), -1) Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* zErr */))) @@ -172262,7 +169430,7 @@ func fts5ExprIsAlnum(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) { / sqlite3Fts5UnicodeCatParse(tls, ts+37621 /* "L*" */, bp /* &aArr[0] */) sqlite3Fts5UnicodeCatParse(tls, ts+37624 /* "N*" */, bp /* &aArr[0] */) sqlite3Fts5UnicodeCatParse(tls, ts+37627 /* "Co" */, bp /* &aArr[0] */) - iCode = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + iCode = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal))) Xsqlite3_result_int(tls, pCtx, int32(*(*U8)(unsafe.Pointer(bp /* &aArr[0] */ + uintptr(sqlite3Fts5UnicodeCategory(tls, U32(iCode))))))) } @@ -172273,9 +169441,9 @@ func fts5ExprFold(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) { /* s } else { var iCode int32 var bRemoveDiacritics int32 = 0 - iCode = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + iCode = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal))) if nArg == 2 { - bRemoveDiacritics = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) + bRemoveDiacritics = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) } Xsqlite3_result_int(tls, pCtx, sqlite3Fts5UnicodeFold(tls, iCode, bRemoveDiacritics)) } @@ -172288,34 +169456,26 @@ func sqlite3Fts5ExprInit(tls *libc.TLS, pGlobal uintptr, db uintptr) int32 { /* defer tls.Free(64) *(*[4]Fts5ExprFunc)(unsafe.Pointer(bp /* aFunc */)) = [4]Fts5ExprFunc{ - { - Fz: ts + 37560, /* "fts5_expr" */ - Fx: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, int32, uintptr) - }{fts5ExprFunctionHr}))}, - { - Fz: ts + 37546, /* "fts5_expr_tcl" */ - Fx: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, int32, uintptr) - }{fts5ExprFunctionTcl}))}, - { - Fz: ts + 37678, /* "fts5_isalnum" */ - Fx: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, int32, uintptr) - }{fts5ExprIsAlnum}))}, - { - Fz: ts + 37691, /* "fts5_fold" */ - Fx: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, int32, uintptr) - }{fts5ExprFold}))}, + {Fz: ts + 37560 /* "fts5_expr" */, Fx: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{fts5ExprFunctionHr}))}, + {Fz: ts + 37546 /* "fts5_expr_tcl" */, Fx: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{fts5ExprFunctionTcl}))}, + {Fz: ts + 37678 /* "fts5_isalnum" */, Fx: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{fts5ExprIsAlnum}))}, + {Fz: ts + 37691 /* "fts5_fold" */, Fx: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, int32, uintptr) + }{fts5ExprFold}))}, } var i int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var pCtx uintptr = pGlobal - for i = 0; (rc == 0) && (i < (int32(uint64(unsafe.Sizeof([4]Fts5ExprFunc{})) / uint64(unsafe.Sizeof(Fts5ExprFunc{}))))); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (int32(uint64(unsafe.Sizeof([4]Fts5ExprFunc{})) / uint64(unsafe.Sizeof(Fts5ExprFunc{}))))); i++ { var p uintptr = (bp /* &aFunc */ + uintptr(i)*16) - rc = Xsqlite3_create_function(tls, db, (*Fts5ExprFunc)(unsafe.Pointer(p)).Fz, -1, 1, pCtx, (*Fts5ExprFunc)(unsafe.Pointer(p)).Fx, uintptr(0), uintptr(0)) + rc = Xsqlite3_create_function(tls, db, (*Fts5ExprFunc)(unsafe.Pointer(p)).Fz, -1, SQLITE_UTF8, pCtx, (*Fts5ExprFunc)(unsafe.Pointer(p)).Fx, uintptr(0), uintptr(0)) } // Avoid warnings indicating that sqlite3Fts5ParserTrace() and @@ -172411,10 +169571,10 @@ func fts5ExprPopulatePoslistsCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToke _ = iUnused1 _ = iUnused2 - if nToken > 32768 { - nToken = 32768 + if nToken > FTS5_MAX_TOKEN_SIZE { + nToken = FTS5_MAX_TOKEN_SIZE } - if (tflags & 0x0001) == 0 { + if (tflags & FTS5_TOKEN_COLOCATED) == 0 { (*Fts5ExprCtx)(unsafe.Pointer(p)).FiOff++ } for i = 0; i < (*Fts5Expr)(unsafe.Pointer(pExpr)).FnPhrase; i++ { @@ -172422,7 +169582,7 @@ func fts5ExprPopulatePoslistsCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToke if (*Fts5PoslistPopulator)(unsafe.Pointer((*Fts5ExprCtx)(unsafe.Pointer(p)).FaPopulator+uintptr(i)*16)).FbOk == 0 { continue } - for pTerm = ((*(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*8)) + 32 /* &.aTerm */) + uintptr(0)*32); pTerm != 0; pTerm = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym { + for pTerm = (*(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(i)*8)) + 32 /* &.aTerm */); pTerm != 0; pTerm = (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym { var nTerm int32 = int32(libc.Xstrlen(tls, (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FzTerm)) if ((nTerm == nToken) || ((nTerm < nToken) && ((*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FbPrefix != 0))) && (libc.Xmemcmp(tls, (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FzTerm, pToken, uint64(nTerm)) == 0) { @@ -172435,7 +169595,7 @@ func fts5ExprPopulatePoslistsCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToke } } } - return 0 + return SQLITE_OK } func sqlite3Fts5ExprPopulatePoslists(tls *libc.TLS, pConfig uintptr, pExpr uintptr, aPopulator uintptr, iCol int32, z uintptr, n int32) int32 { /* sqlite3.c:215666:12: */ @@ -172461,14 +169621,14 @@ func sqlite3Fts5ExprPopulatePoslists(tls *libc.TLS, pConfig uintptr, pExpr uintp } return sqlite3Fts5Tokenize(tls, pConfig, - 0x0004, z, n, bp /* &sCtx */, *(*uintptr)(unsafe.Pointer(&struct { + FTS5_TOKENIZE_DOCUMENT, z, n, bp /* &sCtx */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5ExprPopulatePoslistsCb}))) } func fts5ExprClearPoslists(tls *libc.TLS, pNode uintptr) { /* sqlite3.c:215696:13: */ - if ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == 4) || ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == 9) { - (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */) + uintptr(0)*8)))).Fposlist.Fn = 0 + if ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_TERM) || ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType == FTS5_STRING) { + (*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */))))).Fposlist.Fn = 0 } else { var i int32 for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ { @@ -172481,12 +169641,12 @@ func fts5ExprCheckPoslists(tls *libc.TLS, pNode uintptr, iRowid I64) int32 { /* (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid = iRowid (*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof = 0 switch (*Fts5ExprNode)(unsafe.Pointer(pNode)).FeType { - case 4: + case FTS5_TERM: fallthrough - case 9: - return (libc.Bool32((*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */) + uintptr(0)*8)))).Fposlist.Fn > 0)) + case FTS5_STRING: + return (libc.Bool32((*Fts5ExprPhrase)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(((*Fts5ExprNode)(unsafe.Pointer(pNode)).FpNear + 24 /* &.apPhrase */))))).Fposlist.Fn > 0)) - case 2: + case FTS5_AND: { var i int32 for i = 0; i < (*Fts5ExprNode)(unsafe.Pointer(pNode)).FnChild; i++ { @@ -172499,7 +169659,7 @@ func fts5ExprCheckPoslists(tls *libc.TLS, pNode uintptr, iRowid I64) int32 { /* } - case 1: + case FTS5_OR: { var i int32 var bRet int32 = 0 @@ -172515,8 +169675,8 @@ func fts5ExprCheckPoslists(tls *libc.TLS, pNode uintptr, iRowid I64) int32 { /* default: { - if (0 == fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(0)*8)), iRowid)) || - (0 != fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + uintptr(1)*8)), iRowid)) { + if (0 == fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */))), iRowid)) || + (0 != fts5ExprCheckPoslists(tls, *(*uintptr)(unsafe.Pointer((pNode + 48 /* &.apChild */) + 1*8)), iRowid)) { fts5ExprClearPoslists(tls, pNode) return 0 } @@ -172535,19 +169695,19 @@ func sqlite3Fts5ExprCheckPoslists(tls *libc.TLS, pExpr uintptr, iRowid I64) { /* func sqlite3Fts5ExprPhraseCollist(tls *libc.TLS, pExpr uintptr, iPhrase int32, ppCollist uintptr, pnCollist uintptr) int32 { /* sqlite3.c:215758:12: */ var pPhrase uintptr = *(*uintptr)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FapExprPhrase + uintptr(iPhrase)*8)) var pNode uintptr = (*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).FpNode - var rc int32 = 0 + var rc int32 = SQLITE_OK if (((*Fts5ExprNode)(unsafe.Pointer(pNode)).FbEof == 0) && ((*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid == (*Fts5ExprNode)(unsafe.Pointer((*Fts5Expr)(unsafe.Pointer(pExpr)).FpRoot)).FiRowid)) && ((*Fts5ExprPhrase)(unsafe.Pointer(pPhrase)).Fposlist.Fn > 0) { - var pTerm uintptr = ((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32) + var pTerm uintptr = (pPhrase + 32 /* &.aTerm */) if (*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym != 0 { - var pBuf uintptr = ((*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym + uintptr(1)*32) + var pBuf uintptr = ((*Fts5ExprTerm)(unsafe.Pointer(pTerm)).FpSynonym + 1*32) rc = fts5ExprSynonymList(tls, pTerm, (*Fts5ExprNode)(unsafe.Pointer(pNode)).FiRowid, pBuf, ppCollist, pnCollist) } else { - *(*uintptr)(unsafe.Pointer(ppCollist)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32)).FpIter)).FpData - *(*int32)(unsafe.Pointer(pnCollist)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */) + uintptr(0)*32)).FpIter)).FnData + *(*uintptr)(unsafe.Pointer(ppCollist)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FpIter)).FpData + *(*int32)(unsafe.Pointer(pnCollist)) = (*Fts5IndexIter)(unsafe.Pointer((*Fts5ExprTerm)(unsafe.Pointer((pPhrase + 32 /* &.aTerm */))).FpIter)).FnData } } else { *(*uintptr)(unsafe.Pointer(ppCollist)) = uintptr(0) @@ -172607,12 +169767,12 @@ type Fts5HashEntry = Fts5HashEntry1 /* sqlite3.c:215811:30 */ // Allocate a new hash table. func sqlite3Fts5HashNew(tls *libc.TLS, pConfig uintptr, ppNew uintptr, pnByte uintptr) int32 { /* sqlite3.c:215877:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pNew uintptr *(*uintptr)(unsafe.Pointer(ppNew)) = libc.AssignUintptr(&pNew, Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5Hash{})))) if pNew == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var nByte Sqlite3_int64 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(Fts5Hash{}))) @@ -172625,7 +169785,7 @@ func sqlite3Fts5HashNew(tls *libc.TLS, pConfig uintptr, ppNew uintptr, pnByte ui if (*Fts5Hash)(unsafe.Pointer(pNew)).FaSlot == uintptr(0) { Xsqlite3_free(tls, pNew) *(*uintptr)(unsafe.Pointer(ppNew)) = uintptr(0) - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemset(tls, (*Fts5Hash)(unsafe.Pointer(pNew)).FaSlot, 0, Size_t(nByte)) } @@ -172685,7 +169845,7 @@ func fts5HashResize(tls *libc.TLS, pHash uintptr) int32 { /* sqlite3.c:215954:12 apNew = Xsqlite3_malloc64(tls, (uint64(uint64(nNew) * uint64(unsafe.Sizeof(uintptr(0)))))) if !(apNew != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, apNew, 0, (uint64(nNew) * uint64(unsafe.Sizeof(uintptr(0))))) @@ -172694,8 +169854,8 @@ func fts5HashResize(tls *libc.TLS, pHash uintptr) int32 { /* sqlite3.c:215954:12 var iHash uint32 var p uintptr = *(*uintptr)(unsafe.Pointer(apOld + uintptr(i)*8)) *(*uintptr)(unsafe.Pointer(apOld + uintptr(i)*8)) = (*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext - iHash = fts5HashKey(tls, nNew, ((p) + uintptr(1)*48), - int32(libc.Xstrlen(tls, ((p)+uintptr(1)*48)))) + iHash = fts5HashKey(tls, nNew, ((p) + 1*48), + int32(libc.Xstrlen(tls, ((p)+1*48)))) (*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext = *(*uintptr)(unsafe.Pointer(apNew + uintptr(iHash)*8)) *(*uintptr)(unsafe.Pointer(apNew + uintptr(iHash)*8)) = p } @@ -172704,7 +169864,7 @@ func fts5HashResize(tls *libc.TLS, pHash uintptr) int32 { /* sqlite3.c:215954:12 Xsqlite3_free(tls, apOld) (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot = nNew (*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot = apNew - return 0 + return SQLITE_OK } func fts5HashAddPoslistSize(tls *libc.TLS, pHash uintptr, p uintptr, p2 uintptr) int32 { /* sqlite3.c:215982:12: */ @@ -172717,7 +169877,7 @@ func fts5HashAddPoslistSize(tls *libc.TLS, pHash uintptr, p uintptr, p2 uintptr) pPtr = p } var nData int32 = (*Fts5HashEntry)(unsafe.Pointer(p)).FnData - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == 1 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_NONE { if (*Fts5HashEntry)(unsafe.Pointer(p)).FbDel != 0 { *(*U8)(unsafe.Pointer(pPtr + uintptr(libc.PostIncInt32(&nData, 1)))) = U8(0x00) @@ -172763,15 +169923,15 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, var nIncr int32 = 0 // Amount to increment (*pHash->pnByte) by var bNew int32 // If non-delete entry should be written - bNew = (libc.Bool32((*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == 0)) + bNew = (libc.Bool32((*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL)) // Attempt to locate an existing hash entry iHash = fts5HashKey2(tls, (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot, U8(bByte), pToken, nToken) for p = *(*uintptr)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)); p != 0; p = (*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext { - var zKey uintptr = ((p) + uintptr(1)*48) - if ((int32(*(*int8)(unsafe.Pointer(zKey + uintptr(0)))) == int32(bByte)) && + var zKey uintptr = ((p) + 1*48) + if ((int32(*(*int8)(unsafe.Pointer(zKey))) == int32(bByte)) && ((*Fts5HashEntry)(unsafe.Pointer(p)).FnKey == nToken)) && - (libc.Xmemcmp(tls, (zKey+uintptr(1)), pToken, uint64(nToken)) == 0) { + (libc.Xmemcmp(tls, (zKey+1), pToken, uint64(nToken)) == 0) { break } } @@ -172788,7 +169948,7 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, // Grow the Fts5Hash.aSlot[] array if necessary. if ((*Fts5Hash)(unsafe.Pointer(pHash)).FnEntry * 2) >= (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot { var rc int32 = fts5HashResize(tls, pHash) - if rc != 0 { + if rc != SQLITE_OK { return rc } iHash = fts5HashKey2(tls, (*Fts5Hash)(unsafe.Pointer(pHash)).FnSlot, U8(bByte), pToken, nToken) @@ -172797,13 +169957,13 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, // Allocate new Fts5HashEntry and add it to the hash table. p = Xsqlite3_malloc64(tls, uint64(nByte)) if !(p != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(Fts5HashEntry{}))) (*Fts5HashEntry)(unsafe.Pointer(p)).FnAlloc = int32(nByte) - zKey = ((p) + uintptr(1)*48) - *(*int8)(unsafe.Pointer(zKey + uintptr(0))) = bByte - libc.Xmemcpy(tls, (zKey + uintptr(1)), pToken, uint64(nToken)) + zKey = ((p) + 1*48) + *(*int8)(unsafe.Pointer(zKey)) = bByte + libc.Xmemcpy(tls, (zKey + 1), pToken, uint64(nToken)) (*Fts5HashEntry)(unsafe.Pointer(p)).FnKey = nToken *(*int8)(unsafe.Pointer(zKey + uintptr((nToken + 1)))) = int8(0) @@ -172817,10 +169977,10 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, (*Fts5HashEntry)(unsafe.Pointer(p)).FiRowid = iRowid (*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = (*Fts5HashEntry)(unsafe.Pointer(p)).FnData - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail != 1 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail != FTS5_DETAIL_NONE { *(*int32)(unsafe.Pointer(p + 24 /* &.nData */)) += (1) (*Fts5HashEntry)(unsafe.Pointer(p)).FiCol = func() int16 { - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == 0 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { return int16(0) } return int16(-1) @@ -172845,7 +170005,7 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, var pp uintptr pNew = Xsqlite3_realloc64(tls, p, uint64(nNew)) if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Fts5HashEntry)(unsafe.Pointer(pNew)).FnAlloc = int32(nNew) for pp = ((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8); *(*uintptr)(unsafe.Pointer(pp)) != p; pp = (*(*uintptr)(unsafe.Pointer(pp)) /* &.pHashNext */) { @@ -172866,10 +170026,10 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, (*Fts5HashEntry)(unsafe.Pointer(p)).FiRowid = iRowid bNew = 1 (*Fts5HashEntry)(unsafe.Pointer(p)).FiSzPoslist = (*Fts5HashEntry)(unsafe.Pointer(p)).FnData - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail != 1 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail != FTS5_DETAIL_NONE { *(*int32)(unsafe.Pointer(p + 24 /* &.nData */)) += (1) (*Fts5HashEntry)(unsafe.Pointer(p)).FiCol = func() int16 { - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == 0 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { return int16(0) } return int16(-1) @@ -172879,13 +170039,13 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, } if iCol >= 0 { - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == 1 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_NONE { (*Fts5HashEntry)(unsafe.Pointer(p)).FbContent = U8(1) } else { // Append a new column value, if necessary if iCol != int32((*Fts5HashEntry)(unsafe.Pointer(p)).FiCol) { - if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == 0 { + if (*Fts5Hash)(unsafe.Pointer(pHash)).FeDetail == FTS5_DETAIL_FULL { *(*U8)(unsafe.Pointer(pPtr + uintptr(libc.PostIncInt32(&(*Fts5HashEntry)(unsafe.Pointer(p)).FnData, 1)))) = U8(0x01) *(*int32)(unsafe.Pointer(p + 24 /* &.nData */)) += (sqlite3Fts5PutVarint(tls, (pPtr + uintptr((*Fts5HashEntry)(unsafe.Pointer(p)).FnData)), uint64(iCol))) (*Fts5HashEntry)(unsafe.Pointer(p)).FiCol = I16(iCol) @@ -172909,7 +170069,7 @@ func sqlite3Fts5HashWrite(tls *libc.TLS, pHash uintptr, iRowid I64, iCol int32, nIncr = nIncr + ((*Fts5HashEntry)(unsafe.Pointer(p)).FnData) *(*int32)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FpnByte)) += (nIncr) - return 0 + return SQLITE_OK } // Arguments pLeft and pRight point to linked-lists of hash-entry objects, @@ -172933,8 +170093,8 @@ func fts5HashEntryMerge(tls *libc.TLS, pLeft uintptr, pRight uintptr) uintptr { p1 = uintptr(0) } else { var i int32 = 0 - var zKey1 uintptr = ((p1) + uintptr(1)*48) - var zKey2 uintptr = ((p2) + uintptr(1)*48) + var zKey1 uintptr = ((p1) + 1*48) + var zKey2 uintptr = ((p2) + 1*48) for int32(*(*int8)(unsafe.Pointer(zKey1 + uintptr(i)))) == int32(*(*int8)(unsafe.Pointer(zKey2 + uintptr(i)))) { i++ } @@ -172971,7 +170131,7 @@ func fts5HashEntrySort(tls *libc.TLS, pHash uintptr, pTerm uintptr, nTerm int32, *(*uintptr)(unsafe.Pointer(ppSorted)) = uintptr(0) ap = Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(uintptr(0))) * uint64(nMergeSlot)))) if !(ap != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, ap, 0, (uint64(unsafe.Sizeof(uintptr(0))) * uint64(nMergeSlot))) @@ -172979,7 +170139,7 @@ func fts5HashEntrySort(tls *libc.TLS, pHash uintptr, pTerm uintptr, nTerm int32, var pIter uintptr for pIter = *(*uintptr)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iSlot)*8)); pIter != 0; pIter = (*Fts5HashEntry)(unsafe.Pointer(pIter)).FpHashNext { if (pTerm == uintptr(0)) || - ((((*Fts5HashEntry)(unsafe.Pointer(pIter)).FnKey + 1) >= nTerm) && (0 == libc.Xmemcmp(tls, ((pIter)+uintptr(1)*48), pTerm, uint64(nTerm)))) { + ((((*Fts5HashEntry)(unsafe.Pointer(pIter)).FnKey + 1) >= nTerm) && (0 == libc.Xmemcmp(tls, ((pIter)+1*48), pTerm, uint64(nTerm)))) { var pEntry uintptr = pIter (*Fts5HashEntry)(unsafe.Pointer(pEntry)).FpScanNext = uintptr(0) for i = 0; *(*uintptr)(unsafe.Pointer(ap + uintptr(i)*8)) != 0; i++ { @@ -172999,7 +170159,7 @@ func fts5HashEntrySort(tls *libc.TLS, pHash uintptr, pTerm uintptr, nTerm int32, (*Fts5Hash)(unsafe.Pointer(pHash)).FnEntry = 0 Xsqlite3_free(tls, ap) *(*uintptr)(unsafe.Pointer(ppSorted)) = pList - return 0 + return SQLITE_OK } // Query the hash table for a doclist associated with term pTerm/nTerm. @@ -173009,7 +170169,7 @@ func sqlite3Fts5HashQuery(tls *libc.TLS, pHash uintptr, nPre int32, pTerm uintpt var p uintptr for p = *(*uintptr)(unsafe.Pointer((*Fts5Hash)(unsafe.Pointer(pHash)).FaSlot + uintptr(iHash)*8)); p != 0; p = (*Fts5HashEntry)(unsafe.Pointer(p)).FpHashNext { - zKey = ((p) + uintptr(1)*48) + zKey = ((p) + 1*48) if (nTerm == ((*Fts5HashEntry)(unsafe.Pointer(p)).FnKey + 1)) && (libc.Xmemcmp(tls, zKey, pTerm, uint64(nTerm)) == 0) { break @@ -173027,14 +170187,14 @@ func sqlite3Fts5HashQuery(tls *libc.TLS, pHash uintptr, nPre int32, pTerm uintpt *(*int32)(unsafe.Pointer(pnDoclist)) = nList } else { *(*int32)(unsafe.Pointer(pnDoclist)) = 0 - return 7 + return SQLITE_NOMEM } } else { *(*uintptr)(unsafe.Pointer(ppOut)) = uintptr(0) *(*int32)(unsafe.Pointer(pnDoclist)) = 0 } - return 0 + return SQLITE_OK } func sqlite3Fts5HashScanInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32) int32 { /* sqlite3.c:216317:12: */ @@ -173053,7 +170213,7 @@ func sqlite3Fts5HashScanEof(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:21632 func sqlite3Fts5HashScanEntry(tls *libc.TLS, pHash uintptr, pzTerm uintptr, ppDoclist uintptr, pnDoclist uintptr) { /* sqlite3.c:216333:13: */ var p uintptr if libc.AssignUintptr(&p, (*Fts5Hash)(unsafe.Pointer(pHash)).FpScan) != 0 { - var zKey uintptr = ((p) + uintptr(1)*48) + var zKey uintptr = ((p) + 1*48) var nTerm int32 = int32(libc.Xstrlen(tls, zKey)) fts5HashAddPoslistSize(tls, pHash, p, uintptr(0)) *(*uintptr)(unsafe.Pointer(pzTerm)) = zKey @@ -173622,12 +170782,12 @@ type Fts5CResult1 = struct { type Fts5CResult = Fts5CResult1 /* sqlite3.c:216729:28 */ func fts5PutU16(tls *libc.TLS, aOut uintptr, iVal U16) { /* sqlite3.c:216908:13: */ - *(*U8)(unsafe.Pointer(aOut + uintptr(0))) = (U8(int32(iVal) >> 8)) - *(*U8)(unsafe.Pointer(aOut + uintptr(1))) = (U8(int32(iVal) & 0xFF)) + *(*U8)(unsafe.Pointer(aOut)) = (U8(int32(iVal) >> 8)) + *(*U8)(unsafe.Pointer(aOut + 1)) = (U8(int32(iVal) & 0xFF)) } func fts5GetU16(tls *libc.TLS, aIn uintptr) U16 { /* sqlite3.c:216913:12: */ - return (U16((int32(U16(*(*U8)(unsafe.Pointer(aIn + uintptr(0))))) << 8) + int32(*(*U8)(unsafe.Pointer(aIn + uintptr(1)))))) + return (U16((int32(U16(*(*U8)(unsafe.Pointer(aIn)))) << 8) + int32(*(*U8)(unsafe.Pointer(aIn + 1))))) } // Allocate and return a buffer at least nByte bytes in size. @@ -173698,8 +170858,8 @@ func sqlite3Fts5IndexCloseReader(tls *libc.TLS, p uintptr) { /* sqlite3.c:216970 // Fts5Index object. func fts5DataRead(tls *libc.TLS, p uintptr, iRowid I64) uintptr { /* sqlite3.c:216984:17: */ var pRet uintptr = uintptr(0) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - var rc int32 = 0 + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var rc int32 = SQLITE_OK if (*Fts5Index)(unsafe.Pointer(p)).FpReader != 0 { // This call may return SQLITE_ABORT if there has been a savepoint @@ -173710,17 +170870,17 @@ func fts5DataRead(tls *libc.TLS, p uintptr, iRowid I64) uintptr { /* sqlite3.c:2 rc = Xsqlite3_blob_reopen(tls, pBlob, iRowid) (*Fts5Index)(unsafe.Pointer(p)).FpReader = pBlob - if rc != 0 { + if rc != SQLITE_OK { sqlite3Fts5IndexCloseReader(tls, p) } - if rc == 4 { - rc = 0 + if rc == SQLITE_ABORT { + rc = SQLITE_OK } } // If the blob handle is not open at this point, open it and seek // to the requested entry. - if ((*Fts5Index)(unsafe.Pointer(p)).FpReader == uintptr(0)) && (rc == 0) { + if ((*Fts5Index)(unsafe.Pointer(p)).FpReader == uintptr(0)) && (rc == SQLITE_OK) { var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig rc = Xsqlite3_blob_open(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Index)(unsafe.Pointer(p)).FzDataTbl, ts+37701 /* "block" */, iRowid, 0, (p + 56 /* &.pReader */)) @@ -173731,33 +170891,33 @@ func fts5DataRead(tls *libc.TLS, p uintptr, iRowid I64) uintptr { /* sqlite3.c:2 // All the reasons those functions might return SQLITE_ERROR - missing // table, missing row, non-blob/text in block column - indicate // backing store corruption. - if rc == 1 { - rc = (11 | (int32(1) << 8)) + if rc == SQLITE_ERROR { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } - if rc == 0 { + if rc == SQLITE_OK { var aOut uintptr = uintptr(0) // Read blob data into this buffer var nByte int32 = Xsqlite3_blob_bytes(tls, (*Fts5Index)(unsafe.Pointer(p)).FpReader) - var nAlloc Sqlite3_int64 = (Sqlite3_int64((uint64(unsafe.Sizeof(Fts5Data{})) + uint64(nByte)) + uint64(20))) + var nAlloc Sqlite3_int64 = (Sqlite3_int64((uint64(unsafe.Sizeof(Fts5Data{})) + uint64(nByte)) + FTS5_DATA_PADDING)) pRet = Xsqlite3_malloc64(tls, uint64(nAlloc)) if pRet != 0 { (*Fts5Data)(unsafe.Pointer(pRet)).Fnn = nByte - aOut = libc.AssignPtrUintptr(pRet /* &.p */, (pRet + uintptr(1)*16)) + aOut = libc.AssignPtrUintptr(pRet /* &.p */, (pRet + 1*16)) } else { - rc = 7 + rc = SQLITE_NOMEM } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_blob_read(tls, (*Fts5Index)(unsafe.Pointer(p)).FpReader, aOut, nByte, 0) } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_free(tls, pRet) pRet = uintptr(0) } else { // TODO1: Fix this *(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer(pRet)).Fp + uintptr(nByte))) = U8(0x00) *(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer(pRet)).Fp + uintptr((nByte + 1)))) = U8(0x00) - (*Fts5Data)(unsafe.Pointer(pRet)).FszLeaf = int32(fts5GetU16(tls, ((*Fts5Data)(unsafe.Pointer(pRet)).Fp + uintptr(2)))) + (*Fts5Data)(unsafe.Pointer(pRet)).FszLeaf = int32(fts5GetU16(tls, ((*Fts5Data)(unsafe.Pointer(pRet)).Fp + 2))) } } (*Fts5Index)(unsafe.Pointer(p)).Frc = rc @@ -173777,7 +170937,7 @@ func fts5LeafRead(tls *libc.TLS, p uintptr, iRowid I64) uintptr { /* sqlite3.c:2 var pRet uintptr = fts5DataRead(tls, p, iRowid) if pRet != 0 { if ((*Fts5Data)(unsafe.Pointer(pRet)).Fnn < 4) || ((*Fts5Data)(unsafe.Pointer(pRet)).FszLeaf > (*Fts5Data)(unsafe.Pointer(pRet)).Fnn) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) fts5DataRelease(tls, pRet) pRet = uintptr(0) } @@ -173786,13 +170946,13 @@ func fts5LeafRead(tls *libc.TLS, p uintptr, iRowid I64) uintptr { /* sqlite3.c:2 } func fts5IndexPrepareStmt(tls *libc.TLS, p uintptr, ppStmt uintptr, zSql uintptr) int32 { /* sqlite3.c:217073:12: */ - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { if zSql != 0 { (*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_prepare_v3(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fdb, zSql, -1, - (uint32(0x01 | 0x04)), + (uint32(SQLITE_PREPARE_PERSISTENT | SQLITE_PREPARE_NO_VTAB)), ppStmt, uintptr(0)) } else { - (*Fts5Index)(unsafe.Pointer(p)).Frc = 7 + (*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } } Xsqlite3_free(tls, zSql) @@ -173804,7 +170964,7 @@ func fts5DataWrite(tls *libc.TLS, p uintptr, iRowid I64, pData uintptr, nData in bp := tls.Alloc(16) defer tls.Free(16) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { return } @@ -173832,7 +170992,7 @@ func fts5DataDelete(tls *libc.TLS, p uintptr, iFirst I64, iLast I64) { /* sqlite bp := tls.Alloc(16) defer tls.Free(16) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { return } @@ -173857,8 +171017,8 @@ func fts5DataRemoveSegment(tls *libc.TLS, p uintptr, iSegid int32) { /* sqlite3. bp := tls.Alloc(16) defer tls.Free(16) - var iFirst I64 = (((((I64(iSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (int64(0))) - var iLast I64 = ((((((I64(iSegid + 1)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (int64(0))) - int64(1)) + var iFirst I64 = (((((I64(iSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (int64(0))) + var iLast I64 = ((((((I64(iSegid + 1)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (int64(0))) - int64(1)) fts5DataDelete(tls, p, iFirst, iLast) if (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter == uintptr(0) { var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig @@ -173866,7 +171026,7 @@ func fts5DataRemoveSegment(tls *libc.TLS, p uintptr, iSegid int32) { /* sqlite3. ts+37807, /* "DELETE FROM '%q'..." */ libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))) } - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { Xsqlite3_bind_int(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter, 1, iSegid) Xsqlite3_step(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter) (*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*Fts5Index)(unsafe.Pointer(p)).FpIdxDeleter) @@ -173904,7 +171064,7 @@ func fts5StructureDecode(tls *libc.TLS, pData uintptr, nData int32, piCookie uin bp := tls.Alloc(16) defer tls.Free(16) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK var i int32 = 0 var iLvl int32 *(*int32)(unsafe.Pointer(bp /* nLevel */)) = 0 @@ -173922,9 +171082,9 @@ func fts5StructureDecode(tls *libc.TLS, pData uintptr, nData int32, piCookie uin // structure record. i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), bp /* &nLevel */)) i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), bp+4 /* &nSegment */)) - if (((*(*int32)(unsafe.Pointer(bp /* nLevel */)) > 2000) || (*(*int32)(unsafe.Pointer(bp /* nLevel */)) < 0)) || - (*(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) > 2000)) || (*(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) < 0) { - return (11 | (int32(1) << 8)) + if (((*(*int32)(unsafe.Pointer(bp /* nLevel */)) > FTS5_MAX_SEGMENT) || (*(*int32)(unsafe.Pointer(bp /* nLevel */)) < 0)) || + (*(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) > FTS5_MAX_SEGMENT)) || (*(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) < 0) { + return (SQLITE_CORRUPT | (int32(1) << 8)) } nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5Structure{})) + (uint64(unsafe.Sizeof(Fts5StructureLevel{})) * (uint64(*(*int32)(unsafe.Pointer(bp /* nLevel */)) - 1))))) pRet = sqlite3Fts5MallocZero(tls, bp+8 /* &rc */, nByte) @@ -173935,53 +171095,53 @@ func fts5StructureDecode(tls *libc.TLS, pData uintptr, nData int32, piCookie uin (*Fts5Structure)(unsafe.Pointer(pRet)).FnSegment = *(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) i = i + (int32(sqlite3Fts5GetVarint(tls, (pData + uintptr(i)), (pRet + 8 /* &.nWriteCounter */)))) - for iLvl = 0; (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0) && (iLvl < *(*int32)(unsafe.Pointer(bp /* nLevel */))); iLvl++ { + for iLvl = 0; (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK) && (iLvl < *(*int32)(unsafe.Pointer(bp /* nLevel */))); iLvl++ { var pLvl uintptr = ((pRet + 24 /* &.aLevel */) + uintptr(iLvl)*16) *(*int32)(unsafe.Pointer(bp + 12 /* nTotal */)) = 0 var iSeg int32 if i >= nData { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } else { i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), (pLvl /* &.nMerge */))) i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), bp+12 /* &nTotal */)) if *(*int32)(unsafe.Pointer(bp + 12 /* nTotal */)) < (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg = sqlite3Fts5MallocZero(tls, bp+8, /* &rc */ (int64(uint64(*(*int32)(unsafe.Pointer(bp + 12 /* nTotal */))) * uint64(unsafe.Sizeof(Fts5StructureSegment{}))))) *(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) -= *(*int32)(unsafe.Pointer(bp + 12 /* nTotal */)) } - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg = *(*int32)(unsafe.Pointer(bp + 12 /* nTotal */)) for iSeg = 0; iSeg < *(*int32)(unsafe.Pointer(bp + 12 /* nTotal */)); iSeg++ { var pSeg uintptr = ((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSeg)*12) if i >= nData { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) break } i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), (pSeg /* &.iSegid */))) i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), (pSeg + 4 /* &.pgnoFirst */))) i = i + (sqlite3Fts5GetVarint32(tls, (pData + uintptr(i)), (pSeg + 8 /* &.pgnoLast */))) if (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast < (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) break } } if ((iLvl > 0) && ((*Fts5StructureLevel)(unsafe.Pointer(pLvl+libc.UintptrFromInt32(-1)*16)).FnMerge != 0)) && (*(*int32)(unsafe.Pointer(bp + 12 /* nTotal */)) == 0) { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } if (iLvl == (*(*int32)(unsafe.Pointer(bp /* nLevel */)) - 1)) && ((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnMerge != 0) { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } } } - if (*(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) != 0) && (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0) { - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (11 | (int32(1) << 8)) + if (*(*int32)(unsafe.Pointer(bp + 4 /* nSegment */)) != 0) && (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK) { + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) != SQLITE_OK { fts5StructureRelease(tls, pRet) pRet = uintptr(0) } @@ -173993,7 +171153,7 @@ func fts5StructureDecode(tls *libc.TLS, pData uintptr, nData int32, piCookie uin // func fts5StructureAddLevel(tls *libc.TLS, pRc uintptr, ppStruct uintptr) { /* sqlite3.c:217280:13: */ - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var pStruct uintptr = *(*uintptr)(unsafe.Pointer(ppStruct)) var nLevel int32 = (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel var nByte Sqlite3_int64 = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5Structure{})) + (uint64(unsafe.Sizeof(Fts5StructureLevel{})) * (uint64(nLevel + 1))))) @@ -174004,7 +171164,7 @@ func fts5StructureAddLevel(tls *libc.TLS, pRc uintptr, ppStruct uintptr) { /* sq (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel++ *(*uintptr)(unsafe.Pointer(ppStruct)) = pStruct } else { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } } @@ -174012,7 +171172,7 @@ func fts5StructureAddLevel(tls *libc.TLS, pRc uintptr, ppStruct uintptr) { /* sq // Extend level iLvl so that there is room for at least nExtra more // segments. func fts5StructureExtendLevel(tls *libc.TLS, pRc uintptr, pStruct uintptr, iLvl int32, nExtra int32, bInsert int32) { /* sqlite3.c:217304:13: */ - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var pLvl uintptr = ((pStruct + 24 /* &.aLevel */) + uintptr(iLvl)*16) var aNew uintptr var nByte Sqlite3_int64 @@ -174029,7 +171189,7 @@ func fts5StructureExtendLevel(tls *libc.TLS, pRc uintptr, pStruct uintptr, iLvl } (*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg = aNew } else { - *(*int32)(unsafe.Pointer(pRc)) = 7 + *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM } } } @@ -174044,16 +171204,16 @@ func fts5StructureReadUncached(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c: // Configuration cookie var pData uintptr - pData = fts5DataRead(tls, p, int64(10)) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + pData = fts5DataRead(tls, p, FTS5_STRUCTURE_ROWID) + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { // TODO: Do we need this if the leaf-index is appended? Probably... - libc.Xmemset(tls, ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr((*Fts5Data)(unsafe.Pointer(pData)).Fnn)), 0, uint64(20)) + libc.Xmemset(tls, ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr((*Fts5Data)(unsafe.Pointer(pData)).Fnn)), 0, FTS5_DATA_PADDING) (*Fts5Index)(unsafe.Pointer(p)).Frc = fts5StructureDecode(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp, (*Fts5Data)(unsafe.Pointer(pData)).Fnn, bp /* &iCookie */, bp+8 /* &pRet */) - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (((*Fts5Config)(unsafe.Pointer(pConfig)).Fpgsz == 0) || ((*Fts5Config)(unsafe.Pointer(pConfig)).FiCookie != *(*int32)(unsafe.Pointer(bp /* iCookie */)))) { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (((*Fts5Config)(unsafe.Pointer(pConfig)).Fpgsz == 0) || ((*Fts5Config)(unsafe.Pointer(pConfig)).FiCookie != *(*int32)(unsafe.Pointer(bp /* iCookie */)))) { (*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5ConfigLoad(tls, pConfig, *(*int32)(unsafe.Pointer(bp /* iCookie */))) } fts5DataRelease(tls, pData) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { fts5StructureRelease(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pRet */))) *(*uintptr)(unsafe.Pointer(bp + 8 /* pRet */)) = uintptr(0) } @@ -174068,7 +171228,7 @@ func fts5IndexDataVersion(tls *libc.TLS, p uintptr) I64 { /* sqlite3.c:217357:12 var iVersion I64 = int64(0) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { if (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion == uintptr(0) { (*Fts5Index)(unsafe.Pointer(p)).Frc = fts5IndexPrepareStmt(tls, p, (p + 112 /* &.pDataVersion */), Xsqlite3_mprintf(tls, ts+37847 /* "PRAGMA %Q.data_v..." */, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FzDb))) @@ -174077,7 +171237,7 @@ func fts5IndexDataVersion(tls *libc.TLS, p uintptr) I64 { /* sqlite3.c:217357:12 } } - if 100 == Xsqlite3_step(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion) { + if SQLITE_ROW == Xsqlite3_step(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion) { iVersion = Xsqlite3_column_int64(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion, 0) } (*Fts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*Fts5Index)(unsafe.Pointer(p)).FpDataVersion) @@ -174099,12 +171259,12 @@ func fts5StructureRead(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:217388:2 if (*Fts5Index)(unsafe.Pointer(p)).FpStruct == uintptr(0) { (*Fts5Index)(unsafe.Pointer(p)).FiStructVersion = fts5IndexDataVersion(tls, p) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Fts5Index)(unsafe.Pointer(p)).FpStruct = fts5StructureReadUncached(tls, p) } } - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { return uintptr(0) } @@ -174130,7 +171290,7 @@ func fts5StructureWrite(tls *libc.TLS, p uintptr, pStruct uintptr) { /* sqlite3. bp := tls.Alloc(16) defer tls.Free(16) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { // var buf Fts5Buffer at bp, 16 // Buffer to serialize record into var iLvl int32 // Used to iterate through levels @@ -174174,7 +171334,7 @@ func fts5StructureWrite(tls *libc.TLS, p uintptr, pStruct uintptr) { /* sqlite3. } } - fts5DataWrite(tls, p, int64(10), (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn) + fts5DataWrite(tls, p, FTS5_STRUCTURE_ROWID, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn) sqlite3Fts5BufferFree(tls, bp /* &buf */) } } @@ -174230,7 +171390,7 @@ func fts5StructurePromoteTo(tls *libc.TLS, p uintptr, iPromote int32, szPromote // If one or more segments are promoted, the structure object is updated // to reflect this. func fts5StructurePromote(tls *libc.TLS, p uintptr, iLvl int32, pStruct uintptr) { /* sqlite3.c:217577:13: */ - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { var iTst int32 var iPromote int32 = -1 var szPromote int32 = 0 // Promote anything this size or smaller @@ -174287,7 +171447,7 @@ func fts5DlidxLvlNext(tls *libc.TLS, pLvl uintptr) int32 { /* sqlite3.c:217628:1 if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff == 0 { (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff = 1 - *(*int32)(unsafe.Pointer(pLvl + 8 /* &.iOff */)) += (sqlite3Fts5GetVarint32(tls, ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr(1)), (pLvl + 20 /* &.iLeafPgno */))) + *(*int32)(unsafe.Pointer(pLvl + 8 /* &.iOff */)) += (sqlite3Fts5GetVarint32(tls, ((*Fts5Data)(unsafe.Pointer(pData)).Fp + 1), (pLvl + 20 /* &.iLeafPgno */))) *(*int32)(unsafe.Pointer(pLvl + 8 /* &.iOff */)) += (int32(sqlite3Fts5GetVarint(tls, ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff)), (pLvl + 24 /* &.iRowid */)))) (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiFirstOff = (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiOff } else { @@ -174320,11 +171480,11 @@ func fts5DlidxIterNextR(tls *libc.TLS, p uintptr, pIter uintptr, iLvl int32) int if fts5DlidxLvlNext(tls, pLvl) != 0 { if (iLvl + 1) < (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl { fts5DlidxIterNextR(tls, p, pIter, (iLvl + 1)) - if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl+uintptr(1)*32)).FbEof == 0 { + if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl+1*32)).FbEof == 0 { fts5DataRelease(tls, (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData) libc.Xmemset(tls, pLvl, 0, uint64(unsafe.Sizeof(Fts5DlidxLvl{}))) (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData = fts5DataRead(tls, p, - (((((I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(1))) << (31 + 5))) + ((I64(iLvl)) << (31))) + (I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl + uintptr(1)*32)).FiLeafPgno)))) + (((((I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(1))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + ((I64(iLvl)) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl + 1*32)).FiLeafPgno)))) if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData != 0 { fts5DlidxLvlNext(tls, pLvl) } @@ -174332,7 +171492,7 @@ func fts5DlidxIterNextR(tls *libc.TLS, p uintptr, pIter uintptr, iLvl int32) int } } - return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */) + uintptr(0)*32)).FbEof + return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */))).FbEof } func fts5DlidxIterNext(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3.c:217680:12: */ @@ -174353,18 +171513,18 @@ func fts5DlidxIterFirst(tls *libc.TLS, pIter uintptr) int32 { /* sqlite3.c:21769 for i = 0; i < (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl; i++ { fts5DlidxLvlNext(tls, ((pIter + 8 /* &.aLvl */) + uintptr(i)*32)) } - return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */) + uintptr(0)*32)).FbEof + return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */))).FbEof } func fts5DlidxIterEof(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3.c:217704:12: */ - return (libc.Bool32(((*Fts5Index)(unsafe.Pointer(p)).Frc != 0) || ((*Fts5DlidxLvl)(unsafe.Pointer((pIter+8 /* &.aLvl */)+uintptr(0)*32)).FbEof != 0))) + return (libc.Bool32(((*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK) || ((*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */))).FbEof != 0))) } func fts5DlidxIterLast(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:217708:13: */ var i int32 // Advance each level to the last entry on the last page - for i = ((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl - 1); ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (i >= 0); i-- { + for i = ((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl - 1); ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (i >= 0); i-- { var pLvl uintptr = ((pIter + 8 /* &.aLvl */) + uintptr(i)*32) for fts5DlidxLvlNext(tls, pLvl) == 0 { } @@ -174375,7 +171535,7 @@ func fts5DlidxIterLast(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:2 fts5DataRelease(tls, (*Fts5DlidxLvl)(unsafe.Pointer(pChild)).FpData) libc.Xmemset(tls, pChild, 0, uint64(unsafe.Sizeof(Fts5DlidxLvl{}))) (*Fts5DlidxLvl)(unsafe.Pointer(pChild)).FpData = fts5DataRead(tls, p, - (((((I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(1))) << (31 + 5))) + ((I64(i - 1)) << (31))) + (I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiLeafPgno)))) + (((((I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(1))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + ((I64(i - 1)) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FiLeafPgno)))) } } } @@ -174449,11 +171609,11 @@ func fts5DlidxIterPrevR(tls *libc.TLS, p uintptr, pIter uintptr, iLvl int32) int if fts5DlidxLvlPrev(tls, pLvl) != 0 { if (iLvl + 1) < (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl { fts5DlidxIterPrevR(tls, p, pIter, (iLvl + 1)) - if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl+uintptr(1)*32)).FbEof == 0 { + if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl+1*32)).FbEof == 0 { fts5DataRelease(tls, (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData) libc.Xmemset(tls, pLvl, 0, uint64(unsafe.Sizeof(Fts5DlidxLvl{}))) (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData = fts5DataRead(tls, p, - (((((I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(1))) << (31 + 5))) + ((I64(iLvl)) << (31))) + (I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl + uintptr(1)*32)).FiLeafPgno)))) + (((((I64((*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(1))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + ((I64(iLvl)) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5DlidxLvl)(unsafe.Pointer(pLvl + 1*32)).FiLeafPgno)))) if (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData != 0 { for fts5DlidxLvlNext(tls, pLvl) == 0 { } @@ -174463,7 +171623,7 @@ func fts5DlidxIterPrevR(tls *libc.TLS, p uintptr, pIter uintptr, iLvl int32) int } } - return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */) + uintptr(0)*32)).FbEof + return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */))).FbEof } func fts5DlidxIterPrev(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3.c:217803:12: */ @@ -174486,27 +171646,27 @@ func fts5DlidxIterInit(tls *libc.TLS, p uintptr, bRev int32, iSegid int32, iLeaf var i int32 var bDone int32 = 0 - for i = 0; ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (bDone == 0); i++ { + for i = 0; ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (bDone == 0); i++ { var nByte Sqlite3_int64 = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5DlidxIter{})) + (uint64(i) * uint64(unsafe.Sizeof(Fts5DlidxLvl{}))))) var pNew uintptr pNew = Xsqlite3_realloc64(tls, pIter, uint64(nByte)) if pNew == uintptr(0) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = 7 + (*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } else { - var iRowid I64 = (((((I64(iSegid)) << ((31 + 5) + 1)) + (I64((int64(1))) << (31 + 5))) + ((I64(i)) << (31))) + (I64(iLeafPg))) + var iRowid I64 = (((((I64(iSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(1))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + ((I64(i)) << (FTS5_DATA_PAGE_B))) + (I64(iLeafPg))) var pLvl uintptr = ((pNew + 8 /* &.aLvl */) + uintptr(i)*32) pIter = pNew libc.Xmemset(tls, pLvl, 0, uint64(unsafe.Sizeof(Fts5DlidxLvl{}))) (*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData = fts5DataRead(tls, p, iRowid) - if ((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData != 0) && ((int32(*(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData)).Fp + uintptr(0)))) & 0x0001) == 0) { + if ((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData != 0) && ((int32(*(*U8)(unsafe.Pointer((*Fts5Data)(unsafe.Pointer((*Fts5DlidxLvl)(unsafe.Pointer(pLvl)).FpData)).Fp))) & 0x0001) == 0) { bDone = 1 } (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FnLvl = (i + 1) } } - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Fts5DlidxIter)(unsafe.Pointer(pIter)).FiSegid = iSegid if bRev == 0 { fts5DlidxIterFirst(tls, pIter) @@ -174515,7 +171675,7 @@ func fts5DlidxIterInit(tls *libc.TLS, p uintptr, bRev int32, iSegid int32, iLeaf } } - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { fts5DlidxIterFree(tls, pIter) pIter = uintptr(0) } @@ -174524,11 +171684,11 @@ func fts5DlidxIterInit(tls *libc.TLS, p uintptr, bRev int32, iSegid int32, iLeaf } func fts5DlidxIterRowid(tls *libc.TLS, pIter uintptr) I64 { /* sqlite3.c:217867:12: */ - return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */) + uintptr(0)*32)).FiRowid + return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */))).FiRowid } func fts5DlidxIterPgno(tls *libc.TLS, pIter uintptr) int32 { /* sqlite3.c:217870:12: */ - return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */) + uintptr(0)*32)).FiLeafPgno + return (*Fts5DlidxLvl)(unsafe.Pointer((pIter + 8 /* &.aLvl */))).FiLeafPgno } // Load the next leaf page into the segment iterator. @@ -174542,7 +171702,7 @@ func fts5SegIterNextPage(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c (*Fts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf = uintptr(0) } else if (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno <= (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast { (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = fts5LeafRead(tls, p, - (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno)))) + (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno)))) } else { (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0) } @@ -174595,10 +171755,10 @@ func fts5SegIterLoadNPos(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c bp := tls.Alloc(4) defer tls.Free(4) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { var iOff int32 = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset // Offset to read at - if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == 1 { + if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_NONE { var iEod int32 = func() int32 { if ((*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist) < ((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf) { return (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist @@ -174643,8 +171803,8 @@ func fts5SegIterLoadRowid(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3. if iOff >= (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf { fts5SegIterNextPage(tls, p, pIter) if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0) { - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } return } @@ -174679,7 +171839,7 @@ func fts5SegIterLoadTerm(tls *libc.TLS, p uintptr, pIter uintptr, nKeep int32) { iOff = iOff + (sqlite3Fts5GetVarint32(tls, (a + uintptr(iOff)), bp /* &nNew */)) if (((iOff + *(*int32)(unsafe.Pointer(bp /* nNew */))) > (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf) || (nKeep > (*Fts5SegIter)(unsafe.Pointer(pIter)).Fterm.Fn)) || (*(*int32)(unsafe.Pointer(bp /* nNew */)) == 0) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) return } (*Fts5SegIter)(unsafe.Pointer(pIter)).Fterm.Fn = nKeep @@ -174703,11 +171863,11 @@ func fts5SegIterLoadTerm(tls *libc.TLS, p uintptr, pIter uintptr, nKeep int32) { } func fts5SegIterSetNext(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:218031:13: */ - if ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & 0x02) != 0 { + if ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_REVERSE) != 0 { (*Fts5SegIter)(unsafe.Pointer(pIter)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr) }{fts5SegIterNext_Reverse})) - } else if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == 1 { + } else if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_NONE { (*Fts5SegIter)(unsafe.Pointer(pIter)).FxNext = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr) }{fts5SegIterNext_None})) @@ -174735,7 +171895,7 @@ func fts5SegIterInit(tls *libc.TLS, p uintptr, pSeg uintptr, pIter uintptr) { /* return } - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { libc.Xmemset(tls, pIter, 0, uint64(unsafe.Sizeof(Fts5SegIter{}))) fts5SegIterSetNext(tls, p, pIter) (*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg = pSeg @@ -174743,7 +171903,7 @@ func fts5SegIterInit(tls *libc.TLS, p uintptr, pSeg uintptr, pIter uintptr) { /* fts5SegIterNextPage(tls, p, pIter) } - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = 4 (*Fts5SegIter)(unsafe.Pointer(pIter)).FiPgidxOff = ((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf + 1) @@ -174782,7 +171942,7 @@ func fts5SegIterReverseInitPage(tls *libc.TLS, p uintptr, pIter uintptr) { /* sq for 1 != 0 { *(*I64)(unsafe.Pointer(bp + 8 /* iDelta */)) = int64(0) - if eDetail == 1 { + if eDetail == FTS5_DETAIL_NONE { // todo if (i < n) && (int32(*(*U8)(unsafe.Pointer(a + uintptr(i)))) == 0) { i++ @@ -174809,7 +171969,7 @@ func fts5SegIterReverseInitPage(tls *libc.TLS, p uintptr, pIter uintptr) { /* sq var nNew int32 = ((*Fts5SegIter)(unsafe.Pointer(pIter)).FnRowidOffset + 8) var aNew uintptr = Xsqlite3_realloc64(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset, (uint64(uint64(nNew) * uint64(unsafe.Sizeof(int32(0)))))) if aNew == uintptr(0) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = 7 + (*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM break } (*Fts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset = aNew @@ -174828,10 +171988,10 @@ func fts5SegIterReverseNewPage(tls *libc.TLS, p uintptr, pIter uintptr) { /* sql fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0) - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno > (*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno) { + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno > (*Fts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno) { var pNew uintptr (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno-- - pNew = fts5DataRead(tls, p, (((((I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno)))) + pNew = fts5DataRead(tls, p, (((((I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno)))) if pNew != 0 { // iTermLeafOffset may be equal to szLeaf if the term is the last // thing on the page - i.e. the first rowid is on the following page. @@ -174871,8 +172031,8 @@ func fts5SegIterReverseNewPage(tls *libc.TLS, p uintptr, pIter uintptr) { /* sql // points to a delete marker. A delete marker is an entry with a 0 byte // position-list. func fts5MultiIterIsEmpty(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite3.c:218202:12: */ - var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(1)*4)).FiFirst)*120) - return (libc.Bool32((((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0)) && ((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos == 0))) + var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*120) + return (libc.Bool32((((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0)) && ((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos == 0))) } // Advance iterator pIter to the next entry. @@ -174893,7 +172053,7 @@ func fts5SegIterNext_Reverse(tls *libc.TLS, p uintptr, pIter uintptr, pbUnused u (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = *(*int32)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FaRowidOffset + uintptr((*Fts5SegIter)(unsafe.Pointer(pIter)).FiRowidOffset)*4)) fts5SegIterLoadNPos(tls, p, pIter) iOff = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset - if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail != 1 { + if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail != FTS5_DETAIL_NONE { iOff = iOff + ((*Fts5SegIter)(unsafe.Pointer(pIter)).FnPos) } sqlite3Fts5GetVarint(tls, (a + uintptr(iOff)), bp /* &iDelta */) @@ -174949,7 +172109,7 @@ __1: *(*I64)(unsafe.Pointer(pIter + 104 /* &.iRowid */)) += (*(*I64)(unsafe.Pointer(bp /* iDelta */))) goto __4 __3: - if !(((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & 0x01) == 0) { + if !(((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_ONETERM) == 0) { goto __5 } if !((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg != 0) { @@ -175052,7 +172212,7 @@ func fts5SegIterNext(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintptr) *(*uintptr)(unsafe.Pointer(bp + 16 /* zTerm */)) = uintptr(0) *(*int32)(unsafe.Pointer(bp + 32 /* nList */)) = 0 - if 0 == ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & 0x01) { + if 0 == ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_ONETERM) { sqlite3Fts5HashScanNext(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash) sqlite3Fts5HashScanEntry(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, bp+16 /* &zTerm */, bp+24 /* &pList */, bp+32 /* &nList */) } @@ -175094,7 +172254,7 @@ func fts5SegIterNext(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintptr) } if *(*int32)(unsafe.Pointer(bp + 36 /* iOff */)) > (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) return } } @@ -175103,7 +172263,7 @@ func fts5SegIterNext(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintptr) // Check if the iterator is now at EOF. If so, return early. if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { if bNewTerm != 0 { - if ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & 0x01) != 0 { + if ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_ONETERM) != 0 { fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf) (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = uintptr(0) } else { @@ -175148,7 +172308,7 @@ func fts5SegIterReverse(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c: if pDlidx != 0 { var iSegid int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid pgnoLast = fts5DlidxIterPgno(tls, pDlidx) - pLast = fts5DataRead(tls, p, (((((I64(iSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(pgnoLast)))) + pLast = fts5DataRead(tls, p, (((((I64(iSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(pgnoLast)))) } else { var pLeaf uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf // Current leaf data @@ -175179,7 +172339,7 @@ func fts5SegIterReverse(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c: // The last rowid in the doclist may not be on the current page. Search // forward to find the page containing the last rowid. for pgno = ((*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno + 1); !((*Fts5Index)(unsafe.Pointer(p)).Frc != 0) && (pgno <= (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast); pgno++ { - var iAbs I64 = (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(pgno))) + var iAbs I64 = (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(pgno))) var pNew uintptr = fts5DataRead(tls, p, iAbs) if pNew != 0 { var iRowid int32 @@ -175239,7 +172399,7 @@ func fts5SegIterReverse(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c: // doclist-index from disk and initialize an iterator at (pIter->pDlidx). func fts5SegIterLoadDlidx(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:218540:13: */ var iSeg int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid - var bRev int32 = ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & 0x02) + var bRev int32 = ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_REVERSE) var pLeaf uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf // Current leaf data // Check if the current doclist ends on this page. If it does, return @@ -175300,7 +172460,7 @@ func fts5LeafSeek(tls *libc.TLS, p uintptr, bGe int32, pIter uintptr, pTerm uint if !(*(*int32)(unsafe.Pointer(bp + 12 /* iOff */)) > n) { goto __1 } - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) return __1: ; @@ -175396,7 +172556,7 @@ __16: if !(*(*int32)(unsafe.Pointer(bp + 12 /* iOff */)) >= n) { goto __17 } - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) return __17: ; @@ -175444,7 +172604,7 @@ __25: if !((*(*int32)(unsafe.Pointer(bp + 12 /* iOff */)) < 4) || (*(*int32)(unsafe.Pointer(bp + 12 /* iOff */)) >= (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf)) { goto __27 } - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) return goto __28 __27: @@ -175474,7 +172634,7 @@ search_success: if !(((I64(*(*int32)(unsafe.Pointer(bp + 12 /* iOff */))) + I64(*(*U32)(unsafe.Pointer(bp + 4 /* nNew */)))) > I64(n)) || (*(*U32)(unsafe.Pointer(bp + 4 /* nNew */)) < U32(1))) { goto __29 } - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) return __29: ; @@ -175522,7 +172682,7 @@ func fts5IdxSelectStmt(tls *libc.TLS, p uintptr) uintptr { /* sqlite3.c:218701:2 // an error has already occurred when this function is called, it is a no-op. func fts5SegIterSeekInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, flags int32, pSeg uintptr, pIter uintptr) { /* sqlite3.c:218720:13: */ var iPg int32 = 1 - var bGe int32 = (flags & 0x0008) + var bGe int32 = (flags & FTS5INDEX_QUERY_SCAN) var bDlidx int32 = 0 // True if there is a doclist-index var pIdxSelect uintptr = uintptr(0) @@ -175537,7 +172697,7 @@ func fts5SegIterSeekInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, f } Xsqlite3_bind_int(tls, pIdxSelect, 1, (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid) Xsqlite3_bind_blob(tls, pIdxSelect, 2, pTerm, nTerm, uintptr(0)) - if 100 == Xsqlite3_step(tls, pIdxSelect) { + if SQLITE_ROW == Xsqlite3_step(tls, pIdxSelect) { var val I64 = I64(Xsqlite3_column_int(tls, pIdxSelect, 0)) iPg = (int32(val >> 1)) bDlidx = (int32(val & int64(0x0001))) @@ -175557,16 +172717,16 @@ func fts5SegIterSeekInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, f fts5LeafSeek(tls, p, bGe, pIter, pTerm, nTerm) } - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (bGe == 0) { - *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (0x01) + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (bGe == 0) { + *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (FTS5_SEGITER_ONETERM) if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf != 0 { - if (flags & 0x0002) != 0 { - *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (0x02) + if (flags & FTS5INDEX_QUERY_DESC) != 0 { + *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (FTS5_SEGITER_REVERSE) } if bDlidx != 0 { fts5SegIterLoadDlidx(tls, p, pIter) } - if (flags & 0x0002) != 0 { + if (flags & FTS5INDEX_QUERY_DESC) != 0 { fts5SegIterReverse(tls, p, pIter) } } @@ -175599,7 +172759,7 @@ func fts5SegIterHashInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, f var n int32 = 0 *(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)) = uintptr(0) - if (pTerm == uintptr(0)) || ((flags & 0x0008) != 0) { + if (pTerm == uintptr(0)) || ((flags & FTS5INDEX_QUERY_SCAN) != 0) { *(*uintptr)(unsafe.Pointer(bp + 8 /* pList */)) = uintptr(0) (*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5HashScanInit(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, pTerm, nTerm) @@ -175620,11 +172780,11 @@ func fts5SegIterHashInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, f (*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5HashQuery(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, int32(unsafe.Sizeof(Fts5Data{})), pTerm, nTerm, bp+24 /* &pLeaf */, bp+16 /* &nList */) if *(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)) != 0 { - (*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)))).Fp = (*(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)) + uintptr(1)*16) + (*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)))).Fp = (*(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)) + 1*16) } *(*uintptr)(unsafe.Pointer(bp /* z */)) = pTerm n = nTerm - *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (0x01) + *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (FTS5_SEGITER_ONETERM) } if *(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)) != 0 { @@ -175634,8 +172794,8 @@ func fts5SegIterHashInit(tls *libc.TLS, p uintptr, pTerm uintptr, nTerm int32, f (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int32(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)))).Fp, (pIter + 104 /* &.iRowid */))) (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*Fts5Data)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pLeaf */)))).Fnn - if (flags & 0x0002) != 0 { - *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (0x02) + if (flags & FTS5INDEX_QUERY_DESC) != 0 { + *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (FTS5_SEGITER_REVERSE) fts5SegIterReverseInitPage(tls, p, pIter) } else { fts5SegIterLoadNPos(tls, p, pIter) @@ -175716,21 +172876,21 @@ func fts5MultiIterDoCompare(tls *libc.TLS, pIter uintptr, iOut int32) int32 { /* func fts5SegIterGotoPage(tls *libc.TLS, p uintptr, pIter uintptr, iLeafPgno int32) { /* sqlite3.c:219020:13: */ if iLeafPgno > (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FpgnoLast { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf) (*Fts5SegIter)(unsafe.Pointer(pIter)).FpNextLeaf = uintptr(0) (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = (iLeafPgno - 1) fts5SegIterNextPage(tls, p, pIter) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { var iOff int32 var a uintptr = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp var n int32 = (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).FszLeaf iOff = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf)).Fp)) if (iOff < 4) || (iOff >= n) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { iOff = iOff + (int32(sqlite3Fts5GetVarint(tls, (a + uintptr(iOff)), (pIter + 104 /* &.iRowid */)))) (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = iOff @@ -175744,7 +172904,7 @@ func fts5SegIterGotoPage(tls *libc.TLS, p uintptr, pIter uintptr, iLeafPgno int3 // past rowid iFrom. Regardless of the value of iFrom, the iterator is // always advanced at least once. func fts5SegIterNextFrom(tls *libc.TLS, p uintptr, pIter uintptr, iMatch I64) { /* sqlite3.c:219058:13: */ - var bRev int32 = ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & 0x02) + var bRev int32 = ((*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags & FTS5_SEGITER_REVERSE) var pDlidx uintptr = (*Fts5SegIter)(unsafe.Pointer(pIter)).FpDlidx var iLeafPgno int32 = (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno var bMove int32 = 1 @@ -175773,8 +172933,8 @@ func fts5SegIterNextFrom(tls *libc.TLS, p uintptr, pIter uintptr, iMatch I64) { } } - for ok := true; ok; ok = ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) { - if (bMove != 0) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) { + for ok := true; ok; ok = ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) { + if (bMove != 0) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) { (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer((pIter + 40 /* &.xNext */))))(tls, p, pIter, uintptr(0)) } if (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0) { @@ -175804,7 +172964,7 @@ func fts5MultiIterFree(tls *libc.TLS, pIter uintptr) { /* sqlite3.c:219112:13: * func fts5MultiIterAdvanced(tls *libc.TLS, p uintptr, pIter uintptr, iChanged int32, iMinset int32) { /* sqlite3.c:219123:13: */ var i int32 - for i = (((*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg + iChanged) / 2); (i >= iMinset) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0); i = (i / 2) { + for i = (((*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg + iChanged) / 2); (i >= iMinset) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK); i = (i / 2) { var iEq int32 if libc.AssignInt32(&iEq, fts5MultiIterDoCompare(tls, pIter, i)) != 0 { var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr(iEq)*120) @@ -175864,7 +173024,7 @@ func fts5MultiIterAdvanceRowid(tls *libc.TLS, pIter uintptr, iChanged int32, ppF // Set the pIter->bEof variable based on the state of the sub-iterators. func fts5MultiIterSetEof(tls *libc.TLS, pIter uintptr) { /* sqlite3.c:219194:13: */ - var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(1)*4)).FiFirst)*120) + var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*120) (*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FbEof = (U8(libc.Bool32((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf == uintptr(0)))) (*Fts5Iter)(unsafe.Pointer(pIter)).FiSwitchRowid = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiRowid } @@ -175880,8 +173040,8 @@ func fts5MultiIterNext(tls *libc.TLS, p uintptr, pIter uintptr, bFrom int32, iFr var bUseFrom int32 = bFrom - for (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - var iFirst int32 = int32((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + uintptr(1)*4)).FiFirst) + for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var iFirst int32 = int32((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4)).FiFirst) *(*int32)(unsafe.Pointer(bp /* bNewTerm */)) = 0 *(*uintptr)(unsafe.Pointer(bp + 8 /* pSeg */)) = ((pIter + 96 /* &.aSeg */) + uintptr(iFirst)*120) @@ -175895,7 +173055,7 @@ func fts5MultiIterNext(tls *libc.TLS, p uintptr, pIter uintptr, bFrom int32, iFr (fts5MultiIterAdvanceRowid(tls, pIter, iFirst, bp+8 /* &pSeg */) != 0) { fts5MultiIterAdvanced(tls, p, pIter, iFirst, 1) fts5MultiIterSetEof(tls, pIter) - *(*uintptr)(unsafe.Pointer(bp + 8 /* pSeg */)) = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(1)*4)).FiFirst)*120) + *(*uintptr)(unsafe.Pointer(bp + 8 /* pSeg */)) = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*120) if (*Fts5SegIter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pSeg */)))).FpLeaf == uintptr(0) { return } @@ -175913,10 +173073,10 @@ func fts5MultiIterNext2(tls *libc.TLS, p uintptr, pIter uintptr, pbNewTerm uintp bp := tls.Alloc(16) defer tls.Free(16) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { *(*int32)(unsafe.Pointer(pbNewTerm)) = 0 for ok := true; ok; ok = fts5MultiIterIsEmpty(tls, p, pIter) != 0 { - var iFirst int32 = int32((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + uintptr(1)*4)).FiFirst) + var iFirst int32 = int32((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst + 1*4)).FiFirst) *(*uintptr)(unsafe.Pointer(bp + 8 /* pSeg */)) = ((pIter + 96 /* &.aSeg */) + uintptr(iFirst)*120) *(*int32)(unsafe.Pointer(bp /* bNewTerm */)) = 0 @@ -176118,7 +173278,7 @@ func fts5ChunkIterate(tls *libc.TLS, p uintptr, pSeg uintptr, pCtx uintptr, xChu // This function does notmwork with detail=none databases. - if ((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fflags & 0x02) == 0 { + if ((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fflags & FTS5_SEGITER_REVERSE) == 0 { pgnoSave = (pgno + 1) } @@ -176130,11 +173290,11 @@ func fts5ChunkIterate(tls *libc.TLS, p uintptr, pSeg uintptr, pCtx uintptr, xChu break } else { pgno++ - pData = fts5LeafRead(tls, p, (((((I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(pgno)))) + pData = fts5LeafRead(tls, p, (((((I64((*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(pgno)))) if pData == uintptr(0) { break } - pChunk = ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr(4)) + pChunk = ((*Fts5Data)(unsafe.Pointer(pData)).Fp + 4) nChunk = func() int32 { if (nRem) < ((*Fts5Data)(unsafe.Pointer(pData)).FszLeaf - 4) { return nRem @@ -176159,18 +173319,18 @@ func fts5SegiterPoslist(tls *libc.TLS, p uintptr, pSeg uintptr, pColset uintptr, defer tls.Free(48) if 0 == (func() int32 { - if ((U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)) + (U32((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos + 8))) <= (U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace)) { + if ((U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)) + (U32((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos + FTS5_DATA_ZERO_PADDING))) <= (U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace)) { return 0 } - return sqlite3Fts5BufferSize(tls, (p + 52 /* &.rc */), pBuf, (uint32(((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos + 8) + (*Fts5Buffer)(unsafe.Pointer((pBuf))).Fn))) + return sqlite3Fts5BufferSize(tls, (p + 52 /* &.rc */), pBuf, (uint32(((*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos + FTS5_DATA_ZERO_PADDING) + (*Fts5Buffer)(unsafe.Pointer((pBuf))).Fn))) }()) { - libc.Xmemset(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn + (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos))), 0, uint64(8)) + libc.Xmemset(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn + (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos))), 0, FTS5_DATA_ZERO_PADDING) if pColset == uintptr(0) { fts5ChunkIterate(tls, p, pSeg, pBuf, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr, int32) }{fts5PoslistCallback}))) } else { - if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == 0 { + if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_FULL { // var sCtx PoslistCallbackCtx at bp, 24 (*PoslistCallbackCtx)(unsafe.Pointer(bp /* &sCtx */)).FpBuf = pBuf @@ -176245,7 +173405,7 @@ func fts5IndexExtractColset(tls *libc.TLS, pRc uintptr, pColset uintptr, pPos ui bp := tls.Alloc(8) defer tls.Free(8) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var i int32 sqlite3Fts5BufferZero(tls, pBuf) for i = 0; i < (*Fts5Colset)(unsafe.Pointer(pColset)).FnCol; i++ { @@ -176340,7 +173500,7 @@ __3: if !(a < pEnd) { goto __4 } - iPrev = iPrev + (int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&a, 1) + uintptr(0)))) - 2) + iPrev = iPrev + (int32(*(*U8)(unsafe.Pointer(libc.PostIncUintptr(&a, 1)))) - 2) __5: if !(*(*int32)(unsafe.Pointer(aiCol)) < iPrev) { goto __6 @@ -176385,7 +173545,7 @@ func fts5IterSetOutputs_Full(tls *libc.TLS, pIter uintptr, pSeg uintptr) { /* sq // variables to point into the body of the page object. *(*uintptr)(unsafe.Pointer(bp /* a */)) = ((*Fts5Data)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).Fp + uintptr((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset)) if (*Fts5Colset)(unsafe.Pointer(pColset)).FnCol == 1 { - (*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = fts5IndexExtractCol(tls, bp /* &a */, (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos, *(*int32)(unsafe.Pointer((pColset + 4 /* &.aiCol */) + uintptr(0)*4))) + (*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = fts5IndexExtractCol(tls, bp /* &a */, (*Fts5SegIter)(unsafe.Pointer(pSeg)).FnPos, *(*int32)(unsafe.Pointer((pColset + 4 /* &.aiCol */)))) (*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FpData = *(*uintptr)(unsafe.Pointer(bp /* a */)) } else { var pRc uintptr = ((*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex + 52 /* &.rc */) @@ -176406,9 +173566,9 @@ func fts5IterSetOutputs_Full(tls *libc.TLS, pIter uintptr, pSeg uintptr) { /* sq } func fts5IterSetOutputCb(tls *libc.TLS, pRc uintptr, pIter uintptr) { /* sqlite3.c:219689:13: */ - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { var pConfig uintptr = (*Fts5Index)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex)).FpConfig - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 1 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_NONE { (*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) }{fts5IterSetOutputs_None})) @@ -176420,7 +173580,7 @@ func fts5IterSetOutputCb(tls *libc.TLS, pRc uintptr, pIter uintptr) { /* sqlite3 (*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) }{fts5IterSetOutputs_ZeroColset})) - } else if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 0 { + } else if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_FULL { (*Fts5Iter)(unsafe.Pointer(pIter)).FxSetOutputs = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr) }{fts5IterSetOutputs_Full})) @@ -176457,7 +173617,7 @@ func fts5MultiIterNew(tls *libc.TLS, p uintptr, pStruct uintptr, flags int32, pC var pNew uintptr // Allocate space for the new multi-seg-iterator. - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { if iLevel < 0 { nSeg = (*Fts5Structure)(unsafe.Pointer(pStruct)).FnSegment @@ -176480,15 +173640,15 @@ func fts5MultiIterNew(tls *libc.TLS, p uintptr, pStruct uintptr, flags int32, pC if pNew == uintptr(0) { return } - (*Fts5Iter)(unsafe.Pointer(pNew)).FbRev = (libc.Bool32(0 != (flags & 0x0002))) - (*Fts5Iter)(unsafe.Pointer(pNew)).FbSkipEmpty = (U8(libc.Bool32(0 != (flags & 0x0010)))) + (*Fts5Iter)(unsafe.Pointer(pNew)).FbRev = (libc.Bool32(0 != (flags & FTS5INDEX_QUERY_DESC))) + (*Fts5Iter)(unsafe.Pointer(pNew)).FbSkipEmpty = (U8(libc.Bool32(0 != (flags & FTS5INDEX_QUERY_SKIPEMPTY)))) (*Fts5Iter)(unsafe.Pointer(pNew)).FpColset = pColset - if (flags & 0x0020) == 0 { + if (flags & FTS5INDEX_QUERY_NOOUTPUT) == 0 { fts5IterSetOutputCb(tls, (p + 52 /* &.rc */), pNew) } // Initialize each of the component segment iterators. - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { if iLevel < 0 { var pEnd uintptr = ((pStruct + 24 /* &.aLevel */) + uintptr((*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel)*16) if (*Fts5Index)(unsafe.Pointer(p)).FpHash != 0 { @@ -176496,7 +173656,7 @@ func fts5MultiIterNew(tls *libc.TLS, p uintptr, pStruct uintptr, flags int32, pC var pIter uintptr = ((pNew + 96 /* &.aSeg */) + uintptr(libc.PostIncInt32(&iIter, 1))*120) fts5SegIterHashInit(tls, p, pTerm, nTerm, flags, pIter) } - for pLvl = ((pStruct + 24 /* &.aLevel */) + uintptr(0)*16); pLvl < pEnd; pLvl += 16 { + for pLvl = (pStruct + 24 /* &.aLevel */); pLvl < pEnd; pLvl += 16 { for iSeg = ((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FnSeg - 1); iSeg >= 0; iSeg-- { var pSeg uintptr = ((*Fts5StructureLevel)(unsafe.Pointer(pLvl)).FaSeg + uintptr(iSeg)*12) var pIter uintptr = ((pNew + 96 /* &.aSeg */) + uintptr(libc.PostIncInt32(&iIter, 1))*120) @@ -176520,12 +173680,12 @@ func fts5MultiIterNew(tls *libc.TLS, p uintptr, pStruct uintptr, flags int32, pC // to the first entry in its segment. In this case initialize the // aFirst[] array. Or, if an error has occurred, free the iterator // object and set the output variable to NULL. - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { for iIter = ((*Fts5Iter)(unsafe.Pointer(pNew)).FnSeg - 1); iIter > 0; iIter-- { var iEq int32 if libc.AssignInt32(&iEq, fts5MultiIterDoCompare(tls, pNew, iIter)) != 0 { var pSeg uintptr = ((pNew + 96 /* &.aSeg */) + uintptr(iEq)*120) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer((pSeg + 40 /* &.xNext */))))(tls, p, pSeg, uintptr(0)) } fts5MultiIterAdvanced(tls, p, pNew, iEq, iIter) @@ -176536,7 +173696,7 @@ func fts5MultiIterNew(tls *libc.TLS, p uintptr, pStruct uintptr, flags int32, pC if ((*Fts5Iter)(unsafe.Pointer(pNew)).FbSkipEmpty != 0) && (fts5MultiIterIsEmpty(tls, p, pNew) != 0) { fts5MultiIterNext(tls, p, pNew, 0, int64(0)) } else if int32((*Fts5Iter)(unsafe.Pointer(pNew)).Fbase.FbEof) == 0 { - var pSeg uintptr = ((pNew + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pNew)).FaFirst+uintptr(1)*4)).FiFirst)*120) + var pSeg uintptr = ((pNew + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pNew)).FaFirst+1*4)).FiFirst)*120) (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer((pNew + 56 /* &.xSetOutputs */))))(tls, pNew, pSeg) } @@ -176552,17 +173712,17 @@ func fts5MultiIterNew2(tls *libc.TLS, p uintptr, pData uintptr, bDesc int32, ppO var pNew uintptr pNew = fts5MultiIterAlloc(tls, p, 2) if pNew != 0 { - var pIter uintptr = ((pNew + 96 /* &.aSeg */) + uintptr(1)*120) + var pIter uintptr = ((pNew + 96 /* &.aSeg */) + 1*120) - (*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags = 0x01 + (*Fts5SegIter)(unsafe.Pointer(pIter)).Fflags = FTS5_SEGITER_ONETERM if (*Fts5Data)(unsafe.Pointer(pData)).FszLeaf > 0 { (*Fts5SegIter)(unsafe.Pointer(pIter)).FpLeaf = pData (*Fts5SegIter)(unsafe.Pointer(pIter)).FiLeafOffset = int32(sqlite3Fts5GetVarint(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp, (pIter + 104 /* &.iRowid */))) (*Fts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist = (*Fts5Data)(unsafe.Pointer(pData)).Fnn - (*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pNew)).FaFirst + uintptr(1)*4)).FiFirst = U16(1) + (*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pNew)).FaFirst + 1*4)).FiFirst = U16(1) if bDesc != 0 { (*Fts5Iter)(unsafe.Pointer(pNew)).FbRev = 1 - *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (0x02) + *(*int32)(unsafe.Pointer(pIter + 8 /* &.flags */)) |= (FTS5_SEGITER_REVERSE) fts5SegIterReverseInitPage(tls, p, pIter) } else { fts5SegIterLoadNPos(tls, p, pIter) @@ -176591,7 +173751,7 @@ func fts5MultiIterEof(tls *libc.TLS, p uintptr, pIter uintptr) int32 { /* sqlite // results are undefined. func fts5MultiIterRowid(tls *libc.TLS, pIter uintptr) I64 { /* sqlite3.c:219883:12: */ - return (*Fts5SegIter)(unsafe.Pointer((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(1)*4)).FiFirst)*120)).FiRowid + return (*Fts5SegIter)(unsafe.Pointer((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*120)).FiRowid } // Move the iterator to the next entry at or following iMatch. @@ -176615,7 +173775,7 @@ func fts5MultiIterNextFrom(tls *libc.TLS, p uintptr, pIter uintptr, iMatch I64) // Return a pointer to a buffer containing the term associated with the // entry that the iterator currently points to. func fts5MultiIterTerm(tls *libc.TLS, pIter uintptr, pn uintptr) uintptr { /* sqlite3.c:219910:17: */ - var p uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(1)*4)).FiFirst)*120) + var p uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*120) *(*int32)(unsafe.Pointer(pn)) = (*Fts5SegIter)(unsafe.Pointer(p)).Fterm.Fn return (*Fts5SegIter)(unsafe.Pointer(p)).Fterm.Fp } @@ -176633,9 +173793,9 @@ func fts5AllocateSegid(tls *libc.TLS, p uintptr, pStruct uintptr) int32 { /* sql var iSegid int32 = 0 - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - if (*Fts5Structure)(unsafe.Pointer(pStruct)).FnSegment >= 2000 { - (*Fts5Index)(unsafe.Pointer(p)).Frc = 13 + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + if (*Fts5Structure)(unsafe.Pointer(pStruct)).FnSegment >= FTS5_MAX_SEGMENT { + (*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_FULL } else { // FTS5_MAX_SEGMENT is currently defined as 2000. So the following // array is 63 elements, or 252 bytes, in size. @@ -176649,7 +173809,7 @@ func fts5AllocateSegid(tls *libc.TLS, p uintptr, pStruct uintptr) int32 { /* sql for iLvl = 0; iLvl < (*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel; iLvl++ { for iSeg = 0; iSeg < (*Fts5StructureLevel)(unsafe.Pointer((pStruct+24 /* &.aLevel */)+uintptr(iLvl)*16)).FnSeg; iSeg++ { var iId int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5StructureLevel)(unsafe.Pointer((pStruct+24 /* &.aLevel */)+uintptr(iLvl)*16)).FaSeg + uintptr(iSeg)*12)).FiSegid - if (iId <= 2000) && (iId > 0) { + if (iId <= FTS5_MAX_SEGMENT) && (iId > 0) { *(*U32)(unsafe.Pointer(bp /* &aUsed */ + uintptr(((iId-1)/32))*4)) |= (U32(U32(1)) << ((iId - 1) % 32)) } } @@ -176703,7 +173863,7 @@ func fts5WriteDlidxClear(tls *libc.TLS, p uintptr, pWriter uintptr, bFlush int32 if bFlush != 0 { fts5DataWrite(tls, p, - (((((I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(1))) << (31 + 5))) + ((I64(i)) << (31))) + (I64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno))), + (((((I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(1))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + ((I64(i)) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno))), (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fp, (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fn) } sqlite3Fts5BufferZero(tls, (pDlidx + 16 /* &.buf */)) @@ -176714,11 +173874,11 @@ func fts5WriteDlidxClear(tls *libc.TLS, p uintptr, pWriter uintptr, bFlush int32 // Grow the pWriter->aDlidx[] array to at least nLvl elements in size. // Any new array elements are zeroed before returning. func fts5WriteDlidxGrow(tls *libc.TLS, p uintptr, pWriter uintptr, nLvl int32) int32 { /* sqlite3.c:220031:12: */ - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (nLvl >= (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx) { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (nLvl >= (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx) { var aDlidx uintptr = Xsqlite3_realloc64(tls, (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx, (uint64(uint64(unsafe.Sizeof(Fts5DlidxWriter{})) * uint64(nLvl)))) if aDlidx == uintptr(0) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = 7 + (*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM } else { var nByte Size_t = (uint64(unsafe.Sizeof(Fts5DlidxWriter{})) * (uint64(nLvl - (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx))) libc.Xmemset(tls, (aDlidx + uintptr((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnDlidx)*32), 0, nByte) @@ -176737,7 +173897,7 @@ func fts5WriteFlushDlidx(tls *libc.TLS, p uintptr, pWriter uintptr) int32 { /* s // If there were FTS5_MIN_DLIDX_SIZE or more empty leaf pages written // to the database, also write the doclist-index to disk. - if ((*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx+uintptr(0)*32)).Fbuf.Fn > 0) && ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty >= 4) { + if ((*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx)).Fbuf.Fn > 0) && ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty >= FTS5_MIN_DLIDX_SIZE) { bFlag = 1 } fts5WriteDlidxClear(tls, p, pWriter, bFlag) @@ -176762,7 +173922,7 @@ func fts5WriteFlushBtree(tls *libc.TLS, p uintptr, pWriter uintptr) { /* sqlite3 } bFlag = fts5WriteFlushDlidx(tls, p, pWriter) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { var z uintptr = func() uintptr { if (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fn > 0 { return (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fp @@ -176789,7 +173949,7 @@ func fts5WriteFlushBtree(tls *libc.TLS, p uintptr, pWriter uintptr) { /* sqlite3 // has already occurred when this function is called, it is a no-op. func fts5WriteBtreeTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, pTerm uintptr) { /* sqlite3.c:220110:13: */ fts5WriteFlushBtree(tls, p, pWriter) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { sqlite3Fts5BufferSet(tls, (p + 52 /* &.rc */), (pWriter + 96 /* &.btterm */), nTerm, pTerm) (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage = (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fpgno } @@ -176800,8 +173960,8 @@ func fts5WriteBtreeTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, func fts5WriteBtreeNoTerm(tls *libc.TLS, p uintptr, pWriter uintptr) { /* sqlite3.c:220126:13: */ // If there were no rowids on the leaf page either and the doclist-index // has already been started, append an 0x00 byte to it. - if ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage != 0) && ((*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx+uintptr(0)*32)).Fbuf.Fn > 0) { - var pDlidx uintptr = ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(0)*32) + if ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage != 0) && ((*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx)).Fbuf.Fn > 0) { + var pDlidx uintptr = ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx) sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + 16 /* &.buf */), int64(0)) } @@ -176818,7 +173978,7 @@ func fts5DlidxExtractFirstRowid(tls *libc.TLS, pBuf uintptr) I64 { /* sqlite3.c: var iOff int32 - iOff = (1 + int32(sqlite3Fts5GetVarint(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+uintptr(1)), bp /* &iRowid */))) + iOff = (1 + int32(sqlite3Fts5GetVarint(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp+1), bp /* &iRowid */))) sqlite3Fts5GetVarint(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(iOff)), bp /* &iRowid */) return *(*I64)(unsafe.Pointer(bp /* iRowid */)) } @@ -176830,7 +173990,7 @@ func fts5WriteDlidxAppend(tls *libc.TLS, p uintptr, pWriter uintptr, iRowid I64) var i int32 var bDone int32 = 0 - for i = 0; ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (bDone == 0); i++ { + for i = 0; ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (bDone == 0); i++ { var iVal I64 var pDlidx uintptr = ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(i)*32) @@ -176840,22 +174000,22 @@ func fts5WriteDlidxAppend(tls *libc.TLS, p uintptr, pWriter uintptr, iRowid I64) // doclist-index leaf page) up into the next level of the b-tree // hierarchy. If the node being flushed is currently the root node, // also push its first rowid upwards. - *(*U8)(unsafe.Pointer((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fp + uintptr(0))) = U8(0x01) // Not the root node + *(*U8)(unsafe.Pointer((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fp)) = U8(0x01) // Not the root node fts5DataWrite(tls, p, - (((((I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(1))) << (31 + 5))) + ((I64(i)) << (31))) + (I64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno))), + (((((I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(1))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + ((I64(i)) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno))), (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fp, (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fbuf.Fn) fts5WriteDlidxGrow(tls, p, pWriter, (i + 2)) pDlidx = ((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(i)*32) - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx+uintptr(1)*32)).Fbuf.Fn == 0) { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx+1*32)).Fbuf.Fn == 0) { var iFirst I64 = fts5DlidxExtractFirstRowid(tls, (pDlidx + 16 /* &.buf */)) // This was the root node. Push its first rowid up to the new root. - (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + uintptr(1)*32)).Fpgno = (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno - sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + uintptr(1)*32 + 16 /* &.buf */), int64(0)) - sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + uintptr(1)*32 + 16 /* &.buf */), int64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno)) - sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + uintptr(1)*32 + 16 /* &.buf */), iFirst) - (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + uintptr(1)*32)).FbPrevValid = 1 - (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + uintptr(1)*32)).FiPrev = iFirst + (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + 1*32)).Fpgno = (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno + sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + 1*32 + 16 /* &.buf */), int64(0)) + sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + 1*32 + 16 /* &.buf */), int64((*Fts5DlidxWriter)(unsafe.Pointer(pDlidx)).Fpgno)) + sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (pDlidx + 1*32 + 16 /* &.buf */), iFirst) + (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + 1*32)).FbPrevValid = 1 + (*Fts5DlidxWriter)(unsafe.Pointer(pDlidx + 1*32)).FiPrev = iFirst } sqlite3Fts5BufferZero(tls, (pDlidx + 16 /* &.buf */)) @@ -176892,7 +174052,7 @@ func fts5WriteFlushLeaf(tls *libc.TLS, p uintptr, pWriter uintptr) { /* sqlite3. // Set the szLeaf header field. - fts5PutU16(tls, ((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fp + uintptr(2)), U16((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn)) + fts5PutU16(tls, ((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fp + 2), U16((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn)) if (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstTermInPage != 0 { // No term was written to this page. @@ -176904,7 +174064,7 @@ func fts5WriteFlushLeaf(tls *libc.TLS, p uintptr, pWriter uintptr) { /* sqlite3. } // Write the page out to disk - iRowid = (((((I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgno))) + iRowid = (((((I64((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgno))) fts5DataWrite(tls, p, iRowid, (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fp, (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn) // Initialize the next page. @@ -176944,12 +174104,12 @@ func fts5WriteAppendTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, if ((((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn + (*Fts5Buffer)(unsafe.Pointer(pPgidx)).Fn) + nTerm) + 2) >= (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz { if (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn > 4 { fts5WriteFlushLeaf(tls, p, pWriter) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { return } } - if !(((U32((*Fts5Buffer)(unsafe.Pointer((pPage + 8 /* &.buf */))).Fn)) + (U32(nTerm + 20))) <= (U32((*Fts5Buffer)(unsafe.Pointer((pPage + 8 /* &.buf */))).FnSpace))) { - sqlite3Fts5BufferSize(tls, (p + 52 /* &.rc */), (pPage + 8 /* &.buf */), (uint32((nTerm + 20) + (*Fts5Buffer)(unsafe.Pointer((pPage + 8 /* &.buf */))).Fn))) + if !(((U32((*Fts5Buffer)(unsafe.Pointer((pPage + 8 /* &.buf */))).Fn)) + (U32(nTerm + FTS5_DATA_PADDING))) <= (U32((*Fts5Buffer)(unsafe.Pointer((pPage + 8 /* &.buf */))).FnSpace))) { + sqlite3Fts5BufferSize(tls, (p + 52 /* &.rc */), (pPage + 8 /* &.buf */), (uint32((nTerm + FTS5_DATA_PADDING) + (*Fts5Buffer)(unsafe.Pointer((pPage + 8 /* &.buf */))).Fn))) } } @@ -176979,7 +174139,7 @@ func fts5WriteAppendTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, n = (1 + fts5PrefixCompress(tls, nMin, (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fterm.Fp, pTerm)) } fts5WriteBtreeTerm(tls, p, pWriter, n, pTerm) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { return } pPage = (pWriter + 8 /* &.writer */) @@ -177001,12 +174161,12 @@ func fts5WriteAppendTerm(tls *libc.TLS, p uintptr, pWriter uintptr, nTerm int32, (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInPage = U8(0) (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FbFirstRowidInDoclist = U8(1) - (*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx + uintptr(0)*32)).Fpgno = (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgno + (*Fts5DlidxWriter)(unsafe.Pointer((*Fts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx)).Fpgno = (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgno } // Append a rowid and position-list size field to the writers output. func fts5WriteAppendRowid(tls *libc.TLS, p uintptr, pWriter uintptr, iRowid I64) { /* sqlite3.c:220343:13: */ - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { var pPage uintptr = (pWriter + 8 /* &.writer */) if ((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn + (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn) >= (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz { @@ -177042,7 +174202,7 @@ func fts5WriteAppendPoslistData(tls *libc.TLS, p uintptr, pWriter uintptr, aData var a uintptr = aData var n int32 = nData - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((((*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn + (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn) + n) >= (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz) { var nReq int32 = (((*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz - (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fbuf.Fn) - (*Fts5PageWriter)(unsafe.Pointer(pPage)).Fpgidx.Fn) var nCopy int32 = 0 @@ -177066,7 +174226,7 @@ func fts5WriteAppendPoslistData(tls *libc.TLS, p uintptr, pWriter uintptr, aData func fts5WriteFinish(tls *libc.TLS, p uintptr, pWriter uintptr, pnLeaf uintptr) { /* sqlite3.c:220410:13: */ var i int32 var pLeaf uintptr = (pWriter + 8 /* &.writer */) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { if (*Fts5PageWriter)(unsafe.Pointer(pLeaf)).Fbuf.Fn > 4 { fts5WriteFlushLeaf(tls, p, pWriter) @@ -177091,7 +174251,7 @@ func fts5WriteInit(tls *libc.TLS, p uintptr, pWriter uintptr, iSegid int32) { /* bp := tls.Alloc(16) defer tls.Free(16) - var nBuffer int32 = ((*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz + 20) + var nBuffer int32 = ((*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).Fpgsz + FTS5_DATA_PADDING) libc.Xmemset(tls, pWriter, 0, uint64(unsafe.Sizeof(Fts5SegWriter{}))) (*Fts5SegWriter)(unsafe.Pointer(pWriter)).FiSegid = iSegid @@ -177112,7 +174272,7 @@ func fts5WriteInit(tls *libc.TLS, p uintptr, pWriter uintptr, iSegid int32) { /* libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName))) } - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { // Initialize the 4-byte leaf-page header to 0x00. libc.Xmemset(tls, (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fbuf.Fp, 0, uint64(4)) (*Fts5SegWriter)(unsafe.Pointer(pWriter)).Fwriter.Fbuf.Fn = 4 @@ -177135,7 +174295,7 @@ func fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:22 // var buf Fts5Buffer at bp, 16 libc.Xmemset(tls, bp /* &buf */, 0, uint64(unsafe.Sizeof(Fts5Buffer{}))) - for i = 0; (i < (*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0); i++ { + for i = 0; (i < (*Fts5Iter)(unsafe.Pointer(pIter)).FnSeg) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK); i++ { var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr(i)*120) if (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg == uintptr(0) { // no-op @@ -177152,7 +174312,7 @@ func fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:22 var iId int32 = (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid *(*[4]U8)(unsafe.Pointer(bp + 16 /* aHdr */)) = [4]U8{U8(0x00), U8(0x00), U8(0x00), U8(0x00)} - iLeafRowid = (((((I64(iId)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno))) + iLeafRowid = (((((I64(iId)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64((*Fts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno))) pData = fts5LeafRead(tls, p, iLeafRowid) if pData != 0 { if iOff > (*Fts5Data)(unsafe.Pointer(pData)).FszLeaf { @@ -177160,7 +174320,7 @@ func fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:22 // a single page has been assigned to more than one segment. In // this case a prior iteration of this loop may have corrupted the // segment currently being trimmed. - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { sqlite3Fts5BufferZero(tls, bp /* &buf */) if !(((U32((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn)) + (U32((*Fts5Data)(unsafe.Pointer(pData)).Fnn))) <= (U32((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).FnSpace))) { @@ -177170,9 +174330,9 @@ func fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:22 sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), bp /* &buf */, int64((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn)) sqlite3Fts5BufferAppendBlob(tls, (p + 52 /* &.rc */), bp /* &buf */, uint32((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn), (*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp) sqlite3Fts5BufferAppendBlob(tls, (p + 52 /* &.rc */), bp /* &buf */, (uint32((*Fts5Data)(unsafe.Pointer(pData)).FszLeaf - iOff)), ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr(iOff))) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { // Set the szLeaf field - fts5PutU16(tls, ((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp + uintptr(2)), U16((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn)) + fts5PutU16(tls, ((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp + 2), U16((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn)) } // Set up the new page-index array @@ -177186,7 +174346,7 @@ func fts5TrimSegments(tls *libc.TLS, p uintptr, pIter uintptr) { /* sqlite3.c:22 } (*Fts5StructureSegment)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FpgnoFirst = (*Fts5SegIter)(unsafe.Pointer(pSeg)).FiTermLeafPgno - fts5DataDelete(tls, p, (((((I64(iId)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (int64(1))), iLeafRowid) + fts5DataDelete(tls, p, (((((I64(iId)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (int64(1))), iLeafRowid) fts5DataWrite(tls, p, iLeafRowid, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn) } fts5DataRelease(tls, pData) @@ -177224,7 +174384,7 @@ func fts5IndexMergeLevel(tls *libc.TLS, p uintptr, ppStruct uintptr, iLvl int32, var bOldest int32 // True if the output segment is the oldest var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail - var flags int32 = 0x0020 + var flags int32 = FTS5INDEX_QUERY_NOOUTPUT var bTermWritten int32 = 0 // True if current term already output libc.Xmemset(tls, bp /* &writer */, 0, uint64(unsafe.Sizeof(Fts5SegWriter{}))) @@ -177269,7 +174429,7 @@ func fts5IndexMergeLevel(tls *libc.TLS, p uintptr, ppStruct uintptr, iLvl int32, bOldest = (libc.Bool32(((*Fts5StructureLevel)(unsafe.Pointer(pLvlOut)).FnSeg == 1) && ((*Fts5Structure)(unsafe.Pointer(pStruct)).FnLevel == (iLvl + 2)))) for fts5MultiIterNew(tls, p, pStruct, flags, uintptr(0), uintptr(0), 0, iLvl, nInput, bp+136 /* &pIter */); fts5MultiIterEof(tls, p, *(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */))) == 0; fts5MultiIterNext(tls, p, *(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */)), 0, int64(0)) { - var pSegIter uintptr = ((*(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */)))).FaFirst+uintptr(1)*4)).FiFirst)*120) + var pSegIter uintptr = ((*(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */)))).FaFirst+1*4)).FiFirst)*120) var nPos int32 // position-list size field value // var nTerm int32 at bp+144, 4 @@ -177294,7 +174454,7 @@ func fts5IndexMergeLevel(tls *libc.TLS, p uintptr, ppStruct uintptr, iLvl int32, continue } - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (bTermWritten == 0) { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (bTermWritten == 0) { // This is a new term. Append a term to the output segment. fts5WriteAppendTerm(tls, p, bp /* &writer */, *(*int32)(unsafe.Pointer(bp + 144 /* nTerm */)), pTerm) bTermWritten = 1 @@ -177304,7 +174464,7 @@ func fts5IndexMergeLevel(tls *libc.TLS, p uintptr, ppStruct uintptr, iLvl int32, // WRITEPOSLISTSIZE fts5WriteAppendRowid(tls, p, bp /* &writer */, fts5MultiIterRowid(tls, *(*uintptr)(unsafe.Pointer(bp + 136 /* pIter */)))) - if eDetail == 1 { + if eDetail == FTS5_DETAIL_NONE { if (*Fts5SegIter)(unsafe.Pointer(pSegIter)).FbDel != 0 { sqlite3Fts5BufferAppendVarint(tls, (p + 52 /* &.rc */), (bp /* &writer */ + 8 /* &.writer */ + 8 /* &.buf */), int64(0)) if (*Fts5SegIter)(unsafe.Pointer(pSegIter)).FnPos > 0 { @@ -177368,7 +174528,7 @@ func fts5IndexMerge(tls *libc.TLS, p uintptr, ppStruct uintptr, nPg int32, nMin *(*int32)(unsafe.Pointer(bp + 8 /* nRem */)) = nPg var bRet int32 = 0 *(*uintptr)(unsafe.Pointer(bp /* pStruct */)) = *(*uintptr)(unsafe.Pointer(ppStruct)) - for (*(*int32)(unsafe.Pointer(bp + 8 /* nRem */)) > 0) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) { + for (*(*int32)(unsafe.Pointer(bp + 8 /* nRem */)) > 0) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) { var iLvl int32 // To iterate through levels var iBestLvl int32 = 0 // Level offering the most input segments var nBest int32 = 0 // Number of input segments on best level @@ -177397,7 +174557,7 @@ func fts5IndexMerge(tls *libc.TLS, p uintptr, ppStruct uintptr, nPg int32, nMin } bRet = 1 fts5IndexMergeLevel(tls, p, bp /* &pStruct */, iBestLvl, bp+8 /* &nRem */) - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pStruct */))+24 /* &.aLevel */)+uintptr(iBestLvl)*16)).FnMerge == 0) { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pStruct */))+24 /* &.aLevel */)+uintptr(iBestLvl)*16)).FnMerge == 0) { fts5StructurePromote(tls, p, (iBestLvl + 1), *(*uintptr)(unsafe.Pointer(bp /* pStruct */))) } } @@ -177412,7 +174572,7 @@ func fts5IndexMerge(tls *libc.TLS, p uintptr, ppStruct uintptr, nPg int32, nMin // If an error occurs, set the Fts5Index.rc error code. If an error has // already occurred, this function is a no-op. func fts5IndexAutomerge(tls *libc.TLS, p uintptr, ppStruct uintptr, nLeaf int32) { /* sqlite3.c:220771:13: */ - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FnAutomerge > 0) { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FnAutomerge > 0) { var pStruct uintptr = *(*uintptr)(unsafe.Pointer(ppStruct)) var nWrite U64 // Initial value of write-counter var nWork int32 // Number of work-quanta to perform @@ -177436,7 +174596,7 @@ func fts5IndexCrisismerge(tls *libc.TLS, p uintptr, ppStruct uintptr) { /* sqlit *(*uintptr)(unsafe.Pointer(bp /* pStruct */)) = *(*uintptr)(unsafe.Pointer(ppStruct)) var iLvl int32 = 0 - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pStruct */))+24 /* &.aLevel */)+uintptr(iLvl)*16)).FnSeg >= nCrisis) { + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pStruct */))+24 /* &.aLevel */)+uintptr(iLvl)*16)).FnSeg >= nCrisis) { fts5IndexMergeLevel(tls, p, bp /* &pStruct */, iLvl, uintptr(0)) fts5StructurePromote(tls, p, (iLvl + 1), *(*uintptr)(unsafe.Pointer(bp /* pStruct */))) @@ -177447,7 +174607,7 @@ func fts5IndexCrisismerge(tls *libc.TLS, p uintptr, ppStruct uintptr) { /* sqlit func fts5IndexReturn(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:220810:12: */ var rc int32 = (*Fts5Index)(unsafe.Pointer(p)).Frc - (*Fts5Index)(unsafe.Pointer(p)).Frc = 0 + (*Fts5Index)(unsafe.Pointer(p)).Frc = SQLITE_OK return rc } @@ -177521,10 +174681,10 @@ func fts5FlushOneHash(tls *libc.TLS, p uintptr) { /* sqlite3.c:220848:13: */ // Begin scanning through hash table entries. This loop runs once for each // term/doclist currently stored within the hash table. - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Fts5Index)(unsafe.Pointer(p)).Frc = sqlite3Fts5HashScanInit(tls, pHash, uintptr(0), 0) } - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (0 == sqlite3Fts5HashScanEof(tls, pHash)) { + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (0 == sqlite3Fts5HashScanEof(tls, pHash)) { // var zTerm uintptr at bp+120, 8 // Buffer containing term // var pDoclist uintptr at bp+128, 8 @@ -177535,7 +174695,7 @@ func fts5FlushOneHash(tls *libc.TLS, p uintptr) { /* sqlite3.c:220848:13: */ // Write the term for this entry to disk. sqlite3Fts5HashScanEntry(tls, pHash, bp+120 /* &zTerm */, bp+128 /* &pDoclist */, bp+136 /* &nDoclist */) fts5WriteAppendTerm(tls, p, bp /* &writer */, int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* zTerm */)))), *(*uintptr)(unsafe.Pointer(bp + 120 /* zTerm */))) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { break } @@ -177554,23 +174714,23 @@ func fts5FlushOneHash(tls *libc.TLS, p uintptr) { /* sqlite3.c:220848:13: */ // The entire doclist will not fit on this leaf. The following // loop iterates through the poslists that make up the current // doclist. - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (iOff < *(*int32)(unsafe.Pointer(bp + 136 /* nDoclist */))) { + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (iOff < *(*int32)(unsafe.Pointer(bp + 136 /* nDoclist */))) { iOff = iOff + (int32(sqlite3Fts5GetVarint(tls, (*(*uintptr)(unsafe.Pointer(bp + 128 /* pDoclist */)) + uintptr(iOff)), bp+144 /* &iDelta */))) iRowid = iRowid + (*(*I64)(unsafe.Pointer(bp + 144 /* iDelta */))) if (*Fts5SegWriter)(unsafe.Pointer(bp /* &writer */)).FbFirstRowidInPage != 0 { - fts5PutU16(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(0)), U16((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)) // first rowid on page + fts5PutU16(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp), U16((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)) // first rowid on page *(*int32)(unsafe.Pointer(pBuf + 8 /* &.n */)) += (sqlite3Fts5PutVarint(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)), uint64(iRowid))) (*Fts5SegWriter)(unsafe.Pointer(bp /* &writer */)).FbFirstRowidInPage = U8(0) fts5WriteDlidxAppend(tls, p, bp /* &writer */, iRowid) - if (*Fts5Index)(unsafe.Pointer(p)).Frc != 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK { break } } else { *(*int32)(unsafe.Pointer(pBuf + 8 /* &.n */)) += (sqlite3Fts5PutVarint(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)), uint64(*(*I64)(unsafe.Pointer(bp + 144 /* iDelta */))))) } - if eDetail == 1 { + if eDetail == FTS5_DETAIL_NONE { if (iOff < *(*int32)(unsafe.Pointer(bp + 136 /* nDoclist */))) && (int32(*(*U8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 128 /* pDoclist */)) + uintptr(iOff)))) == 0) { *(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr(libc.PostIncInt32(&(*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn, 1)))) = U8(0) iOff++ @@ -177603,7 +174763,7 @@ func fts5FlushOneHash(tls *libc.TLS, p uintptr) { /* sqlite3.c:220848:13: */ // that each varint must be stored contiguously. var pPoslist uintptr = (*(*uintptr)(unsafe.Pointer(bp + 128 /* pDoclist */)) + uintptr(iOff)) var iPos int32 = 0 - for (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + for (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { var nSpace int32 = ((pgsz - (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn) - (*Fts5Buffer)(unsafe.Pointer(pPgidx)).Fn) var n int32 = 0 if (nCopy - iPos) <= nSpace { @@ -177634,7 +174794,7 @@ func fts5FlushOneHash(tls *libc.TLS, p uintptr) { /* sqlite3.c:220848:13: */ // TODO2: Doclist terminator written here. // pBuf->p[pBuf->n++] = '\0'; - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { sqlite3Fts5HashScanNext(tls, pHash) } } @@ -177647,8 +174807,8 @@ func fts5FlushOneHash(tls *libc.TLS, p uintptr) { /* sqlite3.c:220848:13: */ fts5StructureAddLevel(tls, (p + 52 /* &.rc */), bp+168 /* &pStruct */) } fts5StructureExtendLevel(tls, (p + 52 /* &.rc */), *(*uintptr)(unsafe.Pointer(bp + 168 /* pStruct */)), 0, 1, 0) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - pSeg = ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 168 /* pStruct */))+24 /* &.aLevel */)+uintptr(0)*16)).FaSeg + uintptr(libc.PostIncInt32(&(*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 168 /* pStruct */))+24 /* &.aLevel */)+uintptr(0)*16)).FnSeg, 1))*12) + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + pSeg = ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 168 /* pStruct */)) + 24 /* &.aLevel */))).FaSeg + uintptr(libc.PostIncInt32(&(*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 168 /* pStruct */))+24 /* &.aLevel */))).FnSeg, 1))*12) (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid = iSegid (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst = 1 (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast = *(*int32)(unsafe.Pointer(bp + 160 /* pgnoLast */)) @@ -177754,8 +174914,8 @@ func sqlite3Fts5IndexOptimize(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:221 var iLvl int32 for iLvl = 0; (*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNew */))+24 /* &.aLevel */)+uintptr(iLvl)*16)).FnSeg == 0; iLvl++ { } - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNew */))+24 /* &.aLevel */)+uintptr(iLvl)*16)).FnSeg > 0) { - *(*int32)(unsafe.Pointer(bp + 8 /* nRem */)) = 1000 + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5StructureLevel)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNew */))+24 /* &.aLevel */)+uintptr(iLvl)*16)).FnSeg > 0) { + *(*int32)(unsafe.Pointer(bp + 8 /* nRem */)) = FTS5_OPT_WORK_UNIT fts5IndexMergeLevel(tls, p, bp /* &pNew */, iLvl, bp+8 /* &nRem */) } @@ -177800,9 +174960,9 @@ func fts5AppendRowid(tls *libc.TLS, p uintptr, iDelta I64, pUnused uintptr, pBuf func fts5AppendPoslist(tls *libc.TLS, p uintptr, iDelta I64, pMulti uintptr, pBuf uintptr) { /* sqlite3.c:221139:13: */ var nData int32 = (*Fts5Iter)(unsafe.Pointer(pMulti)).Fbase.FnData - var nByte int32 = (((nData + 9) + 9) + 8) + var nByte int32 = (((nData + 9) + 9) + FTS5_DATA_ZERO_PADDING) - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (0 == (func() int32 { + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (0 == (func() int32 { if ((U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)) + (U32(nByte))) <= (U32((*Fts5Buffer)(unsafe.Pointer(pBuf)).FnSpace)) { return 0 } @@ -177821,7 +174981,7 @@ func fts5AppendPoslist(tls *libc.TLS, p uintptr, iDelta I64, pMulti uintptr, pBu *(*int32)(unsafe.Pointer(pBuf + 8 /* &.n */)) += (nData) } - libc.Xmemset(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)), 0, uint64(8)) + libc.Xmemset(tls, ((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp + uintptr((*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn)), 0, FTS5_DATA_ZERO_PADDING) } } @@ -177840,13 +175000,13 @@ func fts5DoclistIterNext(tls *libc.TLS, pIter uintptr) { /* sqlite3.c:221157:13: *(*I64)(unsafe.Pointer(pIter + 8 /* &.iRowid */)) += (*(*I64)(unsafe.Pointer(bp /* iDelta */))) // Read position list size - if (int32(*(*U8)(unsafe.Pointer(p + uintptr(0)))) & 0x80) != 0 { + if (int32(*(*U8)(unsafe.Pointer(p))) & 0x80) != 0 { // var nPos int32 at bp+8, 4 (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnSize = sqlite3Fts5GetVarint32(tls, p, bp+8 /* &nPos */) (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist = (*(*int32)(unsafe.Pointer(bp + 8 /* nPos */)) >> 1) } else { - (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist = ((int32(*(*U8)(unsafe.Pointer(p + uintptr(0))))) >> 1) + (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnPoslist = ((int32(*(*U8)(unsafe.Pointer(p)))) >> 1) (*Fts5DoclistIter)(unsafe.Pointer(pIter)).FnSize = 1 } @@ -178093,8 +175253,8 @@ func fts5MergePrefixLists(tls *libc.TLS, p uintptr, p1 uintptr, p2 uintptr) { /* // WRITEPOSLISTSIZE if (*Fts5Buffer)(unsafe.Pointer(bp+88 /* &tmp */)).Fn > ((*Fts5DoclistIter)(unsafe.Pointer(bp+16 /* &i1 */)).FnPoslist + (*Fts5DoclistIter)(unsafe.Pointer(bp+48 /* &i2 */)).FnPoslist) { - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } break } @@ -178160,7 +175320,7 @@ func fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, pToken uintptr, var nBuf int32 = 32 var xMerge uintptr var xAppend uintptr - if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == 1 { + if (*Fts5Config)(unsafe.Pointer((*Fts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == FTS5_DETAIL_NONE { xMerge = *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, uintptr, uintptr) }{fts5MergeRowidLists})) @@ -178180,9 +175340,9 @@ func fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, pToken uintptr, pStruct = fts5StructureRead(tls, p) if (aBuf != 0) && (pStruct != 0) { - var flags int32 = ((0x0008 | - 0x0010) | - 0x0020) + var flags int32 = ((FTS5INDEX_QUERY_SCAN | + FTS5INDEX_QUERY_SKIPEMPTY) | + FTS5INDEX_QUERY_NOOUTPUT) var i int32 var iLastRowid I64 = int64(0) *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)) = uintptr(0) // Iterator used to gather data from index @@ -178195,7 +175355,7 @@ func fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, pToken uintptr, fts5MultiIterNew(tls, p, pStruct, flags, pColset, pToken, nToken, -1, 0, bp+16 /* &p1 */) fts5IterSetOutputCb(tls, (p + 52 /* &.rc */), *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */))) for ; fts5MultiIterEof(tls, p, *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */))) == 0; fts5MultiIterNext2(tls, p, *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)), bp+24 /* &bNewTerm */) { - var pSeg uintptr = ((*(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)))).FaFirst+uintptr(1)*4)).FiFirst)*120) + var pSeg uintptr = ((*(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)))).FaFirst+1*4)).FiFirst)*120) var nTerm int32 = (*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fn var pTerm uintptr = (*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)) + 56 /* &.xSetOutputs */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)), pSeg) @@ -178211,7 +175371,7 @@ func fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, pToken uintptr, } if ((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */)))).Fbase.FiRowid <= iLastRowid) && ((*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn > 0) { - for i = 0; ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn != 0); i++ { + for i = 0; ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn != 0); i++ { if (*Fts5Buffer)(unsafe.Pointer(aBuf+uintptr(i)*16)).Fn == 0 { fts5BufferSwap(tls, bp /* &doclist */, (aBuf + uintptr(i)*16)) @@ -178229,16 +175389,16 @@ func fts5SetupPrefixIter(tls *libc.TLS, p uintptr, bDesc int32, pToken uintptr, } for i = 0; i < nBuf; i++ { - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&xMerge)))(tls, p, bp /* &doclist */, (aBuf + uintptr(i)*16)) } sqlite3Fts5BufferFree(tls, (aBuf + uintptr(i)*16)) } fts5MultiIterFree(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */))) - pData = fts5IdxMalloc(tls, p, (int64((uint64(unsafe.Sizeof(Fts5Data{})) + uint64((*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn)) + uint64(8)))) + pData = fts5IdxMalloc(tls, p, (int64((uint64(unsafe.Sizeof(Fts5Data{})) + uint64((*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn)) + FTS5_DATA_ZERO_PADDING))) if pData != 0 { - (*Fts5Data)(unsafe.Pointer(pData)).Fp = (pData + uintptr(1)*16) + (*Fts5Data)(unsafe.Pointer(pData)).Fp = (pData + 1*16) (*Fts5Data)(unsafe.Pointer(pData)).Fnn = libc.AssignPtrInt32(pData+12 /* &.szLeaf */, (*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn) if (*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn != 0 { libc.Xmemcpy(tls, (*Fts5Data)(unsafe.Pointer(pData)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fp, uint64((*Fts5Buffer)(unsafe.Pointer(bp /* &doclist */)).Fn)) @@ -178290,7 +175450,7 @@ func sqlite3Fts5IndexRollback(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:221 fts5IndexDiscardData(tls, p) fts5StructureInvalidate(tls, p) // assert( p->rc==SQLITE_OK ); - return 0 + return SQLITE_OK } // The %_data table is completely empty when this function is called. This @@ -178305,7 +175465,7 @@ func sqlite3Fts5IndexReinit(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:22158 fts5StructureInvalidate(tls, p) fts5IndexDiscardData(tls, p) libc.Xmemset(tls, bp /* &s */, 0, uint64(unsafe.Sizeof(Fts5Structure{}))) - fts5DataWrite(tls, p, int64(1), ts+800 /* "" */, 0) + fts5DataWrite(tls, p, FTS5_AVERAGES_ROWID, ts+800 /* "" */, 0) fts5StructureWrite(tls, p, bp /* &s */) return fts5IndexReturn(tls, p) } @@ -178319,23 +175479,23 @@ func sqlite3Fts5IndexOpen(tls *libc.TLS, pConfig uintptr, bCreate int32, pp uint bp := tls.Alloc(12) defer tls.Free(12) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK var p uintptr // New object *(*uintptr)(unsafe.Pointer(pp)) = libc.AssignUintptr(&p, sqlite3Fts5MallocZero(tls, bp+8 /* &rc */, int64(unsafe.Sizeof(Fts5Index{})))) - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { (*Fts5Index)(unsafe.Pointer(p)).FpConfig = pConfig - (*Fts5Index)(unsafe.Pointer(p)).FnWorkUnit = 64 + (*Fts5Index)(unsafe.Pointer(p)).FnWorkUnit = FTS5_WORK_UNIT (*Fts5Index)(unsafe.Pointer(p)).FzDataTbl = sqlite3Fts5Mprintf(tls, bp+8 /* &rc */, ts+38011 /* "%s_data" */, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) if ((*Fts5Index)(unsafe.Pointer(p)).FzDataTbl != 0) && (bCreate != 0) { *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = sqlite3Fts5CreateTable(tls, pConfig, ts+28361 /* "data" */, ts+38019 /* "id INTEGER PRIMA..." */, 0, pzErr) - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = sqlite3Fts5CreateTable(tls, pConfig, ts+12628, /* "idx" */ ts+38054, /* "segid, term, pgn..." */ 1, pzErr) } - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = sqlite3Fts5IndexReinit(tls, p) } } @@ -178350,7 +175510,7 @@ func sqlite3Fts5IndexOpen(tls *libc.TLS, pConfig uintptr, bCreate int32, pp uint // Close a handle opened by an earlier call to sqlite3Fts5IndexOpen(). func sqlite3Fts5IndexClose(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:221641:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if p != 0 { fts5StructureInvalidate(tls, p) @@ -178420,15 +175580,15 @@ func fts5IndexCharlen(tls *libc.TLS, pIn uintptr, nIn int32) int32 { /* sqlite3. // unique token in the document with an iCol value less than zero. The iPos // argument is ignored for a delete. func sqlite3Fts5IndexWrite(tls *libc.TLS, p uintptr, iCol int32, iPos int32, pToken uintptr, nToken int32) int32 { /* sqlite3.c:221713:12: */ - var i int32 // Used to iterate through indexes - var rc int32 = 0 // Return code + var i int32 // Used to iterate through indexes + var rc int32 = SQLITE_OK // Return code var pConfig uintptr = (*Fts5Index)(unsafe.Pointer(p)).FpConfig // Add the entry to the main terms index. rc = sqlite3Fts5HashWrite(tls, (*Fts5Index)(unsafe.Pointer(p)).FpHash, (*Fts5Index)(unsafe.Pointer(p)).FiWriteRowid, iCol, iPos, int8('0'), pToken, nToken) - for i = 0; (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix) && (rc == 0); i++ { + for i = 0; (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix) && (rc == SQLITE_OK); i++ { var nChar int32 = *(*int32)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr(i)*4)) var nByte int32 = sqlite3Fts5IndexCharlenToBytelen(tls, pToken, nToken, nChar) if nByte != 0 { @@ -178456,7 +175616,7 @@ func sqlite3Fts5IndexQuery(tls *libc.TLS, p uintptr, pToken uintptr, nToken int3 if sqlite3Fts5BufferSize(tls, (p+52 /* &.rc */), bp /* &buf */, (uint32(nToken+1))) == 0 { var iIdx int32 = 0 // Index to search if nToken != 0 { - libc.Xmemcpy(tls, ((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp + uintptr(1)), pToken, uint64(nToken)) + libc.Xmemcpy(tls, ((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp + 1), pToken, uint64(nToken)) } // Figure out which index to search and set iIdx accordingly. If this @@ -178469,7 +175629,7 @@ func sqlite3Fts5IndexQuery(tls *libc.TLS, p uintptr, pToken uintptr, nToken int3 // evaluate the prefix query using the main FTS index. This is used // for internal sanity checking by the integrity-check in debug // mode only. - if (flags & 0x0001) != 0 { + if (flags & FTS5INDEX_QUERY_PREFIX) != 0 { var nChar int32 = fts5IndexCharlen(tls, pToken, nToken) for iIdx = 1; iIdx <= (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix; iIdx++ { if *(*int32)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FaPrefix + uintptr((iIdx-1))*4)) == nChar { @@ -178481,21 +175641,21 @@ func sqlite3Fts5IndexQuery(tls *libc.TLS, p uintptr, pToken uintptr, nToken int3 if iIdx <= (*Fts5Config)(unsafe.Pointer(pConfig)).FnPrefix { // Straight index lookup var pStruct uintptr = fts5StructureRead(tls, p) - *(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp + uintptr(0))) = (U8('0' + iIdx)) + *(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp)) = (U8('0' + iIdx)) if pStruct != 0 { - fts5MultiIterNew(tls, p, pStruct, (flags | 0x0010), + fts5MultiIterNew(tls, p, pStruct, (flags | FTS5INDEX_QUERY_SKIPEMPTY), pColset, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp, (nToken + 1), -1, 0, bp+16 /* &pRet */) fts5StructureRelease(tls, pStruct) } } else { // Scan multiple terms in the main index - var bDesc int32 = (libc.Bool32((flags & 0x0002) != 0)) - *(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp + uintptr(0))) = U8('0') + var bDesc int32 = (libc.Bool32((flags & FTS5INDEX_QUERY_DESC) != 0)) + *(*U8)(unsafe.Pointer((*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp)) = U8('0') fts5SetupPrefixIter(tls, p, bDesc, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp, (nToken + 1), pColset, bp+16 /* &pRet */) fts5IterSetOutputCb(tls, (p + 52 /* &.rc */), *(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */))) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - var pSeg uintptr = ((*(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */)))).FaFirst+uintptr(1)*4)).FiFirst)*120) + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var pSeg uintptr = ((*(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */)))).FaFirst+1*4)).FiFirst)*120) if (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0 { (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */)) + 56 /* &.xSetOutputs */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pRet */)), pSeg) } @@ -178529,9 +175689,9 @@ func sqlite3Fts5IterNextScan(tls *libc.TLS, pIndexIter uintptr) int32 { /* sqlit var p uintptr = (*Fts5Iter)(unsafe.Pointer(pIter)).FpIndex fts5MultiIterNext(tls, p, pIter, 0, int64(0)) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { - var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+uintptr(1)*4)).FiFirst)*120) - if ((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0) && (int32(*(*U8)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp + uintptr(0)))) != '0') { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { + var pSeg uintptr = ((pIter + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(pIter)).FaFirst+1*4)).FiFirst)*120) + if ((*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf != 0) && (int32(*(*U8)(unsafe.Pointer((*Fts5SegIter)(unsafe.Pointer(pSeg)).Fterm.Fp))) != '0') { fts5DataRelease(tls, (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf) (*Fts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf = uintptr(0) (*Fts5Iter)(unsafe.Pointer(pIter)).Fbase.FbEof = U8(1) @@ -178559,7 +175719,7 @@ func sqlite3Fts5IterTerm(tls *libc.TLS, pIndexIter uintptr, pn uintptr) uintptr var z uintptr = fts5MultiIterTerm(tls, pIndexIter, bp /* &n */) *(*int32)(unsafe.Pointer(pn)) = (*(*int32)(unsafe.Pointer(bp /* n */)) - 1) - return (z + uintptr(1)) + return (z + 1) } // Close an iterator opened by an earlier call to sqlite3Fts5IndexQuery(). @@ -178582,8 +175742,8 @@ func sqlite3Fts5IndexGetAverages(tls *libc.TLS, p uintptr, pnRow uintptr, anSize *(*I64)(unsafe.Pointer(pnRow)) = int64(0) libc.Xmemset(tls, anSize, 0, (uint64(unsafe.Sizeof(I64(0))) * uint64(nCol))) - pData = fts5DataRead(tls, p, int64(1)) - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && ((*Fts5Data)(unsafe.Pointer(pData)).Fnn != 0) { + pData = fts5DataRead(tls, p, FTS5_AVERAGES_ROWID) + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && ((*Fts5Data)(unsafe.Pointer(pData)).Fnn != 0) { var i int32 = 0 var iCol int32 i = i + (int32(sqlite3Fts5GetVarint(tls, ((*Fts5Data)(unsafe.Pointer(pData)).Fp + uintptr(i)), pnRow))) @@ -178600,7 +175760,7 @@ func sqlite3Fts5IndexGetAverages(tls *libc.TLS, p uintptr, pnRow uintptr, anSize // supplied as the second argument. func sqlite3Fts5IndexSetAverages(tls *libc.TLS, p uintptr, pData uintptr, nData int32) int32 { /* sqlite3.c:221923:12: */ - fts5DataWrite(tls, p, int64(1), pData, nData) + fts5DataWrite(tls, p, FTS5_AVERAGES_ROWID, pData, nData) return fts5IndexReturn(tls, p) } @@ -178628,8 +175788,8 @@ func sqlite3Fts5IndexSetCookie(tls *libc.TLS, p uintptr, iNew int32) int32 { /* sqlite3Fts5Put32(tls, bp /* &aCookie[0] */, iNew) rc = Xsqlite3_blob_open(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Index)(unsafe.Pointer(p)).FzDataTbl, - ts+37701 /* "block" */, int64(10), 1, bp+8 /* &pBlob */) - if rc == 0 { + ts+37701 /* "block" */, FTS5_STRUCTURE_ROWID, 1, bp+8 /* &pBlob */) + if rc == SQLITE_OK { Xsqlite3_blob_write(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pBlob */)), bp /* &aCookie[0] */, 4, 0) rc = Xsqlite3_blob_close(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pBlob */))) } @@ -178676,14 +175836,14 @@ func fts5IndexIntegrityCheckEmpty(tls *libc.TLS, p uintptr, pSeg uintptr, iFirst // Now check that the iter.nEmpty leaves following the current leaf // (a) exist and (b) contain no terms. - for i = iFirst; ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (i <= iLast); i++ { - var pLeaf uintptr = fts5DataRead(tls, p, (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(i)))) + for i = iFirst; ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (i <= iLast); i++ { + var pLeaf uintptr = fts5DataRead(tls, p, (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(i)))) if pLeaf != 0 { if !((*Fts5Data)(unsafe.Pointer((pLeaf))).FszLeaf >= (*Fts5Data)(unsafe.Pointer((pLeaf))).Fnn) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } if (i >= iNoRowid) && (0 != (int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp)))) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } } fts5DataRelease(tls, pLeaf) @@ -178701,7 +175861,7 @@ func fts5IntegrityCheckPgidx(tls *libc.TLS, p uintptr, pLeaf uintptr) { /* sqlit *(*Fts5Buffer)(unsafe.Pointer(bp + 32 /* buf2 */)) = Fts5Buffer{} ii = (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf - for (ii < (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) { + for (ii < (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn) && ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) { var res int32 var iOff int32 // var nIncr int32 at bp, 4 @@ -178711,13 +175871,13 @@ func fts5IntegrityCheckPgidx(tls *libc.TLS, p uintptr, pLeaf uintptr) { /* sqlit iOff = iTermOff if iOff >= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else if iTermOff == *(*int32)(unsafe.Pointer(bp /* nIncr */)) { // var nByte int32 at bp+4, 4 iOff = iOff + (sqlite3Fts5GetVarint32(tls, ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iOff)), bp+4 /* &nByte */)) if (iOff + *(*int32)(unsafe.Pointer(bp + 4 /* nByte */))) > (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { sqlite3Fts5BufferSet(tls, (p + 52 /* &.rc */), bp+8 /* &buf1 */, *(*int32)(unsafe.Pointer(bp + 4 /* nByte */)), ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iOff))) } @@ -178729,16 +175889,16 @@ func fts5IntegrityCheckPgidx(tls *libc.TLS, p uintptr, pLeaf uintptr) { /* sqlit iOff = iOff + (sqlite3Fts5GetVarint32(tls, ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iOff)), bp+24 /* &nKeep */)) iOff = iOff + (sqlite3Fts5GetVarint32(tls, ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iOff)), bp+28 /* &nByte */)) if (*(*int32)(unsafe.Pointer(bp + 24 /* nKeep */)) > (*Fts5Buffer)(unsafe.Pointer(bp+8 /* &buf1 */)).Fn) || ((iOff + *(*int32)(unsafe.Pointer(bp + 28 /* nByte */))) > (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { (*Fts5Buffer)(unsafe.Pointer(bp + 8 /* &buf1 */)).Fn = *(*int32)(unsafe.Pointer(bp + 24 /* nKeep */)) sqlite3Fts5BufferAppendBlob(tls, (p + 52 /* &.rc */), bp+8 /* &buf1 */, uint32(*(*int32)(unsafe.Pointer(bp + 28 /* nByte */))), ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iOff))) } - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { res = fts5BufferCompare(tls, bp+8 /* &buf1 */, bp+32 /* &buf2 */) if res <= 0 { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } } } @@ -178769,7 +175929,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid))) // Iterate through the b-tree hierarchy. - for ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */)))) { + for ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */)))) { var iRow I64 // Rowid for this leaf var pLeaf uintptr // Data for this leaf @@ -178783,7 +175943,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* if iIdxLeaf < (*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst { continue } - iRow = (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(iIdxLeaf))) + iRow = (((((I64((*Fts5StructureSegment)(unsafe.Pointer(pSeg)).FiSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(iIdxLeaf))) pLeaf = fts5LeafRead(tls, p, iRow) if pLeaf == uintptr(0) { break @@ -178794,7 +175954,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* // is also a rowid pointer within the leaf page header, it points to a // location before the term. if (*Fts5Data)(unsafe.Pointer(pLeaf)).Fnn <= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { var iOff int32 // Offset of first term on leaf var iRowidOff int32 // Offset of first rowid on leaf @@ -178805,7 +175965,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* iOff = fts5LeafFirstTermOff(tls, pLeaf) iRowidOff = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp)) if (iRowidOff >= iOff) || (iOff >= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { iOff = iOff + (sqlite3Fts5GetVarint32(tls, ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iOff)), bp+32 /* &nTerm */)) res = func() int32 { @@ -178828,7 +175988,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* res = (*(*int32)(unsafe.Pointer(bp + 32 /* nTerm */)) - nIdxTerm) } if res < 0 { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } } @@ -178859,11 +176019,11 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* // Check any rowid-less pages that occur before the current leaf. for iPg = (iPrevLeaf + 1); iPg < fts5DlidxIterPgno(tls, pDlidx); iPg++ { - iKey = (((((I64(iSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(iPg))) + iKey = (((((I64(iSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(iPg))) pLeaf = fts5DataRead(tls, p, iKey) if pLeaf != 0 { if (int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp))) != 0 { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } fts5DataRelease(tls, pLeaf) } @@ -178872,7 +176032,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* // Check that the leaf page indicated by the iterator really does // contain the rowid suggested by the same. - iKey = (((((I64(iSegid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(iPrevLeaf))) + iKey = (((((I64(iSegid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(iPrevLeaf))) pLeaf = fts5DataRead(tls, p, iKey) if pLeaf != 0 { // var iRowid I64 at bp+40, 8 @@ -178880,11 +176040,11 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* var iRowidOff int32 = int32(fts5GetU16(tls, (*Fts5Data)(unsafe.Pointer(pLeaf)).Fp)) if iRowidOff >= (*Fts5Data)(unsafe.Pointer(pLeaf)).FszLeaf { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } else { sqlite3Fts5GetVarint(tls, ((*Fts5Data)(unsafe.Pointer(pLeaf)).Fp + uintptr(iRowidOff)), bp+40 /* &iRowid */) if *(*I64)(unsafe.Pointer(bp + 40 /* iRowid */)) != fts5DlidxIterRowid(tls, pDlidx) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } } fts5DataRelease(tls, pLeaf) @@ -178903,7 +176063,7 @@ func fts5IndexIntegrityCheckSegment(tls *libc.TLS, p uintptr, pSeg uintptr) { /* } rc2 = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */))) - if (*Fts5Index)(unsafe.Pointer(p)).Frc == 0 { + if (*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK { (*Fts5Index)(unsafe.Pointer(p)).Frc = rc2 } @@ -178929,7 +176089,7 @@ func sqlite3Fts5IndexIntegrityCheck(tls *libc.TLS, p uintptr, cksum U64) int32 { // Used to iterate through entire index var pStruct uintptr // Index structure - var flags int32 = 0x0020 + var flags int32 = FTS5INDEX_QUERY_NOOUTPUT // Load the FTS index structure pStruct = fts5StructureRead(tls, p) @@ -178968,13 +176128,13 @@ func sqlite3Fts5IndexIntegrityCheck(tls *libc.TLS, p uintptr, cksum U64) int32 { // If this is a new term, query for it. Update cksum3 with the results. - if eDetail == 1 { + if eDetail == FTS5_DETAIL_NONE { if 0 == fts5MultiIterIsEmpty(tls, p, *(*uintptr)(unsafe.Pointer(bp /* pIter */))) { cksum2 = cksum2 ^ (sqlite3Fts5IndexEntryCksum(tls, iRowid, 0, 0, -1, z, *(*int32)(unsafe.Pointer(bp + 8 /* n */)))) } } else { (*Fts5Buffer)(unsafe.Pointer(bp + 16 /* &poslist */)).Fn = 0 - fts5SegiterPoslist(tls, p, ((*(*uintptr)(unsafe.Pointer(bp /* pIter */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pIter */)))).FaFirst+uintptr(1)*4)).FiFirst)*120), uintptr(0), bp+16 /* &poslist */) + fts5SegiterPoslist(tls, p, ((*(*uintptr)(unsafe.Pointer(bp /* pIter */)) + 96 /* &.aSeg */) + uintptr((*Fts5CResult)(unsafe.Pointer((*Fts5Iter)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pIter */)))).FaFirst+1*4)).FiFirst)*120), uintptr(0), bp+16 /* &poslist */) for 0 == sqlite3Fts5PoslistNext64(tls, (*Fts5Buffer)(unsafe.Pointer(bp+16 /* &poslist */)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp+16 /* &poslist */)).Fn, bp+32 /* &iOff */, bp+40 /* &iPos */) { var iCol int32 = (int32(*(*I64)(unsafe.Pointer(bp + 40 /* iPos */)) >> 32)) var iTokOff int32 = (int32(*(*I64)(unsafe.Pointer(bp + 40 /* iPos */)) & int64(0x7FFFFFFF))) @@ -178984,8 +176144,8 @@ func sqlite3Fts5IndexIntegrityCheck(tls *libc.TLS, p uintptr, cksum U64) int32 { } fts5MultiIterFree(tls, *(*uintptr)(unsafe.Pointer(bp /* pIter */))) - if ((*Fts5Index)(unsafe.Pointer(p)).Frc == 0) && (cksum != cksum2) { - (*Fts5Index)(unsafe.Pointer(p)).Frc = (11 | (int32(1) << 8)) + if ((*Fts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK) && (cksum != cksum2) { + (*Fts5Index)(unsafe.Pointer(p)).Frc = (SQLITE_CORRUPT | (int32(1) << 8)) } fts5StructureRelease(tls, pStruct) @@ -179002,16 +176162,16 @@ func sqlite3Fts5IndexIntegrityCheck(tls *libc.TLS, p uintptr, cksum U64) int32 { // Decode a segment-data rowid from the %_data table. This function is // the opposite of macro FTS5_SEGMENT_ROWID(). func fts5DecodeRowid(tls *libc.TLS, iRowid I64, piSegid uintptr, pbDlidx uintptr, piHeight uintptr, piPgno uintptr) { /* sqlite3.c:222506:13: */ - *(*int32)(unsafe.Pointer(piPgno)) = (int32(iRowid & ((I64(int64(1)) << 31) - int64(1)))) - iRowid >>= 31 + *(*int32)(unsafe.Pointer(piPgno)) = (int32(iRowid & ((I64(int64(1)) << FTS5_DATA_PAGE_B) - int64(1)))) + iRowid >>= FTS5_DATA_PAGE_B - *(*int32)(unsafe.Pointer(piHeight)) = (int32(iRowid & ((I64(int64(1)) << 5) - int64(1)))) - iRowid >>= 5 + *(*int32)(unsafe.Pointer(piHeight)) = (int32(iRowid & ((I64(int64(1)) << FTS5_DATA_HEIGHT_B) - int64(1)))) + iRowid >>= FTS5_DATA_HEIGHT_B *(*int32)(unsafe.Pointer(pbDlidx)) = (int32(iRowid & int64(0x0001))) - iRowid >>= 1 + iRowid >>= FTS5_DATA_DLI_B - *(*int32)(unsafe.Pointer(piSegid)) = (int32(iRowid & ((I64(int64(1)) << 16) - int64(1)))) + *(*int32)(unsafe.Pointer(piSegid)) = (int32(iRowid & ((I64(int64(1)) << FTS5_DATA_ID_B) - int64(1)))) } func fts5DebugRowid(tls *libc.TLS, pRc uintptr, pBuf uintptr, iKey I64) { /* sqlite3.c:222525:13: */ @@ -179029,7 +176189,7 @@ func fts5DebugRowid(tls *libc.TLS, pRc uintptr, pBuf uintptr, iKey I64) { /* sql fts5DecodeRowid(tls, iKey, bp+32 /* &iSegid */, bp+36 /* &bDlidx */, bp+40 /* &iHeight */, bp+44 /* &iPgno */) if *(*int32)(unsafe.Pointer(bp + 32 /* iSegid */)) == 0 { - if iKey == int64(1) { + if iKey == FTS5_AVERAGES_ROWID { sqlite3Fts5BufferAppendPrintf(tls, pRc, pBuf, ts+38184 /* "{averages} " */, 0) } else { sqlite3Fts5BufferAppendPrintf(tls, pRc, pBuf, ts+38196 /* "{structure}" */, 0) @@ -179078,7 +176238,7 @@ func fts5DecodeStructure(tls *libc.TLS, pRc uintptr, pBuf uintptr, pBlob uintptr *(*uintptr)(unsafe.Pointer(bp /* p */)) = uintptr(0) // Decoded structure object rc = fts5StructureDecode(tls, pBlob, nBlob, uintptr(0), bp /* &p */) - if rc != 0 { + if rc != SQLITE_OK { *(*int32)(unsafe.Pointer(pRc)) = rc return } @@ -179268,20 +176428,20 @@ func fts5DecodeFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) var iOff1 int32 var nDoclist int32 a = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_OK nSpace = int64(0) eDetailNone = (libc.Bool32(Xsqlite3_user_data(tls, pCtx) != uintptr(0))) _ = nArg libc.Xmemset(tls, bp+48 /* &s */, 0, uint64(unsafe.Sizeof(Fts5Buffer{}))) - iRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + iRowid = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal))) // Make a copy of the second argument (a blob) in aBlob[]. The aBlob[] // copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents // buffer overreads even if the record is corrupt. - n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - aBlob = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - nSpace = (Sqlite3_int64(n + 8)) + n = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + aBlob = Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + nSpace = (Sqlite3_int64(n + FTS5_DATA_ZERO_PADDING)) a = sqlite3Fts5MallocZero(tls, bp+64 /* &rc */, nSpace) if !(a == uintptr(0)) { goto __1 @@ -179329,7 +176489,7 @@ __3: if !(*(*int32)(unsafe.Pointer(bp + 68 /* iSegid */)) == 0) { goto __8 } - if !(iRowid == int64(1)) { + if !(iRowid == FTS5_AVERAGES_ROWID) { goto __10 } fts5DecodeAverages(tls, bp+64 /* &rc */, bp+48 /* &s */, a, n) @@ -179343,7 +176503,7 @@ __8: if !(eDetailNone != 0) { goto __12 } - iPgidxOff = libc.AssignInt32(&szLeaf, int32(fts5GetU16(tls, (a+uintptr(2))))) + iPgidxOff = libc.AssignInt32(&szLeaf, int32(fts5GetU16(tls, (a+2)))) *(*int32)(unsafe.Pointer(bp + 164 /* nKeep */)) = 0 libc.Xmemset(tls, bp+136 /* &term */, 0, uint64(unsafe.Sizeof(Fts5Buffer{}))) @@ -179358,7 +176518,7 @@ __14: *(*int32)(unsafe.Pointer(bp + 152 /* iTermOff */)) = szLeaf __15: ; - fts5DecodeRowidList(tls, bp+64 /* &rc */, bp+48 /* &s */, (a + uintptr(4)), (*(*int32)(unsafe.Pointer(bp + 152 /* iTermOff */)) - 4)) + fts5DecodeRowidList(tls, bp+64 /* &rc */, bp+48 /* &s */, (a + 4), (*(*int32)(unsafe.Pointer(bp + 152 /* iTermOff */)) - 4)) iOff = *(*int32)(unsafe.Pointer(bp + 152 /* iTermOff */)) __16: @@ -179414,8 +176574,8 @@ __12: goto decode_out goto __22 __21: - iRowidOff = int32(fts5GetU16(tls, (a + uintptr(0)))) - iPgidxOff1 = libc.AssignInt32(&szLeaf1, int32(fts5GetU16(tls, (a+uintptr(2))))) + iRowidOff = int32(fts5GetU16(tls, (a))) + iPgidxOff1 = libc.AssignInt32(&szLeaf1, int32(fts5GetU16(tls, (a+2)))) if !(iPgidxOff1 < n) { goto __23 } @@ -179425,7 +176585,7 @@ __23: if !(iPgidxOff1 > n) { goto __25 } - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) goto decode_out __25: ; @@ -179455,11 +176615,11 @@ __27: if !(iOff1 > n) { goto __30 } - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) goto decode_out __30: ; - fts5DecodePoslist(tls, bp+64 /* &rc */, bp+48 /* &s */, (a + uintptr(4)), (iOff1 - 4)) + fts5DecodePoslist(tls, bp+64 /* &rc */, bp+48 /* &s */, (a + 4), (iOff1 - 4)) // Decode any more doclist data that appears on the page before the // first term. @@ -179472,14 +176632,14 @@ __30: if !((nDoclist + iOff1) > n) { goto __31 } - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) goto decode_out __31: ; fts5DecodeDoclist(tls, bp+64 /* &rc */, bp+48 /* &s */, (a + uintptr(iOff1)), nDoclist) __32: - if !((iPgidxOff1 < n) && (*(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 0)) { + if !((iPgidxOff1 < n) && (*(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK)) { goto __33 } bFirst = (libc.Bool32(iPgidxOff1 == szLeaf1)) @@ -179501,7 +176661,7 @@ __35: if !(iEnd > szLeaf1) { goto __36 } - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) goto __33 __36: ; @@ -179513,7 +176673,7 @@ __36: if !(*(*int32)(unsafe.Pointer(bp + 188 /* nByte */)) > (*Fts5Buffer)(unsafe.Pointer(bp+168 /* &term1 */)).Fn) { goto __38 } - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) goto __33 __38: ; @@ -179524,7 +176684,7 @@ __37: if !((iOff1 + *(*int32)(unsafe.Pointer(bp + 188 /* nByte */))) > n) { goto __39 } - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) goto __33 __39: ; @@ -179548,7 +176708,7 @@ __4: decode_out: Xsqlite3_free(tls, a) - if !(*(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 0) { + if !(*(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK) { goto __40 } Xsqlite3_result_text(tls, pCtx, (*Fts5Buffer)(unsafe.Pointer(bp+48 /* &s */)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp+48 /* &s */)).Fn, libc.UintptrFromInt32(-1)) @@ -179566,7 +176726,7 @@ func fts5RowidFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) { if nArg == 0 { Xsqlite3_result_error(tls, pCtx, ts+38355 /* "should be: fts5_..." */, -1) } else { - zArg = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) + zArg = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))) if 0 == Xsqlite3_stricmp(tls, zArg, ts+38392 /* "segment" */) { var iRowid I64 var segid int32 @@ -179575,9 +176735,9 @@ func fts5RowidFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) { Xsqlite3_result_error(tls, pCtx, ts+38400 /* "should be: fts5_..." */, -1) } else { - segid = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - pgno = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(2)*8))) - iRowid = (((((I64(segid)) << ((31 + 5) + 1)) + (I64((int64(0))) << (31 + 5))) + (I64((int64(0))) << (31))) + (I64(pgno))) + segid = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + pgno = Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + 2*8))) + iRowid = (((((I64(segid)) << ((FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B) + FTS5_DATA_DLI_B)) + (I64((int64(0))) << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B))) + (I64((int64(0))) << (FTS5_DATA_PAGE_B))) + (I64(pgno))) Xsqlite3_result_int64(tls, pCtx, iRowid) } } else { @@ -179595,21 +176755,21 @@ func fts5RowidFunction(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) { // SQLite error code is returned instead. func sqlite3Fts5IndexInit(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:222955:12: */ var rc int32 = Xsqlite3_create_function(tls, - db, ts+38491 /* "fts5_decode" */, 2, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + db, ts+38491 /* "fts5_decode" */, 2, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{fts5DecodeFunction})), uintptr(0), uintptr(0)) - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_function(tls, db, ts+38503 /* "fts5_decode_none" */, 2, - 1, db, *(*uintptr)(unsafe.Pointer(&struct { + SQLITE_UTF8, db, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{fts5DecodeFunction})), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_function(tls, - db, ts+38520 /* "fts5_rowid" */, -1, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + db, ts+38520 /* "fts5_rowid" */, -1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{fts5RowidFunction})), uintptr(0), uintptr(0)) } @@ -179763,7 +176923,7 @@ type Fts5MatchPhrase = struct { // Return true if pTab is a contentless table. func fts5IsContentless(tls *libc.TLS, pTab uintptr) int32 { /* sqlite3.c:223290:12: */ - return (libc.Bool32((*Fts5Config)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FeContent == 1)) + return (libc.Bool32((*Fts5Config)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FeContent == FTS5_CONTENT_NONE)) } // Delete a virtual table handle allocated by fts5InitVtab(). @@ -179779,14 +176939,14 @@ func fts5FreeVtab(tls *libc.TLS, pTab uintptr) { /* sqlite3.c:223297:13: */ // The xDisconnect() virtual table method. func fts5DisconnectMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:223309:12: */ fts5FreeVtab(tls, pVtab) - return 0 + return SQLITE_OK } // The xDestroy() virtual table method. func fts5DestroyMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:223317:12: */ var pTab uintptr = pVtab var rc int32 = sqlite3Fts5DropAll(tls, (*Fts5Table)(unsafe.Pointer(pTab)).FpConfig) - if rc == 0 { + if rc == SQLITE_OK { fts5FreeVtab(tls, pVtab) } return rc @@ -179807,39 +176967,39 @@ func fts5InitVtab(tls *libc.TLS, bCreate int32, db uintptr, pAux uintptr, argc i var pGlobal uintptr = pAux var azConfig uintptr = argv - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 // Return code + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK // Return code *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)) = uintptr(0) // Results of parsing argc/argv var pTab uintptr = uintptr(0) // New virtual table object // Allocate the new vtab object and parse the configuration pTab = sqlite3Fts5MallocZero(tls, bp /* &rc */, int64(unsafe.Sizeof(Fts5FullTable{}))) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3Fts5ConfigParse(tls, pGlobal, db, argc, azConfig, bp+8 /* &pConfig */, pzErr) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig = *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)) (*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal = pGlobal } // Open the index sub-system - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3Fts5IndexOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)), bCreate, (pTab /* &.p */ + 32 /* &.pIndex */), pzErr) } // Open the storage sub-system - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3Fts5StorageOpen(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)), (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex, bCreate, (pTab + 40 /* &.pStorage */), pzErr) } // Call sqlite3_declare_vtab() - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3Fts5ConfigDeclareVtab(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */))) } // Load the initial configuration - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { (*Fts5Config)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)))).FpzErrmsg = pzErr *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3Fts5IndexLoadConfig(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex) @@ -179847,7 +177007,7 @@ func fts5InitVtab(tls *libc.TLS, bCreate int32, db uintptr, pAux uintptr, argc i (*Fts5Config)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* pConfig */)))).FpzErrmsg = uintptr(0) } - if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { fts5FreeVtab(tls, pTab) pTab = uintptr(0) } else if bCreate != 0 { @@ -179874,7 +177034,7 @@ func fts5CreateMethod(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv // support index-info flags. In that case this function is a no-op. func fts5SetUniqueFlag(tls *libc.TLS, pIdxInfo uintptr) { /* sqlite3.c:223439:13: */ { - *(*int32)(unsafe.Pointer(pIdxInfo + 80 /* &.idxFlags */)) |= (1) + *(*int32)(unsafe.Pointer(pIdxInfo + 80 /* &.idxFlags */)) |= (SQLITE_INDEX_SCAN_UNIQUE) } } @@ -179958,12 +177118,12 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* if (*Fts5Config)(unsafe.Pointer(pConfig)).FbLock != 0 { (*Fts5Table)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+38531 /* "recursively defi..." */, 0) - return 1 + return SQLITE_ERROR } idxStr = Xsqlite3_malloc(tls, (((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint * 6) + 1)) if idxStr == uintptr(0) { - return 7 + return SQLITE_NOMEM } (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxStr = idxStr (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FneedToFreeIdxStr = 1 @@ -179971,8 +177131,8 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* for i = 0; i < (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint; i++ { var p uintptr = ((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12) var iCol int32 = (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn - if (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 64) || - ((int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2) && (iCol >= nCol)) { + if (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) || + ((int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) && (iCol >= nCol)) { // A MATCH operator or equivalent if (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) == 0) || (iCol < 0) { // As there exists an unusable MATCH constraint this is an @@ -179980,7 +177140,7 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = 1e50 *(*int8)(unsafe.Pointer(idxStr + uintptr(iIdxStr))) = int8(0) - return 0 + return SQLITE_OK } else { if iCol == (nCol + 1) { if bSeenRank != 0 { @@ -180001,7 +177161,7 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) } } else if ((((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) && (bSeenEq == 0)) && - (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2)) && (iCol < 0) { + (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ)) && (iCol < 0) { *(*int8)(unsafe.Pointer(idxStr + uintptr(libc.PostIncInt32(&iIdxStr, 1)))) = int8('=') bSeenEq = 1 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&iCons, 1) @@ -180013,14 +177173,14 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* var p uintptr = ((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint + uintptr(i)*12) if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn < 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) { var op int32 = int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) - if (op == 16) || (op == 8) { + if (op == SQLITE_INDEX_CONSTRAINT_LT) || (op == SQLITE_INDEX_CONSTRAINT_LE) { if bSeenLt != 0 { continue } *(*int8)(unsafe.Pointer(idxStr + uintptr(libc.PostIncInt32(&iIdxStr, 1)))) = int8('<') (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&iCons, 1) bSeenLt = 1 - } else if (op == 4) || (op == 32) { + } else if (op == SQLITE_INDEX_CONSTRAINT_GT) || (op == SQLITE_INDEX_CONSTRAINT_GE) { if bSeenGt != 0 { continue } @@ -180035,16 +177195,16 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* // Set idxFlags flags for the ORDER BY clause if (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnOrderBy == 1 { - var iSort int32 = (*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy + uintptr(0)*8)).FiColumn + var iSort int32 = (*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy)).FiColumn if (iSort == ((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol + 1)) && (bSeenMatch != 0) { - idxFlags = idxFlags | (0x0020) + idxFlags = idxFlags | (FTS5_BI_ORDER_RANK) } else if iSort == -1 { - idxFlags = idxFlags | (0x0040) + idxFlags = idxFlags | (FTS5_BI_ORDER_ROWID) } - if ((idxFlags) & (0x0020 | 0x0040)) != 0 { + if ((idxFlags) & (FTS5_BI_ORDER_RANK | FTS5_BI_ORDER_ROWID)) != 0 { (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).ForderByConsumed = 1 - if (*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy+uintptr(0)*8)).Fdesc != 0 { - idxFlags = idxFlags | (0x0080) + if (*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy)).Fdesc != 0 { + idxFlags = idxFlags | (FTS5_BI_ORDER_DESC) } } } @@ -180084,14 +177244,14 @@ func fts5BestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* } (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = idxFlags - return 0 + return SQLITE_OK } func fts5NewTransaction(tls *libc.TLS, pTab uintptr) int32 { /* sqlite3.c:223640:12: */ var pCsr uintptr for pCsr = (*Fts5Global)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal)).FpCsr; pCsr != 0; pCsr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpNext { if (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab == pTab { - return 0 + return SQLITE_OK } } return sqlite3Fts5StorageReset(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage) @@ -180106,18 +177266,18 @@ func fts5OpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 { /* sqli var rc int32 // Return code rc = fts5NewTransaction(tls, pTab) - if rc == 0 { + if rc == SQLITE_OK { nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5Cursor{})) + (uint64((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) * uint64(unsafe.Sizeof(int32(0)))))) pCsr = Xsqlite3_malloc64(tls, uint64(nByte)) if pCsr != 0 { var pGlobal uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal libc.Xmemset(tls, pCsr, 0, Size_t(nByte)) - (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize = (pCsr + uintptr(1)*184) + (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize = (pCsr + 1*184) (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpNext = (*Fts5Global)(unsafe.Pointer(pGlobal)).FpCsr (*Fts5Global)(unsafe.Pointer(pGlobal)).FpCsr = pCsr (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId = libc.PreIncInt64(&(*Fts5Global)(unsafe.Pointer(pGlobal)).FiNextId, 1) } else { - rc = 7 + rc = SQLITE_NOMEM } } *(*uintptr)(unsafe.Pointer(ppCsr)) = pCsr @@ -180125,20 +177285,20 @@ func fts5OpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 { /* sqli } func fts5StmtType(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:223677:12: */ - if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 5 { + if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SCAN { if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FbDesc != 0 { - return 1 + return FTS5_STMT_SCAN_DESC } - return 0 + return FTS5_STMT_SCAN_ASC } - return 2 + return FTS5_STMT_LOOKUP } // This function is called after the cursor passed as the only argument // is moved to point at a different row. It clears all cached data // specific to the previous row stored by the cursor object. func fts5CsrNewrow(tls *libc.TLS, pCsr uintptr) { /* sqlite3.c:223689:13: */ - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (((0x02 | 0x04) | 0x08) | 0x40) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (((FTS5CSR_REQUIRE_CONTENT | FTS5CSR_REQUIRE_DOCSIZE) | FTS5CSR_REQUIRE_INST) | FTS5CSR_REQUIRE_POSLIST) } func fts5FreeCursorComponents(tls *libc.TLS, pCsr uintptr) { /* sqlite3.c:223698:13: */ @@ -180158,7 +177318,7 @@ func fts5FreeCursorComponents(tls *libc.TLS, pCsr uintptr) { /* sqlite3.c:223698 Xsqlite3_free(tls, pSorter) } - if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan != 2 { + if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan != FTS5_PLAN_SOURCE { sqlite3Fts5ExprFree(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) } @@ -180173,7 +177333,7 @@ func fts5FreeCursorComponents(tls *libc.TLS, pCsr uintptr) { /* sqlite3.c:223698 Xsqlite3_finalize(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRankArgStmt) Xsqlite3_free(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg) - if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x10)) != 0 { + if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_FREE_ZRANK)) != 0 { Xsqlite3_free(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRank) Xsqlite3_free(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs) } @@ -180198,7 +177358,7 @@ func fts5CloseMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:223742 Xsqlite3_free(tls, pCsr) } - return 0 + return SQLITE_OK } func fts5SorterNext(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:223758:12: */ @@ -180209,16 +177369,16 @@ func fts5SorterNext(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:223758:12: var rc int32 rc = Xsqlite3_step(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt) - if rc == 101 { - rc = 0 - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x01) - } else if rc == 100 { + if rc == SQLITE_DONE { + rc = SQLITE_OK + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_EOF) + } else if rc == SQLITE_ROW { var a uintptr var aBlob uintptr var nBlob int32 var i int32 var iOff int32 = 0 - rc = 0 + rc = SQLITE_OK (*Fts5Sorter)(unsafe.Pointer(pSorter)).FiRowid = Xsqlite3_column_int64(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt, 0) nBlob = Xsqlite3_column_bytes(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt, 1) @@ -180248,9 +177408,9 @@ func fts5SorterNext(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:223758:12: func fts5TripCursors(tls *libc.TLS, pTab uintptr) { /* sqlite3.c:223801:13: */ var pCsr uintptr for pCsr = (*Fts5Global)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpGlobal)).FpCsr; pCsr != 0; pCsr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpNext { - if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 1) && + if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_MATCH) && ((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab == pTab) { - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x20) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_REQUIRE_RESEEK) } } } @@ -180266,22 +177426,22 @@ func fts5TripCursors(tls *libc.TLS, pTab uintptr) { /* sqlite3.c:223801:13: */ // Return SQLITE_OK if successful or if no reseek was required, or an // error code if an error occurred. func fts5CursorReseek(tls *libc.TLS, pCsr uintptr, pbSkip uintptr) int32 { /* sqlite3.c:223824:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK - if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x20)) != 0 { + if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_REQUIRE_RESEEK)) != 0 { var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab var bDesc int32 = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FbDesc var iRowid I64 = sqlite3Fts5ExprRowid(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) rc = sqlite3Fts5ExprFirst(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex, iRowid, bDesc) - if (rc == 0) && (iRowid != sqlite3Fts5ExprRowid(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)) { + if (rc == SQLITE_OK) && (iRowid != sqlite3Fts5ExprRowid(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)) { *(*int32)(unsafe.Pointer(pbSkip)) = 1 } - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (^libc.Int32(0x20)) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (libc.CplInt32(FTS5CSR_REQUIRE_RESEEK)) fts5CsrNewrow(tls, pCsr) if sqlite3Fts5ExprEof(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) != 0 { - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x01) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_EOF) *(*int32)(unsafe.Pointer(pbSkip)) = 1 } } @@ -180311,16 +177471,16 @@ func fts5NextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:223856: fts5CsrNewrow(tls, pCsr) } else { switch (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan { - case 3: + case FTS5_PLAN_SPECIAL: { - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x01) - rc = 0 + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_EOF) + rc = SQLITE_OK break } fallthrough - case 4: + case FTS5_PLAN_SORTED_MATCH: { rc = fts5SorterNext(tls, pCsr) break @@ -180334,15 +177494,15 @@ func fts5NextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:223856: (*Fts5Config)(unsafe.Pointer(pConfig)).FbLock++ rc = Xsqlite3_step(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) (*Fts5Config)(unsafe.Pointer(pConfig)).FbLock-- - if rc != 100 { - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x01) + if rc != SQLITE_ROW { + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_EOF) rc = Xsqlite3_reset(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) - if rc != 0 { + if rc != SQLITE_OK { (*Sqlite3_vtab)(unsafe.Pointer((*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp, Xsqlite3_errmsg(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb))) } } else { - rc = 0 + rc = SQLITE_OK } break @@ -180366,11 +177526,11 @@ func fts5PrepareStatement(tls *libc.TLS, ppStmt uintptr, pConfig uintptr, zFmt u ap = va zSql = Xsqlite3_vmprintf(tls, zFmt, ap) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_prepare_v3(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -1, - uint32(0x01), bp+8 /* &pRet */, uintptr(0)) - if rc != 0 { + SQLITE_PREPARE_PERSISTENT, bp+8 /* &pRet */, uintptr(0)) + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp, Xsqlite3_errmsg(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb))) } Xsqlite3_free(tls, zSql) @@ -180397,7 +177557,7 @@ func fts5CursorFirstSorted(tls *libc.TLS, pTab uintptr, pCsr uintptr, bDesc int3 nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5Sorter{})) + (uint64(unsafe.Sizeof(int32(0))) * (uint64(nPhrase - 1))))) pSorter = Xsqlite3_malloc64(tls, uint64(nByte)) if pSorter == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pSorter, 0, Size_t(nByte)) (*Fts5Sorter)(unsafe.Pointer(pSorter)).FnIdx = nPhrase @@ -180432,14 +177592,14 @@ func fts5CursorFirstSorted(tls *libc.TLS, pTab uintptr, pCsr uintptr, bDesc int3 }())) (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter = pSorter - if rc == 0 { + if rc == SQLITE_OK { (*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr = pCsr rc = fts5SorterNext(tls, pCsr) (*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr = uintptr(0) } - if rc != 0 { + if rc != SQLITE_OK { Xsqlite3_finalize(tls, (*Fts5Sorter)(unsafe.Pointer(pSorter)).FpStmt) Xsqlite3_free(tls, pSorter) (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter = uintptr(0) @@ -180453,7 +177613,7 @@ func fts5CursorFirst(tls *libc.TLS, pTab uintptr, pCsr uintptr, bDesc int32) int var pExpr uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr rc = sqlite3Fts5ExprFirst(tls, pExpr, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid, bDesc) if sqlite3Fts5ExprEof(tls, pExpr) != 0 { - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x01) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_EOF) } fts5CsrNewrow(tls, pCsr) return rc @@ -180467,17 +177627,17 @@ func fts5SpecialMatch(tls *libc.TLS, pTab uintptr, pCsr uintptr, zQuery uintptr) bp := tls.Alloc(16) defer tls.Free(16) - var rc int32 = 0 // Return code - var z uintptr = zQuery // Special query text - var n int32 // Number of bytes in text at z + var rc int32 = SQLITE_OK // Return code + var z uintptr = zQuery // Special query text + var n int32 // Number of bytes in text at z - for int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == ' ' { + for int32(*(*int8)(unsafe.Pointer(z))) == ' ' { z++ } for n = 0; (*(*int8)(unsafe.Pointer(z + uintptr(n))) != 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr(n)))) != ' '); n++ { } - (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = 3 + (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = FTS5_PLAN_SPECIAL if (n == 5) && (0 == Xsqlite3_strnicmp(tls, ts+38634 /* "reads" */, z, n)) { (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial = I64(sqlite3Fts5IndexReads(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)) @@ -180486,7 +177646,7 @@ func fts5SpecialMatch(tls *libc.TLS, pTab uintptr, pCsr uintptr, zQuery uintptr) } else { // An unrecognized directive. Return an error message. (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+38640 /* "unknown special ..." */, libc.VaList(bp, n, z)) - rc = 1 + rc = SQLITE_ERROR } return rc @@ -180514,7 +177674,7 @@ func fts5FindRankFunction(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:2240 var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK var pAux uintptr = uintptr(0) var zRank uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRank var zRankArgs uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs @@ -180524,16 +177684,16 @@ func fts5FindRankFunction(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:2240 if zSql != 0 { *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */)) = uintptr(0) *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = Xsqlite3_prepare_v3(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -1, - uint32(0x01), bp+24 /* &pStmt */, uintptr(0)) + SQLITE_PREPARE_PERSISTENT, bp+24 /* &pStmt */, uintptr(0)) Xsqlite3_free(tls, zSql) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */))) { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */))) { var nByte Sqlite3_int64 (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg = Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */))) nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(uintptr(0))) * uint64((*Fts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg))) (*Fts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg = sqlite3Fts5MallocZero(tls, bp+16 /* &rc */, nByte) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { var i int32 for i = 0; i < (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg; i++ { *(*uintptr)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg + uintptr(i)*8)) = Xsqlite3_column_value(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt */)), i) @@ -180548,12 +177708,12 @@ func fts5FindRankFunction(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:2240 } } - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { pAux = fts5FindAuxiliary(tls, pTab, zRank) if pAux == uintptr(0) { (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+38678 /* "no such function..." */, libc.VaList(bp+8, zRank)) - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_ERROR } } @@ -180565,24 +177725,24 @@ func fts5CursorParseRank(tls *libc.TLS, pConfig uintptr, pCsr uintptr, pRank uin bp := tls.Alloc(24) defer tls.Free(24) - var rc int32 = 0 + var rc int32 = SQLITE_OK if pRank != 0 { var z uintptr = Xsqlite3_value_text(tls, pRank) *(*uintptr)(unsafe.Pointer(bp + 8 /* zRank */)) = uintptr(0) *(*uintptr)(unsafe.Pointer(bp + 16 /* zRankArgs */)) = uintptr(0) if z == uintptr(0) { - if Xsqlite3_value_type(tls, pRank) == 5 { - rc = 1 + if Xsqlite3_value_type(tls, pRank) == SQLITE_NULL { + rc = SQLITE_ERROR } } else { rc = sqlite3Fts5ConfigParseRank(tls, z, bp+8 /* &zRank */, bp+16 /* &zRankArgs */) } - if rc == 0 { + if rc == SQLITE_OK { (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRank = *(*uintptr)(unsafe.Pointer(bp + 8 /* zRank */)) (*Fts5Cursor)(unsafe.Pointer(pCsr)).FzRankArgs = *(*uintptr)(unsafe.Pointer(bp + 16 /* zRankArgs */)) - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (0x10) - } else if rc == 1 { + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) |= (FTS5CSR_FREE_ZRANK) + } else if rc == SQLITE_ERROR { (*Sqlite3_vtab)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+38699 /* "parse error in r..." */, libc.VaList(bp, z)) } @@ -180601,7 +177761,7 @@ func fts5CursorParseRank(tls *libc.TLS, pConfig uintptr, pCsr uintptr, pRank uin func fts5GetRowidLimit(tls *libc.TLS, pVal uintptr, iDefault I64) I64 { /* sqlite3.c:224142:12: */ if pVal != 0 { var eType int32 = Xsqlite3_value_numeric_type(tls, pVal) - if eType == 1 { + if eType == SQLITE_INTEGER { return Xsqlite3_value_int64(tls, pVal) } } @@ -180642,7 +177802,7 @@ func fts5FilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintp pTab = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab pConfig = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig pCsr = pCursor - rc = 0 + rc = SQLITE_OK pRank = uintptr(0) pRowidEq = uintptr(0) pRowidLe = uintptr(0) @@ -180656,7 +177816,7 @@ func fts5FilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintp } (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+38531 /* "recursively defi..." */, 0) - return 1 + return SQLITE_ERROR __1: ; @@ -180722,26 +177882,26 @@ __13: __14: ; - if !(int32(*(*int8)(unsafe.Pointer(zText + uintptr(0)))) == '*') { + if !(int32(*(*int8)(unsafe.Pointer(zText))) == '*') { goto __18 } // The user has issued a query of the form "MATCH '*...'". This // indicates that the MATCH expression is not a full text query, // but a request for an internal parameter. - rc = fts5SpecialMatch(tls, pTab, pCsr, (zText + uintptr(1))) + rc = fts5SpecialMatch(tls, pTab, pCsr, (zText + 1)) goto filter_out goto __19 __18: pzErr = (pTab /* &.p */ /* &.base */ + 16 /* &.zErrMsg */) rc = sqlite3Fts5ExprNew(tls, pConfig, iCol, zText, bp+8 /* &pExpr */, pzErr) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __20 } rc = sqlite3Fts5ExprAnd(tls, (pCsr + 64 /* &.pExpr */), *(*uintptr)(unsafe.Pointer(bp + 8 /* pExpr */))) *(*uintptr)(unsafe.Pointer(bp + 8 /* pExpr */)) = uintptr(0) __20: ; - if !(rc != 0) { + if !(rc != SQLITE_OK) { goto __21 } goto filter_out @@ -180772,13 +177932,13 @@ __4: __5: ; bOrderByRank = func() int32 { - if (idxNum & 0x0020) != 0 { + if (idxNum & FTS5_BI_ORDER_RANK) != 0 { return 1 } return 0 }() (*Fts5Cursor)(unsafe.Pointer(pCsr)).FbDesc = libc.AssignInt32(&bDesc, func() int32 { - if (idxNum & 0x0080) != 0 { + if (idxNum & FTS5_BI_ORDER_DESC) != 0 { return 1 } return 0 @@ -180827,7 +177987,7 @@ __27: (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiFirstRowid = (*Fts5Cursor)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FiFirstRowid __28: ; - (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = 2 + (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = FTS5_PLAN_SOURCE (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr = (*Fts5Cursor)(unsafe.Pointer((*Fts5FullTable)(unsafe.Pointer(pTab)).FpSortCsr)).FpExpr rc = fts5CursorFirst(tls, pTab, pCsr, bDesc) goto __26 @@ -180836,17 +177996,17 @@ __25: goto __29 } rc = fts5CursorParseRank(tls, pConfig, pCsr, pRank) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __31 } if !(bOrderByRank != 0) { goto __32 } - (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = 4 + (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = FTS5_PLAN_SORTED_MATCH rc = fts5CursorFirstSorted(tls, pTab, pCsr, bDesc) goto __33 __32: - (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = 1 + (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = FTS5_PLAN_MATCH rc = fts5CursorFirst(tls, pTab, pCsr, bDesc) __33: ; @@ -180859,23 +178019,23 @@ __29: } *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg)) = Xsqlite3_mprintf(tls, ts+38732 /* "%s: table does n..." */, libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) - rc = 1 + rc = SQLITE_ERROR goto __35 __34: // This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup // by rowid (ePlan==FTS5_PLAN_ROWID). (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan = func() int32 { if pRowidEq != 0 { - return 6 + return FTS5_PLAN_ROWID } - return 5 + return FTS5_PLAN_SCAN }() rc = sqlite3Fts5StorageStmt(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, fts5StmtType(tls, pCsr), (pCsr + 56 /* &.pStmt */), (pTab /* &.p */ /* &.base */ + 16 /* &.zErrMsg */)) - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __36 } - if !((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 6) { + if !((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_ROWID) { goto __37 } Xsqlite3_bind_value(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, 1, pRowidEq) @@ -180906,7 +178066,7 @@ filter_out: func fts5EofMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:224341:12: */ var pCsr uintptr = pCursor return func() int32 { - if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x01)) != 0 { + if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_EOF)) != 0 { return 1 } return 0 @@ -180933,15 +178093,15 @@ func fts5RowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { /* var ePlan int32 = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan switch ePlan { - case 3: + case FTS5_PLAN_SPECIAL: *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = int64(0) break - case 2: + case FTS5_PLAN_SOURCE: fallthrough - case 1: + case FTS5_PLAN_MATCH: fallthrough - case 4: + case FTS5_PLAN_SORTED_MATCH: *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = fts5CursorRowid(tls, pCsr) break @@ -180950,7 +178110,7 @@ func fts5RowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { /* break } - return 0 + return SQLITE_OK } // If the cursor requires seeking (bSeekRequired flag is set), seek it. @@ -180962,7 +178122,7 @@ func fts5SeekCursor(tls *libc.TLS, pCsr uintptr, bErrormsg int32) int32 { /* sql bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK // If the cursor does not yet have a statement handle, obtain one now. if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt == uintptr(0) { @@ -180978,7 +178138,7 @@ func fts5SeekCursor(tls *libc.TLS, pCsr uintptr, bErrormsg int32) int32 { /* sql } - if (rc == 0) && (((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x02)) != 0) { + if (rc == SQLITE_OK) && (((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_REQUIRE_CONTENT)) != 0) { var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab Xsqlite3_reset(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) @@ -180986,13 +178146,13 @@ func fts5SeekCursor(tls *libc.TLS, pCsr uintptr, bErrormsg int32) int32 { /* sql (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).FbLock++ rc = Xsqlite3_step(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).FbLock-- - if rc == 100 { - rc = 0 - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (^libc.Int32(0x02)) + if rc == SQLITE_ROW { + rc = SQLITE_OK + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (libc.CplInt32(FTS5CSR_REQUIRE_CONTENT)) } else { rc = Xsqlite3_reset(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt) - if rc == 0 { - rc = (11 | (int32(1) << 8)) + if rc == SQLITE_OK { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } else if (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).FpzErrmsg != 0 { *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).FpzErrmsg)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp, Xsqlite3_errmsg(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pTab)).FpConfig)).Fdb))) @@ -181029,23 +178189,23 @@ func fts5SpecialInsert(tls *libc.TLS, pTab uintptr, zCmd uintptr, pVal uintptr) defer tls.Free(4) var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig - var rc int32 = 0 + var rc int32 = SQLITE_OK *(*int32)(unsafe.Pointer(bp /* bError */)) = 0 if 0 == Xsqlite3_stricmp(tls, ts+38768 /* "delete-all" */, zCmd) { - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { fts5SetVtabError(tls, pTab, ts+38779 /* "'delete-all' may..." */, 0) - rc = 1 + rc = SQLITE_ERROR } else { rc = sqlite3Fts5StorageDeleteAll(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage) } } else if 0 == Xsqlite3_stricmp(tls, ts+38859 /* "rebuild" */, zCmd) { - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 1 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NONE { fts5SetVtabError(tls, pTab, ts+38867 /* "'rebuild' may no..." */, 0) - rc = 1 + rc = SQLITE_ERROR } else { rc = sqlite3Fts5StorageRebuild(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage) } @@ -181058,12 +178218,12 @@ func fts5SpecialInsert(tls *libc.TLS, pTab uintptr, zCmd uintptr, pVal uintptr) rc = sqlite3Fts5StorageIntegrity(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage) } else { rc = sqlite3Fts5IndexLoadConfig(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5ConfigSetValue(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig, zCmd, pVal, bp /* &bError */) } - if rc == 0 { + if rc == SQLITE_OK { if *(*int32)(unsafe.Pointer(bp /* bError */)) != 0 { - rc = 1 + rc = SQLITE_ERROR } else { rc = sqlite3Fts5StorageConfigValue(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, zCmd, pVal, 0) } @@ -181073,21 +178233,21 @@ func fts5SpecialInsert(tls *libc.TLS, pTab uintptr, zCmd uintptr, pVal uintptr) } func fts5SpecialDelete(tls *libc.TLS, pTab uintptr, apVal uintptr) int32 { /* sqlite3.c:224515:12: */ - var rc int32 = 0 - var eType1 int32 = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - if eType1 == 1 { - var iDel Sqlite3_int64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) - rc = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iDel, (apVal + uintptr(2)*8)) + var rc int32 = SQLITE_OK + var eType1 int32 = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + if eType1 == SQLITE_INTEGER { + var iDel Sqlite3_int64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) + rc = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iDel, (apVal + 2*8)) } return rc } func fts5StorageInsert(tls *libc.TLS, pRc uintptr, pTab uintptr, apVal uintptr, piRowid uintptr) { /* sqlite3.c:224528:13: */ var rc int32 = *(*int32)(unsafe.Pointer(pRc)) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5StorageContentInsert(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, piRowid) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5StorageIndexInsert(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, *(*I64)(unsafe.Pointer(piRowid))) } *(*int32)(unsafe.Pointer(pRc)) = rc @@ -181111,8 +178271,8 @@ func fts5UpdateMethod(tls *libc.TLS, pVtab uintptr, nArg int32, apVal uintptr, p var pTab uintptr = pVtab var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig - var eType0 int32 // value_type() of apVal[0] - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 0 // Return code + var eType0 int32 // value_type() of apVal[0] + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK // Return code // A transaction must be open when this is called. @@ -181121,12 +178281,12 @@ func fts5UpdateMethod(tls *libc.TLS, pVtab uintptr, nArg int32, apVal uintptr, p // Put any active cursors into REQUIRE_SEEK state. fts5TripCursors(tls, pTab) - eType0 = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) - if (eType0 == 5) && - (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr((2+(*Fts5Config)(unsafe.Pointer(pConfig)).FnCol))*8))) != 5) { + eType0 = Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal))) + if (eType0 == SQLITE_NULL) && + (Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr((2+(*Fts5Config)(unsafe.Pointer(pConfig)).FnCol))*8))) != SQLITE_NULL) { // A "special" INSERT op. These are handled separately. var z uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr((2+(*Fts5Config)(unsafe.Pointer(pConfig)).FnCol))*8))) - if ((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != 0) && + if ((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL) && (0 == Xsqlite3_stricmp(tls, ts+18507 /* "delete" */, z)) { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = fts5SpecialDelete(tls, pTab, apVal) } else { @@ -181143,14 +178303,14 @@ func fts5UpdateMethod(tls *libc.TLS, pVtab uintptr, nArg int32, apVal uintptr, p // 4) INSERT // // Cases 3 and 4 may violate the rowid constraint. - var eConflict int32 = 4 - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0 { + var eConflict int32 = SQLITE_ABORT + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { eConflict = Xsqlite3_vtab_on_conflict(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb) } // Filter out attempts to run UPDATE or DELETE on contentless tables. // This is not suported. - if (eType0 == 1) && (fts5IsContentless(tls, pTab) != 0) { + if (eType0 == SQLITE_INTEGER) && (fts5IsContentless(tls, pTab) != 0) { (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, ts+38945, /* "cannot %s conten..." */ libc.VaList(bp, func() uintptr { @@ -181159,38 +178319,38 @@ func fts5UpdateMethod(tls *libc.TLS, pVtab uintptr, nArg int32, apVal uintptr, p } return ts + 38982 /* "DELETE from" */ }(), (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_ERROR } else if nArg == 1 { - var iDel I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) // Rowid to delete + var iDel I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal))) // Rowid to delete *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iDel, uintptr(0)) } else { - var eType1 int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) + var eType1 int32 = Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) - if (eType1 != 1) && (eType1 != 5) { - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 20 - } else if eType0 != 1 { + if (eType1 != SQLITE_INTEGER) && (eType1 != SQLITE_NULL) { + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_MISMATCH + } else if eType0 != SQLITE_INTEGER { // If this is a REPLACE, first remove the current entry (if any) - if (eConflict == 5) && (eType1 == 1) { - var iNew I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) // Rowid to delete + if (eConflict == SQLITE_REPLACE) && (eType1 == SQLITE_INTEGER) { + var iNew I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) // Rowid to delete *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iNew, uintptr(0)) } fts5StorageInsert(tls, bp+16 /* &rc */, pTab, apVal, pRowid) } else { - var iOld I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(0)*8))) // Old rowid - var iNew I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) // New rowid - if (eType1 == 1) && (iOld != iNew) { - if eConflict == 5 { + var iOld I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal))) // Old rowid + var iNew I64 = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) // New rowid + if (eType1 == SQLITE_INTEGER) && (iOld != iNew) { + if eConflict == SQLITE_REPLACE { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iOld, uintptr(0)) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iNew, uintptr(0)) } fts5StorageInsert(tls, bp+16 /* &rc */, pTab, apVal, pRowid) } else { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageContentInsert(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, pRowid) - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageDelete(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iOld, uintptr(0)) } - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5StorageIndexInsert(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, *(*Sqlite_int64)(unsafe.Pointer(pRowid))) } } @@ -181222,7 +178382,7 @@ func fts5SyncMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:224684:12 func fts5BeginMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:224698:12: */ fts5NewTransaction(tls, pVtab) - return 0 + return SQLITE_OK } // Implementation of xCommit() method. This is a no-op. The contents of @@ -181231,7 +178391,7 @@ func fts5BeginMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:224698:1 func fts5CommitMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:224709:12: */ _ = pVtab // Call below is a no-op for NDEBUG builds - return 0 + return SQLITE_OK } // Implementation of xRollback(). Discard the contents of the pending-terms @@ -181270,7 +178430,7 @@ func fts5ApiTokenize(tls *libc.TLS, pCtx uintptr, pText uintptr, nText int32, pU var pCsr uintptr = pCtx var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab return sqlite3Fts5Tokenize(tls, - (*Fts5Table)(unsafe.Pointer(pTab)).FpConfig, 0x0008, pText, nText, pUserData, xToken) + (*Fts5Table)(unsafe.Pointer(pTab)).FpConfig, FTS5_TOKENIZE_AUX, pText, nText, pUserData, xToken) } func fts5ApiPhraseCount(tls *libc.TLS, pCtx uintptr) int32 { /* sqlite3.c:224768:12: */ @@ -181284,15 +178444,15 @@ func fts5ApiPhraseSize(tls *libc.TLS, pCtx uintptr, iPhrase int32) int32 { /* sq } func fts5ApiColumnText(tls *libc.TLS, pCtx uintptr, iCol int32, pz uintptr, pn uintptr) int32 { /* sqlite3.c:224778:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pCsr uintptr = pCtx if (fts5IsContentless(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab) != 0) || - ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 3) { + ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SPECIAL) { *(*uintptr)(unsafe.Pointer(pz)) = uintptr(0) *(*int32)(unsafe.Pointer(pn)) = 0 } else { rc = fts5SeekCursor(tls, pCsr, 0) - if rc == 0 { + if rc == SQLITE_OK { *(*uintptr)(unsafe.Pointer(pz)) = Xsqlite3_column_text(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, (iCol + 1)) *(*int32)(unsafe.Pointer(pn)) = Xsqlite3_column_bytes(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, (iCol + 1)) } @@ -181305,25 +178465,25 @@ func fts5CsrPoslist(tls *libc.TLS, pCsr uintptr, iPhrase int32, pa uintptr, pn u defer tls.Free(12) var pConfig uintptr = (*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig - var rc int32 = 0 + var rc int32 = SQLITE_OK var bLive int32 = (libc.Bool32((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter == uintptr(0))) - if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x40)) != 0 { + if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_REQUIRE_POSLIST)) != 0 { - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail != 0 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail != FTS5_DETAIL_FULL { var aPopulator uintptr var i int32 aPopulator = sqlite3Fts5ExprClearPoslists(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, bLive) if aPopulator == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } - for i = 0; (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) && (rc == 0); i++ { + for i = 0; (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) && (rc == SQLITE_OK); i++ { // var n int32 at bp+8, 4 // var z uintptr at bp, 8 rc = fts5ApiColumnText(tls, pCsr, i, bp /* &z */, bp+8 /* &n */) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5ExprPopulatePoslists(tls, pConfig, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, aPopulator, i, *(*uintptr)(unsafe.Pointer(bp /* z */)), *(*int32)(unsafe.Pointer(bp + 8 /* n */))) } @@ -181334,10 +178494,10 @@ func fts5CsrPoslist(tls *libc.TLS, pCsr uintptr, iPhrase int32, pa uintptr, pn u sqlite3Fts5ExprCheckPoslists(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, (*Fts5Sorter)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter)).FiRowid) } } - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (^libc.Int32(0x40)) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (libc.CplInt32(FTS5CSR_REQUIRE_POSLIST)) } - if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 0) { + if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_FULL) { var pSorter uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter var i1 int32 = func() int32 { if iPhrase == 0 { @@ -181361,7 +178521,7 @@ func fts5CacheInstArray(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:224853 bp := tls.Alloc(20) defer tls.Free(20) - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK var aIter uintptr // One iterator for each phrase var nIter int32 // Number of iterators/phrases var nCol int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig)).FnCol @@ -181378,18 +178538,18 @@ func fts5CacheInstArray(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:224853 var i int32 // Initialize all iterators - for i = 0; (i < nIter) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == 0); i++ { + for i = 0; (i < nIter) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK); i++ { // var a uintptr at bp+8, 8 // var n int32 at bp+16, 4 *(*int32)(unsafe.Pointer(bp /* rc */)) = fts5CsrPoslist(tls, pCsr, i, bp+8 /* &a */, bp+16 /* &n */) - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { sqlite3Fts5PoslistReaderInit(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* a */)), *(*int32)(unsafe.Pointer(bp + 16 /* n */)), (aIter + uintptr(i)*32)) } } - if *(*int32)(unsafe.Pointer(bp /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { for 1 != 0 { var aInst uintptr var iBest int32 = -1 @@ -181416,17 +178576,17 @@ func fts5CacheInstArray(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:224853 if aInst != 0 { (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst = aInst } else { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 7 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_NOMEM break } } aInst = ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr((3*(nInst-1)))*4) - *(*int32)(unsafe.Pointer(aInst + uintptr(0)*4)) = iBest - *(*int32)(unsafe.Pointer(aInst + uintptr(1)*4)) = (int32((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(iBest)*32)).FiPos >> 32)) - *(*int32)(unsafe.Pointer(aInst + uintptr(2)*4)) = (int32((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(iBest)*32)).FiPos & int64(0x7FFFFFFF))) - if (*(*int32)(unsafe.Pointer(aInst + uintptr(1)*4)) < 0) || (*(*int32)(unsafe.Pointer(aInst + uintptr(1)*4)) >= nCol) { - *(*int32)(unsafe.Pointer(bp /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(aInst)) = iBest + *(*int32)(unsafe.Pointer(aInst + 1*4)) = (int32((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(iBest)*32)).FiPos >> 32)) + *(*int32)(unsafe.Pointer(aInst + 2*4)) = (int32((*Fts5PoslistReader)(unsafe.Pointer(aIter+uintptr(iBest)*32)).FiPos & int64(0x7FFFFFFF))) + if (*(*int32)(unsafe.Pointer(aInst + 1*4)) < 0) || (*(*int32)(unsafe.Pointer(aInst + 1*4)) >= nCol) { + *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) break } sqlite3Fts5PoslistReaderNext(tls, (aIter + uintptr(iBest)*32)) @@ -181434,16 +178594,16 @@ func fts5CacheInstArray(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:224853 } (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount = nInst - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (^libc.Int32(0x08)) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (libc.CplInt32(FTS5CSR_REQUIRE_INST)) } return *(*int32)(unsafe.Pointer(bp /* rc */)) } func fts5ApiInstCount(tls *libc.TLS, pCtx uintptr, pnInst uintptr) int32 { /* sqlite3.c:224925:12: */ var pCsr uintptr = pCtx - var rc int32 = 0 - if (((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x08)) == 0) || - (0 == (libc.AssignInt32(&rc, fts5CacheInstArray(tls, pCsr)))) { + var rc int32 = SQLITE_OK + if (((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_REQUIRE_INST)) == 0) || + (SQLITE_OK == (libc.AssignInt32(&rc, fts5CacheInstArray(tls, pCsr)))) { *(*int32)(unsafe.Pointer(pnInst)) = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount } return rc @@ -181451,11 +178611,11 @@ func fts5ApiInstCount(tls *libc.TLS, pCtx uintptr, pnInst uintptr) int32 { /* sq func fts5ApiInst(tls *libc.TLS, pCtx uintptr, iIdx int32, piPhrase uintptr, piCol uintptr, piOff uintptr) int32 { /* sqlite3.c:224935:12: */ var pCsr uintptr = pCtx - var rc int32 = 0 - if (((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x08)) == 0) || - (0 == (libc.AssignInt32(&rc, fts5CacheInstArray(tls, pCsr)))) { + var rc int32 = SQLITE_OK + if (((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_REQUIRE_INST)) == 0) || + (SQLITE_OK == (libc.AssignInt32(&rc, fts5CacheInstArray(tls, pCsr)))) { if (iIdx < 0) || (iIdx >= (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount) { - rc = 25 + rc = SQLITE_RANGE } else { *(*int32)(unsafe.Pointer(piPhrase)) = *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr((iIdx*3))*4)) *(*int32)(unsafe.Pointer(piCol)) = *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(((iIdx*3)+1))*4)) @@ -181475,10 +178635,10 @@ func fts5ColumnSizeCb(tls *libc.TLS, pContext uintptr, tflags int32, pUnused uin _ = nUnused _ = iUnused1 _ = iUnused2 - if (tflags & 0x0001) == 0 { + if (tflags & FTS5_TOKEN_COLOCATED) == 0 { (*(*int32)(unsafe.Pointer(pCnt)))++ } - return 0 + return SQLITE_OK } func fts5ApiColumnSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) int32 { /* sqlite3.c:224985:12: */ @@ -181488,9 +178648,9 @@ func fts5ApiColumnSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) var pCsr uintptr = pCtx var pTab uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig - var rc int32 = 0 + var rc int32 = SQLITE_OK - if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (0x04)) != 0 { + if ((*Fts5Cursor)(unsafe.Pointer((pCsr))).Fcsrflags & (FTS5CSR_REQUIRE_DOCSIZE)) != 0 { if (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { var iRowid I64 = fts5CursorRowid(tls, pCsr) rc = sqlite3Fts5StorageDocsize(tls, (*Fts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iRowid, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize) @@ -181503,7 +178663,7 @@ func fts5ApiColumnSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) } } else { var i int32 - for i = 0; (rc == 0) && (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); i++ { if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(i)))) == 0 { // var z uintptr at bp, 8 @@ -181512,16 +178672,16 @@ func fts5ApiColumnSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) var p uintptr = ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(i)*4) *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(i)*4)) = 0 rc = fts5ApiColumnText(tls, pCtx, i, bp /* &z */, bp+8 /* &n */) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5Tokenize(tls, - pConfig, 0x0008, *(*uintptr)(unsafe.Pointer(bp /* z */)), *(*int32)(unsafe.Pointer(bp + 8 /* n */)), p, *(*uintptr)(unsafe.Pointer(&struct { + pConfig, FTS5_TOKENIZE_AUX, *(*uintptr)(unsafe.Pointer(bp /* z */)), *(*int32)(unsafe.Pointer(bp + 8 /* n */)), p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5ColumnSizeCb}))) } } } } - *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (^libc.Int32(0x04)) + *(*int32)(unsafe.Pointer(pCsr + 80 /* &.csrflags */)) &= (libc.CplInt32(FTS5CSR_REQUIRE_DOCSIZE)) } if iCol < 0 { var i int32 @@ -181533,7 +178693,7 @@ func fts5ApiColumnSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) *(*int32)(unsafe.Pointer(pnToken)) = *(*int32)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).FaColumnSize + uintptr(iCol)*4)) } else { *(*int32)(unsafe.Pointer(pnToken)) = 0 - rc = 25 + rc = SQLITE_RANGE } return rc } @@ -181559,7 +178719,7 @@ func fts5ApiSetAuxdata(tls *libc.TLS, pCtx uintptr, pPtr uintptr, xDelete uintpt (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((pData + 16 /* &.xDelete */))))(tls, (*Fts5Auxdata)(unsafe.Pointer(pData)).FpPtr) } } else { - *(*int32)(unsafe.Pointer(bp /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK pData = sqlite3Fts5MallocZero(tls, bp /* &rc */, int64(unsafe.Sizeof(Fts5Auxdata{}))) if pData == uintptr(0) { if xDelete != 0 { @@ -181574,7 +178734,7 @@ func fts5ApiSetAuxdata(tls *libc.TLS, pCtx uintptr, pPtr uintptr, xDelete uintpt (*Fts5Auxdata)(unsafe.Pointer(pData)).FxDelete = xDelete (*Fts5Auxdata)(unsafe.Pointer(pData)).FpPtr = pPtr - return 0 + return SQLITE_OK } func fts5ApiGetAuxdata(tls *libc.TLS, pCtx uintptr, bClear int32) uintptr { /* sqlite3.c:225073:13: */ @@ -181629,7 +178789,7 @@ func fts5ApiPhraseFirst(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter uintpt // var n int32 at bp, 4 var rc int32 = fts5CsrPoslist(tls, pCsr, iPhrase, (pIter /* &.a */), bp /* &n */) - if rc == 0 { + if rc == SQLITE_OK { (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb = ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(*(*int32)(unsafe.Pointer(bp /* n */)))) *(*int32)(unsafe.Pointer(piCol)) = 0 *(*int32)(unsafe.Pointer(piOff)) = 0 @@ -181645,13 +178805,13 @@ func fts5ApiPhraseNextColumn(tls *libc.TLS, pCtx uintptr, pIter uintptr, piCol u var pCsr uintptr = pCtx var pConfig uintptr = (*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 2 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_COLUMNS { if (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa >= (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb { *(*int32)(unsafe.Pointer(piCol)) = -1 } else { // var iIncr int32 at bp, 4 - *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(sqlite3Fts5GetVarint32(tls, ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(0)), bp /* &iIncr */))) + *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(sqlite3Fts5GetVarint32(tls, ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa), bp /* &iIncr */))) *(*int32)(unsafe.Pointer(piCol)) += (*(*int32)(unsafe.Pointer(bp /* iIncr */)) - 2) } } else { @@ -181662,12 +178822,12 @@ func fts5ApiPhraseNextColumn(tls *libc.TLS, pCtx uintptr, pIter uintptr, piCol u *(*int32)(unsafe.Pointer(piCol)) = -1 return } - if int32(*(*uint8)(unsafe.Pointer((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(0)))) == 0x01 { + if int32(*(*uint8)(unsafe.Pointer((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa))) == 0x01 { break } *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(sqlite3Fts5GetVarint32(tls, (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp+4 /* &dummy */))) } - *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(1 + sqlite3Fts5GetVarint32(tls, ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa+uintptr(1)), piCol))) + *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(1 + sqlite3Fts5GetVarint32(tls, ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa+1), piCol))) } } @@ -181675,11 +178835,11 @@ func fts5ApiPhraseFirstColumn(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var pCsr uintptr = pCtx var pConfig uintptr = (*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 2 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_COLUMNS { var pSorter uintptr = (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpSorter // var n int32 at bp, 4 @@ -181695,7 +178855,7 @@ func fts5ApiPhraseFirstColumn(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter } else { rc = sqlite3Fts5ExprPhraseCollist(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase, (pIter /* &.a */), bp /* &n */) } - if rc == 0 { + if rc == SQLITE_OK { (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb = ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(*(*int32)(unsafe.Pointer(bp /* n */)))) *(*int32)(unsafe.Pointer(piCol)) = 0 fts5ApiPhraseNextColumn(tls, pCtx, pIter, piCol) @@ -181704,12 +178864,12 @@ func fts5ApiPhraseFirstColumn(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter // var n int32 at bp+4, 4 rc = fts5CsrPoslist(tls, pCsr, iPhrase, (pIter /* &.a */), bp+4 /* &n */) - if rc == 0 { + if rc == SQLITE_OK { (*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fb = ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(*(*int32)(unsafe.Pointer(bp + 4 /* n */)))) if *(*int32)(unsafe.Pointer(bp + 4 /* n */)) <= 0 { *(*int32)(unsafe.Pointer(piCol)) = -1 - } else if int32(*(*uint8)(unsafe.Pointer((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(0)))) == 0x01 { - *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(1 + sqlite3Fts5GetVarint32(tls, ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa+uintptr(1)), piCol))) + } else if int32(*(*uint8)(unsafe.Pointer((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa))) == 0x01 { + *(*uintptr)(unsafe.Pointer(pIter /* &.a */)) += (uintptr(1 + sqlite3Fts5GetVarint32(tls, ((*Fts5PhraseIter)(unsafe.Pointer(pIter)).Fa+1), piCol))) } else { *(*int32)(unsafe.Pointer(piCol)) = 0 } @@ -181720,9 +178880,8 @@ func fts5ApiPhraseFirstColumn(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter } var sFts5Api = Fts5ExtensionApi{ - FiVersion: 2, - FxUserData:// iVersion - 0, + FiVersion: 2, // iVersion + FxUserData: 0, FxColumnCount: 0, FxRowCount: 0, FxColumnTotalSize: 0, @@ -181754,20 +178913,20 @@ func fts5ApiQueryPhrase(tls *libc.TLS, pCtx uintptr, iPhrase int32, pUserData ui *(*uintptr)(unsafe.Pointer(bp /* pNew */)) = uintptr(0) rc = fts5OpenMethod(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab, bp /* &pNew */) - if rc == 0 { - (*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pNew */)))).FePlan = 1 + if rc == SQLITE_OK { + (*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pNew */)))).FePlan = FTS5_PLAN_MATCH (*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pNew */)))).FiFirstRowid = ((int64(-1)) - (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32))) (*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pNew */)))).FiLastRowid = (int64(0xffffffff) | (I64((int64(0x7fffffff))) << 32)) (*Fts5Cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pNew */)))).Fbase.FpVtab = pTab rc = sqlite3Fts5ExprClonePhrase(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase, (*(*uintptr)(unsafe.Pointer(bp /* pNew */)) + 64 /* &.pExpr */)) } - if rc == 0 { - for rc = fts5CursorFirst(tls, pTab, *(*uintptr)(unsafe.Pointer(bp /* pNew */)), 0); (rc == 0) && (((*Fts5Cursor)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNew */))))).Fcsrflags & (0x01)) == 0); rc = fts5NextMethod(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */))) { + if rc == SQLITE_OK { + for rc = fts5CursorFirst(tls, pTab, *(*uintptr)(unsafe.Pointer(bp /* pNew */)), 0); (rc == SQLITE_OK) && (((*Fts5Cursor)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pNew */))))).Fcsrflags & (FTS5CSR_EOF)) == 0); rc = fts5NextMethod(tls, *(*uintptr)(unsafe.Pointer(bp /* pNew */))) { rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&xCallback)))(tls, uintptr(unsafe.Pointer(&sFts5Api)), *(*uintptr)(unsafe.Pointer(bp /* pNew */)), pUserData) - if rc != 0 { - if rc == 101 { - rc = 0 + if rc != SQLITE_OK { + if rc == SQLITE_DONE { + rc = SQLITE_OK } break } @@ -181804,7 +178963,7 @@ func fts5ApiCallback(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { var iCsrId I64 pAux = Xsqlite3_user_data(tls, context) - iCsrId = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8))) + iCsrId = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) pCsr = fts5CursorFromCsrid(tls, (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpGlobal, iCsrId) if (pCsr == uintptr(0)) || ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 0) { @@ -181812,7 +178971,7 @@ func fts5ApiCallback(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { Xsqlite3_result_error(tls, context, zErr, -1) Xsqlite3_free(tls, zErr) } else { - fts5ApiInvoke(tls, pAux, pCsr, context, (argc - 1), (argv + uintptr(1)*8)) + fts5ApiInvoke(tls, pAux, pCsr, context, (argc - 1), (argv + 1*8)) } } @@ -181845,13 +179004,13 @@ func fts5PoslistBlob(tls *libc.TLS, pCtx uintptr, pCsr uintptr) int32 { /* sqlit defer tls.Free(68) var i int32 - *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = SQLITE_OK var nPhrase int32 = sqlite3Fts5ExprPhraseCount(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpExpr) // var val Fts5Buffer at bp, 16 libc.Xmemset(tls, bp /* &val */, 0, uint64(unsafe.Sizeof(Fts5Buffer{}))) switch (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig)).FeDetail { - case 0: + case FTS5_DETAIL_FULL: // Append the varints for i = 0; i < (nPhrase - 1); i++ { @@ -181871,10 +179030,10 @@ func fts5PoslistBlob(tls *libc.TLS, pCtx uintptr, pCsr uintptr) int32 { /* sqlit } break - case 2: + case FTS5_DETAIL_COLUMNS: // Append the varints - for i = 0; (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0) && (i < (nPhrase - 1)); i++ { + for i = 0; (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK) && (i < (nPhrase - 1)); i++ { // var dummy uintptr at bp+40, 8 // var nByte int32 at bp+48, 4 @@ -181884,7 +179043,7 @@ func fts5PoslistBlob(tls *libc.TLS, pCtx uintptr, pCsr uintptr) int32 { /* sqlit } // Append the position lists - for i = 0; (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == 0) && (i < nPhrase); i++ { + for i = 0; (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK) && (i < nPhrase); i++ { // var pPoslist uintptr at bp+56, 8 // var nPoslist int32 at bp+64, 4 @@ -181908,9 +179067,9 @@ func fts5ColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol int32) var pTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab var pConfig uintptr = (*Fts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig var pCsr uintptr = pCursor - var rc int32 = 0 + var rc int32 = SQLITE_OK - if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 3 { + if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SPECIAL { if iCol == (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol { Xsqlite3_result_int64(tls, pCtx, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial) } @@ -181923,18 +179082,18 @@ func fts5ColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol int32) } else if iCol == ((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol + 1) { // The value of the "rank" column. - if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 2 { + if (*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SOURCE { fts5PoslistBlob(tls, pCtx, pCsr) - } else if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 1) || - ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == 4) { - if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRank != 0) || (0 == (libc.AssignInt32(&rc, fts5FindRankFunction(tls, pCsr)))) { + } else if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_MATCH) || + ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FePlan == FTS5_PLAN_SORTED_MATCH) { + if ((*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRank != 0) || (SQLITE_OK == (libc.AssignInt32(&rc, fts5FindRankFunction(tls, pCsr)))) { fts5ApiInvoke(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpRank, pCsr, pCtx, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FnRankArg, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FapRankArg) } } } else if !(fts5IsContentless(tls, pTab) != 0) { (*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = (pTab /* &.p */ /* &.base */ + 16 /* &.zErrMsg */) rc = fts5SeekCursor(tls, pCsr, 1) - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_result_value(tls, pCtx, Xsqlite3_column_value(tls, (*Fts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, (iCol+1))) } (*Fts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg = uintptr(0) @@ -182006,7 +179165,7 @@ func fts5RollbackToMethod(tls *libc.TLS, pVtab uintptr, iSavepoint int32) int32 func fts5CreateAux(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData uintptr, xFunc Fts5_extension_function, xDestroy uintptr) int32 { /* sqlite3.c:225537:12: */ var pGlobal uintptr = pApi var rc int32 = Xsqlite3_overload_function(tls, (*Fts5Global)(unsafe.Pointer(pGlobal)).Fdb, zName, -1) - if rc == 0 { + if rc == SQLITE_OK { var pAux uintptr var nName Sqlite3_int64 // Size of zName in bytes, including \0 var nByte Sqlite3_int64 // Bytes of space to allocate @@ -182016,7 +179175,7 @@ func fts5CreateAux(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData uintptr pAux = Xsqlite3_malloc64(tls, uint64(nByte)) if pAux != 0 { libc.Xmemset(tls, pAux, 0, Size_t(nByte)) - (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc = (pAux + uintptr(1)*48) + (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc = (pAux + 1*48) libc.Xmemcpy(tls, (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc, zName, uint64(nName)) (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpGlobal = pGlobal (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpUserData = pUserData @@ -182025,7 +179184,7 @@ func fts5CreateAux(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData uintptr (*Fts5Auxiliary)(unsafe.Pointer(pAux)).FpNext = (*Fts5Global)(unsafe.Pointer(pGlobal)).FpAux (*Fts5Global)(unsafe.Pointer(pGlobal)).FpAux = pAux } else { - rc = 7 + rc = SQLITE_NOMEM } } @@ -182039,14 +179198,14 @@ func fts5CreateTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData u var pNew uintptr var nName Sqlite3_int64 // Size of zName and its \0 terminator var nByte Sqlite3_int64 // Bytes of space to allocate - var rc int32 = 0 + var rc int32 = SQLITE_OK nName = (Sqlite3_int64(libc.Xstrlen(tls, zName) + uint64(1))) nByte = (Sqlite3_int64(uint64(unsafe.Sizeof(Fts5TokenizerModule{})) + uint64(nName))) pNew = Xsqlite3_malloc64(tls, uint64(nByte)) if pNew != 0 { libc.Xmemset(tls, pNew, 0, Size_t(nByte)) - (*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FzName = (pNew + uintptr(1)*56) + (*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FzName = (pNew + 1*56) libc.Xmemcpy(tls, (*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FzName, zName, uint64(nName)) (*Fts5TokenizerModule)(unsafe.Pointer(pNew)).FpUserData = pUserData (*Fts5TokenizerModule)(unsafe.Pointer(pNew)).Fx = *(*Fts5_tokenizer)(unsafe.Pointer(pTokenizer)) @@ -182057,7 +179216,7 @@ func fts5CreateTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData u (*Fts5Global)(unsafe.Pointer(pGlobal)).FpDfltTok = pNew } } else { - rc = 7 + rc = SQLITE_NOMEM } return rc @@ -182082,7 +179241,7 @@ func fts5LocateTokenizer(tls *libc.TLS, pGlobal uintptr, zName uintptr) uintptr // Find a tokenizer. This is the implementation of the // fts5_api.xFindTokenizer() method. func fts5FindTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, ppUserData uintptr, pTokenizer uintptr) int32 { /* sqlite3.c:225632:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var pMod uintptr pMod = fts5LocateTokenizer(tls, pApi, zName) @@ -182091,7 +179250,7 @@ func fts5FindTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, ppUserData ui *(*uintptr)(unsafe.Pointer(ppUserData)) = (*Fts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData } else { libc.Xmemset(tls, pTokenizer, 0, uint64(unsafe.Sizeof(Fts5_tokenizer{}))) - rc = 1 + rc = SQLITE_ERROR } return rc @@ -182102,32 +179261,32 @@ func sqlite3Fts5GetTokenizer(tls *libc.TLS, pGlobal uintptr, azArg uintptr, nArg defer tls.Free(8) var pMod uintptr - var rc int32 = 0 + var rc int32 = SQLITE_OK pMod = fts5LocateTokenizer(tls, pGlobal, func() uintptr { if nArg == 0 { return uintptr(0) } - return *(*uintptr)(unsafe.Pointer(azArg + uintptr(0)*8)) + return *(*uintptr)(unsafe.Pointer(azArg)) }()) if pMod == uintptr(0) { - rc = 1 - *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+39015 /* "no such tokenize..." */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(azArg + uintptr(0)*8)))) + rc = SQLITE_ERROR + *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+39015 /* "no such tokenize..." */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(azArg)))) } else { - rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pMod + 16 /* &.x */ /* &.xCreate */))))(tls, (*Fts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData, (azArg + uintptr(1)*8), func() int32 { + rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pMod + 16 /* &.x */ /* &.xCreate */))))(tls, (*Fts5TokenizerModule)(unsafe.Pointer(pMod)).FpUserData, (azArg + 1*8), func() int32 { if nArg != 0 { return (nArg - 1) } return 0 }(), ppTok) *(*uintptr)(unsafe.Pointer(ppTokApi)) = (pMod + 16 /* &.x */) - if (rc != 0) && (pzErr != 0) { + if (rc != SQLITE_OK) && (pzErr != 0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+39037 /* "error in tokeniz..." */, 0) } } - if rc != 0 { + if rc != SQLITE_OK { *(*uintptr)(unsafe.Pointer(ppTokApi)) = uintptr(0) *(*uintptr)(unsafe.Pointer(ppTok)) = uintptr(0) } @@ -182166,7 +179325,7 @@ func fts5Fts5Func(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) { /* s var ppApi uintptr _ = nArg - ppApi = Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(0)*8)), ts+39068 /* "fts5_api_ptr" */) + ppApi = Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(apArg)), ts+39068 /* "fts5_api_ptr" */) if ppApi != 0 { *(*uintptr)(unsafe.Pointer(ppApi)) = (pGlobal /* &.api */) } @@ -182202,7 +179361,7 @@ func fts5Init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:225746:12: */ pGlobal = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5Global{}))) if pGlobal == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var p uintptr = pGlobal libc.Xmemset(tls, pGlobal, 0, uint64(unsafe.Sizeof(Fts5Global{}))) @@ -182218,30 +179377,30 @@ func fts5Init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:225746:12: */ f func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32 }{fts5FindTokenizer})) rc = Xsqlite3_create_module_v2(tls, db, ts+39179 /* "fts5" */, uintptr(unsafe.Pointer(&fts5Mod)), p, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5ModuleDestroy}))) - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5IndexInit(tls, db) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5ExprInit(tls, pGlobal, db) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5AuxInit(tls, (pGlobal /* &.api */)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5TokenizerInit(tls, (pGlobal /* &.api */)) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5VocabInit(tls, pGlobal, db) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_function(tls, - db, ts+39179 /* "fts5" */, 1, 1, p, *(*uintptr)(unsafe.Pointer(&struct { + db, ts+39179 /* "fts5" */, 1, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{fts5Fts5Func})), uintptr(0), uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { rc = Xsqlite3_create_function(tls, - db, ts+39184 /* "fts5_source_id" */, 0, 1, p, *(*uintptr)(unsafe.Pointer(&struct { + db, ts+39184 /* "fts5_source_id" */, 0, SQLITE_UTF8, p, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{fts5SourceIdFunc})), uintptr(0), uintptr(0)) } @@ -182255,54 +179414,30 @@ func fts5Init(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:225746:12: */ } var fts5Mod = Sqlite3_module{ - FiVersion: - /* iVersion */ 3, - FxCreate: - /* xCreate */ 0, - FxConnect: - /* xConnect */ 0, - FxBestIndex: - /* xBestIndex */ 0, - FxDisconnect: - /* xDisconnect */ 0, - FxDestroy: - /* xDestroy */ 0, - FxOpen: - /* xOpen */ 0, - FxClose: - /* xClose */ 0, - FxFilter: - /* xFilter */ 0, - FxNext: - /* xNext */ 0, - FxEof: - /* xEof */ 0, - FxColumn: - /* xColumn */ 0, - FxRowid: - /* xRowid */ 0, - FxUpdate: - /* xUpdate */ 0, - FxBegin: - /* xBegin */ 0, - FxSync: - /* xSync */ 0, - FxCommit: - /* xCommit */ 0, - FxRollback: - /* xRollback */ 0, - FxFindFunction: - /* xFindFunction */ 0, - FxRename: - /* xRename */ 0, - FxSavepoint: - /* xSavepoint */ 0, - FxRelease: - /* xRelease */ 0, - FxRollbackTo: - /* xRollbackTo */ 0, - FxShadowName: - /* xShadowName */ 0, + /* iVersion */ FiVersion: 3, + /* xCreate */ FxCreate: 0, + /* xConnect */ FxConnect: 0, + /* xBestIndex */ FxBestIndex: 0, + /* xDisconnect */ FxDisconnect: 0, + /* xDestroy */ FxDestroy: 0, + /* xOpen */ FxOpen: 0, + /* xClose */ FxClose: 0, + /* xFilter */ FxFilter: 0, + /* xNext */ FxNext: 0, + /* xEof */ FxEof: 0, + /* xColumn */ FxColumn: 0, + /* xRowid */ FxRowid: 0, + /* xUpdate */ FxUpdate: 0, + /* xBegin */ FxBegin: 0, + /* xSync */ FxSync: 0, + /* xCommit */ FxCommit: 0, + /* xRollback */ FxRollback: 0, + /* xFindFunction */ FxFindFunction: 0, + /* xRename */ FxRename: 0, + /* xSavepoint */ FxSavepoint: 0, + /* xRelease */ FxRelease: 0, + /* xRollbackTo */ FxRollbackTo: 0, + /* xShadowName */ FxShadowName: 0, } /* sqlite3.c:225747:31 */ // The following functions are used to register the module with SQLite. If @@ -182324,7 +179459,7 @@ func fts5StorageGetStmt(tls *libc.TLS, p uintptr, eStmt int32, ppStmt uintptr, p bp := tls.Alloc(216) defer tls.Free(216) - var rc int32 = 0 + var rc int32 = SQLITE_OK // If there is no %_docsize table, there should be no requests for // statements to operate on it. @@ -182350,30 +179485,30 @@ func fts5StorageGetStmt(tls *libc.TLS, p uintptr, eStmt int32, ppStmt uintptr, p var zSql uintptr = uintptr(0) switch eStmt { - case 10: + case FTS5_STMT_SCAN: zSql = Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* &azStmt[0] */ + uintptr(eStmt)*8)), libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*Fts5Config)(unsafe.Pointer(pC)).FzContent)) break fallthrough - case 0: + case FTS5_STMT_SCAN_ASC: fallthrough - case 1: + case FTS5_STMT_SCAN_DESC: zSql = Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* &azStmt[0] */ + uintptr(eStmt)*8)), libc.VaList(bp+16, (*Fts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*Fts5Config)(unsafe.Pointer(pC)).FzContent, (*Fts5Config)(unsafe.Pointer(pC)).FzContentRowid, (*Fts5Config)(unsafe.Pointer(pC)).FzContentRowid, (*Fts5Config)(unsafe.Pointer(pC)).FzContentRowid)) break fallthrough - case 2: + case FTS5_STMT_LOOKUP: zSql = Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* &azStmt[0] */ + uintptr(eStmt)*8)), libc.VaList(bp+56, (*Fts5Config)(unsafe.Pointer(pC)).FzContentExprlist, (*Fts5Config)(unsafe.Pointer(pC)).FzContent, (*Fts5Config)(unsafe.Pointer(pC)).FzContentRowid)) break fallthrough - case 3: + case FTS5_STMT_INSERT_CONTENT: fallthrough - case 4: + case FTS5_STMT_REPLACE_CONTENT: { var nCol int32 = ((*Fts5Config)(unsafe.Pointer(pC)).FnCol + 1) var zBind uintptr @@ -182400,17 +179535,17 @@ func fts5StorageGetStmt(tls *libc.TLS, p uintptr, eStmt int32, ppStmt uintptr, p } if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { - var f int32 = 0x01 - if eStmt > 2 { - f = f | (0x04) + var f int32 = SQLITE_PREPARE_PERSISTENT + if eStmt > FTS5_STMT_LOOKUP { + f = f | (SQLITE_PREPARE_NO_VTAB) } (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock++ rc = Xsqlite3_prepare_v3(tls, (*Fts5Config)(unsafe.Pointer(pC)).Fdb, zSql, -1, uint32(f), ((p + 40 /* &.aStmt */) + uintptr(eStmt)*8), uintptr(0)) (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FbLock-- Xsqlite3_free(tls, zSql) - if (rc != 0) && (pzErrMsg != 0) { + if (rc != SQLITE_OK) && (pzErrMsg != 0) { *(*uintptr)(unsafe.Pointer(pzErrMsg)) = Xsqlite3_mprintf(tls, ts+824 /* "%s" */, libc.VaList(bp+120, Xsqlite3_errmsg(tls, (*Fts5Config)(unsafe.Pointer(pC)).Fdb))) } } @@ -182431,7 +179566,7 @@ func fts5ExecPrintf(tls *libc.TLS, db uintptr, pzErr uintptr, zFormat uintptr, v zSql = Xsqlite3_vmprintf(tls, zFormat, ap) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { rc = Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), pzErr) Xsqlite3_free(tls, zSql) @@ -182453,12 +179588,12 @@ func sqlite3Fts5DropAll(tls *libc.TLS, pConfig uintptr) int32 { /* sqlite3.c:226 libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { rc = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), ts+39776, /* "DROP TABLE IF EX..." */ libc.VaList(bp+48, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) } - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL) { rc = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), ts+39814, /* "DROP TABLE IF EX..." */ libc.VaList(bp+64, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) @@ -182470,7 +179605,7 @@ func fts5StorageRenameOne(tls *libc.TLS, pConfig uintptr, pRc uintptr, zTail uin bp := tls.Alloc(40) defer tls.Free(40) - if *(*int32)(unsafe.Pointer(pRc)) == 0 { + if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { *(*int32)(unsafe.Pointer(pRc)) = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), ts+39852, /* "ALTER TABLE %Q.'..." */ libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, zTail, zName, zTail)) @@ -182490,7 +179625,7 @@ func sqlite3Fts5StorageRename(tls *libc.TLS, pStorage uintptr, zName uintptr) in if (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { fts5StorageRenameOne(tls, pConfig, bp /* &rc */, ts+36980 /* "docsize" */, zName) } - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { fts5StorageRenameOne(tls, pConfig, bp /* &rc */, ts+36629 /* "content" */, zName) } return *(*int32)(unsafe.Pointer(bp /* rc */)) @@ -182532,7 +179667,7 @@ func sqlite3Fts5StorageOpen(tls *libc.TLS, pConfig uintptr, pIndex uintptr, bCre bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr // New object var nByte Sqlite3_int64 // Bytes of space to allocate @@ -182540,20 +179675,20 @@ func sqlite3Fts5StorageOpen(tls *libc.TLS, pConfig uintptr, pIndex uintptr, bCre (uint64((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) * uint64(unsafe.Sizeof(I64(0)))))) // Fts5Storage.aTotalSize[] *(*uintptr)(unsafe.Pointer(pp)) = libc.AssignUintptr(&p, Xsqlite3_malloc64(tls, uint64(nByte))) if !(p != 0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, p, 0, Size_t(nByte)) - (*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize = (p + uintptr(1)*128) + (*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize = (p + 1*128) (*Fts5Storage)(unsafe.Pointer(p)).FpConfig = pConfig (*Fts5Storage)(unsafe.Pointer(p)).FpIndex = pIndex if bCreate != 0 { - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { var nDefn int32 = (32 + ((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol * 10)) var zDefn uintptr = Xsqlite3_malloc64(tls, (uint64(int64(32) + (Sqlite3_int64((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) * int64(10))))) if zDefn == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var i int32 var iOff int32 @@ -182568,16 +179703,16 @@ func sqlite3Fts5StorageOpen(tls *libc.TLS, pConfig uintptr, pIndex uintptr, bCre Xsqlite3_free(tls, zDefn) } - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { rc = sqlite3Fts5CreateTable(tls, pConfig, ts+36980 /* "docsize" */, ts+39997 /* "id INTEGER PRIMA..." */, 0, pzErr) } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5CreateTable(tls, pConfig, ts+39172 /* "config" */, ts+40029 /* "k PRIMARY KEY, v" */, 1, pzErr) } - if rc == 0 { - rc = sqlite3Fts5StorageConfigValue(tls, p, ts+37126 /* "version" */, uintptr(0), 4) + if rc == SQLITE_OK { + rc = sqlite3Fts5StorageConfigValue(tls, p, ts+37126 /* "version" */, uintptr(0), FTS5_CURRENT_VERSION) } } @@ -182590,7 +179725,7 @@ func sqlite3Fts5StorageOpen(tls *libc.TLS, pConfig uintptr, pIndex uintptr, bCre // Close a handle opened by an earlier call to sqlite3Fts5StorageOpen(). func sqlite3Fts5StorageClose(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:226203:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if p != 0 { var i int32 @@ -182618,10 +179753,10 @@ func fts5StorageInsertCallback(tls *libc.TLS, pContext uintptr, tflags int32, pT var pIdx uintptr = (*Fts5Storage)(unsafe.Pointer((*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FpStorage)).FpIndex _ = iUnused1 _ = iUnused2 - if nToken > 32768 { - nToken = 32768 + if nToken > FTS5_MAX_TOKEN_SIZE { + nToken = FTS5_MAX_TOKEN_SIZE } - if ((tflags & 0x0001) == 0) || ((*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol == 0) { + if ((tflags & FTS5_TOKEN_COLOCATED) == 0) || ((*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol == 0) { (*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol++ } return sqlite3Fts5IndexWrite(tls, pIdx, (*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FiCol, ((*Fts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol - 1), pToken, nToken) @@ -182642,12 +179777,12 @@ func fts5StorageDeleteFromIndex(tls *libc.TLS, p uintptr, iDel I64, apVal uintpt // var ctx Fts5InsertCtx at bp+8, 16 if apVal == uintptr(0) { - rc = fts5StorageGetStmt(tls, p, 2, bp /* &pSeek */, uintptr(0)) - if rc != 0 { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_LOOKUP, bp /* &pSeek */, uintptr(0)) + if rc != SQLITE_OK { return rc } Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pSeek */)), 1, iDel) - if Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pSeek */))) != 100 { + if Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pSeek */))) != SQLITE_ROW { return Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pSeek */))) } } @@ -182655,7 +179790,7 @@ func fts5StorageDeleteFromIndex(tls *libc.TLS, p uintptr, iDel I64, apVal uintpt (*Fts5InsertCtx)(unsafe.Pointer(bp + 8 /* &ctx */)).FpStorage = p (*Fts5InsertCtx)(unsafe.Pointer(bp + 8 /* &ctx */)).FiCol = -1 rc = sqlite3Fts5IndexBeginWrite(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, 1, iDel) - for iCol = 1; (rc == 0) && (iCol <= (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); iCol++ { + for iCol = 1; (rc == SQLITE_OK) && (iCol <= (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); iCol++ { if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr((iCol - 1))))) == 0 { var zText uintptr var nText int32 @@ -182667,7 +179802,7 @@ func fts5StorageDeleteFromIndex(tls *libc.TLS, p uintptr, iDel I64, apVal uintpt nText = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr((iCol-1))*8))) } (*Fts5InsertCtx)(unsafe.Pointer(bp + 8 /* &ctx */)).FszCol = 0 - rc = sqlite3Fts5Tokenize(tls, pConfig, 0x0004, + rc = sqlite3Fts5Tokenize(tls, pConfig, FTS5_TOKENIZE_DOCUMENT, zText, nText, bp+8 /* &ctx */, *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5StorageInsertCallback}))) @@ -182677,7 +179812,7 @@ func fts5StorageDeleteFromIndex(tls *libc.TLS, p uintptr, iDel I64, apVal uintpt (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow-- rc2 = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pSeek */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } return rc @@ -182693,11 +179828,11 @@ func fts5StorageInsertDocsize(tls *libc.TLS, p uintptr, iRowid I64, pBuf uintptr bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FbColumnsize != 0 { *(*uintptr)(unsafe.Pointer(bp /* pReplace */)) = uintptr(0) - rc = fts5StorageGetStmt(tls, p, 6, bp /* &pReplace */, uintptr(0)) - if rc == 0 { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_REPLACE_DOCSIZE, bp /* &pReplace */, uintptr(0)) + if rc == SQLITE_OK { Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 1, iRowid) Xsqlite3_bind_blob(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 2, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fp, (*Fts5Buffer)(unsafe.Pointer(pBuf)).Fn, uintptr(0)) Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */))) @@ -182717,7 +179852,7 @@ func fts5StorageInsertDocsize(tls *libc.TLS, p uintptr, iRowid I64, pBuf uintptr // Return SQLITE_OK if successful, or an SQLite error code if an error // occurs. func fts5StorageLoadTotals(tls *libc.TLS, p uintptr, bCache int32) int32 { /* sqlite3.c:226339:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK if (*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid == 0 { rc = sqlite3Fts5IndexGetAverages(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, (p + 24 /* &.nTotalRow */), (*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize) (*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid = bCache @@ -182738,14 +179873,14 @@ func fts5StorageSaveTotals(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:226355 var i int32 // var buf Fts5Buffer at bp, 16 - *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK libc.Xmemset(tls, bp /* &buf */, 0, uint64(unsafe.Sizeof(Fts5Buffer{}))) sqlite3Fts5BufferAppendVarint(tls, bp+16 /* &rc */, bp /* &buf */, (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow) for i = 0; i < nCol; i++ { sqlite3Fts5BufferAppendVarint(tls, bp+16 /* &rc */, bp /* &buf */, *(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(i)*8))) } - if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3Fts5IndexSetAverages(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fn) } Xsqlite3_free(tls, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp) @@ -182765,14 +179900,14 @@ func sqlite3Fts5StorageDelete(tls *libc.TLS, p uintptr, iDel I64, apVal uintptr) rc = fts5StorageLoadTotals(tls, p, 1) // Delete the index records - if rc == 0 { + if rc == SQLITE_OK { rc = fts5StorageDeleteFromIndex(tls, p, iDel, apVal) } // Delete the %_docsize record - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { - rc = fts5StorageGetStmt(tls, p, 7, bp /* &pDel */, uintptr(0)) - if rc == 0 { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_DELETE_DOCSIZE, bp /* &pDel */, uintptr(0)) + if rc == SQLITE_OK { Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pDel */)), 1, iDel) Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pDel */))) rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pDel */))) @@ -182780,11 +179915,11 @@ func sqlite3Fts5StorageDelete(tls *libc.TLS, p uintptr, iDel I64, apVal uintptr) } // Delete the %_content record - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0 { - if rc == 0 { - rc = fts5StorageGetStmt(tls, p, 5, bp /* &pDel */, uintptr(0)) + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL { + if rc == SQLITE_OK { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_DELETE_CONTENT, bp /* &pDel */, uintptr(0)) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pDel */)), 1, iDel) Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pDel */))) rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pDel */))) @@ -182810,7 +179945,7 @@ func sqlite3Fts5StorageDeleteAll(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c: ts+40046, /* "DELETE FROM %Q.'..." */ libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { rc = fts5ExecPrintf(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), ts+40096, /* "DELETE FROM %Q.'..." */ libc.VaList(bp+32, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName)) @@ -182818,11 +179953,11 @@ func sqlite3Fts5StorageDeleteAll(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c: // Reinitialize the %_data table. This call creates the initial structure // and averages records. - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5IndexReinit(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex) } - if rc == 0 { - rc = sqlite3Fts5StorageConfigValue(tls, p, ts+37126 /* "version" */, uintptr(0), 4) + if rc == SQLITE_OK { + rc = sqlite3Fts5StorageConfigValue(tls, p, ts+37126 /* "version" */, uintptr(0), FTS5_CURRENT_VERSION) } return rc } @@ -182843,26 +179978,26 @@ func sqlite3Fts5StorageRebuild(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:22 libc.Xmemset(tls, bp /* &ctx */, 0, uint64(unsafe.Sizeof(Fts5InsertCtx{}))) (*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FpStorage = p *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = sqlite3Fts5StorageDeleteAll(tls, p) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5StorageLoadTotals(tls, p, 1) } - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { - *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5StorageGetStmt(tls, p, 10, bp+16 /* &pScan */, uintptr(0)) + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { + *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5StorageGetStmt(tls, p, FTS5_STMT_SCAN, bp+16 /* &pScan */, uintptr(0)) } - for (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && (100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pScan */)))) { + for (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pScan */)))) { var iRowid I64 = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pScan */)), 0) sqlite3Fts5BufferZero(tls, bp+24 /* &buf */) *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = sqlite3Fts5IndexBeginWrite(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, 0, iRowid) - for (*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol = 0; (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0) && ((*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); (*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol++ { + for (*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol = 0; (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && ((*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); (*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol++ { (*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FszCol = 0 if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr((*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol)))) == 0 { var zText uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pScan */)), ((*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol + 1)) var nText int32 = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pScan */)), ((*Fts5InsertCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol + 1)) *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = sqlite3Fts5Tokenize(tls, pConfig, - 0x0004, + FTS5_TOKENIZE_DOCUMENT, zText, nText, bp, /* &ctx */ *(*uintptr)(unsafe.Pointer(&struct { @@ -182874,18 +180009,18 @@ func sqlite3Fts5StorageRebuild(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:22 } (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow++ - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5StorageInsertDocsize(tls, p, iRowid, bp+24 /* &buf */) } } Xsqlite3_free(tls, (*Fts5Buffer)(unsafe.Pointer(bp+24 /* &buf */)).Fp) rc2 = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pScan */))) - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = rc2 } // Write the averages record - if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = fts5StorageSaveTotals(tls, p) } return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) @@ -182914,17 +180049,17 @@ func fts5StorageNewRowid(tls *libc.TLS, p uintptr, piRowid uintptr) int32 { /* s bp := tls.Alloc(8) defer tls.Free(8) - var rc int32 = 20 + var rc int32 = SQLITE_MISMATCH if (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FbColumnsize != 0 { *(*uintptr)(unsafe.Pointer(bp /* pReplace */)) = uintptr(0) - rc = fts5StorageGetStmt(tls, p, 6, bp /* &pReplace */, uintptr(0)) - if rc == 0 { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_REPLACE_DOCSIZE, bp /* &pReplace */, uintptr(0)) + if rc == SQLITE_OK { Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 1) Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 2) Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */))) rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */))) } - if rc == 0 { + if rc == SQLITE_OK { *(*I64)(unsafe.Pointer(piRowid)) = Xsqlite3_last_insert_rowid(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb) } } @@ -182937,23 +180072,23 @@ func sqlite3Fts5StorageContentInsert(tls *libc.TLS, p uintptr, apVal uintptr, pi defer tls.Free(8) var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig - var rc int32 = 0 + var rc int32 = SQLITE_OK // Insert the new row into the %_content table. - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != 0 { - if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) == 1 { - *(*I64)(unsafe.Pointer(piRowid)) = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(1)*8))) + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeContent != FTS5_CONTENT_NORMAL { + if Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) == SQLITE_INTEGER { + *(*I64)(unsafe.Pointer(piRowid)) = Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) } else { rc = fts5StorageNewRowid(tls, p, piRowid) } } else { *(*uintptr)(unsafe.Pointer(bp /* pInsert */)) = uintptr(0) // Statement to write %_content table var i int32 // Counter variable - rc = fts5StorageGetStmt(tls, p, 3, bp /* &pInsert */, uintptr(0)) - for i = 1; (rc == 0) && (i <= ((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol + 1)); i++ { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_INSERT_CONTENT, bp /* &pInsert */, uintptr(0)) + for i = 1; (rc == SQLITE_OK) && (i <= ((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol + 1)); i++ { rc = Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp /* pInsert */)), i, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8))) } - if rc == 0 { + if rc == SQLITE_OK { Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pInsert */))) rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pInsert */))) } @@ -182969,7 +180104,7 @@ func sqlite3Fts5StorageIndexInsert(tls *libc.TLS, p uintptr, apVal uintptr, iRow defer tls.Free(36) var pConfig uintptr = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig - *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = 0 // Return code + *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = SQLITE_OK // Return code // var ctx Fts5InsertCtx at bp+16, 16 // Tokenization callback context object // var buf Fts5Buffer at bp, 16 @@ -182979,16 +180114,16 @@ func sqlite3Fts5StorageIndexInsert(tls *libc.TLS, p uintptr, apVal uintptr, iRow (*Fts5InsertCtx)(unsafe.Pointer(bp + 16 /* &ctx */)).FpStorage = p *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = fts5StorageLoadTotals(tls, p, 1) - if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = sqlite3Fts5IndexBeginWrite(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, 0, iRowid) } - for (*Fts5InsertCtx)(unsafe.Pointer(bp + 16 /* &ctx */)).FiCol = 0; (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0) && ((*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); (*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol++ { + for (*Fts5InsertCtx)(unsafe.Pointer(bp + 16 /* &ctx */)).FiCol = 0; (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK) && ((*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); (*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol++ { (*Fts5InsertCtx)(unsafe.Pointer(bp + 16 /* &ctx */)).FszCol = 0 if int32(*(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr((*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol)))) == 0 { var zText uintptr = Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(((*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol+2))*8))) var nText int32 = Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(((*Fts5InsertCtx)(unsafe.Pointer(bp+16 /* &ctx */)).FiCol+2))*8))) *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = sqlite3Fts5Tokenize(tls, pConfig, - 0x0004, + FTS5_TOKENIZE_DOCUMENT, zText, nText, bp+16, /* &ctx */ *(*uintptr)(unsafe.Pointer(&struct { @@ -183001,7 +180136,7 @@ func sqlite3Fts5StorageIndexInsert(tls *libc.TLS, p uintptr, apVal uintptr, iRow (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow++ // Write the %_docsize record - if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = fts5StorageInsertDocsize(tls, p, iRowid, bp /* &buf */) } Xsqlite3_free(tls, (*Fts5Buffer)(unsafe.Pointer(bp /* &buf */)).Fp) @@ -183020,12 +180155,12 @@ func fts5StorageCount(tls *libc.TLS, p uintptr, zSuffix uintptr, pnRow uintptr) zSql = Xsqlite3_mprintf(tls, ts+40125, /* "SELECT count(*) ..." */ libc.VaList(bp, (*Fts5Config)(unsafe.Pointer(pConfig)).FzDb, (*Fts5Config)(unsafe.Pointer(pConfig)).FzName, zSuffix)) if zSql == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { *(*uintptr)(unsafe.Pointer(bp + 24 /* pCnt */)) = uintptr(0) rc = Xsqlite3_prepare_v2(tls, (*Fts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -1, bp+24 /* &pCnt */, uintptr(0)) - if rc == 0 { - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pCnt */))) { + if rc == SQLITE_OK { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pCnt */))) { *(*I64)(unsafe.Pointer(pnRow)) = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pCnt */)), 0) } rc = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pCnt */))) @@ -183059,27 +180194,27 @@ func fts5StorageIntegrityCallback(tls *libc.TLS, pContext uintptr, tflags int32, // var bPresent int32 at bp, 4 var ii int32 - var rc int32 = 0 + var rc int32 = SQLITE_OK var iPos int32 var iCol int32 _ = iUnused1 _ = iUnused2 - if nToken > 32768 { - nToken = 32768 + if nToken > FTS5_MAX_TOKEN_SIZE { + nToken = FTS5_MAX_TOKEN_SIZE } - if ((tflags & 0x0001) == 0) || ((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol == 0) { + if ((tflags & FTS5_TOKEN_COLOCATED) == 0) || ((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol == 0) { (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol++ } switch (*Fts5Config)(unsafe.Pointer((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FeDetail { - case 0: + case FTS5_DETAIL_FULL: iPos = ((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol - 1) iCol = (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiCol break - case 2: + case FTS5_DETAIL_COLUMNS: iPos = (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiCol iCol = 0 break @@ -183092,12 +180227,12 @@ func fts5StorageIntegrityCallback(tls *libc.TLS, pContext uintptr, tflags int32, } rc = sqlite3Fts5TermsetAdd(tls, pTermset, 0, pToken, nToken, bp /* &bPresent */) - if (rc == 0) && (*(*int32)(unsafe.Pointer(bp /* bPresent */)) == 0) { + if (rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* bPresent */)) == 0) { *(*U64)(unsafe.Pointer(pCtx + 16 /* &.cksum */)) ^= (sqlite3Fts5IndexEntryCksum(tls, (*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiRowid, iCol, iPos, 0, pToken, nToken)) } - for ii = 0; (rc == 0) && (ii < (*Fts5Config)(unsafe.Pointer((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FnPrefix); ii++ { + for ii = 0; (rc == SQLITE_OK) && (ii < (*Fts5Config)(unsafe.Pointer((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FnPrefix); ii++ { var nChar int32 = *(*int32)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer((*Fts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FaPrefix + uintptr(ii)*4)) var nByte int32 = sqlite3Fts5IndexCharlenToBytelen(tls, pToken, nToken, nChar) if nByte != 0 { @@ -183132,51 +180267,51 @@ func sqlite3Fts5StorageIntegrity(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c: (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FpConfig = (*Fts5Storage)(unsafe.Pointer(p)).FpConfig aTotalSize = Xsqlite3_malloc64(tls, (uint64(uint64((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol) * (uint64(unsafe.Sizeof(int32(0))) + uint64(unsafe.Sizeof(I64(0))))))) if !(aTotalSize != 0) { - return 7 + return SQLITE_NOMEM } aColSize = (aTotalSize + uintptr((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol)*8) libc.Xmemset(tls, aTotalSize, 0, (uint64(unsafe.Sizeof(I64(0))) * uint64((*Fts5Config)(unsafe.Pointer(pConfig)).FnCol))) // Generate the expected index checksum based on the contents of the // %_content table. This block stores the checksum in ctx.cksum. - rc = fts5StorageGetStmt(tls, p, 10, bp+40 /* &pScan */, uintptr(0)) - if rc == 0 { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_SCAN, bp+40 /* &pScan */, uintptr(0)) + if rc == SQLITE_OK { var rc2 int32 - for 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pScan */))) { + for SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pScan */))) { var i int32 (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FiRowid = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pScan */)), 0) (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FszCol = 0 if (*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 { rc = sqlite3Fts5StorageDocsize(tls, p, (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FiRowid, aColSize) } - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 1) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_NONE) { rc = sqlite3Fts5TermsetNew(tls, (bp /* &ctx */ + 24 /* &.pTermset */)) } - for i = 0; (rc == 0) && (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); i++ { if *(*U8)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer(pConfig)).FabUnindexed + uintptr(i))) != 0 { continue } (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FiCol = i (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FszCol = 0 - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 2 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_COLUMNS { rc = sqlite3Fts5TermsetNew(tls, (bp /* &ctx */ + 24 /* &.pTermset */)) } - if rc == 0 { + if rc == SQLITE_OK { var zText uintptr = Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pScan */)), (i + 1)) var nText int32 = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pScan */)), (i + 1)) rc = sqlite3Fts5Tokenize(tls, pConfig, - 0x0004, + FTS5_TOKENIZE_DOCUMENT, zText, nText, bp, /* &ctx */ *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 }{fts5StorageIntegrityCallback}))) } - if ((rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0)) && ((*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FszCol != *(*int32)(unsafe.Pointer(aColSize + uintptr(i)*4))) { - rc = (11 | (int32(1) << 8)) + if ((rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0)) && ((*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FszCol != *(*int32)(unsafe.Pointer(aColSize + uintptr(i)*4))) { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } *(*I64)(unsafe.Pointer(aTotalSize + uintptr(i)*8)) += (I64((*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FszCol)) - if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == 2 { + if (*Fts5Config)(unsafe.Pointer(pConfig)).FeDetail == FTS5_DETAIL_COLUMNS { sqlite3Fts5TermsetFree(tls, (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FpTermset) (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FpTermset = uintptr(0) } @@ -183184,48 +180319,48 @@ func sqlite3Fts5StorageIntegrity(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c: sqlite3Fts5TermsetFree(tls, (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FpTermset) (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).FpTermset = uintptr(0) - if rc != 0 { + if rc != SQLITE_OK { break } } rc2 = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pScan */))) - if rc == 0 { + if rc == SQLITE_OK { rc = rc2 } } // Test that the "totals" (sometimes called "averages") record looks Ok - if rc == 0 { + if rc == SQLITE_OK { var i int32 rc = fts5StorageLoadTotals(tls, p, 0) - for i = 0; (rc == 0) && (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (*Fts5Config)(unsafe.Pointer(pConfig)).FnCol); i++ { if *(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(i)*8)) != *(*I64)(unsafe.Pointer(aTotalSize + uintptr(i)*8)) { - rc = (11 | (int32(1) << 8)) + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } } // Check that the %_docsize and %_content tables contain the expected // number of rows. - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == 0) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL) { *(*I64)(unsafe.Pointer(bp + 48 /* nRow */)) = int64(0) rc = fts5StorageCount(tls, p, ts+36629 /* "content" */, bp+48 /* &nRow */) - if (rc == 0) && (*(*I64)(unsafe.Pointer(bp + 48 /* nRow */)) != (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow) { - rc = (11 | (int32(1) << 8)) + if (rc == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp + 48 /* nRow */)) != (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow) { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } - if (rc == 0) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { + if (rc == SQLITE_OK) && ((*Fts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0) { *(*I64)(unsafe.Pointer(bp + 56 /* nRow */)) = int64(0) rc = fts5StorageCount(tls, p, ts+36980 /* "docsize" */, bp+56 /* &nRow */) - if (rc == 0) && (*(*I64)(unsafe.Pointer(bp + 56 /* nRow */)) != (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow) { - rc = (11 | (int32(1) << 8)) + if (rc == SQLITE_OK) && (*(*I64)(unsafe.Pointer(bp + 56 /* nRow */)) != (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow) { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } // Pass the expected checksum down to the FTS index module. It will // verify, amongst other things, that it matches the checksum generated by // inspecting the index itself. - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5IndexIntegrityCheck(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, (*Fts5IntegrityCtx)(unsafe.Pointer(bp /* &ctx */)).Fcksum) } @@ -183239,7 +180374,7 @@ func sqlite3Fts5StorageStmt(tls *libc.TLS, p uintptr, eStmt int32, pp uintptr, p var rc int32 rc = fts5StorageGetStmt(tls, p, eStmt, pp, pzErrMsg) - if rc == 0 { + if rc == SQLITE_OK { *(*uintptr)(unsafe.Pointer((p + 40 /* &.aStmt */) + uintptr(eStmt)*8)) = uintptr(0) } @@ -183285,11 +180420,11 @@ func sqlite3Fts5StorageDocsize(tls *libc.TLS, p uintptr, iRowid I64, aCol uintpt *(*uintptr)(unsafe.Pointer(bp /* pLookup */)) = uintptr(0) // Statement to query %_docsize var rc int32 // Return Code - rc = fts5StorageGetStmt(tls, p, 8, bp /* &pLookup */, uintptr(0)) - if rc == 0 { + rc = fts5StorageGetStmt(tls, p, FTS5_STMT_LOOKUP_DOCSIZE, bp /* &pLookup */, uintptr(0)) + if rc == SQLITE_OK { var bCorrupt int32 = 1 Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pLookup */)), 1, iRowid) - if 100 == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pLookup */))) { + if SQLITE_ROW == Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pLookup */))) { var aBlob uintptr = Xsqlite3_column_blob(tls, *(*uintptr)(unsafe.Pointer(bp /* pLookup */)), 0) var nBlob int32 = Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp /* pLookup */)), 0) if 0 == fts5StorageDecodeSizeArray(tls, aCol, nCol, aBlob, nBlob) { @@ -183297,8 +180432,8 @@ func sqlite3Fts5StorageDocsize(tls *libc.TLS, p uintptr, iRowid I64, aCol uintpt } } rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pLookup */))) - if (bCorrupt != 0) && (rc == 0) { - rc = (11 | (int32(1) << 8)) + if (bCorrupt != 0) && (rc == SQLITE_OK) { + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } @@ -183307,7 +180442,7 @@ func sqlite3Fts5StorageDocsize(tls *libc.TLS, p uintptr, iRowid I64, aCol uintpt func sqlite3Fts5StorageSize(tls *libc.TLS, p uintptr, iCol int32, pnToken uintptr) int32 { /* sqlite3.c:226926:12: */ var rc int32 = fts5StorageLoadTotals(tls, p, 0) - if rc == 0 { + if rc == SQLITE_OK { *(*I64)(unsafe.Pointer(pnToken)) = int64(0) if iCol < 0 { var i int32 @@ -183317,7 +180452,7 @@ func sqlite3Fts5StorageSize(tls *libc.TLS, p uintptr, iCol int32, pnToken uintpt } else if iCol < (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FnCol { *(*I64)(unsafe.Pointer(pnToken)) = *(*I64)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(iCol)*8)) } else { - rc = 25 + rc = SQLITE_RANGE } } return rc @@ -183325,7 +180460,7 @@ func sqlite3Fts5StorageSize(tls *libc.TLS, p uintptr, iCol int32, pnToken uintpt func sqlite3Fts5StorageRowCount(tls *libc.TLS, p uintptr, pnRow uintptr) int32 { /* sqlite3.c:226944:12: */ var rc int32 = fts5StorageLoadTotals(tls, p, 0) - if rc == 0 { + if rc == SQLITE_OK { // nTotalRow being zero does not necessarily indicate a corrupt // database - it might be that the FTS5 table really does contain zero // rows. However this function is only called from the xRowCount() API, @@ -183333,7 +180468,7 @@ func sqlite3Fts5StorageRowCount(tls *libc.TLS, p uintptr, pnRow uintptr) int32 { // no rows. Hence the FTS5_CORRUPT return. *(*I64)(unsafe.Pointer(pnRow)) = (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow if (*Fts5Storage)(unsafe.Pointer(p)).FnTotalRow <= int64(0) { - rc = (11 | (int32(1) << 8)) + rc = (SQLITE_CORRUPT | (int32(1) << 8)) } } return rc @@ -183341,13 +180476,13 @@ func sqlite3Fts5StorageRowCount(tls *libc.TLS, p uintptr, pnRow uintptr) int32 { // Flush any data currently held in-memory to disk. func sqlite3Fts5StorageSync(tls *libc.TLS, p uintptr) int32 { /* sqlite3.c:226961:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var iLastRowid I64 = Xsqlite3_last_insert_rowid(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb) if (*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid != 0 { rc = fts5StorageSaveTotals(tls, p) (*Fts5Storage)(unsafe.Pointer(p)).FbTotalsValid = 0 } - if rc == 0 { + if rc == SQLITE_OK { rc = sqlite3Fts5IndexSync(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex) } Xsqlite3_set_last_insert_rowid(tls, (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb, iLastRowid) @@ -183364,8 +180499,8 @@ func sqlite3Fts5StorageConfigValue(tls *libc.TLS, p uintptr, z uintptr, pVal uin defer tls.Free(8) *(*uintptr)(unsafe.Pointer(bp /* pReplace */)) = uintptr(0) - var rc int32 = fts5StorageGetStmt(tls, p, 9, bp /* &pReplace */, uintptr(0)) - if rc == 0 { + var rc int32 = fts5StorageGetStmt(tls, p, FTS5_STMT_REPLACE_CONFIG, bp /* &pReplace */, uintptr(0)) + if rc == SQLITE_OK { Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 1, z, -1, uintptr(0)) if pVal != 0 { Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 2, pVal) @@ -183376,10 +180511,10 @@ func sqlite3Fts5StorageConfigValue(tls *libc.TLS, p uintptr, z uintptr, pVal uin rc = Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */))) Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp /* pReplace */)), 1) } - if (rc == 0) && (pVal != 0) { + if (rc == SQLITE_OK) && (pVal != 0) { var iNew int32 = ((*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FiCookie + 1) rc = sqlite3Fts5IndexSetCookie(tls, (*Fts5Storage)(unsafe.Pointer(p)).FpIndex, iNew) - if rc == 0 { + if rc == SQLITE_OK { (*Fts5Config)(unsafe.Pointer((*Fts5Storage)(unsafe.Pointer(p)).FpConfig)).FiCookie = iNew } } @@ -183436,30 +180571,30 @@ func fts5AsciiDelete(tls *libc.TLS, p uintptr) { /* sqlite3.c:227065:13: */ // Create an "ascii" tokenizer. func fts5AsciiCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) int32 { /* sqlite3.c:227072:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var p uintptr = uintptr(0) _ = pUnused if (nArg % 2) != 0 { - rc = 1 + rc = SQLITE_ERROR } else { p = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(AsciiTokenizer{}))) if p == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { var i int32 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(AsciiTokenizer{}))) libc.Xmemcpy(tls, p /* &.aTokenChar */, uintptr(unsafe.Pointer(&aAsciiTokenChar)), uint64(unsafe.Sizeof(aAsciiTokenChar))) - for i = 0; (rc == 0) && (i < nArg); i = i + (2) { + for i = 0; (rc == SQLITE_OK) && (i < nArg); i = i + (2) { var zArg uintptr = *(*uintptr)(unsafe.Pointer(azArg + uintptr((i+1))*8)) if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), ts+40157 /* "tokenchars" */) { fts5AsciiAddExceptions(tls, p, zArg, 1) } else if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), ts+40168 /* "separators" */) { fts5AsciiAddExceptions(tls, p, zArg, 0) } else { - rc = 1 + rc = SQLITE_ERROR } } - if rc != 0 { + if rc != SQLITE_OK { fts5AsciiDelete(tls, p) p = uintptr(0) } @@ -183487,7 +180622,7 @@ func fts5AsciiTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused defer tls.Free(64) var p uintptr = pTokenizer - var rc int32 = 0 + var rc int32 = SQLITE_OK var ie int32 var is int32 = 0 // var aFold [64]int8 at bp, 64 @@ -183498,7 +180633,7 @@ func fts5AsciiTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused _ = iUnused - for (is < nText) && (rc == 0) { + for (is < nText) && (rc == SQLITE_OK) { var nByte int32 // Skip any leading divider characters. @@ -183523,7 +180658,7 @@ func fts5AsciiTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused } pFold = Xsqlite3_malloc64(tls, (uint64(Sqlite3_int64(nByte) * int64(2)))) if pFold == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM break } nFold = (nByte * 2) @@ -183538,8 +180673,8 @@ func fts5AsciiTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnused if pFold != bp /* aFold */ { Xsqlite3_free(tls, pFold) } - if rc == 101 { - rc = 0 + if rc == SQLITE_DONE { + rc = SQLITE_OK } return rc } @@ -183576,7 +180711,7 @@ type Unicode61Tokenizer = Unicode61Tokenizer1 /* sqlite3.c:227240:35 */ // Values for eRemoveDiacritic (must match internals of fts5_unicode2.c) func fts5UnicodeAddExceptions(tls *libc.TLS, p uintptr, z uintptr, bTokenChars int32) int32 { /* sqlite3.c:227257:12: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK var n int32 = int32(libc.Xstrlen(tls, z)) var aNew uintptr @@ -183622,7 +180757,7 @@ func fts5UnicodeAddExceptions(tls *libc.TLS, p uintptr, z uintptr, bTokenChars i (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaiException = aNew (*Unicode61Tokenizer)(unsafe.Pointer(p)).FnException = nNew } else { - rc = 7 + rc = SQLITE_NOMEM } } @@ -183670,7 +180805,7 @@ func unicodeSetCategories(tls *libc.TLS, p uintptr, zCat uintptr) int32 { /* sql z++ } if (*(*int8)(unsafe.Pointer(z)) != 0) && (sqlite3Fts5UnicodeCatParse(tls, z, p+160 /* &.aCategory */) != 0) { - return 1 + return SQLITE_ERROR } for ((int32(*(*int8)(unsafe.Pointer(z))) != ' ') && (int32(*(*int8)(unsafe.Pointer(z))) != '\t')) && (int32(*(*int8)(unsafe.Pointer(z))) != 0) { z++ @@ -183678,18 +180813,18 @@ func unicodeSetCategories(tls *libc.TLS, p uintptr, zCat uintptr) int32 { /* sql } sqlite3Fts5UnicodeAscii(tls, p+160 /* &.aCategory */, p /* &.aTokenChar */) - return 0 + return SQLITE_OK } // Create a "unicode61" tokenizer. func fts5UnicodeCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32, ppOut uintptr) int32 { /* sqlite3.c:227359:12: */ - var rc int32 = 0 // Return code + var rc int32 = SQLITE_OK // Return code var p uintptr = uintptr(0) // New tokenizer object _ = pUnused if (nArg % 2) != 0 { - rc = 1 + rc = SQLITE_ERROR } else { p = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Unicode61Tokenizer{}))) if p != 0 { @@ -183697,31 +180832,31 @@ func fts5UnicodeCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32 var i int32 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(Unicode61Tokenizer{}))) - (*Unicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = 1 + (*Unicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = FTS5_REMOVE_DIACRITICS_SIMPLE (*Unicode61Tokenizer)(unsafe.Pointer(p)).FnFold = 64 (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaFold = Xsqlite3_malloc64(tls, (uint64(uint64((*Unicode61Tokenizer)(unsafe.Pointer(p)).FnFold) * uint64(unsafe.Sizeof(int8(0)))))) if (*Unicode61Tokenizer)(unsafe.Pointer(p)).FaFold == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } // Search for a "categories" argument - for i = 0; (rc == 0) && (i < nArg); i = i + (2) { + for i = 0; (rc == SQLITE_OK) && (i < nArg); i = i + (2) { if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), ts+40188 /* "categories" */) { zCat = *(*uintptr)(unsafe.Pointer(azArg + uintptr((i+1))*8)) } } - if rc == 0 { + if rc == SQLITE_OK { rc = unicodeSetCategories(tls, p, zCat) } - for i = 0; (rc == 0) && (i < nArg); i = i + (2) { + for i = 0; (rc == SQLITE_OK) && (i < nArg); i = i + (2) { var zArg uintptr = *(*uintptr)(unsafe.Pointer(azArg + uintptr((i+1))*8)) if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), ts+40199 /* "remove_diacritic..." */) { - if (((int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) != '0') && (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) != '1')) && (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) != '2')) || (*(*int8)(unsafe.Pointer(zArg + uintptr(1))) != 0) { - rc = 1 + if (((int32(*(*int8)(unsafe.Pointer(zArg))) != '0') && (int32(*(*int8)(unsafe.Pointer(zArg))) != '1')) && (int32(*(*int8)(unsafe.Pointer(zArg))) != '2')) || (*(*int8)(unsafe.Pointer(zArg + 1)) != 0) { + rc = SQLITE_ERROR } else { - (*Unicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) - '0') + (*Unicode61Tokenizer)(unsafe.Pointer(p)).FeRemoveDiacritic = (int32(*(*int8)(unsafe.Pointer(zArg))) - '0') } } else if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), ts+40157 /* "tokenchars" */) { @@ -183731,14 +180866,14 @@ func fts5UnicodeCreate(tls *libc.TLS, pUnused uintptr, azArg uintptr, nArg int32 } else if 0 == Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), ts+40188 /* "categories" */) { // no-op } else { - rc = 1 + rc = SQLITE_ERROR } } } else { - rc = 7 + rc = SQLITE_NOMEM } - if rc != 0 { + if rc != SQLITE_OK { fts5UnicodeDelete(tls, p) p = uintptr(0) } @@ -183771,7 +180906,7 @@ func fts5UnicodeTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnuse var is int32 var ie int32 p = pTokenizer - rc = 0 + rc = SQLITE_OK a = p /* &.aTokenChar */ zTerm = (pText + uintptr(nText)) zCsr = pText @@ -183784,7 +180919,7 @@ func fts5UnicodeTokenize(tls *libc.TLS, pTokenizer uintptr, pCtx uintptr, iUnuse // Each iteration of this loop gobbles up a contiguous run of separators, // then the next token. __1: - if !(rc == 0) { + if !(rc == SQLITE_OK) { goto __2 } zOut = aFold @@ -183866,7 +181001,7 @@ __14: if !(aFold == uintptr(0)) { goto __17 } - rc = 7 + rc = SQLITE_NOMEM goto tokenize_done __17: ; @@ -183989,10 +181124,10 @@ __2: ; tokenize_done: - if !(rc == 101) { + if !(rc == SQLITE_DONE) { goto __37 } - rc = 0 + rc = SQLITE_OK __37: ; return rc @@ -184037,13 +181172,13 @@ func fts5PorterCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, pp defer tls.Free(8) var pApi uintptr = pCtx - var rc int32 = 0 + var rc int32 = SQLITE_OK var pRet uintptr *(*uintptr)(unsafe.Pointer(bp /* pUserdata */)) = uintptr(0) var zBase uintptr = ts + 40217 /* "unicode61" */ if nArg > 0 { - zBase = *(*uintptr)(unsafe.Pointer(azArg + uintptr(0)*8)) + zBase = *(*uintptr)(unsafe.Pointer(azArg)) } pRet = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(PorterTokenizer{}))) @@ -184051,9 +181186,9 @@ func fts5PorterCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, pp libc.Xmemset(tls, pRet, 0, uint64(unsafe.Sizeof(PorterTokenizer{}))) rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 16 /* &.xFindTokenizer */))))(tls, pApi, zBase, bp /* &pUserdata */, (pRet /* &.tokenizer */)) } else { - rc = 7 + rc = SQLITE_NOMEM } - if rc == 0 { + if rc == SQLITE_OK { var nArg2 int32 = func() int32 { if nArg > 0 { return (nArg - 1) @@ -184062,14 +181197,14 @@ func fts5PorterCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, pp }() var azArg2 uintptr = func() uintptr { if nArg2 != 0 { - return (azArg + uintptr(1)*8) + return (azArg + 1*8) } return uintptr(0) }() rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pRet /* &.tokenizer */ /* &.xCreate */))))(tls, *(*uintptr)(unsafe.Pointer(bp /* pUserdata */)), azArg2, nArg2, (pRet + 24 /* &.pTokenizer */)) } - if rc != 0 { + if rc != SQLITE_OK { fts5PorterDelete(tls, pRet) pRet = uintptr(0) } @@ -184628,7 +181763,7 @@ func fts5PorterCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nTo var c int8 p = pCtx - if !((nToken > 64) || (nToken < 3)) { + if !((nToken > FTS5_PORTER_MAX_TOKEN) || (nToken < 3)) { goto __1 } goto pass_through @@ -184733,39 +181868,27 @@ func sqlite3Fts5TokenizerInit(tls *libc.TLS, pApi uintptr) int32 { /* sqlite3.c: defer tls.Free(96) *(*[3]BuiltinTokenizer)(unsafe.Pointer(bp /* aBuiltin */)) = [3]BuiltinTokenizer{ - { - FzName: ts + 40217 /* "unicode61" */, Fx: Fts5_tokenizer{ - FxCreate: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{fts5UnicodeCreate})), - FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5UnicodeDelete})), - FxTokenize: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 - }{fts5UnicodeTokenize}))}}, - { - FzName: ts + 40506 /* "ascii" */, Fx: Fts5_tokenizer{ - FxCreate: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{fts5AsciiCreate})), - FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5AsciiDelete})), - FxTokenize: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 - }{fts5AsciiTokenize}))}}, - { - FzName: ts + 40512 /* "porter" */, Fx: Fts5_tokenizer{ - FxCreate: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 - }{fts5PorterCreate})), - FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5PorterDelete})), - FxTokenize: *(*uintptr)(unsafe.Pointer(&struct { - f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 - }{fts5PorterTokenize}))}}, + {FzName: ts + 40217 /* "unicode61" */, Fx: Fts5_tokenizer{FxCreate: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{fts5UnicodeCreate})), FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5UnicodeDelete})), FxTokenize: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 + }{fts5UnicodeTokenize}))}}, + {FzName: ts + 40506 /* "ascii" */, Fx: Fts5_tokenizer{FxCreate: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{fts5AsciiCreate})), FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5AsciiDelete})), FxTokenize: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 + }{fts5AsciiTokenize}))}}, + {FzName: ts + 40512 /* "porter" */, Fx: Fts5_tokenizer{FxCreate: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 + }{fts5PorterCreate})), FxDelete: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{fts5PorterDelete})), FxTokenize: *(*uintptr)(unsafe.Pointer(&struct { + f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 + }{fts5PorterTokenize}))}}, } - var rc int32 = 0 // Return code - var i int32 // To iterate through builtin functions + var rc int32 = SQLITE_OK // Return code + var i int32 // To iterate through builtin functions - for i = 0; (rc == 0) && (i < (int32(uint64(unsafe.Sizeof([3]BuiltinTokenizer{})) / uint64(unsafe.Sizeof(BuiltinTokenizer{}))))); i++ { + for i = 0; (rc == SQLITE_OK) && (i < (int32(uint64(unsafe.Sizeof([3]BuiltinTokenizer{})) / uint64(unsafe.Sizeof(BuiltinTokenizer{}))))); i++ { rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 8 /* &.xCreateTokenizer */))))(tls, pApi, (*BuiltinTokenizer)(unsafe.Pointer(bp /* &aBuiltin */ +uintptr(i)*32)).FzName, pApi, @@ -184956,550 +182079,61 @@ type TableEntry = struct { } /* sqlite3.c:228431:16 */ var aEntry = [163]TableEntry{ - { - FiCode: uint16(65), - Fflags: uint8(14), - FnRange: uint8(26)}, { - FiCode: uint16(181), - Fflags: uint8(64), - FnRange: uint8(1)}, { - FiCode: uint16(192), - Fflags: uint8(14), - FnRange: uint8(23)}, - { - FiCode: uint16(216), - Fflags: uint8(14), - FnRange: uint8(7)}, { - FiCode: uint16(256), - Fflags: uint8(1), - FnRange: uint8(48)}, { - FiCode: uint16(306), - Fflags: uint8(1), - FnRange: uint8(6)}, - { - FiCode: uint16(313), - Fflags: uint8(1), - FnRange: uint8(16)}, { - FiCode: uint16(330), - Fflags: uint8(1), - FnRange: uint8(46)}, { - FiCode: uint16(376), - Fflags: uint8(116), - FnRange: uint8(1)}, - { - FiCode: uint16(377), - Fflags: uint8(1), - FnRange: uint8(6)}, { - FiCode: uint16(383), - Fflags: uint8(104), - FnRange: uint8(1)}, { - FiCode: uint16(385), - Fflags: uint8(50), - FnRange: uint8(1)}, - { - FiCode: uint16(386), - Fflags: uint8(1), - FnRange: uint8(4)}, { - FiCode: uint16(390), - Fflags: uint8(44), - FnRange: uint8(1)}, { - FiCode: uint16(391), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(393), - Fflags: uint8(42), - FnRange: uint8(2)}, { - FiCode: uint16(395), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(398), - Fflags: uint8(32), - FnRange: uint8(1)}, - { - FiCode: uint16(399), - Fflags: uint8(38), - FnRange: uint8(1)}, { - FiCode: uint16(400), - Fflags: uint8(40), - FnRange: uint8(1)}, { - FiCode: uint16(401), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(403), - Fflags: uint8(42), - FnRange: uint8(1)}, { - FiCode: uint16(404), - Fflags: uint8(46), - FnRange: uint8(1)}, { - FiCode: uint16(406), - Fflags: uint8(52), - FnRange: uint8(1)}, - { - FiCode: uint16(407), - Fflags: uint8(48), - FnRange: uint8(1)}, { - FiCode: uint16(408), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(412), - Fflags: uint8(52), - FnRange: uint8(1)}, - { - FiCode: uint16(413), - Fflags: uint8(54), - FnRange: uint8(1)}, { - FiCode: uint16(415), - Fflags: uint8(56), - FnRange: uint8(1)}, { - FiCode: uint16(416), - Fflags: uint8(1), - FnRange: uint8(6)}, - { - FiCode: uint16(422), - Fflags: uint8(60), - FnRange: uint8(1)}, { - FiCode: uint16(423), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(425), - Fflags: uint8(60), - FnRange: uint8(1)}, - { - FiCode: uint16(428), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(430), - Fflags: uint8(60), - FnRange: uint8(1)}, { - FiCode: uint16(431), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(433), - Fflags: uint8(58), - FnRange: uint8(2)}, { - FiCode: uint16(435), - Fflags: uint8(1), - FnRange: uint8(4)}, { - FiCode: uint16(439), - Fflags: uint8(62), - FnRange: uint8(1)}, - { - FiCode: uint16(440), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(444), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(452), - Fflags: uint8(2), - FnRange: uint8(1)}, - { - FiCode: uint16(453), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(455), - Fflags: uint8(2), - FnRange: uint8(1)}, { - FiCode: uint16(456), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(458), - Fflags: uint8(2), - FnRange: uint8(1)}, { - FiCode: uint16(459), - Fflags: uint8(1), - FnRange: uint8(18)}, { - FiCode: uint16(478), - Fflags: uint8(1), - FnRange: uint8(18)}, - { - FiCode: uint16(497), - Fflags: uint8(2), - FnRange: uint8(1)}, { - FiCode: uint16(498), - Fflags: uint8(1), - FnRange: uint8(4)}, { - FiCode: uint16(502), - Fflags: uint8(122), - FnRange: uint8(1)}, - { - FiCode: uint16(503), - Fflags: uint8(134), - FnRange: uint8(1)}, { - FiCode: uint16(504), - Fflags: uint8(1), - FnRange: uint8(40)}, { - FiCode: uint16(544), - Fflags: uint8(110), - FnRange: uint8(1)}, - { - FiCode: uint16(546), - Fflags: uint8(1), - FnRange: uint8(18)}, { - FiCode: uint16(570), - Fflags: uint8(70), - FnRange: uint8(1)}, { - FiCode: uint16(571), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(573), - Fflags: uint8(108), - FnRange: uint8(1)}, { - FiCode: uint16(574), - Fflags: uint8(68), - FnRange: uint8(1)}, { - FiCode: uint16(577), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(579), - Fflags: uint8(106), - FnRange: uint8(1)}, { - FiCode: uint16(580), - Fflags: uint8(28), - FnRange: uint8(1)}, { - FiCode: uint16(581), - Fflags: uint8(30), - FnRange: uint8(1)}, - { - FiCode: uint16(582), - Fflags: uint8(1), - FnRange: uint8(10)}, { - FiCode: uint16(837), - Fflags: uint8(36), - FnRange: uint8(1)}, { - FiCode: uint16(880), - Fflags: uint8(1), - FnRange: uint8(4)}, - { - FiCode: uint16(886), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(902), - Fflags: uint8(18), - FnRange: uint8(1)}, { - FiCode: uint16(904), - Fflags: uint8(16), - FnRange: uint8(3)}, - { - FiCode: uint16(908), - Fflags: uint8(26), - FnRange: uint8(1)}, { - FiCode: uint16(910), - Fflags: uint8(24), - FnRange: uint8(2)}, { - FiCode: uint16(913), - Fflags: uint8(14), - FnRange: uint8(17)}, - { - FiCode: uint16(931), - Fflags: uint8(14), - FnRange: uint8(9)}, { - FiCode: uint16(962), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(975), - Fflags: uint8(4), - FnRange: uint8(1)}, - { - FiCode: uint16(976), - Fflags: uint8(140), - FnRange: uint8(1)}, { - FiCode: uint16(977), - Fflags: uint8(142), - FnRange: uint8(1)}, { - FiCode: uint16(981), - Fflags: uint8(146), - FnRange: uint8(1)}, - { - FiCode: uint16(982), - Fflags: uint8(144), - FnRange: uint8(1)}, { - FiCode: uint16(984), - Fflags: uint8(1), - FnRange: uint8(24)}, { - FiCode: uint16(1008), - Fflags: uint8(136), - FnRange: uint8(1)}, - { - FiCode: uint16(1009), - Fflags: uint8(138), - FnRange: uint8(1)}, { - FiCode: uint16(1012), - Fflags: uint8(130), - FnRange: uint8(1)}, { - FiCode: uint16(1013), - Fflags: uint8(128), - FnRange: uint8(1)}, - { - FiCode: uint16(1015), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(1017), - Fflags: uint8(152), - FnRange: uint8(1)}, { - FiCode: uint16(1018), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(1021), - Fflags: uint8(110), - FnRange: uint8(3)}, { - FiCode: uint16(1024), - Fflags: uint8(34), - FnRange: uint8(16)}, { - FiCode: uint16(1040), - Fflags: uint8(14), - FnRange: uint8(32)}, - { - FiCode: uint16(1120), - Fflags: uint8(1), - FnRange: uint8(34)}, { - FiCode: uint16(1162), - Fflags: uint8(1), - FnRange: uint8(54)}, { - FiCode: uint16(1216), - Fflags: uint8(6), - FnRange: uint8(1)}, - { - FiCode: uint16(1217), - Fflags: uint8(1), - FnRange: uint8(14)}, { - FiCode: uint16(1232), - Fflags: uint8(1), - FnRange: uint8(88)}, { - FiCode: uint16(1329), - Fflags: uint8(22), - FnRange: uint8(38)}, - { - FiCode: uint16(4256), - Fflags: uint8(66), - FnRange: uint8(38)}, { - FiCode: uint16(4295), - Fflags: uint8(66), - FnRange: uint8(1)}, { - FiCode: uint16(4301), - Fflags: uint8(66), - FnRange: uint8(1)}, - { - FiCode: uint16(7680), - Fflags: uint8(1), - FnRange: uint8(150)}, { - FiCode: uint16(7835), - Fflags: uint8(132), - FnRange: uint8(1)}, { - FiCode: uint16(7838), - Fflags: uint8(96), - FnRange: uint8(1)}, - { - FiCode: uint16(7840), - Fflags: uint8(1), - FnRange: uint8(96)}, { - FiCode: uint16(7944), - Fflags: uint8(150), - FnRange: uint8(8)}, { - FiCode: uint16(7960), - Fflags: uint8(150), - FnRange: uint8(6)}, - { - FiCode: uint16(7976), - Fflags: uint8(150), - FnRange: uint8(8)}, { - FiCode: uint16(7992), - Fflags: uint8(150), - FnRange: uint8(8)}, { - FiCode: uint16(8008), - Fflags: uint8(150), - FnRange: uint8(6)}, - { - FiCode: uint16(8025), - Fflags: uint8(151), - FnRange: uint8(8)}, { - FiCode: uint16(8040), - Fflags: uint8(150), - FnRange: uint8(8)}, { - FiCode: uint16(8072), - Fflags: uint8(150), - FnRange: uint8(8)}, - { - FiCode: uint16(8088), - Fflags: uint8(150), - FnRange: uint8(8)}, { - FiCode: uint16(8104), - Fflags: uint8(150), - FnRange: uint8(8)}, { - FiCode: uint16(8120), - Fflags: uint8(150), - FnRange: uint8(2)}, - { - FiCode: uint16(8122), - Fflags: uint8(126), - FnRange: uint8(2)}, { - FiCode: uint16(8124), - Fflags: uint8(148), - FnRange: uint8(1)}, { - FiCode: uint16(8126), - Fflags: uint8(100), - FnRange: uint8(1)}, - { - FiCode: uint16(8136), - Fflags: uint8(124), - FnRange: uint8(4)}, { - FiCode: uint16(8140), - Fflags: uint8(148), - FnRange: uint8(1)}, { - FiCode: uint16(8152), - Fflags: uint8(150), - FnRange: uint8(2)}, - { - FiCode: uint16(8154), - Fflags: uint8(120), - FnRange: uint8(2)}, { - FiCode: uint16(8168), - Fflags: uint8(150), - FnRange: uint8(2)}, { - FiCode: uint16(8170), - Fflags: uint8(118), - FnRange: uint8(2)}, - { - FiCode: uint16(8172), - Fflags: uint8(152), - FnRange: uint8(1)}, { - FiCode: uint16(8184), - Fflags: uint8(112), - FnRange: uint8(2)}, { - FiCode: uint16(8186), - Fflags: uint8(114), - FnRange: uint8(2)}, - { - FiCode: uint16(8188), - Fflags: uint8(148), - FnRange: uint8(1)}, { - FiCode: uint16(8486), - Fflags: uint8(98), - FnRange: uint8(1)}, { - FiCode: uint16(8490), - Fflags: uint8(92), - FnRange: uint8(1)}, - { - FiCode: uint16(8491), - Fflags: uint8(94), - FnRange: uint8(1)}, { - FiCode: uint16(8498), - Fflags: uint8(12), - FnRange: uint8(1)}, { - FiCode: uint16(8544), - Fflags: uint8(8), - FnRange: uint8(16)}, - { - FiCode: uint16(8579), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(9398), - Fflags: uint8(10), - FnRange: uint8(26)}, { - FiCode: uint16(11264), - Fflags: uint8(22), - FnRange: uint8(47)}, - { - FiCode: uint16(11360), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(11362), - Fflags: uint8(88), - FnRange: uint8(1)}, { - FiCode: uint16(11363), - Fflags: uint8(102), - FnRange: uint8(1)}, - { - FiCode: uint16(11364), - Fflags: uint8(90), - FnRange: uint8(1)}, { - FiCode: uint16(11367), - Fflags: uint8(1), - FnRange: uint8(6)}, { - FiCode: uint16(11373), - Fflags: uint8(84), - FnRange: uint8(1)}, - { - FiCode: uint16(11374), - Fflags: uint8(86), - FnRange: uint8(1)}, { - FiCode: uint16(11375), - Fflags: uint8(80), - FnRange: uint8(1)}, { - FiCode: uint16(11376), - Fflags: uint8(82), - FnRange: uint8(1)}, - { - FiCode: uint16(11378), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(11381), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(11390), - Fflags: uint8(78), - FnRange: uint8(2)}, - { - FiCode: uint16(11392), - Fflags: uint8(1), - FnRange: uint8(100)}, { - FiCode: uint16(11499), - Fflags: uint8(1), - FnRange: uint8(4)}, { - FiCode: uint16(11506), - Fflags: uint8(0), - FnRange: uint8(1)}, - { - FiCode: uint16(42560), - Fflags: uint8(1), - FnRange: uint8(46)}, { - FiCode: uint16(42624), - Fflags: uint8(1), - FnRange: uint8(24)}, { - FiCode: uint16(42786), - Fflags: uint8(1), - FnRange: uint8(14)}, - { - FiCode: uint16(42802), - Fflags: uint8(1), - FnRange: uint8(62)}, { - FiCode: uint16(42873), - Fflags: uint8(1), - FnRange: uint8(4)}, { - FiCode: uint16(42877), - Fflags: uint8(76), - FnRange: uint8(1)}, - { - FiCode: uint16(42878), - Fflags: uint8(1), - FnRange: uint8(10)}, { - FiCode: uint16(42891), - Fflags: uint8(0), - FnRange: uint8(1)}, { - FiCode: uint16(42893), - Fflags: uint8(74), - FnRange: uint8(1)}, - { - FiCode: uint16(42896), - Fflags: uint8(1), - FnRange: uint8(4)}, { - FiCode: uint16(42912), - Fflags: uint8(1), - FnRange: uint8(10)}, { - FiCode: uint16(42922), - Fflags: uint8(72), - FnRange: uint8(1)}, - { - FiCode: uint16(65313), - Fflags: uint8(14), - FnRange: uint8(26)}, + {FiCode: uint16(65), Fflags: uint8(14), FnRange: uint8(26)}, {FiCode: uint16(181), Fflags: uint8(64), FnRange: uint8(1)}, {FiCode: uint16(192), Fflags: uint8(14), FnRange: uint8(23)}, + {FiCode: uint16(216), Fflags: uint8(14), FnRange: uint8(7)}, {FiCode: uint16(256), Fflags: uint8(1), FnRange: uint8(48)}, {FiCode: uint16(306), Fflags: uint8(1), FnRange: uint8(6)}, + {FiCode: uint16(313), Fflags: uint8(1), FnRange: uint8(16)}, {FiCode: uint16(330), Fflags: uint8(1), FnRange: uint8(46)}, {FiCode: uint16(376), Fflags: uint8(116), FnRange: uint8(1)}, + {FiCode: uint16(377), Fflags: uint8(1), FnRange: uint8(6)}, {FiCode: uint16(383), Fflags: uint8(104), FnRange: uint8(1)}, {FiCode: uint16(385), Fflags: uint8(50), FnRange: uint8(1)}, + {FiCode: uint16(386), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(390), Fflags: uint8(44), FnRange: uint8(1)}, {FiCode: uint16(391), FnRange: uint8(1)}, + {FiCode: uint16(393), Fflags: uint8(42), FnRange: uint8(2)}, {FiCode: uint16(395), FnRange: uint8(1)}, {FiCode: uint16(398), Fflags: uint8(32), FnRange: uint8(1)}, + {FiCode: uint16(399), Fflags: uint8(38), FnRange: uint8(1)}, {FiCode: uint16(400), Fflags: uint8(40), FnRange: uint8(1)}, {FiCode: uint16(401), FnRange: uint8(1)}, + {FiCode: uint16(403), Fflags: uint8(42), FnRange: uint8(1)}, {FiCode: uint16(404), Fflags: uint8(46), FnRange: uint8(1)}, {FiCode: uint16(406), Fflags: uint8(52), FnRange: uint8(1)}, + {FiCode: uint16(407), Fflags: uint8(48), FnRange: uint8(1)}, {FiCode: uint16(408), FnRange: uint8(1)}, {FiCode: uint16(412), Fflags: uint8(52), FnRange: uint8(1)}, + {FiCode: uint16(413), Fflags: uint8(54), FnRange: uint8(1)}, {FiCode: uint16(415), Fflags: uint8(56), FnRange: uint8(1)}, {FiCode: uint16(416), Fflags: uint8(1), FnRange: uint8(6)}, + {FiCode: uint16(422), Fflags: uint8(60), FnRange: uint8(1)}, {FiCode: uint16(423), FnRange: uint8(1)}, {FiCode: uint16(425), Fflags: uint8(60), FnRange: uint8(1)}, + {FiCode: uint16(428), FnRange: uint8(1)}, {FiCode: uint16(430), Fflags: uint8(60), FnRange: uint8(1)}, {FiCode: uint16(431), FnRange: uint8(1)}, + {FiCode: uint16(433), Fflags: uint8(58), FnRange: uint8(2)}, {FiCode: uint16(435), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(439), Fflags: uint8(62), FnRange: uint8(1)}, + {FiCode: uint16(440), FnRange: uint8(1)}, {FiCode: uint16(444), FnRange: uint8(1)}, {FiCode: uint16(452), Fflags: uint8(2), FnRange: uint8(1)}, + {FiCode: uint16(453), FnRange: uint8(1)}, {FiCode: uint16(455), Fflags: uint8(2), FnRange: uint8(1)}, {FiCode: uint16(456), FnRange: uint8(1)}, + {FiCode: uint16(458), Fflags: uint8(2), FnRange: uint8(1)}, {FiCode: uint16(459), Fflags: uint8(1), FnRange: uint8(18)}, {FiCode: uint16(478), Fflags: uint8(1), FnRange: uint8(18)}, + {FiCode: uint16(497), Fflags: uint8(2), FnRange: uint8(1)}, {FiCode: uint16(498), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(502), Fflags: uint8(122), FnRange: uint8(1)}, + {FiCode: uint16(503), Fflags: uint8(134), FnRange: uint8(1)}, {FiCode: uint16(504), Fflags: uint8(1), FnRange: uint8(40)}, {FiCode: uint16(544), Fflags: uint8(110), FnRange: uint8(1)}, + {FiCode: uint16(546), Fflags: uint8(1), FnRange: uint8(18)}, {FiCode: uint16(570), Fflags: uint8(70), FnRange: uint8(1)}, {FiCode: uint16(571), FnRange: uint8(1)}, + {FiCode: uint16(573), Fflags: uint8(108), FnRange: uint8(1)}, {FiCode: uint16(574), Fflags: uint8(68), FnRange: uint8(1)}, {FiCode: uint16(577), FnRange: uint8(1)}, + {FiCode: uint16(579), Fflags: uint8(106), FnRange: uint8(1)}, {FiCode: uint16(580), Fflags: uint8(28), FnRange: uint8(1)}, {FiCode: uint16(581), Fflags: uint8(30), FnRange: uint8(1)}, + {FiCode: uint16(582), Fflags: uint8(1), FnRange: uint8(10)}, {FiCode: uint16(837), Fflags: uint8(36), FnRange: uint8(1)}, {FiCode: uint16(880), Fflags: uint8(1), FnRange: uint8(4)}, + {FiCode: uint16(886), FnRange: uint8(1)}, {FiCode: uint16(902), Fflags: uint8(18), FnRange: uint8(1)}, {FiCode: uint16(904), Fflags: uint8(16), FnRange: uint8(3)}, + {FiCode: uint16(908), Fflags: uint8(26), FnRange: uint8(1)}, {FiCode: uint16(910), Fflags: uint8(24), FnRange: uint8(2)}, {FiCode: uint16(913), Fflags: uint8(14), FnRange: uint8(17)}, + {FiCode: uint16(931), Fflags: uint8(14), FnRange: uint8(9)}, {FiCode: uint16(962), FnRange: uint8(1)}, {FiCode: uint16(975), Fflags: uint8(4), FnRange: uint8(1)}, + {FiCode: uint16(976), Fflags: uint8(140), FnRange: uint8(1)}, {FiCode: uint16(977), Fflags: uint8(142), FnRange: uint8(1)}, {FiCode: uint16(981), Fflags: uint8(146), FnRange: uint8(1)}, + {FiCode: uint16(982), Fflags: uint8(144), FnRange: uint8(1)}, {FiCode: uint16(984), Fflags: uint8(1), FnRange: uint8(24)}, {FiCode: uint16(1008), Fflags: uint8(136), FnRange: uint8(1)}, + {FiCode: uint16(1009), Fflags: uint8(138), FnRange: uint8(1)}, {FiCode: uint16(1012), Fflags: uint8(130), FnRange: uint8(1)}, {FiCode: uint16(1013), Fflags: uint8(128), FnRange: uint8(1)}, + {FiCode: uint16(1015), FnRange: uint8(1)}, {FiCode: uint16(1017), Fflags: uint8(152), FnRange: uint8(1)}, {FiCode: uint16(1018), FnRange: uint8(1)}, + {FiCode: uint16(1021), Fflags: uint8(110), FnRange: uint8(3)}, {FiCode: uint16(1024), Fflags: uint8(34), FnRange: uint8(16)}, {FiCode: uint16(1040), Fflags: uint8(14), FnRange: uint8(32)}, + {FiCode: uint16(1120), Fflags: uint8(1), FnRange: uint8(34)}, {FiCode: uint16(1162), Fflags: uint8(1), FnRange: uint8(54)}, {FiCode: uint16(1216), Fflags: uint8(6), FnRange: uint8(1)}, + {FiCode: uint16(1217), Fflags: uint8(1), FnRange: uint8(14)}, {FiCode: uint16(1232), Fflags: uint8(1), FnRange: uint8(88)}, {FiCode: uint16(1329), Fflags: uint8(22), FnRange: uint8(38)}, + {FiCode: uint16(4256), Fflags: uint8(66), FnRange: uint8(38)}, {FiCode: uint16(4295), Fflags: uint8(66), FnRange: uint8(1)}, {FiCode: uint16(4301), Fflags: uint8(66), FnRange: uint8(1)}, + {FiCode: uint16(7680), Fflags: uint8(1), FnRange: uint8(150)}, {FiCode: uint16(7835), Fflags: uint8(132), FnRange: uint8(1)}, {FiCode: uint16(7838), Fflags: uint8(96), FnRange: uint8(1)}, + {FiCode: uint16(7840), Fflags: uint8(1), FnRange: uint8(96)}, {FiCode: uint16(7944), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(7960), Fflags: uint8(150), FnRange: uint8(6)}, + {FiCode: uint16(7976), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(7992), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(8008), Fflags: uint8(150), FnRange: uint8(6)}, + {FiCode: uint16(8025), Fflags: uint8(151), FnRange: uint8(8)}, {FiCode: uint16(8040), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(8072), Fflags: uint8(150), FnRange: uint8(8)}, + {FiCode: uint16(8088), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(8104), Fflags: uint8(150), FnRange: uint8(8)}, {FiCode: uint16(8120), Fflags: uint8(150), FnRange: uint8(2)}, + {FiCode: uint16(8122), Fflags: uint8(126), FnRange: uint8(2)}, {FiCode: uint16(8124), Fflags: uint8(148), FnRange: uint8(1)}, {FiCode: uint16(8126), Fflags: uint8(100), FnRange: uint8(1)}, + {FiCode: uint16(8136), Fflags: uint8(124), FnRange: uint8(4)}, {FiCode: uint16(8140), Fflags: uint8(148), FnRange: uint8(1)}, {FiCode: uint16(8152), Fflags: uint8(150), FnRange: uint8(2)}, + {FiCode: uint16(8154), Fflags: uint8(120), FnRange: uint8(2)}, {FiCode: uint16(8168), Fflags: uint8(150), FnRange: uint8(2)}, {FiCode: uint16(8170), Fflags: uint8(118), FnRange: uint8(2)}, + {FiCode: uint16(8172), Fflags: uint8(152), FnRange: uint8(1)}, {FiCode: uint16(8184), Fflags: uint8(112), FnRange: uint8(2)}, {FiCode: uint16(8186), Fflags: uint8(114), FnRange: uint8(2)}, + {FiCode: uint16(8188), Fflags: uint8(148), FnRange: uint8(1)}, {FiCode: uint16(8486), Fflags: uint8(98), FnRange: uint8(1)}, {FiCode: uint16(8490), Fflags: uint8(92), FnRange: uint8(1)}, + {FiCode: uint16(8491), Fflags: uint8(94), FnRange: uint8(1)}, {FiCode: uint16(8498), Fflags: uint8(12), FnRange: uint8(1)}, {FiCode: uint16(8544), Fflags: uint8(8), FnRange: uint8(16)}, + {FiCode: uint16(8579), FnRange: uint8(1)}, {FiCode: uint16(9398), Fflags: uint8(10), FnRange: uint8(26)}, {FiCode: uint16(11264), Fflags: uint8(22), FnRange: uint8(47)}, + {FiCode: uint16(11360), FnRange: uint8(1)}, {FiCode: uint16(11362), Fflags: uint8(88), FnRange: uint8(1)}, {FiCode: uint16(11363), Fflags: uint8(102), FnRange: uint8(1)}, + {FiCode: uint16(11364), Fflags: uint8(90), FnRange: uint8(1)}, {FiCode: uint16(11367), Fflags: uint8(1), FnRange: uint8(6)}, {FiCode: uint16(11373), Fflags: uint8(84), FnRange: uint8(1)}, + {FiCode: uint16(11374), Fflags: uint8(86), FnRange: uint8(1)}, {FiCode: uint16(11375), Fflags: uint8(80), FnRange: uint8(1)}, {FiCode: uint16(11376), Fflags: uint8(82), FnRange: uint8(1)}, + {FiCode: uint16(11378), FnRange: uint8(1)}, {FiCode: uint16(11381), FnRange: uint8(1)}, {FiCode: uint16(11390), Fflags: uint8(78), FnRange: uint8(2)}, + {FiCode: uint16(11392), Fflags: uint8(1), FnRange: uint8(100)}, {FiCode: uint16(11499), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(11506), FnRange: uint8(1)}, + {FiCode: uint16(42560), Fflags: uint8(1), FnRange: uint8(46)}, {FiCode: uint16(42624), Fflags: uint8(1), FnRange: uint8(24)}, {FiCode: uint16(42786), Fflags: uint8(1), FnRange: uint8(14)}, + {FiCode: uint16(42802), Fflags: uint8(1), FnRange: uint8(62)}, {FiCode: uint16(42873), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(42877), Fflags: uint8(76), FnRange: uint8(1)}, + {FiCode: uint16(42878), Fflags: uint8(1), FnRange: uint8(10)}, {FiCode: uint16(42891), FnRange: uint8(1)}, {FiCode: uint16(42893), Fflags: uint8(74), FnRange: uint8(1)}, + {FiCode: uint16(42896), Fflags: uint8(1), FnRange: uint8(4)}, {FiCode: uint16(42912), Fflags: uint8(1), FnRange: uint8(10)}, {FiCode: uint16(42922), Fflags: uint8(72), FnRange: uint8(1)}, + {FiCode: uint16(65313), Fflags: uint8(14), FnRange: uint8(26)}, } /* sqlite3.c:228435:5 */ var aiOff = [77]uint16{ uint16(1), uint16(2), uint16(8), uint16(15), uint16(16), uint16(26), uint16(28), uint16(32), @@ -185515,31 +182149,31 @@ var aiOff = [77]uint16{ } /* sqlite3.c:228492:31 */ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int32 { /* sqlite3.c:228549:12: */ - *(*U8)(unsafe.Pointer(aArray + uintptr(0))) = U8(1) - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(0)))) { + *(*U8)(unsafe.Pointer(aArray)) = U8(1) + switch int32(*(*int8)(unsafe.Pointer(zCat))) { case 'C': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'c': - *(*U8)(unsafe.Pointer(aArray + uintptr(1))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 1)) = U8(1) break case 'f': - *(*U8)(unsafe.Pointer(aArray + uintptr(2))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 2)) = U8(1) break case 'n': - *(*U8)(unsafe.Pointer(aArray + uintptr(3))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 3)) = U8(1) break case 's': - *(*U8)(unsafe.Pointer(aArray + uintptr(4))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 4)) = U8(1) break case 'o': - *(*U8)(unsafe.Pointer(aArray + uintptr(31))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 31)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(1))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(2))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(3))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(4))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(31))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 1)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 2)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 3)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 4)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 31)) = U8(1) break default: return 1 @@ -185547,32 +182181,32 @@ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int break case 'L': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'l': - *(*U8)(unsafe.Pointer(aArray + uintptr(5))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 5)) = U8(1) break case 'm': - *(*U8)(unsafe.Pointer(aArray + uintptr(6))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 6)) = U8(1) break case 'o': - *(*U8)(unsafe.Pointer(aArray + uintptr(7))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 7)) = U8(1) break case 't': - *(*U8)(unsafe.Pointer(aArray + uintptr(8))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 8)) = U8(1) break case 'u': - *(*U8)(unsafe.Pointer(aArray + uintptr(9))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 9)) = U8(1) break case 'C': - *(*U8)(unsafe.Pointer(aArray + uintptr(30))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 30)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(5))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(6))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(7))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(8))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(9))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(30))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 5)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 6)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 7)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 8)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 9)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 30)) = U8(1) break default: return 1 @@ -185580,20 +182214,20 @@ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int break case 'M': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'c': - *(*U8)(unsafe.Pointer(aArray + uintptr(10))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 10)) = U8(1) break case 'e': - *(*U8)(unsafe.Pointer(aArray + uintptr(11))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 11)) = U8(1) break case 'n': - *(*U8)(unsafe.Pointer(aArray + uintptr(12))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 12)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(10))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(11))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(12))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 10)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 11)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 12)) = U8(1) break default: return 1 @@ -185601,20 +182235,20 @@ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int break case 'N': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'd': - *(*U8)(unsafe.Pointer(aArray + uintptr(13))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 13)) = U8(1) break case 'l': - *(*U8)(unsafe.Pointer(aArray + uintptr(14))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 14)) = U8(1) break case 'o': - *(*U8)(unsafe.Pointer(aArray + uintptr(15))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 15)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(13))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(14))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(15))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 13)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 14)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 15)) = U8(1) break default: return 1 @@ -185622,36 +182256,36 @@ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int break case 'P': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'c': - *(*U8)(unsafe.Pointer(aArray + uintptr(16))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 16)) = U8(1) break case 'd': - *(*U8)(unsafe.Pointer(aArray + uintptr(17))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 17)) = U8(1) break case 'e': - *(*U8)(unsafe.Pointer(aArray + uintptr(18))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 18)) = U8(1) break case 'f': - *(*U8)(unsafe.Pointer(aArray + uintptr(19))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 19)) = U8(1) break case 'i': - *(*U8)(unsafe.Pointer(aArray + uintptr(20))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 20)) = U8(1) break case 'o': - *(*U8)(unsafe.Pointer(aArray + uintptr(21))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 21)) = U8(1) break case 's': - *(*U8)(unsafe.Pointer(aArray + uintptr(22))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 22)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(16))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(17))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(18))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(19))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(20))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(21))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(22))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 16)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 17)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 18)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 19)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 20)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 21)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 22)) = U8(1) break default: return 1 @@ -185659,24 +182293,24 @@ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int break case 'S': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'c': - *(*U8)(unsafe.Pointer(aArray + uintptr(23))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 23)) = U8(1) break case 'k': - *(*U8)(unsafe.Pointer(aArray + uintptr(24))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 24)) = U8(1) break case 'm': - *(*U8)(unsafe.Pointer(aArray + uintptr(25))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 25)) = U8(1) break case 'o': - *(*U8)(unsafe.Pointer(aArray + uintptr(26))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 26)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(23))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(24))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(25))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(26))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 23)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 24)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 25)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 26)) = U8(1) break default: return 1 @@ -185684,20 +182318,20 @@ func sqlite3Fts5UnicodeCatParse(tls *libc.TLS, zCat uintptr, aArray uintptr) int break case 'Z': - switch int32(*(*int8)(unsafe.Pointer(zCat + uintptr(1)))) { + switch int32(*(*int8)(unsafe.Pointer(zCat + 1))) { case 'l': - *(*U8)(unsafe.Pointer(aArray + uintptr(27))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 27)) = U8(1) break case 'p': - *(*U8)(unsafe.Pointer(aArray + uintptr(28))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 28)) = U8(1) break case 's': - *(*U8)(unsafe.Pointer(aArray + uintptr(29))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 29)) = U8(1) break case '*': - *(*U8)(unsafe.Pointer(aArray + uintptr(27))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(28))) = U8(1) - *(*U8)(unsafe.Pointer(aArray + uintptr(29))) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 27)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 28)) = U8(1) + *(*U8)(unsafe.Pointer(aArray + 29)) = U8(1) break default: return 1 @@ -186247,7 +182881,7 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c a = a | (U32(*(*uint8)(unsafe.Pointer(p)))) // a: p0<<14 | p2 (unmasked) if !((a & U32(0x80)) != 0) { - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) b = b & (U32(0x7f)) b = (b << 7) a = a | (b) @@ -186256,13 +182890,13 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c } // CSE1 from below - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) p++ b = (b << 14) b = b | (U32(*(*uint8)(unsafe.Pointer(p)))) // b: p1<<14 | p3 (unmasked) if !((b & U32(0x80)) != 0) { - b = b & (U32(0x001fc07f)) + b = b & (SLOT_2_0) // moved CSE1 up // a &= (0x7f<<14)|(0x7f); a = (a << 7) @@ -186276,7 +182910,7 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c // 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) // moved CSE1 up // a &= (0x7f<<14)|(0x7f); - b = b & (U32(0x001fc07f)) + b = b & (SLOT_2_0) s = a // s: p0<<14 | p2 (masked) @@ -186307,7 +182941,7 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c if !((b & U32(0x80)) != 0) { // we can skip this cause it was (effectively) done above in calc'ing s // b &= (0x7f<<28)|(0x7f<<14)|(0x7f); - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) a = (a << 7) a = a | (b) s = (s >> 18) @@ -186320,8 +182954,8 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c a = a | (U32(*(*uint8)(unsafe.Pointer(p)))) // a: p2<<28 | p4<<14 | p6 (unmasked) if !((a & U32(0x80)) != 0) { - a = a & (0xf01fc07f) - b = b & (U32(0x001fc07f)) + a = a & (SLOT_4_2_0) + b = b & (SLOT_2_0) b = (b << 7) a = a | (b) s = (s >> 11) @@ -186330,13 +182964,13 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c } // CSE2 from below - a = a & (U32(0x001fc07f)) + a = a & (SLOT_2_0) p++ b = (b << 14) b = b | (U32(*(*uint8)(unsafe.Pointer(p)))) // b: p3<<28 | p5<<14 | p7 (unmasked) if !((b & U32(0x80)) != 0) { - b = b & (0xf01fc07f) + b = b & (SLOT_4_2_0) // moved CSE2 up // a &= (0x7f<<14)|(0x7f); a = (a << 7) @@ -186353,7 +182987,7 @@ func sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) U8 { /* sqlite3.c // moved CSE2 up // a &= (0x7f<<29)|(0x7f<<15)|(0xff); - b = b & (U32(0x001fc07f)) + b = b & (SLOT_2_0) b = (b << 8) a = a | (b) @@ -186403,7 +183037,7 @@ func fts5PutVarint64(tls *libc.TLS, p uintptr, v U64) int32 { /* sqlite3.c:22936 // var buf [10]U8 at bp, 10 if (v & (U64((uint64(0xff000000))) << 32)) != 0 { - *(*uint8)(unsafe.Pointer(p + uintptr(8))) = U8(v) + *(*uint8)(unsafe.Pointer(p + 8)) = U8(v) v >>= 8 for i = 7; i >= 0; i-- { *(*uint8)(unsafe.Pointer(p + uintptr(i))) = (U8((v & uint64(0x7f)) | uint64(0x80))) @@ -186416,7 +183050,7 @@ func fts5PutVarint64(tls *libc.TLS, p uintptr, v U64) int32 { /* sqlite3.c:22936 *(*U8)(unsafe.Pointer(bp /* &buf[0] */ + uintptr(libc.PostIncInt32(&n, 1)))) = (U8((v & uint64(0x7f)) | uint64(0x80))) v >>= 7 } - *(*U8)(unsafe.Pointer(bp /* &buf */ + uintptr(0))) &= U8((0x7f)) + *(*U8)(unsafe.Pointer(bp /* &buf */)) &= U8((0x7f)) i = 0 j = (n - 1) @@ -186441,12 +183075,12 @@ __3: func sqlite3Fts5PutVarint(tls *libc.TLS, p uintptr, v U64) int32 { /* sqlite3.c:229394:12: */ if v <= uint64(0x7f) { - *(*uint8)(unsafe.Pointer(p + uintptr(0))) = (uint8(v & uint64(0x7f))) + *(*uint8)(unsafe.Pointer(p)) = (uint8(v & uint64(0x7f))) return 1 } if v <= uint64(0x3fff) { - *(*uint8)(unsafe.Pointer(p + uintptr(0))) = (uint8(((v >> 7) & uint64(0x7f)) | uint64(0x80))) - *(*uint8)(unsafe.Pointer(p + uintptr(1))) = (uint8(v & uint64(0x7f))) + *(*uint8)(unsafe.Pointer(p)) = (uint8(((v >> 7) & uint64(0x7f)) | uint64(0x80))) + *(*uint8)(unsafe.Pointer(p + 1)) = (uint8(v & uint64(0x7f))) return 2 } return fts5PutVarint64(tls, p, v) @@ -186586,19 +183220,19 @@ func fts5VocabTableType(tls *libc.TLS, zType uintptr, pzErr uintptr, peType uint bp := tls.Alloc(12) defer tls.Free(12) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK var zCopy uintptr = sqlite3Fts5Strndup(tls, bp+8 /* &rc */, zType, -1) - if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK { sqlite3Fts5Dequote(tls, zCopy) if Xsqlite3_stricmp(tls, zCopy, ts+40519 /* "col" */) == 0 { - *(*int32)(unsafe.Pointer(peType)) = 0 + *(*int32)(unsafe.Pointer(peType)) = FTS5_VOCAB_COL } else if Xsqlite3_stricmp(tls, zCopy, ts+40523 /* "row" */) == 0 { - *(*int32)(unsafe.Pointer(peType)) = 1 + *(*int32)(unsafe.Pointer(peType)) = FTS5_VOCAB_ROW } else if Xsqlite3_stricmp(tls, zCopy, ts+40527 /* "instance" */) == 0 { - *(*int32)(unsafe.Pointer(peType)) = 2 + *(*int32)(unsafe.Pointer(peType)) = FTS5_VOCAB_INSTANCE } else { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+40536 /* "fts5vocab: unkno..." */, libc.VaList(bp, zCopy)) - *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_ERROR } Xsqlite3_free(tls, zCopy) } @@ -186610,14 +183244,14 @@ func fts5VocabTableType(tls *libc.TLS, zType uintptr, pzErr uintptr, peType uint func fts5VocabDisconnectMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:229550:12: */ var pTab uintptr = pVtab Xsqlite3_free(tls, pTab) - return 0 + return SQLITE_OK } // The xDestroy() virtual table method. func fts5VocabDestroyMethod(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:229559:12: */ var pTab uintptr = pVtab Xsqlite3_free(tls, pTab) - return 0 + return SQLITE_OK } // This function is the implementation of both the xConnect and xCreate @@ -186650,40 +183284,40 @@ func fts5VocabInitVtab(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv } var pRet uintptr = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = 0 // Return code + *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = SQLITE_OK // Return code var bDb int32 - bDb = (libc.Bool32(((argc == 6) && (libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8))) == uint64(4))) && (libc.Xmemcmp(tls, ts+24978 /* "temp" */, *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)), uint64(4)) == 0))) + bDb = (libc.Bool32(((argc == 6) && (libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) == uint64(4))) && (libc.Xmemcmp(tls, ts+24978 /* "temp" */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uint64(4)) == 0))) if (argc != 5) && (bDb == 0) { *(*uintptr)(unsafe.Pointer(pzErr)) = Xsqlite3_mprintf(tls, ts+40688 /* "wrong number of ..." */, 0) - *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = SQLITE_ERROR } else { var nByte int32 // Bytes of space to allocate var zDb uintptr if bDb != 0 { - zDb = *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)) + zDb = *(*uintptr)(unsafe.Pointer(argv + 3*8)) } else { - zDb = *(*uintptr)(unsafe.Pointer(argv + uintptr(1)*8)) + zDb = *(*uintptr)(unsafe.Pointer(argv + 1*8)) } var zTab uintptr if bDb != 0 { - zTab = *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)) + zTab = *(*uintptr)(unsafe.Pointer(argv + 4*8)) } else { - zTab = *(*uintptr)(unsafe.Pointer(argv + uintptr(3)*8)) + zTab = *(*uintptr)(unsafe.Pointer(argv + 3*8)) } var zType uintptr if bDb != 0 { - zType = *(*uintptr)(unsafe.Pointer(argv + uintptr(5)*8)) + zType = *(*uintptr)(unsafe.Pointer(argv + 5*8)) } else { - zType = *(*uintptr)(unsafe.Pointer(argv + uintptr(4)*8)) + zType = *(*uintptr)(unsafe.Pointer(argv + 4*8)) } var nDb int32 = (int32(libc.Xstrlen(tls, zDb)) + 1) var nTab int32 = (int32(libc.Xstrlen(tls, zTab)) + 1) *(*int32)(unsafe.Pointer(bp /* eType */)) = 0 *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = fts5VocabTableType(tls, zType, pzErr, bp /* &eType */) - if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = Xsqlite3_declare_vtab(tls, db, *(*uintptr)(unsafe.Pointer(bp + 8 /* &azSchema[0] */ + uintptr(*(*int32)(unsafe.Pointer(bp /* eType */)))*8))) } @@ -186694,7 +183328,7 @@ func fts5VocabInitVtab(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv (*Fts5VocabTable)(unsafe.Pointer(pRet)).FpGlobal = pAux (*Fts5VocabTable)(unsafe.Pointer(pRet)).FeType = *(*int32)(unsafe.Pointer(bp /* eType */)) (*Fts5VocabTable)(unsafe.Pointer(pRet)).Fdb = db - (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl = (pRet + uintptr(1)*64) + (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl = (pRet + 1*64) (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db = ((*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl + uintptr(nTab)) libc.Xmemcpy(tls, (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Tbl, zTab, uint64(nTab)) libc.Xmemcpy(tls, (*Fts5VocabTable)(unsafe.Pointer(pRet)).FzFts5Db, zDb, uint64(nDb)) @@ -186743,37 +183377,37 @@ func fts5VocabBestIndexMethod(tls *libc.TLS, pUnused uintptr, pInfo uintptr) int continue } if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0 { // term column - if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 2 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ { iTermEq = i } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 8 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_LE { iTermLe = i } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 16 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_LT { iTermLe = i } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 32 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_GE { iTermGe = i } - if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == 4 { + if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_GT { iTermGe = i } } } if iTermEq >= 0 { - idxNum = idxNum | (0x01) + idxNum = idxNum | (FTS5_VOCAB_TERM_EQ) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(iTermEq)*8)).FargvIndex = libc.PreIncInt32(&nArg, 1) (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(100) } else { (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(1000000) if iTermGe >= 0 { - idxNum = idxNum | (0x02) + idxNum = idxNum | (FTS5_VOCAB_TERM_GE) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(iTermGe)*8)).FargvIndex = libc.PreIncInt32(&nArg, 1) (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = ((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / float64(2)) } if iTermLe >= 0 { - idxNum = idxNum | (0x04) + idxNum = idxNum | (FTS5_VOCAB_TERM_LE) (*sqlite3_index_constraint_usage)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(iTermLe)*8)).FargvIndex = libc.PreIncInt32(&nArg, 1) (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = ((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost / float64(2)) } @@ -186785,13 +183419,13 @@ func fts5VocabBestIndexMethod(tls *libc.TLS, pUnused uintptr, pInfo uintptr) int // sqlite3_index_info.orderByConsumed flag to tell the core the results // are already in sorted order. if (((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FnOrderBy == 1) && - ((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy+uintptr(0)*8)).FiColumn == 0)) && - (int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy+uintptr(0)*8)).Fdesc) == 0) { + ((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy)).FiColumn == 0)) && + (int32((*sqlite3_index_orderby)(unsafe.Pointer((*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FaOrderBy)).Fdesc) == 0) { (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).ForderByConsumed = 1 } (*Sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = idxNum - return 0 + return SQLITE_OK } // Implementation of xOpen method. @@ -186802,14 +183436,14 @@ func fts5VocabOpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 { /* var pTab uintptr = pVTab var pFts5 uintptr = uintptr(0) var pCsr uintptr = uintptr(0) - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_OK *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)) = uintptr(0) var zSql uintptr = uintptr(0) if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FbBusy != 0 { (*Sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+40721 /* "recursive defini..." */, libc.VaList(bp, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Db, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl)) - return 1 + return SQLITE_ERROR } zSql = sqlite3Fts5Mprintf(tls, bp+64, /* &rc */ ts+40752, /* "SELECT t.%Q FROM..." */ @@ -186819,32 +183453,32 @@ func fts5VocabOpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 { /* } Xsqlite3_free(tls, zSql) - if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 1 { - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 0 + if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_ERROR { + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_OK } (*Fts5VocabTable)(unsafe.Pointer(pTab)).FbBusy = uint32(1) - if (*(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)) != 0) && (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) == 100) { + if (*(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)) != 0) && (Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) == SQLITE_ROW) { var iId I64 = Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)), 0) pFts5 = sqlite3Fts5TableFromCsrid(tls, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FpGlobal, iId) } (*Fts5VocabTable)(unsafe.Pointer(pTab)).FbBusy = uint32(0) - if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK { if pFts5 == uintptr(0) { *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)) = uintptr(0) - if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK { (*Sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = Xsqlite3_mprintf(tls, ts+40803 /* "no such fts5 tab..." */, libc.VaList(bp+48, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Db, (*Fts5VocabTable)(unsafe.Pointer(pTab)).FzFts5Tbl)) - *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 1 + *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR } } else { *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = sqlite3Fts5FlushToDisk(tls, pFts5) } } - if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK { var nByte int32 = (int32(((uint64((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pFts5)).FpConfig)).FnCol) * uint64(unsafe.Sizeof(I64(0)))) * uint64(2)) + uint64(unsafe.Sizeof(Fts5VocabCursor{})))) pCsr = sqlite3Fts5MallocZero(tls, bp+64 /* &rc */, int64(nByte)) } @@ -186852,7 +183486,7 @@ func fts5VocabOpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 { /* if pCsr != 0 { (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5 = pFts5 (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpStmt = *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)) - (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt = (pCsr + uintptr(1)*120) + (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt = (pCsr + 1*120) (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc = ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer(pFts5)).FpConfig)).FnCol)*8) } else { Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) @@ -186880,14 +183514,14 @@ func fts5VocabCloseMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:2 sqlite3Fts5BufferFree(tls, (pCsr + 88 /* &.term */)) Xsqlite3_finalize(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpStmt) Xsqlite3_free(tls, pCsr) - return 0 + return SQLITE_OK } func fts5VocabInstanceNewTerm(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:229834:12: */ bp := tls.Alloc(8) defer tls.Free(8) - *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = SQLITE_OK if (*Fts5IndexIter)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FbEof != 0 { (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = 1 @@ -186916,20 +183550,20 @@ func fts5VocabInstanceNewTerm(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c: func fts5VocabInstanceNext(tls *libc.TLS, pCsr uintptr) int32 { /* sqlite3.c:229856:12: */ var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail - var rc int32 = 0 + var rc int32 = SQLITE_OK var pIter uintptr = (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter var pp uintptr = (pCsr + 104 /* &.iInstPos */) var po uintptr = (pCsr + 112 /* &.iInstOff */) - for (eDetail == 1) || + for (eDetail == FTS5_DETAIL_NONE) || (sqlite3Fts5PoslistNext64(tls, (*Fts5IndexIter)(unsafe.Pointer(pIter)).FpData, (*Fts5IndexIter)(unsafe.Pointer(pIter)).FnData, po, pp) != 0) { (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos = int64(0) (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstOff = 0 rc = sqlite3Fts5IterNextScan(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter) - if rc == 0 { + if rc == SQLITE_OK { rc = fts5VocabInstanceNewTerm(tls, pCsr) - if ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0) || (eDetail == 1) { + if ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0) || (eDetail == FTS5_DETAIL_NONE) { break } } @@ -186949,16 +183583,16 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 var pCsr uintptr = pCursor var pTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab - *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = 0 + *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = SQLITE_OK var nCol int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FnCol (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid++ - if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == 2 { + if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_INSTANCE { return fts5VocabInstanceNext(tls, pCsr) } - if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == 0 { + if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_COL { for (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol++; (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol < nCol; (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol++ { if *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) != 0 { break @@ -186966,7 +183600,7 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 } } - if ((*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType != 0) || ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol >= nCol) { + if ((*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType != FTS5_VOCAB_COL) || ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol >= nCol) { if (*Fts5IndexIter)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FbEof != 0 { (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = 1 } else { @@ -186985,7 +183619,7 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 var bCmp int32 = libc.Xmemcmp(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm, zTerm, uint64(nCmp)) if (bCmp < 0) || ((bCmp == 0) && ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm < *(*int32)(unsafe.Pointer(bp /* nTerm */)))) { (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof = 1 - return 0 + return SQLITE_OK } } @@ -186994,7 +183628,7 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 libc.Xmemset(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc, 0, (uint64(nCol) * uint64(unsafe.Sizeof(I64(0))))) (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol = 0 - for *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + for *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { var eDetail int32 = (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail var pPos uintptr var nPos int32 // Position list @@ -187005,24 +183639,24 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 nPos = (*Fts5IndexIter)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter)).FnData switch (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType { - case 1: - if eDetail == 0 { + case FTS5_VOCAB_ROW: + if eDetail == FTS5_DETAIL_FULL { for 0 == sqlite3Fts5PoslistNext64(tls, pPos, nPos, bp+8 /* &iOff */, bp+16 /* &iPos */) { - *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr(0)*8))++ + *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt))++ } } - *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr(0)*8))++ + *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc))++ break fallthrough - case 0: - if eDetail == 0 { + case FTS5_VOCAB_COL: + if eDetail == FTS5_DETAIL_FULL { var iCol int32 = -1 for 0 == sqlite3Fts5PoslistNext64(tls, pPos, nPos, bp+8 /* &iOff */, bp+16 /* &iPos */) { var ii int32 = (int32(*(*I64)(unsafe.Pointer(bp + 16 /* iPos */)) >> 32)) if iCol != ii { if ii >= nCol { - *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) break } *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr(ii)*8))++ @@ -187030,18 +183664,18 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 } *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr(ii)*8))++ } - } else if eDetail == 2 { + } else if eDetail == FTS5_DETAIL_COLUMNS { for 0 == sqlite3Fts5PoslistNext64(tls, pPos, nPos, bp+8 /* &iOff */, bp+16 /* &iPos */) { if *(*I64)(unsafe.Pointer(bp + 16 /* iPos */)) >= I64(nCol) { - *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) break } *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr(*(*I64)(unsafe.Pointer(bp + 16 /* iPos */)))*8))++ } } else { - *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr(0)*8))++ + *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc))++ } break fallthrough @@ -187051,14 +183685,14 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 break } - if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = sqlite3Fts5IterNextScan(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter) } - if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == 2 { + if (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_INSTANCE { break } - if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0 { + if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { zTerm = sqlite3Fts5IterTerm(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpIter, bp /* &nTerm */) if (*(*int32)(unsafe.Pointer(bp /* nTerm */)) != (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fn) || ((*(*int32)(unsafe.Pointer(bp /* nTerm */)) > 0) && (libc.Xmemcmp(tls, zTerm, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fp, uint64(*(*int32)(unsafe.Pointer(bp /* nTerm */)))) != 0)) { @@ -187072,11 +183706,11 @@ func fts5VocabNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* sqlite3.c:22 } } - if ((*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == 0) && ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof == 0)) && ((*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == 0) { + if ((*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK) && ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof == 0)) && ((*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType == FTS5_VOCAB_COL) { for ; ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol < nCol) && (*(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) == int64(0)); (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol++ { } if (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol == nCol { - *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = (11 | (int32(1) << 8)) + *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = (SQLITE_CORRUPT | (int32(1) << 8)) } } return *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) @@ -187087,10 +183721,10 @@ func fts5VocabFilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, zUnused var pTab uintptr = (*Sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab var pCsr uintptr = pCursor var eType int32 = (*Fts5VocabTable)(unsafe.Pointer(pTab)).FeType - var rc int32 = 0 + var rc int32 = SQLITE_OK var iVal int32 = 0 - var f int32 = 0x0008 + var f int32 = FTS5INDEX_QUERY_SCAN var zTerm uintptr = uintptr(0) var nTerm int32 = 0 @@ -187102,13 +183736,13 @@ func fts5VocabFilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, zUnused _ = nUnused fts5VocabResetCursor(tls, pCsr) - if (idxNum & 0x01) != 0 { + if (idxNum & FTS5_VOCAB_TERM_EQ) != 0 { pEq = *(*uintptr)(unsafe.Pointer(apVal + uintptr(libc.PostIncInt32(&iVal, 1))*8)) } - if (idxNum & 0x02) != 0 { + if (idxNum & FTS5_VOCAB_TERM_GE) != 0 { pGe = *(*uintptr)(unsafe.Pointer(apVal + uintptr(libc.PostIncInt32(&iVal, 1))*8)) } - if (idxNum & 0x04) != 0 { + if (idxNum & FTS5_VOCAB_TERM_LE) != 0 { pLe = *(*uintptr)(unsafe.Pointer(apVal + uintptr(libc.PostIncInt32(&iVal, 1))*8)) } @@ -187129,23 +183763,23 @@ func fts5VocabFilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, zUnused (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm = Xsqlite3_value_bytes(tls, pLe) (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm = Xsqlite3_malloc(tls, ((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm + 1)) if (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm == uintptr(0) { - rc = 7 + rc = SQLITE_NOMEM } else { libc.Xmemcpy(tls, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FzLeTerm, zCopy, (uint64((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FnLeTerm + 1))) } } } - if rc == 0 { + if rc == SQLITE_OK { var pIndex uintptr = (*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpIndex rc = sqlite3Fts5IndexQuery(tls, pIndex, zTerm, nTerm, f, uintptr(0), (pCsr + 32 /* &.pIter */)) } - if (rc == 0) && (eType == 2) { + if (rc == SQLITE_OK) && (eType == FTS5_VOCAB_INSTANCE) { rc = fts5VocabInstanceNewTerm(tls, pCsr) } - if ((rc == 0) && !((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0)) && - ((eType != 2) || - ((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail != 1)) { + if ((rc == SQLITE_OK) && !((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof != 0)) && + ((eType != FTS5_VOCAB_INSTANCE) || + ((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FeDetail != FTS5_DETAIL_NONE)) { rc = fts5VocabNextMethod(tls, pCursor) } @@ -187168,10 +183802,10 @@ func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol in if iCol == 0 { Xsqlite3_result_text(tls, pCtx, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fp, (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Fterm.Fn, libc.UintptrFromInt32(-1)) - } else if eType == 0 { + } else if eType == FTS5_VOCAB_COL { if iCol == 1 { - if eDetail != 1 { + if eDetail != FTS5_DETAIL_NONE { var z uintptr = *(*uintptr)(unsafe.Pointer((*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FazCol + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) Xsqlite3_result_text(tls, pCtx, z, -1, uintptr(0)) } @@ -187180,12 +183814,12 @@ func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol in } else { iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiCol)*8)) } - } else if eType == 1 { + } else if eType == FTS5_VOCAB_ROW { if iCol == 1 { - iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc + uintptr(0)*8)) + iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaDoc)) } else { - iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt + uintptr(0)*8)) + iVal = *(*I64)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FaCnt)) } } else { @@ -187197,9 +183831,9 @@ func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol in case 2: { var ii int32 = -1 - if eDetail == 0 { + if eDetail == FTS5_DETAIL_FULL { ii = (int32((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos >> 32)) - } else if eDetail == 2 { + } else if eDetail == FTS5_DETAIL_COLUMNS { ii = int32((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos) } if (ii >= 0) && (ii < (*Fts5Config)(unsafe.Pointer((*Fts5Table)(unsafe.Pointer((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FpFts5)).FpConfig)).FnCol) { @@ -187213,7 +183847,7 @@ func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol in default: { - if eDetail == 0 { + if eDetail == FTS5_DETAIL_FULL { var ii int32 = (int32((*Fts5VocabCursor)(unsafe.Pointer(pCsr)).FiInstPos & int64(0x7FFFFFFF))) Xsqlite3_result_int(tls, pCtx, ii) } @@ -187226,7 +183860,7 @@ func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol in if iVal > int64(0) { Xsqlite3_result_int64(tls, pCtx, iVal) } - return 0 + return SQLITE_OK } // This is the xRowid method. The SQLite core calls this routine to @@ -187235,7 +183869,7 @@ func fts5VocabColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol in func fts5VocabRowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { /* sqlite3.c:230162:12: */ var pCsr uintptr = pCursor *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = (*Fts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid - return 0 + return SQLITE_OK } func sqlite3Fts5VocabInit(tls *libc.TLS, pGlobal uintptr, db uintptr) int32 { /* sqlite3.c:230171:12: */ @@ -187245,54 +183879,19 @@ func sqlite3Fts5VocabInit(tls *libc.TLS, pGlobal uintptr, db uintptr) int32 { /* } var fts5Vocab = Sqlite3_module{ - FiVersion: - /* iVersion */ 2, - FxCreate: - /* xCreate */ 0, - FxConnect: - /* xConnect */ 0, - FxBestIndex: - /* xBestIndex */ 0, - FxDisconnect: - /* xDisconnect */ 0, - FxDestroy: - /* xDestroy */ 0, - FxOpen: - /* xOpen */ 0, - FxClose: - /* xClose */ 0, - FxFilter: - /* xFilter */ 0, - FxNext: - /* xNext */ 0, - FxEof: - /* xEof */ 0, - FxColumn: - /* xColumn */ 0, - FxRowid: - /* xRowid */ 0, - FxUpdate: - /* xUpdate */ uintptr(0), - FxBegin: - /* xBegin */ uintptr(0), - FxSync: - /* xSync */ uintptr(0), - FxCommit: - /* xCommit */ uintptr(0), - FxRollback: - /* xRollback */ uintptr(0), - FxFindFunction: - /* xFindFunction */ uintptr(0), - FxRename: - /* xRename */ uintptr(0), - FxSavepoint: - /* xSavepoint */ uintptr(0), - FxRelease: - /* xRelease */ uintptr(0), - FxRollbackTo: - /* xRollbackTo */ uintptr(0), - FxShadowName: - /* xShadowName */ uintptr(0), + /* iVersion */ FiVersion: 2, + /* xCreate */ FxCreate: 0, + /* xConnect */ FxConnect: 0, + /* xBestIndex */ FxBestIndex: 0, + /* xDisconnect */ FxDisconnect: 0, + /* xDestroy */ FxDestroy: 0, + /* xOpen */ FxOpen: 0, + /* xClose */ FxClose: 0, + /* xFilter */ FxFilter: 0, + /* xNext */ FxNext: 0, + /* xEof */ FxEof: 0, + /* xColumn */ FxColumn: 0, + /* xRowid */ FxRowid: 0, } /* sqlite3.c:230172:31 */ //************* End of fts5.c *********************************************** @@ -187393,11 +183992,11 @@ func stmtConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintp rc = Xsqlite3_declare_vtab(tls, db, ts+40839 /* "CREATE TABLE x(s..." */) - if rc == 0 { + if rc == SQLITE_OK { pNew = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Stmt_vtab{}))) *(*uintptr)(unsafe.Pointer(ppVtab)) = pNew if pNew == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(Stmt_vtab{}))) (*Stmt_vtab)(unsafe.Pointer(pNew)).Fdb = db @@ -187408,7 +184007,7 @@ func stmtConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintp // This method is the destructor for stmt_cursor objects. func stmtDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3.c:230315:12: */ Xsqlite3_free(tls, pVtab) - return 0 + return SQLITE_OK } // Constructor for a new stmt_cursor object. @@ -187416,18 +184015,18 @@ func stmtOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* sqlite3.c:2 var pCur uintptr pCur = Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Stmt_cursor{}))) if pCur == uintptr(0) { - return 7 + return SQLITE_NOMEM } libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(Stmt_cursor{}))) (*Stmt_cursor)(unsafe.Pointer(pCur)).Fdb = (*Stmt_vtab)(unsafe.Pointer(p)).Fdb *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) - return 0 + return SQLITE_OK } // Destructor for a stmt_cursor. func stmtClose(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:230336:12: */ Xsqlite3_free(tls, cur) - return 0 + return SQLITE_OK } // Advance a stmt_cursor to its next row of output. @@ -187435,7 +184034,7 @@ func stmtNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:230345:12: */ var pCur uintptr = cur (*Stmt_cursor)(unsafe.Pointer(pCur)).FiRowid++ (*Stmt_cursor)(unsafe.Pointer(pCur)).FpStmt = Xsqlite3_next_stmt(tls, (*Stmt_cursor)(unsafe.Pointer(pCur)).Fdb, (*Stmt_cursor)(unsafe.Pointer(pCur)).FpStmt) - return 0 + return SQLITE_OK } // Return values of columns for the row at which the stmt_cursor @@ -187443,25 +184042,25 @@ func stmtNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3.c:230345:12: */ func stmtColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* sqlite3.c:230356:12: */ var pCur uintptr = cur switch i { - case 0: + case STMT_COLUMN_SQL: { Xsqlite3_result_text(tls, ctx, Xsqlite3_sql(tls, (*Stmt_cursor)(unsafe.Pointer(pCur)).FpStmt), -1, libc.UintptrFromInt32(-1)) break } - case 1: + case STMT_COLUMN_NCOL: { Xsqlite3_result_int(tls, ctx, Xsqlite3_column_count(tls, (*Stmt_cursor)(unsafe.Pointer(pCur)).FpStmt)) break } - case 2: + case STMT_COLUMN_RO: { Xsqlite3_result_int(tls, ctx, Xsqlite3_stmt_readonly(tls, (*Stmt_cursor)(unsafe.Pointer(pCur)).FpStmt)) break } - case 3: + case STMT_COLUMN_BUSY: { Xsqlite3_result_int(tls, ctx, Xsqlite3_stmt_busy(tls, (*Stmt_cursor)(unsafe.Pointer(pCur)).FpStmt)) break @@ -187470,30 +184069,30 @@ func stmtColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* sql default: { - i = ((99 + 4) - 1) + i = ((SQLITE_STMTSTATUS_MEMUSED + STMT_COLUMN_NSCAN) - SQLITE_STMTSTATUS_FULLSCAN_STEP) // Fall thru } fallthrough - case 4: + case STMT_COLUMN_NSCAN: fallthrough - case 5: + case STMT_COLUMN_NSORT: fallthrough - case 6: + case STMT_COLUMN_NAIDX: fallthrough - case 7: + case STMT_COLUMN_NSTEP: fallthrough - case 8: + case STMT_COLUMN_REPREP: fallthrough - case 9: + case STMT_COLUMN_RUN: { Xsqlite3_result_int(tls, ctx, Xsqlite3_stmt_status(tls, (*Stmt_cursor)(unsafe.Pointer(pCur)).FpStmt, - ((i-4)+1), 0)) + ((i-STMT_COLUMN_NSCAN)+SQLITE_STMTSTATUS_FULLSCAN_STEP), 0)) break } } - return 0 + return SQLITE_OK } // Return the rowid for the current row. In this implementation, the @@ -187501,7 +184100,7 @@ func stmtColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* sql func stmtRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* sqlite3.c:230403:12: */ var pCur uintptr = cur *(*Sqlite_int64)(unsafe.Pointer(pRowid)) = (*Stmt_cursor)(unsafe.Pointer(pCur)).FiRowid - return 0 + return SQLITE_OK } // Return TRUE if the cursor has been moved off of the last @@ -187529,63 +184128,26 @@ func stmtFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr func stmtBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* sqlite3.c:230441:12: */ (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(500) (*Sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(500) - return 0 + return SQLITE_OK } // This following structure defines all the methods for the // stmt virtual table. -var stmtModule = Sqlite3_module{ - FiVersion: 0, - FxCreate:// iVersion - uintptr(0), - FxConnect:// xCreate - 0, - FxBestIndex:// xConnect - 0, - FxDisconnect:// xBestIndex - 0, - FxDestroy:// xDisconnect - uintptr(0), - FxOpen:// xDestroy - 0, - FxClose:// xOpen - open a cursor - 0, - FxFilter:// xClose - close a cursor - 0, - FxNext:// xFilter - configure scan constraints - 0, - FxEof:// xNext - advance a cursor - 0, - FxColumn:// xEof - check for end of scan - 0, - FxRowid:// xColumn - read data - 0, - FxUpdate:// xRowid - read data - uintptr(0), - FxBegin:// xUpdate - uintptr(0), - FxSync:// xBegin - uintptr(0), - FxCommit:// xSync - uintptr(0), - FxRollback:// xCommit - uintptr(0), - FxFindFunction:// xRollback - uintptr(0), - FxRename:// xFindMethod - uintptr(0), - FxSavepoint:// xRename - uintptr(0), - FxRelease:// xSavepoint - uintptr(0), - FxRollbackTo:// xRelease - uintptr(0), - FxShadowName:// xRollbackTo - uintptr(0), // xShadowName +var stmtModule = Sqlite3_module{ // xCreate + FxConnect: 0, // xConnect + FxBestIndex: 0, // xBestIndex + FxDisconnect: 0, // xDestroy + FxOpen: 0, // xOpen - open a cursor + FxClose: 0, // xClose - close a cursor + FxFilter: 0, // xFilter - configure scan constraints + FxNext: 0, // xNext - advance a cursor + FxEof: 0, // xEof - check for end of scan + FxColumn: 0, // xColumn - read data + FxRowid: 0, // xShadowName } /* sqlite3.c:230454:23 */ func Xsqlite3StmtVtabInit(tls *libc.TLS, db uintptr) int32 { /* sqlite3.c:230483:20: */ - var rc int32 = 0 + var rc int32 = SQLITE_OK rc = Xsqlite3_create_module(tls, db, ts+40911 /* "sqlite_stmt" */, uintptr(unsafe.Pointer(&stmtModule)), uintptr(0)) return rc } diff --git a/speedtest1/main_linux_amd64.go b/speedtest1/main_linux_amd64.go index 456a8e7..660e49a 100644 --- a/speedtest1/main_linux_amd64.go +++ b/speedtest1/main_linux_amd64.go @@ -1,4 +1,4 @@ -// Code generated by 'ccgo -o speedtest1/main_linux_amd64.go -trace-translation-units testdata/sqlite-src-3330000/test/speedtest1.c -Itestdata/sqlite-amalgamation-3330000 -l modernc.org/sqlite/lib -DNDEBUG -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -DSQLITE_CORE -DSQLITE_ENABLE_COLUMN_METADATA -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_UNLOCK_NOTIFY -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_MUTEX_NOOP -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_OS_UNIX=1', DO NOT EDIT. +// Code generated by 'ccgo -export-defines "" -o speedtest1/main_linux_amd64.go -trace-translation-units testdata/sqlite-src-3330000/test/speedtest1.c -Itestdata/sqlite-amalgamation-3330000 -l modernc.org/sqlite/lib -DNDEBUG -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -DSQLITE_CORE -DSQLITE_ENABLE_COLUMN_METADATA -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_UNLOCK_NOTIFY -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_MUTEX_NOOP -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_OS_UNIX=1', DO NOT EDIT. package main @@ -9,6 +9,7 @@ import ( "unsafe" "modernc.org/libc" + "modernc.org/libc/sys/types" "modernc.org/sqlite/lib" ) @@ -16,9 +17,681 @@ var _ = math.Pi var _ reflect.Kind var _ atomic.Value var _ unsafe.Pointer +var _ types.Size_t func main() { libc.Start(main1) } +const ( + BIG_ENDIAN = 4321 + BUFSIZ = 8192 + BYTE_ORDER = 1234 + EOF = -1 + EXIT_FAILURE = 1 + EXIT_SUCCESS = 0 + FD_SETSIZE = 1024 + FILENAME_MAX = 4096 + FOPEN_MAX = 16 + FTS5_TOKENIZE_AUX = 0x0008 + FTS5_TOKENIZE_DOCUMENT = 0x0004 + FTS5_TOKENIZE_PREFIX = 0x0002 + FTS5_TOKENIZE_QUERY = 0x0001 + FTS5_TOKEN_COLOCATED = 0x0001 + FULLY_WITHIN = 2 + F_LOCK = 1 + F_OK = 0 + F_TEST = 3 + F_TLOCK = 2 + F_ULOCK = 0 + HAVE_USLEEP = 1 + LITTLE_ENDIAN = 1234 + L_INCR = 1 + L_SET = 0 + L_XTND = 2 + L_ctermid = 9 + L_tmpnam = 20 + NAMEWIDTH = 60 + NDEBUG = 1 + NOT_WITHIN = 0 + PARTLY_WITHIN = 1 + PDP_ENDIAN = 3412 + P_tmpdir = "/tmp" + RAND_MAX = 2147483647 + R_OK = 4 + SEEK_CUR = 1 + SEEK_END = 2 + SEEK_SET = 0 + SQLITE3_H = 0 + SQLITE3_TEXT = 3 + SQLITE_ABORT = 4 + SQLITE_ABORT_ROLLBACK = 516 + SQLITE_ACCESS_EXISTS = 0 + SQLITE_ACCESS_READ = 2 + SQLITE_ACCESS_READWRITE = 1 + SQLITE_ALTER_TABLE = 26 + SQLITE_ANALYZE = 28 + SQLITE_ANY = 5 + SQLITE_API = 0 + SQLITE_APICALL = 0 + SQLITE_ATTACH = 24 + SQLITE_AUTH = 23 + SQLITE_AUTH_USER = 279 + SQLITE_BLOB = 4 + SQLITE_BUSY = 5 + SQLITE_BUSY_RECOVERY = 261 + SQLITE_BUSY_SNAPSHOT = 517 + SQLITE_BUSY_TIMEOUT = 773 + SQLITE_CALLBACK = 0 + SQLITE_CANTOPEN = 14 + SQLITE_CANTOPEN_CONVPATH = 1038 + SQLITE_CANTOPEN_DIRTYWAL = 1294 + SQLITE_CANTOPEN_FULLPATH = 782 + SQLITE_CANTOPEN_ISDIR = 526 + SQLITE_CANTOPEN_NOTEMPDIR = 270 + SQLITE_CANTOPEN_SYMLINK = 1550 + SQLITE_CDECL = 0 + SQLITE_CHECKPOINT_FULL = 1 + SQLITE_CHECKPOINT_PASSIVE = 0 + SQLITE_CHECKPOINT_RESTART = 2 + SQLITE_CHECKPOINT_TRUNCATE = 3 + SQLITE_CONFIG_COVERING_INDEX_SCAN = 20 + SQLITE_CONFIG_GETMALLOC = 5 + SQLITE_CONFIG_GETMUTEX = 11 + SQLITE_CONFIG_GETPCACHE = 15 + SQLITE_CONFIG_GETPCACHE2 = 19 + SQLITE_CONFIG_HEAP = 8 + SQLITE_CONFIG_LOG = 16 + SQLITE_CONFIG_LOOKASIDE = 13 + SQLITE_CONFIG_MALLOC = 4 + SQLITE_CONFIG_MEMDB_MAXSIZE = 29 + SQLITE_CONFIG_MEMSTATUS = 9 + SQLITE_CONFIG_MMAP_SIZE = 22 + SQLITE_CONFIG_MULTITHREAD = 2 + SQLITE_CONFIG_MUTEX = 10 + SQLITE_CONFIG_PAGECACHE = 7 + SQLITE_CONFIG_PCACHE = 14 + SQLITE_CONFIG_PCACHE2 = 18 + SQLITE_CONFIG_PCACHE_HDRSZ = 24 + SQLITE_CONFIG_PMASZ = 25 + SQLITE_CONFIG_SCRATCH = 6 + SQLITE_CONFIG_SERIALIZED = 3 + SQLITE_CONFIG_SINGLETHREAD = 1 + SQLITE_CONFIG_SMALL_MALLOC = 27 + SQLITE_CONFIG_SORTERREF_SIZE = 28 + SQLITE_CONFIG_SQLLOG = 21 + SQLITE_CONFIG_STMTJRNL_SPILL = 26 + SQLITE_CONFIG_URI = 17 + SQLITE_CONFIG_WIN32_HEAPSIZE = 23 + SQLITE_CONSTRAINT = 19 + SQLITE_CONSTRAINT_CHECK = 275 + SQLITE_CONSTRAINT_COMMITHOOK = 531 + SQLITE_CONSTRAINT_FOREIGNKEY = 787 + SQLITE_CONSTRAINT_FUNCTION = 1043 + SQLITE_CONSTRAINT_NOTNULL = 1299 + SQLITE_CONSTRAINT_PINNED = 2835 + SQLITE_CONSTRAINT_PRIMARYKEY = 1555 + SQLITE_CONSTRAINT_ROWID = 2579 + SQLITE_CONSTRAINT_TRIGGER = 1811 + SQLITE_CONSTRAINT_UNIQUE = 2067 + SQLITE_CONSTRAINT_VTAB = 2323 + SQLITE_COPY = 0 + SQLITE_CORE = 1 + SQLITE_CORRUPT = 11 + SQLITE_CORRUPT_INDEX = 779 + SQLITE_CORRUPT_SEQUENCE = 523 + SQLITE_CORRUPT_VTAB = 267 + SQLITE_CREATE_INDEX = 1 + SQLITE_CREATE_TABLE = 2 + SQLITE_CREATE_TEMP_INDEX = 3 + SQLITE_CREATE_TEMP_TABLE = 4 + SQLITE_CREATE_TEMP_TRIGGER = 5 + SQLITE_CREATE_TEMP_VIEW = 6 + SQLITE_CREATE_TRIGGER = 7 + SQLITE_CREATE_VIEW = 8 + SQLITE_CREATE_VTABLE = 29 + SQLITE_DBCONFIG_DEFENSIVE = 1010 + SQLITE_DBCONFIG_DQS_DDL = 1014 + SQLITE_DBCONFIG_DQS_DML = 1013 + SQLITE_DBCONFIG_ENABLE_FKEY = 1002 + SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004 + SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005 + SQLITE_DBCONFIG_ENABLE_QPSG = 1007 + SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003 + SQLITE_DBCONFIG_ENABLE_VIEW = 1015 + SQLITE_DBCONFIG_LEGACY_ALTER_TABLE = 1012 + SQLITE_DBCONFIG_LEGACY_FILE_FORMAT = 1016 + SQLITE_DBCONFIG_LOOKASIDE = 1001 + SQLITE_DBCONFIG_MAINDBNAME = 1000 + SQLITE_DBCONFIG_MAX = 1017 + SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE = 1006 + SQLITE_DBCONFIG_RESET_DATABASE = 1009 + SQLITE_DBCONFIG_TRIGGER_EQP = 1008 + SQLITE_DBCONFIG_TRUSTED_SCHEMA = 1017 + SQLITE_DBCONFIG_WRITABLE_SCHEMA = 1011 + SQLITE_DBSTATUS_CACHE_HIT = 7 + SQLITE_DBSTATUS_CACHE_MISS = 8 + SQLITE_DBSTATUS_CACHE_SPILL = 12 + SQLITE_DBSTATUS_CACHE_USED = 1 + SQLITE_DBSTATUS_CACHE_USED_SHARED = 11 + SQLITE_DBSTATUS_CACHE_WRITE = 9 + SQLITE_DBSTATUS_DEFERRED_FKS = 10 + SQLITE_DBSTATUS_LOOKASIDE_HIT = 4 + SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6 + SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5 + SQLITE_DBSTATUS_LOOKASIDE_USED = 0 + SQLITE_DBSTATUS_MAX = 12 + SQLITE_DBSTATUS_SCHEMA_USED = 2 + SQLITE_DBSTATUS_STMT_USED = 3 + SQLITE_DELETE = 9 + SQLITE_DENY = 1 + SQLITE_DEPRECATED = 0 + SQLITE_DESERIALIZE_FREEONCLOSE = 1 + SQLITE_DESERIALIZE_READONLY = 4 + SQLITE_DESERIALIZE_RESIZEABLE = 2 + SQLITE_DETACH = 25 + SQLITE_DETERMINISTIC = 0x000000800 + SQLITE_DIRECTONLY = 0x000080000 + SQLITE_DONE = 101 + SQLITE_DROP_INDEX = 10 + SQLITE_DROP_TABLE = 11 + SQLITE_DROP_TEMP_INDEX = 12 + SQLITE_DROP_TEMP_TABLE = 13 + SQLITE_DROP_TEMP_TRIGGER = 14 + SQLITE_DROP_TEMP_VIEW = 15 + SQLITE_DROP_TRIGGER = 16 + SQLITE_DROP_VIEW = 17 + SQLITE_DROP_VTABLE = 30 + SQLITE_EMPTY = 16 + SQLITE_ENABLE_COLUMN_METADATA = 1 + SQLITE_ENABLE_FTS5 = 1 + SQLITE_ENABLE_GEOPOLY = 1 + SQLITE_ENABLE_JSON1 = 1 + SQLITE_ENABLE_MEMORY_MANAGEMENT = 1 + SQLITE_ENABLE_OFFSET_SQL_FUNC = 1 + SQLITE_ENABLE_PREUPDATE_HOOK = 1 + SQLITE_ENABLE_RBU = 1 + SQLITE_ENABLE_RTREE = 1 + SQLITE_ENABLE_SNAPSHOT = 1 + SQLITE_ENABLE_STAT4 = 1 + SQLITE_ENABLE_UNLOCK_NOTIFY = 1 + SQLITE_ERROR = 1 + SQLITE_ERROR_MISSING_COLLSEQ = 257 + SQLITE_ERROR_RETRY = 513 + SQLITE_ERROR_SNAPSHOT = 769 + SQLITE_EXPERIMENTAL = 0 + SQLITE_FAIL = 3 + SQLITE_FCNTL_BEGIN_ATOMIC_WRITE = 31 + SQLITE_FCNTL_BUSYHANDLER = 15 + SQLITE_FCNTL_CHUNK_SIZE = 6 + SQLITE_FCNTL_CKPT_DONE = 37 + SQLITE_FCNTL_CKPT_START = 39 + SQLITE_FCNTL_COMMIT_ATOMIC_WRITE = 32 + SQLITE_FCNTL_COMMIT_PHASETWO = 22 + SQLITE_FCNTL_DATA_VERSION = 35 + SQLITE_FCNTL_FILE_POINTER = 7 + SQLITE_FCNTL_GET_LOCKPROXYFILE = 2 + SQLITE_FCNTL_HAS_MOVED = 20 + SQLITE_FCNTL_JOURNAL_POINTER = 28 + SQLITE_FCNTL_LAST_ERRNO = 4 + SQLITE_FCNTL_LOCKSTATE = 1 + SQLITE_FCNTL_LOCK_TIMEOUT = 34 + SQLITE_FCNTL_MMAP_SIZE = 18 + SQLITE_FCNTL_OVERWRITE = 11 + SQLITE_FCNTL_PDB = 30 + SQLITE_FCNTL_PERSIST_WAL = 10 + SQLITE_FCNTL_POWERSAFE_OVERWRITE = 13 + SQLITE_FCNTL_PRAGMA = 14 + SQLITE_FCNTL_RBU = 26 + SQLITE_FCNTL_RESERVE_BYTES = 38 + SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE = 33 + SQLITE_FCNTL_SET_LOCKPROXYFILE = 3 + SQLITE_FCNTL_SIZE_HINT = 5 + SQLITE_FCNTL_SIZE_LIMIT = 36 + SQLITE_FCNTL_SYNC = 21 + SQLITE_FCNTL_SYNC_OMITTED = 8 + SQLITE_FCNTL_TEMPFILENAME = 16 + SQLITE_FCNTL_TRACE = 19 + SQLITE_FCNTL_VFSNAME = 12 + SQLITE_FCNTL_VFS_POINTER = 27 + SQLITE_FCNTL_WAL_BLOCK = 24 + SQLITE_FCNTL_WIN32_AV_RETRY = 9 + SQLITE_FCNTL_WIN32_GET_HANDLE = 29 + SQLITE_FCNTL_WIN32_SET_HANDLE = 23 + SQLITE_FCNTL_ZIPVFS = 25 + SQLITE_FLOAT = 2 + SQLITE_FORMAT = 24 + SQLITE_FULL = 13 + SQLITE_FUNCTION = 31 + SQLITE_GET_LOCKPROXYFILE = 2 + SQLITE_IGNORE = 2 + SQLITE_INDEX_CONSTRAINT_EQ = 2 + SQLITE_INDEX_CONSTRAINT_FUNCTION = 150 + SQLITE_INDEX_CONSTRAINT_GE = 32 + SQLITE_INDEX_CONSTRAINT_GLOB = 66 + SQLITE_INDEX_CONSTRAINT_GT = 4 + SQLITE_INDEX_CONSTRAINT_IS = 72 + SQLITE_INDEX_CONSTRAINT_ISNOT = 69 + SQLITE_INDEX_CONSTRAINT_ISNOTNULL = 70 + SQLITE_INDEX_CONSTRAINT_ISNULL = 71 + SQLITE_INDEX_CONSTRAINT_LE = 8 + SQLITE_INDEX_CONSTRAINT_LIKE = 65 + SQLITE_INDEX_CONSTRAINT_LT = 16 + SQLITE_INDEX_CONSTRAINT_MATCH = 64 + SQLITE_INDEX_CONSTRAINT_NE = 68 + SQLITE_INDEX_CONSTRAINT_REGEXP = 67 + SQLITE_INDEX_SCAN_UNIQUE = 1 + SQLITE_INNOCUOUS = 0x000200000 + SQLITE_INSERT = 18 + SQLITE_INTEGER = 1 + SQLITE_INTERNAL = 2 + SQLITE_INTERRUPT = 9 + SQLITE_IOCAP_ATOMIC = 0x00000001 + SQLITE_IOCAP_ATOMIC16K = 0x00000040 + SQLITE_IOCAP_ATOMIC1K = 0x00000004 + SQLITE_IOCAP_ATOMIC2K = 0x00000008 + SQLITE_IOCAP_ATOMIC32K = 0x00000080 + SQLITE_IOCAP_ATOMIC4K = 0x00000010 + SQLITE_IOCAP_ATOMIC512 = 0x00000002 + SQLITE_IOCAP_ATOMIC64K = 0x00000100 + SQLITE_IOCAP_ATOMIC8K = 0x00000020 + SQLITE_IOCAP_BATCH_ATOMIC = 0x00004000 + SQLITE_IOCAP_IMMUTABLE = 0x00002000 + SQLITE_IOCAP_POWERSAFE_OVERWRITE = 0x00001000 + SQLITE_IOCAP_SAFE_APPEND = 0x00000200 + SQLITE_IOCAP_SEQUENTIAL = 0x00000400 + SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 0x00000800 + SQLITE_IOERR = 10 + SQLITE_IOERR_ACCESS = 3338 + SQLITE_IOERR_AUTH = 7178 + SQLITE_IOERR_BEGIN_ATOMIC = 7434 + SQLITE_IOERR_BLOCKED = 2826 + SQLITE_IOERR_CHECKRESERVEDLOCK = 3594 + SQLITE_IOERR_CLOSE = 4106 + SQLITE_IOERR_COMMIT_ATOMIC = 7690 + SQLITE_IOERR_CONVPATH = 6666 + SQLITE_IOERR_DATA = 8202 + SQLITE_IOERR_DELETE = 2570 + SQLITE_IOERR_DELETE_NOENT = 5898 + SQLITE_IOERR_DIR_CLOSE = 4362 + SQLITE_IOERR_DIR_FSYNC = 1290 + SQLITE_IOERR_FSTAT = 1802 + SQLITE_IOERR_FSYNC = 1034 + SQLITE_IOERR_GETTEMPPATH = 6410 + SQLITE_IOERR_LOCK = 3850 + SQLITE_IOERR_MMAP = 6154 + SQLITE_IOERR_NOMEM = 3082 + SQLITE_IOERR_RDLOCK = 2314 + SQLITE_IOERR_READ = 266 + SQLITE_IOERR_ROLLBACK_ATOMIC = 7946 + SQLITE_IOERR_SEEK = 5642 + SQLITE_IOERR_SHMLOCK = 5130 + SQLITE_IOERR_SHMMAP = 5386 + SQLITE_IOERR_SHMOPEN = 4618 + SQLITE_IOERR_SHMSIZE = 4874 + SQLITE_IOERR_SHORT_READ = 522 + SQLITE_IOERR_TRUNCATE = 1546 + SQLITE_IOERR_UNLOCK = 2058 + SQLITE_IOERR_VNODE = 6922 + SQLITE_IOERR_WRITE = 778 + SQLITE_LAST_ERRNO = 4 + SQLITE_LIKE_DOESNT_MATCH_BLOBS = 1 + SQLITE_LIMIT_ATTACHED = 7 + SQLITE_LIMIT_COLUMN = 2 + SQLITE_LIMIT_COMPOUND_SELECT = 4 + SQLITE_LIMIT_EXPR_DEPTH = 3 + SQLITE_LIMIT_FUNCTION_ARG = 6 + SQLITE_LIMIT_LENGTH = 0 + SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8 + SQLITE_LIMIT_SQL_LENGTH = 1 + SQLITE_LIMIT_TRIGGER_DEPTH = 10 + SQLITE_LIMIT_VARIABLE_NUMBER = 9 + SQLITE_LIMIT_VDBE_OP = 5 + SQLITE_LIMIT_WORKER_THREADS = 11 + SQLITE_LOCKED = 6 + SQLITE_LOCKED_SHAREDCACHE = 262 + SQLITE_LOCKED_VTAB = 518 + SQLITE_LOCK_EXCLUSIVE = 4 + SQLITE_LOCK_NONE = 0 + SQLITE_LOCK_PENDING = 3 + SQLITE_LOCK_RESERVED = 2 + SQLITE_LOCK_SHARED = 1 + SQLITE_MISMATCH = 20 + SQLITE_MISUSE = 21 + SQLITE_MUTEX_APPDEF = 1 + SQLITE_MUTEX_FAST = 0 + SQLITE_MUTEX_NOOP = 1 + SQLITE_MUTEX_RECURSIVE = 1 + SQLITE_MUTEX_STATIC_APP1 = 8 + SQLITE_MUTEX_STATIC_APP2 = 9 + SQLITE_MUTEX_STATIC_APP3 = 10 + SQLITE_MUTEX_STATIC_LRU = 6 + SQLITE_MUTEX_STATIC_LRU2 = 7 + SQLITE_MUTEX_STATIC_MAIN = 2 + SQLITE_MUTEX_STATIC_MASTER = 2 + SQLITE_MUTEX_STATIC_MEM = 3 + SQLITE_MUTEX_STATIC_MEM2 = 4 + SQLITE_MUTEX_STATIC_OPEN = 4 + SQLITE_MUTEX_STATIC_PMEM = 7 + SQLITE_MUTEX_STATIC_PRNG = 5 + SQLITE_MUTEX_STATIC_VFS1 = 11 + SQLITE_MUTEX_STATIC_VFS2 = 12 + SQLITE_MUTEX_STATIC_VFS3 = 13 + SQLITE_NOLFS = 22 + SQLITE_NOMEM = 7 + SQLITE_NOTADB = 26 + SQLITE_NOTFOUND = 12 + SQLITE_NOTICE = 27 + SQLITE_NOTICE_RECOVER_ROLLBACK = 539 + SQLITE_NOTICE_RECOVER_WAL = 283 + SQLITE_NULL = 5 + SQLITE_OK = 0 + SQLITE_OK_LOAD_PERMANENTLY = 256 + SQLITE_OK_SYMLINK = 512 + SQLITE_OPEN_AUTOPROXY = 0x00000020 + SQLITE_OPEN_CREATE = 0x00000004 + SQLITE_OPEN_DELETEONCLOSE = 0x00000008 + SQLITE_OPEN_EXCLUSIVE = 0x00000010 + SQLITE_OPEN_FULLMUTEX = 0x00010000 + SQLITE_OPEN_MAIN_DB = 0x00000100 + SQLITE_OPEN_MAIN_JOURNAL = 0x00000800 + SQLITE_OPEN_MASTER_JOURNAL = 0x00004000 + SQLITE_OPEN_MEMORY = 0x00000080 + SQLITE_OPEN_NOFOLLOW = 0x01000000 + SQLITE_OPEN_NOMUTEX = 0x00008000 + SQLITE_OPEN_PRIVATECACHE = 0x00040000 + SQLITE_OPEN_READONLY = 0x00000001 + SQLITE_OPEN_READWRITE = 0x00000002 + SQLITE_OPEN_SHAREDCACHE = 0x00020000 + SQLITE_OPEN_SUBJOURNAL = 0x00002000 + SQLITE_OPEN_SUPER_JOURNAL = 0x00004000 + SQLITE_OPEN_TEMP_DB = 0x00000200 + SQLITE_OPEN_TEMP_JOURNAL = 0x00001000 + SQLITE_OPEN_TRANSIENT_DB = 0x00000400 + SQLITE_OPEN_URI = 0x00000040 + SQLITE_OPEN_WAL = 0x00080000 + SQLITE_OS_UNIX = 1 + SQLITE_PERM = 3 + SQLITE_PRAGMA = 19 + SQLITE_PREPARE_NORMALIZE = 0x02 + SQLITE_PREPARE_NO_VTAB = 0x04 + SQLITE_PREPARE_PERSISTENT = 0x01 + SQLITE_PROTOCOL = 15 + SQLITE_RANGE = 25 + SQLITE_READ = 20 + SQLITE_READONLY = 8 + SQLITE_READONLY_CANTINIT = 1288 + SQLITE_READONLY_CANTLOCK = 520 + SQLITE_READONLY_DBMOVED = 1032 + SQLITE_READONLY_DIRECTORY = 1544 + SQLITE_READONLY_RECOVERY = 264 + SQLITE_READONLY_ROLLBACK = 776 + SQLITE_RECURSIVE = 33 + SQLITE_REINDEX = 27 + SQLITE_REPLACE = 5 + SQLITE_ROLLBACK = 1 + SQLITE_ROW = 100 + SQLITE_SAVEPOINT = 32 + SQLITE_SCANSTAT_EST = 2 + SQLITE_SCANSTAT_EXPLAIN = 4 + SQLITE_SCANSTAT_NAME = 3 + SQLITE_SCANSTAT_NLOOP = 0 + SQLITE_SCANSTAT_NVISIT = 1 + SQLITE_SCANSTAT_SELECTID = 5 + SQLITE_SCHEMA = 17 + SQLITE_SELECT = 21 + SQLITE_SERIALIZE_NOCOPY = 0x001 + SQLITE_SET_LOCKPROXYFILE = 3 + SQLITE_SHM_EXCLUSIVE = 8 + SQLITE_SHM_LOCK = 2 + SQLITE_SHM_NLOCK = 8 + SQLITE_SHM_SHARED = 4 + SQLITE_SHM_UNLOCK = 1 + SQLITE_SOUNDEX = 1 + SQLITE_SOURCE_ID = "2020-08-14 13:23:32 fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0ff3f" + SQLITE_STATUS_MALLOC_COUNT = 9 + SQLITE_STATUS_MALLOC_SIZE = 5 + SQLITE_STATUS_MEMORY_USED = 0 + SQLITE_STATUS_PAGECACHE_OVERFLOW = 2 + SQLITE_STATUS_PAGECACHE_SIZE = 7 + SQLITE_STATUS_PAGECACHE_USED = 1 + SQLITE_STATUS_PARSER_STACK = 6 + SQLITE_STATUS_SCRATCH_OVERFLOW = 4 + SQLITE_STATUS_SCRATCH_SIZE = 8 + SQLITE_STATUS_SCRATCH_USED = 3 + SQLITE_STDCALL = 0 + SQLITE_STMTSTATUS_AUTOINDEX = 3 + SQLITE_STMTSTATUS_FULLSCAN_STEP = 1 + SQLITE_STMTSTATUS_MEMUSED = 99 + SQLITE_STMTSTATUS_REPREPARE = 5 + SQLITE_STMTSTATUS_RUN = 6 + SQLITE_STMTSTATUS_SORT = 2 + SQLITE_STMTSTATUS_VM_STEP = 4 + SQLITE_SUBTYPE = 0x000100000 + SQLITE_SYNC_DATAONLY = 0x00010 + SQLITE_SYNC_FULL = 0x00003 + SQLITE_SYNC_NORMAL = 0x00002 + SQLITE_SYSAPI = 0 + SQLITE_TESTCTRL_ALWAYS = 13 + SQLITE_TESTCTRL_ASSERT = 12 + SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10 + SQLITE_TESTCTRL_BITVEC_TEST = 8 + SQLITE_TESTCTRL_BYTEORDER = 22 + SQLITE_TESTCTRL_EXPLAIN_STMT = 19 + SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS = 29 + SQLITE_TESTCTRL_FAULT_INSTALL = 9 + SQLITE_TESTCTRL_FIRST = 5 + SQLITE_TESTCTRL_IMPOSTER = 25 + SQLITE_TESTCTRL_INTERNAL_FUNCTIONS = 17 + SQLITE_TESTCTRL_ISINIT = 23 + SQLITE_TESTCTRL_ISKEYWORD = 16 + SQLITE_TESTCTRL_LAST = 29 + SQLITE_TESTCTRL_LOCALTIME_FAULT = 18 + SQLITE_TESTCTRL_NEVER_CORRUPT = 20 + SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD = 19 + SQLITE_TESTCTRL_OPTIMIZATIONS = 15 + SQLITE_TESTCTRL_PARSER_COVERAGE = 26 + SQLITE_TESTCTRL_PENDING_BYTE = 11 + SQLITE_TESTCTRL_PRNG_RESET = 7 + SQLITE_TESTCTRL_PRNG_RESTORE = 6 + SQLITE_TESTCTRL_PRNG_SAVE = 5 + SQLITE_TESTCTRL_PRNG_SEED = 28 + SQLITE_TESTCTRL_RESERVE = 14 + SQLITE_TESTCTRL_RESULT_INTREAL = 27 + SQLITE_TESTCTRL_SCRATCHMALLOC = 17 + SQLITE_TESTCTRL_SORTER_MMAP = 24 + SQLITE_TESTCTRL_VDBE_COVERAGE = 21 + SQLITE_TEXT = 3 + SQLITE_THREADSAFE = 1 + SQLITE_TOOBIG = 18 + SQLITE_TRACE_CLOSE = 0x08 + SQLITE_TRACE_PROFILE = 0x02 + SQLITE_TRACE_ROW = 0x04 + SQLITE_TRACE_STMT = 0x01 + SQLITE_TRANSACTION = 22 + SQLITE_UPDATE = 23 + SQLITE_UTF16 = 4 + SQLITE_UTF16BE = 3 + SQLITE_UTF16LE = 2 + SQLITE_UTF16_ALIGNED = 8 + SQLITE_UTF8 = 1 + SQLITE_VERSION = "3.33.0" + SQLITE_VERSION_NUMBER = 3033000 + SQLITE_VTAB_CONSTRAINT_SUPPORT = 1 + SQLITE_VTAB_DIRECTONLY = 3 + SQLITE_VTAB_INNOCUOUS = 2 + SQLITE_WARNING = 28 + SQLITE_WARNING_AUTOINDEX = 284 + SQLITE_WIN32_DATA_DIRECTORY_TYPE = 1 + SQLITE_WIN32_TEMP_DIRECTORY_TYPE = 2 + STDERR_FILENO = 2 + STDIN_FILENO = 0 + STDOUT_FILENO = 1 + TMP_MAX = 238328 + WCONTINUED = 8 + WEXITED = 4 + WNOHANG = 1 + WNOWAIT = 0x01000000 + WSTOPPED = 2 + WUNTRACED = 2 + W_OK = 2 + X_OK = 1 + X_ALLOCA_H = 1 + X_ANSI_STDARG_H_ = 0 + X_ASSERT_H = 1 + X_ATFILE_SOURCE = 1 + X_BITS_BYTESWAP_H = 1 + X_BITS_FLOATN_COMMON_H = 0 + X_BITS_FLOATN_H = 0 + X_BITS_POSIX_OPT_H = 1 + X_BITS_PTHREADTYPES_ARCH_H = 1 + X_BITS_PTHREADTYPES_COMMON_H = 1 + X_BITS_STDINT_INTN_H = 1 + X_BITS_STDIO_LIM_H = 1 + X_BITS_TYPESIZES_H = 1 + X_BITS_TYPES_H = 1 + X_BITS_TYPES_LOCALE_T_H = 1 + X_BITS_TYPES___LOCALE_T_H = 1 + X_BITS_UINTN_IDENTITY_H = 1 + X_BSD_SIZE_T_ = 0 + X_BSD_SIZE_T_DEFINED_ = 0 + X_CTYPE_H = 1 + X_DEFAULT_SOURCE = 1 + X_ENDIAN_H = 1 + X_FEATURES_H = 1 + X_FILE_OFFSET_BITS = 64 + X_FTS5_H = 0 + X_GCC_SIZE_T = 0 + X_GCC_WCHAR_T = 0 + X_GETOPT_CORE_H = 1 + X_GETOPT_POSIX_H = 1 + X_IOFBF = 0 + X_IOLBF = 1 + X_IONBF = 2 + X_IO_EOF_SEEN = 0x0010 + X_IO_ERR_SEEN = 0x0020 + X_IO_USER_LOCK = 0x8000 + X_LFS64_ASYNCHRONOUS_IO = 1 + X_LFS64_LARGEFILE = 1 + X_LFS64_STDIO = 1 + X_LFS_ASYNCHRONOUS_IO = 1 + X_LFS_LARGEFILE = 1 + X_LP64 = 1 + X_POSIX2_CHAR_TERM = 200809 + X_POSIX2_C_BIND = 200809 + X_POSIX2_C_DEV = 200809 + X_POSIX2_C_VERSION = 200809 + X_POSIX2_LOCALEDEF = 200809 + X_POSIX2_SW_DEV = 200809 + X_POSIX2_VERSION = 200809 + X_POSIX_ADVISORY_INFO = 200809 + X_POSIX_ASYNCHRONOUS_IO = 200809 + X_POSIX_ASYNC_IO = 1 + X_POSIX_BARRIERS = 200809 + X_POSIX_CHOWN_RESTRICTED = 0 + X_POSIX_CLOCK_SELECTION = 200809 + X_POSIX_CPUTIME = 0 + X_POSIX_C_SOURCE = 200809 + X_POSIX_FSYNC = 200809 + X_POSIX_IPV6 = 200809 + X_POSIX_JOB_CONTROL = 1 + X_POSIX_MAPPED_FILES = 200809 + X_POSIX_MEMLOCK = 200809 + X_POSIX_MEMLOCK_RANGE = 200809 + X_POSIX_MEMORY_PROTECTION = 200809 + X_POSIX_MESSAGE_PASSING = 200809 + X_POSIX_MONOTONIC_CLOCK = 0 + X_POSIX_NO_TRUNC = 1 + X_POSIX_PRIORITIZED_IO = 200809 + X_POSIX_PRIORITY_SCHEDULING = 200809 + X_POSIX_RAW_SOCKETS = 200809 + X_POSIX_READER_WRITER_LOCKS = 200809 + X_POSIX_REALTIME_SIGNALS = 200809 + X_POSIX_REENTRANT_FUNCTIONS = 1 + X_POSIX_REGEXP = 1 + X_POSIX_SAVED_IDS = 1 + X_POSIX_SEMAPHORES = 200809 + X_POSIX_SHARED_MEMORY_OBJECTS = 200809 + X_POSIX_SHELL = 1 + X_POSIX_SOURCE = 1 + X_POSIX_SPAWN = 200809 + X_POSIX_SPIN_LOCKS = 200809 + X_POSIX_SPORADIC_SERVER = -1 + X_POSIX_SYNCHRONIZED_IO = 200809 + X_POSIX_THREADS = 200809 + X_POSIX_THREAD_ATTR_STACKADDR = 200809 + X_POSIX_THREAD_ATTR_STACKSIZE = 200809 + X_POSIX_THREAD_CPUTIME = 0 + X_POSIX_THREAD_PRIORITY_SCHEDULING = 200809 + X_POSIX_THREAD_PRIO_INHERIT = 200809 + X_POSIX_THREAD_PRIO_PROTECT = 200809 + X_POSIX_THREAD_PROCESS_SHARED = 200809 + X_POSIX_THREAD_ROBUST_PRIO_INHERIT = 200809 + X_POSIX_THREAD_ROBUST_PRIO_PROTECT = -1 + X_POSIX_THREAD_SAFE_FUNCTIONS = 200809 + X_POSIX_THREAD_SPORADIC_SERVER = -1 + X_POSIX_TIMEOUTS = 200809 + X_POSIX_TIMERS = 200809 + X_POSIX_TRACE = -1 + X_POSIX_TRACE_EVENT_FILTER = -1 + X_POSIX_TRACE_INHERIT = -1 + X_POSIX_TRACE_LOG = -1 + X_POSIX_TYPED_MEMORY_OBJECTS = -1 + X_POSIX_V6_LP64_OFF64 = 1 + X_POSIX_V6_LPBIG_OFFBIG = -1 + X_POSIX_V7_LP64_OFF64 = 1 + X_POSIX_V7_LPBIG_OFFBIG = -1 + X_POSIX_VDISABLE = 0 + X_POSIX_VERSION = 200809 + X_SIZET_ = 0 + X_SIZE_T = 0 + X_SIZE_T_ = 0 + X_SIZE_T_DECLARED = 0 + X_SIZE_T_DEFINED = 0 + X_SIZE_T_DEFINED_ = 0 + X_SQLITE3RTREE_H_ = 0 + X_STDARG_H = 0 + X_STDC_PREDEF_H = 1 + X_STDIO_H = 1 + X_STDLIB_H = 1 + X_STRINGS_H = 1 + X_STRING_H = 1 + X_STRUCT_TIMESPEC = 1 + X_SYS_CDEFS_H = 1 + X_SYS_SELECT_H = 1 + X_SYS_SIZE_T_H = 0 + X_SYS_TYPES_H = 1 + X_THREAD_SHARED_TYPES_H = 1 + X_T_SIZE = 0 + X_T_SIZE_ = 0 + X_T_WCHAR = 0 + X_T_WCHAR_ = 0 + X_UNISTD_H = 1 + X_VA_LIST = 0 + X_VA_LIST_ = 0 + X_VA_LIST_DEFINED = 0 + X_VA_LIST_T_H = 0 + X_WCHAR_T = 0 + X_WCHAR_T_ = 0 + X_WCHAR_T_DECLARED = 0 + X_WCHAR_T_DEFINED = 0 + X_WCHAR_T_DEFINED_ = 0 + X_WCHAR_T_H = 0 + X_XBS5_LP64_OFF64 = 1 + X_XBS5_LPBIG_OFFBIG = -1 + X_XOPEN_ENH_I18N = 1 + X_XOPEN_LEGACY = 1 + X_XOPEN_REALTIME = 1 + X_XOPEN_REALTIME_THREADS = 1 + X_XOPEN_SHM = 1 + X_XOPEN_UNIX = 1 + X_XOPEN_VERSION = 700 + X_XOPEN_XCU_VERSION = 4 + X_XOPEN_XPG2 = 1 + X_XOPEN_XPG3 = 1 + X_XOPEN_XPG4 = 1 + Linux = 1 + Unix = 1 +) + // Copyright (C) 1991-2018 Free Software Foundation, Inc. // This file is part of the GNU C Library. // @@ -4303,22 +4976,22 @@ func integerValue(tls *libc.TLS, zArg uintptr) int32 { /* speedtest1.c:210:12: * var v sqlite3_int64 = int64(0) var i int32 var isNeg int32 = 0 - if int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) == '-' { + if int32(*(*int8)(unsafe.Pointer(zArg))) == '-' { isNeg = 1 zArg++ - } else if int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) == '+' { + } else if int32(*(*int8)(unsafe.Pointer(zArg))) == '+' { zArg++ } - if (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))) == '0') && (int32(*(*int8)(unsafe.Pointer(zArg + uintptr(1)))) == 'x') { + if (int32(*(*int8)(unsafe.Pointer(zArg))) == '0') && (int32(*(*int8)(unsafe.Pointer(zArg + 1))) == 'x') { var x int32 zArg += uintptr(2) - for (libc.AssignInt32(&x, hexDigitValue(tls, *(*int8)(unsafe.Pointer(zArg + uintptr(0)))))) >= 0 { + for (libc.AssignInt32(&x, hexDigitValue(tls, *(*int8)(unsafe.Pointer(zArg))))) >= 0 { v = ((v << 4) + sqlite3_int64(x)) zArg++ } } else { - for (int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(*(*int8)(unsafe.Pointer(zArg + uintptr(0)))))*2))) & int32(_ISdigit)) != 0 { - v = (((v * int64(10)) + sqlite3_int64(*(*int8)(unsafe.Pointer(zArg + uintptr(0))))) - int64('0')) + for (int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(*(*int8)(unsafe.Pointer(zArg))))*2))) & int32(_ISdigit)) != 0 { + v = (((v * int64(10)) + sqlite3_int64(*(*int8)(unsafe.Pointer(zArg)))) - int64('0')) zArg++ } } @@ -4348,33 +5021,15 @@ var aMult = [9]struct { iMult int32 _ [4]byte }{ - { - zSuffix: ts + 2190, /* "KiB" */ - iMult: 1024}, - { - zSuffix: ts + 2194, /* "MiB" */ - iMult: (1024 * 1024)}, - { - zSuffix: ts + 2198, /* "GiB" */ - iMult: ((1024 * 1024) * 1024)}, - { - zSuffix: ts + 2202, /* "KB" */ - iMult: 1000}, - { - zSuffix: ts + 2205, /* "MB" */ - iMult: 1000000}, - { - zSuffix: ts + 2208, /* "GB" */ - iMult: 1000000000}, - { - zSuffix: ts + 2211, /* "K" */ - iMult: 1000}, - { - zSuffix: ts + 2213, /* "M" */ - iMult: 1000000}, - { - zSuffix: ts + 2215, /* "G" */ - iMult: 1000000000}, + {zSuffix: ts + 2190 /* "KiB" */, iMult: 1024}, + {zSuffix: ts + 2194 /* "MiB" */, iMult: (1024 * 1024)}, + {zSuffix: ts + 2198 /* "GiB" */, iMult: ((1024 * 1024) * 1024)}, + {zSuffix: ts + 2202 /* "KB" */, iMult: 1000}, + {zSuffix: ts + 2205 /* "MB" */, iMult: 1000000}, + {zSuffix: ts + 2208 /* "GB" */, iMult: 1000000000}, + {zSuffix: ts + 2211 /* "K" */, iMult: 1000}, + {zSuffix: ts + 2213 /* "M" */, iMult: 1000000}, + {zSuffix: ts + 2215 /* "G" */, iMult: 1000000000}, } /* speedtest1.c:212:53 */ // Return the current wall-clock time, in milliseconds @@ -4517,14 +5172,14 @@ func speedtest1_begin_test(tls *libc.TLS, iTestNum int32, zTestName uintptr, va zName = sqlite3.Xsqlite3_vmprintf(tls, zTestName, ap) _ = ap n = int32(libc.Xstrlen(tls, zName)) - if n > 60 { - *(*int8)(unsafe.Pointer(zName + uintptr(60))) = int8(0) - n = 60 + if n > NAMEWIDTH { + *(*int8)(unsafe.Pointer(zName + 60)) = int8(0) + n = NAMEWIDTH } if g.bSqlOnly != 0 { - libc.Xprintf(tls, ts+2515 /* "/* %4d - %s%.*s ..." */, libc.VaList(bp, iTestNum, zName, (60-n), uintptr(unsafe.Pointer(&zDots)))) + libc.Xprintf(tls, ts+2515 /* "/* %4d - %s%.*s ..." */, libc.VaList(bp, iTestNum, zName, (NAMEWIDTH-n), uintptr(unsafe.Pointer(&zDots)))) } else { - libc.Xprintf(tls, ts+2535 /* "%4d - %s%.*s " */, libc.VaList(bp+32, iTestNum, zName, (60-n), uintptr(unsafe.Pointer(&zDots)))) + libc.Xprintf(tls, ts+2535 /* "%4d - %s%.*s " */, libc.VaList(bp+32, iTestNum, zName, (NAMEWIDTH-n), uintptr(unsafe.Pointer(&zDots)))) libc.Xfflush(tls, libc.Xstdout) } sqlite3.Xsqlite3_free(tls, zName) @@ -4559,7 +5214,7 @@ func speedtest1_final(tls *libc.TLS) { /* speedtest1.c:413:6: */ defer tls.Free(48) if !(g.bSqlOnly != 0) { - libc.Xprintf(tls, ts+2583 /* " TOTAL%.*s..." */, libc.VaList(bp, (60-5), uintptr(unsafe.Pointer(&zDots)), + libc.Xprintf(tls, ts+2583 /* " TOTAL%.*s..." */, libc.VaList(bp, (NAMEWIDTH-5), uintptr(unsafe.Pointer(&zDots)), (int32(g.iTotal/int64(1000))), (int32(g.iTotal%int64(1000))))) } if g.bVerify != 0 { @@ -4625,7 +5280,7 @@ func speedtest1_exec(tls *libc.TLS, zFormat uintptr, va uintptr) { /* speedtest1 if *(*uintptr)(unsafe.Pointer(bp + 24 /* zErrMsg */)) != 0 { fatal_error(tls, ts+2683 /* "SQL error: %s\n%s..." */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 24 /* zErrMsg */)), zSql)) } - if rc != 0 { + if rc != SQLITE_OK { fatal_error(tls, ts+2701 /* "exec error: %s\n" */, libc.VaList(bp+16, sqlite3.Xsqlite3_errmsg(tls, g.db))) } } @@ -4656,7 +5311,7 @@ func speedtest1_once(tls *libc.TLS, zFormat uintptr, va uintptr) uintptr { /* sp if rc != 0 { fatal_error(tls, ts+2717 /* "SQL error: %s\n" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, g.db))) } - if sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == 100 { + if sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == SQLITE_ROW { var z uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)), 0) if z != 0 { zResult = sqlite3.Xsqlite3_mprintf(tls, ts+2256 /* "%s" */, libc.VaList(bp+8, z)) @@ -4708,7 +5363,7 @@ func speedtest1_run(tls *libc.TLS) { /* speedtest1.c:532:6: */ } g.nResult = 0 - for sqlite3.Xsqlite3_step(tls, g.pStmt) == 100 { + for sqlite3.Xsqlite3_step(tls, g.pStmt) == SQLITE_ROW { n = sqlite3.Xsqlite3_column_count(tls, g.pStmt) for i = 0; i < n; i++ { var z uintptr = sqlite3.Xsqlite3_column_text(tls, g.pStmt, i) @@ -4720,27 +5375,27 @@ func speedtest1_run(tls *libc.TLS) { /* speedtest1.c:532:6: */ var eType int32 = sqlite3.Xsqlite3_column_type(tls, g.pStmt, i) // var zPrefix [2]uint8 at bp, 2 - *(*uint8)(unsafe.Pointer(bp /* &zPrefix[0] */ + uintptr(0))) = uint8('\n') - *(*uint8)(unsafe.Pointer(bp /* &zPrefix[0] */ + uintptr(1))) = uint8(*(*int8)(unsafe.Pointer(ts + 2736 /* "-IFTBN" */ + uintptr(eType)))) + *(*uint8)(unsafe.Pointer(bp /* &zPrefix[0] */)) = uint8('\n') + *(*uint8)(unsafe.Pointer(bp /* &zPrefix[0] */ + 1)) = uint8(*(*int8)(unsafe.Pointer(ts + 2736 /* "-IFTBN" */ + uintptr(eType)))) if g.nResByte != 0 { HashUpdate(tls, bp /* &zPrefix[0] */, uint32(2)) } else { HashUpdate(tls, (bp /* &zPrefix[0] */ + uintptr(1)), uint32(1)) } - if eType == 2 { + if eType == SQLITE_FLOAT { // Omit the value of floating-point results from the verification // hash. The only thing we record is the fact that the result was // a floating-point value. *(*u64)(unsafe.Pointer(uintptr(unsafe.Pointer(&g)) + 104 /* &.nResByte */)) += (uint64(2)) - } else if eType == 4 { + } else if eType == SQLITE_BLOB { var nBlob int32 = sqlite3.Xsqlite3_column_bytes(tls, g.pStmt, i) var iBlob int32 // var zChar [2]uint8 at bp+2, 2 var aBlob uintptr = sqlite3.Xsqlite3_column_blob(tls, g.pStmt, i) for iBlob = 0; iBlob < nBlob; iBlob++ { - *(*uint8)(unsafe.Pointer(bp + 2 /* &zChar[0] */ + uintptr(0))) = uint8(*(*int8)(unsafe.Pointer(ts + 2743 /* "0123456789abcdef" */ + uintptr((int32(*(*uint8)(unsafe.Pointer(aBlob + uintptr(iBlob)))) >> 4))))) - *(*uint8)(unsafe.Pointer(bp + 2 /* &zChar[0] */ + uintptr(1))) = uint8(*(*int8)(unsafe.Pointer(ts + 2743 /* "0123456789abcdef" */ + uintptr((int32(*(*uint8)(unsafe.Pointer(aBlob + uintptr(iBlob)))) & 15))))) + *(*uint8)(unsafe.Pointer(bp + 2 /* &zChar[0] */)) = uint8(*(*int8)(unsafe.Pointer(ts + 2743 /* "0123456789abcdef" */ + uintptr((int32(*(*uint8)(unsafe.Pointer(aBlob + uintptr(iBlob)))) >> 4))))) + *(*uint8)(unsafe.Pointer(bp + 2 /* &zChar[0] */ + 1)) = uint8(*(*int8)(unsafe.Pointer(ts + 2743 /* "0123456789abcdef" */ + uintptr((int32(*(*uint8)(unsafe.Pointer(aBlob + uintptr(iBlob)))) & 15))))) HashUpdate(tls, bp+2 /* &zChar[0] */, uint32(2)) } *(*u64)(unsafe.Pointer(uintptr(unsafe.Pointer(&g)) + 104 /* &.nResByte */)) += (u64((nBlob * 2) + 2)) @@ -4819,7 +5474,7 @@ func testset_main(tls *libc.TLS) { /* speedtest1.c:694:6: */ // A number name sz = libc.AssignInt32(&n, (g.szTest * 500)) - *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */ + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */)) = int8(0) maxb = int32(roundup_allones(tls, uint32(sz))) speedtest1_begin_test(tls, 100, ts+2760 /* "%d INSERTs into ..." */, libc.VaList(bp, n)) speedtest1_exec(tls, ts+2796 /* "BEGIN" */, 0) @@ -4900,7 +5555,7 @@ func testset_main(tls *libc.TLS) { /* speedtest1.c:694:6: */ for i = 1; i <= n; i++ { if ((i - 1) % g.nRepeat) == 0 { x1 = (speedtest1_random(tls) % uint32(maxb)) - *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */ + uintptr(0))) = int8('%') + *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */)) = int8('%') len = speedtest1_numbername(tls, uint32(i), (bp + 568 /* &zNum[0] */ + uintptr(1)), (int32(uint64(unsafe.Sizeof([2000]int8{})) - uint64(2)))) *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */ + uintptr(len))) = int8('%') *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */ + uintptr((len + 1)))) = int8(0) @@ -4920,7 +5575,7 @@ func testset_main(tls *libc.TLS) { /* speedtest1.c:694:6: */ for i = 1; i <= n; i++ { if ((i - 1) % g.nRepeat) == 0 { x1 = (speedtest1_random(tls) % uint32(maxb)) - *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */ + uintptr(0))) = int8('%') + *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */)) = int8('%') len = speedtest1_numbername(tls, uint32(i), (bp + 568 /* &zNum[0] */ + uintptr(1)), (int32(uint64(unsafe.Sizeof([2000]int8{})) - uint64(2)))) *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */ + uintptr(len))) = int8('%') *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */ + uintptr((len + 1)))) = int8(0) @@ -4940,7 +5595,7 @@ func testset_main(tls *libc.TLS) { /* speedtest1.c:694:6: */ for i = 1; i <= n; i++ { if ((i - 1) % g.nRepeat) == 0 { x1 = (speedtest1_random(tls) % uint32(maxb)) - *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */ + uintptr(0))) = int8('%') + *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */)) = int8('%') len = speedtest1_numbername(tls, uint32(i), (bp + 568 /* &zNum[0] */ + uintptr(1)), (int32(uint64(unsafe.Sizeof([2000]int8{})) - uint64(2)))) *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */ + uintptr(len))) = int8('%') *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */ + uintptr((len + 1)))) = int8(0) @@ -5144,7 +5799,7 @@ func testset_main(tls *libc.TLS) { /* speedtest1.c:694:6: */ speedtest1_end_test(tls) sz = libc.AssignInt32(&n, (g.szTest * 700)) - *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */ + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */)) = int8(0) maxb = int32(roundup_allones(tls, (uint32(sz / 3)))) speedtest1_begin_test(tls, 400, ts+5666 /* "%d REPLACE ops o..." */, libc.VaList(bp+456, n)) speedtest1_exec(tls, ts+2796 /* "BEGIN" */, 0) @@ -5170,7 +5825,7 @@ func testset_main(tls *libc.TLS) { /* speedtest1.c:694:6: */ speedtest1_end_test(tls) sz = libc.AssignInt32(&n, (g.szTest * 700)) - *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */ + uintptr(0))) = int8(0) + *(*int8)(unsafe.Pointer(bp + 568 /* &zNum[0] */)) = int8(0) maxb = int32(roundup_allones(tls, (uint32(sz / 3)))) speedtest1_begin_test(tls, 500, ts+5846 /* "%d REPLACE on TE..." */, libc.VaList(bp+504, n)) speedtest1_exec(tls, ts+2796 /* "BEGIN" */, 0) @@ -5402,8 +6057,8 @@ func twoCoords(tls *libc.TLS, p1 int32, p2 int32, mx uint32, pX0 uintptr, pX1 ui // // SELECT count(*) FROM rt1 WHERE y1>=10 AND y0<=20; func xsliceGeometryCallback(tls *libc.TLS, p uintptr, nCoord int32, aCoord uintptr, pRes uintptr) int32 { /* speedtest1.c:1412:12: */ - *(*int32)(unsafe.Pointer(pRes)) = (libc.Bool32((*(*float64)(unsafe.Pointer(aCoord + uintptr(3)*8)) >= *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).aParam + uintptr(0)*8))) && (*(*float64)(unsafe.Pointer(aCoord + uintptr(2)*8)) <= *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).aParam + uintptr(1)*8))))) - return 0 + *(*int32)(unsafe.Pointer(pRes)) = (libc.Bool32((*(*float64)(unsafe.Pointer(aCoord + 3*8)) >= *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).aParam))) && (*(*float64)(unsafe.Pointer(aCoord + 2*8)) <= *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).aParam + 1*8))))) + return SQLITE_OK } // A testset for the R-Tree virtual table @@ -5643,7 +6298,7 @@ func testset_orm(tls *libc.TLS) { /* speedtest1.c:1612:6: */ fallthrough case 'B': sqlite3.Xsqlite3_bind_text64(tls, g.pStmt, (int32(j + uint32(2))), bp+16 /* &zNum[0] */, uint64(len), - uintptr(0), uint8(1)) + uintptr(0), SQLITE_UTF8) break } } @@ -5665,7 +6320,9 @@ func testset_orm(tls *libc.TLS) { /* speedtest1.c:1612:6: */ speedtest1_end_test(tls) } -var zType = *(*[120]int8)(unsafe.Pointer(ts + 20757 /* "IBBIIITIVVITBTBF..." */)) /* speedtest1.c:1617:21 */ +var zType = // Types for all non-PK columns, in order + +*(*[120]int8)(unsafe.Pointer(ts + 20757 /* "IBBIIITIVVITBTBF..." */)) /* speedtest1.c:1617:21 */ // func testset_trigger(tls *libc.TLS) { /* speedtest1.c:1879:6: */ @@ -5930,35 +6587,21 @@ var aTrans = [7]struct { zPattern uintptr zDesc uintptr }{ - { - zPattern: ts + 22739, /* "rchar: " */ - zDesc: ts + 22747 /* "Bytes received b..." */}, - { - zPattern: ts + 22773, /* "wchar: " */ - zDesc: ts + 22781 /* "Bytes sent to wr..." */}, - { - zPattern: ts + 22804, /* "syscr: " */ - zDesc: ts + 22812 /* "Read() system ca..." */}, - { - zPattern: ts + 22833, /* "syscw: " */ - zDesc: ts + 22841 /* "Write() system c..." */}, - { - zPattern: ts + 22863, /* "read_bytes: " */ - zDesc: ts + 22876 /* "Bytes rcvd from ..." */}, - { - zPattern: ts + 22901, /* "write_bytes: " */ - zDesc: ts + 22915 /* "Bytes sent to st..." */}, - { - zPattern: ts + 22938, /* "cancelled_write_..." */ - zDesc: ts + 22962 /* "Cancelled write ..." */}, + {zPattern: ts + 22739 /* "rchar: " */, zDesc: ts + 22747 /* "Bytes received b..." */}, + {zPattern: ts + 22773 /* "wchar: " */, zDesc: ts + 22781 /* "Bytes sent to wr..." */}, + {zPattern: ts + 22804 /* "syscr: " */, zDesc: ts + 22812 /* "Read() system ca..." */}, + {zPattern: ts + 22833 /* "syscw: " */, zDesc: ts + 22841 /* "Write() system c..." */}, + {zPattern: ts + 22863 /* "read_bytes: " */, zDesc: ts + 22876 /* "Bytes rcvd from ..." */}, + {zPattern: ts + 22901 /* "write_bytes: " */, zDesc: ts + 22915 /* "Bytes sent to st..." */}, + {zPattern: ts + 22938 /* "cancelled_write_..." */, zDesc: ts + 22962 /* "Cancelled write ..." */}, } /* speedtest1.c:2112:7 */ func xCompileOptions(tls *libc.TLS, pCtx uintptr, nVal int32, azVal uintptr, azCol uintptr) int32 { /* speedtest1.c:2138:12: */ bp := tls.Alloc(8) defer tls.Free(8) - libc.Xprintf(tls, ts+22985 /* "-- Compile optio..." */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(azVal + uintptr(0)*8)))) - return 0 + libc.Xprintf(tls, ts+22985 /* "-- Compile optio..." */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(azVal)))) + return SQLITE_OK } func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143:5: */ @@ -6011,8 +6654,8 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143 g.nRepeat = 1 for i = 1; i < argc; i++ { var z uintptr = *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) - if int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '-' { - for ok := true; ok; ok = (int32(*(*int8)(unsafe.Pointer(z + uintptr(0)))) == '-') { + if int32(*(*int8)(unsafe.Pointer(z))) == '-' { + for ok := true; ok; ok = (int32(*(*int8)(unsafe.Pointer(z))) == '-') { z++ } if libc.Xstrcmp(tls, z, ts+23055 /* "autovacuum" */) == 0 { @@ -6059,9 +6702,9 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143 } else if libc.Xstrcmp(tls, z, ts+23192 /* "memdb" */) == 0 { memDb = 1 } else if libc.Xstrcmp(tls, z, ts+23198 /* "multithread" */) == 0 { - sqlite3.Xsqlite3_config(tls, 2, 0) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MULTITHREAD, 0) } else if libc.Xstrcmp(tls, z, ts+23210 /* "nomemstat" */) == 0 { - sqlite3.Xsqlite3_config(tls, 9, libc.VaList(bp+56, 0)) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MEMSTATUS, libc.VaList(bp+56, 0)) } else if libc.Xstrcmp(tls, z, ts+23220 /* "mmap" */) == 0 { if i >= (argc - 1) { fatal_error(tls, ts+23076 /* "missing argument..." */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) @@ -6108,9 +6751,9 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143 } else if libc.Xstrcmp(tls, z, ts+23337 /* "reprepare" */) == 0 { g.bReprepare = 1 } else if libc.Xstrcmp(tls, z, ts+23347 /* "serialized" */) == 0 { - sqlite3.Xsqlite3_config(tls, 3, 0) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_SERIALIZED, 0) } else if libc.Xstrcmp(tls, z, ts+23358 /* "singlethread" */) == 0 { - sqlite3.Xsqlite3_config(tls, 1, 0) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_SINGLETHREAD, 0) } else if libc.Xstrcmp(tls, z, ts+23371 /* "sqlonly" */) == 0 { g.bSqlOnly = 1 } else if libc.Xstrcmp(tls, z, ts+23379 /* "shrink-memory" */) == 0 { @@ -6127,10 +6770,10 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143 fatal_error(tls, ts+23076 /* "missing argument..." */, libc.VaList(bp+120, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) } i++ - if ((int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) + uintptr(0)))) < '0') || (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) + uintptr(0)))) > '9')) || (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) + uintptr(1)))) != 0) { + if ((int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))))) < '0') || (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))))) > '9')) || (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) + 1))) != 0) { fatal_error(tls, ts+23409 /* "argument to --te..." */, 0) } - g.eTemp = (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) + uintptr(0)))) - '0') + g.eTemp = (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))))) - '0') } else if libc.Xstrcmp(tls, z, ts+23462 /* "testset" */) == 0 { if i >= (argc - 1) { fatal_error(tls, ts+23076 /* "missing argument..." */, libc.VaList(bp+128, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) @@ -6154,17 +6797,17 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143 g.zWR = ts + 5915 /* "WITHOUT ROWID" */ g.zPK = ts + 23318 /* "PRIMARY KEY" */ } else if (libc.Xstrcmp(tls, z, ts+23521 /* "help" */) == 0) || (libc.Xstrcmp(tls, z, ts+23526 /* "?" */) == 0) { - libc.Xprintf(tls, uintptr(unsafe.Pointer(&zHelp)), libc.VaList(bp+144, *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + libc.Xprintf(tls, uintptr(unsafe.Pointer(&zHelp)), libc.VaList(bp+144, *(*uintptr)(unsafe.Pointer(argv)))) libc.Xexit(tls, 0) } else { fatal_error(tls, ts+23528, /* "unknown option: ..." */ - libc.VaList(bp+152, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + libc.VaList(bp+152, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(argv)))) } } else if zDbName == uintptr(0) { zDbName = *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) } else { fatal_error(tls, ts+23569, /* "surplus argument..." */ - libc.VaList(bp+168, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(0)*8)))) + libc.VaList(bp+168, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), *(*uintptr)(unsafe.Pointer(argv)))) } } if zDbName != uintptr(0) { @@ -6175,7 +6818,7 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143 if pHeap == uintptr(0) { fatal_error(tls, ts+23612 /* "cannot allocate ..." */, libc.VaList(bp+184, nHeap)) } - rc = sqlite3.Xsqlite3_config(tls, 8, libc.VaList(bp+192, pHeap, nHeap, mnHeap)) + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_HEAP, libc.VaList(bp+192, pHeap, nHeap, mnHeap)) if rc != 0 { fatal_error(tls, ts+23642 /* "heap configurati..." */, libc.VaList(bp+216, rc)) } @@ -6188,13 +6831,13 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143 libc.VaList(bp+224, (sqlite3_int64(nPCache)*sqlite3_int64(szPCache)))) } } - rc = sqlite3.Xsqlite3_config(tls, 7, libc.VaList(bp+232, pPCache, szPCache, nPCache)) + rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PAGECACHE, libc.VaList(bp+232, pPCache, szPCache, nPCache)) if rc != 0 { fatal_error(tls, ts+23707 /* "pcache configura..." */, libc.VaList(bp+256, rc)) } } if nLook >= 0 { - sqlite3.Xsqlite3_config(tls, 13, libc.VaList(bp+264, 0, 0)) + sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_LOOKASIDE, libc.VaList(bp+264, 0, 0)) } sqlite3.Xsqlite3_initialize(tls) @@ -6209,14 +6852,14 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143 } if (nLook > 0) && (szLook > 0) { pLook = libc.Xmalloc(tls, (uint64(nLook * szLook))) - rc = sqlite3.Xsqlite3_db_config(tls, g.db, 1001, libc.VaList(bp+288, pLook, szLook, nLook)) + rc = sqlite3.Xsqlite3_db_config(tls, g.db, SQLITE_DBCONFIG_LOOKASIDE, libc.VaList(bp+288, pLook, szLook, nLook)) if rc != 0 { fatal_error(tls, ts+23780 /* "lookaside config..." */, libc.VaList(bp+312, rc)) } } // Set database connection options - sqlite3.Xsqlite3_create_function(tls, g.db, ts+23816 /* "random" */, 0, 1, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { + sqlite3.Xsqlite3_create_function(tls, g.db, ts+23816 /* "random" */, 0, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { f func(*libc.TLS, uintptr, int32, uintptr) }{randomFunc})), uintptr(0), uintptr(0)) if doTrace != 0 { @@ -6261,7 +6904,7 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143 if g.bExplain != 0 { libc.Xprintf(tls, ts+24094 /* ".explain\n.echo o..." */, 0) } - for ok1 := true; ok1; ok1 = *(*int8)(unsafe.Pointer(zTSet + uintptr(0))) != 0 { + for ok1 := true; ok1; ok1 = *(*int8)(unsafe.Pointer(zTSet)) != 0 { var zThisTest uintptr = zTSet var zComma uintptr = libc.Xstrchr(tls, zThisTest, ',') if zComma != 0 { @@ -6292,7 +6935,7 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143 ts+24172, /* "unknown testset:..." */ libc.VaList(bp+384, zThisTest)) } - if *(*int8)(unsafe.Pointer(zTSet + uintptr(0))) != 0 { + if *(*int8)(unsafe.Pointer(zTSet)) != 0 { var zSql uintptr var zObj uintptr speedtest1_begin_test(tls, 999, ts+24241 /* "Reset the databa..." */, 0) @@ -6334,25 +6977,25 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143 // Database connection statistics printed after both prepared statements // have been finalized if showStats != 0 { - sqlite3.Xsqlite3_db_status(tls, g.db, 0, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) + sqlite3.Xsqlite3_db_status(tls, g.db, SQLITE_DBSTATUS_LOOKASIDE_USED, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) libc.Xprintf(tls, ts+24444 /* "-- Lookaside Slo..." */, libc.VaList(bp+408, *(*int32)(unsafe.Pointer(bp + 560 /* iCur */)), *(*int32)(unsafe.Pointer(bp + 564 /* iHi */)))) - sqlite3.Xsqlite3_db_status(tls, g.db, 4, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) + sqlite3.Xsqlite3_db_status(tls, g.db, SQLITE_DBSTATUS_LOOKASIDE_HIT, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) libc.Xprintf(tls, ts+24489 /* "-- Successful lo..." */, libc.VaList(bp+424, *(*int32)(unsafe.Pointer(bp + 564 /* iHi */)))) - sqlite3.Xsqlite3_db_status(tls, g.db, 5, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) + sqlite3.Xsqlite3_db_status(tls, g.db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) libc.Xprintf(tls, ts+24525 /* "-- Lookaside siz..." */, libc.VaList(bp+432, *(*int32)(unsafe.Pointer(bp + 564 /* iHi */)))) - sqlite3.Xsqlite3_db_status(tls, g.db, 6, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) + sqlite3.Xsqlite3_db_status(tls, g.db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) libc.Xprintf(tls, ts+24561 /* "-- Lookaside OOM..." */, libc.VaList(bp+440, *(*int32)(unsafe.Pointer(bp + 564 /* iHi */)))) - sqlite3.Xsqlite3_db_status(tls, g.db, 1, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) + sqlite3.Xsqlite3_db_status(tls, g.db, SQLITE_DBSTATUS_CACHE_USED, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) libc.Xprintf(tls, ts+24597 /* "-- Pager Heap Us..." */, libc.VaList(bp+448, *(*int32)(unsafe.Pointer(bp + 560 /* iCur */)))) - sqlite3.Xsqlite3_db_status(tls, g.db, 7, bp+560 /* &iCur */, bp+564 /* &iHi */, 1) + sqlite3.Xsqlite3_db_status(tls, g.db, SQLITE_DBSTATUS_CACHE_HIT, bp+560 /* &iCur */, bp+564 /* &iHi */, 1) libc.Xprintf(tls, ts+24639 /* "-- Page cache hi..." */, libc.VaList(bp+456, *(*int32)(unsafe.Pointer(bp + 560 /* iCur */)))) - sqlite3.Xsqlite3_db_status(tls, g.db, 8, bp+560 /* &iCur */, bp+564 /* &iHi */, 1) + sqlite3.Xsqlite3_db_status(tls, g.db, SQLITE_DBSTATUS_CACHE_MISS, bp+560 /* &iCur */, bp+564 /* &iHi */, 1) libc.Xprintf(tls, ts+24675 /* "-- Page cache mi..." */, libc.VaList(bp+464, *(*int32)(unsafe.Pointer(bp + 560 /* iCur */)))) - sqlite3.Xsqlite3_db_status(tls, g.db, 9, bp+560 /* &iCur */, bp+564 /* &iHi */, 1) + sqlite3.Xsqlite3_db_status(tls, g.db, SQLITE_DBSTATUS_CACHE_WRITE, bp+560 /* &iCur */, bp+564 /* &iHi */, 1) libc.Xprintf(tls, ts+24711 /* "-- Page cache wr..." */, libc.VaList(bp+472, *(*int32)(unsafe.Pointer(bp + 560 /* iCur */)))) - sqlite3.Xsqlite3_db_status(tls, g.db, 2, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) + sqlite3.Xsqlite3_db_status(tls, g.db, SQLITE_DBSTATUS_SCHEMA_USED, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) libc.Xprintf(tls, ts+24747 /* "-- Schema Heap U..." */, libc.VaList(bp+480, *(*int32)(unsafe.Pointer(bp + 560 /* iCur */)))) - sqlite3.Xsqlite3_db_status(tls, g.db, 3, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) + sqlite3.Xsqlite3_db_status(tls, g.db, SQLITE_DBSTATUS_STMT_USED, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) libc.Xprintf(tls, ts+24789 /* "-- Statement Hea..." */, libc.VaList(bp+488, *(*int32)(unsafe.Pointer(bp + 560 /* iCur */)))) } @@ -6361,15 +7004,15 @@ func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* speedtest1.c:2143 // Global memory usage statistics printed after the database connection // has closed. Memory usage should be zero at this point. if showStats != 0 { - sqlite3.Xsqlite3_status(tls, 0, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) + sqlite3.Xsqlite3_status(tls, SQLITE_STATUS_MEMORY_USED, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) libc.Xprintf(tls, ts+24831 /* "-- Memory Used (..." */, libc.VaList(bp+496, *(*int32)(unsafe.Pointer(bp + 560 /* iCur */)), *(*int32)(unsafe.Pointer(bp + 564 /* iHi */)))) - sqlite3.Xsqlite3_status(tls, 9, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) + sqlite3.Xsqlite3_status(tls, SQLITE_STATUS_MALLOC_COUNT, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) libc.Xprintf(tls, ts+24876 /* "-- Outstanding A..." */, libc.VaList(bp+512, *(*int32)(unsafe.Pointer(bp + 560 /* iCur */)), *(*int32)(unsafe.Pointer(bp + 564 /* iHi */)))) - sqlite3.Xsqlite3_status(tls, 2, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) + sqlite3.Xsqlite3_status(tls, SQLITE_STATUS_PAGECACHE_OVERFLOW, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) libc.Xprintf(tls, ts+24921 /* "-- Pcache Overfl..." */, libc.VaList(bp+528, *(*int32)(unsafe.Pointer(bp + 560 /* iCur */)), *(*int32)(unsafe.Pointer(bp + 564 /* iHi */)))) - sqlite3.Xsqlite3_status(tls, 5, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) + sqlite3.Xsqlite3_status(tls, SQLITE_STATUS_MALLOC_SIZE, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) libc.Xprintf(tls, ts+24966 /* "-- Largest Alloc..." */, libc.VaList(bp+544, *(*int32)(unsafe.Pointer(bp + 564 /* iHi */)))) - sqlite3.Xsqlite3_status(tls, 7, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) + sqlite3.Xsqlite3_status(tls, SQLITE_STATUS_PAGECACHE_SIZE, bp+560 /* &iCur */, bp+564 /* &iHi */, 0) libc.Xprintf(tls, ts+25008 /* "-- Largest Pcach..." */, libc.VaList(bp+552, *(*int32)(unsafe.Pointer(bp + 564 /* iHi */)))) }